dtable-ui-component 0.1.79-beta → 0.1.82-beta

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 (117) hide show
  1. package/es/app.css +20 -0
  2. package/es/app.js +91 -0
  3. package/es/assets/images/avatar/default_avatar.png +0 -0
  4. package/es/assets/images/file/192/excel.png +0 -0
  5. package/es/assets/images/file/192/file.png +0 -0
  6. package/es/assets/images/file/192/music.png +0 -0
  7. package/es/assets/images/file/192/pdf.png +0 -0
  8. package/es/assets/images/file/192/pic.png +0 -0
  9. package/es/assets/images/file/192/ppt.png +0 -0
  10. package/es/assets/images/file/192/txt.png +0 -0
  11. package/es/assets/images/file/192/video.png +0 -0
  12. package/es/assets/images/file/192/word.png +0 -0
  13. package/es/assets/images/file/24/excel.png +0 -0
  14. package/es/assets/images/file/24/file.png +0 -0
  15. package/es/assets/images/file/24/music.png +0 -0
  16. package/es/assets/images/file/24/pdf.png +0 -0
  17. package/es/assets/images/file/24/pic.png +0 -0
  18. package/es/assets/images/file/24/ppt.png +0 -0
  19. package/es/assets/images/file/24/txt.png +0 -0
  20. package/es/assets/images/file/24/video.png +0 -0
  21. package/es/assets/images/file/24/word.png +0 -0
  22. package/es/assets/images/folder/folder-192.png +0 -0
  23. package/es/assets/images/folder/folder-24.png +0 -0
  24. package/es/components/cell-editor/checkbox-editor.js +104 -0
  25. package/es/components/cell-editor/collaborator-editor.js +236 -0
  26. package/es/components/cell-editor/date-editor.js +151 -0
  27. package/es/components/cell-editor/index.js +9 -0
  28. package/es/components/cell-editor/link-editor.js +303 -0
  29. package/es/components/cell-editor/multiple-select-editor.js +237 -0
  30. package/es/components/cell-editor/number-editor.js +154 -0
  31. package/es/components/cell-editor/single-select-editor.js +202 -0
  32. package/es/components/cell-editor/text-editor.js +122 -0
  33. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +46 -0
  34. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  35. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  36. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  37. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  38. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +177 -0
  39. package/es/components/cell-editor-popover/mb-date-editor-popover.js +245 -0
  40. package/es/components/cell-editor-popover/mb-link-editor-popover.js +170 -0
  41. package/es/components/cell-editor-popover/mb-select-editor-popover.js +230 -0
  42. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +109 -0
  43. package/es/components/cell-editor-popover/pc-date-editor-popover.js +142 -0
  44. package/es/components/cell-editor-popover/pc-link-editor-popover.js +114 -0
  45. package/es/components/cell-editor-popover/pc-select-editor-popover.js +143 -0
  46. package/es/components/cell-factory/cell-formatter-factory.js +25 -0
  47. package/es/components/cell-formatter/auto-number-formatter.js +35 -0
  48. package/es/components/cell-formatter/button-formatter.js +55 -0
  49. package/es/components/cell-formatter/checkbox-formatter.js +44 -0
  50. package/es/components/cell-formatter/collaborator-formatter.js +91 -0
  51. package/es/components/cell-formatter/creator-formatter.js +87 -0
  52. package/es/components/cell-formatter/ctime-formatter.js +57 -0
  53. package/es/components/cell-formatter/date-formatter.js +59 -0
  54. package/es/components/cell-formatter/duration-formatter.js +37 -0
  55. package/es/components/cell-formatter/email-formatter.js +35 -0
  56. package/es/components/cell-formatter/file-formatter.js +63 -0
  57. package/es/components/cell-formatter/formatter-config.js +31 -0
  58. package/es/components/cell-formatter/formula-formatter.js +164 -0
  59. package/es/components/cell-formatter/geolocation-formatter.js +52 -0
  60. package/es/components/cell-formatter/image-formatter.js +153 -0
  61. package/es/components/cell-formatter/index.js +27 -0
  62. package/es/components/cell-formatter/last-modifier-formatter.js +87 -0
  63. package/es/components/cell-formatter/link-formatter.js +144 -0
  64. package/es/components/cell-formatter/long-text-formatter.js +106 -0
  65. package/es/components/cell-formatter/mtime-formatter.js +57 -0
  66. package/es/components/cell-formatter/multiple-select-formatter.js +69 -0
  67. package/es/components/cell-formatter/number-formatter.js +46 -0
  68. package/es/components/cell-formatter/rate-formatter.js +79 -0
  69. package/es/components/cell-formatter/single-select-formatter.js +69 -0
  70. package/es/components/cell-formatter/text-formatter.js +55 -0
  71. package/es/components/cell-formatter/url-formatter.js +35 -0
  72. package/es/components/cell-formatter/widgets/file-item-formatter.js +50 -0
  73. package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +119 -0
  74. package/es/components/common/collaborator-item.js +63 -0
  75. package/es/components/common/edit-editor-button.js +56 -0
  76. package/es/components/common/images-lazy-load.js +150 -0
  77. package/es/components/common/link-editor-option.js +113 -0
  78. package/es/components/common/mobile/mb-editor-header.js +48 -0
  79. package/es/components/common/modal-portal.js +44 -0
  80. package/es/components/common/select-editor-option.js +106 -0
  81. package/es/components/common/select-item.js +58 -0
  82. package/es/components/file-uploader/index.js +53 -0
  83. package/es/components/loading.js +7 -0
  84. package/es/components/toast/alert.js +150 -0
  85. package/es/components/toast/index.js +3 -0
  86. package/es/components/toast/toast.js +179 -0
  87. package/es/components/toast/toastManager.js +170 -0
  88. package/es/components/toast/toaster.js +76 -0
  89. package/es/constants/cell-types.js +25 -0
  90. package/es/constants/index.js +48 -0
  91. package/es/css/cell-editor.css +614 -0
  92. package/es/css/cell-formatter.css +241 -0
  93. package/es/css/custom-rc-calendar.css +118 -0
  94. package/es/css/image-previewer-ligntbox.css +87 -0
  95. package/es/css/loading.css +54 -0
  96. package/es/index.js +6 -0
  97. package/es/lang/index.js +50 -0
  98. package/es/locals/de.js +2 -0
  99. package/es/locals/en.js +17 -0
  100. package/es/locals/fr.js +2 -0
  101. package/es/locals/zh-CN.js +17 -0
  102. package/es/utils/cell-value-validator.js +32 -0
  103. package/es/utils/column-utils.js +7 -0
  104. package/es/utils/editor-utils.js +71 -0
  105. package/es/utils/normalize-long-text-value.js +68 -0
  106. package/es/utils/number-precision.js +163 -0
  107. package/es/utils/utils.js +116 -0
  108. package/es/utils/value-format-utils.js +495 -0
  109. package/lib/CTimeFormatter/index.js +2 -2
  110. package/lib/DateEditor/index.js +2 -2
  111. package/lib/DateEditor/mb-date-editor-popover/index.js +9 -9
  112. package/lib/DateEditor/pc-date-editor-popover.js +3 -3
  113. package/lib/MTimeFormatter/index.js +2 -2
  114. package/lib/RateFormatter/index.js +4 -2
  115. package/lib/TextFormatter/index.js +4 -2
  116. package/lib/utils/value-format-utils.js +2 -2
  117. package/package.json +5 -5
