@zag-js/form-utils
Advanced tools
Comparing version 0.0.0-dev-20221118143153 to 0.0.0-dev-20221118145623
@@ -13,3 +13,8 @@ declare type DescriptorOptions = { | ||
declare function isNativeDisabled(el: HTMLElement): boolean; | ||
declare type FormControlOptions = { | ||
onFieldsetDisabled: () => void; | ||
onFormReset: () => void; | ||
}; | ||
declare function trackFormControl(el: HTMLElement | null, options: FormControlOptions): (() => void) | undefined; | ||
export { dispatchInputCheckedEvent, dispatchInputValueEvent, getClosestForm, isNativeDisabled, setElementValue, trackFieldsetDisabled, trackFormReset }; | ||
export { FormControlOptions, dispatchInputCheckedEvent, dispatchInputValueEvent, getClosestForm, isNativeDisabled, setElementValue, trackFieldsetDisabled, trackFormControl, trackFormReset }; |
@@ -29,2 +29,3 @@ "use strict"; | ||
trackFieldsetDisabled: () => trackFieldsetDisabled, | ||
trackFormControl: () => trackFormControl, | ||
trackFormReset: () => trackFormReset | ||
@@ -121,2 +122,17 @@ }); | ||
} | ||
function trackFormControl(el, options) { | ||
if (!el) | ||
return; | ||
const { onFieldsetDisabled, onFormReset } = options; | ||
const cleanups = [ | ||
trackFormReset(el, onFormReset), | ||
trackFieldsetDisabled(el, (disabled) => { | ||
if (disabled) | ||
onFieldsetDisabled(); | ||
}) | ||
]; | ||
return () => { | ||
cleanups.forEach((cleanup) => cleanup == null ? void 0 : cleanup()); | ||
}; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -130,3 +146,4 @@ 0 && (module.exports = { | ||
trackFieldsetDisabled, | ||
trackFormControl, | ||
trackFormReset | ||
}); |
{ | ||
"name": "@zag-js/form-utils", | ||
"version": "0.0.0-dev-20221118143153", | ||
"version": "0.0.0-dev-20221118145623", | ||
"description": "", | ||
@@ -22,3 +22,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@zag-js/dom-utils": "0.0.0-dev-20221118143153" | ||
"@zag-js/dom-utils": "0.0.0-dev-20221118145623" | ||
}, | ||
@@ -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
11800
269