import { Meta } from '@storybook/react'; import React from 'react'; import { longTree } from 'demodata'; import { UncontrolledTreeEnvironment } from '../uncontrolledEnvironment/UncontrolledTreeEnvironment'; import { StaticTreeDataProvider } from '../uncontrolledEnvironment/StaticTreeDataProvider'; import { Tree } from '../tree/Tree'; import { defaultLiveDescriptors } from '../tree/defaultLiveDescriptors'; export default { title: 'Core/Accessibility', } as Meta; const VisibleLiveDescriptorContainer = ({ children, tree }: any) => (
{children}
); export const VisibleLiveDescriptors = () => ( canDragAndDrop canDropOnFolder canReorderItems dataProvider={ new StaticTreeDataProvider(longTree.items, (item, data) => ({ ...item, data, })) } getItemTitle={item => item.data} viewState={{ 'tree-1': { expandedItems: [ 'Fruit', 'Meals', 'America', 'Europe', 'Asia', 'Desserts', ], }, }} renderLiveDescriptorContainer={VisibleLiveDescriptorContainer} > ); export const CustomHotkeys = () => ( canDragAndDrop canDropOnFolder canReorderItems dataProvider={ new StaticTreeDataProvider(longTree.items, (item, data) => ({ ...item, data, })) } getItemTitle={item => item.data} viewState={{ 'tree-1': { expandedItems: ['Fruit', 'Meals', 'Desserts'], }, }} keyboardBindings={{ primaryAction: ['f3'], renameItem: ['control+e'], abortRenameItem: ['control'], startProgrammaticDnd: ['f2'], completeProgrammaticDnd: ['control'], abortProgrammaticDnd: ['enter'], }} renderLiveDescriptorContainer={VisibleLiveDescriptorContainer} > ); export const CustomDescriptors = () => ( canDragAndDrop canDropOnFolder canReorderItems dataProvider={ new StaticTreeDataProvider(longTree.items, (item, data) => ({ ...item, data, })) } getItemTitle={item => item.data} viewState={{ 'tree-1': { expandedItems: ['Fruit', 'Meals', 'Desserts'], }, }} liveDescriptors={{ ...defaultLiveDescriptors, introduction: 'Custom live descriptor for tree {treeLabel}', renamingItem: 'Renaming {renamingItem}', programmaticallyDragging: 'Dragging {dragItems}', programmaticallyDraggingTarget: 'Target is {dropTarget}', }} renderLiveDescriptorContainer={VisibleLiveDescriptorContainer} > ); export const NoDescriptors = () => ( canDragAndDrop canDropOnFolder canReorderItems dataProvider={ new StaticTreeDataProvider(longTree.items, (item, data) => ({ ...item, data, })) } getItemTitle={item => item.data} viewState={{ 'tree-1': { expandedItems: ['Fruit', 'Meals', 'Desserts'], }, }} showLiveDescription={false} >

The following tree has no accessibility descriptors in the DOM at all.

); export const NoKeyboardBindings = () => ( canDragAndDrop canDropOnFolder canReorderItems dataProvider={ new StaticTreeDataProvider(longTree.items, (item, data) => ({ ...item, data, })) } getItemTitle={item => item.data} viewState={{ 'tree-1': {}, }} keyboardBindings={{ primaryAction: [], moveFocusToFirstItem: [], moveFocusToLastItem: [], expandSiblings: [], renameItem: [], abortRenameItem: [], toggleSelectItem: [], abortSearch: [], startSearch: [], selectAll: [], startProgrammaticDnd: [], abortProgrammaticDnd: [], completeProgrammaticDnd: [], }} disableArrowKeys > );