@@ -0,0 +1,91 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+ import CollaboratorItem from '../common/collaborator-item';
8
+ import DefaultAvatar from '../../assets/images/avatar/default_avatar.png';
9
+
10
+ // there will be there conditions
11
+ // 1 value is not exist, typeof value is array, but it's length is 0
12
+ // 2 value is exist, but can't find in collaborators
13
+ // 3 value is exist, typeof value is a string
14
+ // 4 value is exist, typeof value is array
15
+ var CollaboratorFormatter = /*#__PURE__*/function (_React$PureComponent) {
16
+ _inherits(CollaboratorFormatter, _React$PureComponent);
17
+
18
+ var _super = _createSuper(CollaboratorFormatter);
19
+
20
+ function CollaboratorFormatter() {
21
+ var _this;
22
+
23
+ _classCallCheck(this, CollaboratorFormatter);
24
+
25
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ args[_key] = arguments[_key];
27
+ }
28
+
29
+ _this = _super.call.apply(_super, [this].concat(args));
30
+
31
+ _this.getCollaborators = function () {
32
+ var _this$props = _this.props,
33
+ value = _this$props.value,
34
+ collaborators = _this$props.collaborators,
35
+ enableDeleteCollaborator = _this$props.enableDeleteCollaborator,
36
+ onDeleteCollaborator = _this$props.onDeleteCollaborator;
37
+
38
+ if (!Array.isArray(value)) {
39
+ value = [value];
40
+ }
41
+
42
+ return value.map(function (item, index) {
43
+ var collaborator = collaborators.find(function (collaborator) {
44
+ return collaborator.email === item;
45
+ });
46
+
47
+ if (!collaborator) {
48
+ collaborator = {
49
+ name: item,
50
+ avatar_url: DefaultAvatar
51
+ };
52
+ }
53
+
54
+ ;
55
+ return /*#__PURE__*/React.createElement(CollaboratorItem, {
56
+ key: index,
57
+ collaborator: collaborator,
58
+ enableDeleteCollaborator: enableDeleteCollaborator,
59
+ onDeleteCollaborator: onDeleteCollaborator
60
+ });
61
+ });
62
+ };
63
+
64
+ return _this;
65
+ }
66
+
67
+ _createClass(CollaboratorFormatter, [{
68
+ key: "render",
69
+ value: function render() {
70
+ var _this$props2 = this.props,
71
+ containerClassName = _this$props2.containerClassName,
72
+ value = _this$props2.value;
73
+ var classname = cn('dtable-ui cell-formatter-container collaborator-formatter', containerClassName);
74
+
75
+ if (!value || Array.isArray(value) && value.length === 0) {
76
+ return /*#__PURE__*/React.createElement("div", {
77
+ className: classname
78
+ });
79
+ }
80
+
81
+ var collaborators = this.getCollaborators();
82
+ return /*#__PURE__*/React.createElement("div", {
83
+ className: classname
84
+ }, collaborators);
85
+ }
86
+ }]);
87
+
88
+ return CollaboratorFormatter;
89
+ }(React.PureComponent);
90
+
91
+ export default CollaboratorFormatter;
@@ -0,0 +1,87 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+ import CollaboratorItem from '../common/collaborator-item';
8
+ import DefaultAvatar from '../../assets/images/avatar/default_avatar.png';
9
+
10
+ // there will be there conditions
11
+ // 1 value is not exist, typeof value is array, but it's length is 0
12
+ // 2 value is exist, but can't find in collaborators
13
+ // 3 value is exist, typeof value is a string
14
+ // 4 value is exist, typeof value is array
15
+ var CreatorFormatter = /*#__PURE__*/function (_React$PureComponent) {
16
+ _inherits(CreatorFormatter, _React$PureComponent);
17
+
18
+ var _super = _createSuper(CreatorFormatter);
19
+
20
+ function CreatorFormatter() {
21
+ var _this;
22
+
23
+ _classCallCheck(this, CreatorFormatter);
24
+
25
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ args[_key] = arguments[_key];
27
+ }
28
+
29
+ _this = _super.call.apply(_super, [this].concat(args));
30
+
31
+ _this.getCollaborators = function () {
32
+ var _this$props = _this.props,
33
+ value = _this$props.value,
34
+ collaborators = _this$props.collaborators;
35
+
36
+ if (!Array.isArray(value)) {
37
+ value = [value];
38
+ }
39
+
40
+ return value.map(function (item, index) {
41
+ var collaborator = collaborators.find(function (collaborator) {
42
+ return collaborator.email === item;
43
+ }); // the collaborator can be not exist, beacuse the row created by third app
44
+
45
+ if (!collaborator) {
46
+ collaborator = {
47
+ name: item,
48
+ avatar_url: DefaultAvatar
49
+ };
50
+ }
51
+
52
+ ;
53
+ return /*#__PURE__*/React.createElement(CollaboratorItem, {
54
+ key: index,
55
+ collaborator: collaborator
56
+ });
57
+ });
58
+ };
59
+
60
+ return _this;
61
+ }
62
+
63
+ _createClass(CreatorFormatter, [{
64
+ key: "render",
65
+ value: function render() {
66
+ var _this$props2 = this.props,
67
+ containerClassName = _this$props2.containerClassName,
68
+ value = _this$props2.value;
69
+ var classname = cn('dtable-ui cell-formatter-container creator-formatter', containerClassName);
70
+
71
+ if (!value || Array.isArray(value) && value.length === 0) {
72
+ return /*#__PURE__*/React.createElement("div", {
73
+ className: classname
74
+ });
75
+ }
76
+
77
+ var collaborators = this.getCollaborators();
78
+ return /*#__PURE__*/React.createElement("div", {
79
+ className: classname
80
+ }, collaborators);
81
+ }
82
+ }]);
83
+
84
+ return CreatorFormatter;
85
+ }(React.PureComponent);
86
+
87
+ export default CreatorFormatter;
@@ -0,0 +1,57 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+ import moment from 'moment';
8
+
9
+ var CTimeFormatter = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(CTimeFormatter, _React$Component);
11
+
12
+ var _super = _createSuper(CTimeFormatter);
13
+
14
+ function CTimeFormatter() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, CTimeFormatter);
18
+
19
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20
+ args[_key] = arguments[_key];
21
+ }
22
+
23
+ _this = _super.call.apply(_super, [this].concat(args));
24
+
25
+ _this.formatDate = function (date) {
26
+ return moment(date).format('YYYY-MM-DD HH:mm:ss');
27
+ };
28
+
29
+ return _this;
30
+ }
31
+
32
+ _createClass(CTimeFormatter, [{
33
+ key: "render",
34
+ value: function render() {
35
+ var _this$props = this.props,
36
+ date = _this$props.value,
37
+ containerClassName = _this$props.containerClassName;
38
+ var classname = cn('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
39
+
40
+ if (date !== '') {
41
+ date = this.formatDate(date);
42
+ }
43
+
44
+ return /*#__PURE__*/React.createElement("div", {
45
+ className: classname
46
+ }, date);
47
+ }
48
+ }]);
49
+
50
+ return CTimeFormatter;
51
+ }(React.Component);
52
+
53
+ CTimeFormatter.defaultProps = {
54
+ value: '',
55
+ containerClassName: ''
56
+ };
57
+ export default CTimeFormatter;
@@ -0,0 +1,59 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+ import { getDateDisplayString } from '../../utils/value-format-utils';
8
+
9
+ var DateFormatter = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(DateFormatter, _React$Component);
11
+
12
+ var _super = _createSuper(DateFormatter);
13
+
14
+ function DateFormatter() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, DateFormatter);
18
+
19
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20
+ args[_key] = arguments[_key];
21
+ }
22
+
23
+ _this = _super.call.apply(_super, [this].concat(args));
24
+
25
+ _this.formatDate = function (date, format) {
26
+ return getDateDisplayString(date, format);
27
+ };
28
+
29
+ return _this;
30
+ }
31
+
32
+ _createClass(DateFormatter, [{
33
+ key: "render",
34
+ value: function render() {
35
+ var _this$props = this.props,
36
+ date = _this$props.value,
37
+ format = _this$props.format,
38
+ containerClassName = _this$props.containerClassName;
39
+ var classname = cn('dtable-ui cell-formatter-container date-formatter', containerClassName);
40
+
41
+ if (date !== '') {
42
+ date = this.formatDate(date, format);
43
+ }
44
+
45
+ return /*#__PURE__*/React.createElement("div", {
46
+ className: classname
47
+ }, date);
48
+ }
49
+ }]);
50
+
51
+ return DateFormatter;
52
+ }(React.Component);
53
+
54
+ DateFormatter.defaultProps = {
55
+ value: '',
56
+ format: 'YYYY-MM-DD',
57
+ containerClassName: ''
58
+ };
59
+ export default DateFormatter;
@@ -0,0 +1,37 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+ import { getDurationDisplayString } from '../../utils/value-format-utils';
8
+
9
+ var DurationFormatter = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(DurationFormatter, _React$Component);
11
+
12
+ var _super = _createSuper(DurationFormatter);
13
+
14
+ function DurationFormatter() {
15
+ _classCallCheck(this, DurationFormatter);
16
+
17
+ return _super.apply(this, arguments);
18
+ }
19
+
20
+ _createClass(DurationFormatter, [{
21
+ key: "render",
22
+ value: function render() {
23
+ var _this$props = this.props,
24
+ value = _this$props.value,
25
+ containerClassName = _this$props.containerClassName,
26
+ format = _this$props.format;
27
+ var classname = cn('dtable-ui cell-formatter-container duration-formatter', containerClassName);
28
+ return /*#__PURE__*/React.createElement("div", {
29
+ className: classname
30
+ }, getDurationDisplayString(value, format));
31
+ }
32
+ }]);
33
+
34
+ return DurationFormatter;
35
+ }(React.Component);
36
+
37
+ export default DurationFormatter;
@@ -0,0 +1,35 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+
8
+ var EmailFormatter = /*#__PURE__*/function (_React$Component) {
9
+ _inherits(EmailFormatter, _React$Component);
10
+
11
+ var _super = _createSuper(EmailFormatter);
12
+
13
+ function EmailFormatter() {
14
+ _classCallCheck(this, EmailFormatter);
15
+
16
+ return _super.apply(this, arguments);
17
+ }
18
+
19
+ _createClass(EmailFormatter, [{
20
+ key: "render",
21
+ value: function render() {
22
+ var _this$props = this.props,
23
+ containerClassName = _this$props.containerClassName,
24
+ value = _this$props.value;
25
+ var classname = cn('dtable-ui cell-formatter-container email-formatter', containerClassName);
26
+ return /*#__PURE__*/React.createElement("div", {
27
+ className: classname
28
+ }, value);
29
+ }
30
+ }]);
31
+
32
+ return EmailFormatter;
33
+ }(React.Component);
34
+
35
+ export default EmailFormatter;
@@ -0,0 +1,63 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+ import FileItemFormatter from './widgets/file-item-formatter';
8
+
9
+ var FileFormatter = /*#__PURE__*/function (_React$PureComponent) {
10
+ _inherits(FileFormatter, _React$PureComponent);
11
+
12
+ var _super = _createSuper(FileFormatter);
13
+
14
+ function FileFormatter() {
15
+ _classCallCheck(this, FileFormatter);
16
+
17
+ return _super.apply(this, arguments);
18
+ }
19
+
20
+ _createClass(FileFormatter, [{
21
+ key: "render",
22
+ value: function render() {
23
+ var _this$props = this.props,
24
+ isSample = _this$props.isSample,
25
+ value = _this$props.value,
26
+ containerClassName = _this$props.containerClassName;
27
+ var className = cn('dtable-ui cell-formatter-container file-formatter', containerClassName);
28
+
29
+ if (!Array.isArray(value) || value.length === 0) {
30
+ return null;
31
+ }
32
+
33
+ if (isSample) {
34
+ var item = value[0];
35
+ return /*#__PURE__*/React.createElement("div", {
36
+ className: className
37
+ }, /*#__PURE__*/React.createElement(FileItemFormatter, {
38
+ file: item
39
+ }), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
40
+ className: "file-item-count"
41
+ }, "+".concat(value.length)));
42
+ }
43
+
44
+ return /*#__PURE__*/React.createElement("div", {
45
+ className: className
46
+ }, value.map(function (item, index) {
47
+ return /*#__PURE__*/React.createElement(FileItemFormatter, {
48
+ file: item,
49
+ key: index
50
+ });
51
+ }));
52
+ }
53
+ }]);
54
+
55
+ return FileFormatter;
56
+ }(React.PureComponent);
57
+
58
+ FileFormatter.defaultProps = {
59
+ isSample: false,
60
+ value: [],
61
+ containerClassName: ''
62
+ };
63
+ export default FileFormatter;
@@ -0,0 +1,31 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+
3
+ var _FormatterConfig;
4
+
5
+ import React from 'react';
6
+ import * as CellTypes from '../../constants/cell-types';
7
+ import CheckboxFormatter from './checkbox-formatter';
8
+ import ImageFormatter from './image-formatter';
9
+ import LongTextFormatter from './long-text-formatter';
10
+ import TextCellFormatter from './text-formatter';
11
+ import SingleSelectFormatter from './single-select-formatter';
12
+ import MultipleSelectFormatter from './multiple-select-formatter';
13
+ import FileFormatter from './file-formatter';
14
+ import LinkFormatter from './link-formatter';
15
+ import CollaboratorFormatter from './collaborator-formatter';
16
+ import NumberFormatter from './number-formatter';
17
+ import DateFormatter from './date-formatter';
18
+ import CreatorFormatter from './creator-formatter';
19
+ import CTimeFormatter from './ctime-formatter';
20
+ import LastModifierFormatter from './last-modifier-formatter';
21
+ import MTimeFormatter from './mtime-formatter';
22
+ import GeolocationFormatter from './geolocation-formatter';
23
+ import FormulaFormatter from './formula-formatter';
24
+ import AutoNumberFormatter from './auto-number-formatter';
25
+ import UrlFormatter from './url-formatter';
26
+ import EmailFormatter from './email-formatter';
27
+ import DurationFormatter from './duration-formatter';
28
+ import RateFormatter from './rate-formatter';
29
+ import ButtonFormatter from './button-formatter';
30
+ var FormatterConfig = (_FormatterConfig = {}, _defineProperty(_FormatterConfig, CellTypes.DEFAULT, /*#__PURE__*/React.createElement(TextCellFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.TEXT, /*#__PURE__*/React.createElement(TextCellFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CHECKBOX, /*#__PURE__*/React.createElement(CheckboxFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LONG_TEXT, /*#__PURE__*/React.createElement(LongTextFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.SINGLE_SELECT, /*#__PURE__*/React.createElement(SingleSelectFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.IMAGE, /*#__PURE__*/React.createElement(ImageFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.FILE, /*#__PURE__*/React.createElement(FileFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.MULTIPLE_SELECT, /*#__PURE__*/React.createElement(MultipleSelectFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.COLLABORATOR, /*#__PURE__*/React.createElement(CollaboratorFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.NUMBER, /*#__PURE__*/React.createElement(NumberFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.DATE, /*#__PURE__*/React.createElement(DateFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LINK, /*#__PURE__*/React.createElement(LinkFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CREATOR, /*#__PURE__*/React.createElement(CreatorFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.CTIME, /*#__PURE__*/React.createElement(CTimeFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.LAST_MODIFIER, /*#__PURE__*/React.createElement(LastModifierFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.MTIME, /*#__PURE__*/React.createElement(MTimeFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.GEOLOCATION, /*#__PURE__*/React.createElement(GeolocationFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.FORMULA, /*#__PURE__*/React.createElement(FormulaFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.AUTO_NUMBER, /*#__PURE__*/React.createElement(AutoNumberFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.URL, /*#__PURE__*/React.createElement(UrlFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.EMAIL, /*#__PURE__*/React.createElement(EmailFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.DURATION, /*#__PURE__*/React.createElement(DurationFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.RATE, /*#__PURE__*/React.createElement(RateFormatter, null)), _defineProperty(_FormatterConfig, CellTypes.BUTTON, /*#__PURE__*/React.createElement(ButtonFormatter, null)), _FormatterConfig);
31
+ export default FormatterConfig;
@@ -0,0 +1,164 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import React from 'react';
7
+ import { FORMULA_RESULT_TYPE } from '../../constants';
8
+ import cellFormatterFactory from '../cell-factory/cell-formatter-factory';
9
+ import * as CellType from '../../constants/cell-types';
10
+ import { isFunction } from '../../utils/utils';
11
+ import TextFormatter from './text-formatter';
12
+ import { isArrayFormalColumn, isSimpleCellFormatter } from '../../utils/column-utils';
13
+ import cellValueValidator from '../../utils/cell-value-validator';
14
+ import { getFormulaDisplayString } from '../../utils/value-format-utils';
15
+
16
+ var FormulaFormatter = /*#__PURE__*/function (_React$Component) {
17
+ _inherits(FormulaFormatter, _React$Component);
18
+
19
+ var _super = _createSuper(FormulaFormatter);
20
+
21
+ function FormulaFormatter() {
22
+ var _this;
23
+
24
+ _classCallCheck(this, FormulaFormatter);
25
+
26
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
+ args[_key] = arguments[_key];
28
+ }
29
+
30
+ _this = _super.call.apply(_super, [this].concat(args));
31
+
32
+ _this.getGridCellClassName = function (resultType) {
33
+ switch (resultType) {
34
+ case FORMULA_RESULT_TYPE.NUMBER:
35
+ {
36
+ return 'text-right';
37
+ }
38
+
39
+ default:
40
+ {
41
+ return '';
42
+ }
43
+ }
44
+ };
45
+
46
+ _this.renderOtherColumnFormatter = function () {
47
+ var _this$props = _this.props,
48
+ value = _this$props.value,
49
+ column = _this$props.column,
50
+ collaborators = _this$props.collaborators;
51
+ var columnData = column.data;
52
+ var array_type = columnData.array_type,
53
+ array_data = columnData.array_data;
54
+
55
+ if (!array_type || array_type === CellType.LINK) {
56
+ return null;
57
+ }
58
+
59
+ var Formatter = cellFormatterFactory.createFormatter(array_type);
60
+
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);
66
+ }
67
+
68
+ var _isSimpleCellFormatterColumn = isSimpleCellFormatter(array_type);
69
+
70
+ var cellValue = value;
71
+
72
+ if (!Array.isArray(value)) {
73
+ cellValue = cellValueValidator(value, array_type) ? [value] : [];
74
+ }
75
+
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
+ }
114
+ };
115
+
116
+ return _this;
117
+ }
118
+
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
+ }, {
131
+ key: "render",
132
+ value: function render() {
133
+ var _this$props2 = this.props,
134
+ value = _this$props2.value,
135
+ containerClassName = _this$props2.containerClassName,
136
+ column = _this$props2.column,
137
+ collaborators = _this$props2.collaborators;
138
+ var columnData = column.data;
139
+ var resultType = columnData.result_type;
140
+
141
+ if (resultType === FORMULA_RESULT_TYPE.ARRAY) {
142
+ return this.renderOtherColumnFormatter();
143
+ }
144
+
145
+ if (typeof value === 'object') {
146
+ return null;
147
+ }
148
+
149
+ var gridCellClassName = this.getGridCellClassName(resultType);
150
+ var formattedValue = getFormulaDisplayString(value, columnData, {
151
+ collaborators: collaborators
152
+ });
153
+ return /*#__PURE__*/React.createElement("div", {
154
+ className: "dtable-ui cell-formatter-container formula-formatter ".concat(containerClassName, " ").concat(gridCellClassName),
155
+ title: formattedValue,
156
+ "aria-label": formattedValue
157
+ }, formattedValue);
158
+ }
159
+ }]);
160
+
161
+ return FormulaFormatter;
162
+ }(React.Component);
163
+
164
+ export default FormulaFormatter;
@@ -0,0 +1,52 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import cn from 'astro-classname';
7
+ import { getGeolocationDisplayString } from '../../utils/value-format-utils';
8
+
9
+ var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(GeolocationFormatter, _React$Component);
11
+
12
+ var _super = _createSuper(GeolocationFormatter);
13
+
14
+ function GeolocationFormatter() {
15
+ _classCallCheck(this, GeolocationFormatter);
16
+
17
+ return _super.apply(this, arguments);
18
+ }
19
+
20
+ _createClass(GeolocationFormatter, [{
21
+ key: "render",
22
+ value: function render() {
23
+ var _this$props = this.props,
24
+ value = _this$props.value,
25
+ data = _this$props.data,
26
+ containerClassName = _this$props.containerClassName;
27
+ var className = cn('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
28
+
29
+ if (typeof value !== 'object') {
30
+ return null;
31
+ }
32
+
33
+ return /*#__PURE__*/React.createElement("div", {
34
+ className: className
35
+ }, getGeolocationDisplayString(value, data));
36
+ }
37
+ }]);
38
+
39
+ return GeolocationFormatter;
40
+ }(React.Component);
41
+
42
+ GeolocationFormatter.defaultProps = {
43
+ value: {
44
+ province: '',
45
+ city: '',
46
+ district: '',
47
+ detail: ''
48
+ },
49
+ data: {},
50
+ containerClassName: ''
51
+ };
52
+ export default GeolocationFormatter;