@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.
- package/dist/chunk-HPRMFGOY.mjs +9 -0
- package/dist/{chunk-F2ZDEPE3.mjs → chunk-IOEWCDUH.mjs} +171 -125
- package/dist/chunk-SQ3UMXCZ.mjs +131 -0
- package/dist/chunk-T56NFB6E.mjs +102 -0
- package/dist/chunk-UC2SKBKO.mjs +209 -0
- package/dist/index.js +470 -322
- package/dist/index.mjs +5 -4
- package/dist/splitter.anatomy.d.ts +2 -2
- package/dist/splitter.anatomy.js +1 -8
- package/dist/splitter.anatomy.mjs +1 -1
- package/dist/splitter.connect.d.ts +19 -13
- package/dist/splitter.connect.js +218 -197
- package/dist/splitter.connect.mjs +4 -3
- package/dist/splitter.dom.d.ts +15 -13
- package/dist/splitter.dom.js +54 -49
- package/dist/splitter.dom.mjs +1 -1
- package/dist/splitter.machine.js +340 -172
- package/dist/splitter.machine.mjs +3 -2
- package/dist/splitter.types.d.ts +50 -78
- package/dist/splitter.utils.d.ts +54 -0
- package/dist/splitter.utils.js +159 -0
- package/dist/splitter.utils.mjs +14 -0
- package/package.json +4 -4
- package/dist/chunk-7IDNY7GP.mjs +0 -217
- package/dist/chunk-A3GF7W2N.mjs +0 -97
- package/dist/chunk-DX6NGFGC.mjs +0 -16
package/dist/splitter.dom.js
CHANGED
|
@@ -51,25 +51,7 @@ function defineDomHelpers(helpers) {
|
|
|
51
51
|
return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
|
|
52
52
|
},
|
|
53
53
|
getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
|
|
54
|
-
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
55
|
-
createEmitter: (ctx, target) => {
|
|
56
|
-
const win = dom2.getWin(ctx);
|
|
57
|
-
return function emit(evt, detail, options) {
|
|
58
|
-
const { bubbles = true, cancelable, composed = true } = options != null ? options : {};
|
|
59
|
-
const eventName = `zag:${evt}`;
|
|
60
|
-
const init = { bubbles, cancelable, composed, detail };
|
|
61
|
-
const event = new win.CustomEvent(eventName, init);
|
|
62
|
-
target.dispatchEvent(event);
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
createListener: (target) => {
|
|
66
|
-
return function listen(evt, handler) {
|
|
67
|
-
const eventName = `zag:${evt}`;
|
|
68
|
-
const listener = (e) => handler(e);
|
|
69
|
-
target.addEventListener(eventName, listener);
|
|
70
|
-
return () => target.removeEventListener(eventName, listener);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
54
|
+
getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
|
|
73
55
|
};
|
|
74
56
|
return {
|
|
75
57
|
...dom2,
|
|
@@ -77,44 +59,67 @@ function defineDomHelpers(helpers) {
|
|
|
77
59
|
};
|
|
78
60
|
}
|
|
79
61
|
|
|
62
|
+
// ../../utilities/dom/src/nodelist.ts
|
|
63
|
+
function queryAll(root, selector) {
|
|
64
|
+
var _a;
|
|
65
|
+
return Array.from((_a = root == null ? void 0 : root.querySelectorAll(selector)) != null ? _a : []);
|
|
66
|
+
}
|
|
67
|
+
|
|
80
68
|
// src/splitter.dom.ts
|
|
81
69
|
var dom = defineDomHelpers({
|
|
82
|
-
getRootId: (ctx) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var _a, _b;
|
|
92
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.toggleBtn) != null ? _b : `splitter:${ctx.id}:toggle-btn`;
|
|
93
|
-
},
|
|
94
|
-
getLabelId: (ctx) => {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `splitter:${ctx.id}:label`;
|
|
97
|
-
},
|
|
98
|
-
getPrimaryPaneId: (ctx) => {
|
|
99
|
-
var _a, _b;
|
|
100
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.primaryPane) != null ? _b : `splitter:${ctx.id}:primary`;
|
|
101
|
-
},
|
|
102
|
-
getSecondaryPaneId: (ctx) => {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.secondaryPane) != null ? _b : `splitter:${ctx.id}:secondary`;
|
|
105
|
-
},
|
|
106
|
-
getSplitterEl: (ctx) => dom.getById(ctx, dom.getSplitterId(ctx)),
|
|
107
|
-
getPrimaryPaneEl: (ctx) => dom.getById(ctx, dom.getPrimaryPaneId(ctx)),
|
|
70
|
+
getRootId: (ctx) => `splitter:${ctx.id}`,
|
|
71
|
+
getResizeTriggerId: (ctx, id) => `splitter:${ctx.id}:splitter:${id}`,
|
|
72
|
+
getToggleTriggerId: (ctx) => `splitter:${ctx.id}:toggle-btn`,
|
|
73
|
+
getLabelId: (ctx) => `splitter:${ctx.id}:label`,
|
|
74
|
+
getPanelId: (ctx, id) => `splitter:${ctx.id}:panel:${id}`,
|
|
75
|
+
globalCursorId: (ctx) => `splitter:${ctx.id}:global-cursor`,
|
|
76
|
+
getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
|
|
77
|
+
getResizeTriggerEl: (ctx, id) => dom.getById(ctx, dom.getResizeTriggerId(ctx, id)),
|
|
78
|
+
getPanelEl: (ctx, id) => dom.getById(ctx, dom.getPanelId(ctx, id)),
|
|
108
79
|
getCursor(ctx) {
|
|
109
|
-
if (ctx.disabled || ctx.fixed)
|
|
110
|
-
return "default";
|
|
111
80
|
const x = ctx.isHorizontal;
|
|
112
81
|
let cursor = x ? "col-resize" : "row-resize";
|
|
113
|
-
if (ctx.isAtMin)
|
|
82
|
+
if (ctx.activeResizeState.isAtMin)
|
|
114
83
|
cursor = x ? "e-resize" : "s-resize";
|
|
115
|
-
if (ctx.isAtMax)
|
|
84
|
+
if (ctx.activeResizeState.isAtMax)
|
|
116
85
|
cursor = x ? "w-resize" : "n-resize";
|
|
117
86
|
return cursor;
|
|
87
|
+
},
|
|
88
|
+
getPanelStyle(ctx, id) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const flexGrow = (_b = (_a = ctx.panels.find((panel) => panel.id === id)) == null ? void 0 : _a.size) != null ? _b : "0";
|
|
91
|
+
return {
|
|
92
|
+
flexBasis: 0,
|
|
93
|
+
flexGrow,
|
|
94
|
+
flexShrink: 1,
|
|
95
|
+
overflow: "hidden"
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
getActiveHandleEl(ctx) {
|
|
99
|
+
const activeId = ctx.activeResizeId;
|
|
100
|
+
if (activeId == null)
|
|
101
|
+
return;
|
|
102
|
+
return dom.getById(ctx, dom.getResizeTriggerId(ctx, activeId));
|
|
103
|
+
},
|
|
104
|
+
getResizeTriggerEls(ctx) {
|
|
105
|
+
const ownerId = CSS.escape(dom.getRootId(ctx));
|
|
106
|
+
return queryAll(dom.getRootEl(ctx), `[role=separator][data-ownedby='${ownerId}']`);
|
|
107
|
+
},
|
|
108
|
+
setupGlobalCursor(ctx) {
|
|
109
|
+
const styleEl = dom.getById(ctx, dom.globalCursorId(ctx));
|
|
110
|
+
const textContent = `* { cursor: ${dom.getCursor(ctx)} !important; }`;
|
|
111
|
+
if (styleEl) {
|
|
112
|
+
styleEl.textContent = textContent;
|
|
113
|
+
} else {
|
|
114
|
+
const style = dom.getDoc(ctx).createElement("style");
|
|
115
|
+
style.id = dom.globalCursorId(ctx);
|
|
116
|
+
style.textContent = textContent;
|
|
117
|
+
dom.getDoc(ctx).head.appendChild(style);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
removeGlobalCursor(ctx) {
|
|
121
|
+
var _a;
|
|
122
|
+
(_a = dom.getById(ctx, dom.globalCursorId(ctx))) == null ? void 0 : _a.remove();
|
|
118
123
|
}
|
|
119
124
|
});
|
|
120
125
|
// Annotate the CommonJS export names for ESM import in node:
|