DateRange picker widget for z3c.form based on Air Datepicker
Project description
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.
=======
CHANGES
=======
0.5.1 (2026-05-20)
------------------
- Fix: Inline init script bailed out on initial page parse because
the secondary widget's hidden `_to` input was rendered *after*
the primary widget's `<script>` block in document order, so
`document.getElementById(toInputId)` returned null and the
`if (!toEl) return;` guard tripped -- Air Datepicker was never
attached. Init now waits for `DOMContentLoaded` when the document
is still loading, falls back to `setTimeout(init, 0)` otherwise.
0.5.0 (2026-05-20)
------------------
- Initial release. DateRange picker widget for z3c.form wrapping
Air Datepicker v3.6.0 (MIT, Timur Borodin).
- Pair-mode wiring through `setUpDateRangePickerWidget`: two
`zope.schema.Date` fields share one picker UI, standard
z3c.form data managers write back.
- ISO-8601 (`YYYY-MM-DD`) on the wire; locale-formatted display
string driven by the standard `z3c.form` `IDate` converter.
- Vendored Air Datepicker library files in `cdn/{js,css}/` for
consumer-side resource registration. Locale files (de/en/fr/it)
rewrapped as browser IIFEs that attach to
`window.AirDatepickerLocales[lang]`.
- Optional `m01.mongo` IMongoDate adapter (zcml:condition).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
j01_daterangepicker-0.5.1.tar.gz
(37.2 kB
view details)
File details
Details for the file j01_daterangepicker-0.5.1.tar.gz.
File metadata
- Download URL: j01_daterangepicker-0.5.1.tar.gz
- Upload date:
- Size: 37.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a6e04a00585f659d936d33e0440330f184b4b131087a3eb860782dc05eada78
|
|
| MD5 |
d00b6d29a39be553891977bfb47e8ce1
|
|
| BLAKE2b-256 |
ac8482419e882be3972e75d1da284f594aed40c74d918837dd079a6d8dd4f648
|