qbs-react-grid 1.0.49 → 1.0.51

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.
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react';
2
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import Cell from '../Cell';
4
4
  import Column from '../Column';
5
5
  import ColumnGroup from '../ColumnGroup';
@@ -10,9 +10,9 @@ import { ActionCell, CheckCell, CustomTableCell, ExpandCell } from './CustomTabl
10
10
  import ToolBar from './Toolbar';
11
11
  import ColumToggle from './utilities/ColumShowHide';
12
12
  import debounce from './utilities/debounce';
13
+ import { deepEqual } from './utilities/deepEqual';
13
14
  import { SettingsIcon } from './utilities/icons';
14
15
  import '../../dist/css/qbs-react-grid.css';
15
- import { deepEqual } from './utilities/deepEqual';
16
16
  var CHECKBOX_LINE_HEIGHT = '36px';
17
17
  var COLUMN_WIDTH = 250;
18
18
  var QbsTable = function QbsTable(_ref) {
@@ -186,7 +186,8 @@ var QbsTable = function QbsTable(_ref) {
186
186
  tableHeaderActions: tableHeaderActions,
187
187
  selectedRowActions: selectedRowActions,
188
188
  onSelect: handleClear,
189
- handleColumnToggle: handleColumnToggle
189
+ handleColumnToggle: handleColumnToggle,
190
+ dataLength: data === null || data === void 0 ? void 0 : data.length
190
191
  };
191
192
  var themeToggle = useMemo(function () {
192
193
  return document.getElementById('themeToggle');
@@ -258,6 +259,9 @@ var QbsTable = function QbsTable(_ref) {
258
259
  });
259
260
  setColumns(reColumns);
260
261
  }, [columns]);
262
+ useEffect(function () {
263
+ setColumns(propColumn);
264
+ }, [propColumn]);
261
265
  useEffect(function () {
262
266
  if (!deepEqual(columns, prevColumns.current)) {
263
267
  handleColumnsResizable();
@@ -18,7 +18,8 @@ var ToolBar = function ToolBar(_ref) {
18
18
  tableHeaderActions = _ref.tableHeaderActions,
19
19
  selectedRowActions = _ref.selectedRowActions,
20
20
  checkedKeys = _ref.checkedKeys,
21
- onSelect = _ref.onSelect;
21
+ onSelect = _ref.onSelect,
22
+ dataLength = _ref.dataLength;
22
23
  var debouncedOnSearch = useCallback(debounce(onSearch != null ? onSearch : function () {}, 1000), [onSearch]);
23
24
  var handleSearch = useCallback(function (e) {
24
25
  if (debouncedOnSearch) {
@@ -84,7 +85,7 @@ var ToolBar = function ToolBar(_ref) {
84
85
  return actions === null || actions === void 0 ? void 0 : actions.action(checkedKeys);
85
86
  }
86
87
  }, actions.actionTitle));
87
- }))) : /*#__PURE__*/React.createElement("div", null, pagination && paginationProps && /*#__PURE__*/React.createElement("div", {
88
+ }))) : /*#__PURE__*/React.createElement("div", null, pagination && paginationProps && dataLength > 0 && /*#__PURE__*/React.createElement("div", {
88
89
  className: "rows-count"
89
90
  }, getRowDisplayRange((_paginationProps$tota = paginationProps.total) != null ? _paginationProps$tota : 0, (_paginationProps$rows = paginationProps.rowsPerPage) != null ? _paginationProps$rows : 0, (_paginationProps$curr = paginationProps.currentPage) != null ? _paginationProps$curr : 0)))));
90
91
  };
@@ -114,6 +114,7 @@ export interface QbsTableToolbarProps {
114
114
  tableHeaderActions?: ReactElement | ReactNode;
115
115
  onSelect?: (keys: any[]) => void;
116
116
  handleColumnToggle?: (columns: QbsColumnProps[]) => void;
117
+ dataLength: number;
117
118
  selectedRowActions?: {
118
119
  actionTitle?: string;
119
120
  action: (checked: (number | string)[]) => void;
@@ -15,9 +15,9 @@ var _CustomTableCell = require("./CustomTableCell");
15
15
  var _Toolbar = _interopRequireDefault(require("./Toolbar"));
16
16
  var _ColumShowHide = _interopRequireDefault(require("./utilities/ColumShowHide"));
17
17
  var _debounce = _interopRequireDefault(require("./utilities/debounce"));
18
+ var _deepEqual = require("./utilities/deepEqual");
18
19
  var _icons = require("./utilities/icons");
19
20
  require("../../dist/css/qbs-react-grid.css");
20
- var _deepEqual = require("./utilities/deepEqual");
21
21
  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); }
22
22
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
23
  var CHECKBOX_LINE_HEIGHT = '36px';
@@ -193,7 +193,8 @@ var QbsTable = function QbsTable(_ref) {
193
193
  tableHeaderActions: tableHeaderActions,
194
194
  selectedRowActions: selectedRowActions,
195
195
  onSelect: handleClear,
196
- handleColumnToggle: handleColumnToggle
196
+ handleColumnToggle: handleColumnToggle,
197
+ dataLength: data === null || data === void 0 ? void 0 : data.length
197
198
  };
198
199
  var themeToggle = (0, _react.useMemo)(function () {
199
200
  return document.getElementById('themeToggle');
@@ -265,6 +266,9 @@ var QbsTable = function QbsTable(_ref) {
265
266
  });
266
267
  setColumns(reColumns);
267
268
  }, [columns]);
