dtable-ui-component 4.3.6 → 4.3.8

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 (122) hide show
  1. package/lib/AutoNumberFormatter/index.js +11 -24
  2. package/lib/ButtonFormatter/index.js +29 -45
  3. package/lib/CTimeFormatter/index.js +17 -32
  4. package/lib/CheckboxEditor/index.js +42 -49
  5. package/lib/CheckboxFormatter/index.js +17 -30
  6. package/lib/CollaboratorEditor/index.js +118 -135
  7. package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
  8. package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
  9. package/lib/CollaboratorFormatter/index.js +26 -42
  10. package/lib/CollaboratorItem/index.js +31 -44
  11. package/lib/CreatorFormatter/index.js +24 -40
  12. package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
  13. package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
  14. package/lib/DTableCustomizeSelect/index.css +22 -59
  15. package/lib/DTableCustomizeSelect/index.js +99 -95
  16. package/lib/DTablePopover/index.js +52 -71
  17. package/lib/DTablePopover/utils.js +1 -1
  18. package/lib/DTableRadio/index.js +9 -7
  19. package/lib/DTableSearchInput/index.js +89 -99
  20. package/lib/DTableSearchInput/utils.js +2 -2
  21. package/lib/DTableSelect/dtable-select-label.js +5 -3
  22. package/lib/DTableSelect/index.js +50 -64
  23. package/lib/DTableSelect/utils.js +36 -41
  24. package/lib/DTableSwitch/index.js +7 -5
  25. package/lib/DateEditor/index.js +88 -94
  26. package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
  27. package/lib/DateEditor/pc-date-editor-popover.js +70 -77
  28. package/lib/DateFormatter/index.js +15 -28
  29. package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
  30. package/lib/DigitalSignFormatter/index.js +55 -65
  31. package/lib/DigitalSignFormatter/utils.js +9 -8
  32. package/lib/DurationFormatter/index.js +14 -27
  33. package/lib/EditEditorButton/index.js +10 -22
  34. package/lib/EmailFormatter/index.js +11 -24
  35. package/lib/FieldDisplaySetting/field-item.js +18 -20
  36. package/lib/FieldDisplaySetting/index.js +41 -43
  37. package/lib/FileEditor/index.js +18 -29
  38. package/lib/FileFormatter/index.js +29 -43
  39. package/lib/FileItemFormatter/index.js +17 -32
  40. package/lib/FileItemFormatter/utils.js +5 -5
  41. package/lib/FileUploader/index.js +20 -33
  42. package/lib/FormulaFormatter/cell-value-validator.js +23 -8
  43. package/lib/FormulaFormatter/index.js +77 -83
  44. package/lib/FormulaFormatter/utils.js +27 -21
  45. package/lib/GeolocationFormatter/index.js +19 -32
  46. package/lib/HtmlLongTextFormatter/index.js +43 -52
  47. package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
  48. package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
  49. package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
  50. package/lib/ImageFormatter/images-lazy-load.js +71 -79
  51. package/lib/ImageFormatter/index.js +86 -97
  52. package/lib/ImageFormatter/utils.js +1 -1
  53. package/lib/ImagePreviewerLightbox/index.js +20 -18
  54. package/lib/ImagePreviewerLightbox/utils.js +3 -3
  55. package/lib/LastModifierFormatter/index.js +24 -40
  56. package/lib/LinkEditor/index.js +163 -167
  57. package/lib/LinkEditor/link-editor-option.js +41 -56
  58. package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
  59. package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
  60. package/lib/LinkFormatter/index.js +75 -77
  61. package/lib/LongTextFormatter/index.js +5 -3
  62. package/lib/MBEditorHeader/index.js +25 -38
  63. package/lib/MTimeFormatter/index.js +17 -32
  64. package/lib/ModalPortal/index.js +15 -32
  65. package/lib/MultipleSelectEditor/index.js +118 -136
  66. package/lib/MultipleSelectFormatter/index.js +24 -40
  67. package/lib/NotificationPopover/index.js +68 -95
  68. package/lib/NumberEditor/index.js +75 -82
  69. package/lib/NumberFormatter/index.js +15 -28
  70. package/lib/RateFormatter/index.js +29 -45
  71. package/lib/RoleStatusEditor/index.js +20 -22
  72. package/lib/RowExpandEmailFormatter/index.js +24 -37
  73. package/lib/RowExpandFileFormatter/index.js +28 -42
  74. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
  75. package/lib/RowExpandFormatter/index.js +92 -96
  76. package/lib/RowExpandFormulaFormatter/index.js +85 -91
  77. package/lib/RowExpandImageFormatter/index.js +65 -82
  78. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
  79. package/lib/RowExpandImageFormatter/utils.js +1 -1
  80. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
  81. package/lib/RowExpandLinkFormatter/index.js +131 -137
  82. package/lib/RowExpandLinkFormatter/utils.js +23 -17
  83. package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
  84. package/lib/RowExpandRateFormatter/index.js +27 -42
  85. package/lib/RowExpandUrlFormatter/index.js +27 -40
  86. package/lib/SelectItem/index.js +17 -33
  87. package/lib/SelectOptionGroup/index.css +103 -0
  88. package/lib/SelectOptionGroup/index.js +157 -135
  89. package/lib/SelectOptionGroup/option.js +31 -38
  90. package/lib/SimpleLongTextFormatter/index.js +55 -67
  91. package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
  92. package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
  93. package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
  94. package/lib/SingleSelectEditor/index.js +108 -119
  95. package/lib/SingleSelectFormatter/index.js +21 -37
  96. package/lib/TextEditor/index.js +45 -51
  97. package/lib/TextFormatter/index.js +17 -32
  98. package/lib/UrlFormatter/index.js +11 -24
  99. package/lib/cellFormatterFactory/index.js +8 -17
  100. package/lib/common/ClickOutside.js +28 -0
  101. package/lib/common/delete-tip.js +40 -65
  102. package/lib/common/modal-portal.js +15 -33
  103. package/lib/constants/index.js +5 -5
  104. package/lib/data/dtable-value.js +4 -4
  105. package/lib/formatterConfig/base-formatter-config.js +24 -3
  106. package/lib/formatterConfig/index.js +5 -4
  107. package/lib/lang/index.js +6 -6
  108. package/lib/locals/de.js +1 -1
  109. package/lib/locals/en.js +1 -1
  110. package/lib/locals/fr.js +1 -1
  111. package/lib/locals/zh-CN.js +1 -1
  112. package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
  113. package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
  114. package/lib/select-editor/select-editor-option.js +41 -56
  115. package/lib/toaster/alert.js +73 -88
  116. package/lib/toaster/index.js +1 -1
  117. package/lib/toaster/toast.js +75 -102
  118. package/lib/toaster/toastManager.js +55 -91
  119. package/lib/toaster/toaster.js +58 -57
  120. package/lib/utils/editor-utils.js +17 -19
  121. package/lib/utils/utils.js +14 -14
  122. package/package.json +4 -4
