@jsonforms/material-renderers 3.1.0 → 3.2.0-alpha.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.
Files changed (84) hide show
  1. package/lib/additional/ListWithDetailMasterItem.d.ts +1 -1
  2. package/lib/additional/MaterialLabelRenderer.d.ts +1 -1
  3. package/lib/additional/MaterialListWithDetailRenderer.d.ts +1 -1
  4. package/lib/additional/unwrapped.d.ts +2 -2
  5. package/lib/cells/MaterialBooleanCell.d.ts +1 -1
  6. package/lib/cells/MaterialBooleanToggleCell.d.ts +1 -1
  7. package/lib/cells/MaterialDateCell.d.ts +2 -1
  8. package/lib/cells/MaterialEnumCell.d.ts +1 -1
  9. package/lib/cells/MaterialIntegerCell.d.ts +1 -1
  10. package/lib/cells/MaterialNumberCell.d.ts +1 -1
  11. package/lib/cells/MaterialNumberFormatCell.d.ts +1 -1
  12. package/lib/cells/MaterialOneOfEnumCell.d.ts +1 -1
  13. package/lib/cells/MaterialTextCell.d.ts +1 -1
  14. package/lib/cells/MaterialTimeCell.d.ts +1 -1
  15. package/lib/complex/CombinatorProperties.d.ts +1 -1
  16. package/lib/complex/MaterialAllOfRenderer.d.ts +1 -1
  17. package/lib/complex/MaterialAnyOfRenderer.d.ts +2 -2
  18. package/lib/complex/MaterialArrayControlRenderer.d.ts +1 -1
  19. package/lib/complex/MaterialEnumArrayRenderer.d.ts +1 -1
  20. package/lib/complex/MaterialObjectRenderer.d.ts +1 -1
  21. package/lib/complex/MaterialOneOfRenderer.d.ts +1 -1
  22. package/lib/complex/MaterialTableControl.d.ts +2 -2
  23. package/lib/complex/NoBorderTableCell.d.ts +2 -2
  24. package/lib/complex/TabSwitchConfirmDialog.d.ts +9 -0
  25. package/lib/complex/unwrapped.d.ts +6 -6
  26. package/lib/controls/MaterialAnyOfStringOrEnumControl.d.ts +1 -1
  27. package/lib/controls/MaterialBooleanControl.d.ts +1 -1
  28. package/lib/controls/MaterialBooleanToggleControl.d.ts +1 -1
  29. package/lib/controls/MaterialDateControl.d.ts +1 -1
  30. package/lib/controls/MaterialDateTimeControl.d.ts +1 -1
  31. package/lib/controls/MaterialEnumControl.d.ts +1 -1
  32. package/lib/controls/MaterialInputControl.d.ts +2 -2
  33. package/lib/controls/MaterialIntegerControl.d.ts +1 -1
  34. package/lib/controls/MaterialNativeControl.d.ts +1 -1
  35. package/lib/controls/MaterialNumberControl.d.ts +1 -1
  36. package/lib/controls/MaterialOneOfEnumControl.d.ts +1 -1
  37. package/lib/controls/MaterialOneOfRadioGroupControl.d.ts +1 -1
  38. package/lib/controls/MaterialRadioGroup.d.ts +2 -2
  39. package/lib/controls/MaterialRadioGroupControl.d.ts +1 -1
  40. package/lib/controls/MaterialSliderControl.d.ts +1 -1
  41. package/lib/controls/MaterialTextControl.d.ts +1 -1
  42. package/lib/controls/MaterialTimeControl.d.ts +1 -1
  43. package/lib/controls/unwrapped.d.ts +14 -14
  44. package/lib/index.d.ts +28 -28
  45. package/lib/jsonforms-react-material.cjs.js +102 -43
  46. package/lib/jsonforms-react-material.cjs.js.map +1 -1
  47. package/lib/jsonforms-react-material.esm.js +90 -42
  48. package/lib/jsonforms-react-material.esm.js.map +1 -1
  49. package/lib/layouts/ExpandPanelRenderer.d.ts +1 -1
  50. package/lib/layouts/MaterialArrayLayout.d.ts +1 -1
  51. package/lib/layouts/MaterialArrayLayoutRenderer.d.ts +1 -1
  52. package/lib/layouts/MaterialCategorizationLayout.d.ts +3 -3
  53. package/lib/layouts/MaterialCategorizationStepperLayout.d.ts +3 -3
  54. package/lib/layouts/MaterialGroupLayout.d.ts +1 -1
  55. package/lib/layouts/MaterialHorizontalLayout.d.ts +1 -1
  56. package/lib/layouts/MaterialVerticalLayout.d.ts +1 -1
  57. package/lib/layouts/unwrapped.d.ts +6 -6
  58. package/lib/mui-controls/MuiAutocomplete.d.ts +1 -1
  59. package/lib/mui-controls/MuiInputInteger.d.ts +2 -1
  60. package/lib/mui-controls/MuiInputNumber.d.ts +2 -1
  61. package/lib/mui-controls/MuiInputNumberFormat.d.ts +2 -1
  62. package/lib/mui-controls/MuiInputText.d.ts +2 -1
  63. package/lib/mui-controls/MuiInputTime.d.ts +2 -1
  64. package/lib/mui-controls/MuiSelect.d.ts +2 -1
  65. package/lib/util/layout.d.ts +3 -3
  66. package/lib/util/theme.d.ts +8 -1
  67. package/package.json +26 -17
  68. package/src/cells/MaterialDateCell.tsx +21 -6
  69. package/src/complex/MaterialAnyOfRenderer.tsx +49 -6
  70. package/src/complex/MaterialOneOfRenderer.tsx +21 -45
  71. package/src/complex/TabSwitchConfirmDialog.tsx +56 -0
  72. package/src/controls/MaterialAnyOfStringOrEnumControl.tsx +9 -4
  73. package/src/controls/MaterialDateControl.tsx +0 -1
  74. package/src/controls/MaterialDateTimeControl.tsx +0 -1
  75. package/src/controls/MaterialInputControl.tsx +3 -2
  76. package/src/controls/MaterialTimeControl.tsx +0 -1
  77. package/src/mui-controls/MuiAutocomplete.tsx +0 -1
  78. package/src/mui-controls/MuiInputInteger.tsx +16 -6
  79. package/src/mui-controls/MuiInputNumber.tsx +20 -10
  80. package/src/mui-controls/MuiInputNumberFormat.tsx +6 -4
  81. package/src/mui-controls/MuiInputText.tsx +11 -4
  82. package/src/mui-controls/MuiInputTime.tsx +20 -10
  83. package/src/mui-controls/MuiSelect.tsx +4 -3
  84. package/src/util/theme.ts +40 -5
