@jsonforms/material-renderers 3.5.1 → 3.6.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.
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useCallback, useMemo, Fragment, useEffect } from 'react';
2
2
  import { rankWith, isAllOfControl, findMatchingUISchema, createCombinatorRenderInfos, Generate, isLayout, isAnyOfControl, createDefaultValue, Resolve, encode, Paths, formatErrorMessage, errorAt, 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';
3
3
  import { withJsonFormsAllOfProps, JsonFormsDispatch, withJsonFormsAnyOfProps, DispatchCell, useJsonForms, withJsonFormsArrayLayoutProps, withTranslateProps, withArrayTranslationProps, withJsonFormsMultiEnumProps, withJsonFormsDetailProps, withJsonFormsOneOfProps, withJsonFormsLabelProps, withJsonFormsMasterListItemProps, withJsonFormsControlProps, Control, withJsonFormsEnumProps, 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';
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, ListItemButton, 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';
@@ -481,23 +481,23 @@ const i18nDefaults = {
481
481
  const toNumber$1 = (value) => value === '' ? undefined : parseInt(value, 10);
482
482
  const eventToValue$2 = (ev) => toNumber$1(ev.target.value);
483
483
  const MuiInputInteger = React.memo(function MuiInputInteger(props) {
484
- const { data, className, id, enabled, uischema, path, handleChange, config, label, } = props;
484
+ const { data, className, id, enabled, uischema, isValid, path, handleChange, config, label, } = props;
485
485
  const InputComponent = useInputComponent();
486
486
  const inputProps = { step: '1' };
487
487
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
488
488
  const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue$2);
489
- return (React.createElement(InputComponent, { label: label, type: 'number', value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
489
+ return (React.createElement(InputComponent, { label: label, type: 'number', value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true, error: !isValid }));
490
490
  });
491
491
 
492
492
  const toNumber = (value) => value === '' ? undefined : parseFloat(value);
493
493
  const eventToValue$1 = (ev) => toNumber(ev.target.value);
494
494
  const MuiInputNumber = React.memo(function MuiInputNumber(props) {
495
- const { data, className, id, enabled, uischema, path, handleChange, config, label, } = props;
495
+ const { data, className, id, enabled, uischema, isValid, path, handleChange, config, label, } = props;
496
496
  const InputComponent = useInputComponent();
497
497
  const inputProps = { step: '0.1' };
498
498
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
499
499
  const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path, eventToValue$1);
500
- return (React.createElement(InputComponent, { type: 'number', label: label, value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true }));
500
+ return (React.createElement(InputComponent, { type: 'number', label: label, value: inputValue, onChange: onChange, className: className, id: id, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, inputProps: inputProps, fullWidth: true, error: !isValid }));
501
501
  });
502
502
 
503
503
  const MuiInputNumberFormat = React.memo(function MuiInputNumberFormat(props) {
@@ -557,18 +557,18 @@ const MuiInputText = React.memo(function MuiInputText(props) {
557
557
  });
558
558
 
559
559
  const MuiInputTime = React.memo(function MuiInputTime(props) {
560
- const { data, className, id, enabled, uischema, path, handleChange, config, label, } = props;
560
+ const { data, className, id, enabled, uischema, isValid, path, handleChange, config, label, } = props;
561
561
  const InputComponent = useInputComponent();
562
562
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
563
563
  const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
564
- return (React.createElement(InputComponent, { type: 'time', value: inputValue, onChange: onChange, className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, fullWidth: true }));
564
+ return (React.createElement(InputComponent, { type: 'time', value: inputValue, onChange: onChange, className: className, id: id, label: label, disabled: !enabled, autoFocus: appliedUiSchemaOptions.focus, fullWidth: true, error: !isValid }));
565
565
  });
566
566
 
567
567
  const MuiSelect = React.memo(function MuiSelect(props) {
568
- const { data, className, id, enabled, schema, uischema, path, handleChange, options, config, label, t, multiple, } = props;
568
+ const { data, className, id, enabled, schema, uischema, isValid, path, handleChange, options, config, label, t, multiple, } = props;
569
569
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
570
570
  const noneOptionLabel = useMemo(() => t('enum.none', i18nDefaults['enum.none'], { schema, uischema, path }), [t, schema, uischema, path]);
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 }, [
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, error: !isValid }, [
572
572
  React.createElement(MenuItem, { value: '', key: 'jsonforms.enum.none' },
573
573
  React.createElement("em", null, noneOptionLabel)),
574
574
  ].concat(options.map((optionValue) => (React.createElement(MenuItem, { value: optionValue.value, key: optionValue.value }, optionValue.label))))));
@@ -703,7 +703,7 @@ const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({ label, descr
703
703
  });
704
704
 
705
705
  const ListWithDetailMasterItem = ({ index, childLabel, selected, enabled, handleSelect, removeItem, path, translations, disableRemove, }) => {
706
- return (React.createElement(ListItem, { button: true, selected: selected, onClick: handleSelect(index) },
706
+ return (React.createElement(ListItemButton, { selected: selected, onClick: handleSelect(index) },
707
707
  React.createElement(ListItemAvatar, null,
708
708
  React.createElement(Avatar, { "aria-label": 'Index' }, index + 1)),
709
709
  React.createElement(ListItemText, { primary: childLabel }),