@react-aria/tabs 3.0.0-beta.0 → 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.
Files changed (41) hide show
  1. package/dist/TabsKeyboardDelegate.main.js +71 -0
  2. package/dist/TabsKeyboardDelegate.main.js.map +1 -0
  3. package/dist/TabsKeyboardDelegate.mjs +66 -0
  4. package/dist/TabsKeyboardDelegate.module.js +66 -0
  5. package/dist/TabsKeyboardDelegate.module.js.map +1 -0
  6. package/dist/import.mjs +21 -0
  7. package/dist/main.js +9 -231
  8. package/dist/main.js.map +1 -1
  9. package/dist/module.js +5 -206
  10. package/dist/module.js.map +1 -1
  11. package/dist/types.d.ts +38 -14
  12. package/dist/types.d.ts.map +1 -1
  13. package/dist/useTab.main.js +62 -0
  14. package/dist/useTab.main.js.map +1 -0
  15. package/dist/useTab.mjs +57 -0
  16. package/dist/useTab.module.js +57 -0
  17. package/dist/useTab.module.js.map +1 -0
  18. package/dist/useTabList.main.js +67 -0
  19. package/dist/useTabList.main.js.map +1 -0
  20. package/dist/useTabList.mjs +62 -0
  21. package/dist/useTabList.module.js +62 -0
  22. package/dist/useTabList.module.js.map +1 -0
  23. package/dist/useTabPanel.main.js +47 -0
  24. package/dist/useTabPanel.main.js.map +1 -0
  25. package/dist/useTabPanel.mjs +42 -0
  26. package/dist/useTabPanel.module.js +42 -0
  27. package/dist/useTabPanel.module.js.map +1 -0
  28. package/dist/utils.main.js +28 -0
  29. package/dist/utils.main.js.map +1 -0
  30. package/dist/utils.mjs +22 -0
  31. package/dist/utils.module.js +22 -0
  32. package/dist/utils.module.js.map +1 -0
  33. package/package.json +18 -13
  34. package/src/TabsKeyboardDelegate.ts +27 -31
  35. package/src/index.ts +8 -2
  36. package/src/useTab.ts +77 -0
  37. package/src/useTabList.ts +75 -0
  38. package/src/useTabPanel.ts +47 -0
  39. package/src/utils.ts +30 -0
  40. package/LICENSE +0 -201
  41. package/src/useTabs.ts +0 -133
