@rjsf/mantine 6.0.0-beta.21 → 6.0.0-beta.23

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 (53) hide show
  1. package/dist/index.cjs +98 -234
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/mantine.esm.js +98 -236
  4. package/dist/mantine.esm.js.map +4 -4
  5. package/dist/mantine.umd.js +105 -239
  6. package/lib/templates/ArrayFieldItemTemplate.d.ts +3 -3
  7. package/lib/templates/ArrayFieldItemTemplate.js +1 -1
  8. package/lib/templates/ArrayFieldItemTemplate.js.map +1 -1
  9. package/lib/templates/ArrayFieldTemplate.d.ts +1 -1
  10. package/lib/templates/ArrayFieldTemplate.js +2 -3
  11. package/lib/templates/ArrayFieldTemplate.js.map +1 -1
  12. package/lib/templates/BaseInputTemplate.js +2 -2
  13. package/lib/templates/BaseInputTemplate.js.map +1 -1
  14. package/lib/templates/FieldHelpTemplate.js +4 -1
  15. package/lib/templates/FieldHelpTemplate.js.map +1 -1
  16. package/lib/templates/ObjectFieldTemplate.js +2 -2
  17. package/lib/templates/ObjectFieldTemplate.js.map +1 -1
  18. package/lib/templates/WrapIfAdditionalTemplate.js +2 -4
  19. package/lib/templates/WrapIfAdditionalTemplate.js.map +1 -1
  20. package/lib/tsconfig.tsbuildinfo +1 -1
  21. package/lib/widgets/CheckboxWidget.js +2 -2
  22. package/lib/widgets/CheckboxWidget.js.map +1 -1
  23. package/lib/widgets/CheckboxesWidget.js +2 -2
  24. package/lib/widgets/CheckboxesWidget.js.map +1 -1
  25. package/lib/widgets/DateTime/AltDateTimeWidget.d.ts +1 -7
  26. package/lib/widgets/DateTime/AltDateTimeWidget.js +1 -6
  27. package/lib/widgets/DateTime/AltDateTimeWidget.js.map +1 -1
  28. package/lib/widgets/DateTime/AltDateWidget.d.ts +1 -7
  29. package/lib/widgets/DateTime/AltDateWidget.js +6 -39
  30. package/lib/widgets/DateTime/AltDateWidget.js.map +1 -1
  31. package/lib/widgets/FileWidget.js +9 -87
  32. package/lib/widgets/FileWidget.js.map +1 -1
  33. package/lib/widgets/RadioWidget.js +2 -2
  34. package/lib/widgets/RadioWidget.js.map +1 -1
  35. package/lib/widgets/SelectWidget.js +2 -2
  36. package/lib/widgets/SelectWidget.js.map +1 -1
  37. package/lib/widgets/TextareaWidget.js +2 -2
  38. package/lib/widgets/TextareaWidget.js.map +1 -1
  39. package/package.json +7 -7
  40. package/src/templates/ArrayFieldItemTemplate.tsx +3 -3
  41. package/src/templates/ArrayFieldTemplate.tsx +2 -10
  42. package/src/templates/BaseInputTemplate.tsx +3 -2
  43. package/src/templates/FieldHelpTemplate.tsx +5 -1
  44. package/src/templates/ObjectFieldTemplate.tsx +2 -2
  45. package/src/templates/WrapIfAdditionalTemplate.tsx +4 -10
  46. package/src/widgets/CheckboxWidget.tsx +2 -1
  47. package/src/widgets/CheckboxesWidget.tsx +2 -1
  48. package/src/widgets/DateTime/AltDateTimeWidget.tsx +1 -8
  49. package/src/widgets/DateTime/AltDateWidget.tsx +6 -71
  50. package/src/widgets/FileWidget.tsx +20 -112
  51. package/src/widgets/RadioWidget.tsx +2 -1
  52. package/src/widgets/SelectWidget.tsx +2 -1
  53. package/src/widgets/TextareaWidget.tsx +2 -1
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('@rjsf/utils'), require('@mantine/core'), require('react/jsx-runtime'), require('react'), require('dayjs'), require('dayjs/plugin/customParseFormat'), require('@mantine/dates')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', '@rjsf/core', '@rjsf/utils', '@mantine/core', 'react/jsx-runtime', 'react', 'dayjs', 'dayjs/plugin/customParseFormat', '@mantine/dates'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/mantine"] = {}, global.core$1, global.utils, global.core, global.jsxRuntime, global.react, global.dayjs, global.customParseFormat, global.dates));
5
- })(this, (function (exports, core$1, utils, core, jsxRuntime, react, dayjs, customParseFormat, dates) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/mantine"] = {}, global.core, global.utils, global.core$1, global.jsxRuntime, global.react, global.dayjs, global.customParseFormat, global.dates));
5
+ })(this, (function (exports, core, utils, core$1, jsxRuntime, react, dayjs, customParseFormat, dates) { 'use strict';
6
6
 
7
7
  // src/Form/index.ts
8
8
  function ArrayFieldItemTemplate(props) {
@@ -13,9 +13,9 @@
13
13
  registry,
14
14
  uiOptions
15
15
  );
16
- return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { className: className || "rjsf-array-item", mb: "xs", children: /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "end", justify: "center", children: [
17
- /* @__PURE__ */ jsxRuntime.jsx(core.Box, { w: "100%", children }),
18
- hasToolbar && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { wrap: "nowrap", gap: 2, mb: 7, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps }) })
16
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { className: className || "rjsf-array-item", mb: "xs", children: /* @__PURE__ */ jsxRuntime.jsxs(core$1.Flex, { gap: "xs", align: "end", justify: "center", children: [
17
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { w: "100%", children }),
18
+ hasToolbar && /* @__PURE__ */ jsxRuntime.jsx(core$1.Group, { wrap: "nowrap", gap: 2, mb: 7, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps }) })
19
19
  ] }) }, `array-item-${index}`);
