87 lines
2.3 KiB
Vue
87 lines
2.3 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from "vue";
|
|
import {
|
|
Select,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
SelectIndicator,
|
|
SelectPopover,
|
|
ListBox,
|
|
ListBoxItem,
|
|
ListBoxItemIndicator,
|
|
Label,
|
|
Button,
|
|
Modal,
|
|
ModalTrigger,
|
|
ModalBackdrop,
|
|
ModalContainer,
|
|
ModalDialog,
|
|
ModalHeading,
|
|
} from "@heroui-vue/components";
|
|
const log = ref<string[]>([]);
|
|
function record(event: AnimationEvent) {
|
|
const element = event.target as HTMLElement;
|
|
if (element.dataset.slot !== "select-popover") return;
|
|
const style = getComputedStyle(element);
|
|
log.value.push(
|
|
JSON.stringify({
|
|
event: event.type,
|
|
name: event.animationName,
|
|
elapsed: event.elapsedTime,
|
|
entering: element.dataset.entering,
|
|
exiting: element.dataset.exiting,
|
|
duration: style.animationDuration,
|
|
scale: style.getPropertyValue("--tw-enter-scale"),
|
|
side: element.dataset.side,
|
|
}),
|
|
);
|
|
}
|
|
</script>
|
|
<template>
|
|
<div class="flex flex-col gap-4 p-8">
|
|
<Button>Before select</Button>
|
|
<Select class="w-64" placeholder="Choose" default-value="12">
|
|
<Label>Lifecycle select</Label>
|
|
<SelectTrigger>
|
|
<SelectValue />
|
|
<SelectIndicator />
|
|
</SelectTrigger>
|
|
<SelectPopover @animationstart="record" @animationend="record">
|
|
<ListBox>
|
|
<ListBoxItem
|
|
v-for="index in 40"
|
|
:id="String(index)"
|
|
:key="index"
|
|
:text-value="`Option ${index}`"
|
|
>
|
|
Option {{ index }}
|
|
<ListBoxItemIndicator />
|
|
</ListBoxItem>
|
|
</ListBox>
|
|
</SelectPopover>
|
|
</Select>
|
|
<Button>After select</Button>
|
|
<Modal>
|
|
<ModalTrigger>Open parent</ModalTrigger>
|
|
<ModalBackdrop>
|
|
<ModalContainer>
|
|
<ModalDialog>
|
|
<ModalHeading>Parent</ModalHeading>
|
|
<Select class="w-64">
|
|
<Label>Nested select</Label>
|
|
<SelectTrigger>
|
|
<SelectValue />
|
|
<SelectIndicator />
|
|
</SelectTrigger>
|
|
<SelectPopover>
|
|
<ListBox><ListBoxItem id="one">One</ListBoxItem></ListBox>
|
|
</SelectPopover>
|
|
</Select>
|
|
</ModalDialog>
|
|
</ModalContainer>
|
|
</ModalBackdrop>
|
|
</Modal>
|
|
<pre aria-label="Animation log">{{ log.join("\n") }}</pre>
|
|
</div>
|
|
</template>
|