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