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.
Files changed (149) hide show
  1. package/lib/AutoNumberFormatter/index.js +7 -14
  2. package/lib/ButtonFormatter/index.js +9 -16
  3. package/lib/CTimeFormatter/index.js +9 -16
  4. package/lib/CheckboxEditor/index.js +8 -15
  5. package/lib/CheckboxFormatter/index.js +8 -15
  6. package/lib/CollaboratorEditor/index.js +21 -29
  7. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +25 -32
  8. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +18 -25
  9. package/lib/CollaboratorFormatter/index.js +12 -19
  10. package/lib/CollaboratorItem/index.js +10 -17
  11. package/lib/CreatorFormatter/index.js +12 -19
  12. package/lib/DTableCommonAddTool/index.js +6 -13
  13. package/lib/DTableCustomizeCollaboratorSelect/index.js +18 -26
  14. package/lib/DTableCustomizeSelect/index.js +15 -23
  15. package/lib/DTableFiltersPopover/constants/index.js +33 -38
  16. package/lib/DTableFiltersPopover/index.js +31 -38
  17. package/lib/DTableFiltersPopover/utils/filter-item-utils.js +46 -53
  18. package/lib/DTableFiltersPopover/utils/index.js +99 -128
  19. package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +26 -34
  20. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-multiple-select-filter.js +25 -33
  21. package/lib/DTableFiltersPopover/widgets/department-select-filter/department-single-select-filter.js +26 -34
  22. package/lib/DTableFiltersPopover/widgets/filter-calendar.js +26 -34
  23. package/lib/DTableFiltersPopover/widgets/filter-item.js +120 -128
  24. package/lib/DTableFiltersPopover/widgets/filter-list/index.js +18 -26
  25. package/lib/DTableFiltersPopover/widgets/rate-item.js +8 -15
  26. package/lib/DTablePopover/index.js +8 -15
  27. package/lib/DTablePopover/utils.js +2 -9
  28. package/lib/DTableRadio/index.js +10 -17
  29. package/lib/DTableSearchInput/index.js +13 -21
  30. package/lib/DTableSearchInput/utils.js +2 -9
  31. package/lib/DTableSelect/dtable-select-label.js +6 -13
  32. package/lib/DTableSelect/index.js +10 -18
  33. package/lib/DTableSelect/utils.js +10 -20
  34. package/lib/DTableSwitch/index.js +7 -14
  35. package/lib/DateEditor/index.js +22 -30
  36. package/lib/DateEditor/mb-date-editor-popover/index.js +47 -55
  37. package/lib/DateEditor/pc-date-editor-popover.js +20 -27
  38. package/lib/DateFormatter/index.js +9 -16
  39. package/lib/Department-editor/constants.js +1 -7
  40. package/lib/Department-editor/department-multiple-select/index.js +24 -32
  41. package/lib/Department-editor/department-single-select.js +33 -41
  42. package/lib/Department-editor/index.js +14 -22
  43. package/lib/Department-editor/selected-departments/index.js +25 -32
  44. package/lib/Department-editor/utils.js +3 -11
  45. package/lib/DepartmentSingleSelectFormatter/index.js +9 -16
  46. package/lib/DigitalSignFormatter/index.js +15 -23
  47. package/lib/DigitalSignFormatter/utils.js +3 -11
  48. package/lib/DurationFormatter/index.js +9 -16
  49. package/lib/EditEditorButton/index.js +5 -12
  50. package/lib/EmailFormatter/index.js +7 -14
  51. package/lib/FieldDisplaySetting/field-item.js +14 -21
  52. package/lib/FieldDisplaySetting/index.js +19 -27
  53. package/lib/FileEditor/index.js +8 -15
  54. package/lib/FileEditor/pc-files-addition/index.js +0 -1
  55. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -1
  56. package/lib/FileEditor/pc-files-preview/index.js +0 -1
  57. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -1
  58. package/lib/FileFormatter/index.js +11 -19
  59. package/lib/FileItemFormatter/index.js +6 -14
  60. package/lib/FileItemFormatter/utils.js +2 -9
  61. package/lib/FileUploader/index.js +4 -11
  62. package/lib/FormulaFormatter/cell-value-validator.js +18 -24
  63. package/lib/FormulaFormatter/index.js +32 -39
  64. package/lib/FormulaFormatter/utils.js +13 -29
  65. package/lib/GeolocationFormatter/index.js +9 -16
  66. package/lib/HtmlLongTextFormatter/index.js +9 -17
  67. package/lib/HtmlLongTextFormatter/markdown2html.js +47 -0
  68. package/lib/HtmlLongTextFormatter/unified/index.js +400 -0
  69. package/lib/HtmlLongTextFormatter/vfile/core.js +155 -0
  70. package/lib/HtmlLongTextFormatter/vfile/index.js +40 -0
  71. package/lib/ImageFormatter/images-lazy-load.js +9 -16
  72. package/lib/ImageFormatter/index.js +16 -24
  73. package/lib/ImageFormatter/utils.js +2 -9
  74. package/lib/ImagePreviewerLightbox/index.js +12 -19
  75. package/lib/ImagePreviewerLightbox/utils.js +3 -11
  76. package/lib/LastModifierFormatter/index.js +12 -19
  77. package/lib/LinkEditor/index.js +25 -33
  78. package/lib/LinkEditor/link-editor-option.js +8 -15
  79. package/lib/LinkEditor/mb-link-editor-popover/index.js +23 -30
  80. package/lib/LinkEditor/pc-link-editor-popover/index.js +17 -24
  81. package/lib/LinkFormatter/index.js +13 -20
  82. package/lib/Loading/index.js +4 -11
  83. package/lib/LongTextFormatter/index.js +6 -13
  84. package/lib/MBEditorHeader/index.js +7 -14
  85. package/lib/MTimeFormatter/index.js +9 -16
  86. package/lib/ModalPortal/index.js +5 -12
  87. package/lib/MultipleSelectEditor/index.js +17 -25
  88. package/lib/MultipleSelectFormatter/index.js +10 -17
  89. package/lib/NotificationPopover/index.js +16 -24
  90. package/lib/NumberEditor/index.js +18 -25
  91. package/lib/NumberFormatter/index.js +9 -16
  92. package/lib/RateFormatter/index.js +8 -15
  93. package/lib/RoleStatusEditor/index.js +14 -22
  94. package/lib/RowExpandEmailFormatter/index.js +10 -17
  95. package/lib/RowExpandFileFormatter/index.js +8 -16
  96. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +18 -27
  97. package/lib/RowExpandFormatter/index.js +78 -86
  98. package/lib/RowExpandFormulaFormatter/index.js +34 -42
  99. package/lib/RowExpandImageFormatter/index.js +10 -19
  100. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +18 -27
  101. package/lib/RowExpandImageFormatter/utils.js +2 -9
  102. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +7 -16
  103. package/lib/RowExpandLinkFormatter/index.js +37 -46
  104. package/lib/RowExpandLinkFormatter/utils.js +6 -17
  105. package/lib/RowExpandLinkFormatter/value-display-utils.js +5 -12
  106. package/lib/RowExpandRateFormatter/index.js +8 -15
  107. package/lib/RowExpandUrlFormatter/index.js +14 -21
  108. package/lib/SelectItem/index.js +4 -12
  109. package/lib/SelectOptionGroup/KeyCodes.js +1 -7
  110. package/lib/SelectOptionGroup/index.js +33 -32
  111. package/lib/SelectOptionGroup/option.js +4 -19
  112. package/lib/SimpleLongTextFormatter/index.js +20 -27
  113. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +1 -7
  114. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +8 -15
  115. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +7 -14
  116. package/lib/SingleSelectEditor/index.js +18 -26
  117. package/lib/SingleSelectFormatter/index.js +9 -16
  118. package/lib/TextEditor/index.js +7 -14
  119. package/lib/TextFormatter/index.js +7 -14
  120. package/lib/UrlFormatter/index.js +7 -14
  121. package/lib/cellFormatterFactory/index.js +4 -11
  122. package/lib/common/ClickOutside.js +4 -12
  123. package/lib/common/delete-tip.js +12 -20
  124. package/lib/common/modal-portal.js +5 -13
  125. package/lib/constants/index.js +9 -28
  126. package/lib/data/dtable-value.js +6 -11
  127. package/lib/formatterConfig/base-formatter-config.js +46 -53
  128. package/lib/formatterConfig/index.js +9 -16
  129. package/lib/hooks/common-hooks.js +4 -11
  130. package/lib/index.js +75 -432
  131. package/lib/lang/index.js +13 -24
  132. package/lib/locals/de.js +1 -7
  133. package/lib/locals/en.js +1 -7
  134. package/lib/locals/fr.js +1 -7
  135. package/lib/locals/zh-CN.js +1 -7
  136. package/lib/select-editor/index.js +4 -27
  137. package/lib/select-editor/mb-select-editor-popover/index.js +33 -41
  138. package/lib/select-editor/pc-select-editor-popover/index.js +19 -26
  139. package/lib/select-editor/select-editor-option.js +8 -15
  140. package/lib/toaster/alert.js +11 -18
  141. package/lib/toaster/index.js +3 -10
  142. package/lib/toaster/toast.js +8 -16
  143. package/lib/toaster/toastManager.js +5 -13
  144. package/lib/toaster/toaster.js +7 -15
  145. package/lib/utils/dayjs.js +4 -11
  146. package/lib/utils/editor-utils.js +5 -15
  147. package/lib/utils/event-bus.js +1 -7
  148. package/lib/utils/utils.js +6 -17
  149. 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
