kineto 0.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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +279 -0
  3. package/base.css +46 -0
  4. package/dist/accordion.d.ts +13 -0
  5. package/dist/accordion.js +161 -0
  6. package/dist/accordion.js.map +1 -0
  7. package/dist/alert.d.ts +20 -0
  8. package/dist/alert.js +137 -0
  9. package/dist/alert.js.map +1 -0
  10. package/dist/animated-number.d.ts +16 -0
  11. package/dist/animated-number.js +40 -0
  12. package/dist/animated-number.js.map +1 -0
  13. package/dist/area-chart.d.ts +16 -0
  14. package/dist/area-chart.js +138 -0
  15. package/dist/area-chart.js.map +1 -0
  16. package/dist/aspect-ratio.d.ts +6 -0
  17. package/dist/aspect-ratio.js +9 -0
  18. package/dist/aspect-ratio.js.map +1 -0
  19. package/dist/avatar.d.ts +18 -0
  20. package/dist/avatar.js +202 -0
  21. package/dist/avatar.js.map +1 -0
  22. package/dist/badge.d.ts +14 -0
  23. package/dist/badge.js +54 -0
  24. package/dist/badge.js.map +1 -0
  25. package/dist/bar-chart.d.ts +19 -0
  26. package/dist/bar-chart.js +139 -0
  27. package/dist/bar-chart.js.map +1 -0
  28. package/dist/bento-grid.d.ts +24 -0
  29. package/dist/bento-grid.js +129 -0
  30. package/dist/bento-grid.js.map +1 -0
  31. package/dist/breadcrumbs.d.ts +13 -0
  32. package/dist/breadcrumbs.js +50 -0
  33. package/dist/breadcrumbs.js.map +1 -0
  34. package/dist/button-group.d.ts +9 -0
  35. package/dist/button-group.js +29 -0
  36. package/dist/button-group.js.map +1 -0
  37. package/dist/button.d.ts +16 -0
  38. package/dist/button.js +131 -0
  39. package/dist/button.js.map +1 -0
  40. package/dist/calendar.d.ts +11 -0
  41. package/dist/calendar.js +185 -0
  42. package/dist/calendar.js.map +1 -0
  43. package/dist/card.d.ts +15 -0
  44. package/dist/card.js +131 -0
  45. package/dist/card.js.map +1 -0
  46. package/dist/carousel.d.ts +14 -0
  47. package/dist/carousel.js +143 -0
  48. package/dist/carousel.js.map +1 -0
  49. package/dist/chart-tooltip.d.ts +18 -0
  50. package/dist/chart-tooltip.js +30 -0
  51. package/dist/chart-tooltip.js.map +1 -0
  52. package/dist/checkbox.d.ts +6 -0
  53. package/dist/checkbox.js +88 -0
  54. package/dist/checkbox.js.map +1 -0
  55. package/dist/cn.d.ts +10 -0
  56. package/dist/cn.js +10 -0
  57. package/dist/cn.js.map +1 -0
  58. package/dist/code-block.d.ts +25 -0
  59. package/dist/code-block.js +155 -0
  60. package/dist/code-block.js.map +1 -0
  61. package/dist/collapsible.d.ts +12 -0
  62. package/dist/collapsible.js +125 -0
  63. package/dist/collapsible.js.map +1 -0
  64. package/dist/color-picker.d.ts +12 -0
  65. package/dist/color-picker.js +180 -0
  66. package/dist/color-picker.js.map +1 -0
  67. package/dist/command.d.ts +88 -0
  68. package/dist/command.js +277 -0
  69. package/dist/command.js.map +1 -0
  70. package/dist/confetti.d.ts +25 -0
  71. package/dist/confetti.js +109 -0
  72. package/dist/confetti.js.map +1 -0
  73. package/dist/container.d.ts +19 -0
  74. package/dist/container.js +41 -0
  75. package/dist/container.js.map +1 -0
  76. package/dist/content-divider.d.ts +7 -0
  77. package/dist/content-divider.js +35 -0
  78. package/dist/content-divider.js.map +1 -0
  79. package/dist/context-menu.d.ts +30 -0
  80. package/dist/context-menu.js +213 -0
  81. package/dist/context-menu.js.map +1 -0
  82. package/dist/copy-button.d.ts +17 -0
  83. package/dist/copy-button.js +107 -0
  84. package/dist/copy-button.js.map +1 -0
  85. package/dist/dashboard-showcase.d.ts +7 -0
  86. package/dist/dashboard-showcase.js +2560 -0
  87. package/dist/dashboard-showcase.js.map +1 -0
  88. package/dist/data-table.d.ts +130 -0
  89. package/dist/data-table.js +1620 -0
  90. package/dist/data-table.js.map +1 -0
  91. package/dist/date-picker.d.ts +12 -0
  92. package/dist/date-picker.js +261 -0
  93. package/dist/date-picker.js.map +1 -0
  94. package/dist/dialog.d.ts +23 -0
  95. package/dist/dialog.js +188 -0
  96. package/dist/dialog.js.map +1 -0
  97. package/dist/dock.d.ts +17 -0
  98. package/dist/dock.js +77 -0
  99. package/dist/dock.js.map +1 -0
  100. package/dist/donut-chart.d.ts +18 -0
  101. package/dist/donut-chart.js +92 -0
  102. package/dist/donut-chart.js.map +1 -0
  103. package/dist/drawer.d.ts +26 -0
  104. package/dist/drawer.js +166 -0
  105. package/dist/drawer.js.map +1 -0
  106. package/dist/dropdown-menu.d.ts +22 -0
  107. package/dist/dropdown-menu.js +163 -0
  108. package/dist/dropdown-menu.js.map +1 -0
  109. package/dist/empty-state.d.ts +13 -0
  110. package/dist/empty-state.js +149 -0
  111. package/dist/empty-state.js.map +1 -0
  112. package/dist/featured-icon.d.ts +16 -0
  113. package/dist/featured-icon.js +56 -0
  114. package/dist/featured-icon.js.map +1 -0
  115. package/dist/file-uploader.d.ts +11 -0
  116. package/dist/file-uploader.js +212 -0
  117. package/dist/file-uploader.js.map +1 -0
  118. package/dist/flex.d.ts +30 -0
  119. package/dist/flex.js +89 -0
  120. package/dist/flex.js.map +1 -0
  121. package/dist/form.d.ts +28 -0
  122. package/dist/form.js +139 -0
  123. package/dist/form.js.map +1 -0
  124. package/dist/format-time.d.ts +18 -0
  125. package/dist/format-time.js +54 -0
  126. package/dist/format-time.js.map +1 -0
  127. package/dist/gap.d.ts +9 -0
  128. package/dist/gap.js +34 -0
  129. package/dist/gap.js.map +1 -0
  130. package/dist/gradient-border.d.ts +15 -0
  131. package/dist/gradient-border.js +79 -0
  132. package/dist/gradient-border.js.map +1 -0
  133. package/dist/gradient-text.d.ts +12 -0
  134. package/dist/gradient-text.js +43 -0
  135. package/dist/gradient-text.js.map +1 -0
  136. package/dist/grid.d.ts +25 -0
  137. package/dist/grid.js +77 -0
  138. package/dist/grid.js.map +1 -0
  139. package/dist/hover-card.d.ts +8 -0
  140. package/dist/hover-card.js +93 -0
  141. package/dist/hover-card.js.map +1 -0
  142. package/dist/index.d.ts +93 -0
  143. package/dist/index.js +93 -0
  144. package/dist/inline-edit.d.ts +20 -0
  145. package/dist/inline-edit.js +107 -0
  146. package/dist/inline-edit.js.map +1 -0
  147. package/dist/input.d.ts +6 -0
  148. package/dist/input.js +31 -0
  149. package/dist/input.js.map +1 -0
  150. package/dist/kbd.d.ts +16 -0
  151. package/dist/kbd.js +35 -0
  152. package/dist/kbd.js.map +1 -0
  153. package/dist/label.d.ts +6 -0
  154. package/dist/label.js +31 -0
  155. package/dist/label.js.map +1 -0
  156. package/dist/line-chart.d.ts +17 -0
  157. package/dist/line-chart.js +120 -0
  158. package/dist/line-chart.js.map +1 -0
  159. package/dist/logo-cloud.d.ts +14 -0
  160. package/dist/logo-cloud.js +106 -0
  161. package/dist/logo-cloud.js.map +1 -0
  162. package/dist/masonry.d.ts +15 -0
  163. package/dist/masonry.js +63 -0
  164. package/dist/masonry.js.map +1 -0
  165. package/dist/menubar.d.ts +31 -0
  166. package/dist/menubar.js +250 -0
  167. package/dist/menubar.js.map +1 -0
  168. package/dist/motion-presets.d.ts +70 -0
  169. package/dist/motion-presets.js +71 -0
  170. package/dist/motion-presets.js.map +1 -0
  171. package/dist/navigation-menu.d.ts +15 -0
  172. package/dist/navigation-menu.js +181 -0
  173. package/dist/navigation-menu.js.map +1 -0
  174. package/dist/notification-center.d.ts +35 -0
  175. package/dist/notification-center.js +384 -0
  176. package/dist/notification-center.js.map +1 -0
  177. package/dist/page-header.d.ts +13 -0
  178. package/dist/page-header.js +37 -0
  179. package/dist/page-header.js.map +1 -0
  180. package/dist/pagination.d.ts +13 -0
  181. package/dist/pagination.js +103 -0
  182. package/dist/pagination.js.map +1 -0
  183. package/dist/popover.d.ts +9 -0
  184. package/dist/popover.js +93 -0
  185. package/dist/popover.js.map +1 -0
  186. package/dist/progress-steps.d.ts +17 -0
  187. package/dist/progress-steps.js +158 -0
  188. package/dist/progress-steps.js.map +1 -0
  189. package/dist/progress.d.ts +13 -0
  190. package/dist/progress.js +98 -0
  191. package/dist/progress.js.map +1 -0
  192. package/dist/radio-group.d.ts +7 -0
  193. package/dist/radio-group.js +94 -0
  194. package/dist/radio-group.js.map +1 -0
  195. package/dist/rating.d.ts +18 -0
  196. package/dist/rating.js +122 -0
  197. package/dist/rating.js.map +1 -0
  198. package/dist/relative-time.d.ts +19 -0
  199. package/dist/relative-time.js +187 -0
  200. package/dist/relative-time.js.map +1 -0
  201. package/dist/resizable.d.ts +27 -0
  202. package/dist/resizable.js +50 -0
  203. package/dist/resizable.js.map +1 -0
  204. package/dist/scroll-area.d.ts +20 -0
  205. package/dist/scroll-area.js +94 -0
  206. package/dist/scroll-area.js.map +1 -0
  207. package/dist/segmented-control.d.ts +16 -0
  208. package/dist/segmented-control.js +139 -0
  209. package/dist/segmented-control.js.map +1 -0
  210. package/dist/select.d.ts +13 -0
  211. package/dist/select.js +153 -0
  212. package/dist/select.js.map +1 -0
  213. package/dist/separator.d.ts +6 -0
  214. package/dist/separator.js +36 -0
  215. package/dist/separator.js.map +1 -0
  216. package/dist/sidebar.d.ts +24 -0
  217. package/dist/sidebar.js +150 -0
  218. package/dist/sidebar.js.map +1 -0
  219. package/dist/skeleton.d.ts +6 -0
  220. package/dist/skeleton.js +42 -0
  221. package/dist/skeleton.js.map +1 -0
  222. package/dist/slider.d.ts +6 -0
  223. package/dist/slider.js +44 -0
  224. package/dist/slider.js.map +1 -0
  225. package/dist/social-button.d.ts +14 -0
  226. package/dist/social-button.js +203 -0
  227. package/dist/social-button.js.map +1 -0
  228. package/dist/spacer.d.ts +19 -0
  229. package/dist/spacer.js +52 -0
  230. package/dist/spacer.js.map +1 -0
  231. package/dist/spinner.d.ts +15 -0
  232. package/dist/spinner.js +48 -0
  233. package/dist/spinner.js.map +1 -0
  234. package/dist/stack.d.ts +27 -0
  235. package/dist/stack.js +77 -0
  236. package/dist/stack.js.map +1 -0
  237. package/dist/stat-card.d.ts +26 -0
  238. package/dist/stat-card.js +198 -0
  239. package/dist/stat-card.js.map +1 -0
  240. package/dist/status-dot.d.ts +26 -0
  241. package/dist/status-dot.js +68 -0
  242. package/dist/status-dot.js.map +1 -0
  243. package/dist/switch.d.ts +6 -0
  244. package/dist/switch.js +108 -0
  245. package/dist/switch.js.map +1 -0
  246. package/dist/tabs.d.ts +13 -0
  247. package/dist/tabs.js +167 -0
  248. package/dist/tabs.js.map +1 -0
  249. package/dist/tag.d.ts +16 -0
  250. package/dist/tag.js +53 -0
  251. package/dist/tag.js.map +1 -0
  252. package/dist/textarea.d.ts +6 -0
  253. package/dist/textarea.js +30 -0
  254. package/dist/textarea.js.map +1 -0
  255. package/dist/theme-switcher.d.ts +16 -0
  256. package/dist/theme-switcher.js +170 -0
  257. package/dist/theme-switcher.js.map +1 -0
  258. package/dist/toast.d.ts +20 -0
  259. package/dist/toast.js +162 -0
  260. package/dist/toast.js.map +1 -0
  261. package/dist/tooltip.d.ts +14 -0
  262. package/dist/tooltip.js +98 -0
  263. package/dist/tooltip.js.map +1 -0
  264. package/dist/tree-view.d.ts +16 -0
  265. package/dist/tree-view.js +123 -0
  266. package/dist/tree-view.js.map +1 -0
  267. package/dist/truncate.d.ts +16 -0
  268. package/dist/truncate.js +151 -0
  269. package/dist/truncate.js.map +1 -0
  270. package/dist/use-reduced-motion.d.ts +15 -0
  271. package/dist/use-reduced-motion.js +11 -0
  272. package/dist/use-reduced-motion.js.map +1 -0
  273. package/dist/verification-code-input.d.ts +12 -0
  274. package/dist/verification-code-input.js +90 -0
  275. package/dist/verification-code-input.js.map +1 -0
  276. package/package.json +131 -0
  277. package/theme.css +343 -0
