Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TabContainer.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React, { useMemo } from 'react';
  2. import { useUncontrolled } from 'uncontrollable';
  3. import TabContext from './TabContext';
  4. import SelectableContext from './SelectableContext';
  5. /* eslint-disable react/no-unused-prop-types */
  6. var TabContainer = function TabContainer(props) {
  7. var _useUncontrolled = useUncontrolled(props, {
  8. activeKey: 'onSelect'
  9. }),
  10. id = _useUncontrolled.id,
  11. generateCustomChildId = _useUncontrolled.generateChildId,
  12. onSelect = _useUncontrolled.onSelect,
  13. activeKey = _useUncontrolled.activeKey,
  14. transition = _useUncontrolled.transition,
  15. mountOnEnter = _useUncontrolled.mountOnEnter,
  16. unmountOnExit = _useUncontrolled.unmountOnExit,
  17. children = _useUncontrolled.children;
  18. var generateChildId = useMemo(function () {
  19. return generateCustomChildId || function (key, type) {
  20. return id ? id + "-" + type + "-" + key : null;
  21. };
  22. }, [id, generateCustomChildId]);
  23. var tabContext = useMemo(function () {
  24. return {
  25. onSelect: onSelect,
  26. activeKey: activeKey,
  27. transition: transition,
  28. mountOnEnter: mountOnEnter,
  29. unmountOnExit: unmountOnExit,
  30. getControlledId: function getControlledId(key) {
  31. return generateChildId(key, 'tabpane');
  32. },
  33. getControllerId: function getControllerId(key) {
  34. return generateChildId(key, 'tab');
  35. }
  36. };
  37. }, [onSelect, activeKey, transition, mountOnEnter, unmountOnExit, generateChildId]);
  38. return React.createElement(TabContext.Provider, {
  39. value: tabContext
  40. }, React.createElement(SelectableContext.Provider, {
  41. value: onSelect
  42. }, children));
  43. };
  44. export default TabContainer;