CustomTable.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireWildcard(require("react"));
  7. var _reactMaterialize = require("react-materialize");
  8. var _modularityFront = _interopRequireDefault(require("modularity-front"));
  9. require("./CustomTable.css");
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. 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; } }
  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 Module = _modularityFront.default.Module;
  24. var CustomTable =
  25. /*#__PURE__*/
  26. function (_Modularity$Module) {
  27. _inherits(CustomTable, _Modularity$Module);
  28. function CustomTable(props) {
  29. _classCallCheck(this, CustomTable);
  30. return _possibleConstructorReturn(this, _getPrototypeOf(CustomTable).call(this, props));
  31. }
  32. _createClass(CustomTable, [{
  33. key: "render",
  34. value: function render() {
  35. var headers = this.TableHeader.value.map(function (header) {
  36. return _react.default.createElement("th", null, header);
  37. });
  38. var items = this.TableBody.value;
  39. var body = Object.keys(items).map(function (key, index) {
  40. return _react.default.createElement("tr", {
  41. key: index,
  42. className: "row_content"
  43. }, _react.default.createElement("td", null, items[key].name), _react.default.createElement("td", null, items[key].price, " \u20AC"), _react.default.createElement("td", null, items[key].quantity), _react.default.createElement("td", null, (items[key].price * items[key].quantity, 3).toFixed(2), " \u20AC"));
  44. });
  45. return _react.default.createElement(_reactMaterialize.Row, null, _react.default.createElement("table", {
  46. className: "custom_table"
  47. }, _react.default.createElement("thead", {
  48. className: "header"
  49. }, _react.default.createElement("tr", {
  50. className: "header_content"
  51. }, headers)), _react.default.createElement("tbody", {
  52. className: "table_body"
  53. }, body)), _get(_getPrototypeOf(CustomTable.prototype), "render", this).call(this));
  54. }
  55. }]);
  56. return CustomTable;
  57. }(_modularityFront.default.Module);
  58. CustomTable.EditPosition = "center";
  59. CustomTable.Inputs = {
  60. TableHeader: {
  61. type: Module.Types.Array,
  62. defaultValue: ['Selected Items', 'Unit Price', 'Quantity', 'SubTotal']
  63. },
  64. TableBody: {
  65. type: Module.Types.Object,
  66. defaultValue: {}
  67. }
  68. };
  69. CustomTable.Category = 'sxoinas';
  70. var _default = CustomTable;
  71. exports.default = _default;