20
20
  }
21
21
  function ArrayFieldTemplate(props) {
@@ -40,11 +40,6 @@
40
40
  registry,
41
41
  uiOptions
42
42
  );
43
- const ArrayFieldItemTemplate2 = utils.getTemplate(
44
- "ArrayFieldItemTemplate",
45
- registry,
46
- uiOptions
47
- );
48
43
  const ArrayFieldTitleTemplate2 = utils.getTemplate(
49
44
  "ArrayFieldTitleTemplate",
50
45
  registry,
@@ -66,7 +61,7 @@
66
61
  optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
67
62
  }
68
63
  );
69
- return /* @__PURE__ */ jsxRuntime.jsxs(core.Fieldset, { legend, className, id: fieldPathId.$id, children: [
64
+ return /* @__PURE__ */ jsxRuntime.jsxs(core$1.Fieldset, { legend, className, id: fieldPathId.$id, children: [
70
65
  (uiOptions.description || schema.description) && /* @__PURE__ */ jsxRuntime.jsx(
71
66
  ArrayFieldDescriptionTemplate,
72
67
  {
@@ -77,11 +72,11 @@
77
72
  registry
78
73
  }
79
74
  ),
80
- /* @__PURE__ */ jsxRuntime.jsxs(core.Box, { className: "row rjsf-array-item-list", children: [
75
+ /* @__PURE__ */ jsxRuntime.jsxs(core$1.Box, { className: "row rjsf-array-item-list", children: [
81
76
  !showOptionalDataControlInTitle ? optionalDataControl : void 0,
82
- items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...itemProps }, key))
77
+ items
83
78
  ] }),
84
- canAdd && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
79
+ canAdd && /* @__PURE__ */ jsxRuntime.jsx(core$1.Group, { justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
85
80
  AddButton2,
86
81
  {
87
82
  id: utils.buttonId(fieldPathId, "add"),
@@ -102,7 +97,7 @@
102
97
  if (!title || !displayLabel) {
103
98
  return null;
104
99
  }
105
- return /* @__PURE__ */ jsxRuntime.jsx(core.Title, { id: utils.titleId(fieldPathId), order: 4, fw: "normal", children: title });
100
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Title, { id: utils.titleId(fieldPathId), order: 4, fw: "normal", children: title });
106
101
  }
107
102
 
108
103
  // src/utils.ts
@@ -143,6 +138,7 @@
143
138
  function BaseInputTemplate(props) {
144
139
  const {
145
140
  id,
141
+ htmlName,
146
142
  type,
147
143
  schema,
148
144
  value,
@@ -185,10 +181,10 @@
185
181
  [onFocus, id]
186
182
  );
187
183
  const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ jsxRuntime.jsx(
188
- core.NumberInput,
184
+ core$1.NumberInput,
189
185
  {
190
186
  id,
191
- name: id,
187
+ name: htmlName || id,
192
188
  label: utils.labelValue(label || void 0, hideLabel, false),
193
189
  required,
194
190
  autoFocus: autofocus,
@@ -207,10 +203,10 @@
207
203
  "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
208
204
  }
209
205
  ) : /* @__PURE__ */ jsxRuntime.jsx(
210
- core.TextInput,
206
+ core$1.TextInput,
211
207
  {
212
208
  id,
213
- name: id,
209
+ name: htmlName || id,
214
210
  label: utils.labelValue(label || void 0, hideLabel, false),
215
211
  required,
216
212
  autoFocus: autofocus,
@@ -238,7 +234,7 @@
238
234
  function DescriptionField(props) {
239
235
  const { id, description, registry, uiSchema } = props;
240
236
  if (description) {
241
- return /* @__PURE__ */ jsxRuntime.jsx(core.Text, { id, mt: 3, mb: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(core$1.RichDescription, { description, registry, uiSchema }) });
237
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Text, { id, mt: 3, mb: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(core.RichDescription, { description, registry, uiSchema }) });
242
238
  }
243
239
  return null;
244
240
  }
@@ -390,13 +386,13 @@
390
386
  }) {
391
387
  const { translateString } = registry;
392
388
  return /* @__PURE__ */ jsxRuntime.jsx(
393
- core.Alert,
389
+ core$1.Alert,
394
390
  {
395
391
  color: "red",
396
392
  variant: "transparent",
397
- title: /* @__PURE__ */ jsxRuntime.jsx(core.Title, { order: 5, fw: "normal", children: translateString(utils.TranslatableString.ErrorsLabel) }),
393
+ title: /* @__PURE__ */ jsxRuntime.jsx(core$1.Title, { order: 5, fw: "normal", children: translateString(utils.TranslatableString.ErrorsLabel) }),
398
394
  icon: /* @__PURE__ */ jsxRuntime.jsx(ExclamationCircle, {}),
399
- children: /* @__PURE__ */ jsxRuntime.jsx(core.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.List.Item, { c: "red", children: error.stack }, `error-${index}`)) })
395
+ children: /* @__PURE__ */ jsxRuntime.jsx(core$1.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.List.Item, { c: "red", children: error.stack }, `error-${index}`)) })
400
396
  }
401
397
  );
402
398
  }
@@ -405,12 +401,12 @@
405
401
  if (norender) {
406
402
  return null;
407
403
  }
408
- return /* @__PURE__ */ jsxRuntime.jsx(core.Button, { type: "submit", variant: "filled", ...submitButtonProps, children: submitText });
404
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Button, { type: "submit", variant: "filled", ...submitButtonProps, children: submitText });
409
405
  }
