PIMS/resources/js/lib/utils.ts

19 lines
511 B
TypeScript
Raw Permalink Normal View History

2025-12-07 03:49:26 +00:00
import { InertiaLinkProps } from '@inertiajs/vue3';
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function urlIsActive(
urlToCheck: NonNullable<InertiaLinkProps['href']>,
currentUrl: string,
) {
return toUrl(urlToCheck) === currentUrl;
}
export function toUrl(href: NonNullable<InertiaLinkProps['href']>) {
return typeof href === 'string' ? href : href?.url;
}