@react-aria/tabs 3.0.0-beta.0 → 3.0.0-nightly-4980928d3-240906

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,62 @@
1
+ import {tabsIds as $99b62ae3ff97ec45$export$c5f62239608282b6} from "./utils.mjs";
2
+ import {TabsKeyboardDelegate as $bfc6f2d60b8a4c40$export$15010ca3c1abe90b} from "./TabsKeyboardDelegate.mjs";
3
+ import {useId as $bQNZs$useId, useLabels as $bQNZs$useLabels, mergeProps as $bQNZs$mergeProps} from "@react-aria/utils";
4
+ import {useLocale as $bQNZs$useLocale} from "@react-aria/i18n";
5
+ import {useMemo as $bQNZs$useMemo} from "react";
6
+ import {useSelectableCollection as $bQNZs$useSelectableCollection} from "@react-aria/selection";
7
+
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ function $58d314389b21fa3f$export$773e389e644c5874(props, state, ref) {
25
+ let { orientation: orientation = 'horizontal', keyboardActivation: keyboardActivation = 'automatic' } = props;
26
+ let { collection: collection, selectionManager: manager, disabledKeys: disabledKeys } = state;
27
+ let { direction: direction } = (0, $bQNZs$useLocale)();
28
+ let delegate = (0, $bQNZs$useMemo)(()=>new (0, $bfc6f2d60b8a4c40$export$15010ca3c1abe90b)(collection, direction, orientation, disabledKeys), [
29
+ collection,
30
+ disabledKeys,
31
+ orientation,
32
+ direction
33
+ ]);
34
+ let { collectionProps: collectionProps } = (0, $bQNZs$useSelectableCollection)({
35
+ ref: ref,
36
+ selectionManager: manager,
37
+ keyboardDelegate: delegate,
38
+ selectOnFocus: keyboardActivation === 'automatic',
39
+ disallowEmptySelection: true,
40
+ scrollRef: ref,
41
+ linkBehavior: 'selection'
42
+ });
43
+ // Compute base id for all tabs
44
+ let tabsId = (0, $bQNZs$useId)();
45
+ (0, $99b62ae3ff97ec45$export$c5f62239608282b6).set(state, tabsId);
46
+ let tabListLabelProps = (0, $bQNZs$useLabels)({
47
+ ...props,
48
+ id: tabsId
49
+ });
50
+ return {
51
+ tabListProps: {
52
+ ...(0, $bQNZs$mergeProps)(collectionProps, tabListLabelProps),
53
+ role: 'tablist',
54
+ 'aria-orientation': orientation,
55
+ tabIndex: undefined
56
+ }
57
+ };
58
+ }
59
+
60
+
61
+ export {$58d314389b21fa3f$export$773e389e644c5874 as useTabList};
62
+ //# sourceMappingURL=useTabList.module.js.map
@@ -0,0 +1,62 @@
1
+ import {tabsIds as $99b62ae3ff97ec45$export$c5f62239608282b6} from "./utils.module.js";
2
+ import {TabsKeyboardDelegate as $bfc6f2d60b8a4c40$export$15010ca3c1abe90b} from "./TabsKeyboardDelegate.module.js";
3
+ import {useId as $bQNZs$useId, useLabels as $bQNZs$useLabels, mergeProps as $bQNZs$mergeProps} from "@react-aria/utils";
4
+ import {useLocale as $bQNZs$useLocale} from "@react-aria/i18n";
5
+ import {useMemo as $bQNZs$useMemo} from "react";
6
+ import {useSelectableCollection as $bQNZs$useSelectableCollection} from "@react-aria/selection";
7
+
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */
19
+
20
+
21
+
22
+
23
+
24
+ function $58d314389b21fa3f$export$773e389e644c5874(props, state, ref) {
25
+ let { orientation: orientation = 'horizontal', keyboardActivation: keyboardActivation = 'automatic' } = props;
26
+ let { collection: collection, selectionManager: manager, disabledKeys: disabledKeys } = state;
27
+ let { direction: direction } = (0, $bQNZs$useLocale)();
28
+ let delegate = (0, $bQNZs$useMemo)(()=>new (0, $bfc6f2d60b8a4c40$export$15010ca3c1abe90b)(collection, direction, orientation, disabledKeys), [
29
+ collection,
30
+ disabledKeys,
31
+ orientation,
32
+ direction
33
+ ]);
34
+ let { collectionProps: collectionProps } = (0, $bQNZs$useSelectableCollection)({
35
+ ref: ref,
36
+ selectionManager: manager,
37
+ keyboardDelegate: delegate,
38
+ selectOnFocus: keyboardActivation === 'automatic',
39
+ disallowEmptySelection: true,
40
+ scrollRef: ref,
41
+ linkBehavior: 'selection'
42
+ });
43
+ // Compute base id for all tabs
44
+ let tabsId = (0, $bQNZs$useId)();
45
+ (0, $99b62ae3ff97ec45$export$c5f62239608282b6).set(state, tabsId);
46
+ let tabListLabelProps = (0, $bQNZs$useLabels)({
47
+ ...props,
48
+ id: tabsId
49
+ });
50
+ return {
51
+ tabListProps: {
52
+ ...(0, $bQNZs$mergeProps)(collectionProps, tabListLabelProps),
53
+ role: 'tablist',
54
+ 'aria-orientation': orientation,
55
+ tabIndex: undefined
56
+ }
57
+ };
58
+ }
59
+
60
+
61
+ export {$58d314389b21fa3f$export$773e389e644c5874 as useTabList};
62
+ //# sourceMappingURL=useTabList.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;AAUA;;;;;;AAuBO,SAAS,0CAAc,KAA4B,EAAE,KAAsB,EAAE,GAAkC;IACpH,IAAI,eACF,cAAc,kCACd,qBAAqB,aACtB,GAAG;IACJ,IAAI,cACF,UAAU,EACV,kBAAkB,OAAO,gBACzB,YAAY,EACb,GAAG;IACJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,WAAW,CAAA,GAAA,cAAM,EAAE,IAAM,IAAI,CAAA,GAAA,yCAAmB,EAClD,YACA,WACA,aACA,eAAe;QAAC;QAAY;QAAc;QAAa;KAAU;IAEnE,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,8BAAsB,EAAE;aAC9C;QACA,kBAAkB;QAClB,kBAAkB;QAClB,eAAe,uBAAuB;QACtC,wBAAwB;QACxB,WAAW;QACX,cAAc;IAChB;IAEA,+BAA+B;IAC/B,IAAI,SAAS,CAAA,GAAA,YAAI;IACjB,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC,OAAO;IAEnB,IAAI,oBAAoB,CAAA,GAAA,gBAAQ,EAAE;QAAC,GAAG,KAAK;QAAE,IAAI;IAAM;IAEvD,OAAO;QACL,cAAc;YACZ,GAAG,CAAA,GAAA,iBAAS,EAAE,iBAAiB,kBAAkB;YACjD,MAAM;YACN,oBAAoB;YACpB,UAAU;QACZ;IACF;AACF","sources":["packages/@react-aria/tabs/src/useTabList.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 {AriaTabListProps} from '@react-types/tabs';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {tabsIds} from './utils';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {useLocale} from '@react-aria/i18n';\nimport {useMemo} from 'react';\nimport {useSelectableCollection} from '@react-aria/selection';\n\nexport interface AriaTabListOptions<T> extends Omit<AriaTabListProps<T>, 'children'> {}\n\nexport interface TabListAria {\n /** Props for the tablist container. */\n tabListProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tab list.\n * Tabs organize content into multiple sections and allow users to navigate between them.\n */\nexport function useTabList<T>(props: AriaTabListOptions<T>, state: TabListState<T>, ref: RefObject<HTMLElement | null>): TabListAria {\n let {\n orientation = 'horizontal',\n keyboardActivation = 'automatic'\n } = props;\n let {\n collection,\n selectionManager: manager,\n disabledKeys\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 scrollRef: ref,\n linkBehavior: 'selection'\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 };\n}\n"],"names":[],"version":3,"file":"useTabList.module.js.map"}
@@ -0,0 +1,47 @@
1
+ var $a217ebca77471970$exports = require("./utils.main.js");
2
+ var $8Zd8I$reactariautils = require("@react-aria/utils");
3
+ var $8Zd8I$reactariafocus = require("@react-aria/focus");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useTabPanel", () => $8db1928b18472a1f$export$fae0121b5afe572d);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $8db1928b18472a1f$export$fae0121b5afe572d(props, state, ref) {
25
+ // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
26
+ // Otherwise, tabbing from the focused tab should go directly to the first tabbable element
27
+ // within the tabpanel.
28
+ let tabIndex = (0, $8Zd8I$reactariafocus.useHasTabbableChild)(ref) ? undefined : 0;
29
+ var _props_id;
30
+ const id = (0, $a217ebca77471970$exports.generateId)(state, (_props_id = props.id) !== null && _props_id !== void 0 ? _props_id : state === null || state === void 0 ? void 0 : state.selectedKey, 'tabpanel');
31
+ const tabPanelProps = (0, $8Zd8I$reactariautils.useLabels)({
32
+ ...props,
33
+ id: id,
34
+ 'aria-labelledby': (0, $a217ebca77471970$exports.generateId)(state, state === null || state === void 0 ? void 0 : state.selectedKey, 'tab')
35
+ });
36
+ return {
37
+ tabPanelProps: (0, $8Zd8I$reactariautils.mergeProps)(tabPanelProps, {
38
+ tabIndex: tabIndex,
39
+ role: 'tabpanel',
40
+ 'aria-describedby': props['aria-describedby'],
41
+ 'aria-details': props['aria-details']
42
+ })
43
+ };
44
+ }
45
+
46
+
47
+ //# sourceMappingURL=useTabPanel.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAmBM,SAAS,0CAAe,KAAwB,EAAE,KAA6B,EAAE,GAA8B;IACpH,qFAAqF;IACrF,2FAA2F;IAC3F,uBAAuB;IACvB,IAAI,WAAW,CAAA,GAAA,yCAAkB,EAAE,OAAO,YAAY;QAEzB;IAA7B,MAAM,KAAK,CAAA,GAAA,oCAAS,EAAE,OAAO,CAAA,YAAA,MAAM,EAAE,cAAR,uBAAA,YAAY,kBAAA,4BAAA,MAAO,WAAW,EAAE;IAC7D,MAAM,gBAAgB,CAAA,GAAA,+BAAQ,EAAE;QAAC,GAAG,KAAK;YAAE;QAAI,mBAAmB,CAAA,GAAA,oCAAS,EAAE,OAAO,kBAAA,4BAAA,MAAO,WAAW,EAAE;IAAM;IAE9G,OAAO;QACL,eAAe,CAAA,GAAA,gCAAS,EAAE,eAAe;sBACvC;YACA,MAAM;YACN,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;QACvC;IACF;AACF","sources":["packages/@react-aria/tabs/src/useTabPanel.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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {generateId} from './utils';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {useHasTabbableChild} from '@react-aria/focus';\n\nexport interface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: DOMAttributes\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for\n * the contents of a tab, and is shown when the tab is selected.\n */\nexport function useTabPanel<T>(props: AriaTabPanelProps, state: TabListState<T> | null, ref: RefObject<Element | null>): TabPanelAria {\n // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.\n // Otherwise, tabbing from the focused tab should go directly to the first tabbable element\n // within the tabpanel.\n let tabIndex = useHasTabbableChild(ref) ? undefined : 0;\n\n const id = generateId(state, props.id ?? state?.selectedKey, 'tabpanel');\n const tabPanelProps = useLabels({...props, id, 'aria-labelledby': generateId(state, state?.selectedKey, 'tab')});\n\n return {\n tabPanelProps: mergeProps(tabPanelProps, {\n tabIndex,\n role: 'tabpanel',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\n })\n };\n}\n"],"names":[],"version":3,"file":"useTabPanel.main.js.map"}
@@ -0,0 +1,42 @@
1
+ import {generateId as $99b62ae3ff97ec45$export$567fc7097e064344} from "./utils.mjs";
2
+ import {useLabels as $jik2T$useLabels, mergeProps as $jik2T$mergeProps} from "@react-aria/utils";
3
+ import {useHasTabbableChild as $jik2T$useHasTabbableChild} from "@react-aria/focus";
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
+ function $34bce698202e07cb$export$fae0121b5afe572d(props, state, ref) {
19
+ // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
20
+ // Otherwise, tabbing from the focused tab should go directly to the first tabbable element
21
+ // within the tabpanel.
22
+ let tabIndex = (0, $jik2T$useHasTabbableChild)(ref) ? undefined : 0;
23
+ var _props_id;
24
+ const id = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, (_props_id = props.id) !== null && _props_id !== void 0 ? _props_id : state === null || state === void 0 ? void 0 : state.selectedKey, 'tabpanel');
25
+ const tabPanelProps = (0, $jik2T$useLabels)({
26
+ ...props,
27
+ id: id,
28
+ 'aria-labelledby': (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, state === null || state === void 0 ? void 0 : state.selectedKey, 'tab')
29
+ });
30
+ return {
31
+ tabPanelProps: (0, $jik2T$mergeProps)(tabPanelProps, {
32
+ tabIndex: tabIndex,
33
+ role: 'tabpanel',
34
+ 'aria-describedby': props['aria-describedby'],
35
+ 'aria-details': props['aria-details']
36
+ })
37
+ };
38
+ }
39
+
40
+
41
+ export {$34bce698202e07cb$export$fae0121b5afe572d as useTabPanel};
42
+ //# sourceMappingURL=useTabPanel.module.js.map
@@ -0,0 +1,42 @@
1
+ import {generateId as $99b62ae3ff97ec45$export$567fc7097e064344} from "./utils.module.js";
2
+ import {useLabels as $jik2T$useLabels, mergeProps as $jik2T$mergeProps} from "@react-aria/utils";
3
+ import {useHasTabbableChild as $jik2T$useHasTabbableChild} from "@react-aria/focus";
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
+ function $34bce698202e07cb$export$fae0121b5afe572d(props, state, ref) {
19
+ // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
20
+ // Otherwise, tabbing from the focused tab should go directly to the first tabbable element
21
+ // within the tabpanel.
22
+ let tabIndex = (0, $jik2T$useHasTabbableChild)(ref) ? undefined : 0;
23
+ var _props_id;
24
+ const id = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, (_props_id = props.id) !== null && _props_id !== void 0 ? _props_id : state === null || state === void 0 ? void 0 : state.selectedKey, 'tabpanel');
25
+ const tabPanelProps = (0, $jik2T$useLabels)({
26
+ ...props,
27
+ id: id,
28
+ 'aria-labelledby': (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, state === null || state === void 0 ? void 0 : state.selectedKey, 'tab')
29
+ });
30
+ return {
31
+ tabPanelProps: (0, $jik2T$mergeProps)(tabPanelProps, {
32
+ tabIndex: tabIndex,
33
+ role: 'tabpanel',
34
+ 'aria-describedby': props['aria-describedby'],
35
+ 'aria-details': props['aria-details']
36
+ })
37
+ };
38
+ }
39
+
40
+
41
+ export {$34bce698202e07cb$export$fae0121b5afe572d as useTabPanel};
42
+ //# sourceMappingURL=useTabPanel.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAmBM,SAAS,0CAAe,KAAwB,EAAE,KAA6B,EAAE,GAA8B;IACpH,qFAAqF;IACrF,2FAA2F;IAC3F,uBAAuB;IACvB,IAAI,WAAW,CAAA,GAAA,0BAAkB,EAAE,OAAO,YAAY;QAEzB;IAA7B,MAAM,KAAK,CAAA,GAAA,yCAAS,EAAE,OAAO,CAAA,YAAA,MAAM,EAAE,cAAR,uBAAA,YAAY,kBAAA,4BAAA,MAAO,WAAW,EAAE;IAC7D,MAAM,gBAAgB,CAAA,GAAA,gBAAQ,EAAE;QAAC,GAAG,KAAK;YAAE;QAAI,mBAAmB,CAAA,GAAA,yCAAS,EAAE,OAAO,kBAAA,4BAAA,MAAO,WAAW,EAAE;IAAM;IAE9G,OAAO;QACL,eAAe,CAAA,GAAA,iBAAS,EAAE,eAAe;sBACvC;YACA,MAAM;YACN,oBAAoB,KAAK,CAAC,mBAAmB;YAC7C,gBAAgB,KAAK,CAAC,eAAe;QACvC;IACF;AACF","sources":["packages/@react-aria/tabs/src/useTabPanel.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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {generateId} from './utils';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {useHasTabbableChild} from '@react-aria/focus';\n\nexport interface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: DOMAttributes\n}\n\n\n/**\n * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for\n * the contents of a tab, and is shown when the tab is selected.\n */\nexport function useTabPanel<T>(props: AriaTabPanelProps, state: TabListState<T> | null, ref: RefObject<Element | null>): TabPanelAria {\n // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.\n // Otherwise, tabbing from the focused tab should go directly to the first tabbable element\n // within the tabpanel.\n let tabIndex = useHasTabbableChild(ref) ? undefined : 0;\n\n const id = generateId(state, props.id ?? state?.selectedKey, 'tabpanel');\n const tabPanelProps = useLabels({...props, id, 'aria-labelledby': generateId(state, state?.selectedKey, 'tab')});\n\n return {\n tabPanelProps: mergeProps(tabPanelProps, {\n tabIndex,\n role: 'tabpanel',\n 'aria-describedby': props['aria-describedby'],\n 'aria-details': props['aria-details']\n })\n };\n}\n"],"names":[],"version":3,"file":"useTabPanel.module.js.map"}
@@ -0,0 +1,28 @@
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, "tabsIds", () => $a217ebca77471970$export$c5f62239608282b6);
7
+ $parcel$export(module.exports, "generateId", () => $a217ebca77471970$export$567fc7097e064344);
8
+ /*
9
+ * Copyright 2020 Adobe. All rights reserved.
10
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software distributed under
15
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
+ * OF ANY KIND, either express or implied. See the License for the specific language
17
+ * governing permissions and limitations under the License.
18
+ */ const $a217ebca77471970$export$c5f62239608282b6 = new WeakMap();
19
+ function $a217ebca77471970$export$567fc7097e064344(state, key, role) {
20
+ if (!state) // this case should only happen in the first render before the tabs are registered
21
+ return '';
22
+ if (typeof key === 'string') key = key.replace(/\s+/g, '');
23
+ let baseId = $a217ebca77471970$export$c5f62239608282b6.get(state);
24
+ return `${baseId}-${role}-${key}`;
25
+ }
26
+
27
+
28
+ //# sourceMappingURL=utils.main.js.map
@@ -0,0 +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,CAAC,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC;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"}
package/dist/utils.mjs ADDED
@@ -0,0 +1,22 @@
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
+ */ const $99b62ae3ff97ec45$export$c5f62239608282b6 = new WeakMap();
12
+ function $99b62ae3ff97ec45$export$567fc7097e064344(state, key, role) {
13
+ if (!state) // this case should only happen in the first render before the tabs are registered
14
+ return '';
15
+ if (typeof key === 'string') key = key.replace(/\s+/g, '');
16
+ let baseId = $99b62ae3ff97ec45$export$c5f62239608282b6.get(state);
17
+ return `${baseId}-${role}-${key}`;
18
+ }
19
+
20
+
21
+ export {$99b62ae3ff97ec45$export$c5f62239608282b6 as tabsIds, $99b62ae3ff97ec45$export$567fc7097e064344 as generateId};
22
+ //# sourceMappingURL=utils.module.js.map
@@ -0,0 +1,22 @@
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
+ */ const $99b62ae3ff97ec45$export$c5f62239608282b6 = new WeakMap();
12
+ function $99b62ae3ff97ec45$export$567fc7097e064344(state, key, role) {
13
+ if (!state) // this case should only happen in the first render before the tabs are registered
14
+ return '';
15
+ if (typeof key === 'string') key = key.replace(/\s+/g, '');
16
+ let baseId = $99b62ae3ff97ec45$export$c5f62239608282b6.get(state);
17
+ return `${baseId}-${role}-${key}`;
18
+ }
19
+
20
+
21
+ export {$99b62ae3ff97ec45$export$c5f62239608282b6 as tabsIds, $99b62ae3ff97ec45$export$567fc7097e064344 as generateId};
22
+ //# sourceMappingURL=utils.module.js.map
@@ -0,0 +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,CAAC,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC;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"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/tabs",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0-nightly-4980928d3-240906",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,21 +22,21 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/i18n": "^3.3.0",
22
- "@react-aria/interactions": "^3.3.3",
23
- "@react-aria/selection": "^3.3.2",
24
- "@react-aria/utils": "^3.6.0",
25
- "@react-stately/list": "^3.2.2",
26
- "@react-stately/tabs": "3.0.0-beta.0",
27
- "@react-types/shared": "^3.4.0",
28
- "@react-types/tabs": "3.0.0-beta.0"
25
+ "@react-aria/focus": "^3.0.0-nightly-4980928d3-240906",
26
+ "@react-aria/i18n": "^3.0.0-nightly-4980928d3-240906",
27
+ "@react-aria/selection": "^3.0.0-nightly-4980928d3-240906",
28
+ "@react-aria/utils": "^3.0.0-nightly-4980928d3-240906",
29
+ "@react-stately/tabs": "^3.0.0-nightly-4980928d3-240906",
30
+ "@react-types/shared": "^3.0.0-nightly-4980928d3-240906",
31
+ "@react-types/tabs": "^3.0.0-nightly-4980928d3-240906",
32
+ "@swc/helpers": "^0.5.0"
29
33
  },
