0.0.1 • Published 4 years ago

@impervaos/react-date-picker v0.0.1

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

Date picker widget

coverage tests

Presentation

Installation

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

DatePickerWithPresets

Import

    import DatePickerWithPresets, {DateRangePicker} from "@imperva/date-picker"; 

####Props

PropertyTypeDescriptionDefault
currentTimeStampnumberCurrent time in millisecondsnull
styleobjectstyling object that will be applied on the top wrapper of the component{}
classNamestringcss class that will be applied on the top wrapping component""
presetslistlist of names and values of predefined presets (ex. { label: 'Last 24 hours', value: 86400000 } )[]
dateFilterfunctionif you would like to limit the displayed dates with a custom functionnull
includeDatePickerbooleanshould the custom date picker be displayedtrue
calendarDaysRangearraymin and max value of days back that you allow to be displayed in the custom datepicker0, -180
selectionDaysRangearraymin and max value of days that you can select within custom datepicker
presetsPropliststate of the presets, mostly for being able to disable certain presets (ex. { value: 86400000, disabled: false }). value is the key[]
onChangefunctionfunction performed when new date is pickednull
onAnalyticsfunctionfunction that would run on any change in the component, used for google analytics reportingnull

####Code Example

    import DatePickerWithPresets from "@imperva/date-picker";
    ...
    ...
    ...

    <DatePickerWithPresets
        className={"main-date-picker"}
        includeDatePicker
        dateFilter={{ startTS: null, endTS: null, offset: 0 }}
        onChange={this._onDateChange.bind(this)}
        currentTimeStamp={new Date().getTime()}
        presets={[
          { label: 'Last 24 hours', value: 86400000 },
          { label: 'Last 7 days', value: 604800000 },
          { label: 'Last 30 days', value: 2592000000 },
          { label: 'Last 90 days', value: 7776000000 },
          { label: 'Custom', value: -1 },
        ]}
        presetsProp={[
          { value: 86400000, disabled: false },
          { value: 604800000, disabled: false },
          { value: 2592000000, disabled: false },
          { value: 7776000000, disabled: false },
        ]}
        onAnalytics={(event)=>this._onDatePickerAnalytics(event)}
    />

DateRangePicker - use only the custom picker, without the presets

Import

    import {DateRangePicker} from "@imperva/date-picker"; 

####Props

PropertyTypeDescriptionDefault
classNamestringcss class that will be applied on the top wrapping component""
dateFilterfunctionif you would like to limit the displayed dates with a custom functionnull
onApplyDateRangefunctionrun as a result of clicking applynull
onChangefunctionfunction performed when new date is pickednull
onCancelfunctionfunction performed when cancel is clickednull
closeRangeDatePickerfunctionfunction that is run upon closing or opening the pickernull
onAnalyticsfunctionfunction that would run on any change in the component, used for google analytics reportingnull
isOpenbooltrue for opening the picker, false to closenull

####Code Example

    import {DateRangePicker} from "@imperva/date-picker";
    ...
    ...
    ...

    <DateRangePicker
        className={"main-date-picker"}        
        onChange={this._onDateChange.bind(this)}
    />