@react-aria/tree 3.0.0-nightly.5042 → 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/import.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import {useTree as $6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1} from "./useTree.mjs";
2
- import {useTreeGridList as $1642482277341dec$export$abb2211d46906a63} from "./useTreeGridList.mjs";
3
- import {useTreeGridListItem as $0cbbe9a595ac1615$export$8001083cb3f61028} from "./useTreeGridListItem.mjs";
2
+ import {useTreeItem as $b41e0bc5ca49db3d$export$e4bcc4675b2b123a} from "./useTreeItem.mjs";
4
3
 
5
4
  /*
6
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -16,6 +15,5 @@ import {useTreeGridListItem as $0cbbe9a595ac1615$export$8001083cb3f61028} from "
16
15
 
17
16
 
18
17
 
19
-
20
- export {$6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1 as useTree, $1642482277341dec$export$abb2211d46906a63 as useTreeGridList, $0cbbe9a595ac1615$export$8001083cb3f61028 as useTreeGridListItem};
18
+ export {$6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1 as useTree, $b41e0bc5ca49db3d$export$e4bcc4675b2b123a as useTreeItem};
21
19
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,6 +1,5 @@
1
1
  var $0caa22fd4e1b3c7e$exports = require("./useTree.main.js");
2
- var $41ae298c995bc55f$exports = require("./useTreeGridList.main.js");
3
- var $89b99a0b1379ba07$exports = require("./useTreeGridListItem.main.js");
2
+ var $739d43f6fe8a5583$exports = require("./useTreeItem.main.js");
4
3
 
5
4
 
6
5
  function $parcel$export(e, n, v, s) {
@@ -8,8 +7,7 @@ function $parcel$export(e, n, v, s) {
8
7
  }
9
8
 
10
9
  $parcel$export(module.exports, "useTree", () => $0caa22fd4e1b3c7e$exports.useTree);
11
- $parcel$export(module.exports, "useTreeGridList", () => $41ae298c995bc55f$exports.useTreeGridList);
12
- $parcel$export(module.exports, "useTreeGridListItem", () => $89b99a0b1379ba07$exports.useTreeGridListItem);
10
+ $parcel$export(module.exports, "useTreeItem", () => $739d43f6fe8a5583$exports.useTreeItem);
13
11
  /*
14
12
  * Copyright 2020 Adobe. All rights reserved.
15
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -24,5 +22,4 @@ $parcel$export(module.exports, "useTreeGridListItem", () => $89b99a0b1379ba07$ex
24
22
 
25
23
 
26
24
 
27
-
28
25
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tree/src/index.ts"],"sourcesContent":["/*\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\nexport {useTree} from './useTree';\nexport {useTreeGridList} from './useTreeGridList';\nexport {useTreeGridListItem} from './useTreeGridListItem';\n\nexport type {AriaTreeGridListOptions, AriaTreeGridListProps, TreeGridListAria, TreeGridListProps} from './useTreeGridList';\nexport type {AriaTreeGridListItemOptions, TreeGridListItemAria} from './useTreeGridListItem';\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tree/src/index.ts"],"sourcesContent":["/*\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\nexport {useTree} from './useTree';\nexport {useTreeItem} from './useTreeItem';\n\nexport type {AriaTreeOptions, AriaTreeProps, TreeAria, TreeProps} from './useTree';\nexport type {AriaTreeItemOptions, TreeItemAria} from './useTreeItem';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import {useTree as $6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1} from "./useTree.module.js";
2
- import {useTreeGridList as $1642482277341dec$export$abb2211d46906a63} from "./useTreeGridList.module.js";
3
- import {useTreeGridListItem as $0cbbe9a595ac1615$export$8001083cb3f61028} from "./useTreeGridListItem.module.js";
2
+ import {useTreeItem as $b41e0bc5ca49db3d$export$e4bcc4675b2b123a} from "./useTreeItem.module.js";
4
3
 
5
4
  /*
6
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -16,6 +15,5 @@ import {useTreeGridListItem as $0cbbe9a595ac1615$export$8001083cb3f61028} from "
16
15
 
17
16
 
18
17
 
19
-
20
- export {$6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1 as useTree, $1642482277341dec$export$abb2211d46906a63 as useTreeGridList, $0cbbe9a595ac1615$export$8001083cb3f61028 as useTreeGridListItem};
18
+ export {$6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1 as useTree, $b41e0bc5ca49db3d$export$e4bcc4675b2b123a as useTreeItem};
21
19
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tree/src/index.ts"],"sourcesContent":["/*\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\nexport {useTree} from './useTree';\nexport {useTreeGridList} from './useTreeGridList';\nexport {useTreeGridListItem} from './useTreeGridListItem';\n\nexport type {AriaTreeGridListOptions, AriaTreeGridListProps, TreeGridListAria, TreeGridListProps} from './useTreeGridList';\nexport type {AriaTreeGridListItemOptions, TreeGridListItemAria} from './useTreeGridListItem';\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tree/src/index.ts"],"sourcesContent":["/*\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\nexport {useTree} from './useTree';\nexport {useTreeItem} from './useTreeItem';\n\nexport type {AriaTreeOptions, AriaTreeProps, TreeAria, TreeProps} from './useTree';\nexport type {AriaTreeItemOptions, TreeItemAria} from './useTreeItem';\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -2,19 +2,18 @@ import { AriaGridListOptions, AriaGridListProps, GridListProps, AriaGridListItem
2
2
  import { DOMAttributes, KeyboardDelegate, RefObject, FocusableElement, Node } from "@react-types/shared";
3
3
  import { TreeState } from "@react-stately/tree";
4
4
  import { AriaButtonProps } from "@react-types/button";
5
- export function useTree(): {};
6
- export interface TreeGridListProps<T> extends GridListProps<T> {
5
+ export interface TreeProps<T> extends GridListProps<T> {
7
6
  }
8
- export interface AriaTreeGridListProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {
7
+ export interface AriaTreeProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {
9
8
  }
10
- export interface AriaTreeGridListOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {
9
+ export interface AriaTreeOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {
11
10
  /**
12
11
  * An optional keyboard delegate implementation for type to select,
13
12
  * to override the default.
14
13
  */
15
14
  keyboardDelegate?: KeyboardDelegate;
16
15
  }