30
34
  "peerDependencies": {
31
- "react": "^16.8.0 || ^17.0.0-rc.1"
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"
32
37
  },
33
38
  "publishConfig": {
34
39
  "access": "public"
35
40
  },
36
- "gitHead": "9920ffaa2596a03c4498a15cb940bd2f4ba5cd6a"
37
- }
41
+ "stableVersion": "3.9.5"
42
+ }
@@ -10,61 +10,43 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Collection, Direction, KeyboardDelegate, Orientation} from '@react-types/shared';
14
- import {Key} from 'react';
13
+ import {Collection, Direction, Key, KeyboardDelegate, Node, Orientation} from '@react-types/shared';
15
14
 
16
15
  export class TabsKeyboardDelegate<T> implements KeyboardDelegate {
17
- private collection: Collection<T>;
16
+ private collection: Collection<Node<T>>;
18
17
  private flipDirection: boolean;
19
18
  private disabledKeys: Set<Key>;
20
- private orientation: Orientation;
19
+ private tabDirection: boolean;
21
20
 
22
- constructor(collection: Collection<T>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {
21
+ constructor(collection: Collection<Node<T>>, direction: Direction, orientation: Orientation, disabledKeys: Set<Key> = new Set()) {
23
22
  this.collection = collection;
24
23
  this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
25
- this.orientation = orientation;
26
24
  this.disabledKeys = disabledKeys;
25
+ this.tabDirection = orientation === 'horizontal';
27
26
  }
28
27
 
29
28
  getKeyLeftOf(key: Key) {
30
29
  if (this.flipDirection) {
31
30
  return this.getNextKey(key);
32
- } else {
33
- if (this.orientation === 'horizontal') {
34
- return this.getPreviousKey(key);
35
- }
36
- return null;
37
31
  }
32
+ return this.getPreviousKey(key);
38
33
  }
39
34
 
40
35
  getKeyRightOf(key: Key) {
41
36
  if (this.flipDirection) {
42
37
  return this.getPreviousKey(key);
43
- } else {
44
- if (this.orientation === 'horizontal') {
45
- return this.getNextKey(key);
46
- }
47
- return null;
48
38
  }
39
+ return this.getNextKey(key);
49
40
  }
50
41
 
51
- getKeyAbove(key: Key) {
52
- if (this.orientation === 'vertical') {
53
- return this.getPreviousKey(key);
54
- }
55
- return null;
56
- }
57
42
 
58
- getKeyBelow(key: Key) {
59
- if (this.orientation === 'vertical') {
60
- return this.getNextKey(key);
61
- }
62
- return null;
43
+ private isDisabled(key: Key) {
44
+ return this.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled;
63
45
  }
64
46
 
65
47
  getFirstKey() {
66
48
  let key = this.collection.getFirstKey();
67
- if (this.disabledKeys.has(key)) {
49
+ if (key != null && this.isDisabled(key)) {
68
50
  key = this.getNextKey(key);
69
51
  }
70
52
  return key;
@@ -72,11 +54,25 @@ export class TabsKeyboardDelegate<T> implements KeyboardDelegate {
72
54
 
73
55
  getLastKey() {
74
56
  let key = this.collection.getLastKey();
75
- if (this.disabledKeys.has(key)) {
57
+ if (key != null && this.isDisabled(key)) {
76
58
  key = this.getPreviousKey(key);
77
59
  }
78
60
  return key;
79
61
  }
62
+
63
+ getKeyAbove(key: Key) {
64
+ if (this.tabDirection) {
65
+ return null;
66
+ }
67
+ return this.getPreviousKey(key);
68
+ }
69
+
70
+ getKeyBelow(key: Key) {
71
+ if (this.tabDirection) {
72
+ return null;
73
+ }
74
+ return this.getNextKey(key);
75
+ }
80
76
 
81
77
  getNextKey(key) {
82
78
  do {
@@ -84,7 +80,7 @@ export class TabsKeyboardDelegate<T> implements KeyboardDelegate {
84
80
  if (key == null) {
85
81
  key = this.collection.getFirstKey();
86
82
  }
87
- } while (this.disabledKeys.has(key));
83
+ } while (this.isDisabled(key));
88
84
  return key;
89
85
  }
90
86
 
@@ -94,7 +90,7 @@ export class TabsKeyboardDelegate<T> implements KeyboardDelegate {
94
90
  if (key == null) {
95
91
  key = this.collection.getLastKey();
96
92
  }
97
- } while (this.disabledKeys.has(key));
93
+ } while (this.isDisabled(key));
98
94
  return key;
99
95
  }
100
96
  }
package/src/index.ts CHANGED
@@ -9,5 +9,11 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
-
13
- export * from './useTabs';
12
+ export {useTab} from './useTab';
13
+ export {useTabPanel} from './useTabPanel';
14
+ export {useTabList} from './useTabList';
15
+ export type {AriaTabListProps, AriaTabPanelProps, AriaTabProps} from '@react-types/tabs';
16
+ export type {Orientation} from '@react-types/shared';
17
+ export type {TabAria} from './useTab';
18
+ export type {TabPanelAria} from './useTabPanel';
19
+ export type {AriaTabListOptions, TabListAria} from './useTabList';
package/src/useTab.ts ADDED
@@ -0,0 +1,77 @@
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
+ */
12
+
13
+ import {AriaTabProps} from '@react-types/tabs';
14
+ import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
15
+ import {filterDOMProps, mergeProps, useLinkProps} from '@react-aria/utils';
16
+ import {generateId} from './utils';
17
+ import {TabListState} from '@react-stately/tabs';
18
+ import {useSelectableItem} from '@react-aria/selection';
19
+
20
+ export interface TabAria {
21
+ /** Props for the tab element. */
22
+ tabProps: DOMAttributes,
23
+ /** Whether the tab is currently selected. */
24
+ isSelected: boolean,
25
+ /** Whether the tab is disabled. */
26
+ isDisabled: boolean,
27
+ /** Whether the tab is currently in a pressed state. */
28
+ isPressed: boolean
29
+ }
30
+
31
+ /**
32
+ * Provides the behavior and accessibility implementation for a tab.
33
+ * When selected, the associated tab panel is shown.
34
+ */
35
+ export function useTab<T>(
36
+ props: AriaTabProps,
37
+ state: TabListState<T>,
38
+ ref: RefObject<FocusableElement | null>
39
+ ): TabAria {
40
+ let {key, isDisabled: propsDisabled, shouldSelectOnPressUp} = props;
41
+ let {selectionManager: manager, selectedKey} = state;
42
+
43
+ let isSelected = key === selectedKey;
44
+
45
+ let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);
46
+ let {itemProps, isPressed} = useSelectableItem({
47
+ selectionManager: manager,
48
+ key,
49
+ ref,
50
+ isDisabled,
51
+ shouldSelectOnPressUp,
52
+ linkBehavior: 'selection'
53
+ });
54
+
55
+ let tabId = generateId(state, key, 'tab');
56
+ let tabPanelId = generateId(state, key, 'tabpanel');
57
+ let {tabIndex} = itemProps;
58
+
59
+ let item = state.collection.getItem(key);
60
+ let domProps = filterDOMProps(item?.props, {labelable: true});
61
+ delete domProps.id;
62
+ let linkProps = useLinkProps(item?.props);
63
+
64
+ return {
65
+ tabProps: mergeProps(domProps, linkProps, itemProps, {
66
+ id: tabId,
67
+ 'aria-selected': isSelected,
68
+ 'aria-disabled': isDisabled || undefined,
69
+ 'aria-controls': isSelected ? tabPanelId : undefined,
70
+ tabIndex: isDisabled ? undefined : tabIndex,
71
+ role: 'tab'
72
+ }),
73
+ isSelected,
74
+ isDisabled,
75
+ isPressed
76
+ };
77
+ }