@zag-js/splitter 0.2.6 → 0.2.8

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,97 +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 == null ? void 0 : value.toString()) === "[object Window]";
7
- }
8
- function getDocument(el) {
9
- var _a;
10
- if (isWindow(el))
11
- return el.document;
12
- if (isDocument(el))
13
- return el;
14
- return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
15
- }
16
- function defineDomHelpers(helpers) {
17
- const dom2 = {
18
- getRootNode: (ctx) => {
19
- var _a, _b;
20
- return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
21
- },
22
- getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
23
- getWin: (ctx) => {
24
- var _a;
25
- return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
26
- },
27
- getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
28
- getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id),
29
- createEmitter: (ctx, target) => {
30
- const win = dom2.getWin(ctx);
31
- return function emit(evt, detail, options) {
32
- const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
33
- const eventName = `zag:${evt}`;
34
- const init = { bubbles, cancelable, composed, detail };
35
- const event = new win.CustomEvent(eventName, init);
36
- target.dispatchEvent(event);
37
- };
38
- },
39
- createListener: (target) => {
40
- return function listen(evt, handler) {
41
- const eventName = `zag:${evt}`;
42
- const listener = (e) => handler(e);
43
- target.addEventListener(eventName, listener);
44
- return () => target.removeEventListener(eventName, listener);
45
- };
46
- }
47
- };
48
- return {
49
- ...dom2,
50
- ...helpers
51
- };
52
- }
53
-
54
- // src/splitter.dom.ts
55
- var dom = defineDomHelpers({
56
- getRootId: (ctx) => {
57
- var _a, _b;
58
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `splitter:${ctx.id}`;
59
- },
60
- getSplitterId: (ctx) => {
61
- var _a, _b;
62
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.splitter) != null ? _b : `splitter:${ctx.id}:splitter`;
63
- },
64
- getToggleButtonId: (ctx) => {
65
- var _a, _b;
66
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.toggleBtn) != null ? _b : `splitter:${ctx.id}:toggle-btn`;
67
- },
68
- getLabelId: (ctx) => {
69
- var _a, _b;
70
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `splitter:${ctx.id}:label`;
71
- },
72
- getPrimaryPaneId: (ctx) => {
73
- var _a, _b;
74
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.primaryPane) != null ? _b : `splitter:${ctx.id}:primary`;
75
- },
76
- getSecondaryPaneId: (ctx) => {
77
- var _a, _b;
78
- return (_b = (_a = ctx.ids) == null ? void 0 : _a.secondaryPane) != null ? _b : `splitter:${ctx.id}:secondary`;
79
- },
80
- getSplitterEl: (ctx) => dom.getById(ctx, dom.getSplitterId(ctx)),
81
- getPrimaryPaneEl: (ctx) => dom.getById(ctx, dom.getPrimaryPaneId(ctx)),
82
- getCursor(ctx) {
83
- if (ctx.disabled || ctx.fixed)
84
- return "default";
85
- const x = ctx.isHorizontal;
86
- let cursor = x ? "col-resize" : "row-resize";
87
- if (ctx.isAtMin)
88
- cursor = x ? "e-resize" : "s-resize";
89
- if (ctx.isAtMax)
90
- cursor = x ? "w-resize" : "n-resize";
91
- return cursor;
92
- }
93
- });
94
-
95
- export {
96
- dom
97
- };
@@ -1,16 +0,0 @@
1
- // src/splitter.anatomy.ts
2
- import { createAnatomy } from "@zag-js/anatomy";
3
- var anatomy = createAnatomy("splitter").parts(
4
- "root",
5
- "secondaryPane",
6
- "primaryPane",
7
- "toggleButton",
8
- "label",
9
- "splitter"
10
- );
11
- var parts = anatomy.build();
12
-
13
- export {
14
- anatomy,
15
- parts
16
- };