@economic/taco 2.45.0-alpha.2 → 2.45.0-alpha.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (316) hide show
  1. package/dist/charts/components/Area/AreaChart.d.ts +19 -0
  2. package/dist/charts/components/Bar/BarChart.d.ts +20 -0
  3. package/dist/charts/components/Donut/ActiveShape.d.ts +8 -0
  4. package/dist/charts/components/Donut/CenteredLabel.d.ts +11 -0
  5. package/dist/charts/components/Donut/DonutChart.d.ts +21 -0
  6. package/dist/charts/components/Donut/Legend.d.ts +13 -0
  7. package/dist/charts/components/Donut/util.d.ts +2 -0
  8. package/dist/charts/components/Legend.d.ts +16 -0
  9. package/dist/charts/components/Line/LineChart.d.ts +18 -0
  10. package/dist/charts/components/ResponsiveContainer.d.ts +5 -0
  11. package/dist/charts/components/Tooltip.d.ts +10 -0
  12. package/dist/charts/components/types.d.ts +5 -0
  13. package/dist/charts/utils/color.d.ts +3 -0
  14. package/dist/charts/utils/common.d.ts +37 -0
  15. package/dist/components/Alert/Alert.d.ts +1 -1
  16. package/dist/components/Combobox/Combobox.d.ts +1 -1
  17. package/dist/components/Hanger/Hanger.d.ts +1 -0
  18. package/dist/components/Icon/components/Autopay.d.ts +3 -0
  19. package/dist/components/Icon/components/AutopayPaused.d.ts +3 -0
  20. package/dist/components/Icon/components/Experiment.d.ts +3 -0
  21. package/dist/components/Icon/components/Person.d.ts +3 -0
  22. package/dist/components/Icon/components/PersonSolid.d.ts +3 -0
  23. package/dist/components/Icon/components/Wallet.d.ts +3 -0
  24. package/dist/components/Icon/components/index.d.ts +1 -1
  25. package/dist/components/Input/Input.d.ts +1 -1
  26. package/dist/components/Listbox/util.d.ts +1 -1
  27. package/dist/components/Menu/components/Content.d.ts +1 -1
  28. package/dist/components/Menu/components/Item.d.ts +1 -1
  29. package/dist/components/Menu/components/Link.d.ts +1 -1
  30. package/dist/components/Menu/components/SubMenu.d.ts +1 -1
  31. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  32. package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
  33. package/dist/components/Report/Report.d.ts +4 -2
  34. package/dist/components/SearchInput2/SearchInput2.d.ts +2 -0
  35. package/dist/components/Select/Select.d.ts +5 -19
  36. package/dist/components/Select2/components/Option.d.ts +4 -4
  37. package/dist/components/Select2/components/Search.d.ts +1 -1
  38. package/dist/components/Table3/Table3.d.ts +4 -5
  39. package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +2 -2
  40. package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +1 -3
  41. package/dist/components/Table3/components/Row/Editing/TemporaryRow.d.ts +1 -0
  42. package/dist/components/Table3/features/useEditingState.d.ts +23 -18
  43. package/dist/components/Table3/features/useTableEditing.d.ts +24 -19
  44. package/dist/components/Table3/types.d.ts +2 -0
  45. package/dist/components/Table3/util/editing.d.ts +3 -0
  46. package/dist/components/Tag/Tag.d.ts +1 -1
  47. package/dist/esm/index.css +74 -12
  48. package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js +67 -0
  49. package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js.map +1 -0
  50. package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js +120 -0
  51. package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js.map +1 -0
  52. package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js +47 -0
  53. package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js.map +1 -0
  54. package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js +27 -0
  55. package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js.map +1 -0
  56. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js +170 -0
  57. package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -0
  58. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +165 -0
  59. package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -0
  60. package/dist/esm/packages/taco/src/charts/components/Donut/util.js +5 -0
  61. package/dist/esm/packages/taco/src/charts/components/Donut/util.js.map +1 -0
  62. package/dist/esm/packages/taco/src/charts/components/Legend.js +146 -0
  63. package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -0
  64. package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js +65 -0
  65. package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js.map +1 -0
  66. package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js +10 -0
  67. package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js.map +1 -0
  68. package/dist/esm/packages/taco/src/charts/components/Tooltip.js +44 -0
  69. package/dist/esm/packages/taco/src/charts/components/Tooltip.js.map +1 -0
  70. package/dist/esm/packages/taco/src/charts/utils/color.js +24 -0
  71. package/dist/esm/packages/taco/src/charts/utils/color.js.map +1 -0
  72. package/dist/esm/packages/taco/src/charts/utils/common.js +34 -0
  73. package/dist/esm/packages/taco/src/charts/utils/common.js.map +1 -0
  74. package/dist/esm/packages/taco/src/components/Accordion/Accordion.js +6 -14
  75. package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
  76. package/dist/esm/packages/taco/src/components/Alert/Alert.js +2 -0
  77. package/dist/esm/packages/taco/src/components/Alert/Alert.js.map +1 -1
  78. package/dist/esm/packages/taco/src/components/Badge/Badge.js +9 -6
  79. package/dist/esm/packages/taco/src/components/Badge/Badge.js.map +1 -1
  80. package/dist/esm/packages/taco/src/components/Banner/util.js +5 -0
  81. package/dist/esm/packages/taco/src/components/Banner/util.js.map +1 -1
  82. package/dist/esm/packages/taco/src/components/Button/Button.js +2 -1
  83. package/dist/esm/packages/taco/src/components/Button/Button.js.map +1 -1
  84. package/dist/esm/packages/taco/src/components/Button/util.js +1 -1
  85. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  86. package/dist/esm/packages/taco/src/components/Card/Card.js +2 -2
  87. package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
  88. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +3 -2
  89. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  90. package/dist/esm/packages/taco/src/components/Combobox/Combobox.js.map +1 -1
  91. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js +18 -17
  92. package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
  93. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +13 -0
  94. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
  95. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +10 -1
  96. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  97. package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
  98. package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +4 -2
  99. package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
  100. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +2 -2
  101. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -1
  102. package/dist/esm/packages/taco/src/components/Hanger/Hanger.js +4 -2
  103. package/dist/esm/packages/taco/src/components/Hanger/Hanger.js.map +1 -1
  104. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +2 -4
  105. package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
  106. package/dist/esm/packages/taco/src/components/Icon/components/Autopay.js +19 -0
  107. package/dist/esm/packages/taco/src/components/Icon/components/Autopay.js.map +1 -0
  108. package/dist/esm/packages/taco/src/components/Icon/components/AutopayPaused.js +19 -0
  109. package/dist/esm/packages/taco/src/components/Icon/components/AutopayPaused.js.map +1 -0
  110. package/dist/esm/packages/taco/src/components/Icon/components/Experiment.js +20 -0
  111. package/dist/esm/packages/taco/src/components/Icon/components/Experiment.js.map +1 -0
  112. package/dist/esm/packages/taco/src/components/Icon/components/Person.js +19 -0
  113. package/dist/esm/packages/taco/src/components/Icon/components/Person.js.map +1 -0
  114. package/dist/esm/packages/taco/src/components/Icon/components/PersonSolid.js +19 -0
  115. package/dist/esm/packages/taco/src/components/Icon/components/PersonSolid.js.map +1 -0
  116. package/dist/esm/packages/taco/src/components/Icon/components/Wallet.js +19 -0
  117. package/dist/esm/packages/taco/src/components/Icon/components/Wallet.js.map +1 -0
  118. package/dist/esm/packages/taco/src/components/Icon/components/index.js +12 -0
  119. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  120. package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
  121. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  122. package/dist/esm/packages/taco/src/components/Listbox/util.js +1 -7
  123. package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
  124. package/dist/esm/packages/taco/src/components/Menu/components/Content.js +5 -0
  125. package/dist/esm/packages/taco/src/components/Menu/components/Content.js.map +1 -1
  126. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
  127. package/dist/esm/packages/taco/src/components/Report/Report.js +2 -3
  128. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
  129. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +6 -3
  130. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  131. package/dist/esm/packages/taco/src/components/Select/Select.js +0 -9
  132. package/dist/esm/packages/taco/src/components/Select/Select.js.map +1 -1
  133. package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
  134. package/dist/esm/packages/taco/src/components/Select2/components/Create.js +10 -11
  135. package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
  136. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +7 -5
  137. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  138. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +56 -19
  139. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  140. package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js +1 -1
  141. package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js.map +1 -1
  142. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +1 -1
  143. package/dist/esm/packages/taco/src/components/Table3/Table3.js +23 -12
  144. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  145. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +25 -9
  146. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
  147. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +4 -3
  148. package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
  149. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +18 -10
  150. package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
  151. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js +0 -1
  152. package/dist/esm/packages/taco/src/components/Table3/components/Editing/DiscardChangesConfirmationDialog.js.map +1 -1
  153. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +6 -37
  154. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
  155. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +7 -6
  156. package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
  157. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +81 -81
  158. package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
  159. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +70 -14
  160. package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
  161. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +16 -22
  162. package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
  163. package/dist/esm/packages/taco/src/components/Table3/useTable3.js +16 -5
  164. package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
  165. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +9 -1
  166. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  167. package/dist/esm/packages/taco/src/components/Tag/Tag.js +6 -4
  168. package/dist/esm/packages/taco/src/components/Tag/Tag.js.map +1 -1
  169. package/dist/esm/packages/taco/src/components/Tooltip/Tooltip.js +2 -2
  170. package/dist/esm/packages/taco/src/components/Tooltip/Tooltip.js.map +1 -1
  171. package/dist/esm/packages/taco/src/hooks/useLazyEffect.js +1 -1
  172. package/dist/esm/packages/taco/src/hooks/useLazyEffect.js.map +1 -1
  173. package/dist/esm/packages/taco/src/index.js +6 -1
  174. package/dist/esm/packages/taco/src/index.js.map +1 -1
  175. package/dist/esm/packages/taco/src/primitives/BubbleSelect.js +1 -1
  176. package/dist/esm/packages/taco/src/primitives/BubbleSelect.js.map +1 -1
  177. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +5 -3
  178. package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
  179. package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
  180. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +7 -5
  181. package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
  182. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +15 -2
  183. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
  184. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +23 -16
  185. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
  186. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +6 -4
  187. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
  188. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
  189. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
  190. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +11 -0
  191. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
  192. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +10 -7
  193. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
  194. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js +7 -2
  195. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Footer.js.map +1 -1
  196. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Summary.js +7 -6
  197. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Summary.js.map +1 -1
  198. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js +3 -1
  199. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Header/components/Menu.js.map +1 -1
  200. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +5 -2
  201. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
  202. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +24 -22
  203. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
  204. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +44 -5
  205. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
  206. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +3 -2
  207. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
  208. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/FilterContext.js +6 -0
  209. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/FilterContext.js.map +1 -0
  210. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +5 -3
  211. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -1
  212. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.js +0 -2
  213. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.js.map +1 -1
  214. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js +2 -1
  215. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -1
  216. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js +4 -0
  217. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterComparator.js.map +1 -1
  218. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js +3 -1
  219. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
  220. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +3 -1
  221. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
  222. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js +26 -4
  223. package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js.map +1 -1
  224. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js +2 -2
  225. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js.map +1 -1
  226. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +43 -12
  227. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
  228. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js +2 -2
  229. package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleGrid.js.map +1 -1
  230. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +1 -1
  231. package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
  232. package/dist/esm/packages/taco/src/primitives/Table/types.js +3 -7
  233. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  234. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +13 -12
  235. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
  236. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js +224 -0
  237. package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js.map +1 -0
  238. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActions.js +11 -0
  239. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActions.js.map +1 -1
  240. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +1 -1
  241. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
  242. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowExpansion.js +2 -1
  243. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowExpansion.js.map +1 -1
  244. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js +3 -2
  245. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
  246. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js +18 -8
  247. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
  248. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableDataListener.js +3 -4
  249. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableDataListener.js.map +1 -1
  250. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js +3 -1
  251. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js.map +1 -1
  252. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js +2 -1
  253. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js.map +1 -1
  254. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js +4 -4
  255. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js.map +1 -1
  256. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +14 -13
  257. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
  258. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js +7 -3
  259. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js.map +1 -1
  260. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +5 -5
  261. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
  262. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js +4 -1
  263. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js.map +1 -1
  264. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js +6 -2
  265. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js.map +1 -1
  266. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/filtering.js +6 -0
  267. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/filtering.js.map +1 -1
  268. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js +7 -1
  269. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/presets.js.map +1 -1
  270. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js +7 -1
  271. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
  272. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +16 -4
  273. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
  274. package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
  275. package/dist/esm/packages/taco/src/types.js.map +1 -1
  276. package/dist/esm/packages/taco/src/utils/dom.js +12 -1
  277. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  278. package/dist/esm/packages/taco/src/utils/tailwind.js +2 -0
  279. package/dist/esm/packages/taco/src/utils/tailwind.js.map +1 -1
  280. package/dist/esm/packages/taco/tailwind.colors.js +122 -0
  281. package/dist/esm/packages/taco/tailwind.colors.js.map +1 -0
  282. package/dist/hooks/useLazyDebouncedEffect.d.ts +2 -0
  283. package/dist/index.css +74 -12
  284. package/dist/index.d.ts +6 -0
  285. package/dist/primitives/Table/Core/Table.d.ts +1 -0
  286. package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
  287. package/dist/primitives/Table/Core/components/Body/util.d.ts +4 -4
  288. package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
  289. package/dist/primitives/Table/Core/components/Row/Row.d.ts +2 -0
  290. package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -1
  291. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/FilterContext.d.ts +3 -0
  292. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/Filter.d.ts +0 -1
  293. package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +0 -3
  294. package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
  295. package/dist/primitives/Table/Core/types.d.ts +1 -0
  296. package/dist/primitives/Table/types.d.ts +18 -14
  297. package/dist/primitives/Table/useTableDataLoader.d.ts +2 -2
  298. package/dist/primitives/Table/useTableDataLoader2.d.ts +23 -0
  299. package/dist/primitives/Table/useTableManager/features/useTableRowActions.d.ts +2 -0
  300. package/dist/primitives/Table/useTableManager/features/useTableRowExpansion.d.ts +2 -1
  301. package/dist/primitives/Table/useTableManager/features/useTableSearch.d.ts +4 -2
  302. package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +6 -3
  303. package/dist/primitives/Table/useTableManager/listeners/useTableDataListener.d.ts +1 -1
  304. package/dist/primitives/Table/useTableManager/listeners/useTableSearchListener.d.ts +1 -2
  305. package/dist/primitives/Table/useTableManager/util/columns.d.ts +2 -1
  306. package/dist/primitives/Table/useTableManager/util/dataTypes.d.ts +1 -1
  307. package/dist/taco.cjs.development.js +1988 -512
  308. package/dist/taco.cjs.development.js.map +1 -1
  309. package/dist/taco.cjs.production.min.js +1 -1
  310. package/dist/taco.cjs.production.min.js.map +1 -1
  311. package/dist/types.d.ts +1 -1
  312. package/dist/utils/dom.d.ts +2 -2
  313. package/package.json +14 -13
  314. package/tailwind.colors.js +121 -0
  315. package/tailwind.config.js +3 -2
  316. package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
