@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
@@ -52,11 +52,6 @@ function ArrayFieldTemplate(props) {
52
52
  registry,
53
53
  uiOptions
54
54
  );
55
- const ArrayFieldItemTemplate2 = getTemplate2(
56
- "ArrayFieldItemTemplate",
57
- registry,
58
- uiOptions
59
- );
60
55
  const ArrayFieldTitleTemplate2 = getTemplate2(
61
56
  "ArrayFieldTitleTemplate",
62
57
  registry,
@@ -91,7 +86,7 @@ function ArrayFieldTemplate(props) {
91
86
  ),
92
87
  /* @__PURE__ */ jsxs2(Box2, { className: "row rjsf-array-item-list", children: [
93
88
  !showOptionalDataControlInTitle ? optionalDataControl : void 0,
94
- items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx2(ArrayFieldItemTemplate2, { ...itemProps }, key))
89
+ items
95
90
  ] }),
96
91
  canAdd && /* @__PURE__ */ jsx2(Group2, { justify: "flex-end", children: /* @__PURE__ */ jsx2(
97
92
  AddButton2,
@@ -176,6 +171,7 @@ import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
176
171
  function BaseInputTemplate(props) {
177
172
  const {
178
173
  id,
174
+ htmlName,
179
175
  type,
180
176
  schema,
181
177
  value,
@@ -221,7 +217,7 @@ function BaseInputTemplate(props) {
221
217
  NumberInput,
222
218
  {
223
219
  id,
224
- name: id,
220
+ name: htmlName || id,
225
221
  label: labelValue(label || void 0, hideLabel, false),
226
222
  required,
227
223
  autoFocus: autofocus,
@@ -243,7 +239,7 @@ function BaseInputTemplate(props) {
243
239
  TextInput,
244
240
  {
245
241
  id,
246
- name: id,
242
+ name: htmlName || id,
247
243
  label: labelValue(label || void 0, hideLabel, false),
248
244
  required,
249
245
  autoFocus: autofocus,
@@ -625,8 +621,11 @@ import { Text as Text2 } from "@mantine/core";
625
621
  import { jsx as jsx13 } from "react/jsx-runtime";
626
622
  function FieldHelpTemplate(props) {
627
623
  const { fieldPathId, help } = props;
624
+ if (!help) {
625
+ return null;
626
+ }
628
627
  const id = helpId(fieldPathId);
629
- return !help ? null : /* @__PURE__ */ jsx13(Text2, { id, size: "sm", my: "xs", c: "dimmed", children: help });
628
+ return /* @__PURE__ */ jsx13(Text2, { id, size: "sm", my: "xs", c: "dimmed", children: help });
630
629
  }
631
630
 
632
631
  // src/templates/GridTemplate.tsx
@@ -661,7 +660,7 @@ function ObjectFieldTemplate(props) {
661
660
  disabled,
662
661
  properties,
663
662
  optionalDataControl,
664
- onAddClick,
663
+ onAddProperty,
665
664
  readonly,
666
665
  required,
667
666
  schema,
@@ -725,7 +724,7 @@ function ObjectFieldTemplate(props) {
725
724
  {
726
725
  id: buttonId2(fieldPathId, "add"),
727
726
  disabled: disabled || readonly,
728
- onClick: onAddClick(schema),
727
+ onClick: onAddProperty,
729
728
  className: "rjsf-object-property-expand",
730
729
  uiSchema,
731
730
  registry
@@ -782,7 +781,6 @@ function TitleField(props) {
782
781
  }
783
782
 
784
783
  // src/templates/WrapIfAdditionalTemplate.tsx
785
- import { useCallback as useCallback2 } from "react";
786
784
  import {
787
785
  ADDITIONAL_PROPERTY_FLAG,
788
786
  UI_OPTIONS_KEY,
@@ -802,8 +800,8 @@ function WrapIfAdditionalTemplate(props) {
802
800
  disabled,
803
801
  schema,
804
802
  uiSchema,
805
- onKeyChange,
806
- onDropPropertyClick,
803
+ onKeyRenameBlur,
804
+ onRemoveProperty,
807
805
  registry,
808
806
  children
809
807
  } = props;
@@ -811,10 +809,6 @@ function WrapIfAdditionalTemplate(props) {
811
809
  const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
812
810
  const keyLabel = translateString(TranslatableString4.KeyLabel, [label]);
813
811
  const additional = ADDITIONAL_PROPERTY_FLAG in schema;
814
- const handleBlur = useCallback2(
815
- ({ target }) => onKeyChange(target && target.value),
816
- [onKeyChange]
817
- );
818
812
  if (!additional) {
819
813
  return /* @__PURE__ */ jsx18("div", { className: classNames, style, children });
820
814
  }
@@ -835,7 +829,7 @@ function WrapIfAdditionalTemplate(props) {
835
829
  disabled: disabled || readonly,
836
830
  id: `${id}-key`,
837
831
  name: `${id}-key`,
838
- onBlur: !readonly ? handleBlur : void 0
832
+ onBlur: !readonly ? onKeyRenameBlur : void 0
839
833
  }
840
834
  ) }) }),
841
835
  /* @__PURE__ */ jsx18(Grid3.Col, { span: 6, className: "form-additional", children })
@@ -847,7 +841,7 @@ function WrapIfAdditionalTemplate(props) {
847
841
  iconType: "sm",
848
842
  className: "rjsf-array-item-remove",
849
843
  disabled: disabled || readonly,
850
- onClick: onDropPropertyClick(label),
844
+ onClick: onRemoveProperty,
851
845
  uiSchema: buttonUiOptions,
852
846
  registry
853
847
  }
@@ -892,78 +886,33 @@ var templates_default = generateTemplates();
892
886
  import dayjs2 from "dayjs";
893
887
  import customParseFormat from "dayjs/plugin/customParseFormat";
894
888
 
889
+ // src/widgets/DateTime/AltDateTimeWidget.tsx
890
+ import { jsx as jsx19 } from "react/jsx-runtime";
891
+ function AltDateTimeWidget(props) {
892
+ const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
893
+ return /* @__PURE__ */ jsx19(AltDateWidget2, { time: true, ...props });
894
+ }
895
+
895
896
  // src/widgets/DateTime/AltDateWidget.tsx
896
- import { useCallback as useCallback3, useEffect, useState } from "react";
897
897
  import {
898
898
  ariaDescribedByIds as ariaDescribedByIds2,
899
899
  dateRangeOptions,
900
- parseDateString,
901
- toDateString,
902
- getDateElementProps,
903
900
  titleId as titleId3,
904
- TranslatableString as TranslatableString5
901
+ TranslatableString as TranslatableString5,
902
+ useAltDateWidgetProps
905
903
  } from "@rjsf/utils";
906
904
  import { Flex as Flex3, Box as Box6, Group as Group4, Button as Button2, Select, Input } from "@mantine/core";
907
- import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
908
- function readyForChange(state) {
909
- return Object.values(state).every((value) => value !== -1);
910
- }
905
+ import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
911
906
  function AltDateWidget(props) {
912
- const {
913
- id,
914
- value,
915
- required,
916
- disabled,
917
- readonly,
918
- label,
919
- hideLabel,
920
- rawErrors,
921
- options,
922
- onChange,
923
- showTime = false,
924
- registry
925
- } = props;
907
+ const { id, required, disabled, readonly, label, hideLabel, rawErrors, options, registry } = props;
926
908
  const { translateString } = registry;
927
- const [state, setState] = useState(parseDateString(value, showTime));
928
- useEffect(() => {
929
- setState(parseDateString(value, showTime));
930
- }, [showTime, value]);
931
- const handleChange = useCallback3(
932
- (property, nextValue) => {
933
- const nextState = {
934
- ...state,
935
- [property]: typeof nextValue === "undefined" ? -1 : nextValue
936
- };
937
- if (readyForChange(nextState)) {
938
- onChange(toDateString(nextState, showTime));
939
- } else {
940
- setState(nextState);
941
- }
942
- },
943
- [state, onChange, showTime]
944
- );
945
- const handleSetNow = useCallback3(() => {
946
- if (!disabled && !readonly) {
947
- const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), showTime);
948
- onChange(toDateString(nextState, showTime));
949
- }
950
- }, [disabled, readonly, showTime, onChange]);
951
- const handleClear = useCallback3(() => {
952
- if (!disabled && !readonly) {
953
- onChange("");
954
- }
955
- }, [disabled, readonly, onChange]);
909
+ const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps(props);
956
910
  return /* @__PURE__ */ jsxs10(Fragment2, { children: [
957
- !hideLabel && !!label && /* @__PURE__ */ jsx19(Input.Label, { id: titleId3(id), required, children: label }),
911
+ !hideLabel && !!label && /* @__PURE__ */ jsx20(Input.Label, { id: titleId3(id), required, children: label }),
958
912
  /* @__PURE__ */ jsxs10(Flex3, { gap: "xs", align: "center", wrap: "nowrap", children: [
959
- getDateElementProps(
960
- state,
961
- showTime,
962
- options.yearsRange,
963
- options.format
964
- ).map((elemProps, i) => {
965
- const elemId = id + "_" + elemProps.type;
966
- return /* @__PURE__ */ jsx19(Box6, { children: /* @__PURE__ */ jsx19(
913
+ elements.map((elemProps, i) => {
914
+ const elemId = `${id}_${elemProps.type}`;
915
+ return /* @__PURE__ */ jsx20(Box6, { children: /* @__PURE__ */ jsx20(
967
916
  Select,
968
917
  {
969
918
  id: elemId,
@@ -972,7 +921,7 @@ function AltDateWidget(props) {
972
921
  disabled: disabled || readonly,
973
922
  data: dateRangeOptions(elemProps.range[0], elemProps.range[1]).map((item) => item.value.toString()),
974
923
  value: !elemProps.value || elemProps.value < 0 ? null : elemProps.value.toString(),
975
- onChange: (v) => handleChange(elemProps.type, v),
924
+ onChange: (v) => handleChange(elemProps.type, v || void 0),
976
925
  searchable: false,
977
926
  allowDeselect: false,
978
927
  comboboxProps: { withinPortal: false },
@@ -981,30 +930,16 @@ function AltDateWidget(props) {
981
930
  ) }, i);
982
931
  }),
983
932
  /* @__PURE__ */ jsxs10(Group4, { wrap: "nowrap", gap: 3, children: [
984
- (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx19(Button2, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(TranslatableString5.NowLabel) }),
985
- (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx19(Button2, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(TranslatableString5.ClearLabel) })
933
+ (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx20(Button2, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(TranslatableString5.NowLabel) }),
934
+ (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx20(Button2, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(TranslatableString5.ClearLabel) })
986
935
  ] })
987
936
  ] }),
988
- rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsx19(Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
937
+ rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsx20(Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
989
938
  ] });
990
939
  }
991
- AltDateWidget.defaultProps = {
992
- showTime: false
993
- };
994
-
995
- // src/widgets/DateTime/AltDateTimeWidget.tsx
996
- import { jsx as jsx20 } from "react/jsx-runtime";
997
- function AltDateTimeWidget(props) {
998
- const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
999
- return /* @__PURE__ */ jsx20(AltDateWidget2, { showTime: true, ...props });
1000
- }
1001
- AltDateTimeWidget.defaultProps = {
1002
- ...AltDateWidget?.defaultProps,
1003
- showTime: true
1004
- };
1005
940
 
1006
941
  // src/widgets/DateTime/DateTimeInput.tsx
1007
- import { useCallback as useCallback4 } from "react";
942
+ import { useCallback as useCallback2 } from "react";
1008
943
  import {
1009
944
  ariaDescribedByIds as ariaDescribedByIds3,
1010
945
  labelValue as labelValue2
@@ -1045,18 +980,18 @@ function DateTimeInput(props) {
1045
980
  valueFormat,
1046
981
  displayFormat
1047
982
  } = props;
1048
- const handleChange = useCallback4(
983
+ const handleChange = useCallback2(
1049
984
  (nextValue) => {
1050
985
  onChange(dateFormat(nextValue, valueFormat));
1051
986
  },
1052
987
  [onChange, valueFormat]
1053
988
  );
1054
- const handleBlur = useCallback4(() => {
989
+ const handleBlur = useCallback2(() => {
1055
990
  if (onBlur) {
1056
991
  onBlur(id, value);
1057
992
  }
1058
993
  }, [onBlur, id, value]);
1059
- const handleFocus = useCallback4(() => {
994
+ const handleFocus = useCallback2(() => {
1060
995
  if (onFocus) {
1061
996
  onFocus(id, value);
1062
997
  }
@@ -1117,7 +1052,7 @@ function DateTimeWidget(props) {
1117
1052
  }
1118
1053
 
1119
1054
  // src/widgets/DateTime/TimeWidget.tsx
1120
- import { useCallback as useCallback5 } from "react";
1055
+ import { useCallback as useCallback3 } from "react";
1121
1056
  import {
1122
1057
  labelValue as labelValue3,
1123
1058
  ariaDescribedByIds as ariaDescribedByIds4
@@ -1143,13 +1078,13 @@ function TimeWidget(props) {
1143
1078
  onFocus
1144
1079
  } = props;
1145
1080
  const emptyValue = options.emptyValue || "";
1146
- const handleChange = useCallback5(
1081
+ const handleChange = useCallback3(
1147
1082
  (e) => {
1148
1083
  onChange(e.target.value === "" ? emptyValue : e.target.value);
1149
1084
  },
1150
1085
  [onChange, emptyValue]
1151
1086
  );
1152
- const handleBlur = useCallback5(
1087
+ const handleBlur = useCallback3(
1153
1088
  ({ target }) => {
1154
1089
  if (onBlur) {
1155
1090
  onBlur(id, target && target.value);
@@ -1157,7 +1092,7 @@ function TimeWidget(props) {
1157
1092
  },
1158
1093
  [onBlur, id]
1159
1094
  );
1160
- const handleFocus = useCallback5(
1095
+ const handleFocus = useCallback3(
1161
1096
  ({ target }) => {
1162
1097
  if (onFocus) {
1163
1098
  onFocus(id, target && target.value);
@@ -1188,7 +1123,7 @@ function TimeWidget(props) {
1188
1123
  }
1189
1124
 
1190
1125
  // src/widgets/CheckboxesWidget.tsx
1191
- import { useCallback as useCallback6 } from "react";
1126
+ import { useCallback as useCallback4 } from "react";
1192
1127
  import {
1193
1128
  ariaDescribedByIds as ariaDescribedByIds5,
1194
1129
  enumOptionsValueForIndex,
@@ -1201,6 +1136,7 @@ import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs11 } from "react/jsx-r
1201
1136
  function CheckboxesWidget(props) {
1202
1137
  const {
1203
1138
  id,
1139
+ htmlName,
1204
1140
  value,
1205
1141
  required,
1206
1142
  disabled,
@@ -1216,7 +1152,7 @@ function CheckboxesWidget(props) {
1216
1152
  } = props;
1217
1153
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
1218
1154
  const themeProps = cleanupOptions(options);
1219
- const handleChange = useCallback6(
1155
+ const handleChange = useCallback4(
1220
1156
  (nextValue) => {
1221
1157
  if (!disabled && !readonly && onChange) {
1222
1158
  onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
@@ -1224,7 +1160,7 @@ function CheckboxesWidget(props) {
1224
1160
  },
1225
1161
  [onChange, disabled, readonly, enumOptions, emptyValue]
1226
1162
  );
1227
- const handleBlur = useCallback6(
1163
+ const handleBlur = useCallback4(
1228
1164
  ({ target }) => {
1229
1165
  if (onBlur) {
1230
1166
  onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
@@ -1232,7 +1168,7 @@ function CheckboxesWidget(props) {
1232
1168
  },
1233
1169
  [onBlur, id, enumOptions, emptyValue]
1234
1170
  );
1235
- const handleFocus = useCallback6(
1171
+ const handleFocus = useCallback4(
1236
1172
  ({ target }) => {
1237
1173
  if (onFocus) {
1238
1174
  onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
@@ -1258,7 +1194,7 @@ function CheckboxesWidget(props) {
1258
1194
  Checkbox,
1259
1195
  {
1260
1196
  id: optionId(id, i),
1261
- name: id,
1197
+ name: htmlName || id,
1262
1198
  value: String(i),
1263
1199
  label: option.label,
1264
1200
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
@@ -1274,7 +1210,7 @@ function CheckboxesWidget(props) {
1274
1210
  }
1275
1211
 
1276
1212
  // src/widgets/CheckboxWidget.tsx
1277
- import { useCallback as useCallback7 } from "react";
1213
+ import { useCallback as useCallback5 } from "react";
1278
1214
  import {
1279
1215
  descriptionId as descriptionId2,
1280
1216
  getTemplate as getTemplate5,
@@ -1287,6 +1223,7 @@ function CheckboxWidget(props) {
1287
1223
  const {
1288
1224
  id,
1289
1225
  name,
1226
+ htmlName,
1290
1227
  value = false,
1291
1228
  required,
1292
1229
  disabled,
@@ -1309,7 +1246,7 @@ function CheckboxWidget(props) {
1309
1246
  registry,
1310
1247
  options
1311
1248
  );
1312
- const handleCheckboxChange = useCallback7(
1249
+ const handleCheckboxChange = useCallback5(
1313
1250
  (e) => {
1314
1251
  if (!disabled && !readonly && onChange) {
1315
1252
  onChange(e.currentTarget.checked);
@@ -1317,7 +1254,7 @@ function CheckboxWidget(props) {
1317
1254
  },
1318
1255
  [onChange, disabled, readonly]
1319
1256
  );
1320
- const handleBlur = useCallback7(
1257
+ const handleBlur = useCallback5(
1321
1258
  ({ target }) => {
1322
1259
  if (onBlur) {
1323
1260
  onBlur(id, target.checked);
@@ -1325,7 +1262,7 @@ function CheckboxWidget(props) {
1325
1262
  },
1326
1263
  [onBlur, id]
1327
1264
  );
1328
- const handleFocus = useCallback7(
1265
+ const handleFocus = useCallback5(
1329
1266
  ({ target }) => {
1330
1267
  if (onFocus) {
1331
1268
  onFocus(id, target.checked);
@@ -1349,7 +1286,7 @@ function CheckboxWidget(props) {
1349
1286
  Checkbox2,
1350
1287
  {
1351
1288
  id,
1352
- name,
1289
+ name: htmlName || name,
1353
1290
  label: labelValue4(label || void 0, hideLabel, false),
1354
1291
  disabled: disabled || readonly,
1355
1292
  required,
@@ -1367,7 +1304,7 @@ function CheckboxWidget(props) {
1367
1304
  }
1368
1305
 
1369
1306
  // src/widgets/ColorWidget.tsx
1370
- import { useCallback as useCallback8 } from "react";
1307
+ import { useCallback as useCallback6 } from "react";
1371
1308
  import {
1372
1309
  labelValue as labelValue5,
1373
1310
  ariaDescribedByIds as ariaDescribedByIds7
@@ -1393,13 +1330,13 @@ function ColorWidget(props) {
1393
1330
  onFocus
1394
1331
  } = props;
1395
1332
  const themeProps = cleanupOptions(options);
1396
- const handleChange = useCallback8(
1333
+ const handleChange = useCallback6(
1397
1334
  (nextValue) => {
1398
1335
  onChange(nextValue);
1399
1336
  },
1400
1337
  [onChange]
1401
1338
  );
1402
- const handleBlur = useCallback8(
1339
+ const handleBlur = useCallback6(
1403
1340
  ({ target }) => {
1404
1341
  if (onBlur) {
1405
1342
  onBlur(id, target && target.value);
@@ -1407,7 +1344,7 @@ function ColorWidget(props) {
1407
1344
  },
1408
1345
  [onBlur, id]
1409
1346
  );
1410
- const handleFocus = useCallback8(
1347
+ const handleFocus = useCallback6(
1411
1348
  ({ target }) => {
1412
1349
  if (onFocus) {
1413
1350
  onFocus(id, target && target.value);
@@ -1438,70 +1375,14 @@ function ColorWidget(props) {
1438
1375
  }
1439
1376
 
1440
1377
  // src/widgets/FileWidget.tsx
1441
- import { useCallback as useCallback9 } from "react";
1378
+ import { useCallback as useCallback7 } from "react";
1442
1379
  import {
1443
- dataURItoBlob,
1444
1380
  ariaDescribedByIds as ariaDescribedByIds8,
1445
- labelValue as labelValue6
1381
+ labelValue as labelValue6,
1382
+ useFileWidgetProps
1446
1383
  } from "@rjsf/utils";
1447
1384
  import { FileInput, Pill } from "@mantine/core";
1448
1385
  import { jsx as jsx28 } from "react/jsx-runtime";
1449
- function addNameToDataURL(dataURL, name) {
1450
- if (dataURL === null) {
1451
- return null;
1452
- }
1453
- return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
1454
- }
1455
- function processFile(file) {
1456
- const { name, size, type } = file;
1457
- return new Promise((resolve, reject) => {
1458
- const reader = new window.FileReader();
1459
- reader.onerror = reject;
1460
- reader.onload = (event) => {
1461
- if (typeof event.target?.result === "string") {
1462
- resolve({
1463
- dataURL: addNameToDataURL(event.target.result, name),
1464
- name,
1465
- size,
1466
- type
1467
- });
1468
- } else {
1469
- resolve({
1470
- dataURL: null,
1471
- name,
1472
- size,
1473
- type
1474
- });
1475
- }
1476
- };
1477
- reader.readAsDataURL(file);
1478
- });
1479
- }
1480
- function processFiles(files) {
1481
- return Promise.all(Array.from(files).map(processFile));
1482
- }
1483
- function extractFileInfo(dataURLs) {
1484
- return dataURLs.reduce((acc, dataURL) => {
1485
- if (!dataURL) {
1486
- return acc;
1487
- }
1488
- try {
1489
- const { blob, name } = dataURItoBlob(dataURL);
1490
- return [
1491
- ...acc,
1492
- {
1493
- dataURL,
1494
- name,
1495
- size: blob.size,
1496
- type: blob.type
1497
- }
1498
- ];
1499
- } catch (e) {
1500
- console.log(e);
1501
- return acc;
1502
- }
1503
- }, []);
1504
- }
1505
1386
  function FileWidget(props) {
1506
1387
  const {
1507
1388
  id,
@@ -1519,44 +1400,22 @@ function FileWidget(props) {
1519
1400
  multiple,
1520
1401
  onChange
1521
1402
  } = props;
1403
+ const { filesInfo, handleChange, handleRemove } = useFileWidgetProps(value, onChange, multiple);
1522
1404
  const themeProps = cleanupOptions(options);
1523
- const handleChange = useCallback9(
1405
+ const handleOnChange = useCallback7(
1524
1406
  (files) => {
1525
1407
  if (typeof files === "object") {
1526
- processFiles(multiple ? files : [files]).then((filesInfoEvent) => {
1527
- const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
1528
- if (multiple) {
1529
- onChange(value.concat(newValue));
1530
- } else {
1531
- onChange(newValue[0]);
1532
- }
1533
- });
1534
- }
1535
- return;
1536
- },
1537
- [multiple, value, onChange]
1538
- );
1539
- const handleRemoveFile = useCallback9(
1540
- (index) => {
1541
- if (multiple) {
1542
- const newValue = value.filter((_, i) => i !== index);
1543
- onChange(newValue);
1544
- } else {
1545
- onChange(void 0);
1408
+ handleChange(files);
1546
1409
  }
1547
1410
  },
1548
- [multiple, value, onChange]
1549
- );
1550
- const ValueComponent = useCallback9(
1551
- (props2) => {
1552
- const filesInfo = props2.value ? extractFileInfo(Array.isArray(props2.value) ? props2.value : [props2.value]) : null;
1553
- if (Array.isArray(filesInfo) && filesInfo.length > 0) {
1554
- return /* @__PURE__ */ jsx28(Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsx28(Pill, { withRemoveButton: true, onRemove: () => handleRemoveFile(index), children: file.name }, index)) });
1555
- }
1556
- return null;
1557
- },
1558
- [handleRemoveFile]
1411
+ [handleChange]
1559
1412
  );
1413
+ const ValueComponent = useCallback7(() => {
1414
+ if (Array.isArray(filesInfo) && filesInfo.length > 0) {
1415
+ return /* @__PURE__ */ jsx28(Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsx28(Pill, { withRemoveButton: true, onRemove: () => handleRemove(index), children: file.name }, index)) });
1416
+ }
1417
+ return null;
1418
+ }, [handleRemove, filesInfo]);
1560
1419
  return /* @__PURE__ */ jsx28(
1561
1420
  FileInput,
1562
1421
  {
@@ -1570,7 +1429,7 @@ function FileWidget(props) {
1570
1429
  label: labelValue6(label || void 0, hideLabel, false),
1571
1430
  multiple: !!multiple,
1572
1431
  valueComponent: ValueComponent,
1573
- onChange: handleChange,
1432
+ onChange: handleOnChange,
1574
1433
  error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1575
1434
  ...themeProps,
1576
1435
  "aria-describedby": ariaDescribedByIds8(id)
@@ -1579,7 +1438,7 @@ function FileWidget(props) {
1579
1438
  }
1580
1439
 
1581
1440
  // src/widgets/PasswordWidget.tsx
1582
- import { useCallback as useCallback10 } from "react";
1441
+ import { useCallback as useCallback8 } from "react";
1583
1442
  import {
1584
1443
  ariaDescribedByIds as ariaDescribedByIds9,
1585
1444
  labelValue as labelValue7
@@ -1606,13 +1465,13 @@ function PasswordWidget(props) {
1606
1465
  } = props;
1607
1466
  const emptyValue = options.emptyValue || "";
1608
1467
  const themeProps = cleanupOptions(options);
1609
- const handleChange = useCallback10(
1468
+ const handleChange = useCallback8(
1610
1469
  (e) => {
1611
1470
  onChange(e.target.value === "" ? emptyValue : e.target.value);
1612
1471
  },
1613
1472
  [onChange, emptyValue]
1614
1473
  );
1615
- const handleBlur = useCallback10(
1474
+ const handleBlur = useCallback8(
1616
1475
  ({ target }) => {
1617
1476
  if (onBlur) {
1618
1477
  onBlur(id, target && target.value);
@@ -1620,7 +1479,7 @@ function PasswordWidget(props) {
1620
1479
  },
1621
1480
  [onBlur, id]
1622
1481
  );
1623
- const handleFocus = useCallback10(
1482
+ const handleFocus = useCallback8(
1624
1483
  ({ target }) => {
1625
1484
  if (onFocus) {
1626
1485
  onFocus(id, target && target.value);
@@ -1650,7 +1509,7 @@ function PasswordWidget(props) {
1650
1509
  }
1651
1510
 
1652
1511
  // src/widgets/RadioWidget.tsx
1653
- import { useCallback as useCallback11 } from "react";
1512
+ import { useCallback as useCallback9 } from "react";
1654
1513
  import {
1655
1514
  ariaDescribedByIds as ariaDescribedByIds10,
1656
1515
  enumOptionsIndexForValue as enumOptionsIndexForValue2,
@@ -1662,6 +1521,7 @@ import { jsx as jsx30 } from "react/jsx-runtime";
1662
1521
  function RadioWidget(props) {
1663
1522
  const {
1664
1523
  id,
1524
+ htmlName,
1665
1525
  value,
1666
1526
  required,
1667
1527
  disabled,
@@ -1677,7 +1537,7 @@ function RadioWidget(props) {
1677
1537
  } = props;
1678
1538
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
1679
1539
  const themeProps = cleanupOptions(options);
1680
- const handleChange = useCallback11(
1540
+ const handleChange = useCallback9(
1681
1541
  (nextValue) => {
1682
1542
  if (!disabled && !readonly && onChange) {
1683
1543
  onChange(enumOptionsValueForIndex2(nextValue, enumOptions, emptyValue));
@@ -1685,7 +1545,7 @@ function RadioWidget(props) {
1685
1545
  },
1686
1546
  [onChange, disabled, readonly, enumOptions, emptyValue]
1687
1547
  );
1688
- const handleBlur = useCallback11(
1548
+ const handleBlur = useCallback9(
1689
1549
  ({ target }) => {
1690
1550
  if (onBlur) {
1691
1551
  onBlur(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
@@ -1693,7 +1553,7 @@ function RadioWidget(props) {
1693
1553
  },
1694
1554
  [onBlur, id, enumOptions, emptyValue]
1695
1555
  );
1696
- const handleFocus = useCallback11(
1556
+ const handleFocus = useCallback9(
1697
1557
  ({ target }) => {
1698
1558
  if (onFocus) {
1699
1559
  onFocus(id, enumOptionsValueForIndex2(target && target.value, enumOptions, emptyValue));
@@ -1706,7 +1566,7 @@ function RadioWidget(props) {
1706
1566
  Radio.Group,
1707
1567
  {
1708
1568
  id,
1709
- name: id,
1569
+ name: htmlName || id,
1710
1570
  value: selected,
1711
1571
  label: !hideLabel ? label : void 0,
1712
1572
  onChange: handleChange,
@@ -1733,7 +1593,7 @@ function RadioWidget(props) {
1733
1593
  }
1734
1594
 
1735
1595
  // src/widgets/RangeWidget.tsx
1736
- import { useCallback as useCallback12 } from "react";
1596
+ import { useCallback as useCallback10 } from "react";
1737
1597
  import {
1738
1598
  ariaDescribedByIds as ariaDescribedByIds11,
1739
1599
  rangeSpec,
@@ -1761,7 +1621,7 @@ function RangeWidget(props) {
1761
1621
  } = props;
1762
1622
  const themeProps = cleanupOptions(options);
1763
1623
  const { min, max, step } = rangeSpec(schema);
1764
- const handleChange = useCallback12(
1624
+ const handleChange = useCallback10(
1765
1625
  (nextValue) => {
1766
1626
  if (!disabled && !readonly && onChange) {
1767
1627
  onChange(nextValue);
@@ -1769,12 +1629,12 @@ function RangeWidget(props) {
1769
1629
  },
1770
1630
  [onChange, disabled, readonly]
1771
1631
  );
1772
- const handleBlur = useCallback12(() => {
1632
+ const handleBlur = useCallback10(() => {
1773
1633
  if (onBlur) {
1774
1634
  onBlur(id, value);
1775
1635
  }
1776
1636
  }, [onBlur, id, value]);
1777
- const handleFocus = useCallback12(() => {
1637
+ const handleFocus = useCallback10(() => {
1778
1638
  if (onFocus) {
1779
1639
  onFocus(id, value);
1780
1640
  }
@@ -1805,7 +1665,7 @@ function RangeWidget(props) {
1805
1665
  }
1806
1666
 
1807
1667
  // src/widgets/SelectWidget.tsx
1808
- import { useCallback as useCallback13, useMemo } from "react";
1668
+ import { useCallback as useCallback11, useMemo } from "react";
1809
1669
  import {
1810
1670
  ariaDescribedByIds as ariaDescribedByIds12,
1811
1671
  enumOptionsIndexForValue as enumOptionsIndexForValue3,
@@ -1817,6 +1677,7 @@ import { jsx as jsx32 } from "react/jsx-runtime";
1817
1677
  function SelectWidget(props) {
1818
1678
  const {
1819
1679
  id,
1680
+ htmlName,
1820
1681
  value,
1821
1682
  placeholder,
1822
1683
  required,
@@ -1834,7 +1695,7 @@ function SelectWidget(props) {
1834
1695
  } = props;
1835
1696
  const { enumOptions, enumDisabled, emptyValue } = options;
1836
1697
  const themeProps = cleanupOptions(options);
1837
- const handleChange = useCallback13(
1698
+ const handleChange = useCallback11(
1838
1699
  (nextValue) => {
1839
1700
  if (!disabled && !readonly && onChange) {
1840
1701
  onChange(enumOptionsValueForIndex3(nextValue, enumOptions, emptyValue));
@@ -1842,7 +1703,7 @@ function SelectWidget(props) {
1842
1703
  },
1843
1704
  [onChange, disabled, readonly, enumOptions, emptyValue]
1844
1705
  );
1845
- const handleBlur = useCallback13(
1706
+ const handleBlur = useCallback11(
1846
1707
  ({ target }) => {
1847
1708
  if (onBlur) {
1848
1709
  onBlur(id, enumOptionsValueForIndex3(target && target.value, enumOptions, emptyValue));
@@ -1850,7 +1711,7 @@ function SelectWidget(props) {
1850
1711
  },
1851
1712
  [onBlur, id, enumOptions, emptyValue]
1852
1713
  );
1853
- const handleFocus = useCallback13(
1714
+ const handleFocus = useCallback11(
1854
1715
  ({ target }) => {
1855
1716
  if (onFocus) {
1856
1717
  onFocus(id, enumOptionsValueForIndex3(target && target.value, enumOptions, emptyValue));
@@ -1875,7 +1736,7 @@ function SelectWidget(props) {
1875
1736
  Component,
1876
1737
  {
1877
1738
  id,
1878
- name: id,
1739
+ name: htmlName || id,
1879
1740
  label: labelValue8(label || void 0, hideLabel, false),
1880
1741
  data: selectOptions,
1881
1742
  value: multiple ? selectedIndexes : selectedIndexes,
@@ -1896,7 +1757,7 @@ function SelectWidget(props) {
1896
1757
  }
1897
1758
 
1898
1759
  // src/widgets/TextareaWidget.tsx
1899
- import { useCallback as useCallback14 } from "react";
1760
+ import { useCallback as useCallback12 } from "react";
1900
1761
  import {
1901
1762
  labelValue as labelValue9,
1902
1763
  ariaDescribedByIds as ariaDescribedByIds13
@@ -1907,6 +1768,7 @@ function TextareaWidget(props) {
1907
1768
  const {
1908
1769
  id,
1909
1770
  name,
1771
+ htmlName,
1910
1772
  value,
1911
1773
  placeholder,
1912
1774
  required,
@@ -1923,13 +1785,13 @@ function TextareaWidget(props) {
1923
1785
  } = props;
1924
1786
  const themeProps = cleanupOptions(options);
1925
1787
  const emptyValue = options?.emptyValue ?? "";
1926
- const handleChange = useCallback14(
1788
+ const handleChange = useCallback12(
1927
1789
  (e) => {
1928
1790
  onChange(e.target.value === "" ? emptyValue : e.target.value);
1929
1791
  },
1930
1792
  [onChange, emptyValue]
1931
1793
  );
1932
- const handleBlur = useCallback14(
1794
+ const handleBlur = useCallback12(
1933
1795
  ({ target }) => {
1934
1796
  if (onBlur) {
1935
1797
  onBlur(id, target && target.value);
@@ -1937,7 +1799,7 @@ function TextareaWidget(props) {
1937
1799
  },
1938
1800
  [onBlur, id]
1939
1801
  );
1940
- const handleFocus = useCallback14(
1802
+ const handleFocus = useCallback12(
1941
1803
  ({ target }) => {
1942
1804
  if (onFocus) {
1943
1805
  onFocus(id, target && target.value);
@@ -1949,7 +1811,7 @@ function TextareaWidget(props) {
1949
1811
  Textarea,
1950
1812
  {
1951
1813
  id,
1952
- name,
1814
+ name: htmlName || name,
1953
1815
  value: value || "",
1954
1816
  placeholder: placeholder || void 0,
1955
1817
  required,