@rjsf/antd 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.
Files changed (90) hide show
  1. package/README.md +2 -0
  2. package/dist/antd.esm.js +248 -227
  3. package/dist/antd.esm.js.map +4 -4
  4. package/dist/antd.umd.js +176 -157
  5. package/dist/{index.js → index.cjs} +227 -203
  6. package/dist/index.cjs.map +7 -0
  7. package/lib/templates/ArrayFieldItemTemplate/index.d.ts +3 -3
  8. package/lib/templates/ArrayFieldItemTemplate/index.js +1 -1
  9. package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -1
  10. package/lib/templates/ArrayFieldTemplate/index.d.ts +1 -1
  11. package/lib/templates/ArrayFieldTemplate/index.js +5 -5
  12. package/lib/templates/ArrayFieldTemplate/index.js.map +1 -1
  13. package/lib/templates/BaseInputTemplate/index.js +3 -2
  14. package/lib/templates/BaseInputTemplate/index.js.map +1 -1
  15. package/lib/templates/FieldErrorTemplate/index.js +2 -2
  16. package/lib/templates/FieldErrorTemplate/index.js.map +1 -1
  17. package/lib/templates/FieldTemplate/index.js +3 -2
  18. package/lib/templates/FieldTemplate/index.js.map +1 -1
  19. package/lib/templates/IconButton/index.d.ts +2 -2
  20. package/lib/templates/IconButton/index.js +6 -4
  21. package/lib/templates/IconButton/index.js.map +1 -1
  22. package/lib/templates/MultiSchemaFieldTemplate/index.d.ts +2 -0
  23. package/lib/templates/MultiSchemaFieldTemplate/index.js +6 -0
  24. package/lib/templates/MultiSchemaFieldTemplate/index.js.map +1 -0
  25. package/lib/templates/ObjectFieldTemplate/index.js +5 -3
  26. package/lib/templates/ObjectFieldTemplate/index.js.map +1 -1
  27. package/lib/templates/OptionalDataControlsTemplate/index.d.ts +10 -0
  28. package/lib/templates/OptionalDataControlsTemplate/index.js +21 -0
  29. package/lib/templates/OptionalDataControlsTemplate/index.js.map +1 -0
  30. package/lib/templates/TitleField/index.d.ts +1 -1
  31. package/lib/templates/TitleField/index.js +8 -4
  32. package/lib/templates/TitleField/index.js.map +1 -1
  33. package/lib/templates/WrapIfAdditionalTemplate/index.js +2 -3
  34. package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -1
  35. package/lib/templates/index.js +4 -0
  36. package/lib/templates/index.js.map +1 -1
  37. package/lib/tsconfig.tsbuildinfo +1 -1
  38. package/lib/widgets/AltDateTimeWidget/index.d.ts +1 -1
  39. package/lib/widgets/AltDateTimeWidget/index.js +2 -2
  40. package/lib/widgets/AltDateTimeWidget/index.js.map +1 -1
  41. package/lib/widgets/AltDateWidget/index.d.ts +1 -1
  42. package/lib/widgets/AltDateWidget/index.js +9 -61
  43. package/lib/widgets/AltDateWidget/index.js.map +1 -1
  44. package/lib/widgets/CheckboxWidget/index.js +3 -2
  45. package/lib/widgets/CheckboxWidget/index.js.map +1 -1
  46. package/lib/widgets/CheckboxesWidget/index.d.ts +1 -1
  47. package/lib/widgets/CheckboxesWidget/index.js +4 -3
  48. package/lib/widgets/CheckboxesWidget/index.js.map +1 -1
  49. package/lib/widgets/DateTimeWidget/index.js +2 -1
  50. package/lib/widgets/DateTimeWidget/index.js.map +1 -1
  51. package/lib/widgets/DateWidget/index.js +2 -1
  52. package/lib/widgets/DateWidget/index.js.map +1 -1
  53. package/lib/widgets/PasswordWidget/index.js +2 -1
  54. package/lib/widgets/PasswordWidget/index.js.map +1 -1
  55. package/lib/widgets/RadioWidget/index.d.ts +1 -1
  56. package/lib/widgets/RadioWidget/index.js +4 -3
  57. package/lib/widgets/RadioWidget/index.js.map +1 -1
  58. package/lib/widgets/RangeWidget/index.js +2 -1
  59. package/lib/widgets/RangeWidget/index.js.map +1 -1
  60. package/lib/widgets/SelectWidget/index.d.ts +1 -1
  61. package/lib/widgets/SelectWidget/index.js +3 -2
  62. package/lib/widgets/SelectWidget/index.js.map +1 -1
  63. package/lib/widgets/TextareaWidget/index.d.ts +1 -1
  64. package/lib/widgets/TextareaWidget/index.js +3 -2
  65. package/lib/widgets/TextareaWidget/index.js.map +1 -1
  66. package/package.json +21 -21
  67. package/src/templates/ArrayFieldItemTemplate/index.tsx +3 -3
  68. package/src/templates/ArrayFieldTemplate/index.tsx +12 -18
  69. package/src/templates/BaseInputTemplate/index.tsx +10 -8
  70. package/src/templates/FieldErrorTemplate/index.tsx +2 -2
  71. package/src/templates/FieldTemplate/index.tsx +7 -5
  72. package/src/templates/IconButton/index.tsx +10 -8
  73. package/src/templates/MultiSchemaFieldTemplate/index.tsx +16 -0
  74. package/src/templates/ObjectFieldTemplate/index.tsx +12 -9
  75. package/src/templates/OptionalDataControlsTemplate/index.tsx +47 -0
  76. package/src/templates/TitleField/index.tsx +18 -3
  77. package/src/templates/WrapIfAdditionalTemplate/index.tsx +5 -8
  78. package/src/templates/index.ts +4 -0
  79. package/src/widgets/AltDateTimeWidget/index.tsx +2 -2
  80. package/src/widgets/AltDateWidget/index.tsx +21 -120
  81. package/src/widgets/CheckboxWidget/index.tsx +5 -3
  82. package/src/widgets/CheckboxesWidget/index.tsx +17 -4
  83. package/src/widgets/DateTimeWidget/index.tsx +3 -2
  84. package/src/widgets/DateWidget/index.tsx +3 -2
  85. package/src/widgets/PasswordWidget/index.tsx +3 -2
  86. package/src/widgets/RadioWidget/index.tsx +6 -4
  87. package/src/widgets/RangeWidget/index.tsx +3 -2
  88. package/src/widgets/SelectWidget/index.tsx +5 -3
  89. package/src/widgets/TextareaWidget/index.tsx +5 -3
  90. package/dist/index.js.map +0 -7
