@rjsf/core 6.0.0-beta.2 → 6.0.0-beta.21

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 (114) hide show
  1. package/dist/core.umd.js +705 -471
  2. package/dist/{index.js → index.cjs} +1094 -844
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/index.esm.js +1053 -774
  5. package/dist/index.esm.js.map +4 -4
  6. package/lib/components/Form.d.ts +88 -23
  7. package/lib/components/Form.d.ts.map +1 -1
  8. package/lib/components/Form.js +213 -151
  9. package/lib/components/fields/ArrayField.d.ts +17 -7
  10. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  11. package/lib/components/fields/ArrayField.js +116 -70
  12. package/lib/components/fields/BooleanField.d.ts.map +1 -1
  13. package/lib/components/fields/BooleanField.js +7 -2
  14. package/lib/components/fields/LayoutGridField.d.ts +27 -25
  15. package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
  16. package/lib/components/fields/LayoutGridField.js +83 -59
  17. package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
  18. package/lib/components/fields/LayoutHeaderField.js +3 -3
  19. package/lib/components/fields/LayoutMultiSchemaField.js +6 -5
  20. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
  21. package/lib/components/fields/MultiSchemaField.js +13 -9
  22. package/lib/components/fields/NullField.js +3 -3
  23. package/lib/components/fields/NumberField.d.ts.map +1 -1
  24. package/lib/components/fields/NumberField.js +3 -3
  25. package/lib/components/fields/ObjectField.d.ts +3 -3
  26. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  27. package/lib/components/fields/ObjectField.js +34 -34
  28. package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
  29. package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
  30. package/lib/components/fields/OptionalDataControlsField.js +43 -0
  31. package/lib/components/fields/SchemaField.d.ts.map +1 -1
  32. package/lib/components/fields/SchemaField.js +17 -17
  33. package/lib/components/fields/StringField.d.ts.map +1 -1
  34. package/lib/components/fields/StringField.js +7 -2
  35. package/lib/components/fields/index.d.ts.map +1 -1
  36. package/lib/components/fields/index.js +2 -0
  37. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
  38. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
  39. package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +2 -2
  40. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
  41. package/lib/components/templates/ArrayFieldTemplate.js +4 -3
  42. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
  43. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
  44. package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
  45. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
  46. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
  47. package/lib/components/templates/ButtonTemplates/AddButton.js +2 -2
  48. package/lib/components/templates/FieldErrorTemplate.js +2 -2
  49. package/lib/components/templates/FieldHelpTemplate.js +2 -2
  50. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
  51. package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
  52. package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
  53. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
  54. package/lib/components/templates/ObjectFieldTemplate.js +3 -2
  55. package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
  56. package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
  57. package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
  58. package/lib/components/templates/TitleField.d.ts.map +1 -1
  59. package/lib/components/templates/TitleField.js +2 -2
  60. package/lib/components/templates/UnsupportedField.js +3 -3
  61. package/lib/components/templates/index.d.ts.map +1 -1
  62. package/lib/components/templates/index.js +4 -0
  63. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
  64. package/lib/components/widgets/AltDateWidget.js +15 -18
  65. package/lib/components/widgets/CheckboxesWidget.js +2 -2
  66. package/lib/getDefaultRegistry.d.ts.map +1 -1
  67. package/lib/getDefaultRegistry.js +2 -1
  68. package/lib/getTestRegistry.d.ts +5 -0
  69. package/lib/getTestRegistry.d.ts.map +1 -0
  70. package/lib/getTestRegistry.js +19 -0
  71. package/lib/index.d.ts +2 -1
  72. package/lib/index.d.ts.map +1 -1
  73. package/lib/index.js +2 -1
  74. package/lib/tsconfig.tsbuildinfo +1 -1
  75. package/package.json +18 -19
  76. package/src/components/Form.tsx +306 -177
  77. package/src/components/fields/ArrayField.tsx +127 -80
  78. package/src/components/fields/BooleanField.tsx +12 -3
  79. package/src/components/fields/LayoutGridField.tsx +95 -88
  80. package/src/components/fields/LayoutHeaderField.tsx +3 -3
  81. package/src/components/fields/LayoutMultiSchemaField.tsx +5 -5
  82. package/src/components/fields/MultiSchemaField.tsx +51 -35
  83. package/src/components/fields/NullField.tsx +3 -3
  84. package/src/components/fields/NumberField.tsx +11 -3
  85. package/src/components/fields/ObjectField.tsx +47 -53
  86. package/src/components/fields/OptionalDataControlsField.tsx +84 -0
  87. package/src/components/fields/SchemaField.tsx +24 -30
  88. package/src/components/fields/StringField.tsx +12 -3
  89. package/src/components/fields/index.ts +2 -0
  90. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
  91. package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
  92. package/src/components/templates/ArrayFieldTemplate.tsx +9 -5
  93. package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
  94. package/src/components/templates/BaseInputTemplate.tsx +3 -3
  95. package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
  96. package/src/components/templates/FieldErrorTemplate.tsx +2 -2
  97. package/src/components/templates/FieldHelpTemplate.tsx +2 -2
  98. package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
  99. package/src/components/templates/ObjectFieldTemplate.tsx +10 -5
  100. package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
  101. package/src/components/templates/TitleField.tsx +6 -1
  102. package/src/components/templates/UnsupportedField.tsx +3 -3
  103. package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
  104. package/src/components/templates/index.ts +4 -0
  105. package/src/components/widgets/AltDateWidget.tsx +21 -23
  106. package/src/components/widgets/CheckboxWidget.tsx +2 -2
  107. package/src/components/widgets/CheckboxesWidget.tsx +3 -3
  108. package/src/components/widgets/RadioWidget.tsx +1 -1
  109. package/src/components/widgets/SelectWidget.tsx +1 -1
  110. package/src/components/widgets/TextareaWidget.tsx +1 -1
  111. package/src/getDefaultRegistry.ts +10 -1
  112. package/src/getTestRegistry.tsx +34 -0
  113. package/src/index.ts +2 -1
  114. package/dist/index.js.map +0 -7
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Component } from 'react';
3
- import { getTemplate, getUiOptions, orderProperties, TranslatableString, ADDITIONAL_PROPERTY_FLAG, PROPERTIES_KEY, REF_KEY, ANY_OF_KEY, ONE_OF_KEY, } from '@rjsf/utils';
3
+ import { getTemplate, getUiOptions, orderProperties, shouldRenderOptionalField, toFieldPathId, TranslatableString, ADDITIONAL_PROPERTY_FLAG, PROPERTIES_KEY, REF_KEY, ANY_OF_KEY, ONE_OF_KEY, isFormDataAvailable, } from '@rjsf/utils';
4
4
  import Markdown from 'markdown-to-jsx';
