import type { BooleanInput } from '@angular/cdk/coercion';
import {
booleanAttribute,
ChangeDetectionStrategy,
Component,
computed,
input,
} from '@angular/core';
import type { RouterLink } from '@angular/router';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideChevronLeft } from '@ng-icons/lucide';
import type { ButtonVariants } from '@spartan-ng/styles/button';
import { hlm } from '@spartan-ng/styles/utils';
import type { ClassValue } from 'clsx';
import { HlmPaginationLink } from './hlm-pagination-link';
@Component({
selector: 'hlm-pagination-previous',
imports: [HlmPaginationLink, NgIcon],
providers: [provideIcons({ lucideChevronLeft })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
{{ text() }}
`,
})
export class HlmPaginationPrevious {
public readonly userClass = input('', { alias: 'class' });
/** The link to navigate to the previous page. */
public readonly link = input();
/** The query parameters to pass to the previous page. */
public readonly queryParams = input();
/** How to handle query parameters when navigating to the previous page. */
public readonly queryParamsHandling = input();
/** The aria-label for the previous page link. */
public readonly ariaLabel = input('Go to previous page', { alias: 'aria-label' });
/** The text to display for the previous page link. */
public readonly text = input('Previous');
/** Whether the button should only display the icon. */
public readonly iconOnly = input(false, {
transform: booleanAttribute,
});
protected readonly _labelClass = computed(() =>
hlm(this.iconOnly() ? 'sr-only' : 'hidden sm:block'),
);
protected readonly _size = computed(() =>
this.iconOnly() ? 'icon' : 'default',
);
protected readonly _computedClass = computed(() =>
hlm(!this.iconOnly() && 'ps-1.5!', this.userClass()),
);
}