UNPKG

wix-style-react

Version:
125 lines (96 loc) 5.05 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _react = _interopRequireDefault(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _constants = require("./constants"); var _colorsSt = require("../Foundation/stylable/colors.st.css"); var _Box = _interopRequireDefault(require("../Box")); var _PreviewWidgetSt = require("./PreviewWidget.st.css"); function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(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; } } /** Preview content widget*/ var PreviewWidget = /*#__PURE__*/function (_React$PureComponent) { (0, _inherits2["default"])(PreviewWidget, _React$PureComponent); var _super = _createSuper(PreviewWidget); function PreviewWidget() { (0, _classCallCheck2["default"])(this, PreviewWidget); return _super.apply(this, arguments); } (0, _createClass2["default"])(PreviewWidget, [{ key: "render", value: function render() { var _this$props = this.props, dataHook = _this$props.dataHook, skin = _this$props.skin, contentOutline = _this$props.contentOutline, backgroundColor = _this$props.backgroundColor, height = _this$props.height, width = _this$props.width, children = _this$props.children, className = _this$props.className, scrollable = _this$props.scrollable; var rootStyles = { height: "".concat(height), width: "".concat(width), background: skin === _constants.skins.custom && (_colorsSt.stVars[backgroundColor] || backgroundColor) }; return /*#__PURE__*/_react["default"].createElement("div", { className: (0, _PreviewWidgetSt.st)(_PreviewWidgetSt.classes.root, { skin: skin, contentOutline: contentOutline, scrollable: scrollable }, className), "data-hook": dataHook, style: rootStyles }, /*#__PURE__*/_react["default"].createElement("div", { "data-hook": _constants.dataHooks.contentArea, className: _PreviewWidgetSt.classes.contentArea }, children)); } }]); return PreviewWidget; }(_react["default"].PureComponent); (0, _defineProperty2["default"])(PreviewWidget, "displayName", 'PreviewWidget'); (0, _defineProperty2["default"])(PreviewWidget, "propTypes", { /** Preview widget data hook*/ dataHook: _propTypes["default"].string, /** A css class to be applied to the component's root element */ className: _propTypes["default"].string, /** Background skin. To use `custom` skin, set it to custom and use the backgroundColor prop*/ skin: _propTypes["default"].oneOf(['neutral', 'gradient', 'custom']), /** Preview widget background color. Can be set with `design system` colors*/ backgroundColor: _propTypes["default"].string, /** Content area outline*/ contentOutline: _propTypes["default"].oneOf(['shadow', 'border', 'none']), /** Sets the height of the component */ height: _propTypes["default"].string, /** Sets the width of the component */ width: _propTypes["default"].string, /** Node to preview */ children: _propTypes["default"].node.isRequired, /** Enable scroll of the overflowed content **/ scrollable: _propTypes["default"].bool }); (0, _defineProperty2["default"])(PreviewWidget, "defaultProps", { skin: 'neutral', contentOutline: 'shadow', height: 'auto', width: '100%', scrollable: false, children: /*#__PURE__*/_react["default"].createElement(_Box["default"], { height: "50px", width: "50px" }) }); var _default = PreviewWidget; exports["default"] = _default;