@react-spectrum/tabs 3.8.9-nightly.4555 → 3.8.9-nightly.4558

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/import.mjs CHANGED
@@ -1,26 +1,6 @@
1
- import "./module.css";
2
- import {Item as $7e899e8977e9ac07$re_export$Item, useCollection as $cLzzU$useCollection} from "@react-stately/collections";
3
- import {useDOMRef as $cLzzU$useDOMRef, useStyleProps as $cLzzU$useStyleProps, classNames as $cLzzU$classNames, SlotProvider as $cLzzU$SlotProvider, unwrapDOMRef as $cLzzU$unwrapDOMRef} from "@react-spectrum/utils";
4
- import {useResizeObserver as $cLzzU$useResizeObserver, useId as $cLzzU$useId, filterDOMProps as $cLzzU$filterDOMProps, mergeProps as $cLzzU$mergeProps, useLayoutEffect as $cLzzU$useLayoutEffect} from "@react-aria/utils";
5
- import {FocusRing as $cLzzU$FocusRing} from "@react-aria/focus";
6
- import {Picker as $cLzzU$Picker, Item as $cLzzU$Item} from "@react-spectrum/picker";
7
- import {ListCollection as $cLzzU$ListCollection} from "@react-stately/list";
8
- import $cLzzU$react, {useRef as $cLzzU$useRef, useState as $cLzzU$useState, useEffect as $cLzzU$useEffect, useCallback as $cLzzU$useCallback, useContext as $cLzzU$useContext} from "react";
9
- import {useTabListState as $cLzzU$useTabListState} from "@react-stately/tabs";
10
- import {Text as $cLzzU$Text} from "@react-spectrum/text";
11
- import {useHover as $cLzzU$useHover} from "@react-aria/interactions";
12
- import {useLocale as $cLzzU$useLocale} from "@react-aria/i18n";
13
- import {useProviderProps as $cLzzU$useProviderProps, useProvider as $cLzzU$useProvider} from "@react-spectrum/provider";
14
- import {useTab as $cLzzU$useTab, useTabList as $cLzzU$useTabList, useTabPanel as $cLzzU$useTabPanel} from "@react-aria/tabs";
1
+ import {TabList as $65ab70ddbed1564b$export$e51a686c67fdaa2d, TabPanels as $65ab70ddbed1564b$export$5dae8d435677f210, Tabs as $65ab70ddbed1564b$export$b2539bed5023c21c} from "./Tabs.mjs";
2
+ import {Item as $7e899e8977e9ac07$re_export$Item} from "@react-stately/collections";
15
3
 
16
-
17
- function $parcel$interopDefault(a) {
18
- return a && a.__esModule ? a.default : a;
19
- }
20
-
21
- function $parcel$export(e, n, v, s) {
22
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
23
- }
24
4
  /*
25
5
  * Copyright 2020 Adobe. All rights reserved.
26
6
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -32,460 +12,6 @@ function $parcel$export(e, n, v, s) {
32
12
  * OF ANY KIND, either express or implied. See the License for the specific language
33
13
  * governing permissions and limitations under the License.
34
14
  */ /// <reference types="css-module-types" />
