@zag-js/checkbox
Advanced tools
Comparing version 0.70.0 to 0.71.0
@@ -1,42 +0,16 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
'use strict'; | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
anatomy: () => anatomy, | ||
connect: () => connect, | ||
machine: () => machine, | ||
props: () => props, | ||
splitProps: () => splitProps | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var anatomy$1 = require('@zag-js/anatomy'); | ||
var domQuery = require('@zag-js/dom-query'); | ||
var focusVisible = require('@zag-js/focus-visible'); | ||
var core = require('@zag-js/core'); | ||
var domEvent = require('@zag-js/dom-event'); | ||
var formUtils = require('@zag-js/form-utils'); | ||
var utils = require('@zag-js/utils'); | ||
var types = require('@zag-js/types'); | ||
// src/checkbox.anatomy.ts | ||
var import_anatomy = require("@zag-js/anatomy"); | ||
var anatomy = (0, import_anatomy.createAnatomy)("checkbox").parts("root", "label", "control", "indicator"); | ||
var anatomy = anatomy$1.createAnatomy("checkbox").parts("root", "label", "control", "indicator"); | ||
var parts = anatomy.build(); | ||
// src/checkbox.connect.ts | ||
var import_dom_query2 = require("@zag-js/dom-query"); | ||
// src/checkbox.dom.ts | ||
var import_dom_query = require("@zag-js/dom-query"); | ||
var dom = (0, import_dom_query.createScope)({ | ||
var dom = domQuery.createScope({ | ||
getRootId: (ctx) => ctx.ids?.root ?? `checkbox:${ctx.id}`, | ||
@@ -49,5 +23,2 @@ getLabelId: (ctx) => ctx.ids?.label ?? `checkbox:${ctx.id}:label`, | ||
}); | ||
// src/checkbox.connect.ts | ||
var import_focus_visible = require("@zag-js/focus-visible"); | ||
function connect(state, send, normalize) { | ||
@@ -57,14 +28,14 @@ const disabled = state.context.isDisabled; | ||
const focused = !disabled && state.context.focused; | ||
const focusVisible = !disabled && state.context.focusVisible; | ||
const focusVisible$1 = !disabled && state.context.focusVisible; | ||
const checked = state.context.isChecked; | ||
const indeterminate = state.context.isIndeterminate; | ||
const dataAttrs = { | ||
"data-active": (0, import_dom_query2.dataAttr)(state.context.active), | ||
"data-focus": (0, import_dom_query2.dataAttr)(focused), | ||
"data-focus-visible": (0, import_dom_query2.dataAttr)(focusVisible), | ||
"data-readonly": (0, import_dom_query2.dataAttr)(readOnly), | ||
"data-hover": (0, import_dom_query2.dataAttr)(state.context.hovered), | ||
"data-disabled": (0, import_dom_query2.dataAttr)(disabled), | ||
"data-active": domQuery.dataAttr(state.context.active), | ||
"data-focus": domQuery.dataAttr(focused), | ||
"data-focus-visible": domQuery.dataAttr(focusVisible$1), | ||
"data-readonly": domQuery.dataAttr(readOnly), | ||
"data-hover": domQuery.dataAttr(state.context.hovered), | ||
"data-disabled": domQuery.dataAttr(disabled), | ||
"data-state": indeterminate ? "indeterminate" : state.context.checked ? "checked" : "unchecked", | ||
"data-invalid": (0, import_dom_query2.dataAttr)(state.context.invalid) | ||
"data-invalid": domQuery.dataAttr(state.context.invalid) | ||
}; | ||
@@ -142,5 +113,5 @@ return { | ||
value: state.context.value, | ||
style: import_dom_query2.visuallyHiddenStyle, | ||
style: domQuery.visuallyHiddenStyle, | ||
onFocus() { | ||
const focusVisible2 = (0, import_focus_visible.isFocusVisible)(); | ||
const focusVisible2 = focusVisible.isFocusVisible(); | ||
send({ type: "CONTEXT.SET", context: { focused: true, focusVisible: focusVisible2 } }); | ||
@@ -163,13 +134,6 @@ }, | ||
} | ||
// src/checkbox.machine.ts | ||
var import_core = require("@zag-js/core"); | ||
var import_dom_event = require("@zag-js/dom-event"); | ||
var import_focus_visible2 = require("@zag-js/focus-visible"); | ||
var import_form_utils = require("@zag-js/form-utils"); | ||
var import_utils = require("@zag-js/utils"); | ||
var { not } = import_core.guards; | ||
var { not } = core.guards; | ||
function machine(userContext) { | ||
const ctx = (0, import_utils.compact)(userContext); | ||
return (0, import_core.createMachine)( | ||
const ctx = utils.compact(userContext); | ||
return core.createMachine( | ||
{ | ||
@@ -230,3 +194,3 @@ id: "checkbox", | ||
if (ctx2.isDisabled) return; | ||
return (0, import_dom_event.trackPress)({ | ||
return domEvent.trackPress({ | ||
pointerNode: dom.getRootEl(ctx2), | ||
@@ -242,6 +206,6 @@ keyboardNode: dom.getHiddenInputEl(ctx2), | ||
if (ctx2.isDisabled) return; | ||
return (0, import_focus_visible2.trackFocusVisible)({ root: dom.getRootNode(ctx2) }); | ||
return focusVisible.trackFocusVisible({ root: dom.getRootNode(ctx2) }); | ||
}, | ||
trackFormControlState(ctx2, _evt, { send, initialContext }) { | ||
return (0, import_form_utils.trackFormControl)(dom.getHiddenInputEl(ctx2), { | ||
return formUtils.trackFormControl(dom.getHiddenInputEl(ctx2), { | ||
onFieldsetDisabledChange(disabled) { | ||
@@ -263,3 +227,3 @@ ctx2.fieldsetDisabled = disabled; | ||
if (!inputEl) return; | ||
(0, import_form_utils.setElementChecked)(inputEl, ctx2.isChecked); | ||
formUtils.setElementChecked(inputEl, ctx2.isChecked); | ||
inputEl.indeterminate = ctx2.isIndeterminate; | ||
@@ -282,3 +246,3 @@ }, | ||
const inputEl = dom.getHiddenInputEl(ctx2); | ||
(0, import_form_utils.dispatchInputCheckedEvent)(inputEl, { checked: isChecked(ctx2.checked) }); | ||
formUtils.dispatchInputCheckedEvent(inputEl, { checked: isChecked(ctx2.checked) }); | ||
} | ||
@@ -302,3 +266,3 @@ } | ||
checked: (ctx, checked) => { | ||
if ((0, import_utils.isEqual)(ctx.checked, checked)) return; | ||
if (utils.isEqual(ctx.checked, checked)) return; | ||
ctx.checked = checked; | ||
@@ -308,7 +272,3 @@ invoke.change(ctx); | ||
}; | ||
// src/checkbox.props.ts | ||
var import_types = require("@zag-js/types"); | ||
var import_utils2 = require("@zag-js/utils"); | ||
var props = (0, import_types.createProps)()([ | ||
var props = types.createProps()([ | ||
"checked", | ||
@@ -328,11 +288,8 @@ "dir", | ||
]); | ||
var splitProps = (0, import_utils2.createSplitProps)(props); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
anatomy, | ||
connect, | ||
machine, | ||
props, | ||
splitProps | ||
}); | ||
//# sourceMappingURL=index.js.map | ||
var splitProps = utils.createSplitProps(props); | ||
exports.anatomy = anatomy; | ||
exports.connect = connect; | ||
exports.machine = machine; | ||
exports.props = props; | ||
exports.splitProps = splitProps; |
{ | ||
"name": "@zag-js/checkbox", | ||
"version": "0.70.0", | ||
"version": "0.71.0", | ||
"description": "Core logic for the checkbox widget implemented as a state machine", | ||
@@ -20,4 +20,3 @@ "keywords": [ | ||
"files": [ | ||
"dist", | ||
"src" | ||
"dist" | ||
], | ||
@@ -31,10 +30,10 @@ "publishConfig": { | ||
"dependencies": { | ||
"@zag-js/anatomy": "0.70.0", | ||
"@zag-js/core": "0.70.0", | ||
"@zag-js/types": "0.70.0", | ||
"@zag-js/dom-query": "0.70.0", | ||
"@zag-js/focus-visible": "0.70.0", | ||
"@zag-js/dom-event": "0.70.0", | ||
"@zag-js/form-utils": "0.70.0", | ||
"@zag-js/utils": "0.70.0" | ||
"@zag-js/anatomy": "0.71.0", | ||
"@zag-js/core": "0.71.0", | ||
"@zag-js/types": "0.71.0", | ||
"@zag-js/dom-query": "0.71.0", | ||
"@zag-js/focus-visible": "0.71.0", | ||
"@zag-js/dom-event": "0.71.0", | ||
"@zag-js/form-utils": "0.71.0", | ||
"@zag-js/utils": "0.71.0" | ||
}, | ||
@@ -58,3 +57,3 @@ "devDependencies": { | ||
"build": "tsup", | ||
"test": "jest --config ../../jest.config.js --rootDir tests", | ||
"test": "vitest", | ||
"lint": "eslint src", | ||
@@ -61,0 +60,0 @@ "test-ci": "pnpm test --ci --runInBand -u", |
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
29914
7
681
+ Added@zag-js/anatomy@0.71.0(transitive)
+ Added@zag-js/core@0.71.0(transitive)
+ Added@zag-js/dom-event@0.71.0(transitive)
+ Added@zag-js/dom-query@0.71.0(transitive)
+ Added@zag-js/focus-visible@0.71.0(transitive)
+ Added@zag-js/form-utils@0.71.0(transitive)
+ Added@zag-js/store@0.71.0(transitive)
+ Added@zag-js/text-selection@0.71.0(transitive)
+ Added@zag-js/types@0.71.0(transitive)
+ Added@zag-js/utils@0.71.0(transitive)
- Removed@zag-js/anatomy@0.70.0(transitive)
- Removed@zag-js/core@0.70.0(transitive)
- Removed@zag-js/dom-event@0.70.0(transitive)
- Removed@zag-js/dom-query@0.70.0(transitive)
- Removed@zag-js/focus-visible@0.70.0(transitive)
- Removed@zag-js/form-utils@0.70.0(transitive)
- Removed@zag-js/store@0.70.0(transitive)
- Removed@zag-js/text-selection@0.70.0(transitive)
- Removed@zag-js/types@0.70.0(transitive)
- Removed@zag-js/utils@0.70.0(transitive)
Updated@zag-js/anatomy@0.71.0
Updated@zag-js/core@0.71.0
Updated@zag-js/dom-event@0.71.0
Updated@zag-js/dom-query@0.71.0
Updated@zag-js/focus-visible@0.71.0
Updated@zag-js/form-utils@0.71.0
Updated@zag-js/types@0.71.0
Updated@zag-js/utils@0.71.0