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

react-anpicker

v2.0.11

Published

a react date picker for supporting persian dates

Downloads

289

Readme

react-anpicker

react-anpicker is a free and light component in react for date picker mostly based on Intl and predefined function for converting dates

  • type script
  • rtl/ltr
  • other calendars

demo image

Installation

react-anpicker requires react "^18.2.0", react-dome "^18.2.0" to run.

run this command:

npm i react-anpicker

add css to your project

import "react-anpicker/dist/styles.css";

Usage

import { AnPicker } from 'react-anpicker';
...
    const [date, setDate] = useState(null);
    const handleChange = (date: Date | null, localDate: string | null) => { }
    <AnPicker value={date} onChange={handleChange} />
...

Props

  • showTodayBottom: boolean- today button be visible or not
  • value::string includes year/month/day
  • onChange: (string, gregorianDate?: [number, number, number]) => void- a function that fires after change with valid date and gives you value
  • showTodayBottom: boolean- today button be visible or not
  • inputControl: ReactElemt- for passing an custom input from other libraries
  • showSidebar: boolean: show sidebar beside picker section
  • popupTargetId: by defaylt date picker appears as a last child of body, in case like using it in a modal, you can specify wrapper for it.
  • locale: :
{
   title:string-calander title in sidebar
   name: string-locale from Intl like "en-US" or "fa-IR" ,...
   startOfWeek: number-if your week not starts with monday, you can specifing it(sunday=-1,tusday=1);
   rtl: boolean;
   todayButtonText: string,
   daysOfEachMonth: (year: number, month: number) => number-a functio that return number of days in each month
   numberConverter: (number: string) => number- get number in other languages in convert them to eng number;
   convertToDate: (localYear: number, localMonth: number, localDay: number) => [number, number, number]- a function that takes local date and retrun eq in gregorian date;
}

an object that needs to be set if you use another locale, default is been configed for "fa-Ir"

gregorian config example

gregorian image

for this calander use locale like below:

{
  rtl: false,
  convertToDate: (y, m, d) => [y, m, d],
  daysOfEachMonth: (y, m) => {
    switch (m) {
      case 1:
      case 3:
      case 5:
      case 6:
      case 7:
      case 8:
      case 10:
      case 12:
        return 31;
      case 2:
        let isKabise = false;
        if (y % 400 === 0) isKabise = true;
        else if (y % 100 === 0) isKabise = false;
        else if (y % 4 === 0) isKabise = true;
        return isKabise ? 29 : 28;
      default:
        return 30;
    }

  },
  name: "en-US",
  numberConverter: (n) => parseInt(n),
  startOfWeek:0,
  title:"Gregorian",
  todayButtonText:"today"
}