@react-aria/gridlist 3.0.0-rc.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1 -2
- package/dist/main.js.map +1 -1
- package/dist/module.js +1 -2
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/useGridList.ts +4 -10
package/dist/main.js
CHANGED
|
@@ -28,7 +28,7 @@ function $7db02799adae605d$export$e0c709538cb8ae18(key) {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
function $acf209ae814f1c93$export$664f9155035607eb(props, state, ref) {
|
|
31
|
-
let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate ,
|
|
31
|
+
let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate , onAction: onAction } = props;
|
|
32
32
|
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
33
33
|
let { listProps: listProps } = $dSFus$reactariaselection.useSelectableList({
|
|
34
34
|
selectionManager: state.selectionManager,
|
|
@@ -61,7 +61,6 @@ function $acf209ae814f1c93$export$664f9155035607eb(props, state, ref) {
|
|
|
61
61
|
gridProps['aria-colcount'] = 1;
|
|
62
62
|
}
|
|
63
63
|
$dSFus$reactariagrid.useGridSelectionAnnouncement({
|
|
64
|
-
getRowText: getRowText
|
|
65
64
|
}, state);
|
|
66
65
|
return {
|
|
67
66
|
gridProps: gridProps
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AEsBO,KAAK,CAAC,yCAAO,GAAG,GAAG,CAAC,OAAO;SAElB,yCAAQ,CAAI,KAAmB,EAAE,GAAQ,EAAE,CAAC;IAC1D,GAAG,CAAC,CAAC,KAAA,EAAE,EAAA,CAAC,GAAG,yCAAO,CAAC,GAAG,CAAC,KAAK;IAC5B,EA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QACF,IAAI,GAAG,MAAM,CAAC,SAAS;QACvB,EAAE,EAAE,IAAI,EACN,IAAI,GAAG,IAAI;IAEf,CAAC,OAAQ,IAAI;IACb,MAAM,CAAC,IAAI;AACb,CAAC;;;;;SCxLe,yCAA4B,CAAI,KAAqC,EAAE,KAAmB,EAA6B,CAAC;IACtI,GAAG,CAAC,CAAC,MAAA,GAAG,EAAA,CAAC,GAAG,KAAK;IACjB,KAAK,CAAC,CAAC,gBAAA,aAAa,EAAA,CAAC,GAAG,6CAAwB,CAAC,KAAK,EAAE,KAAK;IAE7D,MAAM,CAAC,CAAC;QACN,aAAa,EAAE,CAAC;eACX,aAAa;YAChB,CAAiB,qBAAK,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,yCAAQ,CAAC,KAAK,EAAE,GAAG;QAC/D,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/gridlist/src/index.ts","packages/@react-aria/gridlist/src/useGridList.ts","packages/@react-aria/gridlist/src/utils.ts","packages/@react-aria/gridlist/src/useGridListItem.ts","packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useGridList} from './useGridList';\nexport {useGridListItem} from './useGridListItem';\nexport {useGridListSelectionCheckbox} from './useGridListSelectionCheckbox';\n\nexport type {AriaGridListOptions, GridListAria} from './useGridList';\nexport type {AriaGridListItemOptions, GridListItemAria} from './useGridListItem';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from '@react-aria/grid';\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridListProps} from '@react-types/list';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {listMap} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * A function that returns the text that should be announced by assistive technology when a row is added or removed from selection.\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive children.\n * A grid list displays data in a single columns and enables a user to navigate its contents via directional navigation keys.\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n getRowText,\n onAction\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate: keyboardDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace'\n });\n\n let id = useId();\n listMap.set(state, {id, onAction});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({getRowText}, state);\n\n return {\n gridProps\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport type {ListState} from '@react-stately/list';\n\ninterface ListMapShared {\n id: string,\n onAction: (key: Key) => void\n}\n\n// Used to share:\n// id of the list and onAction between useList, useListItem, and useListSelectionCheckbox\nexport const listMap = new WeakMap<ListState<unknown>, ListMapShared>();\n\nexport function getRowId<T>(state: ListState<T>, key: Key) {\n let {id} = listMap.get(state);\n if (!id) {\n throw new Error('Unknown list');\n }\n\n return `${id}-${normalizeKey(key)}`;\n}\n\nexport function normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, Node as RSNode} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getRowId, listMap} from './utils';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport type {ListState} from '@react-stately/list';\nimport {mergeProps, useSlotId} from '@react-aria/utils';\nimport {KeyboardEvent as ReactKeyboardEvent, RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaGridListItemOptions {\n /** An object representing the list item. Contains all the relevant information that makes up the list row. */\n node: RSNode<unknown>,\n /** Whether the list row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes,\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes,\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(props: AriaGridListItemOptions, state: ListState<T>, ref: RefObject<FocusableElement>): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp\n } = props;\n\n let {direction} = useLocale();\n let {onAction} = listMap.get(state);\n let descriptionId = useSlotId();\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (!ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onAction ? () => onAction(node.key) : undefined,\n focus\n });\n\n let onKeyDown = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the row.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n let onFocus = (e) => {\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let rowProps: DOMAttributes = mergeProps(itemProps, {\n role: 'row',\n onKeyDownCapture: onKeyDown,\n onFocus,\n 'aria-label': node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby': descriptionId && node.textValue ? `${getRowId(state, node.key)} ${descriptionId}` : undefined,\n id: getRowId(state, node.key)\n });\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n return {\n rowProps,\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria, useGridSelectionCheckbox} from '@react-aria/grid';\nimport {getRowId} from './utils';\nimport type {ListState} from '@react-stately/list';\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid list.\n * @param props - Props for the selection checkbox.\n * @param state - State of the list, as returned by `useListState`.\n */\nexport function useGridListSelectionCheckbox<T>(props: AriaGridSelectionCheckboxProps, state: ListState<T>): GridSelectionCheckboxAria {\n let {key} = props;\n const {checkboxProps} = useGridSelectionCheckbox(props, state as any);\n\n return {\n checkboxProps: {\n ...checkboxProps,\n 'aria-labelledby': `${checkboxProps.id} ${getRowId(state, key)}`\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AEsBO,KAAK,CAAC,yCAAO,GAAG,GAAG,CAAC,OAAO;SAElB,yCAAQ,CAAI,KAAmB,EAAE,GAAQ,EAAE,CAAC;IAC1D,GAAG,CAAC,CAAC,KAAA,EAAE,EAAA,CAAC,GAAG,yCAAO,CAAC,GAAG,CAAC,KAAK;IAC5B,EAAE,GAAG,EAAE,EACL,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAc;IAGhC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,yCAAY,CAAC,GAAG;AAClC,CAAC;SAEe,yCAAY,CAAC,GAAQ,EAAU,CAAC;IAC9C,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,MAAM,CAAC,GAAG,CAAC,OAAO,SAAS,CAAE;IAG/B,MAAM,CAAC,CAAE,IAAG,GAAG;AACjB,CAAC;;;;;SDIe,yCAAW,CAAI,KAA6B,EAAE,KAAmB,EAAE,GAA2B,EAAgB,CAAC;IAC7H,GAAG,CAAC,CAAC,gBACH,aAAa,qBACb,gBAAgB,aAChB,QAAQ,EACV,CAAC,GAAG,KAAK;IAET,EAAE,GAAG,KAAK,CAAC,CAAY,iBAAM,KAAK,CAAC,CAAiB,mBAClD,OAAO,CAAC,IAAI,CAAC,CAAsE;IAGrF,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,2CAAiB,CAAC,CAAC;QACnC,gBAAgB,EAAE,KAAK,CAAC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E,aAAa,KAAK,SAAS;QAChH,EAAE,EAAE,yCAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG;IAC9B,CAAC;IAED,EAAE,EAAE,aAAa,EACf,QAAQ,CAAC,CAAe,kBAAI,IAAI,CAAC,KAAK,GAAG,CAAC;IAG5C,GAAG,CAAC,aAAa,GAAG,CAAC;QACnB,IAAI,EAAE,CAAU;QAChB,CAAe,gBAAE,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,CAAC;kBACN,QAAQ;uBACR,aAAa;QACb,gBAAgB,EAAE,CAAC;YACjB,EAAE,EAAE,aAAa;QACnB,CAAC;WACE,UAAU;IACf,CAAC;AACH,CAAC;SAEQ,0BAAI,CAAC,MAAkB,EAAE,CAAC;IACjC,GAAG,CAAC,IAAI;IACR,GAAG,CAAC,IAAI;OACL,CAAC;QACF,IAAI,GAAG,MAAM,CAAC,SAAS;QACvB,EAAE,EAAE,IAAI,EACN,IAAI,GAAG,IAAI;IAEf,CAAC,OAAQ,IAAI;IACb,MAAM,CAAC,IAAI;AACb,CAAC;;;;;SCxLe,yCAA4B,CAAI,KAAqC,EAAE,KAAmB,EAA6B,CAAC;IACtI,GAAG,CAAC,CAAC,MAAA,GAAG,EAAA,CAAC,GAAG,KAAK;IACjB,KAAK,CAAC,CAAC,gBAAA,aAAa,EAAA,CAAC,GAAG,6CAAwB,CAAC,KAAK,EAAE,KAAK;IAE7D,MAAM,CAAC,CAAC;QACN,aAAa,EAAE,CAAC;eACX,aAAa;YAChB,CAAiB,qBAAK,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,yCAAQ,CAAC,KAAK,EAAE,GAAG;QAC/D,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/gridlist/src/index.ts","packages/@react-aria/gridlist/src/useGridList.ts","packages/@react-aria/gridlist/src/utils.ts","packages/@react-aria/gridlist/src/useGridListItem.ts","packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useGridList} from './useGridList';\nexport {useGridListItem} from './useGridListItem';\nexport {useGridListSelectionCheckbox} from './useGridListSelectionCheckbox';\n\nexport type {AriaGridListOptions, GridListAria} from './useGridList';\nexport type {AriaGridListItemOptions, GridListItemAria} from './useGridListItem';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from '@react-aria/grid';\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridListProps} from '@react-types/list';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listMap} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive children.\n * A grid list displays data in a single column and enables a user to navigate its contents via directional navigation keys.\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n onAction\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate: keyboardDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace'\n });\n\n let id = useId();\n listMap.set(state, {id, onAction});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport type {ListState} from '@react-stately/list';\n\ninterface ListMapShared {\n id: string,\n onAction: (key: Key) => void\n}\n\n// Used to share:\n// id of the list and onAction between useList, useListItem, and useListSelectionCheckbox\nexport const listMap = new WeakMap<ListState<unknown>, ListMapShared>();\n\nexport function getRowId<T>(state: ListState<T>, key: Key) {\n let {id} = listMap.get(state);\n if (!id) {\n throw new Error('Unknown list');\n }\n\n return `${id}-${normalizeKey(key)}`;\n}\n\nexport function normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, Node as RSNode} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getRowId, listMap} from './utils';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport type {ListState} from '@react-stately/list';\nimport {mergeProps, useSlotId} from '@react-aria/utils';\nimport {KeyboardEvent as ReactKeyboardEvent, RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaGridListItemOptions {\n /** An object representing the list item. Contains all the relevant information that makes up the list row. */\n node: RSNode<unknown>,\n /** Whether the list row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes,\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes,\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(props: AriaGridListItemOptions, state: ListState<T>, ref: RefObject<FocusableElement>): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp\n } = props;\n\n let {direction} = useLocale();\n let {onAction} = listMap.get(state);\n let descriptionId = useSlotId();\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (!ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onAction ? () => onAction(node.key) : undefined,\n focus\n });\n\n let onKeyDown = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the row.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n let onFocus = (e) => {\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let rowProps: DOMAttributes = mergeProps(itemProps, {\n role: 'row',\n onKeyDownCapture: onKeyDown,\n onFocus,\n 'aria-label': node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby': descriptionId && node.textValue ? `${getRowId(state, node.key)} ${descriptionId}` : undefined,\n id: getRowId(state, node.key)\n });\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n return {\n rowProps,\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria, useGridSelectionCheckbox} from '@react-aria/grid';\nimport {getRowId} from './utils';\nimport type {ListState} from '@react-stately/list';\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid list.\n * @param props - Props for the selection checkbox.\n * @param state - State of the list, as returned by `useListState`.\n */\nexport function useGridListSelectionCheckbox<T>(props: AriaGridSelectionCheckboxProps, state: ListState<T>): GridSelectionCheckboxAria {\n let {key} = props;\n const {checkboxProps} = useGridSelectionCheckbox(props, state as any);\n\n return {\n checkboxProps: {\n ...checkboxProps,\n 'aria-labelledby': `${checkboxProps.id} ${getRowId(state, key)}`\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -21,7 +21,7 @@ function $ce9b18daab526bbd$export$e0c709538cb8ae18(key) {
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
function $f47efb0c3a859cf2$export$664f9155035607eb(props, state, ref) {
|
|
24
|
-
let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate ,
|
|
24
|
+
let { isVirtualized: isVirtualized , keyboardDelegate: keyboardDelegate , onAction: onAction } = props;
|
|
25
25
|
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
26
26
|
let { listProps: listProps } = $13Gtr$useSelectableList({
|
|
27
27
|
selectionManager: state.selectionManager,
|
|
@@ -54,7 +54,6 @@ function $f47efb0c3a859cf2$export$664f9155035607eb(props, state, ref) {
|
|
|
54
54
|
gridProps['aria-colcount'] = 1;
|
|
55
55
|
}
|
|
56
56
|
$13Gtr$useGridSelectionAnnouncement({
|
|
57
|
-
getRowText: getRowText
|
|
58
57
|
}, state);
|
|
59
58
|
return {
|
|
60
59
|
gridProps: gridProps
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AEsBO,KAAK,CAAC,yCAAO,GAAG,GAAG,CAAC,OAAO;SAElB,yCAAQ,CAAI,KAAmB,EAAE,GAAQ,EAAE,CAAC;IAC1D,GAAG,CAAC,CAAC,KAAA,EAAE,EAAA,CAAC,GAAG,yCAAO,CAAC,GAAG,CAAC,KAAK;IAC5B,EAAE,GAAG,EAAE,EACL,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAc;IAGhC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,yCAAY,CAAC,GAAG;AAClC,CAAC;SAEe,yCAAY,CAAC,GAAQ,EAAU,CAAC;IAC9C,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,MAAM,CAAC,GAAG,CAAC,OAAO,SAAS,CAAE;IAG/B,MAAM,CAAC,CAAE,IAAG,GAAG;AACjB,CAAC;;;;;SDSe,yCAAW,CAAI,KAA6B,EAAE,KAAmB,EAAE,GAA2B,EAAgB,CAAC;IAC7H,GAAG,CAAC,CAAC,gBACH,aAAa,qBACb,gBAAgB,eAChB,UAAU,aACV,QAAQ,EACV,CAAC,GAAG,KAAK;IAET,EAAE,GAAG,KAAK,CAAC,CAAY,iBAAM,KAAK,CAAC,CAAiB,mBAClD,OAAO,CAAC,IAAI,CAAC,CAAsE;IAGrF,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,wBAAiB,CAAC,CAAC;QACnC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,YAAY,EAAE,KAAK,CAAC,YAAY;aAChC,GAAG;QACH,gBAAgB,EAAE,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AAE,EAAE,aAAa,EACf,QAAQ,CAAC,CAAe,kBAAI,IAAI,CAAC,KAAK,GAAG,CAAC;IAG5C,GAAG,CAAC,aAAa,GAAG,CAAC;QACnB,IAAI,EAAE,CAAU;QAChB,CAAe,gBAAE,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,CAAC;kBACN,QAAQ;uBACR,aAAa;QACb,gBAAgB,EAAE,CAAC;YACjB,EAAE,EAAE,aAAa;QACnB,CAAC;WACE,UAAU;IACf,CAAC;AACH,CAAC;SAEQ,0BAAI,CAAC,MAAkB,EAAE,CAAC;IACjC,GAAG,CAAC,IAAI;IACR,GAAG,CAAC,IAAI;OACL,CAAC;QACF,IAAI,GAAG,MAAM,CAAC,SAAS;QACvB,EAAE,EAAE,IAAI,EACN,IAAI,GAAG,IAAI;IAEf,CAAC,OAAQ,IAAI;IACb,MAAM,CAAC,IAAI;AACb,CAAC;;;;;SCxLe,yCAA4B,CAAI,KAAqC,EAAE,KAAmB,EAA6B,CAAC;IACtI,GAAG,CAAC,CAAC,MAAA,GAAG,EAAA,CAAC,GAAG,KAAK;IACjB,KAAK,CAAC,CAAC,gBAAA,aAAa,EAAA,CAAC,GAAG,+BAAwB,CAAC,KAAK,EAAE,KAAK;IAE7D,MAAM,CAAC,CAAC;QACN,aAAa,EAAE,CAAC;eACX,aAAa;YAChB,CAAiB,qBAAK,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,yCAAQ,CAAC,KAAK,EAAE,GAAG;QAC/D,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/gridlist/src/index.ts","packages/@react-aria/gridlist/src/useGridList.ts","packages/@react-aria/gridlist/src/utils.ts","packages/@react-aria/gridlist/src/useGridListItem.ts","packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useGridList} from './useGridList';\nexport {useGridListItem} from './useGridListItem';\nexport {useGridListSelectionCheckbox} from './useGridListSelectionCheckbox';\n\nexport type {AriaGridListOptions, GridListAria} from './useGridList';\nexport type {AriaGridListItemOptions, GridListItemAria} from './useGridListItem';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from '@react-aria/grid';\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridListProps} from '@react-types/list';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {Key, RefObject} from 'react';\nimport {listMap} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * A function that returns the text that should be announced by assistive technology when a row is added or removed from selection.\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive children.\n * A grid list displays data in a single columns and enables a user to navigate its contents via directional navigation keys.\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n getRowText,\n onAction\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate: keyboardDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace'\n });\n\n let id = useId();\n listMap.set(state, {id, onAction});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({getRowText}, state);\n\n return {\n gridProps\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport type {ListState} from '@react-stately/list';\n\ninterface ListMapShared {\n id: string,\n onAction: (key: Key) => void\n}\n\n// Used to share:\n// id of the list and onAction between useList, useListItem, and useListSelectionCheckbox\nexport const listMap = new WeakMap<ListState<unknown>, ListMapShared>();\n\nexport function getRowId<T>(state: ListState<T>, key: Key) {\n let {id} = listMap.get(state);\n if (!id) {\n throw new Error('Unknown list');\n }\n\n return `${id}-${normalizeKey(key)}`;\n}\n\nexport function normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, Node as RSNode} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getRowId, listMap} from './utils';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport type {ListState} from '@react-stately/list';\nimport {mergeProps, useSlotId} from '@react-aria/utils';\nimport {KeyboardEvent as ReactKeyboardEvent, RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaGridListItemOptions {\n /** An object representing the list item. Contains all the relevant information that makes up the list row. */\n node: RSNode<unknown>,\n /** Whether the list row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes,\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes,\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(props: AriaGridListItemOptions, state: ListState<T>, ref: RefObject<FocusableElement>): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp\n } = props;\n\n let {direction} = useLocale();\n let {onAction} = listMap.get(state);\n let descriptionId = useSlotId();\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (!ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onAction ? () => onAction(node.key) : undefined,\n focus\n });\n\n let onKeyDown = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the row.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n let onFocus = (e) => {\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let rowProps: DOMAttributes = mergeProps(itemProps, {\n role: 'row',\n onKeyDownCapture: onKeyDown,\n onFocus,\n 'aria-label': node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby': descriptionId && node.textValue ? `${getRowId(state, node.key)} ${descriptionId}` : undefined,\n id: getRowId(state, node.key)\n });\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n return {\n rowProps,\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria, useGridSelectionCheckbox} from '@react-aria/grid';\nimport {getRowId} from './utils';\nimport type {ListState} from '@react-stately/list';\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid list.\n * @param props - Props for the selection checkbox.\n * @param state - State of the list, as returned by `useListState`.\n */\nexport function useGridListSelectionCheckbox<T>(props: AriaGridSelectionCheckboxProps, state: ListState<T>): GridSelectionCheckboxAria {\n let {key} = props;\n const {checkboxProps} = useGridSelectionCheckbox(props, state as any);\n\n return {\n checkboxProps: {\n ...checkboxProps,\n 'aria-labelledby': `${checkboxProps.id} ${getRowId(state, key)}`\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;AEsBO,KAAK,CAAC,yCAAO,GAAG,GAAG,CAAC,OAAO;SAElB,yCAAQ,CAAI,KAAmB,EAAE,GAAQ,EAAE,CAAC;IAC1D,GAAG,CAAC,CAAC,KAAA,EAAE,EAAA,CAAC,GAAG,yCAAO,CAAC,GAAG,CAAC,KAAK;IAC5B,EAAE,GAAG,EAAE,EACL,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAc;IAGhC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,yCAAY,CAAC,GAAG;AAClC,CAAC;SAEe,yCAAY,CAAC,GAAQ,EAAU,CAAC;IAC9C,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,MAAM,CAAC,GAAG,CAAC,OAAO,SAAS,CAAE;IAG/B,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AC,GAAG,+BAAwB,CAAC,KAAK,EAAE,KAAK;IAE7D,MAAM,CAAC,CAAC;QACN,aAAa,EAAE,CAAC;eACX,aAAa;YAChB,CAAiB,qBAAK,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,yCAAQ,CAAC,KAAK,EAAE,GAAG;QAC/D,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/gridlist/src/index.ts","packages/@react-aria/gridlist/src/useGridList.ts","packages/@react-aria/gridlist/src/utils.ts","packages/@react-aria/gridlist/src/useGridListItem.ts","packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useGridList} from './useGridList';\nexport {useGridListItem} from './useGridListItem';\nexport {useGridListSelectionCheckbox} from './useGridListSelectionCheckbox';\n\nexport type {AriaGridListOptions, GridListAria} from './useGridList';\nexport type {AriaGridListItemOptions, GridListItemAria} from './useGridListItem';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from '@react-aria/grid';\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridListProps} from '@react-types/list';\nimport {DOMAttributes, KeyboardDelegate} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listMap} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {RefObject} from 'react';\nimport {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive children.\n * A grid list displays data in a single column and enables a user to navigate its contents via directional navigation keys.\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement>): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n onAction\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate: keyboardDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace'\n });\n\n let id = useId();\n listMap.set(state, {id, onAction});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\nimport type {ListState} from '@react-stately/list';\n\ninterface ListMapShared {\n id: string,\n onAction: (key: Key) => void\n}\n\n// Used to share:\n// id of the list and onAction between useList, useListItem, and useListSelectionCheckbox\nexport const listMap = new WeakMap<ListState<unknown>, ListMapShared>();\n\nexport function getRowId<T>(state: ListState<T>, key: Key) {\n let {id} = listMap.get(state);\n if (!id) {\n throw new Error('Unknown list');\n }\n\n return `${id}-${normalizeKey(key)}`;\n}\n\nexport function normalizeKey(key: Key): string {\n if (typeof key === 'string') {\n return key.replace(/\\s*/g, '');\n }\n\n return '' + key;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, FocusableElement, Node as RSNode} from '@react-types/shared';\nimport {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';\nimport {getRowId, listMap} from './utils';\nimport {isFocusVisible} from '@react-aria/interactions';\nimport type {ListState} from '@react-stately/list';\nimport {mergeProps, useSlotId} from '@react-aria/utils';\nimport {KeyboardEvent as ReactKeyboardEvent, RefObject} from 'react';\nimport {SelectableItemStates, useSelectableItem} from '@react-aria/selection';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface AriaGridListItemOptions {\n /** An object representing the list item. Contains all the relevant information that makes up the list row. */\n node: RSNode<unknown>,\n /** Whether the list row is contained in a virtual scroller. */\n isVirtualized?: boolean,\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean\n}\n\nexport interface GridListItemAria extends SelectableItemStates {\n /** Props for the list row element. */\n rowProps: DOMAttributes,\n /** Props for the grid cell element within the list row. */\n gridCellProps: DOMAttributes,\n /** Props for the list item description element, if any. */\n descriptionProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useListState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useGridListItem<T>(props: AriaGridListItemOptions, state: ListState<T>, ref: RefObject<FocusableElement>): GridListItemAria {\n // Copied from useGridCell + some modifications to make it not so grid specific\n let {\n node,\n isVirtualized,\n shouldSelectOnPressUp\n } = props;\n\n let {direction} = useLocale();\n let {onAction} = listMap.get(state);\n let descriptionId = useSlotId();\n let focus = () => {\n // Don't shift focus to the row if the active element is a element within the row already\n // (e.g. clicking on a row button)\n if (!ref.current.contains(document.activeElement)) {\n focusSafely(ref.current);\n }\n };\n\n let {itemProps, ...itemStates} = useSelectableItem({\n selectionManager: state.selectionManager,\n key: node.key,\n ref,\n isVirtualized,\n shouldSelectOnPressUp,\n onAction: onAction ? () => onAction(node.key) : undefined,\n focus\n });\n\n let onKeyDown = (e: ReactKeyboardEvent) => {\n if (!e.currentTarget.contains(e.target as Element)) {\n return;\n }\n\n let walker = getFocusableTreeWalker(ref.current);\n walker.currentNode = document.activeElement;\n\n switch (e.key) {\n case 'ArrowLeft': {\n // Find the next focusable element within the row.\n let focusable = direction === 'rtl'\n ? walker.nextNode() as FocusableElement\n : walker.previousNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n // If there is no next focusable child, then return focus back to the row\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowRight': {\n let focusable = direction === 'rtl'\n ? walker.previousNode() as FocusableElement\n : walker.nextNode() as FocusableElement;\n\n if (focusable) {\n e.preventDefault();\n e.stopPropagation();\n focusSafely(focusable);\n } else {\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'ltr') {\n focusSafely(ref.current);\n } else {\n walker.currentNode = ref.current;\n let lastElement = last(walker);\n if (lastElement) {\n focusSafely(lastElement);\n }\n }\n }\n break;\n }\n case 'ArrowUp':\n case 'ArrowDown':\n // Prevent this event from reaching row children, e.g. menu buttons. We want arrow keys to navigate\n // to the row above/below instead. We need to re-dispatch the event from a higher parent so it still\n // bubbles and gets handled by useSelectableCollection.\n if (!e.altKey && ref.current.contains(e.target as Element)) {\n e.stopPropagation();\n e.preventDefault();\n ref.current.parentElement.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n );\n }\n break;\n }\n };\n\n let onFocus = (e) => {\n if (e.target !== ref.current) {\n // useSelectableItem only handles setting the focused key when\n // the focused element is the row itself. We also want to\n // set the focused key when a child element receives focus.\n // If focus is currently visible (e.g. the user is navigating with the keyboard),\n // then skip this. We want to restore focus to the previously focused row\n // in that case since the list should act like a single tab stop.\n if (!isFocusVisible()) {\n state.selectionManager.setFocusedKey(node.key);\n }\n return;\n }\n };\n\n let rowProps: DOMAttributes = mergeProps(itemProps, {\n role: 'row',\n onKeyDownCapture: onKeyDown,\n onFocus,\n 'aria-label': node.textValue || undefined,\n 'aria-selected': state.selectionManager.canSelectItem(node.key) ? state.selectionManager.isSelected(node.key) : undefined,\n 'aria-disabled': state.selectionManager.isDisabled(node.key) || undefined,\n 'aria-labelledby': descriptionId && node.textValue ? `${getRowId(state, node.key)} ${descriptionId}` : undefined,\n id: getRowId(state, node.key)\n });\n\n if (isVirtualized) {\n rowProps['aria-rowindex'] = node.index + 1;\n }\n\n let gridCellProps = {\n role: 'gridcell',\n 'aria-colindex': 1\n };\n\n return {\n rowProps,\n gridCellProps,\n descriptionProps: {\n id: descriptionId\n },\n ...itemStates\n };\n}\n\nfunction last(walker: TreeWalker) {\n let next: FocusableElement;\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n next = last;\n }\n } while (last);\n return next;\n}\n","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria, useGridSelectionCheckbox} from '@react-aria/grid';\nimport {getRowId} from './utils';\nimport type {ListState} from '@react-stately/list';\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid list.\n * @param props - Props for the selection checkbox.\n * @param state - State of the list, as returned by `useListState`.\n */\nexport function useGridListSelectionCheckbox<T>(props: AriaGridSelectionCheckboxProps, state: ListState<T>): GridSelectionCheckboxAria {\n let {key} = props;\n const {checkboxProps} = useGridSelectionCheckbox(props, state as any);\n\n return {\n checkboxProps: {\n ...checkboxProps,\n 'aria-labelledby': `${checkboxProps.id} ${getRowId(state, key)}`\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AriaGridListProps } from "@react-types/list";
|
|
2
2
|
import { DOMAttributes, KeyboardDelegate, FocusableElement, Node } from "@react-types/shared";
|
|
3
|
-
import { Key, RefObject } from "react";
|
|
4
3
|
import { ListState } from "@react-stately/list";
|
|
4
|
+
import { RefObject } from "react";
|
|
5
5
|
import { SelectableItemStates } from "@react-aria/selection";
|
|
6
6
|
import { AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria } from "@react-aria/grid";
|
|
7
7
|
export interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {
|
|
@@ -12,11 +12,6 @@ export interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'chil
|
|
|
12
12
|
* to override the default.
|
|
13
13
|
*/
|
|
14
14
|
keyboardDelegate?: KeyboardDelegate;
|
|
15
|
-
/**
|
|
16
|
-
* A function that returns the text that should be announced by assistive technology when a row is added or removed from selection.
|
|
17
|
-
* @default (key) => state.collection.getItem(key)?.textValue
|
|
18
|
-
*/
|
|
19
|
-
getRowText?: (key: Key) => string;
|
|
20
15
|
}
|
|
21
16
|
export interface GridListAria {
|
|
22
17
|
/** Props for the grid element. */
|
|
@@ -24,7 +19,7 @@ export interface GridListAria {
|
|
|
24
19
|
}
|
|
25
20
|
/**
|
|
26
21
|
* Provides the behavior and accessibility implementation for a list component with interactive children.
|
|
27
|
-
* A grid list displays data in a single
|
|
22
|
+
* A grid list displays data in a single column and enables a user to navigate its contents via directional navigation keys.
|
|
28
23
|
* @param props - Props for the list.
|
|
29
24
|
* @param state - State for the list, as returned by `useListState`.
|
|
30
25
|
* @param ref - The ref attached to the list element.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;ACqBA,qCAAqC,CAAC,CAAE,SAAQ,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC;IACpF,+CAA+C;IAC/C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,
|
|
1
|
+
{"mappings":";;;;;;ACqBA,qCAAqC,CAAC,CAAE,SAAQ,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,UAAU,CAAC;IACpF,+CAA+C;IAC/C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED;IACE,kCAAkC;IAClC,SAAS,EAAE,aAAa,CAAA;CACzB;AAED;;;;;;GAMG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,YAAY,CAmD5H;ACxED;IACE,8GAA8G;IAC9G,IAAI,EAAE,KAAO,OAAO,CAAC,CAAC;IACtB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,iCAAkC,SAAQ,oBAAoB;IAC5D,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAC;IACxB,2DAA2D;IAC3D,aAAa,EAAE,aAAa,CAAC;IAC7B,2DAA2D;IAC3D,gBAAgB,EAAE,aAAa,CAAA;CAChC;AAED;;;;;GAKG;AACH,gCAAgC,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,gBAAgB,CAmJ1I;ACjLD;;;;GAIG;AACH,6CAA6C,CAAC,EAAE,KAAK,EAAE,8BAA8B,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,GAAG,yBAAyB,CAUrI;ACbD,YAAY,EAAC,8BAA8B,EAAE,yBAAyB,EAAC,MAAM,kBAAkB,CAAC","sources":["packages/@react-aria/gridlist/src/packages/@react-aria/gridlist/src/utils.ts","packages/@react-aria/gridlist/src/packages/@react-aria/gridlist/src/useGridList.ts","packages/@react-aria/gridlist/src/packages/@react-aria/gridlist/src/useGridListItem.ts","packages/@react-aria/gridlist/src/packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts","packages/@react-aria/gridlist/src/packages/@react-aria/gridlist/src/index.ts","packages/@react-aria/gridlist/src/index.ts"],"sourcesContent":[null,null,null,null,null,"/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {useGridList} from './useGridList';\nexport {useGridListItem} from './useGridListItem';\nexport {useGridListSelectionCheckbox} from './useGridListSelectionCheckbox';\n\nexport type {AriaGridListOptions, GridListAria} from './useGridList';\nexport type {AriaGridListItemOptions, GridListItemAria} from './useGridListItem';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from '@react-aria/grid';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/gridlist",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/focus": "^3.
|
|
22
|
-
"@react-aria/grid": "^3.4.
|
|
23
|
-
"@react-aria/i18n": "^3.
|
|
24
|
-
"@react-aria/interactions": "^3.
|
|
25
|
-
"@react-aria/selection": "^3.10.
|
|
26
|
-
"@react-aria/utils": "^3.13.
|
|
27
|
-
"@react-stately/list": "^3.5.
|
|
28
|
-
"@react-types/checkbox": "^3.3.
|
|
29
|
-
"@react-types/list": "3.0.0
|
|
30
|
-
"@react-types/shared": "^3.14.
|
|
21
|
+
"@react-aria/focus": "^3.8.0",
|
|
22
|
+
"@react-aria/grid": "^3.4.1",
|
|
23
|
+
"@react-aria/i18n": "^3.6.0",
|
|
24
|
+
"@react-aria/interactions": "^3.11.0",
|
|
25
|
+
"@react-aria/selection": "^3.10.1",
|
|
26
|
+
"@react-aria/utils": "^3.13.3",
|
|
27
|
+
"@react-stately/list": "^3.5.3",
|
|
28
|
+
"@react-types/checkbox": "^3.3.3",
|
|
29
|
+
"@react-types/list": "^3.0.0",
|
|
30
|
+
"@react-types/shared": "^3.14.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "b03ef51e6317547dd0a840f151e59d039b1e1fd3"
|
|
39
39
|
}
|
package/src/useGridList.ts
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
import {AriaGridListProps} from '@react-types/list';
|
|
14
14
|
import {DOMAttributes, KeyboardDelegate} from '@react-types/shared';
|
|
15
15
|
import {filterDOMProps, mergeProps, useId} from '@react-aria/utils';
|
|
16
|
-
import {Key, RefObject} from 'react';
|
|
17
16
|
import {listMap} from './utils';
|
|
18
17
|
import {ListState} from '@react-stately/list';
|
|
18
|
+
import {RefObject} from 'react';
|
|
19
19
|
import {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid';
|
|
20
20
|
import {useSelectableList} from '@react-aria/selection';
|
|
21
21
|
|
|
@@ -26,12 +26,7 @@ export interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'chil
|
|
|
26
26
|
* An optional keyboard delegate implementation for type to select,
|
|
27
27
|
* to override the default.
|
|
28
28
|
*/
|
|
29
|
-
keyboardDelegate?: KeyboardDelegate
|
|
30
|
-
/**
|
|
31
|
-
* A function that returns the text that should be announced by assistive technology when a row is added or removed from selection.
|
|
32
|
-
* @default (key) => state.collection.getItem(key)?.textValue
|
|
33
|
-
*/
|
|
34
|
-
getRowText?: (key: Key) => string
|
|
29
|
+
keyboardDelegate?: KeyboardDelegate
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
export interface GridListAria {
|
|
@@ -41,7 +36,7 @@ export interface GridListAria {
|
|
|
41
36
|
|
|
42
37
|
/**
|
|
43
38
|
* Provides the behavior and accessibility implementation for a list component with interactive children.
|
|
44
|
-
* A grid list displays data in a single
|
|
39
|
+
* A grid list displays data in a single column and enables a user to navigate its contents via directional navigation keys.
|
|
45
40
|
* @param props - Props for the list.
|
|
46
41
|
* @param state - State for the list, as returned by `useListState`.
|
|
47
42
|
* @param ref - The ref attached to the list element.
|
|
@@ -50,7 +45,6 @@ export function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T
|
|
|
50
45
|
let {
|
|
51
46
|
isVirtualized,
|
|
52
47
|
keyboardDelegate,
|
|
53
|
-
getRowText,
|
|
54
48
|
onAction
|
|
55
49
|
} = props;
|
|
56
50
|
|
|
@@ -93,7 +87,7 @@ export function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T
|
|
|
93
87
|
gridProps['aria-colcount'] = 1;
|
|
94
88
|
}
|
|
95
89
|
|
|
96
|
-
useGridSelectionAnnouncement({
|
|
90
|
+
useGridSelectionAnnouncement({}, state);
|
|
97
91
|
|
|
98
92
|
return {
|
|
99
93
|
gridProps
|