@rjsf/core 6.6.1 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/dist/core.umd.js +694 -584
- package/dist/index.cjs +1191 -1071
- package/dist/index.cjs.map +4 -4
- package/dist/index.esm.js +1030 -984
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +16 -13
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +126 -76
- package/lib/components/RichDescription.d.ts +3 -3
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.d.ts +3 -3
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/SchemaExamples.d.ts +2 -2
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/SchemaExamples.js +1 -3
- package/lib/components/fields/ArrayField.d.ts +2 -2
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +87 -88
- package/lib/components/fields/BooleanField.d.ts +2 -2
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -5
- package/lib/components/fields/CyclicSchemaField.d.ts +8 -0
- package/lib/components/fields/CyclicSchemaField.d.ts.map +1 -0
- package/lib/components/fields/CyclicSchemaField.js +21 -0
- package/lib/components/fields/FallbackField.d.ts +2 -2
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/FallbackField.js +2 -2
- package/lib/components/fields/LayoutGridField.d.ts +8 -10
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +5 -4
- package/lib/components/fields/LayoutHeaderField.d.ts +2 -2
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
- package/lib/components/fields/LayoutHeaderField.js +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +2 -2
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +4 -1
- package/lib/components/fields/MultiSchemaField.d.ts +2 -41
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +116 -122
- package/lib/components/fields/NullField.d.ts +1 -1
- package/lib/components/fields/NullField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.d.ts +2 -2
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +7 -9
- package/lib/components/fields/ObjectField.d.ts +2 -2
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +28 -26
- package/lib/components/fields/OptionalDataControlsField.d.ts +2 -2
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +14 -8
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +43 -30
- package/lib/components/fields/StringField.d.ts +2 -2
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +2 -5
- package/lib/components/fields/index.d.ts +1 -1
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +2 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +2 -2
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +2 -2
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +7 -6
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +2 -2
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +14 -7
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js +14 -6
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +2 -2
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts +7 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts.map +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js +12 -0
- package/lib/components/templates/DescriptionField.d.ts +2 -2
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +2 -2
- package/lib/components/templates/ErrorList.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.js +2 -4
- package/lib/components/templates/FallbackFieldTemplate.d.ts +2 -2
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +2 -2
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.js +1 -3
- package/lib/components/templates/FieldHelpTemplate.d.ts +2 -2
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +2 -2
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts +3 -3
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +2 -2
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +2 -2
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +2 -2
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.js +1 -1
- package/lib/components/templates/TitleField.d.ts +2 -2
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +2 -2
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +2 -2
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +2 -2
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
- package/lib/components/templates/index.d.ts +1 -1
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +2 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts +2 -2
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +2 -2
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +2 -2
- package/lib/components/widgets/CheckboxWidget.d.ts +2 -2
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +2 -2
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +4 -4
- package/lib/components/widgets/ColorWidget.d.ts +2 -2
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +2 -2
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.js +2 -2
- package/lib/components/widgets/DateWidget.d.ts +2 -2
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +2 -2
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +2 -2
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.js +6 -4
- package/lib/components/widgets/HiddenWidget.d.ts +2 -2
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +2 -2
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +2 -2
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +4 -4
- package/lib/components/widgets/RangeWidget.d.ts +2 -2
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +2 -2
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.js +15 -15
- package/lib/components/widgets/SelectWidget.d.ts +2 -2
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +9 -8
- package/lib/components/widgets/TextWidget.d.ts +2 -2
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +2 -2
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +5 -5
- package/lib/components/widgets/TimeWidget.d.ts +2 -2
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +2 -2
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +2 -2
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
- package/lib/components/widgets/index.d.ts +1 -1
- package/lib/components/widgets/index.d.ts.map +1 -1
- package/lib/getDefaultRegistry.d.ts +1 -1
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +1 -1
- package/lib/getTestRegistry.d.ts +1 -1
- package/lib/getTestRegistry.d.ts.map +1 -1
- package/lib/getTestRegistry.js +1 -1
- package/lib/index.d.ts +10 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +3 -3
- package/lib/withTheme.d.ts.map +1 -1
- package/lib/withTheme.js +6 -6
- package/package.json +28 -28
- package/src/components/Form.tsx +197 -111
- package/src/components/RichDescription.tsx +3 -10
- package/src/components/RichHelp.tsx +3 -10
- package/src/components/SchemaExamples.tsx +6 -4
- package/src/components/fields/ArrayField.tsx +122 -108
- package/src/components/fields/BooleanField.tsx +4 -9
- package/src/components/fields/CyclicSchemaField.tsx +40 -0
- package/src/components/fields/FallbackField.tsx +4 -8
- package/src/components/fields/LayoutGridField.tsx +21 -19
- package/src/components/fields/LayoutHeaderField.tsx +2 -10
- package/src/components/fields/LayoutMultiSchemaField.tsx +15 -10
- package/src/components/fields/MultiSchemaField.tsx +202 -218
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +8 -10
- package/src/components/fields/ObjectField.tsx +52 -40
- package/src/components/fields/OptionalDataControlsField.tsx +6 -4
- package/src/components/fields/SchemaField.tsx +66 -51
- package/src/components/fields/StringField.tsx +4 -15
- package/src/components/fields/index.ts +3 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +2 -7
- package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -9
- package/src/components/templates/ArrayFieldTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -10
- package/src/components/templates/BaseInputTemplate.tsx +16 -23
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/IconButton.tsx +16 -7
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/CyclicSchemaExpandTemplate.tsx +31 -0
- package/src/components/templates/DescriptionField.tsx +1 -1
- package/src/components/templates/ErrorList.tsx +8 -15
- package/src/components/templates/FallbackFieldTemplate.tsx +2 -1
- package/src/components/templates/FieldErrorTemplate.tsx +8 -8
- package/src/components/templates/FieldHelpTemplate.tsx +2 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/components/templates/FieldTemplate/Label.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +1 -1
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/components/templates/ObjectFieldTemplate.tsx +2 -7
- package/src/components/templates/OptionalDataControlsTemplate.tsx +3 -2
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +4 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/templates/index.ts +3 -1
- package/src/components/widgets/AltDateTimeWidget.tsx +1 -1
- package/src/components/widgets/AltDateWidget.tsx +7 -13
- package/src/components/widgets/CheckboxWidget.tsx +3 -5
- package/src/components/widgets/CheckboxesWidget.tsx +8 -10
- package/src/components/widgets/ColorWidget.tsx +2 -1
- package/src/components/widgets/DateTimeWidget.tsx +3 -10
- package/src/components/widgets/DateWidget.tsx +2 -1
- package/src/components/widgets/EmailWidget.tsx +2 -1
- package/src/components/widgets/FileWidget.tsx +9 -8
- package/src/components/widgets/HiddenWidget.tsx +1 -1
- package/src/components/widgets/PasswordWidget.tsx +2 -1
- package/src/components/widgets/RadioWidget.tsx +8 -10
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +48 -47
- package/src/components/widgets/SelectWidget.tsx +48 -31
- package/src/components/widgets/TextWidget.tsx +2 -1
- package/src/components/widgets/TextareaWidget.tsx +10 -7
- package/src/components/widgets/TimeWidget.tsx +2 -1
- package/src/components/widgets/URLWidget.tsx +2 -1
- package/src/components/widgets/UpDownWidget.tsx +2 -1
- package/src/components/widgets/index.ts +1 -1
- package/src/getDefaultRegistry.ts +2 -9
- package/src/getTestRegistry.tsx +2 -7
- package/src/index.ts +10 -5
- package/src/withTheme.tsx +14 -9
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { FocusEvent
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
4
|
import {
|
|
3
5
|
ariaDescribedByIds,
|
|
4
6
|
enumOptionValueDecoder,
|
|
@@ -6,10 +8,6 @@ import {
|
|
|
6
8
|
enumOptionsIsSelected,
|
|
7
9
|
getOptionValueFormat,
|
|
8
10
|
optionId,
|
|
9
|
-
FormContextType,
|
|
10
|
-
RJSFSchema,
|
|
11
|
-
StrictRJSFSchema,
|
|
12
|
-
WidgetProps,
|
|
13
11
|
} from '@rjsf/utils';
|
|
14
12
|
|
|
15
13
|
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
@@ -35,13 +33,13 @@ function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
35
33
|
|
|
36
34
|
const handleBlur = useCallback(
|
|
37
35
|
({ target }: FocusEvent<HTMLInputElement>) =>
|
|
38
|
-
onBlur(id, enumOptionValueDecoder<S>(target
|
|
36
|
+
onBlur(id, enumOptionValueDecoder<S>(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
39
37
|
[onBlur, enumOptions, emptyValue, id, optionValueFormat],
|
|
40
38
|
);
|
|
41
39
|
|
|
42
40
|
const handleFocus = useCallback(
|
|
43
41
|
({ target }: FocusEvent<HTMLInputElement>) =>
|
|
44
|
-
onFocus(id, enumOptionValueDecoder<S>(target
|
|
42
|
+
onFocus(id, enumOptionValueDecoder<S>(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
45
43
|
[onFocus, enumOptions, emptyValue, id, optionValueFormat],
|
|
46
44
|
);
|
|
47
45
|
|
|
@@ -50,7 +48,7 @@ function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
50
48
|
{Array.isArray(enumOptions) &&
|
|
51
49
|
enumOptions.map((option, i) => {
|
|
52
50
|
const checked = enumOptionsIsSelected<S>(option.value, value);
|
|
53
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
51
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
54
52
|
const disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
55
53
|
|
|
56
54
|
const handleChange = () => onChange(option.value);
|
|
@@ -76,11 +74,11 @@ function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
76
74
|
);
|
|
77
75
|
|
|
78
76
|
return inline ? (
|
|
79
|
-
<label key={
|
|
77
|
+
<label key={String(option.value)} className={`radio-inline ${disabledCls}`}>
|
|
80
78
|
{radio}
|
|
81
79
|
</label>
|
|
82
80
|
) : (
|
|
83
|
-
<div key={
|
|
81
|
+
<div key={String(option.value)} className={`radio ${disabledCls}`}>
|
|
84
82
|
<label>{radio}</label>
|
|
85
83
|
</div>
|
|
86
84
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
4
4
|
* in a div, with the value along side it.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FocusEvent
|
|
2
|
-
import {
|
|
1
|
+
import type { FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
/** The `RatingWidget` component renders a star or heart rating input
|
|
5
6
|
*
|
|
@@ -80,51 +81,51 @@ export default function RatingWidget<
|
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
return (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const isFilled = starValue <= value;
|
|
84
|
+
<div
|
|
85
|
+
className='rating-widget'
|
|
86
|
+
style={{
|
|
87
|
+
display: 'inline-flex',
|
|
88
|
+
fontSize: '1.5rem',
|
|
89
|
+
cursor: disabled || readonly ? 'default' : 'pointer',
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{[...Array(numStars)].map((_, index) => {
|
|
93
|
+
const starValue = min + index;
|
|
94
|
+
const isFilled = starValue <= value;
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
96
|
+
return (
|
|
97
|
+
<span
|
|
98
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
99
|
+
key={index}
|
|
100
|
+
onClick={() => handleStarClick(starValue)}
|
|
101
|
+
onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && handleStarClick(starValue)}
|
|
102
|
+
onFocus={handleFocus}
|
|
103
|
+
onBlur={handleBlur}
|
|
104
|
+
data-value={starValue}
|
|
105
|
+
tabIndex={disabled || readonly ? -1 : 0}
|
|
106
|
+
role='radio'
|
|
107
|
+
aria-checked={starValue === value}
|
|
108
|
+
aria-label={`${starValue} ${shape === 'heart' ? 'heart' : 'star'}${starValue === 1 ? '' : 's'}`}
|
|
109
|
+
style={{
|
|
110
|
+
color: isFilled ? '#FFD700' : '#ccc',
|
|
111
|
+
padding: '0 0.2rem',
|
|
112
|
+
transition: 'color 0.2s',
|
|
113
|
+
userSelect: 'none',
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{getSymbol(isFilled)}
|
|
117
|
+
</span>
|
|
118
|
+
);
|
|
119
|
+
})}
|
|
120
|
+
<input
|
|
121
|
+
type='hidden'
|
|
122
|
+
id={id}
|
|
123
|
+
name={htmlName || id}
|
|
124
|
+
value={value || ''}
|
|
125
|
+
required={required}
|
|
126
|
+
disabled={disabled || readonly}
|
|
127
|
+
aria-hidden='true'
|
|
128
|
+
/>
|
|
129
|
+
</div>
|
|
129
130
|
);
|
|
130
131
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent, SyntheticEvent
|
|
1
|
+
import type { ChangeEvent, FocusEvent, SyntheticEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
4
|
import {
|
|
3
5
|
ariaDescribedByIds,
|
|
4
6
|
enumOptionSelectedValue,
|
|
5
7
|
enumOptionValueDecoder,
|
|
6
8
|
enumOptionValueEncoder,
|
|
7
9
|
getOptionValueFormat,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
StrictRJSFSchema,
|
|
11
|
-
WidgetProps,
|
|
10
|
+
logUnsupportedDefaultForEnum,
|
|
11
|
+
SelectedOptionDescription,
|
|
12
12
|
} from '@rjsf/utils';
|
|
13
13
|
|
|
14
14
|
function getValue(event: SyntheticEvent<HTMLSelectElement>, multiple: boolean) {
|
|
@@ -41,6 +41,8 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
|
|
41
41
|
onFocus,
|
|
42
42
|
placeholder,
|
|
43
43
|
htmlName,
|
|
44
|
+
registry,
|
|
45
|
+
uiSchema,
|
|
44
46
|
}: WidgetProps<T, S, F>) {
|
|
45
47
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
46
48
|
const emptyValue = multiple ? [] : '';
|
|
@@ -72,34 +74,49 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
|
|
72
74
|
|
|
73
75
|
const selectValue = enumOptionSelectedValue<S>(value, enumOptions, multiple, optionValueFormat, emptyValue);
|
|
74
76
|
const showPlaceholderOption = !multiple && schema.default === undefined;
|
|
77
|
+
logUnsupportedDefaultForEnum<S>(id, schema, enumOptions, multiple);
|
|
75
78
|
|
|
76
79
|
return (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
80
|
+
<>
|
|
81
|
+
<SelectedOptionDescription
|
|
82
|
+
id={id}
|
|
83
|
+
multiple={multiple}
|
|
84
|
+
options={options}
|
|
85
|
+
registry={registry}
|
|
86
|
+
uiSchema={uiSchema}
|
|
87
|
+
value={value}
|
|
88
|
+
/>
|
|
89
|
+
{/* oxlint-disable-next-line jsx-a11y/no-autofocus */}
|
|
90
|
+
<select
|
|
91
|
+
id={id}
|
|
92
|
+
name={htmlName || id}
|
|
93
|
+
multiple={multiple}
|
|
94
|
+
className='form-control'
|
|
95
|
+
value={selectValue}
|
|
96
|
+
required={required}
|
|
97
|
+
disabled={disabled || readonly}
|
|
98
|
+
autoFocus={autofocus}
|
|
99
|
+
onBlur={handleBlur}
|
|
100
|
+
onFocus={handleFocus}
|
|
101
|
+
onChange={handleChange}
|
|
102
|
+
aria-describedby={ariaDescribedByIds(id)}
|
|
103
|
+
>
|
|
104
|
+
{showPlaceholderOption && <option value=''>{placeholder}</option>}
|
|
105
|
+
{Array.isArray(enumOptions) &&
|
|
106
|
+
enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
|
|
107
|
+
const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
|
|
108
|
+
return (
|
|
109
|
+
<option
|
|
110
|
+
key={String(enumValue)}
|
|
111
|
+
value={enumOptionValueEncoder(enumValue, i, optionValueFormat)}
|
|
112
|
+
disabled={isDisabled}
|
|
113
|
+
>
|
|
114
|
+
{enumLabel}
|
|
115
|
+
</option>
|
|
116
|
+
);
|
|
117
|
+
})}
|
|
118
|
+
</select>
|
|
119
|
+
</>
|
|
103
120
|
);
|
|
104
121
|
}
|
|
105
122
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
/** The `TextWidget` component uses the `BaseInputTemplate`.
|
|
4
5
|
*
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent
|
|
2
|
-
import {
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
4
|
+
import { ariaDescribedByIds } from '@rjsf/utils';
|
|
3
5
|
|
|
4
6
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
5
7
|
*
|
|
@@ -7,7 +9,7 @@ import { ariaDescribedByIds, FormContextType, RJSFSchema, StrictRJSFSchema, Widg
|
|
|
7
9
|
*/
|
|
8
10
|
function TextareaWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
9
11
|
id,
|
|
10
|
-
options
|
|
12
|
+
options,
|
|
11
13
|
placeholder,
|
|
12
14
|
value,
|
|
13
15
|
required,
|
|
@@ -20,17 +22,18 @@ function TextareaWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
|
|
|
20
22
|
htmlName,
|
|
21
23
|
}: WidgetProps<T, S, F>) {
|
|
22
24
|
const handleChange = useCallback(
|
|
23
|
-
({ target: { value } }: ChangeEvent<HTMLTextAreaElement>) =>
|
|
25
|
+
({ target: { value: newValue } }: ChangeEvent<HTMLTextAreaElement>) =>
|
|
26
|
+
onChange(newValue === '' ? options.emptyValue : newValue),
|
|
24
27
|
[onChange, options.emptyValue],
|
|
25
28
|
);
|
|
26
29
|
|
|
27
30
|
const handleBlur = useCallback(
|
|
28
|
-
({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target
|
|
31
|
+
({ target }: FocusEvent<HTMLTextAreaElement>) => onBlur(id, target?.value),
|
|
29
32
|
[onBlur, id],
|
|
30
33
|
);
|
|
31
34
|
|
|
32
35
|
const handleFocus = useCallback(
|
|
33
|
-
({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target
|
|
36
|
+
({ target }: FocusEvent<HTMLTextAreaElement>) => onFocus(id, target?.value),
|
|
34
37
|
[id, onFocus],
|
|
35
38
|
);
|
|
36
39
|
|
|
@@ -39,7 +42,7 @@ function TextareaWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F exte
|
|
|
39
42
|
id={id}
|
|
40
43
|
name={htmlName || id}
|
|
41
44
|
className='form-control'
|
|
42
|
-
value={value
|
|
45
|
+
value={value || ''}
|
|
43
46
|
placeholder={placeholder}
|
|
44
47
|
required={required}
|
|
45
48
|
disabled={disabled}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
3
|
+
import { getTemplate } from '@rjsf/utils';
|
|
3
4
|
|
|
4
5
|
/** The `TimeWidget` component uses the `BaseInputTemplate` changing the type to `time` and transforms
|
|
5
6
|
* the value to undefined when it is falsy during the `onChange` handling.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
/** The `URLWidget` component uses the `BaseInputTemplate` changing the type to `url`.
|
|
4
5
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate } from '@rjsf/utils';
|
|
2
3
|
|
|
3
4
|
/** The `UpDownWidget` component uses the `BaseInputTemplate` changing the type to `number`.
|
|
4
5
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RegistryWidgetsType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
|
|
3
3
|
import AltDateTimeWidget from './AltDateTimeWidget';
|
|
4
4
|
import AltDateWidget from './AltDateWidget';
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
DEFAULT_ID_SEPARATOR,
|
|
4
|
-
englishStringTranslator,
|
|
5
|
-
FormContextType,
|
|
6
|
-
Registry,
|
|
7
|
-
RJSFSchema,
|
|
8
|
-
StrictRJSFSchema,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
|
+
import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator } from '@rjsf/utils';
|
|
10
3
|
|
|
11
4
|
import fields from './components/fields';
|
|
12
5
|
import templates from './components/templates';
|
package/src/getTestRegistry.tsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
DEFAULT_ID_SEPARATOR,
|
|
4
|
-
createSchemaUtils,
|
|
5
|
-
englishStringTranslator,
|
|
6
|
-
Registry,
|
|
7
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { Registry } from '@rjsf/utils';
|
|
2
|
+
import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, createSchemaUtils, englishStringTranslator } from '@rjsf/utils';
|
|
8
3
|
import validator from '@rjsf/validator-ajv8';
|
|
9
4
|
|
|
10
5
|
import getDefaultRegistry from './getDefaultRegistry';
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import type { FormProps, FormState, IChangeEvent } from './components/Form';
|
|
2
|
+
import Form from './components/Form';
|
|
3
|
+
import type { RichDescriptionProps } from './components/RichDescription';
|
|
4
|
+
import RichDescription from './components/RichDescription';
|
|
5
|
+
import type { RichHelpProps } from './components/RichHelp';
|
|
6
|
+
import RichHelp from './components/RichHelp';
|
|
7
|
+
import type { SchemaExamplesProps } from './components/SchemaExamples';
|
|
8
|
+
import SchemaExamples from './components/SchemaExamples';
|
|
5
9
|
import getDefaultRegistry from './getDefaultRegistry';
|
|
6
10
|
import getTestRegistry from './getTestRegistry';
|
|
7
|
-
import
|
|
11
|
+
import type { ThemeProps } from './withTheme';
|
|
12
|
+
import withTheme from './withTheme';
|
|
8
13
|
|
|
9
14
|
export type {
|
|
10
15
|
FormProps,
|
package/src/withTheme.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ComponentType, ForwardedRef
|
|
2
|
-
import {
|
|
1
|
+
import type { ComponentType, ForwardedRef } from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
4
|
|
|
4
|
-
import
|
|
5
|
+
import type { FormProps } from './components/Form';
|
|
6
|
+
import Form from './components/Form';
|
|
5
7
|
|
|
6
8
|
/** The properties for the `withTheme` function, essentially a subset of properties from the `FormProps` that can be
|
|
7
9
|
* overridden while creating a theme
|
|
@@ -17,15 +19,18 @@ export default function withTheme<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
17
19
|
): ComponentType<FormProps<T, S, F>> {
|
|
18
20
|
// @ts-expect-error TS2322 because the latest types complain about LegacyRef's string form not working with Form
|
|
19
21
|
return forwardRef<Form<T, S, F>, FormProps<T, S, F>>(
|
|
20
|
-
(
|
|
21
|
-
fields
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
(
|
|
23
|
+
{ fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }: FormProps<T, S, F>,
|
|
24
|
+
ref: ForwardedRef<Form<T, S, F>>,
|
|
25
|
+
) => {
|
|
26
|
+
const fields = { ...themeProps?.fields, ...propFields };
|
|
27
|
+
const widgets = { ...themeProps?.widgets, ...propWidgets };
|
|
28
|
+
const templates = {
|
|
24
29
|
...themeProps?.templates,
|
|
25
|
-
...
|
|
30
|
+
...propTemplates,
|
|
26
31
|
ButtonTemplates: {
|
|
27
32
|
...themeProps?.templates?.ButtonTemplates,
|
|
28
|
-
...
|
|
33
|
+
...propTemplates?.ButtonTemplates,
|
|
29
34
|
},
|
|
30
35
|
};
|
|
31
36
|
|