Fragiola

API: components

YearRangePicker

A trigger and a non-modal popup holding a bound YearRangeCalendar: a range of years, submitted as 2020/2024.

A trigger and a non-modal popup holding a YearRangeCalendar: the DatePicker's trigger, popup, form and Field, with a range of years as its value. Its parts are the DatePicker's, named year-range-picker-*; the YearRangeCalendar inside the Popup has no value of its own and binds to the picker. The popup is a non-modal APG dialog disclosed by a button, as the DatePicker's. It renders no text: the trigger's content and the popup's name are yours.

Year range filter
Gallery

Behaviour

  • Open, choose, close: as the DatePicker's: the calendar focuses its focused year as the popup opens (the value, else the year holding today); choosing the range's end sets the value, closes the popup (reason item-press) and focuses the Trigger; Escape, an outside press and Tab out close it; focus is not trapped.
  • Forms: with a name, the Root renders a hidden input after its children, which submits the ISO interval years=2020/2024, or an empty value. required, disabled, readOnly, a form reset and a Field work as the DatePicker's.

Anatomy

partelementdata-primitives-partrole
Rootnoneholds the value and the open state
Triggerbuttonyear-range-picker-triggertoggles the popup, and anchors it
Portalnonemoves the Positioner to the end of body
Positionerdivyear-range-picker-positionerplaces the popup next to the trigger
Popupdivyear-range-picker-popupthe non-modal dialog, holding a YearRangeCalendar.Root
(hidden input)inputyear-range-picker-inputwhat the form submits

Usage

import { YearRangePicker, type YearRange } from "@fragiola/primitives-react/year-range-picker";
import { YearRangeCalendar } from "@fragiola/primitives-react/year-range-calendar";

<YearRangePicker.Root value={value} onValueChange={setValue} name="year">
    <YearRangePicker.Trigger>{/* the formatted value */}</YearRangePicker.Trigger>
    <YearRangePicker.Portal>
        <YearRangePicker.Positioner>
            <YearRangePicker.Popup aria-label="Choose years">
                <YearRangeCalendar.Root>{/* its header and grid */}</YearRangeCalendar.Root>
            </YearRangePicker.Popup>
        </YearRangePicker.Positioner>
    </YearRangePicker.Portal>
</YearRangePicker.Root>;

Props

Every part also takes what the primitive contract gives. Vue binds v-model:value and v-model:open; Angular [(value)], [(open)], (valueChangeDetails), (openChangeDetails). The other parts' props are the DatePicker's.

Root

proptypedefaultdescription
valueYearRange | nullthe chosen range, controlled
defaultValueYearRange | nullnullthe initial range, uncontrolled
onValueChange(value: YearRange | null, details: { reason }) => voidevery choice (reason item-press), a form reset (none)
openbooleanthe open state, controlled
defaultOpenbooleanfalsethe initial open state, uncontrolled
onOpenChange(open: boolean, details: OpenChangeDetails) => voidevery change, with its reason; called before the change, details.cancel() stops it
onOpenChangeComplete(open: boolean) => voidonce an opening or a closing has finished its transitions
actionsRef (react){ current: OverlayActions | null }receives close() and unmount(); Vue exposes them on the Root's template ref, Angular as the root directive's methods
minPlainYear | nullpassed to the bound calendar
maxPlainYear | nullpassed to the bound calendar
isUnavailable(year: PlainYear) => booleanpassed to the bound calendar
localestringthe document's langpassed to the bound calendar
calendarCalendarSystemthe ISO calendara calendar system, passed to the bound calendar: the values are its years, submitted as the first day's ISO date with the system (2026-10-23[u-ca=persian])
columnsnumber3passed to the bound calendar
namestringthe hidden input's form name (a Field's wins)
requiredbooleanfalsea native form's validation blocks a submission with no value
disabledbooleanfalsethe Trigger cannot open the popup; nothing is submitted
readOnlybooleanfalsethe popup still opens; its calendar chooses nothing

Trigger

No props of its own.

Portal

proptypedefaultdescription
container (react, vue)Elementdocument.bodywhere the Positioner goes
keepMounted (react, vue)booleanfalsekeep the content rendered while closed (before the first opening and after an exit), hidden and data-closed; reopening shows the same elements
options (angular)Element | { container?, keepMounted? }{}the same two options: *datePickerPortal="{ keepMounted: true }", or *datePickerPortal="element" for a container alone

Positioner

proptypedefaultdescription
side"top" | "bottom" | "inline-start" | "inline-end" | "left" | "right""bottom"the side of the trigger
align"start" | "center" | "end""start"the alignment along that side
sideOffsetnumber0the distance from the trigger, in px
alignOffsetnumber0the shift along its edge, in px
collisionPaddingnumber8the space kept from the viewport's edges, in px
anchorElementthe triggerthe element to place the popup next to

No props of its own.

State and part attributes

The DatePicker's, named year-range-picker-*; the hidden input's value is the ISO text (the ISO interval years=2020/2024).

Keyboard

The DatePicker's, with the YearRangeCalendar's keys in the popup.

Exports

entryexports
@fragiola/primitives-react/year-range-pickerAlign, ChangeDetails, ChangeReason, DatePicker, DatePickerPopupProps, DatePickerPopupState, DatePickerPortalProps, DatePickerPositionerProps, DatePickerPositionerState, DatePickerTriggerProps, DatePickerTriggerState, MonthPickerRootSharedProps, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootProps, PlainYear, PositionerProps, RenderProp, Side, YearRange, YearRangePicker, YearRangePickerRootProps
@fragiola/primitives-vue/year-range-pickerAlign, ChangeDetails, ChangeReason, DatePicker, DatePickerPopupProps, DatePickerPopupState, DatePickerPortalProps, DatePickerPositionerState, DatePickerTriggerProps, DatePickerTriggerState, MonthPickerRootSharedProps, OpenChangeDetails, OverlayActions, OverlayPortalProps, OverlayRootEmits, OverlayRootProps, PlainYear, PositionerProps, RenderSlotProps, Side, YearRange, YearRangePicker, YearRangePickerRootEmits, YearRangePickerRootProps
@fragiola/primitives-angular/year-range-pickerChangeDetails, ChangeReason, DatePickerPopup, DatePickerPopupState, DatePickerPortal, DatePickerPositioner, DatePickerPositionerState, DatePickerTrigger, DatePickerTriggerState, OpenChangeDetails, OpenChangeEvent, OverlayActions, PlainYear, PlainYearMonth, ValueChangeEvent, YearMonthRange, YearRange, YearRangePickerRoot