@brightlocal/ui-components 2.20.0 → 2.21.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.
Files changed (45) hide show
  1. package/AI_USAGE.md +2 -0
  2. package/README.md +26 -13
  3. package/component-meta.json +20 -10
  4. package/dist/blocks/data-table.cjs +1 -1
  5. package/dist/blocks/data-table.d.ts.map +1 -1
  6. package/dist/blocks/data-table.js +14 -16
  7. package/dist/blocks/sidebar.cjs +1 -1
  8. package/dist/blocks/sidebar.d.ts +2 -2
  9. package/dist/blocks/sidebar.js +18 -18
  10. package/dist/breadcrumb.cjs +1 -1
  11. package/dist/breadcrumb.d.ts +1 -1
  12. package/dist/breadcrumb.d.ts.map +1 -1
  13. package/dist/breadcrumb.js +9 -6
  14. package/dist/button.cjs +1 -1
  15. package/dist/button.d.ts.map +1 -1
  16. package/dist/button.js +12 -12
  17. package/dist/logo.cjs +1 -1
  18. package/dist/logo.d.ts +1 -1
  19. package/dist/logo.js +2 -2
  20. package/dist/navigation-menu.cjs +1 -1
  21. package/dist/navigation-menu.d.ts +19 -0
  22. package/dist/navigation-menu.d.ts.map +1 -1
  23. package/dist/navigation-menu.js +134 -96
  24. package/dist/pagination.cjs +1 -1
  25. package/dist/pagination.d.ts +12 -8
  26. package/dist/pagination.d.ts.map +1 -1
  27. package/dist/pagination.js +117 -113
  28. package/dist/progress.cjs +1 -1
  29. package/dist/progress.d.ts +28 -2
  30. package/dist/progress.d.ts.map +1 -1
  31. package/dist/progress.js +90 -49
  32. package/dist/skeleton.cjs +1 -1
  33. package/dist/skeleton.js +1 -1
  34. package/dist/sonner.d.ts +1 -1
  35. package/package.json +7 -3
  36. package/src/blocks/data-table.tsx +0 -2
  37. package/src/blocks/sidebar.tsx +5 -5
  38. package/src/components/breadcrumb.tsx +6 -3
  39. package/src/components/button.tsx +7 -1
  40. package/src/components/logo.tsx +3 -3
  41. package/src/components/navigation-menu.tsx +134 -32
  42. package/src/components/pagination.tsx +47 -67
  43. package/src/components/progress.tsx +118 -14
  44. package/src/components/skeleton.tsx +1 -1
  45. package/src/components/sonner.tsx +1 -1
