@floegence/floe-webapp-core 0.62.0 → 0.64.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.
- package/dist/components/ui/Dialog.d.ts +6 -5
- package/dist/components/ui/Dialog.js +95 -103
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,8 @@ export interface DialogProps {
|
|
|
4
4
|
onOpenChange: (open: boolean) => void;
|
|
5
5
|
/** Dialog title - can be a string or JSX element for custom headers */
|
|
6
6
|
title?: string | JSX.Element;
|
|
7
|
-
|
|
7
|
+
/** Plain-text guidance rendered at the start of the body, never in the header. */
|
|
8
|
+
bodyDescription?: string;
|
|
8
9
|
/** Localized accessible name for the close button. */
|
|
9
10
|
closeLabel?: string;
|
|
10
11
|
/** Whether clicking the backdrop requests dismissal. Defaults to true. */
|
|
@@ -17,7 +18,7 @@ export interface DialogProps {
|
|
|
17
18
|
class?: string;
|
|
18
19
|
/** Bottom drawers retain the same modal and surface-placement contract. */
|
|
19
20
|
presentation?: 'dialog' | 'bottom-drawer';
|
|
20
|
-
/** Undefined uses the default header; null leaves only accessible title
|
|
21
|
+
/** Undefined uses the default header; null leaves only the accessible title. */
|
|
21
22
|
header?: JSX.Element;
|
|
22
23
|
contentClass?: string;
|
|
23
24
|
/** Includes the exit animation, so hosts can retain background input isolation. */
|
|
@@ -36,9 +37,9 @@ export interface ConfirmDialogProps {
|
|
|
36
37
|
open: boolean;
|
|
37
38
|
onOpenChange: (open: boolean) => void;
|
|
38
39
|
title: string;
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
/**
|
|
40
|
+
/** Plain-text guidance rendered in the body; use children for rich content. */
|
|
41
|
+
bodyDescription?: string;
|
|
42
|
+
/** Optional custom content after the body description. */
|
|
42
43
|
children?: JSX.Element;
|
|
43
44
|
confirmText?: string;
|
|
44
45
|
cancelText?: string;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { createComponent as r, use as L, setAttribute as s, style as ee, Portal as te, spread as
|
|
2
|
-
import { createUniqueId as ne, createSignal as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { Button as
|
|
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";
|
|
3
|
+
import { cn as y } from "../../utils/cn.js";
|
|
4
|
+
import { Button as I } from "./Button.js";
|
|
5
5
|
import { X as oe } from "../icons/index.js";
|
|
6
|
-
import { useResolvedFloeConfig as
|
|
6
|
+
import { useResolvedFloeConfig as ae } from "../../context/FloeConfigContext.js";
|
|
7
7
|
import { useOverlayMask as le } from "../../hooks/useOverlayMask.js";
|
|
8
|
-
import { resolveSurfacePortalHost as
|
|
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
9
|
import { LOCAL_INTERACTION_SURFACE_ATTR as ge } from "./localInteractionSurface.js";
|
|
10
10
|
import { createFloatingPresence as me } from "./floatingPresence.js";
|
|
11
11
|
import { useDialogPlacement as he } from "./DialogPlacementContext.js";
|
|
12
|
-
var be = /* @__PURE__ */
|
|
13
|
-
const
|
|
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 = {
|
|
14
14
|
display: "none"
|
|
15
15
|
};
|
|
16
|
-
function
|
|
16
|
+
function Ae(e) {
|
|
17
17
|
if (typeof queueMicrotask == "function") {
|
|
18
18
|
queueMicrotask(e);
|
|
19
19
|
return;
|
|
@@ -23,59 +23,59 @@ function Re(e) {
|
|
|
23
23
|
function U(e) {
|
|
24
24
|
return `${e.left}|${e.top}|${e.right}|${e.bottom}|${e.width}|${e.height}`;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Oe(e) {
|
|
27
27
|
return typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(e) : window.setTimeout(() => e(Date.now()), 16);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function ke(e) {
|
|
30
30
|
if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
|
|
31
31
|
window.cancelAnimationFrame(e);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
window.clearTimeout(e);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const v = he(),
|
|
38
|
-
let
|
|
39
|
-
const [
|
|
40
|
-
open: () => e.open && !!
|
|
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,
|
|
41
41
|
get exitDurationMs() {
|
|
42
|
-
return
|
|
42
|
+
return u() ? 180 : 160;
|
|
43
43
|
}
|
|
44
|
-
}),
|
|
45
|
-
G(() => e.onPresenceChange?.(
|
|
44
|
+
}), x = () => d.mounted() && !!O() && M() > 0;
|
|
45
|
+
G(() => e.onPresenceChange?.(x())), j(() => e.onPresenceChange?.(!1));
|
|
46
46
|
const Y = (n) => {
|
|
47
|
-
z(n),
|
|
48
|
-
re(
|
|
47
|
+
z(n), Ae(() => {
|
|
48
|
+
re(O) === n && Z((i) => i + 1);
|
|
49
49
|
});
|
|
50
|
-
}, k = q(() =>
|
|
51
|
-
owner:
|
|
50
|
+
}, k = q(() => x() ? ie({
|
|
51
|
+
owner: O()
|
|
52
52
|
}) : {
|
|
53
53
|
host: null,
|
|
54
54
|
boundaryHost: null,
|
|
55
55
|
mountHost: null,
|
|
56
56
|
mode: "global"
|
|
57
|
-
}),
|
|
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
58
|
return G(() => {
|
|
59
59
|
const n = k();
|
|
60
|
-
if (!
|
|
60
|
+
if (!x() || !o() || typeof window > "u")
|
|
61
61
|
return;
|
|
62
|
-
let
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
62
|
+
let i = !1, m = null, a = U(S(n));
|
|
63
|
+
const h = () => {
|
|
64
|
+
if (i || !K(n))
|
|
65
65
|
return;
|
|
66
|
-
const t = U(
|
|
67
|
-
t !==
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
const t = U(S(n));
|
|
67
|
+
t !== a && (a = t, W((b) => b + 1));
|
|
68
|
+
}, C = () => {
|
|
69
|
+
i || (m = Oe(() => {
|
|
70
|
+
h(), C();
|
|
71
71
|
}));
|
|
72
72
|
};
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
C(), j(() => {
|
|
74
|
+
i = !0, m !== null && ke(m);
|
|
75
75
|
});
|
|
76
76
|
}), le({
|
|
77
|
-
open:
|
|
78
|
-
root: () =>
|
|
77
|
+
open: x,
|
|
78
|
+
root: () => p,
|
|
79
79
|
containsTarget: Q,
|
|
80
80
|
onClose: () => e.onOpenChange(!1),
|
|
81
81
|
lockBodyScroll: () => !o(),
|
|
@@ -89,10 +89,10 @@ function pe(e) {
|
|
|
89
89
|
restoreFocus: !0
|
|
90
90
|
}), [(() => {
|
|
91
91
|
var n = be();
|
|
92
|
-
return L(Y, n), s(n, "data-floe-dialog-owner-anchor",
|
|
92
|
+
return L(Y, n), s(n, "data-floe-dialog-owner-anchor", c), ee(n, _e), n;
|
|
93
93
|
})(), r(f, {
|
|
94
94
|
get when() {
|
|
95
|
-
return
|
|
95
|
+
return x();
|
|
96
96
|
},
|
|
97
97
|
get children() {
|
|
98
98
|
return r(te, {
|
|
@@ -100,8 +100,8 @@ function pe(e) {
|
|
|
100
100
|
return X();
|
|
101
101
|
},
|
|
102
102
|
get children() {
|
|
103
|
-
var n = $e(),
|
|
104
|
-
s(n, "data-floe-dialog-overlay-root",
|
|
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({
|
|
105
105
|
get "data-floe-dialog-mode"() {
|
|
106
106
|
return o() ? "surface" : "global";
|
|
107
107
|
},
|
|
@@ -109,70 +109,70 @@ function pe(e) {
|
|
|
109
109
|
return e.presentation ?? "dialog";
|
|
110
110
|
},
|
|
111
111
|
get "data-floating-presence"() {
|
|
112
|
-
return
|
|
112
|
+
return d.state();
|
|
113
113
|
},
|
|
114
114
|
get "aria-hidden"() {
|
|
115
|
-
return
|
|
115
|
+
return d.exiting() ? "true" : void 0;
|
|
116
116
|
}
|
|
117
117
|
}, {
|
|
118
118
|
[ge]: "true"
|
|
119
119
|
}, () => ({
|
|
120
120
|
[de]: "true",
|
|
121
|
-
[
|
|
121
|
+
[A]: $()
|
|
122
122
|
}), {
|
|
123
123
|
get class() {
|
|
124
|
-
return
|
|
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");
|
|
125
125
|
},
|
|
126
126
|
get style() {
|
|
127
|
-
return
|
|
128
|
-
left: `${
|
|
129
|
-
top: `${
|
|
130
|
-
width: `${
|
|
131
|
-
height: `${
|
|
127
|
+
return _(() => !!o())() ? {
|
|
128
|
+
left: `${R().left}px`,
|
|
129
|
+
top: `${R().top}px`,
|
|
130
|
+
width: `${R().width}px`,
|
|
131
|
+
height: `${R().height}px`
|
|
132
132
|
} : {
|
|
133
133
|
"z-index": H()
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
}), !1, !0), s(
|
|
137
|
-
[
|
|
136
|
+
}), !1, !0), s(i, "data-floe-dialog-backdrop", c), T(i, B(() => ({
|
|
137
|
+
[A]: $()
|
|
138
138
|
}), {
|
|
139
139
|
get "data-floating-presence"() {
|
|
140
|
-
return
|
|
140
|
+
return d.state();
|
|
141
141
|
},
|
|
142
142
|
get class() {
|
|
143
|
-
return
|
|
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");
|
|
144
144
|
},
|
|
145
145
|
onClick: () => {
|
|
146
|
-
!
|
|
146
|
+
!d.exiting() && e.closeOnBackdropClick !== !1 && e.onOpenChange(!1);
|
|
147
147
|
}
|
|
148
148
|
}), !1, !1);
|
|
149
|
-
var
|
|
150
|
-
return typeof
|
|
151
|
-
[
|
|
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
152
|
[ce]: "true"
|
|
153
153
|
}), {
|
|
154
154
|
get class() {
|
|
155
|
-
return
|
|
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);
|
|
156
156
|
},
|
|
157
157
|
get "data-floating-presence"() {
|
|
158
|
-
return
|
|
158
|
+
return d.state();
|
|
159
159
|
},
|
|
160
160
|
get inert() {
|
|
161
|
-
return
|
|
161
|
+
return _(() => !!u())() && d.exiting();
|
|
162
162
|
},
|
|
163
163
|
role: "dialog",
|
|
164
164
|
get "aria-modal"() {
|
|
165
165
|
return o() ? void 0 : "true";
|
|
166
166
|
},
|
|
167
167
|
get "aria-labelledby"() {
|
|
168
|
-
return
|
|
168
|
+
return _(() => !!e.title)() ? P() : void 0;
|
|
169
169
|
},
|
|
170
170
|
get "aria-describedby"() {
|
|
171
|
-
return
|
|
171
|
+
return _(() => !!e.bodyDescription)() ? E() : void 0;
|
|
172
172
|
},
|
|
173
173
|
onKeyDown: (t) => e.onKeyDown?.(t),
|
|
174
174
|
tabIndex: -1
|
|
175
|
-
}), !1, !0),
|
|
175
|
+
}), !1, !0), l(a, r(f, {
|
|
176
176
|
get when() {
|
|
177
177
|
return e.header === void 0;
|
|
178
178
|
},
|
|
@@ -181,44 +181,28 @@ function pe(e) {
|
|
|
181
181
|
get when() {
|
|
182
182
|
return e.title;
|
|
183
183
|
},
|
|
184
|
-
get children() {
|
|
185
|
-
var t = _e();
|
|
186
|
-
return i(t, () => e.title), A(() => s(t, "id", p())), t;
|
|
187
|
-
}
|
|
188
|
-
}), r(f, {
|
|
189
|
-
get when() {
|
|
190
|
-
return e.description;
|
|
191
|
-
},
|
|
192
184
|
get children() {
|
|
193
185
|
var t = Ce();
|
|
194
|
-
return
|
|
186
|
+
return l(t, () => e.title), D(() => s(t, "id", P())), t;
|
|
195
187
|
}
|
|
196
|
-
}),
|
|
188
|
+
}), _(() => e.header)];
|
|
197
189
|
},
|
|
198
190
|
get children() {
|
|
199
191
|
return r(f, {
|
|
200
192
|
get when() {
|
|
201
|
-
return e.title
|
|
193
|
+
return e.title;
|
|
202
194
|
},
|
|
203
195
|
get children() {
|
|
204
|
-
var t = ye(),
|
|
205
|
-
return
|
|
196
|
+
var t = ye(), b = t.firstChild;
|
|
197
|
+
return l(b, r(f, {
|
|
206
198
|
get when() {
|
|
207
199
|
return e.title;
|
|
208
200
|
},
|
|
209
201
|
get children() {
|
|
210
|
-
var
|
|
211
|
-
return
|
|
202
|
+
var w = we();
|
|
203
|
+
return l(w, () => e.title), D(() => s(w, "id", P())), w;
|
|
212
204
|
}
|
|
213
|
-
})
|
|
214
|
-
get when() {
|
|
215
|
-
return e.description;
|
|
216
|
-
},
|
|
217
|
-
get children() {
|
|
218
|
-
var a = ve();
|
|
219
|
-
return i(a, () => e.description), A(() => s(a, "id", S())), a;
|
|
220
|
-
}
|
|
221
|
-
}), null), i(t, r(E, {
|
|
205
|
+
})), l(t, r(I, {
|
|
222
206
|
variant: "ghost-destructive",
|
|
223
207
|
size: "icon",
|
|
224
208
|
class: "-my-2 -mr-2 h-[46px] w-[46px] shrink-0 sm:my-0 sm:-mr-1 sm:h-6 sm:w-6",
|
|
@@ -235,17 +219,25 @@ function pe(e) {
|
|
|
235
219
|
}
|
|
236
220
|
});
|
|
237
221
|
}
|
|
238
|
-
}),
|
|
222
|
+
}), h), l(h, r(f, {
|
|
223
|
+
get when() {
|
|
224
|
+
return e.bodyDescription;
|
|
225
|
+
},
|
|
226
|
+
get children() {
|
|
227
|
+
var t = ve();
|
|
228
|
+
return l(t, () => e.bodyDescription), D(() => s(t, "id", E())), t;
|
|
229
|
+
}
|
|
230
|
+
}), null), l(h, () => e.children, null), l(a, r(f, {
|
|
239
231
|
get when() {
|
|
240
232
|
return e.footer;
|
|
241
233
|
},
|
|
242
234
|
get children() {
|
|
243
235
|
var t = xe();
|
|
244
|
-
return
|
|
236
|
+
return l(t, () => e.footer), t;
|
|
245
237
|
}
|
|
246
|
-
}), null),
|
|
247
|
-
var
|
|
248
|
-
return
|
|
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;
|
|
249
241
|
}, {
|
|
250
242
|
e: void 0,
|
|
251
243
|
t: void 0
|
|
@@ -255,9 +247,9 @@ function pe(e) {
|
|
|
255
247
|
}
|
|
256
248
|
})];
|
|
257
249
|
}
|
|
258
|
-
function
|
|
259
|
-
const v =
|
|
260
|
-
return r(
|
|
250
|
+
function Ne(e) {
|
|
251
|
+
const v = ae();
|
|
252
|
+
return r(Re, {
|
|
261
253
|
get open() {
|
|
262
254
|
return e.open;
|
|
263
255
|
},
|
|
@@ -267,14 +259,14 @@ function je(e) {
|
|
|
267
259
|
get title() {
|
|
268
260
|
return e.title;
|
|
269
261
|
},
|
|
270
|
-
get
|
|
271
|
-
return e.
|
|
262
|
+
get bodyDescription() {
|
|
263
|
+
return e.bodyDescription;
|
|
272
264
|
},
|
|
273
265
|
get globalZIndex() {
|
|
274
266
|
return e.globalZIndex;
|
|
275
267
|
},
|
|
276
268
|
get footer() {
|
|
277
|
-
return [r(
|
|
269
|
+
return [r(I, {
|
|
278
270
|
variant: "ghost",
|
|
279
271
|
onClick: () => e.onOpenChange(!1),
|
|
280
272
|
get disabled() {
|
|
@@ -283,7 +275,7 @@ function je(e) {
|
|
|
283
275
|
get children() {
|
|
284
276
|
return e.cancelText ?? v.config.strings.confirmDialog.cancel;
|
|
285
277
|
}
|
|
286
|
-
}), r(
|
|
278
|
+
}), r(I, {
|
|
287
279
|
get variant() {
|
|
288
280
|
return e.variant === "destructive" ? "destructive" : "primary";
|
|
289
281
|
},
|
|
@@ -299,11 +291,11 @@ function je(e) {
|
|
|
299
291
|
})];
|
|
300
292
|
},
|
|
301
293
|
get children() {
|
|
302
|
-
return e.children
|
|
294
|
+
return e.children;
|
|
303
295
|
}
|
|
304
296
|
});
|
|
305
297
|
}
|
|
306
298
|
export {
|
|
307
|
-
|
|
308
|
-
|
|
299
|
+
Ne as ConfirmDialog,
|
|
300
|
+
Re as Dialog
|
|
309
301
|
};
|