Git Product home page Git Product logo

react-calendar-datetime-picker's Introduction

react-calendar-datetime-picker

The Simple and fast English and Persian calender for React

version: "1.7.4" NPM JavaScript Style Guide

⚙️ Install

npm install react-calendar-datetime-picker
or
yarn add react-calendar-datetime-picker

⚡️ Usage

import { DtPicker } from 'react-calendar-datetime-picker'
import 'react-calendar-datetime-picker/dist/style.css'

const App = () => {
  const [date, setDate] = useState(null)
  return <DtPicker onChange={setDate} />
}

📄 Documentation

Documentation with examples

🎯 Features

  • Supports Gregorian and Jalali calender
  • Uses context api to share data
  • Supports three types of calender: single day - date range - multiple dates
  • Fully customizable
  • Supports maximum and minimum dates
  • Capability to add a list of disabled dates
  • Supports time for single and range type
  • Capability to mark weekends
  • Function called for change, open and close events
  • Supports Typescript


🔧 Props

Property Type Required Default Description
onChange func true - A function that returns an object of selected date/dates.
initValue Day null null
type string single You can choose the selection type that you need to use. There exist 3 types: "single", "range", "multi"
local string en This date picker supports both Gregorian and Jalali calenders.To select Gregorian calendar you have to set "local" to "en" and to "fa" for Jalali.
withTime boolean false Should you need to use time in your date picker you can set this prop to true.This prop works only in single and range types.
showTimeInput boolean false Helps you to show time in input date picker
showWeekend boolean false Marks weekends by changing the color.
clearBtn boolean false Add a button to your input to clear you calendar initial date/dates.
isRequired boolean false This prop makes your input as a required field in the form validation
todayBtn boolean false A button to move fast to the date of today in the calendar.
onCalenderChange func A callback that runs when the calendar value is changed
onCalenderShow func A callback that runs when the calendar opens
onCalenderHide func A callback that runs when the calendar closes
maxDate Day You can set this prop to limit the maximum date that the user can select.Periods partially overlapped by maxDate will also be selectable, although React-calendar-dateTime-picker will ensure that no later date is selected.
minDate Day You can set this prop to limit the minimum date that the user can select. Periods partially overlapped by minDate will also be selectable, although React-calendar-dateTime-picker will ensure that no earlier date is selected.
disabledDates Day[] A list of dates that you want the user not to select.
isDisabled boolean false Use to disable the calendar input
yearListStyle string grid Use to change year item list style(accepted value: grid, list)

🎨 Customization

Property Type Default Description
placeholder string "select" To change input date picker placeholder
inputClass string To change calendar's input style
clearBtnClass string To change calendar's clear button style
calenderModalClass string To change calendar's main modal style
headerClass string To change calendar's green header style
timeClass string To change calendar's time view style
daysClass string To change calendar's days view style
monthsClass string To change calendar's months view style
yearsClass string To change calendar's years view style
NextBtnIcon svg as component ">" To change next month button icon.
PreviousBtnIcon svg as component "<" To change previous month button icon.
nextMonthBtnTitle string "next" To change next month button title(shows by hover).
previousMonthBtnTitle string "previous" To change previous month button title(shows by hover).
fromLabel string "from" Starting date label in input result(works only in range type).
toLabel string "to" Ending date label in input result(works only in range type).
clockFromLabel string "from" Title for starting time in the time component(works only in range type).
clockToLabel string "to" Title for ending time in the time component(works only in range type).
clockLabel string "clock" Label for time in the time component(works in single and range type).



✔️ bundle size

You can check out this package bundle size in this Link

🙇 Special Thanks

Thanks to jalaali-js, the only dependency of this date picker.

📋 License

MIT © mehdinasiri

react-calendar-datetime-picker's People

Contributors

mmehdinasiri avatar mohammadizanloo55 avatar omidrafiee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-calendar-datetime-picker's Issues

Vanilla JS

Hi,
Is there any version of this library that does not have the ReactJS dependency? (Just use vanilla Js)

If not:
1- Do you have a plan to do this?
2- Do you have a vanilla date range picker that does not any dependency (like jquery or react and etc)? (another library)

Thanks.

maxDate and minDate are not updated if used with a React State

Hey, I got a component with two DatePickers (with time)
My idea is to set into the second picker a maxDate with the selected date on the first picker.
I tried using a state, but it seems like the second picker is not receiving the state value once I update it through the first picker onChange.

Any workarounds?

Expose value prop

Use Case -
When I want to show date range in format like "Nov 18, 22 - Nov 30, 22", I'm stuck default format is very verbose & does not offer best UI for most use cases.

Suggested solutions-

  1. expose value prop that can be passed to DtPicker, that will be further passed down to tag.
  2. expose a formatValue function, date or date range will be formatted using this function. Specifically this will requires passing correctValue function here as prop.

@mmehdinasiri Let me know your thoughts on this, I think we should go with 2. I'll do a PR after your approval.

PS: using this in production, so 🤞

Regards,
Atul Yadav

feature request : add an prop to DtPicker component to assign id to input

hi, thanks for creating this awesome date picker component I need a feature Which I will explain below:

I use reactstrap label component and I want to assign a label to the Date picker input but can't because the component doesn't have any prop to assign an id to input
example:

import { useState } from "react";
import DtPicker from "react-calendar-datetime-picker";
import { Col, Form, Label, Row } from "reactstrap";

function Test() {
    const [date, setDate] = useState(null);

    return (
        <Form>
            <Row>
                <Col className="mb-1" md="6" sm="12">
                    <Label for="example-input"> example </Label>
                    <DtPicker onChange={setDate} inputId="example-input" />
                </Col>
            </Row>
        </Form>
    );
}

If you can not take the time to add this feature and you are busy I will try to add this feature just please let me know so I know you do not have time to do this

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.