@rjsf/core 6.0.0-beta.9 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +2 -0
  2. package/dist/core.umd.js +2042 -1987
  3. package/dist/index.cjs +4909 -0
  4. package/dist/index.cjs.map +7 -0
  5. package/dist/index.esm.js +2509 -2389
  6. package/dist/index.esm.js.map +4 -4
  7. package/lib/components/Form.d.ts +137 -34
  8. package/lib/components/Form.d.ts.map +1 -1
  9. package/lib/components/Form.js +318 -173
  10. package/lib/components/fields/ArrayField.d.ts +2 -187
  11. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  12. package/lib/components/fields/ArrayField.js +526 -492
  13. package/lib/components/fields/BooleanField.d.ts.map +1 -1
  14. package/lib/components/fields/BooleanField.js +8 -3
  15. package/lib/components/fields/FallbackField.d.ts +7 -0
  16. package/lib/components/fields/FallbackField.d.ts.map +1 -0
  17. package/lib/components/fields/FallbackField.js +72 -0
  18. package/lib/components/fields/LayoutGridField.d.ts +109 -186
  19. package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
  20. package/lib/components/fields/LayoutGridField.js +426 -426
  21. package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
  22. package/lib/components/fields/LayoutHeaderField.js +3 -3
  23. package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
  24. package/lib/components/fields/LayoutMultiSchemaField.js +6 -6
  25. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
  26. package/lib/components/fields/MultiSchemaField.js +16 -10
  27. package/lib/components/fields/NullField.js +3 -3
  28. package/lib/components/fields/NumberField.d.ts.map +1 -1
  29. package/lib/components/fields/NumberField.js +3 -3
  30. package/lib/components/fields/ObjectField.d.ts +2 -68
  31. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  32. package/lib/components/fields/ObjectField.js +163 -163
  33. package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
  34. package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
  35. package/lib/components/fields/OptionalDataControlsField.js +43 -0
  36. package/lib/components/fields/SchemaField.d.ts.map +1 -1
  37. package/lib/components/fields/SchemaField.js +52 -30
  38. package/lib/components/fields/StringField.d.ts.map +1 -1
  39. package/lib/components/fields/StringField.js +8 -3
  40. package/lib/components/fields/index.d.ts.map +1 -1
  41. package/lib/components/fields/index.js +4 -0
  42. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
  43. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
  44. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +3 -3
  45. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
  46. package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +3 -8
  47. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +3 -3
  48. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
  49. package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
  50. package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
  51. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
  52. package/lib/components/templates/ArrayFieldTemplate.js +4 -5
  53. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
  54. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
  55. package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
  56. package/lib/components/templates/BaseInputTemplate.js +2 -2
  57. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
  58. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
  59. package/lib/components/templates/ButtonTemplates/AddButton.js +2 -2
  60. package/lib/components/templates/FallbackFieldTemplate.d.ts +7 -0
  61. package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -0
  62. package/lib/components/templates/FallbackFieldTemplate.js +12 -0
  63. package/lib/components/templates/FieldErrorTemplate.js +2 -2
  64. package/lib/components/templates/FieldHelpTemplate.js +2 -2
  65. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
  66. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
  67. package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
  68. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
  69. package/lib/components/templates/ObjectFieldTemplate.js +3 -2
  70. package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
  71. package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
  72. package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
  73. package/lib/components/templates/TitleField.d.ts.map +1 -1
  74. package/lib/components/templates/TitleField.js +2 -2
  75. package/lib/components/templates/UnsupportedField.js +3 -3
  76. package/lib/components/templates/WrapIfAdditionalTemplate.js +2 -2
  77. package/lib/components/templates/index.d.ts.map +1 -1
  78. package/lib/components/templates/index.js +6 -0
  79. package/lib/components/widgets/AltDateWidget.d.ts +1 -1
  80. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
  81. package/lib/components/widgets/AltDateWidget.js +5 -46
  82. package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
  83. package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
  84. package/lib/components/widgets/CheckboxWidget.js +2 -2
  85. package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
  86. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
  87. package/lib/components/widgets/CheckboxesWidget.js +4 -4
  88. package/lib/components/widgets/FileWidget.d.ts.map +1 -1
  89. package/lib/components/widgets/FileWidget.js +7 -87
  90. package/lib/components/widgets/HiddenWidget.d.ts +1 -1
  91. package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
  92. package/lib/components/widgets/HiddenWidget.js +2 -2
  93. package/lib/components/widgets/RadioWidget.d.ts +1 -1
  94. package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
  95. package/lib/components/widgets/RadioWidget.js +2 -2
  96. package/lib/components/widgets/RatingWidget.d.ts +1 -1
  97. package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
  98. package/lib/components/widgets/RatingWidget.js +2 -2
  99. package/lib/components/widgets/SelectWidget.d.ts +1 -1
  100. package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
  101. package/lib/components/widgets/SelectWidget.js +2 -2
  102. package/lib/components/widgets/TextareaWidget.d.ts +1 -1
  103. package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
  104. package/lib/components/widgets/TextareaWidget.js +2 -2
  105. package/lib/getDefaultRegistry.d.ts.map +1 -1
  106. package/lib/getDefaultRegistry.js +6 -1
  107. package/lib/getTestRegistry.d.ts +5 -0
  108. package/lib/getTestRegistry.d.ts.map +1 -0
  109. package/lib/getTestRegistry.js +23 -0
  110. package/lib/index.d.ts +2 -1
  111. package/lib/index.d.ts.map +1 -1
  112. package/lib/index.js +2 -1
  113. package/lib/tsconfig.tsbuildinfo +1 -1
  114. package/package.json +35 -20
  115. package/src/components/Form.tsx +468 -206
  116. package/src/components/fields/ArrayField.tsx +871 -723
  117. package/src/components/fields/BooleanField.tsx +14 -5
  118. package/src/components/fields/FallbackField.tsx +157 -0
  119. package/src/components/fields/LayoutGridField.tsx +626 -603
  120. package/src/components/fields/LayoutHeaderField.tsx +3 -3
  121. package/src/components/fields/LayoutMultiSchemaField.tsx +9 -10
  122. package/src/components/fields/MultiSchemaField.tsx +57 -36
  123. package/src/components/fields/NullField.tsx +3 -3
  124. package/src/components/fields/NumberField.tsx +11 -3
  125. package/src/components/fields/ObjectField.tsx +308 -239
  126. package/src/components/fields/OptionalDataControlsField.tsx +84 -0
  127. package/src/components/fields/SchemaField.tsx +75 -94
  128. package/src/components/fields/StringField.tsx +14 -5
  129. package/src/components/fields/index.ts +4 -0
  130. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
  131. package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +16 -21
  132. package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -3
  133. package/src/components/templates/ArrayFieldTemplate.tsx +11 -18
  134. package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
  135. package/src/components/templates/BaseInputTemplate.tsx +5 -5
  136. package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
  137. package/src/components/templates/FallbackFieldTemplate.tsx +28 -0
  138. package/src/components/templates/FieldErrorTemplate.tsx +2 -2
  139. package/src/components/templates/FieldHelpTemplate.tsx +2 -2
  140. package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
  141. package/src/components/templates/ObjectFieldTemplate.tsx +12 -7
  142. package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
  143. package/src/components/templates/TitleField.tsx +6 -1
  144. package/src/components/templates/UnsupportedField.tsx +3 -3
  145. package/src/components/templates/WrapIfAdditionalTemplate.tsx +5 -5
  146. package/src/components/templates/index.ts +6 -0
  147. package/src/components/widgets/AltDateWidget.tsx +8 -126
  148. package/src/components/widgets/CheckboxWidget.tsx +4 -3
  149. package/src/components/widgets/CheckboxesWidget.tsx +5 -4
  150. package/src/components/widgets/FileWidget.tsx +11 -102
  151. package/src/components/widgets/HiddenWidget.tsx +2 -1
  152. package/src/components/widgets/RadioWidget.tsx +3 -2
  153. package/src/components/widgets/RatingWidget.tsx +2 -1
  154. package/src/components/widgets/SelectWidget.tsx +3 -2
  155. package/src/components/widgets/TextareaWidget.tsx +3 -2
  156. package/src/getDefaultRegistry.ts +14 -1
  157. package/src/getTestRegistry.tsx +38 -0
  158. package/src/index.ts +2 -1
  159. package/dist/index.js +0 -4834
  160. package/dist/index.js.map +0 -7
