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

查看生态总览
Skip to content

GridList new ​

Data display 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="grid-list": root · label · row · row-selection-indicator · row-content · row-text · row-description · row-actions · row-action · empty · loading

API reference ​

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

Artifacts ​

LayerValue
Custom element<xh-grid-list>
Vue componentsXhGridListEmpty XhGridListLabel XhGridListLoading XhGridListRoot XhGridListRow XhGridListRowAction XhGridListRowActions XhGridListRowContent XhGridListRowDescription XhGridListRowSelectionIndicator XhGridListRowText
ComposableuseGridList
State machinegridListMachine
Skin@xihan-ui/styles/grid-list.css

Props ​

PropTypeRequired
labelledboolean
collectionGridListNode[]
valuestring | string[]
defaultValuestring | string[]
selectionModeGridListSelectionMode
disabledboolean
readOnlyboolean
invalidboolean
loadingboolean
loopboolean
typeaheadboolean
dirDirection
variantControlVariant
toneTone
sizeSize
translationsPartial<GridListTranslations>
onValueChange(details: GridListValueChangeDetails) => void
onAction(details: GridListActionDetails) => void

GridListNode ​

Elements of collection.

FieldTypeRequired
valuestringYes
labelstring
descriptionstring
disabledboolean
toneTone

Events ​

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

EventPayload
value-changeGridListValueChangeDetails
actionGridListActionDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhGridListRootdefault—

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
XhGridListRootchildrenReactNode
XhGridListRowvaluestringYes
XhGridListRowdisabledboolean

State ​

Public state is written to data-state.

PartValues
row'checked' | 'unchecked'
row-selection-indicator'checked' | 'unchecked'
row-content'checked' | 'unchecked'
row-text'checked' | 'unchecked'
row-description'checked' | 'unchecked'
row-actions'checked' | 'unchecked'
row-action'checked' | 'unchecked'

The following names are internal to the state machine.

States: idle

Events: VALUE.SET · ROW.SELECT · ROW.TOGGLE · ROW.EXTEND · ROW.ACTION · ROW.FOCUS · GRID.BLUR · PRESS.START · PRESS.END

Guards: canPress

connect API ​

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

MemberType
valuestring[]
collectionreadonly GridListNodeMeta[]
selectionModeGridListSelectionMode
focusedValuestring | null
disabledboolean
readOnlyboolean
invalidboolean
loadingboolean
isSelected(value: string) => boolean
setValue(next: string[]) => void
select(value: string) => void
toggle(value: string) => void
action(value: string) => void
getRootProps() => T['element']
getLabelProps() => T['element']
getRowProps(props: GridListRowProps) => T['element']
getRowSelectionIndicatorProps(props: GridListRowProps) => T['element']
getRowContentProps(props: GridListRowProps) => T['element']
getRowTextProps(props: GridListRowProps) => T['element']
getRowDescriptionProps(props: GridListRowProps) => T['element']
getRowActionsProps(props: GridListRowProps) => T['element']
getRowActionProps(props: GridListRowProps) => T['button']
getEmptyProps() => T['element']
getLoadingProps() => 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
Tab / Shift+Tabgrid-list.kbd.tab
ArrowDowngrid-list.kbd.next
ArrowUpgrid-list.kbd.prev
Homegrid-list.kbd.first
Endgrid-list.kbd.last
Spacegrid-list.kbd.select
Shift+ArrowDown / Shift+ArrowUp / Shift+Home / Shift+Endgrid-list.kbd.extend
Shift+Spacegrid-list.kbd.extend-select
Entergrid-list.kbd.action
Ctrl+A / Cmd+Agrid-list.kbd.select-all
any single printable charactergrid-list.kbd.typeahead
Enter / Spacegrid-list.kbd.inline-action

ARIA ​

These attributes are produced by connect.

PartAttributeValue
rootaria-busy'true' | undefined
rootaria-disabled'true' | 'false'
rootaria-invalid'true' | 'false'
rootaria-labeltranslations.root
rootaria-labelledbyid of the label part | undefined
rootaria-multiselectable'true' | undefined
rootaria-readonly'true' | 'false'
rootrole'grid'
rowaria-disabled'true' | 'false'
rowaria-selected'true' | 'false' | undefined
rowrole'row'
row-selection-indicatoraria-hidden'true'
row-contentrole'gridcell'
row-actionsrole'gridcell'

Style reference ​

Skin ​

