@bento-core/table 1.0.1-ccdiintegrated.4 → 1.0.1-ccdiintegrated.5
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/DisplayBodyCell.js +5 -4
- package/dist/body/components/CustomLinkView.js +1 -1
- package/dist/body/components/DataFormatView.js +1 -1
- package/dist/index.js +6 -0
- package/dist/util/Dataformat.js +16 -3
- package/package.json +1 -1
- package/src/body/DisplayBodyCell.js +14 -5
- package/src/body/components/CustomLinkView.js +4 -2
- package/src/body/components/DataFormatView.js +4 -2
- package/src/index.js +6 -1
- package/src/util/Dataformat.js +8 -0
|
@@ -31,10 +31,11 @@ const CustomComponent = _ref => {
|
|
|
31
31
|
dataField,
|
|
32
32
|
customCellRender
|
|
33
33
|
} = column;
|
|
34
|
-
const
|
|
34
|
+
const raw = row[dataField];
|
|
35
|
+
const value = (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.stripSurroundingBrackets)(raw) : raw;
|
|
35
36
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, customCellRender(_objectSpread(_objectSpread(_objectSpread({}, row), column), {}, {
|
|
36
|
-
[dataField]:
|
|
37
|
-
label:
|
|
37
|
+
[dataField]: value,
|
|
38
|
+
label: value
|
|
38
39
|
})));
|
|
39
40
|
};
|
|
40
41
|
|
|
@@ -90,7 +91,7 @@ const ViewCell = _ref2 => {
|
|
|
90
91
|
column: column
|
|
91
92
|
});
|
|
92
93
|
default:
|
|
93
|
-
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.formatValueForDisplay)(row[column.dataField]));
|
|
94
|
+
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.formatValueForDisplay)(row[column.dataField]) : row[column.dataField]);
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
97
|
const DisplayCell = _ref3 => {
|
|
@@ -25,7 +25,7 @@ const CustomLinkView = _ref => {
|
|
|
25
25
|
return /*#__PURE__*/_react.default.createElement(_core.Link, {
|
|
26
26
|
href: url,
|
|
27
27
|
className: _Types.cellTypes.LINK
|
|
28
|
-
}, /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.formatValueForDisplay)(row[column === null || column === void 0 ? void 0 : column.dataField])));
|
|
28
|
+
}, /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.formatValueForDisplay)(row[column === null || column === void 0 ? void 0 : column.dataField]) : row[column === null || column === void 0 ? void 0 : column.dataField]));
|
|
29
29
|
};
|
|
30
30
|
var _default = CustomLinkView;
|
|
31
31
|
exports.default = _default;
|
|
@@ -26,7 +26,7 @@ const CellView = _ref => {
|
|
|
26
26
|
case _Types.dataFormatTypes.FORMAT_BYTES:
|
|
27
27
|
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.formatBytes)(value));
|
|
28
28
|
default:
|
|
29
|
-
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.formatValueForDisplay)(value));
|
|
29
|
+
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, (0, _Dataformat.isBracketStripEnabled)(column) ? (0, _Dataformat.formatValueForDisplay)(value) : value);
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
const DataFormatView = _ref2 => {
|
package/dist/index.js
CHANGED
|
@@ -57,6 +57,12 @@ Object.defineProperty(exports, "headerTypes", {
|
|
|
57
57
|
return _Types.headerTypes;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "isBracketStripEnabled", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _Dataformat.isBracketStripEnabled;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
60
66
|
Object.defineProperty(exports, "stripSurroundingBrackets", {
|
|
61
67
|
enumerable: true,
|
|
62
68
|
get: function get() {
|
package/dist/util/Dataformat.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.formatBytes = formatBytes;
|
|
7
|
-
exports.stripSurroundingBrackets = exports.formatValueForDisplay = exports.formatColumnValues = void 0;
|
|
7
|
+
exports.stripSurroundingBrackets = exports.isBracketStripEnabled = exports.formatValueForDisplay = exports.formatColumnValues = void 0;
|
|
8
8
|
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; }
|
|
9
9
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -53,11 +53,21 @@ const formatColumnValues = (columns, data) => {
|
|
|
53
53
|
return data;
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Column flag `stripSurroundingBrackets: false` disables OpenSearch
|
|
58
|
+
* bracket-stripping for that column. Default (undefined/true) is enabled.
|
|
59
|
+
*/
|
|
60
|
+
exports.formatColumnValues = formatColumnValues;
|
|
61
|
+
const isBracketStripEnabled = function isBracketStripEnabled() {
|
|
62
|
+
let column = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
63
|
+
return column.stripSurroundingBrackets !== false;
|
|
64
|
+
};
|
|
65
|
+
|
|
56
66
|
/**
|
|
57
67
|
* Remove wrapping square brackets from OpenSearch array-as-string values.
|
|
58
68
|
* "[Complete Response]" => "Complete Response"; "[]" => "".
|
|
59
69
|
*/
|
|
60
|
-
exports.
|
|
70
|
+
exports.isBracketStripEnabled = isBracketStripEnabled;
|
|
61
71
|
const stripSurroundingBrackets = value => {
|
|
62
72
|
if (value == null) {
|
|
63
73
|
return value;
|
|
@@ -65,7 +75,10 @@ const stripSurroundingBrackets = value => {
|
|
|
65
75
|
if (Array.isArray(value)) {
|
|
66
76
|
return value.map(item => stripSurroundingBrackets(item));
|
|
67
77
|
}
|
|
68
|
-
|
|
78
|
+
if (typeof value !== 'string') {
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
const text = value.trim();
|
|
69
82
|
if (text === '[]') {
|
|
70
83
|
return '';
|
|
71
84
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
Typography,
|
|
5
5
|
} from '@material-ui/core';
|
|
6
6
|
import { cellTypes } from '../util/Types';
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
formatValueForDisplay,
|
|
9
|
+
isBracketStripEnabled,
|
|
10
|
+
stripSurroundingBrackets,
|
|
11
|
+
} from '../util/Dataformat';
|
|
8
12
|
import CustomLinkView from './components/CustomLinkView';
|
|
9
13
|
import DataFormatView from './components/DataFormatView';
|
|
10
14
|
import CPIView from './components/CPIView';
|
|
@@ -19,14 +23,17 @@ const CustomComponent = ({
|
|
|
19
23
|
column,
|
|
20
24
|
}) => {
|
|
21
25
|
const { dataField, customCellRender } = column;
|
|
22
|
-
const
|
|
26
|
+
const raw = row[dataField];
|
|
27
|
+
const value = isBracketStripEnabled(column)
|
|
28
|
+
? stripSurroundingBrackets(raw)
|
|
29
|
+
: raw;
|
|
23
30
|
return (
|
|
24
31
|
<>
|
|
25
32
|
{customCellRender({
|
|
26
33
|
...row,
|
|
27
34
|
...column,
|
|
28
|
-
[dataField]:
|
|
29
|
-
label:
|
|
35
|
+
[dataField]: value,
|
|
36
|
+
label: value,
|
|
30
37
|
})}
|
|
31
38
|
</>
|
|
32
39
|
);
|
|
@@ -95,7 +102,9 @@ const ViewCell = ({
|
|
|
95
102
|
default:
|
|
96
103
|
return (
|
|
97
104
|
<Typography>
|
|
98
|
-
{
|
|
105
|
+
{isBracketStripEnabled(column)
|
|
106
|
+
? formatValueForDisplay(row[column.dataField])
|
|
107
|
+
: row[column.dataField]}
|
|
99
108
|
</Typography>
|
|
100
109
|
);
|
|
101
110
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Link, Typography,
|
|
4
4
|
} from '@material-ui/core';
|
|
5
5
|
import { cellTypes } from '../../util/Types';
|
|
6
|
-
import { formatValueForDisplay } from '../../util/Dataformat';
|
|
6
|
+
import { formatValueForDisplay, isBracketStripEnabled } from '../../util/Dataformat';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Custom Link component
|
|
@@ -17,7 +17,9 @@ const CustomLinkView = ({
|
|
|
17
17
|
return (
|
|
18
18
|
<Link href={url} className={cellTypes.LINK}>
|
|
19
19
|
<Typography>
|
|
20
|
-
{
|
|
20
|
+
{isBracketStripEnabled(column)
|
|
21
|
+
? formatValueForDisplay(row[column?.dataField])
|
|
22
|
+
: row[column?.dataField]}
|
|
21
23
|
</Typography>
|
|
22
24
|
</Link>
|
|
23
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, formatValueForDisplay } 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
|
-
{
|
|
26
|
+
{isBracketStripEnabled(column)
|
|
27
|
+
? formatValueForDisplay(value)
|
|
28
|
+
: value}
|
|
27
29
|
</Typography>
|
|
28
30
|
);
|
|
29
31
|
}
|
package/src/index.js
CHANGED
|
@@ -6,5 +6,10 @@ export {
|
|
|
6
6
|
ComponentTypes,
|
|
7
7
|
dataFormatTypes,
|
|
8
8
|
} from './util/Types';
|
|
9
|
-
export {
|
|
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';
|
package/src/util/Dataformat.js
CHANGED
|
@@ -32,6 +32,14 @@ export const formatColumnValues = (columns, data) => {
|
|
|
32
32
|
return data;
|
|
33
33
|
};
|
|
34
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
|
+
|
|
35
43
|
/**
|
|
36
44
|
* Remove wrapping square brackets from OpenSearch array-as-string values.
|
|
37
45
|
* "[Complete Response]" => "Complete Response"; "[]" => "".
|