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

@richigo/date-picker-lib

v1.0.23

Published

calendar library

Downloads

49

Readme

@richigo/date-picker-lib

This library provides two components for work with calendars. First, DatePicker allows you to pick single day from calendar. This component also includes Todo list that can add\delete todo for specific day. These todos will be saved in localStorage. Second, RangeDatePicker can pick range between two dates.

Installation

    yarn add datepicker-pl1fert
    # or
    npm install datepicker-pl1fert

API

Date pickers receive following props:

//Common props for all pickers
interface PickerProps {
  minDate?: Date;
  maxDate?: Date;
  styles?: CalendarStyles;
  highlightWeekends?: boolean;
  highlightHolidays?: boolean;
  weekStartDay?: WeekStartDay;
  initialDate?: Date;
  viewType?: CalendarViewType;
  holidays?: Holiday[];
}

//DatePicker
interface DatePickerProps extends PickerProps {
  withTodo?: boolean;
  onSelect?: (day: Date | null) => void;
}

//RangeDatePicker
interface RangeDatePickerProps extends PickerProps {
  onSelect?: (from: Date | null, to: Date | null) => void;
}

minDate and maxDate

These props define range of date within which the calendar will navigate.

styles

Both components can receive prop styles:

interface CalendarStyles {
  // for days that are included in the current month
  innerDay?: CalendarDayStyle;
  // for days that are not included in the current month
  outerDay?: CalendarDayStyle;
  // for day that is picked as start of selection range
  selectionHeadDay?: CalendarDayStyle;
  // for day that is picked as start of selection range
  selectionTailDay?: CalendarDayStyle;
  // for days that are inside of selection range (only for RangeDatePciker)
  selectedDay?: CalendarDayStyle;
  //style for today
  today?: CalendarDayStyle;
  //style for weekend
  weekend?: CalendarDayStyle;
  //style for holiday
  holiday?: CalendarDayStyle;
  //style for day that has todos
  withTodoDay?: CalendarDayStyle;
  //style for calendar
  calendar?: CalendarColors;
}

This way you can set styles for days and calendar.

Styles for days are consist of some React CSSProperties. For define day style you have to use object with following properties:

import { CSSProperties } from 'react';

type ReactCssProperties = Pick<CSSProperties, keyof CSSProperties>;

export type CalendarDayStyle = ReactCssProperties;

To style calendar itself you need to pass next object:

import { CSSProperties } from 'react';

type ReactCssProperties = Pick<CSSProperties, keyof CSSProperties>;

export type CalendarColors = ReactCssProperties;

Warning! To style selected day in DatePicker, you need to pass styles in selectionTailDay.

It worth noting, that each style has own precedence, and will rewrite previous style rules in following order (from lowest to highest priority):

    innerDay < today < weekend < outerDay < holiday < selectedDay < selectionHeadDay < selectionTailDay < withTodoDay

highlightWeekends

This prop is for show or hide weekend styles display.

highlightHolidays

Same as highlightWeekends but for holidays.

initialDate

This prop is used for setting start date of your calendar.

weekStartDay

Sets start date of the week. Accept WeekStartDay enum:

enum WeekStartDay {
  Sunday = 0,
  Monday = 1,
}

viewType

Sets display type of calendar. Accept CalendarViewType enum:

enum CalendarViewType {
  Week = 0,
  Month = 1,
  Year = 2,
}

holidays

This prop allows you to set holidays that will be displayed. Accepts array of Holiday's:

interface Holiday {
  name: string;
  day: number;
  month: number; // zero-based!
}

onSelect

onSelect event triggers on every date selection. For DatePicker:

    onSelect?: (day: Date | null) => void

For RangeDatePicker:

    onSelect?: (from: Date | null, to: Date | null) => void

withTodo

Add todo list to Picker. This prop is available only for DatePicker.

Demo

Storybook

Interactive example of library usage