@brightlocal/ui-components 2.20.0 → 2.22.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 (66) hide show
  1. package/AI_USAGE.md +2 -0
  2. package/README.md +26 -13
  3. package/component-meta.json +41 -14
  4. package/dist/blocks/data-table.cjs +1 -1
  5. package/dist/blocks/data-table.d.ts +35 -3
  6. package/dist/blocks/data-table.d.ts.map +1 -1
  7. package/dist/blocks/data-table.js +178 -154
  8. package/dist/blocks/sidebar.cjs +1 -1
  9. package/dist/blocks/sidebar.d.ts +2 -2
  10. package/dist/blocks/sidebar.js +18 -18
  11. package/dist/breadcrumb.cjs +1 -1
  12. package/dist/breadcrumb.d.ts +1 -1
  13. package/dist/breadcrumb.d.ts.map +1 -1
  14. package/dist/breadcrumb.js +9 -6
  15. package/dist/button.cjs +1 -1
  16. package/dist/button.d.ts.map +1 -1
  17. package/dist/button.js +12 -12
  18. package/dist/hover-card.cjs +1 -1
  19. package/dist/hover-card.d.ts.map +1 -1
  20. package/dist/hover-card.js +45 -45
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +69 -68
  23. package/dist/lib/utils.cjs +1 -1
  24. package/dist/lib/utils.d.ts +1 -0
  25. package/dist/lib/utils.d.ts.map +1 -1
  26. package/dist/lib/utils.js +7 -5
  27. package/dist/logo.cjs +1 -1
  28. package/dist/logo.d.ts +1 -1
  29. package/dist/logo.js +2 -2
  30. package/dist/navigation-menu.cjs +1 -1
  31. package/dist/navigation-menu.d.ts +17 -0
  32. package/dist/navigation-menu.d.ts.map +1 -1
  33. package/dist/navigation-menu.js +120 -90
  34. package/dist/pagination.cjs +1 -1
  35. package/dist/pagination.d.ts +12 -8
  36. package/dist/pagination.d.ts.map +1 -1
  37. package/dist/pagination.js +117 -113
  38. package/dist/progress.cjs +1 -1
  39. package/dist/progress.d.ts +28 -2
  40. package/dist/progress.d.ts.map +1 -1
  41. package/dist/progress.js +90 -49
  42. package/dist/skeleton.cjs +1 -1
  43. package/dist/skeleton.js +1 -1
  44. package/dist/sonner.d.ts +1 -1
  45. package/dist/table.cjs +1 -1
  46. package/dist/table.d.ts +22 -2
  47. package/dist/table.d.ts.map +1 -1
  48. package/dist/table.js +57 -43
  49. package/dist/tooltip.cjs +1 -1
  50. package/dist/tooltip.d.ts.map +1 -1
  51. package/dist/tooltip.js +36 -36
  52. package/package.json +7 -3
  53. package/src/blocks/data-table.tsx +56 -4
  54. package/src/blocks/sidebar.tsx +5 -5
  55. package/src/components/breadcrumb.tsx +6 -3
  56. package/src/components/button.tsx +7 -1
  57. package/src/components/hover-card.tsx +6 -3
  58. package/src/components/logo.tsx +3 -3
  59. package/src/components/navigation-menu.tsx +113 -32
  60. package/src/components/pagination.tsx +47 -67
  61. package/src/components/progress.tsx +118 -14
  62. package/src/components/skeleton.tsx +1 -1
  63. package/src/components/sonner.tsx +1 -1
  64. package/src/components/table.tsx +44 -7
  65. package/src/components/tooltip.tsx +8 -5
  66. package/src/lib/utils.ts +3 -0