@@ -1,7 +1,7 @@
1
1
  import React__default from 'react';
2
2
  import { useLocalization } from '../../../../../../../components/Provider/Localization.js';
3
3
  import { Switch } from '../../../../../../../components/Switch/Switch.js';
4
- import { TableServerLoadAllState } from '../../../../../types.js';
4
+ import { getHiddenColumns } from '../../../../../useTableManager/util/columns.js';
5
5
  import { SearchInput2 } from '../../../../../../../components/SearchInput2/SearchInput2.js';
6
6
 
7
7
  function Search(props) {
@@ -20,6 +20,7 @@ function Search(props) {
20
20
  const scrollTo = rowIndex => scrollToIndex(rowIndex, {
21
21
  align: 'center'
22
22
  });
23
+ const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
23
24
  React__default.useEffect(() => {
24
25
  if (tableMeta.search.highlightedColumnIndexes.length) {
25
26
  scrollTo(tableMeta.search.highlightedColumnIndexes[0][0]);
@@ -28,9 +29,11 @@ function Search(props) {
28
29
  const handleFocus = function () {
29
30
  try {
30
31
  const _temp = function () {
31
- if (tableMeta.server.loadAllIfNeeded) {
32
+ if (tableMeta.server.loadAllIfNeeded && !tableMeta.server._experimentalDataLoader2) {
32
33
  // don't pass the search query because we need all data - not filtered data
33
- return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
34
+ return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, hiddenColumns,
35
+ // the old data loader doesn't have server side search
36
+ undefined)).then(function () {});
34
37
  }
35
38
  }();
36
39
  // load all data if that is possible
@@ -39,8 +42,20 @@ function Search(props) {
39
42
  return Promise.reject(e);
40
43
  }
41
44
  };
45
+ const [loading, setLoading] = React__default.useState(false);
46
+ const searchTimeoutRef = React__default.useRef();
42
47
  const handleChange = query => {
43
48
  table.setGlobalFilter(String(query !== null && query !== void 0 ? query : ''));
49
+ if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {
50
+ clearTimeout(searchTimeoutRef.current);
51
+ searchTimeoutRef.current = setTimeout(() => {
52
+ var _tableMeta$search$han, _tableMeta$search;
53
+ setLoading(true);
54
+ (_tableMeta$search$han = (_tableMeta$search = tableMeta.search).handleSearch) === null || _tableMeta$search$han === void 0 ? void 0 : _tableMeta$search$han.call(_tableMeta$search, query, hiddenColumns).then(() => {
55
+ setLoading(false);
56
+ });
57
+ }, 150);
58
+ }
44
59
  };
45
60
  const handleToggleExcludeUnmatchedResults = enabled => {
46
61
  tableMeta.search.setEnableGlobalFilter(enabled, table);
@@ -48,6 +63,12 @@ function Search(props) {
48
63
  var _ref$current;
49
64
  return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
50
65
  });
66
+ if (tableMeta.search.handleSearch) {
67
+ setLoading(true);
68
+ tableMeta.search.handleSearch(enabled ? query : undefined, hiddenColumns).then(() => {
69
+ setLoading(false);
70
+ });
71
+ }
51
72
  };
52
73
  const handleNextResult = () => {
53
74
  if (!tableMeta.search.highlightedColumnIndexes.length) {
@@ -91,7 +112,7 @@ function Search(props) {
91
112
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SearchInput2, {
92
113
  findCurrent: tableMeta.search.currentHighlightColumnIndex !== undefined ? tableMeta.search.currentHighlightColumnIndex + 1 : null,
93
114
  findTotal: (_tableMeta$search$hig = (_tableMeta$search$hig2 = tableMeta.search.highlightedColumnIndexes) === null || _tableMeta$search$hig2 === void 0 ? void 0 : _tableMeta$search$hig2.length) !== null && _tableMeta$search$hig !== void 0 ? _tableMeta$search$hig : null,
94
- loading: tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading,
115
+ loading: tableMeta.server._experimentalDataLoader2 ? loading : tableMeta.server.loading,
95
116
  name: "table-search",
96
117
  onClickFindPrevious: handlePreviousResult,
97
118
  onClickFindNext: handleNextResult,
@@ -106,6 +127,7 @@ function Search(props) {
106
127
  meta: true,
107
128
  shift: false
108
129
  },
130
+ showTotal: !tableMeta.server._experimentalDataLoader2,
109
131
  value: query
110
132
  }));
111
133
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Search.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Search/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { SearchInput2 } from '../../../../../../../components/SearchInput2/SearchInput2';\nimport { Switch } from '../../../../../../../components/Switch/Switch';\nimport { TableRef, TableServerLoadAllState } from '../../../../../types';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: ReactTable<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table, tableRef } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const query = table.getState().globalFilter;\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n\n React.useEffect(() => {\n if (tableMeta.search.highlightedColumnIndexes.length) {\n scrollTo(tableMeta.search.highlightedColumnIndexes[0][0]);\n }\n }, [tableMeta.search.highlightedColumnIndexes.length]);\n\n const handleFocus = async () => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n };\n\n const handleChange = (query: any) => {\n table.setGlobalFilter(String(query ?? ''));\n };\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n tableMeta.search.setEnableGlobalFilter(enabled, table);\n requestAnimationFrame(() => ref.current?.focus());\n };\n\n const handleNextResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined ||\n tableMeta.search.currentHighlightColumnIndex === tableMeta.search.highlightedColumnIndexes.length - 1\n ? 0\n : tableMeta.search.currentHighlightColumnIndex + 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const handlePreviousResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined\n ? 0\n : tableMeta.search.currentHighlightColumnIndex === 0\n ? tableMeta.search.highlightedColumnIndexes.length - 1\n : tableMeta.search.currentHighlightColumnIndex - 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const settings = (\n <Switch\n label={texts.table.search.excludeUnmatchedResults}\n checked={!!table.options.enableGlobalFilter}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && tableMeta.search.currentHighlightColumnIndex !== undefined) {\n const [rowIndex, cellIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (rowIndex !== undefined && cellIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n\n requestAnimationFrame(() => {\n const cell = tableRef.current?.querySelector(\n `tbody > tr[data-row-index=\"${rowIndex}\"] > td[data-cell-index=\"${cellIndex}\"]`\n );\n\n if (cell) {\n (cell as HTMLElement).focus?.();\n }\n });\n }\n }\n };\n\n return (\n <>\n <SearchInput2\n findCurrent={\n tableMeta.search.currentHighlightColumnIndex !== undefined\n ? tableMeta.search.currentHighlightColumnIndex + 1\n : null\n }\n findTotal={tableMeta.search.highlightedColumnIndexes?.length ?? null}\n loading={tableMeta.server.loadAllStatus === TableServerLoadAllState.Loading}\n name=\"table-search\"\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n placeholder={texts.table.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n value={query}\n />\n </>\n );\n}\n"],"names":["Search","props","scrollToIndex","table","tableRef","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","query","getState","globalFilter","scrollTo","rowIndex","align","useEffect","search","highlightedColumnIndexes","length","handleFocus","server","loadAllIfNeeded","Promise","resolve","sorting","columnFilters","then","_temp","e","reject","handleChange","setGlobalFilter","String","handleToggleExcludeUnmatchedResults","enabled","setEnableGlobalFilter","requestAnimationFrame","_ref$current","current","focus","handleNextResult","nextIndex","currentHighlightColumnIndex","undefined","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","excludeUnmatchedResults","checked","enableGlobalFilter","onChange","handleKeyDown","event","key","cellIndex","rowActive","setRowActiveIndex","cell","_tableRef$current","querySelector","_cell$focus","call","SearchInput2","findCurrent","findTotal","_tableMeta$search$hig","_tableMeta$search$hig2","loading","loadAllStatus","TableServerLoadAllState","Loading","name","onClickFindPrevious","onClickFindNext","onFocus","onKeyDown","placeholder","settingsContent","shortcut","shift","value"],"mappings":";;;;;;SAagBA,MAAMA,CAAkBC,KAAyB;;EAC7D,MAAM;IAAEC,aAAa;IAAEC,KAAK;IAAEC;GAAU,GAAGH,KAAK;EAChD,MAAM;IAAEI;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAChD,MAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACC,IAA6B;EAC7D,MAAMC,KAAK,GAAGV,KAAK,CAACW,QAAQ,EAAE,CAACC,YAAY;EAC3C,MAAMC,QAAQ,GAAIC,QAAgB,IAAKf,aAAa,CAACe,QAAQ,EAAE;IAAEC,KAAK,EAAE;GAAU,CAAC;EAEnFV,cAAK,CAACW,SAAS,CAAC;IACZ,IAAIT,SAAS,CAACU,MAAM,CAACC,wBAAwB,CAACC,MAAM,EAAE;MAClDN,QAAQ,CAACN,SAAS,CAACU,MAAM,CAACC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;GAEhE,EAAE,CAACX,SAAS,CAACU,MAAM,CAACC,wBAAwB,CAACC,MAAM,CAAC,CAAC;EAEtD,MAAMC,WAAW;IAAA;;YAETb,SAAS,CAACc,MAAM,CAACC,eAAe;;UAChC,OAAAC,OAAA,CAAAC,OAAA,CACMjB,SAAS,CAACc,MAAM,CAACC,eAAe,CAACtB,KAAK,CAACW,QAAQ,EAAE,CAACc,OAAO,EAAEzB,KAA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Q,4BAA4B2C,SAAS,IAAI,CAClF;UAED,IAAIG,IAAI,EAAE;YAAA,IAAAG,WAAA;YACL,CAAAA,WAAA,GAAAH,IAAoB,CAACpB,KAAK,cAAAuB,WAAA,uBAA1BA,WAAA,CAAAC,IAAA,CAAAJ,KAA8B;;SAEtC,CAAC;;;GAGb;EAED,oBACIvD,yEACIA,6BAAC4D,YAAY;IACTC,WAAW,EACP3D,SAAS,CAACU,MAAM,CAAC0B,2BAA2B,KAAKC,SAAS,GACpDrC,SAAS,CAACU,MAAM,CAAC0B,2BAA2B,GAAG,CAAC,GAChD,IAAI;IAEdwB,SAAS,GAAAC,qBAAA,IAAAC,sBAAA,GAAE9D,SAAS,CAACU,MAAM,CAACC,wBAAwB,cAAAmD,sBAAA,uBAAzCA,sBAAA,CAA2ClD,MAAM,cAAAiD,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IACpEE,OAAO,EAAE/D,SAAS,CAACc,MAAM,CAACkD,aAAa,KAAKC,uBAAuB,CAACC,OAAO;IAC3EC,IAAI,EAAC,cAAc;IACnBC,mBAAmB,EAAE7B,oBAAoB;IACzC8B,eAAe,EAAEnC,gBAAgB;IACjCY,QAAQ,EAAEtB,YAAY;IACtB8C,OAAO,EAAEzD,WAAW;IACpB0D,SAAS,EAAExB,aAAa;IACxByB,WAAW,EAAE7E,KAAK,CAACF,KAAK,CAACiB,MAAM,CAAC8D,WAAW;IAC3CC,eAAe,EAAEjC,QAAQ;IACzB3C,GAAG,EAAEA,GAAG;IACR6E,QAAQ,EAAE;MAAEzB,GAAG,EAAE,GAAG;MAAE/C,IAAI,EAAE,IAAI;MAAEyE,KAAK,EAAE;KAAO;IAChDC,KAAK,EAAEzE;IACT,CACH;AAEX;;;;"}
1
+ {"version":3,"file":"Search.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Search/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { SearchInput2 } from '../../../../../../../components/SearchInput2/SearchInput2';\nimport { Switch } from '../../../../../../../components/Switch/Switch';\nimport { TableRef } from '../../../../../types';\nimport { getHiddenColumns } from '../../../../../useTableManager/util/columns';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: ReactTable<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table, tableRef } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const query = table.getState().globalFilter;\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);\n\n React.useEffect(() => {\n if (tableMeta.search.highlightedColumnIndexes.length) {\n scrollTo(tableMeta.search.highlightedColumnIndexes[0][0]);\n }\n }, [tableMeta.search.highlightedColumnIndexes.length]);\n\n const handleFocus = async () => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded && !tableMeta.server._experimentalDataLoader2) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(\n table.getState().sorting,\n table.getState().columnFilters,\n hiddenColumns,\n // the old data loader doesn't have server side search\n undefined\n );\n }\n };\n\n const [loading, setLoading] = React.useState(false);\n\n const searchTimeoutRef = React.useRef<NodeJS.Timeout>();\n\n const handleChange = (query: any) => {\n table.setGlobalFilter(String(query ?? ''));\n\n if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {\n clearTimeout(searchTimeoutRef.current);\n searchTimeoutRef.current = setTimeout(() => {\n setLoading(true);\n tableMeta.search.handleSearch?.(query, hiddenColumns).then(() => {\n setLoading(false);\n });\n }, 150);\n }\n };\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n tableMeta.search.setEnableGlobalFilter(enabled, table);\n requestAnimationFrame(() => ref.current?.focus());\n\n if (tableMeta.search.handleSearch) {\n setLoading(true);\n tableMeta.search.handleSearch(enabled ? query : undefined, hiddenColumns).then(() => {\n setLoading(false);\n });\n }\n };\n\n const handleNextResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined ||\n tableMeta.search.currentHighlightColumnIndex === tableMeta.search.highlightedColumnIndexes.length - 1\n ? 0\n : tableMeta.search.currentHighlightColumnIndex + 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const handlePreviousResult = () => {\n if (!tableMeta.search.highlightedColumnIndexes.length) {\n return;\n }\n\n const nextIndex =\n tableMeta.search.currentHighlightColumnIndex === undefined\n ? 0\n : tableMeta.search.currentHighlightColumnIndex === 0\n ? tableMeta.search.highlightedColumnIndexes.length - 1\n : tableMeta.search.currentHighlightColumnIndex - 1;\n\n tableMeta.search.setCurrentHighlightColumnIndex(nextIndex);\n // we scroll to the row here, the cell scrolls itself into view\n scrollTo(tableMeta.search.highlightedColumnIndexes[nextIndex][0]);\n };\n\n const settings = (\n <Switch\n label={texts.table.search.excludeUnmatchedResults}\n checked={!!table.options.enableGlobalFilter}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && tableMeta.search.currentHighlightColumnIndex !== undefined) {\n const [rowIndex, cellIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (rowIndex !== undefined && cellIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n\n requestAnimationFrame(() => {\n const cell = tableRef.current?.querySelector(\n `tbody > tr[data-row-index=\"${rowIndex}\"] > td[data-cell-index=\"${cellIndex}\"]`\n );\n\n if (cell) {\n (cell as HTMLElement).focus?.();\n }\n });\n }\n }\n };\n\n return (\n <>\n <SearchInput2\n findCurrent={\n tableMeta.search.currentHighlightColumnIndex !== undefined\n ? tableMeta.search.currentHighlightColumnIndex + 1\n : null\n }\n findTotal={tableMeta.search.highlightedColumnIndexes?.length ?? null}\n loading={tableMeta.server._experimentalDataLoader2 ? loading : tableMeta.server.loading}\n name=\"table-search\"\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n placeholder={texts.table.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n showTotal={!tableMeta.server._experimentalDataLoader2}\n value={query}\n />\n </>\n );\n}\n"],"names":["Search","props","scrollToIndex","table","tableRef","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","query","getState","globalFilter","scrollTo","rowIndex","align","hiddenColumns","getHiddenColumns","columnVisibility","useEffect","search","highlightedColumnIndexes","length","handleFocus","server","loadAllIfNeeded","_experimentalDataLoader2","Promise","resolve","sorting","columnFilters","undefined","then","_temp","e","reject","loading","setLoading","useState","searchTimeoutRef","handleChange","setGlobalFilter","String","enableGlobalFilter","handleSearch","clearTimeout","current","setTimeout","_tableMeta$search$han","_tableMeta$search","call","handleToggleExcludeUnmatchedResults","enabled","setEnableGlobalFilter","requestAnimationFrame","_ref$current","focus","handleNextResult","nextIndex","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","excludeUnmatchedResults","checked","onChange","handleKeyDown","event","key","cellIndex","rowActive","setRowActiveIndex","cell","_tableRef$current","querySelector","_cell$focus","SearchInput2","findCurrent","findTotal","_tableMeta$search$hig","_tableMeta$search$hig2","name","onClickFindPrevious","onClickFindNext","onFocus","onKeyDown","placeholder","settingsContent","shortcut","shift","showTotal","value"],"mappings":";;;;;;SAcgBA,MAAMA,CAAkBC,KAAyB;;EAC7D,MAAM;IAAEC,aAAa;IA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wBAAwB,GAAGU,OAAO,GAAG7B,SAAS,CAACiB,MAAM,CAACY,OAAO;IACvF+C,IAAI,EAAC,cAAc;IACnBC,mBAAmB,EAAEvB,oBAAoB;IACzCwB,eAAe,EAAE5B,gBAAgB;IACjCU,QAAQ,EAAE3B,YAAY;IACtB8C,OAAO,EAAE/D,WAAW;IACpBgE,SAAS,EAAEnB,aAAa;IACxBoB,WAAW,EAAEtF,KAAK,CAACF,KAAK,CAACoB,MAAM,CAACoE,WAAW;IAC3CC,eAAe,EAAE3B,QAAQ;IACzB1D,GAAG,EAAEA,GAAG;IACRsF,QAAQ,EAAE;MAAEpB,GAAG,EAAE,GAAG;MAAE7D,IAAI,EAAE,IAAI;MAAEkF,KAAK,EAAE;KAAO;IAChDC,SAAS,EAAE,CAACrF,SAAS,CAACiB,MAAM,CAACE,wBAAwB;IACrDmE,KAAK,EAAEnF;IACT,CACH;AAEX;;;;"}
@@ -10,7 +10,7 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
10
10
  if (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current) || isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current)) {
11
11
  return;
12
12
  }