5
5
  import get from 'lodash-es/get.js';
6
6
  import has from 'lodash-es/has.js';
@@ -36,8 +36,8 @@ class ObjectField extends Component {
36
36
  * @returns - The onPropertyChange callback for the `name` property
37
37
  */
38
38
  onPropertyChange = (name, addedByAdditionalProperties = false) => {
39
- return (value, newErrorSchema, id) => {
40
- const { formData, onChange, errorSchema } = this.props;
39
+ return (value, path, newErrorSchema, id) => {
40
+ const { onChange } = this.props;
41
41
  if (value === undefined && addedByAdditionalProperties) {
42
42
  // Don't set value = undefined for fields added by
43
43
  // additionalProperties. Doing so removes them from the
@@ -48,12 +48,7 @@ class ObjectField extends Component {
48
48
  // set empty values to the empty string.
49
49
  value = '';
50
50
  }
51
- const newFormData = { ...formData, [name]: value };
52
- onChange(newFormData, errorSchema &&
53
- errorSchema && {
54
- ...errorSchema,
55
- [name]: newErrorSchema,
56
- }, id);
51
+ onChange(value, path, newErrorSchema, id);
57
52
  };
58
53
  };
59
54
  /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
@@ -65,10 +60,11 @@ class ObjectField extends Component {
65
60
  onDropPropertyClick = (key) => {
66
61
  return (event) => {
67
62
  event.preventDefault();
68
- const { onChange, formData } = this.props;
63
+ const { onChange, formData, fieldPathId } = this.props;
69
64
  const copiedFormData = { ...formData };
70
65
  unset(copiedFormData, key);
71
- onChange(copiedFormData);
66
+ // drop property will pass the name in `path` array
67
+ onChange(copiedFormData, fieldPathId.path);
72
68
  };
73
69
  };
74
70
  /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
@@ -95,11 +91,11 @@ class ObjectField extends Component {
95
91
  * @returns - The key change callback function
96
92
  */
97
93
  onKeyChange = (oldValue) => {
98
- return (value, newErrorSchema) => {
94
+ return (value) => {
99
95
  if (oldValue === value) {
100
96
  return;
101
97
  }
102
- const { formData, onChange, errorSchema } = this.props;
98
+ const { formData, onChange, fieldPathId } = this.props;
103
99
  value = this.getAvailableKey(value, formData);
104
100
  const newFormData = {
105
101
  ...formData,
@@ -111,11 +107,7 @@ class ObjectField extends Component {
111
107
  });
112
108
  const renamedObj = Object.assign({}, ...keyValues);
113
109
  this.setState({ wasPropertyKeyModified: true });
114
- onChange(renamedObj, errorSchema &&
115
- errorSchema && {
116
- ...errorSchema,
117
- [value]: newErrorSchema,
118
- });
110
+ onChange(renamedObj, fieldPathId.path);
119
111
  };
120
112
  };
121
113
  /** Returns a default value to be used for a new additional schema property of the given `type`
@@ -150,7 +142,7 @@ class ObjectField extends Component {
150
142
  if (!(schema.additionalProperties || schema.patternProperties)) {
151
143
  return;
152
144
  }
153
- const { formData, onChange, registry } = this.props;
145
+ const { formData, onChange, registry, fieldPathId } = this.props;
154
146
  const newFormData = { ...formData };
155
147
  const newKey = this.getAvailableKey('newKey', newFormData);
156
148
  if (schema.patternProperties) {
@@ -181,28 +173,34 @@ class ObjectField extends Component {
181
173
  // Cast this to make the `set` work properly
182
174
  set(newFormData, newKey, newValue);
183
175
  }
184
- onChange(newFormData);
176
+ // add will pass the name in `path` array
177
+ onChange(newFormData, fieldPathId.path);
185
178
  };
186
179
  /** Renders the `ObjectField` from the given props
187
180
  */
188
181
  render() {
189
- const { schema: rawSchema, uiSchema = {}, formData, errorSchema, idSchema, name, required = false, disabled, readonly, hideError, idPrefix, idSeparator, onBlur, onFocus, registry, title, } = this.props;
190
- const { fields, formContext, schemaUtils, translateString, globalUiOptions } = registry;
191
- const { SchemaField } = fields;
192
- const schema = schemaUtils.retrieveSchema(rawSchema, formData);
182
+ const { schema: rawSchema, uiSchema = {}, formData, errorSchema, fieldPathId, name, required = false, disabled, readonly, hideError, onBlur, onFocus, registry, title, } = this.props;
183
+ const { fields, formContext, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
184
+ const { OptionalDataControlsField, SchemaField } = fields;
185
+ const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
193
186
  const uiOptions = getUiOptions(uiSchema, globalUiOptions);
194
187
  const { properties: schemaProperties = {} } = schema;
195
188
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
196
189
  const description = uiOptions.description ?? schema.description;
197
- let orderedProperties;
198
- try {
199
- const properties = Object.keys(schemaProperties);
200
- orderedProperties = orderProperties(properties, uiOptions.order);
201
- }
202
- catch (err) {
203
- return (_jsxs("div", { children: [_jsx("p", { className: 'rjsf-config-error', style: { color: 'red' }, children: _jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) }), _jsx("pre", { children: JSON.stringify(schema) })] }));
190
+ const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
191
+ const hasFormData = isFormDataAvailable(formData);
192
+ let orderedProperties = [];
193
+ if (!renderOptionalField || hasFormData) {
194
+ try {
195
+ const properties = Object.keys(schemaProperties);
196
+ orderedProperties = orderProperties(properties, uiOptions.order);
197
+ }
198
+ catch (err) {
199
+ return (_jsxs("div", { children: [_jsx("p", { className: 'rjsf-config-error', style: { color: 'red' }, children: _jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString.InvalidObjectField, [name || 'root', err.message]) }) }), _jsx("pre", { children: JSON.stringify(schema) })] }));
200
+ }
204
201
  }
205
202
  const Template = getTemplate('ObjectFieldTemplate', registry, uiOptions);
203
+ const optionalDataControl = renderOptionalField ? (_jsx(OptionalDataControlsField, { ...this.props, schema: schema })) : undefined;
206
204
  const templateProps = {
207
205
  // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
208
206
  title: uiOptions.label === false ? '' : templateTitle,
@@ -211,9 +209,9 @@ class ObjectField extends Component {
211
209
  const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name, ADDITIONAL_PROPERTY_FLAG]);
212
210
  const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name];
213
211
  const hidden = getUiOptions(fieldUiSchema).widget === 'hidden';
214
- const fieldIdSchema = get(idSchema, [name], {});
212
+ const innerFieldIdPathId = toFieldPathId(name, globalFormOptions, fieldPathId);
215
213
  return {
216
- content: (_jsx(SchemaField, { name: name, required: this.isRequired(name), schema: get(schema, [PROPERTIES_KEY, name], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, name), idSchema: fieldIdSchema, idPrefix: idPrefix, idSeparator: idSeparator, formData: get(formData, name), formContext: formContext, wasPropertyKeyModified: this.state.wasPropertyKeyModified, onKeyChange: this.onKeyChange(name), onChange: this.onPropertyChange(name, addedByAdditionalProperties), onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError, onDropPropertyClick: this.onDropPropertyClick }, name)),
214
+ content: (_jsx(SchemaField, { name: name, required: this.isRequired(name), schema: get(schema, [PROPERTIES_KEY, name], {}), uiSchema: fieldUiSchema, errorSchema: get(errorSchema, name), fieldPathId: innerFieldIdPathId, formData: get(formData, name), formContext: formContext, wasPropertyKeyModified: this.state.wasPropertyKeyModified, onKeyChange: this.onKeyChange(name), onChange: this.onPropertyChange(name, addedByAdditionalProperties), onBlur: onBlur, onFocus: onFocus, registry: registry, disabled: disabled, readonly: readonly, hideError: hideError, onDropPropertyClick: this.onDropPropertyClick }, name)),
217
215
  name,
218
216
  readonly,
219
217
  disabled,
@@ -224,13 +222,15 @@ class ObjectField extends Component {
224
222
  readonly,
225
223
  disabled,
226
224
  required,
227
- idSchema,
225
+ fieldPathId,
228
226
  uiSchema,
229
227
  errorSchema,
230
228
  schema,
231
229
  formData,
232
230
  formContext,
233
231
  registry,
232
+ optionalDataControl,
233
+ className: renderOptionalField ? 'rjsf-optional-object-field' : undefined,
234
234
  };
235
235
  return _jsx(Template, { ...templateProps, onAddClick: this.handleAddClick });
236
236
  }
@@ -0,0 +1,8 @@
1
+ import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ /** The `OptionalDataControlsField` component is used to render the optional data controls for the field associated
3
+ * with the given props.
4
+ *
5
+ * @param props - The `FieldProps` for this template
6
+ */
7
+ export default function OptionalDataControlsField<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: FieldProps<T, S, F>): "" | import("react/jsx-runtime").JSX.Element | undefined;
8
+ //# sourceMappingURL=OptionalDataControlsField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OptionalDataControlsField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/OptionalDataControlsField.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EAOf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,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,4DA4D3B"}
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { getSchemaType, getTemplate, getUiOptions, isFormDataAvailable, optionalControlsId, TranslatableString, } from '@rjsf/utils';
3
+ /** The `OptionalDataControlsField` component is used to render the optional data controls for the field associated
4
+ * with the given props.
5
+ *
6
+ * @param props - The `FieldProps` for this template
7
+ */
8
+ export default function OptionalDataControlsField(props) {
9
+ const { schema, uiSchema = {}, formData, disabled = false, readonly = false, onChange, errorSchema, fieldPathId, registry, } = props;
10
+ const { globalUiOptions = {}, schemaUtils, translateString } = registry;
11
+ const uiOptions = getUiOptions(uiSchema, globalUiOptions);
12
+ const OptionalDataControlsTemplate = getTemplate('OptionalDataControlsTemplate', registry, uiOptions);
13
+ const hasFormData = isFormDataAvailable(formData);
14
+ let id;
15
+ let label;
16
+ let onAddClick;
17
+ let onRemoveClick;
18
+ if (disabled || readonly) {
19
+ id = optionalControlsId(fieldPathId, 'Msg');
20
+ label = hasFormData ? undefined : translateString(TranslatableString.OptionalObjectEmptyMsg);
21
+ }
22
+ else {
23
+ const labelEnum = hasFormData ? TranslatableString.OptionalObjectRemove : TranslatableString.OptionalObjectAdd;
24
+ label = translateString(labelEnum);
25
+ if (hasFormData) {
26
+ id = optionalControlsId(fieldPathId, 'Remove');
27
+ onRemoveClick = () => onChange(undefined, fieldPathId.path, errorSchema);
28
+ }
29
+ else {
30
+ id = optionalControlsId(fieldPathId, 'Add');
31
+ onAddClick = () => {
32
+ // If it has form data, store an empty object, otherwise get the default form state and use it
33
+ let newFormData = schemaUtils.getDefaultFormState(schema, formData, 'excludeObjectChildren');
34
+ if (newFormData === undefined) {
35
+ // If new form data ended up being undefined, and we have pushed the add button we need to actually add data
36
+ newFormData = getSchemaType(schema) === 'array' ? [] : {};
37
+ }
38
+ onChange(newFormData, fieldPathId.path, errorSchema);
39
+ };
40
+ }
41
+ }
42
+ return (label && (_jsx(OptionalDataControlsTemplate, { id: id, registry: registry, schema: schema, uiSchema: uiSchema, label: label, onAddClick: onAddClick, onRemoveClick: onRemoveClick })));
43
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAiB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAKL,UAAU,EAEV,eAAe,EAQf,UAAU,EACV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;AA6TrB;;GAEG;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,CACpB;IACC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAI9D,MAAM;CAGP;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"SchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/SchemaField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAiB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAML,UAAU,EAEV,eAAe,EAMf,UAAU,EAEV,gBAAgB,EAIjB,MAAM,aAAa,CAAC;AAkTrB;;GAEG;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,CACpB;IACC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAS9D,MAAM;CAGP;AAED,eAAe,WAAW,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, Component } from 'react';
3
- import { ADDITIONAL_PROPERTY_FLAG, deepEquals, descriptionId, getSchemaType, getTemplate, getUiOptions, ID_KEY, mergeObjects, TranslatableString, UI_OPTIONS_KEY, } from '@rjsf/utils';
3
+ import { ADDITIONAL_PROPERTY_FLAG, descriptionId, getSchemaType, getTemplate, getUiOptions, ID_KEY, shouldRender, TranslatableString, UI_OPTIONS_KEY, } from '@rjsf/utils';
4
4
  import isObject from 'lodash-es/isObject.js';
5
5
  import omit from 'lodash-es/omit.js';
6
6
  /** The map of component type to FieldName */
@@ -19,11 +19,11 @@ const COMPONENT_TYPES = {
19
19
  *
20
20
  * @param schema - The schema from which to obtain the type
21
21
  * @param uiOptions - The UI Options that may affect the component decision
22
- * @param idSchema - The id that is passed to the `UnsupportedFieldTemplate`
22
+ * @param fieldPathId - The id that is passed to the `UnsupportedFieldTemplate`
23
23
  * @param registry - The registry from which fields and templates are obtained
24
24
  * @returns - The `Field` component that is used to render the actual field data
25
25
  */
26
- function getFieldComponent(schema, uiOptions, idSchema, registry) {
26
+ function getFieldComponent(schema, uiOptions, fieldPathId, registry) {
27
27
  const field = uiOptions.field;
28
28
  const { fields, translateString } = registry;
29
29
  if (typeof field === 'function') {
@@ -48,7 +48,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
48
48
  ? fields[componentName]
49
49
  : () => {
50
50
  const UnsupportedFieldTemplate = getTemplate('UnsupportedFieldTemplate', registry, uiOptions);
51
- return (_jsx(UnsupportedFieldTemplate, { schema: schema, idSchema: idSchema, reason: translateString(TranslatableString.UnknownFieldType, [String(schema.type)]), registry: registry }));
51
+ return (_jsx(UnsupportedFieldTemplate, { schema: schema, fieldPathId: fieldPathId, reason: translateString(TranslatableString.UnknownFieldType, [String(schema.type)]), registry: registry }));
52
52
  };
53
53
  }
54
54
  /** The `SchemaFieldRender` component is the work-horse of react-jsonschema-form, determining what kind of real field to
@@ -58,7 +58,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
58
58
  * @param props - The `FieldProps` for this component
59
59
  */
60
60
  function SchemaFieldRender(props) {
61
- const { schema: _schema, idSchema: _idSchema, uiSchema, formData, errorSchema, idPrefix, idSeparator, name, onChange, onKeyChange, onDropPropertyClick, required, registry, wasPropertyKeyModified = false, } = props;
61
+ const { schema: _schema, fieldPathId, uiSchema, formData, errorSchema, name, onChange, onKeyChange, onDropPropertyClick, required, registry, wasPropertyKeyModified = false, } = props;
62
62
  const { formContext, schemaUtils, globalUiOptions } = registry;
63
63
  const uiOptions = getUiOptions(uiSchema, globalUiOptions);
64
64
  const FieldTemplate = getTemplate('FieldTemplate', registry, uiOptions);
@@ -66,16 +66,15 @@ function SchemaFieldRender(props) {
66
66
  const FieldHelpTemplate = getTemplate('FieldHelpTemplate', registry, uiOptions);
67
67
  const FieldErrorTemplate = getTemplate('FieldErrorTemplate', registry, uiOptions);
68
68
  const schema = schemaUtils.retrieveSchema(_schema, formData);
69
- const fieldId = _idSchema[ID_KEY];
70
- const idSchema = mergeObjects(schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator), _idSchema);
69
+ const fieldId = fieldPathId[ID_KEY];
71
70
  /** Intermediary `onChange` handler for field components that will inject the `id` of the current field into the
72
71
  * `onChange` chain if it is not already being provided from a deeper level in the hierarchy
73
72
  */
74
- const handleFieldComponentChange = useCallback((formData, newErrorSchema, id) => {
73
+ const handleFieldComponentChange = useCallback((formData, path, newErrorSchema, id) => {
75
74
  const theId = id || fieldId;
76
- return onChange(formData, newErrorSchema, theId);
75
+ return onChange(formData, path, newErrorSchema, theId);
77
76
  }, [fieldId, onChange]);
78
- const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
77
+ const FieldComponent = getFieldComponent(schema, uiOptions, fieldPathId, registry);
79
78
  const disabled = Boolean(uiOptions.disabled ?? props.disabled);
80
79
  const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
81
80
  const uiSchemaHideError = uiOptions.hideError;
@@ -92,8 +91,8 @@ function SchemaFieldRender(props) {
92
91
  if (UI_OPTIONS_KEY in fieldUiSchema) {
93
92
  fieldUiSchema[UI_OPTIONS_KEY] = omit(fieldUiSchema[UI_OPTIONS_KEY], ['classNames', 'style']);
94
93
  }
95
- const field = (_jsx(FieldComponent, { ...props, onChange: handleFieldComponentChange, idSchema: idSchema, schema: schema, uiSchema: fieldUiSchema, disabled: disabled, readonly: readonly, hideError: hideError, autofocus: autofocus, errorSchema: fieldErrorSchema, formContext: formContext, rawErrors: __errors }));
96
- const id = idSchema[ID_KEY];
94
+ const field = (_jsx(FieldComponent, { ...props, onChange: handleFieldComponentChange, fieldPathId: fieldPathId, schema: schema, uiSchema: fieldUiSchema, disabled: disabled, readonly: readonly, hideError: hideError, autofocus: autofocus, errorSchema: fieldErrorSchema, formContext: formContext, rawErrors: __errors }));
95
+ const id = fieldPathId[ID_KEY];
97
96
  // If this schema has a title defined, but the user has set a new key/label, retain their input.
98
97
  let label;
99
98
  if (wasPropertyKeyModified) {
@@ -115,12 +114,12 @@ function SchemaFieldRender(props) {
115
114
  if (uiOptions.classNames) {
116
115
  classNames.push(uiOptions.classNames);
117
116
  }
118
- const helpComponent = (_jsx(FieldHelpTemplate, { help: help, idSchema: idSchema, schema: schema, uiSchema: uiSchema, hasErrors: !hideError && __errors && __errors.length > 0, registry: registry }));
117
+ const helpComponent = (_jsx(FieldHelpTemplate, { help: help, fieldPathId: fieldPathId, schema: schema, uiSchema: uiSchema, hasErrors: !hideError && __errors && __errors.length > 0, registry: registry }));
119
118
  /*
120
119
  * AnyOf/OneOf errors handled by child schema
121
120
  * unless it can be rendered as select control
122
121
  */
123
- const errorsComponent = hideError || ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema)) ? undefined : (_jsx(FieldErrorTemplate, { errors: __errors, errorSchema: errorSchema, idSchema: idSchema, schema: schema, uiSchema: uiSchema, registry: registry }));
122
+ const errorsComponent = hideError || ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema)) ? undefined : (_jsx(FieldErrorTemplate, { errors: __errors, errorSchema: errorSchema, fieldPathId: fieldPathId, schema: schema, uiSchema: uiSchema, registry: registry }));
124
123
  const fieldProps = {
125
124
  description: (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })),
126
125
  rawDescription: description,
@@ -141,7 +140,6 @@ function SchemaFieldRender(props) {
141
140
  displayLabel,
142
141
  classNames: classNames.join(' ').trim(),
143
142
  style: uiOptions.style,
144
- formContext,
145
143
  formData,
146
144
  schema,
147
145
  uiSchema,
@@ -150,14 +148,16 @@ function SchemaFieldRender(props) {
150
148
  const _AnyOfField = registry.fields.AnyOfField;
151
149
  const _OneOfField = registry.fields.OneOfField;
152
150
  const isReplacingAnyOrOneOf = uiSchema?.['ui:field'] && uiSchema?.['ui:fieldReplacesAnyOrOneOf'] === true;
153
- return (_jsx(FieldTemplate, { ...fieldProps, children: _jsxs(_Fragment, { children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_AnyOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, idPrefix: idPrefix, idSchema: idSchema, idSeparator: idSeparator, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.anyOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, required: required, schema: schema, uiSchema: uiSchema })), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_OneOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, idPrefix: idPrefix, idSchema: idSchema, idSeparator: idSeparator, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.oneOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, required: required, schema: schema, uiSchema: uiSchema }))] }) }));
151
+ return (_jsx(FieldTemplate, { ...fieldProps, children: _jsxs(_Fragment, { children: [field, schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_AnyOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, fieldPathId: fieldPathId, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.anyOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, required: required, schema: schema, uiSchema: uiSchema })), schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && (_jsx(_OneOfField, { name: name, disabled: disabled, readonly: readonly, hideError: hideError, errorSchema: errorSchema, formData: formData, formContext: formContext, fieldPathId: fieldPathId, onBlur: props.onBlur, onChange: props.onChange, onFocus: props.onFocus, options: schema.oneOf.map((_schema) => schemaUtils.retrieveSchema(isObject(_schema) ? _schema : {}, formData)), registry: registry, required: required, schema: schema, uiSchema: uiSchema }))] }) }));
154
152
  }
