Fragiola

API: components

YearPicker

A trigger and a non-modal popup holding a bound YearCalendar: one year, submitted as 2026.

A trigger and a non-modal popup holding a YearCalendar: the DatePicker's trigger, popup, form and Field, with a year as its value. Its parts are the DatePicker's, named year-picker-*; the YearCalendar 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.

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 a year 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 year=2026, 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-picker-triggertoggles the popup, and anchors it
Portalnonemoves the Positioner to the end of body
Positionerdivyear-picker-positionerplaces the popup next to the trigger
Popupdivyear-picker-popupthe non-modal dialog, holding a YearCalendar.Root
(hidden input)inputyear-picker-inputwhat the form submits

Usage

import { YearPicker, type PlainYear } from "@fragiola/primitives-react/year-picker";
import { YearCalendar } from "@fragiola/primitives-react/year-calendar";

<YearPicker.Root value={value} onValueChange={setValue} name="year">
    <YearPicker.Trigger>{/* the formatted value */}</YearPicker.Trigger>
    <YearPicker.Portal>
        <YearPicker.Positioner>
            <YearPicker.Popup aria-label="Choose year">
                <YearCalendar.Root>{/* its header and grid */}</YearCalendar.Root>
            </YearPicker.Popup>
        </YearPicker.Positioner>
    </YearPicker.Portal>
</YearPicker.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
valuePlainYear | nullthe chosen year, controlled
defaultValuePlainYear | nullnullthe initial year, uncontrolled
onValueChange(value: PlainYear | 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-picker-*; the hidden input's value is the ISO text (year=2026).

Keyboard

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

Exports

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