@floegence/floe-webapp-core 0.36.34 → 0.36.35

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,142 +1,192 @@
1
- import { createComponent as n, Portal as D, setAttribute as u, spread as x, mergeProps as $, memo as C, insert as l, effect as S, template as c, use as E } from "solid-js/web";
2
- import { createUniqueId as M, createMemo as T, Show as s } from "solid-js";
3
- import { cn as _ } from "../../utils/cn.js";
4
- import { Button as y } from "./Button.js";
5
- import { X as P } from "../icons/index.js";
6
- import { useResolvedFloeConfig as j } from "../../context/FloeConfigContext.js";
7
- import { useOverlayMask as z } from "../../hooks/useOverlayMask.js";
8
- import { resolveSurfacePortalHost as F, projectSurfacePortalRect as H, resolveSurfacePortalBoundaryRect as N, DIALOG_SURFACE_BOUNDARY_ATTR as h, isSurfacePortalMode as U, resolveSurfacePortalMount as L } from "./dialogSurfaceScope.js";
9
- import { LOCAL_INTERACTION_SURFACE_ATTR as W } from "./localInteractionSurface.js";
10
- var q = /* @__PURE__ */ c('<h2 class="text-sm font-semibold">'), G = /* @__PURE__ */ c('<p class="mt-0.5 text-xs text-muted-foreground">'), X = /* @__PURE__ */ c('<div class="flex items-start justify-between p-3 border-b border-border"><div>'), Y = /* @__PURE__ */ c('<div class="flex items-center justify-end gap-2 p-3 border-t border-border">'), J = /* @__PURE__ */ c('<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">'), K = /* @__PURE__ */ c("<div>");
11
- function Q(e) {
12
- const o = M(), w = () => `dialog-${o}-title`, k = () => `dialog-${o}-description`;
13
- let b;
14
- const f = T(() => e.open ? F() : {
1
+ import { createComponent as n, use as D, setAttribute as s, style as K, Portal as W, spread as A, mergeProps as O, memo as R, insert as d, effect as E, template as u } from "solid-js/web";
2
+ import { createUniqueId as Y, createSignal as k, createMemo as I, createEffect as X, onCleanup as J, Show as g, untrack as Q } from "solid-js";
3
+ import { cn as S } from "../../utils/cn.js";
4
+ import { Button as P } from "./Button.js";
5
+ import { X as Z } from "../icons/index.js";
6
+ import { useResolvedFloeConfig as ee } from "../../context/FloeConfigContext.js";
7
+ import { useOverlayMask as te } from "../../hooks/useOverlayMask.js";
8
+ import { resolveSurfacePortalHost as re, isSurfacePortalMode as F, DIALOG_SURFACE_BOUNDARY_ATTR as x, projectSurfacePortalRect as ne, resolveSurfacePortalBoundaryRect as oe, resolveSurfacePortalMount as ie } from "./dialogSurfaceScope.js";
9
+ import { LOCAL_INTERACTION_SURFACE_ATTR as le } from "./localInteractionSurface.js";
10
+ var ae = /* @__PURE__ */ u("<span aria-hidden=true>"), de = /* @__PURE__ */ u('<h2 class="text-sm font-semibold">'), ce = /* @__PURE__ */ u('<p class="mt-0.5 text-xs text-muted-foreground">'), ue = /* @__PURE__ */ u('<div class="flex items-start justify-between p-3 border-b border-border"><div>'), se = /* @__PURE__ */ u('<div class="flex items-center justify-end gap-2 p-3 border-t border-border">'), fe = /* @__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">'), me = /* @__PURE__ */ u("<div>");
11
+ const ge = {
12
+ display: "none"
13
+ };
14
+ function he(e) {
15
+ if (typeof queueMicrotask == "function") {
16
+ queueMicrotask(e);
17
+ return;
18
+ }
19
+ Promise.resolve().then(e);
20
+ }
21
+ function M(e) {
22
+ return `${e.left}|${e.top}|${e.right}|${e.bottom}|${e.width}|${e.height}`;
23
+ }
24
+ function we(e) {
25
+ return typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(e) : window.setTimeout(() => e(Date.now()), 16);
26
+ }
27
+ function be(e) {
28
+ if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
29
+ window.cancelAnimationFrame(e);
30
+ return;
31
+ }
32
+ window.clearTimeout(e);
33
+ }
34
+ function ve(e) {
35
+ const o = Y(), T = () => `dialog-${o}-title`, B = () => `dialog-${o}-description`;
36
+ let p;
37
+ const [_, H] = k(null), [N, j] = k(0), [q, G] = k(0), h = () => e.open && !!_() && N() > 0, z = (t) => {
38
+ H(t), he(() => {
39
+ Q(_) === t && j((l) => l + 1);
40
+ });
41
+ }, w = I(() => h() ? re({
42
+ owner: _()
43
+ }) : {
15
44
  host: null,
16
45
  boundaryHost: null,
17
46
  mountHost: null,
18
47
  mode: "global"
19
- }), g = () => `dialog-boundary-${o}`, t = () => U(f()), A = () => L(f()), m = T(() => H(N(f()), f())), B = (r) => typeof Element < "u" && r instanceof Element ? !!r.closest(`[${h}="${g()}"]`) : typeof Node < "u" && r instanceof Node ? !!r.parentElement?.closest(`[${h}="${g()}"]`) : !1;
20
- return z({
21
- open: () => e.open,
22
- root: () => b,
23
- containsTarget: (r) => t() && B(r),
48
+ }), b = () => `dialog-boundary-${o}`, r = () => F(w()), L = () => ie(w()), C = (t) => ne(oe(t), t), U = () => C(w()), v = I(() => (q(), U())), V = (t) => typeof Element < "u" && t instanceof Element ? !!t.closest(`[${x}="${b()}"]`) : typeof Node < "u" && t instanceof Node ? !!t.parentElement?.closest(`[${x}="${b()}"]`) : !1;
49
+ return X(() => {
50
+ const t = w();
51
+ if (!h() || !F(t) || typeof window > "u")
52
+ return;
53
+ let l = !1, f = null, i = M(C(t));
54
+ const y = () => {
55
+ if (l || !F(t))
56
+ return;
57
+ const a = M(C(t));
58
+ a !== i && (i = a, G(($) => $ + 1));
59
+ }, m = () => {
60
+ l || (f = we(() => {
61
+ y(), m();
62
+ }));
63
+ };
64
+ m(), J(() => {
65
+ l = !0, f !== null && be(f);
66
+ });
67
+ }), te({
68
+ open: h,
69
+ root: () => p,
70
+ containsTarget: (t) => r() && V(t),
24
71
  onClose: () => e.onOpenChange(!1),
25
- lockBodyScroll: () => !t(),
72
+ lockBodyScroll: () => !r(),
26
73
  trapFocus: !0,
27
- closeOnEscape: () => t() ? "inside" : !0,
74
+ closeOnEscape: () => r() ? "inside" : !0,
28
75
  blockHotkeys: !0,
29
76
  // Block scroll bleed outside the dialog while keeping the dialog content scrollable.
30
- blockWheel: () => t() ? "none" : "outside",
31
- blockTouchMove: () => t() ? "none" : "outside",
77
+ blockWheel: () => r() ? "none" : "outside",
78
+ blockTouchMove: () => r() ? "none" : "outside",
32
79
  restoreFocus: !0
33
- }), n(s, {
80
+ }), [(() => {
81
+ var t = ae();
82
+ return D(z, t), s(t, "data-floe-dialog-owner-anchor", o), K(t, ge), t;
83
+ })(), n(g, {
34
84
  get when() {
35
- return e.open;
85
+ return h();
36
86
  },
37
87
  get children() {
38
- return n(D, {
88
+ return n(W, {
39
89
  get mount() {
40
- return A();
90
+ return L();
41
91
  },
42
92
  get children() {
43
- var r = J(), v = r.firstChild, I = v.nextSibling, i = I.firstChild, p = i.firstChild;
44
- u(r, "data-floe-dialog-overlay-root", o), x(r, $({
93
+ var t = fe(), l = t.firstChild, f = l.nextSibling, i = f.firstChild, y = i.firstChild;
94
+ s(t, "data-floe-dialog-overlay-root", o), A(t, O({
45
95
  get "data-floe-dialog-mode"() {
46
- return t() ? "surface" : "global";
96
+ return r() ? "surface" : "global";
47
97
  }
48
98
  }, () => ({
49
- [W]: t() ? "true" : void 0
99
+ [le]: r() ? "true" : void 0
50
100
  }), {
51
101
  get class() {
52
- return _(t() ? "absolute z-20 box-border p-3" : "fixed inset-0 box-border z-50 p-4");
102
+ return S(r() ? "absolute z-20 box-border p-3" : "fixed inset-0 box-border z-50 p-4");
53
103
  },
54
104
  get style() {
55
- return C(() => !!t())() ? {
56
- left: `${m().left}px`,
57
- top: `${m().top}px`,
58
- width: `${m().width}px`,
59
- height: `${m().height}px`
105
+ return R(() => !!r())() ? {
106
+ left: `${v().left}px`,
107
+ top: `${v().top}px`,
108
+ width: `${v().width}px`,
109
+ height: `${v().height}px`
60
110
  } : void 0;
61
111
  }
62
- }), !1, !0), u(v, "data-floe-dialog-backdrop", o), x(v, $(() => ({
63
- [h]: g()
112
+ }), !1, !0), s(l, "data-floe-dialog-backdrop", o), A(l, O(() => ({
113
+ [x]: b()
64
114
  }), {
65
115
  get class() {
66
- return _("absolute inset-0 cursor-pointer animate-in fade-in", t() ? "bg-background/72 backdrop-blur-[2px]" : "bg-background/80 backdrop-blur-sm");
116
+ return S("absolute inset-0 cursor-pointer animate-in fade-in", r() ? "bg-background/72 backdrop-blur-[2px]" : "bg-background/80 backdrop-blur-sm");
67
117
  },
68
118
  onClick: () => e.onOpenChange(!1)
69
119
  }), !1, !1);
70
- var O = b;
71
- return typeof O == "function" ? E(O, i) : b = i, u(i, "data-floe-dialog-panel", o), x(i, $(() => ({
72
- [h]: g()
120
+ var m = p;
121
+ return typeof m == "function" ? D(m, i) : p = i, s(i, "data-floe-dialog-panel", o), A(i, O(() => ({
122
+ [x]: b()
73
123
  }), {
74
124
  get class() {
75
- return _(t() ? "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", "animate-in fade-in zoom-in-95", "flex flex-col", e.class);
125
+ return S(r() ? "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", "animate-in fade-in zoom-in-95", "flex flex-col", e.class);
76
126
  },
77
127
  role: "dialog",
78
128
  get "aria-modal"() {
79
- return t() ? void 0 : "true";
129
+ return r() ? void 0 : "true";
80
130
  },
81
131
  get "aria-labelledby"() {
82
- return C(() => !!e.title)() ? w() : void 0;
132
+ return R(() => !!e.title)() ? T() : void 0;
83
133
  },
84
134
  get "aria-describedby"() {
85
- return C(() => !!e.description)() ? k() : void 0;
135
+ return R(() => !!e.description)() ? B() : void 0;
86
136
  },
87
137
  tabIndex: -1
88
- }), !1, !0), l(i, n(s, {
138
+ }), !1, !0), d(i, n(g, {
89
139
  get when() {
90
140
  return e.title || e.description;
91
141
  },
92
142
  get children() {
93
- var d = X(), R = d.firstChild;
94
- return l(R, n(s, {
143
+ var a = ue(), $ = a.firstChild;
144
+ return d($, n(g, {
95
145
  get when() {
96
146
  return e.title;
97
147
  },
98
148
  get children() {
99
- var a = q();
100
- return l(a, () => e.title), S(() => u(a, "id", w())), a;
149
+ var c = de();
150
+ return d(c, () => e.title), E(() => s(c, "id", T())), c;
101
151
  }
102
- }), null), l(R, n(s, {
152
+ }), null), d($, n(g, {
103
153
  get when() {
104
154
  return e.description;
105
155
  },
106
156
  get children() {
107
- var a = G();
108
- return l(a, () => e.description), S(() => u(a, "id", k())), a;
157
+ var c = ce();
158
+ return d(c, () => e.description), E(() => s(c, "id", B())), c;
109
159
  }
110
- }), null), l(d, n(y, {
160
+ }), null), d(a, n(P, {
111
161
  variant: "ghost-destructive",
112
162
  size: "icon",
113
163
  class: "h-6 w-6 -mr-1",
114
164
  onClick: () => e.onOpenChange(!1),
115
165
  "aria-label": "Close",
116
166
  get children() {
117
- return n(P, {
167
+ return n(Z, {
118
168
  class: "w-3.5 h-3.5"
119
169
  });
120
170
  }
121
- }), null), d;
171
+ }), null), a;
122
172
  }
123
- }), p), l(p, () => e.children), l(i, n(s, {
173
+ }), y), d(y, () => e.children), d(i, n(g, {
124
174
  get when() {
125
175
  return e.footer;
126
176
  },
127
177
  get children() {
128
- var d = Y();
129
- return l(d, () => e.footer), d;
178
+ var a = se();
179
+ return d(a, () => e.footer), a;
130
180
  }
131
- }), null), r;
181
+ }), null), t;
132
182
  }
133
183
  });
134
184
  }
135
- });
185
+ })];
136
186
  }
137
- function ae(e) {
138
- const o = j();
139
- return n(Q, {
187
+ function ke(e) {
188
+ const o = ee();
189
+ return n(ve, {
140
190
  get open() {
141
191
  return e.open;
142
192
  },
@@ -150,7 +200,7 @@ function ae(e) {
150
200
  return e.description;
151
201
  },
152
202
  get footer() {
153
- return [n(y, {
203
+ return [n(P, {
154
204
  variant: "ghost",
155
205
  onClick: () => e.onOpenChange(!1),
156
206
  get disabled() {
@@ -159,7 +209,7 @@ function ae(e) {
159
209
  get children() {
160
210
  return e.cancelText ?? o.config.strings.confirmDialog.cancel;
161
211
  }
162
- }), n(y, {
212
+ }), n(P, {
163
213
  get variant() {
164
214
  return e.variant === "destructive" ? "destructive" : "primary";
165
215
  },
@@ -175,11 +225,11 @@ function ae(e) {
175
225
  })];
176
226
  },
177
227
  get children() {
178
- return e.children ?? K();
228
+ return e.children ?? me();
179
229
  }
180
230
  });
181
231
  }
182
232
  export {
183
- ae as ConfirmDialog,
184
- Q as Dialog
233
+ ke as ConfirmDialog,
234
+ ve as Dialog
185
235
  };
@@ -19,10 +19,13 @@ export type ResolvedDialogSurfaceHost = Readonly<{
19
19
  export type ResolvedSurfacePortalHost = ResolvedDialogSurfaceHost;
20
20
  export type SurfacePortalBoundaryRect = SurfacePortalRect;
21
21
  export type { SurfacePortalRect };
22
+ export type SurfacePortalHostResolutionOptions = Readonly<{
23
+ owner?: Element | null;
24
+ }>;
22
25
  export declare function ensureDialogSurfaceInteractionTracking(): void;
23
26
  export declare function ensureSurfacePortalInteractionTracking(): void;
24
- export declare function resolveDialogSurfaceHost(): ResolvedDialogSurfaceHost;
25
- export declare function resolveSurfacePortalHost(): ResolvedSurfacePortalHost;
27
+ export declare function resolveDialogSurfaceHost(options?: SurfacePortalHostResolutionOptions): ResolvedDialogSurfaceHost;
28
+ export declare function resolveSurfacePortalHost(options?: SurfacePortalHostResolutionOptions): ResolvedSurfacePortalHost;
26
29
  export declare function isSurfacePortalMode(surfaceHost: ResolvedSurfacePortalHost): boolean;
27
30
  export declare function resolveSurfacePortalMount(surfaceHost: ResolvedSurfacePortalHost): HTMLElement | undefined;
28
31
  export declare function resolveSurfacePortalBoundaryRect(surfaceHost: ResolvedSurfacePortalHost): SurfacePortalBoundaryRect;
@@ -3,52 +3,52 @@ let r = null, o = null;
3
3
  function E(t) {
4
4
  return typeof Element < "u" && t instanceof Element ? t : typeof Node < "u" && t instanceof Node ? t.parentElement : null;
5
5
  }
6
- function T(t) {
6
+ function w(t) {
7
7
  const e = t?.activeElement;
8
8
  return e instanceof Element ? e : null;
9
9
  }
10
- function i(t) {
10
+ function l(t) {
11
11
  const e = typeof document < "u" ? document : null;
12
12
  r = {
13
13
  target: E(t),
14
- activeElement: T(e),
14
+ activeElement: w(e),
15
15
  recordedAt: Date.now()
16
16
  };
17
17
  }
18
- function l(t) {
19
- i(t.target);
20
- }
21
18
  function c(t) {
22
- i(t.target);
19
+ l(t.target);
20
+ }
21
+ function f(t) {
22
+ l(t.target);
23
23
  }
24
24
  function d(t) {
25
- i(t.target);
25
+ l(t.target);
26
26
  }
27
27
  function s() {
28
- w();
28
+ T();
29
29
  }
30
- function w() {
31
- typeof document > "u" || o !== document && (o && (o.removeEventListener("pointerdown", l, !0), o.removeEventListener("focusin", c, !0), o.removeEventListener("contextmenu", d, !0)), document.addEventListener("pointerdown", l, !0), document.addEventListener("focusin", c, !0), document.addEventListener("contextmenu", d, !0), o = document);
30
+ function T() {
31
+ typeof document > "u" || o !== document && (o && (o.removeEventListener("pointerdown", c, !0), o.removeEventListener("focusin", f, !0), o.removeEventListener("contextmenu", d, !0)), document.addEventListener("pointerdown", c, !0), document.addEventListener("focusin", f, !0), document.addEventListener("contextmenu", d, !0), o = document);
32
32
  }
33
33
  function R() {
34
34
  return !r || Date.now() - r.recordedAt > g ? null : r;
35
35
  }
36
- function f(t) {
36
+ function i(t) {
37
37
  const e = t?.closest(`[${a}="true"]`);
38
- return typeof HTMLElement > "u" ? null : e instanceof HTMLElement && e.isConnected ? e : null;
38
+ return typeof HTMLElement > "u" ? null : e instanceof HTMLElement ? e : null;
39
39
  }
40
40
  function S(t) {
41
41
  if (!t) return null;
42
42
  const e = t.closest(`[${p}="true"]`);
43
- return typeof HTMLElement > "u" ? null : e instanceof HTMLElement && e.isConnected ? e : null;
43
+ return typeof HTMLElement > "u" ? null : e instanceof HTMLElement ? e : null;
44
44
  }
45
- function L() {
45
+ function L(t = {}) {
46
46
  s();
47
- const t = R(), e = f(t?.target ?? null) ?? f(t?.activeElement ?? null);
48
- return e ? {
49
- host: e,
50
- boundaryHost: e,
51
- mountHost: S(e) ?? e,
47
+ const e = R(), n = i(t.owner ?? null) ?? i(e?.target ?? null) ?? i(e?.activeElement ?? null);
48
+ return n ? {
49
+ host: n,
50
+ boundaryHost: n,
51
+ mountHost: S(n) ?? n,
52
52
  mode: "surface"
53
53
  } : { host: null, boundaryHost: null, mountHost: null, mode: "global" };
54
54
  }
@@ -112,7 +112,7 @@ function b(t, e) {
112
112
  y: t.y - n.top
113
113
  };
114
114
  }
115
- function C(t, e) {
115
+ function P(t, e) {
116
116
  if (!u(e))
117
117
  return t;
118
118
  const n = h(e);
@@ -125,7 +125,7 @@ function C(t, e) {
125
125
  height: t.height
126
126
  };
127
127
  }
128
- function P() {
128
+ function C() {
129
129
  r = null;
130
130
  }
131
131
  typeof document < "u" && s();
@@ -134,12 +134,12 @@ export {
134
134
  a as DIALOG_SURFACE_HOST_ATTR,
135
135
  y as SURFACE_PORTAL_HOST_ATTR,
136
136
  p as SURFACE_PORTAL_LAYER_ATTR,
137
- P as __resetSurfacePortalScopeForTests,
137
+ C as __resetSurfacePortalScopeForTests,
138
138
  s as ensureDialogSurfaceInteractionTracking,
139
- w as ensureSurfacePortalInteractionTracking,
139
+ T as ensureSurfacePortalInteractionTracking,
140
140
  u as isSurfacePortalMode,
141
141
  b as projectSurfacePortalPosition,
142
- C as projectSurfacePortalRect,
142
+ P as projectSurfacePortalRect,
143
143
  _ as resolveSurfacePortalBoundaryRect,
144
144
  L as resolveSurfacePortalHost,
145
145
  v as resolveSurfacePortalMount,
@@ -1 +1 @@
1
- export { DIALOG_SURFACE_HOST_ATTR, SURFACE_PORTAL_HOST_ATTR, SURFACE_PORTAL_LAYER_ATTR, DIALOG_SURFACE_BOUNDARY_ATTR, ensureSurfacePortalInteractionTracking, resolveSurfacePortalHost, isSurfacePortalMode, resolveSurfacePortalMount, resolveSurfacePortalBoundaryRect, resolveSurfacePortalMountRect, projectSurfacePortalPosition, projectSurfacePortalRect, __resetSurfacePortalScopeForTests, type SurfacePortalInteractionSnapshot, type SurfacePortalMode, type ResolvedSurfacePortalHost, type SurfacePortalBoundaryRect, type SurfacePortalRect, } from './dialogSurfaceScope';
1
+ export { DIALOG_SURFACE_HOST_ATTR, SURFACE_PORTAL_HOST_ATTR, SURFACE_PORTAL_LAYER_ATTR, DIALOG_SURFACE_BOUNDARY_ATTR, ensureSurfacePortalInteractionTracking, resolveSurfacePortalHost, isSurfacePortalMode, resolveSurfacePortalMount, resolveSurfacePortalBoundaryRect, resolveSurfacePortalMountRect, projectSurfacePortalPosition, projectSurfacePortalRect, __resetSurfacePortalScopeForTests, type SurfacePortalInteractionSnapshot, type SurfacePortalHostResolutionOptions, type SurfacePortalMode, type ResolvedSurfacePortalHost, type SurfacePortalBoundaryRect, type SurfacePortalRect, } from './dialogSurfaceScope';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.34",
3
+ "version": "0.36.35",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",