@kumix/ui 0.3.14 → 0.3.16

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 (78) hide show
  1. package/README.md +15 -15
  2. package/dist/components/motion/animated-toast-stack.js +4 -3
  3. package/dist/components/motion/animated-toast-stack.js.map +1 -1
  4. package/dist/components/motion/command-palette.d.ts.map +1 -1
  5. package/dist/components/motion/command-palette.js +2 -21
  6. package/dist/components/motion/command-palette.js.map +1 -1
  7. package/dist/components/motion/tabs.js +1 -1
  8. package/dist/components/motion/tabs.js.map +1 -1
  9. package/dist/components/motion/tooltip-surface.d.ts +12 -0
  10. package/dist/components/motion/tooltip-surface.d.ts.map +1 -0
  11. package/dist/components/motion/tooltip-surface.js +97 -0
  12. package/dist/components/motion/tooltip-surface.js.map +1 -0
  13. package/dist/components/motion/tooltip.d.ts +13 -3
  14. package/dist/components/motion/tooltip.d.ts.map +1 -1
  15. package/dist/components/motion/tooltip.js +74 -103
  16. package/dist/components/motion/tooltip.js.map +1 -1
  17. package/dist/components/reui/alert.d.ts +1 -1
  18. package/dist/components/reui/autocomplete.d.ts +1 -1
  19. package/dist/components/reui/autocomplete.d.ts.map +1 -1
  20. package/dist/components/reui/autocomplete.js +1 -1
  21. package/dist/components/reui/autocomplete.js.map +1 -1
  22. package/dist/components/reui/badge.d.ts +2 -2
  23. package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -1
  24. package/dist/components/reui/cascader/cascader-virtual.js +2 -0
  25. package/dist/components/reui/cascader/cascader-virtual.js.map +1 -1
  26. package/dist/components/reui/data-grid/data-grid-pagination.d.ts +2 -0
  27. package/dist/components/reui/data-grid/data-grid-pagination.d.ts.map +1 -1
  28. package/dist/components/reui/data-grid/data-grid-pagination.js +103 -42
  29. package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
  30. package/dist/components/reui/data-grid/data-grid-table.js +1 -1
  31. package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
  32. package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
  33. package/dist/components/reui/data-grid/data-grid.js.map +1 -1
  34. package/dist/components/reui/event-calendar/event-calendar-resource-view.d.ts.map +1 -1
  35. package/dist/components/reui/event-calendar/event-calendar-resource-view.js +3 -4
  36. package/dist/components/reui/event-calendar/event-calendar-resource-view.js.map +1 -1
  37. package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts +9 -1
  38. package/dist/components/reui/event-calendar/event-calendar-time-grid.d.ts.map +1 -1
  39. package/dist/components/reui/event-calendar/event-calendar-time-grid.js +11 -4
  40. package/dist/components/reui/event-calendar/event-calendar-time-grid.js.map +1 -1
  41. package/dist/components/reui/event-calendar/event-calendar.d.ts.map +1 -1
  42. package/dist/components/reui/event-calendar/event-calendar.js.map +1 -1
  43. package/dist/components/reui/filters/filters-advanced.js.map +1 -1
  44. package/dist/components/reui/filters/filters-builder.js +1 -1
  45. package/dist/components/reui/filters/filters-editors.js +1 -1
  46. package/dist/components/reui/filters/filters-types.d.ts +8 -0
  47. package/dist/components/reui/filters/filters-types.d.ts.map +1 -1
  48. package/dist/components/reui/frame.d.ts +6 -12
  49. package/dist/components/reui/frame.d.ts.map +1 -1
  50. package/dist/components/reui/frame.js +9 -16
  51. package/dist/components/reui/frame.js.map +1 -1
  52. package/dist/components/reui/gantt/gantt.d.ts.map +1 -1
  53. package/dist/components/reui/gantt/gantt.js.map +1 -1
  54. package/dist/components/reui/icon-tile.d.ts +2 -2
  55. package/dist/components/reui/number-field.d.ts +3 -3
  56. package/dist/components/reui/number-field.d.ts.map +1 -1
  57. package/dist/components/reui/number-field.js +3 -3
  58. package/dist/components/reui/number-field.js.map +1 -1
  59. package/dist/components/reui/rating.d.ts +1 -1
  60. package/dist/components/ui/attachment.d.ts +2 -2
  61. package/dist/components/ui/badge.d.ts +1 -1
  62. package/dist/components/ui/bubble.d.ts +1 -1
  63. package/dist/components/ui/button-group.d.ts +1 -1
  64. package/dist/components/ui/button.d.ts +2 -2
  65. package/dist/components/ui/field.d.ts +1 -1
  66. package/dist/components/ui/item.d.ts +3 -3
  67. package/dist/components/ui/marker.d.ts +1 -1
  68. package/dist/components/ui/sidebar.d.ts +2 -2
  69. package/dist/components/ui/tabs.d.ts +1 -1
  70. package/dist/components/ui/toggle.d.ts +2 -2
  71. package/dist/hooks/use-dismiss.d.ts +1 -1
  72. package/dist/hooks/use-dismiss.d.ts.map +1 -1
  73. package/dist/hooks/use-dismiss.js.map +1 -1
  74. package/dist/lib/command-search.d.ts +10 -0
  75. package/dist/lib/command-search.d.ts.map +1 -0
  76. package/dist/lib/command-search.js +52 -0
  77. package/dist/lib/command-search.js.map +1 -0
  78. package/package.json +5 -5