package/dist/antd.umd.js CHANGED
@@ -33,9 +33,9 @@
33
33
  canAdd,
34
34
  className,
35
35
  disabled,
36
- formContext,
37
- idSchema,
36
+ fieldPathId,
38
37
  items,
38
+ optionalDataControl,
39
39
  onAddClick,
40
40
  readonly,
41
41
  registry,
@@ -50,16 +50,13 @@
50
50
  registry,
51
51
  uiOptions
52
52
  );
53
- const ArrayFieldItemTemplate2 = utils.getTemplate(
54
- "ArrayFieldItemTemplate",
55
- registry,
56
- uiOptions
57
- );
58
53
  const ArrayFieldTitleTemplate = utils.getTemplate(
59
54
  "ArrayFieldTitleTemplate",
60
55
  registry,
61
56
  uiOptions
62
57
  );
58
+ const showOptionalDataControlInTitle = !readonly && !disabled;
59
+ const { formContext } = registry;
63
60
  const {
64
61
  ButtonTemplates: { AddButton: AddButton2 }
65
62
  } = registry.templates;
@@ -72,33 +69,37 @@
72
69
  labelAlign === "left" && `${labelClsBasic}-left`
73
70
  // labelCol.className,
74
71
  );
75
- return /* @__PURE__ */ jsxRuntime.jsx("fieldset", { className, id: idSchema.$id, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: rowGutter, children: [
72
+ return /* @__PURE__ */ jsxRuntime.jsx("fieldset", { className, id: fieldPathId.$id, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: rowGutter, children: [
76
73
  (uiOptions.title || title) && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { className: labelColClassName, span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(
77
74
  ArrayFieldTitleTemplate,
78
75
  {
79
- idSchema,
76
+ fieldPathId,
80
77
  required,
81
78
  title: uiOptions.title || title,
82
79
  schema,
83
80
  uiSchema,
84
- registry
81
+ registry,
82
+ optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
85
83
  }
86
84
  ) }),
87
85
  (uiOptions.description || schema.description) && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24, style: DESCRIPTION_COL_STYLE, children: /* @__PURE__ */ jsxRuntime.jsx(
88
86
  ArrayFieldDescriptionTemplate,
89
87
  {
90
88
  description: uiOptions.description || schema.description,
91
- idSchema,
89
+ fieldPathId,
92
90
  schema,
93
91
  uiSchema,
94
92
  registry
95
93
  }
96
94
  ) }),
97
- /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { className: "row array-item-list", span: 24, children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
95
+ /* @__PURE__ */ jsxRuntime.jsxs(antd.Col, { className: "row array-item-list", span: 24, children: [
96
+ !showOptionalDataControlInTitle ? optionalDataControl : void 0,
97
+ items
98
+ ] }),
98
99
  canAdd && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: rowGutter, justify: "end", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "192px", children: /* @__PURE__ */ jsxRuntime.jsx(
99
100
  AddButton2,
100
101
  {
101
- id: utils.buttonId(idSchema, "add"),
102
+ id: utils.buttonId(fieldPathId, "add"),
102
103
  className: "rjsf-array-item-add",
103
104
  disabled: disabled || readonly,
104
105
  onClick: onAddClick,
@@ -114,8 +115,9 @@
114
115
  function BaseInputTemplate(props) {
115
116
  const {
116
117
  disabled,
117
- formContext,
118
+ registry,
118
119
  id,
120
+ htmlName,
119
121
  onBlur,
120
122
  onChange,
121
123
  onChangeOverride,
@@ -127,6 +129,7 @@
127
129
  value,
128
130
  type
129
131
  } = props;
132
+ const { formContext } = registry;
130
133
  const inputProps = utils.getInputProps(schema, type, options, false);
131
134
  const { readonlyAsDisabled = true } = formContext;
132
135
  const handleNumberChange = (nextValue) => onChange(nextValue);
@@ -138,7 +141,7 @@
138
141
  {
139
142
  disabled: disabled || readonlyAsDisabled && readonly,
140
143
  id,
141
- name: id,
144
+ name: htmlName || id,
142
145
  onBlur: !readonly ? handleBlur : void 0,
143
146
  onChange: !readonly ? handleNumberChange : void 0,
144
147
  onFocus: !readonly ? handleFocus : void 0,
@@ -154,7 +157,7 @@
154
157
  {
155
158
  disabled: disabled || readonlyAsDisabled && readonly,
156
159
  id,
157
- name: id,
160
+ name: htmlName || id,
158
161
  onBlur: !readonly ? handleBlur : void 0,
159
162
  onChange: !readonly ? handleTextChange : void 0,
160
163
  onFocus: !readonly ? handleFocus : void 0,
@@ -200,13 +203,18 @@
200
203
  );
201
204
  }
202
205
  function IconButton(props) {
203
- const { iconType = "default", icon, onClick, uiSchema, registry, ...otherProps } = props;
206
+ const { iconType = "default", icon, onClick, uiSchema, registry, color, ...otherProps } = props;
204
207
  return /* @__PURE__ */ jsxRuntime.jsx(
205
208
  antd.Button,
206
209
  {
207
210
  onClick,
208
211
  type: iconType,
209
212
  icon,
213
+ color,
214
+ style: {
215
+ paddingTop: "4px"
216
+ /* Center the button */
217
+ },
210
218
  ...otherProps
211
219
  }
212
220
  );
@@ -219,9 +227,9 @@
219
227
  IconButton,
220
228
  {
221
229
  title: translateString(utils.TranslatableString.AddItemButton),
222
- ...props,
223
- block: true,
224
230
  iconType: "primary",
231
+ block: true,
232
+ ...props,
225
233
  icon: /* @__PURE__ */ jsxRuntime.jsx(PlusCircleOutlined, {})
226
234
  }
227
235
  );
@@ -253,20 +261,20 @@
253
261
  IconButton,
254
262
  {
255
263
  title: translateString(utils.TranslatableString.RemoveButton),
256
- ...props,
257
264
  danger: true,
258
265
  block: !!options.block,
259
266
  iconType: "primary",
267
+ ...props,
260
268
  icon: /* @__PURE__ */ jsxRuntime.jsx(DeleteOutlined, {})
261
269
  }
262
270
  );
263
271
  }
264
272
  function FieldErrorTemplate(props) {
265
- const { errors = [], idSchema } = props;
273
+ const { errors = [], fieldPathId } = props;
266
274
  if (errors.length === 0) {
267
275
  return null;
268
276
  }
269
- const id = utils.errorId(idSchema);
277
+ const id = utils.errorId(fieldPathId);
270
278
  return /* @__PURE__ */ jsxRuntime.jsx("div", { id, children: errors.map((error) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: error }, `field-${id}-error-${error}`)) });
271
279
  }
272
280
  var VERTICAL_LABEL_COL = { span: 24 };
@@ -280,13 +288,13 @@
280
288
  disabled,
281
289
  displayLabel,
282
290
  errors,
283
- formContext,
284
291
  help,
285
292
  hidden,
286
293
  id,
287
294
  label,
288
- onDropPropertyClick,
289
- onKeyChange,
295
+ onKeyRename,
296
+ onKeyRenameBlur,
297
+ onRemoveProperty,
290
298
  rawErrors,
291
299
  rawDescription,
292
300
  rawHelp,
@@ -296,6 +304,7 @@
296
304
  schema,
297
305
  uiSchema
298
306
  } = props;
307
+ const { formContext } = registry;
299
308
  const {
300
309
  colon,
301
310
  labelCol = VERTICAL_LABEL_COL,
@@ -331,8 +340,9 @@
331
340
  disabled,
332
341
  id,
333
342
  label,
334
- onDropPropertyClick,
335
- onKeyChange,
343
+ onKeyRename,
344
+ onKeyRenameBlur,
345
+ onRemoveProperty,
336
346
  readonly,
337
347
  required,
338
348
  schema,
@@ -365,6 +375,13 @@
365
375
  }
366
376
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { ...rest, children });
367
377
  }
