@economic/taco 2.13.0 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. package/dist/components/Field/Field.d.ts +4 -2
  2. package/dist/components/Icon/components/Location.d.ts +3 -0
  3. package/dist/components/Icon/components/index.d.ts +1 -1
  4. package/dist/components/Input/Input.d.ts +1 -1
  5. package/dist/components/Menu/components/Item.d.ts +1 -1
  6. package/dist/components/Menu/components/Link.d.ts +1 -1
  7. package/dist/components/Navigation2/components/Link.d.ts +1 -1
  8. package/dist/components/Provider/Localization.d.ts +0 -113
  9. package/dist/components/Select2/components/Option.d.ts +2 -2
  10. package/dist/components/Select2/components/Search.d.ts +1 -1
  11. package/dist/components/Table3/components/columns/styles.d.ts +2 -2
  12. package/dist/components/Table3/components/toolbar/Filter/filters/components/Filter.d.ts +4 -4
  13. package/dist/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.d.ts +3 -2
  14. package/dist/components/Table3/components/toolbar/Filter/filters/components/Placeholder.d.ts +3 -2
  15. package/dist/components/Table3/components/toolbar/FontSize.d.ts +4 -0
  16. package/dist/components/Table3/hooks/useCssGrid.d.ts +2 -1
  17. package/dist/components/Table3/hooks/useTable.d.ts +1 -1
  18. package/dist/components/Table3/types.d.ts +1 -1
  19. package/dist/components/Tag/Tag.d.ts +1 -1
  20. package/dist/esm/packages/taco/src/components/Field/Field.js +6 -4
  21. package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
  22. package/dist/esm/packages/taco/src/components/Icon/components/Location.js +17 -0
  23. package/dist/esm/packages/taco/src/components/Icon/components/Location.js.map +1 -0
  24. package/dist/esm/packages/taco/src/components/Icon/components/index.js +2 -0
  25. package/dist/esm/packages/taco/src/components/Icon/components/index.js.map +1 -1
  26. package/dist/esm/packages/taco/src/components/Provider/Localization.js +0 -110
  27. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  28. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +1 -1
  29. package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
  30. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +1 -1
  31. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  32. package/dist/esm/packages/taco/src/components/Select2/components/Search.js +1 -1
  33. package/dist/esm/packages/taco/src/components/Select2/components/Search.js.map +1 -1
  34. package/dist/esm/packages/taco/src/components/Table3/Table3.js +5 -4
  35. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  36. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +2 -5
  37. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  38. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +1 -4
  39. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  40. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js +6 -1
  42. package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Menu.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js +3 -2
  44. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/Actions.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js +14 -2
  46. package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +2 -2
  48. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +15 -8
  49. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
  50. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js +2 -2
  51. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Filter.js.map +1 -1
  52. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js +12 -3
  53. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterColumn.js.map +1 -1
  54. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js +0 -1
  55. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterComparator.js.map +1 -1
  56. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js +5 -3
  57. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/FilterValue.js.map +1 -1
  58. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js +2 -2
  59. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/components/Placeholder.js.map +1 -1
  60. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js +9 -4
  61. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/FontSize.js.map +1 -1
  62. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +2 -3
  63. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
  64. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js +3 -2
  65. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/RowHeight.js.map +1 -1
  66. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Settings.js +1 -1
  67. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js +6 -7
  68. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSettings.js.map +1 -1
  69. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js +48 -0
  70. package/dist/esm/packages/taco/src/components/Table3/hooks/listeners/useSettingsStateListener.js.map +1 -1
  71. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +4 -2
  72. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
  73. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js +6 -5
  74. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssGrid.js.map +1 -1
  75. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js +11 -9
  76. package/dist/esm/packages/taco/src/components/Table3/hooks/useCssVars.js.map +1 -1
  77. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  78. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
  79. package/dist/esm/packages/taco/src/index.js +1 -2
  80. package/dist/esm/packages/taco/src/index.js.map +1 -1
  81. package/dist/esm/packages/taco/src/utils/dom.js +1 -2
  82. package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
  83. package/dist/index.d.ts +0 -1
  84. package/dist/taco.cjs.development.js +485 -4052
  85. package/dist/taco.cjs.development.js.map +1 -1
  86. package/dist/taco.cjs.production.min.js +1 -1
  87. package/dist/taco.cjs.production.min.js.map +1 -1
  88. package/package.json +2 -2
  89. package/tailwind.config.js +3 -0
  90. package/types.json +13748 -32551
  91. package/dist/components/Table2/Table2.d.ts +0 -130
  92. package/dist/components/Table2/components/BatchActionsMenu.d.ts +0 -10
  93. package/dist/components/Table2/components/ColumnSettingsButton.d.ts +0 -6
  94. package/dist/components/Table2/components/EditModeButton.d.ts +0 -8
  95. package/dist/components/Table2/components/RowDensityButton.d.ts +0 -7
  96. package/dist/components/Table2/components/Search.d.ts +0 -3
  97. package/dist/components/Table2/components/ShortcutsGuideButton.d.ts +0 -7
  98. package/dist/components/Table2/components/column/Base.d.ts +0 -14
  99. package/dist/components/Table2/components/column/Cell.d.ts +0 -15
  100. package/dist/components/Table2/components/column/Footer.d.ts +0 -9
  101. package/dist/components/Table2/components/column/Header.d.ts +0 -11
  102. package/dist/components/Table2/components/column/Indicator.d.ts +0 -17
  103. package/dist/components/Table2/components/column/ValidationError.d.ts +0 -5
  104. package/dist/components/Table2/components/column/utils.d.ts +0 -3
  105. package/dist/components/Table2/components/filters/FiltersButton.d.ts +0 -7
  106. package/dist/components/Table2/components/filters/components/Column.d.ts +0 -11
  107. package/dist/components/Table2/components/filters/components/ColumnFilter.d.ts +0 -10
  108. package/dist/components/Table2/components/filters/components/Comparator.d.ts +0 -11
  109. package/dist/components/Table2/components/filters/components/EmptyFilter.d.ts +0 -13
  110. package/dist/components/Table2/components/filters/components/InferredControl.d.ts +0 -10
  111. package/dist/components/Table2/components/row/Context.d.ts +0 -24
  112. package/dist/components/Table2/components/row/ExpandedRow.d.ts +0 -6
  113. package/dist/components/Table2/components/row/Row.d.ts +0 -2
  114. package/dist/components/Table2/hooks/listeners/useActiveCellStateListener.d.ts +0 -3
  115. package/dist/components/Table2/hooks/listeners/useActiveRowStateListener.d.ts +0 -3
  116. package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +0 -3
  117. package/dist/components/Table2/hooks/listeners/useFilterStateListener.d.ts +0 -3
  118. package/dist/components/Table2/hooks/listeners/useRowSelectionListener.d.ts +0 -3
  119. package/dist/components/Table2/hooks/listeners/useSettingsStateListener.d.ts +0 -3
  120. package/dist/components/Table2/hooks/useActiveCell.d.ts +0 -26
  121. package/dist/components/Table2/hooks/useActiveRow.d.ts +0 -10
  122. package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +0 -37
  123. package/dist/components/Table2/hooks/useEditMode.d.ts +0 -28
  124. package/dist/components/Table2/hooks/useGridTemplate.d.ts +0 -2
  125. package/dist/components/Table2/hooks/useTable.d.ts +0 -46
  126. package/dist/components/Table2/hooks/useTableShortcuts.d.ts +0 -2
  127. package/dist/components/Table2/hooks/useVirtualiser.d.ts +0 -23
  128. package/dist/components/Table2/types.d.ts +0 -148
  129. package/dist/components/Table2/utilities/cell.d.ts +0 -14
  130. package/dist/components/Table2/utilities/columns.d.ts +0 -16
  131. package/dist/components/Table2/utilities/filterFn.d.ts +0 -3
  132. package/dist/esm/packages/taco/src/components/Table2/Table2.js +0 -422
  133. package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +0 -1
  134. package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js +0 -83
  135. package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js.map +0 -1
  136. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +0 -116
  137. package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +0 -1
  138. package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +0 -81
  139. package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js.map +0 -1
  140. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +0 -47
  141. package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +0 -1
  142. package/dist/esm/packages/taco/src/components/Table2/components/Search.js +0 -62
  143. package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +0 -1
  144. package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js +0 -32
  145. package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js.map +0 -1
  146. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +0 -605
  147. package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +0 -1
  148. package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js +0 -32
  149. package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js.map +0 -1
  150. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +0 -243
  151. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +0 -1
  152. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +0 -73
  153. package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +0 -1
  154. package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js +0 -30
  155. package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js.map +0 -1
  156. package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +0 -39
  157. package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +0 -1
  158. package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +0 -155
  159. package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js.map +0 -1
  160. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js +0 -31
  161. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js.map +0 -1
  162. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js +0 -129
  163. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js.map +0 -1
  164. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js +0 -68
  165. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js.map +0 -1
  166. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js +0 -63
  167. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js.map +0 -1
  168. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js +0 -99
  169. package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js.map +0 -1
  170. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +0 -58
  171. package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +0 -1
  172. package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js +0 -36
  173. package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js.map +0 -1
  174. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +0 -44
  175. package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +0 -1
  176. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js +0 -19
  177. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js.map +0 -1
  178. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +0 -28
  179. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +0 -1
  180. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js +0 -12
  181. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js.map +0 -1
  182. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js +0 -18
  183. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js.map +0 -1
  184. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js +0 -25
  185. package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js.map +0 -1
  186. package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js +0 -33
  187. package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js.map +0 -1
  188. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +0 -122
  189. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +0 -1
  190. package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js +0 -112
  191. package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js.map +0 -1
  192. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +0 -34
  193. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +0 -1
  194. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +0 -222
  195. package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +0 -1
  196. package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js +0 -46
  197. package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js.map +0 -1
  198. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +0 -48
  199. package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +0 -1
  200. package/dist/esm/packages/taco/src/components/Table2/types.js +0 -18
  201. package/dist/esm/packages/taco/src/components/Table2/types.js.map +0 -1
  202. package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +0 -41
  203. package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +0 -1
  204. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +0 -387
  205. package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +0 -1
  206. package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js +0 -100
  207. package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js.map +0 -1
  208. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +0 -32
  209. package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +0 -1
  210. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +0 -20
  211. package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +0 -1
