@bento-core/table 1.0.1-ccdiintegrated.1 → 1.0.1-ccdiintegrated.10

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.
Files changed (47) hide show
  1. package/dist/ExtendedView.js +2 -2
  2. package/dist/TableView.js +3 -1
  3. package/dist/body/DefaultThemConfig.js +1 -1
  4. package/dist/body/DisplayBodyCell.js +6 -2
  5. package/dist/body/components/CPIMappingView.js +2 -2
  6. package/dist/body/components/CPIModal.js +12 -7
  7. package/dist/body/components/CustomLinkView.js +2 -1
  8. package/dist/body/components/DataFormatView.js +1 -1
  9. package/dist/body/components/assets/CPI_Icon_Dataset.svg +3 -3
  10. package/dist/body/components/assets/CPI_Icon_Multi.svg +1 -1
  11. package/dist/body/components/assets/CPI_Icon_Single.svg +1 -1
  12. package/dist/body/components/assets/CPI_Icon_Study.svg +1 -1
  13. package/dist/index.js +18 -0
  14. package/dist/util/Dataformat.js +50 -2
  15. package/dist/util/downloadTable.js +77 -53
  16. package/dist/wrapper/components/AddFiles.js +6 -14
  17. package/dist/wrapper/components/AddToCart/AddToCartView.js +5 -3
  18. package/dist/wrapper/components/AddToCart/ReduxAddToCart.js +1 -0
  19. package/dist/wrapper/components/CPIFilesView/CPIFilesView.js +12 -6
  20. package/dist/wrapper/components/ReduxAddFile.js +1 -0
  21. package/dist/wrapper/components/Snackbar/CartToast.js +96 -0
  22. package/dist/wrapper/components/Snackbar/Snackbar.js +8 -2
  23. package/dist/wrapper/components/Snackbar/SnackbarRedux.js +2 -1
  24. package/package.json +4 -4
  25. package/src/ExtendedView.js +2 -2
  26. package/src/TableView.js +2 -0
  27. package/src/body/DefaultThemConfig.js +1 -1
  28. package/src/body/DisplayBodyCell.js +18 -2
  29. package/src/body/components/CPIMappingView.js +2 -2
  30. package/src/body/components/CPIModal.js +50 -46
  31. package/src/body/components/CustomLinkView.js +4 -1
  32. package/src/body/components/DataFormatView.js +4 -2
  33. package/src/body/components/assets/CPI_Icon_Dataset.svg +3 -3
  34. package/src/body/components/assets/CPI_Icon_Multi.svg +1 -1
  35. package/src/body/components/assets/CPI_Icon_Single.svg +1 -1
  36. package/src/body/components/assets/CPI_Icon_Study.svg +1 -1
  37. package/src/index.js +6 -1
  38. package/src/util/Dataformat.js +47 -0
  39. package/src/util/downloadTable.js +75 -34
  40. package/src/wrapper/components/AddFiles.js +7 -14
  41. package/src/wrapper/components/AddToCart/AddToCartView.js +4 -2
  42. package/src/wrapper/components/AddToCart/ReduxAddToCart.js +1 -0
  43. package/src/wrapper/components/CPIFilesView/CPIFilesView.js +15 -9
  44. package/src/wrapper/components/ReduxAddFile.js +1 -0
  45. package/src/wrapper/components/Snackbar/CartToast.js +99 -0
  46. package/src/wrapper/components/Snackbar/Snackbar.js +8 -4
  47. package/src/wrapper/components/Snackbar/SnackbarRedux.js +2 -1
