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

查看生态总览
Skip to content

TimeField ​

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="time-field": root · label · control · segment-group · segment · clear-trigger · hidden-input

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-time-field>
Vue componentsXhTimeFieldClearTrigger XhTimeFieldControl XhTimeFieldHiddenInput XhTimeFieldLabel XhTimeFieldRoot XhTimeFieldSegment XhTimeFieldSegmentGroup
ComposableuseTimeField
State machinetimeFieldMachine
Skin@xihan-ui/styles/time-field.css

Props ​

PropTypeRequired
labelledboolean
ariaLabelstring
valuestring
defaultValuestring
minstring
maxstring
localestring
hourCycleTimeHourCycle
granularityTimeGranularity
disabledboolean
readOnlyboolean
invalidboolean
requiredboolean
namestring
placeholderstring
variantControlVariant
toneTone
sizeSize
translationsPartial<TimeFieldTranslations>
onValueChange(details: TimeFieldValueChangeDetails) => void
onClear() => void

Events ​

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

EventPayload
value-changeTimeFieldValueChangeDetails
clear``

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhTimeFieldRootdefaultTimeFieldRootSlotProps

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
XhTimeFieldRootchildrenSlotChildren<TimeFieldRootSlotProps>
XhTimeFieldSegmentsegmentTimeSegmentTypeYes

State ​

The following names are internal to the state machine.

States: idle

Events: VALUE.SET · VALUE.CLEAR · SEGMENT.STEP · SEGMENT.DIGIT · SEGMENT.CLEAR · SEGMENT.PERIOD · SEGMENT.FOCUS · SEGMENT.BLUR · FORM.RESET · PRESS.START · PRESS.END

Guards: canEdit · canPress

connect API ​

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

MemberType
valuestring
emptyboolean
outOfRangeboolean
disabledboolean
readOnlyboolean
invalidboolean
canClearboolean
hourCycleTimeHourCycle
granularityTimeGranularity
segmentsTimeSegmentType[]
focusedSegmentTimeSegmentType | null
getSegmentText(props: TimeFieldSegmentProps) => string
setValue(next: string) => void
clear() => void
getRootProps() => T['element']
getLabelProps() => T['label']
getControlProps() => T['element']
getSegmentGroupProps() => T['element']
getSegmentProps(props: TimeFieldSegmentProps) => T['element']
getClearTriggerProps() => T['button']
getHiddenInputProps() => T['input']

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
ArrowUptime-field.kbd.increment
ArrowDowntime-field.kbd.decrement
ArrowRighttime-field.kbd.next
ArrowLefttime-field.kbd.prev
Hometime-field.kbd.first
Endtime-field.kbd.last
0-9time-field.kbd.digit
Backspace / Deletetime-field.kbd.clear
Enter / Spacetime-field.kbd.press
a / ptime-field.kbd.period

ARIA ​

These attributes are produced by connect.

