@carbon/ibm-products 2.43.2-canary.266 → 2.43.2-canary.267

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.
@@ -24,6 +24,7 @@ var rowSizeMap = {
24
24
  };
25
25
  var defaultRowHeight = rowSizeMap.lg;
26
26
  var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
27
+ var _gridRef$current;
27
28
  var getTableBodyProps = datagridState.getTableBodyProps,
28
29
  rows = datagridState.rows,
29
30
  prepareRow = datagridState.prepareRow,
@@ -42,7 +43,7 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
42
43
  onVirtualScroll = datagridState.onVirtualScroll;
43
44
  var headWrapRef = useRef(null);
44
45
  var innerRef = useRef(null);
45
-
46
+ var gridWidth = gridRef === null || gridRef === void 0 || (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth;
46
47
  /* istanbul ignore next */
47
48
  var handleVirtualGridResize = function handleVirtualGridResize() {
48
49
  var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
@@ -70,35 +71,43 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
70
71
  useEffect(function () {
71
72
  var _document;
72
73
  var headWrapEl = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector("#".concat(tableId, " .").concat(blockClass, "__head-wrap"));
73
- var headEle = headWrapEl === null || headWrapEl === void 0 ? void 0 : headWrapEl.querySelector("thead");
74
- if (headEle) {
75
- headEle.style.display = 'flex';
76
- } // scrollbar width to header column to fix header alignment
77
74
 
78
- function handleScroll(event) {
75
+ // Syncs header scroll position when virtual body is scrolled
76
+ function handleVirtualScrollX(event) {
79
77
  var virtualBody = event.target;
80
78
  if (headWrapEl) {
81
79
  headWrapEl.scrollLeft = virtualBody === null || virtualBody === void 0 ? void 0 : virtualBody.scrollLeft;
82
80
  }
83
81
  }
82
+
83
+ // Syncs virtual body scroll position when header is scrolled
84
+ function handleHeaderScrollX(event) {
85
+ var header = event.target;
86
+ if (testRef && testRef.current) {
87
+ testRef.current.scrollLeft = header === null || header === void 0 ? void 0 : header.scrollLeft;
88
+ // this prevents the scroll bar from over exceeding the vertical scroll bar compensation in the right
89
+ header.scrollLeft = testRef.current.scrollLeft;
90
+ }
91
+ }
84
92
  var testRefValue = testRef === null || testRef === void 0 ? void 0 : testRef.current;
85
- testRefValue === null || testRefValue === void 0 || testRefValue.addEventListener('scroll', handleScroll);
93
+ testRefValue === null || testRefValue === void 0 || testRefValue.addEventListener('scroll', handleVirtualScrollX);
94
+ headWrapEl === null || headWrapEl === void 0 || headWrapEl.addEventListener('scroll', handleHeaderScrollX);
86
95
  return function () {
87
- testRefValue === null || testRefValue === void 0 || testRefValue.removeEventListener('scroll', handleScroll);
96
+ testRefValue === null || testRefValue === void 0 || testRefValue.removeEventListener('scroll', handleVirtualScrollX);
97
+ headWrapEl === null || headWrapEl === void 0 || headWrapEl.removeEventListener('scroll', handleHeaderScrollX);
88
98
  };
89
99
  });
90
100
  useIsomorphicEffect(function () {
91
101
  if (headWrapRef.current && headWrapRef.current.style) {
92
- var _gridRef$current;
93
- headWrapRef.current.style.width = "".concat(gridRef === null || gridRef === void 0 || (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth, "px");
102
+ headWrapRef.current.style.width = "".concat(gridWidth, "px");
103
+ headWrapRef.current.style.overflow = "auto";
94
104
  }
95
- }, [headWrapRef, gridRef]);
105
+ }, [headWrapRef, gridWidth]);
96
106
  useIsomorphicEffect(function () {
97
107
  if (testRef !== null && testRef !== void 0 && testRef.current && testRef.current.style) {
98
- var _gridRef$current2;
99
- testRef.current.style.width = "".concat(gridRef === null || gridRef === void 0 || (_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.clientWidth, "px");
108
+ testRef.current.style.width = "".concat(gridWidth, "px");
100
109
  }
101
- }, [testRef, gridRef]);
110
+ }, [testRef, gridWidth]);
102
111
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
103
112
  className: "".concat(blockClass, "__head-wrap"),
104
113
  ref: headWrapRef
@@ -165,7 +165,7 @@ var DatagridRow = function DatagridRow(datagridState) {
165
165
  return h.id === cell.column.id;
166
166
  });
167
167
  var lastVisibleIndex = withActionsColumn ? 2 : 1;
168
- var lastVisibleFlexStyle = index === visibleColumns.length - lastVisibleIndex ? '1 1 0' : '0 0 auto';
168
+ var lastVisibleFlexStyle = index === visibleColumns.length - lastVisibleIndex ? '1 0 auto' : '0 0 auto';
169
169
  if (style) {
170
170
  style.flex = lastVisibleFlexStyle;
171
171
  }
@@ -28,6 +28,7 @@ var rowSizeMap = {
28
28
  };
29
29
  var defaultRowHeight = rowSizeMap.lg;
30
30
  var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
31
+ var _gridRef$current;
31
32
  var getTableBodyProps = datagridState.getTableBodyProps,
32
33
  rows = datagridState.rows,
33
34
  prepareRow = datagridState.prepareRow,
@@ -46,7 +47,7 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
46
47
  onVirtualScroll = datagridState.onVirtualScroll;
47
48
  var headWrapRef = React.useRef(null);
48
49
  var innerRef = React.useRef(null);
