2024-07-05 12:22:31 +00:00
|
|
|
<template>
|
2024-07-09 09:00:50 +00:00
|
|
|
<div :class="rootPT">
|
2024-07-08 11:24:09 +00:00
|
|
|
<button
|
|
|
|
id="dropdownDefaultButton"
|
|
|
|
data-dropdown-toggle="dropdown"
|
|
|
|
:class="titlePT"
|
|
|
|
type="button"
|
|
|
|
@click="
|
|
|
|
useRipple($event, props.ripple);
|
|
|
|
openMenu();
|
|
|
|
"
|
|
|
|
>
|
|
|
|
{{ props.title }}
|
|
|
|
<span :class="arrowPT">
|
|
|
|
<ml-arrow></ml-arrow>
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
<div v-show="isMenuOpen" :class="dropdownPT" @click="isOpen = false">
|
|
|
|
<slot />
|
2024-07-05 12:22:31 +00:00
|
|
|
</div>
|
2024-07-08 11:24:09 +00:00
|
|
|
</div>
|
2024-07-05 12:22:31 +00:00
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
2024-07-08 11:24:09 +00:00
|
|
|
import { computed, ref } from "vue";
|
|
|
|
import { useRipple } from "#imports";
|
|
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
import type { DropDownProps, DropDownPT } from "./types";
|
2024-07-05 12:22:31 +00:00
|
|
|
|
|
|
|
const props = withDefaults(defineProps<DropDownProps>(), {
|
2024-07-08 11:24:09 +00:00
|
|
|
isOpen: false,
|
2024-07-05 12:22:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const PT = {
|
2024-07-08 11:24:09 +00:00
|
|
|
root: {
|
2024-07-08 12:10:47 +00:00
|
|
|
class: "",
|
2024-07-08 11:24:09 +00:00
|
|
|
},
|
|
|
|
dropdown: {
|
2024-07-09 09:00:50 +00:00
|
|
|
class: "z-10 absolute bg-white rounded-3xl pointer text-black text-center",
|
2024-07-08 11:24:09 +00:00
|
|
|
},
|
|
|
|
title: {
|
|
|
|
class:
|
|
|
|
"text-black inline-flex items-center rounded-lg font-medium text-center text-base pointer ",
|
|
|
|
},
|
|
|
|
arrow: {
|
|
|
|
class: "px-2",
|
|
|
|
},
|
2024-07-05 12:22:31 +00:00
|
|
|
} as DropDownPT;
|
|
|
|
|
|
|
|
const rootPT = computed(() => twMerge(PT.root?.class, props.pt?.root?.class));
|
2024-07-08 11:24:09 +00:00
|
|
|
const titlePT = computed(() =>
|
|
|
|
twMerge(PT.title?.class, props.pt?.title?.class)
|
|
|
|
);
|
|
|
|
const dropdownPT = computed(() =>
|
|
|
|
twMerge(PT.dropdown?.class, props.pt?.dropdown?.class)
|
|
|
|
);
|
|
|
|
const arrowPT = computed(() =>
|
|
|
|
twMerge(PT.arrow?.class, props.pt?.arrow?.class)
|
|
|
|
);
|
2024-07-05 12:22:31 +00:00
|
|
|
|
|
|
|
const isOpen = ref(props.isOpen);
|
|
|
|
|
|
|
|
function openMenu() {
|
2024-07-08 11:24:09 +00:00
|
|
|
isOpen.value = !isOpen.value;
|
2024-07-05 12:22:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const isMenuOpen = computed(() => isOpen.value);
|
|
|
|
</script>
|