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.
- package/lib/DTableCustomizeCollaboratorSelect/index.css +124 -0
- package/lib/DTableCustomizeCollaboratorSelect/index.js +187 -0
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +24 -0
- package/lib/DTableCustomizeSelect/index.js +155 -0
- package/lib/DTablePopover/index.js +115 -0
- package/lib/DTablePopover/utils.js +5 -0
- package/lib/DTableSearchInput/index.js +161 -0
- package/lib/DTableSearchInput/utils.js +4 -0
- package/lib/DTableSelect/index.js +141 -0
- package/lib/DTableSwitch/index.js +27 -0
- package/lib/SelectOptionGroup/KeyCodes.js +10 -0
- package/lib/SelectOptionGroup/index.js +217 -0
- package/lib/SelectOptionGroup/option.js +60 -0
- package/lib/assets/css/DTableCustomSelect.css +148 -0
- package/lib/index.js +8 -1
- package/package.json +2 -1
- package/es/app.css +0 -20
- package/es/app.js +0 -91
- package/es/assets/images/avatar/default_avatar.png +0 -0
- package/es/assets/images/file/192/excel.png +0 -0
- package/es/assets/images/file/192/file.png +0 -0
- package/es/assets/images/file/192/music.png +0 -0
- package/es/assets/images/file/192/pdf.png +0 -0
- package/es/assets/images/file/192/pic.png +0 -0
- package/es/assets/images/file/192/ppt.png +0 -0
- package/es/assets/images/file/192/txt.png +0 -0
- package/es/assets/images/file/192/video.png +0 -0
- package/es/assets/images/file/192/word.png +0 -0
- package/es/assets/images/file/24/excel.png +0 -0
- package/es/assets/images/file/24/file.png +0 -0
- package/es/assets/images/file/24/music.png +0 -0
- package/es/assets/images/file/24/pdf.png +0 -0
- package/es/assets/images/file/24/pic.png +0 -0
- package/es/assets/images/file/24/ppt.png +0 -0
- package/es/assets/images/file/24/txt.png +0 -0
- package/es/assets/images/file/24/video.png +0 -0
- package/es/assets/images/file/24/word.png +0 -0
- package/es/assets/images/folder/folder-192.png +0 -0
- package/es/assets/images/folder/folder-24.png +0 -0
- package/es/components/cell-editor/checkbox-editor.js +0 -104
- package/es/components/cell-editor/collaborator-editor.js +0 -236
- package/es/components/cell-editor/date-editor.js +0 -151
- package/es/components/cell-editor/index.js +0 -9
- package/es/components/cell-editor/link-editor.js +0 -303
- package/es/components/cell-editor/multiple-select-editor.js +0 -237
- package/es/components/cell-editor/number-editor.js +0 -154
- package/es/components/cell-editor/single-select-editor.js +0 -202
- package/es/components/cell-editor/text-editor.js +0 -122
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +0 -46
- package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
- package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +0 -177
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +0 -245
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +0 -170
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +0 -230
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +0 -109
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +0 -142
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +0 -114
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +0 -143
- package/es/components/cell-factory/cell-formatter-factory.js +0 -25
- package/es/components/cell-formatter/auto-number-formatter.js +0 -35
- package/es/components/cell-formatter/button-formatter.js +0 -55
- package/es/components/cell-formatter/checkbox-formatter.js +0 -44
- package/es/components/cell-formatter/collaborator-formatter.js +0 -91
- package/es/components/cell-formatter/creator-formatter.js +0 -87
- package/es/components/cell-formatter/ctime-formatter.js +0 -57
- package/es/components/cell-formatter/date-formatter.js +0 -59
- package/es/components/cell-formatter/duration-formatter.js +0 -37
- package/es/components/cell-formatter/email-formatter.js +0 -35
- package/es/components/cell-formatter/file-formatter.js +0 -63
- package/es/components/cell-formatter/formatter-config.js +0 -31
- package/es/components/cell-formatter/formula-formatter.js +0 -164
- package/es/components/cell-formatter/geolocation-formatter.js +0 -52
- package/es/components/cell-formatter/image-formatter.js +0 -153
- package/es/components/cell-formatter/index.js +0 -27
- package/es/components/cell-formatter/last-modifier-formatter.js +0 -87
- package/es/components/cell-formatter/link-formatter.js +0 -144
- package/es/components/cell-formatter/long-text-formatter.js +0 -106
- package/es/components/cell-formatter/mtime-formatter.js +0 -57
- package/es/components/cell-formatter/multiple-select-formatter.js +0 -69
- package/es/components/cell-formatter/number-formatter.js +0 -46
- package/es/components/cell-formatter/rate-formatter.js +0 -79
- package/es/components/cell-formatter/single-select-formatter.js +0 -69
- package/es/components/cell-formatter/text-formatter.js +0 -55
- package/es/components/cell-formatter/url-formatter.js +0 -35
- package/es/components/cell-formatter/widgets/file-item-formatter.js +0 -50
- package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +0 -119
- package/es/components/common/collaborator-item.js +0 -63
- package/es/components/common/edit-editor-button.js +0 -56
- package/es/components/common/images-lazy-load.js +0 -150
- package/es/components/common/link-editor-option.js +0 -113
- package/es/components/common/mobile/mb-editor-header.js +0 -48
- package/es/components/common/modal-portal.js +0 -44
- package/es/components/common/select-editor-option.js +0 -106
- package/es/components/common/select-item.js +0 -58
- package/es/components/file-uploader/index.js +0 -53
- package/es/components/loading.js +0 -7
- package/es/components/toast/alert.js +0 -150
- package/es/components/toast/index.js +0 -3
- package/es/components/toast/toast.js +0 -179
- package/es/components/toast/toastManager.js +0 -170
- package/es/components/toast/toaster.js +0 -76
- package/es/constants/cell-types.js +0 -25
- package/es/constants/index.js +0 -48
- package/es/css/cell-editor.css +0 -614
- package/es/css/cell-formatter.css +0 -241
- package/es/css/custom-rc-calendar.css +0 -118
- package/es/css/image-previewer-ligntbox.css +0 -87
- package/es/css/loading.css +0 -54
- package/es/index.js +0 -6
- package/es/lang/index.js +0 -50
- package/es/locals/de.js +0 -2
- package/es/locals/en.js +0 -17
- package/es/locals/fr.js +0 -2
- package/es/locals/zh-CN.js +0 -17
- package/es/utils/cell-value-validator.js +0 -32
- package/es/utils/column-utils.js +0 -7
- package/es/utils/editor-utils.js +0 -71
- package/es/utils/normalize-long-text-value.js +0 -68
- package/es/utils/number-precision.js +0 -163
- package/es/utils/utils.js +0 -116
- package/es/utils/value-format-utils.js +0 -495
|
@@ -0,0 +1,161 @@
|
|
|
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, { Component, Fragment } from 'react';
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
import { isFunction } from './utils';
|
|
8
|
+
|
|
9
|
+
var DtableSearchInput = /*#__PURE__*/function (_Component) {
|
|
10
|
+
_inherits(DtableSearchInput, _Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(DtableSearchInput);
|
|
13
|
+
|
|
14
|
+
function DtableSearchInput(props) {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, DtableSearchInput);
|
|
18
|
+
|
|
19
|
+
_this = _super.call(this, props);
|
|
20
|
+
|
|
21
|
+
_this.onCompositionStart = function () {
|
|
22
|
+
_this.isInputtingChinese = true;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
_this.onChange = function (e) {
|
|
26
|
+
_this.timer && clearTimeout(_this.timer);
|
|
27
|
+
var _this$props = _this.props,
|
|
28
|
+
onChange = _this$props.onChange,
|
|
29
|
+
wait = _this$props.wait;
|
|
30
|
+
var text = e.target.value;
|
|
31
|
+
|
|
32
|
+
_this.setState({
|
|
33
|
+
searchValue: text || ''
|
|
34
|
+
}, function () {
|
|
35
|
+
if (_this.isInputtingChinese) return;
|
|
36
|
+
_this.timer = setTimeout(function () {
|
|
37
|
+
onChange && onChange(_this.state.searchValue.trim());
|
|
38
|
+
}, wait);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
_this.onCompositionEnd = function (e) {
|
|
43
|
+
_this.isInputtingChinese = false;
|
|
44
|
+
|
|
45
|
+
_this.onChange(e);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
_this.clearSearch = function () {
|
|
49
|
+
var clearValue = _this.props.clearValue;
|
|
50
|
+
|
|
51
|
+
_this.setState({
|
|
52
|
+
searchValue: ''
|
|
53
|
+
}, function () {
|
|
54
|
+
clearValue && clearValue();
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
_this.setFocus = function (isSelectAllText) {
|
|
59
|
+
if (_this.inputRef === document.activeElement) return;
|
|
60
|
+
|
|
61
|
+
_this.inputRef.focus();
|
|
62
|
+
|
|
63
|
+
if (isSelectAllText) {
|
|
64
|
+
var txtLength = _this.state.searchValue.length;
|
|
65
|
+
|
|
66
|
+
_this.inputRef.setSelectionRange(0, txtLength);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
_this.renderClear = function () {
|
|
71
|
+
var _this$props2 = _this.props,
|
|
72
|
+
isClearable = _this$props2.isClearable,
|
|
73
|
+
clearClassName = _this$props2.clearClassName,
|
|
74
|
+
_this$props2$componen = _this$props2.components,
|
|
75
|
+
components = _this$props2$componen === void 0 ? {} : _this$props2$componen;
|
|
76
|
+
var searchValue = _this.state.searchValue;
|
|
77
|
+
if (!isClearable || !searchValue) return null;
|
|
78
|
+
var ClearIndicator = components.ClearIndicator;
|
|
79
|
+
|
|
80
|
+
if (React.isValidElement(ClearIndicator)) {
|
|
81
|
+
return React.cloneElement(ClearIndicator, {
|
|
82
|
+
clearValue: _this.clearSearch
|
|
83
|
+
});
|
|
84
|
+
} else if (isFunction(ClearIndicator)) {
|
|
85
|
+
return /*#__PURE__*/React.createElement(ClearIndicator, {
|
|
86
|
+
clearValue: _this.clearSearch
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return /*#__PURE__*/React.createElement("i", {
|
|
91
|
+
className: classnames('search-text-clear input-icon-addon', clearClassName),
|
|
92
|
+
onClick: _this.clearSearch
|
|
93
|
+
}, "\xD7");
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
_this.state = {
|
|
97
|
+
searchValue: props.value
|
|
98
|
+
};
|
|
99
|
+
_this.isInputtingChinese = false;
|
|
100
|
+
_this.timer = null;
|
|
101
|
+
_this.inputRef = null;
|
|
102
|
+
return _this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_createClass(DtableSearchInput, [{
|
|
106
|
+
key: "componentWillReceiveProps",
|
|
107
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
108
|
+
if (nextProps.value !== this.props.value) {
|
|
109
|
+
this.setState({
|
|
110
|
+
searchValue: nextProps.value
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "componentWillUnmount",
|
|
116
|
+
value: function componentWillUnmount() {
|
|
117
|
+
this.timer && clearTimeout(this.timer);
|
|
118
|
+
this.timer = null;
|
|
119
|
+
this.inputRef = null;
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "render",
|
|
123
|
+
value: function render() {
|
|
124
|
+
var _this2 = this;
|
|
125
|
+
|
|
126
|
+
var _this$props3 = this.props,
|
|
127
|
+
placeholder = _this$props3.placeholder,
|
|
128
|
+
autoFocus = _this$props3.autoFocus,
|
|
129
|
+
className = _this$props3.className,
|
|
130
|
+
onKeyDown = _this$props3.onKeyDown,
|
|
131
|
+
disabled = _this$props3.disabled,
|
|
132
|
+
style = _this$props3.style;
|
|
133
|
+
var searchValue = this.state.searchValue;
|
|
134
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("input", {
|
|
135
|
+
type: "text",
|
|
136
|
+
value: searchValue,
|
|
137
|
+
className: classnames('form-control', className),
|
|
138
|
+
onChange: this.onChange,
|
|
139
|
+
autoFocus: autoFocus,
|
|
140
|
+
placeholder: placeholder,
|
|
141
|
+
onCompositionStart: this.onCompositionStart,
|
|
142
|
+
onCompositionEnd: this.onCompositionEnd,
|
|
143
|
+
onKeyDown: onKeyDown,
|
|
144
|
+
disabled: disabled,
|
|
145
|
+
style: style,
|
|
146
|
+
ref: function ref(_ref) {
|
|
147
|
+
return _this2.inputRef = _ref;
|
|
148
|
+
}
|
|
149
|
+
}), this.renderClear());
|
|
150
|
+
}
|
|
151
|
+
}]);
|
|
152
|
+
|
|
153
|
+
return DtableSearchInput;
|
|
154
|
+
}(Component);
|
|
155
|
+
|
|
156
|
+
DtableSearchInput.defaultProps = {
|
|
157
|
+
wait: 100,
|
|
158
|
+
disabled: false,
|
|
159
|
+
value: ''
|
|
160
|
+
};
|
|
161
|
+
export default DtableSearchInput;
|
|
@@ -0,0 +1,141 @@
|
|
|
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 _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import Select, { components } from 'react-select';
|
|
8
|
+
var MenuSelectStyle = {
|
|
9
|
+
option: function option(provided, state) {
|
|
10
|
+
var isDisabled = state.isDisabled,
|
|
11
|
+
isSelected = state.isSelected,
|
|
12
|
+
isFocused = state.isFocused;
|
|
13
|
+
return _objectSpread(_objectSpread({}, provided), {}, {
|
|
14
|
+
cursor: isDisabled ? 'default' : 'pointer',
|
|
15
|
+
backgroundColor: isSelected ? '#20a0ff' : isFocused ? '#f5f5f5' : '#fff',
|
|
16
|
+
'.header-icon .dtable-font': {
|
|
17
|
+
color: isSelected ? '#fff' : '#aaa'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
control: function control(provided) {
|
|
22
|
+
return _objectSpread(_objectSpread({}, provided), {}, {
|
|
23
|
+
fontSize: '14px',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
lineHeight: '1.5'
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
menuPortal: function menuPortal(base) {
|
|
29
|
+
return _objectSpread(_objectSpread({}, base), {}, {
|
|
30
|
+
zIndex: 9999
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
indicatorSeparator: function indicatorSeparator() {}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var DropdownIndicator = function DropdownIndicator(props) {
|
|
37
|
+
return components.DropdownIndicator && /*#__PURE__*/React.createElement(components.DropdownIndicator, props, /*#__PURE__*/React.createElement("span", {
|
|
38
|
+
className: "dtable-font dtable-icon-drop-down",
|
|
39
|
+
style: {
|
|
40
|
+
fontSize: '12px'
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var MenuList = function MenuList(props) {
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
onClick: function onClick(e) {
|
|
48
|
+
return e.nativeEvent.stopImmediatePropagation();
|
|
49
|
+
},
|
|
50
|
+
onMouseDown: function onMouseDown(e) {
|
|
51
|
+
return e.nativeEvent.stopImmediatePropagation();
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement(components.MenuList, props, props.children));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var Option = function Option(props) {
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
style: props.data.style
|
|
59
|
+
}, /*#__PURE__*/React.createElement(components.Option, props));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var DtableSelect = /*#__PURE__*/function (_React$Component) {
|
|
63
|
+
_inherits(DtableSelect, _React$Component);
|
|
64
|
+
|
|
65
|
+
var _super = _createSuper(DtableSelect);
|
|
66
|
+
|
|
67
|
+
function DtableSelect() {
|
|
68
|
+
var _this;
|
|
69
|
+
|
|
70
|
+
_classCallCheck(this, DtableSelect);
|
|
71
|
+
|
|
72
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
73
|
+
args[_key] = arguments[_key];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
77
|
+
|
|
78
|
+
_this.getMenuPortalTarget = function () {
|
|
79
|
+
var menuPortalTarget = _this.props.menuPortalTarget;
|
|
80
|
+
return document.querySelector(menuPortalTarget);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return _this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_createClass(DtableSelect, [{
|
|
87
|
+
key: "render",
|
|
88
|
+
value: function render() {
|
|
89
|
+
var _this$props = this.props,
|
|
90
|
+
options = _this$props.options,
|
|
91
|
+
onChange = _this$props.onChange,
|
|
92
|
+
value = _this$props.value,
|
|
93
|
+
isSearchable = _this$props.isSearchable,
|
|
94
|
+
placeholder = _this$props.placeholder,
|
|
95
|
+
isMulti = _this$props.isMulti,
|
|
96
|
+
menuPosition = _this$props.menuPosition,
|
|
97
|
+
isClearable = _this$props.isClearable,
|
|
98
|
+
noOptionsMessage = _this$props.noOptionsMessage,
|
|
99
|
+
classNamePrefix = _this$props.classNamePrefix,
|
|
100
|
+
style = _this$props.style;
|
|
101
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
102
|
+
value: value,
|
|
103
|
+
onChange: onChange,
|
|
104
|
+
options: options,
|
|
105
|
+
isMulti: isMulti,
|
|
106
|
+
classNamePrefix: classNamePrefix,
|
|
107
|
+
styles: style || MenuSelectStyle,
|
|
108
|
+
components: {
|
|
109
|
+
Option: Option,
|
|
110
|
+
DropdownIndicator: DropdownIndicator,
|
|
111
|
+
MenuList: MenuList
|
|
112
|
+
},
|
|
113
|
+
placeholder: placeholder,
|
|
114
|
+
isSearchable: isSearchable,
|
|
115
|
+
isClearable: isClearable,
|
|
116
|
+
menuPosition: menuPosition || 'fixed' // when use default menuPosition(absolute), menuPortalTarget is unnecessary.
|
|
117
|
+
,
|
|
118
|
+
menuShouldScrollIntoView: true,
|
|
119
|
+
menuPortalTarget: this.getMenuPortalTarget(),
|
|
120
|
+
captureMenuScroll: false,
|
|
121
|
+
noOptionsMessage: noOptionsMessage
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}]);
|
|
125
|
+
|
|
126
|
+
return DtableSelect;
|
|
127
|
+
}(React.Component);
|
|
128
|
+
|
|
129
|
+
DtableSelect.defaultProps = {
|
|
130
|
+
options: [],
|
|
131
|
+
value: {},
|
|
132
|
+
isSearchable: false,
|
|
133
|
+
isClearable: false,
|
|
134
|
+
placeholder: '',
|
|
135
|
+
isMulti: false,
|
|
136
|
+
menuPortalTarget: '.modal',
|
|
137
|
+
noOptionsMessage: function noOptionsMessage() {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
export default DtableSelect;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
function DtableSwitch(props) {
|
|
4
|
+
var onChange = props.onChange,
|
|
5
|
+
checked = props.checked,
|
|
6
|
+
placeholder = props.placeholder,
|
|
7
|
+
disabled = props.disabled,
|
|
8
|
+
switchClassName = props.switchClassName;
|
|
9
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
10
|
+
className: "dtable-switch ".concat(switchClassName || '')
|
|
11
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
12
|
+
className: "custom-switch"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
14
|
+
className: "custom-switch-input",
|
|
15
|
+
type: "checkbox",
|
|
16
|
+
checked: checked,
|
|
17
|
+
onChange: onChange,
|
|
18
|
+
name: "custom-switch-checkbox",
|
|
19
|
+
disabled: disabled
|
|
20
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
21
|
+
className: "custom-switch-description text-truncate"
|
|
22
|
+
}, placeholder), /*#__PURE__*/React.createElement("span", {
|
|
23
|
+
className: "custom-switch-indicator"
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default DtableSwitch;
|
|
@@ -0,0 +1,217 @@
|
|
|
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, { Component } from 'react';
|
|
6
|
+
import Option from './option';
|
|
7
|
+
import DTableSearchInput from '../DTableSearchInput';
|
|
8
|
+
import KeyCodes from './KeyCodes';
|
|
9
|
+
var OPTION_HEIGHT = 32;
|
|
10
|
+
|
|
11
|
+
var SelectOptionGroup = /*#__PURE__*/function (_Component) {
|
|
12
|
+
_inherits(SelectOptionGroup, _Component);
|
|
13
|
+
|
|
14
|
+
var _super = _createSuper(SelectOptionGroup);
|
|
15
|
+
|
|
16
|
+
function SelectOptionGroup(props) {
|
|
17
|
+
var _this;
|
|
18
|
+
|
|
19
|
+
_classCallCheck(this, SelectOptionGroup);
|
|
20
|
+
|
|
21
|
+
_this = _super.call(this, props);
|
|
22
|
+
|
|
23
|
+
_this.resetMenuStyle = function () {
|
|
24
|
+
var _this$optionGroupRef$ = _this.optionGroupRef.getBoundingClientRect(),
|
|
25
|
+
top = _this$optionGroupRef$.top,
|
|
26
|
+
height = _this$optionGroupRef$.height;
|
|
27
|
+
|
|
28
|
+
if (height + top > window.innerHeight) {
|
|
29
|
+
var borderWidth = 2;
|
|
30
|
+
_this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_this.onHotKey = function (event) {
|
|
35
|
+
var keyCode = event.keyCode;
|
|
36
|
+
|
|
37
|
+
if (keyCode === KeyCodes.UpArrow) {
|
|
38
|
+
_this.onPressUp();
|
|
39
|
+
} else if (keyCode === KeyCodes.DownArrow) {
|
|
40
|
+
_this.onPressDown();
|
|
41
|
+
} else if (keyCode === KeyCodes.Enter) {
|
|
42
|
+
var option = _this.filterOptions && _this.filterOptions[_this.state.activeIndex];
|
|
43
|
+
|
|
44
|
+
if (option) {
|
|
45
|
+
_this.props.onSelectOption(option.value);
|
|
46
|
+
|
|
47
|
+
if (!_this.props.supportMultipleSelect) {
|
|
48
|
+
_this.props.closeSelect();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
} else if (keyCode === KeyCodes.Tab || keyCode === KeyCodes.Escape) {
|
|
52
|
+
_this.props.closeSelect();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
_this.onPressUp = function () {
|
|
57
|
+
if (_this.state.activeIndex > 0) {
|
|
58
|
+
_this.setState({
|
|
59
|
+
activeIndex: _this.state.activeIndex - 1
|
|
60
|
+
}, function () {
|
|
61
|
+
_this.scrollContent();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
_this.onPressDown = function () {
|
|
67
|
+
if (_this.filterOptions && _this.state.activeIndex < _this.filterOptions.length - 1) {
|
|
68
|
+
_this.setState({
|
|
69
|
+
activeIndex: _this.state.activeIndex + 1
|
|
70
|
+
}, function () {
|
|
71
|
+
_this.scrollContent();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
_this.onClick = function (e) {
|
|
77
|
+
if (_this.props.stopClickEvent && _this.optionGroupRef.contains(e.target) && !e.target.className.includes('dtable-font')) {
|
|
78
|
+
e.stopPropagation();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
_this.scrollContent = function () {
|
|
83
|
+
var _this$optionGroupCont = _this.optionGroupContentRef,
|
|
84
|
+
offsetHeight = _this$optionGroupCont.offsetHeight,
|
|
85
|
+
scrollTop = _this$optionGroupCont.scrollTop;
|
|
86
|
+
|
|
87
|
+
if (_this.state.activeIndex * OPTION_HEIGHT < scrollTop) {
|
|
88
|
+
_this.optionGroupContentRef.scrollTop = scrollTop - OPTION_HEIGHT;
|
|
89
|
+
} else if (_this.state.activeIndex * OPTION_HEIGHT > offsetHeight + scrollTop) {
|
|
90
|
+
_this.optionGroupContentRef.scrollTop = scrollTop + OPTION_HEIGHT;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
_this.changeIndex = function (index) {
|
|
95
|
+
_this.setState({
|
|
96
|
+
activeIndex: index
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
_this.onChangeSearch = function (searchVal) {
|
|
101
|
+
var value = searchVal || '';
|
|
102
|
+
|
|
103
|
+
if (value !== _this.state.searchVal) {
|
|
104
|
+
_this.setState({
|
|
105
|
+
searchVal: value,
|
|
106
|
+
activeIndex: -1
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
_this.renderOptGroup = function (searchVal) {
|
|
112
|
+
var _this$props = _this.props,
|
|
113
|
+
noOptionsPlaceholder = _this$props.noOptionsPlaceholder,
|
|
114
|
+
onSelectOption = _this$props.onSelectOption;
|
|
115
|
+
_this.filterOptions = _this.props.getFilterOptions(searchVal);
|
|
116
|
+
|
|
117
|
+
if (_this.filterOptions === 0) {
|
|
118
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
119
|
+
className: "none-search-result"
|
|
120
|
+
}, noOptionsPlaceholder);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return _this.filterOptions.map(function (opt, i) {
|
|
124
|
+
var key = opt.value.column ? opt.value.column.key : i;
|
|
125
|
+
var isActive = _this.state.activeIndex === i;
|
|
126
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
127
|
+
key: key,
|
|
128
|
+
index: i,
|
|
129
|
+
isActive: isActive,
|
|
130
|
+
value: opt.value,
|
|
131
|
+
onSelectOption: onSelectOption,
|
|
132
|
+
changeIndex: _this.changeIndex,
|
|
133
|
+
supportMultipleSelect: _this.props.supportMultipleSelect
|
|
134
|
+
}, opt.label);
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
_this.state = {
|
|
139
|
+
searchVal: '',
|
|
140
|
+
activeIndex: -1
|
|
141
|
+
};
|
|
142
|
+
_this.filterOptions = null;
|
|
143
|
+
return _this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_createClass(SelectOptionGroup, [{
|
|
147
|
+
key: "componentDidMount",
|
|
148
|
+
value: function componentDidMount() {
|
|
149
|
+
window.addEventListener('keydown', this.onHotKey);
|
|
150
|
+
window.addEventListener('click', this.onClick, true);
|
|
151
|
+
this.resetMenuStyle();
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "componentWillUnmount",
|
|
155
|
+
value: function componentWillUnmount() {
|
|
156
|
+
this.filterOptions = null;
|
|
157
|
+
window.removeEventListener('click', this.onClick, true);
|
|
158
|
+
window.removeEventListener('keydown', this.onHotKey);
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "render",
|
|
162
|
+
value: function render() {
|
|
163
|
+
var _this2 = this;
|
|
164
|
+
|
|
165
|
+
var _this$props2 = this.props,
|
|
166
|
+
searchable = _this$props2.searchable,
|
|
167
|
+
searchPlaceholder = _this$props2.searchPlaceholder,
|
|
168
|
+
top = _this$props2.top,
|
|
169
|
+
left = _this$props2.left,
|
|
170
|
+
minWidth = _this$props2.minWidth,
|
|
171
|
+
value = _this$props2.value,
|
|
172
|
+
isShowSelected = _this$props2.isShowSelected;
|
|
173
|
+
var searchVal = this.state.searchVal;
|
|
174
|
+
var style = {
|
|
175
|
+
top: top || 0,
|
|
176
|
+
left: left || 0
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if (minWidth) {
|
|
180
|
+
style = {
|
|
181
|
+
top: top || 0,
|
|
182
|
+
left: left || 0,
|
|
183
|
+
minWidth: minWidth
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
188
|
+
className: "option-group ".concat(isShowSelected ? 'pt-0' : ''),
|
|
189
|
+
ref: function ref(_ref2) {
|
|
190
|
+
return _this2.optionGroupRef = _ref2;
|
|
191
|
+
},
|
|
192
|
+
style: style
|
|
193
|
+
}, isShowSelected && /*#__PURE__*/React.createElement("div", {
|
|
194
|
+
className: "editor-list-delete mb-2",
|
|
195
|
+
onClick: function onClick(e) {
|
|
196
|
+
return e.stopPropagation();
|
|
197
|
+
}
|
|
198
|
+
}, value.label || ''), searchable && /*#__PURE__*/React.createElement("div", {
|
|
199
|
+
className: "option-group-search"
|
|
200
|
+
}, /*#__PURE__*/React.createElement(DTableSearchInput, {
|
|
201
|
+
className: "option-search-control",
|
|
202
|
+
placeholder: searchPlaceholder,
|
|
203
|
+
onChange: this.onChangeSearch,
|
|
204
|
+
autoFocus: true
|
|
205
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
206
|
+
className: "option-group-content",
|
|
207
|
+
ref: function ref(_ref) {
|
|
208
|
+
return _this2.optionGroupContentRef = _ref;
|
|
209
|
+
}
|
|
210
|
+
}, this.renderOptGroup(searchVal)));
|
|
211
|
+
}
|
|
212
|
+
}]);
|
|
213
|
+
|
|
214
|
+
return SelectOptionGroup;
|
|
215
|
+
}(Component);
|
|
216
|
+
|
|
217
|
+
export default SelectOptionGroup;
|
|
@@ -0,0 +1,60 @@
|
|
|
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, { Component } from 'react';
|
|
6
|
+
|
|
7
|
+
var Option = /*#__PURE__*/function (_Component) {
|
|
8
|
+
_inherits(Option, _Component);
|
|
9
|
+
|
|
10
|
+
var _super = _createSuper(Option);
|
|
11
|
+
|
|
12
|
+
function Option() {
|
|
13
|
+
var _this;
|
|
14
|
+
|
|
15
|
+
_classCallCheck(this, Option);
|
|
16
|
+
|
|
17
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
|
+
args[_key] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
22
|
+
|
|
23
|
+
_this.onSelectOption = function (value, event) {
|
|
24
|
+
_this.props.onSelectOption(value, event);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
_this.onClick = function (event) {
|
|
28
|
+
if (_this.props.supportMultipleSelect) {
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
_this.onMouseEnter = function () {
|
|
34
|
+
_this.props.changeIndex(_this.props.index);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
_this.onMouseLeave = function () {
|
|
38
|
+
_this.props.changeIndex(-1);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return _this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_createClass(Option, [{
|
|
45
|
+
key: "render",
|
|
46
|
+
value: function render() {
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: this.props.isActive ? 'option option-active' : 'option',
|
|
49
|
+
onMouseDown: this.onSelectOption.bind(this, this.props.value),
|
|
50
|
+
onClick: this.onClick,
|
|
51
|
+
onMouseEnter: this.onMouseEnter,
|
|
52
|
+
onMouseLeave: this.onMouseLeave
|
|
53
|
+
}, this.props.children);
|
|
54
|
+
}
|
|
55
|
+
}]);
|
|
56
|
+
|
|
57
|
+
return Option;
|
|
58
|
+
}(Component);
|
|
59
|
+
|
|
60
|
+
export default Option;
|