@xihan-ui/styles/grid-list.css is written against [data-scope="grid-list"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-grid-list 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-loading'' (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)
rowdata-disabled'' (present only while the condition holds)
rowdata-highlighted'' (present only while the condition holds)
rowdata-pressed'' (present only while the condition holds)
rowdata-state'checked' | 'unchecked'
rowdata-tonemetaOf.get(row.value)?.tone
rowdata-xh-collection-context'page'
rowdata-xh-collection-item''
rowdata-xh-collection-sizeprops.size
row-selection-indicatordata-disabled'' (present only while the condition holds)
row-selection-indicatordata-highlighted'' (present only while the condition holds)
row-selection-indicatordata-state'checked' | 'unchecked'
row-selection-indicatordata-xh-check-mark'checked' | 'unchecked'
row-selection-indicatordata-xh-check-mark-profile'box'
row-selection-indicatordata-xh-collection-slot'prefix'
row-contentdata-disabled'' (present only while the condition holds)
row-contentdata-highlighted'' (present only while the condition holds)
row-contentdata-state'checked' | 'unchecked'
row-textdata-disabled'' (present only while the condition holds)
row-textdata-highlighted'' (present only while the condition holds)
row-textdata-state'checked' | 'unchecked'
row-textdata-xh-collection-slot'text'
row-descriptiondata-disabled'' (present only while the condition holds)
row-descriptiondata-highlighted'' (present only while the condition holds)
row-descriptiondata-state'checked' | 'unchecked'
row-descriptiondata-xh-collection-slot'description'
row-actionsdata-disabled'' (present only while the condition holds)
row-actionsdata-highlighted'' (present only while the condition holds)
row-actionsdata-state'checked' | 'unchecked'
row-actiondata-disabled'' (present only while the condition holds)
row-actiondata-highlighted'' (present only while the condition holds)
row-actiondata-state'checked' | 'unchecked'
row-actiondata-xh-action-control''
row-actiondata-xh-action-display'always'
row-actiondata-xh-action-profile'text'
row-actiondata-xh-action-size'xs'
row-actiondata-xh-action-variant'ghost'
loadingdata-loading'' (present only while the condition holds)
loadingdata-xh-loading-ring''

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-grid-list-bgrootbackgrounddefault
variant=outline
variant=subtle
--xh-bg-subtle
--xh-bg-surface
transparent
--xh-grid-list-borderrootborder-colorvariant=outline--xh-border-default
--xh-grid-list-border-invalidrootborder-colorinvalid--xh-border-invalid
--xh-grid-list-gaprootgapdefault--xh-list-option-gap
--xh-grid-list-icon-sizeroot--xh-icon-sizedefault
size=lg
size=sm
--xh-glyph-size-lg
--xh-glyph-size-md
--xh-glyph-size-sm
--xh-grid-list-label-fglabelcolordefault--xh-fg-default
--xh-grid-list-label-font-sizelabelfont-sizedefault--xh-text-label-size
--xh-grid-list-label-font-weightlabelfont-weightdefault--xh-font-weight-medium
--xh-grid-list-label-pxlabelpadding-inlinedefault--xh-control-px-md
--xh-grid-list-label-pylabelpadding-blockdefault--xh-space-1
--xh-grid-list-prootpaddingdefault--xh-space-1
--xh-grid-list-radiusrootborder-radiusdefault--xh-shape-surface
--xh-grid-list-row-action-font-sizerow-actionfont-sizedefault--xh-control-font-sm
--xh-grid-list-row-actions-gaprow-actionsgapdefault--xh-space-1
--xh-grid-list-row-actions-msrow-actionsmargin-inline-startdefault--xh-control-gap-md
--xh-grid-list-row-bg-selectedrowbackground-colordisabled
error
highlighted
is(:focus-visible, [data-highlighted])
is([aria-selected='true'], [data-selected])
not(:focus-visible)
not([aria-disabled='true'], [data-disabled], [aria-busy='true'], [data-error])
selected
xh-collection-context=page
--xh-bg-brand-subtle
--xh-grid-list-row-content-gaprow-contentgapdefault--xh-space-1
--xh-grid-list-row-description-fgrow-descriptioncolordefault--xh-fg-muted
--xh-grid-list-row-description-font-sizerow-descriptionfont-sizedefault--xh-control-caption-md
--xh-grid-list-row-fg-selectedrowcolordisabled
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=page
--xh-fg-on-brand-subtle
--xh-grid-list-row-indicator-bgrow-selection-indicatorbackgrounddefaulttransparent
--xh-grid-list-row-indicator-bg-selectedrow-selection-indicatorbackgroundstate=checked--xh-_grid-list-indicator-accent
--xh-grid-list-row-indicator-borderrow-selection-indicatorborderdefault--xh-border-control
--xh-grid-list-row-indicator-border-selectedrow-selection-indicatorborder-colorstate=checked--xh-_grid-list-indicator-accent
--xh-grid-list-row-indicator-fg-selectedrow-selection-indicatorcolordefault--xh-_grid-list-indicator-on-accent
--xh-grid-list-row-indicator-glyph-sizerow-selection-indicator--xh-icon-sizedefault--xh-_grid-list-indicator-glyph
--xh-grid-list-row-indicator-merow-selection-indicatormargin-inline-enddefault--xh-control-gap-md
--xh-grid-list-row-indicator-radiusrow-selection-indicatorborder-radiusdefault--xh-shape-inset
--xh-grid-list-row-indicator-sizerow-selection-indicatorblock-size
inline-size
default--xh-_grid-list-indicator
--xh-grid-list-row-loading-opacityroot
row
opacityloading--xh-state-disabled-opacity
--xh-grid-list-row-radiusrowborder-radiusdefault--xh-shape-control
--xh-grid-list-state-fgempty
loading
colordefault--xh-fg-muted
--xh-grid-list-state-font-sizeempty
loading
font-sizedefault--xh-_grid-list-state-font-size
--xh-grid-list-state-gapempty
loading
gapdefault--xh-control-gap-md
--xh-grid-list-state-pxempty
loading
padding-inlinedefault--xh-_grid-list-state-px
--xh-grid-list-state-pyempty
loading
padding-blockdefault--xh-space-3

Released under The MIT License