Socket
Socket
Sign inDemoInstall

@zag-js/form-utils

Package Overview
Dependencies
Maintainers
1
Versions
698
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/form-utils - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

13

dist/index.d.ts
declare type DescriptorOptions = {
type: "HTMLInputElement" | "HTMLTextAreaElement" | "HTMLSelectElement";
property: "value" | "checked";
property?: "value" | "checked";
};
declare function setElementValue(el: HTMLElement, value: string, option: DescriptorOptions): void;
declare function dispatchInputValueEvent(el: HTMLElement | null, value: string | number): void;
declare function dispatchInputCheckedEvent(el: HTMLElement | null, checked: boolean): void;
declare function trackInputPropertyMutation(el: HTMLInputElement | null, options: DescriptorOptions & {
fn?: (value: string) => void;
}): (() => void) | undefined;

@@ -15,3 +13,8 @@ declare function getClosestForm(el: HTMLElement): HTMLFormElement | null;

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, trackFieldsetDisabled, trackFormReset, trackInputPropertyMutation };
export { FormControlOptions, dispatchInputCheckedEvent, dispatchInputValueEvent, getClosestForm, isNativeDisabled, setElementValue, trackFieldsetDisabled, trackFormControl, trackFormReset };

@@ -27,5 +27,6 @@ "use strict";

isNativeDisabled: () => isNativeDisabled,
setElementValue: () => setElementValue,
trackFieldsetDisabled: () => trackFieldsetDisabled,
trackFormReset: () => trackFormReset,
trackInputPropertyMutation: () => trackInputPropertyMutation
trackFormControl: () => trackFormControl,
trackFormReset: () => trackFormReset
});

@@ -58,6 +59,11 @@ module.exports = __toCommonJS(src_exports);

var _a;
const { type, property } = options;
const { type, property = "value" } = options;
const proto = getWindow(el)[type].prototype;
return (_a = Object.getOwnPropertyDescriptor(proto, property)) != null ? _a : {};
}
function setElementValue(el, value, option) {
var _a;
const descriptor = getDescriptor(el, option);
(_a = descriptor.set) == null ? void 0 : _a.call(el, value);
}
function dispatchInputValueEvent(el, value) {

@@ -87,22 +93,2 @@ var _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;
};
}

@@ -138,2 +124,17 @@ // src/form.ts

}
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:

@@ -145,5 +146,6 @@ 0 && (module.exports = {

isNativeDisabled,
setElementValue,
trackFieldsetDisabled,
trackFormReset,
trackInputPropertyMutation
trackFormControl,
trackFormReset
});
{
"name": "@zag-js/form-utils",
"version": "0.2.0",
"version": "0.2.1",
"description": "",

@@ -22,3 +22,3 @@ "main": "dist/index.js",

"devDependencies": {
"@zag-js/dom-utils": "0.2.0"
"@zag-js/dom-utils": "0.2.1"
},

@@ -25,0 +25,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc