@floegence/floe-webapp-core 0.46.3 → 0.46.5

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.
@@ -8,7 +8,7 @@ export interface DialogProps {
8
8
  children: JSX.Element;
9
9
  footer?: JSX.Element;
10
10
  class?: string;
11
- /** Optional stacking layer for global dialogs. Surface-scoped dialogs remain locally layered. */
11
+ /** Optional stacking layer for global dialogs. Overrides the placement provider default. */
12
12
  globalZIndex?: number;
13
13
  }
14
14
  /**
@@ -1,77 +1,78 @@
1
- import { createComponent as r, use as E, setAttribute as f, style as W, Portal as Y, spread as R, mergeProps as k, memo as P, insert as d, effect as H, template as u } from "solid-js/web";
2
- import { createUniqueId as X, createSignal as S, createMemo as N, createEffect as J, onCleanup as Q, Show as h, untrack as ee } from "solid-js";
3
- import { cn as p } from "../../utils/cn.js";
4
- import { Button as I } from "./Button.js";
5
- import { X as te } from "../icons/index.js";
6
- import { useResolvedFloeConfig as ne } from "../../context/FloeConfigContext.js";
7
- import { useOverlayMask as re } from "../../hooks/useOverlayMask.js";
8
- import { resolveSurfacePortalHost as oe, isSurfacePortalMode as F, DIALOG_SURFACE_BOUNDARY_ATTR as _, projectSurfacePortalRect as ie, resolveSurfacePortalBoundaryRect as le, resolveSurfacePortalMount as ae } from "./dialogSurfaceScope.js";
9
- import { LOCAL_INTERACTION_SURFACE_ATTR as de } from "./localInteractionSurface.js";
10
- import { createFloatingPresence as ce } from "./floatingPresence.js";
11
- var ue = /* @__PURE__ */ u("<span aria-hidden=true>"), se = /* @__PURE__ */ u('<h2 class="text-sm font-semibold">'), fe = /* @__PURE__ */ u('<p class="mt-0.5 text-xs text-muted-foreground">'), ge = /* @__PURE__ */ u('<div class="flex items-start justify-between p-3 border-b border-border"><div>'), me = /* @__PURE__ */ u('<div class="flex items-center justify-end gap-2 p-3 border-t border-border">'), he = /* @__PURE__ */ u('<div><div></div><div class="relative z-[1] flex h-full w-full items-center justify-center"><div><div class="flex-1 overflow-auto overscroll-contain p-3">'), be = /* @__PURE__ */ u("<div>");
12
- const we = {
1
+ import { createComponent as r, use as E, setAttribute as f, style as Y, Portal as X, spread as k, mergeProps as P, memo as S, insert as a, effect as N, template as u } from "solid-js/web";
2
+ import { createUniqueId as J, createSignal as I, createMemo as H, createEffect as Q, onCleanup as ee, Show as b, untrack as te } from "solid-js";
3
+ import { cn as A } from "../../utils/cn.js";
4
+ import { Button as B } from "./Button.js";
5
+ import { X as ne } from "../icons/index.js";
6
+ import { useResolvedFloeConfig as re } from "../../context/FloeConfigContext.js";
7
+ import { useOverlayMask as oe } from "../../hooks/useOverlayMask.js";
8
+ import { resolveSurfacePortalHost as ie, DIALOG_SURFACE_BOUNDARY_ATTR as O, isSurfacePortalMode as j, projectSurfacePortalRect as le, resolveSurfacePortalBoundaryRect as ae, resolveSurfacePortalMount as de } from "./dialogSurfaceScope.js";
9
+ import { LOCAL_INTERACTION_SURFACE_ATTR as ce } from "./localInteractionSurface.js";
10
+ import { createFloatingPresence as ue } from "./floatingPresence.js";
11
+ import { useDialogPlacement as se } from "./DialogPlacementContext.js";
12
+ var fe = /* @__PURE__ */ u("<span aria-hidden=true>"), ge = /* @__PURE__ */ u('<h2 class="text-sm font-semibold">'), me = /* @__PURE__ */ u('<p class="mt-0.5 text-xs text-muted-foreground">'), he = /* @__PURE__ */ u('<div class="flex items-start justify-between p-3 border-b border-border"><div>'), be = /* @__PURE__ */ u('<div class="flex items-center justify-end gap-2 p-3 border-t border-border">'), ve = /* @__PURE__ */ u('<div><div></div><div class="pointer-events-none relative z-[1] flex h-full w-full items-center justify-center"><div><div class="flex-1 overflow-auto overscroll-contain p-3">'), we = /* @__PURE__ */ u("<div>");
13
+ const ye = {
13
14
  display: "none"
14
15
  };
15
- function ve(e) {
16
+ function xe(e) {
16
17
  if (typeof queueMicrotask == "function") {
17
18
  queueMicrotask(e);
18
19
  return;
19
20
  }
20
21
  Promise.resolve().then(e);
21
22
  }
22
- function j(e) {
23
+ function q(e) {
23
24
  return `${e.left}|${e.top}|${e.right}|${e.bottom}|${e.width}|${e.height}`;
24
25
  }
25
- function ye(e) {
26
+ function pe(e) {
26
27
  return typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(e) : window.setTimeout(() => e(Date.now()), 16);
27
28
  }
28
- function xe(e) {
29
+ function $e(e) {
29
30
  if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
30
31
  window.cancelAnimationFrame(e);
31
32
  return;
32
33
  }
33
34
  window.clearTimeout(e);
34
35
  }
35
- function $e(e) {
36
- const o = X(), B = () => `dialog-${o}-title`, T = () => `dialog-${o}-description`;
37
- let C;
38
- const [b, q] = S(null), [D, G] = S(0), [z, L] = S(0), M = () => e.open && !!b() && D() > 0, s = ce({
39
- open: M,
36
+ function _e(e) {
37
+ const g = se(), d = J(), F = () => `dialog-${d}-title`, D = () => `dialog-${d}-description`;
38
+ let v;
39
+ const [w, G] = I(null), [M, z] = I(0), [L, Z] = I(0), s = ue({
40
+ open: () => e.open && !!w() && M() > 0,
40
41
  exitDurationMs: 120
41
- }), A = () => s.mounted() && !!b() && D() > 0, U = (t) => {
42
- q(t), ve(() => {
43
- ee(b) === t && G((l) => l + 1);
42
+ }), y = () => s.mounted() && !!w() && M() > 0, U = (t) => {
43
+ G(t), xe(() => {
44
+ te(w) === t && z((i) => i + 1);
44
45
  });
45
- }, w = N(() => A() ? oe({
46
- owner: b()
46
+ }, x = H(() => y() ? ie({
47
+ owner: w()
47
48
  }) : {
48
49
  host: null,
49
50
  boundaryHost: null,
50
51
  mountHost: null,
51
52
  mode: "global"
52
- }), v = () => `dialog-boundary-${o}`, n = () => F(w()), V = () => ae(w()), O = (t) => ie(le(t), t), Z = () => O(w()), y = N(() => (z(), Z())), K = (t) => typeof Element < "u" && t instanceof Element ? !!t.closest(`[${_}="${v()}"]`) : typeof Node < "u" && t instanceof Node ? !!t.parentElement?.closest(`[${_}="${v()}"]`) : !1;
53
- return J(() => {
54
- const t = w();
55
- if (!A() || !F(t) || typeof window > "u")
53
+ }), p = () => `dialog-boundary-${d}`, n = () => g.mode() === "auto" && j(x()), V = () => n() ? de(x()) : void 0, T = () => e.globalZIndex ?? g.globalZIndex(), R = (t) => le(ae(t), t), K = () => R(x()), $ = H(() => (L(), K())), W = (t) => typeof Element < "u" && t instanceof Element ? !!t.closest(`[${O}="${p()}"]`) : typeof Node < "u" && t instanceof Node ? !!t.parentElement?.closest(`[${O}="${p()}"]`) : !1;
54
+ return Q(() => {
55
+ const t = x();
56
+ if (!y() || !n() || typeof window > "u")
56
57
  return;
57
- let l = !1, g = null, i = j(O(t));
58
- const x = () => {
59
- if (l || !F(t))
58
+ let i = !1, m = null, o = q(R(t));
59
+ const _ = () => {
60
+ if (i || !j(t))
60
61
  return;
61
- const a = j(O(t));
62
- a !== i && (i = a, L(($) => $ + 1));
63
- }, m = () => {
64
- l || (g = ye(() => {
65
- x(), m();
62
+ const l = q(R(t));
63
+ l !== o && (o = l, Z((C) => C + 1));
64
+ }, h = () => {
65
+ i || (m = pe(() => {
66
+ _(), h();
66
67
  }));
67
68
  };
68
- m(), Q(() => {
69
- l = !0, g !== null && xe(g);
69
+ h(), ee(() => {
70
+ i = !0, m !== null && $e(m);
70
71
  });
71
- }), re({
72
- open: M,
73
- root: () => C,
74
- containsTarget: n() ? (t) => K(t) : void 0,
72
+ }), oe({
73
+ open: y,
74
+ root: () => v,
75
+ containsTarget: (t) => n() ? W(t) : typeof Node < "u" && t instanceof Node ? !!v?.contains(t) : !1,
75
76
  onClose: () => e.onOpenChange(!1),
76
77
  lockBodyScroll: () => !n(),
77
78
  trapFocus: !0,
@@ -82,20 +83,20 @@ function $e(e) {
82
83
  blockTouchMove: () => n() ? "none" : "outside",
83
84
  restoreFocus: !0
84
85
  }), [(() => {
85
- var t = ue();
86
- return E(U, t), f(t, "data-floe-dialog-owner-anchor", o), W(t, we), t;
87
- })(), r(h, {
86
+ var t = fe();
87
+ return E(U, t), f(t, "data-floe-dialog-owner-anchor", d), Y(t, ye), t;
88
+ })(), r(b, {
88
89
  get when() {
89
- return A();
90
+ return y();
90
91
  },
91
92
  get children() {
92
- return r(Y, {
93
+ return r(X, {
93
94
  get mount() {
94
95
  return V();
95
96
  },
96
97
  get children() {
97
- var t = he(), l = t.firstChild, g = l.nextSibling, i = g.firstChild, x = i.firstChild;
98
- f(t, "data-floe-dialog-overlay-root", o), R(t, k({
98
+ var t = ve(), i = t.firstChild, m = i.nextSibling, o = m.firstChild, _ = o.firstChild;
99
+ f(t, "data-floe-dialog-overlay-root", d), k(t, P({
99
100
  get "data-floe-dialog-mode"() {
100
101
  return n() ? "surface" : "global";
101
102
  },
@@ -106,38 +107,38 @@ function $e(e) {
106
107
  return s.exiting() ? "true" : void 0;
107
108
  }
108
109
  }, () => ({
109
- [de]: n() ? "true" : void 0
110
+ [ce]: n() ? "true" : void 0
110
111
  }), {
111
112
  get class() {
112
- return p(n() ? "absolute z-20 box-border p-3" : p("fixed inset-0 box-border p-4", e.globalZIndex === void 0 && "z-50"), s.exiting() && "pointer-events-none");
113
+ return A(n() ? "absolute z-20 box-border p-3" : A("fixed inset-0 box-border p-4", T() === void 0 && "z-50"), s.exiting() && "pointer-events-none");
113
114
  },
114
115
  get style() {
115
- return P(() => !!n())() ? {
116
- left: `${y().left}px`,
117
- top: `${y().top}px`,
118
- width: `${y().width}px`,
119
- height: `${y().height}px`
116
+ return S(() => !!n())() ? {
117
+ left: `${$().left}px`,
118
+ top: `${$().top}px`,
119
+ width: `${$().width}px`,
120
+ height: `${$().height}px`
120
121
  } : {
121
- "z-index": e.globalZIndex
122
+ "z-index": T()
122
123
  };
123
124
  }
124
- }), !1, !0), f(l, "data-floe-dialog-backdrop", o), R(l, k(() => ({
125
- [_]: v()
125
+ }), !1, !0), f(i, "data-floe-dialog-backdrop", d), k(i, P(() => ({
126
+ [O]: p()
126
127
  }), {
127
128
  get "data-floating-presence"() {
128
129
  return s.state();
129
130
  },
130
131
  get class() {
131
- return p("absolute inset-0 cursor-pointer floe-floating-presence floe-floating-backdrop", n() ? "bg-background/72 backdrop-blur-[2px]" : "bg-background/80 backdrop-blur-sm");
132
+ return A("absolute inset-0 cursor-pointer floe-floating-presence floe-floating-backdrop", n() ? "bg-background/72 backdrop-blur-[2px]" : "bg-background/80 backdrop-blur-sm");
132
133
  },
133
134
  onClick: () => e.onOpenChange(!1)
134
135
  }), !1, !1);
135
- var m = C;
136
- return typeof m == "function" ? E(m, i) : C = i, f(i, "data-floe-dialog-panel", o), R(i, k(() => ({
137
- [_]: v()
136
+ var h = v;
137
+ return typeof h == "function" ? E(h, o) : v = o, f(o, "data-floe-dialog-panel", d), k(o, P(() => ({
138
+ [O]: p()
138
139
  }), {
139
140
  get class() {
140
- return p(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 max-h-[85vh]", "bg-card text-card-foreground rounded-md shadow-lg", "border border-border", "floe-floating-presence floe-floating-dialog-panel", "flex flex-col", e.class);
141
+ return A(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 max-h-[85vh]", "bg-card text-card-foreground rounded-md shadow-lg", "border border-border", "floe-floating-presence floe-floating-dialog-panel", "pointer-events-auto flex flex-col", e.class);
141
142
  },
142
143
  get "data-floating-presence"() {
143
144
  return s.state();
@@ -147,54 +148,54 @@ function $e(e) {
147
148
  return n() ? void 0 : "true";
148
149
  },
149
150
  get "aria-labelledby"() {
150
- return P(() => !!e.title)() ? B() : void 0;
151
+ return S(() => !!e.title)() ? F() : void 0;
151
152
  },
152
153
  get "aria-describedby"() {
153
- return P(() => !!e.description)() ? T() : void 0;
154
+ return S(() => !!e.description)() ? D() : void 0;
154
155
  },
155
156
  tabIndex: -1
156
- }), !1, !0), d(i, r(h, {
157
+ }), !1, !0), a(o, r(b, {
157
158
  get when() {
158
159
  return e.title || e.description;
159
160
  },
160
161
  get children() {
161
- var a = ge(), $ = a.firstChild;
162
- return d($, r(h, {
162
+ var l = he(), C = l.firstChild;
163
+ return a(C, r(b, {
163
164
  get when() {
164
165
  return e.title;
165
166
  },
166
167
  get children() {
167
- var c = se();
168
- return d(c, () => e.title), H(() => f(c, "id", B())), c;
168
+ var c = ge();
169
+ return a(c, () => e.title), N(() => f(c, "id", F())), c;
169
170
  }
170
- }), null), d($, r(h, {
171
+ }), null), a(C, r(b, {
171
172
  get when() {
172
173
  return e.description;
173
174
  },
174
175
  get children() {
175
- var c = fe();
176
- return d(c, () => e.description), H(() => f(c, "id", T())), c;
176
+ var c = me();
177
+ return a(c, () => e.description), N(() => f(c, "id", D())), c;
177
178
  }
178
- }), null), d(a, r(I, {
179
+ }), null), a(l, r(B, {
179
180
  variant: "ghost-destructive",
180
181
  size: "icon",
181
182
  class: "-my-2 -mr-2 h-[46px] w-[46px] shrink-0 sm:my-0 sm:-mr-1 sm:h-6 sm:w-6",
182
183
  onClick: () => e.onOpenChange(!1),
183
184
  "aria-label": "Close",
184
185
  get children() {
185
- return r(te, {
186
+ return r(ne, {
186
187
  class: "w-3.5 h-3.5"
187
188
  });
188
189
  }
189
- }), null), a;
190
+ }), null), l;
190
191
  }
191
- }), x), d(x, () => e.children), d(i, r(h, {
192
+ }), _), a(_, () => e.children), a(o, r(b, {
192
193
  get when() {
193
194
  return e.footer;
194
195
  },
195
196
  get children() {
196
- var a = me();
197
- return d(a, () => e.footer), a;
197
+ var l = be();
198
+ return a(l, () => e.footer), l;
198
199
  }
199
200
  }), null), t;
200
201
  }
@@ -202,9 +203,9 @@ function $e(e) {
202
203
  }
203
204
  })];
204
205
  }
205
- function Ie(e) {
206
- const o = ne();
207
- return r($e, {
206
+ function Te(e) {
207
+ const g = re();
208
+ return r(_e, {
208
209
  get open() {
209
210
  return e.open;
210
211
  },
@@ -221,16 +222,16 @@ function Ie(e) {
221
222
  return e.globalZIndex;
222
223
  },
223
224
  get footer() {
224
- return [r(I, {
225
+ return [r(B, {
225
226
  variant: "ghost",
226
227
  onClick: () => e.onOpenChange(!1),
227
228
  get disabled() {
228
229
  return e.loading;
229
230
  },
230
231
  get children() {
231
- return e.cancelText ?? o.config.strings.confirmDialog.cancel;
232
+ return e.cancelText ?? g.config.strings.confirmDialog.cancel;
232
233
  }
233
- }), r(I, {
234
+ }), r(B, {
234
235
  get variant() {
235
236
  return e.variant === "destructive" ? "destructive" : "primary";
236
237
  },
@@ -241,16 +242,16 @@ function Ie(e) {
241
242
  return e.loading;
242
243
  },
243
244
  get children() {
244
- return e.confirmText ?? o.config.strings.confirmDialog.confirm;
245
+ return e.confirmText ?? g.config.strings.confirmDialog.confirm;
245
246
  }
246
247
  })];
247
248
  },
248
249
  get children() {
249
- return e.children ?? be();
250
+ return e.children ?? we();
250
251
  }
251
252
  });
252
253
  }
253
254
  export {
254
- Ie as ConfirmDialog,
255
- $e as Dialog
255
+ Te as ConfirmDialog,
256
+ _e as Dialog
256
257
  };
@@ -0,0 +1,16 @@
1
+ import { type Accessor, type JSX } from 'solid-js';
2
+ export type DialogPlacementMode = 'auto' | 'global';
3
+ export interface DialogPlacementProviderProps {
4
+ /** Resolve dialogs from their nearest surface host, or force document-level modal placement. */
5
+ mode: DialogPlacementMode;
6
+ /** Default stacking layer for global dialogs in this placement scope. */
7
+ globalZIndex?: number;
8
+ children: JSX.Element;
9
+ }
10
+ interface DialogPlacementContextValue {
11
+ mode: Accessor<DialogPlacementMode>;
12
+ globalZIndex: Accessor<number | undefined>;
13
+ }
14
+ export declare function DialogPlacementProvider(props: DialogPlacementProviderProps): JSX.Element;
15
+ export declare function useDialogPlacement(): DialogPlacementContextValue;
16
+ export {};
@@ -0,0 +1,26 @@
1
+ import { createComponent as n } from "solid-js/web";
2
+ import { useContext as r, createContext as l } from "solid-js";
3
+ const a = {
4
+ mode: () => "auto",
5
+ globalZIndex: () => {
6
+ }
7
+ }, o = l(a);
8
+ function d(e) {
9
+ const t = {
10
+ mode: () => e.mode,
11
+ globalZIndex: () => e.globalZIndex
12
+ };
13
+ return n(o.Provider, {
14
+ value: t,
15
+ get children() {
16
+ return e.children;
17
+ }
18
+ });
19
+ }
20
+ function m() {
21
+ return r(o);
22
+ }
23
+ export {
24
+ d as DialogPlacementProvider,
25
+ m as useDialogPlacement
26
+ };
@@ -2,6 +2,7 @@ export { Button, type ButtonProps, type ButtonVariant, type ButtonSize } from '.
2
2
  export { Tag, type TagProps, type TagVariant, type TagSize } from './Tag';
3
3
  export { Input, Textarea, NumberInput, AffixInput, type InputProps, type InputSize, type TextareaProps, type NumberInputProps, type AffixInputProps, type AffixOption, } from './Input';
4
4
  export { Dialog, ConfirmDialog, type DialogProps, type ConfirmDialogProps } from './Dialog';
5
+ export { DialogPlacementProvider, type DialogPlacementMode, type DialogPlacementProviderProps, } from './DialogPlacementContext';
5
6
  export { FloatingWindow, type FloatingWindowProps } from './FloatingWindow';
6
7
  export { createFloatingPresence, type FloatingPresence, type FloatingPresenceOptions, type FloatingPresenceState, } from './floatingPresence';
7
8
  export { MENU_ITEM_SELECTOR, focusMenuItem, getMenuItems, handleMenuKeyboardNavigation, moveMenuFocus, type MenuDismissReason, type MenuFocusMode, type MenuItemNavigationOptions, type MenuKeyboardNavigationOptions, } from './menuUtils';