@@ -1,5 +1,5 @@
1
1
  import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
- /** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `idSchema`
2
+ /** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
3
3
  * and whether it is `required` from the props. The `title` is derived from the props as follows:
4
4
  * - If there is a title in the `uiSchema`, it is displayed
5
5
  * - Else, if there is an explicit `title` passed in the props, it is displayed
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
3
- /** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `idSchema`
3
+ /** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
4
4
  * and whether it is `required` from the props. The `title` is derived from the props as follows:
5
5
  * - If there is a title in the `uiSchema`, it is displayed
6
6
  * - Else, if there is an explicit `title` passed in the props, it is displayed
@@ -10,7 +10,7 @@ import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
10
10
  * @param props - The `LayoutHeaderField` for the component
11
11
  */
12
12
  export default function LayoutHeaderField(props) {
13
- const { idSchema, title, schema, uiSchema, required, registry, name } = props;
13
+ const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
14
14
  const options = getUiOptions(uiSchema, registry.globalUiOptions);
15
15
  const { title: uiTitle } = options;
16
16
  const { title: schemaTitle } = schema;
@@ -19,5 +19,5 @@ export default function LayoutHeaderField(props) {
19
19
  return null;
20
20
  }
21
21
  const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
22
- return (_jsx(TitleFieldTemplate, { id: titleId(idSchema), title: fieldTitle, required: required, schema: schema, uiSchema: uiSchema, registry: registry }));
22
+ return (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: fieldTitle, required: required, schema: schema, uiSchema: uiSchema, registry: registry }));
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,eAAe,EAEf,UAAU,EACV,eAAe,EAOf,UAAU,EAIV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,aAAa,CAAC;AAQr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AO,GACb,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,GACX,eAAe,CAAC,CAAC,CAAC,EAAE,CAatB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsI3B"}
@@ -55,10 +55,10 @@ export function computeEnumOptions(schema, options, schemaUtils, uiSchema, formD
55
55
  * is active. If no `selectorField` is specified, then an error is thrown.
56
56
  */
57
57
  export default function LayoutMultiSchemaField(props) {
58
- const { name, baseType, disabled = false, formData, idSchema, onBlur, onChange, options, onFocus, registry, uiSchema, schema, formContext, autofocus, readonly, required, errorSchema, hideError = false, } = props;
58
+ const { name, baseType, disabled = false, formData, fieldPathId, onBlur, onChange, options, onFocus, registry, uiSchema, schema, autofocus, readonly, required, errorSchema, hideError = false, } = props;
59
59
  const { widgets, schemaUtils, globalUiOptions } = registry;
60
60
  const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
61
- const id = get(idSchema, ID_KEY);
61
+ const id = get(fieldPathId, ID_KEY);
62
62
  const discriminator = getDiscriminatorFieldFromSchema(schema);
63
63
  const FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, options);
64
64
  const FieldTemplate = getTemplate('FieldTemplate', registry, options);
@@ -104,11 +104,11 @@ export default function LayoutMultiSchemaField(props) {
104
104
  if (newFormData) {
105
105
  set(newFormData, selectorField, opt);
106
106
  }
107
- onChange(newFormData, undefined, id);
107
+ // Pass the component name in the path
108
+ onChange(newFormData, fieldPathId.path, undefined, id);
108
109
  };
109
110
  // filtering the options based on the type of widget because `selectField` does not recognize the `convertOther` prop
110
111
  const widgetOptions = { enumOptions, ...uiOptions };
111
- const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, { idSchema: idSchema, schema: schema, errors: rawErrors, registry: registry })) : undefined;
112
- const ignored = (value) => noop;
113
- return (_jsx(FieldTemplate, { id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, formContext: formContext, required: required, readonly: !!readonly, registry: registry, displayLabel: displayLabel, errors: errors, onChange: onChange, onDropPropertyClick: ignored, onKeyChange: ignored, children: _jsx(Widget, { id: id, name: name, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, formContext: formContext, autofocus: autofocus, readonly: readonly, required: required, registry: registry, multiple: false, rawErrors: rawErrors, hideError: hideFieldError, hideLabel: !displayLabel, errorSchema: fieldErrorSchema, placeholder: placeholder, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, value: selectedOption, options: widgetOptions }) }));
112
+ const errors = !hideFieldError && rawErrors.length > 0 ? (_jsx(FieldErrorTemplate, { fieldPathId: fieldPathId, schema: schema, errors: rawErrors, registry: registry })) : undefined;
113
+ return (_jsx(FieldTemplate, { id: id, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, required: required, readonly: !!readonly, registry: registry, displayLabel: displayLabel, errors: errors, onChange: onChange, onKeyRename: noop, onKeyRenameBlur: noop, onRemoveProperty: noop, children: _jsx(Widget, { id: id, name: name, schema: schema, label: (title || schema.title) ?? '', disabled: disabled || (Array.isArray(enumOptions) && isEmpty(enumOptions)), uiSchema: uiSchema, autofocus: autofocus, readonly: readonly, required: required, registry: registry, multiple: false, rawErrors: rawErrors, hideError: hideFieldError, hideLabel: !displayLabel, errorSchema: fieldErrorSchema, placeholder: placeholder, onChange: onOptionChange, onBlur: onBlur, onFocus: onFocus, value: selectedOption, options: widgetOptions, htmlName: fieldPathId.name }) }));
114
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/MultiSchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,OAAO,EAIL,UAAU,EACV,eAAe,EAMf,UAAU,EACV,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAErB,4DAA4D;AAC5D,KAAK,eAAe,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,IAAI;IAC9D,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,gBAAgB,EAAE,CAAC,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,cAAM,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACnH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,eAAe,CAAC,CAAC,CAAC,CACnB;IACC;;;OAGG;gBACS,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAiBtC;;;;;OAKG;IACH,kBAAkB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAA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,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE;IAW/E;;;;;OAKG;IACH,cAAc,GAAI,SAAS,MAAM,UAqB/B;IAEF,UAAU;IAKV;OACG;IACH,MAAM;CA4HP;AAED,eAAe,UAAU,CAAC"}
@@ -1,9 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Component } from 'react';
3
3
  import get from 'lodash-es/get.js';
