@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/sonner.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsx as o, jsxs as u } from "react/jsx-runtime";
2
- import { Loader2 as S, XCircle as p, AlertTriangle as g, CheckCircle2 as b, Info as v } from "@brightlocal/icons";
3
- import { cva as i } from "class-variance-authority";
2
+ import { Loader2 as S, XCircle as p, AlertTriangle as b, CheckCircle2 as g, Info as v } from "@brightlocal/icons";
3
+ import { cva as d } from "class-variance-authority";
4
4
  import { Toaster as x, toast as f } from "sonner";
5
5
  import { Button as N } from "@brightlocal/ui-components/button";
6
6
  import { cn as a } from "@brightlocal/ui-components/lib/utils";
7
- const T = 4e3, I = i(
7
+ const I = 4e3, T = d(
8
8
  [
9
9
  "flex",
10
10
  "items-center",
@@ -30,7 +30,7 @@ const T = 4e3, I = i(
30
30
  colorSchema: "default"
31
31
  }
32
32
  }
33
- ), k = i("text-sm leading-normal font-medium", {
33
+ ), k = d("text-sm leading-normal font-medium", {
34
34
  variants: {
35
35
  colorSchema: {
36
36
  default: "text-foreground",
@@ -40,7 +40,7 @@ const T = 4e3, I = i(
40
40
  defaultVariants: {
41
41
  colorSchema: "default"
42
42
  }
43
- }), A = i("text-sm leading-normal", {
43
+ }), A = d("text-sm leading-normal", {
44
44
  variants: {
45
45
  colorSchema: {
46
46
  default: "text-muted-foreground",
@@ -50,7 +50,7 @@ const T = 4e3, I = i(
50
50
  defaultVariants: {
51
51
  colorSchema: "default"
52
52
  }
53
- }), l = i("", {
53
+ }), i = d("", {
54
54
  variants: {
55
55
  colorSchema: {
56
56
  default: "text-foreground",
@@ -61,72 +61,78 @@ const T = 4e3, I = i(
61
61
  colorSchema: "default"
62
62
  }
63
63
  });
64
- function C(r, e) {
65
- switch (r) {
64
+ function C(n, e) {
65
+ switch (n) {
66
66
  case "info":
67
- return /* @__PURE__ */ o(v, { className: a(l({ colorSchema: e })) });
67
+ return /* @__PURE__ */ o(v, { className: a(i({ colorSchema: e })) });
68
68
  case "success":
69
- return /* @__PURE__ */ o(b, { className: a(l({ colorSchema: e })) });
69
+ return /* @__PURE__ */ o(g, { className: a(i({ colorSchema: e })) });
70
70
  case "warning":
71
- return /* @__PURE__ */ o(g, { className: a(l({ colorSchema: e })) });
71
+ return /* @__PURE__ */ o(b, { className: a(i({ colorSchema: e })) });
72
72
  case "error":
73
- return /* @__PURE__ */ o(p, { className: a(l({ colorSchema: e })) });
73
+ return /* @__PURE__ */ o(p, { className: a(i({ colorSchema: e })) });
74
74
  case "loading":
75
75
  return /* @__PURE__ */ o(
76
76
  S,
77
77
  {
78
- className: a(l({ colorSchema: e }), "animate-spin")
78
+ className: a(i({ colorSchema: e }), "animate-spin")
79
79
  }
80
80
  );
81
81
  default:
82
82
  return null;
83
83
  }
84
84
  }
85
- const w = function(e, n) {
86
- const { id: c, ...t } = e, d = {
87
- ...n,
88
- duration: n?.duration ?? T,
89
- ...c != null && { id: n?.id ?? c }
90
- };
91
- f.custom((m) => {
92
- const s = t.button && t.button.label ? {
93
- label: t.button.label,
94
- variant: t.button.variant,
95
- onClick: () => {
96
- t.button?.onClick && t.button.onClick(), f.dismiss(m);
97
- }
98
- } : void 0;
99
- return /* @__PURE__ */ o(
100
- V,
101
- {
102
- button: s,
103
- colorSchema: t.colorSchema,
104
- description: t.description,
105
- icon: t.icon ?? void 0,
106
- id: m,
107
- title: t.title
108
- }
109
- );
110
- }, d);
85
+ const w = function(e, s) {
86
+ const { id: c, ...t } = e, l = {
87
+ ...s,
88
+ duration: s?.duration ?? I,
89
+ ...c != null && { id: s?.id ?? c }
90
+ }, h = l.duration === 1 / 0;
91
+ f.custom(
92
+ (r) => {
93
+ const m = t.button && t.button.label ? {
94
+ label: t.button.label,
95
+ variant: t.button.variant,
96
+ onClick: () => {
97
+ t.button?.onClick && t.button.onClick(), f.dismiss(r);
98
+ }
99
+ } : void 0;
100
+ return /* @__PURE__ */ o(
101
+ V,
102
+ {
103
+ button: m,
104
+ colorSchema: t.colorSchema,
105
+ description: t.description,
106
+ icon: t.icon ?? void 0,
107
+ id: r,
108
+ title: t.title
109
+ }
110
+ );
111
+ },
112
+ {
113
+ ...l,
114
+ ...h && { dismissible: !1 }
115
+ }
116
+ );
111
117
  };
112
- w.dismiss = (r) => {
113
- f.dismiss(r);
118
+ w.dismiss = (n) => {
119
+ f.dismiss(n);
114
120
  };
115
- function V(r) {
116
- const { button: e, description: n, icon: c, title: t, colorSchema: d } = r, s = ((h) => h === "success" ? "success" : "default")(d);
121
+ function V(n) {
122
+ const { button: e, description: s, icon: c, title: t, colorSchema: l } = n, r = ((m) => m === "success" ? "success" : "default")(l);
117
123
  return /* @__PURE__ */ u(
118
124
  "div",
119
125
  {
120
126
  "aria-atomic": "true",
121
127
  "aria-live": "polite",
122
- className: a(I({ colorSchema: s })),
128
+ className: a(T({ colorSchema: r })),
123
129
  role: "status",
124
130
  children: [
125
131
  /* @__PURE__ */ u("div", { className: "flex flex-1 items-start gap-2", children: [
126
- c != null && C(c, s),
132
+ c != null && C(c, r),
127
133
  /* @__PURE__ */ u("div", { className: "w-full", children: [
128
- /* @__PURE__ */ o("p", { className: a(k({ colorSchema: s })), children: t }),
129
- n && /* @__PURE__ */ o("p", { className: a(A({ colorSchema: s })), children: n })
134
+ /* @__PURE__ */ o("p", { className: a(k({ colorSchema: r })), children: t }),
135
+ s && /* @__PURE__ */ o("p", { className: a(A({ colorSchema: r })), children: s })
130
136
  ] })
131
137
  ] }),
132
138
  e?.label && /* @__PURE__ */ o(
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),N=require("react"),c=require("@brightlocal/ui-components/lib/utils");function R(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const l=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(a,e,l.get?l:{enumerable:!0,get:()=>t[e]})}}return a.default=t,Object.freeze(a)}const n=R(N),m=n.createContext(!1),j=n.forwardRef(({className:t,dataHook:a,trackingEl:e,trackingLabel:l,left:r,right:u,children:L,...C},S)=>{const d=[],f=[],p=[],g=o=>{if(n.isValidElement(o)){if(o.type===n.Fragment){n.Children.forEach(o.props.children,g);return}o.type===y?d.push(o):o.type===i?p.push(o):f.push(o)}};n.Children.forEach(L,g);const b=r!=null||u!=null,v=f.length>0||p.length>0,x=b&&!v,w=d.length>0;return s.jsxs("div",{ref:S,className:c.cn("flex min-h-screen w-full flex-col lg:flex-row",t),"data-hook":a,"data-slot":"split-layout","data-tracking-el":e||"split-layout","data-tracking-label":l,...C,children:[s.jsx("div",{className:"bg-background flex flex-1 flex-col","data-slot":"split-layout-body",children:s.jsxs(m.Provider,{value:w,children:[d,x?r&&s.jsx(h,{children:r}):f]})}),x?u&&s.jsx(i,{children:u}):p]})});j.displayName="SplitLayout";const y=n.forwardRef(({className:t,children:a,...e},l)=>s.jsx("div",{ref:l,className:c.cn("px-section pt-section flex w-full items-center justify-center lg:justify-start",t),"data-slot":"split-layout-header",...e,children:a}));y.displayName="SplitLayoutHeader";const h=n.forwardRef(({className:t,children:a,...e},l)=>{const r=n.useContext(m);return s.jsx("div",{ref:l,className:c.cn("p-section flex flex-1 items-center justify-center overflow-auto",r&&"pt-2",t),"data-slot":"split-layout-left",...e,children:a})});h.displayName="SplitLayoutContentLeft";const i=n.forwardRef(({className:t,children:a,...e},l)=>s.jsx("div",{ref:l,className:c.cn("bg-card p-section hidden flex-1 items-center justify-center overflow-auto lg:flex",t),"data-slot":"split-layout-right",...e,children:a}));i.displayName="SplitLayoutContentRight";exports.SplitLayout=j;exports.SplitLayoutContentLeft=h;exports.SplitLayoutContentRight=i;exports.SplitLayoutHeader=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),N=require("react"),c=require("@brightlocal/ui-components/lib/utils");function R(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const l=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(a,e,l.get?l:{enumerable:!0,get:()=>t[e]})}}return a.default=t,Object.freeze(a)}const n=R(N),x=n.createContext(!1),j=n.forwardRef(({className:t,dataHook:a,trackingEl:e,trackingLabel:l,left:r,right:u,children:L,...C},S)=>{const d=[],f=[],p=[],m=o=>{if(n.isValidElement(o)){if(o.type===n.Fragment){n.Children.forEach(o.props.children,m);return}o.type===y?d.push(o):o.type===i?p.push(o):f.push(o)}};n.Children.forEach(L,m);const b=r!=null||u!=null,v=f.length>0||p.length>0,g=b&&!v,w=d.length>0;return s.jsxs("div",{ref:S,className:c.cn("flex min-h-screen w-full flex-col lg:flex-row",t),"data-hook":a,"data-slot":"split-layout","data-tracking-el":e||"split-layout","data-tracking-label":l,...C,children:[s.jsx("div",{className:"bg-background flex flex-1 flex-col","data-slot":"split-layout-body",children:s.jsxs(x.Provider,{value:w,children:[d,g?r&&s.jsx(h,{children:r}):f]})}),g?u&&s.jsx(i,{children:u}):p]})});j.displayName="SplitLayout";const y=n.forwardRef(({className:t,children:a,...e},l)=>s.jsx("div",{ref:l,className:c.cn("px-section-sm pt-section-sm flex w-full items-center justify-center lg:justify-start",t),"data-slot":"split-layout-header",...e,children:a}));y.displayName="SplitLayoutHeader";const h=n.forwardRef(({className:t,children:a,...e},l)=>{const r=n.useContext(x);return s.jsx("div",{ref:l,className:c.cn("p-section-sm flex flex-1 items-center justify-center overflow-auto",r&&"pt-2",t),"data-slot":"split-layout-left",...e,children:a})});h.displayName="SplitLayoutContentLeft";const i=n.forwardRef(({className:t,children:a,...e},l)=>s.jsx("div",{ref:l,className:c.cn("bg-card p-section-sm hidden flex-1 items-center justify-center overflow-auto lg:flex",t),"data-slot":"split-layout-right",...e,children:a}));i.displayName="SplitLayoutContentRight";exports.SplitLayout=j;exports.SplitLayoutContentLeft=h;exports.SplitLayoutContentRight=i;exports.SplitLayoutHeader=y;
@@ -1,4 +1,4 @@
1
- import { jsxs as m, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as h, jsx as n } from "react/jsx-runtime";
2
2
  import * as t from "react";
3
3
  import { cn as i } from "@brightlocal/ui-components/lib/utils";
4
4
  const x = t.createContext(!1), j = t.forwardRef(
@@ -25,8 +25,8 @@ const x = t.createContext(!1), j = t.forwardRef(
25
25
  }
26
26
  };
27
27
  t.Children.forEach(L, y);
28
- const N = r != null || c != null, S = f.length > 0 || p.length > 0, h = N && !S, R = d.length > 0;
29
- return /* @__PURE__ */ m(
28
+ const N = r != null || c != null, S = f.length > 0 || p.length > 0, m = N && !S, R = d.length > 0;
29
+ return /* @__PURE__ */ h(
30
30
  "div",
31
31
  {
32
32
  ref: w,
@@ -45,13 +45,13 @@ const x = t.createContext(!1), j = t.forwardRef(
45
45
  {
46
46
  className: "bg-background flex flex-1 flex-col",
47
47
  "data-slot": "split-layout-body",
48
- children: /* @__PURE__ */ m(x.Provider, { value: R, children: [
48
+ children: /* @__PURE__ */ h(x.Provider, { value: R, children: [
49
49
  d,
50
- h ? r && /* @__PURE__ */ n(C, { children: r }) : f
50
+ m ? r && /* @__PURE__ */ n(C, { children: r }) : f
51
51
  ] })
52
52
  }
53
53
  ),
54
- h ? c && /* @__PURE__ */ n(u, { children: c }) : p
54
+ m ? c && /* @__PURE__ */ n(u, { children: c }) : p
55
55
  ]
56
56
  }
57
57
  );
@@ -63,7 +63,7 @@ const g = t.forwardRef(({ className: a, children: l, ...o }, s) => /* @__PURE__
63
63
  {
64
64
  ref: s,
65
65
  className: i(
66
- "px-section pt-section flex w-full items-center justify-center lg:justify-start",
66
+ "px-section-sm pt-section-sm flex w-full items-center justify-center lg:justify-start",
67
67
  a
68
68
  ),
69
69
  "data-slot": "split-layout-header",
@@ -79,7 +79,7 @@ const C = t.forwardRef(({ className: a, children: l, ...o }, s) => {
79
79
  {
80
80
  ref: s,
81
81
  className: i(
82
- "p-section flex flex-1 items-center justify-center overflow-auto",
82
+ "p-section-sm flex flex-1 items-center justify-center overflow-auto",
83
83
  r && "pt-2",
84
84
  a
85
85
  ),
@@ -95,7 +95,7 @@ const u = t.forwardRef(({ className: a, children: l, ...o }, s) => /* @__PURE__
95
95
  {
96
96
  ref: s,
97
97
  className: i(
98
- "bg-card p-section hidden flex-1 items-center justify-center overflow-auto lg:flex",
98
+ "bg-card p-section-sm hidden flex-1 items-center justify-center overflow-auto lg:flex",
99
99
  a
100
100
  ),
101
101
  "data-slot": "split-layout-right",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightlocal/ui-components",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "BrightLocal Design System UI Components",
5
5
  "type": "module",
6
6
  "private": false,
@@ -19,7 +19,7 @@ const cardVariants = cva(
19
19
  "flex-col",
20
20
  "gap-8",
21
21
  "rounded-xl",
22
- "py-8",
22
+ "py-section-md",
23
23
  "transition-colors",
24
24
  "w-full",
25
25
  ],
@@ -150,7 +150,7 @@ const CardHeader = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
150
150
  ref={ref}
151
151
  className={cn(
152
152
  "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
153
- !flush && "px-8",
153
+ !flush && "px-section-md",
154
154
  className
155
155
  )}
156
156
  data-slot="card-header"
@@ -221,7 +221,7 @@ const CardContent = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
221
221
  return (
222
222
  <div
223
223
  ref={ref}
224
- className={cn(!flush && "px-8", className)}
224
+ className={cn(!flush && "px-section-md", className)}
225
225
  data-slot="card-content"
226
226
  {...props}
227
227
  />
@@ -239,7 +239,11 @@ const CardFooter = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
239
239
  return (
240
240
  <div
241
241
  ref={ref}
242
- className={cn("flex items-center", !flush && "px-8", className)}
242
+ className={cn(
243
+ "flex items-center",
244
+ !flush && "px-section-md",
245
+ className
246
+ )}
243
247
  data-slot="card-footer"
244
248
  {...props}
245
249
  />
@@ -10,7 +10,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
10
10
  * CentredLayout provides a full-page centered container.
11
11
  *
12
12
  * Spacing tokens used:
13
- * - Padding: section-padding-x/y tokens (responsive: 16px mobile, 24px desktop)
13
+ * - Padding: p-section-sm utility (16px mobile/tablet, 24px desktop)
14
14
  * - Header to content gap: gap-4 (spacing.4 = 16px)
15
15
  *
16
16
  * The component takes full page width/height and centers content horizontally and vertically.
@@ -63,7 +63,7 @@ const CentredLayout = React.forwardRef<HTMLDivElement, CentredLayoutProps>(
63
63
  ref={ref}
64
64
  className={cn(
65
65
  // Base styles with section-padding tokens (responsive: 16px mobile, 24px desktop) and gap-4 for header/content spacing
66
- "bg-background p-section flex min-h-screen w-full flex-col items-center justify-center gap-4",
66
+ "bg-background p-section-sm flex min-h-screen w-full flex-col items-center justify-center gap-4",
67
67
  className
68
68
  )}
69
69
  data-hook={dataHook}
@@ -330,8 +330,8 @@ export interface ComboboxContentProps {
330
330
  children: React.ReactNode;
331
331
  /** Alignment of the popover relative to trigger */
332
332
  align?: "start" | "center" | "end";
333
- /** Which side of the trigger to render the popover. @default "bottom" */
334
- side?: "top" | "right" | "bottom" | "left";
333
+ /** Which side of the trigger to render the popover. Only vertical positioning is supported — the dropdown spans the full trigger width. @default "bottom" */
334
+ side?: "top" | "bottom";
335
335
  /** Distance in px between the trigger and the popover. @default 4 */
336
336
  sideOffset?: number;
337
337
  /**
@@ -358,7 +358,99 @@ function ComboboxContent({
358
358
  avoidCollisions,
359
359
  hideList = false,
360
360
  }: ComboboxContentProps) {
361
- const { shouldFilter, itemToStringValue } = useComboboxContext();
361
+ const { open, shouldFilter, itemToStringValue } = useComboboxContext();
362
+
363
+ // TODO: This is a workaround for floating-ui re-flipping on content resize.
364
+ // The root cause is that Radix Popper's autoUpdate watches elementResize and
365
+ // re-runs the full middleware pipeline (including flip) every time the list
366
+ // shrinks during filtering. Ideally this would be solved at a lower level:
367
+ //
368
+ // 1. Radix exposes `updatePositionStrategy` but not fine-grained autoUpdate
369
+ // options (e.g. disabling `elementResize` or `layoutShift` listeners).
370
+ // If Radix adds this, we can disable elementResize and remove this hack.
371
+ // Track: https://github.com/radix-ui/primitives/issues
372
+ //
373
+ // 2. Build a base-ui / headless Combobox with floating-ui directly, where
374
+ // we control the autoUpdate config and middleware pipeline. This would
375
+ // let us disable flip after initial placement or use a custom middleware
376
+ // that only flips on scroll/viewport changes, not content resize.
377
+ //
378
+ // 3. Use Radix's `updatePositionStrategy="optimized"` — but this only
379
+ // throttles updates, it doesn't prevent flip on resize specifically.
380
+ //
381
+ // Current workaround: lock the resolved `data-side` after initial open via
382
+ // MutationObserver + double-rAF, then force that side on subsequent renders.
383
+ // Works but adds complexity. Remove when a proper upstream fix is available.
384
+ //
385
+ // Lock the resolved side after initial open so that content resizes
386
+ // (e.g. filtering the list) don't cause the dropdown to flip.
387
+ // Scroll repositioning and shift still work because avoidCollisions
388
+ // stays enabled — only the preferred `side` is locked.
389
+ const [lockedSide, setLockedSide] = React.useState<"top" | "bottom" | null>(
390
+ null
391
+ );
392
+ const cleanupRef = React.useRef<(() => void) | null>(null);
393
+
394
+ // When the popover content mounts, detect the resolved side via two
395
+ // complementary strategies and lock it:
396
+ // 1. MutationObserver — catches the flip (data-side changes from the
397
+ // initial preferred side to the resolved side after computePosition).
398
+ // 2. Double rAF fallback — if no flip occurs, data-side never changes,
399
+ // so we read it after two animation frames when positioning is done.
400
+ // Note: safe under React StrictMode — the triple ref-callback invocation
401
+ // (node → null → node) is handled by the cleanup/done guard pattern.
402
+ const handleContentRef = React.useCallback((node: HTMLDivElement | null) => {
403
+ // Cleanup previous observer/timers
404
+ cleanupRef.current?.();
405
+ cleanupRef.current = null;
406
+
407
+ if (!node) return;
408
+
409
+ let done = false;
410
+ const lock = (attr: string | null) => {
411
+ if (done) return;
412
+ if (attr === "top" || attr === "bottom") {
413
+ done = true;
414
+ observer.disconnect();
415
+ setLockedSide(attr);
416
+ }
417
+ };
418
+
419
+ // Strategy 1: observe data-side attribute mutations (catches flip)
420
+ const observer = new MutationObserver(() => {
421
+ lock(node.getAttribute("data-side"));
422
+ });
423
+ observer.observe(node, {
424
+ attributes: true,
425
+ attributeFilter: ["data-side"],
426
+ });
427
+
428
+ // Strategy 2: double rAF fallback (catches no-flip case where
429
+ // data-side is set during initial render and never changes)
430
+ let rafOuter = 0;
431
+ let rafInner = 0;
432
+ rafOuter = requestAnimationFrame(() => {
433
+ rafInner = requestAnimationFrame(() => {
434
+ lock(node.getAttribute("data-side"));
435
+ });
436
+ });
437
+
438
+ cleanupRef.current = () => {
439
+ done = true;
440
+ observer.disconnect();
441
+ cancelAnimationFrame(rafOuter);
442
+ cancelAnimationFrame(rafInner);
443
+ };
444
+ }, []);
445
+
446
+ // Reset locked side when popover closes
447
+ React.useEffect(() => {
448
+ if (!open) {
449
+ cleanupRef.current?.();
450
+ cleanupRef.current = null;
451
+ setLockedSide(null);
452
+ }
453
+ }, [open]);
362
454
 
363
455
  const filter = React.useMemo(() => {
364
456
  if (!itemToStringValue) return undefined;
@@ -368,12 +460,13 @@ function ComboboxContent({
368
460
 
369
461
  return (
370
462
  <PopoverContent
463
+ ref={handleContentRef}
371
464
  align={align}
372
465
  aria-label="Options"
373
466
  avoidCollisions={avoidCollisions}
374
467
  className={cn("w-[var(--radix-popover-trigger-width)] p-0", className)}
375
468
  data-slot="combobox-popover"
376
- side={side}
469
+ side={lockedSide ?? side}
377
470
  sideOffset={sideOffset}
378
471
  >
379
472
  <Command
@@ -61,7 +61,7 @@ export type SonnerColorSchema = "default" | "success";
61
61
  type SonnerCustomOptions = {
62
62
  className?: string;
63
63
  id?: string | number;
64
- /** 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 */
64
+ /** 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 */
65
65
  duration?: number;
66
66
  };
67
67
 
@@ -188,33 +188,42 @@ const sonner: SonnerFn = function sonner(
188
188
  ...(providedId != null && { id: options?.id ?? providedId }),
189
189
  };
190
190
 
191
- sonnerToast.custom((id) => {
192
- // Wrap button onClick to include dismiss logic
193
- const buttonWithDismiss =
194
- rest.button && rest.button.label
195
- ? {
196
- label: rest.button.label,
197
- variant: rest.button.variant,
198
- onClick: () => {
199
- if (rest.button?.onClick) {
200
- rest.button.onClick();
201
- }
202
- sonnerToast.dismiss(id);
203
- },
204
- }
205
- : undefined;
191
+ // Persistent toasts (duration: Infinity) should not be swipeable
192
+ const isPersistent = mergedOptions.duration === Infinity;
206
193
 
207
- return (
208
- <Toast
209
- button={buttonWithDismiss}
210
- colorSchema={rest.colorSchema}
211
- description={rest.description}
212
- icon={rest.icon ?? undefined}
213
- id={id}
214
- title={rest.title}
215
- />
216
- );
217
- }, mergedOptions);
194
+ sonnerToast.custom(
195
+ (id) => {
196
+ // Wrap button onClick to include dismiss logic
197
+ const buttonWithDismiss =
198
+ rest.button && rest.button.label
199
+ ? {
200
+ label: rest.button.label,
201
+ variant: rest.button.variant,
202
+ onClick: () => {
203
+ if (rest.button?.onClick) {
204
+ rest.button.onClick();
205
+ }
206
+ sonnerToast.dismiss(id);
207
+ },
208
+ }
209
+ : undefined;
210
+
211
+ return (
212
+ <Toast
213
+ button={buttonWithDismiss}
214
+ colorSchema={rest.colorSchema}
215
+ description={rest.description}
216
+ icon={rest.icon ?? undefined}
217
+ id={id}
218
+ title={rest.title}
219
+ />
220
+ );
221
+ },
222
+ {
223
+ ...mergedOptions,
224
+ ...(isPersistent && { dismissible: false }),
225
+ }
226
+ );
218
227
  };
219
228
 
220
229
  sonner.dismiss = (id: string | number) => {
@@ -177,7 +177,7 @@ const SplitLayoutHeader = React.forwardRef<
177
177
  <div
178
178
  ref={ref}
179
179
  className={cn(
180
- "px-section pt-section flex w-full items-center justify-center lg:justify-start",
180
+ "px-section-sm pt-section-sm flex w-full items-center justify-center lg:justify-start",
181
181
  className
182
182
  )}
183
183
  data-slot="split-layout-header"
@@ -214,7 +214,7 @@ const SplitLayoutContentLeft = React.forwardRef<
214
214
  <div
215
215
  ref={ref}
216
216
  className={cn(
217
- "p-section flex flex-1 items-center justify-center overflow-auto",
217
+ "p-section-sm flex flex-1 items-center justify-center overflow-auto",
218
218
  hasHeader && "pt-2",
219
219
  className
220
220
  )}
@@ -250,7 +250,7 @@ const SplitLayoutContentRight = React.forwardRef<
250
250
  <div
251
251
  ref={ref}
252
252
  className={cn(
253
- "bg-card p-section hidden flex-1 items-center justify-center overflow-auto lg:flex",
253
+ "bg-card p-section-sm hidden flex-1 items-center justify-center overflow-auto lg:flex",
254
254
  className
255
255
  )}
256
256
  data-slot="split-layout-right"