155
153
  /** The `SchemaField` component determines whether it is necessary to rerender the component based on any props changes
156
154
  * and if so, calls the `SchemaFieldRender` component with the props.
157
155
  */
158
156
  class SchemaField extends Component {
159
157
  shouldComponentUpdate(nextProps) {
160
- return !deepEquals(this.props, nextProps);
158
+ const { registry: { globalFormOptions }, } = this.props;
159
+ const { experimental_componentUpdateStrategy = 'customDeep' } = globalFormOptions;
160
+ return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
161
161
  }
162
162
  render() {
163
163
  return _jsx(SchemaFieldRender, { ...this.props });
@@ -1 +1 @@
1
- {"version":3,"file":"StringField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAErB;;;GAGG;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,2CAsD3B;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"StringField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/StringField.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,UAAU,EACV,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;GAGG;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,2CA6D3B;AAED,eAAe,WAAW,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback } from 'react';
2
3
  import { getWidget, getUiOptions, optionsList, hasWidget, } from '@rjsf/utils';
3
4
  /** The `StringField` component is used to render a schema field that represents a string type
4
5
  *
5
6
  * @param props - The `FieldProps` for this template
6
7
  */
7
8
  function StringField(props) {
8
- const { schema, name, uiSchema, idSchema, formData, required, disabled = false, readonly = false, autofocus = false, onChange, onBlur, onFocus, registry, rawErrors, hideError, } = props;
9
+ const { schema, name, uiSchema, fieldPathId, formData, required, disabled = false, readonly = false, autofocus = false, onChange, onBlur, onFocus, registry, rawErrors, hideError, } = props;
9
10
  const { title, format } = schema;
10
11
  const { widgets, formContext, schemaUtils, globalUiOptions } = registry;
11
12
  const enumOptions = schemaUtils.isSelect(schema) ? optionsList(schema, uiSchema) : undefined;
@@ -17,6 +18,10 @@ function StringField(props) {
17
18
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
18
19
  const label = uiTitle ?? title ?? name;
19
20
  const Widget = getWidget(schema, widget, widgets);
20
- return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: idSchema.$id, name: name, label: label, hideLabel: !displayLabel, hideError: hideError, value: formData, onChange: onChange, onBlur: onBlur, onFocus: onFocus, required: required, disabled: disabled, readonly: readonly, formContext: formContext, autofocus: autofocus, registry: registry, placeholder: placeholder, rawErrors: rawErrors }));
21
+ const onWidgetChange = useCallback((value, errorSchema, id) => {
22
+ // String field change passes an empty path array to the parent field which adds the appropriate path
23
+ return onChange(value, fieldPathId.path, errorSchema, id);
24
+ }, [onChange, fieldPathId]);
25
+ return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: fieldPathId.$id, name: name, label: label, hideLabel: !displayLabel, hideError: hideError, value: formData, onChange: onWidgetChange, onBlur: onBlur, onFocus: onFocus, required: required, disabled: disabled, readonly: readonly, formContext: formContext, autofocus: autofocus, registry: registry, placeholder: placeholder, rawErrors: rawErrors }));
21
26
  }