@@ -67,7 +67,7 @@ const ToolTipView = props => {
67
67
  // };
68
68
  exports.ToolTipView = ToolTipView;
69
69
  const checkDuplicate = (cartFiles, ids) => ids.filter(id => !cartFiles[id]);
70
- const addFileQuery = (0, _graphqlTag.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nquery search ( \n $participant_ids: [String],\n){\n fileIDsFromList ( \n participant_ids: $participant_ids,\n ) \n}\n "])));
70
+ const addFileQuery = (0, _graphqlTag.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\nquery search (\n $pid: [String],\n){\n fileIDsFromList (\n pid: $pid,\n )\n}\n "])));
71
71
  const CPIFilesComponent = props => {
72
72
  const {
73
73
  title,
@@ -82,7 +82,8 @@ const CPIFilesComponent = props => {
82
82
  cartFiles,
83
83
  participantIds,
84
84
  buttonStyle,
85
- rowID
85
+ rowID,
86
+ onOptionClick
86
87
  } = props;
87
88
  /**
88
89
  * conditionally display dialog view
@@ -106,21 +107,26 @@ const CPIFilesComponent = props => {
106
107
  * verify and set file ids
107
108
  */
108
109
  const addAllFiles = () => {
110
+ if (typeof onOptionClick === 'function') {
111
+ onOptionClick();
112
+ }
109
113
  let toAdd = [];
110
114
  if (btnType === 'ADD_ALL_FILES') {
115
+ // Always include the modal participant pid plus any internal CPI-mapped ids.
116
+ toAdd = rowID ? [rowID] : [];
111
117
  participantIds.forEach(e => {
112
118
  if (e.data_type === 'internal' && e.p_id) {
113
119
  toAdd = toAdd.concat(e.p_id);
114
120
  }
115
- toAdd = toAdd.concat(rowID);
116
121
  });
117
122
  } else {
118
- toAdd = participantIds.concat(rowID);
123
+ toAdd = (rowID ? [rowID] : []).concat(participantIds);
119
124
  }
125
+ toAdd = [...new Set(toAdd.filter(id => typeof id === 'string' && id))];
120
126
  const fileIds = (0, _WrapperService.getFilesID)({
121
127
  client,
122
128
  variables: {
123
- participant_ids: toAdd
129
+ pid: toAdd
124
130
  },
125
131
  query: addFileQuery
126
132
  });
@@ -136,7 +142,7 @@ const CPIFilesComponent = props => {
136
142
  setOpen(true);
137
143
  setAddFilesId(ids);
138
144
  } else {
139
- const newIds = checkDuplicate(cartFiles, ids);
145
+ const newIds = checkDuplicate(cartFilesDict, ids);
140
146
  if (cartCount + newIds.length <= upperLimit) {
141
147
  setOpen(true);
142
148
  setAddFilesId(newIds);
@@ -16,6 +16,7 @@ const AddFilesRedux = props => /*#__PURE__*/_react.default.createElement(_AddFil
16
16
  */
17
17
  const mapStateToProps = state => ({
18
18
  count: state.cartReducer && state.cartReducer.count,
19
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount,
19
20
  cartFiles: state.cartReducer && state.cartReducer.filesId
20
21
  });
21
22
  const mapDispatchToProps = dispatch => ({
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactDom = _interopRequireDefault(require("react-dom"));
9
+ var _cart = require("@bento-core/cart");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ 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); }
12
+ 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; }
13
+ /**
14
+ * Explore CPI cart toast.
15
+ * Body portal keeps it visible above the Explore Modal; styling matches the
16
+ * Global Search CPI MUI snackbar. Dropdown closes on option click so the toast
17
+ * does not need width hacks to avoid overlap.
18
+ */
19
+ const SuccessIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
20
+ xmlns: "http://www.w3.org/2000/svg",
21
+ width: "24",
22
+ height: "24",
23
+ viewBox: "0 0 24 24",
24
+ "aria-hidden": "true",
25
+ focusable: "false",
26
+ style: {
27
+ display: 'block',
28
+ fill: 'currentColor'
29
+ }
30
+ }, /*#__PURE__*/_react.default.createElement("path", {
31
+ d: "M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"
32
+ }));
33
+ const CartToast = _ref => {
34
+ let {
35
+ open,
36
+ count,
37
+ alreadyInCartCount = 0,
38
+ onClose
39
+ } = _ref;
40
+ (0, _react.useEffect)(() => {
41
+ if (!open) {
42
+ return undefined;
43
+ }
44
+ const timer = setTimeout(() => {
45
+ onClose();
46
+ }, 3000);
47
+ return () => clearTimeout(timer);
48
+ }, [open, onClose]);
49
+ if (!open || typeof document === 'undefined') {
50
+ return null;
51
+ }
52
+ return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement("div", {
53
+ className: "snackBar exploreCpiCartToast",
54
+ role: "status",
55
+ "aria-live": "polite",
56
+ style: {
57
+ position: 'fixed',
58
+ bottom: '20px',
59
+ right: '24px',
60
+ zIndex: 99999,
61
+ pointerEvents: 'none'
62
+ }
63
+ }, /*#__PURE__*/_react.default.createElement("div", {
64
+ className: "snackBarMessage",
65
+ style: {
66
+ display: 'flex',
67
+ alignItems: 'center',
68
+ backgroundColor: '#323232',
69
+ color: '#fff',
70
+ padding: '6px 16px',
71
+ borderRadius: '4px',
72
+ boxShadow: '0px 3px 5px -1px rgba(0,0,0,0.2), 0px 6px 10px 0px rgba(0,0,0,0.14), 0px 1px 18px 0px rgba(0,0,0,0.12)',
73
+ minWidth: 288,
74
+ maxWidth: 568,
75
+ boxSizing: 'border-box',
76
+ fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
77
+ fontWeight: 400,
78
+ fontSize: '0.875rem',
79
+ lineHeight: 1.43,
80
+ letterSpacing: '0.01071em'
81
+ }
82
+ }, /*#__PURE__*/_react.default.createElement("span", {
83
+ className: "snackBarMessageIcon",
84
+ style: {
85
+ display: 'inline-flex',
86
+ alignItems: 'center',
87
+ marginRight: 8,
88
+ color: '#fff',
89
+ flexShrink: 0
90
+ }
91
+ }, /*#__PURE__*/_react.default.createElement(SuccessIcon, null)), /*#__PURE__*/_react.default.createElement("span", {
92
+ className: "snackBarText"
93
+ }, (0, _cart.formatCartAddMessage)(count, alreadyInCartCount)))), document.body);
94
+ };
95
+ var _default = CartToast;
96
+ exports.default = _default;
@@ -6,11 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _core = require("@material-ui/core");
9
+ var _cart = require("@bento-core/cart");
9
10
  var _SuccessOutlined = _interopRequireDefault(require("./SuccessOutlined"));
10
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ /**
13
+ * Legacy MUI snackbar kept for non-CPI table cart actions.
14
+ * Explore CPI uses CartToast instead.
15
+ */
11
16
  const SnackbarView = props => {
12
17
  const {
13
18
  count,
19
+ alreadyInCartCount = 0,
14
20
  open,
15
21
  onClose
16
22
  } = props;
@@ -29,7 +35,7 @@ const SnackbarView = props => {
29
35
  },
30
36
  style: {
31
37
  bottom: '-45%',
32
- zIndex: '-10000',
38
+ zIndex: 15000,
33
39
  pointerEvents: 'none'
34
40
  },
35
41
  message: /*#__PURE__*/_react.default.createElement("div", {
@@ -38,7 +44,7 @@ const SnackbarView = props => {
38
44
  className: "snackBarMessageIcon"
39
45
  }, /*#__PURE__*/_react.default.createElement(_SuccessOutlined.default, null), ' '), /*#__PURE__*/_react.default.createElement("span", {
40
46
  className: "snackBarText"
41
- }, count, ' ', "File(s) successfully added to your cart"))
47
+ }, (0, _cart.formatCartAddMessage)(count, alreadyInCartCount)))
42
48
  }));
