@aloudata/aloudata-design 0.4.3 → 0.4.4
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/dist/Select/index.js +41 -16
- package/dist/Select/style/index.less +18 -14
- package/package.json +1 -1
package/dist/Select/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["mode", "options", "dropdownRender", "onDropdownVisibleChange", "onChange", "open", "prefix", "className", "style"];
|
|
1
|
+
var _excluded = ["mode", "options", "dropdownRender", "onDropdownVisibleChange", "onChange", "open", "prefix", "className", "popupClassName", "notFoundContent", "value", "style"];
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
|
|
@@ -31,6 +31,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
31
31
|
import { Select as AntdSelect } from 'antd';
|
|
32
32
|
import classNames from 'classnames';
|
|
33
33
|
import React, { forwardRef, useLayoutEffect, useMemo } from 'react';
|
|
34
|
+
import Empty from "../Empty";
|
|
34
35
|
import MultipleList from "./components/MultipleOption";
|
|
35
36
|
import SingleOption from "./components/SingleOption";
|
|
36
37
|
var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
@@ -42,6 +43,10 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
42
43
|
open = props.open,
|
|
43
44
|
prefix = props.prefix,
|
|
44
45
|
className = props.className,
|
|
46
|
+
popupClassName = props.popupClassName,
|
|
47
|
+
_props$notFoundConten = props.notFoundContent,
|
|
48
|
+
notFoundContent = _props$notFoundConten === void 0 ? /*#__PURE__*/React.createElement(Empty, null) : _props$notFoundConten,
|
|
49
|
+
value = props.value,
|
|
45
50
|
_props$style = props.style,
|
|
46
51
|
style = _props$style === void 0 ? {} : _props$style,
|
|
47
52
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
@@ -72,8 +77,14 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
72
77
|
var newOptions = [];
|
|
73
78
|
|
|
74
79
|
if (selected) {
|
|
80
|
+
var _props$onSelect;
|
|
81
|
+
|
|
75
82
|
newOptions = [].concat(_toConsumableArray(selectedOptions), [option]);
|
|
83
|
+
(_props$onSelect = props.onSelect) === null || _props$onSelect === void 0 ? void 0 : _props$onSelect.call(props, option.value, option);
|
|
76
84
|
} else {
|
|
85
|
+
var _props$onDeselect;
|
|
86
|
+
|
|
87
|
+
(_props$onDeselect = props.onDeselect) === null || _props$onDeselect === void 0 ? void 0 : _props$onDeselect.call(props, option.value, option);
|
|
77
88
|
newOptions = selectedOptions.filter(function (item) {
|
|
78
89
|
return item.value !== option.value;
|
|
79
90
|
});
|
|
@@ -104,14 +115,13 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
104
115
|
}));
|
|
105
116
|
};
|
|
106
117
|
|
|
107
|
-
var onSingleOptionChange = function onSingleOptionChange(option
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
118
|
+
var onSingleOptionChange = function onSingleOptionChange(option) {
|
|
119
|
+
var _props$onSelect2;
|
|
120
|
+
|
|
121
|
+
setSelectedOptions([option]);
|
|
122
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option.value, option);
|
|
123
|
+
(_props$onSelect2 = props.onSelect) === null || _props$onSelect2 === void 0 ? void 0 : _props$onSelect2.call(props, option.value, option);
|
|
124
|
+
setIsOpen(false);
|
|
115
125
|
};
|
|
116
126
|
|
|
117
127
|
var singleRender = function singleRender() {
|
|
@@ -126,18 +136,32 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
126
136
|
selected: isSelected,
|
|
127
137
|
option: option,
|
|
128
138
|
disabled: option.disabled,
|
|
129
|
-
onChange: function onChange(
|
|
130
|
-
onSingleOptionChange(option
|
|
139
|
+
onChange: function onChange() {
|
|
140
|
+
onSingleOptionChange(option);
|
|
131
141
|
}
|
|
132
142
|
});
|
|
133
143
|
}));
|
|
134
144
|
};
|
|
135
145
|
|
|
136
|
-
var
|
|
137
|
-
|
|
146
|
+
var getDropdownRender = function getDropdownRender() {
|
|
147
|
+
if (dropdownRender) {
|
|
148
|
+
return dropdownRender;
|
|
149
|
+
} else if (Array.isArray(options) && options.length > 0) {
|
|
150
|
+
if (!isMultiple) {
|
|
151
|
+
return singleRender;
|
|
152
|
+
} else {
|
|
153
|
+
return multipleRender;
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
return function () {
|
|
157
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, notFoundContent);
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}; // todo: tagRender
|
|
138
161
|
// todo: 隐藏已选择项
|
|
139
162
|
// todo: 分组
|
|
140
163
|
|
|
164
|
+
|
|
141
165
|
var currentValue = useMemo(function () {
|
|
142
166
|
if (isMultiple) {
|
|
143
167
|
return selectedOptions.map(function (option) {
|
|
@@ -153,7 +177,7 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
153
177
|
if (prefixRef.current) {
|
|
154
178
|
setPrefixWidth(prefixRef.current.offsetWidth);
|
|
155
179
|
}
|
|
156
|
-
}, [props.size]);
|
|
180
|
+
}, [props.size, prefix]);
|
|
157
181
|
var selectorStyle = style.width ? {
|
|
158
182
|
width: '100%'
|
|
159
183
|
} : {};
|
|
@@ -199,6 +223,7 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
199
223
|
maxTagCount: "responsive",
|
|
200
224
|
ref: ref,
|
|
201
225
|
tagRender: tagRender,
|
|
226
|
+
popupClassName: classNames('ald-select-popup', popupClassName),
|
|
202
227
|
maxTagPlaceholder: maxTagPlaceholder,
|
|
203
228
|
className: classNames(className, {
|
|
204
229
|
'ald-select-prefix-select': !!prefix || prefix === 0
|
|
@@ -216,8 +241,8 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
216
241
|
|
|
217
242
|
_onDropdownVisibleChange === null || _onDropdownVisibleChange === void 0 ? void 0 : _onDropdownVisibleChange(open);
|
|
218
243
|
},
|
|
219
|
-
value: currentValue,
|
|
220
|
-
dropdownRender:
|
|
244
|
+
value: value !== null && value !== void 0 ? value : currentValue,
|
|
245
|
+
dropdownRender: getDropdownRender()
|
|
221
246
|
})));
|
|
222
247
|
});
|
|
223
248
|
export default Select;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* stylelint-disable no-descending-specificity */
|
|
2
2
|
@import './variables.less';
|
|
3
|
-
|
|
3
|
+
@import '../../Empty/style/index.less';
|
|
4
4
|
@import './multiple.less';
|
|
5
5
|
@import './single.less';
|
|
6
6
|
@import './size.less';
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
.ant-select-dropdown {
|
|
10
10
|
padding-left: 0;
|
|
11
11
|
padding-right: 0;
|
|
12
|
+
|
|
13
|
+
&.ald-select-popup {
|
|
14
|
+
max-height: 264px;
|
|
15
|
+
overflow-y: auto;
|
|
16
|
+
overflow-y: overlay;
|
|
17
|
+
}
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
.ald-select {
|
|
@@ -20,7 +26,6 @@
|
|
|
20
26
|
// padding: 0 4px;
|
|
21
27
|
cursor: pointer;
|
|
22
28
|
|
|
23
|
-
|
|
24
29
|
.ald-select-prefix {
|
|
25
30
|
color: @NL40;
|
|
26
31
|
display: inline-flex;
|
|
@@ -31,7 +36,7 @@
|
|
|
31
36
|
height: 100%;
|
|
32
37
|
|
|
33
38
|
&.ald-select-prefix-single {
|
|
34
|
-
|
|
39
|
+
cursor: pointer;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
&.ald-select-prefix-multiple {
|
|
@@ -39,11 +44,12 @@
|
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
.ant-select.ald-select-prefix-select{
|
|
43
|
-
|
|
44
|
-
border:none;
|
|
47
|
+
.ant-select.ald-select-prefix-select {
|
|
48
|
+
.ant-select-selector {
|
|
49
|
+
border: none;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
52
|
+
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
.ant-select-selection-overflow {
|
|
@@ -70,13 +76,12 @@
|
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
&.ant-select-selection-overflow-item-rest{
|
|
74
|
-
.ant-select-selection-item{
|
|
75
|
-
border:none;
|
|
79
|
+
&.ant-select-selection-overflow-item-rest {
|
|
80
|
+
.ant-select-selection-item {
|
|
81
|
+
border: none;
|
|
76
82
|
background: none;
|
|
77
83
|
margin-bottom: 0;
|
|
78
84
|
}
|
|
79
|
-
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
.ald-select-multiple-tag-default {
|
|
@@ -94,11 +99,10 @@
|
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
101
|
|
|
97
|
-
.ant-select-selection-overflow-item-rest{
|
|
98
|
-
.ant-select-selection-item{
|
|
102
|
+
.ant-select-selection-overflow-item-rest {
|
|
103
|
+
.ant-select-selection-item {
|
|
99
104
|
padding-inline-start: 0;
|
|
100
105
|
}
|
|
101
|
-
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
.ant-select-selection-overflow-item:first-of-type {
|
|
@@ -106,4 +110,4 @@
|
|
|
106
110
|
content: '';
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
|
-
}
|
|
113
|
+
}
|