@economic/taco 2.21.3 → 2.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. package/dist/components/Report/Report.d.ts +21 -0
  2. package/dist/components/Report/components/Cell/Cell.d.ts +0 -1
  3. package/dist/components/Report/components/Cell/DisplayCell.d.ts +1 -1
  4. package/dist/components/Report/components/Cell/util.d.ts +1 -1
  5. package/dist/components/Report/components/Row/DisplayRow.d.ts +2 -9
  6. package/dist/components/Report/components/Toolbar/components/Filters/components/Placeholder.d.ts +5 -5
  7. package/dist/components/Report/listeners/useTableRowActiveListener.d.ts +3 -0
  8. package/dist/components/Report/styles/util.d.ts +2 -2
  9. package/dist/components/Report/types.d.ts +1 -3
  10. package/dist/components/Report/useReport.d.ts +2 -7
  11. package/dist/components/Table3/types.d.ts +1 -1
  12. package/dist/esm/index.css +501 -9
  13. package/dist/esm/packages/taco/src/components/Card/Card.js +1 -1
  14. package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Group/Group.js +1 -1
  16. package/dist/esm/packages/taco/src/components/Group/Group.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Input/Input.js +37 -7
  18. package/dist/esm/packages/taco/src/components/Input/Input.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Input/util.js +3 -1
  20. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Report/Report.js +70 -0
  22. package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -0
  23. package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js +61 -0
  24. package/dist/esm/packages/taco/src/components/Report/components/Body/Body.js.map +1 -0
  25. package/dist/esm/packages/taco/src/components/Report/components/Body/util.js +22 -0
  26. package/dist/esm/packages/taco/src/components/Report/components/Body/util.js.map +1 -0
  27. package/dist/esm/packages/taco/src/components/Report/components/Cell/Cell.js +32 -0
  28. package/dist/esm/packages/taco/src/components/Report/components/Cell/Cell.js.map +1 -0
  29. package/dist/esm/packages/taco/src/components/Report/components/Cell/DisplayCell.js +23 -0
  30. package/dist/esm/packages/taco/src/components/Report/components/Cell/DisplayCell.js.map +1 -0
  31. package/dist/esm/packages/taco/src/components/Report/components/Cell/GroupedCell.js +58 -0
  32. package/dist/esm/packages/taco/src/components/Report/components/Cell/GroupedCell.js.map +1 -0
  33. package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js +69 -0
  34. package/dist/esm/packages/taco/src/components/Report/components/Cell/util.js.map +1 -0
  35. package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js +34 -0
  36. package/dist/esm/packages/taco/src/components/Report/components/Footer/Footer.js.map +1 -0
  37. package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js +39 -0
  38. package/dist/esm/packages/taco/src/components/Report/components/Footer/Summary.js.map +1 -0
  39. package/dist/esm/packages/taco/src/components/Report/components/Header/Header.js +194 -0
  40. package/dist/esm/packages/taco/src/components/Report/components/Header/Header.js.map +1 -0
  41. package/dist/esm/packages/taco/src/components/Report/components/Header/components/Goto.js +28 -0
  42. package/dist/esm/packages/taco/src/components/Report/components/Header/components/Goto.js.map +1 -0
  43. package/dist/esm/packages/taco/src/components/Report/components/Header/components/Menu.js +150 -0
  44. package/dist/esm/packages/taco/src/components/Report/components/Header/components/Menu.js.map +1 -0
  45. package/dist/esm/packages/taco/src/components/Report/components/Header/components/Resizer.js +60 -0
  46. package/dist/esm/packages/taco/src/components/Report/components/Header/components/Resizer.js.map +1 -0
  47. package/dist/esm/packages/taco/src/components/Report/components/Header/components/SortIndicator.js +41 -0
  48. package/dist/esm/packages/taco/src/components/Report/components/Header/components/SortIndicator.js.map +1 -0
  49. package/dist/esm/packages/taco/src/components/Report/components/Header/util.js +24 -0
  50. package/dist/esm/packages/taco/src/components/Report/components/Header/util.js.map +1 -0
  51. package/dist/esm/packages/taco/src/components/Report/components/Internal/Actions.js +90 -0
  52. package/dist/esm/packages/taco/src/components/Report/components/Internal/Actions.js.map +1 -0
  53. package/dist/esm/packages/taco/src/components/Report/components/Internal/Expansion.js +59 -0
  54. package/dist/esm/packages/taco/src/components/Report/components/Internal/Expansion.js.map +1 -0
  55. package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js +118 -0
  56. package/dist/esm/packages/taco/src/components/Report/components/Internal/Selection.js.map +1 -0
  57. package/dist/esm/packages/taco/src/components/Report/components/Row/DisplayRow.js +102 -0
  58. package/dist/esm/packages/taco/src/components/Report/components/Row/DisplayRow.js.map +1 -0
  59. package/dist/esm/packages/taco/src/components/Report/components/Row/Row.js +24 -0
  60. package/dist/esm/packages/taco/src/components/Report/components/Row/Row.js.map +1 -0
  61. package/dist/esm/packages/taco/src/components/Report/components/Row/RowContext.js +10 -0
  62. package/dist/esm/packages/taco/src/components/Report/components/Row/RowContext.js.map +1 -0
  63. package/dist/esm/packages/taco/src/components/Report/components/Row/SkeletonRow.js +62 -0
  64. package/dist/esm/packages/taco/src/components/Report/components/Row/SkeletonRow.js.map +1 -0
  65. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/Toolbar.js +63 -0
  66. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/Toolbar.js.map +1 -0
  67. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/Filters.js +50 -0
  68. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/Filters.js.map +1 -0
  69. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js +136 -0
  70. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/ManageFiltersPopover.js.map +1 -0
  71. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js +95 -0
  72. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Filter.js.map +1 -0
  73. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js +49 -0
  74. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterColumn.js.map +1 -0
  75. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterComparator.js +110 -0
  76. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterComparator.js.map +1 -0
  77. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterValue.js +118 -0
  78. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -0
  79. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js +41 -0
  80. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/components/Placeholder.js.map +1 -0
  81. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/util.js +7 -0
  82. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Filters/util.js.map +1 -0
  83. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js +123 -0
  84. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/Print.js.map +1 -0
  85. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/PrintDialog.js +88 -0
  86. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Print/PrintDialog.js.map +1 -0
  87. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Search/Search.js +95 -0
  88. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Search/Search.js.map +1 -0
  89. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/HideOrOrderPopover.js +105 -0
  90. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/HideOrOrderPopover.js.map +1 -0
  91. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/Settings.js +103 -0
  92. package/dist/esm/packages/taco/src/components/Report/components/Toolbar/components/Settings/Settings.js.map +1 -0
  93. package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js +24 -0
  94. package/dist/esm/packages/taco/src/components/Report/listeners/useTableRowActiveListener.js.map +1 -0
  95. package/dist/esm/packages/taco/src/components/Report/styles/useColumnPinningStylesheet.js +44 -0
  96. package/dist/esm/packages/taco/src/components/Report/styles/useColumnPinningStylesheet.js.map +1 -0
  97. package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js +54 -0
  98. package/dist/esm/packages/taco/src/components/Report/styles/useCssGridStylesheet.js.map +1 -0
  99. package/dist/esm/packages/taco/src/components/Report/styles/useStylesheet.js +20 -0
  100. package/dist/esm/packages/taco/src/components/Report/styles/useStylesheet.js.map +1 -0
  101. package/dist/esm/packages/taco/src/components/Report/styles/util.js +61 -0
  102. package/dist/esm/packages/taco/src/components/Report/styles/util.js.map +1 -0
  103. package/dist/esm/packages/taco/src/components/Report/useReport.js +51 -0
  104. package/dist/esm/packages/taco/src/components/Report/useReport.js.map +1 -0
  105. package/dist/esm/packages/taco/src/components/Report/util/rows.js +10 -0
  106. package/dist/esm/packages/taco/src/components/Report/util/rows.js.map +1 -0
  107. package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js +39 -0
  108. package/dist/esm/packages/taco/src/components/Report/util/useTableGlobalShortcuts.js.map +1 -0
  109. package/dist/esm/packages/taco/src/components/Report/util/useTableRenderer.js +162 -0
  110. package/dist/esm/packages/taco/src/components/Report/util/useTableRenderer.js.map +1 -0
  111. package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js +3 -2
  112. package/dist/esm/packages/taco/src/components/ScrollArea/ScrollArea.js.map +1 -1
  113. package/dist/esm/packages/taco/src/components/Select2/Select2.js +2 -2
  114. package/dist/esm/packages/taco/src/components/Select2/components/Create.js +1 -1
  115. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
  116. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +1 -1
  117. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +6 -7
  118. package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
  119. package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +1 -1
  120. package/dist/esm/packages/taco/src/components/Table3/Table3.js +7 -2
  121. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  122. package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js +6 -6
  123. package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js.map +1 -1
  124. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +7 -1
  125. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
  126. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -0
  127. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  128. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +6 -1
  129. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  130. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +1 -0
  131. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
  132. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +3 -1
  133. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
  134. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js +1 -0
  135. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Summary.js.map +1 -1
  136. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +9 -1
  137. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
  138. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +1 -0
  139. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
  140. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +2 -0
  141. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
  142. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +3 -3
  143. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +4 -8
  144. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
  145. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +1 -0
  146. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
  147. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js +19 -14
  148. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintButton.js.map +1 -1
  149. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +6 -5
  150. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
  151. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +18 -1
  152. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
  153. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js +8 -14
  154. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useColumnFreezing.js.map +1 -1
  155. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +1 -1
  156. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +1 -1
  157. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +5 -1
  158. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
  159. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +15 -15
  160. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  161. package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js +20 -0
  162. package/dist/esm/packages/taco/src/components/Table3/hooks/useTablePreset.js.map +1 -1
  163. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
  164. package/dist/esm/packages/taco/src/components/Table3/util/columns.js +2 -0
  165. package/dist/esm/packages/taco/src/components/Table3/util/columns.js.map +1 -1
  166. package/dist/esm/packages/taco/src/components/Textarea/Textarea.js +1 -1
  167. package/dist/esm/packages/taco/src/components/Textarea/Textarea.js.map +1 -1
  168. package/dist/esm/packages/taco/src/hooks/useBoundaryOverflowDetection.js +1 -1
  169. package/dist/esm/packages/taco/src/index.js +7 -6
  170. package/dist/esm/packages/taco/src/index.js.map +1 -1
  171. package/dist/esm/packages/taco/src/primitives/Button.js +2 -1
  172. package/dist/esm/packages/taco/src/primitives/Button.js.map +1 -1
  173. package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
  174. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnFreezing.js +21 -0
  175. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableColumnFreezing.js.map +1 -0
  176. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableFooter.js +8 -0
  177. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableFooter.js.map +1 -0
  178. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js +16 -0
  179. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTablePrinting.js.map +1 -0
  180. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRef.js +17 -0
  181. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRef.js.map +1 -0
  182. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowActions.js +11 -0
  183. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowActions.js.map +1 -0
  184. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowExpansion.js +9 -0
  185. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowExpansion.js.map +1 -0
  186. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGroups.js +9 -0
  187. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableRowGroups.js.map +1 -0
  188. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSearch.js +38 -0
  189. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSearch.js.map +1 -0
  190. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js +28 -0
  191. package/dist/esm/packages/taco/src/primitives/Table/useTable/features/useTableSettings.js.map +1 -0
  192. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowHeightListener.js +14 -0
  193. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableRowHeightListener.js.map +1 -0
  194. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSearchListener.js +15 -0
  195. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSearchListener.js.map +1 -0
  196. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js +26 -0
  197. package/dist/esm/packages/taco/src/primitives/Table/useTable/listeners/useTableSettingsListener.js.map +1 -0
  198. package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js +117 -0
  199. package/dist/esm/packages/taco/src/primitives/Table/useTable/useTable.js.map +1 -0
  200. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js +30 -3
  201. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/columns.js.map +1 -1
  202. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/filtering.js +131 -0
  203. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/filtering.js.map +1 -0
  204. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js +131 -0
  205. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/presets.js.map +1 -0
  206. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js +43 -0
  207. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/search.js.map +1 -0
  208. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js +22 -0
  209. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/settings.js.map +1 -0
  210. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/setup.js +270 -0
  211. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/setup.js.map +1 -0
  212. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/sorting.js +18 -0
  213. package/dist/esm/packages/taco/src/primitives/Table/useTable/util/sorting.js.map +1 -0
  214. package/dist/esm/packages/taco/src/utils/dom.js +5 -1
  215. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  216. package/dist/esm/packages/taco/src/utils/keyboard.js +3 -5
  217. package/dist/esm/packages/taco/src/utils/keyboard.js.map +1 -1
  218. package/dist/index.css +501 -9
  219. package/dist/index.d.ts +1 -0
  220. package/dist/primitives/Table/types.d.ts +2 -2
  221. package/dist/primitives/Table/useTable/features/useTablePrinting.d.ts +1 -1
  222. package/dist/primitives/Table/useTable/util/settings.d.ts +1 -1
  223. package/dist/primitives/Table/useTable/util/sorting.d.ts +1 -1
  224. package/dist/taco.cjs.development.js +6381 -2732
  225. package/dist/taco.cjs.development.js.map +1 -1
  226. package/dist/taco.cjs.production.min.js +1 -1
  227. package/dist/taco.cjs.production.min.js.map +1 -1
  228. package/dist/utils/dom.d.ts +1 -0
  229. package/dist/utils/keyboard.d.ts +0 -1
  230. package/package.json +2 -2
  231. package/types.json +6050 -4979
  232. package/dist/components/Report/features/useReportExport.d.ts +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTableSettings.js","sources":["../../../../../../../../../src/primitives/Table/useTable/features/useTableSettings.ts"],"sourcesContent":["import React from 'react';\nimport { useLocalStorage } from '../../../../hooks/useLocalStorage';\nimport { useTacoSettings } from '../../../../hooks/useTacoSettings';\nimport { TableSettings, TableSettingsHandler } from '../../types';\n\nexport function useUniqueTableId(tableId: string) {\n const tacoSettings = useTacoSettings();\n\n return `taco.${tacoSettings.uniqueUserIdentifier}.table.${tableId}.settings`;\n}\n\nexport function useTableSettings(\n isEnabled = false,\n id: string,\n defaultSettings: TableSettings | undefined = {},\n onChangeSettings: TableSettingsHandler | undefined\n): [TableSettings, TableSettingsHandler] {\n const uniqueId = useUniqueTableId(id);\n const [persistedSettings, _setPersistedSettings] = useLocalStorage<TableSettings>(\n isEnabled ? uniqueId : undefined,\n defaultSettings\n );\n\n const setPersistedSettings = React.useCallback(\n (value: TableSettings) => {\n if (!isEnabled) {\n return;\n }\n\n _setPersistedSettings(value);\n\n if (typeof onChangeSettings === 'function') {\n onChangeSettings(value);\n }\n },\n [isEnabled, onChangeSettings]\n );\n\n if (!isEnabled) {\n return [defaultSettings, () => undefined];\n }\n\n return [persistedSettings, setPersistedSettings];\n}\n"],"names":["useUniqueTableId","tableId","tacoSettings","useTacoSettings","uniqueUserIdentifier","useTableSettings","isEnabled","id","defaultSettings","onChangeSettings","uniqueId","persistedSettings","_setPersistedSettings","useLocalStorage","undefined","setPersistedSettings","React","useCallback","value"],"mappings":";;;;SAKgBA,gBAAgBA,CAACC,OAAe;EAC5C,MAAMC,YAAY,GAAGC,eAAe,EAAE;EAEtC,eAAeD,YAAY,CAACE,8BAA8BH,kBAAkB;AAChF;SAEgBI,gBAAgBA,CAC5BC,SAAS,GAAG,KAAK,EACjBC,EAAU,EACVC,kBAA6C,EAAE,EAC/CC,gBAAkD;EAElD,MAAMC,QAAQ,GAAGV,gBAAgB,CAACO,EAAE,CAAC;EACrC,MAAM,CAACI,iBAAiB,EAAEC,qBAAqB,CAAC,GAAGC,eAAe,CAC9DP,SAAS,GAAGI,QAAQ,GAAGI,SAAS,EAChCN,eAAe,CAClB;EAED,MAAMO,oBAAoB,GAAGC,cAAK,CAACC,WAAW,CACzCC,KAAoB;IACjB,IAAI,CAACZ,SAAS,EAAE;MACZ;;IAGJM,qBAAqB,CAACM,KAAK,CAAC;IAE5B,IAAI,OAAOT,gBAAgB,KAAK,UAAU,EAAE;MACxCA,gBAAgB,CAACS,KAAK,CAAC;;GAE9B,EACD,CAACZ,SAAS,EAAEG,gBAAgB,CAAC,CAChC;EAED,IAAI,CAACH,SAAS,EAAE;IACZ,OAAO,CAACE,eAAe,EAAE,MAAMM,SAAS,CAAC;;EAG7C,OAAO,CAACH,iBAAiB,EAAEI,oBAAoB,CAAC;AACpD;;;;"}
