@synerise/ds-table 1.9.10 → 1.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +9 -10
  3. package/dist/Cell/Action/ActionCell.d.ts +2 -2
  4. package/dist/Cell/Action/ActionCell.js +15 -18
  5. package/dist/Cell/Action/ActionCell.styles.d.ts +2 -2
  6. package/dist/Cell/Action/ActionCell.styles.js +10 -11
  7. package/dist/Cell/Action/ActionCell.types.d.ts +2 -2
  8. package/dist/Cell/Action/ActionCell.types.js +1 -1
  9. package/dist/Cell/AvatarLabel/AvatarLabel.d.ts +2 -2
  10. package/dist/Cell/AvatarLabel/AvatarLabel.js +32 -43
  11. package/dist/Cell/AvatarLabel/AvatarLabel.styles.d.ts +13 -13
  12. package/dist/Cell/AvatarLabel/AvatarLabel.styles.js +27 -28
  13. package/dist/Cell/AvatarLabel/AvatarLabel.types.d.ts +2 -2
  14. package/dist/Cell/AvatarLabel/AvatarLabel.types.js +1 -1
  15. package/dist/Cell/Copyable/Copyable.styles.d.ts +2 -2
  16. package/dist/Cell/Copyable/Copyable.styles.js +9 -15
  17. package/dist/Cell/Copyable/Copyable.types.d.ts +1 -1
  18. package/dist/Cell/Copyable/Copyable.types.js +1 -1
  19. package/dist/Cell/Copyable/CopyableCell.d.ts +2 -2
  20. package/dist/Cell/Copyable/CopyableCell.js +23 -27
  21. package/dist/Cell/Editable/EditableCell.d.ts +2 -2
  22. package/dist/Cell/Editable/EditableCell.js +26 -39
  23. package/dist/Cell/Editable/EditableCell.styles.d.ts +2 -2
  24. package/dist/Cell/Editable/EditableCell.styles.js +9 -7
  25. package/dist/Cell/Editable/EditableCell.types.d.ts +1 -1
  26. package/dist/Cell/Editable/EditableCell.types.js +1 -1
  27. package/dist/Cell/FlagLabel/FlagLabelCell.d.ts +2 -2
  28. package/dist/Cell/FlagLabel/FlagLabelCell.js +15 -14
  29. package/dist/Cell/FlagLabel/FlagLabelCell.styles.d.ts +1 -1
  30. package/dist/Cell/FlagLabel/FlagLabelCell.styles.js +6 -3
  31. package/dist/Cell/FlagLabel/FlagLabelCell.types.d.ts +2 -2
  32. package/dist/Cell/FlagLabel/FlagLabelCell.types.js +1 -1
  33. package/dist/Cell/IconLabel/IconLabel.d.ts +2 -2
  34. package/dist/Cell/IconLabel/IconLabel.js +14 -15
  35. package/dist/Cell/IconLabel/IconLabel.styles.d.ts +1 -1
  36. package/dist/Cell/IconLabel/IconLabel.styles.js +7 -6
  37. package/dist/Cell/IconLabel/IconLabel.types.d.ts +3 -3
  38. package/dist/Cell/IconLabel/IconLabel.types.js +1 -1
  39. package/dist/Cell/IconTooltipCell/IconTooltipCell.d.ts +2 -2
  40. package/dist/Cell/IconTooltipCell/IconTooltipCell.js +18 -23
  41. package/dist/Cell/IconTooltipCell/IconTooltipCell.styles.d.ts +2 -2
  42. package/dist/Cell/IconTooltipCell/IconTooltipCell.styles.js +9 -11
  43. package/dist/Cell/IconTooltipCell/IconTooltipCell.types.d.ts +4 -4
  44. package/dist/Cell/IconTooltipCell/IconTooltipCell.types.js +1 -1
  45. package/dist/Cell/InputNumber/InputNumberCell.d.ts +2 -2
  46. package/dist/Cell/InputNumber/InputNumberCell.js +10 -17
  47. package/dist/Cell/InputNumber/InputNumberCell.styles.d.ts +1 -1
  48. package/dist/Cell/InputNumber/InputNumberCell.styles.js +9 -5
  49. package/dist/Cell/InputNumber/InputNumberCell.types.d.ts +2 -2
  50. package/dist/Cell/InputNumber/InputNumberCell.types.js +1 -1
  51. package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.d.ts +3 -3
  52. package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.js +29 -40
  53. package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.styles.d.ts +3 -3
  54. package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.styles.js +11 -8
  55. package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.types.d.ts +2 -2
  56. package/dist/Cell/LabelsWithShowMore/LabelsWithShowMore.types.js +1 -1
  57. package/dist/Cell/LabelsWithShowMore/Modal/Modal.d.ts +2 -2
  58. package/dist/Cell/LabelsWithShowMore/Modal/Modal.js +35 -64
  59. package/dist/Cell/LabelsWithShowMore/Modal/Modal.types.d.ts +3 -3
  60. package/dist/Cell/LabelsWithShowMore/Modal/Modal.types.js +1 -1
  61. package/dist/Cell/Star/StarCell.d.ts +45 -45
  62. package/dist/Cell/Star/StarCell.js +25 -31
  63. package/dist/Cell/Star/StarCell.styles.d.ts +2 -2
  64. package/dist/Cell/Star/StarCell.styles.js +11 -9
  65. package/dist/Cell/Star/StarCell.types.d.ts +2 -2
  66. package/dist/Cell/Star/StarCell.types.js +1 -1
  67. package/dist/Cell/StatusLabel/StatusLabel.d.ts +2 -2
  68. package/dist/Cell/StatusLabel/StatusLabel.js +17 -19
  69. package/dist/Cell/StatusLabel/StatusLabel.styles.d.ts +2 -2
  70. package/dist/Cell/StatusLabel/StatusLabel.styles.js +9 -9
  71. package/dist/Cell/StatusLabel/StatusLabel.types.d.ts +3 -3
  72. package/dist/Cell/StatusLabel/StatusLabel.types.js +1 -1
  73. package/dist/Cell/TagIcon/TagIcon.d.ts +2 -2
  74. package/dist/Cell/TagIcon/TagIcon.js +9 -13
  75. package/dist/Cell/TagIcon/TagIcon.styles.d.ts +1 -1
  76. package/dist/Cell/TagIcon/TagIcon.styles.js +7 -6
  77. package/dist/Cell/TagIcon/TagIcon.types.d.ts +2 -2
  78. package/dist/Cell/TagIcon/TagIcon.types.js +1 -1
  79. package/dist/Cell/TagsGroup/TagsGroup.d.ts +2 -2
  80. package/dist/Cell/TagsGroup/TagsGroup.js +22 -39
  81. package/dist/Cell/TagsGroup/TagsGroup.styles.d.ts +2 -2
  82. package/dist/Cell/TagsGroup/TagsGroup.styles.js +30 -9
  83. package/dist/Cell/TagsGroup/TagsGroup.types.d.ts +2 -2
  84. package/dist/Cell/TagsGroup/TagsGroup.types.js +1 -1
  85. package/dist/Cell/index.d.ts +12 -12
  86. package/dist/Cell/index.js +28 -14
  87. package/dist/ColumnSortMenu/SortIcons.d.ts +2 -2
  88. package/dist/ColumnSortMenu/SortIcons.js +26 -38
  89. package/dist/ColumnSortMenu/SortRender.styles.d.ts +34 -34
  90. package/dist/ColumnSortMenu/SortRender.styles.js +13 -10
  91. package/dist/ColumnSortMenu/SortRenderer.d.ts +2 -2
  92. package/dist/ColumnSortMenu/SortRenderer.js +74 -108
  93. package/dist/ColumnSortMenu/TitleWithSort.d.ts +2 -2
  94. package/dist/ColumnSortMenu/TitleWithSort.js +19 -16
  95. package/dist/ColumnSortMenu/columnWithSortButtons.d.ts +1 -2
  96. package/dist/ColumnSortMenu/columnWithSortButtons.js +26 -43
  97. package/dist/ColumnSortMenu/groupedColumnsSort.d.ts +3 -3
  98. package/dist/ColumnSortMenu/groupedColumnsSort.js +33 -28
  99. package/dist/ColumnSortMenu/replaceSortButtons.d.ts +1 -1
  100. package/dist/ColumnSortMenu/replaceSortButtons.js +14 -15
  101. package/dist/ColumnSortMenu/useSortState.d.ts +1 -1
  102. package/dist/ColumnSortMenu/useSortState.js +95 -93
  103. package/dist/DefaultTable/DefaultTable.d.ts +2 -2
  104. package/dist/DefaultTable/DefaultTable.js +147 -148
  105. package/dist/FilterTrigger/FilterTrigger.d.ts +2 -2
  106. package/dist/FilterTrigger/FilterTrigger.js +42 -67
  107. package/dist/FilterTrigger/FilterTrigger.styles.d.ts +53 -53
  108. package/dist/FilterTrigger/FilterTrigger.styles.js +19 -32
  109. package/dist/FilterTrigger/FilterTrigger.types.d.ts +1 -1
  110. package/dist/FilterTrigger/FilterTrigger.types.js +1 -1
  111. package/dist/GroupTable/GroupTable.d.ts +3 -4
  112. package/dist/GroupTable/GroupTable.js +97 -118
  113. package/dist/GroupTable/GroupTable.styles.d.ts +25 -25
  114. package/dist/GroupTable/GroupTable.styles.js +40 -37
  115. package/dist/GroupTable/GroupTable.types.d.ts +1 -1
  116. package/dist/GroupTable/GroupTable.types.js +9 -6
  117. package/dist/GroupTable/GroupTableBody/GroupTableBody.d.ts +1 -1
  118. package/dist/GroupTable/GroupTableBody/GroupTableBody.js +83 -107
  119. package/dist/GroupTable/GroupTableBody/GroupTableBody.types.d.ts +3 -3
  120. package/dist/GroupTable/GroupTableBody/GroupTableBody.types.js +1 -1
  121. package/dist/GroupTable/GroupTableHeader/GroupTableHeader.d.ts +1 -1
  122. package/dist/GroupTable/GroupTableHeader/GroupTableHeader.js +25 -28
  123. package/dist/GroupTable/GroupTableHeader/GroupTableHeader.types.js +1 -1
  124. package/dist/InfiniteScroll/BackToTopButton.d.ts +2 -2
  125. package/dist/InfiniteScroll/BackToTopButton.js +7 -15
  126. package/dist/InfiniteScroll/BackToTopButton.styles.d.ts +34 -34
  127. package/dist/InfiniteScroll/BackToTopButton.styles.js +11 -9
  128. package/dist/InfiniteScroll/ErrorItem.d.ts +1 -1
  129. package/dist/InfiniteScroll/ErrorItem.js +19 -23
  130. package/dist/InfiniteScroll/ErrorItem.styles.d.ts +1 -1
  131. package/dist/InfiniteScroll/ErrorItem.styles.js +6 -3
  132. package/dist/InfiniteScroll/InfiniteLoaderItem.d.ts +2 -2
  133. package/dist/InfiniteScroll/InfiniteLoaderItem.js +33 -28
  134. package/dist/InfiniteScroll/InfiniteLoaderItem.styles.d.ts +1 -1
  135. package/dist/InfiniteScroll/InfiniteLoaderItem.styles.js +7 -4
  136. package/dist/InfiniteScroll/InfiniteLoaderItem.types.d.ts +1 -1
  137. package/dist/InfiniteScroll/InfiniteLoaderItem.types.js +1 -1
  138. package/dist/InfiniteScroll/LoadingItem.d.ts +1 -1
  139. package/dist/InfiniteScroll/LoadingItem.js +10 -10
  140. package/dist/InfiniteScroll/NoMoreItem.d.ts +1 -1
  141. package/dist/InfiniteScroll/NoMoreItem.js +10 -10
  142. package/dist/InfiniteScroll/OuterListElement.d.ts +1 -1
  143. package/dist/InfiniteScroll/OuterListElement.js +45 -58
  144. package/dist/InfiniteScroll/constants.js +4 -1
  145. package/dist/InfiniteScroll/utils.d.ts +1 -1
  146. package/dist/InfiniteScroll/utils.js +15 -12
  147. package/dist/ItemsMenu/ItemsMenu.d.ts +2 -2
  148. package/dist/ItemsMenu/ItemsMenu.js +7 -6
  149. package/dist/ItemsMenu/ItemsMenu.styles.d.ts +1 -1
  150. package/dist/ItemsMenu/ItemsMenu.styles.js +6 -3
  151. package/dist/ItemsMenu/ItemsMenu.types.d.ts +1 -1
  152. package/dist/ItemsMenu/ItemsMenu.types.js +1 -1
  153. package/dist/RowSelection/RowSelectionColumn.d.ts +3 -3
  154. package/dist/RowSelection/RowSelectionColumn.js +77 -81
  155. package/dist/RowSelection/RowSelectionColumn.types.d.ts +3 -3
  156. package/dist/RowSelection/RowSelectionColumn.types.js +1 -1
  157. package/dist/RowSelection/index.js +4 -1
  158. package/dist/Table.d.ts +2 -4
  159. package/dist/Table.js +94 -129
  160. package/dist/Table.styles.d.ts +23 -23
  161. package/dist/Table.styles.js +86 -110
  162. package/dist/Table.types.d.ts +7 -7
  163. package/dist/Table.types.js +1 -1
  164. package/dist/TableHeader/TableHeader.d.ts +2 -2
  165. package/dist/TableHeader/TableHeader.js +91 -129
  166. package/dist/TableHeader/TableHeader.types.d.ts +2 -2
  167. package/dist/TableHeader/TableHeader.types.js +1 -1
  168. package/dist/TableHeader/TableLimit/TableLimit.d.ts +2 -2
  169. package/dist/TableHeader/TableLimit/TableLimit.js +44 -36
  170. package/dist/TableHeader/TableLimit/TableLimit.styles.d.ts +4 -4
  171. package/dist/TableHeader/TableLimit/TableLimit.styles.js +15 -13
  172. package/dist/TableHeader/TableLimit/TableLimit.types.d.ts +3 -3
  173. package/dist/TableHeader/TableLimit/TableLimit.types.js +1 -1
  174. package/dist/TableHeader/TableLimit/index.js +4 -2
  175. package/dist/TableHeader/TableSelection.d.ts +2 -2
  176. package/dist/TableHeader/TableSelection.js +163 -180
  177. package/dist/TableHeader/TableSelection.types.d.ts +1 -1
  178. package/dist/TableHeader/TableSelection.types.js +1 -1
  179. package/dist/TreeTable/TreeTable.d.ts +2 -3
  180. package/dist/TreeTable/TreeTable.js +51 -78
  181. package/dist/TreeTable/TreeTable.styles.d.ts +5 -5
  182. package/dist/TreeTable/TreeTable.styles.js +21 -20
  183. package/dist/VirtualTable/VirtualTable.d.ts +3 -3
  184. package/dist/VirtualTable/VirtualTable.js +342 -411
  185. package/dist/VirtualTable/VirtualTable.styles.d.ts +8 -8
  186. package/dist/VirtualTable/VirtualTable.styles.js +30 -40
  187. package/dist/VirtualTable/VirtualTable.types.d.ts +4 -4
  188. package/dist/VirtualTable/VirtualTable.types.js +1 -1
  189. package/dist/VirtualTable/VirtualTableRow.d.ts +4 -4
  190. package/dist/VirtualTable/VirtualTableRow.js +103 -111
  191. package/dist/VirtualTable/constants.js +8 -3
  192. package/dist/assets/style/index-tn0RQdqM.css +0 -0
  193. package/dist/constants/Table.constants.js +11 -6
  194. package/dist/constants/TableSkeleton.constants.d.ts +1 -1
  195. package/dist/constants/TableSkeleton.constants.js +48 -100
  196. package/dist/hooks/useBulkSelection/index.js +4 -1
  197. package/dist/hooks/useBulkSelection/useBulkSelection.d.ts +1 -1
  198. package/dist/hooks/useBulkSelection/useBulkSelection.js +55 -40
  199. package/dist/hooks/useRowKey/index.js +4 -1
  200. package/dist/hooks/useRowKey/useRowKey.js +11 -11
  201. package/dist/hooks/useRowStar/index.js +4 -2
  202. package/dist/hooks/useRowStar/useRowStar.d.ts +1 -1
  203. package/dist/hooks/useRowStar/useRowStar.js +54 -62
  204. package/dist/hooks/useRowStar/useRowStar.types.d.ts +2 -2
  205. package/dist/hooks/useRowStar/useRowStar.types.js +1 -1
  206. package/dist/index.d.ts +4 -4
  207. package/dist/index.js +18 -9
  208. package/dist/modules.d.js +1 -1
  209. package/dist/modules.d.ts +0 -0
  210. package/dist/utils/calculateColumnWidths.d.ts +1 -1
  211. package/dist/utils/calculateColumnWidths.js +17 -16
  212. package/dist/utils/calculatePixels.js +11 -12
  213. package/dist/utils/columnWithCellTooltip.d.ts +1 -1
  214. package/dist/utils/columnWithCellTooltip.js +18 -15
  215. package/dist/utils/getChildrenColumnName.js +6 -3
  216. package/dist/utils/getRecordSelectionStatus.d.ts +1 -1
  217. package/dist/utils/getRecordSelectionStatus.js +11 -7
  218. package/dist/utils/getSkeletonProps.d.ts +1 -1
  219. package/dist/utils/getSkeletonProps.js +26 -36
  220. package/dist/utils/getValueFromPath.js +9 -6
  221. package/dist/utils/index.js +23 -9
  222. package/dist/utils/isGrouped.d.ts +1 -1
  223. package/dist/utils/isGrouped.js +6 -3
  224. package/dist/utils/isRecordSelectable.d.ts +1 -1
  225. package/dist/utils/isRecordSelectable.js +10 -6
  226. package/dist/utils/locale.d.ts +3 -3
  227. package/dist/utils/locale.js +115 -111
  228. package/package.json +31 -31
  229. package/dist/Cell/TagsGroup/TagsGroup.spec.d.ts +0 -1
  230. package/dist/ColumnSortMenu/__spec__/groupedColumnsSort.spec.d.ts +0 -1
  231. package/dist/VirtualTable/VirtualTable.spec.d.ts +0 -1
  232. package/dist/utils/__specs__/getValueFromPath.spec.d.ts +0 -1
