@react-aria/gridlist 3.0.0-nightly-641446f65-240905
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/README.md +3 -0
- package/dist/import.mjs +21 -0
- package/dist/main.js +28 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +21 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useGridList.main.js +79 -0
- package/dist/useGridList.main.js.map +1 -0
- package/dist/useGridList.mjs +74 -0
- package/dist/useGridList.module.js +74 -0
- package/dist/useGridList.module.js.map +1 -0
- package/dist/useGridListItem.main.js +258 -0
- package/dist/useGridListItem.main.js.map +1 -0
- package/dist/useGridListItem.mjs +253 -0
- package/dist/useGridListItem.module.js +253 -0
- package/dist/useGridListItem.module.js.map +1 -0
- package/dist/useGridListSelectionCheckbox.main.js +34 -0
- package/dist/useGridListSelectionCheckbox.main.js.map +1 -0
- package/dist/useGridListSelectionCheckbox.mjs +29 -0
- package/dist/useGridListSelectionCheckbox.module.js +29 -0
- package/dist/useGridListSelectionCheckbox.module.js.map +1 -0
- package/dist/utils.main.js +30 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +24 -0
- package/dist/utils.module.js +24 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +45 -0
- package/src/index.ts +19 -0
- package/src/useGridList.ts +154 -0
- package/src/useGridListItem.ts +299 -0
- package/src/useGridListSelectionCheckbox.ts +32 -0
- package/src/utils.ts +42 -0
package/README.md
ADDED
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {useGridList as $f47efb0c3a859cf2$export$664f9155035607eb} from "./useGridList.mjs";
|
|
2
|
+
import {useGridListItem as $4e8b0456ef72939f$export$9610e69494fadfd2} from "./useGridListItem.mjs";
|
|
3
|
+
import {useGridListSelectionCheckbox as $e52ffc04a4adbd52$export$e29f2573fabbf7b9} from "./useGridListSelectionCheckbox.mjs";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export {$f47efb0c3a859cf2$export$664f9155035607eb as useGridList, $4e8b0456ef72939f$export$9610e69494fadfd2 as useGridListItem, $e52ffc04a4adbd52$export$e29f2573fabbf7b9 as useGridListSelectionCheckbox};
|
|
21
|
+
//# sourceMappingURL=module.js.map
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var $acf209ae814f1c93$exports = require("./useGridList.main.js");
|
|
2
|
+
var $f7116f5928c03f32$exports = require("./useGridListItem.main.js");
|
|
3
|
+
var $43131ea217bc2ad3$exports = require("./useGridListSelectionCheckbox.main.js");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$parcel$export(module.exports, "useGridList", () => $acf209ae814f1c93$exports.useGridList);
|
|
11
|
+
$parcel$export(module.exports, "useGridListItem", () => $f7116f5928c03f32$exports.useGridListItem);
|
|
12
|
+
$parcel$export(module.exports, "useGridListSelectionCheckbox", () => $43131ea217bc2ad3$exports.useGridListSelectionCheckbox);
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/gridlist/src/index.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, AriaGridListProps, GridListAria, GridListProps} from './useGridList';\nexport type {AriaGridListItemOptions, GridListItemAria} from './useGridListItem';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from '@react-aria/grid';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {useGridList as $f47efb0c3a859cf2$export$664f9155035607eb} from "./useGridList.module.js";
|
|
2
|
+
import {useGridListItem as $4e8b0456ef72939f$export$9610e69494fadfd2} from "./useGridListItem.module.js";
|
|
3
|
+
import {useGridListSelectionCheckbox as $e52ffc04a4adbd52$export$e29f2573fabbf7b9} from "./useGridListSelectionCheckbox.module.js";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export {$f47efb0c3a859cf2$export$664f9155035607eb as useGridList, $4e8b0456ef72939f$export$9610e69494fadfd2 as useGridListItem, $e52ffc04a4adbd52$export$e29f2573fabbf7b9 as useGridListSelectionCheckbox};
|
|
21
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/gridlist/src/index.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, AriaGridListProps, GridListAria, GridListProps} from './useGridList';\nexport type {AriaGridListItemOptions, GridListItemAria} from './useGridListItem';\nexport type {AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria} from '@react-aria/grid';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { AriaLabelingProps, CollectionBase, DisabledBehavior, DOMAttributes, DOMProps, Key, KeyboardDelegate, LayoutDelegate, MultipleSelection, RefObject, FocusableElement, Node } from "@react-types/shared";
|
|
2
|
+
import { ListState } from "@react-stately/list";
|
|
3
|
+
import { SelectableItemStates } from "@react-aria/selection";
|
|
4
|
+
import { TreeState } from "@react-stately/tree";
|
|
5
|
+
import { AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria } from "@react-aria/grid";
|
|
6
|
+
export interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {
|
|
7
|
+
/**
|
|
8
|
+
* Handler that is called when a user performs an action on an item. The exact user event depends on
|
|
9
|
+
* the collection's `selectionBehavior` prop and the interaction modality.
|
|
10
|
+
*/
|
|
11
|
+
onAction?: (key: Key) => void;
|
|
12
|
+
/** Whether `disabledKeys` applies to all interactions, or only selection. */
|
|
13
|
+
disabledBehavior?: DisabledBehavior;
|
|
14
|
+
}
|
|
15
|
+
export interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {
|
|
16
|
+
/**
|
|
17
|
+
* Whether keyboard navigation to focusable elements within grid list items is
|
|
18
|
+
* via the left/right arrow keys or the tab key.
|
|
19
|
+
* @default 'arrow'
|
|
20
|
+
*/
|
|
21
|
+
keyboardNavigationBehavior?: 'arrow' | 'tab';
|
|
22
|
+
}
|
|
23
|
+
export interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {
|
|
24
|
+
/** Whether the list uses virtual scrolling. */
|
|
25
|
+
isVirtualized?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* An optional keyboard delegate implementation for type to select,
|
|
28
|
+
* to override the default.
|
|
29
|
+
*/
|
|
30
|
+
keyboardDelegate?: KeyboardDelegate;
|
|
31
|
+
/**
|
|
32
|
+
* A delegate object that provides layout information for items in the collection.
|
|
33
|
+
* By default this uses the DOM, but this can be overridden to implement things like
|
|
34
|
+
* virtualized scrolling.
|
|
35
|
+
*/
|
|
36
|
+
layoutDelegate?: LayoutDelegate;
|
|
37
|
+
/**
|
|
38
|
+
* Whether focus should wrap around when the end/start is reached.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
shouldFocusWrap?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The behavior of links in the collection.
|
|
44
|
+
* - 'action': link behaves like onAction.
|
|
45
|
+
* - 'selection': link follows selection interactions (e.g. if URL drives selection).
|
|
46
|
+
* - 'override': links override all other interactions (link items are not selectable).
|
|
47
|
+
* @default 'action'
|
|
48
|
+
*/
|
|
49
|
+
linkBehavior?: 'action' | 'selection' | 'override';
|
|
50
|
+
}
|
|
51
|
+
export interface GridListAria {
|
|
52
|
+
/** Props for the grid element. */
|
|
53
|
+
gridProps: DOMAttributes;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Provides the behavior and accessibility implementation for a list component with interactive children.
|
|
57
|
+
* A grid list displays data in a single column and enables a user to navigate its contents via directional navigation keys.
|
|
58
|
+
* @param props - Props for the list.
|
|
59
|
+
* @param state - State for the list, as returned by `useListState`.
|
|
60
|
+
* @param ref - The ref attached to the list element.
|
|
61
|
+
*/
|
|
62
|
+
export function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T>, ref: RefObject<HTMLElement | null>): GridListAria;
|
|
63
|
+
export interface AriaGridListItemOptions {
|
|
64
|
+
/** An object representing the list item. Contains all the relevant information that makes up the list row. */
|
|
65
|
+
node: Node<unknown>;
|
|
66
|
+
/** Whether the list row is contained in a virtual scroller. */
|
|
67
|
+
isVirtualized?: boolean;
|
|
68
|
+
/** Whether selection should occur on press up instead of press down. */
|
|
69
|
+
shouldSelectOnPressUp?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface GridListItemAria extends SelectableItemStates {
|
|
72
|
+
/** Props for the list row element. */
|
|
73
|
+
rowProps: DOMAttributes;
|
|
74
|
+
/** Props for the grid cell element within the list row. */
|
|
75
|
+
gridCellProps: DOMAttributes;
|
|
76
|
+
/** Props for the list item description element, if any. */
|
|
77
|
+
descriptionProps: DOMAttributes;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Provides the behavior and accessibility implementation for a row in a grid list.
|
|
81
|
+
* @param props - Props for the row.
|
|
82
|
+
* @param state - State of the parent list, as returned by `useListState`.
|
|
83
|
+
* @param ref - The ref attached to the row element.
|
|
84
|
+
*/
|
|
85
|
+
export function useGridListItem<T>(props: AriaGridListItemOptions, state: ListState<T> | TreeState<T>, ref: RefObject<FocusableElement | null>): GridListItemAria;
|
|
86
|
+
/**
|
|
87
|
+
* Provides the behavior and accessibility implementation for a selection checkbox in a grid list.
|
|
88
|
+
* @param props - Props for the selection checkbox.
|
|
89
|
+
* @param state - State of the list, as returned by `useListState`.
|
|
90
|
+
*/
|
|
91
|
+
export function useGridListSelectionCheckbox<T>(props: AriaGridSelectionCheckboxProps, state: ListState<T>): GridSelectionCheckboxAria;
|
|
92
|
+
export type { AriaGridSelectionCheckboxProps, GridSelectionCheckboxAria } from '@react-aria/grid';
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;AC+BA,+BAA+B,CAAC,CAAE,SAAQ,eAAe,CAAC,CAAC,EAAE,iBAAiB;IAC5E;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAC9B,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED,mCAAmC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,iBAAiB;IACzF;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;CAC7C;AAED,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,CAAC;IACpC;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAA;CACnD;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,GAAG,IAAI,CAAC,GAAG,YAAY,CA8DnI;ACjID;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;AAaD;;;;;GAKG;AACH,gCAAgC,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,gBAAgB,CAmOhK;AC9QD;;;;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, AriaGridListProps, GridListAria, GridListProps} 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"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var $7db02799adae605d$exports = require("./utils.main.js");
|
|
2
|
+
var $i2dnl$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $i2dnl$reactariagrid = require("@react-aria/grid");
|
|
4
|
+
var $i2dnl$reactariafocus = require("@react-aria/focus");
|
|
5
|
+
var $i2dnl$reactariaselection = require("@react-aria/selection");
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function $parcel$export(e, n, v, s) {
|
|
9
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
$parcel$export(module.exports, "useGridList", () => $acf209ae814f1c93$export$664f9155035607eb);
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function $acf209ae814f1c93$export$664f9155035607eb(props, state, ref) {
|
|
29
|
+
let { isVirtualized: isVirtualized, keyboardDelegate: keyboardDelegate, layoutDelegate: layoutDelegate, onAction: onAction, linkBehavior: linkBehavior = 'action', keyboardNavigationBehavior: keyboardNavigationBehavior = 'arrow' } = props;
|
|
30
|
+
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
31
|
+
let { listProps: listProps } = (0, $i2dnl$reactariaselection.useSelectableList)({
|
|
32
|
+
selectionManager: state.selectionManager,
|
|
33
|
+
collection: state.collection,
|
|
34
|
+
disabledKeys: state.disabledKeys,
|
|
35
|
+
ref: ref,
|
|
36
|
+
keyboardDelegate: keyboardDelegate,
|
|
37
|
+
layoutDelegate: layoutDelegate,
|
|
38
|
+
isVirtualized: isVirtualized,
|
|
39
|
+
selectOnFocus: state.selectionManager.selectionBehavior === 'replace',
|
|
40
|
+
shouldFocusWrap: props.shouldFocusWrap,
|
|
41
|
+
linkBehavior: linkBehavior
|
|
42
|
+
});
|
|
43
|
+
let id = (0, $i2dnl$reactariautils.useId)(props.id);
|
|
44
|
+
(0, $7db02799adae605d$exports.listMap).set(state, {
|
|
45
|
+
id: id,
|
|
46
|
+
onAction: onAction,
|
|
47
|
+
linkBehavior: linkBehavior,
|
|
48
|
+
keyboardNavigationBehavior: keyboardNavigationBehavior
|
|
49
|
+
});
|
|
50
|
+
let descriptionProps = (0, $i2dnl$reactariagrid.useHighlightSelectionDescription)({
|
|
51
|
+
selectionManager: state.selectionManager,
|
|
52
|
+
hasItemActions: !!onAction
|
|
53
|
+
});
|
|
54
|
+
let hasTabbableChild = (0, $i2dnl$reactariafocus.useHasTabbableChild)(ref, {
|
|
55
|
+
isDisabled: state.collection.size !== 0
|
|
56
|
+
});
|
|
57
|
+
let domProps = (0, $i2dnl$reactariautils.filterDOMProps)(props, {
|
|
58
|
+
labelable: true
|
|
59
|
+
});
|
|
60
|
+
let gridProps = (0, $i2dnl$reactariautils.mergeProps)(domProps, {
|
|
61
|
+
role: 'grid',
|
|
62
|
+
id: id,
|
|
63
|
+
'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined
|
|
64
|
+
}, // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.
|
|
65
|
+
state.collection.size === 0 ? {
|
|
66
|
+
tabIndex: hasTabbableChild ? -1 : 0
|
|
67
|
+
} : listProps, descriptionProps);
|
|
68
|
+
if (isVirtualized) {
|
|
69
|
+
gridProps['aria-rowcount'] = state.collection.size;
|
|
70
|
+
gridProps['aria-colcount'] = 1;
|
|
71
|
+
}
|
|
72
|
+
(0, $i2dnl$reactariagrid.useGridSelectionAnnouncement)({}, state);
|
|
73
|
+
return {
|
|
74
|
+
gridProps: gridProps
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=useGridList.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiFM,SAAS,0CAAe,KAA6B,EAAE,KAAmB,EAAE,GAAkC;IACnH,IAAI,iBACF,aAAa,oBACb,gBAAgB,kBAChB,cAAc,YACd,QAAQ,gBACR,eAAe,sCACf,6BAA6B,SAC9B,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAClC,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;aAChC;0BACA;wBACA;uBACA;QACA,eAAe,MAAM,gBAAgB,CAAC,iBAAiB,KAAK;QAC5D,iBAAiB,MAAM,eAAe;sBACtC;IACF;IAEA,IAAI,KAAK,CAAA,GAAA,2BAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,iCAAM,EAAE,GAAG,CAAC,OAAO;YAAC;kBAAI;sBAAU;oCAAc;IAA0B;IAE1E,IAAI,mBAAmB,CAAA,GAAA,qDAA+B,EAAE;QACtD,kBAAkB,MAAM,gBAAgB;QACxC,gBAAgB,CAAC,CAAC;IACpB;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,YAA2B,CAAA,GAAA,gCAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBAAwB,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa,SAAS;IACzF,GACA,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,iDAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/gridlist/src/useGridList.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\nimport {\n AriaLabelingProps,\n CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listMap} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid';\nimport {useHasTabbableChild} from '@react-aria/focus';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void,\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab'\n}\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 delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate,\n /**\n * Whether focus should wrap around when the end/start is reached.\n * @default false\n */\n shouldFocusWrap?: boolean,\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override'\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 | null>): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow'\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,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior\n });\n\n let id = useId(props.id);\n listMap.set(state, {id, onAction, linkBehavior, keyboardNavigationBehavior});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\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 // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : 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"],"names":[],"version":3,"file":"useGridList.main.js.map"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {listMap as $ce9b18daab526bbd$export$5b9bb410392e3991} from "./utils.mjs";
|
|
2
|
+
import {useId as $lnALe$useId, filterDOMProps as $lnALe$filterDOMProps, mergeProps as $lnALe$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useHighlightSelectionDescription as $lnALe$useHighlightSelectionDescription, useGridSelectionAnnouncement as $lnALe$useGridSelectionAnnouncement} from "@react-aria/grid";
|
|
4
|
+
import {useHasTabbableChild as $lnALe$useHasTabbableChild} from "@react-aria/focus";
|
|
5
|
+
import {useSelectableList as $lnALe$useSelectableList} from "@react-aria/selection";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function $f47efb0c3a859cf2$export$664f9155035607eb(props, state, ref) {
|
|
23
|
+
let { isVirtualized: isVirtualized, keyboardDelegate: keyboardDelegate, layoutDelegate: layoutDelegate, onAction: onAction, linkBehavior: linkBehavior = 'action', keyboardNavigationBehavior: keyboardNavigationBehavior = 'arrow' } = props;
|
|
24
|
+
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
25
|
+
let { listProps: listProps } = (0, $lnALe$useSelectableList)({
|
|
26
|
+
selectionManager: state.selectionManager,
|
|
27
|
+
collection: state.collection,
|
|
28
|
+
disabledKeys: state.disabledKeys,
|
|
29
|
+
ref: ref,
|
|
30
|
+
keyboardDelegate: keyboardDelegate,
|
|
31
|
+
layoutDelegate: layoutDelegate,
|
|
32
|
+
isVirtualized: isVirtualized,
|
|
33
|
+
selectOnFocus: state.selectionManager.selectionBehavior === 'replace',
|
|
34
|
+
shouldFocusWrap: props.shouldFocusWrap,
|
|
35
|
+
linkBehavior: linkBehavior
|
|
36
|
+
});
|
|
37
|
+
let id = (0, $lnALe$useId)(props.id);
|
|
38
|
+
(0, $ce9b18daab526bbd$export$5b9bb410392e3991).set(state, {
|
|
39
|
+
id: id,
|
|
40
|
+
onAction: onAction,
|
|
41
|
+
linkBehavior: linkBehavior,
|
|
42
|
+
keyboardNavigationBehavior: keyboardNavigationBehavior
|
|
43
|
+
});
|
|
44
|
+
let descriptionProps = (0, $lnALe$useHighlightSelectionDescription)({
|
|
45
|
+
selectionManager: state.selectionManager,
|
|
46
|
+
hasItemActions: !!onAction
|
|
47
|
+
});
|
|
48
|
+
let hasTabbableChild = (0, $lnALe$useHasTabbableChild)(ref, {
|
|
49
|
+
isDisabled: state.collection.size !== 0
|
|
50
|
+
});
|
|
51
|
+
let domProps = (0, $lnALe$filterDOMProps)(props, {
|
|
52
|
+
labelable: true
|
|
53
|
+
});
|
|
54
|
+
let gridProps = (0, $lnALe$mergeProps)(domProps, {
|
|
55
|
+
role: 'grid',
|
|
56
|
+
id: id,
|
|
57
|
+
'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined
|
|
58
|
+
}, // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.
|
|
59
|
+
state.collection.size === 0 ? {
|
|
60
|
+
tabIndex: hasTabbableChild ? -1 : 0
|
|
61
|
+
} : listProps, descriptionProps);
|
|
62
|
+
if (isVirtualized) {
|
|
63
|
+
gridProps['aria-rowcount'] = state.collection.size;
|
|
64
|
+
gridProps['aria-colcount'] = 1;
|
|
65
|
+
}
|
|
66
|
+
(0, $lnALe$useGridSelectionAnnouncement)({}, state);
|
|
67
|
+
return {
|
|
68
|
+
gridProps: gridProps
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export {$f47efb0c3a859cf2$export$664f9155035607eb as useGridList};
|
|
74
|
+
//# sourceMappingURL=useGridList.module.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {listMap as $ce9b18daab526bbd$export$5b9bb410392e3991} from "./utils.module.js";
|
|
2
|
+
import {useId as $lnALe$useId, filterDOMProps as $lnALe$filterDOMProps, mergeProps as $lnALe$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useHighlightSelectionDescription as $lnALe$useHighlightSelectionDescription, useGridSelectionAnnouncement as $lnALe$useGridSelectionAnnouncement} from "@react-aria/grid";
|
|
4
|
+
import {useHasTabbableChild as $lnALe$useHasTabbableChild} from "@react-aria/focus";
|
|
5
|
+
import {useSelectableList as $lnALe$useSelectableList} from "@react-aria/selection";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
function $f47efb0c3a859cf2$export$664f9155035607eb(props, state, ref) {
|
|
23
|
+
let { isVirtualized: isVirtualized, keyboardDelegate: keyboardDelegate, layoutDelegate: layoutDelegate, onAction: onAction, linkBehavior: linkBehavior = 'action', keyboardNavigationBehavior: keyboardNavigationBehavior = 'arrow' } = props;
|
|
24
|
+
if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
|
|
25
|
+
let { listProps: listProps } = (0, $lnALe$useSelectableList)({
|
|
26
|
+
selectionManager: state.selectionManager,
|
|
27
|
+
collection: state.collection,
|
|
28
|
+
disabledKeys: state.disabledKeys,
|
|
29
|
+
ref: ref,
|
|
30
|
+
keyboardDelegate: keyboardDelegate,
|
|
31
|
+
layoutDelegate: layoutDelegate,
|
|
32
|
+
isVirtualized: isVirtualized,
|
|
33
|
+
selectOnFocus: state.selectionManager.selectionBehavior === 'replace',
|
|
34
|
+
shouldFocusWrap: props.shouldFocusWrap,
|
|
35
|
+
linkBehavior: linkBehavior
|
|
36
|
+
});
|
|
37
|
+
let id = (0, $lnALe$useId)(props.id);
|
|
38
|
+
(0, $ce9b18daab526bbd$export$5b9bb410392e3991).set(state, {
|
|
39
|
+
id: id,
|
|
40
|
+
onAction: onAction,
|
|
41
|
+
linkBehavior: linkBehavior,
|
|
42
|
+
keyboardNavigationBehavior: keyboardNavigationBehavior
|
|
43
|
+
});
|
|
44
|
+
let descriptionProps = (0, $lnALe$useHighlightSelectionDescription)({
|
|
45
|
+
selectionManager: state.selectionManager,
|
|
46
|
+
hasItemActions: !!onAction
|
|
47
|
+
});
|
|
48
|
+
let hasTabbableChild = (0, $lnALe$useHasTabbableChild)(ref, {
|
|
49
|
+
isDisabled: state.collection.size !== 0
|
|
50
|
+
});
|
|
51
|
+
let domProps = (0, $lnALe$filterDOMProps)(props, {
|
|
52
|
+
labelable: true
|
|
53
|
+
});
|
|
54
|
+
let gridProps = (0, $lnALe$mergeProps)(domProps, {
|
|
55
|
+
role: 'grid',
|
|
56
|
+
id: id,
|
|
57
|
+
'aria-multiselectable': state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined
|
|
58
|
+
}, // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.
|
|
59
|
+
state.collection.size === 0 ? {
|
|
60
|
+
tabIndex: hasTabbableChild ? -1 : 0
|
|
61
|
+
} : listProps, descriptionProps);
|
|
62
|
+
if (isVirtualized) {
|
|
63
|
+
gridProps['aria-rowcount'] = state.collection.size;
|
|
64
|
+
gridProps['aria-colcount'] = 1;
|
|
65
|
+
}
|
|
66
|
+
(0, $lnALe$useGridSelectionAnnouncement)({}, state);
|
|
67
|
+
return {
|
|
68
|
+
gridProps: gridProps
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
export {$f47efb0c3a859cf2$export$664f9155035607eb as useGridList};
|
|
74
|
+
//# sourceMappingURL=useGridList.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAiFM,SAAS,0CAAe,KAA6B,EAAE,KAAmB,EAAE,GAAkC;IACnH,IAAI,iBACF,aAAa,oBACb,gBAAgB,kBAChB,cAAc,YACd,QAAQ,gBACR,eAAe,sCACf,6BAA6B,SAC9B,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAClC,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;aAChC;0BACA;wBACA;uBACA;QACA,eAAe,MAAM,gBAAgB,CAAC,iBAAiB,KAAK;QAC5D,iBAAiB,MAAM,eAAe;sBACtC;IACF;IAEA,IAAI,KAAK,CAAA,GAAA,YAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC,OAAO;YAAC;kBAAI;sBAAU;oCAAc;IAA0B;IAE1E,IAAI,mBAAmB,CAAA,GAAA,uCAA+B,EAAE;QACtD,kBAAkB,MAAM,gBAAgB;QACxC,gBAAgB,CAAC,CAAC;IACpB;IAEA,IAAI,mBAAmB,CAAA,GAAA,0BAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,YAA2B,CAAA,GAAA,iBAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBAAwB,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa,SAAS;IACzF,GACA,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,mCAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/gridlist/src/useGridList.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\nimport {\n AriaLabelingProps,\n CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {listMap} from './utils';\nimport {ListState} from '@react-stately/list';\nimport {useGridSelectionAnnouncement, useHighlightSelectionDescription} from '@react-aria/grid';\nimport {useHasTabbableChild} from '@react-aria/focus';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends on\n * the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void,\n /** Whether `disabledKeys` applies to all interactions, or only selection. */\n disabledBehavior?: DisabledBehavior\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab'\n}\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 delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate,\n /**\n * Whether focus should wrap around when the end/start is reached.\n * @default false\n */\n shouldFocusWrap?: boolean,\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override'\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 | null>): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow'\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,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior\n });\n\n let id = useId(props.id);\n listMap.set(state, {id, onAction, linkBehavior, keyboardNavigationBehavior});\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\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 // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : 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"],"names":[],"version":3,"file":"useGridList.module.js.map"}
|