@povio/ui 6.0.0-rc.13 → 6.0.0-rc.14

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 (291) hide show
  1. package/README.md +55 -1
  2. package/dist/{Accordion-gUW7u1Zn.js → Accordion-BNHpv7Zj.js} +3 -3
  3. package/dist/{Alert-DwnALnFY.d.ts → Alert-xHGPLUpt.d.ts} +1 -1
  4. package/dist/{AlertDialog-BcRiqY_n.d.ts → AlertDialog-CKcUZ6l9.d.ts} +3 -3
  5. package/dist/{Autocomplete-DRwQxx0U.d.ts → Autocomplete-CkWTSFoj.d.ts} +1 -1
  6. package/dist/{Autocomplete-CV4Aa1Ok.js → Autocomplete-CrNDRxvg.js} +10 -10
  7. package/dist/{Badge-CO-ZsmbR.d.ts → Badge-B25YEMEw.d.ts} +3 -3
  8. package/dist/{BottomSheet-Be0HtQzP.d.ts → BottomSheet-CtcPZG82.d.ts} +1 -1
  9. package/dist/{BottomSheet-APVu5TUd.js → BottomSheet-tUXH3NjS.js} +4 -4
  10. package/dist/{BottomSheet.lazy-NNB7ivkW.d.ts → BottomSheet.lazy-DuwAJSaI.d.ts} +1 -1
  11. package/dist/{Breadcrumbs-Bn3fqVYx.d.ts → Breadcrumbs-BrtRh_dX.d.ts} +1 -1
  12. package/dist/{Breadcrumbs-Cd75RPbS.js → Breadcrumbs-D8WXqOLN.js} +8 -8
  13. package/dist/{Button-CzEs3tcV.js → Button-C1Jv1Plk.js} +1 -1
  14. package/dist/{Button-Hk8zm9q_.d.ts → Button-DDuk3hJ3.d.ts} +1 -1
  15. package/dist/{Button-BJJkLVNj.js → Button-DF6sbTuF.js} +3 -3
  16. package/dist/{ButtonBase-aGz6DYum.js → ButtonBase-BYJz1JkH.js} +4 -4
  17. package/dist/{ButtonBase-Cp1w00t2.d.ts → ButtonBase-Bn_FT89h.d.ts} +3 -3
  18. package/dist/{Calendar-DN-i_b-_.js → Calendar-DdneUEhM.js} +58 -24
  19. package/dist/{Calendar.lazy-CqmyDSND.js → Calendar.lazy-BY0kLoYH.js} +6 -6
  20. package/dist/{Checkbox-D32MOIhF.d.ts → Checkbox-Bwl6MA-V.d.ts} +1 -1
  21. package/dist/{Checkbox-CzKXZw_w.js → Checkbox-E2bns_n0.js} +7 -7
  22. package/dist/{CheckboxCheckmark-DDU_Ie7-.js → CheckboxCheckmark-Beu8T1g9.js} +2 -2
  23. package/dist/{CheckboxGroup-B5Mn1G3u.d.ts → CheckboxGroup-0rzsn-bA.d.ts} +2 -2
  24. package/dist/{CheckboxGroup-BqWt09kZ.js → CheckboxGroup-C7epIEpW.js} +3 -3
  25. package/dist/ColumnConfigContent-LNq-6Brf.js +1025 -0
  26. package/dist/ColumnListContent-Dzze5R7T.js +133 -0
  27. package/dist/{DatePicker-CmoVbapu.d.ts → DatePicker-B70SCKfT.d.ts} +3 -3
  28. package/dist/{DatePicker-DQewd1By.js → DatePicker-BU-34fCk.js} +44 -12
  29. package/dist/{DatePickerInput-B9VnExeA.d.ts → DatePickerInput-BCuz08Ws.d.ts} +3 -3
  30. package/dist/{DatePickerInput-Bp9ZIN5E.js → DatePickerInput-CMEJmZSQ.js} +10 -10
  31. package/dist/{DateRangePicker-DRZ1hLlR.js → DateRangePicker-D0RtqeBM.js} +13 -13
  32. package/dist/{DateRangePicker-LX1VJlnD.d.ts → DateRangePicker-jovxcWGk.d.ts} +4 -4
  33. package/dist/{DateTimePicker-DWtKPaE6.js → DateTimePicker-Cbdt76CL.js} +30 -11
  34. package/dist/{DateTimePicker-D9pODhAj.d.ts → DateTimePicker-Cfi3ruFy.d.ts} +3 -3
  35. package/dist/{Dialog-D0SeePPz.d.ts → Dialog-BWNQjIgo.d.ts} +1 -1
  36. package/dist/{Dialog-BJ13KRQo.js → Dialog-Bpwr1nuy.js} +15 -15
  37. package/dist/{Dialog-BzQYDPJ9.js → Dialog-ebjPH22i.js} +3 -3
  38. package/dist/{Disclosure-Bjm5IOpg.js → Disclosure-D_aym2zh.js} +3 -3
  39. package/dist/{DropdownMenu-DTr7b-XO.d.ts → DropdownMenu-3V-G7fZ7.d.ts} +2 -2
  40. package/dist/{DropdownMenu-DrshB60h.js → DropdownMenu-C4WitobV.js} +4 -4
  41. package/dist/{DropdownMenuDesktop-DxGA0yvx.js → DropdownMenuDesktop-BM7659Sk.js} +1 -1
  42. package/dist/{FileInput-LMhFxlqB.js → FileInput-Bc_E1M1X.js} +5 -5
  43. package/dist/{FileInput-Bokcp9nH.d.ts → FileInput-CWRW7OzZ.d.ts} +2 -2
  44. package/dist/{FileTrigger-DlryDp2T.js → FileTrigger-tGSUFrb2.js} +6 -6
  45. package/dist/{FileUpload-BqXd4_nz.d.ts → FileUpload-DVnp9xxv.d.ts} +2 -2
  46. package/dist/{FileUpload-CJZrkr_U.js → FileUpload-Dk6ZmgWF.js} +501 -75
  47. package/dist/{Form-CqF1SaVw.js → Form-4jZarkjk.js} +2 -2
  48. package/dist/{FormField-XQbjfGSv.d.ts → FormField-BgiWLGjf.d.ts} +1 -1
  49. package/dist/{FormField-TI8Vx5aC.js → FormField-DOZ7eXjA.js} +2 -2
  50. package/dist/{FormFieldHeaderTooltip-DB7KrrcD.js → FormFieldHeaderTooltip-DW9sqJWl.js} +3 -3
  51. package/dist/{Heading-D4XFYv__.js → Heading-B9G3z6Es.js} +2 -2
  52. package/dist/{IconButton-CQLHX8-Y.d.ts → IconButton-Bjjf5cQL.d.ts} +1 -1
  53. package/dist/{InlineTooltipWrapper-CjDUsi2I.js → InlineTooltipWrapper-CcdpMJa6.js} +1 -1
  54. package/dist/{Input-BG0Xjw5X.js → Input-BkR3jkvt.js} +2 -2
  55. package/dist/{Input-CeRJeAoR.js → Input-CvYyjMWx.js} +5 -5
  56. package/dist/{Input-onUj0DKg.d.ts → Input-lppNS8wM.d.ts} +3 -3
  57. package/dist/{InputContent-B8OCdbVP.js → InputContent-B5YjsLDE.js} +2 -2
  58. package/dist/{InputContent-D5ZkB9hO.d.ts → InputContent-Bgalf6R1.d.ts} +2 -2
  59. package/dist/{Label-BGvF9vWx.js → Label-VTcaaLO8.js} +2 -2
  60. package/dist/{Link-Chux-Clm.js → Link-8zP_NC_c.js} +2 -2
  61. package/dist/{Link-BdnWVYL9.d.ts → Link-HJ4y-xiW.d.ts} +1 -1
  62. package/dist/{ListBox-gR4iSV7N.js → ListBox-Ck-B1Jae.js} +7 -7
  63. package/dist/{Modal-DAMsCwzb.js → Modal-xT-Wz5GH.js} +3 -3
  64. package/dist/{NumberField-6Q9LHGSo.js → NumberField-BXLzNb2T.js} +6 -6
  65. package/dist/{NumberField-Sb30Qao3.d.ts → NumberField-Q-4y3jpb.d.ts} +3 -3
  66. package/dist/{NumberFormatter-DYarfm5F.js → NumberFormatter-D5csbNXm.js} +1 -1
  67. package/dist/{NumberRangeInput-BDSkcHVJ.js → NumberRangeInput-BBzZCC54.js} +6 -6
  68. package/dist/{NumberRangeInput-Dvq8mOUY.d.ts → NumberRangeInput-DuWOdSdU.d.ts} +2 -2
  69. package/dist/{OverlayArrow-DF0jMwul.js → OverlayArrow-BptI-A_7.js} +2 -2
  70. package/dist/{PageHeader-eJk6GNK6.d.ts → PageHeader-jVaC3Z9L.d.ts} +2 -2
  71. package/dist/{PasswordInput-VHzP4VPU.d.ts → PasswordInput-DtTnGHRD.d.ts} +1 -1
  72. package/dist/{PasswordInput-BcHpV0Ie.js → PasswordInput-U0QhNsMp.js} +2 -2
  73. package/dist/{Popover-qplPGDnR.d.ts → Popover-ClCEOP3e.d.ts} +2 -2
  74. package/dist/{Progress-WzWvbvtp.js → Progress-DlXY0dv_.js} +1 -1
  75. package/dist/{Progress-DH-w99MU.d.ts → Progress-VkkXbIh7.d.ts} +1 -1
  76. package/dist/{ProgressBar-BsSimmJF.js → ProgressBar-mpNpV7ow.js} +3 -3
  77. package/dist/{RadioGroup-PKqFHoKP.js → RadioGroup-BPPJyA1s.js} +8 -8
  78. package/dist/{RadioGroup-CC8bKtBN.d.ts → RadioGroup-BbcrP56w.d.ts} +2 -2
  79. package/dist/{RangeCalendar-DqCTlIuy.js → RangeCalendar-DIVjIl0T.js} +4 -4
  80. package/dist/{Select-CSyfDyxG.d.ts → Select-D1qIWZCv.d.ts} +3 -3
  81. package/dist/{Select-D3fuXwVt.js → Select-DlbVDCz8.js} +36 -26
  82. package/dist/{SelectListBox-DqAxkT1f.js → SelectListBox-CCr5YY86.js} +15 -12
  83. package/dist/{SelectionIndicator-C3hniBa2.js → SelectionIndicator-CvuKjZRP.js} +3 -3
  84. package/dist/{SharedElementTransition-CZ2bE7yo.js → SharedElementTransition-BkyYit3Q.js} +2 -2
  85. package/dist/{SidebarWorkspaces-BGl_PIsH.js → SidebarWorkspaces-CIpFJGOa.js} +10 -10
  86. package/dist/{SidebarWorkspaces-CdtK2M-C.d.ts → SidebarWorkspaces-DcwA_jv7.d.ts} +3 -3
  87. package/dist/{Slider-DxalZD3o.d.ts → Slider-CLViwkE1.d.ts} +1 -1
  88. package/dist/{Slider-BCUiALjE.js → Slider-_RsgBJcg.js} +5 -5
  89. package/dist/{Spinner-BTrEbNFy.d.ts → Spinner-GMEauCHv.d.ts} +1 -1
  90. package/dist/{SplitButton-Dv5l8p5t.d.ts → SplitButton-BdP4xjFQ.d.ts} +3 -3
  91. package/dist/{Stepper-DA2G546I.js → Stepper-D4z7JNsD.js} +2 -2
  92. package/dist/{Stepper-B1IOUcSI.d.ts → Stepper-DBb0qfla.d.ts} +1 -1
  93. package/dist/{Switch-Ce-bJOVw.js → Switch-Bi3_bUw1.js} +3 -3
  94. package/dist/{Switch-urNrop0P.d.ts → Switch-DCxONL2Q.d.ts} +1 -1
  95. package/dist/TableDnd-CG1yOlxh.js +238 -0
  96. package/dist/TableDragHandle-CXApnuUm.js +51 -0
  97. package/dist/{TabsFilters-Cweij8He.js → TabsFilters-BPogry73.js} +4 -4
  98. package/dist/{TabsFilters-M5Ld7eb8.d.ts → TabsFilters-CPfGBODw.d.ts} +1 -1
  99. package/dist/{Tag-BKR1AZFa.d.ts → Tag-xhcJOv_X.d.ts} +2 -2
  100. package/dist/{Text-D72yc4S6.js → Text-D7Nqkw1l.js} +1 -1
  101. package/dist/{TextArea-D7YVclaz.d.ts → TextArea-BYX9Kk_v.d.ts} +2 -2
  102. package/dist/{TextArea-P8F0oD_A.js → TextArea-CuJS3-Nv.js} +6 -6
  103. package/dist/{TimePicker-l4Ysk2AX.js → TimePicker-ByfjqkLp.js} +28 -13
  104. package/dist/{TimePicker-Ai1M2TGW.d.ts → TimePicker-UTo9C6gz.d.ts} +3 -2
  105. package/dist/TimePickerForm-CaIHR0PV.js +532 -0
  106. package/dist/{ToastContainer-BeklfvlK.js → ToastContainer-tr7Zxahc.js} +4 -4
  107. package/dist/{ToggleButton-DWw53pTt.d.ts → ToggleButton-BX8o7ECO.d.ts} +1 -1
  108. package/dist/{ToggleButton-P1z1pxzT.js → ToggleButton-D8BT67FO.js} +5 -5
  109. package/dist/{ToggleGroup-BdIgqoqA.js → ToggleGroup-18c-FZ_r.js} +5 -5
  110. package/dist/{ToggleGroup-BQk3k0at.d.ts → ToggleGroup-UazUtgU1.d.ts} +2 -2
  111. package/dist/{Tooltip-BkXPEBqw.js → Tooltip-Dl3sf8fq.js} +3 -3
  112. package/dist/{Tooltip-H8OB7CqY.d.ts → Tooltip-FcJ29dhq.d.ts} +1 -1
  113. package/dist/{TooltipWrapper-ubbBHHVD.js → TooltipWrapper-bvNpM6ku.js} +3 -3
  114. package/dist/{Typography-Cx1oRGxd.d.ts → Typography-auHWN282.d.ts} +1 -1
  115. package/dist/{badge.cva-BpoxNggB.js → badge.cva-C9mE8CMf.js} +3 -2
  116. package/dist/{buttonContent.cva-Dyy_RUZU.d.ts → buttonContent.cva-CeGnrjoA.d.ts} +2 -2
  117. package/dist/calendarHeader.cva-D3sXR7ox.js +23 -0
  118. package/dist/columnConfig.cva-CERwSZRN.js +29 -0
  119. package/dist/components/accordion.js +1 -1
  120. package/dist/components/alert-dialog.d.ts +1 -1
  121. package/dist/components/alert-dialog.js +3 -3
  122. package/dist/components/alert.d.ts +1 -1
  123. package/dist/components/autocomplete.d.ts +1 -1
  124. package/dist/components/autocomplete.js +1 -1
  125. package/dist/components/badge.d.ts +1 -1
  126. package/dist/components/badge.js +37 -30
  127. package/dist/components/bottom-sheet-header.d.ts +1 -1
  128. package/dist/components/bottom-sheet-header.js +23 -19
  129. package/dist/components/bottom-sheet.d.ts +2 -2
  130. package/dist/components/bottom-sheet.js +2 -2
  131. package/dist/components/breadcrumbs.d.ts +1 -1
  132. package/dist/components/breadcrumbs.js +1 -1
  133. package/dist/components/button.d.ts +2 -2
  134. package/dist/components/button.js +1 -1
  135. package/dist/components/checkbox-group.d.ts +1 -1
  136. package/dist/components/checkbox-group.js +1 -1
  137. package/dist/components/checkbox.d.ts +1 -1
  138. package/dist/components/checkbox.js +1 -1
  139. package/dist/components/date-picker.d.ts +1 -1
  140. package/dist/components/date-picker.js +1 -1
  141. package/dist/components/date-range-picker.d.ts +2 -2
  142. package/dist/components/date-range-picker.js +2 -2
  143. package/dist/components/date-range-presets.js +1 -1
  144. package/dist/components/date-time-picker.d.ts +1 -1
  145. package/dist/components/date-time-picker.js +1 -1
  146. package/dist/components/dialog.d.ts +1 -1
  147. package/dist/components/dialog.js +1 -1
  148. package/dist/components/drawer.js +2 -2
  149. package/dist/components/dropdown-menu.d.ts +1 -1
  150. package/dist/components/dropdown-menu.js +1 -1
  151. package/dist/components/file-input.d.ts +1 -1
  152. package/dist/components/file-input.js +1 -1
  153. package/dist/components/file-upload.d.ts +1 -1
  154. package/dist/components/file-upload.js +1 -1
  155. package/dist/components/form-field.d.ts +2 -2
  156. package/dist/components/form-field.js +1 -1
  157. package/dist/components/icon-button.d.ts +1 -1
  158. package/dist/components/icon-button.js +2 -2
  159. package/dist/components/input-frame.d.ts +3 -3
  160. package/dist/components/input-frame.js +5 -5
  161. package/dist/components/input.d.ts +1 -1
  162. package/dist/components/input.js +1 -1
  163. package/dist/components/link.d.ts +1 -1
  164. package/dist/components/link.js +1 -1
  165. package/dist/components/number-field.d.ts +1 -1
  166. package/dist/components/number-field.js +1 -1
  167. package/dist/components/number-range-input.d.ts +1 -1
  168. package/dist/components/number-range-input.js +1 -1
  169. package/dist/components/page-header.d.ts +1 -1
  170. package/dist/components/page-header.js +1 -1
  171. package/dist/components/password-input.d.ts +1 -1
  172. package/dist/components/password-input.js +1 -1
  173. package/dist/components/popover.d.ts +1 -1
  174. package/dist/components/popover.js +2 -2
  175. package/dist/components/progress.d.ts +1 -1
  176. package/dist/components/progress.js +1 -1
  177. package/dist/components/radio-group.d.ts +1 -1
  178. package/dist/components/radio-group.js +1 -1
  179. package/dist/components/select.d.ts +1 -1
  180. package/dist/components/select.js +1 -1
  181. package/dist/components/sidebar.d.ts +1 -1
  182. package/dist/components/sidebar.js +1 -1
  183. package/dist/components/slider.d.ts +1 -1
  184. package/dist/components/slider.js +1 -1
  185. package/dist/components/spinner.d.ts +1 -1
  186. package/dist/components/split-button.d.ts +1 -1
  187. package/dist/components/split-button.js +2 -2
  188. package/dist/components/stepper.d.ts +1 -1
  189. package/dist/components/stepper.js +1 -1
  190. package/dist/components/style-definitions.d.ts +2 -2
  191. package/dist/components/style-definitions.js +32 -5
  192. package/dist/components/switch.d.ts +1 -1
  193. package/dist/components/switch.js +1 -1
  194. package/dist/components/tabs-filters.d.ts +1 -1
  195. package/dist/components/tabs-filters.js +1 -1
  196. package/dist/components/tag.d.ts +1 -1
  197. package/dist/components/tag.js +3 -3
  198. package/dist/components/text-area.d.ts +1 -1
  199. package/dist/components/text-area.js +1 -1
  200. package/dist/components/time-picker.d.ts +1 -1
  201. package/dist/components/time-picker.js +1 -1
  202. package/dist/components/toast.d.ts +2 -2
  203. package/dist/components/toast.js +3 -3
  204. package/dist/components/toggle-button.d.ts +1 -1
  205. package/dist/components/toggle-button.js +1 -1
  206. package/dist/components/toggle-group.d.ts +1 -1
  207. package/dist/components/toggle-group.js +1 -1
  208. package/dist/components/tooltip-ellipsis.js +1 -1
  209. package/dist/components/tooltip.d.ts +1 -1
  210. package/dist/components/tooltip.js +1 -1
  211. package/dist/components/typography.d.ts +2 -2
  212. package/dist/components/use-toast.d.ts +1 -1
  213. package/dist/components/use-toast.js +1 -1
  214. package/dist/config/component-configuration.d.ts +2 -2
  215. package/dist/config/confirmation.d.ts +1 -1
  216. package/dist/config/confirmation.js +1 -1
  217. package/dist/config/link-context.d.ts +2 -2
  218. package/dist/config/resources.d.ts +1 -1
  219. package/dist/config/resources.js +1 -1
  220. package/dist/config/ui-config.d.ts +2 -2
  221. package/dist/config/ui-config.js +1 -1
  222. package/dist/config/ui-overrides.d.ts +1 -1
  223. package/dist/{confirmation.context-BflM4Vxg.js → confirmation.context-C_-uADGJ.js} +1 -1
  224. package/dist/{confirmation.context-C_js9qNv.d.ts → confirmation.context-DkWyR2aT.d.ts} +1 -1
  225. package/dist/{dist-DZOoWaZz.js → dist-CP6vV22I.js} +14 -10
  226. package/dist/{dom.utils-BPooTXtC.js → dom.utils-CqejLWIQ.js} +1 -1
  227. package/dist/{fileUpload.cva-MH5ziWUe.js → fileUpload.cva-SrF6v406.js} +1 -1
  228. package/dist/form-field-C735uXsi.d.ts +1 -0
  229. package/dist/hooks/use-async-list.js +1 -1
  230. package/dist/hooks/use-breakpoint.d.ts +2 -2
  231. package/dist/hooks/use-breakpoint.js +1 -1
  232. package/dist/{i18n-DQs7jPjv.js → i18n-DaIHnR2n.js} +26 -2
  233. package/dist/{i18n-B3PeqBM7.d.ts → i18n-xXkHgzet.d.ts} +24 -0
  234. package/dist/{import-C73fI3WD.js → import-Cz8NlFqm.js} +39 -15
  235. package/dist/index.d.ts +56 -55
  236. package/dist/index.js +49 -49
  237. package/dist/{intlStrings-Cu1YN1tA.js → intlStrings-ClpdCJmU.js} +35 -35
  238. package/dist/{isEqual-LFw0W5rU.js → isEqual-BdJdNr5O.js} +1 -1
  239. package/dist/{link.context-BcBuP9ZT.d.ts → link.context-BxVK2yQ5.d.ts} +1 -1
  240. package/dist/{link.cva-D6L1c2wq.d.ts → link.cva-ZhpQz3P0.d.ts} +129 -9
  241. package/dist/{logger-CW24po62.js → logger-CqZjM-sn.js} +1 -10
  242. package/dist/rich-text-editor.d.ts +2 -2
  243. package/dist/rich-text-editor.js +14 -14
  244. package/dist/{selectItem.cva-B6vxey2R.js → selectItem.cva-DsOZSSPx.js} +2 -1
  245. package/dist/{staticDateTimeSegments-BYk1tcxs.js → staticDateTimeSegments-BgUrcqXD.js} +342 -87
  246. package/dist/styles/input.d.ts +1 -1
  247. package/dist/{table.cva-DkcsOmZG.js → table.cva-n9TO_vu1.js} +68 -17
  248. package/dist/tableCells.cva-Br0_kgRM.js +18 -0
  249. package/dist/tableColumnConfigStorage-Cciq8gVe.js +215 -0
  250. package/dist/tableVirtualStore-whSmFzTV.js +67 -0
  251. package/dist/tanstack/form.js +1 -1
  252. package/dist/tanstack/table-context.d.ts +2 -0
  253. package/dist/tanstack/table-context.js +2 -0
  254. package/dist/tanstack/table-types.d.ts +55 -0
  255. package/dist/tanstack/table.d.ts +5 -5
  256. package/dist/tanstack/table.js +3 -2
  257. package/dist/tanstack-JB8VmS9j.js +73 -0
  258. package/dist/{tanstack-bLXoUPDY.d.ts → tanstack-cQOW9-Q2.d.ts} +50 -50
  259. package/dist/tanstack-table-DdWYwCZM.d.ts +858 -0
  260. package/dist/tanstack-table-M1M26UQJ.js +5299 -0
  261. package/dist/tanstack.d.ts +56 -55
  262. package/dist/tanstack.js +49 -49
  263. package/dist/{toast.cva-C3oA7He3.js → toast.cva-DusQwZw-.js} +5 -1
  264. package/dist/{toast.runtime-BHXdSTXV.js → toast.runtime-ZN5q4T9X.js} +1 -1
  265. package/dist/{uiConfig.context-CjnLnQOo.js → uiConfig.context-NWmBJ2Hc.js} +68 -4
  266. package/dist/{uiConfig.context-CN_QgxGO.d.ts → uiConfig.context-ykH4E2js.d.ts} +1 -1
  267. package/dist/uiConfig.types-BsyPKepP.d.ts +291 -0
  268. package/dist/{uiOverrides.context-DHHzLSnq.d.ts → uiOverrides.context-C5Maic5Q.d.ts} +106 -0
  269. package/dist/{useAsyncList-CQgkDfjW.js → useAsyncList-DkIjhlce.js} +2 -2
  270. package/dist/{useBreakpoint-D-SVcBeQ.d.ts → useBreakpoint-BPrZNuNl.d.ts} +1 -1
  271. package/dist/{useBreakpoint-BrJrvp9_.js → useBreakpoint-DtYSRweq.js} +2 -2
  272. package/dist/{useControlledState-CuU1VIh1.js → useControlledState-C1-Mt2i0.js} +1 -1
  273. package/dist/{useDebounceCallback-BjePw6y4.js → useDebounceCallback-C7YKfjXW.js} +6 -0
  274. package/dist/{useFormAutosave-BN-zueci.js → useFormAutosave-BzCGqFqi.js} +2 -2
  275. package/dist/{useLiveNumberFieldState-B7qGzySj.js → useLiveNumberFieldState-npiqOvyB.js} +4 -4
  276. package/dist/{useRemoveButton-B6-IGvpY.js → useRemoveButton-zhlA1Pbc.js} +1 -1
  277. package/dist/{useResolveDateRangePreset-C_L-doA6.js → useResolveDateRangePreset-k_h_XJBG.js} +1 -1
  278. package/dist/{useScrollableListBox-C8chM7c-.js → useScrollableListBox-4pieApqz.js} +1 -1
  279. package/dist/useTableVirtualizer-sFInQiH-.d.ts +162 -0
  280. package/dist/{useToast-D2C9pROU.d.ts → useToast-BHqkSByv.d.ts} +1 -1
  281. package/dist/{useToast-DSoOiSw0.js → useToast-DgqC6Ta_.js} +2 -2
  282. package/dist/utils/logger.js +1 -1
  283. package/dist/{utils-BkLF-JA3.js → utils-Q5Oc6oX2.js} +1 -1
  284. package/llms.txt +89 -4
  285. package/package.json +13 -1
  286. package/dist/TimePickerForm-BMqNpDPT.js +0 -225
  287. package/dist/form-field-Bw7U_ZPI.d.ts +0 -1
  288. package/dist/tanstack-ABeiJISz.js +0 -10
  289. package/dist/uiConfig.types-B0sPL7nN.d.ts +0 -132
  290. package/dist/useTableColumnConfig-B9cYBKo3.js +0 -2327
  291. package/dist/useTableNav-rP1wDkhV.d.ts +0 -372
