@alicloud/console-components-search 0.2.37-alpha.4 → 0.2.37-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,7 +223,7 @@ const Demo1: React.FC<{}> = (props) => {
108
223
  <Search
109
224
  defaultDataIndex="name"
110
225
  // defaultSelectedDataIndex="name"
111
- options={options}
226
+ options={options3}
112
227
  prefixSelectMode="cascader"
113
228
  onSearch={(value, dataIndex, extra) => {
114
229
  // @ts-ignore
package/dist/index.js CHANGED
@@ -90217,7 +90217,7 @@ function formatOptionsChildren(children) {
90217
90217
  return children.map(function (o) {
90218
90218
  return {
90219
90219
  label: o.label,
90220
- value: o.value || o.dataIndex || o.label,
90220
+ value: o.dataIndex || o.value || o.label,
90221
90221
  disabled: o.disabled,
90222
90222
  children: formatOptionsChildren(o.children),
90223
90223
  };
@@ -90233,7 +90233,7 @@ var normalizeOptions = function (options, prefixSelectMode) {
90233
90233
  return options.map(function (o) {
90234
90234
  return {
90235
90235
  label: o.label,
90236
- value: o.value || o.dataIndex || o.label,
90236
+ value: o.dataIndex || o.value || o.label,
90237
90237
  disabled: o.disabled,
90238
90238
  // @ts-ignore
90239
90239
  children: formatOptionsChildren(o.children),
@@ -90249,7 +90249,7 @@ var normalizeOptions = function (options, prefixSelectMode) {
90249
90249
  children: children.map(function (l) {
90250
90250
  return {
90251
90251
  label: l.label,
90252
- value: l.dataIndex,
90252
+ value: l.dataIndex || l.value,
90253
90253
  disabled: l.disabled,
90254
90254
  };
90255
90255
  }),
@@ -90279,7 +90279,7 @@ var normalizeSelectDataSource = function (title, list) {
90279
90279
  };
90280
90280
  var normalizeSearchOptions = function (dataIndex, value, options) {
90281
90281
  var _a, _b, _c;
90282
- var opt = options === null || options === void 0 ? void 0 : options.find(function (o) { return o.dataIndex === dataIndex; });
90282
+ var opt = options === null || options === void 0 ? void 0 : options.find(function (o) { return getDataIndex(o) === dataIndex; });
90283
90283
  var valueLabel = value;
90284
90284
  if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
90285
90285
  valueLabel = (_b = (_a = opt.templateProps) === null || _a === void 0 ? void 0 : _a.dataSource.find(function (d) { return d.value === value; })) === null || _b === void 0 ? void 0 : _b.label;
@@ -90304,9 +90304,12 @@ var highlightKeyword = function (value, keywords) {
90304
90304
  react_1.default.createElement("span", { style: { color: 'var(--color-brand1-6)' } }, highlightValue),
90305
90305
  endValue));
90306
90306
  };
90307
+ var getDataIndex = function (option) {
90308
+ return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
90309
+ };
90307
90310
  var ComplexSearch = function (props) {
90308
90311
  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;
90309
- var _e = (0, react_1.useState)(options.find(function (o) { return o.dataIndex === defaultSelectedDataIndex; })), selectedFilterType = _e[0], setSelectedFilterType = _e[1];
90312
+ var _e = (0, react_1.useState)(options.find(function (o) { return getDataIndex(o) === defaultSelectedDataIndex; })), selectedFilterType = _e[0], setSelectedFilterType = _e[1];
90310
90313
  var _f = (0, react_1.useState)(false), focused = _f[0], setFocused = _f[1];
90311
90314
  var autoRef = (0, react_1.useRef)(null);
90312
90315
  var field = console_components_1.Field.useField();
@@ -90321,7 +90324,7 @@ var ComplexSearch = function (props) {
90321
90324
  };
90322
90325
  // 计算视图,根据内部状态和输入的 props 决定一些值
90323
90326
  var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(constants_1.SEARCH_FILTER_FIELD);
90324
- var defaultFilter = options.find(function (t) { return t.dataIndex === defaultDataIndex; });
90327
+ var defaultFilter = options.find(function (t) { return getDataIndex(t) === defaultDataIndex; });
90325
90328
  var highlightItem = function (item, searchKey) {
90326
90329
  var label = item.label;
90327
90330
  if (searchKey && searchKey.length) {
@@ -90334,18 +90337,30 @@ var ComplexSearch = function (props) {
90334
90337
  */
90335
90338
  var handlerFilterTypeChange = function (type, resetValue) {
90336
90339
  if (resetValue === void 0) { resetValue = true; }
90337
- setSelectedFilterType(options.find(function (o) { return o.dataIndex === type; }));
90340
+ var flatOption = function (opts) {
90341
+ var flattened = [];
90342
+ opts.forEach(function (item) {
90343
+ if (item.children) {
90344
+ flattened.push.apply(flattened, flatOption(item.children));
90345
+ }
90346
+ else {
90347
+ flattened.push(item);
90348
+ }
90349
+ });
90350
+ return flattened;
90351
+ };
90352
+ setSelectedFilterType(flatOption(options).find(function (o) { return getDataIndex(o) === type; }));
90338
90353
  resetValue && reset();
90339
90354
  };
90340
90355
  /**
90341
90356
  * 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
90342
90357
  */
90343
- var handlerFilterTypeInput = function (value, actionType, isFuzzy, option) {
90344
- var isFuzzySearch = isFuzzy && getValue(constants_1.SEARCH_FILTER_FIELD);
90358
+ var handlerFilterTypeInput = function (value, actionType, _isFuzzy, option) {
90359
+ var isFuzzySearch = _isFuzzy && getValue(constants_1.SEARCH_FILTER_FIELD);
90345
90360
  // 如果是模糊搜索,则直接处理
90346
90361
  if (isFuzzySearch) {
90347
90362
  if (actionType !== 'change') {
90348
- handleSearch(option.dataIndex);
90363
+ handleSearch(getDataIndex(option));
90349
90364
  }
90350
90365
  else {
90351
90366
  onSuggest && onSuggest(value, defaultDataIndex || '');
@@ -90371,7 +90386,7 @@ var ComplexSearch = function (props) {
90371
90386
  onSearch(getValue(constants_1.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(constants_1.SEARCH_FILTER_FIELD), options));
90372
90387
  }
90373
90388
  if (selectedFilterType) {
90374
- onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
90389
+ onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
90375
90390
  }
90376
90391
  }
90377
90392
  reset();
@@ -90450,7 +90465,7 @@ var ComplexSearch = function (props) {
90450
90465
  react_1.default.createElement("div", { className: (0, classnames_1.default)('left-wrap', "".concat(prefix, "input"), {
90451
90466
  focus: focused,
90452
90467
  }) },
90453
- 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: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex, onChange: function (value) {
90468
+ 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) {
90454
90469
  handlerFilterTypeChange(value);
90455
90470
  }, itemRender: prefixSelectItemRender })) : null),
90456
90471
  react_1.default.createElement("div", { className: (0, classnames_1.default)('forms') },
@@ -21,7 +21,7 @@ function formatOptionsChildren(children) {
21
21
  return children.map(function (o) {
22
22
  return {
23
23
  label: o.label,
24
- value: o.value || o.dataIndex || o.label,
24
+ value: o.dataIndex || o.value || o.label,
25
25
  disabled: o.disabled,
26
26
  children: formatOptionsChildren(o.children)
27
27
  };
@@ -38,7 +38,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
38
38
  return options.map(function (o) {
39
39
  return {
40
40
  label: o.label,
41
- value: o.value || o.dataIndex || o.label,
41
+ value: o.dataIndex || o.value || o.label,
42
42
  disabled: o.disabled,
43
43
  // @ts-ignore
44
44
  children: formatOptionsChildren(o.children)
@@ -58,7 +58,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
58
58
  children: children.map(function (l) {
59
59
  return {
60
60
  label: l.label,
61
- value: l.dataIndex,
61
+ value: l.dataIndex || l.value,
62
62
  disabled: l.disabled
63
63
  };
64
64
  })
@@ -86,7 +86,7 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
86
86
  };
87
87
  var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
88
88
  var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
89
- return o.dataIndex === dataIndex;
89
+ return getDataIndex(o) === dataIndex;
90
90
  });
91
91
  var valueLabel = value;
92
92
  if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
@@ -121,6 +121,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
121
121
  }
122
122
  }, highlightValue), endValue);
123
123
  };
124
+ var getDataIndex = function getDataIndex(option) {
125
+ return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
126
+ };
124
127
  var ComplexSearch = function ComplexSearch(props) {
125
128
  var _props$options = props.options,
126
129
  options = _props$options === void 0 ? [] : _props$options,
@@ -138,7 +141,7 @@ var ComplexSearch = function ComplexSearch(props) {
138
141
  prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
139
142
  prefixSelectItemRender = props.prefixSelectItemRender;
140
143
  var _useState = useState(options.find(function (o) {
141
- return o.dataIndex === defaultSelectedDataIndex;
144
+ return getDataIndex(o) === defaultSelectedDataIndex;
142
145
  })),
143
146
  _useState2 = _slicedToArray(_useState, 2),
144
147
  selectedFilterType = _useState2[0],
@@ -164,7 +167,7 @@ var ComplexSearch = function ComplexSearch(props) {
164
167
  // 计算视图,根据内部状态和输入的 props 决定一些值
165
168
  var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(SEARCH_FILTER_FIELD);
166
169
  var defaultFilter = options.find(function (t) {
167
- return t.dataIndex === defaultDataIndex;
170
+ return getDataIndex(t) === defaultDataIndex;
168
171
  });
169
172
  var highlightItem = function highlightItem(item, searchKey) {
170
173
  var label = item.label;
@@ -181,8 +184,19 @@ var ComplexSearch = function ComplexSearch(props) {
181
184
  */
182
185
  var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
183
186
  var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
184
- setSelectedFilterType(options.find(function (o) {
185
- return o.dataIndex === type;
187
+ var _flatOption = function flatOption(opts) {
188
+ var flattened = [];
189
+ opts.forEach(function (item) {
190
+ if (item.children) {
191
+ flattened.push.apply(flattened, _toConsumableArray(_flatOption(item.children)));
192
+ } else {
193
+ flattened.push(item);
194
+ }
195
+ });
196
+ return flattened;
197
+ };
198
+ setSelectedFilterType(_flatOption(options).find(function (o) {
199
+ return getDataIndex(o) === type;
186
200
  }));
187
201
  resetValue && reset();
188
202
  };
@@ -190,13 +204,13 @@ var ComplexSearch = function ComplexSearch(props) {
190
204
  /**
191
205
  * 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
192
206
  */
193
- var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy, option) {
194
- var isFuzzySearch = isFuzzy && getValue(SEARCH_FILTER_FIELD);
207
+ var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
208
+ var isFuzzySearch = _isFuzzy && getValue(SEARCH_FILTER_FIELD);
195
209
 
196
210
  // 如果是模糊搜索,则直接处理
197
211
  if (isFuzzySearch) {
198
212
  if (actionType !== 'change') {
199
- handleSearch(option.dataIndex);
213
+ handleSearch(getDataIndex(option));
200
214
  } else {
201
215
  onSuggest && onSuggest(value, defaultDataIndex || '');
202
216
  }
@@ -222,7 +236,7 @@ var ComplexSearch = function ComplexSearch(props) {
222
236
  onSearch(getValue(SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(SEARCH_FILTER_FIELD), options));
223
237
  }
224
238
  if (selectedFilterType) {
225
- onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
239
+ onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
226
240
  }
227
241
  }
228
242
  reset();
@@ -355,7 +369,7 @@ var ComplexSearch = function ComplexSearch(props) {
355
369
  type: prefixSelectMode,
356
370
  dataSource: normalizeOptions(options, prefixSelectMode),
357
371
  label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
358
- defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
372
+ defaultValue: getDataIndex(selectedFilterType),
359
373
  onChange: function onChange(value) {
360
374
  handlerFilterTypeChange(value);
361
375
  },
@@ -30,7 +30,7 @@ function formatOptionsChildren(children) {
30
30
  return children.map(function (o) {
31
31
  return {
32
32
  label: o.label,
33
- value: o.value || o.dataIndex || o.label,
33
+ value: o.dataIndex || o.value || o.label,
34
34
  disabled: o.disabled,
35
35
  children: formatOptionsChildren(o.children)
36
36
  };
@@ -47,7 +47,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
47
47
  return options.map(function (o) {
48
48
  return {
49
49
  label: o.label,
50
- value: o.value || o.dataIndex || o.label,
50
+ value: o.dataIndex || o.value || o.label,
51
51
  disabled: o.disabled,
52
52
  // @ts-ignore
53
53
  children: formatOptionsChildren(o.children)
@@ -67,7 +67,7 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
67
67
  children: children.map(function (l) {
68
68
  return {
69
69
  label: l.label,
70
- value: l.dataIndex,
70
+ value: l.dataIndex || l.value,
71
71
  disabled: l.disabled
72
72
  };
73
73
  })
@@ -95,7 +95,7 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
95
95
  };
96
96
  var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
97
97
  var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
98
- return o.dataIndex === dataIndex;
98
+ return getDataIndex(o) === dataIndex;
99
99
  });
100
100
  var valueLabel = value;
101
101
  if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
@@ -130,6 +130,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
130
130
  }
131
131
  }, highlightValue), endValue);
132
132
  };
133
+ var getDataIndex = function getDataIndex(option) {
134
+ return (option === null || option === void 0 ? void 0 : option.dataIndex) || (option === null || option === void 0 ? void 0 : option.value);
135
+ };
133
136
  var ComplexSearch = function ComplexSearch(props) {
134
137
  var _props$options = props.options,
135
138
  options = _props$options === void 0 ? [] : _props$options,
@@ -147,7 +150,7 @@ var ComplexSearch = function ComplexSearch(props) {
147
150
  prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
148
151
  prefixSelectItemRender = props.prefixSelectItemRender;
149
152
  var _useState = (0, _react.useState)(options.find(function (o) {
150
- return o.dataIndex === defaultSelectedDataIndex;
153
+ return getDataIndex(o) === defaultSelectedDataIndex;
151
154
  })),
152
155
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
153
156
  selectedFilterType = _useState2[0],
@@ -173,7 +176,7 @@ var ComplexSearch = function ComplexSearch(props) {
173
176
  // 计算视图,根据内部状态和输入的 props 决定一些值
174
177
  var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(_constants.SEARCH_FILTER_FIELD);
175
178
  var defaultFilter = options.find(function (t) {
176
- return t.dataIndex === defaultDataIndex;
179
+ return getDataIndex(t) === defaultDataIndex;
177
180
  });
178
181
  var highlightItem = function highlightItem(item, searchKey) {
179
182
  var label = item.label;
@@ -190,8 +193,19 @@ var ComplexSearch = function ComplexSearch(props) {
190
193
  */
191
194
  var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
192
195
  var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
193
- setSelectedFilterType(options.find(function (o) {
194
- return o.dataIndex === type;
196
+ var _flatOption = function flatOption(opts) {
197
+ var flattened = [];
198
+ opts.forEach(function (item) {
199
+ if (item.children) {
200
+ flattened.push.apply(flattened, (0, _toConsumableArray2.default)(_flatOption(item.children)));
201
+ } else {
202
+ flattened.push(item);
203
+ }
204
+ });
205
+ return flattened;
206
+ };
207
+ setSelectedFilterType(_flatOption(options).find(function (o) {
208
+ return getDataIndex(o) === type;
195
209
  }));
196
210
  resetValue && reset();
197
211
  };
@@ -199,13 +213,13 @@ var ComplexSearch = function ComplexSearch(props) {
199
213
  /**
200
214
  * 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
201
215
  */
202
- var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy, option) {
203
- var isFuzzySearch = isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
216
+ var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
217
+ var isFuzzySearch = _isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
204
218
 
205
219
  // 如果是模糊搜索,则直接处理
206
220
  if (isFuzzySearch) {
207
221
  if (actionType !== 'change') {
208
- handleSearch(option.dataIndex);
222
+ handleSearch(getDataIndex(option));
209
223
  } else {
210
224
  onSuggest && onSuggest(value, defaultDataIndex || '');
211
225
  }
@@ -231,7 +245,7 @@ var ComplexSearch = function ComplexSearch(props) {
231
245
  onSearch(getValue(_constants.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(_constants.SEARCH_FILTER_FIELD), options));
232
246
  }
233
247
  if (selectedFilterType) {
234
- onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
248
+ onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
235
249
  }
236
250
  }
237
251
  reset();
@@ -364,7 +378,7 @@ var ComplexSearch = function ComplexSearch(props) {
364
378
  type: prefixSelectMode,
365
379
  dataSource: normalizeOptions(options, prefixSelectMode),
366
380
  label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
367
- defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
381
+ defaultValue: getDataIndex(selectedFilterType),
368
382
  onChange: function onChange(value) {
369
383
  handlerFilterTypeChange(value);
370
384
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/console-components-search",
3
- "version": "0.2.37-alpha.4",
3
+ "version": "0.2.37-alpha.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "license": "MIT",