mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-27 15:30:57 +00:00
27 lines
776 B
JavaScript
27 lines
776 B
JavaScript
'use client';
|
|
function getInputOnChange(setValue) {
|
|
return (val) => {
|
|
if (!val) {
|
|
setValue(val);
|
|
} else if (typeof val === "function") {
|
|
setValue(val);
|
|
} else if (typeof val === "object" && "nativeEvent" in val) {
|
|
const { currentTarget } = val;
|
|
if (currentTarget instanceof HTMLInputElement) {
|
|
if (currentTarget.type === "checkbox") {
|
|
setValue(currentTarget.checked);
|
|
} else {
|
|
setValue(currentTarget.value);
|
|
}
|
|
} else if (currentTarget instanceof HTMLTextAreaElement || currentTarget instanceof HTMLSelectElement) {
|
|
setValue(currentTarget.value);
|
|
}
|
|
} else {
|
|
setValue(val);
|
|
}
|
|
};
|
|
}
|
|
|
|
export { getInputOnChange };
|
|
//# sourceMappingURL=get-input-on-change.mjs.map
|