@dynamix-layout/core 0.0.2-beta.0 → 0.0.5
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/CHANGELOG.md +12 -0
- package/README.md +155 -61
- package/{LICENSE → dist/LICENSE} +1 -1
- package/dist/core.cjs.js +57 -0
- package/dist/core.cjs.js.br +0 -0
- package/dist/core.cjs.js.gz +0 -0
- package/dist/core.cjs.js.map +1 -0
- package/dist/core.es.js +1025 -0
- package/dist/core.es.js.br +0 -0
- package/dist/core.es.js.gz +0 -0
- package/dist/core.es.js.map +1 -0
- package/dist/core.iife.js +57 -1
- package/dist/core.iife.js.br +0 -0
- package/dist/core.iife.js.gz +0 -0
- package/dist/core.iife.js.map +1 -0
- package/dist/core.umd.js +57 -1
- package/dist/core.umd.js.br +0 -0
- package/dist/core.umd.js.gz +0 -0
- package/dist/core.umd.js.map +1 -0
- package/dist/types/app/comparator.d.ts +3 -0
- package/dist/types/app/dynamix.d.ts +97 -0
- package/dist/types/app/index.d.ts +4 -64
- package/dist/types/app/queue.d.ts +217 -0
- package/dist/types/app/reactive-state.d.ts +3 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/type/index.d.ts +54 -0
- package/package.json +58 -29
- package/dist/core.js +0 -1
- package/dist/core.mjs +0 -244
- package/dist/types/lib/Constant.d.ts +0 -14
- package/dist/types/lib/Element.d.ts +0 -22
- package/dist/types/lib/Helper.d.ts +0 -21
- package/dist/types/lib/Method.d.ts +0 -1
- package/dist/types/lib/index.d.ts +0 -4
- package/dist/types/types/Element.d.ts +0 -103
- package/dist/types/types/Method.d.ts +0 -5
- package/dist/types/types/index.d.ts +0 -2
- package/src/app/index.ts +0 -291
- package/src/index.ts +0 -3
- package/src/lib/Constant.ts +0 -17
- package/src/lib/Element.ts +0 -66
- package/src/lib/Helper.ts +0 -259
- package/src/lib/Method.ts +0 -12
- package/src/lib/index.ts +0 -4
- package/src/types/Element.ts +0 -116
- package/src/types/Method.ts +0 -4
- package/src/types/index.ts +0 -2
package/dist/core.es.js
ADDED
|
@@ -0,0 +1,1025 @@
|
|
|
1
|
+
class N {
|
|
2
|
+
buffer;
|
|
3
|
+
head = 0;
|
|
4
|
+
tail = 0;
|
|
5
|
+
count = 0;
|
|
6
|
+
capacity;
|
|
7
|
+
constructor(t = 16, e = []) {
|
|
8
|
+
this.capacity = Math.max(t, e.length), this.buffer = new Array(this.capacity), e.forEach((i) => {
|
|
9
|
+
this.enqueue(i);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
enqueue(t) {
|
|
13
|
+
this.count === this.capacity && this.resize(), this.buffer[this.tail] = t, this.tail = (this.tail + 1) % this.capacity, this.count++;
|
|
14
|
+
}
|
|
15
|
+
enqueueFront(t) {
|
|
16
|
+
this.count === this.capacity && this.resize(), this.head = (this.head - 1 + this.capacity) % this.capacity, this.buffer[this.head] = t, this.count++;
|
|
17
|
+
}
|
|
18
|
+
insert(t, e) {
|
|
19
|
+
if (t < 0 || t > this.count)
|
|
20
|
+
return !1;
|
|
21
|
+
if (t === 0)
|
|
22
|
+
return this.enqueueFront(e), !0;
|
|
23
|
+
if (t === this.count)
|
|
24
|
+
return this.enqueue(e), !0;
|
|
25
|
+
this.count === this.capacity && this.resize();
|
|
26
|
+
const i = t, n = this.count - t;
|
|
27
|
+
return i <= n ? this.shiftLeft(t, e) : this.shiftRight(t, e), this.count++, !0;
|
|
28
|
+
}
|
|
29
|
+
insertArray(t, e) {
|
|
30
|
+
if (t < 0 || t > this.count)
|
|
31
|
+
return !1;
|
|
32
|
+
if (e.length === 0)
|
|
33
|
+
return !0;
|
|
34
|
+
if (t === 0) {
|
|
35
|
+
for (let d = e.length - 1; d >= 0; d--)
|
|
36
|
+
this.enqueueFront(e[d]);
|
|
37
|
+
return !0;
|
|
38
|
+
}
|
|
39
|
+
if (t === this.count)
|
|
40
|
+
return e.forEach((d) => this.enqueue(d)), !0;
|
|
41
|
+
for (; this.count + e.length > this.capacity; )
|
|
42
|
+
this.resize();
|
|
43
|
+
const i = t, n = this.count - t, s = e.length;
|
|
44
|
+
return i <= n ? this.shiftLeftArray(t, e) : this.shiftRightArray(t, e), this.count += s, !0;
|
|
45
|
+
}
|
|
46
|
+
insertQueue(t, e) {
|
|
47
|
+
if (t < 0 || t > this.count)
|
|
48
|
+
return !1;
|
|
49
|
+
if (e.isEmpty())
|
|
50
|
+
return !0;
|
|
51
|
+
const i = e.size();
|
|
52
|
+
if (t === 0) {
|
|
53
|
+
const o = e.toArray();
|
|
54
|
+
for (let h = o.length - 1; h >= 0; h--)
|
|
55
|
+
this.enqueueFront(o[h]);
|
|
56
|
+
return !0;
|
|
57
|
+
}
|
|
58
|
+
if (t === this.count) {
|
|
59
|
+
for (const o of e)
|
|
60
|
+
this.enqueue(o);
|
|
61
|
+
return !0;
|
|
62
|
+
}
|
|
63
|
+
for (; this.count + i > this.capacity; )
|
|
64
|
+
this.resize();
|
|
65
|
+
const n = e.toArray(), s = t, d = this.count - t;
|
|
66
|
+
return s <= d ? this.shiftLeftArray(t, n) : this.shiftRightArray(t, n), this.count += i, !0;
|
|
67
|
+
}
|
|
68
|
+
push(t) {
|
|
69
|
+
this.enqueue(t);
|
|
70
|
+
}
|
|
71
|
+
unshift(t) {
|
|
72
|
+
this.enqueueFront(t);
|
|
73
|
+
}
|
|
74
|
+
dequeue() {
|
|
75
|
+
if (this.count === 0)
|
|
76
|
+
return;
|
|
77
|
+
const t = this.buffer[this.head];
|
|
78
|
+
return this.head = (this.head + 1) % this.capacity, this.count--, t;
|
|
79
|
+
}
|
|
80
|
+
dequeueBack() {
|
|
81
|
+
if (this.count === 0)
|
|
82
|
+
return;
|
|
83
|
+
this.tail = (this.tail - 1 + this.capacity) % this.capacity;
|
|
84
|
+
const t = this.buffer[this.tail];
|
|
85
|
+
return this.count--, t;
|
|
86
|
+
}
|
|
87
|
+
indexOf(t) {
|
|
88
|
+
for (let e = 0; e < this.count; e++) {
|
|
89
|
+
const i = (this.head + e) % this.capacity;
|
|
90
|
+
if (this.buffer[i] === t)
|
|
91
|
+
return e;
|
|
92
|
+
}
|
|
93
|
+
return -1;
|
|
94
|
+
}
|
|
95
|
+
remove(t) {
|
|
96
|
+
const e = this.indexOf(t);
|
|
97
|
+
return e === -1 ? !1 : (this.removeAt(e), !0);
|
|
98
|
+
}
|
|
99
|
+
removeAt(t) {
|
|
100
|
+
if (t < 0 || t >= this.count)
|
|
101
|
+
return;
|
|
102
|
+
if (t === 0)
|
|
103
|
+
return this.dequeue();
|
|
104
|
+
if (t === this.count - 1)
|
|
105
|
+
return this.dequeueBack();
|
|
106
|
+
const e = (this.head + t) % this.capacity, i = this.buffer[e], n = t, s = this.count - t - 1;
|
|
107
|
+
return n <= s ? this.shiftRightForRemoval(t) : this.shiftLeftForRemoval(t), this.count--, i;
|
|
108
|
+
}
|
|
109
|
+
shift() {
|
|
110
|
+
return this.dequeue();
|
|
111
|
+
}
|
|
112
|
+
pop() {
|
|
113
|
+
return this.dequeueBack();
|
|
114
|
+
}
|
|
115
|
+
fifoAdd(t) {
|
|
116
|
+
this.enqueue(t);
|
|
117
|
+
}
|
|
118
|
+
fifoRemove() {
|
|
119
|
+
return this.dequeue();
|
|
120
|
+
}
|
|
121
|
+
filoAdd(t) {
|
|
122
|
+
this.enqueue(t);
|
|
123
|
+
}
|
|
124
|
+
filoRemove() {
|
|
125
|
+
return this.dequeueBack();
|
|
126
|
+
}
|
|
127
|
+
lifoAdd(t) {
|
|
128
|
+
this.enqueueFront(t);
|
|
129
|
+
}
|
|
130
|
+
lifoRemove() {
|
|
131
|
+
return this.dequeue();
|
|
132
|
+
}
|
|
133
|
+
liloAdd(t) {
|
|
134
|
+
this.enqueueFront(t);
|
|
135
|
+
}
|
|
136
|
+
liloRemove() {
|
|
137
|
+
return this.dequeueBack();
|
|
138
|
+
}
|
|
139
|
+
get(t) {
|
|
140
|
+
if (t < 0 || t >= this.count)
|
|
141
|
+
return;
|
|
142
|
+
const e = (this.head + t) % this.capacity;
|
|
143
|
+
return this.buffer[e];
|
|
144
|
+
}
|
|
145
|
+
set(t, e) {
|
|
146
|
+
if (t < 0 || t >= this.count)
|
|
147
|
+
return !1;
|
|
148
|
+
const i = (this.head + t) % this.capacity;
|
|
149
|
+
return this.buffer[i] = e, !0;
|
|
150
|
+
}
|
|
151
|
+
peek() {
|
|
152
|
+
return this.count > 0 ? this.buffer[this.head] : void 0;
|
|
153
|
+
}
|
|
154
|
+
peekBack() {
|
|
155
|
+
if (this.count === 0) return;
|
|
156
|
+
const t = (this.tail - 1 + this.capacity) % this.capacity;
|
|
157
|
+
return this.buffer[t];
|
|
158
|
+
}
|
|
159
|
+
front() {
|
|
160
|
+
return this.peek();
|
|
161
|
+
}
|
|
162
|
+
back() {
|
|
163
|
+
return this.peekBack();
|
|
164
|
+
}
|
|
165
|
+
size() {
|
|
166
|
+
return this.count;
|
|
167
|
+
}
|
|
168
|
+
getCapacity() {
|
|
169
|
+
return this.capacity;
|
|
170
|
+
}
|
|
171
|
+
isEmpty() {
|
|
172
|
+
return this.count === 0;
|
|
173
|
+
}
|
|
174
|
+
isFull() {
|
|
175
|
+
return this.count === this.capacity;
|
|
176
|
+
}
|
|
177
|
+
clear() {
|
|
178
|
+
this.head = 0, this.tail = 0, this.count = 0;
|
|
179
|
+
}
|
|
180
|
+
toArray() {
|
|
181
|
+
const t = [];
|
|
182
|
+
for (let e = 0; e < this.count; e++) {
|
|
183
|
+
const i = (this.head + e) % this.capacity;
|
|
184
|
+
t.push(this.buffer[i]);
|
|
185
|
+
}
|
|
186
|
+
return t;
|
|
187
|
+
}
|
|
188
|
+
*[Symbol.iterator]() {
|
|
189
|
+
for (let t = 0; t < this.count; t++) {
|
|
190
|
+
const e = (this.head + t) % this.capacity;
|
|
191
|
+
yield this.buffer[e];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
*forward() {
|
|
195
|
+
for (let t = 0; t < this.count; t++) {
|
|
196
|
+
const e = (this.head + t) % this.capacity;
|
|
197
|
+
yield this.buffer[e];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
*reverse() {
|
|
201
|
+
for (let t = this.count - 1; t >= 0; t--) {
|
|
202
|
+
const e = (this.head + t) % this.capacity;
|
|
203
|
+
yield this.buffer[e];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
*entries() {
|
|
207
|
+
for (let t = 0; t < this.count; t++) {
|
|
208
|
+
const e = (this.head + t) % this.capacity;
|
|
209
|
+
yield [t, this.buffer[e]];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
*keys() {
|
|
213
|
+
for (let t = 0; t < this.count; t++)
|
|
214
|
+
yield t;
|
|
215
|
+
}
|
|
216
|
+
*values() {
|
|
217
|
+
for (let t = 0; t < this.count; t++) {
|
|
218
|
+
const e = (this.head + t) % this.capacity;
|
|
219
|
+
yield this.buffer[e];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
toString() {
|
|
223
|
+
return `Queue(${this.toArray().join(", ")})`;
|
|
224
|
+
}
|
|
225
|
+
resize() {
|
|
226
|
+
const t = this.capacity * 2, e = new Array(t);
|
|
227
|
+
for (let i = 0; i < this.count; i++) {
|
|
228
|
+
const n = (this.head + i) % this.capacity;
|
|
229
|
+
e[i] = this.buffer[n];
|
|
230
|
+
}
|
|
231
|
+
this.buffer = e, this.capacity = t, this.head = 0, this.tail = this.count;
|
|
232
|
+
}
|
|
233
|
+
shiftLeft(t, e) {
|
|
234
|
+
this.head = (this.head - 1 + this.capacity) % this.capacity;
|
|
235
|
+
for (let n = 0; n < t; n++) {
|
|
236
|
+
const s = (this.head + 1 + n) % this.capacity, d = (this.head + n) % this.capacity;
|
|
237
|
+
this.buffer[d] = this.buffer[s];
|
|
238
|
+
}
|
|
239
|
+
const i = (this.head + t) % this.capacity;
|
|
240
|
+
this.buffer[i] = e;
|
|
241
|
+
}
|
|
242
|
+
shiftRight(t, e) {
|
|
243
|
+
for (let n = this.count - 1; n >= t; n--) {
|
|
244
|
+
const s = (this.head + n) % this.capacity, d = (this.head + n + 1) % this.capacity;
|
|
245
|
+
this.buffer[d] = this.buffer[s];
|
|
246
|
+
}
|
|
247
|
+
const i = (this.head + t) % this.capacity;
|
|
248
|
+
this.buffer[i] = e, this.tail = (this.tail + 1) % this.capacity;
|
|
249
|
+
}
|
|
250
|
+
shiftRightForRemoval(t) {
|
|
251
|
+
for (let e = t; e > 0; e--) {
|
|
252
|
+
const i = (this.head + e - 1) % this.capacity, n = (this.head + e) % this.capacity;
|
|
253
|
+
this.buffer[n] = this.buffer[i];
|
|
254
|
+
}
|
|
255
|
+
this.head = (this.head + 1) % this.capacity;
|
|
256
|
+
}
|
|
257
|
+
shiftLeftForRemoval(t) {
|
|
258
|
+
for (let e = t; e < this.count - 1; e++) {
|
|
259
|
+
const i = (this.head + e + 1) % this.capacity, n = (this.head + e) % this.capacity;
|
|
260
|
+
this.buffer[n] = this.buffer[i];
|
|
261
|
+
}
|
|
262
|
+
this.tail = (this.tail - 1 + this.capacity) % this.capacity;
|
|
263
|
+
}
|
|
264
|
+
shiftLeftArray(t, e) {
|
|
265
|
+
const i = e.length;
|
|
266
|
+
this.head = (this.head - i + this.capacity) % this.capacity;
|
|
267
|
+
for (let n = 0; n < t; n++) {
|
|
268
|
+
const s = (this.head + i + n) % this.capacity, d = (this.head + n) % this.capacity;
|
|
269
|
+
this.buffer[d] = this.buffer[s];
|
|
270
|
+
}
|
|
271
|
+
for (let n = 0; n < i; n++) {
|
|
272
|
+
const s = (this.head + t + n) % this.capacity;
|
|
273
|
+
this.buffer[s] = e[n];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
shiftRightArray(t, e) {
|
|
277
|
+
const i = e.length;
|
|
278
|
+
for (let n = this.count - 1; n >= t; n--) {
|
|
279
|
+
const s = (this.head + n) % this.capacity, d = (this.head + n + i) % this.capacity;
|
|
280
|
+
this.buffer[d] = this.buffer[s];
|
|
281
|
+
}
|
|
282
|
+
for (let n = 0; n < i; n++) {
|
|
283
|
+
const s = (this.head + t + n) % this.capacity;
|
|
284
|
+
this.buffer[s] = e[n];
|
|
285
|
+
}
|
|
286
|
+
this.tail = (this.tail + i) % this.capacity;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
function g(I, t = (e, i) => e === i) {
|
|
290
|
+
let e = I;
|
|
291
|
+
const i = /* @__PURE__ */ new Set();
|
|
292
|
+
let n = [];
|
|
293
|
+
const s = () => e, d = (l, f = !1) => {
|
|
294
|
+
if (f) {
|
|
295
|
+
e = l;
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
t(e, l) || (e = l, i.forEach((m) => m(e)), n.forEach((m) => m(e)), n = []);
|
|
299
|
+
}, o = () => {
|
|
300
|
+
i.forEach((l) => l(e)), n.forEach((l) => l(e)), n = [];
|
|
301
|
+
}, h = (l) => (i.add(l), () => i.delete(l)), r = () => new Promise((l) => {
|
|
302
|
+
n.push(l);
|
|
303
|
+
});
|
|
304
|
+
return {
|
|
305
|
+
get: s,
|
|
306
|
+
set: d,
|
|
307
|
+
onChange: h,
|
|
308
|
+
nextChange: r,
|
|
309
|
+
triggerChange: o,
|
|
310
|
+
onChangePromise: (l) => {
|
|
311
|
+
let f = !0;
|
|
312
|
+
return (async () => {
|
|
313
|
+
for (; f; ) {
|
|
314
|
+
const p = await r();
|
|
315
|
+
if (!f) break;
|
|
316
|
+
l(p);
|
|
317
|
+
}
|
|
318
|
+
})(), () => {
|
|
319
|
+
f = !1;
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function E(I, t) {
|
|
325
|
+
if (I.size !== t.size) return !1;
|
|
326
|
+
for (const [e, i] of I.entries()) {
|
|
327
|
+
const n = t.get(e);
|
|
328
|
+
if (!n || !O(i, n))
|
|
329
|
+
return !1;
|
|
330
|
+
}
|
|
331
|
+
return !0;
|
|
332
|
+
}
|
|
333
|
+
function O(I, t) {
|
|
334
|
+
if (I.typNode !== t.typNode || I.nodName !== t.nodName || I.uidNode !== t.uidNode || I.nodPart !== t.nodPart) return !1;
|
|
335
|
+
const e = I.nodDims, i = t.nodDims;
|
|
336
|
+
return e.x === i.x && e.y === i.y && e.w === i.w && e.h === i.h;
|
|
337
|
+
}
|
|
338
|
+
class a {
|
|
339
|
+
static cache = {
|
|
340
|
+
dimMins: /* @__PURE__ */ new Map(),
|
|
341
|
+
mapDirs: /* @__PURE__ */ new Map(),
|
|
342
|
+
tabCnts: /* @__PURE__ */ new Map(),
|
|
343
|
+
mapElem: /* @__PURE__ */ new Map(),
|
|
344
|
+
tabOpts: g(
|
|
345
|
+
/* @__PURE__ */ new Map(),
|
|
346
|
+
E
|
|
347
|
+
),
|
|
348
|
+
nodOpts: g(
|
|
349
|
+
/* @__PURE__ */ new Map(),
|
|
350
|
+
E
|
|
351
|
+
),
|
|
352
|
+
bndOpts: g(
|
|
353
|
+
/* @__PURE__ */ new Map(),
|
|
354
|
+
E
|
|
355
|
+
)
|
|
356
|
+
};
|
|
357
|
+
kids = new N();
|
|
358
|
+
dims = { w: 0, h: 0, x: 0, y: 0 };
|
|
359
|
+
unId;
|
|
360
|
+
next = null;
|
|
361
|
+
prev = null;
|
|
362
|
+
type = "row";
|
|
363
|
+
name = "";
|
|
364
|
+
part = 0;
|
|
365
|
+
host = null;
|
|
366
|
+
open = "";
|
|
367
|
+
constructor(t = {}) {
|
|
368
|
+
const e = {
|
|
369
|
+
type: "row",
|
|
370
|
+
host: null,
|
|
371
|
+
name: "",
|
|
372
|
+
part: 100,
|
|
373
|
+
dims: { w: 0, h: 0, x: 0, y: 0 },
|
|
374
|
+
unId: crypto.randomUUID(),
|
|
375
|
+
open: ""
|
|
376
|
+
};
|
|
377
|
+
this.type = t.type ?? e.type, this.host = t.host ?? e.host, this.name = t.name ?? e.name, this.part = t.part ?? e.part, this.dims = t.dims ?? e.dims, this.open = t.open ?? e.open, this.unId = t.unId || e.unId;
|
|
378
|
+
}
|
|
379
|
+
addBond(t, e = null) {
|
|
380
|
+
if (!e) return;
|
|
381
|
+
const i = new x(t, this, e);
|
|
382
|
+
a.cache.mapElem.set(i.unId, i);
|
|
383
|
+
}
|
|
384
|
+
getReqDimension() {
|
|
385
|
+
const t = a.cache.dimMins.get(this.unId), e = a.cache.tabCnts.get(this.unId), i = Math.max(
|
|
386
|
+
t.minWidth,
|
|
387
|
+
e.horizontal * c._minW + Math.max(0, e.horizontal - 1) * c._bond
|
|
388
|
+
), n = Math.max(
|
|
389
|
+
t.minHeight,
|
|
390
|
+
e.vertical * c._minH + Math.max(0, e.vertical - 1) * c._bond
|
|
391
|
+
);
|
|
392
|
+
return {
|
|
393
|
+
width: i,
|
|
394
|
+
height: n
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
calcDimensions() {
|
|
398
|
+
const t = a.cache.mapDirs.get(this.unId);
|
|
399
|
+
if (!this.kids) return;
|
|
400
|
+
let e = 0;
|
|
401
|
+
const i = a.cache.dimMins.get(this.unId) || {
|
|
402
|
+
minWidth: 0,
|
|
403
|
+
minHeight: 0
|
|
404
|
+
};
|
|
405
|
+
let n = 0;
|
|
406
|
+
for (const o of this.kids)
|
|
407
|
+
e += o.part;
|
|
408
|
+
if (e === 0) return;
|
|
409
|
+
let s;
|
|
410
|
+
t ? s = this.dims.w - i.minWidth : s = this.dims.h - i.minHeight;
|
|
411
|
+
let d = s;
|
|
412
|
+
for (const o of this.kids) {
|
|
413
|
+
const h = a.cache.dimMins.get(o.unId) || {
|
|
414
|
+
minWidth: 0,
|
|
415
|
+
minHeight: 0
|
|
416
|
+
};
|
|
417
|
+
if (this.dims.w < i.minWidth)
|
|
418
|
+
t ? (o.dims.w = h.minWidth, o.dims.h = this.dims.h, o.dims.x = this.dims.x + n, o.dims.y = this.dims.y, n += o.dims.w + c._bond) : (o.dims.h = h.minHeight, o.dims.w = this.dims.w, o.dims.y = this.dims.y + n, o.dims.x = this.dims.x, n += o.dims.h + c._bond);
|
|
419
|
+
else {
|
|
420
|
+
const r = o.part / e, u = Math.floor(s * r);
|
|
421
|
+
if (o === this.kids.peekBack()) {
|
|
422
|
+
t ? (o.dims.w = h.minWidth + d, o.dims.h = this.dims.h, o.dims.x = this.dims.x + n, o.dims.y = this.dims.y, n += o.dims.w + c._bond) : (o.dims.h = h.minHeight + d, o.dims.w = this.dims.w, o.dims.y = this.dims.y + n, o.dims.x = this.dims.x, n += o.dims.h + c._bond);
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
t ? (o.dims.w = h.minWidth + u, o.dims.h = this.dims.h, o.dims.x = this.dims.x + n, o.dims.y = this.dims.y, n += o.dims.w + c._bond) : (o.dims.h = h.minHeight + u, o.dims.w = this.dims.w, o.dims.y = this.dims.y + n, o.dims.x = this.dims.x, n += o.dims.h + c._bond), d -= u;
|
|
426
|
+
}
|
|
427
|
+
o.next && (t ? o.next.dims = {
|
|
428
|
+
w: c._bond,
|
|
429
|
+
h: o.dims.h,
|
|
430
|
+
x: o.dims.x + o.dims.w,
|
|
431
|
+
y: o.dims.y
|
|
432
|
+
} : o.next.dims = {
|
|
433
|
+
w: o.dims.w,
|
|
434
|
+
h: c._bond,
|
|
435
|
+
x: o.dims.x,
|
|
436
|
+
y: o.dims.y + o.dims.h
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
toJSON() {
|
|
441
|
+
const t = [];
|
|
442
|
+
for (const i of this.kids)
|
|
443
|
+
t.push(i.toJSON());
|
|
444
|
+
const e = {
|
|
445
|
+
typNode: this.type,
|
|
446
|
+
nodPart: this.part,
|
|
447
|
+
nodName: this.name,
|
|
448
|
+
uidNode: this.unId
|
|
449
|
+
};
|
|
450
|
+
return this.open && (e.nodOpen = this.open), t.length > 0 && (e.nodKids = t), e;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
class c {
|
|
454
|
+
static _root;
|
|
455
|
+
static _tree;
|
|
456
|
+
static _minW = 40;
|
|
457
|
+
static _minH = 40;
|
|
458
|
+
static _bond = 10;
|
|
459
|
+
static _inst = null;
|
|
460
|
+
nodeOps;
|
|
461
|
+
cntdown = null;
|
|
462
|
+
tabsIds = /* @__PURE__ */ new Map();
|
|
463
|
+
constructor(t = {}) {
|
|
464
|
+
const e = {
|
|
465
|
+
tabs: [],
|
|
466
|
+
tree: null,
|
|
467
|
+
minW: 40,
|
|
468
|
+
minH: 40,
|
|
469
|
+
bond: 10,
|
|
470
|
+
uqid: "dynamix-layout-root",
|
|
471
|
+
tabsIds: /* @__PURE__ */ new Map(),
|
|
472
|
+
...t
|
|
473
|
+
};
|
|
474
|
+
this.tabsIds = e.tabsIds, e.tree && (c._tree = e.tree), c._root = new a({
|
|
475
|
+
unId: e.uqid,
|
|
476
|
+
name: e.uqid,
|
|
477
|
+
type: "row"
|
|
478
|
+
}), this.nodeOps = g(
|
|
479
|
+
/* @__PURE__ */ new Map(),
|
|
480
|
+
E
|
|
481
|
+
), c._minW = e.minW, c._minH = e.minH, c._bond = e.bond;
|
|
482
|
+
const i = new N(e.tabs.length, e.tabs);
|
|
483
|
+
c._tree ? this.createNodeLayout() : this.createBinaryNodeTreeFromQueue(i), c._inst = this;
|
|
484
|
+
}
|
|
485
|
+
*JSONLayoutIterator(t) {
|
|
486
|
+
const e = new N();
|
|
487
|
+
for (e.enqueue(t); !e.isEmpty(); ) {
|
|
488
|
+
const i = e.dequeue();
|
|
489
|
+
if (i && (yield i, i.nodKids && i.nodKids.length > 0))
|
|
490
|
+
for (const n of i.nodKids)
|
|
491
|
+
e.enqueue(n);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
*NodeLayoutIterator(t) {
|
|
495
|
+
const e = new N();
|
|
496
|
+
for (e.enqueue(t); !e.isEmpty(); ) {
|
|
497
|
+
const i = e.dequeue();
|
|
498
|
+
if (i && (a.cache.mapElem.set(i.unId, i), yield i, i.kids.size() > 0))
|
|
499
|
+
for (const n of i.kids)
|
|
500
|
+
e.enqueue(n);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
*NodeLayoutRecursiveIterator(t) {
|
|
504
|
+
for (const e of t.kids)
|
|
505
|
+
yield* this.NodeLayoutRecursiveIterator(e);
|
|
506
|
+
yield t;
|
|
507
|
+
}
|
|
508
|
+
updateChildDirections(t) {
|
|
509
|
+
const e = a.cache.mapDirs.get(t.unId);
|
|
510
|
+
if (e === void 0) {
|
|
511
|
+
console.warn(
|
|
512
|
+
`Cannot update child directions for node ${t.unId}; its own direction is not set.`
|
|
513
|
+
);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
for (const i of t.kids)
|
|
517
|
+
a.cache.mapDirs.set(i.unId, !e), i.kids.size() > 0 && (i.host = t, this.updateChildDirections(i), i.next && a.cache.mapDirs.set(i.next.unId, !e));
|
|
518
|
+
}
|
|
519
|
+
createNodeLayout(t = c._tree) {
|
|
520
|
+
const e = this.JSONLayoutIterator(t), i = this.NodeLayoutIterator(c._root);
|
|
521
|
+
for (a.cache.mapDirs.set(c._root.unId, !0); ; ) {
|
|
522
|
+
const n = e.next(), s = i.next();
|
|
523
|
+
if (n.done || s.done)
|
|
524
|
+
break;
|
|
525
|
+
const d = n.value, o = s.value;
|
|
526
|
+
!d || !o || this.createNodeTreeFromJSONTree(d, o);
|
|
527
|
+
}
|
|
528
|
+
this.calcTabsetCountAndMinDim();
|
|
529
|
+
}
|
|
530
|
+
createNodeTreeFromJSONTree(t, e) {
|
|
531
|
+
const i = a.cache.mapDirs.get(e.unId);
|
|
532
|
+
for (const n of t.nodKids || []) {
|
|
533
|
+
const s = this.createNodeFromJSON(n), d = e.kids.peekBack();
|
|
534
|
+
s.host = e, s.addBond(s.host, d), e.kids.enqueue(s), a.cache.mapDirs.set(s.unId, !i);
|
|
535
|
+
}
|
|
536
|
+
e.type === "tabset" && a.cache.mapElem.set(e.unId, e), e.type === "tab" && a.cache.mapElem.set(e.unId, e);
|
|
537
|
+
}
|
|
538
|
+
createBinaryNodeTreeFromQueue(t, e = c._root) {
|
|
539
|
+
const i = new N();
|
|
540
|
+
for (i.enqueue(e), a.cache.mapDirs.set(c._root.unId, !0); !t.isEmpty(); ) {
|
|
541
|
+
const n = i.dequeue();
|
|
542
|
+
if (!n)
|
|
543
|
+
break;
|
|
544
|
+
const s = a.cache.mapDirs.get(n.unId);
|
|
545
|
+
if (t.size() == 2) {
|
|
546
|
+
const u = t.dequeue(), l = t.dequeue(), f = new a({ type: "tabset", host: n }), m = new a({ type: "tabset", host: n }), p = new a({
|
|
547
|
+
type: "tab",
|
|
548
|
+
host: f,
|
|
549
|
+
name: u,
|
|
550
|
+
unId: this.tabsIds.get(u ?? "") ?? crypto.randomUUID()
|
|
551
|
+
}), w = new a({
|
|
552
|
+
type: "tab",
|
|
553
|
+
host: m,
|
|
554
|
+
name: l,
|
|
555
|
+
unId: this.tabsIds.get(l ?? "") ?? crypto.randomUUID()
|
|
556
|
+
});
|
|
557
|
+
f.open = p.name, m.open = w.name, f.kids.enqueue(p), m.kids.enqueue(w), n.kids.enqueue(f), n.kids.enqueue(m), m.addBond(n, f), a.cache.mapDirs.set(f.unId, !s), a.cache.mapDirs.set(m.unId, !s), a.cache.mapElem.set(f.unId, f), a.cache.mapElem.set(m.unId, m), a.cache.mapDirs.set(p.unId, s), a.cache.mapDirs.set(w.unId, s), a.cache.mapElem.set(p.unId, p), a.cache.mapElem.set(w.unId, w), console.log(this.tabsIds);
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
const d = t.dequeue(), o = new a({ type: "tabset", host: n }), h = new a({ type: "row", host: n }), r = new a({
|
|
561
|
+
type: "tab",
|
|
562
|
+
host: o,
|
|
563
|
+
name: d,
|
|
564
|
+
unId: this.tabsIds.get(d ?? "") ?? crypto.randomUUID()
|
|
565
|
+
});
|
|
566
|
+
o.open = r.name, o.kids.enqueue(r), n.kids.enqueue(o), n.kids.enqueue(h), h.addBond(n, o), a.cache.mapDirs.set(o.unId, !s), a.cache.mapDirs.set(h.unId, !s), a.cache.mapElem.set(o.unId, o), a.cache.mapDirs.set(r.unId, s), a.cache.mapElem.set(r.unId, r), i.enqueue(h);
|
|
567
|
+
}
|
|
568
|
+
this.calcTabsetCountAndMinDim();
|
|
569
|
+
}
|
|
570
|
+
createNodeFromJSON(t) {
|
|
571
|
+
const e = new a({
|
|
572
|
+
type: t.typNode,
|
|
573
|
+
name: t.nodName,
|
|
574
|
+
unId: t.uidNode,
|
|
575
|
+
part: t.nodPart,
|
|
576
|
+
dims: { w: 0, h: 0, x: 0, y: 0 },
|
|
577
|
+
open: typeof t.nodOpen == "string" ? t.nodOpen : ""
|
|
578
|
+
});
|
|
579
|
+
return t.typNode === "tab" && (e.unId = this.tabsIds.get(t.nodName) || t.uidNode), e;
|
|
580
|
+
}
|
|
581
|
+
calcTabsetCountAndMinDim(t = c._root, e = !0) {
|
|
582
|
+
t === c._root && e && (a.cache.tabCnts.clear(), a.cache.dimMins.clear(), a.cache.mapElem.clear(), a.cache.mapElem.clear(), a.cache.mapElem.clear(), a.cache.mapElem.clear(), a.cache.nodOpts.get().clear(), a.cache.bndOpts.get().clear());
|
|
583
|
+
for (const i of this.NodeLayoutRecursiveIterator(t)) {
|
|
584
|
+
const n = a.cache.tabCnts, s = a.cache.dimMins;
|
|
585
|
+
a.cache.mapElem.set(i.unId, i);
|
|
586
|
+
const d = n.set(i.unId, {
|
|
587
|
+
horizontal: 0,
|
|
588
|
+
vertical: 0
|
|
589
|
+
}).get(i.unId), o = s.set(i.unId, {
|
|
590
|
+
minWidth: 0,
|
|
591
|
+
minHeight: 0
|
|
592
|
+
}).get(i.unId), h = a.cache.mapDirs.get(i.unId);
|
|
593
|
+
if (i.type === "tab" && (a.cache.mapElem.set(i.unId, i), s.set(i.unId, {
|
|
594
|
+
minWidth: 0,
|
|
595
|
+
minHeight: 0
|
|
596
|
+
})), i.next && a.cache.mapElem.set(i.next.unId, i.next), i.type === "tabset" && (a.cache.mapElem.set(i.unId, i), s.set(i.unId, {
|
|
597
|
+
minWidth: c._minW,
|
|
598
|
+
minHeight: c._minH
|
|
599
|
+
}), h ? n.set(i.unId, {
|
|
600
|
+
horizontal: 0,
|
|
601
|
+
vertical: 1
|
|
602
|
+
}) : n.set(i.unId, {
|
|
603
|
+
horizontal: 1,
|
|
604
|
+
vertical: 0
|
|
605
|
+
})), i.type === "row") {
|
|
606
|
+
for (const r of i.kids) {
|
|
607
|
+
const u = n.get(r.unId), l = s.get(r.unId);
|
|
608
|
+
u && (d.horizontal += u.horizontal, d.vertical += u.vertical, h ? (o.minHeight = Math.max(
|
|
609
|
+
o.minHeight,
|
|
610
|
+
l.minHeight
|
|
611
|
+
), o.minWidth += l.minWidth) : (o.minHeight += l.minHeight, o.minWidth = Math.max(
|
|
612
|
+
o.minWidth,
|
|
613
|
+
l.minWidth
|
|
614
|
+
)));
|
|
615
|
+
}
|
|
616
|
+
h ? o.minWidth += (i.kids.size() - 1) * c._bond : o.minHeight += (i.kids.size() - 1) * c._bond;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
calculateRootAdjustment() {
|
|
621
|
+
const t = c._root.getReqDimension();
|
|
622
|
+
let e = !1, i = c._root.dims.w, n = c._root.dims.h;
|
|
623
|
+
return c._root.dims.w < t.width && (i = t.width, e = !0), c._root.dims.h < t.height && (n = t.height, e = !0), e && (c._root.dims.w = i, c._root.dims.h = n), {
|
|
624
|
+
adjustedW: i,
|
|
625
|
+
adjustedH: n,
|
|
626
|
+
wasAdjusted: e
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
calcDimensions(t = c._root, e = !1) {
|
|
630
|
+
const i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
|
|
631
|
+
t === c._root && this.calculateRootAdjustment();
|
|
632
|
+
for (const d of this.NodeLayoutIterator(t)) {
|
|
633
|
+
d.calcDimensions();
|
|
634
|
+
const o = a.cache.mapDirs.get(d.unId);
|
|
635
|
+
if (d.type === "tabset") {
|
|
636
|
+
const h = {
|
|
637
|
+
typNode: d.type,
|
|
638
|
+
nodName: d.name,
|
|
639
|
+
uidNode: d.unId,
|
|
640
|
+
nodPart: d.part,
|
|
641
|
+
nodOpen: d.open,
|
|
642
|
+
nodeDir: o,
|
|
643
|
+
nodKids: Array.from(d.kids).map((r) => {
|
|
644
|
+
const u = {
|
|
645
|
+
typNode: r.type,
|
|
646
|
+
nodName: r.name,
|
|
647
|
+
uidNode: r.unId,
|
|
648
|
+
nodPart: r.part,
|
|
649
|
+
nodOpen: d.open === r.name,
|
|
650
|
+
nodeDir: !o,
|
|
651
|
+
nodDims: {
|
|
652
|
+
...d.dims
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
return s.set(r.unId, u), u;
|
|
656
|
+
}),
|
|
657
|
+
nodDims: {
|
|
658
|
+
...d.dims
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
i.set(d.unId, h);
|
|
662
|
+
}
|
|
663
|
+
if (d.next && d.type !== "tab") {
|
|
664
|
+
const h = {
|
|
665
|
+
typNode: "bond",
|
|
666
|
+
nodName: d.name,
|
|
667
|
+
uidNode: d.next.unId,
|
|
668
|
+
nodeDir: o,
|
|
669
|
+
nodPart: 0,
|
|
670
|
+
nodDims: {
|
|
671
|
+
...d.next.dims
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
n.set(d.next.unId, h);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
a.cache.nodOpts.set(i, e), a.cache.bndOpts.set(n, e), a.cache.tabOpts.set(s, e);
|
|
678
|
+
}
|
|
679
|
+
updateDimension(t, e = !1, i = 2) {
|
|
680
|
+
if (c._root.dims = t, e) {
|
|
681
|
+
this.calcDimensions(c._root);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
this.cntdown && (clearTimeout(this.cntdown), this.cntdown = null), this.cntdown = setTimeout(() => {
|
|
685
|
+
this.cntdown = null, this.calcDimensions();
|
|
686
|
+
}, i);
|
|
687
|
+
}
|
|
688
|
+
updateSlider(t, e, i = !1, n = 2) {
|
|
689
|
+
if (i) {
|
|
690
|
+
this.updateSliderDimension(t, e);
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
this.cntdown && (clearTimeout(this.cntdown), this.cntdown = null), this.cntdown = setTimeout(() => {
|
|
694
|
+
this.cntdown = null, this.updateSliderDimension(t, e);
|
|
695
|
+
}, n);
|
|
696
|
+
}
|
|
697
|
+
updateSliderDimension(t, e) {
|
|
698
|
+
const i = a.cache.mapElem.get(t);
|
|
699
|
+
if (!i || !(i instanceof x)) {
|
|
700
|
+
console.warn(
|
|
701
|
+
`Bond with id ${t} not found or is not a Bond instance`
|
|
702
|
+
);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
const n = a.cache.mapDirs.get(i.host.unId), s = i.prev, d = i.next, o = i.host;
|
|
706
|
+
if (!s || !d || !o) {
|
|
707
|
+
console.warn("Missing prev, next, or host node", s, d, o);
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
const h = a.cache.dimMins.get(s.unId) || {
|
|
711
|
+
minWidth: 0,
|
|
712
|
+
minHeight: 0
|
|
713
|
+
}, r = a.cache.dimMins.get(d.unId) || {
|
|
714
|
+
minWidth: 0,
|
|
715
|
+
minHeight: 0
|
|
716
|
+
}, u = c._bond / 2;
|
|
717
|
+
if (n) {
|
|
718
|
+
const l = d.dims.x + d.dims.w, f = s.dims.x + h.minWidth + u, m = l - r.minWidth - u, p = Math.max(f, Math.min(m, e.x));
|
|
719
|
+
i.dims.x = p - u, s.dims.w = i.dims.x - s.dims.x, d.dims.x = p + u, d.dims.w = l - d.dims.x;
|
|
720
|
+
const w = Math.max(
|
|
721
|
+
0,
|
|
722
|
+
s.dims.w - h.minWidth
|
|
723
|
+
), k = Math.max(
|
|
724
|
+
0,
|
|
725
|
+
d.dims.w - r.minWidth
|
|
726
|
+
), b = w + k, y = s.part + d.part;
|
|
727
|
+
b > 0 ? (s.part = w / b * y, d.part = k / b * y) : (s.part = y / 2, d.part = y / 2);
|
|
728
|
+
} else {
|
|
729
|
+
const l = d.dims.y + d.dims.h, f = s.dims.y + h.minHeight + u, m = l - r.minHeight - u, p = Math.max(f, Math.min(m, e.y));
|
|
730
|
+
i.dims.y = p - u, s.dims.h = i.dims.y - s.dims.y, d.dims.y = p + u, d.dims.h = l - d.dims.y;
|
|
731
|
+
const w = Math.max(
|
|
732
|
+
0,
|
|
733
|
+
s.dims.h - h.minHeight
|
|
734
|
+
), k = Math.max(
|
|
735
|
+
0,
|
|
736
|
+
d.dims.h - r.minHeight
|
|
737
|
+
), b = w + k, y = s.part + d.part;
|
|
738
|
+
b > 0 ? (s.part = w / b * y, d.part = k / b * y) : (s.part = y / 2, d.part = y / 2);
|
|
739
|
+
}
|
|
740
|
+
this.calcDimensions(o);
|
|
741
|
+
}
|
|
742
|
+
updateTree(t, e, i) {
|
|
743
|
+
const n = a.cache.mapElem.get(t);
|
|
744
|
+
let s = a.cache.mapElem.get(e);
|
|
745
|
+
return !n || !(n instanceof a) || !s || !(s instanceof a) ? (console.warn(
|
|
746
|
+
`Source node ${t} not found or is not a Node instance`
|
|
747
|
+
), !1) : n?.type == "tab" && n.host === s && s.kids.size() < 2 ? (console.warn("Cannot move to self as it has only one tab"), !1) : n?.type == "tabset" && s?.host === n ? (console.warn("Cannot move tabset to self as it is already a child"), !1) : !n || !s ? (console.warn(`Source or destination node not found: ${t}, ${e}`), !1) : n === s ? (console.warn(
|
|
748
|
+
"Source and destination nodes are the same, no action taken."
|
|
749
|
+
), !1) : !n.host || !s.host && s.type !== "row" ? (console.warn(
|
|
750
|
+
`Source node or destination node's host is null: ${n.unId}, ${s.unId}`
|
|
751
|
+
), !1) : s.type === "row" && i === "contain" ? (console.warn(
|
|
752
|
+
`Cannot move to a row with 'contain' layout: ${s.unId}`
|
|
753
|
+
), !1) : n.type === "row" ? !1 : (s.type === "tabset" && i === "contain" && (s = s.kids.peekBack() || s), s.type === "tab" && (i === "contain" || i === "left" || i === "right") ? this.moveNodeAsTab(n, s, i) : s.type === "row" && i !== "contain" ? this.moveRelativeToRoot(n, s, i) : s.type === "tabset" && i !== "contain" && this.moveRelativeToTabset(n, s, i), this.calcTabsetCountAndMinDim(), this.calcDimensions(c._root, !0), !0);
|
|
754
|
+
}
|
|
755
|
+
moveNodeAsTab(t, e, i) {
|
|
756
|
+
if (!e || !e.host) {
|
|
757
|
+
console.warn(
|
|
758
|
+
`Destination node ${e.unId} has no host, cannot move.`
|
|
759
|
+
);
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
this.removeNode(t);
|
|
763
|
+
const n = e.host, s = n.kids.indexOf(e);
|
|
764
|
+
if (s === void 0 || s === -1)
|
|
765
|
+
return;
|
|
766
|
+
const d = i === "contain" || i === "left", o = d ? s : s + 1, h = n.kids.get(o + 1), r = n.kids.get(o - 1), u = e.next, l = e.prev;
|
|
767
|
+
if (!d && u ? (a.cache.mapElem.delete(u.unId), a.cache.nodOpts.get().delete(u.unId)) : d && l && (a.cache.mapElem.delete(l.unId), a.cache.nodOpts.get().delete(l.unId)), t.type == "tab")
|
|
768
|
+
d ? (r && t.addBond(n, r), e.addBond(n, t)) : (t.addBond(n, e), h && h.addBond(n, t)), n.kids.insert(o, t), t.host = n, n.open = t.name;
|
|
769
|
+
else if (t.type == "tabset") {
|
|
770
|
+
const f = t.kids.peek(), m = t.kids.peekBack();
|
|
771
|
+
d ? (f && r && f.addBond(n, r), m && e && e.addBond(n, m)) : (f && e && f.addBond(n, e), m && h && h.addBond(n, m)), n.kids.insertQueue(o, t.kids);
|
|
772
|
+
for (const p of t.kids)
|
|
773
|
+
p.host = n, p.next && (p.next.host = n);
|
|
774
|
+
n.open = m ? m.name : "";
|
|
775
|
+
}
|
|
776
|
+
this.updateChildDirections(n);
|
|
777
|
+
}
|
|
778
|
+
moveRelativeToRoot(t, e, i) {
|
|
779
|
+
this.removeNode(t);
|
|
780
|
+
const n = a.cache.mapDirs.get(e.unId), s = i === "top" || i === "left";
|
|
781
|
+
if (t.type === "tab") {
|
|
782
|
+
const d = new a({ type: "tabset", host: e.host });
|
|
783
|
+
d.kids.enqueue(t), t.host = d, d.open = t.name, n == !1 ? i === "left" || i === "right" ? this.insertNodeWithNewParent(d, e, s) : this.insertNode(e, d, s) : i === "top" || i === "bottom" ? this.insertNodeWithNewParent(d, e, s) : this.insertNode(e, d, s);
|
|
784
|
+
} else t.type === "tabset" && (n == !1 ? i === "left" || i === "right" ? this.insertNodeWithNewParent(t, e, s) : this.insertNode(e, t, s) : i === "top" || i === "bottom" ? this.insertNodeWithNewParent(t, e, s) : this.insertNode(e, t, s));
|
|
785
|
+
}
|
|
786
|
+
moveRelativeToTabset(t, e, i) {
|
|
787
|
+
this.removeNode(t);
|
|
788
|
+
const n = a.cache.mapDirs.get(e.unId), s = i === "top" || i === "left";
|
|
789
|
+
if (t.type === "tab") {
|
|
790
|
+
const d = new a({ type: "tabset", host: e.host });
|
|
791
|
+
d.kids.enqueue(t), t.host = d, d.open = t.name, n == !1 ? i === "top" || i === "bottom" ? this.insertNodeWithNewParent(d, e, s) : this.insertNode(e, d, s) : i === "left" || i === "right" ? this.insertNodeWithNewParent(d, e, s) : this.insertNode(e, d, s);
|
|
792
|
+
} else t.type === "tabset" && (n == !1 ? i === "top" || i === "bottom" ? this.insertNodeWithNewParent(t, e, s) : this.insertNode(e, t, s) : i === "left" || i === "right" ? this.insertNodeWithNewParent(t, e, s) : this.insertNode(e, t, s));
|
|
793
|
+
}
|
|
794
|
+
insertNode(t, e, i) {
|
|
795
|
+
const n = t.host;
|
|
796
|
+
if (t == c._root) {
|
|
797
|
+
const l = c._root.kids.peek(), f = c._root.kids.peekBack();
|
|
798
|
+
i ? (c._root.kids.enqueueFront(e), l && l.addBond(c._root, e)) : (c._root.kids.enqueue(e), f && e.addBond(c._root, f)), e.host = c._root, this.updateChildDirections(c._root);
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (!n) {
|
|
802
|
+
console.warn(
|
|
803
|
+
`Destination node ${t.unId} has no host, cannot insert.`
|
|
804
|
+
);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
const s = n.kids.indexOf(t);
|
|
808
|
+
if (s === -1) {
|
|
809
|
+
console.warn(
|
|
810
|
+
`Destination node ${t.unId} not found in its host's kids.`
|
|
811
|
+
);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
const d = a.cache.mapDirs.get(n.unId);
|
|
815
|
+
d && a.cache.mapDirs.set(e.unId, !d);
|
|
816
|
+
const o = n.kids.get(s + 1), h = n.kids.get(s - 1), r = t.next, u = t.prev;
|
|
817
|
+
e.host = n, i ? (n.kids.insert(s, e), t.addBond(n, e), h && e.addBond(n, h), u && (a.cache.mapElem.delete(u.unId), a.cache.nodOpts.get().delete(u.unId))) : (n.kids.insert(s + 1, e), e.addBond(n, t), o && o.addBond(n, e), r && (a.cache.mapElem.delete(r.unId), a.cache.nodOpts.get().delete(r.unId))), this.updateChildDirections(n);
|
|
818
|
+
}
|
|
819
|
+
insertNodeWithNewParent(t, e, i) {
|
|
820
|
+
const n = new N(), s = new a({ type: "tabset", host: e.host });
|
|
821
|
+
if (!e || !t) {
|
|
822
|
+
console.warn(
|
|
823
|
+
`Destination node ${e.unId} has no host, cannot insert.`
|
|
824
|
+
);
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
if (e === c._root) {
|
|
828
|
+
const o = new a({ type: "row", host: e });
|
|
829
|
+
if (e.kids.size() == 1 && e.kids.peek()?.type === "tabset") {
|
|
830
|
+
const h = e.kids.dequeue();
|
|
831
|
+
if (!h) {
|
|
832
|
+
console.warn(
|
|
833
|
+
`No kid found in destination node ${e.unId}, cannot insert.`
|
|
834
|
+
);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
i ? (o.kids.enqueue(t), o.kids.enqueue(h), e.kids.enqueue(o), h.addBond(o, t)) : (o.kids.enqueue(h), o.kids.enqueue(t), t.addBond(o, h), e.kids.enqueue(o)), t.host = o, h.host = o;
|
|
838
|
+
} else if (e.kids.size() == 1 && e.kids.peek()?.type === "row") {
|
|
839
|
+
const h = e.kids.peek(), r = h?.kids.peek(), u = h?.kids.peekBack();
|
|
840
|
+
i && h ? (h.kids.enqueueFront(t), r && r.addBond(h, t)) : h && (h.kids.enqueue(t), u && t.addBond(h, u)), t.host = h;
|
|
841
|
+
} else if (e.kids.size() > 1) {
|
|
842
|
+
const h = new a({ type: "row", host: e }), r = new a({ type: "row", host: h });
|
|
843
|
+
for (const u of e.kids)
|
|
844
|
+
r.kids.enqueue(u), u.host = r, u.next && (u.next.host = r);
|
|
845
|
+
t.host = h, e.kids.clear(), i ? (h.kids.enqueueFront(t), h.kids.enqueue(r), r.addBond(h, t)) : (h.kids.enqueue(r), h.kids.enqueue(t), t.addBond(h, r)), e.kids.enqueue(h);
|
|
846
|
+
}
|
|
847
|
+
this.updateChildDirections(e);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
t.host = e, s.host = e, s.kids = e.kids, s.open = e.open;
|
|
851
|
+
const d = a.cache.mapDirs.get(e.unId);
|
|
852
|
+
for (const o of s.kids)
|
|
853
|
+
o.host = s, o.next && (o.next.host = s), a.cache.mapDirs.set(o.unId, d);
|
|
854
|
+
for (const o of t.kids)
|
|
855
|
+
o.host = t, o.next && (o.next.host = t), a.cache.mapDirs.set(o.unId, d);
|
|
856
|
+
a.cache.mapDirs.set(s.unId, !d), a.cache.mapDirs.set(t.unId, !d), i ? (n.enqueue(t), n.enqueue(s), e.kids = n, e.type = "row", s.addBond(e, t)) : (n.enqueue(s), n.enqueue(t), e.kids = n, e.type = "row", t.addBond(e, s));
|
|
857
|
+
}
|
|
858
|
+
moveAdjacentNodeToGrandParent(t) {
|
|
859
|
+
if (!t.host || !t.host.host) {
|
|
860
|
+
console.warn(`Source node ${t.unId} has no host, cannot move.`);
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
const e = t.host, i = t.host.host, n = i.kids.indexOf(e), s = i.kids.get(n - 1), d = i.kids.get(n + 1), o = t.kids.peek(), h = t.kids.peekBack();
|
|
864
|
+
this.removeKid(e);
|
|
865
|
+
let r = n;
|
|
866
|
+
if (t.type == "row" && e) {
|
|
867
|
+
s && o && o.addBond(i, s), d && h && d.addBond(i, h);
|
|
868
|
+
for (const u of t.kids)
|
|
869
|
+
u.host = i, u.next && (u.next.host = i), i.kids.insert(r, u), a.cache.mapDirs.set(
|
|
870
|
+
u.unId,
|
|
871
|
+
!a.cache.mapDirs.get(i.unId)
|
|
872
|
+
), a.cache.dimMins.delete(u.unId), r++;
|
|
873
|
+
} else if (t.type == "tabset") {
|
|
874
|
+
s && t.addBond(i, s), d && d.addBond(i, t), i.kids.insert(r, t), t.host = i, a.cache.mapDirs.set(
|
|
875
|
+
t.unId,
|
|
876
|
+
!a.cache.mapDirs.get(i.unId)
|
|
877
|
+
);
|
|
878
|
+
for (const u of t.kids)
|
|
879
|
+
a.cache.mapDirs.set(
|
|
880
|
+
u.unId,
|
|
881
|
+
a.cache.mapDirs.get(i.unId)
|
|
882
|
+
), a.cache.dimMins.delete(u.unId);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
removeRelation(t, e = !0) {
|
|
886
|
+
const i = t.host, n = t.prev, s = t.next;
|
|
887
|
+
if (t.host = null, t.next = null, t.prev = null, n && (n.next = null), s && (s.prev = null), !e)
|
|
888
|
+
return t;
|
|
889
|
+
n && s && n.prev && s.next ? n.prev.addBond(i, s.next) : n && n.prev ? n.prev.next = null : s && s.next && (s.next.prev = null);
|
|
890
|
+
}
|
|
891
|
+
removeNode(t) {
|
|
892
|
+
if (!t.host) {
|
|
893
|
+
console.warn("Kid node has no host, cannot remove.");
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
const e = t?.host, i = e?.host;
|
|
897
|
+
if (this.removeKid(t), t.type === "tabset" && e.kids.size() === 1) {
|
|
898
|
+
const n = e.kids.peek();
|
|
899
|
+
n && this.moveAdjacentNodeToGrandParent(n);
|
|
900
|
+
} else if (t.type === "tab" && e.kids.size() === 0 && i.kids.size() === 2) {
|
|
901
|
+
this.removeKid(e);
|
|
902
|
+
const n = i?.kids.peek();
|
|
903
|
+
n && this.moveAdjacentNodeToGrandParent(n);
|
|
904
|
+
} else if (t.type === "tab" && e.kids.size() === 0 && i.kids.size() > 2)
|
|
905
|
+
this.removeKid(e);
|
|
906
|
+
else if (t.type === "tab" && e.open === t.name && e.kids.size() > 0) {
|
|
907
|
+
const n = e.kids.peek();
|
|
908
|
+
n && (e.open = n.name);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
removeKid(t) {
|
|
912
|
+
if (!t.host) {
|
|
913
|
+
console.warn("Kid node has no host, cannot remove.");
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
const e = t.host, i = e.kids.indexOf(t), n = e.kids.get(i + 1), s = e.kids.get(i - 1), d = t.next, o = t.prev;
|
|
917
|
+
if (i === -1) {
|
|
918
|
+
console.warn("Kid node not found in its host's kids.");
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
d && (a.cache.mapElem.delete(d.unId), a.cache.nodOpts.get().delete(d.unId)), o && (a.cache.mapElem.delete(o.unId), a.cache.nodOpts.get().delete(o.unId)), n && s ? n.addBond(e, s) : n ? n.prev = null : s && (s.next = null), e.kids.removeAt(i), a.cache.mapElem.delete(t.unId), a.cache.dimMins.delete(t.unId), a.cache.mapDirs.delete(t.unId), a.cache.tabCnts.delete(t.unId), t.type === "tabset" && a.cache.mapElem.delete(t.unId), t.type === "tab" && a.cache.mapElem.delete(t.unId), t.host = null, t.next = null, t.prev = null;
|
|
922
|
+
}
|
|
923
|
+
clearAllCache() {
|
|
924
|
+
a.cache.dimMins.clear(), a.cache.mapDirs.clear(), a.cache.tabCnts.clear(), a.cache.mapElem.clear(), a.cache.nodOpts.get().clear(), a.cache.bndOpts.get().clear();
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
class x {
|
|
928
|
+
dims = { w: 0, h: 0, x: 0, y: 0 };
|
|
929
|
+
unId = crypto.randomUUID();
|
|
930
|
+
next = null;
|
|
931
|
+
prev = null;
|
|
932
|
+
host = null;
|
|
933
|
+
constructor(t = null, e = null, i = null) {
|
|
934
|
+
this.host = t, this.next = e, this.prev = i, this.next && (this.next.prev = this), this.prev && (this.prev.next = this);
|
|
935
|
+
}
|
|
936
|
+
toJSON() {
|
|
937
|
+
return {
|
|
938
|
+
nodName: this.host?.name || "",
|
|
939
|
+
typNode: "bond",
|
|
940
|
+
uidNode: this.unId,
|
|
941
|
+
nodPart: 0,
|
|
942
|
+
nodOpen: "",
|
|
943
|
+
nodKids: []
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
(() => {
|
|
948
|
+
if (typeof window > "u") return;
|
|
949
|
+
const I = "color: #03A9F4; font-weight: bold; line-height: 1.2;", t = "color: #E0E0E0; font-size: 12px;", e = "color: #42a5f5; font-size: 12px;", i = "color: #9E9E9E; font-size: 10px;", n = `
|
|
950
|
+
██████╗ ██╗ ██╗ ███╗ ██╗ █████╗ ███╗ ███╗ ██████╗ ██╗ ██╗
|
|
951
|
+
██╔══██╗╚██╗ ██╔╝ ████╗ ██║ ██╔══██╗ ████╗ ████║ ╚═██╔═╝ ╚██╗██╔╝
|
|
952
|
+
██║ ██║ ╚████╔╝ ██╔██╗ ██║ ███████║ ██╔████╔██║ ██║ ╚███╔╝
|
|
953
|
+
██║ ██║ ╚██╔╝ ██║╚██╗██║ ██╔══██║ ██║╚██╔╝██║ ██║ ██╔██╗
|
|
954
|
+
██████╔╝ ██║ ██║ ╚████║ ██║ ██║ ██║ ╚═╝ ██║ ██████╗ ██╔╝ ██╗
|
|
955
|
+
╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝
|
|
956
|
+
██╗ █████╗ ██╗ ██╗ ██████╗ ██╗ ██╗████████╗
|
|
957
|
+
██║ ██╔══██╗ ╚██╗ ██╔╝ ██╔═══██╗ ██║ ██║╚══██╔══╝
|
|
958
|
+
██║ ███████║ ╚████╔╝ ██║ ██║ ██║ ██║ ██║
|
|
959
|
+
██║ ██╔══██║ ╚██╔╝ ██║ ██║ ██║ ██║ ██║
|
|
960
|
+
███████╗ ██║ ██║ ██║ ╚██████╔╝ ╚█████╔╝ ██║
|
|
961
|
+
╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚════╝ ╚═╝
|
|
962
|
+
`;
|
|
963
|
+
console.groupCollapsed(
|
|
964
|
+
"%cDYNAMIX LAYOUT (click to expand)",
|
|
965
|
+
"color: #03A9F4; font-weight: bold; font-size: 14px;"
|
|
966
|
+
), console.log(`%c${n}`, I), console.log("%c A powerful, dynamic layout system 🚀", t), console.log(
|
|
967
|
+
`%c ⚡ For docs and more info,
|
|
968
|
+
⚡ visit: https://github.com/akash-aman/dynamix-layout`,
|
|
969
|
+
e
|
|
970
|
+
), console.log(`%cMIT License
|
|
971
|
+
|
|
972
|
+
Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
|
|
973
|
+
|
|
974
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
975
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
976
|
+
in the Software without restriction, including without limitation the rights
|
|
977
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
978
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
979
|
+
furnished to do so, subject to the following conditions:
|
|
980
|
+
|
|
981
|
+
The above copyright notice and this permission notice shall be included in all
|
|
982
|
+
copies or substantial portions of the Software.
|
|
983
|
+
|
|
984
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
985
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
986
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
987
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
988
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
989
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
990
|
+
SOFTWARE.
|
|
991
|
+
`, i), console.groupEnd(), typeof window < "u" && (window.__DYNAMIX_LAYOUT__ = {
|
|
992
|
+
__LICENSE__: `MIT License
|
|
993
|
+
|
|
994
|
+
Copyright (c) 2025 Akash Aman <sir.akashaman@gmail.com> (https://akash.cx)
|
|
995
|
+
|
|
996
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
997
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
998
|
+
in the Software without restriction, including without limitation the rights
|
|
999
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1000
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1001
|
+
furnished to do so, subject to the following conditions:
|
|
1002
|
+
|
|
1003
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1004
|
+
copies or substantial portions of the Software.
|
|
1005
|
+
|
|
1006
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1007
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1008
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1009
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1010
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1011
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1012
|
+
SOFTWARE.
|
|
1013
|
+
`,
|
|
1014
|
+
__LAYOUT__: c
|
|
1015
|
+
});
|
|
1016
|
+
})();
|
|
1017
|
+
export {
|
|
1018
|
+
x as Bond,
|
|
1019
|
+
c as DynamixLayoutCore,
|
|
1020
|
+
a as Node,
|
|
1021
|
+
N as Queue,
|
|
1022
|
+
O as areNodeOptionsEqual,
|
|
1023
|
+
E as areNodeOptionsMapEqual,
|
|
1024
|
+
g as createReactiveState
|
|
1025
|
+
};
|