Skip to main content

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.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


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.0.tar.gz (36.5 kB view details)

Uploaded Source

File details

Details for the file j01_daterangepicker-0.5.0.tar.gz.

File metadata

  • Download URL: j01_daterangepicker-0.5.0.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for j01_daterangepicker-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8b5877058335edbdd1433c741b798e2b17c9d89273c353201664b0e6ca24c186
MD5 1ecae400a7b6a700ae8f8e45d74253af
BLAKE2b-256 57112459ee5d3cf8047a805496900c9861bf4de9422be5736d86a169d12217ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page