This PR adds three components along with stories 1. MultiSelect - This is used for filter values, allowing multiple values and folding of values where there are too many items 2. SingleSelect - This is used for filter values, allows selecting and toggling a single item 3. FilterSelect - This is used for operators and others, it allows icons and labels as well as toggling them using props. The v-model for this binds just the final value unlike the previous two components with bind the entire object. --------- Co-authored-by: Pranav <pranavrajs@gmail.com>
31 lines
643 B
Vue
31 lines
643 B
Vue
<script setup>
|
|
import { useToggle } from '@vueuse/core';
|
|
import { vOnClickOutside } from '@vueuse/components';
|
|
import { provideDropdownContext } from './provider.js';
|
|
|
|
const emit = defineEmits(['close']);
|
|
const [isOpen, toggle] = useToggle(false);
|
|
|
|
const closeMenu = () => {
|
|
if (isOpen.value) {
|
|
emit('close');
|
|
toggle(false);
|
|
}
|
|
};
|
|
|
|
provideDropdownContext({
|
|
isOpen,
|
|
toggle,
|
|
closeMenu,
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="relative space-y-2">
|
|
<slot name="trigger" :is-open :toggle="() => toggle()" />
|
|
<div v-if="isOpen" v-on-click-outside="closeMenu" class="absolute">
|
|
<slot />
|
|
</div>
|
|
</div>
|
|
</template>
|