@@ -0,0 +1,14 @@
1
+ import { FontSizes } from '../../../../types.js';
2
+ import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
3
+
4
+ function useTableRowHeightListener(table) {
5
+ const meta = table.options.meta;
6
+ useLazyEffect(() => {
7
+ if (meta.rowHeight.height === 'short' && meta.fontSize.size === FontSizes.large) {
8
+ meta.fontSize.setSize(FontSizes.medium);
9
+ }
10
+ }, [meta.rowHeight.height]);
11
+ }
12
+
13
+ export { useTableRowHeightListener };
14
+ //# sourceMappingURL=useTableRowHeightListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTableRowHeightListener.js","sources":["../../../../../../../../../src/primitives/Table/useTable/listeners/useTableRowHeightListener.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { FontSizes } from '../../../../types';\n\nexport function useTableRowHeightListener<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n\n useLazyEffect(() => {\n if (meta.rowHeight.height === 'short' && meta.fontSize.size === FontSizes.large) {\n meta.fontSize.setSize(FontSizes.medium);\n }\n }, [meta.rowHeight.height]);\n}\n"],"names":["useTableRowHeightListener","table","meta","options","useLazyEffect","rowHeight","height","fontSize","size","FontSizes","large","setSize","medium"],"mappings":";;;SAIgBA,yBAAyBA,CAAkBC,KAAwB;EAC/E,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAA6B;EAExDE,aAAa,CAAC;IACV,IAAIF,IAAI,CAACG,SAAS,CAACC,MAAM,KAAK,OAAO,IAAIJ,IAAI,CAACK,QAAQ,CAACC,IAAI,KAAKC,SAAS,CAACC,KAAK,EAAE;MAC7ER,IAAI,CAACK,QAAQ,CAACI,OAAO,CAACF,SAAS,CAACG,MAAM,CAAC;;GAE9C,EAAE,CAACV,IAAI,CAACG,SAAS,CAACC,MAAM,CAAC,CAAC;AAC/B;;;;"}
@@ -0,0 +1,15 @@
1
+ import React__default from 'react';
2
+ import { resetHighlightedColumnIndexes } from '../util/search.js';
3
+
4
+ function useTableSearchListener(table) {
5
+ const meta = table.options.meta;
6
+ // recalculates highlighted indexes whenever something important changes
7
+ React__default.useEffect(() => {
8
+ if (meta.search.isEnabled) {
9
+ resetHighlightedColumnIndexes(table.getState().globalFilter, table);
10
+ }
11
+ }, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility)]);
12
+ }
13
+
14
+ export { useTableSearchListener };
15
+ //# sourceMappingURL=useTableSearchListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTable/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n\n // recalculates highlighted indexes whenever something important changes\n React.useEffect(() => {\n if (meta.search.isEnabled) {\n resetHighlightedColumnIndexes(table.getState().globalFilter, table);\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n ]);\n}\n"],"names":["useTableSearchListener","table","meta","options","React","useEffect","search","isEnabled","resetHighlightedColumnIndexes","getState","globalFilter","server","loadAllStatus","enableGlobalFilter","getRowModel","rows","length","JSON","stringify","sorting","columnVisibility"],"mappings":";;;SAIgBA,sBAAsBA,CAAkBC,KAAwB;EAC5E,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAA6B;;EAGxDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,MAAM,CAACC,SAAS,EAAE;MACvBC,6BAA6B,CAACP,KAAK,CAACQ,QAAQ,EAAE,CAACC,YAAY,EAAET,KAAK,CAAC;;GAE1E,EAAE,CACCC,IAAI,CAACS,MAAM,CAACC,aAAa,EACzBV,IAAI,CAACI,MAAM,CAACC,SAAS,EACrBL,IAAI,CAACI,MAAM,CAACO,kBAAkB,EAC9BZ,KAAK,CAACa,WAAW,EAAE,CAACC,IAAI,CAACC,MAAM,EAC/Bf,KAAK,CAACQ,QAAQ,EAAE,CAACC,YAAY,EAC7BO,IAAI,CAACC,SAAS,CAACjB,KAAK,CAACQ,QAAQ,EAAE,CAACU,OAAO,CAAC,EACxCF,IAAI,CAACC,SAAS,CAACjB,KAAK,CAACQ,QAAQ,EAAE,CAACW,gBAAgB,CAAC,CACpD,CAAC;AACN;;;;"}
@@ -0,0 +1,26 @@
1
+ import React__default from 'react';
2
+ import { getSettings } from '../util/settings.js';
3
+
4
+ function useTableSettingsListener(table, onChangeSettings) {
5
+ const meta = table.options.meta;
6
+ const state = table.getState();
7
+ React__default.useEffect(() => {
8
+ let handler;
9
+ if (typeof onChangeSettings === 'function') {
10
+ handler = setTimeout(() => {
11
+ // some settings shouldn't be persisted, but we comment them out here to highlight the intention
12
+ onChangeSettings(getSettings(table));
13
+ }, 250);
14
+ }
15
+ return () => clearTimeout(handler);
16
+ }, [
17
+ //state.columnFilters,
18
+ state.columnOrder, state.columnPinning, state.columnSizing, state.columnVisibility,
19
+ // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
20
+ meta.search.excludeUnmatchedResults, meta.fontSize.size, state.grouping, meta.rowHeight.height, meta.printing.isWarningVisibleForLargeDatasets,
21
+ //state.globalFilter,
22
+ state.sorting]);
23
+ }
24
+
25
+ export { useTableSettingsListener };
26
+ //# sourceMappingURL=useTableSettingsListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTableSettingsListener.js","sources":["../../../../../../../../../src/primitives/Table/useTable/listeners/useTableSettingsListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableSettingsHandler } from '../../types';\nimport { getSettings } from '../util/settings';\n\nexport function useTableSettingsListener<TType = unknown>(\n table: ReactTable<TType>,\n onChangeSettings: TableSettingsHandler | undefined\n) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(() => {\n // some settings shouldn't be persisted, but we comment them out here to highlight the intention\n onChangeSettings(getSettings(table));\n }, 250);\n }\n\n return () => clearTimeout(handler);\n }, [\n //state.columnFilters,\n state.columnOrder,\n state.columnPinning,\n state.columnSizing,\n state.columnVisibility,\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n meta.search.excludeUnmatchedResults,\n meta.fontSize.size,\n state.grouping,\n meta.rowHeight.height,\n meta.printing.isWarningVisibleForLargeDatasets,\n //state.globalFilter,\n state.sorting,\n ]);\n}\n"],"names":["useTableSettingsListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","getSettings","clearTimeout","columnOrder","columnPinning","columnSizing","columnVisibility","search","excludeUnmatchedResults","fontSize","size","grouping","rowHeight","height","printing","isWarningVisibleForLargeDatasets","sorting"],"mappings":";;;SAKgBA,wBAAwBA,CACpCC,KAAwB,EACxBC,gBAAkD;EAElD,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,KAAK,GAAGJ,KAAK,CAACK,QAAQ,EAAE;EAE9BC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAI,OAAOP,gBAAgB,KAAK,UAAU,EAAE;MACxCO,OAAO,GAAGC,UAAU,CAAC;;QAEjBR,gBAAgB,CAACS,WAAW,CAACV,KAAK,CAAC,CAAC;OACvC,EAAE,GAAG,CAAC;;IAGX,OAAO,MAAMW,YAAY,CAACH,OAAO,CAAC;GACrC,EAAE;;EAECJ,KAAK,CAACQ,WAAW,EACjBR,KAAK,CAACS,aAAa,EACnBT,KAAK,CAACU,YAAY,EAClBV,KAAK,CAACW,gBAAgB;;EAEtBb,IAAI,CAACc,MAAM,CAACC,uBAAuB,EACnCf,IAAI,CAACgB,QAAQ,CAACC,IAAI,EAClBf,KAAK,CAACgB,QAAQ,EACdlB,IAAI,CAACmB,SAAS,CAACC,MAAM,EACrBpB,IAAI,CAACqB,QAAQ,CAACC,gCAAgC;;EAE9CpB,KAAK,CAACqB,OAAO,CAChB,CAAC;AACN;;;;"}
@@ -0,0 +1,117 @@
1
+ import { useReactTable } from '@tanstack/react-table';
2
+ import { mapTableChildrenToColumns, useReactTableInitialState, configureReactTableOptions } from './util/setup.js';
3
+ import { useTableFeaturePreset } from './util/presets.js';
4
+ import { useTableColumnFreezing } from './features/useTableColumnFreezing.js';
5
+ import { useTableColumnOrdering } from './features/useTableColumnOrdering.js';
6
+ import { useTableFooter } from './features/useTableFooter.js';
7
+ import { useTableFontSize } from './features/useTableFontSize.js';
8
+ import { useTablePrinting } from './features/useTablePrinting.js';
9
+ import { useTableRowActions } from './features/useTableRowActions.js';
10
+ import { useTableRowActive } from './features/useTableRowActive.js';
11
+ import { useTableRowClick } from './features/useTableRowClick.js';
12
+ import { useTableRowExpansion } from './features/useTableRowExpansion.js';
13
+ import { useTableRowGoto } from './features/useTableRowGoto.js';
14
+ import { useTableRowGroups } from './features/useTableRowGroups.js';
15
+ import { useTableRowHeight } from './features/useTableRowHeight.js';
16
+ import { useTableRowSelection } from './features/useTableRowSelection.js';
17
+ import { useTableSearch } from './features/useTableSearch.js';
18
+ import { useTableServerLoading } from './features/useTableServerLoading.js';
19
+ import { useTableSettings } from './features/useTableSettings.js';
20
+ import { useTableDataListener } from './listeners/useTableDataListener.js';
21
+ import { useTableFilterListener } from './listeners/useTableFilterListener.js';
22
+ import { useTableFontSizeListener } from './listeners/useTableFontSizeListener.js';
23
+ import { useTableRowHeightListener } from './listeners/useTableRowHeightListener.js';
24
+ import { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener.js';
25
+ import { useTableSearchListener } from './listeners/useTableSearchListener.js';
26
+ import { useTableSettingsListener } from './listeners/useTableSettingsListener.js';
27
+ import { useTableShortcutsListener } from './listeners/useTableShortcutsListener.js';
28
+ import { useTableSortingListener } from './listeners/useTableSortingListener.js';
29
+ import { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener.js';
30
+ import { useTableRef } from './features/useTableRef.js';
31
+
32
+ function useTable(props, ref, meta, internalColumns) {
33
+ var _props$length, _instance$options$met;
34
+ // configure table options, merging props with presets
35
+ const options = useTableFeaturePreset(props);
36
+ // load any persisted table settings and merge them with any defaults
37
+ const [settings, setSettings] = useTableSettings(options.enableSettings, props.id, props.defaultSettings, props.onChangeSettings);
38
+ // configure common custom features
39
+ const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);
40
+ const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);
41
+ const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);
42
+ const footer = useTableFooter(options.enableFooter);
43
+ const printing = useTablePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset);
44
+ const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);
45
+ const rowActions = useTableRowActions(options.enableRowActions, props.rowActions, props.rowActionsLength);
46
+ const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
47
+ const rowExpansion = useTableRowExpansion(options.enableRowExpansion, props.rowExpansionRenderer);
48
+ const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);
49
+ const rowGroups = useTableRowGroups(props.rowActionsForGroup);
50
+ const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);
51
+ const rowSelection = useTableRowSelection(options.enableRowSelection);
52
+ const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
53
+ const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);
54
+ // TODO: memoise
55
+ // convert jsx column components into valid table columns
56
+ const {
57
+ columns,
58
+ ...defaultState
59
+ } = mapTableChildrenToColumns(props, settings, options, internalColumns);
60
+ // configure initial table state
61
+ const initialState = useReactTableInitialState(props, columns, settings, defaultState);
62
+ // create a react-table instance
63
+ // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel
64
+ const instance = useReactTable({
65
+ data: props.data,
66
+ columns,
67
+ // configure initial table state
68
+ initialState,
69
+ // configure react-table built-in features
70
+ ...configureReactTableOptions(options, props),
71
+ // settings that can be toggled by the user, and therefore require our own state
72
+ enableGlobalFilter: search.enableGlobalFilter,
73
+ // custom context
74
+ meta: {
75
+ // spread features from specific implementations
76
+ ...meta,
77
+ columnFreezing,
78
+ columnOrdering,
79
+ fontSize,
80
+ footer,
81
+ //getSettings
82
+ printing,
83
+ rowActions,
84
+ rowActive,
85
+ rowClick: rowClick,
86
+ rowExpansion,
87
+ rowGoto,
88
+ rowGroups,
89
+ rowHeight,
90
+ rowSelection,
91
+ search,
92
+ server
93
+ }
94
+ });
95
+ // state listeners - we have these so that we don't have to control state outside the table
96
+ useTableDataListener(instance);
97
+ useTableFilterListener(instance, props.onChangeFilter);
98
+ useTableFontSizeListener(instance);
99
+ useTableRowHeightListener(instance);
100
+ useTableRowSelectionListener(instance, props.onRowSelect);
101
+ useTableSearchListener(instance);
102
+ useTableServerLoadingListener(instance, server.loadPage);
103
+ useTableSettingsListener(instance, setSettings);
104
+ useTableShortcutsListener(instance, props.shortcuts);
105
+ useTableSortingListener(instance, props.onChangeSort);
106
+ // configure ref with reset functions
107
+ useTableRef(instance, ref);
108
+ return {
109
+ instance,
110
+ length: (_props$length = props.length) !== null && _props$length !== void 0 ? _props$length : props.data.length,
111
+ meta: (_instance$options$met = instance.options.meta) !== null && _instance$options$met !== void 0 ? _instance$options$met : {},
112
+ state: instance.getState()
113
+ };
114
+ }
115
+
116
+ export { useTable };
117
+ //# sourceMappingURL=useTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTable.js","sources":["../../../../../../../../src/primitives/Table/useTable/useTable.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRendererControl,\n TableFilterComparator,\n TableRef,\n useTableInternalColumns,\n useTableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { useTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableRef } from './features/useTableRef';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n //shortcutsState: ReturnType<typeof usePauseShortcuts>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n tooltip?: string;\n }\n}\n\nexport function useTable<TType = unknown, TMeta = {}>(\n props: useTableProps<TType>,\n ref: React.RefObject<TableRef>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableInternalColumns<TType>\n) {\n // configure table options, merging props with presets\n const options = useTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSettings,\n props.id,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, settings.showWarningWhenPrintingLargeDataset);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowExpansion = useTableRowExpansion<TType>(options.enableRowExpansion, props.rowExpansionRenderer);\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(props, settings, options, internalColumns);\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n // @ts-expect-error: fixing type issue while report and table3 TableMeta definitions live in parallel\n const instance = useReactTable<TType>({\n data: props.data,\n columns,\n // configure initial table state\n initialState,\n // configure react-table built-in features\n ...configureReactTableOptions(options, props),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n //getSettings\n printing,\n rowActions,\n rowActive,\n rowClick: rowClick as any,\n rowExpansion,\n rowGoto,\n rowGroups,\n rowHeight,\n rowSelection,\n search,\n server,\n },\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n // configure ref with reset functions\n useTableRef(instance, ref);\n\n return {\n instance,\n length: props.length ?? props.data.length,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["useTable","props","ref","meta","internalColumns","options","useTableFeaturePreset","settings","setSettings","useTableSettings","enableSettings","id","defaultSettings","onChangeSettings","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","showWarningWhenPrintingLargeDataset","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowExpansion","useTableRowExpansion","enableRowExpansion","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","data","configureReactTableOptions","enableGlobalFilter","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","useTableRef","length","_props$length","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAuFgBA,QAAQA,CACpBC,KAA2B,EAC3BC,GAA8B,EAC9BC,IAA6C,EAC7CC,eAAgD;;;EAGhD,MAAMC,OAAO,GAAGC,qBAAqB,CAACL,KAAK,CAAC;;EAG5C,MAAM,CAACM,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,cAAc,EACtBT,KAAK,CAACU,EAAE,EACRV,KAAK,CAACW,eAAe,EACrBX,KAAK,CAACY,gBAAgB,CACzB;;EAGD,MAAMC,cAAc,GAAGC,sBAAsB,CAACV,OAAO,CAACW,oBAAoB,CAAC;EAC3E,MAAMC,cAAc,GAAGC,sBAAsB,CAACb,OAAO,CAACc,oBAAoB,CAAC;EAC3E,MAAMC,QAAQ,GAAGC,gBAAgB,CAAChB,OAAO,CAACiB,cAAc,EAAEf,QAAQ,CAACa,QAAQ,CAAC;EAC5E,MAAMG,MAAM,GAAGC,cAAc,CAACnB,OAAO,CAACoB,YAAY,CAAC;EACnD,MAAMC,QAAQ,GAAGC,gBAAgB,CAACtB,OAAO,CAACuB,cAAc,EAAErB,QAAQ,CAACsB,mCAAmC,CAAC;EACvG,MAAMC,SAAS,GAAGC,iBAAiB,CAAC1B,OAAO,CAAC2B,eAAe,EAAE/B,KAAK,CAACgC,qBAAqB,CAAC;EACzF,MAAMC,UAAU,GAAGC,kBAAkB,CAAQ9B,OAAO,CAAC+B,gBAAgB,EAAEnC,KAAK,CAACiC,UAAU,EAAEjC,KAAK,CAACoC,gBAAgB,CAAC;EAChH,MAAMC,QAAQ,GAAGC,gBAAgB,CAAQlC,OAAO,CAACmC,cAAc,EAAEvC,KAAK,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MACRQ,UAAU;MACVJ,SAAS;MACTQ,QAAQ,EAAEA,QAAe;MACzBI,YAAY;MACZI,OAAO;MACPI,SAAS;MACTG,SAAS;MACTG,YAAY;MACZG,MAAM;MACNI;;GAEP,CAAC;;EAGFe,oBAAoB,CAACL,QAAQ,CAAC;EAC9BM,sBAAsB,CAACN,QAAQ,EAAExE,KAAK,CAAC+E,cAAc,CAAC;EACtDC,wBAAwB,CAACR,QAAQ,CAAC;EAClCS,yBAAyB,CAACT,QAAQ,CAAC;EACnCU,4BAA4B,CAACV,QAAQ,EAAExE,KAAK,CAACmF,WAAW,CAAC;EACzDC,sBAAsB,CAACZ,QAAQ,CAAC;EAChCa,6BAA6B,CAACb,QAAQ,EAAEV,MAAM,CAACE,QAAQ,CAAC;EACxDsB,wBAAwB,CAACd,QAAQ,EAAEjE,WAAW,CAAC;EAC/CgF,yBAAyB,CAACf,QAAQ,EAAExE,KAAK,CAACwF,SAAS,CAAC;EACpDC,uBAAuB,CAACjB,QAAQ,EAAExE,KAAK,CAAC0F,YAAY,CAAC;;EAGrDC,WAAW,CAACnB,QAAQ,EAAEvE,GAAG,CAAC;EAE1B,OAAO;IACHuE,QAAQ;IACRoB,MAAM,GAAAC,aAAA,GAAE7F,KAAK,CAAC4F,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAI7F,KAAK,CAAC0E,IAAI,CAACkB,MAAM;IACzC1F,IAAI,GAAA4F,qBAAA,GAAGtB,QAAQ,CAACpE,OAAO,CAACF,IAAI,cAAA4F,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEvB,QAAQ,CAACwB,QAAQ;GAC3B;AACL;;;;"}
@@ -1,5 +1,5 @@
1
- import 'date-fns';
2
- import '../../../../utils/date.js';
1
+ import { isDate } from 'date-fns';
2
+ import { format, parseFromISOString } from '../../../../utils/date.js';
3
3
  import { FontSizes } from '../../../../types.js';
