@rjsf/core 6.6.1 → 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/core.umd.js +454 -373
- package/dist/index.cjs +416 -334
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +418 -415
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts +14 -11
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +97 -62
- package/lib/components/RichDescription.d.ts +2 -2
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.d.ts +2 -2
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/SchemaExamples.d.ts +1 -1
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/SchemaExamples.js +1 -3
- package/lib/components/fields/ArrayField.d.ts +1 -1
- 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 +1 -1
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -5
- package/lib/components/fields/FallbackField.d.ts +1 -1
- 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 +7 -9
- 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 +1 -1
- 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 +1 -1
- 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 +9 -3
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +27 -9
- 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 +1 -1
- 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 +1 -1
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +27 -25
- package/lib/components/fields/OptionalDataControlsField.d.ts +1 -1
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +1 -1
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +7 -7
- package/lib/components/fields/StringField.d.ts +1 -1
- 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/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/DescriptionField.d.ts +1 -1
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +1 -1
- 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 +1 -1
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -1
- 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 +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -1
- 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 +2 -2
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +1 -1
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -1
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -1
- 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/widgets/AltDateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -1
- 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 +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/components/widgets/ColorWidget.d.ts +1 -1
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
- 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 +1 -1
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -1
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -1
- 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 +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -1
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +2 -2
- package/lib/components/widgets/RangeWidget.d.ts +1 -1
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +1 -1
- 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 +1 -1
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +4 -4
- package/lib/components/widgets/TextWidget.d.ts +1 -1
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +2 -2
- package/lib/components/widgets/TimeWidget.d.ts +1 -1
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -1
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -1
- 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 +5 -6
- package/src/components/Form.tsx +164 -97
- 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/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 +29 -16
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +8 -10
- package/src/components/fields/ObjectField.tsx +48 -39
- package/src/components/fields/OptionalDataControlsField.tsx +6 -4
- package/src/components/fields/SchemaField.tsx +22 -19
- package/src/components/fields/StringField.tsx +4 -15
- package/src/components/fields/index.ts +1 -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 +15 -19
- 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/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 +3 -2
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/templates/index.ts +1 -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 +6 -8
- 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 +6 -8
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +48 -47
- package/src/components/widgets/SelectWidget.tsx +12 -10
- package/src/components/widgets/TextWidget.tsx +2 -1
- package/src/components/widgets/TextareaWidget.tsx +7 -4
- 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,14 +1,12 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent
|
|
1
|
+
import type { ChangeEvent, 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
|
descriptionId,
|
|
5
7
|
getTemplate,
|
|
6
8
|
labelValue,
|
|
7
9
|
schemaRequiresTrueValue,
|
|
8
|
-
FormContextType,
|
|
9
|
-
RJSFSchema,
|
|
10
|
-
StrictRJSFSchema,
|
|
11
|
-
WidgetProps,
|
|
12
10
|
getUiOptions,
|
|
13
11
|
} from '@rjsf/utils';
|
|
14
12
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import type { FormContextType, WidgetProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
4
|
import {
|
|
3
5
|
ariaDescribedByIds,
|
|
4
6
|
enumOptionValueDecoder,
|
|
@@ -8,10 +10,6 @@ import {
|
|
|
8
10
|
enumOptionsSelectValue,
|
|
9
11
|
getOptionValueFormat,
|
|
10
12
|
optionId,
|
|
11
|
-
FormContextType,
|
|
12
|
-
WidgetProps,
|
|
13
|
-
RJSFSchema,
|
|
14
|
-
StrictRJSFSchema,
|
|
15
13
|
} from '@rjsf/utils';
|
|
16
14
|
|
|
17
15
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
@@ -52,7 +50,7 @@ function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
52
50
|
{Array.isArray(enumOptions) &&
|
|
53
51
|
enumOptions.map((option, index) => {
|
|
54
52
|
const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
|
|
55
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
53
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
56
54
|
const disabledCls = disabled || itemDisabled || readonly ? 'disabled' : '';
|
|
57
55
|
|
|
58
56
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
@@ -82,11 +80,11 @@ function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
82
80
|
</span>
|
|
83
81
|
);
|
|
84
82
|
return inline ? (
|
|
85
|
-
<label key={
|
|
83
|
+
<label key={String(option.value)} className={`checkbox-inline ${disabledCls}`}>
|
|
86
84
|
{checkbox}
|
|
87
85
|
</label>
|
|
88
86
|
) : (
|
|
89
|
-
<div key={
|
|
87
|
+
<div key={String(option.value)} className={`checkbox ${disabledCls}`}>
|
|
90
88
|
<label>{checkbox}</label>
|
|
91
89
|
</div>
|
|
92
90
|
);
|
|
@@ -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 `ColorWidget` component uses the `BaseInputTemplate` changing the type to `color` and disables it when it is
|
|
4
5
|
* either disabled or readonly.
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
localToUTC,
|
|
4
|
-
utcToLocal,
|
|
5
|
-
FormContextType,
|
|
6
|
-
RJSFSchema,
|
|
7
|
-
StrictRJSFSchema,
|
|
8
|
-
WidgetProps,
|
|
9
|
-
} from '@rjsf/utils';
|
|
1
|
+
import type { FormContextType, RJSFSchema, StrictRJSFSchema, WidgetProps } from '@rjsf/utils';
|
|
2
|
+
import { getTemplate, localToUTC, utcToLocal } from '@rjsf/utils';
|
|
10
3
|
|
|
11
4
|
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
12
5
|
* the value to/from utc using the appropriate utility functions.
|
|
@@ -25,7 +18,7 @@ export default function DateTimeWidget<
|
|
|
25
18
|
type='datetime-local'
|
|
26
19
|
{...props}
|
|
27
20
|
value={utcToLocal(value)}
|
|
28
|
-
onChange={(
|
|
21
|
+
onChange={(newValue) => onChange(localToUTC(newValue))}
|
|
29
22
|
/>
|
|
30
23
|
);
|
|
31
24
|
}
|
|
@@ -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 `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` 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 `EmailWidget` component uses the `BaseInputTemplate` changing the type to `email`.
|
|
4
5
|
*
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import type {
|
|
3
3
|
FileInfoType,
|
|
4
4
|
FormContextType,
|
|
5
|
-
getTemplate,
|
|
6
5
|
Registry,
|
|
7
6
|
RJSFSchema,
|
|
8
7
|
StrictRJSFSchema,
|
|
9
|
-
TranslatableString,
|
|
10
8
|
UIOptionsType,
|
|
11
|
-
useFileWidgetProps,
|
|
12
9
|
WidgetProps,
|
|
13
10
|
} from '@rjsf/utils';
|
|
14
|
-
import {
|
|
11
|
+
import { getTemplate, TranslatableString, useFileWidgetProps } from '@rjsf/utils';
|
|
12
|
+
import { Markdown } from 'markdown-to-jsx/react';
|
|
15
13
|
|
|
16
14
|
function FileInfoPreview<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
|
|
17
15
|
fileInfo,
|
|
@@ -25,12 +23,13 @@ function FileInfoPreview<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
25
23
|
if (!dataURL) {
|
|
26
24
|
return null;
|
|
27
25
|
}
|
|
26
|
+
const previewLabel = translateString(TranslatableString.PreviewLabel);
|
|
28
27
|
|
|
29
28
|
// If type is JPEG or PNG then show image preview.
|
|
30
29
|
// Originally, any type of image was supported, but this was changed into a whitelist
|
|
31
30
|
// since SVGs and animated GIFs are also images, which are generally considered a security risk.
|
|
32
31
|
if (['image/jpeg', 'image/png'].includes(type)) {
|
|
33
|
-
return <img src={dataURL} style={{ maxWidth: '100%' }} className='file-preview' />;
|
|
32
|
+
return <img src={dataURL} alt={previewLabel} style={{ maxWidth: '100%' }} className='file-preview' />;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
// otherwise, let users download file
|
|
@@ -39,7 +38,7 @@ function FileInfoPreview<T = any, S extends StrictRJSFSchema = RJSFSchema, F ext
|
|
|
39
38
|
<>
|
|
40
39
|
{' '}
|
|
41
40
|
<a download={`preview-${name}`} href={dataURL} className='file-download'>
|
|
42
|
-
{
|
|
41
|
+
{previewLabel}
|
|
43
42
|
</a>
|
|
44
43
|
</>
|
|
45
44
|
);
|
|
@@ -71,6 +70,7 @@ function FilesInfo<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends F
|
|
|
71
70
|
const { name, size, type } = fileInfo;
|
|
72
71
|
const handleRemove = () => onRemove(key);
|
|
73
72
|
return (
|
|
73
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
74
74
|
<li key={key}>
|
|
75
75
|
<Markdown>{translateString(TranslatableString.FilesInfo, [name, type, String(size)])}</Markdown>
|
|
76
76
|
{preview && <FileInfoPreview<T, S, F> fileInfo={fileInfo} registry={registry} />}
|
|
@@ -96,6 +96,7 @@ function FileWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
|
|
|
96
96
|
const handleOnChangeEvent = (event: ChangeEvent<HTMLInputElement>) => {
|
|
97
97
|
if (event.target.files) {
|
|
98
98
|
// handleChange is async; DOM event handlers are void-returning, so we intentionally don't await
|
|
99
|
+
// oxlint-disable-next-line no-floating-promises, no-void
|
|
99
100
|
void handleChange(event.target.files);
|
|
100
101
|
}
|
|
101
102
|
};
|
|
@@ -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 `HiddenWidget` is a widget for rendering a hidden input field.
|
|
4
4
|
* It is typically used by setting type to "hidden".
|
|
@@ -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 `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
|
|
4
5
|
*
|
|
@@ -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.
|
|
@@ -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,12 @@
|
|
|
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
|
-
FormContextType,
|
|
9
|
-
RJSFSchema,
|
|
10
|
-
StrictRJSFSchema,
|
|
11
|
-
WidgetProps,
|
|
12
10
|
} from '@rjsf/utils';
|
|
13
11
|
|
|
14
12
|
function getValue(event: SyntheticEvent<HTMLSelectElement>, multiple: boolean) {
|
|
@@ -74,11 +72,11 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
|
|
74
72
|
const showPlaceholderOption = !multiple && schema.default === undefined;
|
|
75
73
|
|
|
76
74
|
return (
|
|
75
|
+
// oxlint-disable-next-line jsx-a11y/no-autofocus
|
|
77
76
|
<select
|
|
78
77
|
id={id}
|
|
79
78
|
name={htmlName || id}
|
|
80
79
|
multiple={multiple}
|
|
81
|
-
role='combobox'
|
|
82
80
|
className='form-control'
|
|
83
81
|
value={selectValue}
|
|
84
82
|
required={required}
|
|
@@ -91,11 +89,15 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
|
|
|
91
89
|
>
|
|
92
90
|
{showPlaceholderOption && <option value=''>{placeholder}</option>}
|
|
93
91
|
{Array.isArray(enumOptions) &&
|
|
94
|
-
enumOptions.map(({ value, label }, i) => {
|
|
95
|
-
const
|
|
92
|
+
enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
|
|
93
|
+
const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
|
|
96
94
|
return (
|
|
97
|
-
<option
|
|
98
|
-
{
|
|
95
|
+
<option
|
|
96
|
+
key={String(enumValue)}
|
|
97
|
+
value={enumOptionValueEncoder(enumValue, i, optionValueFormat)}
|
|
98
|
+
disabled={isDisabled}
|
|
99
|
+
>
|
|
100
|
+
{enumLabel}
|
|
99
101
|
</option>
|
|
100
102
|
);
|
|
101
103
|
})}
|
|
@@ -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
|
*
|
|
@@ -20,7 +22,8 @@ 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
|
|
|
@@ -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
|
|