378
+ function MultiSchemaFieldTemplate(props) {
379
+ const { optionSchemaField, selector } = props;
380
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
381
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: selector }),
382
+ optionSchemaField
383
+ ] });
384
+ }
368
385
  var DESCRIPTION_COL_STYLE2 = {
369
386
  paddingBottom: "8px"
370
387
  };
@@ -372,10 +389,10 @@
372
389
  const {
373
390
  description,
374
391
  disabled,
375
- formContext,
376
392
  formData,
377
- idSchema,
378
- onAddClick,
393
+ fieldPathId,
394
+ onAddProperty,
395
+ optionalDataControl,
379
396
  properties,
380
397
  readonly,
381
398
  required,
@@ -391,6 +408,8 @@
391
408
  registry,
392
409
  uiOptions
393
410
  );
411
+ const { formContext } = registry;
412
+ const showOptionalDataControlInTitle = !readonly && !disabled;
394
413
  const {
395
414
  ButtonTemplates: { AddButton: AddButton2 }
396
415
  } = registry.templates;
@@ -431,44 +450,79 @@
431
450
  labelAlign === "left" && `${labelClsBasic}-left`
432
451
  // labelCol.className,
433
452
  );
434
- return /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { id: idSchema.$id, children: [
453
+ return /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { id: fieldPathId.$id, children: [
435
454
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: rowGutter, children: [
436
455
  title && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { className: labelColClassName, span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(
437
456
  TitleFieldTemplate,
438
457
  {
439
- id: utils.titleId(idSchema),
458
+ id: utils.titleId(fieldPathId),
440
459
  title,
441
460
  required,
442
461
  schema,
443
462
  uiSchema,
444
- registry
463
+ registry,
464
+ optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
445
465
  }
446
466
  ) }),
447
467
  description && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24, style: DESCRIPTION_COL_STYLE2, children: /* @__PURE__ */ jsxRuntime.jsx(
448
468
  DescriptionFieldTemplate,
449
469
  {
450
- id: utils.descriptionId(idSchema),
470
+ id: utils.descriptionId(fieldPathId),
451
471
  description,
452
472
  schema,
453
473
  uiSchema,
454
474
  registry
455
475
  }
456
476
  ) }),
477
+ !showOptionalDataControlInTitle ? /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24, children: optionalDataControl }) : void 0,
457
478
  properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: calculateColSpan(element), children: element.content }, element.name))
