dtable-ui-component 0.1.84 → 0.1.87

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 (124) hide show
  1. package/lib/DTableCustomizeCollaboratorSelect/index.css +124 -0
  2. package/lib/DTableCustomizeCollaboratorSelect/index.js +187 -0
  3. package/lib/DTableCustomizeCollaboratorSelect/utils.js +24 -0
  4. package/lib/DTableCustomizeSelect/index.js +155 -0
  5. package/lib/DTablePopover/index.js +115 -0
  6. package/lib/DTablePopover/utils.js +5 -0
  7. package/lib/DTableSearchInput/index.js +161 -0
  8. package/lib/DTableSearchInput/utils.js +4 -0
  9. package/lib/DTableSelect/index.js +141 -0
  10. package/lib/DTableSwitch/index.js +27 -0
  11. package/lib/SelectOptionGroup/KeyCodes.js +10 -0
  12. package/lib/SelectOptionGroup/index.js +217 -0
  13. package/lib/SelectOptionGroup/option.js +60 -0
  14. package/lib/assets/css/DTableCustomSelect.css +148 -0
  15. package/lib/index.js +8 -1
  16. package/package.json +2 -1
  17. package/es/app.css +0 -20
  18. package/es/app.js +0 -91
  19. package/es/assets/images/avatar/default_avatar.png +0 -0
  20. package/es/assets/images/file/192/excel.png +0 -0
  21. package/es/assets/images/file/192/file.png +0 -0
  22. package/es/assets/images/file/192/music.png +0 -0
  23. package/es/assets/images/file/192/pdf.png +0 -0
  24. package/es/assets/images/file/192/pic.png +0 -0
  25. package/es/assets/images/file/192/ppt.png +0 -0
  26. package/es/assets/images/file/192/txt.png +0 -0
  27. package/es/assets/images/file/192/video.png +0 -0
  28. package/es/assets/images/file/192/word.png +0 -0
  29. package/es/assets/images/file/24/excel.png +0 -0
  30. package/es/assets/images/file/24/file.png +0 -0
  31. package/es/assets/images/file/24/music.png +0 -0
  32. package/es/assets/images/file/24/pdf.png +0 -0
  33. package/es/assets/images/file/24/pic.png +0 -0
  34. package/es/assets/images/file/24/ppt.png +0 -0
  35. package/es/assets/images/file/24/txt.png +0 -0
  36. package/es/assets/images/file/24/video.png +0 -0
  37. package/es/assets/images/file/24/word.png +0 -0
  38. package/es/assets/images/folder/folder-192.png +0 -0
  39. package/es/assets/images/folder/folder-24.png +0 -0
  40. package/es/components/cell-editor/checkbox-editor.js +0 -104
  41. package/es/components/cell-editor/collaborator-editor.js +0 -236
  42. package/es/components/cell-editor/date-editor.js +0 -151
  43. package/es/components/cell-editor/index.js +0 -9
  44. package/es/components/cell-editor/link-editor.js +0 -303
  45. package/es/components/cell-editor/multiple-select-editor.js +0 -237
  46. package/es/components/cell-editor/number-editor.js +0 -154
  47. package/es/components/cell-editor/single-select-editor.js +0 -202
  48. package/es/components/cell-editor/text-editor.js +0 -122
  49. package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
  50. package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
  51. package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
  52. package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
  53. package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
  54. package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
  55. package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
  56. package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
  57. package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
  58. package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
  59. package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
  60. package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
  61. package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
  62. package/es/components/cell-factory/cell-formatter-factory.js +0 -25
  63. package/es/components/cell-formatter/auto-number-formatter.js +0 -35
  64. package/es/components/cell-formatter/button-formatter.js +0 -55
  65. package/es/components/cell-formatter/checkbox-formatter.js +0 -44
  66. package/es/components/cell-formatter/collaborator-formatter.js +0 -91
  67. package/es/components/cell-formatter/creator-formatter.js +0 -87
  68. package/es/components/cell-formatter/ctime-formatter.js +0 -57
  69. package/es/components/cell-formatter/date-formatter.js +0 -59
  70. package/es/components/cell-formatter/duration-formatter.js +0 -37
  71. package/es/components/cell-formatter/email-formatter.js +0 -35
  72. package/es/components/cell-formatter/file-formatter.js +0 -63
  73. package/es/components/cell-formatter/formatter-config.js +0 -31
  74. package/es/components/cell-formatter/formula-formatter.js +0 -164
  75. package/es/components/cell-formatter/geolocation-formatter.js +0 -52
  76. package/es/components/cell-formatter/image-formatter.js +0 -153
  77. package/es/components/cell-formatter/index.js +0 -27
  78. package/es/components/cell-formatter/last-modifier-formatter.js +0 -87
  79. package/es/components/cell-formatter/link-formatter.js +0 -144
  80. package/es/components/cell-formatter/long-text-formatter.js +0 -106
  81. package/es/components/cell-formatter/mtime-formatter.js +0 -57
  82. package/es/components/cell-formatter/multiple-select-formatter.js +0 -69
  83. package/es/components/cell-formatter/number-formatter.js +0 -46
  84. package/es/components/cell-formatter/rate-formatter.js +0 -79
  85. package/es/components/cell-formatter/single-select-formatter.js +0 -69
  86. package/es/components/cell-formatter/text-formatter.js +0 -55
  87. package/es/components/cell-formatter/url-formatter.js +0 -35
  88. package/es/components/cell-formatter/widgets/file-item-formatter.js +0 -50
  89. package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -119
  90. package/es/components/common/collaborator-item.js +0 -63
  91. package/es/components/common/edit-editor-button.js +0 -56
  92. package/es/components/common/images-lazy-load.js +0 -150
  93. package/es/components/common/link-editor-option.js +0 -113
  94. package/es/components/common/mobile/mb-editor-header.js +0 -48
  95. package/es/components/common/modal-portal.js +0 -44
  96. package/es/components/common/select-editor-option.js +0 -106
  97. package/es/components/common/select-item.js +0 -58
  98. package/es/components/file-uploader/index.js +0 -53
  99. package/es/components/loading.js +0 -7
  100. package/es/components/toast/alert.js +0 -150
  101. package/es/components/toast/index.js +0 -3
  102. package/es/components/toast/toast.js +0 -179
  103. package/es/components/toast/toastManager.js +0 -170
  104. package/es/components/toast/toaster.js +0 -76
  105. package/es/constants/cell-types.js +0 -25
  106. package/es/constants/index.js +0 -48
  107. package/es/css/cell-editor.css +0 -614
  108. package/es/css/cell-formatter.css +0 -241
  109. package/es/css/custom-rc-calendar.css +0 -118
  110. package/es/css/image-previewer-ligntbox.css +0 -87
  111. package/es/css/loading.css +0 -54
  112. package/es/index.js +0 -6
  113. package/es/lang/index.js +0 -50
  114. package/es/locals/de.js +0 -2
  115. package/es/locals/en.js +0 -17
  116. package/es/locals/fr.js +0 -2
  117. package/es/locals/zh-CN.js +0 -17
  118. package/es/utils/cell-value-validator.js +0 -32
  119. package/es/utils/column-utils.js +0 -7
  120. package/es/utils/editor-utils.js +0 -71
  121. package/es/utils/normalize-long-text-value.js +0 -68
  122. package/es/utils/number-precision.js +0 -163
  123. package/es/utils/utils.js +0 -116
  124. package/es/utils/value-format-utils.js +0 -495