@@ -7,6 +7,89 @@ import { cn } from "@kumix/utils";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
9
9
  //#region src/components/reui/data-grid/data-grid-pagination.tsx
10
+ /**
11
+ * The adaptive window: first page, the run around the current one, last page,
12
+ * with an ellipsis standing in for each hidden stretch. It replaced fixed
13
+ * BLOCKS (1-5, then 6-10) because a block never shows the last page, so on a
14
+ * 50-page grid there was no way to reach the end - the primitive wires only
15
+ * `previousPage()` / `nextPage()`, so there is no last-page arrow either.
16
+ *
17
+ * `limit` is `moreLimit`: how many page buttons the truncated middle shows.
18
+ * At the default of 5 this emits exactly the same rows as the block version
19
+ * did at `moreLimit: 5`, so the prop keeps both its meaning and its default.
20
+ * An ellipsis never stands for a single page, because the early return covers
21
+ * every count a full row could hold.
22
+ */
23
+ function getDataGridPaginationItems(pageIndex, pageCount, limit) {
24
+ const sibling = Math.max(0, Math.floor(((Math.floor(limit) || 3) - 3) / 2));
25
+ const pages = sibling * 2 + 3;
26
+ if (pageCount <= pages + 2) return Array.from({ length: pageCount }, (_, index) => ({
27
+ type: "page",
28
+ index
29
+ }));
30
+ if (pageIndex <= sibling + 2) return [
31
+ ...Array.from({ length: pages }, (_, index) => ({
32
+ type: "page",
33
+ index
34
+ })),
35
+ {
36
+ type: "ellipsis",
37
+ direction: "next",
38
+ target: pages
39
+ },
40
+ {
41
+ type: "page",
42
+ index: pageCount - 1
43
+ }
44
+ ];
45
+ if (pageIndex >= pageCount - sibling - 3) return [
46
+ {
47
+ type: "page",
48
+ index: 0
49
+ },
50
+ {
51
+ type: "ellipsis",
52
+ direction: "previous",
53
+ target: pageCount - pages - 1
54
+ },
55
+ ...Array.from({ length: pages }, (_, offset) => ({
56
+ type: "page",
57
+ index: pageCount - pages + offset
58
+ }))
59
+ ];
60
+ return [
61
+ {
62
+ type: "page",
63
+ index: 0
64
+ },
65
+ {
66
+ type: "ellipsis",
67
+ direction: "previous",
68
+ target: pageIndex - sibling - 1
69
+ },
70
+ ...Array.from({ length: sibling * 2 + 1 }, (_, offset) => ({
71
+ type: "page",
72
+ index: pageIndex - sibling + offset
73
+ })),
74
+ {
75
+ type: "ellipsis",
76
+ direction: "next",
77
+ target: pageIndex + sibling + 1
78
+ },
79
+ {
80
+ type: "page",
81
+ index: pageCount - 1
82
+ }
83
+ ];
84
+ }
85
+ /**
86
+ * A page button is square at one digit and grows from there, so the row does
87
+ * not reflow when the count crosses 10 or 100. The floor is each style's own
88
+ * `icon-sm` square, which is also its `sm` HEIGHT, so the numbers stay square
89
+ * and keep the arrows' height. Hardcoding one value would be right in three
90
+ * styles and wrong in five.
91
+ */
92
+ const PAGE_BUTTON_WIDTH_CLASS = "min-w-7";
10
93
  function DataGridPagination(props) {
11
94
  const { i18n, table, recordCount, isLoading } = useDataGrid();
12
95
  const mergedProps = {
@@ -38,44 +121,7 @@ function DataGridPagination(props) {
38
121
  to,
39
122
  count: recordCount
40
123
  });
41
- const paginationMoreLimit = mergedProps.moreLimit || 5;
42
- const currentGroupStart = Math.floor(pageIndex / paginationMoreLimit) * paginationMoreLimit;
43
- const currentGroupEnd = Math.min(currentGroupStart + paginationMoreLimit, pageCount);
44
- const renderPageButtons = () => {
45
- const buttons = [];
46
- for (let i = currentGroupStart; i < currentGroupEnd; i++) buttons.push(/* @__PURE__ */ jsx(Button, {
47
- size: "icon-sm",
48
- variant: "ghost",
49
- "aria-label": i18n.labels.goToPage(i + 1),
50
- "aria-current": pageIndex === i ? "page" : void 0,
51
- className: cn(btnBaseClasses, "text-muted-foreground", { "bg-accent text-accent-foreground": pageIndex === i }),
52
- onClick: () => {
53
- if (pageIndex !== i) table.setPageIndex(i);
54
- },
55
- children: i + 1
56
- }, i));
57
- return buttons;
58
- };
59
- const renderEllipsisPrevButton = () => {
60
- if (currentGroupStart > 0) return /* @__PURE__ */ jsx(Button, {
61
- size: "icon-sm",
62
- className: btnBaseClasses,
63
- variant: "ghost",
64
- onClick: () => table.setPageIndex(currentGroupStart - 1),
65
- children: mergedProps.ellipsisText
66
- });
67
- return null;
68
- };
69
- const renderEllipsisNextButton = () => {
70
- if (currentGroupEnd < pageCount) return /* @__PURE__ */ jsx(Button, {
71
- className: btnBaseClasses,
72
- variant: "ghost",
73
- size: "icon-sm",
74
- onClick: () => table.setPageIndex(currentGroupEnd),
75
- children: mergedProps.ellipsisText
76
- });
77
- return null;
78
- };
124
+ const paginationItems = getDataGridPaginationItems(pageIndex, pageCount, mergedProps.moreLimit ?? 5);
79
125
  return /* @__PURE__ */ jsxs("div", {
80
126
  "data-slot": "data-grid-pagination",
81
127
  className: cn("flex grow flex-col flex-wrap items-center justify-between gap-2.5 py-2.5 sm:flex-row sm:py-0", mergedProps.className),
@@ -111,7 +157,7 @@ function DataGridPagination(props) {
111
157
  className: "order-2 text-nowrap text-muted-foreground text-sm sm:order-1",
112
158
  children: paginationInfo
113
159
  }), pageCount > 1 && /* @__PURE__ */ jsxs("div", {
114
- className: "order-1 flex items-center space-x-1",
160
+ className: "order-1 flex flex-wrap items-center justify-center gap-1 sm:flex-nowrap",
115
161
  children: [
116
162
  /* @__PURE__ */ jsxs(Button, {
117
163
  size: "icon-sm",
@@ -124,9 +170,24 @@ function DataGridPagination(props) {
124
170
  children: mergedProps.previousPageLabel
125
171
  }), /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "size-4" })]
126
172
  }),
127
- renderEllipsisPrevButton(),
128
- renderPageButtons(),
129
- renderEllipsisNextButton(),
173
+ paginationItems.map((item) => item.type === "page" ? /* @__PURE__ */ jsx(Button, {
174
+ size: "sm",
175
+ variant: "ghost",
176
+ "aria-label": i18n.labels.goToPage(item.index + 1),
177
+ "aria-current": pageIndex === item.index ? "page" : void 0,
178
+ className: cn(PAGE_BUTTON_WIDTH_CLASS, "px-1.5 text-sm", "text-muted-foreground", { "bg-accent text-accent-foreground": pageIndex === item.index }),
179
+ onClick: () => {
180
+ if (pageIndex !== item.index) table.setPageIndex(item.index);
181
+ },
182
+ children: item.index + 1
183
+ }, `page-${item.index}`) : /* @__PURE__ */ jsx(Button, {
184
+ size: "icon-sm",
185
+ className: btnBaseClasses,
186
+ variant: "ghost",
187
+ "aria-label": i18n.labels.goToPage(item.target + 1),
188
+ onClick: () => table.setPageIndex(item.target),
189
+ children: mergedProps.ellipsisText
190
+ }, `ellipsis-${item.direction}`)),
130
191
  /* @__PURE__ */ jsxs(Button, {
131
192
  size: "icon-sm",
132
193
  variant: "ghost",
@@ -1 +1 @@
1
- {"version":3,"file":"data-grid-pagination.js","names":[],"sources":["../../../../src/components/reui/data-grid/data-grid-pagination.tsx"],"sourcesContent":["\"use client\";\n\nimport type { JSX, ReactNode } from \"react\";\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { Button } from \"../../ui/button\";\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from \"../../ui/select\";\nimport { Skeleton } from \"../../ui/skeleton\";\nimport { useDataGrid } from \"./data-grid\";\n\ninterface DataGridPaginationProps {\n sizes?: number[];\n sizesInfo?: string;\n sizesLabel?: string;\n sizesDescription?: string;\n sizesSkeleton?: ReactNode;\n more?: boolean;\n moreLimit?: number;\n info?: string;\n infoSkeleton?: ReactNode;\n className?: string;\n rowsPerPageLabel?: string;\n previousPageLabel?: string;\n nextPageLabel?: string;\n ellipsisText?: string;\n}\n\nfunction DataGridPagination(props: DataGridPaginationProps): JSX.Element {\n const { i18n, table, recordCount, isLoading } = useDataGrid();\n\n const defaultProps: Partial<DataGridPaginationProps> = {\n sizes: [5, 10, 25, 50, 100],\n sizesSkeleton: <Skeleton className=\"h-8 w-44\" />,\n moreLimit: 5,\n infoSkeleton: <Skeleton className=\"h-8 w-60\" />,\n rowsPerPageLabel: i18n.labels.rowsPerPage,\n previousPageLabel: i18n.labels.previousPage,\n nextPageLabel: i18n.labels.nextPage,\n ellipsisText: i18n.labels.paginationEllipsis,\n };\n\n const mergedProps: DataGridPaginationProps = { ...defaultProps, ...props };\n\n const btnBaseClasses = \"p-0 text-sm\";\n const btnArrowClasses = `${btnBaseClasses} rtl:transform rtl:rotate-180`;\n const pageIndex = table.state.pagination.pageIndex;\n const pageSize = table.state.pagination.pageSize;\n const from = recordCount === 0 ? 0 : pageIndex * pageSize + 1;\n const to = Math.min((pageIndex + 1) * pageSize, recordCount);\n const pageCount = table.getPageCount();\n\n // A supplied `info` keeps its placeholder-template contract; the default\n // routes through the i18n label function, where word order is free.\n const paginationInfo = mergedProps.info\n ? mergedProps.info\n .replaceAll(\"{from}\", from.toString())\n .replaceAll(\"{to}\", to.toString())\n .replaceAll(\"{count}\", recordCount.toString())\n : i18n.labels.paginationInfo({ from, to, count: recordCount });\n\n // Pagination limit logic\n const paginationMoreLimit = mergedProps.moreLimit || 5;\n\n // Determine the start and end of the pagination group\n const currentGroupStart = Math.floor(pageIndex / paginationMoreLimit) * paginationMoreLimit;\n const currentGroupEnd = Math.min(currentGroupStart + paginationMoreLimit, pageCount);\n\n // Render page buttons based on the current group\n const renderPageButtons = () => {\n const buttons = [];\n for (let i = currentGroupStart; i < currentGroupEnd; i++) {\n buttons.push(\n <Button\n key={i}\n size=\"icon-sm\"\n variant=\"ghost\"\n aria-label={i18n.labels.goToPage(i + 1)}\n aria-current={pageIndex === i ? \"page\" : undefined}\n className={cn(btnBaseClasses, \"text-muted-foreground\", {\n \"bg-accent text-accent-foreground\": pageIndex === i,\n })}\n onClick={() => {\n if (pageIndex !== i) {\n table.setPageIndex(i);\n }\n }}\n >\n {i + 1}\n </Button>,\n );\n }\n return buttons;\n };\n\n // Render a \"previous\" ellipsis button if there are previous pages to show\n const renderEllipsisPrevButton = () => {\n if (currentGroupStart > 0) {\n return (\n <Button\n size=\"icon-sm\"\n className={btnBaseClasses}\n variant=\"ghost\"\n onClick={() => table.setPageIndex(currentGroupStart - 1)}\n >\n {mergedProps.ellipsisText}\n </Button>\n );\n }\n return null;\n };\n\n // Render a \"next\" ellipsis button if there are more pages to show after the current group\n const renderEllipsisNextButton = () => {\n if (currentGroupEnd < pageCount) {\n return (\n <Button\n className={btnBaseClasses}\n variant=\"ghost\"\n size=\"icon-sm\"\n onClick={() => table.setPageIndex(currentGroupEnd)}\n >\n {mergedProps.ellipsisText}\n </Button>\n );\n }\n return null;\n };\n\n return (\n <div\n data-slot=\"data-grid-pagination\"\n className={cn(\n \"flex grow flex-col flex-wrap items-center justify-between gap-2.5 py-2.5 sm:flex-row sm:py-0\",\n mergedProps.className,\n )}\n >\n <div className=\"order-2 flex flex-wrap items-center space-x-2.5 pb-2.5 sm:order-1 sm:pb-0\">\n {isLoading ? (\n mergedProps.sizesSkeleton\n ) : (\n <>\n <div className=\"text-muted-foreground text-sm\">{mergedProps.rowsPerPageLabel}</div>\n <Select\n value={`${pageSize}`}\n onValueChange={(value) => {\n const newPageSize = Number(value);\n table.setPageSize(newPageSize);\n }}\n >\n {/* w-fit with a min, never a fixed width: a fixed w-16 clipped\n the value \"100\" by 1px at nova's paddings, while fit-content\n grows the trigger for 3-digit sizes and the min keeps the\n 1-2 digit ones from collapsing narrower than 64px. */}\n <SelectTrigger\n aria-label={mergedProps.rowsPerPageLabel}\n className=\"w-fit min-w-16\"\n size=\"sm\"\n >\n <SelectValue />\n </SelectTrigger>\n <SelectContent\n align=\"start\"\n alignItemWithTrigger={false}\n className=\"min-w-(--anchor-width)\"\n >\n {mergedProps.sizes?.map((size: number) => (\n <SelectItem key={size} value={`${size}`}>\n {size}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </>\n )}\n </div>\n <div className=\"order-1 flex flex-col items-center justify-center gap-2.5 pt-2.5 sm:order-2 sm:flex-row sm:justify-end sm:pt-0\">\n {isLoading ? (\n mergedProps.infoSkeleton\n ) : (\n <>\n <div className=\"order-2 text-nowrap text-muted-foreground text-sm sm:order-1\">\n {paginationInfo}\n </div>\n {pageCount > 1 && (\n <div className=\"order-1 flex items-center space-x-1\">\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className={btnArrowClasses}\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n <span className=\"sr-only\">{mergedProps.previousPageLabel}</span>\n <ChevronLeftIcon className=\"size-4\" />\n </Button>\n\n {renderEllipsisPrevButton()}\n\n {renderPageButtons()}\n\n {renderEllipsisNextButton()}\n\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className={btnArrowClasses}\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n <span className=\"sr-only\">{mergedProps.nextPageLabel}</span>\n <ChevronRightIcon className=\"size-4\" />\n </Button>\n </div>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n\nexport { DataGridPagination, type DataGridPaginationProps };\n"],"mappings":";;;;;;;;;AA4BA,SAAS,mBAAmB,OAA6C;CACvE,MAAM,EAAE,MAAM,OAAO,aAAa,cAAc,YAAY;CAa5D,MAAM,cAAuC;EAV3C,OAAO;GAAC;GAAG;GAAI;GAAI;GAAI;EAAG;EAC1B,eAAe,oBAAC,UAAD,EAAU,WAAU,WAAY,CAAA;EAC/C,WAAW;EACX,cAAc,oBAAC,UAAD,EAAU,WAAU,WAAY,CAAA;EAC9C,kBAAkB,KAAK,OAAO;EAC9B,mBAAmB,KAAK,OAAO;EAC/B,eAAe,KAAK,OAAO;EA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,UAAA,YAAY;MAAwB,CAAA,GAC/D,oBAAC,iBAAD,EAAiB,WAAU,SAAU,CAAA,CAC/B;;KAEP,yBAAyB;KAEzB,kBAAkB;KAElB,yBAAyB;KAE1B,qBAAC,QAAD;MACE,MAAK;MACL,SAAQ;MACR,WAAW;MACX,eAAe,MAAM,SAAS;MAC9B,UAAU,CAAC,MAAM,eAAe;MALlC,UAAA,CAOE,oBAAC,QAAD;OAAM,WAAU;OAAW,UAAA,YAAY;MAAoB,CAAA,GAC3D,oBAAC,kBAAD,EAAkB,WAAU,SAAU,CAAA,CAChC;;IACL;GAEP,CAAA,CAAA,EAAA,CAAA;EAED,CAAA,CACF;;AAET"}
1
+ {"version":3,"file":"data-grid-pagination.js","names":[],"sources":["../../../../src/components/reui/data-grid/data-grid-pagination.tsx"],"sourcesContent":["\"use client\";\n\nimport type { JSX, ReactNode } from \"react\";\nimport { ChevronLeftIcon, ChevronRightIcon } from \"lucide-react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { Button } from \"../../ui/button\";\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from \"../../ui/select\";\nimport { Skeleton } from \"../../ui/skeleton\";\nimport { useDataGrid } from \"./data-grid\";\n\ninterface DataGridPaginationProps {\n sizes?: number[];\n sizesInfo?: string;\n sizesLabel?: string;\n sizesDescription?: string;\n sizesSkeleton?: ReactNode;\n more?: boolean;\n /** Page buttons the truncated middle shows; the row adds first, last and\n * an ellipsis for each hidden stretch. Clamped to a minimum of 3. */\n moreLimit?: number;\n info?: string;\n infoSkeleton?: ReactNode;\n className?: string;\n rowsPerPageLabel?: string;\n previousPageLabel?: string;\n nextPageLabel?: string;\n ellipsisText?: string;\n}\n\n/**\n * One slot in the page row: a page button, or an ellipsis that jumps over the\n * pages it stands for.\n */\ntype DataGridPaginationItem =\n | { type: \"page\"; index: number }\n | { type: \"ellipsis\"; direction: \"previous\"; target: number }\n | { type: \"ellipsis\"; direction: \"next\"; target: number };\n\n/**\n * The adaptive window: first page, the run around the current one, last page,\n * with an ellipsis standing in for each hidden stretch. It replaced fixed\n * BLOCKS (1-5, then 6-10) because a block never shows the last page, so on a\n * 50-page grid there was no way to reach the end - the primitive wires only\n * `previousPage()` / `nextPage()`, so there is no last-page arrow either.\n *\n * `limit` is `moreLimit`: how many page buttons the truncated middle shows.\n * At the default of 5 this emits exactly the same rows as the block version\n * did at `moreLimit: 5`, so the prop keeps both its meaning and its default.\n * An ellipsis never stands for a single page, because the early return covers\n * every count a full row could hold.\n */\nfunction getDataGridPaginationItems(\n pageIndex: number,\n pageCount: number,\n limit: number,\n): DataGridPaginationItem[] {\n // Pages flanking the current one, per side. The run is rebuilt from it so\n // the count is always odd: an even `limit` would make the head and tail\n // rows one slot wider than the middle, and the footer would twitch as the\n // user pages through.\n const sibling = Math.max(0, Math.floor(((Math.floor(limit) || 3) - 3) / 2));\n const pages = sibling * 2 + 3;\n\n // Two ellipses cost the width of two pages, so below this there is nothing\n // to gain by hiding any.\n if (pageCount <= pages + 2) {\n return Array.from({ length: pageCount }, (_, index) => ({\n type: \"page\" as const,\n index,\n }));\n }\n\n if (pageIndex <= sibling + 2) {\n return [\n ...Array.from({ length: pages }, (_, index) => ({\n type: \"page\" as const,\n index,\n })),\n { type: \"ellipsis\", direction: \"next\", target: pages },\n { type: \"page\", index: pageCount - 1 },\n ];\n }\n\n if (pageIndex >= pageCount - sibling - 3) {\n return [\n { type: \"page\", index: 0 },\n {\n type: \"ellipsis\",\n direction: \"previous\",\n target: pageCount - pages - 1,\n },\n ...Array.from({ length: pages }, (_, offset) => ({\n type: \"page\" as const,\n index: pageCount - pages + offset,\n })),\n ];\n }\n\n return [\n { type: \"page\", index: 0 },\n {\n type: \"ellipsis\",\n direction: \"previous\",\n target: pageIndex - sibling - 1,\n },\n ...Array.from({ length: sibling * 2 + 1 }, (_, offset) => ({\n type: \"page\" as const,\n index: pageIndex - sibling + offset,\n })),\n { type: \"ellipsis\", direction: \"next\", target: pageIndex + sibling + 1 },\n { type: \"page\", index: pageCount - 1 },\n ];\n}\n\n/**\n * A page button is square at one digit and grows from there, so the row does\n * not reflow when the count crosses 10 or 100. The floor is each style's own\n * `icon-sm` square, which is also its `sm` HEIGHT, so the numbers stay square\n * and keep the arrows' height. Hardcoding one value would be right in three\n * styles and wrong in five.\n */\nconst PAGE_BUTTON_WIDTH_CLASS = \"min-w-7\";\n\nfunction DataGridPagination(props: DataGridPaginationProps): JSX.Element {\n const { i18n, table, recordCount, isLoading } = useDataGrid();\n\n const defaultProps: Partial<DataGridPaginationProps> = {\n sizes: [5, 10, 25, 50, 100],\n sizesSkeleton: <Skeleton className=\"h-8 w-44\" />,\n moreLimit: 5,\n infoSkeleton: <Skeleton className=\"h-8 w-60\" />,\n rowsPerPageLabel: i18n.labels.rowsPerPage,\n previousPageLabel: i18n.labels.previousPage,\n nextPageLabel: i18n.labels.nextPage,\n ellipsisText: i18n.labels.paginationEllipsis,\n };\n\n const mergedProps: DataGridPaginationProps = { ...defaultProps, ...props };\n\n const btnBaseClasses = \"p-0 text-sm\";\n const btnArrowClasses = `${btnBaseClasses} rtl:transform rtl:rotate-180`;\n const pageIndex = table.state.pagination.pageIndex;\n const pageSize = table.state.pagination.pageSize;\n const from = recordCount === 0 ? 0 : pageIndex * pageSize + 1;\n const to = Math.min((pageIndex + 1) * pageSize, recordCount);\n const pageCount = table.getPageCount();\n\n // A supplied `info` keeps its placeholder-template contract; the default\n // routes through the i18n label function, where word order is free.\n const paginationInfo = mergedProps.info\n ? mergedProps.info\n .replaceAll(\"{from}\", from.toString())\n .replaceAll(\"{to}\", to.toString())\n .replaceAll(\"{count}\", recordCount.toString())\n : i18n.labels.paginationInfo({ from, to, count: recordCount });\n\n const paginationItems = getDataGridPaginationItems(\n pageIndex,\n pageCount,\n mergedProps.moreLimit ?? 5,\n );\n\n return (\n <div\n data-slot=\"data-grid-pagination\"\n className={cn(\n \"flex grow flex-col flex-wrap items-center justify-between gap-2.5 py-2.5 sm:flex-row sm:py-0\",\n mergedProps.className,\n )}\n >\n <div className=\"order-2 flex flex-wrap items-center space-x-2.5 pb-2.5 sm:order-1 sm:pb-0\">\n {isLoading ? (\n mergedProps.sizesSkeleton\n ) : (\n <>\n <div className=\"text-muted-foreground text-sm\">{mergedProps.rowsPerPageLabel}</div>\n <Select\n value={`${pageSize}`}\n onValueChange={(value) => {\n const newPageSize = Number(value);\n table.setPageSize(newPageSize);\n }}\n >\n {/* w-fit with a min, never a fixed width: a fixed w-16 clipped\n the value \"100\" by 1px at nova's paddings, while fit-content\n grows the trigger for 3-digit sizes and the min keeps the\n 1-2 digit ones from collapsing narrower than 64px. */}\n <SelectTrigger\n aria-label={mergedProps.rowsPerPageLabel}\n className=\"w-fit min-w-16\"\n size=\"sm\"\n >\n <SelectValue />\n </SelectTrigger>\n <SelectContent\n align=\"start\"\n alignItemWithTrigger={false}\n className=\"min-w-(--anchor-width)\"\n >\n {mergedProps.sizes?.map((size: number) => (\n <SelectItem key={size} value={`${size}`}>\n {size}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </>\n )}\n </div>\n <div className=\"order-1 flex flex-col items-center justify-center gap-2.5 pt-2.5 sm:order-2 sm:flex-row sm:justify-end sm:pt-0\">\n {isLoading ? (\n mergedProps.infoSkeleton\n ) : (\n <>\n <div className=\"order-2 text-nowrap text-muted-foreground text-sm sm:order-1\">\n {paginationInfo}\n </div>\n {pageCount > 1 && (\n <div className=\"order-1 flex flex-wrap items-center justify-center gap-1 sm:flex-nowrap\">\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className={btnArrowClasses}\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n <span className=\"sr-only\">{mergedProps.previousPageLabel}</span>\n <ChevronLeftIcon className=\"size-4\" />\n </Button>\n\n {paginationItems.map((item) =>\n item.type === \"page\" ? (\n <Button\n key={`page-${item.index}`}\n size=\"sm\"\n variant=\"ghost\"\n aria-label={i18n.labels.goToPage(item.index + 1)}\n aria-current={pageIndex === item.index ? \"page\" : undefined}\n className={cn(\n PAGE_BUTTON_WIDTH_CLASS,\n \"px-1.5 text-sm\",\n \"text-muted-foreground\",\n {\n \"bg-accent text-accent-foreground\": pageIndex === item.index,\n },\n )}\n onClick={() => {\n if (pageIndex !== item.index) {\n table.setPageIndex(item.index);\n }\n }}\n >\n {item.index + 1}\n </Button>\n ) : (\n /* Clickable, unlike the shadcn PaginationEllipsis, which is\n an aria-hidden span. This one MOVES the user, so it needs\n a name saying where. */\n <Button\n key={`ellipsis-${item.direction}`}\n size=\"icon-sm\"\n className={btnBaseClasses}\n variant=\"ghost\"\n aria-label={i18n.labels.goToPage(item.target + 1)}\n onClick={() => table.setPageIndex(item.target)}\n >\n {mergedProps.ellipsisText}\n </Button>\n ),\n )}\n\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className={btnArrowClasses}\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n <span className=\"sr-only\">{mergedProps.nextPageLabel}</span>\n <ChevronRightIcon className=\"size-4\" />\n </Button>\n </div>\n )}\n </>\n )}\n </div>\n </div>\n );\n}\n\nexport { DataGridPagination, type DataGridPaginationProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAS,2BACP,WACA,WACA,OAC0B;CAK1B,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,QAAQ,KAAK,MAAM,KAAK,KAAK,KAAK,KAAK,CAAC,CAAC;CAC1E,MAAM,QAAQ,UAAU,IAAI;CAI5B,IAAI,aAAa,QAAQ,GACvB,OAAO,MAAM,KAAK,EAAE,QAAQ,UAAU,IAAI,GAAG,WAAW;EACtD,MAAM;EACN;CACF,EAAE;CAGJ,IAAI,aAAa,UAAU,GACzB,OAAO;EACL,GAAG,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,WAAW;GAC9C,MAAM;GACN;EACF,EAAE;EACF;GAAE,MAAM;GAAY,WAAW;GAAQ,QAAQ;EAAM;EACrD;GAAE,MAAM;GAAQ,OAAO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AAK;MACL,SAAQ;MACR,WAAW;MACX,eAAe,MAAM,aAAa;MAClC,UAAU,CAAC,MAAM,mBAAmB;MALtC,UAAA,CAOE,oBAAC,QAAD;OAAM,WAAU;OAAW,UAAA,YAAY;MAAwB,CAAA,GAC/D,oBAAC,iBAAD,EAAiB,WAAU,SAAU,CAAA,CAC/B;;KAEP,gBAAgB,KAAK,SACpB,KAAK,SAAS,SACZ,oBAAC,QAAD;MAEE,MAAK;MACL,SAAQ;MACR,cAAY,KAAK,OAAO,SAAS,KAAK,QAAQ,CAAC;MAC/C,gBAAc,cAAc,KAAK,QAAQ,SAAS,KAAA;MAClD,WAAW,GACT,yBACA,kBACA,yBACA,EACE,oCAAoC,cAAc,KAAK,MACzD,CACF;MACA,eAAe;OACb,IAAI,cAAc,KAAK,OACrB,MAAM,aAAa,KAAK,KAAK;MAEjC;MAEC,UAAA,KAAK,QAAQ;KACR,GApBD,QAAQ,KAAK,OAoBZ,IAKR,oBAAC,QAAD;MAEE,MAAK;MACL,WAAW;MACX,SAAQ;MACR,cAAY,KAAK,OAAO,SAAS,KAAK,SAAS,CAAC;MAChD,eAAe,MAAM,aAAa,KAAK,MAAM;MAE5C,UAAA,YAAY;KACP,GARD,YAAY,KAAK,WAQhB,CAEZ;KAEA,qBAAC,QAAD;MACE,MAAK;MACL,SAAQ;MACR,WAAW;MACX,eAAe,MAAM,SAAS;MAC9B,UAAU,CAAC,MAAM,eAAe;MALlC,UAAA,CAOE,oBAAC,QAAD;OAAM,WAAU;OAAW,UAAA,YAAY;MAAoB,CAAA,GAC3D,oBAAC,kBAAD,EAAkB,WAAU,SAAU,CAAA,CAChC;;IACL;GAEP,CAAA,CAAA,EAAA,CAAA;EAED,CAAA,CACF;;AAET"}
@@ -559,7 +559,7 @@ function DataGridTableHeadRowCellResize({ header }) {
559
559
  onDoubleClick: () => column.resetSize(),
560
560
  onMouseDown: handleMouseDown,
561
561
  onTouchStart: handleTouchStart,
562
- className: cn("user-select-none absolute top-0 z-10 flex h-full cursor-col-resize touch-none", isPinned === "end" ? cn("start-0 w-5 justify-start", props.tableLayout?.columnsPinnable ? "before:hidden" : "before:absolute before:inset-y-0 before:start-0 before:w-px before:bg-border") : isLastVisibleColumn ? "end-0 w-5 justify-end before:hidden" : isPinned ? cn("end-0 w-5 justify-end", props.tableLayout?.columnsPinnable ? "before:hidden" : "before:absolute before:inset-y-0 before:end-0 before:w-px before:bg-border") : cn("-end-2 w-5 justify-center", props.tableLayout?.cellBorder ? "before:hidden" : "before:absolute before:inset-y-0 before:w-px before:-translate-x-px before:bg-border"), column.getIsResizing() && (isResizeModeOnEnd ? "opacity-100" : isLastVisibleColumn ? "opacity-100 before:absolute before:inset-y-0 before:end-0 before:block before:w-0.5 before:bg-primary" : "opacity-100 before:block before:w-0.5 before:bg-primary"))
562
+ className: cn("absolute top-0 z-10 flex h-full cursor-col-resize touch-none select-none", isPinned === "end" ? cn("start-0 w-5 justify-start", props.tableLayout?.columnsPinnable ? "before:hidden" : "before:absolute before:inset-y-0 before:start-0 before:w-px before:bg-border") : isLastVisibleColumn ? "end-0 w-5 justify-end before:hidden" : isPinned ? cn("end-0 w-5 justify-end", props.tableLayout?.columnsPinnable ? "before:hidden" : "before:absolute before:inset-y-0 before:end-0 before:w-px before:bg-border") : cn("-end-2 w-5 justify-center", props.tableLayout?.cellBorder ? "before:hidden" : "before:absolute before:inset-y-0 before:w-px before:-translate-x-px before:bg-border"), column.getIsResizing() && (isResizeModeOnEnd ? "opacity-100" : isLastVisibleColumn ? "opacity-100 before:absolute before:inset-y-0 before:end-0 before:block before:w-0.5 before:bg-primary" : "opacity-100 before:block before:w-0.5 before:bg-primary"))
563
563
  });
564
564
  }
565
565
  function DataGridTableResizeIndicator({ viewportNodeRef }) {