qbs-react-grid 1.1.45 → 1.1.46

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/es/Table.d.ts CHANGED
@@ -98,6 +98,7 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
98
98
  dataTheme?: string;
99
99
  /** Tree table, the callback function in the expanded node */
100
100
  renderTreeToggle?: (expandButton: React.ReactNode, rowData?: Row, expanded?: boolean) => React.ReactNode;
101
+ tableKey?: string;
101
102
  /** Customize what you can do to expand a zone */
102
103
  renderRowExpanded?: (rowData?: Row) => React.ReactNode;
103
104
  /** Custom row element */
package/es/Table.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- var _excluded = ["affixHeader", "children", "classPrefix", "className", "data", "defaultSortType", "width", "expandedRowKeys", "defaultExpandAllRows", "defaultExpandedRowKeys", "style", "id", "isTree", "hover", "bordered", "cellBordered", "wordWrap", "loading", "locale", "showHeader", "pagination", "paginationProps", "sortColumn", "rowHeight", "sortType", "headerHeight", "minHeight", "height", "autoHeight", "fillHeight", "rtl", "translate3d", "rowKey", "virtualized", "rowClassName", "rowExpandedHeight", "disabledScroll", "affixHorizontalScrollbar", "loadAnimation", "shouldUpdateScroll", "renderRow", "renderRowExpanded", "renderLoading", "renderEmpty", "onSortColumn", "onScroll", "renderTreeToggle", "onRowClick", "onRowContextMenu", "onExpandChange", "onTouchStart", "onTouchMove", "onTouchEnd", "dataTheme", "tableBodyHeight", "columns", "tableBodyRef"],
3
+ var _excluded = ["affixHeader", "children", "classPrefix", "className", "data", "defaultSortType", "width", "expandedRowKeys", "defaultExpandAllRows", "defaultExpandedRowKeys", "style", "id", "isTree", "hover", "bordered", "cellBordered", "wordWrap", "loading", "locale", "showHeader", "pagination", "paginationProps", "sortColumn", "rowHeight", "sortType", "headerHeight", "minHeight", "height", "autoHeight", "fillHeight", "rtl", "translate3d", "rowKey", "virtualized", "rowClassName", "rowExpandedHeight", "disabledScroll", "affixHorizontalScrollbar", "loadAnimation", "shouldUpdateScroll", "renderRow", "renderRowExpanded", "renderLoading", "renderEmpty", "onSortColumn", "onScroll", "renderTreeToggle", "onRowClick", "onRowContextMenu", "onExpandChange", "onTouchStart", "onTouchMove", "onTouchEnd", "dataTheme", "tableBodyHeight", "columns", "tableBodyRef", "tableKey"],
4
4
  _excluded2 = ["depth", "rowIndex"],
5
5
  _excluded3 = ["cellHeight"];
6
6
  import { getTranslateDOMPositionXY } from 'dom-lib/translateDOMPositionXY';
@@ -115,11 +115,13 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
115
115
  tableBodyHeight = props.tableBodyHeight,
116
116
  columns = props.columns,
117
117
  tableBodyRef = props.tableBodyRef,
118
+ tableKey = props.tableKey,
118
119
  rest = _objectWithoutPropertiesLoose(props, _excluded);
119
120
  var _useClassNames = useClassNames(classPrefix, typeof classPrefix !== 'undefined'),
120
121
  withClassPrefix = _useClassNames.withClassPrefix,
121
122
  mergeCls = _useClassNames.merge,
122
123
  prefix = _useClassNames.prefix;
124
+ var childTableRef = useRef(null);
123
125
 
124
126
  // Use `forceUpdate` to force the component to re-render after manipulating the DOM.
125
127
  var _useReducer = useReducer(function (x) {
@@ -283,6 +285,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
283
285
  minScrollY: minScrollY,
284
286
  minScrollX: minScrollX,
285
287
  scrollX: scrollX,
288
+ tableKey: tableKey,
286
289
  setScrollX: setScrollX,
287
290
  setScrollY: setScrollY,
288
291
  forceUpdatePosition: forceUpdatePosition,
@@ -293,12 +296,14 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
293
296
  onTouchEnd: onTouchEnd
294
297
  }),
295
298
  isScrolling = _useScrollListener.isScrolling,
299
+ isChildFocused = _useScrollListener.isChildFocused,
296
300
  onScrollHorizontal = _useScrollListener.onScrollHorizontal,
297
301
  onScrollVertical = _useScrollListener.onScrollVertical,
298
302
  onScrollBody = _useScrollListener.onScrollBody,
299
303
  onScrollTop = _useScrollListener.onScrollTop,
300
304
  onScrollLeft = _useScrollListener.onScrollLeft,