4
4
 
5
5
  function isInternalColumn(id) {
@@ -17,6 +17,25 @@ const getCellMinWidth = (fontSize = 'medium') => {
17
17
  return 72;
18
18
  }
19
19
  };
20
+ // highlighting
21
+ function isCellHighlighted(query, value, dataType) {
22
+ if (value === undefined || value === null) {
23
+ return false;
24
+ }
25
+ return String(getCellValueAsString(value, dataType)).toLocaleLowerCase().includes(query.toLocaleLowerCase());
26
+ }
27
+ function getCellValueAsString(value, dataType) {
28
+ if (value === undefined || value === null) {
29
+ return '';
30
+ } else if (isDate(value)) {
31
+ var _format;
32
+ return (_format = format(value)) !== null && _format !== void 0 ? _format : '';
33
+ } else if (dataType === 'datetime' && typeof value === 'string') {
34
+ var _format2;
35
+ return (_format2 = format(parseFromISOString(value))) !== null && _format2 !== void 0 ? _format2 : '';
36
+ }
37
+ return String(value);
38
+ }
20
39
  // ordering
21
40
  function ensureOrdering(columns, settingsOrder, internalColumnsPinnedToTheRight = ['__actions']) {
22
41
  // internal columns come with a defined order
@@ -51,6 +70,14 @@ function ensureOrdering(columns, settingsOrder, internalColumnsPinnedToTheRight
51
70
  });
