import { action } from "@tachybase/schema";
import { useCollectionManager_deprecated } from "./index.mjs";
import { useCompile } from "../../schema-component/index.mjs";
function useCollectionDataSource(filter) {
    const compile = useCompile();
    const { collections = [] } = useCollectionManager_deprecated();
    return (field)=>{
        action.bound((data)=>{
            const filtered = 'function' == typeof filter ? data.filter(filter) : data;
            field.dataSource = filtered.map((item)=>({
                    label: compile(item.title),
                    value: item.name
                }));
        })(collections);
    };
}
export { useCollectionDataSource };