@@ -0,0 +1,71 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "TabsKeyboardDelegate", () => $283e5d8830177ead$export$15010ca3c1abe90b);
7
+ /*
8
+ * Copyright 2020 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
+ */ class $283e5d8830177ead$export$15010ca3c1abe90b {
18
+ getKeyLeftOf(key) {
19
+ if (this.flipDirection) return this.getNextKey(key);
20
+ return this.getPreviousKey(key);
21
+ }
22
+ getKeyRightOf(key) {
23
+ if (this.flipDirection) return this.getPreviousKey(key);
24
+ return this.getNextKey(key);
25
+ }
26
+ isDisabled(key) {
27
+ var _this_collection_getItem_props, _this_collection_getItem;
28
+ return this.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled);
29
+ }
30
+ getFirstKey() {
31
+ let key = this.collection.getFirstKey();
32
+ if (key != null && this.isDisabled(key)) key = this.getNextKey(key);
33
+ return key;
34
+ }
35
+ getLastKey() {
36
+ let key = this.collection.getLastKey();
37
+ if (key != null && this.isDisabled(key)) key = this.getPreviousKey(key);
38
+ return key;
39
+ }
40
+ getKeyAbove(key) {
41
+ if (this.tabDirection) return null;
42
+ return this.getPreviousKey(key);
43
+ }
44
+ getKeyBelow(key) {
45
+ if (this.tabDirection) return null;
46
+ return this.getNextKey(key);
47
+ }
48
+ getNextKey(key) {
49
+ do {
50
+ key = this.collection.getKeyAfter(key);
51
+ if (key == null) key = this.collection.getFirstKey();
52
+ }while (this.isDisabled(key));
53
+ return key;
54
+ }
55
+ getPreviousKey(key) {
56
+ do {
57
+ key = this.collection.getKeyBefore(key);
58
+ if (key == null) key = this.collection.getLastKey();
59
+ }while (this.isDisabled(key));
60
+ return key;
61
+ }
62
+ constructor(collection, direction, orientation, disabledKeys = new Set()){
63
+ this.collection = collection;
64
+ this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
65
+ this.disabledKeys = disabledKeys;
66
+ this.tabDirection = orientation === 'horizontal';
67
+ }
68
+ }
69
+
70
+
71
+ //# sourceMappingURL=TabsKeyboardDelegate.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAaX,aAAa,GAAQ,EAAE;QACrB,IAAI,IAAI,CAAC,aAAa,EACpB,OAAO,IAAI,CAAC,UAAU,CAAC;QAEzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B;IAEA,cAAc,GAAQ,EAAE;QACtB,IAAI,IAAI,CAAC,aAAa,EACpB,OAAO,IAAI,CAAC,cAAc,CAAC;QAE7B,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB;IAGQ,WAAW,GAAQ,EAAE;YACY,gCAAA;QAAvC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAC,2BAAA,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,kBAAxB,gDAAA,iCAAA,yBAA8B,KAAK,cAAnC,qDAAA,+BAAqC,UAAU;IACxF;IAEA,cAAc;QACZ,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW;QACrC,IAAI,OAAO,QAAQ,IAAI,CAAC,UAAU,CAAC,MACjC,MAAM,IAAI,CAAC,UAAU,CAAC;QAExB,OAAO;IACT;IAEA,aAAa;QACX,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU;QACpC,IAAI,OAAO,QAAQ,IAAI,CAAC,UAAU,CAAC,MACjC,MAAM,IAAI,CAAC,cAAc,CAAC;QAE5B,OAAO;IACT;IAEA,YAAY,GAAQ,EAAE;QACpB,IAAI,IAAI,CAAC,YAAY,EACnB,OAAO;QAET,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B;IAEA,YAAY,GAAQ,EAAE;QACpB,IAAI,IAAI,CAAC,YAAY,EACnB,OAAO;QAET,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB;IAEA,WAAW,GAAG,EAAE;QACd,GAAG;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;YAClC,IAAI,OAAO,MACT,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW;QAErC,QAAS,IAAI,CAAC,UAAU,CAAC,MAAM;QAC/B,OAAO;IACT;IAEA,eAAe,GAAG,EAAE;QAClB,GAAG;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;YACnC,IAAI,OAAO,MACT,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU;QAEpC,QAAS,IAAI,CAAC,UAAU,CAAC,MAAM;QAC/B,OAAO;IACT;IA1EA,YAAY,UAA+B,EAAE,SAAoB,EAAE,WAAwB,EAAE,eAAyB,IAAI,KAAK,CAAE;QAC/H,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,aAAa,GAAG,cAAc,SAAS,gBAAgB;QAC5D,IAAI,CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,YAAY,GAAG,gBAAgB;IACtC;AAsEF","sources":["packages/@react-aria/tabs/src/TabsKeyboardDelegate.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\nimport {Collection, Direction, Key, KeyboardDelegate, Node, Orientation} from '@react-types/shared';\n\nexport class TabsKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<Node<T>>;\n private flipDirection: boolean;\n private disabledKeys: Set<Key>;\n private tabDirection: boolean;\n\n constructor(collection: Collection<Node<T>>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {\n this.collection = collection;\n this.flipDirection = direction === 'rtl' && orientation === 'horizontal';\n this.disabledKeys = disabledKeys;\n this.tabDirection = orientation === 'horizontal';\n }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n }\n return this.getPreviousKey(key);\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n }\n return this.getNextKey(key);\n }\n\n\n private isDisabled(key: Key) {\n return this.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n \n getKeyAbove(key: Key) {\n if (this.tabDirection) {\n return null;\n }\n return this.getPreviousKey(key);\n }\n\n getKeyBelow(key: Key) {\n if (this.tabDirection) {\n return null;\n }\n return this.getNextKey(key);\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n}\n"],"names":[],"version":3,"file":"TabsKeyboardDelegate.main.js.map"}
@@ -0,0 +1,66 @@
1
+ /*
2
+ * Copyright 2020 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
+ */ class $bfc6f2d60b8a4c40$export$15010ca3c1abe90b {
12
+ getKeyLeftOf(key) {
13
+ if (this.flipDirection) return this.getNextKey(key);
14
+ return this.getPreviousKey(key);
15
+ }
16
+ getKeyRightOf(key) {
17
+ if (this.flipDirection) return this.getPreviousKey(key);
18
+ return this.getNextKey(key);
19
+ }
20
+ isDisabled(key) {
21
+ var _this_collection_getItem_props, _this_collection_getItem;
22
+ return this.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled);
23
+ }
24
+ getFirstKey() {
25
+ let key = this.collection.getFirstKey();
26
+ if (key != null && this.isDisabled(key)) key = this.getNextKey(key);
27
+ return key;
28
+ }
29
+ getLastKey() {
30
+ let key = this.collection.getLastKey();
31
+ if (key != null && this.isDisabled(key)) key = this.getPreviousKey(key);
32
+ return key;
33
+ }
34
+ getKeyAbove(key) {
35
+ if (this.tabDirection) return null;
36
+ return this.getPreviousKey(key);
37
+ }
38
+ getKeyBelow(key) {
39
+ if (this.tabDirection) return null;
40
+ return this.getNextKey(key);
41
+ }
42
+ getNextKey(key) {
43
+ do {
44
+ key = this.collection.getKeyAfter(key);
45
+ if (key == null) key = this.collection.getFirstKey();
46
+ }while (this.isDisabled(key));
47
+ return key;
48
+ }
49
+ getPreviousKey(key) {
50
+ do {
51
+ key = this.collection.getKeyBefore(key);
52
+ if (key == null) key = this.collection.getLastKey();
53
+ }while (this.isDisabled(key));
54
+ return key;
55
+ }
56
+ constructor(collection, direction, orientation, disabledKeys = new Set()){
57
+ this.collection = collection;
58
+ this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
59
+ this.disabledKeys = disabledKeys;
60
+ this.tabDirection = orientation === 'horizontal';
61
+ }
62
+ }
63
+
64
+
65
+ export {$bfc6f2d60b8a4c40$export$15010ca3c1abe90b as TabsKeyboardDelegate};
66
+ //# sourceMappingURL=TabsKeyboardDelegate.module.js.map
@@ -0,0 +1,66 @@
1
+ /*
2
+ * Copyright 2020 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
+ */ class $bfc6f2d60b8a4c40$export$15010ca3c1abe90b {
12
+ getKeyLeftOf(key) {
13
+ if (this.flipDirection) return this.getNextKey(key);
14
+ return this.getPreviousKey(key);
15
+ }
16
+ getKeyRightOf(key) {
17
+ if (this.flipDirection) return this.getPreviousKey(key);
18
+ return this.getNextKey(key);
19
+ }
20
+ isDisabled(key) {
21
+ var _this_collection_getItem_props, _this_collection_getItem;
22
+ return this.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled);
23
+ }
24
+ getFirstKey() {
25
+ let key = this.collection.getFirstKey();
26
+ if (key != null && this.isDisabled(key)) key = this.getNextKey(key);
27
+ return key;
28
+ }
29
+ getLastKey() {
30
+ let key = this.collection.getLastKey();
31
+ if (key != null && this.isDisabled(key)) key = this.getPreviousKey(key);
32
+ return key;
33
+ }
34
+ getKeyAbove(key) {
35
+ if (this.tabDirection) return null;
36
+ return this.getPreviousKey(key);
37
+ }
38
+ getKeyBelow(key) {
39
+ if (this.tabDirection) return null;
40
+ return this.getNextKey(key);
41
+ }
42
+ getNextKey(key) {
43
+ do {
44
+ key = this.collection.getKeyAfter(key);
45
+ if (key == null) key = this.collection.getFirstKey();
46
+ }while (this.isDisabled(key));
47
+ return key;
48
+ }
49
+ getPreviousKey(key) {
50
+ do {
51
+ key = this.collection.getKeyBefore(key);
52
+ if (key == null) key = this.collection.getLastKey();
53
+ }while (this.isDisabled(key));
54
+ return key;
55
+ }
56
+ constructor(collection, direction, orientation, disabledKeys = new Set()){
57
+ this.collection = collection;
58
+ this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
59
+ this.disabledKeys = disabledKeys;
60
+ this.tabDirection = orientation === 'horizontal';
61
+ }
62
+ }
63
+
64
+
65
+ export {$bfc6f2d60b8a4c40$export$15010ca3c1abe90b as TabsKeyboardDelegate};
66
+ //# sourceMappingURL=TabsKeyboardDelegate.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAaX,aAAa,GAAQ,EAAE;QACrB,IAAI,IAAI,CAAC,aAAa,EACpB,OAAO,IAAI,CAAC,UAAU,CAAC;QAEzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B;IAEA,cAAc,GAAQ,EAAE;QACtB,IAAI,IAAI,CAAC,aAAa,EACpB,OAAO,IAAI,CAAC,cAAc,CAAC;QAE7B,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB;IAGQ,WAAW,GAAQ,EAAE;YACY,gCAAA;QAAvC,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAC,2BA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CAAC,YAAY,GAAG;QACpB,IAAI,CAAC,YAAY,GAAG,gBAAgB;IACtC;AAsEF","sources":["packages/@react-aria/tabs/src/TabsKeyboardDelegate.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\nimport {Collection, Direction, Key, KeyboardDelegate, Node, Orientation} from '@react-types/shared';\n\nexport class TabsKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<Node<T>>;\n private flipDirection: boolean;\n private disabledKeys: Set<Key>;\n private tabDirection: boolean;\n\n constructor(collection: Collection<Node<T>>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {\n this.collection = collection;\n this.flipDirection = direction === 'rtl' && orientation === 'horizontal';\n this.disabledKeys = disabledKeys;\n this.tabDirection = orientation === 'horizontal';\n }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n }\n return this.getPreviousKey(key);\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n }\n return this.getNextKey(key);\n }\n\n\n private isDisabled(key: Key) {\n return this.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n \n getKeyAbove(key: Key) {\n if (this.tabDirection) {\n return null;\n }\n return this.getPreviousKey(key);\n }\n\n getKeyBelow(key: Key) {\n if (this.tabDirection) {\n return null;\n }\n return this.getNextKey(key);\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n}\n"],"names":[],"version":3,"file":"TabsKeyboardDelegate.module.js.map"}
@@ -0,0 +1,21 @@
1
+ import {useTab as $0175d55c2a017ebc$export$fdf4756d5b8ef90a} from "./useTab.mjs";
2
+ import {useTabPanel as $34bce698202e07cb$export$fae0121b5afe572d} from "./useTabPanel.mjs";
3
+ import {useTabList as $58d314389b21fa3f$export$773e389e644c5874} from "./useTabList.mjs";
4
+
5
+ /*
6
+ * Copyright 2020 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 {$0175d55c2a017ebc$export$fdf4756d5b8ef90a as useTab, $34bce698202e07cb$export$fae0121b5afe572d as useTabPanel, $58d314389b21fa3f$export$773e389e644c5874 as useTabList};
21
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,32 +1,15 @@
1
- var {
2
- useSelectableCollection,
3
- useSelectableItem
4
- } = require("@react-aria/selection");
1
+ var $4eeea1c984cc0628$exports = require("./useTab.main.js");
2
+ var $8db1928b18472a1f$exports = require("./useTabPanel.main.js");
3
+ var $f2b4a4926440e901$exports = require("./useTabList.main.js");
5
4
 
6
- var {
7
- usePress
8
- } = require("@react-aria/interactions");
9
5
 
10
- var {
11
- useLocale
12
- } = require("@react-aria/i18n");
13
-
14
- var {
15
- mergeProps,
16
- useId,
17
- useLabels
18
- } = require("@react-aria/utils");
19
-
20
- var {
21
- useMemo
22
- } = require("react");
23
-
24
- var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
25
-
26
- function $parcel$interopDefault(a) {
27
- return a && a.__esModule ? a.default : a;
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
28
8
  }
29
9
 
10
+ $parcel$export(module.exports, "useTab", () => $4eeea1c984cc0628$exports.useTab);
11
+ $parcel$export(module.exports, "useTabPanel", () => $8db1928b18472a1f$exports.useTabPanel);
12
+ $parcel$export(module.exports, "useTabList", () => $f2b4a4926440e901$exports.useTabList);
30
13
  /*
31
14
  * Copyright 2020 Adobe. All rights reserved.
32
15
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -37,214 +20,9 @@ function $parcel$interopDefault(a) {
37
20
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
38
21
  * OF ANY KIND, either express or implied. See the License for the specific language
39
22
  * governing permissions and limitations under the License.
40
- */
41
- class $c98ba41732a4afea84f1af0a5428958$export$TabsKeyboardDelegate {
42
- constructor(collection, direction, orientation, disabledKeys) {
43
- if (disabledKeys === void 0) {
44
- disabledKeys = new Set();
45
- }
46
-
47
- this.collection = void 0;
48
- this.flipDirection = void 0;
49
- this.disabledKeys = void 0;
50
- this.orientation = void 0;
51
- this.collection = collection;
52
- this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
53
- this.orientation = orientation;
54
- this.disabledKeys = disabledKeys;
55
- }
56
-
57
- getKeyLeftOf(key) {
58
- if (this.flipDirection) {
59
- return this.getNextKey(key);
60
- } else {
61
- if (this.orientation === 'horizontal') {
62
- return this.getPreviousKey(key);
63
- }
64
-
65
- return null;
66
- }
67
- }
68
-
69
- getKeyRightOf(key) {
70
- if (this.flipDirection) {
71
- return this.getPreviousKey(key);
72
- } else {
73
- if (this.orientation === 'horizontal') {
74
- return this.getNextKey(key);
75
- }
76
-
77
- return null;
78
- }
79
- }
80
-
81
- getKeyAbove(key) {
82
- if (this.orientation === 'vertical') {
83
- return this.getPreviousKey(key);
84
- }
85
-
86
- return null;
87
- }
88
-
89
- getKeyBelow(key) {
90
- if (this.orientation === 'vertical') {
91
- return this.getNextKey(key);
92
- }
93
-
94
- return null;
95
- }
96
-
97
- getFirstKey() {
98
- let key = this.collection.getFirstKey();
99
-
100
- if (this.disabledKeys.has(key)) {
101
- key = this.getNextKey(key);
102
- }
103
-
104
- return key;
105
- }
106
-
107
- getLastKey() {
108
- let key = this.collection.getLastKey();
109
-
110
- if (this.disabledKeys.has(key)) {
111
- key = this.getPreviousKey(key);
112
- }
23
+ */
113
24
 
114
- return key;
115
- }
116
25
 
117
- getNextKey(key) {
118
- do {
119
- key = this.collection.getKeyAfter(key);
120
26
 
121
- if (key == null) {
122
- key = this.collection.getFirstKey();
123
- }
124
- } while (this.disabledKeys.has(key));
125
27
 
126
- return key;
127
- }
128
-
129
- getPreviousKey(key) {
130
- do {
131
- key = this.collection.getKeyBefore(key);
132
-
133
- if (key == null) {
134
- key = this.collection.getLastKey();
135
- }
136
- } while (this.disabledKeys.has(key));
137
-
138
- return key;
139
- }
140
-
141
- }
142
-
143
- const $d3534b2e5f49231696504$var$tabsIds = new WeakMap();
144
-
145
- function useTabs(props, state, ref) {
146
- let {
147
- orientation = 'horizontal',
148
- keyboardActivation = 'automatic'
149
- } = props;
150
- let {
151
- collection,
152
- selectionManager: manager,
153
- disabledKeys,
154
- selectedKey
155
- } = state;
156
- let {
157
- direction
158
- } = useLocale();
159
- let delegate = useMemo(() => new $c98ba41732a4afea84f1af0a5428958$export$TabsKeyboardDelegate(collection, direction, orientation, disabledKeys), [collection, disabledKeys, orientation, direction]);
160
- let {
161
- collectionProps
162
- } = useSelectableCollection({
163
- ref,
164
- selectionManager: manager,
165
- keyboardDelegate: delegate,
166
- selectOnFocus: keyboardActivation === 'automatic',
167
- disallowEmptySelection: true
168
- }); // Compute base id for all tabs
169
-
170
- let tabsId = useId();
171
- $d3534b2e5f49231696504$var$tabsIds.set(state, tabsId);
172
- let tabListLabelProps = useLabels(_babelRuntimeHelpersExtends({}, props, {
173
- id: tabsId
174
- }));
175
- return {
176
- tabListProps: _babelRuntimeHelpersExtends({}, mergeProps(collectionProps, tabListLabelProps), {
177
- role: 'tablist',
178
- 'aria-orientation': orientation,
179
- tabIndex: undefined
180
- }),
181
- tabPanelProps: {
182
- id: $d3534b2e5f49231696504$var$generateId(state, selectedKey, 'tabpanel'),
183
- 'aria-labelledby': $d3534b2e5f49231696504$var$generateId(state, selectedKey, 'tab'),
184
- tabIndex: 0,
185
- role: 'tabpanel'
186
- }
187
- };
188
- }
189
-
190
- exports.useTabs = useTabs;
191
-
192
- function useTab(props, state, ref) {
193
- let {
194
- item,
195
- isDisabled: propsDisabled
196
- } = props;
197
- let {
198
- key
199
- } = item;
200
- let {
201
- selectionManager: manager,
202
- selectedKey
203
- } = state;
204
- let isSelected = key === selectedKey;
205
- let {
206
- itemProps
207
- } = useSelectableItem({
208
- selectionManager: manager,
209
- key,
210
- ref
211
- });
212
- let isDisabled = propsDisabled || state.disabledKeys.has(key);
213
- let {
214
- pressProps
215
- } = usePress(_babelRuntimeHelpersExtends({}, itemProps, {
216
- isDisabled
217
- }));
218
- let tabId = $d3534b2e5f49231696504$var$generateId(state, key, 'tab');
219
- let tabPanelId = $d3534b2e5f49231696504$var$generateId(state, key, 'tabpanel');
220
- let {
221
- tabIndex
222
- } = pressProps; // selected tab should have tabIndex=0, when it initializes
223
-
224
- if (isSelected && !isDisabled) {
225
- tabIndex = 0;
226
- }
227
-
228
- return {
229
- tabProps: _babelRuntimeHelpersExtends({}, pressProps, {
230
- id: tabId,
231
- 'aria-selected': isSelected,
232
- 'aria-disabled': isDisabled || undefined,
233
- 'aria-controls': isSelected ? tabPanelId : undefined,
234
- tabIndex: isDisabled ? undefined : tabIndex,
235
- role: 'tab'
236
- })
237
- };
238
- }
239
-
240
- exports.useTab = useTab;
241
-
242
- function $d3534b2e5f49231696504$var$generateId(state, key, role) {
243
- if (typeof key === 'string') {
244
- key = key.replace(/\s+/g, '');
245
- }
246
-
247
- let baseId = $d3534b2e5f49231696504$var$tabsIds.get(state);
248
- return baseId + "-" + role + "-" + key;
249
- }
250
28
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACFD;;;;;;;;;;;AAeO,MAAMG,4DAAN,CAA0D;AAM/DC,EAAAA,WAAW,CAACC,UAAD,EAA4BC,SAA5B,EAAkDC,WAAlD,EAA4EC,YAA5E,EAAgH;AAAA,QAApCA,YAAoC;AAApCA,MAAAA,YAAoC,GAAX,IAAIC,GAAJ,EAAW;AAAA;;AAAA,SALnHJ,UAKmH;AAAA,SAJnHK,aAImH;AAAA,SAHnHF,YAGmH;AAAA,SAFnHD,WAEmH;AACzH,SAAKF,UAAL,GAAkBA,UAAlB;AACA,SAAKK,aAAL,GAAqBJ,SAAS,KAAK,KAAd,IAAuBC,WAAW,KAAK,YAA5D;AACA,SAAKA,WAAL,GAAmBA,WAAnB;AACA,SAAKC,YAAL,GAAoBA,YAApB;AACD;;AAEDG,EAAAA,YAAY,CAACC,GAAD,EAAW;AACrB,QAAI,KAAKF,aAAT,EAAwB;AACtB,aAAO,KAAKG,UAAL,CAAgBD,GAAhB,CAAP;AACD,KAFD,MAEO;AACL,UAAI,KAAKL,WAAL,KAAqB,YAAzB,EAAuC;AACrC,eAAO,KAAKO,cAAL,CAA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/scope-hoisting/lib/helpers.js","./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/useTabs.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Direction, KeyboardDelegate, Orientation} from '@react-types/shared';\nimport {Key} from 'react';\n\nexport class TabsKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<T>;\n private flipDirection: boolean;\n private disabledKeys: Set<Key>;\n private orientation: Orientation;\n\n constructor(collection: Collection<T>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {\n this.collection = collection;\n this.flipDirection = direction === 'rtl' && orientation === 'horizontal';\n this.orientation = orientation;\n this.disabledKeys = disabledKeys;\n }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n } else {\n if (this.orientation === 'horizontal') {\n return this.getNextKey(key);\n }\n return null;\n }\n }\n\n getKeyAbove(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getPreviousKey(key);\n }\n return null;\n }\n\n getKeyBelow(key: Key) {\n if (this.orientation === 'vertical') {\n return this.getNextKey(key);\n }\n return null;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (this.disabledKeys.has(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (this.disabledKeys.has(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.disabledKeys.has(key));\n return key;\n }\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaTabProps, AriaTabsProps} from '@react-types/tabs';\nimport {HTMLAttributes, Key, RefObject, useMemo} from 'react';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {SingleSelectListState} from '@react-stately/list';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {TabsState} from '@react-stately/tabs';\nimport {useLocale} from '@react-aria/i18n';\nimport {usePress} from '@react-aria/interactions';\nimport {useSelectableCollection, useSelectableItem} from '@react-aria/selection';\n\ninterface TabsAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>,\n /** Props for the associated tabpanel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\n}\n\nconst tabsIds = new WeakMap<SingleSelectListState<unknown>, string>();\n\nexport function useTabs<T>(props: AriaTabsProps<T>, state: TabsState<T>, ref): TabsAria {\n let {\n orientation = 'horizontal',\n keyboardActivation = 'automatic'\n } = props;\n let {\n collection,\n selectionManager: manager,\n disabledKeys,\n selectedKey\n } = state;\n let {direction} = useLocale();\n let delegate = useMemo(() => new TabsKeyboardDelegate(\n collection,\n direction,\n orientation,\n disabledKeys), [collection, disabledKeys, orientation, direction]);\n\n let {collectionProps} = useSelectableCollection({\n ref,\n selectionManager: manager,\n keyboardDelegate: delegate,\n selectOnFocus: keyboardActivation === 'automatic',\n disallowEmptySelection: true\n });\n\n // Compute base id for all tabs\n let tabsId = useId();\n tabsIds.set(state, tabsId);\n\n let tabListLabelProps = useLabels({...props, id: tabsId});\n\n return {\n tabListProps: {\n ...mergeProps(collectionProps, tabListLabelProps),\n role: 'tablist',\n 'aria-orientation': orientation,\n tabIndex: undefined\n },\n tabPanelProps: {\n id: generateId(state, selectedKey, 'tabpanel'),\n 'aria-labelledby': generateId(state, selectedKey, 'tab'),\n tabIndex: 0,\n role: 'tabpanel'\n }\n };\n}\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useTab<T>(\n props: AriaTabProps<T>,\n state: SingleSelectListState<T>,\n ref: RefObject<HTMLElement>\n): TabAria {\n let {item, isDisabled: propsDisabled} = props;\n let {key} = item;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref\n });\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n\n let {pressProps} = usePress({...itemProps, isDisabled});\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = pressProps;\n\n // selected tab should have tabIndex=0, when it initializes\n if (isSelected && !isDisabled) {\n tabIndex = 0;\n }\n\n return {\n tabProps: {\n ...pressProps,\n id: tabId,\n 'aria-selected': isSelected,\n 'aria-disabled': isDisabled || undefined,\n 'aria-controls': isSelected ? tabPanelId : undefined,\n tabIndex: isDisabled ? undefined : tabIndex,\n role: 'tab'\n }\n };\n}\n\nfunction generateId<T>(state: SingleSelectListState<T>, key: Key, role: string) {\n if (typeof key === 'string') {\n key = key.replace(/\\s+/g, '');\n }\n\n let baseId = tabsIds.get(state);\n return `${baseId}-${role}-${key}`;\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","TabsKeyboardDelegate","constructor","collection","direction","orientation","disabledKeys","Set","flipDirection","getKeyLeftOf","key","getNextKey","getPreviousKey","getKeyRightOf","getKeyAbove","getKeyBelow","getFirstKey","has","getLastKey","getKeyAfter","getKeyBefore","tabsIds","WeakMap","useTabs","props","state","ref","keyboardActivation","selectionManager","manager","selectedKey","useLocale","delegate","useMemo","collectionProps","useSelectableCollection","keyboardDelegate","selectOnFocus","disallowEmptySelection","tabsId","useId","set","tabListLabelProps","useLabels","id","tabListProps","mergeProps","role","tabIndex","undefined","tabPanelProps","generateId","useTab","item","isDisabled","propsDisabled","isSelected","itemProps","useSelectableItem","pressProps","usePress","tabId","tabPanelId","tabProps","replace","baseId","get"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tabs/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 */\nexport {useTab} from './useTab';\nexport {useTabPanel} from './useTabPanel';\nexport {useTabList} from './useTabList';\nexport type {AriaTabListProps, AriaTabPanelProps, AriaTabProps} from '@react-types/tabs';\nexport type {Orientation} from '@react-types/shared';\nexport type {TabAria} from './useTab';\nexport type {TabPanelAria} from './useTabPanel';\nexport type {AriaTabListOptions, TabListAria} from './useTabList';\n"],"names":[],"version":3,"file":"main.js.map"}