qbs-react-grid 1.1.36 → 1.1.37

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.
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["rowData", "onChange", "checkedKeys", "dataKey", "dataTheme"],
4
4
  _excluded2 = ["rowData", "dataKey", "expandedRowKeys", "onChange"],
5
- _excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "type", "path", "link"],
5
+ _excluded3 = ["rowData", "renderCell", "toolTip", "hideLink", "dataKey", "onChange", "rowClick", "type", "path", "link"],
6
6
  _excluded4 = ["rowData", "getToolTip", "dataKey", "onChange", "rowClick", "getIcon", "path", "link"];
7
7
  import React, { useRef, useState } from 'react';
8
8
  import { Link } from 'react-router-dom';
@@ -80,6 +80,7 @@ export var CustomTableCell = /*#__PURE__*/React.memo(function (_ref4) {
80
80
  var rowData = _ref4.rowData,
81
81
  renderCell = _ref4.renderCell,
82
82
  toolTip = _ref4.toolTip,
83
+ hideLink = _ref4.hideLink,
83
84
  dataKey = _ref4.dataKey,
84
85
  onChange = _ref4.onChange,
85
86
  rowClick = _ref4.rowClick,
@@ -89,12 +90,12 @@ export var CustomTableCell = /*#__PURE__*/React.memo(function (_ref4) {
89
90
  props = _objectWithoutPropertiesLoose(_ref4, _excluded3);
90
91
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Cell, _extends({}, props, {
91
92
  dataKey: dataKey
92
- }), link && !path ? /*#__PURE__*/React.createElement("a", {
93
+ }), link && !path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/React.createElement("a", {
93
94
  onClick: function onClick() {
94
95
  return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
95
96
  },
96
97
  className: "qbs-table-row-link"
97
- }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : handleCellFormat(rowData[dataKey], type)) : path ? /*#__PURE__*/React.createElement(Link, {
98
+ }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : handleCellFormat(rowData[dataKey], type)) : path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/React.createElement(Link, {
98
99
  to: (_path = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path : '',
99
100
  className: "qbs-table-row-link"
100
101
  }, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : handleCellFormat(rowData[dataKey], type)) : /*#__PURE__*/React.createElement(React.Fragment, null, renderCell ? (_renderCell3 = renderCell(rowData)) === null || _renderCell3 === void 0 ? void 0 : _renderCell3.cell : handleCellFormat(rowData[dataKey], type))));
@@ -320,7 +320,8 @@ var QbsTable = function QbsTable(_ref) {
320
320
  getPath = _ref3.getPath,
321
321
  rowClick = _ref3.rowClick,
322
322
  sortKey = _ref3.sortKey,
323
- type = _ref3.type;
323
+ type = _ref3.type,
324
+ hideLink = _ref3.hideLink;
324
325
  return /*#__PURE__*/React.createElement(React.Fragment, null, isVisible && /*#__PURE__*/React.createElement(React.Fragment, null, grouped ? /*#__PURE__*/React.createElement(ColumnGroup, {
325
326
  header: groupHeader,
326
327
  fixed: fixed,
@@ -372,6 +373,7 @@ var QbsTable = function QbsTable(_ref) {
372
373
  dataKey: field,
373
374
  rowClick: rowClick,
374
375
  type: type,
376
+ hideLink: hideLink,
375
377
  path: getPath,
376
378
  dataTheme: dataTheme,
377
379
  link: link
@@ -19,6 +19,7 @@ export interface ColumnBase {
19
19
  sortKey?: string;
20
20
  type?: string;
21
21
  getPath?: (data: any) => string;
22
+ hideLink?: (data: any) => boolean;
22
23
  }
23
24
  export interface QbsColumnProps extends ColumnBase {
24
25
  grouped?: boolean;
@@ -12,7 +12,7 @@ var _handleFormatCell = require("./utilities/handleFormatCell");
12
12
  var _menuDropDown = _interopRequireDefault(require("./utilities/menuDropDown"));
13
13
  var _excluded = ["rowData", "onChange", "checkedKeys", "dataKey", "dataTheme"],
14
14
  _excluded2 = ["rowData", "dataKey", "expandedRowKeys", "onChange"],
15
- _excluded3 = ["rowData", "renderCell", "toolTip", "dataKey", "onChange", "rowClick", "type", "path", "link"],
15
+ _excluded3 = ["rowData", "renderCell", "toolTip", "hideLink", "dataKey", "onChange", "rowClick", "type", "path", "link"],
16
16
  _excluded4 = ["rowData", "getToolTip", "dataKey", "onChange", "rowClick", "getIcon", "path", "link"];
17
17
  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); }
18
18
  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; }
@@ -90,6 +90,7 @@ var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
90
90
  var rowData = _ref4.rowData,
91
91
  renderCell = _ref4.renderCell,
92
92
  toolTip = _ref4.toolTip,
93
+ hideLink = _ref4.hideLink,
93
94
  dataKey = _ref4.dataKey,
94
95
  onChange = _ref4.onChange,
95
96
  rowClick = _ref4.rowClick,
@@ -99,12 +100,12 @@ var CustomTableCell = /*#__PURE__*/_react["default"].memo(function (_ref4) {
99
100
  props = (0, _objectWithoutPropertiesLoose2["default"])(_ref4, _excluded3);
100
101
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Cell["default"], (0, _extends2["default"])({}, props, {
101
102
  dataKey: dataKey
102
- }), link && !path ? /*#__PURE__*/_react["default"].createElement("a", {
103
+ }), link && !path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/_react["default"].createElement("a", {
103
104
  onClick: function onClick() {
104
105
  return rowClick === null || rowClick === void 0 ? void 0 : rowClick(rowData);
105
106
  },
106
107
  className: "qbs-table-row-link"
107
- }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : path ? /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, {
108
+ }, renderCell ? (_renderCell = renderCell(rowData)) === null || _renderCell === void 0 ? void 0 : _renderCell.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : path && !(hideLink !== null && hideLink !== void 0 && hideLink(rowData)) ? /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Link, {
108
109
  to: (_path = path === null || path === void 0 ? void 0 : path(rowData)) != null ? _path : '',
109
110
  className: "qbs-table-row-link"
110
111
  }, renderCell ? (_renderCell2 = renderCell(rowData)) === null || _renderCell2 === void 0 ? void 0 : _renderCell2.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, renderCell ? (_renderCell3 = renderCell(rowData)) === null || _renderCell3 === void 0 ? void 0 : _renderCell3.cell : (0, _handleFormatCell.handleCellFormat)(rowData[dataKey], type))));
@@ -326,7 +326,8 @@ var QbsTable = function QbsTable(_ref) {
326
326
  getPath = _ref3.getPath,
327
327
  rowClick = _ref3.rowClick,
328
328
  sortKey = _ref3.sortKey,
329
- type = _ref3.type;
329
+ type = _ref3.type,
330
+ hideLink = _ref3.hideLink;
330
331
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isVisible && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, grouped ? /*#__PURE__*/_react["default"].createElement(_ColumnGroup["default"], {
331
332
  header: groupHeader,
332
333
  fixed: fixed,
@@ -378,6 +379,7 @@ var QbsTable = function QbsTable(_ref) {
378
379
  dataKey: field,
379
380
  rowClick: rowClick,
380
381
  type: type,
382
+ hideLink: hideLink,
381
383
  path: getPath,
382
384
  dataTheme: dataTheme,
383
385
  link: link
@@ -19,6 +19,7 @@ export interface ColumnBase {
19
19
  sortKey?: string;
20
20
  type?: string;
21
21
  getPath?: (data: any) => string;
22
+ hideLink?: (data: any) => boolean;
22
23
  }
23
24
  export interface QbsColumnProps extends ColumnBase {
24
25
  grouped?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qbs-react-grid",
3
- "version": "1.1.36",
3
+ "version": "1.1.37",
4
4
  "description": "A React table component",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -65,15 +65,27 @@ export const ExpandCell: React.FC<any> = React.memo(
65
65
  )
66
66
  );
67
67
  export const CustomTableCell: React.FC<any> = React.memo(
68
- ({ rowData, renderCell, toolTip, dataKey, onChange, rowClick, type, path, link, ...props }) => {
68
+ ({
69
+ rowData,
70
+ renderCell,
71
+ toolTip,
72
+ hideLink,
73
+ dataKey,
74
+ onChange,
75
+ rowClick,
76
+ type,
77
+ path,
78
+ link,
79
+ ...props
80
+ }) => {
69
81
  return (
70
82
  <>
71
83
  <Cell {...props} dataKey={dataKey}>
72
- {link && !path ? (
84
+ {link && !path && !hideLink?.(rowData) ? (
73
85
  <a onClick={() => rowClick?.(rowData)} className="qbs-table-row-link">
74
86
  {renderCell ? renderCell(rowData)?.cell : handleCellFormat(rowData[dataKey], type)}
75
87
  </a>
76
- ) : path ? (
88
+ ) : path && !hideLink?.(rowData) ? (
77
89
  <Link to={path?.(rowData) ?? ''} className="qbs-table-row-link">
78
90
  {renderCell ? renderCell(rowData)?.cell : handleCellFormat(rowData[dataKey], type)}
79
91
  </Link>
@@ -7,13 +7,7 @@ import HeaderCell from '../HeaderCell';
7
7
  import Pagination from '../Pagination';
8
8
  import Table from '../Table';
9
9
  import { QbsColumnProps, QbsTableProps } from './commontypes';
10
- import {
11
- ActionCell,
12
- CheckCell,
13
- CustomRowStatus,
14
- CustomTableCell,
15
- ExpandCell
16
- } from './CustomTableCell';
10
+ import { ActionCell, CheckCell, CustomRowStatus, CustomTableCell, ExpandCell } from './CustomTableCell';
17
11
  import ToolBar from './Toolbar';
18
12
  import ColumToggle from './utilities/ColumShowHide';
19
13
  import debounce from './utilities/debounce';
@@ -321,7 +315,8 @@ const QbsTable: React.FC<QbsTableProps> = ({
321
315
  getPath,
322
316
  rowClick,
323
317
  sortKey,
324
- type
318
+ type,
319
+ hideLink
325
320
  }) => (
326
321
  <>
327
322
  {isVisible && (
@@ -397,6 +392,7 @@ const QbsTable: React.FC<QbsTableProps> = ({
397
392
  dataKey={field}
398
393
  rowClick={rowClick}
399
394
  type={type}
395
+ hideLink={hideLink}
400
396
  path={getPath}
401
397
  dataTheme={dataTheme}
402
398
  link={link}
@@ -20,6 +20,7 @@ export interface ColumnBase {
20
20
  sortKey?: string;
21
21
  type?: string;
22
22
  getPath?: (data: any) => string;
23
+ hideLink?:(data:any)=>boolean
23
24
  }
24
25
 
25
26
  export interface QbsColumnProps extends ColumnBase {