import { computed, defineComponent, h, PropType, provide, ref, useId, watch } from 'vue' import { CFormControlWrapper } from './../form/CFormControlWrapper' import { CConditionalTeleport } from '../conditional-teleport' import { CMultiSelectNativeSelect } from './CMultiSelectNativeSelect' import { CMultiSelectOptions } from './CMultiSelectOptions' import { CMultiSelectSelection } from './CMultiSelectSelection' import { useDropdownWithPopper } from '../../composables' import { getNextActiveElement, isEqual } from '../../utils' import { createOption, filterOptionsList, flattenOptionsArray, getOptionsList, isExternalSearch, isGlobalSearch, selectOptions, } from './utils' import type { Option, OptionsGroup, Search, SelectedOption } from './types' const CMultiSelect = defineComponent({ name: 'CMultiSelect', props: { /** * Allow users to create options if they are not in the list of options. * * @since 4.9.0 */ allowCreateOptions: Boolean, /** * A string that provides an accessible label for the cleaner button. This label is read by screen readers to describe the action associated with the button. * * @since 5.13.0 */ ariaCleanerLabel: { type: String, default: 'Clear all selections', }, /** * A string that provides an accessible label for the indicator button. This label is read by screen readers to describe the action associated with the button. * * @since 5.7.0 */ ariaIndicatorLabel: { type: String, default: 'Toggle dropdown', }, /** * Enables selection cleaner element. * * @default true */ cleaner: { type: Boolean, default: true, }, /** * Appends the dropdown to a specific element. You can pass an HTML element or function that returns a single element. * * @since 5.7.0 */ container: { type: [Object, String] as PropType HTMLElement) | string>, default: 'body', }, /** * Clear current search on selecting an item. * * @since 4.9.0 */ clearSearchOnSelect: Boolean, /** * Toggle the disabled state for the component. */ disabled: Boolean, /** * Provide valuable, actionable feedback. * * @since 4.6.0 */ feedback: String, /** * Provide valuable, actionable feedback. * * @since 4.6.0 */ feedbackInvalid: String, /** * Provide valuable, actionable invalid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`. * * @since 4.6.0 */ feedbackValid: String, /** * Set the id attribute for the native select element. * * **[Deprecated since v5.3.0]** The name attribute for the native select element is generated based on the `id` property: * - `