dtable-ui-component 7.0.1-beta.1 → 7.0.1-beta.2
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/AsyncUserSelect/index.css +36 -18
- package/lib/AsyncUserSelect/index.js +29 -18
- package/lib/DTableCustomizeSearchInput/index.css +81 -0
- package/lib/DTableCustomizeSearchInput/index.js +136 -0
- package/lib/DTableCustomizeSelect/index.css +120 -42
- package/lib/DTableCustomizeSelect/index.js +9 -4
- package/lib/DTableFiltersPopover/utils/filter-item-utils.js +7 -19
- package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +5 -9
- package/lib/DTableFiltersPopover/widgets/filter-item.js +15 -7
- package/lib/DTableFiltersPopover/widgets/filter-list/index.css +3 -3
- package/lib/DTableSelect/dtable-select-label.css +4 -4
- package/lib/DTableSelect/dtable-select-label.js +1 -1
- package/lib/DTableSelect/index.js +3 -3
- package/lib/DTableSelect/select-dropdown-indicator/index.css +16 -0
- package/lib/DTableSelect/select-dropdown-indicator/index.js +24 -0
- package/lib/DTableSelect/user-select.css +7 -46
- package/lib/DTableSelect/utils.js +165 -79
- package/lib/ImageEditor/images-previewer/image-preview/index.js +1 -2
- package/lib/ImageEditor/pc-editor/addition-previewer/local-image-addition/index.js +2 -2
- package/lib/ImageFormatter/images-lazy-load.js +2 -2
- package/lib/ImageFormatter/index.js +2 -5
- package/lib/ImagePreviewerLightbox/index.js +1 -2
- package/lib/ImageThumbnail/index.js +1 -2
- package/lib/SelectOptionGroup/KeyCodes.js +96 -4
- package/lib/SelectOptionGroup/index.css +74 -52
- package/lib/SelectOptionGroup/index.js +35 -26
- package/lib/SelectOptionGroup/option.js +16 -4
- package/lib/assets/icons/close.svg +1 -0
- package/lib/assets/icons/down.svg +3 -0
- package/lib/index.js +3 -10
- package/lib/utils/url.js +35 -10
- package/package.json +2 -2
- package/lib/DTableCustomizeCollaboratorSelect/index.css +0 -86
- package/lib/DTableCustomizeCollaboratorSelect/index.js +0 -158
- package/lib/DTableGroupSelect/index.css +0 -96
- package/lib/DTableGroupSelect/index.js +0 -131
- package/lib/DTableGroupSelect/option.js +0 -42
- package/lib/DTableGroupSelect/select-option-group.css +0 -54
- package/lib/DTableGroupSelect/select-option-group.js +0 -227
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _DTableSearchInput = _interopRequireDefault(require("../DTableSearchInput"));
|
|
12
|
-
var _option = _interopRequireDefault(require("./option"));
|
|
13
|
-
var _KeyCodes = _interopRequireDefault(require("../SelectOptionGroup/KeyCodes"));
|
|
14
|
-
require("./select-option-group.css");
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
const OPTION_HEIGHT = 32;
|
|
17
|
-
class SelectOptionGroup extends _react.Component {
|
|
18
|
-
constructor(props) {
|
|
19
|
-
super(props);
|
|
20
|
-
this.handleDocumentClick = e => {
|
|
21
|
-
this.props.onClickOutside(e);
|
|
22
|
-
};
|
|
23
|
-
this.resetMenuStyle = () => {
|
|
24
|
-
const _this$props = this.props,
|
|
25
|
-
isInModal = _this$props.isInModal,
|
|
26
|
-
position = _this$props.position;
|
|
27
|
-
const _this$optionGroupRef$ = this.optionGroupRef.getBoundingClientRect(),
|
|
28
|
-
top = _this$optionGroupRef$.top,
|
|
29
|
-
height = _this$optionGroupRef$.height;
|
|
30
|
-
if (isInModal) {
|
|
31
|
-
if (position.y + position.height + height > window.innerHeight) {
|
|
32
|
-
this.optionGroupRef.style.top = position.y - height + 'px';
|
|
33
|
-
}
|
|
34
|
-
this.optionGroupRef.style.opacity = 1;
|
|
35
|
-
this.searchInputRef.current && this.searchInputRef.current.inputRef.focus();
|
|
36
|
-
} else {
|
|
37
|
-
if (height + top > window.innerHeight) {
|
|
38
|
-
const borderWidth = 2;
|
|
39
|
-
this.optionGroupRef.style.top = -1 * (height + borderWidth) + 'px';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
this.onHotKey = event => {
|
|
44
|
-
const keyCode = event.keyCode;
|
|
45
|
-
if (keyCode === _KeyCodes.default.UpArrow) {
|
|
46
|
-
this.onPressUp();
|
|
47
|
-
} else if (keyCode === _KeyCodes.default.DownArrow) {
|
|
48
|
-
this.onPressDown();
|
|
49
|
-
} else if (keyCode === _KeyCodes.default.Enter) {
|
|
50
|
-
let option = this.filterOptions && this.filterOptions[this.state.activeIndex];
|
|
51
|
-
if (option) {
|
|
52
|
-
this.props.onSelectOption(option);
|
|
53
|
-
}
|
|
54
|
-
} else if (keyCode === _KeyCodes.default.Tab || keyCode === _KeyCodes.default.Escape) {
|
|
55
|
-
this.props.closeSelect();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
this.onPressUp = () => {
|
|
59
|
-
if (this.state.activeIndex > 0) {
|
|
60
|
-
this.setState({
|
|
61
|
-
activeIndex: this.state.activeIndex - 1
|
|
62
|
-
}, () => {
|
|
63
|
-
this.scrollContent();
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
this.onPressDown = () => {
|
|
68
|
-
if (this.filterOptions && this.state.activeIndex < this.filterOptions.length - 1) {
|
|
69
|
-
this.setState({
|
|
70
|
-
activeIndex: this.state.activeIndex + 1
|
|
71
|
-
}, () => {
|
|
72
|
-
this.scrollContent();
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
this.onMouseDown = e => {
|
|
77
|
-
const isInModal = this.props.isInModal;
|
|
78
|
-
// prevent event propagation when click option or search input
|
|
79
|
-
if (isInModal) {
|
|
80
|
-
e.stopPropagation();
|
|
81
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
this.scrollContent = () => {
|
|
85
|
-
const _this$optionGroupCont = this.optionGroupContentRef,
|
|
86
|
-
offsetHeight = _this$optionGroupCont.offsetHeight,
|
|
87
|
-
scrollTop = _this$optionGroupCont.scrollTop;
|
|
88
|
-
this.setState({
|
|
89
|
-
disableHover: true
|
|
90
|
-
});
|
|
91
|
-
this.timer = setTimeout(() => {
|
|
92
|
-
this.setState({
|
|
93
|
-
disableHover: false
|
|
94
|
-
});
|
|
95
|
-
}, 500);
|
|
96
|
-
if (this.state.activeIndex * OPTION_HEIGHT === 0) {
|
|
97
|
-
this.optionGroupContentRef.scrollTop = 0;
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (this.state.activeIndex * OPTION_HEIGHT < scrollTop) {
|
|
101
|
-
this.optionGroupContentRef.scrollTop = scrollTop - OPTION_HEIGHT;
|
|
102
|
-
} else if (this.state.activeIndex * OPTION_HEIGHT > offsetHeight + scrollTop) {
|
|
103
|
-
this.optionGroupContentRef.scrollTop = scrollTop + OPTION_HEIGHT;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
this.changeIndex = index => {
|
|
107
|
-
this.setState({
|
|
108
|
-
activeIndex: index
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
this.onChangeSearch = searchVal => {
|
|
112
|
-
this.setState({
|
|
113
|
-
searchVal: searchVal || '',
|
|
114
|
-
activeIndex: -1
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
this.clearValue = () => {
|
|
118
|
-
this.setState({
|
|
119
|
-
searchVal: '',
|
|
120
|
-
activeIndex: -1
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
this.renderOptGroup = searchVal => {
|
|
124
|
-
let _this$props2 = this.props,
|
|
125
|
-
noOptionsPlaceholder = _this$props2.noOptionsPlaceholder,
|
|
126
|
-
onSelectOption = _this$props2.onSelectOption,
|
|
127
|
-
selectedOptions = _this$props2.selectedOptions;
|
|
128
|
-
this.filterOptions = this.props.getFilterOptions(searchVal);
|
|
129
|
-
if (this.filterOptions.length === 0) {
|
|
130
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
131
|
-
className: "none-search-result",
|
|
132
|
-
children: noOptionsPlaceholder
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return this.filterOptions.map((option, index) => {
|
|
136
|
-
const isSelected = selectedOptions.some(item => item.id === option.id);
|
|
137
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_option.default, {
|
|
138
|
-
index: index,
|
|
139
|
-
isActive: this.state.activeIndex === index,
|
|
140
|
-
option: option,
|
|
141
|
-
onSelectOption: onSelectOption,
|
|
142
|
-
changeIndex: this.changeIndex,
|
|
143
|
-
disableHover: this.state.disableHover,
|
|
144
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
145
|
-
className: "option-label text-truncate",
|
|
146
|
-
title: option.label,
|
|
147
|
-
children: option.label
|
|
148
|
-
}), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
149
|
-
className: "dtable-font dtable-icon-check-mark"
|
|
150
|
-
})]
|
|
151
|
-
}, "".concat(option.id, "-").concat(index));
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
this.state = {
|
|
155
|
-
searchVal: '',
|
|
156
|
-
activeIndex: -1,
|
|
157
|
-
disableHover: false
|
|
158
|
-
};
|
|
159
|
-
this.filterOptions = null;
|
|
160
|
-
this.timer = null;
|
|
161
|
-
this.searchInputRef = /*#__PURE__*/_react.default.createRef();
|
|
162
|
-
}
|
|
163
|
-
componentDidMount() {
|
|
164
|
-
window.addEventListener('keydown', this.onHotKey);
|
|
165
|
-
document.addEventListener('mousedown', this.handleDocumentClick);
|
|
166
|
-
setTimeout(() => {
|
|
167
|
-
this.resetMenuStyle();
|
|
168
|
-
}, 1);
|
|
169
|
-
}
|
|
170
|
-
componentWillUnmount() {
|
|
171
|
-
this.filterOptions = null;
|
|
172
|
-
this.timer && clearTimeout(this.timer);
|
|
173
|
-
window.removeEventListener('keydown', this.onHotKey);
|
|
174
|
-
document.removeEventListener('mousedown', this.handleDocumentClick);
|
|
175
|
-
}
|
|
176
|
-
render() {
|
|
177
|
-
const _this$props3 = this.props,
|
|
178
|
-
searchPlaceholder = _this$props3.searchPlaceholder,
|
|
179
|
-
top = _this$props3.top,
|
|
180
|
-
left = _this$props3.left,
|
|
181
|
-
minWidth = _this$props3.minWidth,
|
|
182
|
-
isInModal = _this$props3.isInModal,
|
|
183
|
-
position = _this$props3.position,
|
|
184
|
-
className = _this$props3.className;
|
|
185
|
-
let searchVal = this.state.searchVal;
|
|
186
|
-
let style = {
|
|
187
|
-
top: top || 0,
|
|
188
|
-
left: left || 0
|
|
189
|
-
};
|
|
190
|
-
if (minWidth) {
|
|
191
|
-
style = {
|
|
192
|
-
top: top || 0,
|
|
193
|
-
left: left || 0,
|
|
194
|
-
minWidth
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
if (isInModal) {
|
|
198
|
-
style = {
|
|
199
|
-
position: 'fixed',
|
|
200
|
-
left: position.x,
|
|
201
|
-
top: position.y + position.height,
|
|
202
|
-
minWidth: position.width,
|
|
203
|
-
opacity: 0
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
207
|
-
className: (0, _classnames.default)('option-group group-selector', className ? 'option-group-' + className : ''),
|
|
208
|
-
ref: ref => this.optionGroupRef = ref,
|
|
209
|
-
style: style,
|
|
210
|
-
onMouseDown: this.onMouseDown,
|
|
211
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
212
|
-
className: "option-group-search position-relative",
|
|
213
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableSearchInput.default, {
|
|
214
|
-
className: "option-search-control",
|
|
215
|
-
placeholder: searchPlaceholder,
|
|
216
|
-
onChange: this.onChangeSearch,
|
|
217
|
-
ref: this.searchInputRef
|
|
218
|
-
})
|
|
219
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
220
|
-
className: "option-group-content",
|
|
221
|
-
ref: ref => this.optionGroupContentRef = ref,
|
|
222
|
-
children: this.renderOptGroup(searchVal)
|
|
223
|
-
})]
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
var _default = exports.default = SelectOptionGroup;
|