@zag-js/form-utils
Advanced tools
Comparing version 0.0.0-dev-20221117154049 to 0.0.0-dev-20221117183651
declare type DescriptorOptions = { | ||
type: "HTMLInputElement" | "HTMLTextAreaElement" | "HTMLSelectElement"; | ||
property: "value" | "checked"; | ||
property?: "value" | "checked"; | ||
}; | ||
@@ -8,5 +8,2 @@ declare function setElementValue(el: HTMLElement, value: string, option: DescriptorOptions): void; | ||
declare function dispatchInputCheckedEvent(el: HTMLElement | null, checked: boolean): void; | ||
declare function trackInputPropertyMutation(el: HTMLInputElement | null, options: DescriptorOptions & { | ||
fn?: (value: string) => void; | ||
}): (() => void) | undefined; | ||
@@ -18,2 +15,2 @@ declare function getClosestForm(el: HTMLElement): HTMLFormElement | null; | ||
export { dispatchInputCheckedEvent, dispatchInputValueEvent, getClosestForm, isNativeDisabled, setElementValue, trackFieldsetDisabled, trackFormReset, trackInputPropertyMutation }; | ||
export { dispatchInputCheckedEvent, dispatchInputValueEvent, getClosestForm, isNativeDisabled, setElementValue, trackFieldsetDisabled, trackFormReset }; |
@@ -29,4 +29,3 @@ "use strict"; | ||
trackFieldsetDisabled: () => trackFieldsetDisabled, | ||
trackFormReset: () => trackFormReset, | ||
trackInputPropertyMutation: () => trackInputPropertyMutation | ||
trackFormReset: () => trackFormReset | ||
}); | ||
@@ -59,3 +58,3 @@ module.exports = __toCommonJS(src_exports); | ||
var _a; | ||
const { type, property } = options; | ||
const { type, property = "value" } = options; | ||
const proto = getWindow(el)[type].prototype; | ||
@@ -93,22 +92,2 @@ return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {}; | ||
} | ||
function trackInputPropertyMutation(el, options) { | ||
const { fn, property, type } = options; | ||
if (!fn || !el) | ||
return; | ||
const { get, set } = getDescriptor(el, { property, type }); | ||
let run = true; | ||
Object.defineProperty(el, property, { | ||
get() { | ||
return get == null ? void 0 : get.call(this); | ||
}, | ||
set(value) { | ||
if (run) | ||
fn(value); | ||
return set == null ? void 0 : set.call(this, value); | ||
} | ||
}); | ||
return () => { | ||
run = false; | ||
}; | ||
} | ||
@@ -152,4 +131,3 @@ // src/form.ts | ||
trackFieldsetDisabled, | ||
trackFormReset, | ||
trackInputPropertyMutation | ||
trackFormReset | ||
}); |
{ | ||
"name": "@zag-js/form-utils", | ||
"version": "0.0.0-dev-20221117154049", | ||
"version": "0.0.0-dev-20221117183651", | ||
"description": "", | ||
@@ -22,3 +22,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@zag-js/dom-utils": "0.0.0-dev-20221117154049" | ||
"@zag-js/dom-utils": "0.0.0-dev-20221117183651" | ||
}, | ||
@@ -25,0 +25,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10696
231