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