4.5.5 • Published 2 months ago

@availity/reactstrap-validation-date v4.5.5

Weekly downloads
52
License
MIT
Repository
github
Last release
2 months ago

@availity/reactstrap-validation-date

Wrapper for react-date-range to work with availity-reactstrap-validation.

Installation

npm install @availity/reactstrap-validation-date availity-reactstrap-validation reactstrap react --save

Usage

import React from 'react';
import { Label } from 'reactstrap';
import { AvForm, AvGroup, AvFeedback } from 'availity-reactstrap-validation';
import AvDate, { AvDateField, AvDateRange, AvDateRangeField } from '@availity/reactstrap-validation-date';
import '@availity/reactstrap-validation-date/styles.scss';
// ...
<AvForm>
    <AvGroup>
        <Label for="justTheDate">My Input Label</Label>
        <AvDate name="justTheDate" required />
        <AvFeedback>Some error message</AvFeedback>
    </AvGroup>

    <AvDateField
        name="fieldWithLabel"
        label="Label Made For Me"
        required
    />

    <AvGroup>
        <Label for="justTheDateRange">My Input Label</Label>
        <AvDateRange name="justTheDateRange" required />
        <AvFeedback>Some error message</AvFeedback>
    </AvGroup>

    <AvDateField
        name="DateRangeWithLabel"
        label="Label Made For Me"
        required
    />
</AvForm>;

Note: the input callbacks (e.g. onChange) do not get called with an event like other reactstrap-validation component; just the value of the field. This is because the underlying date picker does not return the event in it's callbacks.

AvDate (Default export)

This is the underlying date without the AvGroup, Label or AvFeedback

AvDate Props

See availity-reactstrap-validation for additional props, such as name, validate, min, max, and more.

  • datepicker: Boolean. Optional. Default: true. If true, the date picker button will be shown, clicking it activates the datepicker calendar. If false, only the date input field will be displayed (useful for date of birth fields).

AvDate Example usage

import React from 'react';
import { Label } from 'reactstrap';
import { AvForm, AvGroup, AvFeedback } from 'availity-reactstrap-validation';
import AvDate from '@availity/reactstrap-validation-date';
// ...
<AvForm>
    <AvGroup>
        <Label for="justFieldAndPicker">My Input Label</Label>
        <AvDate
            name="justFieldAndPicker"
            required
        />
        <AvFeedback>Some error message</AvFeedback>
    </AvGroup>
</AvForm>;

AvDateField

Like AvField, but for dates with a date picker

AvDateField Props

See availity-reactstrap-validation for additional props, such as name, validate, min, max, and more.

  • datepicker: Boolean. Optional. Default: true. If true, the date picker button will be shown, clicking it activates the datepicker calendar. If false, only the date input field will be displayed (useful for date of birth fields).

AvDateField Example usage

import React from 'react';
import { AvDateField } from '@availity/reactstrap-validation-date';
// ...
<AvForm>
    <AvDateField
        name="fieldWithLabel"
        label="Label Made For Me"
        required
    />
</AvForm>;

AvDateRange

A date range, consists of 2 fields, a start date and an end date. This is the underlying date-range without the AvGroup, Label or AvFeedback.

AvDateRange Props

See availity-reactstrap-validation for additional props, such as name, validate, min, max, and more.

  • ranges: Object or Array. Optional. Default: ['Last 7 Days','Last 30 Days','Last Calendar Month','Last 120 Days','Last 6 Months','Last 12 Months']. Controls the preset range options which allows the user to easily select predefined ranges. If an array, the array must be a subset of the default array, any string not in the array will be omitted. If an object, the keys will be the display text and the value will be an object containing startDate and endDate function which will be called with the current date moment object and are expected to return the start and end dates respectfully.
  • start: Object. Required. and object which will be spread on the start date input. It must contain the name prop as required by availity-reactstrap-validation. It can contain additional validations as well.
  • end: Object. Required. and object which will be spread on the end date input. It must contain the name prop as required by availity-reactstrap-validation. It can contain additional validations as well.
  • distance: Object. Optional. Object containing the min and max distance the start and end dates are allowed to be apart from each other. See example below.

AvDateRange Example usage

import React from 'react';
import AvApi from '@availity/api-axios';
import { AvResourceDate } from '@availity/reactstrap-validation-date';
import '@availity/reactstrap-validation-date/styles.scss';
// ...
const avCustomResource = new AvApi({ name: 'my-custom-resource' });
// ...
<AvForm>
    <AvDateRange
        start={{name: 'date.start'}}
        end={{name: 'date.end'}}
        resource={avCustomResource}
        distance={{
            min: {
                value: 3,
                units: 'days'
            },
            max: {
                value: 1,
                units: 'month'
            }
        }}
        ranges={{
            'Last 10 Days': {
                startDate: now => now.add(-9, 'd'),
                endDate: now => now,
            },
            'Last 20 Days': {
                startDate: now => now.add(-19, 'd'),
                endDate: now => now,
            },
            'Tomorrow': {
                startDate: now => now.add(1, 'd'),
                endDate: now => now.add(1, 'd'),
            },
        }}
        required
    />
