@economic/taco 1.41.0 → 2.0.0-alpha.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. package/dist/components/Icon/components/HeightTall.d.ts +3 -0
  2. package/dist/components/Icon/components/index.d.ts +1 -1
  3. package/dist/components/Input/Input.d.ts +1 -1
  4. package/dist/components/Menu/Menu.d.ts +2 -0
  5. package/dist/components/Menu/components/Item.d.ts +6 -1
  6. package/dist/components/Menu/components/Link.d.ts +1 -1
  7. package/dist/components/Menu/components/SubMenu.d.ts +8 -0
  8. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  9. package/dist/components/Popover/Popover.d.ts +3 -0
  10. package/dist/components/Provider/Localization.d.ts +148 -0
  11. package/dist/components/SearchInput/SearchInput.d.ts +2 -0
  12. package/dist/components/SearchInput2/SearchInput2.d.ts +23 -0
  13. package/dist/components/Select2/components/Option.d.ts +1 -1
  14. package/dist/components/Select2/components/Search.d.ts +1 -1
  15. package/dist/components/Table2/hooks/useTable.d.ts +1 -1
  16. package/dist/components/Table3/Table3.d.ts +12 -0
  17. package/dist/components/Table3/components/columns/cell/Cell.d.ts +6 -0
  18. package/dist/components/Table3/components/columns/cell/DisplayCell.d.ts +22 -0
  19. package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +7 -0
  20. package/dist/components/Table3/components/columns/cell/Indicator.d.ts +17 -0
  21. package/dist/components/Table3/components/columns/footer/Footer.d.ts +14 -0
  22. package/dist/components/Table3/components/columns/footer/Summary.d.ts +7 -0
  23. package/dist/components/Table3/components/columns/header/Goto.d.ts +6 -0
  24. package/dist/components/Table3/components/columns/header/Header.d.ts +27 -0
  25. package/dist/components/Table3/components/columns/header/Menu.d.ts +16 -0
  26. package/dist/components/Table3/components/columns/header/Resizer.d.ts +7 -0
  27. package/dist/components/Table3/components/columns/header/SortIndicator.d.ts +12 -0
  28. package/dist/components/Table3/components/columns/internal/Actions.d.ts +4 -0
  29. package/dist/components/Table3/components/columns/internal/Drag.d.ts +4 -0
  30. package/dist/components/Table3/components/columns/internal/EditingActions.d.ts +8 -0
  31. package/dist/components/Table3/components/columns/internal/Expansion.d.ts +4 -0
  32. package/dist/components/Table3/components/columns/internal/Selection.d.ts +4 -0
  33. package/dist/components/Table3/components/columns/styles.d.ts +4 -0
  34. package/dist/components/Table3/components/rows/ExpandedRow.d.ts +8 -0
  35. package/dist/components/Table3/components/rows/Row.d.ts +21 -0
  36. package/dist/components/Table3/components/rows/RowContext.d.ts +9 -0
  37. package/dist/components/Table3/components/rows/SkeletonRow.d.ts +10 -0
  38. package/dist/components/Table3/components/rows/styles.d.ts +6 -0
  39. package/dist/components/Table3/components/toolbar/ColumnSettings.d.ts +6 -0
  40. package/dist/components/Table3/components/toolbar/EditButton.d.ts +7 -0
  41. package/dist/components/Table3/components/toolbar/Filter/filters/Filters.d.ts +7 -0
  42. package/dist/components/Table3/components/toolbar/Filter/filters/components/Comparator.d.ts +11 -0
  43. package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +13 -0
  44. package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +8 -0
  45. package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.d.ts +7 -0
  46. package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterValue.d.ts +10 -0
  47. package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +11 -0
  48. package/dist/components/Table3/components/toolbar/FontSize.d.ts +7 -0
  49. package/dist/components/Table3/components/toolbar/PrintButton/PrintButton.d.ts +8 -0
  50. package/dist/components/Table3/components/toolbar/PrintButton/PrintIFrame.d.ts +8 -0
  51. package/dist/components/Table3/components/toolbar/PrintButton/hooks/useParentStylesheets.d.ts +1 -0
  52. package/dist/components/Table3/components/toolbar/RowHeight.d.ts +7 -0
  53. package/dist/components/Table3/components/toolbar/Search.d.ts +8 -0
  54. package/dist/components/Table3/components/toolbar/Toolbar.d.ts +12 -0
  55. package/dist/components/Table3/hooks/features/useColumnFreezing.d.ts +12 -0
  56. package/dist/components/Table3/hooks/features/useColumnOrdering.d.ts +6 -0
  57. package/dist/components/Table3/hooks/features/useCurrentRow.d.ts +9 -0
  58. package/dist/components/Table3/hooks/features/useEditing.d.ts +31 -0
  59. package/dist/components/Table3/hooks/features/useFontSize.d.ts +7 -0
  60. package/dist/components/Table3/hooks/features/usePauseHoverState.d.ts +6 -0
  61. package/dist/components/Table3/hooks/features/usePrinting.d.ts +5 -0
  62. package/dist/components/Table3/hooks/features/useRowClick.d.ts +7 -0
  63. package/dist/components/Table3/hooks/features/useRowDrag.d.ts +6 -0
  64. package/dist/components/Table3/hooks/features/useRowDrop.d.ts +5 -0
  65. package/dist/components/Table3/hooks/features/useRowGoto.d.ts +5 -0
  66. package/dist/components/Table3/hooks/features/useRowHeight.d.ts +7 -0
  67. package/dist/components/Table3/hooks/features/useRowSelection.d.ts +6 -0
  68. package/dist/components/Table3/hooks/features/useSearch.d.ts +16 -0
  69. package/dist/components/Table3/hooks/listeners/useCurrentRowListener.d.ts +2 -0
  70. package/dist/components/Table3/hooks/listeners/useEditingStateListener.d.ts +2 -0
  71. package/dist/components/Table3/hooks/listeners/useFilteringStateListener.d.ts +3 -0
  72. package/dist/components/Table3/hooks/listeners/useRowSelectionListener.d.ts +3 -0
  73. package/dist/components/Table3/hooks/listeners/useSearchStateListener.d.ts +3 -0
  74. package/dist/components/Table3/hooks/listeners/useServerLoadingListener.d.ts +3 -0
  75. package/dist/components/Table3/hooks/listeners/useSettingsStateListener.d.ts +3 -0
  76. package/dist/components/Table3/hooks/listeners/useShortcutsListener.d.ts +3 -0
  77. package/dist/components/Table3/hooks/listeners/useSortingStateListener.d.ts +3 -0
  78. package/dist/components/Table3/hooks/useConvertChildrenToColumns.d.ts +9 -0
  79. package/dist/components/Table3/hooks/useCssGrid.d.ts +5 -0
  80. package/dist/components/Table3/hooks/useCssVars.d.ts +6 -0
  81. package/dist/components/Table3/hooks/useTable.d.ts +63 -0
  82. package/dist/components/Table3/hooks/useTableData.d.ts +23 -0
  83. package/dist/components/Table3/hooks/useTablePreset.d.ts +2 -0
  84. package/dist/components/Table3/hooks/useTableRefInstanceSetup.d.ts +4 -0
  85. package/dist/components/Table3/strategies/index.d.ts +4 -0
  86. package/dist/components/Table3/strategies/virtualised.d.ts +4 -0
  87. package/dist/components/Table3/types.d.ts +310 -0
  88. package/dist/components/Table3/util/columns.d.ts +7 -0
  89. package/dist/components/Table3/util/editing.d.ts +4 -0
  90. package/dist/components/Table3/util/filtering.d.ts +3 -0
  91. package/dist/components/Tag/Tag.d.ts +1 -1
  92. package/dist/esm/index.css +130 -2
  93. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js +2 -2
  94. package/dist/esm/node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js.map +1 -1
  95. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +2 -1
  96. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  97. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js +4 -1
  98. package/dist/esm/packages/taco/src/components/Datepicker/useDatepicker.js.map +1 -1
  99. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +1 -1
  100. package/dist/esm/packages/taco/src/components/Icon/components/FontSize.js +19 -0
  101. package/dist/esm/packages/taco/src/components/Icon/components/FontSize.js.map +1 -0
  102. package/dist/esm/packages/taco/src/components/Icon/components/{DensitySpacious.js → HeightExtraTall.js} +4 -4
  103. package/dist/esm/packages/taco/src/components/Icon/components/{DensitySpacious.js.map → HeightExtraTall.js.map} +1 -1
  104. package/dist/esm/packages/taco/src/components/Icon/components/{DensityNormal.js → HeightMedium.js} +4 -4
  105. package/dist/esm/packages/taco/src/components/Icon/components/HeightMedium.js.map +1 -0
  106. package/dist/esm/packages/taco/src/components/Icon/components/{DensityCompact.js → HeightShort.js} +4 -4
  107. package/dist/esm/packages/taco/src/components/Icon/components/HeightShort.js.map +1 -0
  108. package/dist/esm/packages/taco/src/components/Icon/components/{DensityComfortable.js → HeightTall.js} +4 -4
  109. package/dist/esm/packages/taco/src/components/Icon/components/HeightTall.js.map +1 -0
  110. package/dist/esm/packages/taco/src/components/Icon/components/index.js +10 -8
  111. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  112. package/dist/esm/packages/taco/src/components/Menu/Menu.js +2 -0
  113. package/dist/esm/packages/taco/src/components/Menu/Menu.js.map +1 -1
  114. package/dist/esm/packages/taco/src/components/Menu/components/Item.js +20 -2
  115. package/dist/esm/packages/taco/src/components/Menu/components/Item.js.map +1 -1
  116. package/dist/esm/packages/taco/src/components/Menu/components/SubMenu.js +22 -0
  117. package/dist/esm/packages/taco/src/components/Menu/components/SubMenu.js.map +1 -0
  118. package/dist/esm/packages/taco/src/components/Popover/Popover.js +11 -3
  119. package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
  120. package/dist/esm/packages/taco/src/components/Provider/Localization.js +145 -0
  121. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  122. package/dist/esm/packages/taco/src/components/SearchInput/SearchInput.js.map +1 -1
  123. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +196 -0
  124. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -0
  125. package/dist/esm/packages/taco/src/components/Shortcut/Shortcut.js.map +1 -1
  126. package/dist/esm/packages/taco/src/components/Switch/Switch.js +3 -1
  127. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  128. package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +1 -1
  129. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +13 -1
  130. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +1 -1
  131. package/dist/esm/packages/taco/src/components/Table2/components/Search.js +1 -1
  132. package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +1 -1
  133. package/dist/esm/packages/taco/src/components/Table3/Table3.js +145 -0
  134. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -0
  135. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +27 -0
  136. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -0
  137. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +131 -0
  138. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -0
  139. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +286 -0
  140. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -0
  141. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js +74 -0
  142. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Indicator.js.map +1 -0
  143. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js +50 -0
  144. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js.map +1 -0
  145. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js +30 -0
  146. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js.map +1 -0
  147. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Goto.js +27 -0
  148. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Goto.js.map +1 -0
  149. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js +134 -0
  150. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -0
  151. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +156 -0
  152. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -0
  153. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Resizer.js +42 -0
  154. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Resizer.js.map +1 -0
  155. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/SortIndicator.js +38 -0
  156. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/SortIndicator.js.map +1 -0
  157. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +108 -0
  158. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -0
  159. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js +86 -0
  160. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Drag.js.map +1 -0
  161. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +124 -0
  162. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -0
  163. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js +103 -0
  164. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Expansion.js.map +1 -0
  165. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js +121 -0
  166. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Selection.js.map +1 -0
  167. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +17 -0
  168. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -0
  169. package/dist/esm/packages/taco/src/components/Table3/components/rows/ExpandedRow.js +27 -0
  170. package/dist/esm/packages/taco/src/components/Table3/components/rows/ExpandedRow.js.map +1 -0
  171. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +255 -0
  172. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -0
  173. package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js +13 -0
  174. package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js.map +1 -0
  175. package/dist/esm/packages/taco/src/components/Table3/components/rows/SkeletonRow.js +43 -0
  176. package/dist/esm/packages/taco/src/components/Table3/components/rows/SkeletonRow.js.map +1 -0
  177. package/dist/esm/packages/taco/src/components/Table3/components/rows/styles.js +9 -0
  178. package/dist/esm/packages/taco/src/components/Table3/components/rows/styles.js.map +1 -0
  179. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +105 -0
  180. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js.map +1 -0
  181. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/EditButton.js +45 -0
  182. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/EditButton.js.map +1 -0
  183. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +148 -0
  184. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -0
  185. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +107 -0
  186. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -0
  187. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +28 -0
  188. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -0
  189. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +60 -0
  190. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -0
  191. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js +89 -0
  192. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js.map +1 -0
  193. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +45 -0
  194. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +1 -0
  195. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js +25 -0
  196. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js.map +1 -0
  197. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +99 -0
  198. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -0
  199. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +224 -0
  200. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -0
  201. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/hooks/useParentStylesheets.js +88 -0
  202. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/hooks/useParentStylesheets.js.map +1 -0
  203. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js +26 -0
  204. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js.map +1 -0
  205. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +137 -0
  206. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -0
  207. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js +85 -0
  208. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Toolbar.js.map +1 -0
  209. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js +87 -0
  210. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js.map +1 -0
  211. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnOrdering.js +45 -0
  212. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnOrdering.js.map +1 -0
  213. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js +52 -0
  214. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useCurrentRow.js.map +1 -0
  215. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +197 -0
  216. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js.map +1 -0
  217. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useFontSize.js +13 -0
  218. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useFontSize.js.map +1 -0
  219. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseHoverState.js +19 -0
  220. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseHoverState.js.map +1 -0
  221. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePrinting.js +9 -0
  222. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePrinting.js.map +1 -0
  223. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js +25 -0
  224. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowClick.js.map +1 -0
  225. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowDrag.js +13 -0
  226. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowDrag.js.map +1 -0
  227. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowDrop.js +9 -0
  228. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowDrop.js.map +1 -0
  229. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowGoto.js +9 -0
  230. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowGoto.js.map +1 -0
  231. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowHeight.js +27 -0
  232. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowHeight.js.map +1 -0
  233. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js +29 -0
  234. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useRowSelection.js.map +1 -0
  235. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js +27 -0
  236. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js.map +1 -0
  237. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js +14 -0
  238. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useCurrentRowListener.js.map +1 -0
  239. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js +24 -0
  240. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useEditingStateListener.js.map +1 -0
  241. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useFilteringStateListener.js +19 -0
  242. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useFilteringStateListener.js.map +1 -0
  243. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useRowSelectionListener.js +19 -0
  244. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useRowSelectionListener.js.map +1 -0
  245. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSearchStateListener.js +51 -0
  246. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSearchStateListener.js.map +1 -0
  247. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useServerLoadingListener.js +16 -0
  248. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useServerLoadingListener.js.map +1 -0
  249. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +26 -0
  250. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -0
  251. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js +49 -0
  252. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useShortcutsListener.js.map +1 -0
  253. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSortingStateListener.js +17 -0
  254. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSortingStateListener.js.map +1 -0
  255. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +116 -0
  256. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -0
  257. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +56 -0
  258. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -0
  259. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +61 -0
  260. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -0
  261. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +154 -0
  262. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -0
  263. package/dist/esm/packages/taco/src/components/Table3/hooks/useTableData.js +128 -0
  264. package/dist/esm/packages/taco/src/components/Table3/hooks/useTableData.js.map +1 -0
  265. package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js +98 -0
  266. package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js.map +1 -0
  267. package/dist/esm/packages/taco/src/components/Table3/hooks/useTableRefInstanceSetup.js +19 -0
  268. package/dist/esm/packages/taco/src/components/Table3/hooks/useTableRefInstanceSetup.js.map +1 -0
  269. package/dist/esm/packages/taco/src/components/Table3/strategies/index.js +8 -0
  270. package/dist/esm/packages/taco/src/components/Table3/strategies/index.js.map +1 -0
  271. package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.js +113 -0
  272. package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.js.map +1 -0
  273. package/dist/esm/packages/taco/src/components/Table3/types.js +18 -0
  274. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -0
  275. package/dist/esm/packages/taco/src/components/Table3/util/columns.js +39 -0
  276. package/dist/esm/packages/taco/src/components/Table3/util/columns.js.map +1 -0
  277. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +41 -0
  278. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -0
  279. package/dist/esm/packages/taco/src/components/Table3/util/filtering.js +102 -0
  280. package/dist/esm/packages/taco/src/components/Table3/util/filtering.js.map +1 -0
  281. package/dist/esm/packages/taco/src/hooks/useGlobalKeyDown.js +10 -5
  282. package/dist/esm/packages/taco/src/hooks/useGlobalKeyDown.js.map +1 -1
  283. package/dist/esm/packages/taco/src/hooks/useLazyEffect.js +16 -0
  284. package/dist/esm/packages/taco/src/hooks/useLazyEffect.js.map +1 -0
  285. package/dist/esm/packages/taco/src/index.js +5 -1
  286. package/dist/esm/packages/taco/src/index.js.map +1 -1
  287. package/dist/esm/packages/taco/src/primitives/Button.js +6 -17
  288. package/dist/esm/packages/taco/src/primitives/Button.js.map +1 -1
  289. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +6 -6
  290. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -1
  291. package/dist/esm/packages/taco/src/utils/input.js +14 -1
  292. package/dist/esm/packages/taco/src/utils/input.js.map +1 -1
  293. package/dist/hooks/useGlobalKeyDown.d.ts +1 -1
  294. package/dist/hooks/useLazyEffect.d.ts +2 -0
  295. package/dist/index.css +130 -2
  296. package/dist/index.d.ts +3 -0
  297. package/dist/taco.cjs.development.js +5171 -240
  298. package/dist/taco.cjs.development.js.map +1 -1
  299. package/dist/taco.cjs.production.min.js +1 -1
  300. package/dist/taco.cjs.production.min.js.map +1 -1
  301. package/dist/utils/input.d.ts +1 -0
  302. package/package.json +2 -2
  303. package/types.json +2322 -25
  304. package/dist/esm/packages/taco/src/components/Icon/components/DensityComfortable.js.map +0 -1
  305. package/dist/esm/packages/taco/src/components/Icon/components/DensityCompact.js.map +0 -1
  306. package/dist/esm/packages/taco/src/components/Icon/components/DensityNormal.js.map +0 -1
  307. /package/dist/components/Icon/components/{DensityComfortable.d.ts → FontSize.d.ts} +0 -0
  308. /package/dist/components/Icon/components/{DensityCompact.d.ts → HeightExtraTall.d.ts} +0 -0
  309. /package/dist/components/Icon/components/{DensityNormal.d.ts → HeightMedium.d.ts} +0 -0
  310. /package/dist/components/Icon/components/{DensitySpacious.d.ts → HeightShort.d.ts} +0 -0