@@ -1,31 +1,36 @@
1
- import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
- import * as n from "react";
3
- import * as r from "@radix-ui/react-navigation-menu";
4
- import { ChevronDown as u } from "@brightlocal/icons";
5
- import { cn as i } from "@brightlocal/ui-components/lib/utils";
6
- const c = n.forwardRef(({ className: t, children: e, dataHook: a, ...s }, m) => /* @__PURE__ */ d(
7
- r.Root,
8
- {
9
- ref: m,
10
- className: i(
11
- "relative z-10 flex max-w-max flex-1 items-center justify-center",
12
- t
13
- ),
14
- "data-hook": a,
15
- "data-slot": "navigation-menu",
16
- ...s,
17
- children: [
18
- e,
19
- /* @__PURE__ */ o(l, {})
20
- ]
21
- }
1
+ import { jsxs as v, jsx as n } from "react/jsx-runtime";
2
+ import * as i from "react";
3
+ import * as s from "@radix-ui/react-navigation-menu";
4
+ import { ChevronDown as w } from "@brightlocal/icons";
5
+ import { cn as r } from "@brightlocal/ui-components/lib/utils";
6
+ const h = i.forwardRef(({ className: t, children: e, dataHook: o, delayDuration: u = 50, ...l }, d) => (
7
+ // Radix defaults delayDuration to 200ms, which reads as a laggy hover-open.
8
+ // Match Base UI's snappier 50ms default (still overridable via props).
9
+ /* @__PURE__ */ v(
10
+ s.Root,
11
+ {
12
+ ref: d,
13
+ className: r(
14
+ "relative z-10 flex max-w-max flex-1 items-center justify-center",
15
+ t
16
+ ),
17
+ "data-hook": o,
18
+ "data-slot": "navigation-menu",
19
+ delayDuration: u,
20
+ ...l,
21
+ children: [
22
+ e,
23
+ /* @__PURE__ */ n(p, {})
24
+ ]
25
+ }
26
+ )
22
27
  ));
23
- c.displayName = "NavigationMenu";
24
- const f = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
25
- r.List,
28
+ h.displayName = "NavigationMenu";
29
+ const x = i.forwardRef(({ className: t, ...e }, o) => /* @__PURE__ */ n(
30
+ s.List,
26
31
  {
27
- ref: a,
28
- className: i(
32
+ ref: o,
33
+ className: r(
29
34
  "group flex flex-1 list-none items-center justify-center gap-1",
30
35
  t
31
36
  ),
@@ -33,61 +38,88 @@ const f = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
33
38
  ...e
34
39
  }
35
40
  ));
36
- f.displayName = "NavigationMenuList";
37
- const g = n.forwardRef((t, e) => /* @__PURE__ */ o(
38
- r.Item,
41
+ x.displayName = "NavigationMenuList";
42
+ const y = i.forwardRef((t, e) => /* @__PURE__ */ n(
43
+ s.Item,
39
44
  {
40
45
  ref: e,
41
46
  "data-slot": "navigation-menu-item",
42
47
  ...t
43
48
  }
44
49
  ));
45
- g.displayName = "NavigationMenuItem";
46
- const v = n.forwardRef(({ className: t, children: e, ...a }, s) => /* @__PURE__ */ d(
47
- r.Trigger,
48
- {
49
- ref: s,
50
- className: i(
51
- [
52
- "group inline-flex h-9 w-max items-center justify-center gap-1",
53
- "rounded-md px-4 py-2",
54
- "text-sm font-medium",
55
- "text-foreground",
56
- "transition-colors",
57
- "hover:bg-accent hover:text-accent-foreground",
58
- "focus:bg-accent focus:text-accent-foreground",
59
- "focus-visible:bg-accent focus-visible:ring-ring focus-visible:shadow-[0_0_0_4px_rgba(163,163,163,0.1)] focus-visible:ring-1 focus-visible:outline-none",
60
- "disabled:pointer-events-none disabled:opacity-50",
61
- "data-[state=open]:bg-accent/50"
62
- ],
63
- t
64
- ),
65
- "data-slot": "navigation-menu-trigger",
66
- ...a,
67
- children: [
68
- e,
69
- /* @__PURE__ */ o(
70
- u,
71
- {
72
- "aria-hidden": "true",
73
- className: "relative top-[1px] ml-1 transition duration-300 group-data-[state=open]:rotate-180",
74
- size: 12
75
- }
76
- )
77
- ]
78
- }
79
- ));
80
- v.displayName = "NavigationMenuTrigger";
81
- const p = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
82
- r.Content,
50
+ y.displayName = "NavigationMenuItem";
51
+ const M = 500, R = i.forwardRef(({ className: t, children: e, onClick: o, onPointerDown: u, ...l }, d) => {
52
+ const m = i.useRef(""), f = i.useRef(-1 / 0), g = i.useRef(null), b = i.useCallback(
53
+ (a) => {
54
+ if (typeof d == "function" ? d(a) : d && (d.current = a), g.current?.disconnect(), a) {
55
+ const c = new MutationObserver(() => {
56
+ a.getAttribute("data-state") === "open" && (f.current = performance.now());
57
+ });
58
+ c.observe(a, {
59
+ attributes: !0,
60
+ attributeFilter: ["data-state"]
61
+ }), g.current = c;
62
+ }
63
+ },
64
+ [d]
65
+ );
66
+ return /* @__PURE__ */ v(
67
+ s.Trigger,
68
+ {
69
+ ref: b,
70
+ className: r(
71
+ [
72
+ "group inline-flex h-9 w-max items-center justify-center gap-1",
73
+ "rounded-md px-4 py-2",
74
+ "text-sm font-medium",
75
+ "text-foreground",
76
+ "transition-colors",
77
+ "hover:bg-accent hover:text-accent-foreground",
78
+ "focus:bg-accent focus:text-accent-foreground",
79
+ "focus-visible:bg-accent focus-visible:ring-ring focus-visible:shadow-[0_0_0_4px_rgba(163,163,163,0.1)] focus-visible:ring-1 focus-visible:outline-none",
80
+ "disabled:pointer-events-none disabled:opacity-50",
81
+ "data-[state=open]:bg-accent/50"
82
+ ],
83
+ t
84
+ ),
85
+ "data-slot": "navigation-menu-trigger",
86
+ onClick: (a) => {
87
+ const c = a.currentTarget.getAttribute("data-state") === "open", N = a.timeStamp - f.current < M;
88
+ m.current === "mouse" && a.detail > 0 && c && N && a.preventDefault(), o?.(a);
89
+ },
90
+ onPointerDown: (a) => {
91
+ m.current = a.pointerType, u?.(a);
92
+ },
93
+ ...l,
94
+ children: [
95
+ e,
96
+ /* @__PURE__ */ n(
97
+ w,
98
+ {
99
+ "aria-hidden": "true",
100
+ className: "relative top-[1px] ml-1 transition duration-300 group-data-[state=open]:rotate-180",
101
+ size: 12
102
+ }
103
+ )
104
+ ]
105
+ }
106
+ );
107
+ });
108
+ R.displayName = "NavigationMenuTrigger";
109
+ const _ = i.forwardRef(({ className: t, ...e }, o) => /* @__PURE__ */ n(
110
+ s.Content,
83
111
  {
84
- ref: a,
85
- className: i(
112
+ ref: o,
113
+ className: r(
86
114
  [
87
115
  "data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out top-0 left-0 w-full",
88
116
  "data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out",
89
117
  "data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52",
90
118
  "data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52",
119
+ // Match the viewport's easeOutQuint timing so the directional slide and
120
+ // the container morph feel like one motion (kept snappy so content
121
+ // appears without a perceptible fade-in delay).
122
+ "duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]",
91
123
  "md:absolute md:w-auto"
92
124
  ],
93
125
  t
@@ -97,12 +129,12 @@ const p = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
97
129
  ...e
98
130
  }
99
131
  ));
100
- p.displayName = "NavigationMenuContent";
101
- const N = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
102
- r.Link,
132
+ _.displayName = "NavigationMenuContent";
133
+ const I = i.forwardRef(({ className: t, ...e }, o) => /* @__PURE__ */ n(
134
+ s.Link,
103
135
  {
104
- ref: a,
105
- className: i(
136
+ ref: o,
137
+ className: r(
106
138
  [
107
139
  "block rounded-md p-3 leading-none no-underline select-none",
108
140
  "transition-colors outline-none",
@@ -116,17 +148,23 @@ const N = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
116
148
  ...e
117
149
  }
118
150
  ));
119
- N.displayName = "NavigationMenuLink";
120
- const l = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o("div", { className: i("absolute top-full left-0 z-50 flex justify-center"), children: /* @__PURE__ */ o(
121
- r.Viewport,
151
+ I.displayName = "NavigationMenuLink";
152
+ const p = i.forwardRef(({ className: t, ...e }, o) => /* @__PURE__ */ n("div", { className: r("absolute top-full left-0 z-50 flex justify-center"), children: /* @__PURE__ */ n(
153
+ s.Viewport,
122
154
  {
123
- ref: a,
124
- className: i(
155
+ ref: o,
156
+ className: r(
125
157
  [
126
158
  "origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)]",
127
159
  "bg-popover text-popover-foreground w-full overflow-hidden rounded-md border shadow-sm",
128
- "data-[state=open]:animate-in data-[state=closed]:animate-out",
129
- "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90",
160
+ // Base UI-style size morph: smoothly animate width/height between items
161
+ // with an easeOutQuint curve. The enter/exit stays snappy (200ms in,
162
+ // 150ms out) so the panel and its content appear immediately rather
163
+ // than fading in slowly. Reduced motion is neutralised globally by the
164
+ // token preset, so no per-element motion-reduce guard is needed.
165
+ "transition-[width,height] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]",
166
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
167
+ "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-150",
130
168
  "md:w-[var(--radix-navigation-menu-viewport-width)]"
131
169
  ],
132
170
  t
@@ -135,12 +173,12 @@ const l = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o("div", {
135
173
  ...e
136
174
  }
137
175
  ) }));
138
- l.displayName = "NavigationMenuViewport";
139
- const b = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
140
- r.Indicator,
176
+ p.displayName = "NavigationMenuViewport";
177
+ const k = i.forwardRef(({ className: t, ...e }, o) => /* @__PURE__ */ n(
178
+ s.Indicator,
141
179
  {
142
- ref: a,
143
- className: i(
180
+ ref: o,
181
+ className: r(
144
182
  [
145
183
  "top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden",
146
184
  "data-[state=visible]:animate-in data-[state=hidden]:animate-out",
@@ -150,17 +188,17 @@ const b = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
150
188
  ),
151
189
  "data-slot": "navigation-menu-indicator",
152
190
  ...e,
153
- children: /* @__PURE__ */ o("div", { className: "bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" })
191
+ children: /* @__PURE__ */ n("div", { className: "bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" })
154
192
  }
155
193
  ));
156
- b.displayName = "NavigationMenuIndicator";
194
+ k.displayName = "NavigationMenuIndicator";
157
195
  export {
158
- c as NavigationMenu,
159
- p as NavigationMenuContent,
160
- b as NavigationMenuIndicator,
161
- g as NavigationMenuItem,
162
- N as NavigationMenuLink,
163
- f as NavigationMenuList,
164
- v as NavigationMenuTrigger,
165
- l as NavigationMenuViewport
196
+ h as NavigationMenu,
197
+ _ as NavigationMenuContent,
198
+ k as NavigationMenuIndicator,
199
+ y as NavigationMenuItem,
200
+ I as NavigationMenuLink,
201
+ x as NavigationMenuList,
202
+ R as NavigationMenuTrigger,
203
+ p as NavigationMenuViewport
166
204
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),j=require("react"),d=require("@brightlocal/icons"),N=require("class-variance-authority"),f=require("@brightlocal/ui-components/lib/utils");function k(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>a[n]})}}return e.default=a,Object.freeze(e)}const l=k(j);function w({page:a,totalPages:e,siblingCount:n=1,boundaryCount:i=1}){return l.useMemo(()=>{const r=[];r.push("previous");const u=Math.max(a-n,i+1),p=Math.min(a+n,e-i),b=u>i+2,P=p<e-i-1;for(let t=1;t<=Math.min(i,e);t++)r.push(t);if(b)r.push("ellipsis");else if(i+1<u)for(let t=i+1;t<u;t++)r.push(t);for(let t=u;t<=p;t++)t>i&&t<=e-i&&r.push(t);if(P)r.push("ellipsis");else if(p<e-i)for(let t=p+1;t<e-i+1;t++)r.push(t);for(let t=Math.max(e-i+1,i+1);t<=e;t++)t>i&&r.push(t);return r.push("next"),r},[a,e,n,i])}const g=N.cva(["inline-flex items-center justify-center","h-9 w-9","rounded-full","text-sm font-medium","transition-colors","focus-visible:outline-none focus-visible:shadow-default"],{variants:{variant:{previous:["text-foreground","hover:bg-accent","aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none"],next:["text-foreground","hover:bg-accent","aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none"],link:["text-foreground","hover:bg-accent hover:text-accent-foreground","aria-[current=page]:bg-background aria-[current=page]:border aria-[current=page]:border-input","dark:aria-[current=page]:bg-input/30","aria-[current=page]:hover:bg-accent","aria-[current=page]:focus-visible:border-ring","aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none"],ellipsis:["cursor-default","text-foreground","pointer-events-none"]}},defaultVariants:{variant:"link"}});function h({className:a,dataHook:e,trackingEl:n,trackingLabel:i,ariaLabel:o,...r}){return s.jsx("nav",{"aria-label":o??"Pagination",className:f.cn("mx-auto flex w-full justify-center",a),"data-hook":e,"data-slot":"pagination","data-tracking-el":n||"pagination","data-tracking-label":i,role:"navigation",...r})}h.displayName="Pagination";function M({className:a,...e}){return s.jsx("ul",{className:f.cn("flex flex-row items-center gap-2",a),"data-slot":"pagination-content",...e})}function R(a){return s.jsx("li",{"data-slot":"pagination-item",...a})}const c=l.forwardRef(({className:a,variant:e,isActive:n,children:i,...o},r)=>s.jsx("button",{ref:r,"aria-current":n?"page":void 0,className:f.cn(g({variant:e}),a),"data-active":n,"data-slot":"pagination-button",type:"button",...o,children:i}));c.displayName="PaginationButton";const x=l.forwardRef(({className:a,disabled:e,ariaLabel:n,...i},o)=>s.jsx(c,{ref:o,"aria-disabled":e,"aria-label":n??"Go to previous page",className:a,disabled:e,variant:"previous",...i,children:s.jsx(d.ChevronLeft,{})}));x.displayName="PaginationPrevious";const v=l.forwardRef(({className:a,disabled:e,ariaLabel:n,...i},o)=>s.jsx(c,{ref:o,"aria-disabled":e,"aria-label":n??"Go to next page",className:a,disabled:e,variant:"next",...i,children:s.jsx(d.ChevronRight,{})}));v.displayName="PaginationNext";const m=l.forwardRef(({className:a,page:e,isActive:n,ariaLabel:i,...o},r)=>s.jsx(c,{ref:r,"aria-label":i?i.replace("{page}",String(e)):`Go to page ${e}`,className:a,isActive:n,variant:"link",...o,children:e}));m.displayName="PaginationLink";function S({className:a,srLabel:e="More pages",...n}){return s.jsxs("span",{"aria-hidden":"true",className:f.cn(g({variant:"ellipsis"}),a),"data-slot":"pagination-ellipsis",...n,children:[s.jsx(d.MoreHorizontal,{}),s.jsx("span",{className:"sr-only",children:e})]})}exports.Pagination=h;exports.PaginationButton=c;exports.PaginationContent=M;exports.PaginationEllipsis=S;exports.PaginationItem=R;exports.PaginationLink=m;exports.PaginationNext=v;exports.PaginationPrevious=x;exports.usePagination=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),j=require("react"),g=require("@brightlocal/icons"),y=require("class-variance-authority"),p=require("@brightlocal/ui-components/lib/utils"),k=require("@brightlocal/ui-components/hooks/use-breakpoint");function N(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(e,n,t.get?t:{enumerable:!0,get:()=>a[n]})}}return e.default=a,Object.freeze(e)}const c=N(j);function w({page:a,totalPages:e}){const t=k.useIsBelowBreakpoint("sm")?5:7;return c.useMemo(()=>{const r=Math.max(5,t),o=[];if(o.push("previous"),e<=r)for(let u=1;u<=e;u++)o.push(u);else{const u=Math.floor((r-5)/2),f=r-3,P=e-f;if(a<=f){for(let s=1;s<=r-2;s++)o.push(s);o.push("ellipsis",e)}else if(a>=P){o.push(1,"ellipsis");for(let s=e-(r-3);s<=e;s++)o.push(s)}else{o.push(1,"ellipsis");for(let s=a-u;s<=a+u;s++)o.push(s);o.push("ellipsis",e)}}return o.push("next"),o},[a,e,t])}const b=y.cva(["inline-flex items-center justify-center","h-9 w-9","rounded-full","text-sm font-medium","transition-colors duration-200 ease-out","focus-visible:outline-none focus-visible:shadow-default"],{variants:{variant:{previous:["text-foreground","hover:bg-accent","aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none"],next:["text-foreground","hover:bg-accent","aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none"],link:["text-foreground","hover:bg-accent hover:text-accent-foreground","aria-[current=page]:bg-background aria-[current=page]:border aria-[current=page]:border-input","dark:aria-[current=page]:bg-input/30","aria-[current=page]:hover:bg-accent","aria-[current=page]:focus-visible:border-ring","aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none"],ellipsis:["relative","cursor-default","text-foreground","pointer-events-none"]}},defaultVariants:{variant:"link"}});function v({className:a,dataHook:e,trackingEl:n,trackingLabel:t,ariaLabel:l,...r}){return i.jsx("nav",{"aria-label":l??"Pagination",className:p.cn("mx-auto flex w-full justify-center",a),"data-hook":e,"data-slot":"pagination","data-tracking-el":n||"pagination","data-tracking-label":t,role:"navigation",...r})}v.displayName="Pagination";function R({className:a,...e}){return i.jsx("ul",{className:p.cn("flex flex-row items-center gap-2",a),"data-slot":"pagination-content",...e})}function M(a){return i.jsx("li",{"data-slot":"pagination-item",...a})}const d=c.forwardRef(({className:a,variant:e,isActive:n,children:t,...l},r)=>i.jsx("button",{ref:r,"aria-current":n?"page":void 0,className:p.cn(b({variant:e}),a),"data-active":n,"data-slot":"pagination-button",type:"button",...l,children:t}));d.displayName="PaginationButton";const h=c.forwardRef(({className:a,disabled:e,ariaLabel:n,...t},l)=>i.jsx(d,{ref:l,"aria-disabled":e,"aria-label":n??"Go to previous page",className:a,disabled:e,variant:"previous",...t,children:i.jsx(g.ChevronLeft,{})}));h.displayName="PaginationPrevious";const m=c.forwardRef(({className:a,disabled:e,ariaLabel:n,...t},l)=>i.jsx(d,{ref:l,"aria-disabled":e,"aria-label":n??"Go to next page",className:a,disabled:e,variant:"next",...t,children:i.jsx(g.ChevronRight,{})}));m.displayName="PaginationNext";const x=c.forwardRef(({className:a,page:e,isActive:n,ariaLabel:t,...l},r)=>i.jsx(d,{ref:r,"aria-label":t?t.replace("{page}",String(e)):`Go to page ${e}`,className:a,isActive:n,variant:"link",...l,children:e}));x.displayName="PaginationLink";function q({className:a,srLabel:e="More pages",...n}){return i.jsxs("span",{"aria-hidden":"true",className:p.cn(b({variant:"ellipsis"}),a),"data-slot":"pagination-ellipsis",...n,children:[i.jsx(g.MoreHorizontal,{}),i.jsx("span",{className:"sr-only",children:e})]})}exports.Pagination=v;exports.PaginationButton=d;exports.PaginationContent=R;exports.PaginationEllipsis=q;exports.PaginationItem=M;exports.PaginationLink=x;exports.PaginationNext=m;exports.PaginationPrevious=h;exports.usePagination=w;
@@ -16,24 +16,28 @@ export interface UsePaginationParams {
16
16
  page: number;
17
17
  /** Total number of pages */
18
18
  totalPages: number;
19
- /** Number of siblings to show on each side of current page */
20
- siblingCount?: number;
21
- /** Number of boundary pages to show at start and end */
22
- boundaryCount?: number;
23
19
  }
24
20
  /**
25
21
  * Pagination item type - can be a page number, "previous", "next", or "ellipsis"
26
22
  */
27
23
  type PaginationItemType = number | "previous" | "next" | "ellipsis";
28
24
  /**
29
- * Custom hook for pagination logic
30
- * Returns an ordered list of pagination items to render
25
+ * Custom hook for pagination logic.
26
+ * Returns a fixed-width list of pagination items — the count never changes
27
+ * as the user navigates. Page 1 and totalPages are always visible as boundary
28
+ * anchors. Ellipsis only appears when hiding 2+ pages.
31
29
  *
32
30
  * @example
33
- * const items = usePagination({ page: 5, totalPages: 10, siblingCount: 1, boundaryCount: 1 });
31
+ * const items = usePagination({ page: 2, totalPages: 10 });
32
+ * // Returns: ["previous", 1, 2, 3, 4, 5, "ellipsis", 10, "next"]
33
+ *
34
+ * const items = usePagination({ page: 5, totalPages: 10 });
34
35
  * // Returns: ["previous", 1, "ellipsis", 4, 5, 6, "ellipsis", 10, "next"]
36
+ *
37
+ * // Automatically uses 5 slots below the `sm` breakpoint (640px)
38
+ * const items = usePagination({ page, totalPages });
35
39
  */
36
- export declare function usePagination({ page, totalPages, siblingCount, boundaryCount, }: UsePaginationParams): PaginationItemType[];
40
+ export declare function usePagination({ page, totalPages, }: UsePaginationParams): PaginationItemType[];
37
41
  declare const paginationItemVariants: (props?: ({
38
42
  variant?: "link" | "ellipsis" | "next" | "previous" | null | undefined;
39
43
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/components/pagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,KAAK,kBAAkB,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;AAEpE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,UAAU,EACV,YAAgB,EAChB,aAAiB,GAClB,EAAE,mBAAmB,GAAG,kBAAkB,EAAE,CAwE5C;AAED,QAAA,MAAM,sBAAsB;;8EA2C3B,CAAC;AAEF,UAAU,eAAgB,SAAQ,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC;IAC3D,iDAAiD;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