dtable-ui-component 5.1.3 → 5.1.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/lib/DTableRadioGroup/index.css +4 -0
- package/lib/DTableRadioGroup/index.js +3 -2
- package/lib/FormulaFormatter/index.js +23 -13
- package/lib/FormulaFormatter/utils.js +1 -64
- package/lib/RowExpandFormatter/index.js +1 -1
- package/lib/RowExpandFormulaFormatter/index.js +34 -16
- package/package.json +1 -1
|
@@ -67,7 +67,8 @@ class DTableRadioGroup extends _react.default.Component {
|
|
|
67
67
|
render() {
|
|
68
68
|
const {
|
|
69
69
|
options,
|
|
70
|
-
optionsDisplay
|
|
70
|
+
optionsDisplay,
|
|
71
|
+
readOnly
|
|
71
72
|
} = this.props;
|
|
72
73
|
const {
|
|
73
74
|
activeOption
|
|
@@ -75,7 +76,7 @@ class DTableRadioGroup extends _react.default.Component {
|
|
|
75
76
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
76
77
|
className: "radio-group-wrapper"
|
|
77
78
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
78
|
-
className: "radio-group-options"
|
|
79
|
+
className: "radio-group-options ".concat(readOnly ? 'read-only' : '')
|
|
79
80
|
}, options.map(option => {
|
|
80
81
|
const isActive = activeOption === option ? true : false;
|
|
81
82
|
const displayOption = optionsDisplay && optionsDisplay[option] || '';
|
|
@@ -18,6 +18,7 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
18
18
|
this.getGridCellClassName = resultType => {
|
|
19
19
|
switch (resultType) {
|
|
20
20
|
case _dtableUtils.FORMULA_RESULT_TYPE.NUMBER:
|
|
21
|
+
case _dtableUtils.FORMULA_RESULT_TYPE.DATE:
|
|
21
22
|
{
|
|
22
23
|
return 'text-right';
|
|
23
24
|
}
|
|
@@ -27,6 +28,20 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
};
|
|
31
|
+
this.renderCellValue = (cellValue, resultType) => {
|
|
32
|
+
const {
|
|
33
|
+
containerClassName
|
|
34
|
+
} = this.props;
|
|
35
|
+
const gridCellClassName = this.getGridCellClassName(resultType);
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
37
|
+
className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
|
|
38
|
+
title: cellValue,
|
|
39
|
+
"aria-label": cellValue
|
|
40
|
+
}, cellValue);
|
|
41
|
+
};
|
|
42
|
+
this.renderInternalErrorValue = (errorValue, resultType) => {
|
|
43
|
+
return this.renderCellValue(errorValue, resultType);
|
|
44
|
+
};
|
|
30
45
|
this.renderOtherColumnFormatter = () => {
|
|
31
46
|
const {
|
|
32
47
|
value,
|
|
@@ -106,23 +121,23 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
106
121
|
}
|
|
107
122
|
render() {
|
|
108
123
|
const {
|
|
109
|
-
containerClassName,
|
|
110
124
|
column,
|
|
111
125
|
collaborators
|
|
112
126
|
} = this.props;
|
|
113
127
|
const {
|
|
114
128
|
data
|
|
115
129
|
} = column;
|
|
130
|
+
let value = this.props.value;
|
|
131
|
+
if (!data || !value && value !== 0 && value !== false) return null;
|
|
116
132
|
const {
|
|
117
133
|
array_type,
|
|
118
134
|
result_type: resultType
|
|
119
135
|
} = data;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
136
|
+
if (_dtableUtils.DISPLAY_INTERNAL_ERRORS.includes(value)) {
|
|
137
|
+
return this.renderInternalErrorValue(value, resultType);
|
|
138
|
+
}
|
|
139
|
+
if (array_type && array_type === _dtableUtils.CellType.LONG_TEXT && Array.isArray(value)) {
|
|
140
|
+
value = value.map(item => (0, _utils.convertValueToDtableLongTextValue)(item));
|
|
126
141
|
}
|
|
127
142
|
if (resultType === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
128
143
|
return this.renderOtherColumnFormatter();
|
|
@@ -130,15 +145,10 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
130
145
|
if (typeof value === 'object') {
|
|
131
146
|
return null;
|
|
132
147
|
}
|
|
133
|
-
const gridCellClassName = this.getGridCellClassName(resultType);
|
|
134
148
|
const formattedValue = (0, _dtableUtils.getFormulaDisplayString)(value, data, {
|
|
135
149
|
collaborators
|
|
136
150
|
});
|
|
137
|
-
return
|
|
138
|
-
className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
|
|
139
|
-
title: formattedValue,
|
|
140
|
-
"aria-label": formattedValue
|
|
141
|
-
}, formattedValue);
|
|
151
|
+
return this.renderCellValue(formattedValue, resultType);
|
|
142
152
|
}
|
|
143
153
|
}
|
|
144
154
|
var _default = exports.default = FormulaFormatter;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.convertValueToDtableLongTextValue = void 0;
|
|
8
8
|
exports.isArrayFormatColumn = isArrayFormatColumn;
|
|
9
9
|
exports.isFunction = void 0;
|
|
10
10
|
exports.isSimpleCellFormatter = isSimpleCellFormatter;
|
|
@@ -46,69 +46,6 @@ const openUrlLink = url => {
|
|
|
46
46
|
document.body.removeChild(a);
|
|
47
47
|
};
|
|
48
48
|
exports.openUrlLink = openUrlLink;
|
|
49
|
-
const getFormulaArrayValue = function (value) {
|
|
50
|
-
let isFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
51
|
-
if (!Array.isArray(value)) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
if (!isFlat) {
|
|
55
|
-
return getTwoDimensionArrayValue(value);
|
|
56
|
-
}
|
|
57
|
-
return value.map(item => {
|
|
58
|
-
if (Object.prototype.toString.call(item) !== '[object Object]' || !Object.prototype.hasOwnProperty.call(item, 'display_value')) {
|
|
59
|
-
return item;
|
|
60
|
-
}
|
|
61
|
-
const {
|
|
62
|
-
display_value
|
|
63
|
-
} = item;
|
|
64
|
-
if (!Array.isArray(display_value) || display_value.length === 0) {
|
|
65
|
-
return display_value;
|
|
66
|
-
}
|
|
67
|
-
return display_value.map(i => {
|
|
68
|
-
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
69
|
-
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) {
|
|
70
|
-
return i;
|
|
71
|
-
}
|
|
72
|
-
const {
|
|
73
|
-
display_value
|
|
74
|
-
} = i;
|
|
75
|
-
return display_value;
|
|
76
|
-
}
|
|
77
|
-
return i;
|
|
78
|
-
});
|
|
79
|
-
}).flat().filter(item => isValidCellValue(item));
|
|
80
|
-
};
|
|
81
|
-
exports.getFormulaArrayValue = getFormulaArrayValue;
|
|
82
|
-
const getTwoDimensionArrayValue = value => {
|
|
83
|
-
if (!Array.isArray(value)) return [];
|
|
84
|
-
return value.map(item => {
|
|
85
|
-
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
86
|
-
return item;
|
|
87
|
-
}
|
|
88
|
-
if (!Object.prototype.hasOwnProperty.call(item, 'display_value')) {
|
|
89
|
-
return item;
|
|
90
|
-
}
|
|
91
|
-
const {
|
|
92
|
-
display_value
|
|
93
|
-
} = item;
|
|
94
|
-
if (!Array.isArray(display_value) || display_value.length === 0) {
|
|
95
|
-
return display_value;
|
|
96
|
-
}
|
|
97
|
-
return display_value.map(i => {
|
|
98
|
-
if (Object.prototype.toString.call(i) === '[object Object]') {
|
|
99
|
-
if (!Object.prototype.hasOwnProperty.call(i, 'display_value')) {
|
|
100
|
-
return i;
|
|
101
|
-
}
|
|
102
|
-
const {
|
|
103
|
-
display_value
|
|
104
|
-
} = i;
|
|
105
|
-
return display_value;
|
|
106
|
-
}
|
|
107
|
-
return i;
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
exports.getTwoDimensionArrayValue = getTwoDimensionArrayValue;
|
|
112
49
|
const convertValueToDtableLongTextValue = value => {
|
|
113
50
|
const valueType = Object.prototype.toString.call(value);
|
|
114
51
|
if (value && valueType === '[object String]') {
|
|
@@ -95,7 +95,7 @@ class EditorFormatter extends _react.default.Component {
|
|
|
95
95
|
collaborators
|
|
96
96
|
} = this.state;
|
|
97
97
|
const containerClassName = "dtable-".concat(columnType, "-formatter ").concat(className || '');
|
|
98
|
-
let cellValue = row[column.key]
|
|
98
|
+
let cellValue = row[column.key] !== null && row[column.key] !== undefined ? row[column.key] : row[column.name];
|
|
99
99
|
switch (columnType) {
|
|
100
100
|
case _constants.CellType.TEXT:
|
|
101
101
|
{
|
|
@@ -18,6 +18,19 @@ require("../FormulaFormatter/index.css");
|
|
|
18
18
|
class RowExpandFormulaFormatter extends _react.default.Component {
|
|
19
19
|
constructor() {
|
|
20
20
|
super(...arguments);
|
|
21
|
+
this.getGridCellClassName = resultType => {
|
|
22
|
+
switch (resultType) {
|
|
23
|
+
case _dtableUtils.FORMULA_RESULT_TYPE.NUMBER:
|
|
24
|
+
case _dtableUtils.FORMULA_RESULT_TYPE.DATE:
|
|
25
|
+
{
|
|
26
|
+
return 'text-right';
|
|
27
|
+
}
|
|
28
|
+
default:
|
|
29
|
+
{
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
21
34
|
this.onOpenUrlLink = url => {
|
|
22
35
|
if (!(0, _utils.isValidUrl)(url)) {
|
|
23
36
|
url = "http://".concat(url);
|
|
@@ -58,6 +71,21 @@ class RowExpandFormulaFormatter extends _react.default.Component {
|
|
|
58
71
|
style: style
|
|
59
72
|
}, dom);
|
|
60
73
|
};
|
|
74
|
+
this.renderCellValue = (cellValue, resultType) => {
|
|
75
|
+
const {
|
|
76
|
+
containerClassName
|
|
77
|
+
} = this.props;
|
|
78
|
+
const customClassName = this.getGridCellClassName(resultType);
|
|
79
|
+
const className = "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(customClassName);
|
|
80
|
+
return this.renderBorder( /*#__PURE__*/_react.default.createElement("div", {
|
|
81
|
+
className: className,
|
|
82
|
+
title: cellValue,
|
|
83
|
+
"aria-label": cellValue
|
|
84
|
+
}, cellValue));
|
|
85
|
+
};
|
|
86
|
+
this.renderInternalErrorValue = (errorValue, resultType) => {
|
|
87
|
+
return this.renderCellValue(errorValue, resultType);
|
|
88
|
+
};
|
|
61
89
|
this.renderOtherColumnFormatter = () => {
|
|
62
90
|
const {
|
|
63
91
|
value,
|
|
@@ -156,7 +184,6 @@ class RowExpandFormulaFormatter extends _react.default.Component {
|
|
|
156
184
|
}
|
|
157
185
|
render() {
|
|
158
186
|
let {
|
|
159
|
-
containerClassName,
|
|
160
187
|
column,
|
|
161
188
|
collaborators,
|
|
162
189
|
value
|
|
@@ -168,12 +195,11 @@ class RowExpandFormulaFormatter extends _react.default.Component {
|
|
|
168
195
|
array_type,
|
|
169
196
|
result_type
|
|
170
197
|
} = data;
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
198
|
+
if (_dtableUtils.DISPLAY_INTERNAL_ERRORS.includes(value)) {
|
|
199
|
+
return this.renderInternalErrorValue(value, result_type);
|
|
200
|
+
}
|
|
201
|
+
if (array_type === _dtableUtils.CellType.LONG_TEXT && Array.isArray(value)) {
|
|
202
|
+
value = value.map(item => (0, _utils.convertValueToDtableLongTextValue)(item));
|
|
177
203
|
}
|
|
178
204
|
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
|
|
179
205
|
return this.renderOtherColumnFormatter();
|
|
@@ -184,15 +210,7 @@ class RowExpandFormulaFormatter extends _react.default.Component {
|
|
|
184
210
|
const formattedValue = (0, _dtableUtils.getFormulaDisplayString)(value, data, {
|
|
185
211
|
collaborators
|
|
186
212
|
});
|
|
187
|
-
|
|
188
|
-
if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
|
|
189
|
-
className = className + ' text-right';
|
|
190
|
-
}
|
|
191
|
-
return this.renderBorder( /*#__PURE__*/_react.default.createElement("div", {
|
|
192
|
-
className: className,
|
|
193
|
-
title: formattedValue,
|
|
194
|
-
"aria-label": formattedValue
|
|
195
|
-
}, formattedValue));
|
|
213
|
+
return this.renderCellValue(formattedValue, result_type);
|
|
196
214
|
}
|
|
197
215
|
}
|
|
198
216
|
exports.default = RowExpandFormulaFormatter;
|