@jsonforms/material-renderers 3.2.0-alpha.1 → 3.2.0-alpha.3
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/complex/CombinatorProperties.d.ts +1 -0
- package/lib/jsonforms-react-material.cjs.js +20 -18
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +24 -19
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/additional/MaterialListWithDetailRenderer.tsx +1 -1
- package/src/complex/CombinatorProperties.tsx +5 -2
- package/src/complex/MaterialAnyOfRenderer.tsx +9 -2
- package/src/complex/MaterialEnumArrayRenderer.tsx +6 -2
- package/src/complex/MaterialObjectRenderer.tsx +5 -2
- package/src/complex/MaterialOneOfRenderer.tsx +5 -1
- package/src/complex/TableToolbar.tsx +2 -1
- package/src/controls/MaterialRadioGroup.tsx +7 -3
- package/src/layouts/MaterialArrayLayout.tsx +1 -1
- package/src/mui-controls/MuiAutocomplete.tsx +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useCallback, useMemo, Fragment, useEffect } from 'react';
|
|
2
2
|
import { Hidden, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Tabs, Tab, TableCell, styled as styled$1, Badge, Tooltip, TableRow, Grid, Typography, IconButton, FormHelperText, Table, TableHead, TableBody, Autocomplete, TextField, Checkbox, useThemeProps, Input, FilledInput, OutlinedInput, useTheme, InputAdornment, Select, MenuItem, Switch, FormControl, FormGroup, FormControlLabel, Toolbar, ListItem, ListItemAvatar, Avatar, ListItemText, ListItemSecondaryAction, List, InputLabel, FormLabel, RadioGroup, Radio, Slider, Accordion, AccordionSummary, AccordionDetails, Card, CardHeader, CardContent, AppBar, Stepper, Step, StepButton } from '@mui/material';
|
|
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, isObjectControl, findUISchema, isOneOfControl, isObjectArray, computeLabel, composePaths, showAsRequired, isBooleanControl, optionIs, isDateControl, isDateTimeControl, isEnumControl, isIntegerControl, isTimeControl, isNumberControl, isOneOfEnumControl, isRangeControl, isStringControl, createId, removeId, update, moveUp, moveDown, getFirstPrimitiveProp, withIncreasedRank, isVisible, deriveLabelForUISchemaElement, isObjectArrayWithNesting, isNumberFormatControl, categorizationHasCategory } from '@jsonforms/core';
|
|
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, isObjectControl, findUISchema, isOneOfControl, isObjectArray, computeLabel, composePaths, showAsRequired, isBooleanControl, optionIs, isDateControl, isDateTimeControl, isEnumControl, isIntegerControl, isTimeControl, isNumberControl, isOneOfEnumControl, isRangeControl, isStringControl, createId, removeId, update, moveUp, moveDown, getFirstPrimitiveProp, withIncreasedRank, isVisible, deriveLabelForUISchemaElement, isObjectArrayWithNesting, isNumberFormatControl, categorizationHasCategory } from '@jsonforms/core';
|
|
4
4
|
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';
|
|
5
5
|
import omit from 'lodash/omit';
|
|
6
6
|
import isEmpty from 'lodash/isEmpty';
|
|
@@ -38,9 +38,9 @@ var MaterialAllOfRenderer$1 = withJsonFormsAllOfProps(MaterialAllOfRenderer);
|
|
|
38
38
|
|
|
39
39
|
class CombinatorProperties extends React.Component {
|
|
40
40
|
render() {
|
|
41
|
-
const { schema, combinatorKeyword, path } = this.props;
|
|
41
|
+
const { schema, combinatorKeyword, path, rootSchema } = this.props;
|
|
42
42
|
const otherProps = omit(schema, combinatorKeyword);
|
|
43
|
-
const foundUISchema = Generate.uiSchema(otherProps, 'VerticalLayout');
|
|
43
|
+
const foundUISchema = Generate.uiSchema(otherProps, 'VerticalLayout', undefined, rootSchema);
|
|
44
44
|
let isLayoutWithElements = false;
|
|
45
45
|
if (foundUISchema !== null && isLayout(foundUISchema)) {
|
|
46
46
|
isLayoutWithElements = foundUISchema.elements.length > 0;
|
|
@@ -70,7 +70,7 @@ const MaterialAnyOfRenderer = ({ handleChange, schema, rootSchema, indexOfFittin
|
|
|
70
70
|
const handleTabChange = useCallback((_event, newIndex) => {
|
|
71
71
|
if (isEmpty(data) ||
|
|
72
72
|
typeof data ===
|
|
73
|
-
typeof createDefaultValue(anyOfRenderInfos[newIndex].schema)) {
|
|
73
|
+
typeof createDefaultValue(anyOfRenderInfos[newIndex].schema, rootSchema)) {
|
|
74
74
|
setSelectedAnyOf(newIndex);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
@@ -79,7 +79,7 @@ const MaterialAnyOfRenderer = ({ handleChange, schema, rootSchema, indexOfFittin
|
|
|
79
79
|
}
|
|
80
80
|
}, [setConfirmDialogOpen, setSelectedAnyOf, data]);
|
|
81
81
|
const openNewTab = (newIndex) => {
|
|
82
|
-
handleChange(path, createDefaultValue(anyOfRenderInfos[newIndex].schema));
|
|
82
|
+
handleChange(path, createDefaultValue(anyOfRenderInfos[newIndex].schema, rootSchema));
|
|
83
83
|
setSelectedAnyOf(newIndex);
|
|
84
84
|
};
|
|
85
85
|
const confirm = useCallback(() => {
|
|
@@ -89,7 +89,7 @@ const MaterialAnyOfRenderer = ({ handleChange, schema, rootSchema, indexOfFittin
|
|
|
89
89
|
const anyOf = 'anyOf';
|
|
90
90
|
const anyOfRenderInfos = createCombinatorRenderInfos(schema.anyOf, rootSchema, anyOf, uischema, path, uischemas);
|
|
91
91
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
92
|
-
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: anyOf, path: path }),
|
|
92
|
+
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: anyOf, path: path, rootSchema: rootSchema }),
|
|
93
93
|
React.createElement(Tabs, { value: selectedAnyOf, onChange: handleTabChange }, anyOfRenderInfos.map((anyOfRenderInfo) => (React.createElement(Tab, { key: anyOfRenderInfo.label, label: anyOfRenderInfo.label })))),
|
|
94
94
|
anyOfRenderInfos.map((anyOfRenderInfo, anyOfIndex) => selectedAnyOf === anyOfIndex && (React.createElement(JsonFormsDispatch, { key: anyOfIndex, schema: anyOfRenderInfo.schema, uischema: anyOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }))),
|
|
95
95
|
React.createElement(TabSwitchConfirmDialog, { cancel: handleClose, confirm: confirm, id: 'anyOf-' + id, open: confirmDialogOpen, handleClose: handleClose })));
|
|
@@ -115,7 +115,7 @@ const fixedCellSmall = {
|
|
|
115
115
|
paddingLeft: 0,
|
|
116
116
|
paddingRight: 0,
|
|
117
117
|
};
|
|
118
|
-
const TableToolbar = React.memo(function TableToolbar({ numColumns, errors, label, path, addItem, schema, enabled, translations, }) {
|
|
118
|
+
const TableToolbar = React.memo(function TableToolbar({ numColumns, errors, label, path, addItem, schema, enabled, translations, rootSchema, }) {
|
|
119
119
|
return (React.createElement(TableRow, null,
|
|
120
120
|
React.createElement(NoBorderTableCell, { colSpan: numColumns },
|
|
121
121
|
React.createElement(Grid, { container: true, justifyContent: 'flex-start', alignItems: 'center', spacing: 2 },
|
|
@@ -125,7 +125,7 @@ const TableToolbar = React.memo(function TableToolbar({ numColumns, errors, labe
|
|
|
125
125
|
React.createElement(ValidationIcon, { id: 'tooltip-validation', errorMessages: errors })))))),
|
|
126
126
|
enabled ? (React.createElement(NoBorderTableCell, { align: 'right', style: fixedCellSmall },
|
|
127
127
|
React.createElement(Tooltip, { id: 'tooltip-add', title: translations.addTooltip, placement: 'bottom' },
|
|
128
|
-
React.createElement(IconButton, { "aria-label": translations.addAriaLabel, onClick: addItem(path, createDefaultValue(schema)), size: 'large' },
|
|
128
|
+
React.createElement(IconButton, { "aria-label": translations.addAriaLabel, onClick: addItem(path, createDefaultValue(schema, rootSchema)), size: 'large' },
|
|
129
129
|
React.createElement(AddIcon, null))))) : null));
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -331,7 +331,7 @@ const MuiAutocomplete = (props) => {
|
|
|
331
331
|
}, inputValue: inputValue, onInputChange: (_event, newInputValue) => {
|
|
332
332
|
setInputValue(newInputValue);
|
|
333
333
|
}, autoHighlight: true, autoSelect: true, autoComplete: true, fullWidth: true, options: options, getOptionLabel: getOptionLabel || ((option) => option?.label), freeSolo: false, renderInput: (params) => {
|
|
334
|
-
return (React.createElement(TextField, Object.assign({ label: label, type: 'text', inputProps: params.inputProps, inputRef: params.InputProps.ref, autoFocus: appliedUiSchemaOptions.focus, disabled: !enabled }, params, { id: id
|
|
334
|
+
return (React.createElement(TextField, Object.assign({ label: label, type: 'text', inputProps: params.inputProps, inputRef: params.InputProps.ref, autoFocus: appliedUiSchemaOptions.focus, disabled: !enabled }, params, { id: id, required: required && !appliedUiSchemaOptions.hideRequiredAsterisk, error: !isValid, fullWidth: !appliedUiSchemaOptions.trim, InputLabelProps: data ? { shrink: true } : undefined, onFocus: onFocus, onBlur: onBlur, focused: focused })));
|
|
335
335
|
}, renderOption: renderOption, filterOptions: filterOptions }),
|
|
336
336
|
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
337
337
|
React.createElement(FormHelperText, { error: !isValid }, secondFormHelperText)));
|
|
@@ -556,15 +556,21 @@ const hasOneOfItems = (schema) => schema.oneOf !== undefined &&
|
|
|
556
556
|
const hasEnumItems = (schema) => schema.type === 'string' && schema.enum !== undefined;
|
|
557
557
|
const materialEnumArrayRendererTester = rankWith(5, and(uiTypeIs('Control'), and(schemaMatches((schema) => hasType(schema, 'array') &&
|
|
558
558
|
!Array.isArray(schema.items) &&
|
|
559
|
-
schema.uniqueItems === true), schemaSubPathMatches('items', (schema) => {
|
|
560
|
-
|
|
559
|
+
schema.uniqueItems === true), schemaSubPathMatches('items', (schema, rootSchema) => {
|
|
560
|
+
const resolvedSchema = schema.$ref
|
|
561
|
+
? resolveSchema(rootSchema, schema.$ref, rootSchema)
|
|
562
|
+
: schema;
|
|
563
|
+
return hasOneOfItems(resolvedSchema) || hasEnumItems(resolvedSchema);
|
|
561
564
|
}))));
|
|
562
565
|
var MaterialEnumArrayRenderer$1 = withJsonFormsMultiEnumProps(MaterialEnumArrayRenderer);
|
|
563
566
|
|
|
564
567
|
const MaterialObjectRenderer = ({ renderers, cells, uischemas, schema, label, path, visible, enabled, uischema, rootSchema, }) => {
|
|
565
568
|
const detailUiSchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, () => isEmpty(path)
|
|
566
|
-
? Generate.uiSchema(schema, 'VerticalLayout')
|
|
567
|
-
: {
|
|
569
|
+
? Generate.uiSchema(schema, 'VerticalLayout', undefined, rootSchema)
|
|
570
|
+
: {
|
|
571
|
+
...Generate.uiSchema(schema, 'Group', undefined, rootSchema),
|
|
572
|
+
label,
|
|
573
|
+
}, uischema, rootSchema), [uischemas, schema, uischema.scope, path, label, uischema, rootSchema]);
|
|
568
574
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
569
575
|
React.createElement(JsonFormsDispatch, { visible: visible, enabled: enabled, schema: schema, uischema: detailUiSchema, path: path, renderers: renderers, cells: cells })));
|
|
570
576
|
};
|
|
@@ -581,7 +587,7 @@ const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, r
|
|
|
581
587
|
}, [setConfirmDialogOpen]);
|
|
582
588
|
const oneOfRenderInfos = createCombinatorRenderInfos(schema.oneOf, rootSchema, 'oneOf', uischema, path, uischemas);
|
|
583
589
|
const openNewTab = (newIndex) => {
|
|
584
|
-
handleChange(path, createDefaultValue(oneOfRenderInfos[newIndex].schema));
|
|
590
|
+
handleChange(path, createDefaultValue(oneOfRenderInfos[newIndex].schema, rootSchema));
|
|
585
591
|
setSelectedIndex(newIndex);
|
|
586
592
|
};
|
|
587
593
|
const confirm = useCallback(() => {
|
|
@@ -598,7 +604,7 @@ const MaterialOneOfRenderer = ({ handleChange, schema, path, renderers, cells, r
|
|
|
598
604
|
}
|
|
599
605
|
}, [setConfirmDialogOpen, setSelectedIndex, data]);
|
|
600
606
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
601
|
-
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: 'oneOf', path: path }),
|
|
607
|
+
React.createElement(CombinatorProperties, { schema: schema, combinatorKeyword: 'oneOf', path: path, rootSchema: rootSchema }),
|
|
602
608
|
React.createElement(Tabs, { value: selectedIndex, onChange: handleTabChange }, oneOfRenderInfos.map((oneOfRenderInfo) => (React.createElement(Tab, { key: oneOfRenderInfo.label, label: oneOfRenderInfo.label })))),
|
|
603
609
|
oneOfRenderInfos.map((oneOfRenderInfo, oneOfIndex) => selectedIndex === oneOfIndex && (React.createElement(JsonFormsDispatch, { key: oneOfIndex, schema: oneOfRenderInfo.schema, uischema: oneOfRenderInfo.uischema, path: path, renderers: renderers, cells: cells }))),
|
|
604
610
|
React.createElement(TabSwitchConfirmDialog, { cancel: cancel, confirm: confirm, id: 'oneOf-' + id, open: confirmDialogOpen, handleClose: handleClose })));
|
|
@@ -653,7 +659,7 @@ const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, ena
|
|
|
653
659
|
}
|
|
654
660
|
}, [removeItems, setSelectedIndex]);
|
|
655
661
|
const handleListItemClick = useCallback((index) => () => setSelectedIndex(index), [setSelectedIndex]);
|
|
656
|
-
const handleCreateDefaultValue = useCallback(() => createDefaultValue(schema), [createDefaultValue]);
|
|
662
|
+
const handleCreateDefaultValue = useCallback(() => createDefaultValue(schema, rootSchema), [createDefaultValue]);
|
|
657
663
|
const foundUISchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, undefined, uischema, rootSchema), [uischemas, schema, uischema.scope, path, uischema, rootSchema]);
|
|
658
664
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
659
665
|
React.useEffect(() => {
|
|
@@ -953,11 +959,10 @@ const MaterialRadioGroup = (props) => {
|
|
|
953
959
|
const isValid = errors.length === 0;
|
|
954
960
|
const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
|
|
955
961
|
const showDescription = !isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
956
|
-
const onChange = (_ev, value) => handleChange(path, value);
|
|
957
962
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
958
963
|
React.createElement(FormControl, { component: 'fieldset', fullWidth: !appliedUiSchemaOptions.trim, onFocus: onFocus, onBlur: onBlur },
|
|
959
964
|
React.createElement(FormLabel, { htmlFor: id, error: !isValid, component: 'legend', required: showAsRequired(required, appliedUiSchemaOptions.hideRequiredAsterisk) }, label),
|
|
960
|
-
React.createElement(RadioGroup, { value: props.data ?? '',
|
|
965
|
+
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 })))),
|
|
961
966
|
React.createElement(FormHelperText, { error: !isValid }, !isValid ? errors : showDescription ? description : null))));
|
|
962
967
|
};
|
|
963
968
|
|
|
@@ -1229,7 +1234,7 @@ var MaterialCategorizationLayout = withAjvProps(withTranslateProps(withJsonForms
|
|
|
1229
1234
|
|
|
1230
1235
|
const MaterialArrayLayoutComponent = (props) => {
|
|
1231
1236
|
const [expanded, setExpanded] = useState(false);
|
|
1232
|
-
const innerCreateDefaultValue = useCallback(() => createDefaultValue(props.schema), [props.schema]);
|
|
1237
|
+
const innerCreateDefaultValue = useCallback(() => createDefaultValue(props.schema, props.rootSchema), [props.schema]);
|
|
1233
1238
|
const handleChange = useCallback((panel) => (_event, expandedPanel) => {
|
|
1234
1239
|
setExpanded(expandedPanel ? panel : false);
|
|
1235
1240
|
}, []);
|