@jsonforms/material-renderers 3.1.0-alpha.1 → 3.1.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.
Files changed (123) hide show
  1. package/README.md +16 -17
  2. package/lib/additional/ListWithDetailMasterItem.d.ts +2 -0
  3. package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
  4. package/lib/additional/index.d.ts +2 -2
  5. package/lib/additional/unwrapped.d.ts +5 -0
  6. package/lib/cells/index.d.ts +1 -1
  7. package/lib/complex/CombinatorProperties.d.ts +1 -2
  8. package/lib/complex/DeleteDialog.d.ts +5 -1
  9. package/lib/complex/MaterialAllOfRenderer.d.ts +1 -1
  10. package/lib/complex/MaterialAnyOfRenderer.d.ts +1 -1
  11. package/lib/complex/MaterialArrayControlRenderer.d.ts +2 -1
  12. package/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
  13. package/lib/complex/MaterialObjectRenderer.d.ts +1 -1
  14. package/lib/complex/MaterialOneOfRenderer.d.ts +1 -1
  15. package/lib/complex/MaterialTableControl.d.ts +4 -2
  16. package/lib/complex/NoBorderTableCell.d.ts +2 -2
  17. package/lib/complex/TableToolbar.d.ts +3 -2
  18. package/lib/complex/index.d.ts +11 -16
  19. package/lib/complex/unwrapped.d.ts +9 -0
  20. package/lib/controls/MaterialBooleanControl.d.ts +1 -1
  21. package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
  22. package/lib/controls/index.d.ts +8 -26
  23. package/lib/controls/unwrapped.d.ts +19 -0
  24. package/lib/index.d.ts +34 -1
  25. package/lib/jsonforms-react-material.cjs.js +690 -599
  26. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  27. package/lib/jsonforms-react-material.esm.js +620 -557
  28. package/lib/jsonforms-react-material.esm.js.map +1 -1
  29. package/lib/layouts/ArrayToolbar.d.ts +3 -1
  30. package/lib/layouts/ExpandPanelRenderer.d.ts +3 -1
  31. package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
  32. package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
  33. package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
  34. package/lib/layouts/index.d.ts +3 -1
  35. package/lib/layouts/unwrapped.d.ts +10 -0
  36. package/lib/mui-controls/MuiCheckbox.d.ts +1 -1
  37. package/lib/mui-controls/MuiInputInteger.d.ts +1 -1
  38. package/lib/mui-controls/MuiInputNumber.d.ts +1 -1
  39. package/lib/mui-controls/MuiInputNumberFormat.d.ts +1 -1
  40. package/lib/mui-controls/MuiInputText.d.ts +1 -1
  41. package/lib/mui-controls/MuiInputTime.d.ts +1 -1
  42. package/lib/mui-controls/MuiSelect.d.ts +1 -1
  43. package/lib/mui-controls/MuiToggle.d.ts +1 -1
  44. package/lib/mui-controls/index.d.ts +3 -1
  45. package/lib/util/layout.d.ts +2 -3
  46. package/package.json +16 -9
  47. package/src/additional/ListWithDetailMasterItem.tsx +31 -23
  48. package/src/additional/MaterialLabelRenderer.tsx +8 -15
  49. package/src/additional/MaterialListWithDetailRenderer.tsx +8 -5
  50. package/src/additional/index.ts +12 -4
  51. package/src/additional/unwrapped.ts +32 -0
  52. package/src/cells/MaterialBooleanCell.tsx +1 -1
  53. package/src/cells/MaterialBooleanToggleCell.tsx +2 -2
  54. package/src/cells/MaterialDateCell.tsx +4 -12
  55. package/src/cells/MaterialEnumCell.tsx +13 -6
  56. package/src/cells/MaterialIntegerCell.tsx +1 -1
  57. package/src/cells/MaterialNumberCell.tsx +1 -1
  58. package/src/cells/MaterialNumberFormatCell.tsx +1 -1
  59. package/src/cells/MaterialOneOfEnumCell.tsx +17 -7
  60. package/src/cells/MaterialTextCell.tsx +1 -1
  61. package/src/cells/MaterialTimeCell.tsx +1 -1
  62. package/src/cells/index.ts +7 -7
  63. package/src/complex/CombinatorProperties.tsx +20 -9
  64. package/src/complex/DeleteDialog.tsx +48 -37
  65. package/src/complex/MaterialAllOfRenderer.tsx +2 -2
  66. package/src/complex/MaterialAnyOfRenderer.tsx +3 -3
  67. package/src/complex/MaterialArrayControlRenderer.tsx +27 -11
  68. package/src/complex/MaterialEnumArrayRenderer.tsx +6 -8
  69. package/src/complex/MaterialObjectRenderer.tsx +6 -3
  70. package/src/complex/MaterialOneOfRenderer.tsx +105 -88
  71. package/src/complex/MaterialTableControl.tsx +145 -97
  72. package/src/complex/NoBorderTableCell.tsx +3 -5
  73. package/src/complex/TableToolbar.tsx +24 -25
  74. package/src/complex/ValidationIcon.tsx +10 -18
  75. package/src/complex/index.ts +35 -32
  76. package/src/complex/unwrapped.ts +39 -0
  77. package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +19 -11
  78. package/src/controls/MaterialBooleanControl.tsx +22 -16
  79. package/src/controls/MaterialBooleanToggleControl.tsx +22 -16
  80. package/src/controls/MaterialDateControl.tsx +16 -19
  81. package/src/controls/MaterialDateTimeControl.tsx +24 -23
  82. package/src/controls/MaterialEnumControl.tsx +21 -15
  83. package/src/controls/MaterialInputControl.tsx +7 -8
  84. package/src/controls/MaterialIntegerControl.tsx +1 -1
  85. package/src/controls/MaterialNativeControl.tsx +12 -9
  86. package/src/controls/MaterialNumberControl.tsx +1 -1
  87. package/src/controls/MaterialOneOfEnumControl.tsx +21 -15
  88. package/src/controls/MaterialOneOfRadioGroupControl.tsx +5 -3
  89. package/src/controls/MaterialRadioGroup.tsx +11 -17
  90. package/src/controls/MaterialRadioGroupControl.tsx +8 -3
  91. package/src/controls/MaterialSliderControl.tsx +17 -16
  92. package/src/controls/MaterialTextControl.tsx +1 -1
  93. package/src/controls/MaterialTimeControl.tsx +19 -22
  94. package/src/controls/index.ts +36 -72
  95. package/src/controls/unwrapped.ts +57 -0
  96. package/src/index.ts +41 -22
  97. package/src/layouts/ArrayToolbar.tsx +38 -42
  98. package/src/layouts/ExpandPanelRenderer.tsx +96 -67
  99. package/src/layouts/MaterialArrayLayout.tsx +21 -16
  100. package/src/layouts/MaterialArrayLayoutRenderer.tsx +6 -9
  101. package/src/layouts/MaterialCategorizationLayout.tsx +52 -21
  102. package/src/layouts/MaterialCategorizationStepperLayout.tsx +60 -44
  103. package/src/layouts/MaterialGroupLayout.tsx +25 -6
  104. package/src/layouts/MaterialHorizontalLayout.tsx +18 -4
  105. package/src/layouts/MaterialVerticalLayout.tsx +18 -4
  106. package/src/layouts/index.ts +18 -7
  107. package/src/layouts/unwrapped.ts +41 -0
  108. package/src/mui-controls/MuiAutocomplete.tsx +51 -35
  109. package/src/mui-controls/MuiCheckbox.tsx +5 -3
  110. package/src/mui-controls/MuiInputInteger.tsx +31 -32
  111. package/src/mui-controls/MuiInputNumber.tsx +16 -16
  112. package/src/mui-controls/MuiInputNumberFormat.tsx +51 -42
  113. package/src/mui-controls/MuiInputText.tsx +30 -19
  114. package/src/mui-controls/MuiInputTime.tsx +11 -12
  115. package/src/mui-controls/MuiSelect.tsx +15 -6
  116. package/src/mui-controls/MuiToggle.tsx +5 -3
  117. package/src/mui-controls/index.ts +3 -1
  118. package/src/util/datejs.tsx +41 -20
  119. package/src/util/debounce.ts +26 -11
  120. package/src/util/focus.ts +7 -7
  121. package/src/util/i18nDefaults.ts +2 -2
  122. package/src/util/layout.tsx +47 -42
  123. package/src/util/theme.ts +2 -2
