diff --git a/packages/core/src/collections/api.ts b/packages/core/src/collections/api.ts index ad40ebef..cc0d1b2c 100644 --- a/packages/core/src/collections/api.ts +++ b/packages/core/src/collections/api.ts @@ -1,38 +1,38 @@ -import { computed, ComputedRef, MaybeRefOrGetter, toValue } from 'vue'; -import { getFromPath } from '../utils/path'; -import { isObject } from '../../../shared/src'; +// import { computed, ComputedRef, MaybeRefOrGetter, toValue } from 'vue'; +// import { getFromPath } from '../utils/path'; +// import { isObject } from '../../../shared/src'; -export interface CollectionInit { - /** - * The items to be displayed in the collection. - */ - items: MaybeRefOrGetter; - /** - * The property to track by, it can be a function that extracts the value from the item. Should be the same as the "value" prop of the option. - */ - key?: string | ((item: TItem) => unknown); -} +// export interface CollectionInit { +// /** +// * The items to be displayed in the collection. +// */ +// items: MaybeRefOrGetter; +// /** +// * The property to track by, it can be a function that extracts the value from the item. Should be the same as the "value" prop of the option. +// */ +// key?: string | ((item: TItem) => unknown); +// } -export interface CollectionManager { - items: ComputedRef; - key: (item: TItem) => unknown; -} +// export interface CollectionManager { +// items: ComputedRef; +// key: (item: TItem) => unknown; +// } -// TODO: Implement fetching, loading, pagination, adding a new item, etc... -export function defineCollection(init: CollectionInit): CollectionManager { - const { items, key } = init; +// // TODO: Implement fetching, loading, pagination, adding a new item, etc... +// export function defineCollection(init: CollectionInit): CollectionManager { +// const { items, key } = init; - return { - items: computed(() => toValue(items)), - key: - typeof key === 'function' - ? key - : item => { - if (key && isObject(item)) { - return getFromPath(item, key, item); - } +// return { +// items: computed(() => toValue(items)), +// key: +// typeof key === 'function' +// ? key +// : item => { +// if (key && isObject(item)) { +// return getFromPath(item, key, item); +// } - return item; - }, - }; -} +// return item; +// }, +// }; +// } diff --git a/packages/core/src/collections/filter.ts b/packages/core/src/collections/filter.ts index d4778aed..9254a6f3 100644 --- a/packages/core/src/collections/filter.ts +++ b/packages/core/src/collections/filter.ts @@ -1,8 +1,8 @@ -export interface FilterContext { +export interface FilterContext { search: string; option: { label: string; - item: TItem; + value: TValue; }; } diff --git a/packages/core/src/collections/index.ts b/packages/core/src/collections/index.ts index ca93acdc..1f6dc735 100644 --- a/packages/core/src/collections/index.ts +++ b/packages/core/src/collections/index.ts @@ -1,2 +1,2 @@ -export * from './api'; +// export * from './api'; export * from './filter'; diff --git a/packages/core/src/useComboBox/useComboBox.ts b/packages/core/src/useComboBox/useComboBox.ts index 0c2c9f5d..aa0d5286 100644 --- a/packages/core/src/useComboBox/useComboBox.ts +++ b/packages/core/src/useComboBox/useComboBox.ts @@ -312,14 +312,18 @@ export function useComboBox( }); const filter = collectionOptions?.filter; - - watch(inputValue, textValue => { - renderedOptions.value.forEach(opt => { - opt.setHidden( - filter ? !filter({ option: { item: opt.getValue(), label: opt.getLabel() }, search: textValue }) : false, - ); + if (filter) { + watch(inputValue, textValue => { + renderedOptions.value.forEach(opt => { + opt.setHidden( + !filter({ + option: { value: opt.getValue(), label: opt.getLabel() }, + search: textValue, + }), + ); + }); }); - }); + } return exposeField( {