22
27
  export default StringField;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAcvG,iBAAS,MAAM,CACb,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAgB/B;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAevG,iBAAS,MAAM,CACb,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,KAC5B,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAiB/B;AAED,eAAe,MAAM,CAAC"}
@@ -6,6 +6,7 @@ import LayoutMultiSchemaField from './LayoutMultiSchemaField.js';
6
6
  import MultiSchemaField from './MultiSchemaField.js';
7
7
  import NumberField from './NumberField.js';
8
8
  import ObjectField from './ObjectField.js';
9
+ import OptionalDataControlsField from './OptionalDataControlsField.js';
9
10
  import SchemaField from './SchemaField.js';
10
11
  import StringField from './StringField.js';
11
12
  import NullField from './NullField.js';
@@ -21,6 +22,7 @@ function fields() {
21
22
  NumberField,
22
23
  ObjectField,
23
24
  OneOfField: MultiSchemaField,
25
+ OptionalDataControlsField,
24
26
  SchemaField,
25
27
  StringField,
26
28
  NullField,
@@ -1,6 +1,6 @@
1
1
  import { ArrayFieldDescriptionProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
  /** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
3
- * the `idSchema`.
3
+ * the `fieldPathId`.
4
4
  *
5
5
  * @param props - The `ArrayFieldDescriptionProps` for the component
6
6
  */
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { descriptionId, getTemplate, getUiOptions, } from '@rjsf/utils';
3
3
  /** The `ArrayFieldDescriptionTemplate` component renders a `DescriptionFieldTemplate` with an `id` derived from
4
- * the `idSchema`.
4
+ * the `fieldPathId`.
5
5
  *
6
6
  * @param props - The `ArrayFieldDescriptionProps` for the component
7
7
  */
8
8
  export default function ArrayFieldDescriptionTemplate(props) {
9
- const { idSchema, description, registry, schema, uiSchema } = props;
9
+ const { fieldPathId, description, registry, schema, uiSchema } = props;
10
10
  const options = getUiOptions(uiSchema, registry.globalUiOptions);
11
11
  const { label: displayLabel = true } = options;
12
12
  if (!description || !displayLabel) {
13
13
  return null;
14
14
  }
15
15
  const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
16
- return (_jsx(DescriptionFieldTemplate, { id: descriptionId(idSchema), description: description, schema: schema, uiSchema: uiSchema, registry: registry }));
16
+ return (_jsx(DescriptionFieldTemplate, { id: descriptionId(fieldPathId), description: description, schema: schema, uiSchema: uiSchema, registry: registry }));
17
17
  }
@@ -7,11 +7,11 @@ import { buttonId, } from '@rjsf/utils';
7
7
  * @param props - The `ArrayFieldItemButtonsTemplateType` props for the component
8
8
  */
9
9
  export default function ArrayFieldItemButtonsTemplate(props) {
10
- const { disabled, hasCopy, hasMoveDown, hasMoveUp, hasRemove, idSchema, index, onCopyIndexClick, onDropIndexClick, onReorderClick, readonly, registry, uiSchema, } = props;
10
+ const { disabled, hasCopy, hasMoveDown, hasMoveUp, hasRemove, fieldPathId, index, onCopyIndexClick, onDropIndexClick, onReorderClick, readonly, registry, uiSchema, } = props;
11
11
  const { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } = registry.templates.ButtonTemplates;
12
12
  const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
13
13
  const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
14
14
  const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
15
15
  const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
16
- return (_jsxs(_Fragment, { children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { id: buttonId(idSchema, 'moveUp'), className: 'rjsf-array-item-move-up', disabled: disabled || readonly || !hasMoveUp, onClick: onArrowUpClick, uiSchema: uiSchema, registry: registry })), (hasMoveUp || hasMoveDown) && (_jsx(MoveDownButton, { id: buttonId(idSchema, 'moveDown'), className: 'rjsf-array-item-move-down', disabled: disabled || readonly || !hasMoveDown, onClick: onArrowDownClick, uiSchema: uiSchema, registry: registry })), hasCopy && (_jsx(CopyButton, { id: buttonId(idSchema, 'copy'), className: 'rjsf-array-item-copy', disabled: disabled || readonly, onClick: onCopyClick, uiSchema: uiSchema, registry: registry })), hasRemove && (_jsx(RemoveButton, { id: buttonId(idSchema, 'remove'), className: 'rjsf-array-item-remove', disabled: disabled || readonly, onClick: onRemoveClick, uiSchema: uiSchema, registry: registry }))] }));
16
+ return (_jsxs(_Fragment, { children: [(hasMoveUp || hasMoveDown) && (_jsx(MoveUpButton, { id: buttonId(fieldPathId, 'moveUp'), className: 'rjsf-array-item-move-up', disabled: disabled || readonly || !hasMoveUp, onClick: onArrowUpClick, uiSchema: uiSchema, registry: registry })), (hasMoveUp || hasMoveDown) && (_jsx(MoveDownButton, { id: buttonId(fieldPathId, 'moveDown'), className: 'rjsf-array-item-move-down', disabled: disabled || readonly || !hasMoveDown, onClick: onArrowDownClick, uiSchema: uiSchema, registry: registry })), hasCopy && (_jsx(CopyButton, { id: buttonId(fieldPathId, 'copy'), className: 'rjsf-array-item-copy', disabled: disabled || readonly, onClick: onCopyClick, uiSchema: uiSchema, registry: registry })), hasRemove && (_jsx(RemoveButton, { id: buttonId(fieldPathId, 'remove'), className: 'rjsf-array-item-remove', disabled: disabled || readonly, onClick: onRemoveClick, uiSchema: uiSchema, registry: registry }))] }));
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ArrayFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EAEvB,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsExC"}
1
+ {"version":3,"file":"ArrayFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EAEvB,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA0ExC"}
@@ -5,13 +5,14 @@ import { getTemplate, getUiOptions, buttonId, } from '@rjsf/utils';
5
5
  * @param props - The `ArrayFieldItemTemplateType` props for the component
