v2.15.0

LocaleSelect

Select для переключения между локалями.

Использование

Компонент LocaleSelect расширяет SelectMenu, поэтому ему можно передать любое свойство, например color, size и другие.

Компонент предназначен для работы с системой i18n. Подробнее — в руководстве.
Компонент предназначен для работы с системой i18n. Подробнее — в руководстве.
Флаги отображаются символами Unicode, поэтому вид может отличаться: например, Microsoft Edge в Windows показывает вместо флага код ISO 3166-1 alpha-2, так как в шрифтах ОС нет значков флагов.

Локали

Пропс locales принимает массив локалей из @bxshefby/b24ui-nuxt/locale.

<script setup lang="ts">
import * as locales from '@bxshefby/b24ui-nuxt/locale'

const locale = ref('en')
</script>

<template>
  <B24LocaleSelect v-model="locale" :locales="Object.values(locales)" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import * as locales from '@bxshefby/b24ui-nuxt/locale'

const locale = ref('en')
</script>

<template>
  <B24LocaleSelect v-model="locale" :locales="Object.values(locales)" class="w-48" />
</template>

Можно передать только те локали, которые нужны вашему приложению:

<script setup lang="ts">
import { en, es, ru, tr, ar } from '@bxshefby/b24ui-nuxt/locale'

const locale = ref('en')
</script>

<template>
  <B24LocaleSelect v-model="locale" :locales="[en, es, ru, tr, ar]" />
</template>

Динамическая локаль

Использование с Nuxt i18n:

<script setup lang="ts">
import { de, en, fr } from '@bxshefby/b24ui-nuxt/locale'

const { locale, setLocale } = useI18n()
</script>

<template>
  <B24LocaleSelect
    :model-value="locale"
    :locales="[de, en, fr]"
    @update:model-value="setLocale($event)"
  />
</template>

Использование с Vue i18n:

<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { de, en } from '@bxshefby/b24ui-nuxt/locale'

const { locale, setLocale } = useI18n()
</script>

<template>
  <B24LocaleSelect
    :model-value="locale"
    :locales="[de, en]"
    @update:model-value="setLocale($event)"
  />
</template>

API

Пропсы

Prop Default Type
modelValuestring
locales Locale<any>[]
name string

The name of the field. Submitted with its owning form as part of a name/value pair.

avatar AvatarProps

Display an avatar on the left side.

color'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot"
size'md' "md" | "xs" | "sm" | "lg" | "xl" | "xss"
loadingboolean

When true, the loading icon will be displayed.

iconIconComponent

Display an icon on the left side.

trailingIconicons.chevronDownIconComponent

The icon displayed to open the menu.

autofocusboolean
disabledboolean

When true, prevents the user from interacting with listbox

openboolean

The controlled open state of the Combobox. Can be binded with v-model:open.

defaultOpenboolean

The open state of the combobox when it is initially rendered.
Use when you do not need to control its open state.

resetSearchTermOnBlur`true`boolean

Whether to reset the searchTerm when the Combobox input blurred

resetSearchTermOnSelect`true`boolean

Whether to reset the searchTerm when the Combobox value is selected

resetModelValueOnClearboolean

When true the modelValue will be reset to null (or [] if multiple)

highlightOnHoverboolean

When true, hover over item will trigger highlight

loopboolean

When true, keyboard navigation will loop from last item to first, and vice versa.

by string | (a: Locale<any>[], b: Locale<any>[]): boolean

Use this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared.

defaultValue string

The value of the SelectMenu when initially rendered. Use when you do not need to control the state of the SelectMenu.

multiple false

Whether multiple options can be selected or not.

requiredfalseboolean
id string
placeholder string

The placeholder text when the select is empty.

searchInputfalseboolean | Omit<InputProps<AcceptableValue, ModelModifiers>, "modelValue" | "defaultValue">

Whether to display the search input or not. Can be an object to pass additional props to the input. { placeholder: 'Search...', type: 'text', size: 'md' } Set autofocus: false to prevent the search input from being focused when the menu opens (e.g. to avoid opening the virtual keyboard on touch devices).

noPaddingfalseboolean

Removes padding from input

noBorderfalseboolean

Removes all borders (rings)

underlinefalseboolean

Removes all borders (rings) except the bottom one

roundedfalseboolean

Rounds the corners of the select

tag string
tagColor'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary" | "air-secondary-alert" | "air-secondary-accent" | "air-secondary-accent-1" | "air-secondary-accent-2" | "air-tertiary" | "air-selection"
selectedIconicons.checkIconComponent

The icon displayed when an item is selected.

clearfalse false | false & Partial<Omit<ButtonProps, LinkPropsKeys>>

Display a clear button to reset the model value. Can be an object to pass additional props to the Button.

clearIconicons.closeIconComponent

The icon displayed in the clear button.

content{ side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' } ComboboxContentProps & Partial<EmitsToProps<DismissableLayerEmits>>

The content of the menu.

arrowfalseboolean | ComboboxArrowProps

Display an arrow alongside the menu.

portaltrue string | false | true | HTMLElement

Render the menu in a portal.

virtualizefalseboolean | { overscan?: number ; estimateSize?: number | ((index: number) => number) | undefined; } | undefined

Enable virtualization for large lists. Note: when enabled, all groups are flattened into a single list due to a limitation of Reka UI (https://github.com/unovue/reka-ui/issues/1885).

valueKey'code' "code"

When items is an array of objects, select the field to use as the value instead of the object itself.

labelKey'name' "name" | "code" | "dir" | "locale" | "messages"

When items is an array of objects, select the field to use as the label.

descriptionKey'description' "name" | "code" | "dir" | "locale" | "messages"

When items is an array of objects, select the field to use as the description.

modelModifiers Omit<ModelModifiers, "lazy">
highlightboolean

Highlight the ring color like a focus state.

fixedboolean

Keep the mobile text size on all breakpoints.

createItemfalseboolean | "always" | { position?: "top" | "bottom" ; when?: "empty" | "always" | undefined; } | undefined

Determines if custom user input that does not exist in options can be added.

filterFields[labelKey] string[]

Fields to filter items by.

ignoreFilterfalseboolean

When true, disable the default filters, useful for custom filtering (useAsyncData, useFetch, etc.).

autofocusDelay number
trailingboolean

When true, the icon will be displayed on the right side.

b24ui { root?: SlotClass; base?: SlotClass; leading?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailing?: SlotClass; trailingIcon?: SlotClass; tag?: SlotClass; value?: SlotClass; placeholder?: SlotClass; content?: SlotClass; viewport?: SlotClass; arrow?: SlotClass; group?: SlotClass; empty?: SlotClass; label?: SlotClass; separator?: SlotClass; item?: SlotClass; itemLeadingIcon?: SlotClass; itemLeadingAvatar?: SlotClass; itemLeadingAvatarSize?: SlotClass; itemLeadingChip?: SlotClass; itemLeadingChipSize?: SlotClass; itemTrailing?: SlotClass; itemTrailingIcon?: SlotClass; itemWrapper?: SlotClass; itemLabel?: SlotClass; itemDescription?: SlotClass; input?: SlotClass; focusScope?: SlotClass; trailingClear?: SlotClass; }