@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.esm.js CHANGED
@@ -1,12 +1,12 @@
1
- import './index.css';var D = Object.defineProperty;
2
- var F = (n, e, t) => e in n ? D(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var A = (n, e, t) => F(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { EditableConfigurablePanelLayout as Z, ResponsiveConfigurablePanelLayout as G, mapThemeToPanelVars as Q, mapThemeToTabVars as H } from "@principal-ade/panels";
5
- import { useState as R, useRef as C, useEffect as P, useCallback as p } from "react";
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
- A(this, "storageKey", "panel-layouts");
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 _(n) {
30
+ function _(l) {
31
31
  const {
32
32
  viewKey: e,
33
33
  defaultSizes: t,
34
34
  panelType: a,
35
35
  adapter: s = new $()
36
- } = n, [l, f] = R(t), [u, v] = R(n.collapsed), w = C(n.collapsed), b = C({}), h = C(null), y = C(null);
37
- P(() => {
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 && (f(g.sizes), r(g.sizes));
40
+ g != null && g.sizes && (o(g.sizes), k(g.sizes));
41
41
  })();
42
42
  }, [e]);
43
- const r = p(
44
- (i) => {
45
- "left" in i && i.left > 0 && (b.current.left = i.left), "middle" in i && i.middle > 0 && (b.current.middle = i.middle), "right" in i && i.right > 0 && (b.current.right = i.right);
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
- ), o = p(
49
- (i) => {
50
- const g = b.current[i];
48
+ ), d = f(
49
+ (n) => {
50
+ const g = P.current[n];
51
51
  if (g && g > 0)
52
52
  return g;
53
- if (i === "left" && "left" in t && t.left > 0)
53
+ if (n === "left" && "left" in t && t.left > 0)
54
54
  return t.left;
55
- if (i === "right" && "right" in t && t.right > 0)
55
+ if (n === "right" && "right" in t && t.right > 0)
56
56
  return t.right;
57
57
  },
58
58
  [t]
59
- ), k = C(t);
60
- P(() => {
61
- ("left" in t && t.left !== k.current.left || "middle" in t && "middle" in k.current && t.middle !== k.current.middle || "right" in t && t.right !== k.current.right) && (f(t), r(t), k.current = t);
62
- }, [t, r]), P(() => {
63
- const i = n.collapsed.left !== w.current.left, g = "right" in n.collapsed && "right" in w.current && n.collapsed.right !== w.current.right;
64
- (i || g) && (v(n.collapsed), w.current = { ...n.collapsed });
65
- }, [n.collapsed.left, n.collapsed.right]);
66
- const T = p(
67
- async (i) => {
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: i });
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
- ), z = p(
79
- (i) => {
80
- const g = { ...i };
81
- let c = !0;
82
- if ("left" in i) {
83
- const d = !!(u != null && u.left), S = i.left;
84
- if (d) {
85
- const W = o("left");
86
- W !== void 0 && W > 0 ? g.left = W : c = !1;
87
- } else S === 0 && (c = !1);
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 i) {
90
- const d = !!(u != null && u.right), S = i.right;
91
- if (d) {
92
- const W = o("right");
93
- W !== void 0 && W > 0 ? g.right = W : c = !1;
94
- } else S === 0 && (c = !1);
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 (f(g), r(g), h.current && (clearTimeout(h.current), h.current = null), !c) {
97
- y.current = null;
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
- y.current = g, h.current = setTimeout(() => {
101
- const d = y.current;
102
- d && (T(d), y.current = null), h.current = null;
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
- u,
107
- o,
106
+ c,
107
+ d,
108
108
  a,
109
- T,
110
- r
109
+ y,
110
+ k
111
111
  ]
112
112
  );
113
- P(() => () => {
114
- if (h.current) {
115
- const i = y.current;
116
- i && (T(i), y.current = null), clearTimeout(h.current), h.current = null;
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
- }, [T]);
119
- const I = p(async () => {
120
- }, []), E = p(async () => {
121
- }, []), L = p(async () => {
122
- }, []), x = p(async () => {
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: l,
127
- collapsed: u,
128
- handlePanelResize: z,
129
- handleLeftCollapseComplete: I,
126
+ sizes: i,
127
+ collapsed: c,
128
+ handlePanelResize: W,
129
+ handleLeftCollapseComplete: A,
130
130
  handleLeftExpandComplete: E,
131
131
  handleRightCollapseComplete: L,
132
- handleRightExpandComplete: x
132
+ handleRightExpandComplete: D
133
133
  } : {
134
134
  type: "two-panel",
135
- sizes: l,
136
- collapsed: u,
137
- handlePanelResize: z,
138
- handleLeftCollapseComplete: I,
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
- A(this, "PRESETS_KEY", "panel-layouts:workspace-presets");
145
- A(this, "REPO_STATE_PREFIX", "panel-layouts:repo-state:");
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), l = localStorage.getItem(a);
206
- if (l)
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(l);
209
- } catch (f) {
208
+ e[s] = JSON.parse(i);
209
+ } catch (o) {
210
210
  console.error(
211
211
  `Failed to parse repository state for ${s}:`,
212
- f
212
+ o
213
213
  );
214
214
  }
215
215
  }
@@ -220,7 +220,7 @@ class N {
220
220
  }
221
221
  }
222
222
  }
223
- class m {
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
- }, l = {
260
+ }, i = {
261
261
  ...t,
262
262
  [a]: s
263
263
  };
264
- return await this.adapter.saveWorkspacePresets(l), s;
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 l = {
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
- }, f = {
283
+ }, o = {
284
284
  ...a,
285
- [e]: l
285
+ [e]: i
286
286
  };
287
- return await this.adapter.saveWorkspacePresets(f), l;
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
- A(m, "adapter", new N());
613
- function K(n = {}) {
614
- const { repositoryKey: e, autoInitialize: t = !1, defaultWorkspaceId: a } = n, [s, l] = R(
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
- ), [f, u] = R(null), [v, w] = R(null), [b, h] = R(!0), [y, r] = R(null), o = p(async () => {
616
+ ), [o, c] = C(null), [R, h] = C(null), [P, w] = C(!0), [m, k] = C(null), d = f(async () => {
617
617
  try {
618
- h(!0), r(null);
619
- const c = await m.getWorkspaceLayouts();
620
- if (l(c), e) {
621
- let d = await m.getRepositoryState(e);
622
- if (!d && t) {
623
- const S = a || "project-management", W = await m.getWorkspaceLayout(S);
624
- W && (d = {
625
- workspaceId: S,
626
- sizes: W.defaultSizes || {
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: W.defaultCollapsed || {
631
+ collapsed: v.defaultCollapsed || {
632
632
  left: !1,
633
633
  right: !1
634
634
  }
635
- }, await m.setRepositoryState(
635
+ }, await S.setRepositoryState(
636
636
  e,
637
- d
637
+ p
638
638
  ));
639
639
  }
640
- if (u(d), d != null && d.workspaceId) {
641
- const S = await m.getWorkspaceLayout(
642
- d.workspaceId
640
+ if (c(p), p != null && p.workspaceId) {
641
+ const b = await S.getWorkspaceLayout(
642
+ p.workspaceId
643
643
  );
644
- w(S);
644
+ h(b);
645
645
  } else
646
- w(null);
646
+ h(null);
647
647
  }
648
- } catch (c) {
649
- r(c), console.error("Failed to load workspace data:", c);
648
+ } catch (u) {
649
+ k(u), console.error("Failed to load workspace data:", u);
650
650
  } finally {
651
- h(!1);
651
+ w(!1);
652
652
  }
653
653
  }, [e, t, a]);
654
- P(() => {
655
- o();
656
- }, [o]);
657
- const k = p(
658
- async (c) => await m.getWorkspaceLayout(c),
654
+ T(() => {
655
+ d();
656
+ }, [d]);
657
+ const r = f(
658
+ async (u) => await S.getWorkspaceLayout(u),
659
659
  []
660
- ), T = p(
661
- async (c) => {
662
- const d = await m.createWorkspaceLayout(c);
663
- return await o(), d;
660
+ ), y = f(
661
+ async (u) => {
662
+ const p = await S.createWorkspaceLayout(u);
663
+ return await d(), p;
664
664
  },
665
- [o]
666
- ), z = p(
667
- async (c, d) => {
668
- const S = await m.updateWorkspaceLayout(c, d);
669
- return await o(), S;
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
- [o]
672
- ), I = p(
673
- async (c) => {
674
- const d = await m.deleteWorkspaceLayout(c);
675
- return d && await o(), d;
671
+ [d]
672
+ ), A = f(
673
+ async (u) => {
674
+ const p = await S.deleteWorkspaceLayout(u);
675
+ return p && await d(), p;
676
676
  },
677
- [o]
678
- ), E = p(
679
- async (c) => {
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 d = await m.getWorkspaceLayout(c);
685
- if (!d) {
686
- console.error(`Workspace ${c} not found`);
684
+ const p = await S.getWorkspaceLayout(u);
685
+ if (!p) {
686
+ console.error(`Workspace ${u} not found`);
687
687
  return;
688
688
  }
689
- const S = {
690
- workspaceId: c,
691
- sizes: d.defaultSizes || { left: 20, middle: 45, right: 35 },
692
- collapsed: d.defaultCollapsed || {
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 m.setRepositoryState(e, S), await o();
697
+ await S.setRepositoryState(e, b), await d();
698
698
  },
699
- [e, o]
700
- ), L = p(
701
- async (c) => {
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 m.updateRepositorySizes(e, c), await o();
706
+ await S.updateRepositorySizes(e, u), await d();
707
707
  },
708
- [e, o]
709
- ), x = p(
710
- async (c) => {
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 m.updateRepositoryCollapsed(
715
+ await S.updateRepositoryCollapsed(
716
716
  e,
717
- c
718
- ), await o();
717
+ u
718
+ ), await d();
719
719
  },
720
- [e, o]
721
- ), i = p(async () => {
722
- if (!e || !(f != null && f.workspaceId)) {
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 m.resetRepositoryToWorkspaceDefaults(
726
+ await S.resetRepositoryToWorkspaceDefaults(
727
727
  e,
728
- f.workspaceId
729
- ), await o();
730
- }, [e, f == null ? void 0 : f.workspaceId, o]), g = p(async () => {
731
- await o();
732
- }, [o]);
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: f,
736
- activeWorkspace: v,
737
- loading: b,
738
- error: y,
739
- getWorkspace: k,
740
- createWorkspace: T,
741
- updateWorkspace: z,
742
- deleteWorkspace: I,
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: x,
746
- resetToDefaults: i,
745
+ updateCollapsed: D,
746
+ resetToDefaults: n,
747
747
  refresh: g
748
748
  };
749
749
  }
750
- function j(n = {}) {
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
- } = n, [l, f] = R(
755
+ onFocusChange: s,
756
+ events: i,
757
+ getPanelId: o
758
+ } = l, [c, R] = C(
757
759
  e
758
- ), u = p(
760
+ ), h = f(
759
761
  (r) => {
760
- f(r), s == null || s(r);
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
- ), v = p(() => {
764
- f(null), s == null || s(null);
765
- }, [s]), w = p(() => {
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]), b = p(() => {
808
+ }, [t, a]), m = f(() => {
769
809
  const r = w();
770
810
  if (r.length === 0) return;
771
- if (l === null) {
772
- u(r[0]);
811
+ if (c === null) {
812
+ h(r[0]);
773
813
  return;
774
814
  }
775
- const o = r.indexOf(l);
776
- if (o === -1) {
777
- u(r[0]);
815
+ const y = r.indexOf(c);
816
+ if (y === -1) {
817
+ h(r[0]);
778
818
  return;
779
819
  }
780
- const k = (o + 1) % r.length;
781
- u(r[k]);
782
- }, [l, w, u]), h = p(() => {
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 (l === null) {
786
- u(r[r.length - 1]);
825
+ if (c === null) {
826
+ h(r[r.length - 1]);
787
827
  return;
788
828
  }
789
- const o = r.indexOf(l);
790
- if (o === -1) {
791
- u(r[r.length - 1]);
829
+ const y = r.indexOf(c);
830
+ if (y === -1) {
831
+ h(r[r.length - 1]);
792
832
  return;
793
833
  }
794
- const k = o === 0 ? r.length - 1 : o - 1;
795
- u(r[k]);
796
- }, [l, w, u]), y = p(
797
- (r) => l === r,
798
- [l]
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: l,
802
- setFocus: u,
803
- clearFocus: v,
804
- focusNext: b,
805
- focusPrevious: h,
806
- isFocused: y
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(n) {
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: l,
816
- onExpand: f,
817
- onCollapse: u
818
- } = n, v = C(t), w = C(a), b = C(s);
819
- P(() => {
820
- v.current = t;
821
- }, [t]), P(() => {
822
- w.current = a;
823
- }, [a]), P(() => {
824
- b.current = s;
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 h = p(
827
- (y) => {
828
- if (!y.altKey || y.ctrlKey || y.metaKey || y.shiftKey)
866
+ const w = f(
867
+ (m) => {
868
+ if (!m.altKey || m.ctrlKey || m.metaKey || m.shiftKey)
829
869
  return;
830
- const r = y.code, o = v.current, k = w.current, T = b.current;
831
- r === "Digit1" || r === "Numpad1" ? (y.preventDefault(), k.left ? f("left") : o !== "left" ? l("left") : (u("left"), l("middle"))) : r === "Digit2" || r === "Numpad2" ? (y.preventDefault(), l("middle")) : (r === "Digit3" || r === "Numpad3") && T === "three-panel" && (y.preventDefault(), k.right ? f("right") : o !== "right" ? l("right") : (u("right"), l("middle")));
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
- [l, f, u]
873
+ [i, o, c]
834
874
  );
835
- P(() => {
875
+ T(() => {
836
876
  if (e)
837
- return window.addEventListener("keydown", h), () => {
838
- window.removeEventListener("keydown", h);
877
+ return window.addEventListener("keydown", w), () => {
878
+ window.removeEventListener("keydown", w);
839
879
  };
840
- }, [e, h]);
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 X = ({
843
- isFocused: n,
901
+ const M = ({
902
+ isFocused: l,
844
903
  className: e = "",
845
904
  style: t = {}
846
905
  }) => {
847
- if (!n)
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
- Z as EditableConfigurablePanelLayout,
875
- X as FocusIndicator,
933
+ G as EditableConfigurablePanelLayout,
934
+ M as FocusIndicator,
876
935
  $ as LocalStoragePersistenceAdapter,
877
936
  N as LocalStorageWorkspaceAdapter,
878
- G as ResponsiveConfigurablePanelLayout,
879
- m as WorkspaceLayoutService,
880
- Q as mapThemeToPanelVars,
881
- H as mapThemeToTabVars,
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