@mt-gloss/ui 0.1.88 → 0.1.90

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,7 +1,7 @@
1
- import { jsx as i, jsxs as f, Fragment as v } from "react/jsx-runtime";
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() {
1
+ import { jsx as i, jsxs as f, Fragment as I } from "react/jsx-runtime";
2
+ import { createContext as h, useContext as p, useReducer as m, useRef as u, useEffect as a, useMemo as E, useCallback as g, useSyncExternalStore as S, useLayoutEffect as _ } from "react";
3
+ const d = h(null);
4
+ function P() {
5
5
  const e = p(d);
6
6
  if (!e)
7
7
  throw new Error(
@@ -9,10 +9,10 @@ function S() {
9
9
  );
10
10
  return e;
11
11
  }
12
- function F() {
12
+ function V() {
13
13
  return p(d);
14
14
  }
15
- const m = {
15
+ const y = {
16
16
  activePanelId: null,
17
17
  activeTrigger: null,
18
18
  bellCutoutOpen: !1,
@@ -20,8 +20,8 @@ const m = {
20
20
  lockHint: null,
21
21
  lastClose: null,
22
22
  pendingSideEffects: []
23
- }, y = /* @__PURE__ */ new Set(["settings"]);
24
- function O(e, n) {
23
+ }, O = /* @__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 O(e, n) {
34
34
  return e.global === n.global && e.align === n.align;
35
35
  }
36
36
  }
37
- function L(e, n) {
37
+ function T(e, n) {
38
38
  switch (n.type) {
39
39
  case "OPEN_PANEL": {
40
40
  if (e.activePanelId && e.isDirty)
@@ -52,7 +52,7 @@ function L(e, n) {
52
52
  }
53
53
  ]
54
54
  };
55
- if (e.activePanelId === n.panelId && O(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 L(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 || !y.has(e.activePanelId) ? {
104
+ return e.activePanelId == null || !O.has(e.activePanelId) ? {
105
105
  ...e,
106
106
  pendingSideEffects: [
107
107
  ...e.pendingSideEffects,
@@ -134,14 +134,14 @@ function L(e, n) {
134
134
  return e;
135
135
  }
136
136
  }
137
- function T(e) {
137
+ function D(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 D() {
141
- const [e, n] = h(L, m), t = u([]), l = u(null);
142
- s(() => () => {
140
+ function N() {
141
+ const [e, n] = m(T, y), t = u([]), l = u(null);
142
+ a(() => () => {
143
143
  l.current != null && (window.clearTimeout(l.current), l.current = null);
144
- }, []), s(() => {
144
+ }, []), a(() => {
145
145
  if (e.pendingSideEffects.length !== 0) {
146
146
  for (const r of e.pendingSideEffects)
147
147
  r.type === "SCHEDULE_TIMER" ? (l.current != null && window.clearTimeout(l.current), l.current = window.setTimeout(() => {
@@ -157,7 +157,7 @@ function D() {
157
157
  ] : r.type === "INVALID_DISPATCH" && process.env.NODE_ENV !== "production" && console.warn("[panels] INVALID_DISPATCH:", r.reason);
158
158
  n({ type: "DRAIN_SIDE_EFFECTS" });
159
159
  }
160
- }, [e.pendingSideEffects, n]), s(() => {
160
+ }, [e.pendingSideEffects, n]), a(() => {
161
161
  if (!e.lastClose) return;
162
162
  const r = {
163
163
  panelId: e.lastClose.panelId,
@@ -170,15 +170,14 @@ function D() {
170
170
  r
171
171
  ];
172
172
  }, [e.lastClose]);
173
- const o = E(
174
- () => T(e),
175
- // eslint-disable-next-line react-hooks/exhaustive-deps
173
+ const c = E(
174
+ () => D(e),
176
175
  [e.activePanelId, e.bellCutoutOpen, e.isDirty]
177
- ), a = g(() => t.current.slice(), []);
178
- return { state: e, surfaceState: o, dispatch: n, getCloseLog: a };
176
+ ), s = g(() => t.current.slice(), []);
177
+ return { state: e, surfaceState: c, dispatch: n, getCloseLog: s };
179
178
  }
180
- function k({ children: e }) {
181
- const n = D(), t = E(
179
+ function j({ children: e }) {
180
+ const n = N(), t = E(
182
181
  () => n,
183
182
  // Re-publish only when one of the four coordinator fields changes identity.
184
183
  // dispatch + getCloseLog are stable. state + surfaceState change on dispatch.
@@ -186,24 +185,19 @@ function k({ children: e }) {
186
185
  );
187
186
  return /* @__PURE__ */ i(d.Provider, { value: t, children: e });
188
187
  }
189
- const N = {
188
+ const w = {
190
189
  position: "relative",
191
190
  pointerEvents: "auto"
192
191
  };
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(
192
+ function x({ children: e, onClose: n, footer: t }) {
193
+ return /* @__PURE__ */ f(
199
194
  "div",
200
195
  {
201
196
  "data-chrome": "panel",
202
- "data-open": o ? "true" : "false",
203
197
  role: "dialog",
204
198
  "aria-modal": "true",
205
199
  className: "gloss-panel-chrome",
206
- style: N,
200
+ style: w,
207
201
  children: [
208
202
  /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__header", children: /* @__PURE__ */ i(
209
203
  "button",
@@ -217,23 +211,60 @@ function x({ children: e, onClose: n, isOpen: t = !0, footer: l }) {
217
211
  }
218
212
  ) }),
219
213
  /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__body", children: e }),
220
- l != null && /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__footer", children: l })
214
+ t != null && /* @__PURE__ */ i("div", { className: "gloss-panel-chrome__footer", children: t })
221
215
  ]
222
216
  }
223
217
  );
224
218
  }
225
- const H = {
219
+ const H = "(prefers-reduced-motion: reduce)";
220
+ function v() {
221
+ return typeof window > "u" || typeof window.matchMedia != "function" ? null : window.matchMedia(H);
222
+ }
223
+ function b(e) {
224
+ const n = v();
225
+ return n ? (n.addEventListener("change", e), () => {
226
+ n.removeEventListener("change", e);
227
+ }) : () => {
228
+ };
229
+ }
230
+ function A() {
231
+ const e = v();
232
+ return e ? e.matches : !1;
233
+ }
234
+ function F() {
235
+ return !1;
236
+ }
237
+ function R() {
238
+ return S(b, A, F);
239
+ }
240
+ function k({ isOpen: e, children: n }) {
241
+ const t = R(), l = [
242
+ "gloss-panel-mount",
243
+ e ? "has-panel" : "",
244
+ t ? "reduced-motion" : ""
245
+ ].filter(Boolean).join(" ");
246
+ return /* @__PURE__ */ i(
247
+ "div",
248
+ {
249
+ className: l,
250
+ "data-mount": "panel",
251
+ "data-open": e ? "true" : "false",
252
+ children: n
253
+ }
254
+ );
255
+ }
256
+ const M = {
226
257
  position: "fixed",
227
258
  top: 0,
228
259
  left: 0,
229
260
  right: 0,
230
261
  height: "var(--tb-h, 60px)",
231
- perspective: "1200px",
262
+ perspective: "var(--panel-perspective, 1500px)",
232
263
  perspectiveOrigin: "center bottom",
233
264
  overflow: "visible",
234
265
  pointerEvents: "none",
235
266
  zIndex: 55
236
- }, b = {
267
+ }, U = {
237
268
  position: "fixed",
238
269
  top: "var(--tb-h, 60px)",
239
270
  left: 0,
@@ -249,57 +280,57 @@ const H = {
249
280
  pointerEvents: "none",
250
281
  background: "rgba(0, 0, 0, 0.04)"
251
282
  };
252
- function R({ panelComponents: e }) {
253
- const { state: n, dispatch: t, getCloseLog: l } = S(), o = n.activePanelId ? e[n.activePanelId] : null;
254
- n.activePanelId && !o && process.env.NODE_ENV !== "production" && console.error(
283
+ function q({ panelComponents: e }) {
284
+ const { state: n, dispatch: t, getCloseLog: l } = P(), c = n.activePanelId ? e[n.activePanelId] : null;
285
+ n.activePanelId && !c && process.env.NODE_ENV !== "production" && console.error(
255
286
  "[panels] No panel component registered for activePanelId:",
256
287
  n.activePanelId
257
- ), s(() => {
288
+ ), a(() => {
258
289
  if (n.activePanelId == null) return;
259
- function c(I) {
260
- I.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
290
+ function o(C) {
291
+ C.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
261
292
  }
262
- return document.addEventListener("keydown", c), () => {
263
- document.removeEventListener("keydown", c);
293
+ return document.addEventListener("keydown", o), () => {
294
+ document.removeEventListener("keydown", o);
264
295
  };
265
296
  }, [n.activePanelId, t]);
266
- const a = u(n);
267
- C(() => {
268
- a.current = n;
269
- }), s(() => {
297
+ const s = u(n);
298
+ _(() => {
299
+ s.current = n;
300
+ }), a(() => {
270
301
  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 = {
302
+ const o = window;
303
+ return o.__panelsHostHandle && console.warn("[panels] multiple PanelHost/PanelHostShell instances mounted; dev handle is unreliable"), o.__panelsHostHandle = {
273
304
  dispatch: t,
274
- getState: () => a.current,
305
+ getState: () => s.current,
275
306
  getCloseLog: l
276
307
  }, () => {
277
- c.__panelsHostHandle?.dispatch === t && delete c.__panelsHostHandle;
308
+ o.__panelsHostHandle?.dispatch === t && delete o.__panelsHostHandle;
278
309
  };
279
310
  }, [t, l]);
280
311
  const r = g(() => {
281
312
  t({ type: "CLOSE_PANEL", reason: "nav-escape-hatch" });
282
313
  }, [t]);
283
- return /* @__PURE__ */ i("div", { "data-panel-host": "true", style: H, children: n.activePanelId != null && o != null && /* @__PURE__ */ f(v, { children: [
314
+ return /* @__PURE__ */ i("div", { "data-panel-host": "true", style: M, children: n.activePanelId != null && c != null && /* @__PURE__ */ f(I, { children: [
284
315
  /* @__PURE__ */ i(
285
316
  "div",
286
317
  {
287
318
  "data-panel-scrim": "true",
288
- style: b,
319
+ style: U,
289
320
  onClick: r
290
321
  }
291
322
  ),
292
- /* @__PURE__ */ i(
323
+ /* @__PURE__ */ i(k, { isOpen: !0, children: /* @__PURE__ */ i(
293
324
  x,
294
325
  {
295
326
  isOpen: !0,
296
327
  onClose: () => t({ type: "CLOSE_PANEL", reason: "header-x" }),
297
- children: /* @__PURE__ */ i(o, { isOpen: !0 })
328
+ children: /* @__PURE__ */ i(c, { isOpen: !0 })
298
329
  }
299
- )
330
+ ) })
300
331
  ] }) });
301
332
  }
302
- const U = {
333
+ const z = {
303
334
  "apply-button": !0,
304
335
  // the ONLY commit reason
305
336
  "cancel-button": !1,
@@ -313,14 +344,16 @@ const U = {
313
344
  "nav-escape-hatch": !1
314
345
  };
315
346
  export {
316
- U as C,
317
- k as P,
318
- F as a,
319
- R as b,
347
+ z as C,
348
+ j as P,
349
+ V as a,
350
+ q as b,
320
351
  x as c,
321
- D as d,
322
- T as e,
323
- m as i,
324
- L as r,
325
- S as u
352
+ N as d,
353
+ D as e,
354
+ k as f,
355
+ R as g,
356
+ y as i,
357
+ T as r,
358
+ P as u
326
359
  };