@@ -0,0 +1,39 @@
1
+ /*
2
+ The MIT License
3
+
4
+ Copyright (c) 2017-2019 EclipseSource Munich
5
+ https://github.com/eclipsesource/jsonforms
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ */
25
+ import { MaterialAllOfRenderer } from './MaterialAllOfRenderer';
26
+ import { MaterialAnyOfRenderer } from './MaterialAnyOfRenderer';
27
+ import { MaterialArrayControlRenderer } from './MaterialArrayControlRenderer';
28
+ import { MaterialEnumArrayRenderer } from './MaterialEnumArrayRenderer';
29
+ import { MaterialObjectRenderer } from './MaterialObjectRenderer';
30
+ import { MaterialOneOfRenderer } from './MaterialOneOfRenderer';
31
+
32
+ export const UnwrappedComplex = {
33
+ MaterialAllOfRenderer,
34
+ MaterialAnyOfRenderer,
35
+ MaterialArrayControlRenderer,
36
+ MaterialEnumArrayRenderer,
37
+ MaterialObjectRenderer,
38
+ MaterialOneOfRenderer,
39
+ };
@@ -32,7 +32,7 @@ import {
32
32
  rankWith,
33
33
  schemaMatches,
34
34
  uiTypeIs,
35
- WithClassname
35
+ WithClassname,
36
36
  } from '@jsonforms/core';
