Skip to content

Commit

Permalink
Export all unwrapped React Material renderers
Browse files Browse the repository at this point in the history
Previously only the control renderers were made available unwrapped. Now all unwrapped
React Material renderers are exported.

Implements #1687

Contributed on behalf of STMicroelectronics
  • Loading branch information
sdirix committed Apr 21, 2023
1 parent 8c82d78 commit d4f629b
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
import DeleteIcon from '@mui/icons-material/Delete';
import React from 'react';

const ListWithDetailMasterItem = ({
export const ListWithDetailMasterItem = ({
index,
childLabel,
selected,
Expand Down
12 changes: 10 additions & 2 deletions packages/material-renderers/src/additional/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@
import MaterialLabelRenderer, {
materialLabelRendererTester,
} from './MaterialLabelRenderer';
export { MaterialLabelRenderer, materialLabelRendererTester };

import MaterialListWithDetailRenderer, {
materialListWithDetailTester,
} from './MaterialListWithDetailRenderer';
export { MaterialListWithDetailRenderer, materialListWithDetailTester };

export {
MaterialLabelRenderer,
materialLabelRendererTester,
MaterialListWithDetailRenderer,
materialListWithDetailTester,
};

export * from './ListWithDetailMasterItem';
32 changes: 32 additions & 0 deletions packages/material-renderers/src/additional/unwrapped.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
The MIT License
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { MaterialLabelRenderer } from './MaterialLabelRenderer';

import { MaterialListWithDetailRenderer } from './MaterialListWithDetailRenderer';

export const UnwrappedAdditional = {
MaterialLabelRenderer,
MaterialListWithDetailRenderer,
};
10 changes: 6 additions & 4 deletions packages/material-renderers/src/complex/CombinatorProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
THE SOFTWARE.
*/
import React from 'react';
import { Generate, JsonSchema, Layout, UISchemaElement } from '@jsonforms/core';
import {
Generate,
JsonSchema,
UISchemaElement,
isLayout,
} from '@jsonforms/core';
import { JsonFormsDispatch } from '@jsonforms/react';
import omit from 'lodash/omit';

Expand All @@ -33,9 +38,6 @@ interface CombinatorPropertiesProps {
path: string;
}

export const isLayout = (uischema: UISchemaElement): uischema is Layout =>
uischema.hasOwnProperty('elements');

export class CombinatorProperties extends React.Component<
CombinatorPropertiesProps,
// TODO fix @typescript-eslint/ban-types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
THE SOFTWARE.
*/
import React, { useCallback, useState } from 'react';
import { ArrayLayoutProps } from '@jsonforms/core';
import {
ArrayLayoutProps,
RankedTester,
isObjectArrayControl,
isPrimitiveArrayControl,
or,
rankWith,
} from '@jsonforms/core';
import { withJsonFormsArrayLayoutProps } from '@jsonforms/react';
import { MaterialTableControl } from './MaterialTableControl';
import { Hidden } from '@mui/material';
Expand Down Expand Up @@ -68,4 +75,9 @@ export const MaterialArrayControlRenderer = (props: ArrayLayoutProps) => {
);
};

export const materialArrayControlTester: RankedTester = rankWith(
3,
or(isObjectArrayControl, isPrimitiveArrayControl)
);

export default withJsonFormsArrayLayoutProps(MaterialArrayControlRenderer);
59 changes: 31 additions & 28 deletions packages/material-renderers/src/complex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,45 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import {
isObjectArrayControl,
isPrimitiveArrayControl,
or,
RankedTester,
rankWith,
} from '@jsonforms/core';
import MaterialArrayControlRenderer from './MaterialArrayControlRenderer';
import MaterialObjectRenderer, {
materialObjectControlTester,
} from './MaterialObjectRenderer';
import MaterialAllOfRenderer, {
materialAllOfControlTester,
} from './MaterialAllOfRenderer';
import MaterialAnyOfRenderer, {
materialAnyOfControlTester,
} from './MaterialAnyOfRenderer';
import MaterialArrayControlRenderer, {
materialArrayControlTester,
} from './MaterialArrayControlRenderer';
import MaterialEnumArrayRenderer, {
materialEnumArrayRendererTester,
} from './MaterialEnumArrayRenderer';
import MaterialObjectRenderer, {
materialObjectControlTester,
} from './MaterialObjectRenderer';
import MaterialOneOfRenderer, {
materialOneOfControlTester,
} from './MaterialOneOfRenderer';
import MaterialEnumArrayRenderer, {

export {
materialAllOfControlTester,
MaterialAllOfRenderer,
materialAnyOfControlTester,
MaterialAnyOfRenderer,
materialArrayControlTester,
MaterialArrayControlRenderer,
materialEnumArrayRendererTester,
} from './MaterialEnumArrayRenderer';
MaterialEnumArrayRenderer,
materialObjectControlTester,
MaterialObjectRenderer,
materialOneOfControlTester,
MaterialOneOfRenderer,
};

export * from './CombinatorProperties';
export * from './DeleteDialog';
export * from './MaterialTableControl';
export * from './TableToolbar';
export * from './ValidationIcon';

export const materialArrayControlTester: RankedTester = rankWith(
3,
or(isObjectArrayControl, isPrimitiveArrayControl)
);
export { MaterialArrayControlRenderer };
export { MaterialObjectRenderer };
export { MaterialAllOfRenderer };
export { MaterialAnyOfRenderer };
export { MaterialOneOfRenderer };
export { MaterialEnumArrayRenderer };
export { materialObjectControlTester };
export { materialAllOfControlTester };
export { materialAnyOfControlTester };
export { materialOneOfControlTester };
export { materialEnumArrayRendererTester };
import NoBorderTableCell from './NoBorderTableCell';
export { NoBorderTableCell };
39 changes: 39 additions & 0 deletions packages/material-renderers/src/complex/unwrapped.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
The MIT License
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { MaterialAllOfRenderer } from './MaterialAllOfRenderer';
import { MaterialAnyOfRenderer } from './MaterialAnyOfRenderer';
import { MaterialArrayControlRenderer } from './MaterialArrayControlRenderer';
import { MaterialEnumArrayRenderer } from './MaterialEnumArrayRenderer';
import { MaterialObjectRenderer } from './MaterialObjectRenderer';
import { MaterialOneOfRenderer } from './MaterialOneOfRenderer';

export const UnwrappedComplex = {
MaterialAllOfRenderer,
MaterialAnyOfRenderer,
MaterialArrayControlRenderer,
MaterialEnumArrayRenderer,
MaterialObjectRenderer,
MaterialOneOfRenderer,
};
106 changes: 35 additions & 71 deletions packages/material-renderers/src/controls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,119 +22,83 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import MaterialAnyOfStringOrEnumControl, {
materialAnyOfStringOrEnumControlTester,
} from './MaterialAnyOfStringOrEnumControl';
import MaterialBooleanControl, {
materialBooleanControlTester,
MaterialBooleanControl as MaterialBooleanControlUnwrapped,
} from './MaterialBooleanControl';
import MaterialBooleanToggleControl, {
materialBooleanToggleControlTester,
MaterialBooleanToggleControl as MaterialBooleanToggleControlUnwrapped,
} from './MaterialBooleanToggleControl';
import MaterialEnumControl, {
materialEnumControlTester,
MaterialEnumControl as MaterialEnumControlUnwrapped,
} from './MaterialEnumControl';
import MaterialNativeControl, {
materialNativeControlTester,
MaterialNativeControl as MaterialNativeControlUnwrapped,
} from './MaterialNativeControl';
import MaterialDateControl, {
materialDateControlTester,
MaterialDateControl as MaterialDateControlUnwrapped,
} from './MaterialDateControl';
import MaterialDateTimeControl, {
materialDateTimeControlTester,
MaterialDateTimeControl as MaterialDateTimeControlUnwrapped,
} from './MaterialDateTimeControl';
import MaterialTimeControl, {
materialTimeControlTester,
MaterialTimeControl as MaterialTimeControlUnwrapped,
} from './MaterialTimeControl';
import MaterialSliderControl, {
materialSliderControlTester,
MaterialSliderControl as MaterialSliderControlUnwrapped,
} from './MaterialSliderControl';
import MaterialRadioGroupControl, {
materialRadioGroupControlTester,
MaterialRadioGroupControl as MaterialRadioGroupControlUnwrapped,
} from './MaterialRadioGroupControl';
import MaterialEnumControl, {
materialEnumControlTester,
} from './MaterialEnumControl';
import MaterialIntegerControl, {
materialIntegerControlTester,
MaterialIntegerControl as MaterialIntegerControlUnwrapped,
} from './MaterialIntegerControl';
import MaterialNativeControl, {
materialNativeControlTester,
} from './MaterialNativeControl';
import MaterialNumberControl, {
materialNumberControlTester,
MaterialNumberControl as MaterialNumberControlUnwrapped,
} from './MaterialNumberControl';
import MaterialTextControl, {
materialTextControlTester,
MaterialTextControl as MaterialTextControlUnwrapped,
} from './MaterialTextControl';

import MaterialAnyOfStringOrEnumControl, {
materialAnyOfStringOrEnumControlTester,
MaterialAnyOfStringOrEnumControl as MaterialAnyOfStringOrEnumControlUnwrapped,
} from './MaterialAnyOfStringOrEnumControl';

import MaterialOneOfEnumControl, {
materialOneOfEnumControlTester,
MaterialOneOfEnumControl as MaterialOneOfEnumControlUnwrapped,
} from './MaterialOneOfEnumControl';

import MaterialOneOfRadioGroupControl, {
materialOneOfRadioGroupControlTester,
MaterialOneOfRadioGroupControl as MaterialOneOfRadioGroupControlUnwrapped,
} from './MaterialOneOfRadioGroupControl';

export const Unwrapped = {
MaterialBooleanControl: MaterialBooleanControlUnwrapped,
MaterialBooleanToggleControl: MaterialBooleanToggleControlUnwrapped,
MaterialEnumControl: MaterialEnumControlUnwrapped,
MaterialNativeControl: MaterialNativeControlUnwrapped,
MaterialDateControl: MaterialDateControlUnwrapped,
MaterialDateTimeControl: MaterialDateTimeControlUnwrapped,
MaterialTimeControl: MaterialTimeControlUnwrapped,
MaterialSliderControl: MaterialSliderControlUnwrapped,
MaterialRadioGroupControl: MaterialRadioGroupControlUnwrapped,
MaterialIntegerControl: MaterialIntegerControlUnwrapped,
MaterialNumberControl: MaterialNumberControlUnwrapped,
MaterialTextControl: MaterialTextControlUnwrapped,
MaterialAnyOfStringOrEnumControl: MaterialAnyOfStringOrEnumControlUnwrapped,
MaterialOneOfEnumControl: MaterialOneOfEnumControlUnwrapped,
MaterialOneOfRadioGroupControl: MaterialOneOfRadioGroupControlUnwrapped,
};
import MaterialRadioGroupControl, {
materialRadioGroupControlTester,
} from './MaterialRadioGroupControl';
import MaterialSliderControl, {
materialSliderControlTester,
} from './MaterialSliderControl';
import MaterialTextControl, {
materialTextControlTester,
} from './MaterialTextControl';
import MaterialTimeControl, {
materialTimeControlTester,
} from './MaterialTimeControl';

export {
MaterialAnyOfStringOrEnumControl,
materialAnyOfStringOrEnumControlTester,
MaterialBooleanControl,
materialBooleanControlTester,
MaterialBooleanToggleControl,
materialBooleanToggleControlTester,
MaterialEnumControl,
materialEnumControlTester,
MaterialNativeControl,
materialNativeControlTester,
MaterialDateControl,
materialDateControlTester,
MaterialDateTimeControl,
materialDateTimeControlTester,
MaterialTimeControl,
materialTimeControlTester,
MaterialSliderControl,
materialSliderControlTester,
MaterialRadioGroupControl,
materialRadioGroupControlTester,
MaterialEnumControl,
materialEnumControlTester,
MaterialIntegerControl,
materialIntegerControlTester,
MaterialNativeControl,
materialNativeControlTester,
MaterialNumberControl,
materialNumberControlTester,
MaterialTextControl,
materialTextControlTester,
MaterialAnyOfStringOrEnumControl,
materialAnyOfStringOrEnumControlTester,
MaterialOneOfEnumControl,
materialOneOfEnumControlTester,
MaterialOneOfRadioGroupControl,
materialOneOfRadioGroupControlTester,
MaterialRadioGroupControl,
materialRadioGroupControlTester,
MaterialSliderControl,
materialSliderControlTester,
MaterialTextControl,
materialTextControlTester,
MaterialTimeControl,
materialTimeControlTester,
};

export * from './MaterialInputControl';
Loading

0 comments on commit d4f629b

Please sign in to comment.