Container.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _Module2 = _interopRequireDefault(require("../Module"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. 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); }
  10. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
  11. 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; }
  12. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13. 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); } }
  14. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  15. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17. function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
  18. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  19. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  20. 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); }
  21. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  22. var UNIT_REGEX = /[A-Z]/g;
  23. var Container =
  24. /*#__PURE__*/
  25. function (_Module) {
  26. _inherits(Container, _Module);
  27. function Container(props) {
  28. var _this;
  29. _classCallCheck(this, Container);
  30. _this = _possibleConstructorReturn(this, _getPrototypeOf(Container).call(this, props));
  31. _this.state = {
  32. children: []
  33. };
  34. _this.mode = props._mode;
  35. return _this;
  36. }
  37. _createClass(Container, [{
  38. key: "render",
  39. value: function render() {
  40. var bg = this.background.value || '',
  41. w = this.width.value ? this.width.value : 'auto',
  42. h = this.height.value ? this.height.value : 'auto';
  43. return _react.default.createElement("div", {
  44. className: "container ".concat(Object.getPrototypeOf(this) === Container.prototype ? this.props.className || this.ClassName.value : ''),
  45. style: _objectSpread({
  46. background: bg,
  47. width: w,
  48. height: h,
  49. padding: "" + this.Padding.value
  50. }, this.props.style)
  51. }, _get(_getPrototypeOf(Container.prototype), "render", this).call(this));
  52. }
  53. }]);
  54. return Container;
  55. }(_Module2.default);
  56. Container.EditPosition = "top-left";
  57. Container.Inputs = _objectSpread({}, _Module2.default.Inputs, {
  58. ClassName: {
  59. type: _Module2.default.Types.Text,
  60. required: false,
  61. comment: "ClassName"
  62. },
  63. width: {
  64. type: _Module2.default.Types.Text,
  65. required: true,
  66. defaultValue: 'auto'
  67. },
  68. height: {
  69. type: _Module2.default.Types.Text,
  70. required: false,
  71. defaultValue: "auto",
  72. comment: "Setting this comment here to show the power!"
  73. },
  74. background: {
  75. type: _Module2.default.Types.Text,
  76. required: false,
  77. comment: "Setting bg color!"
  78. },
  79. Padding: {
  80. type: _Module2.default.Types.Text
  81. }
  82. });
  83. Container.Outputs = {
  84. custom: {}
  85. };
  86. Container.Category = "Basic";
  87. var _default = Container;
  88. exports.default = _default;