@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/dist/combobox.js CHANGED
@@ -1,73 +1,73 @@
1
- import { jsx as a, jsxs as R, Fragment as M } from "react/jsx-runtime";
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 P, ChevronsUpDown as F } from "@brightlocal/icons";
4
- import { cva as G } from "class-variance-authority";
5
- import { defaultFilter as O } from "cmdk";
6
- import { cn as C } from "@brightlocal/ui-components/lib/utils";
7
- import { Popover as U, PopoverContent as _, PopoverTrigger as $ } from "@brightlocal/ui-components/popover";
8
- import { Command as z, CommandEmpty as D, CommandGroup as H, CommandInput as V, CommandItem as q, CommandList as A, CommandSeparator as B } from "@brightlocal/ui-components/command";
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 k() {
11
- const o = t.useContext(T);
12
- if (!o)
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 o;
14
+ return e;
15
15
  }
16
- function lo({
17
- value: o,
18
- onValueChange: e,
16
+ function ue({
17
+ value: e,
18
+ onValueChange: o,
19
19
  open: n,
20
20
  onOpenChange: r,
21
- shouldFilter: s = !0,
21
+ shouldFilter: i = !0,
22
22
  disabled: d = !1,
23
- itemToStringValue: i,
24
- children: u
23
+ itemToStringValue: u,
24
+ children: b
25
25
  }) {
26
- const [g, l] = t.useState(""), [b, v] = t.useState(!1), [m, c] = t.useState(
26
+ const [h, v] = t.useState(""), [f, w] = t.useState(!1), [C, s] = t.useState(
27
27
  () => /* @__PURE__ */ new Map()
28
- ), f = o !== void 0, p = n !== void 0, h = f ? o : g, w = p ? n : b, y = t.useCallback(
29
- (x) => {
30
- p || v(x), r?.(x);
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
- [p, r]
33
- ), N = t.useCallback(
34
- (x) => {
35
- f || l(x), e?.(x);
32
+ [x, r]
33
+ ), k = t.useCallback(
34
+ (l) => {
35
+ p || v(l), o?.(l);
36
36
  },
37
- [f, e]
38
- ), S = t.useCallback((x, E) => {
39
- c((I) => {
40
- if (I.get(x) === E) return I;
41
- const L = new Map(I);
42
- return L.set(x, E), L;
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
- }, []), j = t.useMemo(
44
+ }, []), R = t.useMemo(
45
45
  () => ({
46
- open: w,
47
- setOpen: y,
48
- value: h,
49
- onValueChange: N,
50
- shouldFilter: s,
46
+ open: m,
47
+ setOpen: g,
48
+ value: c,
49
+ onValueChange: k,
50
+ shouldFilter: i,
51
51
  disabled: d,
52
- itemLabels: m,
53
- registerItem: S,
54
- itemToStringValue: i
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
- S,
65
- i
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: j, children: /* @__PURE__ */ a(U, { open: w, onOpenChange: y, children: u }) });
68
+ return /* @__PURE__ */ a(T.Provider, { value: R, children: /* @__PURE__ */ a(G, { open: m, onOpenChange: g, children: b }) });
69
69
  }
70
- const J = G(
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: o,
109
- variant: e,
108
+ className: e,
109
+ variant: o,
110
110
  dataHook: n,
111
111
  error: r,
112
- trackingEl: s,
112
+ trackingEl: i,
113
113
  trackingLabel: d,
114
- children: i,
115
- ...u
116
- }, g) => {
117
- const { open: l, disabled: b, value: v } = k(), m = t.useId(), c = !v, f = r || u["aria-invalid"] === !0 || u["aria-invalid"] === "true";
118
- return /* @__PURE__ */ a($, { asChild: !0, children: /* @__PURE__ */ R(
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: g,
122
- "aria-controls": l ? m : void 0,
123
- "aria-expanded": l,
121
+ ref: h,
122
+ "aria-controls": v ? C : void 0,
123
+ "aria-expanded": v,
124
124
  "aria-haspopup": "listbox",
125
- "aria-invalid": f ? "true" : void 0,
126
- className: C(
127
- J({ variant: e }),
128
- f && "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
- o
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": c,
132
+ "data-placeholder": s,
133
133
  "data-slot": "combobox-trigger",
134
- "data-state": l ? "open" : "closed",
135
- "data-tracking-el": s || "combobox-trigger",
134
+ "data-state": v ? "open" : "closed",
135
+ "data-tracking-el": i || "combobox-trigger",
136
136
  "data-tracking-label": d,
137
- disabled: b || u.disabled,
137
+ disabled: f || b.disabled,
138
138
  role: "combobox",
139
139
  type: "button",
140
- ...u,
140
+ ...b,
141
141
  children: [
142
- i,
142
+ u,
143
143
  /* @__PURE__ */ a(
144
- F,
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 co({ placeholder: o, className: e }) {
157
- const { value: n, itemLabels: r } = k(), s = n ? r.get(n) || n : o;
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: C(
161
+ className: y(
162
162
  "text-foreground overflow-hidden text-sm leading-normal font-medium text-ellipsis whitespace-nowrap",
163
- e
163
+ o
164
164
  ),
165
165
  "data-slot": "combobox-value",
166
- children: s
166
+ children: i
167
167
  }
168
168
  );
169
169
  }
170
- function bo({
171
- dataHook: o,
172
- className: e,
170
+ function le({
171
+ dataHook: e,
172
+ className: o,
173
173
  children: n,
174
174
  align: r = "start",
175
- side: s = "bottom",
175
+ side: i = "bottom",
176
176
  sideOffset: d,
177
- avoidCollisions: i,
178
- hideList: u = !1
177
+ avoidCollisions: u,
178
+ hideList: b = !1
179
179
  }) {
180
- const { shouldFilter: g, itemToStringValue: l } = k(), b = t.useMemo(() => {
181
- if (l)
182
- return (v, m, c) => O(l(v), m, c);
183
- }, [l]);
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: i,
190
- className: C("w-[var(--radix-popover-trigger-width)] p-0", e),
216
+ avoidCollisions: u,
217
+ className: y("w-[var(--radix-popover-trigger-width)] p-0", o),
191
218
  "data-slot": "combobox-popover",
192
- side: s,
219
+ side: w ?? i,
193
220
  sideOffset: d,
194
221
  children: /* @__PURE__ */ a(
195
- z,
222
+ $,
196
223
  {
197
- className: C(
224
+ className: y(
198
225
  "border-0 shadow-none",
199
- u && "[&_[data-slot='command-input-wrapper']]:border-b-0"
226
+ b && "[&_[data-slot='command-input-wrapper']]:border-b-0"
200
227
  ),
201
228
  "data-slot": "combobox-command",
202
- dataHook: o || "combobox-command",
203
- filter: b,
204
- shouldFilter: g,
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((o, e) => /* @__PURE__ */ a(V, { ref: e, "data-slot": "combobox-input", ...o }));
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((o, e) => /* @__PURE__ */ a(A, { ref: e, "data-slot": "combobox-list", ...o }));
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((o, e) => /* @__PURE__ */ a(D, { ref: e, "data-slot": "combobox-empty", ...o }));
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((o, e) => /* @__PURE__ */ a(H, { ref: e, "data-slot": "combobox-group", ...o }));
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(o, e, n) {
220
- if (!e || !e.trim())
221
- return o;
246
+ function Z(e, o, n) {
247
+ if (!o || !o.trim())
248
+ return e;
222
249
  const r = new RegExp(
223
- `(${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
250
+ `(${o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
224
251
  "gi"
225
- ), s = o.split(r);
226
- return /* @__PURE__ */ a("span", { children: s.map(
227
- (d, i) => i % 2 === 1 ? /* @__PURE__ */ a("span", { className: n, children: d }, i) : /* @__PURE__ */ a(t.Fragment, { children: d }, i)
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 oo = t.forwardRef(
257
+ const ee = t.forwardRef(
231
258
  ({
232
- value: o,
233
- label: e,
259
+ value: e,
260
+ label: o,
234
261
  dataHook: n,
235
262
  children: r,
236
- className: s,
263
+ className: i,
237
264
  highlight: d,
238
- highlightClassName: i,
239
- keywords: u,
240
- ...g
241
- }, l) => {
242
- const { value: b, onValueChange: v, setOpen: m, registerItem: c } = k(), f = b === o, p = t.useMemo(() => e || (typeof r == "string" ? r : typeof r == "number" ? String(r) : o), [e, r, o]), h = t.useRef(c);
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
- h.current = c;
245
- }, [c]), t.useEffect(() => {
246
- h.current(o, p);
247
- }, [o, p]);
248
- const w = () => {
249
- v(o === b ? "" : o), m(!1);
250
- }, y = () => d && typeof r == "string" ? Z(
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
- i || "text-sm leading-normal font-semibold"
280
+ u || "text-sm leading-normal font-semibold"
254
281
  ) : r;
255
- return /* @__PURE__ */ R(
256
- q,
282
+ return /* @__PURE__ */ E(
283
+ H,
257
284
  {
258
- ref: l,
259
- className: C("justify-between", s),
285
+ ref: v,
286
+ className: y("justify-between", i),
260
287
  "data-slot": "combobox-item",
261
288
  dataHook: n,
262
- keywords: u ? [p, ...u] : [p],
263
- value: o,
264
- onSelect: w,
265
- ...g,
289
+ keywords: b ? [x, ...b] : [x],
290
+ value: e,
291
+ onSelect: m,
292
+ ...h,
266
293
  children: [
267
- y(),
268
- f && /* @__PURE__ */ a(
269
- P,
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
- oo.displayName = "ComboboxItem";
281
- const eo = t.forwardRef((o, e) => /* @__PURE__ */ a(B, { ref: e, "data-slot": "combobox-separator", ...o }));
282
- eo.displayName = "ComboboxSeparator";
283
- function mo({ className: o, children: e }) {
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: C(
316
+ className: y(
290
317
  "text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",
291
- o
318
+ e
292
319
  ),
293
320
  "data-slot": "combobox-loading",
294
321
  role: "option",
295
- children: e || /* @__PURE__ */ R(M, { 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
- lo as Combobox,
310
- bo as ComboboxContent,
336
+ ue as Combobox,
337
+ le as ComboboxContent,
311
338
  X as ComboboxEmpty,
312
339
  Y as ComboboxGroup,
313
340
  Q as ComboboxInput,
314
- oo as ComboboxItem,
341
+ ee as ComboboxItem,
315
342
  W as ComboboxList,
316
- mo as ComboboxLoading,
317
- eo as ComboboxSeparator,
343
+ be as ComboboxLoading,
344
+ oe as ComboboxSeparator,
318
345
  K as ComboboxTrigger,
319
- co as ComboboxValue
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"),l=require("@brightlocal/icons"),d=require("class-variance-authority"),u=require("sonner"),b=require("@brightlocal/ui-components/button"),a=require("@brightlocal/ui-components/lib/utils"),g=4e3,v=d.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=d.cva("text-sm leading-normal font-medium",{variants:{colorSchema:{default:"text-foreground",success:"text-green-900 dark:text-green-100"}},defaultVariants:{colorSchema:"default"}}),N=d.cva("text-sm leading-normal",{variants:{colorSchema:{default:"text-muted-foreground",success:"text-green-900 dark:text-green-100"}},defaultVariants:{colorSchema:"default"}}),i=d.cva("",{variants:{colorSchema:{default:"text-foreground",success:"text-green-900 dark:text-green-100"}},defaultVariants:{colorSchema:"default"}});function j(n,e){switch(n){case"info":return t.jsx(l.Info,{className:a.cn(i({colorSchema:e}))});case"success":return t.jsx(l.CheckCircle2,{className:a.cn(i({colorSchema:e}))});case"warning":return t.jsx(l.AlertTriangle,{className:a.cn(i({colorSchema:e}))});case"error":return t.jsx(l.XCircle,{className:a.cn(i({colorSchema:e}))});case"loading":return t.jsx(l.Loader2,{className:a.cn(i({colorSchema:e}),"animate-spin")});default:return null}}const h=function(e,r){const{id:s,...o}=e,m={...r,duration:r?.duration??g,...s!=null&&{id:r?.id??s}};u.toast.custom(f=>{const c=o.button&&o.button.label?{label:o.button.label,variant:o.button.variant,onClick:()=>{o.button?.onClick&&o.button.onClick(),u.toast.dismiss(f)}}:void 0;return t.jsx(T,{button:c,colorSchema:o.colorSchema,description:o.description,icon:o.icon??void 0,id:f,title:o.title})},m)};h.dismiss=n=>{u.toast.dismiss(n)};function T(n){const{button:e,description:r,icon:s,title:o,colorSchema:m}=n,c=(S=>S==="success"?"success":"default")(m);return t.jsxs("div",{"aria-atomic":"true","aria-live":"polite",className:a.cn(v({colorSchema:c})),role:"status",children:[t.jsxs("div",{className:"flex flex-1 items-start gap-2",children:[s!=null&&j(s,c),t.jsxs("div",{className:"w-full",children:[t.jsx("p",{className:a.cn(p({colorSchema:c})),children:o}),r&&t.jsx("p",{className:a.cn(N({colorSchema:c})),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 x(){return t.jsx(u.Toaster,{position:"top-right"})}x.displayName="Sonner";exports.Sonner=x;exports.sonner=h;
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` to keep the toast visible until the user closes it or you call `sonner.dismiss(id)`. @default 4000 */
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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sonner.d.ts","sourceRoot":"","sources":["../../src/components/sonner.tsx"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,KAAK,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