Repository navigation
v0.14.0
The ninth Fluent UI v9 parity release: Phase 9 of the roadmap, collections, data grids and guided tours. Overflow hides by priority and in groups, Breadcrumb collapses into a menu (by count or by the room it has), DataGrid renders and sorts its own rows from typed columns and selects on a row click, the static Table gets sortable headers, a selection cell, a cell layout and cell actions, List can be navigated without selecting and gets an action of its own, and TeachingPopover gets footer actions and Fluent's composable parts. Every addition is opt-in, and nothing public was removed; the type widenings and the few markup changes are under "Upgrading from 0.13".
Upgrading from 0.13
DataGridColumnandDataGridare generic over the type of the grid'sitems(DataGridColumn<T = unknown>,DataGridProps<T>,DataGridBaseProps<T>,DataGridBodyProps<T>); without a type argument they keep the 0.13 shape withT = unknown. A column'slabelwidens fromstringtoReactNode(code that reads it as a string narrows it first), and itsidis optional and deprecated, socolumn.idreads asstring | undefined(writecolumnId).DataGridhas two call signatures;React.ComponentProps<typeof DataGrid>is the last one,DataGridProps<unknown>.childrenofDataGridandDataGrid.Bodyis optional, andDataGridBodyProps['children']may be a render function(item, index) => ReactNode(DataGridBodyPropsomits the nativechildren): code that reads it as aReactNodehandles the function.onSortChange(sort)andonSelectedItemsChange(items)get a second argument,details({ event }, the click or key press behind the change). Exact assertions such astoHaveBeenCalledWith(sort)or amock.callsentry compared to a one-element array need it ({ event: expect.any(Event) }). The 0.4 positionalonSortChange(columnId, direction)and the deprecatedonSelectionChange(keys)are unchanged.- A grid with
itemsuses the object form ofonSortChange, with or withoutsortanddefaultSort. Next toitems, the positional callback and the deprecatedsortColumn,sortDirection,defaultSortColumnanddefaultSortDirectionare type errors. At run time a positionalonSortChangeis called in the object form (onSortChange(sort, details)), and only the deprecated sort props are ignored, with a development warning (DataGrid:items-deprecated-sort). Passitems={data ?? []}while the data loads. - A sorted DataGrid header shows an arrow (up for ascending, down for descending:
<svg data-wave-icon="sort-arrow-up">or"sort-arrow-down", 12px, withdata-direction, stillwave-data-grid-header-cell__sort-icon) instead of 0.13's filled triangle. A test or style that reads the triangle's path or itsh-3 w-3classes changes. OverflowItemPropsis a type alias of a union (OverflowItemBaseProps & OverflowItemPriorityProps:priorityandpinnedexclude each other).interface X extends OverflowItemPropsno longer compiles: extendOverflowItemBaseProps(and intersectOverflowItemPriorityPropsfor the two props).- TeachingPopover's Done calls
onFinish, thenonDismiss. Done still callsonDismissthrough 0.x, so that 0.13 code keeps working; 1.0 drops it. A handler pair that does the same work in both runs it twice on Done. - Children of TeachingPopover render. 0.13 dropped them silently; they now render in place, before the popover's own surface (the new parts are written there).
- TeachingPopover's
stepsform renders the default parts. The Close button sits in a<div class="wave-teaching-popover-header">(it keeps its class and its place at the top end), the heading, the body and the footer carrywave-teaching-popover-title,wave-teaching-popover-bodyandwave-teaching-popover-footerbefore their 0.13 part classes, and the surface and the footer carrydata-layout(horizontal). The look and every other attribute are unchanged. A selector that relies on the Close button being a child of the surface (.wave-teaching-popover > .wave-teaching-popover__close-button), on:first-child, or a test that walksdialog.firstElementChild, changes. It is the one change to an element structure of 0.13 that needs no opt-in (the others add attributes and classes), made so that a part's stable class sits on the element that takes itsclassName(C-CLASS) and thestepsform and the parts form render the same markup. - Table and DataGrid cells are positioned (
relative: the box ofTable.CellActions), and their rows are the Tailwind groupgroup/table-row. An absolutely positioned element of yours inside a cell is placed against the cell, and body cells paint over astickyheader of yours that sets noz-index(give it one). - New attributes on 0.13 markup, always rendered with their resolved value: Overflow's
data-orientation,data-overflow-directionanddata-button-position; Breadcrumb'sdata-size,data-focus-modeanddata-overflow(on the<nav>); DataGrid'sdata-selection-appearance(on the table); List'sdata-navigation-mode; the TeachingPopover surface'sdata-layout. A test that compares an element's full HTML or attribute list changes.
Added
- Overflow:
Overflow.Itempriority(items hide in ascending priority; equal priorities by direction) orpinned(never hides);overflowDirection(end,start),orientation(verticalstacks the items and measures heights; Fluent'soverflowAxis),minimumVisible,hasHiddenItems(the button is rendered before the first measurement, also in the server HTML),buttonPosition(end, the default, orbefore-hidden: the button stands just before the first hidden item, as a breadcrumb's "…" does) andonOverflowChange(hiddenItems, details)with{ visibleItems, groupVisibility }. Groups:Overflow.Item groupId,Overflow.Divider(OverflowDivider, hidden while its group is; it stretches across the row, so aToolbar.Dividerin it is drawn at the row's height),useIsOverflowGroupVisible(groupId)('visible','hidden'or'overflow') anduseHasHiddenItems().Overflow.Item asChildputs the item's props on its single element child (an<li>, a Toolbar button), and a row withrole="list"makes the button's wrapper a list item. When every item fits again while the overflow button has focus, focus moves to the first item it stood for (also in Breadcrumb'soverflow="auto"trail), not to the page. While no item setspriorityorpinned, the first item (withstart, the last) never hides, as in 0.13. TypesOverflowDirection,OverflowGroupVisibility,OverflowChangeDetails,OverflowItemBaseProps,OverflowItemPriorityProps,OverflowDividerProps. - Breadcrumb:
maxDisplayedItemsandoverflowIndex(default1) collapse the middle items into a "…" button (overflowLabel, "More items") that opens a Menu of them: aMenu.ItemLinkfor a link item (anasChildlink too, the element's ownhrefwinning; anasChildelement of a component, a router link with or without a stringhref, is rendered by that component with its own props, itsasincluded, so it navigates the way the trail's link does; a link item or anasChild<a>keeps itstarget,relanddownloadon the trail), aMenu.Itemfor a button item, disabled when the item is. The first item and the lastcurrentitem never collapse.overflow="auto"collapses by the room instead: the trail is an Overflow of its<li>s, the first and the current item pinned, and the "…" (with its own separator) stands where the hidden items were.size(small,medium,large),focusMode(tab, orarrow: one Tab stop, the arrow keys, Home and End, mirrored in RTL) anddivider(a slot;falsehides the separators). - Breadcrumb helpers, server-safe and importing nothing:
partitionBreadcrumbItems({ items, maxDisplayedItems, overflowIndex })(Fluent's rules;PartitionBreadcrumbItemsOptions,PartitionBreadcrumbItemsResult),truncateBreadcrumbLongName(content, maxLength = 30),truncateBreadcrumbLongTooltip(content, maxLength = 80)(Fluent spells ittruncateBreadcrumLongTooltip; there is no alias) andisTruncatableBreadcrumbContent(content, maxLength). - DataGrid typed columns and items:
DataGridColumngainscolumnId,compare,renderCell,renderHeaderCellandsortable(default: it hascompare), and itslabeltakes any content;createTableColumn<T>(options)(CreateTableColumnOptions; server-safe) builds one withsortableresolved.items,getRowId(default: the item's index initems) andcolumnsrender the header, the rows and their cells;DataGrid.Bodyalso takes a render function(item, index) => <DataGrid.Row>, whose rows get theirrowIdfromgetRowId. Item rows are memoised by row id, so a sort moves them without rendering them again. TypesDataGridItemsProps,DataGridItemsSortProps. - DataGrid built-in sorting: with
items, the grid orders its rows by the sorted column'scompare, also whilesortis controlled: a stable sort of a copy, and descending negatescompare, so items that compare equal keep their order in both directions. A column withoutcomparenever reorders the rows (server-sorted data).DataGrid.HeaderCell sortIconreplaces the arrow (an optional indicator:falsehides it; the glyph shows only while the column is sorted).onSortChangeandonSelectedItemsChangereceivedetails(DataGridSortChangeDetails,DataGridSelectedItemsChangeDetails). - DataGrid selection:
selectOnRowClick(a click on a row toggles it; the row'sonClickruns first, and itspreventDefault()keeps the selection; a click on a link, a button, an input or another interactive element, from a popup portaled from the row, on a header row, or one that ends a text selection never toggles),selectionAppearance(brand, the default,neutral,none;DataGridSelectionAppearance),subtleSelection(unchecked controls are drawn while their row, and the select-all while the grid, is hovered or holds focus; always in forced colors and on touch screens;data-subtle-selection),DataGrid.Row selectionCellProps(disabled,invisible,className,aria-label;DataGridRowSelectionCellProps) andDataGrid.SelectionCell(DataGridSelectionCell,DataGridSelectionCellProps): the select-all in a header row and the row's toggle in a body row, where you write it, in place of the automatic cell. A disabled row is skipped by row clicks, Space and select-all, which counts and selects the enabled rows only. - Table parts:
Table.HeaderCellsortable,sortDirection(ascendingordescending; unset is unsorted),onSortClick(event),sortIconandaside: a sort<button>in a<th aria-sort>("none"while unsorted), with no grid semantics, and the table stays stateless.Table.SelectionCell(TableSelectionCell): a checkbox or radio cell withchecked(true,false,'mixed'),defaultChecked,onCheckedChange(checked, details)(TableSelectionCellCheckedChangeDetails),name,value,form,required,subtle,invisibleandcontrolRef; the control's attributes and handlers go to the input, and uncontrolled radios that share anamebehave as one group.Table.CellLayout(TableCellLayout):media(an Avatar there gets a 32px box), the main text,description,truncateandappearance="primary".Table.CellActions(TableCellActions): actions over the end of a cell, drawn while the row is hovered or holds focus (always in forced colors and on touch screens;visiblekeeps them), over a background that follows the library's row fills (a row fill of your own, or a table on a Card, needs the same background class on the actions). TypesTableSelectionCellProps,TableCellLayoutProps,TableCellActionsProps. - List:
navigationMode(none,items,composite;ListNavigationMode):itemsgives a list without selection one Tab stop, the arrow keys, Home, End and, in a list of more than 7 items, typeahead, andcompositeis the grid from the first render, so the items never remount when actions appear.List.Item onAction(event)(ListItemActionEvent: a click and Enter, and Space on an item that cannot be selected; it runs before the selection toggles, and itspreventDefault()keeps the selection),List.Item disabledSelection(the selection cannot change, the item stays in the arrow order;data-disabled-selection), and check marks:checkmarkon the List (opt-in,data-checkmark) and acheckmarkslot onList.Item. - TeachingPopover actions:
primaryActionandsecondaryAction, on the popover and on a step (the step's wins), replace Next (or Done) and Back: a label, a Button-like element or a slot object ({ as: 'a', href, children }stays a Wave Button). The consumer'sonClickruns first, then the step's own action unless it calledpreventDefault()(TeachingPopoverAction).footerLayout(horizontal,vertical: the dots above full-width buttons), andonFinish(), called by Done. - TeachingPopover parts (Fluent's composition), also under flat names:
TeachingPopover.Trigger(opens and closes the popover witharia-haspopup="dialog",aria-expandedandaria-controls; the popover points at it whiletargetis unset, and focus returns to it; written directly inside, it makesdefaultOpenfalse),.Surface,.Header(the Close button, a caption,iconand adismissButtonslot),.Title(as; it names the surface),.Body(media),.Footer,.Carousel,.CarouselNav(interactive step buttons, each a Tab stop:labels.nav, "Choose step", andlabels.navButton(index, count), "Step 2 of 3"),.CarouselPageCount(a visible "2 of 3", worded by a render function) and.CarouselFooter(layoutoffsetorcentered,initialStepText,finalStepText; the footer wraps rather than let the indicator and the buttons overlap:offsetmoves the buttons to a row of their own, andcenteredkeeps the indicator in the middle of the footer, with or without a secondary button, or, when that row does not fit, puts it on a row of its own above the buttons, withdata-stacked), with their*Propstypes. A part without children shows its share of the current step;stepsstays the only source of the pages. Where WaveUI differs from Fluent:initialStepTextmakes the first step's secondary button dismiss the popover (onOpenChange(false), thenonDismiss; Fluent callsonFinish), CarouselFooter's defaultlayoutisoffset(WaveUI's own footer; Fluent's iscentered), and CarouselNav is a named group of buttons witharia-current="step"(Fluent's is a tablist). - Stable class names:
overflowDividerClassNames,dataGridSelectionCellClassNames,tableSelectionCellClassNames(root,control),tableCellLayoutClassNames(root,media,content,main,description),tableCellActionsClassNames,teachingPopoverSurfaceClassNames,teachingPopoverHeaderClassNames(root,icon),teachingPopoverTitleClassNames,teachingPopoverBodyClassNames(root,media),teachingPopoverFooterClassNames,teachingPopoverCarouselClassNames,teachingPopoverCarouselNavClassNames(root,button,indicator),teachingPopoverCarouselPageCountClassNames,teachingPopoverCarouselFooterClassNames; new keys onbreadcrumbClassNames(overflowButton),tableHeaderCellClassNames(button,sortIcon,aside),listItemClassNames(checkmark) andteachingPopoverClassNames(primaryButton,secondaryButton). The Surface carrieswave-teaching-popover wave-teaching-popover-surface, and the CarouselFooter carries TeachingPopover'sfooterpart class. - Development warnings (keys):
Overflow:button-position,Overflow.Item:as-child-children,Breadcrumb:overflow-item,DataGrid:column-without-columnId,DataGrid:items-deprecated-sort,DataGrid.Body:render-without-items,DataGrid.SelectionCell:not-selectable,DataGrid.SelectionCell:unseen,DataGrid.Header:several-selection-cells,DataGrid.HeaderCell:sortIcon-button,Table.HeaderCell:sortIcon-button,Table.SelectionCell:name,List:items-with-actions,List:none-selectable,List.Item:action-not-navigable,TeachingPopover:surface-props,TeachingPopover.Surface:placement,TeachingPopover.Header:dismissButton-button-element. - Stories for Overflow priorities, groups and a Toolbar, the Breadcrumb collapse, sizes, arrow keys, divider and truncated names, typed DataGrid columns with sorting, row-click selection and the selection looks, the Table parts, the List modes and
onAction, and TeachingPopover actions and a tour built from parts.
Changed
Behaviour
- List: when a list stops navigating its items while one of them has focus (
navigationModeitemstonone, or a list without item actions whoseselectableis turned off), focus moves to that item's first focusable content; an item with none keeps focus, though it is no longer a Tab stop. Enter on a selectable item ispreventDefault()ed afteronActionand the toggle ran, not before, soonActioncan cancel the toggle. - TeachingPopover renders its children (see "Upgrading from 0.13", 8).
DOM structure
- The attributes of "Upgrading from 0.13", 11, the TeachingPopover header element and part classes (9), and
relativeonTable.CellandDataGrid.Cellwithgroup/table-rowonTable.RowandDataGrid.Row(10). The DataGrid's sort glyph is the arrow icon (5). - The selection controls of a DataGrid carry
disabled:cursor-not-allowed. - An Overflow with
role="list"gives its button's wrapperrole="listitem".
Types
- See "Upgrading from 0.13", 1 to 4 and 6.
DataGridLegacySortPropsgainsitems?: undefined;TeachingPopoverLabelsgainsnavandnavButton;typeof Overflow,typeof DataGrid,typeof Tableandtypeof TeachingPopovergain members. - Dev gates:
verify-distprobes that an import of onlycreateTableColumnholds no table component, and an import of only one breadcrumb helper no Breadcrumb, Menu or Overflow module, and neither any React module; its module-only list gains the seams the tables share, the Overflow store and TeachingPopover's root, context and surface. Thestepsform's markup is pinned in the TeachingPopover suite.
Deprecated
DataGridColumn.id: usecolumnId. It is read only whencolumnIdis missing, with a development warning once.- Notice: Done stops calling
onDismissin 1.0 (useonFinish), and the optionaldetailsarguments added in 0.14 (onOverflowChange,onSortChange,onSelectedItemsChange,Table.SelectionCellonCheckedChange) become required, unchanged; WaveUI always passes them.
Size
Not re-measured for 0.14: the additions are new props and parts of six components and five helpers, all tree-shakeable (the verify-dist helper probes show that an import of only createTableColumn, or of only one breadcrumb helper, holds no component and no React module).