52
71
  return order;
53
72
  }
73
+ // freezing - we use the react-table pinning state, but that requires some mapping between them
74
+ function unfreezeAllExternalColumns(leftPinnedState) {
75
+ var _leftPinnedState$filt;
76
+ return (_leftPinnedState$filt = leftPinnedState === null || leftPinnedState === void 0 ? void 0 : leftPinnedState.filter(id => isInternalColumn(id) && id !== '__actions')) !== null && _leftPinnedState$filt !== void 0 ? _leftPinnedState$filt : [];
77
+ }
78
+ function freezeUptoExternalColumn(index, columns) {
79
+ return columns.slice(0, index + 1);
80
+ }
54
81
 
55
- export { ensureOrdering, getCellMinWidth, isInternalColumn };
82
+ export { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, getCellValueAsString, isCellHighlighted, isInternalColumn, unfreezeAllExternalColumns };
56
83
  //# sourceMappingURL=columns.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"columns.js","sources":["../../../../../../../../../src/primitives/Table/useTable/util/columns.ts"],"sourcesContent":["import { ColumnDef as ReactTableColumnDef } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { FontSize, FontSizes } from '../../../../types';\nimport { format, parseFromISOString } from '../../../../utils/date';\nimport { TableColumnDataType } from '../../types';\n\nexport function isInternalColumn(id: string | undefined) {\n return id?.startsWith('__');\n}\n\n// column widths\nexport const getCellMinWidth = (fontSize: FontSize = 'medium') => {\n switch (fontSize) {\n case FontSizes.small:\n return 57;\n\n case FontSizes.large:\n return 83;\n\n default:\n case FontSizes.medium:\n return 72;\n }\n};\n\n// highlighting\nexport function isCellHighlighted(query: string, value: unknown, dataType?: TableColumnDataType) {\n if (value === undefined || value === null) {\n return false;\n }\n\n return String(getCellValueAsString(value, dataType)).toLocaleLowerCase().includes(query.toLocaleLowerCase());\n}\n\nexport function getCellValueAsString(value: unknown, dataType?: TableColumnDataType): string {\n if (value === undefined || value === null) {\n return '';\n } else if (isDate(value)) {\n return format(value as Date) ?? '';\n } else if (dataType === 'datetime' && typeof value === 'string') {\n return format(parseFromISOString(value as string)) ?? '';\n }\n\n return String(value);\n}\n\n// ordering\nexport function ensureOrdering<TType = unknown>(\n columns: ReactTableColumnDef<TType>[],\n settingsOrder: string[] | undefined,\n internalColumnsPinnedToTheRight: string[] = ['__actions']\n): string[] {\n // internal columns come with a defined order\n const internalColumns = columns\n .filter(column => isInternalColumn(column.id) && !internalColumnsPinnedToTheRight.includes(String(column.id)))\n .map(column => column.id) as string[];\n\n // columns with ordering disabled should be moved to the front\n const orderingDisabled: string[] = [];\n const orderingEnabled: string[] = [];\n\n let orderedColumns = columns;\n\n // if settings is defined, make sure the columns that are actual children are sorted by it\n if (Array.isArray(settingsOrder)) {\n orderedColumns = columns.slice().sort(\n // the magic >>> 0 here ensures that columns that aren't found in settings, but are children, are pushed to the end\n (a, b) => (settingsOrder.indexOf(a.id as string) >>> 0) - (settingsOrder.indexOf(b.id as string) >>> 0)\n );\n }\n\n orderedColumns.forEach(column => {\n if (isInternalColumn(column.id)) {\n return;\n }\n\n if (column.meta?.enableOrdering) {\n orderingEnabled.push(column.id as string);\n } else {\n orderingDisabled.push(column.id as string);\n }\n });\n\n const order = [...internalColumns, ...orderingDisabled, ...orderingEnabled];\n\n // actions should always be last, enforce that\n internalColumnsPinnedToTheRight.forEach(id => {\n if (columns.findIndex(column => column.id === id) > -1) {\n order.push(id);\n }\n });\n\n return order;\n}\n\n// freezing - we use the react-table pinning state, but that requires some mapping between them\nexport function unfreezeAllExternalColumns(leftPinnedState?: string[]): string[] {\n return leftPinnedState?.filter(id => isInternalColumn(id) && id !== '__actions') ?? [];\n}\n\nexport function freezeUptoExternalColumn(index: number, columns: string[]): string[] {\n return columns.slice(0, index + 1);\n}\n"],"names":["isInternalColumn","id","startsWith","getCellMinWidth","fontSize","FontSizes","small","large","medium","ensureOrdering","columns","settingsOrder","internalColumnsPinnedToTheRight","internalColumns","filter","column","includes","String","map","orderingDisabled","orderingEnabled","orderedColumns","Array","isArray","slice","sort","a","b","indexOf","forEach","_column$meta","meta","enableOrdering","push","order","findIndex"],"mappings":";;;;SAMgBA,gBAAgBA,CAACC,EAAsB;EACnD,OAAOA,EAAE,aAAFA,EAAE,uBAAFA,EAAE,CAAEC,UAAU,CAAC,IAAI,CAAC;AAC/B;AAEA;MACaC,eAAe,GAAGA,CAACC,WAAqB,QAAQ;EACzD,QAAQA,QAAQ;IACZ,KAAKC,SAAS,CAACC,KAAK;MAChB,OAAO,EAAE;IAEb,KAAKD,SAAS,CAACE,KAAK;MAChB,OAAO,EAAE;IAEb;IACA,KAAKF,SAAS,CAACG,MAAM;MACjB,OAAO,EAAE;;AAErB;AAuBA;SACgBC,cAAcA,CAC1BC,OAAqC,EACrCC,aAAmC,EACnCC,kCAA4C,CAAC,WAAW,CAAC;;EAGzD,MAAMC,eAAe,GAAGH,OAAO,CAC1BI,MAAM,CAACC,MAAM,IAAIf,gBAAgB,CAACe,MAAM,CAACd,EAAE,CAAC,IAAI,CAACW,+BAA+B,CAACI,QAAQ,CAACC,MAAM,CAACF,MAAM,CAACd,EAAE,CAAC,CAA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ns.ts"],"sourcesContent":["import { ColumnDef as ReactTableColumnDef } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { FontSize, FontSizes } from '../../../../types';\nimport { format, parseFromISOString } from '../../../../utils/date';\nimport { TableColumnDataType } from '../../types';\n\nexport function isInternalColumn(id: string | undefined) {\n return id?.startsWith('__');\n}\n\n// column widths\nexport const getCellMinWidth = (fontSize: FontSize = 'medium') => {\n switch (fontSize) {\n case FontSizes.small:\n return 57;\n\n case FontSizes.large:\n return 83;\n\n default:\n case FontSizes.medium:\n return 72;\n }\n};\n\n// highlighting\nexport function isCellHighlighted(query: string, value: unknown, dataType?: TableColumnDataType) {\n if (value === undefined || value === null) {\n return false;\n }\n\n return String(getCellValueAsString(value, dataType)).toLocaleLowerCase().includes(query.toLocaleLowerCase());\n}\n\nexport function getCellValueAsString(value: unknown, dataType?: TableColumnDataType): string {\n if (value === undefined || value === null) {\n return '';\n } else if (isDate(value)) {\n return format(value as Date) ?? '';\n } else if (dataType === 'datetime' && typeof value === 'string') {\n return format(parseFromISOString(value as string)) ?? '';\n }\n\n return String(value);\n}\n\n// ordering\nexport function ensureOrdering<TType = unknown>(\n columns: ReactTableColumnDef<TType>[],\n settingsOrder: string[] | undefined,\n internalColumnsPinnedToTheRight: string[] = ['__actions']\n): string[] {\n // internal columns come with a defined order\n const internalColumns = columns\n .filter(column => isInternalColumn(column.id) && !internalColumnsPinnedToTheRight.includes(String(column.id)))\n .map(column => column.id) as string[];\n\n // columns with ordering disabled should be moved to the front\n const orderingDisabled: string[] = [];\n const orderingEnabled: string[] = [];\n\n let orderedColumns = columns;\n\n // if settings is defined, make sure the columns that are actual children are sorted by it\n if (Array.isArray(settingsOrder)) {\n orderedColumns = columns.slice().sort(\n // the magic >>> 0 here ensures that columns that aren't found in settings, but are children, are pushed to the end\n (a, b) => (settingsOrder.indexOf(a.id as string) >>> 0) - (settingsOrder.indexOf(b.id as string) >>> 0)\n );\n }\n\n orderedColumns.forEach(column => {\n if (isInternalColumn(column.id)) {\n return;\n }\n\n if (column.meta?.enableOrdering) {\n orderingEnabled.push(column.id as string);\n } else {\n orderingDisabled.push(column.id as string);\n }\n });\n\n const order = [...internalColumns, ...orderingDisabled, ...orderingEnabled];\n\n // actions should always be last, enforce that\n internalColumnsPinnedToTheRight.forEach(id => {\n if (columns.findIndex(column => column.id === id) > -1) {\n order.push(id);\n }\n });\n\n return order;\n}\n\n// freezing - we use the react-table pinning state, but that requires some mapping between them\nexport function unfreezeAllExternalColumns(leftPinnedState?: string[]): string[] {\n return leftPinnedState?.filter(id => isInternalColumn(id) && id !== '__actions') ?? [];\n}\n\nexport function freezeUptoExternalColumn(index: number, columns: string[]): string[] {\n return columns.slice(0, index + 1);\n}\n"],"names":["isInternalColumn","id","startsWith","getCellMinWidth","fontSize","FontSizes","small","large","medium","isCellHighlighted","query","value","dataType","undefined","String","getCellValueAsString","toLocaleLowerCase","includes","isDate","_format","format","_format2","parseFromISOString","ensureOrdering","columns","settingsOrder","internalColumnsPinnedToTheRight","internalColumns","filter","column","map","orderingDisabled","orderingEnabled","orderedColumns","Array","isArray","slice","sort","a","b","indexOf","forEach","_column$meta","meta","enableOrdering","push","order","findIndex","unfreezeAllExternalColumns","leftPinnedState","_leftPinnedState$filt","freezeUptoExternalColumn","index"],"mappings":";;;;SAMgBA,gBAAgBA,CAACC,EAAsB;EACnD,OAAOA,EAAE,aAAFA,EAAE,uBAAFA,EAAE,CAAEC,UAAU,CAAC,IAAI,CAAC;AAC/B;AAEA;MACaC,eAAe,GAAGA,CAACC,WAAqB,QAAQ;EACzD,QAAQA,QAAQ;IACZ,KAAKC,SAAS,CAACC,KAAK;MAChB,OAAO,EAAE;IAEb,KAAKD,SAAS,CAACE,KAAK;MAChB,OAAO,EAAE;IAEb;IACA,KAAKF,SAAS,CAACG,MAAM;MACjB,OAAO,EAAE;;AAErB;AAEA;SACgBC,iBAAiBA,CAACC,KAAa,EAAEC,KAAc,EAAEC,QAA8B;EAC3F,IAAID,KAAK,KA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AAwBA,CAACC,KAAa,EAAE5B,OAAiB;EACrE,OAAOA,OAAO,CAACY,KAAK,CAAC,CAAC,EAAEgB,KAAK,GAAG,CAAC,CAAC;AACtC;;;;"}
