@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.
- package/dist/chunk-CPXMEVTH.mjs +23 -0
- package/dist/{chunk-6TEZTVFI.mjs → chunk-H5AVP4J4.mjs} +21 -65
- package/dist/{chunk-QVOI2QEW.mjs → chunk-KLVAQVBX.mjs} +27 -64
- package/dist/index.js +74 -187
- package/dist/index.mjs +3 -4
- package/dist/pin-input.anatomy.d.ts +2 -2
- package/dist/pin-input.connect.d.ts +21 -0
- package/dist/pin-input.connect.js +47 -115
- package/dist/pin-input.connect.mjs +2 -3
- package/dist/pin-input.dom.d.ts +6 -2
- package/dist/pin-input.dom.js +5 -38
- package/dist/pin-input.dom.mjs +1 -1
- package/dist/pin-input.machine.js +31 -107
- package/dist/pin-input.machine.mjs +2 -3
- package/package.json +9 -7
- package/dist/chunk-NT4W6JYX.mjs +0 -7
- package/dist/chunk-T5OKDF74.mjs +0 -58
package/dist/chunk-T5OKDF74.mjs
DELETED
|
@@ -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
|
-
};
|