@rjsf/mantine 6.4.2 → 6.5.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 (42) hide show
  1. package/dist/index.cjs +59 -45
  2. package/dist/index.cjs.map +2 -2
  3. package/dist/mantine.esm.js +69 -49
  4. package/dist/mantine.esm.js.map +3 -3
  5. package/dist/mantine.umd.js +59 -45
  6. package/lib/Form/index.js +1 -1
  7. package/lib/Theme/index.js +2 -2
  8. package/lib/index.d.ts +4 -4
  9. package/lib/index.js +4 -4
  10. package/lib/templates/BaseInputTemplate.js +3 -2
  11. package/lib/templates/BaseInputTemplate.js.map +1 -1
  12. package/lib/templates/ButtonTemplates/AddButton.js +2 -2
  13. package/lib/templates/ButtonTemplates/IconButton.js +1 -1
  14. package/lib/templates/ButtonTemplates/index.js +3 -3
  15. package/lib/templates/ErrorList.js +1 -1
  16. package/lib/templates/OptionalDataControlsTemplate.js +2 -2
  17. package/lib/templates/WrapIfAdditionalTemplate.js +1 -1
  18. package/lib/templates/WrapIfAdditionalTemplate.js.map +1 -1
  19. package/lib/templates/index.js +16 -16
  20. package/lib/tsconfig.tsbuildinfo +1 -1
  21. package/lib/widgets/CheckboxesWidget.js +10 -9
  22. package/lib/widgets/CheckboxesWidget.js.map +1 -1
  23. package/lib/widgets/ColorWidget.js +1 -1
  24. package/lib/widgets/DateTime/DateTimeWidget.js +1 -1
  25. package/lib/widgets/DateTime/DateWidget.js +1 -1
  26. package/lib/widgets/DateTime/index.d.ts +5 -5
  27. package/lib/widgets/DateTime/index.js +5 -5
  28. package/lib/widgets/FileWidget.js +1 -1
  29. package/lib/widgets/PasswordWidget.js +1 -1
  30. package/lib/widgets/RadioWidget.js +10 -9
  31. package/lib/widgets/RadioWidget.js.map +1 -1
  32. package/lib/widgets/RangeWidget.js +1 -1
  33. package/lib/widgets/SelectWidget.js +30 -13
  34. package/lib/widgets/SelectWidget.js.map +1 -1
  35. package/lib/widgets/TextareaWidget.js +1 -1
  36. package/lib/widgets/index.js +10 -10
  37. package/package.json +10 -10
  38. package/src/templates/BaseInputTemplate.tsx +5 -1
  39. package/src/templates/WrapIfAdditionalTemplate.tsx +1 -0
  40. package/src/widgets/CheckboxesWidget.tsx +11 -8
  41. package/src/widgets/RadioWidget.tsx +11 -8
  42. package/src/widgets/SelectWidget.tsx +40 -32
package/dist/index.cjs CHANGED
@@ -277,17 +277,20 @@ function BaseInputTemplate(props) {
277
277
  error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
278
278
  list: schema.examples ? (0, import_utils4.examplesId)(id) : void 0
279
279
  };
280
+ const { min, max, ...restInputProps } = inputProps;
280
281
  const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
281
282
  import_core4.NumberInput,
282
283
  {
283
284
  onChange: !readonly ? handleNumberChange : void 0,
284
285
  ...componentProps,
285
- ...inputProps,
286
+ ...restInputProps,
286
287
  ...themeProps,
287
288
  step: typeof inputProps.step === "number" ? inputProps.step : 1,
288
289
  type: "text",
289
290
  description,
290
291
  value,
292
+ min: typeof min === "number" ? min : void 0,
293
+ max: typeof max === "number" ? max : void 0,
291
294
  "aria-describedby": (0, import_utils4.ariaDescribedByIds)(id, !!schema.examples)
292
295
  }
293
296
  ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -872,7 +875,8 @@ function WrapIfAdditionalTemplate(props) {
872
875
  id: `${id}-key`,
873
876
  name: `${id}-key`,
874
877
  onBlur: !readonly ? onKeyRenameBlur : void 0
875
- }
878
+ },
879
+ label
876
880
  ) }),
877
881
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_core18.Grid.Col, { span: 6, className: "form-additional", children })
878
882
  ] }),
@@ -1175,30 +1179,31 @@ function CheckboxesWidget(props) {
1175
1179
  onFocus
1176
1180
  } = props;
1177
1181
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
1182
+ const optionValueFormat = (0, import_utils18.getOptionValueFormat)(options);
1178
1183
  const themeProps = cleanupOptions(options);
