0.9.6 • Published 2 years ago

@zenequityui/date-picker v0.9.6

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

Installation

To install a component run

$ npm install @zenequityui/date-picker --save

Please import CSS styles via

@import '/path__to__node_modules/@zenequityui/date-picker/dist/index.min.css

Usage

Single Date Selector

import { DatePicker } from '@zenequityui/date-picker';
const moment = require('moment');
initialState = {
  selectedDate: moment(new Date()),
};

<DatePicker
  onChange={(value) => {
    setState({
      selectedDate: value,
    });
  }}
  renderInput={() => (
    !state.selectedDate ? <span>Start Date</span> : state.selectedDate
  )}
  value={{
    startMoment: state.selectedDate,
  }}
  htmlAttributes={{
    isOutsideRange: () => false,
  }}
/>

Future Date Disabled

import { DatePicker } from '@zenequityui/date-picker';
const moment = require('moment');
initialState = {
  selectedDate: moment(new Date()),
};

<DatePicker
  onChange={(value) => {
    setState({
      selectedDate: value,
    });
  }}
  renderInput={() => (
    !state.selectedDate ? <span>Start Date</span> : state.selectedDate
  )}
  value={{
    startMoment: state.selectedDate,
  }}
  htmlAttributes={{
    isOutsideRange: (day) => (day.isAfter(moment(), 'days')),
  }}
/>

Past Date Disabled

import { DatePicker } from '@zenequityui/date-picker';
const moment = require('moment');
initialState = {
  selectedDate: moment(new Date()),
};

<DatePicker
  onChange={(value) => {
    setState({
      selectedDate: value,
    });
  }}
  renderInput={() => (
    !state.selectedDate ? <span>Start Date</span> : state.selectedDate
  )}
  value={{
    startMoment: state.selectedDate,
  }}
  htmlAttributes={{
    isOutsideRange: (day) => (day.isBefore(moment(), 'days')),
  }}
/>

Empty Date Selector

import { DatePicker } from '@zenequityui/date-picker';
const moment = require('moment');
initialState = {
  selectedDate: '',
};

<DatePicker
  onChange={(value) => {
    setState({
      selectedDate: value,
    });
  }}
  renderInput={() => (
    !state.selectedDate ? <span>Start Date</span> : state.selectedDate
  )}
  value={{
    startMoment: state.selectedDate,
  }}
  htmlAttributes={{
    isOutsideRange: () => false,
  }}
/>

Range Date Selector

import { DatePicker } from '@zenequityui/date-picker';
const moment = require('moment');
initialState = {
  startDate: moment(new Date()),
  endDate: moment(new Date()),
};

<div style={{ display: 'flex', justifyContent: 'space-around' }}>
  <div style={{ width: '100%', marginRight: '10px' }}>
    <DatePicker
      onChange={(value) => {
        const updatedEndDate = !state.endDate || moment(state.endDate).isBefore(moment(value), 'days') ? value : null;

        setState({
          startDate: value,
          ...(updatedEndDate ? { endDate: updatedEndDate } : {}),
        });
      }}
      isDayBlocked={(day) => (day.isBefore(moment(), 'days'))}
      renderInput={() => (
        !state.startDate ? <span>Start Date</span> : state.startDate
      )}
      value={{
        startMoment: state.startDate,
      }}
    />
  </div>

  <div style={{ width: '100%', marginLeft: '10px' }}>
    <DatePicker
      onChange={(value) => {
        setState({
          endDate: value,
        });
      }}
      isDayBlocked={(day) => (
        day.isBefore(state.startDate ? moment(state.startDate) : moment(), 'days')
      )}
      renderInput={() => (
        !state.endDate ? <span>End Date</span> : state.endDate
      )}
      value={{
        startMoment: state.endDate,
      }}
    />
  </div>
</div>
0.8.9

3 years ago

0.8.8

3 years ago

0.8.5

3 years ago

0.8.4

3 years ago

0.8.7

3 years ago

0.8.6

3 years ago

0.9.0

3 years ago

0.7.2

3 years ago

0.9.2

3 years ago

0.7.4

3 years ago

0.9.1

3 years ago

0.7.3

3 years ago

0.7.9

3 years ago

0.9.4

3 years ago

0.7.6

3 years ago

0.9.3

3 years ago

0.7.5

3 years ago

0.9.6

2 years ago

0.7.8

3 years ago

0.9.5

3 years ago

0.7.7

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.6.7

3 years ago

0.6.6

3 years ago

0.6.9

3 years ago

0.6.8

3 years ago

0.6.3

3 years ago

0.7.1

3 years ago

0.6.2

3 years ago

0.6.5

3 years ago

0.7.0

3 years ago

0.6.0

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.10

4 years ago

0.4.7

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.4.0

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago