qbs-react-grid 1.1.18 → 1.1.19

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.js CHANGED
@@ -8,7 +8,7 @@ import debounce from 'lodash/debounce';
8
8
  import flatten from 'lodash/flatten';
9
9
  import isFunction from 'lodash/isFunction';
10
10
  import PropTypes from 'prop-types';
11
- import React, { useCallback, useImperativeHandle, useReducer, useRef, useState } from 'react';
11
+ import React, { useCallback, useImperativeHandle, useReducer, useRef, useState, useEffect } from 'react';
12
12
  import CellGroup from './CellGroup';
13
13
  import { CELL_PADDING_HEIGHT, EXPANDED_KEY, ROW_HEADER_HEIGHT, ROW_HEIGHT, SCROLLBAR_WIDTH, SORT_TYPE, TREE_DEPTH } from './constants';
14
14
  import EmptyMessage from './EmptyMessage';
@@ -617,6 +617,9 @@ var Table = /*#__PURE__*/React.forwardRef(function (props, ref) {
617
617
  var _useState2 = useState(Array(data === null || data === void 0 ? void 0 : data.length).fill(1)),
618
618
  rowZIndices = _useState2[0],
619
619
  setRowZIndices = _useState2[1];
620
+ useEffect(function () {
621
+ if ((data === null || data === void 0 ? void 0 : data.length) > 0) setRowZIndices(Array(data === null || data === void 0 ? void 0 : data.length).fill(1));
622
+ }, [data]);
620
623
  var handleParentCallBack = function handleParentCallBack(index) {
621
624
  setRowZIndices(function (currentZIndices) {
622
625
  return currentZIndices.map(function (_, idx) {
File without changes
File without changes
package/lib/Table.js CHANGED
@@ -624,6 +624,9 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
624
624
  var _useState2 = (0, _react.useState)(Array(data === null || data === void 0 ? void 0 : data.length).fill(1)),
625
625
  rowZIndices = _useState2[0],
626
626
  setRowZIndices = _useState2[1];
627
+ (0, _react.useEffect)(function () {
628
+ if ((data === null || data === void 0 ? void 0 : data.length) > 0) setRowZIndices(Array(data === null || data === void 0 ? void 0 : data.length).fill(1));
629
+ }, [data]);
627
630
  var handleParentCallBack = function handleParentCallBack(index) {
628
631
  setRowZIndices(function (currentZIndices) {
629
632
  return currentZIndices.map(function (_, idx) {
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
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,7 +49,6 @@ 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
-
53
52
  return (
54
53
  <div
55
54
  role="row"
package/src/Table.tsx CHANGED
@@ -3,7 +3,14 @@ import debounce from 'lodash/debounce';
3
3
  import flatten from 'lodash/flatten';
4
4
  import isFunction from 'lodash/isFunction';
5
5
  import PropTypes from 'prop-types';
6
- import React, { useCallback, useImperativeHandle, useReducer, useRef, useState } from 'react';
6
+ import React, {
7
+ useCallback,
8
+ useImperativeHandle,
9
+ useReducer,
10
+ useRef,
11
+ useState,
12
+ useEffect
13
+ } from 'react';
7
14
 
8
15
  import CellGroup from './CellGroup';
9
16
  import {
@@ -851,8 +858,7 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
851
858
  'aria-rowindex': (props.key as number) + 2,
852
859
  rowRef: bindTableRowsRef(props.key as any, rowData),
853
860
  onClick: bindRowClick(rowData),
854
- onContextMenu: bindRowContextMenu(rowData),
855
-
861
+ onContextMenu: bindRowContextMenu(rowData)
856
862
  };
857
863
 
858
864
  const expanded = expandedRowKeys.some(key => rowKey && key === rowData[rowKey]);
@@ -946,7 +952,9 @@ const Table = React.forwardRef(<Row extends RowDataType, Key>(props: TableProps<
946
952
  return scrollbars;
947
953
  };
948
954
  const [rowZIndices, setRowZIndices] = useState(Array(data?.length).fill(1));
949
-
955
+ useEffect(() => {
956
+ if (data?.length > 0) setRowZIndices(Array(data?.length).fill(1));
957
+ }, [data]);
950
958
  const handleParentCallBack = (index: number) => {
951
959
  setRowZIndices(currentZIndices => currentZIndices.map((_, idx) => (idx === index ? 10 : 1)));
952
960
  };
File without changes