410
406
  function IconButton(props) {
411
407
  const { icon, iconType = "sm", color, onClick, uiSchema, registry, ...otherProps } = props;
412
408
  return /* @__PURE__ */ jsxRuntime.jsx(
413
- core.ActionIcon,
409
+ core$1.ActionIcon,
414
410
  {
415
411
  size: iconType,
416
412
  color,
@@ -493,7 +489,7 @@
493
489
  return null;
494
490
  }
495
491
  const id = utils.errorId(fieldPathId);
496
- return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { id, c: "red", display: "none", children: /* @__PURE__ */ jsxRuntime.jsx(core.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.List.Item, { children: error }, `field-error-${index}`)) }) });
492
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { id, c: "red", display: "none", children: /* @__PURE__ */ jsxRuntime.jsx(core$1.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.List.Item, { children: error }, `field-error-${index}`)) }) });
497
493
  }
498
494
  function FieldTemplate(props) {
499
495
  const {
@@ -520,7 +516,7 @@
520
516
  uiOptions
521
517
  );
522
518
  if (hidden) {
523
- return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { display: "none", children });
519
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { display: "none", children });
524
520
  }
525
521
  return /* @__PURE__ */ jsxRuntime.jsxs(
526
522
  WrapIfAdditionalTemplate2,
@@ -543,18 +539,21 @@
543
539
  }
544
540
  function FieldHelpTemplate(props) {
545
541
  const { fieldPathId, help } = props;
542
+ if (!help) {
543
+ return null;
544
+ }
546
545
  const id = utils.helpId(fieldPathId);
547
- return !help ? null : /* @__PURE__ */ jsxRuntime.jsx(core.Text, { id, size: "sm", my: "xs", c: "dimmed", children: help });
546
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Text, { id, size: "sm", my: "xs", c: "dimmed", children: help });
548
547
  }
549
548
  function GridTemplate(props) {
550
549
  const { children, column, fluid = true, ...rest } = props;
551
550
  if (column) {
552
- return /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { ...rest, children });
551
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { ...rest, children });
553
552
  }
554
553
  if (fluid) {
555
- return /* @__PURE__ */ jsxRuntime.jsx(core.Container, { p: "4", mx: 0, w: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(core.Grid, { ...rest, children }) });
554
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Container, { p: "4", mx: 0, w: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid, { ...rest, children }) });
556
555
  }