43
49
  };
44
50
  var _default = SnackbarView;
@@ -10,7 +10,8 @@ var _Snackbar = _interopRequireDefault(require("./Snackbar"));
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
11
  const ReduxSnackbar = props => /*#__PURE__*/_react.default.createElement(_Snackbar.default, props);
12
12
  const mapStateToProps = state => ({
13
- count: state.cartReducer.count
13
+ count: state.cartReducer && state.cartReducer.count,
14
+ alreadyInCartCount: state.cartReducer && state.cartReducer.alreadyInCartCount
14
15
  });
15
16
  var _default = (0, _reactRedux.connect)(mapStateToProps, null)(ReduxSnackbar);
16
17
  exports.default = _default;
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@bento-core/table",
3
- "version": "1.0.1-ccdiintegrated.1",
4
- "description": "",
3
+ "version": "1.0.1-ccdiintegrated.10",
5
4
  "homepage": "https://github.com/CBIIT/bento-frontend#readme",
6
5
  "bugs": {
7
6
  "url": "https://github.com/CBIIT/bento-frontend/issues"
@@ -21,7 +20,7 @@
21
20
  },
22
21
  "dependencies": {
23
22
  "@apollo/client": "^3.8.3",
24
- "@bento-core/cart": "1.0.1-ccdiintegrated.1",
23
+ "@bento-core/cart": "1.0.1-ccdiintegrated.2",
25
24
  "@bento-core/tool-tip": "1.0.1-ccdiintegrated.1",
26
25
  "@bento-core/util": "1.0.1-ccdiintegrated.1",
27
26
  "clsx": "^2.1.1",
@@ -39,5 +38,6 @@
39
38
  },
40
39
  "publishConfig": {
41
40
  "access": "public"
42
- }
41
+ },
42
+ "description": ""
43
43
  }