@@ -1,41 +1,28 @@
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
1
  import React from 'react';
6
- var MBEditorHeader = /*#__PURE__*/function (_React$Component) {
7
- _inherits(MBEditorHeader, _React$Component);
8
- var _super = _createSuper(MBEditorHeader);
9
- function MBEditorHeader() {
10
- _classCallCheck(this, MBEditorHeader);
11
- return _super.apply(this, arguments);
2
+ class MBEditorHeader extends React.Component {
3
+ render() {
4
+ let {
5
+ title,
6
+ titleClass,
7
+ leftContent,
8
+ rightContent,
9
+ onLeftClick,
10
+ onRightClick
11
+ } = this.props;
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ className: "dtable-ui-mb-editor-header ".concat(titleClass ? titleClass : '')
14
+ }, /*#__PURE__*/React.createElement("span", {
15
+ className: "editor-header-left-content",
16
+ onClick: onLeftClick
17
+ }, leftContent), /*#__PURE__*/React.createElement("span", {
18
+ className: "editor-header-title"
19
+ }, title), /*#__PURE__*/React.createElement("span", {
20
+ className: "editor-header-right-content",
21
+ onClick: onRightClick,
22
+ style: {
23
+ color: '#f09f3f'
24
+ }
25
+ }, rightContent));
12
26
  }
13
- _createClass(MBEditorHeader, [{
14
- key: "render",
15
- value: function render() {
16
- var _this$props = this.props,
17
- title = _this$props.title,
18
- titleClass = _this$props.titleClass,
19
- leftContent = _this$props.leftContent,
20
- rightContent = _this$props.rightContent,
21
- onLeftClick = _this$props.onLeftClick,
22
- onRightClick = _this$props.onRightClick;
23
- return /*#__PURE__*/React.createElement("div", {
24
- className: "dtable-ui-mb-editor-header ".concat(titleClass ? titleClass : '')
25
- }, /*#__PURE__*/React.createElement("span", {
26
- className: "editor-header-left-content",
27
- onClick: onLeftClick
28
- }, leftContent), /*#__PURE__*/React.createElement("span", {
29
- className: "editor-header-title"
30
- }, title), /*#__PURE__*/React.createElement("span", {
31
- className: "editor-header-right-content",
32
- onClick: onRightClick,
33
- style: {
34
- color: '#f09f3f'
35
- }
36
- }, rightContent));
37
- }
38
- }]);
39
- return MBEditorHeader;
40
- }(React.Component);
27
+ }
41
28
  export default MBEditorHeader;
