@brightlocal/ui-components 1.2.0 → 1.2.2
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/component-meta.json +112 -474
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +20 -16
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +1 -1
- package/dist/centred-layout.js +1 -1
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +2 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +177 -150
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +53 -47
- package/dist/split-layout.cjs +1 -1
- package/dist/split-layout.js +9 -9
- package/package.json +1 -1
- package/src/components/card.tsx +8 -4
- package/src/components/centred-layout.tsx +2 -2
- package/src/components/combobox.tsx +97 -4
- package/src/components/sonner.tsx +36 -27
- package/src/components/split-layout.tsx +3 -3
package/dist/combobox.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
1
|
+
import { jsx as a, jsxs as E, Fragment as A } from "react/jsx-runtime";
|
|
2
2
|
import * as t from "react";
|
|
3
|
-
import { Check as
|
|
4
|
-
import { cva as
|
|
5
|
-
import { defaultFilter as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { Popover as
|
|
8
|
-
import { Command as
|
|
3
|
+
import { Check as M, ChevronsUpDown as j } from "@brightlocal/icons";
|
|
4
|
+
import { cva as O } from "class-variance-authority";
|
|
5
|
+
import { defaultFilter as P } from "cmdk";
|
|
6
|
+
import { cn as y } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { Popover as G, PopoverContent as U, PopoverTrigger as _ } from "@brightlocal/ui-components/popover";
|
|
8
|
+
import { Command as $, CommandEmpty as q, CommandGroup as z, CommandInput as D, CommandItem as H, CommandList as V, CommandSeparator as B } from "@brightlocal/ui-components/command";
|
|
9
9
|
const T = t.createContext(null);
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
10
|
+
function I() {
|
|
11
|
+
const e = t.useContext(T);
|
|
12
|
+
if (!e)
|
|
13
13
|
throw new Error("Combobox components must be used within a <Combobox>");
|
|
14
|
-
return
|
|
14
|
+
return e;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
value:
|
|
18
|
-
onValueChange:
|
|
16
|
+
function ue({
|
|
17
|
+
value: e,
|
|
18
|
+
onValueChange: o,
|
|
19
19
|
open: n,
|
|
20
20
|
onOpenChange: r,
|
|
21
|
-
shouldFilter:
|
|
21
|
+
shouldFilter: i = !0,
|
|
22
22
|
disabled: d = !1,
|
|
23
|
-
itemToStringValue:
|
|
24
|
-
children:
|
|
23
|
+
itemToStringValue: u,
|
|
24
|
+
children: b
|
|
25
25
|
}) {
|
|
26
|
-
const [
|
|
26
|
+
const [h, v] = t.useState(""), [f, w] = t.useState(!1), [C, s] = t.useState(
|
|
27
27
|
() => /* @__PURE__ */ new Map()
|
|
28
|
-
),
|
|
29
|
-
(
|
|
30
|
-
|
|
28
|
+
), p = e !== void 0, x = n !== void 0, c = p ? e : h, m = x ? n : f, g = t.useCallback(
|
|
29
|
+
(l) => {
|
|
30
|
+
x || w(l), r?.(l);
|
|
31
31
|
},
|
|
32
|
-
[
|
|
33
|
-
),
|
|
34
|
-
(
|
|
35
|
-
|
|
32
|
+
[x, r]
|
|
33
|
+
), k = t.useCallback(
|
|
34
|
+
(l) => {
|
|
35
|
+
p || v(l), o?.(l);
|
|
36
36
|
},
|
|
37
|
-
[
|
|
38
|
-
),
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
return
|
|
37
|
+
[p, o]
|
|
38
|
+
), N = t.useCallback((l, L) => {
|
|
39
|
+
s((S) => {
|
|
40
|
+
if (S.get(l) === L) return S;
|
|
41
|
+
const F = new Map(S);
|
|
42
|
+
return F.set(l, L), F;
|
|
43
43
|
});
|
|
44
|
-
}, []),
|
|
44
|
+
}, []), R = t.useMemo(
|
|
45
45
|
() => ({
|
|
46
|
-
open:
|
|
47
|
-
setOpen:
|
|
48
|
-
value:
|
|
49
|
-
onValueChange:
|
|
50
|
-
shouldFilter:
|
|
46
|
+
open: m,
|
|
47
|
+
setOpen: g,
|
|
48
|
+
value: c,
|
|
49
|
+
onValueChange: k,
|
|
50
|
+
shouldFilter: i,
|
|
51
51
|
disabled: d,
|
|
52
|
-
itemLabels:
|
|
53
|
-
registerItem:
|
|
54
|
-
itemToStringValue:
|
|
52
|
+
itemLabels: C,
|
|
53
|
+
registerItem: N,
|
|
54
|
+
itemToStringValue: u
|
|
55
55
|
}),
|
|
56
56
|
[
|
|
57
|
-
w,
|
|
58
|
-
y,
|
|
59
|
-
h,
|
|
60
|
-
N,
|
|
61
|
-
s,
|
|
62
|
-
d,
|
|
63
57
|
m,
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
g,
|
|
59
|
+
c,
|
|
60
|
+
k,
|
|
61
|
+
i,
|
|
62
|
+
d,
|
|
63
|
+
C,
|
|
64
|
+
N,
|
|
65
|
+
u
|
|
66
66
|
]
|
|
67
67
|
);
|
|
68
|
-
return /* @__PURE__ */ a(T.Provider, { value:
|
|
68
|
+
return /* @__PURE__ */ a(T.Provider, { value: R, children: /* @__PURE__ */ a(G, { open: m, onOpenChange: g, children: b }) });
|
|
69
69
|
}
|
|
70
|
-
const J =
|
|
70
|
+
const J = O(
|
|
71
71
|
[
|
|
72
72
|
// Base layout
|
|
73
73
|
"relative flex w-full items-center justify-between gap-2",
|
|
@@ -105,43 +105,43 @@ const J = G(
|
|
|
105
105
|
}
|
|
106
106
|
), K = t.forwardRef(
|
|
107
107
|
({
|
|
108
|
-
className:
|
|
109
|
-
variant:
|
|
108
|
+
className: e,
|
|
109
|
+
variant: o,
|
|
110
110
|
dataHook: n,
|
|
111
111
|
error: r,
|
|
112
|
-
trackingEl:
|
|
112
|
+
trackingEl: i,
|
|
113
113
|
trackingLabel: d,
|
|
114
|
-
children:
|
|
115
|
-
...
|
|
116
|
-
},
|
|
117
|
-
const { open:
|
|
118
|
-
return /* @__PURE__ */ a(
|
|
114
|
+
children: u,
|
|
115
|
+
...b
|
|
116
|
+
}, h) => {
|
|
117
|
+
const { open: v, disabled: f, value: w } = I(), C = t.useId(), s = !w, p = r || b["aria-invalid"] === !0 || b["aria-invalid"] === "true";
|
|
118
|
+
return /* @__PURE__ */ a(_, { asChild: !0, children: /* @__PURE__ */ E(
|
|
119
119
|
"button",
|
|
120
120
|
{
|
|
121
|
-
ref:
|
|
122
|
-
"aria-controls":
|
|
123
|
-
"aria-expanded":
|
|
121
|
+
ref: h,
|
|
122
|
+
"aria-controls": v ? C : void 0,
|
|
123
|
+
"aria-expanded": v,
|
|
124
124
|
"aria-haspopup": "listbox",
|
|
125
|
-
"aria-invalid":
|
|
126
|
-
className:
|
|
127
|
-
J({ variant:
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
"aria-invalid": p ? "true" : void 0,
|
|
126
|
+
className: y(
|
|
127
|
+
J({ variant: o }),
|
|
128
|
+
p && "border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive",
|
|
129
|
+
e
|
|
130
130
|
),
|
|
131
131
|
"data-hook": n,
|
|
132
|
-
"data-placeholder":
|
|
132
|
+
"data-placeholder": s,
|
|
133
133
|
"data-slot": "combobox-trigger",
|
|
134
|
-
"data-state":
|
|
135
|
-
"data-tracking-el":
|
|
134
|
+
"data-state": v ? "open" : "closed",
|
|
135
|
+
"data-tracking-el": i || "combobox-trigger",
|
|
136
136
|
"data-tracking-label": d,
|
|
137
|
-
disabled:
|
|
137
|
+
disabled: f || b.disabled,
|
|
138
138
|
role: "combobox",
|
|
139
139
|
type: "button",
|
|
140
|
-
...
|
|
140
|
+
...b,
|
|
141
141
|
children: [
|
|
142
|
-
|
|
142
|
+
u,
|
|
143
143
|
/* @__PURE__ */ a(
|
|
144
|
-
|
|
144
|
+
j,
|
|
145
145
|
{
|
|
146
146
|
"aria-hidden": "true",
|
|
147
147
|
className: "text-muted-foreground ml-auto shrink-0"
|
|
@@ -153,120 +153,147 @@ const J = G(
|
|
|
153
153
|
}
|
|
154
154
|
);
|
|
155
155
|
K.displayName = "ComboboxTrigger";
|
|
156
|
-
function
|
|
157
|
-
const { value: n, itemLabels: r } =
|
|
156
|
+
function ce({ placeholder: e, className: o }) {
|
|
157
|
+
const { value: n, itemLabels: r } = I(), i = n ? r.get(n) || n : e;
|
|
158
158
|
return /* @__PURE__ */ a(
|
|
159
159
|
"span",
|
|
160
160
|
{
|
|
161
|
-
className:
|
|
161
|
+
className: y(
|
|
162
162
|
"text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",
|
|
163
|
-
|
|
163
|
+
o
|
|
164
164
|
),
|
|
165
165
|
"data-slot": "combobox-value",
|
|
166
|
-
children:
|
|
166
|
+
children: i
|
|
167
167
|
}
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
dataHook:
|
|
172
|
-
className:
|
|
170
|
+
function le({
|
|
171
|
+
dataHook: e,
|
|
172
|
+
className: o,
|
|
173
173
|
children: n,
|
|
174
174
|
align: r = "start",
|
|
175
|
-
side:
|
|
175
|
+
side: i = "bottom",
|
|
176
176
|
sideOffset: d,
|
|
177
|
-
avoidCollisions:
|
|
178
|
-
hideList:
|
|
177
|
+
avoidCollisions: u,
|
|
178
|
+
hideList: b = !1
|
|
179
179
|
}) {
|
|
180
|
-
const { shouldFilter:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
const { open: h, shouldFilter: v, itemToStringValue: f } = I(), [w, C] = t.useState(
|
|
181
|
+
null
|
|
182
|
+
), s = t.useRef(null), p = t.useCallback((c) => {
|
|
183
|
+
if (s.current?.(), s.current = null, !c) return;
|
|
184
|
+
let m = !1;
|
|
185
|
+
const g = (l) => {
|
|
186
|
+
m || (l === "top" || l === "bottom") && (m = !0, k.disconnect(), C(l));
|
|
187
|
+
}, k = new MutationObserver(() => {
|
|
188
|
+
g(c.getAttribute("data-side"));
|
|
189
|
+
});
|
|
190
|
+
k.observe(c, {
|
|
191
|
+
attributes: !0,
|
|
192
|
+
attributeFilter: ["data-side"]
|
|
193
|
+
});
|
|
194
|
+
let N = 0, R = 0;
|
|
195
|
+
N = requestAnimationFrame(() => {
|
|
196
|
+
R = requestAnimationFrame(() => {
|
|
197
|
+
g(c.getAttribute("data-side"));
|
|
198
|
+
});
|
|
199
|
+
}), s.current = () => {
|
|
200
|
+
m = !0, k.disconnect(), cancelAnimationFrame(N), cancelAnimationFrame(R);
|
|
201
|
+
};
|
|
202
|
+
}, []);
|
|
203
|
+
t.useEffect(() => {
|
|
204
|
+
h || (s.current?.(), s.current = null, C(null));
|
|
205
|
+
}, [h]);
|
|
206
|
+
const x = t.useMemo(() => {
|
|
207
|
+
if (f)
|
|
208
|
+
return (c, m, g) => P(f(c), m, g);
|
|
209
|
+
}, [f]);
|
|
184
210
|
return /* @__PURE__ */ a(
|
|
185
|
-
|
|
211
|
+
U,
|
|
186
212
|
{
|
|
213
|
+
ref: p,
|
|
187
214
|
align: r,
|
|
188
215
|
"aria-label": "Options",
|
|
189
|
-
avoidCollisions:
|
|
190
|
-
className:
|
|
216
|
+
avoidCollisions: u,
|
|
217
|
+
className: y("w-[var(--radix-popover-trigger-width)] p-0", o),
|
|
191
218
|
"data-slot": "combobox-popover",
|
|
192
|
-
side:
|
|
219
|
+
side: w ?? i,
|
|
193
220
|
sideOffset: d,
|
|
194
221
|
children: /* @__PURE__ */ a(
|
|
195
|
-
|
|
222
|
+
$,
|
|
196
223
|
{
|
|
197
|
-
className:
|
|
224
|
+
className: y(
|
|
198
225
|
"border-0 shadow-none",
|
|
199
|
-
|
|
226
|
+
b && "[&_[data-slot='command-input-wrapper']]:border-b-0"
|
|
200
227
|
),
|
|
201
228
|
"data-slot": "combobox-command",
|
|
202
|
-
dataHook:
|
|
203
|
-
filter:
|
|
204
|
-
shouldFilter:
|
|
229
|
+
dataHook: e || "combobox-command",
|
|
230
|
+
filter: x,
|
|
231
|
+
shouldFilter: v,
|
|
205
232
|
children: n
|
|
206
233
|
}
|
|
207
234
|
)
|
|
208
235
|
}
|
|
209
236
|
);
|
|
210
237
|
}
|
|
211
|
-
const Q = t.forwardRef((
|
|
238
|
+
const Q = t.forwardRef((e, o) => /* @__PURE__ */ a(D, { ref: o, "data-slot": "combobox-input", ...e }));
|
|
212
239
|
Q.displayName = "ComboboxInput";
|
|
213
|
-
const W = t.forwardRef((
|
|
240
|
+
const W = t.forwardRef((e, o) => /* @__PURE__ */ a(V, { ref: o, "data-slot": "combobox-list", ...e }));
|
|
214
241
|
W.displayName = "ComboboxList";
|
|
215
|
-
const X = t.forwardRef((
|
|
242
|
+
const X = t.forwardRef((e, o) => /* @__PURE__ */ a(q, { ref: o, "data-slot": "combobox-empty", ...e }));
|
|
216
243
|
X.displayName = "ComboboxEmpty";
|
|
217
|
-
const Y = t.forwardRef((
|
|
244
|
+
const Y = t.forwardRef((e, o) => /* @__PURE__ */ a(z, { ref: o, "data-slot": "combobox-group", ...e }));
|
|
218
245
|
Y.displayName = "ComboboxGroup";
|
|
219
|
-
function Z(
|
|
220
|
-
if (!
|
|
221
|
-
return
|
|
246
|
+
function Z(e, o, n) {
|
|
247
|
+
if (!o || !o.trim())
|
|
248
|
+
return e;
|
|
222
249
|
const r = new RegExp(
|
|
223
|
-
`(${
|
|
250
|
+
`(${o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
224
251
|
"gi"
|
|
225
|
-
),
|
|
226
|
-
return /* @__PURE__ */ a("span", { children:
|
|
227
|
-
(d,
|
|
252
|
+
), i = e.split(r);
|
|
253
|
+
return /* @__PURE__ */ a("span", { children: i.map(
|
|
254
|
+
(d, u) => u % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: d }, u) : /* @__PURE__ */ a(t.Fragment, { children: d }, u)
|
|
228
255
|
) });
|
|
229
256
|
}
|
|
230
|
-
const
|
|
257
|
+
const ee = t.forwardRef(
|
|
231
258
|
({
|
|
232
|
-
value:
|
|
233
|
-
label:
|
|
259
|
+
value: e,
|
|
260
|
+
label: o,
|
|
234
261
|
dataHook: n,
|
|
235
262
|
children: r,
|
|
236
|
-
className:
|
|
263
|
+
className: i,
|
|
237
264
|
highlight: d,
|
|
238
|
-
highlightClassName:
|
|
239
|
-
keywords:
|
|
240
|
-
...
|
|
241
|
-
},
|
|
242
|
-
const { value:
|
|
265
|
+
highlightClassName: u,
|
|
266
|
+
keywords: b,
|
|
267
|
+
...h
|
|
268
|
+
}, v) => {
|
|
269
|
+
const { value: f, onValueChange: w, setOpen: C, registerItem: s } = I(), p = f === e, x = t.useMemo(() => o || (typeof r == "string" ? r : typeof r == "number" ? String(r) : e), [o, r, e]), c = t.useRef(s);
|
|
243
270
|
t.useEffect(() => {
|
|
244
|
-
|
|
245
|
-
}, [
|
|
246
|
-
|
|
247
|
-
}, [
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
},
|
|
271
|
+
c.current = s;
|
|
272
|
+
}, [s]), t.useEffect(() => {
|
|
273
|
+
c.current(e, x);
|
|
274
|
+
}, [e, x]);
|
|
275
|
+
const m = () => {
|
|
276
|
+
w(e === f ? "" : e), C(!1);
|
|
277
|
+
}, g = () => d && typeof r == "string" ? Z(
|
|
251
278
|
r,
|
|
252
279
|
d,
|
|
253
|
-
|
|
280
|
+
u || "text-sm leading-normal font-semibold"
|
|
254
281
|
) : r;
|
|
255
|
-
return /* @__PURE__ */
|
|
256
|
-
|
|
282
|
+
return /* @__PURE__ */ E(
|
|
283
|
+
H,
|
|
257
284
|
{
|
|
258
|
-
ref:
|
|
259
|
-
className:
|
|
285
|
+
ref: v,
|
|
286
|
+
className: y("justify-between", i),
|
|
260
287
|
"data-slot": "combobox-item",
|
|
261
288
|
dataHook: n,
|
|
262
|
-
keywords:
|
|
263
|
-
value:
|
|
264
|
-
onSelect:
|
|
265
|
-
...
|
|
289
|
+
keywords: b ? [x, ...b] : [x],
|
|
290
|
+
value: e,
|
|
291
|
+
onSelect: m,
|
|
292
|
+
...h,
|
|
266
293
|
children: [
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
294
|
+
g(),
|
|
295
|
+
p && /* @__PURE__ */ a(
|
|
296
|
+
M,
|
|
270
297
|
{
|
|
271
298
|
"aria-hidden": "true",
|
|
272
299
|
className: "text-muted-foreground shrink-0"
|
|
@@ -277,22 +304,22 @@ const oo = t.forwardRef(
|
|
|
277
304
|
);
|
|
278
305
|
}
|
|
279
306
|
);
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
function
|
|
307
|
+
ee.displayName = "ComboboxItem";
|
|
308
|
+
const oe = t.forwardRef((e, o) => /* @__PURE__ */ a(B, { ref: o, "data-slot": "combobox-separator", ...e }));
|
|
309
|
+
oe.displayName = "ComboboxSeparator";
|
|
310
|
+
function be({ className: e, children: o }) {
|
|
284
311
|
return /* @__PURE__ */ a(
|
|
285
312
|
"div",
|
|
286
313
|
{
|
|
287
314
|
"aria-disabled": "true",
|
|
288
315
|
"aria-selected": "false",
|
|
289
|
-
className:
|
|
316
|
+
className: y(
|
|
290
317
|
"text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",
|
|
291
|
-
|
|
318
|
+
e
|
|
292
319
|
),
|
|
293
320
|
"data-slot": "combobox-loading",
|
|
294
321
|
role: "option",
|
|
295
|
-
children:
|
|
322
|
+
children: o || /* @__PURE__ */ E(A, { children: [
|
|
296
323
|
/* @__PURE__ */ a(
|
|
297
324
|
"div",
|
|
298
325
|
{
|
|
@@ -306,15 +333,15 @@ function mo({ className: o, children: e }) {
|
|
|
306
333
|
);
|
|
307
334
|
}
|
|
308
335
|
export {
|
|
309
|
-
|
|
310
|
-
|
|
336
|
+
ue as Combobox,
|
|
337
|
+
le as ComboboxContent,
|
|
311
338
|
X as ComboboxEmpty,
|
|
312
339
|
Y as ComboboxGroup,
|
|
313
340
|
Q as ComboboxInput,
|
|
314
|
-
|
|
341
|
+
ee as ComboboxItem,
|
|
315
342
|
W as ComboboxList,
|
|
316
|
-
|
|
317
|
-
|
|
343
|
+
be as ComboboxLoading,
|
|
344
|
+
oe as ComboboxSeparator,
|
|
318
345
|
K as ComboboxTrigger,
|
|
319
|
-
|
|
346
|
+
ce as ComboboxValue
|
|
320
347
|
};
|
package/dist/sonner.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("@brightlocal/icons"),m=require("class-variance-authority"),d=require("sonner"),b=require("@brightlocal/ui-components/button"),o=require("@brightlocal/ui-components/lib/utils"),g=4e3,v=m.cva(["flex","items-center","justify-between","w-full","md:w-auto","md:min-w-[364px]","rounded-md","border","border-border","p-4","gap-2","shadow-lg"].join(" "),{variants:{colorSchema:{default:"bg-white dark:bg-popover",success:"bg-green-200 dark:bg-popover"}},defaultVariants:{colorSchema:"default"}}),p=m.cva("text-sm leading-normal font-medium",{variants:{colorSchema:{default:"text-foreground",success:"text-green-900 dark:text-green-100"}},defaultVariants:{colorSchema:"default"}}),N=m.cva("text-sm leading-normal",{variants:{colorSchema:{default:"text-muted-foreground",success:"text-green-900 dark:text-green-100"}},defaultVariants:{colorSchema:"default"}}),l=m.cva("",{variants:{colorSchema:{default:"text-foreground",success:"text-green-900 dark:text-green-100"}},defaultVariants:{colorSchema:"default"}});function j(s,e){switch(s){case"info":return t.jsx(i.Info,{className:o.cn(l({colorSchema:e}))});case"success":return t.jsx(i.CheckCircle2,{className:o.cn(l({colorSchema:e}))});case"warning":return t.jsx(i.AlertTriangle,{className:o.cn(l({colorSchema:e}))});case"error":return t.jsx(i.XCircle,{className:o.cn(l({colorSchema:e}))});case"loading":return t.jsx(i.Loader2,{className:o.cn(l({colorSchema:e}),"animate-spin")});default:return null}}const x=function(e,r){const{id:c,...n}=e,u={...r,duration:r?.duration??g,...c!=null&&{id:r?.id??c}},h=u.duration===1/0;d.toast.custom(a=>{const f=n.button&&n.button.label?{label:n.button.label,variant:n.button.variant,onClick:()=>{n.button?.onClick&&n.button.onClick(),d.toast.dismiss(a)}}:void 0;return t.jsx(T,{button:f,colorSchema:n.colorSchema,description:n.description,icon:n.icon??void 0,id:a,title:n.title})},{...u,...h&&{dismissible:!1}})};x.dismiss=s=>{d.toast.dismiss(s)};function T(s){const{button:e,description:r,icon:c,title:n,colorSchema:u}=s,a=(f=>f==="success"?"success":"default")(u);return t.jsxs("div",{"aria-atomic":"true","aria-live":"polite",className:o.cn(v({colorSchema:a})),role:"status",children:[t.jsxs("div",{className:"flex flex-1 items-start gap-2",children:[c!=null&&j(c,a),t.jsxs("div",{className:"w-full",children:[t.jsx("p",{className:o.cn(p({colorSchema:a})),children:n}),r&&t.jsx("p",{className:o.cn(N({colorSchema:a})),children:r})]})]}),e?.label&&t.jsx(b.Button,{"aria-label":e.label,className:"min-h-6 px-2 py-0 text-xs leading-normal font-medium",dataHook:"toast-action",size:"default",variant:e.variant,onClick:e.onClick,children:e.label})]})}function S(){return t.jsx(d.Toaster,{position:"top-right"})}S.displayName="Sonner";exports.Sonner=S;exports.sonner=x;
|
package/dist/sonner.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type SonnerColorSchema = "default" | "success";
|
|
|
36
36
|
type SonnerCustomOptions = {
|
|
37
37
|
className?: string;
|
|
38
38
|
id?: string | number;
|
|
39
|
-
/** Duration in ms before the toast auto-dismisses. Set to `Infinity`
|
|
39
|
+
/** Duration in ms before the toast auto-dismisses. Set to `Infinity` for a persistent toast that can only be dismissed programmatically via `sonner.dismiss(id)` or through an action button. @default 4000 */
|
|
40
40
|
duration?: number;
|
|
41
41
|
};
|
|
42
42
|
/**
|
package/dist/sonner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sonner.d.ts","sourceRoot":"","sources":["../../src/components/sonner.tsx"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,KAAK,UAAU,GAAG;IAChB,2CAA2C;IAC3C,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,MAAM,CAAC,EAAE;QACP,wBAAwB;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,mCAAmC;QACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,mCAAmC;QACnC,OAAO,CAAC,EACJ,SAAS,GACT,aAAa,GACb,SAAS,GACT,WAAW,GACX,OAAO,GACP,SAAS,CAAC;KACf,CAAC;IACF,gCAAgC;IAChC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,mCAAmC;IACnC,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9E,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,IAAI,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtD,KAAK,mBAAmB,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB
|
|
1
|
+
{"version":3,"file":"sonner.d.ts","sourceRoot":"","sources":["../../src/components/sonner.tsx"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,KAAK,UAAU,GAAG;IAChB,2CAA2C;IAC3C,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,MAAM,CAAC,EAAE;QACP,wBAAwB;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,mCAAmC;QACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;QACrB,mCAAmC;QACnC,OAAO,CAAC,EACJ,SAAS,GACT,aAAa,GACb,SAAS,GACT,WAAW,GACX,OAAO,GACP,SAAS,CAAC;KACf,CAAC;IACF,gCAAgC;IAChC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,mCAAmC;IACnC,IAAI,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE9E,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,IAAI,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtD,KAAK,mBAAmB,GAAG;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,+MAA+M;IAC/M,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,KAAK,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAuGpE,UAAU,QAAQ;IAChB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzD,mCAAmC;IACnC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,QAAA,MAAM,MAAM,EAAE,QA+Cb,CAAC;AAyDF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,iBAAS,MAAM,4CAEd;kBAFQ,MAAM;;;AAKf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}
|