@synerise/ds-table 0.51.4 → 0.52.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,17 @@
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.52.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-table@0.51.4...@synerise/ds-table@0.52.0) (2024-05-31)
7
+
8
+
9
+ ### Features
10
+
11
+ * **table:** reveal table header in sticky virtual table ([315b0f8](https://github.com/synerise/synerise-design/commit/315b0f8b3068362881f23133966ac0a59003e253))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [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
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-table
@@ -59,18 +59,24 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
59
59
  var intl = useIntl();
60
60
  var tableLocale = useTableLocale(intl, locale);
61
61
  var listRef = useRef(null);
62
+ var listScrollTopRef = useRef(0);
62
63
  var outerListRef = useRef(null);
63
64
  var containerRef = useRef(null);
64
65
  var horizontalScrollRef = useRef(null);
65
66
  var customBodyOnScrollRef = useRef();
67
+
68
+ var _useState = useState(false),
69
+ isHeaderVisible = _useState[0],
70
+ setIsHeaderVisible = _useState[1];
71
+
72
+ var _useState2 = useState(null),
73
+ firstItem = _useState2[0],
74
+ setFirstItem = _useState2[1];
75
+
66
76
  var hasInfiniteScroll = Boolean(infiniteScroll);
67
77
  var isSticky = Boolean(sticky);
68
78
  var stickyScrollThreshold = sticky && sticky.scrollThreshold;
69
-
70
- var _React$useState = React.useState(null),
71
- firstItem = _React$useState[0],
72
- setFirstItem = _React$useState[1];
73
-
79
+ var dataSourceEmpty = dataSource.length === 0;
74
80
  var updateFirstItem = useCallback(function (findFirstItem) {
75
81
  var prevFirstItemIndex = dataSource.findIndex(findFirstItem);
76
82
  setFirstItem(dataSource[0]);
@@ -86,9 +92,14 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
86
92
  }
87
93
  }
88
94
  }, [dataSource, setFirstItem, onScrollToRecordIndex]);
89
- React.useEffect(function () {
95
+ useEffect(function () {
96
+ if (dataSourceEmpty) {
97
+ setIsHeaderVisible(false);
98
+ }
99
+ }, [dataSourceEmpty]);
100
+ useEffect(function () {
90
101
  try {
91
- if (!(infiniteScroll != null && infiniteScroll.prevPage) || dataSource.length === 0) {
102
+ if (!(infiniteScroll != null && infiniteScroll.prevPage) || dataSourceEmpty) {
92
103
  return;
93
104
  }
94
105
 
@@ -129,8 +140,8 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
129
140
  } catch (error) {
130
141
  throw new Error('Cannot find firs item');
131
142
  }
132
- }, [dataSource, dataSource.length, rowKey, firstItem, infiniteScroll, updateFirstItem]);
133
- React.useEffect(function () {
143
+ }, [dataSource, dataSourceEmpty, rowKey, firstItem, infiniteScroll, updateFirstItem]);
144
+ useEffect(function () {
134
145
  var _infiniteScroll$prevP;
135
146
 
136
147
  if (listRef.current && infiniteScroll != null && (_infiniteScroll$prevP = infiniteScroll.prevPage) != null && _infiniteScroll$prevP.hasMore) {
@@ -147,13 +158,13 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
147
158
  };
148
159
  });
149
160
 
150
- var _useState = useState(initialWidth),
151
- tableWidth = _useState[0],
152
- setTableWidth = _useState[1];
161
+ var _useState3 = useState(initialWidth),
162
+ tableWidth = _useState3[0],
163
+ setTableWidth = _useState3[1];
153
164
 
154
- var _useState2 = useState(initialWidth),
155
- scrollWidth = _useState2[0],
156
- setScrollWidth = _useState2[1];
165
+ var _useState4 = useState(initialWidth),
166
+ scrollWidth = _useState4[0],
167
+ setScrollWidth = _useState4[1];
157
168
 
158
169
  var _useRowStar = useRowStar((rowStar == null ? void 0 : rowStar.starredRowKeys) || []),
159
170
  getRowStarColumn = _useRowStar.getRowStarColumn; // deprecated, verify if not used and remove
@@ -219,17 +230,26 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
219
230
  limit = _ref3.limit,
220
231
  independentSelectionExpandedRows = _ref3.independentSelectionExpandedRows,
221
232
  onChange = _ref3.onChange;
233
+
234
+ var handleChange = function handleChange(keys, records) {
235
+ if (isSticky && listScrollTopRef.current) {
236
+ setIsHeaderVisible(true);
237
+ }
238
+
239
+ onChange(keys, records);
240
+ };
241
+
222
242
  return /*#__PURE__*/React.createElement(RowSelectionColumn, {
223
243
  rowKey: rowKey,
224
244
  record: record,
225
245
  limit: limit,
226
246
  selectedRowKeys: selectedRowKeys,
227
247
  independentSelectionExpandedRows: independentSelectionExpandedRows,
228
- onChange: onChange,
248
+ onChange: handleChange,
229
249
  selectedRecords: selectedRecords,
230
250
  tableLocale: locale
231
251
  });
232
- }, [locale, rowKey, selectedRecords, selection]);
252
+ }, [isSticky, locale, rowKey, selectedRecords, selection]);
233
253
  var virtualColumns = useMemo(function () {
234
254
  return compact([!!selection && {
235
255
  width: 64,
@@ -407,6 +427,15 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
407
427
  }
408
428
 
409
429
  var roundedOffset = Math.ceil(scrollOffset);
430
+ listScrollTopRef.current = roundedOffset;
431
+
432
+ if (isSticky && scrollDirection === 'forward' && containerRef.current) {
433
+ setIsHeaderVisible(false);
434
+ }
435
+
436
+ if (isSticky && scrollDirection === 'backward' && containerRef.current) {
437
+ setIsHeaderVisible(roundedOffset > 0);
438
+ }
410
439
 
411
440
  if (scrollDirection === 'forward' && roundedOffset >= listMaxScroll - LOAD_DATA_OFFSET && typeof (infiniteScroll == null ? void 0 : infiniteScroll.onScrollEndReach) === 'function') {
412
441
  infiniteScroll.onScrollEndReach();
@@ -521,7 +550,8 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
521
550
  isSticky: isSticky,
522
551
  style: isSticky ? {} : relativeInlineStyle,
523
552
  key: "relative-container",
524
- ref: containerRef
553
+ ref: containerRef,
554
+ isHeaderVisible: isHeaderVisible
525
555
  }, /*#__PURE__*/React.createElement(ResizeObserver, {
526
556
  onResize: function onResize(_ref6) {
527
557
  var offsetWidth = _ref6.offsetWidth;
@@ -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.52.0",
4
4
  "description": "Table UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -38,7 +38,7 @@
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.57",
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",
@@ -53,8 +53,8 @@
53
53
  "@synerise/ds-search": "^0.8.92",
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": "9293cda82b432c10af1d230262afcc6f08f3dd99"
83
83
  }