@mt-gloss/ui 0.1.80 → 0.1.82

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,48 +1,48 @@
1
1
  import { jsx as o, jsxs as m } from "react/jsx-runtime";
2
- import { g as p, d as B, al as g, i as _ } from "./UIContext-DP6JGCto.js";
3
- import b, { useEffect as f } from "react";
4
- const N = function(l) {
5
- const { as: e, htmlFor: s, className: t, ...n } = l;
2
+ import { d as p, B, ak as g, f } from "./UIContext-C7m-9sGv.js";
3
+ import b, { useEffect as _ } from "react";
4
+ const N = function(t) {
5
+ const { as: e, htmlFor: s, className: l, ...n } = t;
6
6
  return /* @__PURE__ */ o(
7
7
  p,
8
8
  {
9
9
  as: e || "label",
10
10
  htmlFor: s,
11
- className: t ? `gloss-base-label ${t}` : "gloss-base-label",
11
+ className: l ? `gloss-base-label ${l}` : "gloss-base-label",
12
12
  ...n
13
13
  }
14
14
  );
15
15
  };
16
16
  N.displayName = "BaseLabel";
17
- const h = function(l) {
18
- const { as: e, className: s, ...t } = l;
17
+ const h = function(t) {
18
+ const { as: e, className: s, ...l } = t;
19
19
  return /* @__PURE__ */ o(
20
20
  p,
21
21
  {
22
22
  as: e || "span",
23
23
  "data-role": "value",
24
24
  className: s ? `gloss-base-value ${s}` : "gloss-base-value",
25
- ...t
25
+ ...l
26
26
  }
27
27
  );
28
28
  };
29
29
  h.displayName = "BaseValue";
30
30
  function v({
31
31
  definition: a,
32
- open: l,
32
+ open: t,
33
33
  onDismiss: e,
34
34
  className: s,
35
- style: t,
35
+ style: l,
36
36
  children: n
37
37
  }) {
38
38
  const c = a?.position ?? "top-right", r = a?.duration ?? 0;
39
- f(() => {
40
- if (!l || r <= 0 || !e) return;
39
+ _(() => {
40
+ if (!t || r <= 0 || !e) return;
41
41
  const y = setTimeout(() => {
42
42
  e();
43
43
  }, r);
44
44
  return () => clearTimeout(y);
45
- }, [l, r, e]);
45
+ }, [t, r, e]);
46
46
  const i = {
47
47
  portal: !0,
48
48
  dismissOnClickOutside: !1,
@@ -57,13 +57,13 @@ function v({
57
57
  B,
58
58
  {
59
59
  definition: i,
60
- open: l,
60
+ open: t,
61
61
  onDismiss: e,
62
62
  children: /* @__PURE__ */ o(
63
63
  "div",
64
64
  {
65
65
  className: u.join(" "),
66
- style: t,
66
+ style: l,
67
67
  role: "status",
68
68
  "aria-live": "polite",
69
69
  children: n
@@ -82,11 +82,11 @@ const A = {
82
82
  iconColor: "--_icon-color"
83
83
  };
84
84
  function C(a) {
85
- const { definition: l, className: e, style: s, role: t, children: n, ...c } = a, { style: r, dataAttrs: i } = g(l, A);
85
+ const { definition: t, className: e, style: s, role: l, children: n, ...c } = a, { style: r, dataAttrs: i } = g(t, A);
86
86
  return /* @__PURE__ */ o(
87
87
  "div",
88
88
  {
89
- role: t || "alert",
89
+ role: l || "alert",
90
90
  className: e ? `gloss-base-alert ${e}` : "gloss-base-alert",
91
91
  style: { ...r, ...s },
92
92
  ...i,
@@ -102,8 +102,8 @@ const S = {
102
102
  fontSize: "--_font-size"
103
103
  };
104
104
  function $(a) {
105
- const { definition: l, separator: e = "/", className: s, style: t, children: n } = a, { style: c } = g(
106
- l,
105
+ const { definition: t, separator: e = "/", className: s, style: l, children: n } = a, { style: c } = g(
106
+ t,
107
107
  S
108
108
  ), r = b.Children.toArray(n);
109
109
  return /* @__PURE__ */ o(
@@ -111,7 +111,7 @@ function $(a) {
111
111
  {
112
112
  "aria-label": "Breadcrumb",
113
113
  className: s ? `gloss-base-breadcrumbs-nav ${s}` : "gloss-base-breadcrumbs-nav",
114
- style: { ...c, ...t },
114
+ style: { ...c, ...l },
115
115
  children: /* @__PURE__ */ o("ol", { className: "gloss-base-breadcrumbs", children: r.map((i, d) => {
116
116
  const u = d === r.length - 1;
117
117
  return /* @__PURE__ */ m(b.Fragment, { children: [
@@ -132,10 +132,10 @@ function $(a) {
132
132
  $.displayName = "BaseBreadcrumbs";
133
133
  function T(a) {
134
134
  const {
135
- as: l,
135
+ as: t,
136
136
  definition: e,
137
137
  loading: s = !1,
138
- disabled: t = !1,
138
+ disabled: l = !1,
139
139
  className: n,
140
140
  style: c,
141
141
  children: r,
@@ -145,11 +145,11 @@ function T(a) {
145
145
  n
146
146
  ].filter(Boolean).join(" ");
147
147
  return /* @__PURE__ */ m(
148
- _,
148
+ f,
149
149
  {
150
- as: l,
150
+ as: t,
151
151
  definition: e,
152
- disabled: t || s,
152
+ disabled: l || s,
153
153
  loading: s,
154
154
  className: d,
155
155
  style: c,
@@ -0,0 +1,223 @@
1
+ import { jsx as a, jsxs as u, Fragment as P } from "react/jsx-runtime";
2
+ import { createContext as h, useContext as p, useReducer as g, useRef as i, useEffect as r, useMemo as f, useCallback as v, useLayoutEffect as C } from "react";
3
+ const c = h(null);
4
+ function m() {
5
+ const e = p(c);
6
+ if (!e)
7
+ throw new Error(
8
+ "[panels] usePanelContext must be used inside <PanelProvider>. See @mt-gloss/ui/composites/panels."
9
+ );
10
+ return e;
11
+ }
12
+ function O() {
13
+ return p(c);
14
+ }
15
+ const S = {
16
+ activePanelId: null,
17
+ lastClose: null,
18
+ pendingSideEffects: []
19
+ };
20
+ function _(e, n) {
21
+ switch (n.type) {
22
+ case "OPEN_PANEL":
23
+ return n.panelId === "notification-center" && e.activePanelId === null ? {
24
+ activePanelId: "notification-center",
25
+ lastClose: null,
26
+ // reset lastClose on fresh open
27
+ pendingSideEffects: e.pendingSideEffects
28
+ // preserve any draining queue
29
+ } : n.panelId === "notification-center" && e.activePanelId === "notification-center" ? e : {
30
+ ...e,
31
+ pendingSideEffects: [
32
+ ...e.pendingSideEffects,
33
+ {
34
+ type: "INVALID_DISPATCH",
35
+ reason: `panel-not-supported-in-P1:${n.panelId}`
36
+ }
37
+ ]
38
+ };
39
+ case "CLOSE_PANEL":
40
+ return e.activePanelId === null ? e : {
41
+ activePanelId: null,
42
+ lastClose: { panelId: e.activePanelId, reason: n.reason },
43
+ pendingSideEffects: e.pendingSideEffects
44
+ };
45
+ case "DRAIN_SIDE_EFFECTS":
46
+ return e.pendingSideEffects.length === 0 ? e : {
47
+ ...e,
48
+ pendingSideEffects: []
49
+ };
50
+ default:
51
+ return e;
52
+ }
53
+ }
54
+ function y(e) {
55
+ return e.activePanelId === "notification-center" ? "notif-center" : (e.activePanelId != null, "idle");
56
+ }
57
+ function x() {
58
+ const [e, n] = g(_, S), t = i([]);
59
+ i(null), r(() => {
60
+ if (e.pendingSideEffects.length !== 0) {
61
+ for (const o of e.pendingSideEffects)
62
+ o.type === "SCHEDULE_TIMER" ? window.setTimeout(() => n(o.action), Math.max(0, o.ms)) : o.type === "INVALID_DISPATCH" && process.env.NODE_ENV !== "production" && console.warn("[panels] INVALID_DISPATCH:", o.reason);
63
+ n({ type: "DRAIN_SIDE_EFFECTS" });
64
+ }
65
+ }, [e.pendingSideEffects]), r(() => {
66
+ if (!e.lastClose) return;
67
+ const o = {
68
+ panelId: e.lastClose.panelId,
69
+ reason: e.lastClose.reason,
70
+ at: Date.now(),
71
+ note: e.lastClose.reason === "nav-escape-hatch" ? "F21: backdrop-click OR page-nav escape" : void 0
72
+ };
73
+ t.current = [
74
+ ...t.current.slice(-99),
75
+ o
76
+ ];
77
+ }, [e.lastClose]);
78
+ const l = f(
79
+ () => y(e),
80
+ // eslint-disable-next-line react-hooks/exhaustive-deps
81
+ [e.activePanelId]
82
+ ), s = v(() => t.current.slice(), []);
83
+ return { state: e, surfaceState: l, dispatch: n, getCloseLog: s };
84
+ }
85
+ function k({ children: e }) {
86
+ const n = x(), t = f(
87
+ () => n,
88
+ // Re-publish only when one of the four coordinator fields changes identity.
89
+ // dispatch + getCloseLog are stable. state + surfaceState change on dispatch.
90
+ [n.state, n.surfaceState, n.dispatch, n.getCloseLog]
91
+ );
92
+ return /* @__PURE__ */ a(c.Provider, { value: t, children: e });
93
+ }
94
+ const N = {
95
+ position: "absolute",
96
+ top: "100%",
97
+ left: 0,
98
+ right: 0,
99
+ zIndex: 2,
100
+ pointerEvents: "auto"
101
+ };
102
+ function L({ children: e, onClose: n, isOpen: t = !0 }) {
103
+ return /* @__PURE__ */ u(
104
+ "div",
105
+ {
106
+ "data-chrome": "panel",
107
+ "data-open": t ? "true" : "false",
108
+ role: "dialog",
109
+ "aria-modal": "true",
110
+ className: "gloss-panel-chrome",
111
+ style: N,
112
+ children: [
113
+ /* @__PURE__ */ a("div", { className: "gloss-panel-chrome__header", children: /* @__PURE__ */ a(
114
+ "button",
115
+ {
116
+ id: "panel-close",
117
+ type: "button",
118
+ "aria-label": "Close panel",
119
+ className: "gloss-panel-chrome__close",
120
+ onClick: n,
121
+ children: "×"
122
+ }
123
+ ) }),
124
+ /* @__PURE__ */ a("div", { className: "gloss-panel-chrome__body", children: e })
125
+ ]
126
+ }
127
+ );
128
+ }
129
+ const b = {
130
+ position: "fixed",
131
+ top: 0,
132
+ left: 0,
133
+ right: 0,
134
+ height: "var(--tb-h, 60px)",
135
+ perspective: "1200px",
136
+ perspectiveOrigin: "center bottom",
137
+ overflow: "visible",
138
+ pointerEvents: "none",
139
+ zIndex: 55
140
+ }, w = {
141
+ position: "fixed",
142
+ top: "var(--tb-h, 60px)",
143
+ left: 0,
144
+ right: 0,
145
+ bottom: 0,
146
+ zIndex: 1,
147
+ pointerEvents: "auto",
148
+ background: "rgba(0, 0, 0, 0.04)"
149
+ };
150
+ function H({ panelComponents: e }) {
151
+ const { state: n, dispatch: t, getCloseLog: l } = m(), s = n.activePanelId ? e[n.activePanelId] : null;
152
+ n.activePanelId && !s && process.env.NODE_ENV !== "production" && console.error(
153
+ "[panels] No panel component registered for activePanelId:",
154
+ n.activePanelId
155
+ ), r(() => {
156
+ if (n.activePanelId == null) return;
157
+ function d(I) {
158
+ I.key === "Escape" && t({ type: "CLOSE_PANEL", reason: "escape-key" });
159
+ }
160
+ return document.addEventListener("keydown", d), () => {
161
+ document.removeEventListener("keydown", d);
162
+ };
163
+ }, [n.activePanelId, t]);
164
+ const o = i(n);
165
+ C(() => {
166
+ o.current = n;
167
+ }), r(() => {
168
+ if (process.env.NODE_ENV !== "production")
169
+ return window.__panelsHostHandle = {
170
+ dispatch: t,
171
+ getState: () => o.current,
172
+ getCloseLog: l
173
+ }, () => {
174
+ delete window.__panelsHostHandle;
175
+ };
176
+ }, [t, l]);
177
+ const E = v(() => {
178
+ t({ type: "CLOSE_PANEL", reason: "nav-escape-hatch" });
179
+ }, [t]);
180
+ return /* @__PURE__ */ a("div", { "data-panel-host": "true", style: b, children: n.activePanelId != null && s != null && /* @__PURE__ */ u(P, { children: [
181
+ /* @__PURE__ */ a(
182
+ "div",
183
+ {
184
+ "data-panel-scrim": "true",
185
+ style: w,
186
+ onClick: E
187
+ }
188
+ ),
189
+ /* @__PURE__ */ a(
190
+ L,
191
+ {
192
+ isOpen: !0,
193
+ onClose: () => t({ type: "CLOSE_PANEL", reason: "header-x" }),
194
+ children: /* @__PURE__ */ a(s, { isOpen: !0 })
195
+ }
196
+ )
197
+ ] }) });
198
+ }
199
+ const R = {
200
+ "apply-button": !0,
201
+ // the ONLY commit reason
202
+ "cancel-button": !1,
203
+ "header-x": !1,
204
+ "escape-key": !1,
205
+ "page-nav": !1,
206
+ "mutex-handoff": !1,
207
+ "ghost-anchor": !1,
208
+ "viewport-collapse": !1,
209
+ unmount: !1,
210
+ "nav-escape-hatch": !1
211
+ };
212
+ export {
213
+ R as C,
214
+ k as P,
215
+ O as a,
216
+ H as b,
217
+ L as c,
218
+ x as d,
219
+ y as e,
220
+ S as i,
221
+ _ as r,
222
+ m as u
223
+ };