@@ -15,7 +15,7 @@ const downloadAreaStyle = {
15
15
  display: 'flex',
16
16
  justifyContent: 'space-between',
17
17
  alignItems: 'center',
18
- borderTop: '1px solid #8A7F7C',
18
+ borderTop: '3px solid #8A7F7C',
19
19
  paddingRight: '48px',
20
20
  paddingTop: '5px',
21
21
  paddingBottom: '5px',
@@ -25,7 +25,7 @@ const searchBarContainerStyle = {
25
25
  display: 'flex',
26
26
  alignItems: 'center',
27
27
  marginRight: 'auto',
28
- paddingLeft: '18px',
28
+ paddingLeft: '20px',
29
29
  };
30
30
 
31
31
  const getSearchBarWrapperStyle = (isFocused) => ({
package/src/TableView.js CHANGED
@@ -32,6 +32,8 @@ const downloadAreaStyle = {
32
32
  borderTop: '1px solid #8A7F7C',
33
33
  borderBottom: '1px solid #8A7F7C',
34
34
  paddingRight: '48px',
35
+ paddingTop: '5px',
36
+ paddingBottom: '5px',
35
37
  };
36
38
 
37
39
  const cartDownloadAreaStyle = {
@@ -44,7 +44,7 @@ const defaultTheme = () => ({
44
44
  MuiCheckbox: {
45
45
  colorSecondary: {
46
46
  '&.Mui-checked': {
47
- color: '#8DCAFF',
47
+ color: '#6D5F5B',
48
48
  },
49
49
  },
50
50
  root: {
@@ -4,6 +4,11 @@ import {
4
4
  Typography,
5
5
  } from '@material-ui/core';
6
6
  import { cellTypes } from '../util/Types';
7
+ import {
8
+ formatValueForDisplay,
9
+ isBracketStripEnabled,
10
+ stripSurroundingBrackets,
11
+ } from '../util/Dataformat';
7
12
  import CustomLinkView from './components/CustomLinkView';
8
13
  import DataFormatView from './components/DataFormatView';
9
14
  import CPIView from './components/CPIView';
@@ -18,9 +23,18 @@ const CustomComponent = ({
18
23
  column,
19
24
  }) => {
20
25
  const { dataField, customCellRender } = column;
26
+ const raw = row[dataField];
27
+ const value = isBracketStripEnabled(column)
28
+ ? stripSurroundingBrackets(raw)
29
+ : raw;
21
30
  return (
22
31
  <>
23
- {customCellRender({ ...row, ...column, label: row[dataField] })}
32
+ {customCellRender({
33
+ ...row,
34
+ ...column,
35
+ [dataField]: value,
36
+ label: value,
37
+ })}
24
38
  </>
25
39
  );
26
40
  };
@@ -88,7 +102,9 @@ const ViewCell = ({
88
102
  default:
89
103
  return (
90
104
  <Typography>
91
- {row[column.dataField]}
105
+ {isBracketStripEnabled(column)
106
+ ? formatValueForDisplay(row[column.dataField])
107
+ : row[column.dataField]}
92
108
  </Typography>
93
109
  );
94
110
  }
@@ -127,7 +127,7 @@ const CPIMappingView = ({
127
127
  right: rightOffset,
128
128
  bottom: bottomOffset,
129
129
  backgroundColor: 'white',
130
- border: '1.5px solid #07679C',
130
+ border: '1.5px solid #2A6E93',
131
131
  borderRadius: '4px',
132
132
  minWidth: '12px',
133
133
  height: '12px',
@@ -140,7 +140,7 @@ const CPIMappingView = ({
140
140
  fontStyle: 'normal',
141
141
  lineHeight: '16px',
142
142
  letterSpacing: '-0.02em',
143
- color: '#07679C',
143
+ color: '#2A6E93',
144
144
  fontFamily: 'Open Sans',
145
145
  boxShadow,
146
146
  };
@@ -687,7 +687,7 @@ const CPIModal = ({
687
687
  style={viewInExploreButton}
688
688
  onClick={() => {
689
689
  onClose();
690
- navigation(`/explore?p_id=${participantId}&dbgap_accession=${studyId}`);
690
+ navigation(`/exploreParticipants?p_id=${participantId}&dbgap_accession=${studyId}`);
691
691
  }}
692
692
  disableRipple
693
693
  >
@@ -706,52 +706,56 @@ const CPIModal = ({
706
706
  </Button>
707
707
 
708
708
  {dropdownOpen && (
709
- <>
710
- <div
711
- style={{
712
- position: 'fixed',
713
- top: 0,
714
- left: 0,
715
- right: 0,
716
- bottom: 0,
717
- zIndex: 9998,
718
- }}
719
- onClick={() => setDropdownOpen(false)}
720
- />
721
- <div className={classes.dropdown}>
722
- <div className={classes.dropdownList}>
723
- <div className={classes.dropdownItem}>
724
- <AddFileButtonView
725
- {...wrapperConfig.items[0]}
726
- buttonStyle={addAllFilesButton}
727
- rowID={row.id}
728
- />
729
- </div>
730
- <div className={classes.dropdownItem}>
731
- <AddFileButtonView
732
- {...wrapperConfig.items[1]}
733
- buttonStyle={addSelectedFilesButton}
734
- rowID={row.id}
735
- disabled={selectedIds.length === 0}
736
- />
737
- </div>
738
- <div className={classes.dropdownItem}>
739
- <Button
740
- style={goToCartButton}
741
- onClick={() => {
742
- onClose();
743
- setDropdownOpen(false);
744
- navigation('/fileCentricCart');
745
- }}
746
- disableRipple
747
- >
748
- GO TO CART
749
- </Button>
750
- </div>
751
- </div>
752
- </div>
753
- </>
709
+ <div
710
+ style={{
711
+ position: 'fixed',
712
+ top: 0,
713
+ left: 0,
714
+ right: 0,
715
+ bottom: 0,
716
+ zIndex: 1,
717
+ }}
718
+ onClick={() => setDropdownOpen(false)}
719
+ />
754
720
  )}
721
+ {/* Keep cart actions mounted while closed so the success toast is not unmounted. */}
722
+ <div
723
+ className={classes.dropdown}
724
+ style={{ display: dropdownOpen ? 'block' : 'none' }}
725
+ >
726
+ <div className={classes.dropdownList}>
727
+ <div className={classes.dropdownItem}>
728
+ <AddFileButtonView
729
+ {...wrapperConfig.items[0]}
730
+ buttonStyle={addAllFilesButton}
731
+ rowID={row.id}
732
+ onOptionClick={() => setDropdownOpen(false)}
733
+ />
734
+ </div>
735
+ <div className={classes.dropdownItem}>
736
+ <AddFileButtonView
737
+ {...wrapperConfig.items[1]}
738
+ buttonStyle={addSelectedFilesButton}
739
+ rowID={row.id}
740
+ disabled={selectedIds.length === 0}
741
+ onOptionClick={() => setDropdownOpen(false)}
742
+ />
743
+ </div>
744
+ <div className={classes.dropdownItem}>
745
+ <Button
746
+ style={goToCartButton}
747
+ onClick={() => {
748
+ onClose();
749
+ setDropdownOpen(false);
750
+ navigation('/fileCentricCart');
751
+ }}
752
+ disableRipple
753
+ >
754
+ GO TO CART
755
+ </Button>
756
+ </div>
757
+ </div>
758
+ </div>
755
759
  </div>
756
760
  </div>
757
761
  <div className="footer" style={footer}>
@@ -3,6 +3,7 @@ import {
3
3
  Link, Typography,
4
4
  } from '@material-ui/core';
5
5
  import { cellTypes } from '../../util/Types';
6
+ import { formatValueForDisplay, isBracketStripEnabled } from '../../util/Dataformat';
6
7
 
7
8
  /**
8
9
  * Custom Link component
@@ -16,7 +17,9 @@ const CustomLinkView = ({
16
17
  return (
17
18
  <Link href={url} className={cellTypes.LINK}>
18
19
  <Typography>
19
- {row[column?.dataField]}
20
+ {isBracketStripEnabled(column)
21
+ ? formatValueForDisplay(row[column?.dataField])
22
+ : row[column?.dataField]}
20
23
  </Typography>
21
24
  </Link>
22
25
  );
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Typography } from '@material-ui/core';
3
3
  import { dataFormatTypes } from '../../util/Types';
4
- import { formatBytes } from '../../util/Dataformat';
4
+ import { formatBytes, formatValueForDisplay, isBracketStripEnabled } from '../../util/Dataformat';
5
5
 
6
6
  /**
7
7
  * dataformat view for file size (byte, MB, GB)
@@ -23,7 +23,9 @@ const CellView = ({
23
23
  default:
24
24
  return (
25
25
  <Typography>
26
- {value}
26
+ {isBracketStripEnabled(column)
27
+ ? formatValueForDisplay(value)
28
+ : value}
27
29
  </Typography>
28
30
  );
29
31
  }
@@ -1,6 +1,6 @@
1
1
  <svg width="18" height="23" viewBox="0 0 18 23" fill="none" xmlns="http://www.w3.org/2000/svg">
2
2
  <path d="M17.5136 1.7276C17.9317 2.03935 18 2.2645 18 2.36841C18 2.47666 17.9275 2.69748 17.5136 3.00922C17.1083 3.31231 16.4769 3.61107 15.6407 3.87519C13.9725 4.3991 11.626 4.73682 9.00213 4.73682C6.37829 4.73682 4.03176 4.40343 2.36359 3.87519C1.52738 3.61107 0.895947 3.31231 0.490637 3.00922C0.0725288 2.69748 0.00426674 2.47233 0.00426674 2.36841C0.00426674 2.2645 0.0725288 2.04367 0.490637 1.7276C0.895947 1.42451 1.52738 1.12575 2.36359 0.861634C4.03176 0.337726 6.37829 0 9.00213 0C11.626 0 13.9682 0.333396 15.6364 0.861634C16.4726 1.12575 17.1041 1.42451 17.5094 1.7276H17.5136Z" fill="#07679C"/>
3
- <path d="M1.96682 5.16535C3.79711 5.74121 6.28443 6.0876 8.99787 6.0876C11.7113 6.0876 14.1986 5.74121 16.0289 5.16535C16.7926 4.92721 17.4624 4.64144 18 4.30371V8.11828C18 8.22653 17.9275 8.44735 17.5136 8.75909C17.1083 9.06218 16.4769 9.36094 15.6407 9.62506C13.9725 10.149 11.626 10.4867 9.00213 10.4867C6.37829 10.4867 4.03603 10.1533 2.36359 9.62506C1.52738 9.36094 0.895947 9.06218 0.490637 8.75909C0.0725288 8.44735 0.00426674 8.2222 0.00426674 8.11828V4.30371C0.537569 4.64144 1.21166 4.92721 1.97108 5.16535H1.96682ZM3.8867 9.1661C4.54373 9.1661 5.07703 8.62487 5.07703 7.95808C5.07703 7.29129 4.54373 6.75006 3.8867 6.75006C3.22968 6.75006 2.69637 7.29129 2.69637 7.95808C2.69637 8.62487 3.22968 9.1661 3.8867 9.1661Z" fill="#07679C"/>
4
- <path d="M1.96718 10.9153C3.79747 11.4912 6.28479 11.8376 8.99823 11.8376C11.7117 11.8376 14.2033 11.4912 16.0293 10.9153C16.7887 10.6772 17.4628 10.3914 17.9961 10.0537V14.206C17.9961 14.3099 17.9278 14.5307 17.5097 14.8468C17.1044 15.1499 16.473 15.4487 15.6368 15.7128C13.9686 16.2367 11.6221 16.5744 8.99823 16.5744C6.37438 16.5744 4.02785 16.241 2.35969 15.7128C1.52347 15.4487 0.89204 15.1499 0.486731 14.8468C0.0686226 14.5351 0.000360489 14.3099 0.000360489 14.206V10.0537C0.533663 10.3914 1.20775 10.6772 1.96718 10.9153ZM3.88706 15.1109C4.54409 15.1109 5.07739 14.5697 5.07739 13.9029C5.07739 13.2361 4.54409 12.6949 3.88706 12.6949C3.23003 12.6949 2.69673 13.2361 2.69673 13.9029C2.69673 14.5697 3.23003 15.1109 3.88706 15.1109Z" fill="#07679C"/>
5
- <path d="M1.96718 17.0076C3.79747 17.5835 6.28479 17.9299 8.99823 17.9299C11.7117 17.9299 14.199 17.5835 16.0293 17.0076C16.7887 16.7695 17.4628 16.4837 17.9961 16.146V20.636C17.9961 20.7399 17.9278 20.9608 17.5097 21.2768C17.1044 21.5799 16.473 21.8787 15.6368 22.1428C13.9686 22.6667 11.6221 23.0044 8.99823 23.0044C6.37438 23.0044 4.03212 22.671 2.35969 22.1428C1.52347 21.8787 0.89204 21.5799 0.486731 21.2768C0.0686226 20.9651 0.000360489 20.7399 0.000360489 20.636V16.146C0.533663 16.4837 1.20775 16.7695 1.96718 17.0076ZM3.88706 21.056C4.54409 21.056 5.07739 20.5148 5.07739 19.848C5.07739 19.1812 4.54409 18.64 3.88706 18.64C3.23003 18.64 2.69673 19.1812 2.69673 19.848C2.69673 20.5148 3.23003 21.056 3.88706 21.056Z" fill="#07679C"/>
3
+ <path d="M1.96682 5.16535C3.79711 5.74121 6.28443 6.0876 8.99787 6.0876C11.7113 6.0876 14.1986 5.74121 16.0289 5.16535C16.7926 4.92721 17.4624 4.64144 18 4.30371V8.11828C18 8.22653 17.9275 8.44735 17.5136 8.75909C17.1083 9.06218 16.4769 9.36094 15.6407 9.62506C13.9725 10.149 11.626 10.4867 9.00213 10.4867C6.37829 10.4867 4.03603 10.1533 2.36359 9.62506C1.52738 9.36094 0.895947 9.06218 0.490637 8.75909C0.0725288 8.44735 0.00426674 8.2222 0.00426674 8.11828V4.30371C0.537569 4.64144 1.21166 4.92721 1.97108 5.16535H1.96682ZM3.8867 9.1661C4.54373 9.1661 5.07703 8.62487 5.07703 7.95808C5.07703 7.29129 4.54373 6.75006 3.8867 6.75006C3.22968 6.75006 2.69637 7.29129 2.69637 7.95808C2.69637 8.62487 3.22968 9.1661 3.8867 9.1661Z" fill="#2A6E93"/>
4
+ <path d="M1.96718 10.9153C3.79747 11.4912 6.28479 11.8376 8.99823 11.8376C11.7117 11.8376 14.2033 11.4912 16.0293 10.9153C16.7887 10.6772 17.4628 10.3914 17.9961 10.0537V14.206C17.9961 14.3099 17.9278 14.5307 17.5097 14.8468C17.1044 15.1499 16.473 15.4487 15.6368 15.7128C13.9686 16.2367 11.6221 16.5744 8.99823 16.5744C6.37438 16.5744 4.02785 16.241 2.35969 15.7128C1.52347 15.4487 0.89204 15.1499 0.486731 14.8468C0.0686226 14.5351 0.000360489 14.3099 0.000360489 14.206V10.0537C0.533663 10.3914 1.20775 10.6772 1.96718 10.9153ZM3.88706 15.1109C4.54409 15.1109 5.07739 14.5697 5.07739 13.9029C5.07739 13.2361 4.54409 12.6949 3.88706 12.6949C3.23003 12.6949 2.69673 13.2361 2.69673 13.9029C2.69673 14.5697 3.23003 15.1109 3.88706 15.1109Z" fill="#2A6E93"/>
5
+ <path d="M1.96718 17.0076C3.79747 17.5835 6.28479 17.9299 8.99823 17.9299C11.7117 17.9299 14.199 17.5835 16.0293 17.0076C16.7887 16.7695 17.4628 16.4837 17.9961 16.146V20.636C17.9961 20.7399 17.9278 20.9608 17.5097 21.2768C17.1044 21.5799 16.473 21.8787 15.6368 22.1428C13.9686 22.6667 11.6221 23.0044 8.99823 23.0044C6.37438 23.0044 4.03212 22.671 2.35969 22.1428C1.52347 21.8787 0.89204 21.5799 0.486731 21.2768C0.0686226 20.9651 0.000360489 20.7399 0.000360489 20.636V16.146C0.533663 16.4837 1.20775 16.7695 1.96718 17.0076ZM3.88706 21.056C4.54409 21.056 5.07739 20.5148 5.07739 19.848C5.07739 19.1812 4.54409 18.64 3.88706 18.64C3.23003 18.64 2.69673 19.1812 2.69673 19.848C2.69673 20.5148 3.23003 21.056 3.88706 21.056Z" fill="#2A6E93"/>
6
6
  </svg>
@@ -2,5 +2,5 @@
2
2
  <path d="M7.81999 13.6018C8.47642 13.6018 9.08678 13.4661 9.67412 13.2739C8.02728 11.6571 7.00233 9.40706 7.00233 6.94223C7.00233 5.39324 7.4054 3.9347 8.1079 2.66836C8.01577 2.66836 7.92364 2.64575 7.83151 2.64575C4.74513 2.64575 2.24609 5.09927 2.24609 8.12942C2.24609 11.1596 4.74513 13.6131 7.83151 13.6131L7.81999 13.6018Z" fill="#07679C"/>
3
3
  <path d="M21.119 11.8262C23.8759 9.1195 23.8759 4.73109 21.119 2.0244C18.3621 -0.682283 13.8923 -0.682284 11.1354 2.0244C8.37847 4.73109 8.37847 9.1195 11.1354 11.8262C13.8923 14.5329 18.3621 14.5329 21.119 11.8262Z" fill="#07679C"/>
4
4
  <path d="M18.5 21.4887C18.5 18.3455 20.5 16.5 22.9522 15.5238C22.3879 15.0829 21.766 14.7211 21.0865 14.4497C19.6585 15.3655 17.9541 15.9082 16.1115 15.9082C14.2689 15.9082 12.576 15.3655 11.1364 14.4497C8.25734 15.6143 6.23047 18.3844 6.23047 21.6294V22.7374C6.23047 23.5628 6.8178 24.2751 7.64698 24.4334C10.0078 24.8743 12.8639 25.2248 16.1115 25.2248C16.9637 25.2248 17.7698 25.1909 18.5644 25.1457C18.5644 23.5 18.5 22.6193 18.5 21.5V21.4887Z" fill="#07679C"/>
5
- <path d="M3.43186 14.2688C1.40499 15.2864 0 17.3442 0 19.7412V20.6231C0 21.2789 0.472169 21.8442 1.11708 21.9685C2.03839 22.1381 3.06334 22.2964 4.16891 22.4095V21.6294C4.16891 19.3341 4.99808 17.1972 6.39156 15.5012C5.30902 15.2977 4.29559 14.8794 3.42035 14.2801L3.43186 14.2688Z" fill="#07679C"/>
5
+ <path d="M3.43186 14.2688C1.40499 15.2864 0 17.3442 0 19.7412V20.6231C0 21.2789 0.472169 21.8442 1.11708 21.9685C2.03839 22.1381 3.06334 22.2964 4.16891 22.4095V21.6294C4.16891 19.3341 4.99808 17.1972 6.39156 15.5012C5.30902 15.2977 4.29559 14.8794 3.42035 14.2801L3.43186 14.2688Z" fill="#2A6E93"/>
6
6
  </svg>
@@ -1,4 +1,4 @@
1
1
  <svg width="20" height="26" viewBox="0 0 20 26" fill="none" xmlns="http://www.w3.org/2000/svg">
2
2
  <path d="M14.9755 11.8262C17.7324 9.1195 17.7324 4.73109 14.9755 2.0244C12.2186 -0.682283 7.74873 -0.682284 4.99182 2.0244C2.23491 4.73109 2.23491 9.1195 4.99182 11.8262C7.74873 14.5329 12.2186 14.5329 14.9755 11.8262Z" fill="#07679C"/>
3
- <path d="M12.3564 21.4887C12.3564 18.3455 14.3564 16.5 16.8086 15.5238C16.2443 15.0829 15.6224 14.7211 14.943 14.4497C13.5149 15.3655 11.8105 15.9082 9.96791 15.9082C8.1253 15.9082 6.4324 15.3655 4.99287 14.4497C2.11379 15.6143 0.0869141 18.3844 0.0869141 21.6294V22.7374C0.0869141 23.5628 0.674246 24.2751 1.50342 24.4334C3.86427 24.8743 6.72031 25.2248 9.96791 25.2248C10.8201 25.2248 11.6263 25.1909 12.4209 25.1457C12.4209 23.5 12.3564 22.6193 12.3564 21.5V21.4887Z" fill="#07679C"/>
3
+ <path d="M12.3564 21.4887C12.3564 18.3455 14.3564 16.5 16.8086 15.5238C16.2443 15.0829 15.6224 14.7211 14.943 14.4497C13.5149 15.3655 11.8105 15.9082 9.96791 15.9082C8.1253 15.9082 6.4324 15.3655 4.99287 14.4497C2.11379 15.6143 0.0869141 18.3844 0.0869141 21.6294V22.7374C0.0869141 23.5628 0.674246 24.2751 1.50342 24.4334C3.86427 24.8743 6.72031 25.2248 9.96791 25.2248C10.8201 25.2248 11.6263 25.1909 12.4209 25.1457C12.4209 23.5 12.3564 22.6193 12.3564 21.5V21.4887Z" fill="#2A6E93"/>
4
4
  </svg>
@@ -7,5 +7,5 @@
7
7
  <path d="M19.8132 14.5845H19.9532L27.0595 13.1389C27.4445 13.0666 27.7246 12.6691 27.6196 12.2716C27.5496 11.8741 27.1645 11.585 26.7794 11.6934L19.6732 13.1389C19.2881 13.2112 19.0081 13.6087 19.1131 14.0062C19.1831 14.3676 19.4631 14.5845 19.8132 14.5845Z" fill="#07679C"/>
8
8
  <path d="M19.8132 10.9341H19.9532L27.0595 9.48853C27.4445 9.41625 27.7246 9.01873 27.6196 8.62121C27.5496 8.22368 27.1645 7.93457 26.7794 8.04299L19.6732 9.48853C19.2881 9.56081 19.0081 9.95833 19.1131 10.3559C19.1831 10.6811 19.4631 10.9341 19.8132 10.9341Z" fill="#07679C"/>
9
9
  <path d="M26.7794 15.3433L19.6732 16.7888C19.2881 16.8611 19.0081 17.2586 19.1131 17.6562C19.1831 18.0176 19.4981 18.2705 19.8132 18.2705H19.9532L27.0595 16.825C27.4445 16.7527 27.7246 16.3552 27.6196 15.9577C27.5496 15.524 27.1645 15.271 26.7794 15.3433Z" fill="#07679C"/>
10
- <path d="M30.8404 2.98385V2.73088C30.8404 1.89969 30.4904 1.10464 29.8603 0.562567C29.2302 0.0204891 28.425 -0.196342 27.6199 -0.0156494L16.873 2.15266C16.6979 2.1888 16.5579 2.1888 16.3829 2.15266L5.63599 -0.0156494C4.83085 -0.196342 4.02571 0.0204891 3.3956 0.562567C2.76549 1.10464 2.41543 1.86355 2.41543 2.73088V2.98385C1.08519 3.1284 0 4.28483 0 5.73037V20.2942C0 21.8481 1.22522 23.0768 2.69548 23.0768H30.5254C32.0306 23.0768 33.2209 21.812 33.2209 20.2942V5.73037C33.2559 4.28483 32.1707 3.1284 30.8404 2.98385ZM27.8999 1.46603C28.285 1.39375 28.635 1.50217 28.9501 1.719C29.2302 1.97197 29.4052 2.33335 29.4052 2.73088V17.9452C29.4052 18.5595 28.9851 19.1016 28.39 19.21L17.3631 21.4506V3.5982L27.8999 1.46603ZM3.88569 2.73088C3.88569 2.33335 4.06072 1.97197 4.34076 1.719C4.5508 1.53831 4.83085 1.42989 5.14591 1.42989C5.21592 1.42989 5.32094 1.42989 5.39095 1.46603L15.9278 3.5982V21.4506L4.90086 19.21C4.30576 19.1016 3.88569 18.5595 3.88569 17.9452V2.73088Z" fill="#07679C"/>
10
+ <path d="M30.8404 2.98385V2.73088C30.8404 1.89969 30.4904 1.10464 29.8603 0.562567C29.2302 0.0204891 28.425 -0.196342 27.6199 -0.0156494L16.873 2.15266C16.6979 2.1888 16.5579 2.1888 16.3829 2.15266L5.63599 -0.0156494C4.83085 -0.196342 4.02571 0.0204891 3.3956 0.562567C2.76549 1.10464 2.41543 1.86355 2.41543 2.73088V2.98385C1.08519 3.1284 0 4.28483 0 5.73037V20.2942C0 21.8481 1.22522 23.0768 2.69548 23.0768H30.5254C32.0306 23.0768 33.2209 21.812 33.2209 20.2942V5.73037C33.2559 4.28483 32.1707 3.1284 30.8404 2.98385ZM27.8999 1.46603C28.285 1.39375 28.635 1.50217 28.9501 1.719C29.2302 1.97197 29.4052 2.33335 29.4052 2.73088V17.9452C29.4052 18.5595 28.9851 19.1016 28.39 19.21L17.3631 21.4506V3.5982L27.8999 1.46603ZM3.88569 2.73088C3.88569 2.33335 4.06072 1.97197 4.34076 1.719C4.5508 1.53831 4.83085 1.42989 5.14591 1.42989C5.21592 1.42989 5.32094 1.42989 5.39095 1.46603L15.9278 3.5982V21.4506L4.90086 19.21C4.30576 19.1016 3.88569 18.5595 3.88569 17.9452V2.73088Z" fill="#2A6E93"/>
11
11
  </svg>
package/src/index.js CHANGED
@@ -6,5 +6,10 @@ export {
6
6
  ComponentTypes,
7
7
  dataFormatTypes,
8
8
  } from './util/Types';
9
- export { formatBytes } from './util/Dataformat';
9
+ export {
10
+ formatBytes,
11
+ stripSurroundingBrackets,
12
+ formatValueForDisplay,
13
+ isBracketStripEnabled,
14
+ } from './util/Dataformat';
10
15
  export { default as AddToCart } from './wrapper/components/AddToCart/ReduxAddToCart';
@@ -31,3 +31,50 @@ export const formatColumnValues = (columns, data) => {
31
31
  }
32
32
  return data;
33
33
  };
34
+
35
+ /**
36
+ * Column flag `stripSurroundingBrackets: false` disables OpenSearch
37
+ * bracket-stripping for that column. Default (undefined/true) is enabled.
38
+ */
39
+ export const isBracketStripEnabled = (column = {}) => (
40
+ column.stripSurroundingBrackets !== false
41
+ );
42
+
43
+ /**
44
+ * Remove wrapping square brackets from OpenSearch array-as-string values.
45
+ * "[Complete Response]" => "Complete Response"; "[]" => "".
46
+ */
47
+ export const stripSurroundingBrackets = (value) => {
48
+ if (value == null) {
49
+ return value;
50
+ }
51
+ if (Array.isArray(value)) {
52
+ return value.map((item) => stripSurroundingBrackets(item));
53
+ }
54
+ if (typeof value !== 'string') {
55
+ return value;
56
+ }
57
+ const text = value.trim();
58
+ if (text === '[]') {
59
+ return '';
60
+ }
61
+ if (text.startsWith('[') && text.endsWith(']')) {
62
+ return text.slice(1, -1).trim();
63
+ }
64
+ return value;
65
+ };
66
+
67
+ /** Display helper: strip wrapping brackets and join arrays. */
68
+ export const formatValueForDisplay = (value) => {
69
+ const stripped = stripSurroundingBrackets(value);
70
+ if (Array.isArray(stripped)) {
71
+ return stripped
72
+ .map((item) => (item == null ? '' : String(item)))
73
+ .filter(Boolean)
74
+ .join(', ');
75
+ }
76
+ if (stripped == null) {
77
+ return '';
78
+ }
79
+ return String(stripped);
80
+ };