458
479
  ] }),
459
480
  utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Row, { gutter: rowGutter, justify: "end", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "192px", children: /* @__PURE__ */ jsxRuntime.jsx(
460
481
  AddButton2,
461
482
  {
462
- id: utils.buttonId(idSchema, "add"),
483
+ id: utils.buttonId(fieldPathId, "add"),
463
484
  className: "rjsf-object-property-expand",
464
485
  disabled: disabled || readonly,
465
- onClick: onAddClick(schema),
486
+ onClick: onAddProperty,
466
487
  uiSchema,
467
488
  registry
468
489
  }
469
490
  ) }) }) })
470
491
  ] });
471
492
  }
493
+ function OptionalDataControlsTemplate(props) {
494
+ const { id, registry, label, onAddClick, onRemoveClick } = props;
495
+ if (onAddClick) {
496
+ return /* @__PURE__ */ jsxRuntime.jsx(
497
+ AddButton,
498
+ {
499
+ id,
500
+ registry,
501
+ className: "rjsf-add-optional-data",
502
+ onClick: onAddClick,
503
+ title: label,
504
+ size: "small",
505
+ iconType: "default",
506
+ block: false
507
+ }
508
+ );
509
+ } else if (onRemoveClick) {
510
+ return /* @__PURE__ */ jsxRuntime.jsx(
511
+ RemoveButton,
512
+ {
513
+ id,
514
+ registry,
515
+ className: "rjsf-remove-optional-data",
516
+ onClick: onRemoveClick,
517
+ title: label,
518
+ size: "small",
519
+ iconType: "default",
520
+ block: false
521
+ }
522
+ );
523
+ }
524
+ return /* @__PURE__ */ jsxRuntime.jsx("em", { id, children: label });
525
+ }
472
526
  function SubmitButton({ uiSchema }) {
473
527
  const { submitText, norender, props: submitButtonProps } = utils.getSubmitButtonOptions(uiSchema);
474
528
  if (norender) {
@@ -480,7 +534,8 @@
480
534
  id,
481
535
  required,
482
536
  registry,
483
- title
537
+ title,
538
+ optionalDataControl
484
539
  }) {
485
540
  const { formContext } = registry;
486
541
  const { colon = true } = formContext;
@@ -503,7 +558,7 @@
503
558
  [`${prefixCls}-item-required`]: required,
504
559
  [`${prefixCls}-item-no-colon`]: !colon
505
560
  });
