@principal-ade/panel-layouts 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +40 -0
- package/dist/index.esm.js +292 -232
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import './index.css';var
|
|
2
|
-
var F = (
|
|
3
|
-
var
|
|
4
|
-
import { EditableConfigurablePanelLayout as
|
|
5
|
-
import { useState as
|
|
1
|
+
import './index.css';var x = Object.defineProperty;
|
|
2
|
+
var F = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var z = (l, e, t) => F(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { EditableConfigurablePanelLayout as G, ResponsiveConfigurablePanelLayout as Q, mapThemeToPanelVars as H, mapThemeToTabVars as U } from "@principal-ade/panels";
|
|
5
|
+
import { useState as C, useRef as I, useEffect as T, useCallback as f } from "react";
|
|
6
6
|
import { jsx as O } from "react/jsx-runtime";
|
|
7
7
|
class $ {
|
|
8
8
|
constructor() {
|
|
9
|
-
|
|
9
|
+
z(this, "storageKey", "panel-layouts");
|
|
10
10
|
}
|
|
11
11
|
async load(e) {
|
|
12
12
|
try {
|
|
@@ -27,46 +27,46 @@ class $ {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function _(
|
|
30
|
+
function _(l) {
|
|
31
31
|
const {
|
|
32
32
|
viewKey: e,
|
|
33
33
|
defaultSizes: t,
|
|
34
34
|
panelType: a,
|
|
35
35
|
adapter: s = new $()
|
|
36
|
-
} =
|
|
37
|
-
|
|
36
|
+
} = l, [i, o] = C(t), [c, R] = C(l.collapsed), h = I(l.collapsed), P = I({}), w = I(null), m = I(null);
|
|
37
|
+
T(() => {
|
|
38
38
|
(async () => {
|
|
39
39
|
const g = await s.load(e);
|
|
40
|
-
g != null && g.sizes && (
|
|
40
|
+
g != null && g.sizes && (o(g.sizes), k(g.sizes));
|
|
41
41
|
})();
|
|
42
42
|
}, [e]);
|
|
43
|
-
const
|
|
44
|
-
(
|
|
45
|
-
"left" in
|
|
43
|
+
const k = f(
|
|
44
|
+
(n) => {
|
|
45
|
+
"left" in n && n.left > 0 && (P.current.left = n.left), "middle" in n && n.middle > 0 && (P.current.middle = n.middle), "right" in n && n.right > 0 && (P.current.right = n.right);
|
|
46
46
|
},
|
|
47
47
|
[]
|
|
48
|
-
),
|
|
49
|
-
(
|
|
50
|
-
const g =
|
|
48
|
+
), d = f(
|
|
49
|
+
(n) => {
|
|
50
|
+
const g = P.current[n];
|
|
51
51
|
if (g && g > 0)
|
|
52
52
|
return g;
|
|
53
|
-
if (
|
|
53
|
+
if (n === "left" && "left" in t && t.left > 0)
|
|
54
54
|
return t.left;
|
|
55
|
-
if (
|
|
55
|
+
if (n === "right" && "right" in t && t.right > 0)
|
|
56
56
|
return t.right;
|
|
57
57
|
},
|
|
58
58
|
[t]
|
|
59
|
-
),
|
|
60
|
-
|
|
61
|
-
("left" in t && t.left !==
|
|
62
|
-
}, [t,
|
|
63
|
-
const
|
|
64
|
-
(
|
|
65
|
-
}, [
|
|
66
|
-
const
|
|
67
|
-
async (
|
|
59
|
+
), r = I(t);
|
|
60
|
+
T(() => {
|
|
61
|
+
("left" in t && t.left !== r.current.left || "middle" in t && "middle" in r.current && t.middle !== r.current.middle || "right" in t && t.right !== r.current.right) && (o(t), k(t), r.current = t);
|
|
62
|
+
}, [t, k]), T(() => {
|
|
63
|
+
const n = l.collapsed.left !== h.current.left, g = "right" in l.collapsed && "right" in h.current && l.collapsed.right !== h.current.right;
|
|
64
|
+
(n || g) && (R(l.collapsed), h.current = { ...l.collapsed });
|
|
65
|
+
}, [l.collapsed.left, l.collapsed.right]);
|
|
66
|
+
const y = f(
|
|
67
|
+
async (n) => {
|
|
68
68
|
try {
|
|
69
|
-
await s.save(e, { sizes:
|
|
69
|
+
await s.save(e, { sizes: n });
|
|
70
70
|
} catch (g) {
|
|
71
71
|
console.error(
|
|
72
72
|
`Failed to save panel preferences for ${e}:`,
|
|
@@ -75,74 +75,74 @@ function _(n) {
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
[e, s]
|
|
78
|
-
),
|
|
79
|
-
(
|
|
80
|
-
const g = { ...
|
|
81
|
-
let
|
|
82
|
-
if ("left" in
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
} else
|
|
78
|
+
), W = f(
|
|
79
|
+
(n) => {
|
|
80
|
+
const g = { ...n };
|
|
81
|
+
let u = !0;
|
|
82
|
+
if ("left" in n) {
|
|
83
|
+
const p = !!(c != null && c.left), b = n.left;
|
|
84
|
+
if (p) {
|
|
85
|
+
const v = d("left");
|
|
86
|
+
v !== void 0 && v > 0 ? g.left = v : u = !1;
|
|
87
|
+
} else b === 0 && (u = !1);
|
|
88
88
|
}
|
|
89
|
-
if (a === "three-panel" && "right" in
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
} else
|
|
89
|
+
if (a === "three-panel" && "right" in n) {
|
|
90
|
+
const p = !!(c != null && c.right), b = n.right;
|
|
91
|
+
if (p) {
|
|
92
|
+
const v = d("right");
|
|
93
|
+
v !== void 0 && v > 0 ? g.right = v : u = !1;
|
|
94
|
+
} else b === 0 && (u = !1);
|
|
95
95
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
96
|
+
if (o(g), k(g), w.current && (clearTimeout(w.current), w.current = null), !u) {
|
|
97
|
+
m.current = null;
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
100
|
+
m.current = g, w.current = setTimeout(() => {
|
|
101
|
+
const p = m.current;
|
|
102
|
+
p && (y(p), m.current = null), w.current = null;
|
|
103
103
|
}, 500);
|
|
104
104
|
},
|
|
105
105
|
[
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
c,
|
|
107
|
+
d,
|
|
108
108
|
a,
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
y,
|
|
110
|
+
k
|
|
111
111
|
]
|
|
112
112
|
);
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
const
|
|
116
|
-
|
|
113
|
+
T(() => () => {
|
|
114
|
+
if (w.current) {
|
|
115
|
+
const n = m.current;
|
|
116
|
+
n && (y(n), m.current = null), clearTimeout(w.current), w.current = null;
|
|
117
117
|
}
|
|
118
|
-
}, [
|
|
119
|
-
const
|
|
120
|
-
}, []), E =
|
|
121
|
-
}, []), L =
|
|
122
|
-
}, []),
|
|
118
|
+
}, [y]);
|
|
119
|
+
const A = f(async () => {
|
|
120
|
+
}, []), E = f(async () => {
|
|
121
|
+
}, []), L = f(async () => {
|
|
122
|
+
}, []), D = f(async () => {
|
|
123
123
|
}, []);
|
|
124
124
|
return a === "three-panel" ? {
|
|
125
125
|
type: "three-panel",
|
|
126
|
-
sizes:
|
|
127
|
-
collapsed:
|
|
128
|
-
handlePanelResize:
|
|
129
|
-
handleLeftCollapseComplete:
|
|
126
|
+
sizes: i,
|
|
127
|
+
collapsed: c,
|
|
128
|
+
handlePanelResize: W,
|
|
129
|
+
handleLeftCollapseComplete: A,
|
|
130
130
|
handleLeftExpandComplete: E,
|
|
131
131
|
handleRightCollapseComplete: L,
|
|
132
|
-
handleRightExpandComplete:
|
|
132
|
+
handleRightExpandComplete: D
|
|
133
133
|
} : {
|
|
134
134
|
type: "two-panel",
|
|
135
|
-
sizes:
|
|
136
|
-
collapsed:
|
|
137
|
-
handlePanelResize:
|
|
138
|
-
handleLeftCollapseComplete:
|
|
135
|
+
sizes: i,
|
|
136
|
+
collapsed: c,
|
|
137
|
+
handlePanelResize: W,
|
|
138
|
+
handleLeftCollapseComplete: A,
|
|
139
139
|
handleLeftExpandComplete: E
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
class N {
|
|
143
143
|
constructor() {
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
z(this, "PRESETS_KEY", "panel-layouts:workspace-presets");
|
|
145
|
+
z(this, "REPO_STATE_PREFIX", "panel-layouts:repo-state:");
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* Load all user-created workspace presets
|
|
@@ -202,14 +202,14 @@ class N {
|
|
|
202
202
|
for (let t = 0; t < localStorage.length; t++) {
|
|
203
203
|
const a = localStorage.key(t);
|
|
204
204
|
if (a && a.startsWith(this.REPO_STATE_PREFIX)) {
|
|
205
|
-
const s = a.substring(this.REPO_STATE_PREFIX.length),
|
|
206
|
-
if (
|
|
205
|
+
const s = a.substring(this.REPO_STATE_PREFIX.length), i = localStorage.getItem(a);
|
|
206
|
+
if (i)
|
|
207
207
|
try {
|
|
208
|
-
e[s] = JSON.parse(
|
|
209
|
-
} catch (
|
|
208
|
+
e[s] = JSON.parse(i);
|
|
209
|
+
} catch (o) {
|
|
210
210
|
console.error(
|
|
211
211
|
`Failed to parse repository state for ${s}:`,
|
|
212
|
-
|
|
212
|
+
o
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -220,7 +220,7 @@ class N {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class
|
|
223
|
+
class S {
|
|
224
224
|
/**
|
|
225
225
|
* Configure a custom storage adapter (for Electron IPC or remote storage)
|
|
226
226
|
*/
|
|
@@ -257,11 +257,11 @@ class m {
|
|
|
257
257
|
createdAt: Date.now(),
|
|
258
258
|
updatedAt: Date.now(),
|
|
259
259
|
isBuiltIn: !1
|
|
260
|
-
},
|
|
260
|
+
}, i = {
|
|
261
261
|
...t,
|
|
262
262
|
[a]: s
|
|
263
263
|
};
|
|
264
|
-
return await this.adapter.saveWorkspacePresets(
|
|
264
|
+
return await this.adapter.saveWorkspacePresets(i), s;
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
267
|
* Update an existing workspace layout
|
|
@@ -272,7 +272,7 @@ class m {
|
|
|
272
272
|
return console.error(`Workspace layout ${e} not found`), null;
|
|
273
273
|
if (s.isBuiltIn)
|
|
274
274
|
return console.error(`Cannot update built-in workspace layout ${e}`), null;
|
|
275
|
-
const
|
|
275
|
+
const i = {
|
|
276
276
|
...s,
|
|
277
277
|
...t,
|
|
278
278
|
id: e,
|
|
@@ -280,11 +280,11 @@ class m {
|
|
|
280
280
|
createdAt: s.createdAt,
|
|
281
281
|
// Preserve creation time
|
|
282
282
|
updatedAt: Date.now()
|
|
283
|
-
},
|
|
283
|
+
}, o = {
|
|
284
284
|
...a,
|
|
285
|
-
[e]:
|
|
285
|
+
[e]: i
|
|
286
286
|
};
|
|
287
|
-
return await this.adapter.saveWorkspacePresets(
|
|
287
|
+
return await this.adapter.saveWorkspacePresets(o), i;
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
290
|
* Delete a workspace layout
|
|
@@ -609,242 +609,301 @@ class m {
|
|
|
609
609
|
Object.keys(e).length;
|
|
610
610
|
}
|
|
611
611
|
}
|
|
612
|
-
|
|
613
|
-
function K(
|
|
614
|
-
const { repositoryKey: e, autoInitialize: t = !1, defaultWorkspaceId: a } =
|
|
612
|
+
z(S, "adapter", new N());
|
|
613
|
+
function K(l = {}) {
|
|
614
|
+
const { repositoryKey: e, autoInitialize: t = !1, defaultWorkspaceId: a } = l, [s, i] = C(
|
|
615
615
|
{}
|
|
616
|
-
), [
|
|
616
|
+
), [o, c] = C(null), [R, h] = C(null), [P, w] = C(!0), [m, k] = C(null), d = f(async () => {
|
|
617
617
|
try {
|
|
618
|
-
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
let
|
|
622
|
-
if (!
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
workspaceId:
|
|
626
|
-
sizes:
|
|
618
|
+
w(!0), k(null);
|
|
619
|
+
const u = await S.getWorkspaceLayouts();
|
|
620
|
+
if (i(u), e) {
|
|
621
|
+
let p = await S.getRepositoryState(e);
|
|
622
|
+
if (!p && t) {
|
|
623
|
+
const b = a || "project-management", v = await S.getWorkspaceLayout(b);
|
|
624
|
+
v && (p = {
|
|
625
|
+
workspaceId: b,
|
|
626
|
+
sizes: v.defaultSizes || {
|
|
627
627
|
left: 20,
|
|
628
628
|
middle: 45,
|
|
629
629
|
right: 35
|
|
630
630
|
},
|
|
631
|
-
collapsed:
|
|
631
|
+
collapsed: v.defaultCollapsed || {
|
|
632
632
|
left: !1,
|
|
633
633
|
right: !1
|
|
634
634
|
}
|
|
635
|
-
}, await
|
|
635
|
+
}, await S.setRepositoryState(
|
|
636
636
|
e,
|
|
637
|
-
|
|
637
|
+
p
|
|
638
638
|
));
|
|
639
639
|
}
|
|
640
|
-
if (
|
|
641
|
-
const
|
|
642
|
-
|
|
640
|
+
if (c(p), p != null && p.workspaceId) {
|
|
641
|
+
const b = await S.getWorkspaceLayout(
|
|
642
|
+
p.workspaceId
|
|
643
643
|
);
|
|
644
|
-
|
|
644
|
+
h(b);
|
|
645
645
|
} else
|
|
646
|
-
|
|
646
|
+
h(null);
|
|
647
647
|
}
|
|
648
|
-
} catch (
|
|
649
|
-
|
|
648
|
+
} catch (u) {
|
|
649
|
+
k(u), console.error("Failed to load workspace data:", u);
|
|
650
650
|
} finally {
|
|
651
|
-
|
|
651
|
+
w(!1);
|
|
652
652
|
}
|
|
653
653
|
}, [e, t, a]);
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}, [
|
|
657
|
-
const
|
|
658
|
-
async (
|
|
654
|
+
T(() => {
|
|
655
|
+
d();
|
|
656
|
+
}, [d]);
|
|
657
|
+
const r = f(
|
|
658
|
+
async (u) => await S.getWorkspaceLayout(u),
|
|
659
659
|
[]
|
|
660
|
-
),
|
|
661
|
-
async (
|
|
662
|
-
const
|
|
663
|
-
return await
|
|
660
|
+
), y = f(
|
|
661
|
+
async (u) => {
|
|
662
|
+
const p = await S.createWorkspaceLayout(u);
|
|
663
|
+
return await d(), p;
|
|
664
664
|
},
|
|
665
|
-
[
|
|
666
|
-
),
|
|
667
|
-
async (
|
|
668
|
-
const
|
|
669
|
-
return await
|
|
665
|
+
[d]
|
|
666
|
+
), W = f(
|
|
667
|
+
async (u, p) => {
|
|
668
|
+
const b = await S.updateWorkspaceLayout(u, p);
|
|
669
|
+
return await d(), b;
|
|
670
670
|
},
|
|
671
|
-
[
|
|
672
|
-
),
|
|
673
|
-
async (
|
|
674
|
-
const
|
|
675
|
-
return
|
|
671
|
+
[d]
|
|
672
|
+
), A = f(
|
|
673
|
+
async (u) => {
|
|
674
|
+
const p = await S.deleteWorkspaceLayout(u);
|
|
675
|
+
return p && await d(), p;
|
|
676
676
|
},
|
|
677
|
-
[
|
|
678
|
-
), E =
|
|
679
|
-
async (
|
|
677
|
+
[d]
|
|
678
|
+
), E = f(
|
|
679
|
+
async (u) => {
|
|
680
680
|
if (!e) {
|
|
681
681
|
console.error("Cannot apply workspace without repositoryKey");
|
|
682
682
|
return;
|
|
683
683
|
}
|
|
684
|
-
const
|
|
685
|
-
if (!
|
|
686
|
-
console.error(`Workspace ${
|
|
684
|
+
const p = await S.getWorkspaceLayout(u);
|
|
685
|
+
if (!p) {
|
|
686
|
+
console.error(`Workspace ${u} not found`);
|
|
687
687
|
return;
|
|
688
688
|
}
|
|
689
|
-
const
|
|
690
|
-
workspaceId:
|
|
691
|
-
sizes:
|
|
692
|
-
collapsed:
|
|
689
|
+
const b = {
|
|
690
|
+
workspaceId: u,
|
|
691
|
+
sizes: p.defaultSizes || { left: 20, middle: 45, right: 35 },
|
|
692
|
+
collapsed: p.defaultCollapsed || {
|
|
693
693
|
left: !1,
|
|
694
694
|
right: !1
|
|
695
695
|
}
|
|
696
696
|
};
|
|
697
|
-
await
|
|
697
|
+
await S.setRepositoryState(e, b), await d();
|
|
698
698
|
},
|
|
699
|
-
[e,
|
|
700
|
-
), L =
|
|
701
|
-
async (
|
|
699
|
+
[e, d]
|
|
700
|
+
), L = f(
|
|
701
|
+
async (u) => {
|
|
702
702
|
if (!e) {
|
|
703
703
|
console.error("Cannot update sizes without repositoryKey");
|
|
704
704
|
return;
|
|
705
705
|
}
|
|
706
|
-
await
|
|
706
|
+
await S.updateRepositorySizes(e, u), await d();
|
|
707
707
|
},
|
|
708
|
-
[e,
|
|
709
|
-
),
|
|
710
|
-
async (
|
|
708
|
+
[e, d]
|
|
709
|
+
), D = f(
|
|
710
|
+
async (u) => {
|
|
711
711
|
if (!e) {
|
|
712
712
|
console.error("Cannot update collapsed without repositoryKey");
|
|
713
713
|
return;
|
|
714
714
|
}
|
|
715
|
-
await
|
|
715
|
+
await S.updateRepositoryCollapsed(
|
|
716
716
|
e,
|
|
717
|
-
|
|
718
|
-
), await
|
|
717
|
+
u
|
|
718
|
+
), await d();
|
|
719
719
|
},
|
|
720
|
-
[e,
|
|
721
|
-
),
|
|
722
|
-
if (!e || !(
|
|
720
|
+
[e, d]
|
|
721
|
+
), n = f(async () => {
|
|
722
|
+
if (!e || !(o != null && o.workspaceId)) {
|
|
723
723
|
console.error("Cannot reset without repositoryKey and active workspace");
|
|
724
724
|
return;
|
|
725
725
|
}
|
|
726
|
-
await
|
|
726
|
+
await S.resetRepositoryToWorkspaceDefaults(
|
|
727
727
|
e,
|
|
728
|
-
|
|
729
|
-
), await
|
|
730
|
-
}, [e,
|
|
731
|
-
await
|
|
732
|
-
}, [
|
|
728
|
+
o.workspaceId
|
|
729
|
+
), await d();
|
|
730
|
+
}, [e, o == null ? void 0 : o.workspaceId, d]), g = f(async () => {
|
|
731
|
+
await d();
|
|
732
|
+
}, [d]);
|
|
733
733
|
return {
|
|
734
734
|
workspaces: s,
|
|
735
|
-
repositoryState:
|
|
736
|
-
activeWorkspace:
|
|
737
|
-
loading:
|
|
738
|
-
error:
|
|
739
|
-
getWorkspace:
|
|
740
|
-
createWorkspace:
|
|
741
|
-
updateWorkspace:
|
|
742
|
-
deleteWorkspace:
|
|
735
|
+
repositoryState: o,
|
|
736
|
+
activeWorkspace: R,
|
|
737
|
+
loading: P,
|
|
738
|
+
error: m,
|
|
739
|
+
getWorkspace: r,
|
|
740
|
+
createWorkspace: y,
|
|
741
|
+
updateWorkspace: W,
|
|
742
|
+
deleteWorkspace: A,
|
|
743
743
|
applyWorkspace: E,
|
|
744
744
|
updateSizes: L,
|
|
745
|
-
updateCollapsed:
|
|
746
|
-
resetToDefaults:
|
|
745
|
+
updateCollapsed: D,
|
|
746
|
+
resetToDefaults: n,
|
|
747
747
|
refresh: g
|
|
748
748
|
};
|
|
749
749
|
}
|
|
750
|
-
function j(
|
|
750
|
+
function j(l = {}) {
|
|
751
751
|
const {
|
|
752
752
|
initialFocus: e = null,
|
|
753
753
|
collapsed: t = {},
|
|
754
754
|
panelType: a = "three-panel",
|
|
755
|
-
onFocusChange: s
|
|
756
|
-
|
|
755
|
+
onFocusChange: s,
|
|
756
|
+
events: i,
|
|
757
|
+
getPanelId: o
|
|
758
|
+
} = l, [c, R] = C(
|
|
757
759
|
e
|
|
758
|
-
),
|
|
760
|
+
), h = f(
|
|
759
761
|
(r) => {
|
|
760
|
-
|
|
762
|
+
const y = c;
|
|
763
|
+
if (R(r), s == null || s(r), i && o) {
|
|
764
|
+
if (y) {
|
|
765
|
+
const A = o(y);
|
|
766
|
+
A && i.emit({
|
|
767
|
+
type: "panel:blur",
|
|
768
|
+
source: "panel-layouts",
|
|
769
|
+
timestamp: Date.now(),
|
|
770
|
+
payload: {
|
|
771
|
+
panelId: A,
|
|
772
|
+
panelSlot: y,
|
|
773
|
+
nextPanelId: o(r)
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
const W = o(r);
|
|
778
|
+
W && i.emit({
|
|
779
|
+
type: "panel:focus",
|
|
780
|
+
source: "panel-layouts",
|
|
781
|
+
timestamp: Date.now(),
|
|
782
|
+
payload: {
|
|
783
|
+
panelId: W,
|
|
784
|
+
panelSlot: r,
|
|
785
|
+
source: "keyboard-shortcut"
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
}
|
|
761
789
|
},
|
|
762
|
-
[s]
|
|
763
|
-
),
|
|
764
|
-
|
|
765
|
-
|
|
790
|
+
[c, s, i, o]
|
|
791
|
+
), P = f(() => {
|
|
792
|
+
const r = c;
|
|
793
|
+
if (R(null), s == null || s(null), i && o && r) {
|
|
794
|
+
const y = o(r);
|
|
795
|
+
y && i.emit({
|
|
796
|
+
type: "panel:blur",
|
|
797
|
+
source: "panel-layouts",
|
|
798
|
+
timestamp: Date.now(),
|
|
799
|
+
payload: {
|
|
800
|
+
panelId: y,
|
|
801
|
+
panelSlot: r
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
}, [c, s, i, o]), w = f(() => {
|
|
766
806
|
const r = [];
|
|
767
807
|
return t.left || r.push("left"), r.push("middle"), a === "three-panel" && !t.right && r.push("right"), r;
|
|
768
|
-
}, [t, a]),
|
|
808
|
+
}, [t, a]), m = f(() => {
|
|
769
809
|
const r = w();
|
|
770
810
|
if (r.length === 0) return;
|
|
771
|
-
if (
|
|
772
|
-
|
|
811
|
+
if (c === null) {
|
|
812
|
+
h(r[0]);
|
|
773
813
|
return;
|
|
774
814
|
}
|
|
775
|
-
const
|
|
776
|
-
if (
|
|
777
|
-
|
|
815
|
+
const y = r.indexOf(c);
|
|
816
|
+
if (y === -1) {
|
|
817
|
+
h(r[0]);
|
|
778
818
|
return;
|
|
779
819
|
}
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
}, [
|
|
820
|
+
const W = (y + 1) % r.length;
|
|
821
|
+
h(r[W]);
|
|
822
|
+
}, [c, w, h]), k = f(() => {
|
|
783
823
|
const r = w();
|
|
784
824
|
if (r.length === 0) return;
|
|
785
|
-
if (
|
|
786
|
-
|
|
825
|
+
if (c === null) {
|
|
826
|
+
h(r[r.length - 1]);
|
|
787
827
|
return;
|
|
788
828
|
}
|
|
789
|
-
const
|
|
790
|
-
if (
|
|
791
|
-
|
|
829
|
+
const y = r.indexOf(c);
|
|
830
|
+
if (y === -1) {
|
|
831
|
+
h(r[r.length - 1]);
|
|
792
832
|
return;
|
|
793
833
|
}
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
}, [
|
|
797
|
-
(r) =>
|
|
798
|
-
[
|
|
834
|
+
const W = y === 0 ? r.length - 1 : y - 1;
|
|
835
|
+
h(r[W]);
|
|
836
|
+
}, [c, w, h]), d = f(
|
|
837
|
+
(r) => c === r,
|
|
838
|
+
[c]
|
|
799
839
|
);
|
|
800
840
|
return {
|
|
801
|
-
focusedPanel:
|
|
802
|
-
setFocus:
|
|
803
|
-
clearFocus:
|
|
804
|
-
focusNext:
|
|
805
|
-
focusPrevious:
|
|
806
|
-
isFocused:
|
|
841
|
+
focusedPanel: c,
|
|
842
|
+
setFocus: h,
|
|
843
|
+
clearFocus: P,
|
|
844
|
+
focusNext: m,
|
|
845
|
+
focusPrevious: k,
|
|
846
|
+
isFocused: d
|
|
807
847
|
};
|
|
808
848
|
}
|
|
809
|
-
function q(
|
|
849
|
+
function q(l) {
|
|
810
850
|
const {
|
|
811
851
|
enabled: e = !0,
|
|
812
852
|
focusedPanel: t,
|
|
813
853
|
collapsed: a,
|
|
814
854
|
panelType: s,
|
|
815
|
-
setFocus:
|
|
816
|
-
onExpand:
|
|
817
|
-
onCollapse:
|
|
818
|
-
} =
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}, [t]),
|
|
822
|
-
|
|
823
|
-
}, [a]),
|
|
824
|
-
|
|
855
|
+
setFocus: i,
|
|
856
|
+
onExpand: o,
|
|
857
|
+
onCollapse: c
|
|
858
|
+
} = l, R = I(t), h = I(a), P = I(s);
|
|
859
|
+
T(() => {
|
|
860
|
+
R.current = t;
|
|
861
|
+
}, [t]), T(() => {
|
|
862
|
+
h.current = a;
|
|
863
|
+
}, [a]), T(() => {
|
|
864
|
+
P.current = s;
|
|
825
865
|
}, [s]);
|
|
826
|
-
const
|
|
827
|
-
(
|
|
828
|
-
if (!
|
|
866
|
+
const w = f(
|
|
867
|
+
(m) => {
|
|
868
|
+
if (!m.altKey || m.ctrlKey || m.metaKey || m.shiftKey)
|
|
829
869
|
return;
|
|
830
|
-
const
|
|
831
|
-
|
|
870
|
+
const k = m.code, d = R.current, r = h.current, y = P.current;
|
|
871
|
+
k === "Digit1" || k === "Numpad1" ? (m.preventDefault(), r.left ? o("left") : d !== "left" ? i("left") : (c("left"), i("middle"))) : k === "Digit2" || k === "Numpad2" ? (m.preventDefault(), i("middle")) : (k === "Digit3" || k === "Numpad3") && y === "three-panel" && (m.preventDefault(), r.right ? o("right") : d !== "right" ? i("right") : (c("right"), i("middle")));
|
|
832
872
|
},
|
|
833
|
-
[
|
|
873
|
+
[i, o, c]
|
|
834
874
|
);
|
|
835
|
-
|
|
875
|
+
T(() => {
|
|
836
876
|
if (e)
|
|
837
|
-
return window.addEventListener("keydown",
|
|
838
|
-
window.removeEventListener("keydown",
|
|
877
|
+
return window.addEventListener("keydown", w), () => {
|
|
878
|
+
window.removeEventListener("keydown", w);
|
|
839
879
|
};
|
|
840
|
-
}, [e,
|
|
880
|
+
}, [e, w]);
|
|
881
|
+
}
|
|
882
|
+
function X(l, e, t, a) {
|
|
883
|
+
T(() => {
|
|
884
|
+
const s = e.on(
|
|
885
|
+
"panel:focus",
|
|
886
|
+
(o) => {
|
|
887
|
+
o.payload.panelId === l && t();
|
|
888
|
+
}
|
|
889
|
+
);
|
|
890
|
+
let i;
|
|
891
|
+
return a && (i = e.on(
|
|
892
|
+
"panel:blur",
|
|
893
|
+
(o) => {
|
|
894
|
+
o.payload.panelId === l && a();
|
|
895
|
+
}
|
|
896
|
+
)), () => {
|
|
897
|
+
s(), i == null || i();
|
|
898
|
+
};
|
|
899
|
+
}, [l, e, t, a]);
|
|
841
900
|
}
|
|
842
|
-
const
|
|
843
|
-
isFocused:
|
|
901
|
+
const M = ({
|
|
902
|
+
isFocused: l,
|
|
844
903
|
className: e = "",
|
|
845
904
|
style: t = {}
|
|
846
905
|
}) => {
|
|
847
|
-
if (!
|
|
906
|
+
if (!l)
|
|
848
907
|
return null;
|
|
849
908
|
const a = {
|
|
850
909
|
position: "absolute",
|
|
@@ -871,15 +930,16 @@ const X = ({
|
|
|
871
930
|
);
|
|
872
931
|
};
|
|
873
932
|
export {
|
|
874
|
-
|
|
875
|
-
|
|
933
|
+
G as EditableConfigurablePanelLayout,
|
|
934
|
+
M as FocusIndicator,
|
|
876
935
|
$ as LocalStoragePersistenceAdapter,
|
|
877
936
|
N as LocalStorageWorkspaceAdapter,
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
937
|
+
Q as ResponsiveConfigurablePanelLayout,
|
|
938
|
+
S as WorkspaceLayoutService,
|
|
939
|
+
H as mapThemeToPanelVars,
|
|
940
|
+
U as mapThemeToTabVars,
|
|
882
941
|
j as usePanelFocus,
|
|
942
|
+
X as usePanelFocusListener,
|
|
883
943
|
q as usePanelKeyboardShortcuts,
|
|
884
944
|
_ as usePanelPersistence,
|
|
885
945
|
K as useWorkspace
|