301
- onScrollTo = _useScrollListener.onScrollTo;
305
+ onScrollTo = _useScrollListener.onScrollTo,
306
+ setIsChildFocused = _useScrollListener.setIsChildFocused;
302
307
  var _useCellDescriptor = useCellDescriptor({
303
308
  children: children,
304
309
  rtl: rtl,
@@ -363,6 +368,12 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
363
368
  width: widthProp || 'auto',
364
369
  height: getTableHeight()
365
370
  }, style);
371
+ var handleChildFocus = useCallback(function () {
372
+ setIsChildFocused(true);
373
+ }, []);
374
+ var handleChildBlur = useCallback(function () {
375
+ setIsChildFocused(false);
376
+ }, []);
366
377
  var renderRowExpanded = useCallback(function (rowData) {
367
378
  var _tableRef$current;
368
379
  var styles = {
@@ -371,8 +382,11 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
371
382
  };
372
383
  if (typeof renderRowExpandedProp === 'function') {
373
384
  return /*#__PURE__*/React.createElement("div", {
385
+ ref: childTableRef,
374
386
  className: prefix('row-expanded'),
375
- style: styles
387
+ style: styles,
388
+ onMouseEnter: handleChildFocus,
389
+ onMouseLeave: handleChildBlur
376
390
  }, renderRowExpandedProp(rowData));
377
391
  }
378
392
  return null;
@@ -447,7 +461,9 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
447
461
  } else {
448
462
  rowNode = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CellGroup, null, mergeCells(cells)), shouldRenderExpandedRow && renderRowExpanded(rowData));
449
463
  }
