@react-aria/tabs 3.8.6-nightly.4552 → 3.8.6-nightly.4558
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 +68 -0
- package/dist/TabsKeyboardDelegate.main.js.map +1 -0
- package/dist/TabsKeyboardDelegate.mjs +63 -0
- package/dist/TabsKeyboardDelegate.module.js +63 -0
- package/dist/TabsKeyboardDelegate.module.js.map +1 -0
- package/dist/import.mjs +3 -219
- package/dist/main.js +6 -222
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -219
- package/dist/module.js.map +1 -1
- package/dist/useTab.main.js +62 -0
- package/dist/useTab.main.js.map +1 -0
- package/dist/useTab.mjs +57 -0
- package/dist/useTab.module.js +57 -0
- package/dist/useTab.module.js.map +1 -0
- package/dist/useTabList.main.js +67 -0
- package/dist/useTabList.main.js.map +1 -0
- package/dist/useTabList.mjs +62 -0
- package/dist/useTabList.module.js +62 -0
- package/dist/useTabList.module.js.map +1 -0
- package/dist/useTabPanel.main.js +47 -0
- package/dist/useTabPanel.main.js.map +1 -0
- package/dist/useTabPanel.mjs +42 -0
- package/dist/useTabPanel.module.js +42 -0
- package/dist/useTabPanel.module.js.map +1 -0
- package/dist/utils.main.js +26 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +20 -0
- package/dist/utils.module.js +20 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +9 -9
package/dist/main.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $1cJu1$react = require("react");
|
|
5
|
-
var $1cJu1$reactariai18n = require("@react-aria/i18n");
|
|
1
|
+
var $4eeea1c984cc0628$exports = require("./useTab.main.js");
|
|
2
|
+
var $8db1928b18472a1f$exports = require("./useTabPanel.main.js");
|
|
3
|
+
var $f2b4a4926440e901$exports = require("./useTabList.main.js");
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
function $parcel$export(e, n, v, s) {
|
|
9
7
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
$parcel$export(module.exports, "useTab", () => $4eeea1c984cc0628$
|
|
13
|
-
$parcel$export(module.exports, "useTabPanel", () => $8db1928b18472a1f$
|
|
14
|
-
$parcel$export(module.exports, "useTabList", () => $f2b4a4926440e901$
|
|
10
|
+
$parcel$export(module.exports, "useTab", () => $4eeea1c984cc0628$exports.useTab);
|
|
11
|
+
$parcel$export(module.exports, "useTabPanel", () => $8db1928b18472a1f$exports.useTabPanel);
|
|
12
|
+
$parcel$export(module.exports, "useTabList", () => $f2b4a4926440e901$exports.useTabList);
|
|
15
13
|
/*
|
|
16
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
17
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
19
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
*
|
|
21
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
22
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
23
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
24
|
-
* governing permissions and limitations under the License.
|
|
25
|
-
*/ /*
|
|
26
14
|
* Copyright 2020 Adobe. All rights reserved.
|
|
27
15
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
28
16
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -33,210 +21,6 @@ $parcel$export(module.exports, "useTabList", () => $f2b4a4926440e901$export$773e
|
|
|
33
21
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
34
22
|
* governing permissions and limitations under the License.
|
|
35
23
|
*/
|
|
36
|
-
/*
|
|
37
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
38
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
39
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
40
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
41
|
-
*
|
|
42
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
43
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
44
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
45
|
-
* governing permissions and limitations under the License.
|
|
46
|
-
*/ const $a217ebca77471970$export$c5f62239608282b6 = new WeakMap();
|
|
47
|
-
function $a217ebca77471970$export$567fc7097e064344(state, key, role) {
|
|
48
|
-
if (typeof key === "string") key = key.replace(/\s+/g, "");
|
|
49
|
-
let baseId = $a217ebca77471970$export$c5f62239608282b6.get(state);
|
|
50
|
-
return `${baseId}-${role}-${key}`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
function $4eeea1c984cc0628$export$fdf4756d5b8ef90a(props, state, ref) {
|
|
56
|
-
let { key: key, isDisabled: propsDisabled, shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
|
|
57
|
-
let { selectionManager: manager, selectedKey: selectedKey } = state;
|
|
58
|
-
let isSelected = key === selectedKey;
|
|
59
|
-
let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);
|
|
60
|
-
let { itemProps: itemProps, isPressed: isPressed } = (0, $1cJu1$reactariaselection.useSelectableItem)({
|
|
61
|
-
selectionManager: manager,
|
|
62
|
-
key: key,
|
|
63
|
-
ref: ref,
|
|
64
|
-
isDisabled: isDisabled,
|
|
65
|
-
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
66
|
-
linkBehavior: "selection"
|
|
67
|
-
});
|
|
68
|
-
let tabId = (0, $a217ebca77471970$export$567fc7097e064344)(state, key, "tab");
|
|
69
|
-
let tabPanelId = (0, $a217ebca77471970$export$567fc7097e064344)(state, key, "tabpanel");
|
|
70
|
-
let { tabIndex: tabIndex } = itemProps;
|
|
71
|
-
let item = state.collection.getItem(key);
|
|
72
|
-
let domProps = (0, $1cJu1$reactariautils.filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
|
|
73
|
-
labelable: true
|
|
74
|
-
});
|
|
75
|
-
delete domProps.id;
|
|
76
|
-
let linkProps = (0, $1cJu1$reactariautils.useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
77
|
-
return {
|
|
78
|
-
tabProps: (0, $1cJu1$reactariautils.mergeProps)(domProps, linkProps, itemProps, {
|
|
79
|
-
id: tabId,
|
|
80
|
-
"aria-selected": isSelected,
|
|
81
|
-
"aria-disabled": isDisabled || undefined,
|
|
82
|
-
"aria-controls": isSelected ? tabPanelId : undefined,
|
|
83
|
-
tabIndex: isDisabled ? undefined : tabIndex,
|
|
84
|
-
role: "tab"
|
|
85
|
-
}),
|
|
86
|
-
isSelected: isSelected,
|
|
87
|
-
isDisabled: isDisabled,
|
|
88
|
-
isPressed: isPressed
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/*
|
|
94
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
95
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
96
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
97
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
98
|
-
*
|
|
99
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
100
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
101
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
102
|
-
* governing permissions and limitations under the License.
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
function $8db1928b18472a1f$export$fae0121b5afe572d(props, state, ref) {
|
|
107
|
-
// The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
|
|
108
|
-
// Otherwise, tabbing from the focused tab should go directly to the first tabbable element
|
|
109
|
-
// within the tabpanel.
|
|
110
|
-
let tabIndex = (0, $1cJu1$reactariafocus.useHasTabbableChild)(ref) ? undefined : 0;
|
|
111
|
-
var _props_id;
|
|
112
|
-
const id = (0, $a217ebca77471970$export$567fc7097e064344)(state, (_props_id = props.id) !== null && _props_id !== void 0 ? _props_id : state === null || state === void 0 ? void 0 : state.selectedKey, "tabpanel");
|
|
113
|
-
const tabPanelProps = (0, $1cJu1$reactariautils.useLabels)({
|
|
114
|
-
...props,
|
|
115
|
-
id: id,
|
|
116
|
-
"aria-labelledby": (0, $a217ebca77471970$export$567fc7097e064344)(state, state === null || state === void 0 ? void 0 : state.selectedKey, "tab")
|
|
117
|
-
});
|
|
118
|
-
return {
|
|
119
|
-
tabPanelProps: (0, $1cJu1$reactariautils.mergeProps)(tabPanelProps, {
|
|
120
|
-
tabIndex: tabIndex,
|
|
121
|
-
role: "tabpanel",
|
|
122
|
-
"aria-describedby": props["aria-describedby"],
|
|
123
|
-
"aria-details": props["aria-details"]
|
|
124
|
-
})
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/*
|
|
130
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
131
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
132
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
133
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
134
|
-
*
|
|
135
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
136
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
137
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
138
|
-
* governing permissions and limitations under the License.
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/*
|
|
143
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
144
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
145
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
146
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
147
|
-
*
|
|
148
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
149
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
150
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
151
|
-
* governing permissions and limitations under the License.
|
|
152
|
-
*/ class $283e5d8830177ead$export$15010ca3c1abe90b {
|
|
153
|
-
getKeyLeftOf(key) {
|
|
154
|
-
if (this.flipDirection) return this.getNextKey(key);
|
|
155
|
-
return this.getPreviousKey(key);
|
|
156
|
-
}
|
|
157
|
-
getKeyRightOf(key) {
|
|
158
|
-
if (this.flipDirection) return this.getPreviousKey(key);
|
|
159
|
-
return this.getNextKey(key);
|
|
160
|
-
}
|
|
161
|
-
getKeyAbove(key) {
|
|
162
|
-
return this.getPreviousKey(key);
|
|
163
|
-
}
|
|
164
|
-
getKeyBelow(key) {
|
|
165
|
-
return this.getNextKey(key);
|
|
166
|
-
}
|
|
167
|
-
isDisabled(key) {
|
|
168
|
-
var _this_collection_getItem_props, _this_collection_getItem;
|
|
169
|
-
return this.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled);
|
|
170
|
-
}
|
|
171
|
-
getFirstKey() {
|
|
172
|
-
let key = this.collection.getFirstKey();
|
|
173
|
-
if (key != null && this.isDisabled(key)) key = this.getNextKey(key);
|
|
174
|
-
return key;
|
|
175
|
-
}
|
|
176
|
-
getLastKey() {
|
|
177
|
-
let key = this.collection.getLastKey();
|
|
178
|
-
if (key != null && this.isDisabled(key)) key = this.getPreviousKey(key);
|
|
179
|
-
return key;
|
|
180
|
-
}
|
|
181
|
-
getNextKey(key) {
|
|
182
|
-
do {
|
|
183
|
-
key = this.collection.getKeyAfter(key);
|
|
184
|
-
if (key == null) key = this.collection.getFirstKey();
|
|
185
|
-
}while (this.isDisabled(key));
|
|
186
|
-
return key;
|
|
187
|
-
}
|
|
188
|
-
getPreviousKey(key) {
|
|
189
|
-
do {
|
|
190
|
-
key = this.collection.getKeyBefore(key);
|
|
191
|
-
if (key == null) key = this.collection.getLastKey();
|
|
192
|
-
}while (this.isDisabled(key));
|
|
193
|
-
return key;
|
|
194
|
-
}
|
|
195
|
-
constructor(collection, direction, orientation, disabledKeys = new Set()){
|
|
196
|
-
this.collection = collection;
|
|
197
|
-
this.flipDirection = direction === "rtl" && orientation === "horizontal";
|
|
198
|
-
this.disabledKeys = disabledKeys;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
function $f2b4a4926440e901$export$773e389e644c5874(props, state, ref) {
|
|
206
|
-
let { orientation: orientation = "horizontal", keyboardActivation: keyboardActivation = "automatic" } = props;
|
|
207
|
-
let { collection: collection, selectionManager: manager, disabledKeys: disabledKeys } = state;
|
|
208
|
-
let { direction: direction } = (0, $1cJu1$reactariai18n.useLocale)();
|
|
209
|
-
let delegate = (0, $1cJu1$react.useMemo)(()=>new (0, $283e5d8830177ead$export$15010ca3c1abe90b)(collection, direction, orientation, disabledKeys), [
|
|
210
|
-
collection,
|
|
211
|
-
disabledKeys,
|
|
212
|
-
orientation,
|
|
213
|
-
direction
|
|
214
|
-
]);
|
|
215
|
-
let { collectionProps: collectionProps } = (0, $1cJu1$reactariaselection.useSelectableCollection)({
|
|
216
|
-
ref: ref,
|
|
217
|
-
selectionManager: manager,
|
|
218
|
-
keyboardDelegate: delegate,
|
|
219
|
-
selectOnFocus: keyboardActivation === "automatic",
|
|
220
|
-
disallowEmptySelection: true,
|
|
221
|
-
scrollRef: ref,
|
|
222
|
-
linkBehavior: "selection"
|
|
223
|
-
});
|
|
224
|
-
// Compute base id for all tabs
|
|
225
|
-
let tabsId = (0, $1cJu1$reactariautils.useId)();
|
|
226
|
-
(0, $a217ebca77471970$export$c5f62239608282b6).set(state, tabsId);
|
|
227
|
-
let tabListLabelProps = (0, $1cJu1$reactariautils.useLabels)({
|
|
228
|
-
...props,
|
|
229
|
-
id: tabsId
|
|
230
|
-
});
|
|
231
|
-
return {
|
|
232
|
-
tabListProps: {
|
|
233
|
-
...(0, $1cJu1$reactariautils.mergeProps)(collectionProps, tabListLabelProps),
|
|
234
|
-
role: "tablist",
|
|
235
|
-
"aria-orientation": orientation,
|
|
236
|
-
tabIndex: undefined
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
24
|
|
|
241
25
|
|
|
242
26
|
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;ACVD;;;;;;;;;;CAUC,GAKM,MAAM,4CAAU,IAAI;AAEpB,SAAS,0CAAc,KAAsB,EAAE,GAAQ,EAAE,IAAY;IAC1E,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;;;;ADWO,SAAS,0CACd,KAAmB,EACnB,KAAsB,EACtB,GAAgC;IAEhC,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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CAAS,EAAE,iBAAiB,kBAAkB;YACjD,MAAM;YACN,oBAAoB;YACpB,UAAU;QACZ;IACF;AACF;;","sources":["packages/@react-aria/tabs/src/index.ts","packages/@react-aria/tabs/src/useTab.ts","packages/@react-aria/tabs/src/utils.ts","packages/@react-aria/tabs/src/useTabPanel.ts","packages/@react-aria/tabs/src/useTabList.ts","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 */\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","/*\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} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLinkProps} from '@react-aria/utils';\nimport {generateId} from './utils';\nimport {RefObject} from 'react';\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>\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","/*\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>, 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\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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {DOMAttributes} from '@react-types/shared';\nimport {generateId} from './utils';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {RefObject} from 'react';\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>, ref: RefObject<Element>): 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","/*\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} from '@react-types/shared';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {RefObject, useMemo} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {tabsIds} from './utils';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {useLocale} from '@react-aria/i18n';\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>): 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","/*\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\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 }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n }\n return this.getPreviousKey(key);\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n }\n return this.getNextKey(key);\n }\n\n getKeyAbove(key: Key) {\n return this.getPreviousKey(key);\n }\n\n getKeyBelow(key: Key) {\n return this.getNextKey(key);\n }\n\n private isDisabled(key: Key) {\n return this.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/tabs/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useTab} from './useTab';\nexport {useTabPanel} from './useTabPanel';\nexport {useTabList} from './useTabList';\nexport type {AriaTabListProps, AriaTabPanelProps, AriaTabProps} from '@react-types/tabs';\nexport type {Orientation} from '@react-types/shared';\nexport type {TabAria} from './useTab';\nexport type {TabPanelAria} from './useTabPanel';\nexport type {AriaTabListOptions, TabListAria} from './useTabList';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,86 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {useMemo as $8kq0t$useMemo} from "react";
|
|
5
|
-
import {useLocale as $8kq0t$useLocale} from "@react-aria/i18n";
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
-
* governing permissions and limitations under the License.
|
|
17
|
-
*/ /*
|
|
18
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
-
*
|
|
23
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
-
* governing permissions and limitations under the License.
|
|
27
|
-
*/
|
|
28
|
-
/*
|
|
29
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
30
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
-
*
|
|
34
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
-
* governing permissions and limitations under the License.
|
|
38
|
-
*/ const $99b62ae3ff97ec45$export$c5f62239608282b6 = new WeakMap();
|
|
39
|
-
function $99b62ae3ff97ec45$export$567fc7097e064344(state, key, role) {
|
|
40
|
-
if (typeof key === "string") key = key.replace(/\s+/g, "");
|
|
41
|
-
let baseId = $99b62ae3ff97ec45$export$c5f62239608282b6.get(state);
|
|
42
|
-
return `${baseId}-${role}-${key}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function $0175d55c2a017ebc$export$fdf4756d5b8ef90a(props, state, ref) {
|
|
48
|
-
let { key: key, isDisabled: propsDisabled, shouldSelectOnPressUp: shouldSelectOnPressUp } = props;
|
|
49
|
-
let { selectionManager: manager, selectedKey: selectedKey } = state;
|
|
50
|
-
let isSelected = key === selectedKey;
|
|
51
|
-
let isDisabled = propsDisabled || state.isDisabled || state.selectionManager.isDisabled(key);
|
|
52
|
-
let { itemProps: itemProps, isPressed: isPressed } = (0, $8kq0t$useSelectableItem)({
|
|
53
|
-
selectionManager: manager,
|
|
54
|
-
key: key,
|
|
55
|
-
ref: ref,
|
|
56
|
-
isDisabled: isDisabled,
|
|
57
|
-
shouldSelectOnPressUp: shouldSelectOnPressUp,
|
|
58
|
-
linkBehavior: "selection"
|
|
59
|
-
});
|
|
60
|
-
let tabId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, "tab");
|
|
61
|
-
let tabPanelId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, "tabpanel");
|
|
62
|
-
let { tabIndex: tabIndex } = itemProps;
|
|
63
|
-
let item = state.collection.getItem(key);
|
|
64
|
-
let domProps = (0, $8kq0t$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props, {
|
|
65
|
-
labelable: true
|
|
66
|
-
});
|
|
67
|
-
delete domProps.id;
|
|
68
|
-
let linkProps = (0, $8kq0t$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
69
|
-
return {
|
|
70
|
-
tabProps: (0, $8kq0t$mergeProps)(domProps, linkProps, itemProps, {
|
|
71
|
-
id: tabId,
|
|
72
|
-
"aria-selected": isSelected,
|
|
73
|
-
"aria-disabled": isDisabled || undefined,
|
|
74
|
-
"aria-controls": isSelected ? tabPanelId : undefined,
|
|
75
|
-
tabIndex: isDisabled ? undefined : tabIndex,
|
|
76
|
-
role: "tab"
|
|
77
|
-
}),
|
|
78
|
-
isSelected: isSelected,
|
|
79
|
-
isDisabled: isDisabled,
|
|
80
|
-
isPressed: isPressed
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
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";
|
|
84
4
|
|
|
85
5
|
/*
|
|
86
6
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -95,142 +15,6 @@ function $0175d55c2a017ebc$export$fdf4756d5b8ef90a(props, state, ref) {
|
|
|
95
15
|
*/
|
|
96
16
|
|
|
97
17
|
|
|
98
|
-
function $34bce698202e07cb$export$fae0121b5afe572d(props, state, ref) {
|
|
99
|
-
// The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
|
|
100
|
-
// Otherwise, tabbing from the focused tab should go directly to the first tabbable element
|
|
101
|
-
// within the tabpanel.
|
|
102
|
-
let tabIndex = (0, $8kq0t$useHasTabbableChild)(ref) ? undefined : 0;
|
|
103
|
-
var _props_id;
|
|
104
|
-
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");
|
|
105
|
-
const tabPanelProps = (0, $8kq0t$useLabels)({
|
|
106
|
-
...props,
|
|
107
|
-
id: id,
|
|
108
|
-
"aria-labelledby": (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, state === null || state === void 0 ? void 0 : state.selectedKey, "tab")
|
|
109
|
-
});
|
|
110
|
-
return {
|
|
111
|
-
tabPanelProps: (0, $8kq0t$mergeProps)(tabPanelProps, {
|
|
112
|
-
tabIndex: tabIndex,
|
|
113
|
-
role: "tabpanel",
|
|
114
|
-
"aria-describedby": props["aria-describedby"],
|
|
115
|
-
"aria-details": props["aria-details"]
|
|
116
|
-
})
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/*
|
|
122
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
123
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
124
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
125
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
126
|
-
*
|
|
127
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
128
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
129
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
130
|
-
* governing permissions and limitations under the License.
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/*
|
|
135
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
136
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
137
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
138
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
139
|
-
*
|
|
140
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
141
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
142
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
143
|
-
* governing permissions and limitations under the License.
|
|
144
|
-
*/ class $bfc6f2d60b8a4c40$export$15010ca3c1abe90b {
|
|
145
|
-
getKeyLeftOf(key) {
|
|
146
|
-
if (this.flipDirection) return this.getNextKey(key);
|
|
147
|
-
return this.getPreviousKey(key);
|
|
148
|
-
}
|
|
149
|
-
getKeyRightOf(key) {
|
|
150
|
-
if (this.flipDirection) return this.getPreviousKey(key);
|
|
151
|
-
return this.getNextKey(key);
|
|
152
|
-
}
|
|
153
|
-
getKeyAbove(key) {
|
|
154
|
-
return this.getPreviousKey(key);
|
|
155
|
-
}
|
|
156
|
-
getKeyBelow(key) {
|
|
157
|
-
return this.getNextKey(key);
|
|
158
|
-
}
|
|
159
|
-
isDisabled(key) {
|
|
160
|
-
var _this_collection_getItem_props, _this_collection_getItem;
|
|
161
|
-
return this.disabledKeys.has(key) || !!((_this_collection_getItem = this.collection.getItem(key)) === null || _this_collection_getItem === void 0 ? void 0 : (_this_collection_getItem_props = _this_collection_getItem.props) === null || _this_collection_getItem_props === void 0 ? void 0 : _this_collection_getItem_props.isDisabled);
|
|
162
|
-
}
|
|
163
|
-
getFirstKey() {
|
|
164
|
-
let key = this.collection.getFirstKey();
|
|
165
|
-
if (key != null && this.isDisabled(key)) key = this.getNextKey(key);
|
|
166
|
-
return key;
|
|
167
|
-
}
|
|
168
|
-
getLastKey() {
|
|
169
|
-
let key = this.collection.getLastKey();
|
|
170
|
-
if (key != null && this.isDisabled(key)) key = this.getPreviousKey(key);
|
|
171
|
-
return key;
|
|
172
|
-
}
|
|
173
|
-
getNextKey(key) {
|
|
174
|
-
do {
|
|
175
|
-
key = this.collection.getKeyAfter(key);
|
|
176
|
-
if (key == null) key = this.collection.getFirstKey();
|
|
177
|
-
}while (this.isDisabled(key));
|
|
178
|
-
return key;
|
|
179
|
-
}
|
|
180
|
-
getPreviousKey(key) {
|
|
181
|
-
do {
|
|
182
|
-
key = this.collection.getKeyBefore(key);
|
|
183
|
-
if (key == null) key = this.collection.getLastKey();
|
|
184
|
-
}while (this.isDisabled(key));
|
|
185
|
-
return key;
|
|
186
|
-
}
|
|
187
|
-
constructor(collection, direction, orientation, disabledKeys = new Set()){
|
|
188
|
-
this.collection = collection;
|
|
189
|
-
this.flipDirection = direction === "rtl" && orientation === "horizontal";
|
|
190
|
-
this.disabledKeys = disabledKeys;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
function $58d314389b21fa3f$export$773e389e644c5874(props, state, ref) {
|
|
198
|
-
let { orientation: orientation = "horizontal", keyboardActivation: keyboardActivation = "automatic" } = props;
|
|
199
|
-
let { collection: collection, selectionManager: manager, disabledKeys: disabledKeys } = state;
|
|
200
|
-
let { direction: direction } = (0, $8kq0t$useLocale)();
|
|
201
|
-
let delegate = (0, $8kq0t$useMemo)(()=>new (0, $bfc6f2d60b8a4c40$export$15010ca3c1abe90b)(collection, direction, orientation, disabledKeys), [
|
|
202
|
-
collection,
|
|
203
|
-
disabledKeys,
|
|
204
|
-
orientation,
|
|
205
|
-
direction
|
|
206
|
-
]);
|
|
207
|
-
let { collectionProps: collectionProps } = (0, $8kq0t$useSelectableCollection)({
|
|
208
|
-
ref: ref,
|
|
209
|
-
selectionManager: manager,
|
|
210
|
-
keyboardDelegate: delegate,
|
|
211
|
-
selectOnFocus: keyboardActivation === "automatic",
|
|
212
|
-
disallowEmptySelection: true,
|
|
213
|
-
scrollRef: ref,
|
|
214
|
-
linkBehavior: "selection"
|
|
215
|
-
});
|
|
216
|
-
// Compute base id for all tabs
|
|
217
|
-
let tabsId = (0, $8kq0t$useId)();
|
|
218
|
-
(0, $99b62ae3ff97ec45$export$c5f62239608282b6).set(state, tabsId);
|
|
219
|
-
let tabListLabelProps = (0, $8kq0t$useLabels)({
|
|
220
|
-
...props,
|
|
221
|
-
id: tabsId
|
|
222
|
-
});
|
|
223
|
-
return {
|
|
224
|
-
tabListProps: {
|
|
225
|
-
...(0, $8kq0t$mergeProps)(collectionProps, tabListLabelProps),
|
|
226
|
-
role: "tablist",
|
|
227
|
-
"aria-orientation": orientation,
|
|
228
|
-
tabIndex: undefined
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
18
|
|
|
235
19
|
|
|
236
20
|
export {$0175d55c2a017ebc$export$fdf4756d5b8ef90a as useTab, $34bce698202e07cb$export$fae0121b5afe572d as useTabPanel, $58d314389b21fa3f$export$773e389e644c5874 as useTabList};
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1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C7G,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/index.ts","packages/@react-aria/tabs/src/useTab.ts","packages/@react-aria/tabs/src/utils.ts","packages/@react-aria/tabs/src/useTabPanel.ts","packages/@react-aria/tabs/src/useTabList.ts","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 */\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","/*\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} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLinkProps} from '@react-aria/utils';\nimport {generateId} from './utils';\nimport {RefObject} from 'react';\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>\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","/*\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>, 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\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 {AriaTabPanelProps} from '@react-types/tabs';\nimport {DOMAttributes} from '@react-types/shared';\nimport {generateId} from './utils';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {RefObject} from 'react';\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>, ref: RefObject<Element>): 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","/*\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} from '@react-types/shared';\nimport {mergeProps, useId, useLabels} from '@react-aria/utils';\nimport {RefObject, useMemo} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {tabsIds} from './utils';\nimport {TabsKeyboardDelegate} from './TabsKeyboardDelegate';\nimport {useLocale} from '@react-aria/i18n';\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>): 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","/*\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\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 }\n\n getKeyLeftOf(key: Key) {\n if (this.flipDirection) {\n return this.getNextKey(key);\n }\n return this.getPreviousKey(key);\n }\n\n getKeyRightOf(key: Key) {\n if (this.flipDirection) {\n return this.getPreviousKey(key);\n }\n return this.getNextKey(key);\n }\n\n getKeyAbove(key: Key) {\n return this.getPreviousKey(key);\n }\n\n getKeyBelow(key: Key) {\n return this.getNextKey(key);\n }\n\n private isDisabled(key: Key) {\n return this.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled;\n }\n\n getFirstKey() {\n let key = this.collection.getFirstKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getNextKey(key);\n }\n return key;\n }\n\n getLastKey() {\n let key = this.collection.getLastKey();\n if (key != null && this.isDisabled(key)) {\n key = this.getPreviousKey(key);\n }\n return key;\n }\n\n getNextKey(key) {\n do {\n key = this.collection.getKeyAfter(key);\n if (key == null) {\n key = this.collection.getFirstKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n\n getPreviousKey(key) {\n do {\n key = this.collection.getKeyBefore(key);\n if (key == null) {\n key = this.collection.getLastKey();\n }\n } while (this.isDisabled(key));\n return key;\n }\n}\n"],"names":[],"version":3,"file":"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"}
|
|
@@ -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;;;AAyBM,SAAS,0CACd,KAAmB,EACnB,KAAsB,EACtB,GAAgC;IAEhC,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} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLinkProps} from '@react-aria/utils';\nimport {generateId} from './utils';\nimport {RefObject} from 'react';\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>\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"}
|