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