@@ -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 f, 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 b } from "@brightlocal/icons";
5
+ import { cn as r } from "@brightlocal/ui-components/lib/utils";
6
+ const h = i.forwardRef(({ className: t, children: e, dataHook: a, delayDuration: d = 50, ...c }, l) => (
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__ */ f(
10
+ s.Root,
11
+ {
12
+ ref: l,
13
+ className: r(
14
+ "relative z-10 flex max-w-max flex-1 items-center justify-center",
15
+ t
16
+ ),
17
+ "data-hook": a,
18
+ "data-slot": "navigation-menu",
19
+ delayDuration: d,
20
+ ...c,
21
+ children: [
22
+ e,
23
+ /* @__PURE__ */ n(g, {})
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 w = i.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ n(
30
+ s.List,
26
31
  {
27
32
  ref: a,
28
- className: i(
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,80 @@ 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
+ w.displayName = "NavigationMenuList";
42
+ const x = 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
- ]
50
+ x.displayName = "NavigationMenuItem";
51
+ const M = 400, y = i.forwardRef(
52
+ ({ className: t, children: e, onClick: a, onPointerDown: d, onPointerEnter: c, ...l }, p) => {
53
+ const u = i.useRef(""), m = i.useRef(0);
54
+ return /* @__PURE__ */ f(
55
+ s.Trigger,
56
+ {
57
+ ref: p,
58
+ className: r(
59
+ [
60
+ "group inline-flex h-9 w-max items-center justify-center gap-1",
61
+ "rounded-md px-4 py-2",
62
+ "text-sm font-medium",
63
+ "text-foreground",
64
+ "transition-colors",
65
+ "hover:bg-accent hover:text-accent-foreground",
66
+ "focus:bg-accent focus:text-accent-foreground",
67
+ "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",
68
+ "disabled:pointer-events-none disabled:opacity-50",
69
+ "data-[state=open]:bg-accent/50"
70
+ ],
71
+ t
72
+ ),
73
+ "data-slot": "navigation-menu-trigger",
74
+ onClick: (o) => {
75
+ const v = o.currentTarget.getAttribute("data-state") === "open", N = o.timeStamp - m.current < M;
76
+ u.current === "mouse" && o.detail > 0 && v && N && o.preventDefault(), a?.(o);
77
+ },
78
+ onPointerDown: (o) => {
79
+ u.current = o.pointerType, d?.(o);
80
+ },
81
+ onPointerEnter: (o) => {
82
+ m.current = o.timeStamp, c?.(o);
83
+ },
84
+ ...l,
85
+ children: [
86
+ e,
87
+ /* @__PURE__ */ n(
88
+ b,
89
+ {
90
+ "aria-hidden": "true",
91
+ className: "relative top-[1px] ml-1 transition duration-300 group-data-[state=open]:rotate-180",
92
+ size: 12
93
+ }
94
+ )
95
+ ]
96
+ }
97
+ );
78
98
  }
79
- ));
80
- v.displayName = "NavigationMenuTrigger";
81
- const p = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
82
- r.Content,
99
+ );
100
+ y.displayName = "NavigationMenuTrigger";
101
+ const R = i.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ n(
102
+ s.Content,
83
103
  {
84
104
  ref: a,
85
- className: i(
105
+ className: r(
86
106
  [
87
107
  "data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out top-0 left-0 w-full",
88
108
  "data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out",
89
109
  "data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52",
90
110
  "data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52",
111
+ // Match the viewport's easeOutQuint timing so the directional slide and
112
+ // the container morph feel like one motion (kept snappy so content
113
+ // appears without a perceptible fade-in delay).
114
+ "duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]",
91
115
  "md:absolute md:w-auto"
92
116
  ],
93
117
  t
@@ -97,12 +121,12 @@ const p = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
97
121
  ...e
98
122
  }
99
123
  ));
100
- p.displayName = "NavigationMenuContent";
101
- const N = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
102
- r.Link,
124
+ R.displayName = "NavigationMenuContent";
125
+ const _ = i.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ n(
126
+ s.Link,
103
127
  {
104
128
  ref: a,
105
- className: i(
129
+ className: r(
106
130
  [
107
131
  "block rounded-md p-3 leading-none no-underline select-none",
108
132
  "transition-colors outline-none",
@@ -116,17 +140,23 @@ const N = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
116
140
  ...e
117
141
  }
118
142
  ));
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,
143
+ _.displayName = "NavigationMenuLink";
144
+ const g = i.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ n("div", { className: r("absolute top-full left-0 z-50 flex justify-center"), children: /* @__PURE__ */ n(
145
+ s.Viewport,
122
146
  {
123
147
  ref: a,
124
- className: i(
148
+ className: r(
125
149
  [
126
150
  "origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)]",
127
151
  "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",
152
+ // Base UI-style size morph: smoothly animate width/height between items
153
+ // with an easeOutQuint curve. The enter/exit stays snappy (200ms in,
154
+ // 150ms out) so the panel and its content appear immediately rather
155
+ // than fading in slowly. Reduced motion is neutralised globally by the
156
+ // token preset, so no per-element motion-reduce guard is needed.
157
+ "transition-[width,height] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]",
158
+ "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
159
+ "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-150",
130
160
  "md:w-[var(--radix-navigation-menu-viewport-width)]"
131
161
  ],
132
162
  t
@@ -135,12 +165,12 @@ const l = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o("div", {
135
165
  ...e
136
166
  }
137
167
  ) }));
138
- l.displayName = "NavigationMenuViewport";
139
- const b = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
140
- r.Indicator,
168
+ g.displayName = "NavigationMenuViewport";
169
+ const I = i.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ n(
170
+ s.Indicator,
141
171
  {
142
172
  ref: a,
143
- className: i(
173
+ className: r(
144
174
  [
145
175
  "top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden",
146
176
  "data-[state=visible]:animate-in data-[state=hidden]:animate-out",
@@ -150,17 +180,17 @@ const b = n.forwardRef(({ className: t, ...e }, a) => /* @__PURE__ */ o(
150
180
  ),
151
181
  "data-slot": "navigation-menu-indicator",
152
182
  ...e,
153
- children: /* @__PURE__ */ o("div", { className: "bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" })
183
+ children: /* @__PURE__ */ n("div", { className: "bg-border relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm shadow-md" })
154
184
  }
155
185
  ));
156
- b.displayName = "NavigationMenuIndicator";
186
+ I.displayName = "NavigationMenuIndicator";
157
187
  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
188
+ h as NavigationMenu,
189
+ R as NavigationMenuContent,
190
+ I as NavigationMenuIndicator,
191
+ x as NavigationMenuItem,
192
+ _ as NavigationMenuLink,
193
+ w as NavigationMenuList,
194
+ y as NavigationMenuTrigger,
195
+ g as NavigationMenuViewport
166
196
  };
@@ -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,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