@@ -0,0 +1,154 @@
1
+ import React__default from 'react';
2
+ import { getFilteredRowModel, getSortedRowModel, useReactTable, getCoreRowModel } from '@tanstack/react-table';
3
+ import { useCurrentRow } from './features/useCurrentRow.js';
4
+ import { usePauseHoverState } from './features/usePauseHoverState.js';
5
+ import { useTablePreset } from './useTablePreset.js';
6
+ import { useRowHeight } from './features/useRowHeight.js';
7
+ import { useFontSize } from './features/useFontSize.js';
8
+ import { useRowSelectionListener } from './listeners/useRowSelectionListener.js';
9
+ import { useRowDrag } from './features/useRowDrag.js';
10
+ import { useSettingsStateListener } from './listeners/useSettingsStateListener.js';
11
+ import { columnFilterFn, globalFilterFn } from '../util/filtering.js';
12
+ import { useSortingStateListener } from './listeners/useSortingStateListener.js';
13
+ import { useFilteringStateListener } from './listeners/useFilteringStateListener.js';
14
+ import { useCurrentRowListener } from './listeners/useCurrentRowListener.js';
15
+ import { useColumnFreezing } from './features/useColumnFreezing.js';
16
+ import { useRowSelection } from './features/useRowSelection.js';
17
+ import { useRowClick } from './features/useRowClick.js';
18
+ import { useSearchStateListener } from './listeners/useSearchStateListener.js';
19
+ import { useEditing } from './features/useEditing.js';
20
+ import { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering.js';
21
+ import { useRowDrop } from './features/useRowDrop.js';
22
+ import { useConvertChildrenToColumns } from './useConvertChildrenToColumns.js';
23
+ import { usePrinting } from './features/usePrinting.js';
24
+ import { useShortcutsListener } from './listeners/useShortcutsListener.js';
25
+ import { useRowGoto } from './features/useRowGoto.js';
26
+ import { useServerLoadingListener } from './listeners/useServerLoadingListener.js';
27
+ import { useEditingStateListener } from './listeners/useEditingStateListener.js';
28
+ import { useSearch } from './features/useSearch.js';
29
+
30
+ function useTable(props) {
31
+ var _props$defaultSetting, _props$defaultSetting2, _props$defaultSetting3, _props$defaultSetting4, _props$defaultSetting5, _props$defaultSetting6, _props$defaultSetting7, _props$length;
32
+ // options
33
+ const options = useTablePreset(props);
34
+ const tableOptions = {
35
+ enableColumnFilters: options.enableFiltering,
36
+ enableColumnResizing: options.enableColumnResizing,
37
+ enableExpanding: options.enableRowExpansion,
38
+ enableGlobalFilter: options.enableSearch,
39
+ enableHiding: options.enableColumnHiding,
40
+ enableRowSelection: options.enableRowSelection,
41
+ enableMultiRowSelection: !options.enableRowSelectionSingle,
42
+ enableSorting: options.enableSorting
43
+ };
44
+ // resizing
45
+ if (tableOptions.enableColumnResizing) {
46
+ tableOptions.columnResizeMode = 'onChange';
47
+ }
48
+ // filtering
49
+ if (tableOptions.enableColumnFilters) {
50
+ if (props.onFilter) {
51
+ tableOptions.manualFiltering = true;
52
+ // onFilter is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange
53
+ } else {
54
+ tableOptions.filterFns = {
55
+ tacoFilter: (row, columnId, filter) => columnFilterFn(row.getValue(columnId), filter)
56
+ };
57
+ tableOptions.getFilteredRowModel = getFilteredRowModel();
58
+ }
59
+ }
60
+ // search
61
+ if (tableOptions.enableGlobalFilter) {
62
+ if (props.onSearch) {
63
+ tableOptions.manualFiltering = true;
64
+ // onSearch is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange
65
+ } else {
66
+ tableOptions.globalFilterFn = (row, columnId, searchQuery) => globalFilterFn(row.getValue(columnId), searchQuery);
67
+ tableOptions.getFilteredRowModel = getFilteredRowModel();
68
+ }
69
+ }
70
+ // sorting
71
+ if (options.enableSorting) {
72
+ if (props.onSort) {
73
+ tableOptions.manualSorting = true;
74
+ // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange
75
+ } else {
76
+ tableOptions.getSortedRowModel = getSortedRowModel();
77
+ }
78
+ }
79
+ // custom features
80
+ const columnFreezing = useColumnFreezing((_props$defaultSetting = (_props$defaultSetting2 = props.defaultSettings) === null || _props$defaultSetting2 === void 0 ? void 0 : _props$defaultSetting2.columnFreezingIndex) !== null && _props$defaultSetting !== void 0 ? _props$defaultSetting : props.defaultColumnFreezingIndex, options);
81
+ const columnOrdering = useColumnOrdering(options);
82
+ const currentRow = useCurrentRow(props.defaultCurrentRowIndex);
83
+ const editing = useEditing(options.enableEditing, props.onSave);
84
+ const fontSize = useFontSize(options.enableFontSize, (_props$defaultSetting3 = props.defaultSettings) === null || _props$defaultSetting3 === void 0 ? void 0 : _props$defaultSetting3.fontSize);
85
+ const hoverState = usePauseHoverState();
86
+ const printing = usePrinting(options.enablePrinting, props.loadAll);
87
+ const rowClick = useRowClick(props.onRowClick);
88
+ const rowDrag = useRowDrag(options.enableRowDrag);
89
+ const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);
90
+ const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);
91
+ const rowHeight = useRowHeight(options.enableRowHeight, (_props$defaultSetting4 = (_props$defaultSetting5 = props.defaultSettings) === null || _props$defaultSetting5 === void 0 ? void 0 : _props$defaultSetting5.rowHeight) !== null && _props$defaultSetting4 !== void 0 ? _props$defaultSetting4 : (_props$defaultSetting6 = props.defaultSettings) === null || _props$defaultSetting6 === void 0 ? void 0 : _props$defaultSetting6.rowDensity);
92
+ const rowSelection = useRowSelection();
93
+ const search = useSearch(options.enableSearch, (_props$defaultSetting7 = props.defaultSettings) === null || _props$defaultSetting7 === void 0 ? void 0 : _props$defaultSetting7.excludeUnmatchedRecordsInSearch, props.loadAll);
94
+ // columns
95
+ const {
96
+ columns,
97
+ defaultColumnSizing,
98
+ defaultColumnVisibility,
99
+ defaultSorting
100
+ } = useConvertChildrenToColumns(props, options, editing);
101
+ // built-in features
102
+ const initialState = React__default.useMemo(() => {
103
+ var _props$defaultSetting8, _props$defaultSetting9, _props$defaultSetting10, _props$defaultSetting11, _props$defaultSetting12, _props$defaultSetting13, _props$defaultSetting14;
104
+ const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);
105
+ return {
106
+ columnOrder: ensureOrdering(columns, (_props$defaultSetting8 = props.defaultSettings) === null || _props$defaultSetting8 === void 0 ? void 0 : _props$defaultSetting8.columnOrder),
107
+ columnSizing: (_props$defaultSetting9 = (_props$defaultSetting10 = props.defaultSettings) === null || _props$defaultSetting10 === void 0 ? void 0 : _props$defaultSetting10.columnSizing) !== null && _props$defaultSetting9 !== void 0 ? _props$defaultSetting9 : defaultColumnSizing,
108
+ columnVisibility: (_props$defaultSetting11 = (_props$defaultSetting12 = props.defaultSettings) === null || _props$defaultSetting12 === void 0 ? void 0 : _props$defaultSetting12.columnVisibility) !== null && _props$defaultSetting11 !== void 0 ? _props$defaultSetting11 : defaultColumnVisibility,
109
+ sorting: (_props$defaultSetting13 = props.defaultSettings) !== null && _props$defaultSetting13 !== void 0 && _props$defaultSetting13.sorting ? (_props$defaultSetting14 = props.defaultSettings) === null || _props$defaultSetting14 === void 0 ? void 0 : _props$defaultSetting14.sorting.filter(sanitizeSortedColumns) : defaultSorting
110
+ };
111
+ }, []);
112
+ const table = useReactTable({
113
+ data: props.data,
114
+ columns,
115
+ getCoreRowModel: getCoreRowModel(),
116
+ initialState,
117
+ ...tableOptions,
118
+ //debugAll: true,
119
+ meta: {
120
+ columnFreezing,
121
+ columnOrdering,
122
+ currentRow,
123
+ editing,
124
+ fontSize,
125
+ hoverState,
126
+ isUsingServer: !!props.loadPage,
127
+ printing,
128
+ rowClick: rowClick,
129
+ rowDrag,
130
+ rowDrop,
131
+ rowGoto,
132
+ rowHeight,
133
+ rowSelection,
134
+ search
135
+ }
136
+ });
137
+ // listeners
138
+ useCurrentRowListener(table);
139
+ useEditingStateListener(table);
140
+ useFilteringStateListener(table, props.onFilter);
141
+ useRowSelectionListener(table, props.onRowSelect);
142
+ useSearchStateListener(table, props.onSearch);
143
+ useSettingsStateListener(table, props.onChangeSettings);
144
+ useShortcutsListener(table, props.shortcuts);
145
+ useServerLoadingListener(table, props.loadPage);
146
+ useSortingStateListener(table, props.onSort);
147
+ return {
148
+ table,
149
+ length: (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : props.data.length
150
+ };
151
+ }
152
+
153
+ export { useTable };
154
+ //# sourceMappingURL=useTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/components/Table3/hooks/useTable.tsx"],"sourcesContent":["import React from 'react';\nimport {\n getCoreRowModel,\n useReactTable,\n Row as RTRow,\n RowData,\n TableOptions as RTableOptions,\n TableState,\n getSortedRowModel,\n getFilteredRowModel,\n} from '@tanstack/react-table';\nimport {\n Table3ColumnAlignment,\n Table3ColumnRenderer,\n Table3Props,\n Table3ColumnHeaderMenu,\n Table3ColumnControlRenderer,\n Table3ColumnDataType,\n Table3ColumnClassNameHandler,\n Table3ColumnFooterRenderer,\n TableStrategy,\n} from '../types';\nimport { useCurrentRow } from './features/useCurrentRow';\nimport { usePauseHoverState } from './features/usePauseHoverState';\nimport { useTablePreset } from './useTablePreset';\nimport { useRowHeight } from './features/useRowHeight';\nimport { useFontSize } from './features/useFontSize';\nimport { useRowSelectionListener } from './listeners/useRowSelectionListener';\nimport { useRowDrag } from './features/useRowDrag';\nimport { useSettingsStateListener } from './listeners/useSettingsStateListener';\nimport { columnFilterFn, globalFilterFn } from '../util/filtering';\nimport { useSortingStateListener } from './listeners/useSortingStateListener';\nimport { useFilteringStateListener } from './listeners/useFilteringStateListener';\nimport { useCurrentRowListener } from './listeners/useCurrentRowListener';\nimport { useColumnFreezing } from './features/useColumnFreezing';\nimport { useRowSelection } from './features/useRowSelection';\nimport { useRowClick } from './features/useRowClick';\nimport { useSearchStateListener } from './listeners/useSearchStateListener';\nimport { ensureOrdering, useColumnOrdering } from './features/useColumnOrdering';\nimport { useRowDrop } from './features/useRowDrop';\nimport { useConvertChildrenToColumns } from './useConvertChildrenToColumns';\nimport { useEditing } from './features/useEditing';\nimport { usePrinting } from './features/usePrinting';\nimport { useShortcutsListener } from './listeners/useShortcutsListener';\nimport { useRowGoto } from './features/useRowGoto';\nimport { useServerLoadingListener } from './listeners/useServerLoadingListener';\nimport { useEditingStateListener } from './listeners/useEditingStateListener';\nimport { useSearch } from './features/useSearch';\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useColumnFreezing>;\n columnOrdering: ReturnType<typeof useColumnOrdering>;\n currentRow: ReturnType<typeof useCurrentRow>;\n editing: ReturnType<typeof useEditing>;\n fontSize: ReturnType<typeof useFontSize>;\n hoverState: ReturnType<typeof usePauseHoverState>;\n isUsingServer: boolean;\n printing: ReturnType<typeof usePrinting>;\n rowClick: ReturnType<typeof useRowClick>;\n rowDrag: ReturnType<typeof useRowDrag>;\n rowDrop: ReturnType<typeof useRowDrop>;\n rowGoto: ReturnType<typeof useRowGoto>;\n rowHeight: ReturnType<typeof useRowHeight>;\n rowSelection: ReturnType<typeof useRowSelection>;\n search: ReturnType<typeof useSearch>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: Table3ColumnAlignment;\n // @ts-ignore -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n className?: Table3ColumnClassNameHandler<TData>;\n // @ts-ignore -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n control?: Table3ColumnControlRenderer<TData>;\n dataType?: Table3ColumnDataType;\n // @ts-ignore -- we ignore it because it conflicts with Table2 also overridding ColumnMeta\n defaultWidth?: number;\n enableOrdering: boolean;\n enableSearch: boolean;\n enableTruncate: boolean;\n footer?: Table3ColumnFooterRenderer;\n header: string;\n headerClassName?: string;\n menu?: Table3ColumnHeaderMenu;\n renderer?: Table3ColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n\n interface CellContext<TData extends RowData, TValue> {\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n }\n\n interface HeaderContext<TData extends RowData, TValue> {\n scrollToIndex: TableStrategy['scrollToIndex'];\n }\n}\n\nexport function useTable<TType = unknown>(props: Table3Props<TType>) {\n // options\n const options = useTablePreset(props);\n\n const tableOptions: Partial<RTableOptions<TType>> = {\n enableColumnFilters: options.enableFiltering,\n enableColumnResizing: options.enableColumnResizing,\n enableExpanding: options.enableRowExpansion,\n enableGlobalFilter: options.enableSearch,\n enableHiding: options.enableColumnHiding,\n enableRowSelection: options.enableRowSelection,\n enableMultiRowSelection: !options.enableRowSelectionSingle,\n enableSorting: options.enableSorting,\n };\n\n // resizing\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n // filtering\n if (tableOptions.enableColumnFilters) {\n if (props.onFilter) {\n tableOptions.manualFiltering = true;\n // onFilter is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange\n } else {\n tableOptions.filterFns = {\n tacoFilter: (row: RTRow<TType>, columnId: string, filter: any) => columnFilterFn(row.getValue(columnId), filter),\n };\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n }\n\n // search\n if (tableOptions.enableGlobalFilter) {\n if (props.onSearch) {\n tableOptions.manualFiltering = true;\n // onSearch is called as a listener to let the consumer update their data, so we don't use onColumnFiltersChange\n } else {\n tableOptions.globalFilterFn = (row: RTRow<TType>, columnId: string, searchQuery: string) =>\n globalFilterFn(row.getValue(columnId), searchQuery);\n tableOptions.getFilteredRowModel = getFilteredRowModel();\n }\n }\n\n // sorting\n if (options.enableSorting) {\n if (props.onSort) {\n tableOptions.manualSorting = true;\n // onSort is called as a listener to let the consumer update their data, so we don't use onSortingChange\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n // custom features\n const columnFreezing = useColumnFreezing(\n props.defaultSettings?.columnFreezingIndex ?? props.defaultColumnFreezingIndex,\n options\n );\n const columnOrdering = useColumnOrdering(options);\n const currentRow = useCurrentRow(props.defaultCurrentRowIndex);\n const editing = useEditing(options.enableEditing, props.onSave);\n const fontSize = useFontSize(options.enableFontSize, props.defaultSettings?.fontSize);\n const hoverState = usePauseHoverState();\n const printing = usePrinting(options.enablePrinting, props.loadAll);\n const rowClick = useRowClick<TType>(props.onRowClick);\n const rowDrag = useRowDrag(options.enableRowDrag);\n const rowDrop = useRowDrop(options.enableRowDrop, props.onRowDrop);\n const rowGoto = useRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowHeight = useRowHeight(\n options.enableRowHeight,\n props.defaultSettings?.rowHeight ?? props.defaultSettings?.rowDensity\n );\n const rowSelection = useRowSelection();\n const search = useSearch(options.enableSearch, props.defaultSettings?.excludeUnmatchedRecordsInSearch, props.loadAll);\n\n // columns\n const { columns, defaultColumnSizing, defaultColumnVisibility, defaultSorting } = useConvertChildrenToColumns<TType>(\n props,\n options,\n editing\n );\n\n // built-in features\n const initialState: Partial<TableState> = React.useMemo(() => {\n const sanitizeSortedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n return {\n columnOrder: ensureOrdering<TType>(columns, props.defaultSettings?.columnOrder),\n columnSizing: props.defaultSettings?.columnSizing ?? defaultColumnSizing,\n columnVisibility: props.defaultSettings?.columnVisibility ?? defaultColumnVisibility,\n sorting: props.defaultSettings?.sorting\n ? props.defaultSettings?.sorting.filter(sanitizeSortedColumns)\n : defaultSorting,\n };\n }, []);\n\n const table = useReactTable<TType>({\n data: props.data,\n columns,\n getCoreRowModel: getCoreRowModel(),\n initialState,\n ...tableOptions,\n //debugAll: true,\n meta: {\n columnFreezing,\n columnOrdering,\n currentRow,\n editing,\n fontSize,\n hoverState,\n isUsingServer: !!props.loadPage,\n printing,\n rowClick: rowClick as any,\n rowDrag,\n rowDrop,\n rowGoto,\n rowHeight,\n rowSelection,\n search,\n },\n });\n\n // listeners\n useCurrentRowListener(table);\n useEditingStateListener(table);\n useFilteringStateListener(table, props.onFilter);\n useRowSelectionListener(table, props.onRowSelect);\n useSearchStateListener(table, props.onSearch);\n useSettingsStateListener(table, props.onChangeSettings);\n useShortcutsListener(table, props.shortcuts);\n useServerLoadingListener(table, props.loadPage);\n useSortingStateListener(table, props.onSort);\n\n return { table, length: props.length ?? props.data.length };\n}\n"],"names":["useTable","props","options","useTablePreset","tableOptions","enableColumnFilters","enableFiltering","enableColumnResizing","enableExpanding","enableRowExpansion","enableGlobalFilter","enableSearch","enableHiding","enableColumnHiding","enableRowSelection","enableMultiRowSelection","enableRowSelectionSingle","enableSorting","columnResizeMode","onFilter","manualFiltering","filterFns","tacoFilter","row","columnId","filter","columnFilterFn","getValue","getFilteredRowModel","onSearch","globalFilterFn","searchQuery","onSort","manualSorting","getSortedRowModel","columnFreezing","useColumnFreezing","defaultSettings","columnFreezingIndex","defaultColumnFreezingIndex","columnOrdering","useColumnOrdering","currentRow","useCurrentRow","defaultCurrentRowIndex","editing","useEditing","enableEditing","onSave","fontSize","useFontSize","enableFontSize","hoverState","usePauseHoverState","printing","usePrinting","enablePrinting","loadAll","rowClick","useRowClick","onRowClick","rowDrag","useRowDrag","enableRowDrag","rowDrop","useRowDrop","enableRowDrop","onRowDrop","rowGoto","useRowGoto","enableRowGoto","onRowGoto","rowHeight","useRowHeight","enableRowHeight","rowDensity","rowSelection","useRowSelection","search","useSearch","excludeUnmatchedRecordsInSearch","columns","defaultColumnSizing","defaultColumnVisibility","defaultSorting","useConvertChildrenToColumns","initialState","React","useMemo","sanitizeSortedColumns","column","find","definedColumn","id","columnOrder","ensureOrdering","columnSizing","columnVisibility","sorting","table","useReactTable","data","getCoreRowModel","meta","isUsingServer","loadPage","useCurrentRowListener","useEditingStateListener","useFilteringStateListener","useRowSelectionListener","onRowSelect","useSearchStateListener","useSettingsStateListener","onChangeSettings","useShortcutsListener","shortcuts","useServerLoadingListener","useSortingStateListener","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAkGgBA,QAAQ,CAAkBC,KAAyB;;;EAE/D,MAAMC,OAAO,GAAGC,cAAc,CAACF,KAAK,CAAC;EAErC,MAAMG,YAAY,GAAkC;IAChDC,mBAAmB,EAAEH,OAAO,CAACI,eAAe;IAC5CC,oBAAoB,EAAEL,OAAO,CAACK,oBAAoB;IAClDC,eAAe,EAAEN,OAAO,CAACO,kBAAkB;IAC3CC,kBAAkB,EAAER,OAAO,CAACS,YAAY;IACxCC,YAAY,EAAEV,OAAO,CAACW,kBAAkB;IACxCC,kBAAkB,EAAEZ,OAAO,CAACY,kBAAkB;IAC9CC,uBAAuB,EAAE,CAACb,OAAO,CAACc,wBAAwB;IAC1DC,aAAa,EAAEf,OAAO,CAACe;GAC1B;;EAGD,IAAIb,YAAY,CAACG,oBAAoB,EAAE;IACnCH,YAAY,CAACc,gBAAgB,GAAG,UAAU;;;EAI9C,IAAId,YAAY,CAACC,mBAAmB,EAAE;IAClC,IAAIJ,KAAK,CAACkB,QAAQ,EAAE;MAChBf,YAAY,CAACgB,eAAe,GAAG,IAAI;;KAEtC,MAAM;MACHhB,YAAY,CAACiB,SAAS,GAAG;QACrBC,UAAU,EAAE,CAACC,GAAiB,EAAEC,QAAgB,EAAEC,MAAW,KAAKC,cAAc,CAACH,GAAG,CAACI,QAAQ,CAACH,QAAQ,CAAC,EAAEC,MAAM;OAClH;MACDrB,YAA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rH,KAAK,CAACoG,IAAI,CAACiB;GAAQ;AAC/D;;;;"}
@@ -0,0 +1,128 @@
1
+ import React__default from 'react';
2
+ import { _finallyRethrows, _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
3
+
4
+ function useTableData(fetch, fetchAll, options = {
5
+ pageSize: 100
6
+ }) {
7
+ const {
8
+ pageSize
9
+ } = options;
10
+ // track the data length, we don't know it until the first request
11
+ const length = React__default.useRef(undefined);
12
+ // data will be filled after the first request, then we'll update values in place
13
+ const [data, setData] = React__default.useState([]);
14
+ // track which pages have been loaded to dedupe requests
15
+ const _pendingPageRequests = React__default.useRef({});
16
+ const lastUsedSorting = React__default.useRef([]);
17
+ const lastUsedFilters = React__default.useRef([]);
18
+ const lastUsedSearch = React__default.useRef();
19
+ const loadPage = function (pageIndex, sorting, filters, search) {
20
+ try {
21
+ let reset = false;
22
+ // sorting or filters changed, reset everything
23
+ if (JSON.stringify(sorting) !== JSON.stringify(lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(lastUsedFilters.current) || search !== lastUsedSearch.current) {
24
+ _pendingPageRequests.current = {};
25
+ // nuke the dataset so that we "start again" after sorting
26
+ reset = true;
27
+ }
28
+ if (_pendingPageRequests.current[pageIndex]) {
29
+ // if page is already loaded/loading, abort, otherwise mark it as loading
30
+ return Promise.resolve();
31
+ } else {
32
+ _pendingPageRequests.current[pageIndex] = true;
33
+ }
34
+ // set the sorting so we can track if it changed between loads
35
+ lastUsedSorting.current = sorting;
36
+ // set the filters so we can track if it changed between loads
37
+ lastUsedFilters.current = filters;
38
+ // set the search so we can track if it changed between loads
39
+ lastUsedSearch.current = search;
40
+ const _temp = _finallyRethrows(function () {
41
+ return _catch(function () {
42
+ return Promise.resolve(fetch(pageIndex, pageSize, sorting, filters, search)).then(function (response) {
43
+ // update state, here we do some "magic" to support "load in place"
44
+ setData(currentData => {
45
+ let nextData;
46
+ // reset table state if:
47
+ // - the length isn't set at all (first load)
48
+ // - the client length and server length are different (the data changed)
49
+ if (reset || length.current !== response.length) {
50
+ length.current = response.length;
51
+ nextData = Array(length.current).fill(undefined);
52
+ } else {
53
+ nextData = [...currentData];
54
+ }
55
+ const startIndex = pageIndex * pageSize;
56
+ nextData.splice(startIndex, pageSize, ...response.data);
57
+ return nextData;
58
+ });
59
+ });
60
+ }, function () {});
61
+ }, function (_wasThrown, _result) {
62
+ _pendingPageRequests.current[pageIndex] = false;
63
+ if (_wasThrown) throw _result;
64
+ return _result;
65
+ });
66
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
67
+ } catch (e) {
68
+ return Promise.reject(e);
69
+ }
70
+ };
71
+ const loadAll = function (sorting, filters, search) {
72
+ try {
73
+ const _temp2 = _catch(function () {
74
+ return Promise.resolve(fetchAll(sorting, filters, search)).then(function (response) {
75
+ length.current = response.length;
76
+ setData(() => {
77
+ let nextData;
78
+ if (response.data.length !== response.length) {
79
+ nextData = Array(response.length).fill(undefined);
80
+ nextData.splice(0, response.data.length, ...response.data);
81
+ } else {
82
+ nextData = [...response.data];
83
+ }
84
+ return nextData;
85
+ });
86
+ });
87
+ }, function () {});
88
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
89
+ } catch (e) {
90
+ return Promise.reject(e);
91
+ }
92
+ };
93
+ // we reset the page to 0 whenever sorting, filtering or search changes
94
+ const handleSort = function (sorting) {
95
+ try {
96
+ return loadPage(0, sorting, lastUsedFilters.current, lastUsedSearch.current);
97
+ } catch (e) {
98
+ return Promise.reject(e);
99
+ }
100
+ };
101
+ const handleFilter = function (filters) {
102
+ try {
103
+ return loadPage(0, lastUsedSorting.current, filters, lastUsedSearch.current);
104
+ } catch (e) {
105
+ return Promise.reject(e);
106
+ }
107
+ };
108
+ const handleSearch = function (query) {
109
+ try {
110
+ return loadAll(lastUsedSorting.current, lastUsedFilters.current, query);
111
+ } catch (e) {
112
+ return Promise.reject(e);
113
+ }
114
+ };
115
+ return {
116
+ data,
117
+ length: length.current,
118
+ loadAll,
119
+ loadPage,
120
+ onFilter: handleFilter,
121
+ onSearch: handleSearch,
122
+ onSort: handleSort,
123
+ pageSize
124
+ };
125
+ }
126
+
127
+ export { useTableData };
128
+ //# sourceMappingURL=useTableData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTableData.js","sources":["../../../../../../../../src/components/Table3/hooks/useTableData.ts"],"sourcesContent":["import React from 'react';\nimport {\n ColumnFilter,\n Table3ColumnSort,\n Table3FilterHandler,\n Table3LoadAllHandler,\n Table3LoadPageHandler,\n Table3SearchHandler,\n Table3SortHandler,\n} from '../types';\n\nexport type useTable3DataFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTable3AllDataFetcher<TType = unknown> = (\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTable3DataOptions = { pageSize: number };\n\nexport type useTableDataValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: Table3LoadAllHandler;\n loadPage: Table3LoadPageHandler;\n onFilter: Table3FilterHandler;\n onSearch: Table3SearchHandler;\n onSort: Table3SortHandler;\n pageSize: number;\n};\n\nexport function useTableData<TType = unknown>(\n fetch: useTable3DataFetcher<TType>,\n fetchAll: useTable3AllDataFetcher<TType>,\n options: useTable3DataOptions = { pageSize: 100 }\n): useTableDataValues<TType> {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n const lastUsedSorting = React.useRef<Table3ColumnSort[]>([]);\n const lastUsedFilters = React.useRef<ColumnFilter[]>([]);\n const lastUsedSearch = React.useRef<string>();\n\n const loadPage = async (\n pageIndex: number,\n sorting: Table3ColumnSort[],\n filters: ColumnFilter[],\n search: string | undefined\n ) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n JSON.stringify(sorting) !== JSON.stringify(lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(lastUsedFilters.current) ||\n search !== lastUsedSearch.current\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n // set the sorting so we can track if it changed between loads\n lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n lastUsedFilters.current = filters;\n // set the search so we can track if it changed between loads\n lastUsedSearch.current = search;\n\n try {\n const response = await fetch(pageIndex, pageSize, sorting, filters, search);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: Table3ColumnSort[], filters: ColumnFilter[], search: string | undefined) => {\n try {\n const response = await fetchAll(sorting, filters, search);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n // we reset the page to 0 whenever sorting, filtering or search changes\n const handleSort = async (sorting: Table3ColumnSort[]) =>\n loadPage(0, sorting, lastUsedFilters.current, lastUsedSearch.current);\n const handleFilter = async (filters: ColumnFilter[]) => loadPage(0, lastUsedSorting.current, filters, lastUsedSearch.current);\n const handleSearch = async (query: string) => loadAll(lastUsedSorting.current, lastUsedFilters.current, query);\n\n return {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onFilter: handleFilter,\n onSearch: handleSearch as any,\n onSort: handleSort,\n pageSize,\n };\n}\n"],"names":["useTableData","fetch","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","lastUsedSorting","lastUsedFilters","lastUsedSearch","loadPage","pageIndex","sorting","filters","search","reset","JSON","stringify","current","response","currentData","nextData","Array","fill","startIndex","splice","loadAll","handleSort","handleFilter","handleSearch","query","onFilter","onSearch","onSort"],"mappings":";;;SAsCgBA,YAAY,CACxBC,KAAkC,EAClCC,QAAwC,EACxCC,UAAgC;EAAEC,QAAQ,EAAE;CAAK;EAEjD,MAAM;IAAEA;GAAU,GAAGD,OAAO;;EAG5B,MAAME,MAAM,GAAGC,cAAK,CAACC,MAAM,CAAqBC,SAAS,CAAC;;EAE1D,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGJ,cAAK,CAACK,QAAQ,CAAQ,EAAE,CAAC;;EAEjD,MAAMC,oBAAoB,GAAGN,cAAK,CAACC,MAAM,CAAC,EAAE,CAAC;EAC7C,MAAMM,eAAe,GAAGP,cAAK,CAACC,MAAM,CAAqB,EAAE,CAAC;EAC5D,MAAMO,eAAe,GAAGR,cAAK,CAACC,MAAM,CAAiB,EAAE,CAAC;EACxD,MAAMQ,cAAc,GAAGT,cAAK,CAACC,MAAM,EAAU;EAE7C,MAAMS,QAAQ,aACVC,SAAiB,EACjBC,OAA2B,EAC3BC,OAAuB,EACvBC,MAA0B;IAAA;MAE1B,IAAIC,KAAK,GAAG,KAAK;;MAGjB,IACIC,IAAI,CAACC,SAAS,CAACL,OAAO,CAAC,KAAKI,IAAI,CAACC,SAAS,CAACV,eAAe,CAACW,OAAO,CAAC,IACnEF,IAAI,CAACC,SAAS,CAACJ,OAAO,C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,EAAEH,YAAmB;IAC7BI,MAAM,EAAEN,UAAU;IAClB7B;GACH;AACL;;;;"}
@@ -0,0 +1,98 @@
1
+ import React__default from 'react';
2
+
3
+ const DEFAULT_ALL_DISABLED = {
4
+ enableColumnFreezing: false,
5
+ enableColumnHiding: false,
6
+ enableColumnOrdering: false,
7
+ enableColumnResizing: false,
8
+ enableFontSize: false,
9
+ enablePrinting: false,
10
+ enableRowDrag: false,
11
+ enableRowDrop: false,
12
+ enableRowExpansion: false,
13
+ enableRowGoto: false,
14
+ enableRowHeight: false,
15
+ enableRowSelection: false,
16
+ enableRowSelectionSingle: false,
17
+ enableEditing: false,
18
+ enableFiltering: false,
19
+ enableSearch: false,
20
+ enableSorting: false
21
+ };
22
+ const presets = {
23
+ display: {
24
+ enableColumnFreezing: true,
25
+ enableColumnHiding: true,
26
+ enableColumnOrdering: true,
27
+ enableColumnResizing: true,
28
+ enableFontSize: true,
29
+ enablePrinting: false,
30
+ enableRowDrag: true,
31
+ enableRowDrop: true,
32
+ enableRowExpansion: true,
33
+ enableRowGoto: true,
34
+ enableRowHeight: true,
35
+ enableRowSelection: true,
36
+ enableRowSelectionSingle: false,
37
+ enableEditing: false,
38
+ enableFiltering: true,
39
+ enableSearch: true,
40
+ enableSorting: true
41
+ },
42
+ editable: {
43
+ enableColumnFreezing: true,
44
+ enableColumnHiding: true,
45
+ enableColumnOrdering: true,
46
+ enableColumnResizing: true,
47
+ enableFontSize: true,
48
+ enablePrinting: false,
49
+ enableRowDrag: true,
50
+ enableRowDrop: true,
51
+ enableRowExpansion: true,
52
+ enableRowGoto: true,
53
+ enableRowHeight: true,
54
+ enableRowSelection: true,
55
+ enableRowSelectionSingle: false,
56
+ enableEditing: true,
57
+ enableFiltering: true,
58
+ enableSearch: true,
59
+ enableSorting: true
60
+ }
61
+ };
62
+ function useTablePreset(props) {
63
+ var _props$enableRowExpan, _props$enableRowSelec, _props$enableColumnFr, _props$enableColumnHi, _props$enableColumnOr, _props$enableColumnRe, _props$enableFontSize, _props$enablePrinting, _props$enableRowDrag, _props$enableRowDrop, _props$enableRowGoto, _props$enableRowHeigh, _props$enableRowSelec2, _props$enableEditing, _props$enableFilterin, _props$enableSearch, _props$enableSorting;
64
+ const presetOptions = props.preset ? presets[props.preset] : DEFAULT_ALL_DISABLED;
65
+ const enableRowExpansion = (_props$enableRowExpan = props.enableRowExpansion) !== null && _props$enableRowExpan !== void 0 ? _props$enableRowExpan : presetOptions.enableRowExpansion;
66
+ const enableRowSelection = (_props$enableRowSelec = props.enableRowSelection) !== null && _props$enableRowSelec !== void 0 ? _props$enableRowSelec : presetOptions.enableRowSelection;
67
+ // guard options that might be unintentionally broken
68
+ React__default.useEffect(() => {
69
+ if (enableRowExpansion && !props.expandedRowRenderer) {
70
+ console.warn(`Table3 (id: ${props.id}) - Row expansion is enabled but no \`expandedRowRenderer\` has been provided. Provide one to enable row expansion or set \`enableRowExpansion\` to \`false\`.`);
71
+ }
72
+ if (enableRowSelection && !props.onRowSelect) {
73
+ console.warn(`Table3 (id: ${props.id}) - Row selection is enabled but no \`onRowSelect\` handler has been provided. Provide one to enable row selection or set \`enableRowSelection\` to \`false\`.`);
74
+ }
75
+ }, []);
76
+ return {
77
+ enableColumnFreezing: (_props$enableColumnFr = props.enableColumnFreezing) !== null && _props$enableColumnFr !== void 0 ? _props$enableColumnFr : presetOptions.enableColumnFreezing,
78
+ enableColumnHiding: (_props$enableColumnHi = props.enableColumnHiding) !== null && _props$enableColumnHi !== void 0 ? _props$enableColumnHi : presetOptions.enableColumnHiding,
79
+ enableColumnOrdering: (_props$enableColumnOr = props.enableColumnOrdering) !== null && _props$enableColumnOr !== void 0 ? _props$enableColumnOr : presetOptions.enableColumnOrdering,
80
+ enableColumnResizing: (_props$enableColumnRe = props.enableColumnResizing) !== null && _props$enableColumnRe !== void 0 ? _props$enableColumnRe : presetOptions.enableColumnResizing,
81
+ enableFontSize: (_props$enableFontSize = props.enableFontSize) !== null && _props$enableFontSize !== void 0 ? _props$enableFontSize : presetOptions.enableFontSize,
82
+ enablePrinting: (_props$enablePrinting = props.enablePrinting) !== null && _props$enablePrinting !== void 0 ? _props$enablePrinting : presetOptions.enablePrinting,
83
+ enableRowDrag: ((_props$enableRowDrag = props.enableRowDrag) !== null && _props$enableRowDrag !== void 0 ? _props$enableRowDrag : presetOptions.enableRowDrag) && !!props.onRowDrag,
84
+ enableRowDrop: ((_props$enableRowDrop = props.enableRowDrop) !== null && _props$enableRowDrop !== void 0 ? _props$enableRowDrop : presetOptions.enableRowDrop) && !!props.onRowDrop,
85
+ enableRowExpansion: enableRowExpansion && !!props.expandedRowRenderer,
86
+ enableRowGoto: ((_props$enableRowGoto = props.enableRowGoto) !== null && _props$enableRowGoto !== void 0 ? _props$enableRowGoto : presetOptions.enableRowGoto) && !!props.onRowGoto,
87
+ enableRowHeight: (_props$enableRowHeigh = props.enableRowHeight) !== null && _props$enableRowHeigh !== void 0 ? _props$enableRowHeigh : presetOptions.enableRowHeight,
88
+ enableRowSelection: enableRowSelection && !!props.onRowSelect,
89
+ enableRowSelectionSingle: ((_props$enableRowSelec2 = props.enableRowSelectionSingle) !== null && _props$enableRowSelec2 !== void 0 ? _props$enableRowSelec2 : presetOptions.enableRowSelectionSingle) && enableRowSelection && !!props.onRowSelect,
90
+ enableEditing: (_props$enableEditing = props.enableEditing) !== null && _props$enableEditing !== void 0 ? _props$enableEditing : presetOptions.enableEditing,
91
+ enableFiltering: (_props$enableFilterin = props.enableFiltering) !== null && _props$enableFilterin !== void 0 ? _props$enableFilterin : presetOptions.enableFiltering,
92
+ enableSearch: (_props$enableSearch = props.enableSearch) !== null && _props$enableSearch !== void 0 ? _props$enableSearch : presetOptions.enableSearch,
93
+ enableSorting: (_props$enableSorting = props.enableSorting) !== null && _props$enableSorting !== void 0 ? _props$enableSorting : presetOptions.enableSorting
94
+ };
95
+ }
96
+
97
+ export { useTablePreset };
98
+ //# sourceMappingURL=useTablePreset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTablePreset.js","sources":["../../../../../../../../src/components/Table3/hooks/useTablePreset.ts"],"sourcesContent":["import React from 'react';\nimport { Table3Options, Table3Preset, Table3Props } from '../types';\n\nconst DEFAULT_ALL_DISABLED: Table3Options = {\n enableColumnFreezing: false,\n enableColumnHiding: false,\n enableColumnOrdering: false,\n enableColumnResizing: false,\n enableFontSize: false,\n enablePrinting: false,\n enableRowDrag: false,\n enableRowDrop: false,\n enableRowExpansion: false,\n enableRowGoto: false,\n enableRowHeight: false,\n enableRowSelection: false,\n enableRowSelectionSingle: false,\n enableEditing: false,\n enableFiltering: false,\n enableSearch: false,\n enableSorting: false,\n};\n\nconst presets: Record<Table3Preset, Table3Options> = {\n display: {\n enableColumnFreezing: true,\n enableColumnHiding: true,\n enableColumnOrdering: true,\n enableColumnResizing: true,\n enableFontSize: true,\n enablePrinting: false,\n enableRowDrag: true,\n enableRowDrop: true,\n enableRowExpansion: true,\n enableRowGoto: true,\n enableRowHeight: true,\n enableRowSelection: true,\n enableRowSelectionSingle: false,\n enableEditing: false,\n enableFiltering: true,\n enableSearch: true,\n enableSorting: true,\n },\n editable: {\n enableColumnFreezing: true,\n enableColumnHiding: true,\n enableColumnOrdering: true,\n enableColumnResizing: true,\n enableFontSize: true,\n enablePrinting: false,\n enableRowDrag: true,\n enableRowDrop: true,\n enableRowExpansion: true,\n enableRowGoto: true,\n enableRowHeight: true,\n enableRowSelection: true,\n enableRowSelectionSingle: false,\n enableEditing: true,\n enableFiltering: true,\n enableSearch: true,\n enableSorting: true,\n },\n};\n\nexport function useTablePreset<TType = unknown>(props: Table3Props<TType>): Table3Options {\n const presetOptions = props.preset ? presets[props.preset] : DEFAULT_ALL_DISABLED;\n\n const enableRowExpansion = props.enableRowExpansion ?? presetOptions.enableRowExpansion;\n const enableRowSelection = props.enableRowSelection ?? presetOptions.enableRowSelection;\n\n // guard options that might be unintentionally broken\n React.useEffect(() => {\n if (enableRowExpansion && !props.expandedRowRenderer) {\n console.warn(\n `Table3 (id: ${props.id}) - Row expansion is enabled but no \\`expandedRowRenderer\\` has been provided. Provide one to enable row expansion or set \\`enableRowExpansion\\` to \\`false\\`.`\n );\n }\n\n if (enableRowSelection && !props.onRowSelect) {\n console.warn(\n `Table3 (id: ${props.id}) - Row selection is enabled but no \\`onRowSelect\\` handler has been provided. Provide one to enable row selection or set \\`enableRowSelection\\` to \\`false\\`.`\n );\n }\n }, []);\n\n return {\n enableColumnFreezing: props.enableColumnFreezing ?? presetOptions.enableColumnFreezing,\n enableColumnHiding: props.enableColumnHiding ?? presetOptions.enableColumnHiding,\n enableColumnOrdering: props.enableColumnOrdering ?? presetOptions.enableColumnOrdering,\n enableColumnResizing: props.enableColumnResizing ?? presetOptions.enableColumnResizing,\n enableFontSize: props.enableFontSize ?? presetOptions.enableFontSize,\n enablePrinting: props.enablePrinting ?? presetOptions.enablePrinting,\n enableRowDrag: (props.enableRowDrag ?? presetOptions.enableRowDrag) && !!props.onRowDrag,\n enableRowDrop: (props.enableRowDrop ?? presetOptions.enableRowDrop) && !!props.onRowDrop,\n enableRowExpansion: enableRowExpansion && !!props.expandedRowRenderer,\n enableRowGoto: (props.enableRowGoto ?? presetOptions.enableRowGoto) && !!props.onRowGoto,\n enableRowHeight: props.enableRowHeight ?? presetOptions.enableRowHeight,\n enableRowSelection: enableRowSelection && !!props.onRowSelect,\n enableRowSelectionSingle:\n (props.enableRowSelectionSingle ?? presetOptions.enableRowSelectionSingle) &&\n enableRowSelection &&\n !!props.onRowSelect,\n enableEditing: props.enableEditing ?? presetOptions.enableEditing,\n enableFiltering: props.enableFiltering ?? presetOptions.enableFiltering,\n enableSearch: props.enableSearch ?? presetOptions.enableSearch,\n enableSorting: props.enableSorting ?? presetOptions.enableSorting,\n };\n}\n"],"names":["DEFAULT_ALL_DISABLED","enableColumnFreezing","enableColumnHiding","enableColumnOrdering","enableColumnResizing","enableFontSize","enablePrinting","enableRowDrag","enableRowDrop","enableRowExpansion","enableRowGoto","enableRowHeight","enableRowSelection","enableRowSelectionSingle","enableEditing","enableFiltering","enableSearch","enableSorting","presets","display","editable","useTablePreset","props","presetOptions","preset","React","useEffect","expandedRowRenderer","console","warn","id","onRowSelect","onRowDrag","onRowDrop","onRowGoto"],"mappings":";;AAGA,MAAMA,oBAAoB,GAAkB;EACxCC,oBAAoB,EAAE,KAAK;EAC3BC,kBAAkB,EAAE,KAAK;EACzBC,oBAAoB,EAAE,KAAK;EAC3BC,oBAAoB,EAAE,KAAK;EAC3BC,cAAc,EAAE,KAAK;EACrBC,cAAc,EAAE,KAAK;EACrBC,aAAa,EAAE,KAAK;EACpBC,aAAa,EAAE,KAAK;EACpBC,kBAAkB,EAAE,KAAK;EACzBC,aAAa,EAAE,KAAK;EACpBC,eAAe,EAAE,KAAK;EACtBC,kBAAkB,EAAE,KAAK;EACzBC,wBAAwB,EAAE,KAAK;EAC/BC,aAAa,EAAE,KAAK;EACpBC,eAAe,EAAE,KAAK;EACtBC,YAAY,EAAE,KAAK;EACnBC,aAAa,EAAE;CAClB;AAED,MAAMC,OAAO,GAAwC;EACjDC,OAAO,EAAE;IACLlB,oBAAoB,EAAE,IAAI;IAC1BC,kBAAkB,EAAE,IAAI;IACxBC,oBAAoB,EAAE,IAAI;IAC1BC,oBAAoB,EAAE,IAAI;IAC1BC,cAAc,EAAE,IAAI;IACpBC,cAAc,EAAE,KAAK;IACrBC,aAAa,EAAE,IAAI;IACnBC,aAAa,EAAE,IAAI;IACnBC,kBAAkB,EAAE,IAAI;IACxBC,aAAa,EAAE,IAAI;IACnBC,eAAe,EAAE,IAAI;IACrBC,kBAAkB,EAAE,IAAI;IACxBC,wBAAwB,EAAE,KAAK;IAC/BC,aAAa,EAAE,KAAK;IACpBC,eAAe,EAAE,IAAI;IACrBC,YAAY,EAAE,IAAI;IAClBC,aAAa,EAAE;GAClB;EACDG,QAAQ,EAAE;IACNnB,oBAAoB,EAAE,IAAI;IAC1BC,kBAAkB,EAAE,IAAI;IACxBC,oBAAoB,EAAE,IAAI;IAC1BC,oBAAo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AAClB,oBAAoB,yEAAImB,aAAa,CAACnB,oBAAoB;IACtFC,cAAc,2BAAEiB,KAAK,CAACjB,cAAc,yEAAIkB,aAAa,CAAClB,cAAc;IACpEC,cAAc,2BAAEgB,KAAK,CAAChB,cAAc,yEAAIiB,aAAa,CAACjB,cAAc;IACpEC,aAAa,EAAE,yBAACe,KAAK,CAACf,aAAa,uEAAIgB,aAAa,CAAChB,aAAa,KAAK,CAAC,CAACe,KAAK,CAACU,SAAS;IACxFxB,aAAa,EAAE,yBAACc,KAAK,CAACd,aAAa,uEAAIe,aAAa,CAACf,aAAa,KAAK,CAAC,CAACc,KAAK,CAACW,SAAS;IACxFxB,kBAAkB,EAAEA,kBAAkB,IAAI,CAAC,CAACa,KAAK,CAACK,mBAAmB;IACrEjB,aAAa,EAAE,yBAACY,KAAK,CAACZ,aAAa,uEAAIa,aAAa,CAACb,aAAa,KAAK,CAAC,CAACY,KAAK,CAACY,SAAS;IACxFvB,eAAe,2BAAEW,KAAK,CAACX,eAAe,yEAAIY,aAAa,CAACZ,eAAe;IACvEC,kBAAkB,EAAEA,kBAAkB,IAAI,CAAC,CAACU,KAAK,CAACS,WAAW;IAC7DlB,wBAAwB,EACpB,2BAACS,KAAK,CAACT,wBAAwB,2EAAIU,aAAa,CAACV,wBAAwB,KACzED,kBAAkB,IAClB,CAAC,CAACU,KAAK,CAACS,WAAW;IACvBjB,aAAa,0BAAEQ,KAAK,CAACR,aAAa,uEAAIS,aAAa,CAACT,aAAa;IACjEC,eAAe,2BAAEO,KAAK,CAACP,eAAe,yEAAIQ,aAAa,CAACR,eAAe;IACvEC,YAAY,yBAAEM,KAAK,CAACN,YAAY,qEAAIO,aAAa,CAACP,YAAY;IAC9DC,aAAa,0BAAEK,KAAK,CAACL,aAAa,uEAAIM,aAAa,CAACN;GACvD;AACL;;;;"}
@@ -0,0 +1,19 @@
1
+ import React__default from 'react';
2
+
3
+ function useTableRefInstanceSetup(table, ref) {
4
+ React__default.useEffect(() => {
5
+ if (ref.current) {
6
+ const tableMeta = table.options.meta;
7
+ ref.current.instance = {
8
+ resetFiltering: () => table.resetColumnFilters(),
9
+ resetRowExpansion: () => table.resetExpanded(),
10
+ resetRowSelection: () => table.resetRowSelection(),
11
+ resetSorting: () => table.resetSorting(),
12
+ toggleEditing: enabled => tableMeta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing)
13
+ };
14
+ }
15
+ }, [table, ref.current]);
16
+ }
17
+
18
+ export { useTableRefInstanceSetup };
19
+ //# sourceMappingURL=useTableRefInstanceSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTableRefInstanceSetup.js","sources":["../../../../../../../../src/components/Table3/hooks/useTableRefInstanceSetup.ts"],"sourcesContent":["import React from 'react';\nimport { Table3Ref } from '../types';\nimport { Table as RTable, TableMeta } from '@tanstack/react-table';\n\nexport function useTableRefInstanceSetup<TType = unknown>(table: RTable<TType>, ref: React.RefObject<Table3Ref>) {\n React.useEffect(() => {\n if (ref.current) {\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n ref.current.instance = {\n resetFiltering: () => table.resetColumnFilters(),\n resetRowExpansion: () => table.resetExpanded(),\n resetRowSelection: () => table.resetRowSelection(),\n resetSorting: () => table.resetSorting(),\n toggleEditing: (enabled: boolean | undefined) =>\n tableMeta.editing.toggleEditing(enabled ?? (editing => !editing)),\n };\n }\n }, [table, ref.current]);\n}\n"],"names":["useTableRefInstanceSetup","table","ref","React","useEffect","current","tableMeta","options","meta","instance","resetFiltering","resetColumnFilters","resetRowExpansion","resetExpanded","resetRowSelection","resetSorting","toggleEditing","enabled","editing"],"mappings":";;SAIgBA,wBAAwB,CAAkBC,KAAoB,EAAEC,GAA+B;EAC3GC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIF,GAAG,CAACG,OAAO,EAAE;MACb,MAAMC,SAAS,GAAGL,KAAK,CAACM,OAAO,CAACC,IAAwB;MAExDN,GAAG,CAACG,OAAO,CAACI,QAAQ,GAAG;QACnBC,cAAc,EAAE,MAAMT,KAAK,CAACU,kBAAkB,EAAE;QAChDC,iBAAiB,EAAE,MAAMX,KAAK,CAACY,aAAa,EAAE;QAC9CC,iBAAiB,EAAE,MAAMb,KAAK,CAACa,iBAAiB,EAAE;QAClDC,YAAY,EAAE,MAAMd,KAAK,CAACc,YAAY,EAAE;QACxCC,aAAa,EAAGC,OAA4B,IACxCX,SAAS,CAACY,OAAO,CAACF,aAAa,CAACC,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAKC,OAAO,IAAI,CAACA,OAAO;OACtE;;GAER,EAAE,CAACjB,KAAK,EAAEC,GAAG,CAACG,OAAO,CAAC,CAAC;AAC5B;;;;"}
@@ -0,0 +1,8 @@
1
+ import { useTableRenderStrategy as useTableRenderStrategy$1 } from './virtualised.js';
2
+
3
+ function useTableRenderStrategy(props, table, ref) {
4
+ return useTableRenderStrategy$1(props, table, ref);
5
+ }
6
+
7
+ export { useTableRenderStrategy };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../../../src/components/Table3/strategies/index.ts"],"sourcesContent":["import { Table as RTable } from '@tanstack/react-table';\nimport { Table3Props, TableStrategy } from '../types';\nimport * as virtualRenderer from './virtualised';\n\nexport function useTableRenderStrategy<TType = unknown>(\n props: Table3Props<TType>,\n table: RTable<TType>,\n ref: React.RefObject<HTMLDivElement>\n): TableStrategy {\n return virtualRenderer.useTableRenderStrategy<TType>(props, table, ref);\n}\n"],"names":["useTableRenderStrategy","props","table","ref","virtualRenderer"],"mappings":";;SAIgBA,sBAAsB,CAClCC,KAAyB,EACzBC,KAAoB,EACpBC,GAAoC;EAEpC,OAAOC,wBAAsC,CAAQH,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC;AAC3E;;;;"}
@@ -0,0 +1,113 @@
1
+ import React__default from 'react';
2
+ import { flexRender } from '@tanstack/react-table';
3
+ import { useVirtual } from 'react-virtual';
4
+ import { Row } from '../components/rows/Row.js';
5
+ import { ExpandedRow } from '../components/rows/ExpandedRow.js';
6
+ import { rowHeightSizeEstimates } from '../components/rows/styles.js';
7
+ import { SkeletonRow } from '../components/rows/SkeletonRow.js';
8
+
9
+ function createBodyRenderer(props, rows, table, tableRef, virtualiser, setExpandedRowSizes) {
10
+ return () => {
11
+ if (rows.length) {
12
+ var _virtualiser$virtualI, _virtualiser$virtualI2, _virtualiser$virtualI3, _virtualiser$virtualI4;
13
+ const paddingTop = virtualiser.virtualItems.length > 0 ? (_virtualiser$virtualI = (_virtualiser$virtualI2 = virtualiser.virtualItems[0]) === null || _virtualiser$virtualI2 === void 0 ? void 0 : _virtualiser$virtualI2.start) !== null && _virtualiser$virtualI !== void 0 ? _virtualiser$virtualI : 0 : 0;
14
+ const paddingBottom = virtualiser.virtualItems.length > 0 ? virtualiser.totalSize - ((_virtualiser$virtualI3 = (_virtualiser$virtualI4 = virtualiser.virtualItems[virtualiser.virtualItems.length - 1]) === null || _virtualiser$virtualI4 === void 0 ? void 0 : _virtualiser$virtualI4.end) !== null && _virtualiser$virtualI3 !== void 0 ? _virtualiser$virtualI3 : 0) : 0;
15
+ const createSetSizeHandler = index => size => {
16
+ setExpandedRowSizes(sizes => {
17
+ if (size !== sizes[index]) {
18
+ return {
19
+ ...sizes,
20
+ [index]: size
21
+ };
22
+ }
23
+ return sizes;
24
+ });
25
+ };
26
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, paddingTop ? /*#__PURE__*/React__default.createElement("div", {
27
+ style: {
28
+ height: paddingTop
29
+ },
30
+ className: "col-span-full"
31
+ }) : null, virtualiser.virtualItems.map(virtualRow => {
32
+ const row = rows[virtualRow.index];
33
+ if (row.original === undefined && props.pageSize) {
34
+ const pageIndex = Math.floor(virtualRow.index / props.pageSize) * props.pageSize / props.pageSize;
35
+ return /*#__PURE__*/React__default.createElement(SkeletonRow, {
36
+ key: row.id,
37
+ columns: table.getVisibleLeafColumns(),
38
+ loadPage: props.loadPage,
39
+ pageIndex: pageIndex,
40
+ table: table
41
+ });
42
+ }
43
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
44
+ key: row.id
45
+ }, /*#__PURE__*/React__default.createElement(Row, {
46
+ index: virtualRow.index,
47
+ isLastRow: virtualRow.index === rows.length - 1,
48
+ row: row,
49
+ table: table,
50
+ tableRef: tableRef
51
+ }, row.getVisibleCells().map((cell, index) => /*#__PURE__*/React__default.createElement(React__default.Fragment, {
52
+ key: cell.id
53
+ }, flexRender(cell.column.columnDef.cell, {
54
+ ...cell.getContext(),
55
+ index,
56
+ tableRef
57
+ })))), row.getIsExpanded() ? /*#__PURE__*/React__default.createElement(ExpandedRow, {
58
+ data: row.original,
59
+ renderer: props.expandedRowRenderer,
60
+ registerSize: createSetSizeHandler(virtualRow.index)
61
+ }) : null);
62
+ }), paddingBottom ? /*#__PURE__*/React__default.createElement("div", {
63
+ style: {
64
+ height: paddingBottom
65
+ },
66
+ className: "col-span-full"
67
+ }) : null);
68
+ }
69
+ return null;
70
+ };
71
+ }
72
+ function useTableRenderStrategy(props, table, tableRef) {
73
+ const meta = table.options.meta;
74
+ const rows = table.getRowModel().rows;
75
+ const expandedState = table.getState().expanded;
76
+ const [expandedRowSizes, setExpandedRowSizes] = React__default.useState({});
77
+ const firstAvailableExpandedRowHeight = React__default.useMemo(() => {
78
+ const values = Object.values(expandedRowSizes);
79
+ return values.length ? values.reduce((a, b) => a + b, 0) / values.length : 0;
80
+ }, [expandedRowSizes]);
81
+ const estimateSize = React__default.useCallback(index => {
82
+ const rowHeight = meta.rowHeight.height ? rowHeightSizeEstimates[meta.rowHeight.height] : rowHeightSizeEstimates.medium;
83
+ if (expandedState === true || expandedState !== null && expandedState !== void 0 && expandedState[index]) {
84
+ var _ref, _expandedRowSizes$ind;
85
+ return rowHeight + ((_ref = (_expandedRowSizes$ind = expandedRowSizes[index]) !== null && _expandedRowSizes$ind !== void 0 ? _expandedRowSizes$ind : firstAvailableExpandedRowHeight) !== null && _ref !== void 0 ? _ref : 0);
86
+ }
87
+ return rowHeight;
88
+ }, [meta.rowHeight.height, expandedRowSizes, expandedState]);
89
+ const virtualiser = useVirtual({
90
+ parentRef: tableRef,
91
+ size: rows.length,
92
+ estimateSize
93
+ });
94
+ const scrollToIndex = React__default.useCallback((index, options) => {
95
+ if (tableRef.current) {
96
+ if (index <= 0) {
97
+ tableRef.current.scrollTo(tableRef.current.scrollLeft, 0);
98
+ } else if (index >= rows.length - 1) {
99
+ var _tableRef$current;
100
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.scrollTo(0, tableRef.current.scrollHeight);
101
+ } else {
102
+ virtualiser.scrollToIndex(index, options);
103
+ }
104
+ }
105
+ }, [rows.length, tableRef.current]);
106
+ return {
107
+ renderBody: createBodyRenderer(props, rows, table, tableRef, virtualiser, setExpandedRowSizes),
108
+ scrollToIndex
109
+ };
110
+ }
111
+
112
+ export { useTableRenderStrategy };
113
+ //# sourceMappingURL=virtualised.js.map