dtable-ui-component 0.3.20 → 0.3.21-beta.1

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 (112) hide show
  1. package/lib/AutoNumberFormatter/index.js +2 -9
  2. package/lib/ButtonFormatter/index.js +4 -17
  3. package/lib/CTimeFormatter/index.js +2 -15
  4. package/lib/CheckboxEditor/index.js +0 -13
  5. package/lib/CheckboxFormatter/index.js +2 -11
  6. package/lib/CollaboratorEditor/index.js +6 -44
  7. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +2 -27
  8. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +2 -20
  9. package/lib/CollaboratorFormatter/index.js +6 -23
  10. package/lib/CollaboratorItem/index.js +2 -14
  11. package/lib/CreatorFormatter/index.js +6 -22
  12. package/lib/DTableCustomizeCollaboratorSelect/index.js +16 -37
  13. package/lib/DTableCustomizeCollaboratorSelect/utils.js +6 -5
  14. package/lib/DTableCustomizeSelect/index.js +14 -37
  15. package/lib/DTablePopover/index.js +8 -26
  16. package/lib/DTableRadio/index.js +0 -2
  17. package/lib/DTableSearchInput/index.js +12 -36
  18. package/lib/DTableSelect/index.js +13 -27
  19. package/lib/DTableSwitch/index.js +4 -6
  20. package/lib/DateEditor/index.js +8 -27
  21. package/lib/DateEditor/mb-date-editor-popover/index.js +8 -42
  22. package/lib/DateEditor/pc-date-editor-popover.js +7 -27
  23. package/lib/DateFormatter/index.js +3 -12
  24. package/lib/DepartmentSingleSelectFormatter/index.css +29 -0
  25. package/lib/DepartmentSingleSelectFormatter/index.js +22 -0
  26. package/lib/DigitalSignFormatter/index.js +8 -26
  27. package/lib/DigitalSignFormatter/utils.js +3 -6
  28. package/lib/DurationFormatter/index.js +3 -10
  29. package/lib/EditEditorButton/index.js +0 -7
  30. package/lib/EmailFormatter/index.js +2 -9
  31. package/lib/FieldDisplaySetting/field-item.js +6 -20
  32. package/lib/FieldDisplaySetting/index.js +8 -13
  33. package/lib/FileEditor/index.js +0 -8
  34. package/lib/FileFormatter/index.js +3 -14
  35. package/lib/FileItemFormatter/index.js +0 -13
  36. package/lib/FileItemFormatter/utils.js +0 -6
  37. package/lib/FileUploader/index.js +0 -16
  38. package/lib/FormulaFormatter/cell-value-validator.js +0 -10
  39. package/lib/FormulaFormatter/index.js +8 -38
  40. package/lib/FormulaFormatter/utils.js +0 -17
  41. package/lib/GeolocationFormatter/index.js +4 -13
  42. package/lib/HtmlLongTextFormatter/index.js +0 -21
  43. package/lib/HtmlLongTextFormatter/markdown2html.js +2 -17
  44. package/lib/HtmlLongTextFormatter/unified/index.js +29 -102
  45. package/lib/HtmlLongTextFormatter/vfile/core.js +13 -32
  46. package/lib/HtmlLongTextFormatter/vfile/index.js +4 -11
  47. package/lib/ImageFormatter/images-lazy-load.js +5 -35
  48. package/lib/ImageFormatter/index.js +7 -34
  49. package/lib/ImageFormatter/utils.js +0 -1
  50. package/lib/ImagePreviewerLightbox/index.js +11 -13
  51. package/lib/LastModifierFormatter/index.js +6 -22
  52. package/lib/LinkEditor/index.js +23 -69
  53. package/lib/LinkEditor/link-editor-option.js +2 -18
  54. package/lib/LinkEditor/mb-link-editor-popover/index.js +2 -27
  55. package/lib/LinkEditor/pc-link-editor-popover/index.js +2 -20
  56. package/lib/LinkFormatter/index.js +12 -35
  57. package/lib/LongTextFormatter/index.js +2 -6
  58. package/lib/MBEditorHeader/index.js +6 -13
  59. package/lib/MTimeFormatter/index.js +2 -15
  60. package/lib/ModalPortal/index.js +0 -8
  61. package/lib/MultipleSelectEditor/index.js +4 -42
  62. package/lib/MultipleSelectFormatter/index.js +4 -17
  63. package/lib/NotificationPopover/index.js +3 -22
  64. package/lib/NumberEditor/index.js +7 -35
  65. package/lib/NumberFormatter/index.js +3 -12
  66. package/lib/RateFormatter/index.js +10 -25
  67. package/lib/RowExpandEmailFormatter/index.js +2 -13
  68. package/lib/RowExpandFileFormatter/index.js +6 -15
  69. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +6 -24
  70. package/lib/RowExpandFormatter/index.js +18 -61
  71. package/lib/RowExpandFormulaFormatter/index.js +10 -41
  72. package/lib/RowExpandImageFormatter/index.js +8 -27
  73. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +6 -25
  74. package/lib/RowExpandImageFormatter/utils.js +0 -1
  75. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +4 -35
  76. package/lib/RowExpandLinkFormatter/index.js +6 -28
  77. package/lib/RowExpandLinkFormatter/utils.js +0 -4
  78. package/lib/RowExpandLinkFormatter/value-display-utils.js +2 -2
  79. package/lib/RowExpandRateFormatter/index.js +8 -23
  80. package/lib/RowExpandUrlFormatter/index.js +2 -14
  81. package/lib/SelectItem/index.js +2 -13
  82. package/lib/SelectOptionGroup/index.js +13 -42
  83. package/lib/SelectOptionGroup/option.js +0 -14
  84. package/lib/SimpleLongTextFormatter/index.js +0 -26
  85. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +2 -12
  86. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +1 -16
  87. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +0 -17
  88. package/lib/SingleSelectEditor/index.js +4 -37
  89. package/lib/SingleSelectFormatter/index.js +5 -17
  90. package/lib/TextEditor/index.js +3 -22
  91. package/lib/TextFormatter/index.js +2 -15
  92. package/lib/UrlFormatter/index.js +2 -9
  93. package/lib/cellFormatterFactory/index.js +0 -5
  94. package/lib/common/delete-tip.js +4 -16
  95. package/lib/common/modal-portal.js +0 -8
  96. package/lib/data/dtable-value.js +41 -1
  97. package/lib/formatterConfig/base-formatter-config.js +0 -2
  98. package/lib/formatterConfig/index.js +0 -4
  99. package/lib/index.js +13 -6
  100. package/lib/lang/index.js +0 -7
  101. package/lib/locals/en.js +2 -1
  102. package/lib/locals/zh-CN.js +2 -1
  103. package/lib/select-editor/mb-select-editor-popover/index.js +6 -38
  104. package/lib/select-editor/pc-select-editor-popover/index.js +3 -25
  105. package/lib/select-editor/select-editor-option.js +2 -17
  106. package/lib/toaster/alert.js +0 -12
  107. package/lib/toaster/toast.js +1 -22
  108. package/lib/toaster/toastManager.js +7 -30
  109. package/lib/toaster/toaster.js +4 -15
  110. package/lib/utils/editor-utils.js +0 -20
  111. package/lib/utils/utils.js +2 -5
  112. package/package.json +6 -6