@@ -35,10 +35,10 @@ import {
35
35
  WithClassname,
36
36
  } from '@jsonforms/core';
37
37
  import { Control, withJsonFormsControlProps } from '@jsonforms/react';
38
- import { Input, InputBaseComponentProps } from '@mui/material';
38
+ import { InputBaseComponentProps } from '@mui/material';
39
39
  import merge from 'lodash/merge';
40
40
  import React, { useMemo } from 'react';
41
- import { useDebouncedChange } from '../util';
41
+ import { useDebouncedChange, useInputComponent, WithInputProps } from '../util';
42
42
  import { MaterialInputControl } from './MaterialInputControl';
43
43
 
44
44
  const findEnumSchema = (schemas: JsonSchema[]) =>
@@ -48,7 +48,9 @@ const findEnumSchema = (schemas: JsonSchema[]) =>
48
48
  const findTextSchema = (schemas: JsonSchema[]) =>
49
49
  schemas.find((s) => s.type === 'string' && s.enum === undefined);
50
50
 
51
- const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
51
+ const MuiAutocompleteInputText = (
52
+ props: EnumCellProps & WithClassname & WithInputProps
53
+ ) => {
52
54
  const {
53
55
  data,
54
56
  config,
@@ -60,7 +62,9 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
60
62
  path,
61
63
  handleChange,
62
64
  schema,
65
+ label,
63
66
  } = props;
67
+ const InputComponent = useInputComponent();
64
68
  const enumSchema = findEnumSchema(schema.anyOf);
65
69
  const stringSchema = findTextSchema(schema.anyOf);
66
70
  const maxLength = stringSchema.maxLength;
@@ -94,12 +98,13 @@ const MuiAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
94
98
  </datalist>
95
99
  );
