@aiquants/resize-panels 2.1.0 → 2.3.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.
@@ -1,1332 +0,0 @@
1
- import { createContext as Kn, useContext as Yn, useCallback as F, useMemo as N, useReducer as qn, useState as Ee, useRef as B, useLayoutEffect as Se, useEffect as J, memo as Je, useId as Rn, Suspense as Xn, lazy as Zn } from "react";
2
- import { jsxs as pe, jsx as ie } from "react/jsx-runtime";
3
- import { twMerge as Le } from "tailwind-merge";
4
- import { flushSync as Jn } from "react-dom";
5
- const Qn = 12, _ = 1e-6, et = 8, nt = 6, tt = 48, rt = 80, ot = 2, it = 32, st = 64, at = 8, lt = 8, gn = 10, In = 0.05, vn = 10, ct = 0.05, dt = 20, ut = 0.05, pt = (e, n = 0) => {
6
- if (!Number.isFinite(e))
7
- return e;
8
- const t = 10 ** n, r = e * t, o = Math.floor(r), i = r - o, s = Number.EPSILON * Math.max(1, Math.abs(r));
9
- return i < 0.5 - s ? o / t : i > 0.5 + s ? (o + 1) / t : (o % 2 === 0 ? o : o + 1) / t;
10
- }, ft = 6, _n = (e, n) => n <= 0 ? 0 : pt(e / n * 100, ft), lr = (e, n) => n <= 0 ? 0 : e / 100 * n, ht = (e, n = "percentage") => {
11
- if (e !== void 0)
12
- return typeof e == "number" ? { value: e, unit: n } : e;
13
- }, xn = (e, n, t) => e === void 0 ? n : typeof e == "number" ? e / 100 * t : e.unit === "pixels" ? e.value : e.value / 100 * t, Fe = (e, n, t) => Math.min(Math.max(e, n), t), Ln = (e) => !Number.isFinite(e) || e <= 0 ? 0 : Math.max(0, Math.min(Qn, vn, e * In)), ge = (e) => {
14
- if (!e)
15
- return 0;
16
- const n = Number.parseFloat(e);
17
- return Number.isFinite(n) ? n : 0;
18
- }, Ae = (e, n, t) => {
19
- const r = n === "horizontal", o = typeof window < "u" ? window.getComputedStyle(e) : null, i = o ? r ? ge(o.paddingLeft) + ge(o.paddingRight) : ge(o.paddingTop) + ge(o.paddingBottom) : 0, s = o ? r ? ge(o.borderLeftWidth) + ge(o.borderRightWidth) : ge(o.borderTopWidth) + ge(o.borderBottomWidth) : 0, a = t?.contentBoxSize?.[0], u = a ? r ? a.inlineSize : a.blockSize : void 0, d = r ? e.clientWidth : e.clientHeight, m = d > 0 ? Math.max(0, d - i) : Math.max(0, (r ? e.offsetWidth : e.offsetHeight) - i - s), c = u ?? m;
20
- return { content: Math.max(0, c), border: Math.max(0, c + i + s) };
21
- }, mt = "[data-panel-group-direction]", Ye = "[data-panel-id], [data-resize-handle-anchor]", gt = "[data-panel-id]", Te = (e) => e?.closest(mt) ?? null, An = (e) => Array.from(e.querySelectorAll(Ye)).filter((n) => {
22
- if (Te(n) !== e)
23
- return !1;
24
- const t = n.parentElement?.closest(gt);
25
- return !(t && e.contains(t));
26
- }), xt = (e) => {
27
- const n = (t) => {
28
- for (const r of Array.from(t))
29
- if (r instanceof Element && (r.matches(Ye) || r.querySelector(Ye) !== null))
30
- return !0;
31
- return !1;
32
- };
33
- return e.some((t) => n(t.addedNodes) || n(t.removedNodes));
34
- }, St = (e, n) => {
35
- if (typeof window > "u")
36
- return 1;
37
- const t = n === "horizontal", r = e.getBoundingClientRect(), o = t ? r.width : r.height, i = window.getComputedStyle(e), s = t ? i.width : i.height;
38
- if (!s.endsWith("px"))
39
- return 1;
40
- const a = Number.parseFloat(s);
41
- return o > 0 && Number.isFinite(a) && a > 0 ? o / a : 1;
42
- }, Sn = (e, n) => {
43
- try {
44
- localStorage.setItem(`panel-layout-${e}`, JSON.stringify(n));
45
- } catch (t) {
46
- console.warn("Failed to save panel layout:", t);
47
- }
48
- }, bt = (e) => {
49
- try {
50
- const n = localStorage.getItem(`panel-layout-${e}`);
51
- if (!n)
52
- return null;
53
- const t = JSON.parse(n);
54
- if (!Array.isArray(t))
55
- return null;
56
- const r = (o) => typeof o == "object" && o !== null && typeof o.id == "string" && Number.isFinite(o.size);
57
- return t.every(r) ? t : null;
58
- } catch (n) {
59
- return console.warn("Failed to load panel layout:", n), null;
60
- }
61
- }, qe = 0, Cn = 1, Be = (e) => Number.isFinite(e) && e > 0 ? e : 0, re = (e) => e.sizeUnit === "pixels", be = (e, n) => {
62
- const t = Math.max(0, Be(xn(e.minSize, 0, n))), r = Math.max(t, Be(xn(e.maxSize, n, n)));
63
- return { min: t, max: r };
64
- }, yt = (e, n) => {
65
- const t = e.map((o) => o.min), r = e.map(() => !1);
66
- for (; ; ) {
67
- let o = 0, i = 0, s = 0;
68
- for (let c = 0; c < e.length; c += 1) {
69
- if (r[c]) {
70
- i += t[c];
71
- continue;
72
- }
73
- s += 1, o += e[c].weight;
74
- }
75
- if (s === 0)
76
- return t;
77
- const a = n - i;
78
- if (o <= 0) {
79
- for (let c = 0; c < e.length; c += 1)
80
- r[c] || (t[c] = e[c].min);
81
- return t;
82
- }
83
- const u = Math.max(0, a / o);
84
- let d = 0;
85
- for (let c = 0; c < e.length; c += 1) {
86
- if (r[c])
87
- continue;
88
- const R = u * e[c].weight, f = Fe(R, e[c].min, e[c].max);
89
- t[c] = f, d += f - R;
90
- }
91
- let m = !1;
92
- for (let c = 0; c < e.length; c += 1) {
93
- if (r[c])
94
- continue;
95
- const R = u * e[c].weight;
96
- d > _ && t[c] > R + _ ? (r[c] = !0, t[c] = e[c].min, m = !0) : d < -_ && t[c] < R - _ && (r[c] = !0, t[c] = e[c].max, m = !0);
97
- }
98
- if (!m)
99
- return t;
100
- }
101
- }, zt = (e, n, t) => {
102
- const { min: r, max: o } = be(e, t);
103
- if (re(e))
104
- return {
105
- index: n,
106
- weight: 0,
107
- target: Fe(Be(e.preferredPixelSize), r, o),
108
- priority: e.pixelAdjustPriority ?? 0,
109
- tier: qe,
110
- min: r,
111
- max: o
112
- };
113
- const i = Be(e.preferredPercentageSize), s = e.flexAdjustPriority !== void 0;
114
- return {
115
- index: n,
116
- weight: i,
117
- target: s ? Fe(i / 100 * t, r, o) : null,
118
- priority: e.flexAdjustPriority ?? 0,
119
- tier: Cn,
120
- min: r,
121
- max: o
122
- };
123
- }, bn = (e, n, t, r) => {
124
- let o = r;
125
- for (const i of e) {
126
- if (o <= _)
127
- break;
128
- const s = t(i) - n[i.index];
129
- if (s <= 0)
130
- continue;
131
- const a = Math.min(s, o);
132
- n[i.index] += a, o -= a;
133
- }
134
- return o;
135
- }, Xe = (e, n, t) => {
136
- if (e.length === 0 || t <= _)
137
- return t;
138
- const r = e.map((s) => ({ ...s, min: n[s.index] })), o = yt(r, t + r.reduce((s, a) => s + a.min, 0));
139
- let i = 0;
140
- for (let s = 0; s < e.length; s += 1)
141
- i += o[s] - n[e[s].index], n[e[s].index] = o[s];
142
- return t - i;
143
- }, Pt = (e, n, t) => Xe(
144
- e.map((r) => ({ ...r, weight: 1 })),
145
- n,
146
- t
147
- ), Et = (e, n) => e.tier !== n.tier ? e.tier - n.tier : e.priority !== n.priority ? n.priority - e.priority : e.index - n.index, wt = (e, n) => {
148
- const t = e.map(() => 0);
149
- if (!Number.isFinite(n) || n <= 0 || e.length === 0)
150
- return { sizes: t, violation: null };
151
- const r = [];
152
- for (let f = 0; f < e.length; f += 1) {
153
- const k = e[f];
154
- k.collapsed || r.push(zt(k, f, n));
155
- }
156
- if (r.length === 0)
157
- return { sizes: t, violation: null };
158
- let o = 0, i = 0;
159
- for (const f of r)
160
- t[f.index] = f.min, o += f.min, i += f.max;
161
- const s = Nt(o, i, n);
162
- let a = n - o;
163
- if (a <= _)
164
- return { sizes: t, violation: s };
165
- const u = r.filter((f) => f.target !== null).sort(Et), d = r.filter((f) => f.target === null && f.weight > 0), m = r.filter((f) => f.tier !== qe && f.weight <= 0), c = u.filter((f) => f.tier === Cn), R = u.filter((f) => f.tier === qe);
166
- return a = bn(u, t, (f) => f.target ?? f.min, a), a = Xe(d, t, a), a = Xe(c, t, a), a = bn(R, t, (f) => f.max, a), a = Pt(m, t, a), { sizes: t, violation: s };
167
- }, Nt = (e, n, t) => e - t > _ ? {
168
- reason: "minimum-exceeded",
169
- totalMinimumSize: e,
170
- totalMaximumSize: n,
171
- availableContainerSize: t
172
- } : t - n > _ ? {
173
- reason: "maximum-insufficient",
174
- totalMinimumSize: e,
175
- totalMaximumSize: n,
176
- availableContainerSize: t
177
- } : null, Mn = Kn(null), Qe = () => {
178
- const e = Yn(Mn);
179
- if (!e)
180
- throw new Error("usePanelGroup must be used within a PanelGroup");
181
- return e;
182
- };
183
- var ke = /* @__PURE__ */ ((e) => (e[e.DEBUG = 0] = "DEBUG", e[e.INFO = 1] = "INFO", e[e.WARN = 2] = "WARN", e[e.ERROR = 3] = "ERROR", e[e.NONE = 4] = "NONE", e))(ke || {});
184
- const Z = class Z {
185
- /**
186
- * @constructor
187
- * @param {LogLevel} [level=LogLevel.WARN] - The minimum log level to output.
188
- * @param {string} [prefix="[resize-panels]"] - The prefix to add to all log messages.
189
- * @param {ILogger} [impl=console] - The implementation to use for logging.
190
- */
191
- constructor(n = 2, t = "[resize-panels]", r = console) {
192
- this.level = n, this.prefix = t, this.impl = r, Z.instances.add(this);
193
- }
194
- /**
195
- * @method setLevel
196
- * @description Updates the log level for every constructed logger (module-level loggers included).
197
- * @description 生成済みのすべてのロガー (モジュールレベルのロガーを含む) のログレベルを更新します。
198
- * @param {LogLevel} level - The new log level.
199
- */
200
- static setLevel(n) {
201
- for (const t of Z.instances)
202
- t.setLevel(n);
203
- }
204
- /**
205
- * @method setLevel
206
- * @description Updates the current log level.
207
- * @description 現在のログレベルを更新します。
208
- * @param {LogLevel} level - The new log level.
209
- */
210
- setLevel(n) {
211
- this.level = n;
212
- }
213
- /**
214
- * @method setImplementation
215
- * @description Updates the logger implementation for every constructed logger.
216
- * @description 生成済みのすべてのロガーの実装を更新します。
217
- * @param {ILogger} impl - The new logger implementation.
218
- */
219
- static setImplementation(n) {
220
- for (const t of Z.instances)
221
- t.setImplementation(n);
222
- }
223
- /**
224
- * @method setImplementation
225
- * @description Updates the logger implementation.
226
- * @description ロガーの実装を更新します。
227
- * @param {ILogger} impl - The new logger implementation.
228
- */
229
- setImplementation(n) {
230
- this.impl = n;
231
- }
232
- /**
233
- * @method setPrefix
234
- * @description Updates the log prefix for every constructed logger.
235
- * @description 生成済みのすべてのロガーのログのプレフィックスを更新します。
236
- * @param {string} prefix - The new prefix.
237
- */
238
- static setPrefix(n) {
239
- for (const t of Z.instances)
240
- t.setPrefix(n);
241
- }
242
- /**
243
- * @method setPrefix
244
- * @description Updates the log prefix.
245
- * @description ログのプレフィックスを更新します。
246
- * @param {string} prefix - The new prefix.
247
- */
248
- setPrefix(n) {
249
- this.prefix = n;
250
- }
251
- /**
252
- * @method enabledFor
253
- * @description Returns whether messages at the given level would be emitted.
254
- * @description 指定レベルのメッセージが出力対象かどうかを返します。
255
- * 高コストなログ引数 (スナップショット等) の組み立てを抑制中に省略するために使用します。
256
- * @param {LogLevel} level - The message level to test.
257
- */
258
- enabledFor(n) {
259
- return this.level <= n;
260
- }
261
- formatMessage(n) {
262
- return typeof n == "string" ? [`${this.prefix} ${n}`] : [this.prefix, n];
263
- }
264
- static debug(n, ...t) {
265
- Z.instance.debug(n, ...t);
266
- }
267
- debug(n, ...t) {
268
- this.level <= 0 && this.impl.debug(...this.formatMessage(n), ...t);
269
- }
270
- static info(n, ...t) {
271
- Z.instance.info(n, ...t);
272
- }
273
- info(n, ...t) {
274
- this.level <= 1 && this.impl.info(...this.formatMessage(n), ...t);
275
- }
276
- static warn(n, ...t) {
277
- Z.instance.warn(n, ...t);
278
- }
279
- warn(n, ...t) {
280
- this.level <= 2 && this.impl.warn(...this.formatMessage(n), ...t);
281
- }
282
- static error(n, ...t) {
283
- Z.instance.error(n, ...t);
284
- }
285
- error(n, ...t) {
286
- this.level <= 3 && this.impl.error(...this.formatMessage(n), ...t);
287
- }
288
- };
289
- Z.instances = /* @__PURE__ */ new Set(), Z.instance = new Z(2, "[resize-panels]");
290
- let Ce = Z;
291
- const Dn = new Ce(ke.INFO, "[resize-panels]"), Rt = {
292
- containerSize: 0,
293
- panels: [],
294
- violation: null
295
- }, yn = (e, n) => e === null || n === null ? e === n : e.reason === n.reason && Math.abs(e.totalMinimumSize - n.totalMinimumSize) <= _ && Math.abs(e.totalMaximumSize - n.totalMaximumSize) <= _ && Math.abs(e.availableContainerSize - n.availableContainerSize) <= _, de = (e, n) => {
296
- const { sizes: t, violation: r } = wt(e, n);
297
- let o = !1;
298
- const i = e.map((a, u) => {
299
- const d = a.collapsed ? 0 : t[u];
300
- return Math.abs(a.size - d) <= _ ? a : (o = !0, { ...a, size: d });
301
- }), s = { containerSize: n, panels: o ? i : e, violation: r };
302
- return vt(s), s;
303
- }, It = (e) => {
304
- if (e.containerSize <= 0 || e.violation !== null)
305
- return null;
306
- let n = 0, t = 0;
307
- for (const o of e.panels)
308
- o.collapsed || (n += o.size, t += 1);
309
- if (t === 0)
310
- return null;
311
- const r = _ * Math.max(1, e.containerSize);
312
- return !Number.isFinite(n) || Math.abs(n - e.containerSize) > r ? { allocatedTotal: n, containerSize: e.containerSize } : null;
313
- }, vt = (e) => {
314
- const n = It(e);
315
- n && Dn.error("Allocated sizes do not fill the container.", {
316
- ...n,
317
- panels: e.panels.map((t) => ({ id: t.id, size: t.size, collapsed: t.collapsed }))
318
- });
319
- }, ue = (e, n) => e.panels === n.panels && e.containerSize === n.containerSize && yn(e.violation, n.violation) ? e : {
320
- containerSize: n.containerSize,
321
- panels: n.panels,
322
- violation: yn(e.violation, n.violation) ? e.violation : n.violation
323
- }, _t = (e, n) => {
324
- const t = e.sizeUnit === "pixels" ? e.preferredPixelSize : e.preferredPercentageSize;
325
- return {
326
- ...e,
327
- size: 0,
328
- collapsed: e.collapsed,
329
- collapsedByDirection: e.collapsed ? n : null,
330
- preferenceBeforeCollapse: t,
331
- authoredPreference: t
332
- };
333
- }, Ve = (e) => e.collapseFromStart ? "start" : e.collapseFromEnd ? "end" : null, Lt = (e, n) => {
334
- if (n <= 0)
335
- return e;
336
- const t = Ln(n);
337
- return e.map((r) => {
338
- if (r.collapsed)
339
- return r;
340
- const o = re(r) ? r.size : r.size / n * 100, i = re(r) ? r.preferredPixelSize : r.preferredPercentageSize, s = r.size > t ? o : r.preferenceBeforeCollapse;
341
- return i === o && s === r.preferenceBeforeCollapse ? r : re(r) ? { ...r, preferredPixelSize: o, preferenceBeforeCollapse: s } : { ...r, preferredPercentageSize: o, preferenceBeforeCollapse: s };
342
- });
343
- }, Ze = (e, n, t) => {
344
- if (re(e)) {
345
- const o = Math.max(0, n);
346
- return { ...e, preferredPixelSize: o, preferenceBeforeCollapse: o };
347
- }
348
- if (t <= 0)
349
- return e;
350
- const r = Math.max(0, n / t * 100);
351
- return { ...e, preferredPercentageSize: r, preferenceBeforeCollapse: r };
352
- }, At = (e, n) => {
353
- const t = e.collapsed ? e.preferenceBeforeCollapse : re(e) ? e.preferredPixelSize : e.preferredPercentageSize;
354
- return re(e) ? t : t / 100 * n;
355
- }, Ct = (e, n, t, r) => {
356
- const o = Math.max(0, Math.min(t, r)), i = e.filter((d) => d.id !== n && !d.collapsed && !re(d)), s = e.reduce((d, m) => m.id !== n && !m.collapsed && re(m) ? d + m.size : d, 0), a = i.reduce((d, m) => d + m.size, 0), u = Math.max(0, r - o - s);
357
- return e.map((d) => {
358
- if (d.id === n)
359
- return Ze(d, o, r);
360
- if (d.collapsed || re(d) || i.length === 0)
361
- return d;
362
- const m = a > 0 ? d.size / a * u : u / i.length;
363
- return Ze(d, m, r);
364
- });
365
- }, Mt = (e, n) => {
366
- switch (n.type) {
367
- case "SET_CONTAINER_SIZE":
368
- return !Number.isFinite(n.containerSize) || n.containerSize < 0 || n.containerSize === e.containerSize ? e : ue(e, de(e.panels, n.containerSize));
369
- case "REGISTER_PANEL": {
370
- const t = e.panels.findIndex((c) => c.id === n.panel.id);
371
- if (t === -1) {
372
- const c = [...e.panels, _t(n.panel, Ve(n.panel))];
373
- return ue(e, de(c, e.containerSize));
374
- }
375
- const r = e.panels[t], o = n.panel.sizeUnit === "pixels" ? n.panel.preferredPixelSize : n.panel.preferredPercentageSize, i = o !== r.authoredPreference || n.panel.sizeUnit !== r.sizeUnit, s = r.collapsedByDirection === "start" ? n.panel.collapseFromStart : r.collapsedByDirection === "end" ? n.panel.collapseFromEnd : !1, a = n.panel.collapseFromStart || n.panel.collapseFromEnd, u = r.collapsed && a, d = {
376
- ...r,
377
- ...n.panel,
378
- collapsed: u,
379
- collapsedByDirection: u ? s ? r.collapsedByDirection : Ve(n.panel) : null,
380
- preferredPercentageSize: i ? n.panel.preferredPercentageSize : r.preferredPercentageSize,
381
- preferredPixelSize: i ? n.panel.preferredPixelSize : r.preferredPixelSize,
382
- preferenceBeforeCollapse: i ? o : r.preferenceBeforeCollapse,
383
- authoredPreference: o
384
- }, m = [...e.panels];
385
- return m[t] = d, ue(e, de(m, e.containerSize));
386
- }
387
- case "UNREGISTER_PANEL": {
388
- const t = e.panels.filter((r) => r.id !== n.id);
389
- return t.length === e.panels.length ? e : ue(e, de(t, e.containerSize));
390
- }
391
- case "REORDER_PANELS": {
392
- if (n.ids.length !== e.panels.length || new Set(n.ids).size !== n.ids.length)
393
- return e;
394
- const t = new Map(e.panels.map((o) => [o.id, o])), r = [];
395
- for (const o of n.ids) {
396
- const i = t.get(o);
397
- if (!i)
398
- return e;
399
- r.push(i);
400
- }
401
- return r.every((o, i) => o === e.panels[i]) ? e : ue(e, de(r, e.containerSize));
402
- }
403
- case "RESIZE_PANELS": {
404
- const t = e.panels.findIndex((k) => k.id === n.startId), r = e.panels.findIndex((k) => k.id === n.endId);
405
- if (t === -1 || r === -1)
406
- return e;
407
- const o = e.panels[t], i = e.panels[r];
408
- if (o.collapsed || i.collapsed || e.containerSize <= 0 || !Number.isFinite(n.startSize))
409
- return e;
410
- const s = o.size + i.size, a = be(o, e.containerSize), u = be(i, e.containerSize), d = Math.max(a.min, s - u.max), m = Math.min(a.max, s - u.min);
411
- if (d - m > _)
412
- return e;
413
- const c = Fe(n.startSize, d, Math.max(d, m)), R = s - c;
414
- if (Math.abs(c - o.size) <= _)
415
- return e;
416
- const f = [...e.panels];
417
- return f[t] = { ...o, size: c }, f[r] = { ...i, size: R }, ue(e, de(Lt(f, e.containerSize), e.containerSize));
418
- }
419
- case "COLLAPSE_PANEL": {
420
- const t = e.panels.findIndex((s) => s.id === n.id);
421
- if (t === -1)
422
- return e;
423
- const r = e.panels[t];
424
- if (!(n.from === "start" ? r.collapseFromStart : r.collapseFromEnd) || r.collapsed)
425
- return e;
426
- const i = [...e.panels];
427
- return i[t] = {
428
- ...r,
429
- collapsed: !0,
430
- collapsedByDirection: n.from
431
- }, ue(e, de(i, e.containerSize));
432
- }
433
- case "EXPAND_PANEL": {
434
- const t = e.panels.findIndex((u) => u.id === n.id);
435
- if (t === -1 || n.targetSize !== void 0 && e.containerSize <= 0)
436
- return e;
437
- const r = e.panels[t];
438
- if (!((n.from === "start" ? r.collapseFromStart : r.collapseFromEnd) && r.collapsed) || r.collapsedByDirection !== null && r.collapsedByDirection !== n.from)
439
- return e;
440
- const i = {
441
- ...r,
442
- collapsed: !1,
443
- collapsedByDirection: null,
444
- preferredPixelSize: re(r) ? r.preferenceBeforeCollapse : r.preferredPixelSize,
445
- preferredPercentageSize: re(r) ? r.preferredPercentageSize : r.preferenceBeforeCollapse
446
- }, s = [...e.panels];
447
- s[t] = i;
448
- const a = n.targetSize === void 0 ? s : Ct(s, n.id, n.targetSize, e.containerSize);
449
- return ue(e, de(a, e.containerSize));
450
- }
451
- case "RESTORE_LAYOUT": {
452
- if (n.entries.length !== e.panels.length || e.containerSize <= 0)
453
- return e;
454
- const t = new Map(n.entries.map((o) => [o.id, o]));
455
- if (e.panels.some((o) => !t.has(o.id)))
456
- return e;
457
- const r = e.panels.map((o) => {
458
- const i = t.get(o.id);
459
- if (!i)
460
- return o;
461
- const s = Ze(o, i.size, e.containerSize), a = o.collapseFromStart || o.collapseFromEnd;
462
- return i.collapsed && a ? { ...s, collapsed: !0, collapsedByDirection: o.collapsedByDirection ?? Ve(o) } : s.collapsed ? { ...s, collapsed: !1, collapsedByDirection: null } : s;
463
- });
464
- return Dn.debug("restore layout", { containerSize: e.containerSize, entries: n.entries }), ue(e, de(r, e.containerSize));
465
- }
466
- default:
467
- return e;
468
- }
469
- }, Dt = {
470
- layout: Rt,
471
- source: null
472
- }, Ot = (e) => {
473
- switch (e.type) {
474
- case "SET_CONTAINER_SIZE":
475
- return "container";
476
- case "REGISTER_PANEL":
477
- case "UNREGISTER_PANEL":
478
- case "REORDER_PANELS":
479
- return "panels";
480
- case "RESTORE_LAYOUT":
481
- return "restore";
482
- case "RESIZE_PANELS":
483
- case "COLLAPSE_PANEL":
484
- case "EXPAND_PANEL":
485
- return e.source;
486
- }
487
- }, Tt = (e, n) => {
488
- const t = Mt(e.layout, n);
489
- if (t === e.layout)
490
- return e;
491
- const r = t.panels !== e.layout.panels || t.containerSize > 0 != e.layout.containerSize > 0;
492
- return { layout: t, source: r ? Ot(n) : e.source };
493
- }, Ft = new Ce(ke.INFO, "[resize-panels]"), Bt = { pointer: !0, keyboard: !0, api: !0 }, kt = (e) => typeof e == "string" && Object.hasOwn(Bt, e), Ke = (e) => {
494
- if (!kt(e))
495
- throw new RangeError(`[resize-panels] A request source must be "pointer", "keyboard" or "api"; received ${typeof e == "string" ? JSON.stringify(e) : String(e)}.`);
496
- return e;
497
- }, Ht = 200, $t = "\0handle", Gt = ({ direction: e, style: n, onLayout: t, autoSaveId: r, showDebugInfo: o = !1 }) => {
498
- const [{ layout: i, source: s }, a] = qn(Tt, Dt), [u, d] = Ee({}), [m, c] = Ee({}), R = B(null), [f, k] = Ee(""), V = B({}), ae = B(t);
499
- ae.current = t, Se(() => {
500
- const l = R.current;
501
- if (!l || typeof ResizeObserver > "u")
502
- return;
503
- let p = Number.NaN;
504
- const g = (L) => {
505
- L !== p && (p = L, a({ type: "SET_CONTAINER_SIZE", containerSize: L }));
506
- }, y = new ResizeObserver((L) => {
507
- g(Ae(l, e, L[0]).content);
508
- });
509
- return y.observe(l), g(Ae(l, e).content), () => {
510
- y.disconnect(), a({ type: "SET_CONTAINER_SIZE", containerSize: 0 });
511
- };
512
- }, [e]);
513
- const b = i.panels, U = B(b);
514
- U.current = b;
515
- const S = F(() => {
516
- const l = R.current, p = U.current;
517
- if (!l)
518
- return;
519
- const g = An(l);
520
- if (k((L) => {
521
- const q = g.map((le) => le.dataset.panelId ?? $t).join("\0");
522
- return L === q ? L : q;
523
- }), p.length === 0)
524
- return;
525
- const y = [];
526
- for (const L of g) {
527
- const q = L.dataset.panelId;
528
- q !== void 0 && y.push(q);
529
- }
530
- if (new Set(y).size !== y.length) {
531
- Ft.error("Duplicate panel id in one group.", { ids: y });
532
- return;
533
- }
534
- y.length !== p.length || y.every((L, q) => L === p[q].id) || a({ type: "REORDER_PANELS", ids: y });
535
- }, []);
536
- Se(() => {
537
- const l = R.current;
538
- if (!l || (S(), typeof MutationObserver > "u"))
539
- return;
540
- const p = new MutationObserver((g) => {
541
- xt(g) && S();
542
- });
543
- return p.observe(l, { childList: !0, subtree: !0 }), () => {
544
- p.disconnect();
545
- };
546
- }, [S]), Se(() => {
547
- S();
548
- }, [S, b]);
549
- const H = N(() => b.map((l) => l.size), [b]), z = i.containerSize > 0;
550
- Se(() => {
551
- !z || H.length === 0 || s === null || ae.current?.(H, { source: s });
552
- }, [H, z, s]);
553
- const K = B(null);
554
- J(() => {
555
- if (!r || K.current === r || !z || b.length === 0)
556
- return;
557
- K.current = r;
558
- const l = bt(r);
559
- l && a({ type: "RESTORE_LAYOUT", entries: l });
560
- }, [r, z, b.length]);
561
- const E = B(null);
562
- J(() => {
563
- if (!(r && K.current === r && z) || b.length === 0)
564
- return;
565
- const l = b.map((g) => ({ id: g.id, size: At(g, i.containerSize), collapsed: g.collapsed }));
566
- E.current = { id: r, entries: l };
567
- const p = setTimeout(() => {
568
- E.current = null, Sn(r, l);
569
- }, Ht);
570
- return () => {
571
- clearTimeout(p);
572
- };
573
- }, [r, b, i.containerSize, z]), J(() => () => {
574
- const l = E.current;
575
- l && (E.current = null, Sn(l.id, l.entries));
576
- }, []);
577
- const A = F((l) => {
578
- const p = JSON.stringify(l);
579
- V.current[l.id] !== p && (V.current[l.id] = p, a({ type: "REGISTER_PANEL", panel: l }));
580
- }, []), v = F((l) => {
581
- delete V.current[l], a({ type: "UNREGISTER_PANEL", id: l }), d((p) => {
582
- if (!(l in p))
583
- return p;
584
- const g = { ...p };
585
- return delete g[l], g;
586
- });
587
- }, []), Q = F((l, p, g, y = "api") => {
588
- a({ type: "RESIZE_PANELS", startId: l, endId: p, startSize: g, source: Ke(y) });
589
- }, []), C = F((l, p, g = "api") => {
590
- a({ type: "COLLAPSE_PANEL", id: l, from: p, source: Ke(g) });
591
- }, []), P = F((l, p, g, y = "api") => {
592
- a({ type: "EXPAND_PANEL", id: l, from: p, targetSize: g, source: Ke(y) });
593
- }, []), x = F((l) => b.find((p) => p.id === l), [b]), W = F((l, p) => {
594
- d((g) => {
595
- if (p === null) {
596
- if (!(l in g))
597
- return g;
598
- const L = { ...g };
599
- return delete L[l], L;
600
- }
601
- const y = g[l];
602
- return y && y.pixelSize === p.pixelSize && y.percentageSize === p.percentageSize ? g : { ...g, [l]: p };
603
- });
604
- }, []), O = F((l, p) => {
605
- c((g) => {
606
- if (p === null) {
607
- if (!(l in g))
608
- return g;
609
- const L = { ...g };
610
- return delete L[l], L;
611
- }
612
- const y = g[l];
613
- return y && y.thickness === p.thickness && y.visible === p.visible && y.direction === p.direction && y.startPanelId === p.startPanelId && y.endPanelId === p.endPanelId ? g : { ...g, [l]: p };
614
- });
615
- }, []), Y = N(
616
- () => ({
617
- direction: e,
618
- panels: b,
619
- containerSize: i.containerSize,
620
- layoutOrderKey: f,
621
- showDebugInfo: o,
622
- registerPanel: A,
623
- unregisterPanel: v,
624
- resizePanels: Q,
625
- collapsePanel: C,
626
- expandPanel: P,
627
- getPanel: x,
628
- reportPanelMeasurement: W,
629
- panelMeasurements: u,
630
- reportHandleMeasurement: O,
631
- handleMeasurements: m,
632
- layoutConstraintViolation: i.violation
633
- }),
634
- [e, b, i.containerSize, f, i.violation, o, A, v, Q, C, P, x, W, u, O, m]
635
- ), fe = N(
636
- () => ({
637
- // 見た目に関わる既定値は利用者が上書きできる
638
- width: "100%",
639
- height: "100%",
640
- minWidth: "0px",
641
- minHeight: "0px",
642
- // ハンドルは境界をまたいで描かれるため、その張り出しでスクロールバーを出さない
643
- overflow: "hidden",
644
- ...n,
645
- // ここから下はレイアウトの前提そのもの。利用者のスタイルやクラスで変わると
646
- // 配分結果と描画が一致しなくなるため、最後に適用して上書きを受け付けない:
647
- // gap はパネルの合計に含まれない隙間を作り、flex-direction の反転は DOM 順と視覚順をずらし、
648
- // writing-mode は主軸の向きそのものを変えてしまう
649
- display: "flex",
650
- flexDirection: e === "horizontal" ? "row" : "column",
651
- alignItems: "stretch",
652
- gap: "0px",
653
- position: "relative",
654
- boxSizing: "border-box",
655
- writingMode: "horizontal-tb"
656
- }),
657
- [e, n]
658
- );
659
- return { groupRef: R, contextValue: Y, groupStyle: fe };
660
- }, cr = (e) => {
661
- const { getPanel: n, collapsePanel: t, expandPanel: r } = Qe(), o = n(e), i = F(
662
- (u) => {
663
- t(e, u, "api");
664
- },
665
- [t, e]
666
- ), s = F(
667
- (u, d) => {
668
- r(e, u, d, "api");
669
- },
670
- [r, e]
671
- ), a = F(
672
- (u, d) => {
673
- o?.collapsed ? s(u, d) : i(u);
674
- },
675
- [o?.collapsed, i, s]
676
- );
677
- return N(
678
- () => ({
679
- panel: o,
680
- isCollapsed: o?.collapsed ?? !1,
681
- canCollapseFromStart: o?.collapseFromStart ?? !1,
682
- canCollapseFromEnd: o?.collapseFromEnd ?? !1,
683
- collapse: i,
684
- expand: s,
685
- toggle: a
686
- }),
687
- [o, i, s, a]
688
- );
689
- }, Ut = ({ panel: e, containerAxisSize: n, containerLabel: t }) => {
690
- if (!e)
691
- return { sizeDisplay: "-", preferenceDisplay: "-", boundsDisplay: "-", containerDisplay: "-", headlineLabel: "Unregistered", titleText: "Unregistered" };
692
- const r = e.sizeUnit === "pixels", o = `${e.size.toFixed(3)}px / ${_n(e.size, n).toFixed(3)}%`, i = r ? `${e.preferredPixelSize.toFixed(3)}px` : `${e.preferredPercentageSize.toFixed(3)}%`, s = be(e, n), a = `${s.min.toFixed(1)} - ${s.max.toFixed(1)}px`, u = Number.isFinite(n) ? `${n.toFixed(3)}px` : "-", d = r ? "Fixed" : "Flexible", m = [d, `${t}: ${u}`, `size: ${o}`, `preference: ${i}`, `bounds: ${a}`].join(`
693
- `);
694
- return { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: a, containerDisplay: u, headlineLabel: d, titleText: m };
695
- }, Wt = Je(({ panel: e, containerAxisSize: n, direction: t }) => {
696
- const r = t === "horizontal" ? "container width" : "container height", { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: s, containerDisplay: a, headlineLabel: u, titleText: d } = N(() => Ut({ panel: e, containerAxisSize: n, containerLabel: r }), [e, n, r]);
697
- return /* @__PURE__ */ pe("div", { style: {
698
- position: "absolute",
699
- top: 2,
700
- left: 2,
701
- zIndex: 30,
702
- pointerEvents: "none",
703
- maxWidth: "calc(100% - 4px)",
704
- padding: "2px 4px",
705
- borderRadius: 4,
706
- border: "1px solid rgba(255,255,255,0.1)",
707
- backgroundColor: "rgba(15, 23, 42, 0.78)",
708
- color: "#e2e8f0",
709
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
710
- fontSize: 10,
711
- lineHeight: 1.35,
712
- whiteSpace: "pre",
713
- overflow: "hidden",
714
- textOverflow: "ellipsis"
715
- }, title: d, "data-panel-debug-info": "", children: [
716
- /* @__PURE__ */ pe("div", { children: [
717
- u,
718
- " · ",
719
- r,
720
- ": ",
721
- a
722
- ] }),
723
- /* @__PURE__ */ pe("div", { children: [
724
- "size: ",
725
- o
726
- ] }),
727
- /* @__PURE__ */ pe("div", { children: [
728
- "preference: ",
729
- i
730
- ] }),
731
- /* @__PURE__ */ pe("div", { children: [
732
- "bounds: ",
733
- s
734
- ] })
735
- ] });
736
- }), zn = new Ce(ke.INFO, "[resize-panels]"), jt = {
737
- both: { collapseFromStart: !0, collapseFromEnd: !0 },
738
- start: { collapseFromStart: !0, collapseFromEnd: !1 },
739
- end: { collapseFromStart: !1, collapseFromEnd: !0 }
740
- }, Vt = (e) => {
741
- if (!e)
742
- return { collapseFromStart: !1, collapseFromEnd: !1 };
743
- const n = jt[e.from];
744
- if (!n)
745
- throw new Error("Invalid collapsible configuration: unsupported 'from' value");
746
- return n;
747
- }, Kt = (e) => {
748
- const n = Math.max(0, e.value);
749
- return e.unit === "pixels" ? { sizeUnit: "pixels", preferredPixelSize: n, preferredPercentageSize: 0 } : { sizeUnit: "percentage", preferredPercentageSize: n, preferredPixelSize: 0 };
750
- }, Yt = ({ size: e, panel: n, registration: t, containerSize: r, isCollapsed: o }) => {
751
- if (o)
752
- return { flexBasis: "0px", flexGrow: 0, flexShrink: 0 };
753
- if (!n || r <= 0) {
754
- const u = t.sizeUnit === "pixels";
755
- return {
756
- flexBasis: u ? `${t.preferredPixelSize}px` : `${t.preferredPercentageSize}%`,
757
- flexGrow: u ? 0 : t.preferredPercentageSize,
758
- flexShrink: u ? 0 : 1
759
- };
760
- }
761
- if (n.sizeUnit === "pixels")
762
- return { flexBasis: `${e}px`, flexGrow: 0, flexShrink: 0 };
763
- const i = be(n, r), s = e < i.max - _, a = s && e > i.min + _;
764
- return { flexBasis: `${e}px`, flexGrow: s ? n.preferredPercentageSize : 0, flexShrink: a ? 1 : 0 };
765
- }, dr = Je(
766
- ({ id: e, defaultSize: n = { value: 50, unit: "percentage" }, minSize: t, maxSize: r, className: o, style: i, children: s, collapsible: a, defaultCollapsed: u = !1, pixelAdjustPriority: d, flexAdjustPriority: m, contentOverflow: c = "auto", ...R }) => {
767
- const { direction: f, registerPanel: k, unregisterPanel: V, getPanel: ae, containerSize: b, showDebugInfo: U, reportPanelMeasurement: S } = Qe(), H = B(null), z = Rn(), E = B(e || `panel-${z}`).current;
768
- J(() => {
769
- e && e !== E && zn.warn("Panel id prop change after mount is ignored.", { currentId: E, attemptedId: e });
770
- }, [e, E]);
771
- const A = N(() => Vt(a), [a]), v = A.collapseFromStart || A.collapseFromEnd;
772
- J(() => {
773
- u && !v && zn.warn("Panel defaultCollapsed is ignored because collapsible configuration is not provided.", { panelId: E });
774
- }, [u, v, E]);
775
- const Q = N(() => {
776
- const l = ht(n) ?? { value: 50, unit: "percentage" };
777
- return {
778
- id: E,
779
- ...Kt(l),
780
- minSize: t,
781
- maxSize: r,
782
- ...A,
783
- collapsed: v && u,
784
- pixelAdjustPriority: d,
785
- flexAdjustPriority: m
786
- };
787
- }, [E, n, t, r, A, v, u, d, m]);
788
- Se(() => {
789
- k(Q);
790
- }, [k, Q]), Se(() => () => {
791
- V(E);
792
- }, [V, E]);
793
- const C = ae(E), P = C?.size ?? 0, x = C?.collapsed ?? !1, W = B(b);
794
- W.current = b;
795
- const O = F(() => {
796
- const l = H.current;
797
- if (!l)
798
- return;
799
- const p = Ae(l, f).border;
800
- S(E, { pixelSize: p, percentageSize: _n(p, W.current) });
801
- }, [f, E, S]);
802
- J(() => {
803
- if (!U) {
804
- S(E, null);
805
- return;
806
- }
807
- const l = H.current;
808
- if (!l || typeof ResizeObserver > "u") {
809
- O();
810
- return;
811
- }
812
- const p = new ResizeObserver(O);
813
- return p.observe(l), O(), () => {
814
- p.disconnect(), S(E, null);
815
- };
816
- }, [U, O, E, S]);
817
- const Y = N(() => {
818
- const l = { overflow: "hidden", isolation: "isolate" }, p = x ? { ...f === "horizontal" ? { width: "0px" } : { height: "0px" }, pointerEvents: "none", visibility: "hidden", display: "none" } : {};
819
- return {
820
- ...l,
821
- ...i,
822
- // ここから下はレイアウトの前提そのもの。利用者のスタイルやクラスで変わると配分結果と
823
- // 描画が一致しなくなるため、最後に適用して上書きを受け付けない:
824
- // flex の三つ組は配分器が決めた長さそのもの、margin はパネルの合計に含まれない隙間を作り、
825
- // order は DOM 順と視覚順をずらす
826
- ...Yt({ size: P, panel: C, registration: Q, containerSize: b, isCollapsed: x }),
827
- order: 0,
828
- margin: 0,
829
- // 内容を通常フローで内容ボックスいっぱいに伸ばすための入れ物 (パディングを効かせる唯一の形)
830
- display: "flex",
831
- flexDirection: "column",
832
- position: "relative",
833
- boxSizing: "border-box",
834
- // 主軸の縮小をコンテンツの固有幅に妨げられないようにし、
835
- // 上限側のクランプ (max-w-* のようなユーティリティクラスを含む) も受け付けない。
836
- // 配分器が配った長さより短く描くと、状態と描画が食い違ったままハンドルが動かなくなる
837
- minWidth: 0,
838
- minHeight: 0,
839
- maxWidth: "none",
840
- maxHeight: "none",
841
- ...f === "horizontal" ? { height: "100%" } : { width: "100%" },
842
- ...p
843
- };
844
- }, [P, f, x, C, Q, b, i]), fe = N(
845
- () => ({
846
- // 内容は通常フローの伸縮子として置く。絶対配置にするとパディングボックスを基準にしてしまい、
847
- // 利用者がパネルへ与えたパディングが何の効果も持たなくなる
848
- flex: "1 1 auto",
849
- position: "relative",
850
- overflow: c,
851
- display: "flex",
852
- flexDirection: "column",
853
- minWidth: "0px",
854
- minHeight: "0px"
855
- }),
856
- [c]
857
- );
858
- return /* @__PURE__ */ pe(
859
- "div",
860
- {
861
- ...R,
862
- ref: H,
863
- className: Le("panel", o),
864
- style: Y,
865
- "data-panel-id": E,
866
- "data-panel-size": P,
867
- "data-panel-size-unit": C?.sizeUnit ?? "percentage",
868
- "data-panel-collapsible": v,
869
- "data-panel-collapse-start": A.collapseFromStart,
870
- "data-panel-collapse-end": A.collapseFromEnd,
871
- "data-panel-collapsed": x,
872
- "aria-hidden": x,
873
- children: [
874
- /* @__PURE__ */ ie("div", { style: fe, children: s }),
875
- U && /* @__PURE__ */ ie(Wt, { panel: C, containerAxisSize: b, direction: f })
876
- ]
877
- }
878
- );
879
- }
880
- ), qt = Zn(() => import("./GlobalDebugOverlay-CIiVujEL.js").then((e) => ({ default: e.GlobalDebugOverlayGate }))), Xt = [], Zt = {};
881
- let Pn = 0;
882
- const Jt = () => (Pn += 1, `panel-group-${Pn}`), Qt = (e) => {
883
- const n = e.reason === "minimum-exceeded", t = n ? "Layout unavailable: minimum panel sizes exceed the container." : "Layout unavailable: panels cannot fill the container with their maximum sizes.", r = n ? `Min required: ${Math.ceil(e.totalMinimumSize)}px | Available: ${Math.floor(e.availableContainerSize)}px` : `Max total: ${Math.floor(e.totalMaximumSize)}px | Needed: ${Math.floor(e.availableContainerSize)}px`;
884
- return { summary: t, detail: r };
885
- }, er = (e, n) => e.map((t) => {
886
- const r = n[t.id];
887
- return r ? { ...t, measuredPixelSize: r.pixelSize, measuredPercentageSize: r.percentageSize } : t;
888
- }), En = (e, n, t) => {
889
- const r = Ae(e, "horizontal"), o = Ae(e, "vertical"), i = e.getBoundingClientRect(), s = r.content > 0 ? r.content : n ?? i.width, a = o.content > 0 ? o.content : t ?? i.height;
890
- return { width: s, height: a };
891
- }, ur = (e) => {
892
- const { id: n, className: t, style: r, children: o, direction: i, onLayout: s, autoSaveId: a, showDebugInfo: u, ...d } = e, { groupRef: m, contextValue: c, groupStyle: R } = Gt(e), [f, k] = Ee({ width: 0, height: 0 }), V = c.layoutConstraintViolation, ae = !!V, b = N(() => {
893
- if (!V)
894
- return null;
895
- const { summary: P, detail: x } = Qt(V);
896
- return /* @__PURE__ */ pe(
897
- "div",
898
- {
899
- className: "flex w-full flex-1 flex-col items-center justify-center gap-2 rounded-lg border border-slate-300 border-dashed bg-slate-100/70 px-6 py-8 text-center text-slate-600 text-sm dark:border-slate-600 dark:bg-slate-800/50 dark:text-slate-200",
900
- "data-panel-group-placeholder": "constraint-violation",
901
- children: [
902
- /* @__PURE__ */ ie("span", { children: P }),
903
- /* @__PURE__ */ ie("span", { className: "text-slate-500 text-xs dark:text-slate-400", children: x })
904
- ]
905
- }
906
- );
907
- }, [V]), U = B(null);
908
- U.current === null && (U.current = n ?? Jt());
909
- const S = U.current, H = n ?? S, z = c.showDebugInfo && c.panels.length > 0, K = z ? c.panels : Xt, E = z ? c.panelMeasurements : Zt, A = N(() => {
910
- if (!z)
911
- return [];
912
- const P = Object.values(c.handleMeasurements);
913
- return P.length <= 1 ? P : P.slice().sort((x, W) => x.id.localeCompare(W.id));
914
- }, [c.handleMeasurements, z]), v = f.width, Q = f.height;
915
- Se(() => {
916
- if (!z) {
917
- k({ width: 0, height: 0 });
918
- return;
919
- }
920
- if (typeof window > "u" || typeof ResizeObserver > "u")
921
- return;
922
- const P = m.current;
923
- if (!P)
924
- return;
925
- const x = (O) => {
926
- k((Y) => Y.width === O.width && Y.height === O.height ? Y : O);
927
- }, W = new ResizeObserver((O) => {
928
- for (const Y of O) {
929
- if (Y.target !== P)
930
- continue;
931
- const fe = En(P, Y.contentRect.width, Y.contentRect.height);
932
- x(fe);
933
- }
934
- });
935
- return W.observe(P), x(En(P)), () => {
936
- W.disconnect();
937
- };
938
- }, [m, z]);
939
- const C = N(() => er(K, E), [K, E]);
940
- return J(() => {
941
- if (!z)
942
- return;
943
- let P = !1, x = null;
944
- return import("./debugOverlayStore-D7FT6zPE.js").then((W) => {
945
- P || (x = W, W.enableDebugOverlayGroup(S));
946
- }), () => {
947
- P = !0, x && (x.disableDebugOverlayGroup(S), x.removeDebugOverlayGroup(S));
948
- };
949
- }, [z, S]), J(() => {
950
- if (!z)
951
- return;
952
- let P = !1;
953
- return import("./debugOverlayStore-D7FT6zPE.js").then((x) => {
954
- P || x.updateDebugOverlayGroup(S, {
955
- displayName: H,
956
- direction: i,
957
- containerSize: {
958
- width: v,
959
- height: Q
960
- },
961
- panels: C,
962
- handles: A
963
- });
964
- }), () => {
965
- P = !0;
966
- };
967
- }, [z, S, H, i, v, Q, C, A]), /* @__PURE__ */ pe(Mn.Provider, { value: c, children: [
968
- /* @__PURE__ */ pe("div", { ...d, ref: m, className: Le("panel-group", i === "horizontal" ? "flex-row" : "flex-col", t), style: R, "data-panel-group-id": n, "data-panel-group-direction": i, children: [
969
- o,
970
- ae && b ? /* @__PURE__ */ ie(
971
- "div",
972
- {
973
- className: "pointer-events-auto",
974
- style: {
975
- position: "absolute",
976
- inset: 0,
977
- // パネル内部要素 (VirtualScroll のスクロールバー z-50 等) を完全に隠蔽するため zIndex を 60 に設定
978
- zIndex: 60,
979
- display: "flex",
980
- flexDirection: "column",
981
- alignItems: "center",
982
- justifyContent: "center",
983
- backgroundColor: "rgba(248, 250, 252, 0.82)",
984
- backdropFilter: "blur(2px)"
985
- },
986
- children: b
987
- }
988
- ) : null
989
- ] }),
990
- z && /* @__PURE__ */ ie(Xn, { fallback: null, children: /* @__PURE__ */ ie(qt, { groupId: S }) })
991
- ] });
992
- }, nr = {
993
- display: "none",
994
- pointerEvents: "none",
995
- visibility: "hidden"
996
- }, tr = {
997
- display: "none"
998
- }, _e = (e, n) => typeof e != "number" || !Number.isFinite(e) || e <= 0 ? n : e, rr = (e) => {
999
- const n = Math.round(e);
1000
- return n % 2 === 0 ? n : n + 1;
1001
- }, wn = (e) => !e || typeof window > "u" ? !1 : window.getComputedStyle(e).direction === "rtl", Nn = (e, n, t) => {
1002
- const r = e.collapsed ? 0 : e.size, o = n.collapsed ? 0 : n.size, i = r + o;
1003
- if (i <= 0)
1004
- return;
1005
- const s = be(e, t), a = be(n, t), u = Math.max(s.min, i - a.max), d = Math.max(u, Math.min(s.max, i - a.min));
1006
- if (e.collapsed)
1007
- return { position: 0, lower: 0, upper: e.collapsedByDirection === "end" ? Math.max(0, d) : 0, resizeLower: u, resizeUpper: d };
1008
- if (n.collapsed) {
1009
- const R = n.collapsedByDirection === "start";
1010
- return { position: i, lower: R ? Math.min(i, u) : i, upper: i, resizeLower: u, resizeUpper: d };
1011
- }
1012
- const m = Math.min(r, e.collapseFromEnd ? 0 : u), c = Math.max(r, m, n.collapseFromStart ? i : d);
1013
- return { position: r, lower: m, upper: c, resizeLower: u, resizeUpper: d };
1014
- }, pr = Je((e) => {
1015
- const { id: n, disabled: t = !1, className: r, style: o, children: i, onDragging: s, thickness: a, indicator: u = !0, indicatorThickness: d, indicatorLength: m, indicatorBarThickness: c, indicatorBarLength: R, title: f, onPointerDown: k, onKeyDown: V, ...ae } = e, { direction: b, resizePanels: U, getPanel: S, collapsePanel: H, expandPanel: z, panels: K, layoutOrderKey: E, reportHandleMeasurement: A, containerSize: v, layoutConstraintViolation: Q } = Qe(), [C, P] = Ee(!1), [x, W] = Ee({ start: null, end: null }), O = B(null), Y = B(null), fe = B({ getPanel: S, containerSize: v });
1016
- fe.current = { getPanel: S, containerSize: v };
1017
- const l = B(""), p = B(""), g = B(null), y = B(null), L = Rn(), q = B(n ?? `resize-handle-${L}`), le = n ?? q.current, w = b === "horizontal", He = !!Q, ee = t || He, nn = F(() => {
1018
- const h = O.current, X = Te(h);
1019
- if (!(h && X))
1020
- return;
1021
- const T = An(X), M = T.indexOf(h);
1022
- let D = "", j = "";
1023
- for (let $ = M - 1; $ >= 0; $ -= 1) {
1024
- const I = T[$].dataset.panelId;
1025
- if (I !== void 0) {
1026
- D = I;
1027
- break;
1028
- }
1029
- }
1030
- for (let $ = M + 1; $ < T.length; $ += 1) {
1031
- const I = T[$].dataset.panelId;
1032
- if (I !== void 0) {
1033
- j = I;
1034
- break;
1035
- }
1036
- }
1037
- D === l.current && j === p.current || (l.current = D, p.current = j, W({ start: D || null, end: j || null }));
1038
- }, []);
1039
- J(() => {
1040
- nn();
1041
- }, [nn, E]), J(() => () => {
1042
- g.current?.();
1043
- }, []);
1044
- const tn = F(
1045
- (h) => {
1046
- if (ee || g.current || h.button !== 0)
1047
- return;
1048
- const X = S(l.current), T = S(p.current);
1049
- if (!(X && T))
1050
- return;
1051
- h.preventDefault(), h.stopPropagation();
1052
- const M = l.current, D = p.current, j = X.size, $ = X.size + T.size, I = w ? h.clientX : h.clientY, ne = Te(O.current), ze = w && wn(ne) ? -1 : 1, te = ne ? St(ne, b) : 1, xe = h.pointerId, Re = h.currentTarget;
1053
- Re.setPointerCapture?.(xe), P(!0), s?.(!0);
1054
- let an = 0, Ie = null;
1055
- const Vn = (G) => {
1056
- const Pe = ((w ? G.clientX : G.clientY) - I) * ze / te, ve = j + Pe, Ue = $ - ve, Oe = fe.current, We = Oe.getPanel(M), je = Oe.getPanel(D);
1057
- if (!(We && je))
1058
- return;
1059
- const hn = Math.min(Oe.containerSize * In, vn), mn = Math.min(Oe.containerSize * ct, dt);
1060
- if (je.collapsed) {
1061
- Ue > mn && z(D, "start", Ue, "pointer");
1062
- return;
1063
- }
1064
- if (We.collapsed) {
1065
- ve > mn && z(M, "end", ve, "pointer");
1066
- return;
1067
- }
1068
- if (je.collapseFromStart && Ue <= hn) {
1069
- H(D, "start", "pointer");
1070
- return;
1071
- }
1072
- if (We.collapseFromEnd && ve <= hn) {
1073
- H(M, "end", "pointer");
1074
- return;
1075
- }
1076
- U(M, D, ve, "pointer");
1077
- }, ln = (G) => {
1078
- Jn(() => {
1079
- Vn(G);
1080
- });
1081
- }, cn = (G) => {
1082
- if (G.pointerId !== xe)
1083
- return;
1084
- G.preventDefault(), G.stopPropagation();
1085
- const Pe = performance.now();
1086
- if (Pe - an < lt) {
1087
- Ie = G;
1088
- return;
1089
- }
1090
- an = Pe, Ie = null, ln(G);
1091
- };
1092
- let dn = !0;
1093
- const De = () => {
1094
- dn && (dn = !1, g.current = null, P(!1), s?.(!1), document.removeEventListener("pointermove", cn), document.removeEventListener("pointerup", un), document.removeEventListener("pointercancel", pn), Re.removeEventListener("lostpointercapture", fn), Re.hasPointerCapture?.(xe) && Re.releasePointerCapture(xe));
1095
- }, un = (G) => {
1096
- if (G.pointerId === xe) {
1097
- if (Ie) {
1098
- const Pe = Ie;
1099
- Ie = null, ln(Pe);
1100
- }
1101
- De();
1102
- }
1103
- }, pn = (G) => {
1104
- G.pointerId === xe && De();
1105
- }, fn = (G) => {
1106
- G.pointerId === xe && De();
1107
- };
1108
- document.addEventListener("pointermove", cn), document.addEventListener("pointerup", un), document.addEventListener("pointercancel", pn), Re.addEventListener("lostpointercapture", fn), g.current = De;
1109
- },
1110
- [ee, w, b, S, U, H, z, s]
1111
- ), rn = F(
1112
- (h) => {
1113
- if (ee)
1114
- return;
1115
- const X = w ? "ArrowLeft" : "ArrowUp", T = w ? "ArrowRight" : "ArrowDown";
1116
- if (h.key !== X && h.key !== T)
1117
- return;
1118
- const M = l.current, D = p.current, j = S(M), $ = S(D);
1119
- if (!(j && $))
1120
- return;
1121
- const I = Nn(j, $, v);
1122
- if (!I || I.upper - I.lower <= _)
1123
- return;
1124
- h.preventDefault(), h.stopPropagation();
1125
- const ne = h.shiftKey ? gn * 5 : gn, ze = w && wn(Te(O.current)) ? -1 : 1, te = (h.key === T ? ne : -ne) * ze;
1126
- if (j.collapsed) {
1127
- te > 0 && z(M, "end", void 0, "keyboard");
1128
- return;
1129
- }
1130
- if ($.collapsed) {
1131
- te < 0 && z(D, "start", void 0, "keyboard");
1132
- return;
1133
- }
1134
- if (te < 0 && j.collapseFromEnd && I.position <= I.resizeLower + _) {
1135
- H(M, "end", "keyboard");
1136
- return;
1137
- }
1138
- if (te > 0 && $.collapseFromStart && I.position >= I.resizeUpper - _) {
1139
- H(D, "start", "keyboard");
1140
- return;
1141
- }
1142
- U(M, D, j.size + te, "keyboard");
1143
- },
1144
- [ee, w, S, U, H, z, v]
1145
- ), ce = typeof u == "object" && u !== null ? u : void 0, $e = u === !1 || ce?.visible === !1, oe = Math.max(1, _e(a, et)), On = w ? tt : rt, Tn = w ? it : st, he = Math.min(oe, Math.max(1, _e(d ?? ce?.thickness, nt))), ye = Math.max(1, _e(m ?? ce?.length, On)), we = Math.min(he, Math.max(1, _e(c ?? ce?.barThickness, ot))), Ne = Math.min(ye, Math.max(1, _e(R ?? ce?.barLength, Tn))), me = N(() => {
1146
- const h = Ln(v), X = (I) => {
1147
- const ne = K[I];
1148
- return ne ? ne.collapsed || ne.size <= h : !1;
1149
- }, T = (I, ne) => {
1150
- let ze = 0;
1151
- for (let te = I; te >= 0 && te < K.length && X(te); te += ne)
1152
- ze += 1;
1153
- return ze;
1154
- }, M = K.findIndex((I) => I.id === x.start), D = K.findIndex((I) => I.id === x.end), j = M >= 0 ? T(M, -1) : 0, $ = D >= 0 ? T(D, 1) : 0;
1155
- return { groupSize: j + $ + 1, overlapIndex: j };
1156
- }, [x.start, x.end, K, v]), se = N(() => He ? !0 : me.groupSize <= 1 ? !1 : me.overlapIndex > 0 && me.overlapIndex < me.groupSize - 1, [me, He]), Me = N(() => {
1157
- if (me.groupSize <= 1 || se)
1158
- return 0;
1159
- const h = rr(Math.max(at, he + 4));
1160
- return (me.overlapIndex === 0 ? -0.5 : 0.5) * h;
1161
- }, [me, se, he]), Fn = N(() => {
1162
- const h = {
1163
- // 長さ 0 のフレックスアイテム: フレックスレイアウトがこれを境界そのものへ配置する
1164
- position: "relative",
1165
- flex: "0 0 0px",
1166
- alignSelf: "stretch",
1167
- // DOM 順を配置順の真実として扱うため、クラス由来の order で並びが変わらないようにする
1168
- order: 0,
1169
- margin: 0,
1170
- overflow: "visible",
1171
- ...w ? { width: 0, minWidth: 0 } : { height: 0, minHeight: 0 }
1172
- };
1173
- return se ? { ...h, ...nr } : h;
1174
- }, [w, se]), on = N(
1175
- () => ({
1176
- "--rp-handle-thickness": `${oe}px`,
1177
- "--rp-indicator-thickness": `${he}px`,
1178
- "--rp-indicator-length": `${ye}px`,
1179
- "--rp-indicator-bar-thickness": `${we}px`,
1180
- "--rp-indicator-bar-length": `${Ne}px`
1181
- }),
1182
- [oe, he, ye, we, Ne]
1183
- ), Bn = N(() => ({
1184
- ...on,
1185
- ...o,
1186
- // ここから下は境界に載るという前提そのもの。利用者のスタイルやクラスで変わると
1187
- // 操作領域の中心が境界から外れ、touch-action が戻るとタッチではスクロールが優先されてしまう
1188
- position: "absolute",
1189
- zIndex: 20,
1190
- touchAction: "none",
1191
- // 位置は論理プロパティで与える。アンカーは寸法 0 なので RTL でも同じ点に重なるが、
1192
- // 「境界からの距離」という意図をそのまま表せる
1193
- ...w ? { insetBlockStart: 0, insetInlineStart: `${-oe / 2}px`, width: `${oe}px`, height: "100%" } : { insetInlineStart: 0, insetBlockStart: `${-oe / 2}px`, height: `${oe}px`, width: "100%" }
1194
- }), [w, oe, on, o]), kn = N(() => {
1195
- if (se || $e)
1196
- return tr;
1197
- const h = {
1198
- width: `${w ? he : ye}px`,
1199
- height: `${w ? ye : he}px`,
1200
- flexShrink: 0
1201
- };
1202
- return Me !== 0 && (h.position = "relative", w ? h.insetInlineStart = `${Me}px` : h.insetBlockStart = `${Me}px`), h;
1203
- }, [se, $e, w, he, ye, Me]), Hn = N(
1204
- () => ({
1205
- width: `${w ? we : Ne}px`,
1206
- height: `${w ? Ne : we}px`,
1207
- flexShrink: 0
1208
- }),
1209
- [w, we, Ne]
1210
- ), $n = N(
1211
- () => Le(
1212
- "group absolute z-20 flex select-none items-center justify-center border-none bg-transparent transition-colors duration-150 overflow-visible",
1213
- w ? "cursor-col-resize h-full" : "cursor-row-resize w-full",
1214
- !ee && "hover:bg-gray-200/70 dark:hover:bg-gray-700/70",
1215
- !ee && "active:bg-blue-300/60 dark:active:bg-blue-700/60",
1216
- C && "bg-blue-200/80 dark:bg-blue-800/60",
1217
- ee && "cursor-not-allowed opacity-50",
1218
- "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50",
1219
- r
1220
- ),
1221
- [w, ee, C, r]
1222
- ), Gn = N(
1223
- () => Le(
1224
- "pointer-events-none flex items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-inset ring-white/80 backdrop-blur-sm transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.85),0_1px_3px_rgba(15,23,42,0.18)]",
1225
- "dark:bg-slate-800/95 dark:text-slate-200 dark:ring-slate-500/60 dark:shadow-[0_0_0_1px_rgba(148,163,184,0.45),0_1px_3px_rgba(2,6,23,0.55)]",
1226
- C && "bg-blue-200/80 ring-blue-300 shadow-[0_0_0_1px_rgba(191,219,254,0.65),0_1px_4px_rgba(59,130,246,0.45)] dark:bg-blue-900/70 dark:ring-blue-400 dark:shadow-[0_0_0_1px_rgba(147,197,253,0.5),0_1px_4px_rgba(59,130,246,0.55)]",
1227
- ce?.className
1228
- ),
1229
- [C, ce?.className]
1230
- ), Un = N(
1231
- () => Le(
1232
- "pointer-events-none rounded-full bg-slate-600 transition-colors duration-150 shadow-[0_0_0_1px_rgba(255,255,255,0.9)] dark:bg-slate-200 dark:shadow-[0_0_0_1px_rgba(15,23,42,0.55)]",
1233
- C && "bg-blue-500 dark:bg-blue-300",
1234
- !ee && "group-hover:bg-slate-700 dark:group-hover:bg-slate-100",
1235
- ce?.barClassName
1236
- ),
1237
- [C, ee, ce?.barClassName]
1238
- );
1239
- J(() => {
1240
- if (le === q.current)
1241
- return;
1242
- const h = q.current;
1243
- q.current = le, y.current = null, A(h, null);
1244
- }, [A, le]), J(() => {
1245
- const h = {
1246
- id: le,
1247
- thickness: se ? 0 : oe,
1248
- direction: b,
1249
- visible: !se && oe > ut,
1250
- startPanelId: x.start,
1251
- endPanelId: x.end
1252
- };
1253
- y.current = h, A(le, h);
1254
- }, [le, oe, se, b, x.start, x.end, A]), J(() => () => {
1255
- A(q.current, null);
1256
- }, [A]);
1257
- const Wn = F(
1258
- (h) => {
1259
- k?.(h), h.defaultPrevented || tn(h);
1260
- },
1261
- [k, tn]
1262
- ), jn = F(
1263
- (h) => {
1264
- V?.(h), h.defaultPrevented || rn(h);
1265
- },
1266
- [V, rn]
1267
- ), sn = `Resize ${w ? "columns" : "rows"} - Drag or use arrow keys to resize, drag to the edge to collapse/expand panels`, Ge = N(() => {
1268
- const h = x.start === null ? void 0 : S(x.start), X = x.end === null ? void 0 : S(x.end);
1269
- if (!(h && X) || v <= 0)
1270
- return;
1271
- const T = Nn(h, X, v);
1272
- if (!T)
1273
- return;
1274
- const M = (D) => Math.round(D / v * 100);
1275
- return { now: M(T.position), min: M(T.lower), max: M(T.upper) };
1276
- }, [x.start, x.end, S, v]);
1277
- return /* @__PURE__ */ ie("div", { ref: O, style: Fn, "data-resize-handle-anchor": "", children: /* @__PURE__ */ ie(
1278
- "button",
1279
- {
1280
- ...ae,
1281
- type: "button",
1282
- ref: Y,
1283
- className: $n,
1284
- style: Bn,
1285
- onPointerDown: Wn,
1286
- onKeyDown: jn,
1287
- disabled: ee,
1288
- role: "separator",
1289
- "aria-orientation": w ? "vertical" : "horizontal",
1290
- "aria-valuenow": Ge?.now,
1291
- "aria-valuemin": Ge?.min,
1292
- "aria-valuemax": Ge?.max,
1293
- "aria-disabled": ee || void 0,
1294
- "aria-hidden": se || void 0,
1295
- "aria-label": ae["aria-label"] ?? sn,
1296
- "data-resize-handle-id": le,
1297
- title: f ?? sn,
1298
- children: i || !$e && /* @__PURE__ */ ie("div", { className: Gn, style: kn, "data-resize-handle-indicator": "", "aria-hidden": "true", children: /* @__PURE__ */ ie("span", { className: Un, style: Hn, "data-resize-handle-indicator-bar": "", "aria-hidden": "true" }) })
1299
- }
1300
- ) });
1301
- }), en = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), fr = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-id="${en(e)}"]`), hr = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-group-id="${en(e)}"]`), mr = (e) => typeof document > "u" ? null : document.querySelector(`[data-resize-handle-id="${en(e)}"]`);
1302
- export {
1303
- Qe as A,
1304
- Gt as B,
1305
- Qn as P,
1306
- dr as a,
1307
- ur as b,
1308
- Mn as c,
1309
- pr as d,
1310
- wt as e,
1311
- Ln as f,
1312
- Fe as g,
1313
- It as h,
1314
- Te as i,
1315
- xn as j,
1316
- Ae as k,
1317
- An as l,
1318
- fr as m,
1319
- hr as n,
1320
- At as o,
1321
- mr as p,
1322
- Rt as q,
1323
- re as r,
1324
- bt as s,
1325
- ht as t,
1326
- Mt as u,
1327
- lr as v,
1328
- be as w,
1329
- Sn as x,
1330
- _n as y,
1331
- cr as z
1332
- };