@salla.sa/twilight-components 2.12.54 → 2.12.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/salla-add-product-button_41.cjs.entry.js +6 -6
- package/dist/cjs/salla-add-product-button_41.cjs.entry.js.map +1 -1
- package/dist/collection/components/salla-product-card/salla-product-card.js +6 -6
- package/dist/collection/components/salla-product-card/salla-product-card.js.map +1 -1
- package/dist/components/salla-product-card2.js +6 -6
- package/dist/components/salla-product-card2.js.map +1 -1
- package/dist/esm/salla-add-product-button_41.entry.js +6 -6
- package/dist/esm/salla-add-product-button_41.entry.js.map +1 -1
- package/dist/esm-es5/salla-add-product-button_41.entry.js +2 -2
- package/dist/esm-es5/salla-add-product-button_41.entry.js.map +1 -1
- package/dist/twilight/{p-79705026.entry.js → p-0cf37c22.entry.js} +2 -2
- package/dist/twilight/p-0cf37c22.entry.js.map +1 -0
- package/dist/twilight/{p-e90369c0.system.entry.js → p-4bb63f55.system.entry.js} +2 -2
- package/dist/twilight/{p-79705026.entry.js.map → p-4bb63f55.system.entry.js.map} +1 -1
- package/dist/twilight/p-9f2e0944.system.js +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/package.json +2 -2
- package/dist/twilight/p-e90369c0.system.entry.js.map +0 -1
|
@@ -98,7 +98,7 @@ export class SallaProductCard {
|
|
|
98
98
|
return h("h4", { class: "s-product-card-price" }, this.getPriceFormat((_c = this.productData) === null || _c === void 0 ? void 0 : _c.price));
|
|
99
99
|
}
|
|
100
100
|
render() {
|
|
101
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
101
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
102
102
|
const classes = {
|
|
103
103
|
's-product-card-entry': true,
|
|
104
104
|
's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,
|
|
@@ -119,16 +119,16 @@ export class SallaProductCard {
|
|
|
119
119
|
: 'cover'} lazy`, src: this.placeholder, alt: (_h = (_g = this.productData) === null || _g === void 0 ? void 0 : _g.image) === null || _h === void 0 ? void 0 : _h.alt, "data-src": ((_k = (_j = this.productData) === null || _j === void 0 ? void 0 : _j.image) === null || _k === void 0 ? void 0 : _k.url) || ((_l = this.productData) === null || _l === void 0 ? void 0 : _l.thumbnail) }), !this.fullImage && !this.minimal ? this.getProductBadge() : ''), this.fullImage && h("a", Object.assign({}, hrefProp, { class: "s-product-card-overlay" })), !this.horizontal && !this.fullImage ?
|
|
120
120
|
h("salla-button", { shape: "icon", fill: "none", color: "light", "aria-label": "Add or remove to wishlist", ref: el => this.wishlistBtn = el, class: "s-product-card-wishlist-btn animated", onClick: () => salla.wishlist.toggle(this.productData.id) }, h("span", { innerHTML: Heart })) : ''), h("div", { class: "s-product-card-content" }, this.isSpecial && ((_m = this.productData) === null || _m === void 0 ? void 0 : _m.quantity) ?
|
|
121
121
|
h("div", { class: "s-product-card-content-pie", ref: pie => this.pie = pie }, h("span", null, h("b", null, salla.helpers.number((_o = this.productData) === null || _o === void 0 ? void 0 : _o.quantity)), this.remained), h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -1 36 34", class: "s-product-card-content-pie-svg" }, h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-base" }), h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-bar" })))
|
|
122
|
-
: '', h("div", { class: { 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial } }, h("h3", { class: "s-product-card-content-title" }, h("a", {
|
|
123
|
-
h("p", { class: "s-product-card-content-subtitle" }, (
|
|
124
|
-
: ''), ((
|
|
125
|
-
[h("salla-progress-bar", { donation: (
|
|
122
|
+
: '', h("div", { class: { 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial } }, h("h3", { class: "s-product-card-content-title" }, h("a", Object.assign({}, hrefProp), (_p = this.productData) === null || _p === void 0 ? void 0 : _p.name)), ((_q = this.productData) === null || _q === void 0 ? void 0 : _q.subtitle) && !this.minimal ?
|
|
123
|
+
h("p", { class: "s-product-card-content-subtitle" }, (_r = this.productData) === null || _r === void 0 ? void 0 : _r.subtitle)
|
|
124
|
+
: ''), ((_s = this.productData) === null || _s === void 0 ? void 0 : _s.donation) && !this.minimal && !this.fullImage ?
|
|
125
|
+
[h("salla-progress-bar", { donation: (_t = this.productData) === null || _t === void 0 ? void 0 : _t.donation }), h("div", { class: "s-product-card-donation-input" }, ((_v = (_u = this.productData) === null || _u === void 0 ? void 0 : _u.donation) === null || _v === void 0 ? void 0 : _v.can_donate) ?
|
|
126
126
|
[h("label", { htmlFor: "donation-amount" }, this.donationAmount, " ", h("span", null, "*")), h("input", { type: "text", onInput: e => {
|
|
127
127
|
salla.helpers.inputDigitsOnly(e.target);
|
|
128
128
|
this.addBtn.donatingAmount = e.target.value;
|
|
129
129
|
}, id: "donation-amount", name: "donating_amount", class: "s-form-control", placeholder: this.donationAmount })]
|
|
130
130
|
: '')]
|
|
131
|
-
: '', h("div", { class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice(), ((
|
|
131
|
+
: '', h("div", { class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice(), ((_x = (_w = this.productData) === null || _w === void 0 ? void 0 : _w.rating) === null || _x === void 0 ? void 0 : _x.stars) && !this.minimal ?
|
|
132
132
|
h("div", { class: "s-product-card-rating" }, h("span", { innerHTML: Star }), h("span", null, this.productData.rating.stars))
|
|
133
133
|
: ''), this.isSpecial && this.productData.discount_ends
|
|
134
134
|
? h("salla-count-down", { date: this.formatDate(this.productData.discount_ends), "end-of-day": true, boxed: true, labeled: true })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salla-product-card.js","sourceRoot":"","sources":["../../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,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,aACjD,kBAAkB;gBAC1B,YAAM,KAAK,EAAC,SAAS,EAAC,SAAS,EAAE,KAAK,GAAI,CAC7B;cACf,CAAC,CAAC,EAAE,CACF;UACN,CAAC,CAAC,EAAE,CACF,CACD,CACR,CAAC;EACJ,CAAC;EAED,gBAAgB;;IACd,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACvE,IAAI,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,QAAQ,KAAI,IAAI,CAAC,SAAS,EAAE;MAChD,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;MACrG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\nimport Star from '../../assets/svg/star2.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n // TODO: Don't you think it's better not to render the component in this case?\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n private addBtn: HTMLSallaAddProductButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price || price == 0) {\n return salla.config.get('store.settings.product.show_price_as_dash')?'-':'';\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n const hrefProp = this.productData?.url ? { href: this.productData.url } : {};\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a {...hrefProp}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a {...hrefProp} class=\"s-product-card-overlay\" />}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart} />\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n : ''}\n\n <div class={{ 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n <h3 class=\"s-product-card-content-title\">\n <a href={this.productData?.url}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation} />,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.donation?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n onInput={e => {\n salla.helpers.inputDigitsOnly(e.target);\n this.addBtn.donatingAmount = (e.target as any).value;\n }}\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount} />]\n : ''}\n </div>]\n : ''}\n <div class={{ 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n {this.getProductPrice()}\n {this.productData?.rating?.stars && !this.minimal ?\n <div class=\"s-product-card-rating\">\n <span innerHTML={Star}/>\n <span>{this.productData.rating.stars}</span>\n </div>\n : ''}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true} />\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n ref={el => this.addBtn = el}\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart} />\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest() && salla.storage.get('salla::wishlist', []).includes(this.productData.id)) {\n this.toggleFavoriteIcon();\n }\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"salla-product-card.js","sourceRoot":"","sources":["../../../src/components/salla-product-card/salla-product-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,MAAM,4BAA4B,CAAC;AAC/C,OAAO,IAAI,MAAM,4BAA4B,CAAC;AAE9C;;GAEG;AAOH,MAAM,OAAO,gBAAgB;EAC3B;;;;;;;;;;;;;;;;;IACE,gBAAgB;IAChB,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;MAC1E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;MAC9E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;MACjF,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;IAEH,WAAW;IACX,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;MACvB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;MAC1D,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,GAA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AsC,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,aACjD,kBAAkB;gBAC1B,YAAM,KAAK,EAAC,SAAS,EAAC,SAAS,EAAE,KAAK,GAAI,CAC7B;cACf,CAAC,CAAC,EAAE,CACF;UACN,CAAC,CAAC,EAAE,CACF,CACD,CACR,CAAC;EACJ,CAAC;EAED,gBAAgB;;IACd,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACvE,IAAI,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,QAAQ,KAAI,IAAI,CAAC,SAAS,EAAE;MAChD,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;MACrG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\nimport Star from '../../assets/svg/star2.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n // TODO: Don't you think it's better not to render the component in this case?\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n private addBtn: HTMLSallaAddProductButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price || price == 0) {\n return salla.config.get('store.settings.product.show_price_as_dash')?'-':'';\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n const hrefProp = this.productData?.url ? { href: this.productData.url } : {};\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a {...hrefProp}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a {...hrefProp} class=\"s-product-card-overlay\" />}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart} />\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n : ''}\n\n <div class={{ 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n <h3 class=\"s-product-card-content-title\">\n <a {...hrefProp}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation} />,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.donation?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n onInput={e => {\n salla.helpers.inputDigitsOnly(e.target);\n this.addBtn.donatingAmount = (e.target as any).value;\n }}\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount} />]\n : ''}\n </div>]\n : ''}\n <div class={{ 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n {this.getProductPrice()}\n {this.productData?.rating?.stars && !this.minimal ?\n <div class=\"s-product-card-rating\">\n <span innerHTML={Star}/>\n <span>{this.productData.rating.stars}</span>\n </div>\n : ''}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true} />\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n ref={el => this.addBtn = el}\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart} />\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest() && salla.storage.get('salla::wishlist', []).includes(this.productData.id)) {\n this.toggleFavoriteIcon();\n }\n }\n\n}\n"]}
|
|
@@ -115,7 +115,7 @@ const SallaProductCard = /*@__PURE__*/ proxyCustomElement(class SallaProductCard
|
|
|
115
115
|
return h("h4", { class: "s-product-card-price" }, this.getPriceFormat((_c = this.productData) === null || _c === void 0 ? void 0 : _c.price));
|
|
116
116
|
}
|
|
117
117
|
render() {
|
|
118
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
119
119
|
const classes = {
|
|
120
120
|
's-product-card-entry': true,
|
|
121
121
|
's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,
|
|
@@ -136,16 +136,16 @@ const SallaProductCard = /*@__PURE__*/ proxyCustomElement(class SallaProductCard
|
|
|
136
136
|
: 'cover'} lazy`, src: this.placeholder, alt: (_h = (_g = this.productData) === null || _g === void 0 ? void 0 : _g.image) === null || _h === void 0 ? void 0 : _h.alt, "data-src": ((_k = (_j = this.productData) === null || _j === void 0 ? void 0 : _j.image) === null || _k === void 0 ? void 0 : _k.url) || ((_l = this.productData) === null || _l === void 0 ? void 0 : _l.thumbnail) }), !this.fullImage && !this.minimal ? this.getProductBadge() : ''), this.fullImage && h("a", Object.assign({}, hrefProp, { class: "s-product-card-overlay" })), !this.horizontal && !this.fullImage ?
|
|
137
137
|
h("salla-button", { shape: "icon", fill: "none", color: "light", "aria-label": "Add or remove to wishlist", ref: el => this.wishlistBtn = el, class: "s-product-card-wishlist-btn animated", onClick: () => salla.wishlist.toggle(this.productData.id) }, h("span", { innerHTML: Heart })) : ''), h("div", { class: "s-product-card-content" }, this.isSpecial && ((_m = this.productData) === null || _m === void 0 ? void 0 : _m.quantity) ?
|
|
138
138
|
h("div", { class: "s-product-card-content-pie", ref: pie => this.pie = pie }, h("span", null, h("b", null, salla.helpers.number((_o = this.productData) === null || _o === void 0 ? void 0 : _o.quantity)), this.remained), h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -1 36 34", class: "s-product-card-content-pie-svg" }, h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-base" }), h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-bar" })))
|
|
139
|
-
: '', h("div", { class: { 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial } }, h("h3", { class: "s-product-card-content-title" }, h("a", {
|
|
140
|
-
h("p", { class: "s-product-card-content-subtitle" }, (
|
|
141
|
-
: ''), ((
|
|
142
|
-
[h("salla-progress-bar", { donation: (
|
|
139
|
+
: '', h("div", { class: { 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial } }, h("h3", { class: "s-product-card-content-title" }, h("a", Object.assign({}, hrefProp), (_p = this.productData) === null || _p === void 0 ? void 0 : _p.name)), ((_q = this.productData) === null || _q === void 0 ? void 0 : _q.subtitle) && !this.minimal ?
|
|
140
|
+
h("p", { class: "s-product-card-content-subtitle" }, (_r = this.productData) === null || _r === void 0 ? void 0 : _r.subtitle)
|
|
141
|
+
: ''), ((_s = this.productData) === null || _s === void 0 ? void 0 : _s.donation) && !this.minimal && !this.fullImage ?
|
|
142
|
+
[h("salla-progress-bar", { donation: (_t = this.productData) === null || _t === void 0 ? void 0 : _t.donation }), h("div", { class: "s-product-card-donation-input" }, ((_v = (_u = this.productData) === null || _u === void 0 ? void 0 : _u.donation) === null || _v === void 0 ? void 0 : _v.can_donate) ?
|
|
143
143
|
[h("label", { htmlFor: "donation-amount" }, this.donationAmount, " ", h("span", null, "*")), h("input", { type: "text", onInput: e => {
|
|
144
144
|
salla.helpers.inputDigitsOnly(e.target);
|
|
145
145
|
this.addBtn.donatingAmount = e.target.value;
|
|
146
146
|
}, id: "donation-amount", name: "donating_amount", class: "s-form-control", placeholder: this.donationAmount })]
|
|
147
147
|
: '')]
|
|
148
|
-
: '', h("div", { class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice(), ((
|
|
148
|
+
: '', h("div", { class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice(), ((_x = (_w = this.productData) === null || _w === void 0 ? void 0 : _w.rating) === null || _x === void 0 ? void 0 : _x.stars) && !this.minimal ?
|
|
149
149
|
h("div", { class: "s-product-card-rating" }, h("span", { innerHTML: Rate }), h("span", null, this.productData.rating.stars))
|
|
150
150
|
: ''), this.isSpecial && this.productData.discount_ends
|
|
151
151
|
? h("salla-count-down", { date: this.formatDate(this.productData.discount_ends), "end-of-day": true, boxed: true, labeled: true })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-product-card2.js","mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,mBAAmB,GAAG,ghBAAghB;;MCa/hB,gBAAgB;EAC3B;;;;;;;;;;;;;;;;;;;;IAEE,KAAK,CAAC,OAAO,CAAC;MACZ,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;MAC1E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;MAC9E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;MACjF,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC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AAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACvE,IAAI,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,QAAQ,KAAI,IAAI,CAAC,SAAS,EAAE;MAChD,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;MACrG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["Star"],"sources":["src/components/salla-product-card/salla-product-card.scss?tag=salla-product-card","src/components/salla-product-card/salla-product-card.tsx"],"sourcesContent":[".s-product-card {\n &-entry {}\n\n &-image {\n &::before {\n font-family: \"sallaicons\";\n content: \"\\ec1f\" !important;\n }\n }\n\n &-vertical {}\n\n &-horizontal {}\n\n &-fit-height {}\n\n &-special {}\n\n &-full-image {}\n\n &-minimal {}\n\n &-donation {}\n\n &-shadow {}\n\n &-out-of-stock {}\n\n &-wishlist-btn {}\n\n &-content {\n &-main {}\n\n &-sub {}\n\n &-footer {}\n\n &-title {}\n\n &-subtitle {}\n\n &-pie {\n &-svg {\n circle {\n transition: stroke-dashoffset 1s linear;\n -webkit-transition: stroke-dashoffset 1s linear;\n -moz-transition: stroke-dashoffset 1s linear;\n -ms-transition: stroke-dashoffset 1s linear;\n -o-transition: stroke-dashoffset 1s linear;\n stroke: #E8EDF2;\n stroke-width: 2px;\n stroke-linecap: round;\n fill: none\n }\n\n &-base {}\n\n &-bar {\n stroke: var(--color-primary) !important;\n stroke-dasharray: 100 100;\n stroke-dashoffset: 100\n }\n }\n }\n\n // for special card\n &-extra-padding {}\n }\n\n &-donation-input {}\n}\n","import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\nimport Star from '../../assets/svg/star2.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n // TODO: Don't you think it's better not to render the component in this case?\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n private addBtn: HTMLSallaAddProductButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price || price == 0) {\n return salla.config.get('store.settings.product.show_price_as_dash')?'-':'';\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n const hrefProp = this.productData?.url ? { href: this.productData.url } : {};\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a {...hrefProp}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a {...hrefProp} class=\"s-product-card-overlay\" />}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart} />\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n : ''}\n\n <div class={{ 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n <h3 class=\"s-product-card-content-title\">\n <a href={this.productData?.url}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation} />,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.donation?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n onInput={e => {\n salla.helpers.inputDigitsOnly(e.target);\n this.addBtn.donatingAmount = (e.target as any).value;\n }}\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount} />]\n : ''}\n </div>]\n : ''}\n <div class={{ 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n {this.getProductPrice()}\n {this.productData?.rating?.stars && !this.minimal ?\n <div class=\"s-product-card-rating\">\n <span innerHTML={Star}/>\n <span>{this.productData.rating.stars}</span>\n </div>\n : ''}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true} />\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n ref={el => this.addBtn = el}\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart} />\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest() && salla.storage.get('salla::wishlist', []).includes(this.productData.id)) {\n this.toggleFavoriteIcon();\n }\n }\n\n}\n"],"version":3}
|
|
1
|
+
{"file":"salla-product-card2.js","mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,mBAAmB,GAAG,ghBAAghB;;MCa/hB,gBAAgB;EAC3B;;;;;;;;;;;;;;;;;;;;IAEE,KAAK,CAAC,OAAO,CAAC;MACZ,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;MAC1E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;MAC9E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;MACjF,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC;KACpF,CAAC,CAAC;;IAGH,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC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AAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;MACrG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;GACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["Star"],"sources":["src/components/salla-product-card/salla-product-card.scss?tag=salla-product-card","src/components/salla-product-card/salla-product-card.tsx"],"sourcesContent":[".s-product-card {\n &-entry {}\n\n &-image {\n &::before {\n font-family: \"sallaicons\";\n content: \"\\ec1f\" !important;\n }\n }\n\n &-vertical {}\n\n &-horizontal {}\n\n &-fit-height {}\n\n &-special {}\n\n &-full-image {}\n\n &-minimal {}\n\n &-donation {}\n\n &-shadow {}\n\n &-out-of-stock {}\n\n &-wishlist-btn {}\n\n &-content {\n &-main {}\n\n &-sub {}\n\n &-footer {}\n\n &-title {}\n\n &-subtitle {}\n\n &-pie {\n &-svg {\n circle {\n transition: stroke-dashoffset 1s linear;\n -webkit-transition: stroke-dashoffset 1s linear;\n -moz-transition: stroke-dashoffset 1s linear;\n -ms-transition: stroke-dashoffset 1s linear;\n -o-transition: stroke-dashoffset 1s linear;\n stroke: #E8EDF2;\n stroke-width: 2px;\n stroke-linecap: round;\n fill: none\n }\n\n &-base {}\n\n &-bar {\n stroke: var(--color-primary) !important;\n stroke-dasharray: 100 100;\n stroke-dashoffset: 100\n }\n }\n }\n\n // for special card\n &-extra-padding {}\n }\n\n &-donation-input {}\n}\n","import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\nimport Star from '../../assets/svg/star2.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n // TODO: Don't you think it's better not to render the component in this case?\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n private addBtn: HTMLSallaAddProductButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price || price == 0) {\n return salla.config.get('store.settings.product.show_price_as_dash')?'-':'';\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n const hrefProp = this.productData?.url ? { href: this.productData.url } : {};\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a {...hrefProp}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a {...hrefProp} class=\"s-product-card-overlay\" />}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart} />\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n : ''}\n\n <div class={{ 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n <h3 class=\"s-product-card-content-title\">\n <a {...hrefProp}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation} />,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.donation?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n onInput={e => {\n salla.helpers.inputDigitsOnly(e.target);\n this.addBtn.donatingAmount = (e.target as any).value;\n }}\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount} />]\n : ''}\n </div>]\n : ''}\n <div class={{ 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n {this.getProductPrice()}\n {this.productData?.rating?.stars && !this.minimal ?\n <div class=\"s-product-card-rating\">\n <span innerHTML={Star}/>\n <span>{this.productData.rating.stars}</span>\n </div>\n : ''}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true} />\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n ref={el => this.addBtn = el}\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart} />\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest() && salla.storage.get('salla::wishlist', []).includes(this.productData.id)) {\n this.toggleFavoriteIcon();\n }\n }\n\n}\n"],"version":3}
|
|
@@ -22242,7 +22242,7 @@ const SallaProductCard = class {
|
|
|
22242
22242
|
return h("h4", { class: "s-product-card-price" }, this.getPriceFormat((_c = this.productData) === null || _c === void 0 ? void 0 : _c.price));
|
|
22243
22243
|
}
|
|
22244
22244
|
render() {
|
|
22245
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
22245
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
22246
22246
|
const classes = {
|
|
22247
22247
|
's-product-card-entry': true,
|
|
22248
22248
|
's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,
|
|
@@ -22263,16 +22263,16 @@ const SallaProductCard = class {
|
|
|
22263
22263
|
: 'cover'} lazy`, src: this.placeholder, alt: (_h = (_g = this.productData) === null || _g === void 0 ? void 0 : _g.image) === null || _h === void 0 ? void 0 : _h.alt, "data-src": ((_k = (_j = this.productData) === null || _j === void 0 ? void 0 : _j.image) === null || _k === void 0 ? void 0 : _k.url) || ((_l = this.productData) === null || _l === void 0 ? void 0 : _l.thumbnail) }), !this.fullImage && !this.minimal ? this.getProductBadge() : ''), this.fullImage && h("a", Object.assign({}, hrefProp, { class: "s-product-card-overlay" })), !this.horizontal && !this.fullImage ?
|
|
22264
22264
|
h("salla-button", { shape: "icon", fill: "none", color: "light", "aria-label": "Add or remove to wishlist", ref: el => this.wishlistBtn = el, class: "s-product-card-wishlist-btn animated", onClick: () => salla.wishlist.toggle(this.productData.id) }, h("span", { innerHTML: Heart })) : ''), h("div", { class: "s-product-card-content" }, this.isSpecial && ((_m = this.productData) === null || _m === void 0 ? void 0 : _m.quantity) ?
|
|
22265
22265
|
h("div", { class: "s-product-card-content-pie", ref: pie => this.pie = pie }, h("span", null, h("b", null, salla.helpers.number((_o = this.productData) === null || _o === void 0 ? void 0 : _o.quantity)), this.remained), h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "-2 -1 36 34", class: "s-product-card-content-pie-svg" }, h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-base" }), h("circle", { cx: "16", cy: "16", r: "15.9155", class: "s-product-card-content-pie-svg-bar" })))
|
|
22266
|
-
: '', h("div", { class: { 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial } }, h("h3", { class: "s-product-card-content-title" }, h("a", {
|
|
22267
|
-
h("p", { class: "s-product-card-content-subtitle" }, (
|
|
22268
|
-
: ''), ((
|
|
22269
|
-
[h("salla-progress-bar", { donation: (
|
|
22266
|
+
: '', h("div", { class: { 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial } }, h("h3", { class: "s-product-card-content-title" }, h("a", Object.assign({}, hrefProp), (_p = this.productData) === null || _p === void 0 ? void 0 : _p.name)), ((_q = this.productData) === null || _q === void 0 ? void 0 : _q.subtitle) && !this.minimal ?
|
|
22267
|
+
h("p", { class: "s-product-card-content-subtitle" }, (_r = this.productData) === null || _r === void 0 ? void 0 : _r.subtitle)
|
|
22268
|
+
: ''), ((_s = this.productData) === null || _s === void 0 ? void 0 : _s.donation) && !this.minimal && !this.fullImage ?
|
|
22269
|
+
[h("salla-progress-bar", { donation: (_t = this.productData) === null || _t === void 0 ? void 0 : _t.donation }), h("div", { class: "s-product-card-donation-input" }, ((_v = (_u = this.productData) === null || _u === void 0 ? void 0 : _u.donation) === null || _v === void 0 ? void 0 : _v.can_donate) ?
|
|
22270
22270
|
[h("label", { htmlFor: "donation-amount" }, this.donationAmount, " ", h("span", null, "*")), h("input", { type: "text", onInput: e => {
|
|
22271
22271
|
salla.helpers.inputDigitsOnly(e.target);
|
|
22272
22272
|
this.addBtn.donatingAmount = e.target.value;
|
|
22273
22273
|
}, id: "donation-amount", name: "donating_amount", class: "s-form-control", placeholder: this.donationAmount })]
|
|
22274
22274
|
: '')]
|
|
22275
|
-
: '', h("div", { class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice(), ((
|
|
22275
|
+
: '', h("div", { class: { 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial } }, this.getProductPrice(), ((_x = (_w = this.productData) === null || _w === void 0 ? void 0 : _w.rating) === null || _x === void 0 ? void 0 : _x.stars) && !this.minimal ?
|
|
22276
22276
|
h("div", { class: "s-product-card-rating" }, h("span", { innerHTML: Rate }), h("span", null, this.productData.rating.stars))
|
|
22277
22277
|
: ''), this.isSpecial && this.productData.discount_ends
|
|
22278
22278
|
? h("salla-count-down", { date: this.formatDate(this.productData.discount_ends), "end-of-day": true, boxed: true, labeled: true })
|