@@ -0,0 +1,148 @@
1
+ .dtable-select {
2
+ position: relative;
3
+ }
4
+
5
+ .dtable-select.custom-select {
6
+ display: flex;
7
+ padding: 0 10px;
8
+ border-radius: 3px;
9
+ align-items: center;
10
+ justify-content: space-between;
11
+ max-width: 900px;
12
+ user-select: none;
13
+ -webkit-user-select: none;
14
+ -moz-user-select: none;
15
+ -o-user-select: none;
16
+ -ms-user-select: none;
17
+ text-align: left;
18
+ }
19
+
20
+ .dtable-select.custom-select:focus,
21
+ .dtable-select.custom-select.focus {
22
+ border-color: #1991eb !important;
23
+ box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.25);
24
+ }
25
+
26
+ .dtable-select.custom-select.disabled:focus,
27
+ .dtable-select.custom-select.focus.disabled,
28
+ .dtable-select.custom-select.disabled:hover {
29
+ border-color: rgba(0, 40, 100, 0.12) !important;
30
+ box-shadow: unset;
31
+ cursor: default;
32
+ }
33
+
34
+ .dtable-select.custom-select:hover {
35
+ cursor: pointer;
36
+ border-color: rgb(179, 179, 179);
37
+ }
38
+
39
+ .dtable-select .select-option-name {
40
+ color: #202428;
41
+ }
42
+
43
+ .dtable-select .dtable-icon-drop-down {
44
+ display: inline-block;
45
+ font-size: 12px;
46
+ color: #949494;
47
+ transform: scale(.8) translateY(2px);
48
+ transition: all .1s;
49
+ }
50
+
51
+ .dtable-select .dtable-icon-drop-down:hover {
52
+ color: #000;
53
+ }
54
+
55
+ .dtable-select .selected-option {
56
+ display: flex;
57
+ flex: 1;
58
+ overflow: hidden;
59
+ flex-wrap: nowrap;
60
+ align-items: center;
61
+ justify-content: space-between;
62
+ background: #fff;
63
+ }
64
+
65
+ .dtable-select .option-group {
66
+ position: absolute;
67
+ left: 0;
68
+ min-height: 60px;
69
+ max-height: 300px;
70
+ min-width: 100%;
71
+ max-width: 15rem;
72
+ padding: .5rem 0;
73
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
74
+ background: #fff;
75
+ border: 1px solid rgba(0, 40, 100, 0.12);
76
+ border-radius: 3px;
77
+ z-index: 10001;
78
+ }
79
+
80
+ .dtable-select .option-group .option-group-search {
81
+ width: 100%;
82
+ padding: 0 10px 6px 10px;
83
+ min-width: 170px;
84
+ }
85
+
86
+ .dtable-select .option-group-search .form-control {
87
+ height: 31px;
88
+ }
89
+
90
+ .dtable-select .option-group .none-search-result {
91
+ height: 100px;
92
+ width: 100%;
93
+ padding: 10px;
94
+ opacity: .5;
95
+ }
96
+
97
+ .dtable-select .option-group .option-group-content {
98
+ max-height: 252px;
99
+ overflow-y: auto;
100
+ }
101
+
102
+ .dtable-select .option {
103
+ display: block;
104
+ width: 100%;
105
+ line-height: 24px;
106
+ padding: .25rem 10px;
107
+ clear: both;
108
+ font-weight: 400;
109
+ color: #212529;
110
+ text-align: inherit;
111
+ background-color: transparent;
112
+ border: 0;
113
+ overflow: hidden;
114
+ text-overflow: ellipsis;
115
+ white-space: nowrap;
116
+ }
117
+
118
+ .dtable-select.selector-collaborator .option-group .option-group-content {
119
+ padding: 10px;
120
+ }
121
+
122
+ .dtable-select.selector-collaborator .option {
123
+ padding: 5px 0 5px 10px !important;
124
+ line-height: 20px;
125
+ }
126
+
127
+ .dtable-select .option.option-active {
128
+ background-color: #20a0ff;
129
+ color: #fff;
130
+ cursor: pointer;
131
+ }
132
+
133
+ .dtable-select .option.option-active .select-option-name {
134
+ color: #fff;
135
+ }
136
+
137
+ .dtable-select .selected-option-show {
138
+ overflow: hidden;
139
+ text-overflow: ellipsis;
140
+ white-space: nowrap;
141
+ }
142
+
143
+ .dtable-select .select-placeholder {
144
+ line-height: 1;
145
+ font-size: 14px;
146
+ color: #949494;
147
+ white-space: nowrap;
148
+ }
package/lib/index.js CHANGED
@@ -41,4 +41,11 @@ export { default as SingleSelectEditor } from './SingleSelectEditor';
41
41
  export { default as MultipleSelectEditor } from './MultipleSelectEditor';
