New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zag-js/checkbox

Package Overview
Dependencies
Maintainers
1
Versions
976
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/checkbox - npm Package Compare versions

Comparing version

to
0.0.0-dev-20220708193601

12

dist/checkbox.dom.d.ts
import type { MachineContext as Ctx } from "./checkbox.types";
export declare const dom: {
getDoc: (ctx: Ctx) => Document;
getRootNode: (ctx: Ctx) => Document | ShadowRoot;
getRootNode: (ctx: {
getRootNode?: () => Node | Document | ShadowRoot;
}) => Document | ShadowRoot;
getDoc: (ctx: {
getRootNode?: () => Node | Document | ShadowRoot;
}) => Document;
getWin: (ctx: {
getRootNode?: () => Node | Document | ShadowRoot;
}) => Window & typeof globalThis;
} & {
getRootId: (ctx: Ctx) => string;

@@ -6,0 +14,0 @@ getLabelId: (ctx: Ctx) => string;

2

dist/checkbox.machine.d.ts
import type { MachineContext, MachineState, UserDefinedContext } from "./checkbox.types";
export declare function machine(ctx?: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
export declare function machine(ctx: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
import type { StateMachine as S } from "@zag-js/core";
import type { Context, DirectionProperty } from "@zag-js/types";
import type { CommonProperties, Context, DirectionProperty, RequiredBy } from "@zag-js/types";
declare type ElementIds = Partial<{

@@ -9,3 +9,3 @@ root: string;

}>;
declare type PublicContext = DirectionProperty & {
declare type PublicContext = DirectionProperty & CommonProperties & {
/**

@@ -70,3 +70,3 @@ * The ids of the elements in the checkbox. Useful for composition.

};
export declare type UserDefinedContext = Partial<PublicContext>;
export declare type UserDefinedContext = RequiredBy<PublicContext, "id">;
declare type ComputedContext = Readonly<{

@@ -73,0 +73,0 @@ /**

@@ -43,5 +43,35 @@ "use strict";

// ../../utilities/dom/dist/index.mjs
var __defProp2 = Object.defineProperty;
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues2 = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp2.call(b, prop))
__defNormalProp2(a, prop, b[prop]);
if (__getOwnPropSymbols2)
for (var prop of __getOwnPropSymbols2(b)) {
if (__propIsEnum2.call(b, prop))
__defNormalProp2(a, prop, b[prop]);
}
return a;
};
var dataAttr = (guard) => {
return guard ? "" : void 0;
};
function isDocument(el) {
return el.nodeType === Node.DOCUMENT_NODE;
}
function isWindow(value) {
return (value == null ? void 0 : value.toString()) === "[object Window]";
}
function getDocument(el) {
var _a;
if (isWindow(el))
return el.document;
if (isDocument(el))
return el;
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
}
function getWindow(el) {

@@ -51,2 +81,16 @@ var _a;

}
function withRootHelpers(domUtils) {
const roots = {
getRootNode: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
},
getDoc: (ctx) => getDocument(roots.getRootNode(ctx)),
getWin: (ctx) => {
var _a;
return (_a = roots.getDoc(ctx).defaultView) != null ? _a : window;
}
};
return __spreadValues2(__spreadValues2({}, roots), domUtils);
}
function observeAttributes(node, attributes, fn) {

@@ -135,30 +179,22 @@ if (!node)

// src/checkbox.dom.ts
var dom = {
getDoc: (ctx) => {
var _a;
return (_a = ctx.doc) != null ? _a : document;
},
getRootNode: (ctx) => {
var _a;
return (_a = ctx.rootNode) != null ? _a : dom.getDoc(ctx);
},
var dom = withRootHelpers({
getRootId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `checkbox:${ctx.uid}`;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `checkbox:${ctx.id}`;
},
getLabelId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `checkbox:${ctx.uid}:label`;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `checkbox:${ctx.id}:label`;
},
getControlId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.control) != null ? _b : `checkbox:${ctx.uid}:control`;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.control) != null ? _b : `checkbox:${ctx.id}:control`;
},
getInputId: (ctx) => {
var _a, _b;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `checkbox:${ctx.uid}:input`;
return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `checkbox:${ctx.id}:input`;
},
getRootEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getRootId(ctx)),
getInputEl: (ctx) => dom.getRootNode(ctx).getElementById(dom.getInputId(ctx))
};
});

@@ -307,3 +343,3 @@ // src/checkbox.connect.ts

var { and } = import_core.guards;
function machine(ctx = {}) {
function machine(ctx) {
return (0, import_core.createMachine)({

@@ -313,3 +349,2 @@ id: "checkbox",

context: __spreadValues({
uid: "",
active: false,

@@ -359,6 +394,3 @@ hovered: false,

on: {
SETUP: {
target: ctx.defaultChecked ? "checked" : "unchecked",
actions: ["setupDocument"]
}
SETUP: ctx.defaultChecked ? "checked" : "unchecked"
}

@@ -417,9 +449,2 @@ },

actions: {
setupDocument(ctx2, evt) {
ctx2.uid = evt.id;
if (evt.doc)
ctx2.doc = (0, import_core.ref)(evt.doc);
if (evt.root)
ctx2.rootNode = (0, import_core.ref)(evt.root);
},
invokeOnChange(ctx2, _evt, { state }) {

@@ -426,0 +451,0 @@ var _a;

{
"name": "@zag-js/checkbox",
"version": "0.0.0-dev-20220707125149",
"version": "0.0.0-dev-20220708193601",
"description": "Core logic for the checkbox widget implemented as a state machine",

@@ -41,9 +41,9 @@ "keywords": [

"dependencies": {
"@zag-js/core": "0.0.0-dev-20220707125149",
"@zag-js/types": "0.0.0-dev-20220707125149"
"@zag-js/core": "0.1.7",
"@zag-js/types": "0.0.0-dev-20220708193601"
},
"devDependencies": {
"@zag-js/dom-utils": "0.0.0-dev-20220707125149",
"@zag-js/dom-utils": "0.0.0-dev-20220708193601",
"@zag-js/utils": "0.1.2"
}
}

Sorry, the diff of this file is not supported yet