@rjsf/core 6.6.1 → 6.7.0
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/LICENSE.md +201 -0
- package/dist/core.umd.js +694 -584
- package/dist/index.cjs +1191 -1071
- package/dist/index.cjs.map +4 -4
- package/dist/index.esm.js +1030 -984
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +16 -13
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +126 -76
- package/lib/components/RichDescription.d.ts +3 -3
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.d.ts +3 -3
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/SchemaExamples.d.ts +2 -2
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/SchemaExamples.js +1 -3
- package/lib/components/fields/ArrayField.d.ts +2 -2
- 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 +2 -2
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -5
- package/lib/components/fields/CyclicSchemaField.d.ts +8 -0
- package/lib/components/fields/CyclicSchemaField.d.ts.map +1 -0
- package/lib/components/fields/CyclicSchemaField.js +21 -0
- package/lib/components/fields/FallbackField.d.ts +2 -2
- 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 +8 -10
- 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 +2 -2
- 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 +2 -2
- 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 +2 -41
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +116 -122
- 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 +2 -2
- 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 +2 -2
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +28 -26
- package/lib/components/fields/OptionalDataControlsField.d.ts +2 -2
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +14 -8
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +43 -30
- package/lib/components/fields/StringField.d.ts +2 -2
- 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/fields/index.js +2 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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/CyclicSchemaExpandTemplate.d.ts +7 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts.map +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js +12 -0
- package/lib/components/templates/DescriptionField.d.ts +2 -2
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +2 -2
- 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 +2 -2
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +2 -2
- 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 +2 -2
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +2 -2
- 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 +3 -3
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +2 -2
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +2 -2
- 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 +2 -2
- 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 +2 -2
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +2 -2
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +2 -2
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +2 -2
- 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/templates/index.js +2 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts +2 -2
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +2 -2
- 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 +2 -2
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +2 -2
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +4 -4
- package/lib/components/widgets/ColorWidget.d.ts +2 -2
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +2 -2
- 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 +2 -2
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +2 -2
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +2 -2
- 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 +2 -2
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +2 -2
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +2 -2
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +4 -4
- package/lib/components/widgets/RangeWidget.d.ts +2 -2
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +2 -2
- 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 +2 -2
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +9 -8
- package/lib/components/widgets/TextWidget.d.ts +2 -2
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +2 -2
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +5 -5
- package/lib/components/widgets/TimeWidget.d.ts +2 -2
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +2 -2
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +2 -2
- 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 +28 -28
- package/src/components/Form.tsx +197 -111
- 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/CyclicSchemaField.tsx +40 -0
- 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 +202 -218
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +8 -10
- package/src/components/fields/ObjectField.tsx +52 -40
- package/src/components/fields/OptionalDataControlsField.tsx +6 -4
- package/src/components/fields/SchemaField.tsx +66 -51
- package/src/components/fields/StringField.tsx +4 -15
- package/src/components/fields/index.ts +3 -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 +16 -23
- 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/CyclicSchemaExpandTemplate.tsx +31 -0
- 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 +4 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/templates/index.ts +3 -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 +8 -10
- 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 +8 -10
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +48 -47
- package/src/components/widgets/SelectWidget.tsx +48 -31
- package/src/components/widgets/TextWidget.tsx +2 -1
- package/src/components/widgets/TextareaWidget.tsx +10 -7
- 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.esm.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// src/components/Form.tsx
|
|
2
|
-
import { Component
|
|
2
|
+
import { Component, createRef } from "react";
|
|
3
3
|
import {
|
|
4
4
|
createSchemaUtils,
|
|
5
|
-
deepEquals as
|
|
5
|
+
deepEquals as deepEquals3,
|
|
6
6
|
ErrorSchemaBuilder,
|
|
7
7
|
getChangedFields,
|
|
8
|
-
getTemplate as
|
|
9
|
-
getUiOptions as
|
|
8
|
+
getTemplate as getTemplate29,
|
|
9
|
+
getUiOptions as getUiOptions22,
|
|
10
|
+
hashObject as hashObject6,
|
|
10
11
|
isObject as isObject6,
|
|
11
12
|
mergeObjects,
|
|
12
|
-
shouldRender
|
|
13
|
+
shouldRender,
|
|
13
14
|
SUBMIT_BTN_OPTIONS_KEY,
|
|
14
15
|
toErrorList,
|
|
15
16
|
toFieldPathId as toFieldPathId6,
|
|
@@ -20,7 +21,7 @@ import {
|
|
|
20
21
|
DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR2,
|
|
21
22
|
DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX2,
|
|
22
23
|
ERRORS_KEY as ERRORS_KEY3,
|
|
23
|
-
ID_KEY as
|
|
24
|
+
ID_KEY as ID_KEY6,
|
|
24
25
|
getUsedFormData,
|
|
25
26
|
getFieldNames,
|
|
26
27
|
ANY_OF_KEY as ANY_OF_KEY6,
|
|
@@ -35,14 +36,10 @@ import _toPath from "lodash/toPath";
|
|
|
35
36
|
import _unset from "lodash/unset";
|
|
36
37
|
|
|
37
38
|
// src/getDefaultRegistry.ts
|
|
38
|
-
import {
|
|
39
|
-
DEFAULT_ID_PREFIX,
|
|
40
|
-
DEFAULT_ID_SEPARATOR,
|
|
41
|
-
englishStringTranslator
|
|
42
|
-
} from "@rjsf/utils";
|
|
39
|
+
import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator } from "@rjsf/utils";
|
|
43
40
|
|
|
44
41
|
// src/components/fields/ArrayField.tsx
|
|
45
|
-
import { useCallback, useMemo, useState } from "react";
|
|
42
|
+
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
46
43
|
import {
|
|
47
44
|
allowAdditionalItems,
|
|
48
45
|
getTemplate,
|
|
@@ -69,12 +66,10 @@ function generateRowId() {
|
|
|
69
66
|
return uniqueId("rjsf-array-item-");
|
|
70
67
|
}
|
|
71
68
|
function generateKeyedFormData(formData) {
|
|
72
|
-
return !Array.isArray(formData) ? [] : formData.map((item) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
});
|
|
69
|
+
return !Array.isArray(formData) ? [] : formData.map((item) => ({
|
|
70
|
+
key: generateRowId(),
|
|
71
|
+
item
|
|
72
|
+
}));
|
|
78
73
|
}
|
|
79
74
|
function keyedToPlainFormData(keyedFormData) {
|
|
80
75
|
if (Array.isArray(keyedFormData)) {
|
|
@@ -275,7 +270,7 @@ function ArrayAsFiles(props) {
|
|
|
275
270
|
}
|
|
276
271
|
);
|
|
277
272
|
}
|
|
278
|
-
function
|
|
273
|
+
function ArrayFieldItemInner(props) {
|
|
279
274
|
const {
|
|
280
275
|
itemKey,
|
|
281
276
|
index,
|
|
@@ -290,10 +285,10 @@ function ArrayFieldItem(props) {
|
|
|
290
285
|
canRemove = true,
|
|
291
286
|
canMoveUp,
|
|
292
287
|
canMoveDown,
|
|
293
|
-
|
|
288
|
+
rawItemSchema,
|
|
294
289
|
itemData,
|
|
295
290
|
itemUiSchema,
|
|
296
|
-
|
|
291
|
+
parentFieldPathId,
|
|
297
292
|
itemErrorSchema,
|
|
298
293
|
autofocus,
|
|
299
294
|
onBlur,
|
|
@@ -310,9 +305,17 @@ function ArrayFieldItem(props) {
|
|
|
310
305
|
const {
|
|
311
306
|
schemaUtils,
|
|
312
307
|
fields: { ArraySchemaField, SchemaField: SchemaField2 },
|
|
313
|
-
globalUiOptions
|
|
308
|
+
globalUiOptions,
|
|
309
|
+
globalFormOptions
|
|
314
310
|
} = registry;
|
|
315
|
-
const
|
|
311
|
+
const itemSchema = useMemo(
|
|
312
|
+
() => schemaUtils.retrieveSchema(rawItemSchema, itemData),
|
|
313
|
+
[schemaUtils, rawItemSchema, itemData]
|
|
314
|
+
);
|
|
315
|
+
const fieldPathId = useMemo(
|
|
316
|
+
() => toFieldPathId(index, globalFormOptions, parentFieldPathId),
|
|
317
|
+
[index, globalFormOptions, parentFieldPathId]
|
|
318
|
+
);
|
|
316
319
|
const ItemSchemaField = ArraySchemaField || SchemaField2;
|
|
317
320
|
const ArrayFieldItemTemplate2 = getTemplate(
|
|
318
321
|
"ArrayFieldItemTemplate",
|
|
@@ -421,6 +424,7 @@ function ArrayFieldItem(props) {
|
|
|
421
424
|
};
|
|
422
425
|
return /* @__PURE__ */ jsx(ArrayFieldItemTemplate2, { ...templateProps });
|
|
423
426
|
}
|
|
427
|
+
var ArrayFieldItem = memo(ArrayFieldItemInner);
|
|
424
428
|
function NormalArray(props) {
|
|
425
429
|
const {
|
|
426
430
|
schema,
|
|
@@ -447,15 +451,18 @@ function NormalArray(props) {
|
|
|
447
451
|
handleReorderItems
|
|
448
452
|
} = props;
|
|
449
453
|
const fieldTitle = schema.title || title || name;
|
|
450
|
-
const { schemaUtils, fields: fields2, formContext,
|
|
454
|
+
const { schemaUtils, fields: fields2, formContext, globalUiOptions } = registry;
|
|
451
455
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
452
|
-
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
453
|
-
const
|
|
454
|
-
const itemsSchema = schemaUtils.retrieveSchema(
|
|
455
|
-
const formData = keyedToPlainFormData(keyedFormData);
|
|
456
|
+
const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
457
|
+
const schemaItems = useMemo(() => isObject(schema.items) ? schema.items : {}, [schema.items]);
|
|
458
|
+
const itemsSchema = useMemo(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
|
|
459
|
+
const formData = useMemo(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
|
|
456
460
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
457
461
|
const hasFormData = isFormDataAvailable(formDataFromProps);
|
|
458
|
-
const canAdd =
|
|
462
|
+
const canAdd = useMemo(
|
|
463
|
+
() => canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData),
|
|
464
|
+
[registry, schema, formData, uiSchema, renderOptionalField, hasFormData]
|
|
465
|
+
);
|
|
459
466
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
460
467
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
461
468
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
@@ -465,9 +472,7 @@ function NormalArray(props) {
|
|
|
465
472
|
items: actualFormData.map((keyedItem, index) => {
|
|
466
473
|
const { key, item } = keyedItem;
|
|
467
474
|
const itemCast = item;
|
|
468
|
-
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
469
475
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
470
|
-
const itemFieldPathId = toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
471
476
|
const itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
472
477
|
const itemProps = {
|
|
473
478
|
itemKey: key,
|
|
@@ -484,8 +489,8 @@ function NormalArray(props) {
|
|
|
484
489
|
canAdd,
|
|
485
490
|
canMoveUp: index > 0,
|
|
486
491
|
canMoveDown: index < formData.length - 1,
|
|
487
|
-
|
|
488
|
-
|
|
492
|
+
rawItemSchema: schemaItems,
|
|
493
|
+
parentFieldPathId: childFieldPathId,
|
|
489
494
|
itemErrorSchema,
|
|
490
495
|
itemData: itemCast,
|
|
491
496
|
itemUiSchema,
|
|
@@ -546,24 +551,24 @@ function FixedArray(props) {
|
|
|
546
551
|
} = props;
|
|
547
552
|
let { formData: items = [] } = props;
|
|
548
553
|
const fieldTitle = schema.title || title || name;
|
|
549
|
-
const {
|
|
550
|
-
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
554
|
+
const { fields: fields2, formContext, globalUiOptions } = registry;
|
|
555
|
+
const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
551
556
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
552
557
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
553
558
|
const hasFormData = isFormDataAvailable(formData);
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
|
|
559
|
+
const schemaItems = useMemo(
|
|
560
|
+
() => isObject(schema.items) ? schema.items : [],
|
|
561
|
+
[schema.items]
|
|
557
562
|
);
|
|
558
|
-
const
|
|
563
|
+
const hasAdditionalItems = isObject(schema.additionalItems);
|
|
559
564
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
560
|
-
if (items.length <
|
|
561
|
-
items = items.concat(new Array(
|
|
565
|
+
if (items.length < schemaItems.length) {
|
|
566
|
+
items = items.concat(new Array(schemaItems.length - items.length));
|
|
562
567
|
}
|
|
563
568
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
564
569
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
565
570
|
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsx(OptionalDataControlsField2, { ...props, fieldPathId: childFieldPathId }) : void 0;
|
|
566
|
-
const canAdd = canAddItem(registry, schema, items, uiSchema) &&
|
|
571
|
+
const canAdd = canAddItem(registry, schema, items, uiSchema) && hasAdditionalItems && (!renderOptionalField || hasFormData);
|
|
567
572
|
const arrayProps = {
|
|
568
573
|
canAdd,
|
|
569
574
|
className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
|
|
@@ -573,18 +578,15 @@ function FixedArray(props) {
|
|
|
573
578
|
items: actualFormData.map((keyedItem, index) => {
|
|
574
579
|
const { key, item } = keyedItem;
|
|
575
580
|
const itemCast = item;
|
|
576
|
-
const additional = index >=
|
|
577
|
-
const
|
|
578
|
-
const itemFieldPathId = toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
581
|
+
const additional = index >= schemaItems.length;
|
|
582
|
+
const rawItemSchema = (additional && isObject(schema.additionalItems) ? schema.additionalItems : schemaItems[index]) || {};
|
|
579
583
|
let itemUiSchema;
|
|
580
584
|
if (additional) {
|
|
581
585
|
itemUiSchema = uiSchema.additionalItems;
|
|
586
|
+
} else if (Array.isArray(uiSchema.items)) {
|
|
587
|
+
itemUiSchema = uiSchema.items[index];
|
|
582
588
|
} else {
|
|
583
|
-
|
|
584
|
-
itemUiSchema = uiSchema.items[index];
|
|
585
|
-
} else {
|
|
586
|
-
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
587
|
-
}
|
|
589
|
+
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
588
590
|
}
|
|
589
591
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
590
592
|
const itemProps = {
|
|
@@ -601,12 +603,12 @@ function FixedArray(props) {
|
|
|
601
603
|
title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
|
|
602
604
|
canAdd,
|
|
603
605
|
canRemove: additional,
|
|
604
|
-
canMoveUp: index >=
|
|
606
|
+
canMoveUp: index >= schemaItems.length + 1,
|
|
605
607
|
canMoveDown: additional && index < items.length - 1,
|
|
606
|
-
|
|
608
|
+
rawItemSchema,
|
|
607
609
|
itemData: itemCast,
|
|
608
610
|
itemUiSchema,
|
|
609
|
-
|
|
611
|
+
parentFieldPathId: childFieldPathId,
|
|
610
612
|
itemErrorSchema,
|
|
611
613
|
autofocus: autofocus && index === 0,
|
|
612
614
|
onBlur,
|
|
@@ -654,8 +656,8 @@ function useKeyedFormData(formData = []) {
|
|
|
654
656
|
}
|
|
655
657
|
const updateKeyedFormData = useCallback((newData) => {
|
|
656
658
|
const plainFormData = keyedToPlainFormData(newData);
|
|
657
|
-
const
|
|
658
|
-
setState({ formDataHash:
|
|
659
|
+
const updatedHash = hashObject(plainFormData);
|
|
660
|
+
setState({ formDataHash: updatedHash, keyedFormData: newData });
|
|
659
661
|
return plainFormData;
|
|
660
662
|
}, []);
|
|
661
663
|
return { keyedFormData, updateKeyedFormData };
|
|
@@ -664,6 +666,10 @@ function ArrayField(props) {
|
|
|
664
666
|
const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
|
|
665
667
|
const { globalFormOptions, schemaUtils, translateString } = registry;
|
|
666
668
|
const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
|
|
669
|
+
const keyedFormDataRef = useRef(keyedFormData);
|
|
670
|
+
keyedFormDataRef.current = keyedFormData;
|
|
671
|
+
const errorSchemaRef = useRef(errorSchema);
|
|
672
|
+
errorSchemaRef.current = errorSchema;
|
|
667
673
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
668
674
|
const handleAddItem = useCallback(
|
|
669
675
|
(event, index) => {
|
|
@@ -671,14 +677,14 @@ function ArrayField(props) {
|
|
|
671
677
|
event.preventDefault();
|
|
672
678
|
}
|
|
673
679
|
let newErrorSchema;
|
|
674
|
-
if (
|
|
680
|
+
if (errorSchemaRef.current) {
|
|
675
681
|
newErrorSchema = {};
|
|
676
|
-
for (const idx
|
|
677
|
-
const i = parseInt(idx);
|
|
682
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
683
|
+
const i = parseInt(idx, 10);
|
|
678
684
|
if (index === void 0 || i < index) {
|
|
679
|
-
set(newErrorSchema, [i],
|
|
685
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
680
686
|
} else if (i >= index) {
|
|
681
|
-
set(newErrorSchema, [i + 1],
|
|
687
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
682
688
|
}
|
|
683
689
|
}
|
|
684
690
|
}
|
|
@@ -686,7 +692,7 @@ function ArrayField(props) {
|
|
|
686
692
|
key: generateRowId(),
|
|
687
693
|
item: getNewFormDataRow(registry, schema)
|
|
688
694
|
};
|
|
689
|
-
const newKeyedFormData = [...
|
|
695
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
690
696
|
if (index !== void 0) {
|
|
691
697
|
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
692
698
|
} else {
|
|
@@ -694,7 +700,7 @@ function ArrayField(props) {
|
|
|
694
700
|
}
|
|
695
701
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
696
702
|
},
|
|
697
|
-
[
|
|
703
|
+
[registry, schema, onChange, updateKeyedFormData, childFieldPathId]
|
|
698
704
|
);
|
|
699
705
|
const handleCopyItem = useCallback(
|
|
700
706
|
(event, index) => {
|
|
@@ -702,22 +708,22 @@ function ArrayField(props) {
|
|
|
702
708
|
event.preventDefault();
|
|
703
709
|
}
|
|
704
710
|
let newErrorSchema;
|
|
705
|
-
if (
|
|
711
|
+
if (errorSchemaRef.current) {
|
|
706
712
|
newErrorSchema = {};
|
|
707
|
-
for (const idx
|
|
708
|
-
const i = parseInt(idx);
|
|
713
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
714
|
+
const i = parseInt(idx, 10);
|
|
709
715
|
if (i <= index) {
|
|
710
|
-
set(newErrorSchema, [i],
|
|
716
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
711
717
|
} else if (i > index) {
|
|
712
|
-
set(newErrorSchema, [i + 1],
|
|
718
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
713
719
|
}
|
|
714
720
|
}
|
|
715
721
|
}
|
|
716
722
|
const newKeyedFormDataRow = {
|
|
717
723
|
key: generateRowId(),
|
|
718
|
-
item: cloneDeep(
|
|
724
|
+
item: cloneDeep(keyedFormDataRef.current[index].item)
|
|
719
725
|
};
|
|
720
|
-
const newKeyedFormData = [...
|
|
726
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
721
727
|
if (index !== void 0) {
|
|
722
728
|
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
723
729
|
} else {
|
|
@@ -725,7 +731,7 @@ function ArrayField(props) {
|
|
|
725
731
|
}
|
|
726
732
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
727
733
|
},
|
|
728
|
-
[
|
|
734
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
729
735
|
);
|
|
730
736
|
const handleRemoveItem = useCallback(
|
|
731
737
|
(event, index) => {
|
|
@@ -733,21 +739,21 @@ function ArrayField(props) {
|
|
|
733
739
|
event.preventDefault();
|
|
734
740
|
}
|
|
735
741
|
let newErrorSchema;
|
|
736
|
-
if (
|
|
742
|
+
if (errorSchemaRef.current) {
|
|
737
743
|
newErrorSchema = {};
|
|
738
|
-
for (const idx
|
|
739
|
-
const i = parseInt(idx);
|
|
744
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
745
|
+
const i = parseInt(idx, 10);
|
|
740
746
|
if (i < index) {
|
|
741
|
-
set(newErrorSchema, [i],
|
|
747
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
742
748
|
} else if (i > index) {
|
|
743
|
-
set(newErrorSchema, [i - 1],
|
|
749
|
+
set(newErrorSchema, [i - 1], errorSchemaRef.current[i]);
|
|
744
750
|
}
|
|
745
751
|
}
|
|
746
752
|
}
|
|
747
|
-
const newKeyedFormData =
|
|
753
|
+
const newKeyedFormData = keyedFormDataRef.current.filter((_, i) => i !== index);
|
|
748
754
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
749
755
|
},
|
|
750
|
-
[
|
|
756
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
751
757
|
);
|
|
752
758
|
const handleReorderItems = useCallback(
|
|
753
759
|
(event, index, newIndex) => {
|
|
@@ -756,29 +762,29 @@ function ArrayField(props) {
|
|
|
756
762
|
event.currentTarget.blur();
|
|
757
763
|
}
|
|
758
764
|
let newErrorSchema;
|
|
759
|
-
if (
|
|
765
|
+
if (errorSchemaRef.current) {
|
|
760
766
|
newErrorSchema = {};
|
|
761
|
-
for (const idx
|
|
762
|
-
const i = parseInt(idx);
|
|
763
|
-
if (i
|
|
764
|
-
set(newErrorSchema, [newIndex],
|
|
765
|
-
} else if (i
|
|
766
|
-
set(newErrorSchema, [index],
|
|
767
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
768
|
+
const i = parseInt(idx, 10);
|
|
769
|
+
if (i === index) {
|
|
770
|
+
set(newErrorSchema, [newIndex], errorSchemaRef.current[index]);
|
|
771
|
+
} else if (i === newIndex) {
|
|
772
|
+
set(newErrorSchema, [index], errorSchemaRef.current[newIndex]);
|
|
767
773
|
} else {
|
|
768
|
-
set(newErrorSchema, [idx],
|
|
774
|
+
set(newErrorSchema, [idx], errorSchemaRef.current[i]);
|
|
769
775
|
}
|
|
770
776
|
}
|
|
771
777
|
}
|
|
772
778
|
function reOrderArray() {
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
return
|
|
779
|
+
const newKeyedFormData2 = keyedFormDataRef.current.slice();
|
|
780
|
+
newKeyedFormData2.splice(index, 1);
|
|
781
|
+
newKeyedFormData2.splice(newIndex, 0, keyedFormDataRef.current[index]);
|
|
782
|
+
return newKeyedFormData2;
|
|
777
783
|
}
|
|
778
784
|
const newKeyedFormData = reOrderArray();
|
|
779
785
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
780
786
|
},
|
|
781
|
-
[
|
|
787
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
782
788
|
);
|
|
783
789
|
const handleChange = useCallback(
|
|
784
790
|
(value, path, newErrorSchema, id) => {
|
|
@@ -855,12 +861,7 @@ function ArrayField(props) {
|
|
|
855
861
|
|
|
856
862
|
// src/components/fields/BooleanField.tsx
|
|
857
863
|
import { useCallback as useCallback2 } from "react";
|
|
858
|
-
import {
|
|
859
|
-
getWidget as getWidget2,
|
|
860
|
-
getUiOptions as getUiOptions2,
|
|
861
|
-
optionsList as optionsList2,
|
|
862
|
-
TranslatableString as TranslatableString2
|
|
863
|
-
} from "@rjsf/utils";
|
|
864
|
+
import { getWidget as getWidget2, getUiOptions as getUiOptions2, optionsList as optionsList2, TranslatableString as TranslatableString2 } from "@rjsf/utils";
|
|
864
865
|
import isObject2 from "lodash/isObject";
|
|
865
866
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
866
867
|
function BooleanField(props) {
|
|
@@ -931,9 +932,7 @@ function BooleanField(props) {
|
|
|
931
932
|
}
|
|
932
933
|
}
|
|
933
934
|
const onWidgetChange = useCallback2(
|
|
934
|
-
(value, errorSchema, id) =>
|
|
935
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
936
|
-
},
|
|
935
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
937
936
|
[onChange, fieldPathId]
|
|
938
937
|
);
|
|
939
938
|
return /* @__PURE__ */ jsx2(
|
|
@@ -963,17 +962,49 @@ function BooleanField(props) {
|
|
|
963
962
|
}
|
|
964
963
|
var BooleanField_default = BooleanField;
|
|
965
964
|
|
|
965
|
+
// src/components/fields/CyclicSchemaField.tsx
|
|
966
|
+
import { useState as useState2 } from "react";
|
|
967
|
+
import { getTemplate as getTemplate2, getUiOptions as getUiOptions3, RJSF_REF_CYCLE_KEY } from "@rjsf/utils";
|
|
968
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
969
|
+
function CyclicSchemaField(props) {
|
|
970
|
+
const [expanded, setExpanded] = useState2(false);
|
|
971
|
+
const { name, registry, schema, uiSchema, fieldPathId } = props;
|
|
972
|
+
const { globalUiOptions } = registry;
|
|
973
|
+
const uiOptions = getUiOptions3(uiSchema, globalUiOptions);
|
|
974
|
+
const CyclicSchemaExpandTemplate2 = getTemplate2(
|
|
975
|
+
"CyclicSchemaExpandTemplate",
|
|
976
|
+
registry,
|
|
977
|
+
uiOptions
|
|
978
|
+
);
|
|
979
|
+
if (!expanded) {
|
|
980
|
+
return /* @__PURE__ */ jsx3(
|
|
981
|
+
CyclicSchemaExpandTemplate2,
|
|
982
|
+
{
|
|
983
|
+
registry,
|
|
984
|
+
schema,
|
|
985
|
+
uiSchema,
|
|
986
|
+
name,
|
|
987
|
+
fieldPathId,
|
|
988
|
+
onExpand: () => setExpanded(true)
|
|
989
|
+
}
|
|
990
|
+
);
|
|
991
|
+
}
|
|
992
|
+
const { fields: fields2 } = registry;
|
|
993
|
+
const { SchemaField: SchemaField2 } = fields2;
|
|
994
|
+
return /* @__PURE__ */ jsx3(SchemaField2, { ...props, schema: { ...schema, [RJSF_REF_CYCLE_KEY]: false } });
|
|
995
|
+
}
|
|
996
|
+
|
|
966
997
|
// src/components/fields/FallbackField.tsx
|
|
967
|
-
import { useMemo as useMemo2, useState as
|
|
998
|
+
import { useMemo as useMemo2, useState as useState3 } from "react";
|
|
968
999
|
import {
|
|
969
|
-
getTemplate as
|
|
970
|
-
getUiOptions as
|
|
1000
|
+
getTemplate as getTemplate3,
|
|
1001
|
+
getUiOptions as getUiOptions4,
|
|
971
1002
|
hashObject as hashObject2,
|
|
972
1003
|
toFieldPathId as toFieldPathId2,
|
|
973
1004
|
TranslatableString as TranslatableString3,
|
|
974
1005
|
useDeepCompareMemo as useDeepCompareMemo2
|
|
975
1006
|
} from "@rjsf/utils";
|
|
976
|
-
import { jsx as
|
|
1007
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
977
1008
|
function getFallbackTypeSelectionSchema(title) {
|
|
978
1009
|
return {
|
|
979
1010
|
type: "string",
|
|
@@ -998,7 +1029,7 @@ function castToNewType(formData, newType) {
|
|
|
998
1029
|
return String(formData);
|
|
999
1030
|
case "number": {
|
|
1000
1031
|
const castedNumber = Number(formData);
|
|
1001
|
-
return isNaN(castedNumber) ? 0 : castedNumber;
|
|
1032
|
+
return Number.isNaN(castedNumber) ? 0 : castedNumber;
|
|
1002
1033
|
}
|
|
1003
1034
|
case "boolean":
|
|
1004
1035
|
return Boolean(formData);
|
|
@@ -1025,8 +1056,8 @@ function FallbackField(props) {
|
|
|
1025
1056
|
errorSchema
|
|
1026
1057
|
} = props;
|
|
1027
1058
|
const { translateString, fields: fields2, globalFormOptions } = registry;
|
|
1028
|
-
const [type, setType] =
|
|
1029
|
-
const uiOptions =
|
|
1059
|
+
const [type, setType] = useState3(getTypeOfFormData(formData));
|
|
1060
|
+
const uiOptions = getUiOptions4(uiSchema);
|
|
1030
1061
|
const typeSelectorInnerFieldPathId = useDeepCompareMemo2(
|
|
1031
1062
|
toFieldPathId2("__internal_type_selector", globalFormOptions, fieldPathId)
|
|
1032
1063
|
);
|
|
@@ -1040,25 +1071,25 @@ function FallbackField(props) {
|
|
|
1040
1071
|
};
|
|
1041
1072
|
if (!globalFormOptions.useFallbackUiForUnsupportedType) {
|
|
1042
1073
|
const { reason = translateString(TranslatableString3.UnknownFieldType, [String(schema.type)]) } = props;
|
|
1043
|
-
const UnsupportedFieldTemplate =
|
|
1074
|
+
const UnsupportedFieldTemplate = getTemplate3(
|
|
1044
1075
|
"UnsupportedFieldTemplate",
|
|
1045
1076
|
registry,
|
|
1046
1077
|
uiOptions
|
|
1047
1078
|
);
|
|
1048
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ jsx4(UnsupportedFieldTemplate, { schema, fieldPathId, reason, registry });
|
|
1049
1080
|
}
|
|
1050
|
-
const FallbackFieldTemplate2 =
|
|
1081
|
+
const FallbackFieldTemplate2 = getTemplate3(
|
|
1051
1082
|
"FallbackFieldTemplate",
|
|
1052
1083
|
registry,
|
|
1053
1084
|
uiOptions
|
|
1054
1085
|
);
|
|
1055
1086
|
const { SchemaField: SchemaField2 } = fields2;
|
|
1056
|
-
return /* @__PURE__ */
|
|
1087
|
+
return /* @__PURE__ */ jsx4(
|
|
1057
1088
|
FallbackFieldTemplate2,
|
|
1058
1089
|
{
|
|
1059
1090
|
schema,
|
|
1060
1091
|
registry,
|
|
1061
|
-
typeSelector: /* @__PURE__ */
|
|
1092
|
+
typeSelector: /* @__PURE__ */ jsx4(
|
|
1062
1093
|
SchemaField2,
|
|
1063
1094
|
{
|
|
1064
1095
|
fieldPathId: typeSelectorInnerFieldPathId,
|
|
@@ -1076,7 +1107,7 @@ function FallbackField(props) {
|
|
|
1076
1107
|
},
|
|
1077
1108
|
formData ? hashObject2(formData) : "__empty__"
|
|
1078
1109
|
),
|
|
1079
|
-
schemaField: /* @__PURE__ */
|
|
1110
|
+
schemaField: /* @__PURE__ */ jsx4(
|
|
1080
1111
|
SchemaField2,
|
|
1081
1112
|
{
|
|
1082
1113
|
...props,
|
|
@@ -1095,9 +1126,9 @@ function FallbackField(props) {
|
|
|
1095
1126
|
import {
|
|
1096
1127
|
ANY_OF_KEY,
|
|
1097
1128
|
getDiscriminatorFieldFromSchema,
|
|
1098
|
-
getTemplate as
|
|
1129
|
+
getTemplate as getTemplate4,
|
|
1099
1130
|
getTestIds,
|
|
1100
|
-
getUiOptions as
|
|
1131
|
+
getUiOptions as getUiOptions5,
|
|
1101
1132
|
hashObject as hashObject3,
|
|
1102
1133
|
ID_KEY as ID_KEY2,
|
|
1103
1134
|
lookupFromFormContext,
|
|
@@ -1125,7 +1156,7 @@ import isString from "lodash/isString";
|
|
|
1125
1156
|
import isUndefined from "lodash/isUndefined";
|
|
1126
1157
|
import last from "lodash/last";
|
|
1127
1158
|
import set2 from "lodash/set";
|
|
1128
|
-
import { jsx as
|
|
1159
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1129
1160
|
import { createElement } from "react";
|
|
1130
1161
|
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
1131
1162
|
var LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
@@ -1148,7 +1179,7 @@ function computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceRea
|
|
|
1148
1179
|
if (!isEmpty(globalUiOptions)) {
|
|
1149
1180
|
set2(fieldUiSchema, [UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
|
|
1150
1181
|
}
|
|
1151
|
-
let { readonly: uiReadonly } =
|
|
1182
|
+
let { readonly: uiReadonly } = getUiOptions5(fieldUiSchema);
|
|
1152
1183
|
if (forceReadonly === true || isUndefined(uiReadonly) && schemaReadonly === true) {
|
|
1153
1184
|
uiReadonly = true;
|
|
1154
1185
|
if (has(localUiOptions, READONLY_KEY)) {
|
|
@@ -1194,6 +1225,7 @@ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
1194
1225
|
}
|
|
1195
1226
|
function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1196
1227
|
let rawSchema;
|
|
1228
|
+
let resultPathId = fieldPathId;
|
|
1197
1229
|
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, ITEMS_KEY2)) {
|
|
1198
1230
|
const index = Number(potentialIndex);
|
|
1199
1231
|
const items = schema[ITEMS_KEY2];
|
|
@@ -1206,12 +1238,12 @@ function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
|
1206
1238
|
} else {
|
|
1207
1239
|
rawSchema = items;
|
|
1208
1240
|
}
|
|
1209
|
-
|
|
1241
|
+
resultPathId = {
|
|
1210
1242
|
[ID_KEY2]: fieldPathId[ID_KEY2],
|
|
1211
1243
|
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1212
1244
|
};
|
|
1213
1245
|
}
|
|
1214
|
-
return { rawSchema, fieldPathId };
|
|
1246
|
+
return { rawSchema, fieldPathId: resultPathId };
|
|
1215
1247
|
}
|
|
1216
1248
|
function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
1217
1249
|
const { schemaUtils, globalFormOptions } = registry;
|
|
@@ -1294,15 +1326,15 @@ function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
|
1294
1326
|
if (isString(prop)) {
|
|
1295
1327
|
const match = LOOKUP_REGEX.exec(prop);
|
|
1296
1328
|
if (Array.isArray(match) && match.length > 1) {
|
|
1297
|
-
const
|
|
1298
|
-
uiProps[key] = lookupFromFormContext(registry,
|
|
1329
|
+
const lookupName = match[1];
|
|
1330
|
+
uiProps[key] = lookupFromFormContext(registry, lookupName, lookupName);
|
|
1299
1331
|
}
|
|
1300
1332
|
}
|
|
1301
1333
|
});
|
|
1302
1334
|
}
|
|
1303
1335
|
UIComponent = getCustomRenderComponent(render, registry);
|
|
1304
1336
|
if (!innerName && UIComponent) {
|
|
1305
|
-
rendered = /* @__PURE__ */
|
|
1337
|
+
rendered = /* @__PURE__ */ jsx5(UIComponent, { ...innerProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent });
|
|
1306
1338
|
}
|
|
1307
1339
|
}
|
|
1308
1340
|
return { name, UIComponent, uiProps, rendered };
|
|
@@ -1329,7 +1361,7 @@ function LayoutGridCondition(props) {
|
|
|
1329
1361
|
const { operator, field = "", value } = gridProps;
|
|
1330
1362
|
const fieldData = get(formData, field, null);
|
|
1331
1363
|
if (conditionMatches(operator, fieldData, value)) {
|
|
1332
|
-
return /* @__PURE__ */
|
|
1364
|
+
return /* @__PURE__ */ jsx5(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children });
|
|
1333
1365
|
}
|
|
1334
1366
|
return null;
|
|
1335
1367
|
}
|
|
@@ -1337,23 +1369,23 @@ function LayoutGridCol(props) {
|
|
|
1337
1369
|
const { layoutGridSchema, ...layoutGridFieldProps } = props;
|
|
1338
1370
|
const { registry, uiSchema } = layoutGridFieldProps;
|
|
1339
1371
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:col" /* COLUMN */, registry);
|
|
1340
|
-
const uiOptions =
|
|
1341
|
-
const GridTemplate2 =
|
|
1342
|
-
return /* @__PURE__ */
|
|
1372
|
+
const uiOptions = getUiOptions5(uiSchema);
|
|
1373
|
+
const GridTemplate2 = getTemplate4("GridTemplate", registry, uiOptions);
|
|
1374
|
+
return /* @__PURE__ */ jsx5(GridTemplate2, { column: true, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.col, ...gridProps, children: /* @__PURE__ */ jsx5(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children }) });
|
|
1343
1375
|
}
|
|
1344
1376
|
function LayoutGridColumns(props) {
|
|
1345
1377
|
const { layoutGridSchema, ...layoutGridFieldProps } = props;
|
|
1346
1378
|
const { registry, uiSchema } = layoutGridFieldProps;
|
|
1347
1379
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:columns" /* COLUMNS */, registry);
|
|
1348
|
-
const uiOptions =
|
|
1349
|
-
const GridTemplate2 =
|
|
1350
|
-
return children.map((child) => /* @__PURE__ */
|
|
1380
|
+
const uiOptions = getUiOptions5(uiSchema);
|
|
1381
|
+
const GridTemplate2 = getTemplate4("GridTemplate", registry, uiOptions);
|
|
1382
|
+
return children.map((child) => /* @__PURE__ */ jsx5(
|
|
1351
1383
|
GridTemplate2,
|
|
1352
1384
|
{
|
|
1353
1385
|
column: true,
|
|
1354
1386
|
"data-testid": LAYOUT_GRID_FIELD_TEST_IDS.col,
|
|
1355
1387
|
...gridProps,
|
|
1356
|
-
children: /* @__PURE__ */
|
|
1388
|
+
children: /* @__PURE__ */ jsx5(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: [child] })
|
|
1357
1389
|
},
|
|
1358
1390
|
`column-${hashObject3(child)}`
|
|
1359
1391
|
));
|
|
@@ -1362,9 +1394,9 @@ function LayoutGridRow(props) {
|
|
|
1362
1394
|
const { layoutGridSchema, ...layoutGridFieldProps } = props;
|
|
1363
1395
|
const { registry, uiSchema } = layoutGridFieldProps;
|
|
1364
1396
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:row" /* ROW */, registry);
|
|
1365
|
-
const uiOptions =
|
|
1366
|
-
const GridTemplate2 =
|
|
1367
|
-
return /* @__PURE__ */
|
|
1397
|
+
const uiOptions = getUiOptions5(uiSchema);
|
|
1398
|
+
const GridTemplate2 = getTemplate4("GridTemplate", registry, uiOptions);
|
|
1399
|
+
return /* @__PURE__ */ jsx5(GridTemplate2, { ...gridProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.row, children: /* @__PURE__ */ jsx5(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children }) });
|
|
1368
1400
|
}
|
|
1369
1401
|
function LayoutGridFieldComponent(props) {
|
|
1370
1402
|
const {
|
|
@@ -1399,10 +1431,10 @@ function LayoutGridFieldComponent(props) {
|
|
|
1399
1431
|
return uiComponentProps.rendered;
|
|
1400
1432
|
}
|
|
1401
1433
|
if (schema) {
|
|
1402
|
-
const
|
|
1434
|
+
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1403
1435
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
1404
|
-
return /* @__PURE__ */
|
|
1405
|
-
|
|
1436
|
+
return /* @__PURE__ */ jsx5(
|
|
1437
|
+
Field,
|
|
1406
1438
|
{
|
|
1407
1439
|
"data-testid": optionsInfo?.hasDiscriminator ? LAYOUT_GRID_FIELD_TEST_IDS.layoutMultiSchemaField : LAYOUT_GRID_FIELD_TEST_IDS.field,
|
|
1408
1440
|
...otherProps,
|
|
@@ -1423,7 +1455,7 @@ function LayoutGridFieldComponent(props) {
|
|
|
1423
1455
|
);
|
|
1424
1456
|
}
|
|
1425
1457
|
if (UIComponent) {
|
|
1426
|
-
return /* @__PURE__ */
|
|
1458
|
+
return /* @__PURE__ */ jsx5(
|
|
1427
1459
|
UIComponent,
|
|
1428
1460
|
{
|
|
1429
1461
|
"data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent,
|
|
@@ -1448,50 +1480,46 @@ function LayoutGridFieldComponent(props) {
|
|
|
1448
1480
|
function LayoutGridField(props) {
|
|
1449
1481
|
const { uiSchema } = props;
|
|
1450
1482
|
let { layoutGridSchema } = props;
|
|
1451
|
-
const uiOptions =
|
|
1483
|
+
const uiOptions = getUiOptions5(uiSchema);
|
|
1452
1484
|
if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && isObject3(uiOptions[LAYOUT_GRID_UI_OPTION])) {
|
|
1453
1485
|
layoutGridSchema = uiOptions[LAYOUT_GRID_UI_OPTION];
|
|
1454
1486
|
}
|
|
1455
1487
|
if (isObject3(layoutGridSchema)) {
|
|
1456
1488
|
if ("ui:row" /* ROW */ in layoutGridSchema) {
|
|
1457
|
-
return /* @__PURE__ */
|
|
1489
|
+
return /* @__PURE__ */ jsx5(LayoutGridRow, { ...props, layoutGridSchema });
|
|
1458
1490
|
}
|
|
1459
1491
|
if ("ui:col" /* COLUMN */ in layoutGridSchema) {
|
|
1460
|
-
return /* @__PURE__ */
|
|
1492
|
+
return /* @__PURE__ */ jsx5(LayoutGridCol, { ...props, layoutGridSchema });
|
|
1461
1493
|
}
|
|
1462
1494
|
if ("ui:columns" /* COLUMNS */ in layoutGridSchema) {
|
|
1463
|
-
return /* @__PURE__ */
|
|
1495
|
+
return /* @__PURE__ */ jsx5(LayoutGridColumns, { ...props, layoutGridSchema });
|
|
1464
1496
|
}
|
|
1465
1497
|
if ("ui:condition" /* CONDITION */ in layoutGridSchema) {
|
|
1466
|
-
return /* @__PURE__ */
|
|
1498
|
+
return /* @__PURE__ */ jsx5(LayoutGridCondition, { ...props, layoutGridSchema });
|
|
1467
1499
|
}
|
|
1468
1500
|
}
|
|
1469
|
-
return /* @__PURE__ */
|
|
1501
|
+
return /* @__PURE__ */ jsx5(LayoutGridFieldComponent, { ...props, gridSchema: layoutGridSchema });
|
|
1470
1502
|
}
|
|
1471
1503
|
LayoutGridField.TEST_IDS = LAYOUT_GRID_FIELD_TEST_IDS;
|
|
1472
1504
|
|
|
1473
1505
|
// src/components/fields/LayoutHeaderField.tsx
|
|
1474
|
-
import {
|
|
1475
|
-
|
|
1476
|
-
getUiOptions as getUiOptions5,
|
|
1477
|
-
titleId
|
|
1478
|
-
} from "@rjsf/utils";
|
|
1479
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1506
|
+
import { getTemplate as getTemplate5, getUiOptions as getUiOptions6, titleId } from "@rjsf/utils";
|
|
1507
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1480
1508
|
function LayoutHeaderField(props) {
|
|
1481
1509
|
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
1482
|
-
const options =
|
|
1510
|
+
const options = getUiOptions6(uiSchema, registry.globalUiOptions);
|
|
1483
1511
|
const { title: uiTitle } = options;
|
|
1484
1512
|
const { title: schemaTitle } = schema;
|
|
1485
1513
|
const fieldTitle = uiTitle || title || schemaTitle || name;
|
|
1486
1514
|
if (!fieldTitle) {
|
|
1487
1515
|
return null;
|
|
1488
1516
|
}
|
|
1489
|
-
const TitleFieldTemplate =
|
|
1517
|
+
const TitleFieldTemplate = getTemplate5(
|
|
1490
1518
|
"TitleFieldTemplate",
|
|
1491
1519
|
registry,
|
|
1492
1520
|
options
|
|
1493
1521
|
);
|
|
1494
|
-
return /* @__PURE__ */
|
|
1522
|
+
return /* @__PURE__ */ jsx6(
|
|
1495
1523
|
TitleFieldTemplate,
|
|
1496
1524
|
{
|
|
1497
1525
|
id: titleId(fieldPathId),
|
|
@@ -1505,7 +1533,7 @@ function LayoutHeaderField(props) {
|
|
|
1505
1533
|
}
|
|
1506
1534
|
|
|
1507
1535
|
// src/components/fields/LayoutMultiSchemaField.tsx
|
|
1508
|
-
import { useState as
|
|
1536
|
+
import { useState as useState4, useEffect } from "react";
|
|
1509
1537
|
import {
|
|
1510
1538
|
ANY_OF_KEY as ANY_OF_KEY2,
|
|
1511
1539
|
CONST_KEY,
|
|
@@ -1517,8 +1545,8 @@ import {
|
|
|
1517
1545
|
ONE_OF_KEY as ONE_OF_KEY2,
|
|
1518
1546
|
optionsList as optionsList3,
|
|
1519
1547
|
PROPERTIES_KEY as PROPERTIES_KEY2,
|
|
1520
|
-
getTemplate as
|
|
1521
|
-
getUiOptions as
|
|
1548
|
+
getTemplate as getTemplate6,
|
|
1549
|
+
getUiOptions as getUiOptions7,
|
|
1522
1550
|
getWidget as getWidget3
|
|
1523
1551
|
} from "@rjsf/utils";
|
|
1524
1552
|
import get2 from "lodash/get";
|
|
@@ -1527,7 +1555,7 @@ import isEmpty2 from "lodash/isEmpty";
|
|
|
1527
1555
|
import noop from "lodash/noop";
|
|
1528
1556
|
import omit from "lodash/omit";
|
|
1529
1557
|
import set3 from "lodash/set";
|
|
1530
|
-
import { jsx as
|
|
1558
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1531
1559
|
function getSelectedOption(options, selectorField, value) {
|
|
1532
1560
|
const defaultValue = "!@#!@$@#$!@$#";
|
|
1533
1561
|
const schemaOptions = options.map(({ schema }) => schema);
|
|
@@ -1572,11 +1600,11 @@ function LayoutMultiSchemaField(props) {
|
|
|
1572
1600
|
hideError = false
|
|
1573
1601
|
} = props;
|
|
1574
1602
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1575
|
-
const [enumOptions, setEnumOptions] =
|
|
1603
|
+
const [enumOptions, setEnumOptions] = useState4(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1576
1604
|
const id = get2(fieldPathId, ID_KEY3);
|
|
1577
1605
|
const discriminator = getDiscriminatorFieldFromSchema2(schema);
|
|
1578
|
-
const FieldErrorTemplate2 =
|
|
1579
|
-
const FieldTemplate2 =
|
|
1606
|
+
const FieldErrorTemplate2 = getTemplate6("FieldErrorTemplate", registry, options);
|
|
1607
|
+
const FieldTemplate2 = getTemplate6("FieldTemplate", registry, options);
|
|
1580
1608
|
const schemaHash = hashObject4(schema);
|
|
1581
1609
|
const optionsHash = hashObject4(options);
|
|
1582
1610
|
const uiSchemaHash = uiSchema ? hashObject4(uiSchema) : "";
|
|
@@ -1591,7 +1619,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1591
1619
|
optionsSchemaSelector: selectorField = discriminator,
|
|
1592
1620
|
hideError: uiSchemaHideError,
|
|
1593
1621
|
...uiOptions
|
|
1594
|
-
} =
|
|
1622
|
+
} = getUiOptions7(uiSchema);
|
|
1595
1623
|
if (!selectorField) {
|
|
1596
1624
|
throw new Error("No selector field provided for the LayoutMultiSchemaField");
|
|
1597
1625
|
}
|
|
@@ -1605,6 +1633,9 @@ function LayoutMultiSchemaField(props) {
|
|
|
1605
1633
|
const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
|
|
1606
1634
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1607
1635
|
const onOptionChange = (opt) => {
|
|
1636
|
+
if (disabled || readonly) {
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1608
1639
|
const newOption = getSelectedOption(enumOptions, selectorField, opt);
|
|
1609
1640
|
const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1610
1641
|
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
@@ -1617,8 +1648,8 @@ function LayoutMultiSchemaField(props) {
|
|
|
1617
1648
|
onChange(newFormData, fieldPathId.path, void 0, id);
|
|
1618
1649
|
};
|
|
1619
1650
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
1620
|
-
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */
|
|
1621
|
-
return /* @__PURE__ */
|
|
1651
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ jsx7(FieldErrorTemplate2, { fieldPathId, schema, errors: rawErrors, registry }) : void 0;
|
|
1652
|
+
return /* @__PURE__ */ jsx7(
|
|
1622
1653
|
FieldTemplate2,
|
|
1623
1654
|
{
|
|
1624
1655
|
fieldPathId,
|
|
@@ -1636,7 +1667,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1636
1667
|
onKeyRename: noop,
|
|
1637
1668
|
onKeyRenameBlur: noop,
|
|
1638
1669
|
onRemoveProperty: noop,
|
|
1639
|
-
children: /* @__PURE__ */
|
|
1670
|
+
children: /* @__PURE__ */ jsx7(
|
|
1640
1671
|
Widget,
|
|
1641
1672
|
{
|
|
1642
1673
|
id,
|
|
@@ -1668,15 +1699,16 @@ function LayoutMultiSchemaField(props) {
|
|
|
1668
1699
|
}
|
|
1669
1700
|
|
|
1670
1701
|
// src/components/fields/MultiSchemaField.tsx
|
|
1671
|
-
import {
|
|
1702
|
+
import { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2, useState as useState5 } from "react";
|
|
1672
1703
|
import {
|
|
1673
1704
|
ANY_OF_KEY as ANY_OF_KEY3,
|
|
1674
1705
|
deepEquals,
|
|
1675
1706
|
ERRORS_KEY as ERRORS_KEY2,
|
|
1676
1707
|
getDiscriminatorFieldFromSchema as getDiscriminatorFieldFromSchema3,
|
|
1677
|
-
getTemplate as
|
|
1678
|
-
getUiOptions as
|
|
1708
|
+
getTemplate as getTemplate7,
|
|
1709
|
+
getUiOptions as getUiOptions8,
|
|
1679
1710
|
getWidget as getWidget4,
|
|
1711
|
+
hashObject as hashObject5,
|
|
1680
1712
|
isFormDataAvailable as isFormDataAvailable2,
|
|
1681
1713
|
mergeSchemas,
|
|
1682
1714
|
ONE_OF_KEY as ONE_OF_KEY3,
|
|
@@ -1686,211 +1718,187 @@ import {
|
|
|
1686
1718
|
import get3 from "lodash/get";
|
|
1687
1719
|
import isEmpty3 from "lodash/isEmpty";
|
|
1688
1720
|
import omit2 from "lodash/omit";
|
|
1689
|
-
import { jsx as
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
const
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1721
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1722
|
+
function AnyOfField(props) {
|
|
1723
|
+
const {
|
|
1724
|
+
name,
|
|
1725
|
+
disabled = false,
|
|
1726
|
+
errorSchema = {},
|
|
1727
|
+
formData,
|
|
1728
|
+
fieldPathId,
|
|
1729
|
+
onBlur,
|
|
1730
|
+
onChange,
|
|
1731
|
+
onFocus,
|
|
1732
|
+
options,
|
|
1733
|
+
readonly,
|
|
1734
|
+
registry,
|
|
1735
|
+
required = false,
|
|
1736
|
+
schema,
|
|
1737
|
+
uiSchema
|
|
1738
|
+
} = props;
|
|
1739
|
+
const { schemaUtils } = registry;
|
|
1740
|
+
const formDataHash = hashObject5(formData ?? null);
|
|
1741
|
+
const retrievedOptions = useMemo3(
|
|
1742
|
+
() => options.map((opt) => schemaUtils.retrieveSchema(opt, formData)),
|
|
1743
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- formDataHash is the value-stable proxy for formData
|
|
1744
|
+
[options, schemaUtils, formDataHash]
|
|
1745
|
+
);
|
|
1746
|
+
const [selectedOption, setSelectedOption] = useState5(() => {
|
|
1747
|
+
const discriminator = getDiscriminatorFieldFromSchema3(schema);
|
|
1748
|
+
return schemaUtils.getClosestMatchingOption(formData, retrievedOptions, 0, discriminator);
|
|
1749
|
+
});
|
|
1750
|
+
const skipNextOptionRecalculation = useRef2(false);
|
|
1751
|
+
const prevFormDataRef = useRef2(formData);
|
|
1752
|
+
const prevFieldIdRef = useRef2(fieldPathId.$id);
|
|
1753
|
+
useEffect2(() => {
|
|
1754
|
+
const prevFormData = prevFormDataRef.current;
|
|
1755
|
+
const prevFieldId = prevFieldIdRef.current;
|
|
1756
|
+
prevFormDataRef.current = formData;
|
|
1757
|
+
prevFieldIdRef.current = fieldPathId.$id;
|
|
1758
|
+
if (!deepEquals(formData, prevFormData) && fieldPathId.$id === prevFieldId) {
|
|
1759
|
+
if (skipNextOptionRecalculation.current) {
|
|
1760
|
+
skipNextOptionRecalculation.current = false;
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
const discriminator = getDiscriminatorFieldFromSchema3(schema);
|
|
1764
|
+
const matchingOption = schemaUtils.getClosestMatchingOption(
|
|
1765
|
+
formData,
|
|
1766
|
+
retrievedOptions,
|
|
1767
|
+
selectedOption,
|
|
1768
|
+
discriminator
|
|
1769
|
+
);
|
|
1770
|
+
if (matchingOption !== selectedOption) {
|
|
1771
|
+
setSelectedOption(matchingOption);
|
|
1772
|
+
}
|
|
1724
1773
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1774
|
+
});
|
|
1775
|
+
const fieldId = `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1776
|
+
const onOptionChange = useCallback3(
|
|
1777
|
+
(option2) => {
|
|
1778
|
+
if (disabled || readonly) {
|
|
1779
|
+
return;
|
|
1730
1780
|
}
|
|
1781
|
+
const intOption = option2 !== void 0 ? parseInt(option2, 10) : -1;
|
|
1782
|
+
if (intOption === selectedOption) {
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
|
|
1786
|
+
const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
|
|
1787
|
+
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
1788
|
+
if (newOption) {
|
|
1789
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1790
|
+
}
|
|
1791
|
+
setSelectedOption(intOption);
|
|
1792
|
+
skipNextOptionRecalculation.current = true;
|
|
1793
|
+
onChange(newFormData, fieldPathId.path, void 0, fieldId);
|
|
1794
|
+
},
|
|
1795
|
+
// setSelectedOption is stable (guaranteed by useState); skipNextOptionRecalculation is a ref
|
|
1796
|
+
[selectedOption, retrievedOptions, disabled, readonly, schemaUtils, formData, fieldPathId, onChange, fieldId]
|
|
1797
|
+
);
|
|
1798
|
+
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions } = registry;
|
|
1799
|
+
const { SchemaField: SchemaFieldComponent } = fields2;
|
|
1800
|
+
const MultiSchemaFieldTemplate2 = getTemplate7(
|
|
1801
|
+
"MultiSchemaFieldTemplate",
|
|
1802
|
+
registry,
|
|
1803
|
+
globalUiOptions
|
|
1804
|
+
);
|
|
1805
|
+
const isOptionalRender = shouldRenderOptionalField2(registry, schema, required, uiSchema);
|
|
1806
|
+
const hasFormData = isFormDataAvailable2(formData);
|
|
1807
|
+
const {
|
|
1808
|
+
widget = "select",
|
|
1809
|
+
placeholder,
|
|
1810
|
+
autofocus,
|
|
1811
|
+
autocomplete,
|
|
1812
|
+
title = schema.title,
|
|
1813
|
+
...uiOptions
|
|
1814
|
+
} = getUiOptions8(uiSchema, globalUiOptions);
|
|
1815
|
+
const Widget = getWidget4({ type: "number" }, widget, widgets2);
|
|
1816
|
+
const rawErrors = get3(errorSchema, ERRORS_KEY2, []);
|
|
1817
|
+
const fieldErrorSchema = omit2(errorSchema, [ERRORS_KEY2]);
|
|
1818
|
+
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1819
|
+
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1820
|
+
let optionSchema;
|
|
1821
|
+
if (option) {
|
|
1822
|
+
const { required: schemaRequired, type: schemaType } = schema;
|
|
1823
|
+
const parentProps = {};
|
|
1824
|
+
if (schemaRequired) {
|
|
1825
|
+
parentProps.required = schemaRequired;
|
|
1731
1826
|
}
|
|
1732
|
-
if (
|
|
1733
|
-
|
|
1827
|
+
if (schemaType !== void 0 && !("type" in option)) {
|
|
1828
|
+
parentProps.type = schemaType;
|
|
1734
1829
|
}
|
|
1830
|
+
optionSchema = Object.keys(parentProps).length > 0 ? mergeSchemas(parentProps, option) : option;
|
|
1735
1831
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
getMatchingOption(selectedOption, formData, options) {
|
|
1743
|
-
const {
|
|
1744
|
-
schema,
|
|
1745
|
-
registry: { schemaUtils }
|
|
1746
|
-
} = this.props;
|
|
1747
|
-
const discriminator = getDiscriminatorFieldFromSchema3(schema);
|
|
1748
|
-
const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
1749
|
-
return option;
|
|
1750
|
-
}
|
|
1751
|
-
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
1752
|
-
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
1753
|
-
* the `onChange` handler.
|
|
1754
|
-
*
|
|
1755
|
-
* @param option - The new option value being selected
|
|
1756
|
-
*/
|
|
1757
|
-
onOptionChange = (option) => {
|
|
1758
|
-
const { selectedOption, retrievedOptions } = this.state;
|
|
1759
|
-
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
1760
|
-
const { schemaUtils } = registry;
|
|
1761
|
-
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1762
|
-
if (intOption === selectedOption) {
|
|
1763
|
-
return;
|
|
1832
|
+
let optionsUiSchema = [];
|
|
1833
|
+
if (ONE_OF_KEY3 in schema && uiSchema && ONE_OF_KEY3 in uiSchema) {
|
|
1834
|
+
if (Array.isArray(uiSchema[ONE_OF_KEY3])) {
|
|
1835
|
+
optionsUiSchema = uiSchema[ONE_OF_KEY3];
|
|
1836
|
+
} else {
|
|
1837
|
+
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
1764
1838
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1839
|
+
} else if (ANY_OF_KEY3 in schema && uiSchema && ANY_OF_KEY3 in uiSchema) {
|
|
1840
|
+
if (Array.isArray(uiSchema[ANY_OF_KEY3])) {
|
|
1841
|
+
optionsUiSchema = uiSchema[ANY_OF_KEY3];
|
|
1842
|
+
} else {
|
|
1843
|
+
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1770
1844
|
}
|
|
1771
|
-
this.setState({ selectedOption: intOption }, () => {
|
|
1772
|
-
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1773
|
-
});
|
|
1774
|
-
};
|
|
1775
|
-
getFieldId() {
|
|
1776
|
-
const { fieldPathId, schema } = this.props;
|
|
1777
|
-
return `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1778
1845
|
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1846
|
+
let optionUiSchema = uiSchema;
|
|
1847
|
+
if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
|
|
1848
|
+
optionUiSchema = optionsUiSchema[selectedOption];
|
|
1849
|
+
}
|
|
1850
|
+
const translateEnum = title ? TranslatableString4.TitleOptionPrefix : TranslatableString4.OptionPrefix;
|
|
1851
|
+
const translateParams = title ? [title] : [];
|
|
1852
|
+
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1853
|
+
const { title: uiTitle = opt.title } = getUiOptions8(optionsUiSchema[index]);
|
|
1854
|
+
return {
|
|
1855
|
+
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1856
|
+
value: index
|
|
1857
|
+
};
|
|
1858
|
+
});
|
|
1859
|
+
const selector = !isOptionalRender || hasFormData ? /* @__PURE__ */ jsx8(
|
|
1860
|
+
Widget,
|
|
1861
|
+
{
|
|
1862
|
+
id: fieldId,
|
|
1863
|
+
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1864
|
+
schema: { type: "number", default: 0 },
|
|
1865
|
+
onChange: onOptionChange,
|
|
1787
1866
|
onBlur,
|
|
1788
1867
|
onFocus,
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1796
|
-
const { SchemaField: _SchemaField } = fields2;
|
|
1797
|
-
const MultiSchemaFieldTemplate2 = getTemplate6(
|
|
1798
|
-
"MultiSchemaFieldTemplate",
|
|
1868
|
+
disabled: disabled || isEmpty3(enumOptions),
|
|
1869
|
+
multiple: false,
|
|
1870
|
+
rawErrors,
|
|
1871
|
+
errorSchema: fieldErrorSchema,
|
|
1872
|
+
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1873
|
+
options: { enumOptions, ...uiOptions },
|
|
1799
1874
|
registry,
|
|
1800
|
-
globalUiOptions
|
|
1801
|
-
);
|
|
1802
|
-
const isOptionalRender = shouldRenderOptionalField2(registry, schema, required, uiSchema);
|
|
1803
|
-
const hasFormData = isFormDataAvailable2(formData);
|
|
1804
|
-
const { selectedOption, retrievedOptions } = this.state;
|
|
1805
|
-
const {
|
|
1806
|
-
widget = "select",
|
|
1807
1875
|
placeholder,
|
|
1808
|
-
autofocus,
|
|
1809
1876
|
autocomplete,
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
const rawErrors = get3(errorSchema, ERRORS_KEY2, []);
|
|
1815
|
-
const fieldErrorSchema = omit2(errorSchema, [ERRORS_KEY2]);
|
|
1816
|
-
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1817
|
-
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1818
|
-
let optionSchema;
|
|
1819
|
-
if (option) {
|
|
1820
|
-
const { required: required2 } = schema;
|
|
1821
|
-
optionSchema = required2 ? mergeSchemas({ required: required2 }, option) : option;
|
|
1822
|
-
}
|
|
1823
|
-
let optionsUiSchema = [];
|
|
1824
|
-
if (ONE_OF_KEY3 in schema && uiSchema && ONE_OF_KEY3 in uiSchema) {
|
|
1825
|
-
if (Array.isArray(uiSchema[ONE_OF_KEY3])) {
|
|
1826
|
-
optionsUiSchema = uiSchema[ONE_OF_KEY3];
|
|
1827
|
-
} else {
|
|
1828
|
-
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
1829
|
-
}
|
|
1830
|
-
} else if (ANY_OF_KEY3 in schema && uiSchema && ANY_OF_KEY3 in uiSchema) {
|
|
1831
|
-
if (Array.isArray(uiSchema[ANY_OF_KEY3])) {
|
|
1832
|
-
optionsUiSchema = uiSchema[ANY_OF_KEY3];
|
|
1833
|
-
} else {
|
|
1834
|
-
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1835
|
-
}
|
|
1877
|
+
autofocus,
|
|
1878
|
+
label: title ?? name,
|
|
1879
|
+
hideLabel: !displayLabel,
|
|
1880
|
+
readonly
|
|
1836
1881
|
}
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1882
|
+
) : void 0;
|
|
1883
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsx8(SchemaFieldComponent, { ...props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1884
|
+
return /* @__PURE__ */ jsx8(
|
|
1885
|
+
MultiSchemaFieldTemplate2,
|
|
1886
|
+
{
|
|
1887
|
+
schema,
|
|
1888
|
+
registry,
|
|
1889
|
+
uiSchema,
|
|
1890
|
+
selector,
|
|
1891
|
+
optionSchemaField: optionsSchemaField
|
|
1840
1892
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1844
|
-
const { title: uiTitle = opt.title } = getUiOptions7(optionsUiSchema[index]);
|
|
1845
|
-
return {
|
|
1846
|
-
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1847
|
-
value: index
|
|
1848
|
-
};
|
|
1849
|
-
});
|
|
1850
|
-
const selector = !isOptionalRender || hasFormData ? /* @__PURE__ */ jsx7(
|
|
1851
|
-
Widget,
|
|
1852
|
-
{
|
|
1853
|
-
id: this.getFieldId(),
|
|
1854
|
-
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1855
|
-
schema: { type: "number", default: 0 },
|
|
1856
|
-
onChange: this.onOptionChange,
|
|
1857
|
-
onBlur,
|
|
1858
|
-
onFocus,
|
|
1859
|
-
disabled: disabled || isEmpty3(enumOptions),
|
|
1860
|
-
multiple: false,
|
|
1861
|
-
rawErrors,
|
|
1862
|
-
errorSchema: fieldErrorSchema,
|
|
1863
|
-
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1864
|
-
options: { enumOptions, ...uiOptions },
|
|
1865
|
-
registry,
|
|
1866
|
-
placeholder,
|
|
1867
|
-
autocomplete,
|
|
1868
|
-
autofocus,
|
|
1869
|
-
label: title ?? name,
|
|
1870
|
-
hideLabel: !displayLabel,
|
|
1871
|
-
readonly
|
|
1872
|
-
}
|
|
1873
|
-
) : void 0;
|
|
1874
|
-
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsx7(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1875
|
-
return /* @__PURE__ */ jsx7(
|
|
1876
|
-
MultiSchemaFieldTemplate2,
|
|
1877
|
-
{
|
|
1878
|
-
schema,
|
|
1879
|
-
registry,
|
|
1880
|
-
uiSchema,
|
|
1881
|
-
selector,
|
|
1882
|
-
optionSchemaField: optionsSchemaField
|
|
1883
|
-
}
|
|
1884
|
-
);
|
|
1885
|
-
}
|
|
1886
|
-
};
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1887
1895
|
var MultiSchemaField_default = AnyOfField;
|
|
1888
1896
|
|
|
1889
1897
|
// src/components/fields/NullField.tsx
|
|
1890
|
-
import { useEffect as
|
|
1898
|
+
import { useEffect as useEffect3 } from "react";
|
|
1891
1899
|
function NullField(props) {
|
|
1892
1900
|
const { formData, onChange, fieldPathId } = props;
|
|
1893
|
-
|
|
1901
|
+
useEffect3(() => {
|
|
1894
1902
|
if (formData === void 0) {
|
|
1895
1903
|
onChange(null, fieldPathId.path);
|
|
1896
1904
|
}
|
|
@@ -1900,25 +1908,21 @@ function NullField(props) {
|
|
|
1900
1908
|
var NullField_default = NullField;
|
|
1901
1909
|
|
|
1902
1910
|
// src/components/fields/NumberField.tsx
|
|
1903
|
-
import { useState as
|
|
1904
|
-
import {
|
|
1905
|
-
|
|
1906
|
-
} from "@rjsf/utils";
|
|
1907
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1911
|
+
import { useState as useState6, useCallback as useCallback4 } from "react";
|
|
1912
|
+
import { asNumber } from "@rjsf/utils";
|
|
1913
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1908
1914
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1909
1915
|
var trailingCharMatcher = /[0.]0*$/;
|
|
1910
1916
|
function NumberField(props) {
|
|
1911
1917
|
const { registry, onChange, formData, value: initialValue } = props;
|
|
1912
|
-
const [lastValue, setLastValue] =
|
|
1918
|
+
const [lastValue, setLastValue] = useState6(initialValue);
|
|
1913
1919
|
const { StringField: StringField2 } = registry.fields;
|
|
1914
1920
|
let value = formData;
|
|
1915
|
-
const handleChange =
|
|
1916
|
-
(
|
|
1917
|
-
setLastValue(
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
}
|
|
1921
|
-
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? asNumber(value2.replace(trailingCharMatcher, "")) : asNumber(value2);
|
|
1921
|
+
const handleChange = useCallback4(
|
|
1922
|
+
(newValue, path, errorSchema, id) => {
|
|
1923
|
+
setLastValue(newValue);
|
|
1924
|
+
const normalizedValue = `${newValue}`.startsWith(".") ? `0${newValue}` : newValue;
|
|
1925
|
+
const processed = typeof normalizedValue === "string" && trailingCharMatcherWithPrefix.exec(normalizedValue) ? asNumber(normalizedValue.replace(trailingCharMatcher, "")) : asNumber(normalizedValue);
|
|
1922
1926
|
onChange(processed, path, errorSchema, id);
|
|
1923
1927
|
},
|
|
1924
1928
|
[onChange]
|
|
@@ -1929,17 +1933,17 @@ function NumberField(props) {
|
|
|
1929
1933
|
value = lastValue;
|
|
1930
1934
|
}
|
|
1931
1935
|
}
|
|
1932
|
-
return /* @__PURE__ */
|
|
1936
|
+
return /* @__PURE__ */ jsx9(StringField2, { ...props, formData: value, onChange: handleChange });
|
|
1933
1937
|
}
|
|
1934
1938
|
var NumberField_default = NumberField;
|
|
1935
1939
|
|
|
1936
1940
|
// src/components/fields/ObjectField.tsx
|
|
1937
|
-
import { useCallback as
|
|
1941
|
+
import { memo as memo2, useCallback as useCallback5, useMemo as useMemo4, useRef as useRef3, useState as useState7 } from "react";
|
|
1938
1942
|
import {
|
|
1939
1943
|
ADDITIONAL_PROPERTY_FLAG,
|
|
1940
1944
|
ANY_OF_KEY as ANY_OF_KEY4,
|
|
1941
|
-
getTemplate as
|
|
1942
|
-
getUiOptions as
|
|
1945
|
+
getTemplate as getTemplate8,
|
|
1946
|
+
getUiOptions as getUiOptions9,
|
|
1943
1947
|
isFormDataAvailable as isFormDataAvailable3,
|
|
1944
1948
|
orderProperties,
|
|
1945
1949
|
shouldRenderOptionalField as shouldRenderOptionalField3,
|
|
@@ -1954,16 +1958,16 @@ import get4 from "lodash/get";
|
|
|
1954
1958
|
import has3 from "lodash/has";
|
|
1955
1959
|
import isObject4 from "lodash/isObject";
|
|
1956
1960
|
import set4 from "lodash/set";
|
|
1957
|
-
import { Markdown } from "markdown-to-jsx";
|
|
1961
|
+
import { Markdown } from "markdown-to-jsx/react";
|
|
1958
1962
|
|
|
1959
1963
|
// src/components/constants.ts
|
|
1960
1964
|
var ADDITIONAL_PROPERTY_KEY_REMOVE = /* @__PURE__ */ Symbol("remove-this-key");
|
|
1961
1965
|
var IS_RESET = /* @__PURE__ */ Symbol("reset");
|
|
1962
1966
|
|
|
1963
1967
|
// src/components/fields/ObjectField.tsx
|
|
1964
|
-
import { jsx as
|
|
1968
|
+
import { jsx as jsx10, jsxs } from "react/jsx-runtime";
|
|
1965
1969
|
function isRequired(schema, name) {
|
|
1966
|
-
return Array.isArray(schema.required) && schema.required.
|
|
1970
|
+
return Array.isArray(schema.required) && schema.required.includes(name);
|
|
1967
1971
|
}
|
|
1968
1972
|
function getDefaultValue(translateString, type) {
|
|
1969
1973
|
switch (type) {
|
|
@@ -1982,7 +1986,7 @@ function getDefaultValue(translateString, type) {
|
|
|
1982
1986
|
return translateString(TranslatableString5.NewStringDefault);
|
|
1983
1987
|
}
|
|
1984
1988
|
}
|
|
1985
|
-
function
|
|
1989
|
+
function ObjectFieldPropertyFn(props) {
|
|
1986
1990
|
const {
|
|
1987
1991
|
fieldPathId,
|
|
1988
1992
|
schema,
|
|
@@ -2002,22 +2006,23 @@ function ObjectFieldProperty(props) {
|
|
|
2002
2006
|
handleRemoveProperty,
|
|
2003
2007
|
addedByAdditionalProperties
|
|
2004
2008
|
} = props;
|
|
2005
|
-
const [wasPropertyKeyModified, setWasPropertyKeyModified] =
|
|
2009
|
+
const [wasPropertyKeyModified, setWasPropertyKeyModified] = useState7(false);
|
|
2006
2010
|
const { globalFormOptions, fields: fields2 } = registry;
|
|
2007
2011
|
const { SchemaField: SchemaField2 } = fields2;
|
|
2008
2012
|
const innerFieldIdPathId = useDeepCompareMemo4(
|
|
2009
2013
|
toFieldPathId4(propertyName, globalFormOptions, fieldPathId.path)
|
|
2010
2014
|
);
|
|
2011
|
-
const onPropertyChange =
|
|
2015
|
+
const onPropertyChange = useCallback5(
|
|
2012
2016
|
(value, path, newErrorSchema, id) => {
|
|
2017
|
+
let normalizedValue = value;
|
|
2013
2018
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
2014
|
-
|
|
2019
|
+
normalizedValue = "";
|
|
2015
2020
|
}
|
|
2016
|
-
onChange(
|
|
2021
|
+
onChange(normalizedValue, path, newErrorSchema, id);
|
|
2017
2022
|
},
|
|
2018
2023
|
[onChange, addedByAdditionalProperties]
|
|
2019
2024
|
);
|
|
2020
|
-
const onKeyRename =
|
|
2025
|
+
const onKeyRename = useCallback5(
|
|
2021
2026
|
(value) => {
|
|
2022
2027
|
if (propertyName !== value) {
|
|
2023
2028
|
setWasPropertyKeyModified(true);
|
|
@@ -2026,7 +2031,7 @@ function ObjectFieldProperty(props) {
|
|
|
2026
2031
|
},
|
|
2027
2032
|
[propertyName, handleKeyRename]
|
|
2028
2033
|
);
|
|
2029
|
-
const onKeyRenameBlur =
|
|
2034
|
+
const onKeyRenameBlur = useCallback5(
|
|
2030
2035
|
(event) => {
|
|
2031
2036
|
const {
|
|
2032
2037
|
target: { value }
|
|
@@ -2035,10 +2040,10 @@ function ObjectFieldProperty(props) {
|
|
|
2035
2040
|
},
|
|
2036
2041
|
[onKeyRename]
|
|
2037
2042
|
);
|
|
2038
|
-
const onRemoveProperty =
|
|
2043
|
+
const onRemoveProperty = useCallback5(() => {
|
|
2039
2044
|
handleRemoveProperty(propertyName);
|
|
2040
2045
|
}, [propertyName, handleRemoveProperty]);
|
|
2041
|
-
return /* @__PURE__ */
|
|
2046
|
+
return /* @__PURE__ */ jsx10(
|
|
2042
2047
|
SchemaField2,
|
|
2043
2048
|
{
|
|
2044
2049
|
name: propertyName,
|
|
@@ -2062,6 +2067,7 @@ function ObjectFieldProperty(props) {
|
|
|
2062
2067
|
}
|
|
2063
2068
|
);
|
|
2064
2069
|
}
|
|
2070
|
+
var ObjectFieldProperty = memo2(ObjectFieldPropertyFn);
|
|
2065
2071
|
function ObjectField(props) {
|
|
2066
2072
|
const {
|
|
2067
2073
|
schema: rawSchema,
|
|
@@ -2082,35 +2088,38 @@ function ObjectField(props) {
|
|
|
2082
2088
|
} = props;
|
|
2083
2089
|
const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
|
|
2084
2090
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
2085
|
-
const formDataRef =
|
|
2091
|
+
const formDataRef = useRef3(formData);
|
|
2086
2092
|
formDataRef.current = formData;
|
|
2087
|
-
const schema =
|
|
2088
|
-
|
|
2093
|
+
const schema = useMemo4(
|
|
2094
|
+
() => schemaUtils.retrieveSchema(rawSchema, formData, true),
|
|
2095
|
+
[schemaUtils, rawSchema, formData]
|
|
2096
|
+
);
|
|
2097
|
+
const uiOptions = useMemo4(() => getUiOptions9(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
2089
2098
|
const { properties: schemaProperties = {} } = schema;
|
|
2090
2099
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
2091
|
-
const lastRenamedProperty =
|
|
2100
|
+
const lastRenamedProperty = useRef3({ previousKey: "", currentKey: void 0 });
|
|
2092
2101
|
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
2093
2102
|
const description = uiOptions.description ?? schema.description;
|
|
2094
2103
|
const renderOptionalField = shouldRenderOptionalField3(registry, schema, required, uiSchema);
|
|
2095
2104
|
const hasFormData = isFormDataAvailable3(formData);
|
|
2096
2105
|
let orderedProperties = [];
|
|
2097
|
-
const getAvailableKey =
|
|
2098
|
-
(preferredKey,
|
|
2099
|
-
const { duplicateKeySuffixSeparator = "-" } =
|
|
2106
|
+
const getAvailableKey = useCallback5(
|
|
2107
|
+
(preferredKey, existingFormData) => {
|
|
2108
|
+
const { duplicateKeySuffixSeparator = "-" } = getUiOptions9(uiSchema, globalUiOptions);
|
|
2100
2109
|
let index = 0;
|
|
2101
2110
|
let newKey = preferredKey;
|
|
2102
|
-
while (has3(
|
|
2103
|
-
|
|
2111
|
+
while (has3(existingFormData, newKey)) {
|
|
2112
|
+
index += 1;
|
|
2113
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
2104
2114
|
}
|
|
2105
2115
|
return newKey;
|
|
2106
2116
|
},
|
|
2107
2117
|
[uiSchema, globalUiOptions]
|
|
2108
2118
|
);
|
|
2109
|
-
const onAddProperty =
|
|
2119
|
+
const onAddProperty = useCallback5(() => {
|
|
2110
2120
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2111
2121
|
return;
|
|
2112
2122
|
}
|
|
2113
|
-
const { translateString: translateString2 } = registry;
|
|
2114
2123
|
const newFormData = { ...formData };
|
|
2115
2124
|
const newKey = getAvailableKey("newKey", newFormData);
|
|
2116
2125
|
if (schema.patternProperties) {
|
|
@@ -2125,17 +2134,16 @@ function ObjectField(props) {
|
|
|
2125
2134
|
defaultValue = schema.additionalProperties.default;
|
|
2126
2135
|
let apSchema = schema.additionalProperties;
|
|
2127
2136
|
if (REF_KEY in apSchema) {
|
|
2128
|
-
|
|
2129
|
-
apSchema = schemaUtils2.retrieveSchema({ [REF_KEY]: apSchema[REF_KEY] }, formData);
|
|
2137
|
+
apSchema = schemaUtils.retrieveSchema({ [REF_KEY]: apSchema[REF_KEY] }, formData);
|
|
2130
2138
|
type = apSchema.type;
|
|
2131
2139
|
constValue = apSchema.const;
|
|
2132
|
-
defaultValue = apSchema
|
|
2140
|
+
defaultValue = schemaUtils.getDefaultFormState(apSchema, defaultValue);
|
|
2133
2141
|
}
|
|
2134
2142
|
if (!type && (ANY_OF_KEY4 in apSchema || ONE_OF_KEY4 in apSchema)) {
|
|
2135
2143
|
type = "object";
|
|
2136
2144
|
}
|
|
2137
2145
|
}
|
|
2138
|
-
const newValue = constValue ?? defaultValue ?? getDefaultValue(
|
|
2146
|
+
const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString, type);
|
|
2139
2147
|
set4(newFormData, newKey, newValue);
|
|
2140
2148
|
}
|
|
2141
2149
|
if (lastRenamedProperty.current.previousKey === newKey) {
|
|
@@ -2143,8 +2151,8 @@ function ObjectField(props) {
|
|
|
2143
2151
|
lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
|
|
2144
2152
|
}
|
|
2145
2153
|
onChange(newFormData, childFieldPathId.path);
|
|
2146
|
-
}, [formData, onChange,
|
|
2147
|
-
const handleKeyRename =
|
|
2154
|
+
}, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
|
|
2155
|
+
const handleKeyRename = useCallback5(
|
|
2148
2156
|
(oldKey, newKey) => {
|
|
2149
2157
|
if (oldKey !== newKey) {
|
|
2150
2158
|
const currentFormData = formDataRef.current;
|
|
@@ -2154,8 +2162,8 @@ function ObjectField(props) {
|
|
|
2154
2162
|
};
|
|
2155
2163
|
const newKeys = { [oldKey]: actualNewKey };
|
|
2156
2164
|
const keyValues = Object.keys(newFormData).map((key) => {
|
|
2157
|
-
const
|
|
2158
|
-
return { [
|
|
2165
|
+
const mappedKey = Object.hasOwn(newKeys, key) ? newKeys[key] : key;
|
|
2166
|
+
return { [mappedKey]: newFormData[key] };
|
|
2159
2167
|
});
|
|
2160
2168
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
2161
2169
|
formDataRef.current = renamedObj;
|
|
@@ -2168,13 +2176,13 @@ function ObjectField(props) {
|
|
|
2168
2176
|
},
|
|
2169
2177
|
[onChange, childFieldPathId, getAvailableKey]
|
|
2170
2178
|
);
|
|
2171
|
-
const handleRemoveProperty =
|
|
2179
|
+
const handleRemoveProperty = useCallback5(
|
|
2172
2180
|
(key) => {
|
|
2173
2181
|
onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
|
|
2174
2182
|
},
|
|
2175
2183
|
[onChange, childFieldPathId]
|
|
2176
2184
|
);
|
|
2177
|
-
const getStableKey =
|
|
2185
|
+
const getStableKey = useCallback5((property) => {
|
|
2178
2186
|
if (lastRenamedProperty.current.currentKey === property) {
|
|
2179
2187
|
return lastRenamedProperty.current.previousKey;
|
|
2180
2188
|
}
|
|
@@ -2186,31 +2194,33 @@ function ObjectField(props) {
|
|
|
2186
2194
|
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
2187
2195
|
} catch (err) {
|
|
2188
2196
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2189
|
-
/* @__PURE__ */
|
|
2190
|
-
/* @__PURE__ */
|
|
2197
|
+
/* @__PURE__ */ jsx10("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx10(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString5.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
2198
|
+
/* @__PURE__ */ jsx10("pre", { children: JSON.stringify(schema) })
|
|
2191
2199
|
] });
|
|
2192
2200
|
}
|
|
2193
2201
|
}
|
|
2194
|
-
const Template =
|
|
2195
|
-
const optionalDataControl = renderOptionalField ? /* @__PURE__ */
|
|
2202
|
+
const Template = getTemplate8("ObjectFieldTemplate", registry, uiOptions);
|
|
2203
|
+
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsx10(OptionalDataControlsField2, { ...props, fieldPathId: childFieldPathId, schema }) : void 0;
|
|
2196
2204
|
const templateProps = {
|
|
2197
2205
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
2198
2206
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
2199
2207
|
description: uiOptions.label === false ? void 0 : description,
|
|
2200
|
-
properties: orderedProperties.map((
|
|
2201
|
-
const addedByAdditionalProperties =
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
const
|
|
2208
|
+
properties: orderedProperties.map((propertyName) => {
|
|
2209
|
+
const addedByAdditionalProperties = Boolean(
|
|
2210
|
+
schema.properties?.[propertyName]?.[ADDITIONAL_PROPERTY_FLAG]
|
|
2211
|
+
);
|
|
2212
|
+
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
|
|
2213
|
+
const hidden = getUiOptions9(fieldUiSchema).widget === "hidden";
|
|
2214
|
+
const content = /* @__PURE__ */ jsx10(
|
|
2205
2215
|
ObjectFieldProperty,
|
|
2206
2216
|
{
|
|
2207
|
-
propertyName
|
|
2208
|
-
required: isRequired(schema,
|
|
2209
|
-
schema: get4(schema, [PROPERTIES_KEY3,
|
|
2217
|
+
propertyName,
|
|
2218
|
+
required: isRequired(schema, propertyName),
|
|
2219
|
+
schema: get4(schema, [PROPERTIES_KEY3, propertyName], {}),
|
|
2210
2220
|
uiSchema: fieldUiSchema,
|
|
2211
|
-
errorSchema: get4(errorSchema, [
|
|
2221
|
+
errorSchema: get4(errorSchema, [propertyName]),
|
|
2212
2222
|
fieldPathId: childFieldPathId,
|
|
2213
|
-
formData: get4(formData, [
|
|
2223
|
+
formData: get4(formData, [propertyName]),
|
|
2214
2224
|
handleKeyRename,
|
|
2215
2225
|
handleRemoveProperty,
|
|
2216
2226
|
addedByAdditionalProperties,
|
|
@@ -2222,11 +2232,11 @@ function ObjectField(props) {
|
|
|
2222
2232
|
readonly,
|
|
2223
2233
|
hideError
|
|
2224
2234
|
},
|
|
2225
|
-
getStableKey(
|
|
2235
|
+
getStableKey(propertyName)
|
|
2226
2236
|
);
|
|
2227
2237
|
return {
|
|
2228
2238
|
content,
|
|
2229
|
-
name:
|
|
2239
|
+
name: propertyName,
|
|
2230
2240
|
readonly,
|
|
2231
2241
|
disabled,
|
|
2232
2242
|
required,
|
|
@@ -2245,19 +2255,19 @@ function ObjectField(props) {
|
|
|
2245
2255
|
optionalDataControl,
|
|
2246
2256
|
className: renderOptionalField ? "rjsf-optional-object-field" : void 0
|
|
2247
2257
|
};
|
|
2248
|
-
return /* @__PURE__ */
|
|
2258
|
+
return /* @__PURE__ */ jsx10(Template, { ...templateProps, onAddProperty });
|
|
2249
2259
|
}
|
|
2250
2260
|
|
|
2251
2261
|
// src/components/fields/OptionalDataControlsField.tsx
|
|
2252
2262
|
import {
|
|
2253
2263
|
getSchemaType,
|
|
2254
|
-
getTemplate as
|
|
2255
|
-
getUiOptions as
|
|
2264
|
+
getTemplate as getTemplate9,
|
|
2265
|
+
getUiOptions as getUiOptions10,
|
|
2256
2266
|
isFormDataAvailable as isFormDataAvailable4,
|
|
2257
2267
|
optionalControlsId,
|
|
2258
2268
|
TranslatableString as TranslatableString6
|
|
2259
2269
|
} from "@rjsf/utils";
|
|
2260
|
-
import { jsx as
|
|
2270
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2261
2271
|
function OptionalDataControlsField(props) {
|
|
2262
2272
|
const {
|
|
2263
2273
|
schema,
|
|
@@ -2271,8 +2281,8 @@ function OptionalDataControlsField(props) {
|
|
|
2271
2281
|
registry
|
|
2272
2282
|
} = props;
|
|
2273
2283
|
const { globalUiOptions = {}, schemaUtils, translateString } = registry;
|
|
2274
|
-
const uiOptions =
|
|
2275
|
-
const OptionalDataControlsTemplate2 =
|
|
2284
|
+
const uiOptions = getUiOptions10(uiSchema, globalUiOptions);
|
|
2285
|
+
const OptionalDataControlsTemplate2 = getTemplate9(
|
|
2276
2286
|
"OptionalDataControlsTemplate",
|
|
2277
2287
|
registry,
|
|
2278
2288
|
uiOptions
|
|
@@ -2302,7 +2312,7 @@ function OptionalDataControlsField(props) {
|
|
|
2302
2312
|
};
|
|
2303
2313
|
}
|
|
2304
2314
|
}
|
|
2305
|
-
return label && /* @__PURE__ */
|
|
2315
|
+
return label && /* @__PURE__ */ jsx11(
|
|
2306
2316
|
OptionalDataControlsTemplate2,
|
|
2307
2317
|
{
|
|
2308
2318
|
id,
|
|
@@ -2317,19 +2327,21 @@ function OptionalDataControlsField(props) {
|
|
|
2317
2327
|
}
|
|
2318
2328
|
|
|
2319
2329
|
// src/components/fields/SchemaField.tsx
|
|
2320
|
-
import { useCallback as
|
|
2330
|
+
import { useCallback as useCallback6, memo as memo3 } from "react";
|
|
2321
2331
|
import {
|
|
2322
2332
|
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG2,
|
|
2323
2333
|
ANY_OF_KEY as ANY_OF_KEY5,
|
|
2334
|
+
deepEquals as deepEquals2,
|
|
2324
2335
|
descriptionId,
|
|
2325
2336
|
getSchemaType as getSchemaType2,
|
|
2326
|
-
getTemplate as
|
|
2327
|
-
getUiOptions as
|
|
2337
|
+
getTemplate as getTemplate10,
|
|
2338
|
+
getUiOptions as getUiOptions11,
|
|
2328
2339
|
ID_KEY as ID_KEY4,
|
|
2329
2340
|
isFormDataAvailable as isFormDataAvailable5,
|
|
2330
2341
|
ONE_OF_KEY as ONE_OF_KEY5,
|
|
2331
2342
|
resolveUiSchema,
|
|
2332
|
-
|
|
2343
|
+
RJSF_REF_CYCLE_KEY as RJSF_REF_CYCLE_KEY2,
|
|
2344
|
+
shallowEquals,
|
|
2333
2345
|
shouldRenderOptionalField as shouldRenderOptionalField4,
|
|
2334
2346
|
toFieldPathId as toFieldPathId5,
|
|
2335
2347
|
TranslatableString as TranslatableString7,
|
|
@@ -2337,7 +2349,7 @@ import {
|
|
|
2337
2349
|
} from "@rjsf/utils";
|
|
2338
2350
|
import isObject5 from "lodash/isObject";
|
|
2339
2351
|
import omit3 from "lodash/omit";
|
|
2340
|
-
import { Fragment, jsx as
|
|
2352
|
+
import { Fragment, jsx as jsx12, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2341
2353
|
var COMPONENT_TYPES = {
|
|
2342
2354
|
array: "ArrayField",
|
|
2343
2355
|
boolean: "BooleanField",
|
|
@@ -2348,8 +2360,8 @@ var COMPONENT_TYPES = {
|
|
|
2348
2360
|
null: "NullField"
|
|
2349
2361
|
};
|
|
2350
2362
|
function getFieldComponent(schema, uiOptions, registry) {
|
|
2351
|
-
const field = uiOptions
|
|
2352
|
-
const { fields: fields2 } = registry;
|
|
2363
|
+
const { field } = uiOptions;
|
|
2364
|
+
const { fields: fields2, schemaUtils } = registry;
|
|
2353
2365
|
if (typeof field === "function") {
|
|
2354
2366
|
return field;
|
|
2355
2367
|
}
|
|
@@ -2363,10 +2375,10 @@ function getFieldComponent(schema, uiOptions, registry) {
|
|
|
2363
2375
|
if (schemaId && schemaId in fields2) {
|
|
2364
2376
|
componentName = schemaId;
|
|
2365
2377
|
}
|
|
2366
|
-
if (
|
|
2378
|
+
if ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) && componentName !== "ObjectField") {
|
|
2367
2379
|
return () => null;
|
|
2368
2380
|
}
|
|
2369
|
-
return componentName in fields2 ? fields2[componentName] : fields2
|
|
2381
|
+
return componentName in fields2 ? fields2[componentName] : fields2.FallbackField;
|
|
2370
2382
|
}
|
|
2371
2383
|
function SchemaFieldRender(props) {
|
|
2372
2384
|
const {
|
|
@@ -2385,26 +2397,29 @@ function SchemaFieldRender(props) {
|
|
|
2385
2397
|
wasPropertyKeyModified = false
|
|
2386
2398
|
} = props;
|
|
2387
2399
|
const { schemaUtils, globalFormOptions, globalUiOptions, fields: fields2 } = registry;
|
|
2388
|
-
const { AnyOfField: _AnyOfField, OneOfField: _OneOfField } = fields2;
|
|
2400
|
+
const { AnyOfField: _AnyOfField, OneOfField: _OneOfField, CyclicSchemaField: CyclicSchemaField2 } = fields2;
|
|
2401
|
+
const fieldId = fieldPathId[ID_KEY4];
|
|
2402
|
+
const handleFieldComponentChange = useCallback6(
|
|
2403
|
+
(newFormData, path, newErrorSchema, id2) => {
|
|
2404
|
+
const theId = id2 || fieldId;
|
|
2405
|
+
return onChange(newFormData, path, newErrorSchema, theId);
|
|
2406
|
+
},
|
|
2407
|
+
[fieldId, onChange]
|
|
2408
|
+
);
|
|
2409
|
+
if (_schema[RJSF_REF_CYCLE_KEY2]) {
|
|
2410
|
+
return /* @__PURE__ */ jsx12(CyclicSchemaField2, { ...props });
|
|
2411
|
+
}
|
|
2389
2412
|
const uiSchema = resolveUiSchema(_schema, _uiSchema, registry);
|
|
2390
|
-
const uiOptions =
|
|
2391
|
-
const FieldTemplate2 =
|
|
2392
|
-
const DescriptionFieldTemplate =
|
|
2413
|
+
const uiOptions = getUiOptions11(uiSchema, globalUiOptions);
|
|
2414
|
+
const FieldTemplate2 = getTemplate10("FieldTemplate", registry, uiOptions);
|
|
2415
|
+
const DescriptionFieldTemplate = getTemplate10(
|
|
2393
2416
|
"DescriptionFieldTemplate",
|
|
2394
2417
|
registry,
|
|
2395
2418
|
uiOptions
|
|
2396
2419
|
);
|
|
2397
|
-
const FieldHelpTemplate2 =
|
|
2398
|
-
const FieldErrorTemplate2 =
|
|
2420
|
+
const FieldHelpTemplate2 = getTemplate10("FieldHelpTemplate", registry, uiOptions);
|
|
2421
|
+
const FieldErrorTemplate2 = getTemplate10("FieldErrorTemplate", registry, uiOptions);
|
|
2399
2422
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2400
|
-
const fieldId = fieldPathId[ID_KEY4];
|
|
2401
|
-
const handleFieldComponentChange = useCallback5(
|
|
2402
|
-
(formData2, path, newErrorSchema, id2) => {
|
|
2403
|
-
const theId = id2 || fieldId;
|
|
2404
|
-
return onChange(formData2, path, newErrorSchema, theId);
|
|
2405
|
-
},
|
|
2406
|
-
[fieldId, onChange]
|
|
2407
|
-
);
|
|
2408
2423
|
const FieldComponent = getFieldComponent(schema, uiOptions, registry);
|
|
2409
2424
|
const isDeprecated = Boolean(schema.deprecated);
|
|
2410
2425
|
const deprecatedHandling = isDeprecated ? uiOptions.deprecatedHandling ?? "label" : void 0;
|
|
@@ -2425,12 +2440,12 @@ function SchemaFieldRender(props) {
|
|
|
2425
2440
|
if (schema[ANY_OF_KEY5]) {
|
|
2426
2441
|
XxxOfField = _AnyOfField;
|
|
2427
2442
|
XxxOfOptions = schema[ANY_OF_KEY5].map(
|
|
2428
|
-
(
|
|
2443
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema(isObject5(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2429
2444
|
);
|
|
2430
2445
|
} else if (schema[ONE_OF_KEY5]) {
|
|
2431
2446
|
XxxOfField = _OneOfField;
|
|
2432
2447
|
XxxOfOptions = schema[ONE_OF_KEY5].map(
|
|
2433
|
-
(
|
|
2448
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema(isObject5(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2434
2449
|
);
|
|
2435
2450
|
}
|
|
2436
2451
|
const isOptionalRender = shouldRenderOptionalField4(registry, schema, required, uiSchema);
|
|
@@ -2448,7 +2463,7 @@ function SchemaFieldRender(props) {
|
|
|
2448
2463
|
if (UI_OPTIONS_KEY2 in fieldUiSchema) {
|
|
2449
2464
|
fieldUiSchema[UI_OPTIONS_KEY2] = omit3(fieldUiSchema[UI_OPTIONS_KEY2], ["classNames", "style"]);
|
|
2450
2465
|
}
|
|
2451
|
-
const field = /* @__PURE__ */
|
|
2466
|
+
const field = /* @__PURE__ */ jsx12(
|
|
2452
2467
|
FieldComponent,
|
|
2453
2468
|
{
|
|
2454
2469
|
...props,
|
|
@@ -2475,7 +2490,7 @@ function SchemaFieldRender(props) {
|
|
|
2475
2490
|
label = registry.translateString(TranslatableString7.DeprecatedLabel, [label]);
|
|
2476
2491
|
}
|
|
2477
2492
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2478
|
-
const help = uiOptions
|
|
2493
|
+
const { help } = uiOptions;
|
|
2479
2494
|
const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
|
|
2480
2495
|
const classNames = ["rjsf-field", `rjsf-field-${getSchemaType2(schema)}`];
|
|
2481
2496
|
if (!hideError && __errors && __errors.length > 0) {
|
|
@@ -2484,7 +2499,7 @@ function SchemaFieldRender(props) {
|
|
|
2484
2499
|
if (uiOptions.classNames) {
|
|
2485
2500
|
classNames.push(uiOptions.classNames);
|
|
2486
2501
|
}
|
|
2487
|
-
const helpComponent = /* @__PURE__ */
|
|
2502
|
+
const helpComponent = /* @__PURE__ */ jsx12(
|
|
2488
2503
|
FieldHelpTemplate2,
|
|
2489
2504
|
{
|
|
2490
2505
|
help,
|
|
@@ -2495,7 +2510,7 @@ function SchemaFieldRender(props) {
|
|
|
2495
2510
|
registry
|
|
2496
2511
|
}
|
|
2497
2512
|
);
|
|
2498
|
-
const errorsComponent = hideError || XxxOfField && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */
|
|
2513
|
+
const errorsComponent = hideError || XxxOfField && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ jsx12(
|
|
2499
2514
|
FieldErrorTemplate2,
|
|
2500
2515
|
{
|
|
2501
2516
|
errors: __errors,
|
|
@@ -2507,7 +2522,7 @@ function SchemaFieldRender(props) {
|
|
|
2507
2522
|
}
|
|
2508
2523
|
);
|
|
2509
2524
|
const fieldProps = {
|
|
2510
|
-
description: /* @__PURE__ */
|
|
2525
|
+
description: /* @__PURE__ */ jsx12(
|
|
2511
2526
|
DescriptionFieldTemplate,
|
|
2512
2527
|
{
|
|
2513
2528
|
id: descriptionId(id),
|
|
@@ -2542,9 +2557,9 @@ function SchemaFieldRender(props) {
|
|
|
2542
2557
|
uiSchema,
|
|
2543
2558
|
registry
|
|
2544
2559
|
};
|
|
2545
|
-
return /* @__PURE__ */
|
|
2560
|
+
return /* @__PURE__ */ jsx12(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
2546
2561
|
field,
|
|
2547
|
-
XxxOfField && /* @__PURE__ */
|
|
2562
|
+
XxxOfField && /* @__PURE__ */ jsx12(
|
|
2548
2563
|
XxxOfField,
|
|
2549
2564
|
{
|
|
2550
2565
|
name,
|
|
@@ -2566,29 +2581,22 @@ function SchemaFieldRender(props) {
|
|
|
2566
2581
|
)
|
|
2567
2582
|
] }) });
|
|
2568
2583
|
}
|
|
2569
|
-
var SchemaField =
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
} = this.props;
|
|
2574
|
-
const { experimental_componentUpdateStrategy = "customDeep" } = globalFormOptions;
|
|
2575
|
-
return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
|
|
2584
|
+
var SchemaField = memo3(SchemaFieldRender, (prevProps, nextProps) => {
|
|
2585
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = nextProps.registry.globalFormOptions;
|
|
2586
|
+
if (experimental_componentUpdateStrategy === "always") {
|
|
2587
|
+
return false;
|
|
2576
2588
|
}
|
|
2577
|
-
|
|
2578
|
-
return
|
|
2589
|
+
if (experimental_componentUpdateStrategy === "shallow") {
|
|
2590
|
+
return shallowEquals(prevProps, nextProps);
|
|
2579
2591
|
}
|
|
2580
|
-
|
|
2592
|
+
return deepEquals2(prevProps, nextProps);
|
|
2593
|
+
});
|
|
2581
2594
|
var SchemaField_default = SchemaField;
|
|
2582
2595
|
|
|
2583
2596
|
// src/components/fields/StringField.tsx
|
|
2584
|
-
import { useCallback as
|
|
2585
|
-
import {
|
|
2586
|
-
|
|
2587
|
-
getUiOptions as getUiOptions11,
|
|
2588
|
-
optionsList as optionsList4,
|
|
2589
|
-
hasWidget
|
|
2590
|
-
} from "@rjsf/utils";
|
|
2591
|
-
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2597
|
+
import { useCallback as useCallback7 } from "react";
|
|
2598
|
+
import { getWidget as getWidget5, getUiOptions as getUiOptions12, optionsList as optionsList4, hasWidget } from "@rjsf/utils";
|
|
2599
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2592
2600
|
function StringField(props) {
|
|
2593
2601
|
const {
|
|
2594
2602
|
schema,
|
|
@@ -2615,17 +2623,15 @@ function StringField(props) {
|
|
|
2615
2623
|
if (format && hasWidget(schema, format, widgets2)) {
|
|
2616
2624
|
defaultWidget = format;
|
|
2617
2625
|
}
|
|
2618
|
-
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } =
|
|
2626
|
+
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = getUiOptions12(uiSchema);
|
|
2619
2627
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2620
2628
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
2621
2629
|
const Widget = getWidget5(schema, widget, widgets2);
|
|
2622
|
-
const onWidgetChange =
|
|
2623
|
-
(value, errorSchema, id) =>
|
|
2624
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2625
|
-
},
|
|
2630
|
+
const onWidgetChange = useCallback7(
|
|
2631
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
2626
2632
|
[onChange, fieldPathId]
|
|
2627
2633
|
);
|
|
2628
|
-
return /* @__PURE__ */
|
|
2634
|
+
return /* @__PURE__ */ jsx13(
|
|
2629
2635
|
Widget,
|
|
2630
2636
|
{
|
|
2631
2637
|
options: { ...options, enumOptions },
|
|
@@ -2660,6 +2666,7 @@ function fields() {
|
|
|
2660
2666
|
ArrayField,
|
|
2661
2667
|
// ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
|
|
2662
2668
|
BooleanField: BooleanField_default,
|
|
2669
|
+
CyclicSchemaField,
|
|
2663
2670
|
FallbackField,
|
|
2664
2671
|
LayoutGridField,
|
|
2665
2672
|
LayoutHeaderField,
|
|
@@ -2676,25 +2683,21 @@ function fields() {
|
|
|
2676
2683
|
var fields_default = fields;
|
|
2677
2684
|
|
|
2678
2685
|
// src/components/templates/ArrayFieldDescriptionTemplate.tsx
|
|
2679
|
-
import {
|
|
2680
|
-
|
|
2681
|
-
getTemplate as getTemplate10,
|
|
2682
|
-
getUiOptions as getUiOptions12
|
|
2683
|
-
} from "@rjsf/utils";
|
|
2684
|
-
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2686
|
+
import { descriptionId as descriptionId2, getTemplate as getTemplate11, getUiOptions as getUiOptions13 } from "@rjsf/utils";
|
|
2687
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
2685
2688
|
function ArrayFieldDescriptionTemplate(props) {
|
|
2686
2689
|
const { fieldPathId, description, registry, schema, uiSchema } = props;
|
|
2687
|
-
const options =
|
|
2690
|
+
const options = getUiOptions13(uiSchema, registry.globalUiOptions);
|
|
2688
2691
|
const { label: displayLabel = true } = options;
|
|
2689
2692
|
if (!description || !displayLabel) {
|
|
2690
2693
|
return null;
|
|
2691
2694
|
}
|
|
2692
|
-
const DescriptionFieldTemplate =
|
|
2695
|
+
const DescriptionFieldTemplate = getTemplate11(
|
|
2693
2696
|
"DescriptionFieldTemplate",
|
|
2694
2697
|
registry,
|
|
2695
2698
|
options
|
|
2696
2699
|
);
|
|
2697
|
-
return /* @__PURE__ */
|
|
2700
|
+
return /* @__PURE__ */ jsx14(
|
|
2698
2701
|
DescriptionFieldTemplate,
|
|
2699
2702
|
{
|
|
2700
2703
|
id: descriptionId2(fieldPathId),
|
|
@@ -2707,10 +2710,8 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
2707
2710
|
}
|
|
2708
2711
|
|
|
2709
2712
|
// src/components/templates/ArrayFieldItemButtonsTemplate.tsx
|
|
2710
|
-
import {
|
|
2711
|
-
|
|
2712
|
-
} from "@rjsf/utils";
|
|
2713
|
-
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2713
|
+
import { buttonId } from "@rjsf/utils";
|
|
2714
|
+
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2714
2715
|
function ArrayFieldItemButtonsTemplate(props) {
|
|
2715
2716
|
const {
|
|
2716
2717
|
disabled,
|
|
@@ -2729,7 +2730,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2729
2730
|
} = props;
|
|
2730
2731
|
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
2731
2732
|
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
2732
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */
|
|
2733
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx15(
|
|
2733
2734
|
MoveUpButton2,
|
|
2734
2735
|
{
|
|
2735
2736
|
id: buttonId(fieldPathId, "moveUp"),
|
|
@@ -2740,7 +2741,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2740
2741
|
registry
|
|
2741
2742
|
}
|
|
2742
2743
|
),
|
|
2743
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */
|
|
2744
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx15(
|
|
2744
2745
|
MoveDownButton2,
|
|
2745
2746
|
{
|
|
2746
2747
|
id: buttonId(fieldPathId, "moveDown"),
|
|
@@ -2751,7 +2752,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2751
2752
|
registry
|
|
2752
2753
|
}
|
|
2753
2754
|
),
|
|
2754
|
-
hasCopy && /* @__PURE__ */
|
|
2755
|
+
hasCopy && /* @__PURE__ */ jsx15(
|
|
2755
2756
|
CopyButton2,
|
|
2756
2757
|
{
|
|
2757
2758
|
id: buttonId(fieldPathId, "copy"),
|
|
@@ -2762,7 +2763,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2762
2763
|
registry
|
|
2763
2764
|
}
|
|
2764
2765
|
),
|
|
2765
|
-
hasRemove && /* @__PURE__ */
|
|
2766
|
+
hasRemove && /* @__PURE__ */ jsx15(
|
|
2766
2767
|
RemoveButton2,
|
|
2767
2768
|
{
|
|
2768
2769
|
id: buttonId(fieldPathId, "remove"),
|
|
@@ -2777,15 +2778,12 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2777
2778
|
}
|
|
2778
2779
|
|
|
2779
2780
|
// src/components/templates/ArrayFieldItemTemplate.tsx
|
|
2780
|
-
import {
|
|
2781
|
-
|
|
2782
|
-
getUiOptions as getUiOptions13
|
|
2783
|
-
} from "@rjsf/utils";
|
|
2784
|
-
import { jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2781
|
+
import { getTemplate as getTemplate12, getUiOptions as getUiOptions14 } from "@rjsf/utils";
|
|
2782
|
+
import { jsx as jsx16, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2785
2783
|
function ArrayFieldItemTemplate(props) {
|
|
2786
2784
|
const { children, className, buttonsProps, displayLabel, hasDescription, hasToolbar, registry, uiSchema } = props;
|
|
2787
|
-
const uiOptions =
|
|
2788
|
-
const ArrayFieldItemButtonsTemplate2 =
|
|
2785
|
+
const uiOptions = getUiOptions14(uiSchema);
|
|
2786
|
+
const ArrayFieldItemButtonsTemplate2 = getTemplate12(
|
|
2789
2787
|
"ArrayFieldItemButtonsTemplate",
|
|
2790
2788
|
registry,
|
|
2791
2789
|
uiOptions
|
|
@@ -2800,18 +2798,14 @@ function ArrayFieldItemTemplate(props) {
|
|
|
2800
2798
|
const containerStyle = { display: "flex", alignItems: displayLabel ? "center" : "baseline" };
|
|
2801
2799
|
const toolbarStyle = { display: "flex", justifyContent: "flex-end", marginTop: displayLabel ? `${margin}px` : 0 };
|
|
2802
2800
|
return /* @__PURE__ */ jsxs4("div", { className, style: containerStyle, children: [
|
|
2803
|
-
/* @__PURE__ */
|
|
2804
|
-
hasToolbar && /* @__PURE__ */
|
|
2801
|
+
/* @__PURE__ */ jsx16("div", { className: hasToolbar ? "col-xs-9 col-md-10 col-xl-11" : "col-xs-12", children }),
|
|
2802
|
+
hasToolbar && /* @__PURE__ */ jsx16("div", { className: "col-xs-3 col-md-2 col-xl-1 array-item-toolbox", children: /* @__PURE__ */ jsx16("div", { className: "btn-group", style: toolbarStyle, children: /* @__PURE__ */ jsx16(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle }) }) })
|
|
2805
2803
|
] });
|
|
2806
2804
|
}
|
|
2807
2805
|
|
|
2808
2806
|
// src/components/templates/ArrayFieldTemplate.tsx
|
|
2809
|
-
import {
|
|
2810
|
-
|
|
2811
|
-
getUiOptions as getUiOptions14,
|
|
2812
|
-
buttonId as buttonId2
|
|
2813
|
-
} from "@rjsf/utils";
|
|
2814
|
-
import { jsx as jsx16, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2807
|
+
import { getTemplate as getTemplate13, getUiOptions as getUiOptions15, buttonId as buttonId2 } from "@rjsf/utils";
|
|
2808
|
+
import { jsx as jsx17, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2815
2809
|
function ArrayFieldTemplate(props) {
|
|
2816
2810
|
const {
|
|
2817
2811
|
canAdd,
|
|
@@ -2828,13 +2822,13 @@ function ArrayFieldTemplate(props) {
|
|
|
2828
2822
|
schema,
|
|
2829
2823
|
title
|
|
2830
2824
|
} = props;
|
|
2831
|
-
const uiOptions =
|
|
2832
|
-
const ArrayFieldDescriptionTemplate2 =
|
|
2825
|
+
const uiOptions = getUiOptions15(uiSchema);
|
|
2826
|
+
const ArrayFieldDescriptionTemplate2 = getTemplate13(
|
|
2833
2827
|
"ArrayFieldDescriptionTemplate",
|
|
2834
2828
|
registry,
|
|
2835
2829
|
uiOptions
|
|
2836
2830
|
);
|
|
2837
|
-
const ArrayFieldTitleTemplate2 =
|
|
2831
|
+
const ArrayFieldTitleTemplate2 = getTemplate13(
|
|
2838
2832
|
"ArrayFieldTitleTemplate",
|
|
2839
2833
|
registry,
|
|
2840
2834
|
uiOptions
|
|
@@ -2844,7 +2838,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2844
2838
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
2845
2839
|
} = registry.templates;
|
|
2846
2840
|
return /* @__PURE__ */ jsxs5("fieldset", { className, id: fieldPathId.$id, children: [
|
|
2847
|
-
/* @__PURE__ */
|
|
2841
|
+
/* @__PURE__ */ jsx17(
|
|
2848
2842
|
ArrayFieldTitleTemplate2,
|
|
2849
2843
|
{
|
|
2850
2844
|
fieldPathId,
|
|
@@ -2856,7 +2850,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2856
2850
|
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
2857
2851
|
}
|
|
2858
2852
|
),
|
|
2859
|
-
/* @__PURE__ */
|
|
2853
|
+
/* @__PURE__ */ jsx17(
|
|
2860
2854
|
ArrayFieldDescriptionTemplate2,
|
|
2861
2855
|
{
|
|
2862
2856
|
fieldPathId,
|
|
@@ -2867,8 +2861,8 @@ function ArrayFieldTemplate(props) {
|
|
|
2867
2861
|
}
|
|
2868
2862
|
),
|
|
2869
2863
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
2870
|
-
/* @__PURE__ */
|
|
2871
|
-
canAdd && /* @__PURE__ */
|
|
2864
|
+
/* @__PURE__ */ jsx17("div", { className: "row array-item-list", children: items }),
|
|
2865
|
+
canAdd && /* @__PURE__ */ jsx17(
|
|
2872
2866
|
AddButton2,
|
|
2873
2867
|
{
|
|
2874
2868
|
id: buttonId2(fieldPathId, "add"),
|
|
@@ -2883,25 +2877,21 @@ function ArrayFieldTemplate(props) {
|
|
|
2883
2877
|
}
|
|
2884
2878
|
|
|
2885
2879
|
// src/components/templates/ArrayFieldTitleTemplate.tsx
|
|
2886
|
-
import {
|
|
2887
|
-
|
|
2888
|
-
getUiOptions as getUiOptions15,
|
|
2889
|
-
titleId as titleId2
|
|
2890
|
-
} from "@rjsf/utils";
|
|
2891
|
-
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
2880
|
+
import { getTemplate as getTemplate14, getUiOptions as getUiOptions16, titleId as titleId2 } from "@rjsf/utils";
|
|
2881
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2892
2882
|
function ArrayFieldTitleTemplate(props) {
|
|
2893
2883
|
const { fieldPathId, title, schema, uiSchema, required, registry, optionalDataControl } = props;
|
|
2894
|
-
const options =
|
|
2884
|
+
const options = getUiOptions16(uiSchema, registry.globalUiOptions);
|
|
2895
2885
|
const { label: displayLabel = true } = options;
|
|
2896
2886
|
if (!title || !displayLabel) {
|
|
2897
2887
|
return null;
|
|
2898
2888
|
}
|
|
2899
|
-
const TitleFieldTemplate =
|
|
2889
|
+
const TitleFieldTemplate = getTemplate14(
|
|
2900
2890
|
"TitleFieldTemplate",
|
|
2901
2891
|
registry,
|
|
2902
2892
|
options
|
|
2903
2893
|
);
|
|
2904
|
-
return /* @__PURE__ */
|
|
2894
|
+
return /* @__PURE__ */ jsx18(
|
|
2905
2895
|
TitleFieldTemplate,
|
|
2906
2896
|
{
|
|
2907
2897
|
id: titleId2(fieldPathId),
|
|
@@ -2916,31 +2906,28 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2916
2906
|
}
|
|
2917
2907
|
|
|
2918
2908
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2919
|
-
import { useCallback as
|
|
2920
|
-
import {
|
|
2921
|
-
ariaDescribedByIds,
|
|
2922
|
-
examplesId as examplesId2,
|
|
2923
|
-
getInputProps
|
|
2924
|
-
} from "@rjsf/utils";
|
|
2909
|
+
import { useCallback as useCallback8 } from "react";
|
|
2910
|
+
import { ariaDescribedByIds, examplesId as examplesId2, getInputProps } from "@rjsf/utils";
|
|
2925
2911
|
|
|
2926
2912
|
// src/components/SchemaExamples.tsx
|
|
2927
2913
|
import { examplesId } from "@rjsf/utils";
|
|
2928
|
-
import { jsx as
|
|
2914
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
2929
2915
|
function SchemaExamples(props) {
|
|
2930
2916
|
const { id, schema } = props;
|
|
2931
2917
|
const { examples, default: schemaDefault } = schema;
|
|
2932
2918
|
if (!Array.isArray(examples)) {
|
|
2933
2919
|
return null;
|
|
2934
2920
|
}
|
|
2935
|
-
return /* @__PURE__ */
|
|
2921
|
+
return /* @__PURE__ */ jsx19("datalist", { id: examplesId(id), children: examples.concat(
|
|
2936
2922
|
schemaDefault !== void 0 && !examples.map(String).includes(String(schemaDefault)) ? [schemaDefault] : []
|
|
2937
|
-
).map((example) =>
|
|
2938
|
-
|
|
2939
|
-
|
|
2923
|
+
).map((example) => (
|
|
2924
|
+
// oxlint-disable-next-line jsx-a11y/control-has-associated-label
|
|
2925
|
+
/* @__PURE__ */ jsx19("option", { value: example }, String(example))
|
|
2926
|
+
)) }, `datalist_${id}`);
|
|
2940
2927
|
}
|
|
2941
2928
|
|
|
2942
2929
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2943
|
-
import { Fragment as Fragment3, jsx as
|
|
2930
|
+
import { Fragment as Fragment3, jsx as jsx20, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2944
2931
|
function BaseInputTemplate(props) {
|
|
2945
2932
|
const {
|
|
2946
2933
|
id,
|
|
@@ -2982,19 +2969,16 @@ function BaseInputTemplate(props) {
|
|
|
2982
2969
|
} else {
|
|
2983
2970
|
inputValue = value == null ? "" : value;
|
|
2984
2971
|
}
|
|
2985
|
-
const
|
|
2986
|
-
({ target: { value:
|
|
2972
|
+
const handleChange = useCallback8(
|
|
2973
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
2987
2974
|
[onChange, options]
|
|
2988
2975
|
);
|
|
2989
|
-
const
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
);
|
|
2993
|
-
const _onFocus = useCallback7(
|
|
2994
|
-
({ target }) => onFocus(id, target && target.value),
|
|
2976
|
+
const handleBlur = useCallback8(({ target }) => onBlur(id, target?.value), [onBlur, id]);
|
|
2977
|
+
const handleFocus = useCallback8(
|
|
2978
|
+
({ target }) => onFocus(id, target?.value),
|
|
2995
2979
|
[onFocus, id]
|
|
2996
2980
|
);
|
|
2997
|
-
const
|
|
2981
|
+
const handleClear = useCallback8(
|
|
2998
2982
|
(e) => {
|
|
2999
2983
|
e.preventDefault();
|
|
3000
2984
|
e.stopPropagation();
|
|
@@ -3003,7 +2987,7 @@ function BaseInputTemplate(props) {
|
|
|
3003
2987
|
[onChange, options.emptyValue]
|
|
3004
2988
|
);
|
|
3005
2989
|
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
3006
|
-
/* @__PURE__ */
|
|
2990
|
+
/* @__PURE__ */ jsx20(
|
|
3007
2991
|
"input",
|
|
3008
2992
|
{
|
|
3009
2993
|
id,
|
|
@@ -3015,14 +2999,14 @@ function BaseInputTemplate(props) {
|
|
|
3015
2999
|
value: inputValue,
|
|
3016
3000
|
...inputProps,
|
|
3017
3001
|
list: schema.examples ? examplesId2(id) : void 0,
|
|
3018
|
-
onChange: onChangeOverride ||
|
|
3019
|
-
onBlur:
|
|
3020
|
-
onFocus:
|
|
3002
|
+
onChange: onChangeOverride || handleChange,
|
|
3003
|
+
onBlur: handleBlur,
|
|
3004
|
+
onFocus: handleFocus,
|
|
3021
3005
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
3022
3006
|
}
|
|
3023
3007
|
),
|
|
3024
|
-
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */
|
|
3025
|
-
/* @__PURE__ */
|
|
3008
|
+
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ jsx20(ClearButton2, { registry, onClick: handleClear }),
|
|
3009
|
+
/* @__PURE__ */ jsx20(SchemaExamples, { id, schema })
|
|
3026
3010
|
] });
|
|
3027
3011
|
}
|
|
3028
3012
|
|
|
@@ -3030,37 +3014,44 @@ function BaseInputTemplate(props) {
|
|
|
3030
3014
|
import { TranslatableString as TranslatableString9 } from "@rjsf/utils";
|
|
3031
3015
|
|
|
3032
3016
|
// src/components/templates/ButtonTemplates/IconButton.tsx
|
|
3017
|
+
import { memo as memo4 } from "react";
|
|
3033
3018
|
import { TranslatableString as TranslatableString8 } from "@rjsf/utils";
|
|
3034
|
-
import { jsx as
|
|
3035
|
-
function
|
|
3019
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
3020
|
+
function IconButtonFn(props) {
|
|
3036
3021
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
3037
|
-
return /* @__PURE__ */
|
|
3022
|
+
return /* @__PURE__ */ jsx21("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsx21("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
3038
3023
|
}
|
|
3039
|
-
|
|
3024
|
+
var IconButton = memo4(IconButtonFn);
|
|
3025
|
+
var IconButton_default = IconButton;
|
|
3026
|
+
function CopyButtonFn(props) {
|
|
3040
3027
|
const {
|
|
3041
3028
|
registry: { translateString }
|
|
3042
3029
|
} = props;
|
|
3043
|
-
return /* @__PURE__ */
|
|
3030
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.CopyButton), ...props, icon: "copy" });
|
|
3044
3031
|
}
|
|
3045
|
-
|
|
3032
|
+
var CopyButton = memo4(CopyButtonFn);
|
|
3033
|
+
function MoveDownButtonFn(props) {
|
|
3046
3034
|
const {
|
|
3047
3035
|
registry: { translateString }
|
|
3048
3036
|
} = props;
|
|
3049
|
-
return /* @__PURE__ */
|
|
3037
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.MoveDownButton), ...props, icon: "arrow-down" });
|
|
3050
3038
|
}
|
|
3051
|
-
|
|
3039
|
+
var MoveDownButton = memo4(MoveDownButtonFn);
|
|
3040
|
+
function MoveUpButtonFn(props) {
|
|
3052
3041
|
const {
|
|
3053
3042
|
registry: { translateString }
|
|
3054
3043
|
} = props;
|
|
3055
|
-
return /* @__PURE__ */
|
|
3044
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.MoveUpButton), ...props, icon: "arrow-up" });
|
|
3056
3045
|
}
|
|
3057
|
-
|
|
3046
|
+
var MoveUpButton = memo4(MoveUpButtonFn);
|
|
3047
|
+
function RemoveButtonFn(props) {
|
|
3058
3048
|
const {
|
|
3059
3049
|
registry: { translateString }
|
|
3060
3050
|
} = props;
|
|
3061
|
-
return /* @__PURE__ */
|
|
3051
|
+
return /* @__PURE__ */ jsx21(IconButton, { title: translateString(TranslatableString8.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
3062
3052
|
}
|
|
3063
|
-
|
|
3053
|
+
var RemoveButton = memo4(RemoveButtonFn);
|
|
3054
|
+
function ClearButtonFn({
|
|
3064
3055
|
id,
|
|
3065
3056
|
className,
|
|
3066
3057
|
onClick,
|
|
@@ -3069,7 +3060,7 @@ function ClearButton({
|
|
|
3069
3060
|
...props
|
|
3070
3061
|
}) {
|
|
3071
3062
|
const { translateString } = registry;
|
|
3072
|
-
return /* @__PURE__ */
|
|
3063
|
+
return /* @__PURE__ */ jsx21(
|
|
3073
3064
|
IconButton,
|
|
3074
3065
|
{
|
|
3075
3066
|
id,
|
|
@@ -3084,9 +3075,10 @@ function ClearButton({
|
|
|
3084
3075
|
}
|
|
3085
3076
|
);
|
|
3086
3077
|
}
|
|
3078
|
+
var ClearButton = memo4(ClearButtonFn);
|
|
3087
3079
|
|
|
3088
3080
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
3089
|
-
import { jsx as
|
|
3081
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
3090
3082
|
function AddButton({
|
|
3091
3083
|
id,
|
|
3092
3084
|
className,
|
|
@@ -3095,12 +3087,12 @@ function AddButton({
|
|
|
3095
3087
|
registry
|
|
3096
3088
|
}) {
|
|
3097
3089
|
const { translateString } = registry;
|
|
3098
|
-
return /* @__PURE__ */
|
|
3090
|
+
return /* @__PURE__ */ jsx22("div", { className: "row", children: /* @__PURE__ */ jsx22(
|
|
3099
3091
|
"p",
|
|
3100
3092
|
{
|
|
3101
3093
|
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}`,
|
|
3102
|
-
children: /* @__PURE__ */
|
|
3103
|
-
|
|
3094
|
+
children: /* @__PURE__ */ jsx22(
|
|
3095
|
+
IconButton_default,
|
|
3104
3096
|
{
|
|
3105
3097
|
id,
|
|
3106
3098
|
iconType: "info",
|
|
@@ -3118,13 +3110,13 @@ function AddButton({
|
|
|
3118
3110
|
|
|
3119
3111
|
// src/components/templates/ButtonTemplates/SubmitButton.tsx
|
|
3120
3112
|
import { getSubmitButtonOptions } from "@rjsf/utils";
|
|
3121
|
-
import { jsx as
|
|
3113
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
3122
3114
|
function SubmitButton({ uiSchema }) {
|
|
3123
3115
|
const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions(uiSchema);
|
|
3124
3116
|
if (norender) {
|
|
3125
3117
|
return null;
|
|
3126
3118
|
}
|
|
3127
|
-
return /* @__PURE__ */
|
|
3119
|
+
return /* @__PURE__ */ jsx23("div", { children: /* @__PURE__ */ jsx23("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
|
|
3128
3120
|
}
|
|
3129
3121
|
|
|
3130
3122
|
// src/components/templates/ButtonTemplates/index.ts
|
|
@@ -3141,62 +3133,83 @@ function buttonTemplates() {
|
|
|
3141
3133
|
}
|
|
3142
3134
|
var ButtonTemplates_default = buttonTemplates;
|
|
3143
3135
|
|
|
3136
|
+
// src/components/templates/CyclicSchemaExpandTemplate.tsx
|
|
3137
|
+
import { ID_KEY as ID_KEY5, TranslatableString as TranslatableString10 } from "@rjsf/utils";
|
|
3138
|
+
import { jsx as jsx24, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3139
|
+
function CyclicSchemaExpandTemplate(props) {
|
|
3140
|
+
const { name, fieldPathId, registry, onExpand } = props;
|
|
3141
|
+
const { translateString } = registry;
|
|
3142
|
+
const buttonId5 = `${fieldPathId[ID_KEY5]}-button`;
|
|
3143
|
+
return /* @__PURE__ */ jsxs7("div", { style: { marginTop: "1rem" }, children: [
|
|
3144
|
+
/* @__PURE__ */ jsx24("div", { className: "text-danger", children: translateString(TranslatableString10.CycleDetected, [name]) }),
|
|
3145
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
3146
|
+
/* @__PURE__ */ jsx24(
|
|
3147
|
+
"button",
|
|
3148
|
+
{
|
|
3149
|
+
id: buttonId5,
|
|
3150
|
+
type: "button",
|
|
3151
|
+
className: "btn btn-sm btn-warning",
|
|
3152
|
+
onClick: () => onExpand(fieldPathId[ID_KEY5]),
|
|
3153
|
+
children: translateString(TranslatableString10.ExpandButton)
|
|
3154
|
+
}
|
|
3155
|
+
),
|
|
3156
|
+
" "
|
|
3157
|
+
] })
|
|
3158
|
+
] });
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3144
3161
|
// src/components/RichDescription.tsx
|
|
3145
|
-
import {
|
|
3146
|
-
getTestIds as getTestIds2,
|
|
3147
|
-
getUiOptions as getUiOptions16
|
|
3148
|
-
} from "@rjsf/utils";
|
|
3162
|
+
import { getTestIds as getTestIds2, getUiOptions as getUiOptions17 } from "@rjsf/utils";
|
|
3149
3163
|
import { Markdown as Markdown2 } from "markdown-to-jsx/react";
|
|
3150
|
-
import { jsx as
|
|
3164
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
3151
3165
|
var TEST_IDS = getTestIds2();
|
|
3152
3166
|
function RichDescription({ description, registry, uiSchema = {} }) {
|
|
3153
3167
|
const { globalUiOptions } = registry;
|
|
3154
|
-
const uiOptions =
|
|
3168
|
+
const uiOptions = getUiOptions17(uiSchema, globalUiOptions);
|
|
3155
3169
|
if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
|
|
3156
|
-
return /* @__PURE__ */
|
|
3170
|
+
return /* @__PURE__ */ jsx25(Markdown2, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
3157
3171
|
}
|
|
3158
3172
|
return description;
|
|
3159
3173
|
}
|
|
3160
3174
|
RichDescription.TEST_IDS = TEST_IDS;
|
|
3161
3175
|
|
|
3162
3176
|
// src/components/templates/DescriptionField.tsx
|
|
3163
|
-
import { jsx as
|
|
3177
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
3164
3178
|
function DescriptionField(props) {
|
|
3165
3179
|
const { id, description, registry, uiSchema } = props;
|
|
3166
3180
|
if (!description) {
|
|
3167
3181
|
return null;
|
|
3168
3182
|
}
|
|
3169
|
-
return /* @__PURE__ */
|
|
3183
|
+
return /* @__PURE__ */ jsx26("div", { id, className: "field-description", children: /* @__PURE__ */ jsx26(RichDescription, { description, registry, uiSchema }) });
|
|
3170
3184
|
}
|
|
3171
3185
|
|
|
3172
3186
|
// src/components/templates/ErrorList.tsx
|
|
3173
|
-
import {
|
|
3174
|
-
|
|
3175
|
-
} from "@rjsf/utils";
|
|
3176
|
-
import { jsx as jsx25, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3187
|
+
import { TranslatableString as TranslatableString11 } from "@rjsf/utils";
|
|
3188
|
+
import { jsx as jsx27, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3177
3189
|
function ErrorList({
|
|
3178
3190
|
errors,
|
|
3179
3191
|
registry
|
|
3180
3192
|
}) {
|
|
3181
3193
|
const { translateString } = registry;
|
|
3182
|
-
return /* @__PURE__ */
|
|
3183
|
-
/* @__PURE__ */
|
|
3184
|
-
/* @__PURE__ */
|
|
3185
|
-
|
|
3186
|
-
|
|
3194
|
+
return /* @__PURE__ */ jsxs8("div", { className: "panel panel-danger errors", children: [
|
|
3195
|
+
/* @__PURE__ */ jsx27("div", { className: "panel-heading", children: /* @__PURE__ */ jsx27("h3", { className: "panel-title", children: translateString(TranslatableString11.ErrorsLabel) }) }),
|
|
3196
|
+
/* @__PURE__ */ jsx27("ul", { className: "list-group", children: errors.map((error, i) => (
|
|
3197
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3198
|
+
/* @__PURE__ */ jsx27("li", { className: "list-group-item text-danger", children: error.stack }, i)
|
|
3199
|
+
)) })
|
|
3187
3200
|
] });
|
|
3188
3201
|
}
|
|
3189
3202
|
|
|
3190
3203
|
// src/components/templates/FallbackFieldTemplate.tsx
|
|
3191
|
-
import { getTemplate as
|
|
3192
|
-
import { jsx as
|
|
3204
|
+
import { getTemplate as getTemplate15 } from "@rjsf/utils";
|
|
3205
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3193
3206
|
function FallbackFieldTemplate(props) {
|
|
3194
3207
|
const { schema, registry, typeSelector, schemaField } = props;
|
|
3195
|
-
const MultiSchemaFieldTemplate2 =
|
|
3208
|
+
const MultiSchemaFieldTemplate2 = getTemplate15(
|
|
3196
3209
|
"MultiSchemaFieldTemplate",
|
|
3197
3210
|
registry
|
|
3198
3211
|
);
|
|
3199
|
-
return /* @__PURE__ */
|
|
3212
|
+
return /* @__PURE__ */ jsx28(
|
|
3200
3213
|
MultiSchemaFieldTemplate2,
|
|
3201
3214
|
{
|
|
3202
3215
|
selector: typeSelector,
|
|
@@ -3209,28 +3222,26 @@ function FallbackFieldTemplate(props) {
|
|
|
3209
3222
|
|
|
3210
3223
|
// src/components/templates/FieldErrorTemplate.tsx
|
|
3211
3224
|
import { errorId } from "@rjsf/utils";
|
|
3212
|
-
import { jsx as
|
|
3225
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
3213
3226
|
function FieldErrorTemplate(props) {
|
|
3214
3227
|
const { errors = [], fieldPathId } = props;
|
|
3215
3228
|
if (errors.length === 0) {
|
|
3216
3229
|
return null;
|
|
3217
3230
|
}
|
|
3218
3231
|
const id = errorId(fieldPathId);
|
|
3219
|
-
return /* @__PURE__ */
|
|
3220
|
-
|
|
3221
|
-
|
|
3232
|
+
return /* @__PURE__ */ jsx29("div", { children: /* @__PURE__ */ jsx29("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => (
|
|
3233
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3234
|
+
/* @__PURE__ */ jsx29("li", { className: "text-danger", children: error }, index)
|
|
3235
|
+
)) }) });
|
|
3222
3236
|
}
|
|
3223
3237
|
|
|
3224
3238
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
3225
3239
|
import { helpId } from "@rjsf/utils";
|
|
3226
3240
|
|
|
3227
3241
|
// src/components/RichHelp.tsx
|
|
3228
|
-
import {
|
|
3229
|
-
getTestIds as getTestIds3,
|
|
3230
|
-
getUiOptions as getUiOptions17
|
|
3231
|
-
} from "@rjsf/utils";
|
|
3242
|
+
import { getTestIds as getTestIds3, getUiOptions as getUiOptions18 } from "@rjsf/utils";
|
|
3232
3243
|
import { Markdown as Markdown3 } from "markdown-to-jsx/react";
|
|
3233
|
-
import { jsx as
|
|
3244
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
3234
3245
|
var TEST_IDS2 = getTestIds3();
|
|
3235
3246
|
function RichHelp({
|
|
3236
3247
|
help,
|
|
@@ -3238,60 +3249,57 @@ function RichHelp({
|
|
|
3238
3249
|
uiSchema = {}
|
|
3239
3250
|
}) {
|
|
3240
3251
|
const { globalUiOptions } = registry;
|
|
3241
|
-
const uiOptions =
|
|
3252
|
+
const uiOptions = getUiOptions18(uiSchema, globalUiOptions);
|
|
3242
3253
|
if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
|
|
3243
|
-
return /* @__PURE__ */
|
|
3254
|
+
return /* @__PURE__ */ jsx30(Markdown3, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
|
|
3244
3255
|
}
|
|
3245
3256
|
return help;
|
|
3246
3257
|
}
|
|
3247
3258
|
RichHelp.TEST_IDS = TEST_IDS2;
|
|
3248
3259
|
|
|
3249
3260
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
3250
|
-
import { jsx as
|
|
3261
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
3251
3262
|
function FieldHelpTemplate(props) {
|
|
3252
3263
|
const { fieldPathId, help, uiSchema, registry } = props;
|
|
3253
3264
|
if (!help) {
|
|
3254
3265
|
return null;
|
|
3255
3266
|
}
|
|
3256
|
-
return /* @__PURE__ */
|
|
3267
|
+
return /* @__PURE__ */ jsx31("div", { id: helpId(fieldPathId), className: "help-block", children: /* @__PURE__ */ jsx31(RichHelp, { help, registry, uiSchema }) });
|
|
3257
3268
|
}
|
|
3258
3269
|
|
|
3259
3270
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3260
|
-
import {
|
|
3261
|
-
getTemplate as getTemplate15,
|
|
3262
|
-
getUiOptions as getUiOptions18
|
|
3263
|
-
} from "@rjsf/utils";
|
|
3271
|
+
import { getTemplate as getTemplate16, getUiOptions as getUiOptions19 } from "@rjsf/utils";
|
|
3264
3272
|
|
|
3265
3273
|
// src/components/templates/FieldTemplate/Label.tsx
|
|
3266
|
-
import { jsx as
|
|
3274
|
+
import { jsx as jsx32, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3267
3275
|
var REQUIRED_FIELD_SYMBOL = "*";
|
|
3268
3276
|
function Label(props) {
|
|
3269
3277
|
const { label, required, id } = props;
|
|
3270
3278
|
if (!label) {
|
|
3271
3279
|
return null;
|
|
3272
3280
|
}
|
|
3273
|
-
return /* @__PURE__ */
|
|
3281
|
+
return /* @__PURE__ */ jsxs9("label", { className: "control-label", htmlFor: id, children: [
|
|
3274
3282
|
label,
|
|
3275
|
-
required && /* @__PURE__ */
|
|
3283
|
+
required && /* @__PURE__ */ jsx32("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
|
|
3276
3284
|
] });
|
|
3277
3285
|
}
|
|
3278
3286
|
|
|
3279
3287
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3280
|
-
import { jsx as
|
|
3288
|
+
import { jsx as jsx33, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3281
3289
|
function FieldTemplate(props) {
|
|
3282
3290
|
const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
|
|
3283
|
-
const uiOptions =
|
|
3284
|
-
const WrapIfAdditionalTemplate2 =
|
|
3291
|
+
const uiOptions = getUiOptions19(uiSchema);
|
|
3292
|
+
const WrapIfAdditionalTemplate2 = getTemplate16(
|
|
3285
3293
|
"WrapIfAdditionalTemplate",
|
|
3286
3294
|
registry,
|
|
3287
3295
|
uiOptions
|
|
3288
3296
|
);
|
|
3289
3297
|
if (hidden) {
|
|
3290
|
-
return /* @__PURE__ */
|
|
3298
|
+
return /* @__PURE__ */ jsx33("div", { className: "hidden", children });
|
|
3291
3299
|
}
|
|
3292
3300
|
const isCheckbox = uiOptions.widget === "checkbox";
|
|
3293
|
-
return /* @__PURE__ */
|
|
3294
|
-
displayLabel && !isCheckbox && /* @__PURE__ */
|
|
3301
|
+
return /* @__PURE__ */ jsxs10(WrapIfAdditionalTemplate2, { ...props, children: [
|
|
3302
|
+
displayLabel && !isCheckbox && /* @__PURE__ */ jsx33(Label, { label, required, id }),
|
|
3295
3303
|
displayLabel && description ? description : null,
|
|
3296
3304
|
children,
|
|
3297
3305
|
errors,
|
|
@@ -3303,32 +3311,25 @@ function FieldTemplate(props) {
|
|
|
3303
3311
|
var FieldTemplate_default = FieldTemplate;
|
|
3304
3312
|
|
|
3305
3313
|
// src/components/templates/GridTemplate.tsx
|
|
3306
|
-
import { jsx as
|
|
3314
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
3307
3315
|
function GridTemplate(props) {
|
|
3308
3316
|
const { children, column, className, ...rest } = props;
|
|
3309
|
-
return /* @__PURE__ */
|
|
3317
|
+
return /* @__PURE__ */ jsx34("div", { className, ...rest, children });
|
|
3310
3318
|
}
|
|
3311
3319
|
|
|
3312
3320
|
// src/components/templates/MultiSchemaFieldTemplate.tsx
|
|
3313
|
-
import { jsx as
|
|
3321
|
+
import { jsx as jsx35, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3314
3322
|
function MultiSchemaFieldTemplate(props) {
|
|
3315
3323
|
const { selector, optionSchemaField } = props;
|
|
3316
|
-
return /* @__PURE__ */
|
|
3317
|
-
/* @__PURE__ */
|
|
3324
|
+
return /* @__PURE__ */ jsxs11("div", { className: "panel panel-default panel-body", children: [
|
|
3325
|
+
/* @__PURE__ */ jsx35("div", { className: "form-group", children: selector }),
|
|
3318
3326
|
optionSchemaField
|
|
3319
3327
|
] });
|
|
3320
3328
|
}
|
|
3321
3329
|
|
|
3322
3330
|
// src/components/templates/ObjectFieldTemplate.tsx
|
|
3323
|
-
import {
|
|
3324
|
-
|
|
3325
|
-
descriptionId as descriptionId3,
|
|
3326
|
-
getTemplate as getTemplate16,
|
|
3327
|
-
getUiOptions as getUiOptions19,
|
|
3328
|
-
titleId as titleId3,
|
|
3329
|
-
buttonId as buttonId3
|
|
3330
|
-
} from "@rjsf/utils";
|
|
3331
|
-
import { jsx as jsx34, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3331
|
+
import { canExpand, descriptionId as descriptionId3, getTemplate as getTemplate17, getUiOptions as getUiOptions20, titleId as titleId3, buttonId as buttonId3 } from "@rjsf/utils";
|
|
3332
|
+
import { jsx as jsx36, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3332
3333
|
function ObjectFieldTemplate(props) {
|
|
3333
3334
|
const {
|
|
3334
3335
|
className,
|
|
@@ -3346,9 +3347,9 @@ function ObjectFieldTemplate(props) {
|
|
|
3346
3347
|
title,
|
|
3347
3348
|
uiSchema
|
|
3348
3349
|
} = props;
|
|
3349
|
-
const options =
|
|
3350
|
-
const TitleFieldTemplate =
|
|
3351
|
-
const DescriptionFieldTemplate =
|
|
3350
|
+
const options = getUiOptions20(uiSchema);
|
|
3351
|
+
const TitleFieldTemplate = getTemplate17("TitleFieldTemplate", registry, options);
|
|
3352
|
+
const DescriptionFieldTemplate = getTemplate17(
|
|
3352
3353
|
"DescriptionFieldTemplate",
|
|
3353
3354
|
registry,
|
|
3354
3355
|
options
|
|
@@ -3361,8 +3362,8 @@ function ObjectFieldTemplate(props) {
|
|
|
3361
3362
|
const {
|
|
3362
3363
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
3363
3364
|
} = registry.templates;
|
|
3364
|
-
return /* @__PURE__ */
|
|
3365
|
-
title && /* @__PURE__ */
|
|
3365
|
+
return /* @__PURE__ */ jsxs12("fieldset", { className, id: fieldPathId.$id, children: [
|
|
3366
|
+
title && /* @__PURE__ */ jsx36(
|
|
3366
3367
|
TitleFieldTemplate,
|
|
3367
3368
|
{
|
|
3368
3369
|
id: titleId3(fieldPathId),
|
|
@@ -3374,7 +3375,7 @@ function ObjectFieldTemplate(props) {
|
|
|
3374
3375
|
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
3375
3376
|
}
|
|
3376
3377
|
),
|
|
3377
|
-
description && /* @__PURE__ */
|
|
3378
|
+
description && /* @__PURE__ */ jsx36(
|
|
3378
3379
|
DescriptionFieldTemplate,
|
|
3379
3380
|
{
|
|
3380
3381
|
id: descriptionId3(fieldPathId),
|
|
@@ -3386,7 +3387,7 @@ function ObjectFieldTemplate(props) {
|
|
|
3386
3387
|
),
|
|
3387
3388
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
3388
3389
|
properties.map((prop) => prop.content),
|
|
3389
|
-
canExpand(schema, uiSchema, formData) && /* @__PURE__ */
|
|
3390
|
+
canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx36(
|
|
3390
3391
|
AddButton2,
|
|
3391
3392
|
{
|
|
3392
3393
|
id: buttonId3(fieldPathId, "add"),
|
|
@@ -3401,12 +3402,12 @@ function ObjectFieldTemplate(props) {
|
|
|
3401
3402
|
}
|
|
3402
3403
|
|
|
3403
3404
|
// src/components/templates/OptionalDataControlsTemplate.tsx
|
|
3404
|
-
import { jsx as
|
|
3405
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
3405
3406
|
function OptionalDataControlsTemplate(props) {
|
|
3406
3407
|
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
3407
3408
|
if (onAddClick) {
|
|
3408
|
-
return /* @__PURE__ */
|
|
3409
|
-
|
|
3409
|
+
return /* @__PURE__ */ jsx37(
|
|
3410
|
+
IconButton_default,
|
|
3410
3411
|
{
|
|
3411
3412
|
id,
|
|
3412
3413
|
registry,
|
|
@@ -3416,9 +3417,10 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3416
3417
|
title: label
|
|
3417
3418
|
}
|
|
3418
3419
|
);
|
|
3419
|
-
}
|
|
3420
|
-
|
|
3421
|
-
|
|
3420
|
+
}
|
|
3421
|
+
if (onRemoveClick) {
|
|
3422
|
+
return /* @__PURE__ */ jsx37(
|
|
3423
|
+
IconButton_default,
|
|
3422
3424
|
{
|
|
3423
3425
|
id,
|
|
3424
3426
|
registry,
|
|
@@ -3429,52 +3431,48 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3429
3431
|
}
|
|
3430
3432
|
);
|
|
3431
3433
|
}
|
|
3432
|
-
return /* @__PURE__ */
|
|
3434
|
+
return /* @__PURE__ */ jsx37("em", { id, children: label });
|
|
3433
3435
|
}
|
|
3434
3436
|
|
|
3435
3437
|
// src/components/templates/TitleField.tsx
|
|
3436
|
-
import { jsx as
|
|
3438
|
+
import { jsx as jsx38, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3437
3439
|
var REQUIRED_FIELD_SYMBOL2 = "*";
|
|
3438
3440
|
function TitleField(props) {
|
|
3439
3441
|
const { id, title, required, optionalDataControl } = props;
|
|
3440
|
-
return /* @__PURE__ */
|
|
3442
|
+
return /* @__PURE__ */ jsxs13("legend", { id, children: [
|
|
3441
3443
|
title,
|
|
3442
|
-
required && /* @__PURE__ */
|
|
3443
|
-
optionalDataControl && /* @__PURE__ */
|
|
3444
|
+
required && /* @__PURE__ */ jsx38("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 }),
|
|
3445
|
+
optionalDataControl && /* @__PURE__ */ jsx38("span", { className: "pull-right", style: { marginBottom: "2px" }, children: optionalDataControl })
|
|
3444
3446
|
] });
|
|
3445
3447
|
}
|
|
3446
3448
|
|
|
3447
3449
|
// src/components/templates/UnsupportedField.tsx
|
|
3448
|
-
import { TranslatableString as
|
|
3449
|
-
import { Markdown as Markdown4 } from "markdown-to-jsx";
|
|
3450
|
-
import { jsx as
|
|
3450
|
+
import { TranslatableString as TranslatableString12 } from "@rjsf/utils";
|
|
3451
|
+
import { Markdown as Markdown4 } from "markdown-to-jsx/react";
|
|
3452
|
+
import { jsx as jsx39, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3451
3453
|
function UnsupportedField(props) {
|
|
3452
3454
|
const { schema, fieldPathId, reason, registry } = props;
|
|
3453
3455
|
const { translateString } = registry;
|
|
3454
|
-
let translateEnum =
|
|
3456
|
+
let translateEnum = TranslatableString12.UnsupportedField;
|
|
3455
3457
|
const translateParams = [];
|
|
3456
|
-
if (fieldPathId
|
|
3457
|
-
translateEnum =
|
|
3458
|
+
if (fieldPathId?.$id) {
|
|
3459
|
+
translateEnum = TranslatableString12.UnsupportedFieldWithId;
|
|
3458
3460
|
translateParams.push(fieldPathId.$id);
|
|
3459
3461
|
}
|
|
3460
3462
|
if (reason) {
|
|
3461
|
-
translateEnum = translateEnum ===
|
|
3463
|
+
translateEnum = translateEnum === TranslatableString12.UnsupportedField ? TranslatableString12.UnsupportedFieldWithReason : TranslatableString12.UnsupportedFieldWithIdAndReason;
|
|
3462
3464
|
translateParams.push(reason);
|
|
3463
3465
|
}
|
|
3464
|
-
return /* @__PURE__ */
|
|
3465
|
-
/* @__PURE__ */
|
|
3466
|
-
schema && /* @__PURE__ */
|
|
3466
|
+
return /* @__PURE__ */ jsxs14("div", { className: "unsupported-field", children: [
|
|
3467
|
+
/* @__PURE__ */ jsx39("p", { children: /* @__PURE__ */ jsx39(Markdown4, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3468
|
+
schema && /* @__PURE__ */ jsx39("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3467
3469
|
] });
|
|
3468
3470
|
}
|
|
3469
3471
|
var UnsupportedField_default = UnsupportedField;
|
|
3470
3472
|
|
|
3471
3473
|
// src/components/templates/WrapIfAdditionalTemplate.tsx
|
|
3472
|
-
import {
|
|
3473
|
-
|
|
3474
|
-
buttonId as buttonId4,
|
|
3475
|
-
TranslatableString as TranslatableString12
|
|
3476
|
-
} from "@rjsf/utils";
|
|
3477
|
-
import { jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3474
|
+
import { ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3, buttonId as buttonId4, TranslatableString as TranslatableString13 } from "@rjsf/utils";
|
|
3475
|
+
import { jsx as jsx40, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3478
3476
|
function WrapIfAdditionalTemplate(props) {
|
|
3479
3477
|
const {
|
|
3480
3478
|
id,
|
|
@@ -3497,7 +3495,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3497
3495
|
} = props;
|
|
3498
3496
|
const { templates: templates2, translateString } = registry;
|
|
3499
3497
|
const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
|
|
3500
|
-
const keyLabel = translateString(
|
|
3498
|
+
const keyLabel = translateString(TranslatableString13.KeyLabel, [label]);
|
|
3501
3499
|
const additional = ADDITIONAL_PROPERTY_FLAG3 in schema;
|
|
3502
3500
|
const hasDescription = !!rawDescription;
|
|
3503
3501
|
const classNamesList = ["form-group", classNames];
|
|
@@ -3506,14 +3504,14 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3506
3504
|
}
|
|
3507
3505
|
const uiClassNames = classNamesList.join(" ").trim();
|
|
3508
3506
|
if (!additional) {
|
|
3509
|
-
return /* @__PURE__ */
|
|
3507
|
+
return /* @__PURE__ */ jsx40("div", { className: uiClassNames, style, children });
|
|
3510
3508
|
}
|
|
3511
3509
|
const margin = hasDescription ? 46 : 26;
|
|
3512
|
-
return /* @__PURE__ */
|
|
3513
|
-
/* @__PURE__ */
|
|
3514
|
-
displayLabel && /* @__PURE__ */
|
|
3515
|
-
displayLabel && rawDescription && /* @__PURE__ */
|
|
3516
|
-
/* @__PURE__ */
|
|
3510
|
+
return /* @__PURE__ */ jsx40("div", { className: uiClassNames, style, children: /* @__PURE__ */ jsxs15("div", { className: "row", children: [
|
|
3511
|
+
/* @__PURE__ */ jsx40("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ jsxs15("div", { className: "form-group", children: [
|
|
3512
|
+
displayLabel && /* @__PURE__ */ jsx40(Label, { label: keyLabel, required, id: `${id}-key` }),
|
|
3513
|
+
displayLabel && rawDescription && /* @__PURE__ */ jsx40("div", { children: "\xA0" }),
|
|
3514
|
+
/* @__PURE__ */ jsx40(
|
|
3517
3515
|
"input",
|
|
3518
3516
|
{
|
|
3519
3517
|
className: "form-control",
|
|
@@ -3525,8 +3523,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3525
3523
|
label
|
|
3526
3524
|
)
|
|
3527
3525
|
] }) }),
|
|
3528
|
-
/* @__PURE__ */
|
|
3529
|
-
/* @__PURE__ */
|
|
3526
|
+
/* @__PURE__ */ jsx40("div", { className: "form-additional form-group col-xs-5", children }),
|
|
3527
|
+
/* @__PURE__ */ jsx40("div", { className: "col-xs-2", style: { marginTop: displayLabel ? `${margin}px` : void 0 }, children: /* @__PURE__ */ jsx40(
|
|
3530
3528
|
RemoveButton2,
|
|
3531
3529
|
{
|
|
3532
3530
|
id: buttonId4(id, "remove"),
|
|
@@ -3551,6 +3549,7 @@ function templates() {
|
|
|
3551
3549
|
ArrayFieldTitleTemplate,
|
|
3552
3550
|
ButtonTemplates: ButtonTemplates_default(),
|
|
3553
3551
|
BaseInputTemplate,
|
|
3552
|
+
CyclicSchemaExpandTemplate,
|
|
3554
3553
|
DescriptionFieldTemplate: DescriptionField,
|
|
3555
3554
|
ErrorListTemplate: ErrorList,
|
|
3556
3555
|
FallbackFieldTemplate,
|
|
@@ -3569,51 +3568,50 @@ function templates() {
|
|
|
3569
3568
|
var templates_default = templates;
|
|
3570
3569
|
|
|
3571
3570
|
// src/components/widgets/AltDateTimeWidget.tsx
|
|
3572
|
-
import { jsx as
|
|
3571
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
3573
3572
|
function AltDateTimeWidget({
|
|
3574
3573
|
time = true,
|
|
3575
3574
|
...props
|
|
3576
3575
|
}) {
|
|
3577
3576
|
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
3578
|
-
return /* @__PURE__ */
|
|
3577
|
+
return /* @__PURE__ */ jsx41(AltDateWidget2, { time, ...props });
|
|
3579
3578
|
}
|
|
3580
3579
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
3581
3580
|
|
|
3582
3581
|
// src/components/widgets/AltDateWidget.tsx
|
|
3583
|
-
import {
|
|
3584
|
-
|
|
3585
|
-
TranslatableString as TranslatableString13,
|
|
3586
|
-
useAltDateWidgetProps
|
|
3587
|
-
} from "@rjsf/utils";
|
|
3588
|
-
import { jsx as jsx40, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3582
|
+
import { DateElement, TranslatableString as TranslatableString14, useAltDateWidgetProps } from "@rjsf/utils";
|
|
3583
|
+
import { jsx as jsx42, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3589
3584
|
function AltDateWidget(props) {
|
|
3590
3585
|
const { disabled = false, readonly = false, autofocus = false, options, id, name, registry, onBlur, onFocus } = props;
|
|
3591
3586
|
const { translateString } = registry;
|
|
3592
3587
|
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps(props);
|
|
3593
|
-
return /* @__PURE__ */
|
|
3594
|
-
elements.map((elemProps, i) =>
|
|
3595
|
-
|
|
3596
|
-
{
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3588
|
+
return /* @__PURE__ */ jsxs16("ul", { className: "list-inline", children: [
|
|
3589
|
+
elements.map((elemProps, i) => (
|
|
3590
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3591
|
+
/* @__PURE__ */ jsx42("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx42(
|
|
3592
|
+
DateElement,
|
|
3593
|
+
{
|
|
3594
|
+
rootId: id,
|
|
3595
|
+
name,
|
|
3596
|
+
select: handleChange,
|
|
3597
|
+
...elemProps,
|
|
3598
|
+
disabled,
|
|
3599
|
+
readonly,
|
|
3600
|
+
registry,
|
|
3601
|
+
onBlur,
|
|
3602
|
+
onFocus,
|
|
3603
|
+
autofocus: autofocus && i === 0
|
|
3604
|
+
}
|
|
3605
|
+
) }, i)
|
|
3606
|
+
)),
|
|
3607
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx42("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx42("button", { type: "button", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString14.NowLabel) }) }),
|
|
3608
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx42("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx42("button", { type: "button", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString14.ClearLabel) }) })
|
|
3611
3609
|
] });
|
|
3612
3610
|
}
|
|
3613
3611
|
var AltDateWidget_default = AltDateWidget;
|
|
3614
3612
|
|
|
3615
3613
|
// src/components/widgets/CheckboxesWidget.tsx
|
|
3616
|
-
import { useCallback as
|
|
3614
|
+
import { useCallback as useCallback9 } from "react";
|
|
3617
3615
|
import {
|
|
3618
3616
|
ariaDescribedByIds as ariaDescribedByIds2,
|
|
3619
3617
|
enumOptionValueDecoder,
|
|
@@ -3624,7 +3622,7 @@ import {
|
|
|
3624
3622
|
getOptionValueFormat,
|
|
3625
3623
|
optionId
|
|
3626
3624
|
} from "@rjsf/utils";
|
|
3627
|
-
import { jsx as
|
|
3625
|
+
import { jsx as jsx43, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3628
3626
|
function CheckboxesWidget({
|
|
3629
3627
|
id,
|
|
3630
3628
|
disabled,
|
|
@@ -3640,17 +3638,17 @@ function CheckboxesWidget({
|
|
|
3640
3638
|
const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
|
|
3641
3639
|
const optionValueFormat = getOptionValueFormat(options);
|
|
3642
3640
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3643
|
-
const handleBlur =
|
|
3644
|
-
({ target }) => onBlur(id, enumOptionValueDecoder(target
|
|
3641
|
+
const handleBlur = useCallback9(
|
|
3642
|
+
({ target }) => onBlur(id, enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3645
3643
|
[onBlur, id, enumOptions, emptyValue, optionValueFormat]
|
|
3646
3644
|
);
|
|
3647
|
-
const handleFocus =
|
|
3648
|
-
({ target }) => onFocus(id, enumOptionValueDecoder(target
|
|
3645
|
+
const handleFocus = useCallback9(
|
|
3646
|
+
({ target }) => onFocus(id, enumOptionValueDecoder(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3649
3647
|
[onFocus, id, enumOptions, emptyValue, optionValueFormat]
|
|
3650
3648
|
);
|
|
3651
|
-
return /* @__PURE__ */
|
|
3649
|
+
return /* @__PURE__ */ jsx43("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3652
3650
|
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
3653
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3651
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3654
3652
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3655
3653
|
const handleChange = (event) => {
|
|
3656
3654
|
if (event.target.checked) {
|
|
@@ -3659,8 +3657,8 @@ function CheckboxesWidget({
|
|
|
3659
3657
|
onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
3660
3658
|
}
|
|
3661
3659
|
};
|
|
3662
|
-
const checkbox = /* @__PURE__ */
|
|
3663
|
-
/* @__PURE__ */
|
|
3660
|
+
const checkbox = /* @__PURE__ */ jsxs17("span", { children: [
|
|
3661
|
+
/* @__PURE__ */ jsx43(
|
|
3664
3662
|
"input",
|
|
3665
3663
|
{
|
|
3666
3664
|
type: "checkbox",
|
|
@@ -3676,24 +3674,24 @@ function CheckboxesWidget({
|
|
|
3676
3674
|
"aria-describedby": ariaDescribedByIds2(id)
|
|
3677
3675
|
}
|
|
3678
3676
|
),
|
|
3679
|
-
/* @__PURE__ */
|
|
3677
|
+
/* @__PURE__ */ jsx43("span", { children: option.label })
|
|
3680
3678
|
] });
|
|
3681
|
-
return inline ? /* @__PURE__ */
|
|
3679
|
+
return inline ? /* @__PURE__ */ jsx43("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, String(option.value)) : /* @__PURE__ */ jsx43("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsx43("label", { children: checkbox }) }, String(option.value));
|
|
3682
3680
|
}) });
|
|
3683
3681
|
}
|
|
3684
3682
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3685
3683
|
|
|
3686
3684
|
// src/components/widgets/CheckboxWidget.tsx
|
|
3687
|
-
import { useCallback as
|
|
3685
|
+
import { useCallback as useCallback10 } from "react";
|
|
3688
3686
|
import {
|
|
3689
3687
|
ariaDescribedByIds as ariaDescribedByIds3,
|
|
3690
3688
|
descriptionId as descriptionId4,
|
|
3691
|
-
getTemplate as
|
|
3689
|
+
getTemplate as getTemplate18,
|
|
3692
3690
|
labelValue,
|
|
3693
3691
|
schemaRequiresTrueValue,
|
|
3694
|
-
getUiOptions as
|
|
3692
|
+
getUiOptions as getUiOptions21
|
|
3695
3693
|
} from "@rjsf/utils";
|
|
3696
|
-
import { jsx as
|
|
3694
|
+
import { jsx as jsx44, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3697
3695
|
function CheckboxWidget({
|
|
3698
3696
|
schema,
|
|
3699
3697
|
uiSchema,
|
|
@@ -3711,29 +3709,29 @@ function CheckboxWidget({
|
|
|
3711
3709
|
registry,
|
|
3712
3710
|
htmlName
|
|
3713
3711
|
}) {
|
|
3714
|
-
const DescriptionFieldTemplate =
|
|
3712
|
+
const DescriptionFieldTemplate = getTemplate18(
|
|
3715
3713
|
"DescriptionFieldTemplate",
|
|
3716
3714
|
registry,
|
|
3717
3715
|
options
|
|
3718
3716
|
);
|
|
3719
3717
|
const required = schemaRequiresTrueValue(schema);
|
|
3720
|
-
const handleChange =
|
|
3718
|
+
const handleChange = useCallback10(
|
|
3721
3719
|
(event) => onChange(event.target.checked),
|
|
3722
3720
|
[onChange]
|
|
3723
3721
|
);
|
|
3724
|
-
const handleBlur =
|
|
3722
|
+
const handleBlur = useCallback10(
|
|
3725
3723
|
(event) => onBlur(id, event.target.checked),
|
|
3726
3724
|
[onBlur, id]
|
|
3727
3725
|
);
|
|
3728
|
-
const handleFocus =
|
|
3726
|
+
const handleFocus = useCallback10(
|
|
3729
3727
|
(event) => onFocus(id, event.target.checked),
|
|
3730
3728
|
[onFocus, id]
|
|
3731
3729
|
);
|
|
3732
|
-
const uiOptions =
|
|
3730
|
+
const uiOptions = getUiOptions21(uiSchema);
|
|
3733
3731
|
const isCheckboxWidget = uiOptions.widget === "checkbox";
|
|
3734
3732
|
const description = isCheckboxWidget ? void 0 : options.description ?? schema.description;
|
|
3735
|
-
return /* @__PURE__ */
|
|
3736
|
-
!hideLabel && description && /* @__PURE__ */
|
|
3733
|
+
return /* @__PURE__ */ jsxs18("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
|
|
3734
|
+
!hideLabel && description && /* @__PURE__ */ jsx44(
|
|
3737
3735
|
DescriptionFieldTemplate,
|
|
3738
3736
|
{
|
|
3739
3737
|
id: descriptionId4(id),
|
|
@@ -3743,8 +3741,8 @@ function CheckboxWidget({
|
|
|
3743
3741
|
registry
|
|
3744
3742
|
}
|
|
3745
3743
|
),
|
|
3746
|
-
/* @__PURE__ */
|
|
3747
|
-
/* @__PURE__ */
|
|
3744
|
+
/* @__PURE__ */ jsxs18("label", { children: [
|
|
3745
|
+
/* @__PURE__ */ jsx44(
|
|
3748
3746
|
"input",
|
|
3749
3747
|
{
|
|
3750
3748
|
type: "checkbox",
|
|
@@ -3760,70 +3758,62 @@ function CheckboxWidget({
|
|
|
3760
3758
|
"aria-describedby": ariaDescribedByIds3(id)
|
|
3761
3759
|
}
|
|
3762
3760
|
),
|
|
3763
|
-
labelValue(/* @__PURE__ */
|
|
3761
|
+
labelValue(/* @__PURE__ */ jsx44("span", { children: label }), hideLabel)
|
|
3764
3762
|
] })
|
|
3765
3763
|
] });
|
|
3766
3764
|
}
|
|
3767
3765
|
var CheckboxWidget_default = CheckboxWidget;
|
|
3768
3766
|
|
|
3769
3767
|
// src/components/widgets/ColorWidget.tsx
|
|
3770
|
-
import { getTemplate as
|
|
3771
|
-
import { jsx as
|
|
3768
|
+
import { getTemplate as getTemplate19 } from "@rjsf/utils";
|
|
3769
|
+
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
3772
3770
|
function ColorWidget(props) {
|
|
3773
3771
|
const { disabled, readonly, options, registry } = props;
|
|
3774
|
-
const BaseInputTemplate2 =
|
|
3775
|
-
return /* @__PURE__ */
|
|
3772
|
+
const BaseInputTemplate2 = getTemplate19("BaseInputTemplate", registry, options);
|
|
3773
|
+
return /* @__PURE__ */ jsx45(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
|
|
3776
3774
|
}
|
|
3777
3775
|
|
|
3778
3776
|
// src/components/widgets/DateTimeWidget.tsx
|
|
3779
|
-
import {
|
|
3780
|
-
|
|
3781
|
-
localToUTC,
|
|
3782
|
-
utcToLocal
|
|
3783
|
-
} from "@rjsf/utils";
|
|
3784
|
-
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
3777
|
+
import { getTemplate as getTemplate20, localToUTC, utcToLocal } from "@rjsf/utils";
|
|
3778
|
+
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
3785
3779
|
function DateTimeWidget(props) {
|
|
3786
3780
|
const { onChange, value, options, registry } = props;
|
|
3787
|
-
const BaseInputTemplate2 =
|
|
3788
|
-
return /* @__PURE__ */
|
|
3781
|
+
const BaseInputTemplate2 = getTemplate20("BaseInputTemplate", registry, options);
|
|
3782
|
+
return /* @__PURE__ */ jsx46(
|
|
3789
3783
|
BaseInputTemplate2,
|
|
3790
3784
|
{
|
|
3791
3785
|
type: "datetime-local",
|
|
3792
3786
|
...props,
|
|
3793
3787
|
value: utcToLocal(value),
|
|
3794
|
-
onChange: (
|
|
3788
|
+
onChange: (newValue) => onChange(localToUTC(newValue))
|
|
3795
3789
|
}
|
|
3796
3790
|
);
|
|
3797
3791
|
}
|
|
3798
3792
|
|
|
3799
3793
|
// src/components/widgets/DateWidget.tsx
|
|
3800
|
-
import { useCallback as
|
|
3801
|
-
import { getTemplate as
|
|
3802
|
-
import { jsx as
|
|
3794
|
+
import { useCallback as useCallback11 } from "react";
|
|
3795
|
+
import { getTemplate as getTemplate21 } from "@rjsf/utils";
|
|
3796
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
3803
3797
|
function DateWidget(props) {
|
|
3804
3798
|
const { onChange, options, registry } = props;
|
|
3805
|
-
const BaseInputTemplate2 =
|
|
3806
|
-
const handleChange =
|
|
3807
|
-
return /* @__PURE__ */
|
|
3799
|
+
const BaseInputTemplate2 = getTemplate21("BaseInputTemplate", registry, options);
|
|
3800
|
+
const handleChange = useCallback11((value) => onChange(value || void 0), [onChange]);
|
|
3801
|
+
return /* @__PURE__ */ jsx47(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3808
3802
|
}
|
|
3809
3803
|
|
|
3810
3804
|
// src/components/widgets/EmailWidget.tsx
|
|
3811
|
-
import { getTemplate as
|
|
3812
|
-
import { jsx as
|
|
3805
|
+
import { getTemplate as getTemplate22 } from "@rjsf/utils";
|
|
3806
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
3813
3807
|
function EmailWidget(props) {
|
|
3814
3808
|
const { options, registry } = props;
|
|
3815
|
-
const BaseInputTemplate2 =
|
|
3816
|
-
return /* @__PURE__ */
|
|
3809
|
+
const BaseInputTemplate2 = getTemplate22("BaseInputTemplate", registry, options);
|
|
3810
|
+
return /* @__PURE__ */ jsx48(BaseInputTemplate2, { type: "email", ...props });
|
|
3817
3811
|
}
|
|
3818
3812
|
|
|
3819
3813
|
// src/components/widgets/FileWidget.tsx
|
|
3820
|
-
import {
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
useFileWidgetProps
|
|
3824
|
-
} from "@rjsf/utils";
|
|
3825
|
-
import { Markdown as Markdown5 } from "markdown-to-jsx";
|
|
3826
|
-
import { Fragment as Fragment4, jsx as jsx47, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3814
|
+
import { getTemplate as getTemplate23, TranslatableString as TranslatableString15, useFileWidgetProps } from "@rjsf/utils";
|
|
3815
|
+
import { Markdown as Markdown5 } from "markdown-to-jsx/react";
|
|
3816
|
+
import { Fragment as Fragment4, jsx as jsx49, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3827
3817
|
function FileInfoPreview({
|
|
3828
3818
|
fileInfo,
|
|
3829
3819
|
registry
|
|
@@ -3833,12 +3823,13 @@ function FileInfoPreview({
|
|
|
3833
3823
|
if (!dataURL) {
|
|
3834
3824
|
return null;
|
|
3835
3825
|
}
|
|
3826
|
+
const previewLabel = translateString(TranslatableString15.PreviewLabel);
|
|
3836
3827
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3837
|
-
return /* @__PURE__ */
|
|
3828
|
+
return /* @__PURE__ */ jsx49("img", { src: dataURL, alt: previewLabel, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3838
3829
|
}
|
|
3839
|
-
return /* @__PURE__ */
|
|
3830
|
+
return /* @__PURE__ */ jsxs19(Fragment4, { children: [
|
|
3840
3831
|
" ",
|
|
3841
|
-
/* @__PURE__ */
|
|
3832
|
+
/* @__PURE__ */ jsx49("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: previewLabel })
|
|
3842
3833
|
] });
|
|
3843
3834
|
}
|
|
3844
3835
|
function FilesInfo({
|
|
@@ -3852,28 +3843,31 @@ function FilesInfo({
|
|
|
3852
3843
|
return null;
|
|
3853
3844
|
}
|
|
3854
3845
|
const { translateString } = registry;
|
|
3855
|
-
const { RemoveButton: RemoveButton2 } =
|
|
3856
|
-
return /* @__PURE__ */
|
|
3846
|
+
const { RemoveButton: RemoveButton2 } = getTemplate23("ButtonTemplates", registry, options);
|
|
3847
|
+
return /* @__PURE__ */ jsx49("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3857
3848
|
const { name, size, type } = fileInfo;
|
|
3858
3849
|
const handleRemove = () => onRemove(key);
|
|
3859
|
-
return
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3850
|
+
return (
|
|
3851
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3852
|
+
/* @__PURE__ */ jsxs19("li", { children: [
|
|
3853
|
+
/* @__PURE__ */ jsx49(Markdown5, { children: translateString(TranslatableString15.FilesInfo, [name, type, String(size)]) }),
|
|
3854
|
+
preview && /* @__PURE__ */ jsx49(FileInfoPreview, { fileInfo, registry }),
|
|
3855
|
+
/* @__PURE__ */ jsx49(RemoveButton2, { onClick: handleRemove, registry })
|
|
3856
|
+
] }, key)
|
|
3857
|
+
);
|
|
3864
3858
|
}) });
|
|
3865
3859
|
}
|
|
3866
3860
|
function FileWidget(props) {
|
|
3867
3861
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|
|
3868
3862
|
const { filesInfo, handleChange, handleRemove } = useFileWidgetProps(value, onChange, multiple);
|
|
3869
|
-
const BaseInputTemplate2 =
|
|
3863
|
+
const BaseInputTemplate2 = getTemplate23("BaseInputTemplate", registry, options);
|
|
3870
3864
|
const handleOnChangeEvent = (event) => {
|
|
3871
3865
|
if (event.target.files) {
|
|
3872
3866
|
void handleChange(event.target.files);
|
|
3873
3867
|
}
|
|
3874
3868
|
};
|
|
3875
|
-
return /* @__PURE__ */
|
|
3876
|
-
/* @__PURE__ */
|
|
3869
|
+
return /* @__PURE__ */ jsxs19("div", { children: [
|
|
3870
|
+
/* @__PURE__ */ jsx49(
|
|
3877
3871
|
BaseInputTemplate2,
|
|
3878
3872
|
{
|
|
3879
3873
|
...props,
|
|
@@ -3885,7 +3879,7 @@ function FileWidget(props) {
|
|
|
3885
3879
|
accept: options.accept ? String(options.accept) : void 0
|
|
3886
3880
|
}
|
|
3887
3881
|
),
|
|
3888
|
-
/* @__PURE__ */
|
|
3882
|
+
/* @__PURE__ */ jsx49(
|
|
3889
3883
|
FilesInfo,
|
|
3890
3884
|
{
|
|
3891
3885
|
filesInfo,
|
|
@@ -3900,27 +3894,27 @@ function FileWidget(props) {
|
|
|
3900
3894
|
var FileWidget_default = FileWidget;
|
|
3901
3895
|
|
|
3902
3896
|
// src/components/widgets/HiddenWidget.tsx
|
|
3903
|
-
import { jsx as
|
|
3897
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
3904
3898
|
function HiddenWidget({
|
|
3905
3899
|
id,
|
|
3906
3900
|
value,
|
|
3907
3901
|
htmlName
|
|
3908
3902
|
}) {
|
|
3909
|
-
return /* @__PURE__ */
|
|
3903
|
+
return /* @__PURE__ */ jsx50("input", { type: "hidden", id, name: htmlName || id, value: typeof value === "undefined" ? "" : value });
|
|
3910
3904
|
}
|
|
3911
3905
|
var HiddenWidget_default = HiddenWidget;
|
|
3912
3906
|
|
|
3913
3907
|
// src/components/widgets/PasswordWidget.tsx
|
|
3914
|
-
import { getTemplate as
|
|
3915
|
-
import { jsx as
|
|
3908
|
+
import { getTemplate as getTemplate24 } from "@rjsf/utils";
|
|
3909
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
3916
3910
|
function PasswordWidget(props) {
|
|
3917
3911
|
const { options, registry } = props;
|
|
3918
|
-
const BaseInputTemplate2 =
|
|
3919
|
-
return /* @__PURE__ */
|
|
3912
|
+
const BaseInputTemplate2 = getTemplate24("BaseInputTemplate", registry, options);
|
|
3913
|
+
return /* @__PURE__ */ jsx51(BaseInputTemplate2, { type: "password", ...props });
|
|
3920
3914
|
}
|
|
3921
3915
|
|
|
3922
3916
|
// src/components/widgets/RadioWidget.tsx
|
|
3923
|
-
import { useCallback as
|
|
3917
|
+
import { useCallback as useCallback12 } from "react";
|
|
3924
3918
|
import {
|
|
3925
3919
|
ariaDescribedByIds as ariaDescribedByIds4,
|
|
3926
3920
|
enumOptionValueDecoder as enumOptionValueDecoder2,
|
|
@@ -3929,7 +3923,7 @@ import {
|
|
|
3929
3923
|
getOptionValueFormat as getOptionValueFormat2,
|
|
3930
3924
|
optionId as optionId2
|
|
3931
3925
|
} from "@rjsf/utils";
|
|
3932
|
-
import { jsx as
|
|
3926
|
+
import { jsx as jsx52, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3933
3927
|
function RadioWidget({
|
|
3934
3928
|
options,
|
|
3935
3929
|
value,
|
|
@@ -3945,21 +3939,21 @@ function RadioWidget({
|
|
|
3945
3939
|
}) {
|
|
3946
3940
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3947
3941
|
const optionValueFormat = getOptionValueFormat2(options);
|
|
3948
|
-
const handleBlur =
|
|
3949
|
-
({ target }) => onBlur(id, enumOptionValueDecoder2(target
|
|
3942
|
+
const handleBlur = useCallback12(
|
|
3943
|
+
({ target }) => onBlur(id, enumOptionValueDecoder2(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3950
3944
|
[onBlur, enumOptions, emptyValue, id, optionValueFormat]
|
|
3951
3945
|
);
|
|
3952
|
-
const handleFocus =
|
|
3953
|
-
({ target }) => onFocus(id, enumOptionValueDecoder2(target
|
|
3946
|
+
const handleFocus = useCallback12(
|
|
3947
|
+
({ target }) => onFocus(id, enumOptionValueDecoder2(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3954
3948
|
[onFocus, enumOptions, emptyValue, id, optionValueFormat]
|
|
3955
3949
|
);
|
|
3956
|
-
return /* @__PURE__ */
|
|
3950
|
+
return /* @__PURE__ */ jsx52("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3957
3951
|
const checked = enumOptionsIsSelected2(option.value, value);
|
|
3958
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3952
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3959
3953
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3960
3954
|
const handleChange = () => onChange(option.value);
|
|
3961
|
-
const radio = /* @__PURE__ */
|
|
3962
|
-
/* @__PURE__ */
|
|
3955
|
+
const radio = /* @__PURE__ */ jsxs20("span", { children: [
|
|
3956
|
+
/* @__PURE__ */ jsx52(
|
|
3963
3957
|
"input",
|
|
3964
3958
|
{
|
|
3965
3959
|
type: "radio",
|
|
@@ -3976,15 +3970,15 @@ function RadioWidget({
|
|
|
3976
3970
|
"aria-describedby": ariaDescribedByIds4(id)
|
|
3977
3971
|
}
|
|
3978
3972
|
),
|
|
3979
|
-
/* @__PURE__ */
|
|
3973
|
+
/* @__PURE__ */ jsx52("span", { children: option.label })
|
|
3980
3974
|
] });
|
|
3981
|
-
return inline ? /* @__PURE__ */
|
|
3975
|
+
return inline ? /* @__PURE__ */ jsx52("label", { className: `radio-inline ${disabledCls}`, children: radio }, String(option.value)) : /* @__PURE__ */ jsx52("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsx52("label", { children: radio }) }, String(option.value));
|
|
3982
3976
|
}) });
|
|
3983
3977
|
}
|
|
3984
3978
|
var RadioWidget_default = RadioWidget;
|
|
3985
3979
|
|
|
3986
3980
|
// src/components/widgets/RangeWidget.tsx
|
|
3987
|
-
import { jsx as
|
|
3981
|
+
import { jsx as jsx53, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3988
3982
|
function RangeWidget(props) {
|
|
3989
3983
|
const {
|
|
3990
3984
|
value,
|
|
@@ -3992,15 +3986,15 @@ function RangeWidget(props) {
|
|
|
3992
3986
|
templates: { BaseInputTemplate: BaseInputTemplate2 }
|
|
3993
3987
|
}
|
|
3994
3988
|
} = props;
|
|
3995
|
-
return /* @__PURE__ */
|
|
3996
|
-
/* @__PURE__ */
|
|
3997
|
-
/* @__PURE__ */
|
|
3989
|
+
return /* @__PURE__ */ jsxs21("div", { className: "field-range-wrapper", children: [
|
|
3990
|
+
/* @__PURE__ */ jsx53(BaseInputTemplate2, { type: "range", ...props }),
|
|
3991
|
+
/* @__PURE__ */ jsx53("span", { className: "range-view", children: value })
|
|
3998
3992
|
] });
|
|
3999
3993
|
}
|
|
4000
3994
|
|
|
4001
3995
|
// src/components/widgets/RatingWidget.tsx
|
|
4002
|
-
import { useCallback as
|
|
4003
|
-
import {
|
|
3996
|
+
import { useCallback as useCallback13 } from "react";
|
|
3997
|
+
import { jsx as jsx54, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4004
3998
|
function RatingWidget({
|
|
4005
3999
|
id,
|
|
4006
4000
|
value,
|
|
@@ -4018,7 +4012,7 @@ function RatingWidget({
|
|
|
4018
4012
|
const { stars = 5, shape = "star" } = options;
|
|
4019
4013
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
4020
4014
|
const min = schema.minimum || 0;
|
|
4021
|
-
const handleStarClick =
|
|
4015
|
+
const handleStarClick = useCallback13(
|
|
4022
4016
|
(starValue) => {
|
|
4023
4017
|
if (!disabled && !readonly) {
|
|
4024
4018
|
onChange(starValue);
|
|
@@ -4026,7 +4020,7 @@ function RatingWidget({
|
|
|
4026
4020
|
},
|
|
4027
4021
|
[onChange, disabled, readonly]
|
|
4028
4022
|
);
|
|
4029
|
-
const handleFocus =
|
|
4023
|
+
const handleFocus = useCallback13(
|
|
4030
4024
|
(event) => {
|
|
4031
4025
|
if (onFocus) {
|
|
4032
4026
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -4035,7 +4029,7 @@ function RatingWidget({
|
|
|
4035
4029
|
},
|
|
4036
4030
|
[onFocus, id]
|
|
4037
4031
|
);
|
|
4038
|
-
const handleBlur =
|
|
4032
|
+
const handleBlur = useCallback13(
|
|
4039
4033
|
(event) => {
|
|
4040
4034
|
if (onBlur) {
|
|
4041
4035
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -4050,7 +4044,7 @@ function RatingWidget({
|
|
|
4050
4044
|
}
|
|
4051
4045
|
return isFilled ? "\u2605" : "\u2606";
|
|
4052
4046
|
};
|
|
4053
|
-
return /* @__PURE__ */
|
|
4047
|
+
return /* @__PURE__ */ jsxs22(
|
|
4054
4048
|
"div",
|
|
4055
4049
|
{
|
|
4056
4050
|
className: "rating-widget",
|
|
@@ -4063,10 +4057,11 @@ function RatingWidget({
|
|
|
4063
4057
|
[...Array(numStars)].map((_, index) => {
|
|
4064
4058
|
const starValue = min + index;
|
|
4065
4059
|
const isFilled = starValue <= value;
|
|
4066
|
-
return /* @__PURE__ */
|
|
4060
|
+
return /* @__PURE__ */ jsx54(
|
|
4067
4061
|
"span",
|
|
4068
4062
|
{
|
|
4069
4063
|
onClick: () => handleStarClick(starValue),
|
|
4064
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && handleStarClick(starValue),
|
|
4070
4065
|
onFocus: handleFocus,
|
|
4071
4066
|
onBlur: handleBlur,
|
|
4072
4067
|
"data-value": starValue,
|
|
@@ -4085,7 +4080,7 @@ function RatingWidget({
|
|
|
4085
4080
|
index
|
|
4086
4081
|
);
|
|
4087
4082
|
}),
|
|
4088
|
-
/* @__PURE__ */
|
|
4083
|
+
/* @__PURE__ */ jsx54(
|
|
4089
4084
|
"input",
|
|
4090
4085
|
{
|
|
4091
4086
|
type: "hidden",
|
|
@@ -4099,19 +4094,21 @@ function RatingWidget({
|
|
|
4099
4094
|
)
|
|
4100
4095
|
]
|
|
4101
4096
|
}
|
|
4102
|
-
)
|
|
4097
|
+
);
|
|
4103
4098
|
}
|
|
4104
4099
|
|
|
4105
4100
|
// src/components/widgets/SelectWidget.tsx
|
|
4106
|
-
import { useCallback as
|
|
4101
|
+
import { useCallback as useCallback14 } from "react";
|
|
4107
4102
|
import {
|
|
4108
4103
|
ariaDescribedByIds as ariaDescribedByIds5,
|
|
4109
4104
|
enumOptionSelectedValue,
|
|
4110
4105
|
enumOptionValueDecoder as enumOptionValueDecoder3,
|
|
4111
4106
|
enumOptionValueEncoder as enumOptionValueEncoder3,
|
|
4112
|
-
getOptionValueFormat as getOptionValueFormat3
|
|
4107
|
+
getOptionValueFormat as getOptionValueFormat3,
|
|
4108
|
+
logUnsupportedDefaultForEnum,
|
|
4109
|
+
SelectedOptionDescription
|
|
4113
4110
|
} from "@rjsf/utils";
|
|
4114
|
-
import { jsx as
|
|
4111
|
+
import { Fragment as Fragment5, jsx as jsx55, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4115
4112
|
function getValue(event, multiple) {
|
|
4116
4113
|
if (multiple) {
|
|
4117
4114
|
return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
|
|
@@ -4132,26 +4129,28 @@ function SelectWidget({
|
|
|
4132
4129
|
onBlur,
|
|
4133
4130
|
onFocus,
|
|
4134
4131
|
placeholder,
|
|
4135
|
-
htmlName
|
|
4132
|
+
htmlName,
|
|
4133
|
+
registry,
|
|
4134
|
+
uiSchema
|
|
4136
4135
|
}) {
|
|
4137
4136
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
4138
4137
|
const emptyValue = multiple ? [] : "";
|
|
4139
4138
|
const optionValueFormat = getOptionValueFormat3(options);
|
|
4140
|
-
const handleFocus =
|
|
4139
|
+
const handleFocus = useCallback14(
|
|
4141
4140
|
(event) => {
|
|
4142
4141
|
const newValue = getValue(event, multiple);
|
|
4143
4142
|
return onFocus(id, enumOptionValueDecoder3(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
4144
4143
|
},
|
|
4145
4144
|
[onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
4146
4145
|
);
|
|
4147
|
-
const handleBlur =
|
|
4146
|
+
const handleBlur = useCallback14(
|
|
4148
4147
|
(event) => {
|
|
4149
4148
|
const newValue = getValue(event, multiple);
|
|
4150
4149
|
return onBlur(id, enumOptionValueDecoder3(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
4151
4150
|
},
|
|
4152
4151
|
[onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
4153
4152
|
);
|
|
4154
|
-
const handleChange =
|
|
4153
|
+
const handleChange = useCallback14(
|
|
4155
4154
|
(event) => {
|
|
4156
4155
|
const newValue = getValue(event, multiple);
|
|
4157
4156
|
return onChange(enumOptionValueDecoder3(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
@@ -4160,41 +4159,62 @@ function SelectWidget({
|
|
|
4160
4159
|
);
|
|
4161
4160
|
const selectValue = enumOptionSelectedValue(value, enumOptions, multiple, optionValueFormat, emptyValue);
|
|
4162
4161
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4162
|
+
logUnsupportedDefaultForEnum(id, schema, enumOptions, multiple);
|
|
4163
|
+
return /* @__PURE__ */ jsxs23(Fragment5, { children: [
|
|
4164
|
+
/* @__PURE__ */ jsx55(
|
|
4165
|
+
SelectedOptionDescription,
|
|
4166
|
+
{
|
|
4167
|
+
id,
|
|
4168
|
+
multiple,
|
|
4169
|
+
options,
|
|
4170
|
+
registry,
|
|
4171
|
+
uiSchema,
|
|
4172
|
+
value
|
|
4173
|
+
}
|
|
4174
|
+
),
|
|
4175
|
+
/* @__PURE__ */ jsxs23(
|
|
4176
|
+
"select",
|
|
4177
|
+
{
|
|
4178
|
+
id,
|
|
4179
|
+
name: htmlName || id,
|
|
4180
|
+
multiple,
|
|
4181
|
+
className: "form-control",
|
|
4182
|
+
value: selectValue,
|
|
4183
|
+
required,
|
|
4184
|
+
disabled: disabled || readonly,
|
|
4185
|
+
autoFocus: autofocus,
|
|
4186
|
+
onBlur: handleBlur,
|
|
4187
|
+
onFocus: handleFocus,
|
|
4188
|
+
onChange: handleChange,
|
|
4189
|
+
"aria-describedby": ariaDescribedByIds5(id),
|
|
4190
|
+
children: [
|
|
4191
|
+
showPlaceholderOption && /* @__PURE__ */ jsx55("option", { value: "", children: placeholder }),
|
|
4192
|
+
Array.isArray(enumOptions) && enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
|
|
4193
|
+
const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
|
|
4194
|
+
return /* @__PURE__ */ jsx55(
|
|
4195
|
+
"option",
|
|
4196
|
+
{
|
|
4197
|
+
value: enumOptionValueEncoder3(enumValue, i, optionValueFormat),
|
|
4198
|
+
disabled: isDisabled,
|
|
4199
|
+
children: enumLabel
|
|
4200
|
+
},
|
|
4201
|
+
String(enumValue)
|
|
4202
|
+
);
|
|
4203
|
+
})
|
|
4204
|
+
]
|
|
4205
|
+
}
|
|
4206
|
+
)
|
|
4207
|
+
] });
|
|
4188
4208
|
}
|
|
4189
4209
|
var SelectWidget_default = SelectWidget;
|
|
4190
4210
|
|
|
4191
4211
|
// src/components/widgets/TextareaWidget.tsx
|
|
4192
|
-
import { useCallback as
|
|
4212
|
+
import { useCallback as useCallback15 } from "react";
|
|
4193
4213
|
import { ariaDescribedByIds as ariaDescribedByIds6 } from "@rjsf/utils";
|
|
4194
|
-
import { jsx as
|
|
4214
|
+
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
4195
4215
|
function TextareaWidget({
|
|
4196
4216
|
id,
|
|
4197
|
-
options
|
|
4217
|
+
options,
|
|
4198
4218
|
placeholder,
|
|
4199
4219
|
value,
|
|
4200
4220
|
required,
|
|
@@ -4206,25 +4226,25 @@ function TextareaWidget({
|
|
|
4206
4226
|
onFocus,
|
|
4207
4227
|
htmlName
|
|
4208
4228
|
}) {
|
|
4209
|
-
const handleChange =
|
|
4210
|
-
({ target: { value:
|
|
4229
|
+
const handleChange = useCallback15(
|
|
4230
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
4211
4231
|
[onChange, options.emptyValue]
|
|
4212
4232
|
);
|
|
4213
|
-
const handleBlur =
|
|
4214
|
-
({ target }) => onBlur(id, target
|
|
4233
|
+
const handleBlur = useCallback15(
|
|
4234
|
+
({ target }) => onBlur(id, target?.value),
|
|
4215
4235
|
[onBlur, id]
|
|
4216
4236
|
);
|
|
4217
|
-
const handleFocus =
|
|
4218
|
-
({ target }) => onFocus(id, target
|
|
4237
|
+
const handleFocus = useCallback15(
|
|
4238
|
+
({ target }) => onFocus(id, target?.value),
|
|
4219
4239
|
[id, onFocus]
|
|
4220
4240
|
);
|
|
4221
|
-
return /* @__PURE__ */
|
|
4241
|
+
return /* @__PURE__ */ jsx56(
|
|
4222
4242
|
"textarea",
|
|
4223
4243
|
{
|
|
4224
4244
|
id,
|
|
4225
4245
|
name: htmlName || id,
|
|
4226
4246
|
className: "form-control",
|
|
4227
|
-
value: value
|
|
4247
|
+
value: value || "",
|
|
4228
4248
|
placeholder,
|
|
4229
4249
|
required,
|
|
4230
4250
|
disabled,
|
|
@@ -4241,41 +4261,41 @@ function TextareaWidget({
|
|
|
4241
4261
|
var TextareaWidget_default = TextareaWidget;
|
|
4242
4262
|
|
|
4243
4263
|
// src/components/widgets/TextWidget.tsx
|
|
4244
|
-
import { getTemplate as
|
|
4245
|
-
import { jsx as
|
|
4264
|
+
import { getTemplate as getTemplate25 } from "@rjsf/utils";
|
|
4265
|
+
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
4246
4266
|
function TextWidget(props) {
|
|
4247
4267
|
const { options, registry } = props;
|
|
4248
|
-
const BaseInputTemplate2 =
|
|
4249
|
-
return /* @__PURE__ */
|
|
4268
|
+
const BaseInputTemplate2 = getTemplate25("BaseInputTemplate", registry, options);
|
|
4269
|
+
return /* @__PURE__ */ jsx57(BaseInputTemplate2, { ...props });
|
|
4250
4270
|
}
|
|
4251
4271
|
|
|
4252
4272
|
// src/components/widgets/TimeWidget.tsx
|
|
4253
|
-
import { useCallback as
|
|
4254
|
-
import { getTemplate as
|
|
4255
|
-
import { jsx as
|
|
4273
|
+
import { useCallback as useCallback16 } from "react";
|
|
4274
|
+
import { getTemplate as getTemplate26 } from "@rjsf/utils";
|
|
4275
|
+
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
4256
4276
|
function TimeWidget(props) {
|
|
4257
4277
|
const { onChange, options, registry } = props;
|
|
4258
|
-
const BaseInputTemplate2 =
|
|
4259
|
-
const handleChange =
|
|
4260
|
-
return /* @__PURE__ */
|
|
4278
|
+
const BaseInputTemplate2 = getTemplate26("BaseInputTemplate", registry, options);
|
|
4279
|
+
const handleChange = useCallback16((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
4280
|
+
return /* @__PURE__ */ jsx58(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
4261
4281
|
}
|
|
4262
4282
|
|
|
4263
4283
|
// src/components/widgets/UpDownWidget.tsx
|
|
4264
|
-
import { getTemplate as
|
|
4265
|
-
import { jsx as
|
|
4284
|
+
import { getTemplate as getTemplate27 } from "@rjsf/utils";
|
|
4285
|
+
import { jsx as jsx59 } from "react/jsx-runtime";
|
|
4266
4286
|
function UpDownWidget(props) {
|
|
4267
4287
|
const { options, registry } = props;
|
|
4268
|
-
const BaseInputTemplate2 =
|
|
4269
|
-
return /* @__PURE__ */
|
|
4288
|
+
const BaseInputTemplate2 = getTemplate27("BaseInputTemplate", registry, options);
|
|
4289
|
+
return /* @__PURE__ */ jsx59(BaseInputTemplate2, { type: "number", ...props });
|
|
4270
4290
|
}
|
|
4271
4291
|
|
|
4272
4292
|
// src/components/widgets/URLWidget.tsx
|
|
4273
|
-
import { getTemplate as
|
|
4274
|
-
import { jsx as
|
|
4293
|
+
import { getTemplate as getTemplate28 } from "@rjsf/utils";
|
|
4294
|
+
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
4275
4295
|
function URLWidget(props) {
|
|
4276
4296
|
const { options, registry } = props;
|
|
4277
|
-
const BaseInputTemplate2 =
|
|
4278
|
-
return /* @__PURE__ */
|
|
4297
|
+
const BaseInputTemplate2 = getTemplate28("BaseInputTemplate", registry, options);
|
|
4298
|
+
return /* @__PURE__ */ jsx60(BaseInputTemplate2, { type: "url", ...props });
|
|
4279
4299
|
}
|
|
4280
4300
|
|
|
4281
4301
|
// src/components/widgets/index.ts
|
|
@@ -4323,14 +4343,14 @@ function getDefaultRegistry() {
|
|
|
4323
4343
|
}
|
|
4324
4344
|
|
|
4325
4345
|
// src/components/Form.tsx
|
|
4326
|
-
import { jsx as
|
|
4346
|
+
import { jsx as jsx61, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4327
4347
|
function toIChangeEvent(state, status) {
|
|
4328
4348
|
return {
|
|
4329
4349
|
..._pick(state, ["schema", "uiSchema", "fieldPathId", "schemaUtils", "formData", "edit", "errors", "errorSchema"]),
|
|
4330
4350
|
...status !== void 0 && { status }
|
|
4331
4351
|
};
|
|
4332
4352
|
}
|
|
4333
|
-
var Form = class extends
|
|
4353
|
+
var Form = class _Form extends Component {
|
|
4334
4354
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4335
4355
|
* provide any possible type here
|
|
4336
4356
|
*/
|
|
@@ -4341,7 +4361,7 @@ var Form = class extends Component3 {
|
|
|
4341
4361
|
/** Flag to track when we're processing a user-initiated field change.
|
|
4342
4362
|
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
4343
4363
|
*/
|
|
4344
|
-
|
|
4364
|
+
isProcessingUserChange = false;
|
|
4345
4365
|
/** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
|
|
4346
4366
|
* state before render, ensuring the updated errors are visible immediately in a single render cycle.
|
|
4347
4367
|
*
|
|
@@ -4350,7 +4370,7 @@ var Form = class extends Component3 {
|
|
|
4350
4370
|
* @returns Partial state with re-merged errors if `extraErrors` changed, or `null` if no update is needed
|
|
4351
4371
|
*/
|
|
4352
4372
|
static getDerivedStateFromProps(props, state) {
|
|
4353
|
-
if (props.extraErrors !== state.
|
|
4373
|
+
if (props.extraErrors !== state.prevExtraErrors) {
|
|
4354
4374
|
const baseErrors = {
|
|
4355
4375
|
errors: state.schemaValidationErrors || [],
|
|
4356
4376
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -4366,7 +4386,7 @@ var Form = class extends Component3 {
|
|
|
4366
4386
|
true
|
|
4367
4387
|
));
|
|
4368
4388
|
}
|
|
4369
|
-
return {
|
|
4389
|
+
return { prevExtraErrors: props.extraErrors, errors, errorSchema };
|
|
4370
4390
|
}
|
|
4371
4391
|
return null;
|
|
4372
4392
|
}
|
|
@@ -4385,9 +4405,9 @@ var Form = class extends Component3 {
|
|
|
4385
4405
|
const formData = propsFormData ?? initialFormData;
|
|
4386
4406
|
this.state = {
|
|
4387
4407
|
...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
|
|
4388
|
-
|
|
4408
|
+
prevExtraErrors: props.extraErrors
|
|
4389
4409
|
};
|
|
4390
|
-
if (onChange && !
|
|
4410
|
+
if (onChange && !deepEquals3(this.state.formData, formData)) {
|
|
4391
4411
|
onChange(toIChangeEvent(this.state));
|
|
4392
4412
|
}
|
|
4393
4413
|
this.formElement = createRef();
|
|
@@ -4411,12 +4431,12 @@ var Form = class extends Component3 {
|
|
|
4411
4431
|
* with a flag indicating that an update is not necessary.
|
|
4412
4432
|
*/
|
|
4413
4433
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
4414
|
-
if (!
|
|
4434
|
+
if (!deepEquals3(this.props, prevProps)) {
|
|
4415
4435
|
const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
|
|
4416
4436
|
const stateDataChangedFields = getChangedFields(this.props.formData, this.state.formData);
|
|
4417
|
-
const isSchemaChanged = !
|
|
4418
|
-
const isFormDataChanged = formDataChangedFields.length > 0 || !
|
|
4419
|
-
const isStateDataChanged = stateDataChangedFields.length > 0 || !
|
|
4437
|
+
const isSchemaChanged = !deepEquals3(prevProps.schema, this.props.schema);
|
|
4438
|
+
const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals3(prevProps.formData, this.props.formData);
|
|
4439
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !deepEquals3(this.state.formData, this.props.formData);
|
|
4420
4440
|
const nextState = this.getStateFromProps(
|
|
4421
4441
|
this.props,
|
|
4422
4442
|
this.props.formData,
|
|
@@ -4429,7 +4449,7 @@ var Form = class extends Component3 {
|
|
|
4429
4449
|
// Skip live validation for this request if no form data has changed from the last state
|
|
4430
4450
|
!isStateDataChanged
|
|
4431
4451
|
);
|
|
4432
|
-
const shouldUpdate = !
|
|
4452
|
+
const shouldUpdate = !deepEquals3(nextState, prevState);
|
|
4433
4453
|
return { nextState, shouldUpdate };
|
|
4434
4454
|
}
|
|
4435
4455
|
return { shouldUpdate: false };
|
|
@@ -4449,13 +4469,13 @@ var Form = class extends Component3 {
|
|
|
4449
4469
|
componentDidUpdate(_, prevState, snapshot) {
|
|
4450
4470
|
if (snapshot.shouldUpdate) {
|
|
4451
4471
|
const { nextState } = snapshot;
|
|
4452
|
-
const nextStateDiffersFromProps = !
|
|
4453
|
-
const wasProcessingUserChange = this.
|
|
4454
|
-
this.
|
|
4472
|
+
const nextStateDiffersFromProps = !deepEquals3(nextState.formData, this.props.formData);
|
|
4473
|
+
const wasProcessingUserChange = this.isProcessingUserChange;
|
|
4474
|
+
this.isProcessingUserChange = false;
|
|
4455
4475
|
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
4456
4476
|
return;
|
|
4457
4477
|
}
|
|
4458
|
-
if (nextStateDiffersFromProps && !
|
|
4478
|
+
if (nextStateDiffersFromProps && !deepEquals3(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
4459
4479
|
this.props.onChange(toIChangeEvent(nextState));
|
|
4460
4480
|
}
|
|
4461
4481
|
this.setState(nextState);
|
|
@@ -4468,12 +4488,13 @@ var Form = class extends Component3 {
|
|
|
4468
4488
|
* @param props - The props passed to the `Form`
|
|
4469
4489
|
* @param inputFormData - The new or current data for the `Form`
|
|
4470
4490
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4471
|
-
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
4472
|
-
* @param formDataChangedFields - The changed fields of `formData`
|
|
4473
|
-
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
4491
|
+
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
4492
|
+
* @param [formDataChangedFields=[]] - The changed fields of `formData`
|
|
4493
|
+
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
4494
|
+
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
4474
4495
|
* @returns - The new state for the `Form`
|
|
4475
4496
|
*/
|
|
4476
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
4497
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false, shouldSanitize = false) {
|
|
4477
4498
|
const state = this.state || {};
|
|
4478
4499
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4479
4500
|
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
@@ -4484,7 +4505,7 @@ var Form = class extends Component3 {
|
|
|
4484
4505
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
4485
4506
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4486
4507
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
4487
|
-
let schemaUtils = state
|
|
4508
|
+
let { schemaUtils } = state;
|
|
4488
4509
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
4489
4510
|
validator2,
|
|
4490
4511
|
schema,
|
|
@@ -4505,19 +4526,45 @@ var Form = class extends Component3 {
|
|
|
4505
4526
|
} else if (inputFormData === void 0 && isUncontrolled) {
|
|
4506
4527
|
defaultsFormData = state.formData;
|
|
4507
4528
|
}
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4529
|
+
let formData;
|
|
4530
|
+
let computedRetrievedSchema;
|
|
4531
|
+
let wasSanitized = false;
|
|
4532
|
+
const preventInfiniteSanitize = [];
|
|
4533
|
+
do {
|
|
4534
|
+
formData = schemaUtils.getDefaultFormState(
|
|
4535
|
+
rootSchema,
|
|
4536
|
+
defaultsFormData,
|
|
4537
|
+
false,
|
|
4538
|
+
state.initialDefaultsGenerated
|
|
4539
|
+
);
|
|
4540
|
+
const formHash = shouldSanitize ? hashObject6({ formData }) : "";
|
|
4541
|
+
computedRetrievedSchema = this.updateRetrievedSchema(
|
|
4542
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4543
|
+
);
|
|
4544
|
+
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !deepEquals3(computedRetrievedSchema, state.retrievedSchema)) {
|
|
4545
|
+
const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(
|
|
4546
|
+
computedRetrievedSchema,
|
|
4547
|
+
state.retrievedSchema,
|
|
4548
|
+
formData
|
|
4549
|
+
);
|
|
4550
|
+
wasSanitized = !deepEquals3(sanitizedFormData, formData);
|
|
4551
|
+
if (wasSanitized) {
|
|
4552
|
+
formData = sanitizedFormData;
|
|
4553
|
+
defaultsFormData = sanitizedFormData;
|
|
4554
|
+
const sanitizedFormHash = hashObject6({ formData: sanitizedFormData });
|
|
4555
|
+
wasSanitized = !preventInfiniteSanitize.includes(sanitizedFormHash);
|
|
4556
|
+
preventInfiniteSanitize.push(sanitizedFormHash);
|
|
4557
|
+
}
|
|
4558
|
+
preventInfiniteSanitize.push(formHash);
|
|
4559
|
+
} else {
|
|
4560
|
+
wasSanitized = false;
|
|
4561
|
+
}
|
|
4562
|
+
} while (wasSanitized);
|
|
4517
4563
|
const getCurrentErrors = () => {
|
|
4518
4564
|
if (props.noValidate || isSchemaChanged) {
|
|
4519
4565
|
return { errors: [], errorSchema: {} };
|
|
4520
|
-
}
|
|
4566
|
+
}
|
|
4567
|
+
if (!props.liveValidate) {
|
|
4521
4568
|
return {
|
|
4522
4569
|
errors: state.schemaValidationErrors || [],
|
|
4523
4570
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -4530,8 +4577,7 @@ var Form = class extends Component3 {
|
|
|
4530
4577
|
};
|
|
4531
4578
|
let errors;
|
|
4532
4579
|
let errorSchema;
|
|
4533
|
-
let schemaValidationErrors = state
|
|
4534
|
-
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
4580
|
+
let { schemaValidationErrors, schemaValidationErrorSchema } = state;
|
|
4535
4581
|
if (mustValidate && !skipLiveValidate) {
|
|
4536
4582
|
const liveValidation = this.liveValidate(
|
|
4537
4583
|
rootSchema,
|
|
@@ -4554,26 +4600,24 @@ var Form = class extends Component3 {
|
|
|
4554
4600
|
errors = currentErrors.errors;
|
|
4555
4601
|
errorSchema = currentErrors.errorSchema;
|
|
4556
4602
|
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
4557
|
-
const newErrorSchema = formDataChangedFields.reduce(
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
{}
|
|
4563
|
-
);
|
|
4564
|
-
errorSchema = schemaValidationErrorSchema = mergeObjects(
|
|
4603
|
+
const newErrorSchema = formDataChangedFields.reduce((acc, key) => {
|
|
4604
|
+
acc[key] = void 0;
|
|
4605
|
+
return acc;
|
|
4606
|
+
}, {});
|
|
4607
|
+
schemaValidationErrorSchema = mergeObjects(
|
|
4565
4608
|
currentErrors.errorSchema,
|
|
4566
4609
|
newErrorSchema,
|
|
4567
4610
|
"preventDuplicates"
|
|
4568
4611
|
);
|
|
4612
|
+
errorSchema = schemaValidationErrorSchema;
|
|
4569
4613
|
}
|
|
4570
|
-
const mergedErrors =
|
|
4614
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
4571
4615
|
errors = mergedErrors.errors;
|
|
4572
4616
|
errorSchema = mergedErrors.errorSchema;
|
|
4573
4617
|
}
|
|
4574
|
-
const newRegistry =
|
|
4575
|
-
const registry =
|
|
4576
|
-
const fieldPathId = state.fieldPathId && state.fieldPathId?.[
|
|
4618
|
+
const newRegistry = _Form.getRegistry(props, rootSchema, schemaUtils);
|
|
4619
|
+
const registry = deepEquals3(state.registry, newRegistry) ? state.registry : newRegistry;
|
|
4620
|
+
const fieldPathId = state.fieldPathId && state.fieldPathId?.[ID_KEY6] === registry.globalFormOptions.idPrefix ? state.fieldPathId : toFieldPathId6("", registry.globalFormOptions);
|
|
4577
4621
|
const nextState = {
|
|
4578
4622
|
schemaUtils,
|
|
4579
4623
|
schema: rootSchema,
|
|
@@ -4585,7 +4629,7 @@ var Form = class extends Component3 {
|
|
|
4585
4629
|
errorSchema,
|
|
4586
4630
|
schemaValidationErrors,
|
|
4587
4631
|
schemaValidationErrorSchema,
|
|
4588
|
-
retrievedSchema:
|
|
4632
|
+
retrievedSchema: computedRetrievedSchema,
|
|
4589
4633
|
initialDefaultsGenerated: true,
|
|
4590
4634
|
registry
|
|
4591
4635
|
};
|
|
@@ -4599,7 +4643,7 @@ var Form = class extends Component3 {
|
|
|
4599
4643
|
*/
|
|
4600
4644
|
shouldComponentUpdate(nextProps, nextState) {
|
|
4601
4645
|
const { experimental_componentUpdateStrategy = "customDeep" } = this.props;
|
|
4602
|
-
return
|
|
4646
|
+
return shouldRender(this, nextProps, nextState, experimental_componentUpdateStrategy);
|
|
4603
4647
|
}
|
|
4604
4648
|
/** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
|
|
4605
4649
|
* `schemaUtils` in the state), returning the results.
|
|
@@ -4610,18 +4654,19 @@ var Form = class extends Component3 {
|
|
|
4610
4654
|
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
4611
4655
|
*/
|
|
4612
4656
|
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
4613
|
-
const schemaUtils = altSchemaUtils
|
|
4657
|
+
const schemaUtils = altSchemaUtils || this.state.schemaUtils;
|
|
4614
4658
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4615
|
-
const
|
|
4616
|
-
|
|
4659
|
+
const validationSchema = retrievedSchema ?? schema;
|
|
4660
|
+
const validationFormData = formData ? JSON.parse(JSON.stringify(formData)) : void 0;
|
|
4661
|
+
return schemaUtils.getValidator().validateFormData(validationFormData, validationSchema, customValidate, transformErrors, uiSchema);
|
|
4617
4662
|
}
|
|
4618
4663
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4619
4664
|
renderErrors(registry) {
|
|
4620
4665
|
const { errors, errorSchema, schema, uiSchema } = this.state;
|
|
4621
|
-
const options =
|
|
4622
|
-
const ErrorListTemplate =
|
|
4623
|
-
if (errors
|
|
4624
|
-
return /* @__PURE__ */
|
|
4666
|
+
const options = getUiOptions22(uiSchema);
|
|
4667
|
+
const ErrorListTemplate = getTemplate29("ErrorListTemplate", registry, options);
|
|
4668
|
+
if (errors?.length) {
|
|
4669
|
+
return /* @__PURE__ */ jsx61(
|
|
4625
4670
|
ErrorListTemplate,
|
|
4626
4671
|
{
|
|
4627
4672
|
errors,
|
|
@@ -4642,9 +4687,8 @@ var Form = class extends Component3 {
|
|
|
4642
4687
|
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
4643
4688
|
* @private
|
|
4644
4689
|
*/
|
|
4645
|
-
mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4646
|
-
let errorSchema = schemaValidation
|
|
4647
|
-
let errors = schemaValidation.errors;
|
|
4690
|
+
static mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4691
|
+
let { errorSchema, errors } = schemaValidation;
|
|
4648
4692
|
if (extraErrors) {
|
|
4649
4693
|
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
4650
4694
|
errorSchema = merged.errorSchema;
|
|
@@ -4673,8 +4717,8 @@ var Form = class extends Component3 {
|
|
|
4673
4717
|
*/
|
|
4674
4718
|
liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
|
|
4675
4719
|
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
|
|
4676
|
-
const errors = schemaValidation
|
|
4677
|
-
let errorSchema = schemaValidation
|
|
4720
|
+
const { errors } = schemaValidation;
|
|
4721
|
+
let { errorSchema } = schemaValidation;
|
|
4678
4722
|
if (mergeIntoOriginalErrorSchema) {
|
|
4679
4723
|
errorSchema = mergeObjects(
|
|
4680
4724
|
originalErrorSchema,
|
|
@@ -4684,7 +4728,7 @@ var Form = class extends Component3 {
|
|
|
4684
4728
|
}
|
|
4685
4729
|
const schemaValidationErrors = errors;
|
|
4686
4730
|
const schemaValidationErrorSchema = errorSchema;
|
|
4687
|
-
const mergedErrors =
|
|
4731
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
|
|
4688
4732
|
return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
|
|
4689
4733
|
}
|
|
4690
4734
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
@@ -4693,18 +4737,16 @@ var Form = class extends Component3 {
|
|
|
4693
4737
|
* @param fields - The fields to keep while filtering
|
|
4694
4738
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4695
4739
|
*/
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
};
|
|
4740
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4741
|
+
getUsedFormData = (formData, fields2) => getUsedFormData(formData, fields2);
|
|
4699
4742
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
4700
4743
|
*
|
|
4701
4744
|
* @param pathSchema - The `PathSchema` object for the form
|
|
4702
4745
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4703
4746
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4704
4747
|
*/
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
};
|
|
4748
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4749
|
+
getFieldNames = (pathSchema, formData) => getFieldNames(pathSchema, formData);
|
|
4708
4750
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
4709
4751
|
*
|
|
4710
4752
|
* @param formData - The data for the `Form`
|
|
@@ -4727,7 +4769,7 @@ var Form = class extends Component3 {
|
|
|
4727
4769
|
const { registry } = this.state;
|
|
4728
4770
|
const path = Array.isArray(fieldPath) ? fieldPath : fieldPath.split(".");
|
|
4729
4771
|
const fieldPathId = toFieldPathId6("", registry.globalFormOptions, path);
|
|
4730
|
-
this.onChange(newValue, path, void 0, fieldPathId[
|
|
4772
|
+
this.onChange(newValue, path, void 0, fieldPathId[ID_KEY6]);
|
|
4731
4773
|
};
|
|
4732
4774
|
/** Pushes the given change information into the `pendingChanges` array and then calls `processPendingChanges()` if
|
|
4733
4775
|
* the array only contains a single pending change.
|
|
@@ -4756,25 +4798,24 @@ var Form = class extends Component3 {
|
|
|
4756
4798
|
if (this.pendingChanges.length === 0) {
|
|
4757
4799
|
return;
|
|
4758
4800
|
}
|
|
4759
|
-
this.
|
|
4801
|
+
this.isProcessingUserChange = true;
|
|
4760
4802
|
const { newValue, path, id } = this.pendingChanges[0];
|
|
4761
4803
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
4762
|
-
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4804
|
+
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, disabled, readonly } = this.props;
|
|
4763
4805
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
4764
|
-
let { customErrors } = this.state;
|
|
4806
|
+
let { customErrors, retrievedSchema } = this.state;
|
|
4765
4807
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
4766
4808
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4767
4809
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4768
|
-
let retrievedSchema = this.state.retrievedSchema;
|
|
4769
4810
|
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
4770
4811
|
const hasOnlyUndefinedValues = isObject6(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
|
|
4771
4812
|
const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
|
|
4772
4813
|
const inputForDefaults = hasOnlyUndefinedValues && wasPreviouslyNull ? void 0 : formData;
|
|
4773
4814
|
if (isObject6(formData) || Array.isArray(formData)) {
|
|
4815
|
+
let plainLeafWasCleared = false;
|
|
4774
4816
|
if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
|
|
4775
4817
|
_unset(formData, path);
|
|
4776
4818
|
} else if (!isRootPath) {
|
|
4777
|
-
let unsetPath = false;
|
|
4778
4819
|
let valueForPath = newValue;
|
|
4779
4820
|
if (newValue === void 0) {
|
|
4780
4821
|
const lastSegment = path[path.length - 1];
|
|
@@ -4785,28 +4826,38 @@ var Form = class extends Component3 {
|
|
|
4785
4826
|
const leaf = field;
|
|
4786
4827
|
const isOneOfOrAnyOfLeaf = leaf && (ONE_OF_KEY6 in leaf || ANY_OF_KEY6 in leaf);
|
|
4787
4828
|
if (!isOneOfOrAnyOfLeaf && leaf !== void 0) {
|
|
4788
|
-
|
|
4829
|
+
plainLeafWasCleared = true;
|
|
4789
4830
|
}
|
|
4790
4831
|
}
|
|
4791
4832
|
}
|
|
4792
|
-
if (
|
|
4793
|
-
|
|
4833
|
+
if (plainLeafWasCleared) {
|
|
4834
|
+
_set(formData, path, void 0);
|
|
4794
4835
|
} else {
|
|
4795
4836
|
_set(formData, path, valueForPath);
|
|
4796
4837
|
}
|
|
4797
4838
|
}
|
|
4798
|
-
const
|
|
4839
|
+
const shouldSanitize = retrievedSchema && !isRootPath && !isObject6(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
4840
|
+
const newState = this.getStateFromProps(
|
|
4841
|
+
this.props,
|
|
4842
|
+
inputForDefaults,
|
|
4843
|
+
void 0,
|
|
4844
|
+
void 0,
|
|
4845
|
+
void 0,
|
|
4846
|
+
true,
|
|
4847
|
+
shouldSanitize
|
|
4848
|
+
);
|
|
4799
4849
|
formData = newState.formData;
|
|
4800
4850
|
retrievedSchema = newState.retrievedSchema;
|
|
4851
|
+
if (plainLeafWasCleared && formData) {
|
|
4852
|
+
_set(formData, path, void 0);
|
|
4853
|
+
}
|
|
4801
4854
|
}
|
|
4802
4855
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
|
|
4803
|
-
let state = { formData,
|
|
4856
|
+
let state = { formData, retrievedSchema };
|
|
4804
4857
|
let newFormData = formData;
|
|
4805
4858
|
if (omitExtraData === true && (liveOmit === true || liveOmit === "onChange")) {
|
|
4806
4859
|
newFormData = this.omitExtraData(formData);
|
|
4807
|
-
state = {
|
|
4808
|
-
formData: newFormData
|
|
4809
|
-
};
|
|
4860
|
+
state = { ...state, formData: newFormData };
|
|
4810
4861
|
}
|
|
4811
4862
|
if (newErrorSchema) {
|
|
4812
4863
|
const oldValidationError = !isRootPath ? _get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
@@ -4822,9 +4873,9 @@ var Form = class extends Component3 {
|
|
|
4822
4873
|
customErrors = new ErrorSchemaBuilder();
|
|
4823
4874
|
}
|
|
4824
4875
|
if (isRootPath) {
|
|
4825
|
-
const
|
|
4826
|
-
if (
|
|
4827
|
-
customErrors.setErrors(
|
|
4876
|
+
const pathErrors = _get(newErrorSchema, ERRORS_KEY3);
|
|
4877
|
+
if (pathErrors) {
|
|
4878
|
+
customErrors.setErrors(pathErrors);
|
|
4828
4879
|
}
|
|
4829
4880
|
} else {
|
|
4830
4881
|
_set(customErrors.ErrorSchema, path, newErrorSchema);
|
|
@@ -4843,14 +4894,14 @@ var Form = class extends Component3 {
|
|
|
4843
4894
|
customErrors,
|
|
4844
4895
|
retrievedSchema
|
|
4845
4896
|
);
|
|
4846
|
-
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
4897
|
+
state = { ...state, formData: newFormData, ...liveValidation, customErrors };
|
|
4847
4898
|
} else if (!noValidate && newErrorSchema) {
|
|
4848
|
-
const mergedErrors =
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
...mergedErrors,
|
|
4899
|
+
const mergedErrors = _Form.mergeErrors(
|
|
4900
|
+
{ errorSchema: mergeBaseErrorSchema, errors },
|
|
4901
|
+
extraErrors,
|
|
4852
4902
|
customErrors
|
|
4853
|
-
|
|
4903
|
+
);
|
|
4904
|
+
state = { ...state, formData: newFormData, ...mergedErrors, customErrors };
|
|
4854
4905
|
}
|
|
4855
4906
|
this.setState(state, () => {
|
|
4856
4907
|
if (onChange) {
|
|
@@ -4870,7 +4921,7 @@ var Form = class extends Component3 {
|
|
|
4870
4921
|
* @returns The new retrieved schema if it has changed, else the old retrieved schema.
|
|
4871
4922
|
*/
|
|
4872
4923
|
updateRetrievedSchema(retrievedSchema) {
|
|
4873
|
-
const isTheSame =
|
|
4924
|
+
const isTheSame = deepEquals3(retrievedSchema, this.state?.retrievedSchema);
|
|
4874
4925
|
return isTheSame ? this.state.retrievedSchema : retrievedSchema;
|
|
4875
4926
|
}
|
|
4876
4927
|
/**
|
|
@@ -4899,7 +4950,7 @@ var Form = class extends Component3 {
|
|
|
4899
4950
|
initialDefaultsGenerated: false,
|
|
4900
4951
|
customErrors: void 0
|
|
4901
4952
|
};
|
|
4902
|
-
this.setState(state, () => onChange
|
|
4953
|
+
this.setState(state, () => onChange?.(toIChangeEvent({ ...this.state, ...state })));
|
|
4903
4954
|
};
|
|
4904
4955
|
/** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
|
|
4905
4956
|
* was provided. Also runs any live validation and/or live omit operations if the flags indicate they should happen
|
|
@@ -4938,7 +4989,7 @@ var Form = class extends Component3 {
|
|
|
4938
4989
|
const hasChanges = Object.keys(state).filter((key) => !key.startsWith("schemaValidation")).some((key) => {
|
|
4939
4990
|
const oldData = _get(this.state, key);
|
|
4940
4991
|
const newData = _get(state, key);
|
|
4941
|
-
return !
|
|
4992
|
+
return !deepEquals3(oldData, newData);
|
|
4942
4993
|
});
|
|
4943
4994
|
this.setState(state, () => {
|
|
4944
4995
|
if (onChange && hasChanges) {
|
|
@@ -5003,7 +5054,7 @@ var Form = class extends Component3 {
|
|
|
5003
5054
|
* @returns - The `GlobalFormOptions` from the props
|
|
5004
5055
|
* @private
|
|
5005
5056
|
*/
|
|
5006
|
-
getGlobalFormOptions(props) {
|
|
5057
|
+
static getGlobalFormOptions(props) {
|
|
5007
5058
|
const {
|
|
5008
5059
|
uiSchema = {},
|
|
5009
5060
|
experimental_componentUpdateStrategy,
|
|
@@ -5022,7 +5073,7 @@ var Form = class extends Component3 {
|
|
|
5022
5073
|
};
|
|
5023
5074
|
}
|
|
5024
5075
|
/** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
|
|
5025
|
-
getRegistry(props, schema, schemaUtils) {
|
|
5076
|
+
static getRegistry(props, schema, schemaUtils) {
|
|
5026
5077
|
const { translateString: customTranslateString, uiSchema = {} } = props;
|
|
5027
5078
|
const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
|
|
5028
5079
|
return {
|
|
@@ -5041,7 +5092,7 @@ var Form = class extends Component3 {
|
|
|
5041
5092
|
schemaUtils,
|
|
5042
5093
|
translateString: customTranslateString || translateString,
|
|
5043
5094
|
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY2],
|
|
5044
|
-
globalFormOptions:
|
|
5095
|
+
globalFormOptions: _Form.getGlobalFormOptions(props),
|
|
5045
5096
|
uiSchemaDefinitions: uiSchema[UI_DEFINITIONS_KEY] ?? {}
|
|
5046
5097
|
};
|
|
5047
5098
|
}
|
|
@@ -5076,7 +5127,7 @@ var Form = class extends Component3 {
|
|
|
5076
5127
|
if (!field) {
|
|
5077
5128
|
field = this.formElement.current.querySelector(`input[id^="${elementId}"], button[id^="${elementId}"]`);
|
|
5078
5129
|
}
|
|
5079
|
-
if (field
|
|
5130
|
+
if (field?.length) {
|
|
5080
5131
|
field = field[0];
|
|
5081
5132
|
}
|
|
5082
5133
|
if (field) {
|
|
@@ -5093,7 +5144,7 @@ var Form = class extends Component3 {
|
|
|
5093
5144
|
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
5094
5145
|
const { errors: prevErrors } = this.state;
|
|
5095
5146
|
const schemaValidation = this.validate(formData);
|
|
5096
|
-
const { errors, errorSchema } = extraErrors ?
|
|
5147
|
+
const { errors, errorSchema } = extraErrors ? _Form.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
|
|
5097
5148
|
const hasError = schemaValidation.errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
5098
5149
|
if (hasError) {
|
|
5099
5150
|
if (focusOnFirstError) {
|
|
@@ -5172,19 +5223,19 @@ var Form = class extends Component3 {
|
|
|
5172
5223
|
_internalFormWrapper
|
|
5173
5224
|
} = this.props;
|
|
5174
5225
|
const { schema, uiSchema, formData, errorSchema, fieldPathId, registry } = this.state;
|
|
5175
|
-
const { SchemaField:
|
|
5226
|
+
const { SchemaField: SchemaFieldComponent } = registry.fields;
|
|
5176
5227
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
5177
5228
|
const as = _internalFormWrapper ? tagName : void 0;
|
|
5178
5229
|
const FormTag = _internalFormWrapper || tagName || "form";
|
|
5179
|
-
let { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } =
|
|
5230
|
+
let { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } = getUiOptions22(uiSchema);
|
|
5180
5231
|
if (disabled) {
|
|
5181
5232
|
submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
|
|
5182
5233
|
}
|
|
5183
5234
|
const submitUiSchema = { [UI_OPTIONS_KEY3]: { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
|
|
5184
|
-
return /* @__PURE__ */
|
|
5235
|
+
return /* @__PURE__ */ jsxs24(
|
|
5185
5236
|
FormTag,
|
|
5186
5237
|
{
|
|
5187
|
-
className: className
|
|
5238
|
+
className: className || "rjsf",
|
|
5188
5239
|
id,
|
|
5189
5240
|
name,
|
|
5190
5241
|
method,
|
|
@@ -5199,8 +5250,8 @@ var Form = class extends Component3 {
|
|
|
5199
5250
|
ref: this.formElement,
|
|
5200
5251
|
children: [
|
|
5201
5252
|
showErrorList === "top" && this.renderErrors(registry),
|
|
5202
|
-
/* @__PURE__ */
|
|
5203
|
-
|
|
5253
|
+
/* @__PURE__ */ jsx61(
|
|
5254
|
+
SchemaFieldComponent,
|
|
5204
5255
|
{
|
|
5205
5256
|
name: "",
|
|
5206
5257
|
schema,
|
|
@@ -5216,7 +5267,7 @@ var Form = class extends Component3 {
|
|
|
5216
5267
|
readonly
|
|
5217
5268
|
}
|
|
5218
5269
|
),
|
|
5219
|
-
children
|
|
5270
|
+
children || /* @__PURE__ */ jsx61(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
5220
5271
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
5221
5272
|
]
|
|
5222
5273
|
}
|
|
@@ -5225,12 +5276,7 @@ var Form = class extends Component3 {
|
|
|
5225
5276
|
};
|
|
5226
5277
|
|
|
5227
5278
|
// src/getTestRegistry.tsx
|
|
5228
|
-
import {
|
|
5229
|
-
DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX3,
|
|
5230
|
-
DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR3,
|
|
5231
|
-
createSchemaUtils as createSchemaUtils2,
|
|
5232
|
-
englishStringTranslator as englishStringTranslator2
|
|
5233
|
-
} from "@rjsf/utils";
|
|
5279
|
+
import { DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX3, DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR3, createSchemaUtils as createSchemaUtils2, englishStringTranslator as englishStringTranslator2 } from "@rjsf/utils";
|
|
5234
5280
|
import validator from "@rjsf/validator-ajv8";
|
|
5235
5281
|
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = {
|
|
5236
5282
|
idPrefix: DEFAULT_ID_PREFIX3,
|
|
@@ -5253,21 +5299,21 @@ function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {
|
|
|
5253
5299
|
|
|
5254
5300
|
// src/withTheme.tsx
|
|
5255
5301
|
import { forwardRef } from "react";
|
|
5256
|
-
import { jsx as
|
|
5302
|
+
import { jsx as jsx62 } from "react/jsx-runtime";
|
|
5257
5303
|
function withTheme(themeProps) {
|
|
5258
5304
|
return forwardRef(
|
|
5259
|
-
({ fields:
|
|
5260
|
-
fields2 = { ...themeProps?.fields, ...
|
|
5261
|
-
widgets2 = { ...themeProps?.widgets, ...
|
|
5262
|
-
templates2 = {
|
|
5305
|
+
({ fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }, ref) => {
|
|
5306
|
+
const fields2 = { ...themeProps?.fields, ...propFields };
|
|
5307
|
+
const widgets2 = { ...themeProps?.widgets, ...propWidgets };
|
|
5308
|
+
const templates2 = {
|
|
5263
5309
|
...themeProps?.templates,
|
|
5264
|
-
...
|
|
5310
|
+
...propTemplates,
|
|
5265
5311
|
ButtonTemplates: {
|
|
5266
5312
|
...themeProps?.templates?.ButtonTemplates,
|
|
5267
|
-
...
|
|
5313
|
+
...propTemplates?.ButtonTemplates
|
|
5268
5314
|
}
|
|
5269
5315
|
};
|
|
5270
|
-
return /* @__PURE__ */
|
|
5316
|
+
return /* @__PURE__ */ jsx62(
|
|
5271
5317
|
Form,
|
|
5272
5318
|
{
|
|
5273
5319
|
...themeProps,
|