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

查看生态总览
Skip to content

FieldArray ​

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="field-array": root · table · header · column-header · item · item-label · item-content · item-cell · item-action · add-trigger · item-delete-trigger · item-drag-trigger · move-up-trigger · move-down-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-field-array>
Vue componentsXhFieldArrayAddTrigger XhFieldArrayColumnHeader XhFieldArrayHeader XhFieldArrayItem XhFieldArrayItemAction XhFieldArrayItemCell XhFieldArrayItemContent XhFieldArrayItemDeleteTrigger XhFieldArrayItemDragTrigger XhFieldArrayItemLabel XhFieldArrayMoveDownTrigger XhFieldArrayMoveUpTrigger XhFieldArrayRoot XhFieldArrayTable
ComposableuseFieldArray
State machinefieldArrayMachine
Skin@xihan-ui/styles/field-array.css

Props ​

PropTypeRequired
valueunknown[]
defaultValueunknown[]
minnumber
maxnumber
createItem() => unknown
movableboolean
stickyActionsboolean
ariaLabelstring
disabledboolean
readOnlyboolean
invalidboolean
layoutFieldArrayLayout
columnsFieldArrayColumn[]
nameFormPath
translationsPartial<FieldArrayTranslations>
onValueChange(details: FieldArrayValueChangeDetails) => void

FieldArrayColumn ​

Elements of columns.

FieldTypeRequired
idstringYes
labelstring
widthstring | number
minWidthstring | number

Events ​

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

EventPayload
value-changeFieldArrayValueChangeDetails

Slots ​

Only slots with a payload are listed.

Vue componentSlotPayload
XhFieldArrayRootdefaultFieldArrayRootSlotProps
XhFieldArrayRootitem-contentFieldArrayItemContentSlotProps
XhFieldArrayRootitem-cellFieldArrayItemCellSlotProps

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
XhFieldArrayColumnHeadervaluestringYes
XhFieldArrayItemindexnumber | stringYes
XhFieldArrayItemCellvaluestringYes
XhFieldArrayRootrenderItemContent(item: FieldArrayItem) => ReactNode
XhFieldArrayRootrenderItemCell(item: FieldArrayItem, column: FieldArrayColumn) => ReactNode
XhFieldArrayRootchildrenSlotChildren<FieldArrayRootSlotProps>

State ​

The following names are internal to the state machine.

States: idle

Events: VALUE.SET · ITEM.ADD · ITEM.REMOVE · ITEM.MOVE · FORM.RESET · PRESS.START · PRESS.END · LIST.TRACKED

Guards: canAdd · canRemove · canMove · canPress

connect API ​

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

MemberType
valueunknown[]
itemsFieldArrayItem[]
countnumber
emptyboolean
disabledboolean
readOnlyboolean
invalidboolean
movableboolean
stickyActionsboolean
draggingboolean
layoutFieldArrayLayout
columnsFieldArrayColumn[]
atMinboolean
atMaxboolean
canAddboolean
translationsFieldArrayTranslations
setValue(next: unknown[]) => void
add() => void
insert(index: number, item?: unknown) => void
remove(index: number) => void
move(from: number, to: number) => void
moveUp(index: number) => void
moveDown(index: number) => void
getRootProps() => T['element']
getTableProps() => T['element']
getHeaderProps() => T['element']
getColumnHeaderProps(column: FieldArrayColumnProps) => T['element']
getItemProps(item: FieldArrayItemProps) => T['element']
getItemCellProps(cell: FieldArrayItemCellProps) => T['element']
getItemLabelProps(item: FieldArrayItemProps) => T['element']
getItemContentProps(item: FieldArrayItemProps) => T['element']
getItemActionProps(item: FieldArrayItemProps) => T['element']
getAddTriggerProps() => T['button']
getItemDeleteTriggerProps(item: FieldArrayItemProps) => T['button']
getMoveUpTriggerProps(item: FieldArrayItemProps) => T['button']
getMoveDownTriggerProps(item: FieldArrayItemProps) => T['button']
getItemDragTriggerProps(item: FieldArrayItemProps) => 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 / Spacefield-array.kbd.press