506
- return title ? /* @__PURE__ */ jsxRuntime.jsx(
561
+ let heading = title ? /* @__PURE__ */ jsxRuntime.jsx(
507
562
  "label",
508
563
  {
509
564
  className: labelClassName,
@@ -513,6 +568,19 @@
513
568
  children: labelChildren
514
569
  }
515
570
  ) : null;
571
+ if (optionalDataControl) {
572
+ heading = /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { children: [
573
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "auto", children: heading }),
574
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "none", children: optionalDataControl })
575
+ ] });
576
+ }
577
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
578
+ heading,
579
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { size: "small", style: {
580
+ marginBlock: "1px"
581
+ /* pull the margin right up against the label */
582
+ } })
583
+ ] });
516
584
  }
517
585
  var VERTICAL_LABEL_COL2 = { span: 24 };
518
586
  var VERTICAL_WRAPPER_COL2 = { span: 24 };
@@ -527,8 +595,8 @@
527
595
  disabled,
528
596
  id,
529
597
  label,
530
- onDropPropertyClick,
531
- onKeyChange,
598
+ onRemoveProperty,
599
+ onKeyRenameBlur,
532
600
  readonly,
533
601
  required,
534
602
  registry,
@@ -551,7 +619,6 @@
551
619
  if (!additional) {
552
620
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames4, style, children });
553
621
  }
554
- const handleBlur = ({ target }) => onKeyChange(target && target.value);
555
622
  const uiOptions = uiSchema ? uiSchema[utils.UI_OPTIONS_KEY] : {};
556
623
  const buttonUiOptions = {
557
624
  ...uiSchema,
@@ -578,7 +645,7 @@
578
645
  disabled: disabled || readonlyAsDisabled && readonly,
579
646
  id: `${id}-key`,
580
647
  name: `${id}-key`,
581
- onBlur: !readonly ? handleBlur : void 0,
648
+ onBlur: !readonly ? onKeyRenameBlur : void 0,
582
649
  style: INPUT_STYLE2,
583
650
  type: "text"
584
651
  }
@@ -592,7 +659,7 @@
592
659
  id: utils.buttonId(id, "remove"),
593
660
  className: "rjsf-object-property-remove",
594
661
  disabled: disabled || readonly,
595
- onClick: onDropPropertyClick(label),
662
+ onClick: onRemoveProperty,
596
663
  uiSchema: buttonUiOptions,
597
664
  registry
598
665
  }
@@ -619,111 +686,39 @@
619
686
  FieldErrorTemplate,
620
687
  FieldTemplate,
621
688
  GridTemplate,
689
+ MultiSchemaFieldTemplate,
622
690
  ObjectFieldTemplate,
691
+ OptionalDataControlsTemplate,
623
692
  TitleFieldTemplate: TitleField,
