@jsonforms/material-renderers 3.3.0-alpha.0 → 3.3.0-beta.0
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/lib/jsonforms-react-material.cjs.js +144 -83
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +149 -85
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/layouts/ExpandPanelRenderer.d.ts +5 -1
- package/package.json +5 -5
- package/src/additional/ListWithDetailMasterItem.tsx +13 -6
- package/src/additional/MaterialLabelRenderer.tsx +5 -6
- package/src/additional/MaterialListWithDetailRenderer.tsx +10 -4
- package/src/complex/MaterialAllOfRenderer.tsx +14 -12
- package/src/complex/MaterialAnyOfRenderer.tsx +7 -3
- package/src/complex/MaterialArrayControlRenderer.tsx +6 -3
- package/src/complex/MaterialEnumArrayRenderer.tsx +56 -55
- package/src/complex/MaterialObjectRenderer.tsx +14 -12
- package/src/complex/MaterialOneOfRenderer.tsx +7 -3
- package/src/complex/MaterialTableControl.tsx +34 -33
- package/src/controls/MaterialBooleanControl.tsx +7 -8
- package/src/controls/MaterialBooleanToggleControl.tsx +7 -8
- package/src/controls/MaterialInputControl.tsx +32 -30
- package/src/controls/MaterialNativeControl.tsx +23 -21
- package/src/controls/MaterialRadioGroup.tsx +39 -38
- package/src/controls/MaterialSliderControl.tsx +44 -43
- package/src/layouts/ExpandPanelRenderer.tsx +48 -11
- package/src/layouts/MaterialArrayLayoutRenderer.tsx +6 -4
- package/src/layouts/MaterialCategorizationLayout.tsx +7 -3
- package/src/layouts/MaterialCategorizationStepperLayout.tsx +8 -3
- package/src/layouts/MaterialGroupLayout.tsx +17 -14
- package/src/mui-controls/MuiAutocomplete.tsx +6 -3
- package/src/util/layout.tsx +16 -18
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useCallback, useMemo, Fragment, useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { rankWith, isAllOfControl, findMatchingUISchema, createCombinatorRenderInfos, Generate, isLayout, isAnyOfControl, createDefaultValue, Resolve, encode, Paths, formatErrorMessage, errorsAt, or, isObjectArrayControl, isPrimitiveArrayControl, isDescriptionHidden, getAjv, and, uiTypeIs, schemaMatches, hasType, schemaSubPathMatches, resolveSchema, showAsRequired, isObjectControl, findUISchema, isOneOfControl, isObjectArray, computeLabel, composePaths, isBooleanControl, optionIs, isDateControl, defaultDateFormat, isDateTimeControl, defaultDateTimeFormat, isEnumControl, isIntegerControl, isTimeControl, isNumberControl, isOneOfEnumControl, isRangeControl, isStringControl, defaultTimeFormat, createId, removeId, update, moveUp, moveDown, getFirstPrimitiveProp, withIncreasedRank, isVisible, deriveLabelForUISchemaElement, isObjectArrayWithNesting, isNumberFormatControl, categorizationHasCategory } from '@jsonforms/core';
|
|
2
|
+
import { rankWith, isAllOfControl, findMatchingUISchema, createCombinatorRenderInfos, Generate, isLayout, isAnyOfControl, createDefaultValue, Resolve, encode, Paths, formatErrorMessage, errorsAt, or, isObjectArrayControl, isPrimitiveArrayControl, isDescriptionHidden, getAjv, and, uiTypeIs, schemaMatches, hasType, schemaSubPathMatches, resolveSchema, showAsRequired, isObjectControl, findUISchema, isOneOfControl, isObjectArray, computeLabel, composePaths, isBooleanControl, optionIs, isDateControl, defaultDateFormat, isDateTimeControl, defaultDateTimeFormat, isEnumControl, isIntegerControl, isTimeControl, isNumberControl, isOneOfEnumControl, isRangeControl, isStringControl, defaultTimeFormat, createId, removeId, update, moveUp, moveDown, computeChildLabel, withIncreasedRank, isVisible, deriveLabelForUISchemaElement, isObjectArrayWithNesting, isNumberFormatControl, categorizationHasCategory } from '@jsonforms/core';
|
|
4
3
|
import { withJsonFormsAllOfProps, JsonFormsDispatch, withJsonFormsAnyOfProps, DispatchCell, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsMultiEnumProps, withJsonFormsDetailProps, withJsonFormsOneOfProps, withJsonFormsLabelProps, withJsonFormsMasterListItemProps, withJsonFormsControlProps, Control, withJsonFormsEnumProps, withTranslateProps, withJsonFormsOneOfEnumProps, withJsonFormsContext, withJsonFormsLayoutProps, withJsonFormsCellProps, withJsonFormsEnumCellProps, withJsonFormsOneOfEnumCellProps } from '@jsonforms/react';
|
|
4
|
+
import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Tabs, Tab, TableCell, styled as styled$1, Badge, Tooltip, TableRow, Stack, Grid, Typography, FormHelperText, IconButton, Table, TableHead, TableBody, Autocomplete, TextField, Checkbox, useThemeProps, Input, FilledInput, OutlinedInput, useTheme, InputAdornment, Select, MenuItem, Switch, FormControl, FormLabel, FormGroup, FormControlLabel, Toolbar, ListItem, ListItemAvatar, Avatar, ListItemText, ListItemSecondaryAction, List, InputLabel, RadioGroup, Radio, Slider, Accordion, AccordionSummary, AccordionDetails, Card, CardHeader, CardContent, AppBar, Stepper, Step, StepButton } from '@mui/material';
|
|
5
5
|
import omit from 'lodash/omit';
|
|
6
6
|
import isEmpty from 'lodash/isEmpty';
|
|
7
7
|
import union from 'lodash/union';
|
|
@@ -17,16 +17,17 @@ import map from 'lodash/map';
|
|
|
17
17
|
import AddIcon from '@mui/icons-material/Add';
|
|
18
18
|
import { LocalizationProvider, DatePicker, DateTimePicker, TimePicker } from '@mui/x-date-pickers';
|
|
19
19
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
20
|
-
import get from 'lodash/get';
|
|
21
20
|
|
|
22
21
|
const MaterialAllOfRenderer = ({ schema, rootSchema, visible, renderers, cells, path, uischemas, uischema, }) => {
|
|
23
22
|
const delegateUISchema = findMatchingUISchema(uischemas)(schema, uischema.scope, path);
|
|
23
|
+
if (!visible) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
24
26
|
if (delegateUISchema) {
|
|
25
|
-
return (React.createElement(
|
|
26
|
-
React.createElement(JsonFormsDispatch, { schema: schema, uischema: delegateUISchema, path: path, renderers: renderers, cells: cells })));
|
|
27
|
+
return (React.createElement(JsonFormsDispatch, { schema: schema, uischema: delegateUISchema, path: path, renderers: renderers, cells: cells }));
|
|
27
28
|
}
|
|
28
29
|
const allOfRenderInfos = createCombinatorRenderInfos(schema.allOf, rootSchema, 'allOf', uischema, path, uischemas);
|
|
29
|
-
return (React.createElement(
|
|
30
|
+
return (React.createElement(React.Fragment, null, allOfRenderInfos.map((allOfRenderInfo, allOfIndex) => (React.createElement(JsonFormsDispatch, { key: allOfIndex, schema: allOfRenderInfo.schema, uischema: allOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells })))));
|
|
30
31
|
};
|
|
31
32
|
const materialAllOfControlTester = rankWith(3, isAllOfControl);
|
|
32
33
|
var MaterialAllOfRenderer$1 = withJsonFormsAllOfProps(MaterialAllOfRenderer);
|
|
@@ -83,7 +84,10 @@ const MaterialAnyOfRenderer = ({ handleChange, schema, rootSchema, indexOfFittin
|
|
|
83
84
|
}, [handleChange, createDefaultValue, newSelectedIndex]);
|
|
84
85
|
const anyOf = 'anyOf';
|
|
85
86
|
const anyOfRenderInfos = createCombinatorRenderInfos(schema.anyOf, rootSchema, anyOf, uischema, path, uischemas);
|
|
86
|
-
|
|
87
|
+
if (!visible) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return (React.createElement(React.Fragment, null,
|
|
87
91
|
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: anyOf, path: path, rootSchema: rootSchema }),
|
|
88
92
|
React.createElement(Tabs, { value: selectedAnyOf, onChange: handleTabChange }, anyOfRenderInfos.map((anyOfRenderInfo) => (React.createElement(Tab, { key: anyOfRenderInfo.label, label: anyOfRenderInfo.label })))),
|
|
89
93
|
anyOfRenderInfos.map((anyOfRenderInfo, anyOfIndex) => selectedAnyOf === anyOfIndex && (React.createElement(JsonFormsDispatch, { key: anyOfIndex, schema: anyOfRenderInfo.schema, uischema: anyOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }))),
|
|
@@ -259,15 +263,17 @@ class MaterialTableControl extends React.Component {
|
|
|
259
263
|
const headerCells = isObjectSchema
|
|
260
264
|
? generateCells(TableHeaderCell, schema, path, enabled, cells)
|
|
261
265
|
: undefined;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
React.createElement(
|
|
266
|
+
if (!visible) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
return (React.createElement(Table, null,
|
|
270
|
+
React.createElement(TableHead, null,
|
|
271
|
+
React.createElement(TableToolbar, { errors: errors, label: label, description: description, addItem: this.addItem, numColumns: isObjectSchema ? headerCells.length : 1, path: path, uischema: controlElement, schema: schema, rootSchema: rootSchema, enabled: enabled, translations: translations }),
|
|
272
|
+
isObjectSchema && (React.createElement(TableRow, null,
|
|
273
|
+
headerCells,
|
|
274
|
+
enabled ? React.createElement(TableCell, null) : null))),
|
|
275
|
+
React.createElement(TableBody, null,
|
|
276
|
+
React.createElement(TableRows, { openDeleteDialog: openDeleteDialog, translations: translations, ...this.props }))));
|
|
271
277
|
}
|
|
272
278
|
}
|
|
273
279
|
|
|
@@ -298,7 +304,10 @@ const MaterialArrayControlRenderer = (props) => {
|
|
|
298
304
|
setOpen(false);
|
|
299
305
|
}, [setOpen, path, rowData]);
|
|
300
306
|
const deleteClose = useCallback(() => setOpen(false), [setOpen]);
|
|
301
|
-
|
|
307
|
+
if (!visible) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
return (React.createElement(React.Fragment, null,
|
|
302
311
|
React.createElement(MaterialTableControl, { ...props, openDeleteDialog: openDeleteDialog }),
|
|
303
312
|
React.createElement(DeleteDialog, { open: open, onCancel: deleteCancel, onConfirm: deleteConfirm, onClose: deleteClose, acceptText: props.translations.deleteDialogAccept, declineText: props.translations.deleteDialogDecline, title: props.translations.deleteDialogTitle, message: props.translations.deleteDialogMessage })));
|
|
304
313
|
};
|
|
@@ -325,7 +334,10 @@ const MuiAutocomplete = (props) => {
|
|
|
325
334
|
? errors
|
|
326
335
|
: null;
|
|
327
336
|
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
328
|
-
|
|
337
|
+
if (!visible) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
return (React.createElement(React.Fragment, null,
|
|
329
341
|
React.createElement(Autocomplete, { className: className, id: id, disabled: !enabled, value: findOption, onChange: (_event, newValue) => {
|
|
330
342
|
handleChange(path, newValue?.value);
|
|
331
343
|
}, inputValue: inputValue, onInputChange: (_event, newInputValue) => {
|
|
@@ -403,12 +415,11 @@ const renderLayoutElements = (elements, schema, path, enabled, renderers, cells)
|
|
|
403
415
|
React.createElement(JsonFormsDispatch, { uischema: child, schema: schema, path: path, enabled: enabled, renderers: renderers, cells: cells }))));
|
|
404
416
|
};
|
|
405
417
|
const MaterialLayoutRendererComponent = ({ visible, elements, schema, path, enabled, direction, renderers, cells, }) => {
|
|
406
|
-
if (isEmpty(elements)) {
|
|
418
|
+
if (isEmpty(elements) || !visible) {
|
|
407
419
|
return null;
|
|
408
420
|
}
|
|
409
421
|
else {
|
|
410
|
-
return (React.createElement(
|
|
411
|
-
React.createElement(Grid, { container: true, direction: direction, spacing: direction === 'row' ? 2 : 0 }, renderLayoutElements(elements, schema, path, enabled, renderers, cells))));
|
|
422
|
+
return (React.createElement(Grid, { container: true, direction: direction, spacing: direction === 'row' ? 2 : 0 }, renderLayoutElements(elements, schema, path, enabled, renderers, cells)));
|
|
412
423
|
}
|
|
413
424
|
};
|
|
414
425
|
const MaterialLayoutRenderer = React.memo(MaterialLayoutRendererComponent);
|
|
@@ -570,19 +581,21 @@ const MaterialEnumArrayRenderer = ({ config, id, schema, visible, errors, descri
|
|
|
570
581
|
const isValid = errors.length === 0;
|
|
571
582
|
const appliedUiSchemaOptions = merge({}, config, otherProps.uischema.options);
|
|
572
583
|
const showDescription = !isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
584
|
+
if (!visible) {
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
return (React.createElement(FormControl, { component: 'fieldset', fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur },
|
|
588
|
+
React.createElement(FormLabel, { error: !isValid, component: 'legend', required: showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk) }, label),
|
|
589
|
+
React.createElement(FormGroup, { row: true }, options.map((option, index) => {
|
|
590
|
+
const optionPath = Paths.compose(path, `${index}`);
|
|
591
|
+
const checkboxValue = data?.includes(option.value)
|
|
592
|
+
? option.value
|
|
593
|
+
: undefined;
|
|
594
|
+
return (React.createElement(FormControlLabel, { id: id + '-label-' + option.value, key: option.value, control: React.createElement(MuiCheckbox, { id: id + '-' + option.value, key: 'checkbox-' + option.value, isValid: isEmpty(errors), path: optionPath, handleChange: (_childPath, newValue) => newValue
|
|
595
|
+
? addItem(path, option.value)
|
|
596
|
+
: removeItem(path, option.value), data: checkboxValue, errors: errors, schema: schema, visible: visible, ...otherProps }), label: option.label }));
|
|
597
|
+
})),
|
|
598
|
+
React.createElement(FormHelperText, { error: !isValid }, !isValid ? errors : showDescription ? description : null)));
|
|
586
599
|
};
|
|
587
600
|
const hasOneOfItems = (schema) => schema.oneOf !== undefined &&
|
|
588
601
|
schema.oneOf.length > 0 &&
|
|
@@ -607,8 +620,10 @@ const MaterialObjectRenderer = ({ renderers, cells, uischemas, schema, label, pa
|
|
|
607
620
|
...Generate.uiSchema(schema, 'Group', undefined, rootSchema),
|
|
608
621
|
label,
|
|
609
622
|
}, uischema, rootSchema), [uischemas, schema, uischema.scope, path, label, uischema, rootSchema]);
|
|
610
|
-
|
|
611
|
-
|
|
623
|
+
if (!visible) {
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
return (React.createElement(JsonFormsDispatch, { visible: visible, enabled: enabled, schema: schema, uischema: detailUiSchema, path: path, renderers: renderers, cells: cells }));
|
|
612
627
|
};
|
|
613
628
|
const materialObjectControlTester = rankWith(2, isObjectControl);
|
|
614
629
|
var MaterialObjectRenderer$1 = withJsonFormsDetailProps(MaterialObjectRenderer);
|
|
@@ -639,7 +654,10 @@ const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, r
|
|
|
639
654
|
setConfirmDialogOpen(true);
|
|
640
655
|
}
|
|
641
656
|
}, [setConfirmDialogOpen, setSelectedIndex, data]);
|
|
642
|
-
|
|
657
|
+
if (!visible) {
|
|
658
|
+
return null;
|
|
659
|
+
}
|
|
660
|
+
return (React.createElement(React.Fragment, null,
|
|
643
661
|
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: 'oneOf', path: path, rootSchema: rootSchema }),
|
|
644
662
|
React.createElement(Tabs, { value: selectedIndex, onChange: handleTabChange }, oneOfRenderInfos.map((oneOfRenderInfo) => (React.createElement(Tab, { key: oneOfRenderInfo.label, label: oneOfRenderInfo.label })))),
|
|
645
663
|
oneOfRenderInfos.map((oneOfRenderInfo, oneOfIndex) => selectedIndex === oneOfIndex && (React.createElement(JsonFormsDispatch, { key: oneOfIndex, schema: oneOfRenderInfo.schema, uischema: oneOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }))),
|
|
@@ -650,8 +668,10 @@ var MaterialOneOfRenderer$1 = withJsonFormsOneOfProps(MaterialOneOfRenderer);
|
|
|
650
668
|
|
|
651
669
|
const materialLabelRendererTester = rankWith(1, uiTypeIs('Label'));
|
|
652
670
|
const MaterialLabelRenderer = ({ text, visible }) => {
|
|
653
|
-
|
|
654
|
-
|
|
671
|
+
if (!visible) {
|
|
672
|
+
return null;
|
|
673
|
+
}
|
|
674
|
+
return React.createElement(Typography, { variant: 'h6' }, text);
|
|
655
675
|
};
|
|
656
676
|
var MaterialLabelRenderer$1 = withJsonFormsLabelProps(MaterialLabelRenderer);
|
|
657
677
|
|
|
@@ -680,8 +700,9 @@ const ListWithDetailMasterItem = ({ index, childLabel, selected, enabled, handle
|
|
|
680
700
|
React.createElement(Avatar, { "aria-label": 'Index' }, index + 1)),
|
|
681
701
|
React.createElement(ListItemText, { primary: childLabel }),
|
|
682
702
|
enabled && (React.createElement(ListItemSecondaryAction, null,
|
|
683
|
-
React.createElement(
|
|
684
|
-
React.createElement(
|
|
703
|
+
React.createElement(Tooltip, { id: 'tooltip-remove', title: translations.removeTooltip, placement: 'bottom' },
|
|
704
|
+
React.createElement(IconButton, { "aria-label": translations.removeAriaLabel, onClick: removeItem(path, index), size: 'large' },
|
|
705
|
+
React.createElement(Delete, null)))))));
|
|
685
706
|
};
|
|
686
707
|
var ListWithDetailMasterItem$1 = withJsonFormsMasterListItemProps(ListWithDetailMasterItem);
|
|
687
708
|
|
|
@@ -703,11 +724,14 @@ const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, ena
|
|
|
703
724
|
React.useEffect(() => {
|
|
704
725
|
setSelectedIndex(undefined);
|
|
705
726
|
}, [schema]);
|
|
706
|
-
|
|
727
|
+
if (!visible) {
|
|
728
|
+
return null;
|
|
729
|
+
}
|
|
730
|
+
return (React.createElement(React.Fragment, null,
|
|
707
731
|
React.createElement(ArrayLayoutToolbar, { translations: translations, label: computeLabel(label, required, appliedUiSchemaOptions.hideRequiredAsterisk), description: description, errors: errors, path: path, enabled: enabled, addItem: addItem, createDefault: handleCreateDefaultValue }),
|
|
708
732
|
React.createElement(Grid, { container: true, direction: 'row', spacing: 2 },
|
|
709
733
|
React.createElement(Grid, { item: true, xs: 3 },
|
|
710
|
-
React.createElement(List, null, data > 0 ? (map(range(data), (index) => (React.createElement(ListWithDetailMasterItem$1, { index: index, path: path, schema: schema, enabled: enabled, handleSelect: handleListItemClick, removeItem: handleRemoveItem, selected: selectedIndex === index, key: index, translations: translations })))) : (React.createElement("p", null,
|
|
734
|
+
React.createElement(List, null, data > 0 ? (map(range(data), (index) => (React.createElement(ListWithDetailMasterItem$1, { index: index, path: path, schema: schema, enabled: enabled, handleSelect: handleListItemClick, removeItem: handleRemoveItem, selected: selectedIndex === index, key: index, uischema: foundUISchema, childLabelProp: appliedUiSchemaOptions.elementLabelProp, translations: translations })))) : (React.createElement("p", null, translations.noDataMessage)))),
|
|
711
735
|
React.createElement(Grid, { item: true, xs: true }, selectedIndex !== undefined ? (React.createElement(JsonFormsDispatch, { renderers: renderers, cells: cells, visible: visible, schema: schema, uischema: foundUISchema, path: composePaths(path, `${selectedIndex}`) })) : (React.createElement(Typography, { variant: 'h6' }, translations.noSelection))))));
|
|
712
736
|
};
|
|
713
737
|
const materialListWithDetailTester = rankWith(4, and(uiTypeIs('ListWithDetail'), isObjectArray));
|
|
@@ -727,12 +751,14 @@ const MaterialInputControl = (props) => {
|
|
|
727
751
|
: null;
|
|
728
752
|
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
729
753
|
const InnerComponent = input;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
754
|
+
if (!visible) {
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
return (React.createElement(FormControl, { fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur, variant: variant, id: id },
|
|
758
|
+
React.createElement(InputLabel, { htmlFor: id + '-input', error: !isValid, required: showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk) }, label),
|
|
759
|
+
React.createElement(InnerComponent, { ...props, id: id + '-input', isValid: isValid, visible: visible }),
|
|
760
|
+
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
761
|
+
React.createElement(FormHelperText, { error: !isValid }, secondFormHelperText)));
|
|
736
762
|
};
|
|
737
763
|
|
|
738
764
|
const findEnumSchema = (schemas) => schemas.find((s) => s.enum !== undefined && (s.type === 'string' || s.type === undefined));
|
|
@@ -805,7 +831,10 @@ const MaterialBooleanControl = ({ data, visible, label, id, enabled, uischema, s
|
|
|
805
831
|
descriptionIds.push(helpId2);
|
|
806
832
|
}
|
|
807
833
|
const ariaDescribedBy = descriptionIds.join(' ');
|
|
808
|
-
|
|
834
|
+
if (!visible) {
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
return (React.createElement(React.Fragment, null,
|
|
809
838
|
React.createElement(Tooltip, { id: tooltipId, title: showTooltip ? description : '' },
|
|
810
839
|
React.createElement(FormControlLabel, { label: label, id: id, control: React.createElement(MuiCheckbox, { id: `${id}-input`, isValid: isEmpty(errors), data: data, enabled: enabled, visible: visible, path: path, uischema: uischema, schema: schema, rootSchema: rootSchema, handleChange: handleChange, errors: errors, config: config, inputProps: {
|
|
811
840
|
'aria-describedby': ariaDescribedBy,
|
|
@@ -845,7 +874,10 @@ const MaterialBooleanToggleControl = ({ data, visible, label, id, enabled, uisch
|
|
|
845
874
|
descriptionIds.push(helpId2);
|
|
846
875
|
}
|
|
847
876
|
const ariaDescribedBy = descriptionIds.join(' ');
|
|
848
|
-
|
|
877
|
+
if (!visible) {
|
|
878
|
+
return null;
|
|
879
|
+
}
|
|
880
|
+
return (React.createElement(React.Fragment, null,
|
|
849
881
|
React.createElement(Tooltip, { id: tooltipId, title: showTooltip ? description : '' },
|
|
850
882
|
React.createElement(FormControlLabel, { label: label, id: id, control: React.createElement(MuiToggle, { id: `${id}-input`, isValid: isEmpty(errors), data: data, enabled: enabled, visible: visible, path: path, uischema: uischema, schema: schema, rootSchema: rootSchema, handleChange: handleChange, errors: errors, config: config, inputProps: {
|
|
851
883
|
'aria-describedby': ariaDescribedBy,
|
|
@@ -980,8 +1012,10 @@ const MaterialNativeControl = (props) => {
|
|
|
980
1012
|
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
|
|
981
1013
|
const fieldType = appliedUiSchemaOptions.format ?? schema.format;
|
|
982
1014
|
const showDescription = !isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
983
|
-
|
|
984
|
-
|
|
1015
|
+
if (!visible) {
|
|
1016
|
+
return null;
|
|
1017
|
+
}
|
|
1018
|
+
return (React.createElement(TextField, { required: showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk), id: id + '-input', label: label, type: fieldType, error: !isValid, disabled: !enabled, fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur, helperText: !isValid ? errors : showDescription ? description : null, InputLabelProps: { shrink: true }, value: inputValue, onChange: onChange }));
|
|
985
1019
|
};
|
|
986
1020
|
const materialNativeControlTester = rankWith(2, or(isDateControl, isTimeControl));
|
|
987
1021
|
var MaterialNativeControl$1 = withJsonFormsControlProps(MaterialNativeControl);
|
|
@@ -1005,11 +1039,13 @@ const MaterialRadioGroup = (props) => {
|
|
|
1005
1039
|
const isValid = errors.length === 0;
|
|
1006
1040
|
const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
|
|
1007
1041
|
const showDescription = !isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1042
|
+
if (!visible) {
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
return (React.createElement(FormControl, { component: 'fieldset', fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur },
|
|
1046
|
+
React.createElement(FormLabel, { error: !isValid, component: 'legend', required: showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk) }, label),
|
|
1047
|
+
React.createElement(RadioGroup, { value: props.data ?? '', row: true }, options.map((option) => (React.createElement(FormControlLabel, { value: option.value, key: option.label, control: React.createElement(Radio, { checked: data === option.value, onChange: () => handleChange(path, option.value) }), label: option.label, disabled: !enabled })))),
|
|
1048
|
+
React.createElement(FormHelperText, { error: !isValid }, !isValid ? errors : showDescription ? description : null)));
|
|
1013
1049
|
};
|
|
1014
1050
|
|
|
1015
1051
|
const MaterialOneOfRadioGroupControl = (props) => {
|
|
@@ -1046,15 +1082,17 @@ const MaterialSliderControl = (props) => {
|
|
|
1046
1082
|
};
|
|
1047
1083
|
const showDescription = !isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
1048
1084
|
const onChange = useCallback((_ev, value) => handleChange(path, Number(value)), [path, handleChange]);
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
React.createElement(
|
|
1057
|
-
React.createElement(
|
|
1085
|
+
if (!visible) {
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
return (React.createElement(FormControl, { fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur, id: id },
|
|
1089
|
+
React.createElement(FormLabel, { htmlFor: id, error: !isValid, component: 'legend', required: showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk) },
|
|
1090
|
+
React.createElement(Typography, { id: id + '-typo', style: labelStyle, variant: 'caption' }, label)),
|
|
1091
|
+
React.createElement("div", { style: rangeContainerStyle },
|
|
1092
|
+
React.createElement(Typography, { style: rangeItemStyle, variant: 'caption', align: 'left' }, schema.minimum),
|
|
1093
|
+
React.createElement(Typography, { style: rangeItemStyle, variant: 'caption', align: 'right' }, schema.maximum)),
|
|
1094
|
+
React.createElement(Slider, { style: sliderStyle, min: schema.minimum, max: schema.maximum, value: Number(data || schema.default), onChange: onChange, id: id + '-input', disabled: !enabled, step: schema.multipleOf || 1 }),
|
|
1095
|
+
React.createElement(FormHelperText, { error: !isValid }, !isValid ? errors : showDescription ? description : null)));
|
|
1058
1096
|
};
|
|
1059
1097
|
const materialSliderControlTester = rankWith(4, isRangeControl);
|
|
1060
1098
|
var MaterialSliderControl$1 = withJsonFormsControlProps(MaterialSliderControl);
|
|
@@ -1181,15 +1219,31 @@ const ctxDispatchToExpandPanelProps = (dispatch) => ({
|
|
|
1181
1219
|
}));
|
|
1182
1220
|
}, [dispatch]),
|
|
1183
1221
|
});
|
|
1184
|
-
const withContextToExpandPanelProps = (Component) =>
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1222
|
+
const withContextToExpandPanelProps = (Component) => {
|
|
1223
|
+
return function WithContextToExpandPanelProps({ ctx, props, }) {
|
|
1224
|
+
const dispatchProps = ctxDispatchToExpandPanelProps(ctx.dispatch);
|
|
1225
|
+
const {
|
|
1226
|
+
childLabelProp,
|
|
1227
|
+
schema,
|
|
1228
|
+
uischema,
|
|
1229
|
+
rootSchema,
|
|
1230
|
+
path,
|
|
1231
|
+
index,
|
|
1232
|
+
uischemas, } = props;
|
|
1233
|
+
const childPath = composePaths(path, `${index}`);
|
|
1234
|
+
const childLabel = useMemo(() => {
|
|
1235
|
+
return computeChildLabel(ctx.core.data, childPath, childLabelProp, schema, rootSchema, ctx.i18n.translate, uischema);
|
|
1236
|
+
}, [
|
|
1237
|
+
ctx.core.data,
|
|
1238
|
+
childPath,
|
|
1239
|
+
childLabelProp,
|
|
1240
|
+
schema,
|
|
1241
|
+
rootSchema,
|
|
1242
|
+
ctx.i18n.translate,
|
|
1243
|
+
uischema,
|
|
1244
|
+
]);
|
|
1245
|
+
return (React.createElement(Component, { ...props, ...dispatchProps, childLabel: childLabel, childPath: childPath, uischemas: uischemas }));
|
|
1246
|
+
};
|
|
1193
1247
|
};
|
|
1194
1248
|
const withJsonFormsExpandPanelProps = (Component) => withJsonFormsContext(withContextToExpandPanelProps(Component));
|
|
1195
1249
|
var ExpandPanelRenderer$1 = withJsonFormsExpandPanelProps(ExpandPanelRenderer);
|
|
@@ -1198,11 +1252,13 @@ const groupTester = rankWith(1, uiTypeIs('Group'));
|
|
|
1198
1252
|
const style = { marginBottom: '10px' };
|
|
1199
1253
|
const GroupComponent = React.memo(function GroupComponent({ visible, enabled, uischema, label, ...props }) {
|
|
1200
1254
|
const groupLayout = uischema;
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1255
|
+
if (!visible) {
|
|
1256
|
+
return null;
|
|
1257
|
+
}
|
|
1258
|
+
return (React.createElement(Card, { style: style },
|
|
1259
|
+
!isEmpty(label) && React.createElement(CardHeader, { title: label }),
|
|
1260
|
+
React.createElement(CardContent, null,
|
|
1261
|
+
React.createElement(MaterialLayoutRenderer, { ...props, visible: visible, enabled: enabled, elements: groupLayout.elements }))));
|
|
1206
1262
|
});
|
|
1207
1263
|
const MaterializedGroupLayoutRenderer = ({ uischema, schema, path, visible, enabled, renderers, cells, direction, label, }) => {
|
|
1208
1264
|
const groupLayout = uischema;
|
|
@@ -1277,7 +1333,10 @@ const MaterialCategorizationLayoutRenderer = (props) => {
|
|
|
1277
1333
|
const tabLabels = useMemo(() => {
|
|
1278
1334
|
return categories.map((e) => deriveLabelForUISchemaElement(e, t));
|
|
1279
1335
|
}, [categories, t]);
|
|
1280
|
-
|
|
1336
|
+
if (!visible) {
|
|
1337
|
+
return null;
|
|
1338
|
+
}
|
|
1339
|
+
return (React.createElement(React.Fragment, null,
|
|
1281
1340
|
React.createElement(AppBar, { position: 'static' },
|
|
1282
1341
|
React.createElement(Tabs, { value: safeCategory, onChange: onTabChange, textColor: 'inherit', indicatorColor: 'secondary', variant: 'scrollable' }, categories.map((_, idx) => (React.createElement(Tab, { key: idx, label: tabLabels[idx] }))))),
|
|
1283
1342
|
React.createElement("div", { style: { marginTop: '0.5em' } },
|
|
@@ -1304,8 +1363,10 @@ const MaterialArrayLayout$1 = React.memo(MaterialArrayLayoutComponent);
|
|
|
1304
1363
|
|
|
1305
1364
|
const MaterialArrayLayoutRenderer = ({ visible, addItem, ...props }) => {
|
|
1306
1365
|
const addItemCb = useCallback((p, value) => addItem(p, value), [addItem]);
|
|
1307
|
-
|
|
1308
|
-
|
|
1366
|
+
if (!visible) {
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
return (React.createElement(MaterialArrayLayout$1, { visible: visible, addItem: addItemCb, ...props }));
|
|
1309
1370
|
};
|
|
1310
1371
|
const materialArrayLayoutTester = rankWith(4, isObjectArrayWithNesting);
|
|
1311
1372
|
var MaterialArrayLayout = withJsonFormsArrayLayoutProps(MaterialArrayLayoutRenderer);
|
|
@@ -1405,7 +1466,10 @@ const MaterialCategorizationStepperLayoutRenderer = (props) => {
|
|
|
1405
1466
|
const tabLabels = useMemo(() => {
|
|
1406
1467
|
return categories.map((e) => deriveLabelForUISchemaElement(e, t));
|
|
1407
1468
|
}, [categories, t]);
|
|
1408
|
-
|
|
1469
|
+
if (!visible) {
|
|
1470
|
+
return null;
|
|
1471
|
+
}
|
|
1472
|
+
return (React.createElement(React.Fragment, null,
|
|
1409
1473
|
React.createElement(Stepper, { activeStep: activeCategory, nonLinear: true }, categories.map((_, idx) => (React.createElement(Step, { key: tabLabels[idx] },
|
|
1410
1474
|
React.createElement(StepButton, { onClick: () => handleStep(idx) }, tabLabels[idx]))))),
|
|
1411
1475
|
React.createElement("div", null,
|