96
100
  return (
97
- <Input
101
+ <InputComponent
98
102
  type='text'
99
103
  value={inputText}
100
104
  onChange={onChange}
101
105
  className={className}
102
106
  id={id}
107
+ label={label}
103
108
  disabled={!enabled}
104
109
  autoFocus={appliedUiSchemaOptions.focus}
105
110
  fullWidth={!appliedUiSchemaOptions.trim || maxLength === undefined}
@@ -110,7 +110,6 @@ export const MaterialDateControl = (props: ControlProps) => {
110
110
  InputLabelProps: data ? { shrink: true } : undefined,
111
111
  onFocus: onFocus,
112
112
  onBlur: onBlur,
113
- variant: 'standard',
114
113
  },
115
114
  }}
116
115
  />
@@ -118,7 +118,6 @@ export const MaterialDateTimeControl = (props: ControlProps) => {
118
118
  InputLabelProps: data ? { shrink: true } : undefined,
119
119
  onFocus: onFocus,
120
120
  onBlur: onBlur,
121
- variant: 'standard',
122
121
  },
123
122
  }}
124
123
  />
@@ -31,7 +31,7 @@ import {
31
31
 
32
32
  import { Hidden, InputLabel, FormControl, FormHelperText } from '@mui/material';
33
33
  import merge from 'lodash/merge';
34
- import { useFocus } from '../util';
34
+ import { useFocus, useInputVariant } from '../util';
35
35
 
36
36
  export interface WithInput {
37
37
  input: any;
@@ -50,6 +50,7 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
50
50
  config,
51
51
  input,
52
52
  } = props;
53
+ const variant = useInputVariant();
53
54
  const isValid = errors.length === 0;
54
55
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
55
56
 
@@ -74,8 +75,8 @@ export const MaterialInputControl = (props: ControlProps & WithInput) => {
74
75
  fullWidth={!appliedUiSchemaOptions.trim}
75
76
  onFocus={onFocus}
76
77
  onBlur={onBlur}
78
+ variant={variant}
77
79
  id={id}
78
- variant={'standard'}
79
80
  >
80
81
  <InputLabel
81
82
  htmlFor={id + '-input'}
@@ -112,7 +112,6 @@ export const MaterialTimeControl = (props: ControlProps) => {
112
112
  InputLabelProps: data ? { shrink: true } : undefined,
113
113
  onFocus: onFocus,
114
114
  onBlur: onBlur,
115
- variant: 'standard',
116
115
  },
117
116
  }}
118
117
  />
