npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fiscozen/pagination

v1.0.1

Published

Design System Pagination component

Readme

@fiscozen/pagination

For usage documentation, see Storybook Documentation

Development

Setup

pnpm install
pnpm --filter @fiscozen/pagination build

Architecture

The package is split into two layers:

  • usePagination composable (src/usePagination.ts): Pure logic that builds a reactive list of PaginationItem objects from currentPage, totalPages, and PaginationOptions. Accepts MaybeRefOrGetter inputs so it works with refs, computed values, and getter functions.
  • FzPagination component (src/FzPagination.vue): Thin UI wrapper that maps items to FzButton / FzIconButton / FzIcon components and emits update:currentPage on click.

Code Organization

src/
  index.ts              Main exports (component, composable, types)
  types.ts              All public types (FzPaginationProps, PaginationOptions, PaginationItem, etc.)
  usePagination.ts      Composable: token generation, clamping, ellipsis filtering
  FzPagination.vue      Component: renders items, handles v-model
  __tests__/
    FzPagination.spec.ts  Component unit tests
    usePagination.spec.ts Composable unit tests

Key Concepts

Token Pipeline

usePagination builds page items through a pipeline:

  1. Clamp current page into [1, totalPages]
  2. Slot config determines how many center pages, anchors, and ellipsis slots are available based on PaginationOptions
  3. Token generation creates a compact list of page numbers and 'ellipsis' markers that fits the slot budget
  4. Ellipsis filtering drops or keeps ellipsis based on the configured visibility (none, both, before, after)
  5. Normalization removes redundant ellipsis (adjacent duplicates, gaps of 1)
  6. Item mapping converts tokens into PaginationItem objects with type, value, label, current, disabled

Position / Alignment

The position prop maps to a justifyClass computed that applies Tailwind justify-start, justify-center, or justify-end to FzContainer. Default is 'end'.

Responsive Behaviour

The component uses useMediaQuery from @fiscozen/composables to detect desktop vs mobile. On mobile, prev/next buttons render as icon-only (FzIconButton) wrapped in <span> elements with flex layout classes.

buttonClasses Helper

buttonClasses(item) centralizes all conditional CSS classes for each pagination item:

  • !min-w-44 on every item
  • flex-1 + justify-start/justify-end for prev/next on mobile
  • fz-pagination-disable-truncate on the current page button

Truncate Override (Scoped CSS)

FzButton applies a .truncate class internally. The scoped CSS rule :deep(.fz-pagination-disable-truncate > .truncate) overrides overflow, text-overflow, and white-space on the active page button so long labels remain visible.

Testing

Running Tests

pnpm --filter @fiscozen/pagination test:unit
pnpm --filter @fiscozen/pagination coverage

Test Structure

Tests mock window.matchMedia (required by useMediaQuery) in beforeEach. They query the DOM directly with wrapper.findAll('button') rather than component name lookups for resilience against component renaming.

Coverage target: >90% line coverage.

Adding Features

  1. Update types in src/types.ts (add props or options fields with JSDoc)
  2. Update composable in src/usePagination.ts if the feature affects item generation logic
  3. Update component in src/FzPagination.vue for template/rendering changes
  4. Add tests in src/__tests__/FzPagination.spec.ts
  5. Update stories in apps/storybook/src/stories/navigation/Pagination.stories.ts
  6. Update MDX in apps/storybook/src/FzPagination.mdx

Dependencies

  • @fiscozen/button - FzButton and FzIconButton for page controls
  • @fiscozen/container - FzContainer for layout
  • @fiscozen/icons - FzIcon for ellipsis indicator
  • @fiscozen/composables - useMediaQuery for responsive layout
  • @fiscozen/style - breakpoints for media query thresholds

Build

pnpm --filter @fiscozen/pagination build

Runs vue-tsc for type checking followed by Vite library build. Output goes to dist/.