PartAttributeValue
controlaria-disabled'true' | 'false'
controlaria-invalid'true' | 'false'
controlaria-labelprops.ariaLabel
controlaria-labelledbyid of the label part | undefined
controlrole'group'
segmentaria-disabled'true' | 'false'
segmentaria-invalid'true' | 'false'
segmentaria-labeltranslations[segment]
segmentaria-readonly'true' | 'false'
segmentaria-required'true' | 'false'
segmentaria-valuemaxrange.max
segmentaria-valueminrange.min
segmentaria-valuenowsegmentNumber(draft, segment, hourCycle)
segmentaria-valuetexttimeSegmentText(draft, segment, { hourCycle, locale, …
segmentrole'spinbutton'
clear-triggeraria-labeltranslations.clearTrigger

Style reference ​

Skin ​

@xihan-ui/styles/time-field.css is written against [data-scope="time-field"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-time-field 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-empty'' (present only while the condition holds)
rootdata-invalid'' (present only while the condition holds)
rootdata-out-of-range'' (present only while the condition holds)
rootdata-readonly'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-toneprops.tone
rootdata-variantprops.variant
labeldata-disabled'' (present only while the condition holds)
controldata-disabled'' (present only while the condition holds)
controldata-empty'' (present only while the condition holds)
controldata-invalid'' (present only while the condition holds)
controldata-readonly'' (present only while the condition holds)
controldata-variantprops.variant
controldata-xh-action-owner''
controldata-xh-field-chrome''
controldata-xh-field-sizeprops.size
segment-groupdata-disabled'' (present only while the condition holds)
segment-groupdata-invalid'' (present only while the condition holds)
segment-groupdata-readonly'' (present only while the condition holds)
segmentdata-disabled'' (present only while the condition holds)
segmentdata-focus'' (present only while the condition holds)
segmentdata-invalid'' (present only while the condition holds)
segmentdata-placeholder'' (present only while the condition holds)
segmentdata-readonly'' (present only while the condition holds)
clear-triggerdata-pressed'' (present only while the condition holds)
clear-triggerdata-xh-action-control''
clear-triggerdata-xh-action-display'has-value'
clear-triggerdata-xh-action-has-value'' (present only while the condition holds)
clear-triggerdata-xh-action-profile'field-inset'
clear-triggerdata-xh-action-sizeprops.size
clear-triggerdata-xh-action-variant'ghost'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-time-field-action-bgclear-trigger--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-time-field-action-bg-activeclear-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-time-field-action-bg-hoverclear-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-time-field-action-fgclear-triggercolordefault--xh-fg-field-clear
--xh-time-field-action-fg-hoverclear-triggercolordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-fg-default
--xh-time-field-action-font-sizeclear-triggerfont-sizedefault--xh-text-secondary-size
--xh-time-field-action-radiusclear-triggerborder-radiusdefault--xh-shape-circle
--xh-time-field-action-sizeclear-triggerblock-size
inline-size
min-inline-size
default
xh-action-profile=field-inset
--xh-_action-profile-visual-size
--xh-time-field-control-bgcontrolbackground-colorxh-field-chrome--xh-_field-variant-bg-rest
--xh-time-field-control-bg-disabledcontrolbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabled
--xh-time-field-control-bg-hovercontrolbackground-colordisabled
hover
invalid
loading
not(:focus-within)
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-bg-hover
--xh-time-field-control-bg-readonlycontrolbackground-colorreadonly
xh-field-chrome
--xh-_field-variant-bg-read-only
--xh-time-field-control-bordercontrolborderxh-field-chrome--xh-_field-variant-border-rest
--xh-time-field-control-border-focuscontrolborder-color
box-shadow
disabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focus
--xh-time-field-control-border-hovercontrolborder-colordisabled
hover
invalid
loading
not(:focus-within)
not([data-disabled])
not([data-invalid])
not([data-loading])
not([data-readonly])
readonly
xh-field-chrome
--xh-_field-variant-border-hover
--xh-time-field-control-border-invalidcontrolborder-colorinvalid
xh-field-chrome
--xh-_field-variant-border-invalid
--xh-time-field-control-fgcontrolcolorxh-field-chrome--xh-fg-default
--xh-time-field-control-gapcontrolgapxh-field-chrome--xh-_time-field-gap
--xh-time-field-control-hcontrolblock-size
min-block-size
has([data-xh-field-input][data-xh-field-layout='multi-tag'])
has([data-xh-field-input][data-xh-field-layout='single-line'])
has([data-xh-field-input][data-xh-field-layout='textarea'])
xh-field-chrome
xh-field-input
xh-field-layout=multi-tag
xh-field-layout=single-line
xh-field-layout=textarea
--xh-_time-field-control-h
--xh-time-field-control-min-wcontrol
root
min-inline-sizedefault
xh-field-chrome
--xh-control-min-w
--xh-time-field-control-pxcontrolpadding-inlinexh-field-chrome--xh-_time-field-control-px
--xh-time-field-control-radiuscontrolborder-radiusxh-field-chrome--xh-shape-control
--xh-time-field-control-shadowcontrolbox-shadowxh-field-chromenone
--xh-time-field-control-wrootinline-size
min-inline-size
default--xh-control-w
--xh-time-field-font-sizecontrolfont-sizedefault--xh-_time-field-font-size
--xh-time-field-gaplabel
root
gap
margin-block-end
default--xh-space-1
--xh-time-field-icon-sizecontrol
root
--xh-icon-sizedefault
size=lg
size=sm
xh-field-chrome
--xh-_field-size-glyph-size
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-time-field-label-fglabelcolordefault--xh-fg-muted
--xh-time-field-label-fg-disabledlabelcolordisabled--xh-fg-muted
--xh-time-field-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-time-field-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-time-field-label-gaplabelmargin-block-enddefault--xh-space-2
--xh-time-field-literal-fgsegment-groupcolornot([data-scope])--xh-fg-subtle
--xh-time-field-placeholder-fgsegmentcolorplaceholder--xh-fg-subtle
--xh-time-field-segment-bg-focussegmentbackgrounddisabled
focus
focus-visible
not([data-disabled])
--xh-_time-field-segment-bg
--xh-time-field-segment-bg-hoversegmentbackgrounddisabled
focus
hover
not([data-focus], [data-disabled])
--xh-bg-subtle
--xh-time-field-segment-bg-invalid-focussegmentbackgroundfocus
invalid
is([data-focus], :focus-visible)
--xh-bg-subtle
--xh-time-field-segment-fg-focussegmentcolordisabled
focus
focus-visible
not([data-disabled])
placeholder
--xh-_time-field-segment-fg
--xh-time-field-segment-fg-invalidsegmentcolorinvalid--xh-fg-danger
--xh-time-field-segment-fg-invalid-focussegmentcolorfocus
invalid
is([data-focus], :focus-visible)
--xh-fg-danger
--xh-time-field-segment-pxsegmentpadding-inlinedefault--xh-space-0_5
--xh-time-field-segment-pysegmentpadding-blockdefault--xh-space-0
--xh-time-field-segment-radiussegmentborder-radiusdefault--xh-shape-inset

Released under The MIT License