dtable-ui-component 0.1.75 → 0.1.76

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 (163) hide show
  1. package/README.md +20 -2
  2. package/lib/AutoNumberFormatter/index.css +1 -0
  3. package/{es/components/cell-formatter/auto-number-formatter.js → lib/AutoNumberFormatter/index.js} +1 -0
  4. package/lib/ButtonFormatter/index.css +13 -0
  5. package/{es/components/cell-formatter/button-formatter.js → lib/ButtonFormatter/index.js} +1 -0
  6. package/lib/CTimeFormatter/index.css +1 -0
  7. package/{es/components/cell-formatter/ctime-formatter.js → lib/CTimeFormatter/index.js} +1 -0
  8. package/lib/CheckboxEditor/index.js +104 -0
  9. package/lib/CheckboxFormatter/index.css +1 -0
  10. package/{es/components/cell-formatter/checkbox-formatter.js → lib/CheckboxFormatter/index.js} +1 -0
  11. package/lib/CollaboratorEditor/index.css +48 -0
  12. package/lib/CollaboratorEditor/index.js +237 -0
  13. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.css +86 -0
  14. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +178 -0
  15. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.css +1 -0
  16. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +110 -0
  17. package/lib/CollaboratorFormatter/index.css +1 -0
  18. package/{es/components/cell-formatter/collaborator-formatter.js → lib/CollaboratorFormatter/index.js} +3 -2
  19. package/lib/CollaboratorItem/index.css +49 -0
  20. package/{es/components/common/collaborator-item.js → lib/CollaboratorItem/index.js} +1 -0
  21. package/lib/CreatorFormatter/index.css +1 -0
  22. package/{es/components/cell-formatter/creator-formatter.js → lib/CreatorFormatter/index.js} +3 -2
  23. package/lib/DateEditor/index.css +4 -0
  24. package/lib/DateEditor/index.js +152 -0
  25. package/{es/css → lib/DateEditor/mb-date-editor-popover}/custom-rc-calendar.css +0 -0
  26. package/lib/DateEditor/mb-date-editor-popover/index.css +45 -0
  27. package/lib/DateEditor/mb-date-editor-popover/index.js +245 -0
  28. package/lib/DateEditor/pc-date-editor-popover.js +142 -0
  29. package/lib/DateFormatter/index.css +1 -0
  30. package/{es/components/cell-formatter/date-formatter.js → lib/DateFormatter/index.js} +2 -1
  31. package/lib/DurationFormatter/index.css +1 -0
  32. package/{es/components/cell-formatter/duration-formatter.js → lib/DurationFormatter/index.js} +2 -1
  33. package/{es/components/common/edit-editor-button.js → lib/EditEditorButton/index.js} +0 -0
  34. package/lib/EmailFormatter/index.css +5 -0
  35. package/{es/components/cell-formatter/email-formatter.js → lib/EmailFormatter/index.js} +1 -0
  36. package/lib/FileEditor/index.js +46 -0
  37. package/lib/FileEditor/pc-files-addition/index.js +0 -0
  38. package/lib/FileEditor/pc-files-addition/pc-file-uploaded-item.js +0 -0
  39. package/lib/FileEditor/pc-files-preview/index.js +0 -0
  40. package/lib/FileEditor/pc-files-preview/pc-file-item-preview.js +0 -0
  41. package/lib/FileFormatter/index.css +29 -0
  42. package/{es/components/cell-formatter/file-formatter.js → lib/FileFormatter/index.js} +2 -1
  43. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/excel.png +0 -0
  44. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/file.png +0 -0
  45. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/music.png +0 -0
  46. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/pdf.png +0 -0
  47. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/pic.png +0 -0
  48. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/ppt.png +0 -0
  49. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/txt.png +0 -0
  50. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/video.png +0 -0
  51. package/{es/assets/images → lib/FileItemFormatter/assets}/file/192/word.png +0 -0
  52. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/excel.png +0 -0
  53. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/file.png +0 -0
  54. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/music.png +0 -0
  55. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/pdf.png +0 -0
  56. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/pic.png +0 -0
  57. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/ppt.png +0 -0
  58. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/txt.png +0 -0
  59. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/video.png +0 -0
  60. package/{es/assets/images → lib/FileItemFormatter/assets}/file/24/word.png +0 -0
  61. package/{es/assets/images → lib/FileItemFormatter/assets}/folder/folder-192.png +0 -0
  62. package/{es/assets/images → lib/FileItemFormatter/assets}/folder/folder-24.png +0 -0
  63. package/{es/components/cell-formatter/widgets/file-item-formatter.js → lib/FileItemFormatter/index.js} +2 -2
  64. package/lib/FileItemFormatter/utils.js +72 -0
  65. package/{es/components/file-uploader → lib/FileUploader}/index.js +0 -0
  66. package/{es/utils → lib/FormulaFormatter}/cell-value-validator.js +1 -2
  67. package/lib/FormulaFormatter/index.css +19 -0
  68. package/{es/components/cell-formatter/formula-formatter.js → lib/FormulaFormatter/index.js} +7 -8
  69. package/{es/utils/column-utils.js → lib/FormulaFormatter/utils.js} +5 -1
  70. package/lib/GeolocationFormatter/index.css +1 -0
  71. package/{es/components/cell-formatter/geolocation-formatter.js → lib/GeolocationFormatter/index.js} +2 -1
  72. package/lib/HtmlLongTextFormatter/index.css +63 -0
  73. package/{es/components/cell-formatter/widgets/long-text-formatter/html-long-text-formatter.js → lib/HtmlLongTextFormatter/index.js} +5 -2
  74. package/{es/utils → lib/HtmlLongTextFormatter}/markdown2html.js +0 -0
  75. package/{es/utils → lib/HtmlLongTextFormatter}/unified/index.js +1 -0
  76. package/{es/utils → lib/HtmlLongTextFormatter}/vfile/core.js +1 -0
  77. package/{es/utils → lib/HtmlLongTextFormatter}/vfile/index.js +0 -0
  78. package/{es/components/common → lib/ImageFormatter}/images-lazy-load.js +2 -2
  79. package/lib/ImageFormatter/index.css +34 -0
  80. package/{es/components/cell-formatter/image-formatter.js → lib/ImageFormatter/index.js} +4 -3
  81. package/lib/ImageFormatter/utils.js +7 -0
  82. package/{es/css/image-previewer-ligntbox.css → lib/ImagePreviewerLightbox/index.css} +0 -0
  83. package/{es/components/cell-formatter/widgets/image-previewer-lightbox.js → lib/ImagePreviewerLightbox/index.js} +3 -3
  84. package/lib/ImagePreviewerLightbox/utils.js +8 -0
  85. package/lib/LastModifierFormatter/index.css +1 -0
  86. package/{es/components/cell-formatter/last-modifier-formatter.js → lib/LastModifierFormatter/index.js} +5 -4
  87. package/lib/LinkEditor/index.css +9 -0
  88. package/lib/LinkEditor/index.js +304 -0
  89. package/{es/components/common → lib/LinkEditor}/link-editor-option.js +0 -0
  90. package/lib/LinkEditor/mb-link-editor-popover/index.css +85 -0
  91. package/lib/LinkEditor/mb-link-editor-popover/index.js +171 -0
  92. package/lib/LinkEditor/pc-link-editor-popover/index.css +63 -0
  93. package/lib/LinkEditor/pc-link-editor-popover/index.js +115 -0
  94. package/lib/LinkFormatter/index.css +27 -0
  95. package/{es/components/cell-formatter/link-formatter.js → lib/LinkFormatter/index.js} +2 -2
  96. package/{es/css/loading.css → lib/Loading/index.css} +0 -0
  97. package/{es/components/loading.js → lib/Loading/index.js} +1 -1
  98. package/{es/components/cell-formatter/long-text-formatter.js → lib/LongTextFormatter/index.js} +4 -6
  99. package/{es/components/common/mobile/mb-editor-header.js → lib/MBEditorHeader/index.js} +0 -0
  100. package/lib/MTimeFormatter/index.css +1 -0
  101. package/{es/components/cell-formatter/mtime-formatter.js → lib/MTimeFormatter/index.js} +1 -0
  102. package/{es/components/common/modal-portal.js → lib/ModalPortal/index.js} +0 -0
  103. package/lib/MultipleSelectEditor/index.css +9 -0
  104. package/lib/MultipleSelectEditor/index.js +236 -0
  105. package/lib/MultipleSelectFormatter/index.css +1 -0
  106. package/{es/components/cell-formatter/multiple-select-formatter.js → lib/MultipleSelectFormatter/index.js} +2 -1
  107. package/lib/NumberEditor/index.js +154 -0
  108. package/lib/NumberFormatter/index.css +1 -0
  109. package/{es/components/cell-formatter/number-formatter.js → lib/NumberFormatter/index.js} +2 -1
  110. package/lib/RateFormatter/index.css +1 -0
  111. package/{es/components/cell-formatter/rate-formatter.js → lib/RateFormatter/index.js} +1 -0
  112. package/{es/components/common/select-item.js → lib/SelectItem/index.js} +0 -0
  113. package/lib/SimpleLongTextFormatter/index.css +63 -0
  114. package/{es/components/cell-formatter/widgets/long-text-formatter/simple-long-text-formatter.js → lib/SimpleLongTextFormatter/index.js} +5 -2
  115. package/{es/utils → lib/SimpleLongTextFormatter}/normalize-long-text-value.js +3 -3
  116. package/lib/SingleSelectEditor/index.css +9 -0
  117. package/lib/SingleSelectEditor/index.js +201 -0
  118. package/lib/SingleSelectFormatter/index.css +1 -0
  119. package/{es/components/cell-formatter/single-select-formatter.js → lib/SingleSelectFormatter/index.js} +2 -1
  120. package/lib/TextEditor/index.js +122 -0
  121. package/lib/TextFormatter/index.css +1 -0
  122. package/{es/components/cell-formatter/text-formatter.js → lib/TextFormatter/index.js} +1 -0
  123. package/lib/UrlFormatter/index.css +5 -0
  124. package/{es/components/cell-formatter/url-formatter.js → lib/UrlFormatter/index.js} +1 -0
  125. package/{es → lib}/assets/images/avatar/default_avatar.png +0 -0
  126. package/{es/components/cell-factory/cell-formatter-factory.js → lib/cellFormatterFactory/index.js} +3 -3
  127. package/{es → lib}/constants/cell-types.js +0 -0
  128. package/lib/constants/index.js +49 -0
  129. package/lib/css/cell-editor.css +6 -0
  130. package/lib/css/cell-formatter.css +4 -0
  131. package/lib/css/mb-cell-editor.css +55 -0
  132. package/lib/formatterConfig/index.js +31 -0
  133. package/lib/index.js +43 -0
  134. package/{es → lib}/lang/index.js +0 -0
  135. package/{es → lib}/locals/de.js +0 -0
  136. package/{es → lib}/locals/en.js +0 -0
  137. package/{es → lib}/locals/fr.js +0 -0
  138. package/{es → lib}/locals/zh-CN.js +0 -0
  139. package/lib/select-editor/index.js +4 -0
  140. package/lib/select-editor/mb-select-editor-popover/index.css +127 -0
  141. package/lib/select-editor/mb-select-editor-popover/index.js +231 -0
  142. package/lib/select-editor/pc-select-editor-popover/index.css +72 -0
  143. package/lib/select-editor/pc-select-editor-popover/index.js +144 -0
  144. package/{es/components/common → lib/select-editor}/select-editor-option.js +0 -0
  145. package/{es/components/toast → lib/toaster}/alert.js +0 -0
  146. package/{es/components/toast → lib/toaster}/index.js +0 -0
  147. package/{es/components/toast → lib/toaster}/toast.js +0 -0
  148. package/{es/components/toast → lib/toaster}/toastManager.js +0 -0
  149. package/{es/components/toast → lib/toaster}/toaster.js +0 -0
  150. package/lib/utils/editor-utils.js +71 -0
  151. package/{es → lib}/utils/number-precision.js +1 -0
  152. package/lib/utils/utils.js +25 -0
  153. package/{es → lib}/utils/value-format-utils.js +3 -2
  154. package/package.json +8 -8
  155. package/es/app.css +0 -20
  156. package/es/app.js +0 -91
  157. package/es/components/cell-formatter/formatter-config.js +0 -31
  158. package/es/components/cell-formatter/index.js +0 -27
  159. package/es/constants/index.js +0 -48
  160. package/es/css/cell-editor.css +0 -614
  161. package/es/css/cell-formatter.css +0 -247
  162. package/es/index.js +0 -6
  163. package/es/utils/utils.js +0 -116