@@ -5,34 +5,27 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import classnames from 'classnames';
7
7
  import './index.css';
8
-
9
8
  var AutoNumberFormatter = /*#__PURE__*/function (_React$Component) {
10
9
  _inherits(AutoNumberFormatter, _React$Component);
11
-
12
10
  var _super = _createSuper(AutoNumberFormatter);
13
-
14
11
  function AutoNumberFormatter() {
15
12
  _classCallCheck(this, AutoNumberFormatter);
16
-
17
13
  return _super.apply(this, arguments);
18
14
  }
19
-
20
15
  _createClass(AutoNumberFormatter, [{
21
16
  key: "render",
22
17
  value: function render() {
23
18
  var _this$props = this.props,
24
- containerClassName = _this$props.containerClassName,
25
- value = _this$props.value;
19
+ containerClassName = _this$props.containerClassName,
20
+ value = _this$props.value;
26
21
  var classname = classnames('dtable-ui cell-formatter-container auto-number-formatter', containerClassName);
27
22
  return /*#__PURE__*/React.createElement("div", {
28
23
  className: classname
29
24
  }, value);
30
25
  }
31
26
  }]);
32
-
33
27
  return AutoNumberFormatter;
34
28
  }(React.Component);
35
-
36
29
  AutoNumberFormatter.defaultProps = {
37
30
  value: ''
38
31
  };
