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

查看生态总览
Skip to content

Approval alpha ​

AI chat 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="approval": root · pending-indicator · title · description · live-region · group · item · item-indicator · item-text · note · timer · result · footer · approve-trigger · deny-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-approval>
Vue componentsXhApprovalApproveTrigger XhApprovalDenyTrigger XhApprovalDescription XhApprovalFooter XhApprovalGroup XhApprovalItem XhApprovalItemIndicator XhApprovalItemText XhApprovalLiveRegion XhApprovalNote XhApprovalPendingIndicator XhApprovalResult XhApprovalRoot XhApprovalTimer XhApprovalTitle
ComposableuseApproval
State machineapprovalMachine
Skin@xihan-ui/styles/approval.css

Props ​

PropTypeRequired
requestIdstring
statusApprovalStatus
defaultStatusApprovalStatus
timeoutMsnumber
scopesreadonly ApprovalScope[]
grantedScopesreadonly string[]
defaultGrantedScopesreadonly string[]
notestring
defaultNotestring
requireReasonboolean
loadingboolean
denyOnEscapeboolean
denyOnUnmountboolean
live'polite' | 'assertive'
variantControlVariant
toneTone
sizeSize
partsTitleDescriptionParts
translationsPartial<ApprovalTranslations>
onDecision(details: ApprovalDecisionDetails) => void
onGrantedScopesChange(details: ApprovalScopesChangeDetails) => void
onNoteChange(details: ApprovalNoteChangeDetails) => void

ApprovalScope ​

Elements of scopes.

FieldTypeRequired
valuestringYes
labelstring
requiredboolean
disabledboolean

Events ​

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

EventPayload
decisionApprovalDecisionDetails
granted-scopes-changeApprovalScopesChangeDetails
note-changeApprovalNoteChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhApprovalItemdefaultApprovalScopeSlotProps
XhApprovalRootdefaultApprovalRootSlotProps

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
XhApprovalItemscopeValuestringYes
XhApprovalItemscopeLabelstring
XhApprovalItemscopeRequiredboolean
XhApprovalItemscopeDisabledboolean
XhApprovalItemchildrenSlotChildren<ApprovalScopeSlotProps>
XhApprovalItemIndicatorscopeValuestringYes
XhApprovalItemTextscopeValuestringYes
XhApprovalRootchildrenSlotChildren<ApprovalRootSlotProps>

State ​

Public state is written to data-state.

PartValues
root'pending' | 'approved' | 'denied' | 'expired'
pending-indicator'pending' | 'approved' | 'denied' | 'expired'
item'checked' | 'unchecked'
item-indicator'checked' | 'unchecked'
note'pending' | 'approved' | 'denied' | 'expired'
timer'pending' | 'approved' | 'denied' | 'expired'
result'pending' | 'approved' | 'denied' | 'expired'
approve-trigger'pending' | 'approved' | 'denied' | 'expired'
deny-trigger'pending' | 'approved' | 'denied' | 'expired'

The following names are internal to the state machine.

States: pending · approved · denied · expired

Events: APPROVE · DENY · SCOPE.TOGGLE · SCOPE.SET · NOTE.SET · after.timeout · CONTROLLED.PENDING · CONTROLLED.APPROVE · CONTROLLED.DENY · CONTROLLED.EXPIRE · REQUEST.RESET · PRESS.START · PRESS.END · REASON.PROMPT

Guards: isStatusControlled · canApprove · isEditable · canApproveControlled · canPress

connect API ​

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

MemberType
statusApprovalStatus
settledboolean
loadingboolean
grantedScopesstring[]
notestring
canApproveboolean
reasonMissingboolean
announcementstring
approve() => void
deny() => void
setGrantedScopes(next: string[]) => void
setNote(next: string) => void
isScopeGranted(value: string) => boolean
getRootProps() => T['element']
getPendingIndicatorProps() => T['element']
getTitleProps() => T['element']
getDescriptionProps() => T['element']
getLiveRegionProps() => T['element']
getGroupProps() => T['element']
getItemProps(scope: ApprovalScope) => T['element']
getItemIndicatorProps(scope: ApprovalScope) => T['element']
getItemTextProps(scope: ApprovalScope) => T['element']
getNoteProps() => T['input']
getTimerProps() => T['element']
getResultProps() => T['element']
getFooterProps() => T['element']
getApproveTriggerProps() => T['button']
getDenyTriggerProps() => T['button']

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
Enter / Spaceapproval.kbd.approve
Enter / Spaceapproval.kbd.deny
Spaceapproval.kbd.scope-toggle
Enter / Spaceapproval.kbd.press
Spaceapproval.kbd.item-press
Escapeapproval.kbd.escape
Enter / Space / Escapeapproval.kbd.deny-reason

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-describedbyid of the description part | undefined
rootaria-labelledbyid of the title part | undefined
rootrole'group'
pending-indicatoraria-hidden'true'
live-regionaria-atomic'true'
live-regionaria-liveprops.live
grouparia-labeltranslations.scopes
grouprole'group'
itemaria-checked'true' | 'false'
itemaria-disabled'true' | 'false'
itemaria-required'true' | 'false'
itemrole'checkbox'
item-indicatoraria-hidden'true'
notearia-invalid'true' | undefined
notearia-labeltranslations.reason | translations.note
notearia-required'true' | undefined
timeraria-hidden'true'
resultaria-hidden'true'
approve-triggeraria-busy'true' | undefined
approve-triggeraria-disabled'true' | 'false'
approve-triggeraria-labeltranslations.approve
deny-triggeraria-busy'true' | undefined
deny-triggeraria-disabled'true' | 'false'
deny-triggeraria-labeltranslations.deny