37
37
  import { Control, withJsonFormsControlProps } from '@jsonforms/react';
38
38
  import { Input, InputBaseComponentProps } from '@mui/material';
@@ -43,10 +43,10 @@ import { MaterialInputControl } from './MaterialInputControl';
43
43
 
44
44
  const findEnumSchema = (schemas: JsonSchema[]) =>
45
45
  schemas.find(
46
- s => s.enum !== undefined && (s.type === 'string' || s.type === undefined)
46
+ (s) => s.enum !== undefined && (s.type === 'string' || s.type === undefined)
47
47
  );
48
48
  const findTextSchema = (schemas: JsonSchema[]) =>
49
- schemas.find(s => s.type === 'string' && s.enum === undefined);
49
+ schemas.find((s) => s.type === 'string' && s.enum === undefined);
50
50
 
51
51
  const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
52
52
  const {
@@ -59,12 +59,15 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
59
59
  isValid,
60
60
  path,
61
61
  handleChange,
62
- schema
62
+ schema,
63
63
  } = props;
64
64
  const enumSchema = findEnumSchema(schema.anyOf);
65
65
  const stringSchema = findTextSchema(schema.anyOf);
66
66
  const maxLength = stringSchema.maxLength;
67
- const appliedUiSchemaOptions = useMemo(() => merge({}, config, uischema.options),[config, uischema.options]);
67
+ const appliedUiSchemaOptions = useMemo(
68
+ () => merge({}, config, uischema.options),
69
+ [config, uischema.options]
70
+ );
68
71
  const inputProps: InputBaseComponentProps = useMemo(() => {
69
72
  let propMemo: InputBaseComponentProps = {};
70
73
  if (appliedUiSchemaOptions.restrict) {
@@ -75,12 +78,17 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
75
78
  }
76
79
  propMemo.list = props.id + 'datalist';
77
80
  return propMemo;
78
- },[appliedUiSchemaOptions,props.id]);
79
- const [inputText, onChange] = useDebouncedChange(handleChange, '', data, path);
81
+ }, [appliedUiSchemaOptions, props.id]);
82
+ const [inputText, onChange] = useDebouncedChange(
83
+ handleChange,
84
+ '',
85
+ data,
86
+ path
87
+ );
80
88
 
