@props([ 'viewHref' => null, 'editHref' => null, 'deleteAction' => null, 'toggleAction' => null, 'canDelete' => true, 'confirmDelete' => null, ]) @php $confirm = $confirmDelete ?? __('admin.confirm_delete'); $hasMenu = $viewHref || $editHref || $toggleAction || ($deleteAction && $canDelete) || ! $slot->isEmpty(); @endphp @if ($hasMenu)
class(['admin-row-actions']) }} x-data="{ open: false, menuStyle: { top: '0px', left: '0px' }, ignoreOutside: false, updatePosition() { const btn = this.$refs.trigger; if (! btn) return; const r = btn.getBoundingClientRect(); const menu = this.$refs.menu; const mw = menu?.offsetWidth || 168; const mh = menu?.offsetHeight || 140; let top = r.bottom + 6; if (top + mh > window.innerHeight - 8) { top = Math.max(8, r.top - mh - 6); } let left = document.documentElement.dir === 'rtl' ? r.left : (r.right - mw); if (left < 8) left = 8; if (left + mw > window.innerWidth - 8) left = window.innerWidth - mw - 8; this.menuStyle = { top: top + 'px', left: left + 'px' }; }, toggle(event) { event.preventDefault(); event.stopPropagation(); if (this.open) { this.open = false; return; } this.open = true; this.ignoreOutside = true; this.$nextTick(() => { this.updatePosition(); requestAnimationFrame(() => { this.ignoreOutside = false; }); }); }, close() { if (this.ignoreOutside) return; this.open = false; }, onOutside(event) { if (this.$refs.trigger && this.$refs.trigger.contains(event.target)) { return; } this.close(); }, }" @keydown.escape.window="close()" @scroll.window="close()" @resize.window="close()" >
@endif