Style reference ​

Skin ​

@xihan-ui/styles/approval.css is written against [data-scope="approval"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-approval 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-loading'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-state'pending' | 'approved' | 'denied' | 'expired'
rootdata-toneprops.tone
rootdata-variantprops.variant
pending-indicatordata-state'pending' | 'approved' | 'denied' | 'expired'
itemdata-disabled'' (present only while the condition holds)
itemdata-pressed'' (present only while the condition holds)
itemdata-state'checked' | 'unchecked'
itemdata-valueitem.value
itemdata-xh-action-control''
itemdata-xh-action-display'always'
itemdata-xh-action-profile'row'
itemdata-xh-action-sizeprops.size
itemdata-xh-action-variant'ghost'
item-indicatordata-state'checked' | 'unchecked'
item-textdata-valueitem.value
notedata-invalid'' (present only while the condition holds)
notedata-state'pending' | 'approved' | 'denied' | 'expired'
timerdata-state'pending' | 'approved' | 'denied' | 'expired'
resultdata-state'pending' | 'approved' | 'denied' | 'expired'
resultdata-tone'success' | 'danger' | undefined
footerdata-loading'' (present only while the condition holds)
footerdata-xh-loading-ring''
approve-triggerdata-disabled'' (present only while the condition holds)
approve-triggerdata-loading'' (present only while the condition holds)
approve-triggerdata-pressed'' (present only while the condition holds)
approve-triggerdata-state'pending' | 'approved' | 'denied' | 'expired'
approve-triggerdata-toneprops.tone
approve-triggerdata-xh-action-control''
approve-triggerdata-xh-action-display'always'
approve-triggerdata-xh-action-profile'text'
approve-triggerdata-xh-action-sizeprops.size
approve-triggerdata-xh-action-variant'solid'
approve-triggerdata-xh-ink-surface''
deny-triggerdata-disabled'' (present only while the condition holds)
deny-triggerdata-loading'' (present only while the condition holds)
deny-triggerdata-pressed'' (present only while the condition holds)
deny-triggerdata-state'pending' | 'approved' | 'denied' | 'expired'
deny-triggerdata-xh-action-control''
deny-triggerdata-xh-action-display'always'
deny-triggerdata-xh-action-profile'text'
deny-triggerdata-xh-action-sizeprops.size
deny-triggerdata-xh-action-variant'outline'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-approval-action-font-sizeapprove-trigger
deny-trigger
font-sizedefault--xh-text-label-size
--xh-approval-action-font-weightapprove-trigger
deny-trigger
font-weightdefault--xh-text-label-weight
--xh-approval-action-happrove-trigger
deny-trigger
block-size
min-block-size
default
xh-action-profile=row
--xh-_approval-action-h
--xh-approval-action-pxapprove-trigger
deny-trigger
padding-inlinedefault--xh-_approval-action-px
--xh-approval-action-radiusapprove-trigger
deny-trigger
border-radiusdefault--xh-shape-control
--xh-approval-approve-bgapprove-trigger--xh-ink-surface
background-color
default
loading
xh-ink-surface
--xh-_action-variant-bg-loading
--xh-_action-variant-bg-rest
--xh-approval-approve-bg-hoverapprove-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-approval-approve-bg-offapprove-trigger--xh-ink-surface
background-color
disabled
xh-ink-surface
--xh-_action-variant-bg-disabled
--xh-approval-approve-fgapprove-triggercolordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-loading
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-approval-approve-shadowapprove-triggerbox-shadowdefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_highlight-tone
--xh-approval-bgrootbackgrounddefault
variant=subtle
--xh-bg-subtle
--xh-bg-surface
--xh-approval-borderrootborder
border-color
default
tone
--xh-_tone
--xh-border-default
--xh-approval-border-settledrootborder-colornot([data-state='pending'])
state=pending
--xh-border-default
--xh-approval-deny-bgdeny-trigger--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-approval-deny-bg-hoverdeny-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-approval-deny-bg-offdeny-trigger--xh-ink-surface
background-color
disabled
xh-ink-surface
--xh-_action-variant-bg-disabled
--xh-approval-deny-borderdeny-triggerborderdefault--xh-_action-variant-border-rest
--xh-approval-deny-border-offdeny-triggerborder-colordisabled--xh-_action-variant-border-disabled
--xh-approval-deny-fgdeny-triggercolordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-fg-hover
--xh-_action-variant-fg-pressed
--xh-_action-variant-fg-rest
--xh-approval-description-fgdescriptioncolordefault--xh-fg-muted
--xh-approval-description-font-sizedescriptionfont-sizedefault--xh-text-secondary-size
--xh-approval-footer-gapfootergapdefault--xh-space-2
--xh-approval-gaprootgapdefault--xh-_approval-gap
--xh-approval-group-gapgroupgapdefault--xh-space-1
--xh-approval-icon-sizeroot--xh-icon-sizedefault--xh-_approval-icon-size
--xh-approval-indicator-bg-checkeditem-indicatorbackgroundstate=checked--xh-bg-brand
--xh-approval-indicator-borderitem-indicatorborderdefault--xh-border-control
--xh-approval-indicator-border-checkeditem-indicatorborder-colorstate=checked--xh-bg-brand
--xh-approval-indicator-fgitem-indicatorcolordefault--xh-fg-on-brand
--xh-approval-indicator-icon-sizeitem-indicator--xh-icon-sizedefault--xh-_approval-indicator-glyph
--xh-approval-indicator-radiusitem-indicatorborder-radiusdefault--xh-shape-inset
--xh-approval-indicator-sizeitem-indicator--xh-icon-size
block-size
inline-size
default--xh-control-indicator-size
--xh-approval-item-bg-hoveritembackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-approval-item-font-sizeitemfont-sizedefault--xh-_approval-item-font-size
--xh-approval-item-gapitemgapdefault--xh-space-1_5
--xh-approval-item-pxitempadding-inlinedefault--xh-space-2
--xh-approval-item-pyitempadding-blockxh-action-profile=row--xh-space-1
--xh-approval-item-radiusitemborder-radiusdefault--xh-_action-profile-radius
--xh-approval-item-text-fgitem-textcolordefault--xh-fg-muted
--xh-approval-item-text-fg-checkeditem
item-text
colorstate=checked--xh-fg-default
--xh-approval-loading-durationfooteranimationxh-loading-ring--xh-motion-loop-spin
--xh-approval-note-bgnotebackgrounddefault--xh-bg-field
--xh-approval-note-bg-disablednotebackgrounddisabled--xh-bg-subtle
--xh-approval-note-bg-focusnotebackgroundfocus-within--xh-bg-surface
--xh-approval-note-bg-invalidnotebackgroundinvalid--xh-bg-field-invalid
--xh-approval-note-bordernoteborderdefault--xh-border-control
--xh-approval-note-border-disablednoteborder-colordisabled--xh-border-default
--xh-approval-note-border-focusnoteborder-color
box-shadow
focus-within--xh-border-control-focus
--xh-approval-note-border-hovernoteborder-colorhover
invalid
not(:disabled, :focus, [data-invalid])
--xh-border-strong
--xh-approval-note-border-invalidnoteborder-colorinvalid--xh-border-invalid
--xh-approval-note-fgnotecolordefault--xh-fg-default
--xh-approval-note-font-sizenotefont-sizedefault--xh-_approval-note-font-size
--xh-approval-note-pxnotepadding-inlinedefault--xh-space-2
--xh-approval-note-pynotepadding-blockdefault--xh-space-1_5
--xh-approval-note-radiusnoteborder-radiusdefault--xh-shape-control
--xh-approval-ppending-indicator
root
inset-block-start
inset-inline-end
padding
default--xh-_approval-p
--xh-approval-pending-indicator-colorpending-indicatorbackgrounddefault--xh-_tone-soft
--xh-approval-pending-indicator-radiuspending-indicatorborder-radiusdefault--xh-shape-circle
--xh-approval-pending-indicator-sizepending-indicatorblock-size
inline-size
default--xh-space-2
--xh-approval-radiusrootborder-radiusdefault--xh-shape-surface
--xh-approval-result-bgresultbackgrounddefault--xh-_tone-subtle
--xh-approval-result-bg-deniedresultbackgroundis([data-state='denied'], [data-state='expired'])
state=denied
state=expired
--xh-_tone-subtle
--xh-approval-result-fgresultcolordefault--xh-_tone-fg
--xh-approval-result-fg-deniedresultcoloris([data-state='denied'], [data-state='expired'])
state=denied
state=expired
--xh-_tone-fg
--xh-approval-result-font-sizeresultfont-sizedefault--xh-text-caption-size
--xh-approval-result-font-weightresultfont-weightdefault--xh-font-weight-medium
--xh-approval-result-gapresultgapdefault--xh-space-1
--xh-approval-result-hresultmin-block-sizedefault--xh-chip-h-sm
--xh-approval-result-pxresultpadding-inlinedefault--xh-space-1_5
--xh-approval-result-pyresultpadding-blockdefault0
--xh-approval-result-radiusresultborder-radiusdefault--xh-shape-control
--xh-approval-shadowrootbox-shadowdefaultnone
--xh-approval-timer-fgtimercolordefault--xh-fg-muted
--xh-approval-timer-font-sizetimerfont-sizedefault--xh-text-caption-size
--xh-approval-title-fgtitlecolordefault--xh-fg-default
--xh-approval-title-font-sizetitlefont-sizedefault--xh-text-label-size
--xh-approval-title-font-weighttitlefont-weightdefault--xh-font-weight-medium

Released under The MIT License