1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import React, { useMemo } from 'react';
- import { useUncontrolled } from 'uncontrollable';
- import TabContext from './TabContext';
- import SelectableContext from './SelectableContext';
- /* eslint-disable react/no-unused-prop-types */
-
- 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,
- unmountOnExit: unmountOnExit,
- getControlledId: function getControlledId(key) {
- return generateChildId(key, 'tabpane');
- },
- getControllerId: function getControllerId(key) {
- return generateChildId(key, 'tab');
- }
- };
- }, [onSelect, activeKey, transition, mountOnEnter, unmountOnExit, generateChildId]);
- return React.createElement(TabContext.Provider, {
- value: tabContext
- }, React.createElement(SelectableContext.Provider, {
- value: onSelect
- }, children));
- };
-
- export default TabContainer;
|