@@ -0,0 +1,131 @@
1
+ import { isDate, isBefore, isAfter, isEqual } from 'date-fns';
2
+ import { isWeakEqual as isWeakEqual$1 } from '../../../../utils/date.js';
3
+ import { getCellValueAsString } from './columns.js';
4
+ import { TableFilterComparator } from '../../types.js';
5
+
6
+ const toLowerCase = value => String(value !== null && value !== void 0 ? value : '').toLocaleLowerCase();
7
+ const isWeakContains = (left, right) => toLowerCase(left).includes(toLowerCase(right));
8
+ const isWeakEqual = (left, right) => toLowerCase(left) === toLowerCase(right);
9
+ // the filter type is only settable on the column definition, which would re-render all columns.
10
+ // so instead we store it in the filter value, but that means we also have to destructure that
11
+ // before we filter - that's why this custom filter function exists
12
+ function columnFilterFn(value, filter) {
13
+ try {
14
+ if (filter.comparator === TableFilterComparator.IsEmpty || filter.comparator === TableFilterComparator.IsNotEmpty) {
15
+ const isEmpty = value === undefined || value === null || value === '';
16
+ return filter.comparator === TableFilterComparator.IsEmpty ? isEmpty : !isEmpty;
17
+ }
18
+ if (filter.value === undefined || filter.value === null || filter.value === '') {
19
+ return true;
20
+ }
21
+ switch (filter.comparator) {
22
+ case TableFilterComparator.Contains:
23
+ return isWeakContains(value, filter.value);
24
+ case TableFilterComparator.DoesNotContain:
25
+ return !isWeakContains(value, filter.value);
26
+ case TableFilterComparator.IsEqualTo:
27
+ {
28
+ if (isDate(value)) {
29
+ return isDate(filter.value) && isWeakEqual$1(value, filter.value);
30
+ } else if (typeof filter.value === 'boolean') {
31
+ return value === filter.value;
32
+ }
33
+ return isWeakEqual(value, filter.value);
34
+ }
35
+ case TableFilterComparator.IsNotEqualTo:
36
+ {
37
+ if (isDate(value)) {
38
+ return isDate(filter.value) && isWeakEqual$1(value, filter.value) === false;
39
+ } else if (typeof filter.value === 'boolean') {
40
+ return value !== filter.value;
41
+ }
42
+ return !isWeakEqual(value, filter.value);
43
+ }
44
+ case TableFilterComparator.IsGreaterThan:
45
+ {
46
+ if (isDate(value)) {
47
+ return isDate(filter.value) && isAfter(value, filter.value);
48
+ } else {
49
+ const valueAsNumber = parseInt(value);
50
+ return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber > filter.value;
51
+ }
52
+ }
53
+ case TableFilterComparator.IsLessThan:
54
+ {
55
+ if (isDate(value)) {
56
+ return isDate(filter.value) && isBefore(value, filter.value);
57
+ } else {
58
+ const valueAsNumber = parseInt(value);
59
+ return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber < filter.value;
60
+ }
61
+ }
62
+ case TableFilterComparator.IsLessThanOrEqualTo:
63
+ {
64
+ if (isDate(value)) {
65
+ return isDate(filter.value) && (isBefore(value, filter.value) || isEqual(value, filter.value));
66
+ } else {
67
+ const valueAsNumber = parseInt(value);
68
+ return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber <= filter.value;
69
+ }
70
+ }
71
+ case TableFilterComparator.IsGreaterThanOrEqualTo:
72
+ {
73
+ if (isDate(value)) {
74
+ return isDate(filter.value) && (isAfter(value, filter.value) || isEqual(value, filter.value));
75
+ } else {
76
+ const valueAsNumber = parseInt(value);
77
+ return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber >= filter.value;
78
+ }
79
+ }
80
+ case TableFilterComparator.IsBetween:
81
+ {
82
+ const [fromValue, toValue] = filter.value;
83
+ if (isDate(value)) {
84
+ if (isDate(fromValue) && isBefore(value, fromValue)) {
85
+ return false;
86
+ } else if (isDate(toValue) && isAfter(value, toValue)) {
87
+ return false;
88
+ }
89
+ return true;
90
+ } else {
91
+ const valueAsNumber = parseInt(value);
92
+ if (isNaN(valueAsNumber)) {
93
+ return false;
94
+ }
95
+ if (fromValue !== undefined && valueAsNumber < fromValue) {
96
+ return false;
97
+ } else if (toValue !== undefined && valueAsNumber > toValue) {
98
+ return false;
99
+ }
100
+ return true;
101
+ }
102
+ }
103
+ case TableFilterComparator.HasAnyOf:
104
+ return Array.isArray(filter.value) && Array.isArray(value) ? filter.value.some(item => value.includes(item)) : false;
105
+ case TableFilterComparator.HasNoneOf:
106
+ return Array.isArray(filter.value) && Array.isArray(value) ? filter.value.every(item => value.includes(item) === false) : false;
107
+ case TableFilterComparator.HasAllOf:
108
+ return Array.isArray(filter.value) && Array.isArray(value) ? filter.value.filter(v => value.includes(v)).length === filter.value.length : false;
109
+ }
110
+ return false;
111
+ } catch (e) {
112
+ console.error(e);
113
+ return true;
114
+ }
115
+ }
116
+ function globalFilterFn(row, columnId, searchQuery) {
117
+ try {
118
+ if (row.original) {
119
+ var _row$_getAllCellsByCo, _row$_getAllCellsByCo2;
120
+ const dataType = (_row$_getAllCellsByCo = row._getAllCellsByColumnId()[columnId]) === null || _row$_getAllCellsByCo === void 0 ? void 0 : (_row$_getAllCellsByCo2 = _row$_getAllCellsByCo.column.columnDef.meta) === null || _row$_getAllCellsByCo2 === void 0 ? void 0 : _row$_getAllCellsByCo2.dataType;
121
+ const cellValue = getCellValueAsString(row.original[columnId], dataType);
122
+ return isWeakContains(cellValue, searchQuery);
123
+ }
124
+ } catch {
125
+ // we don't care, just fail silently and return no results
126
+ }
127
+ return false;
128
+ }
129
+
130
+ export { columnFilterFn, globalFilterFn, isWeakContains, isWeakEqual, toLowerCase };
131
+ //# sourceMappingURL=filtering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filtering.js","sources":["../../../../../../../../../src/primitives/Table/useTable/util/filtering.ts"],"sourcesContent":["import { Row as ReactTableRow } from '@tanstack/react-table';\nimport { isDate, isAfter as isAfterDate, isBefore as isBeforeDate, isEqual as isEqualDate } from 'date-fns';\nimport { isWeakEqual as isWeakEqualDate } from '../../../../utils/date';\nimport { TableFilterValue, TableFilterComparator } from '../../types';\nimport { getCellValueAsString } from './columns';\n\nexport const toLowerCase = (value: string | number) => String(value ?? '').toLocaleLowerCase();\nexport const isWeakContains = (left: string | number, right: string | number) => toLowerCase(left).includes(toLowerCase(right));\nexport const isWeakEqual = (left: string | number, right: string | number) => toLowerCase(left) === toLowerCase(right);\n\n// the filter type is only settable on the column definition, which would re-render all columns.\n// so instead we store it in the filter value, but that means we also have to destructure that\n// before we filter - that's why this custom filter function exists\nexport function columnFilterFn(value: any, filter: TableFilterValue) {\n try {\n if (filter.comparator === TableFilterComparator.IsEmpty || filter.comparator === TableFilterComparator.IsNotEmpty) {\n const isEmpty = value === undefined || value === null || value === '';\n return filter.comparator === TableFilterComparator.IsEmpty ? isEmpty : !isEmpty;\n }\n\n if (filter.value === undefined || filter.value === null || filter.value === '') {\n return true;\n }\n\n switch (filter.comparator) {\n case TableFilterComparator.Contains:\n return isWeakContains(value, filter.value);\n\n case TableFilterComparator.DoesNotContain:\n return !isWeakContains(value, filter.value);\n\n case TableFilterComparator.IsEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && isWeakEqualDate(value, filter.value);\n } else if (typeof filter.value === 'boolean') {\n return value === filter.value;\n }\n\n return isWeakEqual(value, filter.value);\n }\n\n case TableFilterComparator.IsNotEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && isWeakEqualDate(value, filter.value) === false;\n } else if (typeof filter.value === 'boolean') {\n return value !== filter.value;\n }\n\n return !isWeakEqual(value, filter.value);\n }\n\n case TableFilterComparator.IsGreaterThan: {\n if (isDate(value)) {\n return isDate(filter.value) && isAfterDate(value, filter.value);\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber > filter.value;\n }\n }\n\n case TableFilterComparator.IsLessThan: {\n if (isDate(value)) {\n return isDate(filter.value) && isBeforeDate(value, filter.value);\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber < filter.value;\n }\n }\n\n case TableFilterComparator.IsLessThanOrEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && (isBeforeDate(value, filter.value) || isEqualDate(value, filter.value));\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber <= filter.value;\n }\n }\n\n case TableFilterComparator.IsGreaterThanOrEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && (isAfterDate(value, filter.value) || isEqualDate(value, filter.value));\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber >= filter.value;\n }\n }\n\n case TableFilterComparator.IsBetween: {\n const [fromValue, toValue] = filter.value;\n\n if (isDate(value)) {\n if (isDate(fromValue) && isBeforeDate(value, fromValue)) {\n return false;\n } else if (isDate(toValue) && isAfterDate(value, toValue)) {\n return false;\n }\n\n return true;\n } else {\n const valueAsNumber = parseInt(value);\n\n if (isNaN(valueAsNumber)) {\n return false;\n }\n\n if (fromValue !== undefined && valueAsNumber < fromValue) {\n return false;\n } else if (toValue !== undefined && valueAsNumber > toValue) {\n return false;\n }\n\n return true;\n }\n }\n\n case TableFilterComparator.HasAnyOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.some(item => value.includes(item))\n : false;\n\n case TableFilterComparator.HasNoneOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.every(item => value.includes(item) === false)\n : false;\n\n case TableFilterComparator.HasAllOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.filter(v => value.includes(v)).length === filter.value.length\n : false;\n }\n\n return false;\n } catch (e) {\n console.error(e);\n return true;\n }\n}\n\nexport function globalFilterFn<TType = unknown>(row: ReactTableRow<TType>, columnId: string, searchQuery: string) {\n try {\n if (row.original) {\n const dataType = row._getAllCellsByColumnId()[columnId]?.column.columnDef.meta?.dataType;\n const cellValue = getCellValueAsString(row.original[columnId], dataType);\n return isWeakContains(cellValue, searchQuery);\n }\n } catch {\n // we don't care, just fail silently and return no results\n }\n\n return false;\n}\n"],"names":["toLowerCase","value","String","toLocaleLowerCase","isWeakContains","left","right","includes","isWeakEqual","columnFilterFn","filter","comparator","TableFilterComparator","IsEmpty","IsNotEmpty","isEmpty","undefined","Contains","DoesNotContain","IsEqualTo","isDate","isWeakEqualDate","IsNotEqualTo","IsGreaterThan","isAfterDate","valueAsNumber","parseInt","isNaN","IsLessThan","isBeforeDate","IsLessThanOrEqualTo","isEqualDate","IsGreaterThanOrEqualTo","IsBetween","fromValue","toValue","HasAnyOf","Array","isArray","some","item","HasNoneOf","every","HasAllOf","v","length","e","console","error","globalFilterFn","row","columnId","searchQuery","original","_row$_getAllCellsByCo","_row$_getAllCellsByCo2","dataType","_getAllCellsByColumnId","column","columnDef","meta","cellValue","getCellValueAsString"],"mappings":";;;;;MAMaA,WAAW,GAAIC,KAAsB,IAAKC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC,CAACE,iBAAiB;MAC/EC,cAAc,GAAGA,CAACC,IAAqB,EAAEC,KAAsB,KAAKN,WAAW,CAACK,IAAI,CAAC,CAACE,QAAQ,CAACP,WAAW,CAACM,KAAK,CAAC;MACjHE,WAAW,GAAGA,CAACH,IAAqB,EAAEC,KAAsB,KAAKN,WAAW,CAACK,IAAI,CAAC,KAAKL,WAAW,CAACM,KAAK;AAErH;AACA;AACA;SACgBG,cAAcA,CAACR,KAAU,EAAES,MAAwB;EAC/D,IAAI;IACA,IAAIA,MAAM,CAACC,UAAU,KAAKC,qBAAqB,CAACC,OAAO,IAAIH,MAAM,CAACC,UAAU,KAAKC,qBAAqB,CAACE,UAAU,EAAE;MAC/G,MAAMC,OAAO,GAAGd,KAAK,KAAKe,SAAS,IAAIf,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,EAAE;MACrE,OAAOS,MAAM,CAACC,UAAU,KAAKC,qBAAqB,CAACC,OAAO,GAAGE,OAAO,GAAG,CAACA,OAAO;;IAGnF,IAAIL,MAAM,CAACT,KAAK,KAAKe,SAAS,IAAIN,MAAM,CAACT,KAAK,KAAK,IAAI,IAAIS,MAAM,CAACT,KAAK,KAAK,EAAE,EAAE;MAC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"}
@@ -0,0 +1,131 @@
1
+ import React__default from 'react';
2
+
3
+ const DEFAULT_PRESET = {
4
+ // react-table built-in
5
+ enableFiltering: false,
6
+ enableSearch: false,
7
+ enableSorting: false,
8
+ enableColumnFreezing: false,
9
+ enableColumnHiding: false,
10
+ enableColumnResizing: false,
11
+ enableRowExpansion: false,
12
+ enableRowSelection: false,
13
+ enableRowSelectionSingle: false,
14
+ // custom -- common between all table types
15
+ enableColumnOrdering: false,
16
+ enableFontSize: false,
17
+ enableFooter: false,
18
+ enablePrinting: false,
19
+ enableRowActive: true,
20
+ enableRowActions: false,
21
+ enableRowClick: false,
22
+ enableRowGoto: false,
23
+ enableRowHeight: false,
24
+ enableSettings: false
25
+ };
26
+ const presets = {
27
+ lite: {
28
+ // react-table built-in
29
+ enableFiltering: true,
30
+ enableSearch: true,
31
+ enableSorting: true,
32
+ enableColumnFreezing: true,
33
+ enableColumnHiding: false,
34
+ enableColumnResizing: true,
35
+ enableRowExpansion: true,
36
+ enableRowSelection: true,
37
+ enableRowSelectionSingle: false,
38
+ // custom -- common between all table types
39
+ enableColumnOrdering: false,
40
+ enableFontSize: false,
41
+ enableFooter: true,
42
+ enablePrinting: false,
43
+ enableRowActive: true,
44
+ enableRowActions: true,
45
+ enableRowClick: true,
46
+ enableRowGoto: true,
47
+ enableRowHeight: false,
48
+ enableSettings: true
49
+ },
50
+ complex: {
51
+ // react-table built-in
52
+ enableFiltering: true,
53
+ enableSearch: true,
54
+ enableSorting: true,
55
+ enableColumnFreezing: true,
56
+ enableColumnHiding: true,
57
+ enableColumnResizing: true,
58
+ enableRowExpansion: true,
59
+ enableRowSelection: true,
60
+ enableRowSelectionSingle: false,
61
+ // custom -- common between all table types
62
+ enableColumnOrdering: true,
63
+ enableFontSize: true,
64
+ enableFooter: true,
65
+ enablePrinting: true,
66
+ enableRowActive: true,
67
+ enableRowActions: true,
68
+ enableRowClick: true,
69
+ enableRowGoto: true,
70
+ enableRowHeight: true,
71
+ enableSettings: true
72
+ }
73
+ };
74
+ function useTableFeaturePreset(props) {
75
+ var _props$enableRowActio, _props$enableRowClick, _props$enableRowGoto, _props$enableRowExpan, _props$enableRowSelec, _props$enableRowSelec2, _props$enableFilterin, _props$enableSearch, _props$enableSorting, _props$enableColumnFr, _props$enableColumnHi, _props$enableColumnRe, _props$enableColumnOr, _props$enableFontSize, _props$enableFooter, _props$enablePrinting, _props$enableRowActiv, _props$rowActions2, _props$enableRowHeigh, _props$enableSettings;
76
+ const presetOptions = props.preset ? presets[props.preset] : DEFAULT_PRESET;
77
+ const enableRowActions = (_props$enableRowActio = props.enableRowActions) !== null && _props$enableRowActio !== void 0 ? _props$enableRowActio : presetOptions.enableRowActions;
78
+ const enableRowClick = (_props$enableRowClick = props.enableRowClick) !== null && _props$enableRowClick !== void 0 ? _props$enableRowClick : presetOptions.enableRowClick;
79
+ const enableRowGoto = (_props$enableRowGoto = props.enableRowGoto) !== null && _props$enableRowGoto !== void 0 ? _props$enableRowGoto : presetOptions.enableRowGoto;
80
+ const enableRowExpansion = (_props$enableRowExpan = props.enableRowExpansion) !== null && _props$enableRowExpan !== void 0 ? _props$enableRowExpan : presetOptions.enableRowExpansion;
81
+ const enableRowSelection = (_props$enableRowSelec = props.enableRowSelection) !== null && _props$enableRowSelec !== void 0 ? _props$enableRowSelec : presetOptions.enableRowSelection;
82
+ const enableRowSelectionSingle = (_props$enableRowSelec2 = props.enableRowSelectionSingle) !== null && _props$enableRowSelec2 !== void 0 ? _props$enableRowSelec2 : presetOptions.enableRowSelectionSingle;
83
+ // guard options that might be unintentionally broken
84
+ React__default.useEffect(() => {
85
+ var _props$rowActions;
86
+ if (enableRowActions && !((_props$rowActions = props.rowActions) !== null && _props$rowActions !== void 0 && _props$rowActions.length)) {
87
+ console.warn(`Table (id: ${props.id}) - Row actions is enabled but no \`rowActions\` has been provided. Provide one to enable row actions or set \`enableRowActions\` to \`false\`.`);
88
+ }
89
+ if (enableRowClick && !props.onRowClick) {
90
+ console.warn(`Table (id: ${props.id}) - Row click is enabled but no \`onRowClick\` handler has been provided. Provide one to enable row click or set \`enableRowClick\` to \`false\`.`);
91
+ }
92
+ if (enableRowGoto && !props.onRowGoto) {
93
+ console.warn(`Table (id: ${props.id}) - Row click is enabled but no \`onRowGoto\` handler has been provided. Provide one to enable row goto or set \`enableRowGoto\` to \`false\`.`);
94
+ }
95
+ if (enableRowExpansion && !props.rowExpansionRenderer) {
96
+ console.warn(`Table (id: ${props.id}) - Row expansion is enabled but no \`rowExpansionRenderer\` has been provided. Provide one to enable row expansion or set \`enableRowExpansion\` to \`false\`.`);
97
+ }
98
+ if (enableRowSelection && !props.onRowSelect) {
99
+ console.warn(`Table (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\`.`);
100
+ }
101
+ if (enableRowSelectionSingle && !props.onRowSelect) {
102
+ console.warn(`Table (id: ${props.id}) - Row selection (single) is enabled but no \`onRowSelect\` handler has been provided. Provide one to enable row selection or set \`enableRowSelectionSingle\` to \`false\`.`);
103
+ }
104
+ }, []);
105
+ return {
106
+ // react-table built-in
107
+ enableFiltering: (_props$enableFilterin = props.enableFiltering) !== null && _props$enableFilterin !== void 0 ? _props$enableFilterin : presetOptions.enableFiltering,
108
+ enableSearch: (_props$enableSearch = props.enableSearch) !== null && _props$enableSearch !== void 0 ? _props$enableSearch : presetOptions.enableSearch,
109
+ enableSorting: (_props$enableSorting = props.enableSorting) !== null && _props$enableSorting !== void 0 ? _props$enableSorting : presetOptions.enableSorting,
110
+ enableColumnFreezing: (_props$enableColumnFr = props.enableColumnFreezing) !== null && _props$enableColumnFr !== void 0 ? _props$enableColumnFr : presetOptions.enableColumnFreezing,
111
+ enableColumnHiding: (_props$enableColumnHi = props.enableColumnHiding) !== null && _props$enableColumnHi !== void 0 ? _props$enableColumnHi : presetOptions.enableColumnHiding,
112
+ enableColumnResizing: (_props$enableColumnRe = props.enableColumnResizing) !== null && _props$enableColumnRe !== void 0 ? _props$enableColumnRe : presetOptions.enableColumnResizing,
113
+ enableRowExpansion: enableRowExpansion && !!props.rowExpansionRenderer,
114
+ enableRowSelection: enableRowSelection && !!props.onRowSelect,
115
+ enableRowSelectionSingle: enableRowSelectionSingle && !!props.onRowSelect,
116
+ // custom -- common between all table types
117
+ enableColumnOrdering: (_props$enableColumnOr = props.enableColumnOrdering) !== null && _props$enableColumnOr !== void 0 ? _props$enableColumnOr : presetOptions.enableColumnOrdering,
118
+ enableFontSize: (_props$enableFontSize = props.enableFontSize) !== null && _props$enableFontSize !== void 0 ? _props$enableFontSize : presetOptions.enableFontSize,
119
+ enableFooter: (_props$enableFooter = props.enableFooter) !== null && _props$enableFooter !== void 0 ? _props$enableFooter : presetOptions.enableFooter,
120
+ enablePrinting: (_props$enablePrinting = props.enablePrinting) !== null && _props$enablePrinting !== void 0 ? _props$enablePrinting : presetOptions.enablePrinting,
121
+ enableRowActive: (_props$enableRowActiv = props.enableRowActive) !== null && _props$enableRowActiv !== void 0 ? _props$enableRowActiv : presetOptions.enableRowActive,
122
+ enableRowActions: enableRowActions && !!((_props$rowActions2 = props.rowActions) !== null && _props$rowActions2 !== void 0 && _props$rowActions2.length),
123
+ enableRowClick: enableRowClick && !!props.onRowClick,
124
+ enableRowGoto: enableRowGoto && !!props.onRowGoto,
125
+ enableRowHeight: (_props$enableRowHeigh = props.enableRowHeight) !== null && _props$enableRowHeigh !== void 0 ? _props$enableRowHeigh : presetOptions.enableRowHeight,
126
+ enableSettings: (_props$enableSettings = props.enableSettings) !== null && _props$enableSettings !== void 0 ? _props$enableSettings : presetOptions.enableSettings
127
+ };
128
+ }
129
+
130
+ export { useTableFeaturePreset };
131
+ //# sourceMappingURL=presets.js.map