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

calender-carousal-package-react-ts

v2.0.2

Published

<a href="https://www.npmjs.com/package/calender-carousal-package-react-ts"> <img alt="downloads" src="https://img.shields.io/badge/npm-v2.0.2-blue" target="_blank" /> </a> <a href=""> <img alt="License: MIT" src="https://img.shields.io/badge/license-M

Downloads

6

Readme

calender-carousal-react-ts

Table of contents

Installation

You can install calender-carousal-package-react-ts using npm.

npm i calender-carousal-package-react-ts

Usage

import { CalendarProvider } from 'calender-carousal-package-react-ts'
const App = () => {
  return (
    <CalendarProvider>
      {...}
    </CalendarProvider>
  )
}

export default App
import CalenderCarousalContainer from 'calender-carousal-package-react-ts'

const TestComponent = () => {
  return (
    {...}
      <CalenderCarousalContainer />
    {...}
  )
}

export default TestComponent

API

The CalenderCarousalContainer component can be used by wrapping it in the CalendarProvider, both imported from Calender-Carousel. All of the calendar’s state management and date logic are bundled in useCalendar custom hook.

Components 

CalendarProvider

| Prop | Description | Type | Default | | :----------- | :----------------------------------------------------------- | :--------------------------------------- | :------ | | datesRange | The Range of dates displayed in the Carousel | DateType[] |1 Week From CurrentDay| | intervalStep | The Time Span by which duration should increase or decrease | Duration | Value of span is 15 & Unit is "Min" You can choose any span value with avaiable units (Hrs,Mins & Days). | | | || | formats | The display format for date, time, and clock | Formats | Default Formats are Dates : "DD MM YYYY" Clock : "12h" Time : "hh:mm A" | minDuration | Lower threshold for the duration (in Minutes,Hours & Days) | Duration | Default value of span is 30 & Unit is "Mins" | | maxDuration | Upper threshold for the duration (in Minutes,Hours & Days) |Duration | Default value of span is 180 & Unit is "Mins" | | cardsBreakPoints | Numbers of cards per screen to be displayed in Carousal | CardBreakPoint | Default Values of Card Break Points | unavailableDates |You can Either give List of Unavailable Dates or a Callback which will specifies the dates that cannot be selected|UnavailableDate[] |(date: Dayjs) => boolean| Default value is Sunday| | unavailableHours | Hours that should be closed in Time Picker | UnavailableHrs | 12 AM TO 2 AM | | theme | Theme for the calendar and the components within | CalendarTheme | |

CalendarCarousalContainer

| Prop | Description | Type | Default | | :---------------- | :-------------------------------------------------- | :------------------- | :----------- | | activePanels | What panels should initially be opened | string \| string[] | ['1'] | | dateComponent | Component that will replace the card carousel | ReactNode | | | timeComponent | Component that will replace the time picker | ReactNode | | | durationComponent | Component that will replace the duration setter | ReactNode | |

Hooks 

useCalendar

This custom hook provides access to all the state values of the package, along with the functions to update the state.

| Name | Description | Type | | :--------------- | :----------------------------------------------------------- | :--------------------------------------- | | selected | Selected date, time, and duration | Selected | | setDate | Function to update the selected date | (date: Dayjs) => void | | setTime | Function to update the selected time | (time: Dayjs) => void | | handleIncrementClick | Function to increase the selected duration | (offsetValue: Duration) => number | | handleDecrementClick | Function to decrease the selected duration | (offsetValue: Duration) => number | | dateList | The dates displayed in the carousel | DateType[] | | intervalStep | The Time Span by which duration should increase or decrease |Duration | | formats | The display format for date, time, and clock | Formats | | minDuration | Lower threshold for the duration (in Minutes,Hours & Days) | Duration | | maxDuration | Upper threshold for the duration (in Minutes,Hours & Days) | Duration | | cardsBreakPoints |Numbers of cards per screen to be displayed in Carousal | CardBreakPoint | | unavailableDates | You can Either give List of Clode Dates or a Callback which will specifies the dates that cannot be selected| UnavailableDate[] |(date: Dayjs) => boolean | | unavailableHours | Hours that should be closed in Time Picker | UnavailableHrs |

Custom Types

DateType

Date entry with its associated information.

type DateType = {
  date: Dayjs
  unavailable?: boolean
}

Formats

Display format for the date, time and allow the selection of 12 or 24 hour format.

type Formats = {
  date: string 
  time: string 
  clock: '12h' | '24h' 
}

Duration

Duration format for defining time intervals.

type Duration = {
  span: number;
  unit: string;
};

CardBreakPoint

Number of cards to display per slide based on the different screen sizes.

export type CardBreakPoint = {
  xs: number 
  sm: number
  md: number
  xl: number
  xxl: number
}

UnavailableHrs

Range of unavailable hours, including start and end.


export type UnavailableHrs = {
  start: number;
  end: number;
};

UnavailableDate

Date that would be unavaible in Calendar


export type UnavailableDate, = {
  string|Dayjs
};

Selected

export type Selected = {
  date: Dayjs | null
  time: Dayjs | null
  Duration: number 
}

CalendarTheme

type CalendarTheme = {
  isDark: boolean /**@default false */
  general?: Partial<AliasToken>
  custom?: Partial<CustomStyles>
}

DateRange

export type DateRange= {
  start: Dayjs 
  end: Dayjs 
  
}

CustomStyles

custom styles allow for component-specific customization. Below are the styles that can be applied. | Name | Description | Type | | :--- | :--- | :--- | | colorCardHeader | Header color for open date cards | string | colorCardHeaderText | Text color for date card header | string | colorCardBodyText | Text color for date card body | string | colorButton | Color for the duration buttons | string | colorTimePicker | Color for the TimePicker component | string | cardGap | Gap between the date cards in the carousel | number | buttonBorderRadius | Border radius of buttons that update duration | number

Default Card Breakpoints Values

Default number of cards to display per slide based on the different screen sizes.

export const CARD_BREAKPOINT: CardBreakPoint = {
  xs: 1,
  sm: 2,
  md: 3,
  lg: 5,
  xl: 7,
  xxl: 9,
}

Utils

getDatesList

returns: DateType[] Get a list of dates consisiting of the Range you provided as props. | Param | Description | Type | | :--- | :--- | :--- | | Range | Range of Date you want to Display | {DateRange}(#DateRange) | unavaiableDates | Dates that should be closed | string | Dayjs

getMeanDuration

returns: number Get mean value for the Duration. | Param | Description | Type | | :--- | :--- | :--- | | minDuration | Minimum Value of Duration in min| Duration | maxDuration | Maximum Value of Duration in min| Duration

formattedDuration

returns: string Convert minutes into hour representation. | Param | Description | Type | | :--- | :--- | :--- | | minutes | The duration in minutes | number

getFormattedTime

returns: string Convert time to a formatted string. | Param | Description | Type | | :--- | :--- | :--- | | time | The time to format | Dayjs | null | format | The format to return | string

getUnavailableTime

returns: [number] Get Unvailable hours | Param | Description | Type | | :--- | :--- | :--- | | {Unavailable Hours} | Hours that are unavailable | null

Built Using

License

Copyright © 2023 Muhammad Talha.