@rjsf/mui 6.0.0-beta.9 → 6.0.1
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/README.md +2 -2
- package/dist/{index.js → index.cjs} +165 -91
- package/dist/index.cjs.map +7 -0
- package/dist/mui.esm.js +164 -90
- package/dist/mui.esm.js.map +4 -4
- package/dist/mui.umd.js +107 -43
- package/lib/AddButton/AddButton.js +1 -1
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +3 -3
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +4 -4
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +7 -8
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +3 -3
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/CheckboxWidget/CheckboxWidget.js +6 -6
- package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
- package/lib/CheckboxesWidget/CheckboxesWidget.js +6 -6
- package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/DescriptionField/DescriptionField.js +1 -1
- package/lib/ErrorList/ErrorList.js +7 -7
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js +5 -5
- package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +3 -3
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.js +4 -4
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/GridTemplate/GridTemplate.js +1 -1
- package/lib/IconButton/IconButton.js +1 -1
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -0
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +8 -0
- package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -0
- package/lib/MultiSchemaFieldTemplate/index.d.ts +2 -0
- package/lib/MultiSchemaFieldTemplate/index.js +3 -0
- package/lib/MultiSchemaFieldTemplate/index.js.map +1 -0
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +5 -4
- package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +10 -0
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +22 -0
- package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -0
- package/lib/OptionalDataControlsTemplate/index.d.ts +2 -0
- package/lib/OptionalDataControlsTemplate/index.js +3 -0
- package/lib/OptionalDataControlsTemplate/index.js.map +1 -0
- package/lib/RadioWidget/RadioWidget.d.ts +1 -1
- package/lib/RadioWidget/RadioWidget.js +7 -7
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/RangeWidget/RangeWidget.js +2 -2
- package/lib/RangeWidget/RangeWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.d.ts +1 -1
- package/lib/SelectWidget/SelectWidget.js +4 -4
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/SubmitButton/SubmitButton.js +2 -2
- package/lib/Templates/Templates.js +4 -0
- package/lib/Templates/Templates.js.map +1 -1
- package/lib/TitleField/TitleField.d.ts +1 -1
- package/lib/TitleField/TitleField.js +10 -5
- package/lib/TitleField/TitleField.js.map +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +4 -5
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -23
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -3
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +22 -16
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +5 -5
- package/src/CheckboxWidget/CheckboxWidget.tsx +6 -6
- package/src/CheckboxesWidget/CheckboxesWidget.tsx +3 -2
- package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +2 -2
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -2
- package/src/FieldTemplate/FieldTemplate.tsx +6 -4
- package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +20 -0
- package/src/MultiSchemaFieldTemplate/index.ts +2 -0
- package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +10 -6
- package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +43 -0
- package/src/OptionalDataControlsTemplate/index.ts +2 -0
- package/src/RadioWidget/RadioWidget.tsx +4 -3
- package/src/RangeWidget/RangeWidget.tsx +1 -1
- package/src/SelectWidget/SelectWidget.tsx +3 -3
- package/src/Templates/Templates.ts +4 -0
- package/src/TitleField/TitleField.tsx +12 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +6 -8
- package/dist/index.js.map +0 -7
package/dist/mui.umd.js
CHANGED
|
@@ -34,23 +34,32 @@
|
|
|
34
34
|
] });
|
|
35
35
|
}
|
|
36
36
|
function ArrayFieldTemplate(props) {
|
|
37
|
-
const {
|
|
37
|
+
const {
|
|
38
|
+
canAdd,
|
|
39
|
+
disabled,
|
|
40
|
+
fieldPathId,
|
|
41
|
+
uiSchema,
|
|
42
|
+
items,
|
|
43
|
+
optionalDataControl,
|
|
44
|
+
onAddClick,
|
|
45
|
+
readonly,
|
|
46
|
+
registry,
|
|
47
|
+
required,
|
|
48
|
+
schema,
|
|
49
|
+
title
|
|
50
|
+
} = props;
|
|
38
51
|
const uiOptions = utils.getUiOptions(uiSchema);
|
|
39
52
|
const ArrayFieldDescriptionTemplate = utils.getTemplate(
|
|
40
53
|
"ArrayFieldDescriptionTemplate",
|
|
41
54
|
registry,
|
|
42
55
|
uiOptions
|
|
43
56
|
);
|
|
44
|
-
const ArrayFieldItemTemplate2 = utils.getTemplate(
|
|
45
|
-
"ArrayFieldItemTemplate",
|
|
46
|
-
registry,
|
|
47
|
-
uiOptions
|
|
48
|
-
);
|
|
49
57
|
const ArrayFieldTitleTemplate = utils.getTemplate(
|
|
50
58
|
"ArrayFieldTitleTemplate",
|
|
51
59
|
registry,
|
|
52
60
|
uiOptions
|
|
53
61
|
);
|
|
62
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
54
63
|
const {
|
|
55
64
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
56
65
|
} = registry.templates;
|
|
@@ -58,29 +67,31 @@
|
|
|
58
67
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
59
68
|
ArrayFieldTitleTemplate,
|
|
60
69
|
{
|
|
61
|
-
|
|
70
|
+
fieldPathId,
|
|
62
71
|
title: uiOptions.title || title,
|
|
63
72
|
schema,
|
|
64
73
|
uiSchema,
|
|
65
74
|
required,
|
|
66
|
-
registry
|
|
75
|
+
registry,
|
|
76
|
+
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
67
77
|
}
|
|
68
78
|
),
|
|
69
79
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
70
80
|
ArrayFieldDescriptionTemplate,
|
|
71
81
|
{
|
|
72
|
-
|
|
82
|
+
fieldPathId,
|
|
73
83
|
description: uiOptions.description || schema.description,
|
|
74
84
|
schema,
|
|
75
85
|
uiSchema,
|
|
76
86
|
registry
|
|
77
87
|
}
|
|
78
88
|
),
|
|
79
|
-
|
|
89
|
+
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
90
|
+
items,
|
|
80
91
|
canAdd && /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: true, justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(Grid4, { children: /* @__PURE__ */ jsxRuntime.jsx(Box, { mt: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
92
|
AddButton2,
|
|
82
93
|
{
|
|
83
|
-
id: utils.buttonId(
|
|
94
|
+
id: utils.buttonId(fieldPathId, "add"),
|
|
84
95
|
className: "rjsf-array-item-add",
|
|
85
96
|
onClick: onAddClick,
|
|
86
97
|
disabled: disabled || readonly,
|
|
@@ -96,6 +107,7 @@
|
|
|
96
107
|
id,
|
|
97
108
|
name,
|
|
98
109
|
// remove this from textFieldProps
|
|
110
|
+
htmlName,
|
|
99
111
|
placeholder,
|
|
100
112
|
required,
|
|
101
113
|
readonly,
|
|
@@ -115,7 +127,6 @@
|
|
|
115
127
|
uiSchema,
|
|
116
128
|
rawErrors = [],
|
|
117
129
|
errorSchema,
|
|
118
|
-
formContext,
|
|
119
130
|
registry,
|
|
120
131
|
InputLabelProps,
|
|
121
132
|
...textFieldProps
|
|
@@ -135,7 +146,7 @@
|
|
|
135
146
|
TextField,
|
|
136
147
|
{
|
|
137
148
|
id,
|
|
138
|
-
name: id,
|
|
149
|
+
name: htmlName || id,
|
|
139
150
|
placeholder,
|
|
140
151
|
label: utils.labelValue(label || void 0, hideLabel, void 0),
|
|
141
152
|
autoFocus: autofocus,
|
|
@@ -238,21 +249,21 @@
|
|
|
238
249
|
);
|
|
239
250
|
}
|
|
240
251
|
function FieldErrorTemplate(props) {
|
|
241
|
-
const { errors = [],
|
|
252
|
+
const { errors = [], fieldPathId } = props;
|
|
242
253
|
if (errors.length === 0) {
|
|
243
254
|
return null;
|
|
244
255
|
}
|
|
245
|
-
const id = utils.errorId(
|
|
256
|
+
const id = utils.errorId(fieldPathId);
|
|
246
257
|
return /* @__PURE__ */ jsxRuntime.jsx(List, { id, dense: true, disablePadding: true, children: errors.map((error, i) => {
|
|
247
258
|
return /* @__PURE__ */ jsxRuntime.jsx(ListItem, { disableGutters: true, children: /* @__PURE__ */ jsxRuntime.jsx(FormHelperText, { component: "div", id: `${id}-${i}`, children: error }) }, i);
|
|
248
259
|
}) });
|
|
249
260
|
}
|
|
250
261
|
function FieldHelpTemplate(props) {
|
|
251
|
-
const {
|
|
262
|
+
const { fieldPathId, help } = props;
|
|
252
263
|
if (!help) {
|
|
253
264
|
return null;
|
|
254
265
|
}
|
|
255
|
-
const id = utils.helpId(
|
|
266
|
+
const id = utils.helpId(fieldPathId);
|
|
256
267
|
return /* @__PURE__ */ jsxRuntime.jsx(FormHelperText, { component: "div", id, children: help });
|
|
257
268
|
}
|
|
258
269
|
function FieldTemplate(props) {
|
|
@@ -265,8 +276,9 @@
|
|
|
265
276
|
displayLabel,
|
|
266
277
|
hidden,
|
|
267
278
|
label,
|
|
268
|
-
|
|
269
|
-
|
|
279
|
+
onKeyRename,
|
|
280
|
+
onKeyRenameBlur,
|
|
281
|
+
onRemoveProperty,
|
|
270
282
|
readonly,
|
|
271
283
|
required,
|
|
272
284
|
rawErrors = [],
|
|
@@ -295,8 +307,9 @@
|
|
|
295
307
|
disabled,
|
|
296
308
|
id,
|
|
297
309
|
label,
|
|
298
|
-
|
|
299
|
-
|
|
310
|
+
onKeyRename,
|
|
311
|
+
onKeyRenameBlur,
|
|
312
|
+
onRemoveProperty,
|
|
300
313
|
readonly,
|
|
301
314
|
required,
|
|
302
315
|
schema,
|
|
@@ -315,6 +328,13 @@
|
|
|
315
328
|
const { children, column, ...rest } = props;
|
|
316
329
|
return /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: !column, ...rest, children });
|
|
317
330
|
}
|
|
331
|
+
function MultiSchemaFieldTemplate(props) {
|
|
332
|
+
const { optionSchemaField, selector } = props;
|
|
333
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { mb: 2 }, children: [
|
|
334
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { fullWidth: true, sx: { mb: 2 }, children: selector }),
|
|
335
|
+
optionSchemaField
|
|
336
|
+
] });
|
|
337
|
+
}
|
|
318
338
|
function ObjectFieldTemplate(props) {
|
|
319
339
|
const {
|
|
320
340
|
description,
|
|
@@ -324,10 +344,11 @@
|
|
|
324
344
|
disabled,
|
|
325
345
|
readonly,
|
|
326
346
|
uiSchema,
|
|
327
|
-
|
|
347
|
+
fieldPathId,
|
|
328
348
|
schema,
|
|
329
349
|
formData,
|
|
330
|
-
|
|
350
|
+
optionalDataControl,
|
|
351
|
+
onAddProperty,
|
|
331
352
|
registry
|
|
332
353
|
} = props;
|
|
333
354
|
const uiOptions = utils.getUiOptions(uiSchema);
|
|
@@ -337,6 +358,7 @@
|
|
|
337
358
|
registry,
|
|
338
359
|
uiOptions
|
|
339
360
|
);
|
|
361
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
340
362
|
const {
|
|
341
363
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
342
364
|
} = registry.templates;
|
|
@@ -344,18 +366,19 @@
|
|
|
344
366
|
title && /* @__PURE__ */ jsxRuntime.jsx(
|
|
345
367
|
TitleFieldTemplate,
|
|
346
368
|
{
|
|
347
|
-
id: utils.titleId(
|
|
369
|
+
id: utils.titleId(fieldPathId),
|
|
348
370
|
title,
|
|
349
371
|
required,
|
|
350
372
|
schema,
|
|
351
373
|
uiSchema,
|
|
352
|
-
registry
|
|
374
|
+
registry,
|
|
375
|
+
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
353
376
|
}
|
|
354
377
|
),
|
|
355
378
|
description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
356
379
|
DescriptionFieldTemplate,
|
|
357
380
|
{
|
|
358
|
-
id: utils.descriptionId(
|
|
381
|
+
id: utils.descriptionId(fieldPathId),
|
|
359
382
|
description,
|
|
360
383
|
schema,
|
|
361
384
|
uiSchema,
|
|
@@ -363,6 +386,7 @@
|
|
|
363
386
|
}
|
|
364
387
|
),
|
|
365
388
|
/* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, spacing: 2, style: { marginTop: "10px" }, children: [
|
|
389
|
+
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
366
390
|
properties.map(
|
|
367
391
|
(element, index) => (
|
|
368
392
|
// Remove the <Grid> if the inner element is hidden as the <Grid>
|
|
@@ -373,9 +397,9 @@
|
|
|
373
397
|
utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(Grid4, { container: true, justifyContent: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(Grid4, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
374
398
|
AddButton2,
|
|
375
399
|
{
|
|
376
|
-
id: utils.buttonId(
|
|
400
|
+
id: utils.buttonId(fieldPathId, "add"),
|
|
377
401
|
className: "rjsf-object-property-expand",
|
|
378
|
-
onClick:
|
|
402
|
+
onClick: onAddProperty,
|
|
379
403
|
disabled: disabled || readonly,
|
|
380
404
|
uiSchema,
|
|
381
405
|
registry
|
|
@@ -384,6 +408,34 @@
|
|
|
384
408
|
] })
|
|
385
409
|
] });
|
|
386
410
|
}
|
|
411
|
+
function OptionalDataControlsTemplate(props) {
|
|
412
|
+
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
413
|
+
if (onAddClick) {
|
|
414
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
415
|
+
MuiIconButton,
|
|
416
|
+
{
|
|
417
|
+
id,
|
|
418
|
+
registry,
|
|
419
|
+
className: "rjsf-add-optional-data",
|
|
420
|
+
onClick: onAddClick,
|
|
421
|
+
title: label,
|
|
422
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(AddIcon, { fontSize: "small" })
|
|
423
|
+
}
|
|
424
|
+
);
|
|
425
|
+
} else if (onRemoveClick) {
|
|
426
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
427
|
+
RemoveButton,
|
|
428
|
+
{
|
|
429
|
+
id,
|
|
430
|
+
registry,
|
|
431
|
+
className: "rjsf-remove-optional-data",
|
|
432
|
+
onClick: onRemoveClick,
|
|
433
|
+
title: label
|
|
434
|
+
}
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
return /* @__PURE__ */ jsxRuntime.jsx("em", { id, children: label });
|
|
438
|
+
}
|
|
387
439
|
function SubmitButton({ uiSchema }) {
|
|
388
440
|
const { submitText, norender, props: submitButtonProps = {} } = utils.getSubmitButtonOptions(uiSchema);
|
|
389
441
|
if (norender) {
|
|
@@ -393,10 +445,18 @@
|
|
|
393
445
|
}
|
|
394
446
|
function TitleField({
|
|
395
447
|
id,
|
|
396
|
-
title
|
|
448
|
+
title,
|
|
449
|
+
optionalDataControl
|
|
397
450
|
}) {
|
|
451
|
+
let heading = /* @__PURE__ */ jsxRuntime.jsx(Typography, { variant: "h5", children: title });
|
|
452
|
+
if (optionalDataControl) {
|
|
453
|
+
heading = /* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, spacing: 0, children: [
|
|
454
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: "grow", children: heading }),
|
|
455
|
+
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { justifyContent: "flex-end", children: optionalDataControl })
|
|
456
|
+
] });
|
|
457
|
+
}
|
|
398
458
|
return /* @__PURE__ */ jsxRuntime.jsxs(Box, { id, mb: 1, mt: 1, children: [
|
|
399
|
-
|
|
459
|
+
heading,
|
|
400
460
|
/* @__PURE__ */ jsxRuntime.jsx(Divider, {})
|
|
401
461
|
] });
|
|
402
462
|
}
|
|
@@ -408,8 +468,8 @@
|
|
|
408
468
|
disabled,
|
|
409
469
|
id,
|
|
410
470
|
label,
|
|
411
|
-
|
|
412
|
-
|
|
471
|
+
onKeyRenameBlur,
|
|
472
|
+
onRemoveProperty,
|
|
413
473
|
readonly,
|
|
414
474
|
required,
|
|
415
475
|
schema,
|
|
@@ -429,7 +489,6 @@
|
|
|
429
489
|
if (!additional) {
|
|
430
490
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children });
|
|
431
491
|
}
|
|
432
|
-
const handleBlur = ({ target }) => onKeyChange(target && target.value);
|
|
433
492
|
return /* @__PURE__ */ jsxRuntime.jsxs(Grid4, { container: true, alignItems: "center", spacing: 2, className: classNames, style, children: [
|
|
434
493
|
/* @__PURE__ */ jsxRuntime.jsx(Grid4, { size: "auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
435
494
|
TextField,
|
|
@@ -441,7 +500,7 @@
|
|
|
441
500
|
disabled: disabled || readonly,
|
|
442
501
|
id: `${id}-key`,
|
|
443
502
|
name: `${id}-key`,
|
|
444
|
-
onBlur: !readonly ?
|
|
503
|
+
onBlur: !readonly ? onKeyRenameBlur : void 0,
|
|
445
504
|
type: "text"
|
|
446
505
|
}
|
|
447
506
|
) }),
|
|
@@ -454,7 +513,7 @@
|
|
|
454
513
|
iconType: "default",
|
|
455
514
|
style: btnStyle,
|
|
456
515
|
disabled: disabled || readonly,
|
|
457
|
-
onClick:
|
|
516
|
+
onClick: onRemoveProperty,
|
|
458
517
|
uiSchema,
|
|
459
518
|
registry
|
|
460
519
|
}
|
|
@@ -482,7 +541,9 @@
|
|
|
482
541
|
FieldHelpTemplate,
|
|
483
542
|
FieldTemplate,
|
|
484
543
|
GridTemplate,
|
|
544
|
+
MultiSchemaFieldTemplate,
|
|
485
545
|
ObjectFieldTemplate,
|
|
546
|
+
OptionalDataControlsTemplate,
|
|
486
547
|
TitleFieldTemplate: TitleField,
|
|
487
548
|
WrapIfAdditionalTemplate
|
|
488
549
|
};
|
|
@@ -492,6 +553,7 @@
|
|
|
492
553
|
const {
|
|
493
554
|
schema,
|
|
494
555
|
id,
|
|
556
|
+
htmlName,
|
|
495
557
|
value,
|
|
496
558
|
disabled,
|
|
497
559
|
readonly,
|
|
@@ -512,8 +574,8 @@
|
|
|
512
574
|
);
|
|
513
575
|
const required = utils.schemaRequiresTrueValue(schema);
|
|
514
576
|
const _onChange = (_, checked) => onChange(checked);
|
|
515
|
-
const _onBlur = (
|
|
516
|
-
const _onFocus = (
|
|
577
|
+
const _onBlur = () => onBlur(id, value);
|
|
578
|
+
const _onFocus = () => onFocus(id, value);
|
|
517
579
|
const description = options.description ?? schema.description;
|
|
518
580
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
519
581
|
!hideLabel && description && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -533,7 +595,7 @@
|
|
|
533
595
|
Checkbox,
|
|
534
596
|
{
|
|
535
597
|
id,
|
|
536
|
-
name: id,
|
|
598
|
+
name: htmlName || id,
|
|
537
599
|
checked: typeof value === "undefined" ? false : Boolean(value),
|
|
538
600
|
required,
|
|
539
601
|
disabled: disabled || readonly,
|
|
@@ -553,6 +615,7 @@
|
|
|
553
615
|
label,
|
|
554
616
|
hideLabel,
|
|
555
617
|
id,
|
|
618
|
+
htmlName,
|
|
556
619
|
disabled,
|
|
557
620
|
options,
|
|
558
621
|
value,
|
|
@@ -586,7 +649,7 @@
|
|
|
586
649
|
Checkbox,
|
|
587
650
|
{
|
|
588
651
|
id: utils.optionId(id, index),
|
|
589
|
-
name: id,
|
|
652
|
+
name: htmlName || id,
|
|
590
653
|
checked,
|
|
591
654
|
disabled: disabled || itemDisabled || readonly,
|
|
592
655
|
autoFocus: autofocus && index === 0,
|
|
@@ -602,6 +665,7 @@
|
|
|
602
665
|
}
|
|
603
666
|
function RadioWidget({
|
|
604
667
|
id,
|
|
668
|
+
htmlName,
|
|
605
669
|
options,
|
|
606
670
|
value,
|
|
607
671
|
required,
|
|
@@ -628,7 +692,7 @@
|
|
|
628
692
|
RadioGroup,
|
|
629
693
|
{
|
|
630
694
|
id,
|
|
631
|
-
name: id,
|
|
695
|
+
name: htmlName || id,
|
|
632
696
|
value: selectedIndex,
|
|
633
697
|
row,
|
|
634
698
|
onChange: _onChange,
|
|
@@ -640,7 +704,7 @@
|
|
|
640
704
|
const radio = /* @__PURE__ */ jsxRuntime.jsx(
|
|
641
705
|
FormControlLabel,
|
|
642
706
|
{
|
|
643
|
-
control: /* @__PURE__ */ jsxRuntime.jsx(Radio, { name: id, id: utils.optionId(id, index), color: "primary" }),
|
|
707
|
+
control: /* @__PURE__ */ jsxRuntime.jsx(Radio, { name: htmlName || id, id: utils.optionId(id, index), color: "primary" }),
|
|
644
708
|
label: option.label,
|
|
645
709
|
value: String(index),
|
|
646
710
|
disabled: disabled || itemDisabled || readonly
|
|
@@ -685,6 +749,7 @@
|
|
|
685
749
|
id,
|
|
686
750
|
name,
|
|
687
751
|
// remove this from textFieldProps
|
|
752
|
+
htmlName,
|
|
688
753
|
options,
|
|
689
754
|
label,
|
|
690
755
|
hideLabel,
|
|
@@ -703,7 +768,6 @@
|
|
|
703
768
|
registry,
|
|
704
769
|
uiSchema,
|
|
705
770
|
hideError,
|
|
706
|
-
formContext,
|
|
707
771
|
...textFieldProps
|
|
708
772
|
}) {
|
|
709
773
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
@@ -720,7 +784,7 @@
|
|
|
720
784
|
TextField,
|
|
721
785
|
{
|
|
722
786
|
id,
|
|
723
|
-
name: id,
|
|
787
|
+
name: htmlName || id,
|
|
724
788
|
label: utils.labelValue(label || void 0, hideLabel, void 0),
|
|
725
789
|
value: !isEmpty && typeof selectedIndexes !== "undefined" ? selectedIndexes : emptyValue,
|
|
726
790
|
required,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import AddIcon from '@mui/icons-material/Add';
|
|
3
|
-
import IconButton from '@mui/material/IconButton
|
|
3
|
+
import IconButton from '@mui/material/IconButton';
|
|
4
4
|
import { TranslatableString } from '@rjsf/utils';
|
|
5
5
|
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArrayFieldItemTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
3
3
|
*
|
|
4
|
-
* @param props - The `
|
|
4
|
+
* @param props - The `ArrayFieldItemTemplateProps` props for the component
|
|
5
5
|
*/
|
|
6
|
-
export default function ArrayFieldItemTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props:
|
|
6
|
+
export default function ArrayFieldItemTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldItemTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Box from '@mui/material/Box
|
|
3
|
-
import Grid from '@mui/material/Grid
|
|
4
|
-
import Paper from '@mui/material/Paper
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import Grid from '@mui/material/Grid';
|
|
4
|
+
import Paper from '@mui/material/Paper';
|
|
5
5
|
import { getUiOptions, getTemplate, } from '@rjsf/utils';
|
|
6
6
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
7
7
|
*
|
|
8
|
-
* @param props - The `
|
|
8
|
+
* @param props - The `ArrayFieldItemTemplateProps` props for the component
|
|
9
9
|
*/
|
|
10
10
|
export default function ArrayFieldItemTemplate(props) {
|
|
11
11
|
const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayFieldItemTemplate.js","sourceRoot":"","sources":["../../src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx"],"names":[],"mappings":";AACA,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAGL,YAAY,EACZ,WAAW,GAGZ,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAI5C,
|
|
1
|
+
{"version":3,"file":"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1
1
|
import { ArrayFieldTemplateProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
3
3
|
*
|
|
4
|
-
* @param props - The `
|
|
4
|
+
* @param props - The `ArrayFieldTemplateProps` props for the component
|
|
5
5
|
*/
|
|
6
6
|
export default function ArrayFieldTemplate<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(props: ArrayFieldTemplateProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Box from '@mui/material/Box
|
|
3
|
-
import Grid from '@mui/material/Grid
|
|
4
|
-
import Paper from '@mui/material/Paper
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import Grid from '@mui/material/Grid';
|
|
4
|
+
import Paper from '@mui/material/Paper';
|
|
5
5
|
import { getTemplate, getUiOptions, buttonId, } from '@rjsf/utils';
|
|
6
6
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
7
7
|
*
|
|
8
|
-
* @param props - The `
|
|
8
|
+
* @param props - The `ArrayFieldTemplateProps` props for the component
|
|
9
9
|
*/
|
|
10
10
|
export default function ArrayFieldTemplate(props) {
|
|
11
|
-
const { canAdd, disabled,
|
|
11
|
+
const { canAdd, disabled, fieldPathId, uiSchema, items, optionalDataControl, onAddClick, readonly, registry, required, schema, title, } = props;
|
|
12
12
|
const uiOptions = getUiOptions(uiSchema);
|
|
13
13
|
const ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
14
|
-
const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
15
14
|
const ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
15
|
+
const showOptionalDataControlInTitle = !readonly && !disabled;
|
|
16
16
|
// Button templates are not overridden in the uiSchema
|
|
17
17
|
const { ButtonTemplates: { AddButton }, } = registry.templates;
|
|
18
|
-
return (_jsx(Paper, { elevation: 2, children: _jsxs(Box, { p: 2, children: [_jsx(ArrayFieldTitleTemplate, {
|
|
19
|
-
items.map(({ key, ...itemProps }) => (_jsx(ArrayFieldItemTemplate, { ...itemProps }, key))), canAdd && (_jsx(Grid, { container: true, justifyContent: 'flex-end', children: _jsx(Grid, { children: _jsx(Box, { mt: 2, children: _jsx(AddButton, { id: buttonId(idSchema, 'add'), className: 'rjsf-array-item-add', onClick: onAddClick, disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }) }) }) }))] }) }));
|
|
18
|
+
return (_jsx(Paper, { elevation: 2, children: _jsxs(Box, { p: 2, children: [_jsx(ArrayFieldTitleTemplate, { fieldPathId: fieldPathId, title: uiOptions.title || title, schema: schema, uiSchema: uiSchema, required: required, registry: registry, optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : undefined }), _jsx(ArrayFieldDescriptionTemplate, { fieldPathId: fieldPathId, description: uiOptions.description || schema.description, schema: schema, uiSchema: uiSchema, registry: registry }), !showOptionalDataControlInTitle ? optionalDataControl : undefined, items, canAdd && (_jsx(Grid, { container: true, justifyContent: 'flex-end', children: _jsx(Grid, { children: _jsx(Box, { mt: 2, children: _jsx(AddButton, { id: buttonId(fieldPathId, 'add'), className: 'rjsf-array-item-add', onClick: onAddClick, disabled: disabled || readonly, uiSchema: uiSchema, registry: registry }) }) }) }))] }) }));
|
|
20
19
|
}
|
|
21
20
|
//# sourceMappingURL=ArrayFieldTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayFieldTemplate.js","sourceRoot":"","sources":["../../src/ArrayFieldTemplate/ArrayFieldTemplate.tsx"],"names":[],"mappings":";AAAA,OAAO,GAAG,MAAM,mBAAmB,CAAC;AACpC,OAAO,IAAI,MAAM,oBAAoB,CAAC;AACtC,OAAO,KAAK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AE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,8BAA8B,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,GACrF,EACF,KAAC,6BAA6B,IAC5B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,SAAS,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,EACxD,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,EACD,CAAC,8BAA8B,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,EACjE,KAAK,EACL,MAAM,IAAI,CACT,KAAC,IAAI,IAAC,SAAS,QAAC,cAAc,EAAC,UAAU,YACvC,KAAC,IAAI,cACH,KAAC,GAAG,IAAC,EAAE,EAAE,CAAC,YACR,KAAC,SAAS,IACR,EAAE,EAAE,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,EAChC,SAAS,EAAC,qBAAqB,EAC/B,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,QAAQ,IAAI,QAAQ,EAC9B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAClB,GACE,GACD,GACF,CACR,IACG,GACA,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import TextField from '@mui/material/TextField
|
|
2
|
+
import TextField from '@mui/material/TextField';
|
|
3
3
|
import { ariaDescribedByIds, examplesId, getInputProps, labelValue, } from '@rjsf/utils';
|
|
4
4
|
const TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
|
|
5
5
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
@@ -10,7 +10,7 @@ const TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
|
|
|
10
10
|
*/
|
|
11
11
|
export default function BaseInputTemplate(props) {
|
|
12
12
|
const { id, name, // remove this from textFieldProps
|
|
13
|
-
placeholder, required, readonly, disabled, type, label, hideLabel, hideError, value, onChange, onChangeOverride, onBlur, onFocus, autofocus, options, schema, uiSchema, rawErrors = [], errorSchema,
|
|
13
|
+
htmlName, placeholder, required, readonly, disabled, type, label, hideLabel, hideError, value, onChange, onChangeOverride, onBlur, onFocus, autofocus, options, schema, uiSchema, rawErrors = [], errorSchema, registry, InputLabelProps, ...textFieldProps } = props;
|
|
14
14
|
const inputProps = getInputProps(schema, type, options);
|
|
15
15
|
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
16
16
|
const { step, min, max, accept, ...rest } = inputProps;
|
|
@@ -24,7 +24,7 @@ export default function BaseInputTemplate(props) {
|
|
|
24
24
|
shrink: true,
|
|
25
25
|
}
|
|
26
26
|
: InputLabelProps;
|
|
27
|
-
return (_jsxs(_Fragment, { children: [_jsx(TextField, { id: id, name: id, placeholder: placeholder, label: labelValue(label || undefined, hideLabel, undefined), autoFocus: autofocus, required: required, disabled: disabled || readonly, slotProps: { htmlInput: htmlInputProps, inputLabel: DisplayInputLabelProps }, ...rest, value: value || value === 0 ? value : '', error: rawErrors.length > 0, onChange: onChangeOverride || _onChange, onBlur: _onBlur, onFocus: _onFocus, ...textFieldProps, "aria-describedby": ariaDescribedByIds(id, !!schema.examples) }), Array.isArray(schema.examples) && (_jsx("datalist", { id: examplesId(id), children: schema.examples
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsx(TextField, { id: id, name: htmlName || id, placeholder: placeholder, label: labelValue(label || undefined, hideLabel, undefined), autoFocus: autofocus, required: required, disabled: disabled || readonly, slotProps: { htmlInput: htmlInputProps, inputLabel: DisplayInputLabelProps }, ...rest, value: value || value === 0 ? value : '', error: rawErrors.length > 0, onChange: onChangeOverride || _onChange, onBlur: _onBlur, onFocus: _onFocus, ...textFieldProps, "aria-describedby": ariaDescribedByIds(id, !!schema.examples) }), Array.isArray(schema.examples) && (_jsx("datalist", { id: examplesId(id), children: schema.examples
|
|
28
28
|
.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : [])
|
|
29
29
|
.map((example) => {
|
|
30
30
|
return _jsx("option", { value: example }, example);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInputTemplate.js","sourceRoot":"","sources":["../../src/BaseInputTemplate/BaseInputTemplate.tsx"],"names":[],"mappings":";AACA,OAAO,SAA6B,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,kBAAkB,EAElB,UAAU,EACV,aAAa,EACb,UAAU,GAIX,MAAM,aAAa,CAAC;AAErB,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAIvC,KAAsC;IACtC,MAAM,EACJ,EAAE,EACF,IAAI,EAAE,kCAAkC;IACxC,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,GAAG,EAAE,EACd,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"BaseInputTemplate.js","sourceRoot":"","sources":["../../src/BaseInputTemplate/BaseInputTemplate.tsx"],"names":[],"mappings":";AACA,OAAO,SAA6B,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,kBAAkB,EAElB,UAAU,EACV,aAAa,EACb,UAAU,GAIX,MAAM,aAAa,CAAC;AAErB,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAIvC,KAAsC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pB,OAAO,iBAAsB,KAAK,EAAE,OAAO,IAAvB,OAAO,CAAoB,CAAC;gBAClD,CAAC,CAAC,GACK,CACZ,IACA,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Checkbox from '@mui/material/Checkbox
|
|
3
|
-
import FormControlLabel from '@mui/material/FormControlLabel
|
|
2
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
3
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
4
4
|
import { ariaDescribedByIds, descriptionId, getTemplate, labelValue, schemaRequiresTrueValue, } from '@rjsf/utils';
|
|
5
5
|
/** The `CheckBoxWidget` is a widget for rendering boolean properties.
|
|
6
6
|
* It is typically used to represent a boolean.
|
|
@@ -9,16 +9,16 @@ import { ariaDescribedByIds, descriptionId, getTemplate, labelValue, schemaRequi
|
|
|
9
9
|
*/
|
|
10
10
|
export default function CheckboxWidget(props) {
|
|
11
11
|
var _a;
|
|
12
|
-
const { schema, id, value, disabled, readonly, label = '', hideLabel, autofocus, onChange, onBlur, onFocus, registry, options, uiSchema, } = props;
|
|
12
|
+
const { schema, id, htmlName, value, disabled, readonly, label = '', hideLabel, autofocus, onChange, onBlur, onFocus, registry, options, uiSchema, } = props;
|
|
13
13
|
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
14
14
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
15
15
|
// the "required" attribute if the field value must be "true", due to the
|
|
16
16
|
// "const" or "enum" keywords
|
|
17
17
|
const required = schemaRequiresTrueValue(schema);
|
|
18
18
|
const _onChange = (_, checked) => onChange(checked);
|
|
19
|
-
const _onBlur = (
|
|
20
|
-
const _onFocus = (
|
|
19
|
+
const _onBlur = () => onBlur(id, value);
|
|
20
|
+
const _onFocus = () => onFocus(id, value);
|
|
21
21
|
const description = (_a = options.description) !== null && _a !== void 0 ? _a : schema.description;
|
|
22
|
-
return (_jsxs(_Fragment, { children: [!hideLabel && description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), _jsx(FormControlLabel, { control: _jsx(Checkbox, { id: id, name: id, checked: typeof value === 'undefined' ? false : Boolean(value), required: required, disabled: disabled || readonly, autoFocus: autofocus, onChange: _onChange, onBlur: _onBlur, onFocus: _onFocus, "aria-describedby": ariaDescribedByIds(id) }), label: labelValue(label, hideLabel, false) })] }));
|
|
22
|
+
return (_jsxs(_Fragment, { children: [!hideLabel && description && (_jsx(DescriptionFieldTemplate, { id: descriptionId(id), description: description, schema: schema, uiSchema: uiSchema, registry: registry })), _jsx(FormControlLabel, { control: _jsx(Checkbox, { id: id, name: htmlName || id, checked: typeof value === 'undefined' ? false : Boolean(value), required: required, disabled: disabled || readonly, autoFocus: autofocus, onChange: _onChange, onBlur: _onBlur, onFocus: _onFocus, "aria-describedby": ariaDescribedByIds(id) }), label: labelValue(label, hideLabel, false) })] }));
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=CheckboxWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxWidget.js","sourceRoot":"","sources":["../../src/CheckboxWidget/CheckboxWidget.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CheckboxWidget.js","sourceRoot":"","sources":["../../src/CheckboxWidget/CheckboxWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,UAAU,EACV,uBAAuB,GAKxB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAIpC,KAA2B;;IAC3B,MAAM,EACJ,MAAM,EACN,EAAE,EACF,QAAQ,EACR,K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SAAS,EACpB,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,QAAQ,sBACC,kBAAkB,CAAC,EAAE,CAAC,GACxC,EAEJ,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,GAC1C,IACD,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -4,4 +4,4 @@ import { FormContextType, WidgetProps, RJSFSchema, StrictRJSFSchema } from '@rjs
|
|
|
4
4
|
*
|
|
5
5
|
* @param props - The `WidgetProps` for this component
|
|
6
6
|
*/
|
|
7
|
-
export default function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ label, hideLabel, id, disabled, options, value, autofocus, readonly, required, onChange, onBlur, onFocus, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default function CheckboxesWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({ label, hideLabel, id, htmlName, disabled, options, value, autofocus, readonly, required, onChange, onBlur, onFocus, }: WidgetProps<T, S, F>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Checkbox from '@mui/material/Checkbox
|
|
3
|
-
import FormControlLabel from '@mui/material/FormControlLabel
|
|
4
|
-
import FormGroup from '@mui/material/FormGroup
|
|
5
|
-
import FormLabel from '@mui/material/FormLabel
|
|
2
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
3
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
4
|
+
import FormGroup from '@mui/material/FormGroup';
|
|
5
|
+
import FormLabel from '@mui/material/FormLabel';
|
|
6
6
|
import { ariaDescribedByIds, enumOptionsDeselectValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, labelValue, optionId, } from '@rjsf/utils';
|
|
7
7
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
8
8
|
* It is typically used to represent an array of enums.
|
|
9
9
|
*
|
|
10
10
|
* @param props - The `WidgetProps` for this component
|
|
11
11
|
*/
|
|
12
|
-
export default function CheckboxesWidget({ label, hideLabel, id, disabled, options, value, autofocus, readonly, required, onChange, onBlur, onFocus, }) {
|
|
12
|
+
export default function CheckboxesWidget({ label, hideLabel, id, htmlName, disabled, options, value, autofocus, readonly, required, onChange, onBlur, onFocus, }) {
|
|
13
13
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
14
14
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
15
15
|
const _onChange = (index) => ({ target: { checked } }) => {
|
|
@@ -26,7 +26,7 @@ export default function CheckboxesWidget({ label, hideLabel, id, disabled, optio
|
|
|
26
26
|
enumOptions.map((option, index) => {
|
|
27
27
|
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
28
28
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
29
|
-
const checkbox = (_jsx(Checkbox, { id: optionId(id, index), name: id, checked: checked, disabled: disabled || itemDisabled || readonly, autoFocus: autofocus && index === 0, onChange: _onChange(index), onBlur: _onBlur, onFocus: _onFocus, "aria-describedby": ariaDescribedByIds(id) }));
|
|
29
|
+
const checkbox = (_jsx(Checkbox, { id: optionId(id, index), name: htmlName || id, checked: checked, disabled: disabled || itemDisabled || readonly, autoFocus: autofocus && index === 0, onChange: _onChange(index), onBlur: _onBlur, onFocus: _onFocus, "aria-describedby": ariaDescribedByIds(id) }));
|
|
30
30
|
return _jsx(FormControlLabel, { control: checkbox, label: option.label }, index);
|
|
31
31
|
}) })] }));
|
|
32
32
|
}
|