@aloudata/aloudata-design 0.4.3 → 0.4.6
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/Modal/index.d.ts +1 -1
- package/dist/Modal/index.js +2 -1
- package/dist/Modal/style/index.less +8 -7
- package/dist/Select/index.d.ts +1 -1
- package/dist/Select/index.js +104 -28
- package/dist/Select/style/index.less +19 -14
- package/package.json +1 -1
package/dist/Modal/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ interface IModalInterface extends React.FC<ModalProps> {
|
|
|
11
11
|
export interface ModalProps extends Omit<AntdModalProps, 'okButtonProps' | 'cancelButtonProps' | 'okType'> {
|
|
12
12
|
forbidBodyScroll?: boolean;
|
|
13
13
|
children?: React.ReactNode;
|
|
14
|
-
subTitle?:
|
|
14
|
+
subTitle?: React.ReactNode;
|
|
15
15
|
icon?: React.ReactElement;
|
|
16
16
|
cancelButtonProps?: IButtonProps;
|
|
17
17
|
okButtonProps?: IButtonProps;
|
package/dist/Modal/index.js
CHANGED
|
@@ -41,7 +41,8 @@ function getButtonProps(buttonProps, defaultBtnType, okType) {
|
|
|
41
41
|
_buttonProps$shape = buttonProps.shape,
|
|
42
42
|
shape = _buttonProps$shape === void 0 ? 'default' : _buttonProps$shape;
|
|
43
43
|
return {
|
|
44
|
-
|
|
44
|
+
disabled: loading ? true : disabled,
|
|
45
|
+
loading: loading,
|
|
45
46
|
type: getButtonType(type),
|
|
46
47
|
className: classNames(btnPrefix, "".concat(btnPrefix, "-").concat(type), buttonClassName, getButtonSizeClass(size)),
|
|
47
48
|
danger: getDangerStatus(type),
|
|
@@ -10,31 +10,32 @@
|
|
|
10
10
|
|
|
11
11
|
.ald-modal-close {
|
|
12
12
|
position: relative;
|
|
13
|
-
top: 5px;
|
|
14
|
-
left: -4px;
|
|
13
|
+
// top: 5px;
|
|
14
|
+
// left: -4px;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.ald-modal-title-container {
|
|
18
|
-
display:
|
|
18
|
+
display: flex;
|
|
19
19
|
align-items: center;
|
|
20
20
|
|
|
21
21
|
.ald-modal-text-container {
|
|
22
22
|
margin-left: 12px;
|
|
23
|
+
flex: 1;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
.title {
|
|
26
27
|
color: @NL0;
|
|
27
28
|
font-weight: 600;
|
|
28
|
-
font-size:
|
|
29
|
-
line-height:
|
|
29
|
+
font-size: 16px;
|
|
30
|
+
line-height: 24px;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
.subTitle {
|
|
33
34
|
margin-top: 4px;
|
|
34
35
|
color: @NL40;
|
|
35
36
|
font-weight: 400;
|
|
36
|
-
font-size:
|
|
37
|
-
line-height:
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
line-height: 16px;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
package/dist/Select/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefSelectProps, SelectProps } from 'antd';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export interface ISelectProps extends Omit<SelectProps, '
|
|
3
|
+
export interface ISelectProps extends Omit<SelectProps, 'mode'> {
|
|
4
4
|
prefix?: React.ReactNode;
|
|
5
5
|
mode?: 'multiple';
|
|
6
6
|
}
|
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", "defaultValue", "onChange", "open", "defaultOpen", "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
|
|
|
@@ -30,33 +30,83 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
30
30
|
|
|
31
31
|
import { Select as AntdSelect } from 'antd';
|
|
32
32
|
import classNames from 'classnames';
|
|
33
|
-
import React, { forwardRef, useLayoutEffect, useMemo } from 'react';
|
|
33
|
+
import React, { forwardRef, useEffect, useLayoutEffect, useMemo } from 'react';
|
|
34
|
+
import Empty from "../Empty";
|
|
34
35
|
import MultipleList from "./components/MultipleOption";
|
|
35
36
|
import SingleOption from "./components/SingleOption";
|
|
37
|
+
|
|
38
|
+
var getSelectedOptionsFromValue = function getSelectedOptionsFromValue(isMultiple, options, value, defaultValue) {
|
|
39
|
+
if (typeof value !== 'undefined') {
|
|
40
|
+
if (isMultiple) {
|
|
41
|
+
if (Array.isArray(value)) {
|
|
42
|
+
var newOptions = options === null || options === void 0 ? void 0 : options.filter(function (option) {
|
|
43
|
+
return value.includes(option.value);
|
|
44
|
+
});
|
|
45
|
+
return newOptions || [];
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
var _newOptions = options === null || options === void 0 ? void 0 : options.filter(function (option) {
|
|
49
|
+
return option.value === value;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return _newOptions || [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (typeof defaultValue !== 'undefined') {
|
|
59
|
+
if (isMultiple) {
|
|
60
|
+
if (Array.isArray(defaultValue)) {
|
|
61
|
+
var _newOptions2 = options === null || options === void 0 ? void 0 : options.filter(function (option) {
|
|
62
|
+
return defaultValue.includes(option.value);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return _newOptions2 || [];
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
var _newOptions3 = options === null || options === void 0 ? void 0 : options.filter(function (option) {
|
|
69
|
+
return option.value === defaultValue;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return _newOptions3 || [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return [];
|
|
79
|
+
};
|
|
80
|
+
|
|
36
81
|
var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
37
82
|
var mode = props.mode,
|
|
38
83
|
options = props.options,
|
|
39
84
|
dropdownRender = props.dropdownRender,
|
|
40
85
|
_onDropdownVisibleChange = props.onDropdownVisibleChange,
|
|
86
|
+
defaultValue = props.defaultValue,
|
|
41
87
|
onChange = props.onChange,
|
|
42
88
|
open = props.open,
|
|
89
|
+
defaultOpen = props.defaultOpen,
|
|
43
90
|
prefix = props.prefix,
|
|
44
91
|
className = props.className,
|
|
92
|
+
popupClassName = props.popupClassName,
|
|
93
|
+
_props$notFoundConten = props.notFoundContent,
|
|
94
|
+
notFoundContent = _props$notFoundConten === void 0 ? /*#__PURE__*/React.createElement(Empty, null) : _props$notFoundConten,
|
|
95
|
+
value = props.value,
|
|
45
96
|
_props$style = props.style,
|
|
46
97
|
style = _props$style === void 0 ? {} : _props$style,
|
|
47
98
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
48
99
|
|
|
49
100
|
var isMultiple = mode === 'multiple';
|
|
50
101
|
|
|
51
|
-
var _React$useState = React.useState(
|
|
102
|
+
var _React$useState = React.useState(getSelectedOptionsFromValue(isMultiple, options, value, defaultValue)),
|
|
52
103
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
53
104
|
selectedOptions = _React$useState2[0],
|
|
54
105
|
setSelectedOptions = _React$useState2[1];
|
|
55
106
|
|
|
56
|
-
style.width = style.width || '100%';
|
|
57
107
|
var dropDownTimeRef = React.useRef(0);
|
|
58
108
|
|
|
59
|
-
var _React$useState3 = React.useState(open),
|
|
109
|
+
var _React$useState3 = React.useState(typeof open === 'boolean' ? open : defaultOpen),
|
|
60
110
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
61
111
|
isOpen = _React$useState4[0],
|
|
62
112
|
setIsOpen = _React$useState4[1];
|
|
@@ -72,8 +122,14 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
72
122
|
var newOptions = [];
|
|
73
123
|
|
|
74
124
|
if (selected) {
|
|
125
|
+
var _props$onSelect;
|
|
126
|
+
|
|
75
127
|
newOptions = [].concat(_toConsumableArray(selectedOptions), [option]);
|
|
128
|
+
(_props$onSelect = props.onSelect) === null || _props$onSelect === void 0 ? void 0 : _props$onSelect.call(props, option.value, option);
|
|
76
129
|
} else {
|
|
130
|
+
var _props$onDeselect;
|
|
131
|
+
|
|
132
|
+
(_props$onDeselect = props.onDeselect) === null || _props$onDeselect === void 0 ? void 0 : _props$onDeselect.call(props, option.value, option);
|
|
77
133
|
newOptions = selectedOptions.filter(function (item) {
|
|
78
134
|
return item.value !== option.value;
|
|
79
135
|
});
|
|
@@ -98,20 +154,21 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
98
154
|
option: option,
|
|
99
155
|
disabled: option.disabled,
|
|
100
156
|
onChange: function onChange(selected) {
|
|
101
|
-
|
|
157
|
+
if (typeof value === 'undefined') {
|
|
158
|
+
onMultipleOptionChange(option, selected);
|
|
159
|
+
}
|
|
102
160
|
}
|
|
103
161
|
});
|
|
104
162
|
}));
|
|
105
163
|
};
|
|
106
164
|
|
|
107
|
-
var onSingleOptionChange = function onSingleOptionChange(option
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
165
|
+
var onSingleOptionChange = function onSingleOptionChange(option) {
|
|
166
|
+
var _props$onSelect2;
|
|
167
|
+
|
|
168
|
+
setSelectedOptions([option]);
|
|
169
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(option.value, option);
|
|
170
|
+
(_props$onSelect2 = props.onSelect) === null || _props$onSelect2 === void 0 ? void 0 : _props$onSelect2.call(props, option.value, option);
|
|
171
|
+
setIsOpen(false);
|
|
115
172
|
};
|
|
116
173
|
|
|
117
174
|
var singleRender = function singleRender() {
|
|
@@ -126,18 +183,34 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
126
183
|
selected: isSelected,
|
|
127
184
|
option: option,
|
|
128
185
|
disabled: option.disabled,
|
|
129
|
-
onChange: function onChange(
|
|
130
|
-
|
|
186
|
+
onChange: function onChange() {
|
|
187
|
+
if (typeof value === 'undefined') {
|
|
188
|
+
onSingleOptionChange(option);
|
|
189
|
+
}
|
|
131
190
|
}
|
|
132
191
|
});
|
|
133
192
|
}));
|
|
134
193
|
};
|
|
135
194
|
|
|
136
|
-
var
|
|
137
|
-
|
|
195
|
+
var getDropdownRender = function getDropdownRender() {
|
|
196
|
+
if (dropdownRender) {
|
|
197
|
+
return dropdownRender;
|
|
198
|
+
} else if (Array.isArray(options) && options.length > 0) {
|
|
199
|
+
if (!isMultiple) {
|
|
200
|
+
return singleRender;
|
|
201
|
+
} else {
|
|
202
|
+
return multipleRender;
|
|
203
|
+
}
|
|
204
|
+
} else {
|
|
205
|
+
return function () {
|
|
206
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, notFoundContent);
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}; // todo: tagRender
|
|
138
210
|
// todo: 隐藏已选择项
|
|
139
211
|
// todo: 分组
|
|
140
212
|
|
|
213
|
+
|
|
141
214
|
var currentValue = useMemo(function () {
|
|
142
215
|
if (isMultiple) {
|
|
143
216
|
return selectedOptions.map(function (option) {
|
|
@@ -153,10 +226,7 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
153
226
|
if (prefixRef.current) {
|
|
154
227
|
setPrefixWidth(prefixRef.current.offsetWidth);
|
|
155
228
|
}
|
|
156
|
-
}, [props.size]);
|
|
157
|
-
var selectorStyle = style.width ? {
|
|
158
|
-
width: '100%'
|
|
159
|
-
} : {};
|
|
229
|
+
}, [props.size, prefix]);
|
|
160
230
|
var styleVar = {
|
|
161
231
|
'--ald-select-prefix-width': "".concat(prefixWidth, "px")
|
|
162
232
|
};
|
|
@@ -172,8 +242,11 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
172
242
|
return /*#__PURE__*/React.createElement(React.Fragment, null, "\u7B49", omittedValues.length, "\u9879");
|
|
173
243
|
};
|
|
174
244
|
|
|
245
|
+
useEffect(function () {
|
|
246
|
+
getSelectedOptionsFromValue(isMultiple, options, value);
|
|
247
|
+
}, [value]);
|
|
175
248
|
return /*#__PURE__*/React.createElement("div", {
|
|
176
|
-
className: classNames('ald-select', {
|
|
249
|
+
className: classNames('ald-select', className, {
|
|
177
250
|
'ald-select-multiple': isMultiple,
|
|
178
251
|
'ald-select-single': !isMultiple,
|
|
179
252
|
'ald-select-large': props.size === 'large',
|
|
@@ -195,18 +268,21 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
195
268
|
options: options,
|
|
196
269
|
mode: isMultiple ? 'multiple' : undefined,
|
|
197
270
|
bordered: false,
|
|
198
|
-
open: isOpen,
|
|
271
|
+
open: typeof open === 'boolean' ? open : isOpen,
|
|
199
272
|
maxTagCount: "responsive",
|
|
200
273
|
ref: ref,
|
|
201
274
|
tagRender: tagRender,
|
|
275
|
+
popupClassName: classNames('ald-select-popup', popupClassName),
|
|
202
276
|
maxTagPlaceholder: maxTagPlaceholder,
|
|
203
|
-
className: classNames(
|
|
277
|
+
className: classNames({
|
|
204
278
|
'ald-select-prefix-select': !!prefix || prefix === 0
|
|
205
279
|
}),
|
|
206
280
|
dropdownStyle: {
|
|
207
281
|
width: '100%'
|
|
208
282
|
},
|
|
209
|
-
style:
|
|
283
|
+
style: {
|
|
284
|
+
width: '100%'
|
|
285
|
+
},
|
|
210
286
|
onDropdownVisibleChange: function onDropdownVisibleChange(open) {
|
|
211
287
|
setIsOpen(open);
|
|
212
288
|
|
|
@@ -216,8 +292,8 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
216
292
|
|
|
217
293
|
_onDropdownVisibleChange === null || _onDropdownVisibleChange === void 0 ? void 0 : _onDropdownVisibleChange(open);
|
|
218
294
|
},
|
|
219
|
-
value: currentValue,
|
|
220
|
-
dropdownRender:
|
|
295
|
+
value: value !== null && value !== void 0 ? value : currentValue,
|
|
296
|
+
dropdownRender: getDropdownRender()
|
|
221
297
|
})));
|
|
222
298
|
});
|
|
223
299
|
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 {
|
|
@@ -19,7 +25,7 @@
|
|
|
19
25
|
border-radius: 4px;
|
|
20
26
|
// padding: 0 4px;
|
|
21
27
|
cursor: pointer;
|
|
22
|
-
|
|
28
|
+
width:100%;
|
|
23
29
|
|
|
24
30
|
.ald-select-prefix {
|
|
25
31
|
color: @NL40;
|
|
@@ -31,7 +37,7 @@
|
|
|
31
37
|
height: 100%;
|
|
32
38
|
|
|
33
39
|
&.ald-select-prefix-single {
|
|
34
|
-
|
|
40
|
+
cursor: pointer;
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
&.ald-select-prefix-multiple {
|
|
@@ -39,11 +45,12 @@
|
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
.ant-select.ald-select-prefix-select{
|
|
43
|
-
|
|
44
|
-
border:none;
|
|
48
|
+
.ant-select.ald-select-prefix-select {
|
|
49
|
+
.ant-select-selector {
|
|
50
|
+
border: none;
|
|
45
51
|
}
|
|
46
52
|
}
|
|
53
|
+
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
.ant-select-selection-overflow {
|
|
@@ -70,13 +77,12 @@
|
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
&.ant-select-selection-overflow-item-rest{
|
|
74
|
-
.ant-select-selection-item{
|
|
75
|
-
border:none;
|
|
80
|
+
&.ant-select-selection-overflow-item-rest {
|
|
81
|
+
.ant-select-selection-item {
|
|
82
|
+
border: none;
|
|
76
83
|
background: none;
|
|
77
84
|
margin-bottom: 0;
|
|
78
85
|
}
|
|
79
|
-
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
.ald-select-multiple-tag-default {
|
|
@@ -94,11 +100,10 @@
|
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
.ant-select-selection-overflow-item-rest{
|
|
98
|
-
.ant-select-selection-item{
|
|
103
|
+
.ant-select-selection-overflow-item-rest {
|
|
104
|
+
.ant-select-selection-item {
|
|
99
105
|
padding-inline-start: 0;
|
|
100
106
|
}
|
|
101
|
-
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
.ant-select-selection-overflow-item:first-of-type {
|
|
@@ -106,4 +111,4 @@
|
|
|
106
111
|
content: '';
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
|
-
}
|
|
114
|
+
}
|