557
- return /* @__PURE__ */ jsxRuntime.jsx(core.Grid, { grow: true, ...rest, children });
556
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid, { grow: true, ...rest, children });
558
557
  }
559
558
  function ObjectFieldTemplate(props) {
560
559
  const {
@@ -563,7 +562,7 @@
563
562
  disabled,
564
563
  properties,
565
564
  optionalDataControl,
566
- onAddClick,
565
+ onAddProperty,
567
566
  readonly,
568
567
  required,
569
568
  schema,
@@ -586,7 +585,7 @@
586
585
  const gridCols = typeof uiOptions?.gridCols === "number" && uiOptions?.gridCols || void 0;
587
586
  const gridSpacing = uiOptions?.gridSpacing;
588
587
  const gridVerticalSpacing = uiOptions?.gridVerticalSpacing;
589
- return /* @__PURE__ */ jsxRuntime.jsxs(core.Container, { id: fieldPathId.$id, p: 0, children: [
588
+ return /* @__PURE__ */ jsxRuntime.jsxs(core$1.Container, { id: fieldPathId.$id, p: 0, children: [
590
589
  title && /* @__PURE__ */ jsxRuntime.jsx(
591
590
  TitleFieldTemplate,
592
591
  {
@@ -610,7 +609,7 @@
610
609
  }
611
610
  ),
612
611
  /* @__PURE__ */ jsxRuntime.jsxs(
613
- core.SimpleGrid,
612
+ core$1.SimpleGrid,
614
613
  {
615
614
  cols: gridCols,
616
615
  spacing: gridSpacing,
@@ -618,16 +617,16 @@
618
617
  mb: "sm",
619
618
  children: [
620
619
  !showOptionalDataControlInTitle ? optionalDataControl : void 0,
621
- properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ jsxRuntime.jsx(core.Box, { children: element.content }, element.name))
620
+ properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { children: element.content }, element.name))
622
621
  ]
623
622
  }
624
623
  ),
625
- utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { mt: "xs", justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
624
+ utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(core$1.Group, { mt: "xs", justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
626
625
  AddButton2,
627
626
  {
628
627
  id: utils.buttonId(fieldPathId, "add"),
629
628
  disabled: disabled || readonly,
630
- onClick: onAddClick(schema),
629
+ onClick: onAddProperty,
631
630
  className: "rjsf-object-property-expand",
632
631
  uiSchema,
633
632
  registry
@@ -666,11 +665,11 @@
666
665
  }
667
666
  function TitleField(props) {
668
667
  const { id, title, optionalDataControl } = props;
669
- let heading = title ? /* @__PURE__ */ jsxRuntime.jsx(core.Title, { id, order: 3, fw: "normal", children: title }) : null;
668
+ let heading = title ? /* @__PURE__ */ jsxRuntime.jsx(core$1.Title, { id, order: 3, fw: "normal", children: title }) : null;
670
669
  if (optionalDataControl) {
671
- heading = /* @__PURE__ */ jsxRuntime.jsxs(core.Grid, { children: [
672
- /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: "auto", children: heading }),
673
- /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: "content", children: optionalDataControl })
670
+ heading = /* @__PURE__ */ jsxRuntime.jsxs(core$1.Grid, { children: [
671
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: "auto", children: heading }),
672
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: "content", children: optionalDataControl })
674
673
  ] });
675
674
  }
676
675
  return heading;
@@ -686,8 +685,8 @@
686
685
  disabled,
687
686
  schema,
688
687
  uiSchema,
689
- onKeyChange,
690
- onDropPropertyClick,
688
+ onKeyRenameBlur,
689
+ onRemoveProperty,
691
690
  registry,
692
691
  children
693
692
  } = props;
@@ -695,10 +694,6 @@
695
694
  const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
696
695
  const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
697
696
  const additional = utils.ADDITIONAL_PROPERTY_FLAG in schema;
698
- const handleBlur = react.useCallback(
699
- ({ target }) => onKeyChange(target && target.value),
700
- [onKeyChange]
701
- );
702
697
  if (!additional) {
703
698
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children });
704
699
  }
@@ -707,10 +702,10 @@
707
702
  ...uiSchema,
708
703
  [utils.UI_OPTIONS_KEY]: { ...uiOptions, block: true }
709
704
  };
