@bento-core/table 1.0.1-ins.0 → 1.0.1-ins.2

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,49 @@
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 => {
24
+ if (!rootPath) {
25
+ return row[attr];
26
+ }
27
+ return "".concat(rootPath, "/").concat(row[attr]);
28
+ });
29
+ const externalLinkIcon = {
30
+ src: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/bento/images/icons/svgs/externalLinkIcon.svg',
31
+ alt: 'External link icon'
32
+ };
33
+ return /*#__PURE__*/_react.default.createElement(_core.Link, {
34
+ href: url,
35
+ target: "_blank",
36
+ rel: "noopener noreferrer",
37
+ className: _Types.cellTypes.LINK
38
+ }, /*#__PURE__*/_react.default.createElement(_core.Typography, null, row[column === null || column === void 0 ? void 0 : column.dataField], /*#__PURE__*/_react.default.createElement("img", {
39
+ src: externalLinkIcon.src,
40
+ alt: externalLinkIcon.alt,
41
+ style: {
42
+ width: '16px',
43
+ verticalAlign: 'sub',
44
+ marginLeft: '4px'
45
+ }
46
+ })));
47
+ };
48
+ var _default = ExternalLinkView;
49
+ exports.default = _default;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ins.0",
3
+ "version": "1.0.1-ins.2",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "npm run lint && cross-env-shell rm -rf dist && NODE_ENV=production BABEL_ENV=es babel src --out-dir dist --copy-files",
@@ -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,39 @@
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) => {
16
+ if (!rootPath) {
17
+ return row[attr];
18
+ }
19
+ return `${rootPath}/`.concat(row[attr]);
20
+ });
21
+ const externalLinkIcon = {
22
+ src: 'https://raw.githubusercontent.com/CBIIT/datacommons-assets/main/bento/images/icons/svgs/externalLinkIcon.svg',
23
+ alt: 'External link icon',
24
+ };
25
+ return (
26
+ <Link href={url} target="_blank" rel="noopener noreferrer" className={cellTypes.LINK}>
27
+ <Typography>
28
+ {row[column?.dataField]}
29
+ <img
30
+ src={externalLinkIcon.src}
31
+ alt={externalLinkIcon.alt}
32
+ style={{ width: '16px', verticalAlign: 'sub', marginLeft: '4px' }}
33
+ />
34
+ </Typography>
35
+ </Link>
36
+ );
37
+ };
38
+
39
+ 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,