@giddaa-housing/ui 1.0.0 → 1.2.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 (331) hide show
  1. package/css/generated/shared.css +1 -1
  2. package/css/giddaa.css +12 -2
  3. package/dist/accordion.d.ts +9 -10
  4. package/dist/accordion.js +41 -87
  5. package/dist/activity-timeline.d.ts +12 -16
  6. package/dist/activity-timeline.js +83 -198
  7. package/dist/alert.d.ts +8 -9
  8. package/dist/alert.js +53 -111
  9. package/dist/auth-layout.d.ts +4 -4
  10. package/dist/auth-layout.js +143 -294
  11. package/dist/avatar.d.ts +6 -6
  12. package/dist/avatar.js +49 -19
  13. package/dist/badge.d.ts +12 -14
  14. package/dist/badge.js +71 -11
  15. package/dist/bar-chart.d.ts +65 -67
  16. package/dist/bar-chart.js +232 -207
  17. package/dist/breadcrumb.d.ts +5 -5
  18. package/dist/breadcrumb.js +56 -118
  19. package/dist/bullet-chart.d.ts +41 -37
  20. package/dist/bullet-chart.js +125 -148
  21. package/dist/button-BZIeyUw6.d.ts +17 -0
  22. package/dist/button-group.d.ts +13 -16
  23. package/dist/button-group.js +39 -88
  24. package/dist/button.d.ts +2 -19
  25. package/dist/button.js +94 -13
  26. package/dist/calendar.d.ts +6 -6
  27. package/dist/calendar.js +138 -17
  28. package/dist/card.d.ts +14 -16
  29. package/dist/card.js +59 -145
  30. package/dist/carousel.d.ts +34 -35
  31. package/dist/carousel.js +335 -20
  32. package/dist/chart.d.ts +90 -63
  33. package/dist/chart.js +573 -28
  34. package/dist/checkbox.d.ts +10 -12
  35. package/dist/checkbox.js +82 -47
  36. package/dist/cn-BI_4DMBf.js +23 -0
  37. package/dist/collapsible.d.ts +7 -8
  38. package/dist/collapsible.js +22 -47
  39. package/dist/combobox.d.ts +10 -10
  40. package/dist/combobox.js +236 -44
  41. package/dist/cta.d.ts +12 -14
  42. package/dist/cta.js +175 -341
  43. package/dist/currency-selector.d.ts +31 -32
  44. package/dist/currency-selector.js +106 -184
  45. package/dist/data-table.d.ts +168 -0
  46. package/dist/data-table.js +676 -0
  47. package/dist/date-picker.d.ts +22 -23
  48. package/dist/date-picker.js +119 -192
  49. package/dist/details-card.d.ts +7 -7
  50. package/dist/details-card.js +104 -253
  51. package/dist/dialog.d.ts +13 -14
  52. package/dist/dialog.js +116 -209
  53. package/dist/dropdown-menu.d.ts +13 -13
  54. package/dist/dropdown-menu.js +180 -37
  55. package/dist/dropzone.d.ts +55 -55
  56. package/dist/dropzone.js +327 -439
  57. package/dist/editorial-card.d.ts +23 -25
  58. package/dist/editorial-card.js +129 -296
  59. package/dist/empty-state.d.ts +8 -9
  60. package/dist/empty-state.js +48 -105
  61. package/dist/field.d.ts +23 -25
  62. package/dist/field.js +110 -221
  63. package/dist/filter.d.ts +118 -0
  64. package/dist/filter.js +775 -0
  65. package/dist/footer.d.ts +8 -15
  66. package/dist/footer.js +197 -400
  67. package/dist/funnel-chart.d.ts +49 -48
  68. package/dist/funnel-chart.js +170 -189
  69. package/dist/gallery-indicator.d.ts +11 -12
  70. package/dist/gallery-indicator.js +75 -12
  71. package/dist/heatmap-chart.d.ts +47 -50
  72. package/dist/heatmap-chart.js +186 -237
  73. package/dist/infotip.d.ts +8 -9
  74. package/dist/infotip.js +33 -59
  75. package/dist/input-CfoEJ8A6.d.ts +12 -0
  76. package/dist/input-group.d.ts +16 -20
  77. package/dist/input-group.js +99 -23
  78. package/dist/input-size-context-C-SFx9sx.d.ts +10 -0
  79. package/dist/input-size-context.d.ts +2 -11
  80. package/dist/input-size-context.js +17 -9
  81. package/dist/input.d.ts +2 -13
  82. package/dist/input.js +27 -11
  83. package/dist/item.d.ts +7 -8
  84. package/dist/item.js +22 -59
  85. package/dist/kpi-card.d.ts +18 -20
  86. package/dist/kpi-card.js +84 -192
  87. package/dist/label.d.ts +6 -6
  88. package/dist/label.js +40 -8
  89. package/dist/line-chart.d.ts +200 -129
  90. package/dist/line-chart.js +330 -105
  91. package/dist/list-item.d.ts +22 -0
  92. package/dist/list-item.js +84 -0
  93. package/dist/logo.d.ts +4 -4
  94. package/dist/logo.js +92 -9
  95. package/dist/map-indicator.d.ts +7 -7
  96. package/dist/map-indicator.js +80 -106
  97. package/dist/match.d.ts +10 -11
  98. package/dist/match.js +62 -107
  99. package/dist/media-gallery-hero.d.ts +40 -42
  100. package/dist/media-gallery-hero.js +182 -343
  101. package/dist/media-player.d.ts +17 -17
  102. package/dist/media-player.js +873 -1348
  103. package/dist/multi-step-form.d.ts +56 -0
  104. package/dist/multi-step-form.js +342 -0
  105. package/dist/number-input.d.ts +34 -34
  106. package/dist/number-input.js +64 -117
  107. package/dist/page-header.d.ts +10 -11
  108. package/dist/page-header.js +34 -79
  109. package/dist/pagination.d.ts +17 -21
  110. package/dist/pagination.js +132 -207
  111. package/dist/password-input.d.ts +5 -13
  112. package/dist/password-input.js +31 -55
  113. package/dist/phone-input.d.ts +19 -20
  114. package/dist/phone-input.js +226 -344
  115. package/dist/photo-gallery.d.ts +19 -19
  116. package/dist/photo-gallery.js +313 -449
  117. package/dist/picker-lzgmsNfG.js +32 -0
  118. package/dist/pie-chart.d.ts +121 -90
  119. package/dist/pie-chart.js +183 -149
  120. package/dist/popover.d.ts +9 -9
  121. package/dist/popover.js +72 -23
  122. package/dist/price-tag.d.ts +26 -27
  123. package/dist/price-tag.js +113 -173
  124. package/dist/progress.d.ts +16 -17
  125. package/dist/progress.js +169 -24
  126. package/dist/property-listing-card.d.ts +14 -17
  127. package/dist/property-listing-card.js +102 -220
  128. package/dist/purchase-option-card.d.ts +79 -0
  129. package/dist/purchase-option-card.js +176 -0
  130. package/dist/radar-chart.d.ts +29 -31
  131. package/dist/radar-chart.js +162 -137
  132. package/dist/radio-group.d.ts +11 -13
  133. package/dist/radio-group.js +46 -60
  134. package/dist/review-block.d.ts +14 -16
  135. package/dist/review-block.js +154 -10
  136. package/dist/rich-text-editor.d.ts +30 -14
  137. package/dist/rich-text-editor.js +592 -716
  138. package/dist/scatter-chart.d.ts +45 -47
  139. package/dist/scatter-chart.js +236 -240
  140. package/dist/search-input.d.ts +8 -16
  141. package/dist/search-input.js +57 -109
  142. package/dist/select.d.ts +8 -8
  143. package/dist/select.js +144 -27
  144. package/dist/separator.d.ts +8 -9
  145. package/dist/separator.js +32 -8
  146. package/dist/sheet.d.ts +11 -11
  147. package/dist/sheet.js +103 -24
  148. package/dist/sidebar.d.ts +32 -37
  149. package/dist/sidebar.js +364 -634
  150. package/dist/size-context-D4mYvcg8.d.ts +10 -0
  151. package/dist/size-context.d.ts +2 -11
  152. package/dist/size-context.js +17 -9
  153. package/dist/skeleton.d.ts +4 -5
  154. package/dist/skeleton.js +12 -8
  155. package/dist/slider.d.ts +8 -9
  156. package/dist/slider.js +64 -135
  157. package/dist/sparkline.d.ts +68 -58
  158. package/dist/sparkline.js +315 -251
  159. package/dist/stepper.d.ts +23 -24
  160. package/dist/stepper.js +149 -246
  161. package/dist/styles.css +1004 -116
  162. package/dist/switch.d.ts +10 -12
  163. package/dist/switch.js +48 -70
  164. package/dist/table-card.d.ts +35 -0
  165. package/dist/table-card.js +125 -0
  166. package/dist/table.d.ts +18 -14
  167. package/dist/table.js +117 -154
  168. package/dist/tabs.d.ts +33 -15
  169. package/dist/tabs.js +110 -18
  170. package/dist/tag.d.ts +21 -23
  171. package/dist/tag.js +103 -159
  172. package/dist/testimonial-block.d.ts +18 -19
  173. package/dist/testimonial-block.js +189 -358
  174. package/dist/textarea-IS_D8pXf.d.ts +11 -0
  175. package/dist/textarea.d.ts +2 -12
  176. package/dist/textarea.js +24 -11
  177. package/dist/time-picker.d.ts +11 -11
  178. package/dist/time-picker.js +245 -302
  179. package/dist/toast.d.ts +16 -18
  180. package/dist/toast.js +154 -205
  181. package/dist/tooltip.d.ts +8 -9
  182. package/dist/tooltip.js +37 -12
  183. package/dist/tree-map.d.ts +59 -62
  184. package/dist/tree-map.js +226 -269
  185. package/dist/use-uncontrolled-CLfM1XbB.js +21 -0
  186. package/dist/waterfall-chart.d.ts +94 -97
  187. package/dist/waterfall-chart.js +455 -552
  188. package/package.json +36 -9
  189. package/dist/accordion.js.map +0 -1
  190. package/dist/activity-timeline.js.map +0 -1
  191. package/dist/alert.js.map +0 -1
  192. package/dist/auth-layout.js.map +0 -1
  193. package/dist/avatar.js.map +0 -1
  194. package/dist/badge.js.map +0 -1
  195. package/dist/bar-chart.js.map +0 -1
  196. package/dist/breadcrumb.js.map +0 -1
  197. package/dist/bullet-chart.js.map +0 -1
  198. package/dist/button-group.js.map +0 -1
  199. package/dist/button.js.map +0 -1
  200. package/dist/calendar.js.map +0 -1
  201. package/dist/card.js.map +0 -1
  202. package/dist/carousel.js.map +0 -1
  203. package/dist/chart.js.map +0 -1
  204. package/dist/checkbox.js.map +0 -1
  205. package/dist/chunk-322YCNVL.js +0 -278
  206. package/dist/chunk-322YCNVL.js.map +0 -1
  207. package/dist/chunk-3ACQVT7A.js +0 -25
  208. package/dist/chunk-3ACQVT7A.js.map +0 -1
  209. package/dist/chunk-3T65TLJX.js +0 -334
  210. package/dist/chunk-3T65TLJX.js.map +0 -1
  211. package/dist/chunk-6ZSGQHH2.js +0 -192
  212. package/dist/chunk-6ZSGQHH2.js.map +0 -1
  213. package/dist/chunk-7TBMLFGW.js +0 -41
  214. package/dist/chunk-7TBMLFGW.js.map +0 -1
  215. package/dist/chunk-B4H6RNDH.js +0 -135
  216. package/dist/chunk-B4H6RNDH.js.map +0 -1
  217. package/dist/chunk-BUXCGZ6X.js +0 -219
  218. package/dist/chunk-BUXCGZ6X.js.map +0 -1
  219. package/dist/chunk-CHII2QHH.js +0 -58
  220. package/dist/chunk-CHII2QHH.js.map +0 -1
  221. package/dist/chunk-DMNOXRRW.js +0 -147
  222. package/dist/chunk-DMNOXRRW.js.map +0 -1
  223. package/dist/chunk-EFSOSSIC.js +0 -130
  224. package/dist/chunk-EFSOSSIC.js.map +0 -1
  225. package/dist/chunk-FZDSVMKY.js +0 -363
  226. package/dist/chunk-FZDSVMKY.js.map +0 -1
  227. package/dist/chunk-GJOFIJS3.js +0 -246
  228. package/dist/chunk-GJOFIJS3.js.map +0 -1
  229. package/dist/chunk-HL3ZSYES.js +0 -23
  230. package/dist/chunk-HL3ZSYES.js.map +0 -1
  231. package/dist/chunk-JVLUBAPB.js +0 -129
  232. package/dist/chunk-JVLUBAPB.js.map +0 -1
  233. package/dist/chunk-KDPYSOYZ.js +0 -64
  234. package/dist/chunk-KDPYSOYZ.js.map +0 -1
  235. package/dist/chunk-KSMDANKI.js +0 -43
  236. package/dist/chunk-KSMDANKI.js.map +0 -1
  237. package/dist/chunk-MEKCCOP5.js +0 -46
  238. package/dist/chunk-MEKCCOP5.js.map +0 -1
  239. package/dist/chunk-NOFXVRWL.js +0 -451
  240. package/dist/chunk-NOFXVRWL.js.map +0 -1
  241. package/dist/chunk-PC5MHNVA.js +0 -171
  242. package/dist/chunk-PC5MHNVA.js.map +0 -1
  243. package/dist/chunk-QKAQZ2GU.js +0 -122
  244. package/dist/chunk-QKAQZ2GU.js.map +0 -1
  245. package/dist/chunk-QZHSHSVV.js +0 -26
  246. package/dist/chunk-QZHSHSVV.js.map +0 -1
  247. package/dist/chunk-RBMK26XD.js +0 -19
  248. package/dist/chunk-RBMK26XD.js.map +0 -1
  249. package/dist/chunk-SFNJGF6M.js +0 -262
  250. package/dist/chunk-SFNJGF6M.js.map +0 -1
  251. package/dist/chunk-UJJNLGTM.js +0 -112
  252. package/dist/chunk-UJJNLGTM.js.map +0 -1
  253. package/dist/chunk-VGR4ZWJ3.js +0 -418
  254. package/dist/chunk-VGR4ZWJ3.js.map +0 -1
  255. package/dist/chunk-XG47P6D4.js +0 -99
  256. package/dist/chunk-XG47P6D4.js.map +0 -1
  257. package/dist/chunk-XZZAHNVM.js +0 -21
  258. package/dist/chunk-XZZAHNVM.js.map +0 -1
  259. package/dist/chunk-Y4TTYVNE.js +0 -36
  260. package/dist/chunk-Y4TTYVNE.js.map +0 -1
  261. package/dist/chunk-YDWIHW6Q.js +0 -69
  262. package/dist/chunk-YDWIHW6Q.js.map +0 -1
  263. package/dist/collapsible.js.map +0 -1
  264. package/dist/combobox.js.map +0 -1
  265. package/dist/cta.js.map +0 -1
  266. package/dist/currency-selector.js.map +0 -1
  267. package/dist/date-picker.js.map +0 -1
  268. package/dist/details-card.js.map +0 -1
  269. package/dist/dialog.js.map +0 -1
  270. package/dist/dropdown-menu.js.map +0 -1
  271. package/dist/dropzone.js.map +0 -1
  272. package/dist/editorial-card.js.map +0 -1
  273. package/dist/empty-state.js.map +0 -1
  274. package/dist/field.js.map +0 -1
  275. package/dist/footer.js.map +0 -1
  276. package/dist/funnel-chart.js.map +0 -1
  277. package/dist/gallery-indicator.js.map +0 -1
  278. package/dist/heatmap-chart.js.map +0 -1
  279. package/dist/infotip.js.map +0 -1
  280. package/dist/input-group.js.map +0 -1
  281. package/dist/input-size-context.js.map +0 -1
  282. package/dist/input.js.map +0 -1
  283. package/dist/item.js.map +0 -1
  284. package/dist/kpi-card.js.map +0 -1
  285. package/dist/label.js.map +0 -1
  286. package/dist/line-chart.js.map +0 -1
  287. package/dist/logo.js.map +0 -1
  288. package/dist/map-indicator.js.map +0 -1
  289. package/dist/match.js.map +0 -1
  290. package/dist/media-gallery-hero.js.map +0 -1
  291. package/dist/media-player.js.map +0 -1
  292. package/dist/number-input.js.map +0 -1
  293. package/dist/page-header.js.map +0 -1
  294. package/dist/pagination.js.map +0 -1
  295. package/dist/password-input.js.map +0 -1
  296. package/dist/phone-input.js.map +0 -1
  297. package/dist/photo-gallery.js.map +0 -1
  298. package/dist/pie-chart.js.map +0 -1
  299. package/dist/popover.js.map +0 -1
  300. package/dist/price-tag.js.map +0 -1
  301. package/dist/progress.js.map +0 -1
  302. package/dist/property-listing-card.js.map +0 -1
  303. package/dist/radar-chart.js.map +0 -1
  304. package/dist/radio-group.js.map +0 -1
  305. package/dist/review-block.js.map +0 -1
  306. package/dist/rich-text-editor.js.map +0 -1
  307. package/dist/scatter-chart.js.map +0 -1
  308. package/dist/search-input.js.map +0 -1
  309. package/dist/select.js.map +0 -1
  310. package/dist/separator.js.map +0 -1
  311. package/dist/sheet.js.map +0 -1
  312. package/dist/sidebar.js.map +0 -1
  313. package/dist/size-context.js.map +0 -1
  314. package/dist/skeleton.js.map +0 -1
  315. package/dist/slider.js.map +0 -1
  316. package/dist/sparkline.js.map +0 -1
  317. package/dist/stepper.js.map +0 -1
  318. package/dist/switch.js.map +0 -1
  319. package/dist/tab-list.d.ts +0 -38
  320. package/dist/tab-list.js +0 -123
  321. package/dist/tab-list.js.map +0 -1
  322. package/dist/table.js.map +0 -1
  323. package/dist/tabs.js.map +0 -1
  324. package/dist/tag.js.map +0 -1
  325. package/dist/testimonial-block.js.map +0 -1
  326. package/dist/textarea.js.map +0 -1
  327. package/dist/time-picker.js.map +0 -1
  328. package/dist/toast.js.map +0 -1
  329. package/dist/tooltip.js.map +0 -1
  330. package/dist/tree-map.js.map +0 -1
  331. package/dist/waterfall-chart.js.map +0 -1
