dry-ux 1.83.0 → 1.84.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.
|
@@ -34,6 +34,7 @@ exports.CurrencyInput = React.forwardRef((_a, ref) => {
|
|
|
34
34
|
const initialRaw = toRaw((_b = value !== null && value !== void 0 ? value : defaultValue) !== null && _b !== void 0 ? _b : "");
|
|
35
35
|
const [rawValue, setRawValue] = React.useState(initialRaw);
|
|
36
36
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
37
|
+
const hiddenRef = React.useRef(null);
|
|
37
38
|
const isControlled = value !== undefined;
|
|
38
39
|
// Sync rawValue when controlled value changes
|
|
39
40
|
React.useEffect(() => {
|
|
@@ -53,13 +54,16 @@ exports.CurrencyInput = React.forwardRef((_a, ref) => {
|
|
|
53
54
|
const handleChange = (e) => {
|
|
54
55
|
const raw = toRaw(e.target.value);
|
|
55
56
|
setRawValue(raw);
|
|
57
|
+
// Sync hidden input immediately so DOM reads in onChange see the new value
|
|
58
|
+
if (hiddenRef.current) {
|
|
59
|
+
hiddenRef.current.value = raw;
|
|
60
|
+
}
|
|
56
61
|
if (onChange) {
|
|
57
|
-
// Provide the raw numeric value to the parent's onChange
|
|
58
62
|
const syntheticEvent = Object.assign(Object.assign({}, e), { target: Object.assign(Object.assign({}, e.target), { value: raw, name }) });
|
|
59
63
|
onChange(syntheticEvent);
|
|
60
64
|
}
|
|
61
65
|
};
|
|
62
66
|
return (React.createElement(React.Fragment, null,
|
|
63
67
|
React.createElement(HTMLInputs_1.Input, Object.assign({ ref: ref }, rest, { type: "text", value: displayValue, onFocus: handleFocus, onBlur: handleBlur, onChange: handleChange })),
|
|
64
|
-
React.createElement("input", { type: "hidden", name: name, value: rawValue })));
|
|
68
|
+
React.createElement("input", { ref: hiddenRef, type: "hidden", name: name, value: rawValue, className: "validate validate-hidden" })));
|
|
65
69
|
});
|