@window-splitter/web-component 1.0.1
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/.storybook/main.js +27 -0
- package/.storybook/preview.css +23 -0
- package/.storybook/preview.js +15 -0
- package/.tshy/build.json +8 -0
- package/.tshy/commonjs.json +19 -0
- package/.tshy/esm.json +18 -0
- package/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +24 -0
- package/LICENSE +7 -0
- package/README.md +59 -0
- package/dist/commonjs/index.d.ts +77 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +533 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/esm/index.d.ts +77 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +527 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/eslint.config.mjs +10 -0
- package/package.json +84 -0
- package/src/WebComponentWindowSplitter.stories.ts +873 -0
- package/src/WebComponentWindowSplitter.test.ts +299 -0
- package/src/__snapshots__/WebComponentWindowSplitter.test.ts.snap +54 -0
- package/src/index.ts +660 -0
- package/tsconfig.json +8 -0
- package/vitest.config.js +17 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PanelResizer = exports.Panel = exports.PanelGroup = void 0;
|
|
10
|
+
const state_1 = require("@window-splitter/state");
|
|
11
|
+
const lit_1 = require("lit");
|
|
12
|
+
const decorators_js_1 = require("lit/decorators.js");
|
|
13
|
+
const interface_1 = require("@window-splitter/interface");
|
|
14
|
+
const context_1 = require("@lit/context");
|
|
15
|
+
const isPrerenderContext = (0, context_1.createContext)("isPrerender");
|
|
16
|
+
const sendContext = (0, context_1.createContext)("send");
|
|
17
|
+
const contextContext = (0, context_1.createContext)("context");
|
|
18
|
+
const stateContext = (0, context_1.createContext)("state");
|
|
19
|
+
let _id = 0;
|
|
20
|
+
const getNextId = () => {
|
|
21
|
+
_id++;
|
|
22
|
+
return `${_id}`;
|
|
23
|
+
};
|
|
24
|
+
function updateAttributes(element,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
attributes) {
|
|
27
|
+
for (const attr of Object.keys(attributes)) {
|
|
28
|
+
if (attr === "style") {
|
|
29
|
+
for (const style of Object.keys(attributes[attr])) {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
element.style[style] = attributes[attr][style];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
element.setAttribute(attr, attributes[attr]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function isBooleanPropValue(value) {
|
|
41
|
+
if (value === "true" || value === "")
|
|
42
|
+
return true;
|
|
43
|
+
if (value === "false")
|
|
44
|
+
return false;
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
class PanelGroup extends lit_1.LitElement {
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
this.isPrerender = true;
|
|
51
|
+
this.observer = new ResizeObserver(() => { });
|
|
52
|
+
this.cleanupChildrenObserver = () => { };
|
|
53
|
+
const autosaveId = this.getAttribute("autosaveId");
|
|
54
|
+
const autosaveStrategy = this.getAttribute("autosaveStrategy") || "localStorage";
|
|
55
|
+
this.groupId = this.getAttribute("id") || autosaveId || getNextId();
|
|
56
|
+
let snapshot = this.getAttribute("snapshot");
|
|
57
|
+
if (!snapshot &&
|
|
58
|
+
typeof window !== "undefined" &&
|
|
59
|
+
autosaveId &&
|
|
60
|
+
autosaveStrategy === "localStorage") {
|
|
61
|
+
const localSnapshot = localStorage.getItem(autosaveId);
|
|
62
|
+
if (localSnapshot) {
|
|
63
|
+
snapshot = localSnapshot;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const [initialState, send, machineState] = (0, state_1.groupMachine)({
|
|
67
|
+
orientation: this.getAttribute("orientation") || "horizontal",
|
|
68
|
+
groupId: this.groupId,
|
|
69
|
+
autosaveStrategy,
|
|
70
|
+
...(snapshot ? (0, state_1.prepareSnapshot)(JSON.parse(snapshot)) : undefined),
|
|
71
|
+
}, (s) => {
|
|
72
|
+
const oldContext = this.context;
|
|
73
|
+
this.context = s;
|
|
74
|
+
if (oldContext.items.length !== s.items.length) {
|
|
75
|
+
this.cleanupChildrenObserver?.();
|
|
76
|
+
this.measureChildren();
|
|
77
|
+
}
|
|
78
|
+
this.requestUpdate();
|
|
79
|
+
});
|
|
80
|
+
this.state = machineState;
|
|
81
|
+
this.send = send;
|
|
82
|
+
this.context = initialState;
|
|
83
|
+
}
|
|
84
|
+
getId() {
|
|
85
|
+
return this.groupId;
|
|
86
|
+
}
|
|
87
|
+
getPixelSizes() {
|
|
88
|
+
return (0, state_1.getPanelGroupPixelSizes)(this.context);
|
|
89
|
+
}
|
|
90
|
+
getPercentageSizes() {
|
|
91
|
+
return (0, state_1.getPanelGroupPercentageSizes)(this.context);
|
|
92
|
+
}
|
|
93
|
+
getTemplate() {
|
|
94
|
+
return (0, state_1.buildTemplate)({
|
|
95
|
+
...this.context,
|
|
96
|
+
items: (0, state_1.prepareItems)(this.context),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
getState() {
|
|
100
|
+
return this.state.current === "idle" ? "idle" : "dragging";
|
|
101
|
+
}
|
|
102
|
+
setSizes(updates) {
|
|
103
|
+
for (let index = 0; index < updates.length; index++) {
|
|
104
|
+
const item = this.context.items[index];
|
|
105
|
+
const update = updates[index];
|
|
106
|
+
if (item && (0, state_1.isPanelData)(item) && update) {
|
|
107
|
+
this.send({
|
|
108
|
+
type: "setPanelPixelSize",
|
|
109
|
+
panelId: item.id,
|
|
110
|
+
size: update,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
measureSize() {
|
|
116
|
+
if (this.observer) {
|
|
117
|
+
this.observer.disconnect();
|
|
118
|
+
}
|
|
119
|
+
this.observer = new ResizeObserver(([entry]) => {
|
|
120
|
+
if (!entry)
|
|
121
|
+
return;
|
|
122
|
+
if (entry.contentRect.width > 0 && entry.contentRect.height > 0) {
|
|
123
|
+
this.send({ type: "setSize", size: entry.contentRect });
|
|
124
|
+
this.measureChildren();
|
|
125
|
+
this.isPrerender = false;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
this.observer.observe(this.renderRoot.querySelector("div"));
|
|
129
|
+
}
|
|
130
|
+
measureChildren() {
|
|
131
|
+
if (this.cleanupChildrenObserver) {
|
|
132
|
+
this.cleanupChildrenObserver();
|
|
133
|
+
}
|
|
134
|
+
const childrenObserver = new ResizeObserver((childrenEntries) => {
|
|
135
|
+
const childrenSizes = {};
|
|
136
|
+
for (const childEntry of childrenEntries) {
|
|
137
|
+
const child = childEntry.target;
|
|
138
|
+
const childId = child.getAttribute("data-splitter-id");
|
|
139
|
+
const childSize = childEntry.borderBoxSize[0];
|
|
140
|
+
if (childId && childSize) {
|
|
141
|
+
childrenSizes[childId] = {
|
|
142
|
+
width: childSize.inlineSize,
|
|
143
|
+
height: childSize.blockSize,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
this.send({ type: "setActualItemsSize", childrenSizes });
|
|
148
|
+
});
|
|
149
|
+
if (!this.shadowRoot)
|
|
150
|
+
return;
|
|
151
|
+
const slot = this.shadowRoot.querySelector("slot");
|
|
152
|
+
if (!slot)
|
|
153
|
+
return;
|
|
154
|
+
const elements = slot.assignedElements();
|
|
155
|
+
for (const child of elements) {
|
|
156
|
+
childrenObserver.observe(child);
|
|
157
|
+
}
|
|
158
|
+
this.cleanupChildrenObserver = () => {
|
|
159
|
+
childrenObserver.disconnect();
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
firstUpdated() {
|
|
163
|
+
this.send({ type: "unlockGroup" });
|
|
164
|
+
if (this.observer) {
|
|
165
|
+
this.observer.disconnect();
|
|
166
|
+
}
|
|
167
|
+
this.measureSize();
|
|
168
|
+
this.setAttribute("data-panel-group-wrapper", "");
|
|
169
|
+
this.setAttribute("id", this.groupId);
|
|
170
|
+
}
|
|
171
|
+
disconnectedCallback() {
|
|
172
|
+
this.observer?.disconnect();
|
|
173
|
+
this.cleanupChildrenObserver?.();
|
|
174
|
+
this.send({ type: "lockGroup" });
|
|
175
|
+
}
|
|
176
|
+
render() {
|
|
177
|
+
const template = this.context.orientation === "horizontal"
|
|
178
|
+
? `grid-template-columns: ${(0, state_1.buildTemplate)(this.context)};`
|
|
179
|
+
: `grid-template-rows: ${(0, state_1.buildTemplate)(this.context)}`;
|
|
180
|
+
return (0, lit_1.html) `
|
|
181
|
+
<div style="display: grid;height: 100%;${template}">
|
|
182
|
+
<slot></slot>
|
|
183
|
+
</div>
|
|
184
|
+
`;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.PanelGroup = PanelGroup;
|
|
188
|
+
__decorate([
|
|
189
|
+
(0, context_1.provide)({ context: contextContext })
|
|
190
|
+
], PanelGroup.prototype, "context", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
(0, context_1.provide)({ context: sendContext })
|
|
193
|
+
], PanelGroup.prototype, "send", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
(0, context_1.provide)({ context: isPrerenderContext })
|
|
196
|
+
], PanelGroup.prototype, "isPrerender", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
(0, context_1.provide)({ context: stateContext })
|
|
199
|
+
], PanelGroup.prototype, "state", void 0);
|
|
200
|
+
class Panel extends lit_1.LitElement {
|
|
201
|
+
constructor() {
|
|
202
|
+
super();
|
|
203
|
+
this.isPrerender = true;
|
|
204
|
+
this.id ||= getNextId();
|
|
205
|
+
this.send = () => { };
|
|
206
|
+
this.context = {};
|
|
207
|
+
}
|
|
208
|
+
collapse() {
|
|
209
|
+
if (!this.getPanelData()?.collapsible)
|
|
210
|
+
return;
|
|
211
|
+
this.send({ type: "collapsePanel", panelId: this.id, controlled: true });
|
|
212
|
+
}
|
|
213
|
+
isCollapsed() {
|
|
214
|
+
return Boolean(this.getPanelData()?.collapsible && this.getPanelData()?.collapsed);
|
|
215
|
+
}
|
|
216
|
+
expand() {
|
|
217
|
+
if (!this.getPanelData()?.collapsible)
|
|
218
|
+
return;
|
|
219
|
+
this.send({ type: "expandPanel", panelId: this.id, controlled: true });
|
|
220
|
+
}
|
|
221
|
+
isExpanded() {
|
|
222
|
+
return Boolean(this.getPanelData()?.collapsible && !this.getPanelData()?.collapsed);
|
|
223
|
+
}
|
|
224
|
+
getPixelSize() {
|
|
225
|
+
return (0, state_1.getPanelPixelSize)(this.context, this.id);
|
|
226
|
+
}
|
|
227
|
+
getPercentageSize() {
|
|
228
|
+
return (0, state_1.getPanelPercentageSize)(this.context, this.id);
|
|
229
|
+
}
|
|
230
|
+
setSize(size) {
|
|
231
|
+
this.send({ type: "setPanelPixelSize", panelId: this.id, size });
|
|
232
|
+
}
|
|
233
|
+
initPanel() {
|
|
234
|
+
return (0, state_1.initializePanel)({
|
|
235
|
+
id: this.id,
|
|
236
|
+
min: this.getAttribute("min"),
|
|
237
|
+
max: this.getAttribute("max"),
|
|
238
|
+
collapsible: isBooleanPropValue(this.getAttribute("collapsible")),
|
|
239
|
+
collapsed: isBooleanPropValue(this.getAttribute("collapsed")),
|
|
240
|
+
collapsedSize: this.getAttribute("collapsedSize"),
|
|
241
|
+
onCollapseChange: this.onCollapseChange
|
|
242
|
+
? { current: (e) => this.onCollapseChange?.(e, this) }
|
|
243
|
+
: undefined,
|
|
244
|
+
collapseAnimation: this.collapseAnimation,
|
|
245
|
+
onResize: this.onResize ? { current: this.onResize } : undefined,
|
|
246
|
+
defaultCollapsed: isBooleanPropValue(this.getAttribute("defaultCollapsed")),
|
|
247
|
+
default: this.getAttribute("default"),
|
|
248
|
+
isStaticAtRest: isBooleanPropValue(this.getAttribute("isStaticAtRest")),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
getPanelData() {
|
|
252
|
+
return this.context?.items.find((item) => item.id === this.id);
|
|
253
|
+
}
|
|
254
|
+
getAttributes() {
|
|
255
|
+
return {
|
|
256
|
+
...(0, interface_1.getPanelDomAttributes)({
|
|
257
|
+
groupId: this.context.groupId,
|
|
258
|
+
id: this.id,
|
|
259
|
+
collapsible: this.getAttribute("collapsible") === "true",
|
|
260
|
+
collapsed: this.getAttribute("collapsed") === "true"
|
|
261
|
+
? true
|
|
262
|
+
: this.getAttribute("collapsed") === "false"
|
|
263
|
+
? false
|
|
264
|
+
: undefined,
|
|
265
|
+
}),
|
|
266
|
+
style: {
|
|
267
|
+
minWidth: 0,
|
|
268
|
+
minHeight: 0,
|
|
269
|
+
overflow: "hidden",
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
firstUpdated(_changedProperties) {
|
|
274
|
+
updateAttributes(this, this.getAttributes());
|
|
275
|
+
if (this.getPanelData()) {
|
|
276
|
+
this.send?.({
|
|
277
|
+
type: "rebindPanelCallbacks",
|
|
278
|
+
data: {
|
|
279
|
+
id: this.id,
|
|
280
|
+
onCollapseChange: this.onCollapseChange
|
|
281
|
+
? { current: (e) => this.onCollapseChange?.(e, this) }
|
|
282
|
+
: undefined,
|
|
283
|
+
onResize: this.onResize ? { current: this.onResize } : undefined,
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
if (this.isPrerender) {
|
|
289
|
+
this.send({ type: "registerPanel", data: this.initPanel() });
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const groupElement = this.closest("window-splitter");
|
|
293
|
+
if (!groupElement)
|
|
294
|
+
return;
|
|
295
|
+
const order = Array.from(groupElement.children).indexOf(this);
|
|
296
|
+
if (typeof order !== "number")
|
|
297
|
+
return;
|
|
298
|
+
this.send({
|
|
299
|
+
type: "registerDynamicPanel",
|
|
300
|
+
data: { ...this.initPanel(), order },
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
disconnectedCallback() {
|
|
306
|
+
requestAnimationFrame(() => this.send({ type: "unregisterPanel", id: this.id }));
|
|
307
|
+
}
|
|
308
|
+
updated(changedProperties) {
|
|
309
|
+
if (changedProperties.has("collapsed")) {
|
|
310
|
+
const isControlled = this.getPanelData()?.collapseIsControlled;
|
|
311
|
+
if (isControlled) {
|
|
312
|
+
if (this.collapsed) {
|
|
313
|
+
this.send({
|
|
314
|
+
type: "collapsePanel",
|
|
315
|
+
panelId: this.id,
|
|
316
|
+
controlled: true,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
this.send({
|
|
321
|
+
type: "expandPanel",
|
|
322
|
+
panelId: this.id,
|
|
323
|
+
controlled: true,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (changedProperties.has("min") ||
|
|
329
|
+
changedProperties.has("max") ||
|
|
330
|
+
changedProperties.has("default") ||
|
|
331
|
+
changedProperties.has("collapsible") ||
|
|
332
|
+
changedProperties.has("collapsedSize") ||
|
|
333
|
+
changedProperties.has("defaultCollapsed") ||
|
|
334
|
+
changedProperties.has("isStaticAtRest")) {
|
|
335
|
+
const currentPanelData = this.getPanelData();
|
|
336
|
+
if (currentPanelData &&
|
|
337
|
+
(0, state_1.haveConstraintsChangedForPanel)(currentPanelData, this.initPanel())) {
|
|
338
|
+
this.send({ type: "updateConstraints", data: this.initPanel() });
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
render() {
|
|
343
|
+
return (0, lit_1.html) `<slot></slot>`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
exports.Panel = Panel;
|
|
347
|
+
Panel.observedContexts = ["send"];
|
|
348
|
+
__decorate([
|
|
349
|
+
(0, decorators_js_1.property)({ type: Boolean, reflect: true })
|
|
350
|
+
], Panel.prototype, "collapsed", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
353
|
+
], Panel.prototype, "min", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
356
|
+
], Panel.prototype, "max", void 0);
|
|
357
|
+
__decorate([
|
|
358
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
359
|
+
], Panel.prototype, "default", void 0);
|
|
360
|
+
__decorate([
|
|
361
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
362
|
+
], Panel.prototype, "collapsible", void 0);
|
|
363
|
+
__decorate([
|
|
364
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
365
|
+
], Panel.prototype, "defaultCollapsed", void 0);
|
|
366
|
+
__decorate([
|
|
367
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
368
|
+
], Panel.prototype, "collapsedSize", void 0);
|
|
369
|
+
__decorate([
|
|
370
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
371
|
+
], Panel.prototype, "isStaticAtRest", void 0);
|
|
372
|
+
__decorate([
|
|
373
|
+
(0, context_1.consume)({ context: contextContext }),
|
|
374
|
+
(0, decorators_js_1.property)({ attribute: false })
|
|
375
|
+
], Panel.prototype, "context", void 0);
|
|
376
|
+
__decorate([
|
|
377
|
+
(0, context_1.consume)({ context: sendContext }),
|
|
378
|
+
(0, decorators_js_1.property)({ attribute: false })
|
|
379
|
+
], Panel.prototype, "send", void 0);
|
|
380
|
+
__decorate([
|
|
381
|
+
(0, context_1.consume)({ context: isPrerenderContext }),
|
|
382
|
+
(0, decorators_js_1.property)({ attribute: false })
|
|
383
|
+
], Panel.prototype, "isPrerender", void 0);
|
|
384
|
+
class PanelResizer extends lit_1.LitElement {
|
|
385
|
+
constructor() {
|
|
386
|
+
super();
|
|
387
|
+
this.isPrerender = true;
|
|
388
|
+
this.id ||= getNextId();
|
|
389
|
+
this.send = () => { };
|
|
390
|
+
this.context = {};
|
|
391
|
+
}
|
|
392
|
+
initPanelResizer() {
|
|
393
|
+
return (0, state_1.initializePanelHandleData)({
|
|
394
|
+
id: this.id,
|
|
395
|
+
size: this.getAttribute("size") || "0px",
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
getHandleData() {
|
|
399
|
+
return this.context?.items.find((item) => item.id === this.id);
|
|
400
|
+
}
|
|
401
|
+
getAttributes() {
|
|
402
|
+
const handleIndex = this.context?.items.findIndex((item) => item.id === this.id);
|
|
403
|
+
const panelBeforeHandle = handleIndex !== undefined &&
|
|
404
|
+
(0, state_1.isPanelData)(this.context?.items[handleIndex - 1])
|
|
405
|
+
? this.context?.items[handleIndex - 1]
|
|
406
|
+
: undefined;
|
|
407
|
+
const handleData = this.getHandleData() || this.initPanelResizer();
|
|
408
|
+
return {
|
|
409
|
+
...(0, interface_1.getPanelResizerDomAttributes)({
|
|
410
|
+
groupId: this.context?.groupId,
|
|
411
|
+
id: this.id,
|
|
412
|
+
orientation: this.context?.orientation || "horizontal",
|
|
413
|
+
isDragging: this.context?.activeDragHandleId === this.id,
|
|
414
|
+
activeDragHandleId: this.context?.activeDragHandleId,
|
|
415
|
+
disabled: this.disabled,
|
|
416
|
+
controlsId: panelBeforeHandle?.id,
|
|
417
|
+
min: panelBeforeHandle?.min,
|
|
418
|
+
max: panelBeforeHandle?.max,
|
|
419
|
+
currentValue: panelBeforeHandle?.currentValue,
|
|
420
|
+
groupSize: (0, state_1.getGroupSize)(this.context),
|
|
421
|
+
}),
|
|
422
|
+
tabIndex: this.disabled ? -1 : 0,
|
|
423
|
+
style: {
|
|
424
|
+
cursor: this.context ? (0, state_1.getCursor)(this.context) : undefined,
|
|
425
|
+
width: this.context?.orientation === "horizontal"
|
|
426
|
+
? `${handleData.size.value.toNumber()}px`
|
|
427
|
+
: "100%",
|
|
428
|
+
height: this.context?.orientation === "vertical"
|
|
429
|
+
? `${handleData.size.value.toNumber()}px`
|
|
430
|
+
: "100%",
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
firstUpdated(_changedProperties) {
|
|
435
|
+
const { moveProps } = (0, interface_1.move)({
|
|
436
|
+
onMoveStart: () => {
|
|
437
|
+
this.send({
|
|
438
|
+
type: "dragHandleStart",
|
|
439
|
+
handleId: this.id,
|
|
440
|
+
});
|
|
441
|
+
this.onDragStart?.();
|
|
442
|
+
document.body.style.cursor = (0, state_1.getCursor)(this.context) || "auto";
|
|
443
|
+
},
|
|
444
|
+
onMove: (e) => {
|
|
445
|
+
this.send({
|
|
446
|
+
type: "dragHandle",
|
|
447
|
+
handleId: this.id,
|
|
448
|
+
value: e,
|
|
449
|
+
});
|
|
450
|
+
this.onDrag?.(e);
|
|
451
|
+
},
|
|
452
|
+
onMoveEnd: () => {
|
|
453
|
+
this.send({ type: "dragHandleEnd", handleId: this.id });
|
|
454
|
+
this.onDragEnd?.();
|
|
455
|
+
document.body.style.cursor = "auto";
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
this.addEventListener("pointerdown", (e) => {
|
|
459
|
+
if (this.disabled)
|
|
460
|
+
return;
|
|
461
|
+
moveProps.onPointerDown(e);
|
|
462
|
+
});
|
|
463
|
+
this.addEventListener("keydown", (e) => {
|
|
464
|
+
moveProps.onKeyDown(e);
|
|
465
|
+
const collapsiblePanel = (0, state_1.getCollapsiblePanelForHandleId)(this.context, this.id);
|
|
466
|
+
if (e.key === "Enter" && collapsiblePanel) {
|
|
467
|
+
if (collapsiblePanel.collapsed) {
|
|
468
|
+
this.send({ type: "expandPanel", panelId: collapsiblePanel.id });
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
this.send({ type: "collapsePanel", panelId: collapsiblePanel.id });
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
updateAttributes(this, this.getAttributes());
|
|
476
|
+
if (!this.getHandleData()) {
|
|
477
|
+
if (this.isPrerender) {
|
|
478
|
+
this.send({
|
|
479
|
+
type: "registerPanelHandle",
|
|
480
|
+
data: this.initPanelResizer(),
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
const groupElement = this.closest("window-splitter");
|
|
485
|
+
if (!groupElement)
|
|
486
|
+
return;
|
|
487
|
+
const order = Array.from(groupElement.children).indexOf(this);
|
|
488
|
+
if (typeof order !== "number")
|
|
489
|
+
return;
|
|
490
|
+
this.send({
|
|
491
|
+
type: "registerPanelHandle",
|
|
492
|
+
data: { ...this.initPanelResizer(), order },
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
updated(changedProperties) {
|
|
498
|
+
if (changedProperties.has("size")) {
|
|
499
|
+
const currentHandleData = this.getHandleData();
|
|
500
|
+
if (currentHandleData &&
|
|
501
|
+
(0, state_1.haveConstraintsChangedForPanelHandle)(currentHandleData, this.initPanelResizer())) {
|
|
502
|
+
this.send({ type: "updateConstraints", data: this.initPanelResizer() });
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
disconnectedCallback() {
|
|
507
|
+
requestAnimationFrame(() => this.send({ type: "unregisterPanelHandle", id: this.id }));
|
|
508
|
+
}
|
|
509
|
+
render() {
|
|
510
|
+
return (0, lit_1.html) `<slot></slot>`;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
exports.PanelResizer = PanelResizer;
|
|
514
|
+
PanelResizer.observedContexts = ["send"];
|
|
515
|
+
__decorate([
|
|
516
|
+
(0, context_1.consume)({ context: contextContext }),
|
|
517
|
+
(0, decorators_js_1.property)({ attribute: false })
|
|
518
|
+
], PanelResizer.prototype, "context", void 0);
|
|
519
|
+
__decorate([
|
|
520
|
+
(0, context_1.consume)({ context: sendContext }),
|
|
521
|
+
(0, decorators_js_1.property)({ attribute: false })
|
|
522
|
+
], PanelResizer.prototype, "send", void 0);
|
|
523
|
+
__decorate([
|
|
524
|
+
(0, context_1.consume)({ context: isPrerenderContext }),
|
|
525
|
+
(0, decorators_js_1.property)({ attribute: false })
|
|
526
|
+
], PanelResizer.prototype, "isPrerender", void 0);
|
|
527
|
+
__decorate([
|
|
528
|
+
(0, decorators_js_1.property)({ type: String, reflect: true })
|
|
529
|
+
], PanelResizer.prototype, "size", void 0);
|
|
530
|
+
__decorate([
|
|
531
|
+
(0, decorators_js_1.property)({ type: Boolean, reflect: true })
|
|
532
|
+
], PanelResizer.prototype, "disabled", void 0);
|
|
533
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,kDA0BgC;AAChC,6BAAuD;AACvD,qDAA6C;AAC7C,0DAMoC;AACpC,0CAA+D;AAE/D,MAAM,kBAAkB,GAAG,IAAA,uBAAa,EAAU,aAAa,CAAC,CAAC;AACjE,MAAM,WAAW,GAAG,IAAA,uBAAa,EAAS,MAAM,CAAC,CAAC;AAClD,MAAM,cAAc,GAAG,IAAA,uBAAa,EAA2B,SAAS,CAAC,CAAC;AAC1E,MAAM,YAAY,GAAG,IAAA,uBAAa,EAAqB,OAAO,CAAC,CAAC;AAEhE,IAAI,GAAG,GAAG,CAAC,CAAC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AAG1B;IADC,IAAA,wBAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC5B;AAEd;IADC,IAAA,wBAAQ,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACxB","sourcesContent":["import {\n groupMachine,\n initializePanel,\n initializePanelHandleData,\n buildTemplate,\n getCursor,\n PanelHandleData,\n SendFn,\n GroupMachineContextValue,\n Unit,\n PixelUnit,\n isPanelData,\n getGroupSize,\n PanelData,\n Orientation,\n prepareSnapshot,\n getCollapsiblePanelForHandleId,\n OnResizeCallback,\n getPanelPixelSize,\n getPanelPercentageSize,\n getPanelGroupPixelSizes,\n getPanelGroupPercentageSizes,\n prepareItems,\n State,\n haveConstraintsChangedForPanel,\n haveConstraintsChangedForPanelHandle,\n} from \"@window-splitter/state\";\nimport { html, LitElement, PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport {\n getPanelDomAttributes,\n getPanelResizerDomAttributes,\n move,\n MoveEvents,\n SharedPanelProps,\n} from \"@window-splitter/interface\";\nimport { consume, createContext, provide } from \"@lit/context\";\n\nconst isPrerenderContext = createContext<boolean>(\"isPrerender\");\nconst sendContext = createContext<SendFn>(\"send\");\nconst contextContext = createContext<GroupMachineContextValue>(\"context\");\nconst stateContext = createContext<{ current: State }>(\"state\");\n\nlet _id = 0;\n\nconst getNextId = () => {\n _id++;\n return `${_id}`;\n};\n\nfunction updateAttributes(\n element: HTMLElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n attributes: Record<string, any> | { style: Record<string, any> }\n) {\n for (const attr of Object.keys(attributes)) {\n if (attr === \"style\") {\n for (const style of Object.keys(attributes[attr])) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (element.style as any)[style] = attributes[attr][style];\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n element.setAttribute(attr, (attributes as any)[attr]);\n }\n }\n}\n\nfunction isBooleanPropValue(value: string | null) {\n if (value === \"true\" || value === \"\") return true;\n if (value === \"false\") return false;\n return undefined;\n}\n\nexport class PanelGroup extends LitElement {\n private observer: ResizeObserver;\n private cleanupChildrenObserver: () => void;\n private groupId: string;\n\n @provide({ context: contextContext })\n private context: GroupMachineContextValue;\n @provide({ context: sendContext })\n private send: SendFn;\n @provide({ context: isPrerenderContext })\n private isPrerender = true;\n @provide({ context: stateContext })\n private state: { current: State };\n\n constructor() {\n super();\n\n this.observer = new ResizeObserver(() => {});\n this.cleanupChildrenObserver = () => {};\n\n const autosaveId = this.getAttribute(\"autosaveId\");\n const autosaveStrategy =\n (this.getAttribute(\n \"autosaveStrategy\"\n ) as GroupMachineContextValue[\"autosaveStrategy\"]) || \"localStorage\";\n\n this.groupId = this.getAttribute(\"id\") || autosaveId || getNextId();\n\n let snapshot = this.getAttribute(\"snapshot\");\n\n if (\n !snapshot &&\n typeof window !== \"undefined\" &&\n autosaveId &&\n autosaveStrategy === \"localStorage\"\n ) {\n const localSnapshot = localStorage.getItem(autosaveId);\n\n if (localSnapshot) {\n snapshot = localSnapshot;\n }\n }\n\n const [initialState, send, machineState] = groupMachine(\n {\n orientation:\n (this.getAttribute(\"orientation\") as Orientation) || \"horizontal\",\n groupId: this.groupId,\n autosaveStrategy,\n ...(snapshot ? prepareSnapshot(JSON.parse(snapshot)) : undefined),\n },\n (s) => {\n const oldContext = this.context;\n this.context = s;\n\n if (oldContext.items.length !== s.items.length) {\n this.cleanupChildrenObserver?.();\n this.measureChildren();\n }\n\n this.requestUpdate();\n }\n );\n\n this.state = machineState;\n this.send = send;\n this.context = initialState;\n }\n\n public getId() {\n return this.groupId;\n }\n\n public getPixelSizes() {\n return getPanelGroupPixelSizes(this.context);\n }\n\n public getPercentageSizes() {\n return getPanelGroupPercentageSizes(this.context);\n }\n\n public getTemplate() {\n return buildTemplate({\n ...this.context,\n items: prepareItems(this.context),\n });\n }\n\n public getState() {\n return this.state.current === \"idle\" ? \"idle\" : \"dragging\";\n }\n\n public setSizes(updates: Unit[]) {\n for (let index = 0; index < updates.length; index++) {\n const item = this.context.items[index];\n const update = updates[index];\n\n if (item && isPanelData(item) && update) {\n this.send({\n type: \"setPanelPixelSize\",\n panelId: item.id,\n size: update,\n });\n }\n }\n }\n\n private measureSize() {\n if (this.observer) {\n this.observer.disconnect();\n }\n\n this.observer = new ResizeObserver(([entry]) => {\n if (!entry) return;\n if (entry.contentRect.width > 0 && entry.contentRect.height > 0) {\n this.send({ type: \"setSize\", size: entry.contentRect });\n this.measureChildren();\n this.isPrerender = false;\n }\n });\n\n this.observer.observe(this.renderRoot.querySelector(\"div\")!);\n }\n\n private measureChildren() {\n if (this.cleanupChildrenObserver) {\n this.cleanupChildrenObserver();\n }\n\n const childrenObserver = new ResizeObserver((childrenEntries) => {\n const childrenSizes: Record<string, { width: number; height: number }> =\n {};\n\n for (const childEntry of childrenEntries) {\n const child = childEntry.target as HTMLElement;\n const childId = child.getAttribute(\"data-splitter-id\");\n const childSize = childEntry.borderBoxSize[0];\n\n if (childId && childSize) {\n childrenSizes[childId] = {\n width: childSize.inlineSize,\n height: childSize.blockSize,\n };\n }\n }\n\n this.send({ type: \"setActualItemsSize\", childrenSizes });\n });\n\n if (!this.shadowRoot) return;\n\n const slot = this.shadowRoot.querySelector(\"slot\");\n if (!slot) return;\n\n const elements = slot.assignedElements();\n\n for (const child of elements) {\n childrenObserver.observe(child);\n }\n\n this.cleanupChildrenObserver = () => {\n childrenObserver.disconnect();\n };\n }\n\n firstUpdated() {\n this.send({ type: \"unlockGroup\" });\n\n if (this.observer) {\n this.observer.disconnect();\n }\n\n this.measureSize();\n this.setAttribute(\"data-panel-group-wrapper\", \"\");\n this.setAttribute(\"id\", this.groupId);\n }\n\n disconnectedCallback() {\n this.observer?.disconnect();\n this.cleanupChildrenObserver?.();\n this.send({ type: \"lockGroup\" });\n }\n\n render() {\n const template =\n this.context.orientation === \"horizontal\"\n ? `grid-template-columns: ${buildTemplate(this.context)};`\n : `grid-template-rows: ${buildTemplate(this.context)}`;\n\n return html`\n <div style=\"display: grid;height: 100%;${template}\">\n <slot></slot>\n </div>\n `;\n }\n}\n\nexport class Panel extends LitElement {\n static observedContexts = [\"send\"];\n\n public onCollapseChange?: (newCollapsed: boolean, el: Panel) => void;\n public onResize?: OnResizeCallback;\n public collapseAnimation?: SharedPanelProps<boolean>[\"collapseAnimation\"];\n\n @property({ type: Boolean, reflect: true })\n collapsed?: boolean;\n @property({ type: String, reflect: true })\n min?: string;\n @property({ type: String, reflect: true })\n max?: string;\n @property({ type: String, reflect: true })\n default?: string;\n @property({ type: String, reflect: true })\n collapsible?: string;\n @property({ type: String, reflect: true })\n defaultCollapsed?: string;\n @property({ type: String, reflect: true })\n collapsedSize?: string;\n @property({ type: String, reflect: true })\n isStaticAtRest?: string;\n\n @consume({ context: contextContext })\n @property({ attribute: false })\n public context: GroupMachineContextValue;\n\n @consume({ context: sendContext })\n @property({ attribute: false })\n public send: SendFn;\n\n @consume({ context: isPrerenderContext })\n @property({ attribute: false })\n public isPrerender = true;\n\n id: string;\n\n constructor() {\n super();\n\n this.id ||= getNextId();\n this.send = () => {};\n this.context = {} as GroupMachineContextValue;\n }\n\n public collapse() {\n if (!this.getPanelData()?.collapsible) return;\n this.send({ type: \"collapsePanel\", panelId: this.id, controlled: true });\n }\n\n public isCollapsed() {\n return Boolean(\n this.getPanelData()?.collapsible && this.getPanelData()?.collapsed\n );\n }\n\n public expand() {\n if (!this.getPanelData()?.collapsible) return;\n this.send({ type: \"expandPanel\", panelId: this.id, controlled: true });\n }\n\n public isExpanded() {\n return Boolean(\n this.getPanelData()?.collapsible && !this.getPanelData()?.collapsed\n );\n }\n\n public getPixelSize() {\n return getPanelPixelSize(this.context, this.id);\n }\n\n public getPercentageSize() {\n return getPanelPercentageSize(this.context, this.id);\n }\n\n public setSize(size: Unit) {\n this.send({ type: \"setPanelPixelSize\", panelId: this.id, size });\n }\n\n private initPanel() {\n return initializePanel({\n id: this.id,\n min: this.getAttribute(\"min\") as Unit | undefined,\n max: this.getAttribute(\"max\") as Unit | undefined,\n collapsible: isBooleanPropValue(this.getAttribute(\"collapsible\")),\n collapsed: isBooleanPropValue(this.getAttribute(\"collapsed\")),\n collapsedSize: this.getAttribute(\"collapsedSize\") as Unit | undefined,\n onCollapseChange: this.onCollapseChange\n ? { current: (e) => this.onCollapseChange?.(e, this) }\n : undefined,\n collapseAnimation: this.collapseAnimation,\n onResize: this.onResize ? { current: this.onResize } : undefined,\n defaultCollapsed: isBooleanPropValue(\n this.getAttribute(\"defaultCollapsed\")\n ),\n default: this.getAttribute(\"default\") as Unit | undefined,\n isStaticAtRest: isBooleanPropValue(this.getAttribute(\"isStaticAtRest\")),\n });\n }\n\n private getPanelData() {\n return this.context?.items.find((item) => item.id === this.id) as\n | PanelData\n | undefined;\n }\n\n private getAttributes() {\n return {\n ...getPanelDomAttributes({\n groupId: this.context.groupId,\n id: this.id,\n collapsible: this.getAttribute(\"collapsible\") === \"true\",\n collapsed:\n this.getAttribute(\"collapsed\") === \"true\"\n ? true\n : this.getAttribute(\"collapsed\") === \"false\"\n ? false\n : undefined,\n }),\n style: {\n minWidth: 0,\n minHeight: 0,\n overflow: \"hidden\",\n },\n };\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n updateAttributes(this, this.getAttributes());\n\n if (this.getPanelData()) {\n this.send?.({\n type: \"rebindPanelCallbacks\",\n data: {\n id: this.id,\n onCollapseChange: this.onCollapseChange\n ? { current: (e) => this.onCollapseChange?.(e, this) }\n : undefined,\n onResize: this.onResize ? { current: this.onResize } : undefined,\n },\n });\n } else {\n if (this.isPrerender) {\n this.send({ type: \"registerPanel\", data: this.initPanel() });\n } else {\n const groupElement = this.closest(\"window-splitter\");\n if (!groupElement) return;\n\n const order = Array.from(groupElement.children).indexOf(this);\n if (typeof order !== \"number\") return;\n\n this.send({\n type: \"registerDynamicPanel\",\n data: { ...this.initPanel(), order },\n });\n }\n }\n }\n\n disconnectedCallback(): void {\n requestAnimationFrame(() =>\n this.send({ type: \"unregisterPanel\", id: this.id })\n );\n }\n\n updated(changedProperties: PropertyValues) {\n if (changedProperties.has(\"collapsed\")) {\n const isControlled = this.getPanelData()?.collapseIsControlled;\n\n if (isControlled) {\n if (this.collapsed) {\n this.send({\n type: \"collapsePanel\",\n panelId: this.id,\n controlled: true,\n });\n } else {\n this.send({\n type: \"expandPanel\",\n panelId: this.id,\n controlled: true,\n });\n }\n }\n }\n\n if (\n changedProperties.has(\"min\") ||\n changedProperties.has(\"max\") ||\n changedProperties.has(\"default\") ||\n changedProperties.has(\"collapsible\") ||\n changedProperties.has(\"collapsedSize\") ||\n changedProperties.has(\"defaultCollapsed\") ||\n changedProperties.has(\"isStaticAtRest\")\n ) {\n const currentPanelData = this.getPanelData();\n\n if (\n currentPanelData &&\n haveConstraintsChangedForPanel(currentPanelData, this.initPanel())\n ) {\n this.send({ type: \"updateConstraints\", data: this.initPanel() });\n }\n }\n }\n\n render() {\n return html`<slot></slot>`;\n }\n}\n\nexport class PanelResizer extends LitElement {\n static observedContexts = [\"send\"];\n\n public onDragStart?: () => void;\n public onDrag?: (e: Parameters<NonNullable<MoveEvents[\"onMove\"]>>[0]) => void;\n public onDragEnd?: () => void;\n\n @consume({ context: contextContext })\n @property({ attribute: false })\n public context: GroupMachineContextValue;\n @consume({ context: sendContext })\n @property({ attribute: false })\n public send: SendFn;\n @consume({ context: isPrerenderContext })\n @property({ attribute: false })\n public isPrerender = true;\n\n @property({ type: String, reflect: true })\n size?: string;\n @property({ type: Boolean, reflect: true })\n disabled?: boolean;\n\n constructor() {\n super();\n\n this.id ||= getNextId();\n this.send = () => {};\n this.context = {} as GroupMachineContextValue;\n }\n\n private initPanelResizer() {\n return initializePanelHandleData({\n id: this.id,\n size: (this.getAttribute(\"size\") as PixelUnit | undefined) || \"0px\",\n });\n }\n\n private getHandleData() {\n return this.context?.items.find((item) => item.id === this.id) as\n | PanelHandleData\n | undefined;\n }\n\n private getAttributes() {\n const handleIndex = this.context?.items.findIndex(\n (item) => item.id === this.id\n );\n\n const panelBeforeHandle =\n handleIndex !== undefined &&\n isPanelData(this.context?.items[handleIndex - 1])\n ? (this.context?.items[handleIndex - 1] as PanelData | undefined)\n : undefined;\n const handleData = this.getHandleData() || this.initPanelResizer();\n\n return {\n ...getPanelResizerDomAttributes({\n groupId: this.context?.groupId,\n id: this.id,\n orientation: this.context?.orientation || \"horizontal\",\n isDragging: this.context?.activeDragHandleId === this.id,\n activeDragHandleId: this.context?.activeDragHandleId,\n disabled: this.disabled,\n controlsId: panelBeforeHandle?.id,\n min: panelBeforeHandle?.min,\n max: panelBeforeHandle?.max,\n currentValue: panelBeforeHandle?.currentValue,\n groupSize: getGroupSize(this.context),\n }),\n tabIndex: this.disabled ? -1 : 0,\n style: {\n cursor: this.context ? getCursor(this.context) : undefined,\n width:\n this.context?.orientation === \"horizontal\"\n ? `${handleData.size.value.toNumber()}px`\n : \"100%\",\n height:\n this.context?.orientation === \"vertical\"\n ? `${handleData.size.value.toNumber()}px`\n : \"100%\",\n },\n };\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n const { moveProps } = move({\n onMoveStart: () => {\n this.send({\n type: \"dragHandleStart\",\n handleId: this.id,\n });\n this.onDragStart?.();\n document.body.style.cursor = getCursor(this.context) || \"auto\";\n },\n onMove: (e) => {\n this.send({\n type: \"dragHandle\",\n handleId: this.id,\n value: e,\n });\n this.onDrag?.(e);\n },\n onMoveEnd: () => {\n this.send({ type: \"dragHandleEnd\", handleId: this.id });\n this.onDragEnd?.();\n document.body.style.cursor = \"auto\";\n },\n });\n\n this.addEventListener(\"pointerdown\", (e) => {\n if (this.disabled) return;\n moveProps.onPointerDown(e);\n });\n this.addEventListener(\"keydown\", (e) => {\n moveProps.onKeyDown(e);\n\n const collapsiblePanel = getCollapsiblePanelForHandleId(\n this.context,\n this.id\n );\n\n if (e.key === \"Enter\" && collapsiblePanel) {\n if (collapsiblePanel.collapsed) {\n this.send({ type: \"expandPanel\", panelId: collapsiblePanel.id });\n } else {\n this.send({ type: \"collapsePanel\", panelId: collapsiblePanel.id });\n }\n }\n });\n\n updateAttributes(this, this.getAttributes());\n\n if (!this.getHandleData()) {\n if (this.isPrerender) {\n this.send({\n type: \"registerPanelHandle\",\n data: this.initPanelResizer(),\n });\n } else {\n const groupElement = this.closest(\"window-splitter\");\n if (!groupElement) return;\n\n const order = Array.from(groupElement.children).indexOf(this);\n if (typeof order !== \"number\") return;\n\n this.send({\n type: \"registerPanelHandle\",\n data: { ...this.initPanelResizer(), order },\n });\n }\n }\n }\n\n updated(changedProperties: PropertyValues) {\n if (changedProperties.has(\"size\")) {\n const currentHandleData = this.getHandleData();\n if (\n currentHandleData &&\n haveConstraintsChangedForPanelHandle(\n currentHandleData,\n this.initPanelResizer()\n )\n ) {\n this.send({ type: \"updateConstraints\", data: this.initPanelResizer() });\n }\n }\n }\n disconnectedCallback(): void {\n requestAnimationFrame(() =>\n this.send({ type: \"unregisterPanelHandle\", id: this.id })\n );\n }\n\n render() {\n return html`<slot></slot>`;\n }\n}\n"]}
|