@@ -1,43 +1,28 @@
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
1
  import React from 'react';
6
2
  import classnames from 'classnames';
7
3
  import dayjs from 'dayjs';
8
4
  import './index.css';
9
- var MTimeFormatter = /*#__PURE__*/function (_React$Component) {
10
- _inherits(MTimeFormatter, _React$Component);
11
- var _super = _createSuper(MTimeFormatter);
12
- function MTimeFormatter() {
13
- var _this;
14
- _classCallCheck(this, MTimeFormatter);
15
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
16
- args[_key] = arguments[_key];
17
- }
18
- _this = _super.call.apply(_super, [this].concat(args));
19
- _this.formatDate = function (date) {
5
+ class MTimeFormatter extends React.Component {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.formatDate = date => {
20
9
  return dayjs(date).format('YYYY-MM-DD HH:mm:ss');
21
10
  };
22
- return _this;
23
11
  }
24
- _createClass(MTimeFormatter, [{
25
- key: "render",
26
- value: function render() {
27
- var _this$props = this.props,
28
- date = _this$props.value,
29
- containerClassName = _this$props.containerClassName;
30
- var classname = classnames('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
31
- if (date !== '') {
32
- date = this.formatDate(date);
33
- }
34
- return /*#__PURE__*/React.createElement("div", {
35
- className: classname
36
- }, date);
12
+ render() {
13
+ let {
14
+ value: date,
15
+ containerClassName
16
+ } = this.props;
17
+ let classname = classnames('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
18
+ if (date !== '') {
19
+ date = this.formatDate(date);
37
20
  }
38
- }]);
39
- return MTimeFormatter;
40
- }(React.Component);
21
+ return /*#__PURE__*/React.createElement("div", {
22
+ className: classname
23
+ }, date);
24
+ }
25
+ }
41
26
  MTimeFormatter.defaultProps = {
42
27
  value: '',
43
28
  containerClassName: ''
@@ -1,36 +1,19 @@
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
1
  import React from 'react';
6
2
  import ReactDOM from 'react-dom';
7
- var modalRoot = document.getElementById('modal-wrapper');
8
- var ModalPortal = /*#__PURE__*/function (_React$Component) {
9
- _inherits(ModalPortal, _React$Component);
10
- var _super = _createSuper(ModalPortal);
11
- function ModalPortal(props) {
12
- var _this;
13
- _classCallCheck(this, ModalPortal);
14
- _this = _super.call(this, props);
15
- _this.el = document.createElement('div');
16
- return _this;
3
+ const modalRoot = document.getElementById('modal-wrapper');
4
+ class ModalPortal extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.el = document.createElement('div');
17
8
  }
18
- _createClass(ModalPortal, [{
19
- key: "componentDidMount",
20
- value: function componentDidMount() {
21
- modalRoot.appendChild(this.el);
22
- }
23
- }, {
24
- key: "componentWillUnmount",
25
- value: function componentWillUnmount() {
26
- modalRoot.removeChild(this.el);
27
- }
28
- }, {
29
- key: "render",
30
- value: function render() {
31
- return ReactDOM.createPortal(this.props.children, this.el);
32
- }
33
- }]);
34
- return ModalPortal;
35
- }(React.Component);
9
+ componentDidMount() {
10
+ modalRoot.appendChild(this.el);
11
+ }
12
+ componentWillUnmount() {
13
+ modalRoot.removeChild(this.el);
14
+ }
15
+ render() {
16
+ return ReactDOM.createPortal(this.props.children, this.el);
17
+ }
18
+ }
36
19
  export default ModalPortal;
@@ -1,108 +1,97 @@
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
1
  import React, { Fragment } from 'react';
6
2
  import MediaQuery from 'react-responsive';
7
3
  import { getLocale } from '../lang';
8
4
  import EditEditorButton from '../EditEditorButton';
9
5
  import { SelectEditorOption, PCSelectEditorPopover, MBSelectEditorPopover } from '../select-editor';
10
6
  import './index.css';
11
- var MultipleSelectEditor = /*#__PURE__*/function (_React$Component) {
12
- _inherits(MultipleSelectEditor, _React$Component);
13
- var _super = _createSuper(MultipleSelectEditor);
14
- function MultipleSelectEditor(props) {
15
- var _this;
16
- _classCallCheck(this, MultipleSelectEditor);
17
- _this = _super.call(this, props);
18
- _this.onDocumentToggle = function (e) {
19
- if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
20
- _this.onClosePopover();
7
+ class MultipleSelectEditor extends React.Component {
8
+ constructor(props) {
9
+ super(props);
10
+ this.onDocumentToggle = e => {
11
+ if (this.editorContainer !== e.target && !this.editorContainer.contains(e.target)) {
12
+ this.onClosePopover();
21
13
  }
22
14
  };
23
- _this.getFormattedOptions = function () {
24
- var newValue = _this.state.newValue;
15
+ this.getFormattedOptions = () => {
16
+ let {
17
+ newValue
18
+ } = this.state;
25
19
  if (Array.isArray(newValue) && newValue.length > 0) {
26
- return newValue.map(function (option_id) {
27
- return _this.options.find(function (option) {
28
- return option.id === option_id;
29
- });
30
- }).filter(function (option) {
31
- return !!option;
32
- });
20
+ return newValue.map(option_id => {
21
+ return this.options.find(option => option.id === option_id);
22
+ }).filter(option => !!option);
33
23
  }
34
24
  return [];
35
25
  };
36
- _this.onAddOptionToggle = function (event) {
26
+ this.onAddOptionToggle = event => {
37
27
  event.nativeEvent.stopImmediatePropagation();
38
28
  event.stopPropagation();
39
- if (_this.props.isReadOnly) {
29
+ if (this.props.isReadOnly) {
40
30
  return;
41
31
  }
42
- var isPopoverShow = !_this.state.isPopoverShow;
32
+ let isPopoverShow = !this.state.isPopoverShow;
43
33
  if (isPopoverShow) {
44
- var popoverPosition = _this.caculatePopoverPosition();
45
- _this.setState({
46
- isPopoverShow: isPopoverShow,
47
- popoverPosition: popoverPosition
34
+ let popoverPosition = this.caculatePopoverPosition();
35
+ this.setState({
36
+ isPopoverShow,
37
+ popoverPosition
48
38
  });
49
39
  } else {
50
- _this.setState({
51
- isPopoverShow: isPopoverShow
40
+ this.setState({
41
+ isPopoverShow
52
42
  });
53
43
  }
54
44
  };
55
- _this.onCommit = function (newValue) {
56
- var updated = {};
57
- var column = _this.props.column;
45
+ this.onCommit = newValue => {
46
+ let updated = {};
47
+ let {
48
+ column
49
+ } = this.props;
58
50
  updated[column.key] = newValue;
59
- _this.props.onCommit(updated);
51
+ this.props.onCommit(updated);
60
52
  };
61
- _this.onOptionItemToggle = function (option) {
62
- var newValue = _this.state.newValue.slice();
63
- var optionIndex = newValue.findIndex(function (option_id) {
64
- return option_id === option.id;
65
- });
53
+ this.onOptionItemToggle = option => {
54
+ let newValue = this.state.newValue.slice();
55
+ let optionIndex = newValue.findIndex(option_id => option_id === option.id);
66
56
  if (optionIndex !== -1) {
67
57
  newValue.splice(optionIndex, 1);
68
58
  } else {
69
59
  newValue.push(option.id);
70
60
  }
71
- _this.setState({
72
- newValue: newValue
73
- }, function () {
74
- _this.onCommit(newValue);
61
+ this.setState({
62
+ newValue
63
+ }, () => {
64
+ this.onCommit(newValue);
75
65
  });
76
66
  };
77
- _this.onDeleteOption = function (option) {
78
- var newValue = _this.state.newValue.slice();
79
- var optionIndex = newValue.findIndex(function (option_id) {
80
- return option_id === option.id;
81
- });
67
+ this.onDeleteOption = option => {
68
+ let newValue = this.state.newValue.slice();
69
+ let optionIndex = newValue.findIndex(option_id => option_id === option.id);
82
70
  newValue.splice(optionIndex, 1);
83
- _this.setState({
84
- newValue: newValue
85
- }, function () {
86
- _this.onCommit(newValue);
71
+ this.setState({
72
+ newValue
73
+ }, () => {
74
+ this.onCommit(newValue);
87
75
  });
88
76
  };
89
- _this.onAddNewOption = function (optionName) {
90
- _this.props.onAddNewOption(optionName);
91
- _this.onClosePopover();
77
+ this.onAddNewOption = optionName => {
78
+ this.props.onAddNewOption(optionName);
79
+ this.onClosePopover();
92
80
  };
93
- _this.caculatePopoverPosition = function () {
94
- var POPOVER_MAX_HEIGHT = 200;
95
- var innerHeight = window.innerHeight;
96
- var _this$editor$getClien = _this.editor.getClientRects()[0],
97
- top = _this$editor$getClien.top,
98
- height = _this$editor$getClien.height;
99
- var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
100
- var position = {
81
+ this.caculatePopoverPosition = () => {
82
+ const POPOVER_MAX_HEIGHT = 200;
83
+ let innerHeight = window.innerHeight;
84
+ let {
85
+ top,
86
+ height
87
+ } = this.editor.getClientRects()[0];
88
+ let isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
89
+ let position = {
101
90
  top: height + 1,
102
91
  left: 0
103
92
  };
104
93
  if (!isBelow) {
105
- var bottom = height + 1;
94
+ let bottom = height + 1;
106
95
  position = {
107
96
  bottom: bottom,
108
97
  left: 0
@@ -110,87 +99,80 @@ var MultipleSelectEditor = /*#__PURE__*/function (_React$Component) {
110
99
  }
111
100
  return position;
112
101
  };
113
- _this.onClosePopover = function () {
114
- _this.setState({
102
+ this.onClosePopover = () => {
103
+ this.setState({
115
104
  isPopoverShow: false
116
105
  });
117
106
  };
118
- _this.setEditorContainerRef = function (editorContainer) {
119
- _this.editorContainer = editorContainer;
107
+ this.setEditorContainerRef = editorContainer => {
108
+ this.editorContainer = editorContainer;
120
109
  };
121
- _this.setEditorRef = function (editor) {
122
- _this.editor = editor;
110
+ this.setEditorRef = editor => {
111
+ this.editor = editor;
123
112
  };
124
- _this.state = {
113
+ this.state = {
125
114
  newValue: Array.isArray(props.value) ? props.value : [],
126
115
  isPopoverShow: false,
127
116
  popoverPosition: {}
128
117
  };
129
- var _column = _this.props.column;
130
- _this.options = _column.data && (_column.data.options || []);
131
- return _this;
118
+ let {
119
+ column: _column
120
+ } = this.props;
121
+ this.options = _column.data && (_column.data.options || []);
132
122
  }
133
- _createClass(MultipleSelectEditor, [{
134
- key: "componentDidMount",
135
- value: function componentDidMount() {
136
- document.addEventListener('click', this.onDocumentToggle);
137
- }
138
- }, {
139
- key: "componentWillUnmount",
140
- value: function componentWillUnmount() {
141
- document.removeEventListener('click', this.onDocumentToggle);
142
- }
143
- }, {
144
- key: "render",
145
- value: function render() {
146
- var _this2 = this;
147
- var _this$state = this.state,
148
- isPopoverShow = _this$state.isPopoverShow,
149
- popoverPosition = _this$state.popoverPosition;
150
- var options = this.options;
151
- var selectedOptions = this.getFormattedOptions();
152
- return /*#__PURE__*/React.createElement("div", {
153
- ref: this.setEditorContainerRef,
154
- className: "cell-editor dtable-ui-multiple-select-editor"
155
- }, /*#__PURE__*/React.createElement("div", {
156
- ref: this.setEditorRef,
157
- className: "dtable-ui-select-editor-container",
158
- onClick: this.onAddOptionToggle
159
- }, selectedOptions.length === 0 && /*#__PURE__*/React.createElement(EditEditorButton, {
160
- text: getLocale('Add_an_option')
161
- }), selectedOptions.length !== 0 && selectedOptions.map(function (option) {
162
- return /*#__PURE__*/React.createElement(SelectEditorOption, {
163
- key: option.id,
164
- option: option,
165
- isShowRemoveIcon: true,
166
- onDeleteSelectOption: _this2.onDeleteOption
167
- });
168
- })), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
169
- query: "(min-width: 768px)"
170
- }, /*#__PURE__*/React.createElement(PCSelectEditorPopover, {
171
- popoverPosition: popoverPosition,
172
- options: options,
173
- selectedOptions: selectedOptions,
174
- onOptionItemToggle: this.onOptionItemToggle,
175
- isSupportNewOption: this.props.isSupportNewOption,
176
- onAddNewOption: this.onAddNewOption
177
- })), /*#__PURE__*/React.createElement(MediaQuery, {
178
- query: "(max-width: 767.8px)"
179
- }, /*#__PURE__*/React.createElement(MBSelectEditorPopover, {
180
- isReadOnly: this.props.isReadOnly,
181
- value: this.state.newValue,
182
- column: this.props.column,
183
- options: options,
184
- onOptionItemToggle: this.onOptionItemToggle,
123
+ componentDidMount() {
124
+ document.addEventListener('click', this.onDocumentToggle);
125
+ }
126
+ componentWillUnmount() {
127
+ document.removeEventListener('click', this.onDocumentToggle);
128
+ }
129
+ render() {
130
+ let {
131
+ isPopoverShow,
132
+ popoverPosition
133
+ } = this.state;
134
+ let options = this.options;
135
+ let selectedOptions = this.getFormattedOptions();
136
+ return /*#__PURE__*/React.createElement("div", {
137
+ ref: this.setEditorContainerRef,
138
+ className: "cell-editor dtable-ui-multiple-select-editor"
139
+ }, /*#__PURE__*/React.createElement("div", {
140
+ ref: this.setEditorRef,
141
+ className: "dtable-ui-select-editor-container",
142
+ onClick: this.onAddOptionToggle
143
+ }, selectedOptions.length === 0 && /*#__PURE__*/React.createElement(EditEditorButton, {
144
+ text: getLocale('Add_an_option')
145
+ }), selectedOptions.length !== 0 && selectedOptions.map(option => {
146
+ return /*#__PURE__*/React.createElement(SelectEditorOption, {
147
+ key: option.id,
148
+ option: option,
185
149
  isShowRemoveIcon: true,
186
- isSupportNewOption: this.props.isSupportNewOption,
187
- onAddNewOption: this.onAddNewOption,
188
- onClosePopover: this.onClosePopover
189
- }))));
190
- }
191
- }]);
192
- return MultipleSelectEditor;
193
- }(React.Component);
150
+ onDeleteSelectOption: this.onDeleteOption
151
+ });
152
+ })), isPopoverShow && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(MediaQuery, {
153
+ query: "(min-width: 768px)"
154
+ }, /*#__PURE__*/React.createElement(PCSelectEditorPopover, {
155
+ popoverPosition: popoverPosition,
156
+ options: options,
157
+ selectedOptions: selectedOptions,
158
+ onOptionItemToggle: this.onOptionItemToggle,
159
+ isSupportNewOption: this.props.isSupportNewOption,
160
+ onAddNewOption: this.onAddNewOption
161
+ })), /*#__PURE__*/React.createElement(MediaQuery, {
162
+ query: "(max-width: 767.8px)"
163
+ }, /*#__PURE__*/React.createElement(MBSelectEditorPopover, {
164
+ isReadOnly: this.props.isReadOnly,
165
+ value: this.state.newValue,
166
+ column: this.props.column,
167
+ options: options,
168
+ onOptionItemToggle: this.onOptionItemToggle,
169
+ isShowRemoveIcon: true,
170
+ isSupportNewOption: this.props.isSupportNewOption,
171
+ onAddNewOption: this.onAddNewOption,
172
+ onClosePopover: this.onClosePopover
173
+ }))));
174
+ }
175
+ }
194
176
  MultipleSelectEditor.defaultProps = {
195
177
  isReadOnly: false,
196
178
  value: []
@@ -1,59 +1,43 @@
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
1
  import React from 'react';
6
2
  import classnames from 'classnames';
7
3
  import SelectItem from '../SelectItem';
8
4
  import './index.css';
9
- var MultipleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
10
- _inherits(MultipleSelectFormatter, _React$PureComponent);
11
- var _super = _createSuper(MultipleSelectFormatter);
12
- function MultipleSelectFormatter() {
13
- var _this;
14
- _classCallCheck(this, MultipleSelectFormatter);
15
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
16
- args[_key] = arguments[_key];
17
- }
18
- _this = _super.call.apply(_super, [this].concat(args));
19
- _this.getOptions = function () {
20
- var _this$props = _this.props,
21
- value = _this$props.value,
22
- options = _this$props.options;
5
+ class MultipleSelectFormatter extends React.PureComponent {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.getOptions = () => {
9
+ const {
10
+ value,
11
+ options
12
+ } = this.props;
23
13
  if (!Array.isArray(value) || !Array.isArray(options)) return [];
24
- var selectedOptions = options.filter(function (option) {
25
- return value.includes(option.id) || value.includes(option.name);
26
- });
14
+ let selectedOptions = options.filter(option => value.includes(option.id) || value.includes(option.name));
27
15
  if (selectedOptions.length === 0) return [];
28
- return selectedOptions.map(function (option) {
16
+ return selectedOptions.map(option => {
29
17
  return /*#__PURE__*/React.createElement(SelectItem, {
30
18
  key: "multiple-".concat(option.id),
31
19
  option: option
32
20
  });
33
21
  });
34
22
  };
35
- return _this;
36
23
  }
37
- _createClass(MultipleSelectFormatter, [{
38
- key: "render",
39
- value: function render() {
40
- var _this$props2 = this.props,
41
- value = _this$props2.value,
42
- containerClassName = _this$props2.containerClassName;
43
- var classname = classnames('dtable-ui cell-formatter-container multiple-select-formatter', containerClassName);
44
- if (!value || Array.isArray(value) && value.length === 0) {
45
- return /*#__PURE__*/React.createElement("div", {
46
- className: classname
47
- });
48
- }
49
- var options = this.getOptions();
24
+ render() {
25
+ let {
26
+ value,
27
+ containerClassName
28
+ } = this.props;
29
+ let classname = classnames('dtable-ui cell-formatter-container multiple-select-formatter', containerClassName);
30
+ if (!value || Array.isArray(value) && value.length === 0) {
50
31
  return /*#__PURE__*/React.createElement("div", {
51
32
  className: classname
52
- }, options);
33
+ });
53
34
  }
54
- }]);
55
- return MultipleSelectFormatter;
56
- }(React.PureComponent);
35
+ let options = this.getOptions();
36
+ return /*#__PURE__*/React.createElement("div", {
37
+ className: classname
38
+ }, options);
39
+ }
40
+ }
57
41
  MultipleSelectFormatter.defaultProps = {
58
42
  options: []
59
43
  };