@jsonforms/material-renderers 3.0.0-beta.5 → 3.0.0-rc.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/docs/assets/js/search.json +1 -1
- package/docs/globals.html +77 -31
- package/docs/index.html +6 -0
- package/docs/interfaces/categorizationstate.html +1 -1
- package/docs/interfaces/categorizationstepperstate.html +1 -1
- package/docs/interfaces/materialcategorizationlayoutrendererprops.html +49 -4
- package/docs/interfaces/materialcategorizationstepperlayoutrendererprops.html +46 -1
- package/docs/interfaces/materiallabelablelayoutrendererprops.html +328 -0
- package/docs/interfaces/materiallayoutrendererprops.html +5 -0
- package/docs/interfaces/withoptionlabel.html +3 -3
- package/lib/additional/MaterialLabelRenderer.d.ts +3 -3
- package/lib/cells/MaterialEnumCell.d.ts +2 -1
- package/lib/cells/MaterialOneOfEnumCell.d.ts +2 -1
- package/lib/controls/MaterialEnumControl.d.ts +2 -1
- package/lib/controls/MaterialOneOfEnumControl.d.ts +2 -1
- package/lib/controls/index.d.ts +2 -2
- package/lib/jsonforms-react-material.cjs.js +82 -46
- package/lib/jsonforms-react-material.cjs.js.map +1 -1
- package/lib/jsonforms-react-material.esm.js +79 -48
- package/lib/jsonforms-react-material.esm.js.map +1 -1
- package/lib/layouts/MaterialCategorizationLayout.d.ts +4 -3
- package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +4 -3
- package/lib/layouts/MaterialGroupLayout.d.ts +2 -2
- package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
- package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
- package/lib/mui-controls/MuiAutocomplete.d.ts +2 -2
- package/lib/mui-controls/MuiSelect.d.ts +2 -1
- package/lib/util/i18nDefaults.d.ts +3 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/layout.d.ts +3 -0
- package/package.json +6 -6
- package/src/additional/MaterialLabelRenderer.tsx +5 -7
- package/src/cells/MaterialEnumCell.tsx +4 -3
- package/src/cells/MaterialOneOfEnumCell.tsx +3 -3
- package/src/controls/MaterialEnumControl.tsx +12 -5
- package/src/controls/MaterialOneOfEnumControl.tsx +13 -5
- package/src/layouts/MaterialCategorizationLayout.tsx +18 -9
- package/src/layouts/MaterialCategorizationStepperLayout.tsx +19 -12
- package/src/layouts/MaterialGroupLayout.tsx +6 -5
- package/src/mui-controls/MuiAutocomplete.tsx +81 -38
- package/src/mui-controls/MuiInputText.tsx +4 -1
- package/src/mui-controls/MuiSelect.tsx +10 -5
- package/src/util/i18nDefaults.ts +3 -0
- package/src/util/index.ts +1 -0
- package/src/util/layout.tsx +4 -0
- package/stats.html +1 -1
- package/test/renderers/MaterialArrayLayout.test.tsx +4 -4
- package/test/renderers/MaterialCategorizationLayout.test.tsx +17 -7
- package/test/renderers/MaterialCategorizationStepperLayout.test.tsx +21 -11
- package/test/renderers/MaterialGroupLayout.test.tsx +4 -1
- package/test/renderers/MaterialInputControl.test.tsx +4 -0
- package/test/renderers/MaterialLabelRenderer.test.tsx +2 -1
- package/test/renderers/util.ts +5 -0
|
@@ -1,11 +1,11 @@
|
|
|
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';
|
|
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, deriveLabelForUISchemaElement, update, moveUp, moveDown, getFirstPrimitiveProp, createId, removeId, isObjectArrayWithNesting, isNumberFormatControl, categorizationHasCategory } from '@jsonforms/core';
|
|
2
2
|
import React, { useMemo, Fragment, useState, useCallback, useRef, useEffect } from 'react';
|
|
3
|
-
import { DispatchCell, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsDetailProps, JsonFormsDispatch, withJsonFormsAllOfProps, withJsonFormsAnyOfProps, withJsonFormsOneOfProps, withJsonFormsMultiEnumProps,
|
|
3
|
+
import { DispatchCell, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsDetailProps, JsonFormsDispatch, withJsonFormsAllOfProps, withJsonFormsAnyOfProps, withJsonFormsOneOfProps, withJsonFormsMultiEnumProps, withJsonFormsLabelProps, withJsonFormsMasterListItemProps, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, Control, withJsonFormsOneOfEnumProps, withJsonFormsLayoutProps, withJsonFormsContext, withJsonFormsCellProps, withJsonFormsEnumCellProps, withJsonFormsOneOfEnumCellProps } from '@jsonforms/react';
|
|
4
4
|
import isEmpty from 'lodash/isEmpty';
|
|
5
5
|
import union from 'lodash/union';
|
|
6
6
|
import startCase from 'lodash/startCase';
|
|
7
7
|
import range from 'lodash/range';
|
|
8
|
-
import { TableCell, styled as styled$1, Badge, Tooltip, TableRow, Grid, Typography, Hidden, IconButton, FormHelperText, Table, TableHead, TableBody, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Tabs, Tab, Checkbox, Select, MenuItem,
|
|
8
|
+
import { TableCell, styled as styled$1, Badge, Tooltip, TableRow, Grid, Typography, Hidden, IconButton, FormHelperText, Table, TableHead, TableBody, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button, Tabs, Tab, Checkbox, TextField, Select, MenuItem, Input, useTheme, InputAdornment, FormControl, FormGroup, FormControlLabel, Toolbar, ListItem, ListItemAvatar, Avatar, ListItemText, ListItemSecondaryAction, List, Switch, InputLabel, Autocomplete, FormLabel, Slider, RadioGroup, Radio, Card, CardHeader, CardContent, AppBar, Accordion, AccordionSummary, AccordionDetails, Stepper, Step, StepButton } from '@mui/material';
|
|
9
9
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
10
10
|
import ArrowDownward from '@mui/icons-material/ArrowDownward';
|
|
11
11
|
import ArrowUpward from '@mui/icons-material/ArrowUpward';
|
|
@@ -327,12 +327,6 @@ const MuiCheckbox = React.memo((props) => {
|
|
|
327
327
|
return (React.createElement(Checkbox, { checked: checked, onChange: (_ev, isChecked) => handleChange(path, isChecked), className: className, id: id, disabled: !enabled, inputProps: inputProps }));
|
|
328
328
|
});
|
|
329
329
|
|
|
330
|
-
const MuiSelect = React.memo((props) => {
|
|
331
|
-
const { data, className, id, enabled, uischema, path, handleChange, options, config } = props;
|
|
332
|
-
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
333
|
-
return (React.createElement(Select, { className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: ev => handleChange(path, ev.target.value), fullWidth: true, variant: 'standard' }, [React.createElement(MenuItem, { value: '', key: 'empty' })].concat(options.map(optionValue => (React.createElement(MenuItem, { value: optionValue.value, key: optionValue.value }, optionValue.label))))));
|
|
334
|
-
});
|
|
335
|
-
|
|
336
330
|
dayjs.extend(customParsing);
|
|
337
331
|
const createOnChangeHandler = (path, handleChange, saveFormat) => (time, textInputValue) => {
|
|
338
332
|
if (!time) {
|
|
@@ -389,8 +383,8 @@ const withAjvProps = (Component) => (props) => {
|
|
|
389
383
|
return (React.createElement(Component, Object.assign({}, props, { ajv: ajv })));
|
|
390
384
|
};
|
|
391
385
|
|
|
392
|
-
const eventToValue$
|
|
393
|
-
const useDebouncedChange = (handleChange, defaultValue, data, path, eventToValueFunction = eventToValue$
|
|
386
|
+
const eventToValue$3 = (ev) => ev.target.value;
|
|
387
|
+
const useDebouncedChange = (handleChange, defaultValue, data, path, eventToValueFunction = eventToValue$3, timeout = 300) => {
|
|
394
388
|
const [input, setInput] = useState(data ?? defaultValue);
|
|
395
389
|
useEffect(() => {
|
|
396
390
|
setInput(data ?? defaultValue);
|
|
@@ -412,23 +406,35 @@ const useFocus = () => {
|
|
|
412
406
|
return [focused, onFocus, onBlur];
|
|
413
407
|
};
|
|
414
408
|
|
|
409
|
+
const i18nDefaults = {
|
|
410
|
+
'enum.none': 'None'
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
const MuiSelect = React.memo((props) => {
|
|
414
|
+
const { data, className, id, enabled, schema, uischema, path, handleChange, options, config, t } = props;
|
|
415
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
416
|
+
const noneOptionLabel = useMemo(() => t('enum.none', i18nDefaults['enum.none'], { schema, uischema, path }), [t, schema, uischema, path]);
|
|
417
|
+
return (React.createElement(Select, { className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, value: data !== undefined ? data : '', onChange: ev => handleChange(path, ev.target.value || undefined), fullWidth: true, variant: 'standard' }, [React.createElement(MenuItem, { value: '', key: 'jsonforms.enum.none' },
|
|
418
|
+
React.createElement("em", null, noneOptionLabel))].concat(options.map(optionValue => (React.createElement(MenuItem, { value: optionValue.value, key: optionValue.value }, optionValue.label))))));
|
|
419
|
+
});
|
|
420
|
+
|
|
415
421
|
const toNumber$1 = (value) => value === '' ? undefined : parseInt(value, 10);
|
|
416
|
-
const eventToValue$
|
|
422
|
+
const eventToValue$2 = (ev) => toNumber$1(ev.target.value);
|
|
417
423
|
const MuiInputInteger = React.memo((props) => {
|
|
418
424
|
const { data, className, id, enabled, uischema, path, handleChange, config } = props;
|
|
419
425
|
const inputProps = { step: '1' };
|
|
420
426
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
421
|
-
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue$
|
|
427
|
+
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue$2);
|
|
422
428
|
return (React.createElement(Input, { type: 'number', value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
|
|
423
429
|
});
|
|
424
430
|
|
|
425
431
|
const toNumber = (value) => value === '' ? undefined : parseFloat(value);
|
|
426
|
-
const eventToValue = (ev) => toNumber(ev.target.value);
|
|
432
|
+
const eventToValue$1 = (ev) => toNumber(ev.target.value);
|
|
427
433
|
const MuiInputNumber = React.memo((props) => {
|
|
428
434
|
const { data, className, id, enabled, uischema, path, handleChange, config } = props;
|
|
429
435
|
const inputProps = { step: '0.1' };
|
|
430
436
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
431
|
-
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue);
|
|
437
|
+
const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue$1);
|
|
432
438
|
return (React.createElement(Input, { type: 'number', value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
|
|
433
439
|
});
|
|
434
440
|
|
|
@@ -449,6 +455,7 @@ const MuiInputNumberFormat = React.memo((props) => {
|
|
|
449
455
|
return (React.createElement(Input, { type: 'text', value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, multiline: appliedUiSchemaOptions.multi, fullWidth: !appliedUiSchemaOptions.trim || maxLength === undefined, inputProps: inputProps, error: !isValid }));
|
|
450
456
|
});
|
|
451
457
|
|
|
458
|
+
const eventToValue = (ev) => ev.target.value === '' ? undefined : ev.target.value;
|
|
452
459
|
const MuiInputText = React.memo((props) => {
|
|
453
460
|
const [showAdornment, setShowAdornment] = useState(false);
|
|
454
461
|
const { data, config, className, id, enabled, uischema, isValid, path, handleChange, schema, muiInputProps, inputComponent } = props;
|
|
@@ -465,7 +472,7 @@ const MuiInputText = React.memo((props) => {
|
|
|
465
472
|
if (appliedUiSchemaOptions.trim && maxLength !== undefined) {
|
|
466
473
|
inputProps.size = maxLength;
|
|
467
474
|
}
|
|
468
|
-
const [inputText, onChange, onClear] = useDebouncedChange(handleChange, '', data, path);
|
|
475
|
+
const [inputText, onChange, onClear] = useDebouncedChange(handleChange, '', data, path, eventToValue);
|
|
469
476
|
const onPointerEnter = () => setShowAdornment(true);
|
|
470
477
|
const onPointerLeave = () => setShowAdornment(false);
|
|
471
478
|
const theme = useTheme();
|
|
@@ -519,12 +526,11 @@ var MaterialEnumArrayRenderer$1 = withJsonFormsMultiEnumProps(MaterialEnumArrayR
|
|
|
519
526
|
const materialArrayControlTester = rankWith(3, or(isObjectArrayControl, isPrimitiveArrayControl));
|
|
520
527
|
|
|
521
528
|
const materialLabelRendererTester = rankWith(1, uiTypeIs('Label'));
|
|
522
|
-
const MaterialLabelRenderer = ({
|
|
523
|
-
const labelElement = uischema;
|
|
529
|
+
const MaterialLabelRenderer = ({ text, visible }) => {
|
|
524
530
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
525
|
-
React.createElement(Typography, { variant: 'h6' },
|
|
531
|
+
React.createElement(Typography, { variant: 'h6' }, text)));
|
|
526
532
|
};
|
|
527
|
-
var MaterialLabelRenderer$1 =
|
|
533
|
+
var MaterialLabelRenderer$1 = withJsonFormsLabelProps(MaterialLabelRenderer);
|
|
528
534
|
|
|
529
535
|
const ArrayLayoutToolbar = React.memo(({ label, errors, addItem, path, createDefault }) => {
|
|
530
536
|
return (React.createElement(Toolbar, { disableGutters: true },
|
|
@@ -622,24 +628,40 @@ const MaterialInputControl = (props) => {
|
|
|
622
628
|
};
|
|
623
629
|
|
|
624
630
|
const MuiAutocomplete = (props) => {
|
|
625
|
-
const { data, className, id, enabled, uischema, path, handleChange, options, config, getOptionLabel, renderOption, filterOptions } = props;
|
|
631
|
+
const { description, errors, visible, required, label, data, className, id, enabled, uischema, path, handleChange, options, config, getOptionLabel, renderOption, filterOptions, isValid } = props;
|
|
626
632
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
627
633
|
const [inputValue, setInputValue] = React.useState(data ?? '');
|
|
634
|
+
const [focused, onFocus, onBlur] = useFocus();
|
|
628
635
|
const findOption = options.find(o => o.value === data) ?? null;
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
636
|
+
const showDescription = !isDescriptionHidden(visible, description, focused, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
637
|
+
const firstFormHelperText = showDescription
|
|
638
|
+
? description
|
|
639
|
+
: !isValid
|
|
640
|
+
? errors
|
|
641
|
+
: null;
|
|
642
|
+
const secondFormHelperText = showDescription && !isValid ? errors : null;
|
|
643
|
+
return (React.createElement(Hidden, { xsUp: !visible },
|
|
644
|
+
React.createElement(Autocomplete, { className: className, id: id, disabled: !enabled, value: findOption, onChange: (_event, newValue) => {
|
|
645
|
+
handleChange(path, newValue?.value);
|
|
646
|
+
}, inputValue: inputValue, onInputChange: (_event, newInputValue) => {
|
|
647
|
+
setInputValue(newInputValue);
|
|
648
|
+
}, autoHighlight: true, autoSelect: true, autoComplete: true, fullWidth: true, options: options, getOptionLabel: getOptionLabel || (option => option?.label), freeSolo: false, renderInput: params => {
|
|
649
|
+
return (React.createElement(TextField, Object.assign({ label: label, variant: 'standard', type: 'text', inputProps: params.inputProps, inputRef: params.InputProps.ref, autoFocus: appliedUiSchemaOptions.focus, disabled: !enabled }, params, { id: id + '-input', required: required && !appliedUiSchemaOptions.hideRequiredAsterisk, error: !isValid, fullWidth: !appliedUiSchemaOptions.trim, InputLabelProps: data ? { shrink: true } : undefined, onFocus: onFocus, onBlur: onBlur, focused: focused })));
|
|
650
|
+
}, renderOption: renderOption, filterOptions: filterOptions }),
|
|
651
|
+
React.createElement(FormHelperText, { error: !isValid && !showDescription }, firstFormHelperText),
|
|
652
|
+
React.createElement(FormHelperText, { error: !isValid }, secondFormHelperText)));
|
|
634
653
|
};
|
|
635
654
|
|
|
636
655
|
const MaterialEnumControl = (props) => {
|
|
637
|
-
const { config, uischema } = props;
|
|
656
|
+
const { config, uischema, errors } = props;
|
|
638
657
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
639
|
-
|
|
658
|
+
const isValid = errors.length === 0;
|
|
659
|
+
return (appliedUiSchemaOptions.autocomplete === false ?
|
|
660
|
+
React.createElement(MaterialInputControl, Object.assign({}, props, { input: MuiSelect })) :
|
|
661
|
+
React.createElement(MuiAutocomplete, Object.assign({}, props, { isValid: isValid })));
|
|
640
662
|
};
|
|
641
663
|
const materialEnumControlTester = rankWith(2, isEnumControl);
|
|
642
|
-
var MaterialEnumControl$1 = withJsonFormsEnumProps(MaterialEnumControl);
|
|
664
|
+
var MaterialEnumControl$1 = withJsonFormsEnumProps(withTranslateProps(React.memo(MaterialEnumControl)), false);
|
|
643
665
|
|
|
644
666
|
const MaterialNativeControl = (props) => {
|
|
645
667
|
const [focused, onFocus, onBlur] = useFocus();
|
|
@@ -852,12 +874,15 @@ const materialAnyOfStringOrEnumControlTester = rankWith(5, simpleAnyOf);
|
|
|
852
874
|
var MaterialAnyOfStringOrEnumControl$1 = withJsonFormsControlProps(MaterialAnyOfStringOrEnumControl);
|
|
853
875
|
|
|
854
876
|
const MaterialOneOfEnumControl = (props) => {
|
|
855
|
-
const { config, uischema } = props;
|
|
877
|
+
const { config, uischema, errors } = props;
|
|
856
878
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
857
|
-
|
|
879
|
+
const isValid = errors.length === 0;
|
|
880
|
+
return (appliedUiSchemaOptions.autocomplete === false ?
|
|
881
|
+
React.createElement(MaterialInputControl, Object.assign({}, props, { input: MuiSelect })) :
|
|
882
|
+
React.createElement(MuiAutocomplete, Object.assign({}, props, { isValid: isValid })));
|
|
858
883
|
};
|
|
859
884
|
const materialOneOfEnumControlTester = rankWith(5, isOneOfEnumControl);
|
|
860
|
-
var MaterialOneOfEnumControl$1 = withJsonFormsOneOfEnumProps(MaterialOneOfEnumControl);
|
|
885
|
+
var MaterialOneOfEnumControl$1 = withJsonFormsOneOfEnumProps(withTranslateProps(React.memo(MaterialOneOfEnumControl)), false);
|
|
861
886
|
|
|
862
887
|
const MaterialOneOfRadioGroupControl = (props) => {
|
|
863
888
|
return React.createElement(MaterialRadioGroup, Object.assign({}, props));
|
|
@@ -885,17 +910,17 @@ const Unwrapped = {
|
|
|
885
910
|
|
|
886
911
|
const groupTester = rankWith(1, uiTypeIs('Group'));
|
|
887
912
|
const style = { marginBottom: '10px' };
|
|
888
|
-
const GroupComponent = React.memo(({ visible, enabled, uischema, ...props }) => {
|
|
913
|
+
const GroupComponent = React.memo(({ visible, enabled, uischema, label, ...props }) => {
|
|
889
914
|
const groupLayout = uischema;
|
|
890
915
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
891
916
|
React.createElement(Card, { style: style },
|
|
892
|
-
!isEmpty(
|
|
917
|
+
!isEmpty(label) && (React.createElement(CardHeader, { title: label })),
|
|
893
918
|
React.createElement(CardContent, null,
|
|
894
919
|
React.createElement(MaterialLayoutRenderer, Object.assign({}, props, { visible: visible, enabled: enabled, elements: groupLayout.elements }))))));
|
|
895
920
|
});
|
|
896
|
-
const MaterializedGroupLayoutRenderer = ({ uischema, schema, path, visible, enabled, renderers, cells, direction }) => {
|
|
921
|
+
const MaterializedGroupLayoutRenderer = ({ uischema, schema, path, visible, enabled, renderers, cells, direction, label }) => {
|
|
897
922
|
const groupLayout = uischema;
|
|
898
|
-
return (React.createElement(GroupComponent, { elements: groupLayout.elements, schema: schema, path: path, direction: direction, visible: visible, enabled: enabled, uischema: uischema, renderers: renderers, cells: cells }));
|
|
923
|
+
return (React.createElement(GroupComponent, { elements: groupLayout.elements, schema: schema, path: path, direction: direction, visible: visible, enabled: enabled, uischema: uischema, renderers: renderers, cells: cells, label: label }));
|
|
899
924
|
};
|
|
900
925
|
var MaterialGroupLayout = withJsonFormsLayoutProps(MaterializedGroupLayoutRenderer);
|
|
901
926
|
const materialGroupTester = withIncreasedRank(1, groupTester);
|
|
@@ -937,10 +962,10 @@ const isSingleLevelCategorization = and(uiTypeIs('Categorization'), (uischema) =
|
|
|
937
962
|
});
|
|
938
963
|
const materialCategorizationTester = rankWith(1, isSingleLevelCategorization);
|
|
939
964
|
const MaterialCategorizationLayoutRenderer = (props) => {
|
|
940
|
-
const { data, path, renderers, cells, schema, uischema, visible, enabled, selected, onChange, ajv } = props;
|
|
965
|
+
const { data, path, renderers, cells, schema, uischema, visible, enabled, selected, onChange, ajv, t } = props;
|
|
941
966
|
const categorization = uischema;
|
|
942
967
|
const [activeCategory, setActiveCategory] = useState(selected ?? 0);
|
|
943
|
-
const categories = categorization.elements.filter((category) => isVisible(category, data, undefined, ajv));
|
|
968
|
+
const categories = useMemo(() => categorization.elements.filter((category) => isVisible(category, data, undefined, ajv)), [categorization, data, ajv]);
|
|
944
969
|
const childProps = {
|
|
945
970
|
elements: categories[activeCategory].elements,
|
|
946
971
|
schema,
|
|
@@ -957,13 +982,16 @@ const MaterialCategorizationLayoutRenderer = (props) => {
|
|
|
957
982
|
}
|
|
958
983
|
setActiveCategory(value);
|
|
959
984
|
};
|
|
985
|
+
const tabLabels = useMemo(() => {
|
|
986
|
+
return categories.map((e) => deriveLabelForUISchemaElement(e, t));
|
|
987
|
+
}, [categories, t]);
|
|
960
988
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
961
989
|
React.createElement(AppBar, { position: 'static' },
|
|
962
|
-
React.createElement(Tabs, { value: activeCategory, onChange: onTabChange, textColor: 'inherit', indicatorColor: 'secondary', variant: 'scrollable' }, categories.map((
|
|
990
|
+
React.createElement(Tabs, { value: activeCategory, onChange: onTabChange, textColor: 'inherit', indicatorColor: 'secondary', variant: 'scrollable' }, categories.map((_, idx) => (React.createElement(Tab, { key: idx, label: tabLabels[idx] }))))),
|
|
963
991
|
React.createElement("div", { style: { marginTop: '0.5em' } },
|
|
964
992
|
React.createElement(MaterialLayoutRenderer, Object.assign({}, childProps)))));
|
|
965
993
|
};
|
|
966
|
-
var MaterialCategorizationLayout = withJsonFormsLayoutProps(
|
|
994
|
+
var MaterialCategorizationLayout = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(MaterialCategorizationLayoutRenderer)));
|
|
967
995
|
|
|
968
996
|
const iconStyle = { float: 'right' };
|
|
969
997
|
const ExpandPanelRendererComponent = (props) => {
|
|
@@ -1092,7 +1120,7 @@ var MaterialDateCell$1 = withJsonFormsCellProps(MaterialDateCell);
|
|
|
1092
1120
|
|
|
1093
1121
|
const MaterialEnumCell = (props) => (React.createElement(MuiSelect, Object.assign({}, props)));
|
|
1094
1122
|
const materialEnumCellTester = rankWith(2, isEnumControl);
|
|
1095
|
-
var MaterialEnumCell$1 = withJsonFormsEnumCellProps(MaterialEnumCell);
|
|
1123
|
+
var MaterialEnumCell$1 = withJsonFormsEnumCellProps(withTranslateProps(React.memo(MaterialEnumCell)), false);
|
|
1096
1124
|
|
|
1097
1125
|
const MaterialIntegerCell = (props) => (React.createElement(MuiInputInteger, Object.assign({}, props)));
|
|
1098
1126
|
const materialIntegerCellTester = rankWith(2, isIntegerControl);
|
|
@@ -1108,7 +1136,7 @@ var MaterialNumberFormatCell$1 = withJsonFormsCellProps(MaterialNumberFormatCell
|
|
|
1108
1136
|
|
|
1109
1137
|
const MaterialOneOfEnumCell = (props) => (React.createElement(MuiSelect, Object.assign({}, props)));
|
|
1110
1138
|
const materialOneOfEnumCellTester = rankWith(2, isOneOfEnumControl);
|
|
1111
|
-
var MaterialOneOfEnumCell$1 = withJsonFormsOneOfEnumCellProps(MaterialOneOfEnumCell);
|
|
1139
|
+
var MaterialOneOfEnumCell$1 = withJsonFormsOneOfEnumCellProps(withTranslateProps(React.memo(MaterialOneOfEnumCell)), false);
|
|
1112
1140
|
|
|
1113
1141
|
const MaterialTextCell = (props) => (React.createElement(MuiInputText, Object.assign({}, props)));
|
|
1114
1142
|
const materialTextCellTester = rankWith(1, isStringControl);
|
|
@@ -1137,7 +1165,7 @@ const MaterialCategorizationStepperLayoutRenderer = (props) => {
|
|
|
1137
1165
|
const handleStep = (step) => {
|
|
1138
1166
|
setActiveCategory(step);
|
|
1139
1167
|
};
|
|
1140
|
-
const { data, path, renderers, schema, uischema, visible, cells, config, ajv } = props;
|
|
1168
|
+
const { data, path, renderers, schema, uischema, visible, cells, config, ajv, t } = props;
|
|
1141
1169
|
const categorization = uischema;
|
|
1142
1170
|
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
1143
1171
|
const buttonWrapperStyle = {
|
|
@@ -1151,7 +1179,7 @@ const MaterialCategorizationStepperLayoutRenderer = (props) => {
|
|
|
1151
1179
|
const buttonStyle = {
|
|
1152
1180
|
marginRight: '1em'
|
|
1153
1181
|
};
|
|
1154
|
-
const categories = categorization.elements.filter((category) => isVisible(category, data, undefined, ajv));
|
|
1182
|
+
const categories = useMemo(() => categorization.elements.filter((category) => isVisible(category, data, undefined, ajv)), [categorization, data, ajv]);
|
|
1155
1183
|
const childProps = {
|
|
1156
1184
|
elements: categories[activeCategory].elements,
|
|
1157
1185
|
schema,
|
|
@@ -1161,16 +1189,19 @@ const MaterialCategorizationStepperLayoutRenderer = (props) => {
|
|
|
1161
1189
|
renderers,
|
|
1162
1190
|
cells
|
|
1163
1191
|
};
|
|
1192
|
+
const tabLabels = useMemo(() => {
|
|
1193
|
+
return categories.map((e) => deriveLabelForUISchemaElement(e, t));
|
|
1194
|
+
}, [categories, t]);
|
|
1164
1195
|
return (React.createElement(Hidden, { xsUp: !visible },
|
|
1165
|
-
React.createElement(Stepper, { activeStep: activeCategory, nonLinear: true }, categories.map((
|
|
1166
|
-
React.createElement(StepButton, { onClick: () => handleStep(idx) },
|
|
1196
|
+
React.createElement(Stepper, { activeStep: activeCategory, nonLinear: true }, categories.map((_, idx) => (React.createElement(Step, { key: tabLabels[idx] },
|
|
1197
|
+
React.createElement(StepButton, { onClick: () => handleStep(idx) }, tabLabels[idx]))))),
|
|
1167
1198
|
React.createElement("div", null,
|
|
1168
1199
|
React.createElement(MaterialLayoutRenderer, Object.assign({}, childProps))),
|
|
1169
1200
|
!!appliedUiSchemaOptions.showNavButtons ? (React.createElement("div", { style: buttonWrapperStyle },
|
|
1170
1201
|
React.createElement(Button, { style: buttonNextStyle, variant: "contained", color: "primary", disabled: activeCategory >= categories.length - 1, onClick: () => handleStep(activeCategory + 1) }, "Next"),
|
|
1171
1202
|
React.createElement(Button, { style: buttonStyle, color: "secondary", variant: "contained", disabled: activeCategory <= 0, onClick: () => handleStep(activeCategory - 1) }, "Previous"))) : (React.createElement(React.Fragment, null))));
|
|
1172
1203
|
};
|
|
1173
|
-
var MaterialCategorizationStepperLayout = withJsonFormsLayoutProps(
|
|
1204
|
+
var MaterialCategorizationStepperLayout = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(MaterialCategorizationStepperLayoutRenderer)));
|
|
1174
1205
|
|
|
1175
1206
|
const materialRenderers = [
|
|
1176
1207
|
{
|
|
@@ -1243,5 +1274,5 @@ const materialCells = [
|
|
|
1243
1274
|
{ tester: materialTimeCellTester, cell: MaterialTimeCell$1 }
|
|
1244
1275
|
];
|
|
1245
1276
|
|
|
1246
|
-
export { CustomizableCells as Customizable, MaterialAllOfRenderer$1 as MaterialAllOfRenderer, MaterialAnyOfRenderer$1 as MaterialAnyOfRenderer, MaterialAnyOfStringOrEnumControl$1 as MaterialAnyOfStringOrEnumControl, MaterialArrayControlRenderer$1 as MaterialArrayControlRenderer, MaterialArrayLayout, MaterialBooleanCell$1 as MaterialBooleanCell, MaterialBooleanControl$1 as MaterialBooleanControl, MaterialBooleanToggleCell$1 as MaterialBooleanToggleCell, MaterialBooleanToggleControl$1 as MaterialBooleanToggleControl, MaterialCategorizationLayout, MaterialDateCell$1 as MaterialDateCell, MaterialDateControl$1 as MaterialDateControl, MaterialDateTimeControl$1 as MaterialDateTimeControl, MaterialEnumArrayRenderer$1 as MaterialEnumArrayRenderer, MaterialEnumCell$1 as MaterialEnumCell, MaterialEnumControl$1 as MaterialEnumControl, MaterialGroupLayout, MaterialHorizontalLayout, MaterialInputControl, MaterialIntegerCell$1 as MaterialIntegerCell, MaterialIntegerControl$1 as MaterialIntegerControl, MaterialLayoutRenderer, MaterialNativeControl$1 as MaterialNativeControl, MaterialNumberCell$1 as MaterialNumberCell, MaterialNumberControl$1 as MaterialNumberControl, MaterialNumberFormatCell$1 as MaterialNumberFormatCell, MaterialObjectRenderer$1 as MaterialObjectRenderer, MaterialOneOfEnumCell$1 as MaterialOneOfEnumCell, MaterialOneOfEnumControl$1 as MaterialOneOfEnumControl, MaterialOneOfRadioGroupControl$1 as MaterialOneOfRadioGroupControl, MaterialOneOfRenderer$1 as MaterialOneOfRenderer, MaterialRadioGroupControl$1 as MaterialRadioGroupControl, MaterialSliderControl$1 as MaterialSliderControl, MaterialTextCell$1 as MaterialTextCell, MaterialTextControl$1 as MaterialTextControl, MaterialTimeCell$1 as MaterialTimeCell, MaterialTimeControl$1 as MaterialTimeControl, MaterialVerticalLayout, MuiCheckbox, MuiInputInteger, MuiInputNumber, MuiInputNumberFormat, MuiInputText, MuiInputTime, MuiSelect, ResettableTextField, Unwrapped, createOnChangeHandler, getData, materialAllOfControlTester, materialAnyOfControlTester, materialAnyOfStringOrEnumControlTester, materialArrayControlTester, materialArrayLayoutTester, materialBooleanCellTester, materialBooleanControlTester, materialBooleanToggleCellTester, materialBooleanToggleControlTester, materialCategorizationTester, materialCells, materialDateCellTester, materialDateControlTester, materialDateTimeControlTester, materialEnumArrayRendererTester, materialEnumCellTester, materialEnumControlTester, materialGroupTester, materialHorizontalLayoutTester, materialIntegerCellTester, materialIntegerControlTester, materialNativeControlTester, materialNumberCellTester, materialNumberControlTester, materialNumberFormatCellTester, materialObjectControlTester, materialOneOfControlTester, materialOneOfEnumCellTester, materialOneOfEnumControlTester, materialOneOfRadioGroupControlTester, materialRadioGroupControlTester, materialRenderers, materialSliderControlTester, materialTextCellTester, materialTextControlTester, materialTimeCellTester, materialTimeControlTester, materialVerticalLayoutTester, renderLayoutElements, useDebouncedChange, useFocus, withAjvProps };
|
|
1277
|
+
export { CustomizableCells as Customizable, MaterialAllOfRenderer$1 as MaterialAllOfRenderer, MaterialAnyOfRenderer$1 as MaterialAnyOfRenderer, MaterialAnyOfStringOrEnumControl$1 as MaterialAnyOfStringOrEnumControl, MaterialArrayControlRenderer$1 as MaterialArrayControlRenderer, MaterialArrayLayout, MaterialBooleanCell$1 as MaterialBooleanCell, MaterialBooleanControl$1 as MaterialBooleanControl, MaterialBooleanToggleCell$1 as MaterialBooleanToggleCell, MaterialBooleanToggleControl$1 as MaterialBooleanToggleControl, MaterialCategorizationLayout, MaterialDateCell$1 as MaterialDateCell, MaterialDateControl$1 as MaterialDateControl, MaterialDateTimeControl$1 as MaterialDateTimeControl, MaterialEnumArrayRenderer$1 as MaterialEnumArrayRenderer, MaterialEnumCell$1 as MaterialEnumCell, MaterialEnumControl$1 as MaterialEnumControl, MaterialGroupLayout, MaterialHorizontalLayout, MaterialInputControl, MaterialIntegerCell$1 as MaterialIntegerCell, MaterialIntegerControl$1 as MaterialIntegerControl, MaterialLayoutRenderer, MaterialNativeControl$1 as MaterialNativeControl, MaterialNumberCell$1 as MaterialNumberCell, MaterialNumberControl$1 as MaterialNumberControl, MaterialNumberFormatCell$1 as MaterialNumberFormatCell, MaterialObjectRenderer$1 as MaterialObjectRenderer, MaterialOneOfEnumCell$1 as MaterialOneOfEnumCell, MaterialOneOfEnumControl$1 as MaterialOneOfEnumControl, MaterialOneOfRadioGroupControl$1 as MaterialOneOfRadioGroupControl, MaterialOneOfRenderer$1 as MaterialOneOfRenderer, MaterialRadioGroupControl$1 as MaterialRadioGroupControl, MaterialSliderControl$1 as MaterialSliderControl, MaterialTextCell$1 as MaterialTextCell, MaterialTextControl$1 as MaterialTextControl, MaterialTimeCell$1 as MaterialTimeCell, MaterialTimeControl$1 as MaterialTimeControl, MaterialVerticalLayout, MuiCheckbox, MuiInputInteger, MuiInputNumber, MuiInputNumberFormat, MuiInputText, MuiInputTime, MuiSelect, ResettableTextField, Unwrapped, createOnChangeHandler, getData, i18nDefaults, materialAllOfControlTester, materialAnyOfControlTester, materialAnyOfStringOrEnumControlTester, materialArrayControlTester, materialArrayLayoutTester, materialBooleanCellTester, materialBooleanControlTester, materialBooleanToggleCellTester, materialBooleanToggleControlTester, materialCategorizationTester, materialCells, materialDateCellTester, materialDateControlTester, materialDateTimeControlTester, materialEnumArrayRendererTester, materialEnumCellTester, materialEnumControlTester, materialGroupTester, materialHorizontalLayoutTester, materialIntegerCellTester, materialIntegerControlTester, materialNativeControlTester, materialNumberCellTester, materialNumberControlTester, materialNumberFormatCellTester, materialObjectControlTester, materialOneOfControlTester, materialOneOfEnumCellTester, materialOneOfEnumControlTester, materialOneOfRadioGroupControlTester, materialRadioGroupControlTester, materialRenderers, materialSliderControlTester, materialTextCellTester, materialTextControlTester, materialTimeCellTester, materialTimeControlTester, materialVerticalLayoutTester, renderLayoutElements, useDebouncedChange, useFocus, withAjvProps };
|
|
1247
1278
|
//# sourceMappingURL=jsonforms-react-material.esm.js.map
|