@mt-gloss/ui 0.1.85 → 0.1.86

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,8 +1,8 @@
1
- import { jsx as i, jsxs as d, Fragment as v } from "react/jsx-runtime";
2
- import { createContext as I, useContext as f, useReducer as S, useRef as c, useEffect as a, useMemo as p, useCallback as E, useLayoutEffect as P } from "react";
3
- const s = I(null);
4
- function _() {
5
- const e = f(s);
1
+ import { jsx as i, jsxs as f, Fragment as v } from "react/jsx-runtime";
2
+ import { createContext as I, useContext as p, useReducer as S, useRef as s, useEffect as c, useMemo as E, useCallback as C, useLayoutEffect as _ } from "react";
3
+ const u = I(null);
4
+ function h() {
5
+ const e = p(u);
6
6
  if (!e)
7
7
  throw new Error(
8
8
  "[panels] usePanelContext must be used inside <PanelProvider>. See @mt-gloss/ui/composites/panels."
@@ -10,7 +10,7 @@ function _() {
10
10
  return e;
11
11
  }
12
12
  function w() {
13
- return f(s);
13
+ return p(u);
14
14
  }
15
15
  const y = {
16
16
  activePanelId: null,
@@ -20,7 +20,7 @@ const y = {
20
20
  lockHint: null,
21
21
  lastClose: null,
22
22
  pendingSideEffects: []
23
- }, h = /* @__PURE__ */ new Set(["settings"]);
23
+ }, P = /* @__PURE__ */ new Set(["settings"]);
24
24
  function O(e, n) {
25
25
  return e == null ? !1 : JSON.stringify(e) === JSON.stringify(n);
26
26
  }
@@ -50,13 +50,13 @@ function m(e, n) {
50
50
  reason: "mutex-handoff",
51
51
  previousPanelId: e.activePanelId
52
52
  }
53
- ] : [], r = n.panelId === "notification-center" && e.bellCutoutOpen;
53
+ ] : [], l = n.panelId === "notification-center" && e.bellCutoutOpen;
54
54
  return {
55
55
  ...e,
56
56
  activePanelId: n.panelId,
57
57
  activeTrigger: n.trigger,
58
58
  isDirty: !1,
59
- bellCutoutOpen: r ? !1 : e.bellCutoutOpen,
59
+ bellCutoutOpen: l ? !1 : e.bellCutoutOpen,
60
60
  lastClose: null,
61
61
  // reset on fresh open
62
62
  pendingSideEffects: [...e.pendingSideEffects, ...t]
@@ -65,7 +65,7 @@ function m(e, n) {
65
65
  case "CLOSE_PANEL": {
66
66
  if (e.activePanelId == null)
67
67
  return e;
68
- const t = e.activePanelId, r = e.isDirty ? n.reason === "apply-button" ? [{ type: "COMMIT_BUFFER" }] : [{ type: "DISCARD_BUFFER" }] : [];
68
+ const t = e.activePanelId, l = e.isDirty ? n.reason === "apply-button" ? [{ type: "COMMIT_BUFFER" }] : [{ type: "DISCARD_BUFFER" }] : [];
69
69
  return {
70
70
  ...e,
71
71
  activePanelId: null,
@@ -74,7 +74,7 @@ function m(e, n) {
74
74
  lockHint: null,
75
75
  // closing clears any active lockHint (dirty-buffer condition gone)
76
76
  lastClose: { panelId: t, reason: n.reason },
77
- pendingSideEffects: [...e.pendingSideEffects, ...r]
77
+ pendingSideEffects: [...e.pendingSideEffects, ...l]
78
78
  };
79
79
  }
80
80
  case "OPEN_BELL_CUTOUT":
@@ -91,7 +91,7 @@ function m(e, n) {
91
91
  case "CLOSE_BELL_CUTOUT":
92
92
  return e.bellCutoutOpen ? { ...e, bellCutoutOpen: !1 } : e;
93
93
  case "BUFFER_BECOMES_DIRTY":
94
- return e.activePanelId == null || !h.has(e.activePanelId) ? {
94
+ return e.activePanelId == null || !P.has(e.activePanelId) ? {
95
95
  ...e,
96
96
  pendingSideEffects: [
97
97
  ...e.pendingSideEffects,
@@ -127,17 +127,27 @@ function m(e, n) {
127
127
  function L(e) {
128
128
  return e.activePanelId === "notification-center" ? "notif-center" : e.activePanelId != null && e.bellCutoutOpen ? e.isDirty ? "panel-dirty+cutout" : "panel-clean+cutout" : e.activePanelId != null ? e.isDirty ? "panel-dirty" : "panel-clean" : e.bellCutoutOpen ? "bell-cutout-only" : "idle";
129
129
  }
130
- function D() {
131
- const [e, n] = S(m, y), t = c([]);
132
- c(null), a(() => {
130
+ function N() {
131
+ const [e, n] = S(m, y), t = s([]), l = s(null);
132
+ c(() => {
133
133
  if (e.pendingSideEffects.length !== 0) {
134
- for (const l of e.pendingSideEffects)
135
- l.type === "SCHEDULE_TIMER" ? window.setTimeout(() => n(l.action), Math.max(0, l.ms)) : l.type === "INVALID_DISPATCH" && process.env.NODE_ENV !== "production" && console.warn("[panels] INVALID_DISPATCH:", l.reason);
134
+ for (const r of e.pendingSideEffects)
135
+ r.type === "SCHEDULE_TIMER" ? (l.current != null && window.clearTimeout(l.current), l.current = window.setTimeout(() => {
136
+ l.current = null, n(r.action);
137
+ }, Math.max(0, r.ms))) : r.type === "SET_LOCK_HINT" ? n({ type: "SET_LOCK_HINT", hint: r.hint }) : r.type === "HANDOFF_CLOSE" ? t.current = [
138
+ ...t.current.slice(-99),
139
+ {
140
+ panelId: r.previousPanelId,
141
+ reason: "mutex-handoff",
142
+ at: Date.now(),
143
+ note: "F22: mutex-handoff synthetic close-log entry"
144
+ }
145
+ ] : r.type === "INVALID_DISPATCH" && process.env.NODE_ENV !== "production" && console.warn("[panels] INVALID_DISPATCH:", r.reason);
136
146
  n({ type: "DRAIN_SIDE_EFFECTS" });
137
147
  }
138
- }, [e.pendingSideEffects]), a(() => {
148
+ }, [e.pendingSideEffects]), c(() => {
139
149
  if (!e.lastClose) return;
140
- const l = {
150
+ const r = {
141
151
  panelId: e.lastClose.panelId,
142
152
  reason: e.lastClose.reason,
143
153
  at: Date.now(),
@@ -145,31 +155,31 @@ function D() {
145
155
  };
146
156
  t.current = [
147
157
  ...t.current.slice(-99),
148
- l
158
+ r
149
159
  ];
150
160
  }, [e.lastClose]);
151
- const r = p(
161
+ const o = E(
152
162
  () => L(e),
153
163
  // eslint-disable-next-line react-hooks/exhaustive-deps
154
- [e.activePanelId]
155
- ), o = E(() => t.current.slice(), []);
156
- return { state: e, surfaceState: r, dispatch: n, getCloseLog: o };
164
+ [e.activePanelId, e.bellCutoutOpen, e.isDirty]
165
+ ), a = C(() => t.current.slice(), []);
166
+ return { state: e, surfaceState: o, dispatch: n, getCloseLog: a };
157
167
  }
158
168
  function F({ children: e }) {
159
- const n = D(), t = p(
169
+ const n = N(), t = E(
160
170
  () => n,
161
171
  // Re-publish only when one of the four coordinator fields changes identity.
162
172
  // dispatch + getCloseLog are stable. state + surfaceState change on dispatch.
163
173
  [n.state, n.surfaceState, n.dispatch, n.getCloseLog]
164
174
  );
165
- return /* @__PURE__ */ i(s.Provider, { value: t, children: e });
175
+ return /* @__PURE__ */ i(u.Provider, { value: t, children: e });
166
176
  }
167
- const N = {
177
+ const T = {
168
178
  position: "relative",
169
179
  pointerEvents: "auto"
170
180
  };
171
- function b({ children: e, onClose: n, isOpen: t = !0 }) {
172
- return /* @__PURE__ */ d(
181
+ function D({ children: e, onClose: n, isOpen: t = !0, footer: l }) {
182
+ return /* @__PURE__ */ f(
173
183
  "div",
174
184
  {
175
185
  "data-chrome": "panel",
@@ -177,7 +187,7 @@ function b({ children: e, onClose: n, isOpen: t = !0 }) {
177
187
  role: "dialog",
178
188
  "aria-modal": "true",
179
189
  className: "gloss-panel-chrome",
180
- style: N,
190
+ style: T,
181
191
  children: [
182
192
  /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__header", children: /* @__PURE__ */ i(
183
193
  "button",
@@ -190,12 +200,13 @@ function b({ children: e, onClose: n, isOpen: t = !0 }) {
190
200
  children: "×"
191
201
  }
192
202
  ) }),
193
- /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__body", children: e })
203
+ /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__body", children: e }),
204
+ l != null && /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__footer", children: l })
194
205
  ]
195
206
  }
196
207
  );
197
208
  }
198
- const T = {
209
+ const b = {
199
210
  position: "fixed",
200
211
  top: 0,
201
212
  left: 0,
@@ -217,46 +228,46 @@ const T = {
217
228
  background: "rgba(0, 0, 0, 0.04)"
218
229
  };
219
230
  function R({ panelComponents: e }) {
220
- const { state: n, dispatch: t, getCloseLog: r } = _(), o = n.activePanelId ? e[n.activePanelId] : null;
231
+ const { state: n, dispatch: t, getCloseLog: l } = h(), o = n.activePanelId ? e[n.activePanelId] : null;
221
232
  n.activePanelId && !o && process.env.NODE_ENV !== "production" && console.error(
222
233
  "[panels] No panel component registered for activePanelId:",
223
234
  n.activePanelId
224
- ), a(() => {
235
+ ), c(() => {
225
236
  if (n.activePanelId == null) return;
226
- function u(C) {
227
- C.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
237
+ function d(g) {
238
+ g.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
228
239
  }
229
- return document.addEventListener("keydown", u), () => {
230
- document.removeEventListener("keydown", u);
240
+ return document.addEventListener("keydown", d), () => {
241
+ document.removeEventListener("keydown", d);
231
242
  };
232
243
  }, [n.activePanelId, t]);
233
- const l = c(n);
234
- P(() => {
235
- l.current = n;
236
- }), a(() => {
244
+ const a = s(n);
245
+ _(() => {
246
+ a.current = n;
247
+ }), c(() => {
237
248
  if (process.env.NODE_ENV !== "production")
238
249
  return window.__panelsHostHandle = {
239
250
  dispatch: t,
240
- getState: () => l.current,
241
- getCloseLog: r
251
+ getState: () => a.current,
252
+ getCloseLog: l
242
253
  }, () => {
243
254
  delete window.__panelsHostHandle;
244
255
  };
245
- }, [t, r]);
246
- const g = E(() => {
256
+ }, [t, l]);
257
+ const r = C(() => {
247
258
  t({ type: "CLOSE_PANEL", reason: "nav-escape-hatch" });
248
259
  }, [t]);
249
- return /* @__PURE__ */ i("div", { "data-panel-host": "true", style: T, children: n.activePanelId != null && o != null && /* @__PURE__ */ d(v, { children: [
260
+ return /* @__PURE__ */ i("div", { "data-panel-host": "true", style: b, children: n.activePanelId != null && o != null && /* @__PURE__ */ f(v, { children: [
250
261
  /* @__PURE__ */ i(
251
262
  "div",
252
263
  {
253
264
  "data-panel-scrim": "true",
254
265
  style: x,
255
- onClick: g
266
+ onClick: r
256
267
  }
257
268
  ),
258
269
  /* @__PURE__ */ i(
259
- b,
270
+ D,
260
271
  {
261
272
  isOpen: !0,
262
273
  onClose: () => t({ type: "CLOSE_PANEL", reason: "header-x" }),
@@ -283,10 +294,10 @@ export {
283
294
  F as P,
284
295
  w as a,
285
296
  R as b,
286
- b as c,
287
- D as d,
297
+ D as c,
298
+ N as d,
288
299
  L as e,
289
300
  y as i,
290
301
  m as r,
291
- _ as u
302
+ h as u
292
303
  };