@rjsf/daisyui 6.4.2 → 6.5.0

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.
@@ -628,7 +628,8 @@
628
628
  onBlur: onKeyRenameBlur,
629
629
  defaultValue: label,
630
630
  disabled: disabled || readonly
631
- }
631
+ },
632
+ label
632
633
  )
633
634
  ] }),
634
635
  children,
@@ -831,7 +832,8 @@
831
832
  onFocus,
832
833
  onBlur
833
834
  }) {
834
- const { enumOptions } = options;
835
+ const { enumOptions, emptyValue } = options;
836
+ const optionValueFormat = utils.getOptionValueFormat(options);
835
837
  const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
836
838
  const isChecked = react.useCallback(
837
839
  (option) => {
@@ -865,26 +867,18 @@
865
867
  const handleFocus = react.useCallback(
866
868
  (event) => {
867
869
  if (onFocus) {
868
- const index = Number(event.target.dataset.index);
869
- const option = enumOptions?.[index];
870
- if (option) {
871
- onFocus(id, option.value);
872
- }
870
+ onFocus(id, utils.enumOptionValueDecoder(event.target.value, enumOptions, optionValueFormat, emptyValue));
873
871
  }
874
872
  },
875
- [onFocus, id, enumOptions]
873
+ [onFocus, id, enumOptions, optionValueFormat, emptyValue]
876
874
  );
877
875
  const handleBlur = react.useCallback(
878
876
  (event) => {
879
877
  if (onBlur) {
880
- const index = Number(event.target.dataset.index);
881
- const option = enumOptions?.[index];
882
- if (option) {
883
- onBlur(id, option.value);
884
- }
878
+ onBlur(id, utils.enumOptionValueDecoder(event.target.value, enumOptions, optionValueFormat, emptyValue));
885
879
  }
886
880
  },
887
- [onBlur, id, enumOptions]
881
+ [onBlur, id, enumOptions, optionValueFormat, emptyValue]
888
882
  );
889
883
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-control", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center cursor-pointer gap-2", children: [
890
884
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -894,6 +888,7 @@
894
888
  id: `${id}-${option.value}`,
895
889
  className: "checkbox",
896
890
  name: htmlName || id,
891
+ value: utils.enumOptionValueEncoder(option.value, index, optionValueFormat),
897
892
  checked: isChecked(option),
898
893
  required,
899
894
  disabled: disabled || readonly,
@@ -1416,11 +1411,9 @@
1416
1411
  onFocus,
1417
1412
  onBlur
1418
1413
  }) {
1419
- const { enumOptions } = options;
1414
+ const { enumOptions, emptyValue } = options;
1415
+ const optionValueFormat = utils.getOptionValueFormat(options);
1420
1416
  const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
1421
- const getValue = (option) => {
1422
- return option.value;
1423
- };
1424
1417
  const isChecked = (option) => {
1425
1418
  if (isEnumeratedObject) {
1426
1419
  return value && value.name === option.value.name;
@@ -1430,33 +1423,28 @@
1430
1423
  const handleFocus = react.useCallback(
1431
1424
  (event) => {
1432
1425
  if (onFocus) {
1433
- const index = Number(event.target.dataset.index);
1434
- const optionValue = enumOptions?.[index]?.value;
1435
- onFocus(id, optionValue);
1426
+ onFocus(id, utils.enumOptionValueDecoder(event.target.value, enumOptions, optionValueFormat, emptyValue));
1436
1427
  }
1437
1428
  },
1438
- [onFocus, id, enumOptions]
1429
+ [onFocus, id, enumOptions, optionValueFormat, emptyValue]
1439
1430
  );
1440
1431
  const handleBlur = react.useCallback(
1441
1432
  (event) => {
1442
1433
  if (onBlur) {
1443
- const index = Number(event.target.dataset.index);
1444
- const optionValue = enumOptions?.[index]?.value;
1445
- onBlur(id, optionValue);
1434
+ onBlur(id, utils.enumOptionValueDecoder(event.target.value, enumOptions, optionValueFormat, emptyValue));
1446
1435
  }
1447
1436
  },
1448
- [onBlur, id, enumOptions]
1437
+ [onBlur, id, enumOptions, optionValueFormat, emptyValue]
1449
1438
  );
1450
1439
  const handleChange = react.useCallback(
1451
1440
  (event) => {
1452
- const index = Number(event.target.dataset.index);
1453
- const option = enumOptions?.[index];
1454
- if (option) {
1455
- onChange(isEnumeratedObject ? option.value : option.value);
1441
+ const decoded = utils.enumOptionValueDecoder(event.target.value, enumOptions, optionValueFormat, emptyValue);
1442
+ if (decoded !== void 0) {
1443
+ onChange(decoded);
1456
1444
  event.target.blur();
1457
1445
  }
1458
1446
  },
1459
- [onChange, isEnumeratedObject, enumOptions]
1447
+ [onChange, enumOptions, optionValueFormat, emptyValue]
1460
1448
  );
1461
1449
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-control", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center cursor-pointer gap-2", children: [
1462
1450
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1466,7 +1454,7 @@
1466
1454
  id: `${id}-${option.value}`,
1467
1455
  className: "radio",
1468
1456
  name: htmlName || id,
1469
- value: getValue(option),
1457
+ value: utils.enumOptionValueEncoder(option.value, index, optionValueFormat),
1470
1458
  checked: isChecked(option),
1471
1459
  required,
1472
1460
  disabled: disabled || readonly,
@@ -1614,6 +1602,7 @@
1614
1602
  onFocus
1615
1603
  }) {
1616
1604
  const { enumOptions, emptyValue: optEmptyVal } = options;
1605
+ const optionValueFormat = utils.getOptionValueFormat(options);
1617
1606
  multiple = typeof multiple === "undefined" ? false : !!multiple;
1618
1607
  const getDisplayValue = (val) => {
1619
1608
  if (!val) {
@@ -1636,37 +1625,38 @@
1636
1625
  }
1637
1626
  if (multiple) {
1638
1627
  const currentValue = Array.isArray(value) ? value : [];
1639
- const optionValue = isEnumeratedObject ? enumOptions[index].value : utils.enumOptionsValueForIndex(String(index), enumOptions, optEmptyVal);
1628
+ const optionValue = isEnumeratedObject ? enumOptions[index].value : utils.enumOptionValueDecoder(String(index), enumOptions, optionValueFormat, optEmptyVal);
1640
1629
  const newValue = currentValue.includes(optionValue) ? currentValue.filter((v) => v !== optionValue) : [...currentValue, optionValue];
1641
1630
  onChange(newValue);
1642
1631
  } else {
1643
1632
  onChange(
1644
- isEnumeratedObject ? enumOptions[index].value : utils.enumOptionsValueForIndex(String(index), enumOptions, optEmptyVal)
1633
+ isEnumeratedObject ? enumOptions[index].value : utils.enumOptionValueDecoder(String(index), enumOptions, optionValueFormat, optEmptyVal)
1645
1634
  );
1646
1635
  }
1647
1636
  },
1648
- [value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, onChange]
1637
+ [value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, optionValueFormat, onChange]
1649
1638
  );
1650
1639
  const _onBlur = react.useCallback(
1651
1640
  ({ target }) => {
1652
1641
  const dataValue = target?.getAttribute("data-value");
1653
1642
  if (dataValue !== null) {
1654
- onBlur(id, utils.enumOptionsValueForIndex(dataValue, enumOptions, optEmptyVal));
1643
+ onBlur(id, utils.enumOptionValueDecoder(dataValue, enumOptions, optionValueFormat, optEmptyVal));
1655
1644
  }
1656
1645
  },
1657
- [onBlur, id, enumOptions, optEmptyVal]
1646
+ [onBlur, id, enumOptions, optEmptyVal, optionValueFormat]
1658
1647
  );
1659
1648
  const _onFocus = react.useCallback(
1660
1649
  ({ target }) => {
1661
1650
  const dataValue = target?.getAttribute("data-value");
1662
1651
  if (dataValue !== null) {
1663
- onFocus(id, utils.enumOptionsValueForIndex(dataValue, enumOptions, optEmptyVal));
1652
+ onFocus(id, utils.enumOptionValueDecoder(dataValue, enumOptions, optionValueFormat, optEmptyVal));
1664
1653
  }
1665
1654
  },
1666
- [onFocus, id, enumOptions, optEmptyVal]
1655
+ [onFocus, id, enumOptions, optEmptyVal, optionValueFormat]
1667
1656
  );
1668
- const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
1669
- const selectedValues = Array.isArray(selectedIndexes) ? selectedIndexes : [selectedIndexes];
1657
+ const selectedValues = [
1658
+ utils.enumOptionSelectedValue(value, enumOptions, !!multiple, optionValueFormat, multiple ? [] : "")
1659
+ ].flat().filter((v) => v !== "");
1670
1660
  const optionsList = enumOptions || (Array.isArray(schema.examples) ? schema.examples.map((example) => ({ value: example, label: example })) : []);
1671
1661
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-control w-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dropdown w-full", children: [
1672
1662
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1683,29 +1673,32 @@
1683
1673
  ]
1684
1674
  }
1685
1675
  ),
1686
- /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "dropdown-content z-[1] bg-base-100 w-full max-h-60 overflow-auto rounded-box shadow-lg", children: optionsList.map(({ label: label2 }, i) => /* @__PURE__ */ jsxRuntime.jsx(
1687
- "li",
1688
- {
1689
- role: "button",
1690
- tabIndex: 0,
1691
- className: `px-4 py-2 hover:bg-base-200 cursor-pointer ${selectedValues.includes(String(i)) ? "bg-primary/10" : ""}`,
1692
- onClick: handleOptionClick,
1693
- "data-value": i,
1694
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1695
- multiple && /* @__PURE__ */ jsxRuntime.jsx(
1696
- "input",
1697
- {
1698
- type: "checkbox",
1699
- className: "checkbox checkbox-sm",
1700
- checked: selectedValues.includes(String(i)),
1701
- readOnly: true
1702
- }
1703
- ),
1704
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
1705
- ] })
1706
- },
1707
- i
1708
- )) })
1676
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "dropdown-content z-[1] bg-base-100 w-full max-h-60 overflow-auto rounded-box shadow-lg", children: optionsList.map(({ value: optValue, label: label2 }, i) => {
1677
+ const encodedValue = utils.enumOptionValueEncoder(optValue, i, optionValueFormat);
1678
+ return /* @__PURE__ */ jsxRuntime.jsx(
1679
+ "li",
1680
+ {
1681
+ role: "button",
1682
+ tabIndex: 0,
1683
+ className: `px-4 py-2 hover:bg-base-200 cursor-pointer ${selectedValues.includes(encodedValue) ? "bg-primary/10" : ""}`,
1684
+ onClick: handleOptionClick,
1685
+ "data-value": i,
1686
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1687
+ multiple && /* @__PURE__ */ jsxRuntime.jsx(
1688
+ "input",
1689
+ {
1690
+ type: "checkbox",
1691
+ className: "checkbox checkbox-sm",
1692
+ checked: selectedValues.includes(encodedValue),
1693
+ readOnly: true
1694
+ }
1695
+ ),
1696
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
1697
+ ] })
1698
+ },
1699
+ i
1700
+ );
1701
+ }) })
1709
1702
  ] }) });
