@rjsf/daisyui 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.
- package/dist/chakra-ui.esm.js +71 -66
- package/dist/chakra-ui.esm.js.map +3 -3
- package/dist/chakra-ui.umd.js +57 -64
- package/dist/index.cjs +60 -65
- package/dist/index.cjs.map +3 -3
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js +8 -14
- package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
- package/lib/widgets/RadioWidget/RadioWidget.js +12 -25
- package/lib/widgets/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/widgets/SelectWidget/SelectWidget.js +21 -11
- package/lib/widgets/SelectWidget/SelectWidget.js.map +1 -1
- package/package.json +9 -9
- package/src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +1 -0
- package/src/widgets/CheckboxesWidget/CheckboxesWidget.tsx +16 -14
- package/src/widgets/RadioWidget/RadioWidget.tsx +20 -25
- package/src/widgets/SelectWidget/SelectWidget.tsx +47 -35
package/dist/chakra-ui.esm.js
CHANGED
|
@@ -737,7 +737,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
737
737
|
onBlur: onKeyRenameBlur,
|
|
738
738
|
defaultValue: label,
|
|
739
739
|
disabled: disabled || readonly
|
|
740
|
-
}
|
|
740
|
+
},
|
|
741
|
+
label
|
|
741
742
|
)
|
|
742
743
|
] }),
|
|
743
744
|
children,
|
|
@@ -947,6 +948,11 @@ function CheckboxWidget(props) {
|
|
|
947
948
|
|
|
948
949
|
// src/widgets/CheckboxesWidget/CheckboxesWidget.tsx
|
|
949
950
|
import { useCallback as useCallback4 } from "react";
|
|
951
|
+
import {
|
|
952
|
+
enumOptionValueDecoder,
|
|
953
|
+
enumOptionValueEncoder,
|
|
954
|
+
getOptionValueFormat
|
|
955
|
+
} from "@rjsf/utils";
|
|
950
956
|
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
951
957
|
function CheckboxesWidget({
|
|
952
958
|
id,
|
|
@@ -960,7 +966,8 @@ function CheckboxesWidget({
|
|
|
960
966
|
onFocus,
|
|
961
967
|
onBlur
|
|
962
968
|
}) {
|
|
963
|
-
const { enumOptions } = options;
|
|
969
|
+
const { enumOptions, emptyValue } = options;
|
|
970
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
964
971
|
const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
|
|
965
972
|
const isChecked = useCallback4(
|
|
966
973
|
(option) => {
|
|
@@ -994,26 +1001,18 @@ function CheckboxesWidget({
|
|
|
994
1001
|
const handleFocus = useCallback4(
|
|
995
1002
|
(event) => {
|
|
996
1003
|
if (onFocus) {
|
|
997
|
-
|
|
998
|
-
const option = enumOptions?.[index];
|
|
999
|
-
if (option) {
|
|
1000
|
-
onFocus(id, option.value);
|
|
1001
|
-
}
|
|
1004
|
+
onFocus(id, enumOptionValueDecoder(event.target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1002
1005
|
}
|
|
1003
1006
|
},
|
|
1004
|
-
[onFocus, id, enumOptions]
|
|
1007
|
+
[onFocus, id, enumOptions, optionValueFormat, emptyValue]
|
|
1005
1008
|
);
|
|
1006
1009
|
const handleBlur = useCallback4(
|
|
1007
1010
|
(event) => {
|
|
1008
1011
|
if (onBlur) {
|
|
1009
|
-
|
|
1010
|
-
const option = enumOptions?.[index];
|
|
1011
|
-
if (option) {
|
|
1012
|
-
onBlur(id, option.value);
|
|
1013
|
-
}
|
|
1012
|
+
onBlur(id, enumOptionValueDecoder(event.target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1014
1013
|
}
|
|
1015
1014
|
},
|
|
1016
|
-
[onBlur, id, enumOptions]
|
|
1015
|
+
[onBlur, id, enumOptions, optionValueFormat, emptyValue]
|
|
1017
1016
|
);
|
|
1018
1017
|
return /* @__PURE__ */ jsx23("div", { className: "form-control", children: /* @__PURE__ */ jsx23("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxs12("label", { className: "flex items-center cursor-pointer gap-2", children: [
|
|
1019
1018
|
/* @__PURE__ */ jsx23(
|
|
@@ -1023,6 +1022,7 @@ function CheckboxesWidget({
|
|
|
1023
1022
|
id: `${id}-${option.value}`,
|
|
1024
1023
|
className: "checkbox",
|
|
1025
1024
|
name: htmlName || id,
|
|
1025
|
+
value: enumOptionValueEncoder(option.value, index, optionValueFormat),
|
|
1026
1026
|
checked: isChecked(option),
|
|
1027
1027
|
required,
|
|
1028
1028
|
disabled: disabled || readonly,
|
|
@@ -1554,6 +1554,11 @@ function DateWidget(props) {
|
|
|
1554
1554
|
|
|
1555
1555
|
// src/widgets/RadioWidget/RadioWidget.tsx
|
|
1556
1556
|
import { useCallback as useCallback7 } from "react";
|
|
1557
|
+
import {
|
|
1558
|
+
enumOptionValueDecoder as enumOptionValueDecoder2,
|
|
1559
|
+
enumOptionValueEncoder as enumOptionValueEncoder2,
|
|
1560
|
+
getOptionValueFormat as getOptionValueFormat2
|
|
1561
|
+
} from "@rjsf/utils";
|
|
1557
1562
|
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1558
1563
|
function RadioWidget({
|
|
1559
1564
|
id,
|
|
@@ -1567,11 +1572,9 @@ function RadioWidget({
|
|
|
1567
1572
|
onFocus,
|
|
1568
1573
|
onBlur
|
|
1569
1574
|
}) {
|
|
1570
|
-
const { enumOptions } = options;
|
|
1575
|
+
const { enumOptions, emptyValue } = options;
|
|
1576
|
+
const optionValueFormat = getOptionValueFormat2(options);
|
|
1571
1577
|
const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
|
|
1572
|
-
const getValue = (option) => {
|
|
1573
|
-
return option.value;
|
|
1574
|
-
};
|
|
1575
1578
|
const isChecked = (option) => {
|
|
1576
1579
|
if (isEnumeratedObject) {
|
|
1577
1580
|
return value && value.name === option.value.name;
|
|
@@ -1581,33 +1584,28 @@ function RadioWidget({
|
|
|
1581
1584
|
const handleFocus = useCallback7(
|
|
1582
1585
|
(event) => {
|
|
1583
1586
|
if (onFocus) {
|
|
1584
|
-
|
|
1585
|
-
const optionValue = enumOptions?.[index]?.value;
|
|
1586
|
-
onFocus(id, optionValue);
|
|
1587
|
+
onFocus(id, enumOptionValueDecoder2(event.target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1587
1588
|
}
|
|
1588
1589
|
},
|
|
1589
|
-
[onFocus, id, enumOptions]
|
|
1590
|
+
[onFocus, id, enumOptions, optionValueFormat, emptyValue]
|
|
1590
1591
|
);
|
|
1591
1592
|
const handleBlur = useCallback7(
|
|
1592
1593
|
(event) => {
|
|
1593
1594
|
if (onBlur) {
|
|
1594
|
-
|
|
1595
|
-
const optionValue = enumOptions?.[index]?.value;
|
|
1596
|
-
onBlur(id, optionValue);
|
|
1595
|
+
onBlur(id, enumOptionValueDecoder2(event.target.value, enumOptions, optionValueFormat, emptyValue));
|
|
1597
1596
|
}
|
|
1598
1597
|
},
|
|
1599
|
-
[onBlur, id, enumOptions]
|
|
1598
|
+
[onBlur, id, enumOptions, optionValueFormat, emptyValue]
|
|
1600
1599
|
);
|
|
1601
1600
|
const handleChange = useCallback7(
|
|
1602
1601
|
(event) => {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
onChange(isEnumeratedObject ? option.value : option.value);
|
|
1602
|
+
const decoded = enumOptionValueDecoder2(event.target.value, enumOptions, optionValueFormat, emptyValue);
|
|
1603
|
+
if (decoded !== void 0) {
|
|
1604
|
+
onChange(decoded);
|
|
1607
1605
|
event.target.blur();
|
|
1608
1606
|
}
|
|
1609
1607
|
},
|
|
1610
|
-
[onChange,
|
|
1608
|
+
[onChange, enumOptions, optionValueFormat, emptyValue]
|
|
1611
1609
|
);
|
|
1612
1610
|
return /* @__PURE__ */ jsx26("div", { className: "form-control", children: /* @__PURE__ */ jsx26("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxs15("label", { className: "flex items-center cursor-pointer gap-2", children: [
|
|
1613
1611
|
/* @__PURE__ */ jsx26(
|
|
@@ -1617,7 +1615,7 @@ function RadioWidget({
|
|
|
1617
1615
|
id: `${id}-${option.value}`,
|
|
1618
1616
|
className: "radio",
|
|
1619
1617
|
name: htmlName || id,
|
|
1620
|
-
value:
|
|
1618
|
+
value: enumOptionValueEncoder2(option.value, index, optionValueFormat),
|
|
1621
1619
|
checked: isChecked(option),
|
|
1622
1620
|
required,
|
|
1623
1621
|
disabled: disabled || readonly,
|
|
@@ -1762,8 +1760,10 @@ function RatingWidget({
|
|
|
1762
1760
|
// src/widgets/SelectWidget/SelectWidget.tsx
|
|
1763
1761
|
import { useCallback as useCallback10 } from "react";
|
|
1764
1762
|
import {
|
|
1765
|
-
|
|
1766
|
-
|
|
1763
|
+
enumOptionSelectedValue,
|
|
1764
|
+
enumOptionValueDecoder as enumOptionValueDecoder3,
|
|
1765
|
+
enumOptionValueEncoder as enumOptionValueEncoder3,
|
|
1766
|
+
getOptionValueFormat as getOptionValueFormat3
|
|
1767
1767
|
} from "@rjsf/utils";
|
|
1768
1768
|
import { jsx as jsx29, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1769
1769
|
function SelectWidget({
|
|
@@ -1781,6 +1781,7 @@ function SelectWidget({
|
|
|
1781
1781
|
onFocus
|
|
1782
1782
|
}) {
|
|
1783
1783
|
const { enumOptions, emptyValue: optEmptyVal } = options;
|
|
1784
|
+
const optionValueFormat = getOptionValueFormat3(options);
|
|
1784
1785
|
multiple = typeof multiple === "undefined" ? false : !!multiple;
|
|
1785
1786
|
const getDisplayValue = (val) => {
|
|
1786
1787
|
if (!val) {
|
|
@@ -1803,37 +1804,38 @@ function SelectWidget({
|
|
|
1803
1804
|
}
|
|
1804
1805
|
if (multiple) {
|
|
1805
1806
|
const currentValue = Array.isArray(value) ? value : [];
|
|
1806
|
-
const optionValue = isEnumeratedObject ? enumOptions[index].value :
|
|
1807
|
+
const optionValue = isEnumeratedObject ? enumOptions[index].value : enumOptionValueDecoder3(String(index), enumOptions, optionValueFormat, optEmptyVal);
|
|
1807
1808
|
const newValue = currentValue.includes(optionValue) ? currentValue.filter((v) => v !== optionValue) : [...currentValue, optionValue];
|
|
1808
1809
|
onChange(newValue);
|
|
1809
1810
|
} else {
|
|
1810
1811
|
onChange(
|
|
1811
|
-
isEnumeratedObject ? enumOptions[index].value :
|
|
1812
|
+
isEnumeratedObject ? enumOptions[index].value : enumOptionValueDecoder3(String(index), enumOptions, optionValueFormat, optEmptyVal)
|
|
1812
1813
|
);
|
|
1813
1814
|
}
|
|
1814
1815
|
},
|
|
1815
|
-
[value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, onChange]
|
|
1816
|
+
[value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, optionValueFormat, onChange]
|
|
1816
1817
|
);
|
|
1817
1818
|
const _onBlur = useCallback10(
|
|
1818
1819
|
({ target }) => {
|
|
1819
1820
|
const dataValue = target?.getAttribute("data-value");
|
|
1820
1821
|
if (dataValue !== null) {
|
|
1821
|
-
onBlur(id,
|
|
1822
|
+
onBlur(id, enumOptionValueDecoder3(dataValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
1822
1823
|
}
|
|
1823
1824
|
},
|
|
1824
|
-
[onBlur, id, enumOptions, optEmptyVal]
|
|
1825
|
+
[onBlur, id, enumOptions, optEmptyVal, optionValueFormat]
|
|
1825
1826
|
);
|
|
1826
1827
|
const _onFocus = useCallback10(
|
|
1827
1828
|
({ target }) => {
|
|
1828
1829
|
const dataValue = target?.getAttribute("data-value");
|
|
1829
1830
|
if (dataValue !== null) {
|
|
1830
|
-
onFocus(id,
|
|
1831
|
+
onFocus(id, enumOptionValueDecoder3(dataValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
1831
1832
|
}
|
|
1832
1833
|
},
|
|
1833
|
-
[onFocus, id, enumOptions, optEmptyVal]
|
|
1834
|
+
[onFocus, id, enumOptions, optEmptyVal, optionValueFormat]
|
|
1834
1835
|
);
|
|
1835
|
-
const
|
|
1836
|
-
|
|
1836
|
+
const selectedValues = [
|
|
1837
|
+
enumOptionSelectedValue(value, enumOptions, !!multiple, optionValueFormat, multiple ? [] : "")
|
|
1838
|
+
].flat().filter((v) => v !== "");
|
|
1837
1839
|
const optionsList = enumOptions || (Array.isArray(schema.examples) ? schema.examples.map((example) => ({ value: example, label: example })) : []);
|
|
1838
1840
|
return /* @__PURE__ */ jsx29("div", { className: "form-control w-full", children: /* @__PURE__ */ jsxs17("div", { className: "dropdown w-full", children: [
|
|
1839
1841
|
/* @__PURE__ */ jsxs17(
|
|
@@ -1850,29 +1852,32 @@ function SelectWidget({
|
|
|
1850
1852
|
]
|
|
1851
1853
|
}
|
|
1852
1854
|
),
|
|
1853
|
-
/* @__PURE__ */ jsx29("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) =>
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1855
|
+
/* @__PURE__ */ jsx29("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) => {
|
|
1856
|
+
const encodedValue = enumOptionValueEncoder3(optValue, i, optionValueFormat);
|
|
1857
|
+
return /* @__PURE__ */ jsx29(
|
|
1858
|
+
"li",
|
|
1859
|
+
{
|
|
1860
|
+
role: "button",
|
|
1861
|
+
tabIndex: 0,
|
|
1862
|
+
className: `px-4 py-2 hover:bg-base-200 cursor-pointer ${selectedValues.includes(encodedValue) ? "bg-primary/10" : ""}`,
|
|
1863
|
+
onClick: handleOptionClick,
|
|
1864
|
+
"data-value": i,
|
|
1865
|
+
children: /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-2", children: [
|
|
1866
|
+
multiple && /* @__PURE__ */ jsx29(
|
|
1867
|
+
"input",
|
|
1868
|
+
{
|
|
1869
|
+
type: "checkbox",
|
|
1870
|
+
className: "checkbox checkbox-sm",
|
|
1871
|
+
checked: selectedValues.includes(encodedValue),
|
|
1872
|
+
readOnly: true
|
|
1873
|
+
}
|
|
1874
|
+
),
|
|
1875
|
+
/* @__PURE__ */ jsx29("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
|
|
1876
|
+
] })
|
|
1877
|
+
},
|
|
1878
|
+
i
|
|
1879
|
+
);
|
|
1880
|
+
}) })
|
|
1876
1881
|
] }) });
|
|
1877
1882
|
}
|
|
1878
1883
|
|