@health-samurai/react-components 0.0.0-alpha.4 → 0.0.0-alpha.6

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 (304) hide show
  1. package/dist/bundle.css +1375 -484
  2. package/dist/src/components/code-editor/http/grammar/http.d.ts +3 -0
  3. package/dist/src/components/code-editor/http/grammar/http.d.ts.map +1 -0
  4. package/dist/src/components/code-editor/http/grammar/http.grammar +74 -0
  5. package/dist/src/components/code-editor/http/grammar/http.js +38 -0
  6. package/dist/src/components/code-editor/http/grammar/http.js.map +1 -0
  7. package/dist/src/components/code-editor/http/grammar/http.terms.d.ts +2 -0
  8. package/dist/src/components/code-editor/http/grammar/http.terms.d.ts.map +1 -0
  9. package/dist/src/components/code-editor/http/grammar/http.terms.js +4 -0
  10. package/dist/src/components/code-editor/http/grammar/http.terms.js.map +1 -0
  11. package/dist/src/components/code-editor/http/grammar/http.test.d.ts +2 -0
  12. package/dist/src/components/code-editor/http/grammar/http.test.d.ts.map +1 -0
  13. package/dist/src/components/code-editor/http/grammar/http.test.js +80 -0
  14. package/dist/src/components/code-editor/http/grammar/http.test.js.map +1 -0
  15. package/dist/src/components/code-editor/http/index.d.ts +4 -0
  16. package/dist/src/components/code-editor/http/index.d.ts.map +1 -0
  17. package/dist/src/components/code-editor/http/index.js +66 -0
  18. package/dist/src/components/code-editor/http/index.js.map +1 -0
  19. package/dist/src/components/code-editor/index.d.ts +14 -2
  20. package/dist/src/components/code-editor/index.d.ts.map +1 -1
  21. package/dist/src/components/code-editor/index.js +309 -20
  22. package/dist/src/components/code-editor/index.js.map +1 -1
  23. package/dist/src/components/code-editor.stories.d.ts +1 -0
  24. package/dist/src/components/code-editor.stories.d.ts.map +1 -1
  25. package/dist/src/components/code-editor.stories.js +255 -2
  26. package/dist/src/components/code-editor.stories.js.map +1 -1
  27. package/dist/src/components/copy-icon.d.ts +5 -1
  28. package/dist/src/components/copy-icon.d.ts.map +1 -1
  29. package/dist/src/components/copy-icon.js +41 -3
  30. package/dist/src/components/copy-icon.js.map +1 -1
  31. package/dist/src/components/data-table.d.ts +8 -0
  32. package/dist/src/components/data-table.d.ts.map +1 -0
  33. package/dist/src/components/data-table.js +65 -0
  34. package/dist/src/components/data-table.js.map +1 -0
  35. package/dist/src/components/data-table.stories.d.ts +7 -0
  36. package/dist/src/components/data-table.stories.d.ts.map +1 -0
  37. package/dist/src/components/data-table.stories.js +44 -0
  38. package/dist/src/components/data-table.stories.js.map +1 -0
  39. package/dist/src/components/fhir-structure-view.d.ts +34 -0
  40. package/dist/src/components/fhir-structure-view.d.ts.map +1 -0
  41. package/dist/src/components/fhir-structure-view.js +229 -0
  42. package/dist/src/components/fhir-structure-view.js.map +1 -0
  43. package/dist/src/components/fhir-structure-view.stories.d.ts +7 -0
  44. package/dist/src/components/fhir-structure-view.stories.d.ts.map +1 -0
  45. package/dist/src/components/fhir-structure-view.stories.js +447 -0
  46. package/dist/src/components/fhir-structure-view.stories.js.map +1 -0
  47. package/dist/src/components/patient-table.d.ts +73 -0
  48. package/dist/src/components/patient-table.d.ts.map +1 -0
  49. package/dist/src/components/patient-table.js +921 -0
  50. package/dist/src/components/patient-table.js.map +1 -0
  51. package/dist/src/components/patient-table.stories.d.ts +111 -0
  52. package/dist/src/components/patient-table.stories.d.ts.map +1 -0
  53. package/dist/src/components/patient-table.stories.js +172 -0
  54. package/dist/src/components/patient-table.stories.js.map +1 -0
  55. package/dist/src/components/request-line-editor.d.ts +13 -35
  56. package/dist/src/components/request-line-editor.d.ts.map +1 -1
  57. package/dist/src/components/request-line-editor.js +72 -49
  58. package/dist/src/components/request-line-editor.js.map +1 -1
  59. package/dist/src/components/request-line-editor.stories.d.ts.map +1 -1
  60. package/dist/src/components/request-line-editor.stories.js +17 -53
  61. package/dist/src/components/request-line-editor.stories.js.map +1 -1
  62. package/dist/src/components/segment-control.d.ts +16 -0
  63. package/dist/src/components/segment-control.d.ts.map +1 -0
  64. package/dist/src/components/segment-control.js +48 -0
  65. package/dist/src/components/segment-control.js.map +1 -0
  66. package/dist/src/components/segment-control.stories.d.ts +15 -0
  67. package/dist/src/components/segment-control.stories.d.ts.map +1 -0
  68. package/dist/src/components/segment-control.stories.js +33 -0
  69. package/dist/src/components/segment-control.stories.js.map +1 -0
  70. package/dist/src/components/split-button.d.ts +5 -0
  71. package/dist/src/components/split-button.d.ts.map +1 -0
  72. package/dist/src/components/split-button.js +12 -0
  73. package/dist/src/components/split-button.js.map +1 -0
  74. package/dist/src/components/split-button.stories.d.ts +7 -0
  75. package/dist/src/components/split-button.stories.d.ts.map +1 -0
  76. package/dist/src/components/split-button.stories.js +57 -0
  77. package/dist/src/components/split-button.stories.js.map +1 -0
  78. package/dist/src/components/tree-view.d.ts +22 -0
  79. package/dist/src/components/tree-view.d.ts.map +1 -0
  80. package/dist/src/components/tree-view.js +101 -0
  81. package/dist/src/components/tree-view.js.map +1 -0
  82. package/dist/src/components/tree-view.stories.d.ts +13 -0
  83. package/dist/src/components/tree-view.stories.d.ts.map +1 -0
  84. package/dist/src/components/tree-view.stories.js +274 -0
  85. package/dist/src/components/tree-view.stories.js.map +1 -0
  86. package/dist/src/icons.d.ts +9 -0
  87. package/dist/src/icons.d.ts.map +1 -0
  88. package/dist/src/icons.js +279 -0
  89. package/dist/src/icons.js.map +1 -0
  90. package/dist/src/index.css +42 -3
  91. package/dist/src/index.d.ts +9 -1
  92. package/dist/src/index.d.ts.map +1 -1
  93. package/dist/src/index.js +9 -1
  94. package/dist/src/index.js.map +1 -1
  95. package/dist/src/shadcn/components/ui/accordion.d.ts.map +1 -1
  96. package/dist/src/shadcn/components/ui/accordion.js +23 -5
  97. package/dist/src/shadcn/components/ui/accordion.js.map +1 -1
  98. package/dist/src/shadcn/components/ui/alert-dialog.d.ts +3 -1
  99. package/dist/src/shadcn/components/ui/alert-dialog.d.ts.map +1 -1
  100. package/dist/src/shadcn/components/ui/alert-dialog.js +5 -2
  101. package/dist/src/shadcn/components/ui/alert-dialog.js.map +1 -1
  102. package/dist/src/shadcn/components/ui/alert.d.ts.map +1 -1
  103. package/dist/src/shadcn/components/ui/alert.js +12 -5
  104. package/dist/src/shadcn/components/ui/alert.js.map +1 -1
  105. package/dist/src/shadcn/components/ui/avatar.d.ts.map +1 -1
  106. package/dist/src/shadcn/components/ui/avatar.js +4 -3
  107. package/dist/src/shadcn/components/ui/avatar.js.map +1 -1
  108. package/dist/src/shadcn/components/ui/badge.d.ts.map +1 -1
  109. package/dist/src/shadcn/components/ui/badge.js +16 -5
  110. package/dist/src/shadcn/components/ui/badge.js.map +1 -1
  111. package/dist/src/shadcn/components/ui/breadcrumb.d.ts.map +1 -1
  112. package/dist/src/shadcn/components/ui/breadcrumb.js +6 -6
  113. package/dist/src/shadcn/components/ui/breadcrumb.js.map +1 -1
  114. package/dist/src/shadcn/components/ui/button.d.ts.map +1 -1
  115. package/dist/src/shadcn/components/ui/button.js +19 -11
  116. package/dist/src/shadcn/components/ui/button.js.map +1 -1
  117. package/dist/src/shadcn/components/ui/card.d.ts.map +1 -1
  118. package/dist/src/shadcn/components/ui/card.js +14 -6
  119. package/dist/src/shadcn/components/ui/card.js.map +1 -1
  120. package/dist/src/shadcn/components/ui/checkbox.d.ts.map +1 -1
  121. package/dist/src/shadcn/components/ui/checkbox.js +20 -5
  122. package/dist/src/shadcn/components/ui/checkbox.js.map +1 -1
  123. package/dist/src/shadcn/components/ui/checkbox.stories.d.ts.map +1 -1
  124. package/dist/src/shadcn/components/ui/checkbox.stories.js +44 -35
  125. package/dist/src/shadcn/components/ui/checkbox.stories.js.map +1 -1
  126. package/dist/src/shadcn/components/ui/combobox.d.ts +18 -0
  127. package/dist/src/shadcn/components/ui/combobox.d.ts.map +1 -0
  128. package/dist/src/shadcn/components/ui/combobox.js +121 -0
  129. package/dist/src/shadcn/components/ui/combobox.js.map +1 -0
  130. package/dist/src/shadcn/components/ui/combobox.stories.d.ts +11 -0
  131. package/dist/src/shadcn/components/ui/combobox.stories.d.ts.map +1 -0
  132. package/dist/src/shadcn/components/ui/combobox.stories.js +16 -0
  133. package/dist/src/shadcn/components/ui/combobox.stories.js.map +1 -0
  134. package/dist/src/shadcn/components/ui/command.d.ts.map +1 -1
  135. package/dist/src/shadcn/components/ui/command.js +73 -12
  136. package/dist/src/shadcn/components/ui/command.js.map +1 -1
  137. package/dist/src/shadcn/components/ui/command.stories.js +0 -1
  138. package/dist/src/shadcn/components/ui/command.stories.js.map +1 -1
  139. package/dist/src/shadcn/components/ui/dialog.d.ts.map +1 -1
  140. package/dist/src/shadcn/components/ui/dialog.js +35 -7
  141. package/dist/src/shadcn/components/ui/dialog.js.map +1 -1
  142. package/dist/src/shadcn/components/ui/drawer.d.ts.map +1 -1
  143. package/dist/src/shadcn/components/ui/drawer.js +26 -5
  144. package/dist/src/shadcn/components/ui/drawer.js.map +1 -1
  145. package/dist/src/shadcn/components/ui/dropdown-menu.d.ts.map +1 -1
  146. package/dist/src/shadcn/components/ui/dropdown-menu.js +12 -1
  147. package/dist/src/shadcn/components/ui/dropdown-menu.js.map +1 -1
  148. package/dist/src/shadcn/components/ui/form.d.ts.map +1 -1
  149. package/dist/src/shadcn/components/ui/form.js +12 -4
  150. package/dist/src/shadcn/components/ui/form.js.map +1 -1
  151. package/dist/src/shadcn/components/ui/input.d.ts +3 -1
  152. package/dist/src/shadcn/components/ui/input.d.ts.map +1 -1
  153. package/dist/src/shadcn/components/ui/input.js +126 -17
  154. package/dist/src/shadcn/components/ui/input.js.map +1 -1
  155. package/dist/src/shadcn/components/ui/label.d.ts.map +1 -1
  156. package/dist/src/shadcn/components/ui/label.js +8 -1
  157. package/dist/src/shadcn/components/ui/label.js.map +1 -1
  158. package/dist/src/shadcn/components/ui/menubar.d.ts.map +1 -1
  159. package/dist/src/shadcn/components/ui/menubar.js +35 -13
  160. package/dist/src/shadcn/components/ui/menubar.js.map +1 -1
  161. package/dist/src/shadcn/components/ui/pagination.d.ts.map +1 -1
  162. package/dist/src/shadcn/components/ui/pagination.js +6 -6
  163. package/dist/src/shadcn/components/ui/pagination.js.map +1 -1
  164. package/dist/src/shadcn/components/ui/popover.d.ts.map +1 -1
  165. package/dist/src/shadcn/components/ui/popover.js +12 -1
  166. package/dist/src/shadcn/components/ui/popover.js.map +1 -1
  167. package/dist/src/shadcn/components/ui/progress.d.ts.map +1 -1
  168. package/dist/src/shadcn/components/ui/progress.js +6 -2
  169. package/dist/src/shadcn/components/ui/progress.js.map +1 -1
  170. package/dist/src/shadcn/components/ui/radio-group.d.ts.map +1 -1
  171. package/dist/src/shadcn/components/ui/radio-group.js +11 -6
  172. package/dist/src/shadcn/components/ui/radio-group.js.map +1 -1
  173. package/dist/src/shadcn/components/ui/radio-group.stories.d.ts.map +1 -1
  174. package/dist/src/shadcn/components/ui/radio-group.stories.js +57 -34
  175. package/dist/src/shadcn/components/ui/radio-group.stories.js.map +1 -1
  176. package/dist/src/shadcn/components/ui/scroll-area.d.ts.map +1 -1
  177. package/dist/src/shadcn/components/ui/scroll-area.js +9 -3
  178. package/dist/src/shadcn/components/ui/scroll-area.js.map +1 -1
  179. package/dist/src/shadcn/components/ui/select.d.ts.map +1 -1
  180. package/dist/src/shadcn/components/ui/select.js +49 -14
  181. package/dist/src/shadcn/components/ui/select.js.map +1 -1
  182. package/dist/src/shadcn/components/ui/select.stories.d.ts.map +1 -1
  183. package/dist/src/shadcn/components/ui/select.stories.js +1 -4
  184. package/dist/src/shadcn/components/ui/select.stories.js.map +1 -1
  185. package/dist/src/shadcn/components/ui/separator.d.ts.map +1 -1
  186. package/dist/src/shadcn/components/ui/separator.js +7 -1
  187. package/dist/src/shadcn/components/ui/separator.js.map +1 -1
  188. package/dist/src/shadcn/components/ui/sidebar.d.ts.map +1 -1
  189. package/dist/src/shadcn/components/ui/sidebar.js +20 -6
  190. package/dist/src/shadcn/components/ui/sidebar.js.map +1 -1
  191. package/dist/src/shadcn/components/ui/skeleton.d.ts.map +1 -1
  192. package/dist/src/shadcn/components/ui/skeleton.js +3 -1
  193. package/dist/src/shadcn/components/ui/skeleton.js.map +1 -1
  194. package/dist/src/shadcn/components/ui/slider.d.ts.map +1 -1
  195. package/dist/src/shadcn/components/ui/slider.js +34 -4
  196. package/dist/src/shadcn/components/ui/slider.js.map +1 -1
  197. package/dist/src/shadcn/components/ui/sonner.d.ts +16 -1
  198. package/dist/src/shadcn/components/ui/sonner.d.ts.map +1 -1
  199. package/dist/src/shadcn/components/ui/sonner.js +23 -3
  200. package/dist/src/shadcn/components/ui/sonner.js.map +1 -1
  201. package/dist/src/shadcn/components/ui/sonner.stories.d.ts.map +1 -1
  202. package/dist/src/shadcn/components/ui/sonner.stories.js +19 -11
  203. package/dist/src/shadcn/components/ui/sonner.stories.js.map +1 -1
  204. package/dist/src/shadcn/components/ui/switch.d.ts.map +1 -1
  205. package/dist/src/shadcn/components/ui/switch.js +18 -2
  206. package/dist/src/shadcn/components/ui/switch.js.map +1 -1
  207. package/dist/src/shadcn/components/ui/table.d.ts.map +1 -1
  208. package/dist/src/shadcn/components/ui/table.js +12 -8
  209. package/dist/src/shadcn/components/ui/table.js.map +1 -1
  210. package/dist/src/shadcn/components/ui/tabs.d.ts +21 -3
  211. package/dist/src/shadcn/components/ui/tabs.d.ts.map +1 -1
  212. package/dist/src/shadcn/components/ui/tabs.js +315 -9
  213. package/dist/src/shadcn/components/ui/tabs.js.map +1 -1
  214. package/dist/src/shadcn/components/ui/tabs.stories.d.ts.map +1 -1
  215. package/dist/src/shadcn/components/ui/tabs.stories.js +50 -1
  216. package/dist/src/shadcn/components/ui/tabs.stories.js.map +1 -1
  217. package/dist/src/shadcn/components/ui/textarea.d.ts.map +1 -1
  218. package/dist/src/shadcn/components/ui/textarea.js +15 -1
  219. package/dist/src/shadcn/components/ui/textarea.js.map +1 -1
  220. package/dist/src/shadcn/components/ui/toggle-group.d.ts.map +1 -1
  221. package/dist/src/shadcn/components/ui/toggle-group.js +6 -2
  222. package/dist/src/shadcn/components/ui/toggle-group.js.map +1 -1
  223. package/dist/src/shadcn/components/ui/toggle.d.ts.map +1 -1
  224. package/dist/src/shadcn/components/ui/toggle.js +18 -6
  225. package/dist/src/shadcn/components/ui/toggle.js.map +1 -1
  226. package/dist/src/shadcn/components/ui/tooltip.d.ts.map +1 -1
  227. package/dist/src/shadcn/components/ui/tooltip.js +11 -1
  228. package/dist/src/shadcn/components/ui/tooltip.js.map +1 -1
  229. package/dist/src/shadcn/components/ui/tree.d.ts +28 -0
  230. package/dist/src/shadcn/components/ui/tree.d.ts.map +1 -0
  231. package/dist/src/shadcn/components/ui/tree.js +122 -0
  232. package/dist/src/shadcn/components/ui/tree.js.map +1 -0
  233. package/dist/src/typography.css +12 -0
  234. package/package.json +13 -2
  235. package/src/components/code-editor/http/grammar/http.grammar +74 -0
  236. package/src/components/code-editor/http/grammar/http.terms.ts +9 -0
  237. package/src/components/code-editor/http/grammar/http.test.ts +110 -0
  238. package/src/components/code-editor/http/grammar/http.ts +21 -0
  239. package/src/components/code-editor/http/index.ts +87 -0
  240. package/src/components/code-editor/index.tsx +307 -21
  241. package/src/components/code-editor.stories.tsx +295 -1
  242. package/src/components/copy-icon.tsx +57 -3
  243. package/src/components/data-table.stories.tsx +38 -0
  244. package/src/components/data-table.tsx +117 -0
  245. package/src/components/fhir-structure-view.stories.tsx +439 -0
  246. package/src/components/fhir-structure-view.tsx +231 -0
  247. package/src/components/patient-table.stories.tsx +111 -0
  248. package/src/components/patient-table.tsx +1301 -0
  249. package/src/components/request-line-editor.stories.tsx +17 -27
  250. package/src/components/request-line-editor.tsx +98 -61
  251. package/src/components/segment-control.stories.tsx +29 -0
  252. package/src/components/segment-control.tsx +80 -0
  253. package/src/components/split-button.stories.tsx +49 -0
  254. package/src/components/split-button.tsx +17 -0
  255. package/src/components/tree-view.stories.tsx +259 -0
  256. package/src/components/tree-view.tsx +172 -0
  257. package/src/icons.tsx +287 -0
  258. package/src/index.css +42 -3
  259. package/src/index.tsx +9 -2
  260. package/src/shadcn/components/ui/accordion.tsx +66 -8
  261. package/src/shadcn/components/ui/alert-dialog.tsx +6 -2
  262. package/src/shadcn/components/ui/alert.tsx +53 -15
  263. package/src/shadcn/components/ui/avatar.tsx +17 -6
  264. package/src/shadcn/components/ui/badge.tsx +67 -18
  265. package/src/shadcn/components/ui/breadcrumb.tsx +35 -7
  266. package/src/shadcn/components/ui/button.tsx +118 -57
  267. package/src/shadcn/components/ui/card.tsx +44 -13
  268. package/src/shadcn/components/ui/checkbox.stories.tsx +20 -24
  269. package/src/shadcn/components/ui/checkbox.tsx +45 -4
  270. package/src/shadcn/components/ui/combobox.stories.tsx +19 -0
  271. package/src/shadcn/components/ui/combobox.tsx +142 -0
  272. package/src/shadcn/components/ui/command.stories.tsx +1 -1
  273. package/src/shadcn/components/ui/command.tsx +192 -36
  274. package/src/shadcn/components/ui/dialog.tsx +101 -13
  275. package/src/shadcn/components/ui/drawer.tsx +93 -18
  276. package/src/shadcn/components/ui/dropdown-menu.tsx +37 -9
  277. package/src/shadcn/components/ui/form.tsx +16 -4
  278. package/src/shadcn/components/ui/input.tsx +400 -29
  279. package/src/shadcn/components/ui/label.tsx +21 -4
  280. package/src/shadcn/components/ui/menubar.tsx +188 -43
  281. package/src/shadcn/components/ui/pagination.tsx +12 -6
  282. package/src/shadcn/components/ui/popover.tsx +35 -4
  283. package/src/shadcn/components/ui/progress.tsx +21 -5
  284. package/src/shadcn/components/ui/radio-group.stories.tsx +22 -14
  285. package/src/shadcn/components/ui/radio-group.tsx +42 -5
  286. package/src/shadcn/components/ui/scroll-area.tsx +33 -5
  287. package/src/shadcn/components/ui/select.stories.tsx +0 -2
  288. package/src/shadcn/components/ui/select.tsx +184 -33
  289. package/src/shadcn/components/ui/separator.tsx +15 -5
  290. package/src/shadcn/components/ui/sidebar.tsx +68 -26
  291. package/src/shadcn/components/ui/skeleton.tsx +4 -1
  292. package/src/shadcn/components/ui/slider.tsx +82 -11
  293. package/src/shadcn/components/ui/sonner.stories.tsx +19 -15
  294. package/src/shadcn/components/ui/sonner.tsx +53 -3
  295. package/src/shadcn/components/ui/switch.tsx +53 -7
  296. package/src/shadcn/components/ui/table.tsx +38 -11
  297. package/src/shadcn/components/ui/tabs.stories.tsx +32 -0
  298. package/src/shadcn/components/ui/tabs.tsx +456 -17
  299. package/src/shadcn/components/ui/textarea.tsx +42 -4
  300. package/src/shadcn/components/ui/toggle-group.tsx +27 -5
  301. package/src/shadcn/components/ui/toggle.tsx +59 -18
  302. package/src/shadcn/components/ui/tooltip.tsx +33 -8
  303. package/src/shadcn/components/ui/tree.tsx +233 -0
  304. package/src/typography.css +12 -0
