@react-aria/tabs 3.1.1-nightly.3036 → 3.1.1-nightly.3047
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/main.js +197 -260
- package/dist/main.js.map +1 -1
- package/dist/module.js +184 -235
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/main.js
CHANGED
|
@@ -1,292 +1,229 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var $hxncP$reactariaselection = require("@react-aria/selection");
|
|
2
|
+
var $hxncP$reactariafocus = require("@react-aria/focus");
|
|
3
|
+
var $hxncP$react = require("react");
|
|
4
|
+
var $hxncP$reactariautils = require("@react-aria/utils");
|
|
5
|
+
var $hxncP$reactariai18n = require("@react-aria/i18n");
|
|
6
|
+
|
|
7
|
+
function $parcel$exportWildcard(dest, source) {
|
|
8
|
+
Object.keys(source).forEach(function(key) {
|
|
9
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
13
|
+
Object.defineProperty(dest, key, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return source[key];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
return dest;
|
|
22
|
+
}
|
|
23
|
+
function $parcel$export(e, n, v, s) {
|
|
24
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
25
|
+
}
|
|
26
|
+
var $bca6ccd6c0f0d1c7$exports = {};
|
|
27
|
+
|
|
28
|
+
$parcel$export($bca6ccd6c0f0d1c7$exports, "useTab", () => $bca6ccd6c0f0d1c7$export$fdf4756d5b8ef90a);
|
|
29
|
+
const $e8ba102c56610ecd$export$c5f62239608282b6 = new WeakMap();
|
|
30
|
+
function $e8ba102c56610ecd$export$567fc7097e064344(state, key, role) {
|
|
31
|
+
if (typeof key === 'string') key = key.replace(/\s+/g, '');
|
|
32
|
+
let baseId = $e8ba102c56610ecd$export$c5f62239608282b6.get(state);
|
|
33
|
+
return `${baseId}-${role}-${key}`;
|
|
34
|
+
}
|
|
20
35
|
|
|
21
|
-
var {
|
|
22
|
-
useSelectableItem,
|
|
23
|
-
useSelectableCollection
|
|
24
|
-
} = require("@react-aria/selection");
|
|
25
36
|
|
|
26
|
-
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
27
37
|
|
|
28
|
-
function $
|
|
29
|
-
|
|
38
|
+
function $bca6ccd6c0f0d1c7$export$fdf4756d5b8ef90a(props, state, ref) {
|
|
39
|
+
let { key: key , isDisabled: propsDisabled } = props;
|
|
40
|
+
let { selectionManager: manager , selectedKey: selectedKey } = state;
|
|
41
|
+
let isSelected = key === selectedKey;
|
|
42
|
+
let isDisabled = propsDisabled || state.disabledKeys.has(key);
|
|
43
|
+
let { itemProps: itemProps } = $hxncP$reactariaselection.useSelectableItem({
|
|
44
|
+
selectionManager: manager,
|
|
45
|
+
key: key,
|
|
46
|
+
ref: ref,
|
|
47
|
+
isDisabled: isDisabled
|
|
48
|
+
});
|
|
49
|
+
let tabId = $e8ba102c56610ecd$export$567fc7097e064344(state, key, 'tab');
|
|
50
|
+
let tabPanelId = $e8ba102c56610ecd$export$567fc7097e064344(state, key, 'tabpanel');
|
|
51
|
+
let { tabIndex: tabIndex } = itemProps;
|
|
52
|
+
return {
|
|
53
|
+
tabProps: {
|
|
54
|
+
...itemProps,
|
|
55
|
+
id: tabId,
|
|
56
|
+
'aria-selected': isSelected,
|
|
57
|
+
'aria-disabled': isDisabled || undefined,
|
|
58
|
+
'aria-controls': isSelected ? tabPanelId : undefined,
|
|
59
|
+
tabIndex: isDisabled ? undefined : tabIndex,
|
|
60
|
+
role: 'tab'
|
|
61
|
+
}
|
|
62
|
+
};
|
|
30
63
|
}
|
|
31
64
|
|
|
32
|
-
/*
|
|
33
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
34
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
35
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
36
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
37
|
-
*
|
|
38
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
39
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
40
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
41
|
-
* governing permissions and limitations under the License.
|
|
42
|
-
*/
|
|
43
|
-
const $c685c043bb86d16b2fcf2a65974f3$export$tabsIds = new WeakMap();
|
|
44
|
-
|
|
45
|
-
function $c685c043bb86d16b2fcf2a65974f3$export$generateId(state, key, role) {
|
|
46
|
-
if (typeof key === 'string') {
|
|
47
|
-
key = key.replace(/\s+/g, '');
|
|
48
|
-
}
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
var $83205e167d36c1bd$exports = {};
|
|
67
|
+
|
|
68
|
+
$parcel$export($83205e167d36c1bd$exports, "useTabPanel", () => $83205e167d36c1bd$export$fae0121b5afe572d);
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function $83205e167d36c1bd$export$fae0121b5afe572d(props, state, ref) {
|
|
74
|
+
let [tabIndex, setTabIndex] = $hxncP$react.useState(0);
|
|
75
|
+
// The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
|
|
76
|
+
// Otherwise, tabbing from the focused tab should go directly to the first tabbable element
|
|
77
|
+
// within the tabpanel.
|
|
78
|
+
$hxncP$react.useLayoutEffect(()=>{
|
|
79
|
+
if (ref?.current) {
|
|
80
|
+
let update = ()=>{
|
|
81
|
+
// Detect if there are any tabbable elements and update the tabIndex accordingly.
|
|
82
|
+
let walker = $hxncP$reactariafocus.getFocusableTreeWalker(ref.current, {
|
|
83
|
+
tabbable: true
|
|
84
|
+
});
|
|
85
|
+
setTabIndex(walker.nextNode() ? undefined : 0);
|
|
86
|
+
};
|
|
87
|
+
update();
|
|
88
|
+
// Update when new elements are inserted, or the tabIndex/disabled attribute updates.
|
|
89
|
+
let observer = new MutationObserver(update);
|
|
90
|
+
observer.observe(ref.current, {
|
|
91
|
+
subtree: true,
|
|
92
|
+
childList: true,
|
|
93
|
+
attributes: true,
|
|
94
|
+
attributeFilter: [
|
|
95
|
+
'tabIndex',
|
|
96
|
+
'disabled'
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
return ()=>{
|
|
100
|
+
observer.disconnect();
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}, [
|
|
104
|
+
ref
|
|
105
|
+
]);
|
|
106
|
+
const id = $e8ba102c56610ecd$export$567fc7097e064344(state, state?.selectedKey, 'tabpanel');
|
|
107
|
+
const tabPanelProps = $hxncP$reactariautils.useLabels({
|
|
108
|
+
...props,
|
|
109
|
+
id: id,
|
|
110
|
+
'aria-labelledby': $e8ba102c56610ecd$export$567fc7097e064344(state, state?.selectedKey, 'tab')
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
tabPanelProps: $hxncP$reactariautils.mergeProps(tabPanelProps, {
|
|
114
|
+
tabIndex: tabIndex,
|
|
115
|
+
role: 'tabpanel',
|
|
116
|
+
'aria-describedby': props['aria-describedby'],
|
|
117
|
+
'aria-details': props['aria-details']
|
|
118
|
+
})
|
|
119
|
+
};
|
|
52
120
|
}
|
|
53
121
|
|
|
54
|
-
/**
|
|
55
|
-
* Provides the behavior and accessibility implementation for a tab.
|
|
56
|
-
* When selected, the associated tab panel is shown.
|
|
57
|
-
*/
|
|
58
|
-
function useTab(props, state, ref) {
|
|
59
|
-
let {
|
|
60
|
-
key,
|
|
61
|
-
isDisabled: propsDisabled
|
|
62
|
-
} = props;
|
|
63
|
-
let {
|
|
64
|
-
selectionManager: manager,
|
|
65
|
-
selectedKey
|
|
66
|
-
} = state;
|
|
67
|
-
let isSelected = key === selectedKey;
|
|
68
|
-
let isDisabled = propsDisabled || state.disabledKeys.has(key);
|
|
69
|
-
let {
|
|
70
|
-
itemProps
|
|
71
|
-
} = useSelectableItem({
|
|
72
|
-
selectionManager: manager,
|
|
73
|
-
key,
|
|
74
|
-
ref,
|
|
75
|
-
isDisabled
|
|
76
|
-
});
|
|
77
|
-
let tabId = $c685c043bb86d16b2fcf2a65974f3$export$generateId(state, key, 'tab');
|
|
78
|
-
let tabPanelId = $c685c043bb86d16b2fcf2a65974f3$export$generateId(state, key, 'tabpanel');
|
|
79
|
-
let {
|
|
80
|
-
tabIndex
|
|
81
|
-
} = itemProps;
|
|
82
|
-
return {
|
|
83
|
-
tabProps: _babelRuntimeHelpersExtends({}, itemProps, {
|
|
84
|
-
id: tabId,
|
|
85
|
-
'aria-selected': isSelected,
|
|
86
|
-
'aria-disabled': isDisabled || undefined,
|
|
87
|
-
'aria-controls': isSelected ? tabPanelId : undefined,
|
|
88
|
-
tabIndex: isDisabled ? undefined : tabIndex,
|
|
89
|
-
role: 'tab'
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
122
|
|
|
94
|
-
exports
|
|
123
|
+
var $082250f9aef6d971$exports = {};
|
|
95
124
|
|
|
96
|
-
|
|
97
|
-
* Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for
|
|
98
|
-
* the contents of a tab, and is shown when the tab is selected.
|
|
99
|
-
*/
|
|
100
|
-
function useTabPanel(props, state, ref) {
|
|
101
|
-
let [tabIndex, setTabIndex] = useState(0); // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
|
|
102
|
-
// Otherwise, tabbing from the focused tab should go directly to the first tabbable element
|
|
103
|
-
// within the tabpanel.
|
|
125
|
+
$parcel$export($082250f9aef6d971$exports, "useTabList", () => $082250f9aef6d971$export$773e389e644c5874);
|
|
104
126
|
|
|
105
|
-
useLayoutEffect(() => {
|
|
106
|
-
if (ref != null && ref.current) {
|
|
107
|
-
let update = () => {
|
|
108
|
-
// Detect if there are any tabbable elements and update the tabIndex accordingly.
|
|
109
|
-
let walker = getFocusableTreeWalker(ref.current, {
|
|
110
|
-
tabbable: true
|
|
111
|
-
});
|
|
112
|
-
setTabIndex(walker.nextNode() ? undefined : 0);
|
|
113
|
-
};
|
|
114
127
|
|
|
115
|
-
update(); // Update when new elements are inserted, or the tabIndex/disabled attribute updates.
|
|
116
128
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
return () => {
|
|
125
|
-
observer.disconnect();
|
|
126
|
-
};
|
|
129
|
+
class $d4e272ab55181b4b$export$15010ca3c1abe90b {
|
|
130
|
+
constructor(collection, direction, orientation, disabledKeys = new Set()){
|
|
131
|
+
this.collection = collection;
|
|
132
|
+
this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
133
|
+
this.orientation = orientation;
|
|
134
|
+
this.disabledKeys = disabledKeys;
|
|
127
135
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
tabPanelProps: mergeProps(tabPanelProps, {
|
|
136
|
-
tabIndex,
|
|
137
|
-
role: 'tabpanel',
|
|
138
|
-
'aria-describedby': props['aria-describedby'],
|
|
139
|
-
'aria-details': props['aria-details']
|
|
140
|
-
})
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
exports.useTabPanel = useTabPanel;
|
|
145
|
-
|
|
146
|
-
class $c98ba41732a4afea84f1af0a5428958$export$TabsKeyboardDelegate {
|
|
147
|
-
constructor(collection, direction, orientation, disabledKeys) {
|
|
148
|
-
if (disabledKeys === void 0) {
|
|
149
|
-
disabledKeys = new Set();
|
|
136
|
+
getKeyLeftOf(key) {
|
|
137
|
+
if (this.flipDirection) return this.getNextKey(key);
|
|
138
|
+
else {
|
|
139
|
+
if (this.orientation === 'horizontal') return this.getPreviousKey(key);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
150
142
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
158
|
-
this.orientation = orientation;
|
|
159
|
-
this.disabledKeys = disabledKeys;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
getKeyLeftOf(key) {
|
|
163
|
-
if (this.flipDirection) {
|
|
164
|
-
return this.getNextKey(key);
|
|
165
|
-
} else {
|
|
166
|
-
if (this.orientation === 'horizontal') {
|
|
167
|
-
return this.getPreviousKey(key);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return null;
|
|
143
|
+
getKeyRightOf(key) {
|
|
144
|
+
if (this.flipDirection) return this.getPreviousKey(key);
|
|
145
|
+
else {
|
|
146
|
+
if (this.orientation === 'horizontal') return this.getNextKey(key);
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
171
149
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (this.flipDirection) {
|
|
176
|
-
return this.getPreviousKey(key);
|
|
177
|
-
} else {
|
|
178
|
-
if (this.orientation === 'horizontal') {
|
|
179
|
-
return this.getNextKey(key);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return null;
|
|
150
|
+
getKeyAbove(key) {
|
|
151
|
+
if (this.orientation === 'vertical') return this.getPreviousKey(key);
|
|
152
|
+
return null;
|
|
183
153
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (this.orientation === 'vertical') {
|
|
188
|
-
return this.getPreviousKey(key);
|
|
154
|
+
getKeyBelow(key) {
|
|
155
|
+
if (this.orientation === 'vertical') return this.getNextKey(key);
|
|
156
|
+
return null;
|
|
189
157
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
getKeyBelow(key) {
|
|
195
|
-
if (this.orientation === 'vertical') {
|
|
196
|
-
return this.getNextKey(key);
|
|
158
|
+
getFirstKey() {
|
|
159
|
+
let key = this.collection.getFirstKey();
|
|
160
|
+
if (this.disabledKeys.has(key)) key = this.getNextKey(key);
|
|
161
|
+
return key;
|
|
197
162
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
getFirstKey() {
|
|
203
|
-
let key = this.collection.getFirstKey();
|
|
204
|
-
|
|
205
|
-
if (this.disabledKeys.has(key)) {
|
|
206
|
-
key = this.getNextKey(key);
|
|
163
|
+
getLastKey() {
|
|
164
|
+
let key = this.collection.getLastKey();
|
|
165
|
+
if (this.disabledKeys.has(key)) key = this.getPreviousKey(key);
|
|
166
|
+
return key;
|
|
207
167
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (this.disabledKeys.has(key)) {
|
|
216
|
-
key = this.getPreviousKey(key);
|
|
168
|
+
getNextKey(key) {
|
|
169
|
+
do {
|
|
170
|
+
key = this.collection.getKeyAfter(key);
|
|
171
|
+
if (key == null) key = this.collection.getFirstKey();
|
|
172
|
+
}while (this.disabledKeys.has(key))
|
|
173
|
+
return key;
|
|
217
174
|
}
|
|
175
|
+
getPreviousKey(key) {
|
|
176
|
+
do {
|
|
177
|
+
key = this.collection.getKeyBefore(key);
|
|
178
|
+
if (key == null) key = this.collection.getLastKey();
|
|
179
|
+
}while (this.disabledKeys.has(key))
|
|
180
|
+
return key;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
218
183
|
|
|
219
|
-
return key;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
getNextKey(key) {
|
|
223
|
-
do {
|
|
224
|
-
key = this.collection.getKeyAfter(key);
|
|
225
|
-
|
|
226
|
-
if (key == null) {
|
|
227
|
-
key = this.collection.getFirstKey();
|
|
228
|
-
}
|
|
229
|
-
} while (this.disabledKeys.has(key));
|
|
230
|
-
|
|
231
|
-
return key;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
getPreviousKey(key) {
|
|
235
|
-
do {
|
|
236
|
-
key = this.collection.getKeyBefore(key);
|
|
237
184
|
|
|
238
|
-
if (key == null) {
|
|
239
|
-
key = this.collection.getLastKey();
|
|
240
|
-
}
|
|
241
|
-
} while (this.disabledKeys.has(key));
|
|
242
185
|
|
|
243
|
-
return key;
|
|
244
|
-
}
|
|
245
186
|
|
|
187
|
+
function $082250f9aef6d971$export$773e389e644c5874(props, state, ref) {
|
|
188
|
+
let { orientation: orientation = 'horizontal' , keyboardActivation: keyboardActivation = 'automatic' } = props;
|
|
189
|
+
let { collection: collection , selectionManager: manager , disabledKeys: disabledKeys } = state;
|
|
190
|
+
let { direction: direction } = $hxncP$reactariai18n.useLocale();
|
|
191
|
+
let delegate = $hxncP$react.useMemo(()=>new $d4e272ab55181b4b$export$15010ca3c1abe90b(collection, direction, orientation, disabledKeys)
|
|
192
|
+
, [
|
|
193
|
+
collection,
|
|
194
|
+
disabledKeys,
|
|
195
|
+
orientation,
|
|
196
|
+
direction
|
|
197
|
+
]);
|
|
198
|
+
let { collectionProps: collectionProps } = $hxncP$reactariaselection.useSelectableCollection({
|
|
199
|
+
ref: ref,
|
|
200
|
+
selectionManager: manager,
|
|
201
|
+
keyboardDelegate: delegate,
|
|
202
|
+
selectOnFocus: keyboardActivation === 'automatic',
|
|
203
|
+
disallowEmptySelection: true,
|
|
204
|
+
scrollRef: ref
|
|
205
|
+
});
|
|
206
|
+
// Compute base id for all tabs
|
|
207
|
+
let tabsId = $hxncP$reactariautils.useId();
|
|
208
|
+
$e8ba102c56610ecd$export$c5f62239608282b6.set(state, tabsId);
|
|
209
|
+
let tabListLabelProps = $hxncP$reactariautils.useLabels({
|
|
210
|
+
...props,
|
|
211
|
+
id: tabsId
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
tabListProps: {
|
|
215
|
+
...$hxncP$reactariautils.mergeProps(collectionProps, tabListLabelProps),
|
|
216
|
+
role: 'tablist',
|
|
217
|
+
'aria-orientation': orientation,
|
|
218
|
+
tabIndex: undefined
|
|
219
|
+
}
|
|
220
|
+
};
|
|
246
221
|
}
|
|
247
222
|
|
|
248
|
-
/**
|
|
249
|
-
* Provides the behavior and accessibility implementation for a tab list.
|
|
250
|
-
* Tabs organize content into multiple sections and allow users to navigate between them.
|
|
251
|
-
*/
|
|
252
|
-
function useTabList(props, state, ref) {
|
|
253
|
-
let {
|
|
254
|
-
orientation = 'horizontal',
|
|
255
|
-
keyboardActivation = 'automatic'
|
|
256
|
-
} = props;
|
|
257
|
-
let {
|
|
258
|
-
collection,
|
|
259
|
-
selectionManager: manager,
|
|
260
|
-
disabledKeys
|
|
261
|
-
} = state;
|
|
262
|
-
let {
|
|
263
|
-
direction
|
|
264
|
-
} = useLocale();
|
|
265
|
-
let delegate = useMemo(() => new $c98ba41732a4afea84f1af0a5428958$export$TabsKeyboardDelegate(collection, direction, orientation, disabledKeys), [collection, disabledKeys, orientation, direction]);
|
|
266
|
-
let {
|
|
267
|
-
collectionProps
|
|
268
|
-
} = useSelectableCollection({
|
|
269
|
-
ref,
|
|
270
|
-
selectionManager: manager,
|
|
271
|
-
keyboardDelegate: delegate,
|
|
272
|
-
selectOnFocus: keyboardActivation === 'automatic',
|
|
273
|
-
disallowEmptySelection: true,
|
|
274
|
-
scrollRef: ref
|
|
275
|
-
}); // Compute base id for all tabs
|
|
276
223
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}));
|
|
282
|
-
return {
|
|
283
|
-
tabListProps: _babelRuntimeHelpersExtends({}, mergeProps(collectionProps, tabListLabelProps), {
|
|
284
|
-
role: 'tablist',
|
|
285
|
-
'aria-orientation': orientation,
|
|
286
|
-
tabIndex: undefined
|
|
287
|
-
})
|
|
288
|
-
};
|
|
289
|
-
}
|
|
224
|
+
$parcel$exportWildcard(module.exports, $bca6ccd6c0f0d1c7$exports);
|
|
225
|
+
$parcel$exportWildcard(module.exports, $83205e167d36c1bd$exports);
|
|
226
|
+
$parcel$exportWildcard(module.exports, $082250f9aef6d971$exports);
|
|
227
|
+
|
|
290
228
|
|
|
291
|
-
exports.useTabList = useTabList;
|
|
292
229
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACFD;;;;;;;;;;;AAeO,MAAMG,6CAAO,GAAG,IAAIC,OAAJ,EAAhB;;AAEA,SAASC,gDAAT,CAAuBC,KAAvB,EAA+CC,GAA/C,EAAyDC,IAAzD,EAAuE;AAC5E,MAAI,OAAOD,GAAP,KAAe,QAAnB,EAA6B;AAC3BA,IAAAA,GAAG,GAAGA,GAAG,CAACE,OAAJ,CAAY,MAAZ,EAAoB,EAApB,CAAN;AACD;;AAED,MAAIC,MAAM,GAAGP,6CAAO,CAACQ,GAAR,CAAYL,KAAZ,CAAb;AACA,SAAUI,MAAV,SAAoBF,IAApB,SAA4BD,GAA5B;AACD;;ACDD;;;;AAIO,SAASK,MAAT,CACLC,KADK,EAELP,KAFK,EAGLQ,GAHK,EAII;AACT,MAAI;AAACP,IAAAA,GAAD;AAAMQ,IAAAA,UAAU,EAAEC;AAAlB,MAAmCH,KAAvC;AACA,MAAI;AAACI,IAAAA,gBAAgB,EAAEC,OAAnB;AAA4BC,IAAA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-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./packages/@react-aria/tabs/src/useTabList.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key} from 'react';\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 {AriaTabProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\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<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n return {\n tabProps: {\n ...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 };\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 {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\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<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\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 useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, 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 {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 {AriaTabListProps} from '@react-types/tabs';\nimport {HTMLAttributes, RefObject, useMemo} from 'react';\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 {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\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: AriaTabListProps<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 });\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":["$parcel$interopDefault","a","__esModule","default","tabsIds","WeakMap","generateId","state","key","role","replace","baseId","get","useTab","props","ref","isDisabled","propsDisabled","selectionManager","manager","selectedKey","isSelected","disabledKeys","has","itemProps","useSelectableItem","tabId","tabPanelId","tabIndex","tabProps","id","undefined","useTabPanel","setTabIndex","useState","useLayoutEffect","current","update","walker","getFocusableTreeWalker","tabbable","nextNode","observer","MutationObserver","observe","subtree","childList","attributes","attributeFilter","disconnect","tabPanelProps","useLabels","mergeProps","TabsKeyboardDelegate","constructor","collection","direction","orientation","Set","flipDirection","getKeyLeftOf","getNextKey","getPreviousKey","getKeyRightOf","getKeyAbove","getKeyBelow","getFirstKey","getLastKey","getKeyAfter","getKeyBefore","useTabList","keyboardActivation","useLocale","delegate","useMemo","collectionProps","useSelectableCollection","keyboardDelegate","selectOnFocus","disallowEmptySelection","scrollRef","tabsId","useId","set","tabListLabelProps","tabListProps"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AEeO,KAAK,CAAC,yCAAO,GAAG,GAAG,CAAC,OAAO;SAElB,yCAAU,CAAI,KAAsB,EAAE,GAAQ,EAAE,IAAY,EAAE,CAAC;IAC7E,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,GAAG,GAAG,GAAG,CAAC,OAAO,SAAS,CAAE;IAG9B,GAAG,CAAC,MAAM,GAAG,yCAAO,CAAC,GAAG,CAAC,KAAK;IAC9B,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG;AACjC,CAAC;;;;SDGe,yCAAM,CACpB,KAAmB,EACnB,KAAsB,EACtB,GAA2B,EAClB,CAAC;IACV,GAAG,CAAC,CAAC,MAAA,GAAG,GAAE,UAAU,EAAE,aAAa,EAAA,CAAC,GAAG,KAAK;IAC5C,GAAG,CAAC,CAAC,CAAA,gBAAgB,EAAE,OAAO,gBAAE,WAAW,EAAA,CAAC,GAAG,KAAK;IAEpD,GAAG,CAAC,UAA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U;QAAE,YAAY;QAAE,WAAW;QAAE,SAAS;IAAA,CAAC;IAEnE,GAAG,CAAC,CAAC,kBAAA,eAAe,EAAA,CAAC,GAAG,iDAAuB,CAAC,CAAC;aAC/C,GAAG;QACH,gBAAgB,EAAE,OAAO;QACzB,gBAAgB,EAAE,QAAQ;QAC1B,aAAa,EAAE,kBAAkB,KAAK,CAAW;QACjD,sBAAsB,EAAE,IAAI;QAC5B,SAAS,EAAE,GAAG;IAChB,CAAC;IAED,EAA+B,AAA/B,6BAA+B;IAC/B,GAAG,CAAC,MAAM,GAAG,2BAAK;IAClB,yCAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM;IAEzB,GAAG,CAAC,iBAAiB,GAAG,+BAAS,CAAC,CAAC;WAAG,KAAK;QAAE,EAAE,EAAE,MAAM;IAAA,CAAC;IAExD,MAAM,CAAC,CAAC;QACN,YAAY,EAAE,CAAC;eACV,gCAAU,CAAC,eAAe,EAAE,iBAAiB;YAChD,IAAI,EAAE,CAAS;YACf,CAAkB,mBAAE,WAAW;YAC/B,QAAQ,EAAE,SAAS;QACrB,CAAC;IACH,CAAC;AACH,CAAC;","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 */\n\nexport * from './useTab';\nexport * from './useTabPanel';\nexport * 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 {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\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<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n return {\n tabProps: {\n ...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 };\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';\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 {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\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<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\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 useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, 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 {HTMLAttributes, RefObject, useMemo} from 'react';\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 {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\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: AriaTabListProps<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 });\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, 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"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,262 +1,211 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
const $c5c378b07d37fb3729fd37493414d657$export$tabsIds = new WeakMap();
|
|
20
|
-
|
|
21
|
-
function $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, role) {
|
|
22
|
-
if (typeof key === 'string') {
|
|
23
|
-
key = key.replace(/\s+/g, '');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let baseId = $c5c378b07d37fb3729fd37493414d657$export$tabsIds.get(state);
|
|
27
|
-
return baseId + "-" + role + "-" + key;
|
|
1
|
+
import {useSelectableItem as $h3U02$useSelectableItem, useSelectableCollection as $h3U02$useSelectableCollection} from "@react-aria/selection";
|
|
2
|
+
import {getFocusableTreeWalker as $h3U02$getFocusableTreeWalker} from "@react-aria/focus";
|
|
3
|
+
import {useState as $h3U02$useState, useLayoutEffect as $h3U02$useLayoutEffect, useMemo as $h3U02$useMemo} from "react";
|
|
4
|
+
import {useLabels as $h3U02$useLabels, mergeProps as $h3U02$mergeProps, useId as $h3U02$useId} from "@react-aria/utils";
|
|
5
|
+
import {useLocale as $h3U02$useLocale} from "@react-aria/i18n";
|
|
6
|
+
|
|
7
|
+
function $parcel$export(e, n, v, s) {
|
|
8
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28
9
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
key
|
|
37
|
-
isDisabled: propsDisabled
|
|
38
|
-
} = props;
|
|
39
|
-
let {
|
|
40
|
-
selectionManager: manager,
|
|
41
|
-
selectedKey
|
|
42
|
-
} = state;
|
|
43
|
-
let isSelected = key === selectedKey;
|
|
44
|
-
let isDisabled = propsDisabled || state.disabledKeys.has(key);
|
|
45
|
-
let {
|
|
46
|
-
itemProps
|
|
47
|
-
} = useSelectableItem({
|
|
48
|
-
selectionManager: manager,
|
|
49
|
-
key,
|
|
50
|
-
ref,
|
|
51
|
-
isDisabled
|
|
52
|
-
});
|
|
53
|
-
let tabId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tab');
|
|
54
|
-
let tabPanelId = $c5c378b07d37fb3729fd37493414d657$export$generateId(state, key, 'tabpanel');
|
|
55
|
-
let {
|
|
56
|
-
tabIndex
|
|
57
|
-
} = itemProps;
|
|
58
|
-
return {
|
|
59
|
-
tabProps: _babelRuntimeHelpersEsmExtends({}, itemProps, {
|
|
60
|
-
id: tabId,
|
|
61
|
-
'aria-selected': isSelected,
|
|
62
|
-
'aria-disabled': isDisabled || undefined,
|
|
63
|
-
'aria-controls': isSelected ? tabPanelId : undefined,
|
|
64
|
-
tabIndex: isDisabled ? undefined : tabIndex,
|
|
65
|
-
role: 'tab'
|
|
66
|
-
})
|
|
67
|
-
};
|
|
10
|
+
var $184b4f90085af26c$exports = {};
|
|
11
|
+
|
|
12
|
+
$parcel$export($184b4f90085af26c$exports, "useTab", () => $184b4f90085af26c$export$fdf4756d5b8ef90a);
|
|
13
|
+
const $106426b893fe64c5$export$c5f62239608282b6 = new WeakMap();
|
|
14
|
+
function $106426b893fe64c5$export$567fc7097e064344(state, key, role) {
|
|
15
|
+
if (typeof key === 'string') key = key.replace(/\s+/g, '');
|
|
16
|
+
let baseId = $106426b893fe64c5$export$c5f62239608282b6.get(state);
|
|
17
|
+
return `${baseId}-${role}-${key}`;
|
|
68
18
|
}
|
|
69
19
|
|
|
70
|
-
/**
|
|
71
|
-
* Provides the behavior and accessibility implementation for a tab panel. A tab panel is a container for
|
|
72
|
-
* the contents of a tab, and is shown when the tab is selected.
|
|
73
|
-
*/
|
|
74
|
-
export function useTabPanel(props, state, ref) {
|
|
75
|
-
let [tabIndex, setTabIndex] = useState(0); // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
|
|
76
|
-
// Otherwise, tabbing from the focused tab should go directly to the first tabbable element
|
|
77
|
-
// within the tabpanel.
|
|
78
20
|
|
|
79
|
-
useLayoutEffect(() => {
|
|
80
|
-
if (ref != null && ref.current) {
|
|
81
|
-
let update = () => {
|
|
82
|
-
// Detect if there are any tabbable elements and update the tabIndex accordingly.
|
|
83
|
-
let walker = getFocusableTreeWalker(ref.current, {
|
|
84
|
-
tabbable: true
|
|
85
|
-
});
|
|
86
|
-
setTabIndex(walker.nextNode() ? undefined : 0);
|
|
87
|
-
};
|
|
88
21
|
|
|
89
|
-
|
|
22
|
+
function $184b4f90085af26c$export$fdf4756d5b8ef90a(props, state, ref) {
|
|
23
|
+
let { key: key , isDisabled: propsDisabled } = props;
|
|
24
|
+
let { selectionManager: manager , selectedKey: selectedKey } = state;
|
|
25
|
+
let isSelected = key === selectedKey;
|
|
26
|
+
let isDisabled = propsDisabled || state.disabledKeys.has(key);
|
|
27
|
+
let { itemProps: itemProps } = $h3U02$useSelectableItem({
|
|
28
|
+
selectionManager: manager,
|
|
29
|
+
key: key,
|
|
30
|
+
ref: ref,
|
|
31
|
+
isDisabled: isDisabled
|
|
32
|
+
});
|
|
33
|
+
let tabId = $106426b893fe64c5$export$567fc7097e064344(state, key, 'tab');
|
|
34
|
+
let tabPanelId = $106426b893fe64c5$export$567fc7097e064344(state, key, 'tabpanel');
|
|
35
|
+
let { tabIndex: tabIndex } = itemProps;
|
|
36
|
+
return {
|
|
37
|
+
tabProps: {
|
|
38
|
+
...itemProps,
|
|
39
|
+
id: tabId,
|
|
40
|
+
'aria-selected': isSelected,
|
|
41
|
+
'aria-disabled': isDisabled || undefined,
|
|
42
|
+
'aria-controls': isSelected ? tabPanelId : undefined,
|
|
43
|
+
tabIndex: isDisabled ? undefined : tabIndex,
|
|
44
|
+
role: 'tab'
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
90
48
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
49
|
+
|
|
50
|
+
var $4583fbfef9273355$exports = {};
|
|
51
|
+
|
|
52
|
+
$parcel$export($4583fbfef9273355$exports, "useTabPanel", () => $4583fbfef9273355$export$fae0121b5afe572d);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
function $4583fbfef9273355$export$fae0121b5afe572d(props, state, ref) {
|
|
58
|
+
let [tabIndex, setTabIndex] = $h3U02$useState(0);
|
|
59
|
+
// The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
|
|
60
|
+
// Otherwise, tabbing from the focused tab should go directly to the first tabbable element
|
|
61
|
+
// within the tabpanel.
|
|
62
|
+
$h3U02$useLayoutEffect(()=>{
|
|
63
|
+
if (ref?.current) {
|
|
64
|
+
let update = ()=>{
|
|
65
|
+
// Detect if there are any tabbable elements and update the tabIndex accordingly.
|
|
66
|
+
let walker = $h3U02$getFocusableTreeWalker(ref.current, {
|
|
67
|
+
tabbable: true
|
|
68
|
+
});
|
|
69
|
+
setTabIndex(walker.nextNode() ? undefined : 0);
|
|
70
|
+
};
|
|
71
|
+
update();
|
|
72
|
+
// Update when new elements are inserted, or the tabIndex/disabled attribute updates.
|
|
73
|
+
let observer = new MutationObserver(update);
|
|
74
|
+
observer.observe(ref.current, {
|
|
75
|
+
subtree: true,
|
|
76
|
+
childList: true,
|
|
77
|
+
attributes: true,
|
|
78
|
+
attributeFilter: [
|
|
79
|
+
'tabIndex',
|
|
80
|
+
'disabled'
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
return ()=>{
|
|
84
|
+
observer.disconnect();
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
ref
|
|
89
|
+
]);
|
|
90
|
+
const id = $106426b893fe64c5$export$567fc7097e064344(state, state?.selectedKey, 'tabpanel');
|
|
91
|
+
const tabPanelProps = $h3U02$useLabels({
|
|
92
|
+
...props,
|
|
93
|
+
id: id,
|
|
94
|
+
'aria-labelledby': $106426b893fe64c5$export$567fc7097e064344(state, state?.selectedKey, 'tab')
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
tabPanelProps: $h3U02$mergeProps(tabPanelProps, {
|
|
98
|
+
tabIndex: tabIndex,
|
|
99
|
+
role: 'tabpanel',
|
|
100
|
+
'aria-describedby': props['aria-describedby'],
|
|
101
|
+
'aria-details': props['aria-details']
|
|
102
|
+
})
|
|
103
|
+
};
|
|
116
104
|
}
|
|
117
105
|
|
|
118
|
-
class $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate {
|
|
119
|
-
constructor(collection, direction, orientation, disabledKeys) {
|
|
120
|
-
if (disabledKeys === void 0) {
|
|
121
|
-
disabledKeys = new Set();
|
|
122
|
-
}
|
|
123
106
|
|
|
124
|
-
|
|
125
|
-
this.flipDirection = void 0;
|
|
126
|
-
this.disabledKeys = void 0;
|
|
127
|
-
this.orientation = void 0;
|
|
128
|
-
this.collection = collection;
|
|
129
|
-
this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
130
|
-
this.orientation = orientation;
|
|
131
|
-
this.disabledKeys = disabledKeys;
|
|
132
|
-
}
|
|
107
|
+
var $f34b9b0e5fb410d4$exports = {};
|
|
133
108
|
|
|
134
|
-
|
|
135
|
-
if (this.flipDirection) {
|
|
136
|
-
return this.getNextKey(key);
|
|
137
|
-
} else {
|
|
138
|
-
if (this.orientation === 'horizontal') {
|
|
139
|
-
return this.getPreviousKey(key);
|
|
140
|
-
}
|
|
109
|
+
$parcel$export($f34b9b0e5fb410d4$exports, "useTabList", () => $f34b9b0e5fb410d4$export$773e389e644c5874);
|
|
141
110
|
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
111
|
|
|
146
|
-
getKeyRightOf(key) {
|
|
147
|
-
if (this.flipDirection) {
|
|
148
|
-
return this.getPreviousKey(key);
|
|
149
|
-
} else {
|
|
150
|
-
if (this.orientation === 'horizontal') {
|
|
151
|
-
return this.getNextKey(key);
|
|
152
|
-
}
|
|
153
112
|
|
|
154
|
-
|
|
113
|
+
class $6e3da305df7d9d45$export$15010ca3c1abe90b {
|
|
114
|
+
constructor(collection, direction, orientation, disabledKeys = new Set()){
|
|
115
|
+
this.collection = collection;
|
|
116
|
+
this.flipDirection = direction === 'rtl' && orientation === 'horizontal';
|
|
117
|
+
this.orientation = orientation;
|
|
118
|
+
this.disabledKeys = disabledKeys;
|
|
155
119
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
120
|
+
getKeyLeftOf(key) {
|
|
121
|
+
if (this.flipDirection) return this.getNextKey(key);
|
|
122
|
+
else {
|
|
123
|
+
if (this.orientation === 'horizontal') return this.getPreviousKey(key);
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
161
126
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return this.getNextKey(key);
|
|
127
|
+
getKeyRightOf(key) {
|
|
128
|
+
if (this.flipDirection) return this.getPreviousKey(key);
|
|
129
|
+
else {
|
|
130
|
+
if (this.orientation === 'horizontal') return this.getNextKey(key);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
169
133
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
getFirstKey() {
|
|
175
|
-
let key = this.collection.getFirstKey();
|
|
176
|
-
|
|
177
|
-
if (this.disabledKeys.has(key)) {
|
|
178
|
-
key = this.getNextKey(key);
|
|
134
|
+
getKeyAbove(key) {
|
|
135
|
+
if (this.orientation === 'vertical') return this.getPreviousKey(key);
|
|
136
|
+
return null;
|
|
179
137
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
getLastKey() {
|
|
185
|
-
let key = this.collection.getLastKey();
|
|
186
|
-
|
|
187
|
-
if (this.disabledKeys.has(key)) {
|
|
188
|
-
key = this.getPreviousKey(key);
|
|
138
|
+
getKeyBelow(key) {
|
|
139
|
+
if (this.orientation === 'vertical') return this.getNextKey(key);
|
|
140
|
+
return null;
|
|
189
141
|
}
|
|
142
|
+
getFirstKey() {
|
|
143
|
+
let key = this.collection.getFirstKey();
|
|
144
|
+
if (this.disabledKeys.has(key)) key = this.getNextKey(key);
|
|
145
|
+
return key;
|
|
146
|
+
}
|
|
147
|
+
getLastKey() {
|
|
148
|
+
let key = this.collection.getLastKey();
|
|
149
|
+
if (this.disabledKeys.has(key)) key = this.getPreviousKey(key);
|
|
150
|
+
return key;
|
|
151
|
+
}
|
|
152
|
+
getNextKey(key) {
|
|
153
|
+
do {
|
|
154
|
+
key = this.collection.getKeyAfter(key);
|
|
155
|
+
if (key == null) key = this.collection.getFirstKey();
|
|
156
|
+
}while (this.disabledKeys.has(key))
|
|
157
|
+
return key;
|
|
158
|
+
}
|
|
159
|
+
getPreviousKey(key) {
|
|
160
|
+
do {
|
|
161
|
+
key = this.collection.getKeyBefore(key);
|
|
162
|
+
if (key == null) key = this.collection.getLastKey();
|
|
163
|
+
}while (this.disabledKeys.has(key))
|
|
164
|
+
return key;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
190
167
|
|
|
191
|
-
return key;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
getNextKey(key) {
|
|
195
|
-
do {
|
|
196
|
-
key = this.collection.getKeyAfter(key);
|
|
197
|
-
|
|
198
|
-
if (key == null) {
|
|
199
|
-
key = this.collection.getFirstKey();
|
|
200
|
-
}
|
|
201
|
-
} while (this.disabledKeys.has(key));
|
|
202
168
|
|
|
203
|
-
return key;
|
|
204
|
-
}
|
|
205
169
|
|
|
206
|
-
getPreviousKey(key) {
|
|
207
|
-
do {
|
|
208
|
-
key = this.collection.getKeyBefore(key);
|
|
209
170
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
171
|
+
function $f34b9b0e5fb410d4$export$773e389e644c5874(props, state, ref) {
|
|
172
|
+
let { orientation: orientation = 'horizontal' , keyboardActivation: keyboardActivation = 'automatic' } = props;
|
|
173
|
+
let { collection: collection , selectionManager: manager , disabledKeys: disabledKeys } = state;
|
|
174
|
+
let { direction: direction } = $h3U02$useLocale();
|
|
175
|
+
let delegate = $h3U02$useMemo(()=>new $6e3da305df7d9d45$export$15010ca3c1abe90b(collection, direction, orientation, disabledKeys)
|
|
176
|
+
, [
|
|
177
|
+
collection,
|
|
178
|
+
disabledKeys,
|
|
179
|
+
orientation,
|
|
180
|
+
direction
|
|
181
|
+
]);
|
|
182
|
+
let { collectionProps: collectionProps } = $h3U02$useSelectableCollection({
|
|
183
|
+
ref: ref,
|
|
184
|
+
selectionManager: manager,
|
|
185
|
+
keyboardDelegate: delegate,
|
|
186
|
+
selectOnFocus: keyboardActivation === 'automatic',
|
|
187
|
+
disallowEmptySelection: true,
|
|
188
|
+
scrollRef: ref
|
|
189
|
+
});
|
|
190
|
+
// Compute base id for all tabs
|
|
191
|
+
let tabsId = $h3U02$useId();
|
|
192
|
+
$106426b893fe64c5$export$c5f62239608282b6.set(state, tabsId);
|
|
193
|
+
let tabListLabelProps = $h3U02$useLabels({
|
|
194
|
+
...props,
|
|
195
|
+
id: tabsId
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
tabListProps: {
|
|
199
|
+
...$h3U02$mergeProps(collectionProps, tabListLabelProps),
|
|
200
|
+
role: 'tablist',
|
|
201
|
+
'aria-orientation': orientation,
|
|
202
|
+
tabIndex: undefined
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
214
206
|
|
|
215
|
-
return key;
|
|
216
|
-
}
|
|
217
207
|
|
|
218
|
-
}
|
|
219
208
|
|
|
220
|
-
/**
|
|
221
|
-
* Provides the behavior and accessibility implementation for a tab list.
|
|
222
|
-
* Tabs organize content into multiple sections and allow users to navigate between them.
|
|
223
|
-
*/
|
|
224
|
-
export function useTabList(props, state, ref) {
|
|
225
|
-
let {
|
|
226
|
-
orientation = 'horizontal',
|
|
227
|
-
keyboardActivation = 'automatic'
|
|
228
|
-
} = props;
|
|
229
|
-
let {
|
|
230
|
-
collection,
|
|
231
|
-
selectionManager: manager,
|
|
232
|
-
disabledKeys
|
|
233
|
-
} = state;
|
|
234
|
-
let {
|
|
235
|
-
direction
|
|
236
|
-
} = useLocale();
|
|
237
|
-
let delegate = useMemo(() => new $ace72fda23df319bd9db38f00073d9$export$TabsKeyboardDelegate(collection, direction, orientation, disabledKeys), [collection, disabledKeys, orientation, direction]);
|
|
238
|
-
let {
|
|
239
|
-
collectionProps
|
|
240
|
-
} = useSelectableCollection({
|
|
241
|
-
ref,
|
|
242
|
-
selectionManager: manager,
|
|
243
|
-
keyboardDelegate: delegate,
|
|
244
|
-
selectOnFocus: keyboardActivation === 'automatic',
|
|
245
|
-
disallowEmptySelection: true,
|
|
246
|
-
scrollRef: ref
|
|
247
|
-
}); // Compute base id for all tabs
|
|
248
209
|
|
|
249
|
-
|
|
250
|
-
$c5c378b07d37fb3729fd37493414d657$export$tabsIds.set(state, tabsId);
|
|
251
|
-
let tabListLabelProps = useLabels(_babelRuntimeHelpersEsmExtends({}, props, {
|
|
252
|
-
id: tabsId
|
|
253
|
-
}));
|
|
254
|
-
return {
|
|
255
|
-
tabListProps: _babelRuntimeHelpersEsmExtends({}, mergeProps(collectionProps, tabListLabelProps), {
|
|
256
|
-
role: 'tablist',
|
|
257
|
-
'aria-orientation': orientation,
|
|
258
|
-
tabIndex: undefined
|
|
259
|
-
})
|
|
260
|
-
};
|
|
261
|
-
}
|
|
210
|
+
export {$184b4f90085af26c$export$fdf4756d5b8ef90a as useTab, $4583fbfef9273355$export$fae0121b5afe572d as useTabPanel, $f34b9b0e5fb410d4$export$773e389e644c5874 as useTabList};
|
|
262
211
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;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BAAkB,KAAK,WAJQ;AAK9CQ,IAAAA,sBAAsB,EAAE,IALsB;AAM9CC,IAAAA,SAAS,EAAEjE;AANmC,GAAD,CAA/C,CAjB0H,CA0B1H;;AACA,MAAIkE,MAAM,GAAGC,KAAK,EAAlB;AACA,mDAAQC,GAAR,CAAY5E,KAAZ,EAAmB0E,MAAnB;AAEA,MAAIG,iBAAiB,GAAGjC,SAAS,oCAAKrC,KAAL;AAAYgB,IAAAA,EAAE,EAAEmD;AAAhB,KAAjC;AAEA,SAAO;AACLI,IAAAA,YAAY,qCACPjC,UAAU,CAACuB,eAAD,EAAkBS,iBAAlB,CADH;AAEV3E,MAAAA,IAAI,EAAE,SAFI;AAGV,0BAAoBgD,WAHV;AAIV7B,MAAAA,QAAQ,EAAEG;AAJA;AADP,GAAP;AAQD","sources":["./packages/@react-aria/tabs/src/utils.ts","./packages/@react-aria/tabs/src/useTab.ts","./packages/@react-aria/tabs/src/useTabPanel.ts","./packages/@react-aria/tabs/src/TabsKeyboardDelegate.ts","./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 {Key} from 'react';\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 {AriaTabProps} from '@react-types/tabs';\nimport {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\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<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n return {\n tabProps: {\n ...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 };\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 {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\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<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\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 useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, 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 {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 {AriaTabListProps} from '@react-types/tabs';\nimport {HTMLAttributes, RefObject, useMemo} from 'react';\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 {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\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: AriaTabListProps<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 });\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":["tabsIds","WeakMap","generateId","state","key","role","replace","baseId","get","useTab","props","ref","isDisabled","propsDisabled","selectionManager","manager","selectedKey","isSelected","disabledKeys","has","itemProps","useSelectableItem","tabId","tabPanelId","tabIndex","tabProps","id","undefined","useTabPanel","setTabIndex","useState","useLayoutEffect","current","update","walker","getFocusableTreeWalker","tabbable","nextNode","observer","MutationObserver","observe","subtree","childList","attributes","attributeFilter","disconnect","tabPanelProps","useLabels","mergeProps","TabsKeyboardDelegate","constructor","collection","direction","orientation","Set","flipDirection","getKeyLeftOf","getNextKey","getPreviousKey","getKeyRightOf","getKeyAbove","getKeyBelow","getFirstKey","getLastKey","getKeyAfter","getKeyBefore","useTabList","keyboardActivation","useLocale","delegate","useMemo","collectionProps","useSelectableCollection","keyboardDelegate","selectOnFocus","disallowEmptySelection","scrollRef","tabsId","useId","set","tabListLabelProps","tabListProps"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AEeO,KAAK,CAAC,yCAAO,GAAG,GAAG,CAAC,OAAO;SAElB,yCAAU,CAAI,KAAsB,EAAE,GAAQ,EAAE,IAAY,EAAE,CAAC;IAC7E,EAAE,EAAE,MAAM,CAAC,GAAG,KAAK,CAAQ,SACzB,GAAG,GAAG,GAAG,CAAC,OAAO,SAAS,CAAE;IAG9B,GAAG,CAAC,MAAM,GAAG,yCAAO,CAAC,GAAG,CAAC,KAAK;IAC9B,MAAM,IAAI,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG;AACjC,CAAC;;;;SDGe,yCAAM,CACpB,KAAmB,EACnB,KAAsB,EACtB,GAA2B,EAClB,CAAC;IACV,GAAG,CAAC,CAAC,MAAA,GAAG,GAAE,UAAU,EAAE,aAAa,EAAA,CAAC,GAAG,KAAK;IAC5C,GAAG,CAAC,CAAC,CAAA,gBAAgB,EAAE,OAAO,gBAAE,WAAW,EAAA,CAAC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,EACX,YAAY;MAAG,CAAC;QAAA,UAAU;QAAE,YAAY;QAAE,WAAW;QAAE,SAAS;IAAA,CAAC;IAEnE,GAAG,CAAC,CAAC,kBAAA,eAAe,EAAA,CAAC,GAAG,8BAAuB,CAAC,CAAC;aAC/C,GAAG;QACH,gBAAgB,EAAE,OAAO;QACzB,gBAAgB,EAAE,QAAQ;QAC1B,aAAa,EAAE,kBAAkB,KAAK,CAAW;QACjD,sBAAsB,EAAE,IAAI;QAC5B,SAAS,EAAE,GAAG;IAChB,CAAC;IAED,EAA+B,AAA/B,6BAA+B;IAC/B,GAAG,CAAC,MAAM,GAAG,YAAK;IAClB,yCAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM;IAEzB,GAAG,CAAC,iBAAiB,GAAG,gBAAS,CAAC,CAAC;WAAG,KAAK;QAAE,EAAE,EAAE,MAAM;IAAA,CAAC;IAExD,MAAM,CAAC,CAAC;QACN,YAAY,EAAE,CAAC;eACV,iBAAU,CAAC,eAAe,EAAE,iBAAiB;YAChD,IAAI,EAAE,CAAS;YACf,CAAkB,mBAAE,WAAW;YAC/B,QAAQ,EAAE,SAAS;QACrB,CAAC;IACH,CAAC;AACH,CAAC;","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 */\n\nexport * from './useTab';\nexport * from './useTabPanel';\nexport * 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 {generateId} from './utils';\nimport {HTMLAttributes, RefObject} from 'react';\nimport {TabListState} from '@react-stately/tabs';\nimport {useSelectableItem} from '@react-aria/selection';\n\ninterface TabAria {\n /** Props for the tab element. */\n tabProps: HTMLAttributes<HTMLElement>\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<HTMLElement>\n): TabAria {\n let {key, isDisabled: propsDisabled} = props;\n let {selectionManager: manager, selectedKey} = state;\n\n let isSelected = key === selectedKey;\n\n let isDisabled = propsDisabled || state.disabledKeys.has(key);\n let {itemProps} = useSelectableItem({\n selectionManager: manager,\n key,\n ref,\n isDisabled\n });\n\n let tabId = generateId(state, key, 'tab');\n let tabPanelId = generateId(state, key, 'tabpanel');\n let {tabIndex} = itemProps;\n\n return {\n tabProps: {\n ...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 };\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';\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 {generateId} from './utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes, RefObject, useLayoutEffect, useState} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {TabListState} from '@react-stately/tabs';\n\ninterface TabPanelAria {\n /** Props for the tab panel element. */\n tabPanelProps: HTMLAttributes<HTMLElement>\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<HTMLElement>): TabPanelAria {\n let [tabIndex, setTabIndex] = useState(0);\n\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 useLayoutEffect(() => {\n if (ref?.current) {\n let update = () => {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setTabIndex(walker.nextNode() ? undefined : 0);\n };\n\n update();\n\n // Update when new elements are inserted, or the tabIndex/disabled attribute updates.\n let observer = new MutationObserver(update);\n observer.observe(ref.current, {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: ['tabIndex', 'disabled']\n });\n\n return () => {\n observer.disconnect();\n };\n }\n }, [ref]);\n\n const id = generateId(state, 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 {HTMLAttributes, RefObject, useMemo} from 'react';\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 {useSelectableCollection} from '@react-aria/selection';\n\ninterface TabListAria {\n /** Props for the tablist container. */\n tabListProps: HTMLAttributes<HTMLElement>\n}\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: AriaTabListProps<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 });\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, 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"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;ACkBA;IACE,iCAAiC;IACjC,QAAQ,EAAE,eAAe,WAAW,CAAC,CAAA;CACtC;AAED;;;GAGG;AACH,uBAAuB,CAAC,EACtB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,aAAa,CAAC,CAAC,EACtB,GAAG,EAAE,UAAU,WAAW,CAAC,GAC1B,OAAO,CA6BT;ACzCD;IACE,uCAAuC;IACvC,aAAa,EAAE,eAAe,WAAW,CAAC,CAAA;CAC3C;AAGD;;;GAGG;AACH,4BAA4B,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,YAAY,CA0C1H;AElDD;IACE,uCAAuC;IACvC,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAGD;;;GAGG;AACH,2BAA2B,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,WAAW,CAwC1H","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 */\n\nexport * from './useTab';\nexport * from './useTabPanel';\nexport * from './useTabList';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/tabs",
|
|
3
|
-
"version": "3.1.1-nightly.
|
|
3
|
+
"version": "3.1.1-nightly.3047+87960ad25",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/focus": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
24
|
-
"@react-aria/selection": "3.0.0-nightly.
|
|
25
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
26
|
-
"@react-stately/list": "3.4.2-nightly.
|
|
27
|
-
"@react-stately/tabs": "3.0.0-nightly.
|
|
28
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
29
|
-
"@react-types/tabs": "3.0.2-nightly.
|
|
21
|
+
"@react-aria/focus": "3.0.0-nightly.1356+87960ad25",
|
|
22
|
+
"@react-aria/i18n": "3.0.0-nightly.1356+87960ad25",
|
|
23
|
+
"@react-aria/interactions": "3.0.0-nightly.1356+87960ad25",
|
|
24
|
+
"@react-aria/selection": "3.0.0-nightly.1356+87960ad25",
|
|
25
|
+
"@react-aria/utils": "3.0.0-nightly.1356+87960ad25",
|
|
26
|
+
"@react-stately/list": "3.4.2-nightly.3047+87960ad25",
|
|
27
|
+
"@react-stately/tabs": "3.0.0-nightly.1356+87960ad25",
|
|
28
|
+
"@react-types/shared": "3.0.0-nightly.1356+87960ad25",
|
|
29
|
+
"@react-types/tabs": "3.0.2-nightly.3047+87960ad25"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "87960ad25c26bc4cd6af506bb5e7e0f06621556c"
|
|
38
38
|
}
|