@@ -7,43 +7,32 @@ import classnames from 'classnames';
7
7
  import { SELECT_OPTION_COLORS } from 'dtable-utils';
8
8
  import './index.css';
9
9
  var WHITE = '#FFFFFF';
10
-
11
10
  var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
12
11
  _inherits(ButtonFormatter, _React$Component);
13
-
14
12
  var _super = _createSuper(ButtonFormatter);
15
-
16
13
  function ButtonFormatter() {
17
14
  var _this;
18
-
19
15
  _classCallCheck(this, ButtonFormatter);
20
-
21
16
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
17
  args[_key] = arguments[_key];
23
18
  }
24
-
25
19
  _this = _super.call.apply(_super, [this].concat(args));
26
-
27
20
  _this.handleClick = function () {
28
21
  if (_this.props.onClickButton) {
29
22
  _this.props.onClickButton(_this.props.data);
30
23
  }
31
24
  };
32
-
33
25
  return _this;
34
26
  }
35
-
36
27
  _createClass(ButtonFormatter, [{
37
28
  key: "render",
38
29
  value: function render() {
39
30
  var _this$props = this.props,
40
- data = _this$props.data,
41
- containerClassName = _this$props.containerClassName;
42
-
31
+ data = _this$props.data,
32
+ containerClassName = _this$props.containerClassName;
43
33
  var _ref = data || {},
44
- button_color = _ref.button_color,
45
- button_name = _ref.button_name;
46
-
34
+ button_color = _ref.button_color,
35
+ button_name = _ref.button_name;
47
36
  var colorObj = SELECT_OPTION_COLORS.find(function (item) {
48
37
  return item.COLOR === button_color;
49
38
  }) || SELECT_OPTION_COLORS[0];
@@ -59,8 +48,6 @@ var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
59
48
  }, button_name));
60
49
  }
61
50
  }]);
62
-
63
51
  return ButtonFormatter;
64
52
  }(React.Component);
65
-
66
53
  export default ButtonFormatter;
@@ -6,51 +6,38 @@ import React from 'react';
6
6
  import classnames from 'classnames';
7
7
  import dayjs from 'dayjs';
8
8
  import './index.css';
9
-
10
9
  var CTimeFormatter = /*#__PURE__*/function (_React$Component) {
11
10
  _inherits(CTimeFormatter, _React$Component);
12
-
13
11
  var _super = _createSuper(CTimeFormatter);
14
-
15
12
  function CTimeFormatter() {
16
13
  var _this;
17
-
18
14
  _classCallCheck(this, CTimeFormatter);
19
-
20
15
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21
16
  args[_key] = arguments[_key];
22
17
  }
23
-
24
18
  _this = _super.call.apply(_super, [this].concat(args));
25
-
26
19
  _this.formatDate = function (date) {
27
20
  return dayjs(date).format('YYYY-MM-DD HH:mm:ss');
28
21
  };
29
-
30
22
  return _this;
31
23
  }
32
-
33
24
  _createClass(CTimeFormatter, [{
34
25
  key: "render",
35
26
  value: function render() {
36
27
  var _this$props = this.props,
37
- date = _this$props.value,
38
- containerClassName = _this$props.containerClassName;
28
+ date = _this$props.value,
29
+ containerClassName = _this$props.containerClassName;
39
30
  var classname = classnames('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
40
-
41
31
  if (date !== '') {
42
32
  date = this.formatDate(date);
43
33
  }
44
-
45
34
  return /*#__PURE__*/React.createElement("div", {
46
35
  className: classname
47
36
  }, date);
48
37
  }
49
38
  }]);
50
-
51
39
  return CTimeFormatter;
52
40
  }(React.Component);