81
89
  const dataList = (
82
90
  <datalist id={props.id + 'datalist'}>
83
- {enumSchema.enum.map(optionValue => (
91
+ {enumSchema.enum.map((optionValue) => (
84
92
  <option value={optionValue} key={optionValue} />
85
93
  ))}
86
94
  </datalist>
@@ -117,15 +125,15 @@ const hasEnumAndText = (schemas: JsonSchema[]) => {
117
125
  const enumSchema = findEnumSchema(schemas);
118
126
  const stringSchema = findTextSchema(schemas);
119
127
  const remainingSchemas = schemas.filter(
120
- s => s !== enumSchema || s !== stringSchema
128
+ (s) => s !== enumSchema || s !== stringSchema
121
129
  );
122
- const wrongType = remainingSchemas.find(s => s.type && s.type !== 'string');
130
+ const wrongType = remainingSchemas.find((s) => s.type && s.type !== 'string');
123
131
  return enumSchema && stringSchema && !wrongType;
124
132
  };
125
133
  const simpleAnyOf = and(
126
134
  uiTypeIs('Control'),
127
135
  schemaMatches(
128
- schema => schema.hasOwnProperty('anyOf') && hasEnumAndText(schema.anyOf)
136
+ (schema) => schema.hasOwnProperty('anyOf') && hasEnumAndText(schema.anyOf)
129
137
  )
130
138
  );
131
139
  export const materialAnyOfStringOrEnumControlTester: RankedTester = rankWith(
@@ -30,10 +30,15 @@ import {
30
30
  RankedTester,
31
31
  rankWith,
32
32
  ControlProps,
33
- isDescriptionHidden
33
+ isDescriptionHidden,
34
34
  } from '@jsonforms/core';
35
35
  import { withJsonFormsControlProps } from '@jsonforms/react';
36
- import { FormControlLabel, FormHelperText, Tooltip, Hidden } from '@mui/material';
36
+ import {
37
+ FormControlLabel,
38
+ FormHelperText,
39
+ Tooltip,
40
+ Hidden,
41
+ } from '@mui/material';
37
42
  import { MuiCheckbox } from '../mui-controls/MuiCheckbox';
38
43
 
39
44
  export const MaterialBooleanControl = ({
@@ -49,9 +54,8 @@ export const MaterialBooleanControl = ({
49
54
  errors,
50
55
  path,
51
56
  config,
52
- description
57
+ description,
53
58
  }: ControlProps) => {
54
-
55
59
  const isValid = errors.length === 0;
56
60
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
57
61
 
@@ -65,16 +69,18 @@ export const MaterialBooleanControl = ({
65
69
  appliedUiSchemaOptions.showUnfocusedDescription
66
70
  );
67
71
 
68
- const showTooltip = !showDescription && !isDescriptionHidden(
69
- visible,
70
- description,
71
- // Tooltips have their own focus handlers, so we do not need to rely
72
- // on focus state here. So we pass 'true' to treat it as focused.
73
- true,
74
- // We also pass true here for showUnfocusedDescription since it should
75
- // render regardless of that setting.
76
- true
77
- );
72
+ const showTooltip =
73
+ !showDescription &&
74
+ !isDescriptionHidden(
75
+ visible,
76
+ description,
77
+ // Tooltips have their own focus handlers, so we do not need to rely
78
+ // on focus state here. So we pass 'true' to treat it as focused.
79
+ true,
80
+ // We also pass true here for showUnfocusedDescription since it should
81
+ // render regardless of that setting.
82
+ true
83
+ );
78
84
 
79
85
  const firstFormHelperText = showDescription
80
86
  ? description
@@ -100,7 +106,7 @@ export const MaterialBooleanControl = ({
100
106
 
101
107
  return (
102
108
  <Hidden xsUp={!visible}>
103
- <Tooltip id={tooltipId} title={(showTooltip) ? description : ''}>
109
+ <Tooltip id={tooltipId} title={showTooltip ? description : ''}>
104
110
  <FormControlLabel
105
111
  label={label}
106
112
  id={id}
@@ -119,7 +125,7 @@ export const MaterialBooleanControl = ({
119
125
  errors={errors}
120
126
  config={config}
121
127
  inputProps={{
122
- 'aria-describedby': ariaDescribedBy
128
+ 'aria-describedby': ariaDescribedBy,
123
129
  }}
124
130
  />
125
131
  }
@@ -32,10 +32,15 @@ import {
32
32
  ControlProps,
33
33
  optionIs,
34
34
  and,
35
- isDescriptionHidden
35
+ isDescriptionHidden,
36
36
  } from '@jsonforms/core';
37
37
  import { withJsonFormsControlProps } from '@jsonforms/react';
38
- import { FormControlLabel, FormHelperText, Tooltip, Hidden } from '@mui/material';
38
+ import {
39
+ FormControlLabel,
40
+ FormHelperText,
41
+ Tooltip,
42
+ Hidden,
43
+ } from '@mui/material';
39
44
  import { MuiToggle } from '../mui-controls/MuiToggle';
40
45
 
41
46
  export const MaterialBooleanToggleControl = ({
@@ -51,9 +56,8 @@ export const MaterialBooleanToggleControl = ({
51
56
  errors,
52
57
  path,
53
58
  config,
54
- description
59
+ description,
55
60
  }: ControlProps) => {
56
-
57
61
  const isValid = errors.length === 0;
58
62
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
59
63
 
@@ -67,16 +71,18 @@ export const MaterialBooleanToggleControl = ({
67
71
  appliedUiSchemaOptions.showUnfocusedDescription
68
72
  );
69
73
 
70
- const showTooltip = !showDescription && !isDescriptionHidden(
71
- visible,
72
- description,
73
- // Tooltips have their own focus handlers, so we do not need to rely
74
- // on focus state here. So we pass 'true' to treat it as focused.
75
- true,
76
- // We also pass true here for showUnfocusedDescription since it should
77
- // render regardless of that setting.
78
- true
79
- );
74
+ const showTooltip =
75
+ !showDescription &&
76
+ !isDescriptionHidden(
77
+ visible,
78
+ description,
79
+ // Tooltips have their own focus handlers, so we do not need to rely
80
+ // on focus state here. So we pass 'true' to treat it as focused.
81
+ true,
82
+ // We also pass true here for showUnfocusedDescription since it should
83
+ // render regardless of that setting.
84
+ true
85
+ );
80
86
 
81
87
  const firstFormHelperText = showDescription
82
88
  ? description
@@ -102,7 +108,7 @@ export const MaterialBooleanToggleControl = ({
102
108
 
103
109
  return (
104
110
  <Hidden xsUp={!visible}>
105
- <Tooltip id={tooltipId} title={(showTooltip) ? description : ''}>
111
+ <Tooltip id={tooltipId} title={showTooltip ? description : ''}>
106
112
  <FormControlLabel
107
113
  label={label}
108
114
  id={id}
@@ -121,7 +127,7 @@ export const MaterialBooleanToggleControl = ({
121
127
  errors={errors}
122
128
  config={config}
123
129
  inputProps={{
124
- 'aria-describedby': ariaDescribedBy
130
+ 'aria-describedby': ariaDescribedBy,
125
131
  }}
126
132
  />
127
133
  }
@@ -33,10 +33,7 @@ import {
33
33
  } from '@jsonforms/core';
34
34
  import { withJsonFormsControlProps } from '@jsonforms/react';
35
35
  import { FormHelperText, Hidden } from '@mui/material';
36
- import {
37
- DatePicker,
38
- LocalizationProvider
39
- } from '@mui/x-date-pickers';
36
+ import { DatePicker, LocalizationProvider } from '@mui/x-date-pickers';
40
37
  import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
41
38
  import {
42
39
  createOnChangeHandler,
@@ -45,7 +42,7 @@ import {
45
42
  useFocus,
46
43
  } from '../util';
47
44
 
48
- export const MaterialDateControl = (props: ControlProps)=> {
45
+ export const MaterialDateControl = (props: ControlProps) => {
49
46
  const [focused, onFocus, onBlur] = useFocus();
50
47
  const {
51
48
  description,
@@ -59,7 +56,7 @@ export const MaterialDateControl = (props: ControlProps)=> {
59
56
  path,
60
57
  handleChange,
61
58
  data,
62
- config
59
+ config,
63
60
  } = props;
64
61
  const isValid = errors.length === 0;
65
62
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
@@ -81,11 +78,10 @@ export const MaterialDateControl = (props: ControlProps)=> {
81
78
  ? errors
82
79
  : null;
83
80
  const secondFormHelperText = showDescription && !isValid ? errors : null;
84
- const onChange = useMemo(() => createOnChangeHandler(
85
- path,
86
- handleChange,
87
- saveFormat
88
- ),[path, handleChange, saveFormat]);
81
+ const onChange = useMemo(
82
+ () => createOnChangeHandler(path, handleChange, saveFormat),
83
+ [path, handleChange, saveFormat]
84
+ );
89
85
 
90
86
  const value = getData(data, saveFormat);
91
87
  const valueInInputFormat = value ? value.format(format) : '';
@@ -103,18 +99,21 @@ export const MaterialDateControl = (props: ControlProps)=> {
103
99
  disabled={!enabled}
104
100
  componentsProps={{
105
101
  actionBar: {
106
- actions: (variant) => (variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'])
107
- }
102
+ actions: (variant) =>
103
+ variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
104
+ },
108
105
  }}
109
- renderInput={params => (
110
- <ResettableTextField
106
+ renderInput={(params) => (
107
+ <ResettableTextField
111
108
  {...params}
112
109
  rawValue={data}
113
110
  dayjsValueIsValid={value !== null}
114
111
  valueInInputFormat={valueInInputFormat}
115
112
  focused={focused}
116
113
  id={id + '-input'}
117
- required={required && !appliedUiSchemaOptions.hideRequiredAsterisk}
114
+ required={
115
+ required && !appliedUiSchemaOptions.hideRequiredAsterisk
116
+ }
118
117
  autoFocus={appliedUiSchemaOptions.focus}
119
118
  error={!isValid}
120
119
  fullWidth={!appliedUiSchemaOptions.trim}
@@ -132,9 +131,7 @@ export const MaterialDateControl = (props: ControlProps)=> {
132
131
  <FormHelperText error={!isValid && !showDescription}>
133
132
  {firstFormHelperText}
134
133
  </FormHelperText>
135
- <FormHelperText error={!isValid}>
136
- {secondFormHelperText}
137
- </FormHelperText>
134
+ <FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
138
135
  </LocalizationProvider>
139
136
  </Hidden>
140
137
  );
@@ -29,20 +29,17 @@ import {
29
29
  isDateTimeControl,
30
30
  isDescriptionHidden,
31
31
  RankedTester,
32
- rankWith
32
+ rankWith,
33
33
  } from '@jsonforms/core';
34
34
  import { withJsonFormsControlProps } from '@jsonforms/react';
35
35
  import { FormHelperText, Hidden } from '@mui/material';
36
- import {
37
- DateTimePicker,
38
- LocalizationProvider
39
- } from '@mui/x-date-pickers';
36
+ import { DateTimePicker, LocalizationProvider } from '@mui/x-date-pickers';
40
37
  import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
41
38
  import {
42
39
  createOnChangeHandler,
43
40
  getData,
44
41
  ResettableTextField,
45
- useFocus
42
+ useFocus,
46
43
  } from '../util';
47
44
 
48
45
  export const MaterialDateTimeControl = (props: ControlProps) => {
@@ -59,7 +56,7 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
59
56
  path,
60
57
  handleChange,
61
58
  data,
62
- config
59
+ config,
63
60
  } = props;
64
61
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
65
62
  const isValid = errors.length === 0;
@@ -74,7 +71,12 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
74
71
  const format = appliedUiSchemaOptions.dateTimeFormat ?? 'YYYY-MM-DD HH:mm';
75
72
  const saveFormat = appliedUiSchemaOptions.dateTimeSaveFormat ?? undefined;
76
73
 
77
- const views = appliedUiSchemaOptions.views ?? ['year', 'day', 'hours', 'minutes'];
74
+ const views = appliedUiSchemaOptions.views ?? [
75
+ 'year',
76
+ 'day',
77
+ 'hours',
78
+ 'minutes',
79
+ ];
78
80
 
79
81
  const firstFormHelperText = showDescription
80
82
  ? description
@@ -83,11 +85,10 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
83
85
  : null;
84
86
  const secondFormHelperText = showDescription && !isValid ? errors : null;
85
87
 
86
- const onChange = useMemo(() => createOnChangeHandler(
87
- path,
88
- handleChange,
89
- saveFormat
90
- ),[path, handleChange, saveFormat]);
88
+ const onChange = useMemo(
89
+ () => createOnChangeHandler(path, handleChange, saveFormat),
90
+ [path, handleChange, saveFormat]
91
+ );
91
92
 
92
93
  const value = getData(data, saveFormat);
93
94
  const valueInInputFormat = value ? value.format(format) : '';
@@ -106,18 +107,21 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
106
107
  disabled={!enabled}
107
108
  componentsProps={{
108
109
  actionBar: {
109
- actions: (variant) => (variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'])
110
- }
110
+ actions: (variant) =>
111
+ variant === 'desktop' ? [] : ['clear', 'cancel', 'accept'],
112
+ },
111
113
  }}
112
- renderInput={params => (
113
- <ResettableTextField
114
+ renderInput={(params) => (
115
+ <ResettableTextField
114
116
  {...params}
115
117
  rawValue={data}
116
118
  dayjsValueIsValid={value !== null}
117
119
  valueInInputFormat={valueInInputFormat}
118
120
  focused={focused}
119
121
  id={id + '-input'}
120
- required={required && !appliedUiSchemaOptions.hideRequiredAsterisk}
122
+ required={
123
+ required && !appliedUiSchemaOptions.hideRequiredAsterisk
124
+ }
121
125
  autoFocus={appliedUiSchemaOptions.focus}
122
126
  error={!isValid}
123
127
  fullWidth={!appliedUiSchemaOptions.trim}
@@ -130,15 +134,12 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
130
134
  onBlur={onBlur}
131
135
  variant={'standard'}
132
136
  />
133
- )
134
- }
137
+ )}
135
138
  />
136
139
  <FormHelperText error={!isValid && !showDescription}>
137
140
  {firstFormHelperText}
138
141
  </FormHelperText>
139
- <FormHelperText error={!isValid}>
140
- {secondFormHelperText}
141
- </FormHelperText>
142
+ <FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
142
143
  </LocalizationProvider>
143
144
  </Hidden>
144
145
  );
@@ -30,26 +30,29 @@ import {
30
30
  RankedTester,
31
31
  rankWith,
32
32
  } from '@jsonforms/core';
33
- import { TranslateProps, withJsonFormsEnumProps, withTranslateProps } from '@jsonforms/react';
33
+ import {
34
+ TranslateProps,
35
+ withJsonFormsEnumProps,
36
+ withTranslateProps,
37
+ } from '@jsonforms/react';
34
38
  import { MuiSelect } from '../mui-controls/MuiSelect';
35
39
  import merge from 'lodash/merge';
36
40
  import { MaterialInputControl } from './MaterialInputControl';
37
- import { MuiAutocomplete, WithOptionLabel } from '../mui-controls/MuiAutocomplete';
41
+ import {
42
+ MuiAutocomplete,
43
+ WithOptionLabel,
44
+ } from '../mui-controls/MuiAutocomplete';
38
45
 
39
- export const MaterialEnumControl = (props: ControlProps & OwnPropsOfEnum & WithOptionLabel & TranslateProps) => {
40
- const {config, uischema, errors} = props;
46
+ export const MaterialEnumControl = (
47
+ props: ControlProps & OwnPropsOfEnum & WithOptionLabel & TranslateProps
48
+ ) => {
49
+ const { config, uischema, errors } = props;
41
50
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
42
51
  const isValid = errors.length === 0;
43
- return (
44
- appliedUiSchemaOptions.autocomplete === false ?
45
- <MaterialInputControl
46
- {...props}
47
- input={MuiSelect}
48
- />:
49
- <MuiAutocomplete
50
- {...props}
51
- isValid={isValid}
52
- />
52
+ return appliedUiSchemaOptions.autocomplete === false ? (
53
+ <MaterialInputControl {...props} input={MuiSelect} />
54
+ ) : (
55
+ <MuiAutocomplete {...props} isValid={isValid} />
53
56
  );
54
57
  };
55
58
 
@@ -59,4 +62,7 @@ export const materialEnumControlTester: RankedTester = rankWith(
59
62
  );
60
63
 
61
64
  // HOC order can be reversed with https://github.com/eclipsesource/jsonforms/issues/1987
62
- export default withJsonFormsEnumProps(withTranslateProps(React.memo(MaterialEnumControl)), false);
65
+ export default withJsonFormsEnumProps(
66
+ withTranslateProps(React.memo(MaterialEnumControl)),
67
+ false
68
+ );
@@ -29,8 +29,7 @@ import {
29
29
  isDescriptionHidden,
30
30
  } from '@jsonforms/core';
31
31
 
32
- import { Hidden, InputLabel } from '@mui/material';
33
- import { FormControl, FormHelperText } from '@mui/material';
32
+ import { Hidden, InputLabel, FormControl, FormHelperText } from '@mui/material';
34
33
  import merge from 'lodash/merge';
35
34
  import { useFocus } from '../util';
36
35
 
@@ -49,7 +48,7 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
49
48
  visible,
50
49
  required,
51
50
  config,
52
- input
51
+ input,
53
52
  } = props;
54
53
  const isValid = errors.length === 0;
55
54
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
@@ -81,8 +80,10 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
81
80
  <InputLabel
82
81
  htmlFor={id + '-input'}
83
82
  error={!isValid}
84
- required={showAsRequired(required,
85
- appliedUiSchemaOptions.hideRequiredAsterisk)}
83
+ required={showAsRequired(
84
+ required,
85
+ appliedUiSchemaOptions.hideRequiredAsterisk
86
+ )}
86
87
  >
87
88
  {label}
88
89
  </InputLabel>
@@ -95,9 +96,7 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
95
96
  <FormHelperText error={!isValid && !showDescription}>
96
97
  {firstFormHelperText}
97
98
  </FormHelperText>
98
- <FormHelperText error={!isValid}>
99
- {secondFormHelperText}
100
- </FormHelperText>
99
+ <FormHelperText error={!isValid}>{secondFormHelperText}</FormHelperText>
101
100
  </FormControl>
102
101
  </Hidden>
103
102
  );
@@ -27,7 +27,7 @@ import {
27
27
  ControlProps,
28
28
  isIntegerControl,
29
29
  RankedTester,
30
- rankWith
30
+ rankWith,
31
31
  } from '@jsonforms/core';
32
32
  import { MuiInputInteger } from '../mui-controls/MuiInputInteger';
33
33
  import { MaterialInputControl } from './MaterialInputControl';
@@ -31,7 +31,7 @@ import {
31
31
  isTimeControl,
32
32
  or,
33
33
  RankedTester,
34
- rankWith
34
+ rankWith,
35
35
  } from '@jsonforms/core';
36
36
  import { Hidden, TextField } from '@mui/material';
37
37
  import { withJsonFormsControlProps } from '@jsonforms/react';
@@ -52,15 +52,16 @@ export const MaterialNativeControl = (props: ControlProps) => {
52
52
  path,
53
53
  handleChange,
54
54
  data,
55
- config
55
+ config,
56
56
  } = props;
57
57
  const isValid = errors.length === 0;
58
- const appliedUiSchemaOptions = merge(
59
- {},
60
- config,
61
- props.uischema.options
58
+ const appliedUiSchemaOptions = merge({}, config, props.uischema.options);
59
+ const [inputValue, onChange] = useDebouncedChange(
60
+ handleChange,
61
+ '',
62
+ data,
63
+ path
62
64
  );
63
- const [inputValue, onChange] = useDebouncedChange(handleChange, '', data, path);
64
65
  const fieldType = appliedUiSchemaOptions.format ?? schema.format;
65
66
  const showDescription = !isDescriptionHidden(
66
67
  visible,
@@ -72,8 +73,10 @@ export const MaterialNativeControl = (props: ControlProps) => {
72
73
  return (
73
74
  <Hidden xsUp={!visible}>
74
75
  <TextField
75
- required={showAsRequired(required,
76
- appliedUiSchemaOptions.hideRequiredAsterisk)}
76
+ required={showAsRequired(
77
+ required,
78
+ appliedUiSchemaOptions.hideRequiredAsterisk
79
+ )}
77
80
  id={id + '-input'}
78
81
  label={label}
79
82
  type={fieldType}
@@ -27,7 +27,7 @@ import {
27
27
  ControlProps,
28
28
  isNumberControl,
29
29
  RankedTester,
30
- rankWith
30
+ rankWith,
31
31
  } from '@jsonforms/core';
32
32
  import { MuiInputNumber } from '../mui-controls/MuiInputNumber';
33
33
  import { MaterialInputControl } from './MaterialInputControl';
@@ -30,27 +30,30 @@ import {
30
30
  RankedTester,
31
31
  rankWith,
32
32
  } from '@jsonforms/core';
33
- import { TranslateProps, withJsonFormsOneOfEnumProps, withTranslateProps } from '@jsonforms/react';
34
- import { MuiAutocomplete, WithOptionLabel } from '../mui-controls/MuiAutocomplete';
33
+ import {
34
+ TranslateProps,
35
+ withJsonFormsOneOfEnumProps,
36
+ withTranslateProps,
37
+ } from '@jsonforms/react';
38
+ import {
39
+ MuiAutocomplete,
40
+ WithOptionLabel,
41
+ } from '../mui-controls/MuiAutocomplete';
35
42
  import { MuiSelect } from '../mui-controls/MuiSelect';
36
43
  import { MaterialInputControl } from '../controls/MaterialInputControl';
37
44
  import merge from 'lodash/merge';
38
45
 
39
- export const MaterialOneOfEnumControl = (props: ControlProps & OwnPropsOfEnum & WithOptionLabel & TranslateProps) => {
40
- const {config, uischema, errors} = props;
46
+ export const MaterialOneOfEnumControl = (
47
+ props: ControlProps & OwnPropsOfEnum & WithOptionLabel & TranslateProps
48
+ ) => {
49
+ const { config, uischema, errors } = props;
41
50
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
42
51
  const isValid = errors.length === 0;
43
52
 
44
- return (
45
- appliedUiSchemaOptions.autocomplete === false ?
46
- <MaterialInputControl
47
- {...props}
48
- input={MuiSelect}
49
- />:
50
- <MuiAutocomplete
51
- {...props}
52
- isValid={isValid}
53
- />
53
+ return appliedUiSchemaOptions.autocomplete === false ? (
54
+ <MaterialInputControl {...props} input={MuiSelect} />
55
+ ) : (
56
+ <MuiAutocomplete {...props} isValid={isValid} />
54
57
  );
55
58
  };
56
59
 
@@ -60,4 +63,7 @@ export const materialOneOfEnumControlTester: RankedTester = rankWith(
60
63
  );
61
64
 
62
65
  // HOC order can be reversed with https://github.com/eclipsesource/jsonforms/issues/1987
63
- export default withJsonFormsOneOfEnumProps(withTranslateProps(React.memo(MaterialOneOfEnumControl)), false);
66
+ export default withJsonFormsOneOfEnumProps(
67
+ withTranslateProps(React.memo(MaterialOneOfEnumControl)),
68
+ false
69
+ );