mirror of
https://github.com/tabler/tabler.git
synced 2026-08-07 03:42:27 +04:00
f27c70ad38
`Render Modal as real markup` (#2742) reformatted ~140 files back to tabs/semicolons, breaking the Prettier config added by the Astro quality gates (#2749). Re-run prettier --write to restore it, and fix the type errors it had been masking: HTMLElement casts and `this` typing in ChangePasswordModalContent/ConfirmDeleteModalContent scripts, plain-JS syntax in the inline-injected progress.astro script, narrowed prop unions in Button/Check/Spinner, nullable icon svg casts in Icons/Rating, and a duplicate firstLetters/invalid `placeholder` attribute in Select.astro. Also fix shared/vitest.config.mts's stale `astro/lib/**/*.test.ts` include glob left over from the shared source restructure, which made `pnpm test` report zero test files.
111 lines
2.9 KiB
Plaintext
111 lines
2.9 KiB
Plaintext
---
|
|
import Icon from './Icon.astro'
|
|
|
|
interface Props {
|
|
count?: number
|
|
offset?: number
|
|
activeItem?: number | string
|
|
class?: string
|
|
firstLast?: boolean
|
|
text?: boolean
|
|
prevDescription?: string
|
|
nextDescription?: string
|
|
}
|
|
|
|
const { count = 5, offset = count, activeItem: activeItemProp = 3, class: className, firstLast, text, prevDescription, nextDescription } = Astro.props
|
|
|
|
const activeItem = Number(activeItemProp)
|
|
const normalizedActiveItem = Number.isFinite(activeItem) ? activeItem : 3
|
|
|
|
// equivalent of the (1..offset) loop
|
|
const firstPages: number[] = []
|
|
for (let i = 1; i <= offset; i++) firstPages.push(i)
|
|
|
|
// equivalent of (count-offset..count), where count-offset = count - offset + 1
|
|
const countOffset = count - offset + 1
|
|
const lastPages: number[] = []
|
|
if (offset < count) {
|
|
for (let i = countOffset; i <= count; i++) lastPages.push(i)
|
|
}
|
|
---
|
|
|
|
<!-- BEGIN PAGINATION -->
|
|
<ul class={`pagination${className ? ` ${className}` : ''}`}>
|
|
{
|
|
firstLast && (
|
|
<li class="page-item disabled">
|
|
<a class={`page-link${text ? ' page-text' : ''}`} href="#" tabindex="-1" aria-disabled="true">
|
|
{!text ? <Icon name="chevrons-left" /> : 'Previous'}
|
|
</a>
|
|
</li>
|
|
)
|
|
}
|
|
<li class={`page-item${prevDescription ? ' page-prev' : ''} disabled`}>
|
|
<a class={`page-link${text ? ' page-text' : ''}`} href="#" tabindex="-1" aria-disabled="true">
|
|
{
|
|
prevDescription ? (
|
|
<>
|
|
<div class="page-item-subtitle">previous</div>
|
|
<div class="page-item-title">{prevDescription}</div>
|
|
</>
|
|
) : !text ? (
|
|
<Icon name="chevron-left" />
|
|
) : (
|
|
'Previous'
|
|
)
|
|
}
|
|
</a>
|
|
</li>
|
|
{
|
|
firstPages.map((i) => (
|
|
<li class={`page-item${i === normalizedActiveItem ? ' active' : ''}`}>
|
|
<a class="page-link" href="#">
|
|
{i}
|
|
</a>
|
|
</li>
|
|
))
|
|
}
|
|
{
|
|
offset < count && (
|
|
<>
|
|
<li class="page-item">
|
|
<span class="page-link disabled">…</span>
|
|
</li>
|
|
{lastPages.map((i) => (
|
|
<li class={`page-item${i === normalizedActiveItem ? ' active' : ''}`}>
|
|
<a class="page-link" href="#">
|
|
{i}
|
|
</a>
|
|
</li>
|
|
))}
|
|
</>
|
|
)
|
|
}
|
|
<li class={`page-item${prevDescription ? ' page-next' : ''}`}>
|
|
<a class={`page-link${text ? ' page-text' : ''}`} href="#">
|
|
{
|
|
nextDescription ? (
|
|
<>
|
|
<div class="page-item-subtitle">next</div>
|
|
<div class="page-item-title">{nextDescription}</div>
|
|
</>
|
|
) : !text ? (
|
|
<Icon name="chevron-right" />
|
|
) : (
|
|
'Next'
|
|
)
|
|
}
|
|
</a>
|
|
</li>
|
|
{
|
|
firstLast && (
|
|
<li class="page-item">
|
|
<a class={`page-link${text ? ' page-text' : ''}`} href="#">
|
|
{!text ? <Icon name="chevrons-right" /> : 'Next'}
|
|
</a>
|
|
</li>
|
|
)
|
|
}
|
|
</ul>
|
|
<!-- END PAGINATION -->
|