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.
- package/lib/AutoNumberFormatter/index.js +11 -24
- package/lib/ButtonFormatter/index.js +29 -45
- package/lib/CTimeFormatter/index.js +17 -32
- package/lib/CheckboxEditor/index.js +42 -49
- package/lib/CheckboxFormatter/index.js +17 -30
- package/lib/CollaboratorEditor/index.js +118 -135
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +90 -99
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +61 -69
- package/lib/CollaboratorFormatter/index.js +26 -42
- package/lib/CollaboratorItem/index.js +31 -44
- package/lib/CreatorFormatter/index.js +24 -40
- package/lib/DTableCustomizeCollaboratorSelect/index.js +80 -99
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +12 -13
- package/lib/DTableCustomizeSelect/index.css +22 -59
- package/lib/DTableCustomizeSelect/index.js +99 -95
- package/lib/DTablePopover/index.js +52 -71
- package/lib/DTablePopover/utils.js +1 -1
- package/lib/DTableRadio/index.js +9 -7
- package/lib/DTableSearchInput/index.js +89 -99
- package/lib/DTableSearchInput/utils.js +2 -2
- package/lib/DTableSelect/dtable-select-label.js +5 -3
- package/lib/DTableSelect/index.js +50 -64
- package/lib/DTableSelect/utils.js +36 -41
- package/lib/DTableSwitch/index.js +7 -5
- package/lib/DateEditor/index.js +88 -94
- package/lib/DateEditor/mb-date-editor-popover/index.js +136 -134
- package/lib/DateEditor/pc-date-editor-popover.js +70 -77
- package/lib/DateFormatter/index.js +15 -28
- package/lib/DepartmentSingleSelectFormatter/index.js +9 -9
- package/lib/DigitalSignFormatter/index.js +55 -65
- package/lib/DigitalSignFormatter/utils.js +9 -8
- package/lib/DurationFormatter/index.js +14 -27
- package/lib/EditEditorButton/index.js +10 -22
- package/lib/EmailFormatter/index.js +11 -24
- package/lib/FieldDisplaySetting/field-item.js +18 -20
- package/lib/FieldDisplaySetting/index.js +41 -43
- package/lib/FileEditor/index.js +18 -29
- package/lib/FileFormatter/index.js +29 -43
- package/lib/FileItemFormatter/index.js +17 -32
- package/lib/FileItemFormatter/utils.js +5 -5
- package/lib/FileUploader/index.js +20 -33
- package/lib/FormulaFormatter/cell-value-validator.js +23 -8
- package/lib/FormulaFormatter/index.js +77 -83
- package/lib/FormulaFormatter/utils.js +27 -21
- package/lib/GeolocationFormatter/index.js +19 -32
- package/lib/HtmlLongTextFormatter/index.js +43 -52
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -2
- package/lib/HtmlLongTextFormatter/unified/index.js +1 -1
- package/lib/HtmlLongTextFormatter/vfile/core.js +10 -10
- package/lib/ImageFormatter/images-lazy-load.js +71 -79
- package/lib/ImageFormatter/index.js +86 -97
- package/lib/ImageFormatter/utils.js +1 -1
- package/lib/ImagePreviewerLightbox/index.js +20 -18
- package/lib/ImagePreviewerLightbox/utils.js +3 -3
- package/lib/LastModifierFormatter/index.js +24 -40
- package/lib/LinkEditor/index.js +163 -167
- package/lib/LinkEditor/link-editor-option.js +41 -56
- package/lib/LinkEditor/mb-link-editor-popover/index.js +90 -99
- package/lib/LinkEditor/pc-link-editor-popover/index.js +63 -71
- package/lib/LinkFormatter/index.js +75 -77
- package/lib/LongTextFormatter/index.js +5 -3
- package/lib/MBEditorHeader/index.js +25 -38
- package/lib/MTimeFormatter/index.js +17 -32
- package/lib/ModalPortal/index.js +15 -32
- package/lib/MultipleSelectEditor/index.js +118 -136
- package/lib/MultipleSelectFormatter/index.js +24 -40
- package/lib/NotificationPopover/index.js +68 -95
- package/lib/NumberEditor/index.js +75 -82
- package/lib/NumberFormatter/index.js +15 -28
- package/lib/RateFormatter/index.js +29 -45
- package/lib/RoleStatusEditor/index.js +20 -22
- package/lib/RowExpandEmailFormatter/index.js +24 -37
- package/lib/RowExpandFileFormatter/index.js +28 -42
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +66 -82
- package/lib/RowExpandFormatter/index.js +92 -96
- package/lib/RowExpandFormulaFormatter/index.js +85 -91
- package/lib/RowExpandImageFormatter/index.js +65 -82
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +71 -84
- package/lib/RowExpandImageFormatter/utils.js +1 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +54 -68
- package/lib/RowExpandLinkFormatter/index.js +131 -137
- package/lib/RowExpandLinkFormatter/utils.js +23 -17
- package/lib/RowExpandLinkFormatter/value-display-utils.js +9 -7
- package/lib/RowExpandRateFormatter/index.js +27 -42
- package/lib/RowExpandUrlFormatter/index.js +27 -40
- package/lib/SelectItem/index.js +17 -33
- package/lib/SelectOptionGroup/index.css +103 -0
- package/lib/SelectOptionGroup/index.js +157 -135
- package/lib/SelectOptionGroup/option.js +31 -38
- package/lib/SimpleLongTextFormatter/index.js +55 -67
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +23 -22
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +42 -57
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +31 -46
- package/lib/SingleSelectEditor/index.js +108 -119
- package/lib/SingleSelectFormatter/index.js +21 -37
- package/lib/TextEditor/index.js +45 -51
- package/lib/TextFormatter/index.js +17 -32
- package/lib/UrlFormatter/index.js +11 -24
- package/lib/cellFormatterFactory/index.js +8 -17
- package/lib/common/ClickOutside.js +28 -0
- package/lib/common/delete-tip.js +40 -65
- package/lib/common/modal-portal.js +15 -33
- package/lib/constants/index.js +5 -5
- package/lib/data/dtable-value.js +4 -4
- package/lib/formatterConfig/base-formatter-config.js +24 -3
- package/lib/formatterConfig/index.js +5 -4
- package/lib/lang/index.js +6 -6
- package/lib/locals/de.js +1 -1
- package/lib/locals/en.js +1 -1
- package/lib/locals/fr.js +1 -1
- package/lib/locals/zh-CN.js +1 -1
- package/lib/select-editor/mb-select-editor-popover/index.js +126 -137
- package/lib/select-editor/pc-select-editor-popover/index.js +75 -83
- package/lib/select-editor/select-editor-option.js +41 -56
- package/lib/toaster/alert.js +73 -88
- package/lib/toaster/index.js +1 -1
- package/lib/toaster/toast.js +75 -102
- package/lib/toaster/toastManager.js +55 -91
- package/lib/toaster/toaster.js +58 -57
- package/lib/utils/editor-utils.js +17 -19
- package/lib/utils/utils.js +14 -14
- 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
40
|
-
}
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
className: classname
|
|
23
|
+
}, date);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
41
26
|
MTimeFormatter.defaultProps = {
|
|
42
27
|
value: '',
|
|
43
28
|
containerClassName: ''
|
package/lib/ModalPortal/index.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
24
|
-
|
|
15
|
+
this.getFormattedOptions = () => {
|
|
16
|
+
let {
|
|
17
|
+
newValue
|
|
18
|
+
} = this.state;
|
|
25
19
|
if (Array.isArray(newValue) && newValue.length > 0) {
|
|
26
|
-
return newValue.map(
|
|
27
|
-
return
|
|
28
|
-
|
|
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
|
-
|
|
26
|
+
this.onAddOptionToggle = event => {
|
|
37
27
|
event.nativeEvent.stopImmediatePropagation();
|
|
38
28
|
event.stopPropagation();
|
|
39
|
-
if (
|
|
29
|
+
if (this.props.isReadOnly) {
|
|
40
30
|
return;
|
|
41
31
|
}
|
|
42
|
-
|
|
32
|
+
let isPopoverShow = !this.state.isPopoverShow;
|
|
43
33
|
if (isPopoverShow) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
isPopoverShow
|
|
47
|
-
popoverPosition
|
|
34
|
+
let popoverPosition = this.caculatePopoverPosition();
|
|
35
|
+
this.setState({
|
|
36
|
+
isPopoverShow,
|
|
37
|
+
popoverPosition
|
|
48
38
|
});
|
|
49
39
|
} else {
|
|
50
|
-
|
|
51
|
-
isPopoverShow
|
|
40
|
+
this.setState({
|
|
41
|
+
isPopoverShow
|
|
52
42
|
});
|
|
53
43
|
}
|
|
54
44
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
this.onCommit = newValue => {
|
|
46
|
+
let updated = {};
|
|
47
|
+
let {
|
|
48
|
+
column
|
|
49
|
+
} = this.props;
|
|
58
50
|
updated[column.key] = newValue;
|
|
59
|
-
|
|
51
|
+
this.props.onCommit(updated);
|
|
60
52
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
72
|
-
newValue
|
|
73
|
-
},
|
|
74
|
-
|
|
61
|
+
this.setState({
|
|
62
|
+
newValue
|
|
63
|
+
}, () => {
|
|
64
|
+
this.onCommit(newValue);
|
|
75
65
|
});
|
|
76
66
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
84
|
-
newValue
|
|
85
|
-
},
|
|
86
|
-
|
|
71
|
+
this.setState({
|
|
72
|
+
newValue
|
|
73
|
+
}, () => {
|
|
74
|
+
this.onCommit(newValue);
|
|
87
75
|
});
|
|
88
76
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
77
|
+
this.onAddNewOption = optionName => {
|
|
78
|
+
this.props.onAddNewOption(optionName);
|
|
79
|
+
this.onClosePopover();
|
|
92
80
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
top
|
|
98
|
-
height
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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
|
-
|
|
114
|
-
|
|
102
|
+
this.onClosePopover = () => {
|
|
103
|
+
this.setState({
|
|
115
104
|
isPopoverShow: false
|
|
116
105
|
});
|
|
117
106
|
};
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
this.setEditorContainerRef = editorContainer => {
|
|
108
|
+
this.editorContainer = editorContainer;
|
|
120
109
|
};
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
this.setEditorRef = editor => {
|
|
111
|
+
this.editor = editor;
|
|
123
112
|
};
|
|
124
|
-
|
|
113
|
+
this.state = {
|
|
125
114
|
newValue: Array.isArray(props.value) ? props.value : [],
|
|
126
115
|
isPopoverShow: false,
|
|
127
116
|
popoverPosition: {}
|
|
128
117
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
118
|
+
let {
|
|
119
|
+
column: _column
|
|
120
|
+
} = this.props;
|
|
121
|
+
this.options = _column.data && (_column.data.options || []);
|
|
132
122
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
}
|
|
33
|
+
});
|
|
53
34
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
};
|