13
- tableMeta.rowActive.handleKeyDown(event, rows.length, scrollToIndex);
13
+ tableMeta.rowActive.handleKeyDown(event, tableMeta.length, scrollToIndex);
14
14
  tableMeta.rowSelection.handleKeyDown(event, table);
15
15
  if (tableMeta.rowActive.rowActiveIndex !== undefined) {
16
16
  var _rows$tableMeta$rowAc;
@@ -23,7 +23,7 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
23
23
  };
24
24
  },
25
25
  // scrollToIndex function changes when row count changes, so it is important to update handlers
26
- [tableRef.current, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
26
+ [tableRef.current, tableMeta.length, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
27
27
  }
28
28
 
29
29
  export { useTableGlobalShortcuts };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableGlobalShortcuts.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableGlobalShortcuts.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableRef } from '../../types';\nimport {\n isElementInsideOrTriggeredFromContainer,\n isElementInsideOverlay,\n isElementInteractive,\n isSiblingElementInsideSameParentOverlay,\n} from '../../../../utils/dom';\n\nexport function useTableGlobalShortcuts<TType = unknown>(\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n scrollToIndex: (index: number) => void\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const trigger = event.target as HTMLElement;\n\n if (\n (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current)) ||\n (isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current))\n ) {\n return;\n }\n\n tableMeta.rowActive.handleKeyDown(event, rows.length, scrollToIndex);\n tableMeta.rowSelection.handleKeyDown(event, table);\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n tableMeta.rowClick.handleKeyDown(event, rows[tableMeta.rowActive.rowActiveIndex]?.original);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n\n // scrollToIndex function changes when row count changes, so it is important to update handlers\n [tableRef.current, tableMeta.rowActive.rowActiveIndex, scrollToIndex]\n );\n}\n"],"names":["useTableGlobalShortcuts","table","tableRef","scrollToIndex","tableMeta","options","meta","rows","getRowModel","React","useEffect","handleKeyDown","event","trigger","target","isElementInsideOverlay","isSiblingElementInsideSameParentOverlay","current","isElementInteractive","isElementInsideOrTriggeredFromContainer","rowActive","length","rowSelection","rowActiveIndex","undefined","_rows$tableMeta$rowAc","rowClick","original","document","addEventList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file":"useTableGlobalShortcuts.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableGlobalShortcuts.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableRef } from '../../types';\nimport {\n isElementInsideOrTriggeredFromContainer,\n isElementInsideOverlay,\n isElementInteractive,\n isSiblingElementInsideSameParentOverlay,\n} from '../../../../utils/dom';\n\nexport function useTableGlobalShortcuts<TType = unknown>(\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n scrollToIndex: (index: number) => void\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const trigger = event.target as HTMLElement;\n\n if (\n (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current)) ||\n (isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current))\n ) {\n return;\n }\n\n tableMeta.rowActive.handleKeyDown(event, tableMeta.length, scrollToIndex);\n tableMeta.rowSelection.handleKeyDown(event, table);\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n tableMeta.rowClick.handleKeyDown(event, rows[tableMeta.rowActive.rowActiveIndex]?.original);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n\n // scrollToIndex function changes when row count changes, so it is important to update handlers\n [tableRef.current, tableMeta.length, tableMeta.rowActive.rowActiveIndex, scrollToIndex]\n );\n}\n"],"names":["useTableGlobalShortcuts","table","tableRef","scrollToIndex","tableMeta","options","meta","rows","getRowModel","React","useEffect","handleKeyDown","event","trigger","target","isElementInsideOverlay","isSiblingElementInsideSameParentOverlay","current","isElementInteractive","isElementInsideOrTriggeredFromContainer","rowActive","length","rowSelection","rowActiveIndex","undefined","_rows$tableMeta$rowAc","rowClick","original","document","addEventListener","removeEventListener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;;"}