49
-
50
+ var gridWidth = gridRef === null || gridRef === void 0 || (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth;
50
51
  /* istanbul ignore next */
51
52
  var handleVirtualGridResize = function handleVirtualGridResize() {
52
53
  var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
@@ -74,35 +75,43 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
74
75
  React.useEffect(function () {
75
76
  var _document;
76
77
  var headWrapEl = (_document = document) === null || _document === void 0 ? void 0 : _document.querySelector("#".concat(tableId, " .").concat(blockClass, "__head-wrap"));
77
- var headEle = headWrapEl === null || headWrapEl === void 0 ? void 0 : headWrapEl.querySelector("thead");
78
- if (headEle) {
79
- headEle.style.display = 'flex';
80
- } // scrollbar width to header column to fix header alignment
81
78
 
82
- function handleScroll(event) {
79
+ // Syncs header scroll position when virtual body is scrolled
80
+ function handleVirtualScrollX(event) {
83
81
  var virtualBody = event.target;
84
82
  if (headWrapEl) {
85
83
  headWrapEl.scrollLeft = virtualBody === null || virtualBody === void 0 ? void 0 : virtualBody.scrollLeft;
86
84
  }
87
85
  }
86
+
87
+ // Syncs virtual body scroll position when header is scrolled
88
+ function handleHeaderScrollX(event) {
89
+ var header = event.target;
90
+ if (testRef && testRef.current) {
91
+ testRef.current.scrollLeft = header === null || header === void 0 ? void 0 : header.scrollLeft;
92
+ // this prevents the scroll bar from over exceeding the vertical scroll bar compensation in the right
93
+ header.scrollLeft = testRef.current.scrollLeft;
94
+ }
95
+ }
88
96
  var testRefValue = testRef === null || testRef === void 0 ? void 0 : testRef.current;
89
- testRefValue === null || testRefValue === void 0 || testRefValue.addEventListener('scroll', handleScroll);
97
+ testRefValue === null || testRefValue === void 0 || testRefValue.addEventListener('scroll', handleVirtualScrollX);
98
+ headWrapEl === null || headWrapEl === void 0 || headWrapEl.addEventListener('scroll', handleHeaderScrollX);
90
99
  return function () {
91
- testRefValue === null || testRefValue === void 0 || testRefValue.removeEventListener('scroll', handleScroll);
100
+ testRefValue === null || testRefValue === void 0 || testRefValue.removeEventListener('scroll', handleVirtualScrollX);
101
+ headWrapEl === null || headWrapEl === void 0 || headWrapEl.removeEventListener('scroll', handleHeaderScrollX);
92
102
  };
93
103
  });
94
104
  useIsomorphicEffect.useIsomorphicEffect(function () {
95
105
  if (headWrapRef.current && headWrapRef.current.style) {
96
- var _gridRef$current;
97
- headWrapRef.current.style.width = "".concat(gridRef === null || gridRef === void 0 || (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth, "px");
106
+ headWrapRef.current.style.width = "".concat(gridWidth, "px");
107
+ headWrapRef.current.style.overflow = "auto";
98
108
  }
99
- }, [headWrapRef, gridRef]);
109
+ }, [headWrapRef, gridWidth]);
100
110
  useIsomorphicEffect.useIsomorphicEffect(function () {
101
111
  if (testRef !== null && testRef !== void 0 && testRef.current && testRef.current.style) {
102
- var _gridRef$current2;
103
- testRef.current.style.width = "".concat(gridRef === null || gridRef === void 0 || (_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.clientWidth, "px");
112
+ testRef.current.style.width = "".concat(gridWidth, "px");
104
113
  }
105
- }, [testRef, gridRef]);
114
+ }, [testRef, gridWidth]);
106
115
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
107
116
  className: "".concat(blockClass, "__head-wrap"),
108
117
  ref: headWrapRef
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.43.2-canary.266+831a0bc7d",
4
+ "version": "2.43.2-canary.267+9d60c0cd0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -96,7 +96,7 @@
96
96
  "dependencies": {
97
97
  "@babel/runtime": "^7.23.9",
98
98
  "@carbon/feature-flags": "^0.22.0",
99
- "@carbon/ibm-products-styles": "^2.39.1-canary.276+831a0bc7d",
99
+ "@carbon/ibm-products-styles": "^2.39.1-canary.277+9d60c0cd0",
100
100
  "@carbon/telemetry": "^0.1.0",
101
101
  "@dnd-kit/core": "^6.0.8",
102
102
  "@dnd-kit/modifiers": "^7.0.0",
@@ -120,5 +120,5 @@
120
120
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
121
121
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
122
122
  },
123
- "gitHead": "831a0bc7da65e65c09228cf2b292cbb879484d3a"
123
+ "gitHead": "9d60c0cd0f0ab98ba87915eb50a9de2a55dff5a1"
124
124
  }
@@ -735,6 +735,10 @@
735
735
 
736
736
  .#{$block-class}__virtualScrollContainer {
737
737
  width: 100%;
738
+ .#{c4p-settings.$carbon-prefix}--data-table-content {
739
+ // overrides default scroll overflow as we handle overflow in thead and tbody separately for virtualScrollContainer variant
740
+ overflow-x: hidden;
741
+ }
738
742
  }
739
743
 
740
744
  .#{$block-class} .#{c4p-settings.$carbon-prefix}--modal {
@@ -781,6 +785,13 @@
781
785
  .#{$block-class} .#{c4p-settings.$pkg-prefix}--datagrid__head-wrap {
782
786
  overflow: hidden;
783
787
  background-color: $layer-accent;
788
+ -ms-overflow-style: none;
789
+ scrollbar-width: none;
790
+ }
791
+
792
+ .#{$block-class}
793
+ .#{c4p-settings.$pkg-prefix}--datagrid__head-wrap::-webkit-scrollbar {
794
+ display: none;
784
795
  }
785
796
 
786
797
  .#{$block-class}