wix-style-react
Version:
98 lines (81 loc) • 3.63 kB
JavaScript
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
import React from 'react';
import PropTypes from 'prop-types';
import VerticalTabsItem from '../VerticalTabsItem';
import VerticalTabsContext from './VerticalTabsContext';
/** Vertical tabs navigation panel. */
var Footer = function Footer(_ref) {
var children = _ref.children;
return /*#__PURE__*/React.createElement(VerticalTabsItem, {
type: "action"
}, children);
};
var TabsGroup = function TabsGroup(_ref2) {
var title = _ref2.title,
children = _ref2.children;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(VerticalTabsItem, {
type: "title"
}, title), children);
};
TabsGroup.propTypes = {
title: PropTypes.string
};
TabsGroup.defaultProps = {
title: ''
};
var VerticalTabs = /*#__PURE__*/function (_React$Component) {
_inherits(VerticalTabs, _React$Component);
var _super = _createSuper(VerticalTabs);
function VerticalTabs() {
_classCallCheck(this, VerticalTabs);
return _super.apply(this, arguments);
}
_createClass(VerticalTabs, [{
key: "render",
value: function render() {
var _this$props = this.props,
dataHook = _this$props.dataHook,
children = _this$props.children,
size = _this$props.size,
activeTabId = _this$props.activeTabId,
onChange = _this$props.onChange;
return /*#__PURE__*/React.createElement(VerticalTabsContext.Provider, {
value: {
size: size,
activeTabId: activeTabId,
onChange: onChange
}
}, /*#__PURE__*/React.createElement("div", {
"data-hook": dataHook
}, children));
}
}]);
return VerticalTabs;
}(React.Component);
VerticalTabs.displayName = 'VerticalTabs';
VerticalTabs.propTypes = {
/** Text Size (small, medium) */
size: PropTypes.oneOf(['small', 'medium']),
/** Current selected tab id */
activeTabId: PropTypes.number,
/** Callback function called on tab selection change with the following parameters<code>(id)</code> */
onChange: PropTypes.func,
/** Child nodes of this component must be of type <code><VerticalTabs.TabsGroup></code> or <code><VerticalTabs.Footer></code>*/
children: PropTypes.arrayOf(PropTypes.node),
/** Data attribute for testing purposes */
dataHook: PropTypes.string
};
VerticalTabs.defaultProps = {
size: 'medium',
onChange: function onChange() {}
};
VerticalTabs.TabsGroup = TabsGroup;
VerticalTabs.TabItem = VerticalTabsItem;
VerticalTabs.Footer = Footer;
export default VerticalTabs;