710
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children: /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "end", justify: "center", children: [
711
- /* @__PURE__ */ jsxRuntime.jsxs(core.Grid, { w: "100%", align: "center", children: [
712
- /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: 6, className: "form-additional", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-group", children: /* @__PURE__ */ jsxRuntime.jsx(
713
- core.TextInput,
705
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children: /* @__PURE__ */ jsxRuntime.jsxs(core$1.Flex, { gap: "xs", align: "end", justify: "center", children: [
706
+ /* @__PURE__ */ jsxRuntime.jsxs(core$1.Grid, { w: "100%", align: "center", children: [
707
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: 6, className: "form-additional", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-group", children: /* @__PURE__ */ jsxRuntime.jsx(
708
+ core$1.TextInput,
714
709
  {
715
710
  className: "form-group",
716
711
  label: keyLabel,
@@ -719,10 +714,10 @@
719
714
  disabled: disabled || readonly,
720
715
  id: `${id}-key`,
721
716
  name: `${id}-key`,
722
- onBlur: !readonly ? handleBlur : void 0
717
+ onBlur: !readonly ? onKeyRenameBlur : void 0
723
718
  }
724
719
  ) }) }),
725
- /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: 6, className: "form-additional", children })
720
+ /* @__PURE__ */ jsxRuntime.jsx(core$1.Grid.Col, { span: 6, className: "form-additional", children })
726
721
  ] }),
727
722
  /* @__PURE__ */ jsxRuntime.jsx(
728
723
  RemoveButton2,
@@ -731,7 +726,7 @@
731
726
  iconType: "sm",
732
727
  className: "rjsf-array-item-remove",
733
728
  disabled: disabled || readonly,
734
- onClick: onDropPropertyClick(label),
729
+ onClick: onRemoveProperty,
735
730
  uiSchema: buttonUiOptions,
736
731
  registry
737
732
  }
@@ -739,7 +734,7 @@
739
734
  ] }) });
740
735
  }
741
736
  function MultiSchemaFieldTemplate({ selector, optionSchemaField }) {
742
- return /* @__PURE__ */ jsxRuntime.jsxs(core.Stack, { style: { marginBottom: "1rem" }, children: [
737
+ return /* @__PURE__ */ jsxRuntime.jsxs(core$1.Stack, { style: { marginBottom: "1rem" }, children: [
743
738
  selector,
744
739
  optionSchemaField
745
740
  ] });
@@ -767,66 +762,21 @@
767
762
  };
768
763
  }
769
764
  var templates_default = generateTemplates();
770
- function readyForChange(state) {
771
- return Object.values(state).every((value) => value !== -1);
765
+ function AltDateTimeWidget(props) {
766
+ const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
767
+ return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { time: true, ...props });
772
768
  }
773
769
  function AltDateWidget(props) {
774
- const {
775
- id,
776
- value,
777
- required,
778
- disabled,
779
- readonly,
780
- label,
781
- hideLabel,
782
- rawErrors,
783
- options,
784
- onChange,
785
- showTime = false,
786
- registry
787
- } = props;
770
+ const { id, required, disabled, readonly, label, hideLabel, rawErrors, options, registry } = props;
788
771
  const { translateString } = registry;
789
- const [state, setState] = react.useState(utils.parseDateString(value, showTime));
790
- react.useEffect(() => {
791
- setState(utils.parseDateString(value, showTime));
792
- }, [showTime, value]);
793
- const handleChange = react.useCallback(
794
- (property, nextValue) => {
795
- const nextState = {
796
- ...state,
797
- [property]: typeof nextValue === "undefined" ? -1 : nextValue
798
- };
799
- if (readyForChange(nextState)) {
800
- onChange(utils.toDateString(nextState, showTime));
801
- } else {
802
- setState(nextState);
803
- }
804
- },
805
- [state, onChange, showTime]
806
- );
807
- const handleSetNow = react.useCallback(() => {
808
- if (!disabled && !readonly) {
809
- const nextState = utils.parseDateString((/* @__PURE__ */ new Date()).toJSON(), showTime);
810
- onChange(utils.toDateString(nextState, showTime));
811
- }
812
- }, [disabled, readonly, showTime, onChange]);
813
- const handleClear = react.useCallback(() => {
814
- if (!disabled && !readonly) {
815
- onChange("");
816
- }
817
- }, [disabled, readonly, onChange]);
772
+ const { elements, handleChange, handleClear, handleSetNow } = utils.useAltDateWidgetProps(props);
818
773
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
819
- !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
820
- /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "center", wrap: "nowrap", children: [
821
- utils.getDateElementProps(
822
- state,
823
- showTime,
824
- options.yearsRange,
825
- options.format
826
- ).map((elemProps, i) => {
827
- const elemId = id + "_" + elemProps.type;
828
- return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
829
- core.Select,
774
+ !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Label, { id: utils.titleId(id), required, children: label }),
775
+ /* @__PURE__ */ jsxRuntime.jsxs(core$1.Flex, { gap: "xs", align: "center", wrap: "nowrap", children: [
776
+ elements.map((elemProps, i) => {
777
+ const elemId = `${id}_${elemProps.type}`;
778
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
779
+ core$1.Select,
830
780
  {
831
781
  id: elemId,
832
782
  name: elemId,
@@ -834,7 +784,7 @@
834
784
  disabled: disabled || readonly,
835
785
  data: utils.dateRangeOptions(elemProps.range[0], elemProps.range[1]).map((item) => item.value.toString()),
836
786
  value: !elemProps.value || elemProps.value < 0 ? null : elemProps.value.toString(),
837
- onChange: (v) => handleChange(elemProps.type, v),
787
+ onChange: (v) => handleChange(elemProps.type, v || void 0),
838
788
  searchable: false,
839
789
  allowDeselect: false,
840
790
  comboboxProps: { withinPortal: false },
@@ -842,25 +792,14 @@
842
792
  }
843
793
  ) }, i);
844
794
  }),
845
- /* @__PURE__ */ jsxRuntime.jsxs(core.Group, { wrap: "nowrap", gap: 3, children: [
846
- (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core.Button, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }),
847
- (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core.Button, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) })
795
+ /* @__PURE__ */ jsxRuntime.jsxs(core$1.Group, { wrap: "nowrap", gap: 3, children: [
796
+ (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core$1.Button, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }),
797
+ (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core$1.Button, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) })
848
798
  ] })
849
799
  ] }),
