UNPKG

@react-spectrum/s2

Version:
650 lines (631 loc) 28.4 kB
require("./Tabs.css"); var $e991cbcdf82ced71$exports = require("./CenterBaseline.cjs"); var $bde97c91243ed164$exports = require("../icons/Icon.cjs"); var $9d2c38978395d44a$exports = require("./TabsPicker.cjs"); var $6367bc87eb7d24ad$exports = require("./Content.cjs"); var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs"); var $5oxdw$reactjsxruntime = require("react/jsx-runtime"); var $5oxdw$react = require("react"); var $5oxdw$reactariacomponents = require("react-aria-components"); var $5oxdw$reactariacollections = require("@react-aria/collections"); var $5oxdw$reactariautils = require("@react-aria/utils"); var $5oxdw$reactstatelyutils = require("@react-stately/utils"); var $5oxdw$reactspectrumutils = require("@react-spectrum/utils"); var $5oxdw$reactariafocus = require("@react-aria/focus"); var $5oxdw$reactariai18n = require("@react-aria/i18n"); function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "TabsContext", () => $b27519d6a701105b$export$cfa7aa87c26e7d1f); $parcel$export(module.exports, "Tabs", () => $b27519d6a701105b$export$b2539bed5023c21c); $parcel$export(module.exports, "TabList", () => $b27519d6a701105b$export$e51a686c67fdaa2d); $parcel$export(module.exports, "Tab", () => $b27519d6a701105b$export$3e41faf802a29e71); $parcel$export(module.exports, "TabPanel", () => $b27519d6a701105b$export$3d96ec278d3efce4); /* * Copyright 2024 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ const $b27519d6a701105b$export$cfa7aa87c26e7d1f = /*#__PURE__*/ (0, $5oxdw$react.createContext)(null); const $b27519d6a701105b$var$InternalTabsContext = /*#__PURE__*/ (0, $5oxdw$react.createContext)({}); const $b27519d6a701105b$var$CollapseContext = /*#__PURE__*/ (0, $5oxdw$react.createContext)({ showTabs: true, menuId: '', valueId: '', tabs: [] }); const $b27519d6a701105b$var$tabs = function anonymous(props, overrides) { let rules = " "; let position = false; let flexShrink = false; let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L|F|M|K)[^\s]+/g); for (let p of matches){ if (p[1] === "_P") position = true; if (p[1] === "_v") flexShrink = true; rules += p[0]; } if (!position) rules += ' _Pc1'; rules += ' sd1'; if (!flexShrink) rules += ' _va1'; rules += ' uk1'; rules += ' ucJ9TBTb1'; rules += ' ud3Euai1'; rules += ' uea1'; rules += ' ugb1'; rules += ' uhd1'; rules += ' uje1'; rules += ' u2NhKxcl1'; rules += ' uic1'; rules += ' -_6BNtrc-c1'; rules += ' vx1'; rules += ' xb1'; rules += ' _xa1'; rules += ' _Fd1'; rules += ' _FnuYUweb1'; rules += ' pt1'; if (props.orientation === "horizontal") rules += ' _ta1'; return rules; }; const $b27519d6a701105b$export$b2539bed5023c21c = /*#__PURE__*/ (0, $5oxdw$react.forwardRef)(function Tabs(props, ref) { [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $b27519d6a701105b$export$cfa7aa87c26e7d1f); let { density: density = 'regular', isDisabled: isDisabled, disabledKeys: disabledKeys, orientation: orientation = 'horizontal', labelBehavior: labelBehavior = 'show' } = props; let domRef = (0, $5oxdw$reactspectrumutils.useDOMRef)(ref); let [value, setValue] = (0, $5oxdw$reactstatelyutils.useControlledState)(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange); if (!props['aria-label'] && !props['aria-labelledby']) throw new Error('An aria-label or aria-labelledby prop is required on Tabs for accessibility.'); let tablistRef = (0, $5oxdw$react.useRef)(null); return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Provider), { values: [ [ $b27519d6a701105b$var$InternalTabsContext, { density: density, isDisabled: isDisabled, orientation: orientation, disabledKeys: disabledKeys, selectedKey: value, tablistRef: tablistRef, onSelectionChange: setValue, labelBehavior: labelBehavior, 'aria-label': props['aria-label'], 'aria-labelledby': props['aria-labelledby'] } ] ], children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacollections.CollectionBuilder), { content: props.children, children: (collection)=>/*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$CollapsingTabs, { ...props, selectedKey: value, onSelectionChange: setValue, collection: collection, containerRef: domRef }) }) }); }); const $b27519d6a701105b$var$tablist = function anonymous(props) { let rules = " "; rules += ' sd1'; if (props.orientation === "horizontal") { if (props.labelBehavior === "hide") { if (props.density === "regular") rules += ' Uj1'; else if (props.density === "compact") rules += ' Ul1'; } else if (props.density === "regular") rules += ' Up1'; else if (props.density === "compact") rules += ' Uj1'; } if (props.orientation === "horizontal") { if (props.labelBehavior === "hide") { if (props.density === "regular") rules += ' qj1'; else if (props.density === "compact") rules += ' ql1'; } else if (props.density === "regular") rules += ' qp1'; else if (props.density === "compact") rules += ' qj1'; } if (props.orientation === "vertical") rules += ' _ta1'; if (props.orientation === "vertical") rules += ' Hz1'; if (props.orientation === "vertical") rules += ' Ix1'; rules += ' Nq1'; return rules; }; const $b27519d6a701105b$var$tablistWrapper = function anonymous(props, overrides) { let rules = " "; let position = false; let minWidth = false; let flexShrink = false; let flexGrow = false; let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g); for (let p of matches){ if (p[1] === "_P") position = true; if (p[1] === "N") minWidth = true; if (p[1] === "_v") flexShrink = true; if (p[1] === "_u") flexGrow = true; rules += p[0]; } if (!position) rules += ' _Pc1'; if (!minWidth) rules += ' Na1'; if (!flexShrink) rules += ' _va1'; if (!flexGrow) rules += ' _ua1'; return rules; }; function $b27519d6a701105b$export$e51a686c67fdaa2d(props) { let { showTabs: showTabs, menuId: menuId, valueId: valueId, tabs: tabs, listRef: listRef, onSelectionChange: onSelectionChange, ariaLabel: ariaLabel, ariaDescribedBy: ariaDescribedBy } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$CollapseContext) ?? {}; let { density: density, orientation: orientation, labelBehavior: labelBehavior } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext); if (showTabs) return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$TabListInner, { ...props }); return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsxs)("div", { className: $b27519d6a701105b$var$tablistWrapper(null, props.styles), children: [ listRef && /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", { className: $b27519d6a701105b$var$tablist({ orientation: orientation, labelBehavior: labelBehavior, density: density }), children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$HiddenTabs, { items: tabs, density: density, listRef: listRef }) }), /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$TabsMenu, { id: menuId, valueId: valueId, items: tabs, onSelectionChange: onSelectionChange, "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy }) ] }); } function $b27519d6a701105b$var$TabListInner(props) { let { tablistRef: tablistRef, orientation: orientation, density: density, labelBehavior: labelBehavior, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext) ?? {}; let { tabs: tabs, listRef: listRef } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$CollapseContext) ?? {}; return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsxs)("div", { style: props.UNSAFE_style, className: (props.UNSAFE_className || '') + $b27519d6a701105b$var$tablistWrapper(null, props.styles), children: [ listRef && /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", { className: $b27519d6a701105b$var$tablist({ orientation: orientation, labelBehavior: labelBehavior, density: density }), children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$HiddenTabs, { items: tabs, density: density, listRef: listRef }) }), /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.TabList), { ...props, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ref: tablistRef, className: (renderProps)=>$b27519d6a701105b$var$tablist({ ...renderProps, labelBehavior: labelBehavior, density: density }) }) ] }); } const $b27519d6a701105b$var$selectedIndicator = function anonymous(props) { let rules = " "; rules += ' _Pa1'; if (props.isDisabled) rules += ' gH1'; else rules += ' g01'; if (props.isDisabled) rules += ' gld1'; else rules += ' gle1'; if (props.orientation === "horizontal") rules += ' FLvNfn1'; else rules += ' Fb1'; if (props.orientation === "vertical") rules += ' ZLvNfn1'; else rules += ' Za1'; rules += ' _qg1'; rules += ' YIRyJjb1'; rules += ' Ydklsgce1'; rules += ' Xc1'; rules += ' _2a1'; rules += ' _lr1'; if (props.orientation === "vertical") rules += ' Wr1'; if (props.orientation === "horizontal") rules += ' _Er1'; if (props.orientation === "vertical") rules += ' _Aa1'; rules += ' _je1'; rules += ' og1'; rules += ' ng1'; rules += ' kg1'; rules += ' jg1'; return rules; }; const $b27519d6a701105b$var$tab = function anonymous(props, overrides) { let rules = " "; let position = false; let flexShrink = false; let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g); for (let p of matches){ if (p[1] === "_P") position = true; if (p[1] === "_v") flexShrink = true; rules += p[0]; } if (props.isFocusVisible) rules += ' _Lf1'; else rules += ' _Le1'; rules += ' Oh1'; rules += ' Olc1'; rules += ' _Mc1'; rules += ' _Kd1'; rules += ' sd1'; if (props.isDisabled) rules += ' pp1'; else if (props.isSelected) { if (props.isPressed) rules += ' po1'; else if (props.isFocusVisible) rules += ' po1'; else if (props.isHovered) rules += ' po1'; else rules += ' pt1'; } else { if (props.isPressed) rules += ' pt1'; else if (props.isFocusVisible) rules += ' pt1'; else if (props.isHovered) rules += ' pt1'; else rules += ' pv1'; } if (props.isDisabled) rules += ' plc1'; else if (props.isSelected) rules += ' pld1'; rules += ' oa1'; rules += ' na1'; rules += ' ka1'; rules += ' ja1'; rules += ' Uc1'; rules += ' Usd1'; rules += ' qc1'; rules += ' qsd1'; if (props.orientation === "horizontal") { if (props.density === "regular") rules += ' Fz1'; else if (props.density === "compact") rules += ' Fx1'; } if (props.orientation === "vertical") { if (props.density === "regular") rules += ' Mk1'; else if (props.density === "compact") rules += ' Mi1'; } rules += ' eb1'; if (!position) rules += ' _Pc1'; rules += ' ri1'; rules += ' _Xa1'; if (!flexShrink) rules += ' _va1'; rules += ' Yd1'; rules += ' Xb1'; rules += ' _2b1'; if (props.labelBehavior === "hide") rules += ' SssxDec1'; if (props.labelBehavior === "hide") rules += ' RssxDec1'; rules += ' __ca1'; return rules; }; const $b27519d6a701105b$var$icon = " sb1 _va1 -_8sjo0b-t5ZbAob1"; function $b27519d6a701105b$export$3e41faf802a29e71(props1) { let { density: density, orientation: orientation, labelBehavior: labelBehavior } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext) ?? {}; let contentId = (0, $5oxdw$reactariautils.useId)(); let ariaLabelledBy = props1['aria-labelledby'] || ''; return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Tab), { ...props1, // @ts-ignore originalProps: props1, "aria-labelledby": `${labelBehavior === 'hide' ? contentId : ''} ${ariaLabelledBy}`, style: props1.UNSAFE_style, className: (renderProps)=>(props1.UNSAFE_className || '') + $b27519d6a701105b$var$tab({ ...renderProps, density: density, labelBehavior: labelBehavior, orientation: orientation }, props1.styles), children: ({ isMenu: // @ts-ignore isMenu, isDisabled: isDisabled })=>{ if (isMenu) return props1.children; else return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Provider), { values: [ [ (0, $6367bc87eb7d24ad$exports.TextContext), { id: contentId, styles: function anonymous(props) { let rules = " "; rules += ' _Jb1'; if (props.labelBehavior === "hide") rules += ' sk1'; return rules; }({ labelBehavior: labelBehavior }) } ], [ (0, $bde97c91243ed164$exports.IconContext), { render: (0, $e991cbcdf82ced71$exports.centerBaseline)({ slot: 'icon', styles: " _Ja1" }), styles: $b27519d6a701105b$var$icon } ] ], children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$TabInner, { orientation: orientation, isDisabled: isDisabled, children: typeof props1.children === 'string' ? /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Text), { children: props1.children }) : props1.children }) }); } }); } function $b27519d6a701105b$var$TabInner({ isDisabled: isDisabled, orientation: orientation, children: children }) { let ref = (0, $5oxdw$react.useRef)(null); let isHidden = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$HiddenTabsContext); return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsxs)((0, $5oxdw$reactjsxruntime.Fragment), { children: [ !isHidden && /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.SelectionIndicator), { ref: ref, className: $b27519d6a701105b$var$selectedIndicator({ isDisabled: isDisabled, orientation: orientation }) }), children ] }); } const $b27519d6a701105b$var$tabPanel = function anonymous(props, overrides) { let rules = " "; let marginTop = false; let flexGrow = false; let minHeight = false; let matches = (overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L|F|M|K)[^\s]+/g); for (let p of matches){ if (p[1] === "J") marginTop = true; if (p[1] === "_u") flexGrow = true; if (p[1] === "M") minHeight = true; rules += p[0]; } if (props.isFocusVisible) rules += ' _Lf1'; else rules += ' _Le1'; rules += ' Oh1'; rules += ' Olc1'; rules += ' _Mc1'; rules += ' _Kd1'; if (!marginTop) rules += ' Js1'; rules += ' pt1'; if (!flexGrow) rules += ' _ub1'; if (!minHeight) rules += ' Ma1'; if (props.isInert) rules += ' sk1'; else rules += ' sb1'; return rules; }; function $b27519d6a701105b$export$3d96ec278d3efce4(props) { let { showTabs: showTabs } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$CollapseContext); let { selectedKey: selectedKey } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext); if (showTabs) return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.TabPanel), { ...props, style: props.UNSAFE_style, className: (renderProps)=>(props.UNSAFE_className ?? '') + $b27519d6a701105b$var$tabPanel(renderProps, props.styles) }); if (props.id !== selectedKey) return null; return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$CollapsedTabPanel, { ...props }); } function $b27519d6a701105b$var$CollapsedTabPanel(props) { // eslint-disable-next-line @typescript-eslint/no-unused-vars let { UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className = '', id: id, shouldForceMount: shouldForceMount, ...otherProps } = props; let { menuId: menuId, valueId: valueId } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$CollapseContext); let ref = (0, $5oxdw$react.useRef)(null); let tabIndex = (0, $5oxdw$reactariafocus.useHasTabbableChild)(ref) ? undefined : 0; return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Group), { ...otherProps, ref: ref, "aria-labelledby": menuId + ' ' + valueId, tabIndex: tabIndex, style: UNSAFE_style, className: (renderProps)=>UNSAFE_className + $b27519d6a701105b$var$tabPanel(renderProps, props.styles) }); } function $b27519d6a701105b$var$isEveryTabDisabled(collection, disabledKeys) { let testKey = null; if (collection && collection.size > 0) { testKey = collection.getFirstKey(); let index = 0; while(testKey && index < collection.size){ // We have to check if the item in the collection has a key in disabledKeys or has the isDisabled prop set directly on it if (!disabledKeys.has(testKey) && !collection.getItem(testKey)?.props?.isDisabled) return false; testKey = collection.getKeyAfter(testKey); index++; } return true; } return false; } const $b27519d6a701105b$var$HiddenTabsContext = /*#__PURE__*/ (0, $5oxdw$react.createContext)(false); let $b27519d6a701105b$var$HiddenTabs = function(props) { let { listRef: listRef, items: items = [], size: size, density: density } = props; return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", { // @ts-ignore inert: (0, $5oxdw$reactariautils.inertValue)(true), ref: listRef, className: " s40ub4c1 _t40ub4c1 U40ub4c1 q40ub4c1 _w40ub4c1 _Pa1 Wr1 _lr1 _Ar1 _zr1 _6b1 _Nc1 Pc1 _Ia1", children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$HiddenTabsContext.Provider, { value: true, children: items.map((item)=>{ // pull off individual props as an allow list, don't want refs or other props getting through return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", { "data-hidden-tab": true, style: item.props.UNSAFE_style, className: item.props.className({ size: size, density: density }), children: item.props.children({ size: size, density: density }) }, item.key); }) }) }); }; let $b27519d6a701105b$var$TabsMenu = (props1)=>{ let { id: id, items: items, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, valueId: valueId } = props1; let { density: density, onSelectionChange: _onSelectionChange, selectedKey: selectedKey, isDisabled: isDisabled, disabledKeys: disabledKeys, labelBehavior: labelBehavior } = (0, $5oxdw$react.useContext)($b27519d6a701105b$var$InternalTabsContext); let onSelectionChange = (0, $5oxdw$react.useCallback)((key)=>{ if (key != null) _onSelectionChange?.(key); }, [ _onSelectionChange ]); let state = (0, $5oxdw$react.useContext)((0, $5oxdw$reactariacomponents.TabListStateContext)); let allKeysDisabled = (0, $5oxdw$react.useMemo)(()=>{ return $b27519d6a701105b$var$isEveryTabDisabled(state?.collection, disabledKeys ? new Set(disabledKeys) : new Set()); }, [ state?.collection, disabledKeys ]); let labelProps = (0, $5oxdw$reactariautils.useLabels)({ id: id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }); return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", { className: function anonymous(props) { let rules = " "; rules += ' sd1'; rules += ' _va1'; rules += ' eb1'; if (props.density === "regular") rules += ' Fz1'; else if (props.density === "compact") rules += ' Fx1'; return rules; }({ density: density }), children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $9d2c38978395d44a$exports.Picker), { id: id, valueId: valueId, ...labelProps, "aria-describedby": props1['aria-describedby'], "aria-details": props1['aria-details'], isDisabled: isDisabled || allKeysDisabled, density: density, labelBehavior: labelBehavior, items: items, disabledKeys: disabledKeys, selectedKey: selectedKey, onSelectionChange: onSelectionChange, children: (item)=>{ return /*#__PURE__*/ (0, $5oxdw$react.createElement)((0, $9d2c38978395d44a$exports.PickerItem), { ...item.props.originalProps, isDisabled: isDisabled || allKeysDisabled, key: item.key }, item.props.children({ density: density, isMenu: true })); } }) }); }; let $b27519d6a701105b$var$CollapsingTabs = ({ collection: collection, containerRef: containerRef, ...props })=>{ let { orientation: orientation = 'horizontal', onSelectionChange: onSelectionChange } = props; let [showItems, _setShowItems] = (0, $5oxdw$react.useState)(true); showItems = orientation === 'vertical' ? true : showItems; let setShowItems = (0, $5oxdw$react.useCallback)((value)=>{ if (orientation === 'vertical') // if orientation is vertical, we always show the items _setShowItems(true); else _setShowItems(value); }, [ orientation ]); let { direction: direction } = (0, $5oxdw$reactariai18n.useLocale)(); let children = (0, $5oxdw$react.useMemo)(()=>[ ...collection ], [ collection ]); let listRef = (0, $5oxdw$react.useRef)(null); let updateOverflow = ()=>{ if (orientation === 'vertical' || !listRef.current || !containerRef?.current) return; let container = listRef.current; let containerRect = container.getBoundingClientRect(); let tabs = container.querySelectorAll('[data-hidden-tab]'); let lastTab = tabs[tabs.length - 1]; let lastTabRect = lastTab.getBoundingClientRect(); if (direction === 'ltr') setShowItems?.(lastTabRect.right <= containerRect.right); else setShowItems?.(lastTabRect.left >= containerRect.left); }; let updateOverflowEffect = (0, $5oxdw$reactariautils.useEffectEvent)(updateOverflow); (0, $5oxdw$reactariautils.useResizeObserver)({ ref: containerRef, onResize: updateOverflow }); (0, $5oxdw$reactariautils.useLayoutEffect)(()=>{ if (collection.size > 0) queueMicrotask(updateOverflowEffect); }, [ collection.size ]); // start with null so that the first render won't have a flicker let prevOrientation = (0, $5oxdw$react.useRef)(null); (0, $5oxdw$reactariautils.useLayoutEffect)(()=>{ if (collection.size > 0 && prevOrientation.current !== orientation) updateOverflowEffect(); prevOrientation.current = orientation; }, [ collection.size, orientation ]); (0, $5oxdw$react.useEffect)(()=>{ // Recalculate visible tags when fonts are loaded. document.fonts?.ready.then(()=>updateOverflowEffect()); }, []); let menuId = (0, $5oxdw$reactariautils.useId)(); let valueId = (0, $5oxdw$reactariautils.useId)(); let contents; if (showItems) contents = /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactariacomponents.Tabs), { ...props, className: "", style: { display: 'contents' }, children: props.children }); else contents = /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)((0, $5oxdw$reactjsxruntime.Fragment), { children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$CollapseContext.Provider, { value: { showTabs: false, tabs: children, menuId: menuId, valueId: valueId, listRef: listRef, onSelectionChange: onSelectionChange, ariaLabel: props['aria-label'], ariaDescribedBy: props['aria-labelledby'] }, children: props.children }) }); return /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)("div", { style: props.UNSAFE_style, className: (props.UNSAFE_className || '') + $b27519d6a701105b$var$tabs({ orientation: orientation }, props.styles), ref: containerRef, children: /*#__PURE__*/ (0, $5oxdw$reactjsxruntime.jsx)($b27519d6a701105b$var$CollapseContext.Provider, { value: { showTabs: true, menuId: menuId, valueId: valueId, tabs: children, listRef: listRef }, children: contents }) }); }; //# sourceMappingURL=Tabs.cjs.map