269
+ (0, _react.useEffect)(function () {
270
+ setColumns(propColumn);
271
+ }, [propColumn]);
268
272
  (0, _react.useEffect)(function () {
269
273
  if (!(0, _deepEqual.deepEqual)(columns, prevColumns.current)) {
270
274
  handleColumnsResizable();
@@ -25,7 +25,8 @@ var ToolBar = function ToolBar(_ref) {
25
25
  tableHeaderActions = _ref.tableHeaderActions,
26
26
  selectedRowActions = _ref.selectedRowActions,
27
27
  checkedKeys = _ref.checkedKeys,
28
- onSelect = _ref.onSelect;
28
+ onSelect = _ref.onSelect,
29
+ dataLength = _ref.dataLength;
29
30
  var debouncedOnSearch = (0, _react.useCallback)((0, _debounce["default"])(onSearch != null ? onSearch : function () {}, 1000), [onSearch]);
30
31
  var handleSearch = (0, _react.useCallback)(function (e) {
31
32
  if (debouncedOnSearch) {
@@ -91,7 +92,7 @@ var ToolBar = function ToolBar(_ref) {
91
92
  return actions === null || actions === void 0 ? void 0 : actions.action(checkedKeys);
92
93
  }
93
94
  }, actions.actionTitle));
94
- }))) : /*#__PURE__*/_react["default"].createElement("div", null, pagination && paginationProps && /*#__PURE__*/_react["default"].createElement("div", {
95
+ }))) : /*#__PURE__*/_react["default"].createElement("div", null, pagination && paginationProps && dataLength > 0 && /*#__PURE__*/_react["default"].createElement("div", {
95
96
  className: "rows-count"
96
97
  }, (0, _tablecalc.getRowDisplayRange)((_paginationProps$tota = paginationProps.total) != null ? _paginationProps$tota : 0, (_paginationProps$rows = paginationProps.rowsPerPage) != null ? _paginationProps$rows : 0, (_paginationProps$curr = paginationProps.currentPage) != null ? _paginationProps$curr : 0)))));
97
98
  };
@@ -114,6 +114,7 @@ export interface QbsTableToolbarProps {
114
114
  tableHeaderActions?: ReactElement | ReactNode;
115
115
  onSelect?: (keys: any[]) => void;
116
116
  handleColumnToggle?: (columns: QbsColumnProps[]) => void;
117
+ dataLength: number;
117
118
  selectedRowActions?: {
118
119
  actionTitle?: string;
119
120
  action: (checked: (number | string)[]) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
 
3
3
  import Cell from '../Cell';
4
4
  import Column from '../Column';
@@ -11,10 +11,10 @@ import { ActionCell, CheckCell, CustomTableCell, ExpandCell } from './CustomTabl
11
11
  import ToolBar from './Toolbar';
12
12
  import ColumToggle from './utilities/ColumShowHide';
13
13
  import debounce from './utilities/debounce';
14
+ import { deepEqual } from './utilities/deepEqual';
14
15
  import { SettingsIcon } from './utilities/icons';
15
16
 
16
17
  import '../../dist/css/qbs-react-grid.css';
17
- import { deepEqual } from './utilities/deepEqual';
18
18
 
19
19
  const CHECKBOX_LINE_HEIGHT = '36px';
20
20
  const COLUMN_WIDTH = 250;
@@ -172,7 +172,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
172
172
  tableHeaderActions: tableHeaderActions,
173
173
  selectedRowActions: selectedRowActions,
174
174
  onSelect: handleClear,
175
- handleColumnToggle: handleColumnToggle
175
+ handleColumnToggle: handleColumnToggle,
176
+ dataLength: data?.length
176
177
  };
177
178
  const themeToggle = useMemo(() => document.getElementById('themeToggle') as HTMLInputElement, []);
178
179
 
@@ -246,6 +247,10 @@ const QbsTable: React.FC<QbsTableProps> = ({
246
247
  setColumns(reColumns);
247
248
  }, [columns]);
248
249
 
250
+ useEffect(() => {
251
+ setColumns(propColumn);
252
+ }, [propColumn]);
253
+
249
254
  useEffect(() => {
250
255
  if (!deepEqual(columns, prevColumns.current)) {
251
256
  handleColumnsResizable();
@@ -19,7 +19,8 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
19
19
  tableHeaderActions,
20
20
  selectedRowActions,
21
21
  checkedKeys,
22
- onSelect
22
+ onSelect,
23
+ dataLength
23
24
  }) => {
24
25
  const debouncedOnSearch = useCallback(debounce(onSearch ?? (() => {}), 1000), [onSearch]);
25
26
 
@@ -99,7 +100,7 @@ const ToolBar: React.FC<QbsTableToolbarProps> = ({
99
100
  </div>
100
101
  ) : (
101
102
  <div>
102
- {pagination && paginationProps && (
103
+ {pagination && paginationProps && dataLength > 0 && (
103
104
  <div className="rows-count">
104
105
  {getRowDisplayRange(
105
106
  paginationProps.total ?? 0,
@@ -118,6 +118,7 @@ export interface QbsTableToolbarProps {
118
118
  tableHeaderActions?: ReactElement | ReactNode;
119
119
  onSelect?: (keys: any[]) => void;
120
120
  handleColumnToggle?: (columns: QbsColumnProps[]) => void;
121
+ dataLength: number;
121
122
  selectedRowActions?: {
122
123
  actionTitle?: string;
123
124
  action: (checked: (number | string)[]) => void;