@@ -0,0 +1,1620 @@
1
+ "use client";
2
+
3
+ // src/components/application/data-table.tsx
4
+ import * as React8 from "react";
5
+ import {
6
+ DndContext,
7
+ KeyboardSensor,
8
+ MeasuringStrategy,
9
+ MouseSensor,
10
+ TouchSensor,
11
+ closestCenter,
12
+ useSensor,
13
+ useSensors
14
+ } from "@dnd-kit/core";
15
+ import {
16
+ SortableContext,
17
+ arrayMove,
18
+ defaultAnimateLayoutChanges,
19
+ horizontalListSortingStrategy,
20
+ useSortable,
21
+ verticalListSortingStrategy
22
+ } from "@dnd-kit/sortable";
23
+ import { CSS } from "@dnd-kit/utilities";
24
+ import {
25
+ columnFilteringFeature,
26
+ columnOrderingFeature,
27
+ columnPinningFeature,
28
+ columnSizingFeature,
29
+ columnVisibilityFeature,
30
+ createFilteredRowModel,
31
+ createPaginatedRowModel,
32
+ createSortedRowModel,
33
+ filterFn_equalsString,
34
+ filterFn_includesString,
35
+ filterFn_weakEquals,
36
+ flexRender,
37
+ globalFilteringFeature,
38
+ rowPaginationFeature,
39
+ rowSelectionFeature,
40
+ rowSortingFeature,
41
+ sortFn_alphanumeric,
42
+ tableFeatures,
43
+ useTable
44
+ } from "@tanstack/react-table";
45
+ import {
46
+ ArrowDown,
47
+ ArrowUp,
48
+ ArrowUpDown,
49
+ Filter,
50
+ GripVertical,
51
+ MoreHorizontal,
52
+ Pin,
53
+ Search,
54
+ X
55
+ } from "lucide-react";
56
+ import { motion as motion6 } from "motion/react";
57
+
58
+ // src/lib/cn.ts
59
+ import { clsx } from "clsx";
60
+ import { twMerge } from "tailwind-merge";
61
+ function cn(...inputs) {
62
+ return twMerge(clsx(inputs));
63
+ }
64
+
65
+ // src/lib/motion-presets.ts
66
+ var spring = {
67
+ /** Quick, decisive — buttons, indicators, dropdowns. */
68
+ snappy: { type: "spring", stiffness: 420, damping: 32, mass: 0.8 },
69
+ /** Calm and weighty — dialogs, cards, larger surfaces. */
70
+ soft: { type: "spring", stiffness: 180, damping: 26 },
71
+ /** Playful overshoot — badges, toggles, delight moments. Use sparingly. */
72
+ bouncy: { type: "spring", stiffness: 480, damping: 18, mass: 0.9 }
73
+ };
74
+ var tween = {
75
+ /** The signature easing — an expressive ease-out for orchestrated reveals. */
76
+ smooth: { type: "tween", duration: 0.45, ease: [0.22, 1, 0.36, 1] },
77
+ /** Faster variant for small elements. */
78
+ quick: { type: "tween", duration: 0.28, ease: [0.22, 1, 0.36, 1] },
79
+ /** Longer, settled curve for drawing charts, count-ups, and progress fills. */
80
+ draw: { type: "tween", duration: 1.1, ease: [0.16, 1, 0.3, 1] }
81
+ };
82
+ var fadeUp = {
83
+ hidden: { opacity: 0, y: 18 },
84
+ visible: { opacity: 1, y: 0, transition: tween.smooth }
85
+ };
86
+ var fadeIn = {
87
+ hidden: { opacity: 0 },
88
+ visible: { opacity: 1, transition: tween.smooth }
89
+ };
90
+ var scaleIn = {
91
+ hidden: { opacity: 0, scale: 0.96 },
92
+ visible: { opacity: 1, scale: 1, transition: spring.soft }
93
+ };
94
+ var slideInLeft = {
95
+ hidden: { opacity: 0, x: -28 },
96
+ visible: { opacity: 1, x: 0, transition: tween.smooth }
97
+ };
98
+ var slideInRight = {
99
+ hidden: { opacity: 0, x: 28 },
100
+ visible: { opacity: 1, x: 0, transition: tween.smooth }
101
+ };
102
+ var blurIn = {
103
+ hidden: { opacity: 0, filter: "blur(12px)" },
104
+ visible: { opacity: 1, filter: "blur(0px)", transition: tween.smooth }
105
+ };
106
+ var staggerContainer = (stagger = 0.08, delay = 0) => ({
107
+ hidden: {},
108
+ visible: {
109
+ transition: { staggerChildren: stagger, delayChildren: delay }
110
+ }
111
+ });
112
+ var interaction = {
113
+ /** Press feedback for buttons and clickable chips. */
114
+ tap: { scale: 0.97 },
115
+ /** Very subtle scale-up for non-anchored content surfaces (cards/tiles) — never for triggers.
116
+ * A gentle swell reads calmer than a positional lift and doesn't nudge neighbouring content. */
117
+ cardHover: { scale: 1.02 }
118
+ };
119
+
120
+ // src/components/ui/button.tsx
121
+ import * as React from "react";
122
+ import { Slot } from "@radix-ui/react-slot";
123
+ import { cva } from "class-variance-authority";
124
+ import { motion } from "motion/react";
125
+ import { jsx } from "react/jsx-runtime";
126
+ var buttonVariants = cva(
127
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
128
+ {
129
+ variants: {
130
+ variant: {
131
+ default: "bg-primary text-primary-foreground shadow-soft hover:bg-primary/90",
132
+ brand: "bg-brand text-brand-foreground shadow-soft hover:bg-brand/90",
133
+ /* A gradient can't be dimmed with an alpha modifier the way `bg-brand/90` is, so the
134
+ hover state lifts the whole ramp with a filter instead. */
135
+ gradient: "bg-gradient-brand text-brand-foreground shadow-soft transition-[filter,box-shadow] hover:brightness-110 hover:shadow-lift",
136
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
137
+ outline: "border border-input bg-card hover:bg-accent hover:text-accent-foreground",
138
+ ghost: "hover:bg-accent hover:text-accent-foreground",
139
+ destructive: "bg-destructive text-destructive-foreground shadow-soft hover:bg-destructive/90",
140
+ link: "text-primary underline-offset-4 hover:underline"
141
+ },
142
+ size: {
143
+ sm: "h-9 px-3.5",
144
+ default: "h-10 px-5 py-2",
145
+ lg: "h-12 px-7 text-base",
146
+ pill: "h-11 rounded-full px-7",
147
+ icon: "size-10"
148
+ }
149
+ },
150
+ defaultVariants: {
151
+ variant: "default",
152
+ size: "default"
153
+ }
154
+ }
155
+ );
156
+ var Button = React.forwardRef(
157
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
158
+ if (asChild) {
159
+ return /* @__PURE__ */ jsx(
160
+ Slot,
161
+ {
162
+ ref,
163
+ className: cn(
164
+ buttonVariants({ variant, size }),
165
+ // asChild has no Motion presets — give it CSS press feedback so links feel responsive too.
166
+ "transition-[transform,color,background-color,border-color,box-shadow] duration-150 ease-out active:scale-[0.98]",
167
+ className
168
+ ),
169
+ ...props
170
+ }
171
+ );
172
+ }
173
+ return /* @__PURE__ */ jsx(
174
+ motion.button,
175
+ {
176
+ ref,
177
+ className: cn(buttonVariants({ variant, size, className })),
178
+ whileTap: interaction.tap,
179
+ transition: spring.snappy,
180
+ ...props
181
+ }
182
+ );
183
+ }
184
+ );
185
+ Button.displayName = "Button";
186
+
187
+ // src/components/ui/checkbox.tsx
188
+ import * as React2 from "react";
189
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
190
+ import { Check, Minus } from "lucide-react";
191
+ import { motion as motion2 } from "motion/react";
192
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
193
+ var Checkbox = React2.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx2(
194
+ CheckboxPrimitive.Root,
195
+ {
196
+ ref,
197
+ className: cn(
198
+ "group peer size-5 shrink-0 rounded-[6px] border border-input bg-card shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-brand data-[state=checked]:bg-brand data-[state=checked]:text-brand-foreground data-[state=indeterminate]:border-brand data-[state=indeterminate]:bg-brand data-[state=indeterminate]:text-brand-foreground",
199
+ className
200
+ ),
201
+ ...props,
202
+ children: /* @__PURE__ */ jsx2(CheckboxPrimitive.Indicator, { asChild: true, children: /* @__PURE__ */ jsxs(
203
+ motion2.span,
204
+ {
205
+ initial: { scale: 0.4, opacity: 0 },
206
+ animate: { scale: 1, opacity: 1 },
207
+ transition: spring.bouncy,
208
+ className: "flex items-center justify-center text-current",
209
+ children: [
210
+ /* @__PURE__ */ jsx2(Check, { className: "size-3.5 group-data-[state=indeterminate]:hidden", strokeWidth: 3 }),
211
+ /* @__PURE__ */ jsx2(Minus, { className: "hidden size-3.5 group-data-[state=indeterminate]:block", strokeWidth: 3 })
212
+ ]
213
+ }
214
+ ) })
215
+ }
216
+ ));
217
+ Checkbox.displayName = "Checkbox";
218
+
219
+ // src/components/ui/dropdown-menu.tsx
220
+ import * as React3 from "react";
221
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
222
+ import { Check as Check2 } from "lucide-react";
223
+ import { motion as motion3 } from "motion/react";
224
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
225
+ var DropdownMenu = DropdownMenuPrimitive.Root;
226
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
227
+ var DropdownMenuContent = React3.forwardRef(({ className, sideOffset = 6, children, ...props }, ref) => /* @__PURE__ */ jsx3(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx3(
228
+ DropdownMenuPrimitive.Content,
229
+ {
230
+ ref,
231
+ sideOffset,
232
+ className: "z-50",
233
+ ...props,
234
+ children: /* @__PURE__ */ jsx3(
235
+ motion3.div,
236
+ {
237
+ initial: { opacity: 0, scale: 0.97 },
238
+ animate: { opacity: 1, scale: 1 },
239
+ transition: tween.quick,
240
+ style: {
241
+ transformOrigin: "var(--radix-dropdown-menu-content-transform-origin)"
242
+ },
243
+ className: cn(
244
+ "min-w-[10rem] overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lift",
245
+ className
246
+ ),
247
+ children
248
+ }
249
+ )
250
+ }
251
+ ) }));
252
+ DropdownMenuContent.displayName = "DropdownMenuContent";
253
+ var DropdownMenuItem = React3.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx3(
254
+ DropdownMenuPrimitive.Item,
255
+ {
256
+ ref,
257
+ className: cn(
258
+ "relative flex cursor-pointer select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:opacity-70",
259
+ inset && "pl-8",
260
+ className
261
+ ),
262
+ ...props
263
+ }
264
+ ));
265
+ DropdownMenuItem.displayName = "DropdownMenuItem";
266
+ var DropdownMenuCheckboxItem = React3.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs2(
267
+ DropdownMenuPrimitive.CheckboxItem,
268
+ {
269
+ ref,
270
+ checked,
271
+ className: cn(
272
+ "relative flex cursor-pointer select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
273
+ className
274
+ ),
275
+ ...props,
276
+ children: [
277
+ /* @__PURE__ */ jsx3("span", { className: "absolute left-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ jsx3(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx3(Check2, { className: "size-4 text-primary" }) }) }),
278
+ children
279
+ ]
280
+ }
281
+ ));
282
+ DropdownMenuCheckboxItem.displayName = "DropdownMenuCheckboxItem";
283
+ var DropdownMenuLabel = React3.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx3(
284
+ DropdownMenuPrimitive.Label,
285
+ {
286
+ ref,
287
+ className: cn(
288
+ "px-2 py-1.5 text-xs font-medium text-muted-foreground",
289
+ inset && "pl-8",
290
+ className
291
+ ),
292
+ ...props
293
+ }
294
+ ));
295
+ DropdownMenuLabel.displayName = "DropdownMenuLabel";
296
+ var DropdownMenuSeparator = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
297
+ DropdownMenuPrimitive.Separator,
298
+ {
299
+ ref,
300
+ className: cn("-mx-1 my-1 h-px bg-border", className),
301
+ ...props
302
+ }
303
+ ));
304
+ DropdownMenuSeparator.displayName = "DropdownMenuSeparator";
305
+ var DropdownMenuShortcut = ({
306
+ className,
307
+ ...props
308
+ }) => /* @__PURE__ */ jsx3(
309
+ "span",
310
+ {
311
+ className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className),
312
+ ...props
313
+ }
314
+ );
315
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
316
+
317
+ // src/components/ui/input.tsx
318
+ import * as React4 from "react";
319
+ import { jsx as jsx4 } from "react/jsx-runtime";
320
+ var Input = React4.forwardRef(
321
+ ({ className, type = "text", ...props }, ref) => /* @__PURE__ */ jsx4(
322
+ "input",
323
+ {
324
+ ref,
325
+ type,
326
+ className: cn(
327
+ "flex h-10 w-full rounded-lg border border-input bg-card px-3.5 py-2 text-sm text-foreground shadow-xs transition-colors placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 file:border-0 file:bg-transparent file:text-sm file:font-medium",
328
+ className
329
+ ),
330
+ ...props
331
+ }
332
+ )
333
+ );
334
+ Input.displayName = "Input";
335
+
336
+ // src/components/ui/pagination.tsx
337
+ import * as React5 from "react";
338
+ import { ChevronLeft, ChevronRight } from "lucide-react";
339
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
340
+ function range(start, end) {
341
+ return Array.from({ length: end - start + 1 }, (_, i) => start + i);
342
+ }
343
+ function getPages(page, total, siblings) {
344
+ const totalToShow = siblings * 2 + 5;
345
+ if (total <= totalToShow) return range(1, total);
346
+ const leftSibling = Math.max(page - siblings, 1);
347
+ const rightSibling = Math.min(page + siblings, total);
348
+ const showLeftDots = leftSibling > 2;
349
+ const showRightDots = rightSibling < total - 1;
350
+ if (!showLeftDots && showRightDots) {
351
+ return [...range(1, siblings * 2 + 3), "\u2026", total];
352
+ }
353
+ if (showLeftDots && !showRightDots) {
354
+ return [1, "\u2026", ...range(total - (siblings * 2 + 2), total)];
355
+ }
356
+ return [1, "\u2026", ...range(leftSibling, rightSibling), "\u2026", total];
357
+ }
358
+ var itemClass = "inline-flex h-9 min-w-9 items-center justify-center rounded-lg px-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40";
359
+ var Pagination = React5.forwardRef(
360
+ ({ className, page, total, onPageChange, siblingCount = 1, ...props }, ref) => {
361
+ const pages = getPages(page, total, siblingCount);
362
+ const go = (p) => {
363
+ if (p >= 1 && p <= total && p !== page) onPageChange?.(p);
364
+ };
365
+ return /* @__PURE__ */ jsxs3(
366
+ "nav",
367
+ {
368
+ ref,
369
+ "aria-label": "Pagination",
370
+ className: cn("flex items-center gap-1", className),
371
+ ...props,
372
+ children: [
373
+ /* @__PURE__ */ jsx5(
374
+ "button",
375
+ {
376
+ type: "button",
377
+ "aria-label": "Previous page",
378
+ onClick: () => go(page - 1),
379
+ disabled: page <= 1,
380
+ className: cn(itemClass, "gap-1 text-muted-foreground hover:bg-accent hover:text-foreground"),
381
+ children: /* @__PURE__ */ jsx5(ChevronLeft, { className: "size-4" })
382
+ }
383
+ ),
384
+ pages.map(
385
+ (p, i) => p === "\u2026" ? /* @__PURE__ */ jsx5(
386
+ "span",
387
+ {
388
+ className: "inline-flex h-9 min-w-9 items-center justify-center text-sm text-muted-foreground",
389
+ children: "\u2026"
390
+ },
391
+ `dots-${i}`
392
+ ) : /* @__PURE__ */ jsx5(
393
+ "button",
394
+ {
395
+ type: "button",
396
+ "aria-current": p === page ? "page" : void 0,
397
+ onClick: () => go(p),
398
+ className: cn(
399
+ itemClass,
400
+ p === page ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-accent hover:text-foreground"
401
+ ),
402
+ children: p
403
+ },
404
+ p
405
+ )
406
+ ),
407
+ /* @__PURE__ */ jsx5(
408
+ "button",
409
+ {
410
+ type: "button",
411
+ "aria-label": "Next page",
412
+ onClick: () => go(page + 1),
413
+ disabled: page >= total,
414
+ className: cn(itemClass, "gap-1 text-muted-foreground hover:bg-accent hover:text-foreground"),
415
+ children: /* @__PURE__ */ jsx5(ChevronRight, { className: "size-4" })
416
+ }
417
+ )
418
+ ]
419
+ }
420
+ );
421
+ }
422
+ );
423
+ Pagination.displayName = "Pagination";
424
+
425
+ // src/components/ui/select.tsx
426
+ import * as React6 from "react";
427
+ import * as SelectPrimitive from "@radix-ui/react-select";
428
+ import { Check as Check3, ChevronDown, ChevronUp } from "lucide-react";
429
+ import { motion as motion4 } from "motion/react";
430
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
431
+ var Select = SelectPrimitive.Root;
432
+ var SelectValue = SelectPrimitive.Value;
433
+ var SelectTrigger = React6.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs4(
434
+ SelectPrimitive.Trigger,
435
+ {
436
+ ref,
437
+ className: cn(
438
+ "flex h-10 w-full items-center justify-between gap-2 whitespace-nowrap rounded-lg border border-input bg-card px-3.5 py-2 text-sm text-foreground shadow-xs transition-colors data-[placeholder]:text-muted-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/40 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:truncate",
439
+ className
440
+ ),
441
+ ...props,
442
+ children: [
443
+ children,
444
+ /* @__PURE__ */ jsx6(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx6(ChevronDown, { className: "size-4 shrink-0 opacity-60" }) })
445
+ ]
446
+ }
447
+ ));
448
+ SelectTrigger.displayName = "SelectTrigger";
449
+ var SelectContent = React6.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx6(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx6(
450
+ SelectPrimitive.Content,
451
+ {
452
+ ref,
453
+ position,
454
+ sideOffset: 6,
455
+ className: "z-50",
456
+ ...props,
457
+ children: /* @__PURE__ */ jsxs4(
458
+ motion4.div,
459
+ {
460
+ initial: { opacity: 0, scale: 0.97 },
461
+ animate: { opacity: 1, scale: 1 },
462
+ transition: tween.quick,
463
+ style: { transformOrigin: "var(--radix-select-content-transform-origin)" },
464
+ className: cn(
465
+ "max-h-96 min-w-[8rem] overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-lift",
466
+ position === "popper" && "w-[var(--radix-select-trigger-width)]",
467
+ className
468
+ ),
469
+ children: [
470
+ /* @__PURE__ */ jsx6(SelectPrimitive.ScrollUpButton, { className: "flex items-center justify-center py-1 text-muted-foreground", children: /* @__PURE__ */ jsx6(ChevronUp, { className: "size-4" }) }),
471
+ /* @__PURE__ */ jsx6(SelectPrimitive.Viewport, { className: "p-1", children }),
472
+ /* @__PURE__ */ jsx6(SelectPrimitive.ScrollDownButton, { className: "flex items-center justify-center py-1 text-muted-foreground", children: /* @__PURE__ */ jsx6(ChevronDown, { className: "size-4" }) })
473
+ ]
474
+ }
475
+ )
476
+ }
477
+ ) }));
478
+ SelectContent.displayName = "SelectContent";
479
+ var SelectLabel = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
480
+ SelectPrimitive.Label,
481
+ {
482
+ ref,
483
+ className: cn("px-2 py-1.5 text-xs font-medium text-muted-foreground", className),
484
+ ...props
485
+ }
486
+ ));
487
+ SelectLabel.displayName = "SelectLabel";
488
+ var SelectItem = React6.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs4(
489
+ SelectPrimitive.Item,
490
+ {
491
+ ref,
492
+ className: cn(
493
+ "relative flex w-full cursor-pointer select-none items-center rounded-md py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
494
+ className
495
+ ),
496
+ ...props,
497
+ children: [
498
+ /* @__PURE__ */ jsx6("span", { className: "absolute left-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ jsx6(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx6(Check3, { className: "size-4 text-primary" }) }) }),
499
+ /* @__PURE__ */ jsx6(SelectPrimitive.ItemText, { children })
500
+ ]
501
+ }
502
+ ));
503
+ SelectItem.displayName = "SelectItem";
504
+ var SelectSeparator = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx6(
505
+ SelectPrimitive.Separator,
506
+ {
507
+ ref,
508
+ className: cn("-mx-1 my-1 h-px bg-border", className),
509
+ ...props
510
+ }
511
+ ));
512
+ SelectSeparator.displayName = "SelectSeparator";
513
+
514
+ // src/components/ui/spinner.tsx
515
+ import * as React7 from "react";
516
+ import { motion as motion5 } from "motion/react";
517
+ import { jsx as jsx7 } from "react/jsx-runtime";
518
+ var sizeClasses = {
519
+ sm: "size-4 border-2",
520
+ md: "size-6 border-2",
521
+ lg: "size-8 border-[3px]"
522
+ };
523
+ var Spinner = React7.forwardRef(
524
+ ({ className, size = "md", label = "Loading", ...props }, ref) => /* @__PURE__ */ jsx7(
525
+ "span",
526
+ {
527
+ ref,
528
+ role: "status",
529
+ "aria-label": label,
530
+ className: cn("inline-flex text-brand", className),
531
+ ...props,
532
+ children: /* @__PURE__ */ jsx7(
533
+ motion5.span,
534
+ {
535
+ className: cn(
536
+ "block rounded-full border-current border-t-transparent",
537
+ sizeClasses[size]
538
+ ),
539
+ animate: { rotate: 360 },
540
+ transition: { duration: 0.6, ease: "linear", repeat: Infinity }
541
+ }
542
+ )
543
+ }
544
+ )
545
+ );
546
+ Spinner.displayName = "Spinner";
547
+
548
+ // src/components/application/data-table.tsx
549
+ import { Fragment, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
550
+ var dataTableFeatures = tableFeatures({
551
+ rowSortingFeature,
552
+ columnFilteringFeature,
553
+ globalFilteringFeature,
554
+ rowPaginationFeature,
555
+ rowSelectionFeature,
556
+ columnOrderingFeature,
557
+ columnPinningFeature,
558
+ columnSizingFeature,
559
+ columnVisibilityFeature,
560
+ sortedRowModel: createSortedRowModel(),
561
+ filteredRowModel: createFilteredRowModel(),
562
+ paginatedRowModel: createPaginatedRowModel(),
563
+ sortFns: { alphanumeric: sortFn_alphanumeric },
564
+ filterFns: {
565
+ includesString: filterFn_includesString,
566
+ equalsString: filterFn_equalsString,
567
+ weakEquals: filterFn_weakEquals
568
+ },
569
+ columnMeta: {}
570
+ });
571
+ var alignClass = {
572
+ left: "text-left",
573
+ center: "text-center",
574
+ right: "text-right"
575
+ };
576
+ var SELECT_COL_ID = "__select";
577
+ var REORDER_COL_ID = "__reorder";
578
+ function getUtilityColumnIds(options) {
579
+ const ids = [];
580
+ if (options.enableRowOrdering) ids.push(REORDER_COL_ID);
581
+ if (options.enableRowSelection) ids.push(SELECT_COL_ID);
582
+ return ids;
583
+ }
584
+ function withPinnedUtilities(pinning, utilityIds) {
585
+ if (!utilityIds.length) return pinning;
586
+ const utilSet = new Set(utilityIds);
587
+ return {
588
+ start: [
589
+ ...utilityIds,
590
+ ...pinning.start.filter((id) => !utilSet.has(id))
591
+ ],
592
+ end: pinning.end.filter((id) => !utilSet.has(id))
593
+ };
594
+ }
595
+ function withOrderedUtilities(order, utilityIds) {
596
+ if (!utilityIds.length) return order;
597
+ const utilSet = new Set(utilityIds);
598
+ return [...utilityIds, ...order.filter((id) => !utilSet.has(id))];
599
+ }
600
+ function resolveFilterConfig(col, enableColumnFilters) {
601
+ if (col.filter === false || col.enableColumnFilter === false) return false;
602
+ if (typeof col.filter === "object") return { type: "text", ...col.filter };
603
+ if (col.filter === true || col.enableColumnFilter === true || enableColumnFilters) {
604
+ return { type: "text" };
605
+ }
606
+ return false;
607
+ }
608
+ function hasAnyColumnFilter(columns) {
609
+ return columns.some(
610
+ (col) => col.filter === true || typeof col.filter === "object" || col.enableColumnFilter === true
611
+ );
612
+ }
613
+ function filterFnForType(type) {
614
+ switch (type) {
615
+ case "select":
616
+ case "boolean":
617
+ return "equalsString";
618
+ case "number":
619
+ return "weakEquals";
620
+ case "custom":
621
+ case "text":
622
+ default:
623
+ return "includesString";
624
+ }
625
+ }
626
+ function toColumnDef(col, options) {
627
+ const id = col.id ?? col.key;
628
+ const filterConfig = resolveFilterConfig(
629
+ col,
630
+ options.enableColumnFilters
631
+ );
632
+ const enableColumnFilter = filterConfig !== false;
633
+ const base = {
634
+ id,
635
+ header: () => col.header,
636
+ cell: (info) => {
637
+ if (col.cell) return col.cell(info.row.original);
638
+ const value = info.getValue();
639
+ if (col.format) return col.format(value, info.row.original);
640
+ return value == null ? "" : String(value);
641
+ },
642
+ enableSorting: col.enableSorting ?? options.enableSorting,
643
+ enablePinning: col.enablePinning ?? options.enablePinning,
644
+ enableColumnFilter,
645
+ filterFn: filterFnForType(
646
+ filterConfig === false ? void 0 : filterConfig.type
647
+ ),
648
+ size: col.size,
649
+ minSize: col.minSize,
650
+ maxSize: col.maxSize,
651
+ meta: {
652
+ align: col.align ?? "left",
653
+ className: col.className,
654
+ enableOrdering: col.enableOrdering,
655
+ filter: filterConfig
656
+ }
657
+ };
658
+ if (col.accessorFn) {
659
+ return { ...base, accessorFn: col.accessorFn };
660
+ }
661
+ if (col.accessorKey) {
662
+ return { ...base, accessorKey: col.accessorKey };
663
+ }
664
+ return {
665
+ ...base,
666
+ accessorFn: (row) => row[col.key]
667
+ };
668
+ }
669
+ function getPinnedStyles(column, isHeader, options) {
670
+ const pinned = column.getIsPinned();
671
+ if (!pinned) return {};
672
+ return {
673
+ position: "sticky",
674
+ ...pinned === "start" ? { insetInlineStart: `${column.getStart("start")}px` } : { insetInlineEnd: `${column.getAfter("end")}px` },
675
+ zIndex: isHeader ? 3 : 2,
676
+ ...options?.hideShadow ? {} : {}
677
+ };
678
+ }
679
+ var ROW_SORT_TRANSITION = {
680
+ duration: 280,
681
+ easing: "cubic-bezier(0.22, 1, 0.36, 1)"
682
+ };
683
+ var COL_SORT_TRANSITION = {
684
+ duration: 280,
685
+ easing: "cubic-bezier(0.22, 1, 0.36, 1)"
686
+ };
687
+ var rowAnimateLayoutChanges = (args) => {
688
+ if (args.isSorting || args.wasDragging) {
689
+ return defaultAnimateLayoutChanges(args);
690
+ }
691
+ return false;
692
+ };
693
+ var columnAnimateLayoutChanges = (args) => {
694
+ if (args.isSorting || args.wasDragging) {
695
+ return defaultAnimateLayoutChanges(args);
696
+ }
697
+ return false;
698
+ };
699
+ var ColumnDragStoreContext = React8.createContext(null);
700
+ function framesEqual(a, b) {
701
+ if (!a) return false;
702
+ return a.isDragging === b.isDragging && a.transition === b.transition && a.transform?.x === b.transform?.x && a.transform?.y === b.transform?.y && a.transform?.scaleX === b.transform?.scaleX && a.transform?.scaleY === b.transform?.scaleY;
703
+ }
704
+ function ColumnDragBridgeProvider({ children }) {
705
+ const store = React8.useMemo(() => {
706
+ const frames = /* @__PURE__ */ new Map();
707
+ const listeners = /* @__PURE__ */ new Set();
708
+ const emit = () => {
709
+ listeners.forEach((listener) => listener());
710
+ };
711
+ return {
712
+ subscribe(onStoreChange) {
713
+ listeners.add(onStoreChange);
714
+ return () => {
715
+ listeners.delete(onStoreChange);
716
+ };
717
+ },
718
+ getFrame(columnId) {
719
+ return frames.get(columnId);
720
+ },
721
+ setFrame(columnId, frame) {
722
+ const current = frames.get(columnId);
723
+ if (frame == null) {
724
+ if (!current) return;
725
+ frames.delete(columnId);
726
+ emit();
727
+ return;
728
+ }
729
+ if (framesEqual(current, frame)) return;
730
+ frames.set(columnId, frame);
731
+ emit();
732
+ }
733
+ };
734
+ }, []);
735
+ return /* @__PURE__ */ jsx8(ColumnDragStoreContext.Provider, { value: store, children });
736
+ }
737
+ var emptyColumnDragSubscribe = () => () => {
738
+ };
739
+ function useColumnDragFrame(columnId) {
740
+ const store = React8.useContext(ColumnDragStoreContext);
741
+ return React8.useSyncExternalStore(
742
+ store ? store.subscribe : emptyColumnDragSubscribe,
743
+ () => store?.getFrame(columnId),
744
+ () => void 0
745
+ );
746
+ }
747
+ function usePublishColumnDragFrame(columnId, enabled, transform, transition, isDragging) {
748
+ const store = React8.useContext(ColumnDragStoreContext);
749
+ React8.useLayoutEffect(() => {
750
+ if (!enabled || !store) return;
751
+ store.setFrame(columnId, { transform, transition, isDragging });
752
+ }, [
753
+ store,
754
+ enabled,
755
+ columnId,
756
+ transform?.x,
757
+ transform?.y,
758
+ transform?.scaleX,
759
+ transform?.scaleY,
760
+ transition,
761
+ isDragging
762
+ ]);
763
+ React8.useEffect(() => {
764
+ if (!enabled || !store) return;
765
+ return () => {
766
+ store.setFrame(columnId, null);
767
+ };
768
+ }, [store, enabled, columnId]);
769
+ }
770
+ function normalizeFilterValue(value) {
771
+ if (value == null) return void 0;
772
+ if (typeof value === "string" && value.trim() === "") return void 0;
773
+ return value;
774
+ }
775
+ function ColumnFilterControl({
776
+ config,
777
+ value,
778
+ onChange,
779
+ onClear
780
+ }) {
781
+ const type = config.type ?? "text";
782
+ const placeholder = config.placeholder ?? "Filter\u2026";
783
+ if (config.render) {
784
+ return /* @__PURE__ */ jsx8(Fragment, { children: config.render({
785
+ value,
786
+ setValue: onChange,
787
+ clear: onClear
788
+ }) });
789
+ }
790
+ if (type === "select" || type === "boolean") {
791
+ const options = config.options ?? (type === "boolean" ? [
792
+ { label: "True", value: "true" },
793
+ { label: "False", value: "false" }
794
+ ] : []);
795
+ const selectValue = value == null ? "" : String(value);
796
+ return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1", children: [
797
+ /* @__PURE__ */ jsxs5(
798
+ Select,
799
+ {
800
+ value: selectValue || void 0,
801
+ onValueChange: (next) => onChange(next),
802
+ children: [
803
+ /* @__PURE__ */ jsx8(SelectTrigger, { className: "h-8 px-2 text-xs font-normal normal-case tracking-normal", children: /* @__PURE__ */ jsx8(SelectValue, { placeholder }) }),
804
+ /* @__PURE__ */ jsx8(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx8(SelectItem, { value: option.value, children: option.label }, option.value)) })
805
+ ]
806
+ }
807
+ ),
808
+ selectValue ? /* @__PURE__ */ jsx8(
809
+ Button,
810
+ {
811
+ type: "button",
812
+ variant: "ghost",
813
+ size: "icon",
814
+ className: "size-8 shrink-0",
815
+ "aria-label": "Clear filter",
816
+ onClick: onClear,
817
+ children: /* @__PURE__ */ jsx8(X, { className: "size-3.5" })
818
+ }
819
+ ) : null
820
+ ] });
821
+ }
822
+ return /* @__PURE__ */ jsx8(
823
+ Input,
824
+ {
825
+ autoFocus: true,
826
+ type: type === "number" ? "number" : "text",
827
+ value: value == null ? "" : String(value),
828
+ onChange: (e) => onChange(e.target.value),
829
+ placeholder,
830
+ className: "h-8 px-2 text-xs font-normal normal-case tracking-normal",
831
+ onClick: (e) => e.stopPropagation(),
832
+ onKeyDown: (e) => {
833
+ if (e.key === "Escape") onClear();
834
+ }
835
+ }
836
+ );
837
+ }
838
+ function SortableHeaderCell({
839
+ header,
840
+ enableOrdering,
841
+ enablePinning,
842
+ onFilterOpenChange,
843
+ onFilterApply,
844
+ onFilterClear,
845
+ onPinColumn,
846
+ children
847
+ }) {
848
+ const meta = header.column.columnDef.meta;
849
+ const filterConfig = meta?.filter;
850
+ const canOrder = enableOrdering && header.column.id !== SELECT_COL_ID && header.column.id !== REORDER_COL_ID && meta?.enableOrdering !== false;
851
+ const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
852
+ id: header.column.id,
853
+ disabled: !canOrder,
854
+ animateLayoutChanges: columnAnimateLayoutChanges,
855
+ transition: COL_SORT_TRANSITION
856
+ });
857
+ usePublishColumnDragFrame(
858
+ header.column.id,
859
+ canOrder,
860
+ transform,
861
+ transition,
862
+ isDragging
863
+ );
864
+ const [filterOpen, setFilterOpen] = React8.useState(false);
865
+ const [menuOpen, setMenuOpen] = React8.useState(false);
866
+ const pinned = header.column.getIsPinned();
867
+ const canPin = enablePinning && header.column.getCanPin();
868
+ const canFilter = header.column.getCanFilter() && filterConfig !== false;
869
+ const showMenu = canPin || canFilter;
870
+ const rawFilterValue = header.column.getFilterValue();
871
+ const hasActiveFilter = normalizeFilterValue(rawFilterValue) !== void 0;
872
+ const isUtilityCol = header.column.id === SELECT_COL_ID || header.column.id === REORDER_COL_ID;
873
+ const setFilterOpenSafe = (open) => {
874
+ setFilterOpen(open);
875
+ onFilterOpenChange?.(header.column.id, open);
876
+ };
877
+ const applyFilterValue = (value) => {
878
+ const next = normalizeFilterValue(value);
879
+ header.column.setFilterValue(next);
880
+ if (next === void 0) {
881
+ onFilterClear?.(header.column.id);
882
+ } else {
883
+ onFilterApply?.(header.column.id, next);
884
+ }
885
+ };
886
+ const clearFilterValue = () => {
887
+ header.column.setFilterValue(void 0);
888
+ setFilterOpenSafe(false);
889
+ onFilterClear?.(header.column.id);
890
+ };
891
+ const pinColumn = (position) => {
892
+ header.column.pin(position);
893
+ onPinColumn?.(header.column.id, position);
894
+ };
895
+ return /* @__PURE__ */ jsx8(
896
+ "th",
897
+ {
898
+ ref: setNodeRef,
899
+ colSpan: header.colSpan,
900
+ style: {
901
+ width: header.getSize(),
902
+ transform: CSS.Translate.toString(transform),
903
+ transition,
904
+ opacity: isDragging ? 0.92 : 1,
905
+ zIndex: isDragging ? 20 : void 0,
906
+ position: isDragging ? "relative" : void 0,
907
+ boxShadow: isDragging ? "0 10px 28px -10px hsl(var(--foreground) / 0.2)" : void 0,
908
+ ...getPinnedStyles(header.column, true, { hideShadow: isUtilityCol })
909
+ },
910
+ className: cn(
911
+ "group/header relative border-b border-border bg-card text-xs font-medium uppercase tracking-wide text-muted-foreground",
912
+ isUtilityCol ? "px-1.5 py-2.5" : "px-3 py-2.5",
913
+ alignClass[meta?.align ?? "left"],
914
+ meta?.className,
915
+ pinned && !isUtilityCol && "shadow-[1px_0_0_0_hsl(var(--border))]",
916
+ pinned === "end" && !isUtilityCol && "shadow-[-1px_0_0_0_hsl(var(--border))]"
917
+ ),
918
+ children: /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-1.5", children: [
919
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1", children: [
920
+ canOrder ? /* @__PURE__ */ jsx8(
921
+ "button",
922
+ {
923
+ type: "button",
924
+ className: "inline-flex size-6 shrink-0 cursor-grab items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground active:cursor-grabbing group-hover/header:opacity-100",
925
+ "aria-label": `Reorder ${header.column.id} column`,
926
+ ...attributes,
927
+ ...listeners,
928
+ children: /* @__PURE__ */ jsx8(GripVertical, { className: "size-3.5" })
929
+ }
930
+ ) : null,
931
+ /* @__PURE__ */ jsx8("div", { className: "min-w-0 flex-1", children }),
932
+ showMenu ? /* @__PURE__ */ jsxs5(DropdownMenu, { open: menuOpen, onOpenChange: setMenuOpen, children: [
933
+ /* @__PURE__ */ jsx8(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx8(
934
+ Button,
935
+ {
936
+ type: "button",
937
+ variant: "ghost",
938
+ size: "icon",
939
+ className: cn(
940
+ "size-6 shrink-0 transition-opacity hover:bg-muted",
941
+ menuOpen || hasActiveFilter ? "opacity-100" : "opacity-0 group-hover/header:opacity-100"
942
+ ),
943
+ "aria-label": `${header.column.id} column options`,
944
+ children: /* @__PURE__ */ jsx8(MoreHorizontal, { className: "size-3.5" })
945
+ }
946
+ ) }),
947
+ /* @__PURE__ */ jsxs5(DropdownMenuContent, { align: "end", className: "w-44", children: [
948
+ /* @__PURE__ */ jsx8(DropdownMenuLabel, { children: "Column" }),
949
+ canFilter ? /* @__PURE__ */ jsxs5(Fragment, { children: [
950
+ /* @__PURE__ */ jsx8(DropdownMenuSeparator, {}),
951
+ /* @__PURE__ */ jsxs5(
952
+ DropdownMenuItem,
953
+ {
954
+ onSelect: () => setFilterOpenSafe(!filterOpen),
955
+ children: [
956
+ /* @__PURE__ */ jsx8(Filter, { className: "size-4" }),
957
+ filterOpen ? "Hide filter" : "Filter"
958
+ ]
959
+ }
960
+ ),
961
+ hasActiveFilter ? /* @__PURE__ */ jsxs5(DropdownMenuItem, { onSelect: clearFilterValue, children: [
962
+ /* @__PURE__ */ jsx8(X, { className: "size-4" }),
963
+ "Clear filter"
964
+ ] }) : null
965
+ ] }) : null,
966
+ canPin ? /* @__PURE__ */ jsxs5(Fragment, { children: [
967
+ /* @__PURE__ */ jsx8(DropdownMenuSeparator, {}),
968
+ /* @__PURE__ */ jsxs5(DropdownMenuItem, { onSelect: () => pinColumn("start"), children: [
969
+ /* @__PURE__ */ jsx8(Pin, { className: "size-4" }),
970
+ "Pin start"
971
+ ] }),
972
+ /* @__PURE__ */ jsxs5(DropdownMenuItem, { onSelect: () => pinColumn("end"), children: [
973
+ /* @__PURE__ */ jsx8(Pin, { className: "size-4" }),
974
+ "Pin end"
975
+ ] }),
976
+ pinned ? /* @__PURE__ */ jsxs5(DropdownMenuItem, { onSelect: () => pinColumn(false), children: [
977
+ /* @__PURE__ */ jsx8(X, { className: "size-4" }),
978
+ "Unpin"
979
+ ] }) : null
980
+ ] }) : null
981
+ ] })
982
+ ] }) : null
983
+ ] }),
984
+ canFilter && filterOpen && filterConfig ? /* @__PURE__ */ jsx8("div", { onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx8(
985
+ ColumnFilterControl,
986
+ {
987
+ config: filterConfig,
988
+ value: rawFilterValue,
989
+ onChange: applyFilterValue,
990
+ onClear: clearFilterValue
991
+ }
992
+ ) }) : null
993
+ ] })
994
+ }
995
+ );
996
+ }
997
+ function BodyCell({
998
+ cell,
999
+ dragHandleProps,
1000
+ isDragging: isRowDragging
1001
+ }) {
1002
+ const meta = cell.column.columnDef.meta;
1003
+ const pinned = cell.column.getIsPinned();
1004
+ const isSelect = cell.column.id === SELECT_COL_ID;
1005
+ const isReorder = cell.column.id === REORDER_COL_ID;
1006
+ const isUtility = isSelect || isReorder;
1007
+ const columnDrag = useColumnDragFrame(cell.column.id);
1008
+ const isColumnDragging = columnDrag?.isDragging ?? false;
1009
+ if (isReorder) {
1010
+ return /* @__PURE__ */ jsx8(
1011
+ "td",
1012
+ {
1013
+ style: {
1014
+ ...getPinnedStyles(cell.column, false, { hideShadow: true }),
1015
+ transform: CSS.Translate.toString(columnDrag?.transform ?? null),
1016
+ transition: columnDrag?.transition
1017
+ },
1018
+ className: "w-6 px-0 py-3 align-middle bg-card",
1019
+ children: /* @__PURE__ */ jsx8(
1020
+ "button",
1021
+ {
1022
+ type: "button",
1023
+ className: cn(
1024
+ "mx-auto flex size-6 cursor-grab items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-muted hover:text-foreground active:cursor-grabbing",
1025
+ isRowDragging ? "opacity-100" : "opacity-0 group-hover/row:opacity-100"
1026
+ ),
1027
+ "aria-label": "Reorder row",
1028
+ ...dragHandleProps,
1029
+ children: /* @__PURE__ */ jsx8(GripVertical, { className: "size-3.5" })
1030
+ }
1031
+ )
1032
+ }
1033
+ );
1034
+ }
1035
+ return /* @__PURE__ */ jsx8(
1036
+ "td",
1037
+ {
1038
+ style: {
1039
+ width: cell.column.getSize(),
1040
+ ...getPinnedStyles(cell.column, false, { hideShadow: isUtility }),
1041
+ transform: CSS.Translate.toString(columnDrag?.transform ?? null),
1042
+ transition: columnDrag?.transition,
1043
+ opacity: isColumnDragging ? 0.92 : void 0,
1044
+ zIndex: isColumnDragging ? 20 : void 0,
1045
+ position: isColumnDragging ? "relative" : void 0,
1046
+ boxShadow: isColumnDragging ? "0 10px 28px -10px hsl(var(--foreground) / 0.2)" : void 0,
1047
+ backgroundColor: isColumnDragging ? "hsl(var(--card))" : void 0
1048
+ },
1049
+ className: cn(
1050
+ "align-middle text-sm text-foreground",
1051
+ isSelect ? "w-9 bg-card px-1.5 py-3" : "px-3 py-3",
1052
+ alignClass[meta?.align ?? "left"],
1053
+ meta?.className,
1054
+ pinned && !isUtility && "bg-card shadow-[1px_0_0_0_hsl(var(--border))]",
1055
+ pinned === "end" && !isUtility && "shadow-[-1px_0_0_0_hsl(var(--border))]"
1056
+ ),
1057
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
1058
+ }
1059
+ );
1060
+ }
1061
+ function SortableBodyRow({
1062
+ row,
1063
+ enableRowOrdering,
1064
+ animateRows
1065
+ }) {
1066
+ const {
1067
+ attributes,
1068
+ listeners,
1069
+ setNodeRef,
1070
+ transform,
1071
+ transition,
1072
+ isDragging
1073
+ } = useSortable({
1074
+ id: row.id,
1075
+ disabled: !enableRowOrdering,
1076
+ animateLayoutChanges: rowAnimateLayoutChanges,
1077
+ transition: ROW_SORT_TRANSITION
1078
+ });
1079
+ const dragHandleProps = enableRowOrdering ? { ...attributes, ...listeners } : void 0;
1080
+ const isSortingTransform = !!transform && (transform.x !== 0 || transform.y !== 0 || isDragging);
1081
+ const rowStyle = {
1082
+ position: "relative",
1083
+ zIndex: isDragging ? 20 : 0,
1084
+ boxShadow: isDragging ? "0 10px 28px -10px hsl(var(--foreground) / 0.2)" : void 0,
1085
+ backgroundColor: isDragging ? "hsl(var(--card))" : void 0,
1086
+ // Only apply dnd-kit's CSS transition while actively sorting — otherwise it
1087
+ // overrides Motion's entrance tween and the stagger reads as fade-down.
1088
+ ...enableRowOrdering && isSortingTransform ? { transition } : {},
1089
+ ...isDragging ? { opacity: 0.92 } : {},
1090
+ ...!animateRows ? { transform: CSS.Transform.toString(transform) } : {}
1091
+ };
1092
+ const rowClassName = cn(
1093
+ "group/row border-b border-border last:border-0",
1094
+ !enableRowOrdering && "transition-colors",
1095
+ !isDragging && "hover:bg-muted/40",
1096
+ row.getIsSelected() && "bg-muted/50"
1097
+ );
1098
+ const cells = row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx8(
1099
+ BodyCell,
1100
+ {
1101
+ cell,
1102
+ isDragging,
1103
+ dragHandleProps: cell.column.id === REORDER_COL_ID ? dragHandleProps : void 0
1104
+ },
1105
+ cell.id
1106
+ ));
1107
+ if (!animateRows) {
1108
+ return /* @__PURE__ */ jsx8(
1109
+ "tr",
1110
+ {
1111
+ ref: setNodeRef,
1112
+ style: rowStyle,
1113
+ className: rowClassName,
1114
+ "data-state": row.getIsSelected() ? "selected" : void 0,
1115
+ children: cells
1116
+ }
1117
+ );
1118
+ }
1119
+ return /* @__PURE__ */ jsx8(
1120
+ motion6.tr,
1121
+ {
1122
+ ref: setNodeRef,
1123
+ variants: fadeUp,
1124
+ style: rowStyle,
1125
+ className: rowClassName,
1126
+ "data-state": row.getIsSelected() ? "selected" : void 0,
1127
+ transformTemplate: enableRowOrdering ? (_props, generated) => {
1128
+ const dnd = CSS.Transform.toString(transform);
1129
+ return dnd ? `${generated} ${dnd}` : generated;
1130
+ } : void 0,
1131
+ children: cells
1132
+ }
1133
+ );
1134
+ }
1135
+ function InfiniteSentinel({
1136
+ hasMore,
1137
+ isLoading,
1138
+ onLoadMore,
1139
+ rootMargin = "200px"
1140
+ }) {
1141
+ const ref = React8.useRef(null);
1142
+ React8.useEffect(() => {
1143
+ const node = ref.current;
1144
+ if (!node || !hasMore) return;
1145
+ const observer = new IntersectionObserver(
1146
+ (entries) => {
1147
+ if (entries[0]?.isIntersecting && !isLoading) onLoadMore();
1148
+ },
1149
+ { rootMargin }
1150
+ );
1151
+ observer.observe(node);
1152
+ return () => observer.disconnect();
1153
+ }, [hasMore, isLoading, onLoadMore, rootMargin]);
1154
+ if (!hasMore && !isLoading) return null;
1155
+ return /* @__PURE__ */ jsx8("div", { ref, className: "flex items-center justify-center gap-2 py-4 text-sm text-muted-foreground", children: isLoading ? /* @__PURE__ */ jsxs5(Fragment, { children: [
1156
+ /* @__PURE__ */ jsx8(Spinner, { size: "sm" }),
1157
+ "Loading more\u2026"
1158
+ ] }) : "Scroll to load more" });
1159
+ }
1160
+ function DataTable({
1161
+ columns,
1162
+ data,
1163
+ getRowId,
1164
+ enableSorting = true,
1165
+ sorting: sortingProp,
1166
+ onSortingChange,
1167
+ manualSorting = false,
1168
+ enableColumnFilters = false,
1169
+ columnFilters: columnFiltersProp,
1170
+ onColumnFiltersChange,
1171
+ manualFiltering = false,
1172
+ onFilterOpenChange,
1173
+ onFilterApply,
1174
+ onFilterClear,
1175
+ enableGlobalFilter = false,
1176
+ globalFilter: globalFilterProp,
1177
+ onGlobalFilterChange,
1178
+ globalFilterPlaceholder = "Search\u2026",
1179
+ enableRowSelection = false,
1180
+ enableMultiRowSelection = true,
1181
+ rowSelection: rowSelectionProp,
1182
+ onRowSelectionChange,
1183
+ enableColumnOrdering = false,
1184
+ columnOrder: columnOrderProp,
1185
+ onColumnOrderChange,
1186
+ enableColumnPinning = false,
1187
+ columnPinning: columnPinningProp,
1188
+ onColumnPinningChange,
1189
+ onPinColumn,
1190
+ enableRowOrdering = false,
1191
+ onRowOrderChange,
1192
+ pagination = false,
1193
+ onPaginationChange,
1194
+ onNextPage,
1195
+ onPreviousPage,
1196
+ infinite,
1197
+ toolbar,
1198
+ emptyMessage = "No results.",
1199
+ animateRows = true,
1200
+ className,
1201
+ ...props
1202
+ }) {
1203
+ const paginationEnabled = Boolean(pagination) && !infinite;
1204
+ const paginationOptions = typeof pagination === "object" ? pagination : {};
1205
+ const columnFiltersActive = enableColumnFilters || hasAnyColumnFilter(columns);
1206
+ const [sorting, setSorting] = React8.useState(sortingProp ?? []);
1207
+ const [columnFilters, setColumnFilters] = React8.useState(
1208
+ columnFiltersProp ?? []
1209
+ );
1210
+ const [globalFilter, setGlobalFilter] = React8.useState(globalFilterProp ?? "");
1211
+ const [rowSelection, setRowSelection] = React8.useState(
1212
+ rowSelectionProp ?? {}
1213
+ );
1214
+ const [columnPinning, setColumnPinning] = React8.useState(
1215
+ () => withPinnedUtilities(columnPinningProp ?? { start: [], end: [] }, getUtilityColumnIds({
1216
+ enableRowOrdering,
1217
+ enableRowSelection
1218
+ }))
1219
+ );
1220
+ const [paginationState, setPaginationState] = React8.useState({
1221
+ pageIndex: paginationOptions.pageIndex ?? 0,
1222
+ pageSize: paginationOptions.pageSize ?? (paginationEnabled ? 10 : Math.max(data.length, 1))
1223
+ });
1224
+ const [orderedData, setOrderedData] = React8.useState(data);
1225
+ React8.useEffect(() => {
1226
+ setOrderedData(data);
1227
+ }, [data]);
1228
+ React8.useEffect(() => {
1229
+ if (sortingProp) setSorting(sortingProp);
1230
+ }, [sortingProp]);
1231
+ React8.useEffect(() => {
1232
+ if (columnFiltersProp) setColumnFilters(columnFiltersProp);
1233
+ }, [columnFiltersProp]);
1234
+ React8.useEffect(() => {
1235
+ if (globalFilterProp !== void 0) setGlobalFilter(globalFilterProp);
1236
+ }, [globalFilterProp]);
1237
+ React8.useEffect(() => {
1238
+ if (rowSelectionProp) setRowSelection(rowSelectionProp);
1239
+ }, [rowSelectionProp]);
1240
+ React8.useEffect(() => {
1241
+ const utilityIds = getUtilityColumnIds({ enableRowOrdering, enableRowSelection });
1242
+ setColumnPinning((prev) => {
1243
+ const next = withPinnedUtilities(columnPinningProp ?? prev, utilityIds);
1244
+ if (next.start.length === prev.start.length && next.end.length === prev.end.length && next.start.every((id, i) => id === prev.start[i]) && next.end.every((id, i) => id === prev.end[i])) {
1245
+ return prev;
1246
+ }
1247
+ return next;
1248
+ });
1249
+ }, [columnPinningProp, enableRowOrdering, enableRowSelection]);
1250
+ React8.useEffect(() => {
1251
+ if (!paginationEnabled) {
1252
+ setPaginationState((prev) => {
1253
+ const pageSize = Math.max(orderedData.length, 1);
1254
+ if (prev.pageIndex === 0 && prev.pageSize === pageSize) return prev;
1255
+ return { pageIndex: 0, pageSize };
1256
+ });
1257
+ return;
1258
+ }
1259
+ setPaginationState((prev) => {
1260
+ const pageIndex2 = paginationOptions.pageIndex ?? prev.pageIndex;
1261
+ const pageSize = paginationOptions.pageSize ?? prev.pageSize;
1262
+ if (prev.pageIndex === pageIndex2 && prev.pageSize === pageSize) return prev;
1263
+ return { pageIndex: pageIndex2, pageSize };
1264
+ });
1265
+ }, [
1266
+ paginationEnabled,
1267
+ paginationOptions.pageIndex,
1268
+ paginationOptions.pageSize,
1269
+ orderedData.length
1270
+ ]);
1271
+ const utilityColumnIds = React8.useMemo(
1272
+ () => getUtilityColumnIds({ enableRowOrdering, enableRowSelection }),
1273
+ [enableRowOrdering, enableRowSelection]
1274
+ );
1275
+ const leafColumnIds = React8.useMemo(() => {
1276
+ const ids = columns.map((c) => c.id ?? c.key);
1277
+ if (enableRowSelection) ids.unshift(SELECT_COL_ID);
1278
+ if (enableRowOrdering) ids.unshift(REORDER_COL_ID);
1279
+ return ids;
1280
+ }, [columns, enableRowSelection, enableRowOrdering]);
1281
+ const [columnOrder, setColumnOrder] = React8.useState(
1282
+ () => withOrderedUtilities(columnOrderProp ?? leafColumnIds, utilityColumnIds)
1283
+ );
1284
+ React8.useEffect(() => {
1285
+ if (columnOrderProp) {
1286
+ setColumnOrder(withOrderedUtilities(columnOrderProp, utilityColumnIds));
1287
+ return;
1288
+ }
1289
+ setColumnOrder((prev) => {
1290
+ const next = leafColumnIds.filter((id) => prev.includes(id));
1291
+ const missing = leafColumnIds.filter((id) => !prev.includes(id));
1292
+ return withOrderedUtilities([...next, ...missing], utilityColumnIds);
1293
+ });
1294
+ }, [leafColumnIds, columnOrderProp, utilityColumnIds]);
1295
+ const tableColumns = React8.useMemo(() => {
1296
+ const defs = columns.map(
1297
+ (col) => toColumnDef(col, {
1298
+ enableSorting,
1299
+ enableColumnFilters: columnFiltersActive,
1300
+ enablePinning: enableColumnPinning
1301
+ })
1302
+ );
1303
+ if (enableRowSelection) {
1304
+ defs.unshift({
1305
+ id: SELECT_COL_ID,
1306
+ size: 36,
1307
+ enableSorting: false,
1308
+ enablePinning: false,
1309
+ enableColumnFilter: false,
1310
+ meta: { enableOrdering: false },
1311
+ header: ({ table: table2 }) => /* @__PURE__ */ jsx8(
1312
+ Checkbox,
1313
+ {
1314
+ checked: table2.getIsAllPageRowsSelected() ? true : table2.getIsSomePageRowsSelected() ? "indeterminate" : false,
1315
+ onCheckedChange: (value) => table2.toggleAllPageRowsSelected(!!value),
1316
+ "aria-label": "Select all"
1317
+ }
1318
+ ),
1319
+ cell: ({ row }) => /* @__PURE__ */ jsx8(
1320
+ Checkbox,
1321
+ {
1322
+ checked: row.getIsSelected(),
1323
+ disabled: !row.getCanSelect(),
1324
+ onCheckedChange: (value) => row.toggleSelected(!!value),
1325
+ "aria-label": "Select row"
1326
+ }
1327
+ )
1328
+ });
1329
+ }
1330
+ if (enableRowOrdering) {
1331
+ defs.unshift({
1332
+ id: REORDER_COL_ID,
1333
+ size: 24,
1334
+ enableSorting: false,
1335
+ enablePinning: false,
1336
+ enableColumnFilter: false,
1337
+ header: () => /* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Reorder" }),
1338
+ cell: () => null,
1339
+ meta: { enableOrdering: false }
1340
+ });
1341
+ }
1342
+ return defs;
1343
+ }, [columns, enableSorting, columnFiltersActive, enableColumnPinning, enableRowSelection, enableRowOrdering]);
1344
+ const handleSortingChange = (updater) => {
1345
+ setSorting((old) => {
1346
+ const next = typeof updater === "function" ? updater(old) : updater;
1347
+ onSortingChange?.(next);
1348
+ return next;
1349
+ });
1350
+ };
1351
+ const handleColumnFiltersChange = (updater) => {
1352
+ setColumnFilters((old) => {
1353
+ const next = typeof updater === "function" ? updater(old) : updater;
1354
+ const cleaned = next.filter((f) => normalizeFilterValue(f.value) !== void 0);
1355
+ onColumnFiltersChange?.(cleaned);
1356
+ return cleaned;
1357
+ });
1358
+ };
1359
+ const handleGlobalFilterChange = (value) => {
1360
+ const next = value.trim() === "" ? "" : value;
1361
+ setGlobalFilter(next);
1362
+ onGlobalFilterChange?.(next);
1363
+ };
1364
+ const handleRowSelectionChange = (updater) => {
1365
+ setRowSelection((old) => {
1366
+ const next = typeof updater === "function" ? updater(old) : updater;
1367
+ onRowSelectionChange?.(next);
1368
+ return next;
1369
+ });
1370
+ };
1371
+ const handleColumnOrderChange = (updater) => {
1372
+ setColumnOrder((old) => {
1373
+ const next = typeof updater === "function" ? updater(old) : updater;
1374
+ const locked = withOrderedUtilities(next, utilityColumnIds);
1375
+ onColumnOrderChange?.(locked);
1376
+ return locked;
1377
+ });
1378
+ };
1379
+ const handleColumnPinningChange = (updater) => {
1380
+ setColumnPinning((old) => {
1381
+ const next = typeof updater === "function" ? updater(old) : updater;
1382
+ const locked = withPinnedUtilities(next, utilityColumnIds);
1383
+ onColumnPinningChange?.(locked);
1384
+ return locked;
1385
+ });
1386
+ };
1387
+ const handlePaginationChange = (updater) => {
1388
+ setPaginationState((old) => {
1389
+ const next = typeof updater === "function" ? updater(old) : updater;
1390
+ onPaginationChange?.(next);
1391
+ paginationOptions.onPageChange?.(next.pageIndex);
1392
+ if (next.pageSize !== old.pageSize) {
1393
+ paginationOptions.onPageSizeChange?.(next.pageSize);
1394
+ }
1395
+ return next;
1396
+ });
1397
+ };
1398
+ const table = useTable({
1399
+ features: dataTableFeatures,
1400
+ data: orderedData,
1401
+ columns: tableColumns,
1402
+ getRowId: getRowId ? (row, index) => String(getRowId(row, index)) : void 0,
1403
+ enableSorting,
1404
+ enableMultiRowSelection,
1405
+ enableRowSelection,
1406
+ enableColumnPinning,
1407
+ enableColumnFilters: columnFiltersActive,
1408
+ enableGlobalFilter,
1409
+ manualSorting,
1410
+ manualFiltering,
1411
+ manualPagination: paginationOptions.manualPagination,
1412
+ pageCount: paginationOptions.pageCount,
1413
+ rowCount: paginationOptions.rowCount,
1414
+ autoResetPageIndex: true,
1415
+ state: {
1416
+ sorting,
1417
+ columnFilters,
1418
+ globalFilter,
1419
+ rowSelection,
1420
+ columnOrder,
1421
+ columnPinning,
1422
+ pagination: paginationState
1423
+ },
1424
+ onSortingChange: handleSortingChange,
1425
+ onColumnFiltersChange: handleColumnFiltersChange,
1426
+ onGlobalFilterChange: handleGlobalFilterChange,
1427
+ onRowSelectionChange: handleRowSelectionChange,
1428
+ onColumnOrderChange: handleColumnOrderChange,
1429
+ onColumnPinningChange: handleColumnPinningChange,
1430
+ onPaginationChange: handlePaginationChange
1431
+ });
1432
+ const sensors = useSensors(
1433
+ useSensor(MouseSensor, { activationConstraint: { distance: 6 } }),
1434
+ useSensor(TouchSensor, { activationConstraint: { delay: 150, tolerance: 5 } }),
1435
+ useSensor(KeyboardSensor)
1436
+ );
1437
+ const handleDragEnd = (event) => {
1438
+ const { active, over } = event;
1439
+ if (!over || active.id === over.id) return;
1440
+ const activeId = String(active.id);
1441
+ const overId = String(over.id);
1442
+ const isColumnDrag = leafColumnIds.includes(activeId) && leafColumnIds.includes(overId);
1443
+ if (isColumnDrag && enableColumnOrdering) {
1444
+ if (utilityColumnIds.includes(activeId) || utilityColumnIds.includes(overId)) {
1445
+ return;
1446
+ }
1447
+ handleColumnOrderChange((order) => {
1448
+ const oldIndex = order.indexOf(activeId);
1449
+ const newIndex = order.indexOf(overId);
1450
+ if (oldIndex < 0 || newIndex < 0) return order;
1451
+ return arrayMove(order, oldIndex, newIndex);
1452
+ });
1453
+ return;
1454
+ }
1455
+ if (enableRowOrdering) {
1456
+ setOrderedData((rows2) => {
1457
+ const ids = rows2.map(
1458
+ (row, index) => getRowId ? String(getRowId(row, index)) : String(index)
1459
+ );
1460
+ const oldIndex = ids.indexOf(activeId);
1461
+ const newIndex = ids.indexOf(overId);
1462
+ if (oldIndex < 0 || newIndex < 0) return rows2;
1463
+ const next = arrayMove(rows2, oldIndex, newIndex);
1464
+ onRowOrderChange?.(next);
1465
+ return next;
1466
+ });
1467
+ }
1468
+ };
1469
+ const rows = table.getRowModel().rows;
1470
+ const selectedCount = Object.keys(table.state.rowSelection).filter(
1471
+ (id) => table.state.rowSelection[id]
1472
+ ).length;
1473
+ const pageCount = Math.max(table.getPageCount(), 1);
1474
+ const pageIndex = table.state.pagination.pageIndex;
1475
+ const headerGroups = table.getHeaderGroups();
1476
+ const sortableColumnIds = table.getAllLeafColumns().map((c) => c.id);
1477
+ const sortableRowIds = rows.map((r) => r.id);
1478
+ const bodyMotionKey = `${paginationState.pageIndex}:${JSON.stringify(columnFilters)}:${globalFilter}`;
1479
+ const Body = animateRows ? motion6.tbody : "tbody";
1480
+ const bodyMotionProps = animateRows ? {
1481
+ variants: staggerContainer(0.04),
1482
+ initial: "hidden",
1483
+ animate: "visible"
1484
+ } : {};
1485
+ return /* @__PURE__ */ jsxs5("div", { className: cn("flex w-full flex-col gap-3", className), ...props, children: [
1486
+ (enableGlobalFilter || toolbar) && /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center gap-3", children: [
1487
+ enableGlobalFilter ? /* @__PURE__ */ jsxs5("div", { className: "relative min-w-[12rem] flex-1", children: [
1488
+ /* @__PURE__ */ jsx8(Search, { className: "pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }),
1489
+ /* @__PURE__ */ jsx8(
1490
+ Input,
1491
+ {
1492
+ value: globalFilter,
1493
+ onChange: (e) => handleGlobalFilterChange(e.target.value),
1494
+ placeholder: globalFilterPlaceholder,
1495
+ className: "pl-9"
1496
+ }
1497
+ )
1498
+ ] }) : null,
1499
+ typeof toolbar === "function" ? toolbar({ selectedCount }) : toolbar,
1500
+ enableRowSelection && selectedCount > 0 ? /* @__PURE__ */ jsxs5("span", { className: "text-sm text-muted-foreground", children: [
1501
+ selectedCount,
1502
+ " selected"
1503
+ ] }) : null
1504
+ ] }),
1505
+ /* @__PURE__ */ jsx8(
1506
+ DndContext,
1507
+ {
1508
+ sensors,
1509
+ collisionDetection: closestCenter,
1510
+ measuring: { droppable: { strategy: MeasuringStrategy.Always } },
1511
+ onDragEnd: handleDragEnd,
1512
+ children: /* @__PURE__ */ jsx8(ColumnDragBridgeProvider, { children: /* @__PURE__ */ jsxs5("div", { className: "w-full overflow-x-auto rounded-xl border border-border bg-card", children: [
1513
+ /* @__PURE__ */ jsxs5("table", { className: "w-full min-w-[36rem] border-collapse text-sm", children: [
1514
+ /* @__PURE__ */ jsx8("thead", { children: headerGroups.map((headerGroup) => /* @__PURE__ */ jsx8("tr", { children: /* @__PURE__ */ jsx8(
1515
+ SortableContext,
1516
+ {
1517
+ items: sortableColumnIds,
1518
+ strategy: horizontalListSortingStrategy,
1519
+ children: headerGroup.headers.map((header) => {
1520
+ if (header.isPlaceholder) {
1521
+ return /* @__PURE__ */ jsx8("th", { colSpan: header.colSpan, className: "p-0" }, header.id);
1522
+ }
1523
+ const canSort = header.column.getCanSort();
1524
+ const sorted = header.column.getIsSorted();
1525
+ return /* @__PURE__ */ jsx8(
1526
+ SortableHeaderCell,
1527
+ {
1528
+ header,
1529
+ enableOrdering: enableColumnOrdering,
1530
+ enablePinning: enableColumnPinning,
1531
+ onFilterOpenChange,
1532
+ onFilterApply,
1533
+ onFilterClear,
1534
+ onPinColumn,
1535
+ children: header.column.id === SELECT_COL_ID || header.column.id === REORDER_COL_ID ? flexRender(header.column.columnDef.header, header.getContext()) : /* @__PURE__ */ jsxs5(
1536
+ "button",
1537
+ {
1538
+ type: "button",
1539
+ className: cn(
1540
+ "inline-flex max-w-full items-center gap-1.5 rounded-md text-left transition-colors",
1541
+ canSort && "hover:text-foreground"
1542
+ ),
1543
+ onClick: canSort ? header.column.getToggleSortingHandler() : void 0,
1544
+ disabled: !canSort,
1545
+ children: [
1546
+ /* @__PURE__ */ jsx8("span", { className: "truncate", children: flexRender(header.column.columnDef.header, header.getContext()) }),
1547
+ canSort ? sorted === "asc" ? /* @__PURE__ */ jsx8(ArrowUp, { className: "size-3.5 shrink-0" }) : sorted === "desc" ? /* @__PURE__ */ jsx8(ArrowDown, { className: "size-3.5 shrink-0" }) : /* @__PURE__ */ jsx8(ArrowUpDown, { className: "size-3.5 shrink-0 opacity-40" }) : null
1548
+ ]
1549
+ }
1550
+ )
1551
+ },
1552
+ header.id
1553
+ );
1554
+ })
1555
+ }
1556
+ ) }, headerGroup.id)) }),
1557
+ /* @__PURE__ */ jsx8(SortableContext, { items: sortableRowIds, strategy: verticalListSortingStrategy, children: /* @__PURE__ */ jsx8(Body, { ...bodyMotionProps, children: rows.length === 0 ? /* @__PURE__ */ jsx8("tr", { children: /* @__PURE__ */ jsx8(
1558
+ "td",
1559
+ {
1560
+ colSpan: Math.max(table.getAllLeafColumns().length, 1),
1561
+ className: "px-4 py-10 text-center text-sm text-muted-foreground",
1562
+ children: emptyMessage
1563
+ }
1564
+ ) }) : rows.map((row) => /* @__PURE__ */ jsx8(
1565
+ SortableBodyRow,
1566
+ {
1567
+ row,
1568
+ enableRowOrdering,
1569
+ animateRows
1570
+ },
1571
+ row.id
1572
+ )) }, bodyMotionKey) })
1573
+ ] }),
1574
+ infinite ? /* @__PURE__ */ jsx8(InfiniteSentinel, { ...infinite }) : null
1575
+ ] }) })
1576
+ }
1577
+ ),
1578
+ paginationEnabled ? /* @__PURE__ */ jsxs5("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [
1579
+ /* @__PURE__ */ jsxs5("p", { className: "text-sm text-muted-foreground", children: [
1580
+ "Page ",
1581
+ pageIndex + 1,
1582
+ " of ",
1583
+ pageCount,
1584
+ enableRowSelection && selectedCount > 0 ? ` \xB7 ${selectedCount} selected` : null
1585
+ ] }),
1586
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3", children: [
1587
+ paginationOptions.pageSizeOptions?.length ? /* @__PURE__ */ jsxs5("label", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
1588
+ "Rows",
1589
+ /* @__PURE__ */ jsx8(
1590
+ "select",
1591
+ {
1592
+ className: "h-9 rounded-lg border border-input bg-card px-2 text-sm text-foreground shadow-xs",
1593
+ value: table.state.pagination.pageSize,
1594
+ onChange: (e) => table.setPageSize(Number(e.target.value)),
1595
+ children: paginationOptions.pageSizeOptions.map((size) => /* @__PURE__ */ jsx8("option", { value: size, children: size }, size))
1596
+ }
1597
+ )
1598
+ ] }) : null,
1599
+ /* @__PURE__ */ jsx8(
1600
+ Pagination,
1601
+ {
1602
+ page: pageIndex + 1,
1603
+ total: pageCount,
1604
+ onPageChange: (page) => {
1605
+ const nextIndex = page - 1;
1606
+ const current = table.state.pagination.pageIndex;
1607
+ table.setPageIndex(nextIndex);
1608
+ if (nextIndex > current) onNextPage?.(nextIndex);
1609
+ if (nextIndex < current) onPreviousPage?.(nextIndex);
1610
+ }
1611
+ }
1612
+ )
1613
+ ] })
1614
+ ] }) : null
1615
+ ] });
1616
+ }
1617
+ export {
1618
+ DataTable
1619
+ };
1620
+ //# sourceMappingURL=data-table.js.map