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

查看生态总览
Skip to content

ExpressionInput ​

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="expression-input": root · label · control · input · highlight · highlight-segment · issues · issue · positioner · content · item · item-prefix · item-text · item-suffix · item-description · empty

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-expression-input>
Vue componentsXhExpressionInputContent XhExpressionInputControl XhExpressionInputEmpty XhExpressionInputHighlight XhExpressionInputHighlightSegment XhExpressionInputInput XhExpressionInputIssue XhExpressionInputIssues XhExpressionInputItem XhExpressionInputItemDescription XhExpressionInputItemPrefix XhExpressionInputItemSuffix XhExpressionInputItemText XhExpressionInputLabel XhExpressionInputPositioner XhExpressionInputRoot
ComposableuseExpressionInput
State machineexpressionInputMachine
Skin@xihan-ui/styles/expression-input.css

Props ​

PropTypeRequired
labelledboolean
ariaLabelstring
labelstring
multilineboolean
issuesRenderedboolean
valuestring
defaultValuestring
checkExpressionCheck
completionsExpressionCompletionSource
functionsFunctionTable
placeholderstring
namestring
disabledboolean
readOnlyboolean
requiredboolean
invalidboolean
autoSizeboolean | ExpressionInputAutoSize
checkDelaynumber
loopboolean
placementPlacement
dirDirection
offsetnumber
variantControlVariant
toneTone
sizeSize
translationsPartial<ExpressionInputTranslations>
onValueChange(details: ExpressionInputValueChangeDetails) => void
onIssuesChange(details: ExpressionInputIssuesChangeDetails) => void
onCompletionSelect(details: ExpressionInputCompletionSelectDetails) => void
onOpenChange(details: ExpressionInputOpenChangeDetails) => void

Events ​

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

EventPayload
value-changeExpressionInputValueChangeDetails
issues-changeExpressionInputIssuesChangeDetails
completion-selectExpressionInputCompletionSelectDetails
open-changeExpressionInputOpenChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhExpressionInputRootdefaultExpressionInputRootSlotProps

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
XhExpressionInputHighlightSegmentindexstringYes
XhExpressionInputInputasExpressionInputHost
XhExpressionInputIssueindexstringYes
XhExpressionInputItemvaluestringYes
XhExpressionInputPositionercontainer() => Element | null
XhExpressionInputRootchildrenSlotChildren<ExpressionInputRootSlotProps>

State ​

Public state is written to data-state.

PartValues
root'open' | 'closed'
input'open' | 'closed'
positioner'open' | 'closed'
content'open' | 'closed'
empty'open' | 'closed'

The following names are internal to the state machine.

States: open · closed

Events: INPUT.CHANGE · CARET.SYNC · COMPOSITION.START · COMPOSITION.END · OPEN.FORCE · OPEN · WORD.CHANGED · CLOSE · ESCAPE · ITEM.HIGHLIGHT · ITEM.SELECT · VALUE.SET · TEXT.INSERT · CHECK.RUN · FORM.RESET · PRESS.START · PRESS.END

Guards: canEdit · canPress

connect API ​

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

MemberType
valuestring
openboolean
disabledboolean
readOnlyboolean
invalidboolean
itemsreadonly ExpressionInputItem[]
highlightedKeystring | null
emptyboolean
emptyTextstring
kindText(kind: ExpressionCompletionKind) => string
issuesreadonly ExpressionInputIssueView[]
segmentsreadonly ExpressionInputSegment[]
setValue(next: string) => void
insert(text: string) => void
close() => void
getRootProps() => T['element']
getLabelProps() => T['label']
getControlProps() => T['element']
getInputProps(props?: ExpressionInputInputProps) => T['input']
getHighlightProps() => T['element']
getHighlightSegmentProps(props: ExpressionInputMarkProps) => T['element']
getPositionerProps() => T['element']
getContentProps() => T['element']
getItemProps(props: ExpressionInputItemProps) => T['element']
getItemPrefixProps(props: ExpressionInputItemProps) => T['element']
getItemTextProps(props: ExpressionInputItemProps) => T['element']
getItemSuffixProps(props: ExpressionInputItemProps) => T['element']
getItemDescriptionProps(props: ExpressionInputItemProps) => T['element']
getEmptyProps() => T['element']
getIssuesProps() => T['element']
getIssueProps(props: ExpressionInputIssueProps) => T['element']

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
name charactersexpression-input.kbd.type
Ctrl+Spaceexpression-input.kbd.force
ArrowDownexpression-input.kbd.next
ArrowUpexpression-input.kbd.prev
Enter / Tabexpression-input.kbd.accept
Enterexpression-input.kbd.enter-pass
Escapeexpression-input.kbd.escape
ArrowLeft / ArrowRight / Home / Endexpression-input.kbd.caret

ARIA ​

These attributes are produced by connect.

