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 🙏

© 2024 – Pkg Stats / Ryan Hefner

default-pagination-vue

v0.2.2

Published

A pagination component for Vue 3

Downloads

7

Readme

default-pagination-vue

Installation

Install the package

$ npm install default-pagination-vue

Register the component globally in the main.js

import DefaultPagination from 'default-pagination-vue';

const app = createApp(App);
app.component('default-pagination', DefaultPagination);

or inside a component

import DefaultPagination from 'default-pagination-vue';
export default {
  components: {
    DefaultPagination
  }
};

Simple example

<default-pagination
  v-model="current"
  :total-pages="20"
  :max-squares="10"
  no-first-last-icon
  not-inherit-font
  @page-click="handleClick"
/>
    handleClick({ newPage, totalPages, blurState, cancelChange, done }){}

Props (every Boolean prop is false by default)

| Name                                        | Type | Description | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------- | :-------------------------------------------------------------------------------------------------------------------------- | | total-pages | Number | 1 by default | | v-model | Number | Will set/get the current page. 1 by default | | max-squares | Number | Number of squares (all pages including the '...' buttons). 7 by default | | no-first-last-icon | Boolean | Removes the icon from 'first' and 'last' button | | no-first-last-text | Boolean | Removes the text from 'first' and 'last' button | | no-first-last | Boolean | Removes 'first' and 'last' button | | text-first | String | Text for the 'first' button 'First' by default | | text-last | String | Text for the 'last' button 'Last' by default | | no-prev-next | Boolean | Removes 'previous' and 'next' button | | mode-simple | Boolean | pagination without any '...' | | mode-default | Boolean | pagination with '...' before and after the pages when it is necessary | | mode-fancy | Boolean | pagination with '...' after at the first square and the first page always visible (same for the last), when it is necessary | | primary-color | String | CSS color (text color mainly) #4c4c4c by default | | secondary-color | String | CSS color (background page buttons mainly) white by default | | shadow-color | String | CSS color #565656 by default | | disabled-color | String | CSS color (text color of controller buttons when there is no previous or next page) #808080ad by default | | colored-controllers | Boolean | Controllers (first/prev/next/last) with the same color of font (primary-color) when they are enable | | not-inherit-font | Boolean | Will not inherit the font-family from your project, but the same as the examples 'Commissioner' font-family |

'page-click' event

| Name                                        | Type | Description | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | newPage | Number | Current page | | totalPages | Number | Total pages | | cancelChange | Function | In case an error happens during the http request for example, it will return to the previous page, recommended use inside '.catch' | | blurState | Function | use it whenever you use 'cancelChange' in your code, it will blur the component and prevent the user click, the 'cancelChange' or 'done' can deblur the component | | done | Function | will release the component, you can call inside the '.then' for example |

Example

    handleClick({ newPage, totalPages, blurState, cancelChange, done }) {
      console.log(newPage, totalPages, blurState, cancelChange, done);
      blurState();
      setTimeout(() => cancelChange(), 500);
    }
    handleClick({ blurState, cancelChange, done }) {
      blurState();
      yourRequest().then(()=>{
        //your code here
        done();
      })
      .catch(err => {
        cancelChange();
        alert(err);
      });
    }

Slots (replace content)

| Name                                        | Description | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------- | | first | Content inside 'first button' | | last | Content inside 'last button' | | previous | Content inside 'previous button' | | next | Content inside 'next button' |

Example

<default-pagination v-model="current" :total-pages="10">
  <template #first> First one page </template>
  <template #last> Last one page <my-component /> </template>
  <template #previous> <my-own-icon /> </template>
</default-pagination>