@@ -1,2327 +0,0 @@
1
- import { n as __exportAll, t as logger } from "./logger-CW24po62.js";
2
- import { t as clsx } from "./clsx-CnD0nOiA.js";
3
- import { t as UIOverrides } from "./uiOverrides.context-DNEQlTx0.js";
4
- import { t as IconSlot } from "./IconSlot-TAWTJ6iK.js";
5
- import { t as Checkbox } from "./Checkbox-CzKXZw_w.js";
6
- import { t as Tooltip } from "./Tooltip-BkXPEBqw.js";
7
- import { t as Typography } from "./Typography-DCLnPa3P.js";
8
- import "./i18n-DQs7jPjv.js";
9
- import { Spinner } from "./components/spinner.js";
10
- import { t as UIConfig } from "./uiConfig.context-CjnLnQOo.js";
11
- import { n as uiOutlineClass } from "./outline.clsx-DGGQQRkM.js";
12
- import { t as Button } from "./Button-CzEs3tcV.js";
13
- import { IconButton } from "./components/icon-button.js";
14
- import { t as useBreakpoint } from "./useBreakpoint-BrJrvp9_.js";
15
- import { t as Dialog } from "./Dialog-BzQYDPJ9.js";
16
- import { Drawer } from "./components/drawer.js";
17
- import { a as tableDetailsPanelDefinition, c as tableHeaderTextDefinition, d as tableSidePanelDefinition, f as tableSidePanelHeaderDefinition, i as tableDetailsCellDefinition, l as tableRowDefinition, n as tableContainerDefinition, o as tableHeadDataDefinition, p as theadDefinition, r as tableDataDefinition, s as tableHeadRowDefinition, t as tableCellTextDefinition, u as tableSidePanelBodyDefinition } from "./table.cva-DkcsOmZG.js";
18
- import { t as useIntersectionObserver } from "./useIntersectionObserver-B8msnQTR.js";
19
- import { t as UIRouter } from "./router.context-B6j_M4cN.js";
20
- import { c } from "react/compiler-runtime";
21
- import { Fragment, Suspense, createContext, lazy, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
22
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
23
- import { ArrowDown, ArrowUp, ArrowUpDown, ChevronRight, GripVertical, Pin, X } from "lucide-react";
24
- import { useTranslation } from "react-i18next";
25
- import i18next from "i18next";
26
- import { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
27
- import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
28
- import { SortableContext, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
29
- import { CSS } from "@dnd-kit/utilities";
30
- import { createPaginatedRowModel, createSortedRowModel, flexRender, stockFeatures, tableFeatures, useTable } from "@tanstack/react-table";
31
- //#region src/components/table/CellText.tsx
32
- const CellText = (props) => {
33
- const uiConfig = UIConfig.useConfig();
34
- const { size = uiConfig.tableCellText.size, children, style, className } = props;
35
- const cellTextCva = UIOverrides.useCva("table.cellTextCva", tableCellTextDefinition);
36
- return /* @__PURE__ */ jsx(Typography, {
37
- className: cellTextCva({ className }),
38
- as: "span",
39
- size,
40
- style,
41
- "data-rac": true,
42
- children
43
- });
44
- };
45
- //#endregion
46
- //#region src/components/table/TableDnd.tsx
47
- var TableDnd_exports = /* @__PURE__ */ __exportAll({
48
- DndProvider: () => DndProvider$1,
49
- DragHandle: () => DragHandle$1,
50
- DragHandleButton: () => DragHandleButton,
51
- DraggableRow: () => DraggableRow$1,
52
- SortableItem: () => SortableItem,
53
- SortableRows: () => SortableRows$1
54
- });
55
- const DndProvider$1 = (t0) => {
56
- const $ = c(8);
57
- const { children, onDragEnd, onDragStart, onDragCancel } = t0;
58
- let t1;
59
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
60
- t1 = { coordinateGetter: sortableKeyboardCoordinates };
61
- $[0] = t1;
62
- } else t1 = $[0];
63
- const sensors = useSensors(useSensor(MouseSensor), useSensor(TouchSensor), useSensor(KeyboardSensor, t1));
64
- let t2;
65
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
66
- t2 = [restrictToVerticalAxis];
67
- $[1] = t2;
68
- } else t2 = $[1];
69
- let t3;
70
- if ($[2] !== children || $[3] !== onDragCancel || $[4] !== onDragEnd || $[5] !== onDragStart || $[6] !== sensors) {
71
- t3 = /* @__PURE__ */ jsx(DndContext, {
72
- collisionDetection: closestCenter,
73
- modifiers: t2,
74
- onDragStart,
75
- onDragEnd,
76
- onDragCancel,
77
- sensors,
78
- children
79
- });
80
- $[2] = children;
81
- $[3] = onDragCancel;
82
- $[4] = onDragEnd;
83
- $[5] = onDragStart;
84
- $[6] = sensors;
85
- $[7] = t3;
86
- } else t3 = $[7];
87
- return t3;
88
- };
89
- const SortableRows$1 = (t0) => {
90
- const $ = c(3);
91
- const { children, items } = t0;
92
- let t1;
93
- if ($[0] !== children || $[1] !== items) {
94
- t1 = /* @__PURE__ */ jsx(SortableContext, {
95
- items,
96
- strategy: verticalListSortingStrategy,
97
- children
98
- });
99
- $[0] = children;
100
- $[1] = items;
101
- $[2] = t1;
102
- } else t1 = $[2];
103
- return t1;
104
- };
105
- const DraggableRow$1 = (t0) => {
106
- const $ = c(19);
107
- const { id, className, isClickable, isSelected, onClick, onDoubleClick, onKeyDown, children } = t0;
108
- let t1;
109
- if ($[0] !== id) {
110
- t1 = { id };
111
- $[0] = id;
112
- $[1] = t1;
113
- } else t1 = $[1];
114
- const { transform, transition, setNodeRef, isDragging } = useSortable(t1);
115
- let t2;
116
- if ($[2] !== transform) {
117
- t2 = CSS.Transform.toString(transform);
118
- $[2] = transform;
119
- $[3] = t2;
120
- } else t2 = $[3];
121
- const t3 = isDragging ? .8 : 1;
122
- const t4 = isDragging ? 1 : 0;
123
- let t5;
124
- if ($[4] !== t2 || $[5] !== t3 || $[6] !== t4 || $[7] !== transition) {
125
- t5 = {
126
- transform: t2,
127
- transition,
128
- opacity: t3,
129
- zIndex: t4,
130
- position: "relative"
131
- };
132
- $[4] = t2;
133
- $[5] = t3;
134
- $[6] = t4;
135
- $[7] = transition;
136
- $[8] = t5;
137
- } else t5 = $[8];
138
- const style = t5;
139
- const t6 = isClickable || void 0;
140
- const t7 = isSelected || void 0;
141
- let t8;
142
- if ($[9] !== children || $[10] !== className || $[11] !== onClick || $[12] !== onDoubleClick || $[13] !== onKeyDown || $[14] !== setNodeRef || $[15] !== style || $[16] !== t6 || $[17] !== t7) {
143
- t8 = /* @__PURE__ */ jsx("tr", {
144
- ref: setNodeRef,
145
- style,
146
- className,
147
- "data-clickable": t6,
148
- "data-selected": t7,
149
- onClick,
150
- onDoubleClick,
151
- onKeyDown,
152
- children
153
- });
154
- $[9] = children;
155
- $[10] = className;
156
- $[11] = onClick;
157
- $[12] = onDoubleClick;
158
- $[13] = onKeyDown;
159
- $[14] = setNodeRef;
160
- $[15] = style;
161
- $[16] = t6;
162
- $[17] = t7;
163
- $[18] = t8;
164
- } else t8 = $[18];
165
- return t8;
166
- };
167
- const SortableItem = (t0) => {
168
- const $ = c(10);
169
- const { id, children } = t0;
170
- let t1;
171
- if ($[0] !== id) {
172
- t1 = { id };
173
- $[0] = id;
174
- $[1] = t1;
175
- } else t1 = $[1];
176
- const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable(t1);
177
- let t2;
178
- if ($[2] !== attributes || $[3] !== children || $[4] !== isDragging || $[5] !== listeners || $[6] !== setNodeRef || $[7] !== transform || $[8] !== transition) {
179
- t2 = children({
180
- ref: setNodeRef,
181
- style: {
182
- transform: CSS.Transform.toString(transform),
183
- transition,
184
- zIndex: isDragging ? 1 : 0,
185
- position: "relative"
186
- },
187
- isDragging,
188
- handleProps: {
189
- ...attributes,
190
- ...listeners
191
- }
192
- });
193
- $[2] = attributes;
194
- $[3] = children;
195
- $[4] = isDragging;
196
- $[5] = listeners;
197
- $[6] = setNodeRef;
198
- $[7] = transform;
199
- $[8] = transition;
200
- $[9] = t2;
201
- } else t2 = $[9];
202
- return t2;
203
- };
204
- const DragHandleButton = (t0) => {
205
- const $ = c(7);
206
- const { label, className, handleProps } = t0;
207
- let t1;
208
- if ($[0] !== className) {
209
- t1 = clsx("inline-flex size-8 shrink-0 cursor-move touch-none items-center justify-center rounded-md text-muted-foreground hover:text-foreground", uiOutlineClass, className);
210
- $[0] = className;
211
- $[1] = t1;
212
- } else t1 = $[1];
213
- let t2;
214
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
215
- t2 = /* @__PURE__ */ jsx(IconSlot, { icon: GripVertical });
216
- $[2] = t2;
217
- } else t2 = $[2];
218
- let t3;
219
- if ($[3] !== handleProps || $[4] !== label || $[5] !== t1) {
220
- t3 = /* @__PURE__ */ jsx("button", {
221
- ...handleProps,
222
- type: "button",
223
- "aria-label": label,
224
- className: t1,
225
- children: t2
226
- });
227
- $[3] = handleProps;
228
- $[4] = label;
229
- $[5] = t1;
230
- $[6] = t3;
231
- } else t3 = $[6];
232
- return t3;
233
- };
234
- const DragHandle$1 = (t0) => {
235
- const $ = c(8);
236
- const { id, label } = t0;
237
- let t1;
238
- if ($[0] !== id) {
239
- t1 = { id };
240
- $[0] = id;
241
- $[1] = t1;
242
- } else t1 = $[1];
243
- const { attributes, listeners } = useSortable(t1);
244
- let t2;
245
- if ($[2] !== attributes || $[3] !== listeners) {
246
- t2 = {
247
- ...attributes,
248
- ...listeners
249
- };
250
- $[2] = attributes;
251
- $[3] = listeners;
252
- $[4] = t2;
253
- } else t2 = $[4];
254
- let t3;
255
- if ($[5] !== label || $[6] !== t2) {
256
- t3 = /* @__PURE__ */ jsx(DragHandleButton, {
257
- label,
258
- handleProps: t2
259
- });
260
- $[5] = label;
261
- $[6] = t2;
262
- $[7] = t3;
263
- } else t3 = $[7];
264
- return t3;
265
- };
266
- //#endregion
267
- //#region src/components/table/ColumnConfig.tsx
268
- const getColumnId = (column) => column.id ?? column.accessorKey;
269
- function ColumnConfigModal({ isOpen, onOpenChange, trigger, configColumns, visibleColumns, onVisibilityChange, onOrderChange, onReset }) {
270
- const { t } = useTranslation("ui");
271
- const headingId = useId();
272
- const [isDragging, setIsDragging] = useState(false);
273
- const allIds = useMemo(() => configColumns.map(getColumnId), [configColumns]);
274
- const items = useMemo(() => configColumns.filter((column) => column.enableHiding !== false).map((column_0) => {
275
- const id = getColumnId(column_0);
276
- return {
277
- id,
278
- label: typeof column_0.header === "string" && column_0.header ? column_0.header : id,
279
- visible: visibleColumns?.[id] ?? true
280
- };
281
- }), [configColumns, visibleColumns]);
282
- const visibleCount = items.filter((item) => item.visible).length;
283
- const handleToggle = (id_0, visible) => {
284
- onVisibilityChange({
285
- ...visibleColumns,
286
- [id_0]: visible
287
- });
288
- };
289
- const handleShowAll = () => {
290
- onVisibilityChange(Object.fromEntries(items.map((item_0) => [item_0.id, true])));
291
- };
292
- const handleDragEnd = ({ active, over }) => {
293
- setIsDragging(false);
294
- if (!over || active.id === over.id) return;
295
- const listedIds = items.map((item_1) => item_1.id);
296
- const oldIndex = listedIds.indexOf(String(active.id));
297
- const newIndex = listedIds.indexOf(String(over.id));
298
- if (oldIndex === -1 || newIndex === -1) return;
299
- const [moved] = listedIds.splice(oldIndex, 1);
300
- listedIds.splice(newIndex, 0, moved);
301
- const listed = new Set(listedIds);
302
- let nextListed = 0;
303
- onOrderChange(allIds.map((id_1) => listed.has(id_1) ? listedIds[nextListed++] : id_1));
304
- };
305
- return /* @__PURE__ */ jsx(Dialog, {
306
- isOpen,
307
- onOpenChange,
308
- trigger,
309
- showCloseIcon: true,
310
- isKeyboardDismissable: !isDragging,
311
- className: "w-modal",
312
- closeIconClassName: "top-7.5! right-6!",
313
- "aria-labelledby": headingId,
314
- children: (close) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
315
- /* @__PURE__ */ jsxs("div", {
316
- className: "flex flex-col gap-1.5 pr-6",
317
- children: [/* @__PURE__ */ jsx(Typography, {
318
- as: "h2",
319
- id: headingId,
320
- size: "h3",
321
- className: "font-semibold text-foreground",
322
- children: t(($) => $.ui.table.configureColumns)
323
- }), /* @__PURE__ */ jsx(Typography, {
324
- size: "body",
325
- className: "text-pretty text-muted-foreground",
326
- children: t(($_0) => $_0.ui.table.configureColumnsDescription)
327
- })]
328
- }),
329
- /* @__PURE__ */ jsxs("div", {
330
- className: "flex flex-col gap-2",
331
- children: [/* @__PURE__ */ jsxs("div", {
332
- className: "flex items-center justify-between",
333
- children: [/* @__PURE__ */ jsx(Typography, {
334
- size: "small",
335
- className: "text-muted-foreground",
336
- children: t(($_1) => $_1.ui.table.visibleCount, {
337
- visible: visibleCount,
338
- total: items.length
339
- })
340
- }), /* @__PURE__ */ jsx(Button, {
341
- variant: "ghost",
342
- color: "secondary",
343
- size: "sm",
344
- width: "hug",
345
- isDisabled: visibleCount === items.length,
346
- onPress: handleShowAll,
347
- children: t(($_2) => $_2.ui.table.showAll)
348
- })]
349
- }), /* @__PURE__ */ jsx(DndProvider$1, {
350
- onDragStart: () => setIsDragging(true),
351
- onDragEnd: handleDragEnd,
352
- onDragCancel: () => setIsDragging(false),
353
- children: /* @__PURE__ */ jsx(SortableRows$1, {
354
- items: items.map((item_2) => item_2.id),
355
- children: /* @__PURE__ */ jsx("ul", {
356
- className: "max-h-96 overflow-y-auto rounded-lg border border-border",
357
- children: items.map((item_3) => /* @__PURE__ */ jsx(SortableItem, {
358
- id: item_3.id,
359
- children: ({ ref, style, isDragging: isItemDragging, handleProps }) => /* @__PURE__ */ jsxs("li", {
360
- ref,
361
- style,
362
- className: clsx("flex h-11 items-center gap-2 border-b border-border bg-background pr-3 pl-1 last:border-b-0", isItemDragging && "shadow-md"),
363
- children: [/* @__PURE__ */ jsx(DragHandleButton, {
364
- handleProps,
365
- label: t(($_3) => $_3.ui.table.reorderColumn, { column: item_3.label })
366
- }), /* @__PURE__ */ jsx(Checkbox, {
367
- isSelected: item_3.visible,
368
- onChange: (isSelected) => handleToggle(item_3.id, isSelected),
369
- hideError: true,
370
- className: "flex-1 flex-row-reverse justify-between",
371
- labelClassName: item_3.visible ? "text-foreground" : "text-muted-foreground",
372
- children: item_3.label
373
- })]
374
- })
375
- }, item_3.id))
376
- })
377
- })
378
- })]
379
- }),
380
- /* @__PURE__ */ jsxs("div", {
381
- className: clsx("flex items-center gap-2", onReset ? "justify-between" : "justify-end"),
382
- children: [onReset && /* @__PURE__ */ jsx(Button, {
383
- variant: "ghost",
384
- color: "secondary",
385
- width: "hug",
386
- onPress: onReset,
387
- children: t(($_4) => $_4.ui.table.reset)
388
- }), /* @__PURE__ */ jsx(Button, {
389
- variant: "contained",
390
- color: "primary",
391
- width: "hug",
392
- onPress: close,
393
- children: t(($_5) => $_5.ui.table.done)
394
- })]
395
- })
396
- ] })
397
- });
398
- }
399
- //#endregion
400
- //#region src/components/table/HeaderText.tsx
401
- const HeaderText = (props) => {
402
- const uiConfig = UIConfig.useConfig();
403
- const { size = uiConfig.tableHeaderText.size, children, style, className } = props;
404
- const headerTextCva = UIOverrides.useCva("table.headerTextCva", tableHeaderTextDefinition);
405
- return /* @__PURE__ */ jsx(Typography, {
406
- className: headerTextCva({ className }),
407
- as: "span",
408
- size,
409
- style,
410
- children
411
- });
412
- };
413
- //#endregion
414
- //#region src/hooks/useTableNav.ts
415
- const Selectors = {
416
- Cell: "[role=\"cell\"],[role=\"gridcell\"],[role=\"columnheader\"],[role=\"rowheader\"],td,th",
417
- Row: "[role=\"row\"],tr",
418
- RowGroup: "[role=\"rowgroup\"],thead,tbody,tfoot",
419
- /** Selector from here: https://github.com/Shopify/polaris/blob/main/polaris-react/src/utilities/focus.ts#L10 */
420
- Focusable: "a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not([aria-disabled=\"true\"]):not([tabindex=\"-1\"]):not(:disabled),*[tabindex]"
421
- };
422
- const NON_TEXT_INPUT_TYPES = /* @__PURE__ */ new Set([
423
- "checkbox",
424
- "radio",
425
- "button",
426
- "submit",
427
- "reset",
428
- "range",
429
- "color",
430
- "file",
431
- "image"
432
- ]);
433
- const isTextEntry = (element) => element instanceof HTMLInputElement && !NON_TEXT_INPUT_TYPES.has(element.type) || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement || element instanceof HTMLElement && element.isContentEditable;
434
- var DataGridNav = class {
435
- constructor(config = {}) {
436
- this.keys = [];
437
- this.activeCell = null;
438
- this.debugLog = (functionName, message) => {
439
- if (this.debug) logger.info(`[${functionName}]: ${message}`);
440
- };
441
- const { selectors = {}, pageUpDown, debug = false } = config;
442
- this.selectors = {
443
- ...Selectors,
444
- ...selectors
445
- };
446
- this.pageUpDown = pageUpDown;
447
- this.keys = [];
448
- this.debug = debug;
449
- this.disabled = false;
450
- }
451
- disable() {
452
- this.disabled = true;
453
- }
454
- enable() {
455
- this.disabled = false;
456
- }
457
- isFocusable(el) {
458
- return el instanceof HTMLElement || el instanceof SVGElement;
459
- }
460
- getActiveCell() {
461
- return this.activeCell;
462
- }
463
- tableKeyUp() {
464
- this.keys = [];
465
- }
466
- tableKeyDown(e) {
467
- if (this.disabled) return;
468
- const isArrowKey = "ArrowDown" === e.key || "ArrowUp" === e.key || "ArrowLeft" === e.key || "ArrowRight" === e.key;
469
- if (isArrowKey && e.target instanceof Element && isTextEntry(e.target)) return;
470
- if (e.target instanceof Element && !e.target.closest(this.selectors.Row)) return;
471
- if (isArrowKey) e.preventDefault();
472
- if (this.keys.length === 0 || this.keys[this.keys.length - 1] !== e.key) this.keys.push(e.key);
473
- if (!(e.target instanceof Element)) return;
474
- const cell = e.target.parentElement?.closest(`${this.selectors.Cell},${this.selectors.Row}`);
475
- if (!cell) return;
476
- if (cell.matches(this.selectors.Cell)) this.cellNavigation(e);
477
- else this.gridNavigation(e);
478
- }
479
- cellNavigation(e) {
480
- if (!(e.target instanceof Element)) return;
481
- if (e.key === "Escape") {
482
- const cell = e.target.closest(this.selectors.Cell);
483
- if (cell && this.isFocusable(cell)) {
484
- cell.focus();
485
- return;
486
- }
487
- }
488
- /**
489
- * Keys: ArrowUp, ArrowDown
490
- * Leave the widget for the cell above or below, so a header button or a row checkbox leads into the grid.
491
- */
492
- if (e.key === "ArrowUp" || e.key === "ArrowDown") {
493
- this.verticalCellNavigation(e);
494
- return;
495
- }
496
- /**
497
- * Keys: ArrowRight, ArrowLeft
498
- * Move to the next or previous widget in the cell; past the cell's last or first widget, to the next or previous cell.
499
- */
500
- if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
501
- const cell = e.target.closest(this.selectors.Cell);
502
- if (!cell) return;
503
- const direction = e.key === "ArrowRight" ? 1 : -1;
504
- const focusableWidgets = [...cell.querySelectorAll(this.selectors.Focusable)];
505
- const widgetToFocus = focusableWidgets[focusableWidgets.findIndex((el) => el === e.target) + direction];
506
- if (widgetToFocus && this.isFocusable(widgetToFocus)) {
507
- widgetToFocus.focus();
508
- return;
509
- }
510
- const siblingCell = direction > 0 ? cell.nextElementSibling : cell.previousElementSibling;
511
- if (siblingCell && this.isFocusable(siblingCell)) siblingCell.focus();
512
- }
513
- }
514
- gridNavigation(e) {
515
- const { target } = e;
516
- if (!(e.target instanceof Element)) return;
517
- if (!(target instanceof Element)) return;
518
- if (this.keys.length === 1) {
519
- /**
520
- * Keys: Enter
521
- * Should move focus inside the cell to the first focusable element:
522
- * https://www.w3.org/WAI/ARIA/apg/patterns/grid/#gridNav_inside
523
- */
524
- if (/^[a-zA-Z0-9]$/.test(e.key)) {
525
- const cell = e.target.querySelector(this.selectors.Focusable);
526
- if (cell && this.isFocusable(cell) && cell instanceof HTMLInputElement) {
527
- cell.focus();
528
- cell.value = `${cell.value}${e.key}`;
529
- e.preventDefault();
530
- }
531
- return;
532
- }
533
- if (e.key === "Backspace") {
534
- const cell = e.target.querySelector(this.selectors.Focusable);
535
- if (cell && this.isFocusable(cell) && cell instanceof HTMLInputElement) {
536
- const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
537
- if (nativeInputValueSetter) {
538
- nativeInputValueSetter.call(cell, "");
539
- const ev = new Event("input", { bubbles: true });
540
- cell.dispatchEvent(ev);
541
- }
542
- }
543
- return;
544
- }
545
- if (e.key === "Enter") {
546
- const cell = e.target.querySelector(this.selectors.Focusable);
547
- if (cell && this.isFocusable(cell)) {
548
- if (cell.getAttribute("data-type") === "select-trigger") {
549
- cell.click();
550
- return;
551
- }
552
- cell.focus();
553
- e.preventDefault();
554
- }
555
- return;
556
- }
557
- if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
558
- const direction = e.key === "ArrowLeft" ? "prev" : "next";
559
- const cell = e.target.closest(this.selectors.Cell);
560
- let nextCell = null;
561
- if (direction === "next" && cell?.nextElementSibling instanceof HTMLElement) nextCell = cell.nextElementSibling;
562
- if (direction === "prev" && cell?.previousElementSibling instanceof HTMLElement) nextCell = cell.previousElementSibling;
563
- if (nextCell && this.isFocusable(nextCell)) {
564
- nextCell.focus();
565
- e.preventDefault();
566
- }
567
- }
568
- if (e.key === "ArrowDown" || e.key === "ArrowUp") {
569
- this.verticalCellNavigation(e);
570
- return;
571
- }
572
- if (e.key === "PageUp" || e.key === "PageDown") {
573
- this.pageCellNavigation(e);
574
- return;
575
- }
576
- if (e.key === "Home" || e.key === "End") {
577
- const rowChildren = [...e.target.closest(this.selectors.Row)?.children || []];
578
- if (e.key === "End") rowChildren.reverse();
579
- this.focusOnFirstCell(rowChildren);
580
- }
581
- } else {
582
- const [firstKey, secondKey] = this.keys;
583
- if (firstKey === "Control" && (secondKey === "Home" || secondKey === "End")) {
584
- const row = e.target.closest(this.selectors.Row);
585
- if (!row) return;
586
- const siblings = this.getRows(row.parentElement);
587
- const rowChildren = [...(secondKey === "Home" ? siblings[0] : siblings[siblings.length - 1])?.children || []];
588
- if (secondKey === "End") rowChildren.reverse();
589
- this.focusOnFirstCell(rowChildren);
590
- }
591
- }
592
- }
593
- getRows(group) {
594
- return [...group?.children ?? []].filter((child) => child.matches(this.selectors.Row));
595
- }
596
- pageCellNavigation(e) {
597
- if (!(e.target instanceof Element)) return;
598
- const row = e.target.closest(this.selectors.Row);
599
- const cell = e.target.closest(this.selectors.Cell);
600
- if (!row || !cell) return;
601
- const columnIndex = this.getColumnIndex(cell);
602
- if (columnIndex === void 0) return;
603
- const rows = this.getRows(row.parentElement);
604
- const rowIndex = rows.indexOf(row);
605
- const direction = e.key === "PageUp" ? -1 : 1;
606
- const child = rows[this.pageUpDown ? Math.max(0, Math.min(rows.length - 1, rowIndex + direction * this.pageUpDown)) : direction < 0 ? 0 : rows.length - 1]?.children[columnIndex];
607
- if (child && this.isFocusable(child)) child.focus();
608
- }
609
- verticalCellNavigation(e) {
610
- if (!(e.target instanceof Element)) return;
611
- const row = e.target.closest(this.selectors.Row);
612
- const cell = e.target.closest(this.selectors.Cell);
613
- if (!row || !cell) return;
614
- const columnIndex = this.getColumnIndex(cell);
615
- if (columnIndex === void 0) return;
616
- const rows = this.getRows(row.parentElement);
617
- const direction = e.key === "ArrowUp" ? -1 : 1;
618
- let destinationRow = rows[rows.indexOf(row) + direction];
619
- if (!destinationRow) {
620
- const group = row.parentElement?.closest(this.selectors.RowGroup);
621
- const groups = [...group?.parentElement?.children ?? []].filter((element) => element.matches(this.selectors.RowGroup));
622
- const groupIndex = groups.findIndex((element) => element === group);
623
- if (groupIndex === -1) return;
624
- for (let index = groupIndex + direction; index >= 0 && index < groups.length; index += direction) {
625
- const groupRows = this.getRows(groups[index]);
626
- destinationRow = direction < 0 ? groupRows[groupRows.length - 1] : groupRows[0];
627
- if (destinationRow) break;
628
- }
629
- }
630
- const child = destinationRow?.children[columnIndex];
631
- if (child && this.isFocusable(child)) child.focus();
632
- }
633
- focusOnFirstCell(el) {
634
- for (let i = 0; i < el.length; i++) {
635
- const child = el[i];
636
- if (this.isFocusable(child)) {
637
- child.focus();
638
- return;
639
- }
640
- }
641
- }
642
- getColumnIndex(cell) {
643
- let position = 0;
644
- const siblings = cell?.parentNode?.children;
645
- if (!siblings) return;
646
- while (cell !== siblings[position] && siblings[position] !== void 0) position++;
647
- if (siblings[position] === void 0) return;
648
- return position;
649
- }
650
- };
651
- /**
652
- * Arrow-key cell navigation for a hand-built `<table>` or ARIA grid: spread `listeners` on the table element.
653
- * `Table` and `InfiniteTable` already use it; don't add it to them.
654
- *
655
- * Arrows move between cells; from a widget inside a cell, Left/Right step through the cell's widgets and then on to the
656
- * next cell, and Up/Down move to the cell above or below. Escape moves from a widget to its cell. Text fields keep
657
- * their arrow keys. Give one cell `tabIndex={0}` and the rest `-1` so Tab can reach the grid.
658
- */
659
- function useTableNav(options) {
660
- const nav = new DataGridNav(options);
661
- return {
662
- listeners: {
663
- onKeyDown: (e) => nav.tableKeyDown(e),
664
- onKeyUp: () => nav.tableKeyUp()
665
- },
666
- tableNav: nav
667
- };
668
- }
669
- //#endregion
670
- //#region src/components/table/TableRowDetails.tsx
671
- const EXPAND_COLUMN_ID = "row-expand";
672
- const RowDetailsContext = createContext(null);
673
- /** Open/closed state of expandable rows, and the width their detail panels need to stay in view. */
674
- const useExpandableRows = ({ rowDetails, expanded, setExpanded, rowIds, tableRef, scroll }) => {
675
- const idPrefix = useId();
676
- const isEnabled = !!rowDetails;
677
- const isMultiple = rowDetails?.expandMode === "multiple";
678
- const isExpanded = (rowId) => isEnabled && (expanded === true || !!expanded[rowId]);
679
- const canExpand = (row) => isEnabled && (rowDetails.canOpen?.(row) ?? true);
680
- const toggle = (rowId_0) => setExpanded((previous) => {
681
- const isOpen = previous === true || !!previous[rowId_0];
682
- if (!isMultiple) return isOpen ? {} : { [rowId_0]: true };
683
- const current = previous === true ? Object.fromEntries(rowIds.map((id) => [id, true])) : previous;
684
- const { [rowId_0]: _closed, ...rest } = current;
685
- return isOpen ? rest : {
686
- ...current,
687
- [rowId_0]: true
688
- };
689
- });
690
- const getDetailsId = (rowId_1) => `${idPrefix}-details-${rowId_1}`;
691
- const hasExpandedRows = isEnabled && (expanded === true || Object.values(expanded).some(Boolean));
692
- const [panelWidth, setPanelWidth] = useState();
693
- useLayoutEffect(() => {
694
- if (!hasExpandedRows) return;
695
- const table = tableRef.current;
696
- const container = table?.parentElement;
697
- if (!table || !container) return;
698
- const measure = () => setPanelWidth(scroll === "page" ? Math.min(table.getBoundingClientRect().width, document.documentElement.clientWidth) : container.clientWidth);
699
- measure();
700
- const observer = new ResizeObserver(measure);
701
- observer.observe(container);
702
- observer.observe(table);
703
- return () => observer.disconnect();
704
- }, [
705
- hasExpandedRows,
706
- scroll,
707
- tableRef
708
- ]);
709
- return {
710
- isEnabled,
711
- panelWidth,
712
- context: {
713
- isExpanded,
714
- canExpand,
715
- toggle,
716
- getDetailsId
717
- }
718
- };
719
- };
720
- const RowDetailsProvider = RowDetailsContext.Provider;
721
- const RowExpandCell = (t0) => {
722
- const $ = c(32);
723
- const { row } = t0;
724
- const context = useContext(RowDetailsContext);
725
- if (!context?.canExpand(row.original)) return null;
726
- let T0;
727
- let T1;
728
- let isOpen;
729
- let t1;
730
- let t2;
731
- let t3;
732
- let t4;
733
- let t5;
734
- let t6;
735
- if ($[0] !== context || $[1] !== row.id) {
736
- isOpen = context.isExpanded(row.id);
737
- T1 = IconButton;
738
- t2 = "text";
739
- t3 = "sm";
740
- t4 = "hug";
741
- t5 = true;
742
- t6 = isOpen ? "Collapse row" : "Expand row";
743
- T0 = ChevronRight;
744
- t1 = clsx("transition-transform duration-200 motion-reduce:transition-none", isOpen && "rotate-90");
745
- $[0] = context;
746
- $[1] = row.id;
747
- $[2] = T0;
748
- $[3] = T1;
749
- $[4] = isOpen;
750
- $[5] = t1;
751
- $[6] = t2;
752
- $[7] = t3;
753
- $[8] = t4;
754
- $[9] = t5;
755
- $[10] = t6;
756
- } else {
757
- T0 = $[2];
758
- T1 = $[3];
759
- isOpen = $[4];
760
- t1 = $[5];
761
- t2 = $[6];
762
- t3 = $[7];
763
- t4 = $[8];
764
- t5 = $[9];
765
- t6 = $[10];
766
- }
767
- let t7;
768
- if ($[11] !== T0 || $[12] !== t1) {
769
- t7 = /* @__PURE__ */ jsx(T0, { className: t1 });
770
- $[11] = T0;
771
- $[12] = t1;
772
- $[13] = t7;
773
- } else t7 = $[13];
774
- let t8;
775
- if ($[14] !== context || $[15] !== isOpen || $[16] !== row.id) {
776
- t8 = isOpen ? context.getDetailsId(row.id) : void 0;
777
- $[14] = context;
778
- $[15] = isOpen;
779
- $[16] = row.id;
780
- $[17] = t8;
781
- } else t8 = $[17];
782
- let t9;
783
- if ($[18] !== context || $[19] !== row.id) {
784
- t9 = () => context.toggle(row.id);
785
- $[18] = context;
786
- $[19] = row.id;
787
- $[20] = t9;
788
- } else t9 = $[20];
789
- let t10;
790
- if ($[21] !== T1 || $[22] !== isOpen || $[23] !== t2 || $[24] !== t3 || $[25] !== t4 || $[26] !== t5 || $[27] !== t6 || $[28] !== t7 || $[29] !== t8 || $[30] !== t9) {
791
- t10 = /* @__PURE__ */ jsx(T1, {
792
- variant: t2,
793
- size: t3,
794
- width: t4,
795
- disableTooltip: t5,
796
- label: t6,
797
- icon: t7,
798
- className: "pointer-coarse:size-8",
799
- "aria-expanded": isOpen,
800
- "aria-controls": t8,
801
- onPress: t9
802
- });
803
- $[21] = T1;
804
- $[22] = isOpen;
805
- $[23] = t2;
806
- $[24] = t3;
807
- $[25] = t4;
808
- $[26] = t5;
809
- $[27] = t6;
810
- $[28] = t7;
811
- $[29] = t8;
812
- $[30] = t9;
813
- $[31] = t10;
814
- } else t10 = $[31];
815
- return t10;
816
- };
817
- const RowDetailsRow = (t0) => {
818
- const $ = c(18);
819
- const { id, colSpan, variant, panelWidth, children } = t0;
820
- const cellCva = UIOverrides.useCva("table.detailsCellCva", tableDetailsCellDefinition);
821
- const panelCva = UIOverrides.useCva("table.detailsPanelCva", tableDetailsPanelDefinition);
822
- let t1;
823
- if ($[0] !== cellCva || $[1] !== variant) {
824
- t1 = cellCva({ variant });
825
- $[0] = cellCva;
826
- $[1] = variant;
827
- $[2] = t1;
828
- } else t1 = $[2];
829
- let t2;
830
- if ($[3] !== panelWidth) {
831
- t2 = { width: panelWidth };
832
- $[3] = panelWidth;
833
- $[4] = t2;
834
- } else t2 = $[4];
835
- let t3;
836
- if ($[5] !== panelCva) {
837
- t3 = panelCva({});
838
- $[5] = panelCva;
839
- $[6] = t3;
840
- } else t3 = $[6];
841
- let t4;
842
- if ($[7] !== children || $[8] !== t3) {
843
- t4 = /* @__PURE__ */ jsx("div", {
844
- className: "grid grid-rows-[1fr] opacity-100 transition-[grid-template-rows,opacity] duration-200 ease-out starting:grid-rows-[0fr] starting:opacity-0 motion-reduce:transition-none",
845
- children: /* @__PURE__ */ jsx("div", {
846
- className: "min-h-0 overflow-hidden",
847
- children: /* @__PURE__ */ jsx("div", {
848
- className: t3,
849
- children
850
- })
851
- })
852
- });
853
- $[7] = children;
854
- $[8] = t3;
855
- $[9] = t4;
856
- } else t4 = $[9];
857
- let t5;
858
- if ($[10] !== t2 || $[11] !== t4) {
859
- t5 = /* @__PURE__ */ jsx("div", {
860
- className: "sticky left-0",
861
- style: t2,
862
- children: t4
863
- });
864
- $[10] = t2;
865
- $[11] = t4;
866
- $[12] = t5;
867
- } else t5 = $[12];
868
- let t6;
869
- if ($[13] !== colSpan || $[14] !== id || $[15] !== t1 || $[16] !== t5) {
870
- t6 = /* @__PURE__ */ jsx("tr", {
871
- "data-details-row": true,
872
- children: /* @__PURE__ */ jsx("td", {
873
- id,
874
- colSpan,
875
- className: t1,
876
- children: t5
877
- })
878
- });
879
- $[13] = colSpan;
880
- $[14] = id;
881
- $[15] = t1;
882
- $[16] = t5;
883
- $[17] = t6;
884
- } else t6 = $[17];
885
- return t6;
886
- };
887
- /** The panel's name when the table passes no `title`. */
888
- const useDefaultTitle = () => {
889
- const $ = c(2);
890
- const { t } = useTranslation("ui");
891
- let t0;
892
- if ($[0] !== t) {
893
- t0 = t(_temp$2);
894
- $[0] = t;
895
- $[1] = t0;
896
- } else t0 = $[1];
897
- return t0;
898
- };
899
- const SidePanelContent = (t0) => {
900
- const $ = c(21);
901
- const { title, onClose, children } = t0;
902
- const { t } = useTranslation("ui");
903
- const defaultTitle = useDefaultTitle();
904
- const headerCva = UIOverrides.useCva("table.sidePanelHeaderCva", tableSidePanelHeaderDefinition);
905
- const bodyCva = UIOverrides.useCva("table.sidePanelBodyCva", tableSidePanelBodyDefinition);
906
- let t1;
907
- if ($[0] !== headerCva) {
908
- t1 = headerCva({});
909
- $[0] = headerCva;
910
- $[1] = t1;
911
- } else t1 = $[1];
912
- const t2 = title ?? defaultTitle;
913
- let t3;
914
- if ($[2] !== t2) {
915
- t3 = /* @__PURE__ */ jsx(Typography, {
916
- as: "h2",
917
- size: "lead",
918
- className: "min-w-0 flex-1 font-bold",
919
- children: t2
920
- });
921
- $[2] = t2;
922
- $[3] = t3;
923
- } else t3 = $[3];
924
- let t4;
925
- if ($[4] !== t) {
926
- t4 = t(_temp2$2);
927
- $[4] = t;
928
- $[5] = t4;
929
- } else t4 = $[5];
930
- let t5;
931
- if ($[6] !== onClose || $[7] !== t4) {
932
- t5 = /* @__PURE__ */ jsx(IconButton, {
933
- variant: "text",
934
- size: "sm",
935
- width: "hug",
936
- disableTooltip: true,
937
- label: t4,
938
- icon: X,
939
- className: "shrink-0 pointer-coarse:size-8",
940
- onPress: onClose
941
- });
942
- $[6] = onClose;
943
- $[7] = t4;
944
- $[8] = t5;
945
- } else t5 = $[8];
946
- let t6;
947
- if ($[9] !== t1 || $[10] !== t3 || $[11] !== t5) {
948
- t6 = /* @__PURE__ */ jsxs("div", {
949
- className: t1,
950
- children: [t3, t5]
951
- });
952
- $[9] = t1;
953
- $[10] = t3;
954
- $[11] = t5;
955
- $[12] = t6;
956
- } else t6 = $[12];
957
- let t7;
958
- if ($[13] !== bodyCva) {
959
- t7 = bodyCva({});
960
- $[13] = bodyCva;
961
- $[14] = t7;
962
- } else t7 = $[14];
963
- let t8;
964
- if ($[15] !== children || $[16] !== t7) {
965
- t8 = /* @__PURE__ */ jsx("div", {
966
- className: t7,
967
- children
968
- });
969
- $[15] = children;
970
- $[16] = t7;
971
- $[17] = t8;
972
- } else t8 = $[17];
973
- let t9;
974
- if ($[18] !== t6 || $[19] !== t8) {
975
- t9 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t6, t8] });
976
- $[18] = t6;
977
- $[19] = t8;
978
- $[20] = t9;
979
- } else t9 = $[20];
980
- return t9;
981
- };
982
- const RowDetailsDrawer = (t0) => {
983
- const $ = c(11);
984
- const { isOpen, title, onClose, children } = t0;
985
- const defaultTitle = useDefaultTitle();
986
- const t1 = title ?? defaultTitle;
987
- let t2;
988
- if ($[0] !== onClose) {
989
- t2 = (open) => {
990
- if (!open) onClose();
991
- };
992
- $[0] = onClose;
993
- $[1] = t2;
994
- } else t2 = $[1];
995
- let t3;
996
- if ($[2] !== children || $[3] !== onClose || $[4] !== title) {
997
- t3 = () => /* @__PURE__ */ jsx(SidePanelContent, {
998
- title,
999
- onClose,
1000
- children
1001
- });
1002
- $[2] = children;
1003
- $[3] = onClose;
1004
- $[4] = title;
1005
- $[5] = t3;
1006
- } else t3 = $[5];
1007
- let t4;
1008
- if ($[6] !== isOpen || $[7] !== t1 || $[8] !== t2 || $[9] !== t3) {
1009
- t4 = /* @__PURE__ */ jsx(Drawer, {
1010
- label: t1,
1011
- isOpen,
1012
- onOpenChange: t2,
1013
- contentClassName: "h-full w-[min(30rem,100vw)] overflow-y-auto",
1014
- children: t3
1015
- });
1016
- $[6] = isOpen;
1017
- $[7] = t1;
1018
- $[8] = t2;
1019
- $[9] = t3;
1020
- $[10] = t4;
1021
- } else t4 = $[10];
1022
- return t4;
1023
- };
1024
- const RowDetailsSplitPanel = (t0) => {
1025
- const $ = c(16);
1026
- const { title, onClose, maxHeight, children } = t0;
1027
- const panelCva = UIOverrides.useCva("table.sidePanelCva", tableSidePanelDefinition);
1028
- const defaultTitle = useDefaultTitle();
1029
- const t1 = title ?? defaultTitle;
1030
- let t2;
1031
- if ($[0] !== panelCva) {
1032
- t2 = panelCva({});
1033
- $[0] = panelCva;
1034
- $[1] = t2;
1035
- } else t2 = $[1];
1036
- let t3;
1037
- if ($[2] !== maxHeight) {
1038
- t3 = maxHeight === void 0 ? void 0 : { maxHeight };
1039
- $[2] = maxHeight;
1040
- $[3] = t3;
1041
- } else t3 = $[3];
1042
- let t4;
1043
- if ($[4] !== onClose) {
1044
- t4 = (event) => {
1045
- if (event.key === "Escape") onClose();
1046
- };
1047
- $[4] = onClose;
1048
- $[5] = t4;
1049
- } else t4 = $[5];
1050
- let t5;
1051
- if ($[6] !== children || $[7] !== onClose || $[8] !== title) {
1052
- t5 = /* @__PURE__ */ jsx(SidePanelContent, {
1053
- title,
1054
- onClose,
1055
- children
1056
- });
1057
- $[6] = children;
1058
- $[7] = onClose;
1059
- $[8] = title;
1060
- $[9] = t5;
1061
- } else t5 = $[9];
1062
- let t6;
1063
- if ($[10] !== t1 || $[11] !== t2 || $[12] !== t3 || $[13] !== t4 || $[14] !== t5) {
1064
- t6 = /* @__PURE__ */ jsx("aside", {
1065
- "aria-label": t1,
1066
- className: t2,
1067
- style: t3,
1068
- onKeyDown: t4,
1069
- children: t5
1070
- });
1071
- $[10] = t1;
1072
- $[11] = t2;
1073
- $[12] = t3;
1074
- $[13] = t4;
1075
- $[14] = t5;
1076
- $[15] = t6;
1077
- } else t6 = $[15];
1078
- return t6;
1079
- };
1080
- function _temp$2($) {
1081
- return $.ui.table.rowDetails;
1082
- }
1083
- function _temp2$2($) {
1084
- return $.ui.table.closeDetails;
1085
- }
1086
- //#endregion
1087
- //#region src/components/table/TableRowSelection.tsx
1088
- const SELECT_COLUMN_ID = "row-select";
1089
- /** Header of the selection column: select-all for multi selection, a hidden column name for single selection. */
1090
- const RowSelectionHeader = ({ table }) => {
1091
- const { t } = useTranslation("ui");
1092
- if (table.options.enableMultiRowSelection === false) return /* @__PURE__ */ jsx("span", {
1093
- className: "sr-only",
1094
- children: t(($) => $.ui.table.rowSelection)
1095
- });
1096
- const isAllSelected = table.getIsAllPageRowsSelected();
1097
- const isSomeSelected = table.getIsSomePageRowsSelected();
1098
- return /* @__PURE__ */ jsx(Checkbox, {
1099
- isSelected: isAllSelected,
1100
- isIndeterminate: isSomeSelected && !isAllSelected,
1101
- isDisabled: !table.getRowModel().rows.some((row) => row.getCanSelect()),
1102
- onChange: () => table.toggleAllPageRowsSelected(!isAllSelected && !isSomeSelected),
1103
- hideLabel: true,
1104
- hideError: true,
1105
- children: t(($_0) => $_0.ui.table.selectAllRows)
1106
- });
1107
- };
1108
- const RowSelectionCell = ({ row }) => {
1109
- const { t } = useTranslation("ui");
1110
- return /* @__PURE__ */ jsx(Checkbox, {
1111
- isSelected: row.getIsSelected(),
1112
- isDisabled: !row.getCanSelect(),
1113
- onChange: (isSelected) => row.toggleSelected(isSelected),
1114
- hideLabel: true,
1115
- hideError: true,
1116
- children: t(($) => $.ui.table.selectRow, { row: row.index + 1 })
1117
- });
1118
- };
1119
- const DEFAULT_WIDTH = 150;
1120
- const KEYBOARD_STEP = 10;
1121
- const KEYBOARD_STEP_LARGE = 50;
1122
- /** Columns keep their natural widths until resized; the last column fills any remaining space. */
1123
- const useColumnResize = (t0) => {
1124
- const $ = c(39);
1125
- const { columns, columnSizing, setColumnSizing, tableRef, theadRef } = t0;
1126
- const [resizingColumnId, setResizingColumnId] = useState(null);
1127
- let t1;
1128
- if ($[0] !== columnSizing) {
1129
- t1 = Object.keys(columnSizing);
1130
- $[0] = columnSizing;
1131
- $[1] = t1;
1132
- } else t1 = $[1];
1133
- const isSized = t1.length > 0;
1134
- const lastColumnId = columns.at(-1)?.id;
1135
- let t2;
1136
- if ($[2] !== columns) {
1137
- t2 = (sizes) => columns.reduce((total, column) => total + (sizes[column.id] ?? DEFAULT_WIDTH), 0);
1138
- $[2] = columns;
1139
- $[3] = t2;
1140
- } else t2 = $[3];
1141
- const getTotalWidth = t2;
1142
- let t3;
1143
- if ($[4] !== columnSizing || $[5] !== isSized || $[6] !== lastColumnId) {
1144
- t3 = (columnId) => isSized && columnId !== lastColumnId ? columnSizing[columnId] : void 0;
1145
- $[4] = columnSizing;
1146
- $[5] = isSized;
1147
- $[6] = lastColumnId;
1148
- $[7] = t3;
1149
- } else t3 = $[7];
1150
- const getColumnWidth = t3;
1151
- let t4;
1152
- if ($[8] !== columnSizing || $[9] !== getTotalWidth || $[10] !== isSized) {
1153
- t4 = isSized ? {
1154
- tableLayout: "fixed",
1155
- width: getTotalWidth(columnSizing),
1156
- minWidth: "100%"
1157
- } : void 0;
1158
- $[8] = columnSizing;
1159
- $[9] = getTotalWidth;
1160
- $[10] = isSized;
1161
- $[11] = t4;
1162
- } else t4 = $[11];
1163
- const tableStyle = t4;
1164
- const clamp = _temp$1;
1165
- let t5;
1166
- if ($[12] !== columnSizing || $[13] !== columns || $[14] !== theadRef) {
1167
- t5 = () => {
1168
- const sizes_0 = { ...columnSizing };
1169
- const leafColumnIds = new Set(columns.map(_temp2$1));
1170
- theadRef.current?.querySelectorAll("th[data-column-id]").forEach((header) => {
1171
- const columnId_0 = header.dataset.columnId;
1172
- if (leafColumnIds.has(columnId_0)) sizes_0[columnId_0] = Math.round(header.getBoundingClientRect().width);
1173
- });
1174
- return sizes_0;
1175
- };
1176
- $[12] = columnSizing;
1177
- $[13] = columns;
1178
- $[14] = theadRef;
1179
- $[15] = t5;
1180
- } else t5 = $[15];
1181
- const measure = t5;
1182
- let t6;
1183
- if ($[16] !== getTotalWidth || $[17] !== lastColumnId || $[18] !== tableRef) {
1184
- t6 = (sizes_1) => {
1185
- const table = tableRef.current;
1186
- if (!table) return;
1187
- table.querySelectorAll("col[data-column-id]").forEach((col) => {
1188
- const columnId_1 = col.dataset.columnId;
1189
- col.style.width = columnId_1 === lastColumnId || sizes_1[columnId_1] === void 0 ? "" : `${sizes_1[columnId_1]}px`;
1190
- });
1191
- table.style.tableLayout = "fixed";
1192
- table.style.width = `${getTotalWidth(sizes_1)}px`;
1193
- table.style.minWidth = "100%";
1194
- };
1195
- $[16] = getTotalWidth;
1196
- $[17] = lastColumnId;
1197
- $[18] = tableRef;
1198
- $[19] = t6;
1199
- } else t6 = $[19];
1200
- const applyToDom = t6;
1201
- let t7;
1202
- if ($[20] !== tableRef) {
1203
- t7 = () => {
1204
- const table_0 = tableRef.current;
1205
- if (!table_0) return;
1206
- table_0.querySelectorAll("col[data-column-id]").forEach(_temp3$1);
1207
- table_0.style.tableLayout = "";
1208
- table_0.style.width = "";
1209
- table_0.style.minWidth = "";
1210
- };
1211
- $[20] = tableRef;
1212
- $[21] = t7;
1213
- } else t7 = $[21];
1214
- const clearDom = t7;
1215
- let t8;
1216
- if ($[22] !== applyToDom || $[23] !== clearDom || $[24] !== columnSizing || $[25] !== isSized || $[26] !== measure || $[27] !== setColumnSizing) {
1217
- t8 = (event, column_2) => {
1218
- if (event.button !== 0) return;
1219
- event.preventDefault();
1220
- event.stopPropagation();
1221
- const handle = event.currentTarget;
1222
- handle.setPointerCapture(event.pointerId);
1223
- const start = measure();
1224
- const startX = event.clientX;
1225
- const wasSized = isSized;
1226
- let latest = start;
1227
- let moved = false;
1228
- applyToDom(start);
1229
- setResizingColumnId(column_2.id);
1230
- const onMove = (moveEvent) => {
1231
- if (moveEvent.clientX === startX && !moved) return;
1232
- moved = true;
1233
- latest = {
1234
- ...start,
1235
- [column_2.id]: clamp(column_2, start[column_2.id] + moveEvent.clientX - startX)
1236
- };
1237
- applyToDom(latest);
1238
- };
1239
- const onEnd = () => {
1240
- handle.removeEventListener("pointermove", onMove);
1241
- handle.removeEventListener("pointerup", onEnd);
1242
- handle.removeEventListener("pointercancel", onEnd);
1243
- if (moved) setColumnSizing(latest);
1244
- else if (wasSized) applyToDom(columnSizing);
1245
- else clearDom();
1246
- setResizingColumnId(null);
1247
- };
1248
- handle.addEventListener("pointermove", onMove);
1249
- handle.addEventListener("pointerup", onEnd);
1250
- handle.addEventListener("pointercancel", onEnd);
1251
- };
1252
- $[22] = applyToDom;
1253
- $[23] = clearDom;
1254
- $[24] = columnSizing;
1255
- $[25] = isSized;
1256
- $[26] = measure;
1257
- $[27] = setColumnSizing;
1258
- $[28] = t8;
1259
- } else t8 = $[28];
1260
- const onPointerDown = t8;
1261
- let t9;
1262
- if ($[29] !== measure || $[30] !== setColumnSizing) {
1263
- t9 = (event_0, column_3) => {
1264
- const direction = {
1265
- ArrowLeft: -1,
1266
- ArrowRight: 1
1267
- }[event_0.key];
1268
- if (!direction) return;
1269
- event_0.preventDefault();
1270
- event_0.stopPropagation();
1271
- const sizes_2 = measure();
1272
- const step = event_0.shiftKey ? KEYBOARD_STEP_LARGE : KEYBOARD_STEP;
1273
- setColumnSizing({
1274
- ...sizes_2,
1275
- [column_3.id]: clamp(column_3, sizes_2[column_3.id] + direction * step)
1276
- });
1277
- };
1278
- $[29] = measure;
1279
- $[30] = setColumnSizing;
1280
- $[31] = t9;
1281
- } else t9 = $[31];
1282
- const onKeyDown = t9;
1283
- const hasFixedWidths = isSized || resizingColumnId !== null;
1284
- let t10;
1285
- if ($[32] !== getColumnWidth || $[33] !== hasFixedWidths || $[34] !== onKeyDown || $[35] !== onPointerDown || $[36] !== resizingColumnId || $[37] !== tableStyle) {
1286
- t10 = {
1287
- resizingColumnId,
1288
- hasFixedWidths,
1289
- getColumnWidth,
1290
- tableStyle,
1291
- onPointerDown,
1292
- onKeyDown
1293
- };
1294
- $[32] = getColumnWidth;
1295
- $[33] = hasFixedWidths;
1296
- $[34] = onKeyDown;
1297
- $[35] = onPointerDown;
1298
- $[36] = resizingColumnId;
1299
- $[37] = tableStyle;
1300
- $[38] = t10;
1301
- } else t10 = $[38];
1302
- return t10;
1303
- };
1304
- function _temp$1(column_0, width) {
1305
- return Math.round(Math.min(column_0.maxSize ?? Infinity, Math.max(column_0.minSize ?? 60, width)));
1306
- }
1307
- function _temp2$1(column_1) {
1308
- return column_1.id;
1309
- }
1310
- function _temp3$1(col_0) {
1311
- return col_0.style.width = "";
1312
- }
1313
- //#endregion
1314
- //#region src/components/table/Table.tsx
1315
- const DndProvider = lazy(() => Promise.resolve().then(() => TableDnd_exports).then((module) => ({ default: module.DndProvider })));
1316
- const SortableRows = lazy(() => Promise.resolve().then(() => TableDnd_exports).then((module) => ({ default: module.SortableRows })));
1317
- const DraggableRow = lazy(() => Promise.resolve().then(() => TableDnd_exports).then((module) => ({ default: module.DraggableRow })));
1318
- const DragHandle = lazy(() => Promise.resolve().then(() => TableDnd_exports).then((module) => ({ default: module.DragHandle })));
1319
- const tableFeaturesConfig = tableFeatures({
1320
- ...stockFeatures,
1321
- sortedRowModel: createSortedRowModel(),
1322
- paginatedRowModel: createPaginatedRowModel()
1323
- });
1324
- const CustomCellContext = (context) => {
1325
- return {
1326
- ...context,
1327
- original: context.row.original,
1328
- data: context.row.original,
1329
- value: context.getValue()
1330
- };
1331
- };
1332
- const isPlainFunction = (Comp) => typeof Comp === "function" && !Comp.prototype?.isReactComponent;
1333
- const CellContent = ({ cell, props }) => {
1334
- const rendered = isPlainFunction(cell) ? cell(props) : flexRender(cell, props);
1335
- return typeof rendered === "string" || typeof rendered === "number" ? /* @__PURE__ */ jsx(CellText, { children: rendered }) : rendered;
1336
- };
1337
- const renderCell = (Comp, props) => /* @__PURE__ */ jsx(CellContent, {
1338
- cell: Comp,
1339
- props
1340
- });
1341
- const RowDragHandleCell = ({ row }) => {
1342
- const { t } = useTranslation("ui");
1343
- return /* @__PURE__ */ jsx(DragHandle, {
1344
- id: row.id,
1345
- label: t(($) => $.ui.table.reorderRow, { row: row.index + 1 })
1346
- });
1347
- };
1348
- const ColumnResizeHandle = ({ columnName, isResizing, minWidth, maxWidth, ...props }) => {
1349
- const ref = useRef(null);
1350
- const [width, setWidth] = useState();
1351
- useLayoutEffect(() => {
1352
- const header = ref.current?.closest("th");
1353
- if (!header) return;
1354
- const measure = () => setWidth(Math.round(header.getBoundingClientRect().width));
1355
- measure();
1356
- const observer = new ResizeObserver(measure);
1357
- observer.observe(header);
1358
- return () => observer.disconnect();
1359
- }, []);
1360
- return /* @__PURE__ */ jsx("div", {
1361
- ref,
1362
- role: "separator",
1363
- "aria-orientation": "vertical",
1364
- "aria-label": `Resize ${columnName}`,
1365
- "aria-valuenow": width,
1366
- "aria-valuemin": minWidth,
1367
- "aria-valuemax": maxWidth,
1368
- tabIndex: 0,
1369
- "data-resizing": isResizing || void 0,
1370
- className: clsx("absolute inset-y-0 right-0 z-raised w-2 pointer-coarse:w-6 cursor-col-resize touch-none select-none outline-none", "after:absolute after:inset-y-1 after:right-0 after:w-0.5 after:rounded-full after:transition-colors", "hover:after:bg-card-foreground focus-visible:after:bg-ring", "data-resizing:after:bg-card-foreground"),
1371
- ...props
1372
- });
1373
- };
1374
- const DRAG_COLUMN_ID = "drag-handle";
1375
- const isOwnColumn = (columnId) => columnId === DRAG_COLUMN_ID || columnId === "row-select" || columnId === "row-expand";
1376
- const ROW_CONTROL_SELECTOR = "button, a, input, select, textarea, label, [role=button], [role=checkbox], [role=switch], [role=combobox], [role=separator]";
1377
- const isFromRowControl = (event) => event.target instanceof Element && event.target.closest(ROW_CONTROL_SELECTOR) !== null;
1378
- const isFromSelectCell = (event) => event.target instanceof Element && event.target.closest("td[data-select-cell]") !== null;
1379
- const isRowActionKey = (event) => event.key === "Enter" && event.target instanceof HTMLTableCellElement && !event.target.hasAttribute("data-select-cell") && !event.target.querySelector(ROW_CONTROL_SELECTOR);
1380
- const EMPTY_PINNING = {
1381
- start: [],
1382
- end: []
1383
- };
1384
- const EMPTY_SIZING = {};
1385
- const MIN_SCROLLING_SHARE = .25;
1386
- const MIN_SCROLLING_WIDTH = 120;
1387
- const MIN_PINNABLE_COLUMN_WIDTH = 100;
1388
- const getPinnedProps = (column, pinnedOffsets) => {
1389
- const pinned = column.getIsPinned();
1390
- if (!pinned || pinnedOffsets[column.id] === void 0) return {};
1391
- const edgeColumns = column.table.getPinnedVisibleLeafColumns(pinned).filter(({ id }) => pinnedOffsets[id] !== void 0);
1392
- const isEdge = (pinned === "start" ? edgeColumns.at(-1) : edgeColumns[0])?.id === column.id;
1393
- return {
1394
- style: { [pinned === "start" ? "left" : "right"]: pinnedOffsets[column.id] },
1395
- "data-pinned": pinned,
1396
- "data-pinned-edge": isEdge ? pinned : void 0,
1397
- "data-column-id": column.id
1398
- };
1399
- };
1400
- const Table = ({ items, showCellBorder, columns, onRowAction, onRowDoubleClick, isLoading = false, emptyState, className, variant: variantProp, containerClassName, maxHeight, scroll = "table", sorting, onSortingChange, columnOrder, onColumnOrderChange, columnVisibility, onColumnVisibilityChange, enableColumnPinning = false, columnPinning: columnPinningProp, onColumnPinningChange, enableColumnResizing = false, columnSizing: columnSizingProp, onColumnSizingChange, rowDetails, expanded: expandedProp, onExpandedChange, bulkSelectionActions: ActionHeader, enableDragDrop = false, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection = true, rowSelection: rowSelectionProp, defaultRowSelection, onRowSelectionChange, ...props }) => {
1401
- const uiConfig = UIConfig.useConfig();
1402
- const variant = variantProp ?? uiConfig.table.variant;
1403
- const showColumnBorders = showCellBorder ?? (variant !== "horizontals" && variant !== "zebra" && variant !== "striped-columns");
1404
- const tableContainerCva = UIOverrides.useCva("table.containerCva", tableContainerDefinition);
1405
- const tableRowCva = UIOverrides.useCva("table.rowCva", tableRowDefinition);
1406
- const theadCva = UIOverrides.useCva("table.theadCva", theadDefinition);
1407
- const tableHeadRowCva = UIOverrides.useCva("table.headRowCva", tableHeadRowDefinition);
1408
- const tableHeadDataCva = UIOverrides.useCva("table.headDataCva", tableHeadDataDefinition);
1409
- const tableDataCva = UIOverrides.useCva("table.dataCva", tableDataDefinition);
1410
- const { t } = useTranslation("ui");
1411
- const { listeners } = useTableNav({ selectors: { Row: "tr:not([data-details-row])" } });
1412
- const data = useMemo(() => items ?? [], [items]);
1413
- const tabStopCellRef = useRef(null);
1414
- const syncTabStopCell = (tbody) => {
1415
- if (!tbody) return;
1416
- const current = tabStopCellRef.current;
1417
- if (current?.isConnected && tbody.contains(current)) return;
1418
- const first = tbody.querySelector(":scope > tr:not([data-details-row], [data-status-row]) > td");
1419
- if (first) first.tabIndex = 0;
1420
- tabStopCellRef.current = first;
1421
- };
1422
- const moveTabStopCell = (event) => {
1423
- const cell = event.target.closest("td");
1424
- if (!cell || cell === tabStopCellRef.current || cell.closest("tbody") !== event.currentTarget || cell.parentElement?.matches("[data-details-row], [data-status-row]")) return;
1425
- if (tabStopCellRef.current) tabStopCellRef.current.tabIndex = -1;
1426
- cell.tabIndex = 0;
1427
- tabStopCellRef.current = cell;
1428
- };
1429
- const [internalRowSelection, setInternalRowSelection] = useState(() => defaultRowSelection ?? {});
1430
- const isRowSelectionControlled = rowSelectionProp !== void 0;
1431
- const rowSelection = rowSelectionProp ?? internalRowSelection;
1432
- const handleRowSelectionChange = useCallback((updater) => {
1433
- if (!isRowSelectionControlled) setInternalRowSelection(updater);
1434
- onRowSelectionChange?.(updater);
1435
- }, [isRowSelectionControlled, onRowSelectionChange]);
1436
- const baseColumns = useMemo(() => typeof columns === "function" ? columns(i18next.t) : columns, [columns]);
1437
- const rowDetailsMode = rowDetails && !enableDragDrop ? rowDetails.mode ?? uiConfig.table.rowDetailsMode : void 0;
1438
- const hasExpandColumn = rowDetailsMode === "expand";
1439
- const hasDragColumn = enableDragDrop && !!getRowId;
1440
- const hasSelectColumn = !!enableRowSelection;
1441
- const tableColumns = useMemo(() => {
1442
- const ownColumns = [];
1443
- const ownColumnOptions = {
1444
- enableSorting: false,
1445
- enablePinning: false,
1446
- enableResizing: false,
1447
- enableHiding: false
1448
- };
1449
- if (hasDragColumn) ownColumns.push({
1450
- id: DRAG_COLUMN_ID,
1451
- header: "",
1452
- meta: { width: "w-12" },
1453
- cell: RowDragHandleCell,
1454
- ...ownColumnOptions
1455
- });
1456
- if (hasSelectColumn) ownColumns.push({
1457
- id: SELECT_COLUMN_ID,
1458
- header: "",
1459
- meta: { width: "w-10" },
1460
- cell: ({ row }) => /* @__PURE__ */ jsx(RowSelectionCell, { row }),
1461
- ...ownColumnOptions
1462
- });
1463
- if (hasExpandColumn) ownColumns.push({
1464
- id: EXPAND_COLUMN_ID,
1465
- header: () => /* @__PURE__ */ jsx("span", {
1466
- className: "sr-only",
1467
- children: "Row details"
1468
- }),
1469
- meta: {
1470
- width: "w-10",
1471
- headerClass: "px-1",
1472
- cellClass: "px-1"
1473
- },
1474
- cell: RowExpandCell,
1475
- ...ownColumnOptions
1476
- });
1477
- return ownColumns.length > 0 ? [...ownColumns, ...baseColumns] : baseColumns;
1478
- }, [
1479
- baseColumns,
1480
- hasDragColumn,
1481
- hasSelectColumn,
1482
- hasExpandColumn
1483
- ]);
1484
- const ownColumnIds = [
1485
- ...hasDragColumn ? [DRAG_COLUMN_ID] : [],
1486
- ...hasSelectColumn ? [SELECT_COLUMN_ID] : [],
1487
- ...hasExpandColumn ? [EXPAND_COLUMN_ID] : []
1488
- ];
1489
- const withOwnColumns = (order) => order.length > 0 ? [...ownColumnIds, ...order.filter((id) => !isOwnColumn(id))] : order;
1490
- const handleColumnOrderChange = (updater_0) => onColumnOrderChange?.((previous) => (typeof updater_0 === "function" ? updater_0(withOwnColumns(previous)) : updater_0).filter((id_0) => !isOwnColumn(id_0)));
1491
- const [internalColumnPinning, setInternalColumnPinning] = useState(EMPTY_PINNING);
1492
- const columnPinning = columnPinningProp ?? internalColumnPinning;
1493
- const setColumnPinning = onColumnPinningChange ?? setInternalColumnPinning;
1494
- const pinnedOwnColumnIds = columnPinning.start.length > 0 ? ownColumnIds : [];
1495
- const hasPinnedOwnColumns = pinnedOwnColumnIds.length > 0;
1496
- const withPinnedOwnColumns = (pinning) => hasPinnedOwnColumns ? {
1497
- ...pinning,
1498
- start: [...pinnedOwnColumnIds, ...pinning.start]
1499
- } : pinning;
1500
- const tablePinning = withPinnedOwnColumns(columnPinning);
1501
- const handleColumnPinningChange = (updater_1) => setColumnPinning((previous_0) => {
1502
- const next = typeof updater_1 === "function" ? updater_1(withPinnedOwnColumns(previous_0)) : updater_1;
1503
- return {
1504
- ...next,
1505
- start: next.start.filter((id_1) => !isOwnColumn(id_1))
1506
- };
1507
- });
1508
- const [internalExpanded, setInternalExpanded] = useState({});
1509
- const expanded = expandedProp ?? internalExpanded;
1510
- const setExpanded = onExpandedChange ?? setInternalExpanded;
1511
- const [internalColumnSizing, setInternalColumnSizing] = useState(EMPTY_SIZING);
1512
- const columnSizing = enableColumnResizing && (columnSizingProp ?? internalColumnSizing) || EMPTY_SIZING;
1513
- const setColumnSizing = onColumnSizingChange ?? setInternalColumnSizing;
1514
- const [isSticky, setIsSticky] = useState(false);
1515
- const [isStuckStart, setIsStuckStart] = useState(false);
1516
- const [isStuckEnd, setIsStuckEnd] = useState(false);
1517
- const tableRef = useRef(null);
1518
- const theadRef = useRef(null);
1519
- const updateStuck = useCallback(() => {
1520
- const tableRect = tableRef.current?.getBoundingClientRect();
1521
- const theadTop = theadRef.current?.getBoundingClientRect().top;
1522
- setIsSticky(tableRect !== void 0 && theadTop !== void 0 && theadTop > tableRect.top);
1523
- const startEdge = theadRef.current?.querySelector("th[data-pinned-edge=start]");
1524
- const endEdge = theadRef.current?.querySelector("th[data-pinned-edge=end]");
1525
- const startRect = startEdge?.getBoundingClientRect();
1526
- const endRect = endEdge?.getBoundingClientRect();
1527
- setIsStuckStart(!!tableRect && !!startRect && startRect.left > tableRect.left + parseFloat(startEdge.style.left) + .5);
1528
- setIsStuckEnd(!!tableRect && !!endRect && endRect.right < tableRect.right - parseFloat(endEdge.style.right) - .5);
1529
- }, []);
1530
- useEffect(() => {
1531
- updateStuck();
1532
- document.addEventListener("scroll", updateStuck, {
1533
- capture: true,
1534
- passive: true
1535
- });
1536
- window.addEventListener("resize", updateStuck, { passive: true });
1537
- return () => {
1538
- document.removeEventListener("scroll", updateStuck, { capture: true });
1539
- window.removeEventListener("resize", updateStuck);
1540
- };
1541
- }, [updateStuck]);
1542
- const table = useTable({
1543
- features: tableFeaturesConfig,
1544
- data,
1545
- columns: tableColumns,
1546
- state: {
1547
- sorting,
1548
- columnOrder: columnOrder && withOwnColumns(columnOrder),
1549
- columnVisibility,
1550
- columnPinning: tablePinning,
1551
- columnSizing,
1552
- rowSelection
1553
- },
1554
- rowCount: items.length,
1555
- manualPagination: true,
1556
- onColumnOrderChange: handleColumnOrderChange,
1557
- onColumnVisibilityChange,
1558
- onColumnPinningChange: handleColumnPinningChange,
1559
- onColumnSizingChange: setColumnSizing,
1560
- onSortingChange,
1561
- onRowSelectionChange: handleRowSelectionChange,
1562
- manualSorting: true,
1563
- enableSorting: onSortingChange !== void 0,
1564
- autoResetPageIndex: false,
1565
- autoResetExpanded: false,
1566
- defaultColumn: {
1567
- sortDescFirst: true,
1568
- minSize: 60
1569
- },
1570
- enableRowSelection: enableRowSelection ?? false,
1571
- enableMultiRowSelection,
1572
- getRowId: getRowId ? (row_0) => String(getRowId(row_0)) : void 0
1573
- });
1574
- const dataIds = useMemo(() => {
1575
- if (!enableDragDrop || !getRowId) return [];
1576
- return data.map((item) => String(getRowId(item)));
1577
- }, [
1578
- data,
1579
- enableDragDrop,
1580
- getRowId
1581
- ]);
1582
- const handleDragEnd = useCallback((event_0) => {
1583
- const { active, over } = event_0;
1584
- if (!active || !over || active.id === over.id) return;
1585
- if (getRowId && (onReorder || onDragEnd)) {
1586
- if (onReorder) {
1587
- const oldIndex = items.findIndex((item_0) => String(getRowId(item_0)) === String(active.id));
1588
- const newIndex = items.findIndex((item_1) => String(getRowId(item_1)) === String(over.id));
1589
- if (oldIndex !== -1 && newIndex !== -1) {
1590
- const reorderedItems = [...items];
1591
- const [movedItem] = reorderedItems.splice(oldIndex, 1);
1592
- reorderedItems.splice(newIndex, 0, movedItem);
1593
- onReorder(reorderedItems);
1594
- }
1595
- }
1596
- onDragEnd?.(event_0);
1597
- }
1598
- }, [
1599
- onDragEnd,
1600
- onReorder,
1601
- items,
1602
- getRowId
1603
- ]);
1604
- const selectedRows = table.getSelectedRowModel().rows;
1605
- const columnCount = table.getHeaderGroups()[0].headers.length;
1606
- const isAnyRowSelected = selectedRows.length > 0 && !!ActionHeader;
1607
- const hasOnClick = !!onRowAction || !!onRowDoubleClick;
1608
- const hasPinnedColumns = columnPinning.start.length > 0 || columnPinning.end.length > 0;
1609
- const rows = table.getRowModel().rows;
1610
- const unborderedIndex = hasExpandColumn ? ownColumnIds.length : 0;
1611
- const expandableRows = useExpandableRows({
1612
- rowDetails: hasExpandColumn ? rowDetails : void 0,
1613
- expanded,
1614
- setExpanded,
1615
- rowIds: rows.map((row_1) => row_1.id),
1616
- tableRef,
1617
- scroll
1618
- });
1619
- const hasSidePanel = rowDetailsMode === "drawer" || rowDetailsMode === "split";
1620
- const isWideEnoughForSplit = useBreakpoint("lg");
1621
- const sidePanelMode = hasSidePanel && rowDetailsMode === "split" && isWideEnoughForSplit ? "split" : "drawer";
1622
- const openRowId = hasSidePanel && expanded !== true ? Object.keys(expanded).find((rowId) => expanded[rowId]) : void 0;
1623
- const openRow = openRowId === void 0 ? void 0 : rows.find((row_2) => row_2.id === openRowId);
1624
- const [lastOpenRow, setLastOpenRow] = useState(openRow);
1625
- if (openRow && openRow !== lastOpenRow) setLastOpenRow(openRow);
1626
- const detailsRow = openRow ?? lastOpenRow;
1627
- const canOpenDetails = (row_3) => hasSidePanel && (rowDetails?.canOpen?.(row_3.original) ?? true);
1628
- const openDetails = (rowId_0) => setExpanded({ [rowId_0]: true });
1629
- const closeDetails = () => setExpanded({});
1630
- const leafHeaders = table.getHeaderGroups().at(-1)?.headers ?? [];
1631
- const columnResize = useColumnResize({
1632
- columns: leafHeaders.map(({ column }) => ({
1633
- id: column.id,
1634
- minSize: column.columnDef.minSize,
1635
- maxSize: column.columnDef.maxSize
1636
- })),
1637
- columnSizing,
1638
- setColumnSizing,
1639
- tableRef,
1640
- theadRef
1641
- });
1642
- const isResizing = columnResize.resizingColumnId !== null;
1643
- const [pinnedOffsets, setPinnedOffsets] = useState({});
1644
- useLayoutEffect(() => {
1645
- const allHeaders = Array.from(theadRef.current?.querySelectorAll("th[data-column-id]") ?? []);
1646
- const getHeaders = (side) => allHeaders.filter((header) => side.includes(header.dataset.columnId));
1647
- const startHeaders = getHeaders(tablePinning.start);
1648
- const endHeaders = getHeaders(tablePinning.end).toReversed();
1649
- if (startHeaders.length === 0 && endHeaders.length === 0) return;
1650
- const container = tableRef.current?.parentElement;
1651
- const measure = () => {
1652
- const visibleWidth = scroll === "page" ? document.documentElement.clientWidth : container?.clientWidth ?? 0;
1653
- let budget = visibleWidth - Math.max(MIN_SCROLLING_WIDTH, visibleWidth * MIN_SCROLLING_SHARE);
1654
- const offsets = {};
1655
- const accumulate = (ordered) => {
1656
- let offset = 0;
1657
- for (const header_0 of ordered) {
1658
- const width = header_0.getBoundingClientRect().width;
1659
- if (width > budget) break;
1660
- offsets[header_0.dataset.columnId] = offset;
1661
- offset += width;
1662
- budget -= width;
1663
- }
1664
- };
1665
- accumulate(startHeaders);
1666
- accumulate(endHeaders);
1667
- if (isResizing) {
1668
- tableRef.current?.querySelectorAll("[data-pinned][data-column-id]").forEach((cell_0) => {
1669
- const offset_0 = offsets[cell_0.dataset.columnId];
1670
- if (offset_0 !== void 0) cell_0.style[cell_0.dataset.pinned === "start" ? "left" : "right"] = `${offset_0}px`;
1671
- });
1672
- requestAnimationFrame(updateStuck);
1673
- return;
1674
- }
1675
- setPinnedOffsets((previous_1) => Object.keys(offsets).length === Object.keys(previous_1).length && Object.entries(offsets).every(([id_2, offset_1]) => previous_1[id_2] === offset_1) ? previous_1 : offsets);
1676
- requestAnimationFrame(updateStuck);
1677
- };
1678
- measure();
1679
- const observer = new ResizeObserver(measure);
1680
- [...startHeaders, ...endHeaders].forEach((header_1) => observer.observe(header_1));
1681
- if (container && scroll === "table") observer.observe(container);
1682
- window.addEventListener("resize", measure, { passive: true });
1683
- return () => {
1684
- observer.disconnect();
1685
- window.removeEventListener("resize", measure);
1686
- };
1687
- }, [
1688
- columnPinning,
1689
- pinnedOwnColumnIds.length,
1690
- columnVisibility,
1691
- columnOrder,
1692
- isAnyRowSelected,
1693
- scroll,
1694
- updateStuck,
1695
- isResizing
1696
- ]);
1697
- const tableElement = /* @__PURE__ */ jsx("div", {
1698
- className: tableContainerCva({
1699
- variant,
1700
- scroll,
1701
- className: containerClassName
1702
- }),
1703
- style: maxHeight === void 0 || scroll === "page" ? void 0 : { maxHeight },
1704
- children: /* @__PURE__ */ jsxs("table", {
1705
- ref: tableRef,
1706
- className: clsx("group/table w-full font-sans text-sm", hasPinnedColumns && "border-separate border-spacing-0", className),
1707
- style: columnResize.tableStyle,
1708
- "aria-busy": isLoading || void 0,
1709
- "data-has-pinned": hasPinnedColumns || void 0,
1710
- "data-stuck-start": isStuckStart || void 0,
1711
- "data-stuck-end": isStuckEnd || void 0,
1712
- ...listeners,
1713
- children: [
1714
- enableColumnResizing && /* @__PURE__ */ jsx("colgroup", { children: leafHeaders.map(({ column: column_0 }) => /* @__PURE__ */ jsx("col", {
1715
- "data-column-id": column_0.id,
1716
- style: { width: columnResize.getColumnWidth(column_0.id) }
1717
- }, column_0.id)) }),
1718
- /* @__PURE__ */ jsx("thead", {
1719
- ref: theadRef,
1720
- className: clsx(theadCva({})),
1721
- "data-is-sticky": isSticky || void 0,
1722
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx("tr", {
1723
- className: clsx(tableHeadRowCva({})),
1724
- children: headerGroup.headers.filter((header_2) => {
1725
- if (isAnyRowSelected && header_2.index > 0) return false;
1726
- return header_2.column.getIsVisible();
1727
- }).map((header_3, index) => {
1728
- const columnMeta = header_3.column.columnDef.meta ?? {};
1729
- const pinned = isAnyRowSelected ? false : header_3.column.getIsPinned();
1730
- const columnName = typeof header_3.column.columnDef.header === "string" ? header_3.column.columnDef.header : header_3.column.id;
1731
- const ariaSort = header_3.column.getCanSort() ? {
1732
- asc: "ascending",
1733
- desc: "descending"
1734
- }[header_3.column.getIsSorted()] ?? "none" : void 0;
1735
- return /* @__PURE__ */ jsx("th", {
1736
- scope: "col",
1737
- colSpan: isAnyRowSelected ? columnCount : header_3.colSpan,
1738
- tabIndex: -1,
1739
- "aria-sort": ariaSort,
1740
- "data-column-id": header_3.column.id,
1741
- ...pinned ? getPinnedProps(header_3.column, pinnedOffsets) : {},
1742
- className: clsx(tableHeadDataCva({
1743
- variant,
1744
- hasRightBorder: index > 0 && index !== unborderedIndex && showColumnBorders
1745
- }), "group/th", enableColumnResizing && "relative pointer-coarse:pr-6", columnMeta.headerClass, !columnResize.hasFixedWidths && columnMeta.width),
1746
- children: isAnyRowSelected ? hasSelectColumn ? /* @__PURE__ */ jsxs("div", {
1747
- className: "flex items-center gap-4",
1748
- children: [/* @__PURE__ */ jsx(RowSelectionHeader, { table }), /* @__PURE__ */ jsx(ActionHeader, { table })]
1749
- }) : /* @__PURE__ */ jsx(ActionHeader, { table }) : header_3.column.id === "row-select" ? /* @__PURE__ */ jsx(RowSelectionHeader, { table }) : /* @__PURE__ */ jsxs("div", {
1750
- className: "flex min-w-0 items-center gap-1",
1751
- children: [
1752
- /* @__PURE__ */ jsx("div", {
1753
- className: "flex min-w-0 flex-1",
1754
- children: (() => {
1755
- const canSort = header_3.column.getCanSort();
1756
- const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [typeof header_3.column.columnDef.header === "function" ? flexRender(header_3.column.columnDef.header, header_3.getContext()) : /* @__PURE__ */ jsx(HeaderText, {
1757
- className: enableColumnResizing ? "min-w-0 whitespace-nowrap" : void 0,
1758
- children: header_3.column.columnDef.header
1759
- }), {
1760
- asc: /* @__PURE__ */ jsx(IconSlot, { icon: ArrowUp }),
1761
- desc: /* @__PURE__ */ jsx(IconSlot, { icon: ArrowDown })
1762
- }[header_3.column.getIsSorted()] ?? (canSort ? /* @__PURE__ */ jsx(IconSlot, {
1763
- icon: ArrowUpDown,
1764
- className: "text-foreground opacity-60"
1765
- }) : null)] });
1766
- const contentClassName = clsx("flex min-w-0 select-none items-center gap-1 text-card-foreground", canSort && [uiOutlineClass, "-mx-1 h-6 cursor-pointer rounded-xs px-1 hover:bg-muted/50"], columnMeta.sortClass);
1767
- return canSort ? /* @__PURE__ */ jsx("button", {
1768
- type: "button",
1769
- className: contentClassName,
1770
- onClick: header_3.column.getToggleSortingHandler(),
1771
- children: content
1772
- }) : /* @__PURE__ */ jsx("div", {
1773
- className: contentClassName,
1774
- children: content
1775
- });
1776
- })()
1777
- }),
1778
- enableColumnPinning && header_3.column.getCanPin() && (pinned || (columnSizing[header_3.column.id] ?? Infinity) >= MIN_PINNABLE_COLUMN_WIDTH) && /* @__PURE__ */ jsx(Tooltip, {
1779
- text: `${pinned ? "Unpin" : "Pin"} ${columnName}`,
1780
- placement: "bottom",
1781
- children: /* @__PURE__ */ jsx(IconButton, {
1782
- variant: "text",
1783
- size: "sm",
1784
- width: "hug",
1785
- disableTooltip: true,
1786
- label: `${pinned ? "Unpin" : "Pin"} ${columnName}`,
1787
- icon: pinned ? /* @__PURE__ */ jsx(Pin, { className: "fill-current" }) : Pin,
1788
- className: clsx("shrink-0 pointer-coarse:size-8", !pinned && "opacity-0 group-hover/th:opacity-100 group-focus-within/th:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100"),
1789
- onPress: () => header_3.column.pin(pinned ? false : "start")
1790
- })
1791
- }),
1792
- enableColumnResizing && !header_3.isPlaceholder && header_3.column.columns.length === 0 && header_3.column.columnDef.enableResizing !== false && /* @__PURE__ */ jsx(ColumnResizeHandle, {
1793
- columnName,
1794
- isResizing: columnResize.resizingColumnId === header_3.column.id,
1795
- minWidth: header_3.column.columnDef.minSize ?? 60,
1796
- maxWidth: header_3.column.columnDef.maxSize === Number.MAX_SAFE_INTEGER ? void 0 : header_3.column.columnDef.maxSize,
1797
- onPointerDown: (event_1) => columnResize.onPointerDown(event_1, {
1798
- id: header_3.column.id,
1799
- minSize: header_3.column.columnDef.minSize,
1800
- maxSize: header_3.column.columnDef.maxSize
1801
- }),
1802
- onKeyDown: (event_2) => columnResize.onKeyDown(event_2, {
1803
- id: header_3.column.id,
1804
- minSize: header_3.column.columnDef.minSize,
1805
- maxSize: header_3.column.columnDef.maxSize
1806
- })
1807
- })
1808
- ]
1809
- })
1810
- }, header_3.id);
1811
- })
1812
- }, headerGroup.id))
1813
- }),
1814
- /* @__PURE__ */ jsx("tbody", {
1815
- ref: syncTabStopCell,
1816
- onFocus: moveTabStopCell,
1817
- className: "relative",
1818
- children: isLoading || rows.length === 0 ? /* @__PURE__ */ jsx("tr", {
1819
- "data-status-row": true,
1820
- children: /* @__PURE__ */ jsx("td", {
1821
- colSpan: table.getVisibleLeafColumns().length,
1822
- className: clsx(tableDataCva({
1823
- variant,
1824
- hasRightBorder: false
1825
- }), "py-8 text-center whitespace-normal text-muted-foreground"),
1826
- children: isLoading ? /* @__PURE__ */ jsxs("div", {
1827
- className: "flex justify-center",
1828
- children: [/* @__PURE__ */ jsx(Spinner, {}), /* @__PURE__ */ jsx("span", {
1829
- className: "sr-only",
1830
- children: t(($) => $.ui.loadingState.text)
1831
- })]
1832
- }) : emptyState ?? t(($_0) => $_0.ui.table.noResults)
1833
- })
1834
- }) : enableDragDrop ? /* @__PURE__ */ jsx(SortableRows, {
1835
- items: dataIds,
1836
- children: table.getRowModel().rows.map((row_4) => /* @__PURE__ */ jsx(DraggableRow, {
1837
- id: row_4.id,
1838
- className: clsx(tableRowCva({
1839
- ...props,
1840
- variant
1841
- })),
1842
- isClickable: hasOnClick || row_4.getCanSelect(),
1843
- isSelected: row_4.getIsSelected(),
1844
- onClick: (event_3) => {
1845
- if (isFromSelectCell(event_3)) {
1846
- if (!isFromRowControl(event_3) && row_4.getCanSelect()) row_4.toggleSelected();
1847
- return;
1848
- }
1849
- if (onRowAction) {
1850
- onRowAction(row_4.original);
1851
- return;
1852
- }
1853
- if (row_4.getCanSelect() && !isFromRowControl(event_3)) row_4.toggleSelected();
1854
- },
1855
- onDoubleClick: (event_4) => {
1856
- if (!isFromSelectCell(event_4)) onRowDoubleClick?.(row_4.original);
1857
- },
1858
- onKeyDown: onRowAction ? (event_5) => {
1859
- if (isRowActionKey(event_5)) onRowAction(row_4.original);
1860
- } : void 0,
1861
- children: row_4.getVisibleCells().map((cell_1, cellIndex) => {
1862
- const columnMeta_0 = cell_1.column.columnDef.meta ?? {};
1863
- return /* @__PURE__ */ jsx("td", {
1864
- tabIndex: -1,
1865
- "data-select-cell": cell_1.column.id === "row-select" || void 0,
1866
- ...getPinnedProps(cell_1.column, pinnedOffsets),
1867
- className: clsx(tableDataCva({
1868
- variant,
1869
- hasRightBorder: cellIndex > 0 && showColumnBorders
1870
- }), columnMeta_0.cellClass, !columnResize.hasFixedWidths && columnMeta_0.width),
1871
- children: renderCell(cell_1.column.columnDef.cell, CustomCellContext(cell_1.getContext()))
1872
- }, cell_1.id);
1873
- })
1874
- }, row_4.id))
1875
- }) : rows.map((row_5) => {
1876
- const canExpand = expandableRows.context.canExpand(row_5.original);
1877
- const isExpanded = canExpand && expandableRows.context.isExpanded(row_5.id);
1878
- const hasDetails = canOpenDetails(row_5);
1879
- const cells = row_5.getVisibleCells();
1880
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("tr", {
1881
- className: clsx(tableRowCva({
1882
- ...props,
1883
- variant
1884
- })),
1885
- onClick: (event_6) => {
1886
- if (isFromSelectCell(event_6)) {
1887
- if (!isFromRowControl(event_6) && row_5.getCanSelect()) row_5.toggleSelected();
1888
- return;
1889
- }
1890
- if (onRowAction) {
1891
- onRowAction(row_5.original);
1892
- return;
1893
- }
1894
- if (canExpand || hasDetails) {
1895
- if (isFromRowControl(event_6)) return;
1896
- if (canExpand) expandableRows.context.toggle(row_5.id);
1897
- else openDetails(row_5.id);
1898
- return;
1899
- }
1900
- if (row_5.getCanSelect() && !isFromRowControl(event_6)) row_5.toggleSelected();
1901
- },
1902
- onKeyDown: onRowAction || hasDetails ? (event_7) => {
1903
- if (!isRowActionKey(event_7)) return;
1904
- if (onRowAction) onRowAction(row_5.original);
1905
- else openDetails(row_5.id);
1906
- } : void 0,
1907
- onDoubleClick: (event_8) => {
1908
- if (!isFromSelectCell(event_8)) onRowDoubleClick?.(row_5.original);
1909
- },
1910
- "data-clickable": hasOnClick || canExpand || hasDetails || row_5.getCanSelect() || void 0,
1911
- "data-selected": row_5.getIsSelected() || void 0,
1912
- "data-expanded": isExpanded || void 0,
1913
- "data-details-open": hasSidePanel && row_5.id === openRowId || void 0,
1914
- children: cells.map((cell_2, cellIndex_0) => {
1915
- const columnMeta_1 = cell_2.column.columnDef.meta ?? {};
1916
- return /* @__PURE__ */ jsx("td", {
1917
- tabIndex: -1,
1918
- "data-select-cell": cell_2.column.id === "row-select" || void 0,
1919
- ...getPinnedProps(cell_2.column, pinnedOffsets),
1920
- className: clsx(tableDataCva({
1921
- variant,
1922
- hasRightBorder: cellIndex_0 > 0 && cellIndex_0 !== unborderedIndex && showColumnBorders
1923
- }), columnMeta_1.cellClass, !columnResize.hasFixedWidths && columnMeta_1.width),
1924
- children: renderCell(cell_2.column.columnDef.cell, CustomCellContext(cell_2.getContext()))
1925
- }, cell_2.id);
1926
- })
1927
- }), isExpanded && rowDetails && /* @__PURE__ */ jsx(RowDetailsRow, {
1928
- id: expandableRows.context.getDetailsId(row_5.id),
1929
- colSpan: cells.length,
1930
- variant,
1931
- panelWidth: expandableRows.panelWidth,
1932
- children: rowDetails.render(row_5.original, { close: () => expandableRows.context.toggle(row_5.id) })
1933
- })] }, row_5.id);
1934
- })
1935
- })
1936
- ]
1937
- })
1938
- });
1939
- if (hasExpandColumn) return /* @__PURE__ */ jsx(RowDetailsProvider, {
1940
- value: expandableRows.context,
1941
- children: tableElement
1942
- });
1943
- if (hasSidePanel && rowDetails) {
1944
- const title = detailsRow && rowDetails.title?.(detailsRow.original);
1945
- const details = detailsRow && rowDetails.render(detailsRow.original, { close: closeDetails });
1946
- if (sidePanelMode === "split") return /* @__PURE__ */ jsxs("div", {
1947
- className: "flex items-start",
1948
- children: [/* @__PURE__ */ jsx("div", {
1949
- className: "min-w-0 flex-1",
1950
- children: tableElement
1951
- }), openRow && /* @__PURE__ */ jsx(RowDetailsSplitPanel, {
1952
- title,
1953
- onClose: closeDetails,
1954
- maxHeight: scroll === "page" ? void 0 : maxHeight,
1955
- children: details
1956
- })]
1957
- });
1958
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [tableElement, /* @__PURE__ */ jsx(RowDetailsDrawer, {
1959
- isOpen: !!openRow,
1960
- title,
1961
- onClose: closeDetails,
1962
- children: details
1963
- })] });
1964
- }
1965
- if (enableDragDrop) return /* @__PURE__ */ jsx(Suspense, {
1966
- fallback: null,
1967
- children: /* @__PURE__ */ jsx(DndProvider, {
1968
- onDragEnd: handleDragEnd,
1969
- children: tableElement
1970
- })
1971
- });
1972
- return tableElement;
1973
- };
1974
- //#endregion
1975
- //#region src/components/table/InfiniteTable.tsx
1976
- const InfiniteTable = (t0) => {
1977
- const $ = c(35);
1978
- let fetchNextPage;
1979
- let hasNextPage;
1980
- let rest;
1981
- let t1;
1982
- if ($[0] !== t0) {
1983
- ({hasNextPage, isFetchingNextPage: t1, fetchNextPage, ...rest} = t0);
1984
- $[0] = t0;
1985
- $[1] = fetchNextPage;
1986
- $[2] = hasNextPage;
1987
- $[3] = rest;
1988
- $[4] = t1;
1989
- } else {
1990
- fetchNextPage = $[1];
1991
- hasNextPage = $[2];
1992
- rest = $[3];
1993
- t1 = $[4];
1994
- }
1995
- const isFetchingNextPage = t1 === void 0 ? false : t1;
1996
- const itemCount = rest.items.length;
1997
- const requestedAtCountRef = useRef(null);
1998
- let t2;
1999
- if ($[5] !== fetchNextPage || $[6] !== hasNextPage || $[7] !== isFetchingNextPage || $[8] !== itemCount || $[9] !== rest.isLoading) {
2000
- t2 = () => {
2001
- if (!isFetchingNextPage && hasNextPage && !rest.isLoading) {
2002
- requestedAtCountRef.current = itemCount;
2003
- fetchNextPage();
2004
- }
2005
- };
2006
- $[5] = fetchNextPage;
2007
- $[6] = hasNextPage;
2008
- $[7] = isFetchingNextPage;
2009
- $[8] = itemCount;
2010
- $[9] = rest.isLoading;
2011
- $[10] = t2;
2012
- } else t2 = $[10];
2013
- const handleLoadMore = t2;
2014
- let t3;
2015
- if ($[11] !== handleLoadMore) {
2016
- t3 = {
2017
- onIntersection: handleLoadMore,
2018
- rootMargin: "100px"
2019
- };
2020
- $[11] = handleLoadMore;
2021
- $[12] = t3;
2022
- } else t3 = $[12];
2023
- const { ref, getIsIntersecting } = useIntersectionObserver(t3);
2024
- const handleLoadMoreRef = useRef(handleLoadMore);
2025
- let t4;
2026
- let t5;
2027
- if ($[13] !== handleLoadMore) {
2028
- t4 = () => {
2029
- handleLoadMoreRef.current = handleLoadMore;
2030
- };
2031
- t5 = [handleLoadMore];
2032
- $[13] = handleLoadMore;
2033
- $[14] = t4;
2034
- $[15] = t5;
2035
- } else {
2036
- t4 = $[14];
2037
- t5 = $[15];
2038
- }
2039
- useEffect(t4, t5);
2040
- let t6;
2041
- if ($[16] !== getIsIntersecting || $[17] !== itemCount) {
2042
- t6 = () => {
2043
- if (getIsIntersecting() && requestedAtCountRef.current !== itemCount) handleLoadMoreRef.current();
2044
- };
2045
- $[16] = getIsIntersecting;
2046
- $[17] = itemCount;
2047
- $[18] = t6;
2048
- } else t6 = $[18];
2049
- let t7;
2050
- if ($[19] !== getIsIntersecting || $[20] !== hasNextPage || $[21] !== isFetchingNextPage || $[22] !== itemCount || $[23] !== rest.isLoading) {
2051
- t7 = [
2052
- getIsIntersecting,
2053
- itemCount,
2054
- hasNextPage,
2055
- isFetchingNextPage,
2056
- rest.isLoading
2057
- ];
2058
- $[19] = getIsIntersecting;
2059
- $[20] = hasNextPage;
2060
- $[21] = isFetchingNextPage;
2061
- $[22] = itemCount;
2062
- $[23] = rest.isLoading;
2063
- $[24] = t7;
2064
- } else t7 = $[24];
2065
- useEffect(t6, t7);
2066
- let t8;
2067
- if ($[25] !== rest) {
2068
- t8 = /* @__PURE__ */ jsx(Table, { ...rest });
2069
- $[25] = rest;
2070
- $[26] = t8;
2071
- } else t8 = $[26];
2072
- let t9;
2073
- if ($[27] !== hasNextPage || $[28] !== isFetchingNextPage || $[29] !== ref || $[30] !== rest.isLoading) {
2074
- t9 = (hasNextPage || isFetchingNextPage) && !rest.isLoading && /* @__PURE__ */ jsx("div", {
2075
- ref,
2076
- className: "flex justify-center py-4",
2077
- children: /* @__PURE__ */ jsx(Spinner, {})
2078
- });
2079
- $[27] = hasNextPage;
2080
- $[28] = isFetchingNextPage;
2081
- $[29] = ref;
2082
- $[30] = rest.isLoading;
2083
- $[31] = t9;
2084
- } else t9 = $[31];
2085
- let t10;
2086
- if ($[32] !== t8 || $[33] !== t9) {
2087
- t10 = /* @__PURE__ */ jsxs("div", {
2088
- className: "flex flex-col",
2089
- children: [t8, t9]
2090
- });
2091
- $[32] = t8;
2092
- $[33] = t9;
2093
- $[34] = t10;
2094
- } else t10 = $[34];
2095
- return t10;
2096
- };
2097
- //#endregion
2098
- //#region src/hooks/useSorting.ts
2099
- const parseOrder = (order) => order.split(",").map((item) => {
2100
- const field = item.trim();
2101
- if (field.startsWith("-")) return {
2102
- id: field.slice(1),
2103
- desc: true
2104
- };
2105
- if (field.startsWith("+")) return {
2106
- id: field.slice(1),
2107
- desc: false
2108
- };
2109
- return {
2110
- id: field,
2111
- desc: false
2112
- };
2113
- }).filter(({ id }) => id !== "");
2114
- const serializeOrder = (sorting) => sorting.map((field) => `${field.desc ? "-" : "+"}${field.id}`).join(",");
2115
- const fromUrl = (urlOrder, defaultSorting) => {
2116
- const urlSorting = parseOrder(urlOrder);
2117
- return urlSorting.length > 0 ? urlSorting : defaultSorting ?? [];
2118
- };
2119
- /**
2120
- * Table sorting state kept in the URL query (`order`). The table only shows the sort: pass `order`
2121
- * (`"-createdAt,+name"`) to the list request so the server sorts the rows. Needs `UIRouter.UIRouterProvider` from
2122
- * `@povio/ui/ui-router` above it, which connects the app router.
2123
- *
2124
- * @example
2125
- * const { sorting, setSorting, order } = useSorting({ defaultSorting: [{ id: "createdAt", desc: true }] });
2126
- * const { data } = useOrders({ order });
2127
- * <Table items={data} columns={columns} sorting={sorting} onSortingChange={setSorting} />
2128
- */
2129
- function useSorting({ defaultSorting, prefix = "" } = {}) {
2130
- const { searchParams, updateSearch } = UIRouter.useUIRouter();
2131
- const orderKey = prefix ? `order-${prefix}` : "order";
2132
- const urlOrder = searchParams.get(orderKey) ?? "";
2133
- const defaultSortingRef = useRef(defaultSorting);
2134
- const writtenOrderRef = useRef(null);
2135
- const [sorting, setSorting] = useState(() => fromUrl(urlOrder, defaultSorting));
2136
- const order = useMemo(() => serializeOrder(sorting), [sorting]);
2137
- useEffect(() => {
2138
- defaultSortingRef.current = defaultSorting;
2139
- });
2140
- useEffect(() => {
2141
- if (urlOrder === writtenOrderRef.current) return;
2142
- const next = fromUrl(urlOrder, defaultSortingRef.current);
2143
- setSorting((current) => serializeOrder(current) === serializeOrder(next) ? current : next);
2144
- }, [urlOrder]);
2145
- useEffect(() => {
2146
- writtenOrderRef.current = order;
2147
- updateSearch((search) => {
2148
- const current_0 = search[orderKey];
2149
- if ((typeof current_0 === "string" || typeof current_0 === "number" ? `${current_0}` : "") === order) return search;
2150
- const { [orderKey]: _previous, ...rest } = search;
2151
- return order ? {
2152
- ...rest,
2153
- [orderKey]: order
2154
- } : rest;
2155
- });
2156
- }, [order]);
2157
- return {
2158
- sorting,
2159
- setSorting,
2160
- order
2161
- };
2162
- }
2163
- //#endregion
2164
- //#region src/hooks/useTableColumnConfig.ts
2165
- const getColumnKey = (column) => column.id ?? column.accessorKey;
2166
- function sortByKeyOrder(data, orderedKeys = []) {
2167
- const rank = (column) => {
2168
- const index = orderedKeys.indexOf(getColumnKey(column));
2169
- return index === -1 ? orderedKeys.length : index;
2170
- };
2171
- return [...data].sort((a, b) => rank(a) - rank(b));
2172
- }
2173
- /**
2174
- * State for a user-configurable column set: which columns show and in what order.
2175
- * Pass `columns` to the table (already filtered and ordered) and the rest to `ColumnConfigModal`. Columns with
2176
- * `enableHiding: false` (row actions, for example) always show and are not listed in the modal.
2177
- *
2178
- * @example
2179
- * const columnConfig = useTableColumnConfig(columns);
2180
- * <Table items={items} columns={columnConfig.columns} />
2181
- * <ColumnConfigModal trigger={<Button>Columns</Button>} {...columnConfig} onReset={columnConfig.resetColumns} />
2182
- */
2183
- function useTableColumnConfig(defaultColumns, t0) {
2184
- const $ = c(36);
2185
- let t1;
2186
- if ($[0] !== t0) {
2187
- t1 = t0 === void 0 ? {} : t0;
2188
- $[0] = t0;
2189
- $[1] = t1;
2190
- } else t1 = $[1];
2191
- const options = t1;
2192
- let t2;
2193
- if ($[2] !== defaultColumns) {
2194
- t2 = () => defaultColumns.reduce(_temp, {});
2195
- $[2] = defaultColumns;
2196
- $[3] = t2;
2197
- } else t2 = $[3];
2198
- const [internalVisibleColumns, setInternalVisibleColumns] = useState(t2);
2199
- let t3;
2200
- if ($[4] !== defaultColumns) {
2201
- t3 = () => defaultColumns.map(_temp2);
2202
- $[4] = defaultColumns;
2203
- $[5] = t3;
2204
- } else t3 = $[5];
2205
- const [internalColumnOrder, setInternalColumnOrder] = useState(t3);
2206
- let t4;
2207
- let t5;
2208
- if ($[6] !== options.visibleColumns) {
2209
- t4 = () => {
2210
- if (options.visibleColumns) setInternalVisibleColumns(options.visibleColumns);
2211
- };
2212
- t5 = [options.visibleColumns];
2213
- $[6] = options.visibleColumns;
2214
- $[7] = t4;
2215
- $[8] = t5;
2216
- } else {
2217
- t4 = $[7];
2218
- t5 = $[8];
2219
- }
2220
- useEffect(t4, t5);
2221
- let t6;
2222
- let t7;
2223
- if ($[9] !== options.columnOrder) {
2224
- t6 = () => {
2225
- if (options.columnOrder) setInternalColumnOrder(options.columnOrder);
2226
- };
2227
- t7 = [options.columnOrder];
2228
- $[9] = options.columnOrder;
2229
- $[10] = t6;
2230
- $[11] = t7;
2231
- } else {
2232
- t6 = $[10];
2233
- t7 = $[11];
2234
- }
2235
- useEffect(t6, t7);
2236
- let t8;
2237
- if ($[12] !== options) {
2238
- t8 = (value) => {
2239
- setInternalVisibleColumns(value);
2240
- options?.onVisibilityChange?.(value);
2241
- };
2242
- $[12] = options;
2243
- $[13] = t8;
2244
- } else t8 = $[13];
2245
- const handleVisibilityChange = t8;
2246
- let t9;
2247
- if ($[14] !== options) {
2248
- t9 = (value_0) => {
2249
- setInternalColumnOrder(value_0);
2250
- options?.onOrderChange?.(value_0);
2251
- };
2252
- $[14] = options;
2253
- $[15] = t9;
2254
- } else t9 = $[15];
2255
- const handleOrderChange = t9;
2256
- let t10;
2257
- if ($[16] !== defaultColumns || $[17] !== handleOrderChange || $[18] !== handleVisibilityChange) {
2258
- t10 = () => {
2259
- handleVisibilityChange(Object.fromEntries(defaultColumns.map(_temp3)));
2260
- handleOrderChange(defaultColumns.map(_temp4));
2261
- };
2262
- $[16] = defaultColumns;
2263
- $[17] = handleOrderChange;
2264
- $[18] = handleVisibilityChange;
2265
- $[19] = t10;
2266
- } else t10 = $[19];
2267
- const resetColumns = t10;
2268
- let t11;
2269
- if ($[20] !== defaultColumns || $[21] !== internalColumnOrder) {
2270
- t11 = sortByKeyOrder(defaultColumns, internalColumnOrder);
2271
- $[20] = defaultColumns;
2272
- $[21] = internalColumnOrder;
2273
- $[22] = t11;
2274
- } else t11 = $[22];
2275
- const configColumns = t11;
2276
- let t12;
2277
- if ($[23] !== configColumns || $[24] !== internalVisibleColumns) {
2278
- let t13;
2279
- if ($[26] !== internalVisibleColumns) {
2280
- t13 = (col_3) => col_3.enableHiding === false || (internalVisibleColumns?.[getColumnKey(col_3)] ?? true);
2281
- $[26] = internalVisibleColumns;
2282
- $[27] = t13;
2283
- } else t13 = $[27];
2284
- t12 = configColumns.filter(t13);
2285
- $[23] = configColumns;
2286
- $[24] = internalVisibleColumns;
2287
- $[25] = t12;
2288
- } else t12 = $[25];
2289
- const columns = t12;
2290
- let t13;
2291
- if ($[28] !== columns || $[29] !== configColumns || $[30] !== handleOrderChange || $[31] !== handleVisibilityChange || $[32] !== internalColumnOrder || $[33] !== internalVisibleColumns || $[34] !== resetColumns) {
2292
- t13 = {
2293
- configColumns,
2294
- columns,
2295
- visibleColumns: internalVisibleColumns,
2296
- columnOrder: internalColumnOrder,
2297
- onVisibilityChange: handleVisibilityChange,
2298
- onOrderChange: handleOrderChange,
2299
- resetColumns
2300
- };
2301
- $[28] = columns;
2302
- $[29] = configColumns;
2303
- $[30] = handleOrderChange;
2304
- $[31] = handleVisibilityChange;
2305
- $[32] = internalColumnOrder;
2306
- $[33] = internalVisibleColumns;
2307
- $[34] = resetColumns;
2308
- $[35] = t13;
2309
- } else t13 = $[35];
2310
- return t13;
2311
- }
2312
- function _temp4(col_2) {
2313
- return col_2.id ?? col_2.accessorKey;
2314
- }
2315
- function _temp3(col_1) {
2316
- return [col_1.id ?? col_1.accessorKey, true];
2317
- }
2318
- function _temp2(col_0) {
2319
- return col_0.id ?? col_0.accessorKey;
2320
- }
2321
- function _temp(acc, col) {
2322
- const key = col.id ?? col.accessorKey;
2323
- acc[key] = true;
2324
- return acc;
2325
- }
2326
- //#endregion
2327
- export { useTableNav as a, CellText as c, Table as i, useSorting as n, HeaderText as o, InfiniteTable as r, ColumnConfigModal as s, useTableColumnConfig as t };