@alicloud/console-components-search 0.2.37-alpha.3 → 0.2.37-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -90217,7 +90217,8 @@ function formatOptionsChildren(children) {
90217
90217
  return children.map(function (o) {
90218
90218
  return {
90219
90219
  label: o.label,
90220
- value: o.dataIndex || o.label,
90220
+ value: o.dataIndex || o.value || o.label,
90221
+ disabled: o.disabled,
90221
90222
  children: formatOptionsChildren(o.children),
90222
90223
  };
90223
90224
  });
@@ -90232,7 +90233,8 @@ var normalizeOptions = function (options, prefixSelectMode) {
90232
90233
  return options.map(function (o) {
90233
90234
  return {
90234
90235
  label: o.label,
90235
- value: o.dataIndex || o.label,
90236
+ value: o.dataIndex || o.value || o.label,
90237
+ disabled: o.disabled,
90236
90238
  // @ts-ignore
90237
90239
  children: formatOptionsChildren(o.children),
90238
90240
  };
@@ -90244,11 +90246,11 @@ var normalizeOptions = function (options, prefixSelectMode) {
90244
90246
  var groupName = _a[0], children = _a[1];
90245
90247
  return {
90246
90248
  label: groupName,
90247
- value: groupName,
90248
90249
  children: children.map(function (l) {
90249
90250
  return {
90250
90251
  label: l.label,
90251
- value: l.dataIndex,
90252
+ value: l.dataIndex || l.value,
90253
+ disabled: l.disabled,
90252
90254
  };
90253
90255
  }),
90254
90256
  };
@@ -90277,7 +90279,7 @@ var normalizeSelectDataSource = function (title, list) {
90277
90279
  };
90278
90280
  var normalizeSearchOptions = function (dataIndex, value, options) {
90279
90281
  var _a, _b, _c;
90280
- 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; });
90281
90283
  var valueLabel = value;
90282
90284
  if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
90283
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;
@@ -90302,9 +90304,12 @@ var highlightKeyword = function (value, keywords) {
90302
90304
  react_1.default.createElement("span", { style: { color: 'var(--color-brand1-6)' } }, highlightValue),
90303
90305
  endValue));
90304
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
+ };
90305
90310
  var ComplexSearch = function (props) {
90306
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;
90307
- 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];
90308
90313
  var _f = (0, react_1.useState)(false), focused = _f[0], setFocused = _f[1];
90309
90314
  var autoRef = (0, react_1.useRef)(null);
90310
90315
  var field = console_components_1.Field.useField();
@@ -90319,7 +90324,7 @@ var ComplexSearch = function (props) {
90319
90324
  };
90320
90325
  // 计算视图,根据内部状态和输入的 props 决定一些值
90321
90326
  var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(constants_1.SEARCH_FILTER_FIELD);
90322
- var defaultFilter = options.find(function (t) { return t.dataIndex === defaultDataIndex; });
90327
+ var defaultFilter = options.find(function (t) { return getDataIndex(t) === defaultDataIndex; });
90323
90328
  var highlightItem = function (item, searchKey) {
90324
90329
  var label = item.label;
90325
90330
  if (searchKey && searchKey.length) {
@@ -90332,18 +90337,18 @@ var ComplexSearch = function (props) {
90332
90337
  */
90333
90338
  var handlerFilterTypeChange = function (type, resetValue) {
90334
90339
  if (resetValue === void 0) { resetValue = true; }
90335
- setSelectedFilterType(options.find(function (o) { return o.dataIndex === type; }));
90340
+ setSelectedFilterType(options.find(function (o) { return getDataIndex(o) === type; }));
90336
90341
  resetValue && reset();
90337
90342
  };
90338
90343
  /**
90339
90344
  * 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
90340
90345
  */
90341
- var handlerFilterTypeInput = function (value, actionType, isFuzzy, option) {
90342
- var isFuzzySearch = isFuzzy && getValue(constants_1.SEARCH_FILTER_FIELD);
90346
+ var handlerFilterTypeInput = function (value, actionType, _isFuzzy, option) {
90347
+ var isFuzzySearch = _isFuzzy && getValue(constants_1.SEARCH_FILTER_FIELD);
90343
90348
  // 如果是模糊搜索,则直接处理
90344
90349
  if (isFuzzySearch) {
90345
90350
  if (actionType !== 'change') {
90346
- handleSearch(option.dataIndex);
90351
+ handleSearch(getDataIndex(option));
90347
90352
  }
90348
90353
  else {
90349
90354
  onSuggest && onSuggest(value, defaultDataIndex || '');
@@ -90369,7 +90374,7 @@ var ComplexSearch = function (props) {
90369
90374
  onSearch(getValue(constants_1.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(constants_1.SEARCH_FILTER_FIELD), options));
90370
90375
  }
90371
90376
  if (selectedFilterType) {
90372
- onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
90377
+ onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
90373
90378
  }
90374
90379
  }
90375
90380
  reset();
@@ -90448,7 +90453,7 @@ var ComplexSearch = function (props) {
90448
90453
  react_1.default.createElement("div", { className: (0, classnames_1.default)('left-wrap', "".concat(prefix, "input"), {
90449
90454
  focus: focused,
90450
90455
  }) },
90451
- 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) {
90456
+ 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) {
90452
90457
  handlerFilterTypeChange(value);
90453
90458
  }, itemRender: prefixSelectItemRender })) : null),
90454
90459
  react_1.default.createElement("div", { className: (0, classnames_1.default)('forms') },
@@ -21,7 +21,8 @@ function formatOptionsChildren(children) {
21
21
  return children.map(function (o) {
22
22
  return {
23
23
  label: o.label,
24
- value: o.dataIndex || o.label,
24
+ value: o.dataIndex || o.value || o.label,
25
+ disabled: o.disabled,
25
26
  children: formatOptionsChildren(o.children)
26
27
  };
27
28
  });
@@ -37,7 +38,8 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
37
38
  return options.map(function (o) {
38
39
  return {
39
40
  label: o.label,
40
- value: o.dataIndex || o.label,
41
+ value: o.dataIndex || o.value || o.label,
42
+ disabled: o.disabled,
41
43
  // @ts-ignore
42
44
  children: formatOptionsChildren(o.children)
43
45
  };
@@ -53,11 +55,11 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
53
55
  children = _ref2[1];
54
56
  return {
55
57
  label: groupName,
56
- value: groupName,
57
58
  children: children.map(function (l) {
58
59
  return {
59
60
  label: l.label,
60
- value: l.dataIndex
61
+ value: l.dataIndex || l.value,
62
+ disabled: l.disabled
61
63
  };
62
64
  })
63
65
  };
@@ -84,7 +86,7 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
84
86
  };
85
87
  var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
86
88
  var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
87
- return o.dataIndex === dataIndex;
89
+ return getDataIndex(o) === dataIndex;
88
90
  });
89
91
  var valueLabel = value;
90
92
  if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
@@ -119,6 +121,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
119
121
  }
120
122
  }, highlightValue), endValue);
121
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
+ };
122
127
  var ComplexSearch = function ComplexSearch(props) {
123
128
  var _props$options = props.options,
124
129
  options = _props$options === void 0 ? [] : _props$options,
@@ -136,7 +141,7 @@ var ComplexSearch = function ComplexSearch(props) {
136
141
  prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
137
142
  prefixSelectItemRender = props.prefixSelectItemRender;
138
143
  var _useState = useState(options.find(function (o) {
139
- return o.dataIndex === defaultSelectedDataIndex;
144
+ return getDataIndex(o) === defaultSelectedDataIndex;
140
145
  })),
141
146
  _useState2 = _slicedToArray(_useState, 2),
142
147
  selectedFilterType = _useState2[0],
@@ -162,7 +167,7 @@ var ComplexSearch = function ComplexSearch(props) {
162
167
  // 计算视图,根据内部状态和输入的 props 决定一些值
163
168
  var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(SEARCH_FILTER_FIELD);
164
169
  var defaultFilter = options.find(function (t) {
165
- return t.dataIndex === defaultDataIndex;
170
+ return getDataIndex(t) === defaultDataIndex;
166
171
  });
167
172
  var highlightItem = function highlightItem(item, searchKey) {
168
173
  var label = item.label;
@@ -180,7 +185,7 @@ var ComplexSearch = function ComplexSearch(props) {
180
185
  var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
181
186
  var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
182
187
  setSelectedFilterType(options.find(function (o) {
183
- return o.dataIndex === type;
188
+ return getDataIndex(o) === type;
184
189
  }));
185
190
  resetValue && reset();
186
191
  };
@@ -188,13 +193,13 @@ var ComplexSearch = function ComplexSearch(props) {
188
193
  /**
189
194
  * 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
190
195
  */
191
- var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy, option) {
192
- var isFuzzySearch = isFuzzy && getValue(SEARCH_FILTER_FIELD);
196
+ var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
197
+ var isFuzzySearch = _isFuzzy && getValue(SEARCH_FILTER_FIELD);
193
198
 
194
199
  // 如果是模糊搜索,则直接处理
195
200
  if (isFuzzySearch) {
196
201
  if (actionType !== 'change') {
197
- handleSearch(option.dataIndex);
202
+ handleSearch(getDataIndex(option));
198
203
  } else {
199
204
  onSuggest && onSuggest(value, defaultDataIndex || '');
200
205
  }
@@ -220,7 +225,7 @@ var ComplexSearch = function ComplexSearch(props) {
220
225
  onSearch(getValue(SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(SEARCH_FILTER_FIELD), options));
221
226
  }
222
227
  if (selectedFilterType) {
223
- onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
228
+ onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
224
229
  }
225
230
  }
226
231
  reset();
@@ -353,7 +358,7 @@ var ComplexSearch = function ComplexSearch(props) {
353
358
  type: prefixSelectMode,
354
359
  dataSource: normalizeOptions(options, prefixSelectMode),
355
360
  label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
356
- defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
361
+ defaultValue: getDataIndex(selectedFilterType),
357
362
  onChange: function onChange(value) {
358
363
  handlerFilterTypeChange(value);
359
364
  },
@@ -30,7 +30,8 @@ function formatOptionsChildren(children) {
30
30
  return children.map(function (o) {
31
31
  return {
32
32
  label: o.label,
33
- value: o.dataIndex || o.label,
33
+ value: o.dataIndex || o.value || o.label,
34
+ disabled: o.disabled,
34
35
  children: formatOptionsChildren(o.children)
35
36
  };
36
37
  });
@@ -46,7 +47,8 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
46
47
  return options.map(function (o) {
47
48
  return {
48
49
  label: o.label,
49
- value: o.dataIndex || o.label,
50
+ value: o.dataIndex || o.value || o.label,
51
+ disabled: o.disabled,
50
52
  // @ts-ignore
51
53
  children: formatOptionsChildren(o.children)
52
54
  };
@@ -62,11 +64,11 @@ var normalizeOptions = function normalizeOptions(options, prefixSelectMode) {
62
64
  children = _ref2[1];
63
65
  return {
64
66
  label: groupName,
65
- value: groupName,
66
67
  children: children.map(function (l) {
67
68
  return {
68
69
  label: l.label,
69
- value: l.dataIndex
70
+ value: l.dataIndex || l.value,
71
+ disabled: l.disabled
70
72
  };
71
73
  })
72
74
  };
@@ -93,7 +95,7 @@ var normalizeSelectDataSource = function normalizeSelectDataSource(title, list)
93
95
  };
94
96
  var normalizeSearchOptions = function normalizeSearchOptions(dataIndex, value, options) {
95
97
  var opt = options === null || options === void 0 ? void 0 : options.find(function (o) {
96
- return o.dataIndex === dataIndex;
98
+ return getDataIndex(o) === dataIndex;
97
99
  });
98
100
  var valueLabel = value;
99
101
  if ((opt === null || opt === void 0 ? void 0 : opt.template) === 'select') {
@@ -128,6 +130,9 @@ var highlightKeyword = function highlightKeyword(value, keywords) {
128
130
  }
129
131
  }, highlightValue), endValue);
130
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
+ };
131
136
  var ComplexSearch = function ComplexSearch(props) {
132
137
  var _props$options = props.options,
133
138
  options = _props$options === void 0 ? [] : _props$options,
@@ -145,7 +150,7 @@ var ComplexSearch = function ComplexSearch(props) {
145
150
  prefixSelectMode = _props$prefixSelectMo === void 0 ? 'select' : _props$prefixSelectMo,
146
151
  prefixSelectItemRender = props.prefixSelectItemRender;
147
152
  var _useState = (0, _react.useState)(options.find(function (o) {
148
- return o.dataIndex === defaultSelectedDataIndex;
153
+ return getDataIndex(o) === defaultSelectedDataIndex;
149
154
  })),
150
155
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
151
156
  selectedFilterType = _useState2[0],
@@ -171,7 +176,7 @@ var ComplexSearch = function ComplexSearch(props) {
171
176
  // 计算视图,根据内部状态和输入的 props 决定一些值
172
177
  var isFuzzy = (!!defaultDataIndex || fuzzy) && !!getValue(_constants.SEARCH_FILTER_FIELD);
173
178
  var defaultFilter = options.find(function (t) {
174
- return t.dataIndex === defaultDataIndex;
179
+ return getDataIndex(t) === defaultDataIndex;
175
180
  });
176
181
  var highlightItem = function highlightItem(item, searchKey) {
177
182
  var label = item.label;
@@ -189,7 +194,7 @@ var ComplexSearch = function ComplexSearch(props) {
189
194
  var handlerFilterTypeChange = function handlerFilterTypeChange(type) {
190
195
  var resetValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
191
196
  setSelectedFilterType(options.find(function (o) {
192
- return o.dataIndex === type;
197
+ return getDataIndex(o) === type;
193
198
  }));
194
199
  resetValue && reset();
195
200
  };
@@ -197,13 +202,13 @@ var ComplexSearch = function ComplexSearch(props) {
197
202
  /**
198
203
  * 处理当筛选类型没选中,用户输入筛选类型,或者是做默认搜索的情况
199
204
  */
200
- var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, isFuzzy, option) {
201
- var isFuzzySearch = isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
205
+ var handlerFilterTypeInput = function handlerFilterTypeInput(value, actionType, _isFuzzy, option) {
206
+ var isFuzzySearch = _isFuzzy && getValue(_constants.SEARCH_FILTER_FIELD);
202
207
 
203
208
  // 如果是模糊搜索,则直接处理
204
209
  if (isFuzzySearch) {
205
210
  if (actionType !== 'change') {
206
- handleSearch(option.dataIndex);
211
+ handleSearch(getDataIndex(option));
207
212
  } else {
208
213
  onSuggest && onSuggest(value, defaultDataIndex || '');
209
214
  }
@@ -229,7 +234,7 @@ var ComplexSearch = function ComplexSearch(props) {
229
234
  onSearch(getValue(_constants.SEARCH_FILTER_FIELD), dataIndex || '', normalizeSearchOptions(dataIndex || '', getValue(_constants.SEARCH_FILTER_FIELD), options));
230
235
  }
231
236
  if (selectedFilterType) {
232
- onSearch(value, selectedFilterType.dataIndex, normalizeSearchOptions(selectedFilterType.dataIndex, value, options));
237
+ onSearch(value, getDataIndex(selectedFilterType), normalizeSearchOptions(getDataIndex(selectedFilterType), value, options));
233
238
  }
234
239
  }
235
240
  reset();
@@ -362,7 +367,7 @@ var ComplexSearch = function ComplexSearch(props) {
362
367
  type: prefixSelectMode,
363
368
  dataSource: normalizeOptions(options, prefixSelectMode),
364
369
  label: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.label,
365
- defaultValue: selectedFilterType === null || selectedFilterType === void 0 ? void 0 : selectedFilterType.dataIndex,
370
+ defaultValue: getDataIndex(selectedFilterType),
366
371
  onChange: function onChange(value) {
367
372
  handlerFilterTypeChange(value);
368
373
  },
@@ -6,6 +6,8 @@ export interface IRcSearchOptionsProps {
6
6
  * 字段展示名称
7
7
  */
8
8
  label: string;
9
+ value?: any;
10
+ disabled?: boolean;
9
11
  /**
10
12
  * 字段表单key
11
13
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alicloud/console-components-search",
3
- "version": "0.2.37-alpha.3",
3
+ "version": "0.2.37-alpha.5",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "license": "MIT",