@floegence/floe-webapp-core 0.72.0 → 0.73.0

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.
@@ -16,8 +16,8 @@ export interface DialogProps {
16
16
  children: JSX.Element;
17
17
  footer?: JSX.Element;
18
18
  class?: string;
19
- /** Bottom drawers retain the same modal and surface-placement contract. */
20
- presentation?: 'dialog' | 'bottom-drawer';
19
+ /** Drawers retain the same modal, visible-viewport and surface-placement contract. */
20
+ presentation?: 'dialog' | 'bottom-drawer' | 'side-drawer';
21
21
  /** Undefined uses the default header; null leaves only the accessible title. */
22
22
  header?: JSX.Element;
23
23
  contentClass?: string;
@@ -1,208 +1,228 @@
1
- import { createComponent as r, use as L, setAttribute as s, style as ee, Portal as te, spread as T, mergeProps as B, memo as _, insert as l, effect as D, className as N, template as g } from "solid-js/web";
2
- import { createUniqueId as ne, createSignal as F, createEffect as G, onCleanup as j, createMemo as q, Show as f, untrack as re } from "solid-js";
1
+ import { createComponent as o, use as G, setAttribute as f, style as ne, Portal as ae, spread as I, mergeProps as M, memo as C, insert as i, effect as D, className as q, template as m } from "solid-js/web";
2
+ import { createSignal as P, onMount as ie, onCleanup as E, createUniqueId as le, createEffect as K, createMemo as U, Show as g, untrack as V } from "solid-js";
3
3
  import { cn as y } from "../../utils/cn.js";
4
- import { Button as I } from "./Button.js";
5
- import { X as oe } from "../icons/index.js";
6
- import { useResolvedFloeConfig as ae } from "../../context/FloeConfigContext.js";
7
- import { useOverlayMask as le } from "../../hooks/useOverlayMask.js";
8
- import { resolveSurfacePortalHost as ie, DIALOG_SURFACE_BOUNDARY_ATTR as A, SURFACE_PORTAL_LAYER_ATTR as de, DIALOG_SURFACE_HOST_ATTR as ce, isSurfacePortalMode as K, projectSurfacePortalRect as ue, resolveSurfacePortalBoundaryRect as se, resolveSurfacePortalMount as fe } from "./dialogSurfaceScope.js";
9
- import { LOCAL_INTERACTION_SURFACE_ATTR as ge } from "./localInteractionSurface.js";
10
- import { createFloatingPresence as me } from "./floatingPresence.js";
11
- import { useDialogPlacement as he } from "./DialogPlacementContext.js";
12
- var be = /* @__PURE__ */ g("<span aria-hidden=true>"), we = /* @__PURE__ */ g('<h2 class="text-sm font-semibold">'), ye = /* @__PURE__ */ g('<div data-floe-dialog-header class="flex items-start justify-between p-3 border-b border-border"><div>'), ve = /* @__PURE__ */ g('<p class="mb-3 shrink-0 text-sm text-muted-foreground last:mb-0">'), xe = /* @__PURE__ */ g('<div data-floe-dialog-footer class="flex items-center justify-end gap-2 p-3 border-t border-border">'), $e = /* @__PURE__ */ g("<div><div></div><div><div data-floe-surface=floating><div data-floe-dialog-body>"), Ce = /* @__PURE__ */ g("<h2 class=sr-only>");
13
- const _e = {
4
+ import { Button as j } from "./Button.js";
5
+ import { X as de } from "../icons/index.js";
6
+ import { useResolvedFloeConfig as se } from "../../context/FloeConfigContext.js";
7
+ import { useOverlayMask as ce } from "../../hooks/useOverlayMask.js";
8
+ import { resolveSurfacePortalHost as ue, DIALOG_SURFACE_BOUNDARY_ATTR as _, SURFACE_PORTAL_LAYER_ATTR as fe, DIALOG_SURFACE_HOST_ATTR as ge, isSurfacePortalMode as z, projectSurfacePortalRect as me, resolveSurfacePortalBoundaryRect as he, resolveSurfacePortalMount as be } from "./dialogSurfaceScope.js";
9
+ import { LOCAL_INTERACTION_SURFACE_ATTR as ve } from "./localInteractionSurface.js";
10
+ import { createFloatingPresence as we } from "./floatingPresence.js";
11
+ import { useDialogPlacement as ye } from "./DialogPlacementContext.js";
12
+ import { observeViewport as xe, viewportStyle as pe } from "../../viewport.js";
13
+ import { resolveFloatingBoundary as $e } from "./surfaceFloatingBoundary.js";
14
+ var Ae = /* @__PURE__ */ m("<span aria-hidden=true>"), Ce = /* @__PURE__ */ m('<h2 class="text-sm font-semibold">'), _e = /* @__PURE__ */ m('<div data-floe-dialog-header class="flex shrink-0 items-start justify-between p-3 border-b border-border"><div>'), ke = /* @__PURE__ */ m('<p class="mb-3 shrink-0 text-sm text-muted-foreground last:mb-0">'), Oe = /* @__PURE__ */ m('<div data-floe-dialog-footer class="flex shrink-0 items-center justify-end gap-2 p-3 border-t border-border">'), Re = /* @__PURE__ */ m("<div><div></div><div><div data-floe-surface=floating><div data-floe-dialog-body>"), De = /* @__PURE__ */ m("<h2 class=sr-only>");
15
+ const Pe = {
14
16
  display: "none"
15
17
  };
16
- function Ae(e) {
18
+ function Se(e) {
17
19
  if (typeof queueMicrotask == "function") {
18
20
  queueMicrotask(e);
19
21
  return;
20
22
  }
21
23
  Promise.resolve().then(e);
22
24
  }
23
- function U(e) {
25
+ function Z(e) {
24
26
  return `${e.left}|${e.top}|${e.right}|${e.bottom}|${e.width}|${e.height}`;
25
27
  }
26
- function Oe(e) {
28
+ function Te(e) {
27
29
  return typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(e) : window.setTimeout(() => e(Date.now()), 16);
28
30
  }
29
- function ke(e) {
31
+ function Be(e) {
30
32
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
31
33
  window.cancelAnimationFrame(e);
32
34
  return;
33
35
  }
34
36
  window.clearTimeout(e);
35
37
  }
36
- function Re(e) {
37
- const v = he(), c = ne(), P = () => `dialog-${c}-title`, E = () => `dialog-${c}-description`;
38
- let p;
39
- const [O, z] = F(null), [M, Z] = F(0), [V, W] = F(0), u = () => e.presentation === "bottom-drawer", d = me({
40
- open: () => e.open && !!O() && M() > 0,
38
+ function Fe(e) {
39
+ const x = ye(), [d, W] = P();
40
+ ie(() => E(xe(window, W)));
41
+ const c = le(), S = () => `dialog-${c}-title`, H = () => `dialog-${c}-description`;
42
+ let T;
43
+ const [k, Y] = P(null), [L, X] = P(0), [J, Q] = P(0), B = () => e.presentation === "side-drawer", u = () => e.presentation === "bottom-drawer", s = we({
44
+ open: () => e.open && !!k() && L() > 0,
41
45
  get exitDurationMs() {
42
46
  return u() ? 180 : 160;
43
47
  }
44
- }), x = () => d.mounted() && !!O() && M() > 0;
45
- G(() => e.onPresenceChange?.(x())), j(() => e.onPresenceChange?.(!1));
46
- const Y = (n) => {
47
- z(n), Ae(() => {
48
- re(O) === n && Z((i) => i + 1);
48
+ }), p = () => s.mounted() && !!k() && L() > 0;
49
+ K(() => e.onPresenceChange?.(p())), E(() => e.onPresenceChange?.(!1));
50
+ const ee = (t) => {
51
+ Y(t), Se(() => {
52
+ V(k) === t && X((l) => l + 1);
49
53
  });
50
- }, k = q(() => x() ? ie({
51
- owner: O()
54
+ }, O = U(() => p() ? ue({
55
+ owner: k()
52
56
  }) : {
53
57
  host: null,
54
58
  boundaryHost: null,
55
59
  mountHost: null,
56
60
  mode: "global"
57
- }), $ = () => `dialog-boundary-${c}`, o = () => v.mode() === "auto" && K(k()), X = () => o() ? fe(k()) : void 0, H = () => e.globalZIndex ?? v.globalZIndex(), S = (n) => ue(se(n), n), J = () => S(k()), R = q(() => (V(), J())), Q = (n) => typeof Element < "u" && n instanceof Element ? !!n.closest(`[${A}="${$()}"]`) : typeof Node < "u" && n instanceof Node ? !!n.parentElement?.closest(`[${A}="${$()}"]`) : !1;
58
- return G(() => {
59
- const n = k();
60
- if (!x() || !o() || typeof window > "u")
61
+ }), $ = () => `dialog-boundary-${c}`, n = () => x.mode() === "auto" && z(O()), te = () => n() ? be(O()) : void 0, N = () => e.globalZIndex ?? x.globalZIndex(), F = (t) => me($e(t, void 0, V(d)?.safeArea) ?? he(t), t), re = () => F(O()), R = U(() => (J(), d(), re())), oe = (t) => typeof Element < "u" && t instanceof Element ? !!t.closest(`[${_}="${$()}"]`) : typeof Node < "u" && t instanceof Node ? !!t.parentElement?.closest(`[${_}="${$()}"]`) : !1;
62
+ return K(() => {
63
+ const t = O();
64
+ if (!p() || !n() || typeof window > "u")
61
65
  return;
62
- let i = !1, m = null, a = U(S(n));
63
- const h = () => {
64
- if (i || !K(n))
66
+ let l = !1, h = null, a = Z(F(t));
67
+ const b = () => {
68
+ if (l || !z(t))
65
69
  return;
66
- const t = U(S(n));
67
- t !== a && (a = t, W((b) => b + 1));
68
- }, C = () => {
69
- i || (m = Oe(() => {
70
- h(), C();
70
+ const r = Z(F(t));
71
+ r !== a && (a = r, Q((v) => v + 1));
72
+ }, A = () => {
73
+ l || (h = Te(() => {
74
+ b(), A();
71
75
  }));
72
76
  };
73
- C(), j(() => {
74
- i = !0, m !== null && ke(m);
77
+ A(), E(() => {
78
+ l = !0, h !== null && Be(h);
75
79
  });
76
- }), le({
77
- open: x,
78
- root: () => p,
79
- containsTarget: Q,
80
+ }), ce({
81
+ open: p,
82
+ root: () => T,
83
+ containsTarget: oe,
80
84
  onClose: () => e.onOpenChange(!1),
81
- lockBodyScroll: () => !o(),
85
+ lockBodyScroll: () => !n(),
82
86
  trapFocus: !0,
83
- closeOnEscape: () => o() ? "inside" : !0,
87
+ closeOnEscape: () => n() ? "inside" : !0,
84
88
  escapeKeyPhase: () => e.escapeKeyPhase ?? "capture",
85
89
  blockHotkeys: !0,
86
90
  // Block scroll bleed outside the dialog while keeping the dialog content scrollable.
87
- blockWheel: () => o() ? "none" : "outside",
88
- blockTouchMove: () => o() ? "none" : "outside",
91
+ blockWheel: () => n() ? "none" : "outside",
92
+ blockTouchMove: () => n() ? "none" : "outside",
89
93
  restoreFocus: !0
90
94
  }), [(() => {
91
- var n = be();
92
- return L(Y, n), s(n, "data-floe-dialog-owner-anchor", c), ee(n, _e), n;
93
- })(), r(f, {
95
+ var t = Ae();
96
+ return G(ee, t), f(t, "data-floe-dialog-owner-anchor", c), ne(t, Pe), t;
97
+ })(), o(g, {
94
98
  get when() {
95
- return x();
99
+ return p();
96
100
  },
97
101
  get children() {
98
- return r(te, {
102
+ return o(ae, {
99
103
  get mount() {
100
- return X();
104
+ return te();
101
105
  },
102
106
  get children() {
103
- var n = $e(), i = n.firstChild, m = i.nextSibling, a = m.firstChild, h = a.firstChild;
104
- s(n, "data-floe-dialog-overlay-root", c), T(n, B({
107
+ var t = Re(), l = t.firstChild, h = l.nextSibling, a = h.firstChild, b = a.firstChild;
108
+ f(t, "data-floe-dialog-overlay-root", c), I(t, M({
105
109
  get "data-floe-dialog-mode"() {
106
- return o() ? "surface" : "global";
110
+ return n() ? "surface" : "global";
107
111
  },
108
112
  get "data-floe-dialog-presentation"() {
109
113
  return e.presentation ?? "dialog";
110
114
  },
111
115
  get "data-floating-presence"() {
112
- return d.state();
116
+ return s.state();
113
117
  },
114
118
  get "aria-hidden"() {
115
- return d.exiting() ? "true" : void 0;
119
+ return s.exiting() ? "true" : void 0;
116
120
  }
117
121
  }, {
118
- [ge]: "true"
122
+ [ve]: "true"
119
123
  }, () => ({
120
- [de]: "true",
121
- [A]: $()
124
+ [fe]: "true",
125
+ [_]: $()
122
126
  }), {
123
127
  get class() {
124
- return y(o() ? "absolute z-20 box-border p-3" : y("fixed inset-0 box-border p-4", H() === void 0 && "z-50"), u() && "floe-bottom-drawer-overlay", d.exiting() && !u() && "pointer-events-none");
128
+ return y(n() ? "absolute z-20 box-border p-3" : y("fixed box-border p-4", N() === void 0 && "z-50"), u() && "floe-bottom-drawer-overlay", B() && "floe-side-drawer-overlay", s.exiting() && !u() && "pointer-events-none");
125
129
  },
126
130
  get style() {
127
- return _(() => !!o())() ? {
131
+ return C(() => !!n())() ? {
128
132
  left: `${R().left}px`,
129
133
  top: `${R().top}px`,
130
134
  width: `${R().width}px`,
131
135
  height: `${R().height}px`
132
136
  } : {
133
- "z-index": H()
137
+ ...d() ? pe(d()) : {
138
+ inset: "0"
139
+ },
140
+ "--floe-dialog-safe-top": `${d()?.safeArea.top ?? 0}px`,
141
+ "--floe-dialog-safe-right": `${d()?.safeArea.right ?? 0}px`,
142
+ "--floe-dialog-safe-bottom": `${d()?.safeArea.bottom ?? 0}px`,
143
+ "--floe-dialog-safe-left": `${d()?.safeArea.left ?? 0}px`,
144
+ "padding-top": "max(var(--floe-dialog-gap-y, 1rem), var(--floe-dialog-safe-top))",
145
+ "padding-right": "max(var(--floe-dialog-gap-x, 1rem), var(--floe-dialog-safe-right))",
146
+ "padding-bottom": "max(var(--floe-dialog-gap-y, 1rem), var(--floe-dialog-safe-bottom))",
147
+ "padding-left": "max(var(--floe-dialog-gap-x, 1rem), var(--floe-dialog-safe-left))",
148
+ "z-index": N()
134
149
  };
135
150
  }
136
- }), !1, !0), s(i, "data-floe-dialog-backdrop", c), T(i, B(() => ({
137
- [A]: $()
151
+ }), !1, !0), f(l, "data-floe-dialog-backdrop", c), I(l, M(() => ({
152
+ [_]: $()
138
153
  }), {
139
154
  get "data-floating-presence"() {
140
- return d.state();
155
+ return s.state();
141
156
  },
142
157
  get class() {
143
- return y("absolute inset-0 floe-floating-presence floe-floating-backdrop", e.closeOnBackdropClick === !1 ? "cursor-default" : "cursor-pointer", u() ? "floe-bottom-drawer-backdrop" : o() ? "bg-background/72 backdrop-blur-[2px]" : "bg-background/80 backdrop-blur-sm");
158
+ return y("absolute inset-0 floe-floating-presence floe-floating-backdrop", e.closeOnBackdropClick === !1 ? "cursor-default" : "cursor-pointer", u() ? "floe-bottom-drawer-backdrop" : n() ? "bg-background/72 backdrop-blur-[2px]" : "bg-background/80 backdrop-blur-sm");
144
159
  },
145
160
  onClick: () => {
146
- !d.exiting() && e.closeOnBackdropClick !== !1 && e.onOpenChange(!1);
161
+ !s.exiting() && e.closeOnBackdropClick !== !1 && e.onOpenChange(!1);
147
162
  }
148
163
  }), !1, !1);
149
- var C = p;
150
- return typeof C == "function" ? L(C, a) : p = a, s(a, "data-floe-dialog-panel", c), T(a, B(() => ({
151
- [A]: $(),
152
- [ce]: "true"
164
+ var A = T;
165
+ return typeof A == "function" ? G(A, a) : T = a, f(a, "data-floe-dialog-panel", c), I(a, M(() => ({
166
+ [_]: $(),
167
+ [ge]: "true"
153
168
  }), {
154
169
  get class() {
155
- return y(o() ? "flex max-h-[calc(100%-1rem)] w-[min(32rem,calc(100%-1rem))] max-w-[calc(100%-1rem)] flex-col" : "w-full max-w-md max-h-[85vh]", "bg-card text-card-foreground rounded-md shadow-lg", "border border-border", "floe-floating-presence", u() ? "floe-bottom-drawer-panel" : "floe-floating-dialog-panel", "pointer-events-auto flex flex-col", e.class);
170
+ return y(n() ? "flex max-h-[calc(100%-1rem)] w-[min(32rem,calc(100%-1rem))] max-w-[calc(100%-1rem)] flex-col" : "w-full max-w-md", "bg-card text-card-foreground rounded-md shadow-lg", "border border-border", "floe-floating-presence", u() ? "floe-bottom-drawer-panel" : B() ? "floe-side-drawer-panel" : "floe-floating-dialog-panel", "pointer-events-auto flex flex-col", e.class);
171
+ },
172
+ style: {
173
+ "max-height": "100%",
174
+ "min-height": "0",
175
+ "min-width": "0"
156
176
  },
157
177
  get "data-floating-presence"() {
158
- return d.state();
178
+ return s.state();
159
179
  },
160
180
  get inert() {
161
- return _(() => !!u())() && d.exiting();
181
+ return C(() => !!u())() && s.exiting();
162
182
  },
163
183
  role: "dialog",
164
184
  get "aria-modal"() {
165
- return o() ? void 0 : "true";
185
+ return n() ? void 0 : "true";
166
186
  },
167
187
  get "aria-labelledby"() {
168
- return _(() => !!e.title)() ? P() : void 0;
188
+ return C(() => !!e.title)() ? S() : void 0;
169
189
  },
170
190
  get "aria-describedby"() {
171
- return _(() => !!e.bodyDescription)() ? E() : void 0;
191
+ return C(() => !!e.bodyDescription)() ? H() : void 0;
172
192
  },
173
- onKeyDown: (t) => e.onKeyDown?.(t),
193
+ onKeyDown: (r) => e.onKeyDown?.(r),
174
194
  tabIndex: -1
175
- }), !1, !0), l(a, r(f, {
195
+ }), !1, !0), i(a, o(g, {
176
196
  get when() {
177
197
  return e.header === void 0;
178
198
  },
179
199
  get fallback() {
180
- return [r(f, {
200
+ return [o(g, {
181
201
  get when() {
182
202
  return e.title;
183
203
  },
184
204
  get children() {
185
- var t = Ce();
186
- return l(t, () => e.title), D(() => s(t, "id", P())), t;
205
+ var r = De();
206
+ return i(r, () => e.title), D(() => f(r, "id", S())), r;
187
207
  }
188
- }), _(() => e.header)];
208
+ }), C(() => e.header)];
189
209
  },
190
210
  get children() {
191
- return r(f, {
211
+ return o(g, {
192
212
  get when() {
193
213
  return e.title;
194
214
  },
195
215
  get children() {
196
- var t = ye(), b = t.firstChild;
197
- return l(b, r(f, {
216
+ var r = _e(), v = r.firstChild;
217
+ return i(v, o(g, {
198
218
  get when() {
199
219
  return e.title;
200
220
  },
201
221
  get children() {
202
- var w = we();
203
- return l(w, () => e.title), D(() => s(w, "id", P())), w;
222
+ var w = Ce();
223
+ return i(w, () => e.title), D(() => f(w, "id", S())), w;
204
224
  }
205
- })), l(t, r(I, {
225
+ })), i(r, o(j, {
206
226
  variant: "ghost-destructive",
207
227
  size: "icon",
208
228
  class: "-my-2 -mr-2 h-[46px] w-[46px] shrink-0 sm:my-0 sm:-mr-1 sm:h-6 sm:w-6",
@@ -211,45 +231,45 @@ function Re(e) {
211
231
  return e.closeLabel ?? "Close";
212
232
  },
213
233
  get children() {
214
- return r(oe, {
234
+ return o(de, {
215
235
  class: "w-3.5 h-3.5"
216
236
  });
217
237
  }
218
- }), null), t;
238
+ }), null), r;
219
239
  }
220
240
  });
221
241
  }
222
- }), h), l(h, r(f, {
242
+ }), b), i(b, o(g, {
223
243
  get when() {
224
244
  return e.bodyDescription;
225
245
  },
226
246
  get children() {
227
- var t = ve();
228
- return l(t, () => e.bodyDescription), D(() => s(t, "id", E())), t;
247
+ var r = ke();
248
+ return i(r, () => e.bodyDescription), D(() => f(r, "id", H())), r;
229
249
  }
230
- }), null), l(h, () => e.children, null), l(a, r(f, {
250
+ }), null), i(b, () => e.children, null), i(a, o(g, {
231
251
  get when() {
232
252
  return e.footer;
233
253
  },
234
254
  get children() {
235
- var t = xe();
236
- return l(t, () => e.footer), t;
255
+ var r = Oe();
256
+ return i(r, () => e.footer), r;
237
257
  }
238
- }), null), D((t) => {
239
- var b = y("pointer-events-none relative z-[1] flex h-full w-full justify-center", u() ? "items-end" : "items-center"), w = y("min-h-0 flex-1 overflow-auto overscroll-contain p-3", e.contentClass);
240
- return b !== t.e && N(m, t.e = b), w !== t.t && N(h, t.t = w), t;
258
+ }), null), D((r) => {
259
+ var v = y("pointer-events-none relative z-[1] flex h-full w-full", B() ? "items-stretch justify-end" : u() ? "items-end justify-center" : "items-center justify-center"), w = y("min-h-0 flex-1 overflow-auto overscroll-contain p-3", e.contentClass);
260
+ return v !== r.e && q(h, r.e = v), w !== r.t && q(b, r.t = w), r;
241
261
  }, {
242
262
  e: void 0,
243
263
  t: void 0
244
- }), n;
264
+ }), t;
245
265
  }
246
266
  });
247
267
  }
248
268
  })];
249
269
  }
250
- function Ne(e) {
251
- const v = ae();
252
- return r(Re, {
270
+ function We(e) {
271
+ const x = se();
272
+ return o(Fe, {
253
273
  get open() {
254
274
  return e.open;
255
275
  },
@@ -266,16 +286,16 @@ function Ne(e) {
266
286
  return e.globalZIndex;
267
287
  },
268
288
  get footer() {
269
- return [r(I, {
289
+ return [o(j, {
270
290
  variant: "ghost",
271
291
  onClick: () => e.onOpenChange(!1),
272
292
  get disabled() {
273
293
  return e.loading;
274
294
  },
275
295
  get children() {
276
- return e.cancelText ?? v.config.strings.confirmDialog.cancel;
296
+ return e.cancelText ?? x.config.strings.confirmDialog.cancel;
277
297
  }
278
- }), r(I, {
298
+ }), o(j, {
279
299
  get variant() {
280
300
  return e.variant === "destructive" ? "destructive" : "primary";
281
301
  },
@@ -286,7 +306,7 @@ function Ne(e) {
286
306
  return e.loading;
287
307
  },
288
308
  get children() {
289
- return e.confirmText ?? v.config.strings.confirmDialog.confirm;
309
+ return e.confirmText ?? x.config.strings.confirmDialog.confirm;
290
310
  }
291
311
  })];
292
312
  },
@@ -296,6 +316,6 @@ function Ne(e) {
296
316
  });
297
317
  }
298
318
  export {
299
- Ne as ConfirmDialog,
300
- Re as Dialog
319
+ We as ConfirmDialog,
320
+ Fe as Dialog
301
321
  };