@jsonforms/material-renderers 3.3.0 → 3.4.0-alpha.1
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/additional/ListWithDetailMasterItem.d.ts +1 -1
- package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
- package/lib/additional/unwrapped.d.ts +1 -1
- package/lib/complex/MaterialTableControl.d.ts +2 -1
- package/lib/complex/TableToolbar.d.ts +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/jsonforms-react-material.cjs.js +62 -38
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +50 -32
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/layouts/ArrayToolbar.d.ts +1 -0
- package/lib/layouts/ExpandPanelRenderer.d.ts +1 -0
- package/lib/mui-controls/MuiSelect.d.ts +2 -2
- package/lib/util/theme.d.ts +3 -0
- package/package.json +7 -7
- package/src/additional/ListWithDetailMasterItem.tsx +3 -2
- package/src/additional/MaterialListWithDetailRenderer.tsx +6 -0
- package/src/complex/MaterialTableControl.tsx +34 -19
- package/src/complex/TableToolbar.tsx +4 -2
- package/src/complex/ValidationIcon.tsx +1 -1
- package/src/layouts/ArrayToolbar.tsx +3 -1
- package/src/layouts/ExpandPanelRenderer.tsx +41 -22
- package/src/layouts/MaterialArrayLayout.tsx +6 -0
- package/src/mui-controls/MuiInputText.tsx +1 -1
- package/src/mui-controls/MuiSelect.tsx +8 -2
- package/src/util/theme.ts +4 -0
|
@@ -7,16 +7,21 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
7
7
|
import union from 'lodash/union';
|
|
8
8
|
import startCase from 'lodash/startCase';
|
|
9
9
|
import range from 'lodash/range';
|
|
10
|
-
import
|
|
10
|
+
import DeleteIcon from '@mui/icons-material/Delete';
|
|
11
|
+
import ArrowDownward from '@mui/icons-material/ArrowDownward';
|
|
12
|
+
import ArrowUpward from '@mui/icons-material/ArrowUpward';
|
|
11
13
|
import { styled } from '@mui/material/styles';
|
|
14
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
15
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
12
16
|
import merge from 'lodash/merge';
|
|
13
17
|
import dayjs from 'dayjs';
|
|
14
18
|
import customParsing from 'dayjs/plugin/customParseFormat';
|
|
15
19
|
import debounce from 'lodash/debounce';
|
|
20
|
+
import Close from '@mui/icons-material/Close';
|
|
16
21
|
import map from 'lodash/map';
|
|
17
|
-
import AddIcon from '@mui/icons-material/Add';
|
|
18
22
|
import { LocalizationProvider, DatePicker, DateTimePicker, TimePicker } from '@mui/x-date-pickers';
|
|
19
23
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
24
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
20
25
|
|
|
21
26
|
const MaterialAllOfRenderer = ({ schema, rootSchema, visible, renderers, cells, path, uischemas, uischema, }) => {
|
|
22
27
|
const delegateUISchema = findMatchingUISchema(uischemas)(schema, uischema.scope, path);
|
|
@@ -107,14 +112,14 @@ const StyledBadge = styled$1(Badge)(({ theme }) => ({
|
|
|
107
112
|
const ValidationIcon = ({ errorMessages, id }) => {
|
|
108
113
|
return (React.createElement(Tooltip, { id: id, title: errorMessages },
|
|
109
114
|
React.createElement(StyledBadge, { badgeContent: errorMessages.split('\n').length },
|
|
110
|
-
React.createElement(
|
|
115
|
+
React.createElement(ErrorOutlineIcon, { color: 'inherit' }))));
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
const fixedCellSmall = {
|
|
114
119
|
paddingLeft: 0,
|
|
115
120
|
paddingRight: 0,
|
|
116
121
|
};
|
|
117
|
-
const TableToolbar = React.memo(function TableToolbar({ numColumns, errors, label, description, path, addItem, schema, enabled, translations, rootSchema, }) {
|
|
122
|
+
const TableToolbar = React.memo(function TableToolbar({ numColumns, errors, label, description, path, addItem, schema, enabled, translations, rootSchema, disableAdd, }) {
|
|
118
123
|
return (React.createElement(TableRow, null,
|
|
119
124
|
React.createElement(NoBorderTableCell, { colSpan: numColumns },
|
|
120
125
|
React.createElement(Stack, null,
|
|
@@ -124,10 +129,10 @@ const TableToolbar = React.memo(function TableToolbar({ numColumns, errors, labe
|
|
|
124
129
|
React.createElement(Grid, { item: true }, errors.length !== 0 && (React.createElement(Grid, { item: true },
|
|
125
130
|
React.createElement(ValidationIcon, { id: 'tooltip-validation', errorMessages: errors }))))),
|
|
126
131
|
description && React.createElement(FormHelperText, null, description))),
|
|
127
|
-
enabled ? (React.createElement(NoBorderTableCell, { align: 'right', style: fixedCellSmall },
|
|
132
|
+
enabled && !disableAdd ? (React.createElement(NoBorderTableCell, { align: 'right', style: fixedCellSmall },
|
|
128
133
|
React.createElement(Tooltip, { id: 'tooltip-add', title: translations.addTooltip, placement: 'bottom' },
|
|
129
134
|
React.createElement(IconButton, { "aria-label": translations.addAriaLabel, onClick: addItem(path, createDefaultValue(schema, rootSchema)), size: 'large' },
|
|
130
|
-
React.createElement(
|
|
135
|
+
React.createElement(AddIcon, null))))) : null));
|
|
131
136
|
});
|
|
132
137
|
|
|
133
138
|
const styles = {
|
|
@@ -217,7 +222,7 @@ const NonEmptyCell = (ownProps) => {
|
|
|
217
222
|
const isValid = isEmpty(emptyCellProps.errors);
|
|
218
223
|
return React.createElement(NonEmptyCellComponent, { ...emptyCellProps, isValid: isValid });
|
|
219
224
|
};
|
|
220
|
-
const NonEmptyRowComponent = ({ childPath, schema, rowIndex, openDeleteDialog, moveUpCreator, moveDownCreator, enableUp, enableDown, showSortButtons, enabled, cells, path, translations, }) => {
|
|
225
|
+
const NonEmptyRowComponent = ({ childPath, schema, rowIndex, openDeleteDialog, moveUpCreator, moveDownCreator, enableUp, enableDown, showSortButtons, enabled, cells, path, translations, disableRemove, }) => {
|
|
221
226
|
const moveUp = useMemo(() => moveUpCreator(path, rowIndex), [moveUpCreator, path, rowIndex]);
|
|
222
227
|
const moveDown = useMemo(() => moveDownCreator(path, rowIndex), [moveDownCreator, path, rowIndex]);
|
|
223
228
|
return (React.createElement(TableRow, { key: childPath, hover: true },
|
|
@@ -233,13 +238,13 @@ const NonEmptyRowComponent = ({ childPath, schema, rowIndex, openDeleteDialog, m
|
|
|
233
238
|
React.createElement(Tooltip, { id: 'tooltip-down', title: translations.down, placement: 'bottom', open: enableDown ? undefined : false },
|
|
234
239
|
React.createElement(IconButton, { "aria-label": translations.downAriaLabel, onClick: moveDown, disabled: !enableDown, size: 'large' },
|
|
235
240
|
React.createElement(ArrowDownward, null)))))) : null,
|
|
236
|
-
React.createElement(Grid, { item: true },
|
|
241
|
+
!disableRemove ? (React.createElement(Grid, { item: true },
|
|
237
242
|
React.createElement(Tooltip, { id: 'tooltip-remove', title: translations.removeTooltip, placement: 'bottom' },
|
|
238
243
|
React.createElement(IconButton, { "aria-label": translations.removeAriaLabel, onClick: () => openDeleteDialog(childPath, rowIndex), size: 'large' },
|
|
239
|
-
React.createElement(
|
|
244
|
+
React.createElement(DeleteIcon, null))))) : null))) : null));
|
|
240
245
|
};
|
|
241
246
|
const NonEmptyRow = React.memo(NonEmptyRowComponent);
|
|
242
|
-
const TableRows = ({ data, path, schema, openDeleteDialog, moveUp, moveDown, uischema, config, enabled, cells, translations, }) => {
|
|
247
|
+
const TableRows = ({ data, path, schema, openDeleteDialog, moveUp, moveDown, uischema, config, enabled, cells, translations, disableRemove, }) => {
|
|
243
248
|
const isEmptyTable = data === 0;
|
|
244
249
|
if (isEmptyTable) {
|
|
245
250
|
return (React.createElement(EmptyTable, { numColumns: getValidColumnProps(schema).length + 1, translations: translations }));
|
|
@@ -248,7 +253,7 @@ const TableRows = ({ data, path, schema, openDeleteDialog, moveUp, moveDown, uis
|
|
|
248
253
|
return (React.createElement(React.Fragment, null, range(data).map((index) => {
|
|
249
254
|
const childPath = Paths.compose(path, `${index}`);
|
|
250
255
|
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 ||
|
|
251
|
-
appliedUiSchemaOptions.showArrayTableSortButtons, enabled: enabled, cells: cells, path: path, translations: translations }));
|
|
256
|
+
appliedUiSchemaOptions.showArrayTableSortButtons, enabled: enabled, cells: cells, path: path, translations: translations, disableRemove: disableRemove }));
|
|
252
257
|
})));
|
|
253
258
|
};
|
|
254
259
|
class MaterialTableControl extends React.Component {
|
|
@@ -257,7 +262,10 @@ class MaterialTableControl extends React.Component {
|
|
|
257
262
|
this.addItem = (path, value) => this.props.addItem(path, value);
|
|
258
263
|
}
|
|
259
264
|
render() {
|
|
260
|
-
const { label, description, path, schema, rootSchema, uischema, errors, openDeleteDialog, visible, enabled, cells, translations, } = this.props;
|
|
265
|
+
const { label, description, path, schema, rootSchema, uischema, errors, openDeleteDialog, visible, enabled, cells, translations, disableAdd, disableRemove, config, } = this.props;
|
|
266
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
267
|
+
const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
|
|
268
|
+
const doDisableRemove = disableRemove || appliedUiSchemaOptions.disableRemove;
|
|
261
269
|
const controlElement = uischema;
|
|
262
270
|
const isObjectSchema = schema.type === 'object';
|
|
263
271
|
const headerCells = isObjectSchema
|
|
@@ -268,12 +276,12 @@ class MaterialTableControl extends React.Component {
|
|
|
268
276
|
}
|
|
269
277
|
return (React.createElement(Table, null,
|
|
270
278
|
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 }),
|
|
279
|
+
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, disableAdd: doDisableAdd }),
|
|
272
280
|
isObjectSchema && (React.createElement(TableRow, null,
|
|
273
281
|
headerCells,
|
|
274
282
|
enabled ? React.createElement(TableCell, null) : null))),
|
|
275
283
|
React.createElement(TableBody, null,
|
|
276
|
-
React.createElement(TableRows, { openDeleteDialog: openDeleteDialog, translations: translations, ...this.props }))));
|
|
284
|
+
React.createElement(TableRows, { openDeleteDialog: openDeleteDialog, translations: translations, ...this.props, disableRemove: doDisableRemove }))));
|
|
277
285
|
}
|
|
278
286
|
}
|
|
279
287
|
|
|
@@ -557,10 +565,10 @@ const MuiInputTime = React.memo(function MuiInputTime(props) {
|
|
|
557
565
|
});
|
|
558
566
|
|
|
559
567
|
const MuiSelect = React.memo(function MuiSelect(props) {
|
|
560
|
-
const { data, className, id, enabled, schema, uischema, path, handleChange, options, config, label, t, } = props;
|
|
568
|
+
const { data, className, id, enabled, schema, uischema, path, handleChange, options, config, label, t, multiple, } = props;
|
|
561
569
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
562
570
|
const noneOptionLabel = useMemo(() => t('enum.none', i18nDefaults['enum.none'], { schema, uischema, path }), [t, schema, uischema, path]);
|
|
563
|
-
return (React.createElement(Select, { className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: (ev) => handleChange(path, ev.target.value || undefined), fullWidth: true }, [
|
|
571
|
+
return (React.createElement(Select, { className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: (ev) => handleChange(path, ev.target.value || undefined), fullWidth: true, multiple: multiple || false }, [
|
|
564
572
|
React.createElement(MenuItem, { value: '', key: 'jsonforms.enum.none' },
|
|
565
573
|
React.createElement("em", null, noneOptionLabel)),
|
|
566
574
|
].concat(options.map((optionValue) => (React.createElement(MenuItem, { value: optionValue.value, key: optionValue.value }, optionValue.label))))));
|
|
@@ -675,7 +683,7 @@ const MaterialLabelRenderer = ({ text, visible }) => {
|
|
|
675
683
|
};
|
|
676
684
|
var MaterialLabelRenderer$1 = withJsonFormsLabelProps(MaterialLabelRenderer);
|
|
677
685
|
|
|
678
|
-
const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({ label, description, errors, addItem, path, enabled, createDefault, translations, }) {
|
|
686
|
+
const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({ label, description, errors, addItem, path, enabled, createDefault, translations, disableAdd, }) {
|
|
679
687
|
return (React.createElement(Toolbar, { disableGutters: true },
|
|
680
688
|
React.createElement(Stack, null,
|
|
681
689
|
React.createElement(Grid, { container: true, alignItems: 'center', justifyContent: 'space-between' },
|
|
@@ -685,7 +693,7 @@ const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({ label, descr
|
|
|
685
693
|
React.createElement(Typography, { variant: 'h6' }, label)),
|
|
686
694
|
React.createElement(Grid, { item: true }, errors.length !== 0 && (React.createElement(Grid, { item: true },
|
|
687
695
|
React.createElement(ValidationIcon, { id: 'tooltip-validation', errorMessages: errors })))))),
|
|
688
|
-
enabled && (React.createElement(Grid, { item: true },
|
|
696
|
+
enabled && !disableAdd && (React.createElement(Grid, { item: true },
|
|
689
697
|
React.createElement(Grid, { container: true },
|
|
690
698
|
React.createElement(Grid, { item: true },
|
|
691
699
|
React.createElement(Tooltip, { id: 'tooltip-add', title: translations.addTooltip, placement: 'bottom' },
|
|
@@ -694,19 +702,19 @@ const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({ label, descr
|
|
|
694
702
|
description && React.createElement(FormHelperText, null, description))));
|
|
695
703
|
});
|
|
696
704
|
|
|
697
|
-
const ListWithDetailMasterItem = ({ index, childLabel, selected, enabled, handleSelect, removeItem, path, translations, }) => {
|
|
705
|
+
const ListWithDetailMasterItem = ({ index, childLabel, selected, enabled, handleSelect, removeItem, path, translations, disableRemove, }) => {
|
|
698
706
|
return (React.createElement(ListItem, { button: true, selected: selected, onClick: handleSelect(index) },
|
|
699
707
|
React.createElement(ListItemAvatar, null,
|
|
700
708
|
React.createElement(Avatar, { "aria-label": 'Index' }, index + 1)),
|
|
701
709
|
React.createElement(ListItemText, { primary: childLabel }),
|
|
702
|
-
enabled && (React.createElement(ListItemSecondaryAction, null,
|
|
710
|
+
enabled && !disableRemove && (React.createElement(ListItemSecondaryAction, null,
|
|
703
711
|
React.createElement(Tooltip, { id: 'tooltip-remove', title: translations.removeTooltip, placement: 'bottom' },
|
|
704
712
|
React.createElement(IconButton, { "aria-label": translations.removeAriaLabel, onClick: removeItem(path, index), size: 'large' },
|
|
705
|
-
React.createElement(
|
|
713
|
+
React.createElement(DeleteIcon, null)))))));
|
|
706
714
|
};
|
|
707
715
|
var ListWithDetailMasterItem$1 = withJsonFormsMasterListItemProps(ListWithDetailMasterItem);
|
|
708
716
|
|
|
709
|
-
const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, enabled, errors, visible, label, required, removeItems, addItem, data, renderers, cells, config, rootSchema, translations, description, }) => {
|
|
717
|
+
const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, enabled, errors, visible, label, required, removeItems, addItem, data, renderers, cells, config, rootSchema, translations, description, disableAdd, disableRemove, }) => {
|
|
710
718
|
const [selectedIndex, setSelectedIndex] = useState(undefined);
|
|
711
719
|
const handleRemoveItem = useCallback((p, value) => () => {
|
|
712
720
|
removeItems(p, [value])();
|
|
@@ -721,6 +729,8 @@ const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, ena
|
|
|
721
729
|
const handleCreateDefaultValue = useCallback(() => createDefaultValue(schema, rootSchema), [createDefaultValue]);
|
|
722
730
|
const foundUISchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, undefined, uischema, rootSchema), [uischemas, schema, uischema.scope, path, uischema, rootSchema]);
|
|
723
731
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
732
|
+
const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
|
|
733
|
+
const doDisableRemove = disableRemove || appliedUiSchemaOptions.disableRemove;
|
|
724
734
|
React.useEffect(() => {
|
|
725
735
|
setSelectedIndex(undefined);
|
|
726
736
|
}, [schema]);
|
|
@@ -728,10 +738,10 @@ const MaterialListWithDetailRenderer = ({ uischemas, schema, uischema, path, ena
|
|
|
728
738
|
return null;
|
|
729
739
|
}
|
|
730
740
|
return (React.createElement(React.Fragment, null,
|
|
731
|
-
React.createElement(ArrayLayoutToolbar, { translations: translations, label: computeLabel(label, required, appliedUiSchemaOptions.hideRequiredAsterisk), description: description, errors: errors, path: path, enabled: enabled, addItem: addItem, createDefault: handleCreateDefaultValue }),
|
|
741
|
+
React.createElement(ArrayLayoutToolbar, { translations: translations, label: computeLabel(label, required, appliedUiSchemaOptions.hideRequiredAsterisk), description: description, errors: errors, path: path, enabled: enabled, addItem: addItem, createDefault: handleCreateDefaultValue, disableAdd: doDisableAdd }),
|
|
732
742
|
React.createElement(Grid, { container: true, direction: 'row', spacing: 2 },
|
|
733
743
|
React.createElement(Grid, { item: true, xs: 3 },
|
|
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)))),
|
|
744
|
+
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, disableRemove: doDisableRemove })))) : (React.createElement("p", null, translations.noDataMessage)))),
|
|
735
745
|
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))))));
|
|
736
746
|
};
|
|
737
747
|
const materialListWithDetailTester = rankWith(4, and(uiTypeIs('ListWithDetail'), isObjectArray));
|
|
@@ -1158,13 +1168,13 @@ const ExpandPanelRendererComponent = (props) => {
|
|
|
1158
1168
|
removeId(labelHtmlId);
|
|
1159
1169
|
};
|
|
1160
1170
|
}, [labelHtmlId]);
|
|
1161
|
-
const { enabled, childLabel, childPath, index, expanded, moveDown, moveUp, enableMoveDown, enableMoveUp, handleExpansion, removeItems, path, rootSchema, schema, uischema, uischemas, renderers, cells, config, translations, } = props;
|
|
1171
|
+
const { enabled, childLabel, childPath, index, expanded, moveDown, moveUp, enableMoveDown, enableMoveUp, handleExpansion, removeItems, path, rootSchema, schema, uischema, uischemas, renderers, cells, config, translations, disableRemove, } = props;
|
|
1162
1172
|
const foundUISchema = useMemo(() => findUISchema(uischemas, schema, uischema.scope, path, undefined, uischema, rootSchema), [uischemas, schema, uischema.scope, path, uischema, rootSchema]);
|
|
1163
1173
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
1164
1174
|
const showSortButtons = appliedUiSchemaOptions.showSortButtons ||
|
|
1165
1175
|
appliedUiSchemaOptions.showArrayLayoutSortButtons;
|
|
1166
1176
|
return (React.createElement(Accordion, { "aria-labelledby": labelHtmlId, expanded: expanded, onChange: handleExpansion(childPath) },
|
|
1167
|
-
React.createElement(AccordionSummary, { expandIcon: React.createElement(
|
|
1177
|
+
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, null) },
|
|
1168
1178
|
React.createElement(Grid, { container: true, alignItems: 'center' },
|
|
1169
1179
|
React.createElement(Grid, { item: true, xs: 7, md: 9 },
|
|
1170
1180
|
React.createElement(Grid, { container: true, alignItems: 'center' },
|
|
@@ -1185,10 +1195,10 @@ const ExpandPanelRendererComponent = (props) => {
|
|
|
1185
1195
|
React.createElement(Tooltip, { id: 'tooltip-down', title: translations.down, placement: 'bottom', open: enableMoveDown ? undefined : false },
|
|
1186
1196
|
React.createElement(IconButton, { onClick: moveDown(path, index), style: iconStyle, disabled: !enableMoveDown, "aria-label": translations.downAriaLabel, size: 'large' },
|
|
1187
1197
|
React.createElement(ArrowDownward, null)))))) : (''),
|
|
1188
|
-
enabled && (React.createElement(Grid, { item: true },
|
|
1198
|
+
enabled && !disableRemove && (React.createElement(Grid, { item: true },
|
|
1189
1199
|
React.createElement(Tooltip, { id: 'tooltip-remove', title: translations.removeTooltip, placement: 'bottom' },
|
|
1190
1200
|
React.createElement(IconButton, { onClick: removeItems(path, [index]), style: iconStyle, "aria-label": translations.removeAriaLabel, size: 'large' },
|
|
1191
|
-
React.createElement(
|
|
1201
|
+
React.createElement(DeleteIcon, null))))))))))),
|
|
1192
1202
|
React.createElement(AccordionDetails, null,
|
|
1193
1203
|
React.createElement(JsonFormsDispatch, { enabled: enabled, schema: schema, uischema: foundUISchema, path: childPath, key: childPath, renderers: renderers, cells: cells }))));
|
|
1194
1204
|
};
|
|
@@ -1202,13 +1212,16 @@ const ctxDispatchToExpandPanelProps = (dispatch) => ({
|
|
|
1202
1212
|
.reverse()
|
|
1203
1213
|
.forEach((s) => array.splice(s, 1));
|
|
1204
1214
|
return array;
|
|
1205
|
-
}));
|
|
1215
|
+
}, { type: 'REMOVE', indices: toDelete }));
|
|
1206
1216
|
}, [dispatch]),
|
|
1207
1217
|
moveUp: useCallback((path, toMove) => (event) => {
|
|
1208
1218
|
event.stopPropagation();
|
|
1209
1219
|
dispatch(update(path, (array) => {
|
|
1210
1220
|
moveUp(array, toMove);
|
|
1211
1221
|
return array;
|
|
1222
|
+
}, {
|
|
1223
|
+
type: 'MOVE',
|
|
1224
|
+
moves: [{ from: toMove, to: toMove - 1 }],
|
|
1212
1225
|
}));
|
|
1213
1226
|
}, [dispatch]),
|
|
1214
1227
|
moveDown: useCallback((path, toMove) => (event) => {
|
|
@@ -1216,6 +1229,9 @@ const ctxDispatchToExpandPanelProps = (dispatch) => ({
|
|
|
1216
1229
|
dispatch(update(path, (array) => {
|
|
1217
1230
|
moveDown(array, toMove);
|
|
1218
1231
|
return array;
|
|
1232
|
+
}, {
|
|
1233
|
+
type: 'MOVE',
|
|
1234
|
+
moves: [{ from: toMove, to: toMove + 1 }],
|
|
1219
1235
|
}));
|
|
1220
1236
|
}, [dispatch]),
|
|
1221
1237
|
});
|
|
@@ -1351,12 +1367,14 @@ const MaterialArrayLayoutComponent = (props) => {
|
|
|
1351
1367
|
setExpanded(expandedPanel ? panel : false);
|
|
1352
1368
|
}, []);
|
|
1353
1369
|
const isExpanded = (index) => expanded === composePaths(props.path, `${index}`);
|
|
1354
|
-
const { enabled, data, path, schema, uischema, errors, addItem, renderers, cells, label, required, rootSchema, config, uischemas, translations, description, } = props;
|
|
1370
|
+
const { enabled, data, path, schema, uischema, errors, addItem, renderers, cells, label, required, rootSchema, config, uischemas, translations, description, disableAdd, disableRemove, } = props;
|
|
1355
1371
|
const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
|
|
1372
|
+
const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
|
|
1373
|
+
const doDisableRemove = disableRemove || appliedUiSchemaOptions.disableRemove;
|
|
1356
1374
|
return (React.createElement("div", null,
|
|
1357
|
-
React.createElement(ArrayLayoutToolbar, { translations: translations, label: computeLabel(label, required, appliedUiSchemaOptions.hideRequiredAsterisk), description: description, errors: errors, path: path, enabled: enabled, addItem: addItem, createDefault: innerCreateDefaultValue }),
|
|
1375
|
+
React.createElement(ArrayLayoutToolbar, { translations: translations, label: computeLabel(label, required, appliedUiSchemaOptions.hideRequiredAsterisk), description: description, errors: errors, path: path, enabled: enabled, addItem: addItem, createDefault: innerCreateDefaultValue, disableAdd: doDisableAdd }),
|
|
1358
1376
|
React.createElement("div", null, data > 0 ? (map(range(data), (index) => {
|
|
1359
|
-
return (React.createElement(ExpandPanelRenderer$1, { enabled: enabled, index: index, expanded: isExpanded(index), schema: schema, path: path, handleExpansion: handleChange, uischema: uischema, renderers: renderers, cells: cells, key: index, rootSchema: rootSchema, enableMoveUp: index != 0, enableMoveDown: index < data - 1, config: config, childLabelProp: appliedUiSchemaOptions.elementLabelProp, uischemas: uischemas, translations: translations }));
|
|
1377
|
+
return (React.createElement(ExpandPanelRenderer$1, { enabled: enabled, index: index, expanded: isExpanded(index), schema: schema, path: path, handleExpansion: handleChange, uischema: uischema, renderers: renderers, cells: cells, key: index, rootSchema: rootSchema, enableMoveUp: index != 0, enableMoveDown: index < data - 1, config: config, childLabelProp: appliedUiSchemaOptions.elementLabelProp, uischemas: uischemas, translations: translations, disableRemove: doDisableRemove }));
|
|
1360
1378
|
})) : (React.createElement("p", null, translations.noDataMessage)))));
|
|
1361
1379
|
};
|
|
1362
1380
|
const MaterialArrayLayout$1 = React.memo(MaterialArrayLayoutComponent);
|