UNPKG

shopperman

Version:

shopping cart ui for shopify stores

54 lines 3.03 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); var preact_1 = require("preact"); var mobx_preact_1 = require("mobx-preact"); var CartItemDisplay = /** @class */ (function (_super) { __extends(CartItemDisplay, _super); function CartItemDisplay() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.handleQuantityInputChange = function (event) { var input = event.target; var item = _this.props.item; var value = parseInt(input.value); item.setQuantity(value ? value : 0); }; _this.handleRemoval = function (event) { _this.props.item.setQuantity(0); }; return _this; } CartItemDisplay.prototype.render = function () { var _a = this.props, item = _a.item, cartItemText = _a.cartItemText; var product = item.product; return (preact_1.h("li", { className: "cart-item-display" }, preact_1.h("button", { className: "item-remove-button", onClick: this.handleRemoval, title: cartItemText.remove.title }), preact_1.h("input", { className: "item-quantity", type: "number", value: item.quantity.toString(), min: item.quantityMin, max: item.quantityMax, onChange: this.handleQuantityInputChange, onKeyUp: this.handleQuantityInputChange, onMouseUp: this.handleQuantityInputChange, onClick: this.handleQuantityInputChange, onBlur: this.handleQuantityInputChange }), preact_1.h("div", { className: "item-title" }, product.title), preact_1.h("div", { className: "item-price pricevalue" }, item.price))); }; CartItemDisplay = __decorate([ mobx_preact_1.observer ], CartItemDisplay); return CartItemDisplay; }(preact_1.Component)); exports.CartItemDisplay = CartItemDisplay; //# sourceMappingURL=cart-item-display.js.map