1710
1703
  }
1711
1704
  function TextareaWidget(props) {
package/dist/index.cjs CHANGED
@@ -741,7 +741,8 @@ function WrapIfAdditionalTemplate(props) {
741
741
  onBlur: onKeyRenameBlur,
742
742
  defaultValue: label,
743
743
  disabled: disabled || readonly
744
- }
744
+ },
745
+ label
745
746
  )
746
747
  ] }),
747
748
  children,
@@ -947,6 +948,7 @@ function CheckboxWidget(props) {
947
948
 
948
949
  // src/widgets/CheckboxesWidget/CheckboxesWidget.tsx
949
950
  var import_react5 = require("react");
951
+ var import_utils15 = require("@rjsf/utils");
950
952
  var import_jsx_runtime23 = require("react/jsx-runtime");
951
953
  function CheckboxesWidget({
952
954
  id,
@@ -960,7 +962,8 @@ function CheckboxesWidget({
960
962
  onFocus,
961
963
  onBlur
962
964
  }) {
963
- const { enumOptions } = options;
965
+ const { enumOptions, emptyValue } = options;
966
+ const optionValueFormat = (0, import_utils15.getOptionValueFormat)(options);
964
967
  const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
965
968
  const isChecked = (0, import_react5.useCallback)(
966
969
  (option) => {
@@ -994,26 +997,18 @@ function CheckboxesWidget({
994
997
  const handleFocus = (0, import_react5.useCallback)(
995
998
  (event) => {
996
999
  if (onFocus) {
997
- const index = Number(event.target.dataset.index);
998
- const option = enumOptions?.[index];
999
- if (option) {
1000
- onFocus(id, option.value);
1001
- }
1000
+ onFocus(id, (0, import_utils15.enumOptionValueDecoder)(event.target.value, enumOptions, optionValueFormat, emptyValue));
1002
1001
  }
1003
1002
  },
1004
- [onFocus, id, enumOptions]
1003
+ [onFocus, id, enumOptions, optionValueFormat, emptyValue]
1005
1004
  );
1006
1005
  const handleBlur = (0, import_react5.useCallback)(
1007
1006
  (event) => {
1008
1007
  if (onBlur) {
1009
- const index = Number(event.target.dataset.index);
1010
- const option = enumOptions?.[index];
1011
- if (option) {
1012
- onBlur(id, option.value);
1013
- }
1008
+ onBlur(id, (0, import_utils15.enumOptionValueDecoder)(event.target.value, enumOptions, optionValueFormat, emptyValue));
1014
1009
  }
1015
1010
  },
1016
- [onBlur, id, enumOptions]
1011
+ [onBlur, id, enumOptions, optionValueFormat, emptyValue]
1017
1012
  );
1018
1013
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "form-control", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "flex items-center cursor-pointer gap-2", children: [
1019
1014
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
@@ -1023,6 +1018,7 @@ function CheckboxesWidget({
1023
1018
  id: `${id}-${option.value}`,
1024
1019
  className: "checkbox",
1025
1020
  name: htmlName || id,
1021
+ value: (0, import_utils15.enumOptionValueEncoder)(option.value, index, optionValueFormat),
1026
1022
  checked: isChecked(option),
1027
1023
  required,
1028
1024
  disabled: disabled || readonly,
@@ -1554,6 +1550,7 @@ function DateWidget(props) {
1554
1550
 
1555
1551
  // src/widgets/RadioWidget/RadioWidget.tsx
1556
1552
  var import_react8 = require("react");
1553
+ var import_utils16 = require("@rjsf/utils");
1557
1554
  var import_jsx_runtime26 = require("react/jsx-runtime");
1558
1555
  function RadioWidget({
1559
1556
  id,
@@ -1567,11 +1564,9 @@ function RadioWidget({
1567
1564
  onFocus,
1568
1565
  onBlur
1569
1566
  }) {
1570
- const { enumOptions } = options;
1567
+ const { enumOptions, emptyValue } = options;
1568
+ const optionValueFormat = (0, import_utils16.getOptionValueFormat)(options);
1571
1569
  const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
1572
- const getValue = (option) => {
1573
- return option.value;
1574
- };
1575
1570
  const isChecked = (option) => {
1576
1571
  if (isEnumeratedObject) {
1577
1572
  return value && value.name === option.value.name;
@@ -1581,33 +1576,28 @@ function RadioWidget({
1581
1576
  const handleFocus = (0, import_react8.useCallback)(
1582
1577
  (event) => {
1583
1578
  if (onFocus) {
1584
- const index = Number(event.target.dataset.index);
1585
- const optionValue = enumOptions?.[index]?.value;
1586
- onFocus(id, optionValue);
1579
+ onFocus(id, (0, import_utils16.enumOptionValueDecoder)(event.target.value, enumOptions, optionValueFormat, emptyValue));
1587
1580
  }
1588
1581
  },
1589
- [onFocus, id, enumOptions]
1582
+ [onFocus, id, enumOptions, optionValueFormat, emptyValue]
1590
1583
  );
1591
1584
  const handleBlur = (0, import_react8.useCallback)(
1592
1585
  (event) => {
1593
1586
  if (onBlur) {
1594
- const index = Number(event.target.dataset.index);
1595
- const optionValue = enumOptions?.[index]?.value;
1596
- onBlur(id, optionValue);
1587
+ onBlur(id, (0, import_utils16.enumOptionValueDecoder)(event.target.value, enumOptions, optionValueFormat, emptyValue));
1597
1588
  }
1598
1589
  },
1599
- [onBlur, id, enumOptions]
1590
+ [onBlur, id, enumOptions, optionValueFormat, emptyValue]
1600
1591
  );
1601
1592
  const handleChange = (0, import_react8.useCallback)(
1602
1593
  (event) => {
1603
- const index = Number(event.target.dataset.index);
1604
- const option = enumOptions?.[index];
1605
- if (option) {
1606
- onChange(isEnumeratedObject ? option.value : option.value);
1594
+ const decoded = (0, import_utils16.enumOptionValueDecoder)(event.target.value, enumOptions, optionValueFormat, emptyValue);
1595
+ if (decoded !== void 0) {
1596
+ onChange(decoded);
1607
1597
  event.target.blur();
1608
1598
  }
1609
1599
  },
1610
- [onChange, isEnumeratedObject, enumOptions]
1600
+ [onChange, enumOptions, optionValueFormat, emptyValue]
1611
1601
  );
1612
1602
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "form-control", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("label", { className: "flex items-center cursor-pointer gap-2", children: [
1613
1603
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
@@ -1617,7 +1607,7 @@ function RadioWidget({
1617
1607
  id: `${id}-${option.value}`,
1618
1608
  className: "radio",
1619
1609
  name: htmlName || id,
1620
- value: getValue(option),
1610
+ value: (0, import_utils16.enumOptionValueEncoder)(option.value, index, optionValueFormat),
1621
1611
  checked: isChecked(option),
1622
1612
  required,
1623
1613
  disabled: disabled || readonly,
@@ -1761,7 +1751,7 @@ function RatingWidget({
1761
1751
 
1762
1752
  // src/widgets/SelectWidget/SelectWidget.tsx
1763
1753
  var import_react11 = require("react");
1764
- var import_utils15 = require("@rjsf/utils");
1754
+ var import_utils17 = require("@rjsf/utils");
1765
1755
  var import_jsx_runtime29 = require("react/jsx-runtime");
1766
1756
  function SelectWidget({
1767
1757
  schema,
@@ -1778,6 +1768,7 @@ function SelectWidget({
1778
1768
  onFocus
1779
1769
  }) {
1780
1770
  const { enumOptions, emptyValue: optEmptyVal } = options;
1771
+ const optionValueFormat = (0, import_utils17.getOptionValueFormat)(options);
1781
1772
  multiple = typeof multiple === "undefined" ? false : !!multiple;
1782
1773
  const getDisplayValue = (val) => {
1783
1774
  if (!val) {
@@ -1800,37 +1791,38 @@ function SelectWidget({
1800
1791
  }
1801
1792
  if (multiple) {
1802
1793
  const currentValue = Array.isArray(value) ? value : [];
1803
- const optionValue = isEnumeratedObject ? enumOptions[index].value : (0, import_utils15.enumOptionsValueForIndex)(String(index), enumOptions, optEmptyVal);
1794
+ const optionValue = isEnumeratedObject ? enumOptions[index].value : (0, import_utils17.enumOptionValueDecoder)(String(index), enumOptions, optionValueFormat, optEmptyVal);
1804
1795
  const newValue = currentValue.includes(optionValue) ? currentValue.filter((v) => v !== optionValue) : [...currentValue, optionValue];
1805
1796
  onChange(newValue);
1806
1797
  } else {
1807
1798
  onChange(
1808
- isEnumeratedObject ? enumOptions[index].value : (0, import_utils15.enumOptionsValueForIndex)(String(index), enumOptions, optEmptyVal)
1799
+ isEnumeratedObject ? enumOptions[index].value : (0, import_utils17.enumOptionValueDecoder)(String(index), enumOptions, optionValueFormat, optEmptyVal)
1809
1800
  );
1810
1801
  }
1811
1802
  },
1812
- [value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, onChange]
1803
+ [value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, optionValueFormat, onChange]
1813
1804
  );
1814
1805
  const _onBlur = (0, import_react11.useCallback)(
1815
1806
  ({ target }) => {
1816
1807
  const dataValue = target?.getAttribute("data-value");
1817
1808
  if (dataValue !== null) {
1818
- onBlur(id, (0, import_utils15.enumOptionsValueForIndex)(dataValue, enumOptions, optEmptyVal));
1809
+ onBlur(id, (0, import_utils17.enumOptionValueDecoder)(dataValue, enumOptions, optionValueFormat, optEmptyVal));
1819
1810
  }
1820
1811
  },
1821
- [onBlur, id, enumOptions, optEmptyVal]
1812
+ [onBlur, id, enumOptions, optEmptyVal, optionValueFormat]
1822
1813
  );
1823
1814
  const _onFocus = (0, import_react11.useCallback)(
1824
1815
  ({ target }) => {
1825
1816
  const dataValue = target?.getAttribute("data-value");
1826
1817
  if (dataValue !== null) {
1827
- onFocus(id, (0, import_utils15.enumOptionsValueForIndex)(dataValue, enumOptions, optEmptyVal));
1818
+ onFocus(id, (0, import_utils17.enumOptionValueDecoder)(dataValue, enumOptions, optionValueFormat, optEmptyVal));
1828
1819
  }
1829
1820
  },
1830
- [onFocus, id, enumOptions, optEmptyVal]
1821
+ [onFocus, id, enumOptions, optEmptyVal, optionValueFormat]
1831
1822
  );
1832
- const selectedIndexes = (0, import_utils15.enumOptionsIndexForValue)(value, enumOptions, multiple);
1833
- const selectedValues = Array.isArray(selectedIndexes) ? selectedIndexes : [selectedIndexes];
1823
+ const selectedValues = [
1824
+ (0, import_utils17.enumOptionSelectedValue)(value, enumOptions, !!multiple, optionValueFormat, multiple ? [] : "")
1825
+ ].flat().filter((v) => v !== "");
1834
1826
  const optionsList = enumOptions || (Array.isArray(schema.examples) ? schema.examples.map((example) => ({ value: example, label: example })) : []);
1835
1827
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "form-control w-full", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "dropdown w-full", children: [
1836
1828
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
@@ -1847,29 +1839,32 @@ function SelectWidget({
1847
1839
  ]
1848
1840
  }
1849
1841
  ),
1850
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ul", { className: "dropdown-content z-[1] bg-base-100 w-full max-h-60 overflow-auto rounded-box shadow-lg", children: optionsList.map(({ label: label2 }, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1851
- "li",
1852
- {
1853
- role: "button",
1854
- tabIndex: 0,
1855
- className: `px-4 py-2 hover:bg-base-200 cursor-pointer ${selectedValues.includes(String(i)) ? "bg-primary/10" : ""}`,
1856
- onClick: handleOptionClick,
1857
- "data-value": i,
1858
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
1859
- multiple && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1860
- "input",
1861
- {
1862
- type: "checkbox",
1863
- className: "checkbox checkbox-sm",
1864
- checked: selectedValues.includes(String(i)),
1865
- readOnly: true
1866
- }
1867
- ),
1868
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
1869
- ] })
1870
- },
1871
- i
1872
- )) })
1842
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ul", { className: "dropdown-content z-[1] bg-base-100 w-full max-h-60 overflow-auto rounded-box shadow-lg", children: optionsList.map(({ value: optValue, label: label2 }, i) => {
1843
+ const encodedValue = (0, import_utils17.enumOptionValueEncoder)(optValue, i, optionValueFormat);
1844
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1845
+ "li",
1846
+ {
1847
+ role: "button",
1848
+ tabIndex: 0,
1849
+ className: `px-4 py-2 hover:bg-base-200 cursor-pointer ${selectedValues.includes(encodedValue) ? "bg-primary/10" : ""}`,
1850
+ onClick: handleOptionClick,
1851
+ "data-value": i,
1852
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center gap-2", children: [
1853
+ multiple && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1854
+ "input",
1855
+ {
1856
+ type: "checkbox",
1857
+ className: "checkbox checkbox-sm",
1858
+ checked: selectedValues.includes(encodedValue),
1859
+ readOnly: true
1860
+ }
1861
+ ),
1862
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
1863
+ ] })
1864
+ },
1865
+ i
1866
+ );
1867
+ }) })
1873
1868
  ] }) });
1874
1869
  }
1875
1870