@@ -0,0 +1,676 @@
1
+ "use client";
2
+ import { t as cn } from "./cn-BI_4DMBf.js";
3
+ import { Button } from "./button.js";
4
+ import { Input } from "./input.js";
5
+ import { Checkbox } from "./checkbox.js";
6
+ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
7
+ import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "./empty-state.js";
8
+ import { Filter, FilterApplyButton, FilterContent, FilterResetButton, FilterTrigger } from "./filter.js";
9
+ import { Pagination, PaginationButton, PaginationContent, PaginationEllipsis, PaginationItem } from "./pagination.js";
10
+ import { Popover, PopoverBody, PopoverContent, PopoverFooter, PopoverHeader, PopoverTitle, PopoverTrigger } from "./popover.js";
11
+ import { Skeleton } from "./skeleton.js";
12
+ import { Table as Table$1, TableBody, TableCell, TableHead, TableHeader, TableRow } from "./table.js";
13
+ import { TableCard, TableCardAction } from "./table-card.js";
14
+ import { ChevronDown, ChevronLeft, ChevronRight, ChevronUp, ChevronsUpDown, PinIcon, SearchX, SlidersHorizontal } from "lucide-react";
15
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
+ import * as React from "react";
17
+ import { flexRender, getCoreRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
18
+ //#region src/data-table.tsx
19
+ const DataTableContext = React.createContext(null);
20
+ const ROW_SELECT_COLUMN_ID = "row-select";
21
+ const ACTIONS_COLUMN_ID = "actions";
22
+ const DEFAULT_SKELETON_ROW_COUNT = 5;
23
+ const DEFAULT_PAGE_SIZE_OPTIONS = [
24
+ 10,
25
+ 25,
26
+ 50,
27
+ 100,
28
+ 200,
29
+ 500
30
+ ];
31
+ function useOptionalDataTableContext() {
32
+ return React.useContext(DataTableContext);
33
+ }
34
+ function useDataTableContext() {
35
+ const context = useOptionalDataTableContext();
36
+ if (!context) throw new Error("DataTable components must be rendered inside <DataTableRoot>.");
37
+ return context;
38
+ }
39
+ function getCommonPinningStyles(column) {
40
+ const isPinned = column.getIsPinned();
41
+ return {
42
+ left: isPinned === "left" ? `${column.getStart("left")}px` : void 0,
43
+ right: isPinned === "right" ? `${column.getAfter("right")}px` : void 0,
44
+ position: isPinned ? "sticky" : "relative",
45
+ width: column.getSize(),
46
+ zIndex: isPinned ? 1 : 0
47
+ };
48
+ }
49
+ function getPinnedSide(column) {
50
+ const isPinned = column.getIsPinned();
51
+ if (isPinned === "left" && column.getIsLastColumn("left")) return "left";
52
+ if (isPinned === "right" && column.getIsFirstColumn("right")) return "right";
53
+ }
54
+ function getDefaultColumnPinning(columns) {
55
+ const left = [];
56
+ const right = [];
57
+ for (const column of columns) {
58
+ if (!column.id || !column.meta?.isPinned) continue;
59
+ if (column.meta.pinPosition === "right") right.push(column.id);
60
+ else left.push(column.id);
61
+ }
62
+ return {
63
+ left,
64
+ right
65
+ };
66
+ }
67
+ function renderTableCellSkeleton(skeletonType = "default") {
68
+ if (skeletonType === "image-description") return /* @__PURE__ */ jsxs("div", {
69
+ className: "flex items-center gap-3",
70
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "size-10 shrink-0 rounded-full" }), /* @__PURE__ */ jsxs("div", {
71
+ className: "min-w-0 flex-1 space-y-2",
72
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-3.5 w-32 max-w-full rounded" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-48 max-w-full rounded" })]
73
+ })]
74
+ });
75
+ return /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full rounded" });
76
+ }
77
+ function useDataTable({ columns, data, enableRowSelection = false, initialState, getSortedRowModel: getSortedRowModelOption, ...options }) {
78
+ const resolvedColumns = React.useMemo(() => {
79
+ if (!enableRowSelection) return columns;
80
+ return [{
81
+ id: ROW_SELECT_COLUMN_ID,
82
+ meta: {
83
+ isPinned: true,
84
+ pinPosition: "left"
85
+ },
86
+ header: ({ table }) => /* @__PURE__ */ jsx(Checkbox, {
87
+ "aria-label": "Select all rows",
88
+ checked: table.getIsAllPageRowsSelected(),
89
+ onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value),
90
+ size: "sm"
91
+ }),
92
+ cell: ({ row }) => /* @__PURE__ */ jsx(Checkbox, {
93
+ "aria-label": "Select row",
94
+ checked: row.getIsSelected(),
95
+ onCheckedChange: (value) => row.toggleSelected(!!value),
96
+ size: "sm"
97
+ }),
98
+ enableHiding: false,
99
+ enablePinning: false,
100
+ enableSorting: false,
101
+ size: 56
102
+ }, ...columns];
103
+ }, [columns, enableRowSelection]);
104
+ const defaultColumnPinning = React.useMemo(() => getDefaultColumnPinning(resolvedColumns), [resolvedColumns]);
105
+ return useReactTable({
106
+ ...options,
107
+ columns: resolvedColumns,
108
+ data,
109
+ enableRowSelection,
110
+ getCoreRowModel: getCoreRowModel(),
111
+ getSortedRowModel: getSortedRowModelOption ?? getSortedRowModel(),
112
+ initialState: {
113
+ ...initialState,
114
+ columnPinning: {
115
+ ...defaultColumnPinning,
116
+ ...initialState?.columnPinning
117
+ }
118
+ }
119
+ });
120
+ }
121
+ function DataTableRoot({ children, className, isLoading, onRowClick, table, ...props }) {
122
+ const contextValue = {
123
+ isLoading,
124
+ onRowClick,
125
+ table
126
+ };
127
+ return /* @__PURE__ */ jsx(DataTableContext.Provider, {
128
+ value: contextValue,
129
+ children: /* @__PURE__ */ jsx("div", {
130
+ "data-slot": "data-table-root",
131
+ className: cn("flex w-full min-w-0 flex-col gap-4", className),
132
+ ...props,
133
+ children
134
+ })
135
+ });
136
+ }
137
+ function DataTableToolbar({ className, ...props }) {
138
+ return /* @__PURE__ */ jsx("div", {
139
+ "data-slot": "data-table-toolbar",
140
+ className: cn("flex flex-col justify-between gap-4 md:flex-row md:items-center", className),
141
+ ...props
142
+ });
143
+ }
144
+ function DataTableFilter({ applyButtonProps, children, closeOnApply = true, closeOnReset = true, contentProps, defaultJoin, defaultOpen = false, defaultValue, fields, footer, onApply, onOpenChange, open, popoverBodyProps, popoverContentProps, popoverFooterProps, popoverHeaderProps, resetButtonProps, size = "md", title = "Filter", trigger, triggerButtonProps, triggerCountClassName, triggerHideCountWhenZero, triggerLabel = "Filters" }) {
145
+ const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
146
+ const isOpenControlled = open !== void 0;
147
+ const resolvedOpen = open ?? internalOpen;
148
+ const { onApplySuccess, ...resolvedApplyButtonProps } = applyButtonProps ?? {};
149
+ const { onReset, ...resolvedResetButtonProps } = resetButtonProps ?? {};
150
+ const { className: triggerButtonClassName, ...resolvedTriggerButtonProps } = triggerButtonProps ?? {};
151
+ const { className: popoverContentClassName, ...resolvedPopoverContentProps } = popoverContentProps ?? {};
152
+ const { className: popoverHeaderClassName, ...resolvedPopoverHeaderProps } = popoverHeaderProps ?? {};
153
+ const { className: popoverBodyClassName, ...resolvedPopoverBodyProps } = popoverBodyProps ?? {};
154
+ const { className: popoverFooterClassName, ...resolvedPopoverFooterProps } = popoverFooterProps ?? {};
155
+ const handleOpenChange = (nextOpen) => {
156
+ if (!isOpenControlled) setInternalOpen(nextOpen);
157
+ onOpenChange?.(nextOpen);
158
+ };
159
+ return /* @__PURE__ */ jsx(Filter, {
160
+ defaultJoin,
161
+ defaultValue,
162
+ fields,
163
+ onApply,
164
+ children: /* @__PURE__ */ jsxs(Popover, {
165
+ open: resolvedOpen,
166
+ onOpenChange: handleOpenChange,
167
+ children: [/* @__PURE__ */ jsx(FilterTrigger, {
168
+ countClassName: triggerCountClassName,
169
+ hideCountWhenZero: triggerHideCountWhenZero,
170
+ children: /* @__PURE__ */ jsx(PopoverTrigger, { render: trigger ?? /* @__PURE__ */ jsxs(Button, {
171
+ className: cn("group", triggerButtonClassName),
172
+ size,
173
+ variant: "tertiary-outline",
174
+ ...resolvedTriggerButtonProps,
175
+ children: [
176
+ /* @__PURE__ */ jsx(SlidersHorizontal, { className: "shrink-0" }),
177
+ triggerLabel,
178
+ /* @__PURE__ */ jsx(ChevronDown, { className: "transition-transform group-data-popup-open:rotate-180" })
179
+ ]
180
+ }) })
181
+ }), /* @__PURE__ */ jsxs(PopoverContent, {
182
+ align: "end",
183
+ sideOffset: 12,
184
+ size: "sm",
185
+ ...resolvedPopoverContentProps,
186
+ className: cn("w-140 max-w-[calc(100vw-2rem)]", popoverContentClassName),
187
+ children: [
188
+ title ? /* @__PURE__ */ jsx(PopoverHeader, {
189
+ border: true,
190
+ ...resolvedPopoverHeaderProps,
191
+ className: cn("items-center", popoverHeaderClassName),
192
+ children: /* @__PURE__ */ jsx(PopoverTitle, { children: title })
193
+ }) : null,
194
+ /* @__PURE__ */ jsx(PopoverBody, {
195
+ ...resolvedPopoverBodyProps,
196
+ className: popoverBodyClassName,
197
+ children: children ?? /* @__PURE__ */ jsx(FilterContent, { ...contentProps })
198
+ }),
199
+ footer !== null ? /* @__PURE__ */ jsx(PopoverFooter, {
200
+ ...resolvedPopoverFooterProps,
201
+ className: popoverFooterClassName,
202
+ children: footer !== void 0 ? footer : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(FilterResetButton, {
203
+ ...resolvedResetButtonProps,
204
+ onReset: () => {
205
+ if (closeOnReset) handleOpenChange(false);
206
+ onReset?.();
207
+ }
208
+ }), /* @__PURE__ */ jsx(FilterApplyButton, {
209
+ ...resolvedApplyButtonProps,
210
+ onApplySuccess: () => {
211
+ if (closeOnApply) handleOpenChange(false);
212
+ onApplySuccess?.();
213
+ }
214
+ })] })
215
+ }) : null
216
+ ]
217
+ })]
218
+ })
219
+ });
220
+ }
221
+ function DataTable({ className, containerClassName, emptyState, interactiveColumnIds = [ACTIONS_COLUMN_ID, ROW_SELECT_COLUMN_ID], isLoading: isLoadingProp, loadingRowCount = DEFAULT_SKELETON_ROW_COUNT, onRowClick: onRowClickProp, table: tableProp, ...props }) {
222
+ const context = useOptionalDataTableContext();
223
+ const table = tableProp ?? context?.table;
224
+ const isLoading = isLoadingProp ?? context?.isLoading;
225
+ const onRowClick = onRowClickProp ?? context?.onRowClick;
226
+ if (!table) throw new Error("DataTable requires a table prop or DataTableRoot context.");
227
+ const rows = table.getRowModel().rows;
228
+ const isEmpty = !isLoading && rows.length === 0;
229
+ const skeletonRows = Array.from({ length: loadingRowCount }, (_, index) => index);
230
+ if (isEmpty && emptyState) return emptyState;
231
+ return /* @__PURE__ */ jsxs(Table$1, {
232
+ className: cn("table-fixed", className),
233
+ containerClassName: cn("max-h-[68vh] overflow-y-auto", containerClassName),
234
+ style: { width: table.getTotalSize() },
235
+ ...props,
236
+ children: [/* @__PURE__ */ jsx(TableHeader, {
237
+ sticky: true,
238
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => {
239
+ const isPinned = header.column.getIsPinned();
240
+ const pinnedSide = getPinnedSide(header.column);
241
+ return /* @__PURE__ */ jsx(TableHead, {
242
+ colSpan: header.colSpan,
243
+ pinnedSide,
244
+ style: getCommonPinningStyles(header.column),
245
+ children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs("div", {
246
+ className: "flex items-center gap-2",
247
+ children: [
248
+ flexRender(header.column.columnDef.header, header.getContext()),
249
+ header.column.getCanSort() ? /* @__PURE__ */ jsx("button", {
250
+ "aria-label": `Toggle sorting for ${header.column.id}`,
251
+ type: "button",
252
+ className: "shrink-0 cursor-pointer border-none bg-transparent p-0 outline-none",
253
+ onClick: header.column.getToggleSortingHandler(),
254
+ children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(ChevronUp, { className: "size-3.5 text-fg-primary" }) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(ChevronDown, { className: "size-3.5 text-fg-primary" }) : /* @__PURE__ */ jsx(ChevronsUpDown, { className: "size-3.5" })
255
+ }) : null,
256
+ header.column.getCanPin() ? /* @__PURE__ */ jsx("button", {
257
+ "aria-label": isPinned ? `Unpin ${header.column.id}` : `Pin ${header.column.id} to the left`,
258
+ type: "button",
259
+ className: "shrink-0 cursor-pointer border-none bg-transparent p-0 outline-none",
260
+ onClick: () => isPinned ? header.column.pin(false) : header.column.pin("left"),
261
+ children: /* @__PURE__ */ jsx(PinIcon, { className: cn("size-3.5", isPinned && "text-fg-brand") })
262
+ }) : null,
263
+ header.column.getCanResize() ? /* @__PURE__ */ jsx("button", {
264
+ "aria-label": "Resize column",
265
+ type: "button",
266
+ onDoubleClick: () => header.column.resetSize(),
267
+ onMouseDown: header.getResizeHandler(),
268
+ onTouchStart: header.getResizeHandler(),
269
+ className: cn("ml-auto h-6 w-0.5 cursor-col-resize rounded-[1px] border-0 bg-line p-0 outline-none", header.column.getIsResizing() && "w-1 bg-line-focus")
270
+ }) : null
271
+ ]
272
+ })
273
+ }, header.id);
274
+ }) }, headerGroup.id))
275
+ }), /* @__PURE__ */ jsx(TableBody, { children: isLoading ? skeletonRows.map((rowKey) => /* @__PURE__ */ jsx(TableRow, { children: table.getVisibleLeafColumns().map((column) => {
276
+ return /* @__PURE__ */ jsx(TableCell, {
277
+ pinned: !!column.getIsPinned(),
278
+ pinnedSide: getPinnedSide(column),
279
+ style: getCommonPinningStyles(column),
280
+ children: column.id === ROW_SELECT_COLUMN_ID ? /* @__PURE__ */ jsx(Skeleton, { className: "size-4 rounded-sm" }) : renderTableCellSkeleton(column.columnDef.meta?.skeletonType)
281
+ }, `${rowKey}-${column.id}`);
282
+ }) }, rowKey)) : rows.map((row) => /* @__PURE__ */ jsx(TableRow, {
283
+ "data-state": row.getIsSelected() ? "selected" : void 0,
284
+ onClick: () => onRowClick?.(row),
285
+ children: row.getVisibleCells().map((cell) => {
286
+ const isInteractiveColumn = interactiveColumnIds.includes(cell.column.id);
287
+ return /* @__PURE__ */ jsx(TableCell, {
288
+ pinned: !!cell.column.getIsPinned(),
289
+ pinnedSide: getPinnedSide(cell.column),
290
+ style: getCommonPinningStyles(cell.column),
291
+ className: cn(onRowClick && "cursor-pointer", cell.column.id === ACTIONS_COLUMN_ID && "text-center"),
292
+ onClick: isInteractiveColumn ? (event) => event.stopPropagation() : void 0,
293
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
294
+ }, cell.id);
295
+ })
296
+ }, row.id)) })]
297
+ });
298
+ }
299
+ function DataTableCardGrid({ actionsColumnId = ACTIONS_COLUMN_ID, badgeColumnId, className, detailColumnIds, emptyState, isLoading: isLoadingProp, loadingCardCount = DEFAULT_SKELETON_ROW_COUNT, onCardClick, renderActions, renderCard, subtitleColumnId, table: tableProp, titleColumnId, ...props }) {
300
+ const context = useOptionalDataTableContext();
301
+ const table = tableProp ?? context?.table;
302
+ const isLoading = isLoadingProp ?? context?.isLoading;
303
+ const handleCardClick = onCardClick ?? context?.onRowClick;
304
+ if (!table) throw new Error("DataTableCardGrid requires a table prop or DataTableRoot context.");
305
+ const rows = table.getRowModel().rows;
306
+ const isEmpty = !isLoading && rows.length === 0;
307
+ const resolvedTitleColumnId = titleColumnId ?? getColumnIdByCardMeta(table, "useAsCardTitle");
308
+ const resolvedSubtitleColumnId = subtitleColumnId ?? getColumnIdByCardMeta(table, "useAsCardSubtitle");
309
+ const resolvedBadgeColumnId = badgeColumnId ?? getColumnIdByCardMeta(table, "useAsCardBadge");
310
+ const resolvedDetailColumnIds = getDataTableCardDetailColumnIds({
311
+ actionsColumnId,
312
+ badgeColumnId: resolvedBadgeColumnId,
313
+ detailColumnIds,
314
+ subtitleColumnId: resolvedSubtitleColumnId,
315
+ table,
316
+ titleColumnId: resolvedTitleColumnId
317
+ });
318
+ const skeletonCards = Array.from({ length: loadingCardCount }, (_, index) => index);
319
+ if (isEmpty && emptyState) return emptyState;
320
+ return /* @__PURE__ */ jsx("div", {
321
+ "data-slot": "data-table-card-grid",
322
+ className: cn("grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3", className),
323
+ ...props,
324
+ children: isLoading ? skeletonCards.map((cardKey) => /* @__PURE__ */ jsxs(TableCard, {
325
+ "aria-hidden": true,
326
+ children: [
327
+ /* @__PURE__ */ jsxs("div", {
328
+ className: "flex min-w-0 items-start justify-between gap-4",
329
+ children: [/* @__PURE__ */ jsxs("div", {
330
+ className: "min-w-0 flex-1 space-y-2",
331
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-4/5 rounded" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-2/5 rounded" })]
332
+ }), /* @__PURE__ */ jsx(Skeleton, { className: "size-8 rounded-full" })]
333
+ }),
334
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-24 rounded-full" }),
335
+ /* @__PURE__ */ jsx("div", {
336
+ className: "space-y-3",
337
+ children: range(1, 4).map((detailKey) => /* @__PURE__ */ jsxs("div", {
338
+ className: "flex items-center justify-between gap-4 border-line-subtle border-t pt-3 first:border-t-0 first:pt-0",
339
+ children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20 rounded" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-28 rounded" })]
340
+ }, detailKey))
341
+ })
342
+ ]
343
+ }, cardKey)) : rows.map((row) => {
344
+ const actions = renderActions?.(row) ?? renderRowCellByColumnId(row, actionsColumnId);
345
+ const action = renderDataTableCardAction(row, handleCardClick);
346
+ const selection = renderDataTableCardSelection(row);
347
+ if (renderCard) return /* @__PURE__ */ jsx(React.Fragment, { children: renderCard(row, {
348
+ action,
349
+ actions,
350
+ row,
351
+ selection,
352
+ table
353
+ }) }, row.id);
354
+ const details = resolvedDetailColumnIds.map((columnId) => ({
355
+ label: getDataTableCardColumnLabel(table, columnId),
356
+ value: renderRowCellByColumnId(row, columnId)
357
+ }));
358
+ return /* @__PURE__ */ jsx(TableCard, {
359
+ action,
360
+ actions,
361
+ badge: resolvedBadgeColumnId ? renderRowCellByColumnId(row, resolvedBadgeColumnId) : null,
362
+ details,
363
+ selection,
364
+ selected: row.getIsSelected(),
365
+ subtitle: resolvedSubtitleColumnId ? renderRowCellByColumnId(row, resolvedSubtitleColumnId) : null,
366
+ title: resolvedTitleColumnId ? renderRowCellByColumnId(row, resolvedTitleColumnId) : row.id
367
+ }, row.id);
368
+ })
369
+ });
370
+ }
371
+ function renderDataTableCardAction(row, onCardClick) {
372
+ if (!onCardClick) return null;
373
+ return /* @__PURE__ */ jsx(TableCardAction, {
374
+ "aria-label": `Open row ${row.id}`,
375
+ onClick: () => onCardClick(row)
376
+ });
377
+ }
378
+ function renderDataTableCardSelection(row) {
379
+ if (!row.getCanSelect()) return null;
380
+ return /* @__PURE__ */ jsx(Checkbox, {
381
+ "aria-label": "Select row",
382
+ checked: row.getIsSelected(),
383
+ onCheckedChange: (value) => row.toggleSelected(!!value),
384
+ size: "sm"
385
+ });
386
+ }
387
+ function getColumnIdByCardMeta(table, metaKey) {
388
+ return table.getAllLeafColumns().find((column) => column.columnDef.meta?.[metaKey])?.id;
389
+ }
390
+ function getDataTableCardDetailColumnIds({ actionsColumnId, badgeColumnId, detailColumnIds, subtitleColumnId, table, titleColumnId }) {
391
+ if (detailColumnIds) return detailColumnIds;
392
+ const reservedColumnIds = /* @__PURE__ */ new Set([
393
+ ACTIONS_COLUMN_ID,
394
+ ROW_SELECT_COLUMN_ID,
395
+ actionsColumnId,
396
+ badgeColumnId,
397
+ subtitleColumnId,
398
+ titleColumnId
399
+ ]);
400
+ return table.getVisibleLeafColumns().filter((column) => !reservedColumnIds.has(column.id) && !column.columnDef.meta?.hideInCard).map((column) => column.id);
401
+ }
402
+ function getDataTableCardColumnLabel(table, columnId) {
403
+ const column = table.getAllLeafColumns().find((item) => item.id === columnId);
404
+ const header = column?.columnDef.header;
405
+ if (column?.columnDef.meta?.cardLabel) return column.columnDef.meta.cardLabel;
406
+ if (typeof header === "string") return header;
407
+ return column?.id ?? columnId;
408
+ }
409
+ function renderRowCellByColumnId(row, columnId) {
410
+ if (!columnId) return null;
411
+ const cell = row.getAllCells().find((item) => item.column.id === columnId);
412
+ if (!cell) return null;
413
+ return flexRender(cell.column.columnDef.cell, cell.getContext());
414
+ }
415
+ function DataTableBulkActions({ children, className, style, table: tableProp, ...props }) {
416
+ const context = useOptionalDataTableContext();
417
+ const table = tableProp ?? context?.table;
418
+ const barRef = React.useRef(null);
419
+ const [fixedStyle, setFixedStyle] = React.useState(null);
420
+ const [spacerHeight, setSpacerHeight] = React.useState(0);
421
+ if (!table) throw new Error("DataTableBulkActions requires a table prop or DataTable context.");
422
+ const selectedRows = table.getSelectedRowModel().rows;
423
+ React.useLayoutEffect(() => {
424
+ if (selectedRows.length === 0) {
425
+ setFixedStyle(null);
426
+ setSpacerHeight(0);
427
+ return;
428
+ }
429
+ const bar = barRef.current;
430
+ const container = bar?.parentElement;
431
+ if (!bar || !container) return;
432
+ const updatePosition = () => {
433
+ const containerRect = container.getBoundingClientRect();
434
+ const left = Math.max(containerRect.left, 16);
435
+ const right = Math.max(window.innerWidth - containerRect.right, 16);
436
+ const height = bar.offsetHeight;
437
+ setFixedStyle((currentStyle) => currentStyle?.left === left && currentStyle.right === right ? currentStyle : {
438
+ left,
439
+ right
440
+ });
441
+ setSpacerHeight((currentHeight) => currentHeight === height ? currentHeight : height);
442
+ };
443
+ updatePosition();
444
+ const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(updatePosition);
445
+ resizeObserver?.observe(container);
446
+ resizeObserver?.observe(bar);
447
+ window.addEventListener("resize", updatePosition);
448
+ window.addEventListener("scroll", updatePosition, true);
449
+ return () => {
450
+ resizeObserver?.disconnect();
451
+ window.removeEventListener("resize", updatePosition);
452
+ window.removeEventListener("scroll", updatePosition, true);
453
+ };
454
+ }, [selectedRows.length]);
455
+ if (selectedRows.length === 0) return null;
456
+ const content = typeof children === "function" ? children({
457
+ data: selectedRows.map((row) => row.original),
458
+ rows: selectedRows,
459
+ table
460
+ }) : children;
461
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
462
+ ref: barRef,
463
+ "data-slot": "data-table-bulk-actions",
464
+ className: cn("fixed bottom-4 z-50 flex items-center gap-4 rounded-xl border border-line bg-surface-overlay px-4 py-3 shadow-(--shadow-3)", !fixedStyle && "invisible", className),
465
+ style: {
466
+ ...fixedStyle,
467
+ ...style
468
+ },
469
+ ...props,
470
+ children: [/* @__PURE__ */ jsxs("span", {
471
+ className: "text-gdt-sm font-medium text-fg-secondary",
472
+ children: [selectedRows.length, " selected"]
473
+ }), /* @__PURE__ */ jsx("div", {
474
+ className: "flex items-center gap-2",
475
+ children: content
476
+ })]
477
+ }), /* @__PURE__ */ jsx("div", {
478
+ "aria-hidden": "true",
479
+ style: { height: spacerHeight }
480
+ })] });
481
+ }
482
+ function DataTablePagination({ className, controlAppearance = "icon", getSummaryLabel = ({ end, start, totalEntries }) => `Showing ${start} to ${end} of ${totalEntries} entries`, jumpToPageLabel = "Jump to page", nextLabel = "Next", onPageChange, page, pageCount: pageCountProp, pageSize: pageSizeProp, previousLabel = "Previous", showControls = true, showJumpToPage = true, showPreviousNext = true, showSummary = true, siblingCount = 1, table: tableProp, totalEntries: totalEntriesProp, ...props }) {
483
+ const context = useOptionalDataTableContext();
484
+ const table = tableProp ?? context?.table;
485
+ const tablePageSize = table?.getState().pagination.pageSize;
486
+ const pageSize = pageSizeProp ?? tablePageSize;
487
+ const totalEntries = totalEntriesProp ?? table?.getRowCount();
488
+ const derivedPageCount = totalEntries !== void 0 && pageSize ? Math.ceil(totalEntries / pageSize) : void 0;
489
+ if (!(page !== void 0 && (pageCountProp !== void 0 || derivedPageCount !== void 0)) && !table) throw new Error("DataTablePagination requires either a table (prop or DataTable context) or controlled `page` with `pageCount` or `totalEntries` + `pageSize`.");
490
+ const pageCount = pageCountProp ?? derivedPageCount ?? table?.getPageCount() ?? 0;
491
+ const currentPage = page ?? (table ? table.getState().pagination.pageIndex + 1 : 1);
492
+ if (!Number.isFinite(pageCount) || pageCount <= 1) return null;
493
+ const goToPage = (nextPage) => {
494
+ const clampedPage = Math.min(Math.max(nextPage, 1), pageCount);
495
+ if (clampedPage === currentPage) return;
496
+ if (onPageChange) onPageChange(clampedPage);
497
+ else table?.setPageIndex(clampedPage - 1);
498
+ };
499
+ const canPreviousPage = currentPage > 1;
500
+ const canNextPage = currentPage < pageCount;
501
+ const pages = getPaginationItems(currentPage, pageCount, siblingCount);
502
+ const startEntry = totalEntries !== void 0 && pageSize ? totalEntries === 0 ? 0 : (currentPage - 1) * pageSize + 1 : void 0;
503
+ const endEntry = totalEntries !== void 0 && pageSize ? Math.min(currentPage * pageSize, totalEntries) : void 0;
504
+ const summary = showSummary && totalEntries !== void 0 && pageSize !== void 0 && startEntry !== void 0 && endEntry !== void 0 ? getSummaryLabel({
505
+ end: endEntry,
506
+ page: currentPage,
507
+ pageSize,
508
+ start: startEntry,
509
+ totalEntries
510
+ }) : null;
511
+ return /* @__PURE__ */ jsxs("div", {
512
+ "data-slot": "data-table-pagination",
513
+ className: cn("flex w-full flex-col gap-4 text-gdt-sm text-fg-primary md:flex-row md:items-center md:justify-between", className),
514
+ children: [summary ? /* @__PURE__ */ jsx("p", {
515
+ "data-slot": "data-table-pagination-summary",
516
+ className: "text-fg-primary",
517
+ children: summary
518
+ }) : /* @__PURE__ */ jsx("span", {
519
+ "aria-hidden": true,
520
+ className: "hidden md:block"
521
+ }), /* @__PURE__ */ jsx(Pagination, {
522
+ className: "mx-0 w-auto justify-start md:justify-end",
523
+ ...props,
524
+ children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
525
+ showControls && showPreviousNext ? /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsxs(PaginationButton, {
526
+ "aria-label": "Go to previous page",
527
+ appearance: controlAppearance,
528
+ disabled: !canPreviousPage,
529
+ onClick: () => goToPage(currentPage - 1),
530
+ page: Math.max(1, currentPage - 1),
531
+ children: [/* @__PURE__ */ jsx(ChevronLeft, { className: "cn-rtl-flip" }), controlAppearance === "control" ? previousLabel : null]
532
+ }) }) : null,
533
+ showControls ? pages.map((paginationPage, index) => paginationPage === "ellipsis" ? /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }, `ellipsis-${index.toString()}`) : /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationButton, {
534
+ isActive: paginationPage === currentPage,
535
+ onClick: () => goToPage(paginationPage),
536
+ page: paginationPage,
537
+ children: paginationPage
538
+ }) }, paginationPage)) : null,
539
+ showControls && showPreviousNext ? /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsxs(PaginationButton, {
540
+ "aria-label": "Go to next page",
541
+ appearance: controlAppearance,
542
+ disabled: !canNextPage,
543
+ onClick: () => goToPage(currentPage + 1),
544
+ page: Math.min(pageCount, currentPage + 1),
545
+ children: [controlAppearance === "control" ? nextLabel : null, /* @__PURE__ */ jsx(ChevronRight, { className: "cn-rtl-flip" })]
546
+ }) }) : null,
547
+ showJumpToPage ? /* @__PURE__ */ jsx(DataTablePaginationJumpToPage, {
548
+ currentPage,
549
+ label: jumpToPageLabel,
550
+ onSubmit: goToPage,
551
+ totalPages: pageCount
552
+ }) : null
553
+ ] })
554
+ })]
555
+ });
556
+ }
557
+ function DataTablePaginationJumpToPage({ currentPage, label, onSubmit, totalPages }) {
558
+ const inputId = React.useId();
559
+ const [value, setValue] = React.useState(currentPage.toString());
560
+ React.useEffect(() => {
561
+ setValue(currentPage.toString());
562
+ }, [currentPage]);
563
+ const commitValue = (nextValue) => {
564
+ if (nextValue.trim() === "") {
565
+ setValue(currentPage.toString());
566
+ return;
567
+ }
568
+ const parsedPage = Number.parseInt(nextValue, 10);
569
+ if (!Number.isFinite(parsedPage)) {
570
+ setValue(currentPage.toString());
571
+ return;
572
+ }
573
+ const clampedPage = clampPage(parsedPage, totalPages);
574
+ setValue(clampedPage.toString());
575
+ onSubmit(clampedPage);
576
+ };
577
+ return /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsxs("label", {
578
+ htmlFor: inputId,
579
+ className: "ml-2 flex items-center gap-3 text-gdt-sm font-normal text-fg-secondary",
580
+ children: [/* @__PURE__ */ jsx("span", { children: label }), /* @__PURE__ */ jsx(Input, {
581
+ id: inputId,
582
+ type: "number",
583
+ inputMode: "numeric",
584
+ min: 1,
585
+ max: totalPages,
586
+ size: "sm",
587
+ value,
588
+ className: "w-16 rounded-md text-center text-fg-primary [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
589
+ "aria-label": typeof label === "string" ? label : "Jump to page",
590
+ onChange: (event) => {
591
+ setValue(event.target.value);
592
+ },
593
+ onBlur: (event) => {
594
+ commitValue(event.target.value);
595
+ },
596
+ onKeyDown: (event) => {
597
+ if (event.key === "Enter") {
598
+ event.preventDefault();
599
+ commitValue(event.currentTarget.value);
600
+ }
601
+ }
602
+ })]
603
+ }) });
604
+ }
605
+ function clampPage(page, totalPages) {
606
+ return Math.min(Math.max(page, 1), totalPages);
607
+ }
608
+ function getPaginationItems(currentPage, pageCount, siblingCount) {
609
+ const boundaryCount = 1;
610
+ const startPages = range(1, Math.min(boundaryCount, pageCount));
611
+ const endPages = range(Math.max(pageCount - boundaryCount + 1, 2), pageCount);
612
+ const siblingsStart = Math.max(Math.min(currentPage - siblingCount, pageCount - boundaryCount - siblingCount * 2 - 1), 3);
613
+ const siblingsEnd = Math.min(Math.max(currentPage + siblingCount, boundaryCount + siblingCount * 2 + 2), endPages.length > 0 ? endPages[0] - 2 : pageCount - 1);
614
+ const items = [...startPages];
615
+ if (siblingsStart > 3) items.push("ellipsis");
616
+ else if (2 < pageCount - boundaryCount) items.push(2);
617
+ items.push(...range(siblingsStart, siblingsEnd));
618
+ if (siblingsEnd < pageCount - boundaryCount - 1) items.push("ellipsis");
619
+ else if (pageCount - boundaryCount > boundaryCount) items.push(pageCount - boundaryCount);
620
+ items.push(...endPages);
621
+ return items;
622
+ }
623
+ function range(start, end) {
624
+ const length = end - start + 1;
625
+ if (length <= 0) return [];
626
+ return Array.from({ length }, (_, index) => start + index);
627
+ }
628
+ function DataTablePageSizeSelect({ className, label = (pageSize) => `Showing ${pageSize} entries`, onPageSizeChange, pageSize: pageSizeProp, pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS, size = "md", table: tableProp }) {
629
+ const context = useOptionalDataTableContext();
630
+ const table = tableProp ?? context?.table;
631
+ if (!(pageSizeProp !== void 0) && !table) throw new Error("DataTablePageSizeSelect requires either a table (prop or DataTable context) or the controlled `pageSize` prop.");
632
+ const pageSize = pageSizeProp ?? table?.getState().pagination.pageSize ?? DEFAULT_PAGE_SIZE_OPTIONS[0];
633
+ const handleValueChange = (value) => {
634
+ if (value === null) return;
635
+ const nextPageSize = Number(value);
636
+ if (onPageSizeChange) onPageSizeChange(nextPageSize);
637
+ else table?.setPageSize(nextPageSize);
638
+ };
639
+ const selectSize = size === "sm" || size === "md" || size === "lg" ? size : void 0;
640
+ return /* @__PURE__ */ jsxs(Select, {
641
+ value: pageSize.toString(),
642
+ onValueChange: handleValueChange,
643
+ size: selectSize,
644
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
645
+ unstyled: true,
646
+ render: /* @__PURE__ */ jsx(Button, {
647
+ variant: "tertiary-outline",
648
+ size,
649
+ className
650
+ }),
651
+ children: /* @__PURE__ */ jsx(SelectValue, { children: () => label(pageSize) })
652
+ }), /* @__PURE__ */ jsx(SelectContent, {
653
+ side: "top",
654
+ children: pageSizeOptions.map((option) => /* @__PURE__ */ jsx(SelectItem, {
655
+ value: option.toString(),
656
+ children: option
657
+ }, option))
658
+ })]
659
+ });
660
+ }
661
+ function DataTableEmptyState({ action, className, description = "Try adjusting your search or filters to find what you need.", title = "No results found", ...props }) {
662
+ return /* @__PURE__ */ jsxs(Empty, {
663
+ className: cn("min-h-60 rounded-[20px] border border-line bg-canvas", className),
664
+ ...props,
665
+ children: [/* @__PURE__ */ jsxs(EmptyHeader, { children: [
666
+ /* @__PURE__ */ jsx(EmptyMedia, {
667
+ variant: "icon",
668
+ children: /* @__PURE__ */ jsx(SearchX, {})
669
+ }),
670
+ /* @__PURE__ */ jsx(EmptyTitle, { children: title }),
671
+ description ? /* @__PURE__ */ jsx(EmptyDescription, { children: description }) : null
672
+ ] }), action ? /* @__PURE__ */ jsx(EmptyContent, { children: action }) : null]
673
+ });
674
+ }
675
+ //#endregion
676
+ export { DataTable, DataTableBulkActions, DataTableCardGrid, DataTableEmptyState, DataTableFilter, DataTablePageSizeSelect, DataTablePagination, DataTableRoot, DataTableToolbar, useDataTable, useDataTableContext };