@alicloud/console-components-search 0.2.37-beta.0 → 0.2.37
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/CHANGELOG.md +7 -0
- package/demos/demo1.demo.tsx +203 -81
- package/dist/index.js +80 -32
- package/es/ComplexSearch/InputPrefix.js +18 -3
- package/es/ComplexSearch/index.js +76 -20
- package/es/search.js +0 -2
- package/lib/ComplexSearch/InputPrefix.js +17 -2
- package/lib/ComplexSearch/index.js +76 -21
- package/lib/search.js +0 -2
- package/lib/types/IRcSearchOptions.type.d.ts +2 -0
- package/lib/types/IRcSearchProps.type.d.ts +11 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
package/demos/demo1.demo.tsx
CHANGED
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
* @title 场景1
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import React from
|
|
6
|
-
import { Search, SearchFilter } from
|
|
7
|
-
import { ConfigProvider } from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let options = [
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
|
+
import { Search, SearchFilter } from '@alicloud/console-components-search';
|
|
7
|
+
import { ConfigProvider } from '@alicloud/console-components';
|
|
8
|
+
|
|
9
|
+
const options = [
|
|
11
10
|
{
|
|
12
11
|
label: '实例名称',
|
|
13
12
|
dataIndex: 'name',
|
|
14
13
|
template: 'input',
|
|
15
14
|
templateProps: {
|
|
16
15
|
// placeholder: '按实例名称搜索',
|
|
17
|
-
dataSource: []
|
|
16
|
+
dataSource: [],
|
|
18
17
|
},
|
|
19
|
-
groupName:"test"
|
|
20
18
|
},
|
|
21
19
|
{
|
|
22
20
|
label: '网络类型',
|
|
@@ -25,13 +23,12 @@ import { useState } from "react";
|
|
|
25
23
|
templateProps: {
|
|
26
24
|
placeholder: '请选择网络类型',
|
|
27
25
|
dataSource: [
|
|
28
|
-
{label: 'A', value: 'a'},
|
|
29
|
-
{label: 'B', value: 'b'},
|
|
30
|
-
{label: 'C', value: 'c'},
|
|
31
|
-
{label: 'D', value: 'd'},
|
|
32
|
-
]
|
|
26
|
+
{ label: 'A', value: 'a' },
|
|
27
|
+
{ label: 'B', value: 'b' },
|
|
28
|
+
{ label: 'C', value: 'c' },
|
|
29
|
+
{ label: 'D', value: 'd' },
|
|
30
|
+
],
|
|
33
31
|
},
|
|
34
|
-
groupName:"test"
|
|
35
32
|
},
|
|
36
33
|
{
|
|
37
34
|
label: '付费类型',
|
|
@@ -40,88 +37,213 @@ import { useState } from "react";
|
|
|
40
37
|
templateProps: {
|
|
41
38
|
placeholder: '请选择付费类型',
|
|
42
39
|
dataSource: [
|
|
43
|
-
{label: 'A', value: 'a'},
|
|
44
|
-
{label: 'B', value: 'b'},
|
|
45
|
-
{label: 'C', value: 'c'},
|
|
46
|
-
{label: 'D', value: 'd'},
|
|
47
|
-
]
|
|
40
|
+
{ label: 'A', value: 'a' },
|
|
41
|
+
{ label: 'B', value: 'b' },
|
|
42
|
+
{ label: 'C', value: 'c' },
|
|
43
|
+
{ label: 'D', value: 'd' },
|
|
44
|
+
],
|
|
48
45
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
]
|
|
46
|
+
},
|
|
47
|
+
];
|
|
52
48
|
|
|
53
|
-
|
|
49
|
+
const options2 = [
|
|
54
50
|
{
|
|
55
51
|
label: '实例名称',
|
|
56
52
|
dataIndex: 'name',
|
|
57
53
|
template: 'input',
|
|
58
54
|
templateProps: {
|
|
59
55
|
placeholder: '按实例名称搜索',
|
|
60
|
-
dataSource: []
|
|
56
|
+
dataSource: [],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const intl = (a) => a;
|
|
62
|
+
|
|
63
|
+
const options3 = [
|
|
64
|
+
{
|
|
65
|
+
dataIndex: 'SourceIp',
|
|
66
|
+
label: intl('flow_analysis.prop.enum', { value: 'SourceIp' }),
|
|
67
|
+
template: 'input',
|
|
68
|
+
// groupName: intl('flow_analysis.prop.enum', { value: 'SourceIp' }),
|
|
69
|
+
children: [
|
|
70
|
+
{
|
|
71
|
+
dataIndex: 'SourceIp_equal',
|
|
72
|
+
label: intl('flow_analysis.prop.enum', { value: 'SourceIp_equal' }),
|
|
73
|
+
template: 'input',
|
|
74
|
+
}, {
|
|
75
|
+
dataIndex: 'SourceIp_like',
|
|
76
|
+
label: intl('flow_analysis.prop.enum', { value: 'SourceIp_like' }),
|
|
77
|
+
template: 'input',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
dataIndex: 'SourceIp_notlike',
|
|
81
|
+
label: intl('flow_analysis.prop.enum', { value: 'SourceIp_notlike' }),
|
|
82
|
+
template: 'input',
|
|
83
|
+
// groupName: intl('flow_analysis.prop.enum', { value: 'SourceIp' }),
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
dataIndex: 'DestinationIp_equal',
|
|
89
|
+
label: intl('flow_analysis.prop.enum', { value: 'DestinationIp_equal' }),
|
|
90
|
+
labelEx: (
|
|
91
|
+
<div>
|
|
92
|
+
<span>
|
|
93
|
+
{intl('flow_analysis.prop.enum', { value: 'DestinationIp_equal' })}
|
|
94
|
+
</span>
|
|
95
|
+
<span>
|
|
96
|
+
{intl('tr_flow_log.search.operator.enum', { value: 'equal' })}
|
|
97
|
+
</span>
|
|
98
|
+
</div>
|
|
99
|
+
),
|
|
100
|
+
template: 'input',
|
|
101
|
+
groupName: intl('flow_analysis.prop.enum', { value: 'DestinationIp' }),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
dataIndex: 'DestinationIp_like',
|
|
105
|
+
label: intl('flow_analysis.prop.enum', { value: 'DestinationIp_like' }),
|
|
106
|
+
labelEx: (
|
|
107
|
+
<div>
|
|
108
|
+
<span>
|
|
109
|
+
{intl('flow_analysis.prop.enum', { value: 'DestinationIp_like' })}
|
|
110
|
+
</span>
|
|
111
|
+
<span>
|
|
112
|
+
{intl('tr_flow_log.search.operator.enum', { value: 'like' })}
|
|
113
|
+
</span>
|
|
114
|
+
</div>
|
|
115
|
+
),
|
|
116
|
+
template: 'input',
|
|
117
|
+
groupName: intl('flow_analysis.prop.enum', { value: 'DestinationIp' }),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
dataIndex: 'DestinationIp_notlike',
|
|
121
|
+
label: intl('flow_analysis.prop.enum', { value: 'DestinationIp_notlike' }),
|
|
122
|
+
labelEx: (
|
|
123
|
+
<div>
|
|
124
|
+
<span>
|
|
125
|
+
{intl('flow_analysis.prop.enum', { value: 'DestinationIp_notlike' })}
|
|
126
|
+
</span>
|
|
127
|
+
<span>
|
|
128
|
+
{intl('tr_flow_log.search.operator.enum', { value: 'notlike' })}
|
|
129
|
+
</span>
|
|
130
|
+
</div>
|
|
131
|
+
),
|
|
132
|
+
template: 'input',
|
|
133
|
+
groupName: intl('flow_analysis.prop.enum', { value: 'DestinationIp' }),
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
dataIndex: 'Dscp',
|
|
137
|
+
label: intl('flow_analysis.prop.enum', { value: 'Dscp' }),
|
|
138
|
+
template: 'input',
|
|
139
|
+
groupName: intl('flow_analysis.prop.enum', { value: 'Dscp' }),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
dataIndex: 'Protocol',
|
|
143
|
+
label: intl('flow_analysis.prop.enum', { value: 'Protocol' }),
|
|
144
|
+
template: 'select',
|
|
145
|
+
templateProps: {
|
|
146
|
+
dataSource: [
|
|
147
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
|
148
|
+
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
|
|
149
|
+
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 64, 65, 66, 67, 69, 70, 71, 72, 73,
|
|
150
|
+
74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
|
|
151
|
+
97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 115, 116, 117,
|
|
152
|
+
118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135,
|
|
153
|
+
136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 255,
|
|
154
|
+
].map((item) => ({
|
|
155
|
+
label: intl('flow_analyzer.detail.protocol.enum', { value: item }),
|
|
156
|
+
value: String(item),
|
|
157
|
+
})),
|
|
61
158
|
},
|
|
62
|
-
|
|
63
|
-
|
|
159
|
+
groupName: intl('flow_analysis.prop.enum', { value: 'Protocol' }),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
dataIndex: 'DestinationPort',
|
|
163
|
+
label: intl('flow_analysis.prop.enum', { value: 'DestinationPort' }),
|
|
164
|
+
template: 'input',
|
|
165
|
+
groupName: intl('flow_analysis.prop.enum', { value: 'DestinationPort' }),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
dataIndex: 'SourcePort',
|
|
169
|
+
label: intl('flow_analysis.prop.enum', { value: 'SourcePort' }),
|
|
170
|
+
template: 'input',
|
|
171
|
+
groupName: intl('flow_analysis.prop.enum', { value: 'SourcePort' }),
|
|
172
|
+
},
|
|
173
|
+
];
|
|
64
174
|
|
|
65
175
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{label: '实例名称', value: 'xxxxxx', dataIndex: 'name'},
|
|
69
|
-
{value: [{tagKey: 'test', tagValue: ''}], dataIndex: 'tag'}
|
|
176
|
+
const Demo1: React.FC<{}> = (props) => {
|
|
177
|
+
const [filters, setFilters] = useState<any>([
|
|
178
|
+
{ label: '实例名称', value: 'xxxxxx', dataIndex: 'name' },
|
|
179
|
+
{ value: [{ tagKey: 'test', tagValue: '' }], dataIndex: 'tag' },
|
|
180
|
+
{ value: [{ tagKey: 'test', tagValue: '' }], dataIndex: 'tag2' },
|
|
70
181
|
]);
|
|
71
|
-
|
|
182
|
+
return (
|
|
72
183
|
<ConfigProvider>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
<div>搜索条件成组</div>
|
|
102
|
-
<Search
|
|
103
|
-
defaultDataIndex="name"
|
|
104
|
-
defaultSelectedDataIndex="name"
|
|
105
|
-
options={options}
|
|
106
|
-
onSearch={(value, dataIndex, extra) => {
|
|
107
|
-
//@ts-ignore
|
|
108
|
-
setFilters([...filters, extra])
|
|
109
|
-
}}
|
|
110
|
-
suggestions={[{label: '实例名称', children: ['222222']}, '33333333']}
|
|
111
|
-
/>
|
|
184
|
+
<div>
|
|
185
|
+
<div>默认固定搜索条件</div>
|
|
186
|
+
<Search
|
|
187
|
+
defaultDataIndex="name"
|
|
188
|
+
defaultSelectedDataIndex="name"
|
|
189
|
+
options={[{
|
|
190
|
+
label: '实例名称',
|
|
191
|
+
dataIndex: 'name',
|
|
192
|
+
template: 'input',
|
|
193
|
+
templateProps: {
|
|
194
|
+
placeholder: '按实例名称搜索',
|
|
195
|
+
},
|
|
196
|
+
}]}
|
|
197
|
+
onSearch={(value, dataIndex) => {
|
|
198
|
+
console.log(value, dataIndex);
|
|
199
|
+
}}
|
|
200
|
+
/>
|
|
201
|
+
<br /><br />
|
|
202
|
+
<Search
|
|
203
|
+
defaultDataIndex="name"
|
|
204
|
+
options={options2}
|
|
205
|
+
onSearch={(value, dataIndex) => {
|
|
206
|
+
console.log(value, dataIndex);
|
|
207
|
+
}}
|
|
208
|
+
suggestions={[{ label: '实例名称', children: ['222222'] }, '33333333']}
|
|
209
|
+
/>
|
|
210
|
+
<br /><br />
|
|
112
211
|
|
|
113
|
-
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
212
|
+
<div>搜索条件成组</div>
|
|
213
|
+
<Search
|
|
214
|
+
defaultDataIndex="name"
|
|
215
|
+
defaultSelectedDataIndex="name"
|
|
216
|
+
options={options}
|
|
217
|
+
onSearch={(value, dataIndex, extra) => {
|
|
218
|
+
// @ts-ignore
|
|
219
|
+
setFilters([...filters, extra]);
|
|
220
|
+
}}
|
|
221
|
+
suggestions={[{ label: '实例名称', children: ['222222'] }, '33333333']}
|
|
222
|
+
/>
|
|
223
|
+
<Search
|
|
224
|
+
defaultDataIndex="name"
|
|
225
|
+
// defaultSelectedDataIndex="name"
|
|
226
|
+
options={options3}
|
|
227
|
+
prefixSelectMode="cascader"
|
|
228
|
+
onSearch={(value, dataIndex, extra) => {
|
|
229
|
+
console.log(value, dataIndex, extra);
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
setFilters([...filters, extra]);
|
|
118
232
|
}}
|
|
233
|
+
suggestions={[{ label: '实例名称', children: ['222222'] }, '33333333']}
|
|
119
234
|
/>
|
|
235
|
+
|
|
236
|
+
<div style={{ marginTop: 8 }}>
|
|
237
|
+
<SearchFilter
|
|
238
|
+
dataSource={filters}
|
|
239
|
+
onChange={(deletedFilter, remainFilters) => {
|
|
240
|
+
setFilters(remainFilters);
|
|
241
|
+
}}
|
|
242
|
+
/>
|
|
243
|
+
</div>
|
|
120
244
|
</div>
|
|
121
|
-
</div>
|
|
122
245
|
</ConfigProvider>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export default Demo1;
|
package/dist/index.js
CHANGED
|
@@ -89955,7 +89955,7 @@ __webpack_require__(227);
|
|
|
89955
89955
|
var useCssVar_1 = __webpack_require__(228);
|
|
89956
89956
|
var SearchWrap = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: 32px;\n width: 400px;\n display: inline-block;\n vertical-align: top;\n"], ["\n height: 32px;\n width: 400px;\n display: inline-block;\n vertical-align: top;\n"])));
|
|
89957
89957
|
var Search = function (props) {
|
|
89958
|
-
var className = props.className,
|
|
89958
|
+
var className = props.className, style = props.style;
|
|
89959
89959
|
var windThemeClass = (0, useCssVar_1.useWindTheme)();
|
|
89960
89960
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
89961
89961
|
react_1.default.createElement(SearchWrap, { className: (0, classnames_1.default)(constants_1.baseClassName, className, windThemeClass), style: style },
|
|
@@ -90030,12 +90030,35 @@ var InputPrefix_1 = __importDefault(__webpack_require__(417));
|
|
|
90030
90030
|
var constants_1 = __webpack_require__(135);
|
|
90031
90031
|
var message_1 = __importDefault(__webpack_require__(165));
|
|
90032
90032
|
var AutoComplete = console_components_1.Select.AutoComplete;
|
|
90033
|
+
function formatOptionsChildren(children) {
|
|
90034
|
+
if (!children)
|
|
90035
|
+
return undefined;
|
|
90036
|
+
return children.map(function (o) {
|
|
90037
|
+
return {
|
|
90038
|
+
label: o.label,
|
|
90039
|
+
value: o.dataIndex || o.value || o.label,
|
|
90040
|
+
disabled: o.disabled,
|
|
90041
|
+
children: formatOptionsChildren(o.children),
|
|
90042
|
+
};
|
|
90043
|
+
});
|
|
90044
|
+
}
|
|
90033
90045
|
/**
|
|
90034
90046
|
*
|
|
90035
90047
|
* @param IRcSearchOptionsProps options
|
|
90036
90048
|
* @returns
|
|
90037
90049
|
*/
|
|
90038
|
-
var normalizeOptions = function (options) {
|
|
90050
|
+
var normalizeOptions = function (options, prefixSelectMode) {
|
|
90051
|
+
if (prefixSelectMode === 'cascader') {
|
|
90052
|
+
return options.map(function (o) {
|
|
90053
|
+
return {
|
|
90054
|
+
label: o.label,
|
|
90055
|
+
value: o.dataIndex || o.value || o.label,
|
|
90056
|
+
disabled: o.disabled,
|
|
90057
|
+
// @ts-ignore
|
|
90058
|
+
children: formatOptionsChildren(o.children),
|
|
90059
|
+
};
|
|
90060
|
+
});
|
|
90061
|
+
}
|
|
90039
90062
|
var optionsCopy = (0, cloneDeep_1.default)(options);
|
|
90040
90063
|
optionsCopy.forEach(function (o) { !o.groupName && (o.groupName = message_1.default.defaultFilterGroupName); });
|
|
90041
90064
|
return Object.entries((0, groupBy_1.default)(optionsCopy, 'groupName')).map(function (_a) {
|
|
@@ -90045,7 +90068,8 @@ var normalizeOptions = function (options) {
|
|
|
90045
90068
|
children: children.map(function (l) {
|
|
90046
90069
|
return {
|
|
90047
90070
|
label: l.label,
|
|
90048
|
-
value: l.dataIndex,
|
|
90071
|
+
value: l.dataIndex || l.value,
|
|
90072
|
+
disabled: l.disabled,
|
|
90049
90073
|
};
|
|
90050
90074
|
}),
|
|
90051
90075
|
};
|
|
@@ -90072,15 +90096,28 @@ var normalizeSelectDataSource = function (title, list) {
|
|
|
90072
90096
|
},
|
|
90073
90097
|
];
|
|
90074
90098
|
};
|
|
90099
|
+
var flatOption = function (opts) {
|
|
90100
|
+
if (opts === void 0) { opts = []; }
|
|
90101
|
+
var flattened = [];
|
|
90102
|
+
opts.forEach(function (item) {
|
|
90103
|
+
if (item.children) {
|
|
90104
|
+
flattened.push.apply(flattened, flatOption(item.children));
|
|
90105
|
+
}
|
|
90106
|
+
else {
|
|
90107
|
+
flattened.push(item);
|
|
90108
|
+
}
|
|
90109
|
+
});
|
|
90110
|
+
return flattened;
|
|
90111
|
+
};
|
|
90075
90112
|
var normalizeSearchOptions = function (dataIndex, value, options) {
|
|
90076
|
-
var _a, _b, _c;
|
|
90077
|
-
var opt = options === null ||
|
|
90113
|
+
var _a, _b, _c, _d;
|
|
90114
|
+
var opt = (_a = flatOption(options)) === null || _a === void 0 ? void 0 : _a.find(function (o) { return getDataIndex(o) === dataIndex; });
|
|
90078
90115
|
var valueLabel = value;
|
|
90079
90116
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
90080
|
-
valueLabel = (
|
|
90117
|
+
valueLabel = (_c = (_b = opt.templateProps) === null || _b === void 0 ? void 0 : _b.dataSource.find(function (d) { return d.value === value; })) === null || _c === void 0 ? void 0 : _c.label;
|
|
90081
90118
|
}
|
|
90082
90119
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'multiple') {
|
|
90083
|
-
valueLabel = (
|
|
90120
|
+
valueLabel = (_d = opt.templateProps) === null || _d === void 0 ? void 0 : _d.dataSource.filter(function (d) { return value === null || value === void 0 ? void 0 : value.includes(d.value); }).map(function (d) { return d.label; }).join('/');
|
|
90084
90121
|
}
|
|
90085
90122
|
return {
|
|
90086
90123
|
label: opt === null || opt === void 0 ? void 0 : opt.label,
|
|
@@ -90099,10 +90136,13 @@ var highlightKeyword = function (value, keywords) {
|
|
|
90099
90136
|
react_1.default.createElement("span", { style: { color: 'var(--color-brand1-6)' } }, highlightValue),
|
|
90100
90137
|
endValue));
|
|
90101
90138
|
};
|
|
90139
|
+
var getDataIndex = function (option) {
|
|
90140
|
+
return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
|
|
90141
|
+
};
|
|
90102
90142
|
var ComplexSearch = function (props) {
|
|
90103
|
-
var _a = props.options, options = _a === void 0 ? [] : _a, fuzzy = props.fuzzy, defaultDataIndex = props.defaultDataIndex, defaultSelectedDataIndex = props.defaultSelectedDataIndex, placeholder = props.placeholder, onSearch = props.onSearch, onSuggest = props.onSuggest, _b = props.suggestions, suggestions = _b === void 0 ? [] : _b, _c = props.prefix, prefix = _c === void 0 ? 'next-' : _c;
|
|
90104
|
-
var
|
|
90105
|
-
var
|
|
90143
|
+
var _a = props.options, options = _a === void 0 ? [] : _a, fuzzy = props.fuzzy, defaultDataIndex = props.defaultDataIndex, defaultSelectedDataIndex = props.defaultSelectedDataIndex, placeholder = props.placeholder, onSearch = props.onSearch, onSuggest = props.onSuggest, _b = props.suggestions, suggestions = _b === void 0 ? [] : _b, _c = props.prefix, prefix = _c === void 0 ? 'next-' : _c, _d = props.prefixSelectMode, prefixSelectMode = _d === void 0 ? 'select' : _d, prefixSelectItemRender = props.prefixSelectItemRender;
|
|
90144
|
+
var _e = (0, react_1.useState)(options.find(function (o) { return getDataIndex(o) === defaultSelectedDataIndex; })), selectedFilterType = _e[0], setSelectedFilterType = _e[1];
|
|
90145
|
+
var _f = (0, react_1.useState)(false), focused = _f[0], setFocused = _f[1];
|
|
90106
90146
|
var autoRef = (0, react_1.useRef)(null);
|
|
90107
90147
|
var field = console_components_1.Field.useField();
|
|
90108
90148
|
var init = field.init, getValue = field.getValue, reset = field.reset;
|
|
@@ -90116,7 +90156,7 @@ var ComplexSearch = function (props) {
|
|
|
90116
90156
|
};
|
|
90117
90157
|
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
90118
90158
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(constants_1.SEARCH_FILTER_FIELD);
|
|
90119
|
-
var defaultFilter = options.find(function (t) { return t
|
|
90159
|
+
var defaultFilter = options.find(function (t) { return getDataIndex(t) === defaultDataIndex; });
|
|
90120
90160
|
var highlightItem = function (item, searchKey) {
|
|
90121
90161
|
var label = item.label;
|
|
90122
90162
|
if (searchKey && searchKey.length) {
|
|
@@ -90129,18 +90169,18 @@ var ComplexSearch = function (props) {
|
|
|
90129
90169
|
*/
|
|
90130
90170
|
var handlerFilterTypeChange = function (type, resetValue) {
|
|
90131
90171
|
if (resetValue === void 0) { resetValue = true; }
|
|
90132
|
-
setSelectedFilterType(options.find(function (o) { return o
|
|
90172
|
+
setSelectedFilterType(flatOption(options).find(function (o) { return getDataIndex(o) === type; }));
|
|
90133
90173
|
resetValue && reset();
|
|
90134
90174
|
};
|
|
90135
90175
|
/**
|
|
90136
90176
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
90137
90177
|
*/
|
|
90138
|
-
var handlerFilterTypeInput = function (value, actionType,
|
|
90139
|
-
var isFuzzySearch =
|
|
90178
|
+
var handlerFilterTypeInput = function (value, actionType, _isFuzzy, option) {
|
|
90179
|
+
var isFuzzySearch = _isFuzzy && getValue(constants_1.SEARCH_FILTER_FIELD);
|
|
90140
90180
|
// 如果是模糊搜索,则直接处理
|
|
90141
90181
|
if (isFuzzySearch) {
|
|
90142
90182
|
if (actionType !== 'change') {
|
|
90143
|
-
handleSearch(option
|
|
90183
|
+
handleSearch(getDataIndex(option));
|
|
90144
90184
|
}
|
|
90145
90185
|
else {
|
|
90146
90186
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
@@ -90166,7 +90206,7 @@ var ComplexSearch = function (props) {
|
|
|
90166
90206
|
onSearch(getValue(constants_1.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(constants_1.SEARCH_FILTER_FIELD), options));
|
|
90167
90207
|
}
|
|
90168
90208
|
if (selectedFilterType) {
|
|
90169
|
-
onSearch(value, selectedFilterType
|
|
90209
|
+
onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
|
|
90170
90210
|
}
|
|
90171
90211
|
}
|
|
90172
90212
|
reset();
|
|
@@ -90245,11 +90285,19 @@ var ComplexSearch = function (props) {
|
|
|
90245
90285
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('left-wrap', "".concat(prefix, "input"), {
|
|
90246
90286
|
focus: focused,
|
|
90247
90287
|
}) },
|
|
90248
|
-
react_1.default.createElement("div", { className: (0, classnames_1.default)('condition') }, selectedFilterType ? (react_1.default.createElement(InputPrefix_1.default, { dataSource: normalizeOptions(options), label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label, defaultValue: selectedFilterType
|
|
90288
|
+
react_1.default.createElement("div", { className: (0, classnames_1.default)('condition') }, selectedFilterType ? (react_1.default.createElement(InputPrefix_1.default, { type: prefixSelectMode, dataSource: normalizeOptions(options, prefixSelectMode), label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label, defaultValue: getDataIndex(selectedFilterType), onChange: function (value) {
|
|
90249
90289
|
handlerFilterTypeChange(value);
|
|
90250
|
-
} })) : null),
|
|
90290
|
+
}, itemRender: prefixSelectItemRender })) : null),
|
|
90251
90291
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('forms') },
|
|
90252
|
-
!selectedFilterType ?
|
|
90292
|
+
!selectedFilterType && prefixSelectMode === 'cascader' ? react_1.default.createElement(console_components_1.CascaderSelect, { className: (0, classnames_1.default)('main-input', 'multi'), hasBorder: false, dataSource: normalizeOptions(options, prefixSelectMode), placeholder: placeholder ||
|
|
90293
|
+
((defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label)
|
|
90294
|
+
? (0, lodash_1.template)(message_1.default.defaultPlaceHolder)({
|
|
90295
|
+
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label,
|
|
90296
|
+
})
|
|
90297
|
+
: ''), onChange: function (value) {
|
|
90298
|
+
handlerFilterTypeChange(value);
|
|
90299
|
+
}, itemRender: prefixSelectItemRender }) : null,
|
|
90300
|
+
!selectedFilterType && prefixSelectMode === 'select' ? (react_1.default.createElement(AutoComplete, __assign({}, init(constants_1.SEARCH_FILTER_FIELD, {
|
|
90253
90301
|
props: {
|
|
90254
90302
|
// @ts-ignore
|
|
90255
90303
|
onChange: function (value, actionType, option) {
|
|
@@ -90258,7 +90306,7 @@ var ComplexSearch = function (props) {
|
|
|
90258
90306
|
},
|
|
90259
90307
|
}), { autoHighlightFirstItem: false,
|
|
90260
90308
|
// @ts-ignore
|
|
90261
|
-
itemRender: highlightItem, placeholder: placeholder ||
|
|
90309
|
+
itemRender: prefixSelectItemRender || highlightItem, placeholder: placeholder ||
|
|
90262
90310
|
((defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label)
|
|
90263
90311
|
? (0, lodash_1.template)(message_1.default.defaultPlaceHolder)({
|
|
90264
90312
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label,
|
|
@@ -90268,7 +90316,7 @@ var ComplexSearch = function (props) {
|
|
|
90268
90316
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
90269
90317
|
isFuzzy
|
|
90270
90318
|
? normalizeSuggestion(suggestions)
|
|
90271
|
-
: normalizeOptions(options), popupStyle: { width: 'auto' }, popupClassName: "rc-search-auto-complete" }, focusProps))) : null,
|
|
90319
|
+
: normalizeOptions(options, prefixSelectMode), popupStyle: { width: 'auto' }, popupClassName: "rc-search-auto-complete" }, focusProps))) : null,
|
|
90272
90320
|
renderSelectedFilter(),
|
|
90273
90321
|
renderSelectFilterCloseIcon())),
|
|
90274
90322
|
react_1.default.createElement("div", { className: (0, classnames_1.default)('right-wrap'), ref: autoRef },
|
|
@@ -114222,15 +114270,15 @@ var classnames_1 = __importDefault(__webpack_require__(3));
|
|
|
114222
114270
|
var console_components_1 = __webpack_require__(45);
|
|
114223
114271
|
var SearchConditionSelectPrefix = function (props) {
|
|
114224
114272
|
var _a, _b;
|
|
114225
|
-
var defaultValue = props.defaultValue, _c = props.dataSource, dataSource = _c === void 0 ? [] : _c, label = props.label, reset = __rest(props, ["defaultValue", "dataSource", "label"]);
|
|
114273
|
+
var defaultValue = props.defaultValue, _c = props.dataSource, dataSource = _c === void 0 ? [] : _c, label = props.label, type = props.type, reset = __rest(props, ["defaultValue", "dataSource", "label", "type"]);
|
|
114226
114274
|
var noSelect = dataSource.length < 2 && ((_b = (_a = dataSource[0]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) < 2;
|
|
114227
114275
|
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('condition-item') },
|
|
114228
114276
|
react_1.default.createElement("span", { className: (0, classnames_1.default)('condition-item-txt') }, label),
|
|
114229
114277
|
noSelect ? null : react_1.default.createElement(console_components_1.Icon, { type: "caret-down", size: "xxs" }),
|
|
114230
|
-
react_1.default.createElement(console_components_1.Select, __assign({ className: (0, classnames_1.default)('condition-select', { 'rc-search-prefix-no-select': noSelect }), defaultValue: defaultValue, hasBorder: false, disabled: noSelect, autoHighlightFirstItem: false, dataSource: dataSource, itemRender: function (_a) {
|
|
114278
|
+
type === 'select' ? react_1.default.createElement(console_components_1.Select, __assign({ className: (0, classnames_1.default)('condition-select', { 'rc-search-prefix-no-select': noSelect }), defaultValue: defaultValue, hasBorder: false, disabled: noSelect, autoHighlightFirstItem: false, dataSource: dataSource, itemRender: function (_a) {
|
|
114231
114279
|
var label = _a.label, value = _a.value;
|
|
114232
114280
|
return (react_1.default.createElement("span", { "data-value": value }, label));
|
|
114233
|
-
} }, reset, { autoWidth: false, popupClassName: "rc-search-prefix" }))));
|
|
114281
|
+
} }, reset, { autoWidth: false, popupClassName: "rc-search-prefix" })) : react_1.default.createElement(console_components_1.CascaderSelect, __assign({ className: (0, classnames_1.default)('condition-select', { 'rc-search-prefix-no-select': noSelect }), defaultValue: defaultValue, hasBorder: false, disabled: noSelect, autoHighlightFirstItem: false, dataSource: dataSource }, reset, { autoWidth: false, popupClassName: "rc-search-prefix", canOnlyCheckLeaf: true }))));
|
|
114234
114282
|
};
|
|
114235
114283
|
exports.default = SearchConditionSelectPrefix;
|
|
114236
114284
|
|
|
@@ -117887,7 +117935,7 @@ var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
|
|
|
117887
117935
|
var truncate = __webpack_require__(237);
|
|
117888
117936
|
var truncate_default = /*#__PURE__*/__webpack_require__.n(truncate);
|
|
117889
117937
|
|
|
117890
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
117938
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/constants.js
|
|
117891
117939
|
/**
|
|
117892
117940
|
* @public
|
|
117893
117941
|
*/
|
|
@@ -125485,7 +125533,7 @@ if (typeof window === "object") {
|
|
|
125485
125533
|
window['__lib_info_array'].push(__LIB_INFO);
|
|
125486
125534
|
}
|
|
125487
125535
|
|
|
125488
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
125536
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/utils.js
|
|
125489
125537
|
|
|
125490
125538
|
|
|
125491
125539
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -125543,7 +125591,7 @@ function useTooltip(_ref) {
|
|
|
125543
125591
|
className: originalContentClassName
|
|
125544
125592
|
}, originalContent));
|
|
125545
125593
|
}
|
|
125546
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
125594
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/TruncateByLength.js
|
|
125547
125595
|
|
|
125548
125596
|
|
|
125549
125597
|
|
|
@@ -125695,7 +125743,7 @@ function _objectWithoutProperties(e, t) {
|
|
|
125695
125743
|
var external_styled_components_ = __webpack_require__(46);
|
|
125696
125744
|
var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_);
|
|
125697
125745
|
|
|
125698
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
125746
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/styles.js
|
|
125699
125747
|
|
|
125700
125748
|
|
|
125701
125749
|
|
|
@@ -125721,7 +125769,7 @@ var STruncateWidthContainer = external_styled_components_default()(styles_Filter
|
|
|
125721
125769
|
return omissionByCSS ? 'text-overflow: ellipsis;' : '';
|
|
125722
125770
|
}, omissionClassName);
|
|
125723
125771
|
var SWrapper = external_styled_components_default.a.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: inline-block;\n"])));
|
|
125724
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
125772
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/TruncateByWidth.js
|
|
125725
125773
|
|
|
125726
125774
|
|
|
125727
125775
|
|
|
@@ -125807,7 +125855,7 @@ function isWidthOverflow(element) {
|
|
|
125807
125855
|
// debugger
|
|
125808
125856
|
return element.scrollWidth > element.clientWidth;
|
|
125809
125857
|
}
|
|
125810
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
125858
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/Truncate.js
|
|
125811
125859
|
|
|
125812
125860
|
|
|
125813
125861
|
|
|
@@ -126515,7 +126563,7 @@ var es_TruncateMarkup = (_temp = _class = function (_React$Component) {
|
|
|
126515
126563
|
}, _temp);
|
|
126516
126564
|
|
|
126517
126565
|
es_TruncateMarkup.propTypes = false ? undefined : {};
|
|
126518
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
126566
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/MultiLines.js
|
|
126519
126567
|
|
|
126520
126568
|
|
|
126521
126569
|
|
|
@@ -126562,7 +126610,7 @@ var MultiLines_MultiLines = function MultiLines(_ref) {
|
|
|
126562
126610
|
};
|
|
126563
126611
|
|
|
126564
126612
|
/* harmony default export */ var es_MultiLines = (MultiLines_MultiLines);
|
|
126565
|
-
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+
|
|
126613
|
+
// CONCATENATED MODULE: /aoneci/runner/work/source/node_modules/.pnpm/@alicloud+console-components-truncate@1.1.2_@alicloud+console-components@2.2.35_@alifd+_71d6f86247c728034b3f885376901724/node_modules/@alicloud/console-components-truncate/es/index.js
|
|
126566
126614
|
|
|
126567
126615
|
|
|
126568
126616
|
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["defaultValue", "dataSource", "label"];
|
|
3
|
+
var _excluded = ["defaultValue", "dataSource", "label", "type"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { Icon, Select } from '@alicloud/console-components';
|
|
6
|
+
import { Icon, Select, CascaderSelect } from '@alicloud/console-components';
|
|
7
7
|
var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
8
8
|
var _dataSource$, _dataSource$$children;
|
|
9
9
|
var defaultValue = props.defaultValue,
|
|
10
10
|
_props$dataSource = props.dataSource,
|
|
11
11
|
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
12
12
|
label = props.label,
|
|
13
|
+
type = props.type,
|
|
13
14
|
reset = _objectWithoutProperties(props, _excluded);
|
|
14
15
|
var noSelect = dataSource.length < 2 && ((_dataSource$ = dataSource[0]) === null || _dataSource$ === void 0 ? void 0 : (_dataSource$$children = _dataSource$.children) === null || _dataSource$$children === void 0 ? void 0 : _dataSource$$children.length) < 2;
|
|
15
16
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -19,7 +20,7 @@ var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
|
19
20
|
}, label), noSelect ? null : /*#__PURE__*/React.createElement(Icon, {
|
|
20
21
|
type: "caret-down",
|
|
21
22
|
size: "xxs"
|
|
22
|
-
}), /*#__PURE__*/React.createElement(Select, _extends({
|
|
23
|
+
}), type === 'select' ? /*#__PURE__*/React.createElement(Select, _extends({
|
|
23
24
|
className: classNames('condition-select', {
|
|
24
25
|
'rc-search-prefix-no-select': noSelect
|
|
25
26
|
}),
|
|
@@ -38,6 +39,20 @@ var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
|
38
39
|
}, reset, {
|
|
39
40
|
autoWidth: false,
|
|
40
41
|
popupClassName: "rc-search-prefix"
|
|
42
|
+
})) : /*#__PURE__*/React.createElement(CascaderSelect, _extends({
|
|
43
|
+
className: classNames('condition-select', {
|
|
44
|
+
'rc-search-prefix-no-select': noSelect
|
|
45
|
+
}),
|
|
46
|
+
defaultValue: defaultValue,
|
|
47
|
+
hasBorder: false,
|
|
48
|
+
disabled: noSelect,
|
|
49
|
+
autoHighlightFirstItem: false,
|
|
50
|
+
dataSource: dataSource
|
|
51
|
+
// itemRender={({ label, value }) => (<span data-value={value}>{label}</span>)}
|
|
52
|
+
}, reset, {
|
|
53
|
+
autoWidth: false,
|
|
54
|
+
popupClassName: "rc-search-prefix",
|
|
55
|
+
canOnlyCheckLeaf: true
|
|
41
56
|
})));
|
|
42
57
|
};
|
|
43
58
|
export default SearchConditionSelectPrefix;
|
|
@@ -9,19 +9,42 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
9
9
|
import groupBy from 'lodash/groupBy';
|
|
10
10
|
import isArray from 'lodash/isArray';
|
|
11
11
|
import React, { useState, useRef } from 'react';
|
|
12
|
-
import { Button, Icon, Select, ConfigProvider, Field, Checkbox } from '@alicloud/console-components';
|
|
12
|
+
import { Button, Icon, Select, ConfigProvider, Field, Checkbox, CascaderSelect } from '@alicloud/console-components';
|
|
13
13
|
import { isPlainObject, template } from 'lodash';
|
|
14
14
|
import { SearchWarp, MultiBtnWarp } from '../style';
|
|
15
15
|
import SearchConditionSelectPrefix from './InputPrefix';
|
|
16
16
|
import { SEARCH_FILTER_FIELD, SEARCH_FILTER_VALUE_FIELD } from '../constants';
|
|
17
17
|
import message from '../message';
|
|
18
18
|
var AutoComplete = Select.AutoComplete;
|
|
19
|
+
function formatOptionsChildren(children) {
|
|
20
|
+
if (!children) return undefined;
|
|
21
|
+
return children.map(function (o) {
|
|
22
|
+
return {
|
|
23
|
+
label: o.label,
|
|
24
|
+
value: o.dataIndex || o.value || o.label,
|
|
25
|
+
disabled: o.disabled,
|
|
26
|
+
children: formatOptionsChildren(o.children)
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
/**
|
|
20
32
|
*
|
|
21
33
|
* @param IRcSearchOptionsProps options
|
|
22
34
|
* @returns
|
|
23
35
|
*/
|
|
24
|
-
var normalizeOptions = function normalizeOptions(options) {
|
|
36
|
+
var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
37
|
+
if (prefixSelectMode === 'cascader') {
|
|
38
|
+
return options.map(function (o) {
|
|
39
|
+
return {
|
|
40
|
+
label: o.label,
|
|
41
|
+
value: o.dataIndex || o.value || o.label,
|
|
42
|
+
disabled: o.disabled,
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
children: formatOptionsChildren(o.children)
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
25
48
|
var optionsCopy = cloneDeep(options);
|
|
26
49
|
optionsCopy.forEach(function (o) {
|
|
27
50
|
!o.groupName && (o.groupName = message.defaultFilterGroupName);
|
|
@@ -35,7 +58,8 @@ var normalizeOptions = function normalizeOptions(options) {
|
|
|
35
58
|
children: children.map(function (l) {
|
|
36
59
|
return {
|
|
37
60
|
label: l.label,
|
|
38
|
-
value: l.dataIndex
|
|
61
|
+
value: l.dataIndex || l.value,
|
|
62
|
+
disabled: l.disabled
|
|
39
63
|
};
|
|
40
64
|
})
|
|
41
65
|
};
|
|
@@ -60,9 +84,22 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
|
|
|
60
84
|
children: _toConsumableArray(list)
|
|
61
85
|
}];
|
|
62
86
|
};
|
|
87
|
+
var _flatOption = function flatOption() {
|
|
88
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
89
|
+
var flattened = [];
|
|
90
|
+
opts.forEach(function (item) {
|
|
91
|
+
if (item.children) {
|
|
92
|
+
flattened.push.apply(flattened, _toConsumableArray(_flatOption(item.children)));
|
|
93
|
+
} else {
|
|
94
|
+
flattened.push(item);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return flattened;
|
|
98
|
+
};
|
|
63
99
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
64
|
-
var
|
|
65
|
-
|
|
100
|
+
var _flatOption2;
|
|
101
|
+
var opt = (_flatOption2 = _flatOption(options)) === null || _flatOption2 === void 0 ? void 0 : _flatOption2.find(function (o) {
|
|
102
|
+
return getDataIndex(o) === dataIndex;
|
|
66
103
|
});
|
|
67
104
|
var valueLabel = value;
|
|
68
105
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
@@ -97,6 +134,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
|
97
134
|
}
|
|
98
135
|
}, highlightValue), endValue);
|
|
99
136
|
};
|
|
137
|
+
var getDataIndex = function getDataIndex(option) {
|
|
138
|
+
return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
|
|
139
|
+
};
|
|
100
140
|
var ComplexSearch = function ComplexSearch(props) {
|
|
101
141
|
var _props$options = props.options,
|
|
102
142
|
options = _props$options === void 0 ? [] : _props$options,
|
|
@@ -109,9 +149,12 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
109
149
|
_props$suggestions = props.suggestions,
|
|
110
150
|
suggestions = _props$suggestions === void 0 ? [] : _props$suggestions,
|
|
111
151
|
_props$prefix = props.prefix,
|
|
112
|
-
prefix = _props$prefix === void 0 ? 'next-' : _props$prefix
|
|
152
|
+
prefix = _props$prefix === void 0 ? 'next-' : _props$prefix,
|
|
153
|
+
_props$prefixSelectMo = props.prefixSelectMode,
|
|
154
|
+
prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
|
|
155
|
+
prefixSelectItemRender = props.prefixSelectItemRender;
|
|
113
156
|
var _useState = useState(options.find(function (o) {
|
|
114
|
-
return o
|
|
157
|
+
return getDataIndex(o) === defaultSelectedDataIndex;
|
|
115
158
|
})),
|
|
116
159
|
_useState2 = _slicedToArray(_useState, 2),
|
|
117
160
|
selectedFilterType = _useState2[0],
|
|
@@ -137,7 +180,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
137
180
|
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
138
181
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(SEARCH_FILTER_FIELD);
|
|
139
182
|
var defaultFilter = options.find(function (t) {
|
|
140
|
-
return t
|
|
183
|
+
return getDataIndex(t) === defaultDataIndex;
|
|
141
184
|
});
|
|
142
185
|
var highlightItem = function highlightItem(item, searchKey) {
|
|
143
186
|
var label = item.label;
|
|
@@ -154,8 +197,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
154
197
|
*/
|
|
155
198
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
156
199
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
157
|
-
setSelectedFilterType(options.find(function (o) {
|
|
158
|
-
return o
|
|
200
|
+
setSelectedFilterType(_flatOption(options).find(function (o) {
|
|
201
|
+
return getDataIndex(o) === type;
|
|
159
202
|
}));
|
|
160
203
|
resetValue && reset();
|
|
161
204
|
};
|
|
@@ -163,13 +206,13 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
163
206
|
/**
|
|
164
207
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
165
208
|
*/
|
|
166
|
-
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType,
|
|
167
|
-
var isFuzzySearch =
|
|
209
|
+
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
|
|
210
|
+
var isFuzzySearch = _isFuzzy && getValue(SEARCH_FILTER_FIELD);
|
|
168
211
|
|
|
169
212
|
// 如果是模糊搜索,则直接处理
|
|
170
213
|
if (isFuzzySearch) {
|
|
171
214
|
if (actionType !== 'change') {
|
|
172
|
-
handleSearch(option
|
|
215
|
+
handleSearch(getDataIndex(option));
|
|
173
216
|
} else {
|
|
174
217
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
175
218
|
}
|
|
@@ -195,7 +238,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
195
238
|
onSearch(getValue(SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(SEARCH_FILTER_FIELD), options));
|
|
196
239
|
}
|
|
197
240
|
if (selectedFilterType) {
|
|
198
|
-
onSearch(value, selectedFilterType
|
|
241
|
+
onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
|
|
199
242
|
}
|
|
200
243
|
}
|
|
201
244
|
reset();
|
|
@@ -325,15 +368,28 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
325
368
|
}, /*#__PURE__*/React.createElement("div", {
|
|
326
369
|
className: classNames('condition')
|
|
327
370
|
}, selectedFilterType ? /*#__PURE__*/React.createElement(SearchConditionSelectPrefix, {
|
|
328
|
-
|
|
371
|
+
type: prefixSelectMode,
|
|
372
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
329
373
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
330
|
-
defaultValue: selectedFilterType
|
|
374
|
+
defaultValue: getDataIndex(selectedFilterType),
|
|
331
375
|
onChange: function onChange(value) {
|
|
332
376
|
handlerFilterTypeChange(value);
|
|
333
|
-
}
|
|
377
|
+
},
|
|
378
|
+
itemRender: prefixSelectItemRender
|
|
334
379
|
}) : null), /*#__PURE__*/React.createElement("div", {
|
|
335
380
|
className: classNames('forms')
|
|
336
|
-
}, !selectedFilterType ? /*#__PURE__*/React.createElement(
|
|
381
|
+
}, !selectedFilterType && prefixSelectMode === 'cascader' ? /*#__PURE__*/React.createElement(CascaderSelect, {
|
|
382
|
+
className: classNames('main-input', 'multi'),
|
|
383
|
+
hasBorder: false,
|
|
384
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
385
|
+
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? template(message.defaultPlaceHolder)({
|
|
386
|
+
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
387
|
+
}) : ''),
|
|
388
|
+
onChange: function onChange(value) {
|
|
389
|
+
handlerFilterTypeChange(value);
|
|
390
|
+
},
|
|
391
|
+
itemRender: prefixSelectItemRender
|
|
392
|
+
}) : null, !selectedFilterType && prefixSelectMode === 'select' ? /*#__PURE__*/React.createElement(AutoComplete, _extends({}, init(SEARCH_FILTER_FIELD, {
|
|
337
393
|
props: {
|
|
338
394
|
// @ts-ignore
|
|
339
395
|
onChange: function onChange(value, actionType, option) {
|
|
@@ -344,7 +400,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
344
400
|
autoHighlightFirstItem: false
|
|
345
401
|
// @ts-ignore
|
|
346
402
|
,
|
|
347
|
-
itemRender: highlightItem,
|
|
403
|
+
itemRender: prefixSelectItemRender || highlightItem,
|
|
348
404
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? template(message.defaultPlaceHolder)({
|
|
349
405
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
350
406
|
}) : ''),
|
|
@@ -354,7 +410,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
354
410
|
dataSource:
|
|
355
411
|
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
356
412
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
357
|
-
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
413
|
+
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options, prefixSelectMode),
|
|
358
414
|
popupStyle: {
|
|
359
415
|
width: 'auto'
|
|
360
416
|
},
|
package/es/search.js
CHANGED
|
@@ -9,8 +9,6 @@ var SearchWrap = styled.div.withConfig({
|
|
|
9
9
|
})(["height:32px;width:400px;display:inline-block;vertical-align:top;"]);
|
|
10
10
|
export var Search = function Search(props) {
|
|
11
11
|
var className = props.className,
|
|
12
|
-
_props$simple = props.simple,
|
|
13
|
-
simple = _props$simple === void 0 ? false : _props$simple,
|
|
14
12
|
style = props.style;
|
|
15
13
|
var windThemeClass = useWindTheme();
|
|
16
14
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SearchWrap, {
|
|
@@ -10,13 +10,14 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
var _consoleComponents = require("@alicloud/console-components");
|
|
13
|
-
var _excluded = ["defaultValue", "dataSource", "label"];
|
|
13
|
+
var _excluded = ["defaultValue", "dataSource", "label", "type"];
|
|
14
14
|
var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
15
15
|
var _dataSource$, _dataSource$$children;
|
|
16
16
|
var defaultValue = props.defaultValue,
|
|
17
17
|
_props$dataSource = props.dataSource,
|
|
18
18
|
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
19
19
|
label = props.label,
|
|
20
|
+
type = props.type,
|
|
20
21
|
reset = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
21
22
|
var noSelect = dataSource.length < 2 && ((_dataSource$ = dataSource[0]) === null || _dataSource$ === void 0 ? void 0 : (_dataSource$$children = _dataSource$.children) === null || _dataSource$$children === void 0 ? void 0 : _dataSource$$children.length) < 2;
|
|
22
23
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -26,7 +27,7 @@ var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
|
26
27
|
}, label), noSelect ? null : /*#__PURE__*/_react.default.createElement(_consoleComponents.Icon, {
|
|
27
28
|
type: "caret-down",
|
|
28
29
|
size: "xxs"
|
|
29
|
-
}), /*#__PURE__*/_react.default.createElement(_consoleComponents.Select, (0, _extends2.default)({
|
|
30
|
+
}), type === 'select' ? /*#__PURE__*/_react.default.createElement(_consoleComponents.Select, (0, _extends2.default)({
|
|
30
31
|
className: (0, _classnames.default)('condition-select', {
|
|
31
32
|
'rc-search-prefix-no-select': noSelect
|
|
32
33
|
}),
|
|
@@ -45,6 +46,20 @@ var SearchConditionSelectPrefix = function SearchConditionSelectPrefix(props) {
|
|
|
45
46
|
}, reset, {
|
|
46
47
|
autoWidth: false,
|
|
47
48
|
popupClassName: "rc-search-prefix"
|
|
49
|
+
})) : /*#__PURE__*/_react.default.createElement(_consoleComponents.CascaderSelect, (0, _extends2.default)({
|
|
50
|
+
className: (0, _classnames.default)('condition-select', {
|
|
51
|
+
'rc-search-prefix-no-select': noSelect
|
|
52
|
+
}),
|
|
53
|
+
defaultValue: defaultValue,
|
|
54
|
+
hasBorder: false,
|
|
55
|
+
disabled: noSelect,
|
|
56
|
+
autoHighlightFirstItem: false,
|
|
57
|
+
dataSource: dataSource
|
|
58
|
+
// itemRender={({ label, value }) => (<span data-value={value}>{label}</span>)}
|
|
59
|
+
}, reset, {
|
|
60
|
+
autoWidth: false,
|
|
61
|
+
popupClassName: "rc-search-prefix",
|
|
62
|
+
canOnlyCheckLeaf: true
|
|
48
63
|
})));
|
|
49
64
|
};
|
|
50
65
|
var _default = exports.default = SearchConditionSelectPrefix;
|
|
@@ -21,17 +21,39 @@ var _style = require("../style");
|
|
|
21
21
|
var _InputPrefix = _interopRequireDefault(require("./InputPrefix"));
|
|
22
22
|
var _constants = require("../constants");
|
|
23
23
|
var _message = _interopRequireDefault(require("../message"));
|
|
24
|
-
function
|
|
25
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
24
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
26
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
27
26
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
28
27
|
var AutoComplete = _consoleComponents.Select.AutoComplete;
|
|
28
|
+
function formatOptionsChildren(children) {
|
|
29
|
+
if (!children) return undefined;
|
|
30
|
+
return children.map(function (o) {
|
|
31
|
+
return {
|
|
32
|
+
label: o.label,
|
|
33
|
+
value: o.dataIndex || o.value || o.label,
|
|
34
|
+
disabled: o.disabled,
|
|
35
|
+
children: formatOptionsChildren(o.children)
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
/**
|
|
30
41
|
*
|
|
31
42
|
* @param IRcSearchOptionsProps options
|
|
32
43
|
* @returns
|
|
33
44
|
*/
|
|
34
|
-
var normalizeOptions = function normalizeOptions(options) {
|
|
45
|
+
var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
|
|
46
|
+
if (prefixSelectMode === 'cascader') {
|
|
47
|
+
return options.map(function (o) {
|
|
48
|
+
return {
|
|
49
|
+
label: o.label,
|
|
50
|
+
value: o.dataIndex || o.value || o.label,
|
|
51
|
+
disabled: o.disabled,
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
children: formatOptionsChildren(o.children)
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
35
57
|
var optionsCopy = (0, _cloneDeep.default)(options);
|
|
36
58
|
optionsCopy.forEach(function (o) {
|
|
37
59
|
!o.groupName && (o.groupName = _message.default.defaultFilterGroupName);
|
|
@@ -45,7 +67,8 @@ var normalizeOptions = function normalizeOptions(options) {
|
|
|
45
67
|
children: children.map(function (l) {
|
|
46
68
|
return {
|
|
47
69
|
label: l.label,
|
|
48
|
-
value: l.dataIndex
|
|
70
|
+
value: l.dataIndex || l.value,
|
|
71
|
+
disabled: l.disabled
|
|
49
72
|
};
|
|
50
73
|
})
|
|
51
74
|
};
|
|
@@ -70,9 +93,22 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
|
|
|
70
93
|
children: (0, _toConsumableArray2.default)(list)
|
|
71
94
|
}];
|
|
72
95
|
};
|
|
96
|
+
var _flatOption = function flatOption() {
|
|
97
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
98
|
+
var flattened = [];
|
|
99
|
+
opts.forEach(function (item) {
|
|
100
|
+
if (item.children) {
|
|
101
|
+
flattened.push.apply(flattened, (0, _toConsumableArray2.default)(_flatOption(item.children)));
|
|
102
|
+
} else {
|
|
103
|
+
flattened.push(item);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return flattened;
|
|
107
|
+
};
|
|
73
108
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
74
|
-
var
|
|
75
|
-
|
|
109
|
+
var _flatOption2;
|
|
110
|
+
var opt = (_flatOption2 = _flatOption(options)) === null || _flatOption2 === void 0 ? void 0 : _flatOption2.find(function (o) {
|
|
111
|
+
return getDataIndex(o) === dataIndex;
|
|
76
112
|
});
|
|
77
113
|
var valueLabel = value;
|
|
78
114
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
@@ -107,6 +143,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
|
|
|
107
143
|
}
|
|
108
144
|
}, highlightValue), endValue);
|
|
109
145
|
};
|
|
146
|
+
var getDataIndex = function getDataIndex(option) {
|
|
147
|
+
return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
|
|
148
|
+
};
|
|
110
149
|
var ComplexSearch = function ComplexSearch(props) {
|
|
111
150
|
var _props$options = props.options,
|
|
112
151
|
options = _props$options === void 0 ? [] : _props$options,
|
|
@@ -119,9 +158,12 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
119
158
|
_props$suggestions = props.suggestions,
|
|
120
159
|
suggestions = _props$suggestions === void 0 ? [] : _props$suggestions,
|
|
121
160
|
_props$prefix = props.prefix,
|
|
122
|
-
prefix = _props$prefix === void 0 ? 'next-' : _props$prefix
|
|
161
|
+
prefix = _props$prefix === void 0 ? 'next-' : _props$prefix,
|
|
162
|
+
_props$prefixSelectMo = props.prefixSelectMode,
|
|
163
|
+
prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
|
|
164
|
+
prefixSelectItemRender = props.prefixSelectItemRender;
|
|
123
165
|
var _useState = (0, _react.useState)(options.find(function (o) {
|
|
124
|
-
return o
|
|
166
|
+
return getDataIndex(o) === defaultSelectedDataIndex;
|
|
125
167
|
})),
|
|
126
168
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
127
169
|
selectedFilterType = _useState2[0],
|
|
@@ -147,7 +189,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
147
189
|
// 计算视图,根据内部状态和输入的 props 决定一些值
|
|
148
190
|
var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(_constants.SEARCH_FILTER_FIELD);
|
|
149
191
|
var defaultFilter = options.find(function (t) {
|
|
150
|
-
return t
|
|
192
|
+
return getDataIndex(t) === defaultDataIndex;
|
|
151
193
|
});
|
|
152
194
|
var highlightItem = function highlightItem(item, searchKey) {
|
|
153
195
|
var label = item.label;
|
|
@@ -164,8 +206,8 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
164
206
|
*/
|
|
165
207
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
166
208
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
167
|
-
setSelectedFilterType(options.find(function (o) {
|
|
168
|
-
return o
|
|
209
|
+
setSelectedFilterType(_flatOption(options).find(function (o) {
|
|
210
|
+
return getDataIndex(o) === type;
|
|
169
211
|
}));
|
|
170
212
|
resetValue && reset();
|
|
171
213
|
};
|
|
@@ -173,13 +215,13 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
173
215
|
/**
|
|
174
216
|
* 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
|
|
175
217
|
*/
|
|
176
|
-
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType,
|
|
177
|
-
var isFuzzySearch =
|
|
218
|
+
var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
|
|
219
|
+
var isFuzzySearch = _isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
|
|
178
220
|
|
|
179
221
|
// 如果是模糊搜索,则直接处理
|
|
180
222
|
if (isFuzzySearch) {
|
|
181
223
|
if (actionType !== 'change') {
|
|
182
|
-
handleSearch(option
|
|
224
|
+
handleSearch(getDataIndex(option));
|
|
183
225
|
} else {
|
|
184
226
|
onSuggest && onSuggest(value, defaultDataIndex || '');
|
|
185
227
|
}
|
|
@@ -205,7 +247,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
205
247
|
onSearch(getValue(_constants.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(_constants.SEARCH_FILTER_FIELD), options));
|
|
206
248
|
}
|
|
207
249
|
if (selectedFilterType) {
|
|
208
|
-
onSearch(value, selectedFilterType
|
|
250
|
+
onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
|
|
209
251
|
}
|
|
210
252
|
}
|
|
211
253
|
reset();
|
|
@@ -335,15 +377,28 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
335
377
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
336
378
|
className: (0, _classnames.default)('condition')
|
|
337
379
|
}, selectedFilterType ? /*#__PURE__*/_react.default.createElement(_InputPrefix.default, {
|
|
338
|
-
|
|
380
|
+
type: prefixSelectMode,
|
|
381
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
339
382
|
label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
|
|
340
|
-
defaultValue: selectedFilterType
|
|
383
|
+
defaultValue: getDataIndex(selectedFilterType),
|
|
341
384
|
onChange: function onChange(value) {
|
|
342
385
|
handlerFilterTypeChange(value);
|
|
343
|
-
}
|
|
386
|
+
},
|
|
387
|
+
itemRender: prefixSelectItemRender
|
|
344
388
|
}) : null), /*#__PURE__*/_react.default.createElement("div", {
|
|
345
389
|
className: (0, _classnames.default)('forms')
|
|
346
|
-
}, !selectedFilterType ? /*#__PURE__*/_react.default.createElement(
|
|
390
|
+
}, !selectedFilterType && prefixSelectMode === 'cascader' ? /*#__PURE__*/_react.default.createElement(_consoleComponents.CascaderSelect, {
|
|
391
|
+
className: (0, _classnames.default)('main-input', 'multi'),
|
|
392
|
+
hasBorder: false,
|
|
393
|
+
dataSource: normalizeOptions(options, prefixSelectMode),
|
|
394
|
+
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? (0, _lodash.template)(_message.default.defaultPlaceHolder)({
|
|
395
|
+
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
396
|
+
}) : ''),
|
|
397
|
+
onChange: function onChange(value) {
|
|
398
|
+
handlerFilterTypeChange(value);
|
|
399
|
+
},
|
|
400
|
+
itemRender: prefixSelectItemRender
|
|
401
|
+
}) : null, !selectedFilterType && prefixSelectMode === 'select' ? /*#__PURE__*/_react.default.createElement(AutoComplete, (0, _extends2.default)({}, init(_constants.SEARCH_FILTER_FIELD, {
|
|
347
402
|
props: {
|
|
348
403
|
// @ts-ignore
|
|
349
404
|
onChange: function onChange(value, actionType, option) {
|
|
@@ -354,7 +409,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
354
409
|
autoHighlightFirstItem: false
|
|
355
410
|
// @ts-ignore
|
|
356
411
|
,
|
|
357
|
-
itemRender: highlightItem,
|
|
412
|
+
itemRender: prefixSelectItemRender || highlightItem,
|
|
358
413
|
placeholder: placeholder || (defaultFilter !== null && defaultFilter !== void 0 && defaultFilter.label ? (0, _lodash.template)(_message.default.defaultPlaceHolder)({
|
|
359
414
|
value: defaultFilter === null || defaultFilter === void 0 ? void 0 : defaultFilter.label
|
|
360
415
|
}) : ''),
|
|
@@ -364,7 +419,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
364
419
|
dataSource:
|
|
365
420
|
// 如果是指定了默认的筛选类型或者是直接指定模糊搜索模式 ,并且用户在这个输入框里面已经输入了值
|
|
366
421
|
// 则表示需要模糊搜索,调用 handleSuggest
|
|
367
|
-
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options),
|
|
422
|
+
isFuzzy ? normalizeSuggestion(suggestions) : normalizeOptions(options, prefixSelectMode),
|
|
368
423
|
popupStyle: {
|
|
369
424
|
width: 'auto'
|
|
370
425
|
},
|
package/lib/search.js
CHANGED
|
@@ -16,8 +16,6 @@ var SearchWrap = _styledComponents.default.div.withConfig({
|
|
|
16
16
|
})(["height:32px;width:400px;display:inline-block;vertical-align:top;"]);
|
|
17
17
|
var Search = exports.Search = function Search(props) {
|
|
18
18
|
var className = props.className,
|
|
19
|
-
_props$simple = props.simple,
|
|
20
|
-
simple = _props$simple === void 0 ? false : _props$simple,
|
|
21
19
|
style = props.style;
|
|
22
20
|
var windThemeClass = (0, _useCssVar.useWindTheme)();
|
|
23
21
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(SearchWrap, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
/**
|
|
2
3
|
* 这是IRcSearchProps的说明。breezr-docs支持从源码中提取接口信息并文档化,因此你可以使用接口来定义Props,从而能便捷地将Props的信息通过文档透出。
|
|
3
4
|
*
|
|
@@ -63,4 +64,14 @@ export interface IRcSearchProps {
|
|
|
63
64
|
* 样式 class 前缀
|
|
64
65
|
*/
|
|
65
66
|
prefix?: string;
|
|
67
|
+
/**
|
|
68
|
+
* 前缀选择器类型
|
|
69
|
+
*/
|
|
70
|
+
prefixSelectMode?: 'select' | 'cascader';
|
|
71
|
+
/**
|
|
72
|
+
* 前缀选择器 item 渲染
|
|
73
|
+
* @param item
|
|
74
|
+
* @returns
|
|
75
|
+
*/
|
|
76
|
+
prefixSelectItemRender?: (item: any) => React.ReactNode;
|
|
66
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alicloud/console-components-search",
|
|
3
|
-
"version": "0.2.37
|
|
3
|
+
"version": "0.2.37",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"@alicloud/console-toolkit-preset-component": "^1.2.8",
|
|
10
10
|
"@alicloud/console-toolkit-preset-docs": "^1.0.34",
|
|
11
11
|
"@alifd/next": "^1.27.29",
|
|
12
|
+
"@babel/core": "^7.28.0",
|
|
12
13
|
"@types/classnames": "^2.3.4",
|
|
13
14
|
"@types/js-cookie": "^3.0.1",
|
|
14
15
|
"@types/react": "^17.0.0",
|
|
@@ -17,6 +18,8 @@
|
|
|
17
18
|
"prettier": "^2.2.1",
|
|
18
19
|
"react": "^17.0.1",
|
|
19
20
|
"react-dom": "^17.0.1",
|
|
21
|
+
"react-router": "^5.0.0",
|
|
22
|
+
"react-router-dom": "^5.0.0",
|
|
20
23
|
"serve": "^11.3.2",
|
|
21
24
|
"styled-components": "^5.2.1",
|
|
22
25
|
"typescript": "^4.1.3"
|