35
- /*
36
- * Copyright 2020 Adobe. All rights reserved.
37
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
38
- * you may not use this file except in compliance with the License. You may obtain a copy
39
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
40
- *
41
- * Unless required by applicable law or agreed to in writing, software distributed under
42
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
43
- * OF ANY KIND, either express or implied. See the License for the specific language
44
- * governing permissions and limitations under the License.
45
- */
46
-
47
-
48
-
49
-
50
-
51
- var $32d597b82a7aad64$exports = {};
52
-
53
- $parcel$export($32d597b82a7aad64$exports, "focus-ring", () => $32d597b82a7aad64$export$f39a09f249340e2a, (v) => $32d597b82a7aad64$export$f39a09f249340e2a = v);
54
- $parcel$export($32d597b82a7aad64$exports, "i18nFontFamily", () => $32d597b82a7aad64$export$8c4ee2c50c22c514, (v) => $32d597b82a7aad64$export$8c4ee2c50c22c514 = v);
55
- $parcel$export($32d597b82a7aad64$exports, "is-disabled", () => $32d597b82a7aad64$export$d35bc1e505d1ebbf, (v) => $32d597b82a7aad64$export$d35bc1e505d1ebbf = v);
56
- $parcel$export($32d597b82a7aad64$exports, "is-hovered", () => $32d597b82a7aad64$export$b8813cd5d7824ce7, (v) => $32d597b82a7aad64$export$b8813cd5d7824ce7 = v);
57
- $parcel$export($32d597b82a7aad64$exports, "is-selected", () => $32d597b82a7aad64$export$1e0fb04f31d3c22a, (v) => $32d597b82a7aad64$export$1e0fb04f31d3c22a = v);
58
- $parcel$export($32d597b82a7aad64$exports, "spectrum-FocusRing-ring", () => $32d597b82a7aad64$export$4109102f950813a6, (v) => $32d597b82a7aad64$export$4109102f950813a6 = v);
59
- $parcel$export($32d597b82a7aad64$exports, "spectrum-FocusRing", () => $32d597b82a7aad64$export$24c7f46a6e3605dd, (v) => $32d597b82a7aad64$export$24c7f46a6e3605dd = v);
60
- $parcel$export($32d597b82a7aad64$exports, "spectrum-FocusRing--quiet", () => $32d597b82a7aad64$export$2927016961429360, (v) => $32d597b82a7aad64$export$2927016961429360 = v);
61
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Icon", () => $32d597b82a7aad64$export$d374b04f30360026, (v) => $32d597b82a7aad64$export$d374b04f30360026 = v);
62
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs", () => $32d597b82a7aad64$export$35c105c0d9c8e56f, (v) => $32d597b82a7aad64$export$35c105c0d9c8e56f = v);
63
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs--compact", () => $32d597b82a7aad64$export$e15c78184ee03abe, (v) => $32d597b82a7aad64$export$e15c78184ee03abe = v);
64
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs--emphasized", () => $32d597b82a7aad64$export$87b15021e28e067a, (v) => $32d597b82a7aad64$export$87b15021e28e067a = v);
65
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs--horizontal", () => $32d597b82a7aad64$export$229f1ac4d3d38f0e, (v) => $32d597b82a7aad64$export$229f1ac4d3d38f0e = v);
66
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs--isCollapsed", () => $32d597b82a7aad64$export$ea514cd060922d6b, (v) => $32d597b82a7aad64$export$ea514cd060922d6b = v);
67
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs--quiet", () => $32d597b82a7aad64$export$831e830d5828d42b, (v) => $32d597b82a7aad64$export$831e830d5828d42b = v);
68
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs--vertical", () => $32d597b82a7aad64$export$e415005be3957065, (v) => $32d597b82a7aad64$export$e415005be3957065 = v);
69
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs-item", () => $32d597b82a7aad64$export$123e4c01a5440a3e, (v) => $32d597b82a7aad64$export$123e4c01a5440a3e = v);
70
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs-itemLabel", () => $32d597b82a7aad64$export$1f253edac4b98526, (v) => $32d597b82a7aad64$export$1f253edac4b98526 = v);
71
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs-picker", () => $32d597b82a7aad64$export$12dc6b25c6dddfc1, (v) => $32d597b82a7aad64$export$12dc6b25c6dddfc1 = v);
72
- $parcel$export($32d597b82a7aad64$exports, "spectrum-Tabs-selectionIndicator", () => $32d597b82a7aad64$export$a115f9117a19563e, (v) => $32d597b82a7aad64$export$a115f9117a19563e = v);
73
- $parcel$export($32d597b82a7aad64$exports, "spectrum-TabsPanel", () => $32d597b82a7aad64$export$34f1a65c57bb7bb, (v) => $32d597b82a7aad64$export$34f1a65c57bb7bb = v);
74
- $parcel$export($32d597b82a7aad64$exports, "spectrum-TabsPanel--horizontal", () => $32d597b82a7aad64$export$778fb839eaa0528c, (v) => $32d597b82a7aad64$export$778fb839eaa0528c = v);
75
- $parcel$export($32d597b82a7aad64$exports, "spectrum-TabsPanel--vertical", () => $32d597b82a7aad64$export$9a6e2fb72c648072, (v) => $32d597b82a7aad64$export$9a6e2fb72c648072 = v);
76
- $parcel$export($32d597b82a7aad64$exports, "spectrum-TabsPanel-collapseWrapper", () => $32d597b82a7aad64$export$e09869956b4c96f2, (v) => $32d597b82a7aad64$export$e09869956b4c96f2 = v);
77
- $parcel$export($32d597b82a7aad64$exports, "spectrum-TabsPanel-tabpanel", () => $32d597b82a7aad64$export$acb5da0970288266, (v) => $32d597b82a7aad64$export$acb5da0970288266 = v);
78
- $parcel$export($32d597b82a7aad64$exports, "spectrum-TabsPanel-tabs", () => $32d597b82a7aad64$export$4a157a691c854e23, (v) => $32d597b82a7aad64$export$4a157a691c854e23 = v);
79
- var $32d597b82a7aad64$export$f39a09f249340e2a;
80
- var $32d597b82a7aad64$export$8c4ee2c50c22c514;
81
- var $32d597b82a7aad64$export$d35bc1e505d1ebbf;
82
- var $32d597b82a7aad64$export$b8813cd5d7824ce7;
83
- var $32d597b82a7aad64$export$1e0fb04f31d3c22a;
84
- var $32d597b82a7aad64$export$4109102f950813a6;
85
- var $32d597b82a7aad64$export$24c7f46a6e3605dd;
86
- var $32d597b82a7aad64$export$2927016961429360;
87
- var $32d597b82a7aad64$export$d374b04f30360026;
88
- var $32d597b82a7aad64$export$35c105c0d9c8e56f;
89
- var $32d597b82a7aad64$export$e15c78184ee03abe;
90
- var $32d597b82a7aad64$export$87b15021e28e067a;
91
- var $32d597b82a7aad64$export$229f1ac4d3d38f0e;
92
- var $32d597b82a7aad64$export$ea514cd060922d6b;
93
- var $32d597b82a7aad64$export$831e830d5828d42b;
94
- var $32d597b82a7aad64$export$e415005be3957065;
95
- var $32d597b82a7aad64$export$123e4c01a5440a3e;
96
- var $32d597b82a7aad64$export$1f253edac4b98526;
97
- var $32d597b82a7aad64$export$12dc6b25c6dddfc1;
98
- var $32d597b82a7aad64$export$a115f9117a19563e;
99
- var $32d597b82a7aad64$export$34f1a65c57bb7bb;
100
- var $32d597b82a7aad64$export$778fb839eaa0528c;
101
- var $32d597b82a7aad64$export$9a6e2fb72c648072;
102
- var $32d597b82a7aad64$export$e09869956b4c96f2;
103
- var $32d597b82a7aad64$export$acb5da0970288266;
104
- var $32d597b82a7aad64$export$4a157a691c854e23;
105
- $32d597b82a7aad64$export$f39a09f249340e2a = `FzVSrW_focus-ring`;
106
- $32d597b82a7aad64$export$8c4ee2c50c22c514 = `FzVSrW_i18nFontFamily`;
107
- $32d597b82a7aad64$export$d35bc1e505d1ebbf = `FzVSrW_is-disabled`;
108
- $32d597b82a7aad64$export$b8813cd5d7824ce7 = `FzVSrW_is-hovered`;
109
- $32d597b82a7aad64$export$1e0fb04f31d3c22a = `FzVSrW_is-selected`;
110
- $32d597b82a7aad64$export$4109102f950813a6 = `FzVSrW_spectrum-FocusRing-ring`;
111
- $32d597b82a7aad64$export$24c7f46a6e3605dd = `FzVSrW_spectrum-FocusRing ${$32d597b82a7aad64$export$4109102f950813a6}`;
112
- $32d597b82a7aad64$export$2927016961429360 = `FzVSrW_spectrum-FocusRing--quiet`;
113
- $32d597b82a7aad64$export$d374b04f30360026 = `FzVSrW_spectrum-Icon`;
114
- $32d597b82a7aad64$export$35c105c0d9c8e56f = `FzVSrW_spectrum-Tabs`;
115
- $32d597b82a7aad64$export$e15c78184ee03abe = `FzVSrW_spectrum-Tabs--compact`;
116
- $32d597b82a7aad64$export$87b15021e28e067a = `FzVSrW_spectrum-Tabs--emphasized`;
117
- $32d597b82a7aad64$export$229f1ac4d3d38f0e = `FzVSrW_spectrum-Tabs--horizontal`;
118
- $32d597b82a7aad64$export$ea514cd060922d6b = `FzVSrW_spectrum-Tabs--isCollapsed`;
119
- $32d597b82a7aad64$export$831e830d5828d42b = `FzVSrW_spectrum-Tabs--quiet`;
120
- $32d597b82a7aad64$export$e415005be3957065 = `FzVSrW_spectrum-Tabs--vertical`;
121
- $32d597b82a7aad64$export$123e4c01a5440a3e = `FzVSrW_spectrum-Tabs-item`;
122
- $32d597b82a7aad64$export$1f253edac4b98526 = `FzVSrW_spectrum-Tabs-itemLabel`;
123
- $32d597b82a7aad64$export$12dc6b25c6dddfc1 = `FzVSrW_spectrum-Tabs-picker`;
124
- $32d597b82a7aad64$export$a115f9117a19563e = `FzVSrW_spectrum-Tabs-selectionIndicator`;
125
- $32d597b82a7aad64$export$34f1a65c57bb7bb = `FzVSrW_spectrum-TabsPanel`;
126
- $32d597b82a7aad64$export$778fb839eaa0528c = `FzVSrW_spectrum-TabsPanel--horizontal`;
127
- $32d597b82a7aad64$export$9a6e2fb72c648072 = `FzVSrW_spectrum-TabsPanel--vertical`;
128
- $32d597b82a7aad64$export$e09869956b4c96f2 = `FzVSrW_spectrum-TabsPanel-collapseWrapper`;
129
- $32d597b82a7aad64$export$acb5da0970288266 = `FzVSrW_spectrum-TabsPanel-tabpanel`;
130
- $32d597b82a7aad64$export$4a157a691c854e23 = `FzVSrW_spectrum-TabsPanel-tabs`;
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
- const $65ab70ddbed1564b$var$TabContext = /*#__PURE__*/ (0, $cLzzU$react).createContext(null);
141
- function $65ab70ddbed1564b$var$Tabs(props, ref) {
142
- props = (0, $cLzzU$useProviderProps)(props);
143
- let { orientation: orientation = "horizontal", density: density = "regular", children: children, ...otherProps } = props;
144
- let domRef = (0, $cLzzU$useDOMRef)(ref);
145
- let tablistRef = (0, $cLzzU$useRef)();
146
- let wrapperRef = (0, $cLzzU$useRef)();
147
- let { direction: direction } = (0, $cLzzU$useLocale)();
148
- let { styleProps: styleProps } = (0, $cLzzU$useStyleProps)(otherProps);
149
- let [collapsed, setCollapsed] = (0, $cLzzU$useState)(false);
150
- let [selectedTab, setSelectedTab] = (0, $cLzzU$useState)();
151
- const [tabListState, setTabListState] = (0, $cLzzU$useState)(null);
152
- let [tabPositions, setTabPositions] = (0, $cLzzU$useState)([]);
153
- let prevTabPositions = (0, $cLzzU$useRef)(tabPositions);
154
- (0, $cLzzU$useEffect)(()=>{
155
- if (tablistRef.current) {
156
- var _tabListState_selectedKey;
157
- let selectedTab = tablistRef.current.querySelector(`[data-key="${CSS.escape(tabListState === null || tabListState === void 0 ? void 0 : (_tabListState_selectedKey = tabListState.selectedKey) === null || _tabListState_selectedKey === void 0 ? void 0 : _tabListState_selectedKey.toString())}"]`);
158
- if (selectedTab != null) setSelectedTab(selectedTab);
159
- }
160
- // collapse is in the dep array so selectedTab can be updated for TabLine positioning
161
- }, [
162
- children,
163
- tabListState === null || tabListState === void 0 ? void 0 : tabListState.selectedKey,
164
- collapsed,
165
- tablistRef
166
- ]);
167
- let checkShouldCollapse = (0, $cLzzU$useCallback)(()=>{
168
- if (wrapperRef.current && orientation !== "vertical") {
169
- let tabsComponent = wrapperRef.current;
170
- let tabs = tablistRef.current.querySelectorAll('[role="tab"]');
171
- let tabDimensions = [
172
- ...tabs
173
- ].map((tab)=>tab.getBoundingClientRect());
174
- let end = direction === "rtl" ? "left" : "right";
175
- let farEdgeTabList = tabsComponent.getBoundingClientRect()[end];
176
- let farEdgeLastTab = tabDimensions[tabDimensions.length - 1][end];
177
- let shouldCollapse = direction === "rtl" ? farEdgeLastTab < farEdgeTabList : farEdgeTabList < farEdgeLastTab;
178
- setCollapsed(shouldCollapse);
179
- if (tabDimensions.length !== prevTabPositions.current.length || tabDimensions.some((box, index)=>{
180
- var _prevTabPositions_current_index, _prevTabPositions_current_index1;
181
- return (box === null || box === void 0 ? void 0 : box.left) !== ((_prevTabPositions_current_index = prevTabPositions.current[index]) === null || _prevTabPositions_current_index === void 0 ? void 0 : _prevTabPositions_current_index.left) || (box === null || box === void 0 ? void 0 : box.right) !== ((_prevTabPositions_current_index1 = prevTabPositions.current[index]) === null || _prevTabPositions_current_index1 === void 0 ? void 0 : _prevTabPositions_current_index1.right);
182
- })) {
183
- setTabPositions(tabDimensions);
184
- prevTabPositions.current = tabDimensions;
185
- }
186
- }
187
- }, [
188
- tablistRef,
189
- wrapperRef,
190
- direction,
191
- orientation,
192
- setCollapsed,
193
- prevTabPositions,
194
- setTabPositions
195
- ]);
196
- (0, $cLzzU$useEffect)(()=>{
197
- checkShouldCollapse();
198
- }, [
199
- children,
200
- checkShouldCollapse
201
- ]);
202
- (0, $cLzzU$useResizeObserver)({
203
- ref: wrapperRef,
204
- onResize: checkShouldCollapse
205
- });
206
- let tabPanelProps = {
207
- "aria-labelledby": undefined
208
- };
209
- // When the tabs are collapsed, the tabPanel should be labelled by the Picker button element.
210
- let collapsibleTabListId = (0, $cLzzU$useId)();
211
- if (collapsed && orientation !== "vertical") tabPanelProps["aria-labelledby"] = collapsibleTabListId;
212
- return /*#__PURE__*/ (0, $cLzzU$react).createElement($65ab70ddbed1564b$var$TabContext.Provider, {
213
- value: {
214
- tabProps: {
215
- ...props,
216
- orientation: orientation,
217
- density: density
218
- },
219
- tabState: {
220
- tabListState: tabListState,
221
- setTabListState: setTabListState,
222
- selectedTab: selectedTab,
223
- collapsed: collapsed
224
- },
225
- refs: {
226
- tablistRef: tablistRef,
227
- wrapperRef: wrapperRef
228
- },
229
- tabPanelProps: tabPanelProps,
230
- tabLineState: tabPositions
231
- }
232
- }, /*#__PURE__*/ (0, $cLzzU$react).createElement("div", {
233
- ...(0, $cLzzU$filterDOMProps)(otherProps),
234
- ...styleProps,
235
- ref: domRef,
236
- className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-TabsPanel", `spectrum-TabsPanel--${orientation}`, styleProps.className)
237
- }, props.children));
238
- }
239
- // @private
240
- function $65ab70ddbed1564b$var$Tab(props) {
241
- let { item: item, state: state } = props;
242
- let { key: key, rendered: rendered } = item;
243
- let ref = (0, $cLzzU$useRef)();
244
- let { tabProps: tabProps, isSelected: isSelected, isDisabled: isDisabled } = (0, $cLzzU$useTab)({
245
- key: key
246
- }, state, ref);
247
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $cLzzU$useHover)({
248
- ...props
249
- });
250
- let ElementType = item.props.href ? "a" : "div";
251
- return /*#__PURE__*/ (0, $cLzzU$react).createElement((0, $cLzzU$FocusRing), {
252
- focusRingClass: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "focus-ring")
253
- }, /*#__PURE__*/ (0, $cLzzU$react).createElement(ElementType, {
254
- ...(0, $cLzzU$mergeProps)(tabProps, hoverProps),
255
- ref: ref,
256
- className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Tabs-item", {
257
- "is-selected": isSelected,
258
- "is-disabled": isDisabled,
259
- "is-hovered": isHovered
260
- })
261
- }, /*#__PURE__*/ (0, $cLzzU$react).createElement((0, $cLzzU$SlotProvider), {
262
- slots: {
263
- icon: {
264
- size: "S",
265
- UNSAFE_className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Icon")
266
- },
267
- text: {
268
- UNSAFE_className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Tabs-itemLabel")
269
- }
270
- }
271
- }, typeof rendered === "string" ? /*#__PURE__*/ (0, $cLzzU$react).createElement((0, $cLzzU$Text), null, rendered) : rendered)));
272
- }
273
- // @private
274
- function $65ab70ddbed1564b$var$TabLine(props) {
275
- let { orientation: orientation, selectedTab: // Is either the tab node (non-collapsed) or the picker node (collapsed)
276
- selectedTab, selectedKey: // selectedKey is provided so that the TabLine styles are updated when the TabPicker's width updates from a selection change
277
- selectedKey } = props;
278
- let { direction: direction } = (0, $cLzzU$useLocale)();
279
- let { scale: scale } = (0, $cLzzU$useProvider)();
280
- let { tabLineState: tabLineState } = (0, $cLzzU$useContext)($65ab70ddbed1564b$var$TabContext);
281
- let [style, setStyle] = (0, $cLzzU$useState)({
282
- width: undefined,
283
- height: undefined
284
- });
285
- let onResize = (0, $cLzzU$useCallback)(()=>{
286
- if (selectedTab) {
287
- var _selectedTab_offsetParent;
288
- let styleObj = {
289
- transform: undefined,
290
- width: undefined,
291
- height: undefined
292
- };
293
- // In RTL, calculate the transform from the right edge of the tablist so that resizing the window doesn't break the Tabline position due to offsetLeft changes
294
- let offset = direction === "rtl" ? -1 * (((_selectedTab_offsetParent = selectedTab.offsetParent) === null || _selectedTab_offsetParent === void 0 ? void 0 : _selectedTab_offsetParent.offsetWidth) - selectedTab.offsetWidth - selectedTab.offsetLeft) : selectedTab.offsetLeft;
295
- styleObj.transform = orientation === "vertical" ? `translateY(${selectedTab.offsetTop}px)` : `translateX(${offset}px)`;
296
- if (orientation === "horizontal") styleObj.width = `${selectedTab.offsetWidth}px`;
297
- else styleObj.height = `${selectedTab.offsetHeight}px`;
298
- setStyle(styleObj);
299
- }
300
- }, [
301
- direction,
302
- setStyle,
303
- selectedTab,
304
- orientation
305
- ]);
306
- (0, $cLzzU$useLayoutEffect)(()=>{
307
- onResize();
308
- }, [
309
- onResize,
310
- scale,
311
- selectedKey,
312
- tabLineState
313
- ]);
314
- return /*#__PURE__*/ (0, $cLzzU$react).createElement("div", {
315
- className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Tabs-selectionIndicator"),
316
- role: "presentation",
317
- style: style
318
- });
319
- }
320
- function $65ab70ddbed1564b$export$e51a686c67fdaa2d(props) {
321
- const tabContext = (0, $cLzzU$useContext)($65ab70ddbed1564b$var$TabContext);
322
- const { refs: refs, tabState: tabState, tabProps: tabProps, tabPanelProps: tabPanelProps } = tabContext;
323
- const { isQuiet: isQuiet, density: density, isEmphasized: isEmphasized, orientation: orientation } = tabProps;
324
- const { selectedTab: selectedTab, collapsed: collapsed, setTabListState: setTabListState } = tabState;
325
- const { tablistRef: tablistRef, wrapperRef: wrapperRef } = refs;
326
- // Pass original Tab props but override children to create the collection.
327
- const state = (0, $cLzzU$useTabListState)({
328
- ...tabProps,
329
- children: props.children
330
- });
331
- let { styleProps: styleProps } = (0, $cLzzU$useStyleProps)(props);
332
- const { tabListProps: tabListProps } = (0, $cLzzU$useTabList)({
333
- ...tabProps,
334
- ...props
335
- }, state, tablistRef);
336
- (0, $cLzzU$useEffect)(()=>{
337
- // Passing back to root as useTabPanel needs the TabListState
338
- setTabListState(state);
339
- // eslint-disable-next-line react-hooks/exhaustive-deps
340
- }, [
341
- state.disabledKeys,
342
- state.selectedItem,
343
- state.selectedKey,
344
- props.children
345
- ]);
346
- let collapseStyle = collapsed && orientation !== "vertical" ? {
347
- maxWidth: "calc(100% + 1px)",
348
- overflow: "hidden",
349
- visibility: "hidden",
350
- position: "absolute"
351
- } : {
352
- maxWidth: "calc(100% + 1px)"
353
- };
354
- let stylePropsFinal = orientation === "vertical" ? styleProps : {
355
- style: collapseStyle
356
- };
357
- if (collapsed && orientation !== "vertical") tabListProps["aria-hidden"] = true;
358
- let tabListclassName = (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-TabsPanel-tabs");
359
- const tabContent = /*#__PURE__*/ (0, $cLzzU$react).createElement("div", {
360
- ...stylePropsFinal,
361
- ...tabListProps,
362
- ref: tablistRef,
363
- className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Tabs", `spectrum-Tabs--${orientation}`, tabListclassName, {
364
- "spectrum-Tabs--quiet": isQuiet,
365
- "spectrum-Tabs--emphasized": isEmphasized,
366
- ["spectrum-Tabs--compact"]: density === "compact"
367
- }, orientation === "vertical" && styleProps.className)
368
- }, [
369
- ...state.collection
370
- ].map((item)=>/*#__PURE__*/ (0, $cLzzU$react).createElement($65ab70ddbed1564b$var$Tab, {
371
- key: item.key,
372
- item: item,
373
- state: state,
374
- orientation: orientation
375
- })), /*#__PURE__*/ (0, $cLzzU$react).createElement($65ab70ddbed1564b$var$TabLine, {
376
- orientation: orientation,
377
- selectedTab: selectedTab
378
- }));
379
- if (orientation === "vertical") return tabContent;
380
- else return /*#__PURE__*/ (0, $cLzzU$react).createElement("div", {
381
- ...styleProps,
382
- ref: wrapperRef,
383
- className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-TabsPanel-collapseWrapper", styleProps.className)
384
- }, /*#__PURE__*/ (0, $cLzzU$react).createElement($65ab70ddbed1564b$var$TabPicker, {
385
- ...props,
386
- ...tabProps,
387
- visible: collapsed,
388
- id: tabPanelProps["aria-labelledby"],
389
- state: state,
390
- className: tabListclassName
391
- }), tabContent);
392
- }
393
- function $65ab70ddbed1564b$export$5dae8d435677f210(props) {
394
- const { tabState: tabState, tabProps: tabProps } = (0, $cLzzU$useContext)($65ab70ddbed1564b$var$TabContext);
395
- const { tabListState: tabListState } = tabState;
396
- const factory = (0, $cLzzU$useCallback)((nodes)=>new (0, $cLzzU$ListCollection)(nodes), []);
397
- const collection = (0, $cLzzU$useCollection)({
398
- items: tabProps.items,
399
- ...props
400
- }, factory, {
401
- suppressTextValueWarning: true
402
- });
403
- const selectedItem = tabListState ? collection.getItem(tabListState.selectedKey) : null;
404
- return /*#__PURE__*/ (0, $cLzzU$react).createElement($65ab70ddbed1564b$var$TabPanel, {
405
- ...props,
406
- key: tabListState === null || tabListState === void 0 ? void 0 : tabListState.selectedKey
407
- }, selectedItem && selectedItem.props.children);
408
- }
409
- // @private
410
- function $65ab70ddbed1564b$var$TabPanel(props) {
411
- const { tabState: tabState, tabPanelProps: ctxTabPanelProps } = (0, $cLzzU$useContext)($65ab70ddbed1564b$var$TabContext);
412
- const { tabListState: tabListState } = tabState;
413
- let ref = (0, $cLzzU$useRef)();
414
- const { tabPanelProps: tabPanelProps } = (0, $cLzzU$useTabPanel)(props, tabListState, ref);
415
- let { styleProps: styleProps } = (0, $cLzzU$useStyleProps)(props);
416
- if (ctxTabPanelProps["aria-labelledby"]) tabPanelProps["aria-labelledby"] = ctxTabPanelProps["aria-labelledby"];
417
- return /*#__PURE__*/ (0, $cLzzU$react).createElement((0, $cLzzU$FocusRing), {
418
- focusRingClass: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "focus-ring")
419
- }, /*#__PURE__*/ (0, $cLzzU$react).createElement("div", {
420
- ...styleProps,
421
- ...tabPanelProps,
422
- ref: ref,
423
- className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-TabsPanel-tabpanel", styleProps.className)
424
- }, props.children));
425
- }
426
- function $65ab70ddbed1564b$var$TabPicker(props) {
427
- let { isDisabled: isDisabled, isEmphasized: isEmphasized, isQuiet: isQuiet, state: state, "aria-labelledby": ariaLabeledBy, "aria-label": ariaLabel, density: density, className: className, id: id, visible: visible } = props;
428
- let ref = (0, $cLzzU$useRef)();
429
- let [pickerNode, setPickerNode] = (0, $cLzzU$useState)(null);
430
- (0, $cLzzU$useEffect)(()=>{
431
- let node = (0, $cLzzU$unwrapDOMRef)(ref);
432
- setPickerNode(node.current);
433
- }, [
434
- ref
435
- ]);
436
- let items = [
437
- ...state.collection
438
- ];
439
- let pickerProps = {
440
- "aria-labelledby": ariaLabeledBy,
441
- "aria-label": ariaLabel
442
- };
443
- const style = visible ? {} : {
444
- visibility: "hidden",
445
- position: "absolute"
446
- };
447
- // TODO: Figure out if tabListProps should go onto the div here, v2 doesn't do it
448
- return /*#__PURE__*/ (0, $cLzzU$react).createElement("div", {
449
- className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Tabs", "spectrum-Tabs--horizontal", "spectrum-Tabs--isCollapsed", {
450
- "spectrum-Tabs--quiet": isQuiet,
451
- ["spectrum-Tabs--compact"]: density === "compact",
452
- "spectrum-Tabs--emphasized": isEmphasized
453
- }, className),
454
- style: style,
455
- "aria-hidden": visible ? undefined : true
456
- }, /*#__PURE__*/ (0, $cLzzU$react).createElement((0, $cLzzU$SlotProvider), {
457
- slots: {
458
- icon: {
459
- size: "S",
460
- UNSAFE_className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Icon")
461
- },
462
- button: {
463
- focusRingClass: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "focus-ring")
464
- }
465
- }
466
- }, /*#__PURE__*/ (0, $cLzzU$react).createElement((0, $cLzzU$Picker), {
467
- ...pickerProps,
468
- id: id,
469
- items: items,
470
- ref: ref,
471
- isQuiet: true,
472
- isDisabled: !visible || isDisabled,
473
- selectedKey: state.selectedKey,
474
- disabledKeys: state.disabledKeys,
475
- onSelectionChange: state.setSelectedKey,
476
- UNSAFE_className: (0, $cLzzU$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($32d597b82a7aad64$exports))), "spectrum-Tabs-picker")
477
- }, (item)=>/*#__PURE__*/ (0, $cLzzU$react).createElement((0, $cLzzU$Item), item.props, item.rendered)), pickerNode && /*#__PURE__*/ (0, $cLzzU$react).createElement($65ab70ddbed1564b$var$TabLine, {
478
- orientation: "horizontal",
479
- selectedTab: pickerNode,
480
- selectedKey: state.selectedKey
481
- })));
482
- }
483
- /**
484
- * Tabs organize content into multiple sections and allow users to navigate between them. The content under the set of tabs should be related and form a coherent unit.
485
- */ // forwardRef doesn't support generic parameters, so cast the result to the correct type
486
- // https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
487
- const $65ab70ddbed1564b$export$b2539bed5023c21c = /*#__PURE__*/ (0, $cLzzU$react).forwardRef($65ab70ddbed1564b$var$Tabs);
488
-
489
15
 
490
16
 
491
17