Dashboard sipadu mbip
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
  3. import React from 'react';
  4. import requiredForA11y from 'prop-types-extra/lib/isRequiredForA11y';
  5. import { useUncontrolled } from 'uncontrollable';
  6. import Nav from './Nav';
  7. import NavLink from './NavLink';
  8. import NavItem from './NavItem';
  9. import TabContainer from './TabContainer';
  10. import TabContent from './TabContent';
  11. import TabPane from './TabPane';
  12. import { forEach, map } from './utils/ElementChildren';
  13. var defaultProps = {
  14. variant: 'tabs',
  15. mountOnEnter: false,
  16. unmountOnExit: false
  17. };
  18. function getDefaultActiveKey(children) {
  19. var defaultActiveKey;
  20. forEach(children, function (child) {
  21. if (defaultActiveKey == null) {
  22. defaultActiveKey = child.props.eventKey;
  23. }
  24. });
  25. return defaultActiveKey;
  26. }
  27. function renderTab(child) {
  28. var _child$props = child.props,
  29. title = _child$props.title,
  30. eventKey = _child$props.eventKey,
  31. disabled = _child$props.disabled,
  32. tabClassName = _child$props.tabClassName;
  33. if (title == null) {
  34. return null;
  35. }
  36. return React.createElement(NavItem, {
  37. as: NavLink,
  38. eventKey: eventKey,
  39. disabled: disabled,
  40. className: tabClassName
  41. }, title);
  42. }
  43. var Tabs = React.forwardRef(function (props, ref) {
  44. var _useUncontrolled = useUncontrolled(props, {
  45. activeKey: 'onSelect'
  46. }),
  47. id = _useUncontrolled.id,
  48. onSelect = _useUncontrolled.onSelect,
  49. transition = _useUncontrolled.transition,
  50. mountOnEnter = _useUncontrolled.mountOnEnter,
  51. unmountOnExit = _useUncontrolled.unmountOnExit,
  52. children = _useUncontrolled.children,
  53. _useUncontrolled$acti = _useUncontrolled.activeKey,
  54. activeKey = _useUncontrolled$acti === void 0 ? getDefaultActiveKey(children) : _useUncontrolled$acti,
  55. controlledProps = _objectWithoutPropertiesLoose(_useUncontrolled, ["id", "onSelect", "transition", "mountOnEnter", "unmountOnExit", "children", "activeKey"]);
  56. return React.createElement(TabContainer, {
  57. ref: ref,
  58. id: id,
  59. activeKey: activeKey,
  60. onSelect: onSelect,
  61. transition: transition,
  62. mountOnEnter: mountOnEnter,
  63. unmountOnExit: unmountOnExit
  64. }, React.createElement(Nav, _extends({}, controlledProps, {
  65. role: "tablist",
  66. as: "nav"
  67. }), map(children, renderTab)), React.createElement(TabContent, null, map(children, function (child) {
  68. var childProps = _extends({}, child.props);
  69. delete childProps.title;
  70. delete childProps.disabled;
  71. delete childProps.tabClassName;
  72. return React.createElement(TabPane, childProps);
  73. })));
  74. });
  75. Tabs.defaultProps = defaultProps;
  76. Tabs.displayName = 'Tabs';
  77. export default Tabs;