@@ -0,0 +1,921 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
3
+ import { ArrowLeftToLine, ArrowRightToLine, ChevronDown, ChevronUp, GripVertical, MoreHorizontal, PinOff, Search } from "lucide-react";
4
+ import { useEffect, useMemo, useState } from "react";
5
+ import { Button } from "../shadcn/components/ui/button.js";
6
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../shadcn/components/ui/dropdown-menu.js";
7
+ import { Input } from "../shadcn/components/ui/input.js";
8
+ import { cn } from "../shadcn/lib/utils.js";
9
+ // Unstyled table components to preserve custom styling
10
+ const Table = ({ className, ...props })=>/*#__PURE__*/ _jsx("table", {
11
+ className: className,
12
+ ...props
13
+ });
14
+ const TableHeader = ({ className, ...props })=>/*#__PURE__*/ _jsx("thead", {
15
+ className: className,
16
+ ...props
17
+ });
18
+ const TableBody = ({ className, ...props })=>/*#__PURE__*/ _jsx("tbody", {
19
+ className: className,
20
+ ...props
21
+ });
22
+ const TableRow = ({ className, ...props })=>/*#__PURE__*/ _jsx("tr", {
23
+ className: className,
24
+ ...props
25
+ });
26
+ const TableHead = ({ className, ...props })=>/*#__PURE__*/ _jsx("th", {
27
+ className: className,
28
+ ...props
29
+ });
30
+ const TableCell = ({ className, ...props })=>/*#__PURE__*/ _jsx("td", {
31
+ className: className,
32
+ ...props
33
+ });
34
+ const getPinningStyles = (column)=>{
35
+ const isPinned = column.getIsPinned();
36
+ return {
37
+ left: isPinned === "left" ? `${column.getStart("left")}px` : undefined,
38
+ right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined,
39
+ position: isPinned ? "sticky" : "relative",
40
+ width: column.getSize(),
41
+ zIndex: isPinned ? 1 : 0
42
+ };
43
+ };
44
+ // Styles
45
+ const styles = {
46
+ // Table container
47
+ tableContainer: cn("w-full", "overflow-x-auto", "border", "border-border-secondary", "rounded-md"),
48
+ table: cn("w-full", "table-fixed", "border-collapse", "text-sm", "[&_td]:border-border", "[&_th]:border-border", "border-separate", "border-spacing-0", "[&_tfoot_td]:border-t", "[&_th]:border-b", "[&_tr]:border-none"),
49
+ // Global cell padding
50
+ cellPadding: cn("px-4"),
51
+ pinnedColumn: cn("data-pinned:bg-background/90", "data-pinned:backdrop-blur-xs", "[&[data-pinned=left][data-last-col=left]]:border-r", "[&[data-pinned=left][data-last-col=left]]:border-r-border-primary", "[&[data-pinned=right][data-last-col=right]]:border-l", "[&[data-pinned=right][data-last-col=right]]:border-l-border-primary"),
52
+ pinnedHeader: cn("data-pinned:bg-muted/90", "data-pinned:backdrop-blur-xs", "[&[data-pinned=left][data-last-col=left]]:border-r", "[&[data-pinned=left][data-last-col=left]]:border-r-border-primary", "[&[data-pinned=right][data-last-col=right]]:border-l", "[&[data-pinned=right][data-last-col=right]]:border-l-border-primary"),
53
+ // Header styles
54
+ thead: cn("bg-bg-secondary"),
55
+ th: cn("h-8", "text-left", "font-medium", "text-text-primary", "select-none"),
56
+ thSortable: cn("cursor-pointer", "hover:bg-bg-tertiary"),
57
+ thSorted: cn("bg-bg-link/3", "border-b", "border-border-link"),
58
+ thRightAlign: cn("text-right"),
59
+ // Cell styles for sorted columns
60
+ cellSorted: cn("bg-bg-link/3"),
61
+ // Header content
62
+ headerContent: cn("h-8", "flex", "items-center", "justify-between", "typo-body", "text-text-secondary", "relative", "w-full"),
63
+ headerText: cn("truncate", "pr-3"),
64
+ headerIcons: cn("flex", "flex-col", "items-center", "justify-center"),
65
+ headerIcon: cn("w-3", "h-3"),
66
+ headerIconInactive: cn("w-3", "h-3", "opacity-30"),
67
+ // Cell content
68
+ cellContent: cn("h-8", "flex", "items-center", "text-text-primary"),
69
+ cellText: cn("truncate"),
70
+ cellCode: cn("h-8", "flex", "items-center", "text-text-primary", "typo-code"),
71
+ cellRightAlign: cn("justify-end"),
72
+ cellTextRightAlign: cn("text-right"),
73
+ // Filter row
74
+ filterRow: cn("bg-white", "border-b", "border-border-secondary"),
75
+ filterCell: cn("px-1", "h-8"),
76
+ filterCellPinned: cn("px-1", "h-8", "bg-white/90", "backdrop-blur-xs"),
77
+ filterActions: cn("text-text-tertiary", "text-sm"),
78
+ filterInput: cn("border-0", "h-8"),
79
+ filterIcon: cn("w-4", "h-4", "text-text-tertiary"),
80
+ dataRow: cn("hover:bg-bg-link/10"),
81
+ dataRowZebra: cn("bg-bg-secondary", "hover:bg-bg-link/10"),
82
+ dataCell: cn("h-8"),
83
+ // Action button
84
+ actionButton: cn("text-text-link", "hover:text-text-link_hover", "transition-colors", "cursor-pointer"),
85
+ // Action link
86
+ actionLink: cn("text-text-link", "hover:text-text-link_hover", "transition-colors", "cursor-pointer"),
87
+ // Column resize handle
88
+ resizeHandle: cn("absolute", "right-0", "top-0", "h-full", "w-1", "bg-border-primary", "cursor-col-resize", "user-select-none", "touch-action-none", "opacity-0", "hover:opacity-100", "active:opacity-100", "transition-opacity", "duration-150", "before:absolute", "before:right-[-4px]", "before:top-0", "before:w-2", "before:h-full", "before:content-['']"),
89
+ resizeHandleActive: cn("opacity-100", "bg-border-link"),
90
+ // Resizable header indicator
91
+ resizableHeader: cn("group-hover:[&:not(:last-child)]:after:opacity-30", "after:absolute", "after:right-0", "after:top-1/2", "after:-translate-y-1/2", "after:h-4", "after:w-px", "after:bg-border-primary", "after:opacity-0", "after:transition-opacity", "after:duration-150", "hover:after:opacity-50", "last:after:w-0"),
92
+ // Draggable header styles
93
+ draggableHeader: cn("transition-all", "duration-150", "group/header"),
94
+ dragZone: cn("absolute", "left-0", "top-0", "h-full", "cursor-grab", "active:cursor-grabbing", "flex", "items-center", "justify-start", "pl-0", "opacity-0", "hover:opacity-100", "group-hover/header:opacity-60", "hover:!opacity-100", "transition-opacity", "duration-150", "bg-transparent", "border-none", "text-text-tertiary", "hover:text-text-secondary", "right-5"),
95
+ draggingHeader: cn("bg-bg-primary_inverse/10", "scale-105", "shadow-lg", "z-50"),
96
+ draggingColumn: cn("bg-bg-primary_inverse/10", "shadow-inner"),
97
+ dropZone: cn("relative", "before:absolute", "before:left-0", "before:top-0", "before:w-1", "before:h-full", "before:bg-border-link", "before:opacity-0", "before:transition-opacity", "before:duration-150"),
98
+ dropZoneActive: cn("before:opacity-100")
99
+ };
100
+ // Mock components
101
+ function TableHeaderContent({ content, isSortable = false, sortDirection = null, isPinnable = false, pinnedDirection = false, onPin }) {
102
+ return /*#__PURE__*/ _jsxs("div", {
103
+ className: styles.headerContent,
104
+ children: [
105
+ /*#__PURE__*/ _jsx("span", {
106
+ className: styles.headerText,
107
+ children: content
108
+ }),
109
+ /*#__PURE__*/ _jsxs("div", {
110
+ className: "flex items-center",
111
+ children: [
112
+ isSortable && /*#__PURE__*/ _jsx("div", {
113
+ className: styles.headerIcons,
114
+ children: sortDirection === "asc" ? /*#__PURE__*/ _jsx(ChevronUp, {
115
+ className: styles.headerIcon
116
+ }) : sortDirection === "desc" ? /*#__PURE__*/ _jsx(ChevronDown, {
117
+ className: styles.headerIcon
118
+ }) : /*#__PURE__*/ _jsxs("div", {
119
+ className: "flex flex-col",
120
+ children: [
121
+ /*#__PURE__*/ _jsx(ChevronUp, {
122
+ className: styles.headerIconInactive
123
+ }),
124
+ /*#__PURE__*/ _jsx(ChevronDown, {
125
+ className: styles.headerIconInactive
126
+ })
127
+ ]
128
+ })
129
+ }),
130
+ isPinnable && onPin && (pinnedDirection ? /*#__PURE__*/ _jsx(Button, {
131
+ size: "small",
132
+ variant: "ghost",
133
+ className: "h-6 w-6 p-0 ml-1 opacity-60 hover:opacity-100",
134
+ onClick: ()=>onPin(false),
135
+ title: "Unpin column",
136
+ children: /*#__PURE__*/ _jsx(PinOff, {
137
+ className: "h-3 w-3"
138
+ })
139
+ }) : /*#__PURE__*/ _jsxs(DropdownMenu, {
140
+ children: [
141
+ /*#__PURE__*/ _jsx(DropdownMenuTrigger, {
142
+ asChild: true,
143
+ children: /*#__PURE__*/ _jsx(Button, {
144
+ size: "small",
145
+ variant: "ghost",
146
+ className: "h-6 w-6 p-0 ml-1 opacity-60 hover:opacity-100",
147
+ title: "Pin column",
148
+ children: /*#__PURE__*/ _jsx(MoreHorizontal, {
149
+ className: "h-3 w-3"
150
+ })
151
+ })
152
+ }),
153
+ /*#__PURE__*/ _jsxs(DropdownMenuContent, {
154
+ align: "end",
155
+ children: [
156
+ /*#__PURE__*/ _jsxs(DropdownMenuItem, {
157
+ onClick: ()=>onPin("left"),
158
+ children: [
159
+ /*#__PURE__*/ _jsx(ArrowLeftToLine, {
160
+ className: "mr-2 h-4 w-4"
161
+ }),
162
+ "Stick to left"
163
+ ]
164
+ }),
165
+ /*#__PURE__*/ _jsxs(DropdownMenuItem, {
166
+ onClick: ()=>onPin("right"),
167
+ children: [
168
+ /*#__PURE__*/ _jsx(ArrowRightToLine, {
169
+ className: "mr-2 h-4 w-4"
170
+ }),
171
+ "Stick to right"
172
+ ]
173
+ })
174
+ ]
175
+ })
176
+ ]
177
+ }))
178
+ ]
179
+ })
180
+ ]
181
+ });
182
+ }
183
+ function TableCellContent({ content, type = "text", rightAlign = false, actions = [], rowId }) {
184
+ // For action types, render actions instead of content
185
+ if (type === "link" || type === "button") {
186
+ return /*#__PURE__*/ _jsx("div", {
187
+ className: cn(styles.cellContent, rightAlign && styles.cellRightAlign),
188
+ children: /*#__PURE__*/ _jsx("div", {
189
+ className: "flex gap-2",
190
+ children: actions.map((action, index)=>{
191
+ const handleClick = (e)=>{
192
+ e.stopPropagation();
193
+ action.onClick(rowId || "");
194
+ };
195
+ const actionKey = `${rowId}-${action.label}-${index}`;
196
+ if (type === "button") {
197
+ return /*#__PURE__*/ _jsx(Button, {
198
+ variant: action.variant || "primary",
199
+ size: "small",
200
+ ...action.danger !== undefined && {
201
+ danger: action.danger
202
+ },
203
+ onClick: handleClick,
204
+ children: action.label
205
+ }, actionKey);
206
+ }
207
+ // Default to link type
208
+ return /*#__PURE__*/ _jsx("button", {
209
+ type: "button",
210
+ className: styles.actionLink,
211
+ onClick: handleClick,
212
+ children: action.label
213
+ }, actionKey);
214
+ })
215
+ })
216
+ });
217
+ }
218
+ // For regular content
219
+ const cellClass = cn(type === "code" ? styles.cellCode : styles.cellContent, rightAlign && styles.cellRightAlign);
220
+ const textClass = cn(styles.cellText, rightAlign && styles.cellTextRightAlign);
221
+ return /*#__PURE__*/ _jsx("div", {
222
+ className: cellClass,
223
+ children: /*#__PURE__*/ _jsx("span", {
224
+ className: textClass,
225
+ children: content
226
+ })
227
+ });
228
+ }
229
+ // Filter row component
230
+ function FilterRow({ headers, draggedColumn, dropTarget }) {
231
+ return /*#__PURE__*/ _jsx(TableRow, {
232
+ className: styles.filterRow,
233
+ children: headers.map((header)=>{
234
+ const tableColumn = header.column;
235
+ const columnKey = header.id;
236
+ const isPinned = tableColumn.getIsPinned();
237
+ const isBeingDragged = draggedColumn === columnKey;
238
+ const isDropTarget = dropTarget === columnKey;
239
+ const isLastLeftPinned = isPinned === "left" && tableColumn.getIsLastColumn("left");
240
+ const isFirstRightPinned = isPinned === "right" && tableColumn.getIsFirstColumn("right");
241
+ return /*#__PURE__*/ _jsx(TableCell, {
242
+ className: cn(isPinned ? styles.filterCellPinned : styles.filterCell, styles.pinnedColumn, isBeingDragged && styles.draggingColumn, isDropTarget && styles.dropZone, isDropTarget && styles.dropZoneActive),
243
+ style: {
244
+ ...getPinningStyles(tableColumn)
245
+ },
246
+ "data-pinned": isPinned || undefined,
247
+ "data-last-col": isLastLeftPinned ? "left" : isFirstRightPinned ? "right" : undefined,
248
+ children: columnKey === "actions" ? /*#__PURE__*/ _jsx("div", {
249
+ className: styles.filterActions
250
+ }) : /*#__PURE__*/ _jsx(Input, {
251
+ placeholder: "Search",
252
+ leftSlot: /*#__PURE__*/ _jsx(Search, {
253
+ className: styles.filterIcon
254
+ }),
255
+ onChange: (e)=>console.log(`Filter ${columnKey}:`, e.target.value),
256
+ className: styles.filterInput
257
+ })
258
+ }, `filter-${columnKey}`);
259
+ })
260
+ });
261
+ }
262
+ function DataTable({ columns, data, showZebraStripes, showFilters = true, showSorting = true, enableColumnResizing = false, enableColumnReordering = false, enableColumnPinning = false, onSort, columnWidths = {}, sortConfig, columnOrder = [], onColumnOrderChange, columnPinning = {}, onColumnPinningChange, columnConfigs }) {
263
+ const [draggedColumn, setDraggedColumn] = useState(null);
264
+ const [dropTarget, setDropTarget] = useState(null);
265
+ const initialColumnSizing = useMemo(()=>{
266
+ if (!enableColumnResizing || !columnConfigs) return {};
267
+ const sizing = {};
268
+ columnConfigs.forEach((config)=>{
269
+ if (config.width) {
270
+ const width = parseInt(config.width.replace("px", ""), 10);
271
+ if (!Number.isNaN(width)) {
272
+ sizing[config.key] = width;
273
+ }
274
+ }
275
+ });
276
+ return sizing;
277
+ }, [
278
+ enableColumnResizing,
279
+ columnConfigs
280
+ ]);
281
+ const table = useReactTable({
282
+ data,
283
+ columns,
284
+ getCoreRowModel: getCoreRowModel(),
285
+ enableColumnResizing,
286
+ enableColumnPinning,
287
+ columnResizeMode: "onChange",
288
+ state: {
289
+ ...columnOrder.length > 0 && {
290
+ columnOrder
291
+ },
292
+ ...enableColumnPinning && {
293
+ columnPinning
294
+ }
295
+ },
296
+ ...onColumnOrderChange && {
297
+ onColumnOrderChange: (updater)=>{
298
+ const newOrder = typeof updater === "function" ? updater(columnOrder) : updater;
299
+ onColumnOrderChange(newOrder);
300
+ }
301
+ },
302
+ ...onColumnPinningChange && enableColumnPinning && {
303
+ onColumnPinningChange: (updater)=>{
304
+ const newPinning = typeof updater === "function" ? updater(columnPinning) : updater;
305
+ onColumnPinningChange(newPinning);
306
+ }
307
+ },
308
+ initialState: {
309
+ columnSizing: initialColumnSizing
310
+ }
311
+ });
312
+ return /*#__PURE__*/ _jsx("div", {
313
+ className: styles.tableContainer,
314
+ children: /*#__PURE__*/ _jsxs(Table, {
315
+ className: styles.table,
316
+ children: [
317
+ /*#__PURE__*/ _jsx(TableHeader, {
318
+ className: styles.thead,
319
+ children: /*#__PURE__*/ _jsx(TableRow, {
320
+ className: enableColumnResizing ? "group" : "",
321
+ children: table.getHeaderGroups()[0]?.headers.map((header)=>{
322
+ const columnKey = header.id;
323
+ const isSortable = columnKey !== "actions";
324
+ const isPinned = header.column.getIsPinned();
325
+ const isSorted = sortConfig?.key === columnKey;
326
+ const isDraggable = enableColumnReordering && !isPinned;
327
+ const isDragging = draggedColumn === columnKey;
328
+ const isDropTarget = dropTarget === columnKey;
329
+ const isLastLeftPinned = isPinned === "left" && header.column.getIsLastColumn("left");
330
+ const isFirstRightPinned = isPinned === "right" && header.column.getIsFirstColumn("right");
331
+ const columnConfig = columnConfigs?.find((config)=>config.key === columnKey);
332
+ const isRightAlign = columnConfig?.rightAlign || false;
333
+ return /*#__PURE__*/ _jsxs(TableHead, {
334
+ className: cn(styles.cellPadding, styles.th, isSortable && showSorting && styles.thSortable, styles.pinnedHeader, isSorted && styles.thSorted, isRightAlign && styles.thRightAlign, "relative", enableColumnResizing && header.column.getCanResize() && styles.resizableHeader, isDraggable && styles.draggableHeader, isDragging && styles.draggingHeader, isDragging && styles.draggingColumn, isDropTarget && styles.dropZone, isDropTarget && styles.dropZoneActive),
335
+ style: {
336
+ ...getPinningStyles(header.column),
337
+ ...enableColumnResizing ? {} : {
338
+ width: columnWidths[columnKey] || "200px"
339
+ }
340
+ },
341
+ "data-pinned": isPinned || undefined,
342
+ "data-last-col": isLastLeftPinned ? "left" : isFirstRightPinned ? "right" : undefined,
343
+ onClick: (e)=>{
344
+ const target = e.currentTarget;
345
+ if (target.closest("[data-resize-handle]") || target.closest("[data-drag-zone]")) {
346
+ return;
347
+ }
348
+ if (isSortable && showSorting && onSort) {
349
+ onSort(String(columnKey));
350
+ }
351
+ },
352
+ onDragOver: (e)=>{
353
+ if (!isDraggable || !draggedColumn || draggedColumn === columnKey) return;
354
+ e.preventDefault();
355
+ setDropTarget(columnKey);
356
+ },
357
+ onDragLeave: (e)=>{
358
+ const rect = e.currentTarget.getBoundingClientRect();
359
+ const x = e.clientX;
360
+ const y = e.clientY;
361
+ if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) {
362
+ setDropTarget(null);
363
+ }
364
+ },
365
+ onDrop: (e)=>{
366
+ e.preventDefault();
367
+ if (!isDraggable || !draggedColumn || !onColumnOrderChange) return;
368
+ const currentOrder = table.getAllLeafColumns().map((col)=>col.id);
369
+ const draggedIndex = currentOrder.indexOf(draggedColumn);
370
+ const targetIndex = currentOrder.indexOf(columnKey);
371
+ if (draggedIndex !== -1 && targetIndex !== -1) {
372
+ const newOrder = [
373
+ ...currentOrder
374
+ ];
375
+ newOrder.splice(draggedIndex, 1);
376
+ newOrder.splice(targetIndex, 0, draggedColumn);
377
+ onColumnOrderChange(newOrder);
378
+ }
379
+ setDraggedColumn(null);
380
+ setDropTarget(null);
381
+ },
382
+ children: [
383
+ isDraggable && /*#__PURE__*/ _jsx("button", {
384
+ type: "button",
385
+ "data-drag-zone": true,
386
+ draggable: true,
387
+ className: styles.dragZone,
388
+ onDragStart: (e)=>{
389
+ setDraggedColumn(columnKey);
390
+ e.dataTransfer.effectAllowed = "move";
391
+ },
392
+ onDragEnd: ()=>{
393
+ setDraggedColumn(null);
394
+ setDropTarget(null);
395
+ },
396
+ children: /*#__PURE__*/ _jsx(GripVertical, {
397
+ className: "w-4 h-4"
398
+ })
399
+ }),
400
+ flexRender(header.column.columnDef.header, header.getContext()),
401
+ enableColumnResizing && header.column.getCanResize() && /*#__PURE__*/ _jsx("div", {
402
+ "data-resize-handle": true,
403
+ onMouseDown: header.getResizeHandler(),
404
+ onTouchStart: header.getResizeHandler(),
405
+ onClick: (e)=>e.stopPropagation(),
406
+ className: cn(styles.resizeHandle, header.column.getIsResizing() && styles.resizeHandleActive)
407
+ })
408
+ ]
409
+ }, `header-${columnKey}`);
410
+ })
411
+ })
412
+ }),
413
+ /*#__PURE__*/ _jsxs(TableBody, {
414
+ children: [
415
+ showFilters && /*#__PURE__*/ _jsx(FilterRow, {
416
+ headers: table.getHeaderGroups()[0]?.headers || [],
417
+ draggedColumn: draggedColumn,
418
+ dropTarget: dropTarget
419
+ }),
420
+ table.getRowModel().rows.map((row, rowIndex)=>/*#__PURE__*/ _jsx(TableRow, {
421
+ className: cn(styles.dataRow, showZebraStripes && rowIndex % 2 === (showFilters ? 0 : 1) && styles.dataRowZebra),
422
+ children: row.getVisibleCells().map((cell)=>{
423
+ const columnKey = cell.column.id;
424
+ const isPinned = cell.column.getIsPinned();
425
+ const isSorted = sortConfig?.key === columnKey;
426
+ const isBeingDragged = draggedColumn === columnKey;
427
+ const isDropTarget = dropTarget === columnKey;
428
+ const isLastLeftPinned = isPinned === "left" && cell.column.getIsLastColumn("left");
429
+ const isFirstRightPinned = isPinned === "right" && cell.column.getIsFirstColumn("right");
430
+ return /*#__PURE__*/ _jsx(TableCell, {
431
+ className: cn(styles.cellPadding, styles.dataCell, styles.pinnedColumn, isSorted && styles.cellSorted, isBeingDragged && styles.draggingColumn, isDropTarget && styles.dropZone, isDropTarget && styles.dropZoneActive),
432
+ style: {
433
+ ...getPinningStyles(cell.column),
434
+ ...enableColumnResizing ? {} : {
435
+ width: columnWidths[columnKey] || "200px"
436
+ }
437
+ },
438
+ "data-pinned": isPinned || undefined,
439
+ "data-last-col": isLastLeftPinned ? "left" : isFirstRightPinned ? "right" : undefined,
440
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
441
+ }, cell.id);
442
+ })
443
+ }, `row-${row.id}`))
444
+ ]
445
+ })
446
+ ]
447
+ })
448
+ });
449
+ }
450
+ const columnHelper = createColumnHelper();
451
+ const columns = [
452
+ columnHelper.accessor("firstName", {
453
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
454
+ content: "First name"
455
+ }),
456
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
457
+ content: props.getValue()
458
+ })
459
+ }),
460
+ columnHelper.accessor("lastName", {
461
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
462
+ content: "Last name"
463
+ }),
464
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
465
+ content: props.getValue()
466
+ })
467
+ }),
468
+ columnHelper.accessor("id", {
469
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
470
+ content: "ID"
471
+ }),
472
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
473
+ content: props.getValue(),
474
+ type: "code"
475
+ })
476
+ }),
477
+ columnHelper.accessor("birthDate", {
478
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
479
+ content: "Birth"
480
+ }),
481
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
482
+ content: props.getValue(),
483
+ type: "code"
484
+ })
485
+ }),
486
+ columnHelper.accessor("phoneNumber", {
487
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
488
+ content: "Phone number"
489
+ }),
490
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
491
+ content: props.getValue()
492
+ })
493
+ }),
494
+ columnHelper.accessor("email", {
495
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
496
+ content: "Email"
497
+ }),
498
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
499
+ content: props.getValue()
500
+ })
501
+ }),
502
+ columnHelper.accessor("gender", {
503
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
504
+ content: "Gender"
505
+ }),
506
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
507
+ content: props.getValue()
508
+ })
509
+ }),
510
+ columnHelper.accessor("street", {
511
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
512
+ content: "Street"
513
+ }),
514
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
515
+ content: props.getValue()
516
+ })
517
+ }),
518
+ columnHelper.accessor("city", {
519
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
520
+ content: "City"
521
+ }),
522
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
523
+ content: props.getValue()
524
+ })
525
+ }),
526
+ columnHelper.accessor("state", {
527
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
528
+ content: "State"
529
+ }),
530
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
531
+ content: props.getValue()
532
+ })
533
+ }),
534
+ columnHelper.accessor("zip", {
535
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
536
+ content: "ZIP"
537
+ }),
538
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
539
+ content: props.getValue()
540
+ })
541
+ }),
542
+ columnHelper.accessor("country", {
543
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
544
+ content: "Country"
545
+ }),
546
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
547
+ content: props.getValue()
548
+ })
549
+ }),
550
+ columnHelper.accessor("encounters", {
551
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
552
+ content: "Encounters"
553
+ }),
554
+ cell: (props)=>/*#__PURE__*/ _jsx(TableCellContent, {
555
+ content: props.getValue()
556
+ })
557
+ }),
558
+ columnHelper.display({
559
+ id: "actions",
560
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
561
+ content: "Actions"
562
+ }),
563
+ cell: ({ row })=>/*#__PURE__*/ _jsx(TableCellContent, {
564
+ content: /*#__PURE__*/ _jsx("button", {
565
+ type: "button",
566
+ className: styles.actionButton,
567
+ onClick: (e)=>{
568
+ e.stopPropagation();
569
+ console.log("Match clicked for:", row.original.id);
570
+ },
571
+ children: "Match"
572
+ })
573
+ }),
574
+ meta: {
575
+ fixed: "right"
576
+ }
577
+ })
578
+ ];
579
+ export function PatientTable(props) {
580
+ const { showFilters = true, showSorting = true, enableColumnResizing = false, enableColumnReordering = false, enableColumnPinning = false, showPinningMenu = true, columnWidths = {}, columnConfigs } = props;
581
+ const [sortConfig, setSortConfig] = useState(null);
582
+ const [columnOrder, setColumnOrder] = useState([]);
583
+ const [columnPinning, setColumnPinning] = useState({});
584
+ useEffect(()=>{
585
+ if (!enableColumnPinning || !columnConfigs) return;
586
+ const fixedColumns = columnConfigs.filter((config)=>config.fixed);
587
+ if (fixedColumns.length > 0) {
588
+ const initialPinning = {
589
+ right: fixedColumns.map((config)=>config.key)
590
+ };
591
+ setColumnPinning(initialPinning);
592
+ }
593
+ }, [
594
+ enableColumnPinning,
595
+ columnConfigs
596
+ ]);
597
+ const handleSort = (columnKey)=>{
598
+ setSortConfig((current)=>{
599
+ if (current?.key === columnKey) {
600
+ return current.direction === "asc" ? {
601
+ key: columnKey,
602
+ direction: "desc"
603
+ } : null;
604
+ }
605
+ return {
606
+ key: columnKey,
607
+ direction: "asc"
608
+ };
609
+ });
610
+ };
611
+ const data = [
612
+ {
613
+ id: "PAT-000001",
614
+ firstName: "John",
615
+ lastName: "Smith",
616
+ phoneNumber: "(555) 123-4567",
617
+ email: "john.smith@gmail.com",
618
+ birthDate: "1985-03-15",
619
+ gender: "MALE",
620
+ street: "123 Main St",
621
+ city: "New York",
622
+ state: "NY",
623
+ zip: "10001",
624
+ encounters: 5
625
+ },
626
+ {
627
+ id: "PAT-000002",
628
+ firstName: "Jane",
629
+ lastName: "Johnson",
630
+ phoneNumber: "(555) 234-5678",
631
+ email: "jane.johnson@yahoo.com",
632
+ birthDate: "1990-07-22",
633
+ gender: "FEMALE",
634
+ street: "456 Oak Ave",
635
+ city: "Los Angeles",
636
+ state: "CA",
637
+ zip: "90210",
638
+ encounters: 12
639
+ },
640
+ {
641
+ id: "PAT-000003",
642
+ firstName: "Michael",
643
+ lastName: "Williams",
644
+ phoneNumber: "(555) 345-6789",
645
+ email: "michael.williams@hotmail.com",
646
+ birthDate: "1978-11-08",
647
+ gender: "MALE",
648
+ street: "789 Pine St",
649
+ city: "Chicago",
650
+ state: "IL",
651
+ zip: "60601",
652
+ encounters: 8
653
+ },
654
+ {
655
+ id: "PAT-000004",
656
+ firstName: "Sarah",
657
+ lastName: "Brown",
658
+ phoneNumber: "(555) 456-7890",
659
+ email: "sarah.brown@outlook.com",
660
+ birthDate: "1992-01-30",
661
+ gender: "FEMALE",
662
+ street: "321 Elm Ave",
663
+ city: "Houston",
664
+ state: "TX",
665
+ zip: "77001",
666
+ encounters: 3
667
+ },
668
+ {
669
+ id: "PAT-000005",
670
+ firstName: "David",
671
+ lastName: "Garcia",
672
+ phoneNumber: "(555) 567-8901",
673
+ email: "david.garcia@gmail.com",
674
+ birthDate: "1980-09-12",
675
+ gender: "MALE",
676
+ street: "654 Cedar St",
677
+ city: "Phoenix",
678
+ state: "AZ",
679
+ zip: "85001",
680
+ encounters: 15
681
+ },
682
+ {
683
+ id: "PAT-000006",
684
+ firstName: "Emily",
685
+ lastName: "Martinez",
686
+ phoneNumber: "(555) 678-9012",
687
+ email: "emily.martinez@icloud.com",
688
+ birthDate: "1995-05-18",
689
+ gender: "FEMALE",
690
+ street: "987 Washington St",
691
+ city: "Philadelphia",
692
+ state: "PA",
693
+ zip: "19101",
694
+ encounters: 7
695
+ },
696
+ {
697
+ id: "PAT-000007",
698
+ firstName: "Robert",
699
+ lastName: "Davis",
700
+ phoneNumber: "(555) 789-0123",
701
+ email: "robert.davis@aol.com",
702
+ birthDate: "1973-12-03",
703
+ gender: "MALE",
704
+ street: "147 Park Ave",
705
+ city: "San Antonio",
706
+ state: "TX",
707
+ zip: "78201",
708
+ encounters: 22
709
+ },
710
+ {
711
+ id: "PAT-000008",
712
+ firstName: "Jessica",
713
+ lastName: "Rodriguez",
714
+ phoneNumber: "(555) 890-1234",
715
+ email: "jessica.rodriguez@protonmail.com",
716
+ birthDate: "1988-04-25",
717
+ gender: "FEMALE",
718
+ street: "258 Lincoln St",
719
+ city: "San Diego",
720
+ state: "CA",
721
+ zip: "92101",
722
+ encounters: 9
723
+ },
724
+ {
725
+ id: "PAT-000009",
726
+ firstName: "William",
727
+ lastName: "Wilson",
728
+ phoneNumber: "(555) 901-2345",
729
+ email: "william.wilson@gmail.com",
730
+ birthDate: "1965-08-14",
731
+ gender: "MALE",
732
+ street: "369 Jefferson Ave",
733
+ city: "Dallas",
734
+ state: "TX",
735
+ zip: "75201",
736
+ encounters: 18
737
+ },
738
+ {
739
+ id: "PAT-000010",
740
+ firstName: "Ashley",
741
+ lastName: "Anderson",
742
+ phoneNumber: "(555) 012-3456",
743
+ email: "ashley.anderson@yahoo.com",
744
+ birthDate: "1993-10-07",
745
+ gender: "FEMALE",
746
+ street: "741 Madison St",
747
+ city: "San Jose",
748
+ state: "CA",
749
+ zip: "95101",
750
+ encounters: 4
751
+ },
752
+ {
753
+ id: "PAT-000011",
754
+ firstName: "Alex",
755
+ lastName: "Taylor",
756
+ phoneNumber: "(555) 111-2222",
757
+ email: "alex.taylor@outlook.com",
758
+ birthDate: "1987-06-19",
759
+ gender: "OTHER",
760
+ street: "852 Adams Ave",
761
+ city: "Austin",
762
+ state: "TX",
763
+ zip: "73301",
764
+ encounters: 11
765
+ }
766
+ ];
767
+ const sortedData = useMemo(()=>{
768
+ if (!sortConfig) return data;
769
+ return [
770
+ ...data
771
+ ].sort((a, b)=>{
772
+ const aValue = a[sortConfig.key] ?? "";
773
+ const bValue = b[sortConfig.key] ?? "";
774
+ if (aValue < bValue) return sortConfig.direction === "asc" ? -1 : 1;
775
+ if (aValue > bValue) return sortConfig.direction === "asc" ? 1 : -1;
776
+ return 0;
777
+ });
778
+ }, [
779
+ sortConfig
780
+ ]);
781
+ const generatedColumnWidths = useMemo(()=>{
782
+ if (!columnConfigs) {
783
+ return columnWidths;
784
+ }
785
+ const configWidths = {};
786
+ columnConfigs.forEach((config)=>{
787
+ if (config.width) {
788
+ configWidths[config.key] = config.width;
789
+ }
790
+ });
791
+ return {
792
+ ...columnWidths,
793
+ ...configWidths
794
+ };
795
+ }, [
796
+ columnConfigs,
797
+ columnWidths
798
+ ]);
799
+ const generatedColumns = useMemo(()=>{
800
+ if (!columnConfigs) {
801
+ return columns;
802
+ }
803
+ return columnConfigs.map((config)=>{
804
+ const columnSize = config.width ? parseInt(config.width.replace("px", ""), 10) : undefined;
805
+ if (config.type === "link" || config.type === "button") {
806
+ return {
807
+ id: config.key,
808
+ accessorFn: ()=>null,
809
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
810
+ content: config.label
811
+ }),
812
+ cell: ({ row })=>/*#__PURE__*/ _jsx(TableCellContent, {
813
+ content: "",
814
+ ...config.type && {
815
+ type: config.type
816
+ },
817
+ ...config.rightAlign !== undefined && {
818
+ rightAlign: config.rightAlign
819
+ },
820
+ actions: config.actions || [],
821
+ rowId: row.original.id
822
+ }),
823
+ ...config.fixed && {
824
+ meta: {
825
+ fixed: "right"
826
+ }
827
+ },
828
+ ...columnSize && {
829
+ size: columnSize
830
+ }
831
+ };
832
+ }
833
+ return {
834
+ accessorKey: config.key,
835
+ header: ()=>/*#__PURE__*/ _jsx(TableHeaderContent, {
836
+ content: config.label
837
+ }),
838
+ cell: ({ cell })=>/*#__PURE__*/ _jsx(TableCellContent, {
839
+ content: cell.getValue(),
840
+ type: config.type || "text",
841
+ ...config.rightAlign !== undefined && {
842
+ rightAlign: config.rightAlign
843
+ }
844
+ }),
845
+ ...config.fixed && {
846
+ meta: {
847
+ fixed: "right"
848
+ }
849
+ },
850
+ ...columnSize && {
851
+ size: columnSize
852
+ }
853
+ };
854
+ });
855
+ }, [
856
+ columnConfigs
857
+ ]);
858
+ const columnsWithSorting = generatedColumns.map((column)=>({
859
+ ...column,
860
+ header: ()=>{
861
+ const columnKey = column.id || column.accessorKey;
862
+ const isSortable = columnKey !== "actions";
863
+ const isPinnedLeft = columnPinning.left?.includes(columnKey);
864
+ const isPinnedRight = columnPinning.right?.includes(columnKey);
865
+ const pinnedDirection = isPinnedLeft ? "left" : isPinnedRight ? "right" : false;
866
+ const handlePin = (direction)=>{
867
+ const newPinning = {
868
+ ...columnPinning
869
+ };
870
+ if (newPinning.left) {
871
+ newPinning.left = newPinning.left.filter((id)=>id !== columnKey);
872
+ }
873
+ if (newPinning.right) {
874
+ newPinning.right = newPinning.right.filter((id)=>id !== columnKey);
875
+ }
876
+ if (direction === "left") {
877
+ newPinning.left = [
878
+ ...newPinning.left || [],
879
+ columnKey
880
+ ];
881
+ } else if (direction === "right") {
882
+ newPinning.right = [
883
+ ...newPinning.right || [],
884
+ columnKey
885
+ ];
886
+ }
887
+ setColumnPinning(newPinning);
888
+ };
889
+ return /*#__PURE__*/ _jsx(TableHeaderContent, {
890
+ content: typeof column.header === "function" ? column.header({}) : column.header,
891
+ isSortable: isSortable && showSorting,
892
+ sortDirection: sortConfig?.key === columnKey && sortConfig ? sortConfig.direction : null,
893
+ isPinnable: enableColumnPinning && showPinningMenu,
894
+ pinnedDirection: pinnedDirection,
895
+ onPin: handlePin
896
+ });
897
+ }
898
+ }));
899
+ return /*#__PURE__*/ _jsx(DataTable, {
900
+ columns: columnsWithSorting,
901
+ data: sortedData,
902
+ showZebraStripes: true,
903
+ showFilters: showFilters,
904
+ showSorting: showSorting,
905
+ enableColumnResizing: enableColumnResizing,
906
+ enableColumnReordering: enableColumnReordering,
907
+ enableColumnPinning: enableColumnPinning,
908
+ onSort: handleSort,
909
+ columnWidths: generatedColumnWidths,
910
+ sortConfig: sortConfig,
911
+ columnOrder: columnOrder,
912
+ onColumnOrderChange: setColumnOrder,
913
+ columnPinning: columnPinning,
914
+ onColumnPinningChange: setColumnPinning,
915
+ ...columnConfigs && {
916
+ columnConfigs
917
+ }
918
+ });
919
+ }
920
+
921
+ //# sourceMappingURL=patient-table.js.map