624
693
  WrapIfAdditionalTemplate
625
694
  };
626
695
  }
627
696
  var templates_default = generateTemplates();
628
- var readyForChange = (state) => {
629
- return Object.values(state).every((value) => value !== -1);
630
- };
631
697
  function AltDateWidget(props) {
632
- const {
633
- autofocus,
634
- disabled,
635
- formContext,
636
- id,
637
- onBlur,
638
- onChange,
639
- onFocus,
640
- options,
641
- readonly,
642
- registry,
643
- showTime,
644
- value
645
- } = props;
646
- const { translateString, widgets } = registry;
647
- const { SelectWidget: SelectWidget2 } = widgets;
698
+ const { autofocus, disabled, id, name, onBlur, onFocus, options, readonly, registry } = props;
699
+ const { formContext, translateString } = registry;
648
700
  const { rowGutter = 24 } = formContext;
649
- const [state, setState] = react.useState(utils.parseDateString(value, showTime));
650
- react.useEffect(() => {
651
- setState(utils.parseDateString(value, showTime));
652
- }, [showTime, value]);
653
- const handleChange = (property, nextValue) => {
654
- const nextState = {
655
- ...state,
656
- [property]: typeof nextValue === "undefined" ? -1 : nextValue
657
- };
658
- if (readyForChange(nextState)) {
659
- onChange(utils.toDateString(nextState, showTime));
660
- } else {
661
- setState(nextState);
662
- }
663
- };
664
- const handleNow = (event) => {
665
- event.preventDefault();
666
- if (disabled || readonly) {
667
- return;
668
- }
669
- const nextState = utils.parseDateString((/* @__PURE__ */ new Date()).toJSON(), showTime);
670
- onChange(utils.toDateString(nextState, showTime));
671
- };
672
- const handleClear = (event) => {
673
- event.preventDefault();
674
- if (disabled || readonly) {
675
- return;
676
- }
677
- onChange(void 0);
678
- };
679
- const renderDateElement = (elemProps) => /* @__PURE__ */ jsxRuntime.jsx(
680
- SelectWidget2,
681
- {
682
- autofocus: elemProps.autofocus,
683
- className: "form-control",
684
- disabled: elemProps.disabled,
685
- id: elemProps.id,
686
- name: elemProps.name,
687
- onBlur: elemProps.onBlur,
688
- onChange: (elemValue) => elemProps.select(elemProps.type, elemValue),
689
- onFocus: elemProps.onFocus,
690
- options: {
691
- enumOptions: utils.dateRangeOptions(elemProps.range[0], elemProps.range[1])
692
- },
693
- placeholder: elemProps.type,
694
- readonly: elemProps.readonly,
695
- schema: { type: "integer" },
696
- value: elemProps.value,
697
- registry,
698
- label: "",
699
- "aria-describedby": utils.ariaDescribedByIds(id)
700
- }
701
- );
701
+ const { elements, handleChange, handleClear, handleSetNow } = utils.useAltDateWidgetProps(props);
702
702
  return /* @__PURE__ */ jsxRuntime.jsxs(antd.Row, { gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)], children: [
703
- utils.getDateElementProps(
704
- state,
705
- showTime,
706
- options.yearsRange,
707
- options.format
708
- ).map((elemProps, i) => {
709
- const elemId = id + "_" + elemProps.type;
710
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "88px", children: renderDateElement({
711
- ...elemProps,
712
- autofocus: autofocus && i === 0,
713
- disabled,
714
- id: elemId,
715
- name: id,
716
- onBlur,
717
- onFocus,
718
- readonly,
719
- registry,
720
- select: handleChange,
721
- // NOTE: antd components accept -1 rather than issue a warning
722
- // like material-ui, so we need to convert -1 to undefined here.
723
- value: elemProps.value || -1 < 0 ? void 0 : elemProps.value
724
- }) }, elemId);
703
+ elements.map((elemProps, i) => {
704
+ const elemId = `${id}_${elemProps.type}`;
705
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "88px", children: /* @__PURE__ */ jsxRuntime.jsx(
706
+ utils.DateElement,
707
+ {
708
+ rootId: id,
709
+ name,
710
+ select: handleChange,
711
+ ...elemProps,
712
+ disabled,
713
+ readonly,
714
+ registry,
715
+ onBlur,
716
+ onFocus,
717
+ autofocus: autofocus && i === 0
718
+ }
719
+ ) }, elemId);
725
720
  }),
