UNPKG

wix-style-react

Version:
140 lines (113 loc) 5.85 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; 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 X from 'wix-ui-icons-common/X'; import IconButton from '../IconButton'; import { st, classes } from './ModalMobileLayout.st.css'; var ModalMobileLayout = /*#__PURE__*/function (_React$PureComponent) { _inherits(ModalMobileLayout, _React$PureComponent); var _super = _createSuper(ModalMobileLayout); function ModalMobileLayout() { var _this; _classCallCheck(this, ModalMobileLayout); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "_renderTitle", function () { return /*#__PURE__*/React.createElement("div", { className: classes.title, "data-hook": "modalMobileLayout-title", "data-sticky-title": _this.props.stickyTitle }, _this.props.title); }); _defineProperty(_assertThisInitialized(_this), "_renderFooter", function () { return /*#__PURE__*/React.createElement("div", { className: classes.footer, "data-hook": "modalMobileLayout-footer", "data-sticky-footer": _this.props.stickyFooter }, _this.props.footer); }); return _this; } _createClass(ModalMobileLayout, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, className = _this$props.className, title = _this$props.title, content = _this$props.content, footer = _this$props.footer, onOverlayClick = _this$props.onOverlayClick, onCloseButtonClick = _this$props.onCloseButtonClick, fullscreen = _this$props.fullscreen, stickyTitle = _this$props.stickyTitle, stickyFooter = _this$props.stickyFooter; return /*#__PURE__*/React.createElement("div", { id: "modalMobileLayout-root", "data-hook": dataHook, className: st(classes.root, { fullscreen: fullscreen, stickyTitle: stickyTitle, stickyFooter: stickyFooter, noTitle: !title, noFooter: !footer }, className), onClick: function onClick(_ref) { var id = _ref.target.id; id === 'modalMobileLayout-root' && onOverlayClick && onOverlayClick(); } }, /*#__PURE__*/React.createElement("div", { className: classes.container }, onCloseButtonClick && /*#__PURE__*/React.createElement("div", { className: classes.close }, /*#__PURE__*/React.createElement(IconButton, { dataHook: "modalMobileLayout-close-button", skin: "light", onClick: onCloseButtonClick }, /*#__PURE__*/React.createElement(X, null))), title && stickyTitle && this._renderTitle(), /*#__PURE__*/React.createElement("div", { className: classes.content, "data-hook": "modalMobileLayout-content" }, /*#__PURE__*/React.createElement("div", null, title && !stickyTitle && this._renderTitle(), content, footer && !stickyFooter && this._renderFooter())), footer && stickyFooter && this._renderFooter())); } }]); return ModalMobileLayout; }(React.PureComponent); _defineProperty(ModalMobileLayout, "displayName", 'ModalMobileLayout'); _defineProperty(ModalMobileLayout, "propTypes", { /** Applied as data-hook HTML attribute that can be used in the tests */ dataHook: PropTypes.string, /** A css class to be applied to the component's root element */ className: PropTypes.string, /** title node to be displayed in the header strip */ title: PropTypes.node, /** If true, the title will be sticky to the top of the modal */ stickyTitle: PropTypes.bool, /** content node to be displayed */ content: PropTypes.node, /** footer node to be displayed */ footer: PropTypes.node, /** If true, the footer will be sticky to the bottom of the modal */ stickyFooter: PropTypes.bool, /** callback for when there's a click on the overlay (in case the modal in not fullscreen) */ onOverlayClick: PropTypes.func, /** callback for when the the close button is clicked. **Note**: if this prop is not provided, then the close button will not be shown. */ onCloseButtonClick: PropTypes.func, /** If true, the modal will take all of the screen */ fullscreen: PropTypes.bool }); _defineProperty(ModalMobileLayout, "defaultProps", { stickyTitle: false, stickyFooter: false, fullscreen: false }); export default ModalMobileLayout;