mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-06 22:19:25 +08:00
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { Divider, Input } from 'antd';
|
|
import React from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useCollectionManager } from '../collection-manager';
|
|
|
|
export const SelectCollection = ({ value, onChange, setSelected }) => {
|
|
const { t } = useTranslation();
|
|
const { collections } = useCollectionManager();
|
|
|
|
return (
|
|
<div style={{ width: 210 }}>
|
|
<Input
|
|
allowClear
|
|
style={{ padding: '0 4px 6px' }}
|
|
bordered={false}
|
|
placeholder={t('Search and select collection')}
|
|
value={value}
|
|
onChange={(e) => {
|
|
const names = collections
|
|
.filter((collection) => {
|
|
if (!collection.title) {
|
|
return;
|
|
}
|
|
return collection.title.toUpperCase().includes(e.target.value.toUpperCase());
|
|
})
|
|
.map((item) => item.name);
|
|
setSelected(names);
|
|
onChange(e.target.value);
|
|
}}
|
|
/>
|
|
<Divider style={{ margin: 0 }}/>
|
|
</div>
|
|
);
|
|
};
|