dtable-ui-component 0.3.7-beta.3 → 0.3.8
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/FormulaFormatter/index.js +2 -2
- package/lib/FormulaFormatter/utils.js +3 -3
- package/lib/RowExpandFormatter/index.js +2 -2
- package/lib/RowExpandFormulaFormatter/index.js +188 -0
- package/lib/RowExpandLinkFormatter/index.js +2 -2
- package/lib/RowExpandLinkFormatter/utils.js +1 -1
- package/lib/constants/index.js +2 -2
- package/lib/index.js +1 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import React from 'react';
|
|
|
7
7
|
import { CellType, FORMULA_RESULT_TYPE, getFormulaDisplayString } from 'dtable-utils';
|
|
8
8
|
import BaseFormatterConfig from '../formatterConfig/base-formatter-config';
|
|
9
9
|
import TextFormatter from '../TextFormatter';
|
|
10
|
-
import {
|
|
10
|
+
import { isArrayFormatColumn, isSimpleCellFormatter, isFunction, getFormulaArrayValue, convertValueToDtableLongTextValue } from './utils';
|
|
11
11
|
import cellValueValidator from './cell-value-validator';
|
|
12
12
|
import './index.css';
|
|
13
13
|
|
|
@@ -58,7 +58,7 @@ var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
58
58
|
|
|
59
59
|
var formatterProps = _this.getFormatterProps(array_type, array_data, collaborators);
|
|
60
60
|
|
|
61
|
-
if (
|
|
61
|
+
if (isArrayFormatColumn(array_type)) {
|
|
62
62
|
formatterProps.value = value;
|
|
63
63
|
return _this.createColumnFormatter(Formatter, formatterProps);
|
|
64
64
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ARRAY_FORMAT_COLUMNS, SIMPLE_CELL_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS } from '../constants';
|
|
2
2
|
import getPreviewContent from '../SimpleLongTextFormatter/normalize-long-text-value';
|
|
3
3
|
export function isSimpleCellFormatter(type) {
|
|
4
4
|
return SIMPLE_CELL_COLUMNS.includes(type) || SIMPLE_CELL_FORMULA_RESULTS.includes(type);
|
|
5
5
|
}
|
|
6
|
-
export function
|
|
7
|
-
return
|
|
6
|
+
export function isArrayFormatColumn(columnType) {
|
|
7
|
+
return ARRAY_FORMAT_COLUMNS.includes(columnType);
|
|
8
8
|
}
|
|
9
9
|
export var isFunction = function isFunction(functionToCheck) {
|
|
10
10
|
var getType = {};
|
|
@@ -9,7 +9,7 @@ var _emptyTypeMap;
|
|
|
9
9
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import classnames from 'classnames';
|
|
12
|
-
import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, LongTextFormatter, GeolocationFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, DurationFormatter, ButtonFormatter, RowExpandUrlFormatter, RowExpandEmailFormatter, RowExpandRateFormatter, RowExpandImageFormatter, RowExpandFileFormatter, RowExpandLinkFormatter,
|
|
12
|
+
import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, LongTextFormatter, GeolocationFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, DurationFormatter, ButtonFormatter, RowExpandUrlFormatter, RowExpandEmailFormatter, RowExpandRateFormatter, RowExpandImageFormatter, RowExpandFileFormatter, RowExpandLinkFormatter, RowExpandFormulaFormatter, DigitalSignFormatter } from '../index';
|
|
13
13
|
import { CellType } from '../constants';
|
|
14
14
|
import './index.css';
|
|
15
15
|
var emptyTypeMap = (_emptyTypeMap = {}, _defineProperty(_emptyTypeMap, CellType.TEXT, true), _defineProperty(_emptyTypeMap, CellType.LONG_TEXT, true), _defineProperty(_emptyTypeMap, CellType.GEOLOCATION, true), _defineProperty(_emptyTypeMap, CellType.SINGLE_SELECT, true), _defineProperty(_emptyTypeMap, CellType.MULTIPLE_SELECT, true), _defineProperty(_emptyTypeMap, CellType.CTIME, true), _defineProperty(_emptyTypeMap, CellType.MTIME, true), _defineProperty(_emptyTypeMap, CellType.DATE, true), _defineProperty(_emptyTypeMap, CellType.AUTO_NUMBER, true), _defineProperty(_emptyTypeMap, CellType.URL, true), _defineProperty(_emptyTypeMap, CellType.EMAIL, true), _defineProperty(_emptyTypeMap, CellType.IMAGE, true), _defineProperty(_emptyTypeMap, CellType.FILE, true), _defineProperty(_emptyTypeMap, CellType.CREATOR, true), _defineProperty(_emptyTypeMap, CellType.LAST_MODIFIER, true), _emptyTypeMap);
|
|
@@ -290,7 +290,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
290
290
|
return _this.renderEmpty();
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
return /*#__PURE__*/React.createElement(
|
|
293
|
+
return /*#__PURE__*/React.createElement(RowExpandFormulaFormatter, {
|
|
294
294
|
value: cellValue,
|
|
295
295
|
column: column,
|
|
296
296
|
collaborators: collaborators,
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { CellType, FORMULA_RESULT_TYPE, getFormulaDisplayString } from 'dtable-utils';
|
|
8
|
+
import BaseFormatterConfig from '../formatterConfig/base-formatter-config';
|
|
9
|
+
import TextFormatter from '../TextFormatter';
|
|
10
|
+
import { isArrayFormatColumn, isSimpleCellFormatter, isFunction, getFormulaArrayValue, convertValueToDtableLongTextValue } from '../FormulaFormatter/utils';
|
|
11
|
+
import cellValueValidator from '../FormulaFormatter/cell-value-validator';
|
|
12
|
+
import '../FormulaFormatter/index.css';
|
|
13
|
+
|
|
14
|
+
var RowExpandFormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
15
|
+
_inherits(RowExpandFormulaFormatter, _React$Component);
|
|
16
|
+
|
|
17
|
+
var _super = _createSuper(RowExpandFormulaFormatter);
|
|
18
|
+
|
|
19
|
+
function RowExpandFormulaFormatter() {
|
|
20
|
+
var _this;
|
|
21
|
+
|
|
22
|
+
_classCallCheck(this, RowExpandFormulaFormatter);
|
|
23
|
+
|
|
24
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
+
args[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
29
|
+
|
|
30
|
+
_this.renderBorder = function (dom) {
|
|
31
|
+
var column = _this.props.column;
|
|
32
|
+
var result_type = column.data.result_type;
|
|
33
|
+
var style = {
|
|
34
|
+
minHeight: '38px'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (result_type === FORMULA_RESULT_TYPE.DATE || result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
38
|
+
style = {
|
|
39
|
+
width: '320px'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: "d-flex align-items-center form-control disabled h-auto",
|
|
45
|
+
style: style
|
|
46
|
+
}, dom);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
_this.renderOtherColumnFormatter = function () {
|
|
50
|
+
var _this$props = _this.props,
|
|
51
|
+
value = _this$props.value,
|
|
52
|
+
column = _this$props.column,
|
|
53
|
+
collaborators = _this$props.collaborators;
|
|
54
|
+
var _column$data = column.data,
|
|
55
|
+
array_type = _column$data.array_type,
|
|
56
|
+
array_data = _column$data.array_data;
|
|
57
|
+
|
|
58
|
+
if (!array_type || array_type === CellType.LINK) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var Formatter = BaseFormatterConfig[array_type];
|
|
63
|
+
|
|
64
|
+
var formatterProps = _this.getFormatterProps(array_type, array_data, collaborators);
|
|
65
|
+
|
|
66
|
+
if (isArrayFormatColumn(array_type)) {
|
|
67
|
+
formatterProps.value = value;
|
|
68
|
+
return _this.renderBorder(_this.createColumnFormatter(Formatter, formatterProps));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var cellValue = value;
|
|
72
|
+
|
|
73
|
+
if (!Array.isArray(value)) {
|
|
74
|
+
cellValue = cellValueValidator(value, array_type) ? [value] : [];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return _this.renderBorder( /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
className: "dtable-ui formula-formatter multiple"
|
|
79
|
+
}, cellValue.map(function (v, index) {
|
|
80
|
+
formatterProps.value = v;
|
|
81
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: "formula-formatter-content-item ".concat(isSimpleCellFormatter(array_type) ? 'simple-cell-formatter' : ''),
|
|
83
|
+
key: "formula-formatter-content-item-".concat(index)
|
|
84
|
+
}, _this.createColumnFormatter(Formatter, formatterProps));
|
|
85
|
+
})));
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
_this.getFormatterProps = function (array_type, array_data, collaborators) {
|
|
89
|
+
switch (array_type) {
|
|
90
|
+
case CellType.DURATION:
|
|
91
|
+
{
|
|
92
|
+
var duration_format = array_data.duration_format;
|
|
93
|
+
return {
|
|
94
|
+
format: duration_format
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case CellType.NUMBER:
|
|
99
|
+
case CellType.RATE:
|
|
100
|
+
case CellType.GEOLOCATION:
|
|
101
|
+
{
|
|
102
|
+
return {
|
|
103
|
+
data: array_data
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
default:
|
|
108
|
+
{
|
|
109
|
+
return _objectSpread(_objectSpread({}, array_data), {}, {
|
|
110
|
+
collaborators: collaborators
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return _this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_createClass(RowExpandFormulaFormatter, [{
|
|
120
|
+
key: "createColumnFormatter",
|
|
121
|
+
value: function createColumnFormatter(Formatter, formatterProps) {
|
|
122
|
+
if (React.isValidElement(Formatter)) {
|
|
123
|
+
return React.cloneElement(Formatter, _objectSpread({}, formatterProps));
|
|
124
|
+
} else if (isFunction(Formatter)) {
|
|
125
|
+
return /*#__PURE__*/React.createElement(Formatter, formatterProps);
|
|
126
|
+
} else {
|
|
127
|
+
return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "render",
|
|
132
|
+
value: function render() {
|
|
133
|
+
var _this$props2 = this.props,
|
|
134
|
+
containerClassName = _this$props2.containerClassName,
|
|
135
|
+
column = _this$props2.column,
|
|
136
|
+
collaborators = _this$props2.collaborators,
|
|
137
|
+
value = _this$props2.value;
|
|
138
|
+
var data = column.data;
|
|
139
|
+
var array_type = data.array_type,
|
|
140
|
+
result_type = data.result_type;
|
|
141
|
+
|
|
142
|
+
if (Array.isArray(value)) {
|
|
143
|
+
value = getFormulaArrayValue(value);
|
|
144
|
+
|
|
145
|
+
if (array_type === CellType.DATE || result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
146
|
+
value = value.map(function (item) {
|
|
147
|
+
return item.replace('T', ' ').replace('Z', '');
|
|
148
|
+
});
|
|
149
|
+
} else if (array_type === CellType.LONG_TEXT) {
|
|
150
|
+
value = value.map(function (item) {
|
|
151
|
+
return convertValueToDtableLongTextValue(item);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
if (result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
156
|
+
value = value.replace('T', ' ').replace('Z', '');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
161
|
+
return this.renderOtherColumnFormatter();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (typeof value === 'object') {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
var formattedValue = getFormulaDisplayString(value, data, {
|
|
169
|
+
collaborators: collaborators
|
|
170
|
+
});
|
|
171
|
+
var className = "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName);
|
|
172
|
+
|
|
173
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
174
|
+
className = className + ' text-right';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return this.renderBorder( /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
className: className,
|
|
179
|
+
title: formattedValue,
|
|
180
|
+
"aria-label": formattedValue
|
|
181
|
+
}, formattedValue));
|
|
182
|
+
}
|
|
183
|
+
}]);
|
|
184
|
+
|
|
185
|
+
return RowExpandFormulaFormatter;
|
|
186
|
+
}(React.Component);
|
|
187
|
+
|
|
188
|
+
export { RowExpandFormulaFormatter as default };
|
|
@@ -7,7 +7,7 @@ import React, { Component } from 'react';
|
|
|
7
7
|
import { CellType } from '../constants';
|
|
8
8
|
import { MultipleSelectFormatter, DateFormatter, CTimeFormatter, MTimeFormatter } from '../index';
|
|
9
9
|
import CollaboratorItemFormatter from './collaborator-item-formatter';
|
|
10
|
-
import { getFormulaArrayValue,
|
|
10
|
+
import { getFormulaArrayValue, isArrayFormatColumn } from './utils';
|
|
11
11
|
import { getCellDisplayValue } from './value-display-utils';
|
|
12
12
|
import './index.css';
|
|
13
13
|
|
|
@@ -45,7 +45,7 @@ var RowExpandLinkFormatter = /*#__PURE__*/function (_Component) {
|
|
|
45
45
|
|
|
46
46
|
var displayColumnType = displayColumn.type,
|
|
47
47
|
displayColumnData = displayColumn.data;
|
|
48
|
-
var cellValue = getFormulaArrayValue(value, !
|
|
48
|
+
var cellValue = getFormulaArrayValue(value, !isArrayFormatColumn(displayColumnType));
|
|
49
49
|
|
|
50
50
|
if (!Array.isArray(cellValue) || cellValue.length === 0) {
|
|
51
51
|
return props.renderEmpty();
|
|
@@ -53,6 +53,6 @@ export var getTwoDimensionArrayValue = function getTwoDimensionArrayValue(value)
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
-
export function
|
|
56
|
+
export function isArrayFormatColumn(columnType) {
|
|
57
57
|
return [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR].includes(columnType);
|
|
58
58
|
}
|
package/lib/constants/index.js
CHANGED
|
@@ -17,6 +17,6 @@ var DATE_TYPES = {
|
|
|
17
17
|
'YYYY-MM-DD HH:mm': 'YYYY-MM-DD HH:mm'
|
|
18
18
|
};
|
|
19
19
|
var SIMPLE_CELL_COLUMNS = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.CTIME, CellType.MTIME, CellType.AUTO_NUMBER, CellType.URL, CellType.EMAIL, CellType.DURATION, CellType.CHECKBOX, CellType.RATE];
|
|
20
|
-
var
|
|
20
|
+
var ARRAY_FORMAT_COLUMNS = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
|
|
21
21
|
var SIMPLE_CELL_FORMULA_RESULTS = [FORMULA_RESULT_TYPE.NUMBER, FORMULA_RESULT_TYPE.STRING, FORMULA_RESULT_TYPE.DATE, FORMULA_RESULT_TYPE.BOOL];
|
|
22
|
-
export { CellType, NUMBER_TYPES, DATE_TYPES, FORMULA_RESULT_TYPE, SIMPLE_CELL_COLUMNS,
|
|
22
|
+
export { CellType, NUMBER_TYPES, DATE_TYPES, FORMULA_RESULT_TYPE, SIMPLE_CELL_COLUMNS, ARRAY_FORMAT_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS };
|
package/lib/index.js
CHANGED
|
@@ -40,6 +40,7 @@ export { default as RowExpandLinkFormatter } from './RowExpandLinkFormatter';
|
|
|
40
40
|
export { default as RowExpandRateFormatter } from './RowExpandRateFormatter';
|
|
41
41
|
export { default as RowExpandEmailFormatter } from './RowExpandEmailFormatter';
|
|
42
42
|
export { default as RowExpandUrlFormatter } from './RowExpandUrlFormatter';
|
|
43
|
+
export { default as RowExpandFormulaFormatter } from './RowExpandFormulaFormatter';
|
|
43
44
|
export { default as RowExpandFormatter } from './RowExpandFormatter'; // editor
|
|
44
45
|
|
|
45
46
|
export { default as TextEditor } from './TextEditor';
|