@react-aria/tabs 3.3.5-nightly.3696 → 3.3.5-nightly.3705

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/import.mjs +260 -0
  2. package/package.json +16 -11
@@ -0,0 +1,260 @@
1
+ import {useSelectableItem as $8kq0t$useSelectableItem, useSelectableCollection as $8kq0t$useSelectableCollection} from "@react-aria/selection";
2
+ import {getFocusableTreeWalker as $8kq0t$getFocusableTreeWalker} from "@react-aria/focus";
3
+ import {useLayoutEffect as $8kq0t$useLayoutEffect, useLabels as $8kq0t$useLabels, mergeProps as $8kq0t$mergeProps, useId as $8kq0t$useId} from "@react-aria/utils";
4
+ import {useState as $8kq0t$useState, 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
+ * Copyright 2020 Adobe. All rights reserved.
29
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
30
+ * you may not use this file except in compliance with the License. You may obtain a copy
31
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
32
+ *
33
+ * Unless required by applicable law or agreed to in writing, software distributed under
34
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
35
+ * OF ANY KIND, either express or implied. See the License for the specific language
36
+ * governing permissions and limitations under the License.
37
+ */ const $99b62ae3ff97ec45$export$c5f62239608282b6 = new WeakMap();
38
+ function $99b62ae3ff97ec45$export$567fc7097e064344(state, key, role) {
39
+ if (typeof key === "string") key = key.replace(/\s+/g, "");
40
+ let baseId = $99b62ae3ff97ec45$export$c5f62239608282b6.get(state);
41
+ return `${baseId}-${role}-${key}`;
42
+ }
43
+
44
+
45
+
46
+ function $0175d55c2a017ebc$export$fdf4756d5b8ef90a(props, state, ref) {
47
+ let { key: key , isDisabled: propsDisabled } = props;
48
+ let { selectionManager: manager , selectedKey: selectedKey } = state;
49
+ let isSelected = key === selectedKey;
50
+ let isDisabled = propsDisabled || state.isDisabled || state.disabledKeys.has(key);
51
+ let { itemProps: itemProps } = (0, $8kq0t$useSelectableItem)({
52
+ selectionManager: manager,
53
+ key: key,
54
+ ref: ref,
55
+ isDisabled: isDisabled
56
+ });
57
+ let tabId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, "tab");
58
+ let tabPanelId = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, key, "tabpanel");
59
+ let { tabIndex: tabIndex } = itemProps;
60
+ return {
61
+ tabProps: {
62
+ ...itemProps,
63
+ id: tabId,
64
+ "aria-selected": isSelected,
65
+ "aria-disabled": isDisabled || undefined,
66
+ "aria-controls": isSelected ? tabPanelId : undefined,
67
+ tabIndex: isDisabled ? undefined : tabIndex,
68
+ role: "tab"
69
+ },
70
+ isSelected: isSelected,
71
+ isDisabled: isDisabled
72
+ };
73
+ }
74
+
75
+
76
+ /*
77
+ * Copyright 2020 Adobe. All rights reserved.
78
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
79
+ * you may not use this file except in compliance with the License. You may obtain a copy
80
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
81
+ *
82
+ * Unless required by applicable law or agreed to in writing, software distributed under
83
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
84
+ * OF ANY KIND, either express or implied. See the License for the specific language
85
+ * governing permissions and limitations under the License.
86
+ */
87
+
88
+
89
+
90
+ function $34bce698202e07cb$export$fae0121b5afe572d(props, state, ref) {
91
+ let [tabIndex, setTabIndex] = (0, $8kq0t$useState)(0);
92
+ // The tabpanel should have tabIndex=0 when there are no tabbable elements within it.
93
+ // Otherwise, tabbing from the focused tab should go directly to the first tabbable element
94
+ // within the tabpanel.
95
+ (0, $8kq0t$useLayoutEffect)(()=>{
96
+ if (ref === null || ref === void 0 ? void 0 : ref.current) {
97
+ let update = ()=>{
98
+ // Detect if there are any tabbable elements and update the tabIndex accordingly.
99
+ let walker = (0, $8kq0t$getFocusableTreeWalker)(ref.current, {
100
+ tabbable: true
101
+ });
102
+ setTabIndex(walker.nextNode() ? undefined : 0);
103
+ };
104
+ update();
105
+ // Update when new elements are inserted, or the tabIndex/disabled attribute updates.
106
+ let observer = new MutationObserver(update);
107
+ observer.observe(ref.current, {
108
+ subtree: true,
109
+ childList: true,
110
+ attributes: true,
111
+ attributeFilter: [
112
+ "tabIndex",
113
+ "disabled"
114
+ ]
115
+ });
116
+ return ()=>{
117
+ observer.disconnect();
118
+ };
119
+ }
120
+ }, [
121
+ ref
122
+ ]);
123
+ const id = (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, state === null || state === void 0 ? void 0 : state.selectedKey, "tabpanel");
124
+ const tabPanelProps = (0, $8kq0t$useLabels)({
125
+ ...props,
126
+ id: id,
127
+ "aria-labelledby": (0, $99b62ae3ff97ec45$export$567fc7097e064344)(state, state === null || state === void 0 ? void 0 : state.selectedKey, "tab")
128
+ });
129
+ return {
130
+ tabPanelProps: (0, $8kq0t$mergeProps)(tabPanelProps, {
131
+ tabIndex: tabIndex,
132
+ role: "tabpanel",
133
+ "aria-describedby": props["aria-describedby"],
134
+ "aria-details": props["aria-details"]
135
+ })
136
+ };
137
+ }
138
+
139
+
140
+ /*
141
+ * Copyright 2020 Adobe. All rights reserved.
142
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
143
+ * you may not use this file except in compliance with the License. You may obtain a copy
144
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
145
+ *
146
+ * Unless required by applicable law or agreed to in writing, software distributed under
147
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
148
+ * OF ANY KIND, either express or implied. See the License for the specific language
149
+ * governing permissions and limitations under the License.
150
+ */
151
+
152
+
153
+ /*
154
+ * Copyright 2020 Adobe. All rights reserved.
155
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
156
+ * you may not use this file except in compliance with the License. You may obtain a copy
157
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
158
+ *
159
+ * Unless required by applicable law or agreed to in writing, software distributed under
160
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
161
+ * OF ANY KIND, either express or implied. See the License for the specific language
162
+ * governing permissions and limitations under the License.
163
+ */ class $bfc6f2d60b8a4c40$export$15010ca3c1abe90b {
164
+ getKeyLeftOf(key) {
165
+ if (this.flipDirection) return this.getNextKey(key);
166
+ else {
167
+ if (this.orientation === "horizontal") return this.getPreviousKey(key);
168
+ return null;
169
+ }
170
+ }
171
+ getKeyRightOf(key) {
172
+ if (this.flipDirection) return this.getPreviousKey(key);
173
+ else {
174
+ if (this.orientation === "horizontal") return this.getNextKey(key);
175
+ return null;
176
+ }
177
+ }
178
+ getKeyAbove(key) {
179
+ if (this.orientation === "vertical") return this.getPreviousKey(key);
180
+ return null;
181
+ }
182
+ getKeyBelow(key) {
183
+ if (this.orientation === "vertical") return this.getNextKey(key);
184
+ return null;
185
+ }
186
+ getFirstKey() {
187
+ let key = this.collection.getFirstKey();
188
+ if (this.disabledKeys.has(key)) key = this.getNextKey(key);
189
+ return key;
190
+ }
191
+ getLastKey() {
192
+ let key = this.collection.getLastKey();
193
+ if (this.disabledKeys.has(key)) key = this.getPreviousKey(key);
194
+ return key;
195
+ }
196
+ getNextKey(key) {
197
+ do {
198
+ key = this.collection.getKeyAfter(key);
199
+ if (key == null) key = this.collection.getFirstKey();
200
+ }while (this.disabledKeys.has(key));
201
+ return key;
202
+ }
203
+ getPreviousKey(key) {
204
+ do {
205
+ key = this.collection.getKeyBefore(key);
206
+ if (key == null) key = this.collection.getLastKey();
207
+ }while (this.disabledKeys.has(key));
208
+ return key;
209
+ }
210
+ constructor(collection, direction, orientation, disabledKeys = new Set()){
211
+ this.collection = collection;
212
+ this.flipDirection = direction === "rtl" && orientation === "horizontal";
213
+ this.orientation = orientation;
214
+ this.disabledKeys = disabledKeys;
215
+ }
216
+ }
217
+
218
+
219
+
220
+
221
+ function $58d314389b21fa3f$export$773e389e644c5874(props, state, ref) {
222
+ let { orientation: orientation = "horizontal" , keyboardActivation: keyboardActivation = "automatic" } = props;
223
+ let { collection: collection , selectionManager: manager , disabledKeys: disabledKeys } = state;
224
+ let { direction: direction } = (0, $8kq0t$useLocale)();
225
+ let delegate = (0, $8kq0t$useMemo)(()=>new (0, $bfc6f2d60b8a4c40$export$15010ca3c1abe90b)(collection, direction, orientation, disabledKeys), [
226
+ collection,
227
+ disabledKeys,
228
+ orientation,
229
+ direction
230
+ ]);
231
+ let { collectionProps: collectionProps } = (0, $8kq0t$useSelectableCollection)({
232
+ ref: ref,
233
+ selectionManager: manager,
234
+ keyboardDelegate: delegate,
235
+ selectOnFocus: keyboardActivation === "automatic",
236
+ disallowEmptySelection: true,
237
+ scrollRef: ref
238
+ });
239
+ // Compute base id for all tabs
240
+ let tabsId = (0, $8kq0t$useId)();
241
+ (0, $99b62ae3ff97ec45$export$c5f62239608282b6).set(state, tabsId);
242
+ let tabListLabelProps = (0, $8kq0t$useLabels)({
243
+ ...props,
244
+ id: tabsId
245
+ });
246
+ return {
247
+ tabListProps: {
248
+ ...(0, $8kq0t$mergeProps)(collectionProps, tabListLabelProps),
249
+ role: "tablist",
250
+ "aria-orientation": orientation,
251
+ tabIndex: undefined
252
+ }
253
+ };
254
+ }
255
+
256
+
257
+
258
+
259
+ export {$0175d55c2a017ebc$export$fdf4756d5b8ef90a as useTab, $34bce698202e07cb$export$fae0121b5afe572d as useTabPanel, $58d314389b21fa3f$export$773e389e644c5874 as useTabList};
260
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/tabs",
3
- "version": "3.3.5-nightly.3696+be0fae9f7",
3
+ "version": "3.3.5-nightly.3705+93b3c951e",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,15 +22,15 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-aria/focus": "3.0.0-nightly.1996+be0fae9f7",
21
- "@react-aria/i18n": "3.0.0-nightly.1996+be0fae9f7",
22
- "@react-aria/interactions": "3.0.0-nightly.1996+be0fae9f7",
23
- "@react-aria/selection": "3.0.0-nightly.1996+be0fae9f7",
24
- "@react-aria/utils": "3.0.0-nightly.1996+be0fae9f7",
25
- "@react-stately/list": "3.6.2-nightly.3696+be0fae9f7",
26
- "@react-stately/tabs": "3.0.0-nightly.1996+be0fae9f7",
27
- "@react-types/shared": "3.0.0-nightly.1996+be0fae9f7",
28
- "@react-types/tabs": "3.1.6-nightly.3696+be0fae9f7",
25
+ "@react-aria/focus": "3.0.0-nightly.2005+93b3c951e",
26
+ "@react-aria/i18n": "3.0.0-nightly.2005+93b3c951e",
27
+ "@react-aria/interactions": "3.0.0-nightly.2005+93b3c951e",
28
+ "@react-aria/selection": "3.0.0-nightly.2005+93b3c951e",
29
+ "@react-aria/utils": "3.0.0-nightly.2005+93b3c951e",
30
+ "@react-stately/list": "3.6.2-nightly.3705+93b3c951e",
31
+ "@react-stately/tabs": "3.0.0-nightly.2005+93b3c951e",
32
+ "@react-types/shared": "3.0.0-nightly.2005+93b3c951e",
33
+ "@react-types/tabs": "3.1.6-nightly.3705+93b3c951e",
29
34
  "@swc/helpers": "^0.4.14"
30
35
  },
31
36
  "peerDependencies": {
@@ -34,5 +39,5 @@
34
39
  "publishConfig": {
35
40
  "access": "public"
36
41
  },
37
- "gitHead": "be0fae9f7952f4d09823498dc1f251e13842f338"
42
+ "gitHead": "93b3c951eb784b14183f9988f2d188b34de8f42d"
38
43
  }