53
-
54
41
  CTimeFormatter.defaultProps = {
55
42
  value: '',
56
43
  containerClassName: ''
@@ -4,45 +4,34 @@ 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 './index.css';
7
-
8
7
  var CheckboxEditor = /*#__PURE__*/function (_React$Component) {
9
8
  _inherits(CheckboxEditor, _React$Component);
10
-
11
9
  var _super = _createSuper(CheckboxEditor);
12
-
13
10
  function CheckboxEditor(props) {
14
11
  var _this;
15
-
16
12
  _classCallCheck(this, CheckboxEditor);
17
-
18
13
  _this = _super.call(this, props);
19
-
20
14
  _this.onCommit = function () {
21
15
  var updated = {};
22
16
  var column = _this.props.column;
23
17
  updated[column.name] = _this.state.value;
24
-
25
18
  _this.props.onCommit(updated);
26
19
  };
27
-
28
20
  _this.onChange = function (event) {
29
21
  if (_this.props.isReadOnly) {
30
22
  return;
31
23
  }
32
-
33
24
  _this.setState({
34
25
  value: !_this.state.value
35
26
  }, function () {
36
27
  _this.onCommit();
37
28
  });
38
29
  };
39
-
40
30
  _this.state = {
41
31
  value: props.value ? props.value : false
42
32
  };
43
33
  return _this;
44
34
  }
45
-
46
35
  _createClass(CheckboxEditor, [{
47
36
  key: "render",
48
37
  value: function render() {
@@ -66,10 +55,8 @@ var CheckboxEditor = /*#__PURE__*/function (_React$Component) {
66
55
  })));
67
56
  }
68
57
  }]);
69
-
70
58
  return CheckboxEditor;
71
59
  }(React.Component);
