@zag-js/pin-input 0.2.11 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +0,0 @@
1
- // ../../utilities/dom/src/query.ts
2
- function isDocument(el) {
3
- return el.nodeType === Node.DOCUMENT_NODE;
4
- }
5
- function isWindow(value) {
6
- return value?.toString() === "[object Window]";
7
- }
8
- function getDocument(el) {
9
- if (isWindow(el))
10
- return el.document;
11
- if (isDocument(el))
12
- return el;
13
- return el?.ownerDocument ?? document;
14
- }
15
- function getWindow(el) {
16
- return el?.ownerDocument.defaultView ?? window;
17
- }
18
- function defineDomHelpers(helpers) {
19
- const dom2 = {
20
- getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
21
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
22
- getWin: (ctx) => dom2.getDoc(ctx).defaultView ?? window,
23
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
24
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
25
- };
26
- return {
27
- ...dom2,
28
- ...helpers
29
- };
30
- }
31
-
32
- // ../../utilities/dom/src/nodelist.ts
33
- function queryAll(root, selector) {
34
- return Array.from(root?.querySelectorAll(selector) ?? []);
35
- }
36
-
37
- // src/pin-input.dom.ts
38
- var dom = defineDomHelpers({
39
- getRootId: (ctx) => ctx.ids?.root ?? `pin-input:${ctx.id}`,
40
- getInputId: (ctx, id) => ctx.ids?.input?.(id) ?? `pin-input:${ctx.id}:${id}`,
41
- getHiddenInputId: (ctx) => ctx.ids?.hiddenInput ?? `pin-input:${ctx.id}:hidden`,
42
- getLabelId: (ctx) => ctx.ids?.label ?? `pin-input:${ctx.id}:label`,
43
- getControlId: (ctx) => ctx.ids?.control ?? `pin-input:${ctx.id}:control`,
44
- getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
45
- getElements: (ctx) => {
46
- const ownerId = CSS.escape(dom.getRootId(ctx));
47
- const selector = `input[data-ownedby=${ownerId}]`;
48
- return queryAll(dom.getRootEl(ctx), selector);
49
- },
50
- getFocusedEl: (ctx) => dom.getElements(ctx)[ctx.focusedIndex],
51
- getFirstInputEl: (ctx) => dom.getElements(ctx)[0],
52
- getHiddenInputEl: (ctx) => dom.getById(ctx, dom.getHiddenInputId(ctx))
53
- });
54
-
55
- export {
56
- getWindow,
57
- dom
58
- };