config-driven-form 1.3.1 → 1.4.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.
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +303 -111
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +303 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1460,6 +1460,25 @@ var PropertiesPanel = ({
|
|
|
1460
1460
|
[element]: value
|
|
1461
1461
|
});
|
|
1462
1462
|
};
|
|
1463
|
+
const handleErrorMessageChange = (errorKey, message) => {
|
|
1464
|
+
const currentMessages = typeof field.schema.errorMessage === "object" ? field.schema.errorMessage : {};
|
|
1465
|
+
const newMessages = { ...currentMessages };
|
|
1466
|
+
if (!message) {
|
|
1467
|
+
delete newMessages[errorKey];
|
|
1468
|
+
} else {
|
|
1469
|
+
newMessages[errorKey] = message;
|
|
1470
|
+
}
|
|
1471
|
+
handleSchemaChange(
|
|
1472
|
+
"errorMessage",
|
|
1473
|
+
Object.keys(newMessages).length > 0 ? newMessages : void 0
|
|
1474
|
+
);
|
|
1475
|
+
};
|
|
1476
|
+
const getErrorMessage = (errorKey) => {
|
|
1477
|
+
if (typeof field.schema.errorMessage === "object") {
|
|
1478
|
+
return field.schema.errorMessage[errorKey] || "";
|
|
1479
|
+
}
|
|
1480
|
+
return "";
|
|
1481
|
+
};
|
|
1463
1482
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1464
1483
|
"div",
|
|
1465
1484
|
{
|
|
@@ -1648,135 +1667,308 @@ var PropertiesPanel = ({
|
|
|
1648
1667
|
] }),
|
|
1649
1668
|
activeTab === "validation" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1650
1669
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1651
|
-
"
|
|
1670
|
+
"div",
|
|
1652
1671
|
{
|
|
1653
1672
|
style: {
|
|
1654
1673
|
display: "flex",
|
|
1655
|
-
|
|
1656
|
-
gap: "0.
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
cursor: "pointer"
|
|
1674
|
+
flexDirection: "column",
|
|
1675
|
+
gap: "0.375rem",
|
|
1676
|
+
marginBottom: "1rem",
|
|
1677
|
+
borderBottom: "1px solid #e5e7eb",
|
|
1678
|
+
paddingBottom: "1rem"
|
|
1661
1679
|
},
|
|
1662
1680
|
children: [
|
|
1663
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1664
|
-
"
|
|
1681
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1682
|
+
"label",
|
|
1665
1683
|
{
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1684
|
+
style: {
|
|
1685
|
+
display: "flex",
|
|
1686
|
+
alignItems: "center",
|
|
1687
|
+
gap: "0.5rem",
|
|
1688
|
+
fontSize: "0.875rem",
|
|
1689
|
+
fontWeight: 500,
|
|
1690
|
+
color: "#374151",
|
|
1691
|
+
cursor: "pointer"
|
|
1692
|
+
},
|
|
1693
|
+
children: [
|
|
1694
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1695
|
+
"input",
|
|
1696
|
+
{
|
|
1697
|
+
type: "checkbox",
|
|
1698
|
+
checked: field.isRequired || false,
|
|
1699
|
+
onChange: (e) => onUpdate(field.id, { isRequired: e.target.checked })
|
|
1700
|
+
}
|
|
1701
|
+
),
|
|
1702
|
+
"Required Field"
|
|
1703
|
+
]
|
|
1669
1704
|
}
|
|
1670
1705
|
),
|
|
1671
|
-
|
|
1706
|
+
field.isRequired && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1707
|
+
"input",
|
|
1708
|
+
{
|
|
1709
|
+
type: "text",
|
|
1710
|
+
placeholder: "Custom required error message",
|
|
1711
|
+
value: getErrorMessage("required"),
|
|
1712
|
+
onChange: (e) => handleErrorMessageChange("required", e.target.value),
|
|
1713
|
+
style: {
|
|
1714
|
+
width: "100%",
|
|
1715
|
+
padding: "0.4rem",
|
|
1716
|
+
border: "1px dashed #d1d5db",
|
|
1717
|
+
borderRadius: "0.375rem",
|
|
1718
|
+
fontSize: "0.75rem",
|
|
1719
|
+
marginTop: "0.25rem",
|
|
1720
|
+
backgroundColor: "#f9fafb"
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
)
|
|
1672
1724
|
]
|
|
1673
1725
|
}
|
|
1674
1726
|
),
|
|
1675
1727
|
(field.type === "text" || field.type === "email" || field.type === "password") && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1676
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1728
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1729
|
+
"div",
|
|
1730
|
+
{
|
|
1731
|
+
style: {
|
|
1732
|
+
display: "flex",
|
|
1733
|
+
flexDirection: "column",
|
|
1734
|
+
gap: "0.375rem",
|
|
1735
|
+
marginBottom: "0.5rem"
|
|
1736
|
+
},
|
|
1737
|
+
children: [
|
|
1738
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { fontSize: "0.875rem", fontWeight: 500, color: "#374151" }, children: "Min Length" }),
|
|
1739
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1740
|
+
"input",
|
|
1741
|
+
{
|
|
1742
|
+
type: "number",
|
|
1743
|
+
value: field.schema.minLength || "",
|
|
1744
|
+
onChange: (e) => handleSchemaChange(
|
|
1745
|
+
"minLength",
|
|
1746
|
+
e.target.value ? Number(e.target.value) : void 0
|
|
1747
|
+
),
|
|
1748
|
+
style: {
|
|
1749
|
+
width: "100%",
|
|
1750
|
+
padding: "0.5rem",
|
|
1751
|
+
border: "1px solid #d1d5db",
|
|
1752
|
+
borderRadius: "0.375rem",
|
|
1753
|
+
fontSize: "0.875rem"
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1686
1756
|
),
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1757
|
+
field.schema.minLength !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1758
|
+
"input",
|
|
1759
|
+
{
|
|
1760
|
+
type: "text",
|
|
1761
|
+
placeholder: "Custom error message",
|
|
1762
|
+
value: getErrorMessage("minLength"),
|
|
1763
|
+
onChange: (e) => handleErrorMessageChange("minLength", e.target.value),
|
|
1764
|
+
style: {
|
|
1765
|
+
width: "100%",
|
|
1766
|
+
padding: "0.4rem",
|
|
1767
|
+
border: "1px dashed #d1d5db",
|
|
1768
|
+
borderRadius: "0.375rem",
|
|
1769
|
+
fontSize: "0.75rem",
|
|
1770
|
+
backgroundColor: "#f9fafb"
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
)
|
|
1774
|
+
]
|
|
1775
|
+
}
|
|
1776
|
+
),
|
|
1777
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1778
|
+
"div",
|
|
1779
|
+
{
|
|
1780
|
+
style: {
|
|
1781
|
+
display: "flex",
|
|
1782
|
+
flexDirection: "column",
|
|
1783
|
+
gap: "0.375rem",
|
|
1784
|
+
marginBottom: "0.5rem"
|
|
1785
|
+
},
|
|
1786
|
+
children: [
|
|
1787
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { fontSize: "0.875rem", fontWeight: 500, color: "#374151" }, children: "Max Length" }),
|
|
1788
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1789
|
+
"input",
|
|
1790
|
+
{
|
|
1791
|
+
type: "number",
|
|
1792
|
+
value: field.schema.maxLength || "",
|
|
1793
|
+
onChange: (e) => handleSchemaChange(
|
|
1794
|
+
"maxLength",
|
|
1795
|
+
e.target.value ? Number(e.target.value) : void 0
|
|
1796
|
+
),
|
|
1797
|
+
style: {
|
|
1798
|
+
width: "100%",
|
|
1799
|
+
padding: "0.5rem",
|
|
1800
|
+
border: "1px solid #d1d5db",
|
|
1801
|
+
borderRadius: "0.375rem",
|
|
1802
|
+
fontSize: "0.875rem"
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1707
1805
|
),
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1806
|
+
field.schema.maxLength !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1807
|
+
"input",
|
|
1808
|
+
{
|
|
1809
|
+
type: "text",
|
|
1810
|
+
placeholder: "Custom error message",
|
|
1811
|
+
value: getErrorMessage("maxLength"),
|
|
1812
|
+
onChange: (e) => handleErrorMessageChange("maxLength", e.target.value),
|
|
1813
|
+
style: {
|
|
1814
|
+
width: "100%",
|
|
1815
|
+
padding: "0.4rem",
|
|
1816
|
+
border: "1px dashed #d1d5db",
|
|
1817
|
+
borderRadius: "0.375rem",
|
|
1818
|
+
fontSize: "0.75rem",
|
|
1819
|
+
backgroundColor: "#f9fafb"
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
)
|
|
1823
|
+
]
|
|
1824
|
+
}
|
|
1825
|
+
),
|
|
1826
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1827
|
+
"div",
|
|
1828
|
+
{
|
|
1829
|
+
style: {
|
|
1830
|
+
display: "flex",
|
|
1831
|
+
flexDirection: "column",
|
|
1832
|
+
gap: "0.375rem",
|
|
1833
|
+
marginBottom: "0.5rem"
|
|
1834
|
+
},
|
|
1835
|
+
children: [
|
|
1836
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { fontSize: "0.875rem", fontWeight: 500, color: "#374151" }, children: "Regex Pattern" }),
|
|
1837
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1838
|
+
"input",
|
|
1839
|
+
{
|
|
1840
|
+
type: "text",
|
|
1841
|
+
value: field.schema.pattern || "",
|
|
1842
|
+
onChange: (e) => handleSchemaChange("pattern", e.target.value || void 0),
|
|
1843
|
+
style: {
|
|
1844
|
+
width: "100%",
|
|
1845
|
+
padding: "0.5rem",
|
|
1846
|
+
border: "1px solid #d1d5db",
|
|
1847
|
+
borderRadius: "0.375rem",
|
|
1848
|
+
fontSize: "0.875rem"
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
),
|
|
1852
|
+
field.schema.pattern !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1853
|
+
"input",
|
|
1854
|
+
{
|
|
1855
|
+
type: "text",
|
|
1856
|
+
placeholder: "Custom error message",
|
|
1857
|
+
value: getErrorMessage("pattern"),
|
|
1858
|
+
onChange: (e) => handleErrorMessageChange("pattern", e.target.value),
|
|
1859
|
+
style: {
|
|
1860
|
+
width: "100%",
|
|
1861
|
+
padding: "0.4rem",
|
|
1862
|
+
border: "1px dashed #d1d5db",
|
|
1863
|
+
borderRadius: "0.375rem",
|
|
1864
|
+
fontSize: "0.75rem",
|
|
1865
|
+
backgroundColor: "#f9fafb"
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
)
|
|
1869
|
+
]
|
|
1870
|
+
}
|
|
1871
|
+
)
|
|
1736
1872
|
] }),
|
|
1737
1873
|
field.type === "number" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1738
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1874
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1875
|
+
"div",
|
|
1876
|
+
{
|
|
1877
|
+
style: {
|
|
1878
|
+
display: "flex",
|
|
1879
|
+
flexDirection: "column",
|
|
1880
|
+
gap: "0.375rem",
|
|
1881
|
+
marginBottom: "0.5rem"
|
|
1882
|
+
},
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { fontSize: "0.875rem", fontWeight: 500, color: "#374151" }, children: "Minimum Value" }),
|
|
1885
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1886
|
+
"input",
|
|
1887
|
+
{
|
|
1888
|
+
type: "number",
|
|
1889
|
+
value: field.schema.minimum || "",
|
|
1890
|
+
onChange: (e) => handleSchemaChange(
|
|
1891
|
+
"minimum",
|
|
1892
|
+
e.target.value ? Number(e.target.value) : void 0
|
|
1893
|
+
),
|
|
1894
|
+
style: {
|
|
1895
|
+
width: "100%",
|
|
1896
|
+
padding: "0.5rem",
|
|
1897
|
+
border: "1px solid #d1d5db",
|
|
1898
|
+
borderRadius: "0.375rem",
|
|
1899
|
+
fontSize: "0.875rem"
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1748
1902
|
),
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1903
|
+
field.schema.minimum !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1904
|
+
"input",
|
|
1905
|
+
{
|
|
1906
|
+
type: "text",
|
|
1907
|
+
placeholder: "Custom error message",
|
|
1908
|
+
value: getErrorMessage("minimum"),
|
|
1909
|
+
onChange: (e) => handleErrorMessageChange("minimum", e.target.value),
|
|
1910
|
+
style: {
|
|
1911
|
+
width: "100%",
|
|
1912
|
+
padding: "0.4rem",
|
|
1913
|
+
border: "1px dashed #d1d5db",
|
|
1914
|
+
borderRadius: "0.375rem",
|
|
1915
|
+
fontSize: "0.75rem",
|
|
1916
|
+
backgroundColor: "#f9fafb"
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
)
|
|
1920
|
+
]
|
|
1921
|
+
}
|
|
1922
|
+
),
|
|
1923
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1924
|
+
"div",
|
|
1925
|
+
{
|
|
1926
|
+
style: {
|
|
1927
|
+
display: "flex",
|
|
1928
|
+
flexDirection: "column",
|
|
1929
|
+
gap: "0.375rem",
|
|
1930
|
+
marginBottom: "0.5rem"
|
|
1931
|
+
},
|
|
1932
|
+
children: [
|
|
1933
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { style: { fontSize: "0.875rem", fontWeight: 500, color: "#374151" }, children: "Maximum Value" }),
|
|
1934
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1935
|
+
"input",
|
|
1936
|
+
{
|
|
1937
|
+
type: "number",
|
|
1938
|
+
value: field.schema.maximum || "",
|
|
1939
|
+
onChange: (e) => handleSchemaChange(
|
|
1940
|
+
"maximum",
|
|
1941
|
+
e.target.value ? Number(e.target.value) : void 0
|
|
1942
|
+
),
|
|
1943
|
+
style: {
|
|
1944
|
+
width: "100%",
|
|
1945
|
+
padding: "0.5rem",
|
|
1946
|
+
border: "1px solid #d1d5db",
|
|
1947
|
+
borderRadius: "0.375rem",
|
|
1948
|
+
fontSize: "0.875rem"
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1769
1951
|
),
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1952
|
+
field.schema.maximum !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1953
|
+
"input",
|
|
1954
|
+
{
|
|
1955
|
+
type: "text",
|
|
1956
|
+
placeholder: "Custom error message",
|
|
1957
|
+
value: getErrorMessage("maximum"),
|
|
1958
|
+
onChange: (e) => handleErrorMessageChange("maximum", e.target.value),
|
|
1959
|
+
style: {
|
|
1960
|
+
width: "100%",
|
|
1961
|
+
padding: "0.4rem",
|
|
1962
|
+
border: "1px dashed #d1d5db",
|
|
1963
|
+
borderRadius: "0.375rem",
|
|
1964
|
+
fontSize: "0.75rem",
|
|
1965
|
+
backgroundColor: "#f9fafb"
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
)
|
|
1969
|
+
]
|
|
1970
|
+
}
|
|
1971
|
+
)
|
|
1780
1972
|
] })
|
|
1781
1973
|
] }),
|
|
1782
1974
|
activeTab === "design" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|