@rjsf/core 6.0.0-beta.2 → 6.0.0-beta.20
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 +469 -360
- package/dist/{index.js → index.cjs} +640 -519
- package/dist/index.cjs.map +7 -0
- package/dist/index.esm.js +706 -566
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +66 -16
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +138 -59
- 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 +92 -59
- 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 -53
- 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 +18 -25
- 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/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.js +3 -3
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +3 -3
- 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.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 +2 -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 +183 -73
- package/src/components/fields/ArrayField.tsx +99 -67
- package/src/components/fields/BooleanField.tsx +12 -3
- package/src/components/fields/LayoutGridField.tsx +95 -82
- 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 +19 -36
- package/src/components/fields/SchemaField.tsx +24 -30
- package/src/components/fields/StringField.tsx +12 -3
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +3 -3
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTemplate.tsx +5 -5
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +3 -3
- package/src/components/templates/BaseInputTemplate.tsx +3 -3
- 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 +5 -5
- package/src/components/templates/UnsupportedField.tsx +3 -3
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +2 -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
|
@@ -33,18 +33,21 @@ __export(index_exports, {
|
|
|
33
33
|
RichDescription: () => RichDescription,
|
|
34
34
|
default: () => index_default,
|
|
35
35
|
getDefaultRegistry: () => getDefaultRegistry,
|
|
36
|
+
getTestRegistry: () => getTestRegistry,
|
|
36
37
|
withTheme: () => withTheme
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(index_exports);
|
|
39
40
|
|
|
40
41
|
// src/components/Form.tsx
|
|
41
|
-
var
|
|
42
|
+
var import_react24 = require("react");
|
|
42
43
|
var import_utils45 = require("@rjsf/utils");
|
|
44
|
+
var import_cloneDeep3 = __toESM(require("lodash/cloneDeep"), 1);
|
|
43
45
|
var import_forEach = __toESM(require("lodash/forEach"), 1);
|
|
44
46
|
var import_get6 = __toESM(require("lodash/get"), 1);
|
|
45
47
|
var import_isEmpty4 = __toESM(require("lodash/isEmpty"), 1);
|
|
46
48
|
var import_isNil = __toESM(require("lodash/isNil"), 1);
|
|
47
49
|
var import_pick = __toESM(require("lodash/pick"), 1);
|
|
50
|
+
var import_set5 = __toESM(require("lodash/set"), 1);
|
|
48
51
|
var import_toPath = __toESM(require("lodash/toPath"), 1);
|
|
49
52
|
|
|
50
53
|
// src/getDefaultRegistry.ts
|
|
@@ -57,10 +60,10 @@ var import_cloneDeep = __toESM(require("lodash/cloneDeep"), 1);
|
|
|
57
60
|
var import_get = __toESM(require("lodash/get"), 1);
|
|
58
61
|
var import_isObject = __toESM(require("lodash/isObject"), 1);
|
|
59
62
|
var import_set = __toESM(require("lodash/set"), 1);
|
|
60
|
-
var
|
|
63
|
+
var import_uniqueId = __toESM(require("lodash/uniqueId"), 1);
|
|
61
64
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
65
|
function generateRowId() {
|
|
63
|
-
return (0,
|
|
66
|
+
return (0, import_uniqueId.default)("rjsf-array-item-");
|
|
64
67
|
}
|
|
65
68
|
function generateKeyedFormData(formData) {
|
|
66
69
|
return !Array.isArray(formData) ? [] : formData.map((item) => {
|
|
@@ -180,7 +183,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
180
183
|
if (event) {
|
|
181
184
|
event.preventDefault();
|
|
182
185
|
}
|
|
183
|
-
const { onChange, errorSchema } = this.props;
|
|
186
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
184
187
|
const { keyedFormData } = this.state;
|
|
185
188
|
let newErrorSchema;
|
|
186
189
|
if (errorSchema) {
|
|
@@ -209,7 +212,8 @@ var ArrayField = class extends import_react.Component {
|
|
|
209
212
|
keyedFormData: newKeyedFormData,
|
|
210
213
|
updatedKeyedFormData: true
|
|
211
214
|
},
|
|
212
|
-
|
|
215
|
+
// add click will pass the empty `path` array to the onChange which adds the appropriate path
|
|
216
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
213
217
|
);
|
|
214
218
|
}
|
|
215
219
|
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
@@ -243,7 +247,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
243
247
|
if (event) {
|
|
244
248
|
event.preventDefault();
|
|
245
249
|
}
|
|
246
|
-
const { onChange, errorSchema } = this.props;
|
|
250
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
247
251
|
const { keyedFormData } = this.state;
|
|
248
252
|
let newErrorSchema;
|
|
249
253
|
if (errorSchema) {
|
|
@@ -272,7 +276,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
272
276
|
keyedFormData: newKeyedFormData,
|
|
273
277
|
updatedKeyedFormData: true
|
|
274
278
|
},
|
|
275
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
279
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
276
280
|
);
|
|
277
281
|
};
|
|
278
282
|
};
|
|
@@ -287,7 +291,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
287
291
|
if (event) {
|
|
288
292
|
event.preventDefault();
|
|
289
293
|
}
|
|
290
|
-
const { onChange, errorSchema } = this.props;
|
|
294
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
291
295
|
const { keyedFormData } = this.state;
|
|
292
296
|
let newErrorSchema;
|
|
293
297
|
if (errorSchema) {
|
|
@@ -307,7 +311,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
307
311
|
keyedFormData: newKeyedFormData,
|
|
308
312
|
updatedKeyedFormData: true
|
|
309
313
|
},
|
|
310
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
314
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
311
315
|
);
|
|
312
316
|
};
|
|
313
317
|
};
|
|
@@ -324,7 +328,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
324
328
|
event.preventDefault();
|
|
325
329
|
event.currentTarget.blur();
|
|
326
330
|
}
|
|
327
|
-
const { onChange, errorSchema } = this.props;
|
|
331
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
328
332
|
let newErrorSchema;
|
|
329
333
|
if (errorSchema) {
|
|
330
334
|
newErrorSchema = {};
|
|
@@ -351,7 +355,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
351
355
|
{
|
|
352
356
|
keyedFormData: newKeyedFormData
|
|
353
357
|
},
|
|
354
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
358
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
355
359
|
);
|
|
356
360
|
};
|
|
357
361
|
};
|
|
@@ -361,32 +365,49 @@ var ArrayField = class extends import_react.Component {
|
|
|
361
365
|
* @param index - The index of the item being changed
|
|
362
366
|
*/
|
|
363
367
|
onChangeForIndex = (index) => {
|
|
364
|
-
return (value, newErrorSchema, id) => {
|
|
365
|
-
const {
|
|
366
|
-
const arrayData = Array.isArray(formData) ? formData : [];
|
|
367
|
-
const newFormData = arrayData.map((item, i) => {
|
|
368
|
-
const jsonValue = typeof value === "undefined" ? null : value;
|
|
369
|
-
return index === i ? jsonValue : item;
|
|
370
|
-
});
|
|
368
|
+
return (value, path, newErrorSchema, id) => {
|
|
369
|
+
const { onChange } = this.props;
|
|
371
370
|
onChange(
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
371
|
+
// We need to treat undefined items as nulls to have validation.
|
|
372
|
+
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
373
|
+
value === void 0 ? null : value,
|
|
374
|
+
path,
|
|
375
|
+
newErrorSchema,
|
|
377
376
|
id
|
|
378
377
|
);
|
|
379
378
|
};
|
|
380
379
|
};
|
|
381
380
|
/** Callback handler used to change the value for a checkbox */
|
|
382
381
|
onSelectChange = (value) => {
|
|
383
|
-
const { onChange,
|
|
384
|
-
onChange(value, void 0,
|
|
382
|
+
const { onChange, fieldPathId } = this.props;
|
|
383
|
+
onChange(value, fieldPathId.path, void 0, fieldPathId && fieldPathId.$id);
|
|
385
384
|
};
|
|
385
|
+
/** Helper method to compute item UI schema for both normal and fixed arrays
|
|
386
|
+
* Handles both static object and dynamic function cases
|
|
387
|
+
*
|
|
388
|
+
* @param uiSchema - The parent UI schema containing items definition
|
|
389
|
+
* @param item - The item data
|
|
390
|
+
* @param index - The index of the item
|
|
391
|
+
* @param formContext - The form context
|
|
392
|
+
* @returns The computed UI schema for the item
|
|
393
|
+
*/
|
|
394
|
+
computeItemUiSchema(uiSchema, item, index, formContext) {
|
|
395
|
+
if (typeof uiSchema.items === "function") {
|
|
396
|
+
try {
|
|
397
|
+
const result = uiSchema.items(item, index, formContext);
|
|
398
|
+
return result;
|
|
399
|
+
} catch (e) {
|
|
400
|
+
console.error(`Error executing dynamic uiSchema.items function for item at index ${index}:`, e);
|
|
401
|
+
return void 0;
|
|
402
|
+
}
|
|
403
|
+
} else {
|
|
404
|
+
return uiSchema.items;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
386
407
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
387
408
|
*/
|
|
388
409
|
render() {
|
|
389
|
-
const { schema, uiSchema,
|
|
410
|
+
const { schema, uiSchema, fieldPathId, registry } = this.props;
|
|
390
411
|
const { schemaUtils, translateString } = registry;
|
|
391
412
|
if (!(import_utils.ITEMS_KEY in schema)) {
|
|
392
413
|
const uiOptions = (0, import_utils.getUiOptions)(uiSchema);
|
|
@@ -399,7 +420,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
399
420
|
UnsupportedFieldTemplate,
|
|
400
421
|
{
|
|
401
422
|
schema,
|
|
402
|
-
|
|
423
|
+
fieldPathId,
|
|
403
424
|
reason: translateString(import_utils.TranslatableString.MissingItems),
|
|
404
425
|
registry
|
|
405
426
|
}
|
|
@@ -426,7 +447,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
426
447
|
schema,
|
|
427
448
|
uiSchema = {},
|
|
428
449
|
errorSchema,
|
|
429
|
-
|
|
450
|
+
fieldPathId,
|
|
430
451
|
name,
|
|
431
452
|
title,
|
|
432
453
|
disabled = false,
|
|
@@ -436,13 +457,11 @@ var ArrayField = class extends import_react.Component {
|
|
|
436
457
|
registry,
|
|
437
458
|
onBlur,
|
|
438
459
|
onFocus,
|
|
439
|
-
idPrefix,
|
|
440
|
-
idSeparator = "_",
|
|
441
460
|
rawErrors
|
|
442
461
|
} = this.props;
|
|
443
462
|
const { keyedFormData } = this.state;
|
|
444
463
|
const fieldTitle = schema.title || title || name;
|
|
445
|
-
const { schemaUtils, formContext } = registry;
|
|
464
|
+
const { schemaUtils, formContext, globalFormOptions } = registry;
|
|
446
465
|
const uiOptions = (0, import_utils.getUiOptions)(uiSchema);
|
|
447
466
|
const _schemaItems = (0, import_isObject.default)(schema.items) ? schema.items : {};
|
|
448
467
|
const itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
|
|
@@ -455,8 +474,8 @@ var ArrayField = class extends import_react.Component {
|
|
|
455
474
|
const itemCast = item;
|
|
456
475
|
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
457
476
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
458
|
-
const
|
|
459
|
-
const
|
|
477
|
+
const itemFieldPathId = (0, import_utils.toFieldPathId)(index, globalFormOptions, fieldPathId);
|
|
478
|
+
const itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
|
|
460
479
|
return this.renderArrayFieldItem({
|
|
461
480
|
key,
|
|
462
481
|
index,
|
|
@@ -466,10 +485,10 @@ var ArrayField = class extends import_react.Component {
|
|
|
466
485
|
canMoveUp: index > 0,
|
|
467
486
|
canMoveDown: index < formData.length - 1,
|
|
468
487
|
itemSchema,
|
|
469
|
-
|
|
488
|
+
itemFieldPathId,
|
|
470
489
|
itemErrorSchema,
|
|
471
490
|
itemData: itemCast,
|
|
472
|
-
itemUiSchema
|
|
491
|
+
itemUiSchema,
|
|
473
492
|
autofocus: autofocus && index === 0,
|
|
474
493
|
onBlur,
|
|
475
494
|
onFocus,
|
|
@@ -479,14 +498,13 @@ var ArrayField = class extends import_react.Component {
|
|
|
479
498
|
}),
|
|
480
499
|
className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}`,
|
|
481
500
|
disabled,
|
|
482
|
-
|
|
501
|
+
fieldPathId,
|
|
483
502
|
uiSchema,
|
|
484
503
|
onAddClick: this.onAddClick,
|
|
485
504
|
readonly,
|
|
486
505
|
required,
|
|
487
506
|
schema,
|
|
488
507
|
title: fieldTitle,
|
|
489
|
-
formContext,
|
|
490
508
|
formData,
|
|
491
509
|
rawErrors,
|
|
492
510
|
registry
|
|
@@ -499,7 +517,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
499
517
|
renderCustomWidget() {
|
|
500
518
|
const {
|
|
501
519
|
schema,
|
|
502
|
-
|
|
520
|
+
fieldPathId,
|
|
503
521
|
uiSchema,
|
|
504
522
|
disabled = false,
|
|
505
523
|
readonly = false,
|
|
@@ -522,7 +540,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
522
540
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
523
541
|
Widget,
|
|
524
542
|
{
|
|
525
|
-
id:
|
|
543
|
+
id: fieldPathId.$id,
|
|
526
544
|
name,
|
|
527
545
|
multiple: true,
|
|
528
546
|
onChange: this.onSelectChange,
|
|
@@ -551,7 +569,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
551
569
|
renderMultiSelect() {
|
|
552
570
|
const {
|
|
553
571
|
schema,
|
|
554
|
-
|
|
572
|
+
fieldPathId,
|
|
555
573
|
uiSchema,
|
|
556
574
|
formData: items = [],
|
|
557
575
|
disabled = false,
|
|
@@ -575,7 +593,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
575
593
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
576
594
|
Widget,
|
|
577
595
|
{
|
|
578
|
-
id:
|
|
596
|
+
id: fieldPathId.$id,
|
|
579
597
|
name,
|
|
580
598
|
multiple: true,
|
|
581
599
|
onChange: this.onSelectChange,
|
|
@@ -604,7 +622,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
604
622
|
const {
|
|
605
623
|
schema,
|
|
606
624
|
uiSchema,
|
|
607
|
-
|
|
625
|
+
fieldPathId,
|
|
608
626
|
name,
|
|
609
627
|
disabled = false,
|
|
610
628
|
readonly = false,
|
|
@@ -625,7 +643,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
625
643
|
Widget,
|
|
626
644
|
{
|
|
627
645
|
options,
|
|
628
|
-
id:
|
|
646
|
+
id: fieldPathId.$id,
|
|
629
647
|
name,
|
|
630
648
|
multiple: true,
|
|
631
649
|
onChange: this.onSelectChange,
|
|
@@ -654,9 +672,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
654
672
|
uiSchema = {},
|
|
655
673
|
formData = [],
|
|
656
674
|
errorSchema,
|
|
657
|
-
|
|
658
|
-
idSeparator = "_",
|
|
659
|
-
idSchema,
|
|
675
|
+
fieldPathId,
|
|
660
676
|
name,
|
|
661
677
|
title,
|
|
662
678
|
disabled = false,
|
|
@@ -672,7 +688,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
672
688
|
let { formData: items = [] } = this.props;
|
|
673
689
|
const fieldTitle = schema.title || title || name;
|
|
674
690
|
const uiOptions = (0, import_utils.getUiOptions)(uiSchema);
|
|
675
|
-
const { schemaUtils, formContext } = registry;
|
|
691
|
+
const { schemaUtils, formContext, globalFormOptions } = registry;
|
|
676
692
|
const _schemaItems = (0, import_isObject.default)(schema.items) ? schema.items : [];
|
|
677
693
|
const itemSchemas = _schemaItems.map(
|
|
678
694
|
(item, index) => schemaUtils.retrieveSchema(item, formData[index])
|
|
@@ -687,16 +703,24 @@ var ArrayField = class extends import_react.Component {
|
|
|
687
703
|
canAdd,
|
|
688
704
|
className: "rjsf-field rjsf-field-array rjsf-field-array-fixed-items",
|
|
689
705
|
disabled,
|
|
690
|
-
|
|
706
|
+
fieldPathId,
|
|
691
707
|
formData,
|
|
692
708
|
items: keyedFormData.map((keyedItem, index) => {
|
|
693
709
|
const { key, item } = keyedItem;
|
|
694
710
|
const itemCast = item;
|
|
695
711
|
const additional = index >= itemSchemas.length;
|
|
696
712
|
const itemSchema = (additional && (0, import_isObject.default)(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, itemCast) : itemSchemas[index]) || {};
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
713
|
+
const itemFieldPathId = (0, import_utils.toFieldPathId)(index, globalFormOptions, fieldPathId);
|
|
714
|
+
let itemUiSchema;
|
|
715
|
+
if (additional) {
|
|
716
|
+
itemUiSchema = uiSchema.additionalItems;
|
|
717
|
+
} else {
|
|
718
|
+
if (Array.isArray(uiSchema.items)) {
|
|
719
|
+
itemUiSchema = uiSchema.items[index];
|
|
720
|
+
} else {
|
|
721
|
+
itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
700
724
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
701
725
|
return this.renderArrayFieldItem({
|
|
702
726
|
key,
|
|
@@ -710,7 +734,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
710
734
|
itemSchema,
|
|
711
735
|
itemData: itemCast,
|
|
712
736
|
itemUiSchema,
|
|
713
|
-
|
|
737
|
+
itemFieldPathId,
|
|
714
738
|
itemErrorSchema,
|
|
715
739
|
autofocus: autofocus && index === 0,
|
|
716
740
|
onBlur,
|
|
@@ -726,7 +750,6 @@ var ArrayField = class extends import_react.Component {
|
|
|
726
750
|
schema,
|
|
727
751
|
uiSchema,
|
|
728
752
|
title: fieldTitle,
|
|
729
|
-
formContext,
|
|
730
753
|
errorSchema,
|
|
731
754
|
rawErrors
|
|
732
755
|
};
|
|
@@ -750,7 +773,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
750
773
|
itemSchema,
|
|
751
774
|
itemData,
|
|
752
775
|
itemUiSchema,
|
|
753
|
-
|
|
776
|
+
itemFieldPathId,
|
|
754
777
|
itemErrorSchema,
|
|
755
778
|
autofocus,
|
|
756
779
|
onBlur,
|
|
@@ -759,7 +782,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
759
782
|
totalItems,
|
|
760
783
|
title
|
|
761
784
|
} = props;
|
|
762
|
-
const { disabled, hideError,
|
|
785
|
+
const { disabled, hideError, readonly, uiSchema, registry, formContext } = this.props;
|
|
763
786
|
const {
|
|
764
787
|
fields: { ArraySchemaField, SchemaField: SchemaField2 },
|
|
765
788
|
globalUiOptions
|
|
@@ -786,9 +809,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
786
809
|
formData: itemData,
|
|
787
810
|
formContext,
|
|
788
811
|
errorSchema: itemErrorSchema,
|
|
789
|
-
|
|
790
|
-
idSeparator,
|
|
791
|
-
idSchema: itemIdSchema,
|
|
812
|
+
fieldPathId: itemFieldPathId,
|
|
792
813
|
required: this.isItemRequired(itemSchema),
|
|
793
814
|
onChange: this.onChangeForIndex(index),
|
|
794
815
|
onBlur,
|
|
@@ -802,7 +823,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
802
823
|
}
|
|
803
824
|
),
|
|
804
825
|
buttonsProps: {
|
|
805
|
-
|
|
826
|
+
fieldPathId: itemFieldPathId,
|
|
806
827
|
disabled,
|
|
807
828
|
readonly,
|
|
808
829
|
canAdd,
|
|
@@ -836,6 +857,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
836
857
|
var ArrayField_default = ArrayField;
|
|
837
858
|
|
|
838
859
|
// src/components/fields/BooleanField.tsx
|
|
860
|
+
var import_react2 = require("react");
|
|
839
861
|
var import_utils2 = require("@rjsf/utils");
|
|
840
862
|
var import_isObject2 = __toESM(require("lodash/isObject"), 1);
|
|
841
863
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -844,7 +866,7 @@ function BooleanField(props) {
|
|
|
844
866
|
schema,
|
|
845
867
|
name,
|
|
846
868
|
uiSchema,
|
|
847
|
-
|
|
869
|
+
fieldPathId,
|
|
848
870
|
formData,
|
|
849
871
|
registry,
|
|
850
872
|
required,
|
|
@@ -906,15 +928,21 @@ function BooleanField(props) {
|
|
|
906
928
|
enumOptions = (0, import_utils2.optionsList)({ enum: enums }, uiSchema);
|
|
907
929
|
}
|
|
908
930
|
}
|
|
931
|
+
const onWidgetChange = (0, import_react2.useCallback)(
|
|
932
|
+
(value, errorSchema, id) => {
|
|
933
|
+
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
934
|
+
},
|
|
935
|
+
[onChange, fieldPathId]
|
|
936
|
+
);
|
|
909
937
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
910
938
|
Widget,
|
|
911
939
|
{
|
|
912
940
|
options: { ...options, enumOptions },
|
|
913
941
|
schema,
|
|
914
942
|
uiSchema,
|
|
915
|
-
id:
|
|
943
|
+
id: fieldPathId.$id,
|
|
916
944
|
name,
|
|
917
|
-
onChange,
|
|
945
|
+
onChange: onWidgetChange,
|
|
918
946
|
onFocus,
|
|
919
947
|
onBlur,
|
|
920
948
|
label,
|
|
@@ -934,7 +962,7 @@ function BooleanField(props) {
|
|
|
934
962
|
var BooleanField_default = BooleanField;
|
|
935
963
|
|
|
936
964
|
// src/components/fields/LayoutGridField.tsx
|
|
937
|
-
var
|
|
965
|
+
var import_react3 = require("react");
|
|
938
966
|
var import_utils3 = require("@rjsf/utils");
|
|
939
967
|
var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"), 1);
|
|
940
968
|
var import_each = __toESM(require("lodash/each"), 1);
|
|
@@ -950,17 +978,20 @@ var import_isObject3 = __toESM(require("lodash/isObject"), 1);
|
|
|
950
978
|
var import_isPlainObject = __toESM(require("lodash/isPlainObject"), 1);
|
|
951
979
|
var import_isString = __toESM(require("lodash/isString"), 1);
|
|
952
980
|
var import_isUndefined = __toESM(require("lodash/isUndefined"), 1);
|
|
981
|
+
var import_last = __toESM(require("lodash/last"), 1);
|
|
953
982
|
var import_set2 = __toESM(require("lodash/set"), 1);
|
|
954
983
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
955
|
-
var
|
|
984
|
+
var import_react4 = require("react");
|
|
956
985
|
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
957
986
|
var LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
958
987
|
var LAYOUT_GRID_OPTION = `ui:${LAYOUT_GRID_UI_OPTION}`;
|
|
959
|
-
var UI_GLOBAL_OPTIONS = "ui:global_options";
|
|
960
988
|
function getNonNullishValue(value, fallback) {
|
|
961
989
|
return value ?? fallback;
|
|
962
990
|
}
|
|
963
|
-
|
|
991
|
+
function isNumericIndex(str) {
|
|
992
|
+
return /^\d+?$/.test(str);
|
|
993
|
+
}
|
|
994
|
+
var LayoutGridField = class _LayoutGridField extends import_react3.PureComponent {
|
|
964
995
|
static defaultProps = {
|
|
965
996
|
layoutGridSchema: void 0
|
|
966
997
|
};
|
|
@@ -979,7 +1010,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
979
1010
|
* @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
|
|
980
1011
|
*/
|
|
981
1012
|
static computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
982
|
-
const globalUiOptions = (0, import_get2.default)(uiSchema, [
|
|
1013
|
+
const globalUiOptions = (0, import_get2.default)(uiSchema, [import_utils3.UI_GLOBAL_OPTIONS_KEY], {});
|
|
983
1014
|
const localUiSchema = (0, import_get2.default)(uiSchema, field);
|
|
984
1015
|
const localUiOptions = { ...(0, import_get2.default)(localUiSchema, [import_utils3.UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
|
|
985
1016
|
const fieldUiSchema = { ...localUiSchema };
|
|
@@ -987,7 +1018,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
987
1018
|
(0, import_set2.default)(fieldUiSchema, [import_utils3.UI_OPTIONS_KEY], localUiOptions);
|
|
988
1019
|
}
|
|
989
1020
|
if (!(0, import_isEmpty.default)(globalUiOptions)) {
|
|
990
|
-
(0, import_set2.default)(fieldUiSchema, [
|
|
1021
|
+
(0, import_set2.default)(fieldUiSchema, [import_utils3.UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
|
|
991
1022
|
}
|
|
992
1023
|
let { readonly: uiReadonly } = (0, import_utils3.getUiOptions)(fieldUiSchema);
|
|
993
1024
|
if (forceReadonly === true || (0, import_isUndefined.default)(uiReadonly) && schemaReadonly === true) {
|
|
@@ -1059,60 +1090,74 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1059
1090
|
}
|
|
1060
1091
|
return { children, gridProps };
|
|
1061
1092
|
}
|
|
1062
|
-
/**
|
|
1063
|
-
*
|
|
1093
|
+
/** Computes the `rawSchema` and `fieldPathId` for a `schema` and a `potentialIndex`. If the `schema` is of type array,
|
|
1094
|
+
* has an `ITEMS_KEY` element and `potentialIndex` represents a numeric value, the element at `ITEMS_KEY` is checked
|
|
1095
|
+
* to see if it is an array. If it is AND the `potentialIndex`th element is available, it is used as the `rawSchema`,
|
|
1096
|
+
* otherwise the last value of the element is used. If it is not, then the element is used as the `rawSchema`. In
|
|
1097
|
+
* either case, an `fieldPathId` is computed for the array index. If the `schema` does not represent an array or the
|
|
1098
|
+
* `potentialIndex` is not a numeric value, then `rawSchema` is returned as undefined and given `fieldPathId` is returned
|
|
1099
|
+
* as is.
|
|
1064
1100
|
*
|
|
1065
|
-
* @param
|
|
1066
|
-
* @param
|
|
1067
|
-
* @param
|
|
1068
|
-
* @
|
|
1069
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1070
|
-
* @returns - The generated `idSchema` for the `schema`
|
|
1101
|
+
* @param schema - The schema to generate the fieldPathId for
|
|
1102
|
+
* @param fieldPathId - The FieldPathId for the schema
|
|
1103
|
+
* @param potentialIndex - A string containing a potential index
|
|
1104
|
+
* @returns - An object containing the `rawSchema` and `fieldPathId` of an array item, otherwise an undefined `rawSchema`
|
|
1071
1105
|
*/
|
|
1072
|
-
static
|
|
1073
|
-
|
|
1074
|
-
|
|
1106
|
+
static computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1107
|
+
let rawSchema;
|
|
1108
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && (0, import_has.default)(schema, import_utils3.ITEMS_KEY)) {
|
|
1109
|
+
const index = Number(potentialIndex);
|
|
1110
|
+
const items = schema[import_utils3.ITEMS_KEY];
|
|
1111
|
+
if (Array.isArray(items)) {
|
|
1112
|
+
if (index > items.length) {
|
|
1113
|
+
rawSchema = (0, import_last.default)(items);
|
|
1114
|
+
} else {
|
|
1115
|
+
rawSchema = items[index];
|
|
1116
|
+
}
|
|
1117
|
+
} else {
|
|
1118
|
+
rawSchema = items;
|
|
1119
|
+
}
|
|
1120
|
+
fieldPathId = {
|
|
1121
|
+
[import_utils3.ID_KEY]: fieldPathId[import_utils3.ID_KEY],
|
|
1122
|
+
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
return { rawSchema, fieldPathId };
|
|
1075
1126
|
}
|
|
1076
1127
|
/** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
|
|
1077
1128
|
* the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
|
|
1078
1129
|
* element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
|
|
1079
1130
|
* `options`.
|
|
1080
1131
|
*
|
|
1081
|
-
* @param
|
|
1132
|
+
* @param registry - The registry
|
|
1082
1133
|
* @param dottedPath - The dotted-path to the field for which to get the schema
|
|
1083
1134
|
* @param initialSchema - The initial schema to start the search from
|
|
1084
1135
|
* @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
|
|
1085
|
-
* @param
|
|
1086
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1136
|
+
* @param initialFieldIdPath - The initial fieldPathId to start the search from
|
|
1087
1137
|
* @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
|
|
1088
1138
|
* info if a oneOf/anyOf
|
|
1089
1139
|
*/
|
|
1090
|
-
static getSchemaDetailsForField(
|
|
1140
|
+
static getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
1141
|
+
const { schemaUtils, globalFormOptions } = registry;
|
|
1091
1142
|
let rawSchema = initialSchema;
|
|
1092
|
-
let
|
|
1143
|
+
let fieldPathId = initialFieldIdPath;
|
|
1093
1144
|
const parts = dottedPath.split(".");
|
|
1094
1145
|
const leafPath = parts.pop();
|
|
1095
1146
|
let schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1096
1147
|
let innerData = formData;
|
|
1097
1148
|
let isReadonly = schema.readOnly;
|
|
1098
1149
|
parts.forEach((part) => {
|
|
1150
|
+
fieldPathId = (0, import_utils3.toFieldPathId)(part, globalFormOptions, fieldPathId);
|
|
1099
1151
|
if ((0, import_has.default)(schema, import_utils3.PROPERTIES_KEY)) {
|
|
1100
1152
|
rawSchema = (0, import_get2.default)(schema, [import_utils3.PROPERTIES_KEY, part], {});
|
|
1101
|
-
idSchema = (0, import_get2.default)(idSchema, part, {});
|
|
1102
1153
|
} else if (schema && ((0, import_has.default)(schema, import_utils3.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils3.ANY_OF_KEY))) {
|
|
1103
1154
|
const xxx = (0, import_has.default)(schema, import_utils3.ONE_OF_KEY) ? import_utils3.ONE_OF_KEY : import_utils3.ANY_OF_KEY;
|
|
1104
1155
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
1105
|
-
const selectedIdSchema = _LayoutGridField.getIdSchema(
|
|
1106
|
-
schemaUtils,
|
|
1107
|
-
idSchema,
|
|
1108
|
-
formData,
|
|
1109
|
-
selectedSchema,
|
|
1110
|
-
idSeparator
|
|
1111
|
-
);
|
|
1112
1156
|
rawSchema = (0, import_get2.default)(selectedSchema, [import_utils3.PROPERTIES_KEY, part], {});
|
|
1113
|
-
idSchema = (0, import_get2.default)(selectedIdSchema, part, {});
|
|
1114
1157
|
} else {
|
|
1115
|
-
|
|
1158
|
+
const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, part);
|
|
1159
|
+
rawSchema = result.rawSchema ?? {};
|
|
1160
|
+
fieldPathId = result.fieldPathId;
|
|
1116
1161
|
}
|
|
1117
1162
|
innerData = (0, import_get2.default)(innerData, part, {});
|
|
1118
1163
|
schema = schemaUtils.retrieveSchema(rawSchema, innerData);
|
|
@@ -1127,13 +1172,17 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1127
1172
|
if (schema && ((0, import_has.default)(schema, import_utils3.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils3.ANY_OF_KEY))) {
|
|
1128
1173
|
const xxx = (0, import_has.default)(schema, import_utils3.ONE_OF_KEY) ? import_utils3.ONE_OF_KEY : import_utils3.ANY_OF_KEY;
|
|
1129
1174
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
1130
|
-
const rawIdSchema = _LayoutGridField.getIdSchema(schemaUtils, idSchema, formData, schema, idSeparator);
|
|
1131
|
-
idSchema = (0, import_utils3.mergeObjects)(rawIdSchema, idSchema);
|
|
1132
1175
|
}
|
|
1176
|
+
fieldPathId = (0, import_utils3.toFieldPathId)(leafPath, globalFormOptions, fieldPathId);
|
|
1133
1177
|
isRequired = schema !== void 0 && Array.isArray(schema.required) && (0, import_includes.default)(schema.required, leafPath);
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1178
|
+
const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
|
|
1179
|
+
if (result.rawSchema) {
|
|
1180
|
+
schema = result.rawSchema;
|
|
1181
|
+
fieldPathId = result.fieldPathId;
|
|
1182
|
+
} else {
|
|
1183
|
+
schema = (0, import_get2.default)(schema, [import_utils3.PROPERTIES_KEY, leafPath]);
|
|
1184
|
+
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
1185
|
+
}
|
|
1137
1186
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
1138
1187
|
if (schema && ((0, import_has.default)(schema, import_utils3.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils3.ANY_OF_KEY))) {
|
|
1139
1188
|
const xxx = (0, import_has.default)(schema, import_utils3.ONE_OF_KEY) ? import_utils3.ONE_OF_KEY : import_utils3.ANY_OF_KEY;
|
|
@@ -1141,7 +1190,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1141
1190
|
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
1142
1191
|
}
|
|
1143
1192
|
}
|
|
1144
|
-
return { schema, isRequired, isReadonly, optionsInfo,
|
|
1193
|
+
return { schema, isRequired, isReadonly, optionsInfo, fieldPathId };
|
|
1145
1194
|
}
|
|
1146
1195
|
/** Gets the custom render component from the `render`, by either determining that it is either already a function or
|
|
1147
1196
|
* it is a non-function value that can be used to look up the function in the registry. If no function can be found,
|
|
@@ -1177,7 +1226,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1177
1226
|
if ((0, import_isString.default)(gridSchema) || (0, import_isUndefined.default)(gridSchema)) {
|
|
1178
1227
|
name = gridSchema ?? "";
|
|
1179
1228
|
} else {
|
|
1180
|
-
const { name: innerName, render, ...innerProps } = gridSchema;
|
|
1229
|
+
const { name: innerName = "", render, ...innerProps } = gridSchema;
|
|
1181
1230
|
name = innerName;
|
|
1182
1231
|
uiProps = innerProps;
|
|
1183
1232
|
if (!(0, import_isEmpty.default)(uiProps)) {
|
|
@@ -1210,19 +1259,17 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1210
1259
|
* elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
|
|
1211
1260
|
*
|
|
1212
1261
|
* @param dottedPath - The dotted-path to the field for which to generate the onChange handler
|
|
1213
|
-
* @returns - The `onChange` handling function for the `dottedPath` field
|
|
1262
|
+
* @returns - The `onChange` handling function for the `dottedPath` field of the `schemaType` type
|
|
1214
1263
|
*/
|
|
1215
1264
|
onFieldChange = (dottedPath) => {
|
|
1216
|
-
return (value, errSchema, id) => {
|
|
1217
|
-
const { onChange, errorSchema
|
|
1218
|
-
const newFormData = (0, import_cloneDeep2.default)(formData || {});
|
|
1265
|
+
return (value, path, errSchema, id) => {
|
|
1266
|
+
const { onChange, errorSchema } = this.props;
|
|
1219
1267
|
let newErrorSchema = errorSchema;
|
|
1220
1268
|
if (errSchema && errorSchema) {
|
|
1221
1269
|
newErrorSchema = (0, import_cloneDeep2.default)(errorSchema);
|
|
1222
1270
|
(0, import_set2.default)(newErrorSchema, dottedPath, errSchema);
|
|
1223
1271
|
}
|
|
1224
|
-
(
|
|
1225
|
-
onChange(newFormData, newErrorSchema, id);
|
|
1272
|
+
onChange(value, path, newErrorSchema, id);
|
|
1226
1273
|
};
|
|
1227
1274
|
};
|
|
1228
1275
|
/** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
|
|
@@ -1310,20 +1357,20 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1310
1357
|
const GridTemplate2 = (0, import_utils3.getTemplate)("GridTemplate", registry, uiOptions);
|
|
1311
1358
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GridTemplate2, { ...gridProps, "data-testid": _LayoutGridField.TEST_IDS.row, children: this.renderChildren(children) });
|
|
1312
1359
|
}
|
|
1313
|
-
/** Iterates through all the `
|
|
1360
|
+
/** Iterates through all the `childrenLayoutGrfieldPathId`, rendering a nested `LayoutGridField` for each item in the
|
|
1314
1361
|
* list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
|
|
1315
1362
|
* `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
|
|
1316
|
-
* `
|
|
1363
|
+
* `childrenLayoutGrfieldPathId` is passed as `layoutGridSchema`.
|
|
1317
1364
|
*
|
|
1318
|
-
* @param
|
|
1365
|
+
* @param childrenLayoutGrfieldPathId - The list of strings or objects that represents the configurations for the
|
|
1319
1366
|
* children fields
|
|
1320
1367
|
* @returns - The nested `LayoutGridField`s
|
|
1321
1368
|
*/
|
|
1322
|
-
renderChildren(
|
|
1369
|
+
renderChildren(childrenLayoutGrfieldPathId) {
|
|
1323
1370
|
const { registry, schema: rawSchema, formData } = this.props;
|
|
1324
1371
|
const { schemaUtils } = registry;
|
|
1325
1372
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1326
|
-
return
|
|
1373
|
+
return childrenLayoutGrfieldPathId.map((layoutGridSchema) => /* @__PURE__ */ (0, import_react4.createElement)(
|
|
1327
1374
|
_LayoutGridField,
|
|
1328
1375
|
{
|
|
1329
1376
|
...this.props,
|
|
@@ -1339,7 +1386,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1339
1386
|
* specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
|
|
1340
1387
|
* and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
|
|
1341
1388
|
* schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
|
|
1342
|
-
* `uiSchema`, `errorSchema`, `
|
|
1389
|
+
* `uiSchema`, `errorSchema`, `fieldPathId` and `formData` drilled down to the dotted-path field, spreading any other
|
|
1343
1390
|
* props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
|
|
1344
1391
|
* then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
|
|
1345
1392
|
* schema was located, but a custom render component was found, then it will be rendered with many of the non-event
|
|
@@ -1353,18 +1400,17 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1353
1400
|
schema: initialSchema,
|
|
1354
1401
|
uiSchema,
|
|
1355
1402
|
errorSchema,
|
|
1356
|
-
|
|
1403
|
+
fieldPathId,
|
|
1357
1404
|
onBlur,
|
|
1358
1405
|
onFocus,
|
|
1359
1406
|
formData,
|
|
1360
1407
|
readonly,
|
|
1361
1408
|
registry,
|
|
1362
|
-
idSeparator,
|
|
1363
1409
|
layoutGridSchema,
|
|
1364
1410
|
// Used to pull this out of otherProps since we don't want to pass it through
|
|
1365
1411
|
...otherProps
|
|
1366
1412
|
} = this.props;
|
|
1367
|
-
const { fields: fields2
|
|
1413
|
+
const { fields: fields2 } = registry;
|
|
1368
1414
|
const { SchemaField: SchemaField2, LayoutMultiSchemaField: LayoutMultiSchemaField2 } = fields2;
|
|
1369
1415
|
const uiComponentProps = _LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema);
|
|
1370
1416
|
if (uiComponentProps.rendered) {
|
|
@@ -1376,15 +1422,8 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1376
1422
|
isRequired,
|
|
1377
1423
|
isReadonly,
|
|
1378
1424
|
optionsInfo,
|
|
1379
|
-
|
|
1380
|
-
} = _LayoutGridField.getSchemaDetailsForField(
|
|
1381
|
-
schemaUtils,
|
|
1382
|
-
name,
|
|
1383
|
-
initialSchema,
|
|
1384
|
-
formData,
|
|
1385
|
-
idSchema,
|
|
1386
|
-
idSeparator
|
|
1387
|
-
);
|
|
1425
|
+
fieldPathId: fieldIdSchema
|
|
1426
|
+
} = _LayoutGridField.getSchemaDetailsForField(registry, name, initialSchema, formData, fieldPathId);
|
|
1388
1427
|
if (schema) {
|
|
1389
1428
|
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1390
1429
|
const { fieldUiSchema, uiReadonly } = _LayoutGridField.computeFieldUiSchema(
|
|
@@ -1405,8 +1444,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1405
1444
|
schema,
|
|
1406
1445
|
uiSchema: fieldUiSchema,
|
|
1407
1446
|
errorSchema: (0, import_get2.default)(errorSchema, name),
|
|
1408
|
-
|
|
1409
|
-
idSeparator,
|
|
1447
|
+
fieldPathId: fieldIdSchema,
|
|
1410
1448
|
formData: (0, import_get2.default)(formData, name),
|
|
1411
1449
|
onChange: this.onFieldChange(name),
|
|
1412
1450
|
onBlur,
|
|
@@ -1429,8 +1467,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1429
1467
|
errorSchema,
|
|
1430
1468
|
uiSchema,
|
|
1431
1469
|
schema: initialSchema,
|
|
1432
|
-
|
|
1433
|
-
idSeparator,
|
|
1470
|
+
fieldPathId,
|
|
1434
1471
|
onBlur,
|
|
1435
1472
|
onFocus,
|
|
1436
1473
|
registry,
|
|
@@ -1476,7 +1513,7 @@ var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent
|
|
|
1476
1513
|
var import_utils4 = require("@rjsf/utils");
|
|
1477
1514
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1478
1515
|
function LayoutHeaderField(props) {
|
|
1479
|
-
const {
|
|
1516
|
+
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
1480
1517
|
const options = (0, import_utils4.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
1481
1518
|
const { title: uiTitle } = options;
|
|
1482
1519
|
const { title: schemaTitle } = schema;
|
|
@@ -1492,7 +1529,7 @@ function LayoutHeaderField(props) {
|
|
|
1492
1529
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1493
1530
|
TitleFieldTemplate,
|
|
1494
1531
|
{
|
|
1495
|
-
id: (0, import_utils4.titleId)(
|
|
1532
|
+
id: (0, import_utils4.titleId)(fieldPathId),
|
|
1496
1533
|
title: fieldTitle,
|
|
1497
1534
|
required,
|
|
1498
1535
|
schema,
|
|
@@ -1503,7 +1540,7 @@ function LayoutHeaderField(props) {
|
|
|
1503
1540
|
}
|
|
1504
1541
|
|
|
1505
1542
|
// src/components/fields/LayoutMultiSchemaField.tsx
|
|
1506
|
-
var
|
|
1543
|
+
var import_react5 = require("react");
|
|
1507
1544
|
var import_utils5 = require("@rjsf/utils");
|
|
1508
1545
|
var import_get3 = __toESM(require("lodash/get"), 1);
|
|
1509
1546
|
var import_has2 = __toESM(require("lodash/has"), 1);
|
|
@@ -1541,7 +1578,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1541
1578
|
baseType,
|
|
1542
1579
|
disabled = false,
|
|
1543
1580
|
formData,
|
|
1544
|
-
|
|
1581
|
+
fieldPathId,
|
|
1545
1582
|
onBlur,
|
|
1546
1583
|
onChange,
|
|
1547
1584
|
options,
|
|
@@ -1557,8 +1594,8 @@ function LayoutMultiSchemaField(props) {
|
|
|
1557
1594
|
hideError = false
|
|
1558
1595
|
} = props;
|
|
1559
1596
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1560
|
-
const [enumOptions, setEnumOptions] = (0,
|
|
1561
|
-
const id = (0, import_get3.default)(
|
|
1597
|
+
const [enumOptions, setEnumOptions] = (0, import_react5.useState)(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1598
|
+
const id = (0, import_get3.default)(fieldPathId, import_utils5.ID_KEY);
|
|
1562
1599
|
const discriminator = (0, import_utils5.getDiscriminatorFieldFromSchema)(schema);
|
|
1563
1600
|
const FieldErrorTemplate2 = (0, import_utils5.getTemplate)("FieldErrorTemplate", registry, options);
|
|
1564
1601
|
const FieldTemplate2 = (0, import_utils5.getTemplate)("FieldTemplate", registry, options);
|
|
@@ -1566,7 +1603,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1566
1603
|
const optionsHash = (0, import_utils5.hashObject)(options);
|
|
1567
1604
|
const uiSchemaHash = uiSchema ? (0, import_utils5.hashObject)(uiSchema) : "";
|
|
1568
1605
|
const formDataHash = formData ? (0, import_utils5.hashObject)(formData) : "";
|
|
1569
|
-
(0,
|
|
1606
|
+
(0, import_react5.useEffect)(() => {
|
|
1570
1607
|
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1571
1608
|
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
1572
1609
|
const {
|
|
@@ -1599,10 +1636,10 @@ function LayoutMultiSchemaField(props) {
|
|
|
1599
1636
|
if (newFormData) {
|
|
1600
1637
|
(0, import_set3.default)(newFormData, selectorField, opt);
|
|
1601
1638
|
}
|
|
1602
|
-
onChange(newFormData, void 0, id);
|
|
1639
|
+
onChange(newFormData, fieldPathId.path, void 0, id);
|
|
1603
1640
|
};
|
|
1604
1641
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
1605
|
-
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldErrorTemplate2, {
|
|
1642
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldErrorTemplate2, { fieldPathId, schema, errors: rawErrors, registry }) : void 0;
|
|
1606
1643
|
const ignored = (value) => import_noop.default;
|
|
1607
1644
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1608
1645
|
FieldTemplate2,
|
|
@@ -1612,7 +1649,6 @@ function LayoutMultiSchemaField(props) {
|
|
|
1612
1649
|
label: (title || schema.title) ?? "",
|
|
1613
1650
|
disabled: disabled || Array.isArray(enumOptions) && (0, import_isEmpty2.default)(enumOptions),
|
|
1614
1651
|
uiSchema,
|
|
1615
|
-
formContext,
|
|
1616
1652
|
required,
|
|
1617
1653
|
readonly: !!readonly,
|
|
1618
1654
|
registry,
|
|
@@ -1653,13 +1689,13 @@ function LayoutMultiSchemaField(props) {
|
|
|
1653
1689
|
}
|
|
1654
1690
|
|
|
1655
1691
|
// src/components/fields/MultiSchemaField.tsx
|
|
1656
|
-
var
|
|
1692
|
+
var import_react6 = require("react");
|
|
1657
1693
|
var import_get4 = __toESM(require("lodash/get"), 1);
|
|
1658
1694
|
var import_isEmpty3 = __toESM(require("lodash/isEmpty"), 1);
|
|
1659
1695
|
var import_omit2 = __toESM(require("lodash/omit"), 1);
|
|
1660
1696
|
var import_utils6 = require("@rjsf/utils");
|
|
1661
1697
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1662
|
-
var AnyOfField = class extends
|
|
1698
|
+
var AnyOfField = class extends import_react6.Component {
|
|
1663
1699
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1664
1700
|
*
|
|
1665
1701
|
* @param props - The `FieldProps` for this template
|
|
@@ -1684,7 +1720,7 @@ var AnyOfField = class extends import_react5.Component {
|
|
|
1684
1720
|
* @param prevState - The previous `AnyOfFieldState` for this template
|
|
1685
1721
|
*/
|
|
1686
1722
|
componentDidUpdate(prevProps, prevState) {
|
|
1687
|
-
const { formData, options,
|
|
1723
|
+
const { formData, options, fieldPathId } = this.props;
|
|
1688
1724
|
const { selectedOption } = this.state;
|
|
1689
1725
|
let newState = this.state;
|
|
1690
1726
|
if (!(0, import_utils6.deepEquals)(prevProps.options, options)) {
|
|
@@ -1694,7 +1730,7 @@ var AnyOfField = class extends import_react5.Component {
|
|
|
1694
1730
|
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1695
1731
|
newState = { selectedOption, retrievedOptions };
|
|
1696
1732
|
}
|
|
1697
|
-
if (!(0, import_utils6.deepEquals)(formData, prevProps.formData) &&
|
|
1733
|
+
if (!(0, import_utils6.deepEquals)(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
1698
1734
|
const { retrievedOptions } = newState;
|
|
1699
1735
|
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
1700
1736
|
if (prevState && matchingOption !== selectedOption) {
|
|
@@ -1728,7 +1764,7 @@ var AnyOfField = class extends import_react5.Component {
|
|
|
1728
1764
|
*/
|
|
1729
1765
|
onOptionChange = (option) => {
|
|
1730
1766
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1731
|
-
const { formData, onChange, registry } = this.props;
|
|
1767
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
1732
1768
|
const { schemaUtils } = registry;
|
|
1733
1769
|
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1734
1770
|
if (intOption === selectedOption) {
|
|
@@ -1741,12 +1777,12 @@ var AnyOfField = class extends import_react5.Component {
|
|
|
1741
1777
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1742
1778
|
}
|
|
1743
1779
|
this.setState({ selectedOption: intOption }, () => {
|
|
1744
|
-
onChange(newFormData, void 0, this.getFieldId());
|
|
1780
|
+
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1745
1781
|
});
|
|
1746
1782
|
};
|
|
1747
1783
|
getFieldId() {
|
|
1748
|
-
const {
|
|
1749
|
-
return `${
|
|
1784
|
+
const { fieldPathId, schema } = this.props;
|
|
1785
|
+
return `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1750
1786
|
}
|
|
1751
1787
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1752
1788
|
*/
|
|
@@ -1765,6 +1801,11 @@ var AnyOfField = class extends import_react5.Component {
|
|
|
1765
1801
|
} = this.props;
|
|
1766
1802
|
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1767
1803
|
const { SchemaField: _SchemaField } = fields2;
|
|
1804
|
+
const MultiSchemaFieldTemplate2 = (0, import_utils6.getTemplate)(
|
|
1805
|
+
"MultiSchemaFieldTemplate",
|
|
1806
|
+
registry,
|
|
1807
|
+
globalUiOptions
|
|
1808
|
+
);
|
|
1768
1809
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1769
1810
|
const {
|
|
1770
1811
|
widget = "select",
|
|
@@ -1811,57 +1852,65 @@ var AnyOfField = class extends import_react5.Component {
|
|
|
1811
1852
|
value: index
|
|
1812
1853
|
};
|
|
1813
1854
|
});
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1855
|
+
const selector = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1856
|
+
Widget,
|
|
1857
|
+
{
|
|
1858
|
+
id: this.getFieldId(),
|
|
1859
|
+
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1860
|
+
schema: { type: "number", default: 0 },
|
|
1861
|
+
onChange: this.onOptionChange,
|
|
1862
|
+
onBlur,
|
|
1863
|
+
onFocus,
|
|
1864
|
+
disabled: disabled || (0, import_isEmpty3.default)(enumOptions),
|
|
1865
|
+
multiple: false,
|
|
1866
|
+
rawErrors,
|
|
1867
|
+
errorSchema: fieldErrorSchema,
|
|
1868
|
+
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1869
|
+
options: { enumOptions, ...uiOptions },
|
|
1870
|
+
registry,
|
|
1871
|
+
formContext,
|
|
1872
|
+
placeholder,
|
|
1873
|
+
autocomplete,
|
|
1874
|
+
autofocus,
|
|
1875
|
+
label: title ?? name,
|
|
1876
|
+
hideLabel: !displayLabel,
|
|
1877
|
+
readonly
|
|
1878
|
+
}
|
|
1879
|
+
);
|
|
1880
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1882
|
+
MultiSchemaFieldTemplate2,
|
|
1883
|
+
{
|
|
1884
|
+
schema,
|
|
1885
|
+
registry,
|
|
1886
|
+
uiSchema,
|
|
1887
|
+
selector,
|
|
1888
|
+
optionSchemaField: optionsSchemaField
|
|
1889
|
+
}
|
|
1890
|
+
);
|
|
1842
1891
|
}
|
|
1843
1892
|
};
|
|
1844
1893
|
var MultiSchemaField_default = AnyOfField;
|
|
1845
1894
|
|
|
1846
1895
|
// src/components/fields/NumberField.tsx
|
|
1847
|
-
var
|
|
1896
|
+
var import_react7 = require("react");
|
|
1848
1897
|
var import_utils7 = require("@rjsf/utils");
|
|
1849
1898
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1850
1899
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1851
1900
|
var trailingCharMatcher = /[0.]0*$/;
|
|
1852
1901
|
function NumberField(props) {
|
|
1853
1902
|
const { registry, onChange, formData, value: initialValue } = props;
|
|
1854
|
-
const [lastValue, setLastValue] = (0,
|
|
1903
|
+
const [lastValue, setLastValue] = (0, import_react7.useState)(initialValue);
|
|
1855
1904
|
const { StringField: StringField2 } = registry.fields;
|
|
1856
1905
|
let value = formData;
|
|
1857
|
-
const handleChange = (0,
|
|
1858
|
-
(value2, errorSchema, id) => {
|
|
1906
|
+
const handleChange = (0, import_react7.useCallback)(
|
|
1907
|
+
(value2, path, errorSchema, id) => {
|
|
1859
1908
|
setLastValue(value2);
|
|
1860
1909
|
if (`${value2}`.charAt(0) === ".") {
|
|
1861
1910
|
value2 = `0${value2}`;
|
|
1862
1911
|
}
|
|
1863
1912
|
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? (0, import_utils7.asNumber)(value2.replace(trailingCharMatcher, "")) : (0, import_utils7.asNumber)(value2);
|
|
1864
|
-
onChange(processed, errorSchema, id);
|
|
1913
|
+
onChange(processed, path, errorSchema, id);
|
|
1865
1914
|
},
|
|
1866
1915
|
[onChange]
|
|
1867
1916
|
);
|
|
@@ -1876,7 +1925,7 @@ function NumberField(props) {
|
|
|
1876
1925
|
var NumberField_default = NumberField;
|
|
1877
1926
|
|
|
1878
1927
|
// src/components/fields/ObjectField.tsx
|
|
1879
|
-
var
|
|
1928
|
+
var import_react8 = require("react");
|
|
1880
1929
|
var import_utils8 = require("@rjsf/utils");
|
|
1881
1930
|
var import_markdown_to_jsx = __toESM(require("markdown-to-jsx"), 1);
|
|
1882
1931
|
var import_get5 = __toESM(require("lodash/get"), 1);
|
|
@@ -1885,7 +1934,7 @@ var import_isObject4 = __toESM(require("lodash/isObject"), 1);
|
|
|
1885
1934
|
var import_set4 = __toESM(require("lodash/set"), 1);
|
|
1886
1935
|
var import_unset = __toESM(require("lodash/unset"), 1);
|
|
1887
1936
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1888
|
-
var ObjectField = class extends
|
|
1937
|
+
var ObjectField = class extends import_react8.Component {
|
|
1889
1938
|
/** Set up the initial state */
|
|
1890
1939
|
state = {
|
|
1891
1940
|
wasPropertyKeyModified: false,
|
|
@@ -1909,20 +1958,12 @@ var ObjectField = class extends import_react7.Component {
|
|
|
1909
1958
|
* @returns - The onPropertyChange callback for the `name` property
|
|
1910
1959
|
*/
|
|
1911
1960
|
onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
1912
|
-
return (value, newErrorSchema, id) => {
|
|
1913
|
-
const {
|
|
1961
|
+
return (value, path, newErrorSchema, id) => {
|
|
1962
|
+
const { onChange } = this.props;
|
|
1914
1963
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
1915
1964
|
value = "";
|
|
1916
1965
|
}
|
|
1917
|
-
|
|
1918
|
-
onChange(
|
|
1919
|
-
newFormData,
|
|
1920
|
-
errorSchema && errorSchema && {
|
|
1921
|
-
...errorSchema,
|
|
1922
|
-
[name]: newErrorSchema
|
|
1923
|
-
},
|
|
1924
|
-
id
|
|
1925
|
-
);
|
|
1966
|
+
onChange(value, path, newErrorSchema, id);
|
|
1926
1967
|
};
|
|
1927
1968
|
};
|
|
1928
1969
|
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
@@ -1934,10 +1975,10 @@ var ObjectField = class extends import_react7.Component {
|
|
|
1934
1975
|
onDropPropertyClick = (key) => {
|
|
1935
1976
|
return (event) => {
|
|
1936
1977
|
event.preventDefault();
|
|
1937
|
-
const { onChange, formData } = this.props;
|
|
1978
|
+
const { onChange, formData, fieldPathId } = this.props;
|
|
1938
1979
|
const copiedFormData = { ...formData };
|
|
1939
1980
|
(0, import_unset.default)(copiedFormData, key);
|
|
1940
|
-
onChange(copiedFormData);
|
|
1981
|
+
onChange(copiedFormData, fieldPathId.path);
|
|
1941
1982
|
};
|
|
1942
1983
|
};
|
|
1943
1984
|
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
@@ -1964,11 +2005,11 @@ var ObjectField = class extends import_react7.Component {
|
|
|
1964
2005
|
* @returns - The key change callback function
|
|
1965
2006
|
*/
|
|
1966
2007
|
onKeyChange = (oldValue) => {
|
|
1967
|
-
return (value
|
|
2008
|
+
return (value) => {
|
|
1968
2009
|
if (oldValue === value) {
|
|
1969
2010
|
return;
|
|
1970
2011
|
}
|
|
1971
|
-
const { formData, onChange,
|
|
2012
|
+
const { formData, onChange, fieldPathId } = this.props;
|
|
1972
2013
|
value = this.getAvailableKey(value, formData);
|
|
1973
2014
|
const newFormData = {
|
|
1974
2015
|
...formData
|
|
@@ -1980,13 +2021,7 @@ var ObjectField = class extends import_react7.Component {
|
|
|
1980
2021
|
});
|
|
1981
2022
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
1982
2023
|
this.setState({ wasPropertyKeyModified: true });
|
|
1983
|
-
onChange(
|
|
1984
|
-
renamedObj,
|
|
1985
|
-
errorSchema && errorSchema && {
|
|
1986
|
-
...errorSchema,
|
|
1987
|
-
[value]: newErrorSchema
|
|
1988
|
-
}
|
|
1989
|
-
);
|
|
2024
|
+
onChange(renamedObj, fieldPathId.path);
|
|
1990
2025
|
};
|
|
1991
2026
|
};
|
|
1992
2027
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
@@ -2022,7 +2057,7 @@ var ObjectField = class extends import_react7.Component {
|
|
|
2022
2057
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2023
2058
|
return;
|
|
2024
2059
|
}
|
|
2025
|
-
const { formData, onChange, registry } = this.props;
|
|
2060
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
2026
2061
|
const newFormData = { ...formData };
|
|
2027
2062
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
2028
2063
|
if (schema.patternProperties) {
|
|
@@ -2050,7 +2085,7 @@ var ObjectField = class extends import_react7.Component {
|
|
|
2050
2085
|
const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
|
|
2051
2086
|
(0, import_set4.default)(newFormData, newKey, newValue);
|
|
2052
2087
|
}
|
|
2053
|
-
onChange(newFormData);
|
|
2088
|
+
onChange(newFormData, fieldPathId.path);
|
|
2054
2089
|
};
|
|
2055
2090
|
/** Renders the `ObjectField` from the given props
|
|
2056
2091
|
*/
|
|
@@ -2060,20 +2095,18 @@ var ObjectField = class extends import_react7.Component {
|
|
|
2060
2095
|
uiSchema = {},
|
|
2061
2096
|
formData,
|
|
2062
2097
|
errorSchema,
|
|
2063
|
-
|
|
2098
|
+
fieldPathId,
|
|
2064
2099
|
name,
|
|
2065
2100
|
required = false,
|
|
2066
2101
|
disabled,
|
|
2067
2102
|
readonly,
|
|
2068
2103
|
hideError,
|
|
2069
|
-
idPrefix,
|
|
2070
|
-
idSeparator,
|
|
2071
2104
|
onBlur,
|
|
2072
2105
|
onFocus,
|
|
2073
2106
|
registry,
|
|
2074
2107
|
title
|
|
2075
2108
|
} = this.props;
|
|
2076
|
-
const { fields: fields2, formContext, schemaUtils, translateString, globalUiOptions } = registry;
|
|
2109
|
+
const { fields: fields2, formContext, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
|
|
2077
2110
|
const { SchemaField: SchemaField2 } = fields2;
|
|
2078
2111
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
2079
2112
|
const uiOptions = (0, import_utils8.getUiOptions)(uiSchema, globalUiOptions);
|
|
@@ -2099,7 +2132,7 @@ var ObjectField = class extends import_react7.Component {
|
|
|
2099
2132
|
const addedByAdditionalProperties = (0, import_has3.default)(schema, [import_utils8.PROPERTIES_KEY, name2, import_utils8.ADDITIONAL_PROPERTY_FLAG]);
|
|
2100
2133
|
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
|
|
2101
2134
|
const hidden = (0, import_utils8.getUiOptions)(fieldUiSchema).widget === "hidden";
|
|
2102
|
-
const
|
|
2135
|
+
const innerFieldIdPathId = (0, import_utils8.toFieldPathId)(name2, globalFormOptions, fieldPathId);
|
|
2103
2136
|
return {
|
|
2104
2137
|
content: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2105
2138
|
SchemaField2,
|
|
@@ -2109,9 +2142,7 @@ var ObjectField = class extends import_react7.Component {
|
|
|
2109
2142
|
schema: (0, import_get5.default)(schema, [import_utils8.PROPERTIES_KEY, name2], {}),
|
|
2110
2143
|
uiSchema: fieldUiSchema,
|
|
2111
2144
|
errorSchema: (0, import_get5.default)(errorSchema, name2),
|
|
2112
|
-
|
|
2113
|
-
idPrefix,
|
|
2114
|
-
idSeparator,
|
|
2145
|
+
fieldPathId: innerFieldIdPathId,
|
|
2115
2146
|
formData: (0, import_get5.default)(formData, name2),
|
|
2116
2147
|
formContext,
|
|
2117
2148
|
wasPropertyKeyModified: this.state.wasPropertyKeyModified,
|
|
@@ -2137,7 +2168,7 @@ var ObjectField = class extends import_react7.Component {
|
|
|
2137
2168
|
readonly,
|
|
2138
2169
|
disabled,
|
|
2139
2170
|
required,
|
|
2140
|
-
|
|
2171
|
+
fieldPathId,
|
|
2141
2172
|
uiSchema,
|
|
2142
2173
|
errorSchema,
|
|
2143
2174
|
schema,
|
|
@@ -2151,7 +2182,7 @@ var ObjectField = class extends import_react7.Component {
|
|
|
2151
2182
|
var ObjectField_default = ObjectField;
|
|
2152
2183
|
|
|
2153
2184
|
// src/components/fields/SchemaField.tsx
|
|
2154
|
-
var
|
|
2185
|
+
var import_react9 = require("react");
|
|
2155
2186
|
var import_utils9 = require("@rjsf/utils");
|
|
2156
2187
|
var import_isObject5 = __toESM(require("lodash/isObject"), 1);
|
|
2157
2188
|
var import_omit3 = __toESM(require("lodash/omit"), 1);
|
|
@@ -2165,7 +2196,7 @@ var COMPONENT_TYPES = {
|
|
|
2165
2196
|
string: "StringField",
|
|
2166
2197
|
null: "NullField"
|
|
2167
2198
|
};
|
|
2168
|
-
function getFieldComponent(schema, uiOptions,
|
|
2199
|
+
function getFieldComponent(schema, uiOptions, fieldPathId, registry) {
|
|
2169
2200
|
const field = uiOptions.field;
|
|
2170
2201
|
const { fields: fields2, translateString } = registry;
|
|
2171
2202
|
if (typeof field === "function") {
|
|
@@ -2194,7 +2225,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2194
2225
|
UnsupportedFieldTemplate,
|
|
2195
2226
|
{
|
|
2196
2227
|
schema,
|
|
2197
|
-
|
|
2228
|
+
fieldPathId,
|
|
2198
2229
|
reason: translateString(import_utils9.TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
2199
2230
|
registry
|
|
2200
2231
|
}
|
|
@@ -2204,12 +2235,10 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2204
2235
|
function SchemaFieldRender(props) {
|
|
2205
2236
|
const {
|
|
2206
2237
|
schema: _schema,
|
|
2207
|
-
|
|
2238
|
+
fieldPathId,
|
|
2208
2239
|
uiSchema,
|
|
2209
2240
|
formData,
|
|
2210
2241
|
errorSchema,
|
|
2211
|
-
idPrefix,
|
|
2212
|
-
idSeparator,
|
|
2213
2242
|
name,
|
|
2214
2243
|
onChange,
|
|
2215
2244
|
onKeyChange,
|
|
@@ -2229,19 +2258,15 @@ function SchemaFieldRender(props) {
|
|
|
2229
2258
|
const FieldHelpTemplate2 = (0, import_utils9.getTemplate)("FieldHelpTemplate", registry, uiOptions);
|
|
2230
2259
|
const FieldErrorTemplate2 = (0, import_utils9.getTemplate)("FieldErrorTemplate", registry, uiOptions);
|
|
2231
2260
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2232
|
-
const fieldId =
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2235
|
-
_idSchema
|
|
2236
|
-
);
|
|
2237
|
-
const handleFieldComponentChange = (0, import_react8.useCallback)(
|
|
2238
|
-
(formData2, newErrorSchema, id2) => {
|
|
2261
|
+
const fieldId = fieldPathId[import_utils9.ID_KEY];
|
|
2262
|
+
const handleFieldComponentChange = (0, import_react9.useCallback)(
|
|
2263
|
+
(formData2, path, newErrorSchema, id2) => {
|
|
2239
2264
|
const theId = id2 || fieldId;
|
|
2240
|
-
return onChange(formData2, newErrorSchema, theId);
|
|
2265
|
+
return onChange(formData2, path, newErrorSchema, theId);
|
|
2241
2266
|
},
|
|
2242
2267
|
[fieldId, onChange]
|
|
2243
2268
|
);
|
|
2244
|
-
const FieldComponent = getFieldComponent(schema, uiOptions,
|
|
2269
|
+
const FieldComponent = getFieldComponent(schema, uiOptions, fieldPathId, registry);
|
|
2245
2270
|
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
2246
2271
|
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
2247
2272
|
const uiSchemaHideError = uiOptions.hideError;
|
|
@@ -2261,7 +2286,7 @@ function SchemaFieldRender(props) {
|
|
|
2261
2286
|
{
|
|
2262
2287
|
...props,
|
|
2263
2288
|
onChange: handleFieldComponentChange,
|
|
2264
|
-
|
|
2289
|
+
fieldPathId,
|
|
2265
2290
|
schema,
|
|
2266
2291
|
uiSchema: fieldUiSchema,
|
|
2267
2292
|
disabled,
|
|
@@ -2273,7 +2298,7 @@ function SchemaFieldRender(props) {
|
|
|
2273
2298
|
rawErrors: __errors
|
|
2274
2299
|
}
|
|
2275
2300
|
);
|
|
2276
|
-
const id =
|
|
2301
|
+
const id = fieldPathId[import_utils9.ID_KEY];
|
|
2277
2302
|
let label;
|
|
2278
2303
|
if (wasPropertyKeyModified) {
|
|
2279
2304
|
label = name;
|
|
@@ -2294,7 +2319,7 @@ function SchemaFieldRender(props) {
|
|
|
2294
2319
|
FieldHelpTemplate2,
|
|
2295
2320
|
{
|
|
2296
2321
|
help,
|
|
2297
|
-
|
|
2322
|
+
fieldPathId,
|
|
2298
2323
|
schema,
|
|
2299
2324
|
uiSchema,
|
|
2300
2325
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
@@ -2306,7 +2331,7 @@ function SchemaFieldRender(props) {
|
|
|
2306
2331
|
{
|
|
2307
2332
|
errors: __errors,
|
|
2308
2333
|
errorSchema,
|
|
2309
|
-
|
|
2334
|
+
fieldPathId,
|
|
2310
2335
|
schema,
|
|
2311
2336
|
uiSchema,
|
|
2312
2337
|
registry
|
|
@@ -2341,7 +2366,6 @@ function SchemaFieldRender(props) {
|
|
|
2341
2366
|
displayLabel,
|
|
2342
2367
|
classNames: classNames.join(" ").trim(),
|
|
2343
2368
|
style: uiOptions.style,
|
|
2344
|
-
formContext,
|
|
2345
2369
|
formData,
|
|
2346
2370
|
schema,
|
|
2347
2371
|
uiSchema,
|
|
@@ -2362,9 +2386,7 @@ function SchemaFieldRender(props) {
|
|
|
2362
2386
|
errorSchema,
|
|
2363
2387
|
formData,
|
|
2364
2388
|
formContext,
|
|
2365
|
-
|
|
2366
|
-
idSchema,
|
|
2367
|
-
idSeparator,
|
|
2389
|
+
fieldPathId,
|
|
2368
2390
|
onBlur: props.onBlur,
|
|
2369
2391
|
onChange: props.onChange,
|
|
2370
2392
|
onFocus: props.onFocus,
|
|
@@ -2387,9 +2409,7 @@ function SchemaFieldRender(props) {
|
|
|
2387
2409
|
errorSchema,
|
|
2388
2410
|
formData,
|
|
2389
2411
|
formContext,
|
|
2390
|
-
|
|
2391
|
-
idSchema,
|
|
2392
|
-
idSeparator,
|
|
2412
|
+
fieldPathId,
|
|
2393
2413
|
onBlur: props.onBlur,
|
|
2394
2414
|
onChange: props.onChange,
|
|
2395
2415
|
onFocus: props.onFocus,
|
|
@@ -2404,9 +2424,13 @@ function SchemaFieldRender(props) {
|
|
|
2404
2424
|
)
|
|
2405
2425
|
] }) });
|
|
2406
2426
|
}
|
|
2407
|
-
var SchemaField = class extends
|
|
2427
|
+
var SchemaField = class extends import_react9.Component {
|
|
2408
2428
|
shouldComponentUpdate(nextProps) {
|
|
2409
|
-
|
|
2429
|
+
const {
|
|
2430
|
+
registry: { globalFormOptions }
|
|
2431
|
+
} = this.props;
|
|
2432
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = globalFormOptions;
|
|
2433
|
+
return (0, import_utils9.shouldRender)(this, nextProps, this.state, experimental_componentUpdateStrategy);
|
|
2410
2434
|
}
|
|
2411
2435
|
render() {
|
|
2412
2436
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SchemaFieldRender, { ...this.props });
|
|
@@ -2415,6 +2439,7 @@ var SchemaField = class extends import_react8.Component {
|
|
|
2415
2439
|
var SchemaField_default = SchemaField;
|
|
2416
2440
|
|
|
2417
2441
|
// src/components/fields/StringField.tsx
|
|
2442
|
+
var import_react10 = require("react");
|
|
2418
2443
|
var import_utils10 = require("@rjsf/utils");
|
|
2419
2444
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2420
2445
|
function StringField(props) {
|
|
@@ -2422,7 +2447,7 @@ function StringField(props) {
|
|
|
2422
2447
|
schema,
|
|
2423
2448
|
name,
|
|
2424
2449
|
uiSchema,
|
|
2425
|
-
|
|
2450
|
+
fieldPathId,
|
|
2426
2451
|
formData,
|
|
2427
2452
|
required,
|
|
2428
2453
|
disabled = false,
|
|
@@ -2446,19 +2471,25 @@ function StringField(props) {
|
|
|
2446
2471
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2447
2472
|
const label = uiTitle ?? title ?? name;
|
|
2448
2473
|
const Widget = (0, import_utils10.getWidget)(schema, widget, widgets2);
|
|
2474
|
+
const onWidgetChange = (0, import_react10.useCallback)(
|
|
2475
|
+
(value, errorSchema, id) => {
|
|
2476
|
+
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2477
|
+
},
|
|
2478
|
+
[onChange, fieldPathId]
|
|
2479
|
+
);
|
|
2449
2480
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2450
2481
|
Widget,
|
|
2451
2482
|
{
|
|
2452
2483
|
options: { ...options, enumOptions },
|
|
2453
2484
|
schema,
|
|
2454
2485
|
uiSchema,
|
|
2455
|
-
id:
|
|
2486
|
+
id: fieldPathId.$id,
|
|
2456
2487
|
name,
|
|
2457
2488
|
label,
|
|
2458
2489
|
hideLabel: !displayLabel,
|
|
2459
2490
|
hideError,
|
|
2460
2491
|
value: formData,
|
|
2461
|
-
onChange,
|
|
2492
|
+
onChange: onWidgetChange,
|
|
2462
2493
|
onBlur,
|
|
2463
2494
|
onFocus,
|
|
2464
2495
|
required,
|
|
@@ -2475,14 +2506,14 @@ function StringField(props) {
|
|
|
2475
2506
|
var StringField_default = StringField;
|
|
2476
2507
|
|
|
2477
2508
|
// src/components/fields/NullField.tsx
|
|
2478
|
-
var
|
|
2509
|
+
var import_react11 = require("react");
|
|
2479
2510
|
function NullField(props) {
|
|
2480
|
-
const { formData, onChange } = props;
|
|
2481
|
-
(0,
|
|
2511
|
+
const { name, formData, onChange } = props;
|
|
2512
|
+
(0, import_react11.useEffect)(() => {
|
|
2482
2513
|
if (formData === void 0) {
|
|
2483
|
-
onChange(null);
|
|
2514
|
+
onChange(null, [name]);
|
|
2484
2515
|
}
|
|
2485
|
-
}, [formData, onChange]);
|
|
2516
|
+
}, [name, formData, onChange]);
|
|
2486
2517
|
return null;
|
|
2487
2518
|
}
|
|
2488
2519
|
var NullField_default = NullField;
|
|
@@ -2511,7 +2542,7 @@ var fields_default = fields;
|
|
|
2511
2542
|
var import_utils11 = require("@rjsf/utils");
|
|
2512
2543
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2513
2544
|
function ArrayFieldDescriptionTemplate(props) {
|
|
2514
|
-
const {
|
|
2545
|
+
const { fieldPathId, description, registry, schema, uiSchema } = props;
|
|
2515
2546
|
const options = (0, import_utils11.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
2516
2547
|
const { label: displayLabel = true } = options;
|
|
2517
2548
|
if (!description || !displayLabel) {
|
|
@@ -2525,7 +2556,7 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
2525
2556
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2526
2557
|
DescriptionFieldTemplate,
|
|
2527
2558
|
{
|
|
2528
|
-
id: (0, import_utils11.descriptionId)(
|
|
2559
|
+
id: (0, import_utils11.descriptionId)(fieldPathId),
|
|
2529
2560
|
description,
|
|
2530
2561
|
schema,
|
|
2531
2562
|
uiSchema,
|
|
@@ -2568,7 +2599,7 @@ function ArrayFieldItemTemplate(props) {
|
|
|
2568
2599
|
}
|
|
2569
2600
|
|
|
2570
2601
|
// src/components/templates/ArrayFieldItemButtonsTemplate.tsx
|
|
2571
|
-
var
|
|
2602
|
+
var import_react12 = require("react");
|
|
2572
2603
|
var import_utils13 = require("@rjsf/utils");
|
|
2573
2604
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2574
2605
|
function ArrayFieldItemButtonsTemplate(props) {
|
|
@@ -2578,7 +2609,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2578
2609
|
hasMoveDown,
|
|
2579
2610
|
hasMoveUp,
|
|
2580
2611
|
hasRemove,
|
|
2581
|
-
|
|
2612
|
+
fieldPathId,
|
|
2582
2613
|
index,
|
|
2583
2614
|
onCopyIndexClick,
|
|
2584
2615
|
onDropIndexClick,
|
|
@@ -2588,15 +2619,15 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2588
2619
|
uiSchema
|
|
2589
2620
|
} = props;
|
|
2590
2621
|
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
2591
|
-
const onCopyClick = (0,
|
|
2592
|
-
const onRemoveClick = (0,
|
|
2593
|
-
const onArrowUpClick = (0,
|
|
2594
|
-
const onArrowDownClick = (0,
|
|
2622
|
+
const onCopyClick = (0, import_react12.useMemo)(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
|
|
2623
|
+
const onRemoveClick = (0, import_react12.useMemo)(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
2624
|
+
const onArrowUpClick = (0, import_react12.useMemo)(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
2625
|
+
const onArrowDownClick = (0, import_react12.useMemo)(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
2595
2626
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
2596
2627
|
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2597
2628
|
MoveUpButton2,
|
|
2598
2629
|
{
|
|
2599
|
-
id: (0, import_utils13.buttonId)(
|
|
2630
|
+
id: (0, import_utils13.buttonId)(fieldPathId, "moveUp"),
|
|
2600
2631
|
className: "rjsf-array-item-move-up",
|
|
2601
2632
|
disabled: disabled || readonly || !hasMoveUp,
|
|
2602
2633
|
onClick: onArrowUpClick,
|
|
@@ -2607,7 +2638,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2607
2638
|
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2608
2639
|
MoveDownButton2,
|
|
2609
2640
|
{
|
|
2610
|
-
id: (0, import_utils13.buttonId)(
|
|
2641
|
+
id: (0, import_utils13.buttonId)(fieldPathId, "moveDown"),
|
|
2611
2642
|
className: "rjsf-array-item-move-down",
|
|
2612
2643
|
disabled: disabled || readonly || !hasMoveDown,
|
|
2613
2644
|
onClick: onArrowDownClick,
|
|
@@ -2618,7 +2649,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2618
2649
|
hasCopy && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2619
2650
|
CopyButton2,
|
|
2620
2651
|
{
|
|
2621
|
-
id: (0, import_utils13.buttonId)(
|
|
2652
|
+
id: (0, import_utils13.buttonId)(fieldPathId, "copy"),
|
|
2622
2653
|
className: "rjsf-array-item-copy",
|
|
2623
2654
|
disabled: disabled || readonly,
|
|
2624
2655
|
onClick: onCopyClick,
|
|
@@ -2629,7 +2660,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2629
2660
|
hasRemove && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2630
2661
|
RemoveButton2,
|
|
2631
2662
|
{
|
|
2632
|
-
id: (0, import_utils13.buttonId)(
|
|
2663
|
+
id: (0, import_utils13.buttonId)(fieldPathId, "remove"),
|
|
2633
2664
|
className: "rjsf-array-item-remove",
|
|
2634
2665
|
disabled: disabled || readonly,
|
|
2635
2666
|
onClick: onRemoveClick,
|
|
@@ -2648,7 +2679,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2648
2679
|
canAdd,
|
|
2649
2680
|
className,
|
|
2650
2681
|
disabled,
|
|
2651
|
-
|
|
2682
|
+
fieldPathId,
|
|
2652
2683
|
uiSchema,
|
|
2653
2684
|
items,
|
|
2654
2685
|
onAddClick,
|
|
@@ -2677,11 +2708,11 @@ function ArrayFieldTemplate(props) {
|
|
|
2677
2708
|
const {
|
|
2678
2709
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
2679
2710
|
} = registry.templates;
|
|
2680
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("fieldset", { className, id:
|
|
2711
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("fieldset", { className, id: fieldPathId.$id, children: [
|
|
2681
2712
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2682
2713
|
ArrayFieldTitleTemplate2,
|
|
2683
2714
|
{
|
|
2684
|
-
|
|
2715
|
+
fieldPathId,
|
|
2685
2716
|
title: uiOptions.title || title,
|
|
2686
2717
|
required,
|
|
2687
2718
|
schema,
|
|
@@ -2692,7 +2723,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2692
2723
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2693
2724
|
ArrayFieldDescriptionTemplate2,
|
|
2694
2725
|
{
|
|
2695
|
-
|
|
2726
|
+
fieldPathId,
|
|
2696
2727
|
description: uiOptions.description || schema.description,
|
|
2697
2728
|
schema,
|
|
2698
2729
|
uiSchema,
|
|
@@ -2703,7 +2734,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2703
2734
|
canAdd && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2704
2735
|
AddButton2,
|
|
2705
2736
|
{
|
|
2706
|
-
id: (0, import_utils14.buttonId)(
|
|
2737
|
+
id: (0, import_utils14.buttonId)(fieldPathId, "add"),
|
|
2707
2738
|
className: "rjsf-array-item-add",
|
|
2708
2739
|
onClick: onAddClick,
|
|
2709
2740
|
disabled: disabled || readonly,
|
|
@@ -2718,7 +2749,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2718
2749
|
var import_utils15 = require("@rjsf/utils");
|
|
2719
2750
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2720
2751
|
function ArrayFieldTitleTemplate(props) {
|
|
2721
|
-
const {
|
|
2752
|
+
const { fieldPathId, title, schema, uiSchema, required, registry } = props;
|
|
2722
2753
|
const options = (0, import_utils15.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
2723
2754
|
const { label: displayLabel = true } = options;
|
|
2724
2755
|
if (!title || !displayLabel) {
|
|
@@ -2732,7 +2763,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2732
2763
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2733
2764
|
TitleFieldTemplate,
|
|
2734
2765
|
{
|
|
2735
|
-
id: (0, import_utils15.titleId)(
|
|
2766
|
+
id: (0, import_utils15.titleId)(fieldPathId),
|
|
2736
2767
|
title,
|
|
2737
2768
|
required,
|
|
2738
2769
|
schema,
|
|
@@ -2743,7 +2774,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2743
2774
|
}
|
|
2744
2775
|
|
|
2745
2776
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2746
|
-
var
|
|
2777
|
+
var import_react13 = require("react");
|
|
2747
2778
|
var import_utils16 = require("@rjsf/utils");
|
|
2748
2779
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2749
2780
|
function BaseInputTemplate(props) {
|
|
@@ -2786,15 +2817,15 @@ function BaseInputTemplate(props) {
|
|
|
2786
2817
|
} else {
|
|
2787
2818
|
inputValue = value == null ? "" : value;
|
|
2788
2819
|
}
|
|
2789
|
-
const _onChange = (0,
|
|
2820
|
+
const _onChange = (0, import_react13.useCallback)(
|
|
2790
2821
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
2791
2822
|
[onChange, options]
|
|
2792
2823
|
);
|
|
2793
|
-
const _onBlur = (0,
|
|
2824
|
+
const _onBlur = (0, import_react13.useCallback)(
|
|
2794
2825
|
({ target }) => onBlur(id, target && target.value),
|
|
2795
2826
|
[onBlur, id]
|
|
2796
2827
|
);
|
|
2797
|
-
const _onFocus = (0,
|
|
2828
|
+
const _onFocus = (0, import_react13.useCallback)(
|
|
2798
2829
|
({ target }) => onFocus(id, target && target.value),
|
|
2799
2830
|
[onFocus, id]
|
|
2800
2831
|
);
|
|
@@ -2992,11 +3023,11 @@ var FieldTemplate_default = FieldTemplate;
|
|
|
2992
3023
|
var import_utils23 = require("@rjsf/utils");
|
|
2993
3024
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2994
3025
|
function FieldErrorTemplate(props) {
|
|
2995
|
-
const { errors = [],
|
|
3026
|
+
const { errors = [], fieldPathId } = props;
|
|
2996
3027
|
if (errors.length === 0) {
|
|
2997
3028
|
return null;
|
|
2998
3029
|
}
|
|
2999
|
-
const id = (0, import_utils23.errorId)(
|
|
3030
|
+
const id = (0, import_utils23.errorId)(fieldPathId);
|
|
3000
3031
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
|
|
3001
3032
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("li", { className: "text-danger", children: error }, index);
|
|
3002
3033
|
}) }) });
|
|
@@ -3006,11 +3037,11 @@ function FieldErrorTemplate(props) {
|
|
|
3006
3037
|
var import_utils24 = require("@rjsf/utils");
|
|
3007
3038
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3008
3039
|
function FieldHelpTemplate(props) {
|
|
3009
|
-
const {
|
|
3040
|
+
const { fieldPathId, help } = props;
|
|
3010
3041
|
if (!help) {
|
|
3011
3042
|
return null;
|
|
3012
3043
|
}
|
|
3013
|
-
const id = (0, import_utils24.helpId)(
|
|
3044
|
+
const id = (0, import_utils24.helpId)(fieldPathId);
|
|
3014
3045
|
if (typeof help === "string") {
|
|
3015
3046
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { id, className: "help-block", children: help });
|
|
3016
3047
|
}
|
|
@@ -3024,15 +3055,25 @@ function GridTemplate(props) {
|
|
|
3024
3055
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className, ...rest, children });
|
|
3025
3056
|
}
|
|
3026
3057
|
|
|
3058
|
+
// src/components/templates/MultiSchemaFieldTemplate.tsx
|
|
3059
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3060
|
+
function MultiSchemaFieldTemplate(props) {
|
|
3061
|
+
const { selector, optionSchemaField } = props;
|
|
3062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "panel panel-default panel-body", children: [
|
|
3063
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "form-group", children: selector }),
|
|
3064
|
+
optionSchemaField
|
|
3065
|
+
] });
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3027
3068
|
// src/components/templates/ObjectFieldTemplate.tsx
|
|
3028
3069
|
var import_utils25 = require("@rjsf/utils");
|
|
3029
|
-
var
|
|
3070
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3030
3071
|
function ObjectFieldTemplate(props) {
|
|
3031
3072
|
const {
|
|
3032
3073
|
description,
|
|
3033
3074
|
disabled,
|
|
3034
3075
|
formData,
|
|
3035
|
-
|
|
3076
|
+
fieldPathId,
|
|
3036
3077
|
onAddClick,
|
|
3037
3078
|
properties,
|
|
3038
3079
|
readonly,
|
|
@@ -3052,11 +3093,11 @@ function ObjectFieldTemplate(props) {
|
|
|
3052
3093
|
const {
|
|
3053
3094
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
3054
3095
|
} = registry.templates;
|
|
3055
|
-
return /* @__PURE__ */ (0,
|
|
3056
|
-
title && /* @__PURE__ */ (0,
|
|
3096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("fieldset", { id: fieldPathId.$id, children: [
|
|
3097
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3057
3098
|
TitleFieldTemplate,
|
|
3058
3099
|
{
|
|
3059
|
-
id: (0, import_utils25.titleId)(
|
|
3100
|
+
id: (0, import_utils25.titleId)(fieldPathId),
|
|
3060
3101
|
title,
|
|
3061
3102
|
required,
|
|
3062
3103
|
schema,
|
|
@@ -3064,10 +3105,10 @@ function ObjectFieldTemplate(props) {
|
|
|
3064
3105
|
registry
|
|
3065
3106
|
}
|
|
3066
3107
|
),
|
|
3067
|
-
description && /* @__PURE__ */ (0,
|
|
3108
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3068
3109
|
DescriptionFieldTemplate,
|
|
3069
3110
|
{
|
|
3070
|
-
id: (0, import_utils25.descriptionId)(
|
|
3111
|
+
id: (0, import_utils25.descriptionId)(fieldPathId),
|
|
3071
3112
|
description,
|
|
3072
3113
|
schema,
|
|
3073
3114
|
uiSchema,
|
|
@@ -3075,10 +3116,10 @@ function ObjectFieldTemplate(props) {
|
|
|
3075
3116
|
}
|
|
3076
3117
|
),
|
|
3077
3118
|
properties.map((prop) => prop.content),
|
|
3078
|
-
(0, import_utils25.canExpand)(schema, uiSchema, formData) && /* @__PURE__ */ (0,
|
|
3119
|
+
(0, import_utils25.canExpand)(schema, uiSchema, formData) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3079
3120
|
AddButton2,
|
|
3080
3121
|
{
|
|
3081
|
-
id: (0, import_utils25.buttonId)(
|
|
3122
|
+
id: (0, import_utils25.buttonId)(fieldPathId, "add"),
|
|
3082
3123
|
className: "rjsf-object-property-expand",
|
|
3083
3124
|
onClick: onAddClick(schema),
|
|
3084
3125
|
disabled: disabled || readonly,
|
|
@@ -3090,43 +3131,43 @@ function ObjectFieldTemplate(props) {
|
|
|
3090
3131
|
}
|
|
3091
3132
|
|
|
3092
3133
|
// src/components/templates/TitleField.tsx
|
|
3093
|
-
var
|
|
3134
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3094
3135
|
var REQUIRED_FIELD_SYMBOL2 = "*";
|
|
3095
3136
|
function TitleField(props) {
|
|
3096
3137
|
const { id, title, required } = props;
|
|
3097
|
-
return /* @__PURE__ */ (0,
|
|
3138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("legend", { id, children: [
|
|
3098
3139
|
title,
|
|
3099
|
-
required && /* @__PURE__ */ (0,
|
|
3140
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 })
|
|
3100
3141
|
] });
|
|
3101
3142
|
}
|
|
3102
3143
|
|
|
3103
3144
|
// src/components/templates/UnsupportedField.tsx
|
|
3104
3145
|
var import_utils26 = require("@rjsf/utils");
|
|
3105
3146
|
var import_markdown_to_jsx3 = __toESM(require("markdown-to-jsx"), 1);
|
|
3106
|
-
var
|
|
3147
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3107
3148
|
function UnsupportedField(props) {
|
|
3108
|
-
const { schema,
|
|
3149
|
+
const { schema, fieldPathId, reason, registry } = props;
|
|
3109
3150
|
const { translateString } = registry;
|
|
3110
3151
|
let translateEnum = import_utils26.TranslatableString.UnsupportedField;
|
|
3111
3152
|
const translateParams = [];
|
|
3112
|
-
if (
|
|
3153
|
+
if (fieldPathId && fieldPathId.$id) {
|
|
3113
3154
|
translateEnum = import_utils26.TranslatableString.UnsupportedFieldWithId;
|
|
3114
|
-
translateParams.push(
|
|
3155
|
+
translateParams.push(fieldPathId.$id);
|
|
3115
3156
|
}
|
|
3116
3157
|
if (reason) {
|
|
3117
3158
|
translateEnum = translateEnum === import_utils26.TranslatableString.UnsupportedField ? import_utils26.TranslatableString.UnsupportedFieldWithReason : import_utils26.TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
3118
3159
|
translateParams.push(reason);
|
|
3119
3160
|
}
|
|
3120
|
-
return /* @__PURE__ */ (0,
|
|
3121
|
-
/* @__PURE__ */ (0,
|
|
3122
|
-
schema && /* @__PURE__ */ (0,
|
|
3161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "unsupported-field", children: [
|
|
3162
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_markdown_to_jsx3.default, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3163
|
+
schema && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3123
3164
|
] });
|
|
3124
3165
|
}
|
|
3125
3166
|
var UnsupportedField_default = UnsupportedField;
|
|
3126
3167
|
|
|
3127
3168
|
// src/components/templates/WrapIfAdditionalTemplate.tsx
|
|
3128
3169
|
var import_utils27 = require("@rjsf/utils");
|
|
3129
|
-
var
|
|
3170
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3130
3171
|
function WrapIfAdditionalTemplate(props) {
|
|
3131
3172
|
const {
|
|
3132
3173
|
id,
|
|
@@ -3155,12 +3196,12 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3155
3196
|
}
|
|
3156
3197
|
const uiClassNames = classNamesList.join(" ").trim();
|
|
3157
3198
|
if (!additional) {
|
|
3158
|
-
return /* @__PURE__ */ (0,
|
|
3199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: uiClassNames, style, children });
|
|
3159
3200
|
}
|
|
3160
|
-
return /* @__PURE__ */ (0,
|
|
3161
|
-
/* @__PURE__ */ (0,
|
|
3162
|
-
/* @__PURE__ */ (0,
|
|
3163
|
-
/* @__PURE__ */ (0,
|
|
3201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: uiClassNames, style, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "row", children: [
|
|
3202
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "form-group", children: [
|
|
3203
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Label, { label: keyLabel, required, id: `${id}-key` }),
|
|
3204
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3164
3205
|
"input",
|
|
3165
3206
|
{
|
|
3166
3207
|
className: "form-control",
|
|
@@ -3171,8 +3212,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3171
3212
|
}
|
|
3172
3213
|
)
|
|
3173
3214
|
] }) }),
|
|
3174
|
-
/* @__PURE__ */ (0,
|
|
3175
|
-
/* @__PURE__ */ (0,
|
|
3215
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "form-additional form-group col-xs-5", children }),
|
|
3216
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "col-xs-2", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3176
3217
|
RemoveButton2,
|
|
3177
3218
|
{
|
|
3178
3219
|
id: (0, import_utils27.buttonId)(id, "remove"),
|
|
@@ -3203,6 +3244,7 @@ function templates() {
|
|
|
3203
3244
|
FieldErrorTemplate,
|
|
3204
3245
|
FieldHelpTemplate,
|
|
3205
3246
|
GridTemplate,
|
|
3247
|
+
MultiSchemaFieldTemplate,
|
|
3206
3248
|
ObjectFieldTemplate,
|
|
3207
3249
|
TitleFieldTemplate: TitleField,
|
|
3208
3250
|
UnsupportedFieldTemplate: UnsupportedField_default,
|
|
@@ -3212,9 +3254,9 @@ function templates() {
|
|
|
3212
3254
|
var templates_default = templates;
|
|
3213
3255
|
|
|
3214
3256
|
// src/components/widgets/AltDateWidget.tsx
|
|
3215
|
-
var
|
|
3257
|
+
var import_react14 = require("react");
|
|
3216
3258
|
var import_utils28 = require("@rjsf/utils");
|
|
3217
|
-
var
|
|
3259
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3218
3260
|
function readyForChange(state) {
|
|
3219
3261
|
return Object.values(state).every((value) => value !== -1);
|
|
3220
3262
|
}
|
|
@@ -3234,7 +3276,7 @@ function DateElement({
|
|
|
3234
3276
|
}) {
|
|
3235
3277
|
const id = rootId + "_" + type;
|
|
3236
3278
|
const { SelectWidget: SelectWidget2 } = registry.widgets;
|
|
3237
|
-
return /* @__PURE__ */ (0,
|
|
3279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3238
3280
|
SelectWidget2,
|
|
3239
3281
|
{
|
|
3240
3282
|
schema: { type: "integer" },
|
|
@@ -3271,26 +3313,25 @@ function AltDateWidget({
|
|
|
3271
3313
|
value
|
|
3272
3314
|
}) {
|
|
3273
3315
|
const { translateString } = registry;
|
|
3274
|
-
const [
|
|
3275
|
-
|
|
3276
|
-
(
|
|
3277
|
-
|
|
3316
|
+
const [state, setState] = (0, import_react14.useState)((0, import_utils28.parseDateString)(value, time));
|
|
3317
|
+
(0, import_react14.useEffect)(() => {
|
|
3318
|
+
setState((0, import_utils28.parseDateString)(value, time));
|
|
3319
|
+
}, [time, value]);
|
|
3320
|
+
const handleChange = (0, import_react14.useCallback)(
|
|
3321
|
+
(property, value2) => {
|
|
3322
|
+
const nextState = {
|
|
3323
|
+
...state,
|
|
3324
|
+
[property]: typeof value2 === "undefined" ? -1 : value2
|
|
3325
|
+
};
|
|
3326
|
+
if (readyForChange(nextState)) {
|
|
3327
|
+
onChange((0, import_utils28.toDateString)(nextState, time));
|
|
3328
|
+
} else {
|
|
3329
|
+
setState(nextState);
|
|
3330
|
+
}
|
|
3278
3331
|
},
|
|
3279
|
-
|
|
3332
|
+
[state, onChange, time]
|
|
3280
3333
|
);
|
|
3281
|
-
(0,
|
|
3282
|
-
const stateValue = (0, import_utils28.toDateString)(state, time);
|
|
3283
|
-
if (readyForChange(state) && stateValue !== value) {
|
|
3284
|
-
onChange(stateValue);
|
|
3285
|
-
} else if (lastValue !== value) {
|
|
3286
|
-
setLastValue(value);
|
|
3287
|
-
setState((0, import_utils28.parseDateString)(value, time));
|
|
3288
|
-
}
|
|
3289
|
-
}, [time, value, onChange, state, lastValue]);
|
|
3290
|
-
const handleChange = (0, import_react12.useCallback)((property, value2) => {
|
|
3291
|
-
setState({ [property]: value2 });
|
|
3292
|
-
}, []);
|
|
3293
|
-
const handleSetNow = (0, import_react12.useCallback)(
|
|
3334
|
+
const handleSetNow = (0, import_react14.useCallback)(
|
|
3294
3335
|
(event) => {
|
|
3295
3336
|
event.preventDefault();
|
|
3296
3337
|
if (disabled || readonly) {
|
|
@@ -3299,9 +3340,9 @@ function AltDateWidget({
|
|
|
3299
3340
|
const nextState = (0, import_utils28.parseDateString)((/* @__PURE__ */ new Date()).toJSON(), time);
|
|
3300
3341
|
onChange((0, import_utils28.toDateString)(nextState, time));
|
|
3301
3342
|
},
|
|
3302
|
-
[disabled, readonly, time]
|
|
3343
|
+
[disabled, readonly, time, onChange]
|
|
3303
3344
|
);
|
|
3304
|
-
const handleClear = (0,
|
|
3345
|
+
const handleClear = (0, import_react14.useCallback)(
|
|
3305
3346
|
(event) => {
|
|
3306
3347
|
event.preventDefault();
|
|
3307
3348
|
if (disabled || readonly) {
|
|
@@ -3311,13 +3352,13 @@ function AltDateWidget({
|
|
|
3311
3352
|
},
|
|
3312
3353
|
[disabled, readonly, onChange]
|
|
3313
3354
|
);
|
|
3314
|
-
return /* @__PURE__ */ (0,
|
|
3355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("ul", { className: "list-inline", children: [
|
|
3315
3356
|
(0, import_utils28.getDateElementProps)(
|
|
3316
3357
|
state,
|
|
3317
3358
|
time,
|
|
3318
3359
|
options.yearsRange,
|
|
3319
3360
|
options.format
|
|
3320
|
-
).map((elemProps, i) => /* @__PURE__ */ (0,
|
|
3361
|
+
).map((elemProps, i) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3321
3362
|
DateElement,
|
|
3322
3363
|
{
|
|
3323
3364
|
rootId: id,
|
|
@@ -3332,27 +3373,27 @@ function AltDateWidget({
|
|
|
3332
3373
|
autofocus: autofocus && i === 0
|
|
3333
3374
|
}
|
|
3334
3375
|
) }, i)),
|
|
3335
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0,
|
|
3336
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0,
|
|
3376
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(import_utils28.TranslatableString.NowLabel) }) }),
|
|
3377
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(import_utils28.TranslatableString.ClearLabel) }) })
|
|
3337
3378
|
] });
|
|
3338
3379
|
}
|
|
3339
3380
|
var AltDateWidget_default = AltDateWidget;
|
|
3340
3381
|
|
|
3341
3382
|
// src/components/widgets/AltDateTimeWidget.tsx
|
|
3342
|
-
var
|
|
3383
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3343
3384
|
function AltDateTimeWidget({
|
|
3344
3385
|
time = true,
|
|
3345
3386
|
...props
|
|
3346
3387
|
}) {
|
|
3347
3388
|
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
3348
|
-
return /* @__PURE__ */ (0,
|
|
3389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AltDateWidget2, { time, ...props });
|
|
3349
3390
|
}
|
|
3350
3391
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
3351
3392
|
|
|
3352
3393
|
// src/components/widgets/CheckboxWidget.tsx
|
|
3353
|
-
var
|
|
3394
|
+
var import_react15 = require("react");
|
|
3354
3395
|
var import_utils29 = require("@rjsf/utils");
|
|
3355
|
-
var
|
|
3396
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3356
3397
|
function CheckboxWidget({
|
|
3357
3398
|
schema,
|
|
3358
3399
|
uiSchema,
|
|
@@ -3375,21 +3416,21 @@ function CheckboxWidget({
|
|
|
3375
3416
|
options
|
|
3376
3417
|
);
|
|
3377
3418
|
const required = (0, import_utils29.schemaRequiresTrueValue)(schema);
|
|
3378
|
-
const handleChange = (0,
|
|
3419
|
+
const handleChange = (0, import_react15.useCallback)(
|
|
3379
3420
|
(event) => onChange(event.target.checked),
|
|
3380
3421
|
[onChange]
|
|
3381
3422
|
);
|
|
3382
|
-
const handleBlur = (0,
|
|
3423
|
+
const handleBlur = (0, import_react15.useCallback)(
|
|
3383
3424
|
(event) => onBlur(id, event.target.checked),
|
|
3384
3425
|
[onBlur, id]
|
|
3385
3426
|
);
|
|
3386
|
-
const handleFocus = (0,
|
|
3427
|
+
const handleFocus = (0, import_react15.useCallback)(
|
|
3387
3428
|
(event) => onFocus(id, event.target.checked),
|
|
3388
3429
|
[onFocus, id]
|
|
3389
3430
|
);
|
|
3390
3431
|
const description = options.description ?? schema.description;
|
|
3391
|
-
return /* @__PURE__ */ (0,
|
|
3392
|
-
!hideLabel && description && /* @__PURE__ */ (0,
|
|
3432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
|
|
3433
|
+
!hideLabel && description && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3393
3434
|
DescriptionFieldTemplate,
|
|
3394
3435
|
{
|
|
3395
3436
|
id: (0, import_utils29.descriptionId)(id),
|
|
@@ -3399,8 +3440,8 @@ function CheckboxWidget({
|
|
|
3399
3440
|
registry
|
|
3400
3441
|
}
|
|
3401
3442
|
),
|
|
3402
|
-
/* @__PURE__ */ (0,
|
|
3403
|
-
/* @__PURE__ */ (0,
|
|
3443
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("label", { children: [
|
|
3444
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3404
3445
|
"input",
|
|
3405
3446
|
{
|
|
3406
3447
|
type: "checkbox",
|
|
@@ -3416,16 +3457,16 @@ function CheckboxWidget({
|
|
|
3416
3457
|
"aria-describedby": (0, import_utils29.ariaDescribedByIds)(id)
|
|
3417
3458
|
}
|
|
3418
3459
|
),
|
|
3419
|
-
(0, import_utils29.labelValue)(/* @__PURE__ */ (0,
|
|
3460
|
+
(0, import_utils29.labelValue)(/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { children: label }), hideLabel)
|
|
3420
3461
|
] })
|
|
3421
3462
|
] });
|
|
3422
3463
|
}
|
|
3423
3464
|
var CheckboxWidget_default = CheckboxWidget;
|
|
3424
3465
|
|
|
3425
3466
|
// src/components/widgets/CheckboxesWidget.tsx
|
|
3426
|
-
var
|
|
3467
|
+
var import_react16 = require("react");
|
|
3427
3468
|
var import_utils30 = require("@rjsf/utils");
|
|
3428
|
-
var
|
|
3469
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3429
3470
|
function CheckboxesWidget({
|
|
3430
3471
|
id,
|
|
3431
3472
|
disabled,
|
|
@@ -3438,15 +3479,15 @@ function CheckboxesWidget({
|
|
|
3438
3479
|
onFocus
|
|
3439
3480
|
}) {
|
|
3440
3481
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3441
|
-
const handleBlur = (0,
|
|
3482
|
+
const handleBlur = (0, import_react16.useCallback)(
|
|
3442
3483
|
({ target }) => onBlur(id, (0, import_utils30.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
3443
|
-
[onBlur, id]
|
|
3484
|
+
[onBlur, id, enumOptions, emptyValue]
|
|
3444
3485
|
);
|
|
3445
|
-
const handleFocus = (0,
|
|
3486
|
+
const handleFocus = (0, import_react16.useCallback)(
|
|
3446
3487
|
({ target }) => onFocus(id, (0, import_utils30.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
3447
|
-
[onFocus, id]
|
|
3488
|
+
[onFocus, id, enumOptions, emptyValue]
|
|
3448
3489
|
);
|
|
3449
|
-
return /* @__PURE__ */ (0,
|
|
3490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3450
3491
|
const checked = (0, import_utils30.enumOptionsIsSelected)(option.value, checkboxesValues);
|
|
3451
3492
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3452
3493
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
@@ -3457,8 +3498,8 @@ function CheckboxesWidget({
|
|
|
3457
3498
|
onChange((0, import_utils30.enumOptionsDeselectValue)(index, checkboxesValues, enumOptions));
|
|
3458
3499
|
}
|
|
3459
3500
|
};
|
|
3460
|
-
const checkbox = /* @__PURE__ */ (0,
|
|
3461
|
-
/* @__PURE__ */ (0,
|
|
3501
|
+
const checkbox = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { children: [
|
|
3502
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3462
3503
|
"input",
|
|
3463
3504
|
{
|
|
3464
3505
|
type: "checkbox",
|
|
@@ -3474,40 +3515,40 @@ function CheckboxesWidget({
|
|
|
3474
3515
|
"aria-describedby": (0, import_utils30.ariaDescribedByIds)(id)
|
|
3475
3516
|
}
|
|
3476
3517
|
),
|
|
3477
|
-
/* @__PURE__ */ (0,
|
|
3518
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { children: option.label })
|
|
3478
3519
|
] });
|
|
3479
|
-
return inline ? /* @__PURE__ */ (0,
|
|
3520
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("label", { children: checkbox }) }, index);
|
|
3480
3521
|
}) });
|
|
3481
3522
|
}
|
|
3482
3523
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3483
3524
|
|
|
3484
3525
|
// src/components/widgets/ColorWidget.tsx
|
|
3485
3526
|
var import_utils31 = require("@rjsf/utils");
|
|
3486
|
-
var
|
|
3527
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3487
3528
|
function ColorWidget(props) {
|
|
3488
3529
|
const { disabled, readonly, options, registry } = props;
|
|
3489
3530
|
const BaseInputTemplate2 = (0, import_utils31.getTemplate)("BaseInputTemplate", registry, options);
|
|
3490
|
-
return /* @__PURE__ */ (0,
|
|
3531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
|
|
3491
3532
|
}
|
|
3492
3533
|
|
|
3493
3534
|
// src/components/widgets/DateWidget.tsx
|
|
3494
|
-
var
|
|
3535
|
+
var import_react17 = require("react");
|
|
3495
3536
|
var import_utils32 = require("@rjsf/utils");
|
|
3496
|
-
var
|
|
3537
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3497
3538
|
function DateWidget(props) {
|
|
3498
3539
|
const { onChange, options, registry } = props;
|
|
3499
3540
|
const BaseInputTemplate2 = (0, import_utils32.getTemplate)("BaseInputTemplate", registry, options);
|
|
3500
|
-
const handleChange = (0,
|
|
3501
|
-
return /* @__PURE__ */ (0,
|
|
3541
|
+
const handleChange = (0, import_react17.useCallback)((value) => onChange(value || void 0), [onChange]);
|
|
3542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3502
3543
|
}
|
|
3503
3544
|
|
|
3504
3545
|
// src/components/widgets/DateTimeWidget.tsx
|
|
3505
3546
|
var import_utils33 = require("@rjsf/utils");
|
|
3506
|
-
var
|
|
3547
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3507
3548
|
function DateTimeWidget(props) {
|
|
3508
3549
|
const { onChange, value, options, registry } = props;
|
|
3509
3550
|
const BaseInputTemplate2 = (0, import_utils33.getTemplate)("BaseInputTemplate", registry, options);
|
|
3510
|
-
return /* @__PURE__ */ (0,
|
|
3551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3511
3552
|
BaseInputTemplate2,
|
|
3512
3553
|
{
|
|
3513
3554
|
type: "datetime-local",
|
|
@@ -3520,18 +3561,18 @@ function DateTimeWidget(props) {
|
|
|
3520
3561
|
|
|
3521
3562
|
// src/components/widgets/EmailWidget.tsx
|
|
3522
3563
|
var import_utils34 = require("@rjsf/utils");
|
|
3523
|
-
var
|
|
3564
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3524
3565
|
function EmailWidget(props) {
|
|
3525
3566
|
const { options, registry } = props;
|
|
3526
3567
|
const BaseInputTemplate2 = (0, import_utils34.getTemplate)("BaseInputTemplate", registry, options);
|
|
3527
|
-
return /* @__PURE__ */ (0,
|
|
3568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(BaseInputTemplate2, { type: "email", ...props });
|
|
3528
3569
|
}
|
|
3529
3570
|
|
|
3530
3571
|
// src/components/widgets/FileWidget.tsx
|
|
3531
|
-
var
|
|
3572
|
+
var import_react18 = require("react");
|
|
3532
3573
|
var import_utils35 = require("@rjsf/utils");
|
|
3533
3574
|
var import_markdown_to_jsx4 = __toESM(require("markdown-to-jsx"), 1);
|
|
3534
|
-
var
|
|
3575
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3535
3576
|
function addNameToDataURL(dataURL, name) {
|
|
3536
3577
|
if (dataURL === null) {
|
|
3537
3578
|
return null;
|
|
@@ -3576,11 +3617,11 @@ function FileInfoPreview({
|
|
|
3576
3617
|
return null;
|
|
3577
3618
|
}
|
|
3578
3619
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3579
|
-
return /* @__PURE__ */ (0,
|
|
3620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3580
3621
|
}
|
|
3581
|
-
return /* @__PURE__ */ (0,
|
|
3622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
3582
3623
|
" ",
|
|
3583
|
-
/* @__PURE__ */ (0,
|
|
3624
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(import_utils35.TranslatableString.PreviewLabel) })
|
|
3584
3625
|
] });
|
|
3585
3626
|
}
|
|
3586
3627
|
function FilesInfo({
|
|
@@ -3595,13 +3636,13 @@ function FilesInfo({
|
|
|
3595
3636
|
}
|
|
3596
3637
|
const { translateString } = registry;
|
|
3597
3638
|
const { RemoveButton: RemoveButton2 } = (0, import_utils35.getTemplate)("ButtonTemplates", registry, options);
|
|
3598
|
-
return /* @__PURE__ */ (0,
|
|
3639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3599
3640
|
const { name, size, type } = fileInfo;
|
|
3600
3641
|
const handleRemove = () => onRemove(key);
|
|
3601
|
-
return /* @__PURE__ */ (0,
|
|
3602
|
-
/* @__PURE__ */ (0,
|
|
3603
|
-
preview && /* @__PURE__ */ (0,
|
|
3604
|
-
/* @__PURE__ */ (0,
|
|
3642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("li", { children: [
|
|
3643
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_markdown_to_jsx4.default, { children: translateString(import_utils35.TranslatableString.FilesInfo, [name, type, String(size)]) }),
|
|
3644
|
+
preview && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(FileInfoPreview, { fileInfo, registry }),
|
|
3645
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(RemoveButton2, { onClick: handleRemove, registry })
|
|
3605
3646
|
] }, key);
|
|
3606
3647
|
}) });
|
|
3607
3648
|
}
|
|
@@ -3629,7 +3670,7 @@ function extractFileInfo(dataURLs) {
|
|
|
3629
3670
|
function FileWidget(props) {
|
|
3630
3671
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|
|
3631
3672
|
const BaseInputTemplate2 = (0, import_utils35.getTemplate)("BaseInputTemplate", registry, options);
|
|
3632
|
-
const handleChange = (0,
|
|
3673
|
+
const handleChange = (0, import_react18.useCallback)(
|
|
3633
3674
|
(event) => {
|
|
3634
3675
|
if (!event.target.files) {
|
|
3635
3676
|
return;
|
|
@@ -3645,8 +3686,8 @@ function FileWidget(props) {
|
|
|
3645
3686
|
},
|
|
3646
3687
|
[multiple, value, onChange]
|
|
3647
3688
|
);
|
|
3648
|
-
const filesInfo = (0,
|
|
3649
|
-
const rmFile = (0,
|
|
3689
|
+
const filesInfo = (0, import_react18.useMemo)(() => extractFileInfo(Array.isArray(value) ? value : [value]), [value]);
|
|
3690
|
+
const rmFile = (0, import_react18.useCallback)(
|
|
3650
3691
|
(index) => {
|
|
3651
3692
|
if (multiple) {
|
|
3652
3693
|
const newValue = value.filter((_, i) => i !== index);
|
|
@@ -3657,8 +3698,8 @@ function FileWidget(props) {
|
|
|
3657
3698
|
},
|
|
3658
3699
|
[multiple, value, onChange]
|
|
3659
3700
|
);
|
|
3660
|
-
return /* @__PURE__ */ (0,
|
|
3661
|
-
/* @__PURE__ */ (0,
|
|
3701
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { children: [
|
|
3702
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3662
3703
|
BaseInputTemplate2,
|
|
3663
3704
|
{
|
|
3664
3705
|
...props,
|
|
@@ -3670,7 +3711,7 @@ function FileWidget(props) {
|
|
|
3670
3711
|
accept: options.accept ? String(options.accept) : void 0
|
|
3671
3712
|
}
|
|
3672
3713
|
),
|
|
3673
|
-
/* @__PURE__ */ (0,
|
|
3714
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3674
3715
|
FilesInfo,
|
|
3675
3716
|
{
|
|
3676
3717
|
filesInfo,
|
|
@@ -3685,28 +3726,28 @@ function FileWidget(props) {
|
|
|
3685
3726
|
var FileWidget_default = FileWidget;
|
|
3686
3727
|
|
|
3687
3728
|
// src/components/widgets/HiddenWidget.tsx
|
|
3688
|
-
var
|
|
3729
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
3689
3730
|
function HiddenWidget({
|
|
3690
3731
|
id,
|
|
3691
3732
|
value
|
|
3692
3733
|
}) {
|
|
3693
|
-
return /* @__PURE__ */ (0,
|
|
3734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
|
|
3694
3735
|
}
|
|
3695
3736
|
var HiddenWidget_default = HiddenWidget;
|
|
3696
3737
|
|
|
3697
3738
|
// src/components/widgets/PasswordWidget.tsx
|
|
3698
3739
|
var import_utils36 = require("@rjsf/utils");
|
|
3699
|
-
var
|
|
3740
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
3700
3741
|
function PasswordWidget(props) {
|
|
3701
3742
|
const { options, registry } = props;
|
|
3702
3743
|
const BaseInputTemplate2 = (0, import_utils36.getTemplate)("BaseInputTemplate", registry, options);
|
|
3703
|
-
return /* @__PURE__ */ (0,
|
|
3744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(BaseInputTemplate2, { type: "password", ...props });
|
|
3704
3745
|
}
|
|
3705
3746
|
|
|
3706
3747
|
// src/components/widgets/RadioWidget.tsx
|
|
3707
|
-
var
|
|
3748
|
+
var import_react19 = require("react");
|
|
3708
3749
|
var import_utils37 = require("@rjsf/utils");
|
|
3709
|
-
var
|
|
3750
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
3710
3751
|
function RadioWidget({
|
|
3711
3752
|
options,
|
|
3712
3753
|
value,
|
|
@@ -3720,21 +3761,21 @@ function RadioWidget({
|
|
|
3720
3761
|
id
|
|
3721
3762
|
}) {
|
|
3722
3763
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3723
|
-
const handleBlur = (0,
|
|
3764
|
+
const handleBlur = (0, import_react19.useCallback)(
|
|
3724
3765
|
({ target }) => onBlur(id, (0, import_utils37.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
3725
3766
|
[onBlur, enumOptions, emptyValue, id]
|
|
3726
3767
|
);
|
|
3727
|
-
const handleFocus = (0,
|
|
3768
|
+
const handleFocus = (0, import_react19.useCallback)(
|
|
3728
3769
|
({ target }) => onFocus(id, (0, import_utils37.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
3729
3770
|
[onFocus, enumOptions, emptyValue, id]
|
|
3730
3771
|
);
|
|
3731
|
-
return /* @__PURE__ */ (0,
|
|
3772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3732
3773
|
const checked = (0, import_utils37.enumOptionsIsSelected)(option.value, value);
|
|
3733
3774
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3734
3775
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3735
3776
|
const handleChange = () => onChange(option.value);
|
|
3736
|
-
const radio = /* @__PURE__ */ (0,
|
|
3737
|
-
/* @__PURE__ */ (0,
|
|
3777
|
+
const radio = /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { children: [
|
|
3778
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3738
3779
|
"input",
|
|
3739
3780
|
{
|
|
3740
3781
|
type: "radio",
|
|
@@ -3751,15 +3792,15 @@ function RadioWidget({
|
|
|
3751
3792
|
"aria-describedby": (0, import_utils37.ariaDescribedByIds)(id)
|
|
3752
3793
|
}
|
|
3753
3794
|
),
|
|
3754
|
-
/* @__PURE__ */ (0,
|
|
3795
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: option.label })
|
|
3755
3796
|
] });
|
|
3756
|
-
return inline ? /* @__PURE__ */ (0,
|
|
3797
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("label", { children: radio }) }, i);
|
|
3757
3798
|
}) });
|
|
3758
3799
|
}
|
|
3759
3800
|
var RadioWidget_default = RadioWidget;
|
|
3760
3801
|
|
|
3761
3802
|
// src/components/widgets/RangeWidget.tsx
|
|
3762
|
-
var
|
|
3803
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
3763
3804
|
function RangeWidget(props) {
|
|
3764
3805
|
const {
|
|
3765
3806
|
value,
|
|
@@ -3767,15 +3808,15 @@ function RangeWidget(props) {
|
|
|
3767
3808
|
templates: { BaseInputTemplate: BaseInputTemplate2 }
|
|
3768
3809
|
}
|
|
3769
3810
|
} = props;
|
|
3770
|
-
return /* @__PURE__ */ (0,
|
|
3771
|
-
/* @__PURE__ */ (0,
|
|
3772
|
-
/* @__PURE__ */ (0,
|
|
3811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "field-range-wrapper", children: [
|
|
3812
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BaseInputTemplate2, { type: "range", ...props }),
|
|
3813
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "range-view", children: value })
|
|
3773
3814
|
] });
|
|
3774
3815
|
}
|
|
3775
3816
|
|
|
3776
3817
|
// src/components/widgets/RatingWidget.tsx
|
|
3777
|
-
var
|
|
3778
|
-
var
|
|
3818
|
+
var import_react20 = require("react");
|
|
3819
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
3779
3820
|
function RatingWidget({
|
|
3780
3821
|
id,
|
|
3781
3822
|
value,
|
|
@@ -3792,7 +3833,7 @@ function RatingWidget({
|
|
|
3792
3833
|
const { stars = 5, shape = "star" } = options;
|
|
3793
3834
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3794
3835
|
const min = schema.minimum || 0;
|
|
3795
|
-
const handleStarClick = (0,
|
|
3836
|
+
const handleStarClick = (0, import_react20.useCallback)(
|
|
3796
3837
|
(starValue) => {
|
|
3797
3838
|
if (!disabled && !readonly) {
|
|
3798
3839
|
onChange(starValue);
|
|
@@ -3800,7 +3841,7 @@ function RatingWidget({
|
|
|
3800
3841
|
},
|
|
3801
3842
|
[onChange, disabled, readonly]
|
|
3802
3843
|
);
|
|
3803
|
-
const handleFocus = (0,
|
|
3844
|
+
const handleFocus = (0, import_react20.useCallback)(
|
|
3804
3845
|
(event) => {
|
|
3805
3846
|
if (onFocus) {
|
|
3806
3847
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3809,7 +3850,7 @@ function RatingWidget({
|
|
|
3809
3850
|
},
|
|
3810
3851
|
[onFocus, id]
|
|
3811
3852
|
);
|
|
3812
|
-
const handleBlur = (0,
|
|
3853
|
+
const handleBlur = (0, import_react20.useCallback)(
|
|
3813
3854
|
(event) => {
|
|
3814
3855
|
if (onBlur) {
|
|
3815
3856
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3824,7 +3865,7 @@ function RatingWidget({
|
|
|
3824
3865
|
}
|
|
3825
3866
|
return isFilled ? "\u2605" : "\u2606";
|
|
3826
3867
|
};
|
|
3827
|
-
return /* @__PURE__ */ (0,
|
|
3868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_jsx_runtime46.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
3828
3869
|
"div",
|
|
3829
3870
|
{
|
|
3830
3871
|
className: "rating-widget",
|
|
@@ -3837,7 +3878,7 @@ function RatingWidget({
|
|
|
3837
3878
|
[...Array(numStars)].map((_, index) => {
|
|
3838
3879
|
const starValue = min + index;
|
|
3839
3880
|
const isFilled = starValue <= value;
|
|
3840
|
-
return /* @__PURE__ */ (0,
|
|
3881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
3841
3882
|
"span",
|
|
3842
3883
|
{
|
|
3843
3884
|
onClick: () => handleStarClick(starValue),
|
|
@@ -3859,7 +3900,7 @@ function RatingWidget({
|
|
|
3859
3900
|
index
|
|
3860
3901
|
);
|
|
3861
3902
|
}),
|
|
3862
|
-
/* @__PURE__ */ (0,
|
|
3903
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
3863
3904
|
"input",
|
|
3864
3905
|
{
|
|
3865
3906
|
type: "hidden",
|
|
@@ -3877,9 +3918,9 @@ function RatingWidget({
|
|
|
3877
3918
|
}
|
|
3878
3919
|
|
|
3879
3920
|
// src/components/widgets/SelectWidget.tsx
|
|
3880
|
-
var
|
|
3921
|
+
var import_react21 = require("react");
|
|
3881
3922
|
var import_utils38 = require("@rjsf/utils");
|
|
3882
|
-
var
|
|
3923
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
3883
3924
|
function getValue(event, multiple) {
|
|
3884
3925
|
if (multiple) {
|
|
3885
3926
|
return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
|
|
@@ -3903,21 +3944,21 @@ function SelectWidget({
|
|
|
3903
3944
|
}) {
|
|
3904
3945
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
3905
3946
|
const emptyValue = multiple ? [] : "";
|
|
3906
|
-
const handleFocus = (0,
|
|
3947
|
+
const handleFocus = (0, import_react21.useCallback)(
|
|
3907
3948
|
(event) => {
|
|
3908
3949
|
const newValue = getValue(event, multiple);
|
|
3909
3950
|
return onFocus(id, (0, import_utils38.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
|
|
3910
3951
|
},
|
|
3911
3952
|
[onFocus, id, multiple, enumOptions, optEmptyVal]
|
|
3912
3953
|
);
|
|
3913
|
-
const handleBlur = (0,
|
|
3954
|
+
const handleBlur = (0, import_react21.useCallback)(
|
|
3914
3955
|
(event) => {
|
|
3915
3956
|
const newValue = getValue(event, multiple);
|
|
3916
3957
|
return onBlur(id, (0, import_utils38.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
|
|
3917
3958
|
},
|
|
3918
3959
|
[onBlur, id, multiple, enumOptions, optEmptyVal]
|
|
3919
3960
|
);
|
|
3920
|
-
const handleChange = (0,
|
|
3961
|
+
const handleChange = (0, import_react21.useCallback)(
|
|
3921
3962
|
(event) => {
|
|
3922
3963
|
const newValue = getValue(event, multiple);
|
|
3923
3964
|
return onChange((0, import_utils38.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
|
|
@@ -3926,7 +3967,7 @@ function SelectWidget({
|
|
|
3926
3967
|
);
|
|
3927
3968
|
const selectedIndexes = (0, import_utils38.enumOptionsIndexForValue)(value, enumOptions, multiple);
|
|
3928
3969
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
3929
|
-
return /* @__PURE__ */ (0,
|
|
3970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
3930
3971
|
"select",
|
|
3931
3972
|
{
|
|
3932
3973
|
id,
|
|
@@ -3943,10 +3984,10 @@ function SelectWidget({
|
|
|
3943
3984
|
onChange: handleChange,
|
|
3944
3985
|
"aria-describedby": (0, import_utils38.ariaDescribedByIds)(id),
|
|
3945
3986
|
children: [
|
|
3946
|
-
showPlaceholderOption && /* @__PURE__ */ (0,
|
|
3987
|
+
showPlaceholderOption && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: "", children: placeholder }),
|
|
3947
3988
|
Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
|
|
3948
3989
|
const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
|
|
3949
|
-
return /* @__PURE__ */ (0,
|
|
3990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("option", { value: String(i), disabled: disabled2, children: label }, i);
|
|
3950
3991
|
})
|
|
3951
3992
|
]
|
|
3952
3993
|
}
|
|
@@ -3955,9 +3996,9 @@ function SelectWidget({
|
|
|
3955
3996
|
var SelectWidget_default = SelectWidget;
|
|
3956
3997
|
|
|
3957
3998
|
// src/components/widgets/TextareaWidget.tsx
|
|
3958
|
-
var
|
|
3999
|
+
var import_react22 = require("react");
|
|
3959
4000
|
var import_utils39 = require("@rjsf/utils");
|
|
3960
|
-
var
|
|
4001
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
3961
4002
|
function TextareaWidget({
|
|
3962
4003
|
id,
|
|
3963
4004
|
options = {},
|
|
@@ -3971,19 +4012,19 @@ function TextareaWidget({
|
|
|
3971
4012
|
onBlur,
|
|
3972
4013
|
onFocus
|
|
3973
4014
|
}) {
|
|
3974
|
-
const handleChange = (0,
|
|
4015
|
+
const handleChange = (0, import_react22.useCallback)(
|
|
3975
4016
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
3976
4017
|
[onChange, options.emptyValue]
|
|
3977
4018
|
);
|
|
3978
|
-
const handleBlur = (0,
|
|
4019
|
+
const handleBlur = (0, import_react22.useCallback)(
|
|
3979
4020
|
({ target }) => onBlur(id, target && target.value),
|
|
3980
4021
|
[onBlur, id]
|
|
3981
4022
|
);
|
|
3982
|
-
const handleFocus = (0,
|
|
4023
|
+
const handleFocus = (0, import_react22.useCallback)(
|
|
3983
4024
|
({ target }) => onFocus(id, target && target.value),
|
|
3984
4025
|
[id, onFocus]
|
|
3985
4026
|
);
|
|
3986
|
-
return /* @__PURE__ */ (0,
|
|
4027
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
3987
4028
|
"textarea",
|
|
3988
4029
|
{
|
|
3989
4030
|
id,
|
|
@@ -4011,40 +4052,40 @@ var TextareaWidget_default = TextareaWidget;
|
|
|
4011
4052
|
|
|
4012
4053
|
// src/components/widgets/TextWidget.tsx
|
|
4013
4054
|
var import_utils40 = require("@rjsf/utils");
|
|
4014
|
-
var
|
|
4055
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
4015
4056
|
function TextWidget(props) {
|
|
4016
4057
|
const { options, registry } = props;
|
|
4017
4058
|
const BaseInputTemplate2 = (0, import_utils40.getTemplate)("BaseInputTemplate", registry, options);
|
|
4018
|
-
return /* @__PURE__ */ (0,
|
|
4059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(BaseInputTemplate2, { ...props });
|
|
4019
4060
|
}
|
|
4020
4061
|
|
|
4021
4062
|
// src/components/widgets/TimeWidget.tsx
|
|
4022
|
-
var
|
|
4063
|
+
var import_react23 = require("react");
|
|
4023
4064
|
var import_utils41 = require("@rjsf/utils");
|
|
4024
|
-
var
|
|
4065
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
4025
4066
|
function TimeWidget(props) {
|
|
4026
4067
|
const { onChange, options, registry } = props;
|
|
4027
4068
|
const BaseInputTemplate2 = (0, import_utils41.getTemplate)("BaseInputTemplate", registry, options);
|
|
4028
|
-
const handleChange = (0,
|
|
4029
|
-
return /* @__PURE__ */ (0,
|
|
4069
|
+
const handleChange = (0, import_react23.useCallback)((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
4070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
4030
4071
|
}
|
|
4031
4072
|
|
|
4032
4073
|
// src/components/widgets/URLWidget.tsx
|
|
4033
4074
|
var import_utils42 = require("@rjsf/utils");
|
|
4034
|
-
var
|
|
4075
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
4035
4076
|
function URLWidget(props) {
|
|
4036
4077
|
const { options, registry } = props;
|
|
4037
4078
|
const BaseInputTemplate2 = (0, import_utils42.getTemplate)("BaseInputTemplate", registry, options);
|
|
4038
|
-
return /* @__PURE__ */ (0,
|
|
4079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(BaseInputTemplate2, { type: "url", ...props });
|
|
4039
4080
|
}
|
|
4040
4081
|
|
|
4041
4082
|
// src/components/widgets/UpDownWidget.tsx
|
|
4042
4083
|
var import_utils43 = require("@rjsf/utils");
|
|
4043
|
-
var
|
|
4084
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
4044
4085
|
function UpDownWidget(props) {
|
|
4045
4086
|
const { options, registry } = props;
|
|
4046
4087
|
const BaseInputTemplate2 = (0, import_utils43.getTemplate)("BaseInputTemplate", registry, options);
|
|
4047
|
-
return /* @__PURE__ */ (0,
|
|
4088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(BaseInputTemplate2, { type: "number", ...props });
|
|
4048
4089
|
}
|
|
4049
4090
|
|
|
4050
4091
|
// src/components/widgets/index.ts
|
|
@@ -4082,17 +4123,21 @@ function getDefaultRegistry() {
|
|
|
4082
4123
|
widgets: widgets_default(),
|
|
4083
4124
|
rootSchema: {},
|
|
4084
4125
|
formContext: {},
|
|
4085
|
-
translateString: import_utils44.englishStringTranslator
|
|
4126
|
+
translateString: import_utils44.englishStringTranslator,
|
|
4127
|
+
globalFormOptions: { idPrefix: import_utils44.DEFAULT_ID_PREFIX, idSeparator: import_utils44.DEFAULT_ID_SEPARATOR }
|
|
4086
4128
|
};
|
|
4087
4129
|
}
|
|
4088
4130
|
|
|
4089
4131
|
// src/components/Form.tsx
|
|
4090
|
-
var
|
|
4091
|
-
var Form = class extends
|
|
4132
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
4133
|
+
var Form = class extends import_react24.Component {
|
|
4092
4134
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4093
4135
|
* provide any possible type here
|
|
4094
4136
|
*/
|
|
4095
4137
|
formElement;
|
|
4138
|
+
/** The list of pending changes
|
|
4139
|
+
*/
|
|
4140
|
+
pendingChanges = [];
|
|
4096
4141
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
4097
4142
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
4098
4143
|
* state construction.
|
|
@@ -4108,7 +4153,7 @@ var Form = class extends import_react22.Component {
|
|
|
4108
4153
|
if (this.props.onChange && !(0, import_utils45.deepEquals)(this.state.formData, this.props.formData)) {
|
|
4109
4154
|
this.props.onChange(this.state);
|
|
4110
4155
|
}
|
|
4111
|
-
this.formElement = (0,
|
|
4156
|
+
this.formElement = (0, import_react24.createRef)();
|
|
4112
4157
|
}
|
|
4113
4158
|
/**
|
|
4114
4159
|
* `getSnapshotBeforeUpdate` is a React lifecycle method that is invoked right before the most recently rendered
|
|
@@ -4131,8 +4176,10 @@ var Form = class extends import_react22.Component {
|
|
|
4131
4176
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
4132
4177
|
if (!(0, import_utils45.deepEquals)(this.props, prevProps)) {
|
|
4133
4178
|
const formDataChangedFields = (0, import_utils45.getChangedFields)(this.props.formData, prevProps.formData);
|
|
4179
|
+
const stateDataChangedFields = (0, import_utils45.getChangedFields)(this.props.formData, this.state.formData);
|
|
4134
4180
|
const isSchemaChanged = !(0, import_utils45.deepEquals)(prevProps.schema, this.props.schema);
|
|
4135
4181
|
const isFormDataChanged = formDataChangedFields.length > 0 || !(0, import_utils45.deepEquals)(prevProps.formData, this.props.formData);
|
|
4182
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !(0, import_utils45.deepEquals)(this.state.formData, this.props.formData);
|
|
4136
4183
|
const nextState = this.getStateFromProps(
|
|
4137
4184
|
this.props,
|
|
4138
4185
|
this.props.formData,
|
|
@@ -4141,7 +4188,9 @@ var Form = class extends import_react22.Component {
|
|
|
4141
4188
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
4142
4189
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
4143
4190
|
isSchemaChanged,
|
|
4144
|
-
formDataChangedFields
|
|
4191
|
+
formDataChangedFields,
|
|
4192
|
+
// Skip live validation for this request if no form data has changed from the last state
|
|
4193
|
+
!isStateDataChanged
|
|
4145
4194
|
);
|
|
4146
4195
|
const shouldUpdate = !(0, import_utils45.deepEquals)(nextState, prevState);
|
|
4147
4196
|
return { nextState, shouldUpdate };
|
|
@@ -4178,35 +4227,37 @@ var Form = class extends import_react22.Component {
|
|
|
4178
4227
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4179
4228
|
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
4180
4229
|
* @param formDataChangedFields - The changed fields of `formData`
|
|
4230
|
+
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
4181
4231
|
* @returns - The new state for the `Form`
|
|
4182
4232
|
*/
|
|
4183
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
|
|
4233
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
4184
4234
|
const state = this.state || {};
|
|
4185
4235
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4236
|
+
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
4186
4237
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
4187
4238
|
const edit = typeof inputFormData !== "undefined";
|
|
4188
4239
|
const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
|
|
4189
4240
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
4190
|
-
const rootSchema = schema;
|
|
4191
4241
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4192
4242
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
4193
4243
|
let schemaUtils = state.schemaUtils;
|
|
4194
4244
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
4195
|
-
|
|
4196
|
-
|
|
4245
|
+
validator2,
|
|
4246
|
+
schema,
|
|
4197
4247
|
experimental_defaultFormStateBehavior,
|
|
4198
4248
|
experimental_customMergeAllOf
|
|
4199
4249
|
)) {
|
|
4200
4250
|
schemaUtils = (0, import_utils45.createSchemaUtils)(
|
|
4201
|
-
|
|
4202
|
-
|
|
4251
|
+
validator2,
|
|
4252
|
+
schema,
|
|
4203
4253
|
experimental_defaultFormStateBehavior,
|
|
4204
4254
|
experimental_customMergeAllOf
|
|
4205
4255
|
);
|
|
4206
4256
|
}
|
|
4207
|
-
const
|
|
4257
|
+
const rootSchema = schemaUtils.getRootSchema();
|
|
4258
|
+
const formData = schemaUtils.getDefaultFormState(rootSchema, inputFormData);
|
|
4208
4259
|
const _retrievedSchema = this.updateRetrievedSchema(
|
|
4209
|
-
retrievedSchema ?? schemaUtils.retrieveSchema(
|
|
4260
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4210
4261
|
);
|
|
4211
4262
|
const getCurrentErrors = () => {
|
|
4212
4263
|
if (props.noValidate || isSchemaChanged) {
|
|
@@ -4226,8 +4277,8 @@ var Form = class extends import_react22.Component {
|
|
|
4226
4277
|
let errorSchema;
|
|
4227
4278
|
let schemaValidationErrors = state.schemaValidationErrors;
|
|
4228
4279
|
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
4229
|
-
if (mustValidate) {
|
|
4230
|
-
const schemaValidation = this.validate(formData,
|
|
4280
|
+
if (mustValidate && !skipLiveValidate) {
|
|
4281
|
+
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, _retrievedSchema);
|
|
4231
4282
|
errors = schemaValidation.errors;
|
|
4232
4283
|
if (retrievedSchema === void 0) {
|
|
4233
4284
|
errorSchema = schemaValidation.errorSchema;
|
|
@@ -4244,7 +4295,7 @@ var Form = class extends import_react22.Component {
|
|
|
4244
4295
|
const currentErrors = getCurrentErrors();
|
|
4245
4296
|
errors = currentErrors.errors;
|
|
4246
4297
|
errorSchema = currentErrors.errorSchema;
|
|
4247
|
-
if (formDataChangedFields.length > 0) {
|
|
4298
|
+
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
4248
4299
|
const newErrorSchema = formDataChangedFields.reduce(
|
|
4249
4300
|
(acc, key) => {
|
|
4250
4301
|
acc[key] = void 0;
|
|
@@ -4264,18 +4315,12 @@ var Form = class extends import_react22.Component {
|
|
|
4264
4315
|
errorSchema = merged.errorSchema;
|
|
4265
4316
|
errors = merged.errors;
|
|
4266
4317
|
}
|
|
4267
|
-
const
|
|
4268
|
-
_retrievedSchema,
|
|
4269
|
-
uiSchema["ui:rootFieldId"],
|
|
4270
|
-
formData,
|
|
4271
|
-
props.idPrefix,
|
|
4272
|
-
props.idSeparator
|
|
4273
|
-
);
|
|
4318
|
+
const fieldPathId = (0, import_utils45.toFieldPathId)("", this.getGlobalFormOptions(this.props));
|
|
4274
4319
|
const nextState = {
|
|
4275
4320
|
schemaUtils,
|
|
4276
|
-
schema,
|
|
4321
|
+
schema: rootSchema,
|
|
4277
4322
|
uiSchema,
|
|
4278
|
-
|
|
4323
|
+
fieldPathId,
|
|
4279
4324
|
formData,
|
|
4280
4325
|
edit,
|
|
4281
4326
|
errors,
|
|
@@ -4293,7 +4338,8 @@ var Form = class extends import_react22.Component {
|
|
|
4293
4338
|
* @returns - True if the component should be updated, false otherwise
|
|
4294
4339
|
*/
|
|
4295
4340
|
shouldComponentUpdate(nextProps, nextState) {
|
|
4296
|
-
|
|
4341
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = this.props;
|
|
4342
|
+
return (0, import_utils45.shouldRender)(this, nextProps, nextState, experimental_componentUpdateStrategy);
|
|
4297
4343
|
}
|
|
4298
4344
|
/** Gets the previously raised customValidate errors.
|
|
4299
4345
|
*
|
|
@@ -4305,8 +4351,7 @@ var Form = class extends import_react22.Component {
|
|
|
4305
4351
|
let customValidateErrors = {};
|
|
4306
4352
|
if (typeof customValidate === "function") {
|
|
4307
4353
|
const errorHandler = customValidate(prevFormData, (0, import_utils45.createErrorHandler)(prevFormData), uiSchema);
|
|
4308
|
-
|
|
4309
|
-
customValidateErrors = userErrorSchema;
|
|
4354
|
+
customValidateErrors = (0, import_utils45.unwrapErrorHandler)(errorHandler);
|
|
4310
4355
|
}
|
|
4311
4356
|
return customValidateErrors;
|
|
4312
4357
|
}
|
|
@@ -4315,9 +4360,10 @@ var Form = class extends import_react22.Component {
|
|
|
4315
4360
|
*
|
|
4316
4361
|
* @param formData - The new form data to validate
|
|
4317
4362
|
* @param schema - The schema used to validate against
|
|
4318
|
-
* @param altSchemaUtils - The alternate schemaUtils to use for validation
|
|
4363
|
+
* @param [altSchemaUtils] - The alternate schemaUtils to use for validation
|
|
4364
|
+
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
4319
4365
|
*/
|
|
4320
|
-
validate(formData, schema = this.
|
|
4366
|
+
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
4321
4367
|
const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
|
|
4322
4368
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4323
4369
|
const resolvedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
@@ -4326,18 +4372,16 @@ var Form = class extends import_react22.Component {
|
|
|
4326
4372
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4327
4373
|
renderErrors(registry) {
|
|
4328
4374
|
const { errors, errorSchema, schema, uiSchema } = this.state;
|
|
4329
|
-
const { formContext } = this.props;
|
|
4330
4375
|
const options = (0, import_utils45.getUiOptions)(uiSchema);
|
|
4331
4376
|
const ErrorListTemplate = (0, import_utils45.getTemplate)("ErrorListTemplate", registry, options);
|
|
4332
4377
|
if (errors && errors.length) {
|
|
4333
|
-
return /* @__PURE__ */ (0,
|
|
4378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4334
4379
|
ErrorListTemplate,
|
|
4335
4380
|
{
|
|
4336
4381
|
errors,
|
|
4337
4382
|
errorSchema: errorSchema || {},
|
|
4338
4383
|
schema,
|
|
4339
4384
|
uiSchema,
|
|
4340
|
-
formContext,
|
|
4341
4385
|
registry
|
|
4342
4386
|
}
|
|
4343
4387
|
);
|
|
@@ -4365,19 +4409,23 @@ var Form = class extends import_react22.Component {
|
|
|
4365
4409
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4366
4410
|
*/
|
|
4367
4411
|
getFieldNames = (pathSchema, formData) => {
|
|
4412
|
+
const formValueHasData = (value, isLeaf) => typeof value !== "object" || (0, import_isEmpty4.default)(value) || isLeaf && !(0, import_isEmpty4.default)(value);
|
|
4368
4413
|
const getAllPaths = (_obj, acc = [], paths = [[]]) => {
|
|
4369
|
-
Object.keys(_obj)
|
|
4370
|
-
|
|
4414
|
+
const objKeys = Object.keys(_obj);
|
|
4415
|
+
objKeys.forEach((key) => {
|
|
4416
|
+
const data = _obj[key];
|
|
4417
|
+
if (typeof data === "object") {
|
|
4371
4418
|
const newPaths = paths.map((path) => [...path, key]);
|
|
4372
|
-
if (
|
|
4373
|
-
acc.push(
|
|
4419
|
+
if (data[import_utils45.RJSF_ADDITIONAL_PROPERTIES_FLAG] && data[import_utils45.NAME_KEY] !== "") {
|
|
4420
|
+
acc.push(data[import_utils45.NAME_KEY]);
|
|
4374
4421
|
} else {
|
|
4375
|
-
getAllPaths(
|
|
4422
|
+
getAllPaths(data, acc, newPaths);
|
|
4376
4423
|
}
|
|
4377
|
-
} else if (key === import_utils45.NAME_KEY &&
|
|
4424
|
+
} else if (key === import_utils45.NAME_KEY && data !== "") {
|
|
4378
4425
|
paths.forEach((path) => {
|
|
4379
4426
|
const formValue = (0, import_get6.default)(formData, path);
|
|
4380
|
-
|
|
4427
|
+
const isLeaf = objKeys.length === 1;
|
|
4428
|
+
if (formValueHasData(formValue, isLeaf) || Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf))) {
|
|
4381
4429
|
acc.push(path);
|
|
4382
4430
|
}
|
|
4383
4431
|
});
|
|
@@ -4397,10 +4445,15 @@ var Form = class extends import_react22.Component {
|
|
|
4397
4445
|
const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
4398
4446
|
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
|
|
4399
4447
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
4400
|
-
|
|
4401
|
-
return newFormData;
|
|
4448
|
+
return this.getUsedFormData(formData, fieldNames);
|
|
4402
4449
|
};
|
|
4403
|
-
|
|
4450
|
+
/** Filtering errors based on your retrieved schema to only show errors for properties in the selected branch.
|
|
4451
|
+
*
|
|
4452
|
+
* @param schemaErrors - The schema errors to filter
|
|
4453
|
+
* @param [resolvedSchema] - An optionally resolved schema to use for performance reasons
|
|
4454
|
+
* @param [formData] - The formData to help filter errors
|
|
4455
|
+
* @private
|
|
4456
|
+
*/
|
|
4404
4457
|
filterErrorsBasedOnSchema(schemaErrors, resolvedSchema, formData) {
|
|
4405
4458
|
const { retrievedSchema, schemaUtils } = this.state;
|
|
4406
4459
|
const _retrievedSchema = resolvedSchema ?? retrievedSchema;
|
|
@@ -4408,7 +4461,7 @@ var Form = class extends import_react22.Component {
|
|
|
4408
4461
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
4409
4462
|
const filteredErrors = (0, import_pick.default)(schemaErrors, fieldNames);
|
|
4410
4463
|
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
4411
|
-
filteredErrors.
|
|
4464
|
+
filteredErrors[import_utils45.ERRORS_KEY] = schemaErrors[import_utils45.ERRORS_KEY];
|
|
4412
4465
|
}
|
|
4413
4466
|
const prevCustomValidateErrors = this.getPreviousCustomValidateErrors();
|
|
4414
4467
|
const filterPreviousCustomErrors = (errors = [], prevCustomErrors) => {
|
|
@@ -4424,9 +4477,14 @@ var Form = class extends import_react22.Component {
|
|
|
4424
4477
|
const prevCustomValidateErrorAtKey = previousCustomValidateErrors[errorKey];
|
|
4425
4478
|
if ((0, import_isNil.default)(errorAtKey) || Array.isArray(errorAtKey) && errorAtKey.length === 0) {
|
|
4426
4479
|
delete errors[errorKey];
|
|
4427
|
-
} else if ((0, import_utils45.isObject)(errorAtKey) && (0, import_utils45.isObject)(prevCustomValidateErrorAtKey) && Array.isArray(prevCustomValidateErrorAtKey?.
|
|
4428
|
-
errors[errorKey] =
|
|
4429
|
-
|
|
4480
|
+
} else if ((0, import_utils45.isObject)(errorAtKey) && (0, import_utils45.isObject)(prevCustomValidateErrorAtKey) && Array.isArray(prevCustomValidateErrorAtKey?.[import_utils45.ERRORS_KEY])) {
|
|
4481
|
+
errors[errorKey] = {
|
|
4482
|
+
[import_utils45.ERRORS_KEY]: filterPreviousCustomErrors(
|
|
4483
|
+
errorAtKey[import_utils45.ERRORS_KEY],
|
|
4484
|
+
prevCustomValidateErrorAtKey?.[import_utils45.ERRORS_KEY]
|
|
4485
|
+
)
|
|
4486
|
+
};
|
|
4487
|
+
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey[import_utils45.ERRORS_KEY])) {
|
|
4430
4488
|
filterNilOrEmptyErrors(errorAtKey, previousCustomValidateErrors[errorKey]);
|
|
4431
4489
|
}
|
|
4432
4490
|
});
|
|
@@ -4434,23 +4492,46 @@ var Form = class extends import_react22.Component {
|
|
|
4434
4492
|
};
|
|
4435
4493
|
return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
|
|
4436
4494
|
}
|
|
4437
|
-
/**
|
|
4438
|
-
*
|
|
4439
|
-
* then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
|
|
4440
|
-
* in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
|
|
4441
|
-
* updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
|
|
4442
|
-
* callback will be called if specified with the updated state.
|
|
4495
|
+
/** Pushes the given change information into the `pendingChanges` array and then calls `processPendingChanges()` if
|
|
4496
|
+
* the array only contains a single pending change.
|
|
4443
4497
|
*
|
|
4444
|
-
* @param
|
|
4445
|
-
* @param
|
|
4446
|
-
* @param
|
|
4498
|
+
* @param newValue - The new form data from a change to a field
|
|
4499
|
+
* @param path - The path to the change into which to set the formData
|
|
4500
|
+
* @param [newErrorSchema] - The new `ErrorSchema` based on the field change
|
|
4501
|
+
* @param [id] - The id of the field that caused the change
|
|
4502
|
+
*/
|
|
4503
|
+
onChange = (newValue, path, newErrorSchema, id) => {
|
|
4504
|
+
this.pendingChanges.push({ newValue, path, newErrorSchema, id });
|
|
4505
|
+
if (this.pendingChanges.length === 1) {
|
|
4506
|
+
this.processPendingChange();
|
|
4507
|
+
}
|
|
4508
|
+
};
|
|
4509
|
+
/** Function to handle changes made to a field in the `Form`. This handler gets the first change from the
|
|
4510
|
+
* `pendingChanges` list, containing the `newValue` for the `formData` and the `path` at which the `newValue` is to be
|
|
4511
|
+
* updated, along with a new, optional `ErrorSchema` for that same `path` and potentially the `id` of the field being
|
|
4512
|
+
* changed. It will first update the `formData` with any missing default fields and then, if `omitExtraData` and
|
|
4513
|
+
* `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not in a form field. Then, the
|
|
4514
|
+
* resulting `formData` will be validated if required. The state will be updated with the new updated (potentially
|
|
4515
|
+
* filtered) `formData`, any errors that resulted from validation. Finally the `onChange` callback will be called, if
|
|
4516
|
+
* specified, with the updated state and the `processPendingChange()` function is called again.
|
|
4447
4517
|
*/
|
|
4448
|
-
|
|
4518
|
+
processPendingChange() {
|
|
4519
|
+
if (this.pendingChanges.length === 0) {
|
|
4520
|
+
return;
|
|
4521
|
+
}
|
|
4522
|
+
const { newValue, path, id } = this.pendingChanges[0];
|
|
4523
|
+
let { newErrorSchema } = this.pendingChanges[0];
|
|
4449
4524
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4450
|
-
const { schemaUtils, schema } = this.state;
|
|
4525
|
+
const { formData: oldFormData, schemaUtils, schema, errorSchema, fieldPathId } = this.state;
|
|
4526
|
+
const rootPathId = fieldPathId.path[0] || "";
|
|
4527
|
+
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4451
4528
|
let retrievedSchema = this.state.retrievedSchema;
|
|
4529
|
+
let formData = isRootPath ? newValue : (0, import_cloneDeep3.default)(oldFormData);
|
|
4452
4530
|
if ((0, import_utils45.isObject)(formData) || Array.isArray(formData)) {
|
|
4453
|
-
|
|
4531
|
+
if (!isRootPath) {
|
|
4532
|
+
(0, import_set5.default)(formData, path, newValue);
|
|
4533
|
+
}
|
|
4534
|
+
const newState = this.getStateFromProps(this.props, formData, void 0, void 0, void 0, true);
|
|
4454
4535
|
formData = newState.formData;
|
|
4455
4536
|
retrievedSchema = newState.retrievedSchema;
|
|
4456
4537
|
}
|
|
@@ -4463,38 +4544,49 @@ var Form = class extends import_react22.Component {
|
|
|
4463
4544
|
formData: newFormData
|
|
4464
4545
|
};
|
|
4465
4546
|
}
|
|
4466
|
-
if (
|
|
4547
|
+
if (newErrorSchema && !isRootPath) {
|
|
4548
|
+
const errorSchemaCopy = (0, import_cloneDeep3.default)(errorSchema);
|
|
4549
|
+
(0, import_set5.default)(errorSchemaCopy, path, newErrorSchema);
|
|
4550
|
+
newErrorSchema = errorSchemaCopy;
|
|
4551
|
+
}
|
|
4552
|
+
if (mustValidate && this.pendingChanges.length === 1) {
|
|
4467
4553
|
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
4468
4554
|
let errors = schemaValidation.errors;
|
|
4469
|
-
let
|
|
4555
|
+
let errorSchema2 = schemaValidation.errorSchema;
|
|
4470
4556
|
const schemaValidationErrors = errors;
|
|
4471
|
-
const schemaValidationErrorSchema =
|
|
4557
|
+
const schemaValidationErrorSchema = errorSchema2;
|
|
4472
4558
|
if (extraErrors) {
|
|
4473
4559
|
const merged = (0, import_utils45.validationDataMerge)(schemaValidation, extraErrors);
|
|
4474
|
-
|
|
4560
|
+
errorSchema2 = merged.errorSchema;
|
|
4475
4561
|
errors = merged.errors;
|
|
4476
4562
|
}
|
|
4477
4563
|
if (newErrorSchema) {
|
|
4478
4564
|
const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
|
|
4479
|
-
|
|
4565
|
+
errorSchema2 = (0, import_utils45.mergeObjects)(errorSchema2, filteredErrors, "preventDuplicates");
|
|
4480
4566
|
}
|
|
4481
4567
|
state = {
|
|
4482
4568
|
formData: newFormData,
|
|
4483
4569
|
errors,
|
|
4484
|
-
errorSchema,
|
|
4570
|
+
errorSchema: errorSchema2,
|
|
4485
4571
|
schemaValidationErrors,
|
|
4486
4572
|
schemaValidationErrorSchema
|
|
4487
4573
|
};
|
|
4488
4574
|
} else if (!noValidate && newErrorSchema) {
|
|
4489
|
-
const
|
|
4575
|
+
const errorSchema2 = extraErrors ? (0, import_utils45.mergeObjects)(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
|
|
4490
4576
|
state = {
|
|
4491
4577
|
formData: newFormData,
|
|
4492
|
-
errorSchema,
|
|
4493
|
-
errors: (0, import_utils45.toErrorList)(
|
|
4578
|
+
errorSchema: errorSchema2,
|
|
4579
|
+
errors: (0, import_utils45.toErrorList)(errorSchema2)
|
|
4494
4580
|
};
|
|
4495
4581
|
}
|
|
4496
|
-
this.setState(state, () =>
|
|
4497
|
-
|
|
4582
|
+
this.setState(state, () => {
|
|
4583
|
+
if (onChange) {
|
|
4584
|
+
onChange({ ...this.state, ...state }, id);
|
|
4585
|
+
}
|
|
4586
|
+
this.pendingChanges.shift();
|
|
4587
|
+
this.processPendingChange();
|
|
4588
|
+
});
|
|
4589
|
+
}
|
|
4498
4590
|
/**
|
|
4499
4591
|
* If the retrievedSchema has changed the new retrievedSchema is returned.
|
|
4500
4592
|
* Otherwise, the old retrievedSchema is returned to persist reference.
|
|
@@ -4589,10 +4681,26 @@ var Form = class extends import_react22.Component {
|
|
|
4589
4681
|
);
|
|
4590
4682
|
}
|
|
4591
4683
|
};
|
|
4684
|
+
/** Extracts the `GlobalFormOptions` from the given Form `props`
|
|
4685
|
+
*
|
|
4686
|
+
* @param props - The form props to extract the global form options from
|
|
4687
|
+
* @returns - The `GlobalFormOptions` from the props
|
|
4688
|
+
* @private
|
|
4689
|
+
*/
|
|
4690
|
+
getGlobalFormOptions(props) {
|
|
4691
|
+
const {
|
|
4692
|
+
uiSchema = {},
|
|
4693
|
+
experimental_componentUpdateStrategy,
|
|
4694
|
+
idSeparator = import_utils45.DEFAULT_ID_SEPARATOR,
|
|
4695
|
+
idPrefix = import_utils45.DEFAULT_ID_PREFIX
|
|
4696
|
+
} = props;
|
|
4697
|
+
const rootFieldId = uiSchema["ui:rootFieldId"];
|
|
4698
|
+
return { idPrefix: rootFieldId || idPrefix, idSeparator, experimental_componentUpdateStrategy };
|
|
4699
|
+
}
|
|
4592
4700
|
/** Returns the registry for the form */
|
|
4593
4701
|
getRegistry() {
|
|
4594
4702
|
const { translateString: customTranslateString, uiSchema = {} } = this.props;
|
|
4595
|
-
const { schemaUtils } = this.state;
|
|
4703
|
+
const { schema, schemaUtils } = this.state;
|
|
4596
4704
|
const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
|
|
4597
4705
|
return {
|
|
4598
4706
|
fields: { ...fields2, ...this.props.fields },
|
|
@@ -4605,11 +4713,12 @@ var Form = class extends import_react22.Component {
|
|
|
4605
4713
|
}
|
|
4606
4714
|
},
|
|
4607
4715
|
widgets: { ...widgets2, ...this.props.widgets },
|
|
4608
|
-
rootSchema:
|
|
4716
|
+
rootSchema: schema,
|
|
4609
4717
|
formContext: this.props.formContext || formContext,
|
|
4610
4718
|
schemaUtils,
|
|
4611
4719
|
translateString: customTranslateString || translateString,
|
|
4612
|
-
globalUiOptions: uiSchema[import_utils45.UI_GLOBAL_OPTIONS_KEY]
|
|
4720
|
+
globalUiOptions: uiSchema[import_utils45.UI_GLOBAL_OPTIONS_KEY],
|
|
4721
|
+
globalFormOptions: this.getGlobalFormOptions(this.props)
|
|
4613
4722
|
};
|
|
4614
4723
|
}
|
|
4615
4724
|
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
@@ -4724,8 +4833,6 @@ var Form = class extends import_react22.Component {
|
|
|
4724
4833
|
const {
|
|
4725
4834
|
children,
|
|
4726
4835
|
id,
|
|
4727
|
-
idPrefix,
|
|
4728
|
-
idSeparator,
|
|
4729
4836
|
className = "",
|
|
4730
4837
|
tagName,
|
|
4731
4838
|
name,
|
|
@@ -4738,11 +4845,10 @@ var Form = class extends import_react22.Component {
|
|
|
4738
4845
|
noHtml5Validate = false,
|
|
4739
4846
|
disabled,
|
|
4740
4847
|
readonly,
|
|
4741
|
-
formContext,
|
|
4742
4848
|
showErrorList = "top",
|
|
4743
4849
|
_internalFormWrapper
|
|
4744
4850
|
} = this.props;
|
|
4745
|
-
const { schema, uiSchema, formData, errorSchema,
|
|
4851
|
+
const { schema, uiSchema, formData, errorSchema, fieldPathId } = this.state;
|
|
4746
4852
|
const registry = this.getRegistry();
|
|
4747
4853
|
const { SchemaField: _SchemaField } = registry.fields;
|
|
4748
4854
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
@@ -4753,7 +4859,7 @@ var Form = class extends import_react22.Component {
|
|
|
4753
4859
|
submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
|
|
4754
4860
|
}
|
|
4755
4861
|
const submitUiSchema = { [import_utils45.UI_OPTIONS_KEY]: { [import_utils45.SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
|
|
4756
|
-
return /* @__PURE__ */ (0,
|
|
4862
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
|
|
4757
4863
|
FormTag,
|
|
4758
4864
|
{
|
|
4759
4865
|
className: className ? className : "rjsf",
|
|
@@ -4771,17 +4877,14 @@ var Form = class extends import_react22.Component {
|
|
|
4771
4877
|
ref: this.formElement,
|
|
4772
4878
|
children: [
|
|
4773
4879
|
showErrorList === "top" && this.renderErrors(registry),
|
|
4774
|
-
/* @__PURE__ */ (0,
|
|
4880
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
4775
4881
|
_SchemaField,
|
|
4776
4882
|
{
|
|
4777
4883
|
name: "",
|
|
4778
4884
|
schema,
|
|
4779
4885
|
uiSchema,
|
|
4780
4886
|
errorSchema,
|
|
4781
|
-
|
|
4782
|
-
idPrefix,
|
|
4783
|
-
idSeparator,
|
|
4784
|
-
formContext,
|
|
4887
|
+
fieldPathId,
|
|
4785
4888
|
formData,
|
|
4786
4889
|
onChange: this.onChange,
|
|
4787
4890
|
onBlur: this.onBlur,
|
|
@@ -4791,7 +4894,7 @@ var Form = class extends import_react22.Component {
|
|
|
4791
4894
|
readonly
|
|
4792
4895
|
}
|
|
4793
4896
|
),
|
|
4794
|
-
children ? children : /* @__PURE__ */ (0,
|
|
4897
|
+
children ? children : /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
4795
4898
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
4796
4899
|
]
|
|
4797
4900
|
}
|
|
@@ -4800,10 +4903,10 @@ var Form = class extends import_react22.Component {
|
|
|
4800
4903
|
};
|
|
4801
4904
|
|
|
4802
4905
|
// src/withTheme.tsx
|
|
4803
|
-
var
|
|
4804
|
-
var
|
|
4906
|
+
var import_react25 = require("react");
|
|
4907
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
4805
4908
|
function withTheme(themeProps) {
|
|
4806
|
-
return (0,
|
|
4909
|
+
return (0, import_react25.forwardRef)(
|
|
4807
4910
|
({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
|
|
4808
4911
|
fields2 = { ...themeProps?.fields, ...fields2 };
|
|
4809
4912
|
widgets2 = { ...themeProps?.widgets, ...widgets2 };
|
|
@@ -4815,7 +4918,7 @@ function withTheme(themeProps) {
|
|
|
4815
4918
|
...templates2?.ButtonTemplates
|
|
4816
4919
|
}
|
|
4817
4920
|
};
|
|
4818
|
-
return /* @__PURE__ */ (0,
|
|
4921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
4819
4922
|
Form,
|
|
4820
4923
|
{
|
|
4821
4924
|
...themeProps,
|
|
@@ -4830,6 +4933,24 @@ function withTheme(themeProps) {
|
|
|
4830
4933
|
);
|
|
4831
4934
|
}
|
|
4832
4935
|
|
|
4936
|
+
// src/getTestRegistry.tsx
|
|
4937
|
+
var import_utils46 = require("@rjsf/utils");
|
|
4938
|
+
var import_validator_ajv8 = __toESM(require("@rjsf/validator-ajv8"), 1);
|
|
4939
|
+
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = { idPrefix: import_utils46.DEFAULT_ID_PREFIX, idSeparator: import_utils46.DEFAULT_ID_SEPARATOR }) {
|
|
4940
|
+
const defaults = getDefaultRegistry();
|
|
4941
|
+
const schemaUtils = (0, import_utils46.createSchemaUtils)(import_validator_ajv8.default, rootSchema);
|
|
4942
|
+
return {
|
|
4943
|
+
fields: { ...defaults.fields, ...fields2 },
|
|
4944
|
+
templates: { ...defaults.templates, ...templates2 },
|
|
4945
|
+
widgets: { ...defaults.widgets, ...widgets2 },
|
|
4946
|
+
formContext,
|
|
4947
|
+
rootSchema,
|
|
4948
|
+
schemaUtils,
|
|
4949
|
+
translateString: import_utils46.englishStringTranslator,
|
|
4950
|
+
globalFormOptions
|
|
4951
|
+
};
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4833
4954
|
// src/index.ts
|
|
4834
4955
|
var index_default = Form;
|
|
4835
|
-
//# sourceMappingURL=index.
|
|
4956
|
+
//# sourceMappingURL=index.cjs.map
|