Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/amis/src/renderers/Form/InputTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
* 搜索框的配置
*/
searchConfig?: {
/**
* 哪些字段可以用于本地检索,默认['label','value']
*/
searchKeys: string | string[];
/**
* 搜索框外层CSS样式类
*/
Expand Down Expand Up @@ -349,14 +353,21 @@
}

filterOptions(options: Array<Option>, keywords: string): Array<Option> {
const {labelField, valueField} = this.props;
const {labelField, valueField, searchConfig} = this.props;

return options.map(option => {
option = {
...option
};
let searchKeys = searchConfig?.searchKeys;
if (searchKeys) {
searchKeys = Array.isArray(searchKeys) ? searchKeys : [searchKeys];
} else {
searchKeys = [labelField || 'label', valueField || 'value'];
}

option.visible = !!matchSorter([option], keywords, {
keys: [labelField || 'label', valueField || 'value'],
keys: searchKeys,
threshold: matchSorter.rankings.CONTAINS
}).length;

Expand Down Expand Up @@ -695,7 +706,7 @@
<>
<div
className={cx(`${ns}TreeControl`, className, treeContainerClassName, {
'is-sticky': searchable && searchConfig?.sticky,

Check failure on line 709 in packages/amis/src/renderers/Form/InputTree.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'sticky' does not exist on type '{}'.
'h-auto': heightAuto
})}
{...testIdBuilder?.getChild('control').getTestId()}
Expand Down
Loading