ARIA ​

These attributes are produced by connect.

PartAttributeValue
tablearia-labelprops.ariaLabel | undefined
tablearia-rowcountcount + 1 | undefined
tablerole'table' | undefined
headeraria-rowindex1 | undefined
headerrole'row' | undefined
column-headerrole'columnheader' | undefined
itemaria-rowindexitem.index + 2 | undefined
itemrole'row' | undefined
item-labelrole'rowheader' | undefined
item-cellrole'cell' | undefined
item-actionrole'cell' | undefined
add-triggeraria-disabled'false' | 'true'
item-delete-triggeraria-disabled'false' | 'true'
item-delete-triggeraria-labellabel.deleteItem(item.index + 1, count)
item-drag-triggeraria-hidden'true'

Style reference ​

Skin ​

@xihan-ui/styles/field-array.css is written against [data-scope="field-array"][data-part="root"] part selectors; the published build uses the mount class .xh-scope-field-array 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-max'' (present only while the condition holds)
rootdata-at-min'' (present only while the condition holds)
rootdata-disabled'' (present only while the condition holds)
rootdata-dragging'' (present only while the condition holds)
rootdata-empty'' (present only while the condition holds)
rootdata-instant'' (present only while the condition holds)
rootdata-invalid'' (present only while the condition holds)
rootdata-layout'table' | 'list'
rootdata-movable'' (present only while the condition holds)
rootdata-readonly'' (present only while the condition holds)
tabledata-at-max-horizontal'' (present only while the condition holds)
tabledata-at-min-horizontal'' (present only while the condition holds)
tabledata-layout'table' | 'list'
headerdata-frozen-actions'' (present only while the condition holds)
headerdata-layout'table' | 'list'
column-headerdata-layout'table' | 'list'
column-headerdata-valuecolumn.value
itemdata-animatingdragged['data-animating']
itemdata-at-max'' (present only while the condition holds)
itemdata-at-min'' (present only while the condition holds)
itemdata-disabled'' (present only while the condition holds)
itemdata-draggingdragged['data-dragging']
itemdata-first'' (present only while the condition holds)
itemdata-indexString(item.index)
itemdata-invalid'' (present only while the condition holds)
itemdata-last'' (present only while the condition holds)
itemdata-layout'table' | 'list'
itemdata-readonly'' (present only while the condition holds)
item-labeldata-at-max'' (present only while the condition holds)
item-labeldata-at-min'' (present only while the condition holds)
item-labeldata-disabled'' (present only while the condition holds)
item-labeldata-indexString(item.index)
item-labeldata-invalid'' (present only while the condition holds)
item-labeldata-layout'table' | 'list'
item-labeldata-readonly'' (present only while the condition holds)
item-contentdata-at-max'' (present only while the condition holds)
item-contentdata-at-min'' (present only while the condition holds)
item-contentdata-disabled'' (present only while the condition holds)
item-contentdata-indexString(item.index)
item-contentdata-invalid'' (present only while the condition holds)
item-contentdata-layout'table' | 'list'
item-contentdata-readonly'' (present only while the condition holds)
item-celldata-at-max'' (present only while the condition holds)
item-celldata-at-min'' (present only while the condition holds)
item-celldata-disabled'' (present only while the condition holds)
item-celldata-indexString(item.index)
item-celldata-invalid'' (present only while the condition holds)
item-celldata-layout'table' | 'list'
item-celldata-readonly'' (present only while the condition holds)
item-celldata-valuecell.value
item-actiondata-at-max'' (present only while the condition holds)
item-actiondata-at-min'' (present only while the condition holds)
item-actiondata-disabled'' (present only while the condition holds)
item-actiondata-frozen'end' | undefined
item-actiondata-indexString(item.index)
item-actiondata-invalid'' (present only while the condition holds)
item-actiondata-layout'table' | 'list'
item-actiondata-readonly'' (present only while the condition holds)
add-triggerdata-disabled'' (present only while the condition holds)
add-triggerdata-pressed'' (present only while the condition holds)
add-triggerdata-xh-action-control''
add-triggerdata-xh-action-display'always'
add-triggerdata-xh-action-profile'text'
add-triggerdata-xh-action-size'md'
add-triggerdata-xh-action-variant'outline'
item-delete-triggerdata-at-max'' (present only while the condition holds)
item-delete-triggerdata-at-min'' (present only while the condition holds)
item-delete-triggerdata-disabled'' (present only while the condition holds)
item-delete-triggerdata-indexString(item.index)
item-delete-triggerdata-invalid'' (present only while the condition holds)
item-delete-triggerdata-layout'table' | 'list'
item-delete-triggerdata-pressed'' (present only while the condition holds)
item-delete-triggerdata-readonly'' (present only while the condition holds)
item-delete-triggerdata-xh-action-control''
item-delete-triggerdata-xh-action-display'always'
item-delete-triggerdata-xh-action-profile'icon'
item-delete-triggerdata-xh-action-size'xs'
item-delete-triggerdata-xh-action-variant'ghost'
item-drag-triggerdata-at-max'' (present only while the condition holds)
item-drag-triggerdata-at-min'' (present only while the condition holds)
item-drag-triggerdata-disabled'' (present only while the condition holds)
item-drag-triggerdata-dragginggrip['data-dragging']
item-drag-triggerdata-indexString(item.index)
item-drag-triggerdata-invalid'' (present only while the condition holds)
item-drag-triggerdata-layout'table' | 'list'
item-drag-triggerdata-pressedgrip['data-pressed']
item-drag-triggerdata-readonly'' (present only while the condition holds)
item-drag-triggerdata-xh-action-control''
item-drag-triggerdata-xh-action-display'always'
item-drag-triggerdata-xh-action-profile'icon'
item-drag-triggerdata-xh-action-size'xs'
item-drag-triggerdata-xh-action-variant'ghost'
move-up-triggerdata-pressed'' (present only while the condition holds)
move-up-triggerdata-xh-action-control''
move-up-triggerdata-xh-action-display'always'
move-up-triggerdata-xh-action-profile'icon'
move-up-triggerdata-xh-action-size'xs'
move-up-triggerdata-xh-action-variant'ghost'
move-down-triggerdata-pressed'' (present only while the condition holds)
move-down-triggerdata-xh-action-control''
move-down-triggerdata-xh-action-display'always'
move-down-triggerdata-xh-action-profile'icon'
move-down-triggerdata-xh-action-size'xs'
move-down-triggerdata-xh-action-variant'ghost'

