@alicloud/console-components-search 0.2.37-alpha.5 → 0.2.37-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demos/demo1.demo.tsx +117 -1
- package/dist/index.js +18 -5
- package/es/ComplexSearch/index.js +15 -2
- package/lib/ComplexSearch/index.js +15 -2
- package/package.json +1 -1
package/demos/demo1.demo.tsx
CHANGED
|
@@ -58,6 +58,121 @@ const options2 = [
|
|
|
58
58
|
},
|
|
59
59
|
];
|
|
60
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
|
+
})),
|
|
158
|
+
},
|
|
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
|
+
];
|
|
174
|
+
|
|
175
|
+
|
|
61
176
|
const Demo1: React.FC<{}> = (props) => {
|
|
62
177
|
const [filters, setFilters] = useState<any>([
|
|
63
178
|
{ label: '实例名称', value: 'xxxxxx', dataIndex: 'name' },
|
|
@@ -108,9 +223,10 @@ const Demo1: React.FC<{}> = (props) => {
|
|
|
108
223
|
<Search
|
|
109
224
|
defaultDataIndex="name"
|
|
110
225
|
// defaultSelectedDataIndex="name"
|
|
111
|
-
options={
|
|
226
|
+
options={options3}
|
|
112
227
|
prefixSelectMode="cascader"
|
|
113
228
|
onSearch={(value, dataIndex, extra) => {
|
|
229
|
+
console.log(value, dataIndex, extra);
|
|
114
230
|
// @ts-ignore
|
|
115
231
|
setFilters([...filters, extra]);
|
|
116
232
|
}}
|
package/dist/index.js
CHANGED
|
@@ -90277,15 +90277,28 @@ var normalizeSelectDataSource = function (title, list) {
|
|
|
90277
90277
|
},
|
|
90278
90278
|
];
|
|
90279
90279
|
};
|
|
90280
|
+
var flatOption = function (opts) {
|
|
90281
|
+
if (opts === void 0) { opts = []; }
|
|
90282
|
+
var flattened = [];
|
|
90283
|
+
opts.forEach(function (item) {
|
|
90284
|
+
if (item.children) {
|
|
90285
|
+
flattened.push.apply(flattened, flatOption(item.children));
|
|
90286
|
+
}
|
|
90287
|
+
else {
|
|
90288
|
+
flattened.push(item);
|
|
90289
|
+
}
|
|
90290
|
+
});
|
|
90291
|
+
return flattened;
|
|
90292
|
+
};
|
|
90280
90293
|
var normalizeSearchOptions = function (dataIndex, value, options) {
|
|
90281
|
-
var _a, _b, _c;
|
|
90282
|
-
var opt = options === null ||
|
|
90294
|
+
var _a, _b, _c, _d;
|
|
90295
|
+
var opt = (_a = flatOption(options)) === null || _a === void 0 ? void 0 : _a.find(function (o) { return getDataIndex(o) === dataIndex; });
|
|
90283
90296
|
var valueLabel = value;
|
|
90284
90297
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
|
|
90285
|
-
valueLabel = (
|
|
90298
|
+
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;
|
|
90286
90299
|
}
|
|
90287
90300
|
if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'multiple') {
|
|
90288
|
-
valueLabel = (
|
|
90301
|
+
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('/');
|
|
90289
90302
|
}
|
|
90290
90303
|
return {
|
|
90291
90304
|
label: opt === null || opt === void 0 ? void 0 : opt.label,
|
|
@@ -90337,7 +90350,7 @@ var ComplexSearch = function (props) {
|
|
|
90337
90350
|
*/
|
|
90338
90351
|
var handlerFilterTypeChange = function (type, resetValue) {
|
|
90339
90352
|
if (resetValue === void 0) { resetValue = true; }
|
|
90340
|
-
setSelectedFilterType(options.find(function (o) { return getDataIndex(o) === type; }));
|
|
90353
|
+
setSelectedFilterType(flatOption(options).find(function (o) { return getDataIndex(o) === type; }));
|
|
90341
90354
|
resetValue && reset();
|
|
90342
90355
|
};
|
|
90343
90356
|
/**
|
|
@@ -84,8 +84,21 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
|
|
|
84
84
|
children: _toConsumableArray(list)
|
|
85
85
|
}];
|
|
86
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
|
+
};
|
|
87
99
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
88
|
-
var
|
|
100
|
+
var _flatOption2;
|
|
101
|
+
var opt = (_flatOption2 = _flatOption(options)) === null || _flatOption2 === void 0 ? void 0 : _flatOption2.find(function (o) {
|
|
89
102
|
return getDataIndex(o) === dataIndex;
|
|
90
103
|
});
|
|
91
104
|
var valueLabel = value;
|
|
@@ -184,7 +197,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
184
197
|
*/
|
|
185
198
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
186
199
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
187
|
-
setSelectedFilterType(options.find(function (o) {
|
|
200
|
+
setSelectedFilterType(_flatOption(options).find(function (o) {
|
|
188
201
|
return getDataIndex(o) === type;
|
|
189
202
|
}));
|
|
190
203
|
resetValue && reset();
|
|
@@ -93,8 +93,21 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
|
|
|
93
93
|
children: (0, _toConsumableArray2.default)(list)
|
|
94
94
|
}];
|
|
95
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
|
+
};
|
|
96
108
|
var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
|
|
97
|
-
var
|
|
109
|
+
var _flatOption2;
|
|
110
|
+
var opt = (_flatOption2 = _flatOption(options)) === null || _flatOption2 === void 0 ? void 0 : _flatOption2.find(function (o) {
|
|
98
111
|
return getDataIndex(o) === dataIndex;
|
|
99
112
|
});
|
|
100
113
|
var valueLabel = value;
|
|
@@ -193,7 +206,7 @@ var ComplexSearch = function ComplexSearch(props) {
|
|
|
193
206
|
*/
|
|
194
207
|
var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
|
|
195
208
|
var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
196
|
-
setSelectedFilterType(options.find(function (o) {
|
|
209
|
+
setSelectedFilterType(_flatOption(options).find(function (o) {
|
|
197
210
|
return getDataIndex(o) === type;
|
|
198
211
|
}));
|
|
199
212
|
resetValue && reset();
|