Card.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. require("./Card.css");
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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 _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); }
  13. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14. 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); } }
  15. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18. 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); }
  19. function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
  20. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  21. 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); }
  22. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  23. var UNIT_REGEX = /[A-Z]/g;
  24. var Card =
  25. /*#__PURE__*/
  26. function (_Module) {
  27. _inherits(Card, _Module);
  28. function Card(props) {
  29. var _this;
  30. _classCallCheck(this, Card);
  31. _this = _possibleConstructorReturn(this, _getPrototypeOf(Card).call(this, props));
  32. _this.state = {
  33. children: [],
  34. text: _this.header.value || ''
  35. };
  36. _this.mode = props._mode;
  37. return _this;
  38. }
  39. _createClass(Card, [{
  40. key: "render",
  41. value: function render() {
  42. var text = this.header.value || '',
  43. w = this.width.value ? this.width.value : 'auto',
  44. h = this.height.value ? this.height.value : 'auto',
  45. img = this.image.value;
  46. return _react.default.createElement("div", {
  47. className: "card shadow-sm ".concat(Object.getPrototypeOf(this) === Card.prototype ? this.props.className || '' : ''),
  48. style: {
  49. width: w,
  50. height: h
  51. }
  52. }, img ? _react.default.createElement("img", {
  53. class: "card-img-top",
  54. src: img,
  55. alt: "Card image cap"
  56. }) : '', _react.default.createElement("div", {
  57. className: "card-body"
  58. }, _react.default.createElement("div", {
  59. className: "card-title"
  60. }, text), _get(_getPrototypeOf(Card.prototype), "render", this).call(this)));
  61. }
  62. }]);
  63. return Card;
  64. }(_Module2.default);
  65. Card.EditPosition = "center";
  66. Card.Inputs = _objectSpread({}, _Module2.default.Inputs, {
  67. width: {
  68. type: _Module2.default.Types.Number,
  69. required: true,
  70. defaultValue: 'auto'
  71. },
  72. height: {
  73. type: _Module2.default.Types.Number,
  74. required: false,
  75. defaultValue: "auto"
  76. },
  77. header: {
  78. type: _Module2.default.Types.Text,
  79. required: false,
  80. defaultValue: ""
  81. },
  82. image: {
  83. type: _Module2.default.Types.Text,
  84. required: false,
  85. defaultValue: ""
  86. }
  87. });
  88. Card.Category = "theme";
  89. var _default = Card;
  90. exports.default = _default;