</AvForm>;

AvDateRangeField

Like AvField, but for a date range with a date range picker

AvDateRangeField Props

See availity-reactstrap-validation for additional props, such as name, label, validate, min, max, and more.

  • ranges: Object or Array. Optional. Default: ['Last 7 Days','Last 30 Days','Last Calendar Month','Last 120 Days','Last 6 Months','Last 12 Months']. Controls the preset range options which allows the user to easily select predefined ranges. If an array, the array must be a subset of the default array, any string not in the array will be omitted. If an object, the keys will be the display text and the value will be an object containing startDate and endDate function which will be called with the current date moment object and are expected to return the start and end dates respectfully.
  • start: Object. Required. and object which will be spread on the start date input. It must contain the name prop as required by availity-reactstrap-validation. It can contain additional validations as well.
  • end: Object. Required. and object which will be spread on the end date input. It must contain the name prop as required by availity-reactstrap-validation. It can contain additional validations as well.
  • distance: Object. Optional. Object containing the min and max distance the start and end dates are allowed to be apart from each other. See example below.

AvDateRangeField Example usage

import React from 'react';
import AvApi from '@availity/api-axios';
import { AvResourceDate } from '@availity/reactstrap-validation-date';
import '@availity/reactstrap-validation-date/styles.scss';
// ...
const avCustomResource = new AvApi({ name: 'my-custom-resource' });
// ...
<AvForm>
    <AvDateRange
        label="Dates of Service"
        start={{name: 'date.start'}}
        end={{name: 'date.end'}}
        resource={avCustomResource}
        distance={{
            min: {
                value: 3,
                units: 'days'
            },
            max: {
                value: 1,
                units: 'month'
            }
        }}
        ranges={{
            'Last 10 Days': {
                startDate: now => now.add(-9, 'd'),
                endDate: now => now,
            },
            'Last 20 Days': {
                startDate: now => now.add(-19, 'd'),
                endDate: now => now,
            }
        }}
        required
    />
</AvForm>;
4.5.5

2 months ago

4.5.4

7 months ago

4.5.3

8 months ago

4.5.2

1 year ago

4.5.1

1 year ago

4.5.0

2 years ago

4.4.1

2 years ago

4.4.0

2 years ago

4.3.4

2 years ago

4.3.3

2 years ago

4.3.2

2 years ago

4.3.1

2 years ago

4.3.0

2 years ago

4.2.3

2 years ago

4.2.2

2 years ago

4.2.5

2 years ago

4.2.4

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.1.5-ts.15

2 years ago

4.1.4

3 years ago

4.1.5

2 years ago

4.1.3

3 years ago

4.1.2

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.3

3 years ago

4.0.2

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

3.1.7-alpha.99

4 years ago

3.1.7-alpha.96

4 years ago

3.1.7-alpha.95

4 years ago

3.1.7-alpha.93

4 years ago

3.1.7-alpha.91

4 years ago

3.1.7-alpha.88

4 years ago

3.1.7-alpha.85

4 years ago

3.2.22

4 years ago

3.2.20

4 years ago

3.2.21

4 years ago

3.2.19

4 years ago

3.2.18

4 years ago

3.2.17

4 years ago

3.2.15

4 years ago

3.2.16

4 years ago

3.2.14

4 years ago

3.2.13

4 years ago

3.2.12

4 years ago

3.2.10

4 years ago

3.2.9

4 years ago

3.2.8

4 years ago

3.2.7

4 years ago

3.2.6

4 years ago

3.2.5

4 years ago

3.2.4

4 years ago

3.2.3-alpha.5

4 years ago

3.2.3

4 years ago

3.2.2

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.9

4 years ago

3.1.8

4 years ago

3.1.7

4 years ago

3.1.7-alpha.60

4 years ago

3.1.7-alpha.59

4 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.6-alpha.16

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.1-alpha.3

5 years ago

3.0.0

5 years ago

3.0.0-alpha.30

5 years ago

3.0.0-alpha.29

5 years ago

3.0.0-alpha.25

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.7.12

5 years ago

1.7.11

5 years ago

1.7.10

5 years ago

1.7.9

5 years ago

1.7.8

5 years ago

1.7.8-alpha.5

5 years ago

1.7.8-alpha.4

5 years ago

1.7.7

5 years ago

1.7.6

5 years ago

1.7.5

5 years ago

1.7.4

5 years ago

1.7.3

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

0.0.0-t325224b2

5 years ago

1.6.0

5 years ago

1.5.0

6 years ago

1.4.0

6 years ago