@mt-gloss/ui 0.1.94 → 0.1.96

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,6 +1,6 @@
1
- import { jsx as i, jsxs as p } from "react/jsx-runtime";
2
- import { createContext as h, useContext as E, useReducer as m, useRef as d, useEffect as s, useMemo as g, useCallback as v, useSyncExternalStore as S, useState as _, useLayoutEffect as P } from "react";
3
- const f = h(null);
1
+ import { jsx as o, jsxs as p } from "react/jsx-runtime";
2
+ import { createContext as I, useContext as E, useReducer as P, useRef as d, useEffect as s, useMemo as v, useCallback as g, useSyncExternalStore as S, useLayoutEffect as C, useState as _ } from "react";
3
+ const f = I(null);
4
4
  function y() {
5
5
  const e = E(f);
6
6
  if (!e)
@@ -9,7 +9,7 @@ function y() {
9
9
  );
10
10
  return e;
11
11
  }
12
- function q() {
12
+ function j() {
13
13
  return E(f);
14
14
  }
15
15
  const O = {
@@ -20,8 +20,8 @@ const O = {
20
20
  lockHint: null,
21
21
  lastClose: null,
22
22
  pendingSideEffects: []
23
- }, L = /* @__PURE__ */ new Set(["settings"]);
24
- function T(e, n) {
23
+ }, w = /* @__PURE__ */ new Set(["settings"]);
24
+ function L(e, n) {
25
25
  if (e == null || e.kind !== n.kind) return !1;
26
26
  switch (e.kind) {
27
27
  case "bell":
@@ -34,7 +34,7 @@ function T(e, n) {
34
34
  return e.global === n.global && e.align === n.align;
35
35
  }
36
36
  }
37
- function D(e, n) {
37
+ function N(e, n) {
38
38
  switch (n.type) {
39
39
  case "OPEN_PANEL": {
40
40
  if (e.activePanelId && e.isDirty)
@@ -52,7 +52,7 @@ function D(e, n) {
52
52
  }
53
53
  ]
54
54
  };
55
- if (e.activePanelId === n.panelId && T(e.activeTrigger, n.trigger))
55
+ if (e.activePanelId === n.panelId && L(e.activeTrigger, n.trigger))
56
56
  return e;
57
57
  const t = e.activePanelId != null ? [
58
58
  {
@@ -101,7 +101,7 @@ function D(e, n) {
101
101
  case "CLOSE_BELL_CUTOUT":
102
102
  return e.bellCutoutOpen ? { ...e, bellCutoutOpen: !1 } : e;
103
103
  case "BUFFER_BECOMES_DIRTY":
104
- return e.activePanelId == null || !L.has(e.activePanelId) ? {
104
+ return e.activePanelId == null || !w.has(e.activePanelId) ? {
105
105
  ...e,
106
106
  pendingSideEffects: [
107
107
  ...e.pendingSideEffects,
@@ -134,11 +134,11 @@ function D(e, n) {
134
134
  return e;
135
135
  }
136
136
  }
137
- function N(e) {
137
+ function T(e) {
138
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";
139
139
  }
140
- function w() {
141
- const [e, n] = m(D, O), t = d([]), r = d(null);
140
+ function D() {
141
+ const [e, n] = P(N, O), t = d([]), r = d(null);
142
142
  s(() => () => {
143
143
  r.current != null && (window.clearTimeout(r.current), r.current = null);
144
144
  }, []), s(() => {
@@ -170,26 +170,47 @@ function w() {
170
170
  l
171
171
  ];
172
172
  }, [e.lastClose]);
173
- const o = g(
174
- () => N(e),
173
+ const i = v(
174
+ () => T(e),
175
175
  [e.activePanelId, e.bellCutoutOpen, e.isDirty]
176
- ), a = v(() => t.current.slice(), []);
177
- return { state: e, surfaceState: o, dispatch: n, getCloseLog: a };
176
+ ), a = g(() => t.current.slice(), []);
177
+ return { state: e, surfaceState: i, dispatch: n, getCloseLog: a };
178
178
  }
179
- function j({ children: e }) {
180
- const n = w(), t = g(
179
+ function Y({ children: e }) {
180
+ const n = D(), t = v(
181
181
  () => n,
182
182
  // Re-publish only when one of the four coordinator fields changes identity.
183
183
  // dispatch + getCloseLog are stable. state + surfaceState change on dispatch.
184
184
  [n.state, n.surfaceState, n.dispatch, n.getCloseLog]
185
185
  );
186
- return /* @__PURE__ */ i(f.Provider, { value: t, children: e });
186
+ return /* @__PURE__ */ o(f.Provider, { value: t, children: e });
187
187
  }
188
- const x = {
188
+ const x = "(prefers-reduced-motion: reduce)";
189
+ function h() {
190
+ return typeof window > "u" || typeof window.matchMedia != "function" ? null : window.matchMedia(x);
191
+ }
192
+ function H(e) {
193
+ const n = h();
194
+ return n ? (n.addEventListener("change", e), () => {
195
+ n.removeEventListener("change", e);
196
+ }) : () => {
197
+ };
198
+ }
199
+ function b() {
200
+ const e = h();
201
+ return e ? e.matches : !1;
202
+ }
203
+ function A() {
204
+ return !1;
205
+ }
206
+ function R() {
207
+ return S(H, b, A);
208
+ }
209
+ const F = {
189
210
  position: "relative",
190
211
  pointerEvents: "auto"
191
212
  };
192
- function H({ children: e, onClose: n, footer: t }) {
213
+ function k({ children: e, onClose: n, footer: t }) {
193
214
  return /* @__PURE__ */ p(
194
215
  "div",
195
216
  {
@@ -197,9 +218,9 @@ function H({ children: e, onClose: n, footer: t }) {
197
218
  role: "dialog",
198
219
  "aria-modal": "true",
199
220
  className: "gloss-panel-chrome",
200
- style: x,
221
+ style: F,
201
222
  children: [
202
- /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__header", children: /* @__PURE__ */ i(
223
+ /* @__PURE__ */ o("div", { className: "gloss-panel-chrome__header", children: /* @__PURE__ */ o(
203
224
  "button",
204
225
  {
205
226
  id: "panel-close",
@@ -210,59 +231,54 @@ function H({ children: e, onClose: n, footer: t }) {
210
231
  children: "×"
211
232
  }
212
233
  ) }),
213
- /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__body", children: e }),
214
- t != null && /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__footer", children: t })
234
+ /* @__PURE__ */ o("div", { className: "gloss-panel-chrome__body", children: e }),
235
+ t != null && /* @__PURE__ */ o("div", { className: "gloss-panel-chrome__footer", children: t })
215
236
  ]
216
237
  }
217
238
  );
218
239
  }
219
- const b = "(prefers-reduced-motion: reduce)";
220
- function C() {
221
- return typeof window > "u" || typeof window.matchMedia != "function" ? null : window.matchMedia(b);
222
- }
223
- function A(e) {
224
- const n = C();
225
- return n ? (n.addEventListener("change", e), () => {
226
- n.removeEventListener("change", e);
227
- }) : () => {
228
- };
229
- }
230
- function F() {
231
- const e = C();
232
- return e ? e.matches : !1;
233
- }
234
- function R() {
235
- return !1;
236
- }
237
- function k() {
238
- return S(A, F, R);
240
+ function M(e) {
241
+ if (process.env.NODE_ENV === "production" || !e || !e.parentElement) return;
242
+ const n = e.parentElement, t = window.getComputedStyle(n);
243
+ t.perspective === "none" && console.warn(
244
+ "[PanelMount] §2.7 violation: parent of .gloss-panel-mount has perspective:none. Rotated mount will render flat. Parent:",
245
+ n
246
+ ), (t.overflow === "hidden" || t.overflowY === "hidden") && console.warn(
247
+ "[PanelMount] §2.9 violation: parent of .gloss-panel-mount has overflow:hidden. Rising panel will be clipped. Parent:",
248
+ n
249
+ );
239
250
  }
240
- function M({ isOpen: e, children: n }) {
241
- const t = k(), [r, o] = _(!1);
251
+ function U({ isOpen: e, children: n }) {
252
+ const t = R(), r = d(null);
253
+ C(() => {
254
+ M(r.current);
255
+ }, []);
256
+ const [i, a] = _(!1);
242
257
  s(() => {
243
258
  if (!e) {
244
- o(!1);
259
+ a(!1);
245
260
  return;
246
261
  }
247
- const l = requestAnimationFrame(() => o(!0));
248
- return () => cancelAnimationFrame(l);
262
+ const u = requestAnimationFrame(() => a(!0));
263
+ return () => cancelAnimationFrame(u);
249
264
  }, [e]);
250
- const a = [
265
+ const l = [
251
266
  "gloss-panel-mount",
252
- r ? "has-panel" : "",
267
+ i ? "has-panel" : "",
253
268
  t ? "reduced-motion" : ""
254
269
  ].filter(Boolean).join(" ");
255
- return /* @__PURE__ */ i(
270
+ return /* @__PURE__ */ o(
256
271
  "div",
257
272
  {
258
- className: a,
273
+ ref: r,
274
+ className: l,
259
275
  "data-mount": "panel",
260
276
  "data-open": e ? "true" : "false",
261
277
  children: n
262
278
  }
263
279
  );
264
280
  }
265
- const U = {
281
+ const B = {
266
282
  position: "fixed",
267
283
  top: 0,
268
284
  left: 0,
@@ -273,7 +289,7 @@ const U = {
273
289
  overflow: "visible",
274
290
  pointerEvents: "none",
275
291
  zIndex: 55
276
- }, B = {
292
+ }, K = {
277
293
  position: "fixed",
278
294
  top: "var(--tb-h, 60px)",
279
295
  left: 0,
@@ -290,21 +306,21 @@ const U = {
290
306
  background: "rgba(0, 0, 0, 0.04)"
291
307
  };
292
308
  function z({ panelComponents: e }) {
293
- const { state: n, dispatch: t, getCloseLog: r } = y(), o = n.activePanelId ? e[n.activePanelId] : null;
294
- n.activePanelId && !o && process.env.NODE_ENV !== "production" && console.error(
309
+ const { state: n, dispatch: t, getCloseLog: r } = y(), i = n.activePanelId ? e[n.activePanelId] : null;
310
+ n.activePanelId && !i && process.env.NODE_ENV !== "production" && console.error(
295
311
  "[panels] No panel component registered for activePanelId:",
296
312
  n.activePanelId
297
313
  ), s(() => {
298
314
  if (n.activePanelId == null) return;
299
- function c(I) {
300
- I.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
315
+ function c(m) {
316
+ m.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
301
317
  }
302
318
  return document.addEventListener("keydown", c), () => {
303
319
  document.removeEventListener("keydown", c);
304
320
  };
305
321
  }, [n.activePanelId, t]);
306
322
  const a = d(n);
307
- P(() => {
323
+ C(() => {
308
324
  a.current = n;
309
325
  }), s(() => {
310
326
  if (process.env.NODE_ENV === "production") return;
@@ -317,24 +333,24 @@ function z({ panelComponents: e }) {
317
333
  c.__panelsHostHandle?.dispatch === t && delete c.__panelsHostHandle;
318
334
  };
319
335
  }, [t, r]);
320
- const l = v(() => {
336
+ const l = g(() => {
321
337
  t({ type: "CLOSE_PANEL", reason: "nav-escape-hatch" });
322
- }, [t]), u = n.activePanelId != null && o != null;
323
- return /* @__PURE__ */ p("div", { "data-panel-host": "true", style: U, children: [
324
- u && /* @__PURE__ */ i(
338
+ }, [t]), u = n.activePanelId != null && i != null;
339
+ return /* @__PURE__ */ p("div", { "data-panel-host": "true", style: B, children: [
340
+ u && /* @__PURE__ */ o(
325
341
  "div",
326
342
  {
327
343
  "data-panel-scrim": "true",
328
- style: B,
344
+ style: K,
329
345
  onClick: l
330
346
  }
331
347
  ),
332
- /* @__PURE__ */ i(M, { isOpen: u, children: u && /* @__PURE__ */ i(
333
- H,
348
+ /* @__PURE__ */ o(U, { isOpen: u, children: u && /* @__PURE__ */ o(
349
+ k,
334
350
  {
335
351
  isOpen: !0,
336
352
  onClose: () => t({ type: "CLOSE_PANEL", reason: "header-x" }),
337
- children: /* @__PURE__ */ i(o, { isOpen: !0 })
353
+ children: /* @__PURE__ */ o(i, { isOpen: !0 })
338
354
  }
339
355
  ) })
340
356
  ] });
@@ -354,15 +370,15 @@ const Q = {
354
370
  };
355
371
  export {
356
372
  Q as C,
357
- j as P,
358
- q as a,
373
+ Y as P,
374
+ j as a,
359
375
  z as b,
360
- H as c,
361
- w as d,
362
- N as e,
363
- M as f,
364
- k as g,
376
+ k as c,
377
+ D as d,
378
+ T as e,
379
+ R as f,
380
+ U as g,
365
381
  O as i,
366
- D as r,
382
+ N as r,
367
383
  y as u
368
384
  };