850
- rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
800
+ rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
851
801
  ] });
852
802
  }
853
- AltDateWidget.defaultProps = {
854
- showTime: false
855
- };
856
- function AltDateTimeWidget(props) {
857
- const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
858
- return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { showTime: true, ...props });
859
- }
860
- AltDateTimeWidget.defaultProps = {
861
- ...AltDateWidget?.defaultProps,
862
- showTime: true
863
- };
864
803
  var dateParser = (input, format) => {
865
804
  if (!input) {
866
805
  return null;
@@ -1023,6 +962,7 @@
1023
962
  function CheckboxesWidget(props) {
1024
963
  const {
1025
964
  id,
965
+ htmlName,
1026
966
  value,
1027
967
  required,
1028
968
  disabled,
@@ -1064,9 +1004,9 @@
1064
1004
  );
1065
1005
  const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
1066
1006
  return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1067
- !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
1007
+ !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Label, { id: utils.titleId(id), required, children: label }),
1068
1008
  /* @__PURE__ */ jsxRuntime.jsx(
1069
- core.Checkbox.Group,
1009
+ core$1.Checkbox.Group,
1070
1010
  {
1071
1011
  id,
1072
1012
  value: selectedIndexes,
@@ -1076,11 +1016,11 @@
1076
1016
  error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1077
1017
  "aria-describedby": utils.ariaDescribedByIds(id),
1078
1018
  ...themeProps,
1079
- children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
1080
- core.Checkbox,
1019
+ children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core$1.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
1020
+ core$1.Checkbox,
1081
1021
  {
1082
1022
  id: utils.optionId(id, i),
1083
- name: id,
1023
+ name: htmlName || id,
1084
1024
  value: String(i),
1085
1025
  label: option.label,
1086
1026
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
@@ -1098,6 +1038,7 @@
1098
1038
  const {
1099
1039
  id,
1100
1040
  name,
1041
+ htmlName,
1101
1042
  value = false,
1102
1043
  required,
1103
1044
  disabled,
@@ -1157,10 +1098,10 @@
1157
1098
  }
1158
1099
  ),
1159
1100
  /* @__PURE__ */ jsxRuntime.jsx(
1160
- core.Checkbox,
1101
+ core$1.Checkbox,
1161
1102
  {
1162
1103
  id,
1163
- name,
1104
+ name: htmlName || name,
1164
1105
  label: utils.labelValue(label || void 0, hideLabel, false),
1165
1106
  disabled: disabled || readonly,
1166
1107
  required,
@@ -1218,7 +1159,7 @@
1218
1159
  [onFocus, id]
1219
1160
  );
1220
1161
  return /* @__PURE__ */ jsxRuntime.jsx(
1221
- core.ColorInput,
1162
+ core$1.ColorInput,
1222
1163
  {
1223
1164
  id,
1224
1165
  name,
@@ -1238,62 +1179,6 @@
1238
1179
  }
1239
1180
  );
1240
1181
  }
1241
- function addNameToDataURL(dataURL, name) {
1242
- if (dataURL === null) {
1243
- return null;
1244
- }
1245
- return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
1246
- }
1247
- function processFile(file) {
1248
- const { name, size, type } = file;
1249
- return new Promise((resolve, reject) => {
1250
- const reader = new window.FileReader();
1251
- reader.onerror = reject;
1252
- reader.onload = (event) => {
1253
- if (typeof event.target?.result === "string") {
1254
- resolve({
1255
- dataURL: addNameToDataURL(event.target.result, name),
1256
- name,
1257
- size,
1258
- type
1259
- });
1260
- } else {
1261
- resolve({
1262
- dataURL: null,
1263
- name,
1264
- size,
1265
- type
1266
- });
1267
- }
1268
- };
1269
- reader.readAsDataURL(file);
1270
- });
1271
- }
1272
- function processFiles(files) {
1273
- return Promise.all(Array.from(files).map(processFile));
1274
- }
1275
- function extractFileInfo(dataURLs) {
1276
- return dataURLs.reduce((acc, dataURL) => {
1277
- if (!dataURL) {
1278
- return acc;
1279
- }
1280
- try {
1281
- const { blob, name } = utils.dataURItoBlob(dataURL);
1282
- return [
1283
- ...acc,
1284
- {
1285
- dataURL,
1286
- name,
1287
- size: blob.size,
1288
- type: blob.type
1289
- }
1290
- ];
1291
- } catch (e) {
1292
- console.log(e);
1293
- return acc;
1294
- }
1295
- }, []);
1296
- }
1297
1182
  function FileWidget(props) {
1298
1183
  const {
1299
1184
  id,
@@ -1311,46 +1196,24 @@
1311
1196
  multiple,
1312
1197
  onChange
1313
1198
  } = props;
1199
+ const { filesInfo, handleChange, handleRemove } = utils.useFileWidgetProps(value, onChange, multiple);
1314
1200
  const themeProps = cleanupOptions(options);
1315
- const handleChange = react.useCallback(
1201
+ const handleOnChange = react.useCallback(
1316
1202
  (files) => {
1317
1203
  if (typeof files === "object") {
1318
- processFiles(multiple ? files : [files]).then((filesInfoEvent) => {
1319
- const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
1320
- if (multiple) {
1321
- onChange(value.concat(newValue));
1322
- } else {
1323
- onChange(newValue[0]);
1324
- }
1325
- });
1326
- }
1327
- return;
1328
- },
1329
- [multiple, value, onChange]
1330
- );
1331
- const handleRemoveFile = react.useCallback(
1332
- (index) => {
1333
- if (multiple) {
1334
- const newValue = value.filter((_, i) => i !== index);
1335
- onChange(newValue);
1336
- } else {
1337
- onChange(void 0);
1204
+ handleChange(files);
1338
1205
  }
1339
1206
  },
1340
- [multiple, value, onChange]
1341
- );
1342
- const ValueComponent = react.useCallback(
1343
- (props2) => {
1344
- const filesInfo = props2.value ? extractFileInfo(Array.isArray(props2.value) ? props2.value : [props2.value]) : null;
1345
- if (Array.isArray(filesInfo) && filesInfo.length > 0) {
1346
- return /* @__PURE__ */ jsxRuntime.jsx(core.Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Pill, { withRemoveButton: true, onRemove: () => handleRemoveFile(index), children: file.name }, index)) });
1347
- }
1348
- return null;
1349
- },
1350
- [handleRemoveFile]
1207
+ [handleChange]
1351
1208
  );
1209
+ const ValueComponent = react.useCallback(() => {
1210
+ if (Array.isArray(filesInfo) && filesInfo.length > 0) {
1211
+ return /* @__PURE__ */ jsxRuntime.jsx(core$1.Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Pill, { withRemoveButton: true, onRemove: () => handleRemove(index), children: file.name }, index)) });
1212
+ }
1213
+ return null;
1214
+ }, [handleRemove, filesInfo]);
1352
1215
  return /* @__PURE__ */ jsxRuntime.jsx(
1353
- core.FileInput,
1216
+ core$1.FileInput,
1354
1217
  {
1355
1218
  id,
1356
1219
  name,
@@ -1362,7 +1225,7 @@
1362
1225
  label: utils.labelValue(label || void 0, hideLabel, false),
1363
1226
  multiple: !!multiple,
1364
1227
  valueComponent: ValueComponent,
1365
- onChange: handleChange,
1228
+ onChange: handleOnChange,
1366
1229
  error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1367
1230
  ...themeProps,
1368
1231
  "aria-describedby": utils.ariaDescribedByIds(id)
@@ -1412,7 +1275,7 @@
1412
1275
  [onFocus, id]
1413
1276
  );
1414
1277
  return /* @__PURE__ */ jsxRuntime.jsx(
1415
- core.PasswordInput,
1278
+ core$1.PasswordInput,
1416
1279
  {
1417
1280
  id,
1418
1281
  name,
@@ -1434,6 +1297,7 @@
1434
1297
  function RadioWidget(props) {
1435
1298
  const {
1436
1299
  id,
1300
+ htmlName,
1437
1301
  value,
1438
1302
  required,
1439
1303
  disabled,
@@ -1475,10 +1339,10 @@
1475
1339
  );
1476
1340
  const selected = utils.enumOptionsIndexForValue(value, enumOptions);
1477
1341
  return /* @__PURE__ */ jsxRuntime.jsx(
1478
- core.Radio.Group,
1342
+ core$1.Radio.Group,
1479
1343
  {
1480
1344
  id,
1481
- name: id,
1345
+ name: htmlName || id,
1482
1346
  value: selected,
1483
1347
  label: !hideLabel ? label : void 0,
1484
1348
  onChange: handleChange,
@@ -1487,8 +1351,8 @@
1487
1351
  error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1488
1352
  "aria-describedby": utils.ariaDescribedByIds(id),
1489
1353
  ...themeProps,
1490
- children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
1491
- core.Radio,
1354
+ children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core$1.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
1355
+ core$1.Radio,
1492
1356
  {
1493
1357
  id: utils.optionId(id, i),
1494
1358
  value: String(i),
@@ -1542,10 +1406,10 @@
1542
1406
  }
1543
1407
  }, [onFocus, id, value]);
1544
1408
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1545
- !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
1546
- options?.description && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Description, { children: options.description }),
1409
+ !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Label, { id: utils.titleId(id), required, children: label }),
1410
+ options?.description && /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Description, { children: options.description }),
1547
1411
  /* @__PURE__ */ jsxRuntime.jsx(
1548
- core.Slider,
1412
+ core$1.Slider,
1549
1413
  {
1550
1414
  id,
1551
1415
  name,
@@ -1562,12 +1426,13 @@
1562
1426
  "aria-describedby": utils.ariaDescribedByIds(id)
1563
1427
  }
1564
1428
  ),
1565
- rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Input.Error, { children: error }, `range-widget-input-errors-${index}`))
1429
+ rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core$1.Input.Error, { children: error }, `range-widget-input-errors-${index}`))
1566
1430
  ] });
