0.1.8 • Published 2 years ago

simple-react-month-picker v0.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Simple React Month Picker

Simple-React-Month-Picker Component offers a popup month selection panel with the option of presets or custom month ranges.

Installation

npm install simple-react-month-picker --save

Snapshots

Customisable preset options list:

Preset options

Custom range selection:

Custom months

Configuration

The most basic use:

<MonthPicker onChange={handleChange} />

Props

proptypedescription
onChangefuncFunction invoked when start and end dates have been selected, it will be passed an array with the start and end dates: [startDate, endDate]
presetsarrayArray of objects to use as presets: [{title: "preset title", start: startDate, end: endDate}]
closeDelayintDelay in ms before pop-up window closes
valuearrayStarting dates: [startDate, endDate]
highlightColstringColour of selected months

Usage Example

Online demo

https://codesandbox.io/s/simple-react-month-picker-p9uhe

Code sample

import MonthPicker from "simple-react-month-picker";
import moment from "moment";

function App() {
  return (
    <div>
      <MonthPicker
        style={{ width: 300, margin: "50px auto" }}
        presets={[
          {
            title: "This month",
            start: moment().startOf("month").toDate(),
            end: moment().endOf("month").toDate(),
          },
          {
            title: "Past 3 months",
            start: moment().subtract(2, "month").startOf("month").toDate(),
            end: moment().endOf("month").toDate(),
          },
          {
            title: "Past 6 months",
            start: moment().subtract(5, "month").startOf("month").toDate(),
            end: moment().endOf("month").toDate(),
          },
          {
            title: "Past Year",
            start: moment().subtract(12, "month").startOf("month").toDate(),
            end: moment().endOf("month").toDate(),
          },
          {
            title: "All time",
            start: null,
            end: null,
          },
        ]}
        onChange={(range) => console.log(range)}
        closeDelay={500}
      />
    </div>
  );
}

export default App;
0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago