valyrian.js 9.1.1 → 9.1.2
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/forms/index.js +51 -8
- package/dist/forms/index.js.map +2 -2
- package/dist/forms/index.min.js +1 -1
- package/dist/forms/index.min.js.map +1 -1
- package/dist/forms/index.mjs +51 -8
- package/dist/forms/index.mjs.map +2 -2
- package/dist/lib/forms/index.d.ts.map +1 -1
- package/dist/lib/money/index.d.ts.map +1 -1
- package/dist/money/index.js.map +2 -2
- package/dist/money/index.min.js.map +1 -1
- package/dist/money/index.mjs.map +2 -2
- package/lib/forms/index.ts +118 -27
- package/lib/money/index.ts +5 -2
- package/llms-full.txt +1 -1
- package/package.json +1 -1
package/dist/forms/index.js
CHANGED
|
@@ -1644,7 +1644,9 @@ function getNodeName(node) {
|
|
|
1644
1644
|
return (0, import_utils.isString)(attributeName) ? attributeName : "";
|
|
1645
1645
|
}
|
|
1646
1646
|
function getNodeType(node) {
|
|
1647
|
-
return String(
|
|
1647
|
+
return String(
|
|
1648
|
+
node.type || getNodeAttribute(node, "type") || ""
|
|
1649
|
+
).toLowerCase();
|
|
1648
1650
|
}
|
|
1649
1651
|
function decodeJsonPointerToken(token) {
|
|
1650
1652
|
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
@@ -1711,7 +1713,9 @@ function getSubmitters(formDom) {
|
|
|
1711
1713
|
const submitters = [];
|
|
1712
1714
|
walkElements(formDom, (node) => {
|
|
1713
1715
|
const tagName = getTagName(node);
|
|
1714
|
-
const nodeType = String(
|
|
1716
|
+
const nodeType = String(
|
|
1717
|
+
node.type || getNodeAttribute(node, "type") || ""
|
|
1718
|
+
).toLowerCase();
|
|
1715
1719
|
if ((tagName === "BUTTON" || tagName === "INPUT") && nodeType === "submit") {
|
|
1716
1720
|
submitters.push(node);
|
|
1717
1721
|
}
|
|
@@ -1823,7 +1827,13 @@ var FormStore = class _FormStore {
|
|
|
1823
1827
|
return this.#runTransform(this.#format, name, value, control);
|
|
1824
1828
|
}
|
|
1825
1829
|
setField(name, rawValue, control = null, event) {
|
|
1826
|
-
const cleanedValue = this.#runTransform(
|
|
1830
|
+
const cleanedValue = this.#runTransform(
|
|
1831
|
+
this.#clean,
|
|
1832
|
+
name,
|
|
1833
|
+
rawValue,
|
|
1834
|
+
control,
|
|
1835
|
+
event
|
|
1836
|
+
);
|
|
1827
1837
|
this.#pulseStore.setField(name, cleanedValue);
|
|
1828
1838
|
}
|
|
1829
1839
|
#mapValidationError(error) {
|
|
@@ -1886,6 +1896,8 @@ function bindControl(formStore, control, vnode) {
|
|
|
1886
1896
|
}
|
|
1887
1897
|
const withBinding = control;
|
|
1888
1898
|
const existingBinding = withBinding[controlBindingKey];
|
|
1899
|
+
const userOnInput = vnode.props.oninput;
|
|
1900
|
+
const userOnChange = vnode.props.onchange;
|
|
1889
1901
|
if (!existingBinding) {
|
|
1890
1902
|
const onInputHandler = (event) => {
|
|
1891
1903
|
const target = event.target;
|
|
@@ -1894,7 +1906,12 @@ function bindControl(formStore, control, vnode) {
|
|
|
1894
1906
|
return;
|
|
1895
1907
|
}
|
|
1896
1908
|
if (currentBinding.type !== "checkbox" && currentBinding.type !== "radio") {
|
|
1897
|
-
currentBinding.formStore.setField(
|
|
1909
|
+
currentBinding.formStore.setField(
|
|
1910
|
+
currentBinding.name,
|
|
1911
|
+
target.value,
|
|
1912
|
+
target,
|
|
1913
|
+
event
|
|
1914
|
+
);
|
|
1898
1915
|
const formattedValue = currentBinding.formStore.formatValue(
|
|
1899
1916
|
currentBinding.name,
|
|
1900
1917
|
currentBinding.formStore.state[currentBinding.name],
|
|
@@ -1902,6 +1919,9 @@ function bindControl(formStore, control, vnode) {
|
|
|
1902
1919
|
);
|
|
1903
1920
|
setControlValue(target, formattedValue);
|
|
1904
1921
|
}
|
|
1922
|
+
if (currentBinding.userOnInput) {
|
|
1923
|
+
currentBinding.userOnInput(event);
|
|
1924
|
+
}
|
|
1905
1925
|
};
|
|
1906
1926
|
const onChangeHandler = (event) => {
|
|
1907
1927
|
const currentBinding = withBinding[controlBindingKey];
|
|
@@ -1910,9 +1930,22 @@ function bindControl(formStore, control, vnode) {
|
|
|
1910
1930
|
}
|
|
1911
1931
|
const target = event.target;
|
|
1912
1932
|
if (currentBinding.type === "checkbox") {
|
|
1913
|
-
currentBinding.formStore.setField(
|
|
1933
|
+
currentBinding.formStore.setField(
|
|
1934
|
+
currentBinding.name,
|
|
1935
|
+
Boolean(target.checked),
|
|
1936
|
+
target,
|
|
1937
|
+
event
|
|
1938
|
+
);
|
|
1914
1939
|
} else if (currentBinding.type === "radio") {
|
|
1915
|
-
currentBinding.formStore.setField(
|
|
1940
|
+
currentBinding.formStore.setField(
|
|
1941
|
+
currentBinding.name,
|
|
1942
|
+
target.value,
|
|
1943
|
+
target,
|
|
1944
|
+
event
|
|
1945
|
+
);
|
|
1946
|
+
}
|
|
1947
|
+
if (currentBinding.userOnChange) {
|
|
1948
|
+
currentBinding.userOnChange(event);
|
|
1916
1949
|
}
|
|
1917
1950
|
};
|
|
1918
1951
|
const binding2 = {
|
|
@@ -1920,13 +1953,17 @@ function bindControl(formStore, control, vnode) {
|
|
|
1920
1953
|
name,
|
|
1921
1954
|
type,
|
|
1922
1955
|
onInputHandler,
|
|
1923
|
-
onChangeHandler
|
|
1956
|
+
onChangeHandler,
|
|
1957
|
+
userOnInput,
|
|
1958
|
+
userOnChange
|
|
1924
1959
|
};
|
|
1925
1960
|
withBinding[controlBindingKey] = binding2;
|
|
1926
1961
|
} else {
|
|
1927
1962
|
withBinding[controlBindingKey].formStore = formStore;
|
|
1928
1963
|
withBinding[controlBindingKey].name = name;
|
|
1929
1964
|
withBinding[controlBindingKey].type = type;
|
|
1965
|
+
withBinding[controlBindingKey].userOnInput = userOnInput;
|
|
1966
|
+
withBinding[controlBindingKey].userOnChange = userOnChange;
|
|
1930
1967
|
}
|
|
1931
1968
|
const binding = withBinding[controlBindingKey];
|
|
1932
1969
|
(0, import_valyrian.setAttribute)("oninput", binding.onInputHandler, vnode);
|
|
@@ -1945,6 +1982,7 @@ function syncSubmitButtons(formDom, formStore) {
|
|
|
1945
1982
|
}
|
|
1946
1983
|
const withBinding = formDom;
|
|
1947
1984
|
const existingBinding = withBinding[formBindingKey];
|
|
1985
|
+
const userOnSubmit = vnode.props.onsubmit;
|
|
1948
1986
|
if (!existingBinding) {
|
|
1949
1987
|
const onSubmitHandler = async (event) => {
|
|
1950
1988
|
const currentBinding = withBinding[formBindingKey];
|
|
@@ -1955,14 +1993,19 @@ function syncSubmitButtons(formDom, formStore) {
|
|
|
1955
1993
|
if (!success) {
|
|
1956
1994
|
event.preventDefault();
|
|
1957
1995
|
}
|
|
1996
|
+
if (currentBinding.userOnSubmit) {
|
|
1997
|
+
currentBinding.userOnSubmit(event);
|
|
1998
|
+
}
|
|
1958
1999
|
};
|
|
1959
2000
|
const binding2 = {
|
|
1960
2001
|
formStore,
|
|
1961
|
-
onSubmitHandler
|
|
2002
|
+
onSubmitHandler,
|
|
2003
|
+
userOnSubmit
|
|
1962
2004
|
};
|
|
1963
2005
|
withBinding[formBindingKey] = binding2;
|
|
1964
2006
|
} else {
|
|
1965
2007
|
withBinding[formBindingKey].formStore = formStore;
|
|
2008
|
+
withBinding[formBindingKey].userOnSubmit = userOnSubmit;
|
|
1966
2009
|
}
|
|
1967
2010
|
const binding = withBinding[formBindingKey];
|
|
1968
2011
|
(0, import_valyrian.setAttribute)("onsubmit", binding.onSubmitHandler, vnode);
|