@aloudata/aloudata-design 0.4.4 → 0.4.7
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
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", "popupClassName", "notFoundContent", "value", "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,17 +30,63 @@ 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
34
|
import Empty from "../Empty";
|
|
35
35
|
import MultipleList from "./components/MultipleOption";
|
|
36
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
|
+
|
|
37
81
|
var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
38
82
|
var mode = props.mode,
|
|
39
83
|
options = props.options,
|
|
40
84
|
dropdownRender = props.dropdownRender,
|
|
41
85
|
_onDropdownVisibleChange = props.onDropdownVisibleChange,
|
|
86
|
+
defaultValue = props.defaultValue,
|
|
42
87
|
onChange = props.onChange,
|
|
43
88
|
open = props.open,
|
|
89
|
+
defaultOpen = props.defaultOpen,
|
|
44
90
|
prefix = props.prefix,
|
|
45
91
|
className = props.className,
|
|
46
92
|
popupClassName = props.popupClassName,
|
|
@@ -53,15 +99,14 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
53
99
|
|
|
54
100
|
var isMultiple = mode === 'multiple';
|
|
55
101
|
|
|
56
|
-
var _React$useState = React.useState(
|
|
102
|
+
var _React$useState = React.useState(getSelectedOptionsFromValue(isMultiple, options, value, defaultValue)),
|
|
57
103
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
58
104
|
selectedOptions = _React$useState2[0],
|
|
59
105
|
setSelectedOptions = _React$useState2[1];
|
|
60
106
|
|
|
61
|
-
style.width = style.width || '100%';
|
|
62
107
|
var dropDownTimeRef = React.useRef(0);
|
|
63
108
|
|
|
64
|
-
var _React$useState3 = React.useState(open),
|
|
109
|
+
var _React$useState3 = React.useState(typeof open === 'boolean' ? open : defaultOpen),
|
|
65
110
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
66
111
|
isOpen = _React$useState4[0],
|
|
67
112
|
setIsOpen = _React$useState4[1];
|
|
@@ -109,7 +154,9 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
109
154
|
option: option,
|
|
110
155
|
disabled: option.disabled,
|
|
111
156
|
onChange: function onChange(selected) {
|
|
112
|
-
|
|
157
|
+
if (typeof value === 'undefined') {
|
|
158
|
+
onMultipleOptionChange(option, selected);
|
|
159
|
+
}
|
|
113
160
|
}
|
|
114
161
|
});
|
|
115
162
|
}));
|
|
@@ -137,7 +184,9 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
137
184
|
option: option,
|
|
138
185
|
disabled: option.disabled,
|
|
139
186
|
onChange: function onChange() {
|
|
140
|
-
|
|
187
|
+
if (typeof value === 'undefined') {
|
|
188
|
+
onSingleOptionChange(option);
|
|
189
|
+
}
|
|
141
190
|
}
|
|
142
191
|
});
|
|
143
192
|
}));
|
|
@@ -178,9 +227,6 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
178
227
|
setPrefixWidth(prefixRef.current.offsetWidth);
|
|
179
228
|
}
|
|
180
229
|
}, [props.size, prefix]);
|
|
181
|
-
var selectorStyle = style.width ? {
|
|
182
|
-
width: '100%'
|
|
183
|
-
} : {};
|
|
184
230
|
var styleVar = {
|
|
185
231
|
'--ald-select-prefix-width': "".concat(prefixWidth, "px")
|
|
186
232
|
};
|
|
@@ -196,8 +242,11 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
196
242
|
return /*#__PURE__*/React.createElement(React.Fragment, null, "\u7B49", omittedValues.length, "\u9879");
|
|
197
243
|
};
|
|
198
244
|
|
|
245
|
+
useEffect(function () {
|
|
246
|
+
getSelectedOptionsFromValue(isMultiple, options, value);
|
|
247
|
+
}, [value]);
|
|
199
248
|
return /*#__PURE__*/React.createElement("div", {
|
|
200
|
-
className: classNames('ald-select', {
|
|
249
|
+
className: classNames('ald-select', className, {
|
|
201
250
|
'ald-select-multiple': isMultiple,
|
|
202
251
|
'ald-select-single': !isMultiple,
|
|
203
252
|
'ald-select-large': props.size === 'large',
|
|
@@ -219,19 +268,21 @@ var Select = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
219
268
|
options: options,
|
|
220
269
|
mode: isMultiple ? 'multiple' : undefined,
|
|
221
270
|
bordered: false,
|
|
222
|
-
open: isOpen,
|
|
271
|
+
open: typeof open === 'boolean' ? open : isOpen,
|
|
223
272
|
maxTagCount: "responsive",
|
|
224
273
|
ref: ref,
|
|
225
274
|
tagRender: tagRender,
|
|
226
275
|
popupClassName: classNames('ald-select-popup', popupClassName),
|
|
227
276
|
maxTagPlaceholder: maxTagPlaceholder,
|
|
228
|
-
className: classNames(
|
|
277
|
+
className: classNames({
|
|
229
278
|
'ald-select-prefix-select': !!prefix || prefix === 0
|
|
230
279
|
}),
|
|
231
280
|
dropdownStyle: {
|
|
232
281
|
width: '100%'
|
|
233
282
|
},
|
|
234
|
-
style:
|
|
283
|
+
style: {
|
|
284
|
+
width: '100%'
|
|
285
|
+
},
|
|
235
286
|
onDropdownVisibleChange: function onDropdownVisibleChange(open) {
|
|
236
287
|
setIsOpen(open);
|
|
237
288
|
|