@rjsf/mui 6.6.0 → 6.6.2
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/dist/index.cjs +90 -71
- package/dist/index.cjs.map +3 -3
- package/dist/mui.esm.js +103 -145
- package/dist/mui.esm.js.map +3 -3
- package/dist/mui.umd.js +85 -67
- package/lib/AddButton/AddButton.d.ts +1 -1
- package/lib/AddButton/AddButton.js +1 -1
- package/lib/AddButton/AddButton.js.map +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +4 -4
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +4 -4
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +3 -3
- package/lib/BaseInputTemplate/BaseInputTemplate.js +7 -7
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.d.ts +3 -3
- package/lib/CheckboxWidget/CheckboxWidget.js +5 -5
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +4 -4
- package/lib/CheckboxesWidget/CheckboxesWidget.js +6 -6
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.d.ts +2 -2
- package/lib/DescriptionField/DescriptionField.js +1 -1
- package/lib/DescriptionField/DescriptionField.js.map +1 -1
- package/lib/ErrorList/ErrorList.d.ts +8 -8
- package/lib/ErrorList/ErrorList.js +2 -4
- package/lib/ErrorList/ErrorList.js.map +1 -1
- package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +4 -4
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +2 -4
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.d.ts +2 -2
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.d.ts +3 -3
- package/lib/FieldTemplate/FieldTemplate.js +2 -2
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.d.ts +1 -1
- package/lib/IconButton/IconButton.d.ts +14 -7
- package/lib/IconButton/IconButton.js +15 -7
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/MuiForm/MuiForm.d.ts +3 -3
- package/lib/MuiForm/MuiForm.js.map +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +3 -3
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -1
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +2 -2
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +3 -3
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -1
- package/lib/RadioWidget/RadioWidget.d.ts +4 -4
- package/lib/RadioWidget/RadioWidget.js +6 -6
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.d.ts +2 -2
- package/lib/RangeWidget/RangeWidget.js +6 -6
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +3 -3
- package/lib/SelectWidget/SelectWidget.js +7 -7
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.d.ts +3 -3
- package/lib/SubmitButton/SubmitButton.js +1 -1
- package/lib/SubmitButton/SubmitButton.js.map +1 -1
- package/lib/Templates/Templates.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
- package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
- package/lib/Theme/Theme.d.ts +2 -2
- package/lib/TitleField/TitleField.d.ts +5 -5
- package/lib/TitleField/TitleField.js +1 -1
- package/lib/TitleField/TitleField.js.map +1 -1
- package/lib/Widgets/Widgets.d.ts +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +2 -2
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/util.d.ts +2 -2
- package/lib/util.js +3 -3
- package/package.json +8 -8
- package/src/AddButton/AddButton.tsx +4 -9
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +9 -7
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +8 -7
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +17 -18
- package/src/CheckboxWidget/CheckboxWidget.tsx +12 -20
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +16 -17
- package/src/DescriptionField/DescriptionField.tsx +4 -3
- package/src/ErrorList/ErrorList.tsx +26 -27
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +17 -22
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +4 -10
- package/src/FieldTemplate/FieldTemplate.tsx +8 -13
- package/src/GridTemplate/GridTemplate.tsx +1 -1
- package/src/IconButton/IconButton.tsx +20 -19
- package/src/MuiForm/MuiForm.tsx +4 -3
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +6 -4
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +6 -10
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +3 -2
- package/src/RadioWidget/RadioWidget.tsx +17 -18
- package/src/RangeWidget/RangeWidget.tsx +12 -19
- package/src/SelectWidget/SelectWidget.tsx +21 -20
- package/src/SubmitButton/SubmitButton.tsx +6 -11
- package/src/Templates/Templates.ts +1 -1
- package/src/TextareaWidget/TextareaWidget.tsx +2 -1
- package/src/Theme/Theme.tsx +2 -2
- package/src/TitleField/TitleField.tsx +11 -13
- package/src/Widgets/Widgets.ts +1 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +6 -8
- package/src/util.ts +5 -5
package/lib/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BoxProps, FormHelperTextProps, GridProps, PaperProps, SxProps, TypographyProps } from '@mui/material';
|
|
2
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, UIOptionsType, GenericObjectType } from '@rjsf/utils';
|
|
1
|
+
import type { BoxProps, FormHelperTextProps, GridProps, PaperProps, SxProps, TypographyProps } from '@mui/material';
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, UIOptionsType, GenericObjectType } from '@rjsf/utils';
|
|
3
3
|
/**
|
|
4
4
|
* Extract props meant for MUI components from the `options` field of the `uiSchema`.
|
|
5
5
|
* @param {UIOptionsType} options - The options from the uiSchema
|
package/lib/util.js
CHANGED
|
@@ -14,9 +14,9 @@ export function getMuiProps(options, propsToFilter, rjsfSlotPropsOnly) {
|
|
|
14
14
|
if (propsToFilter) {
|
|
15
15
|
return Object.keys(muiProps)
|
|
16
16
|
.filter((key) => propsToFilter.includes(key))
|
|
17
|
-
.reduce((
|
|
18
|
-
|
|
19
|
-
return
|
|
17
|
+
.reduce((acc, key) => {
|
|
18
|
+
acc[key] = muiProps[key];
|
|
19
|
+
return acc;
|
|
20
20
|
}, {});
|
|
21
21
|
}
|
|
22
22
|
return muiProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/mui",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.2",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"module": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"lint": "oxlint src test",
|
|
50
50
|
"precommit": "lint-staged",
|
|
51
51
|
"test": "vitest run",
|
|
52
|
-
"test:update": "vitest run --update
|
|
52
|
+
"test:update": "vitest run --update"
|
|
53
53
|
},
|
|
54
54
|
"lint-staged": {
|
|
55
55
|
"{src,test}/**/*.{ts,tsx}": [
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"@emotion/styled": "^11.6.0",
|
|
66
66
|
"@mui/icons-material": "^7.0.0 || ^9.0.0",
|
|
67
67
|
"@mui/material": "^7.0.0 || ^9.0.0",
|
|
68
|
-
"@rjsf/core": "^6.
|
|
69
|
-
"@rjsf/utils": "^6.
|
|
68
|
+
"@rjsf/core": "^6.6.x",
|
|
69
|
+
"@rjsf/utils": "^6.6.x",
|
|
70
70
|
"react": ">=18"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"@emotion/styled": "^11.14.1",
|
|
76
76
|
"@mui/icons-material": "^9.0.1",
|
|
77
77
|
"@mui/material": "^9.0.1",
|
|
78
|
-
"@rjsf/core": "6.6.
|
|
79
|
-
"@rjsf/snapshot-tests": "6.6.
|
|
80
|
-
"@rjsf/utils": "6.6.
|
|
81
|
-
"@rjsf/validator-ajv8": "6.6.
|
|
78
|
+
"@rjsf/core": "6.6.2",
|
|
79
|
+
"@rjsf/snapshot-tests": "6.6.2",
|
|
80
|
+
"@rjsf/utils": "6.6.2",
|
|
81
|
+
"@rjsf/validator-ajv8": "6.6.2"
|
|
82
82
|
},
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import AddIcon from '@mui/icons-material/Add';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
IconButtonProps,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
TranslatableString,
|
|
10
|
-
} from '@rjsf/utils';
|
|
2
|
+
import type { IconButtonProps as MuiIconButtonProps } from '@mui/material/IconButton';
|
|
3
|
+
import IconButton from '@mui/material/IconButton';
|
|
4
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
5
|
+
import { getUiOptions, TranslatableString } from '@rjsf/utils';
|
|
11
6
|
|
|
12
7
|
import { getMuiProps } from '../util';
|
|
13
8
|
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { BoxProps } from '@mui/material/Box';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import type { GridProps } from '@mui/material/Grid';
|
|
5
|
+
import Grid from '@mui/material/Grid';
|
|
6
|
+
import type { PaperProps } from '@mui/material/Paper';
|
|
7
|
+
import Paper from '@mui/material/Paper';
|
|
8
|
+
import type {
|
|
6
9
|
ArrayFieldItemTemplateProps,
|
|
7
10
|
FormContextType,
|
|
8
|
-
getUiOptions,
|
|
9
|
-
getTemplate,
|
|
10
11
|
RJSFSchema,
|
|
11
12
|
StrictRJSFSchema,
|
|
12
13
|
GenericObjectType,
|
|
13
14
|
} from '@rjsf/utils';
|
|
15
|
+
import { getUiOptions, getTemplate } from '@rjsf/utils';
|
|
14
16
|
|
|
15
17
|
import { computeSxProps, getMuiProps } from '../util';
|
|
16
18
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { BoxProps } from '@mui/material/Box';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import type { GridProps } from '@mui/material/Grid';
|
|
4
|
+
import Grid from '@mui/material/Grid';
|
|
5
|
+
import type { PaperProps } from '@mui/material/Paper';
|
|
6
|
+
import Paper from '@mui/material/Paper';
|
|
7
|
+
import type {
|
|
7
8
|
ArrayFieldTemplateProps,
|
|
8
9
|
FormContextType,
|
|
9
10
|
RJSFSchema,
|
|
10
11
|
StrictRJSFSchema,
|
|
11
|
-
buttonId,
|
|
12
12
|
GenericObjectType,
|
|
13
13
|
} from '@rjsf/utils';
|
|
14
|
+
import { getTemplate, getUiOptions, buttonId } from '@rjsf/utils';
|
|
14
15
|
|
|
15
16
|
import { computeSxProps, getMuiProps } from '../util';
|
|
16
17
|
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent, MouseEvent
|
|
2
|
-
import {
|
|
1
|
+
import type { ChangeEvent, FocusEvent, MouseEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import type { InputProps as MuiInputProps } from '@mui/material/Input';
|
|
3
4
|
import InputAdornment from '@mui/material/InputAdornment';
|
|
4
|
-
import { InputLabelProps as MuiInputLabelProps } from '@mui/material/InputLabel';
|
|
5
|
-
import
|
|
5
|
+
import type { InputLabelProps as MuiInputLabelProps } from '@mui/material/InputLabel';
|
|
6
|
+
import type { TextFieldProps } from '@mui/material/TextField';
|
|
7
|
+
import TextField from '@mui/material/TextField';
|
|
6
8
|
import { SchemaExamples } from '@rjsf/core';
|
|
7
|
-
import {
|
|
8
|
-
ariaDescribedByIds,
|
|
9
|
+
import type {
|
|
9
10
|
BaseInputTemplateProps,
|
|
10
|
-
examplesId,
|
|
11
|
-
getInputProps,
|
|
12
|
-
labelValue,
|
|
13
11
|
FormContextType,
|
|
14
12
|
GenericObjectType,
|
|
15
13
|
RJSFSchema,
|
|
16
14
|
StrictRJSFSchema,
|
|
17
15
|
} from '@rjsf/utils';
|
|
16
|
+
import { ariaDescribedByIds, examplesId, getInputProps, labelValue } from '@rjsf/utils';
|
|
18
17
|
|
|
19
18
|
import { getMuiProps } from '../util';
|
|
20
19
|
|
|
@@ -91,14 +90,14 @@ export default function BaseInputTemplate<
|
|
|
91
90
|
accept,
|
|
92
91
|
...(schema.examples ? { list: examplesId(id) } : undefined),
|
|
93
92
|
};
|
|
94
|
-
const
|
|
95
|
-
onChange(
|
|
96
|
-
const
|
|
97
|
-
const
|
|
93
|
+
const handleChange = ({ target: { value: newValue } }: ChangeEvent<HTMLInputElement>) =>
|
|
94
|
+
onChange(newValue === '' ? options.emptyValue : newValue);
|
|
95
|
+
const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
|
|
96
|
+
const handleFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
98
97
|
const DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type)
|
|
99
98
|
? { ...slotProps?.inputLabel, ...muiSlotProps?.inputLabel, ...InputLabelProps, shrink: true }
|
|
100
99
|
: { ...slotProps?.inputLabel, ...muiSlotProps?.inputLabel, ...InputLabelProps };
|
|
101
|
-
const
|
|
100
|
+
const handleClear = useCallback(
|
|
102
101
|
(e: MouseEvent) => {
|
|
103
102
|
e.preventDefault();
|
|
104
103
|
e.stopPropagation();
|
|
@@ -110,7 +109,7 @@ export default function BaseInputTemplate<
|
|
|
110
109
|
if (options.allowClearTextInputs && value && !readonly && !disabled) {
|
|
111
110
|
const clearAdornment = (
|
|
112
111
|
<InputAdornment position='end'>
|
|
113
|
-
<ClearButton registry={registry} onClick={
|
|
112
|
+
<ClearButton registry={registry} onClick={handleClear} />
|
|
114
113
|
</InputAdornment>
|
|
115
114
|
);
|
|
116
115
|
inputProps.endAdornment = !inputProps.endAdornment ? (
|
|
@@ -143,9 +142,9 @@ export default function BaseInputTemplate<
|
|
|
143
142
|
{...rest}
|
|
144
143
|
value={value || value === 0 ? value : ''}
|
|
145
144
|
error={rawErrors.length > 0}
|
|
146
|
-
onChange={onChangeOverride ||
|
|
147
|
-
onBlur={
|
|
148
|
-
onFocus={
|
|
145
|
+
onChange={onChangeOverride || handleChange}
|
|
146
|
+
onBlur={handleBlur}
|
|
147
|
+
onFocus={handleFocus}
|
|
149
148
|
{...({ ...otherMuiProps, ...textFieldProps } as TextFieldProps)}
|
|
150
149
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
151
150
|
/>
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
labelValue,
|
|
8
|
-
schemaRequiresTrueValue,
|
|
9
|
-
FormContextType,
|
|
10
|
-
GenericObjectType,
|
|
11
|
-
RJSFSchema,
|
|
12
|
-
StrictRJSFSchema,
|
|
13
|
-
WidgetProps,
|
|
14
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { CheckboxProps } from '@mui/material/Checkbox';
|
|
2
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
3
|
+
import type { FormControlLabelProps } from '@mui/material/FormControlLabel';
|
|
4
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
5
|
+
import type { FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
6
|
+
import { ariaDescribedByIds, descriptionId, getTemplate, labelValue, schemaRequiresTrueValue } from '@rjsf/utils';
|
|
15
7
|
|
|
16
8
|
import { getMuiProps } from '../util';
|
|
17
9
|
|
|
@@ -63,9 +55,9 @@ export default function CheckboxWidget<
|
|
|
63
55
|
// "const" or "enum" keywords
|
|
64
56
|
const required = schemaRequiresTrueValue<S>(schema);
|
|
65
57
|
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
58
|
+
const handleChange = (_: any, checked: boolean) => onChange(checked);
|
|
59
|
+
const handleBlur: React.FocusEventHandler<HTMLButtonElement> = () => onBlur(id, value);
|
|
60
|
+
const handleFocus: React.FocusEventHandler<HTMLButtonElement> = () => onFocus(id, value);
|
|
69
61
|
const description = options.description ?? schema.description;
|
|
70
62
|
|
|
71
63
|
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps<T, S, F, CheckboxWidgetMuiProps>(options);
|
|
@@ -92,9 +84,9 @@ export default function CheckboxWidget<
|
|
|
92
84
|
required={required}
|
|
93
85
|
disabled={disabled || readonly}
|
|
94
86
|
autoFocus={autofocus}
|
|
95
|
-
onChange={
|
|
96
|
-
onBlur={
|
|
97
|
-
onFocus={
|
|
87
|
+
onChange={handleChange}
|
|
88
|
+
onBlur={handleBlur}
|
|
89
|
+
onFocus={handleFocus}
|
|
98
90
|
aria-describedby={ariaDescribedByIds(id)}
|
|
99
91
|
{...muiSlotProps?.checkbox}
|
|
100
92
|
/>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import type { CheckboxProps } from '@mui/material/Checkbox';
|
|
3
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
4
|
+
import type { FormControlLabelProps } from '@mui/material/FormControlLabel';
|
|
5
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
6
|
+
import type { FormGroupProps } from '@mui/material/FormGroup';
|
|
7
|
+
import FormGroup from '@mui/material/FormGroup';
|
|
5
8
|
import FormLabel from '@mui/material/FormLabel';
|
|
9
|
+
import type { FormContextType, GenericObjectType, WidgetProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
6
10
|
import {
|
|
7
11
|
ariaDescribedByIds,
|
|
8
12
|
enumOptionValueDecoder,
|
|
@@ -12,11 +16,6 @@ import {
|
|
|
12
16
|
getOptionValueFormat,
|
|
13
17
|
labelValue,
|
|
14
18
|
optionId,
|
|
15
|
-
FormContextType,
|
|
16
|
-
GenericObjectType,
|
|
17
|
-
WidgetProps,
|
|
18
|
-
RJSFSchema,
|
|
19
|
-
StrictRJSFSchema,
|
|
20
19
|
} from '@rjsf/utils';
|
|
21
20
|
|
|
22
21
|
import { getMuiProps } from '../util';
|
|
@@ -63,7 +62,7 @@ export default function CheckboxesWidget<
|
|
|
63
62
|
const optionValueFormat = getOptionValueFormat(options);
|
|
64
63
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
65
64
|
|
|
66
|
-
const
|
|
65
|
+
const handleChange =
|
|
67
66
|
(index: number) =>
|
|
68
67
|
({ target: { checked } }: ChangeEvent<HTMLInputElement>) => {
|
|
69
68
|
if (checked) {
|
|
@@ -73,9 +72,9 @@ export default function CheckboxesWidget<
|
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
74
|
|
|
76
|
-
const
|
|
75
|
+
const handleBlur = ({ target }: FocusEvent<HTMLButtonElement>) =>
|
|
77
76
|
onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
78
|
-
const
|
|
77
|
+
const handleFocus = ({ target }: FocusEvent<HTMLButtonElement>) =>
|
|
79
78
|
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, emptyValue));
|
|
80
79
|
|
|
81
80
|
const { rjsfSlotProps: muiSlotProps, ...otherMuiProps } = getMuiProps<T, S, F, CheckboxesWidgetMuiProps>(options);
|
|
@@ -92,7 +91,7 @@ export default function CheckboxesWidget<
|
|
|
92
91
|
{Array.isArray(enumOptions) &&
|
|
93
92
|
enumOptions.map((option, index: number) => {
|
|
94
93
|
const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
|
|
95
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
94
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
96
95
|
const checkbox = (
|
|
97
96
|
<Checkbox
|
|
98
97
|
{...muiSlotProps?.checkbox}
|
|
@@ -101,9 +100,9 @@ export default function CheckboxesWidget<
|
|
|
101
100
|
checked={checked}
|
|
102
101
|
disabled={disabled || itemDisabled || readonly}
|
|
103
102
|
autoFocus={autofocus && index === 0}
|
|
104
|
-
onChange={
|
|
105
|
-
onBlur={
|
|
106
|
-
onFocus={
|
|
103
|
+
onChange={handleChange(index)}
|
|
104
|
+
onBlur={handleBlur}
|
|
105
|
+
onFocus={handleFocus}
|
|
107
106
|
aria-describedby={ariaDescribedByIds(id)}
|
|
108
107
|
/>
|
|
109
108
|
);
|
|
@@ -111,7 +110,7 @@ export default function CheckboxesWidget<
|
|
|
111
110
|
<FormControlLabel
|
|
112
111
|
{...muiSlotProps?.formControlLabel}
|
|
113
112
|
control={checkbox}
|
|
114
|
-
key={
|
|
113
|
+
key={String(option.value)}
|
|
115
114
|
label={option.label}
|
|
116
115
|
/>
|
|
117
116
|
);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { TypographyProps } from '@mui/material/Typography';
|
|
2
|
+
import Typography from '@mui/material/Typography';
|
|
2
3
|
import { RichDescription } from '@rjsf/core';
|
|
3
|
-
import {
|
|
4
|
+
import type {
|
|
4
5
|
DescriptionFieldProps,
|
|
5
6
|
FormContextType,
|
|
6
7
|
GenericObjectType,
|
|
7
8
|
RJSFSchema,
|
|
8
9
|
StrictRJSFSchema,
|
|
9
|
-
getUiOptions,
|
|
10
10
|
} from '@rjsf/utils';
|
|
11
|
+
import { getUiOptions } from '@rjsf/utils';
|
|
11
12
|
|
|
12
13
|
import { computeSxProps, getMuiProps } from '../util';
|
|
13
14
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import ErrorIcon from '@mui/icons-material/Error';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from '@rjsf/utils';
|
|
2
|
+
import type { BoxProps } from '@mui/material/Box';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import type { ListProps } from '@mui/material/List';
|
|
5
|
+
import List from '@mui/material/List';
|
|
6
|
+
import type { ListItemProps } from '@mui/material/ListItem';
|
|
7
|
+
import ListItem from '@mui/material/ListItem';
|
|
8
|
+
import type { ListItemIconProps } from '@mui/material/ListItemIcon';
|
|
9
|
+
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
10
|
+
import type { ListItemTextProps } from '@mui/material/ListItemText';
|
|
11
|
+
import ListItemText from '@mui/material/ListItemText';
|
|
12
|
+
import type { PaperProps } from '@mui/material/Paper';
|
|
13
|
+
import Paper from '@mui/material/Paper';
|
|
14
|
+
import type { TypographyProps } from '@mui/material/Typography';
|
|
15
|
+
import Typography from '@mui/material/Typography';
|
|
16
|
+
import type { ErrorListProps, FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
17
|
+
import { TranslatableString, getUiOptions } from '@rjsf/utils';
|
|
18
18
|
|
|
19
19
|
import { computeSxProps, getMuiProps } from '../util';
|
|
20
20
|
|
|
@@ -69,17 +69,16 @@ export default function ErrorList<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
69
69
|
<Typography variant='h6' {...errorTypography}>
|
|
70
70
|
{translateString(TranslatableString.ErrorsLabel)}
|
|
71
71
|
</Typography>
|
|
72
|
-
<List dense
|
|
73
|
-
{errors.map((error, i: number) =>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})}
|
|
72
|
+
<List dense {...errorList}>
|
|
73
|
+
{errors.map((error, i: number) => (
|
|
74
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
75
|
+
<ListItem key={i} {...errorListItem}>
|
|
76
|
+
<ListItemIcon {...errorListItemIcon}>
|
|
77
|
+
<ErrorIcon color='error' />
|
|
78
|
+
</ListItemIcon>
|
|
79
|
+
<ListItemText primary={error.stack} {...errorListItemText} />
|
|
80
|
+
</ListItem>
|
|
81
|
+
))}
|
|
83
82
|
</List>
|
|
84
83
|
</Box>
|
|
85
84
|
</Paper>
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
RJSFSchema,
|
|
10
|
-
StrictRJSFSchema,
|
|
11
|
-
getUiOptions,
|
|
12
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormHelperTextProps } from '@mui/material/FormHelperText';
|
|
2
|
+
import FormHelperText from '@mui/material/FormHelperText';
|
|
3
|
+
import type { ListProps } from '@mui/material/List';
|
|
4
|
+
import List from '@mui/material/List';
|
|
5
|
+
import type { ListItemProps } from '@mui/material/ListItem';
|
|
6
|
+
import ListItem from '@mui/material/ListItem';
|
|
7
|
+
import type { FieldErrorProps, FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
8
|
+
import { errorId, getUiOptions } from '@rjsf/utils';
|
|
13
9
|
|
|
14
10
|
import { getMuiProps } from '../util';
|
|
15
11
|
|
|
@@ -46,16 +42,15 @@ export default function FieldErrorTemplate<
|
|
|
46
42
|
const { rjsfSlotProps: muiSlotProps } = muiProps;
|
|
47
43
|
|
|
48
44
|
return (
|
|
49
|
-
<List id={id} dense
|
|
50
|
-
{errors.map((error, i: number) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})}
|
|
45
|
+
<List id={id} dense disablePadding {...muiSlotProps?.fieldErrorList}>
|
|
46
|
+
{errors.map((error, i: number) => (
|
|
47
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
48
|
+
<ListItem key={i} disableGutters {...muiSlotProps?.fieldErrorListItem}>
|
|
49
|
+
<FormHelperText component='div' id={`${id}-${i}`} {...muiSlotProps?.fieldErrorFormHelperText}>
|
|
50
|
+
{error}
|
|
51
|
+
</FormHelperText>
|
|
52
|
+
</ListItem>
|
|
53
|
+
))}
|
|
59
54
|
</List>
|
|
60
55
|
);
|
|
61
56
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FormHelperTextProps } from '@mui/material/FormHelperText';
|
|
2
|
+
import FormHelperText from '@mui/material/FormHelperText';
|
|
2
3
|
import { RichHelp } from '@rjsf/core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
FieldHelpProps,
|
|
6
|
-
FormContextType,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
getUiOptions,
|
|
10
|
-
GenericObjectType,
|
|
11
|
-
} from '@rjsf/utils';
|
|
4
|
+
import type { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, GenericObjectType } from '@rjsf/utils';
|
|
5
|
+
import { helpId, getUiOptions } from '@rjsf/utils';
|
|
12
6
|
|
|
13
7
|
import { computeSxProps, getMuiProps } from '../util';
|
|
14
8
|
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
getTemplate,
|
|
10
|
-
getUiOptions,
|
|
11
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormControlProps } from '@mui/material/FormControl';
|
|
2
|
+
import FormControl from '@mui/material/FormControl';
|
|
3
|
+
import type { TypographyProps } from '@mui/material/Typography';
|
|
4
|
+
import Typography from '@mui/material/Typography';
|
|
5
|
+
import type { FieldTemplateProps, FormContextType, GenericObjectType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
6
|
+
import { getTemplate, getUiOptions } from '@rjsf/utils';
|
|
12
7
|
|
|
13
8
|
import { getMuiProps } from '../util';
|
|
14
9
|
|
|
@@ -90,8 +85,8 @@ export default function FieldTemplate<
|
|
|
90
85
|
registry={registry}
|
|
91
86
|
>
|
|
92
87
|
<FormControl
|
|
93
|
-
fullWidth
|
|
94
|
-
error={rawErrors.length
|
|
88
|
+
fullWidth
|
|
89
|
+
error={!!rawErrors.length}
|
|
95
90
|
required={required}
|
|
96
91
|
{...muiSlotProps?.fieldFormControl}
|
|
97
92
|
sx={otherMuiProps.sx}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Grid from '@mui/material/Grid';
|
|
2
|
-
import { GridTemplateProps } from '@rjsf/utils';
|
|
2
|
+
import type { GridTemplateProps } from '@rjsf/utils';
|
|
3
3
|
|
|
4
4
|
/** Renders a `GridTemplate` for mui, which is expecting the column sizing information coming in via the
|
|
5
5
|
* extra props provided by the caller, which are spread directly on the `Grid`.
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
1
2
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
|
2
3
|
import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward';
|
|
3
4
|
import ClearIcon from '@mui/icons-material/Clear';
|
|
4
5
|
import CopyIcon from '@mui/icons-material/ContentCopy';
|
|
5
6
|
import RemoveIcon from '@mui/icons-material/Remove';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
RJSFSchema,
|
|
11
|
-
StrictRJSFSchema,
|
|
12
|
-
TranslatableString,
|
|
13
|
-
getUiOptions,
|
|
14
|
-
} from '@rjsf/utils';
|
|
7
|
+
import type { IconButtonProps as MuiIconButtonProps } from '@mui/material/IconButton';
|
|
8
|
+
import IconButton from '@mui/material/IconButton';
|
|
9
|
+
import type { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
10
|
+
import { TranslatableString, getUiOptions } from '@rjsf/utils';
|
|
15
11
|
|
|
16
12
|
import { getMuiProps } from '../util';
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
T
|
|
20
|
-
|
|
21
|
-
F extends FormContextType = any,
|
|
22
|
-
>(props: IconButtonProps<T, S, F>) {
|
|
14
|
+
function MuiIconButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
15
|
+
props: IconButtonProps<T, S, F>,
|
|
16
|
+
) {
|
|
23
17
|
const { icon, color, uiSchema, registry, ...otherProps } = props;
|
|
24
18
|
|
|
25
19
|
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
@@ -38,8 +32,10 @@ export default function MuiIconButton<
|
|
|
38
32
|
</IconButton>
|
|
39
33
|
);
|
|
40
34
|
}
|
|
35
|
+
const MuiIconButton = memo(MuiIconButtonFn) as typeof MuiIconButtonFn;
|
|
36
|
+
export default MuiIconButton;
|
|
41
37
|
|
|
42
|
-
|
|
38
|
+
function CopyButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
43
39
|
props: IconButtonProps<T, S, F>,
|
|
44
40
|
) {
|
|
45
41
|
const {
|
|
@@ -53,8 +49,9 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
53
49
|
/>
|
|
54
50
|
);
|
|
55
51
|
}
|
|
52
|
+
export const CopyButton = memo(CopyButtonFn) as typeof CopyButtonFn;
|
|
56
53
|
|
|
57
|
-
|
|
54
|
+
function MoveDownButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
58
55
|
props: IconButtonProps<T, S, F>,
|
|
59
56
|
) {
|
|
60
57
|
const {
|
|
@@ -68,8 +65,9 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
|
|
|
68
65
|
/>
|
|
69
66
|
);
|
|
70
67
|
}
|
|
68
|
+
export const MoveDownButton = memo(MoveDownButtonFn) as typeof MoveDownButtonFn;
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
function MoveUpButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
73
71
|
props: IconButtonProps<T, S, F>,
|
|
74
72
|
) {
|
|
75
73
|
const {
|
|
@@ -83,8 +81,9 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
83
81
|
/>
|
|
84
82
|
);
|
|
85
83
|
}
|
|
84
|
+
export const MoveUpButton = memo(MoveUpButtonFn) as typeof MoveUpButtonFn;
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
function RemoveButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
88
87
|
props: IconButtonProps<T, S, F>,
|
|
89
88
|
) {
|
|
90
89
|
const { iconType, ...otherProps } = props;
|
|
@@ -100,8 +99,9 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
100
99
|
/>
|
|
101
100
|
);
|
|
102
101
|
}
|
|
102
|
+
export const RemoveButton = memo(RemoveButtonFn) as typeof RemoveButtonFn;
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
function ClearButtonFn<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
105
105
|
props: IconButtonProps<T, S, F>,
|
|
106
106
|
) {
|
|
107
107
|
const { iconType, ...otherProps } = props;
|
|
@@ -116,3 +116,4 @@ export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
116
116
|
/>
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
|
+
export const ClearButton = memo(ClearButtonFn) as typeof ClearButtonFn;
|
package/src/MuiForm/MuiForm.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { FormProps } from '@rjsf/core';
|
|
3
|
+
import { withTheme } from '@rjsf/core';
|
|
4
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
4
5
|
|
|
5
6
|
import { generateTheme } from '../Theme';
|
|
6
7
|
|