4
4
  import isEmpty from 'lodash-es/isEmpty.js';
5
5
  import omit from 'lodash-es/omit.js';
6
- import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getUiOptions, getWidget, mergeSchemas, ONE_OF_KEY, TranslatableString, } from '@rjsf/utils';
6
+ import { ANY_OF_KEY, deepEquals, ERRORS_KEY, getDiscriminatorFieldFromSchema, getTemplate, getUiOptions, getWidget, isFormDataAvailable, mergeSchemas, ONE_OF_KEY, shouldRenderOptionalField, TranslatableString, } from '@rjsf/utils';
7
7
  /** The `AnyOfField` component is used to render a field in the schema that is an `anyOf`, `allOf` or `oneOf`. It tracks
8
8
  * the currently selected option and cleans up any irrelevant data in `formData`.
9
9
  *
@@ -31,7 +31,7 @@ class AnyOfField extends Component {
31
31
  * @param prevState - The previous `AnyOfFieldState` for this template
32
32
  */
33
33
  componentDidUpdate(prevProps, prevState) {
34
- const { formData, options, idSchema } = this.props;
34
+ const { formData, options, fieldPathId } = this.props;
35
35
  const { selectedOption } = this.state;
36
36
  let newState = this.state;
37
37
  if (!deepEquals(prevProps.options, options)) {
@@ -40,7 +40,7 @@ class AnyOfField extends Component {
40
40
  const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
41
41
  newState = { selectedOption, retrievedOptions };
42
42
  }
43
- if (!deepEquals(formData, prevProps.formData) && idSchema.$id === prevProps.idSchema.$id) {
43
+ if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
44
44
  const { retrievedOptions } = newState;
45
45
  const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
46
46
  if (prevState && matchingOption !== selectedOption) {
@@ -71,7 +71,7 @@ class AnyOfField extends Component {
71
71
  */
72
72
  onOptionChange = (option) => {
73
73
  const { selectedOption, retrievedOptions } = this.state;
74
- const { formData, onChange, registry } = this.props;
74
+ const { formData, onChange, registry, fieldPathId } = this.props;
75
75
  const { schemaUtils } = registry;
76
76
  const intOption = option !== undefined ? parseInt(option, 10) : -1;
77
77
  if (intOption === selectedOption) {
@@ -86,19 +86,22 @@ class AnyOfField extends Component {
86
86
  newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, 'excludeObjectChildren');
87
87
  }
88
88
  this.setState({ selectedOption: intOption }, () => {
89
- onChange(newFormData, undefined, this.getFieldId());
89
+ onChange(newFormData, fieldPathId.path, undefined, this.getFieldId());
90
90
  });
91
91
  };
92
92
  getFieldId() {
93
- const { idSchema, schema } = this.props;
94
- return `${idSchema.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
93
+ const { fieldPathId, schema } = this.props;
94
+ return `${fieldPathId.$id}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`;
95
95
  }
96
96
  /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
97
97
  */
98
98
  render() {
99
- const { name, disabled = false, errorSchema = {}, formContext, onBlur, onFocus, readonly, registry, schema, uiSchema, } = this.props;
99
+ const { name, disabled = false, errorSchema = {}, formData, onBlur, onFocus, readonly, required = false, registry, schema, uiSchema, } = this.props;
100
100
  const { widgets, fields, translateString, globalUiOptions, schemaUtils } = registry;
101
101
  const { SchemaField: _SchemaField } = fields;
102
+ const MultiSchemaFieldTemplate = getTemplate('MultiSchemaFieldTemplate', registry, globalUiOptions);
103
+ const isOptionalRender = shouldRenderOptionalField(registry, schema, required, uiSchema);
104
+ const hasFormData = isFormDataAvailable(formData);
102
105
  const { selectedOption, retrievedOptions } = this.state;
103
106
  const { widget = 'select', placeholder, autofocus, autocomplete, title = schema.title, ...uiOptions } = getUiOptions(uiSchema, globalUiOptions);
104
107
  const Widget = getWidget({ type: 'number' }, widget, widgets);
@@ -148,7 +151,10 @@ class AnyOfField extends Component {
148
151
  value: index,
149
152
  };
150
153
  });
151
- return (_jsxs("div", { className: 'panel panel-default panel-body', children: [_jsx("div", { className: 'form-group', children: _jsx(Widget, { id: this.getFieldId(), name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: this.onOptionChange, onBlur: onBlur, onFocus: onFocus, disabled: disabled || isEmpty(enumOptions), multiple: false, rawErrors: rawErrors, errorSchema: fieldErrorSchema, value: selectedOption >= 0 ? selectedOption : undefined, options: { enumOptions, ...uiOptions }, registry: registry, formContext: formContext, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly }) }), optionSchema && optionSchema.type !== 'null' && (_jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))] }));
154
+ const selector = !isOptionalRender || hasFormData ? (_jsx(Widget, { id: this.getFieldId(), name: `${name}${schema.oneOf ? '__oneof_select' : '__anyof_select'}`, schema: { type: 'number', default: 0 }, onChange: this.onOptionChange, onBlur: onBlur, onFocus: onFocus, disabled: disabled || isEmpty(enumOptions), multiple: false, rawErrors: rawErrors, errorSchema: fieldErrorSchema, value: selectedOption >= 0 ? selectedOption : undefined, options: { enumOptions, ...uiOptions }, registry: registry, placeholder: placeholder, autocomplete: autocomplete, autofocus: autofocus, label: title ?? name, hideLabel: !displayLabel, readonly: readonly })) : undefined;
155
+ const optionsSchemaField = (optionSchema && optionSchema.type !== 'null' && (_jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }))) ||
156
+ null;
157
+ return (_jsx(MultiSchemaFieldTemplate, { schema: schema, registry: registry, uiSchema: uiSchema, selector: selector, optionSchemaField: optionsSchemaField }));
152
158
  }
153
159
  }
154
160
  export default AnyOfField;
@@ -5,12 +5,12 @@ import { useEffect } from 'react';
5
5
  * @param props - The `FieldProps` for this template
6
6
  */
7
7
  function NullField(props) {
8
- const { formData, onChange } = props;
8
+ const { formData, onChange, fieldPathId } = props;
9
9
  useEffect(() => {
10
10
  if (formData === undefined) {
11
- onChange(null);
11
+ onChange(null, fieldPathId.path);
12
12
  }
13
- }, [formData, onChange]);
13
+ }, [fieldPathId, formData, onChange]);
14
14
  return null;
15
15
  }
16
16
  export default NullField;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,EAAyB,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAc/G;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkD3B;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"NumberField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/NumberField.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAcrB;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACpG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkD3B;AAED,eAAe,WAAW,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState, useCallback } from 'react';
3
- import { asNumber } from '@rjsf/utils';
3
+ import { asNumber, } from '@rjsf/utils';
4
4
  // Matches a string that ends in a . character, optionally followed by a sequence of
5
5
  // digits followed by any number of 0 characters up until the end of the line.
6
6
  // Ensuring that there is at least one prefixed character is important so that
@@ -37,7 +37,7 @@ function NumberField(props) {
37
37
  *
38
38
  * @param value - The current value for the change occurring
39
39
  */
40
- const handleChange = useCallback((value, errorSchema, id) => {
40
+ const handleChange = useCallback((value, path, errorSchema, id) => {
41
41
  // Cache the original value in component state
42
42
  setLastValue(value);
43
43
  // Normalize decimals that don't start with a zero character in advance so
@@ -51,7 +51,7 @@ function NumberField(props) {
51
51
  const processed = typeof value === 'string' && value.match(trailingCharMatcherWithPrefix)
52
52
  ? asNumber(value.replace(trailingCharMatcher, ''))
53
53
  : asNumber(value);
54
- onChange(processed, errorSchema, id);
54
+ onChange(processed, path, errorSchema, id);
55
55
  }, [onChange]);
56
56
  if (typeof lastValue === 'string' && typeof value === 'number') {
57
57
  // Construct a regular expression that checks for a string that consists
@@ -1,74 +1,8 @@
1
- import { Component } from 'react';
2
- import { ErrorSchema, FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
3
- /** Type used for the state of the `ObjectField` component */
4
- type ObjectFieldState = {
5
- /** Flag indicating whether an additional property key was modified */
6
- wasPropertyKeyModified: boolean;
7
- /** The set of additional properties */
8
- additionalProperties: object;
9
- };
1
+ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
10
2
  /** The `ObjectField` component is used to render a field in the schema that is of type `object`. It tracks whether an
11
3
  * additional property key was modified and what it was modified to
12
4
  *
13
5
  * @param props - The `FieldProps` for this template
14
6
  */
15
- declare class ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FieldProps<T, S, F>, ObjectFieldState> {
16
- /** Set up the initial state */
17
- state: {
18
- wasPropertyKeyModified: boolean;
19
- additionalProperties: {};
20
- };
21
- /** Returns a flag indicating whether the `name` field is required in the object schema
22
- *
23
- * @param name - The name of the field to check for required-ness
24
- * @returns - True if the field `name` is required, false otherwise
25
- */
26
- isRequired(name: string): boolean;
27
- /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
28
- * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
29
- * formData.
30
- *
31
- * @param name - The name of the property
32
- * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
33
- * @returns - The onPropertyChange callback for the `name` property
34
- */
35
- onPropertyChange: (name: string, addedByAdditionalProperties?: boolean) => (value: T | undefined, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
36
- /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
37
- * and calls the `onChange` callback with it
38
- *
39
- * @param key - The key for which the drop callback is desired
40
- * @returns - The drop property click callback
41
- */
42
- onDropPropertyClick: (key: string) => (event: DragEvent) => void;
43
- /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
44
- * that is already not assigned is found.
45
- *
46
- * @param preferredKey - The preferred name of a new key
47
- * @param [formData] - The form data in which to check if the desired key already exists
48
- * @returns - The name of the next available key from `preferredKey`
49
- */
50
- getAvailableKey: (preferredKey: string, formData?: T) => string;
51
- /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
52
- * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
53
- *
54
- * @param oldValue - The old value of a field
55
- * @returns - The key change callback function
56
- */
57
- onKeyChange: (oldValue: any) => (value: any, newErrorSchema: ErrorSchema<T>) => void;
58
- /** Returns a default value to be used for a new additional schema property of the given `type`
59
- *
60
- * @param type - The type of the new additional schema property
61
- */
62
- getDefaultValue(type?: RJSFSchema['type']): {} | null;
63
- /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
64
- * default data for that field has been added to the formData.
65
- *
66
- * @param schema - The schema element to which the new property is being added
67
- */
68
- handleAddClick: (schema: S) => () => void;
69
- /** Renders the `ObjectField` from the given props
70
- */
71
- render(): import("react/jsx-runtime").JSX.Element;
72
- }
73
- export default ObjectField;
7
+ export default function ObjectField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
74
8
  //# sourceMappingURL=ObjectField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ObjectField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAIL,WAAW,EACX,UAAU,EACV,eAAe,EAGf,UAAU,EACV,gBAAgB,EAOjB,MAAM,aAAa,CAAC;AAQrB,6DAA6D;AAC7D,KAAK,gBAAgB,GAAG;IACtB,sEAAsE;IACtE,sBAAsB,EAAE,OAAO,CAAC;IAChC,uCAAuC;IACvC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,cAAM,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,CAAE,SAAQ,SAAS,CACpH,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACnB,gBAAgB,CACjB;IACC,+BAA+B;IAC/B,KAAK;;;MAGH;IAEF;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM;IAKvB;;;;;;;OAOG;IACH,gBAAgB,GAAI,MAAM,MAAM,EAAE,qCAAmC,MAC3D,OAAO,CAAC,GAAG,SAAS,EAAE,iBAAiB,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,UAuB1E;IAEF;;;;;OAKG;IACH,mBAAmB,GAAI,KAAK,MAAM,MACxB,OAAO,SAAS,UAOxB;IAEF;;;;;;OAMG;IACH,eAAe,GAAI,cAAc,MAAM,EAAE,WAAW,CAAC,YAUnD;IAEF;;;;;OAKG;IACH,W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