@jfrader/ui 0.3.0 → 0.4.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/combobox-DiMC2g_u.js +327 -0
- package/dist/combobox.js +1 -1
- package/dist/{date-picker-ClUYBIBh.js → date-picker-C29Uo4Tx.js} +42 -42
- package/dist/date-picker.js +1 -1
- package/dist/index.js +8 -8
- package/dist/{menu-DU60SMdt.js → menu-CGPTNRnF.js} +49 -49
- package/dist/menu.js +1 -1
- package/dist/{popover-BtN_0ejj.js → popover-CdRXjQqI.js} +30 -30
- package/dist/popover.js +1 -1
- package/dist/{select-BCS0-LVW.js → select-BgG7WgSh.js} +57 -57
- package/dist/select.js +1 -1
- package/dist/theme-root-BbTBuLMQ.js +46 -0
- package/dist/theme-root.js +1 -1
- package/dist/theme-scope-t7nAKc2c.js +27 -0
- package/dist/toast-CjmELMZZ.js +283 -0
- package/dist/toast.js +1 -1
- package/dist/{tooltip-CB-HC1js.js → tooltip-CaL3rKbV.js} +35 -35
- package/dist/tooltip.js +1 -1
- package/dist/types/components/theme-root/theme-root.d.ts +9 -3
- package/dist/types/overlay/overlay-portal.d.ts +7 -0
- package/dist/types/styling/theme-scope.d.ts +19 -0
- package/dist/use-overlay-floating-Bit-f0FU.js +31 -0
- package/package.json +2 -2
- package/dist/combobox-DrmjBbo7.js +0 -327
- package/dist/theme-root-BiXXvQvr.js +0 -42
- package/dist/toast-iqelR-r0.js +0 -282
- package/dist/use-overlay-floating-efeqppiw.js +0 -19
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { r as e, t } from "./sx-Dx9JUKp5.js";
|
|
3
|
-
import { n, t as r } from "./use-controlled-state-CVXDa-qM.js";
|
|
4
|
-
import { t as i } from "./renderable-DzcIj1Lo.js";
|
|
5
|
-
import { a, c as o, d as s, f as c, l, o as u, r as d, s as f, t as p, u as m } from "./collection-registry-BTYi6zGh.js";
|
|
6
|
-
import { t as h } from "./use-overlay-floating-efeqppiw.js";
|
|
7
|
-
import { t as g } from "./text-field-D60ok14S.js";
|
|
8
|
-
import { createContext as _, useCallback as v, useContext as y, useId as b, useLayoutEffect as x, useMemo as S, useRef as C, useState as w } from "react";
|
|
9
|
-
import { vars as T } from "@jfrader/tokens/vars";
|
|
10
|
-
import { jsx as E, jsxs as ee } from "@emotion/react/jsx-runtime";
|
|
11
|
-
import { FloatingList as D, FloatingPortal as O, useDismiss as te, useInteractions as k, useListNavigation as A, useMergeRefs as j } from "@floating-ui/react";
|
|
12
|
-
//#region src/components/combobox/combobox.tsx
|
|
13
|
-
var M = "bottom-start", N = "✓", P = "No results", ne = (e, t) => e.toLocaleLowerCase().includes(t.toLocaleLowerCase()), F = _(null), I = _(!1);
|
|
14
|
-
function L(e) {
|
|
15
|
-
let t = y(F);
|
|
16
|
-
if (!t) throw Error(`Combobox.${e} must be rendered inside <Combobox>.`);
|
|
17
|
-
return t;
|
|
18
|
-
}
|
|
19
|
-
function R(e) {
|
|
20
|
-
let t = L(e);
|
|
21
|
-
if (!y(I)) throw Error(`Combobox.${e} must be rendered inside <Combobox.List>.`);
|
|
22
|
-
return t;
|
|
23
|
-
}
|
|
24
|
-
var z = e({ "&[hidden]": { display: "none" } }), B = e({
|
|
25
|
-
paddingBlock: T.space[1],
|
|
26
|
-
paddingInline: T.space[2],
|
|
27
|
-
fontSize: T.textSize.sm,
|
|
28
|
-
color: T.color.textMuted
|
|
29
|
-
});
|
|
30
|
-
function V({ value: e, defaultValue: t, onValueChange: i, open: o, defaultOpen: s = !1, onOpenChange: c, name: l, filter: u = ne, onInputChange: d, children: f }) {
|
|
31
|
-
let p = b(), [m, g] = w(`${p}-listbox`), [_, y] = w(!1), [x = null, T] = r(e, t ?? null, i), [D = !1, O] = r(o, s, c), [j, N] = w(null), [P, I] = w(""), [L, R] = a(), [z, B] = w(null), V = C([]), H = C(null), U = n(d), W = v((e, t) => t === "" || u(e, t), [u]), { valuesByIndex: G, skippedIndices: K, matchCount: re } = S(() => {
|
|
32
|
-
let e = [], t = /* @__PURE__ */ new Set(), n = 0;
|
|
33
|
-
return L.forEach((r, i) => {
|
|
34
|
-
if (r.index === -1) return;
|
|
35
|
-
e[r.index] = i;
|
|
36
|
-
let a = W(r.label, P);
|
|
37
|
-
a && (n += 1), (r.disabled || !a) && t.add(r.index);
|
|
38
|
-
}), {
|
|
39
|
-
valuesByIndex: e,
|
|
40
|
-
skippedIndices: t,
|
|
41
|
-
matchCount: n
|
|
42
|
-
};
|
|
43
|
-
}, [
|
|
44
|
-
L,
|
|
45
|
-
P,
|
|
46
|
-
W
|
|
47
|
-
]), { refs: q, floatingStyles: J, context: Y } = h({
|
|
48
|
-
open: D,
|
|
49
|
-
placement: M,
|
|
50
|
-
onOpenChange: (e) => O(e)
|
|
51
|
-
}), X = te(Y, {
|
|
52
|
-
escapeKey: !0,
|
|
53
|
-
outsidePress: !0
|
|
54
|
-
}), ie = A(Y, {
|
|
55
|
-
listRef: V,
|
|
56
|
-
activeIndex: j,
|
|
57
|
-
onNavigate: N,
|
|
58
|
-
virtual: !0,
|
|
59
|
-
loop: !0,
|
|
60
|
-
disabledIndices: (e) => K.has(e)
|
|
61
|
-
}), { getReferenceProps: Z, getFloatingProps: Q, getItemProps: $ } = k([X, ie]), ae = S(() => {
|
|
62
|
-
let e = (e) => {
|
|
63
|
-
T(e), O(!1), H.current?.commitLabel(L.get(e)?.label ?? "");
|
|
64
|
-
};
|
|
65
|
-
return {
|
|
66
|
-
baseId: p,
|
|
67
|
-
listId: m,
|
|
68
|
-
setListId: g,
|
|
69
|
-
setInputDisabled: y,
|
|
70
|
-
open: D,
|
|
71
|
-
selectedValue: x,
|
|
72
|
-
activeIndex: j,
|
|
73
|
-
options: L,
|
|
74
|
-
matchCount: re,
|
|
75
|
-
inputLabelling: z,
|
|
76
|
-
inputHandleRef: H,
|
|
77
|
-
refs: q,
|
|
78
|
-
floatingStyles: J,
|
|
79
|
-
elementsRef: V,
|
|
80
|
-
getReferenceProps: Z,
|
|
81
|
-
getFloatingProps: Q,
|
|
82
|
-
getItemProps: $,
|
|
83
|
-
onInputChange: U,
|
|
84
|
-
isVisible: (e) => W(e, P),
|
|
85
|
-
findMatches: (e) => {
|
|
86
|
-
let t = 0, n = null, r = null;
|
|
87
|
-
return L.forEach((i) => {
|
|
88
|
-
i.index !== -1 && W(i.label, e) && (t += 1, !i.disabled && ((n === null || i.index < n) && (n = i.index), (r === null || i.index > r) && (r = i.index)));
|
|
89
|
-
}), {
|
|
90
|
-
count: t,
|
|
91
|
-
first: n,
|
|
92
|
-
last: r
|
|
93
|
-
};
|
|
94
|
-
},
|
|
95
|
-
setQuery: I,
|
|
96
|
-
setActiveIndex: N,
|
|
97
|
-
selectValue: e,
|
|
98
|
-
selectIndex: (t) => {
|
|
99
|
-
let n = G[t];
|
|
100
|
-
n === void 0 || K.has(t) || e(n);
|
|
101
|
-
},
|
|
102
|
-
clearValue: () => T(null),
|
|
103
|
-
requestOpenChange: O,
|
|
104
|
-
registration: R,
|
|
105
|
-
setInputLabelling: B
|
|
106
|
-
};
|
|
107
|
-
}, [
|
|
108
|
-
p,
|
|
109
|
-
m,
|
|
110
|
-
D,
|
|
111
|
-
x,
|
|
112
|
-
j,
|
|
113
|
-
L,
|
|
114
|
-
P,
|
|
115
|
-
re,
|
|
116
|
-
z,
|
|
117
|
-
q,
|
|
118
|
-
J,
|
|
119
|
-
Z,
|
|
120
|
-
Q,
|
|
121
|
-
$,
|
|
122
|
-
U,
|
|
123
|
-
W,
|
|
124
|
-
G,
|
|
125
|
-
K,
|
|
126
|
-
T,
|
|
127
|
-
O,
|
|
128
|
-
R
|
|
129
|
-
]);
|
|
130
|
-
return /* @__PURE__ */ ee(F.Provider, {
|
|
131
|
-
value: ae,
|
|
132
|
-
children: [f, l !== void 0 && /* @__PURE__ */ E("input", {
|
|
133
|
-
type: "hidden",
|
|
134
|
-
name: l,
|
|
135
|
-
value: x ?? "",
|
|
136
|
-
disabled: _
|
|
137
|
-
})]
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
V.displayName = "Combobox";
|
|
141
|
-
function H({ ref: e, inputValue: t, defaultInputValue: n, label: a, description: o, error: s, size: c, slotProps: l, className: u, sx: d, id: f, onChange: p, onKeyDown: m, onBlur: h, disabled: _ = !1, ...v }) {
|
|
142
|
-
let { listId: y, open: S, selectedValue: C, activeIndex: T, options: ee, inputHandleRef: D, refs: O, getReferenceProps: te, onInputChange: k, findMatches: A, setQuery: M, setActiveIndex: N, selectIndex: P, clearValue: ne, requestOpenChange: F, setInputLabelling: I, setInputDisabled: R } = L("Input"), z = j([O.setReference, e]), B = b(), V = f ?? B, H = `${V}-label`, U = i(a), W = v["aria-labelledby"], G = v["aria-label"], [K, re] = w(n), [q, J] = w(() => (t ?? n) !== void 0), Y = C === null ? void 0 : ee.get(C)?.label, X = t ?? (q ? K ?? "" : Y ?? K ?? ""), [, ie] = r(X, void 0, k), Z = (e) => {
|
|
143
|
-
ie(e), t === void 0 && re(e);
|
|
144
|
-
}, Q = t !== void 0 || q ? X : "", $ = (e) => {
|
|
145
|
-
J(!1), Z(e);
|
|
146
|
-
};
|
|
147
|
-
x(() => {
|
|
148
|
-
M(Q);
|
|
149
|
-
}, [Q, M]), x(() => (R(_), () => R(!1)), [_, R]), x(() => (D.current = { commitLabel: $ }, () => {
|
|
150
|
-
D.current = null;
|
|
151
|
-
})), x(() => (I(W !== void 0 || !U ? {
|
|
152
|
-
labelledBy: W,
|
|
153
|
-
label: G
|
|
154
|
-
} : { labelledBy: H }), () => I(null)), [
|
|
155
|
-
W,
|
|
156
|
-
G,
|
|
157
|
-
U,
|
|
158
|
-
H,
|
|
159
|
-
I
|
|
160
|
-
]);
|
|
161
|
-
let ae = (e) => {
|
|
162
|
-
p?.(e);
|
|
163
|
-
let n = e.currentTarget.value;
|
|
164
|
-
J(!0), Z(n), n === "" && ne();
|
|
165
|
-
let r = t ?? n;
|
|
166
|
-
if (r === "") {
|
|
167
|
-
N(null), F(!1);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
let i = A(r);
|
|
171
|
-
N(i.first), i.count > 0 && F(!0);
|
|
172
|
-
}, oe = (e) => {
|
|
173
|
-
if (m?.(e), !e.defaultPrevented) {
|
|
174
|
-
if (e.key === "Escape") q && Y !== void 0 && $(Y);
|
|
175
|
-
else if (S) {
|
|
176
|
-
if (e.key === "Enter" && T !== null) e.preventDefault(), P(T);
|
|
177
|
-
else if (e.key === "Home" || e.key === "End") {
|
|
178
|
-
let t = A(Q), n = e.key === "Home" ? t.first : t.last;
|
|
179
|
-
if (n === null) return;
|
|
180
|
-
e.preventDefault(), N(n);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}, se = (e) => {
|
|
185
|
-
h?.(e), S && F(!1);
|
|
186
|
-
};
|
|
187
|
-
return /* @__PURE__ */ E(g, {
|
|
188
|
-
...te({
|
|
189
|
-
...v,
|
|
190
|
-
onKeyDown: oe,
|
|
191
|
-
onBlur: se
|
|
192
|
-
}),
|
|
193
|
-
ref: z,
|
|
194
|
-
id: V,
|
|
195
|
-
label: U ? /* @__PURE__ */ E("span", {
|
|
196
|
-
id: H,
|
|
197
|
-
children: a
|
|
198
|
-
}) : a,
|
|
199
|
-
description: o,
|
|
200
|
-
error: s,
|
|
201
|
-
size: c,
|
|
202
|
-
slotProps: l,
|
|
203
|
-
className: u,
|
|
204
|
-
sx: d,
|
|
205
|
-
value: X,
|
|
206
|
-
disabled: _,
|
|
207
|
-
onChange: ae,
|
|
208
|
-
role: "combobox",
|
|
209
|
-
autoComplete: "off",
|
|
210
|
-
"aria-autocomplete": "list",
|
|
211
|
-
"aria-expanded": S,
|
|
212
|
-
"aria-controls": S ? y : void 0,
|
|
213
|
-
"data-state": S ? "open" : "closed",
|
|
214
|
-
"data-ui": "combobox-input"
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
H.displayName = "Combobox.Input";
|
|
218
|
-
function U({ ref: e, id: n, style: r, onMouseDown: i, children: a, className: o, sx: l, ...u }) {
|
|
219
|
-
let { baseId: d, setListId: f, open: p, inputLabelling: m, refs: h, floatingStyles: g, elementsRef: _, getFloatingProps: v } = L("List"), y = n ?? `${d}-listbox`;
|
|
220
|
-
x(() => (f(y), () => f(`${d}-listbox`)), [
|
|
221
|
-
d,
|
|
222
|
-
y,
|
|
223
|
-
f
|
|
224
|
-
]);
|
|
225
|
-
let b = j([p ? h.setFloating : null, e]), S = u["aria-labelledby"] !== void 0 || u["aria-label"] !== void 0 ? {} : m?.labelledBy === void 0 ? { "aria-label": m?.label } : { "aria-labelledby": m.labelledBy }, C = (e) => {
|
|
226
|
-
i?.(e), e.preventDefault();
|
|
227
|
-
};
|
|
228
|
-
return /* @__PURE__ */ E(O, { children: /* @__PURE__ */ E(t, {
|
|
229
|
-
className: o,
|
|
230
|
-
styles: [c, s],
|
|
231
|
-
sx: l,
|
|
232
|
-
children: (e) => /* @__PURE__ */ E("div", {
|
|
233
|
-
...v({
|
|
234
|
-
id: y,
|
|
235
|
-
...S,
|
|
236
|
-
...u,
|
|
237
|
-
onMouseDown: C
|
|
238
|
-
}),
|
|
239
|
-
ref: b,
|
|
240
|
-
role: "listbox",
|
|
241
|
-
hidden: !p,
|
|
242
|
-
"data-state": p ? "open" : "closed",
|
|
243
|
-
"data-ui": "combobox-list",
|
|
244
|
-
style: {
|
|
245
|
-
...r,
|
|
246
|
-
...g
|
|
247
|
-
},
|
|
248
|
-
className: e,
|
|
249
|
-
children: /* @__PURE__ */ E(D, {
|
|
250
|
-
elementsRef: _,
|
|
251
|
-
children: /* @__PURE__ */ E(I.Provider, {
|
|
252
|
-
value: !0,
|
|
253
|
-
children: a
|
|
254
|
-
})
|
|
255
|
-
})
|
|
256
|
-
})
|
|
257
|
-
}) });
|
|
258
|
-
}
|
|
259
|
-
U.displayName = "Combobox.List";
|
|
260
|
-
function W({ ref: e, value: n, disabled: r = !1, onClick: i, children: a, className: s, sx: c, ...h }) {
|
|
261
|
-
let { baseId: g, selectedValue: _, activeIndex: v, options: y, isVisible: b, getItemProps: x, selectValue: S, registration: w } = R("Item"), T = C(null), { ref: D, index: O } = d(n, w, T, (e, t) => ({
|
|
262
|
-
index: e,
|
|
263
|
-
label: t,
|
|
264
|
-
disabled: r
|
|
265
|
-
})), te = j([D, e]), k = y.get(n)?.label, A = k !== void 0 && !b(k), M = O !== -1 && v === O, P = _ === n, ne = (e) => {
|
|
266
|
-
i?.(e), !(r || e.defaultPrevented) && S(n);
|
|
267
|
-
};
|
|
268
|
-
return /* @__PURE__ */ E(t, {
|
|
269
|
-
className: s,
|
|
270
|
-
styles: [
|
|
271
|
-
f,
|
|
272
|
-
u,
|
|
273
|
-
l,
|
|
274
|
-
z
|
|
275
|
-
],
|
|
276
|
-
sx: c,
|
|
277
|
-
children: (e) => /* @__PURE__ */ ee("div", {
|
|
278
|
-
...x({
|
|
279
|
-
id: p(g, n),
|
|
280
|
-
...h,
|
|
281
|
-
onClick: ne
|
|
282
|
-
}),
|
|
283
|
-
ref: te,
|
|
284
|
-
role: "option",
|
|
285
|
-
hidden: A,
|
|
286
|
-
"aria-selected": P,
|
|
287
|
-
"aria-disabled": r || void 0,
|
|
288
|
-
"data-active": M || void 0,
|
|
289
|
-
"data-ui": "combobox-item",
|
|
290
|
-
className: e,
|
|
291
|
-
children: [/* @__PURE__ */ E("span", {
|
|
292
|
-
ref: T,
|
|
293
|
-
css: m,
|
|
294
|
-
children: a
|
|
295
|
-
}), P && /* @__PURE__ */ E("span", {
|
|
296
|
-
"aria-hidden": "true",
|
|
297
|
-
css: o,
|
|
298
|
-
children: N
|
|
299
|
-
})]
|
|
300
|
-
})
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
W.displayName = "Combobox.Item";
|
|
304
|
-
function G({ ref: e, children: n, className: r, sx: a, ...o }) {
|
|
305
|
-
let { matchCount: s } = R("Empty");
|
|
306
|
-
return s > 0 ? null : /* @__PURE__ */ E(t, {
|
|
307
|
-
className: r,
|
|
308
|
-
styles: B,
|
|
309
|
-
sx: a,
|
|
310
|
-
children: (t) => /* @__PURE__ */ E("div", {
|
|
311
|
-
...o,
|
|
312
|
-
ref: e,
|
|
313
|
-
"data-ui": "combobox-empty",
|
|
314
|
-
className: t,
|
|
315
|
-
children: i(n) ? n : P
|
|
316
|
-
})
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
G.displayName = "Combobox.Empty";
|
|
320
|
-
var K = Object.assign(V, {
|
|
321
|
-
Input: H,
|
|
322
|
-
List: U,
|
|
323
|
-
Item: W,
|
|
324
|
-
Empty: G
|
|
325
|
-
});
|
|
326
|
-
//#endregion
|
|
327
|
-
export { K as t };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { a as e, n as t, r as n, t as r } from "./sx-Dx9JUKp5.js";
|
|
3
|
-
import { vars as i } from "@jfrader/tokens/vars";
|
|
4
|
-
import { jsx as a } from "@emotion/react/jsx-runtime";
|
|
5
|
-
//#region src/styling/theme.ts
|
|
6
|
-
var o = i;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/components/theme-provider/theme-provider.tsx
|
|
9
|
-
function s({ theme: e = o, children: n }) {
|
|
10
|
-
return /* @__PURE__ */ a(t, {
|
|
11
|
-
theme: e,
|
|
12
|
-
children: n
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
s.displayName = "ThemeProvider";
|
|
16
|
-
function c() {
|
|
17
|
-
return e();
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/components/theme-root/theme-root.tsx
|
|
21
|
-
var l = n({
|
|
22
|
-
color: i.color.text,
|
|
23
|
-
colorScheme: "dark",
|
|
24
|
-
"&[data-theme=\"light\"]": { colorScheme: "light" }
|
|
25
|
-
});
|
|
26
|
-
function u({ ref: e, theme: t, className: n, sx: i, ...o }) {
|
|
27
|
-
return /* @__PURE__ */ a(s, { children: /* @__PURE__ */ a(r, {
|
|
28
|
-
className: n,
|
|
29
|
-
styles: l,
|
|
30
|
-
sx: i,
|
|
31
|
-
children: (n) => /* @__PURE__ */ a("div", {
|
|
32
|
-
"data-ui": "theme-root",
|
|
33
|
-
"data-theme": t ?? "dark",
|
|
34
|
-
...o,
|
|
35
|
-
ref: e,
|
|
36
|
-
className: n
|
|
37
|
-
})
|
|
38
|
-
}) });
|
|
39
|
-
}
|
|
40
|
-
u.displayName = "ThemeRoot";
|
|
41
|
-
//#endregion
|
|
42
|
-
export { o as i, s as n, c as r, u as t };
|
package/dist/toast-iqelR-r0.js
DELETED
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { r as e, t } from "./sx-Dx9JUKp5.js";
|
|
3
|
-
import { n } from "./media-D_eA_I-e.js";
|
|
4
|
-
import { t as r } from "./renderable-DzcIj1Lo.js";
|
|
5
|
-
import { t as i } from "./button-P2e7_44z.js";
|
|
6
|
-
import { createContext as a, useCallback as o, useContext as s, useEffect as c, useId as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
7
|
-
import { vars as p } from "@jfrader/tokens/vars";
|
|
8
|
-
import { Fragment as m, jsx as h, jsxs as g } from "@emotion/react/jsx-runtime";
|
|
9
|
-
import { createPortal as _ } from "react-dom";
|
|
10
|
-
//#region src/components/toast/toast.tsx
|
|
11
|
-
var v = 4, y = 5e3, b = "Dismiss", x = 100, S = "min(380px, calc(100vw - 32px))", C = "3px", w = a(null), T = a(null), E = e({
|
|
12
|
-
position: "fixed",
|
|
13
|
-
insetBlockEnd: 0,
|
|
14
|
-
insetInlineEnd: 0,
|
|
15
|
-
display: "flex",
|
|
16
|
-
flexDirection: "column",
|
|
17
|
-
gap: p.space[2],
|
|
18
|
-
inlineSize: S,
|
|
19
|
-
margin: 0,
|
|
20
|
-
paddingInlineEnd: p.space[4],
|
|
21
|
-
paddingBlockEnd: p.space[4],
|
|
22
|
-
pointerEvents: "none",
|
|
23
|
-
fontFamily: p.font.sans
|
|
24
|
-
}), D = e({
|
|
25
|
-
boxSizing: "border-box",
|
|
26
|
-
display: "grid",
|
|
27
|
-
gridTemplateColumns: "minmax(0, 1fr) auto",
|
|
28
|
-
alignItems: "start",
|
|
29
|
-
gap: p.space[2],
|
|
30
|
-
backgroundColor: p.color.surfaceRaised,
|
|
31
|
-
border: `1px solid ${p.color.border}`,
|
|
32
|
-
borderRadius: p.radius.lg,
|
|
33
|
-
boxShadow: p.shadow.floating,
|
|
34
|
-
padding: p.space[3],
|
|
35
|
-
color: p.color.text,
|
|
36
|
-
lineHeight: p.lineHeight.base,
|
|
37
|
-
pointerEvents: "auto",
|
|
38
|
-
transitionProperty: "opacity, transform",
|
|
39
|
-
transitionDuration: p.motion.duration.base,
|
|
40
|
-
transitionTimingFunction: p.motion.easeStandard,
|
|
41
|
-
"&[data-populated=\"false\"]": { opacity: 0 },
|
|
42
|
-
"&[data-state=\"closing\"]": {
|
|
43
|
-
opacity: 0,
|
|
44
|
-
transform: `translateY(${p.space[2]})`,
|
|
45
|
-
pointerEvents: "none"
|
|
46
|
-
},
|
|
47
|
-
[n]: { transitionDuration: "0s" }
|
|
48
|
-
}), O = {
|
|
49
|
-
neutral: e({ borderInlineStart: `${C} solid ${p.color.borderStrong}` }),
|
|
50
|
-
success: e({ borderInlineStart: `${C} solid ${p.color.success}` }),
|
|
51
|
-
danger: e({ borderInlineStart: `${C} solid ${p.color.danger}` })
|
|
52
|
-
}, k = e({
|
|
53
|
-
display: "grid",
|
|
54
|
-
gap: p.space[1],
|
|
55
|
-
alignSelf: "center",
|
|
56
|
-
minInlineSize: 0
|
|
57
|
-
}), A = e({
|
|
58
|
-
margin: 0,
|
|
59
|
-
fontSize: p.textSize.sm,
|
|
60
|
-
fontWeight: p.fontWeight.semibold
|
|
61
|
-
}), j = e({
|
|
62
|
-
margin: 0,
|
|
63
|
-
fontSize: p.textSize.sm,
|
|
64
|
-
color: p.color.textMuted
|
|
65
|
-
}), M = e({
|
|
66
|
-
gridColumn: 2,
|
|
67
|
-
gridRow: 1,
|
|
68
|
-
inlineSize: "32px",
|
|
69
|
-
paddingInline: 0
|
|
70
|
-
}), N = e({ display: "contents" }), P = e({
|
|
71
|
-
gridColumn: "1 / -1",
|
|
72
|
-
display: "flex",
|
|
73
|
-
gap: p.space[2]
|
|
74
|
-
});
|
|
75
|
-
function F(e) {
|
|
76
|
-
let t = s(T);
|
|
77
|
-
if (!t) throw Error(`Toast.${e} must be rendered inside <Toast.Provider>.`);
|
|
78
|
-
return t;
|
|
79
|
-
}
|
|
80
|
-
function I() {
|
|
81
|
-
let e = s(w);
|
|
82
|
-
if (!e) throw Error("useToast() must be called inside <Toast.Provider>.");
|
|
83
|
-
return e;
|
|
84
|
-
}
|
|
85
|
-
function L({ children: e, max: t = v, duration: n = y, dismissLabel: r = b }) {
|
|
86
|
-
let i = l(), a = d(0), [s, c] = f([]), p = d([]), m = d(/* @__PURE__ */ new Map()), g = Math.max(1, Math.floor(Number.isFinite(t) ? t : v)), _ = o((e, t) => {
|
|
87
|
-
t ? m.current.set(e, t) : m.current.delete(e);
|
|
88
|
-
}, []), x = o((e, t) => {
|
|
89
|
-
let n = new Set(t.filter((e) => e.state === "open").map((e) => m.current.get(e.id)));
|
|
90
|
-
for (let t of e) {
|
|
91
|
-
let e = m.current.get(t.id);
|
|
92
|
-
if (e?.contains(e.ownerDocument.activeElement)) {
|
|
93
|
-
Array.from(e.parentElement?.querySelectorAll("[data-ui=\"toast\"]") ?? []).find((e) => n.has(e))?.querySelector("[data-toast-dismiss]")?.focus();
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}, []), S = o((e) => {
|
|
98
|
-
a.current += 1;
|
|
99
|
-
let t = `${i}toast-${a.current}`, r = {
|
|
100
|
-
id: t,
|
|
101
|
-
options: {
|
|
102
|
-
...e,
|
|
103
|
-
duration: e.duration === void 0 ? n : e.duration
|
|
104
|
-
},
|
|
105
|
-
state: "open"
|
|
106
|
-
}, o = p.current, s = [...o, r].slice(-g);
|
|
107
|
-
return x(o.filter((e) => !s.includes(e)), s), p.current = s, c(s), t;
|
|
108
|
-
}, [
|
|
109
|
-
i,
|
|
110
|
-
g,
|
|
111
|
-
n,
|
|
112
|
-
x
|
|
113
|
-
]), C = o((e) => {
|
|
114
|
-
let t = p.current;
|
|
115
|
-
x(t.filter((t) => t.id === e), t.filter((t) => t.id !== e));
|
|
116
|
-
let n = t.map((t) => t.id === e && t.state === "open" ? {
|
|
117
|
-
...t,
|
|
118
|
-
state: "closing"
|
|
119
|
-
} : t);
|
|
120
|
-
p.current = n, c(n);
|
|
121
|
-
}, [x]), E = o((e) => {
|
|
122
|
-
let t = p.current, n = t.filter((t) => t.id !== e);
|
|
123
|
-
x(t.filter((t) => t.id === e), n), p.current = n, c(n);
|
|
124
|
-
}, [x]), D = u(() => ({
|
|
125
|
-
toast: S,
|
|
126
|
-
dismiss: C
|
|
127
|
-
}), [S, C]), O = u(() => ({
|
|
128
|
-
toasts: s,
|
|
129
|
-
dismiss: C,
|
|
130
|
-
remove: E,
|
|
131
|
-
registerRoot: _,
|
|
132
|
-
dismissLabel: r
|
|
133
|
-
}), [
|
|
134
|
-
s,
|
|
135
|
-
C,
|
|
136
|
-
E,
|
|
137
|
-
_,
|
|
138
|
-
r
|
|
139
|
-
]);
|
|
140
|
-
return /* @__PURE__ */ h(w.Provider, {
|
|
141
|
-
value: D,
|
|
142
|
-
children: /* @__PURE__ */ h(T.Provider, {
|
|
143
|
-
value: O,
|
|
144
|
-
children: e
|
|
145
|
-
})
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
L.displayName = "Toast.Provider";
|
|
149
|
-
function R({ ref: e, className: n, sx: r, ...i }) {
|
|
150
|
-
let { toasts: a } = F("Viewport"), o = d(null), [s, l] = f(null);
|
|
151
|
-
return c(() => {
|
|
152
|
-
l(o.current?.ownerDocument.body ?? null);
|
|
153
|
-
}, []), /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
154
|
-
hidden: !0,
|
|
155
|
-
ref: o
|
|
156
|
-
}), s && _(/* @__PURE__ */ h(t, {
|
|
157
|
-
className: n,
|
|
158
|
-
styles: E,
|
|
159
|
-
sx: r,
|
|
160
|
-
children: (t) => /* @__PURE__ */ h("div", {
|
|
161
|
-
...i,
|
|
162
|
-
ref: e,
|
|
163
|
-
"data-ui": "toast-viewport",
|
|
164
|
-
className: t,
|
|
165
|
-
children: a.map((e) => /* @__PURE__ */ h(z, { record: e }, e.id))
|
|
166
|
-
})
|
|
167
|
-
}), s)] });
|
|
168
|
-
}
|
|
169
|
-
R.displayName = "Toast.Viewport";
|
|
170
|
-
function z({ record: e }) {
|
|
171
|
-
let { dismiss: t, remove: n, registerRoot: a, dismissLabel: s } = F("Viewport"), { id: l, options: u, state: p } = e, { title: _, description: v, tone: y = "neutral", action: b } = u, S = u.duration, C = d(null), w = o((e) => {
|
|
172
|
-
C.current = e, a(l, e);
|
|
173
|
-
}, [l, a]), [T, E] = f(!1), [I, L] = f(!1), [R, z] = f(!1), V = d(S ?? 0);
|
|
174
|
-
c(() => {
|
|
175
|
-
let e = setTimeout(() => E(!0), x);
|
|
176
|
-
return () => clearTimeout(e);
|
|
177
|
-
}, []);
|
|
178
|
-
let H = T && p === "open" && S !== null && !I && !R;
|
|
179
|
-
return c(() => {
|
|
180
|
-
if (!H) return;
|
|
181
|
-
let e = performance.now(), n = setTimeout(() => t(l), V.current);
|
|
182
|
-
return () => {
|
|
183
|
-
clearTimeout(n), V.current -= performance.now() - e;
|
|
184
|
-
};
|
|
185
|
-
}, [
|
|
186
|
-
H,
|
|
187
|
-
t,
|
|
188
|
-
l
|
|
189
|
-
]), c(() => {
|
|
190
|
-
if (p !== "closing") return;
|
|
191
|
-
let e = C.current, t = e && typeof e.getAnimations == "function" ? e.getAnimations() : [], r = !1;
|
|
192
|
-
return Promise.allSettled(t.map((e) => e.finished)).then(() => {
|
|
193
|
-
r || n(l);
|
|
194
|
-
}), () => {
|
|
195
|
-
r = !0;
|
|
196
|
-
};
|
|
197
|
-
}, [
|
|
198
|
-
p,
|
|
199
|
-
n,
|
|
200
|
-
l
|
|
201
|
-
]), /* @__PURE__ */ g("div", {
|
|
202
|
-
ref: w,
|
|
203
|
-
inert: p === "closing",
|
|
204
|
-
"data-ui": "toast",
|
|
205
|
-
"data-tone": y,
|
|
206
|
-
"data-state": p,
|
|
207
|
-
"data-populated": T,
|
|
208
|
-
onPointerEnter: () => L(!0),
|
|
209
|
-
onPointerLeave: () => L(!1),
|
|
210
|
-
onFocus: () => z(!0),
|
|
211
|
-
onBlur: (e) => {
|
|
212
|
-
e.currentTarget.contains(e.relatedTarget) || z(!1);
|
|
213
|
-
},
|
|
214
|
-
css: [D, O[y]],
|
|
215
|
-
children: [/* @__PURE__ */ h("div", {
|
|
216
|
-
role: y === "danger" ? "alert" : "status",
|
|
217
|
-
"aria-atomic": "true",
|
|
218
|
-
css: k,
|
|
219
|
-
children: T && /* @__PURE__ */ g(m, { children: [r(_) && /* @__PURE__ */ h("div", {
|
|
220
|
-
css: A,
|
|
221
|
-
children: _
|
|
222
|
-
}), r(v) && /* @__PURE__ */ h("div", {
|
|
223
|
-
css: j,
|
|
224
|
-
children: v
|
|
225
|
-
})] })
|
|
226
|
-
}), T && /* @__PURE__ */ g("div", {
|
|
227
|
-
css: N,
|
|
228
|
-
children: [/* @__PURE__ */ h(i, {
|
|
229
|
-
variant: "ghost",
|
|
230
|
-
size: "sm",
|
|
231
|
-
"aria-label": s,
|
|
232
|
-
"data-toast-dismiss": "",
|
|
233
|
-
onClick: () => t(l),
|
|
234
|
-
css: M,
|
|
235
|
-
children: /* @__PURE__ */ h(B, {})
|
|
236
|
-
}), b && /* @__PURE__ */ h("div", {
|
|
237
|
-
css: P,
|
|
238
|
-
children: /* @__PURE__ */ h(i, {
|
|
239
|
-
variant: "outline",
|
|
240
|
-
size: "sm",
|
|
241
|
-
onClick: (e) => {
|
|
242
|
-
b?.onClick(e), e.defaultPrevented || t(l);
|
|
243
|
-
},
|
|
244
|
-
children: b.label
|
|
245
|
-
})
|
|
246
|
-
})]
|
|
247
|
-
})]
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
function B() {
|
|
251
|
-
return /* @__PURE__ */ g("svg", {
|
|
252
|
-
"aria-hidden": "true",
|
|
253
|
-
viewBox: "0 0 16 16",
|
|
254
|
-
width: "16",
|
|
255
|
-
height: "16",
|
|
256
|
-
fill: "none",
|
|
257
|
-
stroke: "currentColor",
|
|
258
|
-
strokeWidth: "2",
|
|
259
|
-
strokeLinecap: "round",
|
|
260
|
-
children: [/* @__PURE__ */ h("line", {
|
|
261
|
-
x1: "4",
|
|
262
|
-
y1: "4",
|
|
263
|
-
x2: "12",
|
|
264
|
-
y2: "12"
|
|
265
|
-
}), /* @__PURE__ */ h("line", {
|
|
266
|
-
x1: "12",
|
|
267
|
-
y1: "4",
|
|
268
|
-
x2: "4",
|
|
269
|
-
y2: "12"
|
|
270
|
-
})]
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
function V(e) {
|
|
274
|
-
return /* @__PURE__ */ h(L, { ...e });
|
|
275
|
-
}
|
|
276
|
-
V.displayName = "Toast";
|
|
277
|
-
var H = Object.assign(V, {
|
|
278
|
-
Provider: L,
|
|
279
|
-
Viewport: R
|
|
280
|
-
});
|
|
281
|
-
//#endregion
|
|
282
|
-
export { I as n, H as t };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { autoUpdate as e, flip as t, offset as n, shift as r, useFloating as i } from "@floating-ui/react";
|
|
3
|
-
//#region src/overlay/use-overlay-floating.ts
|
|
4
|
-
var a = 8, o = 8;
|
|
5
|
-
function s({ open: s, onOpenChange: c, placement: l }) {
|
|
6
|
-
return i({
|
|
7
|
-
open: s,
|
|
8
|
-
onOpenChange: c,
|
|
9
|
-
placement: l,
|
|
10
|
-
middleware: [
|
|
11
|
-
n(a),
|
|
12
|
-
t({ padding: o }),
|
|
13
|
-
r({ padding: o })
|
|
14
|
-
],
|
|
15
|
-
whileElementsMounted: e
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { s as t };
|