@bento-core/table 1.0.0-c3dc.4 → 1.0.0-c3dc.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.
|
@@ -44,6 +44,9 @@ const ViewCell = _ref2 => {
|
|
|
44
44
|
const {
|
|
45
45
|
cellType
|
|
46
46
|
} = column;
|
|
47
|
+
function isNumeric(value) {
|
|
48
|
+
return /^-?\d+\.?\d*$/.test(value);
|
|
49
|
+
}
|
|
47
50
|
switch (cellType) {
|
|
48
51
|
case _Types.cellTypes.FORMAT_DATA:
|
|
49
52
|
return /*#__PURE__*/_react.default.createElement(_DataFormatView.default, {
|
|
@@ -60,6 +63,8 @@ const ViewCell = _ref2 => {
|
|
|
60
63
|
row: row,
|
|
61
64
|
column: column
|
|
62
65
|
});
|
|
66
|
+
case _Types.cellTypes.COMMA:
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, isNumeric(row[column.dataField]) ? Number(row[column.dataField]).toLocaleString() : row[column.dataField]);
|
|
63
68
|
default:
|
|
64
69
|
return /*#__PURE__*/_react.default.createElement(_core.Typography, null, row[column.dataField]);
|
|
65
70
|
}
|
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.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.CHECKBOX = void 0;
|
|
6
|
+
exports.headerTypes = exports.dataFormatTypes = exports.cellTypes = exports.cellStyles = exports.actionCellTypes = exports.TRANSFORM = exports.LINK = exports.FORMAT_DATA_CELLS = exports.FORMAT_DATA = exports.FORMAT_BYTES = exports.EXPAND = exports.DISPLAY = exports.DELETE = exports.DEFAULT = exports.ComponentTypes = exports.CUSTOM_ELEM = exports.COMMA = exports.CHECKBOX = void 0;
|
|
7
7
|
const CHECKBOX = 'CHECKBOX';
|
|
8
8
|
exports.CHECKBOX = CHECKBOX;
|
|
9
9
|
const DELETE = 'DELETE';
|
|
@@ -24,6 +24,8 @@ const TRANSFORM = 'TRANSFORM';
|
|
|
24
24
|
exports.TRANSFORM = TRANSFORM;
|
|
25
25
|
const EXPAND = 'EXPAND';
|
|
26
26
|
exports.EXPAND = EXPAND;
|
|
27
|
+
const COMMA = 'COMMA';
|
|
28
|
+
exports.COMMA = COMMA;
|
|
27
29
|
const cellTypes = {
|
|
28
30
|
CUSTOM_ELEM,
|
|
29
31
|
LINK,
|
|
@@ -31,7 +33,8 @@ const cellTypes = {
|
|
|
31
33
|
CHECKBOX,
|
|
32
34
|
DELETE,
|
|
33
35
|
DEFAULT,
|
|
34
|
-
FORMAT_DATA
|
|
36
|
+
FORMAT_DATA,
|
|
37
|
+
COMMA
|
|
35
38
|
};
|
|
36
39
|
exports.cellTypes = cellTypes;
|
|
37
40
|
const cellStyles = {
|
package/package.json
CHANGED
|
@@ -31,6 +31,9 @@ const ViewCell = ({
|
|
|
31
31
|
row,
|
|
32
32
|
}) => {
|
|
33
33
|
const { cellType } = column;
|
|
34
|
+
function isNumeric(value) {
|
|
35
|
+
return /^-?\d+\.?\d*$/.test(value);
|
|
36
|
+
}
|
|
34
37
|
switch (cellType) {
|
|
35
38
|
case cellTypes.FORMAT_DATA:
|
|
36
39
|
return (
|
|
@@ -53,6 +56,14 @@ const ViewCell = ({
|
|
|
53
56
|
column={column}
|
|
54
57
|
/>
|
|
55
58
|
);
|
|
59
|
+
case cellTypes.COMMA:
|
|
60
|
+
return (
|
|
61
|
+
<Typography>
|
|
62
|
+
{isNumeric(row[column.dataField])
|
|
63
|
+
? Number(row[column.dataField]).toLocaleString()
|
|
64
|
+
: row[column.dataField]}
|
|
65
|
+
</Typography>
|
|
66
|
+
);
|
|
56
67
|
default:
|
|
57
68
|
return (
|
|
58
69
|
<Typography>
|
package/src/util/Types.js
CHANGED
|
@@ -8,6 +8,7 @@ export const FORMAT_DATA = 'FORMAT_DATA';
|
|
|
8
8
|
export const FORMAT_BYTES = 'FORMAT_BYTES';
|
|
9
9
|
export const TRANSFORM = 'TRANSFORM';
|
|
10
10
|
export const EXPAND = 'EXPAND';
|
|
11
|
+
export const COMMA = 'COMMA';
|
|
11
12
|
|
|
12
13
|
export const cellTypes = {
|
|
13
14
|
CUSTOM_ELEM,
|
|
@@ -17,6 +18,7 @@ export const cellTypes = {
|
|
|
17
18
|
DELETE,
|
|
18
19
|
DEFAULT,
|
|
19
20
|
FORMAT_DATA,
|
|
21
|
+
COMMA,
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
export const cellStyles = {
|