package/README.md CHANGED
@@ -11,8 +11,26 @@ When using dtable-ui-component component library, you need to import dtable-font
11
11
 
12
12
  ```js
13
13
  import { CollaboratorEditor } from 'dtable-ui-component';
14
-
15
14
  import 'dtable-ui-component/assets/dtable-font.css';
16
15
 
17
16
  ...
18
- ```
17
+ ```
18
+
19
+ ## load demand
20
+
21
+ If you want to use on-demand loading, add the following content to the ` .babelrc` file of your project
22
+
23
+ ```js
24
+ "plugins": [
25
+ ["on-demand-loading", {"library": "dtable-ui-component"}]
26
+ ]
27
+ ```
28
+
29
+ Long Text Formatter
30
+
31
+ If your project only uses a simple long text formatter, you can reference the SimpleLongTextFormatter component.
32
+
33
+ ```js
34
+ import { SimpleLongTextFormatter } from 'dtable-ui-component';
35
+ ```
36
+
@@ -0,0 +1 @@
1
+ @import url('../css/cell-formatter.css');
@@ -4,6 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import cn from 'astro-classname';
7
+ import './index.css';
7
8
 
8
9
  var AutoNumberFormatter = /*#__PURE__*/function (_React$Component) {
9
10
  _inherits(AutoNumberFormatter, _React$Component);
@@ -0,0 +1,13 @@
1
+ @import url('../css/cell-formatter.css');
2
+
3
+ .dtable-ui.button-formatter {
4
+ height: 26px;
5
+ width: 80px;
6
+ padding: 5px 8px;
7
+ border-width: 1px;
8
+ border-style: solid;
9
+ border-radius: 3px;
10
+ overflow: hidden;
11
+ white-space: nowrap;
12
+ text-overflow: ellipsis;
13
+ }
@@ -4,6 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import cn from 'astro-classname';
7
+ import './index.css';
7
8
 
8
9
  var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
9
10
  _inherits(ButtonFormatter, _React$Component);
@@ -0,0 +1 @@
1
+ @import url('../css/cell-formatter.css');
@@ -5,6 +5,7 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import cn from 'astro-classname';
7
7
  import moment from 'moment';
8
+ import './index.css';
8
9
 
9
10
  var CTimeFormatter = /*#__PURE__*/function (_React$Component) {
10
11
  _inherits(CTimeFormatter, _React$Component);
@@ -0,0 +1,104 @@
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
+
7
+ var CheckboxEditor = /*#__PURE__*/function (_React$Component) {
8
+ _inherits(CheckboxEditor, _React$Component);
9
+
10
+ var _super = _createSuper(CheckboxEditor);
11
+
12
+ function CheckboxEditor(props) {
13
+ var _this;
14
+
15
+ _classCallCheck(this, CheckboxEditor);
16
+
17
+ _this = _super.call(this, props);
18
+
19
+ _this.getValue = function () {
20
+ var updated = {};
21
+ var column = _this.props.column;
22
+ updated[column.key] = _this.state.value;
23
+ return updated;
24
+ };
25
+
26
+ _this.onCommit = function () {
27
+ var updated = _this.getValue();
28
+
29
+ _this.props.onCommit(updated);
30
+ };
31
+
32
+ _this.onChange = function (event) {
33
+ if (_this.props.isReadOnly) {
34
+ return;
35
+ }
36
+
37
+ var value = event.target.checked;
38
+
39
+ if (value === _this.state.value) {
40
+ return;
41
+ }
42
+
43
+ _this.setState({
44
+ value: value
45
+ }, function () {
46
+ _this.onCommit();
47
+ });
48
+ };
49
+
50
+ _this.onKeyDown = function (event) {
51
+ event.stopPropagation();
52
+ };
53
+
54
+ _this.onBlur = function () {// this.onCommit();
55
+ };
56
+
57
+ _this.setInputRef = function (input) {
58
+ _this.input = input;
59
+ };
60
+
61
+ _this.getStyle = function () {
62
+ return {
63
+ marginLeft: 0,
64
+ transform: 'scale(1.1)'
65
+ };
66
+ };
67
+
68
+ _this.state = {
69
+ value: props.value ? props.value : false
70
+ };
71
+ return _this;
72
+ }
73
+
74
+ _createClass(CheckboxEditor, [{
75
+ key: "render",
76
+ value: function render() {
77
+ var style = this.getStyle();
78
+ return /*#__PURE__*/React.createElement("div", {
79
+ className: "cell-editor checkbox-editor"
80
+ }, /*#__PURE__*/React.createElement("div", {
81
+ className: "checkbox-editor-container"
82
+ }, /*#__PURE__*/React.createElement("input", {
83
+ ref: this.setInputRef,
84
+ type: "checkbox",
85
+ className: "checkbox",
86
+ checked: this.state.value,
87
+ onBlur: this.onBlur,
88
+ onPaste: this.onPaste,
89
+ onKeyDown: this.onKeyDown,
90
+ onChange: this.onChange,
91
+ style: style,
92
+ readOnly: this.props.isReadOnly
93
+ })));
94
+ }
95
+ }]);
96
+
97
+ return CheckboxEditor;
98
+ }(React.Component);
99
+
100
+ CheckboxEditor.defaultProps = {
101
+ isReadOnly: false,
102
+ value: false
103
+ };
104
+ export default CheckboxEditor;
@@ -0,0 +1 @@
1
+ @import url('../css/cell-formatter.css');
@@ -4,6 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
4
  import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import cn from 'astro-classname';
7
+ import './index.css';
7
8
 
8
9
  var CheckboxFormatter = /*#__PURE__*/function (_React$PureComponent) {
9
10
  _inherits(CheckboxFormatter, _React$PureComponent);
@@ -0,0 +1,48 @@
1
+ .dtable-ui-collaborator-editor {
2
+ position: relative;
3
+ }
4
+
5
+ .dtable-ui-collaborator-editor-container .collaborators-container {
6
+ margin-top: 8px;
7
+ }
8
+
9
+ .dtable-ui-collaborator-editor-popover .collaborator-search-container {
10
+ padding: 10px 10px 0 10px;
11
+ }
12
+
13
+ .dtable-ui-collaborator-editor-popover .collaborator-search-container input {
14
+ height: 28px;
15
+ }
16
+
17
+ .dtable-ui-collaborator-editor-popover .collaborator-list-container {
18
+ min-height: 160px;
19
+ max-height: 200px;
20
+ margin: 10px 0;
21
+ padding: 0 10px;
22
+ overflow: auto;
23
+ }
24
+
25
+ .dtable-ui-collaborator-editor-popover .collaborator-list-container .collaborator-item-container {
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: space-between;
29
+ height: 30px;
30
+ padding-left: 12px;
31
+ font-size: 14px;
32
+ margin-left: 10px;
33
+ cursor: pointer;
34
+ }
35
+
36
+ .dtable-ui-collaborator-editor-popover .collaborator-list-container .collaborator-item-container:hover {
37
+ background-color: #f5f5f5;
38
+ }
39
+
40
+ .dtable-ui-collaborator-editor-popover .collaborator-checked {
41
+ width: 20px;
42
+ text-align: center;
43
+ }
44
+
45
+ .dtable-ui-collaborator-editor-popover .collaborator-checked .dtable-font {
46
+ font-size: 12px;
47
+ color: #798d99;
48
+ }
@@ -0,0 +1,237 @@
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, { Fragment } from 'react';
6
+ import MediaQuery from 'react-responsive';
7
+ import { getLocale } from '../lang';
8
+ import CollaboratorItem from '../CollaboratorItem';
9
+ import EditEditorButton from '../EditEditorButton';
10
+ import PCCollaboratorEditorPopover from './pc-collaborator-editor-popover';
11
+ import MBCollaboratorEditorPopover from './mb-collaborator-editor-popover';
12
+ import './index.css';
13
+
14
+ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
15
+ _inherits(CollaboratorEditor, _React$Component);
16
+
17
+ var _super = _createSuper(CollaboratorEditor);
18
+
19
+ function CollaboratorEditor(props) {
20
+ var _this;
21
+
22
+ _classCallCheck(this, CollaboratorEditor);
23
+
24
+ _this = _super.call(this, props);
25
+
26
+ _this.onDocumentToggle = function (e) {
27
+ if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
28
+ _this.onClosePopover();
29
+ }
30
+ };
31
+
32
+ _this.getFormattedCollaborators = function () {
33
+ var newValue = _this.state.newValue;
34
+
35
+ if (Array.isArray(newValue) && newValue.length > 0) {
36
+ var collaborators = _this.props.collaborators;
37
+ return newValue.map(function (collaboratorEmail) {
38
+ return collaborators.find(function (collaborator) {
39
+ return collaborator.email === collaboratorEmail;
40
+ });
41
+ }).filter(function (collaborator) {
42
+ return !!collaborator;
43
+ });
44
+ }
45
+
46
+ return [];
47
+ };
48
+
49
+ _this.onAddOptionToggle = function (event) {
50
+ event.nativeEvent.stopImmediatePropagation();
51
+ event.stopPropagation();
52
+
53
+ if (_this.props.isReadOnly) {
54
+ return;
55
+ }
56
+
57
+ var isPopoverShow = !_this.state.isPopoverShow;
58
+
59
+ if (isPopoverShow) {
60
+ var popoverPosition = _this.caculatePopoverPosition();
61
+
62
+ _this.setState({
63
+ isPopoverShow: isPopoverShow,
64
+ popoverPosition: popoverPosition
65
+ });
66
+ } else {
67
+ _this.setState({
68
+ isPopoverShow: isPopoverShow
69
+ });
70
+ }
71
+ };
72
+
73
+ _this.onCommit = function (newValue) {
74
+ var updated = {};
75
+ var column = _this.props.column;
76
+ updated[column.key] = newValue;
77
+
78
+ _this.props.onCommit(updated);
79
+ };
80
+
81
+ _this.onCollaboratorItemToggle = function (collaborator) {
82
+ var newValue = _this.state.newValue.slice();
83
+
84
+ var collaboratorIndex = newValue.findIndex(function (collaboratorEmail) {
85
+ return collaboratorEmail === collaborator.email;
86
+ });
87
+
88
+ if (collaboratorIndex !== -1) {
89
+ newValue.splice(collaboratorIndex, 1);
90
+ } else {
91
+ newValue.push(collaborator.email);
92
+ }
93
+
94
+ _this.setState({
95
+ newValue: newValue
96
+ }, function () {
97
+ _this.onCommit(newValue);
98
+
99
+ _this.onClosePopover();
100
+ });
101
+ };
102
+
103
+ _this.onDeleteCollaborator = function (collaborator) {
104
+ var newValue = _this.state.newValue.slice();
105
+
106
+ var optionIndex = newValue.findIndex(function (collaboratorEmail) {
107
+ return collaboratorEmail === collaborator.email;
108
+ });
109
+
110
+ if (optionIndex > -1) {
111
+ newValue.splice(optionIndex, 1);
112
+
113
+ _this.setState({
114
+ newValue: newValue
115
+ }, function () {
116
+ _this.onCommit(newValue);
117
+ });
118
+ }
119
+ };
120
+
121
+ _this.caculatePopoverPosition = function () {
122
+ var POPOVER_MAX_HEIGHT = 200;
123
+ var innerHeight = window.innerHeight;
124
+
125
+ var _this$editor$getClien = _this.editor.getClientRects()[0],
126
+ top = _this$editor$getClien.top,
127
+ height = _this$editor$getClien.height;
128
+
129
+ var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
130
+ var position = {
131
+ top: height + 1,
132
+ left: 0
133
+ };
134
+
135
+ if (!isBelow) {
136
+ var bottom = height + 1;
137
+ position = {
138
+ bottom: bottom,
139
+ left: 0
140
+ };
141
+ }
142
+
143
+ return position;
144
+ };
145
+
146
+ _this.onClosePopover = function () {
147
+ _this.setState({
148
+ isPopoverShow: false
149
+ });
150
+ };
151
+
152
+ _this.setEditorContainerRef = function (editorContainer) {
153
+ _this.editorContainer = editorContainer;
154
+ };
155
+
156
+ _this.setEditorRef = function (editor) {
157
+ _this.editor = editor;
158
+ };
159
+
160
+ _this.state = {
161
+ newValue: Array.isArray(props.value) ? props.value : [],
162
+ isPopoverShow: false,
163
+ popoverPosition: {}
164
+ };
165
+ return _this;
166
+ }
167
+
168
+ _createClass(CollaboratorEditor, [{
169
+ key: "componentDidMount",
170
+ value: function componentDidMount() {
171
+ document.addEventListener('click', this.onDocumentToggle);
172
+ }
173
+ }, {
174
+ key: "componentWillUnmount",
175
+ value: function componentWillUnmount() {
176
+ document.removeEventListener('click', this.onDocumentToggle);
177
+ }
178
+ }, {
179
+ key: "render",
180
+ value: function render() {
181
+ var _this2 = this;
182
+
183
+ var _this$props = this.props,
184
+ collaborators = _this$props.collaborators,
185
+ isReadOnly = _this$props.isReadOnly;
186
+ var _this$state = this.state,
187
+ isPopoverShow = _this$state.isPopoverShow,
188
+ popoverPosition = _this$state.popoverPosition;
189
+ var selectedCollaborators = this.getFormattedCollaborators();
190
+ var enableDeleteCollaborator = !isReadOnly;
191
+ return /*#__PURE__*/React.createElement("div", {
192
+ ref: this.setEditorContainerRef,
193
+ className: "cell-editor dtable-ui-collaborator-editor"
194
+ }, /*#__PURE__*/React.createElement("div", {
195
+ ref: this.setEditorRef,
196
+ className: "dtable-ui-collaborator-editor-container"
197
+ }, /*#__PURE__*/React.createElement(EditEditorButton, {
198
+ text: getLocale('Add_a_collaborator'),
199
+ onClick: this.onAddOptionToggle
200
+ }), /*#__PURE__*/React.createElement("div", {
201
+ className: "collaborators-container"
202
+ }, selectedCollaborators.length > 0 && selectedCollaborators.map(function (collaborator) {
203
+ return /*#__PURE__*/React.createElement(CollaboratorItem, {
204
+ key: collaborator.email,
205
+ collaborator: collaborator,
206
+ enableDeleteCollaborator: enableDeleteCollaborator,
207
+ onDeleteCollaborator: _this2.onDeleteCollaborator
208
+ });
209
+ }))), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
210
+ query: '(min-width: 768px)'
211
+ }, /*#__PURE__*/React.createElement(PCCollaboratorEditorPopover, {
212
+ popoverPosition: popoverPosition,
213
+ isReadOnly: this.props.isReadOnly,
214
+ selectedCollaborators: selectedCollaborators,
215
+ collaborators: collaborators,
216
+ onCollaboratorItemToggle: this.onCollaboratorItemToggle
217
+ })), /*#__PURE__*/React.createElement(MediaQuery, {
218
+ query: '(max-width: 767.8px)'
219
+ }, /*#__PURE__*/React.createElement(MBCollaboratorEditorPopover, {
220
+ isReadOnly: this.props.isReadOnly,
221
+ value: this.state.newValue,
222
+ column: this.props.column,
223
+ collaborators: this.props.collaborators,
224
+ onCollaboratorItemToggle: this.onCollaboratorItemToggle,
225
+ onClosePopover: this.onClosePopover
226
+ }))));
227
+ }
228
+ }]);
229
+
230
+ return CollaboratorEditor;
231
+ }(React.Component);
232
+
233
+ CollaboratorEditor.defaultProps = {
234
+ isReadOnly: false,
235
+ value: []
236
+ };
237
+ export default CollaboratorEditor;
@@ -0,0 +1,86 @@
1
+ @import url('../../css/mb-cell-editor.css');
2
+
3
+ @media screen and (max-width: 767.8px) {
4
+ .dtable-ui-mb-collaborator-editor-body .mb-search-collaborator-items {
5
+ padding: 8px 16px;
6
+ margin-top: 20px;
7
+ border-top: 1px solid #e9e9e9;
8
+ border-bottom: 1px solid #e9e9e9;
9
+ background-color: #fff;
10
+ }
11
+
12
+ .dtable-ui-mb-collaborator-editor-body .mb-search-collaborator-items > input {
13
+ outline: none;
14
+ height: 30px;
15
+ padding: 0;
16
+ line-height: 30px;
17
+ border: none;
18
+ }
19
+
20
+ .dtable-ui-mb-collaborator-editor-body .mb-search-collaborator-items > input:focus,
21
+ .dtable-ui-mb-collaborator-editor-body .mb-search-collaborator-items > input:active {
22
+ outline: none;
23
+ box-shadow: none;
24
+ }
25
+
26
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborators-container {
27
+ flex: 1;
28
+ display: flex;
29
+ flex-direction: column;
30
+ margin-top: 10px;
31
+ min-height: 0;
32
+ }
33
+
34
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborators-container .title {
35
+ padding: 6px 16px;
36
+ border-bottom: 1px solid #e9e9e9;
37
+ }
38
+
39
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborators-container .content {
40
+ flex: 1;
41
+ overflow: auto;
42
+ display: flex;
43
+ flex-direction: column;
44
+ border-bottom: 1px solid #e9e9e9;
45
+ }
46
+
47
+ .dtable-ui-mb-collaborator-editor-body .search-result-none {
48
+ padding: 16px 0 16px 16px;
49
+ }
50
+
51
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborator-option-item {
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: space-between;
55
+ height: 50px;
56
+ padding: 10px 10px 10px 16px;
57
+ font-size: 13px;
58
+ background-color: #fff;
59
+ color: #202428;
60
+ }
61
+
62
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborator-option-item {
63
+ border-bottom: 1px solid #e9e9e9;
64
+ }
65
+
66
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborator-option-item .mb-collaborator-info {
67
+ display: flex;
68
+ align-items: center;
69
+ }
70
+
71
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborator-option-item .collaborator-avatar img {
72
+ width: 24px;
73
+ height: 24px;
74
+ border-radius: 50%;
75
+ }
76
+
77
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborator-option-item .collaborator-name {
78
+ padding: 0 10px;
79
+ overflow: hidden;
80
+ }
81
+
82
+ .dtable-ui-mb-collaborator-editor-body .mb-collaborator-option-item .dtable-font {
83
+ font-size: 12px;
84
+ color: #798d99;
85
+ }
86
+ }