dtable-ui-component 4.4.3-2 → 4.4.3-alpha1
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/AutoNumberFormatter/index.js +7 -14
- package/lib/ButtonFormatter/index.js +9 -16
- package/lib/CTimeFormatter/index.js +9 -16
- package/lib/CheckboxEditor/index.js +8 -15
- package/lib/CheckboxFormatter/index.js +8 -15
- package/lib/CollaboratorEditor/index.js +21 -29
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +25 -32
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +18 -25
- package/lib/CollaboratorFormatter/index.js +12 -19
- package/lib/CollaboratorItem/index.js +10 -17
- package/lib/CreatorFormatter/index.js +12 -19
- package/lib/DTableCommonAddTool/index.js +6 -13
- package/lib/DTableCustomizeCollaboratorSelect/index.js +18 -26
- package/lib/DTableCustomizeSelect/index.js +15 -23
- package/lib/DTableFiltersPopover/constants/index.js +33 -38
- package/lib/DTableFiltersPopover/index.js +31 -38
- package/lib/DTableFiltersPopover/utils/filter-item-utils.js +46 -53
- package/lib/DTableFiltersPopover/utils/index.js +99 -128
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +26 -34
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +25 -33
- package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +26 -34
- package/lib/DTableFiltersPopover/widgets/filter-calendar.js +26 -34
- package/lib/DTableFiltersPopover/widgets/filter-item.js +120 -128
- package/lib/DTableFiltersPopover/widgets/filter-list/index.js +18 -26
- package/lib/DTableFiltersPopover/widgets/rate-item.js +8 -15
- package/lib/DTablePopover/index.js +8 -15
- package/lib/DTablePopover/utils.js +2 -9
- package/lib/DTableRadio/index.js +10 -17
- package/lib/DTableSearchInput/index.js +13 -21
- package/lib/DTableSearchInput/utils.js +2 -9
- package/lib/DTableSelect/dtable-select-label.js +6 -13
- package/lib/DTableSelect/index.js +10 -18
- package/lib/DTableSelect/utils.js +10 -20
- package/lib/DTableSwitch/index.js +7 -14
- package/lib/DateEditor/index.js +22 -30
- package/lib/DateEditor/mb-date-editor-popover/index.js +47 -55
- package/lib/DateEditor/pc-date-editor-popover.js +20 -27
- package/lib/DateFormatter/index.js +9 -16
- package/lib/Department-editor/constants.js +1 -7
- package/lib/Department-editor/department-multiple-select/index.js +24 -32
- package/lib/Department-editor/department-single-select.js +33 -41
- package/lib/Department-editor/index.js +14 -22
- package/lib/Department-editor/selected-departments/index.js +25 -32
- package/lib/Department-editor/utils.js +3 -11
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -16
- package/lib/DigitalSignFormatter/index.js +15 -23
- package/lib/DigitalSignFormatter/utils.js +3 -11
- package/lib/DurationFormatter/index.js +9 -16
- package/lib/EditEditorButton/index.js +5 -12
- package/lib/EmailFormatter/index.js +7 -14
- package/lib/FieldDisplaySetting/field-item.js +14 -21
- package/lib/FieldDisplaySetting/index.js +19 -27
- package/lib/FileEditor/index.js +8 -15
- package/lib/FileEditor/pc-files-addition/index.js +0 -1
- package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
- package/lib/FileEditor/pc-files-preview/index.js +0 -1
- package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
- package/lib/FileFormatter/index.js +11 -19
- package/lib/FileItemFormatter/index.js +6 -14
- package/lib/FileItemFormatter/utils.js +2 -9
- package/lib/FileUploader/index.js +4 -11
- package/lib/FormulaFormatter/cell-value-validator.js +18 -24
- package/lib/FormulaFormatter/index.js +32 -39
- package/lib/FormulaFormatter/utils.js +13 -29
- package/lib/GeolocationFormatter/index.js +9 -16
- package/lib/HtmlLongTextFormatter/index.js +9 -17
- package/lib/HtmlLongTextFormatter/markdown2html.js +47 -0
- package/lib/HtmlLongTextFormatter/unified/index.js +400 -0
- package/lib/HtmlLongTextFormatter/vfile/core.js +155 -0
- package/lib/HtmlLongTextFormatter/vfile/index.js +40 -0
- package/lib/ImageFormatter/images-lazy-load.js +9 -16
- package/lib/ImageFormatter/index.js +16 -24
- package/lib/ImageFormatter/utils.js +2 -9
- package/lib/ImagePreviewerLightbox/index.js +12 -19
- package/lib/ImagePreviewerLightbox/utils.js +3 -11
- package/lib/LastModifierFormatter/index.js +12 -19
- package/lib/LinkEditor/index.js +25 -33
- package/lib/LinkEditor/link-editor-option.js +8 -15
- package/lib/LinkEditor/mb-link-editor-popover/index.js +23 -30
- package/lib/LinkEditor/pc-link-editor-popover/index.js +17 -24
- package/lib/LinkFormatter/index.js +13 -20
- package/lib/Loading/index.js +4 -11
- package/lib/LongTextFormatter/index.js +6 -13
- package/lib/MBEditorHeader/index.js +7 -14
- package/lib/MTimeFormatter/index.js +9 -16
- package/lib/ModalPortal/index.js +5 -12
- package/lib/MultipleSelectEditor/index.js +17 -25
- package/lib/MultipleSelectFormatter/index.js +10 -17
- package/lib/NotificationPopover/index.js +16 -24
- package/lib/NumberEditor/index.js +18 -25
- package/lib/NumberFormatter/index.js +9 -16
- package/lib/RateFormatter/index.js +8 -15
- package/lib/RoleStatusEditor/index.js +14 -22
- package/lib/RowExpandEmailFormatter/index.js +10 -17
- package/lib/RowExpandFileFormatter/index.js +8 -16
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +18 -27
- package/lib/RowExpandFormatter/index.js +78 -86
- package/lib/RowExpandFormulaFormatter/index.js +34 -42
- package/lib/RowExpandImageFormatter/index.js +10 -19
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +18 -27
- package/lib/RowExpandImageFormatter/utils.js +2 -9
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +7 -16
- package/lib/RowExpandLinkFormatter/index.js +37 -46
- package/lib/RowExpandLinkFormatter/utils.js +6 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +5 -12
- package/lib/RowExpandRateFormatter/index.js +8 -15
- package/lib/RowExpandUrlFormatter/index.js +14 -21
- package/lib/SelectItem/index.js +4 -12
- package/lib/SelectOptionGroup/KeyCodes.js +1 -7
- package/lib/SelectOptionGroup/index.js +33 -32
- package/lib/SelectOptionGroup/option.js +4 -19
- package/lib/SimpleLongTextFormatter/index.js +20 -27
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +1 -7
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +8 -15
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +7 -14
- package/lib/SingleSelectEditor/index.js +18 -26
- package/lib/SingleSelectFormatter/index.js +9 -16
- package/lib/TextEditor/index.js +7 -14
- package/lib/TextFormatter/index.js +7 -14
- package/lib/UrlFormatter/index.js +7 -14
- package/lib/cellFormatterFactory/index.js +4 -11
- package/lib/common/ClickOutside.js +4 -12
- package/lib/common/delete-tip.js +12 -20
- package/lib/common/modal-portal.js +5 -13
- package/lib/constants/index.js +9 -28
- package/lib/data/dtable-value.js +6 -11
- package/lib/formatterConfig/base-formatter-config.js +46 -53
- package/lib/formatterConfig/index.js +9 -16
- package/lib/hooks/common-hooks.js +4 -11
- package/lib/index.js +75 -432
- package/lib/lang/index.js +13 -24
- package/lib/locals/de.js +1 -7
- package/lib/locals/en.js +1 -7
- package/lib/locals/fr.js +1 -7
- package/lib/locals/zh-CN.js +1 -7
- package/lib/select-editor/index.js +4 -27
- package/lib/select-editor/mb-select-editor-popover/index.js +33 -41
- package/lib/select-editor/pc-select-editor-popover/index.js +19 -26
- package/lib/select-editor/select-editor-option.js +8 -15
- package/lib/toaster/alert.js +11 -18
- package/lib/toaster/index.js +3 -10
- package/lib/toaster/toast.js +8 -16
- package/lib/toaster/toastManager.js +5 -13
- package/lib/toaster/toaster.js +7 -15
- package/lib/utils/dayjs.js +4 -11
- package/lib/utils/editor-utils.js +5 -15
- package/lib/utils/event-bus.js +1 -7
- package/lib/utils/utils.js +6 -17
- package/package.json +77 -63
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _FileItemFormatter = _interopRequireDefault(require("../FileItemFormatter"));
|
|
11
|
-
require("./index.css");
|
|
12
|
-
class FileFormatter extends _react.default.PureComponent {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import FileItemFormatter from '../FileItemFormatter';
|
|
4
|
+
import './index.css';
|
|
5
|
+
export default class FileFormatter extends React.PureComponent {
|
|
13
6
|
render() {
|
|
14
7
|
let {
|
|
15
8
|
isSample,
|
|
@@ -19,28 +12,27 @@ class FileFormatter extends _react.default.PureComponent {
|
|
|
19
12
|
if (!Array.isArray(value) || value.length === 0) {
|
|
20
13
|
return null;
|
|
21
14
|
}
|
|
22
|
-
let className = (
|
|
15
|
+
let className = classnames('dtable-ui cell-formatter-container file-formatter', containerClassName);
|
|
23
16
|
if (isSample) {
|
|
24
17
|
let item = value[0];
|
|
25
|
-
return /*#__PURE__*/
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
19
|
className: className
|
|
27
|
-
}, /*#__PURE__*/
|
|
20
|
+
}, /*#__PURE__*/React.createElement(FileItemFormatter, {
|
|
28
21
|
file: item
|
|
29
|
-
}), value.length !== 1 && /*#__PURE__*/
|
|
22
|
+
}), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
|
|
30
23
|
className: "file-item-count"
|
|
31
24
|
}, "+".concat(value.length)));
|
|
32
25
|
}
|
|
33
|
-
return /*#__PURE__*/
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
34
27
|
className: className
|
|
35
28
|
}, value.map((item, index) => {
|
|
36
|
-
return /*#__PURE__*/
|
|
29
|
+
return /*#__PURE__*/React.createElement(FileItemFormatter, {
|
|
37
30
|
file: item,
|
|
38
31
|
key: index
|
|
39
32
|
});
|
|
40
33
|
}));
|
|
41
34
|
}
|
|
42
35
|
}
|
|
43
|
-
exports.default = FileFormatter;
|
|
44
36
|
FileFormatter.defaultProps = {
|
|
45
37
|
isSample: false,
|
|
46
38
|
value: [],
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _utils = require("./utils");
|
|
10
|
-
class FileItemFormatter extends _react.Component {
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { getFileIconUrl } from './utils';
|
|
3
|
+
export default class FileItemFormatter extends Component {
|
|
11
4
|
constructor() {
|
|
12
5
|
super(...arguments);
|
|
13
6
|
this.getFileIconData = item => {
|
|
14
|
-
let fileIconUrl =
|
|
7
|
+
let fileIconUrl = getFileIconUrl(item.name, item.type);
|
|
15
8
|
let fileIconData = require('./' + fileIconUrl);
|
|
16
9
|
return fileIconData;
|
|
17
10
|
};
|
|
@@ -20,11 +13,10 @@ class FileItemFormatter extends _react.Component {
|
|
|
20
13
|
const {
|
|
21
14
|
file
|
|
22
15
|
} = this.props;
|
|
23
|
-
return /*#__PURE__*/
|
|
16
|
+
return /*#__PURE__*/React.createElement("img", {
|
|
24
17
|
className: "file-item-icon",
|
|
25
18
|
src: this.getFileIconData(file),
|
|
26
19
|
alt: file.name
|
|
27
20
|
});
|
|
28
21
|
}
|
|
29
|
-
}
|
|
30
|
-
exports.default = FileItemFormatter;
|
|
22
|
+
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getFileIconUrl = void 0;
|
|
7
1
|
const FILEEXT_ICON_MAP = {
|
|
8
2
|
// text file
|
|
9
3
|
md: 'txt.png',
|
|
@@ -52,7 +46,7 @@ const FILEEXT_ICON_MAP = {
|
|
|
52
46
|
// default
|
|
53
47
|
default: 'file.png'
|
|
54
48
|
};
|
|
55
|
-
const getFileIconUrl = (filename, direntType) => {
|
|
49
|
+
export const getFileIconUrl = (filename, direntType) => {
|
|
56
50
|
if (typeof direntType === 'string' && direntType === 'dir') {
|
|
57
51
|
return 'assets/folder/' + FILEEXT_ICON_MAP['folder'];
|
|
58
52
|
}
|
|
@@ -63,5 +57,4 @@ const getFileIconUrl = (filename, direntType) => {
|
|
|
63
57
|
const file_ext = typeof filename === 'string' && filename.slice(identifierIndex + 1).toLowerCase() || 'default';
|
|
64
58
|
const iconUrl = FILEEXT_ICON_MAP[file_ext] ? 'assets/file/192/' + FILEEXT_ICON_MAP[file_ext] : 'assets/file/192/' + FILEEXT_ICON_MAP['default'];
|
|
65
59
|
return iconUrl;
|
|
66
|
-
};
|
|
67
|
-
exports.getFileIconUrl = getFileIconUrl;
|
|
60
|
+
};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
class FileUploader extends _react.default.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
class FileUploader extends React.Component {
|
|
10
3
|
constructor(props) {
|
|
11
4
|
super(props);
|
|
12
5
|
this.onFilesChanged = () => {};
|
|
@@ -22,10 +15,10 @@ class FileUploader extends _react.default.Component {
|
|
|
22
15
|
this.uploadFiles = [];
|
|
23
16
|
}
|
|
24
17
|
render() {
|
|
25
|
-
return /*#__PURE__*/
|
|
18
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
26
19
|
type: "file",
|
|
27
20
|
onChange: this.onFilesChanged
|
|
28
21
|
});
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
|
-
|
|
24
|
+
export default FileUploader;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _constants = require("../constants");
|
|
1
|
+
import { FORMULA_RESULT_TYPE, CellType } from '../constants';
|
|
8
2
|
const numberValidator = value => {
|
|
9
3
|
return (value || value === 0) && Object.prototype.toString.call(value) === '[object Number]';
|
|
10
4
|
};
|
|
@@ -15,22 +9,22 @@ const checkboxValidator = value => {
|
|
|
15
9
|
return typeof value === 'boolean';
|
|
16
10
|
};
|
|
17
11
|
const validators = {
|
|
18
|
-
[
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
12
|
+
[CellType.NUMBER]: numberValidator,
|
|
13
|
+
[CellType.RATE]: numberValidator,
|
|
14
|
+
[CellType.DURATION]: numberValidator,
|
|
15
|
+
[CellType.CHECKBOX]: checkboxValidator,
|
|
16
|
+
[CellType.TEXT]: textValidator,
|
|
17
|
+
[CellType.DATE]: textValidator,
|
|
18
|
+
[CellType.CTIME]: textValidator,
|
|
19
|
+
[CellType.MTIME]: textValidator,
|
|
20
|
+
[CellType.GEOLOCATION]: textValidator,
|
|
21
|
+
[CellType.AUTO_NUMBER]: textValidator,
|
|
22
|
+
[CellType.URL]: textValidator,
|
|
23
|
+
[CellType.EMAIL]: textValidator,
|
|
24
|
+
[FORMULA_RESULT_TYPE.DATE]: textValidator,
|
|
25
|
+
[FORMULA_RESULT_TYPE.STRING]: textValidator,
|
|
26
|
+
[FORMULA_RESULT_TYPE.NUMBER]: numberValidator,
|
|
27
|
+
[FORMULA_RESULT_TYPE.BOOL]: checkboxValidator
|
|
34
28
|
};
|
|
35
29
|
const cellValueValidator = (cellValue, type) => {
|
|
36
30
|
const validator = validators[type];
|
|
@@ -39,4 +33,4 @@ const cellValueValidator = (cellValue, type) => {
|
|
|
39
33
|
}
|
|
40
34
|
return true;
|
|
41
35
|
};
|
|
42
|
-
|
|
36
|
+
export default cellValueValidator;
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _dtableUtils = require("dtable-utils");
|
|
10
|
-
var _baseFormatterConfig = _interopRequireDefault(require("../formatterConfig/base-formatter-config"));
|
|
11
|
-
var _TextFormatter = _interopRequireDefault(require("../TextFormatter"));
|
|
12
|
-
var _utils = require("./utils");
|
|
13
|
-
var _cellValueValidator = _interopRequireDefault(require("./cell-value-validator"));
|
|
14
|
-
require("./index.css");
|
|
15
|
-
class FormulaFormatter extends _react.default.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CellType, FORMULA_RESULT_TYPE, getFormulaDisplayString } from 'dtable-utils';
|
|
3
|
+
import BaseFormatterConfig from '../formatterConfig/base-formatter-config';
|
|
4
|
+
import TextFormatter from '../TextFormatter';
|
|
5
|
+
import { isArrayFormatColumn, isSimpleCellFormatter, isFunction, getFormulaArrayValue, convertValueToDtableLongTextValue } from './utils';
|
|
6
|
+
import cellValueValidator from './cell-value-validator';
|
|
7
|
+
import './index.css';
|
|
8
|
+
class FormulaFormatter extends React.Component {
|
|
16
9
|
constructor() {
|
|
17
10
|
super(...arguments);
|
|
18
11
|
this.getGridCellClassName = resultType => {
|
|
19
12
|
switch (resultType) {
|
|
20
|
-
case
|
|
13
|
+
case FORMULA_RESULT_TYPE.NUMBER:
|
|
21
14
|
{
|
|
22
15
|
return 'text-right';
|
|
23
16
|
}
|
|
@@ -40,26 +33,26 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
40
33
|
array_type,
|
|
41
34
|
array_data
|
|
42
35
|
} = columnData;
|
|
43
|
-
if (!array_type || array_type ===
|
|
36
|
+
if (!array_type || array_type === CellType.LINK) {
|
|
44
37
|
return null;
|
|
45
38
|
}
|
|
46
|
-
const Formatter =
|
|
39
|
+
const Formatter = BaseFormatterConfig[array_type];
|
|
47
40
|
let formatterProps = this.getFormatterProps(array_type, array_data, collaborators);
|
|
48
|
-
if (
|
|
41
|
+
if (isArrayFormatColumn(array_type)) {
|
|
49
42
|
formatterProps.value = value;
|
|
50
43
|
return this.createColumnFormatter(Formatter, formatterProps);
|
|
51
44
|
}
|
|
52
|
-
const _isSimpleCellFormatterColumn =
|
|
45
|
+
const _isSimpleCellFormatterColumn = isSimpleCellFormatter(array_type);
|
|
53
46
|
let cellValue = value;
|
|
54
47
|
if (!Array.isArray(value)) {
|
|
55
|
-
cellValue = (
|
|
48
|
+
cellValue = cellValueValidator(value, array_type) ? [value] : [];
|
|
56
49
|
}
|
|
57
50
|
const contentItemClassName = "formula-formatter-content-item ".concat(_isSimpleCellFormatterColumn ? 'simple-cell-formatter' : '');
|
|
58
|
-
return /*#__PURE__*/
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
59
52
|
className: "dtable-ui formula-formatter multiple"
|
|
60
53
|
}, cellValue.map((v, index) => {
|
|
61
54
|
formatterProps.value = v;
|
|
62
|
-
return /*#__PURE__*/
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
63
56
|
className: contentItemClassName,
|
|
64
57
|
key: "formula-formatter-content-item-".concat(index)
|
|
65
58
|
}, this.createColumnFormatter(Formatter, formatterProps));
|
|
@@ -67,7 +60,7 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
67
60
|
};
|
|
68
61
|
this.getFormatterProps = (array_type, array_data, collaborators) => {
|
|
69
62
|
switch (array_type) {
|
|
70
|
-
case
|
|
63
|
+
case CellType.DURATION:
|
|
71
64
|
{
|
|
72
65
|
const {
|
|
73
66
|
duration_format
|
|
@@ -76,9 +69,9 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
76
69
|
format: duration_format
|
|
77
70
|
};
|
|
78
71
|
}
|
|
79
|
-
case
|
|
80
|
-
case
|
|
81
|
-
case
|
|
72
|
+
case CellType.NUMBER:
|
|
73
|
+
case CellType.RATE:
|
|
74
|
+
case CellType.GEOLOCATION:
|
|
82
75
|
{
|
|
83
76
|
return {
|
|
84
77
|
data: array_data
|
|
@@ -95,14 +88,14 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
95
88
|
};
|
|
96
89
|
}
|
|
97
90
|
createColumnFormatter(Formatter, formatterProps) {
|
|
98
|
-
if (
|
|
99
|
-
return
|
|
91
|
+
if (React.isValidElement(Formatter)) {
|
|
92
|
+
return React.cloneElement(Formatter, {
|
|
100
93
|
...formatterProps
|
|
101
94
|
});
|
|
102
|
-
} else if (
|
|
103
|
-
return /*#__PURE__*/
|
|
95
|
+
} else if (isFunction(Formatter)) {
|
|
96
|
+
return /*#__PURE__*/React.createElement(Formatter, formatterProps);
|
|
104
97
|
}
|
|
105
|
-
return /*#__PURE__*/
|
|
98
|
+
return /*#__PURE__*/React.createElement(TextFormatter, formatterProps);
|
|
106
99
|
}
|
|
107
100
|
render() {
|
|
108
101
|
const {
|
|
@@ -119,26 +112,26 @@ class FormulaFormatter extends _react.default.Component {
|
|
|
119
112
|
} = data;
|
|
120
113
|
let value = this.props.value;
|
|
121
114
|
if (Array.isArray(value)) {
|
|
122
|
-
value =
|
|
123
|
-
if (array_type ===
|
|
124
|
-
value = value.map(item =>
|
|
115
|
+
value = getFormulaArrayValue(value);
|
|
116
|
+
if (array_type === CellType.LONG_TEXT) {
|
|
117
|
+
value = value.map(item => convertValueToDtableLongTextValue(item));
|
|
125
118
|
}
|
|
126
119
|
}
|
|
127
|
-
if (resultType ===
|
|
120
|
+
if (resultType === FORMULA_RESULT_TYPE.ARRAY) {
|
|
128
121
|
return this.renderOtherColumnFormatter();
|
|
129
122
|
}
|
|
130
123
|
if (typeof value === 'object') {
|
|
131
124
|
return null;
|
|
132
125
|
}
|
|
133
126
|
const gridCellClassName = this.getGridCellClassName(resultType);
|
|
134
|
-
const formattedValue =
|
|
127
|
+
const formattedValue = getFormulaDisplayString(value, data, {
|
|
135
128
|
collaborators
|
|
136
129
|
});
|
|
137
|
-
return /*#__PURE__*/
|
|
130
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
138
131
|
className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
|
|
139
132
|
title: formattedValue,
|
|
140
133
|
"aria-label": formattedValue
|
|
141
134
|
}, formattedValue);
|
|
142
135
|
}
|
|
143
136
|
}
|
|
144
|
-
|
|
137
|
+
export default FormulaFormatter;
|
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getTwoDimensionArrayValue = exports.getFormulaArrayValue = exports.convertValueToDtableLongTextValue = void 0;
|
|
8
|
-
exports.isArrayFormatColumn = isArrayFormatColumn;
|
|
9
|
-
exports.isFunction = void 0;
|
|
10
|
-
exports.isSimpleCellFormatter = isSimpleCellFormatter;
|
|
11
|
-
exports.isValidCellValue = void 0;
|
|
12
|
-
var _constants = require("../constants");
|
|
13
|
-
var _normalizeLongTextValue = _interopRequireDefault(require("../SimpleLongTextFormatter/normalize-long-text-value"));
|
|
14
|
-
function isSimpleCellFormatter(type) {
|
|
15
|
-
return _constants.SIMPLE_CELL_COLUMNS.includes(type) || _constants.SIMPLE_CELL_FORMULA_RESULTS.includes(type);
|
|
1
|
+
import { ARRAY_FORMAT_COLUMNS, SIMPLE_CELL_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS } from '../constants';
|
|
2
|
+
import getPreviewContent from '../SimpleLongTextFormatter/normalize-long-text-value';
|
|
3
|
+
export function isSimpleCellFormatter(type) {
|
|
4
|
+
return SIMPLE_CELL_COLUMNS.includes(type) || SIMPLE_CELL_FORMULA_RESULTS.includes(type);
|
|
16
5
|
}
|
|
17
|
-
function isArrayFormatColumn(columnType) {
|
|
18
|
-
return
|
|
6
|
+
export function isArrayFormatColumn(columnType) {
|
|
7
|
+
return ARRAY_FORMAT_COLUMNS.includes(columnType);
|
|
19
8
|
}
|
|
20
|
-
const isFunction = functionToCheck => {
|
|
9
|
+
export const isFunction = functionToCheck => {
|
|
21
10
|
const getType = {};
|
|
22
11
|
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
|
23
12
|
};
|
|
24
|
-
|
|
25
|
-
const isValidCellValue = value => {
|
|
13
|
+
export const isValidCellValue = value => {
|
|
26
14
|
if (value === undefined) return false;
|
|
27
15
|
if (value === null) return false;
|
|
28
16
|
if (value === '') return false;
|
|
@@ -30,8 +18,7 @@ const isValidCellValue = value => {
|
|
|
30
18
|
if (JSON.stringify(value) === '[]') return false;
|
|
31
19
|
return true;
|
|
32
20
|
};
|
|
33
|
-
|
|
34
|
-
const getFormulaArrayValue = function (value) {
|
|
21
|
+
export const getFormulaArrayValue = function (value) {
|
|
35
22
|
let isFlat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
36
23
|
if (!Array.isArray(value)) {
|
|
37
24
|
return [];
|
|
@@ -63,8 +50,7 @@ const getFormulaArrayValue = function (value) {
|
|
|
63
50
|
});
|
|
64
51
|
}).flat().filter(item => isValidCellValue(item));
|
|
65
52
|
};
|
|
66
|
-
|
|
67
|
-
const getTwoDimensionArrayValue = value => {
|
|
53
|
+
export const getTwoDimensionArrayValue = value => {
|
|
68
54
|
if (!Array.isArray(value)) return [];
|
|
69
55
|
return value.map(item => {
|
|
70
56
|
if (Object.prototype.toString.call(item) !== '[object Object]') {
|
|
@@ -93,15 +79,13 @@ const getTwoDimensionArrayValue = value => {
|
|
|
93
79
|
});
|
|
94
80
|
});
|
|
95
81
|
};
|
|
96
|
-
|
|
97
|
-
const convertValueToDtableLongTextValue = value => {
|
|
82
|
+
export const convertValueToDtableLongTextValue = value => {
|
|
98
83
|
const valueType = Object.prototype.toString.call(value);
|
|
99
84
|
if (value && valueType === '[object String]') {
|
|
100
|
-
return (
|
|
85
|
+
return getPreviewContent(value);
|
|
101
86
|
}
|
|
102
87
|
if (valueType === '[object Object]') {
|
|
103
88
|
return value;
|
|
104
89
|
}
|
|
105
90
|
return '';
|
|
106
|
-
};
|
|
107
|
-
exports.convertValueToDtableLongTextValue = convertValueToDtableLongTextValue;
|
|
91
|
+
};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _dtableUtils = require("dtable-utils");
|
|
11
|
-
require("./index.css");
|
|
12
|
-
class GeolocationFormatter extends _react.default.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { getGeolocationDisplayString } from 'dtable-utils';
|
|
4
|
+
import './index.css';
|
|
5
|
+
class GeolocationFormatter extends React.Component {
|
|
13
6
|
render() {
|
|
14
7
|
let {
|
|
15
8
|
value,
|
|
@@ -17,13 +10,13 @@ class GeolocationFormatter extends _react.default.Component {
|
|
|
17
10
|
containerClassName,
|
|
18
11
|
isBaiduMap
|
|
19
12
|
} = this.props;
|
|
20
|
-
let className = (
|
|
13
|
+
let className = classnames('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
|
|
21
14
|
if (typeof value !== 'object') {
|
|
22
15
|
return null;
|
|
23
16
|
}
|
|
24
|
-
return /*#__PURE__*/
|
|
17
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
18
|
className: className
|
|
26
|
-
},
|
|
19
|
+
}, getGeolocationDisplayString(value, data, {
|
|
27
20
|
isBaiduMap,
|
|
28
21
|
hyphen: ' '
|
|
29
22
|
}));
|
|
@@ -40,4 +33,4 @@ GeolocationFormatter.defaultProps = {
|
|
|
40
33
|
containerClassName: '',
|
|
41
34
|
isBaiduMap: false
|
|
42
35
|
};
|
|
43
|
-
|
|
36
|
+
export default GeolocationFormatter;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _seafileEditor = require("@seafile/seafile-editor");
|
|
12
|
-
require("./index.css");
|
|
13
|
-
class HtmlLongTextFormatter extends _react.Component {
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import { processor } from './markdown2html';
|
|
4
|
+
import './index.css';
|
|
5
|
+
class HtmlLongTextFormatter extends Component {
|
|
14
6
|
constructor(_props) {
|
|
15
7
|
super(_props);
|
|
16
8
|
this.translateValue = props => {
|
|
@@ -35,7 +27,7 @@ class HtmlLongTextFormatter extends _react.Component {
|
|
|
35
27
|
return;
|
|
36
28
|
};
|
|
37
29
|
this.convertMarkdown = mdFile => {
|
|
38
|
-
|
|
30
|
+
processor.process(mdFile).then(result => {
|
|
39
31
|
let innerHtml = String(result).replace(/<a /ig, '<a target="_blank" ');
|
|
40
32
|
this.setState({
|
|
41
33
|
innerHtml
|
|
@@ -64,9 +56,9 @@ class HtmlLongTextFormatter extends _react.Component {
|
|
|
64
56
|
const {
|
|
65
57
|
containerClassName
|
|
66
58
|
} = this.props;
|
|
67
|
-
const className = (
|
|
59
|
+
const className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
68
60
|
if (!innerHtml) return null;
|
|
69
|
-
return /*#__PURE__*/
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
70
62
|
className: "".concat(className, " article"),
|
|
71
63
|
dangerouslySetInnerHTML: {
|
|
72
64
|
__html: innerHtml
|
|
@@ -74,4 +66,4 @@ class HtmlLongTextFormatter extends _react.Component {
|
|
|
74
66
|
});
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
|
-
|
|
69
|
+
export default HtmlLongTextFormatter;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var markdown = require('remark-parse');
|
|
2
|
+
var slug = require('remark-slug');
|
|
3
|
+
var breaks = require('remark-breaks');
|
|
4
|
+
var remark2rehype = require('remark-rehype');
|
|
5
|
+
var format = require('rehype-format');
|
|
6
|
+
var raw = require('rehype-raw');
|
|
7
|
+
var xtend = require('xtend');
|
|
8
|
+
var toHTML = require('hast-util-to-html');
|
|
9
|
+
var sanitize = require('hast-util-sanitize');
|
|
10
|
+
var gh = require('hast-util-sanitize/lib/github');
|
|
11
|
+
var deepmerge = require('deepmerge').default;
|
|
12
|
+
const mathjax = require('rehype-mathjax/browser');
|
|
13
|
+
const math = require('remark-math/block');
|
|
14
|
+
var unified = require('./unified').default;
|
|
15
|
+
function stringify(config) {
|
|
16
|
+
var settings = xtend(config, this.data('settings'));
|
|
17
|
+
var schema = deepmerge(gh, {
|
|
18
|
+
'attributes': {
|
|
19
|
+
'input': ['type'],
|
|
20
|
+
'li': ['className'],
|
|
21
|
+
'code': ['className'],
|
|
22
|
+
'span': ['className'],
|
|
23
|
+
'div': ['className']
|
|
24
|
+
},
|
|
25
|
+
'tagNames': ['input', 'code', 'span', 'div']
|
|
26
|
+
});
|
|
27
|
+
this.Compiler = compiler;
|
|
28
|
+
function compiler(tree) {
|
|
29
|
+
// use sanity to remove dangerous html, the default is
|
|
30
|
+
// GitHub style sanitation
|
|
31
|
+
var hast = sanitize(tree, schema);
|
|
32
|
+
return toHTML(hast, settings);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// markdown -> mdast -> html AST -> html
|
|
37
|
+
var processor = unified().use(markdown, {
|
|
38
|
+
commonmark: true
|
|
39
|
+
}).use(math).use(breaks).use(slug).use(remark2rehype, {
|
|
40
|
+
allowDangerousHTML: true
|
|
41
|
+
}).use(mathjax, {
|
|
42
|
+
displayMath: ['$$', '$$']
|
|
43
|
+
}).use(raw).use(format).use(stringify);
|
|
44
|
+
var processorGetAST = unified().use(markdown, {
|
|
45
|
+
commonmark: true
|
|
46
|
+
}).use(slug);
|
|
47
|
+
export { processor, processorGetAST };
|