@rjsf/core 6.0.0-beta.2 → 6.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.umd.js +705 -471
- package/dist/{index.js → index.cjs} +1094 -844
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +1053 -774
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +88 -23
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +213 -151
- package/lib/components/fields/ArrayField.d.ts +17 -7
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +116 -70
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +7 -2
- package/lib/components/fields/LayoutGridField.d.ts +27 -25
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +83 -59
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.js +3 -3
- package/lib/components/fields/LayoutMultiSchemaField.js +6 -5
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +13 -9
- package/lib/components/fields/NullField.js +3 -3
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +3 -3
- package/lib/components/fields/ObjectField.d.ts +3 -3
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +34 -34
- package/lib/components/fields/OptionalDataControlsField.d.ts +8 -0
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -0
- package/lib/components/fields/OptionalDataControlsField.js +43 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +17 -17
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +7 -2
- 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 +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +3 -3
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +2 -2
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +4 -3
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js +2 -2
- package/lib/components/templates/FieldErrorTemplate.js +2 -2
- package/lib/components/templates/FieldHelpTemplate.js +2 -2
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +8 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +3 -2
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +11 -0
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -0
- package/lib/components/templates/OptionalDataControlsTemplate.js +20 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/TitleField.js +2 -2
- package/lib/components/templates/UnsupportedField.js +3 -3
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +4 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +15 -18
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +2 -1
- package/lib/getTestRegistry.d.ts +5 -0
- package/lib/getTestRegistry.d.ts.map +1 -0
- package/lib/getTestRegistry.js +19 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -19
- package/src/components/Form.tsx +306 -177
- package/src/components/fields/ArrayField.tsx +127 -80
- package/src/components/fields/BooleanField.tsx +12 -3
- package/src/components/fields/LayoutGridField.tsx +95 -88
- package/src/components/fields/LayoutHeaderField.tsx +3 -3
- package/src/components/fields/LayoutMultiSchemaField.tsx +5 -5
- package/src/components/fields/MultiSchemaField.tsx +51 -35
- package/src/components/fields/NullField.tsx +3 -3
- package/src/components/fields/NumberField.tsx +11 -3
- package/src/components/fields/ObjectField.tsx +47 -53
- package/src/components/fields/OptionalDataControlsField.tsx +84 -0
- package/src/components/fields/SchemaField.tsx +24 -30
- package/src/components/fields/StringField.tsx +12 -3
- package/src/components/fields/index.ts +2 -0
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTemplate.tsx +9 -5
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +4 -3
- package/src/components/templates/BaseInputTemplate.tsx +3 -3
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -0
- package/src/components/templates/FieldErrorTemplate.tsx +2 -2
- package/src/components/templates/FieldHelpTemplate.tsx +2 -2
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +20 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +10 -5
- package/src/components/templates/OptionalDataControlsTemplate.tsx +43 -0
- package/src/components/templates/TitleField.tsx +6 -1
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +4 -0
- package/src/components/widgets/AltDateWidget.tsx +21 -23
- package/src/components/widgets/CheckboxWidget.tsx +2 -2
- package/src/components/widgets/CheckboxesWidget.tsx +3 -3
- package/src/components/widgets/RadioWidget.tsx +1 -1
- package/src/components/widgets/SelectWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +1 -1
- package/src/getDefaultRegistry.ts +10 -1
- package/src/getTestRegistry.tsx +34 -0
- package/src/index.ts +2 -1
- package/dist/index.js.map +0 -7
package/dist/index.esm.js
CHANGED
|
@@ -2,32 +2,39 @@
|
|
|
2
2
|
import { Component as Component5, createRef } from "react";
|
|
3
3
|
import {
|
|
4
4
|
createSchemaUtils,
|
|
5
|
-
deepEquals as
|
|
5
|
+
deepEquals as deepEquals2,
|
|
6
|
+
ErrorSchemaBuilder,
|
|
6
7
|
getChangedFields,
|
|
7
|
-
getTemplate as
|
|
8
|
-
getUiOptions as
|
|
8
|
+
getTemplate as getTemplate26,
|
|
9
|
+
getUiOptions as getUiOptions18,
|
|
9
10
|
isObject as isObject6,
|
|
10
|
-
mergeObjects
|
|
11
|
+
mergeObjects,
|
|
11
12
|
NAME_KEY,
|
|
12
13
|
RJSF_ADDITIONAL_PROPERTIES_FLAG,
|
|
13
|
-
shouldRender,
|
|
14
|
+
shouldRender as shouldRender2,
|
|
14
15
|
SUBMIT_BTN_OPTIONS_KEY,
|
|
15
16
|
toErrorList,
|
|
16
|
-
|
|
17
|
+
toFieldPathId as toFieldPathId4,
|
|
18
|
+
UI_GLOBAL_OPTIONS_KEY as UI_GLOBAL_OPTIONS_KEY2,
|
|
17
19
|
UI_OPTIONS_KEY as UI_OPTIONS_KEY3,
|
|
18
20
|
validationDataMerge,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR2,
|
|
22
|
+
DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX2,
|
|
23
|
+
ERRORS_KEY as ERRORS_KEY3
|
|
21
24
|
} from "@rjsf/utils";
|
|
22
|
-
import
|
|
25
|
+
import _cloneDeep from "lodash/cloneDeep";
|
|
23
26
|
import _get from "lodash/get";
|
|
24
27
|
import _isEmpty from "lodash/isEmpty";
|
|
25
|
-
import _isNil from "lodash/isNil";
|
|
26
28
|
import _pick from "lodash/pick";
|
|
29
|
+
import _set from "lodash/set";
|
|
27
30
|
import _toPath from "lodash/toPath";
|
|
28
31
|
|
|
29
32
|
// src/getDefaultRegistry.ts
|
|
30
|
-
import {
|
|
33
|
+
import {
|
|
34
|
+
DEFAULT_ID_PREFIX,
|
|
35
|
+
DEFAULT_ID_SEPARATOR,
|
|
36
|
+
englishStringTranslator
|
|
37
|
+
} from "@rjsf/utils";
|
|
31
38
|
|
|
32
39
|
// src/components/fields/ArrayField.tsx
|
|
33
40
|
import { Component } from "react";
|
|
@@ -38,7 +45,10 @@ import {
|
|
|
38
45
|
isFixedItems,
|
|
39
46
|
allowAdditionalItems,
|
|
40
47
|
isCustomWidget,
|
|
48
|
+
isFormDataAvailable,
|
|
41
49
|
optionsList,
|
|
50
|
+
shouldRenderOptionalField,
|
|
51
|
+
toFieldPathId,
|
|
42
52
|
TranslatableString,
|
|
43
53
|
ITEMS_KEY
|
|
44
54
|
} from "@rjsf/utils";
|
|
@@ -46,10 +56,10 @@ import cloneDeep from "lodash/cloneDeep";
|
|
|
46
56
|
import get from "lodash/get";
|
|
47
57
|
import isObject from "lodash/isObject";
|
|
48
58
|
import set from "lodash/set";
|
|
49
|
-
import
|
|
59
|
+
import uniqueId from "lodash/uniqueId";
|
|
50
60
|
import { jsx } from "react/jsx-runtime";
|
|
51
61
|
function generateRowId() {
|
|
52
|
-
return
|
|
62
|
+
return uniqueId("rjsf-array-item-");
|
|
53
63
|
}
|
|
54
64
|
function generateKeyedFormData(formData) {
|
|
55
65
|
return !Array.isArray(formData) ? [] : formData.map((item) => {
|
|
@@ -72,7 +82,7 @@ var ArrayField = class extends Component {
|
|
|
72
82
|
*/
|
|
73
83
|
constructor(props) {
|
|
74
84
|
super(props);
|
|
75
|
-
const { formData
|
|
85
|
+
const { formData } = props;
|
|
76
86
|
const keyedFormData = generateKeyedFormData(formData);
|
|
77
87
|
this.state = {
|
|
78
88
|
keyedFormData,
|
|
@@ -169,7 +179,7 @@ var ArrayField = class extends Component {
|
|
|
169
179
|
if (event) {
|
|
170
180
|
event.preventDefault();
|
|
171
181
|
}
|
|
172
|
-
const { onChange, errorSchema } = this.props;
|
|
182
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
173
183
|
const { keyedFormData } = this.state;
|
|
174
184
|
let newErrorSchema;
|
|
175
185
|
if (errorSchema) {
|
|
@@ -198,7 +208,8 @@ var ArrayField = class extends Component {
|
|
|
198
208
|
keyedFormData: newKeyedFormData,
|
|
199
209
|
updatedKeyedFormData: true
|
|
200
210
|
},
|
|
201
|
-
|
|
211
|
+
// add click will pass the empty `path` array to the onChange which adds the appropriate path
|
|
212
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
202
213
|
);
|
|
203
214
|
}
|
|
204
215
|
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
@@ -232,7 +243,7 @@ var ArrayField = class extends Component {
|
|
|
232
243
|
if (event) {
|
|
233
244
|
event.preventDefault();
|
|
234
245
|
}
|
|
235
|
-
const { onChange, errorSchema } = this.props;
|
|
246
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
236
247
|
const { keyedFormData } = this.state;
|
|
237
248
|
let newErrorSchema;
|
|
238
249
|
if (errorSchema) {
|
|
@@ -261,7 +272,7 @@ var ArrayField = class extends Component {
|
|
|
261
272
|
keyedFormData: newKeyedFormData,
|
|
262
273
|
updatedKeyedFormData: true
|
|
263
274
|
},
|
|
264
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
275
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
265
276
|
);
|
|
266
277
|
};
|
|
267
278
|
};
|
|
@@ -276,7 +287,7 @@ var ArrayField = class extends Component {
|
|
|
276
287
|
if (event) {
|
|
277
288
|
event.preventDefault();
|
|
278
289
|
}
|
|
279
|
-
const { onChange, errorSchema } = this.props;
|
|
290
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
280
291
|
const { keyedFormData } = this.state;
|
|
281
292
|
let newErrorSchema;
|
|
282
293
|
if (errorSchema) {
|
|
@@ -296,7 +307,7 @@ var ArrayField = class extends Component {
|
|
|
296
307
|
keyedFormData: newKeyedFormData,
|
|
297
308
|
updatedKeyedFormData: true
|
|
298
309
|
},
|
|
299
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
310
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
300
311
|
);
|
|
301
312
|
};
|
|
302
313
|
};
|
|
@@ -313,7 +324,7 @@ var ArrayField = class extends Component {
|
|
|
313
324
|
event.preventDefault();
|
|
314
325
|
event.currentTarget.blur();
|
|
315
326
|
}
|
|
316
|
-
const { onChange, errorSchema } = this.props;
|
|
327
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
317
328
|
let newErrorSchema;
|
|
318
329
|
if (errorSchema) {
|
|
319
330
|
newErrorSchema = {};
|
|
@@ -340,7 +351,7 @@ var ArrayField = class extends Component {
|
|
|
340
351
|
{
|
|
341
352
|
keyedFormData: newKeyedFormData
|
|
342
353
|
},
|
|
343
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
354
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
344
355
|
);
|
|
345
356
|
};
|
|
346
357
|
};
|
|
@@ -350,32 +361,49 @@ var ArrayField = class extends Component {
|
|
|
350
361
|
* @param index - The index of the item being changed
|
|
351
362
|
*/
|
|
352
363
|
onChangeForIndex = (index) => {
|
|
353
|
-
return (value, newErrorSchema, id) => {
|
|
354
|
-
const {
|
|
355
|
-
const arrayData = Array.isArray(formData) ? formData : [];
|
|
356
|
-
const newFormData = arrayData.map((item, i) => {
|
|
357
|
-
const jsonValue = typeof value === "undefined" ? null : value;
|
|
358
|
-
return index === i ? jsonValue : item;
|
|
359
|
-
});
|
|
364
|
+
return (value, path, newErrorSchema, id) => {
|
|
365
|
+
const { onChange } = this.props;
|
|
360
366
|
onChange(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
// We need to treat undefined items as nulls to have validation.
|
|
368
|
+
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
369
|
+
value === void 0 ? null : value,
|
|
370
|
+
path,
|
|
371
|
+
newErrorSchema,
|
|
366
372
|
id
|
|
367
373
|
);
|
|
368
374
|
};
|
|
369
375
|
};
|
|
370
376
|
/** Callback handler used to change the value for a checkbox */
|
|
371
377
|
onSelectChange = (value) => {
|
|
372
|
-
const { onChange,
|
|
373
|
-
onChange(value, void 0,
|
|
378
|
+
const { onChange, fieldPathId } = this.props;
|
|
379
|
+
onChange(value, fieldPathId.path, void 0, fieldPathId && fieldPathId.$id);
|
|
374
380
|
};
|
|
381
|
+
/** Helper method to compute item UI schema for both normal and fixed arrays
|
|
382
|
+
* Handles both static object and dynamic function cases
|
|
383
|
+
*
|
|
384
|
+
* @param uiSchema - The parent UI schema containing items definition
|
|
385
|
+
* @param item - The item data
|
|
386
|
+
* @param index - The index of the item
|
|
387
|
+
* @param formContext - The form context
|
|
388
|
+
* @returns The computed UI schema for the item
|
|
389
|
+
*/
|
|
390
|
+
computeItemUiSchema(uiSchema, item, index, formContext) {
|
|
391
|
+
if (typeof uiSchema.items === "function") {
|
|
392
|
+
try {
|
|
393
|
+
const result = uiSchema.items(item, index, formContext);
|
|
394
|
+
return result;
|
|
395
|
+
} catch (e) {
|
|
396
|
+
console.error(`Error executing dynamic uiSchema.items function for item at index ${index}:`, e);
|
|
397
|
+
return void 0;
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
return uiSchema.items;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
375
403
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
376
404
|
*/
|
|
377
405
|
render() {
|
|
378
|
-
const { schema, uiSchema,
|
|
406
|
+
const { schema, uiSchema, fieldPathId, registry } = this.props;
|
|
379
407
|
const { schemaUtils, translateString } = registry;
|
|
380
408
|
if (!(ITEMS_KEY in schema)) {
|
|
381
409
|
const uiOptions = getUiOptions(uiSchema);
|
|
@@ -388,7 +416,7 @@ var ArrayField = class extends Component {
|
|
|
388
416
|
UnsupportedFieldTemplate,
|
|
389
417
|
{
|
|
390
418
|
schema,
|
|
391
|
-
|
|
419
|
+
fieldPathId,
|
|
392
420
|
reason: translateString(TranslatableString.MissingItems),
|
|
393
421
|
registry
|
|
394
422
|
}
|
|
@@ -415,7 +443,7 @@ var ArrayField = class extends Component {
|
|
|
415
443
|
schema,
|
|
416
444
|
uiSchema = {},
|
|
417
445
|
errorSchema,
|
|
418
|
-
|
|
446
|
+
fieldPathId,
|
|
419
447
|
name,
|
|
420
448
|
title,
|
|
421
449
|
disabled = false,
|
|
@@ -425,27 +453,31 @@ var ArrayField = class extends Component {
|
|
|
425
453
|
registry,
|
|
426
454
|
onBlur,
|
|
427
455
|
onFocus,
|
|
428
|
-
idPrefix,
|
|
429
|
-
idSeparator = "_",
|
|
430
456
|
rawErrors
|
|
431
457
|
} = this.props;
|
|
432
458
|
const { keyedFormData } = this.state;
|
|
433
459
|
const fieldTitle = schema.title || title || name;
|
|
434
|
-
const { schemaUtils, formContext } = registry;
|
|
460
|
+
const { schemaUtils, fields: fields2, formContext, globalFormOptions } = registry;
|
|
461
|
+
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
435
462
|
const uiOptions = getUiOptions(uiSchema);
|
|
436
463
|
const _schemaItems = isObject(schema.items) ? schema.items : {};
|
|
437
464
|
const itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
|
|
438
465
|
const formData = keyedToPlainFormData(this.state.keyedFormData);
|
|
439
|
-
const
|
|
466
|
+
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
467
|
+
const hasFormData = isFormDataAvailable(this.props.formData);
|
|
468
|
+
const canAdd = this.canAddItem(formData) && (!renderOptionalField || hasFormData);
|
|
469
|
+
const actualFormData = hasFormData ? keyedFormData : [];
|
|
470
|
+
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
471
|
+
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsx(OptionalDataControlsField2, { ...this.props }) : void 0;
|
|
440
472
|
const arrayProps = {
|
|
441
473
|
canAdd,
|
|
442
|
-
items:
|
|
474
|
+
items: actualFormData.map((keyedItem, index) => {
|
|
443
475
|
const { key, item } = keyedItem;
|
|
444
476
|
const itemCast = item;
|
|
445
477
|
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
446
478
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
447
|
-
const
|
|
448
|
-
const
|
|
479
|
+
const itemFieldPathId = toFieldPathId(index, globalFormOptions, fieldPathId);
|
|
480
|
+
const itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
|
|
449
481
|
return this.renderArrayFieldItem({
|
|
450
482
|
key,
|
|
451
483
|
index,
|
|
@@ -455,10 +487,10 @@ var ArrayField = class extends Component {
|
|
|
455
487
|
canMoveUp: index > 0,
|
|
456
488
|
canMoveDown: index < formData.length - 1,
|
|
457
489
|
itemSchema,
|
|
458
|
-
|
|
490
|
+
itemFieldPathId,
|
|
459
491
|
itemErrorSchema,
|
|
460
492
|
itemData: itemCast,
|
|
461
|
-
itemUiSchema
|
|
493
|
+
itemUiSchema,
|
|
462
494
|
autofocus: autofocus && index === 0,
|
|
463
495
|
onBlur,
|
|
464
496
|
onFocus,
|
|
@@ -466,19 +498,19 @@ var ArrayField = class extends Component {
|
|
|
466
498
|
totalItems: keyedFormData.length
|
|
467
499
|
});
|
|
468
500
|
}),
|
|
469
|
-
className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}`,
|
|
501
|
+
className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}${extraClass}`,
|
|
470
502
|
disabled,
|
|
471
|
-
|
|
503
|
+
fieldPathId,
|
|
472
504
|
uiSchema,
|
|
473
505
|
onAddClick: this.onAddClick,
|
|
474
506
|
readonly,
|
|
475
507
|
required,
|
|
476
508
|
schema,
|
|
477
509
|
title: fieldTitle,
|
|
478
|
-
formContext,
|
|
479
510
|
formData,
|
|
480
511
|
rawErrors,
|
|
481
|
-
registry
|
|
512
|
+
registry,
|
|
513
|
+
optionalDataControl
|
|
482
514
|
};
|
|
483
515
|
const Template = getTemplate("ArrayFieldTemplate", registry, uiOptions);
|
|
484
516
|
return /* @__PURE__ */ jsx(Template, { ...arrayProps });
|
|
@@ -488,7 +520,7 @@ var ArrayField = class extends Component {
|
|
|
488
520
|
renderCustomWidget() {
|
|
489
521
|
const {
|
|
490
522
|
schema,
|
|
491
|
-
|
|
523
|
+
fieldPathId,
|
|
492
524
|
uiSchema,
|
|
493
525
|
disabled = false,
|
|
494
526
|
readonly = false,
|
|
@@ -511,7 +543,7 @@ var ArrayField = class extends Component {
|
|
|
511
543
|
return /* @__PURE__ */ jsx(
|
|
512
544
|
Widget,
|
|
513
545
|
{
|
|
514
|
-
id:
|
|
546
|
+
id: fieldPathId.$id,
|
|
515
547
|
name,
|
|
516
548
|
multiple: true,
|
|
517
549
|
onChange: this.onSelectChange,
|
|
@@ -540,7 +572,7 @@ var ArrayField = class extends Component {
|
|
|
540
572
|
renderMultiSelect() {
|
|
541
573
|
const {
|
|
542
574
|
schema,
|
|
543
|
-
|
|
575
|
+
fieldPathId,
|
|
544
576
|
uiSchema,
|
|
545
577
|
formData: items = [],
|
|
546
578
|
disabled = false,
|
|
@@ -564,7 +596,7 @@ var ArrayField = class extends Component {
|
|
|
564
596
|
return /* @__PURE__ */ jsx(
|
|
565
597
|
Widget,
|
|
566
598
|
{
|
|
567
|
-
id:
|
|
599
|
+
id: fieldPathId.$id,
|
|
568
600
|
name,
|
|
569
601
|
multiple: true,
|
|
570
602
|
onChange: this.onSelectChange,
|
|
@@ -593,7 +625,7 @@ var ArrayField = class extends Component {
|
|
|
593
625
|
const {
|
|
594
626
|
schema,
|
|
595
627
|
uiSchema,
|
|
596
|
-
|
|
628
|
+
fieldPathId,
|
|
597
629
|
name,
|
|
598
630
|
disabled = false,
|
|
599
631
|
readonly = false,
|
|
@@ -614,7 +646,7 @@ var ArrayField = class extends Component {
|
|
|
614
646
|
Widget,
|
|
615
647
|
{
|
|
616
648
|
options,
|
|
617
|
-
id:
|
|
649
|
+
id: fieldPathId.$id,
|
|
618
650
|
name,
|
|
619
651
|
multiple: true,
|
|
620
652
|
onChange: this.onSelectChange,
|
|
@@ -641,11 +673,9 @@ var ArrayField = class extends Component {
|
|
|
641
673
|
const {
|
|
642
674
|
schema,
|
|
643
675
|
uiSchema = {},
|
|
644
|
-
formData
|
|
676
|
+
formData,
|
|
645
677
|
errorSchema,
|
|
646
|
-
|
|
647
|
-
idSeparator = "_",
|
|
648
|
-
idSchema,
|
|
678
|
+
fieldPathId,
|
|
649
679
|
name,
|
|
650
680
|
title,
|
|
651
681
|
disabled = false,
|
|
@@ -657,35 +687,48 @@ var ArrayField = class extends Component {
|
|
|
657
687
|
onFocus,
|
|
658
688
|
rawErrors
|
|
659
689
|
} = this.props;
|
|
660
|
-
const { keyedFormData } = this.state;
|
|
661
690
|
let { formData: items = [] } = this.props;
|
|
691
|
+
const { keyedFormData } = this.state;
|
|
662
692
|
const fieldTitle = schema.title || title || name;
|
|
663
693
|
const uiOptions = getUiOptions(uiSchema);
|
|
664
|
-
const { schemaUtils, formContext } = registry;
|
|
694
|
+
const { schemaUtils, fields: fields2, formContext, globalFormOptions } = registry;
|
|
695
|
+
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
696
|
+
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
697
|
+
const hasFormData = isFormDataAvailable(formData);
|
|
665
698
|
const _schemaItems = isObject(schema.items) ? schema.items : [];
|
|
666
699
|
const itemSchemas = _schemaItems.map(
|
|
667
|
-
(item, index) => schemaUtils.retrieveSchema(item,
|
|
700
|
+
(item, index) => schemaUtils.retrieveSchema(item, items[index])
|
|
668
701
|
);
|
|
669
702
|
const additionalSchema = isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, formData) : null;
|
|
670
|
-
if (
|
|
671
|
-
items = items || [];
|
|
703
|
+
if (items.length < itemSchemas.length) {
|
|
672
704
|
items = items.concat(new Array(itemSchemas.length - items.length));
|
|
673
705
|
}
|
|
674
|
-
const
|
|
706
|
+
const actualFormData = hasFormData ? keyedFormData : [];
|
|
707
|
+
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
708
|
+
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsx(OptionalDataControlsField2, { ...this.props }) : void 0;
|
|
709
|
+
const canAdd = this.canAddItem(items) && !!additionalSchema && (!renderOptionalField || hasFormData);
|
|
675
710
|
const arrayProps = {
|
|
676
711
|
canAdd,
|
|
677
|
-
className:
|
|
712
|
+
className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
|
|
678
713
|
disabled,
|
|
679
|
-
|
|
714
|
+
fieldPathId,
|
|
680
715
|
formData,
|
|
681
|
-
items:
|
|
716
|
+
items: actualFormData.map((keyedItem, index) => {
|
|
682
717
|
const { key, item } = keyedItem;
|
|
683
718
|
const itemCast = item;
|
|
684
719
|
const additional = index >= itemSchemas.length;
|
|
685
720
|
const itemSchema = (additional && isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, itemCast) : itemSchemas[index]) || {};
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
721
|
+
const itemFieldPathId = toFieldPathId(index, globalFormOptions, fieldPathId);
|
|
722
|
+
let itemUiSchema;
|
|
723
|
+
if (additional) {
|
|
724
|
+
itemUiSchema = uiSchema.additionalItems;
|
|
725
|
+
} else {
|
|
726
|
+
if (Array.isArray(uiSchema.items)) {
|
|
727
|
+
itemUiSchema = uiSchema.items[index];
|
|
728
|
+
} else {
|
|
729
|
+
itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
689
732
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
690
733
|
return this.renderArrayFieldItem({
|
|
691
734
|
key,
|
|
@@ -699,7 +742,7 @@ var ArrayField = class extends Component {
|
|
|
699
742
|
itemSchema,
|
|
700
743
|
itemData: itemCast,
|
|
701
744
|
itemUiSchema,
|
|
702
|
-
|
|
745
|
+
itemFieldPathId,
|
|
703
746
|
itemErrorSchema,
|
|
704
747
|
autofocus: autofocus && index === 0,
|
|
705
748
|
onBlur,
|
|
@@ -715,9 +758,9 @@ var ArrayField = class extends Component {
|
|
|
715
758
|
schema,
|
|
716
759
|
uiSchema,
|
|
717
760
|
title: fieldTitle,
|
|
718
|
-
formContext,
|
|
719
761
|
errorSchema,
|
|
720
|
-
rawErrors
|
|
762
|
+
rawErrors,
|
|
763
|
+
optionalDataControl
|
|
721
764
|
};
|
|
722
765
|
const Template = getTemplate("ArrayFieldTemplate", registry, uiOptions);
|
|
723
766
|
return /* @__PURE__ */ jsx(Template, { ...arrayProps });
|
|
@@ -739,7 +782,7 @@ var ArrayField = class extends Component {
|
|
|
739
782
|
itemSchema,
|
|
740
783
|
itemData,
|
|
741
784
|
itemUiSchema,
|
|
742
|
-
|
|
785
|
+
itemFieldPathId,
|
|
743
786
|
itemErrorSchema,
|
|
744
787
|
autofocus,
|
|
745
788
|
onBlur,
|
|
@@ -748,7 +791,7 @@ var ArrayField = class extends Component {
|
|
|
748
791
|
totalItems,
|
|
749
792
|
title
|
|
750
793
|
} = props;
|
|
751
|
-
const { disabled, hideError,
|
|
794
|
+
const { disabled, hideError, readonly, uiSchema, registry, formContext } = this.props;
|
|
752
795
|
const {
|
|
753
796
|
fields: { ArraySchemaField, SchemaField: SchemaField2 },
|
|
754
797
|
globalUiOptions
|
|
@@ -775,9 +818,7 @@ var ArrayField = class extends Component {
|
|
|
775
818
|
formData: itemData,
|
|
776
819
|
formContext,
|
|
777
820
|
errorSchema: itemErrorSchema,
|
|
778
|
-
|
|
779
|
-
idSeparator,
|
|
780
|
-
idSchema: itemIdSchema,
|
|
821
|
+
fieldPathId: itemFieldPathId,
|
|
781
822
|
required: this.isItemRequired(itemSchema),
|
|
782
823
|
onChange: this.onChangeForIndex(index),
|
|
783
824
|
onBlur,
|
|
@@ -791,7 +832,7 @@ var ArrayField = class extends Component {
|
|
|
791
832
|
}
|
|
792
833
|
),
|
|
793
834
|
buttonsProps: {
|
|
794
|
-
|
|
835
|
+
fieldPathId: itemFieldPathId,
|
|
795
836
|
disabled,
|
|
796
837
|
readonly,
|
|
797
838
|
canAdd,
|
|
@@ -825,6 +866,7 @@ var ArrayField = class extends Component {
|
|
|
825
866
|
var ArrayField_default = ArrayField;
|
|
826
867
|
|
|
827
868
|
// src/components/fields/BooleanField.tsx
|
|
869
|
+
import { useCallback } from "react";
|
|
828
870
|
import {
|
|
829
871
|
getWidget as getWidget2,
|
|
830
872
|
getUiOptions as getUiOptions2,
|
|
@@ -838,7 +880,7 @@ function BooleanField(props) {
|
|
|
838
880
|
schema,
|
|
839
881
|
name,
|
|
840
882
|
uiSchema,
|
|
841
|
-
|
|
883
|
+
fieldPathId,
|
|
842
884
|
formData,
|
|
843
885
|
registry,
|
|
844
886
|
required,
|
|
@@ -900,15 +942,21 @@ function BooleanField(props) {
|
|
|
900
942
|
enumOptions = optionsList2({ enum: enums }, uiSchema);
|
|
901
943
|
}
|
|
902
944
|
}
|
|
945
|
+
const onWidgetChange = useCallback(
|
|
946
|
+
(value, errorSchema, id) => {
|
|
947
|
+
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
948
|
+
},
|
|
949
|
+
[onChange, fieldPathId]
|
|
950
|
+
);
|
|
903
951
|
return /* @__PURE__ */ jsx2(
|
|
904
952
|
Widget,
|
|
905
953
|
{
|
|
906
954
|
options: { ...options, enumOptions },
|
|
907
955
|
schema,
|
|
908
956
|
uiSchema,
|
|
909
|
-
id:
|
|
957
|
+
id: fieldPathId.$id,
|
|
910
958
|
name,
|
|
911
|
-
onChange,
|
|
959
|
+
onChange: onWidgetChange,
|
|
912
960
|
onFocus,
|
|
913
961
|
onBlur,
|
|
914
962
|
label,
|
|
@@ -938,13 +986,14 @@ import {
|
|
|
938
986
|
hashObject,
|
|
939
987
|
ID_KEY,
|
|
940
988
|
lookupFromFormContext,
|
|
941
|
-
mergeObjects,
|
|
942
989
|
ONE_OF_KEY,
|
|
943
990
|
PROPERTIES_KEY,
|
|
944
991
|
READONLY_KEY,
|
|
945
|
-
|
|
992
|
+
toFieldPathId as toFieldPathId2,
|
|
993
|
+
UI_OPTIONS_KEY,
|
|
994
|
+
UI_GLOBAL_OPTIONS_KEY,
|
|
995
|
+
ITEMS_KEY as ITEMS_KEY2
|
|
946
996
|
} from "@rjsf/utils";
|
|
947
|
-
import cloneDeep2 from "lodash/cloneDeep";
|
|
948
997
|
import each from "lodash/each";
|
|
949
998
|
import flatten from "lodash/flatten";
|
|
950
999
|
import get2 from "lodash/get";
|
|
@@ -958,16 +1007,19 @@ import isObject3 from "lodash/isObject";
|
|
|
958
1007
|
import isPlainObject from "lodash/isPlainObject";
|
|
959
1008
|
import isString from "lodash/isString";
|
|
960
1009
|
import isUndefined from "lodash/isUndefined";
|
|
1010
|
+
import last from "lodash/last";
|
|
961
1011
|
import set2 from "lodash/set";
|
|
962
1012
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
963
1013
|
import { createElement } from "react";
|
|
964
1014
|
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
965
1015
|
var LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
966
1016
|
var LAYOUT_GRID_OPTION = `ui:${LAYOUT_GRID_UI_OPTION}`;
|
|
967
|
-
var UI_GLOBAL_OPTIONS = "ui:global_options";
|
|
968
1017
|
function getNonNullishValue(value, fallback) {
|
|
969
1018
|
return value ?? fallback;
|
|
970
1019
|
}
|
|
1020
|
+
function isNumericIndex(str) {
|
|
1021
|
+
return /^\d+?$/.test(str);
|
|
1022
|
+
}
|
|
971
1023
|
var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
972
1024
|
static defaultProps = {
|
|
973
1025
|
layoutGridSchema: void 0
|
|
@@ -987,7 +1039,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
987
1039
|
* @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
|
|
988
1040
|
*/
|
|
989
1041
|
static computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
990
|
-
const globalUiOptions = get2(uiSchema, [
|
|
1042
|
+
const globalUiOptions = get2(uiSchema, [UI_GLOBAL_OPTIONS_KEY], {});
|
|
991
1043
|
const localUiSchema = get2(uiSchema, field);
|
|
992
1044
|
const localUiOptions = { ...get2(localUiSchema, [UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
|
|
993
1045
|
const fieldUiSchema = { ...localUiSchema };
|
|
@@ -995,7 +1047,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
995
1047
|
set2(fieldUiSchema, [UI_OPTIONS_KEY], localUiOptions);
|
|
996
1048
|
}
|
|
997
1049
|
if (!isEmpty(globalUiOptions)) {
|
|
998
|
-
set2(fieldUiSchema, [
|
|
1050
|
+
set2(fieldUiSchema, [UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
|
|
999
1051
|
}
|
|
1000
1052
|
let { readonly: uiReadonly } = getUiOptions3(fieldUiSchema);
|
|
1001
1053
|
if (forceReadonly === true || isUndefined(uiReadonly) && schemaReadonly === true) {
|
|
@@ -1067,60 +1119,74 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1067
1119
|
}
|
|
1068
1120
|
return { children, gridProps };
|
|
1069
1121
|
}
|
|
1070
|
-
/**
|
|
1071
|
-
*
|
|
1122
|
+
/** Computes the `rawSchema` and `fieldPathId` for a `schema` and a `potentialIndex`. If the `schema` is of type array,
|
|
1123
|
+
* has an `ITEMS_KEY` element and `potentialIndex` represents a numeric value, the element at `ITEMS_KEY` is checked
|
|
1124
|
+
* to see if it is an array. If it is AND the `potentialIndex`th element is available, it is used as the `rawSchema`,
|
|
1125
|
+
* otherwise the last value of the element is used. If it is not, then the element is used as the `rawSchema`. In
|
|
1126
|
+
* either case, an `fieldPathId` is computed for the array index. If the `schema` does not represent an array or the
|
|
1127
|
+
* `potentialIndex` is not a numeric value, then `rawSchema` is returned as undefined and given `fieldPathId` is returned
|
|
1128
|
+
* as is.
|
|
1072
1129
|
*
|
|
1073
|
-
* @param
|
|
1074
|
-
* @param
|
|
1075
|
-
* @param
|
|
1076
|
-
* @
|
|
1077
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1078
|
-
* @returns - The generated `idSchema` for the `schema`
|
|
1130
|
+
* @param schema - The schema to generate the fieldPathId for
|
|
1131
|
+
* @param fieldPathId - The FieldPathId for the schema
|
|
1132
|
+
* @param potentialIndex - A string containing a potential index
|
|
1133
|
+
* @returns - An object containing the `rawSchema` and `fieldPathId` of an array item, otherwise an undefined `rawSchema`
|
|
1079
1134
|
*/
|
|
1080
|
-
static
|
|
1081
|
-
|
|
1082
|
-
|
|
1135
|
+
static computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1136
|
+
let rawSchema;
|
|
1137
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, ITEMS_KEY2)) {
|
|
1138
|
+
const index = Number(potentialIndex);
|
|
1139
|
+
const items = schema[ITEMS_KEY2];
|
|
1140
|
+
if (Array.isArray(items)) {
|
|
1141
|
+
if (index > items.length) {
|
|
1142
|
+
rawSchema = last(items);
|
|
1143
|
+
} else {
|
|
1144
|
+
rawSchema = items[index];
|
|
1145
|
+
}
|
|
1146
|
+
} else {
|
|
1147
|
+
rawSchema = items;
|
|
1148
|
+
}
|
|
1149
|
+
fieldPathId = {
|
|
1150
|
+
[ID_KEY]: fieldPathId[ID_KEY],
|
|
1151
|
+
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
return { rawSchema, fieldPathId };
|
|
1083
1155
|
}
|
|
1084
1156
|
/** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
|
|
1085
1157
|
* the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
|
|
1086
1158
|
* element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
|
|
1087
1159
|
* `options`.
|
|
1088
1160
|
*
|
|
1089
|
-
* @param
|
|
1161
|
+
* @param registry - The registry
|
|
1090
1162
|
* @param dottedPath - The dotted-path to the field for which to get the schema
|
|
1091
1163
|
* @param initialSchema - The initial schema to start the search from
|
|
1092
1164
|
* @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
|
|
1093
|
-
* @param
|
|
1094
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1165
|
+
* @param initialFieldIdPath - The initial fieldPathId to start the search from
|
|
1095
1166
|
* @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
|
|
1096
1167
|
* info if a oneOf/anyOf
|
|
1097
1168
|
*/
|
|
1098
|
-
static getSchemaDetailsForField(
|
|
1169
|
+
static getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
1170
|
+
const { schemaUtils, globalFormOptions } = registry;
|
|
1099
1171
|
let rawSchema = initialSchema;
|
|
1100
|
-
let
|
|
1172
|
+
let fieldPathId = initialFieldIdPath;
|
|
1101
1173
|
const parts = dottedPath.split(".");
|
|
1102
1174
|
const leafPath = parts.pop();
|
|
1103
1175
|
let schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1104
1176
|
let innerData = formData;
|
|
1105
1177
|
let isReadonly = schema.readOnly;
|
|
1106
1178
|
parts.forEach((part) => {
|
|
1179
|
+
fieldPathId = toFieldPathId2(part, globalFormOptions, fieldPathId);
|
|
1107
1180
|
if (has(schema, PROPERTIES_KEY)) {
|
|
1108
1181
|
rawSchema = get2(schema, [PROPERTIES_KEY, part], {});
|
|
1109
|
-
idSchema = get2(idSchema, part, {});
|
|
1110
1182
|
} else if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
1111
1183
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
1112
1184
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
1113
|
-
const selectedIdSchema = _LayoutGridField.getIdSchema(
|
|
1114
|
-
schemaUtils,
|
|
1115
|
-
idSchema,
|
|
1116
|
-
formData,
|
|
1117
|
-
selectedSchema,
|
|
1118
|
-
idSeparator
|
|
1119
|
-
);
|
|
1120
1185
|
rawSchema = get2(selectedSchema, [PROPERTIES_KEY, part], {});
|
|
1121
|
-
idSchema = get2(selectedIdSchema, part, {});
|
|
1122
1186
|
} else {
|
|
1123
|
-
|
|
1187
|
+
const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, part);
|
|
1188
|
+
rawSchema = result.rawSchema ?? {};
|
|
1189
|
+
fieldPathId = result.fieldPathId;
|
|
1124
1190
|
}
|
|
1125
1191
|
innerData = get2(innerData, part, {});
|
|
1126
1192
|
schema = schemaUtils.retrieveSchema(rawSchema, innerData);
|
|
@@ -1135,13 +1201,17 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1135
1201
|
if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
1136
1202
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
1137
1203
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
1138
|
-
const rawIdSchema = _LayoutGridField.getIdSchema(schemaUtils, idSchema, formData, schema, idSeparator);
|
|
1139
|
-
idSchema = mergeObjects(rawIdSchema, idSchema);
|
|
1140
1204
|
}
|
|
1205
|
+
fieldPathId = toFieldPathId2(leafPath, globalFormOptions, fieldPathId);
|
|
1141
1206
|
isRequired = schema !== void 0 && Array.isArray(schema.required) && includes(schema.required, leafPath);
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1207
|
+
const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
|
|
1208
|
+
if (result.rawSchema) {
|
|
1209
|
+
schema = result.rawSchema;
|
|
1210
|
+
fieldPathId = result.fieldPathId;
|
|
1211
|
+
} else {
|
|
1212
|
+
schema = get2(schema, [PROPERTIES_KEY, leafPath]);
|
|
1213
|
+
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
1214
|
+
}
|
|
1145
1215
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
1146
1216
|
if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
1147
1217
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
@@ -1149,7 +1219,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1149
1219
|
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
1150
1220
|
}
|
|
1151
1221
|
}
|
|
1152
|
-
return { schema, isRequired, isReadonly, optionsInfo,
|
|
1222
|
+
return { schema, isRequired, isReadonly, optionsInfo, fieldPathId };
|
|
1153
1223
|
}
|
|
1154
1224
|
/** Gets the custom render component from the `render`, by either determining that it is either already a function or
|
|
1155
1225
|
* it is a non-function value that can be used to look up the function in the registry. If no function can be found,
|
|
@@ -1185,7 +1255,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1185
1255
|
if (isString(gridSchema) || isUndefined(gridSchema)) {
|
|
1186
1256
|
name = gridSchema ?? "";
|
|
1187
1257
|
} else {
|
|
1188
|
-
const { name: innerName, render, ...innerProps } = gridSchema;
|
|
1258
|
+
const { name: innerName = "", render, ...innerProps } = gridSchema;
|
|
1189
1259
|
name = innerName;
|
|
1190
1260
|
uiProps = innerProps;
|
|
1191
1261
|
if (!isEmpty(uiProps)) {
|
|
@@ -1218,19 +1288,12 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1218
1288
|
* elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
|
|
1219
1289
|
*
|
|
1220
1290
|
* @param dottedPath - The dotted-path to the field for which to generate the onChange handler
|
|
1221
|
-
* @returns - The `onChange` handling function for the `dottedPath` field
|
|
1291
|
+
* @returns - The `onChange` handling function for the `dottedPath` field of the `schemaType` type
|
|
1222
1292
|
*/
|
|
1223
1293
|
onFieldChange = (dottedPath) => {
|
|
1224
|
-
return (value, errSchema, id) => {
|
|
1225
|
-
const { onChange
|
|
1226
|
-
|
|
1227
|
-
let newErrorSchema = errorSchema;
|
|
1228
|
-
if (errSchema && errorSchema) {
|
|
1229
|
-
newErrorSchema = cloneDeep2(errorSchema);
|
|
1230
|
-
set2(newErrorSchema, dottedPath, errSchema);
|
|
1231
|
-
}
|
|
1232
|
-
set2(newFormData, dottedPath, value);
|
|
1233
|
-
onChange(newFormData, newErrorSchema, id);
|
|
1294
|
+
return (value, path, errSchema, id) => {
|
|
1295
|
+
const { onChange } = this.props;
|
|
1296
|
+
onChange(value, path, errSchema, id);
|
|
1234
1297
|
};
|
|
1235
1298
|
};
|
|
1236
1299
|
/** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
|
|
@@ -1318,20 +1381,20 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1318
1381
|
const GridTemplate2 = getTemplate2("GridTemplate", registry, uiOptions);
|
|
1319
1382
|
return /* @__PURE__ */ jsx3(GridTemplate2, { ...gridProps, "data-testid": _LayoutGridField.TEST_IDS.row, children: this.renderChildren(children) });
|
|
1320
1383
|
}
|
|
1321
|
-
/** Iterates through all the `
|
|
1384
|
+
/** Iterates through all the `childrenLayoutGrfieldPathId`, rendering a nested `LayoutGridField` for each item in the
|
|
1322
1385
|
* list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
|
|
1323
1386
|
* `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
|
|
1324
|
-
* `
|
|
1387
|
+
* `childrenLayoutGrfieldPathId` is passed as `layoutGridSchema`.
|
|
1325
1388
|
*
|
|
1326
|
-
* @param
|
|
1389
|
+
* @param childrenLayoutGrfieldPathId - The list of strings or objects that represents the configurations for the
|
|
1327
1390
|
* children fields
|
|
1328
1391
|
* @returns - The nested `LayoutGridField`s
|
|
1329
1392
|
*/
|
|
1330
|
-
renderChildren(
|
|
1393
|
+
renderChildren(childrenLayoutGrfieldPathId) {
|
|
1331
1394
|
const { registry, schema: rawSchema, formData } = this.props;
|
|
1332
1395
|
const { schemaUtils } = registry;
|
|
1333
1396
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1334
|
-
return
|
|
1397
|
+
return childrenLayoutGrfieldPathId.map((layoutGridSchema) => /* @__PURE__ */ createElement(
|
|
1335
1398
|
_LayoutGridField,
|
|
1336
1399
|
{
|
|
1337
1400
|
...this.props,
|
|
@@ -1347,7 +1410,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1347
1410
|
* specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
|
|
1348
1411
|
* and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
|
|
1349
1412
|
* schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
|
|
1350
|
-
* `uiSchema`, `errorSchema`, `
|
|
1413
|
+
* `uiSchema`, `errorSchema`, `fieldPathId` and `formData` drilled down to the dotted-path field, spreading any other
|
|
1351
1414
|
* props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
|
|
1352
1415
|
* then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
|
|
1353
1416
|
* schema was located, but a custom render component was found, then it will be rendered with many of the non-event
|
|
@@ -1361,18 +1424,17 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1361
1424
|
schema: initialSchema,
|
|
1362
1425
|
uiSchema,
|
|
1363
1426
|
errorSchema,
|
|
1364
|
-
|
|
1427
|
+
fieldPathId,
|
|
1365
1428
|
onBlur,
|
|
1366
1429
|
onFocus,
|
|
1367
1430
|
formData,
|
|
1368
1431
|
readonly,
|
|
1369
1432
|
registry,
|
|
1370
|
-
idSeparator,
|
|
1371
1433
|
layoutGridSchema,
|
|
1372
1434
|
// Used to pull this out of otherProps since we don't want to pass it through
|
|
1373
1435
|
...otherProps
|
|
1374
1436
|
} = this.props;
|
|
1375
|
-
const { fields: fields2
|
|
1437
|
+
const { fields: fields2 } = registry;
|
|
1376
1438
|
const { SchemaField: SchemaField2, LayoutMultiSchemaField: LayoutMultiSchemaField2 } = fields2;
|
|
1377
1439
|
const uiComponentProps = _LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema);
|
|
1378
1440
|
if (uiComponentProps.rendered) {
|
|
@@ -1384,15 +1446,8 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1384
1446
|
isRequired,
|
|
1385
1447
|
isReadonly,
|
|
1386
1448
|
optionsInfo,
|
|
1387
|
-
|
|
1388
|
-
} = _LayoutGridField.getSchemaDetailsForField(
|
|
1389
|
-
schemaUtils,
|
|
1390
|
-
name,
|
|
1391
|
-
initialSchema,
|
|
1392
|
-
formData,
|
|
1393
|
-
idSchema,
|
|
1394
|
-
idSeparator
|
|
1395
|
-
);
|
|
1449
|
+
fieldPathId: fieldIdSchema
|
|
1450
|
+
} = _LayoutGridField.getSchemaDetailsForField(registry, name, initialSchema, formData, fieldPathId);
|
|
1396
1451
|
if (schema) {
|
|
1397
1452
|
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1398
1453
|
const { fieldUiSchema, uiReadonly } = _LayoutGridField.computeFieldUiSchema(
|
|
@@ -1413,8 +1468,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1413
1468
|
schema,
|
|
1414
1469
|
uiSchema: fieldUiSchema,
|
|
1415
1470
|
errorSchema: get2(errorSchema, name),
|
|
1416
|
-
|
|
1417
|
-
idSeparator,
|
|
1471
|
+
fieldPathId: fieldIdSchema,
|
|
1418
1472
|
formData: get2(formData, name),
|
|
1419
1473
|
onChange: this.onFieldChange(name),
|
|
1420
1474
|
onBlur,
|
|
@@ -1437,8 +1491,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1437
1491
|
errorSchema,
|
|
1438
1492
|
uiSchema,
|
|
1439
1493
|
schema: initialSchema,
|
|
1440
|
-
|
|
1441
|
-
idSeparator,
|
|
1494
|
+
fieldPathId,
|
|
1442
1495
|
onBlur,
|
|
1443
1496
|
onFocus,
|
|
1444
1497
|
registry,
|
|
@@ -1488,7 +1541,7 @@ import {
|
|
|
1488
1541
|
} from "@rjsf/utils";
|
|
1489
1542
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1490
1543
|
function LayoutHeaderField(props) {
|
|
1491
|
-
const {
|
|
1544
|
+
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
1492
1545
|
const options = getUiOptions4(uiSchema, registry.globalUiOptions);
|
|
1493
1546
|
const { title: uiTitle } = options;
|
|
1494
1547
|
const { title: schemaTitle } = schema;
|
|
@@ -1504,7 +1557,7 @@ function LayoutHeaderField(props) {
|
|
|
1504
1557
|
return /* @__PURE__ */ jsx4(
|
|
1505
1558
|
TitleFieldTemplate,
|
|
1506
1559
|
{
|
|
1507
|
-
id: titleId(
|
|
1560
|
+
id: titleId(fieldPathId),
|
|
1508
1561
|
title: fieldTitle,
|
|
1509
1562
|
required,
|
|
1510
1563
|
schema,
|
|
@@ -1567,7 +1620,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1567
1620
|
baseType,
|
|
1568
1621
|
disabled = false,
|
|
1569
1622
|
formData,
|
|
1570
|
-
|
|
1623
|
+
fieldPathId,
|
|
1571
1624
|
onBlur,
|
|
1572
1625
|
onChange,
|
|
1573
1626
|
options,
|
|
@@ -1584,7 +1637,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1584
1637
|
} = props;
|
|
1585
1638
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1586
1639
|
const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1587
|
-
const id = get3(
|
|
1640
|
+
const id = get3(fieldPathId, ID_KEY2);
|
|
1588
1641
|
const discriminator = getDiscriminatorFieldFromSchema2(schema);
|
|
1589
1642
|
const FieldErrorTemplate2 = getTemplate4("FieldErrorTemplate", registry, options);
|
|
1590
1643
|
const FieldTemplate2 = getTemplate4("FieldTemplate", registry, options);
|
|
@@ -1625,10 +1678,10 @@ function LayoutMultiSchemaField(props) {
|
|
|
1625
1678
|
if (newFormData) {
|
|
1626
1679
|
set3(newFormData, selectorField, opt);
|
|
1627
1680
|
}
|
|
1628
|
-
onChange(newFormData, void 0, id);
|
|
1681
|
+
onChange(newFormData, fieldPathId.path, void 0, id);
|
|
1629
1682
|
};
|
|
1630
1683
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
1631
|
-
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ jsx5(FieldErrorTemplate2, {
|
|
1684
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ jsx5(FieldErrorTemplate2, { fieldPathId, schema, errors: rawErrors, registry }) : void 0;
|
|
1632
1685
|
const ignored = (value) => noop;
|
|
1633
1686
|
return /* @__PURE__ */ jsx5(
|
|
1634
1687
|
FieldTemplate2,
|
|
@@ -1638,7 +1691,6 @@ function LayoutMultiSchemaField(props) {
|
|
|
1638
1691
|
label: (title || schema.title) ?? "",
|
|
1639
1692
|
disabled: disabled || Array.isArray(enumOptions) && isEmpty2(enumOptions),
|
|
1640
1693
|
uiSchema,
|
|
1641
|
-
formContext,
|
|
1642
1694
|
required,
|
|
1643
1695
|
readonly: !!readonly,
|
|
1644
1696
|
registry,
|
|
@@ -1688,13 +1740,14 @@ import {
|
|
|
1688
1740
|
deepEquals,
|
|
1689
1741
|
ERRORS_KEY as ERRORS_KEY2,
|
|
1690
1742
|
getDiscriminatorFieldFromSchema as getDiscriminatorFieldFromSchema3,
|
|
1743
|
+
getTemplate as getTemplate5,
|
|
1691
1744
|
getUiOptions as getUiOptions6,
|
|
1692
1745
|
getWidget as getWidget4,
|
|
1693
1746
|
mergeSchemas,
|
|
1694
1747
|
ONE_OF_KEY as ONE_OF_KEY3,
|
|
1695
1748
|
TranslatableString as TranslatableString3
|
|
1696
1749
|
} from "@rjsf/utils";
|
|
1697
|
-
import { jsx as jsx6
|
|
1750
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1698
1751
|
var AnyOfField = class extends Component2 {
|
|
1699
1752
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1700
1753
|
*
|
|
@@ -1720,7 +1773,7 @@ var AnyOfField = class extends Component2 {
|
|
|
1720
1773
|
* @param prevState - The previous `AnyOfFieldState` for this template
|
|
1721
1774
|
*/
|
|
1722
1775
|
componentDidUpdate(prevProps, prevState) {
|
|
1723
|
-
const { formData, options,
|
|
1776
|
+
const { formData, options, fieldPathId } = this.props;
|
|
1724
1777
|
const { selectedOption } = this.state;
|
|
1725
1778
|
let newState = this.state;
|
|
1726
1779
|
if (!deepEquals(prevProps.options, options)) {
|
|
@@ -1730,7 +1783,7 @@ var AnyOfField = class extends Component2 {
|
|
|
1730
1783
|
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1731
1784
|
newState = { selectedOption, retrievedOptions };
|
|
1732
1785
|
}
|
|
1733
|
-
if (!deepEquals(formData, prevProps.formData) &&
|
|
1786
|
+
if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
1734
1787
|
const { retrievedOptions } = newState;
|
|
1735
1788
|
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
1736
1789
|
if (prevState && matchingOption !== selectedOption) {
|
|
@@ -1764,7 +1817,7 @@ var AnyOfField = class extends Component2 {
|
|
|
1764
1817
|
*/
|
|
1765
1818
|
onOptionChange = (option) => {
|
|
1766
1819
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1767
|
-
const { formData, onChange, registry } = this.props;
|
|
1820
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
1768
1821
|
const { schemaUtils } = registry;
|
|
1769
1822
|
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1770
1823
|
if (intOption === selectedOption) {
|
|
@@ -1777,12 +1830,12 @@ var AnyOfField = class extends Component2 {
|
|
|
1777
1830
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1778
1831
|
}
|
|
1779
1832
|
this.setState({ selectedOption: intOption }, () => {
|
|
1780
|
-
onChange(newFormData, void 0, this.getFieldId());
|
|
1833
|
+
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1781
1834
|
});
|
|
1782
1835
|
};
|
|
1783
1836
|
getFieldId() {
|
|
1784
|
-
const {
|
|
1785
|
-
return `${
|
|
1837
|
+
const { fieldPathId, schema } = this.props;
|
|
1838
|
+
return `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1786
1839
|
}
|
|
1787
1840
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1788
1841
|
*/
|
|
@@ -1801,6 +1854,11 @@ var AnyOfField = class extends Component2 {
|
|
|
1801
1854
|
} = this.props;
|
|
1802
1855
|
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1803
1856
|
const { SchemaField: _SchemaField } = fields2;
|
|
1857
|
+
const MultiSchemaFieldTemplate2 = getTemplate5(
|
|
1858
|
+
"MultiSchemaFieldTemplate",
|
|
1859
|
+
registry,
|
|
1860
|
+
globalUiOptions
|
|
1861
|
+
);
|
|
1804
1862
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1805
1863
|
const {
|
|
1806
1864
|
widget = "select",
|
|
@@ -1847,41 +1905,51 @@ var AnyOfField = class extends Component2 {
|
|
|
1847
1905
|
value: index
|
|
1848
1906
|
};
|
|
1849
1907
|
});
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1908
|
+
const selector = /* @__PURE__ */ jsx6(
|
|
1909
|
+
Widget,
|
|
1910
|
+
{
|
|
1911
|
+
id: this.getFieldId(),
|
|
1912
|
+
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1913
|
+
schema: { type: "number", default: 0 },
|
|
1914
|
+
onChange: this.onOptionChange,
|
|
1915
|
+
onBlur,
|
|
1916
|
+
onFocus,
|
|
1917
|
+
disabled: disabled || isEmpty3(enumOptions),
|
|
1918
|
+
multiple: false,
|
|
1919
|
+
rawErrors,
|
|
1920
|
+
errorSchema: fieldErrorSchema,
|
|
1921
|
+
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1922
|
+
options: { enumOptions, ...uiOptions },
|
|
1923
|
+
registry,
|
|
1924
|
+
formContext,
|
|
1925
|
+
placeholder,
|
|
1926
|
+
autocomplete,
|
|
1927
|
+
autofocus,
|
|
1928
|
+
label: title ?? name,
|
|
1929
|
+
hideLabel: !displayLabel,
|
|
1930
|
+
readonly
|
|
1931
|
+
}
|
|
1932
|
+
);
|
|
1933
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsx6(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1934
|
+
return /* @__PURE__ */ jsx6(
|
|
1935
|
+
MultiSchemaFieldTemplate2,
|
|
1936
|
+
{
|
|
1937
|
+
schema,
|
|
1938
|
+
registry,
|
|
1939
|
+
uiSchema,
|
|
1940
|
+
selector,
|
|
1941
|
+
optionSchemaField: optionsSchemaField
|
|
1942
|
+
}
|
|
1943
|
+
);
|
|
1878
1944
|
}
|
|
1879
1945
|
};
|
|
1880
1946
|
var MultiSchemaField_default = AnyOfField;
|
|
1881
1947
|
|
|
1882
1948
|
// src/components/fields/NumberField.tsx
|
|
1883
|
-
import { useState as useState2, useCallback } from "react";
|
|
1884
|
-
import {
|
|
1949
|
+
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
1950
|
+
import {
|
|
1951
|
+
asNumber
|
|
1952
|
+
} from "@rjsf/utils";
|
|
1885
1953
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1886
1954
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1887
1955
|
var trailingCharMatcher = /[0.]0*$/;
|
|
@@ -1890,14 +1958,14 @@ function NumberField(props) {
|
|
|
1890
1958
|
const [lastValue, setLastValue] = useState2(initialValue);
|
|
1891
1959
|
const { StringField: StringField2 } = registry.fields;
|
|
1892
1960
|
let value = formData;
|
|
1893
|
-
const handleChange =
|
|
1894
|
-
(value2, errorSchema, id) => {
|
|
1961
|
+
const handleChange = useCallback2(
|
|
1962
|
+
(value2, path, errorSchema, id) => {
|
|
1895
1963
|
setLastValue(value2);
|
|
1896
1964
|
if (`${value2}`.charAt(0) === ".") {
|
|
1897
1965
|
value2 = `0${value2}`;
|
|
1898
1966
|
}
|
|
1899
1967
|
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? asNumber(value2.replace(trailingCharMatcher, "")) : asNumber(value2);
|
|
1900
|
-
onChange(processed, errorSchema, id);
|
|
1968
|
+
onChange(processed, path, errorSchema, id);
|
|
1901
1969
|
},
|
|
1902
1970
|
[onChange]
|
|
1903
1971
|
);
|
|
@@ -1914,15 +1982,18 @@ var NumberField_default = NumberField;
|
|
|
1914
1982
|
// src/components/fields/ObjectField.tsx
|
|
1915
1983
|
import { Component as Component3 } from "react";
|
|
1916
1984
|
import {
|
|
1917
|
-
getTemplate as
|
|
1985
|
+
getTemplate as getTemplate6,
|
|
1918
1986
|
getUiOptions as getUiOptions7,
|
|
1919
1987
|
orderProperties,
|
|
1988
|
+
shouldRenderOptionalField as shouldRenderOptionalField2,
|
|
1989
|
+
toFieldPathId as toFieldPathId3,
|
|
1920
1990
|
TranslatableString as TranslatableString4,
|
|
1921
1991
|
ADDITIONAL_PROPERTY_FLAG,
|
|
1922
1992
|
PROPERTIES_KEY as PROPERTIES_KEY3,
|
|
1923
1993
|
REF_KEY,
|
|
1924
1994
|
ANY_OF_KEY as ANY_OF_KEY4,
|
|
1925
|
-
ONE_OF_KEY as ONE_OF_KEY4
|
|
1995
|
+
ONE_OF_KEY as ONE_OF_KEY4,
|
|
1996
|
+
isFormDataAvailable as isFormDataAvailable2
|
|
1926
1997
|
} from "@rjsf/utils";
|
|
1927
1998
|
import Markdown from "markdown-to-jsx";
|
|
1928
1999
|
import get5 from "lodash/get";
|
|
@@ -1930,7 +2001,7 @@ import has3 from "lodash/has";
|
|
|
1930
2001
|
import isObject4 from "lodash/isObject";
|
|
1931
2002
|
import set4 from "lodash/set";
|
|
1932
2003
|
import unset from "lodash/unset";
|
|
1933
|
-
import { jsx as jsx8, jsxs
|
|
2004
|
+
import { jsx as jsx8, jsxs } from "react/jsx-runtime";
|
|
1934
2005
|
var ObjectField = class extends Component3 {
|
|
1935
2006
|
/** Set up the initial state */
|
|
1936
2007
|
state = {
|
|
@@ -1955,20 +2026,12 @@ var ObjectField = class extends Component3 {
|
|
|
1955
2026
|
* @returns - The onPropertyChange callback for the `name` property
|
|
1956
2027
|
*/
|
|
1957
2028
|
onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
1958
|
-
return (value, newErrorSchema, id) => {
|
|
1959
|
-
const {
|
|
2029
|
+
return (value, path, newErrorSchema, id) => {
|
|
2030
|
+
const { onChange } = this.props;
|
|
1960
2031
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
1961
2032
|
value = "";
|
|
1962
2033
|
}
|
|
1963
|
-
|
|
1964
|
-
onChange(
|
|
1965
|
-
newFormData,
|
|
1966
|
-
errorSchema && errorSchema && {
|
|
1967
|
-
...errorSchema,
|
|
1968
|
-
[name]: newErrorSchema
|
|
1969
|
-
},
|
|
1970
|
-
id
|
|
1971
|
-
);
|
|
2034
|
+
onChange(value, path, newErrorSchema, id);
|
|
1972
2035
|
};
|
|
1973
2036
|
};
|
|
1974
2037
|
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
@@ -1980,10 +2043,10 @@ var ObjectField = class extends Component3 {
|
|
|
1980
2043
|
onDropPropertyClick = (key) => {
|
|
1981
2044
|
return (event) => {
|
|
1982
2045
|
event.preventDefault();
|
|
1983
|
-
const { onChange, formData } = this.props;
|
|
2046
|
+
const { onChange, formData, fieldPathId } = this.props;
|
|
1984
2047
|
const copiedFormData = { ...formData };
|
|
1985
2048
|
unset(copiedFormData, key);
|
|
1986
|
-
onChange(copiedFormData);
|
|
2049
|
+
onChange(copiedFormData, fieldPathId.path);
|
|
1987
2050
|
};
|
|
1988
2051
|
};
|
|
1989
2052
|
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
@@ -2010,11 +2073,11 @@ var ObjectField = class extends Component3 {
|
|
|
2010
2073
|
* @returns - The key change callback function
|
|
2011
2074
|
*/
|
|
2012
2075
|
onKeyChange = (oldValue) => {
|
|
2013
|
-
return (value
|
|
2076
|
+
return (value) => {
|
|
2014
2077
|
if (oldValue === value) {
|
|
2015
2078
|
return;
|
|
2016
2079
|
}
|
|
2017
|
-
const { formData, onChange,
|
|
2080
|
+
const { formData, onChange, fieldPathId } = this.props;
|
|
2018
2081
|
value = this.getAvailableKey(value, formData);
|
|
2019
2082
|
const newFormData = {
|
|
2020
2083
|
...formData
|
|
@@ -2026,13 +2089,7 @@ var ObjectField = class extends Component3 {
|
|
|
2026
2089
|
});
|
|
2027
2090
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
2028
2091
|
this.setState({ wasPropertyKeyModified: true });
|
|
2029
|
-
onChange(
|
|
2030
|
-
renamedObj,
|
|
2031
|
-
errorSchema && errorSchema && {
|
|
2032
|
-
...errorSchema,
|
|
2033
|
-
[value]: newErrorSchema
|
|
2034
|
-
}
|
|
2035
|
-
);
|
|
2092
|
+
onChange(renamedObj, fieldPathId.path);
|
|
2036
2093
|
};
|
|
2037
2094
|
};
|
|
2038
2095
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
@@ -2068,7 +2125,7 @@ var ObjectField = class extends Component3 {
|
|
|
2068
2125
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2069
2126
|
return;
|
|
2070
2127
|
}
|
|
2071
|
-
const { formData, onChange, registry } = this.props;
|
|
2128
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
2072
2129
|
const newFormData = { ...formData };
|
|
2073
2130
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
2074
2131
|
if (schema.patternProperties) {
|
|
@@ -2096,7 +2153,7 @@ var ObjectField = class extends Component3 {
|
|
|
2096
2153
|
const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
|
|
2097
2154
|
set4(newFormData, newKey, newValue);
|
|
2098
2155
|
}
|
|
2099
|
-
onChange(newFormData);
|
|
2156
|
+
onChange(newFormData, fieldPathId.path);
|
|
2100
2157
|
};
|
|
2101
2158
|
/** Renders the `ObjectField` from the given props
|
|
2102
2159
|
*/
|
|
@@ -2106,37 +2163,40 @@ var ObjectField = class extends Component3 {
|
|
|
2106
2163
|
uiSchema = {},
|
|
2107
2164
|
formData,
|
|
2108
2165
|
errorSchema,
|
|
2109
|
-
|
|
2166
|
+
fieldPathId,
|
|
2110
2167
|
name,
|
|
2111
2168
|
required = false,
|
|
2112
2169
|
disabled,
|
|
2113
2170
|
readonly,
|
|
2114
2171
|
hideError,
|
|
2115
|
-
idPrefix,
|
|
2116
|
-
idSeparator,
|
|
2117
2172
|
onBlur,
|
|
2118
2173
|
onFocus,
|
|
2119
2174
|
registry,
|
|
2120
2175
|
title
|
|
2121
2176
|
} = this.props;
|
|
2122
|
-
const { fields: fields2, formContext, schemaUtils, translateString, globalUiOptions } = registry;
|
|
2123
|
-
const { SchemaField: SchemaField2 } = fields2;
|
|
2124
|
-
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
2177
|
+
const { fields: fields2, formContext, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
|
|
2178
|
+
const { OptionalDataControlsField: OptionalDataControlsField2, SchemaField: SchemaField2 } = fields2;
|
|
2179
|
+
const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
|
|
2125
2180
|
const uiOptions = getUiOptions7(uiSchema, globalUiOptions);
|
|
2126
2181
|
const { properties: schemaProperties = {} } = schema;
|
|
2127
2182
|
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
2128
2183
|
const description = uiOptions.description ?? schema.description;
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2184
|
+
const renderOptionalField = shouldRenderOptionalField2(registry, schema, required, uiSchema);
|
|
2185
|
+
const hasFormData = isFormDataAvailable2(formData);
|
|
2186
|
+
let orderedProperties = [];
|
|
2187
|
+
if (!renderOptionalField || hasFormData) {
|
|
2188
|
+
try {
|
|
2189
|
+
const properties = Object.keys(schemaProperties);
|
|
2190
|
+
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
2191
|
+
} catch (err) {
|
|
2192
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2193
|
+
/* @__PURE__ */ jsx8("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx8(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString4.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
2194
|
+
/* @__PURE__ */ jsx8("pre", { children: JSON.stringify(schema) })
|
|
2195
|
+
] });
|
|
2196
|
+
}
|
|
2138
2197
|
}
|
|
2139
|
-
const Template =
|
|
2198
|
+
const Template = getTemplate6("ObjectFieldTemplate", registry, uiOptions);
|
|
2199
|
+
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsx8(OptionalDataControlsField2, { ...this.props, schema }) : void 0;
|
|
2140
2200
|
const templateProps = {
|
|
2141
2201
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
2142
2202
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
@@ -2145,7 +2205,7 @@ var ObjectField = class extends Component3 {
|
|
|
2145
2205
|
const addedByAdditionalProperties = has3(schema, [PROPERTIES_KEY3, name2, ADDITIONAL_PROPERTY_FLAG]);
|
|
2146
2206
|
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
|
|
2147
2207
|
const hidden = getUiOptions7(fieldUiSchema).widget === "hidden";
|
|
2148
|
-
const
|
|
2208
|
+
const innerFieldIdPathId = toFieldPathId3(name2, globalFormOptions, fieldPathId);
|
|
2149
2209
|
return {
|
|
2150
2210
|
content: /* @__PURE__ */ jsx8(
|
|
2151
2211
|
SchemaField2,
|
|
@@ -2155,9 +2215,7 @@ var ObjectField = class extends Component3 {
|
|
|
2155
2215
|
schema: get5(schema, [PROPERTIES_KEY3, name2], {}),
|
|
2156
2216
|
uiSchema: fieldUiSchema,
|
|
2157
2217
|
errorSchema: get5(errorSchema, name2),
|
|
2158
|
-
|
|
2159
|
-
idPrefix,
|
|
2160
|
-
idSeparator,
|
|
2218
|
+
fieldPathId: innerFieldIdPathId,
|
|
2161
2219
|
formData: get5(formData, name2),
|
|
2162
2220
|
formContext,
|
|
2163
2221
|
wasPropertyKeyModified: this.state.wasPropertyKeyModified,
|
|
@@ -2183,36 +2241,105 @@ var ObjectField = class extends Component3 {
|
|
|
2183
2241
|
readonly,
|
|
2184
2242
|
disabled,
|
|
2185
2243
|
required,
|
|
2186
|
-
|
|
2244
|
+
fieldPathId,
|
|
2187
2245
|
uiSchema,
|
|
2188
2246
|
errorSchema,
|
|
2189
2247
|
schema,
|
|
2190
2248
|
formData,
|
|
2191
2249
|
formContext,
|
|
2192
|
-
registry
|
|
2250
|
+
registry,
|
|
2251
|
+
optionalDataControl,
|
|
2252
|
+
className: renderOptionalField ? "rjsf-optional-object-field" : void 0
|
|
2193
2253
|
};
|
|
2194
2254
|
return /* @__PURE__ */ jsx8(Template, { ...templateProps, onAddClick: this.handleAddClick });
|
|
2195
2255
|
}
|
|
2196
2256
|
};
|
|
2197
2257
|
var ObjectField_default = ObjectField;
|
|
2198
2258
|
|
|
2259
|
+
// src/components/fields/OptionalDataControlsField.tsx
|
|
2260
|
+
import {
|
|
2261
|
+
getSchemaType,
|
|
2262
|
+
getTemplate as getTemplate7,
|
|
2263
|
+
getUiOptions as getUiOptions8,
|
|
2264
|
+
isFormDataAvailable as isFormDataAvailable3,
|
|
2265
|
+
optionalControlsId,
|
|
2266
|
+
TranslatableString as TranslatableString5
|
|
2267
|
+
} from "@rjsf/utils";
|
|
2268
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
2269
|
+
function OptionalDataControlsField(props) {
|
|
2270
|
+
const {
|
|
2271
|
+
schema,
|
|
2272
|
+
uiSchema = {},
|
|
2273
|
+
formData,
|
|
2274
|
+
disabled = false,
|
|
2275
|
+
readonly = false,
|
|
2276
|
+
onChange,
|
|
2277
|
+
errorSchema,
|
|
2278
|
+
fieldPathId,
|
|
2279
|
+
registry
|
|
2280
|
+
} = props;
|
|
2281
|
+
const { globalUiOptions = {}, schemaUtils, translateString } = registry;
|
|
2282
|
+
const uiOptions = getUiOptions8(uiSchema, globalUiOptions);
|
|
2283
|
+
const OptionalDataControlsTemplate2 = getTemplate7(
|
|
2284
|
+
"OptionalDataControlsTemplate",
|
|
2285
|
+
registry,
|
|
2286
|
+
uiOptions
|
|
2287
|
+
);
|
|
2288
|
+
const hasFormData = isFormDataAvailable3(formData);
|
|
2289
|
+
let id;
|
|
2290
|
+
let label;
|
|
2291
|
+
let onAddClick;
|
|
2292
|
+
let onRemoveClick;
|
|
2293
|
+
if (disabled || readonly) {
|
|
2294
|
+
id = optionalControlsId(fieldPathId, "Msg");
|
|
2295
|
+
label = hasFormData ? void 0 : translateString(TranslatableString5.OptionalObjectEmptyMsg);
|
|
2296
|
+
} else {
|
|
2297
|
+
const labelEnum = hasFormData ? TranslatableString5.OptionalObjectRemove : TranslatableString5.OptionalObjectAdd;
|
|
2298
|
+
label = translateString(labelEnum);
|
|
2299
|
+
if (hasFormData) {
|
|
2300
|
+
id = optionalControlsId(fieldPathId, "Remove");
|
|
2301
|
+
onRemoveClick = () => onChange(void 0, fieldPathId.path, errorSchema);
|
|
2302
|
+
} else {
|
|
2303
|
+
id = optionalControlsId(fieldPathId, "Add");
|
|
2304
|
+
onAddClick = () => {
|
|
2305
|
+
let newFormData = schemaUtils.getDefaultFormState(schema, formData, "excludeObjectChildren");
|
|
2306
|
+
if (newFormData === void 0) {
|
|
2307
|
+
newFormData = getSchemaType(schema) === "array" ? [] : {};
|
|
2308
|
+
}
|
|
2309
|
+
onChange(newFormData, fieldPathId.path, errorSchema);
|
|
2310
|
+
};
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
return label && /* @__PURE__ */ jsx9(
|
|
2314
|
+
OptionalDataControlsTemplate2,
|
|
2315
|
+
{
|
|
2316
|
+
id,
|
|
2317
|
+
registry,
|
|
2318
|
+
schema,
|
|
2319
|
+
uiSchema,
|
|
2320
|
+
label,
|
|
2321
|
+
onAddClick,
|
|
2322
|
+
onRemoveClick
|
|
2323
|
+
}
|
|
2324
|
+
);
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2199
2327
|
// src/components/fields/SchemaField.tsx
|
|
2200
|
-
import { useCallback as
|
|
2328
|
+
import { useCallback as useCallback3, Component as Component4 } from "react";
|
|
2201
2329
|
import {
|
|
2202
2330
|
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG2,
|
|
2203
|
-
deepEquals as deepEquals2,
|
|
2204
2331
|
descriptionId,
|
|
2205
|
-
getSchemaType,
|
|
2206
|
-
getTemplate as
|
|
2207
|
-
getUiOptions as
|
|
2332
|
+
getSchemaType as getSchemaType2,
|
|
2333
|
+
getTemplate as getTemplate8,
|
|
2334
|
+
getUiOptions as getUiOptions9,
|
|
2208
2335
|
ID_KEY as ID_KEY3,
|
|
2209
|
-
|
|
2210
|
-
TranslatableString as
|
|
2336
|
+
shouldRender,
|
|
2337
|
+
TranslatableString as TranslatableString6,
|
|
2211
2338
|
UI_OPTIONS_KEY as UI_OPTIONS_KEY2
|
|
2212
2339
|
} from "@rjsf/utils";
|
|
2213
2340
|
import isObject5 from "lodash/isObject";
|
|
2214
2341
|
import omit3 from "lodash/omit";
|
|
2215
|
-
import { Fragment, jsx as
|
|
2342
|
+
import { Fragment, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2216
2343
|
var COMPONENT_TYPES = {
|
|
2217
2344
|
array: "ArrayField",
|
|
2218
2345
|
boolean: "BooleanField",
|
|
@@ -2222,7 +2349,7 @@ var COMPONENT_TYPES = {
|
|
|
2222
2349
|
string: "StringField",
|
|
2223
2350
|
null: "NullField"
|
|
2224
2351
|
};
|
|
2225
|
-
function getFieldComponent(schema, uiOptions,
|
|
2352
|
+
function getFieldComponent(schema, uiOptions, fieldPathId, registry) {
|
|
2226
2353
|
const field = uiOptions.field;
|
|
2227
2354
|
const { fields: fields2, translateString } = registry;
|
|
2228
2355
|
if (typeof field === "function") {
|
|
@@ -2231,7 +2358,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2231
2358
|
if (typeof field === "string" && field in fields2) {
|
|
2232
2359
|
return fields2[field];
|
|
2233
2360
|
}
|
|
2234
|
-
const schemaType =
|
|
2361
|
+
const schemaType = getSchemaType2(schema);
|
|
2235
2362
|
const type = Array.isArray(schemaType) ? schemaType[0] : schemaType || "";
|
|
2236
2363
|
const schemaId = schema.$id;
|
|
2237
2364
|
let componentName = COMPONENT_TYPES[type];
|
|
@@ -2242,17 +2369,17 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2242
2369
|
return () => null;
|
|
2243
2370
|
}
|
|
2244
2371
|
return componentName in fields2 ? fields2[componentName] : () => {
|
|
2245
|
-
const UnsupportedFieldTemplate =
|
|
2372
|
+
const UnsupportedFieldTemplate = getTemplate8(
|
|
2246
2373
|
"UnsupportedFieldTemplate",
|
|
2247
2374
|
registry,
|
|
2248
2375
|
uiOptions
|
|
2249
2376
|
);
|
|
2250
|
-
return /* @__PURE__ */
|
|
2377
|
+
return /* @__PURE__ */ jsx10(
|
|
2251
2378
|
UnsupportedFieldTemplate,
|
|
2252
2379
|
{
|
|
2253
2380
|
schema,
|
|
2254
|
-
|
|
2255
|
-
reason: translateString(
|
|
2381
|
+
fieldPathId,
|
|
2382
|
+
reason: translateString(TranslatableString6.UnknownFieldType, [String(schema.type)]),
|
|
2256
2383
|
registry
|
|
2257
2384
|
}
|
|
2258
2385
|
);
|
|
@@ -2261,12 +2388,10 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2261
2388
|
function SchemaFieldRender(props) {
|
|
2262
2389
|
const {
|
|
2263
2390
|
schema: _schema,
|
|
2264
|
-
|
|
2391
|
+
fieldPathId,
|
|
2265
2392
|
uiSchema,
|
|
2266
2393
|
formData,
|
|
2267
2394
|
errorSchema,
|
|
2268
|
-
idPrefix,
|
|
2269
|
-
idSeparator,
|
|
2270
2395
|
name,
|
|
2271
2396
|
onChange,
|
|
2272
2397
|
onKeyChange,
|
|
@@ -2276,29 +2401,25 @@ function SchemaFieldRender(props) {
|
|
|
2276
2401
|
wasPropertyKeyModified = false
|
|
2277
2402
|
} = props;
|
|
2278
2403
|
const { formContext, schemaUtils, globalUiOptions } = registry;
|
|
2279
|
-
const uiOptions =
|
|
2280
|
-
const FieldTemplate2 =
|
|
2281
|
-
const DescriptionFieldTemplate =
|
|
2404
|
+
const uiOptions = getUiOptions9(uiSchema, globalUiOptions);
|
|
2405
|
+
const FieldTemplate2 = getTemplate8("FieldTemplate", registry, uiOptions);
|
|
2406
|
+
const DescriptionFieldTemplate = getTemplate8(
|
|
2282
2407
|
"DescriptionFieldTemplate",
|
|
2283
2408
|
registry,
|
|
2284
2409
|
uiOptions
|
|
2285
2410
|
);
|
|
2286
|
-
const FieldHelpTemplate2 =
|
|
2287
|
-
const FieldErrorTemplate2 =
|
|
2411
|
+
const FieldHelpTemplate2 = getTemplate8("FieldHelpTemplate", registry, uiOptions);
|
|
2412
|
+
const FieldErrorTemplate2 = getTemplate8("FieldErrorTemplate", registry, uiOptions);
|
|
2288
2413
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2289
|
-
const fieldId =
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
_idSchema
|
|
2293
|
-
);
|
|
2294
|
-
const handleFieldComponentChange = useCallback2(
|
|
2295
|
-
(formData2, newErrorSchema, id2) => {
|
|
2414
|
+
const fieldId = fieldPathId[ID_KEY3];
|
|
2415
|
+
const handleFieldComponentChange = useCallback3(
|
|
2416
|
+
(formData2, path, newErrorSchema, id2) => {
|
|
2296
2417
|
const theId = id2 || fieldId;
|
|
2297
|
-
return onChange(formData2, newErrorSchema, theId);
|
|
2418
|
+
return onChange(formData2, path, newErrorSchema, theId);
|
|
2298
2419
|
},
|
|
2299
2420
|
[fieldId, onChange]
|
|
2300
2421
|
);
|
|
2301
|
-
const FieldComponent = getFieldComponent(schema, uiOptions,
|
|
2422
|
+
const FieldComponent = getFieldComponent(schema, uiOptions, fieldPathId, registry);
|
|
2302
2423
|
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
2303
2424
|
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
2304
2425
|
const uiSchemaHideError = uiOptions.hideError;
|
|
@@ -2313,12 +2434,12 @@ function SchemaFieldRender(props) {
|
|
|
2313
2434
|
if (UI_OPTIONS_KEY2 in fieldUiSchema) {
|
|
2314
2435
|
fieldUiSchema[UI_OPTIONS_KEY2] = omit3(fieldUiSchema[UI_OPTIONS_KEY2], ["classNames", "style"]);
|
|
2315
2436
|
}
|
|
2316
|
-
const field = /* @__PURE__ */
|
|
2437
|
+
const field = /* @__PURE__ */ jsx10(
|
|
2317
2438
|
FieldComponent,
|
|
2318
2439
|
{
|
|
2319
2440
|
...props,
|
|
2320
2441
|
onChange: handleFieldComponentChange,
|
|
2321
|
-
|
|
2442
|
+
fieldPathId,
|
|
2322
2443
|
schema,
|
|
2323
2444
|
uiSchema: fieldUiSchema,
|
|
2324
2445
|
disabled,
|
|
@@ -2330,7 +2451,7 @@ function SchemaFieldRender(props) {
|
|
|
2330
2451
|
rawErrors: __errors
|
|
2331
2452
|
}
|
|
2332
2453
|
);
|
|
2333
|
-
const id =
|
|
2454
|
+
const id = fieldPathId[ID_KEY3];
|
|
2334
2455
|
let label;
|
|
2335
2456
|
if (wasPropertyKeyModified) {
|
|
2336
2457
|
label = name;
|
|
@@ -2340,37 +2461,37 @@ function SchemaFieldRender(props) {
|
|
|
2340
2461
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2341
2462
|
const help = uiOptions.help;
|
|
2342
2463
|
const hidden = uiOptions.widget === "hidden";
|
|
2343
|
-
const classNames = ["rjsf-field", `rjsf-field-${
|
|
2464
|
+
const classNames = ["rjsf-field", `rjsf-field-${getSchemaType2(schema)}`];
|
|
2344
2465
|
if (!hideError && __errors && __errors.length > 0) {
|
|
2345
2466
|
classNames.push("rjsf-field-error");
|
|
2346
2467
|
}
|
|
2347
2468
|
if (uiOptions.classNames) {
|
|
2348
2469
|
classNames.push(uiOptions.classNames);
|
|
2349
2470
|
}
|
|
2350
|
-
const helpComponent = /* @__PURE__ */
|
|
2471
|
+
const helpComponent = /* @__PURE__ */ jsx10(
|
|
2351
2472
|
FieldHelpTemplate2,
|
|
2352
2473
|
{
|
|
2353
2474
|
help,
|
|
2354
|
-
|
|
2475
|
+
fieldPathId,
|
|
2355
2476
|
schema,
|
|
2356
2477
|
uiSchema,
|
|
2357
2478
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
2358
2479
|
registry
|
|
2359
2480
|
}
|
|
2360
2481
|
);
|
|
2361
|
-
const errorsComponent = hideError || (schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */
|
|
2482
|
+
const errorsComponent = hideError || (schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ jsx10(
|
|
2362
2483
|
FieldErrorTemplate2,
|
|
2363
2484
|
{
|
|
2364
2485
|
errors: __errors,
|
|
2365
2486
|
errorSchema,
|
|
2366
|
-
|
|
2487
|
+
fieldPathId,
|
|
2367
2488
|
schema,
|
|
2368
2489
|
uiSchema,
|
|
2369
2490
|
registry
|
|
2370
2491
|
}
|
|
2371
2492
|
);
|
|
2372
2493
|
const fieldProps = {
|
|
2373
|
-
description: /* @__PURE__ */
|
|
2494
|
+
description: /* @__PURE__ */ jsx10(
|
|
2374
2495
|
DescriptionFieldTemplate,
|
|
2375
2496
|
{
|
|
2376
2497
|
id: descriptionId(id),
|
|
@@ -2398,7 +2519,6 @@ function SchemaFieldRender(props) {
|
|
|
2398
2519
|
displayLabel,
|
|
2399
2520
|
classNames: classNames.join(" ").trim(),
|
|
2400
2521
|
style: uiOptions.style,
|
|
2401
|
-
formContext,
|
|
2402
2522
|
formData,
|
|
2403
2523
|
schema,
|
|
2404
2524
|
uiSchema,
|
|
@@ -2407,9 +2527,9 @@ function SchemaFieldRender(props) {
|
|
|
2407
2527
|
const _AnyOfField = registry.fields.AnyOfField;
|
|
2408
2528
|
const _OneOfField = registry.fields.OneOfField;
|
|
2409
2529
|
const isReplacingAnyOrOneOf = uiSchema?.["ui:field"] && uiSchema?.["ui:fieldReplacesAnyOrOneOf"] === true;
|
|
2410
|
-
return /* @__PURE__ */
|
|
2530
|
+
return /* @__PURE__ */ jsx10(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
2411
2531
|
field,
|
|
2412
|
-
schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */
|
|
2532
|
+
schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx10(
|
|
2413
2533
|
_AnyOfField,
|
|
2414
2534
|
{
|
|
2415
2535
|
name,
|
|
@@ -2419,9 +2539,7 @@ function SchemaFieldRender(props) {
|
|
|
2419
2539
|
errorSchema,
|
|
2420
2540
|
formData,
|
|
2421
2541
|
formContext,
|
|
2422
|
-
|
|
2423
|
-
idSchema,
|
|
2424
|
-
idSeparator,
|
|
2542
|
+
fieldPathId,
|
|
2425
2543
|
onBlur: props.onBlur,
|
|
2426
2544
|
onChange: props.onChange,
|
|
2427
2545
|
onFocus: props.onFocus,
|
|
@@ -2434,7 +2552,7 @@ function SchemaFieldRender(props) {
|
|
|
2434
2552
|
uiSchema
|
|
2435
2553
|
}
|
|
2436
2554
|
),
|
|
2437
|
-
schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */
|
|
2555
|
+
schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx10(
|
|
2438
2556
|
_OneOfField,
|
|
2439
2557
|
{
|
|
2440
2558
|
name,
|
|
@@ -2444,9 +2562,7 @@ function SchemaFieldRender(props) {
|
|
|
2444
2562
|
errorSchema,
|
|
2445
2563
|
formData,
|
|
2446
2564
|
formContext,
|
|
2447
|
-
|
|
2448
|
-
idSchema,
|
|
2449
|
-
idSeparator,
|
|
2565
|
+
fieldPathId,
|
|
2450
2566
|
onBlur: props.onBlur,
|
|
2451
2567
|
onChange: props.onChange,
|
|
2452
2568
|
onFocus: props.onFocus,
|
|
@@ -2463,28 +2579,33 @@ function SchemaFieldRender(props) {
|
|
|
2463
2579
|
}
|
|
2464
2580
|
var SchemaField = class extends Component4 {
|
|
2465
2581
|
shouldComponentUpdate(nextProps) {
|
|
2466
|
-
|
|
2582
|
+
const {
|
|
2583
|
+
registry: { globalFormOptions }
|
|
2584
|
+
} = this.props;
|
|
2585
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = globalFormOptions;
|
|
2586
|
+
return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
|
|
2467
2587
|
}
|
|
2468
2588
|
render() {
|
|
2469
|
-
return /* @__PURE__ */
|
|
2589
|
+
return /* @__PURE__ */ jsx10(SchemaFieldRender, { ...this.props });
|
|
2470
2590
|
}
|
|
2471
2591
|
};
|
|
2472
2592
|
var SchemaField_default = SchemaField;
|
|
2473
2593
|
|
|
2474
2594
|
// src/components/fields/StringField.tsx
|
|
2595
|
+
import { useCallback as useCallback4 } from "react";
|
|
2475
2596
|
import {
|
|
2476
2597
|
getWidget as getWidget5,
|
|
2477
|
-
getUiOptions as
|
|
2598
|
+
getUiOptions as getUiOptions10,
|
|
2478
2599
|
optionsList as optionsList4,
|
|
2479
2600
|
hasWidget
|
|
2480
2601
|
} from "@rjsf/utils";
|
|
2481
|
-
import { jsx as
|
|
2602
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2482
2603
|
function StringField(props) {
|
|
2483
2604
|
const {
|
|
2484
2605
|
schema,
|
|
2485
2606
|
name,
|
|
2486
2607
|
uiSchema,
|
|
2487
|
-
|
|
2608
|
+
fieldPathId,
|
|
2488
2609
|
formData,
|
|
2489
2610
|
required,
|
|
2490
2611
|
disabled = false,
|
|
@@ -2504,23 +2625,29 @@ function StringField(props) {
|
|
|
2504
2625
|
if (format && hasWidget(schema, format, widgets2)) {
|
|
2505
2626
|
defaultWidget = format;
|
|
2506
2627
|
}
|
|
2507
|
-
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } =
|
|
2628
|
+
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = getUiOptions10(uiSchema);
|
|
2508
2629
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2509
2630
|
const label = uiTitle ?? title ?? name;
|
|
2510
2631
|
const Widget = getWidget5(schema, widget, widgets2);
|
|
2511
|
-
|
|
2632
|
+
const onWidgetChange = useCallback4(
|
|
2633
|
+
(value, errorSchema, id) => {
|
|
2634
|
+
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2635
|
+
},
|
|
2636
|
+
[onChange, fieldPathId]
|
|
2637
|
+
);
|
|
2638
|
+
return /* @__PURE__ */ jsx11(
|
|
2512
2639
|
Widget,
|
|
2513
2640
|
{
|
|
2514
2641
|
options: { ...options, enumOptions },
|
|
2515
2642
|
schema,
|
|
2516
2643
|
uiSchema,
|
|
2517
|
-
id:
|
|
2644
|
+
id: fieldPathId.$id,
|
|
2518
2645
|
name,
|
|
2519
2646
|
label,
|
|
2520
2647
|
hideLabel: !displayLabel,
|
|
2521
2648
|
hideError,
|
|
2522
2649
|
value: formData,
|
|
2523
|
-
onChange,
|
|
2650
|
+
onChange: onWidgetChange,
|
|
2524
2651
|
onBlur,
|
|
2525
2652
|
onFocus,
|
|
2526
2653
|
required,
|
|
@@ -2539,12 +2666,12 @@ var StringField_default = StringField;
|
|
|
2539
2666
|
// src/components/fields/NullField.tsx
|
|
2540
2667
|
import { useEffect as useEffect2 } from "react";
|
|
2541
2668
|
function NullField(props) {
|
|
2542
|
-
const { formData, onChange } = props;
|
|
2669
|
+
const { formData, onChange, fieldPathId } = props;
|
|
2543
2670
|
useEffect2(() => {
|
|
2544
2671
|
if (formData === void 0) {
|
|
2545
|
-
onChange(null);
|
|
2672
|
+
onChange(null, fieldPathId.path);
|
|
2546
2673
|
}
|
|
2547
|
-
}, [formData, onChange]);
|
|
2674
|
+
}, [fieldPathId, formData, onChange]);
|
|
2548
2675
|
return null;
|
|
2549
2676
|
}
|
|
2550
2677
|
var NullField_default = NullField;
|
|
@@ -2562,6 +2689,7 @@ function fields() {
|
|
|
2562
2689
|
NumberField: NumberField_default,
|
|
2563
2690
|
ObjectField: ObjectField_default,
|
|
2564
2691
|
OneOfField: MultiSchemaField_default,
|
|
2692
|
+
OptionalDataControlsField,
|
|
2565
2693
|
SchemaField: SchemaField_default,
|
|
2566
2694
|
StringField: StringField_default,
|
|
2567
2695
|
NullField: NullField_default
|
|
@@ -2572,26 +2700,26 @@ var fields_default = fields;
|
|
|
2572
2700
|
// src/components/templates/ArrayFieldDescriptionTemplate.tsx
|
|
2573
2701
|
import {
|
|
2574
2702
|
descriptionId as descriptionId2,
|
|
2575
|
-
getTemplate as
|
|
2576
|
-
getUiOptions as
|
|
2703
|
+
getTemplate as getTemplate9,
|
|
2704
|
+
getUiOptions as getUiOptions11
|
|
2577
2705
|
} from "@rjsf/utils";
|
|
2578
|
-
import { jsx as
|
|
2706
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2579
2707
|
function ArrayFieldDescriptionTemplate(props) {
|
|
2580
|
-
const {
|
|
2581
|
-
const options =
|
|
2708
|
+
const { fieldPathId, description, registry, schema, uiSchema } = props;
|
|
2709
|
+
const options = getUiOptions11(uiSchema, registry.globalUiOptions);
|
|
2582
2710
|
const { label: displayLabel = true } = options;
|
|
2583
2711
|
if (!description || !displayLabel) {
|
|
2584
2712
|
return null;
|
|
2585
2713
|
}
|
|
2586
|
-
const DescriptionFieldTemplate =
|
|
2714
|
+
const DescriptionFieldTemplate = getTemplate9(
|
|
2587
2715
|
"DescriptionFieldTemplate",
|
|
2588
2716
|
registry,
|
|
2589
2717
|
options
|
|
2590
2718
|
);
|
|
2591
|
-
return /* @__PURE__ */
|
|
2719
|
+
return /* @__PURE__ */ jsx12(
|
|
2592
2720
|
DescriptionFieldTemplate,
|
|
2593
2721
|
{
|
|
2594
|
-
id: descriptionId2(
|
|
2722
|
+
id: descriptionId2(fieldPathId),
|
|
2595
2723
|
description,
|
|
2596
2724
|
schema,
|
|
2597
2725
|
uiSchema,
|
|
@@ -2602,14 +2730,14 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
2602
2730
|
|
|
2603
2731
|
// src/components/templates/ArrayFieldItemTemplate.tsx
|
|
2604
2732
|
import {
|
|
2605
|
-
getTemplate as
|
|
2606
|
-
getUiOptions as
|
|
2733
|
+
getTemplate as getTemplate10,
|
|
2734
|
+
getUiOptions as getUiOptions12
|
|
2607
2735
|
} from "@rjsf/utils";
|
|
2608
|
-
import { jsx as
|
|
2736
|
+
import { jsx as jsx13, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2609
2737
|
function ArrayFieldItemTemplate(props) {
|
|
2610
2738
|
const { children, className, buttonsProps, hasToolbar, registry, uiSchema } = props;
|
|
2611
|
-
const uiOptions =
|
|
2612
|
-
const ArrayFieldItemButtonsTemplate2 =
|
|
2739
|
+
const uiOptions = getUiOptions12(uiSchema);
|
|
2740
|
+
const ArrayFieldItemButtonsTemplate2 = getTemplate10(
|
|
2613
2741
|
"ArrayFieldItemButtonsTemplate",
|
|
2614
2742
|
registry,
|
|
2615
2743
|
uiOptions
|
|
@@ -2620,9 +2748,9 @@ function ArrayFieldItemTemplate(props) {
|
|
|
2620
2748
|
paddingRight: 6,
|
|
2621
2749
|
fontWeight: "bold"
|
|
2622
2750
|
};
|
|
2623
|
-
return /* @__PURE__ */
|
|
2624
|
-
/* @__PURE__ */
|
|
2625
|
-
hasToolbar && /* @__PURE__ */
|
|
2751
|
+
return /* @__PURE__ */ jsxs3("div", { className, children: [
|
|
2752
|
+
/* @__PURE__ */ jsx13("div", { className: hasToolbar ? "col-xs-9" : "col-xs-12", children }),
|
|
2753
|
+
hasToolbar && /* @__PURE__ */ jsx13("div", { className: "col-xs-3 array-item-toolbox", children: /* @__PURE__ */ jsx13(
|
|
2626
2754
|
"div",
|
|
2627
2755
|
{
|
|
2628
2756
|
className: "btn-group",
|
|
@@ -2630,7 +2758,7 @@ function ArrayFieldItemTemplate(props) {
|
|
|
2630
2758
|
display: "flex",
|
|
2631
2759
|
justifyContent: "space-around"
|
|
2632
2760
|
},
|
|
2633
|
-
children: /* @__PURE__ */
|
|
2761
|
+
children: /* @__PURE__ */ jsx13(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle })
|
|
2634
2762
|
}
|
|
2635
2763
|
) })
|
|
2636
2764
|
] });
|
|
@@ -2641,7 +2769,7 @@ import { useMemo } from "react";
|
|
|
2641
2769
|
import {
|
|
2642
2770
|
buttonId
|
|
2643
2771
|
} from "@rjsf/utils";
|
|
2644
|
-
import { Fragment as Fragment2, jsx as
|
|
2772
|
+
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2645
2773
|
function ArrayFieldItemButtonsTemplate(props) {
|
|
2646
2774
|
const {
|
|
2647
2775
|
disabled,
|
|
@@ -2649,7 +2777,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2649
2777
|
hasMoveDown,
|
|
2650
2778
|
hasMoveUp,
|
|
2651
2779
|
hasRemove,
|
|
2652
|
-
|
|
2780
|
+
fieldPathId,
|
|
2653
2781
|
index,
|
|
2654
2782
|
onCopyIndexClick,
|
|
2655
2783
|
onDropIndexClick,
|
|
@@ -2663,11 +2791,11 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2663
2791
|
const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
2664
2792
|
const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
2665
2793
|
const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
2666
|
-
return /* @__PURE__ */
|
|
2667
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */
|
|
2794
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
2795
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx14(
|
|
2668
2796
|
MoveUpButton2,
|
|
2669
2797
|
{
|
|
2670
|
-
id: buttonId(
|
|
2798
|
+
id: buttonId(fieldPathId, "moveUp"),
|
|
2671
2799
|
className: "rjsf-array-item-move-up",
|
|
2672
2800
|
disabled: disabled || readonly || !hasMoveUp,
|
|
2673
2801
|
onClick: onArrowUpClick,
|
|
@@ -2675,10 +2803,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2675
2803
|
registry
|
|
2676
2804
|
}
|
|
2677
2805
|
),
|
|
2678
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */
|
|
2806
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx14(
|
|
2679
2807
|
MoveDownButton2,
|
|
2680
2808
|
{
|
|
2681
|
-
id: buttonId(
|
|
2809
|
+
id: buttonId(fieldPathId, "moveDown"),
|
|
2682
2810
|
className: "rjsf-array-item-move-down",
|
|
2683
2811
|
disabled: disabled || readonly || !hasMoveDown,
|
|
2684
2812
|
onClick: onArrowDownClick,
|
|
@@ -2686,10 +2814,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2686
2814
|
registry
|
|
2687
2815
|
}
|
|
2688
2816
|
),
|
|
2689
|
-
hasCopy && /* @__PURE__ */
|
|
2817
|
+
hasCopy && /* @__PURE__ */ jsx14(
|
|
2690
2818
|
CopyButton2,
|
|
2691
2819
|
{
|
|
2692
|
-
id: buttonId(
|
|
2820
|
+
id: buttonId(fieldPathId, "copy"),
|
|
2693
2821
|
className: "rjsf-array-item-copy",
|
|
2694
2822
|
disabled: disabled || readonly,
|
|
2695
2823
|
onClick: onCopyClick,
|
|
@@ -2697,10 +2825,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2697
2825
|
registry
|
|
2698
2826
|
}
|
|
2699
2827
|
),
|
|
2700
|
-
hasRemove && /* @__PURE__ */
|
|
2828
|
+
hasRemove && /* @__PURE__ */ jsx14(
|
|
2701
2829
|
RemoveButton2,
|
|
2702
2830
|
{
|
|
2703
|
-
id: buttonId(
|
|
2831
|
+
id: buttonId(fieldPathId, "remove"),
|
|
2704
2832
|
className: "rjsf-array-item-remove",
|
|
2705
2833
|
disabled: disabled || readonly,
|
|
2706
2834
|
onClick: onRemoveClick,
|
|
@@ -2713,19 +2841,20 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2713
2841
|
|
|
2714
2842
|
// src/components/templates/ArrayFieldTemplate.tsx
|
|
2715
2843
|
import {
|
|
2716
|
-
getTemplate as
|
|
2717
|
-
getUiOptions as
|
|
2844
|
+
getTemplate as getTemplate11,
|
|
2845
|
+
getUiOptions as getUiOptions13,
|
|
2718
2846
|
buttonId as buttonId2
|
|
2719
2847
|
} from "@rjsf/utils";
|
|
2720
|
-
import { jsx as
|
|
2848
|
+
import { jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2721
2849
|
function ArrayFieldTemplate(props) {
|
|
2722
2850
|
const {
|
|
2723
2851
|
canAdd,
|
|
2724
2852
|
className,
|
|
2725
2853
|
disabled,
|
|
2726
|
-
|
|
2854
|
+
fieldPathId,
|
|
2727
2855
|
uiSchema,
|
|
2728
2856
|
items,
|
|
2857
|
+
optionalDataControl,
|
|
2729
2858
|
onAddClick,
|
|
2730
2859
|
readonly,
|
|
2731
2860
|
registry,
|
|
@@ -2733,52 +2862,55 @@ function ArrayFieldTemplate(props) {
|
|
|
2733
2862
|
schema,
|
|
2734
2863
|
title
|
|
2735
2864
|
} = props;
|
|
2736
|
-
const uiOptions =
|
|
2737
|
-
const ArrayFieldDescriptionTemplate2 =
|
|
2865
|
+
const uiOptions = getUiOptions13(uiSchema);
|
|
2866
|
+
const ArrayFieldDescriptionTemplate2 = getTemplate11(
|
|
2738
2867
|
"ArrayFieldDescriptionTemplate",
|
|
2739
2868
|
registry,
|
|
2740
2869
|
uiOptions
|
|
2741
2870
|
);
|
|
2742
|
-
const ArrayFieldItemTemplate2 =
|
|
2871
|
+
const ArrayFieldItemTemplate2 = getTemplate11(
|
|
2743
2872
|
"ArrayFieldItemTemplate",
|
|
2744
2873
|
registry,
|
|
2745
2874
|
uiOptions
|
|
2746
2875
|
);
|
|
2747
|
-
const ArrayFieldTitleTemplate2 =
|
|
2876
|
+
const ArrayFieldTitleTemplate2 = getTemplate11(
|
|
2748
2877
|
"ArrayFieldTitleTemplate",
|
|
2749
2878
|
registry,
|
|
2750
2879
|
uiOptions
|
|
2751
2880
|
);
|
|
2881
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
2752
2882
|
const {
|
|
2753
2883
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
2754
2884
|
} = registry.templates;
|
|
2755
|
-
return /* @__PURE__ */
|
|
2756
|
-
/* @__PURE__ */
|
|
2885
|
+
return /* @__PURE__ */ jsxs5("fieldset", { className, id: fieldPathId.$id, children: [
|
|
2886
|
+
/* @__PURE__ */ jsx15(
|
|
2757
2887
|
ArrayFieldTitleTemplate2,
|
|
2758
2888
|
{
|
|
2759
|
-
|
|
2889
|
+
fieldPathId,
|
|
2760
2890
|
title: uiOptions.title || title,
|
|
2761
2891
|
required,
|
|
2762
2892
|
schema,
|
|
2763
2893
|
uiSchema,
|
|
2764
|
-
registry
|
|
2894
|
+
registry,
|
|
2895
|
+
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
2765
2896
|
}
|
|
2766
2897
|
),
|
|
2767
|
-
/* @__PURE__ */
|
|
2898
|
+
/* @__PURE__ */ jsx15(
|
|
2768
2899
|
ArrayFieldDescriptionTemplate2,
|
|
2769
2900
|
{
|
|
2770
|
-
|
|
2901
|
+
fieldPathId,
|
|
2771
2902
|
description: uiOptions.description || schema.description,
|
|
2772
2903
|
schema,
|
|
2773
2904
|
uiSchema,
|
|
2774
2905
|
registry
|
|
2775
2906
|
}
|
|
2776
2907
|
),
|
|
2777
|
-
|
|
2778
|
-
|
|
2908
|
+
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
2909
|
+
/* @__PURE__ */ jsx15("div", { className: "row array-item-list", children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx15(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
|
|
2910
|
+
canAdd && /* @__PURE__ */ jsx15(
|
|
2779
2911
|
AddButton2,
|
|
2780
2912
|
{
|
|
2781
|
-
id: buttonId2(
|
|
2913
|
+
id: buttonId2(fieldPathId, "add"),
|
|
2782
2914
|
className: "rjsf-array-item-add",
|
|
2783
2915
|
onClick: onAddClick,
|
|
2784
2916
|
disabled: disabled || readonly,
|
|
@@ -2791,44 +2923,45 @@ function ArrayFieldTemplate(props) {
|
|
|
2791
2923
|
|
|
2792
2924
|
// src/components/templates/ArrayFieldTitleTemplate.tsx
|
|
2793
2925
|
import {
|
|
2794
|
-
getTemplate as
|
|
2795
|
-
getUiOptions as
|
|
2926
|
+
getTemplate as getTemplate12,
|
|
2927
|
+
getUiOptions as getUiOptions14,
|
|
2796
2928
|
titleId as titleId2
|
|
2797
2929
|
} from "@rjsf/utils";
|
|
2798
|
-
import { jsx as
|
|
2930
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
2799
2931
|
function ArrayFieldTitleTemplate(props) {
|
|
2800
|
-
const {
|
|
2801
|
-
const options =
|
|
2932
|
+
const { fieldPathId, title, schema, uiSchema, required, registry, optionalDataControl } = props;
|
|
2933
|
+
const options = getUiOptions14(uiSchema, registry.globalUiOptions);
|
|
2802
2934
|
const { label: displayLabel = true } = options;
|
|
2803
2935
|
if (!title || !displayLabel) {
|
|
2804
2936
|
return null;
|
|
2805
2937
|
}
|
|
2806
|
-
const TitleFieldTemplate =
|
|
2938
|
+
const TitleFieldTemplate = getTemplate12(
|
|
2807
2939
|
"TitleFieldTemplate",
|
|
2808
2940
|
registry,
|
|
2809
2941
|
options
|
|
2810
2942
|
);
|
|
2811
|
-
return /* @__PURE__ */
|
|
2943
|
+
return /* @__PURE__ */ jsx16(
|
|
2812
2944
|
TitleFieldTemplate,
|
|
2813
2945
|
{
|
|
2814
|
-
id: titleId2(
|
|
2946
|
+
id: titleId2(fieldPathId),
|
|
2815
2947
|
title,
|
|
2816
2948
|
required,
|
|
2817
2949
|
schema,
|
|
2818
2950
|
uiSchema,
|
|
2819
|
-
registry
|
|
2951
|
+
registry,
|
|
2952
|
+
optionalDataControl
|
|
2820
2953
|
}
|
|
2821
2954
|
);
|
|
2822
2955
|
}
|
|
2823
2956
|
|
|
2824
2957
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2825
|
-
import { useCallback as
|
|
2958
|
+
import { useCallback as useCallback5 } from "react";
|
|
2826
2959
|
import {
|
|
2827
2960
|
ariaDescribedByIds,
|
|
2828
2961
|
examplesId,
|
|
2829
2962
|
getInputProps
|
|
2830
2963
|
} from "@rjsf/utils";
|
|
2831
|
-
import { Fragment as Fragment3, jsx as
|
|
2964
|
+
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2832
2965
|
function BaseInputTemplate(props) {
|
|
2833
2966
|
const {
|
|
2834
2967
|
id,
|
|
@@ -2869,20 +3002,20 @@ function BaseInputTemplate(props) {
|
|
|
2869
3002
|
} else {
|
|
2870
3003
|
inputValue = value == null ? "" : value;
|
|
2871
3004
|
}
|
|
2872
|
-
const _onChange =
|
|
3005
|
+
const _onChange = useCallback5(
|
|
2873
3006
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
2874
3007
|
[onChange, options]
|
|
2875
3008
|
);
|
|
2876
|
-
const _onBlur =
|
|
3009
|
+
const _onBlur = useCallback5(
|
|
2877
3010
|
({ target }) => onBlur(id, target && target.value),
|
|
2878
3011
|
[onBlur, id]
|
|
2879
3012
|
);
|
|
2880
|
-
const _onFocus =
|
|
3013
|
+
const _onFocus = useCallback5(
|
|
2881
3014
|
({ target }) => onFocus(id, target && target.value),
|
|
2882
3015
|
[onFocus, id]
|
|
2883
3016
|
);
|
|
2884
|
-
return /* @__PURE__ */
|
|
2885
|
-
/* @__PURE__ */
|
|
3017
|
+
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
3018
|
+
/* @__PURE__ */ jsx17(
|
|
2886
3019
|
"input",
|
|
2887
3020
|
{
|
|
2888
3021
|
id,
|
|
@@ -2900,74 +3033,76 @@ function BaseInputTemplate(props) {
|
|
|
2900
3033
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
2901
3034
|
}
|
|
2902
3035
|
),
|
|
2903
|
-
Array.isArray(schema.examples) && /* @__PURE__ */
|
|
2904
|
-
return /* @__PURE__ */
|
|
3036
|
+
Array.isArray(schema.examples) && /* @__PURE__ */ jsx17("datalist", { id: examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
|
|
3037
|
+
return /* @__PURE__ */ jsx17("option", { value: example }, example);
|
|
2905
3038
|
}) }, `datalist_${id}`)
|
|
2906
3039
|
] });
|
|
2907
3040
|
}
|
|
2908
3041
|
|
|
2909
3042
|
// src/components/templates/ButtonTemplates/SubmitButton.tsx
|
|
2910
3043
|
import { getSubmitButtonOptions } from "@rjsf/utils";
|
|
2911
|
-
import { jsx as
|
|
3044
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
2912
3045
|
function SubmitButton({ uiSchema }) {
|
|
2913
3046
|
const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions(uiSchema);
|
|
2914
3047
|
if (norender) {
|
|
2915
3048
|
return null;
|
|
2916
3049
|
}
|
|
2917
|
-
return /* @__PURE__ */
|
|
3050
|
+
return /* @__PURE__ */ jsx18("div", { children: /* @__PURE__ */ jsx18("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
|
|
2918
3051
|
}
|
|
2919
3052
|
|
|
2920
3053
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
2921
|
-
import { TranslatableString as
|
|
3054
|
+
import { TranslatableString as TranslatableString8 } from "@rjsf/utils";
|
|
2922
3055
|
|
|
2923
3056
|
// src/components/templates/ButtonTemplates/IconButton.tsx
|
|
2924
|
-
import { TranslatableString as
|
|
2925
|
-
import { jsx as
|
|
3057
|
+
import { TranslatableString as TranslatableString7 } from "@rjsf/utils";
|
|
3058
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
2926
3059
|
function IconButton(props) {
|
|
2927
3060
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
2928
|
-
return /* @__PURE__ */
|
|
3061
|
+
return /* @__PURE__ */ jsx19("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsx19("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
2929
3062
|
}
|
|
2930
3063
|
function CopyButton(props) {
|
|
2931
3064
|
const {
|
|
2932
3065
|
registry: { translateString }
|
|
2933
3066
|
} = props;
|
|
2934
|
-
return /* @__PURE__ */
|
|
3067
|
+
return /* @__PURE__ */ jsx19(IconButton, { title: translateString(TranslatableString7.CopyButton), ...props, icon: "copy" });
|
|
2935
3068
|
}
|
|
2936
3069
|
function MoveDownButton(props) {
|
|
2937
3070
|
const {
|
|
2938
3071
|
registry: { translateString }
|
|
2939
3072
|
} = props;
|
|
2940
|
-
return /* @__PURE__ */
|
|
3073
|
+
return /* @__PURE__ */ jsx19(IconButton, { title: translateString(TranslatableString7.MoveDownButton), ...props, icon: "arrow-down" });
|
|
2941
3074
|
}
|
|
2942
3075
|
function MoveUpButton(props) {
|
|
2943
3076
|
const {
|
|
2944
3077
|
registry: { translateString }
|
|
2945
3078
|
} = props;
|
|
2946
|
-
return /* @__PURE__ */
|
|
3079
|
+
return /* @__PURE__ */ jsx19(IconButton, { title: translateString(TranslatableString7.MoveUpButton), ...props, icon: "arrow-up" });
|
|
2947
3080
|
}
|
|
2948
3081
|
function RemoveButton(props) {
|
|
2949
3082
|
const {
|
|
2950
3083
|
registry: { translateString }
|
|
2951
3084
|
} = props;
|
|
2952
|
-
return /* @__PURE__ */
|
|
3085
|
+
return /* @__PURE__ */ jsx19(IconButton, { title: translateString(TranslatableString7.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
2953
3086
|
}
|
|
2954
3087
|
|
|
2955
3088
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
2956
|
-
import { jsx as
|
|
3089
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
2957
3090
|
function AddButton({
|
|
3091
|
+
id,
|
|
2958
3092
|
className,
|
|
2959
3093
|
onClick,
|
|
2960
3094
|
disabled,
|
|
2961
3095
|
registry
|
|
2962
3096
|
}) {
|
|
2963
3097
|
const { translateString } = registry;
|
|
2964
|
-
return /* @__PURE__ */
|
|
3098
|
+
return /* @__PURE__ */ jsx20("div", { className: "row", children: /* @__PURE__ */ jsx20("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsx20(
|
|
2965
3099
|
IconButton,
|
|
2966
3100
|
{
|
|
3101
|
+
id,
|
|
2967
3102
|
iconType: "info",
|
|
2968
3103
|
icon: "plus",
|
|
2969
3104
|
className: "btn-add col-xs-12",
|
|
2970
|
-
title: translateString(
|
|
3105
|
+
title: translateString(TranslatableString8.AddButton),
|
|
2971
3106
|
onClick,
|
|
2972
3107
|
disabled,
|
|
2973
3108
|
registry
|
|
@@ -2991,84 +3126,84 @@ var ButtonTemplates_default = buttonTemplates;
|
|
|
2991
3126
|
// src/components/RichDescription.tsx
|
|
2992
3127
|
import {
|
|
2993
3128
|
getTestIds as getTestIds2,
|
|
2994
|
-
getUiOptions as
|
|
3129
|
+
getUiOptions as getUiOptions15
|
|
2995
3130
|
} from "@rjsf/utils";
|
|
2996
3131
|
import Markdown2 from "markdown-to-jsx";
|
|
2997
|
-
import { jsx as
|
|
3132
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
2998
3133
|
var TEST_IDS = getTestIds2();
|
|
2999
3134
|
function RichDescription({ description, registry, uiSchema = {} }) {
|
|
3000
3135
|
const { globalUiOptions } = registry;
|
|
3001
|
-
const uiOptions =
|
|
3136
|
+
const uiOptions = getUiOptions15(uiSchema, globalUiOptions);
|
|
3002
3137
|
if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
|
|
3003
|
-
return /* @__PURE__ */
|
|
3138
|
+
return /* @__PURE__ */ jsx21(Markdown2, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
3004
3139
|
}
|
|
3005
3140
|
return description;
|
|
3006
3141
|
}
|
|
3007
3142
|
RichDescription.TEST_IDS = TEST_IDS;
|
|
3008
3143
|
|
|
3009
3144
|
// src/components/templates/DescriptionField.tsx
|
|
3010
|
-
import { jsx as
|
|
3145
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
3011
3146
|
function DescriptionField(props) {
|
|
3012
3147
|
const { id, description, registry, uiSchema } = props;
|
|
3013
3148
|
if (!description) {
|
|
3014
3149
|
return null;
|
|
3015
3150
|
}
|
|
3016
|
-
return /* @__PURE__ */
|
|
3151
|
+
return /* @__PURE__ */ jsx22("div", { id, className: "field-description", children: /* @__PURE__ */ jsx22(RichDescription, { description, registry, uiSchema }) });
|
|
3017
3152
|
}
|
|
3018
3153
|
|
|
3019
3154
|
// src/components/templates/ErrorList.tsx
|
|
3020
3155
|
import {
|
|
3021
|
-
TranslatableString as
|
|
3156
|
+
TranslatableString as TranslatableString9
|
|
3022
3157
|
} from "@rjsf/utils";
|
|
3023
|
-
import { jsx as
|
|
3158
|
+
import { jsx as jsx23, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3024
3159
|
function ErrorList({
|
|
3025
3160
|
errors,
|
|
3026
3161
|
registry
|
|
3027
3162
|
}) {
|
|
3028
3163
|
const { translateString } = registry;
|
|
3029
|
-
return /* @__PURE__ */
|
|
3030
|
-
/* @__PURE__ */
|
|
3031
|
-
/* @__PURE__ */
|
|
3032
|
-
return /* @__PURE__ */
|
|
3164
|
+
return /* @__PURE__ */ jsxs7("div", { className: "panel panel-danger errors", children: [
|
|
3165
|
+
/* @__PURE__ */ jsx23("div", { className: "panel-heading", children: /* @__PURE__ */ jsx23("h3", { className: "panel-title", children: translateString(TranslatableString9.ErrorsLabel) }) }),
|
|
3166
|
+
/* @__PURE__ */ jsx23("ul", { className: "list-group", children: errors.map((error, i) => {
|
|
3167
|
+
return /* @__PURE__ */ jsx23("li", { className: "list-group-item text-danger", children: error.stack }, i);
|
|
3033
3168
|
}) })
|
|
3034
3169
|
] });
|
|
3035
3170
|
}
|
|
3036
3171
|
|
|
3037
3172
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3038
3173
|
import {
|
|
3039
|
-
getTemplate as
|
|
3040
|
-
getUiOptions as
|
|
3174
|
+
getTemplate as getTemplate13,
|
|
3175
|
+
getUiOptions as getUiOptions16
|
|
3041
3176
|
} from "@rjsf/utils";
|
|
3042
3177
|
|
|
3043
3178
|
// src/components/templates/FieldTemplate/Label.tsx
|
|
3044
|
-
import { jsx as
|
|
3179
|
+
import { jsx as jsx24, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3045
3180
|
var REQUIRED_FIELD_SYMBOL = "*";
|
|
3046
3181
|
function Label(props) {
|
|
3047
3182
|
const { label, required, id } = props;
|
|
3048
3183
|
if (!label) {
|
|
3049
3184
|
return null;
|
|
3050
3185
|
}
|
|
3051
|
-
return /* @__PURE__ */
|
|
3186
|
+
return /* @__PURE__ */ jsxs8("label", { className: "control-label", htmlFor: id, children: [
|
|
3052
3187
|
label,
|
|
3053
|
-
required && /* @__PURE__ */
|
|
3188
|
+
required && /* @__PURE__ */ jsx24("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
|
|
3054
3189
|
] });
|
|
3055
3190
|
}
|
|
3056
3191
|
|
|
3057
3192
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3058
|
-
import { jsx as
|
|
3193
|
+
import { jsx as jsx25, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3059
3194
|
function FieldTemplate(props) {
|
|
3060
3195
|
const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
|
|
3061
|
-
const uiOptions =
|
|
3062
|
-
const WrapIfAdditionalTemplate2 =
|
|
3196
|
+
const uiOptions = getUiOptions16(uiSchema);
|
|
3197
|
+
const WrapIfAdditionalTemplate2 = getTemplate13(
|
|
3063
3198
|
"WrapIfAdditionalTemplate",
|
|
3064
3199
|
registry,
|
|
3065
3200
|
uiOptions
|
|
3066
3201
|
);
|
|
3067
3202
|
if (hidden) {
|
|
3068
|
-
return /* @__PURE__ */
|
|
3203
|
+
return /* @__PURE__ */ jsx25("div", { className: "hidden", children });
|
|
3069
3204
|
}
|
|
3070
|
-
return /* @__PURE__ */
|
|
3071
|
-
displayLabel && /* @__PURE__ */
|
|
3205
|
+
return /* @__PURE__ */ jsxs9(WrapIfAdditionalTemplate2, { ...props, children: [
|
|
3206
|
+
displayLabel && /* @__PURE__ */ jsx25(Label, { label, required, id }),
|
|
3072
3207
|
displayLabel && description ? description : null,
|
|
3073
3208
|
children,
|
|
3074
3209
|
errors,
|
|
@@ -3081,57 +3216,69 @@ var FieldTemplate_default = FieldTemplate;
|
|
|
3081
3216
|
|
|
3082
3217
|
// src/components/templates/FieldErrorTemplate.tsx
|
|
3083
3218
|
import { errorId } from "@rjsf/utils";
|
|
3084
|
-
import { jsx as
|
|
3219
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
3085
3220
|
function FieldErrorTemplate(props) {
|
|
3086
|
-
const { errors = [],
|
|
3221
|
+
const { errors = [], fieldPathId } = props;
|
|
3087
3222
|
if (errors.length === 0) {
|
|
3088
3223
|
return null;
|
|
3089
3224
|
}
|
|
3090
|
-
const id = errorId(
|
|
3091
|
-
return /* @__PURE__ */
|
|
3092
|
-
return /* @__PURE__ */
|
|
3225
|
+
const id = errorId(fieldPathId);
|
|
3226
|
+
return /* @__PURE__ */ jsx26("div", { children: /* @__PURE__ */ jsx26("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
|
|
3227
|
+
return /* @__PURE__ */ jsx26("li", { className: "text-danger", children: error }, index);
|
|
3093
3228
|
}) }) });
|
|
3094
3229
|
}
|
|
3095
3230
|
|
|
3096
3231
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
3097
3232
|
import { helpId } from "@rjsf/utils";
|
|
3098
|
-
import { jsx as
|
|
3233
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
3099
3234
|
function FieldHelpTemplate(props) {
|
|
3100
|
-
const {
|
|
3235
|
+
const { fieldPathId, help } = props;
|
|
3101
3236
|
if (!help) {
|
|
3102
3237
|
return null;
|
|
3103
3238
|
}
|
|
3104
|
-
const id = helpId(
|
|
3239
|
+
const id = helpId(fieldPathId);
|
|
3105
3240
|
if (typeof help === "string") {
|
|
3106
|
-
return /* @__PURE__ */
|
|
3241
|
+
return /* @__PURE__ */ jsx27("p", { id, className: "help-block", children: help });
|
|
3107
3242
|
}
|
|
3108
|
-
return /* @__PURE__ */
|
|
3243
|
+
return /* @__PURE__ */ jsx27("div", { id, className: "help-block", children: help });
|
|
3109
3244
|
}
|
|
3110
3245
|
|
|
3111
3246
|
// src/components/templates/GridTemplate.tsx
|
|
3112
|
-
import { jsx as
|
|
3247
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3113
3248
|
function GridTemplate(props) {
|
|
3114
3249
|
const { children, column, className, ...rest } = props;
|
|
3115
|
-
return /* @__PURE__ */
|
|
3250
|
+
return /* @__PURE__ */ jsx28("div", { className, ...rest, children });
|
|
3251
|
+
}
|
|
3252
|
+
|
|
3253
|
+
// src/components/templates/MultiSchemaFieldTemplate.tsx
|
|
3254
|
+
import { jsx as jsx29, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3255
|
+
function MultiSchemaFieldTemplate(props) {
|
|
3256
|
+
const { selector, optionSchemaField } = props;
|
|
3257
|
+
return /* @__PURE__ */ jsxs10("div", { className: "panel panel-default panel-body", children: [
|
|
3258
|
+
/* @__PURE__ */ jsx29("div", { className: "form-group", children: selector }),
|
|
3259
|
+
optionSchemaField
|
|
3260
|
+
] });
|
|
3116
3261
|
}
|
|
3117
3262
|
|
|
3118
3263
|
// src/components/templates/ObjectFieldTemplate.tsx
|
|
3119
3264
|
import {
|
|
3120
3265
|
canExpand,
|
|
3121
3266
|
descriptionId as descriptionId3,
|
|
3122
|
-
getTemplate as
|
|
3123
|
-
getUiOptions as
|
|
3267
|
+
getTemplate as getTemplate14,
|
|
3268
|
+
getUiOptions as getUiOptions17,
|
|
3124
3269
|
titleId as titleId3,
|
|
3125
3270
|
buttonId as buttonId3
|
|
3126
3271
|
} from "@rjsf/utils";
|
|
3127
|
-
import { jsx as
|
|
3272
|
+
import { jsx as jsx30, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3128
3273
|
function ObjectFieldTemplate(props) {
|
|
3129
3274
|
const {
|
|
3275
|
+
className,
|
|
3130
3276
|
description,
|
|
3131
3277
|
disabled,
|
|
3132
3278
|
formData,
|
|
3133
|
-
|
|
3279
|
+
fieldPathId,
|
|
3134
3280
|
onAddClick,
|
|
3281
|
+
optionalDataControl,
|
|
3135
3282
|
properties,
|
|
3136
3283
|
readonly,
|
|
3137
3284
|
registry,
|
|
@@ -3140,43 +3287,46 @@ function ObjectFieldTemplate(props) {
|
|
|
3140
3287
|
title,
|
|
3141
3288
|
uiSchema
|
|
3142
3289
|
} = props;
|
|
3143
|
-
const options =
|
|
3144
|
-
const TitleFieldTemplate =
|
|
3145
|
-
const DescriptionFieldTemplate =
|
|
3290
|
+
const options = getUiOptions17(uiSchema);
|
|
3291
|
+
const TitleFieldTemplate = getTemplate14("TitleFieldTemplate", registry, options);
|
|
3292
|
+
const DescriptionFieldTemplate = getTemplate14(
|
|
3146
3293
|
"DescriptionFieldTemplate",
|
|
3147
3294
|
registry,
|
|
3148
3295
|
options
|
|
3149
3296
|
);
|
|
3297
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
3150
3298
|
const {
|
|
3151
3299
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
3152
3300
|
} = registry.templates;
|
|
3153
|
-
return /* @__PURE__ */ jsxs11("fieldset", { id:
|
|
3154
|
-
title && /* @__PURE__ */
|
|
3301
|
+
return /* @__PURE__ */ jsxs11("fieldset", { className, id: fieldPathId.$id, children: [
|
|
3302
|
+
title && /* @__PURE__ */ jsx30(
|
|
3155
3303
|
TitleFieldTemplate,
|
|
3156
3304
|
{
|
|
3157
|
-
id: titleId3(
|
|
3305
|
+
id: titleId3(fieldPathId),
|
|
3158
3306
|
title,
|
|
3159
3307
|
required,
|
|
3160
3308
|
schema,
|
|
3161
3309
|
uiSchema,
|
|
3162
|
-
registry
|
|
3310
|
+
registry,
|
|
3311
|
+
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
3163
3312
|
}
|
|
3164
3313
|
),
|
|
3165
|
-
description && /* @__PURE__ */
|
|
3314
|
+
description && /* @__PURE__ */ jsx30(
|
|
3166
3315
|
DescriptionFieldTemplate,
|
|
3167
3316
|
{
|
|
3168
|
-
id: descriptionId3(
|
|
3317
|
+
id: descriptionId3(fieldPathId),
|
|
3169
3318
|
description,
|
|
3170
3319
|
schema,
|
|
3171
3320
|
uiSchema,
|
|
3172
3321
|
registry
|
|
3173
3322
|
}
|
|
3174
3323
|
),
|
|
3324
|
+
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
3175
3325
|
properties.map((prop) => prop.content),
|
|
3176
|
-
canExpand(schema, uiSchema, formData) && /* @__PURE__ */
|
|
3326
|
+
canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx30(
|
|
3177
3327
|
AddButton2,
|
|
3178
3328
|
{
|
|
3179
|
-
id: buttonId3(
|
|
3329
|
+
id: buttonId3(fieldPathId, "add"),
|
|
3180
3330
|
className: "rjsf-object-property-expand",
|
|
3181
3331
|
onClick: onAddClick(schema),
|
|
3182
3332
|
disabled: disabled || readonly,
|
|
@@ -3187,37 +3337,70 @@ function ObjectFieldTemplate(props) {
|
|
|
3187
3337
|
] });
|
|
3188
3338
|
}
|
|
3189
3339
|
|
|
3340
|
+
// src/components/templates/OptionalDataControlsTemplate.tsx
|
|
3341
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
3342
|
+
function OptionalDataControlsTemplate(props) {
|
|
3343
|
+
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
3344
|
+
if (onAddClick) {
|
|
3345
|
+
return /* @__PURE__ */ jsx31(
|
|
3346
|
+
IconButton,
|
|
3347
|
+
{
|
|
3348
|
+
id,
|
|
3349
|
+
registry,
|
|
3350
|
+
icon: "plus",
|
|
3351
|
+
className: "rjsf-add-optional-data btn-sm",
|
|
3352
|
+
onClick: onAddClick,
|
|
3353
|
+
title: label
|
|
3354
|
+
}
|
|
3355
|
+
);
|
|
3356
|
+
} else if (onRemoveClick) {
|
|
3357
|
+
return /* @__PURE__ */ jsx31(
|
|
3358
|
+
IconButton,
|
|
3359
|
+
{
|
|
3360
|
+
id,
|
|
3361
|
+
registry,
|
|
3362
|
+
icon: "remove",
|
|
3363
|
+
className: "rjsf-remove-optional-data btn-sm",
|
|
3364
|
+
onClick: onRemoveClick,
|
|
3365
|
+
title: label
|
|
3366
|
+
}
|
|
3367
|
+
);
|
|
3368
|
+
}
|
|
3369
|
+
return /* @__PURE__ */ jsx31("em", { id, children: label });
|
|
3370
|
+
}
|
|
3371
|
+
|
|
3190
3372
|
// src/components/templates/TitleField.tsx
|
|
3191
|
-
import { jsx as
|
|
3373
|
+
import { jsx as jsx32, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3192
3374
|
var REQUIRED_FIELD_SYMBOL2 = "*";
|
|
3193
3375
|
function TitleField(props) {
|
|
3194
|
-
const { id, title, required } = props;
|
|
3376
|
+
const { id, title, required, optionalDataControl } = props;
|
|
3195
3377
|
return /* @__PURE__ */ jsxs12("legend", { id, children: [
|
|
3196
3378
|
title,
|
|
3197
|
-
required && /* @__PURE__ */
|
|
3379
|
+
required && /* @__PURE__ */ jsx32("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 }),
|
|
3380
|
+
optionalDataControl && /* @__PURE__ */ jsx32("span", { className: "pull-right", style: { marginBottom: "2px" }, children: optionalDataControl })
|
|
3198
3381
|
] });
|
|
3199
3382
|
}
|
|
3200
3383
|
|
|
3201
3384
|
// src/components/templates/UnsupportedField.tsx
|
|
3202
|
-
import { TranslatableString as
|
|
3385
|
+
import { TranslatableString as TranslatableString10 } from "@rjsf/utils";
|
|
3203
3386
|
import Markdown3 from "markdown-to-jsx";
|
|
3204
|
-
import { jsx as
|
|
3387
|
+
import { jsx as jsx33, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3205
3388
|
function UnsupportedField(props) {
|
|
3206
|
-
const { schema,
|
|
3389
|
+
const { schema, fieldPathId, reason, registry } = props;
|
|
3207
3390
|
const { translateString } = registry;
|
|
3208
|
-
let translateEnum =
|
|
3391
|
+
let translateEnum = TranslatableString10.UnsupportedField;
|
|
3209
3392
|
const translateParams = [];
|
|
3210
|
-
if (
|
|
3211
|
-
translateEnum =
|
|
3212
|
-
translateParams.push(
|
|
3393
|
+
if (fieldPathId && fieldPathId.$id) {
|
|
3394
|
+
translateEnum = TranslatableString10.UnsupportedFieldWithId;
|
|
3395
|
+
translateParams.push(fieldPathId.$id);
|
|
3213
3396
|
}
|
|
3214
3397
|
if (reason) {
|
|
3215
|
-
translateEnum = translateEnum ===
|
|
3398
|
+
translateEnum = translateEnum === TranslatableString10.UnsupportedField ? TranslatableString10.UnsupportedFieldWithReason : TranslatableString10.UnsupportedFieldWithIdAndReason;
|
|
3216
3399
|
translateParams.push(reason);
|
|
3217
3400
|
}
|
|
3218
3401
|
return /* @__PURE__ */ jsxs13("div", { className: "unsupported-field", children: [
|
|
3219
|
-
/* @__PURE__ */
|
|
3220
|
-
schema && /* @__PURE__ */
|
|
3402
|
+
/* @__PURE__ */ jsx33("p", { children: /* @__PURE__ */ jsx33(Markdown3, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3403
|
+
schema && /* @__PURE__ */ jsx33("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3221
3404
|
] });
|
|
3222
3405
|
}
|
|
3223
3406
|
var UnsupportedField_default = UnsupportedField;
|
|
@@ -3226,9 +3409,9 @@ var UnsupportedField_default = UnsupportedField;
|
|
|
3226
3409
|
import {
|
|
3227
3410
|
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3,
|
|
3228
3411
|
buttonId as buttonId4,
|
|
3229
|
-
TranslatableString as
|
|
3412
|
+
TranslatableString as TranslatableString11
|
|
3230
3413
|
} from "@rjsf/utils";
|
|
3231
|
-
import { jsx as
|
|
3414
|
+
import { jsx as jsx34, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3232
3415
|
function WrapIfAdditionalTemplate(props) {
|
|
3233
3416
|
const {
|
|
3234
3417
|
id,
|
|
@@ -3249,7 +3432,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3249
3432
|
} = props;
|
|
3250
3433
|
const { templates: templates2, translateString } = registry;
|
|
3251
3434
|
const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
|
|
3252
|
-
const keyLabel = translateString(
|
|
3435
|
+
const keyLabel = translateString(TranslatableString11.KeyLabel, [label]);
|
|
3253
3436
|
const additional = ADDITIONAL_PROPERTY_FLAG3 in schema;
|
|
3254
3437
|
const classNamesList = ["form-group", classNames];
|
|
3255
3438
|
if (!hideError && rawErrors && rawErrors.length > 0) {
|
|
@@ -3257,12 +3440,12 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3257
3440
|
}
|
|
3258
3441
|
const uiClassNames = classNamesList.join(" ").trim();
|
|
3259
3442
|
if (!additional) {
|
|
3260
|
-
return /* @__PURE__ */
|
|
3443
|
+
return /* @__PURE__ */ jsx34("div", { className: uiClassNames, style, children });
|
|
3261
3444
|
}
|
|
3262
|
-
return /* @__PURE__ */
|
|
3263
|
-
/* @__PURE__ */
|
|
3264
|
-
/* @__PURE__ */
|
|
3265
|
-
/* @__PURE__ */
|
|
3445
|
+
return /* @__PURE__ */ jsx34("div", { className: uiClassNames, style, children: /* @__PURE__ */ jsxs14("div", { className: "row", children: [
|
|
3446
|
+
/* @__PURE__ */ jsx34("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ jsxs14("div", { className: "form-group", children: [
|
|
3447
|
+
/* @__PURE__ */ jsx34(Label, { label: keyLabel, required, id: `${id}-key` }),
|
|
3448
|
+
/* @__PURE__ */ jsx34(
|
|
3266
3449
|
"input",
|
|
3267
3450
|
{
|
|
3268
3451
|
className: "form-control",
|
|
@@ -3273,8 +3456,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3273
3456
|
}
|
|
3274
3457
|
)
|
|
3275
3458
|
] }) }),
|
|
3276
|
-
/* @__PURE__ */
|
|
3277
|
-
/* @__PURE__ */
|
|
3459
|
+
/* @__PURE__ */ jsx34("div", { className: "form-additional form-group col-xs-5", children }),
|
|
3460
|
+
/* @__PURE__ */ jsx34("div", { className: "col-xs-2", children: /* @__PURE__ */ jsx34(
|
|
3278
3461
|
RemoveButton2,
|
|
3279
3462
|
{
|
|
3280
3463
|
id: buttonId4(id, "remove"),
|
|
@@ -3305,7 +3488,9 @@ function templates() {
|
|
|
3305
3488
|
FieldErrorTemplate,
|
|
3306
3489
|
FieldHelpTemplate,
|
|
3307
3490
|
GridTemplate,
|
|
3491
|
+
MultiSchemaFieldTemplate,
|
|
3308
3492
|
ObjectFieldTemplate,
|
|
3493
|
+
OptionalDataControlsTemplate,
|
|
3309
3494
|
TitleFieldTemplate: TitleField,
|
|
3310
3495
|
UnsupportedFieldTemplate: UnsupportedField_default,
|
|
3311
3496
|
WrapIfAdditionalTemplate
|
|
@@ -3314,16 +3499,16 @@ function templates() {
|
|
|
3314
3499
|
var templates_default = templates;
|
|
3315
3500
|
|
|
3316
3501
|
// src/components/widgets/AltDateWidget.tsx
|
|
3317
|
-
import { useCallback as
|
|
3502
|
+
import { useCallback as useCallback6, useEffect as useEffect3, useState as useState3 } from "react";
|
|
3318
3503
|
import {
|
|
3319
3504
|
ariaDescribedByIds as ariaDescribedByIds2,
|
|
3320
3505
|
dateRangeOptions,
|
|
3321
3506
|
parseDateString,
|
|
3322
3507
|
toDateString,
|
|
3323
|
-
TranslatableString as
|
|
3508
|
+
TranslatableString as TranslatableString12,
|
|
3324
3509
|
getDateElementProps
|
|
3325
3510
|
} from "@rjsf/utils";
|
|
3326
|
-
import { jsx as
|
|
3511
|
+
import { jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3327
3512
|
function readyForChange(state) {
|
|
3328
3513
|
return Object.values(state).every((value) => value !== -1);
|
|
3329
3514
|
}
|
|
@@ -3343,7 +3528,7 @@ function DateElement({
|
|
|
3343
3528
|
}) {
|
|
3344
3529
|
const id = rootId + "_" + type;
|
|
3345
3530
|
const { SelectWidget: SelectWidget2 } = registry.widgets;
|
|
3346
|
-
return /* @__PURE__ */
|
|
3531
|
+
return /* @__PURE__ */ jsx35(
|
|
3347
3532
|
SelectWidget2,
|
|
3348
3533
|
{
|
|
3349
3534
|
schema: { type: "integer" },
|
|
@@ -3380,26 +3565,25 @@ function AltDateWidget({
|
|
|
3380
3565
|
value
|
|
3381
3566
|
}) {
|
|
3382
3567
|
const { translateString } = registry;
|
|
3383
|
-
const [
|
|
3384
|
-
|
|
3385
|
-
(
|
|
3386
|
-
|
|
3568
|
+
const [state, setState] = useState3(parseDateString(value, time));
|
|
3569
|
+
useEffect3(() => {
|
|
3570
|
+
setState(parseDateString(value, time));
|
|
3571
|
+
}, [time, value]);
|
|
3572
|
+
const handleChange = useCallback6(
|
|
3573
|
+
(property, value2) => {
|
|
3574
|
+
const nextState = {
|
|
3575
|
+
...state,
|
|
3576
|
+
[property]: typeof value2 === "undefined" ? -1 : value2
|
|
3577
|
+
};
|
|
3578
|
+
if (readyForChange(nextState)) {
|
|
3579
|
+
onChange(toDateString(nextState, time));
|
|
3580
|
+
} else {
|
|
3581
|
+
setState(nextState);
|
|
3582
|
+
}
|
|
3387
3583
|
},
|
|
3388
|
-
|
|
3584
|
+
[state, onChange, time]
|
|
3389
3585
|
);
|
|
3390
|
-
|
|
3391
|
-
const stateValue = toDateString(state, time);
|
|
3392
|
-
if (readyForChange(state) && stateValue !== value) {
|
|
3393
|
-
onChange(stateValue);
|
|
3394
|
-
} else if (lastValue !== value) {
|
|
3395
|
-
setLastValue(value);
|
|
3396
|
-
setState(parseDateString(value, time));
|
|
3397
|
-
}
|
|
3398
|
-
}, [time, value, onChange, state, lastValue]);
|
|
3399
|
-
const handleChange = useCallback4((property, value2) => {
|
|
3400
|
-
setState({ [property]: value2 });
|
|
3401
|
-
}, []);
|
|
3402
|
-
const handleSetNow = useCallback4(
|
|
3586
|
+
const handleSetNow = useCallback6(
|
|
3403
3587
|
(event) => {
|
|
3404
3588
|
event.preventDefault();
|
|
3405
3589
|
if (disabled || readonly) {
|
|
@@ -3408,9 +3592,9 @@ function AltDateWidget({
|
|
|
3408
3592
|
const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), time);
|
|
3409
3593
|
onChange(toDateString(nextState, time));
|
|
3410
3594
|
},
|
|
3411
|
-
[disabled, readonly, time]
|
|
3595
|
+
[disabled, readonly, time, onChange]
|
|
3412
3596
|
);
|
|
3413
|
-
const handleClear =
|
|
3597
|
+
const handleClear = useCallback6(
|
|
3414
3598
|
(event) => {
|
|
3415
3599
|
event.preventDefault();
|
|
3416
3600
|
if (disabled || readonly) {
|
|
@@ -3426,7 +3610,7 @@ function AltDateWidget({
|
|
|
3426
3610
|
time,
|
|
3427
3611
|
options.yearsRange,
|
|
3428
3612
|
options.format
|
|
3429
|
-
).map((elemProps, i) => /* @__PURE__ */
|
|
3613
|
+
).map((elemProps, i) => /* @__PURE__ */ jsx35("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx35(
|
|
3430
3614
|
DateElement,
|
|
3431
3615
|
{
|
|
3432
3616
|
rootId: id,
|
|
@@ -3441,33 +3625,33 @@ function AltDateWidget({
|
|
|
3441
3625
|
autofocus: autofocus && i === 0
|
|
3442
3626
|
}
|
|
3443
3627
|
) }, i)),
|
|
3444
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */
|
|
3445
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */
|
|
3628
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx35("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx35("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString12.NowLabel) }) }),
|
|
3629
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx35("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx35("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString12.ClearLabel) }) })
|
|
3446
3630
|
] });
|
|
3447
3631
|
}
|
|
3448
3632
|
var AltDateWidget_default = AltDateWidget;
|
|
3449
3633
|
|
|
3450
3634
|
// src/components/widgets/AltDateTimeWidget.tsx
|
|
3451
|
-
import { jsx as
|
|
3635
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
3452
3636
|
function AltDateTimeWidget({
|
|
3453
3637
|
time = true,
|
|
3454
3638
|
...props
|
|
3455
3639
|
}) {
|
|
3456
3640
|
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
3457
|
-
return /* @__PURE__ */
|
|
3641
|
+
return /* @__PURE__ */ jsx36(AltDateWidget2, { time, ...props });
|
|
3458
3642
|
}
|
|
3459
3643
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
3460
3644
|
|
|
3461
3645
|
// src/components/widgets/CheckboxWidget.tsx
|
|
3462
|
-
import { useCallback as
|
|
3646
|
+
import { useCallback as useCallback7 } from "react";
|
|
3463
3647
|
import {
|
|
3464
3648
|
ariaDescribedByIds as ariaDescribedByIds3,
|
|
3465
3649
|
descriptionId as descriptionId4,
|
|
3466
|
-
getTemplate as
|
|
3650
|
+
getTemplate as getTemplate15,
|
|
3467
3651
|
labelValue,
|
|
3468
3652
|
schemaRequiresTrueValue
|
|
3469
3653
|
} from "@rjsf/utils";
|
|
3470
|
-
import { jsx as
|
|
3654
|
+
import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3471
3655
|
function CheckboxWidget({
|
|
3472
3656
|
schema,
|
|
3473
3657
|
uiSchema,
|
|
@@ -3484,27 +3668,27 @@ function CheckboxWidget({
|
|
|
3484
3668
|
onChange,
|
|
3485
3669
|
registry
|
|
3486
3670
|
}) {
|
|
3487
|
-
const DescriptionFieldTemplate =
|
|
3671
|
+
const DescriptionFieldTemplate = getTemplate15(
|
|
3488
3672
|
"DescriptionFieldTemplate",
|
|
3489
3673
|
registry,
|
|
3490
3674
|
options
|
|
3491
3675
|
);
|
|
3492
3676
|
const required = schemaRequiresTrueValue(schema);
|
|
3493
|
-
const handleChange =
|
|
3677
|
+
const handleChange = useCallback7(
|
|
3494
3678
|
(event) => onChange(event.target.checked),
|
|
3495
3679
|
[onChange]
|
|
3496
3680
|
);
|
|
3497
|
-
const handleBlur =
|
|
3681
|
+
const handleBlur = useCallback7(
|
|
3498
3682
|
(event) => onBlur(id, event.target.checked),
|
|
3499
3683
|
[onBlur, id]
|
|
3500
3684
|
);
|
|
3501
|
-
const handleFocus =
|
|
3685
|
+
const handleFocus = useCallback7(
|
|
3502
3686
|
(event) => onFocus(id, event.target.checked),
|
|
3503
3687
|
[onFocus, id]
|
|
3504
3688
|
);
|
|
3505
3689
|
const description = options.description ?? schema.description;
|
|
3506
3690
|
return /* @__PURE__ */ jsxs16("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
|
|
3507
|
-
!hideLabel && description && /* @__PURE__ */
|
|
3691
|
+
!hideLabel && description && /* @__PURE__ */ jsx37(
|
|
3508
3692
|
DescriptionFieldTemplate,
|
|
3509
3693
|
{
|
|
3510
3694
|
id: descriptionId4(id),
|
|
@@ -3515,7 +3699,7 @@ function CheckboxWidget({
|
|
|
3515
3699
|
}
|
|
3516
3700
|
),
|
|
3517
3701
|
/* @__PURE__ */ jsxs16("label", { children: [
|
|
3518
|
-
/* @__PURE__ */
|
|
3702
|
+
/* @__PURE__ */ jsx37(
|
|
3519
3703
|
"input",
|
|
3520
3704
|
{
|
|
3521
3705
|
type: "checkbox",
|
|
@@ -3531,14 +3715,14 @@ function CheckboxWidget({
|
|
|
3531
3715
|
"aria-describedby": ariaDescribedByIds3(id)
|
|
3532
3716
|
}
|
|
3533
3717
|
),
|
|
3534
|
-
labelValue(/* @__PURE__ */
|
|
3718
|
+
labelValue(/* @__PURE__ */ jsx37("span", { children: label }), hideLabel)
|
|
3535
3719
|
] })
|
|
3536
3720
|
] });
|
|
3537
3721
|
}
|
|
3538
3722
|
var CheckboxWidget_default = CheckboxWidget;
|
|
3539
3723
|
|
|
3540
3724
|
// src/components/widgets/CheckboxesWidget.tsx
|
|
3541
|
-
import { useCallback as
|
|
3725
|
+
import { useCallback as useCallback8 } from "react";
|
|
3542
3726
|
import {
|
|
3543
3727
|
ariaDescribedByIds as ariaDescribedByIds4,
|
|
3544
3728
|
enumOptionsDeselectValue,
|
|
@@ -3547,7 +3731,7 @@ import {
|
|
|
3547
3731
|
enumOptionsValueForIndex,
|
|
3548
3732
|
optionId
|
|
3549
3733
|
} from "@rjsf/utils";
|
|
3550
|
-
import { jsx as
|
|
3734
|
+
import { jsx as jsx38, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3551
3735
|
function CheckboxesWidget({
|
|
3552
3736
|
id,
|
|
3553
3737
|
disabled,
|
|
@@ -3560,15 +3744,15 @@ function CheckboxesWidget({
|
|
|
3560
3744
|
onFocus
|
|
3561
3745
|
}) {
|
|
3562
3746
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3563
|
-
const handleBlur =
|
|
3747
|
+
const handleBlur = useCallback8(
|
|
3564
3748
|
({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
3565
|
-
[onBlur, id]
|
|
3749
|
+
[onBlur, id, enumOptions, emptyValue]
|
|
3566
3750
|
);
|
|
3567
|
-
const handleFocus =
|
|
3751
|
+
const handleFocus = useCallback8(
|
|
3568
3752
|
({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
3569
|
-
[onFocus, id]
|
|
3753
|
+
[onFocus, id, enumOptions, emptyValue]
|
|
3570
3754
|
);
|
|
3571
|
-
return /* @__PURE__ */
|
|
3755
|
+
return /* @__PURE__ */ jsx38("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3572
3756
|
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
3573
3757
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3574
3758
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
@@ -3580,7 +3764,7 @@ function CheckboxesWidget({
|
|
|
3580
3764
|
}
|
|
3581
3765
|
};
|
|
3582
3766
|
const checkbox = /* @__PURE__ */ jsxs17("span", { children: [
|
|
3583
|
-
/* @__PURE__ */
|
|
3767
|
+
/* @__PURE__ */ jsx38(
|
|
3584
3768
|
"input",
|
|
3585
3769
|
{
|
|
3586
3770
|
type: "checkbox",
|
|
@@ -3596,44 +3780,44 @@ function CheckboxesWidget({
|
|
|
3596
3780
|
"aria-describedby": ariaDescribedByIds4(id)
|
|
3597
3781
|
}
|
|
3598
3782
|
),
|
|
3599
|
-
/* @__PURE__ */
|
|
3783
|
+
/* @__PURE__ */ jsx38("span", { children: option.label })
|
|
3600
3784
|
] });
|
|
3601
|
-
return inline ? /* @__PURE__ */
|
|
3785
|
+
return inline ? /* @__PURE__ */ jsx38("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsx38("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsx38("label", { children: checkbox }) }, index);
|
|
3602
3786
|
}) });
|
|
3603
3787
|
}
|
|
3604
3788
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3605
3789
|
|
|
3606
3790
|
// src/components/widgets/ColorWidget.tsx
|
|
3607
|
-
import { getTemplate as
|
|
3608
|
-
import { jsx as
|
|
3791
|
+
import { getTemplate as getTemplate16 } from "@rjsf/utils";
|
|
3792
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
3609
3793
|
function ColorWidget(props) {
|
|
3610
3794
|
const { disabled, readonly, options, registry } = props;
|
|
3611
|
-
const BaseInputTemplate2 =
|
|
3612
|
-
return /* @__PURE__ */
|
|
3795
|
+
const BaseInputTemplate2 = getTemplate16("BaseInputTemplate", registry, options);
|
|
3796
|
+
return /* @__PURE__ */ jsx39(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
|
|
3613
3797
|
}
|
|
3614
3798
|
|
|
3615
3799
|
// src/components/widgets/DateWidget.tsx
|
|
3616
|
-
import { useCallback as
|
|
3617
|
-
import { getTemplate as
|
|
3618
|
-
import { jsx as
|
|
3800
|
+
import { useCallback as useCallback9 } from "react";
|
|
3801
|
+
import { getTemplate as getTemplate17 } from "@rjsf/utils";
|
|
3802
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
3619
3803
|
function DateWidget(props) {
|
|
3620
3804
|
const { onChange, options, registry } = props;
|
|
3621
|
-
const BaseInputTemplate2 =
|
|
3622
|
-
const handleChange =
|
|
3623
|
-
return /* @__PURE__ */
|
|
3805
|
+
const BaseInputTemplate2 = getTemplate17("BaseInputTemplate", registry, options);
|
|
3806
|
+
const handleChange = useCallback9((value) => onChange(value || void 0), [onChange]);
|
|
3807
|
+
return /* @__PURE__ */ jsx40(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3624
3808
|
}
|
|
3625
3809
|
|
|
3626
3810
|
// src/components/widgets/DateTimeWidget.tsx
|
|
3627
3811
|
import {
|
|
3628
|
-
getTemplate as
|
|
3812
|
+
getTemplate as getTemplate18,
|
|
3629
3813
|
localToUTC,
|
|
3630
3814
|
utcToLocal
|
|
3631
3815
|
} from "@rjsf/utils";
|
|
3632
|
-
import { jsx as
|
|
3816
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
3633
3817
|
function DateTimeWidget(props) {
|
|
3634
3818
|
const { onChange, value, options, registry } = props;
|
|
3635
|
-
const BaseInputTemplate2 =
|
|
3636
|
-
return /* @__PURE__ */
|
|
3819
|
+
const BaseInputTemplate2 = getTemplate18("BaseInputTemplate", registry, options);
|
|
3820
|
+
return /* @__PURE__ */ jsx41(
|
|
3637
3821
|
BaseInputTemplate2,
|
|
3638
3822
|
{
|
|
3639
3823
|
type: "datetime-local",
|
|
@@ -3645,23 +3829,23 @@ function DateTimeWidget(props) {
|
|
|
3645
3829
|
}
|
|
3646
3830
|
|
|
3647
3831
|
// src/components/widgets/EmailWidget.tsx
|
|
3648
|
-
import { getTemplate as
|
|
3649
|
-
import { jsx as
|
|
3832
|
+
import { getTemplate as getTemplate19 } from "@rjsf/utils";
|
|
3833
|
+
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
3650
3834
|
function EmailWidget(props) {
|
|
3651
3835
|
const { options, registry } = props;
|
|
3652
|
-
const BaseInputTemplate2 =
|
|
3653
|
-
return /* @__PURE__ */
|
|
3836
|
+
const BaseInputTemplate2 = getTemplate19("BaseInputTemplate", registry, options);
|
|
3837
|
+
return /* @__PURE__ */ jsx42(BaseInputTemplate2, { type: "email", ...props });
|
|
3654
3838
|
}
|
|
3655
3839
|
|
|
3656
3840
|
// src/components/widgets/FileWidget.tsx
|
|
3657
|
-
import { useCallback as
|
|
3841
|
+
import { useCallback as useCallback10, useMemo as useMemo2 } from "react";
|
|
3658
3842
|
import {
|
|
3659
3843
|
dataURItoBlob,
|
|
3660
|
-
getTemplate as
|
|
3661
|
-
TranslatableString as
|
|
3844
|
+
getTemplate as getTemplate20,
|
|
3845
|
+
TranslatableString as TranslatableString13
|
|
3662
3846
|
} from "@rjsf/utils";
|
|
3663
3847
|
import Markdown4 from "markdown-to-jsx";
|
|
3664
|
-
import { Fragment as Fragment4, jsx as
|
|
3848
|
+
import { Fragment as Fragment4, jsx as jsx43, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3665
3849
|
function addNameToDataURL(dataURL, name) {
|
|
3666
3850
|
if (dataURL === null) {
|
|
3667
3851
|
return null;
|
|
@@ -3706,11 +3890,11 @@ function FileInfoPreview({
|
|
|
3706
3890
|
return null;
|
|
3707
3891
|
}
|
|
3708
3892
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3709
|
-
return /* @__PURE__ */
|
|
3893
|
+
return /* @__PURE__ */ jsx43("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3710
3894
|
}
|
|
3711
3895
|
return /* @__PURE__ */ jsxs18(Fragment4, { children: [
|
|
3712
3896
|
" ",
|
|
3713
|
-
/* @__PURE__ */
|
|
3897
|
+
/* @__PURE__ */ jsx43("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(TranslatableString13.PreviewLabel) })
|
|
3714
3898
|
] });
|
|
3715
3899
|
}
|
|
3716
3900
|
function FilesInfo({
|
|
@@ -3724,14 +3908,14 @@ function FilesInfo({
|
|
|
3724
3908
|
return null;
|
|
3725
3909
|
}
|
|
3726
3910
|
const { translateString } = registry;
|
|
3727
|
-
const { RemoveButton: RemoveButton2 } =
|
|
3728
|
-
return /* @__PURE__ */
|
|
3911
|
+
const { RemoveButton: RemoveButton2 } = getTemplate20("ButtonTemplates", registry, options);
|
|
3912
|
+
return /* @__PURE__ */ jsx43("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3729
3913
|
const { name, size, type } = fileInfo;
|
|
3730
3914
|
const handleRemove = () => onRemove(key);
|
|
3731
3915
|
return /* @__PURE__ */ jsxs18("li", { children: [
|
|
3732
|
-
/* @__PURE__ */
|
|
3733
|
-
preview && /* @__PURE__ */
|
|
3734
|
-
/* @__PURE__ */
|
|
3916
|
+
/* @__PURE__ */ jsx43(Markdown4, { children: translateString(TranslatableString13.FilesInfo, [name, type, String(size)]) }),
|
|
3917
|
+
preview && /* @__PURE__ */ jsx43(FileInfoPreview, { fileInfo, registry }),
|
|
3918
|
+
/* @__PURE__ */ jsx43(RemoveButton2, { onClick: handleRemove, registry })
|
|
3735
3919
|
] }, key);
|
|
3736
3920
|
}) });
|
|
3737
3921
|
}
|
|
@@ -3758,8 +3942,8 @@ function extractFileInfo(dataURLs) {
|
|
|
3758
3942
|
}
|
|
3759
3943
|
function FileWidget(props) {
|
|
3760
3944
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|
|
3761
|
-
const BaseInputTemplate2 =
|
|
3762
|
-
const handleChange =
|
|
3945
|
+
const BaseInputTemplate2 = getTemplate20("BaseInputTemplate", registry, options);
|
|
3946
|
+
const handleChange = useCallback10(
|
|
3763
3947
|
(event) => {
|
|
3764
3948
|
if (!event.target.files) {
|
|
3765
3949
|
return;
|
|
@@ -3776,7 +3960,7 @@ function FileWidget(props) {
|
|
|
3776
3960
|
[multiple, value, onChange]
|
|
3777
3961
|
);
|
|
3778
3962
|
const filesInfo = useMemo2(() => extractFileInfo(Array.isArray(value) ? value : [value]), [value]);
|
|
3779
|
-
const rmFile =
|
|
3963
|
+
const rmFile = useCallback10(
|
|
3780
3964
|
(index) => {
|
|
3781
3965
|
if (multiple) {
|
|
3782
3966
|
const newValue = value.filter((_, i) => i !== index);
|
|
@@ -3788,7 +3972,7 @@ function FileWidget(props) {
|
|
|
3788
3972
|
[multiple, value, onChange]
|
|
3789
3973
|
);
|
|
3790
3974
|
return /* @__PURE__ */ jsxs18("div", { children: [
|
|
3791
|
-
/* @__PURE__ */
|
|
3975
|
+
/* @__PURE__ */ jsx43(
|
|
3792
3976
|
BaseInputTemplate2,
|
|
3793
3977
|
{
|
|
3794
3978
|
...props,
|
|
@@ -3800,7 +3984,7 @@ function FileWidget(props) {
|
|
|
3800
3984
|
accept: options.accept ? String(options.accept) : void 0
|
|
3801
3985
|
}
|
|
3802
3986
|
),
|
|
3803
|
-
/* @__PURE__ */
|
|
3987
|
+
/* @__PURE__ */ jsx43(
|
|
3804
3988
|
FilesInfo,
|
|
3805
3989
|
{
|
|
3806
3990
|
filesInfo,
|
|
@@ -3815,33 +3999,33 @@ function FileWidget(props) {
|
|
|
3815
3999
|
var FileWidget_default = FileWidget;
|
|
3816
4000
|
|
|
3817
4001
|
// src/components/widgets/HiddenWidget.tsx
|
|
3818
|
-
import { jsx as
|
|
4002
|
+
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
3819
4003
|
function HiddenWidget({
|
|
3820
4004
|
id,
|
|
3821
4005
|
value
|
|
3822
4006
|
}) {
|
|
3823
|
-
return /* @__PURE__ */
|
|
4007
|
+
return /* @__PURE__ */ jsx44("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
|
|
3824
4008
|
}
|
|
3825
4009
|
var HiddenWidget_default = HiddenWidget;
|
|
3826
4010
|
|
|
3827
4011
|
// src/components/widgets/PasswordWidget.tsx
|
|
3828
|
-
import { getTemplate as
|
|
3829
|
-
import { jsx as
|
|
4012
|
+
import { getTemplate as getTemplate21 } from "@rjsf/utils";
|
|
4013
|
+
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
3830
4014
|
function PasswordWidget(props) {
|
|
3831
4015
|
const { options, registry } = props;
|
|
3832
|
-
const BaseInputTemplate2 =
|
|
3833
|
-
return /* @__PURE__ */
|
|
4016
|
+
const BaseInputTemplate2 = getTemplate21("BaseInputTemplate", registry, options);
|
|
4017
|
+
return /* @__PURE__ */ jsx45(BaseInputTemplate2, { type: "password", ...props });
|
|
3834
4018
|
}
|
|
3835
4019
|
|
|
3836
4020
|
// src/components/widgets/RadioWidget.tsx
|
|
3837
|
-
import { useCallback as
|
|
4021
|
+
import { useCallback as useCallback11 } from "react";
|
|
3838
4022
|
import {
|
|
3839
4023
|
ariaDescribedByIds as ariaDescribedByIds5,
|
|
3840
4024
|
enumOptionsIsSelected as enumOptionsIsSelected2,
|
|
3841
4025
|
enumOptionsValueForIndex as enumOptionsValueForIndex2,
|
|
3842
4026
|
optionId as optionId2
|
|
3843
4027
|
} from "@rjsf/utils";
|
|
3844
|
-
import { jsx as
|
|
4028
|
+
import { jsx as jsx46, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3845
4029
|
function RadioWidget({
|
|
3846
4030
|
options,
|
|
3847
4031
|
value,
|
|
@@ -3855,21 +4039,21 @@ function RadioWidget({
|
|
|
3855
4039
|
id
|
|
3856
4040
|
}) {
|
|
3857
4041
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3858
|
-
const handleBlur =
|
|
4042
|
+
const handleBlur = useCallback11(
|
|
3859
4043
|
({ target }) => onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
|
|
3860
4044
|
[onBlur, enumOptions, emptyValue, id]
|
|
3861
4045
|
);
|
|
3862
|
-
const handleFocus =
|
|
4046
|
+
const handleFocus = useCallback11(
|
|
3863
4047
|
({ target }) => onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
|
|
3864
4048
|
[onFocus, enumOptions, emptyValue, id]
|
|
3865
4049
|
);
|
|
3866
|
-
return /* @__PURE__ */
|
|
4050
|
+
return /* @__PURE__ */ jsx46("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3867
4051
|
const checked = enumOptionsIsSelected2(option.value, value);
|
|
3868
4052
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3869
4053
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3870
4054
|
const handleChange = () => onChange(option.value);
|
|
3871
4055
|
const radio = /* @__PURE__ */ jsxs19("span", { children: [
|
|
3872
|
-
/* @__PURE__ */
|
|
4056
|
+
/* @__PURE__ */ jsx46(
|
|
3873
4057
|
"input",
|
|
3874
4058
|
{
|
|
3875
4059
|
type: "radio",
|
|
@@ -3886,15 +4070,15 @@ function RadioWidget({
|
|
|
3886
4070
|
"aria-describedby": ariaDescribedByIds5(id)
|
|
3887
4071
|
}
|
|
3888
4072
|
),
|
|
3889
|
-
/* @__PURE__ */
|
|
4073
|
+
/* @__PURE__ */ jsx46("span", { children: option.label })
|
|
3890
4074
|
] });
|
|
3891
|
-
return inline ? /* @__PURE__ */
|
|
4075
|
+
return inline ? /* @__PURE__ */ jsx46("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ jsx46("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsx46("label", { children: radio }) }, i);
|
|
3892
4076
|
}) });
|
|
3893
4077
|
}
|
|
3894
4078
|
var RadioWidget_default = RadioWidget;
|
|
3895
4079
|
|
|
3896
4080
|
// src/components/widgets/RangeWidget.tsx
|
|
3897
|
-
import { jsx as
|
|
4081
|
+
import { jsx as jsx47, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3898
4082
|
function RangeWidget(props) {
|
|
3899
4083
|
const {
|
|
3900
4084
|
value,
|
|
@@ -3903,14 +4087,14 @@ function RangeWidget(props) {
|
|
|
3903
4087
|
}
|
|
3904
4088
|
} = props;
|
|
3905
4089
|
return /* @__PURE__ */ jsxs20("div", { className: "field-range-wrapper", children: [
|
|
3906
|
-
/* @__PURE__ */
|
|
3907
|
-
/* @__PURE__ */
|
|
4090
|
+
/* @__PURE__ */ jsx47(BaseInputTemplate2, { type: "range", ...props }),
|
|
4091
|
+
/* @__PURE__ */ jsx47("span", { className: "range-view", children: value })
|
|
3908
4092
|
] });
|
|
3909
4093
|
}
|
|
3910
4094
|
|
|
3911
4095
|
// src/components/widgets/RatingWidget.tsx
|
|
3912
|
-
import { useCallback as
|
|
3913
|
-
import { Fragment as Fragment5, jsx as
|
|
4096
|
+
import { useCallback as useCallback12 } from "react";
|
|
4097
|
+
import { Fragment as Fragment5, jsx as jsx48, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3914
4098
|
function RatingWidget({
|
|
3915
4099
|
id,
|
|
3916
4100
|
value,
|
|
@@ -3927,7 +4111,7 @@ function RatingWidget({
|
|
|
3927
4111
|
const { stars = 5, shape = "star" } = options;
|
|
3928
4112
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3929
4113
|
const min = schema.minimum || 0;
|
|
3930
|
-
const handleStarClick =
|
|
4114
|
+
const handleStarClick = useCallback12(
|
|
3931
4115
|
(starValue) => {
|
|
3932
4116
|
if (!disabled && !readonly) {
|
|
3933
4117
|
onChange(starValue);
|
|
@@ -3935,7 +4119,7 @@ function RatingWidget({
|
|
|
3935
4119
|
},
|
|
3936
4120
|
[onChange, disabled, readonly]
|
|
3937
4121
|
);
|
|
3938
|
-
const handleFocus =
|
|
4122
|
+
const handleFocus = useCallback12(
|
|
3939
4123
|
(event) => {
|
|
3940
4124
|
if (onFocus) {
|
|
3941
4125
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3944,7 +4128,7 @@ function RatingWidget({
|
|
|
3944
4128
|
},
|
|
3945
4129
|
[onFocus, id]
|
|
3946
4130
|
);
|
|
3947
|
-
const handleBlur =
|
|
4131
|
+
const handleBlur = useCallback12(
|
|
3948
4132
|
(event) => {
|
|
3949
4133
|
if (onBlur) {
|
|
3950
4134
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3959,7 +4143,7 @@ function RatingWidget({
|
|
|
3959
4143
|
}
|
|
3960
4144
|
return isFilled ? "\u2605" : "\u2606";
|
|
3961
4145
|
};
|
|
3962
|
-
return /* @__PURE__ */
|
|
4146
|
+
return /* @__PURE__ */ jsx48(Fragment5, { children: /* @__PURE__ */ jsxs21(
|
|
3963
4147
|
"div",
|
|
3964
4148
|
{
|
|
3965
4149
|
className: "rating-widget",
|
|
@@ -3972,7 +4156,7 @@ function RatingWidget({
|
|
|
3972
4156
|
[...Array(numStars)].map((_, index) => {
|
|
3973
4157
|
const starValue = min + index;
|
|
3974
4158
|
const isFilled = starValue <= value;
|
|
3975
|
-
return /* @__PURE__ */
|
|
4159
|
+
return /* @__PURE__ */ jsx48(
|
|
3976
4160
|
"span",
|
|
3977
4161
|
{
|
|
3978
4162
|
onClick: () => handleStarClick(starValue),
|
|
@@ -3994,7 +4178,7 @@ function RatingWidget({
|
|
|
3994
4178
|
index
|
|
3995
4179
|
);
|
|
3996
4180
|
}),
|
|
3997
|
-
/* @__PURE__ */
|
|
4181
|
+
/* @__PURE__ */ jsx48(
|
|
3998
4182
|
"input",
|
|
3999
4183
|
{
|
|
4000
4184
|
type: "hidden",
|
|
@@ -4012,13 +4196,13 @@ function RatingWidget({
|
|
|
4012
4196
|
}
|
|
4013
4197
|
|
|
4014
4198
|
// src/components/widgets/SelectWidget.tsx
|
|
4015
|
-
import { useCallback as
|
|
4199
|
+
import { useCallback as useCallback13 } from "react";
|
|
4016
4200
|
import {
|
|
4017
4201
|
ariaDescribedByIds as ariaDescribedByIds6,
|
|
4018
4202
|
enumOptionsIndexForValue,
|
|
4019
4203
|
enumOptionsValueForIndex as enumOptionsValueForIndex3
|
|
4020
4204
|
} from "@rjsf/utils";
|
|
4021
|
-
import { jsx as
|
|
4205
|
+
import { jsx as jsx49, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4022
4206
|
function getValue(event, multiple) {
|
|
4023
4207
|
if (multiple) {
|
|
4024
4208
|
return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
|
|
@@ -4042,21 +4226,21 @@ function SelectWidget({
|
|
|
4042
4226
|
}) {
|
|
4043
4227
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
4044
4228
|
const emptyValue = multiple ? [] : "";
|
|
4045
|
-
const handleFocus =
|
|
4229
|
+
const handleFocus = useCallback13(
|
|
4046
4230
|
(event) => {
|
|
4047
4231
|
const newValue = getValue(event, multiple);
|
|
4048
4232
|
return onFocus(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
|
|
4049
4233
|
},
|
|
4050
4234
|
[onFocus, id, multiple, enumOptions, optEmptyVal]
|
|
4051
4235
|
);
|
|
4052
|
-
const handleBlur =
|
|
4236
|
+
const handleBlur = useCallback13(
|
|
4053
4237
|
(event) => {
|
|
4054
4238
|
const newValue = getValue(event, multiple);
|
|
4055
4239
|
return onBlur(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
|
|
4056
4240
|
},
|
|
4057
4241
|
[onBlur, id, multiple, enumOptions, optEmptyVal]
|
|
4058
4242
|
);
|
|
4059
|
-
const handleChange =
|
|
4243
|
+
const handleChange = useCallback13(
|
|
4060
4244
|
(event) => {
|
|
4061
4245
|
const newValue = getValue(event, multiple);
|
|
4062
4246
|
return onChange(enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
|
|
@@ -4082,10 +4266,10 @@ function SelectWidget({
|
|
|
4082
4266
|
onChange: handleChange,
|
|
4083
4267
|
"aria-describedby": ariaDescribedByIds6(id),
|
|
4084
4268
|
children: [
|
|
4085
|
-
showPlaceholderOption && /* @__PURE__ */
|
|
4269
|
+
showPlaceholderOption && /* @__PURE__ */ jsx49("option", { value: "", children: placeholder }),
|
|
4086
4270
|
Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
|
|
4087
4271
|
const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
|
|
4088
|
-
return /* @__PURE__ */
|
|
4272
|
+
return /* @__PURE__ */ jsx49("option", { value: String(i), disabled: disabled2, children: label }, i);
|
|
4089
4273
|
})
|
|
4090
4274
|
]
|
|
4091
4275
|
}
|
|
@@ -4094,9 +4278,9 @@ function SelectWidget({
|
|
|
4094
4278
|
var SelectWidget_default = SelectWidget;
|
|
4095
4279
|
|
|
4096
4280
|
// src/components/widgets/TextareaWidget.tsx
|
|
4097
|
-
import { useCallback as
|
|
4281
|
+
import { useCallback as useCallback14 } from "react";
|
|
4098
4282
|
import { ariaDescribedByIds as ariaDescribedByIds7 } from "@rjsf/utils";
|
|
4099
|
-
import { jsx as
|
|
4283
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
4100
4284
|
function TextareaWidget({
|
|
4101
4285
|
id,
|
|
4102
4286
|
options = {},
|
|
@@ -4110,19 +4294,19 @@ function TextareaWidget({
|
|
|
4110
4294
|
onBlur,
|
|
4111
4295
|
onFocus
|
|
4112
4296
|
}) {
|
|
4113
|
-
const handleChange =
|
|
4297
|
+
const handleChange = useCallback14(
|
|
4114
4298
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
4115
4299
|
[onChange, options.emptyValue]
|
|
4116
4300
|
);
|
|
4117
|
-
const handleBlur =
|
|
4301
|
+
const handleBlur = useCallback14(
|
|
4118
4302
|
({ target }) => onBlur(id, target && target.value),
|
|
4119
4303
|
[onBlur, id]
|
|
4120
4304
|
);
|
|
4121
|
-
const handleFocus =
|
|
4305
|
+
const handleFocus = useCallback14(
|
|
4122
4306
|
({ target }) => onFocus(id, target && target.value),
|
|
4123
4307
|
[id, onFocus]
|
|
4124
4308
|
);
|
|
4125
|
-
return /* @__PURE__ */
|
|
4309
|
+
return /* @__PURE__ */ jsx50(
|
|
4126
4310
|
"textarea",
|
|
4127
4311
|
{
|
|
4128
4312
|
id,
|
|
@@ -4149,41 +4333,41 @@ TextareaWidget.defaultProps = {
|
|
|
4149
4333
|
var TextareaWidget_default = TextareaWidget;
|
|
4150
4334
|
|
|
4151
4335
|
// src/components/widgets/TextWidget.tsx
|
|
4152
|
-
import { getTemplate as
|
|
4153
|
-
import { jsx as
|
|
4336
|
+
import { getTemplate as getTemplate22 } from "@rjsf/utils";
|
|
4337
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
4154
4338
|
function TextWidget(props) {
|
|
4155
4339
|
const { options, registry } = props;
|
|
4156
|
-
const BaseInputTemplate2 =
|
|
4157
|
-
return /* @__PURE__ */
|
|
4340
|
+
const BaseInputTemplate2 = getTemplate22("BaseInputTemplate", registry, options);
|
|
4341
|
+
return /* @__PURE__ */ jsx51(BaseInputTemplate2, { ...props });
|
|
4158
4342
|
}
|
|
4159
4343
|
|
|
4160
4344
|
// src/components/widgets/TimeWidget.tsx
|
|
4161
|
-
import { useCallback as
|
|
4162
|
-
import { getTemplate as
|
|
4163
|
-
import { jsx as
|
|
4345
|
+
import { useCallback as useCallback15 } from "react";
|
|
4346
|
+
import { getTemplate as getTemplate23 } from "@rjsf/utils";
|
|
4347
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
4164
4348
|
function TimeWidget(props) {
|
|
4165
4349
|
const { onChange, options, registry } = props;
|
|
4166
|
-
const BaseInputTemplate2 =
|
|
4167
|
-
const handleChange =
|
|
4168
|
-
return /* @__PURE__ */
|
|
4350
|
+
const BaseInputTemplate2 = getTemplate23("BaseInputTemplate", registry, options);
|
|
4351
|
+
const handleChange = useCallback15((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
4352
|
+
return /* @__PURE__ */ jsx52(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
4169
4353
|
}
|
|
4170
4354
|
|
|
4171
4355
|
// src/components/widgets/URLWidget.tsx
|
|
4172
|
-
import { getTemplate as
|
|
4173
|
-
import { jsx as
|
|
4356
|
+
import { getTemplate as getTemplate24 } from "@rjsf/utils";
|
|
4357
|
+
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
4174
4358
|
function URLWidget(props) {
|
|
4175
4359
|
const { options, registry } = props;
|
|
4176
|
-
const BaseInputTemplate2 =
|
|
4177
|
-
return /* @__PURE__ */
|
|
4360
|
+
const BaseInputTemplate2 = getTemplate24("BaseInputTemplate", registry, options);
|
|
4361
|
+
return /* @__PURE__ */ jsx53(BaseInputTemplate2, { type: "url", ...props });
|
|
4178
4362
|
}
|
|
4179
4363
|
|
|
4180
4364
|
// src/components/widgets/UpDownWidget.tsx
|
|
4181
|
-
import { getTemplate as
|
|
4182
|
-
import { jsx as
|
|
4365
|
+
import { getTemplate as getTemplate25 } from "@rjsf/utils";
|
|
4366
|
+
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
4183
4367
|
function UpDownWidget(props) {
|
|
4184
4368
|
const { options, registry } = props;
|
|
4185
|
-
const BaseInputTemplate2 =
|
|
4186
|
-
return /* @__PURE__ */
|
|
4369
|
+
const BaseInputTemplate2 = getTemplate25("BaseInputTemplate", registry, options);
|
|
4370
|
+
return /* @__PURE__ */ jsx54(BaseInputTemplate2, { type: "number", ...props });
|
|
4187
4371
|
}
|
|
4188
4372
|
|
|
4189
4373
|
// src/components/widgets/index.ts
|
|
@@ -4221,17 +4405,21 @@ function getDefaultRegistry() {
|
|
|
4221
4405
|
widgets: widgets_default(),
|
|
4222
4406
|
rootSchema: {},
|
|
4223
4407
|
formContext: {},
|
|
4224
|
-
translateString: englishStringTranslator
|
|
4408
|
+
translateString: englishStringTranslator,
|
|
4409
|
+
globalFormOptions: { idPrefix: DEFAULT_ID_PREFIX, idSeparator: DEFAULT_ID_SEPARATOR }
|
|
4225
4410
|
};
|
|
4226
4411
|
}
|
|
4227
4412
|
|
|
4228
4413
|
// src/components/Form.tsx
|
|
4229
|
-
import { jsx as
|
|
4414
|
+
import { jsx as jsx55, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4230
4415
|
var Form = class extends Component5 {
|
|
4231
4416
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4232
4417
|
* provide any possible type here
|
|
4233
4418
|
*/
|
|
4234
4419
|
formElement;
|
|
4420
|
+
/** The list of pending changes
|
|
4421
|
+
*/
|
|
4422
|
+
pendingChanges = [];
|
|
4235
4423
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
4236
4424
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
4237
4425
|
* state construction.
|
|
@@ -4244,7 +4432,7 @@ var Form = class extends Component5 {
|
|
|
4244
4432
|
throw new Error("A validator is required for Form functionality to work");
|
|
4245
4433
|
}
|
|
4246
4434
|
this.state = this.getStateFromProps(props, props.formData);
|
|
4247
|
-
if (this.props.onChange && !
|
|
4435
|
+
if (this.props.onChange && !deepEquals2(this.state.formData, this.props.formData)) {
|
|
4248
4436
|
this.props.onChange(this.state);
|
|
4249
4437
|
}
|
|
4250
4438
|
this.formElement = createRef();
|
|
@@ -4268,10 +4456,12 @@ var Form = class extends Component5 {
|
|
|
4268
4456
|
* with a flag indicating that an update is not necessary.
|
|
4269
4457
|
*/
|
|
4270
4458
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
4271
|
-
if (!
|
|
4459
|
+
if (!deepEquals2(this.props, prevProps)) {
|
|
4272
4460
|
const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
|
|
4273
|
-
const
|
|
4274
|
-
const
|
|
4461
|
+
const stateDataChangedFields = getChangedFields(this.props.formData, this.state.formData);
|
|
4462
|
+
const isSchemaChanged = !deepEquals2(prevProps.schema, this.props.schema);
|
|
4463
|
+
const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals2(prevProps.formData, this.props.formData);
|
|
4464
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !deepEquals2(this.state.formData, this.props.formData);
|
|
4275
4465
|
const nextState = this.getStateFromProps(
|
|
4276
4466
|
this.props,
|
|
4277
4467
|
this.props.formData,
|
|
@@ -4280,9 +4470,11 @@ var Form = class extends Component5 {
|
|
|
4280
4470
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
4281
4471
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
4282
4472
|
isSchemaChanged,
|
|
4283
|
-
formDataChangedFields
|
|
4473
|
+
formDataChangedFields,
|
|
4474
|
+
// Skip live validation for this request if no form data has changed from the last state
|
|
4475
|
+
!isStateDataChanged
|
|
4284
4476
|
);
|
|
4285
|
-
const shouldUpdate = !
|
|
4477
|
+
const shouldUpdate = !deepEquals2(nextState, prevState);
|
|
4286
4478
|
return { nextState, shouldUpdate };
|
|
4287
4479
|
}
|
|
4288
4480
|
return { shouldUpdate: false };
|
|
@@ -4302,7 +4494,7 @@ var Form = class extends Component5 {
|
|
|
4302
4494
|
componentDidUpdate(_, prevState, snapshot) {
|
|
4303
4495
|
if (snapshot.shouldUpdate) {
|
|
4304
4496
|
const { nextState } = snapshot;
|
|
4305
|
-
if (!
|
|
4497
|
+
if (!deepEquals2(nextState.formData, this.props.formData) && !deepEquals2(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
4306
4498
|
this.props.onChange(nextState);
|
|
4307
4499
|
}
|
|
4308
4500
|
this.setState(nextState);
|
|
@@ -4317,35 +4509,42 @@ var Form = class extends Component5 {
|
|
|
4317
4509
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4318
4510
|
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
4319
4511
|
* @param formDataChangedFields - The changed fields of `formData`
|
|
4512
|
+
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
4320
4513
|
* @returns - The new state for the `Form`
|
|
4321
4514
|
*/
|
|
4322
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
|
|
4515
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
4323
4516
|
const state = this.state || {};
|
|
4324
4517
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4518
|
+
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
4325
4519
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
4326
4520
|
const edit = typeof inputFormData !== "undefined";
|
|
4327
4521
|
const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
|
|
4328
4522
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
4329
|
-
const rootSchema = schema;
|
|
4330
4523
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4331
4524
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
4332
4525
|
let schemaUtils = state.schemaUtils;
|
|
4333
4526
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
4334
|
-
|
|
4335
|
-
|
|
4527
|
+
validator2,
|
|
4528
|
+
schema,
|
|
4336
4529
|
experimental_defaultFormStateBehavior,
|
|
4337
4530
|
experimental_customMergeAllOf
|
|
4338
4531
|
)) {
|
|
4339
4532
|
schemaUtils = createSchemaUtils(
|
|
4340
|
-
|
|
4341
|
-
|
|
4533
|
+
validator2,
|
|
4534
|
+
schema,
|
|
4342
4535
|
experimental_defaultFormStateBehavior,
|
|
4343
4536
|
experimental_customMergeAllOf
|
|
4344
4537
|
);
|
|
4345
4538
|
}
|
|
4346
|
-
const
|
|
4539
|
+
const rootSchema = schemaUtils.getRootSchema();
|
|
4540
|
+
const formData = schemaUtils.getDefaultFormState(
|
|
4541
|
+
rootSchema,
|
|
4542
|
+
inputFormData,
|
|
4543
|
+
false,
|
|
4544
|
+
state.initialDefaultsGenerated
|
|
4545
|
+
);
|
|
4347
4546
|
const _retrievedSchema = this.updateRetrievedSchema(
|
|
4348
|
-
retrievedSchema ?? schemaUtils.retrieveSchema(
|
|
4547
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4349
4548
|
);
|
|
4350
4549
|
const getCurrentErrors = () => {
|
|
4351
4550
|
if (props.noValidate || isSchemaChanged) {
|
|
@@ -4365,25 +4564,28 @@ var Form = class extends Component5 {
|
|
|
4365
4564
|
let errorSchema;
|
|
4366
4565
|
let schemaValidationErrors = state.schemaValidationErrors;
|
|
4367
4566
|
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
4368
|
-
if (mustValidate) {
|
|
4369
|
-
const
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4567
|
+
if (mustValidate && !skipLiveValidate) {
|
|
4568
|
+
const liveValidation = this.liveValidate(
|
|
4569
|
+
rootSchema,
|
|
4570
|
+
schemaUtils,
|
|
4571
|
+
state.errorSchema,
|
|
4572
|
+
formData,
|
|
4573
|
+
void 0,
|
|
4574
|
+
state.customErrors,
|
|
4575
|
+
retrievedSchema,
|
|
4576
|
+
// If retrievedSchema is undefined which means the schema or formData has changed, we do not merge state.
|
|
4577
|
+
// Else in the case where it hasn't changed,
|
|
4578
|
+
retrievedSchema !== void 0
|
|
4579
|
+
);
|
|
4580
|
+
errors = liveValidation.errors;
|
|
4581
|
+
errorSchema = liveValidation.errorSchema;
|
|
4582
|
+
schemaValidationErrors = liveValidation.schemaValidationErrors;
|
|
4583
|
+
schemaValidationErrorSchema = liveValidation.schemaValidationErrorSchema;
|
|
4382
4584
|
} else {
|
|
4383
4585
|
const currentErrors = getCurrentErrors();
|
|
4384
4586
|
errors = currentErrors.errors;
|
|
4385
4587
|
errorSchema = currentErrors.errorSchema;
|
|
4386
|
-
if (formDataChangedFields.length > 0) {
|
|
4588
|
+
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
4387
4589
|
const newErrorSchema = formDataChangedFields.reduce(
|
|
4388
4590
|
(acc, key) => {
|
|
4389
4591
|
acc[key] = void 0;
|
|
@@ -4391,37 +4593,30 @@ var Form = class extends Component5 {
|
|
|
4391
4593
|
},
|
|
4392
4594
|
{}
|
|
4393
4595
|
);
|
|
4394
|
-
errorSchema = schemaValidationErrorSchema =
|
|
4596
|
+
errorSchema = schemaValidationErrorSchema = mergeObjects(
|
|
4395
4597
|
currentErrors.errorSchema,
|
|
4396
4598
|
newErrorSchema,
|
|
4397
4599
|
"preventDuplicates"
|
|
4398
4600
|
);
|
|
4399
4601
|
}
|
|
4602
|
+
const mergedErrors = this.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
4603
|
+
errors = mergedErrors.errors;
|
|
4604
|
+
errorSchema = mergedErrors.errorSchema;
|
|
4400
4605
|
}
|
|
4401
|
-
|
|
4402
|
-
const merged = validationDataMerge({ errorSchema, errors }, props.extraErrors);
|
|
4403
|
-
errorSchema = merged.errorSchema;
|
|
4404
|
-
errors = merged.errors;
|
|
4405
|
-
}
|
|
4406
|
-
const idSchema = schemaUtils.toIdSchema(
|
|
4407
|
-
_retrievedSchema,
|
|
4408
|
-
uiSchema["ui:rootFieldId"],
|
|
4409
|
-
formData,
|
|
4410
|
-
props.idPrefix,
|
|
4411
|
-
props.idSeparator
|
|
4412
|
-
);
|
|
4606
|
+
const fieldPathId = toFieldPathId4("", this.getGlobalFormOptions(this.props));
|
|
4413
4607
|
const nextState = {
|
|
4414
4608
|
schemaUtils,
|
|
4415
|
-
schema,
|
|
4609
|
+
schema: rootSchema,
|
|
4416
4610
|
uiSchema,
|
|
4417
|
-
|
|
4611
|
+
fieldPathId,
|
|
4418
4612
|
formData,
|
|
4419
4613
|
edit,
|
|
4420
4614
|
errors,
|
|
4421
4615
|
errorSchema,
|
|
4422
4616
|
schemaValidationErrors,
|
|
4423
4617
|
schemaValidationErrorSchema,
|
|
4424
|
-
retrievedSchema: _retrievedSchema
|
|
4618
|
+
retrievedSchema: _retrievedSchema,
|
|
4619
|
+
initialDefaultsGenerated: true
|
|
4425
4620
|
};
|
|
4426
4621
|
return nextState;
|
|
4427
4622
|
}
|
|
@@ -4432,31 +4627,18 @@ var Form = class extends Component5 {
|
|
|
4432
4627
|
* @returns - True if the component should be updated, false otherwise
|
|
4433
4628
|
*/
|
|
4434
4629
|
shouldComponentUpdate(nextProps, nextState) {
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
/** Gets the previously raised customValidate errors.
|
|
4438
|
-
*
|
|
4439
|
-
* @returns the previous customValidate errors
|
|
4440
|
-
*/
|
|
4441
|
-
getPreviousCustomValidateErrors() {
|
|
4442
|
-
const { customValidate, uiSchema } = this.props;
|
|
4443
|
-
const prevFormData = this.state.formData;
|
|
4444
|
-
let customValidateErrors = {};
|
|
4445
|
-
if (typeof customValidate === "function") {
|
|
4446
|
-
const errorHandler = customValidate(prevFormData, createErrorHandler(prevFormData), uiSchema);
|
|
4447
|
-
const userErrorSchema = unwrapErrorHandler(errorHandler);
|
|
4448
|
-
customValidateErrors = userErrorSchema;
|
|
4449
|
-
}
|
|
4450
|
-
return customValidateErrors;
|
|
4630
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = this.props;
|
|
4631
|
+
return shouldRender2(this, nextProps, nextState, experimental_componentUpdateStrategy);
|
|
4451
4632
|
}
|
|
4452
4633
|
/** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
|
|
4453
4634
|
* `schemaUtils` in the state), returning the results.
|
|
4454
4635
|
*
|
|
4455
4636
|
* @param formData - The new form data to validate
|
|
4456
4637
|
* @param schema - The schema used to validate against
|
|
4457
|
-
* @param altSchemaUtils - The alternate schemaUtils to use for validation
|
|
4638
|
+
* @param [altSchemaUtils] - The alternate schemaUtils to use for validation
|
|
4639
|
+
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
4458
4640
|
*/
|
|
4459
|
-
validate(formData, schema = this.
|
|
4641
|
+
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
4460
4642
|
const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
|
|
4461
4643
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4462
4644
|
const resolvedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
@@ -4465,24 +4647,75 @@ var Form = class extends Component5 {
|
|
|
4465
4647
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4466
4648
|
renderErrors(registry) {
|
|
4467
4649
|
const { errors, errorSchema, schema, uiSchema } = this.state;
|
|
4468
|
-
const
|
|
4469
|
-
const
|
|
4470
|
-
const ErrorListTemplate = getTemplate24("ErrorListTemplate", registry, options);
|
|
4650
|
+
const options = getUiOptions18(uiSchema);
|
|
4651
|
+
const ErrorListTemplate = getTemplate26("ErrorListTemplate", registry, options);
|
|
4471
4652
|
if (errors && errors.length) {
|
|
4472
|
-
return /* @__PURE__ */
|
|
4653
|
+
return /* @__PURE__ */ jsx55(
|
|
4473
4654
|
ErrorListTemplate,
|
|
4474
4655
|
{
|
|
4475
4656
|
errors,
|
|
4476
4657
|
errorSchema: errorSchema || {},
|
|
4477
4658
|
schema,
|
|
4478
4659
|
uiSchema,
|
|
4479
|
-
formContext,
|
|
4480
4660
|
registry
|
|
4481
4661
|
}
|
|
4482
4662
|
);
|
|
4483
4663
|
}
|
|
4484
4664
|
return null;
|
|
4485
4665
|
}
|
|
4666
|
+
/** Merges any `extraErrors` or `customErrors` into the given `schemaValidation` object, returning the result
|
|
4667
|
+
*
|
|
4668
|
+
* @param schemaValidation - The `ValidationData` object into which additional errors are merged
|
|
4669
|
+
* @param [extraErrors] - The extra errors from the props
|
|
4670
|
+
* @param [customErrors] - The customErrors from custom components
|
|
4671
|
+
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
4672
|
+
* @private
|
|
4673
|
+
*/
|
|
4674
|
+
mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4675
|
+
let errorSchema = schemaValidation.errorSchema;
|
|
4676
|
+
let errors = schemaValidation.errors;
|
|
4677
|
+
if (extraErrors) {
|
|
4678
|
+
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
4679
|
+
errorSchema = merged.errorSchema;
|
|
4680
|
+
errors = merged.errors;
|
|
4681
|
+
}
|
|
4682
|
+
if (customErrors) {
|
|
4683
|
+
const merged = validationDataMerge(schemaValidation, customErrors.ErrorSchema, true);
|
|
4684
|
+
errorSchema = merged.errorSchema;
|
|
4685
|
+
errors = merged.errors;
|
|
4686
|
+
}
|
|
4687
|
+
return { errors, errorSchema };
|
|
4688
|
+
}
|
|
4689
|
+
/** Performs live validation and then updates and returns the errors and error schemas by potentially merging in
|
|
4690
|
+
* `extraErrors` and `customErrors`.
|
|
4691
|
+
*
|
|
4692
|
+
* @param rootSchema - The `rootSchema` from the state
|
|
4693
|
+
* @param schemaUtils - The `SchemaUtilsType` from the state
|
|
4694
|
+
* @param originalErrorSchema - The original `ErrorSchema` from the state
|
|
4695
|
+
* @param [formData] - The new form data to validate
|
|
4696
|
+
* @param [extraErrors] - The extra errors from the props
|
|
4697
|
+
* @param [customErrors] - The customErrors from custom components
|
|
4698
|
+
* @param [retrievedSchema] - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`
|
|
4699
|
+
* @param [mergeIntoOriginalErrorSchema=false] - Optional flag indicating whether we merge into original schema
|
|
4700
|
+
* @returns - An object containing `errorSchema`, `errors`, `schemaValidationErrors` and `schemaValidationErrorSchema`
|
|
4701
|
+
* @private
|
|
4702
|
+
*/
|
|
4703
|
+
liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
|
|
4704
|
+
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
|
|
4705
|
+
const errors = schemaValidation.errors;
|
|
4706
|
+
let errorSchema = schemaValidation.errorSchema;
|
|
4707
|
+
if (mergeIntoOriginalErrorSchema) {
|
|
4708
|
+
errorSchema = mergeObjects(
|
|
4709
|
+
originalErrorSchema,
|
|
4710
|
+
schemaValidation.errorSchema,
|
|
4711
|
+
"preventDuplicates"
|
|
4712
|
+
);
|
|
4713
|
+
}
|
|
4714
|
+
const schemaValidationErrors = errors;
|
|
4715
|
+
const schemaValidationErrorSchema = errorSchema;
|
|
4716
|
+
const mergedErrors = this.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
|
|
4717
|
+
return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
|
|
4718
|
+
}
|
|
4486
4719
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
4487
4720
|
*
|
|
4488
4721
|
* @param formData - The data for the `Form`
|
|
@@ -4504,19 +4737,23 @@ var Form = class extends Component5 {
|
|
|
4504
4737
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4505
4738
|
*/
|
|
4506
4739
|
getFieldNames = (pathSchema, formData) => {
|
|
4740
|
+
const formValueHasData = (value, isLeaf) => typeof value !== "object" || _isEmpty(value) || isLeaf && !_isEmpty(value);
|
|
4507
4741
|
const getAllPaths = (_obj, acc = [], paths = [[]]) => {
|
|
4508
|
-
Object.keys(_obj)
|
|
4509
|
-
|
|
4742
|
+
const objKeys = Object.keys(_obj);
|
|
4743
|
+
objKeys.forEach((key) => {
|
|
4744
|
+
const data = _obj[key];
|
|
4745
|
+
if (typeof data === "object") {
|
|
4510
4746
|
const newPaths = paths.map((path) => [...path, key]);
|
|
4511
|
-
if (
|
|
4512
|
-
acc.push(
|
|
4747
|
+
if (data[RJSF_ADDITIONAL_PROPERTIES_FLAG] && data[NAME_KEY] !== "") {
|
|
4748
|
+
acc.push(data[NAME_KEY]);
|
|
4513
4749
|
} else {
|
|
4514
|
-
getAllPaths(
|
|
4750
|
+
getAllPaths(data, acc, newPaths);
|
|
4515
4751
|
}
|
|
4516
|
-
} else if (key === NAME_KEY &&
|
|
4752
|
+
} else if (key === NAME_KEY && data !== "") {
|
|
4517
4753
|
paths.forEach((path) => {
|
|
4518
4754
|
const formValue = _get(formData, path);
|
|
4519
|
-
|
|
4755
|
+
const isLeaf = objKeys.length === 1;
|
|
4756
|
+
if (formValueHasData(formValue, isLeaf) || Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf))) {
|
|
4520
4757
|
acc.push(path);
|
|
4521
4758
|
}
|
|
4522
4759
|
});
|
|
@@ -4536,60 +4773,49 @@ var Form = class extends Component5 {
|
|
|
4536
4773
|
const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
4537
4774
|
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
|
|
4538
4775
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
4539
|
-
|
|
4540
|
-
return newFormData;
|
|
4776
|
+
return this.getUsedFormData(formData, fieldNames);
|
|
4541
4777
|
};
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
const { retrievedSchema, schemaUtils } = this.state;
|
|
4545
|
-
const _retrievedSchema = resolvedSchema ?? retrievedSchema;
|
|
4546
|
-
const pathSchema = schemaUtils.toPathSchema(_retrievedSchema, "", formData);
|
|
4547
|
-
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
4548
|
-
const filteredErrors = _pick(schemaErrors, fieldNames);
|
|
4549
|
-
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
4550
|
-
filteredErrors.__errors = schemaErrors.__errors;
|
|
4551
|
-
}
|
|
4552
|
-
const prevCustomValidateErrors = this.getPreviousCustomValidateErrors();
|
|
4553
|
-
const filterPreviousCustomErrors = (errors = [], prevCustomErrors) => {
|
|
4554
|
-
if (errors.length === 0) {
|
|
4555
|
-
return errors;
|
|
4556
|
-
}
|
|
4557
|
-
return errors.filter((error) => {
|
|
4558
|
-
return !prevCustomErrors.includes(error);
|
|
4559
|
-
});
|
|
4560
|
-
};
|
|
4561
|
-
const filterNilOrEmptyErrors = (errors, previousCustomValidateErrors = {}) => {
|
|
4562
|
-
_forEach(errors, (errorAtKey, errorKey) => {
|
|
4563
|
-
const prevCustomValidateErrorAtKey = previousCustomValidateErrors[errorKey];
|
|
4564
|
-
if (_isNil(errorAtKey) || Array.isArray(errorAtKey) && errorAtKey.length === 0) {
|
|
4565
|
-
delete errors[errorKey];
|
|
4566
|
-
} else if (isObject6(errorAtKey) && isObject6(prevCustomValidateErrorAtKey) && Array.isArray(prevCustomValidateErrorAtKey?.__errors)) {
|
|
4567
|
-
errors[errorKey] = filterPreviousCustomErrors(errorAtKey.__errors, prevCustomValidateErrorAtKey.__errors);
|
|
4568
|
-
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey.__errors)) {
|
|
4569
|
-
filterNilOrEmptyErrors(errorAtKey, previousCustomValidateErrors[errorKey]);
|
|
4570
|
-
}
|
|
4571
|
-
});
|
|
4572
|
-
return errors;
|
|
4573
|
-
};
|
|
4574
|
-
return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
|
|
4575
|
-
}
|
|
4576
|
-
/** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
|
|
4577
|
-
* `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
|
|
4578
|
-
* then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
|
|
4579
|
-
* in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
|
|
4580
|
-
* updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
|
|
4581
|
-
* callback will be called if specified with the updated state.
|
|
4778
|
+
/** Pushes the given change information into the `pendingChanges` array and then calls `processPendingChanges()` if
|
|
4779
|
+
* the array only contains a single pending change.
|
|
4582
4780
|
*
|
|
4583
|
-
* @param
|
|
4584
|
-
* @param
|
|
4585
|
-
* @param
|
|
4781
|
+
* @param newValue - The new form data from a change to a field
|
|
4782
|
+
* @param path - The path to the change into which to set the formData
|
|
4783
|
+
* @param [newErrorSchema] - The new `ErrorSchema` based on the field change
|
|
4784
|
+
* @param [id] - The id of the field that caused the change
|
|
4586
4785
|
*/
|
|
4587
|
-
onChange = (
|
|
4786
|
+
onChange = (newValue, path, newErrorSchema, id) => {
|
|
4787
|
+
this.pendingChanges.push({ newValue, path, newErrorSchema, id });
|
|
4788
|
+
if (this.pendingChanges.length === 1) {
|
|
4789
|
+
this.processPendingChange();
|
|
4790
|
+
}
|
|
4791
|
+
};
|
|
4792
|
+
/** Function to handle changes made to a field in the `Form`. This handler gets the first change from the
|
|
4793
|
+
* `pendingChanges` list, containing the `newValue` for the `formData` and the `path` at which the `newValue` is to be
|
|
4794
|
+
* updated, along with a new, optional `ErrorSchema` for that same `path` and potentially the `id` of the field being
|
|
4795
|
+
* changed. It will first update the `formData` with any missing default fields and then, if `omitExtraData` and
|
|
4796
|
+
* `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not in a form field. Then, the
|
|
4797
|
+
* resulting `formData` will be validated if required. The state will be updated with the new updated (potentially
|
|
4798
|
+
* filtered) `formData`, any errors that resulted from validation. Finally the `onChange` callback will be called, if
|
|
4799
|
+
* specified, with the updated state and the `processPendingChange()` function is called again.
|
|
4800
|
+
*/
|
|
4801
|
+
processPendingChange() {
|
|
4802
|
+
if (this.pendingChanges.length === 0) {
|
|
4803
|
+
return;
|
|
4804
|
+
}
|
|
4805
|
+
const { newValue, path, id } = this.pendingChanges[0];
|
|
4806
|
+
const { newErrorSchema } = this.pendingChanges[0];
|
|
4588
4807
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4589
|
-
const { schemaUtils, schema } = this.state;
|
|
4808
|
+
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
4809
|
+
let { customErrors, errorSchema: originalErrorSchema } = this.state;
|
|
4810
|
+
const rootPathId = fieldPathId.path[0] || "";
|
|
4811
|
+
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4590
4812
|
let retrievedSchema = this.state.retrievedSchema;
|
|
4813
|
+
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
4591
4814
|
if (isObject6(formData) || Array.isArray(formData)) {
|
|
4592
|
-
|
|
4815
|
+
if (!isRootPath) {
|
|
4816
|
+
_set(formData, path, newValue);
|
|
4817
|
+
}
|
|
4818
|
+
const newState = this.getStateFromProps(this.props, formData, void 0, void 0, void 0, true);
|
|
4593
4819
|
formData = newState.formData;
|
|
4594
4820
|
retrievedSchema = newState.retrievedSchema;
|
|
4595
4821
|
}
|
|
@@ -4602,38 +4828,54 @@ var Form = class extends Component5 {
|
|
|
4602
4828
|
formData: newFormData
|
|
4603
4829
|
};
|
|
4604
4830
|
}
|
|
4605
|
-
if (
|
|
4606
|
-
const
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4831
|
+
if (newErrorSchema) {
|
|
4832
|
+
const oldValidationError = !isRootPath ? _get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
4833
|
+
if (!_isEmpty(oldValidationError)) {
|
|
4834
|
+
if (!isRootPath) {
|
|
4835
|
+
_set(originalErrorSchema, path, newErrorSchema);
|
|
4836
|
+
} else {
|
|
4837
|
+
originalErrorSchema = newErrorSchema;
|
|
4838
|
+
}
|
|
4839
|
+
} else {
|
|
4840
|
+
if (!customErrors) {
|
|
4841
|
+
customErrors = new ErrorSchemaBuilder();
|
|
4842
|
+
}
|
|
4843
|
+
if (isRootPath) {
|
|
4844
|
+
customErrors.setErrors(_get(newErrorSchema, ERRORS_KEY3, ""));
|
|
4845
|
+
} else {
|
|
4846
|
+
_set(customErrors.ErrorSchema, path, newErrorSchema);
|
|
4847
|
+
}
|
|
4619
4848
|
}
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4849
|
+
} else if (customErrors && _get(customErrors.ErrorSchema, [...path, ERRORS_KEY3])) {
|
|
4850
|
+
customErrors.clearErrors(path);
|
|
4851
|
+
}
|
|
4852
|
+
if (mustValidate && this.pendingChanges.length === 1) {
|
|
4853
|
+
const liveValidation = this.liveValidate(
|
|
4854
|
+
schema,
|
|
4855
|
+
schemaUtils,
|
|
4856
|
+
originalErrorSchema,
|
|
4857
|
+
newFormData,
|
|
4858
|
+
extraErrors,
|
|
4859
|
+
customErrors,
|
|
4860
|
+
retrievedSchema
|
|
4861
|
+
);
|
|
4862
|
+
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
4627
4863
|
} else if (!noValidate && newErrorSchema) {
|
|
4628
|
-
const
|
|
4864
|
+
const mergedErrors = this.mergeErrors({ errorSchema: originalErrorSchema, errors }, extraErrors, customErrors);
|
|
4629
4865
|
state = {
|
|
4630
4866
|
formData: newFormData,
|
|
4631
|
-
|
|
4632
|
-
|
|
4867
|
+
...mergedErrors,
|
|
4868
|
+
customErrors
|
|
4633
4869
|
};
|
|
4634
4870
|
}
|
|
4635
|
-
this.setState(state, () =>
|
|
4636
|
-
|
|
4871
|
+
this.setState(state, () => {
|
|
4872
|
+
if (onChange) {
|
|
4873
|
+
onChange({ ...this.state, ...state }, id);
|
|
4874
|
+
}
|
|
4875
|
+
this.pendingChanges.shift();
|
|
4876
|
+
this.processPendingChange();
|
|
4877
|
+
});
|
|
4878
|
+
}
|
|
4637
4879
|
/**
|
|
4638
4880
|
* If the retrievedSchema has changed the new retrievedSchema is returned.
|
|
4639
4881
|
* Otherwise, the old retrievedSchema is returned to persist reference.
|
|
@@ -4644,7 +4886,7 @@ var Form = class extends Component5 {
|
|
|
4644
4886
|
* @returns The new retrieved schema if it has changed, else the old retrieved schema.
|
|
4645
4887
|
*/
|
|
4646
4888
|
updateRetrievedSchema(retrievedSchema) {
|
|
4647
|
-
const isTheSame =
|
|
4889
|
+
const isTheSame = deepEquals2(retrievedSchema, this.state?.retrievedSchema);
|
|
4648
4890
|
return isTheSame ? this.state.retrievedSchema : retrievedSchema;
|
|
4649
4891
|
}
|
|
4650
4892
|
/**
|
|
@@ -4662,7 +4904,9 @@ var Form = class extends Component5 {
|
|
|
4662
4904
|
errorSchema: {},
|
|
4663
4905
|
errors: [],
|
|
4664
4906
|
schemaValidationErrors: [],
|
|
4665
|
-
schemaValidationErrorSchema: {}
|
|
4907
|
+
schemaValidationErrorSchema: {},
|
|
4908
|
+
initialDefaultsGenerated: false,
|
|
4909
|
+
customErrors: void 0
|
|
4666
4910
|
};
|
|
4667
4911
|
this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
|
|
4668
4912
|
};
|
|
@@ -4728,10 +4972,26 @@ var Form = class extends Component5 {
|
|
|
4728
4972
|
);
|
|
4729
4973
|
}
|
|
4730
4974
|
};
|
|
4975
|
+
/** Extracts the `GlobalFormOptions` from the given Form `props`
|
|
4976
|
+
*
|
|
4977
|
+
* @param props - The form props to extract the global form options from
|
|
4978
|
+
* @returns - The `GlobalFormOptions` from the props
|
|
4979
|
+
* @private
|
|
4980
|
+
*/
|
|
4981
|
+
getGlobalFormOptions(props) {
|
|
4982
|
+
const {
|
|
4983
|
+
uiSchema = {},
|
|
4984
|
+
experimental_componentUpdateStrategy,
|
|
4985
|
+
idSeparator = DEFAULT_ID_SEPARATOR2,
|
|
4986
|
+
idPrefix = DEFAULT_ID_PREFIX2
|
|
4987
|
+
} = props;
|
|
4988
|
+
const rootFieldId = uiSchema["ui:rootFieldId"];
|
|
4989
|
+
return { idPrefix: rootFieldId || idPrefix, idSeparator, experimental_componentUpdateStrategy };
|
|
4990
|
+
}
|
|
4731
4991
|
/** Returns the registry for the form */
|
|
4732
4992
|
getRegistry() {
|
|
4733
4993
|
const { translateString: customTranslateString, uiSchema = {} } = this.props;
|
|
4734
|
-
const { schemaUtils } = this.state;
|
|
4994
|
+
const { schema, schemaUtils } = this.state;
|
|
4735
4995
|
const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
|
|
4736
4996
|
return {
|
|
4737
4997
|
fields: { ...fields2, ...this.props.fields },
|
|
@@ -4744,11 +5004,12 @@ var Form = class extends Component5 {
|
|
|
4744
5004
|
}
|
|
4745
5005
|
},
|
|
4746
5006
|
widgets: { ...widgets2, ...this.props.widgets },
|
|
4747
|
-
rootSchema:
|
|
5007
|
+
rootSchema: schema,
|
|
4748
5008
|
formContext: this.props.formContext || formContext,
|
|
4749
5009
|
schemaUtils,
|
|
4750
5010
|
translateString: customTranslateString || translateString,
|
|
4751
|
-
globalUiOptions: uiSchema[
|
|
5011
|
+
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY2],
|
|
5012
|
+
globalFormOptions: this.getGlobalFormOptions(this.props)
|
|
4752
5013
|
};
|
|
4753
5014
|
}
|
|
4754
5015
|
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
@@ -4863,8 +5124,6 @@ var Form = class extends Component5 {
|
|
|
4863
5124
|
const {
|
|
4864
5125
|
children,
|
|
4865
5126
|
id,
|
|
4866
|
-
idPrefix,
|
|
4867
|
-
idSeparator,
|
|
4868
5127
|
className = "",
|
|
4869
5128
|
tagName,
|
|
4870
5129
|
name,
|
|
@@ -4877,17 +5136,16 @@ var Form = class extends Component5 {
|
|
|
4877
5136
|
noHtml5Validate = false,
|
|
4878
5137
|
disabled,
|
|
4879
5138
|
readonly,
|
|
4880
|
-
formContext,
|
|
4881
5139
|
showErrorList = "top",
|
|
4882
5140
|
_internalFormWrapper
|
|
4883
5141
|
} = this.props;
|
|
4884
|
-
const { schema, uiSchema, formData, errorSchema,
|
|
5142
|
+
const { schema, uiSchema, formData, errorSchema, fieldPathId } = this.state;
|
|
4885
5143
|
const registry = this.getRegistry();
|
|
4886
5144
|
const { SchemaField: _SchemaField } = registry.fields;
|
|
4887
5145
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
4888
5146
|
const as = _internalFormWrapper ? tagName : void 0;
|
|
4889
5147
|
const FormTag = _internalFormWrapper || tagName || "form";
|
|
4890
|
-
let { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } =
|
|
5148
|
+
let { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } = getUiOptions18(uiSchema);
|
|
4891
5149
|
if (disabled) {
|
|
4892
5150
|
submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
|
|
4893
5151
|
}
|
|
@@ -4910,17 +5168,14 @@ var Form = class extends Component5 {
|
|
|
4910
5168
|
ref: this.formElement,
|
|
4911
5169
|
children: [
|
|
4912
5170
|
showErrorList === "top" && this.renderErrors(registry),
|
|
4913
|
-
/* @__PURE__ */
|
|
5171
|
+
/* @__PURE__ */ jsx55(
|
|
4914
5172
|
_SchemaField,
|
|
4915
5173
|
{
|
|
4916
5174
|
name: "",
|
|
4917
5175
|
schema,
|
|
4918
5176
|
uiSchema,
|
|
4919
5177
|
errorSchema,
|
|
4920
|
-
|
|
4921
|
-
idPrefix,
|
|
4922
|
-
idSeparator,
|
|
4923
|
-
formContext,
|
|
5178
|
+
fieldPathId,
|
|
4924
5179
|
formData,
|
|
4925
5180
|
onChange: this.onChange,
|
|
4926
5181
|
onBlur: this.onBlur,
|
|
@@ -4930,7 +5185,7 @@ var Form = class extends Component5 {
|
|
|
4930
5185
|
readonly
|
|
4931
5186
|
}
|
|
4932
5187
|
),
|
|
4933
|
-
children ? children : /* @__PURE__ */
|
|
5188
|
+
children ? children : /* @__PURE__ */ jsx55(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
4934
5189
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
4935
5190
|
]
|
|
4936
5191
|
}
|
|
@@ -4940,7 +5195,7 @@ var Form = class extends Component5 {
|
|
|
4940
5195
|
|
|
4941
5196
|
// src/withTheme.tsx
|
|
4942
5197
|
import { forwardRef } from "react";
|
|
4943
|
-
import { jsx as
|
|
5198
|
+
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
4944
5199
|
function withTheme(themeProps) {
|
|
4945
5200
|
return forwardRef(
|
|
4946
5201
|
({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
|
|
@@ -4954,7 +5209,7 @@ function withTheme(themeProps) {
|
|
|
4954
5209
|
...templates2?.ButtonTemplates
|
|
4955
5210
|
}
|
|
4956
5211
|
};
|
|
4957
|
-
return /* @__PURE__ */
|
|
5212
|
+
return /* @__PURE__ */ jsx56(
|
|
4958
5213
|
Form,
|
|
4959
5214
|
{
|
|
4960
5215
|
...themeProps,
|
|
@@ -4969,12 +5224,36 @@ function withTheme(themeProps) {
|
|
|
4969
5224
|
);
|
|
4970
5225
|
}
|
|
4971
5226
|
|
|
5227
|
+
// 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";
|
|
5234
|
+
import validator from "@rjsf/validator-ajv8";
|
|
5235
|
+
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = { idPrefix: DEFAULT_ID_PREFIX3, idSeparator: DEFAULT_ID_SEPARATOR3 }) {
|
|
5236
|
+
const defaults = getDefaultRegistry();
|
|
5237
|
+
const schemaUtils = createSchemaUtils2(validator, rootSchema);
|
|
5238
|
+
return {
|
|
5239
|
+
fields: { ...defaults.fields, ...fields2 },
|
|
5240
|
+
templates: { ...defaults.templates, ...templates2 },
|
|
5241
|
+
widgets: { ...defaults.widgets, ...widgets2 },
|
|
5242
|
+
formContext,
|
|
5243
|
+
rootSchema,
|
|
5244
|
+
schemaUtils,
|
|
5245
|
+
translateString: englishStringTranslator2,
|
|
5246
|
+
globalFormOptions
|
|
5247
|
+
};
|
|
5248
|
+
}
|
|
5249
|
+
|
|
4972
5250
|
// src/index.ts
|
|
4973
5251
|
var index_default = Form;
|
|
4974
5252
|
export {
|
|
4975
5253
|
RichDescription,
|
|
4976
5254
|
index_default as default,
|
|
4977
5255
|
getDefaultRegistry,
|
|
5256
|
+
getTestRegistry,
|
|
4978
5257
|
withTheme
|
|
4979
5258
|
};
|
|
4980
5259
|
//# sourceMappingURL=index.esm.js.map
|