@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
package/dist/module.js CHANGED
@@ -1,9 +1,6 @@
1
- import { useSelectableCollection, useSelectableItem } from "@react-aria/selection";
2
- import { usePress } from "@react-aria/interactions";
3
- import { useLocale } from "@react-aria/i18n";
4
- import { mergeProps, useId, useLabels } from "@react-aria/utils";
5
- import { useMemo } from "react";
6
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
1
+ import {useTab as $0175d55c2a017ebc$export$fdf4756d5b8ef90a} from "./useTab.module.js";
2
+ import {useTabPanel as $34bce698202e07cb$export$fae0121b5afe572d} from "./useTabPanel.module.js";
3
+ import {useTabList as $58d314389b21fa3f$export$773e389e644c5874} from "./useTabList.module.js";
7
4
 
8
5
  /*
9
6
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,208 +12,10 @@ import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
15
12
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
13
  * OF ANY KIND, either express or implied. See the License for the specific language
17
14
  * governing permissions and limitations under the License.
18
- */
19
- class $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate {
20
- constructor(collection, direction, orientation, disabledKeys) {
21
- if (disabledKeys === void 0) {
22
- disabledKeys = new Set();
23
- }
15
+ */
24
16
 
25
- this.collection = void 0;
26
- this.flipDirection = void 0;
27
- this.disabledKeys = void 0;
28
- this.orientation = void 0;
29
- this.collection = collection;
30
- this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
31
- this.orientation = orientation;
32
- this.disabledKeys = disabledKeys;
33
- }
34
17
 
35
- getKeyLeftOf(key) {
36
- if (this.flipDirection) {
37
- return this.getNextKey(key);
38
- } else {
39
- if (this.orientation === 'horizontal') {
40
- return this.getPreviousKey(key);
41
- }
42
18
 
43
- return null;
44
- }
45
- }
46
19
 
47
- getKeyRightOf(key) {
48
- if (this.flipDirection) {
49
- return this.getPreviousKey(key);
50
- } else {
51
- if (this.orientation === 'horizontal') {
52
- return this.getNextKey(key);
53
- }
54
-
55
- return null;
56
- }
57
- }
58
-
59
- getKeyAbove(key) {
60
- if (this.orientation === 'vertical') {
61
- return this.getPreviousKey(key);
62
- }
63
-
64
- return null;
65
- }
66
-
67
- getKeyBelow(key) {
68
- if (this.orientation === 'vertical') {
69
- return this.getNextKey(key);
70
- }
71
-
72
- return null;
73
- }
74
-
75
- getFirstKey() {
76
- let key = this.collection.getFirstKey();
77
-
78
- if (this.disabledKeys.has(key)) {
79
- key = this.getNextKey(key);
80
- }
81
-
82
- return key;
83
- }
84
-
85
- getLastKey() {
86
- let key = this.collection.getLastKey();
87
-
88
- if (this.disabledKeys.has(key)) {
89
- key = this.getPreviousKey(key);
90
- }
91
-
92
- return key;
93
- }
94
-
95
- getNextKey(key) {
96
- do {
97
- key = this.collection.getKeyAfter(key);
98
-
99
- if (key == null) {
100
- key = this.collection.getFirstKey();
101
- }
102
- } while (this.disabledKeys.has(key));
103
-
104
- return key;
105
- }
106
-
107
- getPreviousKey(key) {
108
- do {
109
- key = this.collection.getKeyBefore(key);
110
-
111
- if (key == null) {
112
- key = this.collection.getLastKey();
113
- }
114
- } while (this.disabledKeys.has(key));
115
-
116
- return key;
117
- }
118
-
119
- }
120
-
121
- const $a98339edf5b490c874cb7f3b44b70$var$tabsIds = new WeakMap();
122
- export function useTabs(props, state, ref) {
123
- let {
124
- orientation = 'horizontal',
125
- keyboardActivation = 'automatic'
126
- } = props;
127
- let {
128
- collection,
129
- selectionManager: manager,
130
- disabledKeys,
131
- selectedKey
132
- } = state;
133
- let {
134
- direction
135
- } = useLocale();
136
- let delegate = useMemo(() => new $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate(collection, direction, orientation, disabledKeys), [collection, disabledKeys, orientation, direction]);
137
- let {
138
- collectionProps
139
- } = useSelectableCollection({
140
- ref,
141
- selectionManager: manager,
142
- keyboardDelegate: delegate,
143
- selectOnFocus: keyboardActivation === 'automatic',
144
- disallowEmptySelection: true
145
- }); // Compute base id for all tabs
146
-
147
- let tabsId = useId();
148
- $a98339edf5b490c874cb7f3b44b70$var$tabsIds.set(state, tabsId);
149
- let tabListLabelProps = useLabels(_babelRuntimeHelpersEsmExtends({}, props, {
150
- id: tabsId
151
- }));
152
- return {
153
- tabListProps: _babelRuntimeHelpersEsmExtends({}, mergeProps(collectionProps, tabListLabelProps), {
154
- role: 'tablist',
155
- 'aria-orientation': orientation,
156
- tabIndex: undefined
157
- }),
158
- tabPanelProps: {
159
- id: $a98339edf5b490c874cb7f3b44b70$var$generateId(state, selectedKey, 'tabpanel'),
160
- 'aria-labelledby': $a98339edf5b490c874cb7f3b44b70$var$generateId(state, selectedKey, 'tab'),
161
- tabIndex: 0,
162
- role: 'tabpanel'
163
- }
164
- };
165
- }
166
- export function useTab(props, state, ref) {
167
- let {
168
- item,
169
- isDisabled: propsDisabled
170
- } = props;
171
- let {
172
- key
173
- } = item;
174
- let {
175
- selectionManager: manager,
176
- selectedKey
177
- } = state;
178
- let isSelected = key === selectedKey;
179
- let {
180
- itemProps
181
- } = useSelectableItem({
182
- selectionManager: manager,
183
- key,
184
- ref
185
- });
186
- let isDisabled = propsDisabled || state.disabledKeys.has(key);
187
- let {
188
- pressProps
189
- } = usePress(_babelRuntimeHelpersEsmExtends({}, itemProps, {
190
- isDisabled
191
- }));
192
- let tabId = $a98339edf5b490c874cb7f3b44b70$var$generateId(state, key, 'tab');
193
- let tabPanelId = $a98339edf5b490c874cb7f3b44b70$var$generateId(state, key, 'tabpanel');
194
- let {
195
- tabIndex
196
- } = pressProps; // selected tab should have tabIndex=0, when it initializes
197
-
198
- if (isSelected && !isDisabled) {
199
- tabIndex = 0;
200
- }
201
-
202
- return {
203
- tabProps: _babelRuntimeHelpersEsmExtends({}, pressProps, {
204
- id: tabId,
205
- 'aria-selected': isSelected,
206
- 'aria-disabled': isDisabled || undefined,
207
- 'aria-controls': isSelected ? tabPanelId : undefined,
208
- tabIndex: isDisabled ? undefined : tabIndex,
209
- role: 'tab'
210
- })
211
- };
212
- }
213
-
214
- function $a98339edf5b490c874cb7f3b44b70$var$generateId(state, key, role) {
215
- if (typeof key === 'string') {
216
- key = key.replace(/\s+/g, '');
217
- }
218
-
219
- let baseId = $a98339edf5b490c874cb7f3b44b70$var$tabsIds.get(state);
220
- return baseId + "-" + role + "-" + key;
221
- }
20
+ export {$0175d55c2a017ebc$export$fdf4756d5b8ef90a as useTab, $34bce698202e07cb$export$fae0121b5afe572d as useTabPanel, $58d314389b21fa3f$export$773e389e644c5874 as useTabList};
222
21
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;;AAeO,MAAMA,2DAAN,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,CAAoBF,GAApB,CAAP;AACD;;AACD,aAAO,IAAP;AACD;AACF;;AAEDG,EAAAA,aAAa,CAACH,GAAD,EAAW;AACtB,QAAI,KAAKF,aAAT,EAAwB;AACtB,aAAO,KAAKI,cAAL,CAAoBF,GAApB,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,GAAvB,CAAlC;AAEA,MAAI;AAACiD,IAAAA;AAAD,MAAeC,QAAQ,oCAAKH,SAAL;AAAgBH,IAAAA;AAAhB,KAA3B;AACA,MAAIO,KAAK,GAAGV,6CAAU,CAAC1B,KAAD,EAAQf,GAAR,EAAa,KAAb,CAAtB;AACA,MAAIoD,UAAU,GAAGX,6CAAU,CAAC1B,KAAD,EAAQf,GAAR,EAAa,UAAb,CAA3B;AACA,MAAI;AAACsC,IAAAA;AAAD,MAAaW,UAAjB,CAjBS,CAmBT;;AACA,MAAIH,UAAU,IAAI,CAACF,UAAnB,EAA+B;AAC7BN,IAAAA,QAAQ,GAAG,CAAX;AACD;;AAED,SAAO;AACLe,IAAAA,QAAQ,qCACHJ,UADG;AAENf,MAAAA,EAAE,EAAEiB,KAFE;AAGN,uBAAiBL,UAHX;AAIN,uBAAiBF,UAAU,IAAIL,SAJzB;AAKN,uBAAiBO,UAAU,GAAGM,UAAH,GAAgBb,SALrC;AAMND,MAAAA,QAAQ,EAAEM,UAAU,GAAGL,SAAH,GAAeD,QAN7B;AAOND,MAAAA,IAAI,EAAE;AAPA;AADH,GAAP;AAWD;;AAED,SAASI,6CAAT,CAAuB1B,KAAvB,EAAwDf,GAAxD,EAAkEqC,IAAlE,EAAgF;AAC9E,MAAI,OAAOrC,GAAP,KAAe,QAAnB,EAA6B;AAC3BA,IAAAA,GAAG,GAAGA,GAAG,CAACsD,OAAJ,CAAY,MAAZ,EAAoB,EAApB,CAAN;AACD;;AAED,MAAIC,MAAM,GAAG5C,0CAAO,CAAC6C,GAAR,CAAYzC,KAAZ,CAAb;AACA,SAAUwC,MAAV,SAAoBlB,IAApB,SAA4BrC,GAA5B;AACD","sources":["./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/useTabs.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, 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":["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":"module.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":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -1,18 +1,42 @@
1
- import { AriaTabProps, AriaTabsProps } from "@react-types/tabs";
2
- import { HTMLAttributes, RefObject } from "react";
3
- import { SingleSelectListState } from "@react-stately/list";
4
- import { TabsState } from "@react-stately/tabs";
5
- interface TabsAria {
6
- /** Props for the tablist container. */
7
- tabListProps: HTMLAttributes<HTMLElement>;
8
- /** Props for the associated tabpanel element. */
9
- tabPanelProps: HTMLAttributes<HTMLElement>;
10
- }
11
- export function useTabs<T>(props: AriaTabsProps<T>, state: TabsState<T>, ref: any): TabsAria;
12
- interface TabAria {
1
+ import { AriaTabProps, AriaTabPanelProps, AriaTabListProps } from "@react-types/tabs";
2
+ import { DOMAttributes, FocusableElement, RefObject } from "@react-types/shared";
3
+ import { TabListState } from "@react-stately/tabs";
4
+ export interface TabAria {
13
5
  /** Props for the tab element. */
14
- tabProps: HTMLAttributes<HTMLElement>;
6
+ tabProps: DOMAttributes;
7
+ /** Whether the tab is currently selected. */
8
+ isSelected: boolean;
9
+ /** Whether the tab is disabled. */
10
+ isDisabled: boolean;
11
+ /** Whether the tab is currently in a pressed state. */
12
+ isPressed: boolean;
13
+ }
14
+ /**
15
+ * Provides the behavior and accessibility implementation for a tab.
16
+ * When selected, the associated tab panel is shown.
17
+ */
18
+ export function useTab<T>(props: AriaTabProps, state: TabListState<T>, ref: RefObject<FocusableElement | null>): TabAria;
19
+ export interface TabPanelAria {
20
+ /** Props for the tab panel element. */
21
+ tabPanelProps: DOMAttributes;
22
+ }
23
+ /**
24
+ * Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for
25
+ * the contents of a tab, and is shown when the tab is selected.
26
+ */
27
+ export function useTabPanel<T>(props: AriaTabPanelProps, state: TabListState<T> | null, ref: RefObject<Element | null>): TabPanelAria;
28
+ export interface AriaTabListOptions<T> extends Omit<AriaTabListProps<T>, 'children'> {
29
+ }
30
+ export interface TabListAria {
31
+ /** Props for the tablist container. */
32
+ tabListProps: DOMAttributes;
15
33
  }
16
- export function useTab<T>(props: AriaTabProps<T>, state: SingleSelectListState<T>, ref: RefObject<HTMLElement>): TabAria;
34
+ /**
35
+ * Provides the behavior and accessibility implementation for a tab list.
36
+ * Tabs organize content into multiple sections and allow users to navigate between them.
37
+ */
38
+ export function useTabList<T>(props: AriaTabListOptions<T>, state: TabListState<T>, ref: RefObject<HTMLElement | null>): TabListAria;
39
+ export type { AriaTabListProps, AriaTabPanelProps, AriaTabProps } from '@react-types/tabs';
40
+ export type { Orientation } from '@react-types/shared';
17
41
 
18
42
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":"A;A;A;A;ACsBA;IACE,uCAAuC;IACvC,YAAY,EAAE,eAAe,WAAW,CAAC,CAAC;IAC1C,iDAAiD;IACjD,aAAa,EAAE,eAAe,WAAW,CAAC,CAAA;CAC3C;AAID,wBAAwB,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,KAAA,GAAG,QAAQ,CA8CtF;AAED;IACE,iCAAiC;IACjC,QAAQ,EAAE,eAAe,WAAW,CAAC,CAAA;CACtC;AAED,uBAAuB,CAAC,EACtB,KAAK,EAAE,aAAa,CAAC,CAAC,EACtB,KAAK,EAAE,sBAAsB,CAAC,CAAC,EAC/B,GAAG,EAAE,UAAU,WAAW,CAAC,GAC1B,OAAO,CAmCT","sources":["./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTabs.ts","./packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/index.ts"],"sourcesContent":[null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;ACmBA;IACE,iCAAiC;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,6CAA6C;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,mCAAmC;IACnC,UAAU,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;GAGG;AACH,uBAAuB,CAAC,EACtB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,aAAa,CAAC,CAAC,EACtB,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GACtC,OAAO,CAsCT;ACzDD;IACE,uCAAuC;IACvC,aAAa,EAAE,aAAa,CAAA;CAC7B;AAGD;;;GAGG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,UAAU,OAAO,GAAG,IAAI,CAAC,GAAG,YAAY,CAiBpI;AExBD,oCAAoC,CAAC,CAAE,SAAQ,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,UAAU,CAAC;CAAG;AAEvF;IACE,uCAAuC;IACvC,YAAY,EAAE,aAAa,CAAA;CAC5B;AAED;;;GAGG;AACH,2BAA2B,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,GAAG,WAAW,CAyCnI;AC5DD,YAAY,EAAC,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AACzF,YAAY,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/utils.ts","packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTab.ts","packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTabPanel.ts","packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/useTabList.ts","packages/@react-aria/tabs/src/packages/@react-aria/tabs/src/index.ts","packages/@react-aria/tabs/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\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":"types.d.ts.map"}
@@ -0,0 +1,62 @@
1
+ var $a217ebca77471970$exports = require("./utils.main.js");
2
+ var $dX61C$reactariautils = require("@react-aria/utils");
3
+ var $dX61C$reactariaselection = require("@react-aria/selection");
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, "useTab", () => $4eeea1c984cc0628$export$fdf4756d5b8ef90a);
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 $4eeea1c984cc0628$export$fdf4756d5b8ef90a(props, state, ref) {
25
+ let { key: key, isDisabled: propsDisabled, shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
26
+ let { selectionManager: manager, selectedKey: selectedKey } = state;
27
+ let isSelected = key === selectedKey;
28
+ let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);
29
+ let { itemProps: itemProps, isPressed: isPressed } = (0, $dX61C$reactariaselection.useSelectableItem)({
30
+ selectionManager: manager,
31
+ key: key,
32
+ ref: ref,
33
+ isDisabled: isDisabled,
34
+ shouldSelectOnPressUp: shouldSelectOnPressUp,
35
+ linkBehavior: 'selection'
36
+ });
37
+ let tabId = (0, $a217ebca77471970$exports.generateId)(state, key, 'tab');
38
+ let tabPanelId = (0, $a217ebca77471970$exports.generateId)(state, key, 'tabpanel');
39
+ let { tabIndex: tabIndex } = itemProps;
40
+ let item = state.collection.getItem(key);
41
+ let domProps = (0, $dX61C$reactariautils.filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
42
+ labelable: true
43
+ });
44
+ delete domProps.id;
45
+ let linkProps = (0, $dX61C$reactariautils.useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
46
+ return {
47
+ tabProps: (0, $dX61C$reactariautils.mergeProps)(domProps, linkProps, itemProps, {
48
+ id: tabId,
49
+ 'aria-selected': isSelected,
50
+ 'aria-disabled': isDisabled || undefined,
51
+ 'aria-controls': isSelected ? tabPanelId : undefined,
52
+ tabIndex: isDisabled ? undefined : tabIndex,
53
+ role: 'tab'
54
+ }),
55
+ isSelected: isSelected,
56
+ isDisabled: isDisabled,
57
+ isPressed: isPressed
58
+ };
59
+ }
60
+
61
+
62
+ //# sourceMappingURL=useTab.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAwBM,SAAS,0CACd,KAAmB,EACnB,KAAsB,EACtB,GAAuC;IAEvC,IAAI,OAAC,GAAG,EAAE,YAAY,aAAa,yBAAE,qBAAqB,EAAC,GAAG;IAC9D,IAAI,EAAC,kBAAkB,OAAO,eAAE,WAAW,EAAC,GAAG;IAE/C,IAAI,aAAa,QAAQ;IAEzB,IAAI,aAAa,iBAAiB,MAAM,UAAU,IAAI,MAAM,gBAAgB,CAAC,UAAU,CAAC;IACxF,IAAI,aAAC,SAAS,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAC7C,kBAAkB;aAClB;aACA;oBACA;+BACA;QACA,cAAc;IAChB;IAEA,IAAI,QAAQ,CAAA,GAAA,oCAAS,EAAE,OAAO,KAAK;IACnC,IAAI,aAAa,CAAA,GAAA,oCAAS,EAAE,OAAO,KAAK;IACxC,IAAI,YAAC,QAAQ,EAAC,GAAG;IAEjB,IAAI,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC;IACpC,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK,EAAE;QAAC,WAAW;IAAI;IAC3D,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,kCAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,UAAU,CAAA,GAAA,gCAAS,EAAE,UAAU,WAAW,WAAW;YACnD,IAAI;YACJ,iBAAiB;YACjB,iBAAiB,cAAc;YAC/B,iBAAiB,aAAa,aAAa;YAC3C,UAAU,aAAa,YAAY;YACnC,MAAM;QACR;oBACA;oBACA;mBACA;IACF;AACF","sources":["packages/@react-aria/tabs/src/useTab.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 {AriaTabProps} from '@react-types/tabs';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLinkProps} from '@react-aria/utils';\nimport {generateId} from './utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface TabAria {\n /** Props for the tab element. */\n tabProps: DOMAttributes,\n /** Whether the tab is currently selected. */\n isSelected: boolean,\n /** Whether the tab is disabled. */\n isDisabled: boolean,\n /** Whether the tab is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tab.\n * When selected, the associated tab panel is shown.\n */\nexport function useTab<T>(\n props: AriaTabProps,\n state: TabListState<T>,\n ref: RefObject<FocusableElement | null>\n): TabAria {\n let {key, isDisabled: propsDisabled, shouldSelectOnPressUp} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled,\n shouldSelectOnPressUp,\n linkBehavior: 'selection'\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n let item = state.collection.getItem(key);\n let domProps = filterDOMProps(item?.props, {labelable: true});\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n tabProps: mergeProps(domProps, linkProps, itemProps, {\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 isSelected,\n isDisabled,\n isPressed\n };\n}\n"],"names":[],"version":3,"file":"useTab.main.js.map"}
@@ -0,0 +1,57 @@
1
+ import {generateId as $99b62ae3ff97ec45$export$567fc7097e064344} from "./utils.mjs";
2
+ import {filterDOMProps as $dObGJ$filterDOMProps, useLinkProps as $dObGJ$useLinkProps, mergeProps as $dObGJ$mergeProps} from "@react-aria/utils";
3
+ import {useSelectableItem as $dObGJ$useSelectableItem} from "@react-aria/selection";
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 $0175d55c2a017ebc$export$fdf4756d5b8ef90a(props, state, ref) {
19
+ let { key: key, isDisabled: propsDisabled, shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
20
+ let { selectionManager: manager, selectedKey: selectedKey } = state;
21
+ let isSelected = key === selectedKey;
22
+ let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);
23
+ let { itemProps: itemProps, isPressed: isPressed } = (0, $dObGJ$useSelectableItem)({
24
+ selectionManager: manager,
25
+ key: key,
26
+ ref: ref,
27
+ isDisabled: isDisabled,
28
+ shouldSelectOnPressUp: shouldSelectOnPressUp,
29
+ linkBehavior: 'selection'
30
+ });
31
+ let tabId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, 'tab');
32
+ let tabPanelId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, 'tabpanel');
33
+ let { tabIndex: tabIndex } = itemProps;
34
+ let item = state.collection.getItem(key);
35
+ let domProps = (0, $dObGJ$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
36
+ labelable: true
37
+ });
38
+ delete domProps.id;
39
+ let linkProps = (0, $dObGJ$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
40
+ return {
41
+ tabProps: (0, $dObGJ$mergeProps)(domProps, linkProps, itemProps, {
42
+ id: tabId,
43
+ 'aria-selected': isSelected,
44
+ 'aria-disabled': isDisabled || undefined,
45
+ 'aria-controls': isSelected ? tabPanelId : undefined,
46
+ tabIndex: isDisabled ? undefined : tabIndex,
47
+ role: 'tab'
48
+ }),
49
+ isSelected: isSelected,
50
+ isDisabled: isDisabled,
51
+ isPressed: isPressed
52
+ };
53
+ }
54
+
55
+
56
+ export {$0175d55c2a017ebc$export$fdf4756d5b8ef90a as useTab};
57
+ //# sourceMappingURL=useTab.module.js.map
@@ -0,0 +1,57 @@
1
+ import {generateId as $99b62ae3ff97ec45$export$567fc7097e064344} from "./utils.module.js";
2
+ import {filterDOMProps as $dObGJ$filterDOMProps, useLinkProps as $dObGJ$useLinkProps, mergeProps as $dObGJ$mergeProps} from "@react-aria/utils";
3
+ import {useSelectableItem as $dObGJ$useSelectableItem} from "@react-aria/selection";
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 $0175d55c2a017ebc$export$fdf4756d5b8ef90a(props, state, ref) {
19
+ let { key: key, isDisabled: propsDisabled, shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
20
+ let { selectionManager: manager, selectedKey: selectedKey } = state;
21
+ let isSelected = key === selectedKey;
22
+ let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);
23
+ let { itemProps: itemProps, isPressed: isPressed } = (0, $dObGJ$useSelectableItem)({
24
+ selectionManager: manager,
25
+ key: key,
26
+ ref: ref,
27
+ isDisabled: isDisabled,
28
+ shouldSelectOnPressUp: shouldSelectOnPressUp,
29
+ linkBehavior: 'selection'
30
+ });
31
+ let tabId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, 'tab');
32
+ let tabPanelId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, 'tabpanel');
33
+ let { tabIndex: tabIndex } = itemProps;
34
+ let item = state.collection.getItem(key);
35
+ let domProps = (0, $dObGJ$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
36
+ labelable: true
37
+ });
38
+ delete domProps.id;
39
+ let linkProps = (0, $dObGJ$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
40
+ return {
41
+ tabProps: (0, $dObGJ$mergeProps)(domProps, linkProps, itemProps, {
42
+ id: tabId,
43
+ 'aria-selected': isSelected,
44
+ 'aria-disabled': isDisabled || undefined,
45
+ 'aria-controls': isSelected ? tabPanelId : undefined,
46
+ tabIndex: isDisabled ? undefined : tabIndex,
47
+ role: 'tab'
48
+ }),
49
+ isSelected: isSelected,
50
+ isDisabled: isDisabled,
51
+ isPressed: isPressed
52
+ };
53
+ }
54
+
55
+
56
+ export {$0175d55c2a017ebc$export$fdf4756d5b8ef90a as useTab};
57
+ //# sourceMappingURL=useTab.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAwBM,SAAS,0CACd,KAAmB,EACnB,KAAsB,EACtB,GAAuC;IAEvC,IAAI,OAAC,GAAG,EAAE,YAAY,aAAa,yBAAE,qBAAqB,EAAC,GAAG;IAC9D,IAAI,EAAC,kBAAkB,OAAO,eAAE,WAAW,EAAC,GAAG;IAE/C,IAAI,aAAa,QAAQ;IAEzB,IAAI,aAAa,iBAAiB,MAAM,UAAU,IAAI,MAAM,gBAAgB,CAAC,UAAU,CAAC;IACxF,IAAI,aAAC,SAAS,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAC7C,kBAAkB;aAClB;aACA;oBACA;+BACA;QACA,cAAc;IAChB;IAEA,IAAI,QAAQ,CAAA,GAAA,yCAAS,EAAE,OAAO,KAAK;IACnC,IAAI,aAAa,CAAA,GAAA,yCAAS,EAAE,OAAO,KAAK;IACxC,IAAI,YAAC,QAAQ,EAAC,GAAG;IAEjB,IAAI,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC;IACpC,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK,EAAE;QAAC,WAAW;IAAI;IAC3D,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,mBAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,UAAU,CAAA,GAAA,iBAAS,EAAE,UAAU,WAAW,WAAW;YACnD,IAAI;YACJ,iBAAiB;YACjB,iBAAiB,cAAc;YAC/B,iBAAiB,aAAa,aAAa;YAC3C,UAAU,aAAa,YAAY;YACnC,MAAM;QACR;oBACA;oBACA;mBACA;IACF;AACF","sources":["packages/@react-aria/tabs/src/useTab.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 {AriaTabProps} from '@react-types/tabs';\nimport {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLinkProps} from '@react-aria/utils';\nimport {generateId} from './utils';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface TabAria {\n /** Props for the tab element. */\n tabProps: DOMAttributes,\n /** Whether the tab is currently selected. */\n isSelected: boolean,\n /** Whether the tab is disabled. */\n isDisabled: boolean,\n /** Whether the tab is currently in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a tab.\n * When selected, the associated tab panel is shown.\n */\nexport function useTab<T>(\n props: AriaTabProps,\n state: TabListState<T>,\n ref: RefObject<FocusableElement | null>\n): TabAria {\n let {key, isDisabled: propsDisabled, shouldSelectOnPressUp} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);\n let {itemProps, isPressed} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled,\n shouldSelectOnPressUp,\n linkBehavior: 'selection'\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n let item = state.collection.getItem(key);\n let domProps = filterDOMProps(item?.props, {labelable: true});\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n tabProps: mergeProps(domProps, linkProps, itemProps, {\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 isSelected,\n isDisabled,\n isPressed\n };\n}\n"],"names":[],"version":3,"file":"useTab.module.js.map"}
@@ -0,0 +1,67 @@
1
+ var $a217ebca77471970$exports = require("./utils.main.js");
2
+ var $283e5d8830177ead$exports = require("./TabsKeyboardDelegate.main.js");
3
+ var $c5HcZ$reactariautils = require("@react-aria/utils");
4
+ var $c5HcZ$reactariai18n = require("@react-aria/i18n");
5
+ var $c5HcZ$react = require("react");
6
+ var $c5HcZ$reactariaselection = require("@react-aria/selection");
7
+
8
+
9
+ function $parcel$export(e, n, v, s) {
10
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
+ }
12
+
13
+ $parcel$export(module.exports, "useTabList", () => $f2b4a4926440e901$export$773e389e644c5874);
14
+ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+
27
+
28
+
29
+
30
+ function $f2b4a4926440e901$export$773e389e644c5874(props, state, ref) {
31
+ let { orientation: orientation = 'horizontal', keyboardActivation: keyboardActivation = 'automatic' } = props;
32
+ let { collection: collection, selectionManager: manager, disabledKeys: disabledKeys } = state;
33
+ let { direction: direction } = (0, $c5HcZ$reactariai18n.useLocale)();
34
+ let delegate = (0, $c5HcZ$react.useMemo)(()=>new (0, $283e5d8830177ead$exports.TabsKeyboardDelegate)(collection, direction, orientation, disabledKeys), [
35
+ collection,
36
+ disabledKeys,
37
+ orientation,
38
+ direction
39
+ ]);
40
+ let { collectionProps: collectionProps } = (0, $c5HcZ$reactariaselection.useSelectableCollection)({
41
+ ref: ref,
42
+ selectionManager: manager,
43
+ keyboardDelegate: delegate,
44
+ selectOnFocus: keyboardActivation === 'automatic',
45
+ disallowEmptySelection: true,
46
+ scrollRef: ref,
47
+ linkBehavior: 'selection'
48
+ });
49
+ // Compute base id for all tabs
50
+ let tabsId = (0, $c5HcZ$reactariautils.useId)();
51
+ (0, $a217ebca77471970$exports.tabsIds).set(state, tabsId);
52
+ let tabListLabelProps = (0, $c5HcZ$reactariautils.useLabels)({
53
+ ...props,
54
+ id: tabsId
55
+ });
56
+ return {
57
+ tabListProps: {
58
+ ...(0, $c5HcZ$reactariautils.mergeProps)(collectionProps, tabListLabelProps),
59
+ role: 'tablist',
60
+ 'aria-orientation': orientation,
61
+ tabIndex: undefined
62
+ }
63
+ };
64
+ }
65
+
66
+
67
+ //# sourceMappingURL=useTabList.main.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,8BAAQ;IAC1B,IAAI,WAAW,CAAA,GAAA,oBAAM,EAAE,IAAM,IAAI,CAAA,GAAA,8CAAmB,EAClD,YACA,WACA,aACA,eAAe;QAAC;QAAY;QAAc;QAAa;KAAU;IAEnE,IAAI,mBAAC,eAAe,EAAC,GAAG,CAAA,GAAA,iDAAsB,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,2BAAI;IACjB,CAAA,GAAA,iCAAM,EAAE,GAAG,CAAC,OAAO;IAEnB,IAAI,oBAAoB,CAAA,GAAA,+BAAQ,EAAE;QAAC,GAAG,KAAK;QAAE,IAAI;IAAM;IAEvD,OAAO;QACL,cAAc;YACZ,GAAG,CAAA,GAAA,gCAAS,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.main.js.map"}