726
- !options.hideNowButton && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "88px", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { block: true, className: "btn-now", onClick: handleNow, type: "primary", children: translateString(utils.TranslatableString.NowLabel) }) }),
721
+ !options.hideNowButton && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "88px", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { block: true, className: "btn-now", onClick: handleSetNow, type: "primary", children: translateString(utils.TranslatableString.NowLabel) }) }),
727
722
  !options.hideClearButton && /* @__PURE__ */ jsxRuntime.jsx(antd.Col, { flex: "88px", children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { block: true, className: "btn-clear", danger: true, onClick: handleClear, type: "primary", children: translateString(utils.TranslatableString.ClearLabel) }) })
728
723
  ] });
729
724
  }
@@ -734,17 +729,30 @@
734
729
  yearsRange: [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]
735
730
  },
736
731
  readonly: false,
737
- showTime: false
732
+ time: false
738
733
  };
739
734
  function AltDateTimeWidget(props) {
740
735
  const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
741
- return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { showTime: true, ...props });
736
+ return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { time: true, ...props });
742
737
  }
743
738
  AltDateTimeWidget.defaultProps = {
744
739
  ...AltDateWidget.defaultProps,
745
- showTime: true
740
+ time: true
746
741
  };
747
- function CheckboxesWidget({ autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, readonly, value }) {
742
+ function CheckboxesWidget({
743
+ autofocus,
744
+ disabled,
745
+ registry,
746
+ id,
747
+ htmlName,
748
+ onBlur,
749
+ onChange,
750
+ onFocus,
751
+ options,
752
+ readonly,
753
+ value
754
+ }) {
755
+ const { formContext } = registry;
748
756
  const { readonlyAsDisabled = true } = formContext;
749
757
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
750
758
  const handleChange = (nextValue) => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
@@ -760,7 +768,7 @@
760
768
  antd.Checkbox.Group,
761
769
  {
762
770
  disabled: disabled || readonlyAsDisabled && readonly,
763
- name: id,
771
+ name: htmlName || id,
764
772
  onChange: !readonly ? handleChange : void 0,
765
773
  value: selectedIndexes,
766
774
  ...extraProps,
@@ -770,7 +778,7 @@
770
778
  antd.Checkbox,
771
779
  {
772
780
  id: utils.optionId(id, i),
773
- name: id,
781
+ name: htmlName || id,
774
782
  autoFocus: i === 0 ? autofocus : false,
775
783
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
776
784
  value: String(i),
@@ -783,7 +791,8 @@
783
791
  ) }) : null;
784
792
  }