@@ -1,99 +0,0 @@
1
- import React__default from 'react';
2
- import { Input } from '../../../../Input/Input.js';
3
- import { Datepicker } from '../../../../Datepicker/Datepicker.js';
4
- import { Switch } from '../../../../Switch/Switch.js';
5
- import { Table2FilterComparator } from '../../../types.js';
6
-
7
- const InferredControl = ({
8
- column,
9
- comparator,
10
- value
11
- }) => {
12
- var _column$columnDef$met2, _column$columnDef$met3;
13
- const ariaLabel = column.columnDef.header;
14
- if (comparator === Table2FilterComparator.IsEmpty || comparator === Table2FilterComparator.IsNotEmpty) {
15
- return null;
16
- }
17
- if (comparator === Table2FilterComparator.IsBetween) {
18
- var _column$columnDef$met;
19
- const fromValue = Array.isArray(value) ? value[0] : undefined;
20
- const toValue = Array.isArray(value) ? value[1] : undefined;
21
- if (((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.dataType) === 'datetime') {
22
- return /*#__PURE__*/React__default.createElement("div", {
23
- className: "flex flex-grow items-center gap-2"
24
- }, /*#__PURE__*/React__default.createElement(Datepicker, {
25
- "aria-label": ariaLabel,
26
- onChange: event => column.setFilterValue(currentValue => ({
27
- ...currentValue,
28
- value: [event.detail, toValue]
29
- })),
30
- value: fromValue
31
- }), /*#__PURE__*/React__default.createElement(Datepicker, {
32
- "aria-label": ariaLabel,
33
- onChange: event => column.setFilterValue(currentValue => ({
34
- ...currentValue,
35
- value: [fromValue, event.detail]
36
- })),
37
- value: toValue
38
- }));
39
- }
40
- return /*#__PURE__*/React__default.createElement("div", {
41
- className: "flex flex-grow items-center gap-2"
42
- }, /*#__PURE__*/React__default.createElement(Input, {
43
- "aria-label": ariaLabel,
44
- className: "flex-grow",
45
- placeholder: "from",
46
- onChange: event => {
47
- const value = parseInt(event.target.value);
48
- column.setFilterValue(currentValue => ({
49
- ...currentValue,
50
- value: [isNaN(value) ? undefined : value, toValue]
51
- }));
52
- },
53
- value: fromValue !== null && fromValue !== void 0 ? fromValue : ''
54
- }), /*#__PURE__*/React__default.createElement(Input, {
55
- className: "flex-grow",
56
- placeholder: "to",
57
- onChange: event => {
58
- const value = parseInt(event.target.value);
59
- column.setFilterValue(currentValue => ({
60
- ...currentValue,
61
- value: [fromValue, isNaN(value) ? undefined : value]
62
- }));
63
- },
64
- value: toValue !== null && toValue !== void 0 ? toValue : ''
65
- }));
66
- }
67
- if (((_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.dataType) === 'datetime') {
68
- return /*#__PURE__*/React__default.createElement(Datepicker, {
69
- "aria-label": ariaLabel,
70
- onChange: event => column.setFilterValue(currentValue => ({
71
- ...currentValue,
72
- value: event.detail
73
- })),
74
- value: value
75
- });
76
- } else if (((_column$columnDef$met3 = column.columnDef.meta) === null || _column$columnDef$met3 === void 0 ? void 0 : _column$columnDef$met3.dataType) === 'boolean') {
77
- return /*#__PURE__*/React__default.createElement(Switch, {
78
- "aria-label": ariaLabel,
79
- onChange: checked => column.setFilterValue(currentValue => ({
80
- ...currentValue,
81
- value: checked
82
- })),
83
- checked: value
84
- });
85
- }
86
- return /*#__PURE__*/React__default.createElement(Input, {
87
- "aria-label": ariaLabel,
88
- className: "flex-grow",
89
- onChange: event => column.setFilterValue(currentValue => ({
90
- ...currentValue,
91
- value: event.target.value
92
- })),
93
- required: true,
94
- value: value !== null && value !== void 0 ? value : ''
95
- });
96
- };
97
-
98
- export { InferredControl };
99
- //# sourceMappingURL=InferredControl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InferredControl.js","sources":["../../../../../../../../../../src/components/Table2/components/filters/components/InferredControl.tsx"],"sourcesContent":["import React from 'react';\nimport { Column as RTColumn } from '@tanstack/react-table';\nimport { Input } from '../../../../Input/Input';\nimport { Table2FilterComparator } from '../../../types';\nimport { Datepicker } from '../../../../Datepicker/Datepicker';\nimport { Switch } from '../../../../Switch/Switch';\n\ntype InferredControlProps = {\n column: RTColumn<any, any>;\n comparator: Table2FilterComparator;\n value: any | any[];\n};\n\nexport const InferredControl = ({ column, comparator, value }: InferredControlProps) => {\n const ariaLabel = column.columnDef.header as string | undefined;\n\n if (comparator === Table2FilterComparator.IsEmpty || comparator === Table2FilterComparator.IsNotEmpty) {\n return null;\n }\n\n if (comparator === Table2FilterComparator.IsBetween) {\n const fromValue = Array.isArray(value) ? value[0] : undefined;\n const toValue = Array.isArray(value) ? value[1] : undefined;\n\n if (column.columnDef.meta?.dataType === 'datetime') {\n return (\n <div className=\"flex flex-grow items-center gap-2\">\n <Datepicker\n aria-label={ariaLabel}\n onChange={event =>\n column.setFilterValue(currentValue => ({\n ...currentValue,\n value: [(event as any).detail, toValue],\n }))\n }\n value={fromValue}\n />\n <Datepicker\n aria-label={ariaLabel}\n onChange={event =>\n column.setFilterValue(currentValue => ({\n ...currentValue,\n value: [fromValue, (event as any).detail],\n }))\n }\n value={toValue}\n />\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-grow items-center gap-2\">\n <Input\n aria-label={ariaLabel}\n className=\"flex-grow\"\n placeholder=\"from\"\n onChange={event => {\n const value = parseInt(event.target.value);\n column.setFilterValue(currentValue => ({\n ...currentValue,\n value: [isNaN(value) ? undefined : value, toValue],\n }));\n }}\n value={fromValue ?? ''}\n />\n <Input\n className=\"flex-grow\"\n placeholder=\"to\"\n onChange={event => {\n const value = parseInt(event.target.value);\n column.setFilterValue(currentValue => ({\n ...currentValue,\n value: [fromValue, isNaN(value) ? undefined : value],\n }));\n }}\n value={toValue ?? ''}\n />\n </div>\n );\n }\n\n if (column.columnDef.meta?.dataType === 'datetime') {\n return (\n <Datepicker\n aria-label={ariaLabel}\n onChange={event =>\n column.setFilterValue(currentValue => ({\n ...currentValue,\n value: (event as any).detail,\n }))\n }\n value={value}\n />\n );\n } else if (column.columnDef.meta?.dataType === 'boolean') {\n return (\n <Switch\n aria-label={ariaLabel}\n onChange={checked =>\n column.setFilterValue(currentValue => ({\n ...currentValue,\n value: checked,\n }))\n }\n checked={value}\n />\n );\n }\n\n return (\n <Input\n aria-label={ariaLabel}\n className=\"flex-grow\"\n onChange={event =>\n column.setFilterValue(currentValue => ({\n ...currentValue,\n value: event.target.value,\n }))\n }\n required\n value={value ?? ''}\n />\n );\n};\n"],"names":["InferredControl","column","comparator","value","ariaLabel","columnDef","header","Table2FilterComparator","IsEmpty","IsNotEmpty","IsBetween","_column$columnDef$met","fromValue","Array","isArray","undefined","toValue","meta","dataType","React","className","Datepicker","onChange","event","setFilterValue","currentValue","detail","Input","placeholder","parseInt","target","isNaN","_column$columnDef$met2","_column$columnDef$met3","Switch","checked","required"],"mappings":";;;;;;MAaaA,eAAe,GAAGA,CAAC;EAAEC,MAAM;EAAEC,UAAU;EAAEC;CAA6B;;EAC/E,MAAMC,SAAS,GAAGH,MAAM,CAACI,SAAS,CAACC,MAA4B;EAE/D,IAAIJ,UAAU,KAAKK,sBAAsB,CAACC,OAAO,IAAIN,UAAU,KAAKK,sBAAsB,CAACE,UAAU,EAAE;IACnG,OAAO,IAAI;;EAGf,IAAIP,UAAU,KAAKK,sBAAsB,CAACG,SAAS,EAAE;IAAA,IAAAC,qBAAA;IACjD,MAAMC,SAAS,GAAGC,KAAK,CAACC,OAAO,CAACX,KAAK,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAGY,SAAS;IAC7D,MAAMC,OAAO,GAAGH,KAAK,CAACC,OAAO,CAACX,KAAK,CAAC,GAAGA,KAAK,CAAC,CAAC,CAAC,GAAGY,SAAS;IAE3D,IAAI,EAAAJ,qBAAA,GAAAV,MAAM,CAACI,SAAS,CAACY,IAAI,cAAAN,qBAAA,uBAArBA,qBAAA,CAAuBO,QAAQ,MAAK,UAAU,EAAE;MAChD,oBACIC;QAAKC,SAAS,EAAC;sBACXD,6BAACE,UAAU;sBACKjB,SAAS;QACrBkB,QAAQ,EAAEC,KAAK,IACXtB,MAAM,CAACuB,cAAc,CAACC,YAAY,KAAK;UACnC,GAAGA,YAAY;UACftB,KAAK,EAAE,CAAEoB,KAAa,CAACG,MAAM,EAAEV,OAAO;SACzC,CAAC,CAAC;QAEPb,KAAK,EAAES;QACT,eACFO,6BAACE,UAAU;sBACKjB,SAAS;QACrBkB,QAAQ,EAAEC,KAAK,IACXtB,MAAM,CAACuB,cAAc,CAACC,YAAY,KAAK;UACnC,GAAGA,YAAY;UACftB,KAAK,EAAE,CAACS,SAAS,EAAGW,KAAa,CAACG,MAAM;SAC3C,CAAC,CAAC;QAEPvB,KAAK,EAAEa;QACT,CACA;;IAId,oBACIG;MAAKC,SAAS,EAAC;oBACXD,6BAACQ,KAAK;oBACUvB,SAAS;MACrBgB,SAAS,EAAC,WAAW;MACrBQ,WAAW,EAAC,MAAM;MAClBN,QAAQ,EAAEC,KAAK;QACX,MAAMpB,KAAK,GAAG0B,QAAQ,CAACN,KAAK,CAACO,MAAM,CAAC3B,KAAK,CAAC;QAC1CF,MAAM,CAACuB,cAAc,CAACC,YAAY,KAAK;UACnC,GAAGA,YAAY;UACftB,KAAK,EAAE,CAAC4B,KAAK,CAAC5B,KAAK,CAAC,GAAGY,SAAS,GAAGZ,KAAK,EAAEa,OAAO;SACpD,CAAC,CAAC;OACN;MACDb,KAAK,EAAES,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI;MACtB,eACFO,6BAACQ,KAAK;MACFP,SAAS,EAAC,WAAW;MACrBQ,WAAW,EAAC,IAAI;MAChBN,QAAQ,EAAEC,KAAK;QACX,MAAMpB,KAAK,GAAG0B,QAAQ,CAACN,KAAK,CAACO,MAAM,CAAC3B,KAAK,CAAC;QAC1CF,MAAM,CAACuB,cAAc,CAACC,YAAY,KAAK;UACnC,GAAGA,YAAY;UACftB,KAAK,EAAE,CAACS,SAAS,EAAEmB,KAAK,CAAC5B,KAAK,CAAC,GAAGY,SAAS,GAAGZ,KAAK;SACtD,CAAC,CAAC;OACN;MACDA,KAAK,EAAEa,OAAO,aAAPA,OAAO,cAAPA,OAAO,GAAI;MACpB,CACA;;EAId,IAAI,EAAAgB,sBAAA,GAAA/B,MAAM,CAACI,SAAS,CAACY,IAAI,cAAAe,sBAAA,uBAArBA,sBAAA,CAAuBd,QAAQ,MAAK,UAAU,EAAE;IAChD,oBACIC,6BAACE,UAAU;oBACKjB,SAAS;MACrBkB,QAAQ,EAAEC,KAAK,IACXtB,MAAM,CAACuB,cAAc,CAACC,YAAY,KAAK;QACnC,GAAGA,YAAY;QACftB,KAAK,EAAGoB,KAAa,CAACG;OACzB,CAAC,CAAC;MAEPvB,KAAK,EAAEA;MACT;GAET,MAAM,IAAI,EAAA8B,sBAAA,GAAAhC,MAAM,CAACI,SAAS,CAACY,IAAI,cAAAgB,sBAAA,uBAArBA,sBAAA,CAAuBf,QAAQ,MAAK,SAAS,EAAE;IACtD,oBACIC,6BAACe,MAAM;oBACS9B,SAAS;MACrBkB,QAAQ,EAAEa,OAAO,IACblC,MAAM,CAACuB,cAAc,CAACC,YAAY,KAAK;QACnC,GAAGA,YAAY;QACftB,KAAK,EAAEgC;OACV,CAAC,CAAC;MAEPA,OAAO,EAAEhC;MACX;;EAIV,oBACIgB,6BAACQ,KAAK;kBACUvB,SAAS;IACrBgB,SAAS,EAAC,WAAW;IACrBE,QAAQ,EAAEC,KAAK,IACXtB,MAAM,CAACuB,cAAc,CAACC,YAAY,KAAK;MACnC,GAAGA,YAAY;MACftB,KAAK,EAAEoB,KAAK,CAACO,MAAM,CAAC3B;KACvB,CAAC,CAAC;IAEPiC,QAAQ;IACRjC,KAAK,EAAEA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI;IAClB;AAEV;;;;"}
@@ -1,58 +0,0 @@
1
- import React__default from 'react';
2
-
3
- const RowContext = /*#__PURE__*/React__default.createContext({
4
- isActive: false,
5
- editMode: {
6
- validationErrors: null,
7
- setValidationErrors: () => undefined,
8
- rowMoveReason: {},
9
- setRowMoveReason: () => undefined
10
- },
11
- rowIndex: undefined,
12
- isHovered: false,
13
- setIsHovered: () => undefined
14
- });
15
- const RowContextProvider = ({
16
- isActiveRow,
17
- children,
18
- meta,
19
- rowIndex
20
- }) => {
21
- // we use non-css hovered state to determine whether to render actions or not, for performance
22
- const [isHovered, setIsHovered] = React__default.useState(false);
23
- // editing specific functionality
24
- const [validationErrors, setValidationErrors] = React__default.useState(null);
25
- const [rowMoveReason, setRowMoveReason] = React__default.useState({});
26
- // This effect aims to focus the first focussable cell when edit mode is turned on.
27
- React__default.useEffect(() => {
28
- var _meta$tableRef$curren;
29
- const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
30
- // If the foucs is outside the table i.e., table action popups, search etc., then don't focus the first cell.
31
- if (isActiveRow && isFocusInsideTable) {
32
- meta.editMode.moveToFirstColumn(meta.focussableColumnIndexes);
33
- }
34
- // We are intentionally not adding activeRow to the depency variable so that everytime active row is changed,
35
- // first focussable cell is not focussed.
36
- }, [meta.editMode.isEditing, meta.focussableColumnIndexes]);
37
- const context = React__default.useMemo(() => {
38
- return {
39
- isActive: isActiveRow,
40
- editMode: {
41
- validationErrors,
42
- setValidationErrors,
43
- rowMoveReason,
44
- setRowMoveReason
45
- },
46
- rowIndex,
47
- isHovered,
48
- setIsHovered
49
- };
50
- }, [isActiveRow, isHovered, rowMoveReason, validationErrors, rowIndex]);
51
- return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
52
- value: context
53
- }, children);
54
- };
55
- const useRowContext = () => React__default.useContext(RowContext);
56
-
57
- export { RowContext, RowContextProvider, useRowContext };
58
- //# sourceMappingURL=Context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Context.js","sources":["../../../../../../../../../src/components/Table2/components/row/Context.tsx"],"sourcesContent":["import React from 'react';\nimport { SaveHandlerErrorResponse } from '../../types';\nimport { IndicatorReason } from '../column/Indicator';\n\ntype RowContextValue = {\n // we store this here because the \"real\" row index comes from the virtualiser,\n // and that isn't accessible in some places we need it - like the row actions column\n isActive: boolean;\n editMode: {\n validationErrors: SaveHandlerErrorResponse;\n setValidationErrors: React.Dispatch<React.SetStateAction<SaveHandlerErrorResponse>>;\n rowMoveReason: Record<string, IndicatorReason | null>;\n setRowMoveReason: React.Dispatch<React.SetStateAction<Record<string, IndicatorReason | null>>>;\n };\n rowIndex?: number;\n isHovered: boolean;\n setIsHovered: React.Dispatch<React.SetStateAction<boolean>>;\n};\n\nexport const RowContext = React.createContext<RowContextValue>({\n isActive: false,\n editMode: {\n validationErrors: null,\n setValidationErrors: () => undefined,\n rowMoveReason: {},\n setRowMoveReason: () => undefined,\n },\n rowIndex: undefined,\n isHovered: false,\n setIsHovered: () => undefined,\n});\n\nexport const RowContextProvider = ({ isActiveRow, children, meta, rowIndex }) => {\n // we use non-css hovered state to determine whether to render actions or not, for performance\n const [isHovered, setIsHovered] = React.useState(false);\n\n // editing specific functionality\n const [validationErrors, setValidationErrors] = React.useState<SaveHandlerErrorResponse | null>(null);\n const [rowMoveReason, setRowMoveReason] = React.useState<Record<string, IndicatorReason | null>>({});\n\n // This effect aims to focus the first focussable cell when edit mode is turned on.\n React.useEffect(() => {\n const isFocusInsideTable = meta.tableRef.current?.contains(document.activeElement);\n\n // If the foucs is outside the table i.e., table action popups, search etc., then don't focus the first cell.\n if (isActiveRow && isFocusInsideTable) {\n meta.editMode.moveToFirstColumn(meta.focussableColumnIndexes);\n }\n // We are intentionally not adding activeRow to the depency variable so that everytime active row is changed,\n // first focussable cell is not focussed.\n }, [meta.editMode.isEditing, meta.focussableColumnIndexes]);\n\n const context = React.useMemo(() => {\n return {\n isActive: isActiveRow,\n editMode: {\n validationErrors,\n setValidationErrors,\n rowMoveReason,\n setRowMoveReason,\n },\n rowIndex,\n isHovered,\n setIsHovered,\n };\n }, [isActiveRow, isHovered, rowMoveReason, validationErrors, rowIndex]);\n\n return <RowContext.Provider value={context}>{children}</RowContext.Provider>;\n};\n\nexport const useRowContext = () => React.useContext(RowContext);\n"],"names":["RowContext","React","createContext","isActive","editMode","validationErrors","setValidationErrors","undefined","rowMoveReason","setRowMoveReason","rowIndex","isHovered","setIsHovered","RowContextProvider","isActiveRow","children","meta","useState","useEffect","isFocusInsideTable","_meta$tableRef$curren","tableRef","current","contains","document","activeElement","moveToFirstColumn","focussableColumnIndexes","isEditing","context","useMemo","Provider","value","useRowContext","useContext"],"mappings":";;MAmBaA,UAAU,gBAAGC,cAAK,CAACC,aAAa,CAAkB;EAC3DC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE;IACNC,gBAAgB,EAAE,IAAI;IACtBC,mBAAmB,EAAEA,MAAMC,SAAS;IACpCC,aAAa,EAAE,EAAE;IACjBC,gBAAgB,EAAEA,MAAMF;GAC3B;EACDG,QAAQ,EAAEH,SAAS;EACnBI,SAAS,EAAE,KAAK;EAChBC,YAAY,EAAEA,MAAML;CACvB;MAEYM,kBAAkB,GAAGA,CAAC;EAAEC,WAAW;EAAEC,QAAQ;EAAEC,IAAI;EAAEN;CAAU;;EAExE,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGX,cAAK,CAACgB,QAAQ,CAAC,KAAK,CAAC;;EAGvD,MAAM,CAACZ,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGL,cAAK,CAACgB,QAAQ,CAAkC,IAAI,CAAC;EACrG,MAAM,CAACT,aAAa,EAAEC,gBAAgB,CAAC,GAAGR,cAAK,CAACgB,QAAQ,CAAyC,EAAE,CAAC;;EAGpGhB,cAAK,CAACiB,SAAS,CAAC;;IACZ,MAAMC,kBAAkB,IAAAC,qBAAA,GAAGJ,IAAI,CAACK,QAAQ,CAACC,OAAO,cAAAF,qBAAA,uBAArBA,qBAAA,CAAuBG,QAAQ,CAACC,QAAQ,CAACC,aAAa,CAAC;;IAGlF,IAAIX,WAAW,IAAIK,kBAAkB,EAAE;MACnCH,IAAI,CAACZ,QAAQ,CAACsB,iBAAiB,CAACV,IAAI,CAACW,uBAAuB,CAAC;;;;GAIpE,EAAE,CAACX,IAAI,CAACZ,QAAQ,CAACwB,SAAS,EAAEZ,IAAI,CAACW,uBAAuB,CAAC,CAAC;EAE3D,MAAME,OAAO,GAAG5B,cAAK,CAAC6B,OAAO,CAAC;IAC1B,OAAO;MACH3B,QAAQ,EAAEW,WAAW;MACrBV,QAAQ,EAAE;QACNC,gBAAgB;QAChBC,mBAAmB;QACnBE,aAAa;QACbC;OACH;MACDC,QAAQ;MACRC,SAAS;MACTC;KACH;GACJ,EAAE,CAACE,WAAW,EAAEH,SAAS,EAAEH,aAAa,EAAEH,gBAAgB,EAAEK,QAAQ,CAAC,CAAC;EAEvE,oBAAOT,6BAACD,UAAU,CAAC+B,QAAQ;IAACC,KAAK,EAAEH;KAAUd,QAAQ,CAAuB;AAChF;MAEakB,aAAa,GAAGA,MAAMhC,cAAK,CAACiC,UAAU,CAAClC,UAAU;;;;"}
@@ -1,36 +0,0 @@
1
- import React__default from 'react';
2
-
3
- const ExpandedRow = ({
4
- index,
5
- setSize,
6
- ...props
7
- }) => {
8
- const ref = React__default.useRef(null);
9
- React__default.useEffect(() => {
10
- if (ref.current) {
11
- var _ref$current;
12
- const height = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getBoundingClientRect().height;
13
- setSize(sizes => {
14
- if (height !== sizes[index]) {
15
- var _ref$current2;
16
- return {
17
- ...sizes,
18
- [index]: (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.getBoundingClientRect().height
19
- };
20
- }
21
- return sizes;
22
- });
23
- }
24
- }, []);
25
- if (props.children === null || props.children === undefined) {
26
- return null;
27
- }
28
- return /*#__PURE__*/React__default.createElement("div", Object.assign({
29
- className: "border-grey-300 bg-grey-50 col-span-full border-b p-4"
30
- }, props, {
31
- ref: ref
32
- }));
33
- };
34
-
35
- export { ExpandedRow };
36
- //# sourceMappingURL=ExpandedRow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpandedRow.js","sources":["../../../../../../../../../src/components/Table2/components/row/ExpandedRow.tsx"],"sourcesContent":["import React from 'react';\n\nexport const ExpandedRow = ({ index, setSize, ...props }) => {\n const ref = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (ref.current) {\n const height = ref.current?.getBoundingClientRect().height;\n\n setSize(sizes => {\n if (height !== sizes[index]) {\n return { ...sizes, [index]: ref.current?.getBoundingClientRect().height };\n }\n\n return sizes;\n });\n }\n }, []);\n\n if (props.children === null || props.children === undefined) {\n return null;\n }\n\n return <div className=\"border-grey-300 bg-grey-50 col-span-full border-b p-4\" {...props} ref={ref} />;\n};\n"],"names":["ExpandedRow","index","setSize","props","ref","React","useRef","useEffect","current","_ref$current","height","getBoundingClientRect","sizes","_ref$current2","children","undefined","className"],"mappings":";;MAEaA,WAAW,GAAGA,CAAC;EAAEC,KAAK;EAAEC,OAAO;EAAE,GAAGC;CAAO;EACpD,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EAE9CD,cAAK,CAACE,SAAS,CAAC;IACZ,IAAIH,GAAG,CAACI,OAAO,EAAE;MAAA,IAAAC,YAAA;MACb,MAAMC,MAAM,IAAAD,YAAA,GAAGL,GAAG,CAACI,OAAO,cAAAC,YAAA,uBAAXA,YAAA,CAAaE,qBAAqB,EAAE,CAACD,MAAM;MAE1DR,OAAO,CAACU,KAAK;QACT,IAAIF,MAAM,KAAKE,KAAK,CAACX,KAAK,CAAC,EAAE;UAAA,IAAAY,aAAA;UACzB,OAAO;YAAE,GAAGD,KAAK;YAAE,CAACX,KAAK,IAAAY,aAAA,GAAGT,GAAG,CAACI,OAAO,cAAAK,aAAA,uBAAXA,aAAA,CAAaF,qBAAqB,EAAE,CAACD;WAAQ;;QAG7E,OAAOE,KAAK;OACf,CAAC;;GAET,EAAE,EAAE,CAAC;EAEN,IAAIT,KAAK,CAACW,QAAQ,KAAK,IAAI,IAAIX,KAAK,CAACW,QAAQ,KAAKC,SAAS,EAAE;IACzD,OAAO,IAAI;;EAGf,oBAAOV;IAAKW,SAAS,EAAC;KAA4Db,KAAK;IAAEC,GAAG,EAAEA;KAAO;AACzG;;;;"}
@@ -1,44 +0,0 @@
1
- import React__default from 'react';
2
- import { useDropTarget } from '../../../../utils/hooks/useDropTarget.js';
3
- import { RowContextProvider, useRowContext } from './Context.js';
4
-
5
- const InternalRow = ({
6
- onRowDrop,
7
- row,
8
- rowIndex,
9
- table,
10
- ...props
11
- }) => {
12
- const {
13
- setIsHovered
14
- } = useRowContext();
15
- const meta = table.options.meta;
16
- const isActiveRow = meta.activeRowIndex === rowIndex;
17
- const isDragging = meta.dragging[row.id];
18
- const [isDraggedOver, dropTargetProps] = useDropTarget(event => onRowDrop(event, row.original));
19
- const attributes = {
20
- ...props,
21
- ...(typeof onRowDrop === 'function' ? dropTargetProps : undefined),
22
- 'aria-current': isActiveRow ? true : undefined,
23
- 'aria-grabbed': isDragging ? true : undefined,
24
- 'data-row-index': rowIndex,
25
- 'data-dragged-over': isDraggedOver,
26
- draggable: meta.enableRowDragging ? true : undefined,
27
- onMouseEnter: () => setIsHovered(true),
28
- onMouseLeave: () => setIsHovered(false),
29
- role: 'row'
30
- };
31
- return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes));
32
- };
33
- const Row = props => {
34
- const meta = props.table.options.meta;
35
- const isActiveRow = meta.activeRowIndex === props.rowIndex;
36
- return /*#__PURE__*/React__default.createElement(RowContextProvider, {
37
- isActiveRow: isActiveRow,
38
- meta: props.table.options.meta,
39
- rowIndex: props.rowIndex
40
- }, /*#__PURE__*/React__default.createElement(InternalRow, Object.assign({}, props)));
41
- };
42
-
43
- export { Row };
44
- //# sourceMappingURL=Row.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Row.js","sources":["../../../../../../../../../src/components/Table2/components/row/Row.tsx"],"sourcesContent":["import React from 'react';\nimport { TableMeta } from '@tanstack/react-table';\nimport { RowContextProvider, useRowContext } from './Context';\nimport { useDropTarget } from '../../../../utils/hooks/useDropTarget';\n\nconst InternalRow = ({ onRowDrop, row, rowIndex, table, ...props }) => {\n const { setIsHovered } = useRowContext();\n\n const meta = table.options.meta as TableMeta<any>;\n const isActiveRow = meta.activeRowIndex === rowIndex;\n const isDragging = meta.dragging[row.id];\n\n const [isDraggedOver, dropTargetProps] = useDropTarget(event => onRowDrop(event, row.original));\n\n const attributes = {\n ...props,\n ...(typeof onRowDrop === 'function' ? dropTargetProps : undefined),\n 'aria-current': isActiveRow ? true : undefined,\n 'aria-grabbed': isDragging ? true : undefined,\n 'data-row-index': rowIndex,\n 'data-dragged-over': isDraggedOver,\n draggable: meta.enableRowDragging ? true : undefined,\n onMouseEnter: () => setIsHovered(true),\n onMouseLeave: () => setIsHovered(false),\n role: 'row',\n };\n\n return <div {...attributes} />;\n};\n\nexport const Row = props => {\n const meta = props.table.options.meta as TableMeta<any>;\n const isActiveRow = meta.activeRowIndex === props.rowIndex;\n\n return (\n <RowContextProvider isActiveRow={isActiveRow} meta={props.table.options.meta} rowIndex={props.rowIndex}>\n <InternalRow {...props} />\n </RowContextProvider>\n );\n};\n"],"names":["InternalRow","onRowDrop","row","rowIndex","table","props","setIsHovered","useRowContext","meta","options","isActiveRow","activeRowIndex","isDragging","dragging","id","isDraggedOver","dropTargetProps","useDropTarget","event","original","attributes","undefined","draggable","enableRowDragging","onMouseEnter","onMouseLeave","role","React","Row","RowContextProvider"],"mappings":";;;;AAKA,MAAMA,WAAW,GAAGA,CAAC;EAAEC,SAAS;EAAEC,GAAG;EAAEC,QAAQ;EAAEC,KAAK;EAAE,GAAGC;CAAO;EAC9D,MAAM;IAAEC;GAAc,GAAGC,aAAa,EAAE;EAExC,MAAMC,IAAI,GAAGJ,KAAK,CAACK,OAAO,CAACD,IAAsB;EACjD,MAAME,WAAW,GAAGF,IAAI,CAACG,cAAc,KAAKR,QAAQ;EACpD,MAAMS,UAAU,GAAGJ,IAAI,CAACK,QAAQ,CAACX,GAAG,CAACY,EAAE,CAAC;EAExC,MAAM,CAACC,aAAa,EAAEC,eAAe,CAAC,GAAGC,aAAa,CAACC,KAAK,IAAIjB,SAAS,CAACiB,KAAK,EAAEhB,GAAG,CAACiB,QAAQ,CAAC,CAAC;EAE/F,MAAMC,UAAU,GAAG;IACf,GAAGf,KAAK;IACR,IAAI,OAAOJ,SAAS,KAAK,UAAU,GAAGe,eAAe,GAAGK,SAAS,CAAC;IAClE,cAAc,EAAEX,WAAW,GAAG,IAAI,GAAGW,SAAS;IAC9C,cAAc,EAAET,UAAU,GAAG,IAAI,GAAGS,SAAS;IAC7C,gBAAgB,EAAElB,QAAQ;IAC1B,mBAAmB,EAAEY,aAAa;IAClCO,SAAS,EAAEd,IAAI,CAACe,iBAAiB,GAAG,IAAI,GAAGF,SAAS;IACpDG,YAAY,EAAEA,MAAMlB,YAAY,CAAC,IAAI,CAAC;IACtCmB,YAAY,EAAEA,MAAMnB,YAAY,CAAC,KAAK,CAAC;IACvCoB,IAAI,EAAE;GACT;EAED,oBAAOC,sDAASP,UAAU,EAAI;AAClC,CAAC;MAEYQ,GAAG,GAAGvB,KAAK;EACpB,MAAMG,IAAI,GAAGH,KAAK,CAACD,KAAK,CAACK,OAAO,CAACD,IAAsB;EACvD,MAAME,WAAW,GAAGF,IAAI,CAACG,cAAc,KAAKN,KAAK,CAACF,QAAQ;EAE1D,oBACIwB,6BAACE,kBAAkB;IAACnB,WAAW,EAAEA,WAAW;IAAEF,IAAI,EAAEH,KAAK,CAACD,KAAK,CAACK,OAAO,CAACD,IAAI;IAAEL,QAAQ,EAAEE,KAAK,CAACF;kBAC1FwB,6BAAC3B,WAAW,oBAAKK,KAAK,EAAI,CACT;AAE7B;;;;"}
@@ -1,19 +0,0 @@
1
- import React__default from 'react';
2
-
3
- const useActiveRowStateListener = (table, rows, activeRowIndex) => {
4
- const meta = table.options.meta;
5
- React__default.useEffect(() => {
6
- if (meta.editMode.isEditing && meta.shouldPauseSortingAndFiltering) {
7
- meta.setShouldPauseSortingAndFiltering(false);
8
- }
9
- }, [activeRowIndex.activeRowIndex]);
10
- // if a filter would exclude the active row, reset it to 0
11
- React__default.useEffect(() => {
12
- if (activeRowIndex.activeRowIndex > rows.length - 1) {
13
- meta.setActiveRowIndex(rows.length ? rows.length - 1 : 0);
14
- }
15
- }, [table.getState().columnFilters, rows.length]);
16
- };
17
-
18
- export { useActiveRowStateListener };
19
- //# sourceMappingURL=useActiveRowStateListener.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useActiveRowStateListener.js","sources":["../../../../../../../../../src/components/Table2/hooks/listeners/useActiveRowStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Row as RTRow, Table as RTTable, TableMeta } from '@tanstack/react-table';\nimport { useActiveRow } from '../useActiveRow';\n\nexport const useActiveRowStateListener = <TType = any>(\n table: RTTable<any>,\n rows: RTRow<any>[],\n activeRowIndex: useActiveRow<TType>\n) => {\n const meta = table.options.meta as TableMeta<any>;\n\n React.useEffect(() => {\n if (meta.editMode.isEditing && meta.shouldPauseSortingAndFiltering) {\n meta.setShouldPauseSortingAndFiltering(false);\n }\n }, [activeRowIndex.activeRowIndex]);\n\n // if a filter would exclude the active row, reset it to 0\n React.useEffect(() => {\n if (activeRowIndex.activeRowIndex > rows.length - 1) {\n meta.setActiveRowIndex(rows.length ? rows.length - 1 : 0);\n }\n }, [table.getState().columnFilters, rows.length]);\n};\n"],"names":["useActiveRowStateListener","table","rows","activeRowIndex","meta","options","React","useEffect","editMode","isEditing","shouldPauseSortingAndFiltering","setShouldPauseSortingAndFiltering","length","setActiveRowIndex","getState","columnFilters"],"mappings":";;MAIaA,yBAAyB,GAAGA,CACrCC,KAAmB,EACnBC,IAAkB,EAClBC,cAAmC;EAEnC,MAAMC,IAAI,GAAGH,KAAK,CAACI,OAAO,CAACD,IAAsB;EAEjDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,QAAQ,CAACC,SAAS,IAAIL,IAAI,CAACM,8BAA8B,EAAE;MAChEN,IAAI,CAACO,iCAAiC,CAAC,KAAK,CAAC;;GAEpD,EAAE,CAACR,cAAc,CAACA,cAAc,CAAC,CAAC;;EAGnCG,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIJ,cAAc,CAACA,cAAc,GAAGD,IAAI,CAACU,MAAM,GAAG,CAAC,EAAE;MACjDR,IAAI,CAACS,iBAAiB,CAACX,IAAI,CAACU,MAAM,GAAGV,IAAI,CAACU,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;;GAEhE,EAAE,CAACX,KAAK,CAACa,QAAQ,EAAE,CAACC,aAAa,EAAEb,IAAI,CAACU,MAAM,CAAC,CAAC;AACrD;;;;"}
@@ -1,28 +0,0 @@
1
- import React__default from 'react';
2
-
3
- // frozen columns have position sticky, and because we support more than one of them
4
- // we must set a 'left' css value. this hook listens to changes on state that will
5
- // affect the left offset (resize, visibility, freezing) and updates offsets based on width
6
- const useColumnOffsetStateListener = (table, setColumnOffsets) => {
7
- const {
8
- columnOrder,
9
- columnSizing,
10
- columnSizingInfo,
11
- columnVisibility
12
- } = table.getState();
13
- const {
14
- frozenColumnsCount
15
- } = table.options.meta;
16
- React__default.useEffect(() => {
17
- const offsets = {};
18
- // store left offsets for each visible column
19
- table.getVisibleLeafColumns().reduce((offset, column) => {
20
- offsets[column.id] = offset;
21
- return offset + column.getSize();
22
- }, 0);
23
- setColumnOffsets(offsets);
24
- }, [columnOrder, columnSizing, columnSizingInfo, columnVisibility, frozenColumnsCount]);
25
- };
26
-
27
- export { useColumnOffsetStateListener };
28
- //# sourceMappingURL=useColumnOffsetStateListener.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useColumnOffsetStateListener.js","sources":["../../../../../../../../../src/components/Table2/hooks/listeners/useColumnOffsetStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTTable, OnChangeFn, TableMeta } from '@tanstack/react-table';\nimport { ColumnOffsetState } from '../../types';\n\n// frozen columns have position sticky, and because we support more than one of them\n// we must set a 'left' css value. this hook listens to changes on state that will\n// affect the left offset (resize, visibility, freezing) and updates offsets based on width\nexport const useColumnOffsetStateListener = (table: RTTable<any>, setColumnOffsets: OnChangeFn<ColumnOffsetState>) => {\n const { columnOrder, columnSizing, columnSizingInfo, columnVisibility } = table.getState();\n const { frozenColumnsCount } = table.options.meta as TableMeta<any>;\n\n React.useEffect(() => {\n const offsets = {};\n\n // store left offsets for each visible column\n table.getVisibleLeafColumns().reduce((offset, column) => {\n offsets[column.id] = offset;\n return offset + column.getSize();\n }, 0);\n\n setColumnOffsets(offsets);\n }, [columnOrder, columnSizing, columnSizingInfo, columnVisibility, frozenColumnsCount]);\n};\n"],"names":["useColumnOffsetStateListener","table","setColumnOffsets","columnOrder","columnSizing","columnSizingInfo","columnVisibility","getState","frozenColumnsCount","options","meta","React","useEffect","offsets","getVisibleLeafColumns","reduce","offset","column","id","getSize"],"mappings":";;AAIA;AACA;AACA;MACaA,4BAA4B,GAAGA,CAACC,KAAmB,EAAEC,gBAA+C;EAC7G,MAAM;IAAEC,WAAW;IAAEC,YAAY;IAAEC,gBAAgB;IAAEC;GAAkB,GAAGL,KAAK,CAACM,QAAQ,EAAE;EAC1F,MAAM;IAAEC;GAAoB,GAAGP,KAAK,CAACQ,OAAO,CAACC,IAAsB;EAEnEC,cAAK,CAACC,SAAS,CAAC;IACZ,MAAMC,OAAO,GAAG,EAAE;;IAGlBZ,KAAK,CAACa,qBAAqB,EAAE,CAACC,MAAM,CAAC,CAACC,MAAM,EAAEC,MAAM;MAChDJ,OAAO,CAACI,MAAM,CAACC,EAAE,CAAC,GAAGF,MAAM;MAC3B,OAAOA,MAAM,GAAGC,MAAM,CAACE,OAAO,EAAE;KACnC,EAAE,CAAC,CAAC;IAELjB,gBAAgB,CAACW,OAAO,CAAC;GAC5B,EAAE,CAACV,WAAW,EAAEC,YAAY,EAAEC,gBAAgB,EAAEC,gBAAgB,EAAEE,kBAAkB,CAAC,CAAC;AAC3F;;;;"}
@@ -1,12 +0,0 @@
1
- import React__default from 'react';
2
-
3
- const useFilterStateListener = (table, onRowSelect) => {
4
- React__default.useEffect(() => {
5
- if (onRowSelect) {
6
- table.resetRowSelection();
7
- }
8
- }, [table.getState().columnFilters, table.getState().globalFilter]);
9
- };
10
-
11
- export { useFilterStateListener };
12
- //# sourceMappingURL=useFilterStateListener.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFilterStateListener.js","sources":["../../../../../../../../../src/components/Table2/hooks/listeners/useFilterStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTTable } from '@tanstack/react-table';\nimport { RowSelectionHandler } from '../../types';\n\nexport const useFilterStateListener = <TType = any>(table: RTTable<TType>, onRowSelect: RowSelectionHandler | undefined) => {\n React.useEffect(() => {\n if (onRowSelect) {\n table.resetRowSelection();\n }\n }, [table.getState().columnFilters, table.getState().globalFilter]);\n};\n"],"names":["useFilterStateListener","table","onRowSelect","React","useEffect","resetRowSelection","getState","columnFilters","globalFilter"],"mappings":";;MAIaA,sBAAsB,GAAGA,CAAcC,KAAqB,EAAEC,WAA4C;EACnHC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIF,WAAW,EAAE;MACbD,KAAK,CAACI,iBAAiB,EAAE;;GAEhC,EAAE,CAACJ,KAAK,CAACK,QAAQ,EAAE,CAACC,aAAa,EAAEN,KAAK,CAACK,QAAQ,EAAE,CAACE,YAAY,CAAC,CAAC;AACvE;;;;"}
@@ -1,18 +0,0 @@
1
- import React__default from 'react';
2
-
3
- const useRowSelectionListener = (table, onRowSelect) => {
4
- React__default.useEffect(() => {
5
- if (onRowSelect) {
6
- if (table.options.enableMultiRowSelection) {
7
- const rows = table.getSelectedRowModel().rows.map(row => row.original);
8
- onRowSelect(rows, table.getIsAllRowsSelected());
9
- } else {
10
- var _table$getSelectedRow, _table$getSelectedRow2;
11
- onRowSelect((_table$getSelectedRow = (_table$getSelectedRow2 = table.getSelectedRowModel().rows[0]) === null || _table$getSelectedRow2 === void 0 ? void 0 : _table$getSelectedRow2.original) !== null && _table$getSelectedRow !== void 0 ? _table$getSelectedRow : undefined, false);
12
- }
13
- }
14
- }, [table.getState().rowSelection]);
15
- };
16
-
17
- export { useRowSelectionListener };
18
- //# sourceMappingURL=useRowSelectionListener.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useRowSelectionListener.js","sources":["../../../../../../../../../src/components/Table2/hooks/listeners/useRowSelectionListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTTable } from '@tanstack/react-table';\nimport { RowSelectionHandler } from '../../types';\n\nexport const useRowSelectionListener = <TType = any>(table: RTTable<any>, onRowSelect: RowSelectionHandler | undefined) => {\n React.useEffect(() => {\n if (onRowSelect) {\n if (table.options.enableMultiRowSelection) {\n const rows = table.getSelectedRowModel().rows.map(row => row.original) as TType[];\n\n onRowSelect(rows, table.getIsAllRowsSelected());\n } else {\n onRowSelect(table.getSelectedRowModel().rows[0]?.original ?? undefined, false);\n }\n }\n }, [table.getState().rowSelection]);\n};\n"],"names":["useRowSelectionListener","table","onRowSelect","React","useEffect","options","enableMultiRowSelection","rows","getSelectedRowModel","map","row","original","getIsAllRowsSelected","_table$getSelectedRow","_table$getSelectedRow2","undefined","getState","rowSelection"],"mappings":";;MAIaA,uBAAuB,GAAGA,CAAcC,KAAmB,EAAEC,WAA4C;EAClHC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIF,WAAW,EAAE;MACb,IAAID,KAAK,CAACI,OAAO,CAACC,uBAAuB,EAAE;QACvC,MAAMC,IAAI,GAAGN,KAAK,CAACO,mBAAmB,EAAE,CAACD,IAAI,CAACE,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAY;QAEjFT,WAAW,CAACK,IAAI,EAAEN,KAAK,CAACW,oBAAoB,EAAE,CAAC;OAClD,MAAM;QAAA,IAAAC,qBAAA,EAAAC,sBAAA;QACHZ,WAAW,EAAAW,qBAAA,IAAAC,sBAAA,GAACb,KAAK,CAACO,mBAAmB,EAAE,CAACD,IAAI,CAAC,CAAC,CAAC,cAAAO,sBAAA,uBAAnCA,sBAAA,CAAqCH,QAAQ,cAAAE,qBAAA,cAAAA,qBAAA,GAAIE,SAAS,EAAE,KAAK,CAAC;;;GAGzF,EAAE,CAACd,KAAK,CAACe,QAAQ,EAAE,CAACC,YAAY,CAAC,CAAC;AACvC;;;;"}
@@ -1,25 +0,0 @@
1
- import React__default from 'react';
2
-
3
- const useSettingsStateListener = (table, onChangeSettings) => {
4
- const meta = table.options.meta;
5
- const state = table.getState();
6
- React__default.useEffect(() => {
7
- let handler;
8
- if (typeof onChangeSettings === 'function') {
9
- handler = setTimeout(() => onChangeSettings({
10
- columnFilters: state.columnFilters,
11
- columnOrder: state.columnOrder,
12
- columnSizing: state.columnSizing,
13
- columnVisibility: state.columnVisibility,
14
- frozenColumnCount: meta.frozenColumnsCount,
15
- globalFilter: state.globalFilter,
16
- rowDensity: meta.rowDensity,
17
- sorting: state.sorting
18
- }), 250);
19
- }
20
- return () => clearTimeout(handler);
21
- }, [state.columnFilters, state.columnOrder, meta.frozenColumnsCount, state.columnSizing, state.columnVisibility, state.globalFilter, meta.rowDensity, state.sorting]);
22
- };
23
-
24
- export { useSettingsStateListener };
25
- //# sourceMappingURL=useSettingsStateListener.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSettingsStateListener.js","sources":["../../../../../../../../../src/components/Table2/hooks/listeners/useSettingsStateListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as RTTable, TableMeta } from '@tanstack/react-table';\nimport { SettingsHandler } from '../../types';\n\nexport const useSettingsStateListener = (table: RTTable<any>, onChangeSettings: SettingsHandler | undefined) => {\n const meta = table.options.meta as TableMeta<any>;\n const state = table.getState();\n\n React.useEffect(() => {\n let handler;\n\n if (typeof onChangeSettings === 'function') {\n handler = setTimeout(\n () =>\n onChangeSettings({\n columnFilters: state.columnFilters,\n columnOrder: state.columnOrder,\n columnSizing: state.columnSizing,\n columnVisibility: state.columnVisibility,\n frozenColumnCount: meta.frozenColumnsCount,\n globalFilter: state.globalFilter,\n rowDensity: meta.rowDensity,\n sorting: state.sorting,\n }),\n 250\n );\n }\n\n return () => clearTimeout(handler);\n }, [\n state.columnFilters,\n state.columnOrder,\n meta.frozenColumnsCount,\n state.columnSizing,\n state.columnVisibility,\n state.globalFilter,\n meta.rowDensity,\n state.sorting,\n ]);\n};\n"],"names":["useSettingsStateListener","table","onChangeSettings","meta","options","state","getState","React","useEffect","handler","setTimeout","columnFilters","columnOrder","columnSizing","columnVisibility","frozenColumnCount","frozenColumnsCount","globalFilter","rowDensity","sorting","clearTimeout"],"mappings":";;MAIaA,wBAAwB,GAAGA,CAACC,KAAmB,EAAEC,gBAA6C;EACvG,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAAsB;EACjD,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,CAChB,MACIR,gBAAgB,CAAC;QACbS,aAAa,EAAEN,KAAK,CAACM,aAAa;QAClCC,WAAW,EAAEP,KAAK,CAACO,WAAW;QAC9BC,YAAY,EAAER,KAAK,CAACQ,YAAY;QAChCC,gBAAgB,EAAET,KAAK,CAACS,gBAAgB;QACxCC,iBAAiB,EAAEZ,IAAI,CAACa,kBAAkB;QAC1CC,YAAY,EAAEZ,KAAK,CAACY,YAAY;QAChCC,UAAU,EAAEf,IAAI,CAACe,UAAU;QAC3BC,OAAO,EAAEd,KAAK,CAACc;OAClB,CAAC,EACN,GAAG,CACN;;IAGL,OAAO,MAAMC,YAAY,CAACX,OAAO,CAAC;GACrC,EAAE,CACCJ,KAAK,CAACM,aAAa,EACnBN,KAAK,CAACO,WAAW,EACjBT,IAAI,CAACa,kBAAkB,EACvBX,KAAK,CAACQ,YAAY,EAClBR,KAAK,CAACS,gBAAgB,EACtBT,KAAK,CAACY,YAAY,EAClBd,IAAI,CAACe,UAAU,EACfb,KAAK,CAACc,OAAO,CAChB,CAAC;AACN;;;;"}
@@ -1,33 +0,0 @@
1
- import React__default from 'react';
2
-
3
- const useActiveRow = (defaultActiveRowIndex = 0) => {
4
- const [activeRowIndex, _setActiveRow] = React__default.useState(defaultActiveRowIndex);
5
- const moveActiveRow = (direction, rows, callback) => {
6
- _setActiveRow(rowIndex => {
7
- const nextRowIndex = getNextIndex(direction, rowIndex, rows.length);
8
- if (callback) {
9
- callback(nextRowIndex);
10
- }
11
- return nextRowIndex;
12
- });
13
- };
14
- // output
15
- const moveToPreviousRow = (rows, callback) => moveActiveRow(-1, rows, callback);
16
- const moveToNextRow = (rows, callback) => moveActiveRow(1, rows, callback);
17
- const setActiveRowIndex = rowIndex => _setActiveRow(rowIndex);
18
- return {
19
- activeRowIndex,
20
- setActiveRowIndex,
21
- moveToPreviousRow,
22
- moveToNextRow
23
- };
24
- };
25
- const getNextIndex = (direction, currentIndex, length) => {
26
- if (direction === -1) {
27
- return currentIndex - 1 > 0 ? currentIndex - 1 : 0;
28
- }
29
- return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;
30
- };
31
-
32
- export { useActiveRow };
33
- //# sourceMappingURL=useActiveRow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useActiveRow.js","sources":["../../../../../../../../src/components/Table2/hooks/useActiveRow.ts"],"sourcesContent":["import React from 'react';\nimport { Row as TRow } from '@tanstack/react-table';\n\n/*\n Note: We have to use row id as the identifier for the row, index isn't good enough\n\n If new rows are added (e.g. by polling of data) and we use index, then the active row\n could change to a different row, this is really bad if the user is editing a row.\n \n Using row id allows us to always stay on the same row. We have to store index though to make\n arrow key navigation performant (otherwise we have to findIndex the entire row array each time).\n*/\n\nexport type ActiveRowHandler = (rowIndex: number) => void;\nexport type ActiveRowMoveHandler<TType = any> = (rows: TRow<TType>[], callback?: (index: number) => void) => void;\n\nexport type useActiveRow<TType = any> = {\n activeRowIndex: number;\n setActiveRowIndex: ActiveRowHandler;\n moveToPreviousRow: ActiveRowMoveHandler<TType>;\n moveToNextRow: ActiveRowMoveHandler<TType>;\n};\n\nexport const useActiveRow = <TType = any>(defaultActiveRowIndex = 0): useActiveRow<TType> => {\n const [activeRowIndex, _setActiveRow] = React.useState<number>(defaultActiveRowIndex);\n\n const moveActiveRow = (direction: -1 | 1, rows: TRow<TType>[], callback?: (index: number) => void) => {\n _setActiveRow(rowIndex => {\n const nextRowIndex = getNextIndex(direction, rowIndex, rows.length);\n if (callback) {\n callback(nextRowIndex);\n }\n return nextRowIndex;\n });\n };\n\n // output\n const moveToPreviousRow = (rows: TRow<TType>[], callback?: (index: number) => void) => moveActiveRow(-1, rows, callback);\n const moveToNextRow = (rows: TRow<TType>[], callback?: (index: number) => void) => moveActiveRow(1, rows, callback);\n const setActiveRowIndex = (rowIndex: number) => _setActiveRow(rowIndex);\n\n return {\n activeRowIndex,\n setActiveRowIndex,\n moveToPreviousRow,\n moveToNextRow,\n };\n};\n\nconst getNextIndex = (direction: -1 | 1, currentIndex: number, length: number) => {\n if (direction === -1) {\n return currentIndex - 1 > 0 ? currentIndex - 1 : 0;\n }\n\n return currentIndex + 1 < length ? currentIndex + 1 : currentIndex;\n};\n"],"names":["useActiveRow","defaultActiveRowIndex","activeRowIndex","_setActiveRow","React","useState","moveActiveRow","direction","rows","callback","rowIndex","nextRowIndex","getNextIndex","length","moveToPreviousRow","moveToNextRow","setActiveRowIndex","currentIndex"],"mappings":";;MAuBaA,YAAY,GAAGA,CAAcC,qBAAqB,GAAG,CAAC;EAC/D,MAAM,CAACC,cAAc,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAASJ,qBAAqB,CAAC;EAErF,MAAMK,aAAa,GAAGA,CAACC,SAAiB,EAAEC,IAAmB,EAAEC,QAAkC;IAC7FN,aAAa,CAACO,QAAQ;MAClB,MAAMC,YAAY,GAAGC,YAAY,CAACL,SAAS,EAAEG,QAAQ,EAAEF,IAAI,CAACK,MAAM,CAAC;MACnE,IAAIJ,QAAQ,EAAE;QACVA,QAAQ,CAACE,YAAY,CAAC;;MAE1B,OAAOA,YAAY;KACtB,CAAC;GACL;;EAGD,MAAMG,iBAAiB,GAAGA,CAACN,IAAmB,EAAEC,QAAkC,KAAKH,aAAa,CAAC,CAAC,CAAC,EAAEE,IAAI,EAAEC,QAAQ,CAAC;EACxH,MAAMM,aAAa,GAAGA,CAACP,IAAmB,EAAEC,QAAkC,KAAKH,aAAa,CAAC,CAAC,EAAEE,IAAI,EAAEC,QAAQ,CAAC;EACnH,MAAMO,iBAAiB,GAAIN,QAAgB,IAAKP,aAAa,CAACO,QAAQ,CAAC;EAEvE,OAAO;IACHR,cAAc;IACdc,iBAAiB;IACjBF,iBAAiB;IACjBC;GACH;AACL;AAEA,MAAMH,YAAY,GAAGA,CAACL,SAAiB,EAAEU,YAAoB,EAAEJ,MAAc;EACzE,IAAIN,SAAS,KAAK,CAAC,CAAC,EAAE;IAClB,OAAOU,YAAY,GAAG,CAAC,GAAG,CAAC,GAAGA,YAAY,GAAG,CAAC,GAAG,CAAC;;EAGtD,OAAOA,YAAY,GAAG,CAAC,GAAGJ,MAAM,GAAGI,YAAY,GAAG,CAAC,GAAGA,YAAY;AACtE,CAAC;;;;"}
@@ -1,122 +0,0 @@
1
- import React__default from 'react';
2
- import { useLocalization } from '../../Provider/Localization.js';
3
- import { createColumnHelper } from '@tanstack/react-table';
4
- import { createRowExpansionColumn, createRowSelectionColumn, createRowDraggableColumn, createRowActionsColumn, MIN_COLUMN_SIZE } from '../utilities/columns.js';
5
-
6
- function useColumnDefinitions(children, options, tableRef) {
7
- const {
8
- texts
9
- } = useLocalization();
10
- const lastSelectedRowIndex = React__default.useRef();
11
- const columnHelper = createColumnHelper();
12
- return React__default.useMemo(() => {
13
- var _options$actionsForRo;
14
- let internalFrozenColumnCount = 0;
15
- // cannot be typed correctly until https://github.com/TanStack/table/discussions/4530 is resolved
16
- const columns = [];
17
- const defaultColumnSizing = {};
18
- const defaultColumnVisibility = {};
19
- const defaultSorting = [];
20
- const footers = {};
21
- React__default.Children.toArray(children).filter(child => !!child).forEach(child => {
22
- if ( /*#__PURE__*/React__default.isValidElement(child)) {
23
- var _child$props$minWidth;
24
- const defaultWidth = child.props.defaultWidth === 'grow' ? '1fr' : child.props.defaultWidth;
25
- if (defaultWidth) {
26
- defaultColumnSizing[child.props.accessor] = defaultWidth;
27
- }
28
- if (child.props.defaultHidden && options.enableColumnHiding) {
29
- defaultColumnVisibility[child.props.accessor] = false;
30
- }
31
- if (child.props.sort !== undefined) {
32
- defaultSorting.push({
33
- id: child.props.accessor,
34
- desc: child.props.sort === 'desc'
35
- });
36
- }
37
- if (child.props.footer) {
38
- footers[child.props.accessor] = child.props.footer;
39
- }
40
- columns.push({
41
- accessorKey: child.props.accessor,
42
- id: child.props.accessor,
43
- cell: props => {
44
- var _value;
45
- let value = props.getValue();
46
- if (typeof child.props.renderer === 'function') {
47
- value = child.props.renderer(value, props.row.original);
48
- }
49
- if (typeof value === 'string' || typeof value === 'number') {
50
- return /*#__PURE__*/React__default.createElement("span", {
51
- className: "truncate"
52
- }, value);
53
- }
54
- return (_value = value) !== null && _value !== void 0 ? _value : null;
55
- },
56
- header: child.props.header,
57
- meta: {
58
- align: child.props.align,
59
- className: child.props.className,
60
- control: child.props.control,
61
- dataType: child.props.dataType,
62
- defaultWidth,
63
- disableReordering: child.props.disableReordering,
64
- menu: child.props.menu,
65
- tooltip: child.props.tooltip
66
- },
67
- enableHiding: !child.props.disableHiding,
68
- // filtering
69
- enableColumnFilter: !child.props.disableFiltering,
70
- filterFn: options.enableColumnFiltering && !child.props.disableFiltering ? 'tacoFilter' : undefined,
71
- // sizing
72
- enableResizing: !child.props.disableResizing,
73
- minSize: (_child$props$minWidth = child.props.minWidth) !== null && _child$props$minWidth !== void 0 ? _child$props$minWidth : MIN_COLUMN_SIZE,
74
- size: child.props.defaultWidth,
75
- // sorting
76
- enableSorting: !child.props.disableSorting,
77
- sortingFn: getSortingFn(child.props.dataType, child.props.sortFn),
78
- sortDescFirst: false,
79
- sortUndefined: 1
80
- });
81
- }
82
- });
83
- if (options.enableRowExpansion && options.expandedRowRenderer) {
84
- columns.unshift(columnHelper.display(createRowExpansionColumn(options.expandedRowRenderer, texts)));
85
- internalFrozenColumnCount++;
86
- }
87
- if (options.enableRowSelection) {
88
- columns.unshift(columnHelper.display(createRowSelectionColumn(options.enableMultipleRowSelection, lastSelectedRowIndex, options.onRowDrag, tableRef, texts)));
89
- internalFrozenColumnCount++;
90
- }
91
- if (options.onRowDrag) {
92
- columns.unshift(columnHelper.display(createRowDraggableColumn(options.onRowDrag, texts)));
93
- internalFrozenColumnCount++;
94
- }
95
- if ((_options$actionsForRo = options.actionsForRow) !== null && _options$actionsForRo !== void 0 && _options$actionsForRo.length) {
96
- columns.push(columnHelper.display(createRowActionsColumn(options.actionsForRow, options.actionsForRowLength, texts)));
97
- }
98
- return {
99
- columns,
100
- internalFrozenColumnCount,
101
- defaultColumnSizing,
102
- defaultColumnVisibility,
103
- defaultSorting,
104
- footers
105
- };
106
- }, [children]);
107
- }
108
- function getSortingFn(dataType, customFn) {
109
- if (typeof customFn === 'function') {
110
- return (rowA, rowB, columnId) => customFn(rowA.original, rowB.original, columnId);
111
- }
112
- if (customFn) {
113
- return customFn;
114
- }
115
- if (dataType && dataType !== 'boolean') {
116
- return dataType;
117
- }
118
- return 'auto';
119
- }
120
-
121
- export { useColumnDefinitions };
122
- //# sourceMappingURL=useColumnDefinitions.js.map