PartAttributeValue
inputaria-activedescendantid of the item part | undefined
inputaria-autocomplete'list'
inputaria-controlsid of the content part
inputaria-describedbyid of the issues part | undefined
inputaria-expandedundefined | 'true' | 'false'
inputaria-haspopup'listbox'
inputaria-invalid'true' | 'false'
inputaria-labelprops.ariaLabel
inputaria-labelledbyid of the label part | undefined
inputaria-readonly'true' | 'false'
inputaria-required'true' | 'false'
inputroleundefined | 'combobox'
highlightaria-hidden'true'
issuesrole'status'
contentaria-hidden!open || undefined
contentaria-labelt.content
contentrole'listbox'
itemaria-selected'true' | 'false'
itemrole'option'
item-prefixaria-hidden'true'
emptyrole'status'

Style reference ​

Skin ​

@xihan-ui/styles/expression-input.css is written against [data-scope="expression-input"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-expression-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-empty'' (present only while the condition holds)
rootdata-invalid'' (present only while the condition holds)
rootdata-readonly'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-state'open' | 'closed'
rootdata-toneprops.tone
rootdata-variantprops.variant
labeldata-disabled'' (present only while the condition holds)
controldata-disabled'' (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-field-chrome''
controldata-xh-field-sizeprops.size
inputdata-disabled'' (present only while the condition holds)
inputdata-invalid'' (present only while the condition holds)
inputdata-state'open' | 'closed'
inputdata-xh-field-auto-size'' (present only while the condition holds)
inputdata-xh-field-input''
inputdata-xh-field-layout'textarea' | 'single-line'
highlightdata-multiline'' (present only while the condition holds)
highlight-segmentdata-issueundefined | String(segment.issue)
highlight-segmentdata-severitysegment.severity
issuesdata-invalid'' (present only while the condition holds)
issuedata-issueString(issue.index)
issuedata-severityissue.issue.severity
positionerdata-hidden'' (present only while the condition holds)
positionerdata-placementactual placement computed by the positioning engine
positionerdata-positioned'' (present only while the condition holds)
positionerdata-sizeprops.size
positionerdata-state'open' | 'closed'
positionerdata-toneprops.tone
positionerdata-variantprops.variant
contentdata-placementactual placement computed by the positioning engine
contentdata-state'open' | 'closed'
contentdata-xh-material'frosted'
itemdata-highlighted'' (present only while the condition holds)
itemdata-pressed'' (present only while the condition holds)
itemdata-xh-collection-context'overlay'
itemdata-xh-collection-item''
itemdata-xh-collection-sizeprops.size
item-prefixdata-highlighted'' (present only while the condition holds)
item-prefixdata-xh-collection-slot'prefix'
item-textdata-highlighted'' (present only while the condition holds)
item-textdata-xh-collection-slot'text'
item-suffixdata-highlighted'' (present only while the condition holds)
item-suffixdata-xh-collection-slot'suffix'
item-descriptiondata-highlighted'' (present only while the condition holds)
item-descriptiondata-xh-collection-slot'description'
emptydata-state'open' | 'closed'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-expression-input-content-backdropcontent-webkit-backdrop-filter
backdrop-filter
xh-material=frosted--xh-_material-backdrop
--xh-expression-input-content-bgcontentbackgroundnot([data-xh-action-control])
xh-material=frosted
--xh-_material-bg
--xh-expression-input-content-bordercontentbordernot([data-xh-action-control])
xh-material=frosted
--xh-_material-border
--xh-expression-input-content-fgcontentcolornot([data-xh-action-control])
xh-material=frosted
--xh-_material-fg
--xh-expression-input-content-gapcontentgapdefault--xh-list-option-gap
--xh-expression-input-content-highlightcontentbackgroundnot([data-xh-action-control])
xh-material=frosted
--xh-_material-highlight
--xh-expression-input-content-max-hcontentmax-block-sizedefault--xh-overlay-max-h
--xh-expression-input-content-max-wcontentmax-inline-sizedefault--xh-overlay-max-w
--xh-expression-input-content-min-wcontentmin-inline-sizedefault--xh-overlay-min-w
--xh-expression-input-content-pxcontentpadding-inlinedefault--xh-space-1
--xh-expression-input-content-pycontentpadding-blockdefault--xh-space-1
--xh-expression-input-content-radiuscontentborder-radiusdefault--xh-shape-overlay
--xh-expression-input-content-shadowcontentbox-shadownot([data-xh-action-control])
xh-material=frosted
--xh-_material-shadow
--xh-expression-input-control-bgcontrolbackground-colorxh-field-chrome--xh-_field-variant-bg-rest
--xh-expression-input-control-bg-disabledcontrolbackground-colordisabled
xh-field-chrome
--xh-_field-variant-bg-disabled
--xh-expression-input-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-expression-input-control-bg-readonlycontrolbackground-colorreadonly
xh-field-chrome
--xh-_field-variant-bg-read-only
--xh-expression-input-control-bordercontrolborderxh-field-chrome--xh-_field-variant-border-rest
--xh-expression-input-control-border-focuscontrolborder-color
box-shadow
disabled
focus-within
not([data-disabled])
xh-field-chrome
--xh-_field-variant-border-focus
--xh-expression-input-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-expression-input-control-border-invalidcontrolborder-colorinvalid
xh-field-chrome
--xh-_field-variant-border-invalid
--xh-expression-input-control-fgcontrolcolorxh-field-chrome--xh-fg-default
--xh-expression-input-control-gapcontrolgapxh-field-chrome--xh-_expression-input-gap
--xh-expression-input-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-_expression-input-h
--xh-expression-input-control-min-wcontrol
root
min-inline-sizedefault
xh-field-chrome
--xh-control-min-w
--xh-expression-input-control-pxcontrolpadding-inlinexh-field-chrome--xh-_expression-input-px
--xh-expression-input-control-radiuscontrolborder-radiusxh-field-chrome--xh-shape-control
--xh-expression-input-control-shadowcontrolbox-shadowxh-field-chromenone
--xh-expression-input-control-wrootinline-size
min-inline-size
default--xh-control-w
--xh-expression-input-empty-fgemptycolordefault--xh-material-frosted-fg-muted
--xh-expression-input-empty-font-sizeemptyfont-sizedefault--xh-_expression-input-font-size
--xh-expression-input-empty-pxemptypadding-inlinedefault--xh-_expression-input-px
--xh-expression-input-empty-pyemptypadding-blockdefault--xh-space-3
--xh-expression-input-gaplabel
root
gap
margin-block-end
default--xh-space-1
--xh-expression-input-input-autofill-bginputbox-shadow-webkit-autofill
autofill
xh-field-input
--xh-bg-canvas
--xh-expression-input-input-autofill-fginput-webkit-text-fill-color-webkit-autofill
autofill
xh-field-input
--xh-fg-default
--xh-expression-input-input-fginputcolorxh-field-input--xh-fg-default
--xh-expression-input-input-font-sizehighlight
input
font-sizedefault
xh-field-input
--xh-_expression-input-font-size
--xh-expression-input-input-max-hinputmax-block-sizexh-field-auto-size--xh-viewport-h-sm
--xh-expression-input-issue-error-fghighlight-segment
issue
color
text-decoration-color
default
issue
--xh-fg-danger
--xh-expression-input-issue-font-sizeissuefont-sizedefault--xh-text-caption-size
--xh-expression-input-issue-warning-fghighlight-segment
issue
color
text-decoration-color
severity=warning--xh-fg-warning
--xh-expression-input-issues-gapissuesgapdefault--xh-space-0_5
--xh-expression-input-item-bg-hoveritembackground-colordisabled
error
highlighted
hover
is(:focus-visible, [data-highlighted])
is([aria-selected='true'], [data-selected])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
selected
xh-collection-context=overlay
--xh-bg-subtle
--xh-expression-input-item-bg-presseditembackground-colordisabled
error
is(:active, [data-pressed])
is([aria-selected='true'], [data-selected])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
selected
xh-collection-context=overlay
--xh-bg-subtle-hover
--xh-expression-input-item-fgitemcolordefault
disabled
error
highlighted
hover
is(:active, [data-pressed])
is(:focus-visible, [data-highlighted])
is([aria-selected='true'], [data-selected])
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
pressed
selected
xh-collection-context=overlay
--xh-material-frosted-fg
--xh-expression-input-item-font-sizeitemfont-sizedefault--xh-_expression-input-font-size
--xh-expression-input-item-gapitemmargin-inline-end
margin-inline-start
xh-collection-slot=indicator
xh-collection-slot=prefix
xh-collection-slot=shortcut
xh-collection-slot=suffix
--xh-_expression-input-gap
--xh-expression-input-item-hitemmin-block-sizedefault--xh-_expression-input-item-h
--xh-expression-input-item-leadingitemline-heightdefault--xh-leading-normal
--xh-expression-input-item-prefix-fgitem-prefixcolordefault--xh-material-frosted-fg-muted
--xh-expression-input-item-prefix-font-sizeitem-prefixfont-sizedefault--xh-_expression-input-caption-size
--xh-expression-input-item-prefix-witem-prefixmin-inline-sizedefault--xh-space-8
--xh-expression-input-item-pxitempadding-inlinedefault--xh-_expression-input-px
--xh-expression-input-item-pyitempadding-blockdefault--xh-_expression-input-item-py
--xh-expression-input-item-radiusitemborder-radiusdefault--xh-shape-inset
--xh-expression-input-item-suffix-fgitem-suffixcolordefault--xh-material-frosted-fg-muted
--xh-expression-input-item-suffix-font-sizeitem-suffixfont-sizedefault--xh-_expression-input-caption-size
--xh-expression-input-label-fglabelcolordefault--xh-fg-muted
--xh-expression-input-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-expression-input-label-font-weightlabelfont-weightdefault--xh-text-label-weight
--xh-expression-input-label-gaplabelmargin-block-enddefault--xh-space-2
--xh-expression-input-layerpositionerz-indexdefault--xh-_layer
--xh-expression-input-placeholder-fginputcolorplaceholder
xh-field-input
--xh-fg-subtle
--xh-expression-input-textarea-pyhighlight
input
padding-blockmultiline
xh-field-input
xh-field-layout=textarea
--xh-space-1

Released under The MIT License