mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 19:30:37 +01:00
fix(InputMenu/SelectMenu): init filter with labelKey
This commit is contained in:
@@ -19,7 +19,6 @@ function onOpen() {
|
|||||||
:items="countries || []"
|
:items="countries || []"
|
||||||
:loading="status === 'pending'"
|
:loading="status === 'pending'"
|
||||||
label-key="name"
|
label-key="name"
|
||||||
:filter="['name']"
|
|
||||||
:search-input="{ icon: 'i-lucide-search' }"
|
:search-input="{ icon: 'i-lucide-search' }"
|
||||||
placeholder="Select country"
|
placeholder="Select country"
|
||||||
class="w-48"
|
class="w-48"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
|||||||
<UInputMenu
|
<UInputMenu
|
||||||
:items="users || []"
|
:items="users || []"
|
||||||
:loading="status === 'pending'"
|
:loading="status === 'pending'"
|
||||||
:filter="['name', 'email']"
|
:filter="['label', 'email']"
|
||||||
icon="i-lucide-user"
|
icon="i-lucide-user"
|
||||||
placeholder="Select user"
|
placeholder="Select user"
|
||||||
class="w-80"
|
class="w-80"
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ const { data: countries, status, execute } = await useLazyFetch<{
|
|||||||
code: string
|
code: string
|
||||||
emoji: string
|
emoji: string
|
||||||
}[]>('/api/countries.json', {
|
}[]>('/api/countries.json', {
|
||||||
immediate: false
|
immediate: false,
|
||||||
|
default: () => []
|
||||||
})
|
})
|
||||||
|
|
||||||
function onOpen() {
|
function onOpen() {
|
||||||
@@ -16,10 +17,9 @@ function onOpen() {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<USelectMenu
|
<USelectMenu
|
||||||
:items="countries || []"
|
:items="countries"
|
||||||
:loading="status === 'pending'"
|
:loading="status === 'pending'"
|
||||||
label-key="name"
|
label-key="name"
|
||||||
:filter="['name']"
|
|
||||||
:search-input="{ icon: 'i-lucide-search' }"
|
:search-input="{ icon: 'i-lucide-search' }"
|
||||||
placeholder="Select country"
|
placeholder="Select country"
|
||||||
class="w-48"
|
class="w-48"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const { data: users, status } = await useFetch('https://jsonplaceholder.typicode
|
|||||||
<USelectMenu
|
<USelectMenu
|
||||||
:items="users || []"
|
:items="users || []"
|
||||||
:loading="status === 'pending'"
|
:loading="status === 'pending'"
|
||||||
:filter="['name', 'email']"
|
:filter="['label', 'email']"
|
||||||
icon="i-lucide-user"
|
icon="i-lucide-user"
|
||||||
placeholder="Select user"
|
placeholder="Select user"
|
||||||
class="w-80"
|
class="w-80"
|
||||||
|
|||||||
@@ -694,7 +694,7 @@ This example uses [refDebounced](https://vueuse.org/shared/refDebounced/#refdebo
|
|||||||
|
|
||||||
### With custom search
|
### With custom search
|
||||||
|
|
||||||
Use the `filter` prop with an array of fields to filter on.
|
Use the `filter` prop with an array of fields to filter on. Defaults to `[labelKey]`.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ This example uses [refDebounced](https://vueuse.org/shared/refDebounced/#refdebo
|
|||||||
|
|
||||||
### With custom search
|
### With custom search
|
||||||
|
|
||||||
Use the `filter` prop with an array of fields to filter on.
|
Use the `filter` prop with an array of fields to filter on. Defaults to `[labelKey]`.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -78,9 +78,10 @@ export interface InputMenuProps<T extends MaybeArrayOfArrayItem<I>, I extends Ma
|
|||||||
*/
|
*/
|
||||||
portal?: boolean
|
portal?: boolean
|
||||||
/**
|
/**
|
||||||
* Whether to filter items or not, can be an array of fields to filter.
|
* Whether to filter items or not, can be an array of fields to filter. Defaults to `[labelKey]`.
|
||||||
* When `false`, items will not be filtered which is useful for custom filtering.
|
* When `false`, items will not be filtered which is useful for custom filtering (useAsyncData, useFetch, etc.).
|
||||||
* @defaultValue ['label']
|
* `['label']`{lang="ts-type"}
|
||||||
|
* @defaultValue true
|
||||||
*/
|
*/
|
||||||
filter?: boolean | string[]
|
filter?: boolean | string[]
|
||||||
/**
|
/**
|
||||||
@@ -149,7 +150,7 @@ const props = withDefaults(defineProps<InputMenuProps<T, I, V, M>>(), {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
autofocusDelay: 0,
|
autofocusDelay: 0,
|
||||||
portal: true,
|
portal: true,
|
||||||
filter: () => ['label'],
|
filter: true,
|
||||||
labelKey: 'label' as never
|
labelKey: 'label' as never
|
||||||
})
|
})
|
||||||
const emits = defineEmits<InputMenuEmits<T, V, M>>()
|
const emits = defineEmits<InputMenuEmits<T, V, M>>()
|
||||||
|
|||||||
@@ -70,9 +70,10 @@ export interface SelectMenuProps<T extends MaybeArrayOfArrayItem<I>, I extends M
|
|||||||
*/
|
*/
|
||||||
portal?: boolean
|
portal?: boolean
|
||||||
/**
|
/**
|
||||||
* Whether to filter items or not, can be an array of fields to filter.
|
* Whether to filter items or not, can be an array of fields to filter. Defaults to `[labelKey]`.
|
||||||
* When `false`, items will not be filtered which is useful for custom filtering (useAsyncData, useFetch, etc.).
|
* When `false`, items will not be filtered which is useful for custom filtering (useAsyncData, useFetch, etc.).
|
||||||
* @defaultValue ['label']
|
* `['label']`{lang="ts-type"}
|
||||||
|
* @defaultValue true
|
||||||
*/
|
*/
|
||||||
filter?: boolean | string[]
|
filter?: boolean | string[]
|
||||||
/**
|
/**
|
||||||
@@ -139,7 +140,7 @@ const props = withDefaults(defineProps<SelectMenuProps<T, I, V, M>>(), {
|
|||||||
portal: true,
|
portal: true,
|
||||||
autofocusDelay: 0,
|
autofocusDelay: 0,
|
||||||
searchInput: true,
|
searchInput: true,
|
||||||
filter: () => ['label'],
|
filter: true,
|
||||||
labelKey: 'label' as never
|
labelKey: 'label' as never
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user