17
- export interface TreeGridListAria {
16
+ export interface TreeAria {
18
17
  /** Props for the treegrid element. */
19
18
  gridProps: DOMAttributes;
20
19
  }
@@ -25,12 +24,12 @@ export interface TreeGridListAria {
25
24
  * @param state - State for the treegrid, as returned by `useTreeState`.
26
25
  * @param ref - The ref attached to the treegrid element.
27
26
  */
28
- export function useTreeGridList<T>(props: AriaTreeGridListOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeGridListAria;
29
- export interface AriaTreeGridListItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {
27
+ export function useTree<T>(props: AriaTreeOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeAria;
28
+ export interface AriaTreeItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {
30
29
  /** An object representing the treegrid item. Contains all the relevant information that makes up the treegrid row. */
31
30
  node: Node<unknown>;
32
31
  }
33
- export interface TreeGridListItemAria extends GridListItemAria {
32
+ export interface TreeItemAria extends GridListItemAria {
34
33
  /** Props for the tree grid row element. */
35
34
  rowProps: DOMAttributes;
36
35
  /** Props for the tree grid cell element within the tree grid list row. */
@@ -46,6 +45,6 @@ export interface TreeGridListItemAria extends GridListItemAria {
46
45
  * @param state - State of the parent list, as returned by `useTreeState`.
47
46
  * @param ref - The ref attached to the row element.
48
47
  */
49
- export function useTreeGridListItem<T>(props: AriaTreeGridListItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeGridListItemAria;
48
+ export function useTreeItem<T>(props: AriaTreeItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeItemAria;
50
49
 
51
50
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;;AAYA,8BAEC;ACMD,mCAAmC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC;CAAG;AAEjE,uCAAuC,CAAC,CAAE,SAAQ,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,4BAA4B,CAAC;CAAG;AAC7G,yCAAyC,CAAC,CAAE,SAAQ,IAAI,CAAC,oBAAoB,CAAC,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC;IAC9G;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED;IACE,sCAAsC;IACtC,SAAS,EAAE,aAAa,CAAA;CACzB;AAED;;;;;;GAMG;AACH,gCAAgC,CAAC,EAAE,KAAK,EAAE,wBAAwB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,GAAG,gBAAgB,CAO/I;AC7BD,4CAA6C,SAAQ,IAAI,CAAC,uBAAuB,EAAE,eAAe,CAAC;IACjG,sHAAsH;IACtH,IAAI,EAAE,KAAK,OAAO,CAAC,CAAA;CACpB;AAED,qCAAsC,SAAQ,gBAAgB;IAC5D,2CAA2C;IAC3C,QAAQ,EAAE,aAAa,CAAC;IACxB,0EAA0E;IAC1E,aAAa,EAAE,aAAa,CAAC;IAC7B,+DAA+D;IAC/D,gBAAgB,EAAE,aAAa,CAAC;IAChC,iDAAiD;IACjD,iBAAiB,EAAE,eAAe,CAAA;CACnC;AAED;;;;;GAKG;AACH,oCAAoC,CAAC,EAAE,KAAK,EAAE,2BAA2B,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,oBAAoB,CAwB7J","sources":["packages/@react-aria/tree/src/packages/@react-aria/tree/src/useTree.ts","packages/@react-aria/tree/src/packages/@react-aria/tree/src/useTreeGridList.ts","packages/@react-aria/tree/src/packages/@react-aria/tree/src/useTreeGridListItem.ts","packages/@react-aria/tree/src/packages/@react-aria/tree/src/index.ts","packages/@react-aria/tree/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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\nexport {useTree} from './useTree';\nexport {useTreeGridList} from './useTreeGridList';\nexport {useTreeGridListItem} from './useTreeGridListItem';\n\nexport type {AriaTreeGridListOptions, AriaTreeGridListProps, TreeGridListAria, TreeGridListProps} from './useTreeGridList';\nexport type {AriaTreeGridListItemOptions, TreeGridListItemAria} from './useTreeGridListItem';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;AAoBA,2BAA2B,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC;CAAG;AAEzD,+BAA+B,CAAC,CAAE,SAAQ,IAAI,CAAC,kBAAkB,CAAC,CAAC,EAAE,4BAA4B,CAAC;CAAG;AACrG,iCAAiC,CAAC,CAAE,SAAQ,IAAI,CAAC,oBAAoB,CAAC,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACtG;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED;IACE,sCAAsC;IACtC,SAAS,EAAE,aAAa,CAAA;CACzB;AAED;;;;;;GAMG;AACH,wBAAwB,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,GAAG,QAAQ,CAOvH;AC7BD,oCAAqC,SAAQ,IAAI,CAAC,uBAAuB,EAAE,eAAe,CAAC;IACzF,sHAAsH;IACtH,IAAI,EAAE,KAAK,OAAO,CAAC,CAAA;CACpB;AAED,6BAA8B,SAAQ,gBAAgB;IACpD,2CAA2C;IAC3C,QAAQ,EAAE,aAAa,CAAC;IACxB,0EAA0E;IAC1E,aAAa,EAAE,aAAa,CAAC;IAC7B,+DAA+D;IAC/D,gBAAgB,EAAE,aAAa,CAAC;IAChC,iDAAiD;IACjD,iBAAiB,EAAE,eAAe,CAAA;CACnC;AAED;;;;;GAKG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,YAAY,CA4BrI","sources":["packages/@react-aria/tree/src/packages/@react-aria/tree/src/useTree.ts","packages/@react-aria/tree/src/packages/@react-aria/tree/src/useTreeItem.ts","packages/@react-aria/tree/src/packages/@react-aria/tree/src/index.ts","packages/@react-aria/tree/src/index.ts"],"sourcesContent":[null,null,null,"/*\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\nexport {useTree} from './useTree';\nexport {useTreeItem} from './useTreeItem';\n\nexport type {AriaTreeOptions, AriaTreeProps, TreeAria, TreeProps} from './useTree';\nexport type {AriaTreeItemOptions, TreeItemAria} from './useTreeItem';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1,3 +1,5 @@
1
+ var $hREOp$reactariagridlist = require("@react-aria/gridlist");
2
+
1
3
 
2
4
  function $parcel$export(e, n, v, s) {
3
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
@@ -5,7 +7,7 @@ function $parcel$export(e, n, v, s) {
5
7
 
6
8
  $parcel$export(module.exports, "useTree", () => $0caa22fd4e1b3c7e$export$fb0040ce9d6e8bd1);
7
9
  /*
8
- * Copyright 2020 Adobe. All rights reserved.
10
+ * Copyright 2024 Adobe. All rights reserved.
9
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
12
  * you may not use this file except in compliance with the License. You may obtain a copy
11
13
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -14,8 +16,13 @@ $parcel$export(module.exports, "useTree", () => $0caa22fd4e1b3c7e$export$fb0040c
14
16
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
17
  * OF ANY KIND, either express or implied. See the License for the specific language
16
18
  * governing permissions and limitations under the License.
17
- */ function $0caa22fd4e1b3c7e$export$fb0040ce9d6e8bd1() {
18
- return {};
19
+ */
20
+ function $0caa22fd4e1b3c7e$export$fb0040ce9d6e8bd1(props, state, ref) {
21
+ let { gridProps: gridProps } = (0, $hREOp$reactariagridlist.useGridList)(props, state, ref);
22
+ gridProps.role = 'treegrid';
23
+ return {
24
+ gridProps: gridProps
25
+ };
19
26
  }
20
27
 
21
28
 
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAEM,SAAS;IACd,OAAO,CAAC;AACV","sources":["packages/@react-aria/tree/src/useTree.ts"],"sourcesContent":["/*\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\nexport function useTree() {\n return {};\n}\n"],"names":[],"version":3,"file":"useTree.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAiCM,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,oCAAU,EAAE,OAAO,OAAO;IAC5C,UAAU,IAAI,GAAG;IAEjB,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/tree/src/useTree.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaGridListOptions, AriaGridListProps, GridListProps, useGridList} from '@react-aria/gridlist';\nimport {\n DOMAttributes,\n KeyboardDelegate,\n RefObject\n} from '@react-types/shared';\nimport {TreeState} from '@react-stately/tree';\n\nexport interface TreeProps<T> extends GridListProps<T> {}\n\nexport interface AriaTreeProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {}\nexport interface AriaTreeOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface TreeAria {\n /** Props for the treegrid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a single column treegrid component with interactive children.\n * A tree grid provides users with a way to navigate nested hierarchical information.\n * @param props - Props for the treegrid.\n * @param state - State for the treegrid, as returned by `useTreeState`.\n * @param ref - The ref attached to the treegrid element.\n */\nexport function useTree<T>(props: AriaTreeOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeAria {\n let {gridProps} = useGridList(props, state, ref);\n gridProps.role = 'treegrid';\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useTree.main.js.map"}
package/dist/useTree.mjs CHANGED
@@ -1,5 +1,7 @@
1
+ import {useGridList as $gdAyK$useGridList} from "@react-aria/gridlist";
2
+
1
3
  /*
2
- * Copyright 2020 Adobe. All rights reserved.
4
+ * Copyright 2024 Adobe. All rights reserved.
3
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
6
  * you may not use this file except in compliance with the License. You may obtain a copy
5
7
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -8,8 +10,13 @@
8
10
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
11
  * OF ANY KIND, either express or implied. See the License for the specific language
10
12
  * governing permissions and limitations under the License.
11
- */ function $6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1() {
12
- return {};
13
+ */
14
+ function $6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1(props, state, ref) {
15
+ let { gridProps: gridProps } = (0, $gdAyK$useGridList)(props, state, ref);
16
+ gridProps.role = 'treegrid';
17
+ return {
18
+ gridProps: gridProps
19
+ };
13
20
  }
14
21
 
15
22
 
@@ -1,5 +1,7 @@
1
+ import {useGridList as $gdAyK$useGridList} from "@react-aria/gridlist";
2
+
1
3
  /*
2
- * Copyright 2020 Adobe. All rights reserved.
4
+ * Copyright 2024 Adobe. All rights reserved.
3
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
6
  * you may not use this file except in compliance with the License. You may obtain a copy
5
7
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -8,8 +10,13 @@
8
10
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
11
  * OF ANY KIND, either express or implied. See the License for the specific language
10
12
  * governing permissions and limitations under the License.
11
- */ function $6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1() {
12
- return {};
13
+ */
14
+ function $6d8a57ce39fda2fa$export$fb0040ce9d6e8bd1(props, state, ref) {
15
+ let { gridProps: gridProps } = (0, $gdAyK$useGridList)(props, state, ref);
16
+ gridProps.role = 'treegrid';
17
+ return {
18
+ gridProps: gridProps
19
+ };
13
20
  }
14
21
 
15
22
 
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAEM,SAAS;IACd,OAAO,CAAC;AACV","sources":["packages/@react-aria/tree/src/useTree.ts"],"sourcesContent":["/*\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\nexport function useTree() {\n return {};\n}\n"],"names":[],"version":3,"file":"useTree.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAiCM,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,kBAAU,EAAE,OAAO,OAAO;IAC5C,UAAU,IAAI,GAAG;IAEjB,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/tree/src/useTree.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaGridListOptions, AriaGridListProps, GridListProps, useGridList} from '@react-aria/gridlist';\nimport {\n DOMAttributes,\n KeyboardDelegate,\n RefObject\n} from '@react-types/shared';\nimport {TreeState} from '@react-stately/tree';\n\nexport interface TreeProps<T> extends GridListProps<T> {}\n\nexport interface AriaTreeProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {}\nexport interface AriaTreeOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface TreeAria {\n /** Props for the treegrid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a single column treegrid component with interactive children.\n * A tree grid provides users with a way to navigate nested hierarchical information.\n * @param props - Props for the treegrid.\n * @param state - State for the treegrid, as returned by `useTreeState`.\n * @param ref - The ref attached to the treegrid element.\n */\nexport function useTree<T>(props: AriaTreeOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeAria {\n let {gridProps} = useGridList(props, state, ref);\n gridProps.role = 'treegrid';\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useTree.module.js.map"}
@@ -1,7 +1,7 @@
1
1
  var $6fc07bed32f3daee$exports = require("./intlStrings.main.js");
2
- var $gqXxM$reactariagridlist = require("@react-aria/gridlist");
3
- var $gqXxM$reactariautils = require("@react-aria/utils");
4
- var $gqXxM$reactariai18n = require("@react-aria/i18n");
2
+ var $cDrlP$reactariagridlist = require("@react-aria/gridlist");
3
+ var $cDrlP$reactariautils = require("@react-aria/utils");
4
+ var $cDrlP$reactariai18n = require("@react-aria/i18n");
5
5
 
6
6
 
7
7
  function $parcel$interopDefault(a) {
@@ -12,7 +12,7 @@ function $parcel$export(e, n, v, s) {
12
12
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
13
13
  }
14
14
 
15
- $parcel$export(module.exports, "useTreeGridListItem", () => $89b99a0b1379ba07$export$8001083cb3f61028);
15
+ $parcel$export(module.exports, "useTreeItem", () => $739d43f6fe8a5583$export$e4bcc4675b2b123a);
16
16
  /*
17
17
  * Copyright 2024 Adobe. All rights reserved.
18
18
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -27,11 +27,15 @@ $parcel$export(module.exports, "useTreeGridListItem", () => $89b99a0b1379ba07$ex
27
27
 
28
28
 
29
29
 
30
- function $89b99a0b1379ba07$export$8001083cb3f61028(props, state, ref) {
30
+ function $739d43f6fe8a5583$export$e4bcc4675b2b123a(props, state, ref) {
31
31
  let { node: node } = props;
32
- let gridListAria = (0, $gqXxM$reactariagridlist.useGridListItem)(props, state, ref);
32
+ let gridListAria = (0, $cDrlP$reactariagridlist.useGridListItem)(props, state, ref);
33
33
  let isExpanded = gridListAria.rowProps['aria-expanded'] === true;
34
- let stringFormatter = (0, $gqXxM$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($6fc07bed32f3daee$exports))), '@react-aria/tree');
34
+ let stringFormatter = (0, $cDrlP$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($6fc07bed32f3daee$exports))), '@react-aria/tree');
35
+ let labelProps = (0, $cDrlP$reactariautils.useLabels)({
36
+ 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
37
+ 'aria-labelledby': gridListAria.rowProps.id
38
+ });
35
39
  let expandButtonProps = {
36
40
  onPress: ()=>{
37
41
  if (!gridListAria.isDisabled) {
@@ -40,9 +44,9 @@ function $89b99a0b1379ba07$export$8001083cb3f61028(props, state, ref) {
40
44
  state.selectionManager.setFocusedKey(node.key);
41
45
  }
42
46
  },
43
- 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
44
- tabIndex: (0, $gqXxM$reactariautils.isAndroid)() ? -1 : null,
45
- 'data-react-aria-prevent-focus': true
47
+ tabIndex: (0, $cDrlP$reactariautils.isAndroid)() ? -1 : null,
48
+ 'data-react-aria-prevent-focus': true,
49
+ ...labelProps
46
50
  };
47
51
  // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?
48
52
  return {
@@ -52,4 +56,4 @@ function $89b99a0b1379ba07$export$8001083cb3f61028(props, state, ref) {
52
56
  }
53
57
 
54
58
 
55
- //# sourceMappingURL=useTreeGridListItem.main.js.map
59
+ //# sourceMappingURL=useTreeItem.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAe,KAA0B,EAAE,KAAmB,EAAE,GAAuC;IACrH,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,eAAe,CAAA,GAAA,wCAAc,EAAE,OAAO,OAAO;IACjD,IAAI,aAAa,aAAa,QAAQ,CAAC,gBAAgB,KAAK;IAC5D,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,aAAa,CAAA,GAAA,+BAAQ,EAAE;QACzB,cAAc,aAAa,gBAAgB,MAAM,CAAC,cAAc,gBAAgB,MAAM,CAAC;QACvF,mBAAmB,aAAa,QAAQ,CAAC,EAAE;IAC7C;IAEA,IAAI,oBAAoB;QACtB,SAAS;YACP,IAAI,CAAC,aAAa,UAAU,EAAE;gBAC5B,MAAM,SAAS,CAAC,KAAK,GAAG;gBACxB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,GAAG;YAC/C;QACF;QACA,UAAU,CAAA,GAAA,+BAAQ,MAAM,KAAK;QAC7B,iCAAiC;QACjC,GAAG,UAAU;IACf;IAEA,+FAA+F;IAC/F,OAAO;QACL,GAAG,YAAY;2BACf;IACF;AACF","sources":["packages/@react-aria/tree/src/useTreeItem.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaButtonProps} from '@react-types/button';\nimport {AriaGridListItemOptions, GridListItemAria, useGridListItem} from '@react-aria/gridlist';\nimport {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isAndroid, useLabels} from '@react-aria/utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaTreeItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {\n /** An object representing the treegrid item. Contains all the relevant information that makes up the treegrid row. */\n node: Node<unknown>\n}\n\nexport interface TreeItemAria extends GridListItemAria {\n /** Props for the tree grid row element. */\n rowProps: DOMAttributes,\n /** Props for the tree grid cell element within the tree grid list row. */\n gridCellProps: DOMAttributes,\n /** Props for the tree grid row description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the tree grid row expand button. */\n expandButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a tree grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useTreeState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useTreeItem<T>(props: AriaTreeItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeItemAria {\n let {node} = props;\n let gridListAria = useGridListItem(props, state, ref);\n let isExpanded = gridListAria.rowProps['aria-expanded'] === true;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tree');\n let labelProps = useLabels({\n 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),\n 'aria-labelledby': gridListAria.rowProps.id\n });\n\n let expandButtonProps = {\n onPress: () => {\n if (!gridListAria.isDisabled) {\n state.toggleKey(node.key);\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(node.key);\n }\n },\n tabIndex: isAndroid() ? -1 : null,\n 'data-react-aria-prevent-focus': true,\n ...labelProps\n };\n\n // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?\n return {\n ...gridListAria,\n expandButtonProps\n };\n}\n"],"names":[],"version":3,"file":"useTreeItem.main.js.map"}
@@ -1,7 +1,7 @@
1
- import $ho3NY$intlStringsmodulejs from "./intlStrings.mjs";
2
- import {useGridListItem as $ho3NY$useGridListItem} from "@react-aria/gridlist";
3
- import {isAndroid as $ho3NY$isAndroid} from "@react-aria/utils";
4
- import {useLocalizedStringFormatter as $ho3NY$useLocalizedStringFormatter} from "@react-aria/i18n";
1
+ import $f4zHe$intlStringsmodulejs from "./intlStrings.mjs";
2
+ import {useGridListItem as $f4zHe$useGridListItem} from "@react-aria/gridlist";
3
+ import {useLabels as $f4zHe$useLabels, isAndroid as $f4zHe$isAndroid} from "@react-aria/utils";
4
+ import {useLocalizedStringFormatter as $f4zHe$useLocalizedStringFormatter} from "@react-aria/i18n";
5
5
 
6
6
 
7
7
  function $parcel$interopDefault(a) {
@@ -21,11 +21,15 @@ function $parcel$interopDefault(a) {
21
21
 
22
22
 
23
23
 
24
- function $0cbbe9a595ac1615$export$8001083cb3f61028(props, state, ref) {
24
+ function $b41e0bc5ca49db3d$export$e4bcc4675b2b123a(props, state, ref) {
25
25
  let { node: node } = props;
26
- let gridListAria = (0, $ho3NY$useGridListItem)(props, state, ref);
26
+ let gridListAria = (0, $f4zHe$useGridListItem)(props, state, ref);
27
27
  let isExpanded = gridListAria.rowProps['aria-expanded'] === true;
28
- let stringFormatter = (0, $ho3NY$useLocalizedStringFormatter)((0, ($parcel$interopDefault($ho3NY$intlStringsmodulejs))), '@react-aria/tree');
28
+ let stringFormatter = (0, $f4zHe$useLocalizedStringFormatter)((0, ($parcel$interopDefault($f4zHe$intlStringsmodulejs))), '@react-aria/tree');
29
+ let labelProps = (0, $f4zHe$useLabels)({
30
+ 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
31
+ 'aria-labelledby': gridListAria.rowProps.id
32
+ });
29
33
  let expandButtonProps = {
30
34
  onPress: ()=>{
31
35
  if (!gridListAria.isDisabled) {
@@ -34,9 +38,9 @@ function $0cbbe9a595ac1615$export$8001083cb3f61028(props, state, ref) {
34
38
  state.selectionManager.setFocusedKey(node.key);
35
39
  }
36
40
  },
37
- 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
38
- tabIndex: (0, $ho3NY$isAndroid)() ? -1 : null,
39
- 'data-react-aria-prevent-focus': true
41
+ tabIndex: (0, $f4zHe$isAndroid)() ? -1 : null,
42
+ 'data-react-aria-prevent-focus': true,
43
+ ...labelProps
40
44
  };
41
45
  // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?
42
46
  return {
@@ -46,5 +50,5 @@ function $0cbbe9a595ac1615$export$8001083cb3f61028(props, state, ref) {
46
50
  }
47
51
 
48
52
 
49
- export {$0cbbe9a595ac1615$export$8001083cb3f61028 as useTreeGridListItem};
50
- //# sourceMappingURL=useTreeGridListItem.module.js.map
53
+ export {$b41e0bc5ca49db3d$export$e4bcc4675b2b123a as useTreeItem};
54
+ //# sourceMappingURL=useTreeItem.module.js.map
@@ -1,7 +1,7 @@
1
- import $ho3NY$intlStringsmodulejs from "./intlStrings.module.js";
2
- import {useGridListItem as $ho3NY$useGridListItem} from "@react-aria/gridlist";
3
- import {isAndroid as $ho3NY$isAndroid} from "@react-aria/utils";
4
- import {useLocalizedStringFormatter as $ho3NY$useLocalizedStringFormatter} from "@react-aria/i18n";
1
+ import $f4zHe$intlStringsmodulejs from "./intlStrings.module.js";
2
+ import {useGridListItem as $f4zHe$useGridListItem} from "@react-aria/gridlist";
3
+ import {useLabels as $f4zHe$useLabels, isAndroid as $f4zHe$isAndroid} from "@react-aria/utils";
4
+ import {useLocalizedStringFormatter as $f4zHe$useLocalizedStringFormatter} from "@react-aria/i18n";
5
5
 
6
6
 
7
7
  function $parcel$interopDefault(a) {
@@ -21,11 +21,15 @@ function $parcel$interopDefault(a) {
21
21
 
22
22
 
23
23
 
24
- function $0cbbe9a595ac1615$export$8001083cb3f61028(props, state, ref) {
24
+ function $b41e0bc5ca49db3d$export$e4bcc4675b2b123a(props, state, ref) {
25
25
  let { node: node } = props;
26
- let gridListAria = (0, $ho3NY$useGridListItem)(props, state, ref);
26
+ let gridListAria = (0, $f4zHe$useGridListItem)(props, state, ref);
27
27
  let isExpanded = gridListAria.rowProps['aria-expanded'] === true;
28
- let stringFormatter = (0, $ho3NY$useLocalizedStringFormatter)((0, ($parcel$interopDefault($ho3NY$intlStringsmodulejs))), '@react-aria/tree');
28
+ let stringFormatter = (0, $f4zHe$useLocalizedStringFormatter)((0, ($parcel$interopDefault($f4zHe$intlStringsmodulejs))), '@react-aria/tree');
29
+ let labelProps = (0, $f4zHe$useLabels)({
30
+ 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
31
+ 'aria-labelledby': gridListAria.rowProps.id
32
+ });
29
33
  let expandButtonProps = {
30
34
  onPress: ()=>{
31
35
  if (!gridListAria.isDisabled) {
@@ -34,9 +38,9 @@ function $0cbbe9a595ac1615$export$8001083cb3f61028(props, state, ref) {
34
38
  state.selectionManager.setFocusedKey(node.key);
35
39
  }
36
40
  },
37
- 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
38
- tabIndex: (0, $ho3NY$isAndroid)() ? -1 : null,
39
- 'data-react-aria-prevent-focus': true
41
+ tabIndex: (0, $f4zHe$isAndroid)() ? -1 : null,
42
+ 'data-react-aria-prevent-focus': true,
43
+ ...labelProps
40
44
  };
41
45
  // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?
42
46
  return {
@@ -46,5 +50,5 @@ function $0cbbe9a595ac1615$export$8001083cb3f61028(props, state, ref) {
46
50
  }
47
51
 
48
52
 
49
- export {$0cbbe9a595ac1615$export$8001083cb3f61028 as useTreeGridListItem};
50
- //# sourceMappingURL=useTreeGridListItem.module.js.map
53
+ export {$b41e0bc5ca49db3d$export$e4bcc4675b2b123a as useTreeItem};
54
+ //# sourceMappingURL=useTreeItem.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAe,KAA0B,EAAE,KAAmB,EAAE,GAAuC;IACrH,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,eAAe,CAAA,GAAA,sBAAc,EAAE,OAAO,OAAO;IACjD,IAAI,aAAa,aAAa,QAAQ,CAAC,gBAAgB,KAAK;IAC5D,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,aAAa,CAAA,GAAA,gBAAQ,EAAE;QACzB,cAAc,aAAa,gBAAgB,MAAM,CAAC,cAAc,gBAAgB,MAAM,CAAC;QACvF,mBAAmB,aAAa,QAAQ,CAAC,EAAE;IAC7C;IAEA,IAAI,oBAAoB;QACtB,SAAS;YACP,IAAI,CAAC,aAAa,UAAU,EAAE;gBAC5B,MAAM,SAAS,CAAC,KAAK,GAAG;gBACxB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,GAAG;YAC/C;QACF;QACA,UAAU,CAAA,GAAA,gBAAQ,MAAM,KAAK;QAC7B,iCAAiC;QACjC,GAAG,UAAU;IACf;IAEA,+FAA+F;IAC/F,OAAO;QACL,GAAG,YAAY;2BACf;IACF;AACF","sources":["packages/@react-aria/tree/src/useTreeItem.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaButtonProps} from '@react-types/button';\nimport {AriaGridListItemOptions, GridListItemAria, useGridListItem} from '@react-aria/gridlist';\nimport {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isAndroid, useLabels} from '@react-aria/utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaTreeItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {\n /** An object representing the treegrid item. Contains all the relevant information that makes up the treegrid row. */\n node: Node<unknown>\n}\n\nexport interface TreeItemAria extends GridListItemAria {\n /** Props for the tree grid row element. */\n rowProps: DOMAttributes,\n /** Props for the tree grid cell element within the tree grid list row. */\n gridCellProps: DOMAttributes,\n /** Props for the tree grid row description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the tree grid row expand button. */\n expandButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a tree grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useTreeState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useTreeItem<T>(props: AriaTreeItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeItemAria {\n let {node} = props;\n let gridListAria = useGridListItem(props, state, ref);\n let isExpanded = gridListAria.rowProps['aria-expanded'] === true;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tree');\n let labelProps = useLabels({\n 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),\n 'aria-labelledby': gridListAria.rowProps.id\n });\n\n let expandButtonProps = {\n onPress: () => {\n if (!gridListAria.isDisabled) {\n state.toggleKey(node.key);\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(node.key);\n }\n },\n tabIndex: isAndroid() ? -1 : null,\n 'data-react-aria-prevent-focus': true,\n ...labelProps\n };\n\n // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?\n return {\n ...gridListAria,\n expandButtonProps\n };\n}\n"],"names":[],"version":3,"file":"useTreeItem.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/tree",
3
- "version": "3.0.0-nightly.5042+68403fe55",
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",
@@ -22,21 +22,21 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/gridlist": "3.9.4-nightly.5042+68403fe55",
26
- "@react-aria/i18n": "3.0.0-nightly.3114+68403fe55",
27
- "@react-aria/selection": "3.0.0-nightly.3114+68403fe55",
28
- "@react-aria/utils": "3.0.0-nightly.3114+68403fe55",
29
- "@react-stately/tree": "3.0.0-nightly.3114+68403fe55",
30
- "@react-types/button": "3.9.7-nightly.5042+68403fe55",
31
- "@react-types/shared": "3.0.0-nightly.3114+68403fe55",
25
+ "@react-aria/gridlist": "^3.11.0",
26
+ "@react-aria/i18n": "^3.12.6",
27
+ "@react-aria/selection": "^3.23.0",
28
+ "@react-aria/utils": "^3.28.0",
29
+ "@react-stately/tree": "^3.8.8",
30
+ "@react-types/button": "^3.11.0",
31
+ "@react-types/shared": "^3.28.0",
32
32
  "@swc/helpers": "^0.5.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
36
- "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
35
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
36
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "68403fe55489dce3de1b3094c957d598ad719861"
41
+ "gitHead": "4d3c72c94eea2d72eb3a0e7d56000c6ef7e39726"
42
42
  }
package/src/index.ts CHANGED
@@ -11,8 +11,7 @@
11
11
  */
12
12
 
13
13
  export {useTree} from './useTree';
14
- export {useTreeGridList} from './useTreeGridList';
15
- export {useTreeGridListItem} from './useTreeGridListItem';
14
+ export {useTreeItem} from './useTreeItem';
16
15
 
17
- export type {AriaTreeGridListOptions, AriaTreeGridListProps, TreeGridListAria, TreeGridListProps} from './useTreeGridList';
18
- export type {AriaTreeGridListItemOptions, TreeGridListItemAria} from './useTreeGridListItem';
16
+ export type {AriaTreeOptions, AriaTreeProps, TreeAria, TreeProps} from './useTree';
17
+ export type {AriaTreeItemOptions, TreeItemAria} from './useTreeItem';
package/src/useTree.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2020 Adobe. All rights reserved.
2
+ * Copyright 2024 Adobe. All rights reserved.
3
3
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License. You may obtain a copy
5
5
  * of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -10,6 +10,42 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export function useTree() {
14
- return {};
13
+ import {AriaGridListOptions, AriaGridListProps, GridListProps, useGridList} from '@react-aria/gridlist';
14
+ import {
15
+ DOMAttributes,
16
+ KeyboardDelegate,
17
+ RefObject
18
+ } from '@react-types/shared';
19
+ import {TreeState} from '@react-stately/tree';
20
+
21
+ export interface TreeProps<T> extends GridListProps<T> {}
22
+
23
+ export interface AriaTreeProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {}
24
+ export interface AriaTreeOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {
25
+ /**
26
+ * An optional keyboard delegate implementation for type to select,
27
+ * to override the default.
28
+ */
29
+ keyboardDelegate?: KeyboardDelegate
30
+ }
31
+
32
+ export interface TreeAria {
33
+ /** Props for the treegrid element. */
34
+ gridProps: DOMAttributes
35
+ }
36
+
37
+ /**
38
+ * Provides the behavior and accessibility implementation for a single column treegrid component with interactive children.
39
+ * A tree grid provides users with a way to navigate nested hierarchical information.
40
+ * @param props - Props for the treegrid.
41
+ * @param state - State for the treegrid, as returned by `useTreeState`.
42
+ * @param ref - The ref attached to the treegrid element.
43
+ */
44
+ export function useTree<T>(props: AriaTreeOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeAria {
45
+ let {gridProps} = useGridList(props, state, ref);
46
+ gridProps.role = 'treegrid';
47
+
48
+ return {
49
+ gridProps
50
+ };
15
51
  }
@@ -15,16 +15,16 @@ import {AriaGridListItemOptions, GridListItemAria, useGridListItem} from '@react
15
15
  import {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';
16
16
  // @ts-ignore
17
17
  import intlMessages from '../intl/*.json';
18
- import {isAndroid} from '@react-aria/utils';
18
+ import {isAndroid, useLabels} from '@react-aria/utils';
19
19
  import {TreeState} from '@react-stately/tree';
20
20
  import {useLocalizedStringFormatter} from '@react-aria/i18n';
21
21
 
22
- export interface AriaTreeGridListItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {
22
+ export interface AriaTreeItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {
23
23
  /** An object representing the treegrid item. Contains all the relevant information that makes up the treegrid row. */
24
24
  node: Node<unknown>
25
25
  }
26
26
 
27
- export interface TreeGridListItemAria extends GridListItemAria {
27
+ export interface TreeItemAria extends GridListItemAria {
28
28
  /** Props for the tree grid row element. */
29
29
  rowProps: DOMAttributes,
30
30
  /** Props for the tree grid cell element within the tree grid list row. */
@@ -41,11 +41,15 @@ export interface TreeGridListItemAria extends GridListItemAria {
41
41
  * @param state - State of the parent list, as returned by `useTreeState`.
42
42
  * @param ref - The ref attached to the row element.
43
43
  */
44
- export function useTreeGridListItem<T>(props: AriaTreeGridListItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeGridListItemAria {
44
+ export function useTreeItem<T>(props: AriaTreeItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeItemAria {
45
45
  let {node} = props;
46
46
  let gridListAria = useGridListItem(props, state, ref);
47
47
  let isExpanded = gridListAria.rowProps['aria-expanded'] === true;
48
48
  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tree');
49
+ let labelProps = useLabels({
50
+ 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
51
+ 'aria-labelledby': gridListAria.rowProps.id
52
+ });
49
53
 
50
54
  let expandButtonProps = {
51
55
  onPress: () => {
@@ -55,9 +59,9 @@ export function useTreeGridListItem<T>(props: AriaTreeGridListItemOptions, state
55
59
  state.selectionManager.setFocusedKey(node.key);
56
60
  }
57
61
  },
58
- 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),
59
62
  tabIndex: isAndroid() ? -1 : null,
60
- 'data-react-aria-prevent-focus': true
63
+ 'data-react-aria-prevent-focus': true,
64
+ ...labelProps
61
65
  };
62
66
 
63
67
  // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?
@@ -1,29 +0,0 @@
1
- var $fE5UD$reactariagridlist = require("@react-aria/gridlist");
2
-
3
-
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$export(module.exports, "useTreeGridList", () => $41ae298c995bc55f$export$abb2211d46906a63);
9
- /*
10
- * Copyright 2024 Adobe. All rights reserved.
11
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License. You may obtain a copy
13
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software distributed under
16
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
- * OF ANY KIND, either express or implied. See the License for the specific language
18
- * governing permissions and limitations under the License.
19
- */
20
- function $41ae298c995bc55f$export$abb2211d46906a63(props, state, ref) {
21
- let { gridProps: gridProps } = (0, $fE5UD$reactariagridlist.useGridList)(props, state, ref);
22
- gridProps.role = 'treegrid';
23
- return {
24
- gridProps: gridProps
25
- };
26
- }
27
-
28
-
29
- //# sourceMappingURL=useTreeGridList.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAiCM,SAAS,0CAAmB,KAAiC,EAAE,KAAmB,EAAE,GAAkC;IAC3H,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,oCAAU,EAAE,OAAO,OAAO;IAC5C,UAAU,IAAI,GAAG;IAEjB,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/tree/src/useTreeGridList.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaGridListOptions, AriaGridListProps, GridListProps, useGridList} from '@react-aria/gridlist';\nimport {\n DOMAttributes,\n KeyboardDelegate,\n RefObject\n} from '@react-types/shared';\nimport {TreeState} from '@react-stately/tree';\n\nexport interface TreeGridListProps<T> extends GridListProps<T> {}\n\nexport interface AriaTreeGridListProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {}\nexport interface AriaTreeGridListOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface TreeGridListAria {\n /** Props for the treegrid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a single column treegrid component with interactive children.\n * A tree grid provides users with a way to navigate nested hierarchical information.\n * @param props - Props for the treegrid.\n * @param state - State for the treegrid, as returned by `useTreeState`.\n * @param ref - The ref attached to the treegrid element.\n */\nexport function useTreeGridList<T>(props: AriaTreeGridListOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeGridListAria {\n let {gridProps} = useGridList(props, state, ref);\n gridProps.role = 'treegrid';\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useTreeGridList.main.js.map"}
@@ -1,24 +0,0 @@
1
- import {useGridList as $2nLyh$useGridList} from "@react-aria/gridlist";
2
-
3
- /*
4
- * Copyright 2024 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- function $1642482277341dec$export$abb2211d46906a63(props, state, ref) {
15
- let { gridProps: gridProps } = (0, $2nLyh$useGridList)(props, state, ref);
16
- gridProps.role = 'treegrid';
17
- return {
18
- gridProps: gridProps
19
- };
20
- }
21
-
22
-
23
- export {$1642482277341dec$export$abb2211d46906a63 as useTreeGridList};
24
- //# sourceMappingURL=useTreeGridList.module.js.map
@@ -1,24 +0,0 @@
1
- import {useGridList as $2nLyh$useGridList} from "@react-aria/gridlist";
2
-
3
- /*
4
- * Copyright 2024 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- function $1642482277341dec$export$abb2211d46906a63(props, state, ref) {
15
- let { gridProps: gridProps } = (0, $2nLyh$useGridList)(props, state, ref);
16
- gridProps.role = 'treegrid';
17
- return {
18
- gridProps: gridProps
19
- };
20
- }
21
-
22
-
23
- export {$1642482277341dec$export$abb2211d46906a63 as useTreeGridList};
24
- //# sourceMappingURL=useTreeGridList.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAiCM,SAAS,0CAAmB,KAAiC,EAAE,KAAmB,EAAE,GAAkC;IAC3H,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,kBAAU,EAAE,OAAO,OAAO;IAC5C,UAAU,IAAI,GAAG;IAEjB,OAAO;mBACL;IACF;AACF","sources":["packages/@react-aria/tree/src/useTreeGridList.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaGridListOptions, AriaGridListProps, GridListProps, useGridList} from '@react-aria/gridlist';\nimport {\n DOMAttributes,\n KeyboardDelegate,\n RefObject\n} from '@react-types/shared';\nimport {TreeState} from '@react-stately/tree';\n\nexport interface TreeGridListProps<T> extends GridListProps<T> {}\n\nexport interface AriaTreeGridListProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {}\nexport interface AriaTreeGridListOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface TreeGridListAria {\n /** Props for the treegrid element. */\n gridProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a single column treegrid component with interactive children.\n * A tree grid provides users with a way to navigate nested hierarchical information.\n * @param props - Props for the treegrid.\n * @param state - State for the treegrid, as returned by `useTreeState`.\n * @param ref - The ref attached to the treegrid element.\n */\nexport function useTreeGridList<T>(props: AriaTreeGridListOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeGridListAria {\n let {gridProps} = useGridList(props, state, ref);\n gridProps.role = 'treegrid';\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useTreeGridList.module.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAuB,KAAkC,EAAE,KAAmB,EAAE,GAAuC;IACrI,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,eAAe,CAAA,GAAA,wCAAc,EAAE,OAAO,OAAO;IACjD,IAAI,aAAa,aAAa,QAAQ,CAAC,gBAAgB,KAAK;IAC5D,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,oBAAoB;QACtB,SAAS;YACP,IAAI,CAAC,aAAa,UAAU,EAAE;gBAC5B,MAAM,SAAS,CAAC,KAAK,GAAG;gBACxB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,GAAG;YAC/C;QACF;QACA,cAAc,aAAa,gBAAgB,MAAM,CAAC,cAAc,gBAAgB,MAAM,CAAC;QACvF,UAAU,CAAA,GAAA,+BAAQ,MAAM,KAAK;QAC7B,iCAAiC;IACnC;IAEA,+FAA+F;IAC/F,OAAO;QACL,GAAG,YAAY;2BACf;IACF;AACF","sources":["packages/@react-aria/tree/src/useTreeGridListItem.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaButtonProps} from '@react-types/button';\nimport {AriaGridListItemOptions, GridListItemAria, useGridListItem} from '@react-aria/gridlist';\nimport {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isAndroid} from '@react-aria/utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaTreeGridListItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {\n /** An object representing the treegrid item. Contains all the relevant information that makes up the treegrid row. */\n node: Node<unknown>\n}\n\nexport interface TreeGridListItemAria extends GridListItemAria {\n /** Props for the tree grid row element. */\n rowProps: DOMAttributes,\n /** Props for the tree grid cell element within the tree grid list row. */\n gridCellProps: DOMAttributes,\n /** Props for the tree grid row description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the tree grid row expand button. */\n expandButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a tree grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useTreeState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useTreeGridListItem<T>(props: AriaTreeGridListItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeGridListItemAria {\n let {node} = props;\n let gridListAria = useGridListItem(props, state, ref);\n let isExpanded = gridListAria.rowProps['aria-expanded'] === true;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tree');\n\n let expandButtonProps = {\n onPress: () => {\n if (!gridListAria.isDisabled) {\n state.toggleKey(node.key);\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(node.key);\n }\n },\n 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),\n tabIndex: isAndroid() ? -1 : null,\n 'data-react-aria-prevent-focus': true\n };\n\n // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?\n return {\n ...gridListAria,\n expandButtonProps\n };\n}\n"],"names":[],"version":3,"file":"useTreeGridListItem.main.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAuB,KAAkC,EAAE,KAAmB,EAAE,GAAuC;IACrI,IAAI,QAAC,IAAI,EAAC,GAAG;IACb,IAAI,eAAe,CAAA,GAAA,sBAAc,EAAE,OAAO,OAAO;IACjD,IAAI,aAAa,aAAa,QAAQ,CAAC,gBAAgB,KAAK;IAC5D,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,IAAI,oBAAoB;QACtB,SAAS;YACP,IAAI,CAAC,aAAa,UAAU,EAAE;gBAC5B,MAAM,SAAS,CAAC,KAAK,GAAG;gBACxB,MAAM,gBAAgB,CAAC,UAAU,CAAC;gBAClC,MAAM,gBAAgB,CAAC,aAAa,CAAC,KAAK,GAAG;YAC/C;QACF;QACA,cAAc,aAAa,gBAAgB,MAAM,CAAC,cAAc,gBAAgB,MAAM,CAAC;QACvF,UAAU,CAAA,GAAA,gBAAQ,MAAM,KAAK;QAC7B,iCAAiC;IACnC;IAEA,+FAA+F;IAC/F,OAAO;QACL,GAAG,YAAY;2BACf;IACF;AACF","sources":["packages/@react-aria/tree/src/useTreeGridListItem.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaButtonProps} from '@react-types/button';\nimport {AriaGridListItemOptions, GridListItemAria, useGridListItem} from '@react-aria/gridlist';\nimport {DOMAttributes, FocusableElement, Node, RefObject} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {isAndroid} from '@react-aria/utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaTreeGridListItemOptions extends Omit<AriaGridListItemOptions, 'isVirtualized'> {\n /** An object representing the treegrid item. Contains all the relevant information that makes up the treegrid row. */\n node: Node<unknown>\n}\n\nexport interface TreeGridListItemAria extends GridListItemAria {\n /** Props for the tree grid row element. */\n rowProps: DOMAttributes,\n /** Props for the tree grid cell element within the tree grid list row. */\n gridCellProps: DOMAttributes,\n /** Props for the tree grid row description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the tree grid row expand button. */\n expandButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a row in a tree grid list.\n * @param props - Props for the row.\n * @param state - State of the parent list, as returned by `useTreeState`.\n * @param ref - The ref attached to the row element.\n */\nexport function useTreeGridListItem<T>(props: AriaTreeGridListItemOptions, state: TreeState<T>, ref: RefObject<FocusableElement | null>): TreeGridListItemAria {\n let {node} = props;\n let gridListAria = useGridListItem(props, state, ref);\n let isExpanded = gridListAria.rowProps['aria-expanded'] === true;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/tree');\n\n let expandButtonProps = {\n onPress: () => {\n if (!gridListAria.isDisabled) {\n state.toggleKey(node.key);\n state.selectionManager.setFocused(true);\n state.selectionManager.setFocusedKey(node.key);\n }\n },\n 'aria-label': isExpanded ? stringFormatter.format('collapse') : stringFormatter.format('expand'),\n tabIndex: isAndroid() ? -1 : null,\n 'data-react-aria-prevent-focus': true\n };\n\n // TODO: should it return a state specifically for isExpanded? Or is aria attribute sufficient?\n return {\n ...gridListAria,\n expandButtonProps\n };\n}\n"],"names":[],"version":3,"file":"useTreeGridListItem.module.js.map"}
@@ -1,51 +0,0 @@
1
- /*
2
- * Copyright 2024 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {AriaGridListOptions, AriaGridListProps, GridListProps, useGridList} from '@react-aria/gridlist';
14
- import {
15
- DOMAttributes,
16
- KeyboardDelegate,
17
- RefObject
18
- } from '@react-types/shared';
19
- import {TreeState} from '@react-stately/tree';
20
-
21
- export interface TreeGridListProps<T> extends GridListProps<T> {}
22
-
23
- export interface AriaTreeGridListProps<T> extends Omit<AriaGridListProps<T>, 'keyboardNavigationBehavior'> {}
24
- export interface AriaTreeGridListOptions<T> extends Omit<AriaGridListOptions<T>, 'children' | 'shouldFocusWrap'> {
25
- /**
26
- * An optional keyboard delegate implementation for type to select,
27
- * to override the default.
28
- */
29
- keyboardDelegate?: KeyboardDelegate
30
- }
31
-
32
- export interface TreeGridListAria {
33
- /** Props for the treegrid element. */
34
- gridProps: DOMAttributes
35
- }
36
-
37
- /**
38
- * Provides the behavior and accessibility implementation for a single column treegrid component with interactive children.
39
- * A tree grid provides users with a way to navigate nested hierarchical information.
40
- * @param props - Props for the treegrid.
41
- * @param state - State for the treegrid, as returned by `useTreeState`.
42
- * @param ref - The ref attached to the treegrid element.
43
- */
44
- export function useTreeGridList<T>(props: AriaTreeGridListOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): TreeGridListAria {
45
- let {gridProps} = useGridList(props, state, ref);
46
- gridProps.role = 'treegrid';
47
-
48
- return {
49
- gridProps
50
- };
51
- }