Files
app-beta/resources/views/components/common/table-dropdown.blade.php
2025-12-21 08:03:18 +07:00

40 lines
1.2 KiB
PHP

<div x-data="{
isOpen: false,
popperInstance: null,
init() {
this.$nextTick(() => {
this.popperInstance = createPopper(this.$refs.button, this.$refs.content, {
placement: 'bottom-end',
strategy: 'fixed',
modifiers: [
{
name: 'offset',
options: {
offset: [0, 4],
},
},
],
});
});
},
toggle() {
this.isOpen = !this.isOpen;
if (this.popperInstance) {
this.popperInstance.update();
}
}
}"
@click.away="isOpen = false">
<div @click="toggle()" x-ref="button" class="cursor-pointer">
{{ $button }}
</div>
<div class="z-50 fixed" x-ref="content">
<div x-show="isOpen" x-cloak class="p-2 bg-white border border-gray-200 rounded-2xl shadow-lg dark:border-gray-800 dark:bg-gray-dark w-40">
<div class="space-y-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">
{{ $content }}
</div>
</div>
</div>
</div>