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

查看生态总览
Skip to content

Log ​

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="log": root · viewport · content · line · segment · scroll-to-end-trigger · live-region

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-log>
Vue componentsXhLogContent XhLogLine XhLogLiveRegion XhLogRoot XhLogScrollToEndTrigger XhLogSegment XhLogViewport
ComposableuseLog
State machinelogMachine
Skin@xihan-ui/styles/log.css

Props ​

PropTypeRequired
thresholdnumber
virtualizerCollectionVirtualizer
onStickChange(details: LogStickChangeDetails) => void
levelsreadonly LogLevel[]
loadingboolean
rowsnumber
sizeSize
translationsPartial<LogTranslations>

Events ​

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

EventPayload
stick-changeLogStickChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhLogRootdefaultLogRootSlotProps

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
XhLogLinelevelLogLevel
XhLogLineansistring
XhLogRootchildrenSlotChildren<LogRootSlotProps>
XhLogSegmentsegmentLogAnsiSegmentYes

State ​

Public state is written to data-state.

PartValues
scroll-to-end-trigger'visible' | 'hidden'

The following names are internal to the state machine.

States: idle

Events: STICK.CHANGE · SCROLL_TO_BOTTOM · PRESS.START · PRESS.END · TRIGGER.RENDERED

Guards: canPress

connect API ​

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

MemberType
rowsnumber | undefined
loadingboolean
atBottomboolean
stickingboolean
showScrollToEndTriggerboolean
virtualizedboolean
isLevelVisible(level?: LogLevel) => boolean
scrollToBottom() => void
getRootProps() => T['element']
getViewportProps() => T['element']
getContentProps() => T['element']
getLineProps(props?: LogLineProps) => T['element']
getSegmentProps(segment: LogAnsiSegment) => T['element']
getScrollToEndTriggerProps() => T['button']
getLiveRegionProps() => 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
Tablog.kbd.viewport-tab
Space / Enterlog.kbd.scroll-to-end-trigger
Space / Enterlog.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
viewportaria-busy'true' | undefined
viewportaria-labellabel.log
viewportaria-live'off'
viewportrole'log'
scroll-to-end-triggeraria-labellabel.scrollToBottom
live-regionaria-atomic'true'
live-regionaria-live'polite'
live-regionrole'status'

Style reference ​

Skin ​

@xihan-ui/styles/log.css is written against [data-scope="log"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-log 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-at-bottom'' (present only while the condition holds)
rootdata-loading'' (present only while the condition holds)
rootdata-sizeprops.size
rootdata-sticking'' (present only while the condition holds)
viewportdata-virtualized'' (present only while the condition holds)
linedata-levelline?.level
segmentdata-bold'' (present only while the condition holds)
segmentdata-bright'' (present only while the condition holds)
segmentdata-dim'' (present only while the condition holds)
segmentdata-fgsegment.fg
segmentdata-italic'' (present only while the condition holds)
segmentdata-underline'' (present only while the condition holds)
scroll-to-end-triggerdata-pressed'' (present only while the condition holds)
scroll-to-end-triggerdata-state'visible' | 'hidden'
scroll-to-end-triggerdata-xh-action-control''
scroll-to-end-triggerdata-xh-action-display'always'
scroll-to-end-triggerdata-xh-action-profile'floating'
scroll-to-end-triggerdata-xh-action-sizefloatingSizeBelow(props.size)
scroll-to-end-triggerdata-xh-action-variant'ghost'
scroll-to-end-triggerdata-xh-liquid''
scroll-to-end-triggerdata-xh-material'frosted'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-log-ansi-blacksegmentcolorfg=black--xh-fg-default
--xh-log-ansi-bluesegmentcolorfg=blue--xh-fg-info
--xh-log-ansi-bold-weightsegmentfont-weightbold--xh-font-weight-semibold
--xh-log-ansi-cyansegmentcolorfg=cyan--xh-syntax-string
--xh-log-ansi-dim-fgsegmentcolordim
fg
not([data-fg])
--xh-fg-subtle
--xh-log-ansi-greensegmentcolorfg=green--xh-fg-success
--xh-log-ansi-magentasegmentcolorfg=magenta--xh-syntax-keyword
--xh-log-ansi-redsegmentcolorfg=red--xh-fg-danger
--xh-log-ansi-whitesegmentcolorfg=white--xh-fg-muted
--xh-log-ansi-yellowsegmentcolorfg=yellow--xh-fg-warning
--xh-log-bgrootbackgrounddefault--xh-bg-surface
--xh-log-borderrootborderdefault--xh-border-default
--xh-log-content-pxcontent
line
viewport
padding-inlinedefault
virtualized
--xh-_log-content-px
--xh-log-fgrootcolordefault--xh-fg-default
--xh-log-fontcontent
viewport
font-familydefault
virtualized
--xh-font-family-mono
--xh-log-font-sizecontent
viewport
font-sizedefault
virtualized
--xh-_log-font-size
--xh-log-icon-sizescroll-to-end-trigger--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-log-level-debug-fglinecolorlevel=debug--xh-fg-subtle
--xh-log-level-error-fglinecolorlevel=error--xh-fg-danger
--xh-log-level-info-fglinecolorlevel=info--xh-fg-default
--xh-log-level-warn-fglinecolorlevel=warn--xh-fg-warning
--xh-log-line-heightline
root
viewport
block-size
line-height
default--xh-text-code-leading
--xh-log-line-pxline
viewport
padding-inlinevirtualized--xh-log-content-px
--xh-log-radiusrootborder-radiusdefault--xh-shape-surface
--xh-log-rowsviewportblock-sizedefault16
--xh-log-scroll-to-end-trigger-bgscroll-to-end-trigger--xh-ink-surface
background-color
default
disabled
focus-visible
xh-ink-surface
--xh-_material-bg
--xh-_material-bg-focus
--xh-log-scroll-to-end-trigger-bg-hoverscroll-to-end-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_material-bg-hover
--xh-log-scroll-to-end-trigger-borderscroll-to-end-triggerborder
border-color
default
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_material-border
--xh-log-scroll-to-end-trigger-fgscroll-to-end-triggercolordefault
disabled
focus-visible
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_material-fg
--xh-log-scroll-to-end-trigger-insetscroll-to-end-triggerinset-block-end
inset-inline-end
default--xh-space-3
--xh-log-scroll-to-end-trigger-radiusscroll-to-end-triggerborder-radiusdefault--xh-shape-circle
--xh-log-scroll-to-end-trigger-shadowscroll-to-end-triggerbox-shadowdefault
disabled
focus-visible
hover
is(:active, [data-pressed])
is(:hover, [data-loading])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_material-shadow
--xh-log-scroll-to-end-trigger-sizescroll-to-end-triggerblock-size
inline-size
default
xh-action-profile=floating
--xh-_action-profile-visual-size
--xh-log-shadowrootbox-shadowdefaultnone
--xh-log-tab-sizelinetab-sizedefault4

Released under The MIT License