@@ -123,7 +123,6 @@ export const MuiAutocomplete = (
123
123
  return (
124
124
  <TextField
125
125
  label={label}
126
- variant={'standard'}
127
126
  type='text'
128
127
  inputProps={params.inputProps}
129
128
  inputRef={params.InputProps.ref}
@@ -24,19 +24,28 @@
24
24
  */
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
- import { Input } from '@mui/material';
28
27
  import merge from 'lodash/merge';
29
- import { useDebouncedChange } from '../util';
28
+ import { useDebouncedChange, useInputComponent, WithInputProps } from '../util';
30
29
 
31
30
  const toNumber = (value: string) =>
32
31
  value === '' ? undefined : parseInt(value, 10);
33
32
  const eventToValue = (ev: any) => toNumber(ev.target.value);
34
33
 
35
34
  export const MuiInputInteger = React.memo(function MuiInputInteger(
36
- props: CellProps & WithClassname
35
+ props: CellProps & WithClassname & WithInputProps
37
36
  ) {
38
- const { data, className, id, enabled, uischema, path, handleChange, config } =
39
- props;
37
+ const {
38
+ data,
39
+ className,
40
+ id,
41
+ enabled,
42
+ uischema,
43
+ path,
44
+ handleChange,
45
+ config,
46
+ label,
47
+ } = props;
48
+ const InputComponent = useInputComponent();
40
49
  const inputProps = { step: '1' };
41
50
 
42
51
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
@@ -50,7 +59,8 @@ export const MuiInputInteger = React.memo(function MuiInputInteger(
50
59
  );
51
60
 
52
61
  return (
53
- <Input
62
+ <InputComponent
63
+ label={label}
54
64
  type='number'
55
65
  value={inputValue}
56
66
  onChange={onChange}
@@ -1,19 +1,19 @@
1
1
  /*
2
2
  The MIT License
3
-
3
+
4
4
  Copyright (c) 2017-2019 EclipseSource Munich
5
5
  https://github.com/eclipsesource/jsonforms
6
-
6
+
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  of this software and associated documentation files (the "Software"), to deal
9
9
  in the Software without restriction, including without limitation the rights
10
10
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
11
  copies of the Software, and to permit persons to whom the Software is
12
12
  furnished to do so, subject to the following conditions:
13
-
13
+
14
14
  The above copyright notice and this permission notice shall be included in
15
15
  all copies or substantial portions of the Software.
16
-
16
+
17
17
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
18
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
19
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,18 +24,27 @@
24
24
  */
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
- import { Input } from '@mui/material';
28
27
  import merge from 'lodash/merge';
29
- import { useDebouncedChange } from '../util';
28
+ import { useDebouncedChange, useInputComponent, WithInputProps } from '../util';
30
29
 
31
30
  const toNumber = (value: string) =>
32
31
  value === '' ? undefined : parseFloat(value);
33
32
  const eventToValue = (ev: any) => toNumber(ev.target.value);
34
33
  export const MuiInputNumber = React.memo(function MuiInputNumber(
35
- props: CellProps & WithClassname
34
+ props: CellProps & WithClassname & WithInputProps
36
35
  ) {
37
- const { data, className, id, enabled, uischema, path, handleChange, config } =
38
- props;
36
+ const {
37
+ data,
38
+ className,
39
+ id,
40
+ enabled,
41
+ uischema,
42
+ path,
43
+ handleChange,
44
+ config,
45
+ label,
46
+ } = props;
47
+ const InputComponent = useInputComponent();
39
48
  const inputProps = { step: '0.1' };
40
49
 
41
50
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
@@ -48,8 +57,9 @@ export const MuiInputNumber = React.memo(function MuiInputNumber(
48
57
  );
49
58
 
50
59
  return (
51
- <Input
60
+ <InputComponent
52
61
  type='number'
62
+ label={label}
53
63
  value={inputValue}
54
64
  onChange={onChange}
55
65
  className={className}
@@ -24,12 +24,11 @@
24
24
  */
25
25
  import React, { useCallback } from 'react';
26
26
  import { CellProps, Formatted, WithClassname } from '@jsonforms/core';
27
- import { Input } from '@mui/material';
28
27
  import merge from 'lodash/merge';
29
- import { useDebouncedChange } from '../util';
28
+ import { useDebouncedChange, useInputComponent, WithInputProps } from '../util';
30
29
 
31
30
  export const MuiInputNumberFormat = React.memo(function MuiInputNumberFormat(
32
- props: CellProps & WithClassname & Formatted<number>
31
+ props: CellProps & WithClassname & Formatted<number> & WithInputProps
33
32
  ) {
34
33
  const {
35
34
  className,
@@ -41,7 +40,9 @@ export const MuiInputNumberFormat = React.memo(function MuiInputNumberFormat(
41
40
  handleChange,
42
41
  schema,
43
42
  config,
43
+ label,
44
44
  } = props;
45
+ const InputComponent = useInputComponent();
45
46
  const maxLength = schema.maxLength;
46
47
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
47
48
  let inputProps;
@@ -65,12 +66,13 @@ export const MuiInputNumberFormat = React.memo(function MuiInputNumberFormat(
65
66
  );
66
67
 
67
68
  return (
68
- <Input
69
+ <InputComponent
69
70
  type='text'
70
71
  value={inputValue}
71
72
  onChange={onChange}
72
73
  className={className}
73
74
  id={id}
75
+ label={label}
74
76
  disabled={!enabled}
75
77
  autoFocus={appliedUiSchemaOptions.focus}
76
78
  multiline={appliedUiSchemaOptions.multi}
@@ -26,7 +26,6 @@ import React, { useState } from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
27
  import {
28
28
  IconButton,
29
- Input,
30
29
  InputAdornment,
31
30
  InputBaseComponentProps,
32
31
  InputProps,
@@ -34,7 +33,12 @@ import {
34
33
  } from '@mui/material';
35
34
  import merge from 'lodash/merge';
36
35
  import Close from '@mui/icons-material/Close';
37
- import { JsonFormsTheme, useDebouncedChange } from '../util';
36
+ import {
37
+ JsonFormsTheme,
38
+ WithInputProps,
39
+ useDebouncedChange,
40
+ useInputComponent,
41
+ } from '../util';
38
42
 
39
43
  interface MuiTextInputProps {
40
44
  muiInputProps?: InputProps['inputProps'];
@@ -45,7 +49,7 @@ const eventToValue = (ev: any) =>
45
49
  ev.target.value === '' ? undefined : ev.target.value;
46
50
 
47
51
  export const MuiInputText = React.memo(function MuiInputText(
48
- props: CellProps & WithClassname & MuiTextInputProps
52
+ props: CellProps & WithClassname & MuiTextInputProps & WithInputProps
49
53
  ) {
50
54
  const [showAdornment, setShowAdornment] = useState(false);
51
55
  const {
@@ -60,8 +64,10 @@ export const MuiInputText = React.memo(function MuiInputText(
60
64
  handleChange,
61
65
  schema,
62
66
  muiInputProps,
67
+ label,
63
68
  inputComponent,
64
69
  } = props;
70
+ const InputComponent = useInputComponent();
65
71
  const maxLength = schema.maxLength;
66
72
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
67
73
  let inputProps: InputBaseComponentProps;
@@ -97,7 +103,8 @@ export const MuiInputText = React.memo(function MuiInputText(
97
103
  };
98
104
 
99
105
  return (
100
- <Input
106
+ <InputComponent
107
+ label={label}
101
108
  type={appliedUiSchemaOptions.format === 'password' ? 'password' : 'text'}
102
109
  value={inputText}
103
110
  onChange={onChange}
@@ -1,19 +1,19 @@
1
1
  /*
2
2
  The MIT License
3
-
3
+
4
4
  Copyright (c) 2017-2019 EclipseSource Munich
5
5
  https://github.com/eclipsesource/jsonforms
6
-
6
+
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  of this software and associated documentation files (the "Software"), to deal
9
9
  in the Software without restriction, including without limitation the rights
10
10
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
11
  copies of the Software, and to permit persons to whom the Software is
12
12
  furnished to do so, subject to the following conditions:
13
-
13
+
14
14
  The above copyright notice and this permission notice shall be included in
15
15
  all copies or substantial portions of the Software.
16
-
16
+
17
17
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
18
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
19
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,15 +24,24 @@
24
24
  */
25
25
  import React from 'react';
26
26
  import { CellProps, WithClassname } from '@jsonforms/core';
27
- import { Input } from '@mui/material';
28
27
  import merge from 'lodash/merge';
29
- import { useDebouncedChange } from '../util';
28
+ import { WithInputProps, useDebouncedChange, useInputComponent } from '../util';
30
29
 
31
30
  export const MuiInputTime = React.memo(function MuiInputTime(
32
- props: CellProps & WithClassname
31
+ props: CellProps & WithClassname & WithInputProps
33
32
  ) {
34
- const { data, className, id, enabled, uischema, path, handleChange, config } =
35
- props;
33
+ const {
34
+ data,
35
+ className,
36
+ id,
37
+ enabled,
38
+ uischema,
39
+ path,
40
+ handleChange,
41
+ config,
42
+ label,
43
+ } = props;
44
+ const InputComponent = useInputComponent();
36
45
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
37
46
  const [inputValue, onChange] = useDebouncedChange(
38
47
  handleChange,
@@ -42,12 +51,13 @@ export const MuiInputTime = React.memo(function MuiInputTime(
42
51
  );
43
52
 
44
53
  return (
45
- <Input
54
+ <InputComponent
46
55
  type='time'
47
56
  value={inputValue}
48
57
  onChange={onChange}
49
58
  className={className}
50
59
  id={id}
60
+ label={label}
51
61
  disabled={!enabled}
52
62
  autoFocus={appliedUiSchemaOptions.focus}
53
63
  fullWidth={true}
@@ -28,10 +28,10 @@ import { EnumCellProps, WithClassname } from '@jsonforms/core';
28
28
  import { MenuItem, Select } from '@mui/material';
29
29
  import merge from 'lodash/merge';
30
30
  import { TranslateProps } from '@jsonforms/react';
31
- import { i18nDefaults } from '../util';
31
+ import { i18nDefaults, WithInputProps } from '../util';
32
32
 
33
33
  export const MuiSelect = React.memo(function MuiSelect(
34
- props: EnumCellProps & WithClassname & TranslateProps
34
+ props: EnumCellProps & WithClassname & TranslateProps & WithInputProps
35
35
  ) {
36
36
  const {
37
37
  data,
@@ -44,6 +44,7 @@ export const MuiSelect = React.memo(function MuiSelect(
44
44
  handleChange,
45
45
  options,
46
46
  config,
47
+ label,
47
48
  t,
48
49
  } = props;
49
50
  const appliedUiSchemaOptions = merge({}, config, uischema.options);
@@ -56,12 +57,12 @@ export const MuiSelect = React.memo(function MuiSelect(
56
57
  <Select
57
58
  className={className}
58
59
  id={id}
60
+ label={label}
59
61
  disabled={!enabled}
60
62
  autoFocus={appliedUiSchemaOptions.focus}
61
63
  value={data !== undefined ? data : ''}
62
64
  onChange={(ev) => handleChange(path, ev.target.value || undefined)}
63
65
  fullWidth={true}
64
- variant={'standard'}
65
66
  >
66
67
  {[
67
68
  <MenuItem value={''} key='jsonforms.enum.none'>
package/src/util/theme.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  /*
2
2
  The MIT License
3
-
3
+
4
4
  Copyright (c) 2017-2019 EclipseSource Munich
5
5
  https://github.com/eclipsesource/jsonforms
6
-
6
+
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  of this software and associated documentation files (the "Software"), to deal
9
9
  in the Software without restriction, including without limitation the rights
10
10
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
11
  copies of the Software, and to permit persons to whom the Software is
12
12
  furnished to do so, subject to the following conditions:
13
-
13
+
14
14
  The above copyright notice and this permission notice shall be included in
15
15
  all copies or substantial portions of the Software.
16
-
16
+
17
17
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
18
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
19
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -22,7 +22,15 @@
22
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
  THE SOFTWARE.
24
24
  */
25
- import { Theme } from '@mui/material';
25
+ import {
26
+ Theme,
27
+ FilledInput,
28
+ Input,
29
+ OutlinedInput,
30
+ TextFieldProps,
31
+ useThemeProps,
32
+ InputBaseProps,
33
+ } from '@mui/material';
26
34
 
27
35
  export interface JsonFormsTheme extends Theme {
28
36
  jsonforms?: {
@@ -33,3 +41,30 @@ export interface JsonFormsTheme extends Theme {
33
41
  };
34
42
  };
35
43
  }
44
+
45
+ export interface WithInputProps {
46
+ label?: string;
47
+ }
48
+
49
+ const variantToInput = {
50
+ standard: Input,
51
+ filled: FilledInput,
52
+ outlined: OutlinedInput,
53
+ };
54
+
55
+ export const defaultInputVariant: TextFieldProps['variant'] = 'standard';
56
+
57
+ export function useInputVariant(): TextFieldProps['variant'] {
58
+ const { variant = defaultInputVariant } = useThemeProps({
59
+ props: {} as TextFieldProps,
60
+ name: 'MuiTextField',
61
+ });
62
+ return variant;
63
+ }
64
+
65
+ export function useInputComponent(): React.JSXElementConstructor<
66
+ InputBaseProps & WithInputProps
67
+ > {
68
+ const variant = useInputVariant();
69
+ return variantToInput[variant] ?? variantToInput[defaultInputVariant];
70
+ }