@bento-core/table 1.0.1-ins.7 → 1.0.1-ins.9
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/dist/body/DefaultThemConfig.js +1 -1
- package/dist/body/DisplayBodyCell.js +6 -0
- package/dist/body/components/ConditionalExternalLinkView.js +51 -0
- package/dist/util/Types.js +4 -1
- package/package.json +1 -1
- package/src/body/DefaultThemConfig.js +1 -1
- package/src/body/DisplayBodyCell.js +8 -0
- package/src/body/components/ConditionalExternalLinkView.js +43 -0
- package/src/util/Types.js +2 -0
|
@@ -9,6 +9,7 @@ var _core = require("@material-ui/core");
|
|
|
9
9
|
var _Types = require("../util/Types");
|
|
10
10
|
var _CustomLinkView = _interopRequireDefault(require("./components/CustomLinkView"));
|
|
11
11
|
var _ExternalLinkView = _interopRequireDefault(require("./components/ExternalLinkView"));
|
|
12
|
+
var _ConditionalExternalLinkView = _interopRequireDefault(require("./components/ConditionalExternalLinkView"));
|
|
12
13
|
var _DataFormatView = _interopRequireDefault(require("./components/DataFormatView"));
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -61,6 +62,11 @@ const ViewCell = _ref2 => {
|
|
|
61
62
|
row: row,
|
|
62
63
|
column: column
|
|
63
64
|
});
|
|
65
|
+
case _Types.cellTypes.CONDITIONAL_EXTERNAL_LINK:
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_ConditionalExternalLinkView.default, {
|
|
67
|
+
row: row,
|
|
68
|
+
column: column
|
|
69
|
+
});
|
|
64
70
|
case _Types.cellTypes.CUSTOM_ELEM:
|
|
65
71
|
return /*#__PURE__*/_react.default.createElement(CustomComponent, {
|
|
66
72
|
row: row,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _core = require("@material-ui/core");
|
|
9
|
+
var _Types = require("../../util/Types");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
/* eslint-disable no-console */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Conditional External Link component
|
|
15
|
+
*/
|
|
16
|
+
const ConditionalExternalLinkView = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
column,
|
|
19
|
+
row
|
|
20
|
+
} = _ref;
|
|
21
|
+
const {
|
|
22
|
+
rootPath,
|
|
23
|
+
pathParams
|
|
24
|
+
} = column === null || column === void 0 ? void 0 : column.linkAttr;
|
|
25
|
+
const url = pathParams.map(attr => {
|
|
26
|
+
if (!rootPath) {
|
|
27
|
+
return row[attr];
|
|
28
|
+
}
|
|
29
|
+
return "".concat(rootPath, "/").concat(row[attr]);
|
|
30
|
+
});
|
|
31
|
+
const externalLinkIcon = {
|
|
32
|
+
src: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/bento/images/icons/svgs/externalLinkIcon.svg',
|
|
33
|
+
alt: 'External link icon'
|
|
34
|
+
};
|
|
35
|
+
return !url[0] || url[0] === '' ? '' : /*#__PURE__*/_react.default.createElement(_core.Link, {
|
|
36
|
+
href: url,
|
|
37
|
+
target: "_blank",
|
|
38
|
+
rel: "noopener noreferrer",
|
|
39
|
+
className: _Types.cellTypes.LINK
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Typography, null, row[column === null || column === void 0 ? void 0 : column.dataField], /*#__PURE__*/_react.default.createElement("img", {
|
|
41
|
+
src: externalLinkIcon.src,
|
|
42
|
+
alt: externalLinkIcon.alt,
|
|
43
|
+
style: {
|
|
44
|
+
width: '16px',
|
|
45
|
+
verticalAlign: 'sub',
|
|
46
|
+
marginLeft: '4px'
|
|
47
|
+
}
|
|
48
|
+
})));
|
|
49
|
+
};
|
|
50
|
+
var _default = ConditionalExternalLinkView;
|
|
51
|
+
exports.default = _default;
|
package/dist/util/Types.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.actionCellTypes = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXTERNAL_LINK = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CHECKBOX = void 0;
|
|
6
|
+
exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.actionCellTypes = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXTERNAL_LINK = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CONDITIONAL_EXTERNAL_LINK = exports.CHECKBOX = void 0;
|
|
7
7
|
const CHECKBOX = 'CHECKBOX';
|
|
8
8
|
exports.CHECKBOX = CHECKBOX;
|
|
9
9
|
const DELETE = 'DELETE';
|
|
@@ -14,6 +14,8 @@ const LINK = 'LINK';
|
|
|
14
14
|
exports.LINK = LINK;
|
|
15
15
|
const EXTERNAL_LINK = 'EXTERNAL_LINK';
|
|
16
16
|
exports.EXTERNAL_LINK = EXTERNAL_LINK;
|
|
17
|
+
const CONDITIONAL_EXTERNAL_LINK = 'CONDITIONAL_EXTERNAL_LINK';
|
|
18
|
+
exports.CONDITIONAL_EXTERNAL_LINK = CONDITIONAL_EXTERNAL_LINK;
|
|
17
19
|
const DISPLAY = 'DISPLAY';
|
|
18
20
|
exports.DISPLAY = DISPLAY;
|
|
19
21
|
const DEFAULT = 'DEFAULT';
|
|
@@ -26,6 +28,7 @@ const cellTypes = {
|
|
|
26
28
|
CUSTOM_ELEM,
|
|
27
29
|
LINK,
|
|
28
30
|
EXTERNAL_LINK,
|
|
31
|
+
CONDITIONAL_EXTERNAL_LINK,
|
|
29
32
|
DISPLAY,
|
|
30
33
|
CHECKBOX,
|
|
31
34
|
DELETE,
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { cellTypes } from '../util/Types';
|
|
7
7
|
import CustomLinkView from './components/CustomLinkView';
|
|
8
8
|
import ExternalLinkView from './components/ExternalLinkView';
|
|
9
|
+
import ConditionalExternalLinkView from './components/ConditionalExternalLinkView';
|
|
9
10
|
import DataFormatView from './components/DataFormatView';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -54,6 +55,13 @@ const ViewCell = ({
|
|
|
54
55
|
column={column}
|
|
55
56
|
/>
|
|
56
57
|
);
|
|
58
|
+
case cellTypes.CONDITIONAL_EXTERNAL_LINK:
|
|
59
|
+
return (
|
|
60
|
+
<ConditionalExternalLinkView
|
|
61
|
+
row={row}
|
|
62
|
+
column={column}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
57
65
|
case cellTypes.CUSTOM_ELEM:
|
|
58
66
|
return (
|
|
59
67
|
<CustomComponent
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Link, Typography,
|
|
5
|
+
} from '@material-ui/core';
|
|
6
|
+
import { cellTypes } from '../../util/Types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Conditional External Link component
|
|
10
|
+
*/
|
|
11
|
+
const ConditionalExternalLinkView = ({
|
|
12
|
+
column,
|
|
13
|
+
row,
|
|
14
|
+
}) => {
|
|
15
|
+
const { rootPath, pathParams } = column?.linkAttr;
|
|
16
|
+
const url = pathParams.map((attr) => {
|
|
17
|
+
if (!rootPath) {
|
|
18
|
+
return row[attr];
|
|
19
|
+
}
|
|
20
|
+
return `${rootPath}/`.concat(row[attr]);
|
|
21
|
+
});
|
|
22
|
+
const externalLinkIcon = {
|
|
23
|
+
src: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/bento/images/icons/svgs/externalLinkIcon.svg',
|
|
24
|
+
alt: 'External link icon',
|
|
25
|
+
};
|
|
26
|
+
return (
|
|
27
|
+
!url[0] || url[0] === '' ? ''
|
|
28
|
+
: (
|
|
29
|
+
<Link href={url} target="_blank" rel="noopener noreferrer" className={cellTypes.LINK}>
|
|
30
|
+
<Typography>
|
|
31
|
+
{row[column?.dataField]}
|
|
32
|
+
<img
|
|
33
|
+
src={externalLinkIcon.src}
|
|
34
|
+
alt={externalLinkIcon.alt}
|
|
35
|
+
style={{ width: '16px', verticalAlign: 'sub', marginLeft: '4px' }}
|
|
36
|
+
/>
|
|
37
|
+
</Typography>
|
|
38
|
+
</Link>
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default ConditionalExternalLinkView;
|
package/src/util/Types.js
CHANGED
|
@@ -3,6 +3,7 @@ export const DELETE = 'DELETE';
|
|
|
3
3
|
export const CUSTOM_ELEM = 'CUSTOM_ELEM';
|
|
4
4
|
export const LINK = 'LINK';
|
|
5
5
|
export const EXTERNAL_LINK = 'EXTERNAL_LINK';
|
|
6
|
+
export const CONDITIONAL_EXTERNAL_LINK = 'CONDITIONAL_EXTERNAL_LINK';
|
|
6
7
|
export const DISPLAY = 'DISPLAY';
|
|
7
8
|
export const DEFAULT = 'DEFAULT';
|
|
8
9
|
export const FORMAT_DATA = 'FORMAT_DATA';
|
|
@@ -12,6 +13,7 @@ export const cellTypes = {
|
|
|
12
13
|
CUSTOM_ELEM,
|
|
13
14
|
LINK,
|
|
14
15
|
EXTERNAL_LINK,
|
|
16
|
+
CONDITIONAL_EXTERNAL_LINK,
|
|
15
17
|
DISPLAY,
|
|
16
18
|
CHECKBOX,
|
|
17
19
|
DELETE,
|