72
-
73
60
  CheckboxEditor.defaultProps = {
74
61
  isReadOnly: false,
75
62
  value: false
@@ -5,27 +5,21 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import classnames from 'classnames';
7
7
  import './index.css';
8
-
9
8
  var CheckboxFormatter = /*#__PURE__*/function (_React$PureComponent) {
10
9
  _inherits(CheckboxFormatter, _React$PureComponent);
11
-
12
10
  var _super = _createSuper(CheckboxFormatter);
13
-
14
11
  function CheckboxFormatter() {
15
12
  _classCallCheck(this, CheckboxFormatter);
16
-
17
13
  return _super.apply(this, arguments);
18
14
  }
19
-
20
15
  _createClass(CheckboxFormatter, [{
21
16
  key: "render",
22
17
  value: function render() {
23
18
  var _this$props = this.props,
24
- value = _this$props.value,
25
- containerClassName = _this$props.containerClassName;
19
+ value = _this$props.value,
20
+ containerClassName = _this$props.containerClassName;
26
21
  value = value === true ? true : false;
27
22
  var classname = classnames('dtable-ui cell-formatter-container checkbox-formatter d-flex align-items-center justify-content-center', containerClassName);
28
-
29
23
  if (value) {
30
24
  return /*#__PURE__*/React.createElement("div", {
31
25
  className: classname
@@ -33,14 +27,11 @@ var CheckboxFormatter = /*#__PURE__*/function (_React$PureComponent) {
33
27
  className: "dtable-font dtable-icon-check-mark checkbox-checked-mark"
34
28
  }));
35
29
  }
36
-
37
30
  return null;
38
31
  }
39
32
  }]);
40
-
41
33
  return CheckboxFormatter;
42
34
  }(React.PureComponent);
43
-
44
35
  CheckboxFormatter.defaultProps = {
45
36
  value: false
46
37
  };
@@ -10,28 +10,20 @@ import EditEditorButton from '../EditEditorButton';
10
10
  import PCCollaboratorEditorPopover from './pc-collaborator-editor-popover';
11
11
  import MBCollaboratorEditorPopover from './mb-collaborator-editor-popover';
12
12
  import './index.css';
13
-
14
13
  var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
15
14
  _inherits(CollaboratorEditor, _React$Component);
16
-
17
15
  var _super = _createSuper(CollaboratorEditor);
18
-
19
16
  function CollaboratorEditor(props) {
20
17
  var _this;
21
-
22
18
  _classCallCheck(this, CollaboratorEditor);
23
-
24
19
  _this = _super.call(this, props);
25
-
26
20
  _this.onDocumentToggle = function (e) {
27
21
  if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
28
22
  _this.onClosePopover();
29
23
  }
30
24
  };
31
-
32
25
  _this.getFormattedCollaborators = function () {
33
26
  var newValue = _this.state.newValue;
34
-
35
27
  if (Array.isArray(newValue) && newValue.length > 0) {
36
28
  var collaborators = _this.props.collaborators;
37
29
  return newValue.map(function (collaboratorEmail) {
@@ -42,23 +34,17 @@ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
42
34
  return !!collaborator;
43
35
  });
44
36
  }
45
-
46
37
  return [];
47
38
  };
48
-
49
39
  _this.onAddOptionToggle = function (event) {
50
40
  event.nativeEvent.stopImmediatePropagation();
51
41
  event.stopPropagation();
52
-
53
42
  if (_this.props.isReadOnly) {
54
43
  return;
55
44
  }
56
-
57
45
  var isPopoverShow = !_this.state.isPopoverShow;
58
-
59
46
  if (isPopoverShow) {
60
47
  var popoverPosition = _this.caculatePopoverPosition();
61
-
62
48
  _this.setState({
63
49
  isPopoverShow: isPopoverShow,
64
50
  popoverPosition: popoverPosition
@@ -69,47 +55,36 @@ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
69
55
  });
70
56
  }
71
57
  };
72
-
73
58
  _this.onCommit = function (newValue) {
74
59
  var updated = {};
75
60
  var column = _this.props.column;
76
61
  updated[column.name] = newValue;
77
-
78
62
  _this.props.onCommit(updated);
79
63
  };
80
-
81
64
  _this.onCollaboratorItemToggle = function (collaborator) {
82
65
  var newValue = _this.state.newValue.slice();
83
-
84
66
  var collaboratorIndex = newValue.findIndex(function (collaboratorEmail) {
85
67
  return collaboratorEmail === collaborator.email;
86
68
  });
87
-
88
69
  if (collaboratorIndex !== -1) {
89
70
  newValue.splice(collaboratorIndex, 1);
90
71
  } else {
91
72
  newValue.push(collaborator.email);
92
73
  }
93
-
94
74
  _this.setState({
95
75
  newValue: newValue
96
76
  }, function () {
97
77
  _this.onCommit(newValue);
98
-
99
78
  _this.onClosePopover();
100
79
  });
101
80
  };
102
-
103
81
  _this.onDeleteCollaborator = function (collaborator) {
104
82
  var newValue = _this.state.newValue.slice();
105
-
106
83
  var optionIndex = newValue.findIndex(function (collaboratorEmail) {
107
84
  return collaboratorEmail === collaborator.email;
108
85
  });
109
-
110
86
  if (optionIndex > -1) {
111
87
  newValue.splice(optionIndex, 1);
112
-
113
88
  _this.setState({
114
89
  newValue: newValue
115
90
  }, function () {
@@ -117,21 +92,17 @@ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
117
92
  });
118
93
  }
119
94
  };
120
-
121
95
  _this.caculatePopoverPosition = function () {
122
96
  var POPOVER_MAX_HEIGHT = 200;
123
97
  var innerHeight = window.innerHeight;
124
-
125
98
  var _this$editor$getClien = _this.editor.getClientRects()[0],
126
- top = _this$editor$getClien.top,
127
- height = _this$editor$getClien.height;
128
-
99
+ top = _this$editor$getClien.top,
100
+ height = _this$editor$getClien.height;
129
101
  var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
130
102
  var position = {
131
103
  top: height + 1,
132
104
  left: 0
133
105
  };
134
-
135
106
  if (!isBelow) {
136
107
  var bottom = height + 1;
137
108
  position = {
@@ -139,24 +110,19 @@ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
139
110
  left: 0
140
111
  };
141
112
  }
142
-
143
113
  return position;
144
114
  };
145
-
146
115
  _this.onClosePopover = function () {
147
116
  _this.setState({
148
117
  isPopoverShow: false
149
118
  });
150
119
  };
151
-
152
120
  _this.setEditorContainerRef = function (editorContainer) {
153
121
  _this.editorContainer = editorContainer;
154
122
  };
155
-
156
123
  _this.setEditorRef = function (editor) {
157
124
  _this.editor = editor;
158
125
  };
159
-
160
126
  _this.state = {
161
127
  newValue: Array.isArray(props.value) ? props.value : [],
162
128
  isPopoverShow: false,
@@ -164,7 +130,6 @@ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
164
130
  };
165
131
  return _this;
166
132
  }
