@react-aria/tabs 3.10.0 → 3.10.2
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/TabsKeyboardDelegate.main.js +6 -4
- package/dist/TabsKeyboardDelegate.main.js.map +1 -1
- package/dist/TabsKeyboardDelegate.mjs +6 -4
- package/dist/TabsKeyboardDelegate.module.js +6 -4
- package/dist/TabsKeyboardDelegate.module.js.map +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +9 -9
- package/src/TabsKeyboardDelegate.ts +13 -11
- package/src/utils.ts +1 -1
|
@@ -45,18 +45,20 @@ $parcel$export(module.exports, "TabsKeyboardDelegate", () => $283e5d8830177ead$e
|
|
|
45
45
|
if (this.tabDirection) return null;
|
|
46
46
|
return this.getNextKey(key);
|
|
47
47
|
}
|
|
48
|
-
getNextKey(
|
|
48
|
+
getNextKey(startKey) {
|
|
49
|
+
let key = startKey;
|
|
49
50
|
do {
|
|
50
51
|
key = this.collection.getKeyAfter(key);
|
|
51
52
|
if (key == null) key = this.collection.getFirstKey();
|
|
52
|
-
}while (this.isDisabled(key));
|
|
53
|
+
}while (key != null && this.isDisabled(key));
|
|
53
54
|
return key;
|
|
54
55
|
}
|
|
55
|
-
getPreviousKey(
|
|
56
|
+
getPreviousKey(startKey) {
|
|
57
|
+
let key = startKey;
|
|
56
58
|
do {
|
|
57
59
|
key = this.collection.getKeyBefore(key);
|
|
58
60
|
if (key == null) key = this.collection.getLastKey();
|
|
59
|
-
}while (this.isDisabled(key));
|
|
61
|
+
}while (key != null && this.isDisabled(key));
|
|
60
62
|
return key;
|
|
61
63
|
}
|
|
62
64
|
constructor(collection, direction, orientation, disabledKeys = new Set()){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAaX,aAAa,GAAQ,
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;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,OAAO,QAAQ,IAAI,CAAC,UAAU,CAAC,MAAM;QAC9C,OAAO;IACT;IAEA,eAAe,QAAa,EAAc;QACxC,IAAI,MAAkB;QACtB,GAAG;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;YACnC,IAAI,OAAO,MACT,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU;QAEpC,QAAS,OAAO,QAAQ,IAAI,CAAC,UAAU,CAAC,MAAM;QAC9C,OAAO;IACT;IA5EA,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;AAwEF","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): Key | null {\n if (this.flipDirection) {\n return this.getNextKey(key);\n }\n return this.getPreviousKey(key);\n }\n\n getKeyRightOf(key: Key): Key | null {\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(): Key | null {\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(): Key | null {\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): Key | null {\n if (this.tabDirection) {\n return null;\n }\n return this.getPreviousKey(key);\n }\n\n getKeyBelow(key: Key): Key | null {\n if (this.tabDirection) {\n return null;\n }\n return this.getNextKey(key);\n }\n\n getNextKey(startKey: Key): Key | null {\n let key: Key | null = startKey;\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (key != null && this.isDisabled(key));\n return key;\n }\n\n getPreviousKey(startKey: Key): Key | null {\n let key: Key | null = startKey;\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (key != null && this.isDisabled(key));\n return key;\n }\n}\n"],"names":[],"version":3,"file":"TabsKeyboardDelegate.main.js.map"}
|
|
@@ -39,18 +39,20 @@
|
|
|
39
39
|
if (this.tabDirection) return null;
|
|
40
40
|
return this.getNextKey(key);
|
|
41
41
|
}
|
|
42
|
-
getNextKey(
|
|
42
|
+
getNextKey(startKey) {
|
|
43
|
+
let key = startKey;
|
|
43
44
|
do {
|
|
44
45
|
key = this.collection.getKeyAfter(key);
|
|
45
46
|
if (key == null) key = this.collection.getFirstKey();
|
|
46
|
-
}while (this.isDisabled(key));
|
|
47
|
+
}while (key != null && this.isDisabled(key));
|
|
47
48
|
return key;
|
|
48
49
|
}
|
|
49
|
-
getPreviousKey(
|
|
50
|
+
getPreviousKey(startKey) {
|
|
51
|
+
let key = startKey;
|
|
50
52
|
do {
|
|
51
53
|
key = this.collection.getKeyBefore(key);
|
|
52
54
|
if (key == null) key = this.collection.getLastKey();
|
|
53
|
-
}while (this.isDisabled(key));
|
|
55
|
+
}while (key != null && this.isDisabled(key));
|
|
54
56
|
return key;
|
|
55
57
|
}
|
|
56
58
|
constructor(collection, direction, orientation, disabledKeys = new Set()){
|
|
@@ -39,18 +39,20 @@
|
|
|
39
39
|
if (this.tabDirection) return null;
|
|
40
40
|
return this.getNextKey(key);
|
|
41
41
|
}
|
|
42
|
-
getNextKey(
|
|
42
|
+
getNextKey(startKey) {
|
|
43
|
+
let key = startKey;
|
|
43
44
|
do {
|
|
44
45
|
key = this.collection.getKeyAfter(key);
|
|
45
46
|
if (key == null) key = this.collection.getFirstKey();
|
|
46
|
-
}while (this.isDisabled(key));
|
|
47
|
+
}while (key != null && this.isDisabled(key));
|
|
47
48
|
return key;
|
|
48
49
|
}
|
|
49
|
-
getPreviousKey(
|
|
50
|
+
getPreviousKey(startKey) {
|
|
51
|
+
let key = startKey;
|
|
50
52
|
do {
|
|
51
53
|
key = this.collection.getKeyBefore(key);
|
|
52
54
|
if (key == null) key = this.collection.getLastKey();
|
|
53
|
-
}while (this.isDisabled(key));
|
|
55
|
+
}while (key != null && this.isDisabled(key));
|
|
54
56
|
return key;
|
|
55
57
|
}
|
|
56
58
|
constructor(collection, direction, orientation, disabledKeys = new Set()){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAaX,aAAa,GAAQ,
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAIM,MAAM;IAaX,aAAa,GAAQ,EAAc;QACjC,IAAI,IAAI,CAAC,aAAa,EACpB,OAAO,IAAI,CAAC,UAAU,CAAC;QAEzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B;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Y,CAAC;YACnC,IAAI,OAAO,MACT,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU;QAEpC,QAAS,OAAO,QAAQ,IAAI,CAAC,UAAU,CAAC,MAAM;QAC9C,OAAO;IACT;IA5EA,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;AAwEF","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): Key | null {\n if (this.flipDirection) {\n return this.getNextKey(key);\n }\n return this.getPreviousKey(key);\n }\n\n getKeyRightOf(key: Key): Key | null {\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(): Key | null {\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(): Key | null {\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): Key | null {\n if (this.tabDirection) {\n return null;\n }\n return this.getPreviousKey(key);\n }\n\n getKeyBelow(key: Key): Key | null {\n if (this.tabDirection) {\n return null;\n }\n return this.getNextKey(key);\n }\n\n getNextKey(startKey: Key): Key | null {\n let key: Key | null = startKey;\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (key != null && this.isDisabled(key));\n return key;\n }\n\n getPreviousKey(startKey: Key): Key | null {\n let key: Key | null = startKey;\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (key != null && this.isDisabled(key));\n return key;\n }\n}\n"],"names":[],"version":3,"file":"TabsKeyboardDelegate.module.js.map"}
|
package/dist/utils.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAKM,MAAM,4CAAU,IAAI;AAEpB,SAAS,0CAAc,KAA6B,EAAE,GAA2B,EAAE,IAAY;IACpG,IAAI,CAAC,OACH,kFAAkF;IAClF,OAAO;IAET,IAAI,OAAO,QAAQ,UACjB,MAAM,IAAI,OAAO,CAAC,QAAQ;IAG5B,IAAI,SAAS,0CAAQ,GAAG,CAAC;IACzB,OAAO,GAAG,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK;AACnC","sources":["packages/@react-aria/tabs/src/utils.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 {Key} from '@react-types/shared';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T> | null, key: Key | null | undefined, role: string) {\n if (!state) {\n // this case should only happen in the first render before the tabs are registered\n return '';\n }\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\n"],"names":[],"version":3,"file":"utils.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAKM,MAAM,4CAAU,IAAI;AAEpB,SAAS,0CAAc,KAA6B,EAAE,GAA2B,EAAE,IAAY;IACpG,IAAI,CAAC,OACH,kFAAkF;IAClF,OAAO;IAET,IAAI,OAAO,QAAQ,UACjB,MAAM,IAAI,OAAO,CAAC,QAAQ;IAG5B,IAAI,SAAS,0CAAQ,GAAG,CAAC;IACzB,OAAO,GAAG,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK;AACnC","sources":["packages/@react-aria/tabs/src/utils.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 {Key} from '@react-types/shared';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T> | null, key: Key | null | undefined, role: string): string {\n if (!state) {\n // this case should only happen in the first render before the tabs are registered\n return '';\n }\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\n"],"names":[],"version":3,"file":"utils.main.js.map"}
|
package/dist/utils.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAKM,MAAM,4CAAU,IAAI;AAEpB,SAAS,0CAAc,KAA6B,EAAE,GAA2B,EAAE,IAAY;IACpG,IAAI,CAAC,OACH,kFAAkF;IAClF,OAAO;IAET,IAAI,OAAO,QAAQ,UACjB,MAAM,IAAI,OAAO,CAAC,QAAQ;IAG5B,IAAI,SAAS,0CAAQ,GAAG,CAAC;IACzB,OAAO,GAAG,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK;AACnC","sources":["packages/@react-aria/tabs/src/utils.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 {Key} from '@react-types/shared';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T> | null, key: Key | null | undefined, role: string) {\n if (!state) {\n // this case should only happen in the first render before the tabs are registered\n return '';\n }\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\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
|
1
|
+
{"mappings":"AAAA;;;;;;;;;;CAUC,GAKM,MAAM,4CAAU,IAAI;AAEpB,SAAS,0CAAc,KAA6B,EAAE,GAA2B,EAAE,IAAY;IACpG,IAAI,CAAC,OACH,kFAAkF;IAClF,OAAO;IAET,IAAI,OAAO,QAAQ,UACjB,MAAM,IAAI,OAAO,CAAC,QAAQ;IAG5B,IAAI,SAAS,0CAAQ,GAAG,CAAC;IACzB,OAAO,GAAG,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK;AACnC","sources":["packages/@react-aria/tabs/src/utils.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 {Key} from '@react-types/shared';\nimport {TabListState} from '@react-stately/tabs';\n\nexport const tabsIds = new WeakMap<TabListState<unknown>, string>();\n\nexport function generateId<T>(state: TabListState<T> | null, key: Key | null | undefined, role: string): string {\n if (!state) {\n // this case should only happen in the first render before the tabs are registered\n return '';\n }\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\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/tabs",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.2",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/focus": "^3.20.
|
|
26
|
-
"@react-aria/i18n": "^3.12.
|
|
27
|
-
"@react-aria/selection": "^3.
|
|
28
|
-
"@react-aria/utils": "^3.28.
|
|
29
|
-
"@react-stately/tabs": "^3.8.
|
|
30
|
-
"@react-types/shared": "^3.
|
|
31
|
-
"@react-types/tabs": "^3.3.
|
|
25
|
+
"@react-aria/focus": "^3.20.2",
|
|
26
|
+
"@react-aria/i18n": "^3.12.8",
|
|
27
|
+
"@react-aria/selection": "^3.24.0",
|
|
28
|
+
"@react-aria/utils": "^3.28.2",
|
|
29
|
+
"@react-stately/tabs": "^3.8.1",
|
|
30
|
+
"@react-types/shared": "^3.29.0",
|
|
31
|
+
"@react-types/tabs": "^3.3.14",
|
|
32
32
|
"@swc/helpers": "^0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "9b66d270572f482948afee95622a85cdf68ed408"
|
|
42
42
|
}
|
|
@@ -25,14 +25,14 @@ export class TabsKeyboardDelegate<T> implements KeyboardDelegate {
|
|
|
25
25
|
this.tabDirection = orientation === 'horizontal';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
getKeyLeftOf(key: Key) {
|
|
28
|
+
getKeyLeftOf(key: Key): Key | null {
|
|
29
29
|
if (this.flipDirection) {
|
|
30
30
|
return this.getNextKey(key);
|
|
31
31
|
}
|
|
32
32
|
return this.getPreviousKey(key);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
getKeyRightOf(key: Key) {
|
|
35
|
+
getKeyRightOf(key: Key): Key | null {
|
|
36
36
|
if (this.flipDirection) {
|
|
37
37
|
return this.getPreviousKey(key);
|
|
38
38
|
}
|
|
@@ -44,7 +44,7 @@ export class TabsKeyboardDelegate<T> implements KeyboardDelegate {
|
|
|
44
44
|
return this.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
getFirstKey() {
|
|
47
|
+
getFirstKey(): Key | null {
|
|
48
48
|
let key = this.collection.getFirstKey();
|
|
49
49
|
if (key != null && this.isDisabled(key)) {
|
|
50
50
|
key = this.getNextKey(key);
|
|
@@ -52,45 +52,47 @@ export class TabsKeyboardDelegate<T> implements KeyboardDelegate {
|
|
|
52
52
|
return key;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
getLastKey() {
|
|
55
|
+
getLastKey(): Key | null {
|
|
56
56
|
let key = this.collection.getLastKey();
|
|
57
57
|
if (key != null && this.isDisabled(key)) {
|
|
58
58
|
key = this.getPreviousKey(key);
|
|
59
59
|
}
|
|
60
60
|
return key;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
getKeyAbove(key: Key) {
|
|
62
|
+
|
|
63
|
+
getKeyAbove(key: Key): Key | null {
|
|
64
64
|
if (this.tabDirection) {
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
67
|
return this.getPreviousKey(key);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
getKeyBelow(key: Key) {
|
|
70
|
+
getKeyBelow(key: Key): Key | null {
|
|
71
71
|
if (this.tabDirection) {
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
return this.getNextKey(key);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
getNextKey(
|
|
77
|
+
getNextKey(startKey: Key): Key | null {
|
|
78
|
+
let key: Key | null = startKey;
|
|
78
79
|
do {
|
|
79
80
|
key = this.collection.getKeyAfter(key);
|
|
80
81
|
if (key == null) {
|
|
81
82
|
key = this.collection.getFirstKey();
|
|
82
83
|
}
|
|
83
|
-
} while (this.isDisabled(key));
|
|
84
|
+
} while (key != null && this.isDisabled(key));
|
|
84
85
|
return key;
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
getPreviousKey(
|
|
88
|
+
getPreviousKey(startKey: Key): Key | null {
|
|
89
|
+
let key: Key | null = startKey;
|
|
88
90
|
do {
|
|
89
91
|
key = this.collection.getKeyBefore(key);
|
|
90
92
|
if (key == null) {
|
|
91
93
|
key = this.collection.getLastKey();
|
|
92
94
|
}
|
|
93
|
-
} while (this.isDisabled(key));
|
|
95
|
+
} while (key != null && this.isDisabled(key));
|
|
94
96
|
return key;
|
|
95
97
|
}
|
|
96
98
|
}
|
package/src/utils.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {TabListState} from '@react-stately/tabs';
|
|
|
15
15
|
|
|
16
16
|
export const tabsIds = new WeakMap<TabListState<unknown>, string>();
|
|
17
17
|
|
|
18
|
-
export function generateId<T>(state: TabListState<T> | null, key: Key | null | undefined, role: string) {
|
|
18
|
+
export function generateId<T>(state: TabListState<T> | null, key: Key | null | undefined, role: string): string {
|
|
19
19
|
if (!state) {
|
|
20
20
|
// this case should only happen in the first render before the tabs are registered
|
|
21
21
|
return '';
|