CSS variables ​

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

VariablePartCSS propertyStateDefault from
--xh-field-array-action-gapadd-trigger
item-action
gapdefault--xh-space-1
--xh-field-array-add-bgadd-trigger--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-field-array-add-bg-activeadd-triggerbackground-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-field-array-add-bg-hoveradd-triggerbackground-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-field-array-add-borderadd-triggerborderdefault--xh-_action-variant-border-rest
--xh-field-array-add-border-disabledadd-triggerborder-colordisabled--xh-_action-variant-border-disabled
--xh-field-array-add-border-hoveradd-triggerborder-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-border-hover
--xh-field-array-add-fgadd-triggercolordefault
disabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-brand
--xh-field-array-add-font-sizeadd-triggerfont-sizedefault--xh-text-label-size
--xh-field-array-add-heightadd-triggerblock-size
inline-size
default
xh-action-profile=icon
--xh-_action-profile-visual-size
--xh-field-array-add-pxadd-triggerpadding-inlinedefault--xh-_action-profile-padding-inline
--xh-field-array-add-radiusadd-triggerborder-radiusdefault--xh-shape-control
--xh-field-array-cell-control-hitem-action
item-cell
item-label
min-block-sizeis([data-part='item-cell'], [data-part='item-label'], [data-part='item-action'])
layout=table
--xh-_field-array-cell-control-h
--xh-field-array-cell-pxcolumn-header
item-action
item-cell
item-label
padding-inlineis([data-part='item-cell'], [data-part='item-label'], [data-part='item-action'])
layout=table
--xh-table-cell-px-md
--xh-field-array-cell-pycolumn-header
item-action
item-cell
item-label
padding-blockis([data-part='item-cell'], [data-part='item-label'], [data-part='item-action'])
layout=table
--xh-table-cell-py-md
--xh-field-array-column-header-fgcolumn-headercolorlayout=table--xh-fg-default
--xh-field-array-column-header-font-weightcolumn-headerfont-weightlayout=table--xh-font-weight-medium
--xh-field-array-content-gapitem-contentgapdefault--xh-space-2
--xh-field-array-drag-grip-hitem-drag-triggerblock-sizeempty--xh-space-3
--xh-field-array-drag-grip-witem-drag-triggerinline-sizeempty--xh-space-1
--xh-field-array-frozen-bgitem-action
item-label
backgroundis([data-part='item-label'], [data-part='item-action'])
layout=table
--xh-field-array-table-bg
--xh-field-array-frozen-edgeheader
item
item-action
item-label
table
border-inline-end-color
border-inline-start-color
at-max-horizontal
at-min-horizontal
frozen-actions
frozen=end
is([data-part='item'], [data-part='header'])
layout=table
not([data-at-max-horizontal])
not([data-at-min-horizontal])
--xh-border-default
--xh-field-array-frozen-header-bgheaderbackgroundlayout=table--xh-bg-subtle-opaque
--xh-field-array-gaprootgapdefault--xh-space-2
--xh-field-array-header-bgheaderbackgroundlayout=table--xh-bg-subtle
--xh-field-array-icon-sizeadd-trigger
item-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
--xh-icon-sizedefault--xh-_action-profile-glyph-size
--xh-field-array-item-bg-draggingitembackgrounddragging--xh-bg-surface
--xh-field-array-item-delete-fg-hoveritem-delete-triggercolordisabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-danger-hover
--xh-field-array-item-gapitemgapdefault--xh-space-2
--xh-field-array-item-label-fgitem-labelcolordefault--xh-fg-muted
--xh-field-array-item-label-font-sizeitem-labelfont-sizedefault--xh-text-secondary-size
--xh-field-array-item-paddingitempaddingdefault--xh-space-0
--xh-field-array-item-radiusitemborder-radiusdefault--xh-shape-surface
--xh-field-array-item-shadow-draggingitembox-shadowdragging--xh-elevation-lifted
--xh-field-array-row-dividerheader
item
border-block-end
border-block-start
layout=table--xh-border-subtle
--xh-field-array-sticky-column-layerheader
item-action
item-label
z-indexfrozen-actions
frozen=end
layout=table
1
--xh-field-array-table-bgitem-action
item-label
table
backgroundis([data-part='item-label'], [data-part='item-action'])
layout=table
--xh-bg-surface
--xh-field-array-table-bordertableborderlayout=table--xh-border-default
--xh-field-array-table-radiusheader
table
border-radius
border-start-end-radius
border-start-start-radius
layout=table--xh-shape-surface
--xh-field-array-trigger-bgitem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
--xh-ink-surface
background-color
default
xh-ink-surface
--xh-_action-variant-bg-rest
--xh-field-array-trigger-bg-activeitem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
background-colordisabled
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-_action-variant-bg-pressed
--xh-field-array-trigger-bg-hoveritem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
background-colordisabled
hover
loading
not([data-disabled])
not([data-loading])
--xh-_action-variant-bg-hover
--xh-field-array-trigger-fgitem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
colordefault--xh-fg-muted
--xh-field-array-trigger-fg-hoveritem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
colordisabled
hover
is(:active, [data-pressed])
loading
not([data-disabled])
not([data-loading])
pressed
--xh-fg-default
--xh-field-array-trigger-font-sizeitem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
font-sizedefault--xh-text-secondary-size
--xh-field-array-trigger-radiusitem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
border-radiusdefault--xh-shape-control
--xh-field-array-trigger-sizeitem-delete-trigger
item-drag-trigger
move-down-trigger
move-up-trigger
block-size
inline-size
min-inline-size
default
xh-action-profile=icon
--xh-_action-profile-visual-size

Released under The MIT License