1567
1431
  }
1568
1432
  function SelectWidget(props) {
1569
1433
  const {
1570
1434
  id,
1435
+ htmlName,
1571
1436
  value,
1572
1437
  placeholder,
1573
1438
  required,
@@ -1621,12 +1486,12 @@
1621
1486
  }
1622
1487
  return [];
1623
1488
  }, [enumDisabled, enumOptions]);
1624
- const Component = multiple ? core.MultiSelect : core.Select;
1489
+ const Component = multiple ? core$1.MultiSelect : core$1.Select;
1625
1490
  return /* @__PURE__ */ jsxRuntime.jsx(
1626
1491
  Component,
1627
1492
  {
1628
1493
  id,
1629
- name: id,
1494
+ name: htmlName || id,
1630
1495
  label: utils.labelValue(label || void 0, hideLabel, false),
1631
1496
  data: selectOptions,
1632
1497
  value: multiple ? selectedIndexes : selectedIndexes,
@@ -1649,6 +1514,7 @@
1649
1514
  const {
1650
1515
  id,
1651
1516
  name,
1517
+ htmlName,
1652
1518
  value,
1653
1519
  placeholder,
1654
1520
  required,
@@ -1688,10 +1554,10 @@
1688
1554
  [onFocus, id]
1689
1555
  );
1690
1556
  return /* @__PURE__ */ jsxRuntime.jsx(
1691
- core.Textarea,
1557
+ core$1.Textarea,
1692
1558
  {
1693
1559
  id,
1694
- name,
1560
+ name: htmlName || name,
1695
1561
  value: value || "",
1696
1562
  placeholder: placeholder || void 0,
1697
1563
  required,
@@ -1741,7 +1607,7 @@
1741
1607
 
1742
1608
  // src/Form/index.ts
1743
1609
  function generateForm() {
1744
- return core$1.withTheme(generateTheme());
1610
+ return core.withTheme(generateTheme());
1745
1611
  }
1746
1612
  var Form_default = generateForm();
1747
1613