@aiquants/resize-panels 2.2.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,1379 +0,0 @@
1
- import { createContext as rt, useContext as ot, useCallback as k, useMemo as R, useReducer as it, useState as Ne, useRef as B, useLayoutEffect as Pe, useEffect as Q, memo as sn, useId as Cn, Suspense as st, lazy as at } from "react";
2
- import { jsxs as he, jsx as oe } from "react/jsx-runtime";
3
- import { twMerge as Me } from "tailwind-merge";
4
- import { flushSync as En } from "react-dom";
5
- const lt = 12, L = 1e-6, ct = 8, ut = 6, dt = 48, pt = 80, ft = 2, ht = 32, gt = 64, mt = 8, St = 8, xt = 4, wn = 10, Mn = 0.05, Dn = 10, bt = 0.05, yt = 20, zt = 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
- }, Et = 6, On = (e, n) => n <= 0 ? 0 : Pt(e / n * 100, Et), Pr = (e, n) => n <= 0 ? 0 : e / 100 * n, wt = (e, n = "percentage") => {
11
- if (e !== void 0)
12
- return typeof e == "number" ? { value: e, unit: n } : e;
13
- }, en = (e, n, t) => e === void 0 ? n : typeof e == "number" ? e / 100 * t : e.unit === "pixels" ? e.value : e.value / 100 * t, De = (e, n, t) => Math.min(Math.max(e, n), t), Tn = (e) => !Number.isFinite(e) || e <= 0 ? 0 : Math.max(0, Math.min(lt, Dn, e * Mn)), xe = (e) => {
14
- if (!e)
15
- return 0;
16
- const n = Number.parseFloat(e);
17
- return Number.isFinite(n) ? n : 0;
18
- }, Oe = (e, n, t) => {
19
- const r = n === "horizontal", o = typeof window < "u" ? window.getComputedStyle(e) : null, i = o ? r ? xe(o.paddingLeft) + xe(o.paddingRight) : xe(o.paddingTop) + xe(o.paddingBottom) : 0, s = o ? r ? xe(o.borderLeftWidth) + xe(o.borderRightWidth) : xe(o.borderTopWidth) + xe(o.borderBottomWidth) : 0, a = t?.contentBoxSize?.[0], d = a ? r ? a.inlineSize : a.blockSize : void 0, c = r ? e.clientWidth : e.clientHeight, g = c > 0 ? Math.max(0, c - i) : Math.max(0, (r ? e.offsetWidth : e.offsetHeight) - i - s), l = d ?? g;
20
- return { content: Math.max(0, l), border: Math.max(0, l + i + s) };
21
- }, vt = "[data-panel-group-direction]", nn = "[data-panel-id], [data-resize-handle-anchor]", Nt = "[data-panel-id]", Be = (e) => e?.closest(vt) ?? null, Fn = (e) => Array.from(e.querySelectorAll(nn)).filter((n) => {
22
- if (Be(n) !== e)
23
- return !1;
24
- const t = n.parentElement?.closest(Nt);
25
- return !(t && e.contains(t));
26
- }), Rt = (e) => {
27
- const n = (t) => {
28
- for (const r of Array.from(t))
29
- if (r instanceof Element && (r.matches(nn) || r.querySelector(nn) !== null))
30
- return !0;
31
- return !1;
32
- };
33
- return e.some((t) => n(t.addedNodes) || n(t.removedNodes));
34
- }, It = (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
- }, vn = (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
- }, _t = (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
- }, tn = 0, kn = 1, He = (e) => Number.isFinite(e) && e > 0 ? e : 0, ne = (e) => e.sizeUnit === "pixels", Ee = (e, n) => {
62
- const t = Math.max(0, He(en(e.minSize, 0, n))), r = Math.max(t, He(en(e.maxSize, n, n)));
63
- return { min: t, max: r };
64
- }, At = (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 l = 0; l < e.length; l += 1) {
69
- if (r[l]) {
70
- i += t[l];
71
- continue;
72
- }
73
- s += 1, o += e[l].weight;
74
- }
75
- if (s === 0)
76
- return t;
77
- const a = n - i;
78
- if (o <= 0) {
79
- for (let l = 0; l < e.length; l += 1)
80
- r[l] || (t[l] = e[l].min);
81
- return t;
82
- }
83
- const d = Math.max(0, a / o);
84
- let c = 0;
85
- for (let l = 0; l < e.length; l += 1) {
86
- if (r[l])
87
- continue;
88
- const _ = d * e[l].weight, f = De(_, e[l].min, e[l].max);
89
- t[l] = f, c += f - _;
90
- }
91
- let g = !1;
92
- for (let l = 0; l < e.length; l += 1) {
93
- if (r[l])
94
- continue;
95
- const _ = d * e[l].weight;
96
- c > L && t[l] > _ + L ? (r[l] = !0, t[l] = e[l].min, g = !0) : c < -L && t[l] < _ - L && (r[l] = !0, t[l] = e[l].max, g = !0);
97
- }
98
- if (!g)
99
- return t;
100
- }
101
- }, Lt = (e, n, t) => {
102
- const { min: r, max: o } = Ee(e, t);
103
- if (ne(e))
104
- return {
105
- index: n,
106
- weight: 0,
107
- target: De(He(e.preferredPixelSize), r, o),
108
- priority: e.pixelAdjustPriority ?? 0,
109
- tier: tn,
110
- min: r,
111
- max: o
112
- };
113
- const i = He(e.preferredPercentageSize), s = e.flexAdjustPriority !== void 0;
114
- return {
115
- index: n,
116
- weight: i,
117
- target: s ? De(i / 100 * t, r, o) : null,
118
- priority: e.flexAdjustPriority ?? 0,
119
- tier: kn,
120
- min: r,
121
- max: o
122
- };
123
- }, Nn = (e, n, t, r) => {
124
- let o = r;
125
- for (const i of e) {
126
- if (o <= L)
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
- }, rn = (e, n, t) => {
136
- if (e.length === 0 || t <= L)
137
- return t;
138
- const r = e.map((s) => ({ ...s, min: n[s.index] })), o = At(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
- }, Ct = (e, n, t) => rn(
144
- e.map((r) => ({ ...r, weight: 1 })),
145
- n,
146
- t
147
- ), Mt = (e, n) => e.tier !== n.tier ? e.tier - n.tier : e.priority !== n.priority ? n.priority - e.priority : e.index - n.index, Dt = (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 H = e[f];
154
- H.collapsed || r.push(Lt(H, 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 = Ot(o, i, n);
162
- let a = n - o;
163
- if (a <= L)
164
- return { sizes: t, violation: s };
165
- const d = r.filter((f) => f.target !== null).sort(Mt), c = r.filter((f) => f.target === null && f.weight > 0), g = r.filter((f) => f.tier !== tn && f.weight <= 0), l = d.filter((f) => f.tier === kn), _ = d.filter((f) => f.tier === tn);
166
- return a = Nn(d, t, (f) => f.target ?? f.min, a), a = rn(c, t, a), a = rn(l, t, a), a = Nn(_, t, (f) => f.max, a), a = Ct(g, t, a), { sizes: t, violation: s };
167
- }, Ot = (e, n, t) => e - t > L ? {
168
- reason: "minimum-exceeded",
169
- totalMinimumSize: e,
170
- totalMaximumSize: n,
171
- availableContainerSize: t
172
- } : t - n > L ? {
173
- reason: "maximum-insufficient",
174
- totalMinimumSize: e,
175
- totalMaximumSize: n,
176
- availableContainerSize: t
177
- } : null, Bn = rt(null), an = () => {
178
- const e = ot(Bn);
179
- if (!e)
180
- throw new Error("usePanelGroup must be used within a PanelGroup");
181
- return e;
182
- };
183
- var Ge = /* @__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))(Ge || {});
184
- const J = class J {
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, J.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 J.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 J.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 J.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
- J.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
- J.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
- J.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
- J.instance.error(n, ...t);
284
- }
285
- error(n, ...t) {
286
- this.level <= 3 && this.impl.error(...this.formatMessage(n), ...t);
287
- }
288
- };
289
- J.instances = /* @__PURE__ */ new Set(), J.instance = new J(2, "[resize-panels]");
290
- let Te = J;
291
- const Hn = new Te(Ge.INFO, "[resize-panels]"), Tt = {
292
- containerSize: 0,
293
- panels: [],
294
- violation: null
295
- }, Rn = (e, n) => e === null || n === null ? e === n : e.reason === n.reason && Math.abs(e.totalMinimumSize - n.totalMinimumSize) <= L && Math.abs(e.totalMaximumSize - n.totalMaximumSize) <= L && Math.abs(e.availableContainerSize - n.availableContainerSize) <= L, pe = (e, n) => {
296
- const { sizes: t, violation: r } = Dt(e, n);
297
- let o = !1;
298
- const i = e.map((a, d) => {
299
- const c = a.collapsed ? 0 : t[d];
300
- return Math.abs(a.size - c) <= L ? a : (o = !0, { ...a, size: c });
301
- }), s = { containerSize: n, panels: o ? i : e, violation: r };
302
- return kt(s), s;
303
- }, Ft = (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 = L * Math.max(1, e.containerSize);
312
- return !Number.isFinite(n) || Math.abs(n - e.containerSize) > r ? { allocatedTotal: n, containerSize: e.containerSize } : null;
313
- }, kt = (e) => {
314
- const n = Ft(e);
315
- n && Hn.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
- }, fe = (e, n) => e.panels === n.panels && e.containerSize === n.containerSize && Rn(e.violation, n.violation) ? e : {
320
- containerSize: n.containerSize,
321
- panels: n.panels,
322
- violation: Rn(e.violation, n.violation) ? e.violation : n.violation
323
- }, Bt = (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
- }, Ze = (e) => e.collapseFromStart ? "start" : e.collapseFromEnd ? "end" : null, Ht = (e, n) => {
334
- if (n <= 0)
335
- return e;
336
- const t = Tn(n);
337
- return e.map((r) => {
338
- if (r.collapsed)
339
- return r;
340
- const o = ne(r) ? r.size : r.size / n * 100, i = ne(r) ? r.preferredPixelSize : r.preferredPercentageSize, s = r.size > t ? o : r.preferenceBeforeCollapse;
341
- return i === o && s === r.preferenceBeforeCollapse ? r : ne(r) ? { ...r, preferredPixelSize: o, preferenceBeforeCollapse: s } : { ...r, preferredPercentageSize: o, preferenceBeforeCollapse: s };
342
- });
343
- }, on = (e, n, t) => {
344
- if (ne(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
- }, $t = (e, n) => {
353
- const t = e.collapsed ? e.preferenceBeforeCollapse : ne(e) ? e.preferredPixelSize : e.preferredPercentageSize;
354
- return ne(e) ? t : t / 100 * n;
355
- }, Gt = (e, n, t, r) => {
356
- const o = Math.max(0, Math.min(t, r)), i = e.filter((c) => c.id !== n && !c.collapsed && !ne(c)), s = e.reduce((c, g) => g.id !== n && !g.collapsed && ne(g) ? c + g.size : c, 0), a = i.reduce((c, g) => c + g.size, 0), d = Math.max(0, r - o - s);
357
- return e.map((c) => {
358
- if (c.id === n)
359
- return on(c, o, r);
360
- if (c.collapsed || ne(c) || i.length === 0)
361
- return c;
362
- const g = a > 0 ? c.size / a * d : d / i.length;
363
- return on(c, g, r);
364
- });
365
- }, Ut = (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 : fe(e, pe(e.panels, n.containerSize));
369
- case "REGISTER_PANEL": {
370
- const t = e.panels.findIndex((l) => l.id === n.panel.id);
371
- if (t === -1) {
372
- const l = [...e.panels, Bt(n.panel, Ze(n.panel))];
373
- return fe(e, pe(l, 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, d = r.collapsed && a, c = {
376
- ...r,
377
- ...n.panel,
378
- collapsed: d,
379
- collapsedByDirection: d ? s ? r.collapsedByDirection : Ze(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
- }, g = [...e.panels];
385
- return g[t] = c, fe(e, pe(g, 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 : fe(e, pe(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 : fe(e, pe(r, e.containerSize));
402
- }
403
- case "RESIZE_PANELS": {
404
- const t = e.panels.findIndex((H) => H.id === n.startId), r = e.panels.findIndex((H) => H.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 = Ee(o, e.containerSize), d = Ee(i, e.containerSize), c = Math.max(a.min, s - d.max), g = Math.min(a.max, s - d.min);
411
- if (c - g > L)
412
- return e;
413
- const l = De(n.startSize, c, Math.max(c, g)), _ = s - l;
414
- if (Math.abs(l - o.size) <= L)
415
- return e;
416
- const f = [...e.panels];
417
- return f[t] = { ...o, size: l }, f[r] = { ...i, size: _ }, fe(e, pe(Ht(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
- }, fe(e, pe(i, e.containerSize));
432
- }
433
- case "EXPAND_PANEL": {
434
- const t = e.panels.findIndex((d) => d.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: ne(r) ? r.preferenceBeforeCollapse : r.preferredPixelSize,
445
- preferredPercentageSize: ne(r) ? r.preferredPercentageSize : r.preferenceBeforeCollapse
446
- }, s = [...e.panels];
447
- s[t] = i;
448
- const a = n.targetSize === void 0 ? s : Gt(s, n.id, n.targetSize, e.containerSize);
449
- return fe(e, pe(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 = on(o, i.size, e.containerSize), a = o.collapseFromStart || o.collapseFromEnd;
462
- return i.collapsed && a ? { ...s, collapsed: !0, collapsedByDirection: o.collapsedByDirection ?? Ze(o) } : s.collapsed ? { ...s, collapsed: !1, collapsedByDirection: null } : s;
463
- });
464
- return Hn.debug("restore layout", { containerSize: e.containerSize, entries: n.entries }), fe(e, pe(r, e.containerSize));
465
- }
466
- default:
467
- return e;
468
- }
469
- }, Wt = {
470
- layout: Tt,
471
- source: null
472
- }, jt = (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
- }, Vt = (e, n) => {
488
- const t = Ut(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 ? jt(n) : e.source };
493
- }, Kt = new Te(Ge.INFO, "[resize-panels]"), Yt = { pointer: !0, keyboard: !0, api: !0 }, qt = (e) => typeof e == "string" && Object.hasOwn(Yt, e), Je = (e) => {
494
- if (!qt(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
- }, Xt = 200, Zt = "\0handle", Jt = ({ direction: e, style: n, onLayout: t, autoSaveId: r, showDebugInfo: o = !1 }) => {
498
- const [{ layout: i, source: s }, a] = it(Vt, Wt), [d, c] = Ne({}), [g, l] = Ne({}), _ = B(null), [f, H] = Ne(""), V = B({}), ce = B(t);
499
- ce.current = t, Pe(() => {
500
- const u = _.current;
501
- if (!u || typeof ResizeObserver > "u")
502
- return;
503
- let p = Number.NaN;
504
- const m = (A) => {
505
- A !== p && (p = A, a({ type: "SET_CONTAINER_SIZE", containerSize: A }));
506
- }, S = new ResizeObserver((A) => {
507
- m(Oe(u, e, A[0]).content);
508
- });
509
- return S.observe(u), m(Oe(u, e).content), () => {
510
- S.disconnect(), a({ type: "SET_CONTAINER_SIZE", containerSize: 0 });
511
- };
512
- }, [e]);
513
- const w = i.panels, $ = B(w);
514
- $.current = w;
515
- const v = k(() => {
516
- const u = _.current, p = $.current;
517
- if (!u)
518
- return;
519
- const m = Fn(u);
520
- if (H((A) => {
521
- const se = m.map((Ue) => Ue.dataset.panelId ?? Zt).join("\0");
522
- return A === se ? A : se;
523
- }), p.length === 0)
524
- return;
525
- const S = [];
526
- for (const A of m) {
527
- const se = A.dataset.panelId;
528
- se !== void 0 && S.push(se);
529
- }
530
- if (new Set(S).size !== S.length) {
531
- Kt.error("Duplicate panel id in one group.", { ids: S });
532
- return;
533
- }
534
- S.length !== p.length || S.every((A, se) => A === p[se].id) || a({ type: "REORDER_PANELS", ids: S });
535
- }, []);
536
- Pe(() => {
537
- const u = _.current;
538
- if (!u || (v(), typeof MutationObserver > "u"))
539
- return;
540
- const p = new MutationObserver((m) => {
541
- Rt(m) && v();
542
- });
543
- return p.observe(u, { childList: !0, subtree: !0 }), () => {
544
- p.disconnect();
545
- };
546
- }, [v]), Pe(() => {
547
- v();
548
- }, [v, w]);
549
- const C = R(() => w.map((u) => u.size), [w]), P = i.containerSize > 0;
550
- Pe(() => {
551
- !P || C.length === 0 || s === null || ce.current?.(C, { source: s });
552
- }, [C, P, s]);
553
- const G = B(null);
554
- Q(() => {
555
- if (!r || G.current === r || !P || w.length === 0)
556
- return;
557
- G.current = r;
558
- const u = _t(r);
559
- u && a({ type: "RESTORE_LAYOUT", entries: u });
560
- }, [r, P, w.length]);
561
- const x = B(null);
562
- Q(() => {
563
- if (!(r && G.current === r && P) || w.length === 0)
564
- return;
565
- const u = w.map((m) => ({ id: m.id, size: $t(m, i.containerSize), collapsed: m.collapsed }));
566
- x.current = { id: r, entries: u };
567
- const p = setTimeout(() => {
568
- x.current = null, vn(r, u);
569
- }, Xt);
570
- return () => {
571
- clearTimeout(p);
572
- };
573
- }, [r, w, i.containerSize, P]), Q(() => () => {
574
- const u = x.current;
575
- u && (x.current = null, vn(u.id, u.entries));
576
- }, []);
577
- const K = k((u) => {
578
- const p = JSON.stringify(u);
579
- V.current[u.id] !== p && (V.current[u.id] = p, a({ type: "REGISTER_PANEL", panel: u }));
580
- }, []), T = k((u) => {
581
- delete V.current[u], a({ type: "UNREGISTER_PANEL", id: u }), c((p) => {
582
- if (!(u in p))
583
- return p;
584
- const m = { ...p };
585
- return delete m[u], m;
586
- });
587
- }, []), O = k((u, p, m, S = "api") => {
588
- a({ type: "RESIZE_PANELS", startId: u, endId: p, startSize: m, source: Je(S) });
589
- }, []), Y = k((u, p, m = "api") => {
590
- a({ type: "COLLAPSE_PANEL", id: u, from: p, source: Je(m) });
591
- }, []), b = k((u, p, m, S = "api") => {
592
- a({ type: "EXPAND_PANEL", id: u, from: p, targetSize: m, source: Je(S) });
593
- }, []), y = k((u) => w.find((p) => p.id === u), [w]), U = k((u, p) => {
594
- c((m) => {
595
- if (p === null) {
596
- if (!(u in m))
597
- return m;
598
- const A = { ...m };
599
- return delete A[u], A;
600
- }
601
- const S = m[u];
602
- return S && S.pixelSize === p.pixelSize && S.percentageSize === p.percentageSize ? m : { ...m, [u]: p };
603
- });
604
- }, []), z = k((u, p) => {
605
- l((m) => {
606
- if (p === null) {
607
- if (!(u in m))
608
- return m;
609
- const A = { ...m };
610
- return delete A[u], A;
611
- }
612
- const S = m[u];
613
- return S && S.thickness === p.thickness && S.visible === p.visible && S.direction === p.direction && S.startPanelId === p.startPanelId && S.endPanelId === p.endPanelId ? m : { ...m, [u]: p };
614
- });
615
- }, []), X = R(
616
- () => ({
617
- direction: e,
618
- panels: w,
619
- containerSize: i.containerSize,
620
- layoutOrderKey: f,
621
- showDebugInfo: o,
622
- registerPanel: K,
623
- unregisterPanel: T,
624
- resizePanels: O,
625
- collapsePanel: Y,
626
- expandPanel: b,
627
- getPanel: y,
628
- reportPanelMeasurement: U,
629
- panelMeasurements: d,
630
- reportHandleMeasurement: z,
631
- handleMeasurements: g,
632
- layoutConstraintViolation: i.violation
633
- }),
634
- [e, w, i.containerSize, f, i.violation, o, K, T, O, Y, b, y, U, d, z, g]
635
- ), ie = R(
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: _, contextValue: X, groupStyle: ie };
660
- }, Er = (e) => {
661
- const { getPanel: n, collapsePanel: t, expandPanel: r } = an(), o = n(e), i = k(
662
- (d) => {
663
- t(e, d, "api");
664
- },
665
- [t, e]
666
- ), s = k(
667
- (d, c) => {
668
- r(e, d, c, "api");
669
- },
670
- [r, e]
671
- ), a = k(
672
- (d, c) => {
673
- o?.collapsed ? s(d, c) : i(d);
674
- },
675
- [o?.collapsed, i, s]
676
- );
677
- return R(
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
- }, Qt = ({ 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 / ${On(e.size, n).toFixed(3)}%`, i = r ? `${e.preferredPixelSize.toFixed(3)}px` : `${e.preferredPercentageSize.toFixed(3)}%`, s = Ee(e, n), a = `${s.min.toFixed(1)} - ${s.max.toFixed(1)}px`, d = Number.isFinite(n) ? `${n.toFixed(3)}px` : "-", c = r ? "Fixed" : "Flexible", g = [c, `${t}: ${d}`, `size: ${o}`, `preference: ${i}`, `bounds: ${a}`].join(`
693
- `);
694
- return { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: a, containerDisplay: d, headlineLabel: c, titleText: g };
695
- }, er = sn(({ panel: e, containerAxisSize: n, direction: t }) => {
696
- const r = t === "horizontal" ? "container width" : "container height", { sizeDisplay: o, preferenceDisplay: i, boundsDisplay: s, containerDisplay: a, headlineLabel: d, titleText: c } = R(() => Qt({ panel: e, containerAxisSize: n, containerLabel: r }), [e, n, r]);
697
- return /* @__PURE__ */ he("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: c, "data-panel-debug-info": "", children: [
716
- /* @__PURE__ */ he("div", { children: [
717
- d,
718
- " · ",
719
- r,
720
- ": ",
721
- a
722
- ] }),
723
- /* @__PURE__ */ he("div", { children: [
724
- "size: ",
725
- o
726
- ] }),
727
- /* @__PURE__ */ he("div", { children: [
728
- "preference: ",
729
- i
730
- ] }),
731
- /* @__PURE__ */ he("div", { children: [
732
- "bounds: ",
733
- s
734
- ] })
735
- ] });
736
- }), In = new Te(Ge.INFO, "[resize-panels]"), nr = {
737
- both: { collapseFromStart: !0, collapseFromEnd: !0 },
738
- start: { collapseFromStart: !0, collapseFromEnd: !1 },
739
- end: { collapseFromStart: !1, collapseFromEnd: !0 }
740
- }, tr = (e) => {
741
- if (!e)
742
- return { collapseFromStart: !1, collapseFromEnd: !1 };
743
- const n = nr[e.from];
744
- if (!n)
745
- throw new Error("Invalid collapsible configuration: unsupported 'from' value");
746
- return n;
747
- }, rr = (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
- }, or = ({ 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 d = t.sizeUnit === "pixels";
755
- return {
756
- flexBasis: d ? `${t.preferredPixelSize}px` : `${t.preferredPercentageSize}%`,
757
- flexGrow: d ? 0 : t.preferredPercentageSize,
758
- flexShrink: d ? 0 : 1
759
- };
760
- }
761
- if (n.sizeUnit === "pixels")
762
- return { flexBasis: `${e}px`, flexGrow: 0, flexShrink: 0 };
763
- const i = Ee(n, r), s = e < i.max - L, a = s && e > i.min + L;
764
- return { flexBasis: `${e}px`, flexGrow: s ? n.preferredPercentageSize : 0, flexShrink: a ? 1 : 0 };
765
- }, wr = sn(
766
- ({ id: e, defaultSize: n = { value: 50, unit: "percentage" }, minSize: t, maxSize: r, className: o, style: i, children: s, collapsible: a, defaultCollapsed: d = !1, pixelAdjustPriority: c, flexAdjustPriority: g, contentOverflow: l = "auto", ..._ }) => {
767
- const { direction: f, registerPanel: H, unregisterPanel: V, getPanel: ce, containerSize: w, showDebugInfo: $, reportPanelMeasurement: v } = an(), C = B(null), P = Cn(), x = B(e || `panel-${P}`).current;
768
- Q(() => {
769
- e && e !== x && In.warn("Panel id prop change after mount is ignored.", { currentId: x, attemptedId: e });
770
- }, [e, x]);
771
- const K = R(() => tr(a), [a]), T = K.collapseFromStart || K.collapseFromEnd;
772
- Q(() => {
773
- d && !T && In.warn("Panel defaultCollapsed is ignored because collapsible configuration is not provided.", { panelId: x });
774
- }, [d, T, x]);
775
- const O = R(() => {
776
- const u = wt(n) ?? { value: 50, unit: "percentage" };
777
- return {
778
- id: x,
779
- ...rr(u),
780
- minSize: t,
781
- maxSize: r,
782
- ...K,
783
- collapsed: T && d,
784
- pixelAdjustPriority: c,
785
- flexAdjustPriority: g
786
- };
787
- }, [x, n, t, r, K, T, d, c, g]);
788
- Pe(() => {
789
- H(O);
790
- }, [H, O]), Pe(() => () => {
791
- V(x);
792
- }, [V, x]);
793
- const Y = ce(x), b = Y?.size ?? 0, y = Y?.collapsed ?? !1, U = B(w);
794
- U.current = w;
795
- const z = k(() => {
796
- const u = C.current;
797
- if (!u)
798
- return;
799
- const p = Oe(u, f).border;
800
- v(x, { pixelSize: p, percentageSize: On(p, U.current) });
801
- }, [f, x, v]);
802
- Q(() => {
803
- if (!$) {
804
- v(x, null);
805
- return;
806
- }
807
- const u = C.current;
808
- if (!u || typeof ResizeObserver > "u") {
809
- z();
810
- return;
811
- }
812
- const p = new ResizeObserver(z);
813
- return p.observe(u), z(), () => {
814
- p.disconnect(), v(x, null);
815
- };
816
- }, [$, z, x, v]);
817
- const X = R(() => {
818
- const u = { overflow: "hidden", isolation: "isolate" }, p = y ? { ...f === "horizontal" ? { width: "0px" } : { height: "0px" }, pointerEvents: "none", visibility: "hidden", display: "none" } : {};
819
- return {
820
- ...u,
821
- ...i,
822
- // ここから下はレイアウトの前提そのもの。利用者のスタイルやクラスで変わると配分結果と
823
- // 描画が一致しなくなるため、最後に適用して上書きを受け付けない:
824
- // flex の三つ組は配分器が決めた長さそのもの、margin はパネルの合計に含まれない隙間を作り、
825
- // order は DOM 順と視覚順をずらす
826
- ...or({ size: b, panel: Y, registration: O, containerSize: w, isCollapsed: y }),
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
- }, [b, f, y, Y, O, w, i]), ie = R(
845
- () => ({
846
- // 内容は通常フローの伸縮子として置く。絶対配置にするとパディングボックスを基準にしてしまい、
847
- // 利用者がパネルへ与えたパディングが何の効果も持たなくなる
848
- flex: "1 1 auto",
849
- position: "relative",
850
- overflow: l,
851
- display: "flex",
852
- flexDirection: "column",
853
- minWidth: "0px",
854
- minHeight: "0px"
855
- }),
856
- [l]
857
- );
858
- return /* @__PURE__ */ he(
859
- "div",
860
- {
861
- ..._,
862
- ref: C,
863
- className: Me("panel", o),
864
- style: X,
865
- "data-panel-id": x,
866
- "data-panel-size": b,
867
- "data-panel-size-unit": Y?.sizeUnit ?? "percentage",
868
- "data-panel-collapsible": T,
869
- "data-panel-collapse-start": K.collapseFromStart,
870
- "data-panel-collapse-end": K.collapseFromEnd,
871
- "data-panel-collapsed": y,
872
- "aria-hidden": y,
873
- children: [
874
- /* @__PURE__ */ oe("div", { style: ie, children: s }),
875
- $ && /* @__PURE__ */ oe(er, { panel: Y, containerAxisSize: w, direction: f })
876
- ]
877
- }
878
- );
879
- }
880
- ), ir = at(() => import("./GlobalDebugOverlay-BL40__b0.js").then((e) => ({ default: e.GlobalDebugOverlayGate }))), sr = [], ar = {};
881
- let _n = 0;
882
- const lr = () => (_n += 1, `panel-group-${_n}`), cr = (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
- }, ur = (e, n) => e.map((t) => {
886
- const r = n[t.id];
887
- return r ? { ...t, measuredPixelSize: r.pixelSize, measuredPercentageSize: r.percentageSize } : t;
888
- }), An = (e, n, t) => {
889
- const r = Oe(e, "horizontal"), o = Oe(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
- }, vr = (e) => {
892
- const { id: n, className: t, style: r, children: o, direction: i, onLayout: s, autoSaveId: a, showDebugInfo: d, ...c } = e, { groupRef: g, contextValue: l, groupStyle: _ } = Jt(e), [f, H] = Ne({ width: 0, height: 0 }), V = l.layoutConstraintViolation, ce = !!V, w = R(() => {
893
- if (!V)
894
- return null;
895
- const { summary: b, detail: y } = cr(V);
896
- return /* @__PURE__ */ he(
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__ */ oe("span", { children: b }),
903
- /* @__PURE__ */ oe("span", { className: "text-slate-500 text-xs dark:text-slate-400", children: y })
904
- ]
905
- }
906
- );
907
- }, [V]), $ = B(null);
908
- $.current === null && ($.current = n ?? lr());
909
- const v = $.current, C = n ?? v, P = l.showDebugInfo && l.panels.length > 0, G = P ? l.panels : sr, x = P ? l.panelMeasurements : ar, K = R(() => {
910
- if (!P)
911
- return [];
912
- const b = Object.values(l.handleMeasurements);
913
- return b.length <= 1 ? b : b.slice().sort((y, U) => y.id.localeCompare(U.id));
914
- }, [l.handleMeasurements, P]), T = f.width, O = f.height;
915
- Pe(() => {
916
- if (!P) {
917
- H({ width: 0, height: 0 });
918
- return;
919
- }
920
- if (typeof window > "u" || typeof ResizeObserver > "u")
921
- return;
922
- const b = g.current;
923
- if (!b)
924
- return;
925
- const y = (z) => {
926
- H((X) => X.width === z.width && X.height === z.height ? X : z);
927
- }, U = new ResizeObserver((z) => {
928
- for (const X of z) {
929
- if (X.target !== b)
930
- continue;
931
- const ie = An(b, X.contentRect.width, X.contentRect.height);
932
- y(ie);
933
- }
934
- });
935
- return U.observe(b), y(An(b)), () => {
936
- U.disconnect();
937
- };
938
- }, [g, P]);
939
- const Y = R(() => ur(G, x), [G, x]);
940
- return Q(() => {
941
- if (!P)
942
- return;
943
- let b = !1, y = null;
944
- return import("./debugOverlayStore-D7FT6zPE.js").then((U) => {
945
- b || (y = U, U.enableDebugOverlayGroup(v));
946
- }), () => {
947
- b = !0, y && (y.disableDebugOverlayGroup(v), y.removeDebugOverlayGroup(v));
948
- };
949
- }, [P, v]), Q(() => {
950
- if (!P)
951
- return;
952
- let b = !1;
953
- return import("./debugOverlayStore-D7FT6zPE.js").then((y) => {
954
- b || y.updateDebugOverlayGroup(v, {
955
- displayName: C,
956
- direction: i,
957
- containerSize: {
958
- width: T,
959
- height: O
960
- },
961
- panels: Y,
962
- handles: K
963
- });
964
- }), () => {
965
- b = !0;
966
- };
967
- }, [P, v, C, i, T, O, Y, K]), /* @__PURE__ */ he(Bn.Provider, { value: l, children: [
968
- /* @__PURE__ */ he("div", { ...c, ref: g, className: Me("panel-group", i === "horizontal" ? "flex-row" : "flex-col", t), style: _, "data-panel-group-id": n, "data-panel-group-direction": i, children: [
969
- o,
970
- ce && w ? /* @__PURE__ */ oe(
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: w
987
- }
988
- ) : null
989
- ] }),
990
- P && /* @__PURE__ */ oe(st, { fallback: null, children: /* @__PURE__ */ oe(ir, { groupId: v }) })
991
- ] });
992
- }, dr = {
993
- display: "none",
994
- pointerEvents: "none",
995
- visibility: "hidden"
996
- }, pr = {
997
- display: "none"
998
- }, Ce = (e, n) => typeof e != "number" || !Number.isFinite(e) || e <= 0 ? n : e, fr = (e) => {
999
- const n = Math.round(e);
1000
- return n % 2 === 0 ? n : n + 1;
1001
- }, Ln = (e) => !e || typeof window > "u" ? !1 : window.getComputedStyle(e).direction === "rtl", Qe = (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 = Ee(e, t), a = Ee(n, t), d = Math.max(s.min, i - a.max), c = Math.max(d, Math.min(s.max, i - a.min));
1006
- if (e.collapsed)
1007
- return { position: 0, lower: 0, upper: e.collapsedByDirection === "end" ? Math.max(0, c) : 0, resizeLower: d, resizeUpper: c };
1008
- if (n.collapsed) {
1009
- const _ = n.collapsedByDirection === "start";
1010
- return { position: i, lower: _ ? Math.min(i, d) : i, upper: i, resizeLower: d, resizeUpper: c };
1011
- }
1012
- const g = Math.min(r, e.collapseFromEnd ? 0 : d), l = Math.max(r, g, n.collapseFromStart ? i : c);
1013
- return { position: r, lower: g, upper: l, resizeLower: d, resizeUpper: c };
1014
- }, hr = Object.freeze([]), gr = (e) => {
1015
- if (typeof e == "number")
1016
- return Number.isFinite(e) && e >= 0;
1017
- if (typeof e != "object" || e === null)
1018
- return !1;
1019
- const { value: n, unit: t } = e;
1020
- return (t === "pixels" || t === "percentage") && typeof n == "number" && Number.isFinite(n) && n >= 0;
1021
- }, $e = (e) => {
1022
- if (typeof e == "string")
1023
- return JSON.stringify(e);
1024
- if (typeof e != "object" || e === null || Array.isArray(e))
1025
- return String(e);
1026
- const { value: n, unit: t } = e;
1027
- return `{ value: ${$e(n)}, unit: ${$e(t)} }`;
1028
- }, mr = (e) => {
1029
- if (e === void 0)
1030
- return hr;
1031
- if (!Array.isArray(e))
1032
- throw new RangeError(`[resize-panels] activationSizes must be an array of sizes; received ${$e(e)}.`);
1033
- for (const [n, t] of e.entries())
1034
- if (!gr(t))
1035
- throw new RangeError(`[resize-panels] activationSizes[${n}] must be a non-negative finite percentage or { value, unit: "pixels" | "percentage" } with a non-negative finite value; received ${$e(t)}.`);
1036
- return e;
1037
- }, Sr = (e, n, t) => {
1038
- let r, o;
1039
- for (const i of e) {
1040
- const s = De(en(i, 0, t), n.resizeLower, n.resizeUpper);
1041
- Math.abs(s - n.position) <= L || ((o === void 0 || s < o) && (o = s), s > n.position && (r === void 0 || s < r) && (r = s));
1042
- }
1043
- return r === void 0 ? o : r;
1044
- }, Nr = sn((e) => {
1045
- const { id: n, disabled: t = !1, className: r, style: o, children: i, onDragging: s, activationSizes: a, thickness: d, indicator: c = !0, indicatorThickness: g, indicatorLength: l, indicatorBarThickness: _, indicatorBarLength: f, title: H, onPointerDown: V, onKeyDown: ce, ...w } = e, { direction: $, resizePanels: v, getPanel: C, collapsePanel: P, expandPanel: G, panels: x, layoutOrderKey: K, reportHandleMeasurement: T, containerSize: O, layoutConstraintViolation: Y } = an(), b = R(() => mr(a), [a]), [y, U] = Ne(!1), [z, X] = Ne({ start: null, end: null }), ie = B(null), u = B(null), p = B({ getPanel: C, containerSize: O });
1046
- p.current = { getPanel: C, containerSize: O };
1047
- const m = B(""), S = B(""), A = B(null), se = B(null), Ue = Cn(), Re = B(n ?? `resize-handle-${Ue}`), be = n ?? Re.current, N = $ === "horizontal", We = !!Y, ee = t || We, cn = k(() => {
1048
- const h = ie.current, Z = Be(h);
1049
- if (!(h && Z))
1050
- return;
1051
- const F = Fn(Z), M = F.indexOf(h);
1052
- let D = "", j = "";
1053
- for (let W = M - 1; W >= 0; W -= 1) {
1054
- const I = F[W].dataset.panelId;
1055
- if (I !== void 0) {
1056
- D = I;
1057
- break;
1058
- }
1059
- }
1060
- for (let W = M + 1; W < F.length; W += 1) {
1061
- const I = F[W].dataset.panelId;
1062
- if (I !== void 0) {
1063
- j = I;
1064
- break;
1065
- }
1066
- }
1067
- D === m.current && j === S.current || (m.current = D, S.current = j, X({ start: D || null, end: j || null }));
1068
- }, []);
1069
- Q(() => {
1070
- cn();
1071
- }, [cn, K]), Q(() => () => {
1072
- A.current?.();
1073
- }, []);
1074
- const un = k(
1075
- (h) => {
1076
- if (ee || A.current || h.button !== 0)
1077
- return;
1078
- const Z = C(m.current), F = C(S.current);
1079
- if (!(Z && F))
1080
- return;
1081
- h.preventDefault(), h.stopPropagation();
1082
- const M = m.current, D = S.current, j = Z.size, W = Z.size + F.size, I = h.clientX, re = h.clientY, ve = N ? I : re, q = Be(ie.current), Qn = N && Ln(q) ? -1 : 1, et = q ? It(q, $) : 1, ye = h.pointerId, Ae = h.currentTarget;
1083
- Ae.setPointerCapture?.(ye), U(!0), s?.(!0);
1084
- let hn = 0, Le = null, Ke = b.length > 0;
1085
- const gn = (E) => Math.hypot(E.clientX - I, E.clientY - re) >= xt, nt = (E) => {
1086
- const le = ((N ? E.clientX : E.clientY) - ve) * Qn / et, de = j + le, Se = W - de, ze = p.current, qe = ze.getPanel(M), Xe = ze.getPanel(D);
1087
- if (!(qe && Xe))
1088
- return;
1089
- const zn = Math.min(ze.containerSize * Mn, Dn), Pn = Math.min(ze.containerSize * bt, yt);
1090
- if (Xe.collapsed) {
1091
- Se > Pn && G(D, "start", Se, "pointer");
1092
- return;
1093
- }
1094
- if (qe.collapsed) {
1095
- de > Pn && G(M, "end", de, "pointer");
1096
- return;
1097
- }
1098
- if (Xe.collapseFromStart && Se <= zn) {
1099
- P(D, "start", "pointer");
1100
- return;
1101
- }
1102
- if (qe.collapseFromEnd && de <= zn) {
1103
- P(M, "end", "pointer");
1104
- return;
1105
- }
1106
- v(M, D, de, "pointer");
1107
- }, Ye = (E) => {
1108
- En(() => {
1109
- nt(E);
1110
- });
1111
- }, tt = () => {
1112
- const E = p.current, le = E.getPanel(M), de = E.getPanel(D);
1113
- if (!(le && de))
1114
- return;
1115
- const Se = Qe(le, de, E.containerSize);
1116
- if (!Se || Se.upper - Se.lower <= L)
1117
- return;
1118
- const ze = Sr(b, Se, E.containerSize);
1119
- ze !== void 0 && En(() => {
1120
- le.collapsed ? G(M, "end", void 0, "pointer") : de.collapsed && G(D, "start", void 0, "pointer"), v(M, D, ze, "pointer");
1121
- });
1122
- }, mn = (E) => {
1123
- if (E.pointerId !== ye)
1124
- return;
1125
- if (E.preventDefault(), E.stopPropagation(), Ke) {
1126
- if (!gn(E))
1127
- return;
1128
- Ke = !1;
1129
- }
1130
- const le = performance.now();
1131
- if (le - hn < St) {
1132
- Le = E;
1133
- return;
1134
- }
1135
- hn = le, Le = null, Ye(E);
1136
- };
1137
- let Sn = !0;
1138
- const ke = () => {
1139
- Sn && (Sn = !1, A.current = null, U(!1), s?.(!1), document.removeEventListener("pointermove", mn), document.removeEventListener("pointerup", xn), document.removeEventListener("pointercancel", bn), Ae.removeEventListener("lostpointercapture", yn), Ae.hasPointerCapture?.(ye) && Ae.releasePointerCapture(ye));
1140
- }, xn = (E) => {
1141
- if (E.pointerId === ye) {
1142
- if (Ke)
1143
- gn(E) ? Ye(E) : tt();
1144
- else if (Le) {
1145
- const le = Le;
1146
- Le = null, Ye(le);
1147
- }
1148
- ke();
1149
- }
1150
- }, bn = (E) => {
1151
- E.pointerId === ye && ke();
1152
- }, yn = (E) => {
1153
- E.pointerId === ye && ke();
1154
- };
1155
- document.addEventListener("pointermove", mn), document.addEventListener("pointerup", xn), document.addEventListener("pointercancel", bn), Ae.addEventListener("lostpointercapture", yn), A.current = ke;
1156
- },
1157
- [ee, N, $, C, v, P, G, s, b]
1158
- ), dn = k(
1159
- (h) => {
1160
- if (ee)
1161
- return;
1162
- const Z = N ? "ArrowLeft" : "ArrowUp", F = N ? "ArrowRight" : "ArrowDown";
1163
- if (h.key !== Z && h.key !== F)
1164
- return;
1165
- const M = m.current, D = S.current, j = C(M), W = C(D);
1166
- if (!(j && W))
1167
- return;
1168
- const I = Qe(j, W, O);
1169
- if (!I || I.upper - I.lower <= L)
1170
- return;
1171
- h.preventDefault(), h.stopPropagation();
1172
- const re = h.shiftKey ? wn * 5 : wn, ve = N && Ln(Be(ie.current)) ? -1 : 1, q = (h.key === F ? re : -re) * ve;
1173
- if (j.collapsed) {
1174
- q > 0 && G(M, "end", void 0, "keyboard");
1175
- return;
1176
- }
1177
- if (W.collapsed) {
1178
- q < 0 && G(D, "start", void 0, "keyboard");
1179
- return;
1180
- }
1181
- if (q < 0 && j.collapseFromEnd && I.position <= I.resizeLower + L) {
1182
- P(M, "end", "keyboard");
1183
- return;
1184
- }
1185
- if (q > 0 && W.collapseFromStart && I.position >= I.resizeUpper - L) {
1186
- P(D, "start", "keyboard");
1187
- return;
1188
- }
1189
- v(M, D, j.size + q, "keyboard");
1190
- },
1191
- [ee, N, C, v, P, G, O]
1192
- ), ue = typeof c == "object" && c !== null ? c : void 0, je = c === !1 || ue?.visible === !1, te = Math.max(1, Ce(d, ct)), $n = N ? dt : pt, Gn = N ? ht : gt, ge = Math.min(te, Math.max(1, Ce(g ?? ue?.thickness, ut))), we = Math.max(1, Ce(l ?? ue?.length, $n)), Ie = Math.min(ge, Math.max(1, Ce(_ ?? ue?.barThickness, ft))), _e = Math.min(we, Math.max(1, Ce(f ?? ue?.barLength, Gn))), me = R(() => {
1193
- const h = Tn(O), Z = (I) => {
1194
- const re = x[I];
1195
- return re ? re.collapsed || re.size <= h : !1;
1196
- }, F = (I, re) => {
1197
- let ve = 0;
1198
- for (let q = I; q >= 0 && q < x.length && Z(q); q += re)
1199
- ve += 1;
1200
- return ve;
1201
- }, M = x.findIndex((I) => I.id === z.start), D = x.findIndex((I) => I.id === z.end), j = M >= 0 ? F(M, -1) : 0, W = D >= 0 ? F(D, 1) : 0;
1202
- return { groupSize: j + W + 1, overlapIndex: j };
1203
- }, [z.start, z.end, x, O]), ae = R(() => We ? !0 : me.groupSize <= 1 ? !1 : me.overlapIndex > 0 && me.overlapIndex < me.groupSize - 1, [me, We]), Fe = R(() => {
1204
- if (me.groupSize <= 1 || ae)
1205
- return 0;
1206
- const h = fr(Math.max(mt, ge + 4));
1207
- return (me.overlapIndex === 0 ? -0.5 : 0.5) * h;
1208
- }, [me, ae, ge]), Un = R(() => {
1209
- const h = {
1210
- // 長さ 0 のフレックスアイテム: フレックスレイアウトがこれを境界そのものへ配置する
1211
- position: "relative",
1212
- flex: "0 0 0px",
1213
- alignSelf: "stretch",
1214
- // DOM 順を配置順の真実として扱うため、クラス由来の order で並びが変わらないようにする
1215
- order: 0,
1216
- margin: 0,
1217
- overflow: "visible",
1218
- ...N ? { width: 0, minWidth: 0 } : { height: 0, minHeight: 0 }
1219
- };
1220
- return ae ? { ...h, ...dr } : h;
1221
- }, [N, ae]), pn = R(
1222
- () => ({
1223
- "--rp-handle-thickness": `${te}px`,
1224
- "--rp-indicator-thickness": `${ge}px`,
1225
- "--rp-indicator-length": `${we}px`,
1226
- "--rp-indicator-bar-thickness": `${Ie}px`,
1227
- "--rp-indicator-bar-length": `${_e}px`
1228
- }),
1229
- [te, ge, we, Ie, _e]
1230
- ), Wn = R(() => ({
1231
- ...pn,
1232
- ...o,
1233
- // ここから下は境界に載るという前提そのもの。利用者のスタイルやクラスで変わると
1234
- // 操作領域の中心が境界から外れ、touch-action が戻るとタッチではスクロールが優先されてしまう
1235
- position: "absolute",
1236
- zIndex: 20,
1237
- touchAction: "none",
1238
- // 位置は論理プロパティで与える。アンカーは寸法 0 なので RTL でも同じ点に重なるが、
1239
- // 「境界からの距離」という意図をそのまま表せる
1240
- ...N ? { insetBlockStart: 0, insetInlineStart: `${-te / 2}px`, width: `${te}px`, height: "100%" } : { insetInlineStart: 0, insetBlockStart: `${-te / 2}px`, height: `${te}px`, width: "100%" }
1241
- }), [N, te, pn, o]), jn = R(() => {
1242
- if (ae || je)
1243
- return pr;
1244
- const h = {
1245
- width: `${N ? ge : we}px`,
1246
- height: `${N ? we : ge}px`,
1247
- flexShrink: 0
1248
- };
1249
- return Fe !== 0 && (h.position = "relative", N ? h.insetInlineStart = `${Fe}px` : h.insetBlockStart = `${Fe}px`), h;
1250
- }, [ae, je, N, ge, we, Fe]), Vn = R(
1251
- () => ({
1252
- width: `${N ? Ie : _e}px`,
1253
- height: `${N ? _e : Ie}px`,
1254
- flexShrink: 0
1255
- }),
1256
- [N, Ie, _e]
1257
- ), Kn = R(
1258
- () => Me(
1259
- "group absolute z-20 flex select-none items-center justify-center border-none bg-transparent transition-colors duration-150 overflow-visible",
1260
- N ? "cursor-col-resize h-full" : "cursor-row-resize w-full",
1261
- !ee && "hover:bg-gray-200/70 dark:hover:bg-gray-700/70",
1262
- !ee && "active:bg-blue-300/60 dark:active:bg-blue-700/60",
1263
- y && "bg-blue-200/80 dark:bg-blue-800/60",
1264
- ee && "cursor-not-allowed opacity-50",
1265
- "focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50",
1266
- r
1267
- ),
1268
- [N, ee, y, r]
1269
- ), Yn = R(
1270
- () => Me(
1271
- "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)]",
1272
- "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)]",
1273
- y && "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)]",
1274
- ue?.className
1275
- ),
1276
- [y, ue?.className]
1277
- ), qn = R(
1278
- () => Me(
1279
- "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)]",
1280
- y && "bg-blue-500 dark:bg-blue-300",
1281
- !ee && "group-hover:bg-slate-700 dark:group-hover:bg-slate-100",
1282
- ue?.barClassName
1283
- ),
1284
- [y, ee, ue?.barClassName]
1285
- );
1286
- Q(() => {
1287
- if (be === Re.current)
1288
- return;
1289
- const h = Re.current;
1290
- Re.current = be, se.current = null, T(h, null);
1291
- }, [T, be]), Q(() => {
1292
- const h = {
1293
- id: be,
1294
- thickness: ae ? 0 : te,
1295
- direction: $,
1296
- visible: !ae && te > zt,
1297
- startPanelId: z.start,
1298
- endPanelId: z.end
1299
- };
1300
- se.current = h, T(be, h);
1301
- }, [be, te, ae, $, z.start, z.end, T]), Q(() => () => {
1302
- T(Re.current, null);
1303
- }, [T]);
1304
- const Xn = k(
1305
- (h) => {
1306
- V?.(h), h.defaultPrevented || un(h);
1307
- },
1308
- [V, un]
1309
- ), Zn = k(
1310
- (h) => {
1311
- ce?.(h), h.defaultPrevented || dn(h);
1312
- },
1313
- [ce, dn]
1314
- ), Jn = b.length > 0 ? "click to cycle through preset sizes, " : "", fn = `Resize ${N ? "columns" : "rows"} - Drag or use arrow keys to resize, ${Jn}drag to the edge to collapse/expand panels`, Ve = R(() => {
1315
- const h = z.start === null ? void 0 : C(z.start), Z = z.end === null ? void 0 : C(z.end);
1316
- if (!(h && Z) || O <= 0)
1317
- return;
1318
- const F = Qe(h, Z, O);
1319
- if (!F)
1320
- return;
1321
- const M = (D) => Math.round(D / O * 100);
1322
- return { now: M(F.position), min: M(F.lower), max: M(F.upper) };
1323
- }, [z.start, z.end, C, O]);
1324
- return /* @__PURE__ */ oe("div", { ref: ie, style: Un, "data-resize-handle-anchor": "", children: /* @__PURE__ */ oe(
1325
- "button",
1326
- {
1327
- ...w,
1328
- type: "button",
1329
- ref: u,
1330
- className: Kn,
1331
- style: Wn,
1332
- onPointerDown: Xn,
1333
- onKeyDown: Zn,
1334
- disabled: ee,
1335
- role: "separator",
1336
- "aria-orientation": N ? "vertical" : "horizontal",
1337
- "aria-valuenow": Ve?.now,
1338
- "aria-valuemin": Ve?.min,
1339
- "aria-valuemax": Ve?.max,
1340
- "aria-disabled": ee || void 0,
1341
- "aria-hidden": ae || void 0,
1342
- "aria-label": w["aria-label"] ?? fn,
1343
- "data-resize-handle-id": be,
1344
- title: H ?? fn,
1345
- children: i || !je && /* @__PURE__ */ oe("div", { className: Yn, style: jn, "data-resize-handle-indicator": "", "aria-hidden": "true", children: /* @__PURE__ */ oe("span", { className: qn, style: Vn, "data-resize-handle-indicator-bar": "", "aria-hidden": "true" }) })
1346
- }
1347
- ) });
1348
- }), ln = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), Rr = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-id="${ln(e)}"]`), Ir = (e) => typeof document > "u" ? null : document.querySelector(`[data-panel-group-id="${ln(e)}"]`), _r = (e) => typeof document > "u" ? null : document.querySelector(`[data-resize-handle-id="${ln(e)}"]`);
1349
- export {
1350
- an as A,
1351
- Jt as B,
1352
- lt as P,
1353
- wr as a,
1354
- vr as b,
1355
- Bn as c,
1356
- Nr as d,
1357
- Dt as e,
1358
- Tn as f,
1359
- De as g,
1360
- Ft as h,
1361
- Be as i,
1362
- en as j,
1363
- Oe as k,
1364
- Fn as l,
1365
- Rr as m,
1366
- Ir as n,
1367
- $t as o,
1368
- _r as p,
1369
- Tt as q,
1370
- ne as r,
1371
- _t as s,
1372
- wt as t,
1373
- Ut as u,
1374
- Pr as v,
1375
- Ee as w,
1376
- vn as x,
1377
- On as y,
1378
- Er as z
1379
- };