Giter Club home page Giter Club logo

material-ui-multiple-dates-picker's Introduction

Material-UI Multiple Dates Picker

npm version

Lets user pick more than one date from the date picker.

Motivation

This is a fork of react-multiple-datepicker. I needed a date picker that is built on Material-UI and supports multiple dates selections, couldn't find one, so here it is!

Features

  • Based on Material-UI components with Dialog component being the root of it
  • Choose dates right from the calendar
  • See all selected dates on the list
  • Click on any selected date to remove it (either on calendar or on the list)
  • Customize button labels and titles
  • Its appearance is based on your configuration of Material-UI theme

Installation

To install the component run this command:

npm i -S @randex/material-ui-multiple-dates-picker

Usage example

import MultipleDatesPicker from '@randex/material-ui-multiple-dates-picker'

const Example = () => {
  const [open, setOpen] = useState(false)

  return (
    <div>
      <Button onClick={() => setOpen(!open)}>
        Select Dates
      </Button>
      <MultipleDatesPicker
        open={open}
        selectedDates={[]}
        onCancel={() => setOpen(false)}
        onSubmit={dates => console.log('selected dates', dates)}
      />
    </div>
  )
}

API

MultipleDatesPicker (default export)

Prop Name Type Default Description
open bool, required `false Is Date Picker Dialog open or not
selectedDates Array of Date [] MultipleDatesPicker uses its own internal array of selected date and sends it only when user clicks Submit button. But you can still use this variable to pass initial value to it โ€” array will be copied.
onCancel func, required null Fires when user clicks Cancel button. You need to handle closing the picker when this handler fires.
onSubmit func, required null Fires when user clicks Submit button with only one parameter: array of selected Dates: onSubmit(selectedDates). You need to handle closing the picker when this handler fires.
readOnly bool false Is Date Picker interactive. Use this if you just want to display dates to the user. Submit button will be hidden and onCancel will be fired when user presses "Dismiss" button.
cancelButtonText string if readOnly then "Dismiss" is not then "Cancel" Cancel button title
submitButtonText string Submit Submit button title
selectedDatesTitle string Selected Dates Selected dates list header title

To-Do

  • Add locale support

Contributing

I don't have enough time to maintain this library, so pull requests will be greatly appreciated!

  1. Clone the repository: git clone https://github.com/randex/material-ui-multiple-dates-picker.git
  2. Get inside the folder: cd material-ui-multiple-dates-picker
  3. Install all the general dependencies: npm i
  4. Get inside the app folder: cd app
  5. Install all dependencies needed to launch the demo app: npm i
  6. Run npm start to launch the demo app.
  7. Library is located under app/src/lib. Edit the code and watch the changes in the browser.

Happy coding and thank you for your help!

material-ui-multiple-dates-picker's People

Watchers

 avatar

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.