@@ -2,6 +2,7 @@ import React__default from 'react';
2
2
  import { useVirtualizer, defaultRangeExtractor } from '@tanstack/react-virtual';
3
3
  import { ROW_HEIGHT_ESTIMATES } from '../util/rows.js';
4
4
  import { Row } from '../components/Row/Row.js';
5
+ import { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow.js';
5
6
 
6
7
  // scroll padding end is designed to always show half of the next row
7
8
  function getScrollPaddingEndOffset(table) {
@@ -27,8 +28,8 @@ function getPaddingEndOffset(table, options) {
27
28
  const bottomRows = (_table$getBottomRows = table.getBottomRows()) !== null && _table$getBottomRows !== void 0 ? _table$getBottomRows : [];
28
29
  return ROW_HEIGHT_ESTIMATES.medium * ((_options$virtualiserP = options === null || options === void 0 ? void 0 : options.virtualiserPaddingEndOffset) !== null && _options$virtualiserP !== void 0 ? _options$virtualiserP : 1) * bottomRows.length;
29
30
  }
30
- function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, options) {
31
- var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3, _ref, _virtualItems;
31
+ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
32
+ var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3, _virtualItems$end, _virtualItems;
32
33
  const tableMeta = table.options.meta;
33
34
  const isTableRowGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
34
35
  const rows = (_table$getCenterRows = table.getCenterRows()) !== null && _table$getCenterRows !== void 0 ? _table$getCenterRows : [];
@@ -41,11 +42,12 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
41
42
  const rangeExtractor = useRowGroupVirtualisation(table);
42
43
  // account for thead and tfoot in the scroll area - both are always medium row height
43
44
  const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;
45
+ const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;
44
46
  const virtualiser = useVirtualizer({
45
- count: rows.length,
47
+ count,
46
48
  estimateSize,
47
49
  getScrollElement: () => tableRef.current,
48
- overscan: tableMeta.printing.isPrinting ? rows.length : undefined,
50
+ overscan: tableMeta.printing.isPrinting ? count : undefined,
49
51
  rangeExtractor,
50
52
  // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list
51
53
  scrollPaddingStart,
@@ -65,19 +67,19 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
65
67
  if (tableRef.current) {
66
68
  if (index === 0) {
67
69
  virtualiser.scrollToOffset(0, notSmooth);
68
- } else if (index === rows.length - 1) {
70
+ } else if (index === count - 1) {
69
71
  // sometimes the last row doesn't fully show, so we just force scroll to the bottom
70
72
  tableRef.current.scrollTop = tableRef.current.scrollHeight;
71
73
  } else {
72
74
  virtualiser.scrollToIndex(index, options);
73
75
  }
74
76
  }
75
- }, [virtualItems.length, tableRef.current, totalSize, rows.length]);
77
+ }, [virtualItems.length, tableRef.current, totalSize, count]);
76
78
  // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0
77
- const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;
79
+ const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;
78
80
  const startValue = isTableRowGrouped ? ((_virtualItems$padding = virtualItems[paddingStartIndex]) === null || _virtualItems$padding === void 0 ? void 0 : _virtualItems$padding.start) - ((_virtualItems$padding2 = virtualItems[paddingStartIndex]) === null || _virtualItems$padding2 === void 0 ? void 0 : _virtualItems$padding2.size) : (_virtualItems$padding3 = virtualItems[paddingStartIndex]) === null || _virtualItems$padding3 === void 0 ? void 0 : _virtualItems$padding3.start;
79
81
  // styling for offsetting rows - this "is" the virtualisation
80
- const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, startValue !== null && startValue !== void 0 ? startValue : 0), Math.max(0, (_ref = totalSize - ((_virtualItems = virtualItems[virtualItems.length - 1]) === null || _virtualItems === void 0 ? void 0 : _virtualItems.end)) !== null && _ref !== void 0 ? _ref : 0)] : [0, 0];
82
+ const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, startValue !== null && startValue !== void 0 ? startValue : 0), Math.max(0, totalSize - ((_virtualItems$end = (_virtualItems = virtualItems[virtualItems.length - 1]) === null || _virtualItems === void 0 ? void 0 : _virtualItems.end) !== null && _virtualItems$end !== void 0 ? _virtualItems$end : 0))] : [0, 0];
81
83
  // ensure default active rows are scrolled to
