FluidContainer.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 FluidContainer =
  24. /*#__PURE__*/
  25. function (_Module) {
  26. _inherits(FluidContainer, _Module);
  27. function FluidContainer(props) {
  28. var _this;
  29. _classCallCheck(this, FluidContainer);
  30. _this = _possibleConstructorReturn(this, _getPrototypeOf(FluidContainer).call(this, props));
  31. _this.state = {
  32. children: [],
  33. text: _this.text.value || ''
  34. };
  35. _this.mode = props._mode;
  36. _this.text.onUpdate(function (text) {
  37. _this.setState({
  38. text: text
  39. });
  40. });
  41. return _this;
  42. }
  43. _createClass(FluidContainer, [{
  44. key: "render",
  45. value: function render() {
  46. var bg = this.background.value || '',
  47. text = this.text.value || '',
  48. w = this.width.value ? this.width.value : 'auto',
  49. h = this.height.value ? this.height.value : 'auto';
  50. return _react.default.createElement("div", {
  51. className: " ".concat(Object.getPrototypeOf(this) === FluidContainer.prototype ? this.ClassName.value + " " + this.props.className || '' : ''),
  52. style: _objectSpread({
  53. background: bg,
  54. width: w,
  55. height: h
  56. }, this.props.style)
  57. }, this.state.text, _get(_getPrototypeOf(FluidContainer.prototype), "render", this).call(this));
  58. }
  59. }]);
  60. return FluidContainer;
  61. }(_Module2.default);
  62. FluidContainer.EditPosition = "top-left";
  63. FluidContainer.Inputs = _objectSpread({}, _Module2.default.Inputs, {
  64. width: {
  65. type: _Module2.default.Types.Text,
  66. required: true,
  67. defaultValue: 'auto'
  68. },
  69. height: {
  70. type: _Module2.default.Types.Text,
  71. required: false,
  72. defaultValue: "auto",
  73. comment: "Setting this comment here to show the power!"
  74. },
  75. background: {
  76. type: _Module2.default.Types.Text,
  77. required: false,
  78. comment: "Setting bg color!"
  79. },
  80. text: {
  81. type: _Module2.default.Types.Text,
  82. required: false,
  83. comment: "Text for Fluidcontainer"
  84. },
  85. ClassName: {
  86. type: _Module2.default.Types.Text,
  87. required: false
  88. }
  89. });
  90. FluidContainer.Outputs = {
  91. custom: {}
  92. };
  93. FluidContainer.Category = "Basic";
  94. var _default = FluidContainer;
  95. exports.default = _default;