167
-
168
133
  _createClass(CollaboratorEditor, [{
169
134
  key: "componentDidMount",
170
135
  value: function componentDidMount() {
@@ -179,13 +144,12 @@ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
179
144
  key: "render",
180
145
  value: function render() {
181
146
  var _this2 = this;
182
-
183
147
  var _this$props = this.props,
184
- collaborators = _this$props.collaborators,
185
- isReadOnly = _this$props.isReadOnly;
148
+ collaborators = _this$props.collaborators,
149
+ isReadOnly = _this$props.isReadOnly;
186
150
  var _this$state = this.state,
187
- isPopoverShow = _this$state.isPopoverShow,
188
- popoverPosition = _this$state.popoverPosition;
151
+ isPopoverShow = _this$state.isPopoverShow,
152
+ popoverPosition = _this$state.popoverPosition;
189
153
  var selectedCollaborators = this.getFormattedCollaborators();
190
154
  var enableDeleteCollaborator = !isReadOnly;
191
155
  return /*#__PURE__*/React.createElement("div", {
@@ -226,10 +190,8 @@ var CollaboratorEditor = /*#__PURE__*/function (_React$Component) {
226
190
  }))));
227
191
  }
228
192
  }]);
229
-
230
193
  return CollaboratorEditor;
231
194
  }(React.Component);
232
-
233
195
  CollaboratorEditor.defaultProps = {
234
196
  isReadOnly: false,
235
197
  value: []
@@ -7,25 +7,17 @@ import React from 'react';
7
7
  import { getLocale } from '../../lang';
8
8
  import MBEditorHeader from '../../MBEditorHeader';
9
9
  import './index.css';
10
-
11
10
  var MBCollaboratorEditorPopover = /*#__PURE__*/function (_React$Component) {
12
11
  _inherits(MBCollaboratorEditorPopover, _React$Component);
13
-
14
12
  var _super = _createSuper(MBCollaboratorEditorPopover);
15
-
16
13
  function MBCollaboratorEditorPopover(props) {
17
14
  var _this;
18
-
19
15
  _classCallCheck(this, MBCollaboratorEditorPopover);
20
-
21
16
  _this = _super.call(this, props);
22
-
23
17
  _this.handleHistaryBack = function (e) {
24
18
  e.preventDefault();
25
-
26
19
  _this.props.onClosePopover();
27
20
  };
28
-
29
21
  _this.onContainerClick = function (event) {
30
22
  if (_this.editorPopover && _this.editorPopover.contains(event.target)) {
31
23
  event.stopPropagation();
@@ -33,35 +25,27 @@ var MBCollaboratorEditorPopover = /*#__PURE__*/function (_React$Component) {
33
25
  return false;
34
26
  }
35
27
  };
36
-
37
28
  _this.onChangeSearch = function (event) {
38
29
  var searchVal = _this.state.searchVal;
39
-
40
30
  if (searchVal === event.target.value) {
41
31
  return;
42
32
  }
43
-
44
33
  searchVal = event.target.value;
45
-
46
34
  _this.setState({
47
35
  searchVal: searchVal
48
36
  });
49
37
  };
50
-
51
38
  _this.getSelectedCollaborators = function () {
52
39
  var _this$props = _this.props,
53
- value = _this$props.value,
54
- collaborators = _this$props.collaborators;
55
-
40
+ value = _this$props.value,
41
+ collaborators = _this$props.collaborators;
56
42
  if (!Array.isArray(value)) {
57
43
  return [];
58
44
  }
59
-
60
45
  return collaborators.filter(function (collaborator) {
61
46
  return value.indexOf(collaborator.email) > -1;
62
47
  });
63
48
  };
64
-
65
49
  _this.getFilteredCollaborators = function () {
66
50
  var collaborators = _this.props.collaborators;
67
51
  var searchVal = _this.state.searchVal;
@@ -69,15 +53,12 @@ var MBCollaboratorEditorPopover = /*#__PURE__*/function (_React$Component) {
69
53
  return item.name.indexOf(searchVal) > -1;
70
54
  }) : collaborators;
71
55
  };
72
-
73
56
  _this.onSelectCollaborator = function (collaborator) {
74
57
  _this.props.onCollaboratorItemToggle(collaborator);
75
58
  };
76
-
77
59
  _this.onRemoveCollaborator = function (collaborator) {
78
60
  _this.props.onCollaboratorItemToggle(collaborator);
79
61
  };
80
-
81
62
  _this.renderFilteredCollaborators = function (collaborators) {
82
63
  var value = _this.props.value;
83
64
  return collaborators.map(function (collaborator, index) {
@@ -104,22 +85,18 @@ var MBCollaboratorEditorPopover = /*#__PURE__*/function (_React$Component) {
104
85
  }));
105
86
  });
106
87
  };
107
-
108
88
  _this.setEditorPopover = function (editorPopover) {
109
89
  _this.editorPopover = editorPopover;
110
90
  };
111
-
112
91
  _this.state = {
113
92
  searchVal: ''
114
93
  };
115
94
  return _this;
116
95
  }