785
793
  function CheckboxWidget(props) {
786
- const { autofocus, disabled, formContext, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
794
+ const { autofocus, disabled, registry, id, htmlName, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
795
+ const { formContext } = registry;
787
796
  const { readonlyAsDisabled = true } = formContext;
788
797
  const handleChange = ({ target }) => onChange(target.checked);
789
798
  const handleBlur = ({ target }) => onBlur(id, target && target.checked);
@@ -799,7 +808,7 @@
799
808
  checked: typeof value === "undefined" ? false : value,
800
809
  disabled: disabled || readonlyAsDisabled && readonly,
801
810
  id,
802
- name: id,
811
+ name: htmlName || id,
803
812
  onChange: !readonly ? handleChange : void 0,
804
813
  ...extraProps,
805
814
  "aria-describedby": utils.ariaDescribedByIds(id),
@@ -811,7 +820,8 @@
811
820
  width: "100%"
812
821
  };
813
822
  function DateTimeWidget(props) {
814
- const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
823
+ const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
824
+ const { formContext } = registry;
815
825
  const { readonlyAsDisabled = true } = formContext;
816
826
  const handleChange = (nextValue) => onChange(nextValue && nextValue.toISOString());
817
827
  const handleBlur = () => onBlur(id, value);
@@ -839,7 +849,8 @@
839
849
  width: "100%"
840
850
  };
841
851
  function DateWidget(props) {
842
- const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
852
+ const { disabled, registry, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
853
+ const { formContext } = registry;
843
854
  const { readonlyAsDisabled = true } = formContext;
844
855
  const handleChange = (nextValue) => onChange(nextValue && nextValue.format("YYYY-MM-DD"));
845
856
  const handleBlur = () => onBlur(id, value);
@@ -864,7 +875,8 @@
864
875
  );
865
876
  }
866
877
  function PasswordWidget(props) {
867
- const { disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
878
+ const { disabled, registry, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
879
+ const { formContext } = registry;
868
880
  const { readonlyAsDisabled = true } = formContext;
869
881
  const emptyValue = options.emptyValue || "";
870
882
  const handleChange = ({ target }) => onChange(target.value === "" ? emptyValue : target.value);
@@ -888,8 +900,9 @@
888
900
  function RadioWidget({
889
901
  autofocus,
890
902
  disabled,
891
- formContext,
903
+ registry,
892
904
  id,
905
+ htmlName,
893
906
  onBlur,
894
907
  onChange,
895
908
  onFocus,
@@ -897,6 +910,7 @@
897
910
  readonly,
898
911
  value
899
912
  }) {
913
+ const { formContext } = registry;
900
914
  const { readonlyAsDisabled = true } = formContext;
901
915
  const { enumOptions, enumDisabled, emptyValue } = options;
902
916
  const handleChange = ({ target: { value: nextValue } }) => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
@@ -908,7 +922,7 @@
908
922
  {
909
923
  disabled: disabled || readonlyAsDisabled && readonly,
910
924
  id,
911
- name: id,
925
+ name: htmlName || id,
912
926
  onChange: !readonly ? handleChange : void 0,
913
927
  onBlur: !readonly ? handleBlur : void 0,
914
928
  onFocus: !readonly ? handleFocus : void 0,
@@ -918,7 +932,7 @@
918
932
  antd.Radio,
919
933
  {
920
934
  id: utils.optionId(id, i),
921
- name: id,
935
+ name: htmlName || id,
922
936
  autoFocus: i === 0 ? autofocus : false,
923
937
  disabled: disabled || Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
924
938
  value: String(i),
@@ -933,7 +947,7 @@
933
947
  const {
934
948
  autofocus,
935
949
  disabled,
936
- formContext,
950
+ registry,
937
951
  id,
938
952
  onBlur,
939
953
  onChange,
@@ -944,6 +958,7 @@
944
958
  schema,
945
959
  value
946
960
  } = props;
961
+ const { formContext } = registry;
947
962
  const { readonlyAsDisabled = true } = formContext;
948
963
  const { min, max, step } = utils.rangeSpec(schema);
949
964
  const emptyValue = options.emptyValue || "";
@@ -978,8 +993,9 @@
978
993
  function SelectWidget({
979
994
  autofocus,
980
995
  disabled,
981
- formContext = {},
996
+ registry,
982
997
  id,
998
+ htmlName,
983
999
  multiple,
984
1000
  onBlur,
985
1001
  onChange,
@@ -990,6 +1006,7 @@
990
1006
  value,
991
1007
  schema
992
1008
  }) {
1009
+ const { formContext } = registry;
993
1010
  const { readonlyAsDisabled = true } = formContext;
994
1011
  const { enumOptions, enumDisabled, emptyValue } = options;
995
1012
  const handleChange = (nextValue) => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
@@ -1004,7 +1021,7 @@
1004
1021
  const getPopupContainer = (node) => node.parentNode;
1005
1022
  const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
1006
1023
  const extraProps = {
1007
- name: id
1024
+ name: htmlName || id
1008
1025
  };
1009
1026
  const showPlaceholderOption = !multiple && schema.default === void 0;
1010
1027
  const selectOptions = react.useMemo(() => {
@@ -1048,8 +1065,9 @@
1048
1065
  };
1049
1066
  function TextareaWidget({
1050
1067
  disabled,
1051
- formContext,
1068
+ registry,
1052
1069
  id,
1070
+ htmlName,
1053
1071
  onBlur,
1054
1072
  onChange,
1055
1073
  onFocus,
@@ -1058,6 +1076,7 @@
1058
1076
  readonly,
1059
1077
  value
1060
1078
  }) {
1079
+ const { formContext } = registry;
1061
1080
  const { readonlyAsDisabled = true } = formContext;
1062
1081
  const handleChange = ({ target }) => onChange(target.value === "" ? options.emptyValue : target.value);
1063
1082
  const handleBlur = ({ target }) => onBlur(id, target && target.value);
@@ -1070,7 +1089,7 @@
1070
1089
  {
1071
1090
  disabled: disabled || readonlyAsDisabled && readonly,
1072
1091
  id,
1073
- name: id,
1092
+ name: htmlName || id,
1074
1093
  onBlur: !readonly ? handleBlur : void 0,
1075
1094
  onChange: !readonly ? handleChange : void 0,
1076
1095
  onFocus: !readonly ? handleFocus : void 0,