{{-- ═══════════════════════════════════════════════════════════════════════ Tab State Persistence Helper ═══════════════════════════════════════════════════════════════════════ Include this partial on any page with tabbed content so the active tab survives page refreshes AND Laravel pagination clicks. WHAT IT DOES: 1. On page load, reads ?tab=X from the URL. If found, activates the matching tab button and panel. Works with the existing click handlers — it simulates a click on the matching tab button. 2. Wraps tab click handlers so that clicking a tab also updates the URL query string via history.replaceState (no reload). This way, when the page refreshes or a pagination link fires a GET, the `tab` param survives. 3. Rewrites Laravel pagination links to append the current tab param so moving between pages within a tab stays on that tab. HOW TO USE (in any tabbed view): @include('partials._tab-state-helper', ['defaultTab' => 'drugs']) REQUIREMENTS: - Tab buttons must call a switcher like `switchInvTab(this, 'drugs')` or similar that takes a string id (case-sensitive) matching the panel id suffix. - Tab buttons must be queryable via `.hmis-tab` (the existing class already used across tabbed pages). - Tab buttons must have a `data-tab-id` attribute OR we fall back to parsing their onclick handler. - Paginated content should use `->withQueryString()` on the backend paginator so the `tab` param is preserved on link clicks. --}} @php // @phpstan-ignore-next-line $defaultTab = $defaultTab ?? 'drugs'; @endphp