82
84
  React__default.useEffect(() => {
83
85
  if (defaultRowActiveIndex) {
@@ -90,23 +92,52 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
90
92
  // rendered output
91
93
  let style = {};
92
94
  let content = null;
93
- if (rows.length) {
95
+ // bottom rows aren't virtualised (they're sticky) but we need to set the height
96
+ if (count || table.getBottomRows().length) {
94
97
  style = {
95
98
  height: totalSize,
96
- paddingBottom,
97
- paddingTop
99
+ paddingBottom: isNaN(paddingBottom) ? 0 : paddingBottom,
100
+ paddingTop: isNaN(paddingTop) ? 0 : paddingTop
98
101
  };
102
+ }
103
+ // only render non sticky rows
104
+ if (count) {
99
105
  content = virtualItems.map(virtualRow => {
106
+ var _row, _virtualiser$scrollDi2;
100
107
  // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
101
108
  if (!virtualRow) {
102
109
  return null;
103
110
  }
104
- const row = rows[virtualRow.index];
111
+ let row;
112
+ if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {
113
+ var _tableMeta$server$pag, _tableMeta$server$pag2;
114
+ const currentPageIndex = Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
115
+ const pagePosition = (_tableMeta$server$pag = (_tableMeta$server$pag2 = tableMeta.server.pages) === null || _tableMeta$server$pag2 === void 0 ? void 0 : _tableMeta$server$pag2.indexOf(currentPageIndex)) !== null && _tableMeta$server$pag !== void 0 ? _tableMeta$server$pag : -1;
116
+ if (pagePosition > -1) {
117
+ // "flatten" row indexes down into the dataloader2 dataset size
118
+ // for example, with a page size of 100...
119
+ // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)
120
+ const fakeIndex = pagePosition * tableMeta.server.pageSize + virtualRow.index % tableMeta.server.pageSize;
121
+ row = rows[fakeIndex];
122
+ }
123
+ } else {
124
+ row = rows[virtualRow.index];
125
+ }
126
+ if (!((_row = row) !== null && _row !== void 0 && _row.original)) {
127
+ var _virtualiser$scrollDi;
128
+ return /*#__PURE__*/React__default.createElement(SkeletonRow, {
129
+ key: virtualRow.index,
130
+ index: virtualRow.index,
131
+ scrollDirection: (_virtualiser$scrollDi = virtualiser.scrollDirection) !== null && _virtualiser$scrollDi !== void 0 ? _virtualiser$scrollDi : undefined,
132
+ table: table
133
+ });
134
+ }
105
135
  const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);
106
136
  return /*#__PURE__*/React__default.createElement(Row, {
107
137
  key: row.id,
108
138
  row: row,
109
139
  index: virtualRow.index,
140
+ scrollDirection: (_virtualiser$scrollDi2 = virtualiser.scrollDirection) !== null && _virtualiser$scrollDi2 !== void 0 ? _virtualiser$scrollDi2 : undefined,
110
141
  table: table,
111
142
  measureRow: measureRow,
112
143
  renderer: renderers.row,
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n Range,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef } from '../../types';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n defaultRowActiveIndex?: number | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n\n const rows = table.getCenterRows() ?? [];\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const virtualiser = useVirtualizer({\n count: rows.length,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? rows.length : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === rows.length - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, rows.length]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && rows.length > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - virtualItems[virtualItems.length - 1]?.end ?? 0)]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n if (rows.length) {\n style = {\n height: totalSize,\n paddingBottom,\n paddingTop,\n };\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n const row = rows[virtualRow.index];\n const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","virtualiser","useVirtualizer","count","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollPaddingEnd","paddingEnd","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_ref","_virtualItems","end","useEffect","style","content","map","virtualRow","row","measureRow","resizeItem","Row","key","id","renderer","cellRenderer","cell","getRowModel","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;AAcA;AACA,SAASA,yBAAyBA,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pB;EAED,OAAOD,cAAc,GAAG3E,cAAc,GAAGW,SAAS;AACtD;;;;"}
1
+ {"version":3,"file":"useTableRenderer.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableRenderer.tsx"],"sourcesContent":["import React, { CSSProperties } from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport {\n useVirtualizer,\n defaultRangeExtractor,\n ScrollToOptions as ReactVirtualScrollToOptions,\n VirtualItem,\n Range,\n} from '@tanstack/react-virtual';\nimport { ROW_HEIGHT_ESTIMATES } from '../util/rows';\nimport { Row } from '../components/Row/Row';\nimport { useTableRenderers, useTableRenderOptions } from '../types';\nimport { TableRef } from '../../types';\nimport { SkeletonRow } from '../components/Row/BuiltIns/SkeletonRow';\n\n// scroll padding end is designed to always show half of the next row\nfunction getScrollPaddingEndOffset<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let offset = 2;\n\n if (tableMeta.footer.isEnabled) {\n offset += 1;\n }\n\n if (table.getHeaderGroups().length > 1) {\n offset += table.getHeaderGroups().length - 1;\n }\n\n let height = ROW_HEIGHT_ESTIMATES.medium * offset;\n\n const bottomRows = table.getBottomRows();\n\n if (bottomRows.length) {\n // 1.4 offsets for half rows and also accounts for increased row heights (which is likely in pinned rows)\n height += ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height] * 1.4 * bottomRows.length;\n }\n\n return height;\n}\n\n// scroll padding end is designed to always show half of the next row\nfunction getPaddingEndOffset<TType = unknown>(table: ReactTable<TType>, options?: useTableRenderOptions) {\n const bottomRows = table.getBottomRows() ?? [];\n return ROW_HEIGHT_ESTIMATES.medium * (options?.virtualiserPaddingEndOffset ?? 1) * bottomRows.length;\n}\n\nexport function useTableRenderer<TType = unknown>(\n renderers: useTableRenderers<TType>,\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n length: number,\n defaultRowActiveIndex?: number | undefined,\n options?: useTableRenderOptions\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const isTableRowGrouped = !!table.getState().grouping?.length;\n const rows = table.getCenterRows() ?? [];\n\n // expanded rows\n const { createRowMeasurer, estimateSize } = useRowHeightVirtualisation<TType>(table);\n\n // row groups\n const rangeExtractor = useRowGroupVirtualisation<TType>(table);\n\n // account for thead and tfoot in the scroll area - both are always medium row height\n const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;\n\n const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;\n\n const virtualiser = useVirtualizer({\n count,\n estimateSize,\n getScrollElement: () => tableRef.current,\n overscan: tableMeta.printing.isPrinting ? count : undefined,\n rangeExtractor,\n // correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list\n scrollPaddingStart,\n scrollPaddingEnd: getScrollPaddingEndOffset(table),\n paddingEnd: getPaddingEndOffset(table, options),\n });\n\n const totalSize = virtualiser.getTotalSize();\n const virtualItems = virtualiser.getVirtualItems();\n\n const scrollToIndex = React.useCallback(\n (index: number, options: ReactVirtualScrollToOptions = { align: 'auto', behavior: 'smooth' }) => {\n const notSmooth: ReactVirtualScrollToOptions = { ...options, behavior: 'auto' };\n\n if (tableRef.current) {\n if (index === 0) {\n virtualiser.scrollToOffset(0, notSmooth);\n } else if (index === count - 1) {\n // sometimes the last row doesn't fully show, so we just force scroll to the bottom\n tableRef.current.scrollTop = tableRef.current.scrollHeight;\n } else {\n virtualiser.scrollToIndex(index, options);\n }\n }\n },\n [virtualItems.length, tableRef.current, totalSize, count]\n );\n\n // use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0\n const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;\n\n const startValue = isTableRowGrouped\n ? virtualItems[paddingStartIndex]?.start - virtualItems[paddingStartIndex]?.size\n : virtualItems[paddingStartIndex]?.start;\n\n // styling for offsetting rows - this \"is\" the virtualisation\n const [paddingTop, paddingBottom] =\n virtualItems.length > 0\n ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems[virtualItems.length - 1]?.end ?? 0))]\n : [0, 0];\n\n // ensure default active rows are scrolled to\n React.useEffect(() => {\n if (defaultRowActiveIndex) {\n scrollToIndex(defaultRowActiveIndex, { align: 'center', behavior: 'auto' });\n }\n }, []);\n\n // rendered output\n let style: CSSProperties = {};\n let content: (JSX.Element | null)[] | null = null;\n\n // bottom rows aren't virtualised (they're sticky) but we need to set the height\n if (count || table.getBottomRows().length) {\n style = {\n height: totalSize,\n paddingBottom: isNaN(paddingBottom) ? 0 : paddingBottom,\n paddingTop: isNaN(paddingTop) ? 0 : paddingTop,\n };\n }\n\n // only render non sticky rows\n if (count) {\n content = virtualItems.map(virtualRow => {\n // there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here\n if (!virtualRow) {\n return null;\n }\n\n let row: ReactTableRow<TType> | undefined;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {\n const currentPageIndex =\n (Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) /\n tableMeta.server.pageSize;\n const pagePosition = tableMeta.server.pages?.indexOf(currentPageIndex) ?? -1;\n\n if (pagePosition > -1) {\n // \"flatten\" row indexes down into the dataloader2 dataset size\n // for example, with a page size of 100...\n // row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)\n const fakeIndex = pagePosition * tableMeta.server.pageSize + (virtualRow.index % tableMeta.server.pageSize);\n row = rows[fakeIndex];\n }\n } else {\n row = rows[virtualRow.index];\n }\n\n if (!row?.original) {\n return (\n <SkeletonRow\n key={virtualRow.index}\n index={virtualRow.index}\n scrollDirection={virtualiser.scrollDirection ?? undefined}\n table={table}\n />\n );\n }\n\n const measureRow = createRowMeasurer(virtualiser.resizeItem as any, virtualRow);\n return (\n <Row\n key={row.id}\n row={row}\n index={virtualRow.index}\n scrollDirection={virtualiser.scrollDirection ?? undefined}\n table={table}\n measureRow={measureRow}\n renderer={renderers.row}\n cellRenderer={renderers.cell}\n />\n );\n });\n }\n\n return {\n rows: content,\n style,\n scrollToIndex,\n };\n}\n\n// support varying row heights - variable row heights, row expansion\nfunction useRowHeightVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n const expandedState = table.getState().expanded;\n\n const [expandedRowHeightsCache, setExpandedRowHeightsCache] = React.useState<Record<number, number>>({});\n\n // look at all registered expanded row heights and use them to form a more accurate average size\n // it might be worth considering if taking the max, or an upper bound, would be better\n const averageExpandedRowHeight = React.useMemo(() => {\n const values: number[] = Object.values(expandedRowHeightsCache);\n return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;\n }, [expandedRowHeightsCache]);\n\n // row heights\n const estimateSize = React.useCallback(\n (index: number) => {\n const rowHeight = tableMeta.rowHeight.height\n ? ROW_HEIGHT_ESTIMATES[tableMeta.rowHeight.height]\n : ROW_HEIGHT_ESTIMATES.medium;\n\n if (expandedState === true || rows[index]?.getIsExpanded?.()) {\n return rowHeight + averageExpandedRowHeight;\n }\n\n return rowHeight;\n },\n [tableMeta.rowHeight.height, averageExpandedRowHeight, expandedState]\n );\n\n const createRowMeasurer = React.useCallback(\n (resizeItem: (item: VirtualItem, size: number) => void, virtualRow: VirtualItem) =>\n (rowHeight: number, expansionHeight?: number) => {\n // register the expansion height so that it can be used to determine an average\n if (expansionHeight) {\n setExpandedRowHeightsCache(cache => ({ ...cache, [virtualRow.index]: expansionHeight }));\n }\n\n // update the whole row's size to include the expanded height\n resizeItem(virtualRow, rowHeight + (expansionHeight ?? 0));\n },\n []\n );\n\n return { estimateSize, createRowMeasurer };\n}\n\n// support virtualised row groups (where the row group headers are sticky)\nfunction useRowGroupVirtualisation<TType = unknown>(table: ReactTable<TType>) {\n const rows = table.getRowModel().rows;\n const isTableGrouped = !!table.getState().grouping.length;\n\n const rowGroupIndexes = React.useMemo(() => {\n const indexes: number[] = [];\n\n if (isTableGrouped) {\n rows.forEach((row, index) => {\n if (row.getIsGrouped()) {\n indexes.push(index);\n }\n });\n }\n\n return indexes;\n }, [rows]);\n\n // this is taken from the react-virtual docs/examples\n const rangeExtractor = React.useCallback(\n (range: Range) => {\n const activeRowGroupIndex =\n [...rowGroupIndexes].reverse().find(index => range.startIndex >= index) ?? rowGroupIndexes[0];\n\n const next = new Set([activeRowGroupIndex, ...defaultRangeExtractor(range)]);\n return [...next].sort((a, b) => a - b);\n },\n [rowGroupIndexes]\n );\n\n return isTableGrouped ? rangeExtractor : undefined;\n}\n"],"names":["getScrollPaddingEndOffset","table","tableMeta","options","meta","offset","footer","isEnabled","getHeaderGroups","length","height","ROW_HEIGHT_ESTIMATES","medium","bottomRows","getBottomRows","rowHeight","getPaddingEndOffset","_table$getBottomRows","_options$virtualiserP","virtualiserPaddingEndOffset","useTableRenderer","renderers","tableRef","defaultRowActiveIndex","isTableRowGrouped","_table$getState$group","getState","grouping","rows","_table$getCenterRows","getCenterRows","createRowMeasurer","estimateSize","useRowHeightVirtualisation","rangeExtractor","useRowGroupVirtualisation","scrollPaddingStart","count","server","_experimentalDataLoader2","virtualiser","useVirtualizer","getScrollElement","current","overscan","printing","isPrinting","undefined","scrollPaddingEnd","paddingEnd","totalSize","getTotalSize","virtualItems","getVirtualItems","scrollToIndex","React","useCallback","index","align","behavior","notSmooth","scrollToOffset","scrollTop","scrollHeight","paddingStartIndex","startValue","_virtualItems$padding","start","_virtualItems$padding2","size","_virtualItems$padding3","paddingTop","paddingBottom","Math","max","_virtualItems$end","_virtualItems","end","useEffect","style","content","isNaN","map","virtualRow","row","_tableMeta$server$pag","_tableMeta$server$pag2","currentPageIndex","floor","pageSize","pagePosition","pages","indexOf","fakeIndex","_row","original","_virtualiser$scrollDi","SkeletonRow","key","scrollDirection","measureRow","resizeItem","Row","id","_virtualiser$scrollDi2","renderer","cellRenderer","cell","getRowModel","expandedState","expanded","expandedRowHeightsCache","setExpandedRowHeightsCache","useState","averageExpandedRowHeight","useMemo","values","Object","reduce","a","b","_rows$index","_rows$index$getIsExpa","getIsExpanded","call","expansionHeight","cache","isTableGrouped","rowGroupIndexes","indexes","forEach","getIsGrouped","push","range","activeRowGroupIndex","_reverse$find","reverse","find","startIndex","next","Set","defaultRangeExtractor","sort"],"mappings":";;;;;;AAeA;AACA,SAASA,yBAAyBA,CAAkBC,KAAwB;EACxE,MAAMC,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;EAC7D,IAAIC,MAAM,GAAG,CAAC;EAEd,IAAIH,SAAS,CAACI,MAAM,CAACC,SAAS,EAAE;IAC5BF,MAAM,IAAI,CAAC;;EAGf,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC,EAAE;IACpCJ,MAAM,IAAIJ,KAAK,CAACO,eAAe,EAAE,CAACC,MAAM,GAAG,CAAC;;EAGhD,IAAIC,MAAM,GAAGC,oBAAoB,CAACC,MAAM,GAAGP,MAAM;EAEjD,MAAMQ,UAAU,GAAGZ,KAAK,CAACa,aAAa,EAAE;EAExC,IAAID,UAAU,CAACJ,MAAM,EAAE;;IAEnBC,MAAM,IAAIC,oBAAoB,CAACT,SAAS,CAACa,SAAS,CAACL,MAAM,CAAC,GAAG,GAAG,GAAGG,UAAU,CAACJ,MAAM;;EAGxF,OAAOC,MAAM;AACjB;AAEA;AACA,SAASM,mBAAmBA,CAAkBf,KAAwB,EAAEE,OAA+B;;EACnG,MAAMU,UAAU,IAAAI,oBAAA,GAAGhB,KAAK,CAACa,aAAa,EAAE,cAAAG,oBAAA,cAAAA,oBAAA,GAAI,EAAE;EAC9C,OAAON,oBAAoB,CAACC,MAAM,KAAAM,qBAAA,GAAIf,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEgB,2BAA2B,cAAAD,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC,GAAGL,UAAU,CAACJ,MAAM;AACxG;SAEgBW,gBAAgBA,CAC5BC,SAAmC,EACnCpB,KAAwB,E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,MAAMM,cAAc,GAAGqB,cAAK,CAACC,WAAW,CACnC6E,KAAY;;IACT,MAAMC,mBAAmB,IAAAC,aAAA,GACrB,CAAC,GAAGP,eAAe,CAAC,CAACQ,OAAO,EAAE,CAACC,IAAI,CAAChF,KAAK,IAAI4E,KAAK,CAACK,UAAU,IAAIjF,KAAK,CAAC,cAAA8E,aAAA,cAAAA,aAAA,GAAIP,eAAe,CAAC,CAAC,CAAC;IAEjG,MAAMW,IAAI,GAAG,IAAIC,GAAG,CAAC,CAACN,mBAAmB,EAAE,GAAGO,qBAAqB,CAACR,KAAK,CAAC,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAGM,IAAI,CAAC,CAACG,IAAI,CAAC,CAACvB,CAAC,EAAEC,CAAC,KAAKD,CAAC,GAAGC,CAAC,CAAC;GACzC,EACD,CAACQ,eAAe,CAAC,CACpB;EAED,OAAOD,cAAc,GAAG7F,cAAc,GAAGa,SAAS;AACtD;;;;"}
@@ -57,9 +57,9 @@ function useTableStyleGrid(tableId, table, fontSize) {
57
57
  };
58
58
  // printing grid
59
59
  // we have to be specific so that nested tables don't inherit the same css
60
- const hiddenColumns = printHiddenColumns.map(id => `table[data-taco^='table']#${tableId} > thead > tr > th[data-cell-id='${id}']\n,table[data-taco^='table']#${tableId} > tbody > tr > td[data-cell-id='${id}']\n`).join(',');
60
+ const hiddenColumns = printHiddenColumns.map(id => `table[data-taco^='table']#${tableId} > thead > tr > th[data-cell-id='${id}']\n,table[data-taco^='table']#${tableId} tr > td[data-cell-id='${id}']\n`).join(',');
61
61
  const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: repeat(${printGridTemplateColumns}, auto) !important; }
62
- table[data-taco^='table']#${tableId} [data-cell-id^='__']${hiddenColumns ? `, ${hiddenColumns}` : ''} { display: none; }}`;
62
+ table[data-taco^='table']#${tableId} [data-cell-id^='__']${hiddenColumns ? `, ${hiddenColumns}` : ''} { display: none; } table[data-taco^='table']#${tableId} tr { page-break-inside: avoid; break-inside: avoid;}}`;
63
63
  return {
64
64
  style,
65
65
  stylesheet
@@ -1 +1 @@
1
- {"version":3,"file":"useTableStyleGrid.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableStyleGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableFontSize } from '../../types';\nimport { getCellMinWidth, isInternalColumn } from '../../useTableManager/util/columns';\n\nexport function useTableStyleGrid<TType = unknown>(tableId: string, table: ReactTable<TType>, fontSize: TableFontSize) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const globalMinSize = getCellMinWidth(fontSize);\n\n // header body ?footer\n const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';\n\n return React.useMemo(() => {\n let printGridTemplateColumns = 0;\n const printHiddenColumns: string[] = [];\n\n const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {\n if (table.options.enableGrouping && column.getIsGrouped()) {\n return accum;\n }\n\n const minSize = column.columnDef.minSize ?? globalMinSize;\n const width = columnSizing[column.id] as number | 'grow';\n\n let size;\n\n if (isInternalColumn(column.id)) {\n if (column.id === '__actions') {\n const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */\n size = `minmax(${minWidth}px, auto)`;\n } else {\n // getSize method is used instead of columnSizing state because internal columns have defined widths\n size = `${column.getSize()}px`;\n }\n } else if (width !== undefined) {\n const isLastColumn = index === allVisibleColumns.length - 1;\n\n if (width === 'grow' || (Number.isNaN(width) && !isLastColumn)) {\n size = `minmax(max-content, 1fr)`;\n } else {\n const minWidth = width < minSize ? minSize : width;\n\n if (isLastColumn) {\n size = `minmax(${minWidth}px, auto)`;\n } else {\n size = `${minWidth}px`;\n }\n }\n } else {\n size = `minmax(max-content, auto)`;\n }\n\n // printing\n if (column.columnDef.meta?.enablePrinting === false) {\n printHiddenColumns.push(column.id);\n } else {\n printGridTemplateColumns++;\n }\n\n return `${accum} ${size}`.trim();\n }, '');\n\n // normal grid\n const style: React.CSSProperties = {\n gridTemplateColumns,\n gridTemplateRows,\n };\n\n // printing grid\n // we have to be specific so that nested tables don't inherit the same css\n const hiddenColumns = printHiddenColumns\n .map(\n id =>\n `table[data-taco^='table']#${tableId} > thead > tr > th[data-cell-id='${id}']\\n,table[data-taco^='table']#${tableId} > tbody > tr > td[data-cell-id='${id}']\\n`\n )\n .join(',');\n const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: repeat(${printGridTemplateColumns}, auto) !important; }\n table[data-taco^='table']#${tableId} [data-cell-id^='__']${\n hiddenColumns ? `, ${hiddenColumns}` : ''\n } { display: none; }}`;\n\n return { style, stylesheet };\n }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);\n}\n"],"names":["useTableStyleGrid","tableId","table","fontSize","tableMeta","options","meta","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","globalMinSize","getCellMinWidth","gridTemplateRows","getRowModel","rows","length","React","useMemo","printGridTemplateColumns","printHiddenColumns","gridTemplateColumns","reduce","accum","column","index","enableGrouping","getIsGrouped","minSize","_column$columnDef$min","columnDef","width","id","size","isInternalColumn","minWidth","rowActions","rowActionsLength","getSize","undefined","isLastColumn","Number","isNaN","_column$columnDef$met","enablePrinting","push","trim","style","hiddenColumns","map","join","stylesheet"],"mappings":";;;SAKgBA,iBAAiBA,CAAkBC,OAAe,EAAEC,KAAwB,EAAEC,QAAuB;EACjH,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,qBAAqB,EAAE;EACvD,MAAMC,YAAY,GAAGP,KAAK,CAACQ,QAAQ,EAAE,CAACD,YAAY;EAClD,MAAME,aAAa,GAAGC,eAAe,CAACT,QAAQ,CAAC;;EAG/C,MAAMU,gBAAgB,GAAGX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AK;UAElD,IAAIS,YAAY,EAAE;YACdP,IAAI,GAAG,UAAUE,QAAQ,WAAW;WACvC,MAAM;YACHF,IAAI,GAAG,GAAGE,QAAQ,IAAI;;;OAGjC,MAAM;QACHF,IAAI,GAAG,2BAA2B;;;MAItC,IAAI,EAAAU,qBAAA,GAAAnB,MAAM,CAACM,SAAS,CAACxB,IAAI,cAAAqC,qBAAA,uBAArBA,qBAAA,CAAuBC,cAAc,MAAK,KAAK,EAAE;QACjDxB,kBAAkB,CAACyB,IAAI,CAACrB,MAAM,CAACQ,EAAE,CAAC;OACrC,MAAM;QACHb,wBAAwB,EAAE;;MAG9B,OAAO,GAAGI,KAAK,IAAIU,IAAI,EAAE,CAACa,IAAI,EAAE;KACnC,EAAE,EAAE,CAAC;;IAGN,MAAMC,KAAK,GAAwB;MAC/B1B,mBAAmB;MACnBR;KACH;;;IAID,MAAMmC,aAAa,GAAG5B,kBAAkB,CACnC6B,GAAG,CACAjB,EAAE,IACE,6BAA6B/B,OAAO,oCAAoC+B,EAAE,kCAAkC/B,OAAO,oCAAoC+B,EAAE,MAAM,CACtK,CACAkB,IAAI,CAAC,GAAG,CAAC;IACd,MAAMC,UAAU,GAAG,4CAA4ClD,OAAO,oCAAoCkB,wBAAwB;oCACtGlB,OAAO,wBAC/B+C,aAAa,GAAG,KAAKA,aAAa,EAAE,GAAG,EAC3C,sBAAsB;IAEtB,OAAO;MAAED,KAAK;MAAEI;KAAY;GAC/B,EAAE,CAAC5C,iBAAiB,EAAEE,YAAY,EAAEE,aAAa,EAAEP,SAAS,CAACgC,UAAU,CAACC,gBAAgB,CAAC,CAAC;AAC/F;;;;"}
1
+ {"version":3,"file":"useTableStyleGrid.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableStyleGrid.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableFontSize } from '../../types';\nimport { getCellMinWidth, isInternalColumn } from '../../useTableManager/util/columns';\n\nexport function useTableStyleGrid<TType = unknown>(tableId: string, table: ReactTable<TType>, fontSize: TableFontSize) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const allVisibleColumns = table.getVisibleLeafColumns();\n const columnSizing = table.getState().columnSizing;\n const globalMinSize = getCellMinWidth(fontSize);\n\n // header body ?footer\n const gridTemplateRows = table.getRowModel().rows.length ? 'min-content 1fr min-content' : 'min-content 1fr';\n\n return React.useMemo(() => {\n let printGridTemplateColumns = 0;\n const printHiddenColumns: string[] = [];\n\n const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {\n if (table.options.enableGrouping && column.getIsGrouped()) {\n return accum;\n }\n\n const minSize = column.columnDef.minSize ?? globalMinSize;\n const width = columnSizing[column.id] as number | 'grow';\n\n let size;\n\n if (isInternalColumn(column.id)) {\n if (column.id === '__actions') {\n const minWidth = tableMeta.rowActions.rowActionsLength * 32 + 8; /* button margins l+r */\n size = `minmax(${minWidth}px, auto)`;\n } else {\n // getSize method is used instead of columnSizing state because internal columns have defined widths\n size = `${column.getSize()}px`;\n }\n } else if (width !== undefined) {\n const isLastColumn = index === allVisibleColumns.length - 1;\n\n if (width === 'grow' || (Number.isNaN(width) && !isLastColumn)) {\n size = `minmax(max-content, 1fr)`;\n } else {\n const minWidth = width < minSize ? minSize : width;\n\n if (isLastColumn) {\n size = `minmax(${minWidth}px, auto)`;\n } else {\n size = `${minWidth}px`;\n }\n }\n } else {\n size = `minmax(max-content, auto)`;\n }\n\n // printing\n if (column.columnDef.meta?.enablePrinting === false) {\n printHiddenColumns.push(column.id);\n } else {\n printGridTemplateColumns++;\n }\n\n return `${accum} ${size}`.trim();\n }, '');\n\n // normal grid\n const style: React.CSSProperties = {\n gridTemplateColumns,\n gridTemplateRows,\n };\n\n // printing grid\n // we have to be specific so that nested tables don't inherit the same css\n const hiddenColumns = printHiddenColumns\n .map(\n id =>\n `table[data-taco^='table']#${tableId} > thead > tr > th[data-cell-id='${id}']\\n,table[data-taco^='table']#${tableId} tr > td[data-cell-id='${id}']\\n`\n )\n .join(',');\n const stylesheet = `@media print { table[data-taco^='table']#${tableId} { grid-template-columns: repeat(${printGridTemplateColumns}, auto) !important; }\n table[data-taco^='table']#${tableId} [data-cell-id^='__']${\n hiddenColumns ? `, ${hiddenColumns}` : ''\n } { display: none; } table[data-taco^='table']#${tableId} tr { page-break-inside: avoid; break-inside: avoid;}}`;\n\n return { style, stylesheet };\n }, [allVisibleColumns, columnSizing, globalMinSize, tableMeta.rowActions.rowActionsLength]);\n}\n"],"names":["useTableStyleGrid","tableId","table","fontSize","tableMeta","options","meta","allVisibleColumns","getVisibleLeafColumns","columnSizing","getState","globalMinSize","getCellMinWidth","gridTemplateRows","getRowModel","rows","length","React","useMemo","printGridTemplateColumns","printHiddenColumns","gridTemplateColumns","reduce","accum","column","index","enableGrouping","getIsGrouped","minSize","_column$columnDef$min","columnDef","width","id","size","isInternalColumn","minWidth","rowActions","rowActionsLength","getSize","undefined","isLastColumn","Number","isNaN","_column$columnDef$met","enablePrinting","push","trim","style","hiddenColumns","map","join","stylesheet"],"mappings":";;;SAKgBA,iBAAiBA,CAAkBC,OAAe,EAAEC,KAAwB,EAAEC,QAAuB;EACjH,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAO,CAACC,IAA6B;EAC7D,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,qBAAqB,EAAE;EACvD,MAAMC,YAAY,GAAGP,KAAK,CAACQ,QAAQ,EAAE,CAACD,YAAY;EAClD,MAAME,aAAa,GAAGC,eAAe,CAACT,QAAQ,CAAC;;EAG/C,MAAMU,gBAAgB,GAAGX,KAAK,CAACY,WAAW,EAAE,CAACC,IAAI,CAACC,MAAM,GAAG,6BAA6B,GAAG,iBAAiB;EAE5G,OAAOC,cAAK,CAACC,OAAO,CAAC;IACjB,IAAIC,wBAAwB,GAAG,CAAC;IAChC,MAAMC,kBAAkB,GAAa,EAAE;IAEvC,MAAMC,mBAAmB,GAAGd,iBAAiB,CAACe,MAAM,C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,qBAAA,uBAArBA,qBAAA,CAAuBC,cAAc,MAAK,KAAK,EAAE;QACjDxB,kBAAkB,CAACyB,IAAI,CAACrB,MAAM,CAACQ,EAAE,CAAC;OACrC,MAAM;QACHb,wBAAwB,EAAE;;MAG9B,OAAO,GAAGI,KAAK,IAAIU,IAAI,EAAE,CAACa,IAAI,EAAE;KACnC,EAAE,EAAE,CAAC;;IAGN,MAAMC,KAAK,GAAwB;MAC/B1B,mBAAmB;MACnBR;KACH;;;IAID,MAAMmC,aAAa,GAAG5B,kBAAkB,CACnC6B,GAAG,CACAjB,EAAE,IACE,6BAA6B/B,OAAO,oCAAoC+B,EAAE,kCAAkC/B,OAAO,0BAA0B+B,EAAE,MAAM,CAC5J,CACAkB,IAAI,CAAC,GAAG,CAAC;IACd,MAAMC,UAAU,GAAG,4CAA4ClD,OAAO,oCAAoCkB,wBAAwB;oCACtGlB,OAAO,wBAC/B+C,aAAa,GAAG,KAAKA,aAAa,EAAE,GAAG,EAC3C,iDAAiD/C,OAAO,wDAAwD;IAEhH,OAAO;MAAE8C,KAAK;MAAEI;KAAY;GAC/B,EAAE,CAAC5C,iBAAiB,EAAEE,YAAY,EAAEE,aAAa,EAAEP,SAAS,CAACgC,UAAU,CAACC,gBAAgB,CAAC,CAAC;AAC/F;;;;"}
@@ -22,7 +22,7 @@ function useTable(props, externalRef, renderers, meta, options) {
22
22
  // configure the table
23
23
  const manager = useTableManager(props, meta, INTERNAL_RENDERERS);
24
24
  // configure the virtualised renderer
25
- const renderer = useTableRenderer(renderers, manager.instance, ref, props.defaultRowActiveIndex, options);
25
+ const renderer = useTableRenderer(renderers, manager.instance, ref, manager.meta.length, props.defaultRowActiveIndex, options);
26
26
  // configure dynamic styling
27
27
  const {
28
28
  style,
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/primitives/Table/Core/useTable.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta, TableState as ReactTableState } from '@tanstack/react-table';\nimport { ScrollToOptions as ReactVirtualScrollToOptions } from '@tanstack/react-virtual';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { TableCustomSettingsRenderer, TableEmptyStateRenderer, TableProps } from '../types';\nimport { useTableManager } from '../useTableManager/useTableManager';\nimport { useTableStyle } from './features/useTableStyle';\nimport { useTableGlobalShortcuts } from './features/useTableGlobalShortcuts';\nimport { useTableRef } from './features/useTableRef';\nimport { useTableRenderer } from './features/useTableRenderer';\nimport { useTableRowActiveListener } from './listeners/useTableRowActiveListener';\nimport { TableRef } from '../types';\nimport { useTableRenderers, useTableRenderOptions } from './types';\nimport { renderer as rowActions } from './components/Columns/Internal/Actions';\nimport { renderer as rowDrag } from './components/Columns/Internal/Drag';\nimport { renderer as rowExpansion } from './components/Columns/Internal/Expansion';\nimport { renderer as rowSelection } from './components/Columns/Internal/Selection';\nimport { useTableManagerInternalColumns } from '../useTableManager/types';\n\nconst INTERNAL_RENDERERS = {\n rowActions,\n rowDrag,\n rowExpansion,\n rowSelection,\n};\n\nexport type useTableReturnValue<TType = unknown> = {\n id: string;\n instance: ReactTable<TType>;\n meta: ReactTableMeta<TType>;\n props: {\n customSettings: TableCustomSettingsRenderer | undefined;\n emptyState: TableEmptyStateRenderer | undefined;\n toolbarLeft: JSX.Element | undefined;\n toolbarPanel: JSX.Element | undefined;\n toolbarRight: JSX.Element | undefined;\n };\n ref: React.RefObject<TableRef>;\n renderer: {\n rows: (JSX.Element | null)[] | null;\n style: React.CSSProperties;\n scrollToIndex: (index: number, options?: ReactVirtualScrollToOptions) => void;\n };\n style: React.CSSProperties;\n stylesheet: string;\n state: ReactTableState;\n};\n\nexport function useTable<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n externalRef: React.Ref<TableRef>,\n renderers: useTableRenderers<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n options?: useTableRenderOptions\n): useTableReturnValue<TType> {\n // create a ref and merge with the consumer's ref\n const ref = useMergedRef<TableRef>(externalRef);\n // configure the table\n const manager = useTableManager<TType>(props, meta, INTERNAL_RENDERERS as useTableManagerInternalColumns<TType>);\n // configure the virtualised renderer\n const renderer = useTableRenderer<TType>(renderers, manager.instance, ref, props.defaultRowActiveIndex, options);\n // configure dynamic styling\n const { style, stylesheet } = useTableStyle(manager.id, manager.instance);\n // configure global keyboard shortcuts\n useTableGlobalShortcuts(manager.instance, ref, renderer.scrollToIndex);\n // augment the ref with some helper functions\n useTableRef(manager.instance, ref);\n\n // listeners - they are here and not in useTableManager because they rely on the dom and the table ref\n useTableRowActiveListener(manager.instance, ref);\n\n return {\n ...manager,\n props: {\n customSettings: props.customSettings,\n emptyState: props.emptyState,\n toolbarLeft: props.toolbarLeft,\n toolbarPanel: props.toolbarPanel,\n toolbarRight: props.toolbarRight,\n },\n renderer,\n style,\n stylesheet,\n ref,\n };\n}\n"],"names":["INTERNAL_RENDERERS","rowActions","rowDrag","rowExpansion","rowSelection","useTable","props","externalRef","renderers","meta","options","ref","useMergedRef","manager","useTableManager","renderer","useTableRenderer","instance","defaultRowActiveIndex","style","stylesheet","useTableStyle","id","useTableGlobalShortcuts","scrollToIndex","useTableRef","useTableRowActiveListener","customSettings","emptyState","toolbarLeft","toolbarPanel","toolbarRight"],"mappings":";;;;;;;;;;;;AAkBA,MAAMA,kBAAkB,GAAG;cACvBC,QAAU;WACVC,UAAO;gBACPC,UAAY;gBACZC;CACH;SAwBeC,QAAQA,CACpBC,KAAwB,EACxBC,WAAgC,EAChCC,SAAmC,EACnCC,IAA6C,EAC7CC,OAA+B;;EAG/B,MAAMC,GAAG,GAAGC,YAAY,CAAWL,WAAW,CAAC;;EAE/C,MAAMM,OAAO,GAAGC,eAAe,CAAQR,KAAK,EAAEG,IAAI,EAAET,kBAA2D,CAAC;;EAEhH,MAAMe,QAAQ,GAAGC,gBAAgB,CAAQR,SAAS,EAAEK,OAAO,CAACI,QAAQ,EAAEN,GAAG,EAAEL,KAAK,CAACY,qBAAqB,EAAER,OAAO,CAAC;;EAEhH,MAAM;IAAES,KAAK;IAAEC;GAAY,GAAGC,aAAa,CAACR,OAAO,CAACS,EAAE,EAAET,OAAO,CAACI,QAAQ,CAAC;;EAEzEM,uBAAuB,CAACV,OAAO,CAACI,QAAQ,EAAEN,GAAG,EAAEI,QAAQ,CAACS,aAAa,CAAC;;EAEtEC,WAAW,CAACZ,OAAO,CAACI,QAAQ,EAAEN,GAAG,CAAC;;EAGlCe,yBAAyB,CAACb,OAAO,CAACI,QAAQ,EAAEN,GAAG,CAAC;EAEhD,OAAO;IACH,GAAGE,OAAO;IACVP,KAAK,EAAE;MACHqB,cAAc,EAAErB,KAAK,CAACqB,cAAc;MACpCC,UAAU,EAAEtB,KAAK,CAACsB,UAAU;MAC5BC,WAAW,EAAEvB,KAAK,CAACuB,WAAW;MAC9BC,YAAY,EAAExB,KAAK,CAACwB,YAAY;MAChCC,YAAY,EAAEzB,KAAK,CAACyB;KACvB;IACDhB,QAAQ;IACRI,KAAK;IACLC,UAAU;IACVT;GACH;AACL;;;;"}
1
+ {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/primitives/Table/Core/useTable.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta, TableState as ReactTableState } from '@tanstack/react-table';\nimport { ScrollToOptions as ReactVirtualScrollToOptions } from '@tanstack/react-virtual';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\nimport { TableCustomSettingsRenderer, TableEmptyStateRenderer, TableProps } from '../types';\nimport { useTableManager } from '../useTableManager/useTableManager';\nimport { useTableStyle } from './features/useTableStyle';\nimport { useTableGlobalShortcuts } from './features/useTableGlobalShortcuts';\nimport { useTableRef } from './features/useTableRef';\nimport { useTableRenderer } from './features/useTableRenderer';\nimport { useTableRowActiveListener } from './listeners/useTableRowActiveListener';\nimport { TableRef } from '../types';\nimport { useTableRenderers, useTableRenderOptions } from './types';\nimport { renderer as rowActions } from './components/Columns/Internal/Actions';\nimport { renderer as rowDrag } from './components/Columns/Internal/Drag';\nimport { renderer as rowExpansion } from './components/Columns/Internal/Expansion';\nimport { renderer as rowSelection } from './components/Columns/Internal/Selection';\nimport { useTableManagerInternalColumns } from '../useTableManager/types';\n\nconst INTERNAL_RENDERERS = {\n rowActions,\n rowDrag,\n rowExpansion,\n rowSelection,\n};\n\nexport type useTableReturnValue<TType = unknown> = {\n id: string;\n instance: ReactTable<TType>;\n meta: ReactTableMeta<TType>;\n props: {\n customSettings: TableCustomSettingsRenderer | undefined;\n emptyState: TableEmptyStateRenderer | undefined;\n toolbarLeft: JSX.Element | undefined;\n toolbarPanel: JSX.Element | undefined;\n toolbarRight: JSX.Element | undefined;\n };\n ref: React.RefObject<TableRef>;\n renderer: {\n rows: (JSX.Element | null)[] | null;\n style: React.CSSProperties;\n scrollToIndex: (index: number, options?: ReactVirtualScrollToOptions) => void;\n };\n style: React.CSSProperties;\n stylesheet: string;\n state: ReactTableState;\n};\n\nexport function useTable<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n externalRef: React.Ref<TableRef>,\n renderers: useTableRenderers<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n options?: useTableRenderOptions\n): useTableReturnValue<TType> {\n // create a ref and merge with the consumer's ref\n const ref = useMergedRef<TableRef>(externalRef);\n // configure the table\n const manager = useTableManager<TType>(props, meta, INTERNAL_RENDERERS as useTableManagerInternalColumns<TType>);\n\n // configure the virtualised renderer\n const renderer = useTableRenderer<TType>(\n renderers,\n manager.instance,\n ref,\n manager.meta.length,\n props.defaultRowActiveIndex,\n options\n );\n // configure dynamic styling\n const { style, stylesheet } = useTableStyle(manager.id, manager.instance);\n // configure global keyboard shortcuts\n useTableGlobalShortcuts(manager.instance, ref, renderer.scrollToIndex);\n // augment the ref with some helper functions\n useTableRef(manager.instance, ref);\n\n // listeners - they are here and not in useTableManager because they rely on the dom and the table ref\n useTableRowActiveListener(manager.instance, ref);\n\n return {\n ...manager,\n props: {\n customSettings: props.customSettings,\n emptyState: props.emptyState,\n toolbarLeft: props.toolbarLeft,\n toolbarPanel: props.toolbarPanel,\n toolbarRight: props.toolbarRight,\n },\n renderer,\n style,\n stylesheet,\n ref,\n };\n}\n"],"names":["INTERNAL_RENDERERS","rowActions","rowDrag","rowExpansion","rowSelection","useTable","props","externalRef","renderers","meta","options","ref","useMergedRef","manager","useTableManager","renderer","useTableRenderer","instance","length","defaultRowActiveIndex","style","stylesheet","useTableStyle","id","useTableGlobalShortcuts","scrollToIndex","useTableRef","useTableRowActiveListener","customSettings","emptyState","toolbarLeft","toolbarPanel","toolbarRight"],"mappings":";;;;;;;;;;;;AAkBA,MAAMA,kBAAkB,GAAG;cACvBC,QAAU;WACVC,UAAO;gBACPC,UAAY;gBACZC;CACH;SAwBeC,QAAQA,CACpBC,KAAwB,EACxBC,WAAgC,EAChCC,SAAmC,EACnCC,IAA6C,EAC7CC,OAA+B;;EAG/B,MAAMC,GAAG,GAAGC,YAAY,CAAWL,WAAW,CAAC;;EAE/C,MAAMM,OAAO,GAAGC,eAAe,CAAQR,KAAK,EAAEG,IAAI,EAAET,kBAA2D,CAAC;;EAGhH,MAAMe,QAAQ,GAAGC,gBAAgB,CAC7BR,SAAS,EACTK,OAAO,CAACI,QAAQ,EAChBN,GAAG,EACHE,OAAO,CAACJ,IAAI,CAACS,MAAM,EACnBZ,KAAK,CAACa,qBAAqB,EAC3BT,OAAO,CACV;;EAED,MAAM;IAAEU,KAAK;IAAEC;GAAY,GAAGC,aAAa,CAACT,OAAO,CAACU,EAAE,EAAEV,OAAO,CAACI,QAAQ,CAAC;;EAEzEO,uBAAuB,CAACX,OAAO,CAACI,QAAQ,EAAEN,GAAG,EAAEI,QAAQ,CAACU,aAAa,CAAC;;EAEtEC,WAAW,CAACb,OAAO,CAACI,QAAQ,EAAEN,GAAG,CAAC;;EAGlCgB,yBAAyB,CAACd,OAAO,CAACI,QAAQ,EAAEN,GAAG,CAAC;EAEhD,OAAO;IACH,GAAGE,OAAO;IACVP,KAAK,EAAE;MACHsB,cAAc,EAAEtB,KAAK,CAACsB,cAAc;MACpCC,UAAU,EAAEvB,KAAK,CAACuB,UAAU;MAC5BC,WAAW,EAAExB,KAAK,CAACwB,WAAW;MAC9BC,YAAY,EAAEzB,KAAK,CAACyB,YAAY;MAChCC,YAAY,EAAE1B,KAAK,CAAC0B;KACvB;IACDjB,QAAQ;IACRK,KAAK;IACLC,UAAU;IACVV;GACH;AACL;;;;"}
@@ -15,13 +15,9 @@ var TableFilterComparator;
15
15
  TableFilterComparator[TableFilterComparator["HasAnyOf"] = 11] = "HasAnyOf";
16
16
  TableFilterComparator[TableFilterComparator["HasAllOf"] = 12] = "HasAllOf";
17
17
  TableFilterComparator[TableFilterComparator["HasNoneOf"] = 13] = "HasNoneOf";
18
+ TableFilterComparator[TableFilterComparator["IsOneOf"] = 14] = "IsOneOf";
19
+ TableFilterComparator[TableFilterComparator["IsNoneOf"] = 15] = "IsNoneOf";
18
20
  })(TableFilterComparator || (TableFilterComparator = {}));
19
- var TableServerLoadAllState;
20
- (function (TableServerLoadAllState) {
21
- TableServerLoadAllState[TableServerLoadAllState["Incomplete"] = 0] = "Incomplete";
22
- TableServerLoadAllState[TableServerLoadAllState["Loading"] = 1] = "Loading";
23
- TableServerLoadAllState[TableServerLoadAllState["Completed"] = 2] = "Completed";
24
- })(TableServerLoadAllState || (TableServerLoadAllState = {}));
25
21
 
26
- export { TableFilterComparator, TableServerLoadAllState };
22
+ export { TableFilterComparator };
27
23
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'checkbox'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string: any) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void | Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableSearchHandler = (search: string | undefined) => void | Promise<void>;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityAccessor?: keyof TType;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IAmHrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, StringWithAutocompleteOptions, ValueOf } from '../../types';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n IsOneOf,\n IsNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType =\n // base\n | 'text'\n | 'number'\n | 'datetime'\n | 'boolean'\n // advanced\n | 'amount';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType, filterState?: TableFilter[]) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'checkbox'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TType> = (rows: TType[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (\n row: TType,\n internalRowId: string,\n cleanup: (rowId: string) => void\n) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string: any) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[], ids: string[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableSortHandler = (sorting: TableColumnSort[]) => Promise<void>;\nexport type TableFilterHandler = (filters: TableColumnFilter[], hiddenColumns: string[]) => Promise<void>;\nexport type TableSearchHandler = (search: string | undefined, hiddenColumns: string[]) => Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n hiddenColumns: string[],\n search: string | undefined\n) => Promise<void>;\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateReason = 'empty' | 'filtering' | 'searching';\nexport type TableEmptyStateRenderer = (props: { reason: TableEmptyStateReason }) => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableConditionalRowProp<TType = unknown> = boolean | ((row: TType) => boolean);\nexport type TableFeatureProps<TType = unknown> = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowExpansionAll?: boolean;\n enableRowSelection?: TableConditionalRowProp<TType>;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: TableConditionalRowProp<TType>;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableChild = JSX.Element | boolean | null | undefined;\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps<TType> & {\n children: TableChild | TableChild[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityAccessor?: keyof TType;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n pages?: never;\n\n // experimental\n _experimentalDataLoader2?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n pages?: number[];\n\n // experimental\n _experimentalDataLoader2?: boolean;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: StringWithAutocompleteOptions<Key>;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableEditing?: boolean;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n cancel: string;\n clear: string;\n apply: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isOneOf: string;\n isNoneOf: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator"],"mappings":"AAwBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;EACTA,wEAAO;EACPA,0EAAQ;AACZ,CAAC,EAjBWA,qBAAqB,KAArBA,qBAAqB;;;;"}