117
-
118
96
  _createClass(MBCollaboratorEditorPopover, [{
119
97
  key: "componentDidMount",
120
98
  value: function componentDidMount() {
121
99
  history.pushState(null, null, '#'); // eslint-disable-line
122
-
123
100
  window.addEventListener('popstate', this.handleHistaryBack, false);
124
101
  }
125
102
  }, {
@@ -167,10 +144,8 @@ var MBCollaboratorEditorPopover = /*#__PURE__*/function (_React$Component) {
167
144
  }, getLocale('No_collaborators_avaliable')), filteredCollaborators.length > 0 && this.renderFilteredCollaborators(filteredCollaborators)))));
168
145
  }
169
146
  }]);
170
-
171
147
  return MBCollaboratorEditorPopover;
172
148
  }(React.Component);
173
-
174
149
  MBCollaboratorEditorPopover.defaultProps = {
175
150
  isReadOnly: false,
176
151
  value: []
@@ -7,65 +7,49 @@ import React from 'react';
7
7
  import { getLocale } from '../../lang';
8
8
  import CollaboratorItem from '../../CollaboratorItem';
9
9
  import './index.css';
10
-
11
10
  var PCCollaboratorEditorPopover = /*#__PURE__*/function (_React$Component) {
12
11
  _inherits(PCCollaboratorEditorPopover, _React$Component);
13
-
14
12
  var _super = _createSuper(PCCollaboratorEditorPopover);
15
-
16
13
  function PCCollaboratorEditorPopover(props) {
17
14
  var _this;
18
-
19
15
  _classCallCheck(this, PCCollaboratorEditorPopover);
20
-
21
16
  _this = _super.call(this, props);
22
-
23
17
  _this.onValueChanged = function (event) {
24
18
  var value = event.target.value;
25
-
26
19
  _this.setState({
27
20
  searchValue: value
28
21
  });
29
22
  };
30
-
31
23
  _this.onInputClick = function (event) {
32
24
  event.nativeEvent.stopImmediatePropagation();
33
25
  event.stopPropagation();
34
26
  };
35
-
36
27
  _this.onCollaboratorItemToggle = function (item) {
37
28
  _this.props.onCollaboratorItemToggle(item);
38
29
  };
39
-
40
30
  _this.getFilterCollaborator = function () {
41
31
  var collaborators = _this.props.collaborators;
42
-
43
32
  var filter = _this.state.searchValue.toLowerCase();
44
-
45
33
  if (!filter) {
46
34
  return collaborators;
47
35
  }
48
-
49
36
  return collaborators.filter(function (collaborator) {
50
37
  return collaborator.name.toString().toLowerCase().indexOf(filter) > -1;
51
38
  });
52
39
  };
53
-
54
40
  _this.state = {
55
41
  searchValue: ''
56
42
  };
57
43
  return _this;
58
44
  }
59
-
60
45
  _createClass(PCCollaboratorEditorPopover, [{
61
46
  key: "render",
62
47
  value: function render() {
63
48
  var _this2 = this;
64
-
65
49
  var searchValue = this.state.searchValue;
66
50
  var _this$props = this.props,
67
- selectedCollaborators = _this$props.selectedCollaborators,
68
- popoverPosition = _this$props.popoverPosition;
51
+ selectedCollaborators = _this$props.selectedCollaborators,
52
+ popoverPosition = _this$props.popoverPosition;
69
53
  var collaborators = this.getFilterCollaborator();
70
54
  var popoverStyle = Object.assign({}, _objectSpread({}, popoverPosition), {
71
55
  position: 'absolute'
@@ -103,8 +87,6 @@ var PCCollaboratorEditorPopover = /*#__PURE__*/function (_React$Component) {
103
87
  }, getLocale('No_collaborators_available'))));
104
88
  }
105
89
  }]);
106
-
107
90
  return PCCollaboratorEditorPopover;
108
91
  }(React.Component);
109
-
110
92
  export default PCCollaboratorEditorPopover;