@jsonforms/material-renderers 3.0.0-beta.1 → 3.0.0-beta.2

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.
Files changed (45) hide show
  1. package/docs/globals.html +41 -41
  2. package/docs/interfaces/emptytableprops.html +1 -1
  3. package/docs/interfaces/nonemptycellcomponentprops.html +9 -9
  4. package/docs/interfaces/nonemptycellprops.html +9 -9
  5. package/docs/interfaces/ownoneofprops.html +1 -1
  6. package/docs/interfaces/ownpropsofnonemptycell.html +6 -6
  7. package/docs/interfaces/tableheadercellprops.html +1 -1
  8. package/lib/jsonforms-react-material.cjs.js +12 -21
  9. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  10. package/lib/jsonforms-react-material.esm.js +12 -21
  11. package/lib/jsonforms-react-material.esm.js.map +1 -1
  12. package/package.json +8 -6
  13. package/src/complex/MaterialAllOfRenderer.tsx +3 -5
  14. package/src/complex/MaterialAnyOfRenderer.tsx +3 -5
  15. package/src/complex/MaterialEnumArrayRenderer.tsx +1 -2
  16. package/src/complex/MaterialObjectRenderer.tsx +3 -8
  17. package/src/complex/MaterialOneOfRenderer.tsx +3 -5
  18. package/src/complex/MaterialTableControl.tsx +5 -5
  19. package/stats.html +1 -1
  20. package/test/renderers/MaterialAnyOfStringOrEnumControl.test.tsx +7 -7
  21. package/test/renderers/MaterialArrayLayout.test.tsx +34 -7
  22. package/test/renderers/MaterialBooleanCell.test.tsx +10 -7
  23. package/test/renderers/MaterialBooleanToggleCell.test.tsx +14 -9
  24. package/test/renderers/MaterialBooleanToggleControl.test.tsx +14 -9
  25. package/test/renderers/MaterialCategorizationLayout.test.tsx +12 -12
  26. package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +12 -12
  27. package/test/renderers/MaterialDateCell.test.tsx +10 -7
  28. package/test/renderers/MaterialDateControl.test.tsx +12 -8
  29. package/test/renderers/MaterialDateTimeControl.test.tsx +12 -8
  30. package/test/renderers/MaterialEnumArrayRenderer.test.tsx +9 -7
  31. package/test/renderers/MaterialEnumCell.test.tsx +2 -1
  32. package/test/renderers/MaterialEnumControl.test.tsx +75 -0
  33. package/test/renderers/MaterialIntegerCell.test.tsx +10 -7
  34. package/test/renderers/MaterialLabelRenderer.test.tsx +4 -4
  35. package/test/renderers/MaterialListWithDetailRenderer.test.tsx +5 -5
  36. package/test/renderers/MaterialNumberCell.test.tsx +10 -7
  37. package/test/renderers/MaterialObjectControl.test.tsx +10 -7
  38. package/test/renderers/MaterialOneOfEnumCell.test.tsx +2 -1
  39. package/test/renderers/MaterialOneOfRadioGroupControl.test.tsx +3 -2
  40. package/test/renderers/MaterialOneOfRenderer.test.tsx +12 -7
  41. package/test/renderers/MaterialRadioGroupControl.test.tsx +2 -2
  42. package/test/renderers/MaterialSliderControl.test.tsx +20 -12
  43. package/test/renderers/MaterialTextCell.test.tsx +10 -7
  44. package/test/renderers/MaterialTimeCell.test.tsx +10 -7
  45. package/test/renderers/MaterialTimeControl.test.tsx +12 -8
@@ -1,4 +1,4 @@
1
- import { createDefaultValue, Resolve, Paths, formatErrorMessage, errorsAt, rankWith, isObjectControl, findUISchema, isAllOfControl, resolveSubSchemas, findMatchingUISchema, createCombinatorRenderInfos, Generate, 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';
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) => {
@@ -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 _schema = resolveSubSchemas(schema, rootSchema, 'allOf');
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: _schema, uischema: delegateUISchema, path: path, renderers: renderers, cells: cells })));
243
+ React.createElement(JsonFormsDispatch, { schema: schema, uischema: delegateUISchema, path: path, renderers: renderers, cells: cells })));
251
244
  }
252
- const allOfRenderInfos = createCombinatorRenderInfos(_schema.allOf, rootSchema, 'allOf', uischema, path, uischemas);
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 _schema = resolveSubSchemas(schema, rootSchema, anyOf);
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: _schema, combinatorKeyword: 'anyOf', path: path }),
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 _schema = resolveSubSchemas(schema, rootSchema, 'oneOf');
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(schema.oneOf[newIndex]));
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: _schema, combinatorKeyword: 'oneOf', path: path }),
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: startCase(option.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
  };