- "use strict";
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
- 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 = (0, _classnames.default)('dtable-ui cell-formatter-container file-formatter', containerClassName);
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__*/_react.default.createElement("div", {
18
+ return /*#__PURE__*/React.createElement("div", {
26
19
  className: className
27
- }, /*#__PURE__*/_react.default.createElement(_FileItemFormatter.default, {
20
+ }, /*#__PURE__*/React.createElement(FileItemFormatter, {
28
21
  file: item
29
- }), value.length !== 1 && /*#__PURE__*/_react.default.createElement("span", {
22
+ }), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
30
23
  className: "file-item-count"
31
24
  }, "+".concat(value.length)));
32
25
  }
33
- return /*#__PURE__*/_react.default.createElement("div", {
26
+ return /*#__PURE__*/React.createElement("div", {
34
27
  className: className
35
28
  }, value.map((item, index) => {
36
- return /*#__PURE__*/_react.default.createElement(_FileItemFormatter.default, {
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
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
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 = (0, _utils.getFileIconUrl)(item.name, item.type);
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__*/_react.default.createElement("img", {
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
- "use strict";
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__*/_react.default.createElement("input", {
18
+ return /*#__PURE__*/React.createElement("input", {
26
19
  type: "file",
27
20
  onChange: this.onFilesChanged
28
21
  });
29
22
  }
30
23
  }
31
- var _default = exports.default = FileUploader;
24
+ export default FileUploader;
@@ -1,10 +1,4 @@
1
- "use strict";
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
- [_constants.CellType.NUMBER]: numberValidator,
19
- [_constants.CellType.RATE]: numberValidator,
20
- [_constants.CellType.DURATION]: numberValidator,
21
- [_constants.CellType.CHECKBOX]: checkboxValidator,
22
- [_constants.CellType.TEXT]: textValidator,
23
- [_constants.CellType.DATE]: textValidator,
24
- [_constants.CellType.CTIME]: textValidator,
25
- [_constants.CellType.MTIME]: textValidator,
26
- [_constants.CellType.GEOLOCATION]: textValidator,
27
- [_constants.CellType.AUTO_NUMBER]: textValidator,
28
- [_constants.CellType.URL]: textValidator,
29
- [_constants.CellType.EMAIL]: textValidator,
30
- [_constants.FORMULA_RESULT_TYPE.DATE]: textValidator,
31
- [_constants.FORMULA_RESULT_TYPE.STRING]: textValidator,
32
- [_constants.FORMULA_RESULT_TYPE.NUMBER]: numberValidator,
33
- [_constants.FORMULA_RESULT_TYPE.BOOL]: checkboxValidator
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
- var _default = exports.default = cellValueValidator;
36
+ export default cellValueValidator;
@@ -1,23 +1,16 @@
1
- "use strict";
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
- 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 _dtableUtils.FORMULA_RESULT_TYPE.NUMBER:
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 === _dtableUtils.CellType.LINK) {
36
+ if (!array_type || array_type === CellType.LINK) {
44
37
  return null;
45
38
  }
46
- const Formatter = _baseFormatterConfig.default[array_type];
39
+ const Formatter = BaseFormatterConfig[array_type];
47
40
  let formatterProps = this.getFormatterProps(array_type, array_data, collaborators);
48
- if ((0, _utils.isArrayFormatColumn)(array_type)) {
41
+ if (isArrayFormatColumn(array_type)) {
49
42
  formatterProps.value = value;
50
43
  return this.createColumnFormatter(Formatter, formatterProps);
51
44
  }
52
- const _isSimpleCellFormatterColumn = (0, _utils.isSimpleCellFormatter)(array_type);
45
+ const _isSimpleCellFormatterColumn = isSimpleCellFormatter(array_type);
53
46
  let cellValue = value;
54
47
  if (!Array.isArray(value)) {
55
- cellValue = (0, _cellValueValidator.default)(value, array_type) ? [value] : [];
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__*/_react.default.createElement("div", {
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__*/_react.default.createElement("div", {
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 _dtableUtils.CellType.DURATION:
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 _dtableUtils.CellType.NUMBER:
80
- case _dtableUtils.CellType.RATE:
81
- case _dtableUtils.CellType.GEOLOCATION:
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 ( /*#__PURE__*/_react.default.isValidElement(Formatter)) {
99
- return /*#__PURE__*/_react.default.cloneElement(Formatter, {
91
+ if (React.isValidElement(Formatter)) {
92
+ return React.cloneElement(Formatter, {
100
93
  ...formatterProps
101
94
  });
102
- } else if ((0, _utils.isFunction)(Formatter)) {
103
- return /*#__PURE__*/_react.default.createElement(Formatter, formatterProps);
95
+ } else if (isFunction(Formatter)) {
96
+ return /*#__PURE__*/React.createElement(Formatter, formatterProps);
104
97
  }
105
- return /*#__PURE__*/_react.default.createElement(_TextFormatter.default, formatterProps);
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 = (0, _utils.getFormulaArrayValue)(value);
123
- if (array_type === _dtableUtils.CellType.LONG_TEXT) {
124
- value = value.map(item => (0, _utils.convertValueToDtableLongTextValue)(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 === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
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 = (0, _dtableUtils.getFormulaDisplayString)(value, data, {
127
+ const formattedValue = getFormulaDisplayString(value, data, {
135
128
  collaborators
136
129
  });
137
- return /*#__PURE__*/_react.default.createElement("div", {
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
- var _default = exports.default = FormulaFormatter;
137
+ export default FormulaFormatter;
@@ -1,28 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
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 _constants.ARRAY_FORMAT_COLUMNS.includes(columnType);
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
- exports.isFunction = isFunction;
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
- exports.isValidCellValue = isValidCellValue;
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
- exports.getFormulaArrayValue = getFormulaArrayValue;
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
- exports.getTwoDimensionArrayValue = getTwoDimensionArrayValue;
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 (0, _normalizeLongTextValue.default)(value);
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
- "use strict";
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
- 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 = (0, _classnames.default)('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
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__*/_react.default.createElement("div", {
17
+ return /*#__PURE__*/React.createElement("div", {
25
18
  className: className
26
- }, (0, _dtableUtils.getGeolocationDisplayString)(value, data, {
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
- var _default = exports.default = GeolocationFormatter;
36
+ export default GeolocationFormatter;
@@ -1,16 +1,8 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
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
- _seafileEditor.processor.process(mdFile).then(result => {
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 = (0, _classnames.default)('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
59
+ const className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
68
60
  if (!innerHtml) return null;
69
- return /*#__PURE__*/_react.default.createElement("div", {
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
- var _default = exports.default = HtmlLongTextFormatter;
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 };