@@ -1,193 +1,179 @@
1
- var _excluded = ["style"];
2
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
3
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
4
- import classnames from 'classnames';
5
- import compact from 'lodash.compact';
6
- import ResizeObserver from 'rc-resize-observer';
7
- import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
8
- import { useIntl } from 'react-intl';
9
- import { FixedSizeList as List } from 'react-window';
10
- import Scrollbar from '@synerise/ds-scrollbar';
11
- import { useElementInView } from '@synerise/ds-utils';
12
- import BackToTopButton from '../InfiniteScroll/BackToTopButton';
13
- import OuterListElement from '../InfiniteScroll/OuterListElement';
14
- import { infiniteLoaderItemHeight } from '../InfiniteScroll/constants';
15
- import { RowSelectionColumn } from '../RowSelection';
16
- import DSTable from '../Table';
17
- import { useRowKey } from '../hooks/useRowKey';
18
- import { useRowStar } from '../hooks/useRowStar';
19
- import { calculateColumnWidths, useTableLocale } from '../utils';
20
- import { getChildrenColumnName } from '../utils/getChildrenColumnName';
21
- import * as S from './VirtualTable.styles';
22
- import VirtualTableRow, { INFINITE_LOADED_ITEM_HEIGHT } from './VirtualTableRow';
23
- import { EXPANDED_ROW_PROPERTY, HEADER_ROW_HEIGHT, LOAD_DATA_OFFSET } from './constants';
24
- var relativeInlineStyle = {
25
- position: 'relative'
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import classNames from "classnames";
3
+ import compact from "lodash.compact";
4
+ import ResizeObserver from "rc-resize-observer";
5
+ import React, { forwardRef, useRef, useState, useCallback, useEffect, useImperativeHandle, useMemo } from "react";
6
+ import { useIntl } from "react-intl";
7
+ import { FixedSizeList } from "react-window";
8
+ import Scrollbar from "@synerise/ds-scrollbar";
9
+ import { useElementInView } from "@synerise/ds-utils";
10
+ import { BackToTopButton } from "../InfiniteScroll/BackToTopButton.js";
11
+ import OuterListElement from "../InfiniteScroll/OuterListElement.js";
12
+ import { infiniteLoaderItemHeight } from "../InfiniteScroll/constants.js";
13
+ import { RowSelectionColumn } from "../RowSelection/RowSelectionColumn.js";
14
+ import DSTable from "../Table.js";
15
+ import { useRowKey } from "../hooks/useRowKey/useRowKey.js";
16
+ import { useRowStar } from "../hooks/useRowStar/useRowStar.js";
17
+ import { calculateColumnWidths } from "../utils/calculateColumnWidths.js";
18
+ import "unit-to-px";
19
+ import { getChildrenColumnName } from "../utils/getChildrenColumnName.js";
20
+ import "../Table.styles.js";
21
+ import "@synerise/ds-skeleton";
22
+ import "uuid";
23
+ import "styled-components";
24
+ import "@synerise/ds-typography";
25
+ import "ramda";
26
+ import { useTableLocale } from "../utils/locale.js";
27
+ import { InnerListElement, VirtualTableWrapper, StickyScrollbarWrapper, StickyScrollbarContent, VirtualListWrapper } from "./VirtualTable.styles.js";
28
+ import VirtualTableRow, { INFINITE_LOADED_ITEM_HEIGHT } from "./VirtualTableRow.js";
29
+ import { EXPANDED_ROW_PROPERTY, HEADER_ROW_HEIGHT, LOAD_DATA_OFFSET } from "./constants.js";
30
+ const relativeInlineStyle = {
31
+ position: "relative"
26
32
  };
27
- var VirtualTable = function VirtualTable(props, forwardedRef) {
28
- var _infiniteScroll$prevP2, _infiniteScroll$prevP4;
29
- var _props$columns = props.columns,
30
- columns = _props$columns === void 0 ? [] : _props$columns,
31
- scroll = props.scroll,
32
- className = props.className,
33
- _props$cellHeight = props.cellHeight,
34
- cellHeight = _props$cellHeight === void 0 ? 52 : _props$cellHeight,
35
- infiniteScroll = props.infiniteScroll,
36
- selection = props.selection,
37
- onRowClick = props.onRowClick,
38
- rowKey = props.rowKey,
39
- rowStar = props.rowStar,
40
- _props$initialWidth = props.initialWidth,
41
- initialWidth = _props$initialWidth === void 0 ? 0 : _props$initialWidth,
42
- _props$dataSource = props.dataSource,
43
- dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
44
- dataSourceFull = props.dataSourceFull,
45
- expandable = props.expandable,
46
- locale = props.locale,
47
- loading = props.loading,
48
- sticky = props.sticky,
49
- getRowTooltipProps = props.getRowTooltipProps,
50
- onListRefChange = props.onListRefChange,
51
- onItemsRendered = props.onItemsRendered,
52
- onScrollToRecordIndex = props.onScrollToRecordIndex;
53
- var intl = useIntl();
54
- var tableLocale = useTableLocale(intl, locale);
55
- var listRef = useRef(null);
56
- var listScrollTopRef = useRef(0);
57
- var outerListRef = useRef(null);
58
- var containerRef = useRef(null);
59
- var horizontalScrollRef = useRef(null);
60
- var customBodyOnScrollRef = useRef();
61
- var _useState = useState(false),
62
- isHeaderVisible = _useState[0],
63
- setIsHeaderVisible = _useState[1];
64
- var _useState2 = useState(null),
65
- firstItem = _useState2[0],
66
- setFirstItem = _useState2[1];
67
- var childrenColumnName = getChildrenColumnName(expandable == null ? void 0 : expandable.childrenColumnName);
68
- var hasInfiniteScroll = Boolean(infiniteScroll);
69
- var isSticky = Boolean(sticky);
70
- var stickyScrollThreshold = sticky && sticky.scrollThreshold;
71
- var dataSourceEmpty = dataSource.length === 0;
72
- var updateFirstItem = useCallback(function (findFirstItem) {
73
- var prevFirstItemIndex = dataSource.findIndex(findFirstItem);
33
+ const VirtualTable = (props, forwardedRef) => {
34
+ const {
35
+ columns = [],
36
+ scroll,
37
+ className,
38
+ cellHeight = 52,
39
+ infiniteScroll,
40
+ selection,
41
+ onRowClick,
42
+ rowKey,
43
+ rowStar,
44
+ initialWidth = 0,
45
+ dataSource = [],
46
+ dataSourceFull,
47
+ expandable,
48
+ locale,
49
+ loading,
50
+ sticky,
51
+ getRowTooltipProps,
52
+ onListRefChange,
53
+ onItemsRendered,
54
+ onScrollToRecordIndex
55
+ } = props;
56
+ const intl = useIntl();
57
+ const tableLocale = useTableLocale(intl, locale);
58
+ const listRef = useRef(null);
59
+ const listScrollTopRef = useRef(0);
60
+ const outerListRef = useRef(null);
61
+ const containerRef = useRef(null);
62
+ const horizontalScrollRef = useRef(null);
63
+ const customBodyOnScrollRef = useRef();
64
+ const [isHeaderVisible, setIsHeaderVisible] = useState(false);
65
+ const [firstItem, setFirstItem] = useState(null);
66
+ const childrenColumnName = getChildrenColumnName(expandable?.childrenColumnName);
67
+ const hasInfiniteScroll = Boolean(infiniteScroll);
68
+ const isSticky = Boolean(sticky);
69
+ const stickyScrollThreshold = sticky && sticky.scrollThreshold;
70
+ const dataSourceEmpty = dataSource.length === 0;
71
+ const updateFirstItem = useCallback((findFirstItem) => {
72
+ const prevFirstItemIndex = dataSource.findIndex(findFirstItem);
74
73
  setFirstItem(dataSource[0]);
75
- if (prevFirstItemIndex >= 0 && listRef != null && listRef.current) {
74
+ if (prevFirstItemIndex >= 0 && listRef?.current) {
76
75
  if (onScrollToRecordIndex) {
77
- onScrollToRecordIndex(prevFirstItemIndex, function () {
78
- (listRef == null ? void 0 : listRef.current) && listRef.current.scrollToItem(prevFirstItemIndex, 'start');
76
+ onScrollToRecordIndex(prevFirstItemIndex, () => {
77
+ listRef?.current && listRef.current.scrollToItem(prevFirstItemIndex, "start");
79
78
  });
80
79
  } else {
81
- listRef.current.scrollToItem(prevFirstItemIndex, 'start');
80
+ listRef.current.scrollToItem(prevFirstItemIndex, "start");
82
81
  }
83
82
  }
84
83
  }, [dataSource, setFirstItem, onScrollToRecordIndex]);
85
- useEffect(function () {
84
+ useEffect(() => {
86
85
  if (dataSourceEmpty) {
87
86
  setIsHeaderVisible(false);
88
87
  }
89
88
  }, [dataSourceEmpty]);
90
- useEffect(function () {
89
+ useEffect(() => {
91
90
  try {
92
- if (!(infiniteScroll != null && infiniteScroll.prevPage) || dataSourceEmpty) {
91
+ if (!infiniteScroll?.prevPage || dataSourceEmpty) {
93
92
  return;
94
93
  }
95
94
  if (firstItem === null) {
96
95
  setFirstItem(dataSource[0]);
97
96
  return;
98
97
  }
99
- if (rowKey === undefined) {
100
- var firstItemStringified = JSON.stringify(firstItem);
98
+ if (rowKey === void 0) {
99
+ const firstItemStringified = JSON.stringify(firstItem);
101
100
  if (JSON.stringify(dataSource[0]) !== firstItemStringified) {
102
- updateFirstItem(function (item) {
103
- return JSON.stringify(item) === firstItemStringified;
104
- });
101
+ updateFirstItem((item) => JSON.stringify(item) === firstItemStringified);
105
102
  }
106
103
  return;
107
104
  }
108
- if (typeof rowKey === 'string') {
105
+ if (typeof rowKey === "string") {
109
106
  if (dataSource[0][rowKey] !== firstItem[rowKey]) {
110
- updateFirstItem(function (item) {
111
- return item[rowKey] === firstItem[rowKey];
112
- });
107
+ updateFirstItem((item) => item[rowKey] === firstItem[rowKey]);
113
108
  }
114
109
  return;
115
110
  }
116
- if (typeof rowKey === 'function') {
111
+ if (typeof rowKey === "function") {
117
112
  if (rowKey(dataSource[0]) !== rowKey(firstItem)) {
118
- updateFirstItem(function (item) {
119
- return rowKey(item) === rowKey(firstItem);
120
- });
113
+ updateFirstItem((item) => rowKey(item) === rowKey(firstItem));
121
114
  }
122
115
  }
123
116
  } catch (_error) {
124
- throw new Error('Cannot find firs item');
117
+ throw new Error("Cannot find firs item");
125
118
  }
126
119
  }, [dataSource, dataSourceEmpty, rowKey, firstItem, infiniteScroll, updateFirstItem]);
127
- useEffect(function () {
128
- var _infiniteScroll$prevP;
129
- if (listRef.current && infiniteScroll != null && (_infiniteScroll$prevP = infiniteScroll.prevPage) != null && _infiniteScroll$prevP.hasMore) {
120
+ useEffect(() => {
121
+ if (listRef.current && infiniteScroll?.prevPage?.hasMore) {
130
122
  listRef.current.scrollTo(INFINITE_LOADED_ITEM_HEIGHT);
131
123
  }
132
- }, [listRef, infiniteScroll == null || (_infiniteScroll$prevP2 = infiniteScroll.prevPage) == null ? void 0 : _infiniteScroll$prevP2.hasMore]);
133
- useImperativeHandle(forwardedRef, function () {
134
- return {
135
- virtualListRef: listRef,
136
- outerListRef: outerListRef,
137
- horizontalScrollRef: horizontalScrollRef,
138
- scrollTo: scrollTo,
139
- scrollToTop: scrollToTop
140
- };
141
- });
142
- var _useState3 = useState(initialWidth),
143
- tableWidth = _useState3[0],
144
- setTableWidth = _useState3[1];
145
- var _useState4 = useState(initialWidth),
146
- scrollWidth = _useState4[0],
147
- setScrollWidth = _useState4[1];
148
- var _useState5 = useState(0),
149
- titleBarHeight = _useState5[0],
150
- setTitleBarHeight = _useState5[1];
151
- var _useRowStar = useRowStar((rowStar == null ? void 0 : rowStar.starredRowKeys) || []),
152
- getRowStarColumn = _useRowStar.getRowStarColumn;
153
-
154
- // deprecated, verify if not used and remove
155
- useEffect(function () {
124
+ }, [listRef, infiniteScroll?.prevPage?.hasMore]);
125
+ useImperativeHandle(forwardedRef, () => ({
126
+ virtualListRef: listRef,
127
+ outerListRef,
128
+ horizontalScrollRef,
129
+ scrollTo,
130
+ scrollToTop
131
+ }));
132
+ const [tableWidth, setTableWidth] = useState(initialWidth);
133
+ const [scrollWidth, setScrollWidth] = useState(initialWidth);
134
+ const [titleBarHeight, setTitleBarHeight] = useState(0);
135
+ const {
136
+ getRowStarColumn
137
+ } = useRowStar(rowStar?.starredRowKeys || []);
138
+ useEffect(() => {
156
139
  listRef.current && onListRefChange && onListRefChange(listRef);
157
140
  });
158
- var _useRowKey = useRowKey(rowKey),
159
- getRowKey = _useRowKey.getRowKey;
160
- var allData = dataSourceFull || dataSource;
161
- var propsForRowStar = _extends({}, props, {
162
- rowStar: _extends({}, rowStar, {
163
- onClick: function onClick(e) {
141
+ const {
142
+ getRowKey
143
+ } = useRowKey(rowKey);
144
+ const allData = dataSourceFull || dataSource;
145
+ const propsForRowStar = {
146
+ ...props,
147
+ rowStar: {
148
+ ...rowStar,
149
+ onClick: (e) => {
164
150
  e.stopPropagation();
165
- if (typeof (rowStar == null ? void 0 : rowStar.onClick) === 'function') {
151
+ if (typeof rowStar?.onClick === "function") {
166
152
  rowStar.onClick(e);
167
153
  }
168
154
  }
169
- }),
170
- getRowKey: getRowKey,
155
+ },
156
+ getRowKey,
171
157
  locale: tableLocale
172
- });
173
- var rowStarColumn = getRowStarColumn(propsForRowStar);
174
- var selectedRecords = useMemo(function () {
158
+ };
159
+ const rowStarColumn = getRowStarColumn(propsForRowStar);
160
+ const selectedRecords = useMemo(() => {
175
161
  if (selection) {
176
- var _ref = selection,
177
- _ref$selectedRowKeys = _ref.selectedRowKeys,
178
- selectedRowKeys = _ref$selectedRowKeys === void 0 ? [] : _ref$selectedRowKeys;
179
- var selectedRows = [];
180
- allData.forEach(function (row) {
181
- var key = getRowKey(row);
182
- var rowChildren = row[childrenColumnName];
162
+ const {
163
+ selectedRowKeys = []
164
+ } = selection;
165
+ let selectedRows = [];
166
+ allData.forEach((row) => {
167
+ const key = getRowKey(row);
168
+ const rowChildren = row[childrenColumnName];
183
169
  if (key && selectedRowKeys.indexOf(key) >= 0) {
184
- selectedRows = [].concat(selectedRows, [row]);
170
+ selectedRows = [...selectedRows, row];
185
171
  }
186
- if (rowChildren !== undefined && Array.isArray(rowChildren)) {
187
- rowChildren.forEach(function (child) {
188
- var childKey = getRowKey(child);
172
+ if (rowChildren !== void 0 && Array.isArray(rowChildren)) {
173
+ rowChildren.forEach((child) => {
174
+ const childKey = getRowKey(child);
189
175
  if (childKey && selectedRowKeys.indexOf(childKey) >= 0) {
190
- selectedRows = [].concat(selectedRows, [child]);
176
+ selectedRows = [...selectedRows, child];
191
177
  }
192
178
  });
193
179
  }
@@ -196,158 +182,143 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
196
182
  }
197
183
  return [];
198
184
  }, [allData, childrenColumnName, getRowKey, selection]);
199
- var renderRowSelection = useCallback(function (key, record) {
200
- var _selection$globalSele;
201
- var _ref2 = selection,
202
- selectedRowKeys = _ref2.selectedRowKeys,
203
- limit = _ref2.limit,
204
- independentSelectionExpandedRows = _ref2.independentSelectionExpandedRows,
205
- onChange = _ref2.onChange,
206
- checkRowSelectionStatus = _ref2.checkRowSelectionStatus;
207
- var handleChange = function handleChange(keys, records) {
185
+ const renderRowSelection = useCallback((key, record) => {
186
+ const {
187
+ selectedRowKeys,
188
+ limit,
189
+ independentSelectionExpandedRows,
190
+ onChange,
191
+ checkRowSelectionStatus
192
+ } = selection;
193
+ const handleChange = (keys, records) => {
208
194
  if (isSticky && listScrollTopRef.current) {
209
195
  setIsHeaderVisible(true);
210
196
  }
211
197
  onChange(keys, records);
212
198
  };
213
- return /*#__PURE__*/React.createElement(RowSelectionColumn, {
214
- rowKey: rowKey,
215
- record: record,
216
- limit: limit,
217
- selectedRowKeys: selectedRowKeys,
218
- independentSelectionExpandedRows: independentSelectionExpandedRows,
219
- onChange: handleChange,
220
- selectedRecords: selectedRecords,
221
- isGlobalAllSelected: selection == null || (_selection$globalSele = selection.globalSelection) == null ? void 0 : _selection$globalSele.isSelected,
222
- tableLocale: locale,
223
- getSelectionTooltipProps: selection == null ? void 0 : selection.getSelectionTooltipProps,
224
- checkRowSelectionStatus: checkRowSelectionStatus,
225
- childrenColumnName: childrenColumnName
226
- });
199
+ return /* @__PURE__ */ jsx(RowSelectionColumn, { rowKey, record, limit, selectedRowKeys, independentSelectionExpandedRows, onChange: handleChange, selectedRecords, isGlobalAllSelected: selection?.globalSelection?.isSelected, tableLocale: locale, getSelectionTooltipProps: selection?.getSelectionTooltipProps, checkRowSelectionStatus, childrenColumnName });
227
200
  }, [isSticky, locale, rowKey, selectedRecords, selection, childrenColumnName]);
228
- var virtualColumns = useMemo(function () {
201
+ const virtualColumns = useMemo(() => {
229
202
  return compact([!!selection && {
230
203
  width: 64,
231
- key: 'key',
232
- dataIndex: 'key',
204
+ key: "key",
205
+ dataIndex: "key",
233
206
  render: renderRowSelection
234
- }, !!rowStar && rowStarColumn].concat(columns));
207
+ }, !!rowStar && rowStarColumn, ...columns]);
235
208
  }, [selection, renderRowSelection, rowStar, rowStarColumn, columns]);
236
- var mergedColumns = useMemo(function () {
237
- var columnWidths = calculateColumnWidths(virtualColumns, tableWidth);
238
- var cumulativeRightOffset = 0;
239
- var cumulativeLeftOffset = 0;
240
- var firstFixedRightFound = false;
241
- var _virtualColumns$reduc = virtualColumns.reduce(function (prev, column, index) {
242
- var left = cumulativeLeftOffset;
243
- var right = cumulativeRightOffset;
244
- var width = columnWidths[index];
245
- if (column.fixed === 'right') {
246
- cumulativeRightOffset += width;
247
- var fixedFirst = !firstFixedRightFound;
248
- if (!firstFixedRightFound) {
249
- firstFixedRightFound = true;
250
- }
251
- return _extends({}, prev, {
252
- fixedRight: [].concat(prev.fixedRight, [_extends({}, column, {
253
- fixedFirst: fixedFirst,
254
- right: right,
255
- width: width
256
- })])
257
- });
258
- }
259
- if (column.fixed === 'left') {
260
- cumulativeLeftOffset += width;
261
- var prevFixedLeft = prev.fixedLeft;
262
- var newFixedLeft = prevFixedLeft.length ? [].concat(prevFixedLeft, [_extends({}, prevFixedLeft.pop(), {
263
- fixedFirst: false
264
- }), _extends({}, column, {
265
- fixedFirst: true,
266
- left: left,
267
- width: width
268
- })]) : [].concat(prevFixedLeft, [_extends({}, column, {
269
- fixedFirst: true,
270
- left: left,
271
- width: width
272
- })]);
273
- return _extends({}, prev, {
274
- fixedLeft: newFixedLeft
275
- });
209
+ const mergedColumns = useMemo(() => {
210
+ const columnWidths = calculateColumnWidths(virtualColumns, tableWidth);
211
+ let cumulativeRightOffset = 0;
212
+ let cumulativeLeftOffset = 0;
213
+ let firstFixedRightFound = false;
214
+ const {
215
+ fixedLeft,
216
+ remaining,
217
+ fixedRight
218
+ } = virtualColumns.reduce((prev, column, index) => {
219
+ const left = cumulativeLeftOffset;
220
+ const right = cumulativeRightOffset;
221
+ const width = columnWidths[index];
222
+ if (column.fixed === "right") {
223
+ cumulativeRightOffset += width;
224
+ const fixedFirst = !firstFixedRightFound;
225
+ if (!firstFixedRightFound) {
226
+ firstFixedRightFound = true;
276
227
  }
277
- return _extends({}, prev, {
278
- remaining: [].concat(prev.remaining, [_extends({}, column, {
279
- width: width
280
- })])
281
- });
282
- }, {
283
- fixedLeft: [],
284
- fixedRight: [],
285
- remaining: []
286
- }),
287
- fixedLeft = _virtualColumns$reduc.fixedLeft,
288
- remaining = _virtualColumns$reduc.remaining,
289
- fixedRight = _virtualColumns$reduc.fixedRight;
290
- return [].concat(fixedLeft, remaining, fixedRight);
228
+ return {
229
+ ...prev,
230
+ fixedRight: [...prev.fixedRight, {
231
+ ...column,
232
+ fixedFirst,
233
+ right,
234
+ width
235
+ }]
236
+ };
237
+ }
238
+ if (column.fixed === "left") {
239
+ cumulativeLeftOffset += width;
240
+ const {
241
+ fixedLeft: prevFixedLeft
242
+ } = prev;
243
+ const newFixedLeft = prevFixedLeft.length ? [...prevFixedLeft, {
244
+ ...prevFixedLeft.pop(),
245
+ fixedFirst: false
246
+ }, {
247
+ ...column,
248
+ fixedFirst: true,
249
+ left,
250
+ width
251
+ }] : [...prevFixedLeft, {
252
+ ...column,
253
+ fixedFirst: true,
254
+ left,
255
+ width
256
+ }];
257
+ return {
258
+ ...prev,
259
+ fixedLeft: newFixedLeft
260
+ };
261
+ }
262
+ return {
263
+ ...prev,
264
+ remaining: [...prev.remaining, {
265
+ ...column,
266
+ width
267
+ }]
268
+ };
269
+ }, {
270
+ fixedLeft: [],
271
+ fixedRight: [],
272
+ remaining: []
273
+ });
274
+ return [...fixedLeft, ...remaining, ...fixedRight];
291
275
  }, [tableWidth, virtualColumns]);
292
- var infiniteLoaderOffset = useMemo(function () {
293
- var _infiniteScroll$prevP3;
294
- if (isSticky && infiniteScroll != null && (_infiniteScroll$prevP3 = infiniteScroll.prevPage) != null && _infiniteScroll$prevP3.hasMore) {
276
+ const infiniteLoaderOffset = useMemo(() => {
277
+ if (isSticky && infiniteScroll?.prevPage?.hasMore) {
295
278
  return infiniteLoaderItemHeight * 2;
296
279
  }
297
280
  return infiniteLoaderItemHeight;
298
- }, [isSticky, infiniteScroll == null || (_infiniteScroll$prevP4 = infiniteScroll.prevPage) == null ? void 0 : _infiniteScroll$prevP4.hasMore]);
299
- var listInnerElementType = useMemo(function () {
300
- return /*#__PURE__*/forwardRef(function (_ref3, innerElementRef) {
301
- var style = _ref3.style,
302
- rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
303
- return /*#__PURE__*/React.createElement(S.InnerListElement, _extends({
304
- ref: innerElementRef,
305
- style: _extends({}, style, {
306
- height: Number(style == null ? void 0 : style.height) + infiniteLoaderOffset + "px"
307
- })
308
- }, rest));
309
- });
310
- }, [infiniteLoaderOffset]);
311
- var scrollTo = useCallback(function (top) {
281
+ }, [isSticky, infiniteScroll?.prevPage?.hasMore]);
282
+ const listInnerElementType = useMemo(() => forwardRef(({
283
+ style,
284
+ ...rest
285
+ }, innerElementRef) => /* @__PURE__ */ jsx(InnerListElement, { ref: innerElementRef, style: {
286
+ ...style,
287
+ height: `${Number(style?.height) + infiniteLoaderOffset}px`
288
+ }, ...rest })), [infiniteLoaderOffset]);
289
+ const scrollTo = useCallback((top) => {
312
290
  if (!listRef.current) {
313
291
  return;
314
292
  }
315
293
  listRef.current.scrollTo(top);
316
294
  }, []);
317
- var scrollToTop = function scrollToTop() {
295
+ const scrollToTop = () => {
318
296
  scrollTo(0);
319
297
  };
320
- var outerElement = useMemo(function () {
321
- return OuterListElement(containerRef, isSticky);
322
- }, [isSticky]);
323
- var createItemData = useCallback(function (data, defaultTableProps
324
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
325
- ) {
326
- return {
327
- mergedColumns: mergedColumns,
328
- selection: selection,
329
- rowStar: rowStar,
330
- onRowClick: onRowClick,
331
- getRowTooltipProps: getRowTooltipProps,
332
- dataSource: data,
333
- infiniteScroll: infiniteScroll,
334
- cellHeight: cellHeight,
335
- defaultTableProps: defaultTableProps
336
- };
337
- }, [mergedColumns, getRowTooltipProps, selection, rowStar, onRowClick, infiniteScroll, cellHeight]);
338
- var offsetScroll = sticky && sticky !== true ? sticky.offsetScroll : 0;
339
- var offsetStickyHeader = sticky && sticky !== true ? sticky.offsetHeader : 0;
340
- var connectObject = useMemo(function () {
341
- var obj = {};
342
- Object.defineProperty(obj, 'scrollLeft', {
343
- get: function get() {
298
+ const outerElement = useMemo(() => OuterListElement(containerRef, isSticky), [isSticky]);
299
+ const createItemData = useCallback((data, defaultTableProps) => ({
300
+ mergedColumns,
301
+ selection,
302
+ rowStar,
303
+ onRowClick,
304
+ getRowTooltipProps,
305
+ dataSource: data,
306
+ infiniteScroll,
307
+ cellHeight,
308
+ defaultTableProps
309
+ }), [mergedColumns, getRowTooltipProps, selection, rowStar, onRowClick, infiniteScroll, cellHeight]);
310
+ const offsetScroll = sticky && sticky !== true ? sticky.offsetScroll : 0;
311
+ const offsetStickyHeader = sticky && sticky !== true ? sticky.offsetHeader : 0;
312
+ const connectObject = useMemo(() => {
313
+ const obj = {};
314
+ Object.defineProperty(obj, "scrollLeft", {
315
+ get: () => {
344
316
  if (outerListRef.current) {
345
- var _outerListRef$current;
346
- return (_outerListRef$current = outerListRef.current) == null ? void 0 : _outerListRef$current.scrollLeft;
317
+ return outerListRef.current?.scrollLeft;
347
318
  }
348
319
  return null;
349
320
  },
350
- set: function set(scrollLeft) {
321
+ set: (scrollLeft) => {
351
322
  if (outerListRef.current) {
352
323
  outerListRef.current.scrollTo({
353
324
  left: scrollLeft
@@ -357,7 +328,7 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
357
328
  });
358
329
  return obj;
359
330
  }, []);
360
- var handleStickyScrollbarScroll = useCallback(function (event) {
331
+ const handleStickyScrollbarScroll = useCallback((event) => {
361
332
  if (isSticky && customBodyOnScrollRef.current) {
362
333
  customBodyOnScrollRef.current({
363
334
  scrollLeft: event.currentTarget.scrollLeft
@@ -366,58 +337,59 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
366
337
  connectObject.scrollLeft = event.currentTarget.scrollLeft;
367
338
  }
368
339
  }, [connectObject, isSticky]);
369
- var renderBody = useCallback(function (rawData, meta, defaultTableProps) {
370
- var _expandable$expandedR;
371
- var onScroll = meta.onScroll,
372
- ref = meta.ref;
340
+ const renderBody = useCallback((rawData, meta, defaultTableProps) => {
341
+ const {
342
+ onScroll,
343
+ ref
344
+ } = meta;
373
345
  customBodyOnScrollRef.current = onScroll;
374
- // sticky header feature does NOT work without the ref assigned to a html node in the document.
375
- // without sticky header the ref needs to point to the connect proxy in order for the header and body components to scroll in sync
376
- // this gets resolved in antd 5.9.0, when antd supports virtualisation out of the box (but not infinite loader)
377
346
  if (!isSticky) {
378
- // @ts-expect-error Property 'current' does not exist on type '(instance: ScrollProxyType | null) => void
379
347
  ref.current = connectObject;
380
348
  }
381
- var renderVirtualList = function renderVirtualList(data) {
382
- var _infiniteScroll$nextP, _infiniteScroll$prevP5;
383
- var listHeight = data.length * cellHeight - scroll.y + infiniteLoaderOffset;
384
- var listMaxScroll = stickyScrollThreshold && infiniteScroll != null && infiniteScroll.maxScroll ? infiniteScroll.maxScroll - stickyScrollThreshold : listHeight;
385
- var handleListScroll = function handleListScroll(_ref4) {
386
- var scrollOffset = _ref4.scrollOffset,
387
- scrollDirection = _ref4.scrollDirection;
349
+ const renderVirtualList = (data) => {
350
+ const listHeight = data.length * cellHeight - scroll.y + infiniteLoaderOffset;
351
+ const listMaxScroll = stickyScrollThreshold && infiniteScroll?.maxScroll ? infiniteScroll.maxScroll - stickyScrollThreshold : listHeight;
352
+ const handleListScroll = ({
353
+ scrollOffset,
354
+ scrollDirection
355
+ }) => {
388
356
  if (!infiniteScroll || loading || listMaxScroll <= 0) {
389
357
  return;
390
358
  }
391
- var onScrollTopReach = infiniteScroll.onScrollTopReach,
392
- isLoading = infiniteScroll.isLoading,
393
- onScrollEndReach = infiniteScroll.onScrollEndReach;
394
- var roundedOffset = Math.ceil(scrollOffset);
359
+ const {
360
+ onScrollTopReach,
361
+ isLoading,
362
+ onScrollEndReach
363
+ } = infiniteScroll;
364
+ const roundedOffset = Math.ceil(scrollOffset);
395
365
  listScrollTopRef.current = roundedOffset;
396
- if (isSticky && scrollDirection === 'forward' && containerRef.current) {
366
+ if (isSticky && scrollDirection === "forward" && containerRef.current) {
397
367
  setIsHeaderVisible(false);
398
368
  }
399
- if (isSticky && scrollDirection === 'backward' && containerRef.current) {
369
+ if (isSticky && scrollDirection === "backward" && containerRef.current) {
400
370
  setIsHeaderVisible(roundedOffset > 0);
401
371
  }
402
372
  if (isLoading) {
403
373
  return;
404
374
  }
405
- if (scrollDirection === 'forward' && roundedOffset >= listMaxScroll - LOAD_DATA_OFFSET && typeof onScrollEndReach === 'function') {
375
+ if (scrollDirection === "forward" && roundedOffset >= listMaxScroll - LOAD_DATA_OFFSET && typeof onScrollEndReach === "function") {
406
376
  onScrollEndReach();
407
- } else if (scrollDirection === 'backward' && (offsetScroll && roundedOffset <= offsetScroll + LOAD_DATA_OFFSET || roundedOffset < LOAD_DATA_OFFSET) && typeof onScrollTopReach === 'function') {
377
+ } else if (scrollDirection === "backward" && (offsetScroll && roundedOffset <= offsetScroll + LOAD_DATA_OFFSET || roundedOffset < LOAD_DATA_OFFSET) && typeof onScrollTopReach === "function") {
408
378
  onScrollTopReach();
409
379
  }
410
380
  };
411
- var itemData = createItemData(data, defaultTableProps);
412
- var scrollableHeight = isSticky ? scroll.y - HEADER_ROW_HEIGHT : scroll.y;
413
- if (infiniteScroll != null && (_infiniteScroll$nextP = infiniteScroll.nextPage) != null && _infiniteScroll$nextP.hasMore && (_infiniteScroll$prevP5 = infiniteScroll.prevPage) != null && _infiniteScroll$prevP5.hasMore) {
381
+ const itemData = createItemData(data, defaultTableProps);
382
+ let scrollableHeight = isSticky ? scroll.y - HEADER_ROW_HEIGHT : scroll.y;
383
+ if (infiniteScroll?.nextPage?.hasMore && infiniteScroll.prevPage?.hasMore) {
414
384
  scrollableHeight += cellHeight;
415
385
  }
416
- var handleBodyScroll = function handleBodyScroll(event) {
417
- var scrollLeft = event.currentTarget.scrollLeft;
386
+ const handleBodyScroll = (event) => {
387
+ const {
388
+ scrollLeft
389
+ } = event.currentTarget;
418
390
  if (isSticky) {
419
- var info = {
420
- scrollLeft: scrollLeft,
391
+ const info = {
392
+ scrollLeft,
421
393
  currentTarget: event.currentTarget
422
394
  };
423
395
  onScroll(info);
@@ -430,79 +402,60 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
430
402
  setPingLeft(Math.floor(scrollLeft) > 0);
431
403
  }
432
404
  };
433
- return /*#__PURE__*/React.createElement(S.VirtualListWrapper, {
434
- listWidth: tableWidth,
435
- "data-testid": "virtual-list-wrapper",
436
- isSticky: isSticky,
437
- listHeight: listHeight + HEADER_ROW_HEIGHT,
438
- onScroll: handleBodyScroll
439
- // @ts-expect-error Type 'RefObject<ScrollProxyType>' is not assignable to type 'RefObject<HTMLDivElement>'
440
- ,
441
- ref: isSticky ? ref : undefined
442
- }, /*#__PURE__*/React.createElement(List, {
443
- ref: listRef,
444
- key: "virtual-list",
445
- onScroll: handleListScroll,
446
- onItemsRendered: onItemsRendered,
447
- className: "virtual-grid",
448
- height: scrollableHeight,
449
- layout: "vertical",
450
- itemCount: data.length,
451
- itemSize: cellHeight,
452
- width: scrollWidth,
453
- itemData: itemData,
454
- itemKey: function itemKey(index) {
455
- var key = getRowKey(data[index]);
456
- // @ts-expect-error The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
457
- return String(key instanceof String ? key.toLowerCase() : key);
458
- },
459
- outerElementType: outerElement,
460
- overscanCount: 5,
461
- outerRef: outerListRef,
462
- innerElementType: infiniteScroll && listInnerElementType
463
- }, VirtualTableRow));
405
+ return /* @__PURE__ */ jsx(
406
+ VirtualListWrapper,
407
+ {
408
+ listWidth: tableWidth,
409
+ "data-testid": "virtual-list-wrapper",
410
+ isSticky,
411
+ listHeight: listHeight + HEADER_ROW_HEIGHT,
412
+ onScroll: handleBodyScroll,
413
+ ref: isSticky ? ref : void 0,
414
+ children: /* @__PURE__ */ jsx(FixedSizeList, { ref: listRef, onScroll: handleListScroll, onItemsRendered, className: "virtual-grid", height: scrollableHeight, layout: "vertical", itemCount: data.length, itemSize: cellHeight, width: scrollWidth, itemData, itemKey: (index) => {
415
+ const key = getRowKey(data[index]);
416
+ return String(key instanceof String ? key.toLowerCase() : key);
417
+ }, outerElementType: outerElement, overscanCount: 5, outerRef: outerListRef, innerElementType: infiniteScroll && listInnerElementType, children: VirtualTableRow }, "virtual-list")
418
+ }
419
+ );
464
420
  };
465
- if (expandable != null && (_expandable$expandedR = expandable.expandedRowKeys) != null && _expandable$expandedR.length) {
466
- var expandedRows = rawData.reduce(function (result, currentRow) {
467
- var _expandable$expandedR2;
468
- var key = getRowKey(currentRow);
469
- var rowChildren = currentRow[childrenColumnName];
470
- if (key !== undefined && expandable != null && (_expandable$expandedR2 = expandable.expandedRowKeys) != null && _expandable$expandedR2.includes(key) && Array.isArray(rowChildren) && rowChildren.length) {
471
- return [].concat(result, [currentRow], rowChildren.map(function (child, index) {
472
- var _extends2;
473
- return _extends({}, child, (_extends2 = {}, _extends2[EXPANDED_ROW_PROPERTY] = true, _extends2.index = index, _extends2));
474
- }));
421
+ if (expandable?.expandedRowKeys?.length) {
422
+ const expandedRows = rawData.reduce((result, currentRow) => {
423
+ const key = getRowKey(currentRow);
424
+ const rowChildren = currentRow[childrenColumnName];
425
+ if (key !== void 0 && expandable?.expandedRowKeys?.includes(key) && Array.isArray(rowChildren) && rowChildren.length) {
426
+ return [...result, currentRow, ...rowChildren.map((child, index) => ({
427
+ ...child,
428
+ [EXPANDED_ROW_PROPERTY]: true,
429
+ index
430
+ }))];
475
431
  }
476
- return [].concat(result, [currentRow]);
432
+ return [...result, currentRow];
477
433
  }, []);
478
434
  return renderVirtualList(expandedRows);
479
435
  }
480
436
  return renderVirtualList(rawData);
481
- }, [connectObject, expandable == null ? void 0 : expandable.expandedRowKeys, cellHeight, scroll.y, isSticky, stickyScrollThreshold, infiniteScroll, createItemData, tableWidth, scrollWidth, onItemsRendered, outerElement, listInnerElementType, loading, offsetScroll, getRowKey, infiniteLoaderOffset, childrenColumnName]);
482
- var columnsSliceStartIndex = Number(!!selection) + Number(!!rowStar);
483
- var scrollValue = !dataSource || (dataSource == null ? void 0 : dataSource.length) === 0 ? undefined : scroll;
484
- var _useState6 = useState(false),
485
- pingRight = _useState6[0],
486
- setPingRight = _useState6[1];
487
- var _useState7 = useState(false),
488
- pingLeft = _useState7[0],
489
- setPingLeft = _useState7[1];
490
- var classNames = React.useMemo(function () {
491
- return classnames('virtual-table', className, {
492
- 'virtual-table-infinite-scroll': hasInfiniteScroll,
493
- 'with-sticky-header': isSticky,
494
- 'ds-table-ping-left': pingLeft,
495
- 'ds-table-ping-right': pingRight
437
+ }, [connectObject, expandable?.expandedRowKeys, cellHeight, scroll.y, isSticky, stickyScrollThreshold, infiniteScroll, createItemData, tableWidth, scrollWidth, onItemsRendered, outerElement, listInnerElementType, loading, offsetScroll, getRowKey, infiniteLoaderOffset, childrenColumnName]);
438
+ const columnsSliceStartIndex = Number(!!selection) + Number(!!rowStar);
439
+ const scrollValue = !dataSource || dataSource?.length === 0 ? void 0 : scroll;
440
+ const [pingRight, setPingRight] = useState(false);
441
+ const [pingLeft, setPingLeft] = useState(false);
442
+ const classNames$1 = React.useMemo(() => {
443
+ return classNames("virtual-table", className, {
444
+ "virtual-table-infinite-scroll": hasInfiniteScroll,
445
+ "with-sticky-header": isSticky,
446
+ "ds-table-ping-left": pingLeft,
447
+ "ds-table-ping-right": pingRight
496
448
  });
497
449
  }, [className, hasInfiniteScroll, isSticky, pingLeft, pingRight]);
498
- var finalColumns = mergedColumns.slice(columnsSliceStartIndex);
499
- useEffect(function () {
500
- // trigger body component onScroll to toggle .ant-table-ping-left / .ant-table-ping-right classes that indicate where columns overflow
450
+ const finalColumns = mergedColumns.slice(columnsSliceStartIndex);
451
+ useEffect(() => {
501
452
  if (customBodyOnScrollRef.current && outerListRef.current && outerListRef.current.parentElement) {
502
- var scrollableElement = outerListRef.current.parentElement;
503
- var scrollLeft = scrollableElement.scrollLeft,
504
- fullWidth = scrollableElement.scrollWidth,
505
- clientWidth = scrollableElement.clientWidth;
453
+ const scrollableElement = outerListRef.current.parentElement;
454
+ const {
455
+ scrollLeft,
456
+ scrollWidth: fullWidth,
457
+ clientWidth
458
+ } = scrollableElement;
506
459
  setPingLeft(fullWidth > clientWidth && Math.floor(scrollLeft) > 0);
507
460
  setPingRight(fullWidth > clientWidth && Math.ceil(scrollLeft) < fullWidth - clientWidth);
508
461
  customBodyOnScrollRef.current({
@@ -510,56 +463,34 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
510
463
  });
511
464
  }
512
465
  }, [tableWidth, scrollWidth]);
513
- useEffect(function () {
514
- if (containerRef != null && containerRef.current) {
515
- var headerElement = containerRef.current.querySelector('.ant-table-header');
516
- var titleElement = containerRef.current.querySelector('.ant-table-title');
466
+ useEffect(() => {
467
+ if (containerRef?.current) {
468
+ const headerElement = containerRef.current.querySelector(".ant-table-header");
469
+ const titleElement = containerRef.current.querySelector(".ant-table-title");
517
470
  headerElement && setScrollWidth(headerElement.scrollWidth);
518
471
  titleElement && setTitleBarHeight(titleElement.clientHeight);
519
472
  }
520
473
  }, [tableWidth, mergedColumns.length, dataSource.length, loading]);
521
- var _useElementInView = useElementInView({
522
- rootMargin: "0px 0px 12px 0px",
523
- threshold: 0
524
- }, containerRef),
525
- isStuck = _useElementInView.isIntersecting,
526
- elementRef = _useElementInView.elementRef;
527
- return /*#__PURE__*/React.createElement(S.VirtualTableWrapper, {
528
- isSticky: isSticky,
529
- titleBarTop: offsetStickyHeader || 0,
530
- titleBarHeight: titleBarHeight,
531
- style: isSticky ? {} : relativeInlineStyle,
532
- key: "relative-container",
533
- ref: containerRef,
534
- isHeaderVisible: isHeaderVisible
535
- }, /*#__PURE__*/React.createElement(ResizeObserver, {
536
- onResize: function onResize(_ref5) {
537
- var offsetWidth = _ref5.offsetWidth;
474
+ const {
475
+ isIntersecting: isStuck,
476
+ elementRef
477
+ } = useElementInView({
478
+ rootMargin: `0px 0px 12px 0px`,
479
+ threshold: 0
480
+ }, containerRef);
481
+ return /* @__PURE__ */ jsxs(VirtualTableWrapper, { isSticky, titleBarTop: offsetStickyHeader || 0, titleBarHeight, style: isSticky ? {} : relativeInlineStyle, ref: containerRef, isHeaderVisible, children: [
482
+ /* @__PURE__ */ jsx(ResizeObserver, { onResize: ({
483
+ offsetWidth
484
+ }) => {
538
485
  setTableWidth(offsetWidth);
539
- }
540
- }, /*#__PURE__*/React.createElement(DSTable, _extends({}, props, {
541
- sticky: dataSource.length ? sticky : undefined,
542
- loading: loading,
543
- scroll: scrollValue,
544
- className: classNames,
545
- columns: finalColumns,
546
- pagination: false,
547
- components: {
486
+ }, children: /* @__PURE__ */ jsx(DSTable, { ...props, sticky: dataSource.length ? sticky : void 0, loading, scroll: scrollValue, className: classNames$1, columns: finalColumns, pagination: false, components: {
548
487
  body: renderBody
549
- },
550
- locale: tableLocale
551
- }))), !!(infiniteScroll != null && infiniteScroll.showBackToTopButton) && /*#__PURE__*/React.createElement(BackToTopButton, {
552
- onClick: scrollToTop
553
- }, tableLocale.infiniteScrollBackToTop), isSticky && dataSource.length ? /*#__PURE__*/React.createElement(S.StickyScrollbarWrapper, {
554
- isStuck: isStuck,
555
- scrollOffset: offsetScroll || 0
556
- }, /*#__PURE__*/React.createElement(Scrollbar, {
557
- absolute: true,
558
- onScroll: handleStickyScrollbarScroll,
559
- ref: horizontalScrollRef
560
- }, /*#__PURE__*/React.createElement(S.StickyScrollbarContent, {
561
- ref: elementRef,
562
- scrollWidth: scrollWidth
563
- }))) : null);
488
+ }, locale: tableLocale }) }),
489
+ !!infiniteScroll?.showBackToTopButton && /* @__PURE__ */ jsx(BackToTopButton, { onClick: scrollToTop, children: tableLocale.infiniteScrollBackToTop }),
490
+ isSticky && dataSource.length ? /* @__PURE__ */ jsx(StickyScrollbarWrapper, { isStuck, scrollOffset: offsetScroll || 0, children: /* @__PURE__ */ jsx(Scrollbar, { absolute: true, onScroll: handleStickyScrollbarScroll, ref: horizontalScrollRef, children: /* @__PURE__ */ jsx(StickyScrollbarContent, { ref: elementRef, scrollWidth }) }) }) : null
491
+ ] }, "relative-container");
492
+ };
493
+ const VirtualTable$1 = forwardRef(VirtualTable);
494
+ export {
495
+ VirtualTable$1 as default
564
496
  };
565
- export default /*#__PURE__*/forwardRef(VirtualTable);