@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
198 lines (159 loc) • 8.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.StyledModalSection = void 0;
var React = _interopRequireWildcard(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _defaultTheme = _interopRequireDefault(require("../../defaultTheme"));
var _mediaQuery = _interopRequireDefault(require("../../utils/mediaQuery"));
var _ModalFooter = require("../ModalFooter");
var _ModalContext = require("../ModalContext");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var StyledModalSection = _styledComponents.default.section.withConfig({
displayName: "ModalSection__StyledModalSection",
componentId: "sc-1ayrdn8-0"
})(["width:100%;padding:", ";background-color:", ";border-bottom:1px solid ", ";box-sizing:border-box;&:first-of-type{border-top:", ";border-top-left-radius:", ";border-top-right-radius:", ";margin-top:", ";}&:last-of-type{border-bottom:", ";border-bottom-left-radius:", ";border-bottom-right-radius:", ";& ~ ", "{margin-top:", ";}&:not(:last-child){border-radius:0;}}", ";"], function (_ref) {
var theme = _ref.theme;
return "".concat(theme.orbit.spaceLarge, " ").concat(theme.orbit.spaceMedium);
}, function (_ref2) {
var theme = _ref2.theme,
suppressed = _ref2.suppressed;
return suppressed ? theme.orbit.paletteCloudLight : theme.orbit.paletteWhite;
}, function (_ref3) {
var theme = _ref3.theme;
return theme.orbit.paletteCloudNormal;
}, function (_ref4) {
var suppressed = _ref4.suppressed,
theme = _ref4.theme;
return suppressed && "1px solid ".concat(theme.orbit.paletteCloudNormal);
}, function (_ref5) {
var isMobileFullPage = _ref5.isMobileFullPage;
return !isMobileFullPage && "9px";
}, function (_ref6) {
var isMobileFullPage = _ref6.isMobileFullPage;
return !isMobileFullPage && "9px";
}, function (_ref7) {
var suppressed = _ref7.suppressed,
theme = _ref7.theme;
return suppressed && theme.orbit.spaceLarge;
}, function (_ref8) {
var suppressed = _ref8.suppressed,
theme = _ref8.theme;
return suppressed ? "1px solid ".concat(theme.orbit.paletteCloudNormal) : "0";
}, function (_ref9) {
var isMobileFullPage = _ref9.isMobileFullPage;
return !isMobileFullPage && "9px";
}, function (_ref10) {
var isMobileFullPage = _ref10.isMobileFullPage;
return !isMobileFullPage && "9px";
}, _ModalFooter.StyledModalFooter, function (_ref11) {
var theme = _ref11.theme,
suppressed = _ref11.suppressed;
return suppressed && theme.orbit.spaceMedium;
}, _mediaQuery.default.largeMobile((0, _styledComponents.css)(["padding:", ";&:first-of-type{margin-top:", ";}&:last-of-type{& ~ ", "{padding-top:", ";margin-top:0;}}"], function (_ref12) {
var theme = _ref12.theme;
return theme.orbit.spaceXXLarge;
}, function (_ref13) {
var suppressed = _ref13.suppressed,
theme = _ref13.theme;
return suppressed && theme.orbit.spaceXXLarge;
}, _ModalFooter.StyledModalFooter, function (_ref14) {
var suppressed = _ref14.suppressed;
return !suppressed && "0";
})));
exports.StyledModalSection = StyledModalSection;
StyledModalSection.defaultProps = {
theme: _defaultTheme.default
};
var ModalSection =
/*#__PURE__*/
function (_React$PureComponent) {
_inherits(ModalSection, _React$PureComponent);
function ModalSection() {
var _getPrototypeOf2;
var _this;
_classCallCheck(this, ModalSection);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(ModalSection)).call.apply(_getPrototypeOf2, [this].concat(args)));
_defineProperty(_assertThisInitialized(_this), "callContextFunctions", function () {
var _this$props = _this.props,
setDimensions = _this$props.setDimensions,
decideFixedFooter = _this$props.decideFixedFooter;
if (setDimensions) {
setDimensions();
}
if (decideFixedFooter) {
decideFixedFooter();
}
});
return _this;
}
_createClass(ModalSection, [{
key: "componentDidMount",
value: function componentDidMount() {
var setHasModalSection = this.props.setHasModalSection;
this.callContextFunctions();
if (setHasModalSection) {
setHasModalSection();
}
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
if (prevProps !== this.props) {
this.callContextFunctions();
var _this$props2 = this.props,
setHasModalSection = _this$props2.setHasModalSection,
manageFocus = _this$props2.manageFocus;
if (setHasModalSection) {
setHasModalSection();
}
if (manageFocus) {
manageFocus();
}
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var removeHasModalSection = this.props.removeHasModalSection;
this.callContextFunctions();
if (removeHasModalSection) {
removeHasModalSection();
}
}
}, {
key: "render",
value: function render() {
var _this$props3 = this.props,
suppressed = _this$props3.suppressed,
children = _this$props3.children,
dataTest = _this$props3.dataTest,
isMobileFullPage = _this$props3.isMobileFullPage;
return React.createElement(StyledModalSection, {
suppressed: suppressed,
"data-test": dataTest,
isMobileFullPage: isMobileFullPage
}, children);
}
}]);
return ModalSection;
}(React.PureComponent);
var DecoratedComponent = (0, _ModalContext.withModalContext)(ModalSection); // $FlowFixMe flow doesn't recognize displayName for functions
DecoratedComponent.displayName = "ModalSection";
var _default = DecoratedComponent;
exports.default = _default;