@ixfx/components 0.6.2 → 0.7.0
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/bundle/index.d.ts +1490 -615
- package/bundle/index.d.ts.map +1 -1
- package/bundle/index.js +20477 -15855
- package/bundle/index.js.map +1 -1
- package/bundle/style.css +1 -1
- package/dist/ac-text.js +3 -2
- package/dist/ac-text.js.map +1 -1
- package/dist/ac-token.js +3 -2
- package/dist/ac-token.js.map +1 -1
- package/dist/{button-Bn0BuLpO.js → button-Dat2yHAU.js} +4 -3
- package/dist/button-Dat2yHAU.js.map +1 -0
- package/dist/button.js +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{colour-picker-0stHB90J.js → colour-picker-BSDBL-QL.js} +4 -3
- package/dist/{colour-picker-0stHB90J.js.map → colour-picker-BSDBL-QL.js.map} +1 -1
- package/dist/colour-picker.js +1 -1
- package/dist/crumbs.js +4 -2
- package/dist/crumbs.js.map +1 -1
- package/dist/data-display.js +1 -1
- package/dist/data-grid.js +4 -2
- package/dist/data-grid.js.map +1 -1
- package/dist/{defaults-BCiDhZbF.js → defaults-BkWCPJFL.js} +3 -20
- package/dist/defaults-BkWCPJFL.js.map +1 -0
- package/dist/editable-label-rzXkjf1H.d.ts +75 -0
- package/dist/editable-label-rzXkjf1H.d.ts.map +1 -0
- package/dist/editable-label.d.ts +2 -75
- package/dist/editable-label.js +2 -1
- package/dist/editable-label.js.map +1 -1
- package/dist/{fallbacks-DEE1nCTt.js → fallbacks-DNI9xt0F.js} +2 -2
- package/dist/{fallbacks-DEE1nCTt.js.map → fallbacks-DNI9xt0F.js.map} +1 -1
- package/dist/{grouped-item-lister-_pMDwIo1.d.ts → grouped-item-lister-DnWB-eFT.d.ts} +2 -2
- package/dist/{grouped-item-lister-_pMDwIo1.d.ts.map → grouped-item-lister-DnWB-eFT.d.ts.map} +1 -1
- package/dist/grouped-item-lister.d.ts +1 -1
- package/dist/{icons-Bm2ByQ3s.js → icon-CvnPanhA.js} +3 -6
- package/dist/icon-CvnPanhA.js.map +1 -0
- package/dist/icons.js +8 -2
- package/dist/icons.js.map +1 -0
- package/dist/index-CG2vIgPv.d.ts +101 -0
- package/dist/index-CG2vIgPv.d.ts.map +1 -0
- package/dist/index.d.ts +655 -65
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3682 -924
- package/dist/index.js.map +1 -1
- package/dist/interaction-D5XdKzbR.js +2 -0
- package/dist/labelled-radial-input.js +2 -1
- package/dist/labelled-radial-input.js.map +1 -1
- package/dist/labelled-slider-input-DzigjMwP.js +808 -0
- package/dist/labelled-slider-input-DzigjMwP.js.map +1 -0
- package/dist/labelled-slider-input.d.ts +2 -0
- package/dist/labelled-slider-input.js +2 -0
- package/dist/{types-DlVNJez_.d.ts → list-selection-types-DSuRNWpx.d.ts} +10 -2
- package/dist/list-selection-types-DSuRNWpx.d.ts.map +1 -0
- package/dist/menu-BjRvlgPy.js +825 -0
- package/dist/menu-BjRvlgPy.js.map +1 -0
- package/dist/menu-item-B-zYrTTi.js +797 -0
- package/dist/menu-item-B-zYrTTi.js.map +1 -0
- package/dist/menu.js +2 -1
- package/dist/miller.d.ts +1 -1
- package/dist/miller.js +3 -2
- package/dist/miller.js.map +1 -1
- package/dist/narrowed-text.js +4 -2
- package/dist/narrowed-text.js.map +1 -1
- package/dist/notifier.js +3 -2
- package/dist/notifier.js.map +1 -1
- package/dist/panel.d.ts +13 -13
- package/dist/panel.d.ts.map +1 -1
- package/dist/panel.js +37 -253
- package/dist/panel.js.map +1 -1
- package/dist/plots.js +1 -1
- package/dist/polar-pad.js +1 -1
- package/dist/{radial-input-Dk8Wydp5.js → radial-input-Dp5qz0ly.js} +2 -2
- package/dist/{radial-input-Dk8Wydp5.js.map → radial-input-Dp5qz0ly.js.map} +1 -1
- package/dist/radial-input.js +1 -1
- package/dist/range-input.js +1 -1
- package/dist/range.js +1 -1
- package/dist/registry-CkW7q09Q.js +21 -0
- package/dist/registry-CkW7q09Q.js.map +1 -0
- package/dist/select-horiz.js +3 -2
- package/dist/select-horiz.js.map +1 -1
- package/dist/{slider-input-XppH3vcy.d.ts → slider-input-BfRUW2ZB.d.ts} +16 -3
- package/dist/slider-input-BfRUW2ZB.d.ts.map +1 -0
- package/dist/{slider-input-CT4gcF-o.js → slider-input-De4eoT11.js} +382 -67
- package/dist/slider-input-De4eoT11.js.map +1 -0
- package/dist/slider-input.d.ts +1 -1
- package/dist/slider-input.js +1 -1
- package/dist/snackbar.js +1 -1
- package/dist/split-layout-BFSbUZQv.js +969 -0
- package/dist/split-layout-BFSbUZQv.js.map +1 -0
- package/dist/split-layout-JK3xWVX2.d.ts +179 -0
- package/dist/split-layout-JK3xWVX2.d.ts.map +1 -0
- package/dist/split-layout.d.ts +2 -60
- package/dist/split-layout.js +1 -617
- package/dist/style.css +1 -1
- package/dist/swipe.js +1 -1
- package/dist/{tab-list-D_1cYhB_.d.ts → tab-list-MPwq_1Jj.d.ts} +2 -1
- package/dist/tab-list-MPwq_1Jj.d.ts.map +1 -0
- package/dist/tabs.d.ts +1 -1
- package/dist/tabs.js +96 -14
- package/dist/tabs.js.map +1 -1
- package/dist/{tickled-controller-BtevrRLV.d.ts → tickled-controller-CRzdIEjJ.d.ts} +7 -1
- package/dist/tickled-controller-CRzdIEjJ.d.ts.map +1 -0
- package/dist/{tickled-controller-DkAU-0qL.js → tickled-controller-h9GmJ_bU.js} +8 -2
- package/dist/tickled-controller-h9GmJ_bU.js.map +1 -0
- package/dist/titlebar-DaCfpliv.d.ts +50 -0
- package/dist/titlebar-DaCfpliv.d.ts.map +1 -0
- package/dist/titlebar.d.ts +2 -0
- package/dist/titlebar.js +324 -0
- package/dist/titlebar.js.map +1 -0
- package/dist/{tree-BO6BXI2b.js → tree-Ch4W8qXQ.js} +4 -3
- package/dist/{tree-BO6BXI2b.js.map → tree-Ch4W8qXQ.js.map} +1 -1
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +1 -1
- package/dist/vertical-list-ClnqTkF3.js +814 -0
- package/dist/vertical-list-ClnqTkF3.js.map +1 -0
- package/dist/vertical-list.d.ts +8 -9
- package/dist/vertical-list.d.ts.map +1 -1
- package/dist/vertical-list.js +1 -736
- package/dist/{xy-axis-B6yMjckW.js → xy-axis-CxHC8z5E.js} +109 -3
- package/dist/xy-axis-CxHC8z5E.js.map +1 -0
- package/dist/xy-pad.js +1 -1
- package/docs-user/README.md +5 -0
- package/docs-user/detail-list.md +398 -0
- package/docs-user/dock.md +310 -0
- package/docs-user/index.json +27 -2
- package/docs-user/labelled-slider-input.md +198 -0
- package/docs-user/llms.txt +6 -1
- package/docs-user/panel.md +20 -1
- package/docs-user/slider-input.md +55 -15
- package/docs-user/split-layout.md +136 -170
- package/docs-user/tabs.md +34 -0
- package/docs-user/titlebar.md +102 -0
- package/docs-user/toolbar.md +95 -22
- package/docs-user/twosplit-layout.md +254 -0
- package/docs-user/user-catalog.md +8 -1
- package/llms.txt +6 -1
- package/package.json +1 -2
- package/dist/button-Bn0BuLpO.js.map +0 -1
- package/dist/defaults-BCiDhZbF.js.map +0 -1
- package/dist/editable-label.d.ts.map +0 -1
- package/dist/icons-Bm2ByQ3s.js.map +0 -1
- package/dist/menu-DIfU70AA.js +0 -1609
- package/dist/menu-DIfU70AA.js.map +0 -1
- package/dist/slider-input-CT4gcF-o.js.map +0 -1
- package/dist/slider-input-XppH3vcy.d.ts.map +0 -1
- package/dist/split-layout.d.ts.map +0 -1
- package/dist/split-layout.js.map +0 -1
- package/dist/tab-list-D_1cYhB_.d.ts.map +0 -1
- package/dist/tickled-controller-BtevrRLV.d.ts.map +0 -1
- package/dist/tickled-controller-DkAU-0qL.js.map +0 -1
- package/dist/types-DlVNJez_.d.ts.map +0 -1
- package/dist/vertical-list.js.map +0 -1
- package/dist/xy-axis-B6yMjckW.js.map +0 -1
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
import { t as themeFallbacks } from "./fallbacks-DNI9xt0F.js";
|
|
2
|
+
import { n as safeCustomElement, t as __decorate } from "./decorate-VRK8rslU.js";
|
|
3
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
4
|
+
import { property, query, state } from "lit/decorators.js";
|
|
5
|
+
//#region src/split-layout/split-drag.ts
|
|
6
|
+
function createDragMachine(handlers) {
|
|
7
|
+
let state = null;
|
|
8
|
+
let rafId = null;
|
|
9
|
+
let pendingMove = null;
|
|
10
|
+
function startGutterDrag(groupId, gutterIndex, _pointerId, clientX, clientY, containerRect, trackSizes, constraints) {
|
|
11
|
+
state = {
|
|
12
|
+
isDragging: true,
|
|
13
|
+
groupId,
|
|
14
|
+
gutterIndex,
|
|
15
|
+
startPointerX: clientX,
|
|
16
|
+
startPointerY: clientY,
|
|
17
|
+
containerRect,
|
|
18
|
+
trackSizes,
|
|
19
|
+
minConstraints: constraints.map((c) => c.minPx),
|
|
20
|
+
maxConstraints: constraints.map((c) => c.maxPx),
|
|
21
|
+
fixedConstraints: constraints.map((c) => c.fixedPx),
|
|
22
|
+
whenSmallConstraints: constraints.map((c) => c.whenSmall)
|
|
23
|
+
};
|
|
24
|
+
handlers.onDragStart(state);
|
|
25
|
+
}
|
|
26
|
+
function move(pointerEvent) {
|
|
27
|
+
if (!state || !state.isDragging) return;
|
|
28
|
+
pendingMove = {
|
|
29
|
+
deltaX: pointerEvent.clientX - state.startPointerX,
|
|
30
|
+
deltaY: pointerEvent.clientY - state.startPointerY
|
|
31
|
+
};
|
|
32
|
+
if (rafId === null) rafId = requestAnimationFrame(flushMove);
|
|
33
|
+
}
|
|
34
|
+
function flushMove() {
|
|
35
|
+
if (!state || !pendingMove) {
|
|
36
|
+
rafId = null;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { deltaX, deltaY } = pendingMove;
|
|
40
|
+
pendingMove = null;
|
|
41
|
+
rafId = null;
|
|
42
|
+
handlers.onDragMove(state, deltaX, deltaY);
|
|
43
|
+
}
|
|
44
|
+
function end(_pointerEvent) {
|
|
45
|
+
if (!state || !state.isDragging) return;
|
|
46
|
+
if (rafId !== null) {
|
|
47
|
+
cancelAnimationFrame(rafId);
|
|
48
|
+
rafId = null;
|
|
49
|
+
}
|
|
50
|
+
pendingMove = null;
|
|
51
|
+
handlers.onDragEnd(state);
|
|
52
|
+
state = null;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
startGutterDrag,
|
|
56
|
+
move,
|
|
57
|
+
end,
|
|
58
|
+
getState: () => state
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/split-layout/split-model.ts
|
|
63
|
+
let panelIdCounter = 0;
|
|
64
|
+
let groupIdCounter = 0;
|
|
65
|
+
function generatePanelId() {
|
|
66
|
+
return `p-${++panelIdCounter}`;
|
|
67
|
+
}
|
|
68
|
+
function generateGroupId() {
|
|
69
|
+
return `g-${++groupIdCounter}`;
|
|
70
|
+
}
|
|
71
|
+
function resetIdCounters() {
|
|
72
|
+
panelIdCounter = 0;
|
|
73
|
+
groupIdCounter = 0;
|
|
74
|
+
}
|
|
75
|
+
function readOwnWeight(el) {
|
|
76
|
+
const attr = el.getAttribute(`size`) ?? el.getAttribute(`weight`);
|
|
77
|
+
if (attr === null) return void 0;
|
|
78
|
+
const value = Number.parseFloat(attr);
|
|
79
|
+
return Number.isNaN(value) ? void 0 : value;
|
|
80
|
+
}
|
|
81
|
+
function buildModel(rootEl) {
|
|
82
|
+
resetIdCounters();
|
|
83
|
+
return buildGroupFromElement(rootEl, null);
|
|
84
|
+
}
|
|
85
|
+
function buildGroupFromElement(el, _parentAxis) {
|
|
86
|
+
const isNestedLayout = el.tagName === `IXFX-SPLIT-LAYOUT`;
|
|
87
|
+
const axis = el.getAttribute(`direction`) === `column` ? `column` : `row`;
|
|
88
|
+
const group = {
|
|
89
|
+
kind: `group`,
|
|
90
|
+
id: el.id || generateGroupId(),
|
|
91
|
+
el: isNestedLayout ? el : null,
|
|
92
|
+
axis,
|
|
93
|
+
children: [],
|
|
94
|
+
weight: readOwnWeight(el) ?? 1,
|
|
95
|
+
fixedPx: null
|
|
96
|
+
};
|
|
97
|
+
const sizesAttr = el.getAttribute(`sizes`);
|
|
98
|
+
const sizes = sizesAttr ? sizesAttr.split(/\s+/).map((s) => Number.parseFloat(s)).filter((n) => !Number.isNaN(n)) : [];
|
|
99
|
+
const childNodes = Array.from(el.children);
|
|
100
|
+
let sizeIndex = 0;
|
|
101
|
+
for (const child of childNodes) {
|
|
102
|
+
const positional = sizeIndex < sizes.length ? sizes[sizeIndex] : void 0;
|
|
103
|
+
sizeIndex++;
|
|
104
|
+
if (child.tagName === `IXFX-SPLIT-LAYOUT`) group.children.push(buildGroupFromElement(child, axis));
|
|
105
|
+
else if (child.tagName === `IXFX-SPLIT-PANEL`) group.children.push(buildPanelNode(child, positional));
|
|
106
|
+
else {
|
|
107
|
+
const wrapper = createImplicitPanel(child, positional);
|
|
108
|
+
group.children.push(wrapper);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (group.children.length === 0) {
|
|
112
|
+
const implicitPanel = createImplicitPanelWithoutId();
|
|
113
|
+
group.children.push(implicitPanel);
|
|
114
|
+
}
|
|
115
|
+
return group;
|
|
116
|
+
}
|
|
117
|
+
function createImplicitPanel(el, size) {
|
|
118
|
+
const minAttr = el.getAttribute(`min`);
|
|
119
|
+
const maxAttr = el.getAttribute(`max`);
|
|
120
|
+
const whenSmallAttr = el.getAttribute(`when-small`);
|
|
121
|
+
const fixedAttr = el.getAttribute(`fixed`);
|
|
122
|
+
const collapsedAttr = el.hasAttribute(`collapsed`);
|
|
123
|
+
let minPx = 0;
|
|
124
|
+
if (minAttr) minPx = parseLength(minAttr, 0);
|
|
125
|
+
let maxPx = null;
|
|
126
|
+
if (maxAttr) maxPx = parseLength(maxAttr, 0);
|
|
127
|
+
let fixedPx = null;
|
|
128
|
+
if (fixedAttr) fixedPx = fixedAttr === `` ? 100 : parseLength(fixedAttr, 100);
|
|
129
|
+
const weight = readOwnWeight(el) ?? size ?? 1;
|
|
130
|
+
return {
|
|
131
|
+
kind: `panel`,
|
|
132
|
+
id: el.id || generatePanelId(),
|
|
133
|
+
el,
|
|
134
|
+
weight,
|
|
135
|
+
fixedPx,
|
|
136
|
+
minPx,
|
|
137
|
+
maxPx,
|
|
138
|
+
whenSmall: whenSmallAttr || `prevent`,
|
|
139
|
+
collapsed: collapsedAttr,
|
|
140
|
+
restoreWeight: weight
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function createImplicitPanelWithoutId(size) {
|
|
144
|
+
return {
|
|
145
|
+
kind: `panel`,
|
|
146
|
+
id: generatePanelId(),
|
|
147
|
+
el: document.createElement(`div`),
|
|
148
|
+
weight: size ?? 1,
|
|
149
|
+
fixedPx: null,
|
|
150
|
+
minPx: 0,
|
|
151
|
+
maxPx: null,
|
|
152
|
+
whenSmall: `prevent`,
|
|
153
|
+
collapsed: false,
|
|
154
|
+
restoreWeight: size ?? 1
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function buildPanelNode(el, size) {
|
|
158
|
+
const sizeAttr = el.getAttribute(`size`) || el.getAttribute(`weight`);
|
|
159
|
+
const minAttr = el.getAttribute(`min`);
|
|
160
|
+
const maxAttr = el.getAttribute(`max`);
|
|
161
|
+
const whenSmallAttr = el.getAttribute(`when-small`);
|
|
162
|
+
const fixedAttr = el.getAttribute(`fixed`);
|
|
163
|
+
const collapsedAttr = el.hasAttribute(`collapsed`);
|
|
164
|
+
let weight = size ?? 1;
|
|
165
|
+
if (sizeAttr) weight = Number.parseFloat(sizeAttr);
|
|
166
|
+
let minPx = 0;
|
|
167
|
+
if (minAttr) minPx = parseLength(minAttr, 0);
|
|
168
|
+
let maxPx = null;
|
|
169
|
+
if (maxAttr) maxPx = parseLength(maxAttr, 0);
|
|
170
|
+
let fixedPx = null;
|
|
171
|
+
if (fixedAttr) fixedPx = fixedAttr === `` ? 100 : parseLength(fixedAttr, 100);
|
|
172
|
+
return {
|
|
173
|
+
kind: `panel`,
|
|
174
|
+
id: el.id || generatePanelId(),
|
|
175
|
+
el,
|
|
176
|
+
weight,
|
|
177
|
+
fixedPx,
|
|
178
|
+
minPx,
|
|
179
|
+
maxPx,
|
|
180
|
+
whenSmall: whenSmallAttr || `prevent`,
|
|
181
|
+
collapsed: collapsedAttr,
|
|
182
|
+
restoreWeight: weight
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function parseLength(value, fallback) {
|
|
186
|
+
if (value.endsWith(`px`)) return Number.parseFloat(value.replace(`px`, ``));
|
|
187
|
+
if (value.endsWith(`%`)) return fallback;
|
|
188
|
+
const num = Number.parseFloat(value);
|
|
189
|
+
return Number.isNaN(num) ? fallback : num;
|
|
190
|
+
}
|
|
191
|
+
function normalise(group) {
|
|
192
|
+
const flexibleWeights = [];
|
|
193
|
+
let totalFlexibleWeight = 0;
|
|
194
|
+
for (const child of group.children) if (child.kind === `panel`) {
|
|
195
|
+
if (child.fixedPx !== null) {} else if (!child.collapsed) {
|
|
196
|
+
flexibleWeights.push(child.weight);
|
|
197
|
+
totalFlexibleWeight += child.weight;
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
flexibleWeights.push(child.weight);
|
|
201
|
+
totalFlexibleWeight += child.weight;
|
|
202
|
+
}
|
|
203
|
+
if (totalFlexibleWeight === 0) totalFlexibleWeight = 1;
|
|
204
|
+
const normalizedChildren = [];
|
|
205
|
+
for (let i = 0; i < group.children.length; i++) {
|
|
206
|
+
const child = group.children[i];
|
|
207
|
+
if (child.kind === `panel`) {
|
|
208
|
+
if (child.fixedPx === null && !child.collapsed) normalizedChildren.push({
|
|
209
|
+
...child,
|
|
210
|
+
weight: child.weight / totalFlexibleWeight
|
|
211
|
+
});
|
|
212
|
+
else normalizedChildren.push(child);
|
|
213
|
+
} else normalizedChildren.push({
|
|
214
|
+
...child,
|
|
215
|
+
weight: child.weight / totalFlexibleWeight
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
...group,
|
|
220
|
+
children: normalizedChildren
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function distribute(sizesPx, gutterIndex, deltaPx, constraints) {
|
|
224
|
+
const result = [...sizesPx];
|
|
225
|
+
const belowMin = [];
|
|
226
|
+
if (deltaPx === 0) return {
|
|
227
|
+
sizesPx: result,
|
|
228
|
+
belowMin
|
|
229
|
+
};
|
|
230
|
+
const growSide = deltaPx > 0 ? gutterIndex : gutterIndex + 1;
|
|
231
|
+
const shrinkSide = deltaPx > 0 ? gutterIndex + 1 : gutterIndex;
|
|
232
|
+
let remaining = Math.abs(deltaPx);
|
|
233
|
+
for (let i = shrinkSide; i >= 0 && remaining > 0; i--) {
|
|
234
|
+
const c = constraints[i];
|
|
235
|
+
if (c.fixedPx !== null) continue;
|
|
236
|
+
const currentSize = result[i];
|
|
237
|
+
const room = currentSize - c.minPx;
|
|
238
|
+
if (room > 0) {
|
|
239
|
+
const take = Math.min(room, remaining);
|
|
240
|
+
result[i] -= take;
|
|
241
|
+
remaining -= take;
|
|
242
|
+
if (c.whenSmall !== `prevent` && result[i] <= c.minPx && result[i] > 0) {
|
|
243
|
+
belowMin.push(i);
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
} else if (c.whenSmall !== `prevent` && currentSize > 0) {
|
|
247
|
+
const take = Math.min(currentSize, remaining);
|
|
248
|
+
result[i] -= take;
|
|
249
|
+
remaining -= take;
|
|
250
|
+
if (result[i] <= c.minPx) {
|
|
251
|
+
belowMin.push(i);
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const actualMoved = Math.abs(deltaPx) - remaining;
|
|
257
|
+
if (actualMoved > 0) {
|
|
258
|
+
result[growSide] += actualMoved;
|
|
259
|
+
remaining = 0;
|
|
260
|
+
}
|
|
261
|
+
if (remaining > 0) for (let i = growSide; i < result.length && remaining > 0; i++) {
|
|
262
|
+
const c = constraints[i];
|
|
263
|
+
if (c.fixedPx !== null) continue;
|
|
264
|
+
const maxRoom = c.maxPx !== null ? c.maxPx - result[i] : Infinity;
|
|
265
|
+
if (maxRoom <= 0) continue;
|
|
266
|
+
const give = Math.min(maxRoom, remaining);
|
|
267
|
+
result[i] += give;
|
|
268
|
+
remaining -= give;
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
sizesPx: result,
|
|
272
|
+
belowMin
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function resolveTracks(group, _containerPx) {
|
|
276
|
+
const parts = [];
|
|
277
|
+
const gutterSize = `var(--split-gutter-size, 6px)`;
|
|
278
|
+
for (let i = 0; i < group.children.length; i++) {
|
|
279
|
+
const child = group.children[i];
|
|
280
|
+
let track;
|
|
281
|
+
if (child.kind === `panel`) {
|
|
282
|
+
if (child.collapsed) track = `var(--split-collapsed-size, 0px)`;
|
|
283
|
+
else if (child.fixedPx !== null) track = `${child.fixedPx}px`;
|
|
284
|
+
else track = `minmax(${child.minPx > 0 ? `${child.minPx}px` : `0px`}, var(--s${i}))`;
|
|
285
|
+
} else track = `minmax(0, var(--s${i}))`;
|
|
286
|
+
parts.push(track);
|
|
287
|
+
if (i < group.children.length - 1) parts.push(gutterSize);
|
|
288
|
+
}
|
|
289
|
+
return parts.join(` `);
|
|
290
|
+
}
|
|
291
|
+
function toSnapshot(group) {
|
|
292
|
+
return {
|
|
293
|
+
version: 1,
|
|
294
|
+
root: snapshotNode(group)
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function snapshotNode(node) {
|
|
298
|
+
if (node.kind === `panel`) return {
|
|
299
|
+
kind: `panel`,
|
|
300
|
+
id: node.id,
|
|
301
|
+
weight: node.weight,
|
|
302
|
+
collapsed: node.collapsed
|
|
303
|
+
};
|
|
304
|
+
const children = node.children.map((c) => snapshotNode(c));
|
|
305
|
+
return {
|
|
306
|
+
kind: `group`,
|
|
307
|
+
id: node.id,
|
|
308
|
+
weight: node.weight,
|
|
309
|
+
children
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function applySnapshot(group, snapshot) {
|
|
313
|
+
return applySnapshotToGroup(group, snapshot.root);
|
|
314
|
+
}
|
|
315
|
+
function applySnapshotToGroup(group, snapshot) {
|
|
316
|
+
if (snapshot.kind !== `group`) return group;
|
|
317
|
+
const weightMap = /* @__PURE__ */ new Map();
|
|
318
|
+
const collapsedMap = /* @__PURE__ */ new Map();
|
|
319
|
+
collectWeights(snapshot, weightMap, collapsedMap);
|
|
320
|
+
const newChildren = [];
|
|
321
|
+
for (const child of group.children) if (child.kind === `panel`) {
|
|
322
|
+
const newWeight = weightMap.get(child.id);
|
|
323
|
+
const collapsed = collapsedMap.get(child.id);
|
|
324
|
+
newChildren.push({
|
|
325
|
+
...child,
|
|
326
|
+
weight: newWeight !== void 0 ? newWeight : child.weight,
|
|
327
|
+
collapsed: collapsed !== void 0 ? collapsed : child.collapsed
|
|
328
|
+
});
|
|
329
|
+
} else {
|
|
330
|
+
const childSnapshot = snapshot.children?.find((c) => c.id === child.id);
|
|
331
|
+
if (childSnapshot) newChildren.push(applySnapshotToGroup(child, childSnapshot));
|
|
332
|
+
else newChildren.push(child);
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
...group,
|
|
336
|
+
children: newChildren
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function collectWeights(snapshot, weights, collapsed) {
|
|
340
|
+
if (snapshot.kind === `panel`) {
|
|
341
|
+
weights.set(snapshot.id, snapshot.weight ?? 1);
|
|
342
|
+
if (snapshot.collapsed !== void 0) collapsed.set(snapshot.id, snapshot.collapsed);
|
|
343
|
+
} else if (snapshot.children) for (const child of snapshot.children) collectWeights(child, weights, collapsed);
|
|
344
|
+
}
|
|
345
|
+
function walk(group, visitor) {
|
|
346
|
+
walkInner(group, [], visitor);
|
|
347
|
+
}
|
|
348
|
+
function walkInner(node, path, visitor) {
|
|
349
|
+
visitor(node, path);
|
|
350
|
+
if (node.kind === `group`) for (let i = 0; i < node.children.length; i++) walkInner(node.children[i], [...path, i], visitor);
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/split-layout/split-panel.ts
|
|
354
|
+
let SplitPanelElement = class SplitPanelElement extends LitElement {
|
|
355
|
+
constructor(..._args) {
|
|
356
|
+
super(..._args);
|
|
357
|
+
this.id = ``;
|
|
358
|
+
this.size = ``;
|
|
359
|
+
this.weight = ``;
|
|
360
|
+
this.fixed = ``;
|
|
361
|
+
this.min = ``;
|
|
362
|
+
this.max = ``;
|
|
363
|
+
this.whenSmall = `prevent`;
|
|
364
|
+
this.collapsed = false;
|
|
365
|
+
this.snap = ``;
|
|
366
|
+
}
|
|
367
|
+
render() {
|
|
368
|
+
return html`<slot></slot>`;
|
|
369
|
+
}
|
|
370
|
+
static {
|
|
371
|
+
this.styles = [themeFallbacks, css`
|
|
372
|
+
:host {
|
|
373
|
+
display: block;
|
|
374
|
+
width: 100%;
|
|
375
|
+
height: 100%;
|
|
376
|
+
overflow: hidden;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
:host([collapsed]) {
|
|
380
|
+
visibility: hidden;
|
|
381
|
+
}
|
|
382
|
+
`];
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
__decorate([property({
|
|
386
|
+
type: String,
|
|
387
|
+
reflect: true
|
|
388
|
+
})], SplitPanelElement.prototype, "id", void 0);
|
|
389
|
+
__decorate([property({ type: String })], SplitPanelElement.prototype, "size", void 0);
|
|
390
|
+
__decorate([property({ type: String })], SplitPanelElement.prototype, "weight", void 0);
|
|
391
|
+
__decorate([property({ type: String })], SplitPanelElement.prototype, "fixed", void 0);
|
|
392
|
+
__decorate([property({ type: String })], SplitPanelElement.prototype, "min", void 0);
|
|
393
|
+
__decorate([property({ type: String })], SplitPanelElement.prototype, "max", void 0);
|
|
394
|
+
__decorate([property({
|
|
395
|
+
type: String,
|
|
396
|
+
attribute: `when-small`
|
|
397
|
+
})], SplitPanelElement.prototype, "whenSmall", void 0);
|
|
398
|
+
__decorate([property({
|
|
399
|
+
type: Boolean,
|
|
400
|
+
reflect: true
|
|
401
|
+
})], SplitPanelElement.prototype, "collapsed", void 0);
|
|
402
|
+
__decorate([property({ type: String })], SplitPanelElement.prototype, "snap", void 0);
|
|
403
|
+
SplitPanelElement = __decorate([safeCustomElement(`ixfx-split-panel`)], SplitPanelElement);
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/split-layout/split-layout.ts
|
|
406
|
+
let SplitLayoutElement = class SplitLayoutElement extends LitElement {
|
|
407
|
+
constructor(..._args) {
|
|
408
|
+
super(..._args);
|
|
409
|
+
this.direction = `row`;
|
|
410
|
+
this.sizes = ``;
|
|
411
|
+
this.gutterSize = ``;
|
|
412
|
+
this.snap = ``;
|
|
413
|
+
this._model = null;
|
|
414
|
+
this._resizing = false;
|
|
415
|
+
this._observer = null;
|
|
416
|
+
this._applyingOwnMutation = false;
|
|
417
|
+
this._dragStructurallyChanged = false;
|
|
418
|
+
this._dragMachine = createDragMachine({
|
|
419
|
+
onDragStart: (state) => this._handleDragStart(state),
|
|
420
|
+
onDragMove: (state, deltaX, deltaY) => this._handleDragMove(state, deltaX, deltaY),
|
|
421
|
+
onDragEnd: (state) => this._handleDragEnd(state),
|
|
422
|
+
distribute: (sizes, idx, delta, constraints) => {
|
|
423
|
+
return distribute(sizes, idx, delta, constraints);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
this._onGutterPointerDown = (e, groupId, gutterIndex) => {
|
|
427
|
+
e.preventDefault();
|
|
428
|
+
if (!this._groupEl || !this._model) return;
|
|
429
|
+
const { rect, trackSizes, constraints } = this._snapshotTracks();
|
|
430
|
+
this._dragMachine.startGutterDrag(groupId, gutterIndex, e.pointerId, e.clientX, e.clientY, rect, trackSizes, constraints);
|
|
431
|
+
window.addEventListener(`pointermove`, this._onPointerMove);
|
|
432
|
+
window.addEventListener(`pointerup`, this._onPointerUp);
|
|
433
|
+
};
|
|
434
|
+
this._onPointerMove = (e) => {
|
|
435
|
+
this._dragMachine.move(e);
|
|
436
|
+
};
|
|
437
|
+
this._onPointerUp = (e) => {
|
|
438
|
+
this._dragMachine.end(e);
|
|
439
|
+
window.removeEventListener(`pointermove`, this._onPointerMove);
|
|
440
|
+
window.removeEventListener(`pointerup`, this._onPointerUp);
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
connectedCallback() {
|
|
444
|
+
super.connectedCallback();
|
|
445
|
+
this._setupObserver();
|
|
446
|
+
}
|
|
447
|
+
disconnectedCallback() {
|
|
448
|
+
super.disconnectedCallback();
|
|
449
|
+
this._observer?.disconnect();
|
|
450
|
+
}
|
|
451
|
+
firstUpdated() {
|
|
452
|
+
this._rebuildModel();
|
|
453
|
+
}
|
|
454
|
+
_setupObserver() {
|
|
455
|
+
this._observer = new MutationObserver(() => {
|
|
456
|
+
if (!this._applyingOwnMutation) Promise.resolve().then(() => this._rebuildModel());
|
|
457
|
+
});
|
|
458
|
+
this._observer.observe(this, {
|
|
459
|
+
childList: true,
|
|
460
|
+
subtree: true,
|
|
461
|
+
attributeFilter: [
|
|
462
|
+
`size`,
|
|
463
|
+
`weight`,
|
|
464
|
+
`min`,
|
|
465
|
+
`max`,
|
|
466
|
+
`when-small`,
|
|
467
|
+
`fixed`,
|
|
468
|
+
`direction`,
|
|
469
|
+
`collapsed`,
|
|
470
|
+
`sizes`
|
|
471
|
+
]
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
_rebuildModel() {
|
|
475
|
+
this._reindexSlots();
|
|
476
|
+
const normalized = normalise(buildModel(this));
|
|
477
|
+
this._model = normalized;
|
|
478
|
+
this.requestUpdate();
|
|
479
|
+
}
|
|
480
|
+
get panels() {
|
|
481
|
+
if (!this._model) return [];
|
|
482
|
+
const panels = [];
|
|
483
|
+
walk(this._model, (node, path) => {
|
|
484
|
+
if (node.kind === `panel`) panels.push({
|
|
485
|
+
id: node.id,
|
|
486
|
+
el: node.el,
|
|
487
|
+
index: path[path.length - 1],
|
|
488
|
+
path: path.join(`-`),
|
|
489
|
+
weight: node.weight,
|
|
490
|
+
collapsed: node.collapsed,
|
|
491
|
+
min: node.minPx,
|
|
492
|
+
max: node.maxPx,
|
|
493
|
+
whenSmall: node.whenSmall
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
return panels;
|
|
497
|
+
}
|
|
498
|
+
getLayout() {
|
|
499
|
+
if (!this._model) return null;
|
|
500
|
+
return toSnapshot(this._model);
|
|
501
|
+
}
|
|
502
|
+
setLayout(s) {
|
|
503
|
+
if (!this._model) return;
|
|
504
|
+
this._applyingOwnMutation = true;
|
|
505
|
+
this._model = applySnapshot(this._model, s);
|
|
506
|
+
this.requestUpdate();
|
|
507
|
+
this._applyingOwnMutation = false;
|
|
508
|
+
this._emitChange();
|
|
509
|
+
}
|
|
510
|
+
getSizes(_groupId) {
|
|
511
|
+
if (!this._model) return {};
|
|
512
|
+
const result = {};
|
|
513
|
+
if (this._model.children) this._model.children.forEach((child) => {
|
|
514
|
+
result[child.id] = child.weight;
|
|
515
|
+
});
|
|
516
|
+
return result;
|
|
517
|
+
}
|
|
518
|
+
setSizes(weights, _groupId) {
|
|
519
|
+
if (!this._model) return;
|
|
520
|
+
this._applyingOwnMutation = true;
|
|
521
|
+
if (Array.isArray(weights)) this._model.children.forEach((child, i) => {
|
|
522
|
+
if (i < weights.length) child.weight = weights[i];
|
|
523
|
+
});
|
|
524
|
+
else for (const [id, weight] of Object.entries(weights)) {
|
|
525
|
+
const child = this._model.children.find((c) => c.id === id);
|
|
526
|
+
if (child) child.weight = weight;
|
|
527
|
+
}
|
|
528
|
+
this._model = normalise(this._model);
|
|
529
|
+
this.requestUpdate();
|
|
530
|
+
this._applyingOwnMutation = false;
|
|
531
|
+
this._emitResize();
|
|
532
|
+
this._emitChange();
|
|
533
|
+
}
|
|
534
|
+
collapse(idOrEl) {
|
|
535
|
+
this._setCollapsedState(idOrEl, true);
|
|
536
|
+
}
|
|
537
|
+
expand(idOrEl) {
|
|
538
|
+
this._setCollapsedState(idOrEl, false);
|
|
539
|
+
}
|
|
540
|
+
toggle(idOrEl) {
|
|
541
|
+
const panel = this._findPanel(idOrEl);
|
|
542
|
+
if (panel) this._setCollapsedState(panel.id, !panel.collapsed);
|
|
543
|
+
}
|
|
544
|
+
closePanel(idOrEl) {
|
|
545
|
+
const panel = this._findPanel(idOrEl);
|
|
546
|
+
if (!panel) return false;
|
|
547
|
+
const event = new CustomEvent(`ixfx-split-close`, {
|
|
548
|
+
detail: {
|
|
549
|
+
id: panel.id,
|
|
550
|
+
index: panel.index
|
|
551
|
+
},
|
|
552
|
+
bubbles: true,
|
|
553
|
+
composed: true,
|
|
554
|
+
cancelable: true
|
|
555
|
+
});
|
|
556
|
+
this.dispatchEvent(event);
|
|
557
|
+
if (event.defaultPrevented) return false;
|
|
558
|
+
this._applyingOwnMutation = true;
|
|
559
|
+
panel.el.remove();
|
|
560
|
+
this._rebuildModel();
|
|
561
|
+
this._observer?.takeRecords();
|
|
562
|
+
this._applyingOwnMutation = false;
|
|
563
|
+
this._emitResize();
|
|
564
|
+
this._emitChange();
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Bounding rects of the gutter elements, in gutter index order. lets
|
|
569
|
+
* callers (e.g. dock junction handles) hit-test gutters without reaching
|
|
570
|
+
* into the shadow DOM.
|
|
571
|
+
*/
|
|
572
|
+
getGutterRects() {
|
|
573
|
+
const gutters = this.shadowRoot?.querySelectorAll(`.gutter`);
|
|
574
|
+
if (gutters === void 0 || gutters === null) return [];
|
|
575
|
+
return Array.from(gutters, (g) => g.getBoundingClientRect());
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Programmatically begin dragging the gutter at `gutterIndex`, as if the
|
|
579
|
+
* user had pressed on it at (`clientX`, `clientY`). The drag then follows
|
|
580
|
+
* the pointer `pointerId` until pointerup, exactly like a native gutter
|
|
581
|
+
* drag. Returns false when the index is out of range or the layout isn't
|
|
582
|
+
* ready. Intended for composite resize affordances — e.g. a junction handle
|
|
583
|
+
* that starts this drag alongside perpendicular drags on other layouts.
|
|
584
|
+
*/
|
|
585
|
+
beginGutterDrag(gutterIndex, pointerId, clientX, clientY) {
|
|
586
|
+
if (!this._groupEl || !this._model) return false;
|
|
587
|
+
if (gutterIndex < 0 || gutterIndex >= this._model.children.length - 1) return false;
|
|
588
|
+
const { rect, trackSizes, constraints } = this._snapshotTracks();
|
|
589
|
+
this._dragMachine.startGutterDrag(this._model.id, gutterIndex, pointerId, clientX, clientY, rect, trackSizes, constraints);
|
|
590
|
+
window.addEventListener(`pointermove`, this._onPointerMove);
|
|
591
|
+
window.addEventListener(`pointerup`, this._onPointerUp);
|
|
592
|
+
return true;
|
|
593
|
+
}
|
|
594
|
+
_setCollapsedState(idOrEl, collapsed, revealWeight) {
|
|
595
|
+
const panel = this._findPanel(idOrEl);
|
|
596
|
+
if (!panel || panel.collapsed === collapsed) return;
|
|
597
|
+
this._applyingOwnMutation = true;
|
|
598
|
+
if (collapsed) {
|
|
599
|
+
panel.el.setAttribute(`collapsed`, ``);
|
|
600
|
+
panel.el.setAttribute(`data-collapsed`, ``);
|
|
601
|
+
} else {
|
|
602
|
+
panel.el.removeAttribute(`collapsed`);
|
|
603
|
+
panel.el.removeAttribute(`data-collapsed`);
|
|
604
|
+
}
|
|
605
|
+
this._rebuildModel();
|
|
606
|
+
if (!collapsed && revealWeight !== void 0) this._setFlexibleWeight(panel.id, revealWeight);
|
|
607
|
+
this.requestUpdate();
|
|
608
|
+
this._observer?.takeRecords();
|
|
609
|
+
this._applyingOwnMutation = false;
|
|
610
|
+
if (collapsed) this.dispatchEvent(new CustomEvent(`ixfx-split-collapse`, {
|
|
611
|
+
detail: {
|
|
612
|
+
id: panel.id,
|
|
613
|
+
index: panel.index
|
|
614
|
+
},
|
|
615
|
+
bubbles: true,
|
|
616
|
+
composed: true
|
|
617
|
+
}));
|
|
618
|
+
else this.dispatchEvent(new CustomEvent(`ixfx-split-expand`, {
|
|
619
|
+
detail: {
|
|
620
|
+
id: panel.id,
|
|
621
|
+
index: panel.index
|
|
622
|
+
},
|
|
623
|
+
bubbles: true,
|
|
624
|
+
composed: true
|
|
625
|
+
}));
|
|
626
|
+
this._emitResize();
|
|
627
|
+
this._emitChange();
|
|
628
|
+
}
|
|
629
|
+
_reindexSlots() {
|
|
630
|
+
Array.from(this.children).forEach((child, i) => {
|
|
631
|
+
const name = `panel-${i}`;
|
|
632
|
+
if (child.getAttribute(`slot`) !== name) child.setAttribute(`slot`, name);
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
_findPanel(idOrEl) {
|
|
636
|
+
const id = typeof idOrEl === `string` ? idOrEl : idOrEl.id;
|
|
637
|
+
return this.panels.find((p) => p.id === id);
|
|
638
|
+
}
|
|
639
|
+
_setFlexibleWeight(id, weight) {
|
|
640
|
+
if (!this._model) return;
|
|
641
|
+
const isFlexible = (c) => c.kind === `group` || c.fixedPx === null && !c.collapsed;
|
|
642
|
+
const flexible = this._model.children.filter(isFlexible);
|
|
643
|
+
const target = flexible.find((c) => c.id === id);
|
|
644
|
+
if (!target) return;
|
|
645
|
+
const t = Math.min(Math.max(weight, 0), .9);
|
|
646
|
+
const others = flexible.filter((c) => c !== target);
|
|
647
|
+
const othersTotal = others.reduce((sum, c) => sum + c.weight, 0) || 1;
|
|
648
|
+
const scale = (1 - t) / othersTotal;
|
|
649
|
+
for (const c of others) c.weight *= scale;
|
|
650
|
+
target.weight = t;
|
|
651
|
+
this._model = normalise(this._model);
|
|
652
|
+
}
|
|
653
|
+
_snapPx() {
|
|
654
|
+
const fromProp = Number.parseFloat(this.snap);
|
|
655
|
+
if (!Number.isNaN(fromProp)) return fromProp;
|
|
656
|
+
const fromVar = Number.parseFloat(getComputedStyle(this).getPropertyValue(`--split-snap`));
|
|
657
|
+
return Number.isNaN(fromVar) ? 24 : fromVar;
|
|
658
|
+
}
|
|
659
|
+
_collapsedPx() {
|
|
660
|
+
const v = Number.parseFloat(getComputedStyle(this).getPropertyValue(`--split-collapsed-size`));
|
|
661
|
+
return Number.isNaN(v) ? 0 : v;
|
|
662
|
+
}
|
|
663
|
+
_handleDragStart(_state) {
|
|
664
|
+
this._resizing = true;
|
|
665
|
+
this._dragStructurallyChanged = false;
|
|
666
|
+
this.setAttribute(`data-dragging`, ``);
|
|
667
|
+
}
|
|
668
|
+
_handleDragMove(state, deltaX, deltaY) {
|
|
669
|
+
if (!this._model) return;
|
|
670
|
+
if (this._dragStructurallyChanged) return;
|
|
671
|
+
const axis = this.direction;
|
|
672
|
+
const delta = axis === `row` ? deltaX : deltaY;
|
|
673
|
+
const gutterIndex = state.gutterIndex;
|
|
674
|
+
const growSide = delta > 0 ? gutterIndex : gutterIndex + 1;
|
|
675
|
+
const growNeighbour = this._model.children[growSide];
|
|
676
|
+
if (growNeighbour?.kind === `panel` && growNeighbour.collapsed) {
|
|
677
|
+
const revealPx = growNeighbour.minPx > 0 ? growNeighbour.minPx : this._snapPx();
|
|
678
|
+
if (Math.abs(delta) >= revealPx) {
|
|
679
|
+
const axisPx = axis === `row` ? state.containerRect.width : state.containerRect.height;
|
|
680
|
+
this._setCollapsedState(growNeighbour.id, false, axisPx > 0 ? revealPx / axisPx : void 0);
|
|
681
|
+
this._reseedDragState(state, state.startPointerX + deltaX, state.startPointerY + deltaY);
|
|
682
|
+
}
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
const constraints = state.minConstraints.map((min, i) => ({
|
|
686
|
+
minPx: min,
|
|
687
|
+
maxPx: state.maxConstraints[i],
|
|
688
|
+
fixedPx: state.fixedConstraints[i],
|
|
689
|
+
whenSmall: state.whenSmallConstraints[i]
|
|
690
|
+
}));
|
|
691
|
+
const result = distribute(state.trackSizes, gutterIndex, delta, constraints);
|
|
692
|
+
const totalSize = state.trackSizes.reduce((a, b) => a + b, 0);
|
|
693
|
+
result.sizesPx.forEach((size, i) => {
|
|
694
|
+
const child = this._model.children[i];
|
|
695
|
+
if (child && child.kind === `panel`) child.weight = size / totalSize;
|
|
696
|
+
});
|
|
697
|
+
if (result.belowMin.length > 0) {
|
|
698
|
+
let processed = false;
|
|
699
|
+
for (const idx of result.belowMin) {
|
|
700
|
+
if (processed) break;
|
|
701
|
+
const child = this._model.children[idx];
|
|
702
|
+
if (child && child.kind === `panel`) {
|
|
703
|
+
const whenSmall = child.whenSmall;
|
|
704
|
+
if (whenSmall === `collapse` && !child.collapsed) {
|
|
705
|
+
this._setCollapsedState(child.id, true);
|
|
706
|
+
processed = true;
|
|
707
|
+
this._dragStructurallyChanged = true;
|
|
708
|
+
} else if (whenSmall === `close`) {
|
|
709
|
+
this.closePanel(child.id);
|
|
710
|
+
processed = true;
|
|
711
|
+
this._dragStructurallyChanged = true;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
this._model = normalise(this._model);
|
|
717
|
+
this.requestUpdate();
|
|
718
|
+
}
|
|
719
|
+
_handleDragEnd(_state) {
|
|
720
|
+
this._resizing = false;
|
|
721
|
+
this.removeAttribute(`data-dragging`);
|
|
722
|
+
this._emitResize();
|
|
723
|
+
this._emitChange();
|
|
724
|
+
}
|
|
725
|
+
_snapshotTracks() {
|
|
726
|
+
const rect = this._groupEl.getBoundingClientRect();
|
|
727
|
+
const axisSize = this.direction === `row` ? rect.width : rect.height;
|
|
728
|
+
const collapsedPx = this._collapsedPx();
|
|
729
|
+
const children = this._model.children;
|
|
730
|
+
return {
|
|
731
|
+
rect,
|
|
732
|
+
trackSizes: children.map((c) => {
|
|
733
|
+
if (c.kind === `panel` && c.collapsed) return collapsedPx;
|
|
734
|
+
if (c.kind === `panel` && c.fixedPx !== null) return c.fixedPx;
|
|
735
|
+
return c.weight * axisSize;
|
|
736
|
+
}),
|
|
737
|
+
constraints: children.map((c) => {
|
|
738
|
+
if (c.kind === `panel`) return {
|
|
739
|
+
minPx: c.minPx,
|
|
740
|
+
maxPx: c.maxPx,
|
|
741
|
+
fixedPx: c.fixedPx,
|
|
742
|
+
whenSmall: c.whenSmall
|
|
743
|
+
};
|
|
744
|
+
return {
|
|
745
|
+
minPx: 0,
|
|
746
|
+
maxPx: null,
|
|
747
|
+
fixedPx: null,
|
|
748
|
+
whenSmall: `prevent`
|
|
749
|
+
};
|
|
750
|
+
})
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
_reseedDragState(state, pointerX, pointerY) {
|
|
754
|
+
if (!this._groupEl || !this._model) return;
|
|
755
|
+
const { rect, trackSizes, constraints } = this._snapshotTracks();
|
|
756
|
+
state.startPointerX = pointerX;
|
|
757
|
+
state.startPointerY = pointerY;
|
|
758
|
+
state.containerRect = rect;
|
|
759
|
+
state.trackSizes = trackSizes;
|
|
760
|
+
state.minConstraints = constraints.map((c) => c.minPx);
|
|
761
|
+
state.maxConstraints = constraints.map((c) => c.maxPx);
|
|
762
|
+
state.fixedConstraints = constraints.map((c) => c.fixedPx);
|
|
763
|
+
state.whenSmallConstraints = constraints.map((c) => c.whenSmall);
|
|
764
|
+
}
|
|
765
|
+
_emitResize() {
|
|
766
|
+
if (!this._model) return;
|
|
767
|
+
const detail = {
|
|
768
|
+
sizes: this.getSizes(),
|
|
769
|
+
groupId: this._model.id
|
|
770
|
+
};
|
|
771
|
+
this.dispatchEvent(new CustomEvent(`ixfx-split-resize`, {
|
|
772
|
+
detail,
|
|
773
|
+
bubbles: true,
|
|
774
|
+
composed: true
|
|
775
|
+
}));
|
|
776
|
+
}
|
|
777
|
+
_emitChange() {
|
|
778
|
+
const layout = this.getLayout();
|
|
779
|
+
if (!layout) return;
|
|
780
|
+
const detail = { layout };
|
|
781
|
+
this.dispatchEvent(new CustomEvent(`ixfx-split-change`, {
|
|
782
|
+
detail,
|
|
783
|
+
bubbles: true,
|
|
784
|
+
composed: true
|
|
785
|
+
}));
|
|
786
|
+
}
|
|
787
|
+
render() {
|
|
788
|
+
if (!this._model) return nothing;
|
|
789
|
+
const isRow = this._model.axis === `row`;
|
|
790
|
+
const trackSizes = this._resolveTracks(this._model);
|
|
791
|
+
const cssVars = this._model.children.map((child, i) => {
|
|
792
|
+
return `--s${i}: ${child.weight * 100}%`;
|
|
793
|
+
}).join(`; `);
|
|
794
|
+
const gridStyle = isRow ? `grid-template-columns: ${trackSizes}; grid-template-rows: 1fr; ${cssVars}` : `grid-template-rows: ${trackSizes}; grid-template-columns: 1fr; ${cssVars}`;
|
|
795
|
+
return html`
|
|
796
|
+
<div class="grid" style="${gridStyle}">
|
|
797
|
+
${this._model.children.map((_, i) => html`
|
|
798
|
+
<div part="panel" style="grid-column: ${isRow ? i * 2 + 1 : 1}; grid-row: ${isRow ? 1 : i * 2 + 1}; display: flex; flex-direction: ${isRow ? `row` : `column`}; overflow: hidden;">
|
|
799
|
+
<slot name="panel-${i}"></slot>
|
|
800
|
+
</div>
|
|
801
|
+
`)}
|
|
802
|
+
${this._model.children.slice(0, -1).map((_, i) => this._renderGutter(this._model.id, i, isRow))}
|
|
803
|
+
</div>
|
|
804
|
+
`;
|
|
805
|
+
}
|
|
806
|
+
_getTrackSizes(count) {
|
|
807
|
+
const sizes = [];
|
|
808
|
+
for (let i = 0; i < count; i++) sizes.push(`var(--s${i}, 1fr)`);
|
|
809
|
+
return sizes;
|
|
810
|
+
}
|
|
811
|
+
_resolveTracks(model) {
|
|
812
|
+
model.axis;
|
|
813
|
+
const parts = [];
|
|
814
|
+
const gutterSize = `var(--split-gutter-size, 6px)`;
|
|
815
|
+
for (let i = 0; i < model.children.length; i++) {
|
|
816
|
+
const child = model.children[i];
|
|
817
|
+
let track;
|
|
818
|
+
if (child.kind === `panel`) {
|
|
819
|
+
if (child.collapsed) track = `var(--split-collapsed-size, 0px)`;
|
|
820
|
+
else if (child.fixedPx !== null) track = `${child.fixedPx}px`;
|
|
821
|
+
else track = `minmax(${child.minPx > 0 ? `${child.minPx}px` : `0px`}, var(--s${i}, 1fr))`;
|
|
822
|
+
} else track = `minmax(0, var(--s${i}, 1fr))`;
|
|
823
|
+
parts.push(track);
|
|
824
|
+
if (i < model.children.length - 1) parts.push(gutterSize);
|
|
825
|
+
}
|
|
826
|
+
return parts.join(` `);
|
|
827
|
+
}
|
|
828
|
+
_renderGutter(groupId, index, isRow) {
|
|
829
|
+
const cursor = isRow ? `ew-resize` : `ns-resize`;
|
|
830
|
+
const gridColumn = isRow ? `${(index + 1) * 2}` : `1`;
|
|
831
|
+
const gridRow = isRow ? `1` : `${(index + 1) * 2}`;
|
|
832
|
+
return html`
|
|
833
|
+
<div
|
|
834
|
+
class="gutter"
|
|
835
|
+
data-group="${groupId}"
|
|
836
|
+
data-index="${index}"
|
|
837
|
+
style="cursor: ${cursor}; grid-column: ${gridColumn}; grid-row: ${gridRow};"
|
|
838
|
+
@pointerdown=${(e) => this._onGutterPointerDown(e, groupId, index)}
|
|
839
|
+
>
|
|
840
|
+
<div class="grab-handle">
|
|
841
|
+
<span class="dot"></span>
|
|
842
|
+
<span class="dot"></span>
|
|
843
|
+
<span class="dot"></span>
|
|
844
|
+
</div>
|
|
845
|
+
</div>
|
|
846
|
+
`;
|
|
847
|
+
}
|
|
848
|
+
static {
|
|
849
|
+
this.styles = [themeFallbacks, css`
|
|
850
|
+
:host {
|
|
851
|
+
display: block;
|
|
852
|
+
width: 100%;
|
|
853
|
+
height: 100%;
|
|
854
|
+
--split-gutter-size: 6px;
|
|
855
|
+
--split-gutter-color: transparent;
|
|
856
|
+
--split-gutter-hover-color: var(--surface-6);
|
|
857
|
+
--split-gutter-active-color: var(--accent);
|
|
858
|
+
--split-collapsed-size: 0px;
|
|
859
|
+
--split-snap: 24px;
|
|
860
|
+
--split-grab-color: var(--border-subtle-color);
|
|
861
|
+
--split-grab-dot-size: 3px;
|
|
862
|
+
--split-grab-size: 16px;
|
|
863
|
+
--split-grab-thickness: 8px;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
* {
|
|
867
|
+
box-sizing: border-box;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
.grid {
|
|
871
|
+
display: grid;
|
|
872
|
+
width: 100%;
|
|
873
|
+
height: 100%;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.grid slot {
|
|
877
|
+
display: block;
|
|
878
|
+
min-width: 0;
|
|
879
|
+
min-height: 0;
|
|
880
|
+
width: 100%;
|
|
881
|
+
height: 100%;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
::part(panel) {
|
|
885
|
+
width: 100%;
|
|
886
|
+
height: 100%;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
.gutter {
|
|
890
|
+
z-index: 2;
|
|
891
|
+
background: var(--split-gutter-color);
|
|
892
|
+
transition: background-color var(--transition, 0.2s);
|
|
893
|
+
pointer-events: auto;
|
|
894
|
+
display: flex;
|
|
895
|
+
align-items: center;
|
|
896
|
+
justify-content: center;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
:host([direction="row"]) .gutter {
|
|
900
|
+
width: var(--split-gutter-size);
|
|
901
|
+
cursor: ew-resize;
|
|
902
|
+
min-height: 100%;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
:host([direction="column"]) .gutter {
|
|
906
|
+
height: var(--split-gutter-size);
|
|
907
|
+
cursor: ns-resize;
|
|
908
|
+
min-width: 100%;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
.gutter:hover,
|
|
912
|
+
.gutter[data-active] {
|
|
913
|
+
background: var(--split-gutter-hover-color);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
:host([data-dragging]) .gutter {
|
|
917
|
+
background: var(--split-gutter-active-color);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
:host([data-dragging]) * {
|
|
921
|
+
transition: none !important;
|
|
922
|
+
user-select: none;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
.grab-handle .dot {
|
|
926
|
+
width: var(--split-grab-dot-size);
|
|
927
|
+
height: var(--split-grab-dot-size);
|
|
928
|
+
border-radius: 50%;
|
|
929
|
+
background: var(--split-grab-color);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
:host([direction="row"]) .grab-handle {
|
|
933
|
+
flex-direction: column;
|
|
934
|
+
gap: var(--split-grab-dot-size);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
:host([direction="column"]) .grab-handle {
|
|
938
|
+
flex-direction: row;
|
|
939
|
+
gap: var(--split-grab-dot-size);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
:host([data-dragging]) .grab-handle {
|
|
943
|
+
display: none;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
:host(:not([data-dragging])) .gutter:hover .grab-handle {
|
|
947
|
+
display: flex;
|
|
948
|
+
}
|
|
949
|
+
`];
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
__decorate([property({
|
|
953
|
+
type: String,
|
|
954
|
+
reflect: true
|
|
955
|
+
})], SplitLayoutElement.prototype, "direction", void 0);
|
|
956
|
+
__decorate([property({ type: String })], SplitLayoutElement.prototype, "sizes", void 0);
|
|
957
|
+
__decorate([property({
|
|
958
|
+
type: String,
|
|
959
|
+
attribute: `gutter-size`
|
|
960
|
+
})], SplitLayoutElement.prototype, "gutterSize", void 0);
|
|
961
|
+
__decorate([property({ type: String })], SplitLayoutElement.prototype, "snap", void 0);
|
|
962
|
+
__decorate([state()], SplitLayoutElement.prototype, "_model", void 0);
|
|
963
|
+
__decorate([state()], SplitLayoutElement.prototype, "_resizing", void 0);
|
|
964
|
+
__decorate([query(`.grid`)], SplitLayoutElement.prototype, "_groupEl", void 0);
|
|
965
|
+
SplitLayoutElement = __decorate([safeCustomElement(`ixfx-split-layout`)], SplitLayoutElement);
|
|
966
|
+
//#endregion
|
|
967
|
+
export { distribute as a, toSnapshot as c, buildModel as i, walk as l, SplitPanelElement as n, normalise as o, applySnapshot as r, resolveTracks as s, SplitLayoutElement as t };
|
|
968
|
+
|
|
969
|
+
//# sourceMappingURL=split-layout-BFSbUZQv.js.map
|