dtable-ui-component 0.1.83 → 0.1.84
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/es/components/cell-editor/date-editor.js +2 -2
- package/es/components/cell-editor/index.js +1 -1
- package/es/components/cell-editor/link-editor.js +4 -4
- package/es/components/cell-editor/number-editor.js +13 -13
- package/es/components/cell-formatter/creator-formatter.js +3 -3
- package/es/components/cell-formatter/date-formatter.js +2 -2
- package/es/components/cell-formatter/formatter-config.js +1 -1
- package/es/components/cell-formatter/formula-formatter.js +85 -94
- package/es/components/cell-formatter/geolocation-formatter.js +6 -3
- package/es/components/cell-formatter/index.js +2 -1
- package/es/components/cell-formatter/link-formatter.js +4 -4
- package/es/components/cell-formatter/multiple-select-formatter.js +9 -10
- package/es/components/cell-formatter/number-formatter.js +2 -2
- package/es/components/cell-formatter/rate-formatter.js +7 -2
- package/es/components/cell-formatter/text-formatter.js +22 -2
- package/es/components/common/images-lazy-load.js +2 -0
- package/es/{utils → constants}/cell-types.js +0 -0
- package/es/{utils/constants.js → constants/index.js} +8 -1
- package/es/index.js +4 -3
- package/es/utils/cell-value-validator.js +32 -0
- package/es/utils/column-utils.js +7 -0
- package/es/utils/value-format-utils.js +228 -14
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import MediaQuery from 'react-responsive';
|
|
7
7
|
import moment from 'moment';
|
|
8
|
-
import {
|
|
8
|
+
import { getDateDisplayString } from '../../utils/value-format-utils';
|
|
9
9
|
import PCDateEditorPopover from '../cell-editor-popover/pc-date-editor-popover';
|
|
10
10
|
import MBDateEditorPopover from '../cell-editor-popover/mb-date-editor-popover';
|
|
11
11
|
|
|
@@ -117,7 +117,7 @@ var DateEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
117
117
|
}, /*#__PURE__*/React.createElement("div", {
|
|
118
118
|
className: "form-control",
|
|
119
119
|
onClick: this.onDateEditorToggle
|
|
120
|
-
},
|
|
120
|
+
}, getDateDisplayString(newValue, dateFormat))), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
|
|
121
121
|
query: '(min-width: 768px)'
|
|
122
122
|
}, /*#__PURE__*/React.createElement(PCDateEditorPopover, {
|
|
123
123
|
lang: lang,
|
|
@@ -2,7 +2,7 @@ import "../../css/cell-editor.css";
|
|
|
2
2
|
export { default as NumberEditor } from './number-editor';
|
|
3
3
|
export { default as TextEditor } from './text-editor';
|
|
4
4
|
export { default as CheckboxEditor } from './checkbox-editor';
|
|
5
|
-
export { default as
|
|
5
|
+
export { default as SingleSelectEditor } from './single-select-editor';
|
|
6
6
|
export { default as MultipleSelectEditor } from './multiple-select-editor';
|
|
7
7
|
export { default as CollaboratorEditor } from './collaborator-editor';
|
|
8
8
|
export { default as LinkEditor } from './link-editor';
|
|
@@ -5,8 +5,8 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import MediaQuery from 'react-responsive';
|
|
7
7
|
import { getLocale } from '../../lang';
|
|
8
|
-
import * as CellTypes from '../../
|
|
9
|
-
import {
|
|
8
|
+
import * as CellTypes from '../../constants/cell-types';
|
|
9
|
+
import { getNumberDisplayString, getDateDisplayString } from '../../utils/value-format-utils';
|
|
10
10
|
import EditEditorButton from '../common/edit-editor-button';
|
|
11
11
|
import LinkEditorOption from '../common/link-editor-option';
|
|
12
12
|
import PCLinkEditorPopover from '../cell-editor-popover/pc-link-editor-popover';
|
|
@@ -82,13 +82,13 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
82
82
|
switch (type) {
|
|
83
83
|
case CellTypes.NUMBER:
|
|
84
84
|
{
|
|
85
|
-
return
|
|
85
|
+
return getNumberDisplayString(value, data);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
case CellTypes.DATE:
|
|
89
89
|
{
|
|
90
90
|
var format = data.format;
|
|
91
|
-
return
|
|
91
|
+
return getDateDisplayString(value, format);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
default:
|
|
@@ -4,18 +4,18 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import isHotkey from 'is-hotkey';
|
|
7
|
-
import { NUMBER_TYPES } from '../../
|
|
8
|
-
import {
|
|
7
|
+
import { NUMBER_TYPES } from '../../constants';
|
|
8
|
+
import { getNumberDisplayString, formatStringToNumber, formatNumberString } from '../../utils/value-format-utils';
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
_inherits(
|
|
10
|
+
var NumberEditor = /*#__PURE__*/function (_React$Component) {
|
|
11
|
+
_inherits(NumberEditor, _React$Component);
|
|
12
12
|
|
|
13
|
-
var _super = _createSuper(
|
|
13
|
+
var _super = _createSuper(NumberEditor);
|
|
14
14
|
|
|
15
|
-
function
|
|
15
|
+
function NumberEditor(props) {
|
|
16
16
|
var _this;
|
|
17
17
|
|
|
18
|
-
_classCallCheck(this,
|
|
18
|
+
_classCallCheck(this, NumberEditor);
|
|
19
19
|
|
|
20
20
|
_this = _super.call(this, props);
|
|
21
21
|
|
|
@@ -42,7 +42,7 @@ var NumebrEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
42
42
|
|
|
43
43
|
_this.props.onCommit(updated);
|
|
44
44
|
|
|
45
|
-
var newValue =
|
|
45
|
+
var newValue = getNumberDisplayString(value, column.data); // format the number to display
|
|
46
46
|
|
|
47
47
|
_this.setState({
|
|
48
48
|
isEditorShow: false,
|
|
@@ -107,7 +107,7 @@ var NumebrEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
107
107
|
_column = _this$props.column;
|
|
108
108
|
var dataFormat = _column.data && _column.data.format;
|
|
109
109
|
_this.dataFormat = dataFormat || NUMBER_TYPES.NUMBER;
|
|
110
|
-
var initValue =
|
|
110
|
+
var initValue = getNumberDisplayString(_value, _column.data); // format the number to display
|
|
111
111
|
|
|
112
112
|
_this.state = {
|
|
113
113
|
inputValue: initValue,
|
|
@@ -117,7 +117,7 @@ var NumebrEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
117
117
|
return _this;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
_createClass(
|
|
120
|
+
_createClass(NumberEditor, [{
|
|
121
121
|
key: "render",
|
|
122
122
|
value: function render() {
|
|
123
123
|
var style = this.getStyle();
|
|
@@ -144,11 +144,11 @@ var NumebrEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
144
144
|
}
|
|
145
145
|
}]);
|
|
146
146
|
|
|
147
|
-
return
|
|
147
|
+
return NumberEditor;
|
|
148
148
|
}(React.Component);
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
NumberEditor.defaultProps = {
|
|
151
151
|
isReadOnly: false,
|
|
152
152
|
value: ''
|
|
153
153
|
};
|
|
154
|
-
export default
|
|
154
|
+
export default NumberEditor;
|
|
@@ -4,14 +4,14 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import cn from 'astro-classname';
|
|
7
|
-
import
|
|
7
|
+
import CollaboratorItem from '../common/collaborator-item';
|
|
8
8
|
import DefaultAvatar from '../../assets/images/avatar/default_avatar.png';
|
|
9
9
|
|
|
10
10
|
// there will be there conditions
|
|
11
11
|
// 1 value is not exist, typeof value is array, but it's length is 0
|
|
12
12
|
// 2 value is exist, but can't find in collaborators
|
|
13
13
|
// 3 value is exist, typeof value is a string
|
|
14
|
-
// 4
|
|
14
|
+
// 4 value is exist, typeof value is array
|
|
15
15
|
var CreatorFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
16
16
|
_inherits(CreatorFormatter, _React$PureComponent);
|
|
17
17
|
|
|
@@ -50,7 +50,7 @@ var CreatorFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
;
|
|
53
|
-
return /*#__PURE__*/React.createElement(
|
|
53
|
+
return /*#__PURE__*/React.createElement(CollaboratorItem, {
|
|
54
54
|
key: index,
|
|
55
55
|
collaborator: collaborator
|
|
56
56
|
});
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import cn from 'astro-classname';
|
|
7
|
-
import {
|
|
7
|
+
import { getDateDisplayString } from '../../utils/value-format-utils';
|
|
8
8
|
|
|
9
9
|
var DateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
10
10
|
_inherits(DateFormatter, _React$Component);
|
|
@@ -23,7 +23,7 @@ var DateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
23
23
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
24
|
|
|
25
25
|
_this.formatDate = function (date, format) {
|
|
26
|
-
return
|
|
26
|
+
return getDateDisplayString(date, format);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
return _this;
|
|
@@ -3,7 +3,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
3
3
|
var _FormatterConfig;
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import * as CellTypes from '../../
|
|
6
|
+
import * as CellTypes from '../../constants/cell-types';
|
|
7
7
|
import CheckboxFormatter from './checkbox-formatter';
|
|
8
8
|
import ImageFormatter from './image-formatter';
|
|
9
9
|
import LongTextFormatter from './long-text-formatter';
|
|
@@ -4,15 +4,14 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import
|
|
8
|
-
import { FORMULA_RESULT_TYPE } from '../../utils/constants';
|
|
7
|
+
import { FORMULA_RESULT_TYPE } from '../../constants';
|
|
9
8
|
import cellFormatterFactory from '../cell-factory/cell-formatter-factory';
|
|
10
|
-
import * as
|
|
11
|
-
import { formatNumberToString, formatDateToString } from '../../utils/value-format-utils';
|
|
9
|
+
import * as CellType from '../../constants/cell-types';
|
|
12
10
|
import { isFunction } from '../../utils/utils';
|
|
13
11
|
import TextFormatter from './text-formatter';
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import { isArrayFormalColumn, isSimpleCellFormatter } from '../../utils/column-utils';
|
|
13
|
+
import cellValueValidator from '../../utils/cell-value-validator';
|
|
14
|
+
import { getFormulaDisplayString } from '../../utils/value-format-utils';
|
|
16
15
|
|
|
17
16
|
var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
18
17
|
_inherits(FormulaFormatter, _React$Component);
|
|
@@ -30,125 +29,116 @@ var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
30
29
|
|
|
31
30
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
32
31
|
|
|
33
|
-
_this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
value: value
|
|
37
|
-
};
|
|
38
|
-
var columnType = column.type;
|
|
39
|
-
var Formatter = cellFormatterFactory.createFormatter(columnType);
|
|
40
|
-
|
|
41
|
-
switch (columnType) {
|
|
42
|
-
case CellTypes.NUMBER:
|
|
43
|
-
{
|
|
44
|
-
formatterProps.data = column.data;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
case CellTypes.DATE:
|
|
49
|
-
{
|
|
50
|
-
formatterProps.format = column.format;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
case CellTypes.SINGLE_SELECT:
|
|
55
|
-
case CellTypes.MULTIPLE_SELECT:
|
|
56
|
-
{
|
|
57
|
-
formatterProps.options = column.data.options;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
case CellTypes.COLLABORATOR:
|
|
32
|
+
_this.getGridCellClassName = function (resultType) {
|
|
33
|
+
switch (resultType) {
|
|
34
|
+
case FORMULA_RESULT_TYPE.NUMBER:
|
|
62
35
|
{
|
|
63
|
-
|
|
64
|
-
break;
|
|
36
|
+
return 'text-right';
|
|
65
37
|
}
|
|
66
38
|
|
|
67
|
-
|
|
68
|
-
case CellTypes.LINK_FORMULA:
|
|
39
|
+
default:
|
|
69
40
|
{
|
|
70
|
-
|
|
71
|
-
Formatter = FormulaFormatter;
|
|
41
|
+
return '';
|
|
72
42
|
}
|
|
73
43
|
}
|
|
74
|
-
|
|
75
|
-
if (React.isValidElement(Formatter)) {
|
|
76
|
-
return React.cloneElement(Formatter, _objectSpread({}, formatterProps));
|
|
77
|
-
} else if (isFunction(Formatter)) {
|
|
78
|
-
return /*#__PURE__*/React.createElement(Formatter, formatterProps);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
|
|
82
44
|
};
|
|
83
45
|
|
|
84
46
|
_this.renderOtherColumnFormatter = function () {
|
|
85
47
|
var _this$props = _this.props,
|
|
86
48
|
value = _this$props.value,
|
|
87
49
|
column = _this$props.column,
|
|
88
|
-
|
|
50
|
+
collaborators = _this$props.collaborators;
|
|
89
51
|
var columnData = column.data;
|
|
52
|
+
var array_type = columnData.array_type,
|
|
53
|
+
array_data = columnData.array_data;
|
|
90
54
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
55
|
+
if (!array_type || array_type === CellType.LINK) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
94
58
|
|
|
95
|
-
var
|
|
96
|
-
return table._id === linked_table_id;
|
|
97
|
-
});
|
|
98
|
-
if (!linkedTable) return null;
|
|
99
|
-
var linkedColumn = linkedTable.columns.find(function (column) {
|
|
100
|
-
return column.key === display_column_key;
|
|
101
|
-
});
|
|
102
|
-
if (!linkedColumn) return null;
|
|
103
|
-
var linkedColumnType = linkedColumn.type;
|
|
59
|
+
var Formatter = cellFormatterFactory.createFormatter(array_type);
|
|
104
60
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return
|
|
110
|
-
className: "dtable-ui formula-formatter multiple"
|
|
111
|
-
}, value.map(function (v, index) {
|
|
112
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
113
|
-
className: contentItemClassName,
|
|
114
|
-
key: "formula-formatter-content-item-".concat(index)
|
|
115
|
-
}, _this.getOtherColumnFormatter(v, linkedColumn));
|
|
116
|
-
}));
|
|
61
|
+
var formatterProps = _this.getFormatterProps(array_type, array_data, collaborators);
|
|
62
|
+
|
|
63
|
+
if (isArrayFormalColumn(array_type)) {
|
|
64
|
+
formatterProps.value = value;
|
|
65
|
+
return _this.createColumnFormatter(Formatter, formatterProps);
|
|
117
66
|
}
|
|
118
67
|
|
|
119
|
-
|
|
120
|
-
};
|
|
68
|
+
var _isSimpleCellFormatterColumn = isSimpleCellFormatter(array_type);
|
|
121
69
|
|
|
122
|
-
|
|
123
|
-
if (!columnData) return '';
|
|
124
|
-
var result_type = columnData.result_type;
|
|
70
|
+
var cellValue = value;
|
|
125
71
|
|
|
126
|
-
if (
|
|
127
|
-
cellValue =
|
|
128
|
-
return formatNumberToString(cellValue, columnData);
|
|
129
|
-
} else if (result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
130
|
-
var format = columnData.format;
|
|
131
|
-
return formatDateToString(cellValue, format);
|
|
72
|
+
if (!Array.isArray(value)) {
|
|
73
|
+
cellValue = cellValueValidator(value, array_type) ? [value] : [];
|
|
132
74
|
}
|
|
133
75
|
|
|
134
|
-
var
|
|
135
|
-
return
|
|
76
|
+
var contentItemClassName = "formula-formatter-content-item ".concat(_isSimpleCellFormatterColumn ? 'simple-cell-formatter' : '');
|
|
77
|
+
return /*#__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: contentItemClassName,
|
|
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
|
+
}
|
|
136
114
|
};
|
|
137
115
|
|
|
138
116
|
return _this;
|
|
139
117
|
}
|
|
140
118
|
|
|
141
119
|
_createClass(FormulaFormatter, [{
|
|
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
|
+
}
|
|
127
|
+
|
|
128
|
+
return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
142
131
|
key: "render",
|
|
143
132
|
value: function render() {
|
|
144
133
|
var _this$props2 = this.props,
|
|
145
134
|
value = _this$props2.value,
|
|
146
135
|
containerClassName = _this$props2.containerClassName,
|
|
147
|
-
column = _this$props2.column
|
|
136
|
+
column = _this$props2.column,
|
|
137
|
+
collaborators = _this$props2.collaborators;
|
|
148
138
|
var columnData = column.data;
|
|
149
139
|
var resultType = columnData.result_type;
|
|
150
140
|
|
|
151
|
-
if (resultType === FORMULA_RESULT_TYPE.
|
|
141
|
+
if (resultType === FORMULA_RESULT_TYPE.ARRAY) {
|
|
152
142
|
return this.renderOtherColumnFormatter();
|
|
153
143
|
}
|
|
154
144
|
|
|
@@ -156,13 +146,14 @@ var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
156
146
|
return null;
|
|
157
147
|
}
|
|
158
148
|
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
|
|
149
|
+
var gridCellClassName = this.getGridCellClassName(resultType);
|
|
150
|
+
var formattedValue = getFormulaDisplayString(value, columnData, {
|
|
151
|
+
collaborators: collaborators
|
|
162
152
|
});
|
|
163
|
-
var formattedValue = this.getFormattedValue(value, columnData);
|
|
164
153
|
return /*#__PURE__*/React.createElement("div", {
|
|
165
|
-
className:
|
|
154
|
+
className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
|
|
155
|
+
title: formattedValue,
|
|
156
|
+
"aria-label": formattedValue
|
|
166
157
|
}, formattedValue);
|
|
167
158
|
}
|
|
168
159
|
}]);
|
|
@@ -4,6 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import cn from 'astro-classname';
|
|
7
|
+
import { getGeolocationDisplayString } from '../../utils/value-format-utils';
|
|
7
8
|
|
|
8
9
|
var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
9
10
|
_inherits(GeolocationFormatter, _React$Component);
|
|
@@ -21,16 +22,17 @@ var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
21
22
|
value: function render() {
|
|
22
23
|
var _this$props = this.props,
|
|
23
24
|
value = _this$props.value,
|
|
25
|
+
data = _this$props.data,
|
|
24
26
|
containerClassName = _this$props.containerClassName;
|
|
25
|
-
var
|
|
27
|
+
var className = cn('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
|
|
26
28
|
|
|
27
29
|
if (typeof value !== 'object') {
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
-
className:
|
|
33
|
-
},
|
|
34
|
+
className: className
|
|
35
|
+
}, getGeolocationDisplayString(value, data));
|
|
34
36
|
}
|
|
35
37
|
}]);
|
|
36
38
|
|
|
@@ -44,6 +46,7 @@ GeolocationFormatter.defaultProps = {
|
|
|
44
46
|
district: '',
|
|
45
47
|
detail: ''
|
|
46
48
|
},
|
|
49
|
+
data: {},
|
|
47
50
|
containerClassName: ''
|
|
48
51
|
};
|
|
49
52
|
export default GeolocationFormatter;
|
|
@@ -23,4 +23,5 @@ export { default as DurationFormatter } from './duration-formatter';
|
|
|
23
23
|
export { default as RateFormatter } from './rate-formatter';
|
|
24
24
|
export { default as ButtonFormatter } from './button-formatter';
|
|
25
25
|
export { default as FileItemFormatter } from './widgets/file-item-formatter';
|
|
26
|
-
export { default as ImagePreviewerLightbox } from './widgets/image-previewer-lightbox';
|
|
26
|
+
export { default as ImagePreviewerLightbox } from './widgets/image-previewer-lightbox';
|
|
27
|
+
export { default as CollaboratorItem } from '../common/collaborator-item';
|
|
@@ -5,8 +5,8 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
5
5
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import cn from 'astro-classname';
|
|
8
|
-
import * as CellTypes from '../../
|
|
9
|
-
import {
|
|
8
|
+
import * as CellTypes from '../../constants/cell-types';
|
|
9
|
+
import { getNumberDisplayString, getDateDisplayString } from '../../utils/value-format-utils';
|
|
10
10
|
|
|
11
11
|
// link value is get form parant's interface
|
|
12
12
|
var LinkFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -88,13 +88,13 @@ var LinkFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
88
88
|
switch (type) {
|
|
89
89
|
case CellTypes.NUMBER:
|
|
90
90
|
{
|
|
91
|
-
return
|
|
91
|
+
return getNumberDisplayString(value, data);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
case CellTypes.DATE:
|
|
95
95
|
{
|
|
96
96
|
var format = data.format;
|
|
97
|
-
return
|
|
97
|
+
return getDateDisplayString(value, format);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
default:
|
|
@@ -26,17 +26,16 @@ var MultipleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
26
26
|
var _this$props = _this.props,
|
|
27
27
|
value = _this$props.value,
|
|
28
28
|
options = _this$props.options;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (!Array.isArray(value) || !Array.isArray(options)) return [];
|
|
30
|
+
var selectedOptions = options.filter(function (option) {
|
|
31
|
+
return value.includes(option.id) || value.includes(option.name);
|
|
32
|
+
});
|
|
33
|
+
if (selectedOptions.length === 0) return [];
|
|
34
|
+
return selectedOptions.map(function (option) {
|
|
35
|
+
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
36
|
+
key: "multiple-".concat(option.id),
|
|
37
|
+
option: option
|
|
32
38
|
});
|
|
33
|
-
|
|
34
|
-
if (option) {
|
|
35
|
-
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
36
|
-
key: item,
|
|
37
|
-
option: option
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
39
|
});
|
|
41
40
|
};
|
|
42
41
|
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import cn from 'astro-classname';
|
|
7
|
-
import {
|
|
7
|
+
import { getNumberDisplayString } from '../../utils/value-format-utils';
|
|
8
8
|
|
|
9
9
|
var NumberFormatter = /*#__PURE__*/function (_React$Component) {
|
|
10
10
|
_inherits(NumberFormatter, _React$Component);
|
|
@@ -27,7 +27,7 @@ var NumberFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
27
27
|
var classname = cn('dtable-ui cell-formatter-container number-formatter', containerClassName);
|
|
28
28
|
|
|
29
29
|
if (number || number === 0) {
|
|
30
|
-
number =
|
|
30
|
+
number = getNumberDisplayString(number, data);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -25,8 +25,13 @@ var RateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
25
25
|
var _this$props = _this.props,
|
|
26
26
|
data = _this$props.data,
|
|
27
27
|
value = _this$props.value;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
var _ref = data || {},
|
|
30
|
+
_ref$rate_max_number = _ref.rate_max_number,
|
|
31
|
+
rate_max_number = _ref$rate_max_number === void 0 ? 5 : _ref$rate_max_number,
|
|
32
|
+
_ref$rate_style_color = _ref.rate_style_color,
|
|
33
|
+
rate_style_color = _ref$rate_style_color === void 0 ? '#e5e5e5' : _ref$rate_style_color;
|
|
34
|
+
|
|
30
35
|
var validValue = Math.min(rate_max_number, value);
|
|
31
36
|
var rateList = [];
|
|
32
37
|
|
|
@@ -11,9 +11,29 @@ var TextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
11
11
|
var _super = _createSuper(TextFormatter);
|
|
12
12
|
|
|
13
13
|
function TextFormatter() {
|
|
14
|
+
var _this;
|
|
15
|
+
|
|
14
16
|
_classCallCheck(this, TextFormatter);
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19
|
+
args[_key] = arguments[_key];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
23
|
+
|
|
24
|
+
_this.getFormattedValue = function (val) {
|
|
25
|
+
if (typeof val === 'object') {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (Object.prototype.toString.call(val) === '[object Boolean]') {
|
|
30
|
+
return val + '';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return val;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return _this;
|
|
17
37
|
}
|
|
18
38
|
|
|
19
39
|
_createClass(TextFormatter, [{
|
|
@@ -25,7 +45,7 @@ var TextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
25
45
|
var classname = cn('dtable-ui cell-formatter-container text-formatter', containerClassName);
|
|
26
46
|
return /*#__PURE__*/React.createElement("div", {
|
|
27
47
|
className: classname
|
|
28
|
-
}, value);
|
|
48
|
+
}, this.getFormattedValue(value));
|
|
29
49
|
}
|
|
30
50
|
}]);
|
|
31
51
|
|
|
File without changes
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
var _DURATION_ZERO_DISPLA, _DURATION_DECIMAL_DIG;
|
|
4
4
|
|
|
5
|
+
import * as CellType from './cell-types';
|
|
5
6
|
export var NUMBER_TYPES = {
|
|
6
7
|
'NUMBER': 'number',
|
|
7
8
|
'NUMBER_WITH_COMMAS': 'number-with-commas',
|
|
@@ -23,9 +24,15 @@ export var FORMULA_RESULT_TYPE = {
|
|
|
23
24
|
STRING: 'string',
|
|
24
25
|
DATE: 'date',
|
|
25
26
|
BOOL: 'bool',
|
|
26
|
-
|
|
27
|
+
ARRAY: 'array'
|
|
27
28
|
};
|
|
29
|
+
export var SIMPLE_CELL_COLUMNS = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.CTIME, CellType.MTIME, CellType.GEOLOCATION, CellType.AUTO_NUMBER, CellType.URL, CellType.EMAIL, CellType.DURATION, CellType.CHECKBOX, CellType.RATE];
|
|
30
|
+
export var ARRAY_FORMAL_COLUMNS = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
|
|
31
|
+
export var SIMPLE_CELL_FORMULA_RESULTS = [FORMULA_RESULT_TYPE.NUMBER, FORMULA_RESULT_TYPE.STRING, FORMULA_RESULT_TYPE.DATE, FORMULA_RESULT_TYPE.BOOL];
|
|
32
|
+
export var COLLABORATOR_COLUMN_TYPES = [CellType.COLLABORATOR, CellType.CREATOR, CellType.LAST_MODIFIER];
|
|
33
|
+
export var ARRAY_FORMAL_COLUMNS_TYPES = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
|
|
28
34
|
export var DEFAULT_NUMBER_FORMAT = 'number';
|
|
35
|
+
export var DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
|
|
29
36
|
export var DURATION_FORMATS_MAP = {
|
|
30
37
|
H_MM: 'h:mm',
|
|
31
38
|
H_MM_SS: 'h:mm:ss'
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export { default as toaster } from './components/toast';
|
|
1
2
|
export { setLocale } from './lang';
|
|
2
|
-
export {
|
|
3
|
+
export { getDateDisplayString, getNumberDisplayString, formatStringToNumber, formatNumberString } from './utils/value-format-utils';
|
|
3
4
|
export { default as Loading } from './components/loading';
|
|
4
|
-
export { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, ImageFormatter, FileFormatter, LongTextFormatter, GeolocationFormatter, LinkFormatter, FormulaFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, UrlFormatter, EmailFormatter, DurationFormatter, RateFormatter, ButtonFormatter, FileItemFormatter, ImagePreviewerLightbox } from './components/cell-formatter';
|
|
5
|
-
export { TextEditor, NumberEditor, CheckboxEditor,
|
|
5
|
+
export { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, ImageFormatter, FileFormatter, LongTextFormatter, GeolocationFormatter, LinkFormatter, FormulaFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, UrlFormatter, EmailFormatter, DurationFormatter, RateFormatter, ButtonFormatter, FileItemFormatter, ImagePreviewerLightbox, CollaboratorItem } from './components/cell-formatter';
|
|
6
|
+
export { TextEditor, NumberEditor, CheckboxEditor, SingleSelectEditor, CollaboratorEditor, DateEditor, LinkEditor } from './components/cell-editor';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
3
|
+
var _validators;
|
|
4
|
+
|
|
5
|
+
import * as CellType from '../constants/cell-types';
|
|
6
|
+
import { FORMULA_RESULT_TYPE } from '../constants';
|
|
7
|
+
|
|
8
|
+
var numberValidator = function numberValidator(value) {
|
|
9
|
+
return (value || value === 0) && Object.prototype.toString.call(value) === '[object Number]';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
var textValidator = function textValidator(value) {
|
|
13
|
+
return !!value;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var checkboxValidator = function checkboxValidator(value) {
|
|
17
|
+
return typeof value === 'boolean';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var validators = (_validators = {}, _defineProperty(_validators, CellType.NUMBER, numberValidator), _defineProperty(_validators, CellType.RATE, numberValidator), _defineProperty(_validators, CellType.DURATION, numberValidator), _defineProperty(_validators, CellType.CHECKBOX, checkboxValidator), _defineProperty(_validators, CellType.TEXT, textValidator), _defineProperty(_validators, CellType.DATE, textValidator), _defineProperty(_validators, CellType.CTIME, textValidator), _defineProperty(_validators, CellType.MTIME, textValidator), _defineProperty(_validators, CellType.GEOLOCATION, textValidator), _defineProperty(_validators, CellType.AUTO_NUMBER, textValidator), _defineProperty(_validators, CellType.URL, textValidator), _defineProperty(_validators, CellType.EMAIL, textValidator), _defineProperty(_validators, FORMULA_RESULT_TYPE.DATE, textValidator), _defineProperty(_validators, FORMULA_RESULT_TYPE.STRING, textValidator), _defineProperty(_validators, FORMULA_RESULT_TYPE.NUMBER, numberValidator), _defineProperty(_validators, FORMULA_RESULT_TYPE.BOOL, checkboxValidator), _validators);
|
|
21
|
+
|
|
22
|
+
var cellValueValidator = function cellValueValidator(cellValue, type) {
|
|
23
|
+
var validator = validators[type];
|
|
24
|
+
|
|
25
|
+
if (validator) {
|
|
26
|
+
return validator(cellValue);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default cellValueValidator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ARRAY_FORMAL_COLUMNS, SIMPLE_CELL_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS } from '../constants';
|
|
2
|
+
export function isSimpleCellFormatter(type) {
|
|
3
|
+
return SIMPLE_CELL_COLUMNS.includes(type) || SIMPLE_CELL_FORMULA_RESULTS.includes(type);
|
|
4
|
+
}
|
|
5
|
+
export function isArrayFormalColumn(columnType) {
|
|
6
|
+
return ARRAY_FORMAL_COLUMNS.includes(columnType);
|
|
7
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
2
|
import NP from './number-precision';
|
|
3
|
-
import { NUMBER_TYPES, DEFAULT_NUMBER_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS } from '
|
|
3
|
+
import { NUMBER_TYPES, DEFAULT_NUMBER_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_DATE_FORMAT } from '../constants';
|
|
4
|
+
import * as CellType from '../constants/cell-types';
|
|
4
5
|
NP.enableBoundaryChecking(false);
|
|
5
6
|
var _separatorMap = {
|
|
6
7
|
'comma': ',',
|
|
@@ -66,7 +67,7 @@ var _getDecimalDigits = function _getDecimalDigits(num) {
|
|
|
66
67
|
return digitsLength > 8 ? 8 : digitsLength;
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
export var
|
|
70
|
+
export var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
|
|
70
71
|
// formatData: old version maybe 'null'
|
|
71
72
|
var type = Object.prototype.toString.call(value);
|
|
72
73
|
|
|
@@ -122,42 +123,42 @@ export var formatStringToNumber = function formatStringToNumber(value) {
|
|
|
122
123
|
return isNaN(newData) ? '' : newData;
|
|
123
124
|
};
|
|
124
125
|
export var formatNumberString = function formatNumberString(value, format) {
|
|
125
|
-
var
|
|
126
|
+
var formattedValue = '';
|
|
126
127
|
|
|
127
128
|
switch (format) {
|
|
128
129
|
case NUMBER_TYPES.NUMBER:
|
|
129
130
|
case NUMBER_TYPES.NUMBER_WITH_COMMAS:
|
|
130
|
-
|
|
131
|
+
formattedValue = value.replace(/[^.-\d,]/g, '');
|
|
131
132
|
break;
|
|
132
133
|
|
|
133
134
|
case NUMBER_TYPES.PERCENT:
|
|
134
|
-
|
|
135
|
+
formattedValue = value.replace(/[^.-\d,%]/g, '');
|
|
135
136
|
break;
|
|
136
137
|
|
|
137
138
|
case NUMBER_TYPES.YUAN:
|
|
138
|
-
|
|
139
|
+
formattedValue = value.replace(/[^.-\d¥,]/g, '');
|
|
139
140
|
break;
|
|
140
141
|
|
|
141
142
|
case NUMBER_TYPES.DOLLAR:
|
|
142
|
-
|
|
143
|
+
formattedValue = value.replace(/[^.-\d$,]/g, '');
|
|
143
144
|
break;
|
|
144
145
|
|
|
145
146
|
case NUMBER_TYPES.EURO:
|
|
146
|
-
|
|
147
|
+
formattedValue = value.replace(/[^.-\d€,]/g, '');
|
|
147
148
|
break;
|
|
148
149
|
|
|
149
150
|
default:
|
|
150
|
-
|
|
151
|
+
formattedValue = value.replace(/[^.-\d,]/g, '');
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
return
|
|
154
|
+
return formattedValue;
|
|
154
155
|
};
|
|
155
|
-
export var
|
|
156
|
-
var
|
|
156
|
+
export var getDateDisplayString = function getDateDisplayString(value, format) {
|
|
157
|
+
var formattedValue = '';
|
|
157
158
|
|
|
158
159
|
if (!value) {
|
|
159
160
|
// value === '', value === undefine, value === null
|
|
160
|
-
return
|
|
161
|
+
return formattedValue;
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
var date = moment(value);
|
|
@@ -278,4 +279,217 @@ var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format
|
|
|
278
279
|
}
|
|
279
280
|
|
|
280
281
|
return '';
|
|
281
|
-
};
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export var getOptionName = function getOptionName(options, targetOptionID) {
|
|
285
|
+
if (!targetOptionID || !options || !Array.isArray(options)) return null;
|
|
286
|
+
var option = options.find(function (option) {
|
|
287
|
+
return option.id === targetOptionID;
|
|
288
|
+
});
|
|
289
|
+
return option ? option.name : null;
|
|
290
|
+
};
|
|
291
|
+
export var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
|
|
292
|
+
if (!cellVal || !options || !Array.isArray(options)) return null;
|
|
293
|
+
var selectedOptions = options.filter(function (option) {
|
|
294
|
+
return cellVal.includes(option.id);
|
|
295
|
+
});
|
|
296
|
+
if (selectedOptions.length === 0) return null;
|
|
297
|
+
return selectedOptions.map(function (option) {
|
|
298
|
+
return option.name;
|
|
299
|
+
}).join(', ');
|
|
300
|
+
};
|
|
301
|
+
export var getLongtextDisplayString = function getLongtextDisplayString(value) {
|
|
302
|
+
var _ref3 = value || {},
|
|
303
|
+
text = _ref3.text;
|
|
304
|
+
|
|
305
|
+
if (!text) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return text;
|
|
310
|
+
};
|
|
311
|
+
export var getCollaboratorsName = function getCollaboratorsName(collaborators, cellVal) {
|
|
312
|
+
if (cellVal) {
|
|
313
|
+
var collaboratorsName = [];
|
|
314
|
+
cellVal.forEach(function (v) {
|
|
315
|
+
var collaborator = collaborators.find(function (c) {
|
|
316
|
+
return c.email === v;
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
if (collaborator) {
|
|
320
|
+
collaboratorsName.push(collaborator.name);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
if (collaboratorsName.length === 0) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return collaboratorsName.join(', ');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return null;
|
|
332
|
+
};
|
|
333
|
+
export var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
|
|
334
|
+
var _ref4 = columnData || {},
|
|
335
|
+
geo_format = _ref4.geo_format;
|
|
336
|
+
|
|
337
|
+
var cellValue = value || {};
|
|
338
|
+
|
|
339
|
+
if (!value) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (geo_format === 'lng_lat' && value.lng && value.lat) {
|
|
344
|
+
return "".concat(cellValue.lng, ", ").concat(cellValue.lat);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (geo_format === 'country_region' && cellValue.country_region) {
|
|
348
|
+
return value.country_region || '';
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var province = cellValue.province,
|
|
352
|
+
city = cellValue.city,
|
|
353
|
+
district = cellValue.district,
|
|
354
|
+
detail = cellValue.detail;
|
|
355
|
+
|
|
356
|
+
if (geo_format === 'province') {
|
|
357
|
+
return "".concat(province || '');
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (geo_format === 'province_city') {
|
|
361
|
+
return "".concat(province || '').concat(city || '');
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return "".concat(province || '').concat(city || '').concat(district || '').concat(detail || '');
|
|
365
|
+
};
|
|
366
|
+
export var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData) {
|
|
367
|
+
var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
368
|
+
_ref5$collaborators = _ref5.collaborators,
|
|
369
|
+
collaborators = _ref5$collaborators === void 0 ? [] : _ref5$collaborators;
|
|
370
|
+
|
|
371
|
+
if (!columnData) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
var result_type = columnData.result_type;
|
|
376
|
+
|
|
377
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
378
|
+
return getNumberDisplayString(cellValue, columnData);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
382
|
+
var format = columnData.format;
|
|
383
|
+
return getDateDisplayString(cellValue, format);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
387
|
+
var array_type = columnData.array_type,
|
|
388
|
+
array_data = columnData.array_data;
|
|
389
|
+
|
|
390
|
+
if (!array_type) {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
395
|
+
return cellValue;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (ARRAY_FORMAL_COLUMNS_TYPES.indexOf(array_type) < 0 && Array.isArray(cellValue)) {
|
|
399
|
+
return cellValue.map(function (val) {
|
|
400
|
+
return getCellValueDisplayString(val, array_type, {
|
|
401
|
+
data: array_data,
|
|
402
|
+
collaborators: collaborators
|
|
403
|
+
});
|
|
404
|
+
}).join(', ');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return getCellValueDisplayString(cellValue, array_type, {
|
|
408
|
+
data: array_data,
|
|
409
|
+
collaborators: collaborators
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (Object.prototype.toString.call(cellValue) === '[object Boolean]') {
|
|
414
|
+
return cellValue + '';
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return cellValue;
|
|
418
|
+
};
|
|
419
|
+
export function getCellValueDisplayString(cellValue, type) {
|
|
420
|
+
var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
421
|
+
data = _ref6.data,
|
|
422
|
+
_ref6$collaborators = _ref6.collaborators,
|
|
423
|
+
collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators;
|
|
424
|
+
|
|
425
|
+
var newData = data || {};
|
|
426
|
+
|
|
427
|
+
switch (type) {
|
|
428
|
+
case CellType.GEOLOCATION:
|
|
429
|
+
{
|
|
430
|
+
return getGeolocationDisplayString(cellValue, data);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
case CellType.SINGLE_SELECT:
|
|
434
|
+
{
|
|
435
|
+
if (!data) return '';
|
|
436
|
+
var options = newData.options;
|
|
437
|
+
return getOptionName(options, cellValue);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
case CellType.MULTIPLE_SELECT:
|
|
441
|
+
{
|
|
442
|
+
if (!data) return '';
|
|
443
|
+
var _options = newData.options;
|
|
444
|
+
return getMultipleOptionName(_options, cellValue);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
case CellType.FORMULA:
|
|
448
|
+
case CellType.LINK_FORMULA:
|
|
449
|
+
{
|
|
450
|
+
return getFormulaDisplayString(cellValue, newData, {
|
|
451
|
+
collaborators: collaborators
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
case CellType.LONG_TEXT:
|
|
456
|
+
{
|
|
457
|
+
return getLongtextDisplayString(cellValue);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
case CellType.NUMBER:
|
|
461
|
+
{
|
|
462
|
+
return getNumberDisplayString(cellValue, newData);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
case CellType.DATE:
|
|
466
|
+
{
|
|
467
|
+
var _ref7 = newData || {},
|
|
468
|
+
_ref7$format = _ref7.format,
|
|
469
|
+
format = _ref7$format === void 0 ? DEFAULT_DATE_FORMAT : _ref7$format;
|
|
470
|
+
|
|
471
|
+
return getDateDisplayString(cellValue, format);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
case CellType.CREATOR:
|
|
475
|
+
case CellType.LAST_MODIFIER:
|
|
476
|
+
{
|
|
477
|
+
return cellValue === 'anonymous' ? cellValue : getCollaboratorsName(collaborators, [cellValue]);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
case CellType.COLLABORATOR:
|
|
481
|
+
{
|
|
482
|
+
return getCollaboratorsName(collaborators, cellValue);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
case CellType.DURATION:
|
|
486
|
+
{
|
|
487
|
+
return getDurationDisplayString(cellValue, data);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
default:
|
|
491
|
+
{
|
|
492
|
+
return cellValue ? cellValue + '' : '';
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.84",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@seafile/react-image-lightbox": "0.0.9",
|
|
7
|
-
"@seafile/seafile-calendar": "^0.0.
|
|
7
|
+
"@seafile/seafile-calendar": "^0.0.19",
|
|
8
8
|
"antd-mobile": "^2.3.3",
|
|
9
9
|
"astro-classname": "^2.1.0",
|
|
10
10
|
"bail": "1.0.5",
|