1179
1184
  const handleChange = (0, import_react4.useCallback)(
1180
1185
  (nextValue) => {
1181
1186
  if (!disabled && !readonly && onChange) {
1182
- onChange((0, import_utils18.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
1187
+ onChange((0, import_utils18.enumOptionValueDecoder)(nextValue, enumOptions, optionValueFormat, emptyValue));
1183
1188
  }
1184
1189
  },
1185
- [onChange, disabled, readonly, enumOptions, emptyValue]
1190
+ [onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat]
1186
1191
  );
1187
1192
  const handleBlur = (0, import_react4.useCallback)(
1188
1193
  ({ target }) => {
1189
1194
  if (onBlur) {
1190
- onBlur(id, (0, import_utils18.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
1195
+ onBlur(id, (0, import_utils18.enumOptionValueDecoder)(target.value, enumOptions, optionValueFormat, emptyValue));
1191
1196
  }
1192
1197
  },
1193
- [onBlur, id, enumOptions, emptyValue]
1198
+ [onBlur, id, enumOptions, emptyValue, optionValueFormat]
1194
1199
  );
1195
1200
  const handleFocus = (0, import_react4.useCallback)(
1196
1201
  ({ target }) => {
1197
1202
  if (onFocus) {
1198
- onFocus(id, (0, import_utils18.enumOptionsValueForIndex)(target.value, enumOptions, emptyValue));
1203
+ onFocus(id, (0, import_utils18.enumOptionValueDecoder)(target.value, enumOptions, optionValueFormat, emptyValue));
1199
1204
  }
1200
1205
  },
1201
- [onFocus, id, enumOptions, emptyValue]
1206
+ [onFocus, id, enumOptions, emptyValue, optionValueFormat]
1202
1207
  );
1203
1208
  const selectedIndexes = (0, import_utils18.enumOptionsIndexForValue)(value, enumOptions, true);
1204
1209
  return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
@@ -1219,7 +1224,7 @@ function CheckboxesWidget(props) {
1219
1224
  {
1220
1225
  id: (0, import_utils18.optionId)(id, i),
1221
1226
  name: htmlName || id,
1222
- value: String(i),
1227
+ value: (0, import_utils18.enumOptionValueEncoder)(option.value, i, optionValueFormat),
1223
1228
  label: option.label,
1224
1229
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
1225
1230
  autoFocus: i === 0 && autofocus,
@@ -1538,30 +1543,31 @@ function RadioWidget(props) {
1538
1543
  onFocus
1539
1544
  } = props;
1540
1545
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
1546
+ const optionValueFormat = (0, import_utils27.getOptionValueFormat)(options);
1541
1547
  const themeProps = cleanupOptions(options);
1542
1548
  const handleChange = (0, import_react9.useCallback)(
1543
1549
  (nextValue) => {
1544
1550
  if (!disabled && !readonly && onChange) {
1545
- onChange((0, import_utils27.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
1551
+ onChange((0, import_utils27.enumOptionValueDecoder)(nextValue, enumOptions, optionValueFormat, emptyValue));
1546
1552
  }
1547
1553
  },
1548
- [onChange, disabled, readonly, enumOptions, emptyValue]
1554
+ [onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat]
1549
1555
  );
1550
1556
  const handleBlur = (0, import_react9.useCallback)(
1551
1557
  ({ target }) => {
1552
1558
  if (onBlur) {
1553
- onBlur(id, (0, import_utils27.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
1559
+ onBlur(id, (0, import_utils27.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
1554
1560
  }
1555
1561
  },
1556
- [onBlur, id, enumOptions, emptyValue]
1562
+ [onBlur, id, enumOptions, emptyValue, optionValueFormat]
1557
1563
  );
1558
1564
  const handleFocus = (0, import_react9.useCallback)(
1559
1565
  ({ target }) => {
1560
1566
  if (onFocus) {
1561
- onFocus(id, (0, import_utils27.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
1567
+ onFocus(id, (0, import_utils27.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
1562
1568
  }
1563
1569
  },
1564
- [onFocus, id, enumOptions, emptyValue]
1570
+ [onFocus, id, enumOptions, emptyValue, optionValueFormat]
1565
1571
  );
1566
1572
  const selected = (0, import_utils27.enumOptionsIndexForValue)(value, enumOptions);
1567
1573
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
@@ -1581,7 +1587,7 @@ function RadioWidget(props) {
1581
1587
  import_core26.Radio,
1582
1588
  {
1583
1589
  id: (0, import_utils27.optionId)(id, i),
1584
- value: String(i),
1590
+ value: (0, import_utils27.enumOptionValueEncoder)(option.value, i, optionValueFormat),
1585
1591
  label: option.label,
1586
1592
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
1587
1593
  autoFocus: i === 0 && autofocus,
@@ -1687,64 +1693,72 @@ function SelectWidget(props) {
1687
1693
  onFocus
1688
1694
  } = props;
1689
1695
  const { enumOptions, enumDisabled, emptyValue } = options;
1696
+ const optionValueFormat = (0, import_utils31.getOptionValueFormat)(options);
1690
1697
  const themeProps = cleanupOptions(options);
1691
1698
  const handleChange = (0, import_react11.useCallback)(
1692
1699
  (nextValue) => {
1693
1700
  if (!disabled && !readonly && onChange) {
1694
- onChange((0, import_utils31.enumOptionsValueForIndex)(nextValue, enumOptions, emptyValue));
1701
+ onChange((0, import_utils31.enumOptionValueDecoder)(nextValue, enumOptions, optionValueFormat, emptyValue));
1695
1702
  }
1696
1703
  },
1697
- [onChange, disabled, readonly, enumOptions, emptyValue]
1704
+ [onChange, disabled, readonly, enumOptions, emptyValue, optionValueFormat]
1698
1705
  );
1699
1706
  const handleBlur = (0, import_react11.useCallback)(
1700
1707
  ({ target }) => {
1701
1708
  if (onBlur) {
1702
- onBlur(id, (0, import_utils31.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
1709
+ onBlur(id, (0, import_utils31.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
1703
1710
  }
1704
1711
  },
1705
- [onBlur, id, enumOptions, emptyValue]
1712
+ [onBlur, id, enumOptions, emptyValue, optionValueFormat]
1706
1713
  );
1707
1714
  const handleFocus = (0, import_react11.useCallback)(
1708
1715
  ({ target }) => {
1709
1716
  if (onFocus) {
1710
- onFocus(id, (0, import_utils31.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue));
1717
+ onFocus(id, (0, import_utils31.enumOptionValueDecoder)(target && target.value, enumOptions, optionValueFormat, emptyValue));
1711
1718
  }
1712
1719
  },
1713
- [onFocus, id, enumOptions, emptyValue]
1720
+ [onFocus, id, enumOptions, emptyValue, optionValueFormat]
1714
1721
  );
1715
- const selectedIndexes = (0, import_utils31.enumOptionsIndexForValue)(value, enumOptions, multiple);
1716
1722
  const selectOptions = (0, import_react11.useMemo)(() => {
1717
1723
  if (Array.isArray(enumOptions)) {
1718
1724
  return enumOptions.map((option, index) => ({
1719
1725
  key: String(index),
1720
- value: String(index),
1726
+ value: (0, import_utils31.enumOptionValueEncoder)(option.value, index, optionValueFormat),
1721
1727
  label: option.label,
1722
1728
  disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1
1723
1729
  }));
1724
1730
  }
1725
1731
  return [];
1726
- }, [enumDisabled, enumOptions]);
1727
- const Component = multiple ? import_core28.MultiSelect : import_core28.Select;
1728
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1729
- Component,
1732
+ }, [enumDisabled, enumOptions, optionValueFormat]);
1733
+ const sharedProps = {
1734
+ id,
1735
+ name: htmlName || id,
1736
+ label: (0, import_utils31.labelValue)(label || void 0, hideLabel, false),
1737
+ data: selectOptions,
1738
+ onChange: !readonly ? handleChange : void 0,
1739
+ onBlur: !readonly ? handleBlur : void 0,
1740
+ onFocus: !readonly ? handleFocus : void 0,
1741
+ autoFocus: autofocus,
1742
+ placeholder,
1743
+ disabled: disabled || readonly,
1744
+ required,
1745
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1746
+ searchable: true,
1747
+ "aria-describedby": (0, import_utils31.ariaDescribedByIds)(id),
1748
+ comboboxProps: { withinPortal: false },
1749
+ ...themeProps
1750
+ };
1751
+ return multiple ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1752
+ import_core28.MultiSelect,
1730
1753
  {
1731
- id,
1732
- name: htmlName || id,
1733
- label: (0, import_utils31.labelValue)(label || void 0, hideLabel, false),
1734
- data: selectOptions,
1735
- value: multiple ? selectedIndexes : selectedIndexes,
1736
- onChange: !readonly ? handleChange : void 0,
1737
- onBlur: !readonly ? handleBlur : void 0,
1738
- onFocus: !readonly ? handleFocus : void 0,
1739
- autoFocus: autofocus,
1740
- placeholder,
1741
- disabled: disabled || readonly,
1742
- required,
1743
- error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1744
- searchable: true,
1745
- ...themeProps,
1746
- "aria-describedby": (0, import_utils31.ariaDescribedByIds)(id),
1747
- comboboxProps: { withinPortal: false }
1754
+ ...sharedProps,
1755
+ value: (0, import_utils31.enumOptionSelectedValue)(value, enumOptions, true, optionValueFormat, [])
1756
+ }
1757
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
1758
+ import_core28.Select,
1759
+ {
1760
+ ...sharedProps,
1761
+ value: (0, import_utils31.enumOptionSelectedValue)(value, enumOptions, false, optionValueFormat, null)
1748
1762
  }
1749
1763
  );
1750
1764
  }