42
42
  export { default as CollaboratorEditor } from './CollaboratorEditor';
43
43
  export { default as DateEditor } from './DateEditor';
44
- export { default as LinkEditor } from './LinkEditor';
44
+ export { default as LinkEditor } from './LinkEditor'; // dtable custom
45
+
46
+ export { default as DTablePopover } from './DTablePopover';
47
+ export { default as DTableSelect } from './DTableSelect';
48
+ export { default as DTableSwitch } from './DTableSwitch';
49
+ export { default as DTableCustomizeSelect } from './DTableCustomizeSelect';
50
+ export { default as DTableCustomizeCollaboratorSelect } from './DTableCustomizeCollaboratorSelect';
51
+ export { default as DTableSearchInput } from './DTableSearchInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "0.1.84",
3
+ "version": "0.1.87",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "0.0.9",
@@ -22,6 +22,7 @@
22
22
  "react-responsive": "^8.0.3",
23
23
  "react-transition-group": "^4.4.1",
24
24
  "reactstrap": "^8.4.1",
25
+ "react-select": "4.3.0",
25
26
  "rehype-format": "^2.2.0",
26
27
  "rehype-mathjax": "^2.0.0",
27
28
  "rehype-raw": "^2.0.0",
package/es/app.css DELETED
@@ -1,20 +0,0 @@
1
- html, body, #root {
2
- width: 100%;
3
- height: 100%;
4
- }
5
-
6
- .app {
7
- width: 100%;
8
- height: 100%;
9
- display: flex;
10
- flex-direction: column;
11
- }
12
-
13
- .app .app-body {
14
- flex: 1;
15
- }
16
-
17
- .app .app-body .collaborator-container {
18
- padding: 5px;
19
- border: 1px solid;
20
- }
package/es/app.js DELETED
@@ -1,91 +0,0 @@
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 { CollaboratorFormatter, SingleSelectFormatter } from './components/cell-formatter';
7
- import './app.css';
8
-
9
- var App = /*#__PURE__*/function (_React$Component) {
10
- _inherits(App, _React$Component);
11
-
12
- var _super = _createSuper(App);
13
-
14
- function App() {
15
- var _this;
16
-
17
- _classCallCheck(this, App);
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.onDeleteCollaborator = function () {//
26
- };
27
-
28
- return _this;
29
- }
30
-
31
- _createClass(App, [{
32
- key: "render",
33
- value: function render() {
34
- var collaborators = [{
35
- name: '小强',
36
- email: '214402@qq.com',
37
- avatar_url: '你好饿',
38
- contact_email: 'adbd'
39
- }];
40
- var options = [{
41
- id: '1111',
42
- name: '未开始',
43
- color: '#e3f9f6'
44
- }, {
45
- id: '2222',
46
- name: '进行中',
47
- color: '#ff7500'
48
- }, {
49
- id: '3333',
50
- name: '待评审',
51
- color: '#eaff56'
52
- }, {
53
- id: '4444',
54
- name: '已评审',
55
- color: '#faff72'
56
- }, {
57
- id: '5555',
58
- name: '完成',
59
- color: '#00e500'
60
- }];
61
- return /*#__PURE__*/React.createElement("div", {
62
- className: "app"
63
- }, /*#__PURE__*/React.createElement("header", {
64
- className: "app-header"
65
- }, /*#__PURE__*/React.createElement("h1", {
66
- className: "text-center"
67
- }, 'seatable ui component test')), /*#__PURE__*/React.createElement("div", {
68
- className: "app-body"
69
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h2", null, "collaborators\u6D4B\u8BD5"), /*#__PURE__*/React.createElement("div", null, "\u5355\u4E2Acollaborators\u6D4B\u8BD5"), /*#__PURE__*/React.createElement(CollaboratorFormatter, {
70
- value: '123',
71
- collaborators: collaborators
72
- }), /*#__PURE__*/React.createElement("div", null, "\u591A\u4E2Acollaborators\u6D4B\u8BD5"), /*#__PURE__*/React.createElement(CollaboratorFormatter, {
73
- value: ['123', '4567'],
74
- collaborators: collaborators
75
- }), /*#__PURE__*/React.createElement("div", null, "\u5E26\u5220\u9664\u6309\u94AE\u6D4B\u8BD5"), /*#__PURE__*/React.createElement(CollaboratorFormatter, {
76
- containerClassName: "collaborator-container",
77
- value: ['123', '4567'],
78
- collaborators: collaborators,
79
- enableDeleteCollaborator: true,
80
- onDeleteCollaborator: this.onDeleteCollaborator
81
- })), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h2", null, "single-select\u6D4B\u8BD5"), /*#__PURE__*/React.createElement(SingleSelectFormatter, {
82
- value: '3333',
83
- options: options
84
- }))));
85
- }
86
- }]);
87
-
88
- return App;
89
- }(React.Component);
90
-
91
- export default App;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,104 +0,0 @@
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;
@@ -1,236 +0,0 @@
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 '../common/collaborator-item';
9
- import EditEditorButton from '../common/edit-editor-button';
10
- import PCCollaboratorEditorPopover from '../cell-editor-popover/pc-collaborator-editor-popover';
11
- import MBCollaboratorEditorPopover from '../cell-editor-popover/mb-collaborator-editor-popover';
12
-
13
- var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
14
- _inherits(CollaboratorEditor, _React$Component);
15
-
16
- var _super = _createSuper(CollaboratorEditor);
17
-
18
- function CollaboratorEditor(props) {
19
- var _this;
20
-
21
- _classCallCheck(this, CollaboratorEditor);
22
-
23
- _this = _super.call(this, props);
24
-
25
- _this.onDocumentToggle = function (e) {
26
- if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
27
- _this.onClosePopover();
28
- }
29
- };
30
-
31
- _this.getFormattedCollaborators = function () {
32
- var newValue = _this.state.newValue;
33
-
34
- if (Array.isArray(newValue) && newValue.length > 0) {
35
- var collaborators = _this.props.collaborators;
36
- return newValue.map(function (collaboratorEmail) {
37
- return collaborators.find(function (collaborator) {
38
- return collaborator.email === collaboratorEmail;
39
- });
40
- }).filter(function (collaborator) {
41
- return !!collaborator;
42
- });
43
- }
44
-
45
- return [];
46
- };
47
-
48
- _this.onAddOptionToggle = function (event) {
49
- event.nativeEvent.stopImmediatePropagation();
50
- event.stopPropagation();
51
-
52
- if (_this.props.isReadOnly) {
53
- return;
54
- }
55
-
56
- var isPopoverShow = !_this.state.isPopoverShow;
57
-
58
- if (isPopoverShow) {
59
- var popoverPosition = _this.caculatePopoverPosition();
60
-
61
- _this.setState({
62
- isPopoverShow: isPopoverShow,
63
- popoverPosition: popoverPosition
64
- });
65
- } else {
66
- _this.setState({
67
- isPopoverShow: isPopoverShow
68
- });
69
- }
70
- };
71
-
72
- _this.onCommit = function (newValue) {
73
- var updated = {};
74
- var column = _this.props.column;
75
- updated[column.key] = newValue;
76
-
77
- _this.props.onCommit(updated);
78
- };
79
-
80
- _this.onCollaboratorItemToggle = function (collaborator) {
81
- var newValue = _this.state.newValue.slice();
82
-
83
- var collaboratorIndex = newValue.findIndex(function (collaboratorEmail) {
84
- return collaboratorEmail === collaborator.email;
85
- });
86
-
87
- if (collaboratorIndex !== -1) {
88
- newValue.splice(collaboratorIndex, 1);
89
- } else {
90
- newValue.push(collaborator.email);
91
- }
92
-
93
- _this.setState({
94
- newValue: newValue
95
- }, function () {
96
- _this.onCommit(newValue);
97
-
98
- _this.onClosePopover();
99
- });
100
- };
101
-
102
- _this.onDeleteCollaborator = function (collaborator) {
103
- var newValue = _this.state.newValue.slice();
104
-
105
- var optionIndex = newValue.findIndex(function (collaboratorEmail) {
106
- return collaboratorEmail === collaborator.email;
107
- });
108
-
109
- if (optionIndex > -1) {
110
- newValue.splice(optionIndex, 1);
111
-
112
- _this.setState({
113
- newValue: newValue
114
- }, function () {
115
- _this.onCommit(newValue);
116
- });
117
- }
118
- };
119
-
120
- _this.caculatePopoverPosition = function () {
121
- var POPOVER_MAX_HEIGHT = 200;
122
- var innerHeight = window.innerHeight;
123
-
124
- var _this$editor$getClien = _this.editor.getClientRects()[0],
125
- top = _this$editor$getClien.top,
126
- height = _this$editor$getClien.height;
127
-
128
- var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
129
- var position = {
130
- top: height + 1,
131
- left: 0
132
- };
133
-
134
- if (!isBelow) {
135
- var bottom = height + 1;
136
- position = {
137
- bottom: bottom,
138
- left: 0
139
- };
140
- }
141
-
142
- return position;
143
- };
144
-
145
- _this.onClosePopover = function () {
146
- _this.setState({
147
- isPopoverShow: false
148
- });
149
- };
150
-
151
- _this.setEditorContainerRef = function (editorContainer) {
152
- _this.editorContainer = editorContainer;
153
- };
154
-
155
- _this.setEditorRef = function (editor) {
156
- _this.editor = editor;
157
- };
158
-
159
- _this.state = {
160
- newValue: Array.isArray(props.value) ? props.value : [],
161
- isPopoverShow: false,
162
- popoverPosition: {}
163
- };
164
- return _this;
165
- }
166
-
167
- _createClass(CollaboratorEditor, [{
168
- key: "componentDidMount",
169
- value: function componentDidMount() {
170
- document.addEventListener('click', this.onDocumentToggle);
171
- }
172
- }, {
173
- key: "componentWillUnmount",
174
- value: function componentWillUnmount() {
175
- document.removeEventListener('click', this.onDocumentToggle);
176
- }
177
- }, {
178
- key: "render",
179
- value: function render() {
180
- var _this2 = this;
181
-
182
- var _this$props = this.props,
183
- collaborators = _this$props.collaborators,
184
- isReadOnly = _this$props.isReadOnly;
185
- var _this$state = this.state,
186
- isPopoverShow = _this$state.isPopoverShow,
187
- popoverPosition = _this$state.popoverPosition;
188
- var selectedCollaborators = this.getFormattedCollaborators();
189
- var enableDeleteCollaborator = !isReadOnly;
190
- return /*#__PURE__*/React.createElement("div", {
191
- ref: this.setEditorContainerRef,
192
- className: "cell-editor dtable-ui-collaborator-editor"
193
- }, /*#__PURE__*/React.createElement("div", {
194
- ref: this.setEditorRef,
195
- className: "dtable-ui-collaborator-editor-container"
196
- }, /*#__PURE__*/React.createElement(EditEditorButton, {
197
- text: getLocale('Add_a_collaborator'),
198
- onClick: this.onAddOptionToggle
199
- }), /*#__PURE__*/React.createElement("div", {
200
- className: "collaborators-container"
201
- }, selectedCollaborators.length > 0 && selectedCollaborators.map(function (collaborator) {
202
- return /*#__PURE__*/React.createElement(CollaboratorItem, {
203
- key: collaborator.email,
204
- collaborator: collaborator,
205
- enableDeleteCollaborator: enableDeleteCollaborator,
206
- onDeleteCollaborator: _this2.onDeleteCollaborator
207
- });
208
- }))), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
209
- query: '(min-width: 768px)'
210
- }, /*#__PURE__*/React.createElement(PCCollaboratorEditorPopover, {
211
- popoverPosition: popoverPosition,
212
- isReadOnly: this.props.isReadOnly,
213
- selectedCollaborators: selectedCollaborators,
214
- collaborators: collaborators,
215
- onCollaboratorItemToggle: this.onCollaboratorItemToggle
216
- })), /*#__PURE__*/React.createElement(MediaQuery, {
217
- query: '(max-width: 767.8px)'
218
- }, /*#__PURE__*/React.createElement(MBCollaboratorEditorPopover, {
219
- isReadOnly: this.props.isReadOnly,
220
- value: this.state.newValue,
221
- column: this.props.column,
222
- collaborators: this.props.collaborators,
223
- onCollaboratorItemToggle: this.onCollaboratorItemToggle,
224
- onClosePopover: this.onClosePopover
225
- }))));
226
- }
227
- }]);
228
-
229
- return CollaboratorEditor;
230
- }(React.Component);
231
-
232
- CollaboratorEditor.defaultProps = {
233
- isReadOnly: false,
234
- value: []
235
- };
236
- export default CollaboratorEditor;