@synerise/ds-table 0.51.4 → 0.53.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.53.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-table@0.52.0...@synerise/ds-table@0.53.0) (2024-06-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * **table:** display total count in virtual table ([94d8d5b](https://github.com/synerise/synerise-design/commit/94d8d5b1b6e0281d9386bf467fce0f5e80a33308))
12
+
13
+
14
+
15
+
16
+
17
+ # [0.52.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-table@0.51.4...@synerise/ds-table@0.52.0) (2024-05-31)
18
+
19
+
20
+ ### Features
21
+
22
+ * **table:** reveal table header in sticky virtual table ([315b0f8](https://github.com/synerise/synerise-design/commit/315b0f8b3068362881f23133966ac0a59003e253))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.51.4](https://github.com/synerise/synerise-design/compare/@synerise/ds-table@0.51.3...@synerise/ds-table@0.51.4) (2024-05-29)
7
29
 
8
30
  **Note:** Version bump only for package @synerise/ds-table
@@ -47,7 +47,7 @@ var TableHeader = function TableHeader(_ref) {
47
47
  }, [titleRef, isTitleTruncated, title]);
48
48
  var renderLeftSide = React.useMemo(function () {
49
49
  if (selection != null && selection.limit) return /*#__PURE__*/React.createElement(TableLimit, {
50
- total: dataSource.length,
50
+ total: dataSourceTotalCount || dataSource.length,
51
51
  selection: selection,
52
52
  itemsMenu: itemsMenu,
53
53
  locale: locale
@@ -49,6 +49,7 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
49
49
  _props$dataSource = props.dataSource,
50
50
  dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
51
51
  dataSourceFull = props.dataSourceFull,
52
+ dataSourceTotalCount = props.dataSourceTotalCount,
52
53
  expandable = props.expandable,
53
54
  locale = props.locale,
54
55
  loading = props.loading,
@@ -59,18 +60,24 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
59
60
  var intl = useIntl();
60
61
  var tableLocale = useTableLocale(intl, locale);
61
62
  var listRef = useRef(null);
63
+ var listScrollTopRef = useRef(0);
62
64
  var outerListRef = useRef(null);
63
65
  var containerRef = useRef(null);
64
66
  var horizontalScrollRef = useRef(null);
65
67
  var customBodyOnScrollRef = useRef();
68
+
69
+ var _useState = useState(false),
70
+ isHeaderVisible = _useState[0],
71
+ setIsHeaderVisible = _useState[1];
72
+
73
+ var _useState2 = useState(null),
74
+ firstItem = _useState2[0],
75
+ setFirstItem = _useState2[1];
76
+
66
77
  var hasInfiniteScroll = Boolean(infiniteScroll);
67
78
  var isSticky = Boolean(sticky);
68
79
  var stickyScrollThreshold = sticky && sticky.scrollThreshold;
69
-
70
- var _React$useState = React.useState(null),
71
- firstItem = _React$useState[0],
72
- setFirstItem = _React$useState[1];
73
-
80
+ var dataSourceEmpty = dataSource.length === 0;
74
81
  var updateFirstItem = useCallback(function (findFirstItem) {
75
82
  var prevFirstItemIndex = dataSource.findIndex(findFirstItem);
76
83
  setFirstItem(dataSource[0]);
@@ -86,9 +93,14 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
86
93
  }
87
94
  }
88
95
  }, [dataSource, setFirstItem, onScrollToRecordIndex]);
89
- React.useEffect(function () {
96
+ useEffect(function () {
97
+ if (dataSourceEmpty) {
98
+ setIsHeaderVisible(false);
99
+ }
100
+ }, [dataSourceEmpty]);
101
+ useEffect(function () {
90
102
  try {
91
- if (!(infiniteScroll != null && infiniteScroll.prevPage) || dataSource.length === 0) {
103
+ if (!(infiniteScroll != null && infiniteScroll.prevPage) || dataSourceEmpty) {
92
104
  return;
93
105
  }
94
106
 
@@ -129,8 +141,8 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
129
141
  } catch (error) {
130
142
  throw new Error('Cannot find firs item');
131
143
  }
132
- }, [dataSource, dataSource.length, rowKey, firstItem, infiniteScroll, updateFirstItem]);
133
- React.useEffect(function () {
144
+ }, [dataSource, dataSourceEmpty, rowKey, firstItem, infiniteScroll, updateFirstItem]);
145
+ useEffect(function () {
134
146
  var _infiniteScroll$prevP;
135
147
 
136
148
  if (listRef.current && infiniteScroll != null && (_infiniteScroll$prevP = infiniteScroll.prevPage) != null && _infiniteScroll$prevP.hasMore) {
@@ -147,13 +159,13 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
147
159
  };
148
160
  });
149
161
 
150
- var _useState = useState(initialWidth),
151
- tableWidth = _useState[0],
152
- setTableWidth = _useState[1];
162
+ var _useState3 = useState(initialWidth),
163
+ tableWidth = _useState3[0],
164
+ setTableWidth = _useState3[1];
153
165
 
154
- var _useState2 = useState(initialWidth),
155
- scrollWidth = _useState2[0],
156
- setScrollWidth = _useState2[1];
166
+ var _useState4 = useState(initialWidth),
167
+ scrollWidth = _useState4[0],
168
+ setScrollWidth = _useState4[1];
157
169
 
158
170
  var _useRowStar = useRowStar((rowStar == null ? void 0 : rowStar.starredRowKeys) || []),
159
171
  getRowStarColumn = _useRowStar.getRowStarColumn; // deprecated, verify if not used and remove
@@ -219,17 +231,26 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
219
231
  limit = _ref3.limit,
220
232
  independentSelectionExpandedRows = _ref3.independentSelectionExpandedRows,
221
233
  onChange = _ref3.onChange;
234
+
235
+ var handleChange = function handleChange(keys, records) {
236
+ if (isSticky && listScrollTopRef.current) {
237
+ setIsHeaderVisible(true);
238
+ }
239
+
240
+ onChange(keys, records);
241
+ };
242
+
222
243
  return /*#__PURE__*/React.createElement(RowSelectionColumn, {
223
244
  rowKey: rowKey,
224
245
  record: record,
225
246
  limit: limit,
226
247
  selectedRowKeys: selectedRowKeys,
227
248
  independentSelectionExpandedRows: independentSelectionExpandedRows,
228
- onChange: onChange,
249
+ onChange: handleChange,
229
250
  selectedRecords: selectedRecords,
230
251
  tableLocale: locale
231
252
  });
232
- }, [locale, rowKey, selectedRecords, selection]);
253
+ }, [isSticky, locale, rowKey, selectedRecords, selection]);
233
254
  var virtualColumns = useMemo(function () {
234
255
  return compact([!!selection && {
235
256
  width: 64,
@@ -407,6 +428,15 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
407
428
  }
408
429
 
409
430
  var roundedOffset = Math.ceil(scrollOffset);
431
+ listScrollTopRef.current = roundedOffset;
432
+
433
+ if (isSticky && scrollDirection === 'forward' && containerRef.current) {
434
+ setIsHeaderVisible(false);
435
+ }
436
+
437
+ if (isSticky && scrollDirection === 'backward' && containerRef.current) {
438
+ setIsHeaderVisible(roundedOffset > 0);
439
+ }
410
440
 
411
441
  if (scrollDirection === 'forward' && roundedOffset >= listMaxScroll - LOAD_DATA_OFFSET && typeof (infiniteScroll == null ? void 0 : infiniteScroll.onScrollEndReach) === 'function') {
412
442
  infiniteScroll.onScrollEndReach();
@@ -521,7 +551,8 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
521
551
  isSticky: isSticky,
522
552
  style: isSticky ? {} : relativeInlineStyle,
523
553
  key: "relative-container",
524
- ref: containerRef
554
+ ref: containerRef,
555
+ isHeaderVisible: isHeaderVisible
525
556
  }, /*#__PURE__*/React.createElement(ResizeObserver, {
526
557
  onResize: function onResize(_ref6) {
527
558
  var offsetWidth = _ref6.offsetWidth;
@@ -538,6 +569,7 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
538
569
  components: {
539
570
  body: renderBody
540
571
  },
572
+ dataSourceTotalCount: dataSourceTotalCount,
541
573
  locale: tableLocale
542
574
  }))), !!(infiniteScroll != null && infiniteScroll.showBackToTopButton) && /*#__PURE__*/React.createElement(BackToTopButton, {
543
575
  onClick: scrollToTop
@@ -23,5 +23,6 @@ export declare const StickyScrollbarContent: import("styled-components").StyledC
23
23
  export declare const ColWrapper: import("styled-components").StyledComponent<"div", any, ColWrapperProps, never>;
24
24
  export declare const VirtualTableWrapper: import("styled-components").StyledComponent<"div", any, {
25
25
  isSticky: boolean;
26
+ isHeaderVisible?: boolean | undefined;
26
27
  }, never>;
27
28
  export {};
@@ -27,19 +27,19 @@ export var VirtualListWrapper = styled.div.withConfig({
27
27
  displayName: "VirtualTablestyles__VirtualListWrapper",
28
28
  componentId: "aehkhc-3"
29
29
  })(["", " overscroll-behavior-x:contain;"], function (props) {
30
- return props.isSticky && css(["width:", "px;overflow:overlay hidden;scrollbar-color:transparent;scrollbar-width:none;::-webkit-scrollbar-thumb{background-color:transparent;}::-webkit-scrollbar{display:none;}:after{content:'';width:10px;height:", "px;display:block;}"], props.listWidth, props.listHeight);
30
+ return props.isSticky && css(["width:", ";overflow:overlay hidden;scrollbar-color:transparent;scrollbar-width:none;::-webkit-scrollbar-thumb{background-color:transparent;}::-webkit-scrollbar{display:none;}:after{content:'';width:10px;height:", ";display:block;}"], numberToPixels(props.listWidth), numberToPixels(props.listHeight));
31
31
  });
32
32
  export var StickyScrollbar = styled(Scrollbar).withConfig({
33
33
  displayName: "VirtualTablestyles__StickyScrollbar",
34
34
  componentId: "aehkhc-4"
35
- })(["position:sticky;bottom:0;z-index:2;transform:translate(5px,", "px);"], function (props) {
36
- return props.offset;
35
+ })(["position:sticky;bottom:0;z-index:2;transform:translate(5px,", ");"], function (props) {
36
+ return numberToPixels(props.offset);
37
37
  });
38
38
  export var StickyScrollbarContent = styled.div.withConfig({
39
39
  displayName: "VirtualTablestyles__StickyScrollbarContent",
40
40
  componentId: "aehkhc-5"
41
- })(["width:", "px;height:10px;"], function (props) {
42
- return props.scrollWidth;
41
+ })(["width:", ";height:10px;"], function (props) {
42
+ return numberToPixels(props.scrollWidth);
43
43
  });
44
44
  export var ColWrapper = styled.div.withConfig({
45
45
  displayName: "VirtualTablestyles__ColWrapper",
@@ -56,5 +56,5 @@ export var VirtualTableWrapper = styled.div.withConfig({
56
56
  displayName: "VirtualTablestyles__VirtualTableWrapper",
57
57
  componentId: "aehkhc-7"
58
58
  })(["", ""], function (props) {
59
- return props.isSticky ? '' : 'position: relative;';
59
+ return props.isSticky ? css([".ant-table-title{position:sticky;top:-96px;z-index:99;}.ant-table-title,.ant-table-sticky-header{transition:top 0.3s ease-in-out;}", ";"], props.isHeaderVisible && css([".ant-table-title{top:-24px;}.ant-table-sticky-header{top:48px !important;}"])) : css(["position:relative;"]);
60
60
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-table",
3
- "version": "0.51.4",
3
+ "version": "0.53.0",
4
4
  "description": "Table UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -38,23 +38,23 @@
38
38
  "@synerise/ds-button": "^0.20.1",
39
39
  "@synerise/ds-button-group": "^0.7.1",
40
40
  "@synerise/ds-checkbox": "^0.12.1",
41
- "@synerise/ds-column-manager": "^0.11.56",
41
+ "@synerise/ds-column-manager": "^0.11.58",
42
42
  "@synerise/ds-data-format": "^0.5.0",
43
43
  "@synerise/ds-dropdown": "^0.18.0",
44
44
  "@synerise/ds-flag": "^0.5.0",
45
45
  "@synerise/ds-icon": "^0.62.0",
46
46
  "@synerise/ds-input": "^0.21.5",
47
47
  "@synerise/ds-loader": "^0.3.9",
48
- "@synerise/ds-menu": "^0.19.0",
48
+ "@synerise/ds-menu": "^0.19.1",
49
49
  "@synerise/ds-modal": "^0.17.30",
50
50
  "@synerise/ds-pagination": "^0.7.51",
51
51
  "@synerise/ds-result": "^0.6.56",
52
52
  "@synerise/ds-scrollbar": "^0.11.0",
53
- "@synerise/ds-search": "^0.8.92",
53
+ "@synerise/ds-search": "^0.8.93",
54
54
  "@synerise/ds-select": "^0.16.2",
55
55
  "@synerise/ds-skeleton": "^0.6.1",
56
- "@synerise/ds-status": "^0.6.7",
57
- "@synerise/ds-tags": "^0.8.46",
56
+ "@synerise/ds-status": "^0.6.8",
57
+ "@synerise/ds-tags": "^0.9.0",
58
58
  "@synerise/ds-tooltip": "^0.14.29",
59
59
  "@synerise/ds-typography": "^0.15.0",
60
60
  "@synerise/ds-utils": "^0.27.0",
@@ -79,5 +79,5 @@
79
79
  "devDependencies": {
80
80
  "@testing-library/react": "10.0.1"
81
81
  },
82
- "gitHead": "6bd94c78745df68ee3b853120a863ab24fc233ef"
82
+ "gitHead": "81acd8bf6b5fb04a22647e43d2c9289dcceb61a2"
83
83
  }