@rjsf/core 6.6.1 → 6.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.umd.js +454 -373
- package/dist/index.cjs +416 -334
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +418 -415
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts +14 -11
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +97 -62
- package/lib/components/RichDescription.d.ts +2 -2
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.d.ts +2 -2
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/SchemaExamples.d.ts +1 -1
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/SchemaExamples.js +1 -3
- package/lib/components/fields/ArrayField.d.ts +1 -1
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +87 -88
- package/lib/components/fields/BooleanField.d.ts +1 -1
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -5
- package/lib/components/fields/FallbackField.d.ts +1 -1
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/FallbackField.js +2 -2
- package/lib/components/fields/LayoutGridField.d.ts +7 -9
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +5 -4
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
- package/lib/components/fields/LayoutHeaderField.js +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +4 -1
- package/lib/components/fields/MultiSchemaField.d.ts +9 -3
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +27 -9
- package/lib/components/fields/NullField.d.ts +1 -1
- package/lib/components/fields/NullField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.d.ts +1 -1
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +7 -9
- package/lib/components/fields/ObjectField.d.ts +1 -1
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +27 -25
- package/lib/components/fields/OptionalDataControlsField.d.ts +1 -1
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +1 -1
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +7 -7
- package/lib/components/fields/StringField.d.ts +1 -1
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +2 -5
- package/lib/components/fields/index.d.ts +1 -1
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +7 -6
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +14 -7
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js +14 -6
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
- package/lib/components/templates/DescriptionField.d.ts +1 -1
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +1 -1
- package/lib/components/templates/ErrorList.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.js +2 -4
- package/lib/components/templates/FallbackFieldTemplate.d.ts +1 -1
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.js +1 -3
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts +2 -2
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +1 -1
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.js +1 -1
- package/lib/components/templates/TitleField.d.ts +1 -1
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -1
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
- package/lib/components/templates/index.d.ts +1 -1
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +2 -2
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/components/widgets/ColorWidget.d.ts +1 -1
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.js +2 -2
- package/lib/components/widgets/DateWidget.d.ts +1 -1
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -1
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -1
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.js +6 -4
- package/lib/components/widgets/HiddenWidget.d.ts +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -1
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +2 -2
- package/lib/components/widgets/RangeWidget.d.ts +1 -1
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +1 -1
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.js +15 -15
- package/lib/components/widgets/SelectWidget.d.ts +1 -1
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +4 -4
- package/lib/components/widgets/TextWidget.d.ts +1 -1
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +2 -2
- package/lib/components/widgets/TimeWidget.d.ts +1 -1
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -1
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
- package/lib/components/widgets/index.d.ts +1 -1
- package/lib/components/widgets/index.d.ts.map +1 -1
- package/lib/getDefaultRegistry.d.ts +1 -1
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +1 -1
- package/lib/getTestRegistry.d.ts +1 -1
- package/lib/getTestRegistry.d.ts.map +1 -1
- package/lib/getTestRegistry.js +1 -1
- package/lib/index.d.ts +10 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +3 -3
- package/lib/withTheme.d.ts.map +1 -1
- package/lib/withTheme.js +6 -6
- package/package.json +5 -6
- package/src/components/Form.tsx +164 -97
- package/src/components/RichDescription.tsx +3 -10
- package/src/components/RichHelp.tsx +3 -10
- package/src/components/SchemaExamples.tsx +6 -4
- package/src/components/fields/ArrayField.tsx +122 -108
- package/src/components/fields/BooleanField.tsx +4 -9
- package/src/components/fields/FallbackField.tsx +4 -8
- package/src/components/fields/LayoutGridField.tsx +21 -19
- package/src/components/fields/LayoutHeaderField.tsx +2 -10
- package/src/components/fields/LayoutMultiSchemaField.tsx +15 -10
- package/src/components/fields/MultiSchemaField.tsx +29 -16
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +8 -10
- package/src/components/fields/ObjectField.tsx +48 -39
- package/src/components/fields/OptionalDataControlsField.tsx +6 -4
- package/src/components/fields/SchemaField.tsx +22 -19
- package/src/components/fields/StringField.tsx +4 -15
- package/src/components/fields/index.ts +1 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +2 -7
- package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -9
- package/src/components/templates/ArrayFieldTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -10
- package/src/components/templates/BaseInputTemplate.tsx +15 -19
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/IconButton.tsx +16 -7
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/DescriptionField.tsx +1 -1
- package/src/components/templates/ErrorList.tsx +8 -15
- package/src/components/templates/FallbackFieldTemplate.tsx +2 -1
- package/src/components/templates/FieldErrorTemplate.tsx +8 -8
- package/src/components/templates/FieldHelpTemplate.tsx +2 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/components/templates/FieldTemplate/Label.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +1 -1
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/components/templates/ObjectFieldTemplate.tsx +2 -7
- package/src/components/templates/OptionalDataControlsTemplate.tsx +3 -2
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +3 -2
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/templates/index.ts +1 -1
- package/src/components/widgets/AltDateTimeWidget.tsx +1 -1
- package/src/components/widgets/AltDateWidget.tsx +7 -13
- package/src/components/widgets/CheckboxWidget.tsx +3 -5
- package/src/components/widgets/CheckboxesWidget.tsx +6 -8
- package/src/components/widgets/ColorWidget.tsx +2 -1
- package/src/components/widgets/DateTimeWidget.tsx +3 -10
- package/src/components/widgets/DateWidget.tsx +2 -1
- package/src/components/widgets/EmailWidget.tsx +2 -1
- package/src/components/widgets/FileWidget.tsx +9 -8
- package/src/components/widgets/HiddenWidget.tsx +1 -1
- package/src/components/widgets/PasswordWidget.tsx +2 -1
- package/src/components/widgets/RadioWidget.tsx +6 -8
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +48 -47
- package/src/components/widgets/SelectWidget.tsx +12 -10
- package/src/components/widgets/TextWidget.tsx +2 -1
- package/src/components/widgets/TextareaWidget.tsx +7 -4
- package/src/components/widgets/TimeWidget.tsx +2 -1
- package/src/components/widgets/URLWidget.tsx +2 -1
- package/src/components/widgets/UpDownWidget.tsx +2 -1
- package/src/components/widgets/index.ts +1 -1
- package/src/getDefaultRegistry.ts +2 -9
- package/src/getTestRegistry.tsx +2 -7
- package/src/index.ts +10 -5
- package/src/withTheme.tsx +14 -9
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
43
|
// src/components/Form.tsx
|
|
44
|
-
var
|
|
44
|
+
var import_react27 = require("react");
|
|
45
45
|
var import_utils50 = require("@rjsf/utils");
|
|
46
46
|
var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"), 1);
|
|
47
47
|
var import_get5 = __toESM(require("lodash/get"), 1);
|
|
@@ -66,12 +66,10 @@ function generateRowId() {
|
|
|
66
66
|
return (0, import_uniqueId.default)("rjsf-array-item-");
|
|
67
67
|
}
|
|
68
68
|
function generateKeyedFormData(formData) {
|
|
69
|
-
return !Array.isArray(formData) ? [] : formData.map((item) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
});
|
|
69
|
+
return !Array.isArray(formData) ? [] : formData.map((item) => ({
|
|
70
|
+
key: generateRowId(),
|
|
71
|
+
item
|
|
72
|
+
}));
|
|
75
73
|
}
|
|
76
74
|
function keyedToPlainFormData(keyedFormData) {
|
|
77
75
|
if (Array.isArray(keyedFormData)) {
|
|
@@ -272,7 +270,7 @@ function ArrayAsFiles(props) {
|
|
|
272
270
|
}
|
|
273
271
|
);
|
|
274
272
|
}
|
|
275
|
-
function
|
|
273
|
+
function ArrayFieldItemInner(props) {
|
|
276
274
|
const {
|
|
277
275
|
itemKey,
|
|
278
276
|
index,
|
|
@@ -287,10 +285,10 @@ function ArrayFieldItem(props) {
|
|
|
287
285
|
canRemove = true,
|
|
288
286
|
canMoveUp,
|
|
289
287
|
canMoveDown,
|
|
290
|
-
|
|
288
|
+
rawItemSchema,
|
|
291
289
|
itemData,
|
|
292
290
|
itemUiSchema,
|
|
293
|
-
|
|
291
|
+
parentFieldPathId,
|
|
294
292
|
itemErrorSchema,
|
|
295
293
|
autofocus,
|
|
296
294
|
onBlur,
|
|
@@ -307,9 +305,17 @@ function ArrayFieldItem(props) {
|
|
|
307
305
|
const {
|
|
308
306
|
schemaUtils,
|
|
309
307
|
fields: { ArraySchemaField, SchemaField: SchemaField2 },
|
|
310
|
-
globalUiOptions
|
|
308
|
+
globalUiOptions,
|
|
309
|
+
globalFormOptions
|
|
311
310
|
} = registry;
|
|
312
|
-
const
|
|
311
|
+
const itemSchema = (0, import_react.useMemo)(
|
|
312
|
+
() => schemaUtils.retrieveSchema(rawItemSchema, itemData),
|
|
313
|
+
[schemaUtils, rawItemSchema, itemData]
|
|
314
|
+
);
|
|
315
|
+
const fieldPathId = (0, import_react.useMemo)(
|
|
316
|
+
() => (0, import_utils.toFieldPathId)(index, globalFormOptions, parentFieldPathId),
|
|
317
|
+
[index, globalFormOptions, parentFieldPathId]
|
|
318
|
+
);
|
|
313
319
|
const ItemSchemaField = ArraySchemaField || SchemaField2;
|
|
314
320
|
const ArrayFieldItemTemplate2 = (0, import_utils.getTemplate)(
|
|
315
321
|
"ArrayFieldItemTemplate",
|
|
@@ -418,6 +424,7 @@ function ArrayFieldItem(props) {
|
|
|
418
424
|
};
|
|
419
425
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrayFieldItemTemplate2, { ...templateProps });
|
|
420
426
|
}
|
|
427
|
+
var ArrayFieldItem = (0, import_react.memo)(ArrayFieldItemInner);
|
|
421
428
|
function NormalArray(props) {
|
|
422
429
|
const {
|
|
423
430
|
schema,
|
|
@@ -444,15 +451,18 @@ function NormalArray(props) {
|
|
|
444
451
|
handleReorderItems
|
|
445
452
|
} = props;
|
|
446
453
|
const fieldTitle = schema.title || title || name;
|
|
447
|
-
const { schemaUtils, fields: fields2, formContext,
|
|
454
|
+
const { schemaUtils, fields: fields2, formContext, globalUiOptions } = registry;
|
|
448
455
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
449
|
-
const uiOptions = (0, import_utils.getUiOptions)(uiSchema, globalUiOptions);
|
|
450
|
-
const
|
|
451
|
-
const itemsSchema = schemaUtils.retrieveSchema(
|
|
452
|
-
const formData = keyedToPlainFormData(keyedFormData);
|
|
456
|
+
const uiOptions = (0, import_react.useMemo)(() => (0, import_utils.getUiOptions)(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
457
|
+
const schemaItems = (0, import_react.useMemo)(() => (0, import_isObject.default)(schema.items) ? schema.items : {}, [schema.items]);
|
|
458
|
+
const itemsSchema = (0, import_react.useMemo)(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
|
|
459
|
+
const formData = (0, import_react.useMemo)(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
|
|
453
460
|
const renderOptionalField = (0, import_utils.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
454
461
|
const hasFormData = (0, import_utils.isFormDataAvailable)(formDataFromProps);
|
|
455
|
-
const canAdd =
|
|
462
|
+
const canAdd = (0, import_react.useMemo)(
|
|
463
|
+
() => canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData),
|
|
464
|
+
[registry, schema, formData, uiSchema, renderOptionalField, hasFormData]
|
|
465
|
+
);
|
|
456
466
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
457
467
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
458
468
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
@@ -462,9 +472,7 @@ function NormalArray(props) {
|
|
|
462
472
|
items: actualFormData.map((keyedItem, index) => {
|
|
463
473
|
const { key, item } = keyedItem;
|
|
464
474
|
const itemCast = item;
|
|
465
|
-
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
466
475
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
467
|
-
const itemFieldPathId = (0, import_utils.toFieldPathId)(index, globalFormOptions, childFieldPathId);
|
|
468
476
|
const itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
469
477
|
const itemProps = {
|
|
470
478
|
itemKey: key,
|
|
@@ -481,8 +489,8 @@ function NormalArray(props) {
|
|
|
481
489
|
canAdd,
|
|
482
490
|
canMoveUp: index > 0,
|
|
483
491
|
canMoveDown: index < formData.length - 1,
|
|
484
|
-
|
|
485
|
-
|
|
492
|
+
rawItemSchema: schemaItems,
|
|
493
|
+
parentFieldPathId: childFieldPathId,
|
|
486
494
|
itemErrorSchema,
|
|
487
495
|
itemData: itemCast,
|
|
488
496
|
itemUiSchema,
|
|
@@ -543,24 +551,24 @@ function FixedArray(props) {
|
|
|
543
551
|
} = props;
|
|
544
552
|
let { formData: items = [] } = props;
|
|
545
553
|
const fieldTitle = schema.title || title || name;
|
|
546
|
-
const {
|
|
547
|
-
const uiOptions = (0, import_utils.getUiOptions)(uiSchema, globalUiOptions);
|
|
554
|
+
const { fields: fields2, formContext, globalUiOptions } = registry;
|
|
555
|
+
const uiOptions = (0, import_react.useMemo)(() => (0, import_utils.getUiOptions)(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
548
556
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
549
557
|
const renderOptionalField = (0, import_utils.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
550
558
|
const hasFormData = (0, import_utils.isFormDataAvailable)(formData);
|
|
551
|
-
const
|
|
552
|
-
|
|
553
|
-
|
|
559
|
+
const schemaItems = (0, import_react.useMemo)(
|
|
560
|
+
() => (0, import_isObject.default)(schema.items) ? schema.items : [],
|
|
561
|
+
[schema.items]
|
|
554
562
|
);
|
|
555
|
-
const
|
|
563
|
+
const hasAdditionalItems = (0, import_isObject.default)(schema.additionalItems);
|
|
556
564
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
557
|
-
if (items.length <
|
|
558
|
-
items = items.concat(new Array(
|
|
565
|
+
if (items.length < schemaItems.length) {
|
|
566
|
+
items = items.concat(new Array(schemaItems.length - items.length));
|
|
559
567
|
}
|
|
560
568
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
561
569
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
562
570
|
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OptionalDataControlsField2, { ...props, fieldPathId: childFieldPathId }) : void 0;
|
|
563
|
-
const canAdd = canAddItem(registry, schema, items, uiSchema) &&
|
|
571
|
+
const canAdd = canAddItem(registry, schema, items, uiSchema) && hasAdditionalItems && (!renderOptionalField || hasFormData);
|
|
564
572
|
const arrayProps = {
|
|
565
573
|
canAdd,
|
|
566
574
|
className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
|
|
@@ -570,18 +578,15 @@ function FixedArray(props) {
|
|
|
570
578
|
items: actualFormData.map((keyedItem, index) => {
|
|
571
579
|
const { key, item } = keyedItem;
|
|
572
580
|
const itemCast = item;
|
|
573
|
-
const additional = index >=
|
|
574
|
-
const
|
|
575
|
-
const itemFieldPathId = (0, import_utils.toFieldPathId)(index, globalFormOptions, childFieldPathId);
|
|
581
|
+
const additional = index >= schemaItems.length;
|
|
582
|
+
const rawItemSchema = (additional && (0, import_isObject.default)(schema.additionalItems) ? schema.additionalItems : schemaItems[index]) || {};
|
|
576
583
|
let itemUiSchema;
|
|
577
584
|
if (additional) {
|
|
578
585
|
itemUiSchema = uiSchema.additionalItems;
|
|
586
|
+
} else if (Array.isArray(uiSchema.items)) {
|
|
587
|
+
itemUiSchema = uiSchema.items[index];
|
|
579
588
|
} else {
|
|
580
|
-
|
|
581
|
-
itemUiSchema = uiSchema.items[index];
|
|
582
|
-
} else {
|
|
583
|
-
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
584
|
-
}
|
|
589
|
+
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
585
590
|
}
|
|
586
591
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
587
592
|
const itemProps = {
|
|
@@ -598,12 +603,12 @@ function FixedArray(props) {
|
|
|
598
603
|
title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
|
|
599
604
|
canAdd,
|
|
600
605
|
canRemove: additional,
|
|
601
|
-
canMoveUp: index >=
|
|
606
|
+
canMoveUp: index >= schemaItems.length + 1,
|
|
602
607
|
canMoveDown: additional && index < items.length - 1,
|
|
603
|
-
|
|
608
|
+
rawItemSchema,
|
|
604
609
|
itemData: itemCast,
|
|
605
610
|
itemUiSchema,
|
|
606
|
-
|
|
611
|
+
parentFieldPathId: childFieldPathId,
|
|
607
612
|
itemErrorSchema,
|
|
608
613
|
autofocus: autofocus && index === 0,
|
|
609
614
|
onBlur,
|
|
@@ -651,8 +656,8 @@ function useKeyedFormData(formData = []) {
|
|
|
651
656
|
}
|
|
652
657
|
const updateKeyedFormData = (0, import_react.useCallback)((newData) => {
|
|
653
658
|
const plainFormData = keyedToPlainFormData(newData);
|
|
654
|
-
const
|
|
655
|
-
setState({ formDataHash:
|
|
659
|
+
const updatedHash = (0, import_utils.hashObject)(plainFormData);
|
|
660
|
+
setState({ formDataHash: updatedHash, keyedFormData: newData });
|
|
656
661
|
return plainFormData;
|
|
657
662
|
}, []);
|
|
658
663
|
return { keyedFormData, updateKeyedFormData };
|
|
@@ -661,6 +666,10 @@ function ArrayField(props) {
|
|
|
661
666
|
const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
|
|
662
667
|
const { globalFormOptions, schemaUtils, translateString } = registry;
|
|
663
668
|
const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
|
|
669
|
+
const keyedFormDataRef = (0, import_react.useRef)(keyedFormData);
|
|
670
|
+
keyedFormDataRef.current = keyedFormData;
|
|
671
|
+
const errorSchemaRef = (0, import_react.useRef)(errorSchema);
|
|
672
|
+
errorSchemaRef.current = errorSchema;
|
|
664
673
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
665
674
|
const handleAddItem = (0, import_react.useCallback)(
|
|
666
675
|
(event, index) => {
|
|
@@ -668,14 +677,14 @@ function ArrayField(props) {
|
|
|
668
677
|
event.preventDefault();
|
|
669
678
|
}
|
|
670
679
|
let newErrorSchema;
|
|
671
|
-
if (
|
|
680
|
+
if (errorSchemaRef.current) {
|
|
672
681
|
newErrorSchema = {};
|
|
673
|
-
for (const idx
|
|
674
|
-
const i = parseInt(idx);
|
|
682
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
683
|
+
const i = parseInt(idx, 10);
|
|
675
684
|
if (index === void 0 || i < index) {
|
|
676
|
-
(0, import_set.default)(newErrorSchema, [i],
|
|
685
|
+
(0, import_set.default)(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
677
686
|
} else if (i >= index) {
|
|
678
|
-
(0, import_set.default)(newErrorSchema, [i + 1],
|
|
687
|
+
(0, import_set.default)(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
679
688
|
}
|
|
680
689
|
}
|
|
681
690
|
}
|
|
@@ -683,7 +692,7 @@ function ArrayField(props) {
|
|
|
683
692
|
key: generateRowId(),
|
|
684
693
|
item: getNewFormDataRow(registry, schema)
|
|
685
694
|
};
|
|
686
|
-
const newKeyedFormData = [...
|
|
695
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
687
696
|
if (index !== void 0) {
|
|
688
697
|
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
689
698
|
} else {
|
|
@@ -691,7 +700,7 @@ function ArrayField(props) {
|
|
|
691
700
|
}
|
|
692
701
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
693
702
|
},
|
|
694
|
-
[
|
|
703
|
+
[registry, schema, onChange, updateKeyedFormData, childFieldPathId]
|
|
695
704
|
);
|
|
696
705
|
const handleCopyItem = (0, import_react.useCallback)(
|
|
697
706
|
(event, index) => {
|
|
@@ -699,22 +708,22 @@ function ArrayField(props) {
|
|
|
699
708
|
event.preventDefault();
|
|
700
709
|
}
|
|
701
710
|
let newErrorSchema;
|
|
702
|
-
if (
|
|
711
|
+
if (errorSchemaRef.current) {
|
|
703
712
|
newErrorSchema = {};
|
|
704
|
-
for (const idx
|
|
705
|
-
const i = parseInt(idx);
|
|
713
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
714
|
+
const i = parseInt(idx, 10);
|
|
706
715
|
if (i <= index) {
|
|
707
|
-
(0, import_set.default)(newErrorSchema, [i],
|
|
716
|
+
(0, import_set.default)(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
708
717
|
} else if (i > index) {
|
|
709
|
-
(0, import_set.default)(newErrorSchema, [i + 1],
|
|
718
|
+
(0, import_set.default)(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
710
719
|
}
|
|
711
720
|
}
|
|
712
721
|
}
|
|
713
722
|
const newKeyedFormDataRow = {
|
|
714
723
|
key: generateRowId(),
|
|
715
|
-
item: (0, import_cloneDeep.default)(
|
|
724
|
+
item: (0, import_cloneDeep.default)(keyedFormDataRef.current[index].item)
|
|
716
725
|
};
|
|
717
|
-
const newKeyedFormData = [...
|
|
726
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
718
727
|
if (index !== void 0) {
|
|
719
728
|
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
720
729
|
} else {
|
|
@@ -722,7 +731,7 @@ function ArrayField(props) {
|
|
|
722
731
|
}
|
|
723
732
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
724
733
|
},
|
|
725
|
-
[
|
|
734
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
726
735
|
);
|
|
727
736
|
const handleRemoveItem = (0, import_react.useCallback)(
|
|
728
737
|
(event, index) => {
|
|
@@ -730,21 +739,21 @@ function ArrayField(props) {
|
|
|
730
739
|
event.preventDefault();
|
|
731
740
|
}
|
|
732
741
|
let newErrorSchema;
|
|
733
|
-
if (
|
|
742
|
+
if (errorSchemaRef.current) {
|
|
734
743
|
newErrorSchema = {};
|
|
735
|
-
for (const idx
|
|
736
|
-
const i = parseInt(idx);
|
|
744
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
745
|
+
const i = parseInt(idx, 10);
|
|
737
746
|
if (i < index) {
|
|
738
|
-
(0, import_set.default)(newErrorSchema, [i],
|
|
747
|
+
(0, import_set.default)(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
739
748
|
} else if (i > index) {
|
|
740
|
-
(0, import_set.default)(newErrorSchema, [i - 1],
|
|
749
|
+
(0, import_set.default)(newErrorSchema, [i - 1], errorSchemaRef.current[i]);
|
|
741
750
|
}
|
|
742
751
|
}
|
|
743
752
|
}
|
|
744
|
-
const newKeyedFormData =
|
|
753
|
+
const newKeyedFormData = keyedFormDataRef.current.filter((_, i) => i !== index);
|
|
745
754
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
746
755
|
},
|
|
747
|
-
[
|
|
756
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
748
757
|
);
|
|
749
758
|
const handleReorderItems = (0, import_react.useCallback)(
|
|
750
759
|
(event, index, newIndex) => {
|
|
@@ -753,29 +762,29 @@ function ArrayField(props) {
|
|
|
753
762
|
event.currentTarget.blur();
|
|
754
763
|
}
|
|
755
764
|
let newErrorSchema;
|
|
756
|
-
if (
|
|
765
|
+
if (errorSchemaRef.current) {
|
|
757
766
|
newErrorSchema = {};
|
|
758
|
-
for (const idx
|
|
759
|
-
const i = parseInt(idx);
|
|
760
|
-
if (i
|
|
761
|
-
(0, import_set.default)(newErrorSchema, [newIndex],
|
|
762
|
-
} else if (i
|
|
763
|
-
(0, import_set.default)(newErrorSchema, [index],
|
|
767
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
768
|
+
const i = parseInt(idx, 10);
|
|
769
|
+
if (i === index) {
|
|
770
|
+
(0, import_set.default)(newErrorSchema, [newIndex], errorSchemaRef.current[index]);
|
|
771
|
+
} else if (i === newIndex) {
|
|
772
|
+
(0, import_set.default)(newErrorSchema, [index], errorSchemaRef.current[newIndex]);
|
|
764
773
|
} else {
|
|
765
|
-
(0, import_set.default)(newErrorSchema, [idx],
|
|
774
|
+
(0, import_set.default)(newErrorSchema, [idx], errorSchemaRef.current[i]);
|
|
766
775
|
}
|
|
767
776
|
}
|
|
768
777
|
}
|
|
769
778
|
function reOrderArray() {
|
|
770
|
-
const
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
return
|
|
779
|
+
const newKeyedFormData2 = keyedFormDataRef.current.slice();
|
|
780
|
+
newKeyedFormData2.splice(index, 1);
|
|
781
|
+
newKeyedFormData2.splice(newIndex, 0, keyedFormDataRef.current[index]);
|
|
782
|
+
return newKeyedFormData2;
|
|
774
783
|
}
|
|
775
784
|
const newKeyedFormData = reOrderArray();
|
|
776
785
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
777
786
|
},
|
|
778
|
-
[
|
|
787
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
779
788
|
);
|
|
780
789
|
const handleChange = (0, import_react.useCallback)(
|
|
781
790
|
(value, path, newErrorSchema, id) => {
|
|
@@ -923,9 +932,7 @@ function BooleanField(props) {
|
|
|
923
932
|
}
|
|
924
933
|
}
|
|
925
934
|
const onWidgetChange = (0, import_react2.useCallback)(
|
|
926
|
-
(value, errorSchema, id) =>
|
|
927
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
928
|
-
},
|
|
935
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
929
936
|
[onChange, fieldPathId]
|
|
930
937
|
);
|
|
931
938
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -983,7 +990,7 @@ function castToNewType(formData, newType) {
|
|
|
983
990
|
return String(formData);
|
|
984
991
|
case "number": {
|
|
985
992
|
const castedNumber = Number(formData);
|
|
986
|
-
return isNaN(castedNumber) ? 0 : castedNumber;
|
|
993
|
+
return Number.isNaN(castedNumber) ? 0 : castedNumber;
|
|
987
994
|
}
|
|
988
995
|
case "boolean":
|
|
989
996
|
return Boolean(formData);
|
|
@@ -1162,6 +1169,7 @@ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
1162
1169
|
}
|
|
1163
1170
|
function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1164
1171
|
let rawSchema;
|
|
1172
|
+
let resultPathId = fieldPathId;
|
|
1165
1173
|
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && (0, import_has.default)(schema, import_utils4.ITEMS_KEY)) {
|
|
1166
1174
|
const index = Number(potentialIndex);
|
|
1167
1175
|
const items = schema[import_utils4.ITEMS_KEY];
|
|
@@ -1174,12 +1182,12 @@ function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
|
1174
1182
|
} else {
|
|
1175
1183
|
rawSchema = items;
|
|
1176
1184
|
}
|
|
1177
|
-
|
|
1185
|
+
resultPathId = {
|
|
1178
1186
|
[import_utils4.ID_KEY]: fieldPathId[import_utils4.ID_KEY],
|
|
1179
1187
|
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1180
1188
|
};
|
|
1181
1189
|
}
|
|
1182
|
-
return { rawSchema, fieldPathId };
|
|
1190
|
+
return { rawSchema, fieldPathId: resultPathId };
|
|
1183
1191
|
}
|
|
1184
1192
|
function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
1185
1193
|
const { schemaUtils, globalFormOptions } = registry;
|
|
@@ -1262,8 +1270,8 @@ function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
|
1262
1270
|
if ((0, import_isString.default)(prop)) {
|
|
1263
1271
|
const match = LOOKUP_REGEX.exec(prop);
|
|
1264
1272
|
if (Array.isArray(match) && match.length > 1) {
|
|
1265
|
-
const
|
|
1266
|
-
uiProps[key] = (0, import_utils4.lookupFromFormContext)(registry,
|
|
1273
|
+
const lookupName = match[1];
|
|
1274
|
+
uiProps[key] = (0, import_utils4.lookupFromFormContext)(registry, lookupName, lookupName);
|
|
1267
1275
|
}
|
|
1268
1276
|
}
|
|
1269
1277
|
});
|
|
@@ -1367,10 +1375,10 @@ function LayoutGridFieldComponent(props) {
|
|
|
1367
1375
|
return uiComponentProps.rendered;
|
|
1368
1376
|
}
|
|
1369
1377
|
if (schema) {
|
|
1370
|
-
const
|
|
1378
|
+
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1371
1379
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
1372
1380
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1373
|
-
|
|
1381
|
+
Field,
|
|
1374
1382
|
{
|
|
1375
1383
|
"data-testid": optionsInfo?.hasDiscriminator ? LAYOUT_GRID_FIELD_TEST_IDS.layoutMultiSchemaField : LAYOUT_GRID_FIELD_TEST_IDS.field,
|
|
1376
1384
|
...otherProps,
|
|
@@ -1555,6 +1563,9 @@ function LayoutMultiSchemaField(props) {
|
|
|
1555
1563
|
const fieldErrorSchema = (0, import_omit.default)(errorSchema, [import_utils6.ERRORS_KEY]);
|
|
1556
1564
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1557
1565
|
const onOptionChange = (opt) => {
|
|
1566
|
+
if (disabled || readonly) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1558
1569
|
const newOption = getSelectedOption(enumOptions, selectorField, opt);
|
|
1559
1570
|
const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1560
1571
|
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
@@ -1625,6 +1636,12 @@ var import_isEmpty3 = __toESM(require("lodash/isEmpty"), 1);
|
|
|
1625
1636
|
var import_omit2 = __toESM(require("lodash/omit"), 1);
|
|
1626
1637
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1627
1638
|
var AnyOfField = class extends import_react6.Component {
|
|
1639
|
+
/** Flag to skip the formData-change-driven option recalculation when the user just selected an option.
|
|
1640
|
+
* Set to true in the setState callback of onOptionChange (after onChange is called), consumed and reset in
|
|
1641
|
+
* componentDidUpdate. This prevents the matching-option recalculation from overriding a user's explicit choice
|
|
1642
|
+
* when getDefaultFormState populates undefined properties that make deepEquals see a false formData change.
|
|
1643
|
+
*/
|
|
1644
|
+
skipNextOptionRecalculation = false;
|
|
1628
1645
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1629
1646
|
*
|
|
1630
1647
|
* @param props - The `FieldProps` for this template
|
|
@@ -1660,10 +1677,14 @@ var AnyOfField = class extends import_react6.Component {
|
|
|
1660
1677
|
newState = { selectedOption, retrievedOptions };
|
|
1661
1678
|
}
|
|
1662
1679
|
if (!(0, import_utils7.deepEquals)(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1680
|
+
if (this.skipNextOptionRecalculation) {
|
|
1681
|
+
this.skipNextOptionRecalculation = false;
|
|
1682
|
+
} else {
|
|
1683
|
+
const { retrievedOptions } = newState;
|
|
1684
|
+
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
1685
|
+
if (prevState && matchingOption !== selectedOption) {
|
|
1686
|
+
newState = { selectedOption: matchingOption, retrievedOptions };
|
|
1687
|
+
}
|
|
1667
1688
|
}
|
|
1668
1689
|
}
|
|
1669
1690
|
if (newState !== this.state) {
|
|
@@ -1693,7 +1714,10 @@ var AnyOfField = class extends import_react6.Component {
|
|
|
1693
1714
|
*/
|
|
1694
1715
|
onOptionChange = (option) => {
|
|
1695
1716
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1696
|
-
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
1717
|
+
const { disabled = false, formData, onChange, readonly = false, registry, fieldPathId } = this.props;
|
|
1718
|
+
if (disabled || readonly) {
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1697
1721
|
const { schemaUtils } = registry;
|
|
1698
1722
|
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1699
1723
|
if (intOption === selectedOption) {
|
|
@@ -1706,6 +1730,7 @@ var AnyOfField = class extends import_react6.Component {
|
|
|
1706
1730
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1707
1731
|
}
|
|
1708
1732
|
this.setState({ selectedOption: intOption }, () => {
|
|
1733
|
+
this.skipNextOptionRecalculation = true;
|
|
1709
1734
|
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1710
1735
|
});
|
|
1711
1736
|
};
|
|
@@ -1730,7 +1755,7 @@ var AnyOfField = class extends import_react6.Component {
|
|
|
1730
1755
|
uiSchema
|
|
1731
1756
|
} = this.props;
|
|
1732
1757
|
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1733
|
-
const { SchemaField:
|
|
1758
|
+
const { SchemaField: SchemaFieldComponent } = fields2;
|
|
1734
1759
|
const MultiSchemaFieldTemplate2 = (0, import_utils7.getTemplate)(
|
|
1735
1760
|
"MultiSchemaFieldTemplate",
|
|
1736
1761
|
registry,
|
|
@@ -1754,8 +1779,8 @@ var AnyOfField = class extends import_react6.Component {
|
|
|
1754
1779
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1755
1780
|
let optionSchema;
|
|
1756
1781
|
if (option) {
|
|
1757
|
-
const { required:
|
|
1758
|
-
optionSchema =
|
|
1782
|
+
const { required: schemaRequired } = schema;
|
|
1783
|
+
optionSchema = schemaRequired ? (0, import_utils7.mergeSchemas)({ required: schemaRequired }, option) : option;
|
|
1759
1784
|
}
|
|
1760
1785
|
let optionsUiSchema = [];
|
|
1761
1786
|
if (import_utils7.ONE_OF_KEY in schema && uiSchema && import_utils7.ONE_OF_KEY in uiSchema) {
|
|
@@ -1808,7 +1833,7 @@ var AnyOfField = class extends import_react6.Component {
|
|
|
1808
1833
|
readonly
|
|
1809
1834
|
}
|
|
1810
1835
|
) : void 0;
|
|
1811
|
-
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1836
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SchemaFieldComponent, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1812
1837
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1813
1838
|
MultiSchemaFieldTemplate2,
|
|
1814
1839
|
{
|
|
@@ -1848,12 +1873,10 @@ function NumberField(props) {
|
|
|
1848
1873
|
const { StringField: StringField2 } = registry.fields;
|
|
1849
1874
|
let value = formData;
|
|
1850
1875
|
const handleChange = (0, import_react8.useCallback)(
|
|
1851
|
-
(
|
|
1852
|
-
setLastValue(
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
}
|
|
1856
|
-
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? (0, import_utils8.asNumber)(value2.replace(trailingCharMatcher, "")) : (0, import_utils8.asNumber)(value2);
|
|
1876
|
+
(newValue, path, errorSchema, id) => {
|
|
1877
|
+
setLastValue(newValue);
|
|
1878
|
+
const normalizedValue = `${newValue}`.startsWith(".") ? `0${newValue}` : newValue;
|
|
1879
|
+
const processed = typeof normalizedValue === "string" && normalizedValue.match(trailingCharMatcherWithPrefix) ? (0, import_utils8.asNumber)(normalizedValue.replace(trailingCharMatcher, "")) : (0, import_utils8.asNumber)(normalizedValue);
|
|
1857
1880
|
onChange(processed, path, errorSchema, id);
|
|
1858
1881
|
},
|
|
1859
1882
|
[onChange]
|
|
@@ -1875,7 +1898,7 @@ var import_get4 = __toESM(require("lodash/get"), 1);
|
|
|
1875
1898
|
var import_has3 = __toESM(require("lodash/has"), 1);
|
|
1876
1899
|
var import_isObject4 = __toESM(require("lodash/isObject"), 1);
|
|
1877
1900
|
var import_set4 = __toESM(require("lodash/set"), 1);
|
|
1878
|
-
var
|
|
1901
|
+
var import_react10 = require("markdown-to-jsx/react");
|
|
1879
1902
|
|
|
1880
1903
|
// src/components/constants.ts
|
|
1881
1904
|
var ADDITIONAL_PROPERTY_KEY_REMOVE = /* @__PURE__ */ Symbol("remove-this-key");
|
|
@@ -1884,7 +1907,7 @@ var IS_RESET = /* @__PURE__ */ Symbol("reset");
|
|
|
1884
1907
|
// src/components/fields/ObjectField.tsx
|
|
1885
1908
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1886
1909
|
function isRequired(schema, name) {
|
|
1887
|
-
return Array.isArray(schema.required) && schema.required.
|
|
1910
|
+
return Array.isArray(schema.required) && schema.required.includes(name);
|
|
1888
1911
|
}
|
|
1889
1912
|
function getDefaultValue(translateString, type) {
|
|
1890
1913
|
switch (type) {
|
|
@@ -1903,7 +1926,7 @@ function getDefaultValue(translateString, type) {
|
|
|
1903
1926
|
return translateString(import_utils9.TranslatableString.NewStringDefault);
|
|
1904
1927
|
}
|
|
1905
1928
|
}
|
|
1906
|
-
function
|
|
1929
|
+
function ObjectFieldPropertyFn(props) {
|
|
1907
1930
|
const {
|
|
1908
1931
|
fieldPathId,
|
|
1909
1932
|
schema,
|
|
@@ -1931,10 +1954,11 @@ function ObjectFieldProperty(props) {
|
|
|
1931
1954
|
);
|
|
1932
1955
|
const onPropertyChange = (0, import_react9.useCallback)(
|
|
1933
1956
|
(value, path, newErrorSchema, id) => {
|
|
1957
|
+
let normalizedValue = value;
|
|
1934
1958
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
1935
|
-
|
|
1959
|
+
normalizedValue = "";
|
|
1936
1960
|
}
|
|
1937
|
-
onChange(
|
|
1961
|
+
onChange(normalizedValue, path, newErrorSchema, id);
|
|
1938
1962
|
},
|
|
1939
1963
|
[onChange, addedByAdditionalProperties]
|
|
1940
1964
|
);
|
|
@@ -1983,6 +2007,7 @@ function ObjectFieldProperty(props) {
|
|
|
1983
2007
|
}
|
|
1984
2008
|
);
|
|
1985
2009
|
}
|
|
2010
|
+
var ObjectFieldProperty = (0, import_react9.memo)(ObjectFieldPropertyFn);
|
|
1986
2011
|
function ObjectField(props) {
|
|
1987
2012
|
const {
|
|
1988
2013
|
schema: rawSchema,
|
|
@@ -2005,8 +2030,11 @@ function ObjectField(props) {
|
|
|
2005
2030
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
2006
2031
|
const formDataRef = (0, import_react9.useRef)(formData);
|
|
2007
2032
|
formDataRef.current = formData;
|
|
2008
|
-
const schema =
|
|
2009
|
-
|
|
2033
|
+
const schema = (0, import_react9.useMemo)(
|
|
2034
|
+
() => schemaUtils.retrieveSchema(rawSchema, formData, true),
|
|
2035
|
+
[schemaUtils, rawSchema, formData]
|
|
2036
|
+
);
|
|
2037
|
+
const uiOptions = (0, import_react9.useMemo)(() => (0, import_utils9.getUiOptions)(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
2010
2038
|
const { properties: schemaProperties = {} } = schema;
|
|
2011
2039
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
2012
2040
|
const lastRenamedProperty = (0, import_react9.useRef)({ previousKey: "", currentKey: void 0 });
|
|
@@ -2016,12 +2044,13 @@ function ObjectField(props) {
|
|
|
2016
2044
|
const hasFormData = (0, import_utils9.isFormDataAvailable)(formData);
|
|
2017
2045
|
let orderedProperties = [];
|
|
2018
2046
|
const getAvailableKey = (0, import_react9.useCallback)(
|
|
2019
|
-
(preferredKey,
|
|
2047
|
+
(preferredKey, existingFormData) => {
|
|
2020
2048
|
const { duplicateKeySuffixSeparator = "-" } = (0, import_utils9.getUiOptions)(uiSchema, globalUiOptions);
|
|
2021
2049
|
let index = 0;
|
|
2022
2050
|
let newKey = preferredKey;
|
|
2023
|
-
while ((0, import_has3.default)(
|
|
2024
|
-
|
|
2051
|
+
while ((0, import_has3.default)(existingFormData, newKey)) {
|
|
2052
|
+
index += 1;
|
|
2053
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
2025
2054
|
}
|
|
2026
2055
|
return newKey;
|
|
2027
2056
|
},
|
|
@@ -2031,7 +2060,6 @@ function ObjectField(props) {
|
|
|
2031
2060
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2032
2061
|
return;
|
|
2033
2062
|
}
|
|
2034
|
-
const { translateString: translateString2 } = registry;
|
|
2035
2063
|
const newFormData = { ...formData };
|
|
2036
2064
|
const newKey = getAvailableKey("newKey", newFormData);
|
|
2037
2065
|
if (schema.patternProperties) {
|
|
@@ -2046,8 +2074,7 @@ function ObjectField(props) {
|
|
|
2046
2074
|
defaultValue = schema.additionalProperties.default;
|
|
2047
2075
|
let apSchema = schema.additionalProperties;
|
|
2048
2076
|
if (import_utils9.REF_KEY in apSchema) {
|
|
2049
|
-
|
|
2050
|
-
apSchema = schemaUtils2.retrieveSchema({ [import_utils9.REF_KEY]: apSchema[import_utils9.REF_KEY] }, formData);
|
|
2077
|
+
apSchema = schemaUtils.retrieveSchema({ [import_utils9.REF_KEY]: apSchema[import_utils9.REF_KEY] }, formData);
|
|
2051
2078
|
type = apSchema.type;
|
|
2052
2079
|
constValue = apSchema.const;
|
|
2053
2080
|
defaultValue = apSchema.default;
|
|
@@ -2056,7 +2083,7 @@ function ObjectField(props) {
|
|
|
2056
2083
|
type = "object";
|
|
2057
2084
|
}
|
|
2058
2085
|
}
|
|
2059
|
-
const newValue = constValue ?? defaultValue ?? getDefaultValue(
|
|
2086
|
+
const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString, type);
|
|
2060
2087
|
(0, import_set4.default)(newFormData, newKey, newValue);
|
|
2061
2088
|
}
|
|
2062
2089
|
if (lastRenamedProperty.current.previousKey === newKey) {
|
|
@@ -2064,7 +2091,7 @@ function ObjectField(props) {
|
|
|
2064
2091
|
lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
|
|
2065
2092
|
}
|
|
2066
2093
|
onChange(newFormData, childFieldPathId.path);
|
|
2067
|
-
}, [formData, onChange,
|
|
2094
|
+
}, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
|
|
2068
2095
|
const handleKeyRename = (0, import_react9.useCallback)(
|
|
2069
2096
|
(oldKey, newKey) => {
|
|
2070
2097
|
if (oldKey !== newKey) {
|
|
@@ -2075,8 +2102,8 @@ function ObjectField(props) {
|
|
|
2075
2102
|
};
|
|
2076
2103
|
const newKeys = { [oldKey]: actualNewKey };
|
|
2077
2104
|
const keyValues = Object.keys(newFormData).map((key) => {
|
|
2078
|
-
const
|
|
2079
|
-
return { [
|
|
2105
|
+
const mappedKey = Object.hasOwn(newKeys, key) ? newKeys[key] : key;
|
|
2106
|
+
return { [mappedKey]: newFormData[key] };
|
|
2080
2107
|
});
|
|
2081
2108
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
2082
2109
|
formDataRef.current = renamedObj;
|
|
@@ -2107,7 +2134,7 @@ function ObjectField(props) {
|
|
|
2107
2134
|
orderedProperties = (0, import_utils9.orderProperties)(properties, uiOptions.order);
|
|
2108
2135
|
} catch (err) {
|
|
2109
2136
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
2110
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2137
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react10.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(import_utils9.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
2111
2138
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("pre", { children: JSON.stringify(schema) })
|
|
2112
2139
|
] });
|
|
2113
2140
|
}
|
|
@@ -2118,20 +2145,20 @@ function ObjectField(props) {
|
|
|
2118
2145
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
2119
2146
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
2120
2147
|
description: uiOptions.label === false ? void 0 : description,
|
|
2121
|
-
properties: orderedProperties.map((
|
|
2122
|
-
const addedByAdditionalProperties = (0, import_has3.default)(schema, [import_utils9.PROPERTIES_KEY,
|
|
2123
|
-
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[
|
|
2148
|
+
properties: orderedProperties.map((propertyName) => {
|
|
2149
|
+
const addedByAdditionalProperties = (0, import_has3.default)(schema, [import_utils9.PROPERTIES_KEY, propertyName, import_utils9.ADDITIONAL_PROPERTY_FLAG]);
|
|
2150
|
+
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
|
|
2124
2151
|
const hidden = (0, import_utils9.getUiOptions)(fieldUiSchema).widget === "hidden";
|
|
2125
2152
|
const content = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2126
2153
|
ObjectFieldProperty,
|
|
2127
2154
|
{
|
|
2128
|
-
propertyName
|
|
2129
|
-
required: isRequired(schema,
|
|
2130
|
-
schema: (0, import_get4.default)(schema, [import_utils9.PROPERTIES_KEY,
|
|
2155
|
+
propertyName,
|
|
2156
|
+
required: isRequired(schema, propertyName),
|
|
2157
|
+
schema: (0, import_get4.default)(schema, [import_utils9.PROPERTIES_KEY, propertyName], {}),
|
|
2131
2158
|
uiSchema: fieldUiSchema,
|
|
2132
|
-
errorSchema: (0, import_get4.default)(errorSchema, [
|
|
2159
|
+
errorSchema: (0, import_get4.default)(errorSchema, [propertyName]),
|
|
2133
2160
|
fieldPathId: childFieldPathId,
|
|
2134
|
-
formData: (0, import_get4.default)(formData, [
|
|
2161
|
+
formData: (0, import_get4.default)(formData, [propertyName]),
|
|
2135
2162
|
handleKeyRename,
|
|
2136
2163
|
handleRemoveProperty,
|
|
2137
2164
|
addedByAdditionalProperties,
|
|
@@ -2143,11 +2170,11 @@ function ObjectField(props) {
|
|
|
2143
2170
|
readonly,
|
|
2144
2171
|
hideError
|
|
2145
2172
|
},
|
|
2146
|
-
getStableKey(
|
|
2173
|
+
getStableKey(propertyName)
|
|
2147
2174
|
);
|
|
2148
2175
|
return {
|
|
2149
2176
|
content,
|
|
2150
|
-
name:
|
|
2177
|
+
name: propertyName,
|
|
2151
2178
|
readonly,
|
|
2152
2179
|
disabled,
|
|
2153
2180
|
required,
|
|
@@ -2231,7 +2258,7 @@ function OptionalDataControlsField(props) {
|
|
|
2231
2258
|
}
|
|
2232
2259
|
|
|
2233
2260
|
// src/components/fields/SchemaField.tsx
|
|
2234
|
-
var
|
|
2261
|
+
var import_react11 = require("react");
|
|
2235
2262
|
var import_utils11 = require("@rjsf/utils");
|
|
2236
2263
|
var import_isObject5 = __toESM(require("lodash/isObject"), 1);
|
|
2237
2264
|
var import_omit3 = __toESM(require("lodash/omit"), 1);
|
|
@@ -2246,7 +2273,7 @@ var COMPONENT_TYPES = {
|
|
|
2246
2273
|
null: "NullField"
|
|
2247
2274
|
};
|
|
2248
2275
|
function getFieldComponent(schema, uiOptions, registry) {
|
|
2249
|
-
const field = uiOptions
|
|
2276
|
+
const { field } = uiOptions;
|
|
2250
2277
|
const { fields: fields2 } = registry;
|
|
2251
2278
|
if (typeof field === "function") {
|
|
2252
2279
|
return field;
|
|
@@ -2264,7 +2291,7 @@ function getFieldComponent(schema, uiOptions, registry) {
|
|
|
2264
2291
|
if (!componentName && (schema.anyOf || schema.oneOf)) {
|
|
2265
2292
|
return () => null;
|
|
2266
2293
|
}
|
|
2267
|
-
return componentName in fields2 ? fields2[componentName] : fields2
|
|
2294
|
+
return componentName in fields2 ? fields2[componentName] : fields2.FallbackField;
|
|
2268
2295
|
}
|
|
2269
2296
|
function SchemaFieldRender(props) {
|
|
2270
2297
|
const {
|
|
@@ -2296,10 +2323,10 @@ function SchemaFieldRender(props) {
|
|
|
2296
2323
|
const FieldErrorTemplate2 = (0, import_utils11.getTemplate)("FieldErrorTemplate", registry, uiOptions);
|
|
2297
2324
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2298
2325
|
const fieldId = fieldPathId[import_utils11.ID_KEY];
|
|
2299
|
-
const handleFieldComponentChange = (0,
|
|
2300
|
-
(
|
|
2326
|
+
const handleFieldComponentChange = (0, import_react11.useCallback)(
|
|
2327
|
+
(newFormData, path, newErrorSchema, id2) => {
|
|
2301
2328
|
const theId = id2 || fieldId;
|
|
2302
|
-
return onChange(
|
|
2329
|
+
return onChange(newFormData, path, newErrorSchema, theId);
|
|
2303
2330
|
},
|
|
2304
2331
|
[fieldId, onChange]
|
|
2305
2332
|
);
|
|
@@ -2323,12 +2350,12 @@ function SchemaFieldRender(props) {
|
|
|
2323
2350
|
if (schema[import_utils11.ANY_OF_KEY]) {
|
|
2324
2351
|
XxxOfField = _AnyOfField;
|
|
2325
2352
|
XxxOfOptions = schema[import_utils11.ANY_OF_KEY].map(
|
|
2326
|
-
(
|
|
2353
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema((0, import_isObject5.default)(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2327
2354
|
);
|
|
2328
2355
|
} else if (schema[import_utils11.ONE_OF_KEY]) {
|
|
2329
2356
|
XxxOfField = _OneOfField;
|
|
2330
2357
|
XxxOfOptions = schema[import_utils11.ONE_OF_KEY].map(
|
|
2331
|
-
(
|
|
2358
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema((0, import_isObject5.default)(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2332
2359
|
);
|
|
2333
2360
|
}
|
|
2334
2361
|
const isOptionalRender = (0, import_utils11.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
@@ -2373,7 +2400,7 @@ function SchemaFieldRender(props) {
|
|
|
2373
2400
|
label = registry.translateString(import_utils11.TranslatableString.DeprecatedLabel, [label]);
|
|
2374
2401
|
}
|
|
2375
2402
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2376
|
-
const help = uiOptions
|
|
2403
|
+
const { help } = uiOptions;
|
|
2377
2404
|
const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
|
|
2378
2405
|
const classNames = ["rjsf-field", `rjsf-field-${(0, import_utils11.getSchemaType)(schema)}`];
|
|
2379
2406
|
if (!hideError && __errors && __errors.length > 0) {
|
|
@@ -2464,7 +2491,7 @@ function SchemaFieldRender(props) {
|
|
|
2464
2491
|
)
|
|
2465
2492
|
] }) });
|
|
2466
2493
|
}
|
|
2467
|
-
var SchemaField = class extends
|
|
2494
|
+
var SchemaField = class extends import_react11.Component {
|
|
2468
2495
|
shouldComponentUpdate(nextProps) {
|
|
2469
2496
|
const {
|
|
2470
2497
|
registry: { globalFormOptions }
|
|
@@ -2479,7 +2506,7 @@ var SchemaField = class extends import_react10.Component {
|
|
|
2479
2506
|
var SchemaField_default = SchemaField;
|
|
2480
2507
|
|
|
2481
2508
|
// src/components/fields/StringField.tsx
|
|
2482
|
-
var
|
|
2509
|
+
var import_react12 = require("react");
|
|
2483
2510
|
var import_utils12 = require("@rjsf/utils");
|
|
2484
2511
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2485
2512
|
function StringField(props) {
|
|
@@ -2512,10 +2539,8 @@ function StringField(props) {
|
|
|
2512
2539
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2513
2540
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
2514
2541
|
const Widget = (0, import_utils12.getWidget)(schema, widget, widgets2);
|
|
2515
|
-
const onWidgetChange = (0,
|
|
2516
|
-
(value, errorSchema, id) =>
|
|
2517
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2518
|
-
},
|
|
2542
|
+
const onWidgetChange = (0, import_react12.useCallback)(
|
|
2543
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
2519
2544
|
[onChange, fieldPathId]
|
|
2520
2545
|
);
|
|
2521
2546
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -2792,12 +2817,15 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2792
2817
|
}
|
|
2793
2818
|
|
|
2794
2819
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2795
|
-
var
|
|
2820
|
+
var import_react13 = require("react");
|
|
2796
2821
|
var import_utils19 = require("@rjsf/utils");
|
|
2797
2822
|
|
|
2798
2823
|
// src/components/SchemaExamples.tsx
|
|
2799
2824
|
var import_utils18 = require("@rjsf/utils");
|
|
2800
|
-
var import_jsx_runtime18 =
|
|
2825
|
+
var import_jsx_runtime18 = (
|
|
2826
|
+
// oxlint-disable-next-line jsx-a11y/control-has-associated-label
|
|
2827
|
+
require("react/jsx-runtime")
|
|
2828
|
+
);
|
|
2801
2829
|
function SchemaExamples(props) {
|
|
2802
2830
|
const { id, schema } = props;
|
|
2803
2831
|
const { examples, default: schemaDefault } = schema;
|
|
@@ -2806,9 +2834,7 @@ function SchemaExamples(props) {
|
|
|
2806
2834
|
}
|
|
2807
2835
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("datalist", { id: (0, import_utils18.examplesId)(id), children: examples.concat(
|
|
2808
2836
|
schemaDefault !== void 0 && !examples.map(String).includes(String(schemaDefault)) ? [schemaDefault] : []
|
|
2809
|
-
).map((example) => {
|
|
2810
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: example }, String(example));
|
|
2811
|
-
}) }, `datalist_${id}`);
|
|
2837
|
+
).map((example) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: example }, String(example))) }, `datalist_${id}`);
|
|
2812
2838
|
}
|
|
2813
2839
|
|
|
2814
2840
|
// src/components/templates/BaseInputTemplate.tsx
|
|
@@ -2854,19 +2880,19 @@ function BaseInputTemplate(props) {
|
|
|
2854
2880
|
} else {
|
|
2855
2881
|
inputValue = value == null ? "" : value;
|
|
2856
2882
|
}
|
|
2857
|
-
const
|
|
2858
|
-
({ target: { value:
|
|
2883
|
+
const handleChange = (0, import_react13.useCallback)(
|
|
2884
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
2859
2885
|
[onChange, options]
|
|
2860
2886
|
);
|
|
2861
|
-
const
|
|
2887
|
+
const handleBlur = (0, import_react13.useCallback)(
|
|
2862
2888
|
({ target }) => onBlur(id, target && target.value),
|
|
2863
2889
|
[onBlur, id]
|
|
2864
2890
|
);
|
|
2865
|
-
const
|
|
2891
|
+
const handleFocus = (0, import_react13.useCallback)(
|
|
2866
2892
|
({ target }) => onFocus(id, target && target.value),
|
|
2867
2893
|
[onFocus, id]
|
|
2868
2894
|
);
|
|
2869
|
-
const
|
|
2895
|
+
const handleClear = (0, import_react13.useCallback)(
|
|
2870
2896
|
(e) => {
|
|
2871
2897
|
e.preventDefault();
|
|
2872
2898
|
e.stopPropagation();
|
|
@@ -2887,13 +2913,13 @@ function BaseInputTemplate(props) {
|
|
|
2887
2913
|
value: inputValue,
|
|
2888
2914
|
...inputProps,
|
|
2889
2915
|
list: schema.examples ? (0, import_utils19.examplesId)(id) : void 0,
|
|
2890
|
-
onChange: onChangeOverride ||
|
|
2891
|
-
onBlur:
|
|
2892
|
-
onFocus:
|
|
2916
|
+
onChange: onChangeOverride || handleChange,
|
|
2917
|
+
onBlur: handleBlur,
|
|
2918
|
+
onFocus: handleFocus,
|
|
2893
2919
|
"aria-describedby": (0, import_utils19.ariaDescribedByIds)(id, !!schema.examples)
|
|
2894
2920
|
}
|
|
2895
2921
|
),
|
|
2896
|
-
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ClearButton2, { registry, onClick:
|
|
2922
|
+
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ClearButton2, { registry, onClick: handleClear }),
|
|
2897
2923
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SchemaExamples, { id, schema })
|
|
2898
2924
|
] });
|
|
2899
2925
|
}
|
|
@@ -2902,37 +2928,44 @@ function BaseInputTemplate(props) {
|
|
|
2902
2928
|
var import_utils21 = require("@rjsf/utils");
|
|
2903
2929
|
|
|
2904
2930
|
// src/components/templates/ButtonTemplates/IconButton.tsx
|
|
2931
|
+
var import_react14 = require("react");
|
|
2905
2932
|
var import_utils20 = require("@rjsf/utils");
|
|
2906
2933
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2907
|
-
function
|
|
2934
|
+
function IconButtonFn(props) {
|
|
2908
2935
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
2909
2936
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
2910
2937
|
}
|
|
2911
|
-
|
|
2938
|
+
var IconButton = (0, import_react14.memo)(IconButtonFn);
|
|
2939
|
+
var IconButton_default = IconButton;
|
|
2940
|
+
function CopyButtonFn(props) {
|
|
2912
2941
|
const {
|
|
2913
2942
|
registry: { translateString }
|
|
2914
2943
|
} = props;
|
|
2915
2944
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(IconButton, { title: translateString(import_utils20.TranslatableString.CopyButton), ...props, icon: "copy" });
|
|
2916
2945
|
}
|
|
2917
|
-
|
|
2946
|
+
var CopyButton = (0, import_react14.memo)(CopyButtonFn);
|
|
2947
|
+
function MoveDownButtonFn(props) {
|
|
2918
2948
|
const {
|
|
2919
2949
|
registry: { translateString }
|
|
2920
2950
|
} = props;
|
|
2921
2951
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(IconButton, { title: translateString(import_utils20.TranslatableString.MoveDownButton), ...props, icon: "arrow-down" });
|
|
2922
2952
|
}
|
|
2923
|
-
|
|
2953
|
+
var MoveDownButton = (0, import_react14.memo)(MoveDownButtonFn);
|
|
2954
|
+
function MoveUpButtonFn(props) {
|
|
2924
2955
|
const {
|
|
2925
2956
|
registry: { translateString }
|
|
2926
2957
|
} = props;
|
|
2927
2958
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(IconButton, { title: translateString(import_utils20.TranslatableString.MoveUpButton), ...props, icon: "arrow-up" });
|
|
2928
2959
|
}
|
|
2929
|
-
|
|
2960
|
+
var MoveUpButton = (0, import_react14.memo)(MoveUpButtonFn);
|
|
2961
|
+
function RemoveButtonFn(props) {
|
|
2930
2962
|
const {
|
|
2931
2963
|
registry: { translateString }
|
|
2932
2964
|
} = props;
|
|
2933
2965
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(IconButton, { title: translateString(import_utils20.TranslatableString.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
2934
2966
|
}
|
|
2935
|
-
|
|
2967
|
+
var RemoveButton = (0, import_react14.memo)(RemoveButtonFn);
|
|
2968
|
+
function ClearButtonFn({
|
|
2936
2969
|
id,
|
|
2937
2970
|
className,
|
|
2938
2971
|
onClick,
|
|
@@ -2956,6 +2989,7 @@ function ClearButton({
|
|
|
2956
2989
|
}
|
|
2957
2990
|
);
|
|
2958
2991
|
}
|
|
2992
|
+
var ClearButton = (0, import_react14.memo)(ClearButtonFn);
|
|
2959
2993
|
|
|
2960
2994
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
2961
2995
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
@@ -2972,7 +3006,7 @@ function AddButton({
|
|
|
2972
3006
|
{
|
|
2973
3007
|
className: `col-xs-4 col-sm-2 col-lg-1 col-xs-offset-8 col-sm-offset-10 col-lg-offset-11 text-right ${className}`,
|
|
2974
3008
|
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2975
|
-
|
|
3009
|
+
IconButton_default,
|
|
2976
3010
|
{
|
|
2977
3011
|
id,
|
|
2978
3012
|
iconType: "info",
|
|
@@ -3015,14 +3049,14 @@ var ButtonTemplates_default = buttonTemplates;
|
|
|
3015
3049
|
|
|
3016
3050
|
// src/components/RichDescription.tsx
|
|
3017
3051
|
var import_utils23 = require("@rjsf/utils");
|
|
3018
|
-
var
|
|
3052
|
+
var import_react15 = require("markdown-to-jsx/react");
|
|
3019
3053
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3020
3054
|
var TEST_IDS = (0, import_utils23.getTestIds)();
|
|
3021
3055
|
function RichDescription({ description, registry, uiSchema = {} }) {
|
|
3022
3056
|
const { globalUiOptions } = registry;
|
|
3023
3057
|
const uiOptions = (0, import_utils23.getUiOptions)(uiSchema, globalUiOptions);
|
|
3024
3058
|
if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
|
|
3025
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react15.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
3026
3060
|
}
|
|
3027
3061
|
return description;
|
|
3028
3062
|
}
|
|
@@ -3048,9 +3082,10 @@ function ErrorList({
|
|
|
3048
3082
|
const { translateString } = registry;
|
|
3049
3083
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "panel panel-danger errors", children: [
|
|
3050
3084
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "panel-heading", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h3", { className: "panel-title", children: translateString(import_utils24.TranslatableString.ErrorsLabel) }) }),
|
|
3051
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ul", { className: "list-group", children: errors.map((error, i) =>
|
|
3052
|
-
|
|
3053
|
-
|
|
3085
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ul", { className: "list-group", children: errors.map((error, i) => (
|
|
3086
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3087
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("li", { className: "list-group-item text-danger", children: error.stack }, i)
|
|
3088
|
+
)) })
|
|
3054
3089
|
] });
|
|
3055
3090
|
}
|
|
3056
3091
|
|
|
@@ -3076,16 +3111,17 @@ function FallbackFieldTemplate(props) {
|
|
|
3076
3111
|
|
|
3077
3112
|
// src/components/templates/FieldErrorTemplate.tsx
|
|
3078
3113
|
var import_utils26 = require("@rjsf/utils");
|
|
3079
|
-
var import_jsx_runtime27 =
|
|
3114
|
+
var import_jsx_runtime27 = (
|
|
3115
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3116
|
+
require("react/jsx-runtime")
|
|
3117
|
+
);
|
|
3080
3118
|
function FieldErrorTemplate(props) {
|
|
3081
3119
|
const { errors = [], fieldPathId } = props;
|
|
3082
3120
|
if (errors.length === 0) {
|
|
3083
3121
|
return null;
|
|
3084
3122
|
}
|
|
3085
3123
|
const id = (0, import_utils26.errorId)(fieldPathId);
|
|
3086
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
|
|
3087
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("li", { className: "text-danger", children: error }, index);
|
|
3088
|
-
}) }) });
|
|
3124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("li", { className: "text-danger", children: error }, index)) }) });
|
|
3089
3125
|
}
|
|
3090
3126
|
|
|
3091
3127
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
@@ -3093,7 +3129,7 @@ var import_utils28 = require("@rjsf/utils");
|
|
|
3093
3129
|
|
|
3094
3130
|
// src/components/RichHelp.tsx
|
|
3095
3131
|
var import_utils27 = require("@rjsf/utils");
|
|
3096
|
-
var
|
|
3132
|
+
var import_react16 = require("markdown-to-jsx/react");
|
|
3097
3133
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3098
3134
|
var TEST_IDS2 = (0, import_utils27.getTestIds)();
|
|
3099
3135
|
function RichHelp({
|
|
@@ -3104,7 +3140,7 @@ function RichHelp({
|
|
|
3104
3140
|
const { globalUiOptions } = registry;
|
|
3105
3141
|
const uiOptions = (0, import_utils27.getUiOptions)(uiSchema, globalUiOptions);
|
|
3106
3142
|
if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
|
|
3107
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react16.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
|
|
3108
3144
|
}
|
|
3109
3145
|
return help;
|
|
3110
3146
|
}
|
|
@@ -3260,7 +3296,7 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3260
3296
|
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
3261
3297
|
if (onAddClick) {
|
|
3262
3298
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3263
|
-
|
|
3299
|
+
IconButton_default,
|
|
3264
3300
|
{
|
|
3265
3301
|
id,
|
|
3266
3302
|
registry,
|
|
@@ -3270,9 +3306,10 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3270
3306
|
title: label
|
|
3271
3307
|
}
|
|
3272
3308
|
);
|
|
3273
|
-
}
|
|
3309
|
+
}
|
|
3310
|
+
if (onRemoveClick) {
|
|
3274
3311
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3275
|
-
|
|
3312
|
+
IconButton_default,
|
|
3276
3313
|
{
|
|
3277
3314
|
id,
|
|
3278
3315
|
registry,
|
|
@@ -3300,7 +3337,7 @@ function TitleField(props) {
|
|
|
3300
3337
|
|
|
3301
3338
|
// src/components/templates/UnsupportedField.tsx
|
|
3302
3339
|
var import_utils31 = require("@rjsf/utils");
|
|
3303
|
-
var
|
|
3340
|
+
var import_react17 = require("markdown-to-jsx/react");
|
|
3304
3341
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3305
3342
|
function UnsupportedField(props) {
|
|
3306
3343
|
const { schema, fieldPathId, reason, registry } = props;
|
|
@@ -3316,7 +3353,7 @@ function UnsupportedField(props) {
|
|
|
3316
3353
|
translateParams.push(reason);
|
|
3317
3354
|
}
|
|
3318
3355
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "unsupported-field", children: [
|
|
3319
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3356
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_react17.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3320
3357
|
schema && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3321
3358
|
] });
|
|
3322
3359
|
}
|
|
@@ -3437,29 +3474,32 @@ function AltDateWidget(props) {
|
|
|
3437
3474
|
const { translateString } = registry;
|
|
3438
3475
|
const { elements, handleChange, handleClear, handleSetNow } = (0, import_utils33.useAltDateWidgetProps)(props);
|
|
3439
3476
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("ul", { className: "list-inline", children: [
|
|
3440
|
-
elements.map((elemProps, i) =>
|
|
3441
|
-
|
|
3442
|
-
{
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3477
|
+
elements.map((elemProps, i) => (
|
|
3478
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3479
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3480
|
+
import_utils33.DateElement,
|
|
3481
|
+
{
|
|
3482
|
+
rootId: id,
|
|
3483
|
+
name,
|
|
3484
|
+
select: handleChange,
|
|
3485
|
+
...elemProps,
|
|
3486
|
+
disabled,
|
|
3487
|
+
readonly,
|
|
3488
|
+
registry,
|
|
3489
|
+
onBlur,
|
|
3490
|
+
onFocus,
|
|
3491
|
+
autofocus: autofocus && i === 0
|
|
3492
|
+
}
|
|
3493
|
+
) }, i)
|
|
3494
|
+
)),
|
|
3495
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { type: "button", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(import_utils33.TranslatableString.NowLabel) }) }),
|
|
3496
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("button", { type: "button", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(import_utils33.TranslatableString.ClearLabel) }) })
|
|
3457
3497
|
] });
|
|
3458
3498
|
}
|
|
3459
3499
|
var AltDateWidget_default = AltDateWidget;
|
|
3460
3500
|
|
|
3461
3501
|
// src/components/widgets/CheckboxesWidget.tsx
|
|
3462
|
-
var
|
|
3502
|
+
var import_react18 = require("react");
|
|
3463
3503
|
var import_utils34 = require("@rjsf/utils");
|
|
3464
3504
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3465
3505
|
function CheckboxesWidget({
|
|
@@ -3477,17 +3517,17 @@ function CheckboxesWidget({
|
|
|
3477
3517
|
const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
|
|
3478
3518
|
const optionValueFormat = (0, import_utils34.getOptionValueFormat)(options);
|
|
3479
3519
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3480
|
-
const handleBlur = (0,
|
|
3520
|
+
const handleBlur = (0, import_react18.useCallback)(
|
|
3481
3521
|
({ target }) => onBlur(id, (0, import_utils34.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3482
3522
|
[onBlur, id, enumOptions, emptyValue, optionValueFormat]
|
|
3483
3523
|
);
|
|
3484
|
-
const handleFocus = (0,
|
|
3524
|
+
const handleFocus = (0, import_react18.useCallback)(
|
|
3485
3525
|
({ target }) => onFocus(id, (0, import_utils34.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3486
3526
|
[onFocus, id, enumOptions, emptyValue, optionValueFormat]
|
|
3487
3527
|
);
|
|
3488
3528
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3489
3529
|
const checked = (0, import_utils34.enumOptionsIsSelected)(option.value, checkboxesValues);
|
|
3490
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3530
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3491
3531
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3492
3532
|
const handleChange = (event) => {
|
|
3493
3533
|
if (event.target.checked) {
|
|
@@ -3515,13 +3555,13 @@ function CheckboxesWidget({
|
|
|
3515
3555
|
),
|
|
3516
3556
|
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: option.label })
|
|
3517
3557
|
] });
|
|
3518
|
-
return inline ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox },
|
|
3558
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, String(option.value)) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("label", { children: checkbox }) }, String(option.value));
|
|
3519
3559
|
}) });
|
|
3520
3560
|
}
|
|
3521
3561
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3522
3562
|
|
|
3523
3563
|
// src/components/widgets/CheckboxWidget.tsx
|
|
3524
|
-
var
|
|
3564
|
+
var import_react19 = require("react");
|
|
3525
3565
|
var import_utils35 = require("@rjsf/utils");
|
|
3526
3566
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
3527
3567
|
function CheckboxWidget({
|
|
@@ -3547,15 +3587,15 @@ function CheckboxWidget({
|
|
|
3547
3587
|
options
|
|
3548
3588
|
);
|
|
3549
3589
|
const required = (0, import_utils35.schemaRequiresTrueValue)(schema);
|
|
3550
|
-
const handleChange = (0,
|
|
3590
|
+
const handleChange = (0, import_react19.useCallback)(
|
|
3551
3591
|
(event) => onChange(event.target.checked),
|
|
3552
3592
|
[onChange]
|
|
3553
3593
|
);
|
|
3554
|
-
const handleBlur = (0,
|
|
3594
|
+
const handleBlur = (0, import_react19.useCallback)(
|
|
3555
3595
|
(event) => onBlur(id, event.target.checked),
|
|
3556
3596
|
[onBlur, id]
|
|
3557
3597
|
);
|
|
3558
|
-
const handleFocus = (0,
|
|
3598
|
+
const handleFocus = (0, import_react19.useCallback)(
|
|
3559
3599
|
(event) => onFocus(id, event.target.checked),
|
|
3560
3600
|
[onFocus, id]
|
|
3561
3601
|
);
|
|
@@ -3617,19 +3657,19 @@ function DateTimeWidget(props) {
|
|
|
3617
3657
|
type: "datetime-local",
|
|
3618
3658
|
...props,
|
|
3619
3659
|
value: (0, import_utils37.utcToLocal)(value),
|
|
3620
|
-
onChange: (
|
|
3660
|
+
onChange: (newValue) => onChange((0, import_utils37.localToUTC)(newValue))
|
|
3621
3661
|
}
|
|
3622
3662
|
);
|
|
3623
3663
|
}
|
|
3624
3664
|
|
|
3625
3665
|
// src/components/widgets/DateWidget.tsx
|
|
3626
|
-
var
|
|
3666
|
+
var import_react20 = require("react");
|
|
3627
3667
|
var import_utils38 = require("@rjsf/utils");
|
|
3628
3668
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
3629
3669
|
function DateWidget(props) {
|
|
3630
3670
|
const { onChange, options, registry } = props;
|
|
3631
3671
|
const BaseInputTemplate2 = (0, import_utils38.getTemplate)("BaseInputTemplate", registry, options);
|
|
3632
|
-
const handleChange = (0,
|
|
3672
|
+
const handleChange = (0, import_react20.useCallback)((value) => onChange(value || void 0), [onChange]);
|
|
3633
3673
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3634
3674
|
}
|
|
3635
3675
|
|
|
@@ -3644,7 +3684,7 @@ function EmailWidget(props) {
|
|
|
3644
3684
|
|
|
3645
3685
|
// src/components/widgets/FileWidget.tsx
|
|
3646
3686
|
var import_utils40 = require("@rjsf/utils");
|
|
3647
|
-
var
|
|
3687
|
+
var import_react21 = require("markdown-to-jsx/react");
|
|
3648
3688
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
3649
3689
|
function FileInfoPreview({
|
|
3650
3690
|
fileInfo,
|
|
@@ -3655,12 +3695,13 @@ function FileInfoPreview({
|
|
|
3655
3695
|
if (!dataURL) {
|
|
3656
3696
|
return null;
|
|
3657
3697
|
}
|
|
3698
|
+
const previewLabel = translateString(import_utils40.TranslatableString.PreviewLabel);
|
|
3658
3699
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3659
|
-
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("img", { src: dataURL, alt: previewLabel, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3660
3701
|
}
|
|
3661
3702
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
3662
3703
|
" ",
|
|
3663
|
-
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children:
|
|
3704
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: previewLabel })
|
|
3664
3705
|
] });
|
|
3665
3706
|
}
|
|
3666
3707
|
function FilesInfo({
|
|
@@ -3678,11 +3719,14 @@ function FilesInfo({
|
|
|
3678
3719
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3679
3720
|
const { name, size, type } = fileInfo;
|
|
3680
3721
|
const handleRemove = () => onRemove(key);
|
|
3681
|
-
return
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3722
|
+
return (
|
|
3723
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3724
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("li", { children: [
|
|
3725
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_react21.Markdown, { children: translateString(import_utils40.TranslatableString.FilesInfo, [name, type, String(size)]) }),
|
|
3726
|
+
preview && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(FileInfoPreview, { fileInfo, registry }),
|
|
3727
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(RemoveButton2, { onClick: handleRemove, registry })
|
|
3728
|
+
] }, key)
|
|
3729
|
+
);
|
|
3686
3730
|
}) });
|
|
3687
3731
|
}
|
|
3688
3732
|
function FileWidget(props) {
|
|
@@ -3742,7 +3786,7 @@ function PasswordWidget(props) {
|
|
|
3742
3786
|
}
|
|
3743
3787
|
|
|
3744
3788
|
// src/components/widgets/RadioWidget.tsx
|
|
3745
|
-
var
|
|
3789
|
+
var import_react22 = require("react");
|
|
3746
3790
|
var import_utils42 = require("@rjsf/utils");
|
|
3747
3791
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
3748
3792
|
function RadioWidget({
|
|
@@ -3760,17 +3804,17 @@ function RadioWidget({
|
|
|
3760
3804
|
}) {
|
|
3761
3805
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3762
3806
|
const optionValueFormat = (0, import_utils42.getOptionValueFormat)(options);
|
|
3763
|
-
const handleBlur = (0,
|
|
3807
|
+
const handleBlur = (0, import_react22.useCallback)(
|
|
3764
3808
|
({ target }) => onBlur(id, (0, import_utils42.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3765
3809
|
[onBlur, enumOptions, emptyValue, id, optionValueFormat]
|
|
3766
3810
|
);
|
|
3767
|
-
const handleFocus = (0,
|
|
3811
|
+
const handleFocus = (0, import_react22.useCallback)(
|
|
3768
3812
|
({ target }) => onFocus(id, (0, import_utils42.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3769
3813
|
[onFocus, enumOptions, emptyValue, id, optionValueFormat]
|
|
3770
3814
|
);
|
|
3771
3815
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3772
3816
|
const checked = (0, import_utils42.enumOptionsIsSelected)(option.value, value);
|
|
3773
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3817
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3774
3818
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3775
3819
|
const handleChange = () => onChange(option.value);
|
|
3776
3820
|
const radio = /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("span", { children: [
|
|
@@ -3793,7 +3837,7 @@ function RadioWidget({
|
|
|
3793
3837
|
),
|
|
3794
3838
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: option.label })
|
|
3795
3839
|
] });
|
|
3796
|
-
return inline ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("label", { className: `radio-inline ${disabledCls}`, children: radio },
|
|
3840
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("label", { className: `radio-inline ${disabledCls}`, children: radio }, String(option.value)) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("label", { children: radio }) }, String(option.value));
|
|
3797
3841
|
}) });
|
|
3798
3842
|
}
|
|
3799
3843
|
var RadioWidget_default = RadioWidget;
|
|
@@ -3814,7 +3858,7 @@ function RangeWidget(props) {
|
|
|
3814
3858
|
}
|
|
3815
3859
|
|
|
3816
3860
|
// src/components/widgets/RatingWidget.tsx
|
|
3817
|
-
var
|
|
3861
|
+
var import_react23 = require("react");
|
|
3818
3862
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
3819
3863
|
function RatingWidget({
|
|
3820
3864
|
id,
|
|
@@ -3833,7 +3877,7 @@ function RatingWidget({
|
|
|
3833
3877
|
const { stars = 5, shape = "star" } = options;
|
|
3834
3878
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3835
3879
|
const min = schema.minimum || 0;
|
|
3836
|
-
const handleStarClick = (0,
|
|
3880
|
+
const handleStarClick = (0, import_react23.useCallback)(
|
|
3837
3881
|
(starValue) => {
|
|
3838
3882
|
if (!disabled && !readonly) {
|
|
3839
3883
|
onChange(starValue);
|
|
@@ -3841,7 +3885,7 @@ function RatingWidget({
|
|
|
3841
3885
|
},
|
|
3842
3886
|
[onChange, disabled, readonly]
|
|
3843
3887
|
);
|
|
3844
|
-
const handleFocus = (0,
|
|
3888
|
+
const handleFocus = (0, import_react23.useCallback)(
|
|
3845
3889
|
(event) => {
|
|
3846
3890
|
if (onFocus) {
|
|
3847
3891
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3850,7 +3894,7 @@ function RatingWidget({
|
|
|
3850
3894
|
},
|
|
3851
3895
|
[onFocus, id]
|
|
3852
3896
|
);
|
|
3853
|
-
const handleBlur = (0,
|
|
3897
|
+
const handleBlur = (0, import_react23.useCallback)(
|
|
3854
3898
|
(event) => {
|
|
3855
3899
|
if (onBlur) {
|
|
3856
3900
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3865,7 +3909,7 @@ function RatingWidget({
|
|
|
3865
3909
|
}
|
|
3866
3910
|
return isFilled ? "\u2605" : "\u2606";
|
|
3867
3911
|
};
|
|
3868
|
-
return /* @__PURE__ */ (0, import_jsx_runtime52.
|
|
3912
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
3869
3913
|
"div",
|
|
3870
3914
|
{
|
|
3871
3915
|
className: "rating-widget",
|
|
@@ -3882,6 +3926,7 @@ function RatingWidget({
|
|
|
3882
3926
|
"span",
|
|
3883
3927
|
{
|
|
3884
3928
|
onClick: () => handleStarClick(starValue),
|
|
3929
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && handleStarClick(starValue),
|
|
3885
3930
|
onFocus: handleFocus,
|
|
3886
3931
|
onBlur: handleBlur,
|
|
3887
3932
|
"data-value": starValue,
|
|
@@ -3914,13 +3959,16 @@ function RatingWidget({
|
|
|
3914
3959
|
)
|
|
3915
3960
|
]
|
|
3916
3961
|
}
|
|
3917
|
-
)
|
|
3962
|
+
);
|
|
3918
3963
|
}
|
|
3919
3964
|
|
|
3920
3965
|
// src/components/widgets/SelectWidget.tsx
|
|
3921
|
-
var
|
|
3966
|
+
var import_react24 = require("react");
|
|
3922
3967
|
var import_utils43 = require("@rjsf/utils");
|
|
3923
|
-
var import_jsx_runtime53 =
|
|
3968
|
+
var import_jsx_runtime53 = (
|
|
3969
|
+
// oxlint-disable-next-line jsx-a11y/no-autofocus
|
|
3970
|
+
require("react/jsx-runtime")
|
|
3971
|
+
);
|
|
3924
3972
|
function getValue(event, multiple) {
|
|
3925
3973
|
if (multiple) {
|
|
3926
3974
|
return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
|
|
@@ -3946,21 +3994,21 @@ function SelectWidget({
|
|
|
3946
3994
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
3947
3995
|
const emptyValue = multiple ? [] : "";
|
|
3948
3996
|
const optionValueFormat = (0, import_utils43.getOptionValueFormat)(options);
|
|
3949
|
-
const handleFocus = (0,
|
|
3997
|
+
const handleFocus = (0, import_react24.useCallback)(
|
|
3950
3998
|
(event) => {
|
|
3951
3999
|
const newValue = getValue(event, multiple);
|
|
3952
4000
|
return onFocus(id, (0, import_utils43.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
3953
4001
|
},
|
|
3954
4002
|
[onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
3955
4003
|
);
|
|
3956
|
-
const handleBlur = (0,
|
|
4004
|
+
const handleBlur = (0, import_react24.useCallback)(
|
|
3957
4005
|
(event) => {
|
|
3958
4006
|
const newValue = getValue(event, multiple);
|
|
3959
4007
|
return onBlur(id, (0, import_utils43.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
3960
4008
|
},
|
|
3961
4009
|
[onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
3962
4010
|
);
|
|
3963
|
-
const handleChange = (0,
|
|
4011
|
+
const handleChange = (0, import_react24.useCallback)(
|
|
3964
4012
|
(event) => {
|
|
3965
4013
|
const newValue = getValue(event, multiple);
|
|
3966
4014
|
return onChange((0, import_utils43.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
@@ -3975,7 +4023,6 @@ function SelectWidget({
|
|
|
3975
4023
|
id,
|
|
3976
4024
|
name: htmlName || id,
|
|
3977
4025
|
multiple,
|
|
3978
|
-
role: "combobox",
|
|
3979
4026
|
className: "form-control",
|
|
3980
4027
|
value: selectValue,
|
|
3981
4028
|
required,
|
|
@@ -3987,9 +4034,17 @@ function SelectWidget({
|
|
|
3987
4034
|
"aria-describedby": (0, import_utils43.ariaDescribedByIds)(id),
|
|
3988
4035
|
children: [
|
|
3989
4036
|
showPlaceholderOption && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("option", { value: "", children: placeholder }),
|
|
3990
|
-
Array.isArray(enumOptions) && enumOptions.map(({ value:
|
|
3991
|
-
const
|
|
3992
|
-
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4037
|
+
Array.isArray(enumOptions) && enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
|
|
4038
|
+
const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
|
|
4039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4040
|
+
"option",
|
|
4041
|
+
{
|
|
4042
|
+
value: (0, import_utils43.enumOptionValueEncoder)(enumValue, i, optionValueFormat),
|
|
4043
|
+
disabled: isDisabled,
|
|
4044
|
+
children: enumLabel
|
|
4045
|
+
},
|
|
4046
|
+
String(enumValue)
|
|
4047
|
+
);
|
|
3993
4048
|
})
|
|
3994
4049
|
]
|
|
3995
4050
|
}
|
|
@@ -3998,7 +4053,7 @@ function SelectWidget({
|
|
|
3998
4053
|
var SelectWidget_default = SelectWidget;
|
|
3999
4054
|
|
|
4000
4055
|
// src/components/widgets/TextareaWidget.tsx
|
|
4001
|
-
var
|
|
4056
|
+
var import_react25 = require("react");
|
|
4002
4057
|
var import_utils44 = require("@rjsf/utils");
|
|
4003
4058
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
4004
4059
|
function TextareaWidget({
|
|
@@ -4015,15 +4070,15 @@ function TextareaWidget({
|
|
|
4015
4070
|
onFocus,
|
|
4016
4071
|
htmlName
|
|
4017
4072
|
}) {
|
|
4018
|
-
const handleChange = (0,
|
|
4019
|
-
({ target: { value:
|
|
4073
|
+
const handleChange = (0, import_react25.useCallback)(
|
|
4074
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
4020
4075
|
[onChange, options.emptyValue]
|
|
4021
4076
|
);
|
|
4022
|
-
const handleBlur = (0,
|
|
4077
|
+
const handleBlur = (0, import_react25.useCallback)(
|
|
4023
4078
|
({ target }) => onBlur(id, target && target.value),
|
|
4024
4079
|
[onBlur, id]
|
|
4025
4080
|
);
|
|
4026
|
-
const handleFocus = (0,
|
|
4081
|
+
const handleFocus = (0, import_react25.useCallback)(
|
|
4027
4082
|
({ target }) => onFocus(id, target && target.value),
|
|
4028
4083
|
[id, onFocus]
|
|
4029
4084
|
);
|
|
@@ -4033,7 +4088,7 @@ function TextareaWidget({
|
|
|
4033
4088
|
id,
|
|
4034
4089
|
name: htmlName || id,
|
|
4035
4090
|
className: "form-control",
|
|
4036
|
-
value: value
|
|
4091
|
+
value: value || "",
|
|
4037
4092
|
placeholder,
|
|
4038
4093
|
required,
|
|
4039
4094
|
disabled,
|
|
@@ -4059,13 +4114,13 @@ function TextWidget(props) {
|
|
|
4059
4114
|
}
|
|
4060
4115
|
|
|
4061
4116
|
// src/components/widgets/TimeWidget.tsx
|
|
4062
|
-
var
|
|
4117
|
+
var import_react26 = require("react");
|
|
4063
4118
|
var import_utils46 = require("@rjsf/utils");
|
|
4064
4119
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
4065
4120
|
function TimeWidget(props) {
|
|
4066
4121
|
const { onChange, options, registry } = props;
|
|
4067
4122
|
const BaseInputTemplate2 = (0, import_utils46.getTemplate)("BaseInputTemplate", registry, options);
|
|
4068
|
-
const handleChange = (0,
|
|
4123
|
+
const handleChange = (0, import_react26.useCallback)((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
4069
4124
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
4070
4125
|
}
|
|
4071
4126
|
|
|
@@ -4139,7 +4194,7 @@ function toIChangeEvent(state, status) {
|
|
|
4139
4194
|
...status !== void 0 && { status }
|
|
4140
4195
|
};
|
|
4141
4196
|
}
|
|
4142
|
-
var Form = class extends
|
|
4197
|
+
var Form = class _Form extends import_react27.Component {
|
|
4143
4198
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4144
4199
|
* provide any possible type here
|
|
4145
4200
|
*/
|
|
@@ -4150,7 +4205,7 @@ var Form = class extends import_react23.Component {
|
|
|
4150
4205
|
/** Flag to track when we're processing a user-initiated field change.
|
|
4151
4206
|
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
4152
4207
|
*/
|
|
4153
|
-
|
|
4208
|
+
isProcessingUserChange = false;
|
|
4154
4209
|
/** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
|
|
4155
4210
|
* state before render, ensuring the updated errors are visible immediately in a single render cycle.
|
|
4156
4211
|
*
|
|
@@ -4159,7 +4214,7 @@ var Form = class extends import_react23.Component {
|
|
|
4159
4214
|
* @returns Partial state with re-merged errors if `extraErrors` changed, or `null` if no update is needed
|
|
4160
4215
|
*/
|
|
4161
4216
|
static getDerivedStateFromProps(props, state) {
|
|
4162
|
-
if (props.extraErrors !== state.
|
|
4217
|
+
if (props.extraErrors !== state.prevExtraErrors) {
|
|
4163
4218
|
const baseErrors = {
|
|
4164
4219
|
errors: state.schemaValidationErrors || [],
|
|
4165
4220
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -4175,7 +4230,7 @@ var Form = class extends import_react23.Component {
|
|
|
4175
4230
|
true
|
|
4176
4231
|
));
|
|
4177
4232
|
}
|
|
4178
|
-
return {
|
|
4233
|
+
return { prevExtraErrors: props.extraErrors, errors, errorSchema };
|
|
4179
4234
|
}
|
|
4180
4235
|
return null;
|
|
4181
4236
|
}
|
|
@@ -4194,12 +4249,12 @@ var Form = class extends import_react23.Component {
|
|
|
4194
4249
|
const formData = propsFormData ?? initialFormData;
|
|
4195
4250
|
this.state = {
|
|
4196
4251
|
...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
|
|
4197
|
-
|
|
4252
|
+
prevExtraErrors: props.extraErrors
|
|
4198
4253
|
};
|
|
4199
4254
|
if (onChange && !(0, import_utils50.deepEquals)(this.state.formData, formData)) {
|
|
4200
4255
|
onChange(toIChangeEvent(this.state));
|
|
4201
4256
|
}
|
|
4202
|
-
this.formElement = (0,
|
|
4257
|
+
this.formElement = (0, import_react27.createRef)();
|
|
4203
4258
|
}
|
|
4204
4259
|
/**
|
|
4205
4260
|
* `getSnapshotBeforeUpdate` is a React lifecycle method that is invoked right before the most recently rendered
|
|
@@ -4259,8 +4314,8 @@ var Form = class extends import_react23.Component {
|
|
|
4259
4314
|
if (snapshot.shouldUpdate) {
|
|
4260
4315
|
const { nextState } = snapshot;
|
|
4261
4316
|
const nextStateDiffersFromProps = !(0, import_utils50.deepEquals)(nextState.formData, this.props.formData);
|
|
4262
|
-
const wasProcessingUserChange = this.
|
|
4263
|
-
this.
|
|
4317
|
+
const wasProcessingUserChange = this.isProcessingUserChange;
|
|
4318
|
+
this.isProcessingUserChange = false;
|
|
4264
4319
|
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
4265
4320
|
return;
|
|
4266
4321
|
}
|
|
@@ -4277,12 +4332,13 @@ var Form = class extends import_react23.Component {
|
|
|
4277
4332
|
* @param props - The props passed to the `Form`
|
|
4278
4333
|
* @param inputFormData - The new or current data for the `Form`
|
|
4279
4334
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4280
|
-
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
4281
|
-
* @param formDataChangedFields - The changed fields of `formData`
|
|
4282
|
-
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
4335
|
+
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
4336
|
+
* @param [formDataChangedFields=[]] - The changed fields of `formData`
|
|
4337
|
+
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
4338
|
+
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
4283
4339
|
* @returns - The new state for the `Form`
|
|
4284
4340
|
*/
|
|
4285
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
4341
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false, shouldSanitize = false) {
|
|
4286
4342
|
const state = this.state || {};
|
|
4287
4343
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4288
4344
|
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
@@ -4293,7 +4349,7 @@ var Form = class extends import_react23.Component {
|
|
|
4293
4349
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
4294
4350
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4295
4351
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
4296
|
-
let schemaUtils = state
|
|
4352
|
+
let { schemaUtils } = state;
|
|
4297
4353
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
4298
4354
|
validator2,
|
|
4299
4355
|
schema,
|
|
@@ -4314,19 +4370,45 @@ var Form = class extends import_react23.Component {
|
|
|
4314
4370
|
} else if (inputFormData === void 0 && isUncontrolled) {
|
|
4315
4371
|
defaultsFormData = state.formData;
|
|
4316
4372
|
}
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4373
|
+
let formData;
|
|
4374
|
+
let computedRetrievedSchema;
|
|
4375
|
+
let wasSanitized = false;
|
|
4376
|
+
const preventInfiniteSanitize = [];
|
|
4377
|
+
do {
|
|
4378
|
+
formData = schemaUtils.getDefaultFormState(
|
|
4379
|
+
rootSchema,
|
|
4380
|
+
defaultsFormData,
|
|
4381
|
+
false,
|
|
4382
|
+
state.initialDefaultsGenerated
|
|
4383
|
+
);
|
|
4384
|
+
const formHash = shouldSanitize ? (0, import_utils50.hashObject)({ formData }) : "";
|
|
4385
|
+
computedRetrievedSchema = this.updateRetrievedSchema(
|
|
4386
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4387
|
+
);
|
|
4388
|
+
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !(0, import_utils50.deepEquals)(computedRetrievedSchema, state.retrievedSchema)) {
|
|
4389
|
+
const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(
|
|
4390
|
+
computedRetrievedSchema,
|
|
4391
|
+
state.retrievedSchema,
|
|
4392
|
+
formData
|
|
4393
|
+
);
|
|
4394
|
+
wasSanitized = !(0, import_utils50.deepEquals)(sanitizedFormData, formData);
|
|
4395
|
+
if (wasSanitized) {
|
|
4396
|
+
formData = sanitizedFormData;
|
|
4397
|
+
defaultsFormData = sanitizedFormData;
|
|
4398
|
+
const sanitizedFormHash = (0, import_utils50.hashObject)({ formData: sanitizedFormData });
|
|
4399
|
+
wasSanitized = !preventInfiniteSanitize.includes(sanitizedFormHash);
|
|
4400
|
+
preventInfiniteSanitize.push(sanitizedFormHash);
|
|
4401
|
+
}
|
|
4402
|
+
preventInfiniteSanitize.push(formHash);
|
|
4403
|
+
} else {
|
|
4404
|
+
wasSanitized = false;
|
|
4405
|
+
}
|
|
4406
|
+
} while (wasSanitized);
|
|
4326
4407
|
const getCurrentErrors = () => {
|
|
4327
4408
|
if (props.noValidate || isSchemaChanged) {
|
|
4328
4409
|
return { errors: [], errorSchema: {} };
|
|
4329
|
-
}
|
|
4410
|
+
}
|
|
4411
|
+
if (!props.liveValidate) {
|
|
4330
4412
|
return {
|
|
4331
4413
|
errors: state.schemaValidationErrors || [],
|
|
4332
4414
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -4339,8 +4421,7 @@ var Form = class extends import_react23.Component {
|
|
|
4339
4421
|
};
|
|
4340
4422
|
let errors;
|
|
4341
4423
|
let errorSchema;
|
|
4342
|
-
let schemaValidationErrors = state
|
|
4343
|
-
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
4424
|
+
let { schemaValidationErrors, schemaValidationErrorSchema } = state;
|
|
4344
4425
|
if (mustValidate && !skipLiveValidate) {
|
|
4345
4426
|
const liveValidation = this.liveValidate(
|
|
4346
4427
|
rootSchema,
|
|
@@ -4363,24 +4444,22 @@ var Form = class extends import_react23.Component {
|
|
|
4363
4444
|
errors = currentErrors.errors;
|
|
4364
4445
|
errorSchema = currentErrors.errorSchema;
|
|
4365
4446
|
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
4366
|
-
const newErrorSchema = formDataChangedFields.reduce(
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
{}
|
|
4372
|
-
);
|
|
4373
|
-
errorSchema = schemaValidationErrorSchema = (0, import_utils50.mergeObjects)(
|
|
4447
|
+
const newErrorSchema = formDataChangedFields.reduce((acc, key) => {
|
|
4448
|
+
acc[key] = void 0;
|
|
4449
|
+
return acc;
|
|
4450
|
+
}, {});
|
|
4451
|
+
schemaValidationErrorSchema = (0, import_utils50.mergeObjects)(
|
|
4374
4452
|
currentErrors.errorSchema,
|
|
4375
4453
|
newErrorSchema,
|
|
4376
4454
|
"preventDuplicates"
|
|
4377
4455
|
);
|
|
4456
|
+
errorSchema = schemaValidationErrorSchema;
|
|
4378
4457
|
}
|
|
4379
|
-
const mergedErrors =
|
|
4458
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
4380
4459
|
errors = mergedErrors.errors;
|
|
4381
4460
|
errorSchema = mergedErrors.errorSchema;
|
|
4382
4461
|
}
|
|
4383
|
-
const newRegistry =
|
|
4462
|
+
const newRegistry = _Form.getRegistry(props, rootSchema, schemaUtils);
|
|
4384
4463
|
const registry = (0, import_utils50.deepEquals)(state.registry, newRegistry) ? state.registry : newRegistry;
|
|
4385
4464
|
const fieldPathId = state.fieldPathId && state.fieldPathId?.[import_utils50.ID_KEY] === registry.globalFormOptions.idPrefix ? state.fieldPathId : (0, import_utils50.toFieldPathId)("", registry.globalFormOptions);
|
|
4386
4465
|
const nextState = {
|
|
@@ -4394,7 +4473,7 @@ var Form = class extends import_react23.Component {
|
|
|
4394
4473
|
errorSchema,
|
|
4395
4474
|
schemaValidationErrors,
|
|
4396
4475
|
schemaValidationErrorSchema,
|
|
4397
|
-
retrievedSchema:
|
|
4476
|
+
retrievedSchema: computedRetrievedSchema,
|
|
4398
4477
|
initialDefaultsGenerated: true,
|
|
4399
4478
|
registry
|
|
4400
4479
|
};
|
|
@@ -4419,10 +4498,10 @@ var Form = class extends import_react23.Component {
|
|
|
4419
4498
|
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
4420
4499
|
*/
|
|
4421
4500
|
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
4422
|
-
const schemaUtils = altSchemaUtils
|
|
4501
|
+
const schemaUtils = altSchemaUtils || this.state.schemaUtils;
|
|
4423
4502
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4424
|
-
const
|
|
4425
|
-
return schemaUtils.getValidator().validateFormData(formData,
|
|
4503
|
+
const validationSchema = retrievedSchema ?? schema;
|
|
4504
|
+
return schemaUtils.getValidator().validateFormData(formData, validationSchema, customValidate, transformErrors, uiSchema);
|
|
4426
4505
|
}
|
|
4427
4506
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4428
4507
|
renderErrors(registry) {
|
|
@@ -4451,9 +4530,8 @@ var Form = class extends import_react23.Component {
|
|
|
4451
4530
|
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
4452
4531
|
* @private
|
|
4453
4532
|
*/
|
|
4454
|
-
mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4455
|
-
let errorSchema = schemaValidation
|
|
4456
|
-
let errors = schemaValidation.errors;
|
|
4533
|
+
static mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4534
|
+
let { errorSchema, errors } = schemaValidation;
|
|
4457
4535
|
if (extraErrors) {
|
|
4458
4536
|
const merged = (0, import_utils50.validationDataMerge)(schemaValidation, extraErrors);
|
|
4459
4537
|
errorSchema = merged.errorSchema;
|
|
@@ -4482,8 +4560,8 @@ var Form = class extends import_react23.Component {
|
|
|
4482
4560
|
*/
|
|
4483
4561
|
liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
|
|
4484
4562
|
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
|
|
4485
|
-
const errors = schemaValidation
|
|
4486
|
-
let errorSchema = schemaValidation
|
|
4563
|
+
const { errors } = schemaValidation;
|
|
4564
|
+
let { errorSchema } = schemaValidation;
|
|
4487
4565
|
if (mergeIntoOriginalErrorSchema) {
|
|
4488
4566
|
errorSchema = (0, import_utils50.mergeObjects)(
|
|
4489
4567
|
originalErrorSchema,
|
|
@@ -4493,7 +4571,7 @@ var Form = class extends import_react23.Component {
|
|
|
4493
4571
|
}
|
|
4494
4572
|
const schemaValidationErrors = errors;
|
|
4495
4573
|
const schemaValidationErrorSchema = errorSchema;
|
|
4496
|
-
const mergedErrors =
|
|
4574
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
|
|
4497
4575
|
return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
|
|
4498
4576
|
}
|
|
4499
4577
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
@@ -4502,18 +4580,16 @@ var Form = class extends import_react23.Component {
|
|
|
4502
4580
|
* @param fields - The fields to keep while filtering
|
|
4503
4581
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4504
4582
|
*/
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
};
|
|
4583
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4584
|
+
getUsedFormData = (formData, fields2) => (0, import_utils50.getUsedFormData)(formData, fields2);
|
|
4508
4585
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
4509
4586
|
*
|
|
4510
4587
|
* @param pathSchema - The `PathSchema` object for the form
|
|
4511
4588
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4512
4589
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4513
4590
|
*/
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
};
|
|
4591
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4592
|
+
getFieldNames = (pathSchema, formData) => (0, import_utils50.getFieldNames)(pathSchema, formData);
|
|
4517
4593
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
4518
4594
|
*
|
|
4519
4595
|
* @param formData - The data for the `Form`
|
|
@@ -4565,16 +4641,15 @@ var Form = class extends import_react23.Component {
|
|
|
4565
4641
|
if (this.pendingChanges.length === 0) {
|
|
4566
4642
|
return;
|
|
4567
4643
|
}
|
|
4568
|
-
this.
|
|
4644
|
+
this.isProcessingUserChange = true;
|
|
4569
4645
|
const { newValue, path, id } = this.pendingChanges[0];
|
|
4570
4646
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
4571
|
-
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4647
|
+
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, disabled, readonly } = this.props;
|
|
4572
4648
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
4573
|
-
let { customErrors } = this.state;
|
|
4649
|
+
let { customErrors, retrievedSchema } = this.state;
|
|
4574
4650
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
4575
4651
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4576
4652
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4577
|
-
let retrievedSchema = this.state.retrievedSchema;
|
|
4578
4653
|
let formData = isRootPath ? newValue : (0, import_cloneDeep2.default)(oldFormData);
|
|
4579
4654
|
const hasOnlyUndefinedValues = (0, import_utils50.isObject)(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
|
|
4580
4655
|
const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
|
|
@@ -4604,18 +4679,25 @@ var Form = class extends import_react23.Component {
|
|
|
4604
4679
|
(0, import_set5.default)(formData, path, valueForPath);
|
|
4605
4680
|
}
|
|
4606
4681
|
}
|
|
4607
|
-
const
|
|
4682
|
+
const shouldSanitize = retrievedSchema && !isRootPath && !(0, import_utils50.isObject)(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
4683
|
+
const newState = this.getStateFromProps(
|
|
4684
|
+
this.props,
|
|
4685
|
+
inputForDefaults,
|
|
4686
|
+
void 0,
|
|
4687
|
+
void 0,
|
|
4688
|
+
void 0,
|
|
4689
|
+
true,
|
|
4690
|
+
shouldSanitize
|
|
4691
|
+
);
|
|
4608
4692
|
formData = newState.formData;
|
|
4609
4693
|
retrievedSchema = newState.retrievedSchema;
|
|
4610
4694
|
}
|
|
4611
4695
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
|
|
4612
|
-
let state = { formData,
|
|
4696
|
+
let state = { formData, retrievedSchema };
|
|
4613
4697
|
let newFormData = formData;
|
|
4614
4698
|
if (omitExtraData === true && (liveOmit === true || liveOmit === "onChange")) {
|
|
4615
4699
|
newFormData = this.omitExtraData(formData);
|
|
4616
|
-
state = {
|
|
4617
|
-
formData: newFormData
|
|
4618
|
-
};
|
|
4700
|
+
state = { ...state, formData: newFormData };
|
|
4619
4701
|
}
|
|
4620
4702
|
if (newErrorSchema) {
|
|
4621
4703
|
const oldValidationError = !isRootPath ? (0, import_get5.default)(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
@@ -4631,9 +4713,9 @@ var Form = class extends import_react23.Component {
|
|
|
4631
4713
|
customErrors = new import_utils50.ErrorSchemaBuilder();
|
|
4632
4714
|
}
|
|
4633
4715
|
if (isRootPath) {
|
|
4634
|
-
const
|
|
4635
|
-
if (
|
|
4636
|
-
customErrors.setErrors(
|
|
4716
|
+
const pathErrors = (0, import_get5.default)(newErrorSchema, import_utils50.ERRORS_KEY);
|
|
4717
|
+
if (pathErrors) {
|
|
4718
|
+
customErrors.setErrors(pathErrors);
|
|
4637
4719
|
}
|
|
4638
4720
|
} else {
|
|
4639
4721
|
(0, import_set5.default)(customErrors.ErrorSchema, path, newErrorSchema);
|
|
@@ -4652,14 +4734,14 @@ var Form = class extends import_react23.Component {
|
|
|
4652
4734
|
customErrors,
|
|
4653
4735
|
retrievedSchema
|
|
4654
4736
|
);
|
|
4655
|
-
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
4737
|
+
state = { ...state, formData: newFormData, ...liveValidation, customErrors };
|
|
4656
4738
|
} else if (!noValidate && newErrorSchema) {
|
|
4657
|
-
const mergedErrors =
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
...mergedErrors,
|
|
4739
|
+
const mergedErrors = _Form.mergeErrors(
|
|
4740
|
+
{ errorSchema: mergeBaseErrorSchema, errors },
|
|
4741
|
+
extraErrors,
|
|
4661
4742
|
customErrors
|
|
4662
|
-
|
|
4743
|
+
);
|
|
4744
|
+
state = { ...state, formData: newFormData, ...mergedErrors, customErrors };
|
|
4663
4745
|
}
|
|
4664
4746
|
this.setState(state, () => {
|
|
4665
4747
|
if (onChange) {
|
|
@@ -4812,7 +4894,7 @@ var Form = class extends import_react23.Component {
|
|
|
4812
4894
|
* @returns - The `GlobalFormOptions` from the props
|
|
4813
4895
|
* @private
|
|
4814
4896
|
*/
|
|
4815
|
-
getGlobalFormOptions(props) {
|
|
4897
|
+
static getGlobalFormOptions(props) {
|
|
4816
4898
|
const {
|
|
4817
4899
|
uiSchema = {},
|
|
4818
4900
|
experimental_componentUpdateStrategy,
|
|
@@ -4831,7 +4913,7 @@ var Form = class extends import_react23.Component {
|
|
|
4831
4913
|
};
|
|
4832
4914
|
}
|
|
4833
4915
|
/** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
|
|
4834
|
-
getRegistry(props, schema, schemaUtils) {
|
|
4916
|
+
static getRegistry(props, schema, schemaUtils) {
|
|
4835
4917
|
const { translateString: customTranslateString, uiSchema = {} } = props;
|
|
4836
4918
|
const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
|
|
4837
4919
|
return {
|
|
@@ -4850,7 +4932,7 @@ var Form = class extends import_react23.Component {
|
|
|
4850
4932
|
schemaUtils,
|
|
4851
4933
|
translateString: customTranslateString || translateString,
|
|
4852
4934
|
globalUiOptions: uiSchema[import_utils50.UI_GLOBAL_OPTIONS_KEY],
|
|
4853
|
-
globalFormOptions:
|
|
4935
|
+
globalFormOptions: _Form.getGlobalFormOptions(props),
|
|
4854
4936
|
uiSchemaDefinitions: uiSchema[import_utils50.UI_DEFINITIONS_KEY] ?? {}
|
|
4855
4937
|
};
|
|
4856
4938
|
}
|
|
@@ -4902,7 +4984,7 @@ var Form = class extends import_react23.Component {
|
|
|
4902
4984
|
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
4903
4985
|
const { errors: prevErrors } = this.state;
|
|
4904
4986
|
const schemaValidation = this.validate(formData);
|
|
4905
|
-
const { errors, errorSchema } = extraErrors ?
|
|
4987
|
+
const { errors, errorSchema } = extraErrors ? _Form.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
|
|
4906
4988
|
const hasError = schemaValidation.errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
4907
4989
|
if (hasError) {
|
|
4908
4990
|
if (focusOnFirstError) {
|
|
@@ -4981,7 +5063,7 @@ var Form = class extends import_react23.Component {
|
|
|
4981
5063
|
_internalFormWrapper
|
|
4982
5064
|
} = this.props;
|
|
4983
5065
|
const { schema, uiSchema, formData, errorSchema, fieldPathId, registry } = this.state;
|
|
4984
|
-
const { SchemaField:
|
|
5066
|
+
const { SchemaField: SchemaFieldComponent } = registry.fields;
|
|
4985
5067
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
4986
5068
|
const as = _internalFormWrapper ? tagName : void 0;
|
|
4987
5069
|
const FormTag = _internalFormWrapper || tagName || "form";
|
|
@@ -4993,7 +5075,7 @@ var Form = class extends import_react23.Component {
|
|
|
4993
5075
|
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
|
|
4994
5076
|
FormTag,
|
|
4995
5077
|
{
|
|
4996
|
-
className: className
|
|
5078
|
+
className: className || "rjsf",
|
|
4997
5079
|
id,
|
|
4998
5080
|
name,
|
|
4999
5081
|
method,
|
|
@@ -5009,7 +5091,7 @@ var Form = class extends import_react23.Component {
|
|
|
5009
5091
|
children: [
|
|
5010
5092
|
showErrorList === "top" && this.renderErrors(registry),
|
|
5011
5093
|
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
5012
|
-
|
|
5094
|
+
SchemaFieldComponent,
|
|
5013
5095
|
{
|
|
5014
5096
|
name: "",
|
|
5015
5097
|
schema,
|
|
@@ -5025,7 +5107,7 @@ var Form = class extends import_react23.Component {
|
|
|
5025
5107
|
readonly
|
|
5026
5108
|
}
|
|
5027
5109
|
),
|
|
5028
|
-
children
|
|
5110
|
+
children || /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
5029
5111
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
5030
5112
|
]
|
|
5031
5113
|
}
|
|
@@ -5056,19 +5138,19 @@ function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {
|
|
|
5056
5138
|
}
|
|
5057
5139
|
|
|
5058
5140
|
// src/withTheme.tsx
|
|
5059
|
-
var
|
|
5141
|
+
var import_react28 = require("react");
|
|
5060
5142
|
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
5061
5143
|
function withTheme(themeProps) {
|
|
5062
|
-
return (0,
|
|
5063
|
-
({ fields:
|
|
5064
|
-
fields2 = { ...themeProps?.fields, ...
|
|
5065
|
-
widgets2 = { ...themeProps?.widgets, ...
|
|
5066
|
-
templates2 = {
|
|
5144
|
+
return (0, import_react28.forwardRef)(
|
|
5145
|
+
({ fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }, ref) => {
|
|
5146
|
+
const fields2 = { ...themeProps?.fields, ...propFields };
|
|
5147
|
+
const widgets2 = { ...themeProps?.widgets, ...propWidgets };
|
|
5148
|
+
const templates2 = {
|
|
5067
5149
|
...themeProps?.templates,
|
|
5068
|
-
...
|
|
5150
|
+
...propTemplates,
|
|
5069
5151
|
ButtonTemplates: {
|
|
5070
5152
|
...themeProps?.templates?.ButtonTemplates,
|
|
5071
|
-
...
|
|
5153
|
+
...propTemplates?.ButtonTemplates
|
|
5072
5154
|
}
|
|
5073
5155
|
};
|
|
5074
5156
|
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|