6
6
  */
7
7
  export default function ArrayFieldTemplate(props) {
8
- const { canAdd, className, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title, } = props;
8
+ const { canAdd, className, disabled, fieldPathId, uiSchema, items, optionalDataControl, onAddClick, readonly, registry, required, schema, title, } = props;
9
9
  const uiOptions = getUiOptions(uiSchema);
10
10
  const ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
11
11
  const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
12
12
  const ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
13
13
  // Button templates are not overridden in the uiSchema
14
+ const showOptionalDataControlInTitle = !readonly && !disabled;
14
15
  const { ButtonTemplates: { AddButton }, } = registry.templates;
15
- return (_jsxs("fieldset", { className: className, id: idSchema.$id, children: [_jsx(ArrayFieldTitleTemplate, { idSchema: idSchema, title: uiOptions.title || title, required: required, schema: schema, uiSchema: uiSchema, registry: registry }), _jsx(ArrayFieldDescriptionTemplate, { idSchema: idSchema, description: uiOptions.description || schema.description, schema: schema, uiSchema: uiSchema, registry: registry }), _jsx("div", { className: 'row array-item-list', children: items &&
16
- items.map(({ key, ...itemProps }) => (_jsx(ArrayFieldItemTemplate, { ...itemProps }, key))) }), canAdd && (_jsx(AddButton, { id: buttonId(idSchema, 'add'), className: 'rjsf-array-item-add', onClick: onAddClick, disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }))] }));
16
+ return (_jsxs("fieldset", { className: className, id: fieldPathId.$id, children: [_jsx(ArrayFieldTitleTemplate, { fieldPathId: fieldPathId, title: uiOptions.title || title, required: required, schema: schema, uiSchema: uiSchema, registry: registry, optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : undefined }), _jsx(ArrayFieldDescriptionTemplate, { fieldPathId: fieldPathId, description: uiOptions.description || schema.description, schema: schema, uiSchema: uiSchema, registry: registry }), !showOptionalDataControlInTitle ? optionalDataControl : undefined, _jsx("div", { className: 'row array-item-list', children: items &&
17
+ items.map(({ key, ...itemProps }) => (_jsx(ArrayFieldItemTemplate, { ...itemProps }, key))) }), canAdd && (_jsx(AddButton, { id: buttonId(fieldPathId, 'add'), className: 'rjsf-array-item-add', onClick: onAddClick, disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }))] }));
17
18
  }
