assui 3.1.40 → 3.1.42
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/es/condition-select-input/index.d.ts +1 -0
- package/es/condition-select-input/index.js +54 -7
- package/es/label-condition-select-input/index.d.ts +1 -0
- package/es/label-condition-select-input/index.js +55 -7
- package/lib/condition-select-input/index.d.ts +1 -0
- package/lib/condition-select-input/index.js +54 -7
- package/lib/label-condition-select-input/index.d.ts +1 -0
- package/lib/label-condition-select-input/index.js +55 -7
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ export interface MainSelectOptionsType extends SelectOptionsType {
|
|
|
14
14
|
export interface ValueType {
|
|
15
15
|
selectValue?: number | string | null;
|
|
16
16
|
inputValue?: SelectProps['value'] | ConditionInputProps['value'];
|
|
17
|
+
finalSelectValue?: SelectProps['value'] | ConditionInputProps['value'][];
|
|
17
18
|
}
|
|
18
19
|
export interface ConditionSelectInputProps {
|
|
19
20
|
value?: ValueType;
|
|
@@ -35,6 +35,7 @@ var __read = this && this.__read || function (o, n) {
|
|
|
35
35
|
return ar;
|
|
36
36
|
};
|
|
37
37
|
import isNil from 'lodash/isNil';
|
|
38
|
+
import isEmpty from 'lodash/isEmpty';
|
|
38
39
|
import classNames from 'classnames';
|
|
39
40
|
import Select from "antd/es/select";
|
|
40
41
|
import React, { useEffect, useState } from 'react';
|
|
@@ -45,6 +46,15 @@ export var InputTypeEnum;
|
|
|
45
46
|
InputTypeEnum["CONDITION_INPUT"] = "conditionInput";
|
|
46
47
|
InputTypeEnum["SELECT"] = "select";
|
|
47
48
|
})(InputTypeEnum || (InputTypeEnum = {}));
|
|
49
|
+
/** 找所有的子代选项 */
|
|
50
|
+
var findAllSubSelectItems = function findAllSubSelectItems(dataSource, key) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return (_b = (_a = dataSource.find(function (item) {
|
|
53
|
+
return item.value === key;
|
|
54
|
+
})) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.map(function (subItem) {
|
|
55
|
+
return subItem.value;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
48
58
|
var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
49
59
|
var value = props.value,
|
|
50
60
|
_a = props.hiddenInputKeys,
|
|
@@ -64,8 +74,10 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
64
74
|
var _e = __read(useState([]), 2),
|
|
65
75
|
subSelectOptions = _e[0],
|
|
66
76
|
setSubSelectOptions = _e[1];
|
|
77
|
+
/** 子选择器是否多选 */
|
|
78
|
+
var isSubSelectMultiple = (conditionSelectProps === null || conditionSelectProps === void 0 ? void 0 : conditionSelectProps.mode) === 'multiple';
|
|
67
79
|
useEffect(function () {
|
|
68
|
-
if (value && value.selectValue && optionsList.length) {
|
|
80
|
+
if (value && !isNil(value.selectValue) && optionsList.length) {
|
|
69
81
|
var _a = __read(optionsList.filter(function (item) {
|
|
70
82
|
return item.value === value.selectValue;
|
|
71
83
|
}), 1),
|
|
@@ -77,10 +89,16 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
77
89
|
}, [value, optionsList]);
|
|
78
90
|
var onSelectChange = function onSelectChange(selectValue) {
|
|
79
91
|
var inputValue = isInput ? '' : undefined;
|
|
80
|
-
|
|
92
|
+
var finalSelectInputValue = {
|
|
81
93
|
selectValue: selectValue,
|
|
82
94
|
inputValue: inputValue
|
|
83
|
-
}
|
|
95
|
+
};
|
|
96
|
+
if (isSubSelectMultiple) {
|
|
97
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
98
|
+
finalSelectValue: !isNil(selectValue) ? findAllSubSelectItems(optionsList, selectValue) : undefined
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
setSelectInputValue(finalSelectInputValue);
|
|
84
102
|
if (isInput || isNil(selectValue)) {
|
|
85
103
|
setSubSelectOptions([]);
|
|
86
104
|
return;
|
|
@@ -100,14 +118,41 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
100
118
|
});
|
|
101
119
|
};
|
|
102
120
|
var onTypeSelectChange = function onTypeSelectChange(inputValue) {
|
|
103
|
-
|
|
121
|
+
var finalSelectInputValue = {
|
|
104
122
|
selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
105
123
|
inputValue: inputValue
|
|
106
|
-
}
|
|
124
|
+
};
|
|
125
|
+
if (isSubSelectMultiple) {
|
|
126
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
127
|
+
finalSelectValue: isEmpty(inputValue) ? findAllSubSelectItems(optionsList, selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) : inputValue
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
setSelectInputValue(finalSelectInputValue);
|
|
107
131
|
};
|
|
108
132
|
var onConditionSelectInputBlur = function onConditionSelectInputBlur() {
|
|
109
133
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(selectInputValue);
|
|
110
134
|
};
|
|
135
|
+
/** 二级下拉框清空 */
|
|
136
|
+
var onTypeSelectClear = function onTypeSelectClear() {
|
|
137
|
+
var finalSelectInputValue = {
|
|
138
|
+
selectValue: selectInputValue.selectValue,
|
|
139
|
+
inputValue: []
|
|
140
|
+
};
|
|
141
|
+
if (isSubSelectMultiple) {
|
|
142
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
143
|
+
finalSelectValue: findAllSubSelectItems(optionsList, selectInputValue.selectValue)
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(finalSelectInputValue);
|
|
147
|
+
};
|
|
148
|
+
/** 一级下拉框清空 */
|
|
149
|
+
var onSelectClear = function onSelectClear() {
|
|
150
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
151
|
+
selectValue: undefined,
|
|
152
|
+
inputValue: undefined,
|
|
153
|
+
finalSelectValue: undefined
|
|
154
|
+
});
|
|
155
|
+
};
|
|
111
156
|
// 是否展示输入框
|
|
112
157
|
var isShowInput = !isNil(selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) && !(hiddenInputKeys === null || hiddenInputKeys === void 0 ? void 0 : hiddenInputKeys.includes(selectInputValue.selectValue));
|
|
113
158
|
var typeInput = isInput ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -122,7 +167,8 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
122
167
|
onChange: onTypeSelectChange,
|
|
123
168
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
|
|
124
169
|
options: subSelectOptions,
|
|
125
|
-
onBlur: onConditionSelectInputBlur
|
|
170
|
+
onBlur: onConditionSelectInputBlur,
|
|
171
|
+
onClear: onTypeSelectClear
|
|
126
172
|
})));
|
|
127
173
|
return /*#__PURE__*/React.createElement("div", {
|
|
128
174
|
className: "condition-select-wrap"
|
|
@@ -135,7 +181,8 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
135
181
|
onChange: onSelectChange,
|
|
136
182
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
137
183
|
options: optionsList,
|
|
138
|
-
onBlur: onConditionSelectInputBlur
|
|
184
|
+
onBlur: onConditionSelectInputBlur,
|
|
185
|
+
onClear: onSelectClear
|
|
139
186
|
}))), isShowInput && typeInput);
|
|
140
187
|
};
|
|
141
188
|
export default ConditionSelectInput;
|
|
@@ -15,6 +15,7 @@ export interface MainSelectOptionsType extends SelectOptionsType {
|
|
|
15
15
|
export interface ValueType {
|
|
16
16
|
selectValue?: number | string | null;
|
|
17
17
|
inputValue?: LabelSelectProps['value'] | LabelConditionInputProps['value'];
|
|
18
|
+
finalSelectValue?: LabelSelectProps['value'] | LabelConditionInputProps['value'][];
|
|
18
19
|
}
|
|
19
20
|
export interface LabelConditionSelectInputProps {
|
|
20
21
|
value?: ValueType;
|
|
@@ -35,6 +35,7 @@ var __read = this && this.__read || function (o, n) {
|
|
|
35
35
|
return ar;
|
|
36
36
|
};
|
|
37
37
|
import isNil from 'lodash/isNil';
|
|
38
|
+
import isEmpty from 'lodash/isEmpty';
|
|
38
39
|
import classNames from 'classnames';
|
|
39
40
|
import React, { useEffect, useState } from 'react';
|
|
40
41
|
import useControllableValue from "ahooks/es/useControllableValue";
|
|
@@ -45,6 +46,15 @@ export var InputTypeEnum;
|
|
|
45
46
|
InputTypeEnum["CONDITION_INPUT"] = "conditionInput";
|
|
46
47
|
InputTypeEnum["SELECT"] = "select";
|
|
47
48
|
})(InputTypeEnum || (InputTypeEnum = {}));
|
|
49
|
+
/** 找所有的子代选项 */
|
|
50
|
+
var findAllSubSelectItems = function findAllSubSelectItems(dataSource, key) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return (_b = (_a = dataSource.find(function (item) {
|
|
53
|
+
return item.value === key;
|
|
54
|
+
})) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.map(function (subItem) {
|
|
55
|
+
return subItem.value;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
48
58
|
var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
49
59
|
var value = props.value,
|
|
50
60
|
_a = props.hiddenInputKeys,
|
|
@@ -66,8 +76,10 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
66
76
|
var _e = __read(useState([]), 2),
|
|
67
77
|
subSelectOptions = _e[0],
|
|
68
78
|
setSubSelectOptions = _e[1];
|
|
79
|
+
/** 子选择器是否多选 */
|
|
80
|
+
var isSubSelectMultiple = (conditionSelectProps === null || conditionSelectProps === void 0 ? void 0 : conditionSelectProps.mode) === 'multiple';
|
|
69
81
|
useEffect(function () {
|
|
70
|
-
if (value && value.selectValue && optionsList.length) {
|
|
82
|
+
if (value && !isNil(value.selectValue) && optionsList.length) {
|
|
71
83
|
var _a = __read(optionsList.filter(function (item) {
|
|
72
84
|
return item.value === value.selectValue;
|
|
73
85
|
}), 1),
|
|
@@ -79,10 +91,16 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
79
91
|
}, [value, optionsList]);
|
|
80
92
|
var onSelectChange = function onSelectChange(selectValue) {
|
|
81
93
|
var inputValue = isInput ? '' : undefined;
|
|
82
|
-
|
|
94
|
+
var finalSelectInputValue = {
|
|
83
95
|
selectValue: selectValue,
|
|
84
96
|
inputValue: inputValue
|
|
85
|
-
}
|
|
97
|
+
};
|
|
98
|
+
if (isSubSelectMultiple) {
|
|
99
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
100
|
+
finalSelectValue: !isNil(selectValue) ? findAllSubSelectItems(optionsList, selectValue) : undefined
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
setSelectInputValue(finalSelectInputValue);
|
|
86
104
|
if (isInput || isNil(selectValue)) {
|
|
87
105
|
setSubSelectOptions([]);
|
|
88
106
|
return;
|
|
@@ -102,14 +120,42 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
102
120
|
});
|
|
103
121
|
};
|
|
104
122
|
var onTypeSelectChange = function onTypeSelectChange(inputValue) {
|
|
105
|
-
|
|
123
|
+
var finalSelectInputValue = {
|
|
106
124
|
selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
107
125
|
inputValue: inputValue
|
|
108
|
-
}
|
|
126
|
+
};
|
|
127
|
+
if (isSubSelectMultiple) {
|
|
128
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
129
|
+
finalSelectValue: isEmpty(inputValue) ? findAllSubSelectItems(optionsList, selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) : inputValue
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
setSelectInputValue(finalSelectInputValue);
|
|
109
133
|
};
|
|
134
|
+
/** 联级选择框失去焦点 */
|
|
110
135
|
var onLabelConditionSelectInputBlur = function onLabelConditionSelectInputBlur() {
|
|
111
136
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(selectInputValue);
|
|
112
137
|
};
|
|
138
|
+
/** 二级下拉框清空 */
|
|
139
|
+
var onTypeSelectClear = function onTypeSelectClear() {
|
|
140
|
+
var finalSelectInputValue = {
|
|
141
|
+
selectValue: selectInputValue.selectValue,
|
|
142
|
+
inputValue: []
|
|
143
|
+
};
|
|
144
|
+
if (isSubSelectMultiple) {
|
|
145
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
146
|
+
finalSelectValue: findAllSubSelectItems(optionsList, selectInputValue.selectValue)
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(finalSelectInputValue);
|
|
150
|
+
};
|
|
151
|
+
/** 一级下拉框清空 */
|
|
152
|
+
var onSelectClear = function onSelectClear() {
|
|
153
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
154
|
+
selectValue: undefined,
|
|
155
|
+
inputValue: undefined,
|
|
156
|
+
finalSelectValue: undefined
|
|
157
|
+
});
|
|
158
|
+
};
|
|
113
159
|
// 是否展示输入框
|
|
114
160
|
var isShowInput = !isNil(selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) && !(hiddenInputKeys === null || hiddenInputKeys === void 0 ? void 0 : hiddenInputKeys.includes(selectInputValue.selectValue));
|
|
115
161
|
var typeInput = isInput ? /*#__PURE__*/React.createElement(LabelConditionInput, __assign({}, conditionInputProps, {
|
|
@@ -123,7 +169,8 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
123
169
|
onChange: onTypeSelectChange,
|
|
124
170
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
|
|
125
171
|
options: subSelectOptions,
|
|
126
|
-
onBlur: onLabelConditionSelectInputBlur
|
|
172
|
+
onBlur: onLabelConditionSelectInputBlur,
|
|
173
|
+
onClear: onTypeSelectClear
|
|
127
174
|
})));
|
|
128
175
|
return /*#__PURE__*/React.createElement("div", {
|
|
129
176
|
className: classNames('label-condition-select', className)
|
|
@@ -138,7 +185,8 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
138
185
|
onChange: onSelectChange,
|
|
139
186
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
140
187
|
options: optionsList,
|
|
141
|
-
onBlur: onLabelConditionSelectInputBlur
|
|
188
|
+
onBlur: onLabelConditionSelectInputBlur,
|
|
189
|
+
onClear: onSelectClear
|
|
142
190
|
}))), isShowInput && typeInput);
|
|
143
191
|
};
|
|
144
192
|
export default LabelConditionSelect;
|
|
@@ -14,6 +14,7 @@ export interface MainSelectOptionsType extends SelectOptionsType {
|
|
|
14
14
|
export interface ValueType {
|
|
15
15
|
selectValue?: number | string | null;
|
|
16
16
|
inputValue?: SelectProps['value'] | ConditionInputProps['value'];
|
|
17
|
+
finalSelectValue?: SelectProps['value'] | ConditionInputProps['value'][];
|
|
17
18
|
}
|
|
18
19
|
export interface ConditionSelectInputProps {
|
|
19
20
|
value?: ValueType;
|
|
@@ -79,6 +79,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
79
79
|
});
|
|
80
80
|
exports.InputTypeEnum = void 0;
|
|
81
81
|
var isNil_1 = __importDefault(require("lodash/isNil"));
|
|
82
|
+
var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
82
83
|
var classnames_1 = __importDefault(require("classnames"));
|
|
83
84
|
var select_1 = __importDefault(require("antd/lib/select"));
|
|
84
85
|
var react_1 = __importStar(require("react"));
|
|
@@ -89,6 +90,15 @@ var InputTypeEnum;
|
|
|
89
90
|
InputTypeEnum["CONDITION_INPUT"] = "conditionInput";
|
|
90
91
|
InputTypeEnum["SELECT"] = "select";
|
|
91
92
|
})(InputTypeEnum = exports.InputTypeEnum || (exports.InputTypeEnum = {}));
|
|
93
|
+
/** 找所有的子代选项 */
|
|
94
|
+
var findAllSubSelectItems = function findAllSubSelectItems(dataSource, key) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
return (_b = (_a = dataSource.find(function (item) {
|
|
97
|
+
return item.value === key;
|
|
98
|
+
})) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.map(function (subItem) {
|
|
99
|
+
return subItem.value;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
92
102
|
var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
93
103
|
var value = props.value,
|
|
94
104
|
_a = props.hiddenInputKeys,
|
|
@@ -108,8 +118,10 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
108
118
|
var _e = __read((0, react_1.useState)([]), 2),
|
|
109
119
|
subSelectOptions = _e[0],
|
|
110
120
|
setSubSelectOptions = _e[1];
|
|
121
|
+
/** 子选择器是否多选 */
|
|
122
|
+
var isSubSelectMultiple = (conditionSelectProps === null || conditionSelectProps === void 0 ? void 0 : conditionSelectProps.mode) === 'multiple';
|
|
111
123
|
(0, react_1.useEffect)(function () {
|
|
112
|
-
if (value && value.selectValue && optionsList.length) {
|
|
124
|
+
if (value && !(0, isNil_1["default"])(value.selectValue) && optionsList.length) {
|
|
113
125
|
var _a = __read(optionsList.filter(function (item) {
|
|
114
126
|
return item.value === value.selectValue;
|
|
115
127
|
}), 1),
|
|
@@ -121,10 +133,16 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
121
133
|
}, [value, optionsList]);
|
|
122
134
|
var onSelectChange = function onSelectChange(selectValue) {
|
|
123
135
|
var inputValue = isInput ? '' : undefined;
|
|
124
|
-
|
|
136
|
+
var finalSelectInputValue = {
|
|
125
137
|
selectValue: selectValue,
|
|
126
138
|
inputValue: inputValue
|
|
127
|
-
}
|
|
139
|
+
};
|
|
140
|
+
if (isSubSelectMultiple) {
|
|
141
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
142
|
+
finalSelectValue: !(0, isNil_1["default"])(selectValue) ? findAllSubSelectItems(optionsList, selectValue) : undefined
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
setSelectInputValue(finalSelectInputValue);
|
|
128
146
|
if (isInput || (0, isNil_1["default"])(selectValue)) {
|
|
129
147
|
setSubSelectOptions([]);
|
|
130
148
|
return;
|
|
@@ -144,14 +162,41 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
144
162
|
});
|
|
145
163
|
};
|
|
146
164
|
var onTypeSelectChange = function onTypeSelectChange(inputValue) {
|
|
147
|
-
|
|
165
|
+
var finalSelectInputValue = {
|
|
148
166
|
selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
149
167
|
inputValue: inputValue
|
|
150
|
-
}
|
|
168
|
+
};
|
|
169
|
+
if (isSubSelectMultiple) {
|
|
170
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
171
|
+
finalSelectValue: (0, isEmpty_1["default"])(inputValue) ? findAllSubSelectItems(optionsList, selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) : inputValue
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
setSelectInputValue(finalSelectInputValue);
|
|
151
175
|
};
|
|
152
176
|
var onConditionSelectInputBlur = function onConditionSelectInputBlur() {
|
|
153
177
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(selectInputValue);
|
|
154
178
|
};
|
|
179
|
+
/** 二级下拉框清空 */
|
|
180
|
+
var onTypeSelectClear = function onTypeSelectClear() {
|
|
181
|
+
var finalSelectInputValue = {
|
|
182
|
+
selectValue: selectInputValue.selectValue,
|
|
183
|
+
inputValue: []
|
|
184
|
+
};
|
|
185
|
+
if (isSubSelectMultiple) {
|
|
186
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
187
|
+
finalSelectValue: findAllSubSelectItems(optionsList, selectInputValue.selectValue)
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(finalSelectInputValue);
|
|
191
|
+
};
|
|
192
|
+
/** 一级下拉框清空 */
|
|
193
|
+
var onSelectClear = function onSelectClear() {
|
|
194
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
195
|
+
selectValue: undefined,
|
|
196
|
+
inputValue: undefined,
|
|
197
|
+
finalSelectValue: undefined
|
|
198
|
+
});
|
|
199
|
+
};
|
|
155
200
|
// 是否展示输入框
|
|
156
201
|
var isShowInput = !(0, isNil_1["default"])(selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) && !(hiddenInputKeys === null || hiddenInputKeys === void 0 ? void 0 : hiddenInputKeys.includes(selectInputValue.selectValue));
|
|
157
202
|
var typeInput = isInput ? react_1["default"].createElement("div", {
|
|
@@ -166,7 +211,8 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
166
211
|
onChange: onTypeSelectChange,
|
|
167
212
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
|
|
168
213
|
options: subSelectOptions,
|
|
169
|
-
onBlur: onConditionSelectInputBlur
|
|
214
|
+
onBlur: onConditionSelectInputBlur,
|
|
215
|
+
onClear: onTypeSelectClear
|
|
170
216
|
})));
|
|
171
217
|
return react_1["default"].createElement("div", {
|
|
172
218
|
className: "condition-select-wrap"
|
|
@@ -179,7 +225,8 @@ var ConditionSelectInput = function ConditionSelectInput(props) {
|
|
|
179
225
|
onChange: onSelectChange,
|
|
180
226
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
181
227
|
options: optionsList,
|
|
182
|
-
onBlur: onConditionSelectInputBlur
|
|
228
|
+
onBlur: onConditionSelectInputBlur,
|
|
229
|
+
onClear: onSelectClear
|
|
183
230
|
}))), isShowInput && typeInput);
|
|
184
231
|
};
|
|
185
232
|
exports["default"] = ConditionSelectInput;
|
|
@@ -15,6 +15,7 @@ export interface MainSelectOptionsType extends SelectOptionsType {
|
|
|
15
15
|
export interface ValueType {
|
|
16
16
|
selectValue?: number | string | null;
|
|
17
17
|
inputValue?: LabelSelectProps['value'] | LabelConditionInputProps['value'];
|
|
18
|
+
finalSelectValue?: LabelSelectProps['value'] | LabelConditionInputProps['value'][];
|
|
18
19
|
}
|
|
19
20
|
export interface LabelConditionSelectInputProps {
|
|
20
21
|
value?: ValueType;
|
|
@@ -79,6 +79,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
79
79
|
});
|
|
80
80
|
exports.InputTypeEnum = void 0;
|
|
81
81
|
var isNil_1 = __importDefault(require("lodash/isNil"));
|
|
82
|
+
var isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
82
83
|
var classnames_1 = __importDefault(require("classnames"));
|
|
83
84
|
var react_1 = __importStar(require("react"));
|
|
84
85
|
var useControllableValue_1 = __importDefault(require("ahooks/lib/useControllableValue"));
|
|
@@ -89,6 +90,15 @@ var InputTypeEnum;
|
|
|
89
90
|
InputTypeEnum["CONDITION_INPUT"] = "conditionInput";
|
|
90
91
|
InputTypeEnum["SELECT"] = "select";
|
|
91
92
|
})(InputTypeEnum = exports.InputTypeEnum || (exports.InputTypeEnum = {}));
|
|
93
|
+
/** 找所有的子代选项 */
|
|
94
|
+
var findAllSubSelectItems = function findAllSubSelectItems(dataSource, key) {
|
|
95
|
+
var _a, _b;
|
|
96
|
+
return (_b = (_a = dataSource.find(function (item) {
|
|
97
|
+
return item.value === key;
|
|
98
|
+
})) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.map(function (subItem) {
|
|
99
|
+
return subItem.value;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
92
102
|
var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
93
103
|
var value = props.value,
|
|
94
104
|
_a = props.hiddenInputKeys,
|
|
@@ -110,8 +120,10 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
110
120
|
var _e = __read((0, react_1.useState)([]), 2),
|
|
111
121
|
subSelectOptions = _e[0],
|
|
112
122
|
setSubSelectOptions = _e[1];
|
|
123
|
+
/** 子选择器是否多选 */
|
|
124
|
+
var isSubSelectMultiple = (conditionSelectProps === null || conditionSelectProps === void 0 ? void 0 : conditionSelectProps.mode) === 'multiple';
|
|
113
125
|
(0, react_1.useEffect)(function () {
|
|
114
|
-
if (value && value.selectValue && optionsList.length) {
|
|
126
|
+
if (value && !(0, isNil_1["default"])(value.selectValue) && optionsList.length) {
|
|
115
127
|
var _a = __read(optionsList.filter(function (item) {
|
|
116
128
|
return item.value === value.selectValue;
|
|
117
129
|
}), 1),
|
|
@@ -123,10 +135,16 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
123
135
|
}, [value, optionsList]);
|
|
124
136
|
var onSelectChange = function onSelectChange(selectValue) {
|
|
125
137
|
var inputValue = isInput ? '' : undefined;
|
|
126
|
-
|
|
138
|
+
var finalSelectInputValue = {
|
|
127
139
|
selectValue: selectValue,
|
|
128
140
|
inputValue: inputValue
|
|
129
|
-
}
|
|
141
|
+
};
|
|
142
|
+
if (isSubSelectMultiple) {
|
|
143
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
144
|
+
finalSelectValue: !(0, isNil_1["default"])(selectValue) ? findAllSubSelectItems(optionsList, selectValue) : undefined
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
setSelectInputValue(finalSelectInputValue);
|
|
130
148
|
if (isInput || (0, isNil_1["default"])(selectValue)) {
|
|
131
149
|
setSubSelectOptions([]);
|
|
132
150
|
return;
|
|
@@ -146,14 +164,42 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
146
164
|
});
|
|
147
165
|
};
|
|
148
166
|
var onTypeSelectChange = function onTypeSelectChange(inputValue) {
|
|
149
|
-
|
|
167
|
+
var finalSelectInputValue = {
|
|
150
168
|
selectValue: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
151
169
|
inputValue: inputValue
|
|
152
|
-
}
|
|
170
|
+
};
|
|
171
|
+
if (isSubSelectMultiple) {
|
|
172
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
173
|
+
finalSelectValue: (0, isEmpty_1["default"])(inputValue) ? findAllSubSelectItems(optionsList, selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) : inputValue
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
setSelectInputValue(finalSelectInputValue);
|
|
153
177
|
};
|
|
178
|
+
/** 联级选择框失去焦点 */
|
|
154
179
|
var onLabelConditionSelectInputBlur = function onLabelConditionSelectInputBlur() {
|
|
155
180
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(selectInputValue);
|
|
156
181
|
};
|
|
182
|
+
/** 二级下拉框清空 */
|
|
183
|
+
var onTypeSelectClear = function onTypeSelectClear() {
|
|
184
|
+
var finalSelectInputValue = {
|
|
185
|
+
selectValue: selectInputValue.selectValue,
|
|
186
|
+
inputValue: []
|
|
187
|
+
};
|
|
188
|
+
if (isSubSelectMultiple) {
|
|
189
|
+
finalSelectInputValue = __assign(__assign({}, finalSelectInputValue), {
|
|
190
|
+
finalSelectValue: findAllSubSelectItems(optionsList, selectInputValue.selectValue)
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(finalSelectInputValue);
|
|
194
|
+
};
|
|
195
|
+
/** 一级下拉框清空 */
|
|
196
|
+
var onSelectClear = function onSelectClear() {
|
|
197
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
198
|
+
selectValue: undefined,
|
|
199
|
+
inputValue: undefined,
|
|
200
|
+
finalSelectValue: undefined
|
|
201
|
+
});
|
|
202
|
+
};
|
|
157
203
|
// 是否展示输入框
|
|
158
204
|
var isShowInput = !(0, isNil_1["default"])(selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue) && !(hiddenInputKeys === null || hiddenInputKeys === void 0 ? void 0 : hiddenInputKeys.includes(selectInputValue.selectValue));
|
|
159
205
|
var typeInput = isInput ? react_1["default"].createElement(label_condition_input_1["default"], __assign({}, conditionInputProps, {
|
|
@@ -167,7 +213,8 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
167
213
|
onChange: onTypeSelectChange,
|
|
168
214
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.inputValue,
|
|
169
215
|
options: subSelectOptions,
|
|
170
|
-
onBlur: onLabelConditionSelectInputBlur
|
|
216
|
+
onBlur: onLabelConditionSelectInputBlur,
|
|
217
|
+
onClear: onTypeSelectClear
|
|
171
218
|
})));
|
|
172
219
|
return react_1["default"].createElement("div", {
|
|
173
220
|
className: (0, classnames_1["default"])('label-condition-select', className)
|
|
@@ -182,7 +229,8 @@ var LabelConditionSelect = function LabelConditionSelect(props) {
|
|
|
182
229
|
onChange: onSelectChange,
|
|
183
230
|
value: selectInputValue === null || selectInputValue === void 0 ? void 0 : selectInputValue.selectValue,
|
|
184
231
|
options: optionsList,
|
|
185
|
-
onBlur: onLabelConditionSelectInputBlur
|
|
232
|
+
onBlur: onLabelConditionSelectInputBlur,
|
|
233
|
+
onClear: onSelectClear
|
|
186
234
|
}))), isShowInput && typeInput);
|
|
187
235
|
};
|
|
188
236
|
exports["default"] = LabelConditionSelect;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assui",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.42",
|
|
4
4
|
"description": "react ui library",
|
|
5
5
|
"author": "jason <usochen@gmail.com>",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"node": ">=10.0.0"
|
|
81
81
|
},
|
|
82
82
|
"license": "MIT",
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "67f6c3130c1e9c1200119e2f26816fe91b757ef7"
|
|
84
84
|
}
|