@leaflink/stash 53.1.1 → 53.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Copy.js +92 -53
- package/dist/Copy.js.map +1 -1
- package/dist/Copy.vue.d.ts +14 -6
- package/dist/Dialog.js +6 -6
- package/dist/Dialog.js.map +1 -1
- package/dist/FileUpload.js +43 -43
- package/dist/FileUpload.js.map +1 -1
- package/dist/ListView.js +78 -78
- package/dist/ListView.js.map +1 -1
- package/dist/MoreActions.js +1 -1
- package/dist/Select.js +1 -1
- package/dist/Select.js.map +1 -1
- package/dist/Thumbnail.js +27 -27
- package/dist/Thumbnail.js.map +1 -1
- package/dist/ThumbnailEmpty.js +5 -5
- package/dist/ThumbnailEmpty.js.map +1 -1
- package/dist/ThumbnailGroup.js +16 -16
- package/dist/ThumbnailGroup.js.map +1 -1
- package/dist/Tooltip.js +1 -1
- package/dist/{Tooltip.vue_vue_type_script_setup_true_lang-mzBLSXy3.js → Tooltip.vue_vue_type_script_setup_true_lang-CF6sw2VC.js} +2 -2
- package/dist/{Tooltip.vue_vue_type_script_setup_true_lang-mzBLSXy3.js.map → Tooltip.vue_vue_type_script_setup_true_lang-CF6sw2VC.js.map} +1 -1
- package/dist/components.css +1 -1
- package/dist/index-B1Gkwuxd.js +277 -0
- package/dist/index-B1Gkwuxd.js.map +1 -0
- package/dist/useSortable.js +1 -1
- package/package.json +2 -2
- package/dist/index-DBV9Uz0C.js +0 -294
- package/dist/index-DBV9Uz0C.js.map +0 -1
package/dist/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../src/components/Select/Select.vue"],"sourcesContent":["<script lang=\"ts\">\n import { FieldProps } from '../Field/Field.types';\n\n // Note: the `trackBy` prop, the `single` prop, and the fact that options can be strings prevents us from knowing the type of the selected options\n\n type Option = any;\n\n type SelectedOptions = Option | Option[];\n\n export interface SelectProps extends FieldProps {\n /**\n * If there is only 1 option selected, it prevents that option from being de-selected\n */\n preventEmpty?: boolean;\n\n /**\n * @deprecated The `allowEmpty` prop is no longer supported; use `preventEmpty` instead.\n */\n allowEmpty?: string | boolean | null;\n\n /**\n * If `options` are an object, this is what prop to use for display.\n */\n displayBy?: string;\n\n /**\n * List of one or more fields to search on. When empty, displayBy will be used\n */\n searchBy?: string[];\n\n /**\n * Default field to track selected options by.\n */\n trackBy?: string;\n\n /**\n * Placeholder text.\n */\n placeholder?: string;\n\n /**\n * @deprecated Use the `error-text` prop instead\n */\n error?: string;\n\n /**\n * @deprecated Use the `hint-text` prop instead\n */\n hint?: string;\n\n /**\n * Sets a custom icon.\n */\n icon?: string | boolean;\n\n /**\n * Sets a name attribute on the native (hidden) select element\n *\n * Setting the default value to `undefined` so the attribute isn't rendered if not explicitly provided to ensure backwards compatibility with MP django forms\n */\n name?: string;\n\n /**\n * The list of all options to select from.\n */\n options?: Option[] | readonly Option[];\n\n /**\n * Lazily evaluate and set component `options`. Will execute upon user mouseover.\n */\n lazy?: () => Option[];\n\n /**\n * Sets the currently-selected value(s) for the component.\n * Accepts an array of Objects, or a single Object (if `single` is true), or a string\n */\n modelValue?: SelectedOptions;\n\n /**\n * @deprecated Use :model-value or v-model instead of :value.\n */\n value?: SelectedOptions | null;\n\n /**\n * Hides the search input\n */\n hideSearch?: boolean;\n\n /**\n * @deprecated The `searchable` prop is no longer supported; Use `hideSearch` instead.\n */\n searchable?: string | boolean | null;\n\n /**\n * If true, prevents the search term from being cleared when the drawer is dismissed.\n */\n preserveSearchTerm?: boolean;\n\n /**\n * Prevents the options from being filtered when the search term changes.\n * Allows the parent to filter the options.\n */\n disableFiltering?: boolean;\n\n /**\n * Functions as a single select, if true\n */\n single?: boolean;\n\n /**\n * Prevents the Selected Option from being truncated, if true\n */\n noTruncate?: boolean;\n\n /**\n * On an ajaxed request when the dropdown is open, we may be experiencing slower load times.\n * This flag will drop a loader into the dropdown. Note: This has never been design reviewed.\n */\n loading?: boolean;\n\n /**\n * @deprecated Instead, use the `@search` event (the onSearch prop) and ensure its event handler returns a Promise that resolves after the search is complete.\n */\n searchLoading?: boolean;\n\n /**\n * In the selection text we use this to give more visual distinction to what type of item(s) are selected\n * E.g. 2 customers selected. An empty string will result in `2 selected`.\n */\n selectItemType?: string;\n\n /**\n * Hides the \"check\" icon if truthy\n */\n hideCheck?: boolean;\n\n searchPlaceholder?: string;\n\n /**\n * Equivalent to emitting a \"search\" event, except this prop can be used to populate the list of `options` using an HTTP request because a prop's return value can be received and awaited, unlike an event.\n *\n * **Tip:** to show a loading indicator while searching, return a Promise that resolves after the search is complete.\n *\n * **Warning:** the search input is debounced so there is no need to debounce this function.\n */\n onSearch?: (searchTerm: string) => Promise<void> | void;\n\n /**\n * Uses the \"fuzzy search\" algorithm when searching, if true\n */\n useFuzzySearch?: boolean;\n\n /**\n * Sets the placement of the dropdown\n * @default 'bottom-start'\n */\n menuPlacement?: Placement;\n\n /**\n * Enables teleporting the dropdown\n * @default false\n */\n enableTeleport?: boolean;\n\n /**\n * The selector or element to which the dropdown should be teleported\n * @default `'#stash-menus-mount-node'`\n */\n teleportTo?: string | HTMLElement;\n }\n</script>\n\n<script setup lang=\"ts\">\n import { autoUpdate, flip, offset, type Placement, type Side, size, useFloating } from '@floating-ui/vue';\n import logger from '@leaflink/snitch';\n import debounce from 'lodash-es/debounce';\n import isEmpty from 'lodash-es/isEmpty';\n import isEqual from 'lodash-es/isEqual';\n import isPlainObject from 'lodash-es/isPlainObject';\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, nextTick, onMounted, onUnmounted, type Ref, ref, useAttrs, watch } from 'vue';\n\n import useSearch from '../../composables/useSearch/useSearch';\n import { DEBOUNCE, KEY_CODES } from '../../constants';\n import vClickoutside from '../../directives/clickoutside/clickoutside';\n import { DEFAULT_MENUS_PLUGIN_NODE_ID } from '../../plugins/MenusPlugin';\n import Chip from '../Chip/Chip.vue';\n import Field from '../Field/Field.vue';\n import Icon, { IconName } from '../Icon/Icon.vue';\n\n const GAP_HEIGHT = 6;\n\n const MENU_MAX_HEIGHT_PX = 300;\n\n defineOptions({\n name: 'll-select',\n });\n\n const props = withDefaults(defineProps<SelectProps>(), {\n preventEmpty: false,\n allowEmpty: null,\n displayBy: 'name',\n searchBy: () => [],\n trackBy: 'id',\n placeholder: 'Select option',\n error: '',\n hint: '',\n icon: 'caret-down',\n name: undefined,\n options: () => [],\n lazy: undefined,\n modelValue: () => [],\n value: null,\n hideSearch: false,\n searchable: null,\n preserveSearchTerm: false,\n disableFiltering: false,\n single: false,\n noTruncate: false,\n loading: false,\n searchLoading: false,\n selectItemType: '',\n hideCheck: false,\n searchPlaceholder: 'Search',\n onSearch: undefined,\n useFuzzySearch: false,\n menuPlacement: 'bottom-start',\n enableTeleport: false,\n teleportTo: `#${DEFAULT_MENUS_PLUGIN_NODE_ID}`,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the model value changes.\n */\n (e: 'update:model-value', selectedOptions: SelectedOptions): void;\n /**\n * Emitted the selected value(s) a cleared.\n */\n (e: 'clear'): void;\n /**\n * Emitted when an option is added.\n */\n (e: 'add', optionAdded: Option): void;\n /**\n * Emitted when an option is removed.\n */\n (e: 'remove', optionRemoved: Option, index: number): void;\n /**\n * Emitted when the select is opened.\n */\n (e: 'opened'): void;\n /**\n * Emitted when the select is closed.\n */\n (e: 'closed', selectedOptions: SelectedOptions): void;\n }>();\n\n const attrs = useAttrs();\n const slots = defineSlots<{\n /**\n * Selected value(s) custom text. Exposes the option object and remove function.\n */\n selected(props: {\n /**\n * The selected option object.\n */\n option: Option;\n /**\n * Function to remove the selected option from the selection.\n */\n onRemove: () => void;\n /**\n * Class to apply to the selected chip.\n */\n chipSelectedClass: string;\n }): unknown;\n /**\n * Select custom option text. Exposes the option object\n */\n option(props: {\n /**\n * Option The option instance for this list item.\n */\n option: Option;\n }): unknown;\n /**\n * Slot for when there are no options available.\n */\n 'no-options'(): unknown;\n /**\n * Slot to display a helpful hint message below the select field.\n */\n hint(): unknown;\n }>();\n\n const selectRef = ref<HTMLDivElement | null>(null);\n const contentRef = ref<HTMLDivElement | null>(null);\n const optionsWrapperRef = ref<HTMLDivElement | null>(null);\n const chipsRef = ref<HTMLUListElement | null>(null);\n const searchRef = ref<HTMLInputElement | null>(null);\n\n const chipsHeight = ref(0);\n const contentHeight = ref(0);\n const internalValue = ref<Option[]>([]) as Ref<Option[]>;\n const searchFor = ref<(searchTerm: string) => Option[]>(() => []); // initialized in the watch handler for options\n const searchTerm = ref('');\n const activeIndex = ref(-1);\n const isActive = ref(false);\n const pendingSearchRequests = ref({});\n const shouldUseLazyOptions = ref(false);\n\n const { floatingStyles, update: updateFloating } = useFloating(selectRef, optionsWrapperRef, {\n whileElementsMounted: autoUpdate,\n placement: props.menuPlacement,\n middleware: [\n flip(),\n offset(({ rects, placement }) => {\n // gets the current placement side, especially after flip() is run\n const placementSide = placement.split('-')[0] as Side;\n const isBottom = placementSide === ('bottom' satisfies Side);\n\n // if the placement is at the bottom, we need to adjust the offset\n if (isBottom && chipsHeight.value > contentHeight.value) {\n return chipsHeight.value - rects.reference.height + GAP_HEIGHT;\n } else {\n return GAP_HEIGHT;\n }\n }),\n size({\n apply({ availableHeight, elements, rects }) {\n if (props.enableTeleport) {\n Object.assign(elements.floating.style, {\n maxWidth: `${rects.reference.width}px`,\n maxHeight: `${Math.min(availableHeight, MENU_MAX_HEIGHT_PX)}px`,\n });\n }\n },\n }),\n ],\n });\n const resizeObserverChips = new ResizeObserver(() => debouncedUpdateChipsHeight());\n\n const isSearchable = computed(() => !props.hideSearch && props.searchable !== 'false' && props.searchable !== false);\n\n const internalOptions = computed(() => {\n let OPTIONS = (shouldUseLazyOptions.value && props.lazy ? props.lazy() : props.options).filter(Boolean); // prevent [undefined]\n\n // if `options` is an array... but not an array of objects\n if (!isPlainObject(OPTIONS[0])) {\n OPTIONS = OPTIONS.map((name, id) => ({ name, id }) as unknown as Option);\n }\n\n return OPTIONS;\n });\n\n const readOnlyValue = computed(() => {\n if (!internalValue.value.length) {\n return '';\n }\n\n return internalValue.value.map((option) => option[props.displayBy] || option).join(', ');\n });\n\n const isSearching = computed(() => props.searchLoading || Object.keys(pendingSearchRequests.value).length > 0);\n\n const filteredOptions = computed(() => {\n if (props.disableFiltering || !(searchTerm.value || '').trim()) {\n return internalOptions.value;\n }\n\n return searchFor.value(searchTerm.value);\n });\n\n const isChipsOneLine = computed(() => chipsHeight.value <= contentHeight.value);\n\n const shouldShowTotal = computed(\n () => !isActive.value && !props.single && !isChipsOneLine.value && internalValue.value.length,\n );\n\n const clearSelectionText = computed(() => {\n return [internalValue.value.length, props.selectItemType, 'selected'].filter(Boolean).join(' ');\n });\n\n const shouldPreventEmpty = computed(() => {\n return props.preventEmpty || props.allowEmpty === 'false' || props.allowEmpty === false;\n });\n\n watch(searchTerm, (currentValue, oldValue) => oldValue !== currentValue && setIndex(-1));\n\n watch(internalValue, () => debouncedUpdateChipsHeight(), { deep: true });\n\n watch(\n () => props.modelValue,\n (value) => {\n // multiple\n if (Array.isArray(value)) {\n const newValue = value.filter(Boolean); // sometimes modelValue is [undefined]\n\n if (!isEqual(newValue, internalValue.value)) {\n internalValue.value = newValue;\n }\n\n return;\n }\n\n // single; if value is a non-empty string or a non-empty object\n if (!isEmpty(value)) {\n if (!isEqual(value, internalValue.value[0])) {\n internalValue.value[0] = value;\n }\n\n return;\n }\n\n // if value is an empty object or falsy\n internalValue.value = [];\n },\n { immediate: true },\n );\n\n watch(\n () => props.options,\n () => {\n const { searchFor: searchForFn } = useSearch<Option>({\n items: computed(() => internalOptions.value),\n fieldNames: props.searchBy.length ? props.searchBy : [props.displayBy],\n trackBy: props.trackBy,\n });\n\n searchFor.value = (searchTerm) => searchForFn(searchTerm, { fuzzy: props.useFuzzySearch });\n },\n { immediate: true },\n );\n\n watch(chipsHeight, () => debouncedUpdateFloating());\n\n const debouncedUpdateFloating = debounce(() => updateFloating(), 50);\n const debouncedUpdateChipsHeight = debounce(() => updateChipsHeight(), 50);\n\n const isOptionDisabled = (option: Option) => {\n return option && typeof option === 'object' && 'disabled' in option && option?.disabled;\n };\n\n const clear = () => {\n internalValue.value = [];\n emit('update:model-value', props.single ? undefined : internalValue.value);\n emit('clear');\n };\n\n /**\n * Adds (or selects) an option.\n * @param {Option} option The selected option\n */\n const handleSelect = (option?: Option) => {\n if (props.disabled || !option || isOptionDisabled(option)) {\n return;\n }\n\n if (!isSelected(option)) {\n if (props.single) {\n internalValue.value = [];\n }\n\n internalValue.value.push(option);\n emit('update:model-value', props.single ? internalValue.value[0] : internalValue.value);\n emit('add', option);\n } else {\n remove(option);\n }\n\n if (props.single) {\n dismiss();\n }\n };\n\n const handleSelectChange = (evt) => {\n // If this is a single select, just pass along the option\n // This short-circuit is purely for readability, as the iterations for multi would also work for single selects\n if (props.single) {\n const selectedOption = internalOptions.value.find((opt) => opt[props.trackBy]?.toString() === evt.target.value);\n handleSelect(selectedOption);\n return;\n }\n\n // Spread the HTMLCollection (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection) to array so we can invoke `find`\n const selectedOptions = [...evt.target.selectedOptions];\n\n // If it's a multiselect, the HTML select used for the screen reader can have multiple items\n // deselected and a new one selected in one change event.\n // We need to reconcile the new selected options with our internal state\n\n // 1. remove all the items in our internal state that are no longer present\n // (Spread this array so we can remove items from it while iterating)\n for (const internalOption of [...internalValue.value]) {\n const selectedOption = selectedOptions.find((opt) => opt.value === internalOption[props.trackBy]?.toString());\n\n if (!selectedOption) {\n remove(internalOption);\n }\n }\n\n // 2. add all the items that are now selected if needed\n for (const selectedOption of selectedOptions) {\n const internalOption = internalOptions.value.find(\n (opt) => opt[props.trackBy]?.toString() === selectedOption.value,\n );\n\n if (isSelected(internalOption)) {\n continue;\n } else {\n handleSelect(internalOption);\n }\n }\n };\n\n /**\n * Removes (or un-selects) an option.\n * @param {Option} option The option to be removed\n */\n const remove = (option: Option) => {\n if (props.disabled || (shouldPreventEmpty.value && internalValue.value.length === 1)) {\n return;\n }\n\n const index = internalValue.value.findIndex((opt) => opt[props.trackBy] === option[props.trackBy]);\n\n if (index === -1) {\n logger.warn('ll-select: could not find option to remove', option);\n return;\n }\n\n internalValue.value.splice(index, 1);\n emit('update:model-value', props.single ? internalValue.value[0] : internalValue.value);\n emit('remove', option, index);\n };\n\n /**\n * Opens the `options` drawer and provides focus.\n */\n const open = () => {\n if (isActive.value) {\n return;\n }\n\n debouncedUpdateChipsHeight();\n\n isActive.value = true;\n emit('opened');\n\n if (isSearchable.value) {\n nextTick(() => {\n searchRef.value?.focus({ preventScroll: true });\n });\n }\n };\n\n /**\n * Closes the drawer and cleans up a few settings.\n */\n const dismiss = () => {\n if (isActive.value) {\n emit('closed', internalValue.value);\n }\n\n setIndex(-1);\n isActive.value = false;\n\n if (!props.preserveSearchTerm) {\n searchTerm.value = '';\n }\n\n // The optional chaining here is required.\n // There are cases when the component is removed from the DOM and the ref is lost.\n // .ie when the component is used in a modal and the modal is dismissed.\n // Tracked in this ticket: F-1893\n contentRef.value?.blur(); // if the component remains in focus, clicking it again will not open the options list\n };\n\n /**\n * Scroll list items when up and down keys are pressed\n * @param {KeyboardEvent} e The native keydown event.\n */\n const scrollItems = async (e: KeyboardEvent) => {\n await nextTick();\n\n if (!contentRef.value) {\n return;\n }\n\n const allowedKeyCodes = [KEY_CODES.ENTER, KEY_CODES.ESCAPE] as number[];\n\n // Wait for highlighted item update after using keyboard (`onKeyDown`)\n if (!allowedKeyCodes.includes(e.keyCode)) {\n const el = contentRef.value.querySelector('.stash-select__option--highlighted');\n const elBCR = el?.getBoundingClientRect();\n const parentBCR = contentRef.value.getBoundingClientRect();\n\n if (!elBCR || !parentBCR) {\n return;\n }\n\n if (elBCR.bottom >= parentBCR.bottom || elBCR.top <= parentBCR.top + elBCR.height) {\n el?.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n }\n };\n\n /**\n * Sets the `activeIndex` on hover, so that the user may then fine-tune\n * their selection with the arrow keys.\n */\n const setIndex = (index: number) => {\n activeIndex.value = index;\n };\n\n /**\n * Handles all user keyboard input on the Dropdown.\n * @param {KeyboardEvent} e The native keydown event.\n */\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.keyCode === KEY_CODES.ESCAPE) {\n dismiss();\n } else if (e.keyCode === KEY_CODES.DOWN && activeIndex.value < filteredOptions.value.length - 1 && isActive.value) {\n activeIndex.value++;\n } else if (e.keyCode === KEY_CODES.UP && activeIndex.value > 0) {\n if (isActive.value) {\n activeIndex.value--;\n }\n\n // Scroll to top when search is available and first element is highlighted (Using 100 to be sure that it'll be sure that search is visible)\n if (optionsWrapperRef.value && isSearchable.value && activeIndex.value === 0) {\n optionsWrapperRef.value.scrollTop -= 100;\n }\n } else if (e.keyCode === KEY_CODES.ENTER && activeIndex.value !== -1 && isActive.value) {\n handleSelect(filteredOptions.value[activeIndex.value]);\n } else {\n return;\n }\n\n e.preventDefault(); // if keyDown did something / we didn't return\n scrollItems(e);\n };\n\n const handleSearchInput = debounce(function () {\n search();\n }, DEBOUNCE.FAST);\n\n const search = async function () {\n if (!props.onSearch) {\n return;\n }\n\n const requestId = uniqueId('search-request-');\n\n try {\n pendingSearchRequests.value[requestId] = true;\n await props.onSearch(searchTerm.value);\n } finally {\n delete pendingSearchRequests.value[requestId];\n }\n };\n\n /**\n * Dynamically sets classes on an `option` in the drawer.\n * @param {Option} option The `option` for which to generate classes\n * @param {number} index The index of the `option` in the list of `options`\n */\n const optionClass = (option: Option, index: number) => {\n return [\n {\n 'stash-select__option': true,\n 'stash-select__option--disabled': isOptionDisabled(option),\n 'stash-select__option--highlighted': activeIndex.value === index,\n 'stash-select__option--selected': isSelected(option),\n },\n\n // @deprecated\n // backwards compatibility\n {\n 'is-selected': activeIndex.value === index,\n 'bg-ice-200': activeIndex.value === index,\n 'bg-blue-100 text-ice-700': isSelected(option),\n },\n ];\n };\n\n /**\n * Finds out if the given item is already present in the selected options\n * @param {Option} option The item to check\n * @returns {boolean} Returns true if element is selected\n */\n const isSelected = (option?: Option | null): boolean => {\n if (option === undefined || option === null) {\n return false;\n }\n\n return internalValue.value.some((value) => value?.[props.trackBy] === option[props.trackBy]);\n };\n\n /**\n * Checks if the element is within the Select menu by checking both the content and the teleportTo element\n */\n function isElementWithinSelectMenu(element: Node | null) {\n if (!element) {\n return false;\n }\n\n const isElementInMenu = contentRef.value?.contains(element);\n const isElementInTeleportedMenu = optionsWrapperRef.value?.contains(element);\n\n return isElementInMenu || isElementInTeleportedMenu;\n }\n\n function handleFocusOut(focusEvent: FocusEvent) {\n const nextFocusedElement = focusEvent.relatedTarget as Node | null;\n const isFocusedElementInMenu = isElementWithinSelectMenu(nextFocusedElement);\n\n if (!isFocusedElementInMenu && nextFocusedElement) {\n dismiss();\n }\n }\n\n function handleOutsideClick(event: MouseEvent) {\n const target = event.target as Node | null;\n const isFocusedElementInMenu = isElementWithinSelectMenu(target);\n\n if (!isFocusedElementInMenu) {\n dismiss();\n }\n }\n\n /**\n * Handles the mouse leave of the select and clears item highlight\n */\n const handleMouseLeave = () => {\n setIndex(-1);\n };\n\n /**\n * Update height of chips container\n */\n const updateChipsHeight = async () => {\n // Wait for the DOM to update so we can get an accurate value for chips' clientHeight\n await nextTick();\n\n if (chipsRef.value && contentRef.value) {\n contentHeight.value = contentHeight.value === 0 ? contentRef.value.clientHeight : contentHeight.value;\n chipsHeight.value = chipsRef.value.clientHeight;\n }\n };\n\n onMounted(() => {\n if (attrs.onInput) {\n throw new Error('ll-select: use the @update:model-value event instead of @input.');\n }\n\n if (chipsRef.value) {\n resizeObserverChips.observe(chipsRef.value);\n }\n\n window.addEventListener('resize', debouncedUpdateChipsHeight);\n\n debouncedUpdateChipsHeight();\n });\n\n /**\n * Remove event listener to handle component width when resizing window\n */\n onUnmounted(() => {\n window.removeEventListener('resize', updateChipsHeight);\n resizeObserverChips.disconnect();\n debouncedUpdateChipsHeight.cancel();\n });\n</script>\n\n<template>\n <Field\n v-bind=\"props\"\n class=\"input ll-select stash-select\"\n data-test=\"stash-select\"\n :class=\"attrs.class\"\n :error-text=\"props.errorText || props.error\"\n :hint-text=\"props.hintText || props.hint\"\n >\n <template v-if=\"props.isReadOnly\" #default=\"{ fieldId, labelId }\">\n <div class=\"flex h-input items-center text-sm\">\n <span :id=\"fieldId\" :aria-labelledby=\"labelId\" class=\"show-empty h-min\">\n {{ readOnlyValue }}\n </span>\n </div>\n </template>\n <template v-else #default=\"{ fieldId, fieldErrorId, hasError }\">\n <!-- SCREEN READER ONLY -->\n <select\n :id=\"fieldId\"\n :aria-errormessage=\"fieldErrorId\"\n :aria-invalid=\"hasError\"\n class=\"sr-only\"\n :disabled=\"props.disabled\"\n :multiple=\"!props.single\"\n :name=\"props.name\"\n @change=\"handleSelectChange\"\n >\n <option\n v-for=\"(option, index) in filteredOptions\"\n :key=\"`srOnlyOption-${index}`\"\n :selected=\"isSelected(option)\"\n :value=\"option[props.trackBy]\"\n :disabled=\"isOptionDisabled(option)\"\n >\n {{ option[props.displayBy] || '' }}\n </option>\n\n <!-- Empty option to allow deselecting non-multiselects -->\n <option value=\"\"></option>\n </select>\n\n <!-- SELECT -->\n <div\n ref=\"selectRef\"\n v-clickoutside=\"handleOutsideClick\"\n role=\"listbox\"\n aria-hidden=\"true\"\n class=\"stash-select__content-wrapper\"\n :aria-controls=\"'listbox-' + fieldId\"\n :aria-expanded=\"isActive\"\n :aria-label=\"props.placeholder\"\n :aria-disabled=\"props.disabled || undefined\"\n :class=\"[\n {\n 'stash-select--disabled': !!props.disabled,\n 'stash-select--error': !!(props.errorText || props.error),\n 'stash-select--active': isActive,\n 'stash-select--single': props.single,\n },\n\n // @deprecated\n // backwards compatibility\n {\n 'is-active': isActive,\n 'is-single': props.single,\n 'is-disabled': props.disabled,\n },\n ]\"\n @keydown=\"onKeyDown\"\n @keyup.esc=\"dismiss\"\n >\n <!-- CONTENT -->\n <div\n :id=\"'listbox-' + fieldId\"\n ref=\"contentRef\"\n class=\"input-field stash-select__content\"\n tabindex=\"0\"\n data-test=\"stash-select|dropdown-trigger\"\n @focusin=\"open\"\n @focusin.once=\"shouldUseLazyOptions = true\"\n @focusout=\"handleFocusOut\"\n @keydown=\"open\"\n @mouseleave=\"handleMouseLeave\"\n >\n <!-- CHIPS -->\n <ul ref=\"chipsRef\" class=\"stash-select__chips\">\n <!-- PLACEHOLDER -->\n <li\n v-if=\"!internalValue.length\"\n class=\"stash-select__placeholder mr-0 pl-1.5\"\n :class=\"{ truncate: !props.noTruncate }\"\n >\n {{ props.placeholder }}\n </li>\n\n <template v-if=\"props.single\">\n <li\n v-for=\"option of internalValue\"\n :key=\"`chip-${option[props.trackBy]}`\"\n class=\"stash-select__selected mr-0 pl-1.5\"\n :class=\"{ truncate: !props.noTruncate }\"\n >\n <slot\n name=\"selected\"\n :option=\"option\"\n :on-remove=\"() => remove(option)\"\n chip-selected-class=\"stash-select__chip\"\n >\n {{ option[props.displayBy] || option }}\n <button\n tabindex=\"-1\"\n class=\"stash-select__remove\"\n @keypress.enter.prevent=\"remove(option)\"\n @mousedown.prevent.stop=\"remove(option)\"\n >\n <Icon icon=\"close\" name=\"close\" size=\"small\" />\n </button>\n </slot>\n </li>\n </template>\n\n <template v-else>\n <li v-for=\"option of internalValue\" :key=\"`chip-${option[props.trackBy]}`\" class=\"inline-block\">\n <slot\n name=\"selected\"\n :option=\"option\"\n :on-remove=\"() => remove(option)\"\n chip-selected-class=\"stash-select__chip\"\n >\n <Chip\n bg-color=\"blue-500\"\n is-removable\n text-color=\"white\"\n class=\"stash-select__chip\"\n @remove=\"remove(option)\"\n >\n {{ option[props.displayBy] || option }}\n </Chip>\n </slot>\n </li>\n </template>\n </ul>\n\n <!-- TOTAL -->\n <div v-if=\"shouldShowTotal\" class=\"stash-select__total\">\n <Chip bg-color=\"blue-500\" is-removable text-color=\"white\" class=\"stash-select__chip\" @remove=\"clear\">\n {{ clearSelectionText }}\n </Chip>\n </div>\n\n <!-- TOGGLE -->\n <Icon\n v-if=\"props.icon\"\n class=\"stash-select__icon\"\n data-test=\"stash-select|toggle-icon\"\n :name=\"props.icon as IconName\"\n :class=\"{ 'text-ice-500': props.disabled }\"\n @mousedown.prevent=\"isActive && dismiss()\"\n />\n <!-- DRAWER -->\n <Teleport :to=\"props.teleportTo\" :disabled=\"!props.enableTeleport\">\n <transition name=\"fade\">\n <div\n v-show=\"isActive && !props.disabled\"\n ref=\"optionsWrapperRef\"\n class=\"stash-select__border-selector w-full shadow-2xl\"\n :style=\"floatingStyles\"\n @click.stop\n >\n <!-- SEARCH -->\n <div v-if=\"isSearchable\" class=\"flex items-center border-b border-blue-500 pr-1.5\">\n <input\n ref=\"searchRef\"\n v-model=\"searchTerm\"\n type=\"text\"\n autocomplete=\"off\"\n class=\"stash-select__search\"\n :data-test=\"attrs['data-test'] ? attrs['data-test'] + '-search' : 'stash-select|search'\"\n :placeholder=\"props.searchPlaceholder\"\n :spellcheck=\"false\"\n @input=\"handleSearchInput\"\n />\n <Icon name=\"search\" class=\"text-ice-500\" />\n </div>\n\n <!-- OPTIONS -->\n <ul class=\"stash-select__options options my-1.5 w-full border-white bg-white\">\n <li\n v-for=\"(option, index) in filteredOptions\"\n :key=\"`option-${option[props.trackBy]}`\"\n :data-test=\"option[props.trackBy]\"\n :class=\"optionClass(option, index)\"\n @click=\"handleSelect(option)\"\n @mouseenter.self=\"setIndex(index)\"\n >\n <slot name=\"option\" :option=\"option\">\n {{ option[props.displayBy] || option }}\n </slot>\n\n <span v-if=\"isSelected(option) && !props.hideCheck\" class=\"ml-auto pl-1.5\">\n <Icon class=\"text-blue-500\" name=\"check\" />\n </span>\n </li>\n <li v-show=\"props.loading || isSearching\" class=\"m-1.5 cursor-default p-1.5\">\n <Icon data-test=\"stash-select|options-loading\" name=\"working\" class=\"animate-spin text-ice-500\" />\n </li>\n <li\n v-show=\"!props.loading && !isSearching && !filteredOptions.length\"\n class=\"m-1.5 cursor-default p-1.5\"\n data-test=\"stash-select|no-options\"\n >\n <slot name=\"no-options\"> No options </slot>\n </li>\n </ul>\n </div>\n </transition>\n </Teleport>\n </div>\n </div>\n </template>\n <template v-if=\"slots.hint?.()\" #hint>\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style scoped>\n @reference \"../../../styles/main.css\";\n\n @layer utilities {\n .stash-select {\n position: relative;\n }\n\n .stash-select__content,\n .stash-select__content-wrapper {\n height: var(--height-input);\n }\n\n .stash-select__content {\n cursor: pointer;\n overflow: hidden;\n position: absolute;\n background: var(--color-white);\n border: 1px solid var(--color-ice-500);\n border-radius: var(--radius-sm);\n color: var(--color-ice-700);\n display: block;\n font-family: var(--font-family-sofia);\n font-size: var(--text-sm);\n font-weight: normal;\n outline: none;\n padding: 0 !important;\n width: 100%;\n\n &:hover {\n border-color: var(--color-ice-500);\n }\n\n &:focus-within {\n border-color: var(--color-blue-500) !important;\n }\n }\n\n .stash-select--disabled .stash-select__content {\n background-color: var(--color-ice-100);\n border-color: var(--color-ice-500);\n color: var(--color-ice-500);\n pointer-events: none !important;\n }\n\n .stash-select--active .stash-select__content {\n cursor: default;\n height: auto;\n min-width: var(--width-select-menu);\n overflow: visible;\n z-index: var(--z-index-control);\n box-shadow: var(--shadow);\n }\n\n .stash-select--error :where(.stash-select__content, .stash-select__content:hover:not(:focus)) {\n border-color: var(--color-red-500) !important;\n }\n\n .stash-select__placeholder {\n color: var(--color-ice-500);\n }\n\n .stash-select--active .stash-select__placeholder {\n cursor: default;\n }\n\n .stash-select__icon {\n color: var(--color-ice-700);\n cursor: pointer;\n pointer-events: none;\n position: absolute;\n right: --spacing(1.5);\n top: --spacing(1.5);\n }\n\n .stash-select--disabled .stash-select__icon {\n color: var(--color-ice-500);\n }\n\n .stash-select--active .stash-select__icon {\n pointer-events: auto;\n }\n\n .stash-select__chips {\n /* distribute (or split?) the margin between chip and chips container. TODO? */\n --half-space: calc(--spacing(1.5) / 2);\n\n padding: var(--half-space);\n padding-right: --spacing(9);\n }\n\n /* chip AND placeholder AND selected: */\n .stash-select__chips > li {\n cursor: pointer;\n height: var(--height-chip);\n margin: var(--half-space);\n max-width: 100%;\n }\n\n .stash-select--disabled .stash-select__chips > li {\n cursor: default;\n }\n\n .stash-select__content-wrapper:deep(.stash-select__chip) {\n border-radius: var(--radius-sm);\n font-size: var(--text-sm);\n font-weight: normal;\n height: var(--height-chip);\n max-width: inherit;\n text-transform: none;\n }\n\n .stash-select--disabled:deep(.stash-select__chip) {\n background: var(--color-ice-500);\n color: var(--color-white);\n }\n\n /* Base total chip styles moved above the more specific descendant rule to satisfy no-descending-specificity */\n .stash-select__total {\n display: block;\n font-weight: var(--font-weight-semibold);\n line-height: var(--line-height-button);\n position: absolute;\n right: --spacing(6);\n white-space: nowrap;\n z-index: var(--z-index-content);\n\n /* -- design TBD --- */\n top: 0;\n left: 0;\n bottom: 0;\n color: var(--color-white);\n background: white;\n padding: --spacing(1.5);\n }\n\n .stash-select__content-wrapper .stash-select__total:deep(.stash-select__chip) {\n font-weight: var(--font-weight-normal);\n }\n\n .stash-select__selected {\n color: var(--color-ice-700);\n }\n\n .stash-select--disabled .stash-select__selected {\n color: var(--color-ice-500);\n }\n\n .stash-select__selected :where(.stash-select__remove) {\n display: none;\n }\n\n .stash-select__search {\n position: relative;\n width: 100%;\n height: var(--height-input);\n background: var(--color-white);\n border-radius: var(--radius-sm);\n color: var(--color-ice-700);\n display: block;\n font-family: var(--font-family-sofia);\n font-size: var(--text-sm);\n font-weight: var(--font-weight-normal);\n outline: none;\n padding: 0 --spacing(3);\n border: 0 !important;\n }\n\n .stash-select__border-selector {\n background: white;\n border-radius: var(--radius-sm);\n border: 1px solid var(--color-blue-500);\n max-height: var(--max-height-select-menu);\n overflow: auto;\n z-index: var(--z-index-dialog);\n }\n\n .stash-select__option {\n align-items: center;\n border-radius: var(--radius-sm);\n cursor: pointer;\n display: flex;\n line-height: --spacing(6);\n margin: --spacing(1.5);\n padding: --spacing(1.5);\n }\n\n .stash-select__option--disabled {\n color: var(--color-ice-500);\n cursor: not-allowed;\n }\n\n .stash-select__option--highlighted {\n background-color: var(--color-ice-200);\n }\n\n .stash-select__option--selected {\n background-color: var(--color-blue-100);\n color: var(--color-ice-700);\n }\n }\n</style>\n"],"names":["props","__props","emit","__emit","attrs","useAttrs","slots","_useSlots","selectRef","ref","contentRef","optionsWrapperRef","chipsRef","searchRef","chipsHeight","contentHeight","internalValue","searchFor","searchTerm","activeIndex","isActive","pendingSearchRequests","shouldUseLazyOptions","floatingStyles","updateFloating","useFloating","autoUpdate","flip","offset","rects","placement","size","availableHeight","elements","resizeObserverChips","debouncedUpdateChipsHeight","isSearchable","computed","internalOptions","OPTIONS","isPlainObject","name","id","readOnlyValue","option","isSearching","filteredOptions","isChipsOneLine","shouldShowTotal","clearSelectionText","shouldPreventEmpty","watch","currentValue","oldValue","setIndex","value","newValue","isEqual","isEmpty","searchForFn","useSearch","debouncedUpdateFloating","debounce","updateChipsHeight","isOptionDisabled","clear","handleSelect","isSelected","remove","dismiss","handleSelectChange","evt","selectedOption","opt","_a","selectedOptions","internalOption","index","logger","open","nextTick","scrollItems","KEY_CODES","el","elBCR","parentBCR","onKeyDown","handleSearchInput","search","DEBOUNCE","requestId","uniqueId","optionClass","isElementWithinSelectMenu","element","isElementInMenu","isElementInTeleportedMenu","_b","handleFocusOut","focusEvent","nextFocusedElement","handleOutsideClick","event","target","handleMouseLeave","onMounted","onUnmounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsME,UAAMA,IAAQC,IAiCRC,IAAOC,IA2BPC,IAAQC,GAAA,GACRC,IAAQC,GAAA,GAqCRC,KAAYC,EAA2B,IAAI,GAC3CC,IAAaD,EAA2B,IAAI,GAC5CE,IAAoBF,EAA2B,IAAI,GACnDG,IAAWH,EAA6B,IAAI,GAC5CI,KAAYJ,EAA6B,IAAI,GAE7CK,IAAcL,EAAI,CAAC,GACnBM,IAAgBN,EAAI,CAAC,GACrBO,IAAgBP,EAAc,EAAE,GAChCQ,KAAYR,EAAsC,MAAM,EAAE,G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vue"],"sourcesContent":["<script lang=\"ts\">\n import { FieldProps } from '../Field/Field.types';\n\n // Note: the `trackBy` prop, the `single` prop, and the fact that options can be strings prevents us from knowing the type of the selected options\n\n type Option = any;\n\n type SelectedOptions = Option | Option[];\n\n export interface SelectProps extends FieldProps {\n /**\n * If there is only 1 option selected, it prevents that option from being de-selected\n */\n preventEmpty?: boolean;\n\n /**\n * @deprecated The `allowEmpty` prop is no longer supported; use `preventEmpty` instead.\n */\n allowEmpty?: string | boolean | null;\n\n /**\n * If `options` are an object, this is what prop to use for display.\n */\n displayBy?: string;\n\n /**\n * List of one or more fields to search on. When empty, displayBy will be used\n */\n searchBy?: string[];\n\n /**\n * Default field to track selected options by.\n */\n trackBy?: string;\n\n /**\n * Placeholder text.\n */\n placeholder?: string;\n\n /**\n * @deprecated Use the `error-text` prop instead\n */\n error?: string;\n\n /**\n * @deprecated Use the `hint-text` prop instead\n */\n hint?: string;\n\n /**\n * Sets a custom icon.\n */\n icon?: string | boolean;\n\n /**\n * Sets a name attribute on the native (hidden) select element\n *\n * Setting the default value to `undefined` so the attribute isn't rendered if not explicitly provided to ensure backwards compatibility with MP django forms\n */\n name?: string;\n\n /**\n * The list of all options to select from.\n */\n options?: Option[] | readonly Option[];\n\n /**\n * Lazily evaluate and set component `options`. Will execute upon user mouseover.\n */\n lazy?: () => Option[];\n\n /**\n * Sets the currently-selected value(s) for the component.\n * Accepts an array of Objects, or a single Object (if `single` is true), or a string\n */\n modelValue?: SelectedOptions;\n\n /**\n * @deprecated Use :model-value or v-model instead of :value.\n */\n value?: SelectedOptions | null;\n\n /**\n * Hides the search input\n */\n hideSearch?: boolean;\n\n /**\n * @deprecated The `searchable` prop is no longer supported; Use `hideSearch` instead.\n */\n searchable?: string | boolean | null;\n\n /**\n * If true, prevents the search term from being cleared when the drawer is dismissed.\n */\n preserveSearchTerm?: boolean;\n\n /**\n * Prevents the options from being filtered when the search term changes.\n * Allows the parent to filter the options.\n */\n disableFiltering?: boolean;\n\n /**\n * Functions as a single select, if true\n */\n single?: boolean;\n\n /**\n * Prevents the Selected Option from being truncated, if true\n */\n noTruncate?: boolean;\n\n /**\n * On an ajaxed request when the dropdown is open, we may be experiencing slower load times.\n * This flag will drop a loader into the dropdown. Note: This has never been design reviewed.\n */\n loading?: boolean;\n\n /**\n * @deprecated Instead, use the `@search` event (the onSearch prop) and ensure its event handler returns a Promise that resolves after the search is complete.\n */\n searchLoading?: boolean;\n\n /**\n * In the selection text we use this to give more visual distinction to what type of item(s) are selected\n * E.g. 2 customers selected. An empty string will result in `2 selected`.\n */\n selectItemType?: string;\n\n /**\n * Hides the \"check\" icon if truthy\n */\n hideCheck?: boolean;\n\n searchPlaceholder?: string;\n\n /**\n * Equivalent to emitting a \"search\" event, except this prop can be used to populate the list of `options` using an HTTP request because a prop's return value can be received and awaited, unlike an event.\n *\n * **Tip:** to show a loading indicator while searching, return a Promise that resolves after the search is complete.\n *\n * **Warning:** the search input is debounced so there is no need to debounce this function.\n */\n onSearch?: (searchTerm: string) => Promise<void> | void;\n\n /**\n * Uses the \"fuzzy search\" algorithm when searching, if true\n */\n useFuzzySearch?: boolean;\n\n /**\n * Sets the placement of the dropdown\n * @default 'bottom-start'\n */\n menuPlacement?: Placement;\n\n /**\n * Enables teleporting the dropdown\n * @default false\n */\n enableTeleport?: boolean;\n\n /**\n * The selector or element to which the dropdown should be teleported\n * @default `'#stash-menus-mount-node'`\n */\n teleportTo?: string | HTMLElement;\n }\n</script>\n\n<script setup lang=\"ts\">\n import { autoUpdate, flip, offset, type Placement, type Side, size, useFloating } from '@floating-ui/vue';\n import logger from '@leaflink/snitch';\n import debounce from 'lodash-es/debounce';\n import isEmpty from 'lodash-es/isEmpty';\n import isEqual from 'lodash-es/isEqual';\n import isPlainObject from 'lodash-es/isPlainObject';\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, nextTick, onMounted, onUnmounted, type Ref, ref, useAttrs, watch } from 'vue';\n\n import useSearch from '../../composables/useSearch/useSearch';\n import { DEBOUNCE, KEY_CODES } from '../../constants';\n import vClickoutside from '../../directives/clickoutside/clickoutside';\n import { DEFAULT_MENUS_PLUGIN_NODE_ID } from '../../plugins/MenusPlugin';\n import Chip from '../Chip/Chip.vue';\n import Field from '../Field/Field.vue';\n import Icon, { IconName } from '../Icon/Icon.vue';\n\n const GAP_HEIGHT = 6;\n\n const MENU_MAX_HEIGHT_PX = 300;\n\n defineOptions({\n name: 'll-select',\n });\n\n const props = withDefaults(defineProps<SelectProps>(), {\n preventEmpty: false,\n allowEmpty: null,\n displayBy: 'name',\n searchBy: () => [],\n trackBy: 'id',\n placeholder: 'Select option',\n error: '',\n hint: '',\n icon: 'caret-down',\n name: undefined,\n options: () => [],\n lazy: undefined,\n modelValue: () => [],\n value: null,\n hideSearch: false,\n searchable: null,\n preserveSearchTerm: false,\n disableFiltering: false,\n single: false,\n noTruncate: false,\n loading: false,\n searchLoading: false,\n selectItemType: '',\n hideCheck: false,\n searchPlaceholder: 'Search',\n onSearch: undefined,\n useFuzzySearch: false,\n menuPlacement: 'bottom-start',\n enableTeleport: false,\n teleportTo: `#${DEFAULT_MENUS_PLUGIN_NODE_ID}`,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the model value changes.\n */\n (e: 'update:model-value', selectedOptions: SelectedOptions): void;\n /**\n * Emitted the selected value(s) a cleared.\n */\n (e: 'clear'): void;\n /**\n * Emitted when an option is added.\n */\n (e: 'add', optionAdded: Option): void;\n /**\n * Emitted when an option is removed.\n */\n (e: 'remove', optionRemoved: Option, index: number): void;\n /**\n * Emitted when the select is opened.\n */\n (e: 'opened'): void;\n /**\n * Emitted when the select is closed.\n */\n (e: 'closed', selectedOptions: SelectedOptions): void;\n }>();\n\n const attrs = useAttrs();\n const slots = defineSlots<{\n /**\n * Selected value(s) custom text. Exposes the option object and remove function.\n */\n selected(props: {\n /**\n * The selected option object.\n */\n option: Option;\n /**\n * Function to remove the selected option from the selection.\n */\n onRemove: () => void;\n /**\n * Class to apply to the selected chip.\n */\n chipSelectedClass: string;\n }): unknown;\n /**\n * Select custom option text. Exposes the option object\n */\n option(props: {\n /**\n * Option The option instance for this list item.\n */\n option: Option;\n }): unknown;\n /**\n * Slot for when there are no options available.\n */\n 'no-options'(): unknown;\n /**\n * Slot to display a helpful hint message below the select field.\n */\n hint(): unknown;\n }>();\n\n const selectRef = ref<HTMLDivElement | null>(null);\n const contentRef = ref<HTMLDivElement | null>(null);\n const optionsWrapperRef = ref<HTMLDivElement | null>(null);\n const chipsRef = ref<HTMLUListElement | null>(null);\n const searchRef = ref<HTMLInputElement | null>(null);\n\n const chipsHeight = ref(0);\n const contentHeight = ref(0);\n const internalValue = ref<Option[]>([]) as Ref<Option[]>;\n const searchFor = ref<(searchTerm: string) => Option[]>(() => []); // initialized in the watch handler for options\n const searchTerm = ref('');\n const activeIndex = ref(-1);\n const isActive = ref(false);\n const pendingSearchRequests = ref({});\n const shouldUseLazyOptions = ref(false);\n\n const { floatingStyles, update: updateFloating } = useFloating(selectRef, optionsWrapperRef, {\n whileElementsMounted: autoUpdate,\n placement: props.menuPlacement,\n middleware: [\n flip(),\n offset(({ rects, placement }) => {\n // gets the current placement side, especially after flip() is run\n const placementSide = placement.split('-')[0] as Side;\n const isBottom = placementSide === ('bottom' satisfies Side);\n\n // if the placement is at the bottom, we need to adjust the offset\n if (isBottom && chipsHeight.value > contentHeight.value) {\n return chipsHeight.value - rects.reference.height + GAP_HEIGHT;\n } else {\n return GAP_HEIGHT;\n }\n }),\n size({\n apply({ availableHeight, elements, rects }) {\n if (props.enableTeleport) {\n Object.assign(elements.floating.style, {\n maxWidth: `${rects.reference.width}px`,\n maxHeight: `${Math.min(availableHeight, MENU_MAX_HEIGHT_PX)}px`,\n });\n }\n },\n }),\n ],\n });\n const resizeObserverChips = new ResizeObserver(() => debouncedUpdateChipsHeight());\n\n const isSearchable = computed(() => !props.hideSearch && props.searchable !== 'false' && props.searchable !== false);\n\n const internalOptions = computed(() => {\n let OPTIONS = (shouldUseLazyOptions.value && props.lazy ? props.lazy() : props.options).filter(Boolean); // prevent [undefined]\n\n // if `options` is an array... but not an array of objects\n if (!isPlainObject(OPTIONS[0])) {\n OPTIONS = OPTIONS.map((name, id) => ({ name, id }) as unknown as Option);\n }\n\n return OPTIONS;\n });\n\n const readOnlyValue = computed(() => {\n if (!internalValue.value.length) {\n return '';\n }\n\n return internalValue.value.map((option) => option[props.displayBy] || option).join(', ');\n });\n\n const isSearching = computed(() => props.searchLoading || Object.keys(pendingSearchRequests.value).length > 0);\n\n const filteredOptions = computed(() => {\n if (props.disableFiltering || !(searchTerm.value || '').trim()) {\n return internalOptions.value;\n }\n\n return searchFor.value(searchTerm.value);\n });\n\n const isChipsOneLine = computed(() => chipsHeight.value <= contentHeight.value);\n\n const shouldShowTotal = computed(\n () => !isActive.value && !props.single && !isChipsOneLine.value && internalValue.value.length,\n );\n\n const clearSelectionText = computed(() => {\n return [internalValue.value.length, props.selectItemType, 'selected'].filter(Boolean).join(' ');\n });\n\n const shouldPreventEmpty = computed(() => {\n return props.preventEmpty || props.allowEmpty === 'false' || props.allowEmpty === false;\n });\n\n watch(searchTerm, (currentValue, oldValue) => oldValue !== currentValue && setIndex(-1));\n\n watch(internalValue, () => debouncedUpdateChipsHeight(), { deep: true });\n\n watch(\n () => props.modelValue,\n (value) => {\n // multiple\n if (Array.isArray(value)) {\n const newValue = value.filter(Boolean); // sometimes modelValue is [undefined]\n\n if (!isEqual(newValue, internalValue.value)) {\n internalValue.value = newValue;\n }\n\n return;\n }\n\n // single; if value is a non-empty string or a non-empty object\n if (!isEmpty(value)) {\n if (!isEqual(value, internalValue.value[0])) {\n internalValue.value[0] = value;\n }\n\n return;\n }\n\n // if value is an empty object or falsy\n internalValue.value = [];\n },\n { immediate: true },\n );\n\n watch(\n () => props.options,\n () => {\n const { searchFor: searchForFn } = useSearch<Option>({\n items: computed(() => internalOptions.value),\n fieldNames: props.searchBy.length ? props.searchBy : [props.displayBy],\n trackBy: props.trackBy,\n });\n\n searchFor.value = (searchTerm) => searchForFn(searchTerm, { fuzzy: props.useFuzzySearch });\n },\n { immediate: true },\n );\n\n watch(chipsHeight, () => debouncedUpdateFloating());\n\n const debouncedUpdateFloating = debounce(() => updateFloating(), 50);\n const debouncedUpdateChipsHeight = debounce(() => updateChipsHeight(), 50);\n\n const isOptionDisabled = (option: Option) => {\n return option && typeof option === 'object' && 'disabled' in option && option?.disabled;\n };\n\n const clear = () => {\n internalValue.value = [];\n emit('update:model-value', props.single ? undefined : internalValue.value);\n emit('clear');\n };\n\n /**\n * Adds (or selects) an option.\n * @param {Option} option The selected option\n */\n const handleSelect = (option?: Option) => {\n if (props.disabled || !option || isOptionDisabled(option)) {\n return;\n }\n\n if (!isSelected(option)) {\n if (props.single) {\n internalValue.value = [];\n }\n\n internalValue.value.push(option);\n emit('update:model-value', props.single ? internalValue.value[0] : internalValue.value);\n emit('add', option);\n } else {\n remove(option);\n }\n\n if (props.single) {\n dismiss();\n }\n };\n\n const handleSelectChange = (evt) => {\n // If this is a single select, just pass along the option\n // This short-circuit is purely for readability, as the iterations for multi would also work for single selects\n if (props.single) {\n const selectedOption = internalOptions.value.find((opt) => opt[props.trackBy]?.toString() === evt.target.value);\n handleSelect(selectedOption);\n return;\n }\n\n // Spread the HTMLCollection (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection) to array so we can invoke `find`\n const selectedOptions = [...evt.target.selectedOptions];\n\n // If it's a multiselect, the HTML select used for the screen reader can have multiple items\n // deselected and a new one selected in one change event.\n // We need to reconcile the new selected options with our internal state\n\n // 1. remove all the items in our internal state that are no longer present\n // (Spread this array so we can remove items from it while iterating)\n for (const internalOption of [...internalValue.value]) {\n const selectedOption = selectedOptions.find((opt) => opt.value === internalOption[props.trackBy]?.toString());\n\n if (!selectedOption) {\n remove(internalOption);\n }\n }\n\n // 2. add all the items that are now selected if needed\n for (const selectedOption of selectedOptions) {\n const internalOption = internalOptions.value.find(\n (opt) => opt[props.trackBy]?.toString() === selectedOption.value,\n );\n\n if (isSelected(internalOption)) {\n continue;\n } else {\n handleSelect(internalOption);\n }\n }\n };\n\n /**\n * Removes (or un-selects) an option.\n * @param {Option} option The option to be removed\n */\n const remove = (option: Option) => {\n if (props.disabled || (shouldPreventEmpty.value && internalValue.value.length === 1)) {\n return;\n }\n\n const index = internalValue.value.findIndex((opt) => opt[props.trackBy] === option[props.trackBy]);\n\n if (index === -1) {\n logger.warn('ll-select: could not find option to remove', option);\n return;\n }\n\n internalValue.value.splice(index, 1);\n emit('update:model-value', props.single ? internalValue.value[0] : internalValue.value);\n emit('remove', option, index);\n };\n\n /**\n * Opens the `options` drawer and provides focus.\n */\n const open = () => {\n if (isActive.value) {\n return;\n }\n\n debouncedUpdateChipsHeight();\n\n isActive.value = true;\n emit('opened');\n\n if (isSearchable.value) {\n nextTick(() => {\n searchRef.value?.focus({ preventScroll: true });\n });\n }\n };\n\n /**\n * Closes the drawer and cleans up a few settings.\n */\n const dismiss = () => {\n if (isActive.value) {\n emit('closed', internalValue.value);\n }\n\n setIndex(-1);\n isActive.value = false;\n\n if (!props.preserveSearchTerm) {\n searchTerm.value = '';\n }\n\n // The optional chaining here is required.\n // There are cases when the component is removed from the DOM and the ref is lost.\n // .ie when the component is used in a modal and the modal is dismissed.\n // Tracked in this ticket: F-1893\n contentRef.value?.blur(); // if the component remains in focus, clicking it again will not open the options list\n };\n\n /**\n * Scroll list items when up and down keys are pressed\n * @param {KeyboardEvent} e The native keydown event.\n */\n const scrollItems = async (e: KeyboardEvent) => {\n await nextTick();\n\n if (!contentRef.value) {\n return;\n }\n\n const allowedKeyCodes = [KEY_CODES.ENTER, KEY_CODES.ESCAPE] as number[];\n\n // Wait for highlighted item update after using keyboard (`onKeyDown`)\n if (!allowedKeyCodes.includes(e.keyCode)) {\n const el = contentRef.value.querySelector('.stash-select__option--highlighted');\n const elBCR = el?.getBoundingClientRect();\n const parentBCR = contentRef.value.getBoundingClientRect();\n\n if (!elBCR || !parentBCR) {\n return;\n }\n\n if (elBCR.bottom >= parentBCR.bottom || elBCR.top <= parentBCR.top + elBCR.height) {\n el?.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n }\n };\n\n /**\n * Sets the `activeIndex` on hover, so that the user may then fine-tune\n * their selection with the arrow keys.\n */\n const setIndex = (index: number) => {\n activeIndex.value = index;\n };\n\n /**\n * Handles all user keyboard input on the Dropdown.\n * @param {KeyboardEvent} e The native keydown event.\n */\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.keyCode === KEY_CODES.ESCAPE) {\n dismiss();\n } else if (e.keyCode === KEY_CODES.DOWN && activeIndex.value < filteredOptions.value.length - 1 && isActive.value) {\n activeIndex.value++;\n } else if (e.keyCode === KEY_CODES.UP && activeIndex.value > 0) {\n if (isActive.value) {\n activeIndex.value--;\n }\n\n // Scroll to top when search is available and first element is highlighted (Using 100 to be sure that it'll be sure that search is visible)\n if (optionsWrapperRef.value && isSearchable.value && activeIndex.value === 0) {\n optionsWrapperRef.value.scrollTop -= 100;\n }\n } else if (e.keyCode === KEY_CODES.ENTER && activeIndex.value !== -1 && isActive.value) {\n handleSelect(filteredOptions.value[activeIndex.value]);\n } else {\n return;\n }\n\n e.preventDefault(); // if keyDown did something / we didn't return\n scrollItems(e);\n };\n\n const handleSearchInput = debounce(function () {\n search();\n }, DEBOUNCE.FAST);\n\n const search = async function () {\n if (!props.onSearch) {\n return;\n }\n\n const requestId = uniqueId('search-request-');\n\n try {\n pendingSearchRequests.value[requestId] = true;\n await props.onSearch(searchTerm.value);\n } finally {\n delete pendingSearchRequests.value[requestId];\n }\n };\n\n /**\n * Dynamically sets classes on an `option` in the drawer.\n * @param {Option} option The `option` for which to generate classes\n * @param {number} index The index of the `option` in the list of `options`\n */\n const optionClass = (option: Option, index: number) => {\n return [\n {\n 'stash-select__option': true,\n 'stash-select__option--disabled': isOptionDisabled(option),\n 'stash-select__option--highlighted': activeIndex.value === index,\n 'stash-select__option--selected': isSelected(option),\n },\n\n // @deprecated\n // backwards compatibility\n {\n 'is-selected': activeIndex.value === index,\n 'bg-ice-200': activeIndex.value === index,\n 'bg-blue-100 text-ice-700': isSelected(option),\n },\n ];\n };\n\n /**\n * Finds out if the given item is already present in the selected options\n * @param {Option} option The item to check\n * @returns {boolean} Returns true if element is selected\n */\n const isSelected = (option?: Option | null): boolean => {\n if (option === undefined || option === null) {\n return false;\n }\n\n return internalValue.value.some((value) => value?.[props.trackBy] === option[props.trackBy]);\n };\n\n /**\n * Checks if the element is within the Select menu by checking both the content and the teleportTo element\n */\n function isElementWithinSelectMenu(element: Node | null) {\n if (!element) {\n return false;\n }\n\n const isElementInMenu = contentRef.value?.contains(element);\n const isElementInTeleportedMenu = optionsWrapperRef.value?.contains(element);\n\n return isElementInMenu || isElementInTeleportedMenu;\n }\n\n function handleFocusOut(focusEvent: FocusEvent) {\n const nextFocusedElement = focusEvent.relatedTarget as Node | null;\n const isFocusedElementInMenu = isElementWithinSelectMenu(nextFocusedElement);\n\n if (!isFocusedElementInMenu && nextFocusedElement) {\n dismiss();\n }\n }\n\n function handleOutsideClick(event: MouseEvent) {\n const target = event.target as Node | null;\n const isFocusedElementInMenu = isElementWithinSelectMenu(target);\n\n if (!isFocusedElementInMenu) {\n dismiss();\n }\n }\n\n /**\n * Handles the mouse leave of the select and clears item highlight\n */\n const handleMouseLeave = () => {\n setIndex(-1);\n };\n\n /**\n * Update height of chips container\n */\n const updateChipsHeight = async () => {\n // Wait for the DOM to update so we can get an accurate value for chips' clientHeight\n await nextTick();\n\n if (chipsRef.value && contentRef.value) {\n contentHeight.value = contentHeight.value === 0 ? contentRef.value.clientHeight : contentHeight.value;\n chipsHeight.value = chipsRef.value.clientHeight;\n }\n };\n\n onMounted(() => {\n if (attrs.onInput) {\n throw new Error('ll-select: use the @update:model-value event instead of @input.');\n }\n\n if (chipsRef.value) {\n resizeObserverChips.observe(chipsRef.value);\n }\n\n window.addEventListener('resize', debouncedUpdateChipsHeight);\n\n debouncedUpdateChipsHeight();\n });\n\n /**\n * Remove event listener to handle component width when resizing window\n */\n onUnmounted(() => {\n window.removeEventListener('resize', updateChipsHeight);\n resizeObserverChips.disconnect();\n debouncedUpdateChipsHeight.cancel();\n });\n</script>\n\n<template>\n <Field\n v-bind=\"props\"\n class=\"input ll-select stash-select\"\n data-test=\"stash-select\"\n :class=\"attrs.class\"\n :error-text=\"props.errorText || props.error\"\n :hint-text=\"props.hintText || props.hint\"\n >\n <template v-if=\"props.isReadOnly\" #default=\"{ fieldId, labelId }\">\n <div class=\"flex h-input items-center text-sm\">\n <span :id=\"fieldId\" :aria-labelledby=\"labelId\" class=\"show-empty h-min\">\n {{ readOnlyValue }}\n </span>\n </div>\n </template>\n <template v-else #default=\"{ fieldId, fieldErrorId, hasError }\">\n <!-- SCREEN READER ONLY -->\n <select\n :id=\"fieldId\"\n :aria-errormessage=\"fieldErrorId\"\n :aria-invalid=\"hasError\"\n class=\"sr-only\"\n :disabled=\"props.disabled\"\n :multiple=\"!props.single\"\n :name=\"props.name\"\n @change=\"handleSelectChange\"\n >\n <option\n v-for=\"(option, index) in filteredOptions\"\n :key=\"`srOnlyOption-${index}`\"\n :selected=\"isSelected(option)\"\n :value=\"option[props.trackBy]\"\n :disabled=\"isOptionDisabled(option)\"\n >\n {{ option[props.displayBy] || '' }}\n </option>\n\n <!-- Empty option to allow deselecting non-multiselects -->\n <option value=\"\"></option>\n </select>\n\n <!-- SELECT -->\n <div\n ref=\"selectRef\"\n v-clickoutside=\"handleOutsideClick\"\n role=\"listbox\"\n aria-hidden=\"true\"\n class=\"stash-select__content-wrapper\"\n :aria-controls=\"'listbox-' + fieldId\"\n :aria-expanded=\"isActive\"\n :aria-label=\"props.placeholder\"\n :aria-disabled=\"props.disabled || undefined\"\n :class=\"[\n {\n 'stash-select--disabled': !!props.disabled,\n 'stash-select--error': !!(props.errorText || props.error),\n 'stash-select--active': isActive,\n 'stash-select--single': props.single,\n },\n\n // @deprecated\n // backwards compatibility\n {\n 'is-active': isActive,\n 'is-single': props.single,\n 'is-disabled': props.disabled,\n },\n ]\"\n @keydown=\"onKeyDown\"\n @keyup.esc=\"dismiss\"\n >\n <!-- CONTENT -->\n <div\n :id=\"'listbox-' + fieldId\"\n ref=\"contentRef\"\n class=\"input-field stash-select__content\"\n tabindex=\"0\"\n data-test=\"stash-select|dropdown-trigger\"\n @focusin=\"open\"\n @focusin.once=\"shouldUseLazyOptions = true\"\n @focusout=\"handleFocusOut\"\n @keydown=\"open\"\n @mouseleave=\"handleMouseLeave\"\n >\n <!-- CHIPS -->\n <ul ref=\"chipsRef\" class=\"stash-select__chips\">\n <!-- PLACEHOLDER -->\n <li\n v-if=\"!internalValue.length\"\n class=\"stash-select__placeholder mr-0 pl-1.5\"\n :class=\"{ truncate: !props.noTruncate }\"\n >\n {{ props.placeholder }}\n </li>\n\n <template v-if=\"props.single\">\n <li\n v-for=\"option of internalValue\"\n :key=\"`chip-${option[props.trackBy]}`\"\n class=\"stash-select__selected mr-0 pl-1.5\"\n :class=\"{ truncate: !props.noTruncate }\"\n >\n <slot\n name=\"selected\"\n :option=\"option\"\n :on-remove=\"() => remove(option)\"\n chip-selected-class=\"stash-select__chip\"\n >\n {{ option[props.displayBy] || option }}\n <button\n tabindex=\"-1\"\n class=\"stash-select__remove\"\n @keypress.enter.prevent=\"remove(option)\"\n @mousedown.prevent.stop=\"remove(option)\"\n >\n <Icon icon=\"close\" name=\"close\" size=\"small\" />\n </button>\n </slot>\n </li>\n </template>\n\n <template v-else>\n <li v-for=\"option of internalValue\" :key=\"`chip-${option[props.trackBy]}`\" class=\"inline-block\">\n <slot\n name=\"selected\"\n :option=\"option\"\n :on-remove=\"() => remove(option)\"\n chip-selected-class=\"stash-select__chip\"\n >\n <Chip\n bg-color=\"blue-500\"\n is-removable\n text-color=\"white\"\n class=\"stash-select__chip\"\n @remove=\"remove(option)\"\n >\n {{ option[props.displayBy] || option }}\n </Chip>\n </slot>\n </li>\n </template>\n </ul>\n\n <!-- TOTAL -->\n <div v-if=\"shouldShowTotal\" class=\"stash-select__total\">\n <Chip bg-color=\"blue-500\" is-removable text-color=\"white\" class=\"stash-select__chip\" @remove=\"clear\">\n {{ clearSelectionText }}\n </Chip>\n </div>\n\n <!-- TOGGLE -->\n <Icon\n v-if=\"props.icon\"\n class=\"stash-select__icon\"\n data-test=\"stash-select|toggle-icon\"\n :name=\"props.icon as IconName\"\n :class=\"{ 'text-ice-500': props.disabled }\"\n @mousedown.prevent=\"isActive && dismiss()\"\n />\n <!-- DRAWER -->\n <Teleport :to=\"props.teleportTo\" :disabled=\"!props.enableTeleport\">\n <transition name=\"fade\">\n <div\n v-show=\"isActive && !props.disabled\"\n ref=\"optionsWrapperRef\"\n class=\"stash-select__border-selector w-full shadow-2xl\"\n :style=\"floatingStyles\"\n @click.stop\n >\n <!-- SEARCH -->\n <div v-if=\"isSearchable\" class=\"flex items-center border-b border-blue-500 pr-1.5\">\n <input\n ref=\"searchRef\"\n v-model=\"searchTerm\"\n type=\"text\"\n autocomplete=\"off\"\n class=\"stash-select__search\"\n :data-test=\"attrs['data-test'] ? attrs['data-test'] + '-search' : 'stash-select|search'\"\n :placeholder=\"props.searchPlaceholder\"\n :spellcheck=\"false\"\n @input=\"handleSearchInput\"\n />\n <Icon name=\"search\" class=\"text-ice-500\" />\n </div>\n\n <!-- OPTIONS -->\n <ul class=\"stash-select__options options my-1.5 w-full border-white bg-white\">\n <li\n v-for=\"(option, index) in filteredOptions\"\n :key=\"`option-${option[props.trackBy]}`\"\n :data-test=\"option[props.trackBy]\"\n :class=\"optionClass(option, index)\"\n @click=\"handleSelect(option)\"\n @mouseenter.self=\"setIndex(index)\"\n >\n <slot name=\"option\" :option=\"option\">\n {{ option[props.displayBy] || option }}\n </slot>\n\n <span v-if=\"isSelected(option) && !props.hideCheck\" class=\"ml-auto pl-1.5\">\n <Icon class=\"text-blue-500\" name=\"check\" />\n </span>\n </li>\n <li v-show=\"props.loading || isSearching\" class=\"m-1.5 cursor-default p-1.5\">\n <Icon data-test=\"stash-select|options-loading\" name=\"working\" class=\"animate-spin text-ice-500\" />\n </li>\n <li\n v-show=\"!props.loading && !isSearching && !filteredOptions.length\"\n class=\"m-1.5 cursor-default p-1.5\"\n data-test=\"stash-select|no-options\"\n >\n <slot name=\"no-options\"> No options </slot>\n </li>\n </ul>\n </div>\n </transition>\n </Teleport>\n </div>\n </div>\n </template>\n <template v-if=\"slots.hint?.()\" #hint>\n <slot name=\"hint\"></slot>\n </template>\n </Field>\n</template>\n\n<style scoped>\n @reference \"../../../styles/main.css\";\n\n @layer utilities {\n .stash-select {\n position: relative;\n }\n\n .stash-select__content,\n .stash-select__content-wrapper {\n height: var(--height-input);\n }\n\n .stash-select__content {\n cursor: pointer;\n overflow: hidden;\n position: absolute;\n background: var(--color-white);\n border: 1px solid var(--color-ice-500);\n border-radius: var(--radius-sm);\n color: var(--color-ice-700);\n display: block;\n font-family: var(--font-family-sofia);\n font-size: var(--text-sm);\n font-weight: normal;\n outline: none;\n padding: 0 !important;\n width: 100%;\n\n &:hover {\n border-color: var(--color-ice-500);\n }\n\n &:focus-within {\n border-color: var(--color-blue-500) !important;\n }\n }\n\n .stash-select--disabled .stash-select__content {\n background-color: var(--color-ice-100);\n border-color: var(--color-ice-500);\n color: var(--color-ice-500);\n pointer-events: none !important;\n }\n\n .stash-select--active .stash-select__content {\n cursor: default;\n height: auto;\n min-width: var(--width-select-menu);\n overflow: visible;\n z-index: var(--z-index-control);\n box-shadow: var(--shadow-sm);\n }\n\n .stash-select--error :where(.stash-select__content, .stash-select__content:hover:not(:focus)) {\n border-color: var(--color-red-500) !important;\n }\n\n .stash-select__placeholder {\n color: var(--color-ice-500);\n }\n\n .stash-select--active .stash-select__placeholder {\n cursor: default;\n }\n\n .stash-select__icon {\n color: var(--color-ice-700);\n cursor: pointer;\n pointer-events: none;\n position: absolute;\n right: --spacing(1.5);\n top: --spacing(1.5);\n }\n\n .stash-select--disabled .stash-select__icon {\n color: var(--color-ice-500);\n }\n\n .stash-select--active .stash-select__icon {\n pointer-events: auto;\n }\n\n .stash-select__chips {\n /* distribute (or split?) the margin between chip and chips container. TODO? */\n --half-space: calc(--spacing(1.5) / 2);\n\n padding: var(--half-space);\n padding-right: --spacing(9);\n }\n\n /* chip AND placeholder AND selected: */\n .stash-select__chips > li {\n cursor: pointer;\n height: var(--height-chip);\n margin: var(--half-space);\n max-width: 100%;\n }\n\n .stash-select--disabled .stash-select__chips > li {\n cursor: default;\n }\n\n .stash-select__content-wrapper:deep(.stash-select__chip) {\n border-radius: var(--radius-sm);\n font-size: var(--text-sm);\n font-weight: normal;\n height: var(--height-chip);\n max-width: inherit;\n text-transform: none;\n }\n\n .stash-select--disabled:deep(.stash-select__chip) {\n background: var(--color-ice-500);\n color: var(--color-white);\n }\n\n /* Base total chip styles moved above the more specific descendant rule to satisfy no-descending-specificity */\n .stash-select__total {\n display: block;\n font-weight: var(--font-weight-semibold);\n line-height: var(--line-height-button);\n position: absolute;\n right: --spacing(6);\n white-space: nowrap;\n z-index: var(--z-index-content);\n\n /* -- design TBD --- */\n top: 0;\n left: 0;\n bottom: 0;\n color: var(--color-white);\n background: white;\n padding: --spacing(1.5);\n }\n\n .stash-select__content-wrapper .stash-select__total:deep(.stash-select__chip) {\n font-weight: var(--font-weight-normal);\n }\n\n .stash-select__selected {\n color: var(--color-ice-700);\n }\n\n .stash-select--disabled .stash-select__selected {\n color: var(--color-ice-500);\n }\n\n .stash-select__selected :where(.stash-select__remove) {\n display: none;\n }\n\n .stash-select__search {\n position: relative;\n width: 100%;\n height: var(--height-input);\n background: var(--color-white);\n border-radius: var(--radius-sm);\n color: var(--color-ice-700);\n display: block;\n font-family: var(--font-family-sofia);\n font-size: var(--text-sm);\n font-weight: var(--font-weight-normal);\n outline: none;\n padding: 0 --spacing(3);\n border: 0 !important;\n }\n\n .stash-select__border-selector {\n background: white;\n border-radius: var(--radius-sm);\n border: 1px solid var(--color-blue-500);\n max-height: var(--max-height-select-menu);\n overflow: auto;\n z-index: var(--z-index-dialog);\n }\n\n .stash-select__option {\n align-items: center;\n border-radius: var(--radius-sm);\n cursor: pointer;\n display: flex;\n line-height: --spacing(6);\n margin: --spacing(1.5);\n padding: --spacing(1.5);\n }\n\n .stash-select__option--disabled {\n color: var(--color-ice-500);\n cursor: not-allowed;\n }\n\n .stash-select__option--highlighted {\n background-color: var(--color-ice-200);\n }\n\n .stash-select__option--selected {\n background-color: var(--color-blue-100);\n color: var(--color-ice-700);\n }\n }\n</style>\n"],"names":["props","__props","emit","__emit","attrs","useAttrs","slots","_useSlots","selectRef","ref","contentRef","optionsWrapperRef","chipsRef","searchRef","chipsHeight","contentHeight","internalValue","searchFor","searchTerm","activeIndex","isActive","pendingSearchRequests","shouldUseLazyOptions","floatingStyles","updateFloating","useFloating","autoUpdate","flip","offset","rects","placement","size","availableHeight","elements","resizeObserverChips","debouncedUpdateChipsHeight","isSearchable","computed","internalOptions","OPTIONS","isPlainObject","name","id","readOnlyValue","option","isSearching","filteredOptions","isChipsOneLine","shouldShowTotal","clearSelectionText","shouldPreventEmpty","watch","currentValue","oldValue","setIndex","value","newValue","isEqual","isEmpty","searchForFn","useSearch","debouncedUpdateFloating","debounce","updateChipsHeight","isOptionDisabled","clear","handleSelect","isSelected","remove","dismiss","handleSelectChange","evt","selectedOption","opt","_a","selectedOptions","internalOption","index","logger","open","nextTick","scrollItems","KEY_CODES","el","elBCR","parentBCR","onKeyDown","handleSearchInput","search","DEBOUNCE","requestId","uniqueId","optionClass","isElementWithinSelectMenu","element","isElementInMenu","isElementInTeleportedMenu","_b","handleFocusOut","focusEvent","nextFocusedElement","handleOutsideClick","event","target","handleMouseLeave","onMounted","onUnmounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsME,UAAMA,IAAQC,IAiCRC,IAAOC,IA2BPC,IAAQC,GAAA,GACRC,IAAQC,GAAA,GAqCRC,KAAYC,EAA2B,IAAI,GAC3CC,IAAaD,EAA2B,IAAI,GAC5CE,IAAoBF,E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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/Thumbnail.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as k, useCssModule as C, inject as T, computed as B, toValue as I, createElementBlock as y, openBlock as b, unref as e, normalizeClass as m, createVNode as h, createBlock as M, createCommentVNode as N, renderSlot as $, withModifiers as q, withCtx as V } from "vue";
|
|
2
2
|
import { t as w } from "./locale.js";
|
|
3
3
|
import z from "./Button.js";
|
|
4
4
|
import E from "./Icon.js";
|
|
5
5
|
import { _ as U } from "./Image.vue_vue_type_script_setup_true_lang-CAj0FH9h.js";
|
|
6
6
|
import { T as d } from "./ThumbnailGroup.keys-EJ4qFNhx.js";
|
|
7
7
|
import { _ as j } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
8
|
-
const A = ["aria-current", "draggable"], D = /* @__PURE__ */
|
|
8
|
+
const A = ["aria-current", "draggable"], D = /* @__PURE__ */ k({
|
|
9
9
|
__name: "Thumbnail",
|
|
10
10
|
props: {
|
|
11
11
|
thumbnail: {},
|
|
@@ -14,22 +14,22 @@ const A = ["aria-current", "draggable"], D = /* @__PURE__ */ C({
|
|
|
14
14
|
},
|
|
15
15
|
emits: ["remove", "click"],
|
|
16
16
|
setup(_, { emit: p }) {
|
|
17
|
-
const
|
|
17
|
+
const o = _, s = p, t = C(), { thumbnails: v, activeThumbnail: i, draggable: f, isDragging: r, radius: n, removable: u } = T(
|
|
18
18
|
d.key,
|
|
19
19
|
d.defaults
|
|
20
|
-
), a = B(() => I(v).findIndex((l) => l ===
|
|
21
|
-
function k() {
|
|
22
|
-
i.value = a.value, r("click", a.value);
|
|
23
|
-
}
|
|
20
|
+
), a = B(() => I(v).findIndex((l) => l === o.thumbnail));
|
|
24
21
|
function g() {
|
|
25
|
-
|
|
22
|
+
i.value = a.value, s("click", a.value);
|
|
23
|
+
}
|
|
24
|
+
function x() {
|
|
25
|
+
s("remove", a.value), i.value = -1;
|
|
26
26
|
}
|
|
27
27
|
return (l, c) => (b(), y("li", {
|
|
28
|
-
class:
|
|
28
|
+
class: m(["stash-thumbnail focus-visible:outline-hidden group relative cursor-pointer", [
|
|
29
29
|
{
|
|
30
|
-
[e(t)["thumbnail-translucent"]]:
|
|
31
|
-
[e(t)["thumbnail-opaque"]]:
|
|
32
|
-
[e(t)["thumbnail-removable"]]: e(
|
|
30
|
+
[e(t)["thumbnail-translucent"]]: o.variant === "translucent",
|
|
31
|
+
[e(t)["thumbnail-opaque"]]: o.variant === "opaque",
|
|
32
|
+
[e(t)["thumbnail-removable"]]: e(u),
|
|
33
33
|
[e(t)["thumbnail-circle"]]: e(n) === "circle",
|
|
34
34
|
[e(t)["thumbnail-rounded"]]: e(n) === "rounded"
|
|
35
35
|
}
|
|
@@ -38,15 +38,15 @@ const A = ["aria-current", "draggable"], D = /* @__PURE__ */ C({
|
|
|
38
38
|
draggable: e(f),
|
|
39
39
|
"data-test": "stash-thumbnail",
|
|
40
40
|
tabindex: "0",
|
|
41
|
-
onClick: c[0] || (c[0] = (L) =>
|
|
41
|
+
onClick: c[0] || (c[0] = (L) => g())
|
|
42
42
|
}, [
|
|
43
43
|
h(U, {
|
|
44
|
-
class:
|
|
44
|
+
class: m(["stash-thumbnail__img border-ice-200 outline-blue-500/15 transition-colors", [
|
|
45
45
|
e(t)["thumbnail-img"],
|
|
46
46
|
{
|
|
47
|
-
[e(t)["thumbnail-mask"]]: e(
|
|
48
|
-
[e(t)["thumbnail-active"]]: e(i) === a.value && !e(
|
|
49
|
-
"group-hover:border-blue-500 group-focus-visible:border-blue-500 group-focus-visible:outline": !e(
|
|
47
|
+
[e(t)["thumbnail-mask"]]: e(u) && e(n) !== "circle",
|
|
48
|
+
[e(t)["thumbnail-active"]]: e(i) === a.value && !e(r),
|
|
49
|
+
"group-hover:border-blue-500 group-focus-visible:border-blue-500 group-focus-visible:outline": !e(r)
|
|
50
50
|
}
|
|
51
51
|
]]),
|
|
52
52
|
"data-test": "stash-thumbnail|img",
|
|
@@ -54,14 +54,14 @@ const A = ["aria-current", "draggable"], D = /* @__PURE__ */ C({
|
|
|
54
54
|
src: l.thumbnail.imageUrl,
|
|
55
55
|
alt: l.altText
|
|
56
56
|
}, null, 8, ["class", "radius", "src", "alt"]),
|
|
57
|
-
e(
|
|
57
|
+
e(u) ? (b(), M(z, {
|
|
58
58
|
key: 0,
|
|
59
|
-
class:
|
|
59
|
+
class: m(["stash-thumbnail__remove", [e(t)["thumbnail-remove"]]]),
|
|
60
60
|
"data-test": "stash-thumbnail|remove",
|
|
61
61
|
"aria-label": e(w)("ll.thumbnail.removeButton", { index: a.value + 1 }),
|
|
62
62
|
type: "button",
|
|
63
63
|
icon: "",
|
|
64
|
-
onClick: q(
|
|
64
|
+
onClick: q(x, ["stop", "prevent"])
|
|
65
65
|
}, {
|
|
66
66
|
default: V(() => [
|
|
67
67
|
h(E, {
|
|
@@ -75,13 +75,13 @@ const A = ["aria-current", "draggable"], D = /* @__PURE__ */ C({
|
|
|
75
75
|
], 10, A));
|
|
76
76
|
}
|
|
77
77
|
}), H = {
|
|
78
|
-
"thumbnail-remove": "_thumbnail-
|
|
79
|
-
"thumbnail-img": "_thumbnail-
|
|
80
|
-
"thumbnail-translucent": "_thumbnail-
|
|
81
|
-
"thumbnail-active": "_thumbnail-
|
|
82
|
-
"thumbnail-mask": "_thumbnail-
|
|
83
|
-
"thumbnail-full": "_thumbnail-
|
|
84
|
-
"thumbnail-rounded": "_thumbnail-
|
|
78
|
+
"thumbnail-remove": "_thumbnail-remove_pocxm_5",
|
|
79
|
+
"thumbnail-img": "_thumbnail-img_pocxm_27",
|
|
80
|
+
"thumbnail-translucent": "_thumbnail-translucent_pocxm_35",
|
|
81
|
+
"thumbnail-active": "_thumbnail-active_pocxm_39",
|
|
82
|
+
"thumbnail-mask": "_thumbnail-mask_pocxm_49",
|
|
83
|
+
"thumbnail-full": "_thumbnail-full_pocxm_53",
|
|
84
|
+
"thumbnail-rounded": "_thumbnail-rounded_pocxm_57"
|
|
85
85
|
}, J = {
|
|
86
86
|
$style: H
|
|
87
87
|
}, Q = /* @__PURE__ */ j(D, [["__cssModules", J]]);
|
package/dist/Thumbnail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Thumbnail.js","sources":["../src/components/Thumbnail/Thumbnail.vue"],"sourcesContent":["<script lang=\"ts\">\n import { ThumbnailDefinition, ThumbnailVariant } from './Thumbnail.types';\n\n export * from './Thumbnail.types';\n</script>\n\n<script setup lang=\"ts\" generic=\"ThumbnailItem extends ThumbnailDefinition\">\n import { computed, inject, toValue, useCssModule } from 'vue';\n\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import Icon from '../Icon/Icon.vue';\n import Image from '../Image/Image.vue';\n import { THUMBNAIL_INJECTION } from '../ThumbnailGroup/ThumbnailGroup.keys';\n\n const props = withDefaults(\n defineProps<{\n /**\n * Thumbnail data containing and id and the image url\n */\n thumbnail: ThumbnailItem;\n\n /**\n * Thumbnail alt text for the image\n * @default ''\n */\n altText?: string;\n\n /**\n * Whether the thumbnail has some transparency or is fully opaque\n * @default 'opaque'\n */\n variant?: ThumbnailVariant;\n }>(),\n {\n variant: 'opaque',\n altText: '',\n },\n );\n\n const emit = defineEmits<{\n /**\n * Emits when a thumbnail is removed\n */\n remove: [index: number];\n\n /**\n * Emits when a thumbnail is clicked\n */\n click: [index: number];\n }>();\n\n const classes = useCssModule();\n\n const { thumbnails, activeThumbnail, draggable, isDragging, radius, removable } = inject(\n THUMBNAIL_INJECTION.key,\n THUMBNAIL_INJECTION.defaults,\n );\n\n const thumbnailIndex = computed(() => toValue(thumbnails).findIndex((t) => t === props.thumbnail));\n\n function handleThumbnailClick() {\n activeThumbnail.value = thumbnailIndex.value;\n emit('click', thumbnailIndex.value);\n }\n\n function handleRemove() {\n emit('remove', thumbnailIndex.value);\n activeThumbnail.value = -1;\n }\n</script>\n\n<template>\n <li\n class=\"stash-thumbnail focus-visible:outline-hidden group relative cursor-pointer\"\n :class=\"[\n {\n [classes['thumbnail-translucent']]: props.variant === 'translucent',\n [classes['thumbnail-opaque']]: props.variant === 'opaque',\n [classes['thumbnail-removable']]: removable,\n [classes['thumbnail-circle']]: radius === 'circle',\n [classes['thumbnail-rounded']]: radius === 'rounded',\n },\n ]\"\n :aria-current=\"activeThumbnail === thumbnailIndex\"\n :draggable=\"draggable\"\n data-test=\"stash-thumbnail\"\n tabindex=\"0\"\n @click=\"handleThumbnailClick()\"\n >\n <Image\n class=\"stash-thumbnail__img border-ice-200 outline-blue-500/15 transition-colors\"\n :class=\"[\n classes['thumbnail-img'],\n {\n [classes['thumbnail-mask']]: removable && radius !== 'circle',\n [classes['thumbnail-active']]: activeThumbnail === thumbnailIndex && !isDragging,\n 'group-hover:border-blue-500 group-focus-visible:border-blue-500 group-focus-visible:outline': !isDragging,\n },\n ]\"\n data-test=\"stash-thumbnail|img\"\n :radius=\"radius\"\n :src=\"thumbnail.imageUrl\"\n :alt=\"altText\"\n />\n\n <Button\n v-if=\"removable\"\n class=\"stash-thumbnail__remove\"\n :class=\"[classes['thumbnail-remove']]\"\n data-test=\"stash-thumbnail|remove\"\n :aria-label=\"t('ll.thumbnail.removeButton', { index: thumbnailIndex + 1 })\"\n type=\"button\"\n icon\n @click.stop.prevent=\"handleRemove\"\n >\n <Icon name=\"close\" size=\"small\" />\n </Button>\n\n <!-- @slot: Slot to add a hint below the image -->\n <slot name=\"hint\" />\n </li>\n</template>\n\n<style module>\n @reference \"../../../styles/main.css\";\n\n @layer utilities {\n .thumbnail-remove {\n position: absolute;\n top: calc(--spacing(1.5) * -1);\n right: calc(--spacing(1.5) * -1);\n padding: 1px;\n height: auto;\n width: auto !important;\n min-width: auto;\n border-radius: calc(infinity * 1px);\n background: var(--color-blue-500);\n color: white;\n\n &:hover,\n &:focus {\n background: var(--color-blue-600);\n }\n\n &:focus {\n outline: none;\n }\n }\n\n .thumbnail-img {\n border-style: solid;\n object-fit: cover;\n height: --spacing(12);\n width: --spacing(12);\n border-width: 1px;\n outline-width:
|
|
1
|
+
{"version":3,"file":"Thumbnail.js","sources":["../src/components/Thumbnail/Thumbnail.vue"],"sourcesContent":["<script lang=\"ts\">\n import { ThumbnailDefinition, ThumbnailVariant } from './Thumbnail.types';\n\n export * from './Thumbnail.types';\n</script>\n\n<script setup lang=\"ts\" generic=\"ThumbnailItem extends ThumbnailDefinition\">\n import { computed, inject, toValue, useCssModule } from 'vue';\n\n import { t } from '../../locale';\n import Button from '../Button/Button.vue';\n import Icon from '../Icon/Icon.vue';\n import Image from '../Image/Image.vue';\n import { THUMBNAIL_INJECTION } from '../ThumbnailGroup/ThumbnailGroup.keys';\n\n const props = withDefaults(\n defineProps<{\n /**\n * Thumbnail data containing and id and the image url\n */\n thumbnail: ThumbnailItem;\n\n /**\n * Thumbnail alt text for the image\n * @default ''\n */\n altText?: string;\n\n /**\n * Whether the thumbnail has some transparency or is fully opaque\n * @default 'opaque'\n */\n variant?: ThumbnailVariant;\n }>(),\n {\n variant: 'opaque',\n altText: '',\n },\n );\n\n const emit = defineEmits<{\n /**\n * Emits when a thumbnail is removed\n */\n remove: [index: number];\n\n /**\n * Emits when a thumbnail is clicked\n */\n click: [index: number];\n }>();\n\n const classes = useCssModule();\n\n const { thumbnails, activeThumbnail, draggable, isDragging, radius, removable } = inject(\n THUMBNAIL_INJECTION.key,\n THUMBNAIL_INJECTION.defaults,\n );\n\n const thumbnailIndex = computed(() => toValue(thumbnails).findIndex((t) => t === props.thumbnail));\n\n function handleThumbnailClick() {\n activeThumbnail.value = thumbnailIndex.value;\n emit('click', thumbnailIndex.value);\n }\n\n function handleRemove() {\n emit('remove', thumbnailIndex.value);\n activeThumbnail.value = -1;\n }\n</script>\n\n<template>\n <li\n class=\"stash-thumbnail focus-visible:outline-hidden group relative cursor-pointer\"\n :class=\"[\n {\n [classes['thumbnail-translucent']]: props.variant === 'translucent',\n [classes['thumbnail-opaque']]: props.variant === 'opaque',\n [classes['thumbnail-removable']]: removable,\n [classes['thumbnail-circle']]: radius === 'circle',\n [classes['thumbnail-rounded']]: radius === 'rounded',\n },\n ]\"\n :aria-current=\"activeThumbnail === thumbnailIndex\"\n :draggable=\"draggable\"\n data-test=\"stash-thumbnail\"\n tabindex=\"0\"\n @click=\"handleThumbnailClick()\"\n >\n <Image\n class=\"stash-thumbnail__img border-ice-200 outline-blue-500/15 transition-colors\"\n :class=\"[\n classes['thumbnail-img'],\n {\n [classes['thumbnail-mask']]: removable && radius !== 'circle',\n [classes['thumbnail-active']]: activeThumbnail === thumbnailIndex && !isDragging,\n 'group-hover:border-blue-500 group-focus-visible:border-blue-500 group-focus-visible:outline': !isDragging,\n },\n ]\"\n data-test=\"stash-thumbnail|img\"\n :radius=\"radius\"\n :src=\"thumbnail.imageUrl\"\n :alt=\"altText\"\n />\n\n <Button\n v-if=\"removable\"\n class=\"stash-thumbnail__remove\"\n :class=\"[classes['thumbnail-remove']]\"\n data-test=\"stash-thumbnail|remove\"\n :aria-label=\"t('ll.thumbnail.removeButton', { index: thumbnailIndex + 1 })\"\n type=\"button\"\n icon\n @click.stop.prevent=\"handleRemove\"\n >\n <Icon name=\"close\" size=\"small\" />\n </Button>\n\n <!-- @slot: Slot to add a hint below the image -->\n <slot name=\"hint\" />\n </li>\n</template>\n\n<style module>\n @reference \"../../../styles/main.css\";\n\n @layer utilities {\n .thumbnail-remove {\n position: absolute;\n top: calc(--spacing(1.5) * -1);\n right: calc(--spacing(1.5) * -1);\n padding: 1px;\n height: auto;\n width: auto !important;\n min-width: auto;\n border-radius: calc(infinity * 1px);\n background: var(--color-blue-500);\n color: white;\n\n &:hover,\n &:focus {\n background: var(--color-blue-600);\n }\n\n &:focus {\n outline: none;\n }\n }\n\n .thumbnail-img {\n border-style: solid;\n object-fit: cover;\n height: --spacing(12);\n width: --spacing(12);\n border-width: 1px;\n outline-width: --spacing(1);\n\n .thumbnail-translucent & {\n opacity: var(--opacity-40);\n\n &:hover,\n &.thumbnail-active {\n opacity: var(--opacity-100);\n }\n }\n }\n\n .thumbnail-active {\n border: 1px solid var(--color-ice-500);\n }\n\n .thumbnail-mask {\n mask-image: radial-gradient(circle at top right, transparent 20%, white 20.5%);\n }\n\n .thumbnail-full {\n border-radius: calc(infinity * 1px);\n }\n\n .thumbnail-rounded {\n border-radius: var(--radius-sm);\n }\n }\n</style>\n"],"names":["props","__props","emit","__emit","classes","useCssModule","thumbnails","activeThumbnail","draggable","isDragging","radius","removable","inject","THUMBNAIL_INJECTION","thumbnailIndex","computed","toValue","t","handleThumbnailClick","handleRemove"],"mappings":";;;;;;;;;;;;;;;;AAeE,UAAMA,IAAQC,GAyBRC,IAAOC,GAYPC,IAAUC,EAAA,GAEV,EAAE,YAAAC,GAAY,iBAAAC,GAAiB,WAAAC,GAAW,YAAAC,GAAY,QAAAC,GAAQ,WAAAC,MAAcC;AAAA,MAChFC,EAAoB;AAAA,MACpBA,EAAoB;AAAA,IAAA,GAGhBC,IAAiBC,EAAS,MAAMC,EAAQV,CAAU,EAAE,UAAU,CAACW,MAAMA,MAAMjB,EAAM,SAAS,CAAC;AAEjG,aAASkB,IAAuB;AAC9B,MAAAX,EAAgB,QAAQO,EAAe,OACvCZ,EAAK,SAASY,EAAe,KAAK;AAAA,IACpC;AAEA,aAASK,IAAe;AACtB,MAAAjB,EAAK,UAAUY,EAAe,KAAK,GACnCP,EAAgB,QAAQ;AAAA,IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/ThumbnailEmpty.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as o, useCssModule as a, inject as m, createElementBlock as l, openBlock as c, normalizeClass as r, unref as t, createVNode as u } from "vue";
|
|
2
2
|
import i from "./Icon.js";
|
|
3
3
|
import { T as s } from "./ThumbnailGroup.keys-EJ4qFNhx.js";
|
|
4
4
|
import { _ as p } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
5
|
-
const _ = /* @__PURE__ */
|
|
5
|
+
const _ = /* @__PURE__ */ o({
|
|
6
6
|
__name: "ThumbnailEmpty",
|
|
7
7
|
setup(f) {
|
|
8
|
-
const
|
|
8
|
+
const n = a(), { radius: e } = m(s.key, s.defaults);
|
|
9
9
|
return (y, b) => (c(), l("li", {
|
|
10
10
|
class: r(["stash-thumbnail-empty", [
|
|
11
|
-
t(
|
|
11
|
+
t(n)["thumbnail-empty"],
|
|
12
12
|
{
|
|
13
13
|
"rounded-full": t(e) === "circle",
|
|
14
14
|
rounded: t(e) === "rounded"
|
|
@@ -23,7 +23,7 @@ const _ = /* @__PURE__ */ n({
|
|
|
23
23
|
], 2));
|
|
24
24
|
}
|
|
25
25
|
}), d = {
|
|
26
|
-
"thumbnail-empty": "_thumbnail-
|
|
26
|
+
"thumbnail-empty": "_thumbnail-empty_1onjz_5"
|
|
27
27
|
}, h = {
|
|
28
28
|
$style: d
|
|
29
29
|
}, M = /* @__PURE__ */ p(_, [["__cssModules", h]]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThumbnailEmpty.js","sources":["../src/components/ThumbnailEmpty/ThumbnailEmpty.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import Icon from '../Icon/Icon.vue';\n import { THUMBNAIL_INJECTION } from '../ThumbnailGroup/ThumbnailGroup.keys';\n\n const classes = useCssModule();\n\n const { radius } = inject(THUMBNAIL_INJECTION.key, THUMBNAIL_INJECTION.defaults);\n</script>\n\n<template>\n <li\n class=\"stash-thumbnail-empty\"\n :class=\"[\n classes['thumbnail-empty'],\n {\n 'rounded-full': radius === 'circle',\n rounded: radius === 'rounded',\n },\n ]\"\n data-test=\"stash-thumbnail-empty\"\n >\n <Icon name=\"image\" data-test=\"stash-thumbnail-empty|icon\" />\n </li>\n</template>\n\n<style module>\n @reference \"../../../styles/main.css\";\n\n @layer utilities {\n .thumbnail-empty {\n height: --spacing(12);\n width: --spacing(12);\n border-width: 1px;\n outline-width:
|
|
1
|
+
{"version":3,"file":"ThumbnailEmpty.js","sources":["../src/components/ThumbnailEmpty/ThumbnailEmpty.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import Icon from '../Icon/Icon.vue';\n import { THUMBNAIL_INJECTION } from '../ThumbnailGroup/ThumbnailGroup.keys';\n\n const classes = useCssModule();\n\n const { radius } = inject(THUMBNAIL_INJECTION.key, THUMBNAIL_INJECTION.defaults);\n</script>\n\n<template>\n <li\n class=\"stash-thumbnail-empty\"\n :class=\"[\n classes['thumbnail-empty'],\n {\n 'rounded-full': radius === 'circle',\n rounded: radius === 'rounded',\n },\n ]\"\n data-test=\"stash-thumbnail-empty\"\n >\n <Icon name=\"image\" data-test=\"stash-thumbnail-empty|icon\" />\n </li>\n</template>\n\n<style module>\n @reference \"../../../styles/main.css\";\n\n @layer utilities {\n .thumbnail-empty {\n height: --spacing(12);\n width: --spacing(12);\n border-width: 1px;\n outline-width: --spacing(1);\n border-style: dashed;\n border-color: var(--colors-ice-500);\n background-color: var(--colors-ice-100);\n color: var(--colors-ice-700);\n display: flex;\n justify-content: center;\n align-items: center;\n }\n }\n</style>\n"],"names":["classes","useCssModule","radius","inject","THUMBNAIL_INJECTION"],"mappings":";;;;;;;AAME,UAAMA,IAAUC,EAAA,GAEV,EAAE,QAAAC,EAAA,IAAWC,EAAOC,EAAoB,KAAKA,EAAoB,QAAQ;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/ThumbnailGroup.js
CHANGED
|
@@ -20,36 +20,36 @@ const M = /* @__PURE__ */ h({
|
|
|
20
20
|
}),
|
|
21
21
|
emits: /* @__PURE__ */ m(["dragStart", "dragEnd", "update:thumbnails"], ["update:activeThumbnail"]),
|
|
22
22
|
setup(s, { emit: p }) {
|
|
23
|
-
const n = p,
|
|
23
|
+
const n = p, t = s, r = c(s, "activeThumbnail"), a = l({
|
|
24
24
|
get() {
|
|
25
|
-
return
|
|
25
|
+
return t.thumbnails;
|
|
26
26
|
},
|
|
27
27
|
set(e) {
|
|
28
28
|
n("update:thumbnails", e);
|
|
29
29
|
}
|
|
30
30
|
}), u = g(null), { isDragging: i } = k({
|
|
31
31
|
ref: u,
|
|
32
|
-
list:
|
|
33
|
-
isEnabled:
|
|
32
|
+
list: a,
|
|
33
|
+
isEnabled: t.draggable,
|
|
34
34
|
ghostClass: "thumbnail-ghost",
|
|
35
35
|
chosenClass: "thumbnail-chosen",
|
|
36
36
|
sortInPlace: !1,
|
|
37
37
|
onDragStart: (e) => n("dragStart", e),
|
|
38
38
|
onDragEnd: (e) => {
|
|
39
|
-
r.value = e.newIndex, S({ list:
|
|
39
|
+
r.value = e.newIndex, S({ list: a, from: e.oldIndex, to: e.newIndex }), n("dragEnd", e);
|
|
40
40
|
}
|
|
41
|
-
}),
|
|
42
|
-
if (!
|
|
43
|
-
const { max: e } =
|
|
44
|
-
return
|
|
41
|
+
}), b = l(() => {
|
|
42
|
+
if (!t.showEmpty) return 0;
|
|
43
|
+
const { max: e } = t.emptyOptions || {};
|
|
44
|
+
return a.value.length < e ? e - a.value.length : 0;
|
|
45
45
|
});
|
|
46
46
|
return v(
|
|
47
47
|
C.key,
|
|
48
48
|
Object.freeze({
|
|
49
|
-
draggable: l(() =>
|
|
50
|
-
removable: l(() =>
|
|
51
|
-
thumbnails:
|
|
52
|
-
radius:
|
|
49
|
+
draggable: l(() => t.draggable),
|
|
50
|
+
removable: l(() => t.removable),
|
|
51
|
+
thumbnails: a,
|
|
52
|
+
radius: t.radius,
|
|
53
53
|
activeThumbnail: r,
|
|
54
54
|
isDragging: i
|
|
55
55
|
})
|
|
@@ -60,12 +60,12 @@ const M = /* @__PURE__ */ h({
|
|
|
60
60
|
"data-test": "stash-thumbnail-group"
|
|
61
61
|
}, [
|
|
62
62
|
T(e.$slots, "default", y(_({ activeThumbnail: r.value, isDragging: E(i) })), void 0, !0),
|
|
63
|
-
(o(!0), d(x, null, I(
|
|
64
|
-
key: `empty_thumb_${
|
|
63
|
+
(o(!0), d(x, null, I(b.value, (N, f) => (o(), B(w, {
|
|
64
|
+
key: `empty_thumb_${f}`
|
|
65
65
|
}))), 128))
|
|
66
66
|
], 512));
|
|
67
67
|
}
|
|
68
|
-
}), $ = /* @__PURE__ */ D(M, [["__scopeId", "data-v-
|
|
68
|
+
}), $ = /* @__PURE__ */ D(M, [["__scopeId", "data-v-2507f5b5"]]);
|
|
69
69
|
export {
|
|
70
70
|
$ as default,
|
|
71
71
|
S as moveSortableElements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThumbnailGroup.js","sources":["../src/components/ThumbnailGroup/ThumbnailGroup.vue"],"sourcesContent":["<script lang=\"ts\">\n import type { ThumbnailEmptyOptions, ThumbnailRadius } from './ThumbnailGroup.types';\n\n export * from '../../composables/useSortable/useSortable';\n export * from './ThumbnailGroup.types';\n</script>\n\n<script setup lang=\"ts\" generic=\"Thumbnail extends ThumbnailDefinition\">\n import { computed, provide, ref } from 'vue';\n\n import useSortable, {\n moveSortableElements,\n type SortableOnDragEndEvent,\n type SortableOnDragStartEvent,\n } from '../../composables/useSortable/useSortable';\n import { ThumbnailDefinition } from '../Thumbnail/Thumbnail.types';\n import ThumbnailEmpty from '../ThumbnailEmpty/ThumbnailEmpty.vue';\n import { THUMBNAIL_INJECTION } from './ThumbnailGroup.keys';\n\n const emit = defineEmits<{\n /**\n * Emits when a thumbnail starts dragging\n */\n dragStart: [event: SortableOnDragStartEvent];\n\n /**\n * Emits when a thumbnail stops dragging\n */\n dragEnd: [event: SortableOnDragEndEvent];\n\n /**\n * Emits when the thumbnails are updated\n */\n 'update:thumbnails': [thumbnails: Thumbnail[]];\n }>();\n\n const props = withDefaults(\n defineProps<{\n /**\n * Enable drag and drop functionality\n * @default false\n */\n draggable?: boolean;\n\n /**\n * Thumbnail radius. Can be 'rounded' or 'circle'\n * @default 'rounded'\n */\n radius?: ThumbnailRadius;\n\n /**\n * Shows a close button on the thumbnail when set to true\n * @default false\n */\n removable?: boolean;\n\n /**\n * Shows empty thumbnails when set to true\n */\n showEmpty?: boolean;\n\n /**\n * Empty thumbnail options. Only applicable when `showEmpty` is true\n * @default { max: 6 }\n */\n emptyOptions?: ThumbnailEmptyOptions;\n\n /**\n * List of thumbnails to display\n * @default []\n */\n thumbnails?: Thumbnail[];\n }>(),\n {\n thumbnails: () => [],\n draggable: false,\n radius: 'rounded',\n variant: 'opaque',\n removable: false,\n showEmpty: false,\n emptyOptions: () => ({ max: 6 }),\n },\n );\n\n /**\n * The active thumbnail index\n */\n const activeThumbnail = defineModel<number>('activeThumbnail', {\n default: -1,\n });\n\n const internalThumbnails = computed({\n get() {\n return props.thumbnails;\n },\n set(value) {\n emit('update:thumbnails', value);\n },\n });\n\n const thumbnailRef = ref<HTMLElement | null>(null);\n const { isDragging } = useSortable({\n ref: thumbnailRef,\n list: internalThumbnails,\n isEnabled: props.draggable,\n ghostClass: 'thumbnail-ghost',\n chosenClass: 'thumbnail-chosen',\n sortInPlace: false,\n onDragStart: (e) => emit('dragStart', e),\n onDragEnd: (e) => {\n activeThumbnail.value = e.newIndex;\n moveSortableElements({ list: internalThumbnails, from: e.oldIndex, to: e.newIndex });\n emit('dragEnd', e);\n },\n });\n\n const emptyThumbnailsCount = computed(() => {\n if (!props.showEmpty) return 0;\n\n const { max } = props.emptyOptions || {};\n\n return internalThumbnails.value.length < max ? max - internalThumbnails.value.length : 0;\n });\n\n provide(\n THUMBNAIL_INJECTION.key,\n Object.freeze({\n draggable: computed(() => props.draggable),\n removable: computed(() => props.removable),\n thumbnails: internalThumbnails,\n radius: props.radius,\n activeThumbnail,\n isDragging,\n }),\n );\n</script>\n\n<template>\n <ul ref=\"thumbnailRef\" class=\"stash-thumbnail-group flex flex-wrap gap-3\" data-test=\"stash-thumbnail-group\">\n <slot v-bind=\"{ activeThumbnail, isDragging }\"></slot>\n\n <ThumbnailEmpty v-for=\"(_, index) in emptyThumbnailsCount\" :key=\"`empty_thumb_${index}`\" />\n </ul>\n</template>\n\n<style>\n @layer utilities {\n .thumbnail-ghost {\n .stash-thumbnail-item__img {\n border: 1px solid var(--color-blue-500);\n mask-image: none !important;\n box-shadow: var(--shadow);\n }\n\n .stash-thumbnail-item__remove {\n opacity: 0;\n }\n }\n }\n</style>\n\n<style scoped>\n @layer utilities {\n :deep(.thumbnail-chosen) {\n opacity: 0 !important;\n }\n }\n</style>\n"],"names":["emit","__emit","props","__props","activeThumbnail","_useModel","internalThumbnails","computed","value","thumbnailRef","ref","isDragging","useSortable","moveSortableElements","emptyThumbnailsCount","max","provide","THUMBNAIL_INJECTION"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBE,UAAMA,IAAOC,GAiBPC,IAAQC,GAmDRC,IAAkBC,EAAmBF,GAAC,iBAE3C,GAEKG,IAAqBC,EAAS;AAAA,MAClC,MAAM;AACJ,eAAOL,EAAM;AAAA,MACf;AAAA,MACA,IAAIM,GAAO;AACT,QAAAR,EAAK,qBAAqBQ,CAAK;AAAA,MACjC;AAAA,IAAA,CACD,GAEKC,IAAeC,EAAwB,IAAI,GAC3C,EAAE,YAAAC,EAAA,IAAeC,EAAY;AAAA,MACjC,KAAKH;AAAA,MACL,MAAMH;AAAA,MACN,WAAWJ,EAAM;AAAA,MACjB,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa;AAAA,MACb,aAAa,CAAC,MAAMF,EAAK,aAAa,CAAC;AAAA,MACvC,WAAW,CAAC,MAAM;AAChB,QAAAI,EAAgB,QAAQ,EAAE,UAC1BS,EAAqB,EAAE,MAAMP,GAAoB,MAAM,EAAE,UAAU,IAAI,EAAE,UAAU,GACnFN,EAAK,WAAW,CAAC;AAAA,MACnB;AAAA,IAAA,CACD,GAEKc,IAAuBP,EAAS,MAAM;AAC1C,UAAI,CAACL,EAAM,UAAW,QAAO;AAE7B,YAAM,EAAE,KAAAa,EAAA,IAAQb,EAAM,gBAAgB,CAAA;AAEtC,aAAOI,EAAmB,MAAM,SAASS,IAAMA,IAAMT,EAAmB,MAAM,SAAS;AAAA,IACzF,CAAC;AAED,WAAAU;AAAA,MACEC,EAAoB;AAAA,MACpB,OAAO,OAAO;AAAA,QACZ,WAAWV,EAAS,MAAML,EAAM,SAAS;AAAA,QACzC,WAAWK,EAAS,MAAML,EAAM,SAAS;AAAA,QACzC,YAAYI;AAAA,QACZ,QAAQJ,EAAM;AAAA,QACd,iBAAAE;AAAA,QACA,YAAAO;AAAA,MAAA,CACD;AAAA,IAAA;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ThumbnailGroup.js","sources":["../src/components/ThumbnailGroup/ThumbnailGroup.vue"],"sourcesContent":["<script lang=\"ts\">\n import type { ThumbnailEmptyOptions, ThumbnailRadius } from './ThumbnailGroup.types';\n\n export * from '../../composables/useSortable/useSortable';\n export * from './ThumbnailGroup.types';\n</script>\n\n<script setup lang=\"ts\" generic=\"Thumbnail extends ThumbnailDefinition\">\n import { computed, provide, ref } from 'vue';\n\n import useSortable, {\n moveSortableElements,\n type SortableOnDragEndEvent,\n type SortableOnDragStartEvent,\n } from '../../composables/useSortable/useSortable';\n import { ThumbnailDefinition } from '../Thumbnail/Thumbnail.types';\n import ThumbnailEmpty from '../ThumbnailEmpty/ThumbnailEmpty.vue';\n import { THUMBNAIL_INJECTION } from './ThumbnailGroup.keys';\n\n const emit = defineEmits<{\n /**\n * Emits when a thumbnail starts dragging\n */\n dragStart: [event: SortableOnDragStartEvent];\n\n /**\n * Emits when a thumbnail stops dragging\n */\n dragEnd: [event: SortableOnDragEndEvent];\n\n /**\n * Emits when the thumbnails are updated\n */\n 'update:thumbnails': [thumbnails: Thumbnail[]];\n }>();\n\n const props = withDefaults(\n defineProps<{\n /**\n * Enable drag and drop functionality\n * @default false\n */\n draggable?: boolean;\n\n /**\n * Thumbnail radius. Can be 'rounded' or 'circle'\n * @default 'rounded'\n */\n radius?: ThumbnailRadius;\n\n /**\n * Shows a close button on the thumbnail when set to true\n * @default false\n */\n removable?: boolean;\n\n /**\n * Shows empty thumbnails when set to true\n */\n showEmpty?: boolean;\n\n /**\n * Empty thumbnail options. Only applicable when `showEmpty` is true\n * @default { max: 6 }\n */\n emptyOptions?: ThumbnailEmptyOptions;\n\n /**\n * List of thumbnails to display\n * @default []\n */\n thumbnails?: Thumbnail[];\n }>(),\n {\n thumbnails: () => [],\n draggable: false,\n radius: 'rounded',\n variant: 'opaque',\n removable: false,\n showEmpty: false,\n emptyOptions: () => ({ max: 6 }),\n },\n );\n\n /**\n * The active thumbnail index\n */\n const activeThumbnail = defineModel<number>('activeThumbnail', {\n default: -1,\n });\n\n const internalThumbnails = computed({\n get() {\n return props.thumbnails;\n },\n set(value) {\n emit('update:thumbnails', value);\n },\n });\n\n const thumbnailRef = ref<HTMLElement | null>(null);\n const { isDragging } = useSortable({\n ref: thumbnailRef,\n list: internalThumbnails,\n isEnabled: props.draggable,\n ghostClass: 'thumbnail-ghost',\n chosenClass: 'thumbnail-chosen',\n sortInPlace: false,\n onDragStart: (e) => emit('dragStart', e),\n onDragEnd: (e) => {\n activeThumbnail.value = e.newIndex;\n moveSortableElements({ list: internalThumbnails, from: e.oldIndex, to: e.newIndex });\n emit('dragEnd', e);\n },\n });\n\n const emptyThumbnailsCount = computed(() => {\n if (!props.showEmpty) return 0;\n\n const { max } = props.emptyOptions || {};\n\n return internalThumbnails.value.length < max ? max - internalThumbnails.value.length : 0;\n });\n\n provide(\n THUMBNAIL_INJECTION.key,\n Object.freeze({\n draggable: computed(() => props.draggable),\n removable: computed(() => props.removable),\n thumbnails: internalThumbnails,\n radius: props.radius,\n activeThumbnail,\n isDragging,\n }),\n );\n</script>\n\n<template>\n <ul ref=\"thumbnailRef\" class=\"stash-thumbnail-group flex flex-wrap gap-3\" data-test=\"stash-thumbnail-group\">\n <slot v-bind=\"{ activeThumbnail, isDragging }\"></slot>\n\n <ThumbnailEmpty v-for=\"(_, index) in emptyThumbnailsCount\" :key=\"`empty_thumb_${index}`\" />\n </ul>\n</template>\n\n<style>\n @layer utilities {\n .thumbnail-ghost {\n .stash-thumbnail-item__img {\n border: 1px solid var(--color-blue-500);\n mask-image: none !important;\n box-shadow: var(--shadow-sm);\n }\n\n .stash-thumbnail-item__remove {\n opacity: 0;\n }\n }\n }\n</style>\n\n<style scoped>\n @layer utilities {\n :deep(.thumbnail-chosen) {\n opacity: 0 !important;\n }\n }\n</style>\n"],"names":["emit","__emit","props","__props","activeThumbnail","_useModel","internalThumbnails","computed","value","thumbnailRef","ref","isDragging","useSortable","moveSortableElements","emptyThumbnailsCount","max","provide","THUMBNAIL_INJECTION"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmBE,UAAMA,IAAOC,GAiBPC,IAAQC,GAmDRC,IAAkBC,EAAmBF,GAAC,iBAE3C,GAEKG,IAAqBC,EAAS;AAAA,MAClC,MAAM;AACJ,eAAOL,EAAM;AAAA,MACf;AAAA,MACA,IAAIM,GAAO;AACT,QAAAR,EAAK,qBAAqBQ,CAAK;AAAA,MACjC;AAAA,IAAA,CACD,GAEKC,IAAeC,EAAwB,IAAI,GAC3C,EAAE,YAAAC,EAAA,IAAeC,EAAY;AAAA,MACjC,KAAKH;AAAA,MACL,MAAMH;AAAA,MACN,WAAWJ,EAAM;AAAA,MACjB,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,aAAa;AAAA,MACb,aAAa,CAAC,MAAMF,EAAK,aAAa,CAAC;AAAA,MACvC,WAAW,CAAC,MAAM;AAChB,QAAAI,EAAgB,QAAQ,EAAE,UAC1BS,EAAqB,EAAE,MAAMP,GAAoB,MAAM,EAAE,UAAU,IAAI,EAAE,UAAU,GACnFN,EAAK,WAAW,CAAC;AAAA,MACnB;AAAA,IAAA,CACD,GAEKc,IAAuBP,EAAS,MAAM;AAC1C,UAAI,CAACL,EAAM,UAAW,QAAO;AAE7B,YAAM,EAAE,KAAAa,EAAA,IAAQb,EAAM,gBAAgB,CAAA;AAEtC,aAAOI,EAAmB,MAAM,SAASS,IAAMA,IAAMT,EAAmB,MAAM,SAAS;AAAA,IACzF,CAAC;AAED,WAAAU;AAAA,MACEC,EAAoB;AAAA,MACpB,OAAO,OAAO;AAAA,QACZ,WAAWV,EAAS,MAAML,EAAM,SAAS;AAAA,QACzC,WAAWK,EAAS,MAAML,EAAM,SAAS;AAAA,QACzC,YAAYI;AAAA,QACZ,QAAQJ,EAAM;AAAA,QACd,iBAAAE;AAAA,QACA,YAAAO;AAAA,MAAA,CACD;AAAA,IAAA;;;;;;;;;;;;;"}
|
package/dist/Tooltip.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as g, ref as n, computed as r, createElementBlock as S, openBlock as f, createElementVNode as i, createBlock as T, renderSlot as s, Teleport as E, normalizeStyle as u, unref as $, createTextVNode as k, toDisplayString as B } from "vue";
|
|
2
2
|
import { u as D, a as O, f as z, s as A, o as F, b as I } from "./floating-ui.vue-CuGrC-z8.js";
|
|
3
|
-
import { u as P } from "./index-
|
|
3
|
+
import { u as P } from "./index-B1Gkwuxd.js";
|
|
4
4
|
const M = {
|
|
5
5
|
ref: "wrapper",
|
|
6
6
|
class: "stash-tooltip__wrapper relative inline-flex size-fit"
|
|
@@ -81,4 +81,4 @@ const M = {
|
|
|
81
81
|
export {
|
|
82
82
|
U as _
|
|
83
83
|
};
|
|
84
|
-
//# sourceMappingURL=Tooltip.vue_vue_type_script_setup_true_lang-
|
|
84
|
+
//# sourceMappingURL=Tooltip.vue_vue_type_script_setup_true_lang-CF6sw2VC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
{"version":3,"file":"Tooltip.vue_vue_type_script_setup_true_lang-CF6sw2VC.js","sources":["../src/components/Tooltip/Tooltip.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { arrow, autoUpdate, flip, offset, shift, type Side, useFloating } from '@floating-ui/vue';\n import { useMouseInElement } from '@vueuse/core';\n import { computed, ref } from 'vue';\n\n export type TooltipSide = Side;\n\n const ARROW_OFFSET_PX = 6;\n const OFFSET_DISTANCE_PX = 12;\n\n const SIDE_MAP: Record<TooltipSide, TooltipSide> = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n };\n\n export interface TooltipSlots {\n /**\n * The content to display in the tooltip. This may be text node, an element, or a component.\n */\n content: any;\n /**\n * The default slot is the element or component to which the tooltip will be anchored.\n */\n default: any;\n /**\n * A slot for the primary icon. This icon will be displayed before the text or content.\n */\n icon: any;\n /**\n * A slot for the secondary icon. This icon will be displayed after the text or content.\n */\n secondaryIcon: any;\n }\n\n defineSlots<TooltipSlots>();\n\n export interface TooltipProps {\n /**\n * Disables teleporting the popover menu to an external element\n * @default false\n */\n disableTeleport?: boolean;\n /**\n * Sets the placement of the menu\n * @default 'top'\n */\n side?: TooltipSide;\n /**\n * Disables the tooltip\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Sets if the menu is open. If not set from the parent context, the menu will be controlled internally.\n * @default false\n */\n isOpen?: boolean;\n /**\n * The query selector where the tooltip should be teleported\n * @default '#stash-menus-mount-node'\n */\n teleportTo?: string | HTMLElement;\n /**\n * String content to display within the tooltip\n * @default ''\n */\n text?: string;\n }\n\n const props = withDefaults(defineProps<TooltipProps>(), {\n disableTeleport: false,\n isDisabled: false,\n isOpen: false,\n side: 'top',\n teleportTo: '#stash-menus-mount-node',\n text: '',\n });\n\n const anchor = ref<HTMLElement | null>(null);\n const floatingArrow = ref<HTMLElement | null>(null);\n const tooltip = ref<HTMLElement | null>(null);\n\n const { isOutside } = useMouseInElement(anchor);\n\n const open = computed(() => !props.isDisabled && (!isOutside.value || props.isOpen));\n const placementSetting = computed(() => props.side);\n\n const { floatingStyles, middlewareData, placement } = useFloating(anchor, tooltip, {\n whileElementsMounted: autoUpdate,\n placement: placementSetting,\n middleware: [\n flip(),\n shift({ padding: 8 }),\n offset(OFFSET_DISTANCE_PX),\n arrow({ element: floatingArrow, padding: 8 }),\n ],\n });\n\n const arrowStyles = computed(() => {\n const arrowPosition = SIDE_MAP[placement.value];\n\n return {\n left: middlewareData.value.arrow?.x != null ? `${middlewareData.value.arrow.x}px` : '',\n top: middlewareData.value.arrow?.y != null ? `${middlewareData.value.arrow.y}px` : '',\n [arrowPosition]: `-${ARROW_OFFSET_PX}px`,\n };\n });\n</script>\n\n<template>\n <div ref=\"wrapper\" class=\"stash-tooltip__wrapper relative inline-flex size-fit\">\n <span ref=\"anchor\" data-test=\"stash-tooltip|anchor\" class=\"stash-tooltip__anchor\">\n <slot></slot>\n </span>\n <Teleport :to=\"props.teleportTo\" :disabled=\"props.disableTeleport\">\n <div\n ref=\"tooltip\"\n data-test=\"stash-tooltip\"\n class=\"stash-tooltip pointer-events-none z-screen flex w-[148px] flex-col items-center whitespace-normal rounded bg-ice-900 p-3 text-center text-xs text-white opacity-0 shadow transition-opacity\"\n role=\"tooltip\"\n :style=\"{\n ...floatingStyles,\n opacity: open ? 0.95 : 0,\n }\"\n >\n <slot name=\"icon\"></slot>\n <slot name=\"content\">{{ props.text }}</slot>\n <slot name=\"secondaryIcon\"></slot>\n <div\n ref=\"floatingArrow\"\n class=\"stash-tooltip__arrow absolute z-behind size-[12px] rotate-45 bg-ice-900\"\n :style=\"arrowStyles\"\n ></div>\n </div>\n </Teleport>\n </div>\n</template>\n"],"names":["ARROW_OFFSET_PX","OFFSET_DISTANCE_PX","SIDE_MAP","props","__props","anchor","ref","floatingArrow","tooltip","isOutside","useMouseInElement","open","computed","placementSetting","floatingStyles","middlewareData","placement","useFloating","autoUpdate","flip","shift","offset","arrow","arrowStyles","arrowPosition","_a","_b"],"mappings":";;;;;;GAOQA,IAAkB,GAClBC,IAAqB;;;;;;;;;;;AAE3B,UAAMC,IAA6C;AAAA,MACjD,KAAK;AAAA,MACL,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA,GAyDFC,IAAQC,GASRC,IAASC,EAAwB,IAAI,GACrCC,IAAgBD,EAAwB,IAAI,GAC5CE,IAAUF,EAAwB,IAAI,GAEtC,EAAE,WAAAG,EAAA,IAAcC,EAAkBL,CAAM,GAExCM,IAAOC,EAAS,MAAM,CAACT,EAAM,eAAe,CAACM,EAAU,SAASN,EAAM,OAAO,GAC7EU,IAAmBD,EAAS,MAAMT,EAAM,IAAI,GAE5C,EAAE,gBAAAW,GAAgB,gBAAAC,GAAgB,WAAAC,MAAcC,EAAYZ,GAAQG,GAAS;AAAA,MACjF,sBAAsBU;AAAA,MACtB,WAAWL;AAAA,MACX,YAAY;AAAA,QACVM,EAAA;AAAA,QACAC,EAAM,EAAE,SAAS,GAAG;AAAA,QACpBC,EAAOpB,CAAkB;AAAA,QACzBqB,EAAM,EAAE,SAASf,GAAe,SAAS,GAAG;AAAA,MAAA;AAAA,IAC9C,CACD,GAEKgB,IAAcX,EAAS,MAAM;;AACjC,YAAMY,IAAgBtB,EAASc,EAAU,KAAK;AAE9C,aAAO;AAAA,QACL,QAAMS,IAAAV,EAAe,MAAM,UAArB,gBAAAU,EAA4B,MAAK,OAAO,GAAGV,EAAe,MAAM,MAAM,CAAC,OAAO;AAAA,QACpF,OAAKW,IAAAX,EAAe,MAAM,UAArB,gBAAAW,EAA4B,MAAK,OAAO,GAAGX,EAAe,MAAM,MAAM,CAAC,OAAO;AAAA,QACnF,CAACS,CAAa,GAAG,IAAIxB,CAAe;AAAA,MAAA;AAAA,IAExC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|