@@ -1,6 +1,6 @@
1
1
  import { ArrayFieldTitleProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
  /** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
3
- * the `idSchema`.
3
+ * the `fieldPathId`.
4
4
  *
5
5
  * @param props - The `ArrayFieldTitleProps` for the component
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ArrayFieldTitleTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTitleTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDAsBrC"}
1
+ {"version":3,"file":"ArrayFieldTitleTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ArrayFieldTitleTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDAuBrC"}
@@ -1,17 +1,17 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { getTemplate, getUiOptions, titleId, } from '@rjsf/utils';
3
3
  /** The `ArrayFieldTitleTemplate` component renders a `TitleFieldTemplate` with an `id` derived from
4
- * the `idSchema`.
4
+ * the `fieldPathId`.
5
5
  *
6
6
  * @param props - The `ArrayFieldTitleProps` for the component
7
7
  */
8
8
  export default function ArrayFieldTitleTemplate(props) {
9
- const { idSchema, title, schema, uiSchema, required, registry } = props;
9
+ const { fieldPathId, title, schema, uiSchema, required, registry, optionalDataControl } = props;
10
10
  const options = getUiOptions(uiSchema, registry.globalUiOptions);
11
11
  const { label: displayLabel = true } = options;
12
12
  if (!title || !displayLabel) {
13
13
  return null;
14
14
  }
15
15
  const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
16
- return (_jsx(TitleFieldTemplate, { id: titleId(idSchema), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry }));
16
+ return (_jsx(TitleFieldTemplate, { id: titleId(fieldPathId), title: title, required: required, schema: schema, uiSchema: uiSchema, registry: registry, optionalDataControl: optionalDataControl }));
17
17
  }
@@ -1,5 +1,5 @@
1
1
  import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
2
  /** The `AddButton` renders a button that represent the `Add` action on a form
3
3
  */
4
- export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ className, onClick, disabled, registry, }: IconButtonProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
4
+ export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ id, className, onClick, disabled, registry, }: IconButtonProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
5
5
  //# sourceMappingURL=AddButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AddButton.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/ButtonTemplates/AddButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAsB,MAAM,aAAa,CAAC;AAIjH;GACG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACnH,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAiB1B"}
