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

查看生态总览
Skip to content

FormatInput ​

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="format-input": root · label · kind · field-group · item · item-label · pattern-description · preview · error-text

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-format-input>
Vue componentsXhFormatInputErrorText XhFormatInputFieldGroup XhFormatInputItem XhFormatInputItemLabel XhFormatInputKind XhFormatInputLabel XhFormatInputPatternDescription XhFormatInputPreview XhFormatInputRoot
ComposableuseFormatInput
State machineformatInputMachine
Skin@xihan-ui/styles/format-input.css

Props ​

PropTypeRequired
valueFormatSpec | null
defaultValueFormatSpec | null
kindsreadonly FormatInputKind[]
clearableboolean
mixedboolean
datePatternsreadonly string[]
sampleunknown
localestring
timeZonestring
disabledboolean
readOnlyboolean
invalidboolean
labelledboolean
ariaLabelstring
variantControlVariant
sizeSize
translationsPartial<FormatInputTranslations>
onValueChange(details: FormatInputValueChangeDetails) => void

Events ​

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

EventPayload
value-changeFormatInputValueChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhFormatInputRootdefaultFormatInputRootSlotProps

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
XhFormatInputItemvalueFormatInputOptionYes
XhFormatInputItemLabelvalueFormatInputOption | 'kind'Yes
XhFormatInputRootchildrenSlotChildren<FormatInputRootSlotProps>

State ​

The following names are internal to the state machine.

States: idle · settling

Events: KIND.SET · DECIMALS_MODE.SET · DECIMALS.SET · GROUPING.SET · ROUNDING.SET · PATTERN.SET · STYLE.SET · VALUE.SYNC · after.announce

Guards: isEditable

connect API ​

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

MemberType
valueFormatSpec | null
kindFormatInputKind | null
draftFormatInputDraft
issueFormatInputIssueCode | null
issueTextstring
previewTextstring
optionsreadonly FormatInputOption[]
kindItemsreadonly { value: FormatInputKindOption, label: string }[]
kindControl'toggle-group' | 'select'
setKind(kind: FormatInputKind | null) => void
setDecimalsMode(mode: FormatInputDecimalsMode) => void
setDecimals(field: FormatInputDecimalsField, text: string) => void
setGrouping(value: boolean) => void
setRounding(value: FormatRounding) => void
setPattern(value: string) => void
setNumeralStyle(value: NumeralStyle) => void
getRootProps() => T['element']
getLabelProps() => T['element']
getKindProps() => T['element']
getFieldGroupProps() => T['element']
getItemProps(option: FormatInputOption) => T['element']
getItemLabelProps(option: FormatInputOption | 'kind') => T['element']
getPatternDescriptionProps() => T['element']
getPreviewProps() => T['element']
getErrorTextProps() => T['element']
getKindToggleGroupProps() => Partial<StructureInstanceProps['toggle-group']>
getKindSelectProps() => Partial<StructureInstanceProps['select']>
getDecimalsModeControlProps() => Partial<StructureInstanceProps['toggle-group']>
getDecimalsControlProps(field: FormatInputDecimalsField) => Partial<StructureInstanceProps['number-field']>
getGroupingControlProps() => Partial<StructureInstanceProps['switch']>
getRoundingControlProps() => Partial<StructureInstanceProps['select']>
getPatternControlProps() => Partial<StructureInstanceProps['combobox']>
getNumeralStyleControlProps() => Partial<StructureInstanceProps['select']>

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+Tabformat-input.kbd.tab
ArrowUp / ArrowDown / Enter / Spaceformat-input.kbd.controls

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-describedbyundefined | id of the error-text part
rootaria-invalid'true' | undefined
rootaria-labelprops.ariaLabel
rootaria-labelledbyid of the label part | undefined
rootrole'group'
previewaria-live'polite'
previewrole'status'

Style reference ​

Skin ​

@xihan-ui/styles/format-input.css is written against [data-scope="format-input"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-format-input 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-kindundefined | draft.kind
rootdata-readonly'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-variantprops.variant
itemdata-valueoption
item-labeldata-valueoption

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-format-input-error-fgerror-textcolordefault--xh-fg-danger
--xh-format-input-error-font-sizeerror-textfont-sizedefault--xh-text-secondary-size
--xh-format-input-field-group-col-wfield-groupgrid-template-columnsdefault--xh-layout-col-min-sm
--xh-format-input-field-group-gapfield-groupgapdefault--xh-space-3
--xh-format-input-gaprootgapdefault--xh-space-4
--xh-format-input-item-gapitemgapvalue=grouping--xh-space-3
--xh-format-input-item-label-fgitem-labelcolordefault--xh-fg-muted
--xh-format-input-item-label-font-sizeitem-labelfont-sizedefault--xh-text-label-size
--xh-format-input-item-label-font-weightitem-labelfont-weightdefault--xh-text-label-weight
--xh-format-input-item-label-gapitem-labelmargin-block-endwhere(legend)--xh-space-2
--xh-format-input-label-fglabelcolordefault--xh-fg-muted
--xh-format-input-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-format-input-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-format-input-pattern-description-fgpattern-descriptioncolordefault--xh-fg-muted
--xh-format-input-pattern-description-font-sizepattern-descriptionfont-sizedefault--xh-text-secondary-size
--xh-format-input-preview-fgpreviewcolordefault--xh-fg-muted
--xh-format-input-preview-font-sizepreviewfont-sizedefault--xh-text-body-size

Released under The MIT License