生态产品多个设计器现已发布候选版本

查看生态总览
Skip to content

CalendarPicker ​

Data entry component. This page is the API reference, generated from the source code. Usage guidance and live examples are on the Chinese page.

Anatomy ​

Parts in bold are required.

data-scope="calendar-picker": root · header · prev-year-trigger · prev-trigger · next-trigger · next-year-trigger · heading · heading-year-trigger · heading-month-trigger · grid · grid-head · week-day · grid-body · week-row · week-number · cell · cell-trigger

API reference ​

Descriptions of individual props, events and slots are written in Chinese and appear on the Chinese page.

Artifacts ​

LayerValue
Custom element<xh-calendar-picker>
Vue componentsXhCalendarPickerCell XhCalendarPickerCellTrigger XhCalendarPickerGrid XhCalendarPickerGridBody XhCalendarPickerGridHead XhCalendarPickerHeader XhCalendarPickerHeading XhCalendarPickerHeadingMonthTrigger XhCalendarPickerHeadingYearTrigger XhCalendarPickerNextTrigger XhCalendarPickerNextYearTrigger XhCalendarPickerPrevTrigger XhCalendarPickerPrevYearTrigger XhCalendarPickerRoot XhCalendarPickerWeekDay XhCalendarPickerWeekNumber XhCalendarPickerWeekRow
ComposableuseCalendarPicker
State machinecalendarPickerMachine
Skin@xihan-ui/styles/calendar-picker.css

Events ​

Custom elements put the payload in detail; Vue emits an event of the same name.

EventPayload
value-changeCalendarPickerValueChangeDetails
focused-value-changeCalendarFocusChangeDetails
active-view-changeCalendarViewChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhCalendarPickerRootdefaultCalendarPickerRootSlotProps

React adapter props ​

Only the props each component declares itself: DOM attributes inherited from ComponentPropsWithRef are left out, and root props already listed in the Props table are not repeated. The Vue counterpart is the slot table above.

React componentPropTypeRequired
XhCalendarPickerCellvaluestringYes
XhCalendarPickerCellindexnumber
XhCalendarPickerGridindexnumber
XhCalendarPickerHeadingindexnumber
XhCalendarPickerHeadingMonthTriggerindexnumber
XhCalendarPickerHeadingYearTriggerindexnumber
XhCalendarPickerRootvaluestring | string[]
XhCalendarPickerRootdefaultValuestring | string[]
XhCalendarPickerRootselectionModeCalendarPickerSelectionMode
XhCalendarPickerRootmaxSelectednumber
XhCalendarPickerRootfocusedValuestring
XhCalendarPickerRootdefaultFocusedValuestring
XhCalendarPickerRootminstring
XhCalendarPickerRootmaxstring
XhCalendarPickerRootisDateUnavailable(value: string) => boolean
XhCalendarPickerRootinvalidboolean
XhCalendarPickerRootlocalestring
XhCalendarPickerRootfirstDayOfWeeknumber
XhCalendarPickerRoottimeZonestring
XhCalendarPickerRootdisabledboolean
XhCalendarPickerRootreadOnlyboolean
XhCalendarPickerRootweekdayFormatCalendarWeekdayFormat
XhCalendarPickerRootfixedWeeksboolean
XhCalendarPickerRootgranularityCalendarGranularity
XhCalendarPickerRootactiveViewCalendarView
XhCalendarPickerRootdefaultActiveViewCalendarView
XhCalendarPickerRootvisibleCountnumber
XhCalendarPickerRoottranslationsPartial<CalendarPickerTranslations>
XhCalendarPickerRootonValueChangeCalendarPickerProps['onValueChange']
XhCalendarPickerRootonFocusedValueChangeCalendarPickerProps['onFocusedValueChange']
XhCalendarPickerRootonActiveViewChangeCalendarPickerProps['onActiveViewChange']
XhCalendarPickerRootchildrenSlotChildren<CalendarPickerRootSlotProps>
XhCalendarPickerWeekDayvaluenumber | stringYes
XhCalendarPickerWeekNumbervaluestringYes

State ​

The following names are internal to the state machine.

States: idle

Events: PRESS.START · PRESS.END

Guards: canPress

connect API ​

getXxxProps() returns the host attributes of the matching part.

MemberType
selectionModeCalendarPickerSelectionMode
maxSelectednumber | null

Accessibility ​

Keyboard ​

Specification: W3C APG. Each row is a stable behavior id that the conformance tests cover; the conditions and effects are described on the Chinese page.