1
+ {"version":3,"file":"AddButton.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/ButtonTemplates/AddButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAsB,MAAM,aAAa,CAAC;AAIjH;GACG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAAE,EACnH,EAAE,EACF,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkB1B"}
@@ -3,7 +3,7 @@ import { TranslatableString } from '@rjsf/utils';
3
3
  import IconButton from './IconButton.js';
4
4
  /** The `AddButton` renders a button that represent the `Add` action on a form
5
5
  */
6
- export default function AddButton({ className, onClick, disabled, registry, }) {
6
+ export default function AddButton({ id, className, onClick, disabled, registry, }) {
7
7
  const { translateString } = registry;
8
- return (_jsx("div", { className: 'row', children: _jsx("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: _jsx(IconButton, { iconType: 'info', icon: 'plus', className: 'btn-add col-xs-12', title: translateString(TranslatableString.AddButton), onClick: onClick, disabled: disabled, registry: registry }) }) }));
8
+ return (_jsx("div", { className: 'row', children: _jsx("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: _jsx(IconButton, { id: id, iconType: 'info', icon: 'plus', className: 'btn-add col-xs-12', title: translateString(TranslatableString.AddButton), onClick: onClick, disabled: disabled, registry: registry }) }) }));
9
9
  }
@@ -5,11 +5,11 @@ import { errorId } from '@rjsf/utils';
5
5
  * @param props - The `FieldErrorProps` for the errors being rendered
6
6
  */
7
7
  export default function FieldErrorTemplate(props) {
8
- const { errors = [], idSchema } = props;
8
+ const { errors = [], fieldPathId } = props;
9
9
  if (errors.length === 0) {
10
10
  return null;
11
11
  }
12
- const id = errorId(idSchema);
12
+ const id = errorId(fieldPathId);
13
13
  return (_jsx("div", { children: _jsx("ul", { id: id, className: 'error-detail bs-callout bs-callout-info', children: errors
14
14
  .filter((elem) => !!elem)
15
15
  .map((error, index) => {
@@ -5,11 +5,11 @@ import { helpId } from '@rjsf/utils';
5
5
  * @param props - The `FieldHelpProps` to be rendered
6
6
  */
7
7
  export default function FieldHelpTemplate(props) {
8
- const { idSchema, help } = props;
8
+ const { fieldPathId, help } = props;
9
9
  if (!help) {
10
10
  return null;
11
11
  }
12
- const id = helpId(idSchema);
12
+ const id = helpId(fieldPathId);
13
13
  if (typeof help === 'string') {
14
14
  return (_jsx("p", { id: id, className: 'help-block', children: help }));
15
15
  }
@@ -0,0 +1,8 @@
1
+ import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ /** The `MultiSchemaFieldTemplate` component renders the layout for the MultiSchemaField, which supports choosing
3
+ * a schema from a list of schemas defined using `anyOf` or `oneOf`.
4
+ *
5
+ * @param props - The `MultiSchemaFieldTemplate` to be rendered
6
+ */
7
+ export default function MultiSchemaFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: MultiSchemaFieldTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=MultiSchemaFieldTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiSchemaFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/MultiSchemaFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE3G;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAQ9C"}
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /** The `MultiSchemaFieldTemplate` component renders the layout for the MultiSchemaField, which supports choosing
3
+ * a schema from a list of schemas defined using `anyOf` or `oneOf`.
4
+ *
5
+ * @param props - The `MultiSchemaFieldTemplate` to be rendered
6
+ */
7
+ export default function MultiSchemaFieldTemplate(props) {
8
+ const { selector, optionSchemaField } = props;
9
+ return (_jsxs("div", { className: 'panel panel-default panel-body', children: [_jsx("div", { className: 'form-group', children: selector }), optionSchemaField] }));
10
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ObjectFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAOjB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA4DzC"}
1
+ {"version":3,"file":"ObjectFieldTemplate.d.ts","sourceRoot":"","sources":["../../../src/components/templates/ObjectFieldTemplate.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAOjB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAiEzC"}