@rjsf/core 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/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 +6 -7
- 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
package/lib/components/Form.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ElementType, FormEvent, ReactNode, Ref, RefObject } from 'react';
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
import type { CustomValidator, ErrorSchema, ErrorTransformer, FieldPathId, FieldPathList, FormContextType, PathSchema, StrictRJSFSchema, Registry, RegistryFieldsType, RegistryWidgetsType, RJSFSchema, RJSFValidationError, SchemaUtilsType, TemplatesType, UiSchema, ValidationData, ValidatorType, Experimental_DefaultFormStateBehavior, Experimental_CustomMergeAllOf, NameGeneratorFunction } from '@rjsf/utils';
|
|
4
|
+
import { ErrorSchemaBuilder } from '@rjsf/utils';
|
|
3
5
|
/** Represents a boolean option that is deprecated.
|
|
4
6
|
* @deprecated - In a future major release, this type will be removed
|
|
5
7
|
*/
|
|
@@ -249,7 +251,7 @@ export interface FormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
249
251
|
/** The registry (re)computed only when props changed */
|
|
250
252
|
registry: Registry<T, S, F>;
|
|
251
253
|
/** Tracks the previous `extraErrors` prop reference so that `getDerivedStateFromProps` can detect changes */
|
|
252
|
-
|
|
254
|
+
prevExtraErrors?: ErrorSchema<T>;
|
|
253
255
|
}
|
|
254
256
|
/** The event data passed when changes have been made to the form, includes everything from the `FormState` except
|
|
255
257
|
* the schema validation errors. An additional `status` is added when returned from `onSubmit`
|
|
@@ -282,7 +284,7 @@ export default class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
282
284
|
/** Flag to track when we're processing a user-initiated field change.
|
|
283
285
|
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
284
286
|
*/
|
|
285
|
-
private
|
|
287
|
+
private isProcessingUserChange;
|
|
286
288
|
/** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
|
|
287
289
|
* state before render, ensuring the updated errors are visible immediately in a single render cycle.
|
|
288
290
|
*
|
|
@@ -347,12 +349,13 @@ export default class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
347
349
|
* @param props - The props passed to the `Form`
|
|
348
350
|
* @param inputFormData - The new or current data for the `Form`
|
|
349
351
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
350
|
-
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
351
|
-
* @param formDataChangedFields - The changed fields of `formData`
|
|
352
|
-
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
352
|
+
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
353
|
+
* @param [formDataChangedFields=[]] - The changed fields of `formData`
|
|
354
|
+
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
355
|
+
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
353
356
|
* @returns - The new state for the `Form`
|
|
354
357
|
*/
|
|
355
|
-
getStateFromProps(props: FormProps<T, S, F>, inputFormData?: T, retrievedSchema?: S, isSchemaChanged?: boolean, formDataChangedFields?: string[], skipLiveValidate?: boolean): FormState<T, S, F>;
|
|
358
|
+
getStateFromProps(props: FormProps<T, S, F>, inputFormData?: T, retrievedSchema?: S, isSchemaChanged?: boolean, formDataChangedFields?: string[], skipLiveValidate?: boolean, shouldSanitize?: boolean): FormState<T, S, F>;
|
|
356
359
|
/** React lifecycle method that is used to determine whether component should be updated.
|
|
357
360
|
*
|
|
358
361
|
* @param nextProps - The next version of the props
|
|
@@ -379,7 +382,7 @@ export default class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
379
382
|
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
380
383
|
* @private
|
|
381
384
|
*/
|
|
382
|
-
private mergeErrors;
|
|
385
|
+
private static mergeErrors;
|
|
383
386
|
/** Performs live validation and then updates and returns the errors and error schemas by potentially merging in
|
|
384
387
|
* `extraErrors` and `customErrors`.
|
|
385
388
|
*
|
|
@@ -491,9 +494,9 @@ export default class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F ex
|
|
|
491
494
|
* @returns - The `GlobalFormOptions` from the props
|
|
492
495
|
* @private
|
|
493
496
|
*/
|
|
494
|
-
private getGlobalFormOptions;
|
|
497
|
+
private static getGlobalFormOptions;
|
|
495
498
|
/** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
|
|
496
|
-
getRegistry(props: FormProps<T, S, F>, schema: S, schemaUtils: SchemaUtilsType<T, S, F>): Registry<T, S, F>;
|
|
499
|
+
static getRegistry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FormProps<T, S, F>, schema: S, schemaUtils: SchemaUtilsType<T, S, F>): Registry<T, S, F>;
|
|
497
500
|
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
498
501
|
submit: () => void;
|
|
499
502
|
/** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../src/components/Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,eAAe,EACf,UAAU,EACV,gBAAgB,E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runtime";
|
|
2
2
|
import { Component, createRef } from 'react';
|
|
3
|
-
import { createSchemaUtils, deepEquals, ErrorSchemaBuilder, getChangedFields, getTemplate, getUiOptions, isObject, mergeObjects, shouldRender, SUBMIT_BTN_OPTIONS_KEY, toErrorList, toFieldPathId, UI_DEFINITIONS_KEY, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, validationDataMerge, DEFAULT_ID_SEPARATOR, DEFAULT_ID_PREFIX, ERRORS_KEY, ID_KEY, getUsedFormData, getFieldNames, ANY_OF_KEY, ONE_OF_KEY, } from '@rjsf/utils';
|
|
3
|
+
import { createSchemaUtils, deepEquals, ErrorSchemaBuilder, getChangedFields, getTemplate, getUiOptions, hashObject, isObject, mergeObjects, shouldRender, SUBMIT_BTN_OPTIONS_KEY, toErrorList, toFieldPathId, UI_DEFINITIONS_KEY, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, validationDataMerge, DEFAULT_ID_SEPARATOR, DEFAULT_ID_PREFIX, ERRORS_KEY, ID_KEY, getUsedFormData, getFieldNames, ANY_OF_KEY, ONE_OF_KEY, } from '@rjsf/utils';
|
|
4
4
|
import _cloneDeep from 'lodash-es/cloneDeep.js';
|
|
5
5
|
import _get from 'lodash-es/get.js';
|
|
6
6
|
import _isEmpty from 'lodash-es/isEmpty.js';
|
|
@@ -34,7 +34,7 @@ export default class Form extends Component {
|
|
|
34
34
|
/** Flag to track when we're processing a user-initiated field change.
|
|
35
35
|
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
isProcessingUserChange = false;
|
|
38
38
|
/** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
|
|
39
39
|
* state before render, ensuring the updated errors are visible immediately in a single render cycle.
|
|
40
40
|
*
|
|
@@ -43,10 +43,10 @@ export default class Form extends Component {
|
|
|
43
43
|
* @returns Partial state with re-merged errors if `extraErrors` changed, or `null` if no update is needed
|
|
44
44
|
*/
|
|
45
45
|
static getDerivedStateFromProps(props, state) {
|
|
46
|
-
if (props.extraErrors !== state.
|
|
46
|
+
if (props.extraErrors !== state.prevExtraErrors) {
|
|
47
47
|
const baseErrors = {
|
|
48
48
|
errors: state.schemaValidationErrors || [],
|
|
49
|
-
errorSchema:
|
|
49
|
+
errorSchema: state.schemaValidationErrorSchema || {},
|
|
50
50
|
};
|
|
51
51
|
let { errors, errorSchema } = baseErrors;
|
|
52
52
|
if (props.extraErrors) {
|
|
@@ -55,7 +55,7 @@ export default class Form extends Component {
|
|
|
55
55
|
if (state.customErrors) {
|
|
56
56
|
({ errors, errorSchema } = validationDataMerge({ errors, errorSchema }, state.customErrors.ErrorSchema, true));
|
|
57
57
|
}
|
|
58
|
-
return {
|
|
58
|
+
return { prevExtraErrors: props.extraErrors, errors, errorSchema };
|
|
59
59
|
}
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
@@ -74,7 +74,7 @@ export default class Form extends Component {
|
|
|
74
74
|
const formData = propsFormData ?? initialFormData;
|
|
75
75
|
this.state = {
|
|
76
76
|
...this.getStateFromProps(props, formData, undefined, undefined, undefined, true),
|
|
77
|
-
|
|
77
|
+
prevExtraErrors: props.extraErrors,
|
|
78
78
|
};
|
|
79
79
|
if (onChange && !deepEquals(this.state.formData, formData)) {
|
|
80
80
|
onChange(toIChangeEvent(this.state));
|
|
@@ -141,8 +141,8 @@ export default class Form extends Component {
|
|
|
141
141
|
// Prevent oneOf/anyOf option switches from reverting when getStateFromProps
|
|
142
142
|
// re-evaluates and produces stale formData.
|
|
143
143
|
const nextStateDiffersFromProps = !deepEquals(nextState.formData, this.props.formData);
|
|
144
|
-
const wasProcessingUserChange = this.
|
|
145
|
-
this.
|
|
144
|
+
const wasProcessingUserChange = this.isProcessingUserChange;
|
|
145
|
+
this.isProcessingUserChange = false;
|
|
146
146
|
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
147
147
|
// Skip - the user's option switch is already applied via processPendingChange
|
|
148
148
|
return;
|
|
@@ -150,6 +150,7 @@ export default class Form extends Component {
|
|
|
150
150
|
if (nextStateDiffersFromProps && !deepEquals(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
151
151
|
this.props.onChange(toIChangeEvent(nextState));
|
|
152
152
|
}
|
|
153
|
+
// oxlint-disable-next-line react/no-did-update-set-state -- guarded to prevent infinite loop
|
|
153
154
|
this.setState(nextState);
|
|
154
155
|
}
|
|
155
156
|
}
|
|
@@ -160,12 +161,13 @@ export default class Form extends Component {
|
|
|
160
161
|
* @param props - The props passed to the `Form`
|
|
161
162
|
* @param inputFormData - The new or current data for the `Form`
|
|
162
163
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
163
|
-
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
164
|
-
* @param formDataChangedFields - The changed fields of `formData`
|
|
165
|
-
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
164
|
+
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
165
|
+
* @param [formDataChangedFields=[]] - The changed fields of `formData`
|
|
166
|
+
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
167
|
+
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
166
168
|
* @returns - The new state for the `Form`
|
|
167
169
|
*/
|
|
168
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
170
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false, shouldSanitize = false) {
|
|
169
171
|
const state = this.state || {};
|
|
170
172
|
const schema = 'schema' in props ? props.schema : this.props.schema;
|
|
171
173
|
const validator = 'validator' in props ? props.validator : this.props.validator;
|
|
@@ -173,6 +175,7 @@ export default class Form extends Component {
|
|
|
173
175
|
const isUncontrolled = props.formData === undefined && this.props.formData === undefined;
|
|
174
176
|
const edit = typeof inputFormData !== 'undefined';
|
|
175
177
|
const liveValidate = 'liveValidate' in props ? props.liveValidate : this.props.liveValidate;
|
|
178
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
176
179
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
177
180
|
const experimental_defaultFormStateBehavior = 'experimental_defaultFormStateBehavior' in props
|
|
178
181
|
? props.experimental_defaultFormStateBehavior
|
|
@@ -180,7 +183,7 @@ export default class Form extends Component {
|
|
|
180
183
|
const experimental_customMergeAllOf = 'experimental_customMergeAllOf' in props
|
|
181
184
|
? props.experimental_customMergeAllOf
|
|
182
185
|
: this.props.experimental_customMergeAllOf;
|
|
183
|
-
let schemaUtils = state
|
|
186
|
+
let { schemaUtils } = state;
|
|
184
187
|
if (!schemaUtils ||
|
|
185
188
|
schemaUtils.doesSchemaUtilsDiffer(validator, schema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf)) {
|
|
186
189
|
schemaUtils = createSchemaUtils(validator, schema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf);
|
|
@@ -194,14 +197,44 @@ export default class Form extends Component {
|
|
|
194
197
|
else if (inputFormData === undefined && isUncontrolled) {
|
|
195
198
|
defaultsFormData = state.formData;
|
|
196
199
|
}
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
let formData;
|
|
201
|
+
let computedRetrievedSchema;
|
|
202
|
+
let wasSanitized = false;
|
|
203
|
+
const preventInfiniteSanitize = [];
|
|
204
|
+
do {
|
|
205
|
+
formData = schemaUtils.getDefaultFormState(rootSchema, defaultsFormData, false, state.initialDefaultsGenerated);
|
|
206
|
+
// Only hash when sanitizing, wrapping `formData` in an object to deal with a scalar/undefined value
|
|
207
|
+
const formHash = shouldSanitize ? hashObject({ formData }) : '';
|
|
208
|
+
computedRetrievedSchema = this.updateRetrievedSchema(retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData));
|
|
209
|
+
if (shouldSanitize &&
|
|
210
|
+
!preventInfiniteSanitize.includes(formHash) &&
|
|
211
|
+
!deepEquals(computedRetrievedSchema, state.retrievedSchema)) {
|
|
212
|
+
// Sanitize the form data if shouldSanitize is true, we haven't already processed this same formData AND
|
|
213
|
+
// we have a different retrieved schema from when we last ran the state
|
|
214
|
+
const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(computedRetrievedSchema, state.retrievedSchema, formData);
|
|
215
|
+
wasSanitized = !deepEquals(sanitizedFormData, formData);
|
|
216
|
+
if (wasSanitized) {
|
|
217
|
+
// Update both the formData AND defaultsFormData due to the sanitize so the loop works with the new data
|
|
218
|
+
formData = sanitizedFormData;
|
|
219
|
+
defaultsFormData = sanitizedFormData;
|
|
220
|
+
const sanitizedFormHash = hashObject({ formData: sanitizedFormData });
|
|
221
|
+
// If we've seen the sanitized data before, we are done
|
|
222
|
+
wasSanitized = !preventInfiniteSanitize.includes(sanitizedFormHash);
|
|
223
|
+
preventInfiniteSanitize.push(sanitizedFormHash);
|
|
224
|
+
}
|
|
225
|
+
preventInfiniteSanitize.push(formHash);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
wasSanitized = false;
|
|
229
|
+
}
|
|
230
|
+
} while (wasSanitized);
|
|
199
231
|
const getCurrentErrors = () => {
|
|
200
232
|
// If the `props.noValidate` option is set or the schema has changed, we reset the error state.
|
|
233
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
201
234
|
if (props.noValidate || isSchemaChanged) {
|
|
202
235
|
return { errors: [], errorSchema: {} };
|
|
203
236
|
}
|
|
204
|
-
|
|
237
|
+
if (!props.liveValidate) {
|
|
205
238
|
return {
|
|
206
239
|
errors: state.schemaValidationErrors || [],
|
|
207
240
|
errorSchema: state.schemaValidationErrorSchema || {},
|
|
@@ -214,8 +247,7 @@ export default class Form extends Component {
|
|
|
214
247
|
};
|
|
215
248
|
let errors;
|
|
216
249
|
let errorSchema;
|
|
217
|
-
let schemaValidationErrors = state
|
|
218
|
-
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
250
|
+
let { schemaValidationErrors, schemaValidationErrorSchema } = state;
|
|
219
251
|
// If we are skipping live validate, it means that the state has already been updated with live validation errors
|
|
220
252
|
if (mustValidate && !skipLiveValidate) {
|
|
221
253
|
const liveValidation = this.liveValidate(rootSchema, schemaUtils, state.errorSchema, formData, undefined, state.customErrors, retrievedSchema,
|
|
@@ -237,14 +269,15 @@ export default class Form extends Component {
|
|
|
237
269
|
acc[key] = undefined;
|
|
238
270
|
return acc;
|
|
239
271
|
}, {});
|
|
240
|
-
|
|
272
|
+
schemaValidationErrorSchema = mergeObjects(currentErrors.errorSchema, newErrorSchema, 'preventDuplicates');
|
|
273
|
+
errorSchema = schemaValidationErrorSchema;
|
|
241
274
|
}
|
|
242
|
-
const mergedErrors =
|
|
275
|
+
const mergedErrors = Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
243
276
|
errors = mergedErrors.errors;
|
|
244
277
|
errorSchema = mergedErrors.errorSchema;
|
|
245
278
|
}
|
|
246
279
|
// Only store a new registry when the props cause a different one to be created
|
|
247
|
-
const newRegistry =
|
|
280
|
+
const newRegistry = Form.getRegistry(props, rootSchema, schemaUtils);
|
|
248
281
|
const registry = deepEquals(state.registry, newRegistry) ? state.registry : newRegistry;
|
|
249
282
|
// Only compute a new `fieldPathId` when the `idPrefix` is different than the existing fieldPathId's ID_KEY
|
|
250
283
|
const fieldPathId = state.fieldPathId && state.fieldPathId?.[ID_KEY] === registry.globalFormOptions.idPrefix
|
|
@@ -261,7 +294,7 @@ export default class Form extends Component {
|
|
|
261
294
|
errorSchema,
|
|
262
295
|
schemaValidationErrors,
|
|
263
296
|
schemaValidationErrorSchema,
|
|
264
|
-
retrievedSchema:
|
|
297
|
+
retrievedSchema: computedRetrievedSchema,
|
|
265
298
|
initialDefaultsGenerated: true,
|
|
266
299
|
registry,
|
|
267
300
|
};
|
|
@@ -286,12 +319,14 @@ export default class Form extends Component {
|
|
|
286
319
|
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
287
320
|
*/
|
|
288
321
|
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
289
|
-
const schemaUtils = altSchemaUtils
|
|
322
|
+
const schemaUtils = altSchemaUtils || this.state.schemaUtils;
|
|
290
323
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
291
|
-
|
|
324
|
+
// When a pre-resolved schema is provided (e.g., from live validation), use it directly.
|
|
325
|
+
// Otherwise validate against the original schema so AJV sees the full constraint set.
|
|
326
|
+
const validationSchema = retrievedSchema ?? schema;
|
|
292
327
|
return schemaUtils
|
|
293
328
|
.getValidator()
|
|
294
|
-
.validateFormData(formData,
|
|
329
|
+
.validateFormData(formData, validationSchema, customValidate, transformErrors, uiSchema);
|
|
295
330
|
}
|
|
296
331
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
297
332
|
renderErrors(registry) {
|
|
@@ -311,9 +346,8 @@ export default class Form extends Component {
|
|
|
311
346
|
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
312
347
|
* @private
|
|
313
348
|
*/
|
|
314
|
-
mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
315
|
-
let errorSchema = schemaValidation
|
|
316
|
-
let errors = schemaValidation.errors;
|
|
349
|
+
static mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
350
|
+
let { errorSchema, errors } = schemaValidation;
|
|
317
351
|
if (extraErrors) {
|
|
318
352
|
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
319
353
|
errorSchema = merged.errorSchema;
|
|
@@ -342,15 +376,15 @@ export default class Form extends Component {
|
|
|
342
376
|
*/
|
|
343
377
|
liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
|
|
344
378
|
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
|
|
345
|
-
const errors = schemaValidation
|
|
346
|
-
let errorSchema = schemaValidation
|
|
379
|
+
const { errors } = schemaValidation;
|
|
380
|
+
let { errorSchema } = schemaValidation;
|
|
347
381
|
// We merge 'originalErrorSchema' with 'schemaValidation.errorSchema.'; This done to display the raised field error.
|
|
348
382
|
if (mergeIntoOriginalErrorSchema) {
|
|
349
383
|
errorSchema = mergeObjects(originalErrorSchema, schemaValidation.errorSchema, 'preventDuplicates');
|
|
350
384
|
}
|
|
351
385
|
const schemaValidationErrors = errors;
|
|
352
386
|
const schemaValidationErrorSchema = errorSchema;
|
|
353
|
-
const mergedErrors =
|
|
387
|
+
const mergedErrors = Form.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
|
|
354
388
|
return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
|
|
355
389
|
}
|
|
356
390
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
@@ -359,18 +393,16 @@ export default class Form extends Component {
|
|
|
359
393
|
* @param fields - The fields to keep while filtering
|
|
360
394
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
361
395
|
*/
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
};
|
|
396
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
397
|
+
getUsedFormData = (formData, fields) => getUsedFormData(formData, fields);
|
|
365
398
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
366
399
|
*
|
|
367
400
|
* @param pathSchema - The `PathSchema` object for the form
|
|
368
401
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
369
402
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
370
403
|
*/
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
};
|
|
404
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
405
|
+
getFieldNames = (pathSchema, formData) => getFieldNames(pathSchema, formData);
|
|
374
406
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
375
407
|
*
|
|
376
408
|
* @param formData - The data for the `Form`
|
|
@@ -424,19 +456,19 @@ export default class Form extends Component {
|
|
|
424
456
|
}
|
|
425
457
|
// Mark that we're processing a user-initiated change.
|
|
426
458
|
// This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
427
|
-
this.
|
|
459
|
+
this.isProcessingUserChange = true;
|
|
428
460
|
const { newValue, path, id } = this.pendingChanges[0];
|
|
429
461
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
430
|
-
|
|
462
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
463
|
+
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, disabled, readonly } = this.props;
|
|
431
464
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
432
|
-
let { customErrors } = this.state;
|
|
465
|
+
let { customErrors, retrievedSchema } = this.state;
|
|
433
466
|
// Use the un-merged AJV-only schema as the base for re-merging extraErrors. Mirrors the
|
|
434
467
|
// pattern in getStateFromProps/getDerivedStateFromProps and avoids the duplication that
|
|
435
468
|
// happened when state.errorSchema (already containing merged extraErrors) was passed in.
|
|
436
469
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
437
470
|
const rootPathId = fieldPathId.path[0] || '';
|
|
438
471
|
const isRootPath = !path || path.length === 0 || (path.length === 1 && path[0] === rootPathId);
|
|
439
|
-
let retrievedSchema = this.state.retrievedSchema;
|
|
440
472
|
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
441
473
|
// When switching from null to an object option in oneOf, MultiSchemaField sends
|
|
442
474
|
// an object with property names but undefined values (e.g., {types: undefined, content: undefined}).
|
|
@@ -482,19 +514,19 @@ export default class Form extends Component {
|
|
|
482
514
|
_set(formData, path, valueForPath);
|
|
483
515
|
}
|
|
484
516
|
}
|
|
517
|
+
const shouldSanitize = retrievedSchema && !isRootPath && !isObject(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
485
518
|
// Pass true to skip live validation in `getStateFromProps()` since we will do it a bit later
|
|
486
|
-
const newState = this.getStateFromProps(this.props, inputForDefaults, undefined, undefined, undefined, true);
|
|
519
|
+
const newState = this.getStateFromProps(this.props, inputForDefaults, undefined, undefined, undefined, true, shouldSanitize);
|
|
487
520
|
formData = newState.formData;
|
|
488
521
|
retrievedSchema = newState.retrievedSchema;
|
|
489
522
|
}
|
|
490
523
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === 'onChange');
|
|
491
|
-
let state = { formData,
|
|
524
|
+
let state = { formData, retrievedSchema };
|
|
492
525
|
let newFormData = formData;
|
|
493
526
|
if (omitExtraData === true && (liveOmit === true || liveOmit === 'onChange')) {
|
|
527
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
494
528
|
newFormData = this.omitExtraData(formData);
|
|
495
|
-
state = {
|
|
496
|
-
formData: newFormData,
|
|
497
|
-
};
|
|
529
|
+
state = { ...state, formData: newFormData };
|
|
498
530
|
}
|
|
499
531
|
if (newErrorSchema) {
|
|
500
532
|
// First check to see if there is an existing validation error on this path...
|
|
@@ -517,10 +549,10 @@ export default class Form extends Component {
|
|
|
517
549
|
customErrors = new ErrorSchemaBuilder();
|
|
518
550
|
}
|
|
519
551
|
if (isRootPath) {
|
|
520
|
-
const
|
|
521
|
-
if (
|
|
552
|
+
const pathErrors = _get(newErrorSchema, ERRORS_KEY);
|
|
553
|
+
if (pathErrors) {
|
|
522
554
|
// only set errors when there are some
|
|
523
|
-
customErrors.setErrors(
|
|
555
|
+
customErrors.setErrors(pathErrors);
|
|
524
556
|
}
|
|
525
557
|
}
|
|
526
558
|
else {
|
|
@@ -535,16 +567,12 @@ export default class Form extends Component {
|
|
|
535
567
|
// If there are pending changes in the queue, skip live validation since it will happen with the last change
|
|
536
568
|
if (mustValidate && this.pendingChanges.length === 1) {
|
|
537
569
|
const liveValidation = this.liveValidate(schema, schemaUtils, mergeBaseErrorSchema, newFormData, extraErrors, customErrors, retrievedSchema);
|
|
538
|
-
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
570
|
+
state = { ...state, formData: newFormData, ...liveValidation, customErrors };
|
|
539
571
|
}
|
|
540
572
|
else if (!noValidate && newErrorSchema) {
|
|
541
573
|
// Merging 'newErrorSchema' into 'errorSchema' to display the custom raised errors.
|
|
542
|
-
const mergedErrors =
|
|
543
|
-
state = {
|
|
544
|
-
formData: newFormData,
|
|
545
|
-
...mergedErrors,
|
|
546
|
-
customErrors,
|
|
547
|
-
};
|
|
574
|
+
const mergedErrors = Form.mergeErrors({ errorSchema: mergeBaseErrorSchema, errors }, extraErrors, customErrors);
|
|
575
|
+
state = { ...state, formData: newFormData, ...mergedErrors, customErrors };
|
|
548
576
|
}
|
|
549
577
|
this.setState(state, () => {
|
|
550
578
|
if (onChange) {
|
|
@@ -608,6 +636,7 @@ export default class Form extends Component {
|
|
|
608
636
|
let newFormData = formData;
|
|
609
637
|
let state = { formData: newFormData };
|
|
610
638
|
if (omitExtraData === true && liveOmit === 'onBlur') {
|
|
639
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
611
640
|
newFormData = this.omitExtraData(formData);
|
|
612
641
|
state = { formData: newFormData };
|
|
613
642
|
}
|
|
@@ -657,9 +686,11 @@ export default class Form extends Component {
|
|
|
657
686
|
return;
|
|
658
687
|
}
|
|
659
688
|
event.persist();
|
|
689
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
660
690
|
const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
|
|
661
691
|
let { formData: newFormData } = this.state;
|
|
662
692
|
if (omitExtraData === true) {
|
|
693
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
663
694
|
newFormData = this.omitExtraData(newFormData);
|
|
664
695
|
}
|
|
665
696
|
if (noValidate || this.validateFormWithFormData(newFormData)) {
|
|
@@ -686,8 +717,9 @@ export default class Form extends Component {
|
|
|
686
717
|
* @returns - The `GlobalFormOptions` from the props
|
|
687
718
|
* @private
|
|
688
719
|
*/
|
|
689
|
-
getGlobalFormOptions(props) {
|
|
720
|
+
static getGlobalFormOptions(props) {
|
|
690
721
|
const { uiSchema = {}, experimental_componentUpdateStrategy, idSeparator = DEFAULT_ID_SEPARATOR, idPrefix = DEFAULT_ID_PREFIX, nameGenerator, useFallbackUiForUnsupportedType = false, } = props;
|
|
722
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
691
723
|
const rootFieldId = uiSchema['ui:rootFieldId'];
|
|
692
724
|
// Omit any options that are undefined or null
|
|
693
725
|
return {
|
|
@@ -699,7 +731,7 @@ export default class Form extends Component {
|
|
|
699
731
|
};
|
|
700
732
|
}
|
|
701
733
|
/** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
|
|
702
|
-
getRegistry(props, schema, schemaUtils) {
|
|
734
|
+
static getRegistry(props, schema, schemaUtils) {
|
|
703
735
|
const { translateString: customTranslateString, uiSchema = {} } = props;
|
|
704
736
|
const { fields, templates, widgets, formContext, translateString } = getDefaultRegistry();
|
|
705
737
|
return {
|
|
@@ -718,7 +750,7 @@ export default class Form extends Component {
|
|
|
718
750
|
schemaUtils,
|
|
719
751
|
translateString: customTranslateString || translateString,
|
|
720
752
|
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY],
|
|
721
|
-
globalFormOptions:
|
|
753
|
+
globalFormOptions: Form.getGlobalFormOptions(props),
|
|
722
754
|
uiSchemaDefinitions: uiSchema[UI_DEFINITIONS_KEY] ?? {},
|
|
723
755
|
};
|
|
724
756
|
}
|
|
@@ -760,6 +792,7 @@ export default class Form extends Component {
|
|
|
760
792
|
}
|
|
761
793
|
if (field && field.length) {
|
|
762
794
|
// If we got a list with length > 0
|
|
795
|
+
// oxlint-disable-next-line prefer-destructuring
|
|
763
796
|
field = field[0];
|
|
764
797
|
}
|
|
765
798
|
if (field) {
|
|
@@ -777,7 +810,7 @@ export default class Form extends Component {
|
|
|
777
810
|
const { errors: prevErrors } = this.state;
|
|
778
811
|
const schemaValidation = this.validate(formData);
|
|
779
812
|
// Always merge extraErrors so they remain visible in state regardless of extraErrorsBlockSubmit.
|
|
780
|
-
const { errors, errorSchema } = extraErrors ?
|
|
813
|
+
const { errors, errorSchema } = extraErrors ? Form.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
|
|
781
814
|
// hasError gates submission: schema errors always block; extraErrors only block when
|
|
782
815
|
// extraErrorsBlockSubmit is set (non-breaking default: extraErrors are informational only).
|
|
783
816
|
const hasError = schemaValidation.errors.length > 0 || (extraErrors && extraErrorsBlockSubmit);
|
|
@@ -800,6 +833,7 @@ export default class Form extends Component {
|
|
|
800
833
|
onError(errors);
|
|
801
834
|
}
|
|
802
835
|
else {
|
|
836
|
+
// oxlint-disable-next-line no-console
|
|
803
837
|
console.error('Form validation failed', errors);
|
|
804
838
|
}
|
|
805
839
|
});
|
|
@@ -833,6 +867,7 @@ export default class Form extends Component {
|
|
|
833
867
|
const { omitExtraData } = this.props;
|
|
834
868
|
let { formData: newFormData } = this.state;
|
|
835
869
|
if (omitExtraData === true) {
|
|
870
|
+
// oxlint-disable-next-line typescript/no-deprecated
|
|
836
871
|
newFormData = this.omitExtraData(newFormData);
|
|
837
872
|
}
|
|
838
873
|
return this.validateFormWithFormData(newFormData);
|
|
@@ -843,7 +878,7 @@ export default class Form extends Component {
|
|
|
843
878
|
render() {
|
|
844
879
|
const { children, id, className = '', tagName, name, method, target, action, autoComplete, enctype, acceptCharset, noHtml5Validate = false, disabled, readonly, showErrorList = 'top', _internalFormWrapper, } = this.props;
|
|
845
880
|
const { schema, uiSchema, formData, errorSchema, fieldPathId, registry } = this.state;
|
|
846
|
-
const { SchemaField:
|
|
881
|
+
const { SchemaField: SchemaFieldComponent } = registry.fields;
|
|
847
882
|
const { SubmitButton } = registry.templates.ButtonTemplates;
|
|
848
883
|
// The `semantic-ui` and `material-ui` themes have `_internalFormWrapper`s that take an `as` prop that is the
|
|
849
884
|
// PropTypes.elementType to use for the inner tag, so we'll need to pass `tagName` along if it is provided.
|
|
@@ -855,6 +890,6 @@ export default class Form extends Component {
|
|
|
855
890
|
submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
|
|
856
891
|
}
|
|
857
892
|
const submitUiSchema = { [UI_OPTIONS_KEY]: { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
|
|
858
|
-
return (_jsxs(FormTag, { className: className
|
|
893
|
+
return (_jsxs(FormTag, { className: className || 'rjsf', id: id, name: name, method: method, target: target, action: action, autoComplete: autoComplete, encType: enctype, acceptCharset: acceptCharset, noValidate: noHtml5Validate, onSubmit: this.onSubmit, as: as, ref: this.formElement, children: [showErrorList === 'top' && this.renderErrors(registry), _jsx(SchemaFieldComponent, { name: '', schema: schema, uiSchema: uiSchema, errorSchema: errorSchema, fieldPathId: fieldPathId, formData: formData, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, registry: registry, disabled: disabled, readonly: readonly }), children || _jsx(SubmitButton, { uiSchema: submitUiSchema, registry: registry }), showErrorList === 'bottom' && this.renderErrors(registry)] }));
|
|
859
894
|
}
|
|
860
895
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
3
|
export interface RichDescriptionProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
4
4
|
/** The description text for a field, potentially containing markdown */
|
|
5
5
|
description: string | ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichDescription.d.ts","sourceRoot":"","sources":["../../src/components/RichDescription.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RichDescription.d.ts","sourceRoot":"","sources":["../../src/components/RichDescription.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMrG,MAAM,WAAW,oBAAoB,CACnC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG;IAE/B,wEAAwE;IACxE,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC7B;AAED;;;GAGG;AACH,iBAAwB,eAAe,CACrC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAa,EAAE,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,oDAYxE;kBAhBuB,eAAe;;;eAAf,eAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getTestIds, getUiOptions
|
|
2
|
+
import { getTestIds, getUiOptions } from '@rjsf/utils';
|
|
3
3
|
import { Markdown } from 'markdown-to-jsx/react';
|
|
4
4
|
const TEST_IDS = getTestIds();
|
|
5
5
|
/** Renders the given `description` in the props as
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
3
|
export interface RichHelpProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
|
|
4
4
|
/** The description text for a field, potentially containing markdown */
|
|
5
5
|
help: string | ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichHelp.d.ts","sourceRoot":"","sources":["../../src/components/RichHelp.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RichHelp.d.ts","sourceRoot":"","sources":["../../src/components/RichHelp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAMrG,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG;IAC9G,wEAAwE;IACxE,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;CAC7B;AAED;;;GAGG;AACH,iBAAwB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EAClH,IAAI,EACJ,QAAQ,EACR,QAAa,GACd,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,oDAYxB;kBAhBuB,QAAQ;;;eAAR,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getTestIds, getUiOptions
|
|
2
|
+
import { getTestIds, getUiOptions } from '@rjsf/utils';
|
|
3
3
|
import { Markdown } from 'markdown-to-jsx/react';
|
|
4
4
|
const TEST_IDS = getTestIds();
|
|
5
5
|
/** Renders the given `description` in the props as
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
export interface SchemaExamplesProps<S extends StrictRJSFSchema = RJSFSchema> {
|
|
3
3
|
/** The id of the input element this datalist is for */
|
|
4
4
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaExamples.d.ts","sourceRoot":"","sources":["../../src/components/SchemaExamples.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SchemaExamples.d.ts","sourceRoot":"","sources":["../../src/components/SchemaExamples.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGhE,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU;IAC1E,uDAAuD;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,MAAM,EAAE,CAAC,CAAC;CACX;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,kDAoB5G"}
|
|
@@ -17,7 +17,5 @@ export default function SchemaExamples(props) {
|
|
|
17
17
|
.concat(schemaDefault !== undefined && !examples.map(String).includes(String(schemaDefault))
|
|
18
18
|
? [schemaDefault]
|
|
19
19
|
: [])
|
|
20
|
-
.map((example) => {
|
|
21
|
-
return _jsx("option", { value: example }, String(example));
|
|
22
|
-
}) }, `datalist_${id}`));
|
|
20
|
+
.map((example) => (_jsx("option", { value: example }, String(example)))) }, `datalist_${id}`));
|
|
23
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayField` component is used to render a field in the schema that is of type `array`. It supports both normal
|
|
3
3
|
* and fixed array, allowing user to add and remove elements from the array data.
|
|
4
4
|
*/
|