KeysBehavior
Tab / Shift+Tabcalendar-picker.kbd.tab
ArrowLeftcalendar-picker.kbd.prev-day
ArrowRightcalendar-picker.kbd.next-day
ArrowUpcalendar-picker.kbd.prev-week
ArrowDowncalendar-picker.kbd.next-week
Homecalendar-picker.kbd.week-start
Endcalendar-picker.kbd.week-end
PageUpcalendar-picker.kbd.prev-month
PageDowncalendar-picker.kbd.next-month
Shift+PageUpcalendar-picker.kbd.prev-year
Shift+PageDowncalendar-picker.kbd.next-year
Enter / Spacecalendar-picker.kbd.select
Enter / Spacecalendar-picker.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
prev-year-triggeraria-labeltranslations.prevYearTrigger(view)
prev-triggeraria-labeltranslations.prevTrigger(view)
next-triggeraria-labeltranslations.nextTrigger(view)
next-year-triggeraria-labeltranslations.nextYearTrigger(view)
gridaria-disabled'true' | 'false'
gridaria-labelledbyframe.headingId(panel.index)
gridaria-multiselectable'true' | 'false'
gridaria-readonly'true' | 'false'
gridrole'grid'
grid-headrole'rowgroup'
week-dayaria-labelmeta?.long
week-dayrole'columnheader'
grid-bodyrole'rowgroup'
week-rowrole'row'
week-numberaria-hidden'true'
week-numberrole'rowheader'
cellaria-selected'true' | 'false'
cellrole'gridcell'
cell-triggeraria-disabled'true' | 'false'
cell-triggeraria-labelframe.dateLabel(state.date, state.period)
cell-triggerrole'button'

Style reference ​

Skin ​

