@agentero/design-system 0.7.5 → 0.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentero/design-system",
3
- "version": "0.7.5",
3
+ "version": "0.8.0",
4
4
  "description": "A React component library built with Tailwind CSS v4 and Radix UI primitives",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -45,6 +45,10 @@
45
45
  "types": "./src/loading/index.d.ts",
46
46
  "import": "./src/loading/index.js"
47
47
  },
48
+ "./pagination": {
49
+ "types": "./src/pagination/index.d.ts",
50
+ "import": "./src/pagination/index.js"
51
+ },
48
52
  "./status-ball": {
49
53
  "types": "./src/status-ball/index.d.ts",
50
54
  "import": "./src/status-ball/index.js"
@@ -0,0 +1,15 @@
1
+ type Page = {
2
+ number: number;
3
+ type: PageType;
4
+ };
5
+ type UsePaginationProps = {
6
+ totalCount: number;
7
+ pageSize: number;
8
+ currentPage: number;
9
+ };
10
+ export declare enum PageType {
11
+ Normal = 0,
12
+ Dots = 1
13
+ }
14
+ export declare const getPages: ({ totalCount, pageSize, currentPage }: UsePaginationProps) => Page[];
15
+ export {};
@@ -0,0 +1,55 @@
1
+ //#region src/pagination/get-pages.ts
2
+ var e = /* @__PURE__ */ function(e) {
3
+ return e[e.Normal = 0] = "Normal", e[e.Dots = 1] = "Dots", e;
4
+ }({}), t = (t, n) => {
5
+ let r = n - t + 1;
6
+ return Array.from({ length: r }, (n, r) => ({
7
+ number: r + t,
8
+ type: e.Normal
9
+ }));
10
+ }, n = 1, r = 1, i = {
11
+ number: 0,
12
+ type: e.Dots
13
+ }, a = ({ totalCount: a, pageSize: o, currentPage: s }) => {
14
+ let c = Math.ceil(a / o);
15
+ if (r + 5 >= c) return t(1, c);
16
+ let l = Math.max(s - r, 1), u = Math.min(s + r, c), d = l > 2, f = u < c - 2;
17
+ if (!d && f) return [
18
+ ...t(1, 3 + 2 * r),
19
+ i,
20
+ {
21
+ number: c,
22
+ type: e.Normal
23
+ }
24
+ ];
25
+ if (d && !f) {
26
+ let a = t(c - (3 + 2 * r) + 1, c);
27
+ return [
28
+ {
29
+ number: n,
30
+ type: e.Normal
31
+ },
32
+ i,
33
+ ...a
34
+ ];
35
+ }
36
+ if (d && f) {
37
+ let r = t(l, u);
38
+ return [
39
+ {
40
+ number: n,
41
+ type: e.Normal
42
+ },
43
+ i,
44
+ ...r,
45
+ i,
46
+ {
47
+ number: c,
48
+ type: e.Normal
49
+ }
50
+ ];
51
+ }
52
+ return [];
53
+ };
54
+ //#endregion
55
+ export { e as PageType, a as getPages };
@@ -0,0 +1,25 @@
1
+ import { SVGProps } from 'react';
2
+ /**
3
+ * Three-dot ellipsis glyph rendered inside the page list to indicate a
4
+ * collapsed range between page numbers. The fill follows the surrounding
5
+ * text color so it inherits the pagination button color tokens.
6
+ *
7
+ * @summary 24px horizontal-dots icon used as the page-range ellipsis
8
+ */
9
+ export declare const IconHorizontalDots: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
10
+ /**
11
+ * Left-chevron glyph rendered inside the previous-page icon button. The fill
12
+ * follows the surrounding text color so it inherits the pagination button
13
+ * color tokens.
14
+ *
15
+ * @summary 24px chevron-left icon used by the previous-page button
16
+ */
17
+ export declare const IconKeyboardArrowLeft: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
18
+ /**
19
+ * Right-chevron glyph rendered inside the next-page icon button. The fill
20
+ * follows the surrounding text color so it inherits the pagination button
21
+ * color tokens.
22
+ *
23
+ * @summary 24px chevron-right icon used by the next-page button
24
+ */
25
+ export declare const IconKeyboardArrowRight: (props: SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ //#region src/pagination/icons.tsx
3
+ var t = (t) => /* @__PURE__ */ e("svg", {
4
+ width: "24",
5
+ height: "24",
6
+ viewBox: "0 0 24 24",
7
+ fill: "none",
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ ...t,
10
+ children: /* @__PURE__ */ e("path", { d: "M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" })
11
+ }), n = (t) => /* @__PURE__ */ e("svg", {
12
+ width: "24",
13
+ height: "24",
14
+ viewBox: "0 0 24 24",
15
+ fill: "none",
16
+ xmlns: "http://www.w3.org/2000/svg",
17
+ ...t,
18
+ children: /* @__PURE__ */ e("path", { d: "M10.4539 12L14.5269 16.0731C14.6654 16.2115 14.7362 16.3856 14.7394 16.5952C14.7427 16.8048 14.6718 16.982 14.5269 17.1269C14.3821 17.2718 14.2064 17.3442 14 17.3442C13.7936 17.3442 13.618 17.2718 13.4731 17.1269L8.97892 12.6327C8.88532 12.5391 8.81929 12.4404 8.78084 12.3365C8.74238 12.2327 8.72314 12.1205 8.72314 12C8.72314 11.8795 8.74238 11.7673 8.78084 11.6635C8.81929 11.5596 8.88532 11.4609 8.97892 11.3673L13.4731 6.8731C13.6116 6.73463 13.7856 6.6638 13.9952 6.6606C14.2048 6.65738 14.3821 6.72821 14.5269 6.8731C14.6718 7.01796 14.7443 7.1936 14.7443 7.4C14.7443 7.6064 14.6718 7.78203 14.5269 7.9269L10.4539 12Z" })
19
+ }), r = (t) => /* @__PURE__ */ e("svg", {
20
+ width: "24",
21
+ height: "24",
22
+ viewBox: "0 0 24 24",
23
+ fill: "none",
24
+ xmlns: "http://www.w3.org/2000/svg",
25
+ ...t,
26
+ children: /* @__PURE__ */ e("path", { d: "M12.9462 12L8.87309 7.92689C8.73462 7.78844 8.66379 7.6144 8.66059 7.40479C8.65737 7.19519 8.7282 7.01795 8.87309 6.87309C9.01795 6.7282 9.19359 6.65576 9.39999 6.65576C9.60639 6.65576 9.78202 6.7282 9.92689 6.87309L14.4211 11.3673C14.5147 11.4609 14.5807 11.5596 14.6192 11.6635C14.6577 11.7673 14.6769 11.8795 14.6769 12C14.6769 12.1205 14.6577 12.2327 14.6192 12.3365C14.5807 12.4404 14.5147 12.5391 14.4211 12.6327L9.92689 17.1269C9.78844 17.2654 9.6144 17.3362 9.40479 17.3394C9.19519 17.3426 9.01795 17.2718 8.87309 17.1269C8.7282 16.982 8.65576 16.8064 8.65576 16.6C8.65576 16.3936 8.7282 16.218 8.87309 16.0731L12.9462 12Z" })
27
+ });
28
+ //#endregion
29
+ export { t as IconHorizontalDots, n as IconKeyboardArrowLeft, r as IconKeyboardArrowRight };
@@ -0,0 +1,2 @@
1
+ export { Pagination } from './pagination';
2
+ export type { PaginationProps } from './pagination';
@@ -0,0 +1,2 @@
1
+ import { Pagination as e } from "./pagination.js";
2
+ export { e as Pagination };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Style recipe for Pagination using tailwind-variants. Multi-slot recipe that
3
+ * owns every element the component renders: the `root` `<nav>`, the entries
4
+ * `summary`, the `list` and per-page `item` wrappers, the page/prev/next
5
+ * `button`, and the ellipsis `dots` span. The `active` variant paints the
6
+ * current page button.
7
+ *
8
+ * Exported for advanced composition (e.g., styling a custom element to match
9
+ * a Pagination slot). Prefer rendering the `Pagination` component.
10
+ *
11
+ * @summary tailwind-variants recipe backing the Pagination component styles
12
+ */
13
+ export declare const paginationRecipe: import('tailwind-variants').TVReturnType<{
14
+ active: {
15
+ true: {
16
+ button: string;
17
+ };
18
+ };
19
+ }, {
20
+ root: string;
21
+ summary: string;
22
+ list: string;
23
+ item: string;
24
+ button: string[];
25
+ dots: string;
26
+ }, undefined, {
27
+ active: {
28
+ true: {
29
+ button: string;
30
+ };
31
+ };
32
+ }, {
33
+ root: string;
34
+ summary: string;
35
+ list: string;
36
+ item: string;
37
+ button: string[];
38
+ dots: string;
39
+ }, import('tailwind-variants').TVReturnType<{
40
+ active: {
41
+ true: {
42
+ button: string;
43
+ };
44
+ };
45
+ }, {
46
+ root: string;
47
+ summary: string;
48
+ list: string;
49
+ item: string;
50
+ button: string[];
51
+ dots: string;
52
+ }, undefined, unknown, unknown, undefined>>;
53
+ /**
54
+ * Props for the Pagination component.
55
+ *
56
+ * @property {(page: number) => void} onPageChange - Called with the next 1-indexed page number when the user clicks a page, prev, or next button.
57
+ * @property {number} totalCount - Total number of items across all pages. Combined with `pageSize` to derive the total page count.
58
+ * @property {number} currentPage - The 1-indexed page currently in view. Pass `0` to short-circuit and render nothing (legacy "off" sentinel).
59
+ * @property {number} pageSize - Number of items per page. Drives both the page count and the entries-of-total summary.
60
+ * @property {string} [className] - Additional CSS classes applied to the root `<nav>` element.
61
+ */
62
+ export type PaginationProps = {
63
+ onPageChange: (page: number) => void;
64
+ totalCount: number;
65
+ currentPage: number;
66
+ pageSize: number;
67
+ className?: string;
68
+ };
69
+ /**
70
+ * Pagination is a 1-indexed paged navigation control with previous/next icon
71
+ * buttons, numeric page buttons, and a leading "X - Y of Z" entries summary.
72
+ * The page list collapses long ranges with `…` ellipses, keeping at most a
73
+ * handful of buttons in view regardless of total page count. Use it whenever
74
+ * a list, table, or grid is split across pages and the user needs direct
75
+ * access to specific pages (not just prev/next).
76
+ *
77
+ * The control short-circuits to `null` when `currentPage === 0` (legacy "off"
78
+ * sentinel) or when there are no pages to show, so it's safe to mount
79
+ * unconditionally above a list that may be empty.
80
+ *
81
+ * Do **not** use Pagination for infinite-scroll feeds, sub-page-1 indexing
82
+ * (the `0` value is reserved as the off-switch), or as a tab/segmented
83
+ * control — it's strictly a page-of-pages affordance.
84
+ *
85
+ * @summary 1-indexed paged navigation control with prev/next, numeric pages, and entries summary
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * import { useState } from 'react';
90
+ * import { Pagination } from '@agentero/design-system/pagination';
91
+ *
92
+ * const [page, setPage] = useState(1);
93
+ *
94
+ * <Pagination
95
+ * currentPage={page}
96
+ * pageSize={10}
97
+ * totalCount={1000}
98
+ * onPageChange={setPage}
99
+ * />
100
+ * ```
101
+ */
102
+ export declare const Pagination: ({ onPageChange, totalCount, currentPage, pageSize, className }: PaginationProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/utils.js";
3
+ import { PageType as t, getPages as n } from "./get-pages.js";
4
+ import { IconHorizontalDots as r, IconKeyboardArrowLeft as i, IconKeyboardArrowRight as a } from "./icons.js";
5
+ import { tv as o } from "tailwind-variants";
6
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ //#region src/pagination/pagination.tsx
8
+ var l = o({
9
+ slots: {
10
+ root: "flex h-8 items-center justify-between gap-4",
11
+ summary: "text-base text-text-default-base-tertiary",
12
+ list: "flex items-center gap-2",
13
+ item: "flex min-w-8 h-8",
14
+ button: [
15
+ "relative inline-flex items-center justify-center",
16
+ "text-sm font-semibold rounded-md cursor-pointer no-underline whitespace-nowrap",
17
+ "min-w-8 h-8 px-1",
18
+ "border border-solid border-transparent",
19
+ "bg-bg-button-ghost-enable text-text-button-ghost-enable",
20
+ "transition-[background-color,border-color,color] duration-200",
21
+ "disabled:pointer-events-none disabled:opacity-30",
22
+ "focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-[0.0625rem] focus-visible:outline-focus-ring-button-primary",
23
+ "hover:not-aria-[current=page]:border-border-button-secondary-enable hover:not-aria-[current=page]:shadow-1",
24
+ "[&_svg]:size-8 [&_svg]:-mx-2 [&_svg]:fill-current"
25
+ ],
26
+ dots: "inline-flex size-8 items-center justify-center text-text-button-ghost-enable [&_svg]:size-4 [&_svg]:fill-current"
27
+ },
28
+ variants: { active: { true: { button: "bg-bg-button-ghost-hover border-bg-button-ghost-hover" } } }
29
+ }), u = ({ onPageChange: o, totalCount: u, currentPage: d, pageSize: f, className: p }) => {
30
+ let m = n({
31
+ currentPage: d,
32
+ totalCount: u,
33
+ pageSize: f
34
+ });
35
+ if (d === 0 || m.length === 0) return null;
36
+ let h = () => o(d + 1), g = () => o(d - 1), _ = m.length >= 2, v = m[m.length - 1].number, y = d * f - f + 1, b = d * f > u ? u : d * f, x = l();
37
+ return /* @__PURE__ */ c("nav", {
38
+ "aria-label": "Pagination",
39
+ className: e(x.root(), p),
40
+ children: [/* @__PURE__ */ c("span", {
41
+ className: x.summary(),
42
+ children: [
43
+ y,
44
+ " - ",
45
+ b,
46
+ " of ",
47
+ Intl.NumberFormat("en-US").format(u)
48
+ ]
49
+ }), _ && /* @__PURE__ */ c("ul", {
50
+ className: x.list(),
51
+ children: [
52
+ /* @__PURE__ */ s("li", {
53
+ className: x.item(),
54
+ children: /* @__PURE__ */ s("button", {
55
+ type: "button",
56
+ onClick: g,
57
+ disabled: d === 1,
58
+ "aria-label": "Go to previous page",
59
+ className: x.button(),
60
+ children: /* @__PURE__ */ s(i, {})
61
+ })
62
+ }),
63
+ m.map(({ number: e, type: n }, i) => n === t.Dots ? /* @__PURE__ */ s("li", {
64
+ className: x.item(),
65
+ children: /* @__PURE__ */ s("span", {
66
+ "aria-hidden": "true",
67
+ className: x.dots(),
68
+ children: /* @__PURE__ */ s(r, {})
69
+ })
70
+ }, i) : /* @__PURE__ */ s("li", {
71
+ className: x.item(),
72
+ children: /* @__PURE__ */ s("button", {
73
+ type: "button",
74
+ onClick: () => o(e),
75
+ "aria-current": d === e ? "page" : void 0,
76
+ className: x.button({ active: d === e }),
77
+ children: Intl.NumberFormat("en-US").format(e)
78
+ })
79
+ }, i)),
80
+ /* @__PURE__ */ s("li", {
81
+ className: x.item(),
82
+ children: /* @__PURE__ */ s("button", {
83
+ type: "button",
84
+ onClick: h,
85
+ disabled: d === v,
86
+ "aria-label": "Go to next page",
87
+ className: x.button(),
88
+ children: /* @__PURE__ */ s(a, {})
89
+ })
90
+ })
91
+ ]
92
+ })]
93
+ });
94
+ };
95
+ //#endregion
96
+ export { u as Pagination };