@jsonforms/material-renderers 3.0.0-beta.1 → 3.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -13
- package/docs/globals.html +55 -85
- package/docs/index.html +70 -13
- package/docs/interfaces/emptytableprops.html +1 -1
- package/docs/interfaces/nonemptycellcomponentprops.html +9 -9
- package/docs/interfaces/nonemptycellprops.html +9 -9
- package/docs/interfaces/ownoneofprops.html +1 -1
- package/docs/interfaces/ownpropsofnonemptycell.html +6 -6
- package/docs/interfaces/tableheadercellprops.html +1 -1
- package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
- package/lib/jsonforms-react-material.cjs.js +20 -28
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +19 -27
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
- package/package.json +8 -6
- package/src/additional/MaterialListWithDetailRenderer.tsx +5 -3
- package/src/complex/MaterialAllOfRenderer.tsx +3 -5
- package/src/complex/MaterialAnyOfRenderer.tsx +3 -5
- package/src/complex/MaterialEnumArrayRenderer.tsx +1 -2
- package/src/complex/MaterialObjectRenderer.tsx +3 -8
- package/src/complex/MaterialOneOfRenderer.tsx +3 -5
- package/src/complex/MaterialTableControl.tsx +6 -6
- package/src/layouts/ExpandPanelRenderer.tsx +2 -1
- package/src/layouts/MaterialArrayLayoutRenderer.tsx +3 -25
- package/stats.html +1 -1
- package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +7 -7
- package/test/renderers/MaterialArrayLayout.test.tsx +66 -8
- package/test/renderers/MaterialBooleanCell.test.tsx +10 -7
- package/test/renderers/MaterialBooleanToggleCell.test.tsx +14 -9
- package/test/renderers/MaterialBooleanToggleControl.test.tsx +14 -9
- package/test/renderers/MaterialCategorizationLayout.test.tsx +12 -12
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +12 -12
- package/test/renderers/MaterialDateCell.test.tsx +10 -7
- package/test/renderers/MaterialDateControl.test.tsx +12 -8
- package/test/renderers/MaterialDateTimeControl.test.tsx +12 -8
- package/test/renderers/MaterialEnumArrayRenderer.test.tsx +9 -7
- package/test/renderers/MaterialEnumCell.test.tsx +2 -1
- package/test/renderers/MaterialEnumControl.test.tsx +75 -0
- package/test/renderers/MaterialIntegerCell.test.tsx +10 -7
- package/test/renderers/MaterialLabelRenderer.test.tsx +4 -4
- package/test/renderers/MaterialListWithDetailRenderer.test.tsx +5 -5
- package/test/renderers/MaterialNumberCell.test.tsx +10 -7
- package/test/renderers/MaterialObjectControl.test.tsx +10 -7
- package/test/renderers/MaterialOneOfEnumCell.test.tsx +2 -1
- package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +3 -2
- package/test/renderers/MaterialOneOfRenderer.test.tsx +12 -7
- package/test/renderers/MaterialRadioGroupControl.test.tsx +2 -2
- package/test/renderers/MaterialSliderControl.test.tsx +20 -12
- package/test/renderers/MaterialTextCell.test.tsx +10 -7
- package/test/renderers/MaterialTimeCell.test.tsx +10 -7
- package/test/renderers/MaterialTimeControl.test.tsx +12 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createDefaultValue, Resolve, Paths, formatErrorMessage, errorsAt, rankWith, isObjectControl, findUISchema,
|
|
1
|
+
import { createDefaultValue, Resolve, encode, Paths, formatErrorMessage, errorsAt, rankWith, isObjectControl, findUISchema, Generate, isAllOfControl, findMatchingUISchema, createCombinatorRenderInfos, isAnyOfControl, isOneOfControl, getAjv, and, uiTypeIs, schemaMatches, hasType, schemaSubPathMatches, or, isObjectArrayControl, isPrimitiveArrayControl, isObjectArray, computeLabel, composePaths, isBooleanControl, optionIs, isDescriptionHidden, showAsRequired, isEnumControl, isDateControl, isTimeControl, isDateTimeControl, isRangeControl, isIntegerControl, isNumberControl, isStringControl, isOneOfEnumControl, withIncreasedRank, isVisible, update, moveUp, moveDown, getFirstPrimitiveProp, createId, removeId, isObjectArrayWithNesting, isNumberFormatControl, categorizationHasCategory } from '@jsonforms/core';
|
|
2
2
|
import React, { useMemo, Fragment, useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { DispatchCell, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsDetailProps, JsonFormsDispatch, withJsonFormsAllOfProps, withJsonFormsAnyOfProps, withJsonFormsOneOfProps, withJsonFormsMultiEnumProps, withJsonFormsLayoutProps, withJsonFormsMasterListItemProps, withJsonFormsControlProps, withJsonFormsEnumProps, Control, withJsonFormsOneOfEnumProps, withJsonFormsContext, withJsonFormsCellProps, withJsonFormsEnumCellProps, withJsonFormsOneOfEnumCellProps } from '@jsonforms/react';
|
|
4
4
|
import isEmpty from 'lodash/isEmpty';
|
|
@@ -132,7 +132,7 @@ const controlWithoutLabel = (scope) => ({
|
|
|
132
132
|
});
|
|
133
133
|
const NonEmptyCellComponent = React.memo(({ path, propName, schema, rootSchema, errors, enabled, renderers, cells, isValid }) => {
|
|
134
134
|
return (React.createElement(NoBorderTableCell, null,
|
|
135
|
-
schema.properties ? (React.createElement(DispatchCell, { schema: Resolve.schema(schema, `#/properties/${propName}`, rootSchema), uischema: controlWithoutLabel(`#/properties/${propName}`), path: path, enabled: enabled, renderers: renderers, cells: cells })) : (React.createElement(DispatchCell, { schema: schema, uischema: controlWithoutLabel('#'), path: path, enabled: enabled, renderers: renderers, cells: cells })),
|
|
135
|
+
schema.properties ? (React.createElement(DispatchCell, { schema: Resolve.schema(schema, `#/properties/${encode(propName)}`, rootSchema), uischema: controlWithoutLabel(`#/properties/${encode(propName)}`), path: path, enabled: enabled, renderers: renderers, cells: cells })) : (React.createElement(DispatchCell, { schema: schema, uischema: controlWithoutLabel('#'), path: path, enabled: enabled, renderers: renderers, cells: cells })),
|
|
136
136
|
React.createElement(FormHelperText, { error: !isValid }, !isValid && errors)));
|
|
137
137
|
});
|
|
138
138
|
const NonEmptyCell = (ownProps) => {
|
|
@@ -168,7 +168,7 @@ const TableRows = ({ data, path, schema, openDeleteDialog, moveUp, moveDown, uis
|
|
|
168
168
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
169
169
|
return (React.createElement(React.Fragment, null, range(data).map((index) => {
|
|
170
170
|
const childPath = Paths.compose(path, `${index}`);
|
|
171
|
-
return (React.createElement(NonEmptyRow, { key: childPath, childPath: childPath, rowIndex: index, schema: schema, openDeleteDialog: openDeleteDialog, moveUpCreator: moveUp, moveDownCreator: moveDown, enableUp: index !== 0, enableDown: index !== data - 1, showSortButtons: appliedUiSchemaOptions.showSortButtons, enabled: enabled, cells: cells, path: path }));
|
|
171
|
+
return (React.createElement(NonEmptyRow, { key: childPath, childPath: childPath, rowIndex: index, schema: schema, openDeleteDialog: openDeleteDialog, moveUpCreator: moveUp, moveDownCreator: moveDown, enableUp: index !== 0, enableDown: index !== data - 1, showSortButtons: appliedUiSchemaOptions.showSortButtons || appliedUiSchemaOptions.showArrayTableSortButtons, enabled: enabled, cells: cells, path: path }));
|
|
172
172
|
})));
|
|
173
173
|
};
|
|
174
174
|
class MaterialTableControl extends React.Component {
|
|
@@ -229,13 +229,7 @@ const MaterialArrayControlRenderer = (props) => {
|
|
|
229
229
|
var MaterialArrayControlRenderer$1 = withJsonFormsArrayLayoutProps(MaterialArrayControlRenderer);
|
|
230
230
|
|
|
231
231
|
const MaterialObjectRenderer = ({ renderers, cells, uischemas, schema, label, path, visible, enabled, uischema, rootSchema }) => {
|
|
232
|
-
const detailUiSchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, 'Group', uischema, rootSchema), [uischemas, schema, uischema.scope, path, uischema, rootSchema]);
|
|
233
|
-
if (isEmpty(path)) {
|
|
234
|
-
detailUiSchema.type = 'VerticalLayout';
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
detailUiSchema.label = label;
|
|
238
|
-
}
|
|
232
|
+
const detailUiSchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, () => isEmpty(path) ? Generate.uiSchema(schema, 'VerticalLayout') : { ...Generate.uiSchema(schema, 'Group'), label }, uischema, rootSchema), [uischemas, schema, uischema.scope, path, label, uischema, rootSchema]);
|
|
239
233
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
240
234
|
React.createElement(JsonFormsDispatch, { visible: visible, enabled: enabled, schema: schema, uischema: detailUiSchema, path: path, renderers: renderers, cells: cells })));
|
|
241
235
|
};
|
|
@@ -243,13 +237,12 @@ const materialObjectControlTester = rankWith(2, isObjectControl);
|
|
|
243
237
|
var MaterialObjectRenderer$1 = withJsonFormsDetailProps(MaterialObjectRenderer);
|
|
244
238
|
|
|
245
239
|
const MaterialAllOfRenderer = ({ schema, rootSchema, visible, renderers, cells, path, uischemas, uischema }) => {
|
|
246
|
-
const
|
|
247
|
-
const delegateUISchema = findMatchingUISchema(uischemas)(_schema, uischema.scope, path);
|
|
240
|
+
const delegateUISchema = findMatchingUISchema(uischemas)(schema, uischema.scope, path);
|
|
248
241
|
if (delegateUISchema) {
|
|
249
242
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
250
|
-
React.createElement(JsonFormsDispatch, { schema:
|
|
243
|
+
React.createElement(JsonFormsDispatch, { schema: schema, uischema: delegateUISchema, path: path, renderers: renderers, cells: cells })));
|
|
251
244
|
}
|
|
252
|
-
const allOfRenderInfos = createCombinatorRenderInfos(
|
|
245
|
+
const allOfRenderInfos = createCombinatorRenderInfos(schema.allOf, rootSchema, 'allOf', uischema, path, uischemas);
|
|
253
246
|
return (React.createElement(Hidden, { xsUp: !visible }, allOfRenderInfos.map((allOfRenderInfo, allOfIndex) => (React.createElement(JsonFormsDispatch, { key: allOfIndex, schema: allOfRenderInfo.schema, uischema: allOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells })))));
|
|
254
247
|
};
|
|
255
248
|
const materialAllOfControlTester = rankWith(3, isAllOfControl);
|
|
@@ -276,10 +269,9 @@ const MaterialAnyOfRenderer = ({ schema, rootSchema, indexOfFittingSchema, visib
|
|
|
276
269
|
const [selectedAnyOf, setSelectedAnyOf] = useState(indexOfFittingSchema || 0);
|
|
277
270
|
const handleChange = useCallback((_ev, value) => setSelectedAnyOf(value), [setSelectedAnyOf]);
|
|
278
271
|
const anyOf = 'anyOf';
|
|
279
|
-
const
|
|
280
|
-
const anyOfRenderInfos = createCombinatorRenderInfos(_schema.anyOf, rootSchema, anyOf, uischema, path, uischemas);
|
|
272
|
+
const anyOfRenderInfos = createCombinatorRenderInfos(schema.anyOf, rootSchema, anyOf, uischema, path, uischemas);
|
|
281
273
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
282
|
-
React.createElement(CombinatorProperties, { schema:
|
|
274
|
+
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: anyOf, path: path }),
|
|
283
275
|
React.createElement(Tabs, { value: selectedAnyOf, onChange: handleChange }, anyOfRenderInfos.map(anyOfRenderInfo => (React.createElement(Tab, { key: anyOfRenderInfo.label, label: anyOfRenderInfo.label })))),
|
|
284
276
|
anyOfRenderInfos.map((anyOfRenderInfo, anyOfIndex) => selectedAnyOf === anyOfIndex && (React.createElement(JsonFormsDispatch, { key: anyOfIndex, schema: anyOfRenderInfo.schema, uischema: anyOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells })))));
|
|
285
277
|
};
|
|
@@ -294,10 +286,9 @@ const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, r
|
|
|
294
286
|
const cancel = useCallback(() => {
|
|
295
287
|
setOpen(false);
|
|
296
288
|
}, [setOpen]);
|
|
297
|
-
const
|
|
298
|
-
const oneOfRenderInfos = createCombinatorRenderInfos(_schema.oneOf, rootSchema, 'oneOf', uischema, path, uischemas);
|
|
289
|
+
const oneOfRenderInfos = createCombinatorRenderInfos(schema.oneOf, rootSchema, 'oneOf', uischema, path, uischemas);
|
|
299
290
|
const openNewTab = (newIndex) => {
|
|
300
|
-
handleChange(path, createDefaultValue(
|
|
291
|
+
handleChange(path, createDefaultValue(oneOfRenderInfos[newIndex].schema));
|
|
301
292
|
setSelectedIndex(newIndex);
|
|
302
293
|
};
|
|
303
294
|
const confirm = useCallback(() => {
|
|
@@ -314,7 +305,7 @@ const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, r
|
|
|
314
305
|
}
|
|
315
306
|
}, [setOpen, setSelectedIndex, data]);
|
|
316
307
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
317
|
-
React.createElement(CombinatorProperties, { schema:
|
|
308
|
+
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: 'oneOf', path: path }),
|
|
318
309
|
React.createElement(Tabs, { value: selectedIndex, onChange: handleTabChange }, oneOfRenderInfos.map(oneOfRenderInfo => React.createElement(Tab, { key: oneOfRenderInfo.label, label: oneOfRenderInfo.label }))),
|
|
319
310
|
oneOfRenderInfos.map((oneOfRenderInfo, oneOfIndex) => (selectedIndex === oneOfIndex && (React.createElement(JsonFormsDispatch, { key: oneOfIndex, schema: oneOfRenderInfo.schema, uischema: oneOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells })))),
|
|
320
311
|
React.createElement(Dialog, { open: open, onClose: handleClose, "aria-labelledby": 'alert-dialog-title', "aria-describedby": 'alert-dialog-description' },
|
|
@@ -492,7 +483,7 @@ const MaterialEnumArrayRenderer = ({ schema, visible, errors, path, options, dat
|
|
|
492
483
|
: undefined;
|
|
493
484
|
return (React.createElement(FormControlLabel, { id: option.value, key: option.value, control: React.createElement(MuiCheckbox, Object.assign({ key: 'checkbox-' + option.value, isValid: isEmpty(errors), path: optionPath, handleChange: (_childPath, newValue) => newValue
|
|
494
485
|
? addItem(path, option.value)
|
|
495
|
-
: removeItem(path, option.value), data: checkboxValue, errors: errors, schema: schema, visible: visible }, otherProps)), label:
|
|
486
|
+
: removeItem(path, option.value), data: checkboxValue, errors: errors, schema: schema, visible: visible }, otherProps)), label: option.label }));
|
|
496
487
|
})),
|
|
497
488
|
React.createElement(FormHelperText, { error: true }, errors))));
|
|
498
489
|
};
|
|
@@ -546,7 +537,7 @@ const ListWithDetailMasterItem = ({ index, childLabel, selected, handleSelect, r
|
|
|
546
537
|
};
|
|
547
538
|
var ListWithDetailMasterItem$1 = withJsonFormsMasterListItemProps(ListWithDetailMasterItem);
|
|
548
539
|
|
|
549
|
-
const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, errors, visible, label, required, removeItems, addItem, data, renderers, cells, config }) => {
|
|
540
|
+
const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, errors, visible, label, required, removeItems, addItem, data, renderers, cells, config, rootSchema }) => {
|
|
550
541
|
const [selectedIndex, setSelectedIndex] = useState(undefined);
|
|
551
542
|
const handleRemoveItem = useCallback((p, value) => () => {
|
|
552
543
|
removeItems(p, [value])();
|
|
@@ -559,7 +550,7 @@ const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, err
|
|
|
559
550
|
}, [removeItems, setSelectedIndex]);
|
|
560
551
|
const handleListItemClick = useCallback((index) => () => setSelectedIndex(index), [setSelectedIndex]);
|
|
561
552
|
const handleCreateDefaultValue = useCallback(() => createDefaultValue(schema), [createDefaultValue]);
|
|
562
|
-
const foundUISchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, undefined, uischema), [uischemas, schema, uischema.scope, path, uischema]);
|
|
553
|
+
const foundUISchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, undefined, uischema, rootSchema), [uischemas, schema, uischema.scope, path, uischema, rootSchema]);
|
|
563
554
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
564
555
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
565
556
|
React.createElement(ArrayLayoutToolbar, { label: computeLabel(label, required, appliedUiSchemaOptions.hideRequiredAsterisk), errors: errors, path: path, addItem: addItem, createDefault: handleCreateDefaultValue }),
|
|
@@ -951,6 +942,7 @@ const ExpandPanelRendererComponent = (props) => {
|
|
|
951
942
|
const { childLabel, childPath, index, expanded, moveDown, moveUp, enableMoveDown, enableMoveUp, handleExpansion, removeItems, path, rootSchema, schema, uischema, uischemas, renderers, cells, config } = props;
|
|
952
943
|
const foundUISchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, undefined, uischema, rootSchema), [uischemas, schema, uischema.scope, path, uischema, rootSchema]);
|
|
953
944
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
945
|
+
const showSortButtons = appliedUiSchemaOptions.showSortButtons || appliedUiSchemaOptions.showArrayLayoutSortButtons;
|
|
954
946
|
return (React.createElement(Accordion, { "aria-labelledby": labelHtmlId, expanded: expanded, onChange: handleExpansion(childPath) },
|
|
955
947
|
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, null) },
|
|
956
948
|
React.createElement(Grid, { container: true, alignItems: 'center' },
|
|
@@ -964,7 +956,7 @@ const ExpandPanelRendererComponent = (props) => {
|
|
|
964
956
|
React.createElement(Grid, { container: true, justifyContent: 'flex-end' },
|
|
965
957
|
React.createElement(Grid, { item: true },
|
|
966
958
|
React.createElement(Grid, { container: true, direction: 'row', justifyContent: 'center', alignItems: 'center' },
|
|
967
|
-
|
|
959
|
+
showSortButtons ? (React.createElement(Fragment, null,
|
|
968
960
|
React.createElement(Grid, { item: true },
|
|
969
961
|
React.createElement(IconButton, { onClick: moveUp(path, index), style: iconStyle, disabled: !enableMoveUp, "aria-label": `Move up`, size: 'large' },
|
|
970
962
|
React.createElement(ArrowUpward, null))),
|
|
@@ -1034,12 +1026,12 @@ const MaterialArrayLayoutComponent = (props) => {
|
|
|
1034
1026
|
};
|
|
1035
1027
|
const MaterialArrayLayout$1 = React.memo(MaterialArrayLayoutComponent);
|
|
1036
1028
|
|
|
1037
|
-
const MaterialArrayLayoutRenderer = ({ visible,
|
|
1029
|
+
const MaterialArrayLayoutRenderer = ({ visible, addItem, ...props }) => {
|
|
1038
1030
|
const addItemCb = useCallback((p, value) => addItem(p, value), [
|
|
1039
1031
|
addItem
|
|
1040
1032
|
]);
|
|
1041
1033
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
1042
|
-
React.createElement(MaterialArrayLayout$1, {
|
|
1034
|
+
React.createElement(MaterialArrayLayout$1, Object.assign({ visible: visible, addItem: addItemCb }, props))));
|
|
1043
1035
|
};
|
|
1044
1036
|
const materialArrayLayoutTester = rankWith(4, isObjectArrayWithNesting);
|
|
1045
1037
|
var MaterialArrayLayout = withJsonFormsArrayLayoutProps(MaterialArrayLayoutRenderer);
|