# j01.daterangepicker

DateRange picker widget for `z3c.form`. Wraps Air Datepicker v3.6.0
(MIT, Timur Borodin).

Two normal `zope.schema.Date` fields are paired into a single
range-picker UI through the `setUpDateRangePickerWidget` factory.
Standard `z3c.form` data managers handle the write-back -- no
custom data manager required.

## Usage

```python
from j01.daterangepicker import setUpDateRangePickerWidget

class MyForm(form.Form):
    fields = field.Fields(IMySchema).select(
        'startDate', 'endDate')

    widgetFactories = {
        'startDate': setUpDateRangePickerWidget(
            'startDate', 'endDate'),
        'endDate':   setUpDateRangePickerWidget(
            'startDate', 'endDate'),
    }
```

Both factory calls use the same `fromName`/`toName` arguments;
the widget detects on its own which side it is (primary or
secondary) by comparing `field.__name__` to `fromName`.

Optional min/max constraints and custom validator:

```python
setUpDateRangePickerWidget(
    'startDate', 'endDate',
    minDate=datetime.date.today(),
    maxDate=datetime.date(2030, 12, 31),
    validator=myCustomValidator)
```

The widget exposes `validateRange(fromValue, toValue)` with an
in-built `fromValue <= toValue` check; a custom `validator` callable
is called in addition. Wire the check into the consumer's action
handler after `extractData()`.

## Vendor library

Air Datepicker v3.6.0 files are vendored under `cdn/js/` and
`cdn/css/`. See `LICENSE.txt` for the upstream MIT licence text.
The locale files in `cdn/js/air-datepicker.locale.<lang>.js` are
hand-rewrapped from the upstream CJS modules into browser-IIFE form
so they can be loaded via a regular `<script>` tag without a
bundler; the locale data itself is verbatim from upstream.
