@react-spectrum/tabs 3.8.10-nightly.4623 → 3.8.10
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/Tabs.main.js +54 -54
- package/dist/Tabs.mjs +54 -54
- package/dist/Tabs.module.js +54 -54
- package/package.json +17 -17
package/dist/Tabs.main.js
CHANGED
|
@@ -53,7 +53,7 @@ $parcel$export(module.exports, "Tabs", () => $e8d58e7e32285ba6$export$b2539bed50
|
|
|
53
53
|
const $e8d58e7e32285ba6$var$TabContext = /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createContext(null);
|
|
54
54
|
function $e8d58e7e32285ba6$var$Tabs(props, ref) {
|
|
55
55
|
props = (0, $31o9C$reactspectrumprovider.useProviderProps)(props);
|
|
56
|
-
let { orientation: orientation =
|
|
56
|
+
let { orientation: orientation = 'horizontal', density: density = 'regular', children: children, ...otherProps } = props;
|
|
57
57
|
let domRef = (0, $31o9C$reactspectrumutils.useDOMRef)(ref);
|
|
58
58
|
let tablistRef = (0, $31o9C$react.useRef)();
|
|
59
59
|
let wrapperRef = (0, $31o9C$react.useRef)();
|
|
@@ -78,16 +78,16 @@ function $e8d58e7e32285ba6$var$Tabs(props, ref) {
|
|
|
78
78
|
tablistRef
|
|
79
79
|
]);
|
|
80
80
|
let checkShouldCollapse = (0, $31o9C$react.useCallback)(()=>{
|
|
81
|
-
if (wrapperRef.current && orientation !==
|
|
81
|
+
if (wrapperRef.current && orientation !== 'vertical') {
|
|
82
82
|
let tabsComponent = wrapperRef.current;
|
|
83
83
|
let tabs = tablistRef.current.querySelectorAll('[role="tab"]');
|
|
84
84
|
let tabDimensions = [
|
|
85
85
|
...tabs
|
|
86
86
|
].map((tab)=>tab.getBoundingClientRect());
|
|
87
|
-
let end = direction ===
|
|
87
|
+
let end = direction === 'rtl' ? 'left' : 'right';
|
|
88
88
|
let farEdgeTabList = tabsComponent.getBoundingClientRect()[end];
|
|
89
89
|
let farEdgeLastTab = tabDimensions[tabDimensions.length - 1][end];
|
|
90
|
-
let shouldCollapse = direction ===
|
|
90
|
+
let shouldCollapse = direction === 'rtl' ? farEdgeLastTab < farEdgeTabList : farEdgeTabList < farEdgeLastTab;
|
|
91
91
|
setCollapsed(shouldCollapse);
|
|
92
92
|
if (tabDimensions.length !== prevTabPositions.current.length || tabDimensions.some((box, index)=>{
|
|
93
93
|
var _prevTabPositions_current_index, _prevTabPositions_current_index1;
|
|
@@ -117,11 +117,11 @@ function $e8d58e7e32285ba6$var$Tabs(props, ref) {
|
|
|
117
117
|
onResize: checkShouldCollapse
|
|
118
118
|
});
|
|
119
119
|
let tabPanelProps = {
|
|
120
|
-
|
|
120
|
+
'aria-labelledby': undefined
|
|
121
121
|
};
|
|
122
122
|
// When the tabs are collapsed, the tabPanel should be labelled by the Picker button element.
|
|
123
123
|
let collapsibleTabListId = (0, $31o9C$reactariautils.useId)();
|
|
124
|
-
if (collapsed && orientation !==
|
|
124
|
+
if (collapsed && orientation !== 'vertical') tabPanelProps['aria-labelledby'] = collapsibleTabListId;
|
|
125
125
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement($e8d58e7e32285ba6$var$TabContext.Provider, {
|
|
126
126
|
value: {
|
|
127
127
|
tabProps: {
|
|
@@ -146,7 +146,7 @@ function $e8d58e7e32285ba6$var$Tabs(props, ref) {
|
|
|
146
146
|
...(0, $31o9C$reactariautils.filterDOMProps)(otherProps),
|
|
147
147
|
...styleProps,
|
|
148
148
|
ref: domRef,
|
|
149
|
-
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
149
|
+
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-TabsPanel', `spectrum-TabsPanel--${orientation}`, styleProps.className)
|
|
150
150
|
}, props.children));
|
|
151
151
|
}
|
|
152
152
|
// @private
|
|
@@ -160,28 +160,28 @@ function $e8d58e7e32285ba6$var$Tab(props) {
|
|
|
160
160
|
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $31o9C$reactariainteractions.useHover)({
|
|
161
161
|
...props
|
|
162
162
|
});
|
|
163
|
-
let ElementType = item.props.href ?
|
|
163
|
+
let ElementType = item.props.href ? 'a' : 'div';
|
|
164
164
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement((0, $31o9C$reactariafocus.FocusRing), {
|
|
165
|
-
focusRingClass: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
165
|
+
focusRingClass: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'focus-ring')
|
|
166
166
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement(ElementType, {
|
|
167
167
|
...(0, $31o9C$reactariautils.mergeProps)(tabProps, hoverProps),
|
|
168
168
|
ref: ref,
|
|
169
|
-
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Tabs-item', {
|
|
170
|
+
'is-selected': isSelected,
|
|
171
|
+
'is-disabled': isDisabled,
|
|
172
|
+
'is-hovered': isHovered
|
|
173
173
|
})
|
|
174
174
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement((0, $31o9C$reactspectrumutils.SlotProvider), {
|
|
175
175
|
slots: {
|
|
176
176
|
icon: {
|
|
177
|
-
size:
|
|
178
|
-
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
177
|
+
size: 'S',
|
|
178
|
+
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Icon')
|
|
179
179
|
},
|
|
180
180
|
text: {
|
|
181
|
-
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
181
|
+
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Tabs-itemLabel')
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
}, typeof rendered ===
|
|
184
|
+
}, typeof rendered === 'string' ? /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement((0, $31o9C$reactspectrumtext.Text), null, rendered) : rendered)));
|
|
185
185
|
}
|
|
186
186
|
// @private
|
|
187
187
|
function $e8d58e7e32285ba6$var$TabLine(props) {
|
|
@@ -204,9 +204,9 @@ function $e8d58e7e32285ba6$var$TabLine(props) {
|
|
|
204
204
|
height: undefined
|
|
205
205
|
};
|
|
206
206
|
// 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
|
|
207
|
-
let offset = direction ===
|
|
208
|
-
styleObj.transform = orientation ===
|
|
209
|
-
if (orientation ===
|
|
207
|
+
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;
|
|
208
|
+
styleObj.transform = orientation === 'vertical' ? `translateY(${selectedTab.offsetTop}px)` : `translateX(${offset}px)`;
|
|
209
|
+
if (orientation === 'horizontal') styleObj.width = `${selectedTab.offsetWidth}px`;
|
|
210
210
|
else styleObj.height = `${selectedTab.offsetHeight}px`;
|
|
211
211
|
setStyle(styleObj);
|
|
212
212
|
}
|
|
@@ -225,7 +225,7 @@ function $e8d58e7e32285ba6$var$TabLine(props) {
|
|
|
225
225
|
tabLineState
|
|
226
226
|
]);
|
|
227
227
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement("div", {
|
|
228
|
-
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
228
|
+
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Tabs-selectionIndicator'),
|
|
229
229
|
role: "presentation",
|
|
230
230
|
style: style
|
|
231
231
|
});
|
|
@@ -256,28 +256,28 @@ function $e8d58e7e32285ba6$export$e51a686c67fdaa2d(props) {
|
|
|
256
256
|
state.selectedKey,
|
|
257
257
|
props.children
|
|
258
258
|
]);
|
|
259
|
-
let collapseStyle = collapsed && orientation !==
|
|
260
|
-
maxWidth:
|
|
261
|
-
overflow:
|
|
262
|
-
visibility:
|
|
263
|
-
position:
|
|
259
|
+
let collapseStyle = collapsed && orientation !== 'vertical' ? {
|
|
260
|
+
maxWidth: 'calc(100% + 1px)',
|
|
261
|
+
overflow: 'hidden',
|
|
262
|
+
visibility: 'hidden',
|
|
263
|
+
position: 'absolute'
|
|
264
264
|
} : {
|
|
265
|
-
maxWidth:
|
|
265
|
+
maxWidth: 'calc(100% + 1px)'
|
|
266
266
|
};
|
|
267
|
-
let stylePropsFinal = orientation ===
|
|
267
|
+
let stylePropsFinal = orientation === 'vertical' ? styleProps : {
|
|
268
268
|
style: collapseStyle
|
|
269
269
|
};
|
|
270
|
-
if (collapsed && orientation !==
|
|
271
|
-
let tabListclassName = (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
270
|
+
if (collapsed && orientation !== 'vertical') tabListProps['aria-hidden'] = true;
|
|
271
|
+
let tabListclassName = (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-TabsPanel-tabs');
|
|
272
272
|
const tabContent = /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement("div", {
|
|
273
273
|
...stylePropsFinal,
|
|
274
274
|
...tabListProps,
|
|
275
275
|
ref: tablistRef,
|
|
276
|
-
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
[
|
|
280
|
-
}, orientation ===
|
|
276
|
+
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Tabs', `spectrum-Tabs--${orientation}`, tabListclassName, {
|
|
277
|
+
'spectrum-Tabs--quiet': isQuiet,
|
|
278
|
+
'spectrum-Tabs--emphasized': isEmphasized,
|
|
279
|
+
['spectrum-Tabs--compact']: density === 'compact'
|
|
280
|
+
}, orientation === 'vertical' && styleProps.className)
|
|
281
281
|
}, [
|
|
282
282
|
...state.collection
|
|
283
283
|
].map((item)=>/*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement($e8d58e7e32285ba6$var$Tab, {
|
|
@@ -289,16 +289,16 @@ function $e8d58e7e32285ba6$export$e51a686c67fdaa2d(props) {
|
|
|
289
289
|
orientation: orientation,
|
|
290
290
|
selectedTab: selectedTab
|
|
291
291
|
}));
|
|
292
|
-
if (orientation ===
|
|
292
|
+
if (orientation === 'vertical') return tabContent;
|
|
293
293
|
else return /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement("div", {
|
|
294
294
|
...styleProps,
|
|
295
295
|
ref: wrapperRef,
|
|
296
|
-
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
296
|
+
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-TabsPanel-collapseWrapper', styleProps.className)
|
|
297
297
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement($e8d58e7e32285ba6$var$TabPicker, {
|
|
298
298
|
...props,
|
|
299
299
|
...tabProps,
|
|
300
300
|
visible: collapsed,
|
|
301
|
-
id: tabPanelProps[
|
|
301
|
+
id: tabPanelProps['aria-labelledby'],
|
|
302
302
|
state: state,
|
|
303
303
|
className: tabListclassName
|
|
304
304
|
}), tabContent);
|
|
@@ -326,18 +326,18 @@ function $e8d58e7e32285ba6$var$TabPanel(props) {
|
|
|
326
326
|
let ref = (0, $31o9C$react.useRef)();
|
|
327
327
|
const { tabPanelProps: tabPanelProps } = (0, $31o9C$reactariatabs.useTabPanel)(props, tabListState, ref);
|
|
328
328
|
let { styleProps: styleProps } = (0, $31o9C$reactspectrumutils.useStyleProps)(props);
|
|
329
|
-
if (ctxTabPanelProps[
|
|
329
|
+
if (ctxTabPanelProps['aria-labelledby']) tabPanelProps['aria-labelledby'] = ctxTabPanelProps['aria-labelledby'];
|
|
330
330
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement((0, $31o9C$reactariafocus.FocusRing), {
|
|
331
|
-
focusRingClass: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
331
|
+
focusRingClass: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'focus-ring')
|
|
332
332
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement("div", {
|
|
333
333
|
...styleProps,
|
|
334
334
|
...tabPanelProps,
|
|
335
335
|
ref: ref,
|
|
336
|
-
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
336
|
+
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-TabsPanel-tabpanel', styleProps.className)
|
|
337
337
|
}, props.children));
|
|
338
338
|
}
|
|
339
339
|
function $e8d58e7e32285ba6$var$TabPicker(props) {
|
|
340
|
-
let { isDisabled: isDisabled, isEmphasized: isEmphasized, isQuiet: isQuiet, state: state,
|
|
340
|
+
let { isDisabled: isDisabled, isEmphasized: isEmphasized, isQuiet: isQuiet, state: state, 'aria-labelledby': ariaLabeledBy, 'aria-label': ariaLabel, density: density, className: className, id: id, visible: visible } = props;
|
|
341
341
|
let ref = (0, $31o9C$react.useRef)();
|
|
342
342
|
let [pickerNode, setPickerNode] = (0, $31o9C$react.useState)(null);
|
|
343
343
|
(0, $31o9C$react.useEffect)(()=>{
|
|
@@ -350,30 +350,30 @@ function $e8d58e7e32285ba6$var$TabPicker(props) {
|
|
|
350
350
|
...state.collection
|
|
351
351
|
];
|
|
352
352
|
let pickerProps = {
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
'aria-labelledby': ariaLabeledBy,
|
|
354
|
+
'aria-label': ariaLabel
|
|
355
355
|
};
|
|
356
356
|
const style = visible ? {} : {
|
|
357
|
-
visibility:
|
|
358
|
-
position:
|
|
357
|
+
visibility: 'hidden',
|
|
358
|
+
position: 'absolute'
|
|
359
359
|
};
|
|
360
360
|
// TODO: Figure out if tabListProps should go onto the div here, v2 doesn't do it
|
|
361
361
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement("div", {
|
|
362
|
-
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
363
|
-
|
|
364
|
-
[
|
|
365
|
-
|
|
362
|
+
className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Tabs', 'spectrum-Tabs--horizontal', 'spectrum-Tabs--isCollapsed', {
|
|
363
|
+
'spectrum-Tabs--quiet': isQuiet,
|
|
364
|
+
['spectrum-Tabs--compact']: density === 'compact',
|
|
365
|
+
'spectrum-Tabs--emphasized': isEmphasized
|
|
366
366
|
}, className),
|
|
367
367
|
style: style,
|
|
368
368
|
"aria-hidden": visible ? undefined : true
|
|
369
369
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement((0, $31o9C$reactspectrumutils.SlotProvider), {
|
|
370
370
|
slots: {
|
|
371
371
|
icon: {
|
|
372
|
-
size:
|
|
373
|
-
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
372
|
+
size: 'S',
|
|
373
|
+
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Icon')
|
|
374
374
|
},
|
|
375
375
|
button: {
|
|
376
|
-
focusRingClass: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
376
|
+
focusRingClass: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'focus-ring')
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
379
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement((0, $31o9C$reactspectrumpicker.Picker), {
|
|
@@ -386,7 +386,7 @@ function $e8d58e7e32285ba6$var$TabPicker(props) {
|
|
|
386
386
|
selectedKey: state.selectedKey,
|
|
387
387
|
disabledKeys: state.disabledKeys,
|
|
388
388
|
onSelectionChange: state.setSelectedKey,
|
|
389
|
-
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))),
|
|
389
|
+
UNSAFE_className: (0, $31o9C$reactspectrumutils.classNames)((0, ($parcel$interopDefault($29add1fad43dc941$exports))), 'spectrum-Tabs-picker')
|
|
390
390
|
}, (item)=>/*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement((0, $31o9C$reactspectrumpicker.Item), item.props, item.rendered)), pickerNode && /*#__PURE__*/ (0, ($parcel$interopDefault($31o9C$react))).createElement($e8d58e7e32285ba6$var$TabLine, {
|
|
391
391
|
orientation: "horizontal",
|
|
392
392
|
selectedTab: pickerNode,
|
package/dist/Tabs.mjs
CHANGED
|
@@ -45,7 +45,7 @@ function $parcel$interopDefault(a) {
|
|
|
45
45
|
const $65ab70ddbed1564b$var$TabContext = /*#__PURE__*/ (0, $14nVg$react).createContext(null);
|
|
46
46
|
function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
47
47
|
props = (0, $14nVg$useProviderProps)(props);
|
|
48
|
-
let { orientation: orientation =
|
|
48
|
+
let { orientation: orientation = 'horizontal', density: density = 'regular', children: children, ...otherProps } = props;
|
|
49
49
|
let domRef = (0, $14nVg$useDOMRef)(ref);
|
|
50
50
|
let tablistRef = (0, $14nVg$useRef)();
|
|
51
51
|
let wrapperRef = (0, $14nVg$useRef)();
|
|
@@ -70,16 +70,16 @@ function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
|
70
70
|
tablistRef
|
|
71
71
|
]);
|
|
72
72
|
let checkShouldCollapse = (0, $14nVg$useCallback)(()=>{
|
|
73
|
-
if (wrapperRef.current && orientation !==
|
|
73
|
+
if (wrapperRef.current && orientation !== 'vertical') {
|
|
74
74
|
let tabsComponent = wrapperRef.current;
|
|
75
75
|
let tabs = tablistRef.current.querySelectorAll('[role="tab"]');
|
|
76
76
|
let tabDimensions = [
|
|
77
77
|
...tabs
|
|
78
78
|
].map((tab)=>tab.getBoundingClientRect());
|
|
79
|
-
let end = direction ===
|
|
79
|
+
let end = direction === 'rtl' ? 'left' : 'right';
|
|
80
80
|
let farEdgeTabList = tabsComponent.getBoundingClientRect()[end];
|
|
81
81
|
let farEdgeLastTab = tabDimensions[tabDimensions.length - 1][end];
|
|
82
|
-
let shouldCollapse = direction ===
|
|
82
|
+
let shouldCollapse = direction === 'rtl' ? farEdgeLastTab < farEdgeTabList : farEdgeTabList < farEdgeLastTab;
|
|
83
83
|
setCollapsed(shouldCollapse);
|
|
84
84
|
if (tabDimensions.length !== prevTabPositions.current.length || tabDimensions.some((box, index)=>{
|
|
85
85
|
var _prevTabPositions_current_index, _prevTabPositions_current_index1;
|
|
@@ -109,11 +109,11 @@ function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
|
109
109
|
onResize: checkShouldCollapse
|
|
110
110
|
});
|
|
111
111
|
let tabPanelProps = {
|
|
112
|
-
|
|
112
|
+
'aria-labelledby': undefined
|
|
113
113
|
};
|
|
114
114
|
// When the tabs are collapsed, the tabPanel should be labelled by the Picker button element.
|
|
115
115
|
let collapsibleTabListId = (0, $14nVg$useId)();
|
|
116
|
-
if (collapsed && orientation !==
|
|
116
|
+
if (collapsed && orientation !== 'vertical') tabPanelProps['aria-labelledby'] = collapsibleTabListId;
|
|
117
117
|
return /*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$TabContext.Provider, {
|
|
118
118
|
value: {
|
|
119
119
|
tabProps: {
|
|
@@ -138,7 +138,7 @@ function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
|
138
138
|
...(0, $14nVg$filterDOMProps)(otherProps),
|
|
139
139
|
...styleProps,
|
|
140
140
|
ref: domRef,
|
|
141
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
141
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel', `spectrum-TabsPanel--${orientation}`, styleProps.className)
|
|
142
142
|
}, props.children));
|
|
143
143
|
}
|
|
144
144
|
// @private
|
|
@@ -152,28 +152,28 @@ function $65ab70ddbed1564b$var$Tab(props) {
|
|
|
152
152
|
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $14nVg$useHover)({
|
|
153
153
|
...props
|
|
154
154
|
});
|
|
155
|
-
let ElementType = item.props.href ?
|
|
155
|
+
let ElementType = item.props.href ? 'a' : 'div';
|
|
156
156
|
return /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$FocusRing), {
|
|
157
|
-
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
157
|
+
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'focus-ring')
|
|
158
158
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement(ElementType, {
|
|
159
159
|
...(0, $14nVg$mergeProps)(tabProps, hoverProps),
|
|
160
160
|
ref: ref,
|
|
161
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-item', {
|
|
162
|
+
'is-selected': isSelected,
|
|
163
|
+
'is-disabled': isDisabled,
|
|
164
|
+
'is-hovered': isHovered
|
|
165
165
|
})
|
|
166
166
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$SlotProvider), {
|
|
167
167
|
slots: {
|
|
168
168
|
icon: {
|
|
169
|
-
size:
|
|
170
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
169
|
+
size: 'S',
|
|
170
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Icon')
|
|
171
171
|
},
|
|
172
172
|
text: {
|
|
173
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
173
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-itemLabel')
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
}, typeof rendered ===
|
|
176
|
+
}, typeof rendered === 'string' ? /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$Text), null, rendered) : rendered)));
|
|
177
177
|
}
|
|
178
178
|
// @private
|
|
179
179
|
function $65ab70ddbed1564b$var$TabLine(props) {
|
|
@@ -196,9 +196,9 @@ function $65ab70ddbed1564b$var$TabLine(props) {
|
|
|
196
196
|
height: undefined
|
|
197
197
|
};
|
|
198
198
|
// 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
|
|
199
|
-
let offset = direction ===
|
|
200
|
-
styleObj.transform = orientation ===
|
|
201
|
-
if (orientation ===
|
|
199
|
+
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;
|
|
200
|
+
styleObj.transform = orientation === 'vertical' ? `translateY(${selectedTab.offsetTop}px)` : `translateX(${offset}px)`;
|
|
201
|
+
if (orientation === 'horizontal') styleObj.width = `${selectedTab.offsetWidth}px`;
|
|
202
202
|
else styleObj.height = `${selectedTab.offsetHeight}px`;
|
|
203
203
|
setStyle(styleObj);
|
|
204
204
|
}
|
|
@@ -217,7 +217,7 @@ function $65ab70ddbed1564b$var$TabLine(props) {
|
|
|
217
217
|
tabLineState
|
|
218
218
|
]);
|
|
219
219
|
return /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
220
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
220
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-selectionIndicator'),
|
|
221
221
|
role: "presentation",
|
|
222
222
|
style: style
|
|
223
223
|
});
|
|
@@ -248,28 +248,28 @@ function $65ab70ddbed1564b$export$e51a686c67fdaa2d(props) {
|
|
|
248
248
|
state.selectedKey,
|
|
249
249
|
props.children
|
|
250
250
|
]);
|
|
251
|
-
let collapseStyle = collapsed && orientation !==
|
|
252
|
-
maxWidth:
|
|
253
|
-
overflow:
|
|
254
|
-
visibility:
|
|
255
|
-
position:
|
|
251
|
+
let collapseStyle = collapsed && orientation !== 'vertical' ? {
|
|
252
|
+
maxWidth: 'calc(100% + 1px)',
|
|
253
|
+
overflow: 'hidden',
|
|
254
|
+
visibility: 'hidden',
|
|
255
|
+
position: 'absolute'
|
|
256
256
|
} : {
|
|
257
|
-
maxWidth:
|
|
257
|
+
maxWidth: 'calc(100% + 1px)'
|
|
258
258
|
};
|
|
259
|
-
let stylePropsFinal = orientation ===
|
|
259
|
+
let stylePropsFinal = orientation === 'vertical' ? styleProps : {
|
|
260
260
|
style: collapseStyle
|
|
261
261
|
};
|
|
262
|
-
if (collapsed && orientation !==
|
|
263
|
-
let tabListclassName = (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
262
|
+
if (collapsed && orientation !== 'vertical') tabListProps['aria-hidden'] = true;
|
|
263
|
+
let tabListclassName = (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel-tabs');
|
|
264
264
|
const tabContent = /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
265
265
|
...stylePropsFinal,
|
|
266
266
|
...tabListProps,
|
|
267
267
|
ref: tablistRef,
|
|
268
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
[
|
|
272
|
-
}, orientation ===
|
|
268
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs', `spectrum-Tabs--${orientation}`, tabListclassName, {
|
|
269
|
+
'spectrum-Tabs--quiet': isQuiet,
|
|
270
|
+
'spectrum-Tabs--emphasized': isEmphasized,
|
|
271
|
+
['spectrum-Tabs--compact']: density === 'compact'
|
|
272
|
+
}, orientation === 'vertical' && styleProps.className)
|
|
273
273
|
}, [
|
|
274
274
|
...state.collection
|
|
275
275
|
].map((item)=>/*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$Tab, {
|
|
@@ -281,16 +281,16 @@ function $65ab70ddbed1564b$export$e51a686c67fdaa2d(props) {
|
|
|
281
281
|
orientation: orientation,
|
|
282
282
|
selectedTab: selectedTab
|
|
283
283
|
}));
|
|
284
|
-
if (orientation ===
|
|
284
|
+
if (orientation === 'vertical') return tabContent;
|
|
285
285
|
else return /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
286
286
|
...styleProps,
|
|
287
287
|
ref: wrapperRef,
|
|
288
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
288
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel-collapseWrapper', styleProps.className)
|
|
289
289
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$TabPicker, {
|
|
290
290
|
...props,
|
|
291
291
|
...tabProps,
|
|
292
292
|
visible: collapsed,
|
|
293
|
-
id: tabPanelProps[
|
|
293
|
+
id: tabPanelProps['aria-labelledby'],
|
|
294
294
|
state: state,
|
|
295
295
|
className: tabListclassName
|
|
296
296
|
}), tabContent);
|
|
@@ -318,18 +318,18 @@ function $65ab70ddbed1564b$var$TabPanel(props) {
|
|
|
318
318
|
let ref = (0, $14nVg$useRef)();
|
|
319
319
|
const { tabPanelProps: tabPanelProps } = (0, $14nVg$useTabPanel)(props, tabListState, ref);
|
|
320
320
|
let { styleProps: styleProps } = (0, $14nVg$useStyleProps)(props);
|
|
321
|
-
if (ctxTabPanelProps[
|
|
321
|
+
if (ctxTabPanelProps['aria-labelledby']) tabPanelProps['aria-labelledby'] = ctxTabPanelProps['aria-labelledby'];
|
|
322
322
|
return /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$FocusRing), {
|
|
323
|
-
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
323
|
+
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'focus-ring')
|
|
324
324
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
325
325
|
...styleProps,
|
|
326
326
|
...tabPanelProps,
|
|
327
327
|
ref: ref,
|
|
328
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
328
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel-tabpanel', styleProps.className)
|
|
329
329
|
}, props.children));
|
|
330
330
|
}
|
|
331
331
|
function $65ab70ddbed1564b$var$TabPicker(props) {
|
|
332
|
-
let { isDisabled: isDisabled, isEmphasized: isEmphasized, isQuiet: isQuiet, state: state,
|
|
332
|
+
let { isDisabled: isDisabled, isEmphasized: isEmphasized, isQuiet: isQuiet, state: state, 'aria-labelledby': ariaLabeledBy, 'aria-label': ariaLabel, density: density, className: className, id: id, visible: visible } = props;
|
|
333
333
|
let ref = (0, $14nVg$useRef)();
|
|
334
334
|
let [pickerNode, setPickerNode] = (0, $14nVg$useState)(null);
|
|
335
335
|
(0, $14nVg$useEffect)(()=>{
|
|
@@ -342,30 +342,30 @@ function $65ab70ddbed1564b$var$TabPicker(props) {
|
|
|
342
342
|
...state.collection
|
|
343
343
|
];
|
|
344
344
|
let pickerProps = {
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
'aria-labelledby': ariaLabeledBy,
|
|
346
|
+
'aria-label': ariaLabel
|
|
347
347
|
};
|
|
348
348
|
const style = visible ? {} : {
|
|
349
|
-
visibility:
|
|
350
|
-
position:
|
|
349
|
+
visibility: 'hidden',
|
|
350
|
+
position: 'absolute'
|
|
351
351
|
};
|
|
352
352
|
// TODO: Figure out if tabListProps should go onto the div here, v2 doesn't do it
|
|
353
353
|
return /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
354
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
355
|
-
|
|
356
|
-
[
|
|
357
|
-
|
|
354
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs', 'spectrum-Tabs--horizontal', 'spectrum-Tabs--isCollapsed', {
|
|
355
|
+
'spectrum-Tabs--quiet': isQuiet,
|
|
356
|
+
['spectrum-Tabs--compact']: density === 'compact',
|
|
357
|
+
'spectrum-Tabs--emphasized': isEmphasized
|
|
358
358
|
}, className),
|
|
359
359
|
style: style,
|
|
360
360
|
"aria-hidden": visible ? undefined : true
|
|
361
361
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$SlotProvider), {
|
|
362
362
|
slots: {
|
|
363
363
|
icon: {
|
|
364
|
-
size:
|
|
365
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
364
|
+
size: 'S',
|
|
365
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Icon')
|
|
366
366
|
},
|
|
367
367
|
button: {
|
|
368
|
-
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
368
|
+
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'focus-ring')
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$Picker), {
|
|
@@ -378,7 +378,7 @@ function $65ab70ddbed1564b$var$TabPicker(props) {
|
|
|
378
378
|
selectedKey: state.selectedKey,
|
|
379
379
|
disabledKeys: state.disabledKeys,
|
|
380
380
|
onSelectionChange: state.setSelectedKey,
|
|
381
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
381
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-picker')
|
|
382
382
|
}, (item)=>/*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$Item), item.props, item.rendered)), pickerNode && /*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$TabLine, {
|
|
383
383
|
orientation: "horizontal",
|
|
384
384
|
selectedTab: pickerNode,
|
package/dist/Tabs.module.js
CHANGED
|
@@ -45,7 +45,7 @@ function $parcel$interopDefault(a) {
|
|
|
45
45
|
const $65ab70ddbed1564b$var$TabContext = /*#__PURE__*/ (0, $14nVg$react).createContext(null);
|
|
46
46
|
function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
47
47
|
props = (0, $14nVg$useProviderProps)(props);
|
|
48
|
-
let { orientation: orientation =
|
|
48
|
+
let { orientation: orientation = 'horizontal', density: density = 'regular', children: children, ...otherProps } = props;
|
|
49
49
|
let domRef = (0, $14nVg$useDOMRef)(ref);
|
|
50
50
|
let tablistRef = (0, $14nVg$useRef)();
|
|
51
51
|
let wrapperRef = (0, $14nVg$useRef)();
|
|
@@ -70,16 +70,16 @@ function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
|
70
70
|
tablistRef
|
|
71
71
|
]);
|
|
72
72
|
let checkShouldCollapse = (0, $14nVg$useCallback)(()=>{
|
|
73
|
-
if (wrapperRef.current && orientation !==
|
|
73
|
+
if (wrapperRef.current && orientation !== 'vertical') {
|
|
74
74
|
let tabsComponent = wrapperRef.current;
|
|
75
75
|
let tabs = tablistRef.current.querySelectorAll('[role="tab"]');
|
|
76
76
|
let tabDimensions = [
|
|
77
77
|
...tabs
|
|
78
78
|
].map((tab)=>tab.getBoundingClientRect());
|
|
79
|
-
let end = direction ===
|
|
79
|
+
let end = direction === 'rtl' ? 'left' : 'right';
|
|
80
80
|
let farEdgeTabList = tabsComponent.getBoundingClientRect()[end];
|
|
81
81
|
let farEdgeLastTab = tabDimensions[tabDimensions.length - 1][end];
|
|
82
|
-
let shouldCollapse = direction ===
|
|
82
|
+
let shouldCollapse = direction === 'rtl' ? farEdgeLastTab < farEdgeTabList : farEdgeTabList < farEdgeLastTab;
|
|
83
83
|
setCollapsed(shouldCollapse);
|
|
84
84
|
if (tabDimensions.length !== prevTabPositions.current.length || tabDimensions.some((box, index)=>{
|
|
85
85
|
var _prevTabPositions_current_index, _prevTabPositions_current_index1;
|
|
@@ -109,11 +109,11 @@ function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
|
109
109
|
onResize: checkShouldCollapse
|
|
110
110
|
});
|
|
111
111
|
let tabPanelProps = {
|
|
112
|
-
|
|
112
|
+
'aria-labelledby': undefined
|
|
113
113
|
};
|
|
114
114
|
// When the tabs are collapsed, the tabPanel should be labelled by the Picker button element.
|
|
115
115
|
let collapsibleTabListId = (0, $14nVg$useId)();
|
|
116
|
-
if (collapsed && orientation !==
|
|
116
|
+
if (collapsed && orientation !== 'vertical') tabPanelProps['aria-labelledby'] = collapsibleTabListId;
|
|
117
117
|
return /*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$TabContext.Provider, {
|
|
118
118
|
value: {
|
|
119
119
|
tabProps: {
|
|
@@ -138,7 +138,7 @@ function $65ab70ddbed1564b$var$Tabs(props, ref) {
|
|
|
138
138
|
...(0, $14nVg$filterDOMProps)(otherProps),
|
|
139
139
|
...styleProps,
|
|
140
140
|
ref: domRef,
|
|
141
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
141
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel', `spectrum-TabsPanel--${orientation}`, styleProps.className)
|
|
142
142
|
}, props.children));
|
|
143
143
|
}
|
|
144
144
|
// @private
|
|
@@ -152,28 +152,28 @@ function $65ab70ddbed1564b$var$Tab(props) {
|
|
|
152
152
|
let { hoverProps: hoverProps, isHovered: isHovered } = (0, $14nVg$useHover)({
|
|
153
153
|
...props
|
|
154
154
|
});
|
|
155
|
-
let ElementType = item.props.href ?
|
|
155
|
+
let ElementType = item.props.href ? 'a' : 'div';
|
|
156
156
|
return /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$FocusRing), {
|
|
157
|
-
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
157
|
+
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'focus-ring')
|
|
158
158
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement(ElementType, {
|
|
159
159
|
...(0, $14nVg$mergeProps)(tabProps, hoverProps),
|
|
160
160
|
ref: ref,
|
|
161
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-item', {
|
|
162
|
+
'is-selected': isSelected,
|
|
163
|
+
'is-disabled': isDisabled,
|
|
164
|
+
'is-hovered': isHovered
|
|
165
165
|
})
|
|
166
166
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$SlotProvider), {
|
|
167
167
|
slots: {
|
|
168
168
|
icon: {
|
|
169
|
-
size:
|
|
170
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
169
|
+
size: 'S',
|
|
170
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Icon')
|
|
171
171
|
},
|
|
172
172
|
text: {
|
|
173
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
173
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-itemLabel')
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
}, typeof rendered ===
|
|
176
|
+
}, typeof rendered === 'string' ? /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$Text), null, rendered) : rendered)));
|
|
177
177
|
}
|
|
178
178
|
// @private
|
|
179
179
|
function $65ab70ddbed1564b$var$TabLine(props) {
|
|
@@ -196,9 +196,9 @@ function $65ab70ddbed1564b$var$TabLine(props) {
|
|
|
196
196
|
height: undefined
|
|
197
197
|
};
|
|
198
198
|
// 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
|
|
199
|
-
let offset = direction ===
|
|
200
|
-
styleObj.transform = orientation ===
|
|
201
|
-
if (orientation ===
|
|
199
|
+
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;
|
|
200
|
+
styleObj.transform = orientation === 'vertical' ? `translateY(${selectedTab.offsetTop}px)` : `translateX(${offset}px)`;
|
|
201
|
+
if (orientation === 'horizontal') styleObj.width = `${selectedTab.offsetWidth}px`;
|
|
202
202
|
else styleObj.height = `${selectedTab.offsetHeight}px`;
|
|
203
203
|
setStyle(styleObj);
|
|
204
204
|
}
|
|
@@ -217,7 +217,7 @@ function $65ab70ddbed1564b$var$TabLine(props) {
|
|
|
217
217
|
tabLineState
|
|
218
218
|
]);
|
|
219
219
|
return /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
220
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
220
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-selectionIndicator'),
|
|
221
221
|
role: "presentation",
|
|
222
222
|
style: style
|
|
223
223
|
});
|
|
@@ -248,28 +248,28 @@ function $65ab70ddbed1564b$export$e51a686c67fdaa2d(props) {
|
|
|
248
248
|
state.selectedKey,
|
|
249
249
|
props.children
|
|
250
250
|
]);
|
|
251
|
-
let collapseStyle = collapsed && orientation !==
|
|
252
|
-
maxWidth:
|
|
253
|
-
overflow:
|
|
254
|
-
visibility:
|
|
255
|
-
position:
|
|
251
|
+
let collapseStyle = collapsed && orientation !== 'vertical' ? {
|
|
252
|
+
maxWidth: 'calc(100% + 1px)',
|
|
253
|
+
overflow: 'hidden',
|
|
254
|
+
visibility: 'hidden',
|
|
255
|
+
position: 'absolute'
|
|
256
256
|
} : {
|
|
257
|
-
maxWidth:
|
|
257
|
+
maxWidth: 'calc(100% + 1px)'
|
|
258
258
|
};
|
|
259
|
-
let stylePropsFinal = orientation ===
|
|
259
|
+
let stylePropsFinal = orientation === 'vertical' ? styleProps : {
|
|
260
260
|
style: collapseStyle
|
|
261
261
|
};
|
|
262
|
-
if (collapsed && orientation !==
|
|
263
|
-
let tabListclassName = (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
262
|
+
if (collapsed && orientation !== 'vertical') tabListProps['aria-hidden'] = true;
|
|
263
|
+
let tabListclassName = (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel-tabs');
|
|
264
264
|
const tabContent = /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
265
265
|
...stylePropsFinal,
|
|
266
266
|
...tabListProps,
|
|
267
267
|
ref: tablistRef,
|
|
268
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
[
|
|
272
|
-
}, orientation ===
|
|
268
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs', `spectrum-Tabs--${orientation}`, tabListclassName, {
|
|
269
|
+
'spectrum-Tabs--quiet': isQuiet,
|
|
270
|
+
'spectrum-Tabs--emphasized': isEmphasized,
|
|
271
|
+
['spectrum-Tabs--compact']: density === 'compact'
|
|
272
|
+
}, orientation === 'vertical' && styleProps.className)
|
|
273
273
|
}, [
|
|
274
274
|
...state.collection
|
|
275
275
|
].map((item)=>/*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$Tab, {
|
|
@@ -281,16 +281,16 @@ function $65ab70ddbed1564b$export$e51a686c67fdaa2d(props) {
|
|
|
281
281
|
orientation: orientation,
|
|
282
282
|
selectedTab: selectedTab
|
|
283
283
|
}));
|
|
284
|
-
if (orientation ===
|
|
284
|
+
if (orientation === 'vertical') return tabContent;
|
|
285
285
|
else return /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
286
286
|
...styleProps,
|
|
287
287
|
ref: wrapperRef,
|
|
288
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
288
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel-collapseWrapper', styleProps.className)
|
|
289
289
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$TabPicker, {
|
|
290
290
|
...props,
|
|
291
291
|
...tabProps,
|
|
292
292
|
visible: collapsed,
|
|
293
|
-
id: tabPanelProps[
|
|
293
|
+
id: tabPanelProps['aria-labelledby'],
|
|
294
294
|
state: state,
|
|
295
295
|
className: tabListclassName
|
|
296
296
|
}), tabContent);
|
|
@@ -318,18 +318,18 @@ function $65ab70ddbed1564b$var$TabPanel(props) {
|
|
|
318
318
|
let ref = (0, $14nVg$useRef)();
|
|
319
319
|
const { tabPanelProps: tabPanelProps } = (0, $14nVg$useTabPanel)(props, tabListState, ref);
|
|
320
320
|
let { styleProps: styleProps } = (0, $14nVg$useStyleProps)(props);
|
|
321
|
-
if (ctxTabPanelProps[
|
|
321
|
+
if (ctxTabPanelProps['aria-labelledby']) tabPanelProps['aria-labelledby'] = ctxTabPanelProps['aria-labelledby'];
|
|
322
322
|
return /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$FocusRing), {
|
|
323
|
-
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
323
|
+
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'focus-ring')
|
|
324
324
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
325
325
|
...styleProps,
|
|
326
326
|
...tabPanelProps,
|
|
327
327
|
ref: ref,
|
|
328
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
328
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-TabsPanel-tabpanel', styleProps.className)
|
|
329
329
|
}, props.children));
|
|
330
330
|
}
|
|
331
331
|
function $65ab70ddbed1564b$var$TabPicker(props) {
|
|
332
|
-
let { isDisabled: isDisabled, isEmphasized: isEmphasized, isQuiet: isQuiet, state: state,
|
|
332
|
+
let { isDisabled: isDisabled, isEmphasized: isEmphasized, isQuiet: isQuiet, state: state, 'aria-labelledby': ariaLabeledBy, 'aria-label': ariaLabel, density: density, className: className, id: id, visible: visible } = props;
|
|
333
333
|
let ref = (0, $14nVg$useRef)();
|
|
334
334
|
let [pickerNode, setPickerNode] = (0, $14nVg$useState)(null);
|
|
335
335
|
(0, $14nVg$useEffect)(()=>{
|
|
@@ -342,30 +342,30 @@ function $65ab70ddbed1564b$var$TabPicker(props) {
|
|
|
342
342
|
...state.collection
|
|
343
343
|
];
|
|
344
344
|
let pickerProps = {
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
'aria-labelledby': ariaLabeledBy,
|
|
346
|
+
'aria-label': ariaLabel
|
|
347
347
|
};
|
|
348
348
|
const style = visible ? {} : {
|
|
349
|
-
visibility:
|
|
350
|
-
position:
|
|
349
|
+
visibility: 'hidden',
|
|
350
|
+
position: 'absolute'
|
|
351
351
|
};
|
|
352
352
|
// TODO: Figure out if tabListProps should go onto the div here, v2 doesn't do it
|
|
353
353
|
return /*#__PURE__*/ (0, $14nVg$react).createElement("div", {
|
|
354
|
-
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
355
|
-
|
|
356
|
-
[
|
|
357
|
-
|
|
354
|
+
className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs', 'spectrum-Tabs--horizontal', 'spectrum-Tabs--isCollapsed', {
|
|
355
|
+
'spectrum-Tabs--quiet': isQuiet,
|
|
356
|
+
['spectrum-Tabs--compact']: density === 'compact',
|
|
357
|
+
'spectrum-Tabs--emphasized': isEmphasized
|
|
358
358
|
}, className),
|
|
359
359
|
style: style,
|
|
360
360
|
"aria-hidden": visible ? undefined : true
|
|
361
361
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$SlotProvider), {
|
|
362
362
|
slots: {
|
|
363
363
|
icon: {
|
|
364
|
-
size:
|
|
365
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
364
|
+
size: 'S',
|
|
365
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Icon')
|
|
366
366
|
},
|
|
367
367
|
button: {
|
|
368
|
-
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
368
|
+
focusRingClass: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'focus-ring')
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
}, /*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$Picker), {
|
|
@@ -378,7 +378,7 @@ function $65ab70ddbed1564b$var$TabPicker(props) {
|
|
|
378
378
|
selectedKey: state.selectedKey,
|
|
379
379
|
disabledKeys: state.disabledKeys,
|
|
380
380
|
onSelectionChange: state.setSelectedKey,
|
|
381
|
-
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))),
|
|
381
|
+
UNSAFE_className: (0, $14nVg$classNames)((0, ($parcel$interopDefault($14nVg$tabs_vars_cssmodulejs))), 'spectrum-Tabs-picker')
|
|
382
382
|
}, (item)=>/*#__PURE__*/ (0, $14nVg$react).createElement((0, $14nVg$Item), item.props, item.rendered)), pickerNode && /*#__PURE__*/ (0, $14nVg$react).createElement($65ab70ddbed1564b$var$TabLine, {
|
|
383
383
|
orientation: "horizontal",
|
|
384
384
|
selectedTab: pickerNode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/tabs",
|
|
3
|
-
"version": "3.8.10
|
|
3
|
+
"version": "3.8.10",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/focus": "3.
|
|
40
|
-
"@react-aria/i18n": "3.
|
|
41
|
-
"@react-aria/interactions": "3.
|
|
42
|
-
"@react-aria/tabs": "3.9.1
|
|
43
|
-
"@react-aria/utils": "3.
|
|
44
|
-
"@react-spectrum/picker": "3.14.5
|
|
45
|
-
"@react-spectrum/text": "3.5.5
|
|
46
|
-
"@react-spectrum/utils": "3.
|
|
47
|
-
"@react-stately/collections": "3.
|
|
48
|
-
"@react-stately/list": "3.10.5
|
|
49
|
-
"@react-stately/tabs": "3.
|
|
50
|
-
"@react-types/select": "3.9.4
|
|
51
|
-
"@react-types/shared": "3.
|
|
52
|
-
"@react-types/tabs": "3.3.7
|
|
39
|
+
"@react-aria/focus": "^3.17.1",
|
|
40
|
+
"@react-aria/i18n": "^3.11.1",
|
|
41
|
+
"@react-aria/interactions": "^3.21.3",
|
|
42
|
+
"@react-aria/tabs": "^3.9.1",
|
|
43
|
+
"@react-aria/utils": "^3.24.1",
|
|
44
|
+
"@react-spectrum/picker": "^3.14.5",
|
|
45
|
+
"@react-spectrum/text": "^3.5.5",
|
|
46
|
+
"@react-spectrum/utils": "^3.11.7",
|
|
47
|
+
"@react-stately/collections": "^3.10.7",
|
|
48
|
+
"@react-stately/list": "^3.10.5",
|
|
49
|
+
"@react-stately/tabs": "^3.6.6",
|
|
50
|
+
"@react-types/select": "^3.9.4",
|
|
51
|
+
"@react-types/shared": "^3.23.1",
|
|
52
|
+
"@react-types/tabs": "^3.3.7",
|
|
53
53
|
"@swc/helpers": "^0.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@adobe/spectrum-css-temp": "3.0.0-
|
|
56
|
+
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@react-spectrum/provider": "^3.0.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
|
|
67
67
|
}
|