@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
package/dist/index.esm.js
CHANGED
|
@@ -2,32 +2,42 @@
|
|
|
2
2
|
import { Component as Component5, createRef } from "react";
|
|
3
3
|
import {
|
|
4
4
|
createSchemaUtils,
|
|
5
|
-
deepEquals as
|
|
5
|
+
deepEquals as deepEquals2,
|
|
6
|
+
ERRORS_KEY as ERRORS_KEY3,
|
|
6
7
|
getChangedFields,
|
|
7
|
-
getTemplate as
|
|
8
|
+
getTemplate as getTemplate25,
|
|
8
9
|
getUiOptions as getUiOptions17,
|
|
9
10
|
isObject as isObject6,
|
|
10
|
-
mergeObjects
|
|
11
|
+
mergeObjects,
|
|
11
12
|
NAME_KEY,
|
|
12
13
|
RJSF_ADDITIONAL_PROPERTIES_FLAG,
|
|
13
|
-
shouldRender,
|
|
14
|
+
shouldRender as shouldRender2,
|
|
14
15
|
SUBMIT_BTN_OPTIONS_KEY,
|
|
15
16
|
toErrorList,
|
|
16
|
-
|
|
17
|
+
toFieldPathId as toFieldPathId4,
|
|
18
|
+
UI_GLOBAL_OPTIONS_KEY as UI_GLOBAL_OPTIONS_KEY2,
|
|
17
19
|
UI_OPTIONS_KEY as UI_OPTIONS_KEY3,
|
|
18
20
|
validationDataMerge,
|
|
19
21
|
createErrorHandler,
|
|
20
|
-
unwrapErrorHandler
|
|
22
|
+
unwrapErrorHandler,
|
|
23
|
+
DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR2,
|
|
24
|
+
DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX2
|
|
21
25
|
} from "@rjsf/utils";
|
|
26
|
+
import _cloneDeep from "lodash/cloneDeep";
|
|
22
27
|
import _forEach from "lodash/forEach";
|
|
23
28
|
import _get from "lodash/get";
|
|
24
29
|
import _isEmpty from "lodash/isEmpty";
|
|
25
30
|
import _isNil from "lodash/isNil";
|
|
26
31
|
import _pick from "lodash/pick";
|
|
32
|
+
import _set from "lodash/set";
|
|
27
33
|
import _toPath from "lodash/toPath";
|
|
28
34
|
|
|
29
35
|
// src/getDefaultRegistry.ts
|
|
30
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
DEFAULT_ID_PREFIX,
|
|
38
|
+
DEFAULT_ID_SEPARATOR,
|
|
39
|
+
englishStringTranslator
|
|
40
|
+
} from "@rjsf/utils";
|
|
31
41
|
|
|
32
42
|
// src/components/fields/ArrayField.tsx
|
|
33
43
|
import { Component } from "react";
|
|
@@ -39,6 +49,7 @@ import {
|
|
|
39
49
|
allowAdditionalItems,
|
|
40
50
|
isCustomWidget,
|
|
41
51
|
optionsList,
|
|
52
|
+
toFieldPathId,
|
|
42
53
|
TranslatableString,
|
|
43
54
|
ITEMS_KEY
|
|
44
55
|
} from "@rjsf/utils";
|
|
@@ -46,10 +57,10 @@ import cloneDeep from "lodash/cloneDeep";
|
|
|
46
57
|
import get from "lodash/get";
|
|
47
58
|
import isObject from "lodash/isObject";
|
|
48
59
|
import set from "lodash/set";
|
|
49
|
-
import
|
|
60
|
+
import uniqueId from "lodash/uniqueId";
|
|
50
61
|
import { jsx } from "react/jsx-runtime";
|
|
51
62
|
function generateRowId() {
|
|
52
|
-
return
|
|
63
|
+
return uniqueId("rjsf-array-item-");
|
|
53
64
|
}
|
|
54
65
|
function generateKeyedFormData(formData) {
|
|
55
66
|
return !Array.isArray(formData) ? [] : formData.map((item) => {
|
|
@@ -169,7 +180,7 @@ var ArrayField = class extends Component {
|
|
|
169
180
|
if (event) {
|
|
170
181
|
event.preventDefault();
|
|
171
182
|
}
|
|
172
|
-
const { onChange, errorSchema } = this.props;
|
|
183
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
173
184
|
const { keyedFormData } = this.state;
|
|
174
185
|
let newErrorSchema;
|
|
175
186
|
if (errorSchema) {
|
|
@@ -198,7 +209,8 @@ var ArrayField = class extends Component {
|
|
|
198
209
|
keyedFormData: newKeyedFormData,
|
|
199
210
|
updatedKeyedFormData: true
|
|
200
211
|
},
|
|
201
|
-
|
|
212
|
+
// add click will pass the empty `path` array to the onChange which adds the appropriate path
|
|
213
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
202
214
|
);
|
|
203
215
|
}
|
|
204
216
|
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
@@ -232,7 +244,7 @@ var ArrayField = class extends Component {
|
|
|
232
244
|
if (event) {
|
|
233
245
|
event.preventDefault();
|
|
234
246
|
}
|
|
235
|
-
const { onChange, errorSchema } = this.props;
|
|
247
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
236
248
|
const { keyedFormData } = this.state;
|
|
237
249
|
let newErrorSchema;
|
|
238
250
|
if (errorSchema) {
|
|
@@ -261,7 +273,7 @@ var ArrayField = class extends Component {
|
|
|
261
273
|
keyedFormData: newKeyedFormData,
|
|
262
274
|
updatedKeyedFormData: true
|
|
263
275
|
},
|
|
264
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
276
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
265
277
|
);
|
|
266
278
|
};
|
|
267
279
|
};
|
|
@@ -276,7 +288,7 @@ var ArrayField = class extends Component {
|
|
|
276
288
|
if (event) {
|
|
277
289
|
event.preventDefault();
|
|
278
290
|
}
|
|
279
|
-
const { onChange, errorSchema } = this.props;
|
|
291
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
280
292
|
const { keyedFormData } = this.state;
|
|
281
293
|
let newErrorSchema;
|
|
282
294
|
if (errorSchema) {
|
|
@@ -296,7 +308,7 @@ var ArrayField = class extends Component {
|
|
|
296
308
|
keyedFormData: newKeyedFormData,
|
|
297
309
|
updatedKeyedFormData: true
|
|
298
310
|
},
|
|
299
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
311
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
300
312
|
);
|
|
301
313
|
};
|
|
302
314
|
};
|
|
@@ -313,7 +325,7 @@ var ArrayField = class extends Component {
|
|
|
313
325
|
event.preventDefault();
|
|
314
326
|
event.currentTarget.blur();
|
|
315
327
|
}
|
|
316
|
-
const { onChange, errorSchema } = this.props;
|
|
328
|
+
const { onChange, errorSchema, fieldPathId } = this.props;
|
|
317
329
|
let newErrorSchema;
|
|
318
330
|
if (errorSchema) {
|
|
319
331
|
newErrorSchema = {};
|
|
@@ -340,7 +352,7 @@ var ArrayField = class extends Component {
|
|
|
340
352
|
{
|
|
341
353
|
keyedFormData: newKeyedFormData
|
|
342
354
|
},
|
|
343
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
355
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
|
|
344
356
|
);
|
|
345
357
|
};
|
|
346
358
|
};
|
|
@@ -350,32 +362,49 @@ var ArrayField = class extends Component {
|
|
|
350
362
|
* @param index - The index of the item being changed
|
|
351
363
|
*/
|
|
352
364
|
onChangeForIndex = (index) => {
|
|
353
|
-
return (value, newErrorSchema, id) => {
|
|
354
|
-
const {
|
|
355
|
-
const arrayData = Array.isArray(formData) ? formData : [];
|
|
356
|
-
const newFormData = arrayData.map((item, i) => {
|
|
357
|
-
const jsonValue = typeof value === "undefined" ? null : value;
|
|
358
|
-
return index === i ? jsonValue : item;
|
|
359
|
-
});
|
|
365
|
+
return (value, path, newErrorSchema, id) => {
|
|
366
|
+
const { onChange } = this.props;
|
|
360
367
|
onChange(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
368
|
+
// We need to treat undefined items as nulls to have validation.
|
|
369
|
+
// See https://github.com/tdegrunt/jsonschema/issues/206
|
|
370
|
+
value === void 0 ? null : value,
|
|
371
|
+
path,
|
|
372
|
+
newErrorSchema,
|
|
366
373
|
id
|
|
367
374
|
);
|
|
368
375
|
};
|
|
369
376
|
};
|
|
370
377
|
/** Callback handler used to change the value for a checkbox */
|
|
371
378
|
onSelectChange = (value) => {
|
|
372
|
-
const { onChange,
|
|
373
|
-
onChange(value, void 0,
|
|
379
|
+
const { onChange, fieldPathId } = this.props;
|
|
380
|
+
onChange(value, fieldPathId.path, void 0, fieldPathId && fieldPathId.$id);
|
|
374
381
|
};
|
|
382
|
+
/** Helper method to compute item UI schema for both normal and fixed arrays
|
|
383
|
+
* Handles both static object and dynamic function cases
|
|
384
|
+
*
|
|
385
|
+
* @param uiSchema - The parent UI schema containing items definition
|
|
386
|
+
* @param item - The item data
|
|
387
|
+
* @param index - The index of the item
|
|
388
|
+
* @param formContext - The form context
|
|
389
|
+
* @returns The computed UI schema for the item
|
|
390
|
+
*/
|
|
391
|
+
computeItemUiSchema(uiSchema, item, index, formContext) {
|
|
392
|
+
if (typeof uiSchema.items === "function") {
|
|
393
|
+
try {
|
|
394
|
+
const result = uiSchema.items(item, index, formContext);
|
|
395
|
+
return result;
|
|
396
|
+
} catch (e) {
|
|
397
|
+
console.error(`Error executing dynamic uiSchema.items function for item at index ${index}:`, e);
|
|
398
|
+
return void 0;
|
|
399
|
+
}
|
|
400
|
+
} else {
|
|
401
|
+
return uiSchema.items;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
375
404
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
376
405
|
*/
|
|
377
406
|
render() {
|
|
378
|
-
const { schema, uiSchema,
|
|
407
|
+
const { schema, uiSchema, fieldPathId, registry } = this.props;
|
|
379
408
|
const { schemaUtils, translateString } = registry;
|
|
380
409
|
if (!(ITEMS_KEY in schema)) {
|
|
381
410
|
const uiOptions = getUiOptions(uiSchema);
|
|
@@ -388,7 +417,7 @@ var ArrayField = class extends Component {
|
|
|
388
417
|
UnsupportedFieldTemplate,
|
|
389
418
|
{
|
|
390
419
|
schema,
|
|
391
|
-
|
|
420
|
+
fieldPathId,
|
|
392
421
|
reason: translateString(TranslatableString.MissingItems),
|
|
393
422
|
registry
|
|
394
423
|
}
|
|
@@ -415,7 +444,7 @@ var ArrayField = class extends Component {
|
|
|
415
444
|
schema,
|
|
416
445
|
uiSchema = {},
|
|
417
446
|
errorSchema,
|
|
418
|
-
|
|
447
|
+
fieldPathId,
|
|
419
448
|
name,
|
|
420
449
|
title,
|
|
421
450
|
disabled = false,
|
|
@@ -425,13 +454,11 @@ var ArrayField = class extends Component {
|
|
|
425
454
|
registry,
|
|
426
455
|
onBlur,
|
|
427
456
|
onFocus,
|
|
428
|
-
idPrefix,
|
|
429
|
-
idSeparator = "_",
|
|
430
457
|
rawErrors
|
|
431
458
|
} = this.props;
|
|
432
459
|
const { keyedFormData } = this.state;
|
|
433
460
|
const fieldTitle = schema.title || title || name;
|
|
434
|
-
const { schemaUtils, formContext } = registry;
|
|
461
|
+
const { schemaUtils, formContext, globalFormOptions } = registry;
|
|
435
462
|
const uiOptions = getUiOptions(uiSchema);
|
|
436
463
|
const _schemaItems = isObject(schema.items) ? schema.items : {};
|
|
437
464
|
const itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
|
|
@@ -444,8 +471,8 @@ var ArrayField = class extends Component {
|
|
|
444
471
|
const itemCast = item;
|
|
445
472
|
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
446
473
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
447
|
-
const
|
|
448
|
-
const
|
|
474
|
+
const itemFieldPathId = toFieldPathId(index, globalFormOptions, fieldPathId);
|
|
475
|
+
const itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
|
|
449
476
|
return this.renderArrayFieldItem({
|
|
450
477
|
key,
|
|
451
478
|
index,
|
|
@@ -455,10 +482,10 @@ var ArrayField = class extends Component {
|
|
|
455
482
|
canMoveUp: index > 0,
|
|
456
483
|
canMoveDown: index < formData.length - 1,
|
|
457
484
|
itemSchema,
|
|
458
|
-
|
|
485
|
+
itemFieldPathId,
|
|
459
486
|
itemErrorSchema,
|
|
460
487
|
itemData: itemCast,
|
|
461
|
-
itemUiSchema
|
|
488
|
+
itemUiSchema,
|
|
462
489
|
autofocus: autofocus && index === 0,
|
|
463
490
|
onBlur,
|
|
464
491
|
onFocus,
|
|
@@ -468,14 +495,13 @@ var ArrayField = class extends Component {
|
|
|
468
495
|
}),
|
|
469
496
|
className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}`,
|
|
470
497
|
disabled,
|
|
471
|
-
|
|
498
|
+
fieldPathId,
|
|
472
499
|
uiSchema,
|
|
473
500
|
onAddClick: this.onAddClick,
|
|
474
501
|
readonly,
|
|
475
502
|
required,
|
|
476
503
|
schema,
|
|
477
504
|
title: fieldTitle,
|
|
478
|
-
formContext,
|
|
479
505
|
formData,
|
|
480
506
|
rawErrors,
|
|
481
507
|
registry
|
|
@@ -488,7 +514,7 @@ var ArrayField = class extends Component {
|
|
|
488
514
|
renderCustomWidget() {
|
|
489
515
|
const {
|
|
490
516
|
schema,
|
|
491
|
-
|
|
517
|
+
fieldPathId,
|
|
492
518
|
uiSchema,
|
|
493
519
|
disabled = false,
|
|
494
520
|
readonly = false,
|
|
@@ -511,7 +537,7 @@ var ArrayField = class extends Component {
|
|
|
511
537
|
return /* @__PURE__ */ jsx(
|
|
512
538
|
Widget,
|
|
513
539
|
{
|
|
514
|
-
id:
|
|
540
|
+
id: fieldPathId.$id,
|
|
515
541
|
name,
|
|
516
542
|
multiple: true,
|
|
517
543
|
onChange: this.onSelectChange,
|
|
@@ -540,7 +566,7 @@ var ArrayField = class extends Component {
|
|
|
540
566
|
renderMultiSelect() {
|
|
541
567
|
const {
|
|
542
568
|
schema,
|
|
543
|
-
|
|
569
|
+
fieldPathId,
|
|
544
570
|
uiSchema,
|
|
545
571
|
formData: items = [],
|
|
546
572
|
disabled = false,
|
|
@@ -564,7 +590,7 @@ var ArrayField = class extends Component {
|
|
|
564
590
|
return /* @__PURE__ */ jsx(
|
|
565
591
|
Widget,
|
|
566
592
|
{
|
|
567
|
-
id:
|
|
593
|
+
id: fieldPathId.$id,
|
|
568
594
|
name,
|
|
569
595
|
multiple: true,
|
|
570
596
|
onChange: this.onSelectChange,
|
|
@@ -593,7 +619,7 @@ var ArrayField = class extends Component {
|
|
|
593
619
|
const {
|
|
594
620
|
schema,
|
|
595
621
|
uiSchema,
|
|
596
|
-
|
|
622
|
+
fieldPathId,
|
|
597
623
|
name,
|
|
598
624
|
disabled = false,
|
|
599
625
|
readonly = false,
|
|
@@ -614,7 +640,7 @@ var ArrayField = class extends Component {
|
|
|
614
640
|
Widget,
|
|
615
641
|
{
|
|
616
642
|
options,
|
|
617
|
-
id:
|
|
643
|
+
id: fieldPathId.$id,
|
|
618
644
|
name,
|
|
619
645
|
multiple: true,
|
|
620
646
|
onChange: this.onSelectChange,
|
|
@@ -643,9 +669,7 @@ var ArrayField = class extends Component {
|
|
|
643
669
|
uiSchema = {},
|
|
644
670
|
formData = [],
|
|
645
671
|
errorSchema,
|
|
646
|
-
|
|
647
|
-
idSeparator = "_",
|
|
648
|
-
idSchema,
|
|
672
|
+
fieldPathId,
|
|
649
673
|
name,
|
|
650
674
|
title,
|
|
651
675
|
disabled = false,
|
|
@@ -661,7 +685,7 @@ var ArrayField = class extends Component {
|
|
|
661
685
|
let { formData: items = [] } = this.props;
|
|
662
686
|
const fieldTitle = schema.title || title || name;
|
|
663
687
|
const uiOptions = getUiOptions(uiSchema);
|
|
664
|
-
const { schemaUtils, formContext } = registry;
|
|
688
|
+
const { schemaUtils, formContext, globalFormOptions } = registry;
|
|
665
689
|
const _schemaItems = isObject(schema.items) ? schema.items : [];
|
|
666
690
|
const itemSchemas = _schemaItems.map(
|
|
667
691
|
(item, index) => schemaUtils.retrieveSchema(item, formData[index])
|
|
@@ -676,16 +700,24 @@ var ArrayField = class extends Component {
|
|
|
676
700
|
canAdd,
|
|
677
701
|
className: "rjsf-field rjsf-field-array rjsf-field-array-fixed-items",
|
|
678
702
|
disabled,
|
|
679
|
-
|
|
703
|
+
fieldPathId,
|
|
680
704
|
formData,
|
|
681
705
|
items: keyedFormData.map((keyedItem, index) => {
|
|
682
706
|
const { key, item } = keyedItem;
|
|
683
707
|
const itemCast = item;
|
|
684
708
|
const additional = index >= itemSchemas.length;
|
|
685
709
|
const itemSchema = (additional && isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, itemCast) : itemSchemas[index]) || {};
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
710
|
+
const itemFieldPathId = toFieldPathId(index, globalFormOptions, fieldPathId);
|
|
711
|
+
let itemUiSchema;
|
|
712
|
+
if (additional) {
|
|
713
|
+
itemUiSchema = uiSchema.additionalItems;
|
|
714
|
+
} else {
|
|
715
|
+
if (Array.isArray(uiSchema.items)) {
|
|
716
|
+
itemUiSchema = uiSchema.items[index];
|
|
717
|
+
} else {
|
|
718
|
+
itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
689
721
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
690
722
|
return this.renderArrayFieldItem({
|
|
691
723
|
key,
|
|
@@ -699,7 +731,7 @@ var ArrayField = class extends Component {
|
|
|
699
731
|
itemSchema,
|
|
700
732
|
itemData: itemCast,
|
|
701
733
|
itemUiSchema,
|
|
702
|
-
|
|
734
|
+
itemFieldPathId,
|
|
703
735
|
itemErrorSchema,
|
|
704
736
|
autofocus: autofocus && index === 0,
|
|
705
737
|
onBlur,
|
|
@@ -715,7 +747,6 @@ var ArrayField = class extends Component {
|
|
|
715
747
|
schema,
|
|
716
748
|
uiSchema,
|
|
717
749
|
title: fieldTitle,
|
|
718
|
-
formContext,
|
|
719
750
|
errorSchema,
|
|
720
751
|
rawErrors
|
|
721
752
|
};
|
|
@@ -739,7 +770,7 @@ var ArrayField = class extends Component {
|
|
|
739
770
|
itemSchema,
|
|
740
771
|
itemData,
|
|
741
772
|
itemUiSchema,
|
|
742
|
-
|
|
773
|
+
itemFieldPathId,
|
|
743
774
|
itemErrorSchema,
|
|
744
775
|
autofocus,
|
|
745
776
|
onBlur,
|
|
@@ -748,7 +779,7 @@ var ArrayField = class extends Component {
|
|
|
748
779
|
totalItems,
|
|
749
780
|
title
|
|
750
781
|
} = props;
|
|
751
|
-
const { disabled, hideError,
|
|
782
|
+
const { disabled, hideError, readonly, uiSchema, registry, formContext } = this.props;
|
|
752
783
|
const {
|
|
753
784
|
fields: { ArraySchemaField, SchemaField: SchemaField2 },
|
|
754
785
|
globalUiOptions
|
|
@@ -775,9 +806,7 @@ var ArrayField = class extends Component {
|
|
|
775
806
|
formData: itemData,
|
|
776
807
|
formContext,
|
|
777
808
|
errorSchema: itemErrorSchema,
|
|
778
|
-
|
|
779
|
-
idSeparator,
|
|
780
|
-
idSchema: itemIdSchema,
|
|
809
|
+
fieldPathId: itemFieldPathId,
|
|
781
810
|
required: this.isItemRequired(itemSchema),
|
|
782
811
|
onChange: this.onChangeForIndex(index),
|
|
783
812
|
onBlur,
|
|
@@ -791,7 +820,7 @@ var ArrayField = class extends Component {
|
|
|
791
820
|
}
|
|
792
821
|
),
|
|
793
822
|
buttonsProps: {
|
|
794
|
-
|
|
823
|
+
fieldPathId: itemFieldPathId,
|
|
795
824
|
disabled,
|
|
796
825
|
readonly,
|
|
797
826
|
canAdd,
|
|
@@ -825,6 +854,7 @@ var ArrayField = class extends Component {
|
|
|
825
854
|
var ArrayField_default = ArrayField;
|
|
826
855
|
|
|
827
856
|
// src/components/fields/BooleanField.tsx
|
|
857
|
+
import { useCallback } from "react";
|
|
828
858
|
import {
|
|
829
859
|
getWidget as getWidget2,
|
|
830
860
|
getUiOptions as getUiOptions2,
|
|
@@ -838,7 +868,7 @@ function BooleanField(props) {
|
|
|
838
868
|
schema,
|
|
839
869
|
name,
|
|
840
870
|
uiSchema,
|
|
841
|
-
|
|
871
|
+
fieldPathId,
|
|
842
872
|
formData,
|
|
843
873
|
registry,
|
|
844
874
|
required,
|
|
@@ -900,15 +930,21 @@ function BooleanField(props) {
|
|
|
900
930
|
enumOptions = optionsList2({ enum: enums }, uiSchema);
|
|
901
931
|
}
|
|
902
932
|
}
|
|
933
|
+
const onWidgetChange = useCallback(
|
|
934
|
+
(value, errorSchema, id) => {
|
|
935
|
+
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
936
|
+
},
|
|
937
|
+
[onChange, fieldPathId]
|
|
938
|
+
);
|
|
903
939
|
return /* @__PURE__ */ jsx2(
|
|
904
940
|
Widget,
|
|
905
941
|
{
|
|
906
942
|
options: { ...options, enumOptions },
|
|
907
943
|
schema,
|
|
908
944
|
uiSchema,
|
|
909
|
-
id:
|
|
945
|
+
id: fieldPathId.$id,
|
|
910
946
|
name,
|
|
911
|
-
onChange,
|
|
947
|
+
onChange: onWidgetChange,
|
|
912
948
|
onFocus,
|
|
913
949
|
onBlur,
|
|
914
950
|
label,
|
|
@@ -938,11 +974,13 @@ import {
|
|
|
938
974
|
hashObject,
|
|
939
975
|
ID_KEY,
|
|
940
976
|
lookupFromFormContext,
|
|
941
|
-
mergeObjects,
|
|
942
977
|
ONE_OF_KEY,
|
|
943
978
|
PROPERTIES_KEY,
|
|
944
979
|
READONLY_KEY,
|
|
945
|
-
|
|
980
|
+
toFieldPathId as toFieldPathId2,
|
|
981
|
+
UI_OPTIONS_KEY,
|
|
982
|
+
UI_GLOBAL_OPTIONS_KEY,
|
|
983
|
+
ITEMS_KEY as ITEMS_KEY2
|
|
946
984
|
} from "@rjsf/utils";
|
|
947
985
|
import cloneDeep2 from "lodash/cloneDeep";
|
|
948
986
|
import each from "lodash/each";
|
|
@@ -958,16 +996,19 @@ import isObject3 from "lodash/isObject";
|
|
|
958
996
|
import isPlainObject from "lodash/isPlainObject";
|
|
959
997
|
import isString from "lodash/isString";
|
|
960
998
|
import isUndefined from "lodash/isUndefined";
|
|
999
|
+
import last from "lodash/last";
|
|
961
1000
|
import set2 from "lodash/set";
|
|
962
1001
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
963
1002
|
import { createElement } from "react";
|
|
964
1003
|
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
965
1004
|
var LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
966
1005
|
var LAYOUT_GRID_OPTION = `ui:${LAYOUT_GRID_UI_OPTION}`;
|
|
967
|
-
var UI_GLOBAL_OPTIONS = "ui:global_options";
|
|
968
1006
|
function getNonNullishValue(value, fallback) {
|
|
969
1007
|
return value ?? fallback;
|
|
970
1008
|
}
|
|
1009
|
+
function isNumericIndex(str) {
|
|
1010
|
+
return /^\d+?$/.test(str);
|
|
1011
|
+
}
|
|
971
1012
|
var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
972
1013
|
static defaultProps = {
|
|
973
1014
|
layoutGridSchema: void 0
|
|
@@ -987,7 +1028,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
987
1028
|
* @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
|
|
988
1029
|
*/
|
|
989
1030
|
static computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
990
|
-
const globalUiOptions = get2(uiSchema, [
|
|
1031
|
+
const globalUiOptions = get2(uiSchema, [UI_GLOBAL_OPTIONS_KEY], {});
|
|
991
1032
|
const localUiSchema = get2(uiSchema, field);
|
|
992
1033
|
const localUiOptions = { ...get2(localUiSchema, [UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
|
|
993
1034
|
const fieldUiSchema = { ...localUiSchema };
|
|
@@ -995,7 +1036,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
995
1036
|
set2(fieldUiSchema, [UI_OPTIONS_KEY], localUiOptions);
|
|
996
1037
|
}
|
|
997
1038
|
if (!isEmpty(globalUiOptions)) {
|
|
998
|
-
set2(fieldUiSchema, [
|
|
1039
|
+
set2(fieldUiSchema, [UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
|
|
999
1040
|
}
|
|
1000
1041
|
let { readonly: uiReadonly } = getUiOptions3(fieldUiSchema);
|
|
1001
1042
|
if (forceReadonly === true || isUndefined(uiReadonly) && schemaReadonly === true) {
|
|
@@ -1067,60 +1108,74 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1067
1108
|
}
|
|
1068
1109
|
return { children, gridProps };
|
|
1069
1110
|
}
|
|
1070
|
-
/**
|
|
1071
|
-
*
|
|
1111
|
+
/** Computes the `rawSchema` and `fieldPathId` for a `schema` and a `potentialIndex`. If the `schema` is of type array,
|
|
1112
|
+
* has an `ITEMS_KEY` element and `potentialIndex` represents a numeric value, the element at `ITEMS_KEY` is checked
|
|
1113
|
+
* to see if it is an array. If it is AND the `potentialIndex`th element is available, it is used as the `rawSchema`,
|
|
1114
|
+
* otherwise the last value of the element is used. If it is not, then the element is used as the `rawSchema`. In
|
|
1115
|
+
* either case, an `fieldPathId` is computed for the array index. If the `schema` does not represent an array or the
|
|
1116
|
+
* `potentialIndex` is not a numeric value, then `rawSchema` is returned as undefined and given `fieldPathId` is returned
|
|
1117
|
+
* as is.
|
|
1072
1118
|
*
|
|
1073
|
-
* @param
|
|
1074
|
-
* @param
|
|
1075
|
-
* @param
|
|
1076
|
-
* @
|
|
1077
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1078
|
-
* @returns - The generated `idSchema` for the `schema`
|
|
1119
|
+
* @param schema - The schema to generate the fieldPathId for
|
|
1120
|
+
* @param fieldPathId - The FieldPathId for the schema
|
|
1121
|
+
* @param potentialIndex - A string containing a potential index
|
|
1122
|
+
* @returns - An object containing the `rawSchema` and `fieldPathId` of an array item, otherwise an undefined `rawSchema`
|
|
1079
1123
|
*/
|
|
1080
|
-
static
|
|
1081
|
-
|
|
1082
|
-
|
|
1124
|
+
static computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1125
|
+
let rawSchema;
|
|
1126
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, ITEMS_KEY2)) {
|
|
1127
|
+
const index = Number(potentialIndex);
|
|
1128
|
+
const items = schema[ITEMS_KEY2];
|
|
1129
|
+
if (Array.isArray(items)) {
|
|
1130
|
+
if (index > items.length) {
|
|
1131
|
+
rawSchema = last(items);
|
|
1132
|
+
} else {
|
|
1133
|
+
rawSchema = items[index];
|
|
1134
|
+
}
|
|
1135
|
+
} else {
|
|
1136
|
+
rawSchema = items;
|
|
1137
|
+
}
|
|
1138
|
+
fieldPathId = {
|
|
1139
|
+
[ID_KEY]: fieldPathId[ID_KEY],
|
|
1140
|
+
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
return { rawSchema, fieldPathId };
|
|
1083
1144
|
}
|
|
1084
1145
|
/** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
|
|
1085
1146
|
* the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
|
|
1086
1147
|
* element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
|
|
1087
1148
|
* `options`.
|
|
1088
1149
|
*
|
|
1089
|
-
* @param
|
|
1150
|
+
* @param registry - The registry
|
|
1090
1151
|
* @param dottedPath - The dotted-path to the field for which to get the schema
|
|
1091
1152
|
* @param initialSchema - The initial schema to start the search from
|
|
1092
1153
|
* @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
|
|
1093
|
-
* @param
|
|
1094
|
-
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1154
|
+
* @param initialFieldIdPath - The initial fieldPathId to start the search from
|
|
1095
1155
|
* @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
|
|
1096
1156
|
* info if a oneOf/anyOf
|
|
1097
1157
|
*/
|
|
1098
|
-
static getSchemaDetailsForField(
|
|
1158
|
+
static getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
1159
|
+
const { schemaUtils, globalFormOptions } = registry;
|
|
1099
1160
|
let rawSchema = initialSchema;
|
|
1100
|
-
let
|
|
1161
|
+
let fieldPathId = initialFieldIdPath;
|
|
1101
1162
|
const parts = dottedPath.split(".");
|
|
1102
1163
|
const leafPath = parts.pop();
|
|
1103
1164
|
let schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1104
1165
|
let innerData = formData;
|
|
1105
1166
|
let isReadonly = schema.readOnly;
|
|
1106
1167
|
parts.forEach((part) => {
|
|
1168
|
+
fieldPathId = toFieldPathId2(part, globalFormOptions, fieldPathId);
|
|
1107
1169
|
if (has(schema, PROPERTIES_KEY)) {
|
|
1108
1170
|
rawSchema = get2(schema, [PROPERTIES_KEY, part], {});
|
|
1109
|
-
idSchema = get2(idSchema, part, {});
|
|
1110
1171
|
} else if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
1111
1172
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
1112
1173
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
1113
|
-
const selectedIdSchema = _LayoutGridField.getIdSchema(
|
|
1114
|
-
schemaUtils,
|
|
1115
|
-
idSchema,
|
|
1116
|
-
formData,
|
|
1117
|
-
selectedSchema,
|
|
1118
|
-
idSeparator
|
|
1119
|
-
);
|
|
1120
1174
|
rawSchema = get2(selectedSchema, [PROPERTIES_KEY, part], {});
|
|
1121
|
-
idSchema = get2(selectedIdSchema, part, {});
|
|
1122
1175
|
} else {
|
|
1123
|
-
|
|
1176
|
+
const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, part);
|
|
1177
|
+
rawSchema = result.rawSchema ?? {};
|
|
1178
|
+
fieldPathId = result.fieldPathId;
|
|
1124
1179
|
}
|
|
1125
1180
|
innerData = get2(innerData, part, {});
|
|
1126
1181
|
schema = schemaUtils.retrieveSchema(rawSchema, innerData);
|
|
@@ -1135,13 +1190,17 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1135
1190
|
if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
1136
1191
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
1137
1192
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
1138
|
-
const rawIdSchema = _LayoutGridField.getIdSchema(schemaUtils, idSchema, formData, schema, idSeparator);
|
|
1139
|
-
idSchema = mergeObjects(rawIdSchema, idSchema);
|
|
1140
1193
|
}
|
|
1194
|
+
fieldPathId = toFieldPathId2(leafPath, globalFormOptions, fieldPathId);
|
|
1141
1195
|
isRequired = schema !== void 0 && Array.isArray(schema.required) && includes(schema.required, leafPath);
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1196
|
+
const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
|
|
1197
|
+
if (result.rawSchema) {
|
|
1198
|
+
schema = result.rawSchema;
|
|
1199
|
+
fieldPathId = result.fieldPathId;
|
|
1200
|
+
} else {
|
|
1201
|
+
schema = get2(schema, [PROPERTIES_KEY, leafPath]);
|
|
1202
|
+
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
1203
|
+
}
|
|
1145
1204
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
1146
1205
|
if (schema && (has(schema, ONE_OF_KEY) || has(schema, ANY_OF_KEY))) {
|
|
1147
1206
|
const xxx = has(schema, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
@@ -1149,7 +1208,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1149
1208
|
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
1150
1209
|
}
|
|
1151
1210
|
}
|
|
1152
|
-
return { schema, isRequired, isReadonly, optionsInfo,
|
|
1211
|
+
return { schema, isRequired, isReadonly, optionsInfo, fieldPathId };
|
|
1153
1212
|
}
|
|
1154
1213
|
/** Gets the custom render component from the `render`, by either determining that it is either already a function or
|
|
1155
1214
|
* it is a non-function value that can be used to look up the function in the registry. If no function can be found,
|
|
@@ -1185,7 +1244,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1185
1244
|
if (isString(gridSchema) || isUndefined(gridSchema)) {
|
|
1186
1245
|
name = gridSchema ?? "";
|
|
1187
1246
|
} else {
|
|
1188
|
-
const { name: innerName, render, ...innerProps } = gridSchema;
|
|
1247
|
+
const { name: innerName = "", render, ...innerProps } = gridSchema;
|
|
1189
1248
|
name = innerName;
|
|
1190
1249
|
uiProps = innerProps;
|
|
1191
1250
|
if (!isEmpty(uiProps)) {
|
|
@@ -1218,19 +1277,17 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1218
1277
|
* elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
|
|
1219
1278
|
*
|
|
1220
1279
|
* @param dottedPath - The dotted-path to the field for which to generate the onChange handler
|
|
1221
|
-
* @returns - The `onChange` handling function for the `dottedPath` field
|
|
1280
|
+
* @returns - The `onChange` handling function for the `dottedPath` field of the `schemaType` type
|
|
1222
1281
|
*/
|
|
1223
1282
|
onFieldChange = (dottedPath) => {
|
|
1224
|
-
return (value, errSchema, id) => {
|
|
1225
|
-
const { onChange, errorSchema
|
|
1226
|
-
const newFormData = cloneDeep2(formData || {});
|
|
1283
|
+
return (value, path, errSchema, id) => {
|
|
1284
|
+
const { onChange, errorSchema } = this.props;
|
|
1227
1285
|
let newErrorSchema = errorSchema;
|
|
1228
1286
|
if (errSchema && errorSchema) {
|
|
1229
1287
|
newErrorSchema = cloneDeep2(errorSchema);
|
|
1230
1288
|
set2(newErrorSchema, dottedPath, errSchema);
|
|
1231
1289
|
}
|
|
1232
|
-
|
|
1233
|
-
onChange(newFormData, newErrorSchema, id);
|
|
1290
|
+
onChange(value, path, newErrorSchema, id);
|
|
1234
1291
|
};
|
|
1235
1292
|
};
|
|
1236
1293
|
/** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
|
|
@@ -1318,20 +1375,20 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1318
1375
|
const GridTemplate2 = getTemplate2("GridTemplate", registry, uiOptions);
|
|
1319
1376
|
return /* @__PURE__ */ jsx3(GridTemplate2, { ...gridProps, "data-testid": _LayoutGridField.TEST_IDS.row, children: this.renderChildren(children) });
|
|
1320
1377
|
}
|
|
1321
|
-
/** Iterates through all the `
|
|
1378
|
+
/** Iterates through all the `childrenLayoutGrfieldPathId`, rendering a nested `LayoutGridField` for each item in the
|
|
1322
1379
|
* list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
|
|
1323
1380
|
* `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
|
|
1324
|
-
* `
|
|
1381
|
+
* `childrenLayoutGrfieldPathId` is passed as `layoutGridSchema`.
|
|
1325
1382
|
*
|
|
1326
|
-
* @param
|
|
1383
|
+
* @param childrenLayoutGrfieldPathId - The list of strings or objects that represents the configurations for the
|
|
1327
1384
|
* children fields
|
|
1328
1385
|
* @returns - The nested `LayoutGridField`s
|
|
1329
1386
|
*/
|
|
1330
|
-
renderChildren(
|
|
1387
|
+
renderChildren(childrenLayoutGrfieldPathId) {
|
|
1331
1388
|
const { registry, schema: rawSchema, formData } = this.props;
|
|
1332
1389
|
const { schemaUtils } = registry;
|
|
1333
1390
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1334
|
-
return
|
|
1391
|
+
return childrenLayoutGrfieldPathId.map((layoutGridSchema) => /* @__PURE__ */ createElement(
|
|
1335
1392
|
_LayoutGridField,
|
|
1336
1393
|
{
|
|
1337
1394
|
...this.props,
|
|
@@ -1347,7 +1404,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1347
1404
|
* specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
|
|
1348
1405
|
* and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
|
|
1349
1406
|
* schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
|
|
1350
|
-
* `uiSchema`, `errorSchema`, `
|
|
1407
|
+
* `uiSchema`, `errorSchema`, `fieldPathId` and `formData` drilled down to the dotted-path field, spreading any other
|
|
1351
1408
|
* props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
|
|
1352
1409
|
* then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
|
|
1353
1410
|
* schema was located, but a custom render component was found, then it will be rendered with many of the non-event
|
|
@@ -1361,18 +1418,17 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1361
1418
|
schema: initialSchema,
|
|
1362
1419
|
uiSchema,
|
|
1363
1420
|
errorSchema,
|
|
1364
|
-
|
|
1421
|
+
fieldPathId,
|
|
1365
1422
|
onBlur,
|
|
1366
1423
|
onFocus,
|
|
1367
1424
|
formData,
|
|
1368
1425
|
readonly,
|
|
1369
1426
|
registry,
|
|
1370
|
-
idSeparator,
|
|
1371
1427
|
layoutGridSchema,
|
|
1372
1428
|
// Used to pull this out of otherProps since we don't want to pass it through
|
|
1373
1429
|
...otherProps
|
|
1374
1430
|
} = this.props;
|
|
1375
|
-
const { fields: fields2
|
|
1431
|
+
const { fields: fields2 } = registry;
|
|
1376
1432
|
const { SchemaField: SchemaField2, LayoutMultiSchemaField: LayoutMultiSchemaField2 } = fields2;
|
|
1377
1433
|
const uiComponentProps = _LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema);
|
|
1378
1434
|
if (uiComponentProps.rendered) {
|
|
@@ -1384,15 +1440,8 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1384
1440
|
isRequired,
|
|
1385
1441
|
isReadonly,
|
|
1386
1442
|
optionsInfo,
|
|
1387
|
-
|
|
1388
|
-
} = _LayoutGridField.getSchemaDetailsForField(
|
|
1389
|
-
schemaUtils,
|
|
1390
|
-
name,
|
|
1391
|
-
initialSchema,
|
|
1392
|
-
formData,
|
|
1393
|
-
idSchema,
|
|
1394
|
-
idSeparator
|
|
1395
|
-
);
|
|
1443
|
+
fieldPathId: fieldIdSchema
|
|
1444
|
+
} = _LayoutGridField.getSchemaDetailsForField(registry, name, initialSchema, formData, fieldPathId);
|
|
1396
1445
|
if (schema) {
|
|
1397
1446
|
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1398
1447
|
const { fieldUiSchema, uiReadonly } = _LayoutGridField.computeFieldUiSchema(
|
|
@@ -1413,8 +1462,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1413
1462
|
schema,
|
|
1414
1463
|
uiSchema: fieldUiSchema,
|
|
1415
1464
|
errorSchema: get2(errorSchema, name),
|
|
1416
|
-
|
|
1417
|
-
idSeparator,
|
|
1465
|
+
fieldPathId: fieldIdSchema,
|
|
1418
1466
|
formData: get2(formData, name),
|
|
1419
1467
|
onChange: this.onFieldChange(name),
|
|
1420
1468
|
onBlur,
|
|
@@ -1437,8 +1485,7 @@ var LayoutGridField = class _LayoutGridField extends PureComponent {
|
|
|
1437
1485
|
errorSchema,
|
|
1438
1486
|
uiSchema,
|
|
1439
1487
|
schema: initialSchema,
|
|
1440
|
-
|
|
1441
|
-
idSeparator,
|
|
1488
|
+
fieldPathId,
|
|
1442
1489
|
onBlur,
|
|
1443
1490
|
onFocus,
|
|
1444
1491
|
registry,
|
|
@@ -1488,7 +1535,7 @@ import {
|
|
|
1488
1535
|
} from "@rjsf/utils";
|
|
1489
1536
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1490
1537
|
function LayoutHeaderField(props) {
|
|
1491
|
-
const {
|
|
1538
|
+
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
1492
1539
|
const options = getUiOptions4(uiSchema, registry.globalUiOptions);
|
|
1493
1540
|
const { title: uiTitle } = options;
|
|
1494
1541
|
const { title: schemaTitle } = schema;
|
|
@@ -1504,7 +1551,7 @@ function LayoutHeaderField(props) {
|
|
|
1504
1551
|
return /* @__PURE__ */ jsx4(
|
|
1505
1552
|
TitleFieldTemplate,
|
|
1506
1553
|
{
|
|
1507
|
-
id: titleId(
|
|
1554
|
+
id: titleId(fieldPathId),
|
|
1508
1555
|
title: fieldTitle,
|
|
1509
1556
|
required,
|
|
1510
1557
|
schema,
|
|
@@ -1567,7 +1614,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1567
1614
|
baseType,
|
|
1568
1615
|
disabled = false,
|
|
1569
1616
|
formData,
|
|
1570
|
-
|
|
1617
|
+
fieldPathId,
|
|
1571
1618
|
onBlur,
|
|
1572
1619
|
onChange,
|
|
1573
1620
|
options,
|
|
@@ -1584,7 +1631,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1584
1631
|
} = props;
|
|
1585
1632
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1586
1633
|
const [enumOptions, setEnumOptions] = useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1587
|
-
const id = get3(
|
|
1634
|
+
const id = get3(fieldPathId, ID_KEY2);
|
|
1588
1635
|
const discriminator = getDiscriminatorFieldFromSchema2(schema);
|
|
1589
1636
|
const FieldErrorTemplate2 = getTemplate4("FieldErrorTemplate", registry, options);
|
|
1590
1637
|
const FieldTemplate2 = getTemplate4("FieldTemplate", registry, options);
|
|
@@ -1625,10 +1672,10 @@ function LayoutMultiSchemaField(props) {
|
|
|
1625
1672
|
if (newFormData) {
|
|
1626
1673
|
set3(newFormData, selectorField, opt);
|
|
1627
1674
|
}
|
|
1628
|
-
onChange(newFormData, void 0, id);
|
|
1675
|
+
onChange(newFormData, fieldPathId.path, void 0, id);
|
|
1629
1676
|
};
|
|
1630
1677
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
1631
|
-
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ jsx5(FieldErrorTemplate2, {
|
|
1678
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ jsx5(FieldErrorTemplate2, { fieldPathId, schema, errors: rawErrors, registry }) : void 0;
|
|
1632
1679
|
const ignored = (value) => noop;
|
|
1633
1680
|
return /* @__PURE__ */ jsx5(
|
|
1634
1681
|
FieldTemplate2,
|
|
@@ -1638,7 +1685,6 @@ function LayoutMultiSchemaField(props) {
|
|
|
1638
1685
|
label: (title || schema.title) ?? "",
|
|
1639
1686
|
disabled: disabled || Array.isArray(enumOptions) && isEmpty2(enumOptions),
|
|
1640
1687
|
uiSchema,
|
|
1641
|
-
formContext,
|
|
1642
1688
|
required,
|
|
1643
1689
|
readonly: !!readonly,
|
|
1644
1690
|
registry,
|
|
@@ -1688,13 +1734,14 @@ import {
|
|
|
1688
1734
|
deepEquals,
|
|
1689
1735
|
ERRORS_KEY as ERRORS_KEY2,
|
|
1690
1736
|
getDiscriminatorFieldFromSchema as getDiscriminatorFieldFromSchema3,
|
|
1737
|
+
getTemplate as getTemplate5,
|
|
1691
1738
|
getUiOptions as getUiOptions6,
|
|
1692
1739
|
getWidget as getWidget4,
|
|
1693
1740
|
mergeSchemas,
|
|
1694
1741
|
ONE_OF_KEY as ONE_OF_KEY3,
|
|
1695
1742
|
TranslatableString as TranslatableString3
|
|
1696
1743
|
} from "@rjsf/utils";
|
|
1697
|
-
import { jsx as jsx6
|
|
1744
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1698
1745
|
var AnyOfField = class extends Component2 {
|
|
1699
1746
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1700
1747
|
*
|
|
@@ -1720,7 +1767,7 @@ var AnyOfField = class extends Component2 {
|
|
|
1720
1767
|
* @param prevState - The previous `AnyOfFieldState` for this template
|
|
1721
1768
|
*/
|
|
1722
1769
|
componentDidUpdate(prevProps, prevState) {
|
|
1723
|
-
const { formData, options,
|
|
1770
|
+
const { formData, options, fieldPathId } = this.props;
|
|
1724
1771
|
const { selectedOption } = this.state;
|
|
1725
1772
|
let newState = this.state;
|
|
1726
1773
|
if (!deepEquals(prevProps.options, options)) {
|
|
@@ -1730,7 +1777,7 @@ var AnyOfField = class extends Component2 {
|
|
|
1730
1777
|
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1731
1778
|
newState = { selectedOption, retrievedOptions };
|
|
1732
1779
|
}
|
|
1733
|
-
if (!deepEquals(formData, prevProps.formData) &&
|
|
1780
|
+
if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
1734
1781
|
const { retrievedOptions } = newState;
|
|
1735
1782
|
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
1736
1783
|
if (prevState && matchingOption !== selectedOption) {
|
|
@@ -1764,7 +1811,7 @@ var AnyOfField = class extends Component2 {
|
|
|
1764
1811
|
*/
|
|
1765
1812
|
onOptionChange = (option) => {
|
|
1766
1813
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1767
|
-
const { formData, onChange, registry } = this.props;
|
|
1814
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
1768
1815
|
const { schemaUtils } = registry;
|
|
1769
1816
|
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1770
1817
|
if (intOption === selectedOption) {
|
|
@@ -1777,12 +1824,12 @@ var AnyOfField = class extends Component2 {
|
|
|
1777
1824
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1778
1825
|
}
|
|
1779
1826
|
this.setState({ selectedOption: intOption }, () => {
|
|
1780
|
-
onChange(newFormData, void 0, this.getFieldId());
|
|
1827
|
+
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1781
1828
|
});
|
|
1782
1829
|
};
|
|
1783
1830
|
getFieldId() {
|
|
1784
|
-
const {
|
|
1785
|
-
return `${
|
|
1831
|
+
const { fieldPathId, schema } = this.props;
|
|
1832
|
+
return `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1786
1833
|
}
|
|
1787
1834
|
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1788
1835
|
*/
|
|
@@ -1801,6 +1848,11 @@ var AnyOfField = class extends Component2 {
|
|
|
1801
1848
|
} = this.props;
|
|
1802
1849
|
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1803
1850
|
const { SchemaField: _SchemaField } = fields2;
|
|
1851
|
+
const MultiSchemaFieldTemplate2 = getTemplate5(
|
|
1852
|
+
"MultiSchemaFieldTemplate",
|
|
1853
|
+
registry,
|
|
1854
|
+
globalUiOptions
|
|
1855
|
+
);
|
|
1804
1856
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1805
1857
|
const {
|
|
1806
1858
|
widget = "select",
|
|
@@ -1847,41 +1899,51 @@ var AnyOfField = class extends Component2 {
|
|
|
1847
1899
|
value: index
|
|
1848
1900
|
};
|
|
1849
1901
|
});
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1902
|
+
const selector = /* @__PURE__ */ jsx6(
|
|
1903
|
+
Widget,
|
|
1904
|
+
{
|
|
1905
|
+
id: this.getFieldId(),
|
|
1906
|
+
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1907
|
+
schema: { type: "number", default: 0 },
|
|
1908
|
+
onChange: this.onOptionChange,
|
|
1909
|
+
onBlur,
|
|
1910
|
+
onFocus,
|
|
1911
|
+
disabled: disabled || isEmpty3(enumOptions),
|
|
1912
|
+
multiple: false,
|
|
1913
|
+
rawErrors,
|
|
1914
|
+
errorSchema: fieldErrorSchema,
|
|
1915
|
+
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1916
|
+
options: { enumOptions, ...uiOptions },
|
|
1917
|
+
registry,
|
|
1918
|
+
formContext,
|
|
1919
|
+
placeholder,
|
|
1920
|
+
autocomplete,
|
|
1921
|
+
autofocus,
|
|
1922
|
+
label: title ?? name,
|
|
1923
|
+
hideLabel: !displayLabel,
|
|
1924
|
+
readonly
|
|
1925
|
+
}
|
|
1926
|
+
);
|
|
1927
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsx6(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1928
|
+
return /* @__PURE__ */ jsx6(
|
|
1929
|
+
MultiSchemaFieldTemplate2,
|
|
1930
|
+
{
|
|
1931
|
+
schema,
|
|
1932
|
+
registry,
|
|
1933
|
+
uiSchema,
|
|
1934
|
+
selector,
|
|
1935
|
+
optionSchemaField: optionsSchemaField
|
|
1936
|
+
}
|
|
1937
|
+
);
|
|
1878
1938
|
}
|
|
1879
1939
|
};
|
|
1880
1940
|
var MultiSchemaField_default = AnyOfField;
|
|
1881
1941
|
|
|
1882
1942
|
// src/components/fields/NumberField.tsx
|
|
1883
|
-
import { useState as useState2, useCallback } from "react";
|
|
1884
|
-
import {
|
|
1943
|
+
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
1944
|
+
import {
|
|
1945
|
+
asNumber
|
|
1946
|
+
} from "@rjsf/utils";
|
|
1885
1947
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1886
1948
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1887
1949
|
var trailingCharMatcher = /[0.]0*$/;
|
|
@@ -1890,14 +1952,14 @@ function NumberField(props) {
|
|
|
1890
1952
|
const [lastValue, setLastValue] = useState2(initialValue);
|
|
1891
1953
|
const { StringField: StringField2 } = registry.fields;
|
|
1892
1954
|
let value = formData;
|
|
1893
|
-
const handleChange =
|
|
1894
|
-
(value2, errorSchema, id) => {
|
|
1955
|
+
const handleChange = useCallback2(
|
|
1956
|
+
(value2, path, errorSchema, id) => {
|
|
1895
1957
|
setLastValue(value2);
|
|
1896
1958
|
if (`${value2}`.charAt(0) === ".") {
|
|
1897
1959
|
value2 = `0${value2}`;
|
|
1898
1960
|
}
|
|
1899
1961
|
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? asNumber(value2.replace(trailingCharMatcher, "")) : asNumber(value2);
|
|
1900
|
-
onChange(processed, errorSchema, id);
|
|
1962
|
+
onChange(processed, path, errorSchema, id);
|
|
1901
1963
|
},
|
|
1902
1964
|
[onChange]
|
|
1903
1965
|
);
|
|
@@ -1914,9 +1976,10 @@ var NumberField_default = NumberField;
|
|
|
1914
1976
|
// src/components/fields/ObjectField.tsx
|
|
1915
1977
|
import { Component as Component3 } from "react";
|
|
1916
1978
|
import {
|
|
1917
|
-
getTemplate as
|
|
1979
|
+
getTemplate as getTemplate6,
|
|
1918
1980
|
getUiOptions as getUiOptions7,
|
|
1919
1981
|
orderProperties,
|
|
1982
|
+
toFieldPathId as toFieldPathId3,
|
|
1920
1983
|
TranslatableString as TranslatableString4,
|
|
1921
1984
|
ADDITIONAL_PROPERTY_FLAG,
|
|
1922
1985
|
PROPERTIES_KEY as PROPERTIES_KEY3,
|
|
@@ -1930,7 +1993,7 @@ import has3 from "lodash/has";
|
|
|
1930
1993
|
import isObject4 from "lodash/isObject";
|
|
1931
1994
|
import set4 from "lodash/set";
|
|
1932
1995
|
import unset from "lodash/unset";
|
|
1933
|
-
import { jsx as jsx8, jsxs
|
|
1996
|
+
import { jsx as jsx8, jsxs } from "react/jsx-runtime";
|
|
1934
1997
|
var ObjectField = class extends Component3 {
|
|
1935
1998
|
/** Set up the initial state */
|
|
1936
1999
|
state = {
|
|
@@ -1955,20 +2018,12 @@ var ObjectField = class extends Component3 {
|
|
|
1955
2018
|
* @returns - The onPropertyChange callback for the `name` property
|
|
1956
2019
|
*/
|
|
1957
2020
|
onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
1958
|
-
return (value, newErrorSchema, id) => {
|
|
1959
|
-
const {
|
|
2021
|
+
return (value, path, newErrorSchema, id) => {
|
|
2022
|
+
const { onChange } = this.props;
|
|
1960
2023
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
1961
2024
|
value = "";
|
|
1962
2025
|
}
|
|
1963
|
-
|
|
1964
|
-
onChange(
|
|
1965
|
-
newFormData,
|
|
1966
|
-
errorSchema && errorSchema && {
|
|
1967
|
-
...errorSchema,
|
|
1968
|
-
[name]: newErrorSchema
|
|
1969
|
-
},
|
|
1970
|
-
id
|
|
1971
|
-
);
|
|
2026
|
+
onChange(value, path, newErrorSchema, id);
|
|
1972
2027
|
};
|
|
1973
2028
|
};
|
|
1974
2029
|
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
@@ -1980,10 +2035,10 @@ var ObjectField = class extends Component3 {
|
|
|
1980
2035
|
onDropPropertyClick = (key) => {
|
|
1981
2036
|
return (event) => {
|
|
1982
2037
|
event.preventDefault();
|
|
1983
|
-
const { onChange, formData } = this.props;
|
|
2038
|
+
const { onChange, formData, fieldPathId } = this.props;
|
|
1984
2039
|
const copiedFormData = { ...formData };
|
|
1985
2040
|
unset(copiedFormData, key);
|
|
1986
|
-
onChange(copiedFormData);
|
|
2041
|
+
onChange(copiedFormData, fieldPathId.path);
|
|
1987
2042
|
};
|
|
1988
2043
|
};
|
|
1989
2044
|
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
@@ -2010,11 +2065,11 @@ var ObjectField = class extends Component3 {
|
|
|
2010
2065
|
* @returns - The key change callback function
|
|
2011
2066
|
*/
|
|
2012
2067
|
onKeyChange = (oldValue) => {
|
|
2013
|
-
return (value
|
|
2068
|
+
return (value) => {
|
|
2014
2069
|
if (oldValue === value) {
|
|
2015
2070
|
return;
|
|
2016
2071
|
}
|
|
2017
|
-
const { formData, onChange,
|
|
2072
|
+
const { formData, onChange, fieldPathId } = this.props;
|
|
2018
2073
|
value = this.getAvailableKey(value, formData);
|
|
2019
2074
|
const newFormData = {
|
|
2020
2075
|
...formData
|
|
@@ -2026,13 +2081,7 @@ var ObjectField = class extends Component3 {
|
|
|
2026
2081
|
});
|
|
2027
2082
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
2028
2083
|
this.setState({ wasPropertyKeyModified: true });
|
|
2029
|
-
onChange(
|
|
2030
|
-
renamedObj,
|
|
2031
|
-
errorSchema && errorSchema && {
|
|
2032
|
-
...errorSchema,
|
|
2033
|
-
[value]: newErrorSchema
|
|
2034
|
-
}
|
|
2035
|
-
);
|
|
2084
|
+
onChange(renamedObj, fieldPathId.path);
|
|
2036
2085
|
};
|
|
2037
2086
|
};
|
|
2038
2087
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
@@ -2068,7 +2117,7 @@ var ObjectField = class extends Component3 {
|
|
|
2068
2117
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2069
2118
|
return;
|
|
2070
2119
|
}
|
|
2071
|
-
const { formData, onChange, registry } = this.props;
|
|
2120
|
+
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
2072
2121
|
const newFormData = { ...formData };
|
|
2073
2122
|
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
2074
2123
|
if (schema.patternProperties) {
|
|
@@ -2096,7 +2145,7 @@ var ObjectField = class extends Component3 {
|
|
|
2096
2145
|
const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
|
|
2097
2146
|
set4(newFormData, newKey, newValue);
|
|
2098
2147
|
}
|
|
2099
|
-
onChange(newFormData);
|
|
2148
|
+
onChange(newFormData, fieldPathId.path);
|
|
2100
2149
|
};
|
|
2101
2150
|
/** Renders the `ObjectField` from the given props
|
|
2102
2151
|
*/
|
|
@@ -2106,20 +2155,18 @@ var ObjectField = class extends Component3 {
|
|
|
2106
2155
|
uiSchema = {},
|
|
2107
2156
|
formData,
|
|
2108
2157
|
errorSchema,
|
|
2109
|
-
|
|
2158
|
+
fieldPathId,
|
|
2110
2159
|
name,
|
|
2111
2160
|
required = false,
|
|
2112
2161
|
disabled,
|
|
2113
2162
|
readonly,
|
|
2114
2163
|
hideError,
|
|
2115
|
-
idPrefix,
|
|
2116
|
-
idSeparator,
|
|
2117
2164
|
onBlur,
|
|
2118
2165
|
onFocus,
|
|
2119
2166
|
registry,
|
|
2120
2167
|
title
|
|
2121
2168
|
} = this.props;
|
|
2122
|
-
const { fields: fields2, formContext, schemaUtils, translateString, globalUiOptions } = registry;
|
|
2169
|
+
const { fields: fields2, formContext, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
|
|
2123
2170
|
const { SchemaField: SchemaField2 } = fields2;
|
|
2124
2171
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
2125
2172
|
const uiOptions = getUiOptions7(uiSchema, globalUiOptions);
|
|
@@ -2131,12 +2178,12 @@ var ObjectField = class extends Component3 {
|
|
|
2131
2178
|
const properties = Object.keys(schemaProperties);
|
|
2132
2179
|
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
2133
2180
|
} catch (err) {
|
|
2134
|
-
return /* @__PURE__ */
|
|
2181
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2135
2182
|
/* @__PURE__ */ jsx8("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx8(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString4.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
2136
2183
|
/* @__PURE__ */ jsx8("pre", { children: JSON.stringify(schema) })
|
|
2137
2184
|
] });
|
|
2138
2185
|
}
|
|
2139
|
-
const Template =
|
|
2186
|
+
const Template = getTemplate6("ObjectFieldTemplate", registry, uiOptions);
|
|
2140
2187
|
const templateProps = {
|
|
2141
2188
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
2142
2189
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
@@ -2145,7 +2192,7 @@ var ObjectField = class extends Component3 {
|
|
|
2145
2192
|
const addedByAdditionalProperties = has3(schema, [PROPERTIES_KEY3, name2, ADDITIONAL_PROPERTY_FLAG]);
|
|
2146
2193
|
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
|
|
2147
2194
|
const hidden = getUiOptions7(fieldUiSchema).widget === "hidden";
|
|
2148
|
-
const
|
|
2195
|
+
const innerFieldIdPathId = toFieldPathId3(name2, globalFormOptions, fieldPathId);
|
|
2149
2196
|
return {
|
|
2150
2197
|
content: /* @__PURE__ */ jsx8(
|
|
2151
2198
|
SchemaField2,
|
|
@@ -2155,9 +2202,7 @@ var ObjectField = class extends Component3 {
|
|
|
2155
2202
|
schema: get5(schema, [PROPERTIES_KEY3, name2], {}),
|
|
2156
2203
|
uiSchema: fieldUiSchema,
|
|
2157
2204
|
errorSchema: get5(errorSchema, name2),
|
|
2158
|
-
|
|
2159
|
-
idPrefix,
|
|
2160
|
-
idSeparator,
|
|
2205
|
+
fieldPathId: innerFieldIdPathId,
|
|
2161
2206
|
formData: get5(formData, name2),
|
|
2162
2207
|
formContext,
|
|
2163
2208
|
wasPropertyKeyModified: this.state.wasPropertyKeyModified,
|
|
@@ -2183,7 +2228,7 @@ var ObjectField = class extends Component3 {
|
|
|
2183
2228
|
readonly,
|
|
2184
2229
|
disabled,
|
|
2185
2230
|
required,
|
|
2186
|
-
|
|
2231
|
+
fieldPathId,
|
|
2187
2232
|
uiSchema,
|
|
2188
2233
|
errorSchema,
|
|
2189
2234
|
schema,
|
|
@@ -2197,22 +2242,21 @@ var ObjectField = class extends Component3 {
|
|
|
2197
2242
|
var ObjectField_default = ObjectField;
|
|
2198
2243
|
|
|
2199
2244
|
// src/components/fields/SchemaField.tsx
|
|
2200
|
-
import { useCallback as
|
|
2245
|
+
import { useCallback as useCallback3, Component as Component4 } from "react";
|
|
2201
2246
|
import {
|
|
2202
2247
|
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG2,
|
|
2203
|
-
deepEquals as deepEquals2,
|
|
2204
2248
|
descriptionId,
|
|
2205
2249
|
getSchemaType,
|
|
2206
|
-
getTemplate as
|
|
2250
|
+
getTemplate as getTemplate7,
|
|
2207
2251
|
getUiOptions as getUiOptions8,
|
|
2208
2252
|
ID_KEY as ID_KEY3,
|
|
2209
|
-
|
|
2253
|
+
shouldRender,
|
|
2210
2254
|
TranslatableString as TranslatableString5,
|
|
2211
2255
|
UI_OPTIONS_KEY as UI_OPTIONS_KEY2
|
|
2212
2256
|
} from "@rjsf/utils";
|
|
2213
2257
|
import isObject5 from "lodash/isObject";
|
|
2214
2258
|
import omit3 from "lodash/omit";
|
|
2215
|
-
import { Fragment, jsx as jsx9, jsxs as
|
|
2259
|
+
import { Fragment, jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2216
2260
|
var COMPONENT_TYPES = {
|
|
2217
2261
|
array: "ArrayField",
|
|
2218
2262
|
boolean: "BooleanField",
|
|
@@ -2222,7 +2266,7 @@ var COMPONENT_TYPES = {
|
|
|
2222
2266
|
string: "StringField",
|
|
2223
2267
|
null: "NullField"
|
|
2224
2268
|
};
|
|
2225
|
-
function getFieldComponent(schema, uiOptions,
|
|
2269
|
+
function getFieldComponent(schema, uiOptions, fieldPathId, registry) {
|
|
2226
2270
|
const field = uiOptions.field;
|
|
2227
2271
|
const { fields: fields2, translateString } = registry;
|
|
2228
2272
|
if (typeof field === "function") {
|
|
@@ -2242,7 +2286,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2242
2286
|
return () => null;
|
|
2243
2287
|
}
|
|
2244
2288
|
return componentName in fields2 ? fields2[componentName] : () => {
|
|
2245
|
-
const UnsupportedFieldTemplate =
|
|
2289
|
+
const UnsupportedFieldTemplate = getTemplate7(
|
|
2246
2290
|
"UnsupportedFieldTemplate",
|
|
2247
2291
|
registry,
|
|
2248
2292
|
uiOptions
|
|
@@ -2251,7 +2295,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2251
2295
|
UnsupportedFieldTemplate,
|
|
2252
2296
|
{
|
|
2253
2297
|
schema,
|
|
2254
|
-
|
|
2298
|
+
fieldPathId,
|
|
2255
2299
|
reason: translateString(TranslatableString5.UnknownFieldType, [String(schema.type)]),
|
|
2256
2300
|
registry
|
|
2257
2301
|
}
|
|
@@ -2261,12 +2305,10 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
2261
2305
|
function SchemaFieldRender(props) {
|
|
2262
2306
|
const {
|
|
2263
2307
|
schema: _schema,
|
|
2264
|
-
|
|
2308
|
+
fieldPathId,
|
|
2265
2309
|
uiSchema,
|
|
2266
2310
|
formData,
|
|
2267
2311
|
errorSchema,
|
|
2268
|
-
idPrefix,
|
|
2269
|
-
idSeparator,
|
|
2270
2312
|
name,
|
|
2271
2313
|
onChange,
|
|
2272
2314
|
onKeyChange,
|
|
@@ -2277,28 +2319,24 @@ function SchemaFieldRender(props) {
|
|
|
2277
2319
|
} = props;
|
|
2278
2320
|
const { formContext, schemaUtils, globalUiOptions } = registry;
|
|
2279
2321
|
const uiOptions = getUiOptions8(uiSchema, globalUiOptions);
|
|
2280
|
-
const FieldTemplate2 =
|
|
2281
|
-
const DescriptionFieldTemplate =
|
|
2322
|
+
const FieldTemplate2 = getTemplate7("FieldTemplate", registry, uiOptions);
|
|
2323
|
+
const DescriptionFieldTemplate = getTemplate7(
|
|
2282
2324
|
"DescriptionFieldTemplate",
|
|
2283
2325
|
registry,
|
|
2284
2326
|
uiOptions
|
|
2285
2327
|
);
|
|
2286
|
-
const FieldHelpTemplate2 =
|
|
2287
|
-
const FieldErrorTemplate2 =
|
|
2328
|
+
const FieldHelpTemplate2 = getTemplate7("FieldHelpTemplate", registry, uiOptions);
|
|
2329
|
+
const FieldErrorTemplate2 = getTemplate7("FieldErrorTemplate", registry, uiOptions);
|
|
2288
2330
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2289
|
-
const fieldId =
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
_idSchema
|
|
2293
|
-
);
|
|
2294
|
-
const handleFieldComponentChange = useCallback2(
|
|
2295
|
-
(formData2, newErrorSchema, id2) => {
|
|
2331
|
+
const fieldId = fieldPathId[ID_KEY3];
|
|
2332
|
+
const handleFieldComponentChange = useCallback3(
|
|
2333
|
+
(formData2, path, newErrorSchema, id2) => {
|
|
2296
2334
|
const theId = id2 || fieldId;
|
|
2297
|
-
return onChange(formData2, newErrorSchema, theId);
|
|
2335
|
+
return onChange(formData2, path, newErrorSchema, theId);
|
|
2298
2336
|
},
|
|
2299
2337
|
[fieldId, onChange]
|
|
2300
2338
|
);
|
|
2301
|
-
const FieldComponent = getFieldComponent(schema, uiOptions,
|
|
2339
|
+
const FieldComponent = getFieldComponent(schema, uiOptions, fieldPathId, registry);
|
|
2302
2340
|
const disabled = Boolean(uiOptions.disabled ?? props.disabled);
|
|
2303
2341
|
const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly));
|
|
2304
2342
|
const uiSchemaHideError = uiOptions.hideError;
|
|
@@ -2318,7 +2356,7 @@ function SchemaFieldRender(props) {
|
|
|
2318
2356
|
{
|
|
2319
2357
|
...props,
|
|
2320
2358
|
onChange: handleFieldComponentChange,
|
|
2321
|
-
|
|
2359
|
+
fieldPathId,
|
|
2322
2360
|
schema,
|
|
2323
2361
|
uiSchema: fieldUiSchema,
|
|
2324
2362
|
disabled,
|
|
@@ -2330,7 +2368,7 @@ function SchemaFieldRender(props) {
|
|
|
2330
2368
|
rawErrors: __errors
|
|
2331
2369
|
}
|
|
2332
2370
|
);
|
|
2333
|
-
const id =
|
|
2371
|
+
const id = fieldPathId[ID_KEY3];
|
|
2334
2372
|
let label;
|
|
2335
2373
|
if (wasPropertyKeyModified) {
|
|
2336
2374
|
label = name;
|
|
@@ -2351,7 +2389,7 @@ function SchemaFieldRender(props) {
|
|
|
2351
2389
|
FieldHelpTemplate2,
|
|
2352
2390
|
{
|
|
2353
2391
|
help,
|
|
2354
|
-
|
|
2392
|
+
fieldPathId,
|
|
2355
2393
|
schema,
|
|
2356
2394
|
uiSchema,
|
|
2357
2395
|
hasErrors: !hideError && __errors && __errors.length > 0,
|
|
@@ -2363,7 +2401,7 @@ function SchemaFieldRender(props) {
|
|
|
2363
2401
|
{
|
|
2364
2402
|
errors: __errors,
|
|
2365
2403
|
errorSchema,
|
|
2366
|
-
|
|
2404
|
+
fieldPathId,
|
|
2367
2405
|
schema,
|
|
2368
2406
|
uiSchema,
|
|
2369
2407
|
registry
|
|
@@ -2398,7 +2436,6 @@ function SchemaFieldRender(props) {
|
|
|
2398
2436
|
displayLabel,
|
|
2399
2437
|
classNames: classNames.join(" ").trim(),
|
|
2400
2438
|
style: uiOptions.style,
|
|
2401
|
-
formContext,
|
|
2402
2439
|
formData,
|
|
2403
2440
|
schema,
|
|
2404
2441
|
uiSchema,
|
|
@@ -2407,7 +2444,7 @@ function SchemaFieldRender(props) {
|
|
|
2407
2444
|
const _AnyOfField = registry.fields.AnyOfField;
|
|
2408
2445
|
const _OneOfField = registry.fields.OneOfField;
|
|
2409
2446
|
const isReplacingAnyOrOneOf = uiSchema?.["ui:field"] && uiSchema?.["ui:fieldReplacesAnyOrOneOf"] === true;
|
|
2410
|
-
return /* @__PURE__ */ jsx9(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */
|
|
2447
|
+
return /* @__PURE__ */ jsx9(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
2411
2448
|
field,
|
|
2412
2449
|
schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx9(
|
|
2413
2450
|
_AnyOfField,
|
|
@@ -2419,9 +2456,7 @@ function SchemaFieldRender(props) {
|
|
|
2419
2456
|
errorSchema,
|
|
2420
2457
|
formData,
|
|
2421
2458
|
formContext,
|
|
2422
|
-
|
|
2423
|
-
idSchema,
|
|
2424
|
-
idSeparator,
|
|
2459
|
+
fieldPathId,
|
|
2425
2460
|
onBlur: props.onBlur,
|
|
2426
2461
|
onChange: props.onChange,
|
|
2427
2462
|
onFocus: props.onFocus,
|
|
@@ -2444,9 +2479,7 @@ function SchemaFieldRender(props) {
|
|
|
2444
2479
|
errorSchema,
|
|
2445
2480
|
formData,
|
|
2446
2481
|
formContext,
|
|
2447
|
-
|
|
2448
|
-
idSchema,
|
|
2449
|
-
idSeparator,
|
|
2482
|
+
fieldPathId,
|
|
2450
2483
|
onBlur: props.onBlur,
|
|
2451
2484
|
onChange: props.onChange,
|
|
2452
2485
|
onFocus: props.onFocus,
|
|
@@ -2463,7 +2496,11 @@ function SchemaFieldRender(props) {
|
|
|
2463
2496
|
}
|
|
2464
2497
|
var SchemaField = class extends Component4 {
|
|
2465
2498
|
shouldComponentUpdate(nextProps) {
|
|
2466
|
-
|
|
2499
|
+
const {
|
|
2500
|
+
registry: { globalFormOptions }
|
|
2501
|
+
} = this.props;
|
|
2502
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = globalFormOptions;
|
|
2503
|
+
return shouldRender(this, nextProps, this.state, experimental_componentUpdateStrategy);
|
|
2467
2504
|
}
|
|
2468
2505
|
render() {
|
|
2469
2506
|
return /* @__PURE__ */ jsx9(SchemaFieldRender, { ...this.props });
|
|
@@ -2472,6 +2509,7 @@ var SchemaField = class extends Component4 {
|
|
|
2472
2509
|
var SchemaField_default = SchemaField;
|
|
2473
2510
|
|
|
2474
2511
|
// src/components/fields/StringField.tsx
|
|
2512
|
+
import { useCallback as useCallback4 } from "react";
|
|
2475
2513
|
import {
|
|
2476
2514
|
getWidget as getWidget5,
|
|
2477
2515
|
getUiOptions as getUiOptions9,
|
|
@@ -2484,7 +2522,7 @@ function StringField(props) {
|
|
|
2484
2522
|
schema,
|
|
2485
2523
|
name,
|
|
2486
2524
|
uiSchema,
|
|
2487
|
-
|
|
2525
|
+
fieldPathId,
|
|
2488
2526
|
formData,
|
|
2489
2527
|
required,
|
|
2490
2528
|
disabled = false,
|
|
@@ -2508,19 +2546,25 @@ function StringField(props) {
|
|
|
2508
2546
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2509
2547
|
const label = uiTitle ?? title ?? name;
|
|
2510
2548
|
const Widget = getWidget5(schema, widget, widgets2);
|
|
2549
|
+
const onWidgetChange = useCallback4(
|
|
2550
|
+
(value, errorSchema, id) => {
|
|
2551
|
+
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2552
|
+
},
|
|
2553
|
+
[onChange, fieldPathId]
|
|
2554
|
+
);
|
|
2511
2555
|
return /* @__PURE__ */ jsx10(
|
|
2512
2556
|
Widget,
|
|
2513
2557
|
{
|
|
2514
2558
|
options: { ...options, enumOptions },
|
|
2515
2559
|
schema,
|
|
2516
2560
|
uiSchema,
|
|
2517
|
-
id:
|
|
2561
|
+
id: fieldPathId.$id,
|
|
2518
2562
|
name,
|
|
2519
2563
|
label,
|
|
2520
2564
|
hideLabel: !displayLabel,
|
|
2521
2565
|
hideError,
|
|
2522
2566
|
value: formData,
|
|
2523
|
-
onChange,
|
|
2567
|
+
onChange: onWidgetChange,
|
|
2524
2568
|
onBlur,
|
|
2525
2569
|
onFocus,
|
|
2526
2570
|
required,
|
|
@@ -2539,12 +2583,12 @@ var StringField_default = StringField;
|
|
|
2539
2583
|
// src/components/fields/NullField.tsx
|
|
2540
2584
|
import { useEffect as useEffect2 } from "react";
|
|
2541
2585
|
function NullField(props) {
|
|
2542
|
-
const { formData, onChange } = props;
|
|
2586
|
+
const { name, formData, onChange } = props;
|
|
2543
2587
|
useEffect2(() => {
|
|
2544
2588
|
if (formData === void 0) {
|
|
2545
|
-
onChange(null);
|
|
2589
|
+
onChange(null, [name]);
|
|
2546
2590
|
}
|
|
2547
|
-
}, [formData, onChange]);
|
|
2591
|
+
}, [name, formData, onChange]);
|
|
2548
2592
|
return null;
|
|
2549
2593
|
}
|
|
2550
2594
|
var NullField_default = NullField;
|
|
@@ -2572,18 +2616,18 @@ var fields_default = fields;
|
|
|
2572
2616
|
// src/components/templates/ArrayFieldDescriptionTemplate.tsx
|
|
2573
2617
|
import {
|
|
2574
2618
|
descriptionId as descriptionId2,
|
|
2575
|
-
getTemplate as
|
|
2619
|
+
getTemplate as getTemplate8,
|
|
2576
2620
|
getUiOptions as getUiOptions10
|
|
2577
2621
|
} from "@rjsf/utils";
|
|
2578
2622
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
2579
2623
|
function ArrayFieldDescriptionTemplate(props) {
|
|
2580
|
-
const {
|
|
2624
|
+
const { fieldPathId, description, registry, schema, uiSchema } = props;
|
|
2581
2625
|
const options = getUiOptions10(uiSchema, registry.globalUiOptions);
|
|
2582
2626
|
const { label: displayLabel = true } = options;
|
|
2583
2627
|
if (!description || !displayLabel) {
|
|
2584
2628
|
return null;
|
|
2585
2629
|
}
|
|
2586
|
-
const DescriptionFieldTemplate =
|
|
2630
|
+
const DescriptionFieldTemplate = getTemplate8(
|
|
2587
2631
|
"DescriptionFieldTemplate",
|
|
2588
2632
|
registry,
|
|
2589
2633
|
options
|
|
@@ -2591,7 +2635,7 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
2591
2635
|
return /* @__PURE__ */ jsx11(
|
|
2592
2636
|
DescriptionFieldTemplate,
|
|
2593
2637
|
{
|
|
2594
|
-
id: descriptionId2(
|
|
2638
|
+
id: descriptionId2(fieldPathId),
|
|
2595
2639
|
description,
|
|
2596
2640
|
schema,
|
|
2597
2641
|
uiSchema,
|
|
@@ -2602,14 +2646,14 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
2602
2646
|
|
|
2603
2647
|
// src/components/templates/ArrayFieldItemTemplate.tsx
|
|
2604
2648
|
import {
|
|
2605
|
-
getTemplate as
|
|
2649
|
+
getTemplate as getTemplate9,
|
|
2606
2650
|
getUiOptions as getUiOptions11
|
|
2607
2651
|
} from "@rjsf/utils";
|
|
2608
|
-
import { jsx as jsx12, jsxs as
|
|
2652
|
+
import { jsx as jsx12, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2609
2653
|
function ArrayFieldItemTemplate(props) {
|
|
2610
2654
|
const { children, className, buttonsProps, hasToolbar, registry, uiSchema } = props;
|
|
2611
2655
|
const uiOptions = getUiOptions11(uiSchema);
|
|
2612
|
-
const ArrayFieldItemButtonsTemplate2 =
|
|
2656
|
+
const ArrayFieldItemButtonsTemplate2 = getTemplate9(
|
|
2613
2657
|
"ArrayFieldItemButtonsTemplate",
|
|
2614
2658
|
registry,
|
|
2615
2659
|
uiOptions
|
|
@@ -2620,7 +2664,7 @@ function ArrayFieldItemTemplate(props) {
|
|
|
2620
2664
|
paddingRight: 6,
|
|
2621
2665
|
fontWeight: "bold"
|
|
2622
2666
|
};
|
|
2623
|
-
return /* @__PURE__ */
|
|
2667
|
+
return /* @__PURE__ */ jsxs3("div", { className, children: [
|
|
2624
2668
|
/* @__PURE__ */ jsx12("div", { className: hasToolbar ? "col-xs-9" : "col-xs-12", children }),
|
|
2625
2669
|
hasToolbar && /* @__PURE__ */ jsx12("div", { className: "col-xs-3 array-item-toolbox", children: /* @__PURE__ */ jsx12(
|
|
2626
2670
|
"div",
|
|
@@ -2641,7 +2685,7 @@ import { useMemo } from "react";
|
|
|
2641
2685
|
import {
|
|
2642
2686
|
buttonId
|
|
2643
2687
|
} from "@rjsf/utils";
|
|
2644
|
-
import { Fragment as Fragment2, jsx as jsx13, jsxs as
|
|
2688
|
+
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2645
2689
|
function ArrayFieldItemButtonsTemplate(props) {
|
|
2646
2690
|
const {
|
|
2647
2691
|
disabled,
|
|
@@ -2649,7 +2693,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2649
2693
|
hasMoveDown,
|
|
2650
2694
|
hasMoveUp,
|
|
2651
2695
|
hasRemove,
|
|
2652
|
-
|
|
2696
|
+
fieldPathId,
|
|
2653
2697
|
index,
|
|
2654
2698
|
onCopyIndexClick,
|
|
2655
2699
|
onDropIndexClick,
|
|
@@ -2663,11 +2707,11 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2663
2707
|
const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
2664
2708
|
const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
2665
2709
|
const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
2666
|
-
return /* @__PURE__ */
|
|
2710
|
+
return /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
2667
2711
|
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx13(
|
|
2668
2712
|
MoveUpButton2,
|
|
2669
2713
|
{
|
|
2670
|
-
id: buttonId(
|
|
2714
|
+
id: buttonId(fieldPathId, "moveUp"),
|
|
2671
2715
|
className: "rjsf-array-item-move-up",
|
|
2672
2716
|
disabled: disabled || readonly || !hasMoveUp,
|
|
2673
2717
|
onClick: onArrowUpClick,
|
|
@@ -2678,7 +2722,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2678
2722
|
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx13(
|
|
2679
2723
|
MoveDownButton2,
|
|
2680
2724
|
{
|
|
2681
|
-
id: buttonId(
|
|
2725
|
+
id: buttonId(fieldPathId, "moveDown"),
|
|
2682
2726
|
className: "rjsf-array-item-move-down",
|
|
2683
2727
|
disabled: disabled || readonly || !hasMoveDown,
|
|
2684
2728
|
onClick: onArrowDownClick,
|
|
@@ -2689,7 +2733,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2689
2733
|
hasCopy && /* @__PURE__ */ jsx13(
|
|
2690
2734
|
CopyButton2,
|
|
2691
2735
|
{
|
|
2692
|
-
id: buttonId(
|
|
2736
|
+
id: buttonId(fieldPathId, "copy"),
|
|
2693
2737
|
className: "rjsf-array-item-copy",
|
|
2694
2738
|
disabled: disabled || readonly,
|
|
2695
2739
|
onClick: onCopyClick,
|
|
@@ -2700,7 +2744,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2700
2744
|
hasRemove && /* @__PURE__ */ jsx13(
|
|
2701
2745
|
RemoveButton2,
|
|
2702
2746
|
{
|
|
2703
|
-
id: buttonId(
|
|
2747
|
+
id: buttonId(fieldPathId, "remove"),
|
|
2704
2748
|
className: "rjsf-array-item-remove",
|
|
2705
2749
|
disabled: disabled || readonly,
|
|
2706
2750
|
onClick: onRemoveClick,
|
|
@@ -2713,17 +2757,17 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2713
2757
|
|
|
2714
2758
|
// src/components/templates/ArrayFieldTemplate.tsx
|
|
2715
2759
|
import {
|
|
2716
|
-
getTemplate as
|
|
2760
|
+
getTemplate as getTemplate10,
|
|
2717
2761
|
getUiOptions as getUiOptions12,
|
|
2718
2762
|
buttonId as buttonId2
|
|
2719
2763
|
} from "@rjsf/utils";
|
|
2720
|
-
import { jsx as jsx14, jsxs as
|
|
2764
|
+
import { jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2721
2765
|
function ArrayFieldTemplate(props) {
|
|
2722
2766
|
const {
|
|
2723
2767
|
canAdd,
|
|
2724
2768
|
className,
|
|
2725
2769
|
disabled,
|
|
2726
|
-
|
|
2770
|
+
fieldPathId,
|
|
2727
2771
|
uiSchema,
|
|
2728
2772
|
items,
|
|
2729
2773
|
onAddClick,
|
|
@@ -2734,17 +2778,17 @@ function ArrayFieldTemplate(props) {
|
|
|
2734
2778
|
title
|
|
2735
2779
|
} = props;
|
|
2736
2780
|
const uiOptions = getUiOptions12(uiSchema);
|
|
2737
|
-
const ArrayFieldDescriptionTemplate2 =
|
|
2781
|
+
const ArrayFieldDescriptionTemplate2 = getTemplate10(
|
|
2738
2782
|
"ArrayFieldDescriptionTemplate",
|
|
2739
2783
|
registry,
|
|
2740
2784
|
uiOptions
|
|
2741
2785
|
);
|
|
2742
|
-
const ArrayFieldItemTemplate2 =
|
|
2786
|
+
const ArrayFieldItemTemplate2 = getTemplate10(
|
|
2743
2787
|
"ArrayFieldItemTemplate",
|
|
2744
2788
|
registry,
|
|
2745
2789
|
uiOptions
|
|
2746
2790
|
);
|
|
2747
|
-
const ArrayFieldTitleTemplate2 =
|
|
2791
|
+
const ArrayFieldTitleTemplate2 = getTemplate10(
|
|
2748
2792
|
"ArrayFieldTitleTemplate",
|
|
2749
2793
|
registry,
|
|
2750
2794
|
uiOptions
|
|
@@ -2752,11 +2796,11 @@ function ArrayFieldTemplate(props) {
|
|
|
2752
2796
|
const {
|
|
2753
2797
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
2754
2798
|
} = registry.templates;
|
|
2755
|
-
return /* @__PURE__ */
|
|
2799
|
+
return /* @__PURE__ */ jsxs5("fieldset", { className, id: fieldPathId.$id, children: [
|
|
2756
2800
|
/* @__PURE__ */ jsx14(
|
|
2757
2801
|
ArrayFieldTitleTemplate2,
|
|
2758
2802
|
{
|
|
2759
|
-
|
|
2803
|
+
fieldPathId,
|
|
2760
2804
|
title: uiOptions.title || title,
|
|
2761
2805
|
required,
|
|
2762
2806
|
schema,
|
|
@@ -2767,7 +2811,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2767
2811
|
/* @__PURE__ */ jsx14(
|
|
2768
2812
|
ArrayFieldDescriptionTemplate2,
|
|
2769
2813
|
{
|
|
2770
|
-
|
|
2814
|
+
fieldPathId,
|
|
2771
2815
|
description: uiOptions.description || schema.description,
|
|
2772
2816
|
schema,
|
|
2773
2817
|
uiSchema,
|
|
@@ -2778,7 +2822,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2778
2822
|
canAdd && /* @__PURE__ */ jsx14(
|
|
2779
2823
|
AddButton2,
|
|
2780
2824
|
{
|
|
2781
|
-
id: buttonId2(
|
|
2825
|
+
id: buttonId2(fieldPathId, "add"),
|
|
2782
2826
|
className: "rjsf-array-item-add",
|
|
2783
2827
|
onClick: onAddClick,
|
|
2784
2828
|
disabled: disabled || readonly,
|
|
@@ -2791,19 +2835,19 @@ function ArrayFieldTemplate(props) {
|
|
|
2791
2835
|
|
|
2792
2836
|
// src/components/templates/ArrayFieldTitleTemplate.tsx
|
|
2793
2837
|
import {
|
|
2794
|
-
getTemplate as
|
|
2838
|
+
getTemplate as getTemplate11,
|
|
2795
2839
|
getUiOptions as getUiOptions13,
|
|
2796
2840
|
titleId as titleId2
|
|
2797
2841
|
} from "@rjsf/utils";
|
|
2798
2842
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
2799
2843
|
function ArrayFieldTitleTemplate(props) {
|
|
2800
|
-
const {
|
|
2844
|
+
const { fieldPathId, title, schema, uiSchema, required, registry } = props;
|
|
2801
2845
|
const options = getUiOptions13(uiSchema, registry.globalUiOptions);
|
|
2802
2846
|
const { label: displayLabel = true } = options;
|
|
2803
2847
|
if (!title || !displayLabel) {
|
|
2804
2848
|
return null;
|
|
2805
2849
|
}
|
|
2806
|
-
const TitleFieldTemplate =
|
|
2850
|
+
const TitleFieldTemplate = getTemplate11(
|
|
2807
2851
|
"TitleFieldTemplate",
|
|
2808
2852
|
registry,
|
|
2809
2853
|
options
|
|
@@ -2811,7 +2855,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2811
2855
|
return /* @__PURE__ */ jsx15(
|
|
2812
2856
|
TitleFieldTemplate,
|
|
2813
2857
|
{
|
|
2814
|
-
id: titleId2(
|
|
2858
|
+
id: titleId2(fieldPathId),
|
|
2815
2859
|
title,
|
|
2816
2860
|
required,
|
|
2817
2861
|
schema,
|
|
@@ -2822,13 +2866,13 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2822
2866
|
}
|
|
2823
2867
|
|
|
2824
2868
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2825
|
-
import { useCallback as
|
|
2869
|
+
import { useCallback as useCallback5 } from "react";
|
|
2826
2870
|
import {
|
|
2827
2871
|
ariaDescribedByIds,
|
|
2828
2872
|
examplesId,
|
|
2829
2873
|
getInputProps
|
|
2830
2874
|
} from "@rjsf/utils";
|
|
2831
|
-
import { Fragment as Fragment3, jsx as jsx16, jsxs as
|
|
2875
|
+
import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2832
2876
|
function BaseInputTemplate(props) {
|
|
2833
2877
|
const {
|
|
2834
2878
|
id,
|
|
@@ -2869,19 +2913,19 @@ function BaseInputTemplate(props) {
|
|
|
2869
2913
|
} else {
|
|
2870
2914
|
inputValue = value == null ? "" : value;
|
|
2871
2915
|
}
|
|
2872
|
-
const _onChange =
|
|
2916
|
+
const _onChange = useCallback5(
|
|
2873
2917
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
2874
2918
|
[onChange, options]
|
|
2875
2919
|
);
|
|
2876
|
-
const _onBlur =
|
|
2920
|
+
const _onBlur = useCallback5(
|
|
2877
2921
|
({ target }) => onBlur(id, target && target.value),
|
|
2878
2922
|
[onBlur, id]
|
|
2879
2923
|
);
|
|
2880
|
-
const _onFocus =
|
|
2924
|
+
const _onFocus = useCallback5(
|
|
2881
2925
|
({ target }) => onFocus(id, target && target.value),
|
|
2882
2926
|
[onFocus, id]
|
|
2883
2927
|
);
|
|
2884
|
-
return /* @__PURE__ */
|
|
2928
|
+
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
2885
2929
|
/* @__PURE__ */ jsx16(
|
|
2886
2930
|
"input",
|
|
2887
2931
|
{
|
|
@@ -3020,13 +3064,13 @@ function DescriptionField(props) {
|
|
|
3020
3064
|
import {
|
|
3021
3065
|
TranslatableString as TranslatableString8
|
|
3022
3066
|
} from "@rjsf/utils";
|
|
3023
|
-
import { jsx as jsx22, jsxs as
|
|
3067
|
+
import { jsx as jsx22, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3024
3068
|
function ErrorList({
|
|
3025
3069
|
errors,
|
|
3026
3070
|
registry
|
|
3027
3071
|
}) {
|
|
3028
3072
|
const { translateString } = registry;
|
|
3029
|
-
return /* @__PURE__ */
|
|
3073
|
+
return /* @__PURE__ */ jsxs7("div", { className: "panel panel-danger errors", children: [
|
|
3030
3074
|
/* @__PURE__ */ jsx22("div", { className: "panel-heading", children: /* @__PURE__ */ jsx22("h3", { className: "panel-title", children: translateString(TranslatableString8.ErrorsLabel) }) }),
|
|
3031
3075
|
/* @__PURE__ */ jsx22("ul", { className: "list-group", children: errors.map((error, i) => {
|
|
3032
3076
|
return /* @__PURE__ */ jsx22("li", { className: "list-group-item text-danger", children: error.stack }, i);
|
|
@@ -3036,30 +3080,30 @@ function ErrorList({
|
|
|
3036
3080
|
|
|
3037
3081
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3038
3082
|
import {
|
|
3039
|
-
getTemplate as
|
|
3083
|
+
getTemplate as getTemplate12,
|
|
3040
3084
|
getUiOptions as getUiOptions15
|
|
3041
3085
|
} from "@rjsf/utils";
|
|
3042
3086
|
|
|
3043
3087
|
// src/components/templates/FieldTemplate/Label.tsx
|
|
3044
|
-
import { jsx as jsx23, jsxs as
|
|
3088
|
+
import { jsx as jsx23, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3045
3089
|
var REQUIRED_FIELD_SYMBOL = "*";
|
|
3046
3090
|
function Label(props) {
|
|
3047
3091
|
const { label, required, id } = props;
|
|
3048
3092
|
if (!label) {
|
|
3049
3093
|
return null;
|
|
3050
3094
|
}
|
|
3051
|
-
return /* @__PURE__ */
|
|
3095
|
+
return /* @__PURE__ */ jsxs8("label", { className: "control-label", htmlFor: id, children: [
|
|
3052
3096
|
label,
|
|
3053
3097
|
required && /* @__PURE__ */ jsx23("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
|
|
3054
3098
|
] });
|
|
3055
3099
|
}
|
|
3056
3100
|
|
|
3057
3101
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3058
|
-
import { jsx as jsx24, jsxs as
|
|
3102
|
+
import { jsx as jsx24, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3059
3103
|
function FieldTemplate(props) {
|
|
3060
3104
|
const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
|
|
3061
3105
|
const uiOptions = getUiOptions15(uiSchema);
|
|
3062
|
-
const WrapIfAdditionalTemplate2 =
|
|
3106
|
+
const WrapIfAdditionalTemplate2 = getTemplate12(
|
|
3063
3107
|
"WrapIfAdditionalTemplate",
|
|
3064
3108
|
registry,
|
|
3065
3109
|
uiOptions
|
|
@@ -3067,7 +3111,7 @@ function FieldTemplate(props) {
|
|
|
3067
3111
|
if (hidden) {
|
|
3068
3112
|
return /* @__PURE__ */ jsx24("div", { className: "hidden", children });
|
|
3069
3113
|
}
|
|
3070
|
-
return /* @__PURE__ */
|
|
3114
|
+
return /* @__PURE__ */ jsxs9(WrapIfAdditionalTemplate2, { ...props, children: [
|
|
3071
3115
|
displayLabel && /* @__PURE__ */ jsx24(Label, { label, required, id }),
|
|
3072
3116
|
displayLabel && description ? description : null,
|
|
3073
3117
|
children,
|
|
@@ -3083,11 +3127,11 @@ var FieldTemplate_default = FieldTemplate;
|
|
|
3083
3127
|
import { errorId } from "@rjsf/utils";
|
|
3084
3128
|
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
3085
3129
|
function FieldErrorTemplate(props) {
|
|
3086
|
-
const { errors = [],
|
|
3130
|
+
const { errors = [], fieldPathId } = props;
|
|
3087
3131
|
if (errors.length === 0) {
|
|
3088
3132
|
return null;
|
|
3089
3133
|
}
|
|
3090
|
-
const id = errorId(
|
|
3134
|
+
const id = errorId(fieldPathId);
|
|
3091
3135
|
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
|
|
3092
3136
|
return /* @__PURE__ */ jsx25("li", { className: "text-danger", children: error }, index);
|
|
3093
3137
|
}) }) });
|
|
@@ -3097,11 +3141,11 @@ function FieldErrorTemplate(props) {
|
|
|
3097
3141
|
import { helpId } from "@rjsf/utils";
|
|
3098
3142
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
3099
3143
|
function FieldHelpTemplate(props) {
|
|
3100
|
-
const {
|
|
3144
|
+
const { fieldPathId, help } = props;
|
|
3101
3145
|
if (!help) {
|
|
3102
3146
|
return null;
|
|
3103
3147
|
}
|
|
3104
|
-
const id = helpId(
|
|
3148
|
+
const id = helpId(fieldPathId);
|
|
3105
3149
|
if (typeof help === "string") {
|
|
3106
3150
|
return /* @__PURE__ */ jsx26("p", { id, className: "help-block", children: help });
|
|
3107
3151
|
}
|
|
@@ -3115,22 +3159,32 @@ function GridTemplate(props) {
|
|
|
3115
3159
|
return /* @__PURE__ */ jsx27("div", { className, ...rest, children });
|
|
3116
3160
|
}
|
|
3117
3161
|
|
|
3162
|
+
// src/components/templates/MultiSchemaFieldTemplate.tsx
|
|
3163
|
+
import { jsx as jsx28, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3164
|
+
function MultiSchemaFieldTemplate(props) {
|
|
3165
|
+
const { selector, optionSchemaField } = props;
|
|
3166
|
+
return /* @__PURE__ */ jsxs10("div", { className: "panel panel-default panel-body", children: [
|
|
3167
|
+
/* @__PURE__ */ jsx28("div", { className: "form-group", children: selector }),
|
|
3168
|
+
optionSchemaField
|
|
3169
|
+
] });
|
|
3170
|
+
}
|
|
3171
|
+
|
|
3118
3172
|
// src/components/templates/ObjectFieldTemplate.tsx
|
|
3119
3173
|
import {
|
|
3120
3174
|
canExpand,
|
|
3121
3175
|
descriptionId as descriptionId3,
|
|
3122
|
-
getTemplate as
|
|
3176
|
+
getTemplate as getTemplate13,
|
|
3123
3177
|
getUiOptions as getUiOptions16,
|
|
3124
3178
|
titleId as titleId3,
|
|
3125
3179
|
buttonId as buttonId3
|
|
3126
3180
|
} from "@rjsf/utils";
|
|
3127
|
-
import { jsx as
|
|
3181
|
+
import { jsx as jsx29, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3128
3182
|
function ObjectFieldTemplate(props) {
|
|
3129
3183
|
const {
|
|
3130
3184
|
description,
|
|
3131
3185
|
disabled,
|
|
3132
3186
|
formData,
|
|
3133
|
-
|
|
3187
|
+
fieldPathId,
|
|
3134
3188
|
onAddClick,
|
|
3135
3189
|
properties,
|
|
3136
3190
|
readonly,
|
|
@@ -3141,8 +3195,8 @@ function ObjectFieldTemplate(props) {
|
|
|
3141
3195
|
uiSchema
|
|
3142
3196
|
} = props;
|
|
3143
3197
|
const options = getUiOptions16(uiSchema);
|
|
3144
|
-
const TitleFieldTemplate =
|
|
3145
|
-
const DescriptionFieldTemplate =
|
|
3198
|
+
const TitleFieldTemplate = getTemplate13("TitleFieldTemplate", registry, options);
|
|
3199
|
+
const DescriptionFieldTemplate = getTemplate13(
|
|
3146
3200
|
"DescriptionFieldTemplate",
|
|
3147
3201
|
registry,
|
|
3148
3202
|
options
|
|
@@ -3150,11 +3204,11 @@ function ObjectFieldTemplate(props) {
|
|
|
3150
3204
|
const {
|
|
3151
3205
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
3152
3206
|
} = registry.templates;
|
|
3153
|
-
return /* @__PURE__ */ jsxs11("fieldset", { id:
|
|
3154
|
-
title && /* @__PURE__ */
|
|
3207
|
+
return /* @__PURE__ */ jsxs11("fieldset", { id: fieldPathId.$id, children: [
|
|
3208
|
+
title && /* @__PURE__ */ jsx29(
|
|
3155
3209
|
TitleFieldTemplate,
|
|
3156
3210
|
{
|
|
3157
|
-
id: titleId3(
|
|
3211
|
+
id: titleId3(fieldPathId),
|
|
3158
3212
|
title,
|
|
3159
3213
|
required,
|
|
3160
3214
|
schema,
|
|
@@ -3162,10 +3216,10 @@ function ObjectFieldTemplate(props) {
|
|
|
3162
3216
|
registry
|
|
3163
3217
|
}
|
|
3164
3218
|
),
|
|
3165
|
-
description && /* @__PURE__ */
|
|
3219
|
+
description && /* @__PURE__ */ jsx29(
|
|
3166
3220
|
DescriptionFieldTemplate,
|
|
3167
3221
|
{
|
|
3168
|
-
id: descriptionId3(
|
|
3222
|
+
id: descriptionId3(fieldPathId),
|
|
3169
3223
|
description,
|
|
3170
3224
|
schema,
|
|
3171
3225
|
uiSchema,
|
|
@@ -3173,10 +3227,10 @@ function ObjectFieldTemplate(props) {
|
|
|
3173
3227
|
}
|
|
3174
3228
|
),
|
|
3175
3229
|
properties.map((prop) => prop.content),
|
|
3176
|
-
canExpand(schema, uiSchema, formData) && /* @__PURE__ */
|
|
3230
|
+
canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx29(
|
|
3177
3231
|
AddButton2,
|
|
3178
3232
|
{
|
|
3179
|
-
id: buttonId3(
|
|
3233
|
+
id: buttonId3(fieldPathId, "add"),
|
|
3180
3234
|
className: "rjsf-object-property-expand",
|
|
3181
3235
|
onClick: onAddClick(schema),
|
|
3182
3236
|
disabled: disabled || readonly,
|
|
@@ -3188,36 +3242,36 @@ function ObjectFieldTemplate(props) {
|
|
|
3188
3242
|
}
|
|
3189
3243
|
|
|
3190
3244
|
// src/components/templates/TitleField.tsx
|
|
3191
|
-
import { jsx as
|
|
3245
|
+
import { jsx as jsx30, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3192
3246
|
var REQUIRED_FIELD_SYMBOL2 = "*";
|
|
3193
3247
|
function TitleField(props) {
|
|
3194
3248
|
const { id, title, required } = props;
|
|
3195
3249
|
return /* @__PURE__ */ jsxs12("legend", { id, children: [
|
|
3196
3250
|
title,
|
|
3197
|
-
required && /* @__PURE__ */
|
|
3251
|
+
required && /* @__PURE__ */ jsx30("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 })
|
|
3198
3252
|
] });
|
|
3199
3253
|
}
|
|
3200
3254
|
|
|
3201
3255
|
// src/components/templates/UnsupportedField.tsx
|
|
3202
3256
|
import { TranslatableString as TranslatableString9 } from "@rjsf/utils";
|
|
3203
3257
|
import Markdown3 from "markdown-to-jsx";
|
|
3204
|
-
import { jsx as
|
|
3258
|
+
import { jsx as jsx31, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3205
3259
|
function UnsupportedField(props) {
|
|
3206
|
-
const { schema,
|
|
3260
|
+
const { schema, fieldPathId, reason, registry } = props;
|
|
3207
3261
|
const { translateString } = registry;
|
|
3208
3262
|
let translateEnum = TranslatableString9.UnsupportedField;
|
|
3209
3263
|
const translateParams = [];
|
|
3210
|
-
if (
|
|
3264
|
+
if (fieldPathId && fieldPathId.$id) {
|
|
3211
3265
|
translateEnum = TranslatableString9.UnsupportedFieldWithId;
|
|
3212
|
-
translateParams.push(
|
|
3266
|
+
translateParams.push(fieldPathId.$id);
|
|
3213
3267
|
}
|
|
3214
3268
|
if (reason) {
|
|
3215
3269
|
translateEnum = translateEnum === TranslatableString9.UnsupportedField ? TranslatableString9.UnsupportedFieldWithReason : TranslatableString9.UnsupportedFieldWithIdAndReason;
|
|
3216
3270
|
translateParams.push(reason);
|
|
3217
3271
|
}
|
|
3218
3272
|
return /* @__PURE__ */ jsxs13("div", { className: "unsupported-field", children: [
|
|
3219
|
-
/* @__PURE__ */
|
|
3220
|
-
schema && /* @__PURE__ */
|
|
3273
|
+
/* @__PURE__ */ jsx31("p", { children: /* @__PURE__ */ jsx31(Markdown3, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3274
|
+
schema && /* @__PURE__ */ jsx31("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3221
3275
|
] });
|
|
3222
3276
|
}
|
|
3223
3277
|
var UnsupportedField_default = UnsupportedField;
|
|
@@ -3228,7 +3282,7 @@ import {
|
|
|
3228
3282
|
buttonId as buttonId4,
|
|
3229
3283
|
TranslatableString as TranslatableString10
|
|
3230
3284
|
} from "@rjsf/utils";
|
|
3231
|
-
import { jsx as
|
|
3285
|
+
import { jsx as jsx32, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3232
3286
|
function WrapIfAdditionalTemplate(props) {
|
|
3233
3287
|
const {
|
|
3234
3288
|
id,
|
|
@@ -3257,12 +3311,12 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3257
3311
|
}
|
|
3258
3312
|
const uiClassNames = classNamesList.join(" ").trim();
|
|
3259
3313
|
if (!additional) {
|
|
3260
|
-
return /* @__PURE__ */
|
|
3314
|
+
return /* @__PURE__ */ jsx32("div", { className: uiClassNames, style, children });
|
|
3261
3315
|
}
|
|
3262
|
-
return /* @__PURE__ */
|
|
3263
|
-
/* @__PURE__ */
|
|
3264
|
-
/* @__PURE__ */
|
|
3265
|
-
/* @__PURE__ */
|
|
3316
|
+
return /* @__PURE__ */ jsx32("div", { className: uiClassNames, style, children: /* @__PURE__ */ jsxs14("div", { className: "row", children: [
|
|
3317
|
+
/* @__PURE__ */ jsx32("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ jsxs14("div", { className: "form-group", children: [
|
|
3318
|
+
/* @__PURE__ */ jsx32(Label, { label: keyLabel, required, id: `${id}-key` }),
|
|
3319
|
+
/* @__PURE__ */ jsx32(
|
|
3266
3320
|
"input",
|
|
3267
3321
|
{
|
|
3268
3322
|
className: "form-control",
|
|
@@ -3273,8 +3327,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3273
3327
|
}
|
|
3274
3328
|
)
|
|
3275
3329
|
] }) }),
|
|
3276
|
-
/* @__PURE__ */
|
|
3277
|
-
/* @__PURE__ */
|
|
3330
|
+
/* @__PURE__ */ jsx32("div", { className: "form-additional form-group col-xs-5", children }),
|
|
3331
|
+
/* @__PURE__ */ jsx32("div", { className: "col-xs-2", children: /* @__PURE__ */ jsx32(
|
|
3278
3332
|
RemoveButton2,
|
|
3279
3333
|
{
|
|
3280
3334
|
id: buttonId4(id, "remove"),
|
|
@@ -3305,6 +3359,7 @@ function templates() {
|
|
|
3305
3359
|
FieldErrorTemplate,
|
|
3306
3360
|
FieldHelpTemplate,
|
|
3307
3361
|
GridTemplate,
|
|
3362
|
+
MultiSchemaFieldTemplate,
|
|
3308
3363
|
ObjectFieldTemplate,
|
|
3309
3364
|
TitleFieldTemplate: TitleField,
|
|
3310
3365
|
UnsupportedFieldTemplate: UnsupportedField_default,
|
|
@@ -3314,7 +3369,7 @@ function templates() {
|
|
|
3314
3369
|
var templates_default = templates;
|
|
3315
3370
|
|
|
3316
3371
|
// src/components/widgets/AltDateWidget.tsx
|
|
3317
|
-
import { useCallback as
|
|
3372
|
+
import { useCallback as useCallback6, useEffect as useEffect3, useState as useState3 } from "react";
|
|
3318
3373
|
import {
|
|
3319
3374
|
ariaDescribedByIds as ariaDescribedByIds2,
|
|
3320
3375
|
dateRangeOptions,
|
|
@@ -3323,7 +3378,7 @@ import {
|
|
|
3323
3378
|
TranslatableString as TranslatableString11,
|
|
3324
3379
|
getDateElementProps
|
|
3325
3380
|
} from "@rjsf/utils";
|
|
3326
|
-
import { jsx as
|
|
3381
|
+
import { jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3327
3382
|
function readyForChange(state) {
|
|
3328
3383
|
return Object.values(state).every((value) => value !== -1);
|
|
3329
3384
|
}
|
|
@@ -3343,7 +3398,7 @@ function DateElement({
|
|
|
3343
3398
|
}) {
|
|
3344
3399
|
const id = rootId + "_" + type;
|
|
3345
3400
|
const { SelectWidget: SelectWidget2 } = registry.widgets;
|
|
3346
|
-
return /* @__PURE__ */
|
|
3401
|
+
return /* @__PURE__ */ jsx33(
|
|
3347
3402
|
SelectWidget2,
|
|
3348
3403
|
{
|
|
3349
3404
|
schema: { type: "integer" },
|
|
@@ -3380,26 +3435,25 @@ function AltDateWidget({
|
|
|
3380
3435
|
value
|
|
3381
3436
|
}) {
|
|
3382
3437
|
const { translateString } = registry;
|
|
3383
|
-
const [
|
|
3384
|
-
|
|
3385
|
-
(
|
|
3386
|
-
|
|
3438
|
+
const [state, setState] = useState3(parseDateString(value, time));
|
|
3439
|
+
useEffect3(() => {
|
|
3440
|
+
setState(parseDateString(value, time));
|
|
3441
|
+
}, [time, value]);
|
|
3442
|
+
const handleChange = useCallback6(
|
|
3443
|
+
(property, value2) => {
|
|
3444
|
+
const nextState = {
|
|
3445
|
+
...state,
|
|
3446
|
+
[property]: typeof value2 === "undefined" ? -1 : value2
|
|
3447
|
+
};
|
|
3448
|
+
if (readyForChange(nextState)) {
|
|
3449
|
+
onChange(toDateString(nextState, time));
|
|
3450
|
+
} else {
|
|
3451
|
+
setState(nextState);
|
|
3452
|
+
}
|
|
3387
3453
|
},
|
|
3388
|
-
|
|
3454
|
+
[state, onChange, time]
|
|
3389
3455
|
);
|
|
3390
|
-
|
|
3391
|
-
const stateValue = toDateString(state, time);
|
|
3392
|
-
if (readyForChange(state) && stateValue !== value) {
|
|
3393
|
-
onChange(stateValue);
|
|
3394
|
-
} else if (lastValue !== value) {
|
|
3395
|
-
setLastValue(value);
|
|
3396
|
-
setState(parseDateString(value, time));
|
|
3397
|
-
}
|
|
3398
|
-
}, [time, value, onChange, state, lastValue]);
|
|
3399
|
-
const handleChange = useCallback4((property, value2) => {
|
|
3400
|
-
setState({ [property]: value2 });
|
|
3401
|
-
}, []);
|
|
3402
|
-
const handleSetNow = useCallback4(
|
|
3456
|
+
const handleSetNow = useCallback6(
|
|
3403
3457
|
(event) => {
|
|
3404
3458
|
event.preventDefault();
|
|
3405
3459
|
if (disabled || readonly) {
|
|
@@ -3408,9 +3462,9 @@ function AltDateWidget({
|
|
|
3408
3462
|
const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), time);
|
|
3409
3463
|
onChange(toDateString(nextState, time));
|
|
3410
3464
|
},
|
|
3411
|
-
[disabled, readonly, time]
|
|
3465
|
+
[disabled, readonly, time, onChange]
|
|
3412
3466
|
);
|
|
3413
|
-
const handleClear =
|
|
3467
|
+
const handleClear = useCallback6(
|
|
3414
3468
|
(event) => {
|
|
3415
3469
|
event.preventDefault();
|
|
3416
3470
|
if (disabled || readonly) {
|
|
@@ -3426,7 +3480,7 @@ function AltDateWidget({
|
|
|
3426
3480
|
time,
|
|
3427
3481
|
options.yearsRange,
|
|
3428
3482
|
options.format
|
|
3429
|
-
).map((elemProps, i) => /* @__PURE__ */
|
|
3483
|
+
).map((elemProps, i) => /* @__PURE__ */ jsx33("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx33(
|
|
3430
3484
|
DateElement,
|
|
3431
3485
|
{
|
|
3432
3486
|
rootId: id,
|
|
@@ -3441,33 +3495,33 @@ function AltDateWidget({
|
|
|
3441
3495
|
autofocus: autofocus && i === 0
|
|
3442
3496
|
}
|
|
3443
3497
|
) }, i)),
|
|
3444
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */
|
|
3445
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */
|
|
3498
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx33("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx33("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString11.NowLabel) }) }),
|
|
3499
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx33("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx33("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString11.ClearLabel) }) })
|
|
3446
3500
|
] });
|
|
3447
3501
|
}
|
|
3448
3502
|
var AltDateWidget_default = AltDateWidget;
|
|
3449
3503
|
|
|
3450
3504
|
// src/components/widgets/AltDateTimeWidget.tsx
|
|
3451
|
-
import { jsx as
|
|
3505
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
3452
3506
|
function AltDateTimeWidget({
|
|
3453
3507
|
time = true,
|
|
3454
3508
|
...props
|
|
3455
3509
|
}) {
|
|
3456
3510
|
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
3457
|
-
return /* @__PURE__ */
|
|
3511
|
+
return /* @__PURE__ */ jsx34(AltDateWidget2, { time, ...props });
|
|
3458
3512
|
}
|
|
3459
3513
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
3460
3514
|
|
|
3461
3515
|
// src/components/widgets/CheckboxWidget.tsx
|
|
3462
|
-
import { useCallback as
|
|
3516
|
+
import { useCallback as useCallback7 } from "react";
|
|
3463
3517
|
import {
|
|
3464
3518
|
ariaDescribedByIds as ariaDescribedByIds3,
|
|
3465
3519
|
descriptionId as descriptionId4,
|
|
3466
|
-
getTemplate as
|
|
3520
|
+
getTemplate as getTemplate14,
|
|
3467
3521
|
labelValue,
|
|
3468
3522
|
schemaRequiresTrueValue
|
|
3469
3523
|
} from "@rjsf/utils";
|
|
3470
|
-
import { jsx as
|
|
3524
|
+
import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3471
3525
|
function CheckboxWidget({
|
|
3472
3526
|
schema,
|
|
3473
3527
|
uiSchema,
|
|
@@ -3484,27 +3538,27 @@ function CheckboxWidget({
|
|
|
3484
3538
|
onChange,
|
|
3485
3539
|
registry
|
|
3486
3540
|
}) {
|
|
3487
|
-
const DescriptionFieldTemplate =
|
|
3541
|
+
const DescriptionFieldTemplate = getTemplate14(
|
|
3488
3542
|
"DescriptionFieldTemplate",
|
|
3489
3543
|
registry,
|
|
3490
3544
|
options
|
|
3491
3545
|
);
|
|
3492
3546
|
const required = schemaRequiresTrueValue(schema);
|
|
3493
|
-
const handleChange =
|
|
3547
|
+
const handleChange = useCallback7(
|
|
3494
3548
|
(event) => onChange(event.target.checked),
|
|
3495
3549
|
[onChange]
|
|
3496
3550
|
);
|
|
3497
|
-
const handleBlur =
|
|
3551
|
+
const handleBlur = useCallback7(
|
|
3498
3552
|
(event) => onBlur(id, event.target.checked),
|
|
3499
3553
|
[onBlur, id]
|
|
3500
3554
|
);
|
|
3501
|
-
const handleFocus =
|
|
3555
|
+
const handleFocus = useCallback7(
|
|
3502
3556
|
(event) => onFocus(id, event.target.checked),
|
|
3503
3557
|
[onFocus, id]
|
|
3504
3558
|
);
|
|
3505
3559
|
const description = options.description ?? schema.description;
|
|
3506
3560
|
return /* @__PURE__ */ jsxs16("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
|
|
3507
|
-
!hideLabel && description && /* @__PURE__ */
|
|
3561
|
+
!hideLabel && description && /* @__PURE__ */ jsx35(
|
|
3508
3562
|
DescriptionFieldTemplate,
|
|
3509
3563
|
{
|
|
3510
3564
|
id: descriptionId4(id),
|
|
@@ -3515,7 +3569,7 @@ function CheckboxWidget({
|
|
|
3515
3569
|
}
|
|
3516
3570
|
),
|
|
3517
3571
|
/* @__PURE__ */ jsxs16("label", { children: [
|
|
3518
|
-
/* @__PURE__ */
|
|
3572
|
+
/* @__PURE__ */ jsx35(
|
|
3519
3573
|
"input",
|
|
3520
3574
|
{
|
|
3521
3575
|
type: "checkbox",
|
|
@@ -3531,14 +3585,14 @@ function CheckboxWidget({
|
|
|
3531
3585
|
"aria-describedby": ariaDescribedByIds3(id)
|
|
3532
3586
|
}
|
|
3533
3587
|
),
|
|
3534
|
-
labelValue(/* @__PURE__ */
|
|
3588
|
+
labelValue(/* @__PURE__ */ jsx35("span", { children: label }), hideLabel)
|
|
3535
3589
|
] })
|
|
3536
3590
|
] });
|
|
3537
3591
|
}
|
|
3538
3592
|
var CheckboxWidget_default = CheckboxWidget;
|
|
3539
3593
|
|
|
3540
3594
|
// src/components/widgets/CheckboxesWidget.tsx
|
|
3541
|
-
import { useCallback as
|
|
3595
|
+
import { useCallback as useCallback8 } from "react";
|
|
3542
3596
|
import {
|
|
3543
3597
|
ariaDescribedByIds as ariaDescribedByIds4,
|
|
3544
3598
|
enumOptionsDeselectValue,
|
|
@@ -3547,7 +3601,7 @@ import {
|
|
|
3547
3601
|
enumOptionsValueForIndex,
|
|
3548
3602
|
optionId
|
|
3549
3603
|
} from "@rjsf/utils";
|
|
3550
|
-
import { jsx as
|
|
3604
|
+
import { jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3551
3605
|
function CheckboxesWidget({
|
|
3552
3606
|
id,
|
|
3553
3607
|
disabled,
|
|
@@ -3560,15 +3614,15 @@ function CheckboxesWidget({
|
|
|
3560
3614
|
onFocus
|
|
3561
3615
|
}) {
|
|
3562
3616
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3563
|
-
const handleBlur =
|
|
3617
|
+
const handleBlur = useCallback8(
|
|
3564
3618
|
({ target }) => onBlur(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
3565
|
-
[onBlur, id]
|
|
3619
|
+
[onBlur, id, enumOptions, emptyValue]
|
|
3566
3620
|
);
|
|
3567
|
-
const handleFocus =
|
|
3621
|
+
const handleFocus = useCallback8(
|
|
3568
3622
|
({ target }) => onFocus(id, enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue)),
|
|
3569
|
-
[onFocus, id]
|
|
3623
|
+
[onFocus, id, enumOptions, emptyValue]
|
|
3570
3624
|
);
|
|
3571
|
-
return /* @__PURE__ */
|
|
3625
|
+
return /* @__PURE__ */ jsx36("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3572
3626
|
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
3573
3627
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3574
3628
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
@@ -3580,7 +3634,7 @@ function CheckboxesWidget({
|
|
|
3580
3634
|
}
|
|
3581
3635
|
};
|
|
3582
3636
|
const checkbox = /* @__PURE__ */ jsxs17("span", { children: [
|
|
3583
|
-
/* @__PURE__ */
|
|
3637
|
+
/* @__PURE__ */ jsx36(
|
|
3584
3638
|
"input",
|
|
3585
3639
|
{
|
|
3586
3640
|
type: "checkbox",
|
|
@@ -3596,44 +3650,44 @@ function CheckboxesWidget({
|
|
|
3596
3650
|
"aria-describedby": ariaDescribedByIds4(id)
|
|
3597
3651
|
}
|
|
3598
3652
|
),
|
|
3599
|
-
/* @__PURE__ */
|
|
3653
|
+
/* @__PURE__ */ jsx36("span", { children: option.label })
|
|
3600
3654
|
] });
|
|
3601
|
-
return inline ? /* @__PURE__ */
|
|
3655
|
+
return inline ? /* @__PURE__ */ jsx36("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsx36("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsx36("label", { children: checkbox }) }, index);
|
|
3602
3656
|
}) });
|
|
3603
3657
|
}
|
|
3604
3658
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3605
3659
|
|
|
3606
3660
|
// src/components/widgets/ColorWidget.tsx
|
|
3607
|
-
import { getTemplate as
|
|
3608
|
-
import { jsx as
|
|
3661
|
+
import { getTemplate as getTemplate15 } from "@rjsf/utils";
|
|
3662
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
3609
3663
|
function ColorWidget(props) {
|
|
3610
3664
|
const { disabled, readonly, options, registry } = props;
|
|
3611
|
-
const BaseInputTemplate2 =
|
|
3612
|
-
return /* @__PURE__ */
|
|
3665
|
+
const BaseInputTemplate2 = getTemplate15("BaseInputTemplate", registry, options);
|
|
3666
|
+
return /* @__PURE__ */ jsx37(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
|
|
3613
3667
|
}
|
|
3614
3668
|
|
|
3615
3669
|
// src/components/widgets/DateWidget.tsx
|
|
3616
|
-
import { useCallback as
|
|
3617
|
-
import { getTemplate as
|
|
3618
|
-
import { jsx as
|
|
3670
|
+
import { useCallback as useCallback9 } from "react";
|
|
3671
|
+
import { getTemplate as getTemplate16 } from "@rjsf/utils";
|
|
3672
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
3619
3673
|
function DateWidget(props) {
|
|
3620
3674
|
const { onChange, options, registry } = props;
|
|
3621
|
-
const BaseInputTemplate2 =
|
|
3622
|
-
const handleChange =
|
|
3623
|
-
return /* @__PURE__ */
|
|
3675
|
+
const BaseInputTemplate2 = getTemplate16("BaseInputTemplate", registry, options);
|
|
3676
|
+
const handleChange = useCallback9((value) => onChange(value || void 0), [onChange]);
|
|
3677
|
+
return /* @__PURE__ */ jsx38(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3624
3678
|
}
|
|
3625
3679
|
|
|
3626
3680
|
// src/components/widgets/DateTimeWidget.tsx
|
|
3627
3681
|
import {
|
|
3628
|
-
getTemplate as
|
|
3682
|
+
getTemplate as getTemplate17,
|
|
3629
3683
|
localToUTC,
|
|
3630
3684
|
utcToLocal
|
|
3631
3685
|
} from "@rjsf/utils";
|
|
3632
|
-
import { jsx as
|
|
3686
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
3633
3687
|
function DateTimeWidget(props) {
|
|
3634
3688
|
const { onChange, value, options, registry } = props;
|
|
3635
|
-
const BaseInputTemplate2 =
|
|
3636
|
-
return /* @__PURE__ */
|
|
3689
|
+
const BaseInputTemplate2 = getTemplate17("BaseInputTemplate", registry, options);
|
|
3690
|
+
return /* @__PURE__ */ jsx39(
|
|
3637
3691
|
BaseInputTemplate2,
|
|
3638
3692
|
{
|
|
3639
3693
|
type: "datetime-local",
|
|
@@ -3645,23 +3699,23 @@ function DateTimeWidget(props) {
|
|
|
3645
3699
|
}
|
|
3646
3700
|
|
|
3647
3701
|
// src/components/widgets/EmailWidget.tsx
|
|
3648
|
-
import { getTemplate as
|
|
3649
|
-
import { jsx as
|
|
3702
|
+
import { getTemplate as getTemplate18 } from "@rjsf/utils";
|
|
3703
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
3650
3704
|
function EmailWidget(props) {
|
|
3651
3705
|
const { options, registry } = props;
|
|
3652
|
-
const BaseInputTemplate2 =
|
|
3653
|
-
return /* @__PURE__ */
|
|
3706
|
+
const BaseInputTemplate2 = getTemplate18("BaseInputTemplate", registry, options);
|
|
3707
|
+
return /* @__PURE__ */ jsx40(BaseInputTemplate2, { type: "email", ...props });
|
|
3654
3708
|
}
|
|
3655
3709
|
|
|
3656
3710
|
// src/components/widgets/FileWidget.tsx
|
|
3657
|
-
import { useCallback as
|
|
3711
|
+
import { useCallback as useCallback10, useMemo as useMemo2 } from "react";
|
|
3658
3712
|
import {
|
|
3659
3713
|
dataURItoBlob,
|
|
3660
|
-
getTemplate as
|
|
3714
|
+
getTemplate as getTemplate19,
|
|
3661
3715
|
TranslatableString as TranslatableString12
|
|
3662
3716
|
} from "@rjsf/utils";
|
|
3663
3717
|
import Markdown4 from "markdown-to-jsx";
|
|
3664
|
-
import { Fragment as Fragment4, jsx as
|
|
3718
|
+
import { Fragment as Fragment4, jsx as jsx41, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3665
3719
|
function addNameToDataURL(dataURL, name) {
|
|
3666
3720
|
if (dataURL === null) {
|
|
3667
3721
|
return null;
|
|
@@ -3706,11 +3760,11 @@ function FileInfoPreview({
|
|
|
3706
3760
|
return null;
|
|
3707
3761
|
}
|
|
3708
3762
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3709
|
-
return /* @__PURE__ */
|
|
3763
|
+
return /* @__PURE__ */ jsx41("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3710
3764
|
}
|
|
3711
3765
|
return /* @__PURE__ */ jsxs18(Fragment4, { children: [
|
|
3712
3766
|
" ",
|
|
3713
|
-
/* @__PURE__ */
|
|
3767
|
+
/* @__PURE__ */ jsx41("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(TranslatableString12.PreviewLabel) })
|
|
3714
3768
|
] });
|
|
3715
3769
|
}
|
|
3716
3770
|
function FilesInfo({
|
|
@@ -3724,14 +3778,14 @@ function FilesInfo({
|
|
|
3724
3778
|
return null;
|
|
3725
3779
|
}
|
|
3726
3780
|
const { translateString } = registry;
|
|
3727
|
-
const { RemoveButton: RemoveButton2 } =
|
|
3728
|
-
return /* @__PURE__ */
|
|
3781
|
+
const { RemoveButton: RemoveButton2 } = getTemplate19("ButtonTemplates", registry, options);
|
|
3782
|
+
return /* @__PURE__ */ jsx41("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3729
3783
|
const { name, size, type } = fileInfo;
|
|
3730
3784
|
const handleRemove = () => onRemove(key);
|
|
3731
3785
|
return /* @__PURE__ */ jsxs18("li", { children: [
|
|
3732
|
-
/* @__PURE__ */
|
|
3733
|
-
preview && /* @__PURE__ */
|
|
3734
|
-
/* @__PURE__ */
|
|
3786
|
+
/* @__PURE__ */ jsx41(Markdown4, { children: translateString(TranslatableString12.FilesInfo, [name, type, String(size)]) }),
|
|
3787
|
+
preview && /* @__PURE__ */ jsx41(FileInfoPreview, { fileInfo, registry }),
|
|
3788
|
+
/* @__PURE__ */ jsx41(RemoveButton2, { onClick: handleRemove, registry })
|
|
3735
3789
|
] }, key);
|
|
3736
3790
|
}) });
|
|
3737
3791
|
}
|
|
@@ -3758,8 +3812,8 @@ function extractFileInfo(dataURLs) {
|
|
|
3758
3812
|
}
|
|
3759
3813
|
function FileWidget(props) {
|
|
3760
3814
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|
|
3761
|
-
const BaseInputTemplate2 =
|
|
3762
|
-
const handleChange =
|
|
3815
|
+
const BaseInputTemplate2 = getTemplate19("BaseInputTemplate", registry, options);
|
|
3816
|
+
const handleChange = useCallback10(
|
|
3763
3817
|
(event) => {
|
|
3764
3818
|
if (!event.target.files) {
|
|
3765
3819
|
return;
|
|
@@ -3776,7 +3830,7 @@ function FileWidget(props) {
|
|
|
3776
3830
|
[multiple, value, onChange]
|
|
3777
3831
|
);
|
|
3778
3832
|
const filesInfo = useMemo2(() => extractFileInfo(Array.isArray(value) ? value : [value]), [value]);
|
|
3779
|
-
const rmFile =
|
|
3833
|
+
const rmFile = useCallback10(
|
|
3780
3834
|
(index) => {
|
|
3781
3835
|
if (multiple) {
|
|
3782
3836
|
const newValue = value.filter((_, i) => i !== index);
|
|
@@ -3788,7 +3842,7 @@ function FileWidget(props) {
|
|
|
3788
3842
|
[multiple, value, onChange]
|
|
3789
3843
|
);
|
|
3790
3844
|
return /* @__PURE__ */ jsxs18("div", { children: [
|
|
3791
|
-
/* @__PURE__ */
|
|
3845
|
+
/* @__PURE__ */ jsx41(
|
|
3792
3846
|
BaseInputTemplate2,
|
|
3793
3847
|
{
|
|
3794
3848
|
...props,
|
|
@@ -3800,7 +3854,7 @@ function FileWidget(props) {
|
|
|
3800
3854
|
accept: options.accept ? String(options.accept) : void 0
|
|
3801
3855
|
}
|
|
3802
3856
|
),
|
|
3803
|
-
/* @__PURE__ */
|
|
3857
|
+
/* @__PURE__ */ jsx41(
|
|
3804
3858
|
FilesInfo,
|
|
3805
3859
|
{
|
|
3806
3860
|
filesInfo,
|
|
@@ -3815,33 +3869,33 @@ function FileWidget(props) {
|
|
|
3815
3869
|
var FileWidget_default = FileWidget;
|
|
3816
3870
|
|
|
3817
3871
|
// src/components/widgets/HiddenWidget.tsx
|
|
3818
|
-
import { jsx as
|
|
3872
|
+
import { jsx as jsx42 } from "react/jsx-runtime";
|
|
3819
3873
|
function HiddenWidget({
|
|
3820
3874
|
id,
|
|
3821
3875
|
value
|
|
3822
3876
|
}) {
|
|
3823
|
-
return /* @__PURE__ */
|
|
3877
|
+
return /* @__PURE__ */ jsx42("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
|
|
3824
3878
|
}
|
|
3825
3879
|
var HiddenWidget_default = HiddenWidget;
|
|
3826
3880
|
|
|
3827
3881
|
// src/components/widgets/PasswordWidget.tsx
|
|
3828
|
-
import { getTemplate as
|
|
3829
|
-
import { jsx as
|
|
3882
|
+
import { getTemplate as getTemplate20 } from "@rjsf/utils";
|
|
3883
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
3830
3884
|
function PasswordWidget(props) {
|
|
3831
3885
|
const { options, registry } = props;
|
|
3832
|
-
const BaseInputTemplate2 =
|
|
3833
|
-
return /* @__PURE__ */
|
|
3886
|
+
const BaseInputTemplate2 = getTemplate20("BaseInputTemplate", registry, options);
|
|
3887
|
+
return /* @__PURE__ */ jsx43(BaseInputTemplate2, { type: "password", ...props });
|
|
3834
3888
|
}
|
|
3835
3889
|
|
|
3836
3890
|
// src/components/widgets/RadioWidget.tsx
|
|
3837
|
-
import { useCallback as
|
|
3891
|
+
import { useCallback as useCallback11 } from "react";
|
|
3838
3892
|
import {
|
|
3839
3893
|
ariaDescribedByIds as ariaDescribedByIds5,
|
|
3840
3894
|
enumOptionsIsSelected as enumOptionsIsSelected2,
|
|
3841
3895
|
enumOptionsValueForIndex as enumOptionsValueForIndex2,
|
|
3842
3896
|
optionId as optionId2
|
|
3843
3897
|
} from "@rjsf/utils";
|
|
3844
|
-
import { jsx as
|
|
3898
|
+
import { jsx as jsx44, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3845
3899
|
function RadioWidget({
|
|
3846
3900
|
options,
|
|
3847
3901
|
value,
|
|
@@ -3855,21 +3909,21 @@ function RadioWidget({
|
|
|
3855
3909
|
id
|
|
3856
3910
|
}) {
|
|
3857
3911
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3858
|
-
const handleBlur =
|
|
3912
|
+
const handleBlur = useCallback11(
|
|
3859
3913
|
({ target }) => onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
|
|
3860
3914
|
[onBlur, enumOptions, emptyValue, id]
|
|
3861
3915
|
);
|
|
3862
|
-
const handleFocus =
|
|
3916
|
+
const handleFocus = useCallback11(
|
|
3863
3917
|
({ target }) => onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue)),
|
|
3864
3918
|
[onFocus, enumOptions, emptyValue, id]
|
|
3865
3919
|
);
|
|
3866
|
-
return /* @__PURE__ */
|
|
3920
|
+
return /* @__PURE__ */ jsx44("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3867
3921
|
const checked = enumOptionsIsSelected2(option.value, value);
|
|
3868
3922
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
3869
3923
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3870
3924
|
const handleChange = () => onChange(option.value);
|
|
3871
3925
|
const radio = /* @__PURE__ */ jsxs19("span", { children: [
|
|
3872
|
-
/* @__PURE__ */
|
|
3926
|
+
/* @__PURE__ */ jsx44(
|
|
3873
3927
|
"input",
|
|
3874
3928
|
{
|
|
3875
3929
|
type: "radio",
|
|
@@ -3886,15 +3940,15 @@ function RadioWidget({
|
|
|
3886
3940
|
"aria-describedby": ariaDescribedByIds5(id)
|
|
3887
3941
|
}
|
|
3888
3942
|
),
|
|
3889
|
-
/* @__PURE__ */
|
|
3943
|
+
/* @__PURE__ */ jsx44("span", { children: option.label })
|
|
3890
3944
|
] });
|
|
3891
|
-
return inline ? /* @__PURE__ */
|
|
3945
|
+
return inline ? /* @__PURE__ */ jsx44("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ jsx44("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsx44("label", { children: radio }) }, i);
|
|
3892
3946
|
}) });
|
|
3893
3947
|
}
|
|
3894
3948
|
var RadioWidget_default = RadioWidget;
|
|
3895
3949
|
|
|
3896
3950
|
// src/components/widgets/RangeWidget.tsx
|
|
3897
|
-
import { jsx as
|
|
3951
|
+
import { jsx as jsx45, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
3898
3952
|
function RangeWidget(props) {
|
|
3899
3953
|
const {
|
|
3900
3954
|
value,
|
|
@@ -3903,14 +3957,14 @@ function RangeWidget(props) {
|
|
|
3903
3957
|
}
|
|
3904
3958
|
} = props;
|
|
3905
3959
|
return /* @__PURE__ */ jsxs20("div", { className: "field-range-wrapper", children: [
|
|
3906
|
-
/* @__PURE__ */
|
|
3907
|
-
/* @__PURE__ */
|
|
3960
|
+
/* @__PURE__ */ jsx45(BaseInputTemplate2, { type: "range", ...props }),
|
|
3961
|
+
/* @__PURE__ */ jsx45("span", { className: "range-view", children: value })
|
|
3908
3962
|
] });
|
|
3909
3963
|
}
|
|
3910
3964
|
|
|
3911
3965
|
// src/components/widgets/RatingWidget.tsx
|
|
3912
|
-
import { useCallback as
|
|
3913
|
-
import { Fragment as Fragment5, jsx as
|
|
3966
|
+
import { useCallback as useCallback12 } from "react";
|
|
3967
|
+
import { Fragment as Fragment5, jsx as jsx46, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
3914
3968
|
function RatingWidget({
|
|
3915
3969
|
id,
|
|
3916
3970
|
value,
|
|
@@ -3927,7 +3981,7 @@ function RatingWidget({
|
|
|
3927
3981
|
const { stars = 5, shape = "star" } = options;
|
|
3928
3982
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3929
3983
|
const min = schema.minimum || 0;
|
|
3930
|
-
const handleStarClick =
|
|
3984
|
+
const handleStarClick = useCallback12(
|
|
3931
3985
|
(starValue) => {
|
|
3932
3986
|
if (!disabled && !readonly) {
|
|
3933
3987
|
onChange(starValue);
|
|
@@ -3935,7 +3989,7 @@ function RatingWidget({
|
|
|
3935
3989
|
},
|
|
3936
3990
|
[onChange, disabled, readonly]
|
|
3937
3991
|
);
|
|
3938
|
-
const handleFocus =
|
|
3992
|
+
const handleFocus = useCallback12(
|
|
3939
3993
|
(event) => {
|
|
3940
3994
|
if (onFocus) {
|
|
3941
3995
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3944,7 +3998,7 @@ function RatingWidget({
|
|
|
3944
3998
|
},
|
|
3945
3999
|
[onFocus, id]
|
|
3946
4000
|
);
|
|
3947
|
-
const handleBlur =
|
|
4001
|
+
const handleBlur = useCallback12(
|
|
3948
4002
|
(event) => {
|
|
3949
4003
|
if (onBlur) {
|
|
3950
4004
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3959,7 +4013,7 @@ function RatingWidget({
|
|
|
3959
4013
|
}
|
|
3960
4014
|
return isFilled ? "\u2605" : "\u2606";
|
|
3961
4015
|
};
|
|
3962
|
-
return /* @__PURE__ */
|
|
4016
|
+
return /* @__PURE__ */ jsx46(Fragment5, { children: /* @__PURE__ */ jsxs21(
|
|
3963
4017
|
"div",
|
|
3964
4018
|
{
|
|
3965
4019
|
className: "rating-widget",
|
|
@@ -3972,7 +4026,7 @@ function RatingWidget({
|
|
|
3972
4026
|
[...Array(numStars)].map((_, index) => {
|
|
3973
4027
|
const starValue = min + index;
|
|
3974
4028
|
const isFilled = starValue <= value;
|
|
3975
|
-
return /* @__PURE__ */
|
|
4029
|
+
return /* @__PURE__ */ jsx46(
|
|
3976
4030
|
"span",
|
|
3977
4031
|
{
|
|
3978
4032
|
onClick: () => handleStarClick(starValue),
|
|
@@ -3994,7 +4048,7 @@ function RatingWidget({
|
|
|
3994
4048
|
index
|
|
3995
4049
|
);
|
|
3996
4050
|
}),
|
|
3997
|
-
/* @__PURE__ */
|
|
4051
|
+
/* @__PURE__ */ jsx46(
|
|
3998
4052
|
"input",
|
|
3999
4053
|
{
|
|
4000
4054
|
type: "hidden",
|
|
@@ -4012,13 +4066,13 @@ function RatingWidget({
|
|
|
4012
4066
|
}
|
|
4013
4067
|
|
|
4014
4068
|
// src/components/widgets/SelectWidget.tsx
|
|
4015
|
-
import { useCallback as
|
|
4069
|
+
import { useCallback as useCallback13 } from "react";
|
|
4016
4070
|
import {
|
|
4017
4071
|
ariaDescribedByIds as ariaDescribedByIds6,
|
|
4018
4072
|
enumOptionsIndexForValue,
|
|
4019
4073
|
enumOptionsValueForIndex as enumOptionsValueForIndex3
|
|
4020
4074
|
} from "@rjsf/utils";
|
|
4021
|
-
import { jsx as
|
|
4075
|
+
import { jsx as jsx47, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4022
4076
|
function getValue(event, multiple) {
|
|
4023
4077
|
if (multiple) {
|
|
4024
4078
|
return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
|
|
@@ -4042,21 +4096,21 @@ function SelectWidget({
|
|
|
4042
4096
|
}) {
|
|
4043
4097
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
4044
4098
|
const emptyValue = multiple ? [] : "";
|
|
4045
|
-
const handleFocus =
|
|
4099
|
+
const handleFocus = useCallback13(
|
|
4046
4100
|
(event) => {
|
|
4047
4101
|
const newValue = getValue(event, multiple);
|
|
4048
4102
|
return onFocus(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
|
|
4049
4103
|
},
|
|
4050
4104
|
[onFocus, id, multiple, enumOptions, optEmptyVal]
|
|
4051
4105
|
);
|
|
4052
|
-
const handleBlur =
|
|
4106
|
+
const handleBlur = useCallback13(
|
|
4053
4107
|
(event) => {
|
|
4054
4108
|
const newValue = getValue(event, multiple);
|
|
4055
4109
|
return onBlur(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
|
|
4056
4110
|
},
|
|
4057
4111
|
[onBlur, id, multiple, enumOptions, optEmptyVal]
|
|
4058
4112
|
);
|
|
4059
|
-
const handleChange =
|
|
4113
|
+
const handleChange = useCallback13(
|
|
4060
4114
|
(event) => {
|
|
4061
4115
|
const newValue = getValue(event, multiple);
|
|
4062
4116
|
return onChange(enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
|
|
@@ -4082,10 +4136,10 @@ function SelectWidget({
|
|
|
4082
4136
|
onChange: handleChange,
|
|
4083
4137
|
"aria-describedby": ariaDescribedByIds6(id),
|
|
4084
4138
|
children: [
|
|
4085
|
-
showPlaceholderOption && /* @__PURE__ */
|
|
4139
|
+
showPlaceholderOption && /* @__PURE__ */ jsx47("option", { value: "", children: placeholder }),
|
|
4086
4140
|
Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
|
|
4087
4141
|
const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
|
|
4088
|
-
return /* @__PURE__ */
|
|
4142
|
+
return /* @__PURE__ */ jsx47("option", { value: String(i), disabled: disabled2, children: label }, i);
|
|
4089
4143
|
})
|
|
4090
4144
|
]
|
|
4091
4145
|
}
|
|
@@ -4094,9 +4148,9 @@ function SelectWidget({
|
|
|
4094
4148
|
var SelectWidget_default = SelectWidget;
|
|
4095
4149
|
|
|
4096
4150
|
// src/components/widgets/TextareaWidget.tsx
|
|
4097
|
-
import { useCallback as
|
|
4151
|
+
import { useCallback as useCallback14 } from "react";
|
|
4098
4152
|
import { ariaDescribedByIds as ariaDescribedByIds7 } from "@rjsf/utils";
|
|
4099
|
-
import { jsx as
|
|
4153
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
4100
4154
|
function TextareaWidget({
|
|
4101
4155
|
id,
|
|
4102
4156
|
options = {},
|
|
@@ -4110,19 +4164,19 @@ function TextareaWidget({
|
|
|
4110
4164
|
onBlur,
|
|
4111
4165
|
onFocus
|
|
4112
4166
|
}) {
|
|
4113
|
-
const handleChange =
|
|
4167
|
+
const handleChange = useCallback14(
|
|
4114
4168
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
4115
4169
|
[onChange, options.emptyValue]
|
|
4116
4170
|
);
|
|
4117
|
-
const handleBlur =
|
|
4171
|
+
const handleBlur = useCallback14(
|
|
4118
4172
|
({ target }) => onBlur(id, target && target.value),
|
|
4119
4173
|
[onBlur, id]
|
|
4120
4174
|
);
|
|
4121
|
-
const handleFocus =
|
|
4175
|
+
const handleFocus = useCallback14(
|
|
4122
4176
|
({ target }) => onFocus(id, target && target.value),
|
|
4123
4177
|
[id, onFocus]
|
|
4124
4178
|
);
|
|
4125
|
-
return /* @__PURE__ */
|
|
4179
|
+
return /* @__PURE__ */ jsx48(
|
|
4126
4180
|
"textarea",
|
|
4127
4181
|
{
|
|
4128
4182
|
id,
|
|
@@ -4149,41 +4203,41 @@ TextareaWidget.defaultProps = {
|
|
|
4149
4203
|
var TextareaWidget_default = TextareaWidget;
|
|
4150
4204
|
|
|
4151
4205
|
// src/components/widgets/TextWidget.tsx
|
|
4152
|
-
import { getTemplate as
|
|
4153
|
-
import { jsx as
|
|
4206
|
+
import { getTemplate as getTemplate21 } from "@rjsf/utils";
|
|
4207
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
4154
4208
|
function TextWidget(props) {
|
|
4155
4209
|
const { options, registry } = props;
|
|
4156
|
-
const BaseInputTemplate2 =
|
|
4157
|
-
return /* @__PURE__ */
|
|
4210
|
+
const BaseInputTemplate2 = getTemplate21("BaseInputTemplate", registry, options);
|
|
4211
|
+
return /* @__PURE__ */ jsx49(BaseInputTemplate2, { ...props });
|
|
4158
4212
|
}
|
|
4159
4213
|
|
|
4160
4214
|
// src/components/widgets/TimeWidget.tsx
|
|
4161
|
-
import { useCallback as
|
|
4162
|
-
import { getTemplate as
|
|
4163
|
-
import { jsx as
|
|
4215
|
+
import { useCallback as useCallback15 } from "react";
|
|
4216
|
+
import { getTemplate as getTemplate22 } from "@rjsf/utils";
|
|
4217
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
4164
4218
|
function TimeWidget(props) {
|
|
4165
4219
|
const { onChange, options, registry } = props;
|
|
4166
|
-
const BaseInputTemplate2 =
|
|
4167
|
-
const handleChange =
|
|
4168
|
-
return /* @__PURE__ */
|
|
4220
|
+
const BaseInputTemplate2 = getTemplate22("BaseInputTemplate", registry, options);
|
|
4221
|
+
const handleChange = useCallback15((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
4222
|
+
return /* @__PURE__ */ jsx50(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
4169
4223
|
}
|
|
4170
4224
|
|
|
4171
4225
|
// src/components/widgets/URLWidget.tsx
|
|
4172
|
-
import { getTemplate as
|
|
4173
|
-
import { jsx as
|
|
4226
|
+
import { getTemplate as getTemplate23 } from "@rjsf/utils";
|
|
4227
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
4174
4228
|
function URLWidget(props) {
|
|
4175
4229
|
const { options, registry } = props;
|
|
4176
|
-
const BaseInputTemplate2 =
|
|
4177
|
-
return /* @__PURE__ */
|
|
4230
|
+
const BaseInputTemplate2 = getTemplate23("BaseInputTemplate", registry, options);
|
|
4231
|
+
return /* @__PURE__ */ jsx51(BaseInputTemplate2, { type: "url", ...props });
|
|
4178
4232
|
}
|
|
4179
4233
|
|
|
4180
4234
|
// src/components/widgets/UpDownWidget.tsx
|
|
4181
|
-
import { getTemplate as
|
|
4182
|
-
import { jsx as
|
|
4235
|
+
import { getTemplate as getTemplate24 } from "@rjsf/utils";
|
|
4236
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
4183
4237
|
function UpDownWidget(props) {
|
|
4184
4238
|
const { options, registry } = props;
|
|
4185
|
-
const BaseInputTemplate2 =
|
|
4186
|
-
return /* @__PURE__ */
|
|
4239
|
+
const BaseInputTemplate2 = getTemplate24("BaseInputTemplate", registry, options);
|
|
4240
|
+
return /* @__PURE__ */ jsx52(BaseInputTemplate2, { type: "number", ...props });
|
|
4187
4241
|
}
|
|
4188
4242
|
|
|
4189
4243
|
// src/components/widgets/index.ts
|
|
@@ -4221,17 +4275,21 @@ function getDefaultRegistry() {
|
|
|
4221
4275
|
widgets: widgets_default(),
|
|
4222
4276
|
rootSchema: {},
|
|
4223
4277
|
formContext: {},
|
|
4224
|
-
translateString: englishStringTranslator
|
|
4278
|
+
translateString: englishStringTranslator,
|
|
4279
|
+
globalFormOptions: { idPrefix: DEFAULT_ID_PREFIX, idSeparator: DEFAULT_ID_SEPARATOR }
|
|
4225
4280
|
};
|
|
4226
4281
|
}
|
|
4227
4282
|
|
|
4228
4283
|
// src/components/Form.tsx
|
|
4229
|
-
import { jsx as
|
|
4284
|
+
import { jsx as jsx53, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4230
4285
|
var Form = class extends Component5 {
|
|
4231
4286
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4232
4287
|
* provide any possible type here
|
|
4233
4288
|
*/
|
|
4234
4289
|
formElement;
|
|
4290
|
+
/** The list of pending changes
|
|
4291
|
+
*/
|
|
4292
|
+
pendingChanges = [];
|
|
4235
4293
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
4236
4294
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
4237
4295
|
* state construction.
|
|
@@ -4244,7 +4302,7 @@ var Form = class extends Component5 {
|
|
|
4244
4302
|
throw new Error("A validator is required for Form functionality to work");
|
|
4245
4303
|
}
|
|
4246
4304
|
this.state = this.getStateFromProps(props, props.formData);
|
|
4247
|
-
if (this.props.onChange && !
|
|
4305
|
+
if (this.props.onChange && !deepEquals2(this.state.formData, this.props.formData)) {
|
|
4248
4306
|
this.props.onChange(this.state);
|
|
4249
4307
|
}
|
|
4250
4308
|
this.formElement = createRef();
|
|
@@ -4268,10 +4326,12 @@ var Form = class extends Component5 {
|
|
|
4268
4326
|
* with a flag indicating that an update is not necessary.
|
|
4269
4327
|
*/
|
|
4270
4328
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
4271
|
-
if (!
|
|
4329
|
+
if (!deepEquals2(this.props, prevProps)) {
|
|
4272
4330
|
const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
|
|
4273
|
-
const
|
|
4274
|
-
const
|
|
4331
|
+
const stateDataChangedFields = getChangedFields(this.props.formData, this.state.formData);
|
|
4332
|
+
const isSchemaChanged = !deepEquals2(prevProps.schema, this.props.schema);
|
|
4333
|
+
const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals2(prevProps.formData, this.props.formData);
|
|
4334
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !deepEquals2(this.state.formData, this.props.formData);
|
|
4275
4335
|
const nextState = this.getStateFromProps(
|
|
4276
4336
|
this.props,
|
|
4277
4337
|
this.props.formData,
|
|
@@ -4280,9 +4340,11 @@ var Form = class extends Component5 {
|
|
|
4280
4340
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
4281
4341
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
4282
4342
|
isSchemaChanged,
|
|
4283
|
-
formDataChangedFields
|
|
4343
|
+
formDataChangedFields,
|
|
4344
|
+
// Skip live validation for this request if no form data has changed from the last state
|
|
4345
|
+
!isStateDataChanged
|
|
4284
4346
|
);
|
|
4285
|
-
const shouldUpdate = !
|
|
4347
|
+
const shouldUpdate = !deepEquals2(nextState, prevState);
|
|
4286
4348
|
return { nextState, shouldUpdate };
|
|
4287
4349
|
}
|
|
4288
4350
|
return { shouldUpdate: false };
|
|
@@ -4302,7 +4364,7 @@ var Form = class extends Component5 {
|
|
|
4302
4364
|
componentDidUpdate(_, prevState, snapshot) {
|
|
4303
4365
|
if (snapshot.shouldUpdate) {
|
|
4304
4366
|
const { nextState } = snapshot;
|
|
4305
|
-
if (!
|
|
4367
|
+
if (!deepEquals2(nextState.formData, this.props.formData) && !deepEquals2(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
4306
4368
|
this.props.onChange(nextState);
|
|
4307
4369
|
}
|
|
4308
4370
|
this.setState(nextState);
|
|
@@ -4317,35 +4379,37 @@ var Form = class extends Component5 {
|
|
|
4317
4379
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4318
4380
|
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
4319
4381
|
* @param formDataChangedFields - The changed fields of `formData`
|
|
4382
|
+
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
4320
4383
|
* @returns - The new state for the `Form`
|
|
4321
4384
|
*/
|
|
4322
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
|
|
4385
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
4323
4386
|
const state = this.state || {};
|
|
4324
4387
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4388
|
+
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
4325
4389
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
4326
4390
|
const edit = typeof inputFormData !== "undefined";
|
|
4327
4391
|
const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
|
|
4328
4392
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
4329
|
-
const rootSchema = schema;
|
|
4330
4393
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4331
4394
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
4332
4395
|
let schemaUtils = state.schemaUtils;
|
|
4333
4396
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
4334
|
-
|
|
4335
|
-
|
|
4397
|
+
validator2,
|
|
4398
|
+
schema,
|
|
4336
4399
|
experimental_defaultFormStateBehavior,
|
|
4337
4400
|
experimental_customMergeAllOf
|
|
4338
4401
|
)) {
|
|
4339
4402
|
schemaUtils = createSchemaUtils(
|
|
4340
|
-
|
|
4341
|
-
|
|
4403
|
+
validator2,
|
|
4404
|
+
schema,
|
|
4342
4405
|
experimental_defaultFormStateBehavior,
|
|
4343
4406
|
experimental_customMergeAllOf
|
|
4344
4407
|
);
|
|
4345
4408
|
}
|
|
4346
|
-
const
|
|
4409
|
+
const rootSchema = schemaUtils.getRootSchema();
|
|
4410
|
+
const formData = schemaUtils.getDefaultFormState(rootSchema, inputFormData);
|
|
4347
4411
|
const _retrievedSchema = this.updateRetrievedSchema(
|
|
4348
|
-
retrievedSchema ?? schemaUtils.retrieveSchema(
|
|
4412
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4349
4413
|
);
|
|
4350
4414
|
const getCurrentErrors = () => {
|
|
4351
4415
|
if (props.noValidate || isSchemaChanged) {
|
|
@@ -4365,13 +4429,13 @@ var Form = class extends Component5 {
|
|
|
4365
4429
|
let errorSchema;
|
|
4366
4430
|
let schemaValidationErrors = state.schemaValidationErrors;
|
|
4367
4431
|
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
4368
|
-
if (mustValidate) {
|
|
4369
|
-
const schemaValidation = this.validate(formData,
|
|
4432
|
+
if (mustValidate && !skipLiveValidate) {
|
|
4433
|
+
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, _retrievedSchema);
|
|
4370
4434
|
errors = schemaValidation.errors;
|
|
4371
4435
|
if (retrievedSchema === void 0) {
|
|
4372
4436
|
errorSchema = schemaValidation.errorSchema;
|
|
4373
4437
|
} else {
|
|
4374
|
-
errorSchema =
|
|
4438
|
+
errorSchema = mergeObjects(
|
|
4375
4439
|
this.state?.errorSchema,
|
|
4376
4440
|
schemaValidation.errorSchema,
|
|
4377
4441
|
"preventDuplicates"
|
|
@@ -4383,7 +4447,7 @@ var Form = class extends Component5 {
|
|
|
4383
4447
|
const currentErrors = getCurrentErrors();
|
|
4384
4448
|
errors = currentErrors.errors;
|
|
4385
4449
|
errorSchema = currentErrors.errorSchema;
|
|
4386
|
-
if (formDataChangedFields.length > 0) {
|
|
4450
|
+
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
4387
4451
|
const newErrorSchema = formDataChangedFields.reduce(
|
|
4388
4452
|
(acc, key) => {
|
|
4389
4453
|
acc[key] = void 0;
|
|
@@ -4391,7 +4455,7 @@ var Form = class extends Component5 {
|
|
|
4391
4455
|
},
|
|
4392
4456
|
{}
|
|
4393
4457
|
);
|
|
4394
|
-
errorSchema = schemaValidationErrorSchema =
|
|
4458
|
+
errorSchema = schemaValidationErrorSchema = mergeObjects(
|
|
4395
4459
|
currentErrors.errorSchema,
|
|
4396
4460
|
newErrorSchema,
|
|
4397
4461
|
"preventDuplicates"
|
|
@@ -4403,18 +4467,12 @@ var Form = class extends Component5 {
|
|
|
4403
4467
|
errorSchema = merged.errorSchema;
|
|
4404
4468
|
errors = merged.errors;
|
|
4405
4469
|
}
|
|
4406
|
-
const
|
|
4407
|
-
_retrievedSchema,
|
|
4408
|
-
uiSchema["ui:rootFieldId"],
|
|
4409
|
-
formData,
|
|
4410
|
-
props.idPrefix,
|
|
4411
|
-
props.idSeparator
|
|
4412
|
-
);
|
|
4470
|
+
const fieldPathId = toFieldPathId4("", this.getGlobalFormOptions(this.props));
|
|
4413
4471
|
const nextState = {
|
|
4414
4472
|
schemaUtils,
|
|
4415
|
-
schema,
|
|
4473
|
+
schema: rootSchema,
|
|
4416
4474
|
uiSchema,
|
|
4417
|
-
|
|
4475
|
+
fieldPathId,
|
|
4418
4476
|
formData,
|
|
4419
4477
|
edit,
|
|
4420
4478
|
errors,
|
|
@@ -4432,7 +4490,8 @@ var Form = class extends Component5 {
|
|
|
4432
4490
|
* @returns - True if the component should be updated, false otherwise
|
|
4433
4491
|
*/
|
|
4434
4492
|
shouldComponentUpdate(nextProps, nextState) {
|
|
4435
|
-
|
|
4493
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = this.props;
|
|
4494
|
+
return shouldRender2(this, nextProps, nextState, experimental_componentUpdateStrategy);
|
|
4436
4495
|
}
|
|
4437
4496
|
/** Gets the previously raised customValidate errors.
|
|
4438
4497
|
*
|
|
@@ -4444,8 +4503,7 @@ var Form = class extends Component5 {
|
|
|
4444
4503
|
let customValidateErrors = {};
|
|
4445
4504
|
if (typeof customValidate === "function") {
|
|
4446
4505
|
const errorHandler = customValidate(prevFormData, createErrorHandler(prevFormData), uiSchema);
|
|
4447
|
-
|
|
4448
|
-
customValidateErrors = userErrorSchema;
|
|
4506
|
+
customValidateErrors = unwrapErrorHandler(errorHandler);
|
|
4449
4507
|
}
|
|
4450
4508
|
return customValidateErrors;
|
|
4451
4509
|
}
|
|
@@ -4454,9 +4512,10 @@ var Form = class extends Component5 {
|
|
|
4454
4512
|
*
|
|
4455
4513
|
* @param formData - The new form data to validate
|
|
4456
4514
|
* @param schema - The schema used to validate against
|
|
4457
|
-
* @param altSchemaUtils - The alternate schemaUtils to use for validation
|
|
4515
|
+
* @param [altSchemaUtils] - The alternate schemaUtils to use for validation
|
|
4516
|
+
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
4458
4517
|
*/
|
|
4459
|
-
validate(formData, schema = this.
|
|
4518
|
+
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
4460
4519
|
const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
|
|
4461
4520
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4462
4521
|
const resolvedSchema = retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData);
|
|
@@ -4465,18 +4524,16 @@ var Form = class extends Component5 {
|
|
|
4465
4524
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4466
4525
|
renderErrors(registry) {
|
|
4467
4526
|
const { errors, errorSchema, schema, uiSchema } = this.state;
|
|
4468
|
-
const { formContext } = this.props;
|
|
4469
4527
|
const options = getUiOptions17(uiSchema);
|
|
4470
|
-
const ErrorListTemplate =
|
|
4528
|
+
const ErrorListTemplate = getTemplate25("ErrorListTemplate", registry, options);
|
|
4471
4529
|
if (errors && errors.length) {
|
|
4472
|
-
return /* @__PURE__ */
|
|
4530
|
+
return /* @__PURE__ */ jsx53(
|
|
4473
4531
|
ErrorListTemplate,
|
|
4474
4532
|
{
|
|
4475
4533
|
errors,
|
|
4476
4534
|
errorSchema: errorSchema || {},
|
|
4477
4535
|
schema,
|
|
4478
4536
|
uiSchema,
|
|
4479
|
-
formContext,
|
|
4480
4537
|
registry
|
|
4481
4538
|
}
|
|
4482
4539
|
);
|
|
@@ -4504,19 +4561,23 @@ var Form = class extends Component5 {
|
|
|
4504
4561
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4505
4562
|
*/
|
|
4506
4563
|
getFieldNames = (pathSchema, formData) => {
|
|
4564
|
+
const formValueHasData = (value, isLeaf) => typeof value !== "object" || _isEmpty(value) || isLeaf && !_isEmpty(value);
|
|
4507
4565
|
const getAllPaths = (_obj, acc = [], paths = [[]]) => {
|
|
4508
|
-
Object.keys(_obj)
|
|
4509
|
-
|
|
4566
|
+
const objKeys = Object.keys(_obj);
|
|
4567
|
+
objKeys.forEach((key) => {
|
|
4568
|
+
const data = _obj[key];
|
|
4569
|
+
if (typeof data === "object") {
|
|
4510
4570
|
const newPaths = paths.map((path) => [...path, key]);
|
|
4511
|
-
if (
|
|
4512
|
-
acc.push(
|
|
4571
|
+
if (data[RJSF_ADDITIONAL_PROPERTIES_FLAG] && data[NAME_KEY] !== "") {
|
|
4572
|
+
acc.push(data[NAME_KEY]);
|
|
4513
4573
|
} else {
|
|
4514
|
-
getAllPaths(
|
|
4574
|
+
getAllPaths(data, acc, newPaths);
|
|
4515
4575
|
}
|
|
4516
|
-
} else if (key === NAME_KEY &&
|
|
4576
|
+
} else if (key === NAME_KEY && data !== "") {
|
|
4517
4577
|
paths.forEach((path) => {
|
|
4518
4578
|
const formValue = _get(formData, path);
|
|
4519
|
-
|
|
4579
|
+
const isLeaf = objKeys.length === 1;
|
|
4580
|
+
if (formValueHasData(formValue, isLeaf) || Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf))) {
|
|
4520
4581
|
acc.push(path);
|
|
4521
4582
|
}
|
|
4522
4583
|
});
|
|
@@ -4536,10 +4597,15 @@ var Form = class extends Component5 {
|
|
|
4536
4597
|
const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
4537
4598
|
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
|
|
4538
4599
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
4539
|
-
|
|
4540
|
-
return newFormData;
|
|
4600
|
+
return this.getUsedFormData(formData, fieldNames);
|
|
4541
4601
|
};
|
|
4542
|
-
|
|
4602
|
+
/** Filtering errors based on your retrieved schema to only show errors for properties in the selected branch.
|
|
4603
|
+
*
|
|
4604
|
+
* @param schemaErrors - The schema errors to filter
|
|
4605
|
+
* @param [resolvedSchema] - An optionally resolved schema to use for performance reasons
|
|
4606
|
+
* @param [formData] - The formData to help filter errors
|
|
4607
|
+
* @private
|
|
4608
|
+
*/
|
|
4543
4609
|
filterErrorsBasedOnSchema(schemaErrors, resolvedSchema, formData) {
|
|
4544
4610
|
const { retrievedSchema, schemaUtils } = this.state;
|
|
4545
4611
|
const _retrievedSchema = resolvedSchema ?? retrievedSchema;
|
|
@@ -4547,7 +4613,7 @@ var Form = class extends Component5 {
|
|
|
4547
4613
|
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
4548
4614
|
const filteredErrors = _pick(schemaErrors, fieldNames);
|
|
4549
4615
|
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
4550
|
-
filteredErrors
|
|
4616
|
+
filteredErrors[ERRORS_KEY3] = schemaErrors[ERRORS_KEY3];
|
|
4551
4617
|
}
|
|
4552
4618
|
const prevCustomValidateErrors = this.getPreviousCustomValidateErrors();
|
|
4553
4619
|
const filterPreviousCustomErrors = (errors = [], prevCustomErrors) => {
|
|
@@ -4563,9 +4629,14 @@ var Form = class extends Component5 {
|
|
|
4563
4629
|
const prevCustomValidateErrorAtKey = previousCustomValidateErrors[errorKey];
|
|
4564
4630
|
if (_isNil(errorAtKey) || Array.isArray(errorAtKey) && errorAtKey.length === 0) {
|
|
4565
4631
|
delete errors[errorKey];
|
|
4566
|
-
} else if (isObject6(errorAtKey) && isObject6(prevCustomValidateErrorAtKey) && Array.isArray(prevCustomValidateErrorAtKey?.
|
|
4567
|
-
errors[errorKey] =
|
|
4568
|
-
|
|
4632
|
+
} else if (isObject6(errorAtKey) && isObject6(prevCustomValidateErrorAtKey) && Array.isArray(prevCustomValidateErrorAtKey?.[ERRORS_KEY3])) {
|
|
4633
|
+
errors[errorKey] = {
|
|
4634
|
+
[ERRORS_KEY3]: filterPreviousCustomErrors(
|
|
4635
|
+
errorAtKey[ERRORS_KEY3],
|
|
4636
|
+
prevCustomValidateErrorAtKey?.[ERRORS_KEY3]
|
|
4637
|
+
)
|
|
4638
|
+
};
|
|
4639
|
+
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey[ERRORS_KEY3])) {
|
|
4569
4640
|
filterNilOrEmptyErrors(errorAtKey, previousCustomValidateErrors[errorKey]);
|
|
4570
4641
|
}
|
|
4571
4642
|
});
|
|
@@ -4573,23 +4644,46 @@ var Form = class extends Component5 {
|
|
|
4573
4644
|
};
|
|
4574
4645
|
return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
|
|
4575
4646
|
}
|
|
4576
|
-
/**
|
|
4577
|
-
*
|
|
4578
|
-
* then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
|
|
4579
|
-
* in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
|
|
4580
|
-
* updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
|
|
4581
|
-
* callback will be called if specified with the updated state.
|
|
4647
|
+
/** Pushes the given change information into the `pendingChanges` array and then calls `processPendingChanges()` if
|
|
4648
|
+
* the array only contains a single pending change.
|
|
4582
4649
|
*
|
|
4583
|
-
* @param
|
|
4584
|
-
* @param
|
|
4585
|
-
* @param
|
|
4650
|
+
* @param newValue - The new form data from a change to a field
|
|
4651
|
+
* @param path - The path to the change into which to set the formData
|
|
4652
|
+
* @param [newErrorSchema] - The new `ErrorSchema` based on the field change
|
|
4653
|
+
* @param [id] - The id of the field that caused the change
|
|
4654
|
+
*/
|
|
4655
|
+
onChange = (newValue, path, newErrorSchema, id) => {
|
|
4656
|
+
this.pendingChanges.push({ newValue, path, newErrorSchema, id });
|
|
4657
|
+
if (this.pendingChanges.length === 1) {
|
|
4658
|
+
this.processPendingChange();
|
|
4659
|
+
}
|
|
4660
|
+
};
|
|
4661
|
+
/** Function to handle changes made to a field in the `Form`. This handler gets the first change from the
|
|
4662
|
+
* `pendingChanges` list, containing the `newValue` for the `formData` and the `path` at which the `newValue` is to be
|
|
4663
|
+
* updated, along with a new, optional `ErrorSchema` for that same `path` and potentially the `id` of the field being
|
|
4664
|
+
* changed. It will first update the `formData` with any missing default fields and then, if `omitExtraData` and
|
|
4665
|
+
* `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not in a form field. Then, the
|
|
4666
|
+
* resulting `formData` will be validated if required. The state will be updated with the new updated (potentially
|
|
4667
|
+
* filtered) `formData`, any errors that resulted from validation. Finally the `onChange` callback will be called, if
|
|
4668
|
+
* specified, with the updated state and the `processPendingChange()` function is called again.
|
|
4586
4669
|
*/
|
|
4587
|
-
|
|
4670
|
+
processPendingChange() {
|
|
4671
|
+
if (this.pendingChanges.length === 0) {
|
|
4672
|
+
return;
|
|
4673
|
+
}
|
|
4674
|
+
const { newValue, path, id } = this.pendingChanges[0];
|
|
4675
|
+
let { newErrorSchema } = this.pendingChanges[0];
|
|
4588
4676
|
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4589
|
-
const { schemaUtils, schema } = this.state;
|
|
4677
|
+
const { formData: oldFormData, schemaUtils, schema, errorSchema, fieldPathId } = this.state;
|
|
4678
|
+
const rootPathId = fieldPathId.path[0] || "";
|
|
4679
|
+
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4590
4680
|
let retrievedSchema = this.state.retrievedSchema;
|
|
4681
|
+
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
4591
4682
|
if (isObject6(formData) || Array.isArray(formData)) {
|
|
4592
|
-
|
|
4683
|
+
if (!isRootPath) {
|
|
4684
|
+
_set(formData, path, newValue);
|
|
4685
|
+
}
|
|
4686
|
+
const newState = this.getStateFromProps(this.props, formData, void 0, void 0, void 0, true);
|
|
4593
4687
|
formData = newState.formData;
|
|
4594
4688
|
retrievedSchema = newState.retrievedSchema;
|
|
4595
4689
|
}
|
|
@@ -4602,38 +4696,49 @@ var Form = class extends Component5 {
|
|
|
4602
4696
|
formData: newFormData
|
|
4603
4697
|
};
|
|
4604
4698
|
}
|
|
4605
|
-
if (
|
|
4699
|
+
if (newErrorSchema && !isRootPath) {
|
|
4700
|
+
const errorSchemaCopy = _cloneDeep(errorSchema);
|
|
4701
|
+
_set(errorSchemaCopy, path, newErrorSchema);
|
|
4702
|
+
newErrorSchema = errorSchemaCopy;
|
|
4703
|
+
}
|
|
4704
|
+
if (mustValidate && this.pendingChanges.length === 1) {
|
|
4606
4705
|
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
4607
4706
|
let errors = schemaValidation.errors;
|
|
4608
|
-
let
|
|
4707
|
+
let errorSchema2 = schemaValidation.errorSchema;
|
|
4609
4708
|
const schemaValidationErrors = errors;
|
|
4610
|
-
const schemaValidationErrorSchema =
|
|
4709
|
+
const schemaValidationErrorSchema = errorSchema2;
|
|
4611
4710
|
if (extraErrors) {
|
|
4612
4711
|
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
4613
|
-
|
|
4712
|
+
errorSchema2 = merged.errorSchema;
|
|
4614
4713
|
errors = merged.errors;
|
|
4615
4714
|
}
|
|
4616
4715
|
if (newErrorSchema) {
|
|
4617
4716
|
const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
|
|
4618
|
-
|
|
4717
|
+
errorSchema2 = mergeObjects(errorSchema2, filteredErrors, "preventDuplicates");
|
|
4619
4718
|
}
|
|
4620
4719
|
state = {
|
|
4621
4720
|
formData: newFormData,
|
|
4622
4721
|
errors,
|
|
4623
|
-
errorSchema,
|
|
4722
|
+
errorSchema: errorSchema2,
|
|
4624
4723
|
schemaValidationErrors,
|
|
4625
4724
|
schemaValidationErrorSchema
|
|
4626
4725
|
};
|
|
4627
4726
|
} else if (!noValidate && newErrorSchema) {
|
|
4628
|
-
const
|
|
4727
|
+
const errorSchema2 = extraErrors ? mergeObjects(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
|
|
4629
4728
|
state = {
|
|
4630
4729
|
formData: newFormData,
|
|
4631
|
-
errorSchema,
|
|
4632
|
-
errors: toErrorList(
|
|
4730
|
+
errorSchema: errorSchema2,
|
|
4731
|
+
errors: toErrorList(errorSchema2)
|
|
4633
4732
|
};
|
|
4634
4733
|
}
|
|
4635
|
-
this.setState(state, () =>
|
|
4636
|
-
|
|
4734
|
+
this.setState(state, () => {
|
|
4735
|
+
if (onChange) {
|
|
4736
|
+
onChange({ ...this.state, ...state }, id);
|
|
4737
|
+
}
|
|
4738
|
+
this.pendingChanges.shift();
|
|
4739
|
+
this.processPendingChange();
|
|
4740
|
+
});
|
|
4741
|
+
}
|
|
4637
4742
|
/**
|
|
4638
4743
|
* If the retrievedSchema has changed the new retrievedSchema is returned.
|
|
4639
4744
|
* Otherwise, the old retrievedSchema is returned to persist reference.
|
|
@@ -4644,7 +4749,7 @@ var Form = class extends Component5 {
|
|
|
4644
4749
|
* @returns The new retrieved schema if it has changed, else the old retrieved schema.
|
|
4645
4750
|
*/
|
|
4646
4751
|
updateRetrievedSchema(retrievedSchema) {
|
|
4647
|
-
const isTheSame =
|
|
4752
|
+
const isTheSame = deepEquals2(retrievedSchema, this.state?.retrievedSchema);
|
|
4648
4753
|
return isTheSame ? this.state.retrievedSchema : retrievedSchema;
|
|
4649
4754
|
}
|
|
4650
4755
|
/**
|
|
@@ -4728,10 +4833,26 @@ var Form = class extends Component5 {
|
|
|
4728
4833
|
);
|
|
4729
4834
|
}
|
|
4730
4835
|
};
|
|
4836
|
+
/** Extracts the `GlobalFormOptions` from the given Form `props`
|
|
4837
|
+
*
|
|
4838
|
+
* @param props - The form props to extract the global form options from
|
|
4839
|
+
* @returns - The `GlobalFormOptions` from the props
|
|
4840
|
+
* @private
|
|
4841
|
+
*/
|
|
4842
|
+
getGlobalFormOptions(props) {
|
|
4843
|
+
const {
|
|
4844
|
+
uiSchema = {},
|
|
4845
|
+
experimental_componentUpdateStrategy,
|
|
4846
|
+
idSeparator = DEFAULT_ID_SEPARATOR2,
|
|
4847
|
+
idPrefix = DEFAULT_ID_PREFIX2
|
|
4848
|
+
} = props;
|
|
4849
|
+
const rootFieldId = uiSchema["ui:rootFieldId"];
|
|
4850
|
+
return { idPrefix: rootFieldId || idPrefix, idSeparator, experimental_componentUpdateStrategy };
|
|
4851
|
+
}
|
|
4731
4852
|
/** Returns the registry for the form */
|
|
4732
4853
|
getRegistry() {
|
|
4733
4854
|
const { translateString: customTranslateString, uiSchema = {} } = this.props;
|
|
4734
|
-
const { schemaUtils } = this.state;
|
|
4855
|
+
const { schema, schemaUtils } = this.state;
|
|
4735
4856
|
const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
|
|
4736
4857
|
return {
|
|
4737
4858
|
fields: { ...fields2, ...this.props.fields },
|
|
@@ -4744,11 +4865,12 @@ var Form = class extends Component5 {
|
|
|
4744
4865
|
}
|
|
4745
4866
|
},
|
|
4746
4867
|
widgets: { ...widgets2, ...this.props.widgets },
|
|
4747
|
-
rootSchema:
|
|
4868
|
+
rootSchema: schema,
|
|
4748
4869
|
formContext: this.props.formContext || formContext,
|
|
4749
4870
|
schemaUtils,
|
|
4750
4871
|
translateString: customTranslateString || translateString,
|
|
4751
|
-
globalUiOptions: uiSchema[
|
|
4872
|
+
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY2],
|
|
4873
|
+
globalFormOptions: this.getGlobalFormOptions(this.props)
|
|
4752
4874
|
};
|
|
4753
4875
|
}
|
|
4754
4876
|
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
@@ -4863,8 +4985,6 @@ var Form = class extends Component5 {
|
|
|
4863
4985
|
const {
|
|
4864
4986
|
children,
|
|
4865
4987
|
id,
|
|
4866
|
-
idPrefix,
|
|
4867
|
-
idSeparator,
|
|
4868
4988
|
className = "",
|
|
4869
4989
|
tagName,
|
|
4870
4990
|
name,
|
|
@@ -4877,11 +4997,10 @@ var Form = class extends Component5 {
|
|
|
4877
4997
|
noHtml5Validate = false,
|
|
4878
4998
|
disabled,
|
|
4879
4999
|
readonly,
|
|
4880
|
-
formContext,
|
|
4881
5000
|
showErrorList = "top",
|
|
4882
5001
|
_internalFormWrapper
|
|
4883
5002
|
} = this.props;
|
|
4884
|
-
const { schema, uiSchema, formData, errorSchema,
|
|
5003
|
+
const { schema, uiSchema, formData, errorSchema, fieldPathId } = this.state;
|
|
4885
5004
|
const registry = this.getRegistry();
|
|
4886
5005
|
const { SchemaField: _SchemaField } = registry.fields;
|
|
4887
5006
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
@@ -4910,17 +5029,14 @@ var Form = class extends Component5 {
|
|
|
4910
5029
|
ref: this.formElement,
|
|
4911
5030
|
children: [
|
|
4912
5031
|
showErrorList === "top" && this.renderErrors(registry),
|
|
4913
|
-
/* @__PURE__ */
|
|
5032
|
+
/* @__PURE__ */ jsx53(
|
|
4914
5033
|
_SchemaField,
|
|
4915
5034
|
{
|
|
4916
5035
|
name: "",
|
|
4917
5036
|
schema,
|
|
4918
5037
|
uiSchema,
|
|
4919
5038
|
errorSchema,
|
|
4920
|
-
|
|
4921
|
-
idPrefix,
|
|
4922
|
-
idSeparator,
|
|
4923
|
-
formContext,
|
|
5039
|
+
fieldPathId,
|
|
4924
5040
|
formData,
|
|
4925
5041
|
onChange: this.onChange,
|
|
4926
5042
|
onBlur: this.onBlur,
|
|
@@ -4930,7 +5046,7 @@ var Form = class extends Component5 {
|
|
|
4930
5046
|
readonly
|
|
4931
5047
|
}
|
|
4932
5048
|
),
|
|
4933
|
-
children ? children : /* @__PURE__ */
|
|
5049
|
+
children ? children : /* @__PURE__ */ jsx53(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
4934
5050
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
4935
5051
|
]
|
|
4936
5052
|
}
|
|
@@ -4940,7 +5056,7 @@ var Form = class extends Component5 {
|
|
|
4940
5056
|
|
|
4941
5057
|
// src/withTheme.tsx
|
|
4942
5058
|
import { forwardRef } from "react";
|
|
4943
|
-
import { jsx as
|
|
5059
|
+
import { jsx as jsx54 } from "react/jsx-runtime";
|
|
4944
5060
|
function withTheme(themeProps) {
|
|
4945
5061
|
return forwardRef(
|
|
4946
5062
|
({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
|
|
@@ -4954,7 +5070,7 @@ function withTheme(themeProps) {
|
|
|
4954
5070
|
...templates2?.ButtonTemplates
|
|
4955
5071
|
}
|
|
4956
5072
|
};
|
|
4957
|
-
return /* @__PURE__ */
|
|
5073
|
+
return /* @__PURE__ */ jsx54(
|
|
4958
5074
|
Form,
|
|
4959
5075
|
{
|
|
4960
5076
|
...themeProps,
|
|
@@ -4969,12 +5085,36 @@ function withTheme(themeProps) {
|
|
|
4969
5085
|
);
|
|
4970
5086
|
}
|
|
4971
5087
|
|
|
5088
|
+
// src/getTestRegistry.tsx
|
|
5089
|
+
import {
|
|
5090
|
+
DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX3,
|
|
5091
|
+
DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR3,
|
|
5092
|
+
createSchemaUtils as createSchemaUtils2,
|
|
5093
|
+
englishStringTranslator as englishStringTranslator2
|
|
5094
|
+
} from "@rjsf/utils";
|
|
5095
|
+
import validator from "@rjsf/validator-ajv8";
|
|
5096
|
+
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = { idPrefix: DEFAULT_ID_PREFIX3, idSeparator: DEFAULT_ID_SEPARATOR3 }) {
|
|
5097
|
+
const defaults = getDefaultRegistry();
|
|
5098
|
+
const schemaUtils = createSchemaUtils2(validator, rootSchema);
|
|
5099
|
+
return {
|
|
5100
|
+
fields: { ...defaults.fields, ...fields2 },
|
|
5101
|
+
templates: { ...defaults.templates, ...templates2 },
|
|
5102
|
+
widgets: { ...defaults.widgets, ...widgets2 },
|
|
5103
|
+
formContext,
|
|
5104
|
+
rootSchema,
|
|
5105
|
+
schemaUtils,
|
|
5106
|
+
translateString: englishStringTranslator2,
|
|
5107
|
+
globalFormOptions
|
|
5108
|
+
};
|
|
5109
|
+
}
|
|
5110
|
+
|
|
4972
5111
|
// src/index.ts
|
|
4973
5112
|
var index_default = Form;
|
|
4974
5113
|
export {
|
|
4975
5114
|
RichDescription,
|
|
4976
5115
|
index_default as default,
|
|
4977
5116
|
getDefaultRegistry,
|
|
5117
|
+
getTestRegistry,
|
|
4978
5118
|
withTheme
|
|
4979
5119
|
};
|
|
4980
5120
|
//# sourceMappingURL=index.esm.js.map
|