@mt-gloss/ui 0.1.86 → 0.1.88

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,18 +1,18 @@
1
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);
2
+ import { createContext as _, useContext as p, useReducer as h, useRef as u, useEffect as s, useMemo as E, useCallback as g, useState as P, useLayoutEffect as C } from "react";
3
+ const d = _(null);
4
+ function S() {
5
+ const e = p(d);
6
6
  if (!e)
7
7
  throw new Error(
8
8
  "[panels] usePanelContext must be used inside <PanelProvider>. See @mt-gloss/ui/composites/panels."
9
9
  );
10
10
  return e;
11
11
  }
12
- function w() {
13
- return p(u);
12
+ function F() {
13
+ return p(d);
14
14
  }
15
- const y = {
15
+ const m = {
16
16
  activePanelId: null,
17
17
  activeTrigger: null,
18
18
  bellCutoutOpen: !1,
@@ -20,11 +20,21 @@ const y = {
20
20
  lockHint: null,
21
21
  lastClose: null,
22
22
  pendingSideEffects: []
23
- }, P = /* @__PURE__ */ new Set(["settings"]);
23
+ }, y = /* @__PURE__ */ new Set(["settings"]);
24
24
  function O(e, n) {
25
- return e == null ? !1 : JSON.stringify(e) === JSON.stringify(n);
25
+ if (e == null || e.kind !== n.kind) return !1;
26
+ switch (e.kind) {
27
+ case "bell":
28
+ return !0;
29
+ case "card-overflow":
30
+ return e.cardId === n.cardId && e.sectionIndex === n.sectionIndex && e.action === n.action;
31
+ case "empty-cell":
32
+ return e.sectionIndex === n.sectionIndex && e.cellPosition.row === n.cellPosition.row && e.cellPosition.col === n.cellPosition.col;
33
+ case "manage-pages-action":
34
+ return e.global === n.global && e.align === n.align;
35
+ }
26
36
  }
27
- function m(e, n) {
37
+ function L(e, n) {
28
38
  switch (n.type) {
29
39
  case "OPEN_PANEL": {
30
40
  if (e.activePanelId && e.isDirty)
@@ -91,7 +101,7 @@ function m(e, n) {
91
101
  case "CLOSE_BELL_CUTOUT":
92
102
  return e.bellCutoutOpen ? { ...e, bellCutoutOpen: !1 } : e;
93
103
  case "BUFFER_BECOMES_DIRTY":
94
- return e.activePanelId == null || !P.has(e.activePanelId) ? {
104
+ return e.activePanelId == null || !y.has(e.activePanelId) ? {
95
105
  ...e,
96
106
  pendingSideEffects: [
97
107
  ...e.pendingSideEffects,
@@ -124,12 +134,14 @@ function m(e, n) {
124
134
  return e;
125
135
  }
126
136
  }
127
- function L(e) {
137
+ function T(e) {
128
138
  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
139
  }
130
- function N() {
131
- const [e, n] = S(m, y), t = s([]), l = s(null);
132
- c(() => {
140
+ function D() {
141
+ const [e, n] = h(L, m), t = u([]), l = u(null);
142
+ s(() => () => {
143
+ l.current != null && (window.clearTimeout(l.current), l.current = null);
144
+ }, []), s(() => {
133
145
  if (e.pendingSideEffects.length !== 0) {
134
146
  for (const r of e.pendingSideEffects)
135
147
  r.type === "SCHEDULE_TIMER" ? (l.current != null && window.clearTimeout(l.current), l.current = window.setTimeout(() => {
@@ -145,7 +157,7 @@ function N() {
145
157
  ] : r.type === "INVALID_DISPATCH" && process.env.NODE_ENV !== "production" && console.warn("[panels] INVALID_DISPATCH:", r.reason);
146
158
  n({ type: "DRAIN_SIDE_EFFECTS" });
147
159
  }
148
- }, [e.pendingSideEffects]), c(() => {
160
+ }, [e.pendingSideEffects, n]), s(() => {
149
161
  if (!e.lastClose) return;
150
162
  const r = {
151
163
  panelId: e.lastClose.panelId,
@@ -159,35 +171,39 @@ function N() {
159
171
  ];
160
172
  }, [e.lastClose]);
161
173
  const o = E(
162
- () => L(e),
174
+ () => T(e),
163
175
  // eslint-disable-next-line react-hooks/exhaustive-deps
164
176
  [e.activePanelId, e.bellCutoutOpen, e.isDirty]
165
- ), a = C(() => t.current.slice(), []);
177
+ ), a = g(() => t.current.slice(), []);
166
178
  return { state: e, surfaceState: o, dispatch: n, getCloseLog: a };
167
179
  }
168
- function F({ children: e }) {
169
- const n = N(), t = E(
180
+ function k({ children: e }) {
181
+ const n = D(), t = E(
170
182
  () => n,
171
183
  // Re-publish only when one of the four coordinator fields changes identity.
172
184
  // dispatch + getCloseLog are stable. state + surfaceState change on dispatch.
173
185
  [n.state, n.surfaceState, n.dispatch, n.getCloseLog]
174
186
  );
175
- return /* @__PURE__ */ i(u.Provider, { value: t, children: e });
187
+ return /* @__PURE__ */ i(d.Provider, { value: t, children: e });
176
188
  }
177
- const T = {
189
+ const N = {
178
190
  position: "relative",
179
191
  pointerEvents: "auto"
180
192
  };
181
- function D({ children: e, onClose: n, isOpen: t = !0, footer: l }) {
182
- return /* @__PURE__ */ f(
193
+ function x({ children: e, onClose: n, isOpen: t = !0, footer: l }) {
194
+ const [o, a] = P(!1);
195
+ return C(() => {
196
+ const r = requestAnimationFrame(() => a(t));
197
+ return () => cancelAnimationFrame(r);
198
+ }, [t]), /* @__PURE__ */ f(
183
199
  "div",
184
200
  {
185
201
  "data-chrome": "panel",
186
- "data-open": t ? "true" : "false",
202
+ "data-open": o ? "true" : "false",
187
203
  role: "dialog",
188
204
  "aria-modal": "true",
189
205
  className: "gloss-panel-chrome",
190
- style: T,
206
+ style: N,
191
207
  children: [
192
208
  /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__header", children: /* @__PURE__ */ i(
193
209
  "button",
@@ -206,7 +222,7 @@ function D({ children: e, onClose: n, isOpen: t = !0, footer: l }) {
206
222
  }
207
223
  );
208
224
  }
209
- const b = {
225
+ const H = {
210
226
  position: "fixed",
211
227
  top: 0,
212
228
  left: 0,
@@ -217,57 +233,64 @@ const b = {
217
233
  overflow: "visible",
218
234
  pointerEvents: "none",
219
235
  zIndex: 55
220
- }, x = {
236
+ }, b = {
221
237
  position: "fixed",
222
238
  top: "var(--tb-h, 60px)",
223
239
  left: 0,
224
240
  right: 0,
225
241
  bottom: 0,
226
242
  zIndex: 1,
227
- pointerEvents: "auto",
243
+ // CR-03 fix: pass-through tint — scrim is visual-only and must not intercept
244
+ // grid card clicks. Click-outside / scrim-dismiss is handled via the onClick
245
+ // on the div below, which still fires because pointer events on the element
246
+ // itself are honoured when explicitly set; using 'none' prevents the invisible
247
+ // overlay from swallowing clicks on underlying controls (same class as the
248
+ // panel-wrapper-covers-grid-cards bug fixed at V2FeedbackSurface).
249
+ pointerEvents: "none",
228
250
  background: "rgba(0, 0, 0, 0.04)"
229
251
  };
230
252
  function R({ panelComponents: e }) {
231
- const { state: n, dispatch: t, getCloseLog: l } = h(), o = n.activePanelId ? e[n.activePanelId] : null;
253
+ const { state: n, dispatch: t, getCloseLog: l } = S(), o = n.activePanelId ? e[n.activePanelId] : null;
232
254
  n.activePanelId && !o && process.env.NODE_ENV !== "production" && console.error(
233
255
  "[panels] No panel component registered for activePanelId:",
234
256
  n.activePanelId
235
- ), c(() => {
257
+ ), s(() => {
236
258
  if (n.activePanelId == null) return;
237
- function d(g) {
238
- g.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
259
+ function c(I) {
260
+ I.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
239
261
  }
240
- return document.addEventListener("keydown", d), () => {
241
- document.removeEventListener("keydown", d);
262
+ return document.addEventListener("keydown", c), () => {
263
+ document.removeEventListener("keydown", c);
242
264
  };
243
265
  }, [n.activePanelId, t]);
244
- const a = s(n);
245
- _(() => {
266
+ const a = u(n);
267
+ C(() => {
246
268
  a.current = n;
247
- }), c(() => {
248
- if (process.env.NODE_ENV !== "production")
249
- return window.__panelsHostHandle = {
250
- dispatch: t,
251
- getState: () => a.current,
252
- getCloseLog: l
253
- }, () => {
254
- delete window.__panelsHostHandle;
255
- };
269
+ }), s(() => {
270
+ if (process.env.NODE_ENV === "production") return;
271
+ const c = window;
272
+ return c.__panelsHostHandle && console.warn("[panels] multiple PanelHost/PanelHostShell instances mounted; dev handle is unreliable"), c.__panelsHostHandle = {
273
+ dispatch: t,
274
+ getState: () => a.current,
275
+ getCloseLog: l
276
+ }, () => {
277
+ c.__panelsHostHandle?.dispatch === t && delete c.__panelsHostHandle;
278
+ };
256
279
  }, [t, l]);
257
- const r = C(() => {
280
+ const r = g(() => {
258
281
  t({ type: "CLOSE_PANEL", reason: "nav-escape-hatch" });
259
282
  }, [t]);
260
- return /* @__PURE__ */ i("div", { "data-panel-host": "true", style: b, children: n.activePanelId != null && o != null && /* @__PURE__ */ f(v, { children: [
283
+ return /* @__PURE__ */ i("div", { "data-panel-host": "true", style: H, children: n.activePanelId != null && o != null && /* @__PURE__ */ f(v, { children: [
261
284
  /* @__PURE__ */ i(
262
285
  "div",
263
286
  {
264
287
  "data-panel-scrim": "true",
265
- style: x,
288
+ style: b,
266
289
  onClick: r
267
290
  }
268
291
  ),
269
292
  /* @__PURE__ */ i(
270
- D,
293
+ x,
271
294
  {
272
295
  isOpen: !0,
273
296
  onClose: () => t({ type: "CLOSE_PANEL", reason: "header-x" }),
@@ -276,7 +299,7 @@ function R({ panelComponents: e }) {
276
299
  )
277
300
  ] }) });
278
301
  }
279
- const k = {
302
+ const U = {
280
303
  "apply-button": !0,
281
304
  // the ONLY commit reason
282
305
  "cancel-button": !1,
@@ -290,14 +313,14 @@ const k = {
290
313
  "nav-escape-hatch": !1
291
314
  };
292
315
  export {
293
- k as C,
294
- F as P,
295
- w as a,
316
+ U as C,
317
+ k as P,
318
+ F as a,
296
319
  R as b,
297
- D as c,
298
- N as d,
299
- L as e,
300
- y as i,
301
- m as r,
302
- h as u
320
+ x as c,
321
+ D as d,
322
+ T as e,
323
+ m as i,
324
+ L as r,
325
+ S as u
303
326
  };