@xihan-ui/styles/calendar-picker.css is written against [data-scope="calendar-picker"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-calendar-picker in place of data-scope (same specificity) and sits in the xihan.components layer. Put overrides in xihan.overrides; the part selectors work as usual.

Data attributes ​

Produced by connect; valueless attributes are omitted while their condition does not hold.

PartAttributeValue
rootdata-disabled'' (present only while the condition holds)
rootdata-invalid'' (present only while the condition holds)
rootdata-readonly'' (present only while the condition holds)
prev-year-triggerdata-disabled'' (present only while the condition holds)
prev-year-triggerdata-pressed'' (present only while the condition holds)
prev-year-triggerdata-xh-action-control''
prev-year-triggerdata-xh-action-display'always'
prev-year-triggerdata-xh-action-profile'icon'
prev-year-triggerdata-xh-action-size'xs'
prev-year-triggerdata-xh-action-variant'ghost'
prev-triggerdata-disabled'' (present only while the condition holds)
prev-triggerdata-pressed'' (present only while the condition holds)
prev-triggerdata-xh-action-control''
prev-triggerdata-xh-action-display'always'
prev-triggerdata-xh-action-profile'icon'
prev-triggerdata-xh-action-size'xs'
prev-triggerdata-xh-action-variant'ghost'
next-triggerdata-disabled'' (present only while the condition holds)
next-triggerdata-pressed'' (present only while the condition holds)
next-triggerdata-xh-action-control''
next-triggerdata-xh-action-display'always'
next-triggerdata-xh-action-profile'icon'
next-triggerdata-xh-action-size'xs'
next-triggerdata-xh-action-variant'ghost'
next-year-triggerdata-disabled'' (present only while the condition holds)
next-year-triggerdata-pressed'' (present only while the condition holds)
next-year-triggerdata-xh-action-control''
next-year-triggerdata-xh-action-display'always'
next-year-triggerdata-xh-action-profile'icon'
next-year-triggerdata-xh-action-size'xs'
next-year-triggerdata-xh-action-variant'ghost'
headingdata-indexframe.panelOf(panel).index
headingdata-viewview
heading-year-triggerdata-disabled'' (present only while the condition holds)
heading-year-triggerdata-indexframe.panelOf(panel).index
heading-year-triggerdata-pressed'' (present only while the condition holds)
heading-year-triggerdata-viewview
heading-year-triggerdata-xh-action-control''
heading-year-triggerdata-xh-action-display'always'
heading-year-triggerdata-xh-action-profile'text'
heading-year-triggerdata-xh-action-size'xs'
heading-year-triggerdata-xh-action-variant'ghost'
heading-month-triggerdata-disabled'' (present only while the condition holds)
heading-month-triggerdata-indexframe.panelOf(panel).index
heading-month-triggerdata-pressed'' (present only while the condition holds)
heading-month-triggerdata-viewview
heading-month-triggerdata-xh-action-control''
heading-month-triggerdata-xh-action-display'always'
heading-month-triggerdata-xh-action-profile'text'
heading-month-triggerdata-xh-action-size'xs'
heading-month-triggerdata-xh-action-variant'ghost'
griddata-disabled'' (present only while the condition holds)
griddata-indexframe.panelOf(panel).index
griddata-readonly'' (present only while the condition holds)
griddata-viewview
week-rowdata-viewview
celldata-disabled'' (present only while the condition holds)
celldata-focus'' (present only while the condition holds)
celldata-outside-month'' (present only while the condition holds)
celldata-selected'' (present only while the condition holds)
celldata-today'' (present only while the condition holds)
celldata-viewview
cell-triggerdata-disabled'' (present only while the condition holds)
cell-triggerdata-focus'' (present only while the condition holds)
cell-triggerdata-outside-month'' (present only while the condition holds)
cell-triggerdata-pressed'' (present only while the condition holds)
cell-triggerdata-selected'' (present only while the condition holds)
cell-triggerdata-today'' (present only while the condition holds)
cell-triggerdata-viewview
cell-triggerdata-xh-action-control''
cell-triggerdata-xh-action-display'always'
cell-triggerdata-xh-action-profile'text'
cell-triggerdata-xh-action-size'xs'
cell-triggerdata-xh-action-variant'ghost'

CSS variables ​

The public override slots, generated from what the standalone skin actually consumes.

VariablePartCSS propertyStateDefault from
--xh-calendar-picker-cell-bg-disabledcellbackground-colordisabled--xh-bg-subtle
--xh-calendar-picker-cell-bg-hovercell-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-calendar-picker-cell-bg-pressedcell-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-calendar-picker-cell-bg-selectedcell-trigger--xh-ink-surface
background-color
disabled
focus-visible
hover
loading
not([data-disabled])
not([data-loading])
selected
xh-ink-surface
--xh-bg-brand
--xh-calendar-picker-cell-bg-selected-activecell-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
selected
--xh-bg-brand-active
--xh-calendar-picker-cell-bg-selected-disabledcell-trigger--xh-ink-surface
background-color
disabled
selected
xh-ink-surface
--xh-bg-subtle-hover
--xh-calendar-picker-cell-fgcell-triggercolor@media print
default
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
selected
--xh-fg-default
--xh-calendar-picker-cell-fg-outsidecell-triggercolordisabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
outside-month
pressed
--xh-fg-subtle
--xh-calendar-picker-cell-fg-selectedcell-triggercolordisabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
selected
--xh-fg-on-brand
--xh-calendar-picker-cell-font-sizecell-triggerfont-sizedefault--xh-text-body-size
--xh-calendar-picker-cell-font-weightcell-triggerfont-weightdefault--xh-font-weight-medium
--xh-calendar-picker-cell-font-weight-outsidecell-triggerfont-weightoutside-month--xh-font-weight-regular
--xh-calendar-picker-cell-min-wgrid
week-row
grid-template-columns
min-inline-size
@media (pointer: coarse)
default
has(> [data-part='week-number'])
is([data-view='week'], [data-view='month'], [data-view='quarter'], [data-view='year'])
not([hidden])
view=month
view=quarter
view=week
view=year
--xh-control-h-md
--xh-calendar-picker-cell-pxcellpadding-inlinedefault--xh-space-0
--xh-calendar-picker-cell-pycellinset-block
padding-block
default
disabled
--xh-space-1_5
--xh-calendar-picker-cell-radiuscell-triggerborder-radiusview=day--xh-shape-circle
--xh-calendar-picker-cell-sizecell
cell-trigger
block-size
inline-size
inset-block
inset-block-start
min-inline-size
default
disabled
today
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-control-action-size
--xh-calendar-picker-disabled-insetcellinset-blockdisabled--xh-space-0_5
--xh-calendar-picker-gaprootgapdefault--xh-space-0
--xh-calendar-picker-grid-gapgridgapdefault--xh-space-0
--xh-calendar-picker-grid-pxgrid
week-row
grid-template-columns
min-inline-size
padding-inline
@media (pointer: coarse)
default
has(> [data-part='week-number'])
is([data-view='week'], [data-view='month'], [data-view='quarter'], [data-view='year'])
not([hidden])
view=month
view=quarter
view=week
view=year
--xh-space-4
--xh-calendar-picker-grid-pygridpadding-blockdefault--xh-space-3
--xh-calendar-picker-header-borderheaderborder-block-enddefault--xh-material-solid-border
--xh-calendar-picker-header-gapheadergapdefault--xh-space-1
--xh-calendar-picker-header-pxheaderpadding-inlinedefault--xh-space-4
--xh-calendar-picker-header-pyheadermin-block-size
padding-block
default--xh-space-2
--xh-calendar-picker-heading-fgheading
heading-month-trigger
heading-year-trigger
colordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
not([hidden])
pressed
--xh-fg-default
--xh-calendar-picker-heading-font-sizeheading
heading-month-trigger
heading-year-trigger
font-sizedefault
not([hidden])
--xh-text-label-size
--xh-calendar-picker-heading-font-weightheading
heading-month-trigger
heading-year-trigger
font-weightdefault
not([hidden])
--xh-font-weight-medium
--xh-calendar-picker-heading-trigger-bg-hoverheading-month-trigger
heading-year-trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
not([hidden])
--xh-_action-variant-bg-hover
--xh-calendar-picker-heading-trigger-bg-pressedheading-month-trigger
heading-year-trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
not([hidden])
pressed
--xh-_action-variant-bg-pressed
--xh-calendar-picker-heading-trigger-pxheading-month-trigger
heading-year-trigger
padding-inlinenot([hidden])--xh-space-0_5
--xh-calendar-picker-heading-trigger-radiusheading-month-trigger
heading-year-trigger
border-radiusnot([hidden])--xh-shape-control
--xh-calendar-picker-icon-sizeheader--xh-icon-sizedefault--xh-glyph-size-sm
--xh-calendar-picker-nav-bgnext-trigger
next-year-trigger
prev-trigger
prev-year-trigger
--xh-ink-surface
background-color
default
focus-visible
xh-ink-surface
--xh-_action-variant-bg-focus-visible
--xh-_action-variant-bg-rest
--xh-calendar-picker-nav-bg-hovernext-trigger
next-year-trigger
prev-trigger
prev-year-trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-calendar-picker-nav-bg-pressednext-trigger
next-year-trigger
prev-trigger
prev-year-trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-calendar-picker-nav-fgnext-trigger
next-year-trigger
prev-trigger
prev-year-trigger
colordefault
focus-visible
--xh-fg-muted
--xh-calendar-picker-nav-fg-hovernext-trigger
next-year-trigger
prev-trigger
prev-year-trigger
colordisabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-default
--xh-calendar-picker-nav-radiusnext-trigger
next-year-trigger
prev-trigger
prev-year-trigger
border-radiusdefault--xh-shape-circle
--xh-calendar-picker-nav-sizenext-trigger
next-year-trigger
prev-trigger
prev-year-trigger
block-size
inline-size
min-inline-size
default
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-calendar-picker-period-gapgrid
week-row
column-gap
gap
is([data-view='month'], [data-view='year'])
is([data-view='week'], [data-view='month'], [data-view='quarter'], [data-view='year'])
view=month
view=quarter
view=week
view=year
--xh-space-0
--xh-calendar-picker-period-pxcellpadding-inlineis([data-view='week'], [data-view='month'], [data-view='quarter'], [data-view='year'])
view=month
view=quarter
view=week
view=year
--xh-space-1
--xh-calendar-picker-period-radiuscell-triggerborder-radiusdefault--xh-shape-control
--xh-calendar-picker-row-gapgrid-body
grid-head
gapdefault--xh-space-0
--xh-calendar-picker-today-mark-bgcellbackground-colortoday--xh-fg-brand
--xh-calendar-picker-today-mark-sizecellblock-size
border
inline-size
@media print
today
--xh-space-1
--xh-calendar-picker-week-cell-pxcell-triggerpadding-inlineview=week--xh-space-3
--xh-calendar-picker-week-day-fgweek-daycolordefault--xh-fg-subtle
--xh-calendar-picker-week-day-font-sizeweek-dayfont-sizedefault--xh-text-body-size
--xh-calendar-picker-week-day-font-weightweek-dayfont-weightdefault--xh-font-weight-regular
--xh-calendar-picker-week-day-hweek-dayblock-sizedefault--xh-control-h-md
--xh-calendar-picker-week-number-fgweek-numbercolordefault--xh-fg-subtle
--xh-calendar-picker-week-number-font-sizeweek-numberfont-sizedefault--xh-text-caption-size
--xh-calendar-picker-week-number-wweek-rowgrid-template-columns@media (pointer: coarse)
has(> [data-part='week-number'])
not([hidden])
--xh-control-h-md
--xh-calendar-picker-year-grid-max-hgridmax-block-sizeview=year--xh-viewport-h-sm

Released under The MIT License