GoScrobble/web/node_modules/react-bootstrap/esm/TabContainer.js

46 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-04-25 02:47:15 +00:00
import React, { useMemo } from 'react';
import { useUncontrolled } from 'uncontrollable';
import TabContext from './TabContext';
import SelectableContext from './SelectableContext';
var TabContainer = function TabContainer(props) {
var _useUncontrolled = useUncontrolled(props, {
activeKey: 'onSelect'
}),
id = _useUncontrolled.id,
generateCustomChildId = _useUncontrolled.generateChildId,
onSelect = _useUncontrolled.onSelect,
activeKey = _useUncontrolled.activeKey,
transition = _useUncontrolled.transition,
mountOnEnter = _useUncontrolled.mountOnEnter,
unmountOnExit = _useUncontrolled.unmountOnExit,
children = _useUncontrolled.children;
var generateChildId = useMemo(function () {
return generateCustomChildId || function (key, type) {
return id ? id + "-" + type + "-" + key : null;
};
}, [id, generateCustomChildId]);
var tabContext = useMemo(function () {
return {
onSelect: onSelect,
activeKey: activeKey,
transition: transition,
mountOnEnter: mountOnEnter || false,
unmountOnExit: unmountOnExit || false,
getControlledId: function getControlledId(key) {
return generateChildId(key, 'tabpane');
},
getControllerId: function getControllerId(key) {
return generateChildId(key, 'tab');
}
};
}, [onSelect, activeKey, transition, mountOnEnter, unmountOnExit, generateChildId]);
return /*#__PURE__*/React.createElement(TabContext.Provider, {
value: tabContext
}, /*#__PURE__*/React.createElement(SelectableContext.Provider, {
value: onSelect || null
}, children));
};
export default TabContainer;