450
- return /*#__PURE__*/React.createElement(Row, _extends({}, restRowProps, {
464
+ return /*#__PURE__*/React.createElement(Row, _extends({
465
+ rowRef: childTableRef
466
+ }, restRowProps, {
451
467
  "data-depth": depth,
452
468
  style: _extends({}, rowStyles)
453
469
  // zIndexValue={shouldRenderExpandedRow ? 100 : props.zIndexValue}
@@ -593,7 +609,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
593
609
  return null;
594
610
  }
595
611
  var scrollbars = [];
596
- if (hasHorizontalScrollbar) {
612
+ if (hasHorizontalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
597
613
  scrollbars.push( /*#__PURE__*/React.createElement(Scrollbar, {
598
614
  key: "scrollbar",
599
615
  tableId: id,
@@ -606,7 +622,7 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
606
622
  ref: scrollbarXRef
607
623
  }));
608
624
  }
609
- if (hasVerticalScrollbar) {
625
+ if (hasVerticalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
610
626
  scrollbars.push( /*#__PURE__*/React.createElement(Scrollbar, {
611
627
  vertical: true,
612
628
  key: "vertical-scrollbar",
@@ -84,7 +84,8 @@ var QbsTable = function QbsTable(_ref) {
84
84
  searchPlaceholder = _ref.searchPlaceholder,
85
85
  _ref$rowExpandedHeigh = _ref.rowExpandedHeight,
86
86
  rowExpandedHeight = _ref$rowExpandedHeigh === void 0 ? 517 : _ref$rowExpandedHeigh,
87
- renderSortIcon = _ref.renderSortIcon;
87
+ renderSortIcon = _ref.renderSortIcon,
88
+ tableKey = _ref.tableKey;
88
89
  var _useState = useState(false),
89
90
  loading = _useState[0],
90
91
  setLoading = _useState[1];
@@ -399,6 +400,8 @@ var QbsTable = function QbsTable(_ref) {
399
400
  className: "qbs-table-border-wrap"
400
401
  }, /*#__PURE__*/React.createElement(Table, {
401
402
  height: height,
403
+ key: tableKey,
404
+ tableKey: tableKey,
402
405
  data: data,
403
406
  tableBodyRef: tableBodyRef,
404
407
  dataTheme: dataTheme,
@@ -44,6 +44,7 @@ export interface ActionProps {
44
44
  hide?: (data: any, index?: number) => boolean;
45
45
  }
46
46
  export interface QbsTableProps {
47
+ tableKey?: string;
47
48
  isLoading?: boolean;
48
49
  columns: QbsColumnProps[];
49
50
  data: readonly any[];
@@ -21,6 +21,7 @@ interface ScrollListenerProps {
21
21
  minScrollY: React.MutableRefObject<number>;
22
22
  minScrollX: React.MutableRefObject<number>;
23
23
  scrollX: React.MutableRefObject<number>;
24
+ tableKey?: string;
24
25
  setScrollX: (v: number) => void;
25
26
  setScrollY: (v: number) => void;
26
27
  virtualized?: boolean;
@@ -39,6 +40,7 @@ interface ScrollListenerProps {
39
40
  */
40
41
  declare const useScrollListener: (props: ScrollListenerProps) => {
41
42
  isScrolling: boolean;
43
+ isChildFocused: boolean;
42
44
  onScrollHorizontal: (delta: number) => void;
43
45
  onScrollVertical: (delta: number, event: any) => void;
44
46
  onScrollBody: (event: any) => void;
@@ -48,5 +50,6 @@ declare const useScrollListener: (props: ScrollListenerProps) => {
48
50
  x?: number;
49
51
  y?: number;
50
52
  }) => void;
53
+ setIsChildFocused: React.Dispatch<React.SetStateAction<boolean>>;
51
54
  };
52
55
  export default useScrollListener;
@@ -67,14 +67,18 @@ var useScrollListener = function useScrollListener(props) {
67
67
  getTableHeight = props.getTableHeight,
68
68
  contentHeight = props.contentHeight,
69
69
  headerHeight = props.headerHeight,
70
- rtl = props.rtl;
70
+ rtl = props.rtl,
71
+ tableKey = props.tableKey;
71
72
  var wheelListener = useRef();
72
73
  var touchStartListener = useRef();
73
74
  var touchMoveListener = useRef();
74
75
  var touchEndListener = useRef();
75
76
  var _useState = useState(false),
76
- isScrolling = _useState[0],
77
- setScrolling = _useState[1];
77
+ isChildFocused = _useState[0],
78
+ setIsChildFocused = _useState[1];
79
+ var _useState2 = useState(false),
80
+ isScrolling = _useState2[0],
81
+ setScrolling = _useState2[1];
78
82
  var touchX = useRef(0);
79
83
  var touchY = useRef(0);
80
84
  var disableEventsTimeoutId = useRef(null);
@@ -86,13 +90,13 @@ var useScrollListener = function useScrollListener(props) {
86
90
  // The vertical starting value within the inertial sliding range.
87
91
  var momentumStartY = useRef(0);
88
92
  var shouldHandleWheelX = useCallback(function (delta) {
89
- if (delta === 0 || disabledScroll || loading) {
93
+ if (delta === 0 || disabledScroll || loading || isChildFocused) {
90
94
  return false;
91
95
  }
92
96
  return true;
93
97
  }, [disabledScroll, loading]);
94
98
  var shouldHandleWheelY = useCallback(function (delta) {
95
- if (delta === 0 || disabledScroll || loading || autoHeight) {
99
+ if (delta === 0 || disabledScroll || loading || autoHeight || isChildFocused) {
96
100
  return false;
97
101
  }
98
102
  if (typeof scrollY.current === 'number' && typeof minScrollY.current === 'number') {
@@ -116,9 +120,10 @@ var useScrollListener = function useScrollListener(props) {
116
120
  * @param momentumOptions The configuration of inertial scrolling is used for the touch event.
117
121
  */
118
122
  var handleWheel = useCallback(function (deltaX, deltaY, momentumOptions, event) {
119
- if (!tableRef.current) {
123
+ if (!tableRef.current || tableKey === 'parent' && isChildFocused) {
120
124
  return;
121
125
  }
126
+ // setIsChildFocused(false);
122
127
  var nextScrollX = contentWidth.current <= tableWidth.current ? 0 : scrollX.current - deltaX;
123
128
  var nextScrollY = scrollY.current - deltaY;
124
129
  var y = Math.min(0, nextScrollY < minScrollY.current ? minScrollY.current : nextScrollY);
@@ -202,6 +207,7 @@ var useScrollListener = function useScrollListener(props) {
202
207
  if (!isTouching.current) {
203
208
  return;
204
209
  }
210
+ console.log('handleTouchMove');
205
211
  var _event$touches$2 = event.touches[0],
206
212
  pageX = _event$touches$2.pageX,
207
213
  pageY = _event$touches$2.pageY;
@@ -235,6 +241,7 @@ var useScrollListener = function useScrollListener(props) {
235
241
  if (!isTouching.current) {
236
242
  return;
237
243
  }
244
+ console.log('handleTouchEnd');
238
245
  isTouching.current = false;
239
246
  var touchDuration = new Date().getTime() - momentumStartTime.current;
240
247
  var absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
@@ -398,12 +405,14 @@ var useScrollListener = function useScrollListener(props) {
398
405
  }, [handleWheel]);
399
406
  return {
400
407
  isScrolling: isScrolling,
408
+ isChildFocused: isChildFocused,
401
409
  onScrollHorizontal: onScrollHorizontal,
402
410
  onScrollVertical: onScrollVertical,
403
411
  onScrollBody: onScrollBody,
404
412
  onScrollTop: onScrollTop,
405
413
  onScrollLeft: onScrollLeft,
406
- onScrollTo: onScrollTo
414
+ onScrollTo: onScrollTo,
415
+ setIsChildFocused: setIsChildFocused
407
416
  };
408
417
  };
409
418
  export default useScrollListener;
package/lib/Table.d.ts CHANGED
@@ -98,6 +98,7 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
98
98
  dataTheme?: string;
99
99
  /** Tree table, the callback function in the expanded node */
100
100
  renderTreeToggle?: (expandButton: React.ReactNode, rowData?: Row, expanded?: boolean) => React.ReactNode;
101
+ tableKey?: string;
101
102
  /** Customize what you can do to expand a zone */
102
103
  renderRowExpanded?: (rowData?: Row) => React.ReactNode;
103
104
  /** Custom row element */
package/lib/Table.js CHANGED
@@ -20,7 +20,7 @@ var _Row = _interopRequireDefault(require("./Row"));
20
20
  var _Scrollbar = _interopRequireDefault(require("./Scrollbar"));
21
21
  var _TableContext = _interopRequireDefault(require("./TableContext"));
22
22
  var _utils = require("./utils");
23
- var _excluded = ["affixHeader", "children", "classPrefix", "className", "data", "defaultSortType", "width", "expandedRowKeys", "defaultExpandAllRows", "defaultExpandedRowKeys", "style", "id", "isTree", "hover", "bordered", "cellBordered", "wordWrap", "loading", "locale", "showHeader", "pagination", "paginationProps", "sortColumn", "rowHeight", "sortType", "headerHeight", "minHeight", "height", "autoHeight", "fillHeight", "rtl", "translate3d", "rowKey", "virtualized", "rowClassName", "rowExpandedHeight", "disabledScroll", "affixHorizontalScrollbar", "loadAnimation", "shouldUpdateScroll", "renderRow", "renderRowExpanded", "renderLoading", "renderEmpty", "onSortColumn", "onScroll", "renderTreeToggle", "onRowClick", "onRowContextMenu", "onExpandChange", "onTouchStart", "onTouchMove", "onTouchEnd", "dataTheme", "tableBodyHeight", "columns", "tableBodyRef"],
23
+ var _excluded = ["affixHeader", "children", "classPrefix", "className", "data", "defaultSortType", "width", "expandedRowKeys", "defaultExpandAllRows", "defaultExpandedRowKeys", "style", "id", "isTree", "hover", "bordered", "cellBordered", "wordWrap", "loading", "locale", "showHeader", "pagination", "paginationProps", "sortColumn", "rowHeight", "sortType", "headerHeight", "minHeight", "height", "autoHeight", "fillHeight", "rtl", "translate3d", "rowKey", "virtualized", "rowClassName", "rowExpandedHeight", "disabledScroll", "affixHorizontalScrollbar", "loadAnimation", "shouldUpdateScroll", "renderRow", "renderRowExpanded", "renderLoading", "renderEmpty", "onSortColumn", "onScroll", "renderTreeToggle", "onRowClick", "onRowContextMenu", "onExpandChange", "onTouchStart", "onTouchMove", "onTouchEnd", "dataTheme", "tableBodyHeight", "columns", "tableBodyRef", "tableKey"],
24
24
  _excluded2 = ["depth", "rowIndex"],
25
25
  _excluded3 = ["cellHeight"];
26
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -122,11 +122,13 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
122
122
  tableBodyHeight = props.tableBodyHeight,
123
123
  columns = props.columns,
124
124
  tableBodyRef = props.tableBodyRef,
125
+ tableKey = props.tableKey,
125
126
  rest = (0, _objectWithoutPropertiesLoose2["default"])(props, _excluded);
126
127
  var _useClassNames = (0, _utils.useClassNames)(classPrefix, typeof classPrefix !== 'undefined'),
127
128
  withClassPrefix = _useClassNames.withClassPrefix,
128
129
  mergeCls = _useClassNames.merge,
129
130
  prefix = _useClassNames.prefix;
131
+ var childTableRef = (0, _react.useRef)(null);
130
132
 
131
133
  // Use `forceUpdate` to force the component to re-render after manipulating the DOM.
132
134
  var _useReducer = (0, _react.useReducer)(function (x) {
@@ -290,6 +292,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
290
292
  minScrollY: minScrollY,
291
293
  minScrollX: minScrollX,
292
294
  scrollX: scrollX,
295
+ tableKey: tableKey,
293
296
  setScrollX: setScrollX,
294
297
  setScrollY: setScrollY,
295
298
  forceUpdatePosition: forceUpdatePosition,
@@ -300,12 +303,14 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
300
303
  onTouchEnd: onTouchEnd
301
304
  }),
302
305
  isScrolling = _useScrollListener.isScrolling,
306
+ isChildFocused = _useScrollListener.isChildFocused,
303
307
  onScrollHorizontal = _useScrollListener.onScrollHorizontal,
304
308
  onScrollVertical = _useScrollListener.onScrollVertical,
305
309
  onScrollBody = _useScrollListener.onScrollBody,
306
310
  onScrollTop = _useScrollListener.onScrollTop,
307
311
  onScrollLeft = _useScrollListener.onScrollLeft,
308
- onScrollTo = _useScrollListener.onScrollTo;
312
+ onScrollTo = _useScrollListener.onScrollTo,
313
+ setIsChildFocused = _useScrollListener.setIsChildFocused;
309
314
  var _useCellDescriptor = (0, _utils.useCellDescriptor)({
310
315
  children: children,
311
316
  rtl: rtl,
@@ -370,6 +375,12 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
370
375
  width: widthProp || 'auto',
371
376
  height: getTableHeight()
372
377
  }, style);
378
+ var handleChildFocus = (0, _react.useCallback)(function () {
379
+ setIsChildFocused(true);
380
+ }, []);
381
+ var handleChildBlur = (0, _react.useCallback)(function () {
382
+ setIsChildFocused(false);
383
+ }, []);
373
384
  var renderRowExpanded = (0, _react.useCallback)(function (rowData) {
374
385
  var _tableRef$current;
375
386
  var styles = {
@@ -378,8 +389,11 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
378
389
  };
379
390
  if (typeof renderRowExpandedProp === 'function') {
380
391
  return /*#__PURE__*/_react["default"].createElement("div", {
392
+ ref: childTableRef,
381
393
  className: prefix('row-expanded'),
382
- style: styles
394
+ style: styles,
395
+ onMouseEnter: handleChildFocus,
396
+ onMouseLeave: handleChildBlur
383
397
  }, renderRowExpandedProp(rowData));
384
398
  }
385
399
  return null;
@@ -454,7 +468,9 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
454
468
  } else {
455
469
  rowNode = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_CellGroup["default"], null, (0, _utils.mergeCells)(cells)), shouldRenderExpandedRow && renderRowExpanded(rowData));
456
470
  }
457
- return /*#__PURE__*/_react["default"].createElement(_Row["default"], (0, _extends2["default"])({}, restRowProps, {
471
+ return /*#__PURE__*/_react["default"].createElement(_Row["default"], (0, _extends2["default"])({
472
+ rowRef: childTableRef
473
+ }, restRowProps, {
458
474
  "data-depth": depth,
459
475
  style: (0, _extends2["default"])({}, rowStyles)
460
476
  // zIndexValue={shouldRenderExpandedRow ? 100 : props.zIndexValue}
@@ -600,7 +616,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
600
616
  return null;
601
617
  }
602
618
  var scrollbars = [];
603
- if (hasHorizontalScrollbar) {
619
+ if (hasHorizontalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
604
620
  scrollbars.push( /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], {
605
621
  key: "scrollbar",
606
622
  tableId: id,
@@ -613,7 +629,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
613
629
  ref: scrollbarXRef
614
630
  }));
615
631
  }
616
- if (hasVerticalScrollbar) {
632
+ if (hasVerticalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
617
633
  scrollbars.push( /*#__PURE__*/_react["default"].createElement(_Scrollbar["default"], {
618
634
  vertical: true,
619
635
  key: "vertical-scrollbar",
@@ -90,7 +90,8 @@ var QbsTable = function QbsTable(_ref) {
90
90
  searchPlaceholder = _ref.searchPlaceholder,
91
91
  _ref$rowExpandedHeigh = _ref.rowExpandedHeight,
92
92
  rowExpandedHeight = _ref$rowExpandedHeigh === void 0 ? 517 : _ref$rowExpandedHeigh,
93
- renderSortIcon = _ref.renderSortIcon;
93
+ renderSortIcon = _ref.renderSortIcon,
94
+ tableKey = _ref.tableKey;
94
95
  var _useState = (0, _react.useState)(false),
95
96
  loading = _useState[0],
96
97
  setLoading = _useState[1];
@@ -405,6 +406,8 @@ var QbsTable = function QbsTable(_ref) {
405
406
  className: "qbs-table-border-wrap"
406
407
  }, /*#__PURE__*/_react["default"].createElement(_Table["default"], {
407
408
  height: height,
409
+ key: tableKey,
410
+ tableKey: tableKey,
408
411
  data: data,
409
412
  tableBodyRef: tableBodyRef,
410
413
  dataTheme: dataTheme,
@@ -44,6 +44,7 @@ export interface ActionProps {
44
44
  hide?: (data: any, index?: number) => boolean;
45
45
  }
46
46
  export interface QbsTableProps {
47
+ tableKey?: string;
47
48
  isLoading?: boolean;
48
49
  columns: QbsColumnProps[];
49
50
  data: readonly any[];
@@ -21,6 +21,7 @@ interface ScrollListenerProps {
21
21
  minScrollY: React.MutableRefObject<number>;
22
22
  minScrollX: React.MutableRefObject<number>;
23
23
  scrollX: React.MutableRefObject<number>;
24
+ tableKey?: string;
24
25
  setScrollX: (v: number) => void;
25
26
  setScrollY: (v: number) => void;
26
27
  virtualized?: boolean;
@@ -39,6 +40,7 @@ interface ScrollListenerProps {
39
40
  */
40
41
  declare const useScrollListener: (props: ScrollListenerProps) => {
41
42
  isScrolling: boolean;
43
+ isChildFocused: boolean;
42
44
  onScrollHorizontal: (delta: number) => void;
43
45
  onScrollVertical: (delta: number, event: any) => void;
44
46
  onScrollBody: (event: any) => void;
@@ -48,5 +50,6 @@ declare const useScrollListener: (props: ScrollListenerProps) => {
48
50
  x?: number;
49
51
  y?: number;
50
52
  }) => void;
53
+ setIsChildFocused: React.Dispatch<React.SetStateAction<boolean>>;
51
54
  };
52
55
  export default useScrollListener;
@@ -71,14 +71,18 @@ var useScrollListener = function useScrollListener(props) {
71
71
  getTableHeight = props.getTableHeight,
72
72
  contentHeight = props.contentHeight,
73
73
  headerHeight = props.headerHeight,
74
- rtl = props.rtl;
74
+ rtl = props.rtl,
75
+ tableKey = props.tableKey;
75
76
  var wheelListener = (0, _react.useRef)();
76
77
  var touchStartListener = (0, _react.useRef)();
77
78
  var touchMoveListener = (0, _react.useRef)();
78
79
  var touchEndListener = (0, _react.useRef)();
79
80
  var _useState = (0, _react.useState)(false),
80
- isScrolling = _useState[0],
81
- setScrolling = _useState[1];
81
+ isChildFocused = _useState[0],
82
+ setIsChildFocused = _useState[1];
83
+ var _useState2 = (0, _react.useState)(false),
84
+ isScrolling = _useState2[0],
85
+ setScrolling = _useState2[1];
82
86
  var touchX = (0, _react.useRef)(0);
83
87
  var touchY = (0, _react.useRef)(0);
84
88
  var disableEventsTimeoutId = (0, _react.useRef)(null);
@@ -90,13 +94,13 @@ var useScrollListener = function useScrollListener(props) {
90
94
  // The vertical starting value within the inertial sliding range.
91
95
  var momentumStartY = (0, _react.useRef)(0);
92
96
  var shouldHandleWheelX = (0, _react.useCallback)(function (delta) {
93
- if (delta === 0 || disabledScroll || loading) {
97
+ if (delta === 0 || disabledScroll || loading || isChildFocused) {
94
98
  return false;
95
99
  }
96
100
  return true;
97
101
  }, [disabledScroll, loading]);
98
102
  var shouldHandleWheelY = (0, _react.useCallback)(function (delta) {
99
- if (delta === 0 || disabledScroll || loading || autoHeight) {
103
+ if (delta === 0 || disabledScroll || loading || autoHeight || isChildFocused) {
100
104
  return false;
101
105
  }
102
106
  if (typeof scrollY.current === 'number' && typeof minScrollY.current === 'number') {
@@ -120,9 +124,10 @@ var useScrollListener = function useScrollListener(props) {
120
124
  * @param momentumOptions The configuration of inertial scrolling is used for the touch event.
121
125
  */
122
126
  var handleWheel = (0, _react.useCallback)(function (deltaX, deltaY, momentumOptions, event) {
123
- if (!tableRef.current) {
127
+ if (!tableRef.current || tableKey === 'parent' && isChildFocused) {
124
128
  return;
125
129
  }
130
+ // setIsChildFocused(false);
126
131
  var nextScrollX = contentWidth.current <= tableWidth.current ? 0 : scrollX.current - deltaX;
127
132
  var nextScrollY = scrollY.current - deltaY;
128
133
  var y = Math.min(0, nextScrollY < minScrollY.current ? minScrollY.current : nextScrollY);
@@ -206,6 +211,7 @@ var useScrollListener = function useScrollListener(props) {
206
211
  if (!isTouching.current) {
207
212
  return;
208
213
  }
214
+ console.log('handleTouchMove');
209
215
  var _event$touches$2 = event.touches[0],
210
216
  pageX = _event$touches$2.pageX,
211
217
  pageY = _event$touches$2.pageY;
@@ -239,6 +245,7 @@ var useScrollListener = function useScrollListener(props) {
239
245
  if (!isTouching.current) {
240
246
  return;
241
247
  }
248
+ console.log('handleTouchEnd');
242
249
  isTouching.current = false;
243
250
  var touchDuration = new Date().getTime() - momentumStartTime.current;
244
251
  var absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
@@ -402,12 +409,14 @@ var useScrollListener = function useScrollListener(props) {
402
409
  }, [handleWheel]);
403
410
  return {
404
411
  isScrolling: isScrolling,
412
+ isChildFocused: isChildFocused,
405
413
  onScrollHorizontal: onScrollHorizontal,
406
414
  onScrollVertical: onScrollVertical,
407
415
  onScrollBody: onScrollBody,
408
416
  onScrollTop: onScrollTop,
409
417
  onScrollLeft: onScrollLeft,
410
- onScrollTo: onScrollTo
418
+ onScrollTo: onScrollTo,
419
+ setIsChildFocused: setIsChildFocused
411
420
  };
412
421
  };
413
422
  var _default = useScrollListener;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.1.45",
3
+ "version": "1.1.46",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
package/src/Row.tsx CHANGED
@@ -49,6 +49,7 @@ const Row = React.forwardRef((props: RowProps, ref: React.Ref<HTMLDivElement>) =
49
49
  };
50
50
  const INDEX = index as number;
51
51
  translateDOMPositionXY?.(styles as CSSStyleDeclaration, 0, top);
52
+
52
53
  return (
53
54
  <div
54
55
  role="row"
package/src/Table.tsx CHANGED
@@ -223,7 +223,7 @@ export interface TableProps<Row, Key> extends Omit<StandardProps, 'onScroll'> {
223
223
  rowData?: Row,
224
224
  expanded?: boolean
225
225
  ) => React.ReactNode;
226
-
226
+ tableKey?: string;
227
227
  /** Customize what you can do to expand a zone */
228
228
  renderRowExpanded?: (rowData?: Row) => React.ReactNode;
229
229
 
@@ -339,6 +339,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
339
339
  tableBodyHeight,
340
340
  columns,
341
341
  tableBodyRef,
342
+ tableKey,
342
343
  ...rest
343
344
  } = props;
344
345
 
@@ -347,6 +348,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
347
348
  merge: mergeCls,
348
349
  prefix
349
350
  } = useClassNames(classPrefix, typeof classPrefix !== 'undefined');
351
+ const childTableRef = useRef<HTMLDivElement>(null);
350
352
 
351
353
  // Use `forceUpdate` to force the component to re-render after manipulating the DOM.
352
354
  const [, forceUpdate] = useReducer(x => x + 1, 0);
@@ -494,12 +496,14 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
494
496
 
495
497
  const {
496
498
  isScrolling,
499
+ isChildFocused,
497
500
  onScrollHorizontal,
498
501
  onScrollVertical,
499
502
  onScrollBody,
500
503
  onScrollTop,
501
504
  onScrollLeft,
502
- onScrollTo
505
+ onScrollTo,
506
+ setIsChildFocused
503
507
  } = useScrollListener({
504
508
  rtl,
505
509
  data: dataProp,
@@ -521,6 +525,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
521
525
  minScrollY,
522
526
  minScrollX,
523
527
  scrollX,
528
+ tableKey,
524
529
  setScrollX,
525
530
  setScrollY,
526
531
  forceUpdatePosition,
@@ -605,13 +610,27 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
605
610
  ...style
606
611
  };
607
612
 
613
+ const handleChildFocus = useCallback(() => {
614
+ setIsChildFocused(true);
615
+ }, []);
616
+
617
+ const handleChildBlur = useCallback(() => {
618
+ setIsChildFocused(false);
619
+ }, []);
620
+
608
621
  const renderRowExpanded = useCallback(
609
622
  (rowData?: Row) => {
610
623
  const styles = { height: rowExpandedHeight, maxWidth: tableRef?.current?.clientWidth };
611
624
 
612
625
  if (typeof renderRowExpandedProp === 'function') {
613
626
  return (
614
- <div className={prefix('row-expanded')} style={styles}>
627
+ <div
628
+ ref={childTableRef}
629
+ className={prefix('row-expanded')}
630
+ style={styles}
631
+ onMouseEnter={handleChildFocus}
632
+ onMouseLeave={handleChildBlur}
633
+ >
615
634
  {renderRowExpandedProp(rowData)}
616
635
  </div>
617
636
  );
@@ -729,6 +748,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
729
748
  }
730
749
  return (
731
750
  <Row
751
+ rowRef={childTableRef}
732
752
  {...restRowProps}
733
753
  data-depth={depth}
734
754
  style={{
@@ -926,7 +946,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
926
946
 
927
947
  const scrollbars: React.ReactNode[] = [];
928
948
 
929
- if (hasHorizontalScrollbar) {
949
+ if (hasHorizontalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
930
950
  scrollbars.push(
931
951
  <Scrollbar
932
952
  key="scrollbar"
@@ -940,7 +960,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
940
960
  );
941
961
  }
942
962
 
943
- if (hasVerticalScrollbar) {
963
+ if (hasVerticalScrollbar && !(tableKey === 'parent' && isChildFocused)) {
944
964
  scrollbars.push(
945
965
  <Scrollbar
946
966
  vertical
@@ -75,7 +75,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
75
75
  customRowStatus,
76
76
  searchPlaceholder,
77
77
  rowExpandedHeight = 517,
78
- renderSortIcon
78
+ renderSortIcon,
79
+ tableKey
79
80
  }) => {
80
81
  const [loading, setLoading] = useState(false);
81
82
  const [columns, setColumns] = useState(propColumn);
@@ -84,7 +85,6 @@ const QbsTable: React.FC<QbsTableProps> = ({
84
85
  const [isOpen, setIsOpen] = useState(false);
85
86
  const prevColumns = useRef<any | null>();
86
87
  const tableBodyRef = useRef<HTMLDivElement>(null);
87
-
88
88
  const handleSortColumn = useCallback(
89
89
  (sortColumn: any, sortType: any) => {
90
90
  setLoading(true);
@@ -433,6 +433,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
433
433
  <div className="qbs-table-border-wrap">
434
434
  <Table
435
435
  height={height}
436
+ key={tableKey}
437
+ tableKey={tableKey}
436
438
  data={data}
437
439
  tableBodyRef={tableBodyRef}
438
440
  dataTheme={dataTheme}
@@ -49,6 +49,8 @@ export interface ActionProps {
49
49
  }
50
50
 
51
51
  export interface QbsTableProps {
52
+ tableKey?: string;
53
+
52
54
  isLoading?: boolean;
53
55
  columns: QbsColumnProps[];
54
56
  data: readonly any[];
@@ -40,6 +40,7 @@ interface ScrollListenerProps {
40
40
  minScrollY: React.MutableRefObject<number>;
41
41
  minScrollX: React.MutableRefObject<number>;
42
42
  scrollX: React.MutableRefObject<number>;
43
+ tableKey?: string;
43
44
  setScrollX: (v: number) => void;
44
45
  setScrollY: (v: number) => void;
45
46
  virtualized?: boolean;
@@ -104,13 +105,15 @@ const useScrollListener = (props: ScrollListenerProps) => {
104
105
  getTableHeight,
105
106
  contentHeight,
106
107
  headerHeight,
107
- rtl
108
+ rtl,
109
+ tableKey
108
110
  } = props;
109
111
 
110
112
  const wheelListener = useRef<ListenerCallback>();
111
113
  const touchStartListener = useRef<ListenerCallback>();
112
114
  const touchMoveListener = useRef<ListenerCallback>();
113
115
  const touchEndListener = useRef<ListenerCallback>();
116
+ const [isChildFocused, setIsChildFocused] = useState(false);
114
117
 
115
118
  const [isScrolling, setScrolling] = useState(false);
116
119
  const touchX = useRef(0);
@@ -126,7 +129,7 @@ const useScrollListener = (props: ScrollListenerProps) => {
126
129
 
127
130
  const shouldHandleWheelX = useCallback(
128
131
  (delta: number) => {
129
- if (delta === 0 || disabledScroll || loading) {
132
+ if (delta === 0 || disabledScroll || loading || isChildFocused) {
130
133
  return false;
131
134
  }
132
135
 
@@ -137,7 +140,7 @@ const useScrollListener = (props: ScrollListenerProps) => {
137
140
 
138
141
  const shouldHandleWheelY = useCallback(
139
142
  (delta: number) => {
140
- if (delta === 0 || disabledScroll || loading || autoHeight) {
143
+ if (delta === 0 || disabledScroll || loading || autoHeight || isChildFocused) {
141
144
  return false;
142
145
  }
143
146
 
@@ -171,10 +174,10 @@ const useScrollListener = (props: ScrollListenerProps) => {
171
174
  momentumOptions?: { duration: number; bezier: string },
172
175
  event?: React.MouseEvent
173
176
  ) => {
174
- if (!tableRef.current) {
177
+ if (!tableRef.current || (tableKey === 'parent' && isChildFocused)) {
175
178
  return;
176
179
  }
177
-
180
+ // setIsChildFocused(false);
178
181
  const nextScrollX = contentWidth.current <= tableWidth.current ? 0 : scrollX.current - deltaX;
179
182
  const nextScrollY = scrollY.current - deltaY;
180
183
 
@@ -294,6 +297,8 @@ const useScrollListener = (props: ScrollListenerProps) => {
294
297
  if (!isTouching.current) {
295
298
  return;
296
299
  }
300
+ console.log('handleTouchMove');
301
+
297
302
  const { pageX, pageY } = event.touches[0];
298
303
  const deltaX = touchX.current - pageX;
299
304
  const deltaY = autoHeight ? 0 : touchY.current - pageY;
@@ -333,6 +338,7 @@ const useScrollListener = (props: ScrollListenerProps) => {
333
338
  if (!isTouching.current) {
334
339
  return;
335
340
  }
341
+ console.log('handleTouchEnd');
336
342
  isTouching.current = false;
337
343
  const touchDuration = new Date().getTime() - momentumStartTime.current;
338
344
  const absDeltaY = Math.abs(scrollY.current - momentumStartY.current);
@@ -521,12 +527,14 @@ const useScrollListener = (props: ScrollListenerProps) => {
521
527
 
522
528
  return {
523
529
  isScrolling,
530
+ isChildFocused,
524
531
  onScrollHorizontal,
525
532
  onScrollVertical,
526
533
  onScrollBody,
527
534
  onScrollTop,
528
535
  onScrollLeft,
529
- onScrollTo
536
+ onScrollTo,
537
+ setIsChildFocused
530
538
  };
531
539
  };
532
540