@salla.sa/twilight-components 2.13.42 → 2.13.44

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.
Files changed (42) hide show
  1. package/dist/cjs/app-globals-45feca8f.js.map +1 -1
  2. package/dist/cjs/salla-add-product-button_47.cjs.entry.js +3 -3
  3. package/dist/cjs/salla-add-product-button_47.cjs.entry.js.map +1 -1
  4. package/dist/cjs/salla-reviews.cjs.entry.js +2 -1
  5. package/dist/cjs/salla-reviews.cjs.entry.js.map +1 -1
  6. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +3 -3
  7. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js.map +1 -1
  8. package/dist/collection/components/salla-reviews/salla-reviews.js +2 -1
  9. package/dist/collection/components/salla-reviews/salla-reviews.js.map +1 -1
  10. package/dist/components/index.js.map +1 -1
  11. package/dist/components/salla-quick-buy2.js +3 -3
  12. package/dist/components/salla-quick-buy2.js.map +1 -1
  13. package/dist/components/salla-reviews.js +2 -1
  14. package/dist/components/salla-reviews.js.map +1 -1
  15. package/dist/esm/app-globals-486fea68.js.map +1 -1
  16. package/dist/esm/salla-add-product-button_47.entry.js +3 -3
  17. package/dist/esm/salla-add-product-button_47.entry.js.map +1 -1
  18. package/dist/esm/salla-reviews.entry.js +2 -1
  19. package/dist/esm/salla-reviews.entry.js.map +1 -1
  20. package/dist/esm-es5/app-globals-486fea68.js.map +1 -1
  21. package/dist/esm-es5/salla-add-product-button_47.entry.js +1 -1
  22. package/dist/esm-es5/salla-add-product-button_47.entry.js.map +1 -1
  23. package/dist/esm-es5/salla-reviews.entry.js +1 -1
  24. package/dist/esm-es5/salla-reviews.entry.js.map +1 -1
  25. package/dist/twilight/{p-9ca75cfb.system.entry.js → p-40ce25f9.system.entry.js} +2 -2
  26. package/dist/twilight/p-40ce25f9.system.entry.js.map +1 -0
  27. package/dist/twilight/p-6005717c.system.js.map +1 -1
  28. package/dist/twilight/{p-f82c4cd5.system.entry.js → p-6b99863e.system.entry.js} +2 -2
  29. package/dist/twilight/p-6b99863e.system.entry.js.map +1 -0
  30. package/dist/twilight/{p-6c7b9377.entry.js → p-ae737289.entry.js} +2 -2
  31. package/dist/twilight/p-ae737289.entry.js.map +1 -0
  32. package/dist/twilight/p-bf392e76.system.js +1 -1
  33. package/dist/twilight/p-c1d20d62.js.map +1 -1
  34. package/dist/twilight/{p-d38e7783.entry.js → p-f209fb12.entry.js} +2 -2
  35. package/dist/twilight/p-f209fb12.entry.js.map +1 -0
  36. package/dist/twilight/twilight.esm.js +1 -1
  37. package/dist/types/global.d.ts +20 -0
  38. package/package.json +5 -5
  39. package/dist/twilight/p-6c7b9377.entry.js.map +0 -1
  40. package/dist/twilight/p-9ca75cfb.system.entry.js.map +0 -1
  41. package/dist/twilight/p-d38e7783.entry.js.map +0 -1
  42. package/dist/twilight/p-f82c4cd5.system.entry.js.map +0 -1
@@ -57,8 +57,9 @@ const SallaReviews = class {
57
57
  componentWillLoad() {
58
58
  return (new Promise(resolve => salla.onReady(resolve)))
59
59
  .then(() => this.fetchReviews())
60
+ .then((resp) => resp.data || [])
60
61
  .then(reviews => {
61
- if (reviews.length > 0) {
62
+ if (reviews.length) {
62
63
  this.reviews = reviews;
63
64
  this.showReviews = true;
64
65
  Helper.Helper.generateReviewSchema(this.reviews);
@@ -1 +1 @@
1
- {"file":"salla-reviews.entry.cjs.js","mappings":";;;;;;;;;;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,EAAE;;MCYb,YAAY;EACvB;;IAkEQ,kBAAa,GAAG,IAAI,CAAA;;kBA7Bc,OAAO;;iBAoBhB,CAAC;mBAGA,EAAE;;uBAEJ,KAAK;2BACF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC;8BACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;IA/D7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,KAAK,CAAC,O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K,EAClBA,iBAAK,KAAK,EAAC,qCAAqC,IAC9CA,iBAAK,KAAK,EAAC,6BAA6B,IACrC,IAAI,CAAC,IAAI,IAAIA,oBAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAM,CACnC,EACNA,iBAAK,KAAK,EAAC,+BAA+B,IAExCA,gCAAoB,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAuB,CACtE,CACF,CACF,EAENA,kBAAM,KAAK,EAAC,6BAA6B,EAAC,SAAS,EAAE,aAAa,GAAI,CAClE,CACF,CACF,CACP,CAAC,CACE,CACO,CACX,EACN;GACH;;;;;;","names":["Helper","h","IconArrowLeft","index"],"sources":["src/components/salla-reviews/salla-reviews.scss?tag=salla-reviews","src/components/salla-reviews/salla-reviews.tsx"],"sourcesContent":["","import { Component, Prop, State, h } from '@stencil/core';\nimport IconArrowLeft from '../../assets/svg/arrow-left.svg'\nimport IconQuoteOpen from '../../assets/svg/quote-open.svg'\n\nimport {Source, Review} from \"./interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n\n@Component({\n tag: 'salla-reviews',\n styleUrl: 'salla-reviews.scss',\n})\nexport class SallaReviews {\n constructor(){\n this.source = this.source;\n salla.onReady(() => {\n this.displayAllURL = salla.url.get('testimonials')\n this.isRTL = salla.config.get('theme.is_rtl', true)\n })\n\n salla.lang.onLoaded(() => { \n this.testimonialText = salla.lang.get('blocks.home.testimonials')\n this.displayAllLinkText = salla.lang.get('blocks.home.display_all')\n })\n }\n\n /**\n * Controls the visibility of a link to the reviews page.\n * \n * When set to `true`, a link will be displayed allowing users to navigate to the full reviews section.\n * \n * @type {boolean}\n */\n @Prop({ reflect: true }) displayAllLink: boolean\n\n /**\n * Specifies the data source for reviews.\n * \n * Valid options include:\n * - 'store': Retrieves reviews for the entire store.\n * - 'all': Retrieves reviews from all sources.\n * - 'categories': Retrieves reviews for specific product categories.\n * - 'products': Retrieves reviews for individual products.\n * - 'json': Retrieves reviews from a custom JSON payload provided in `sourceValue`.\n * \n * When using 'json' as the source, a valid payload must be provided in `sourceValue`.\n * \n * @type {Source}\n * @default \"store\"\n */\n @Prop({ reflect: true }) source: Source = \"store\";\n\n /**\n * Provides data specific to the chosen source.\n * \n * Required when using 'categories', 'products', or 'json' as the source:\n * - 'categories': An array of category IDs.\n * - 'products': An array of product IDs.\n * - 'json': A custom JSON object containing review data.\n * \n * @type {number | string | object | Array<string | number>}\n */\n @Prop({ reflect: true }) sourceValue: number | string | object | Array<string | number>;\n\n /**\n * Defines the maximum number of reviews to retrieve from the API.\n * \n * @type {number}\n * @default 5\n */\n @Prop({ reflect: true }) limit = 5\n\n\n @State() reviews: Array<Review> = [];\n @State() isRTL: boolean\n @State() showReviews: boolean = false;\n @State() testimonialText: string = salla.lang.get('blocks.home.testimonials');\n @State() displayAllLinkText: string = salla.lang.get('blocks.home.display_all');\n\n private displayAllURL = null\n\n fetchReviews() {\n if (this.source === 'json') {\n return Promise.resolve(JSON.parse(this.sourceValue as string));\n }\n const isJsonEncoded = ['products', 'categories'].includes(this.source);\n const params = {\n per_page: this.limit,\n type: this.source,\n items: isJsonEncoded ? JSON.parse(this.sourceValue as string) : this.sourceValue,\n };\n return salla.api.request('reviews', { params }, 'get');\n }\n\n\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(resolve)))\n .then(() => this.fetchReviews())\n .then(reviews => {\n if (reviews.length > 0) {\n this.reviews = reviews;\n this.showReviews = true;\n Helper.generateReviewSchema(this.reviews);\n }\n });\n }\n\n render() {\n return (\n <div class=\"s-reviews-container\">\n <div class=\"s-reviews-header-wrapper\">\n <h1 class=\"s-reviews-header\">\n {this.testimonialText}\n </h1>\n {!!this.displayAllLink ? (\n <a href={this.displayAllURL} class=\"s-reviews-display-all\">\n {this.displayAllLinkText}\n <span class=\"s-reviews-display-all-icon\" innerHTML={IconArrowLeft} />\n </a>\n ) : null}\n </div>\n <salla-slider\n centered\n slides-per-view={1}\n type=\"testimonials\"\n class=\"s-reviews-testimonials-slider\"\n controls-outer\n auto-play\n id={`testimonials-${this.source}-slider`}\n >\n <div slot=\"items\">\n {this.reviews.map((item: Review, index) => (\n <div key={index} class=\"s-reviews-swiper-slide\">\n <div class=\"s-reviews-testimonial\">\n <div class=\"s-reviews-testimonial__inner\">\n <div class=\"s-reviews-testimonial__avatar\">\n <img\n src={'images/s-empty.png'}\n data-src={item.avatar}\n alt={item.name ? item.name : 'testimonial-' + index}\n class=\"lazy\"\n />\n </div>\n <div class=\"s-reviews-testimonial__text\">\n <p>{item.text}</p>\n <div class=\"s-reviews-testimonial__name_wrapper\">\n <div class=\"s-reviews-testimonial__info\">\n {item.name && <h2>{`${item.name}`}</h2>}\n </div>\n <div class=\"s-reviews-testimonial__rating\">\n {/* TODO stars is missing */}\n <salla-rating-stars size=\"small\" value={item.rating}></salla-rating-stars>\n </div>\n </div>\n </div>\n\n <span class=\"s-reviews-testimonial__icon\" innerHTML={IconQuoteOpen} />\n </div>\n </div>\n </div>\n ))}\n </div>\n </salla-slider>\n </div>\n );\n }\n\n}\n\n"],"version":3}
1
+ {"file":"salla-reviews.entry.cjs.js","mappings":";;;;;;;;;;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,EAAE;;MCYb,YAAY;EACvB;;IAkEQ,kBAAa,GAAG,IAAI,CAAA;;kBA7Bc,OAAO;;iBAoBhB,CAAC;mBAGA,EAAE;;uBAEJ,KAAK;2BACF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC;8BACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;IA/D7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,KAAK,CAAC,OAAO,CAAC;MACZ,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;MAClD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,IAA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G,IAAI,CAAC,IAAI,EAAE,CAAM,CACnC,EACNA,iBAAK,KAAK,EAAC,+BAA+B,IAExCA,gCAAoB,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAuB,CACtE,CACF,CACF,EAENA,kBAAM,KAAK,EAAC,6BAA6B,EAAC,SAAS,EAAE,aAAa,GAAI,CAClE,CACF,CACF,CACP,CAAC,CACE,CACO,CACX,EACN;GACH;;;;;;","names":["Helper","h","IconArrowLeft","index"],"sources":["src/components/salla-reviews/salla-reviews.scss?tag=salla-reviews","src/components/salla-reviews/salla-reviews.tsx"],"sourcesContent":["","import { Component, Prop, State, h } from '@stencil/core';\nimport IconArrowLeft from '../../assets/svg/arrow-left.svg'\nimport IconQuoteOpen from '../../assets/svg/quote-open.svg'\n\nimport {Source, Review} from \"./interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n\n@Component({\n tag: 'salla-reviews',\n styleUrl: 'salla-reviews.scss',\n})\nexport class SallaReviews {\n constructor(){\n this.source = this.source;\n salla.onReady(() => {\n this.displayAllURL = salla.url.get('testimonials')\n this.isRTL = salla.config.get('theme.is_rtl', true)\n })\n\n salla.lang.onLoaded(() => { \n this.testimonialText = salla.lang.get('blocks.home.testimonials')\n this.displayAllLinkText = salla.lang.get('blocks.home.display_all')\n })\n }\n\n /**\n * Controls the visibility of a link to the reviews page.\n * \n * When set to `true`, a link will be displayed allowing users to navigate to the full reviews section.\n * \n * @type {boolean}\n */\n @Prop({ reflect: true }) displayAllLink: boolean\n\n /**\n * Specifies the data source for reviews.\n * \n * Valid options include:\n * - 'store': Retrieves reviews for the entire store.\n * - 'all': Retrieves reviews from all sources.\n * - 'categories': Retrieves reviews for specific product categories.\n * - 'products': Retrieves reviews for individual products.\n * - 'json': Retrieves reviews from a custom JSON payload provided in `sourceValue`.\n * \n * When using 'json' as the source, a valid payload must be provided in `sourceValue`.\n * \n * @type {Source}\n * @default \"store\"\n */\n @Prop({ reflect: true }) source: Source = \"store\";\n\n /**\n * Provides data specific to the chosen source.\n * \n * Required when using 'categories', 'products', or 'json' as the source:\n * - 'categories': An array of category IDs.\n * - 'products': An array of product IDs.\n * - 'json': A custom JSON object containing review data.\n * \n * @type {number | string | object | Array<string | number>}\n */\n @Prop({ reflect: true }) sourceValue: number | string | object | Array<string | number>;\n\n /**\n * Defines the maximum number of reviews to retrieve from the API.\n * \n * @type {number}\n * @default 5\n */\n @Prop({ reflect: true }) limit = 5\n\n\n @State() reviews: Array<Review> = [];\n @State() isRTL: boolean\n @State() showReviews: boolean = false;\n @State() testimonialText: string = salla.lang.get('blocks.home.testimonials');\n @State() displayAllLinkText: string = salla.lang.get('blocks.home.display_all');\n\n private displayAllURL = null\n\n fetchReviews() {\n if (this.source === 'json') {\n return Promise.resolve(JSON.parse(this.sourceValue as string));\n }\n const isJsonEncoded = ['products', 'categories'].includes(this.source);\n const params = {\n per_page: this.limit,\n type: this.source,\n items: isJsonEncoded ? JSON.parse(this.sourceValue as string) : this.sourceValue,\n };\n return salla.api.request('reviews', { params }, 'get');\n }\n\n\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(resolve)))\n .then(() => this.fetchReviews())\n .then((resp) => resp.data || [])\n .then(reviews => {\n if (reviews.length) {\n this.reviews = reviews;\n this.showReviews = true;\n Helper.generateReviewSchema(this.reviews);\n }\n });\n }\n\n render() {\n return (\n <div class=\"s-reviews-container\">\n <div class=\"s-reviews-header-wrapper\">\n <h1 class=\"s-reviews-header\">\n {this.testimonialText}\n </h1>\n {!!this.displayAllLink ? (\n <a href={this.displayAllURL} class=\"s-reviews-display-all\">\n {this.displayAllLinkText}\n <span class=\"s-reviews-display-all-icon\" innerHTML={IconArrowLeft} />\n </a>\n ) : null}\n </div>\n <salla-slider\n centered\n slides-per-view={1}\n type=\"testimonials\"\n class=\"s-reviews-testimonials-slider\"\n controls-outer\n auto-play\n id={`testimonials-${this.source}-slider`}\n >\n <div slot=\"items\">\n {this.reviews.map((item: Review, index) => (\n <div key={index} class=\"s-reviews-swiper-slide\">\n <div class=\"s-reviews-testimonial\">\n <div class=\"s-reviews-testimonial__inner\">\n <div class=\"s-reviews-testimonial__avatar\">\n <img\n src={'images/s-empty.png'}\n data-src={item.avatar}\n alt={item.name ? item.name : 'testimonial-' + index}\n class=\"lazy\"\n />\n </div>\n <div class=\"s-reviews-testimonial__text\">\n <p>{item.text}</p>\n <div class=\"s-reviews-testimonial__name_wrapper\">\n <div class=\"s-reviews-testimonial__info\">\n {item.name && <h2>{`${item.name}`}</h2>}\n </div>\n <div class=\"s-reviews-testimonial__rating\">\n {/* TODO stars is missing */}\n <salla-rating-stars size=\"small\" value={item.rating}></salla-rating-stars>\n </div>\n </div>\n </div>\n\n <span class=\"s-reviews-testimonial__icon\" innerHTML={IconQuoteOpen} />\n </div>\n </div>\n </div>\n ))}\n </div>\n </salla-slider>\n </div>\n );\n }\n\n}\n\n"],"version":3}
@@ -127,7 +127,7 @@ export class SallaQuickBuy {
127
127
  // if (!this.currency) {
128
128
  // this.currency = salla.config.get('user.currency_code');
129
129
  // }
130
- var _a, _b, _c, _d;
130
+ var _a, _b, _c;
131
131
  if (!this.productId && salla.config.get('page.id')) {
132
132
  this.productId = salla.config.get('page.id');
133
133
  }
@@ -170,8 +170,8 @@ export class SallaQuickBuy {
170
170
  this.currency = response.data.base_currency_price.currency;
171
171
  });
172
172
  }
173
- this.isApplePayActive = ((_c = window.ApplePaySession) === null || _c === void 0 ? void 0 : _c.canMakePayments())
174
- && ((_d = salla.config.get('store.settings.payments')) === null || _d === void 0 ? void 0 : _d.includes('apple_pay'))
173
+ this.isApplePayActive = salla.helpers.hasApplePay()
174
+ && ((_c = salla.config.get('store.settings.payments')) === null || _c === void 0 ? void 0 : _c.includes('apple_pay'))
175
175
  && salla.config.get('store.settings.is_salla_gateway', false);
176
176
  let applePaySdk = document.getElementById('apple-pay-sdk');
177
177
  if (applePaySdk || !this.isApplePayActive) {
@@ -1 +1 @@
1
- {"version":3,"file":"salla-quick-buy.js","sour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C,CAAC,wBAAkB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAChE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,yBACjB,UAAU,EAC9B,KAAK,EAAC,uBAAuB,sBACZ,GAAG,EACpB,WAAW,EAAC,OAAO,EACnB,IAAI,EAAE,IAAI,CAAC,IAAI,GAAI;MACrB,CAAC;QACD,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA,oBAAc,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,EAAE,EACzD,KAAK,EAAC,oBAAoB,EAC1B,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,SAAS,EACd,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,MAAM,EACZ,KAAK,EAAC,KAAK;UACvB,YAAM,SAAS,EAAE,UAAU,GAAG;UAC7B,IAAI,CAAC,QAAQ,CACD;UACf,CAAC,CAAC,EAAE,CAAC;EACT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport FullWallet from '../../assets/svg/full-wallet.svg';\nimport \"@salla.sa/applepay/src/index\";\n\n@Component({\n tag: 'salla-quick-buy',\n styleUrl: 'salla-quick-buy.scss',\n})\nexport class SallaQuickBuy {\n constructor() {\n salla.lang.onLoaded(() => {\n this.quickBuy = salla.lang.get('pages.products.buy_now');\n });\n }\n\n @Element() host: HTMLElement;\n\n /**\n * Button type.\n *\n * @type {string}\n * @default buy\n **/\n @Prop({ mutable: true }) type: 'plain' | 'buy' | 'donate' | 'book' | 'pay' | 'order' = 'buy';\n\n /**\n * Product ID.\n *\n * @type {string}\n **/\n @Prop({ mutable: true }) productId: string;\n\n /**\n * Cart ID, when you need to applePay for existed cart\n *\n * @type {string}\n **/\n @Prop({ mutable: true }) cartId: string;\n\n /**\n * Product amount in base currency (SAR).\n *\n * @type {number}\n * @default 0\n **/\n @Prop({ reflect: true, mutable: true }) amount: number;\n\n /**\n * base currency\n *\n * @type {string}\n * @default SAR\n */\n @Prop({ mutable: true }) currency: string;\n\n /**\n * Product options, if is empty will get the data from the document.querySelector('salla-product-options[product-id=\"X\"]')\n *\n * @type {object}\n * @default {}\n */\n @Prop() options = {};\n\n /**\n * To be passed to purchaseNow request\n * @type {boolean}\n **/\n @Prop({mutable: true}) isRequireShipping: boolean;\n \n /**\n * Show Apple Pay only\n * @type {boolean}\n **/\n @Prop({mutable: true}) applePayOnly: boolean;\n\n @State() isApplePayActive: boolean;\n\n @State() quickBuy: string = salla.lang.get('pages.products.buy_now');\n\n private async quickBuyHandler() {\n if (salla.config.isGuest()) {\n \n // todo (low) :: find a way to re-fire the method after success\n let afterLoginEvent = \"salla-quick-buy::user.logged-in\"\n salla.event.on(afterLoginEvent, () => this.settlePayment())\n salla.api.auth.setAfterLoginEvent(afterLoginEvent)\n return salla.auth.event.dispatch('login::open', { withoutReload: true });\n }\n await this.settlePayment()\n }\n\n private async settlePayment() {\n\n let optionsElement = document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as HTMLSallaProductOptionsElement;\n //make sure all the required options are selected\n if (optionsElement && !await optionsElement.reportValidity()) {\n return salla.error(salla.lang.get('common.messages.required_fields'));\n }\n\n //use this way to get quantity too\n let data = (this.host as any).getElementSallaData();\n\n // if the store doesn't have Apple Pay , just create a cart and then redirect to check out page\n if (!this.isApplePayActive) {\n // return salla.product.buyNow(this.productId, data);\n return salla.api.request('checkout/quick-purchase/' + this.productId, data, 'post')\n .then(resp => {\n if (resp.data.redirect) {\n window.location.href = resp.data.redirect;\n }\n return resp;\n });\n }\n data.is_applepay = true;\n\n if ('append' in data) {\n data.append('is_applepay', true);\n }\n\n // noinspection TypeScriptValidateJSTypes\n salla.event.dispatch('payments::apple-pay.start-transaction', {\n amount: this.amount, // 1000\n currency: this.currency || 'SAR', // SAR\n requiredShippingContactFields: this.isRequireShipping ? ['postalAddress'] : null,\n shippingMethods: this.isRequireShipping ? [] : null,\n supportedNetworks: salla.config.get('store.settings.buy_now.networks'),\n supportedCountries: salla.config.get('store.settings.buy_now.countries'),\n validateMerchant: {\n url: salla.url.get('checkout/applepay/validate'),\n onSuccess: (response) => {\n if (this.applePayOnly && !this.productId) { // the cart is not passes\n if (!this.cartId) {\n salla.logger.warn('🍏 Pay: trying to create applePay transaction without cartId/ProductId !');\n return Promise.resolve(response);\n }\n window.SallaApplePay.id = this.cartId;\n salla.log('🍏 Pay: create checkout success: with id #' + this.cartId);\n return Promise.resolve(response);\n\n }\n\n return salla.api.request('checkout/quick-purchase/' + this.productId, typeof data == 'object' ? data : undefined, 'post', {}).then(response => {\n\n // if is redirect url returned for any reason, lets redirect the user to check out\n if (response?.data?.redirect) {\n salla.log('🍏 Pay: create checkout success: redirect exits, go to checkout page');\n window.location.href = response.data.redirect.url;\n return response;\n }\n\n // the cart is not ready to complete apply pay session\n if (!response?.data?.id) {\n salla.logger.warn('🍏 Pay: create checkout success: No id, or redirect');\n return response;\n }\n\n window.SallaApplePay.id = response.data.id;\n\n salla.log('🍏 Pay: create checkout success: with id #' + window.SallaApplePay.id);\n });\n }\n },\n authorized: {\n // submit checkout route\n url: salla.url.get('checkout/{id}/payments/submit'),\n onFailed: (response) => {\n window.SallaApplePay.onCancel({}, response?.data?.error?.message || response?.data?.error?.code || salla.lang.get('pages.checkout.payment_failed'));\n },\n onSuccess: (response) => {\n window.location.href = response.redirect.url;\n salla.log('🍏 Pay: authorized Success:: redirect to thank you page, order placed');\n }\n },\n shippingMethodSelected: this.isRequireShipping ? {\n url: salla.url.get('checkout/{id}/shipping/details'),\n } : null,\n shippingContactSelected: this.isRequireShipping ? {\n url: salla.url.get('checkout/{id}/address/add'),\n } : null,\n oncouponcodechanged: {\n url: salla.url.get('checkout/{id}/coupons')\n },\n recalculateTotal: {\n url: salla.url.get('checkout/{id}/payments/recalculate?payment_method=apple_pay')\n },\n onError: function (message) {\n salla.log(message);\n salla.notify.error(message);\n }\n });\n }\n\n componentWillLoad() {\n return new Promise((resolve, reject) => {\n salla.onReady(async () => {\n\n // if (!this.currency) {\n // this.currency = salla.config.get('user.currency_code');\n // }\n\n if (!this.productId && salla.config.get('page.id')) {\n this.productId = salla.config.get('page.id');\n }\n\n if (!this.applePayOnly && !this.productId) {\n salla.logger.warn('🍏 Pay: Failed load the quick buy, the product id is missing')\n return reject()\n }\n\n /**\n * We should check the product if it's required shipping\n * in order for apple pay sdk to show the required Shipping Contact Fields\n * components..\n */\n if ((!this.amount || !this.isRequireShipping) && this.productId) {\n await salla.product.getDetails(this.productId, []).then((response) => {\n this.amount = response.data.base_currency_price.amount;\n this.currency = response.data.base_currency_price.currency;\n this.isRequireShipping = response?.data?.is_require_shipping || false;\n }).catch((error) => {\n salla.logger.warn('🍏 Pay: Failed load the quick buy, get the product details failed: ', error)\n return reject()\n })\n }\n\n\n\n if (this.type == 'donate') {\n salla.event.on('product-options::donation-changed', (data) => {\n if (String(data.id) !== String(this.productId)) {\n return;\n }\n\n this.amount = data.price;\n });\n if (salla.url.is_page('product.single')) {\n salla.product.event?.onPriceUpdated(response => {\n this.currency = response.data.base_currency_price.currency;\n });\n }\n } else if (salla.url.is_page('product.single')) {\n salla.product.event?.onPriceUpdated(response => {\n this.amount = response.data.base_currency_price.amount;\n this.currency = response.data.base_currency_price.currency;\n });\n }\n this.isApplePayActive = window.ApplePaySession?.canMakePayments()\n && salla.config.get('store.settings.payments')?.includes('apple_pay')\n && salla.config.get('store.settings.is_salla_gateway', false);\n\n let applePaySdk = document.getElementById('apple-pay-sdk');\n if (applePaySdk || !this.isApplePayActive) {\n salla.logger.warn('🍏 Pay: Skipped load apple pay because ' + (applePaySdk ? 'already loaded' : 'is not available in the browser'))\n resolve(true);\n return;\n }\n\n const script = document.createElement('script');\n script.src = 'https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js';\n script.setAttribute('id', 'apple-pay-sdk');\n script.async = true;\n\n document.body.appendChild(script);\n\n resolve(true);\n })\n })\n }\n\n render() {\n return <Host>{this.quickBuyButton()}</Host>\n }\n\n private quickBuyButton() {\n return this.isApplePayActive\n ? <apple-pay-button locale={salla.config.get('user.language_code')}\n onClick={() => this.quickBuyHandler()}\n data-quick-purchase=\"applepay\"\n class=\"s-quick-buy-apple-pay\"\n data-is-applepay=\"1\"\n buttonstyle=\"black\"\n type={this.type} />\n :\n !this.applePayOnly ?<salla-button onClick={() => this.quickBuyHandler()}\n class=\"s-quick-buy-button\"\n color=\"primary\"\n fill=\"outline\"\n size=\"medium\"\n width=\"wide\"\n shape=\"btn\">\n <span innerHTML={FullWallet}/>\n {this.quickBuy}\n </salla-button>\n : '';\n }\n}\n"]}
1
+ {"version":3,"file":"salla-quick-buy.js","sourceRoot":"","sources":["../../../src/components/salla-quick-buy/salla-quick-buy.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,8BAA8B,CAAC;AAMtC,MAAM,OAAO,aAAa;EACxB;gBAcuF,KAAK;;;;;mBAsC1E,EAAE;;;;oBAgBQ,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC;IAnElE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;MACvB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;GACJ;EAkEO,KAAK,CAAC,eAAe;IAC3B,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CACD;UACf,CAAC,CAAC,EAAE,CAAC;EACT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport FullWallet from '../../assets/svg/full-wallet.svg';\nimport \"@salla.sa/applepay/src/index\";\n\n@Component({\n tag: 'salla-quick-buy',\n styleUrl: 'salla-quick-buy.scss',\n})\nexport class SallaQuickBuy {\n constructor() {\n salla.lang.onLoaded(() => {\n this.quickBuy = salla.lang.get('pages.products.buy_now');\n });\n }\n\n @Element() host: HTMLElement;\n\n /**\n * Button type.\n *\n * @type {string}\n * @default buy\n **/\n @Prop({ mutable: true }) type: 'plain' | 'buy' | 'donate' | 'book' | 'pay' | 'order' = 'buy';\n\n /**\n * Product ID.\n *\n * @type {string}\n **/\n @Prop({ mutable: true }) productId: string;\n\n /**\n * Cart ID, when you need to applePay for existed cart\n *\n * @type {string}\n **/\n @Prop({ mutable: true }) cartId: string;\n\n /**\n * Product amount in base currency (SAR).\n *\n * @type {number}\n * @default 0\n **/\n @Prop({ reflect: true, mutable: true }) amount: number;\n\n /**\n * base currency\n *\n * @type {string}\n * @default SAR\n */\n @Prop({ mutable: true }) currency: string;\n\n /**\n * Product options, if is empty will get the data from the document.querySelector('salla-product-options[product-id=\"X\"]')\n *\n * @type {object}\n * @default {}\n */\n @Prop() options = {};\n\n /**\n * To be passed to purchaseNow request\n * @type {boolean}\n **/\n @Prop({mutable: true}) isRequireShipping: boolean;\n \n /**\n * Show Apple Pay only\n * @type {boolean}\n **/\n @Prop({mutable: true}) applePayOnly: boolean;\n\n @State() isApplePayActive: boolean;\n\n @State() quickBuy: string = salla.lang.get('pages.products.buy_now');\n\n private async quickBuyHandler() {\n if (salla.config.isGuest()) {\n \n // todo (low) :: find a way to re-fire the method after success\n let afterLoginEvent = \"salla-quick-buy::user.logged-in\"\n salla.event.on(afterLoginEvent, () => this.settlePayment())\n salla.api.auth.setAfterLoginEvent(afterLoginEvent)\n return salla.auth.event.dispatch('login::open', { withoutReload: true });\n }\n await this.settlePayment()\n }\n\n private async settlePayment() {\n\n let optionsElement = document.querySelector(`salla-product-options[product-id=\"${this.productId}\"]`) as HTMLSallaProductOptionsElement;\n //make sure all the required options are selected\n if (optionsElement && !await optionsElement.reportValidity()) {\n return salla.error(salla.lang.get('common.messages.required_fields'));\n }\n\n //use this way to get quantity too\n let data = (this.host as any).getElementSallaData();\n\n // if the store doesn't have Apple Pay , just create a cart and then redirect to check out page\n if (!this.isApplePayActive) {\n // return salla.product.buyNow(this.productId, data);\n return salla.api.request('checkout/quick-purchase/' + this.productId, data, 'post')\n .then(resp => {\n if (resp.data.redirect) {\n window.location.href = resp.data.redirect;\n }\n return resp;\n });\n }\n data.is_applepay = true;\n\n if ('append' in data) {\n data.append('is_applepay', true);\n }\n\n // noinspection TypeScriptValidateJSTypes\n salla.event.dispatch('payments::apple-pay.start-transaction', {\n amount: this.amount, // 1000\n currency: this.currency || 'SAR', // SAR\n requiredShippingContactFields: this.isRequireShipping ? ['postalAddress'] : null,\n shippingMethods: this.isRequireShipping ? [] : null,\n supportedNetworks: salla.config.get('store.settings.buy_now.networks'),\n supportedCountries: salla.config.get('store.settings.buy_now.countries'),\n validateMerchant: {\n url: salla.url.get('checkout/applepay/validate'),\n onSuccess: (response) => {\n if (this.applePayOnly && !this.productId) { // the cart is not passes\n if (!this.cartId) {\n salla.logger.warn('🍏 Pay: trying to create applePay transaction without cartId/ProductId !');\n return Promise.resolve(response);\n }\n window.SallaApplePay.id = this.cartId;\n salla.log('🍏 Pay: create checkout success: with id #' + this.cartId);\n return Promise.resolve(response);\n\n }\n\n return salla.api.request('checkout/quick-purchase/' + this.productId, typeof data == 'object' ? data : undefined, 'post', {}).then(response => {\n\n // if is redirect url returned for any reason, lets redirect the user to check out\n if (response?.data?.redirect) {\n salla.log('🍏 Pay: create checkout success: redirect exits, go to checkout page');\n window.location.href = response.data.redirect.url;\n return response;\n }\n\n // the cart is not ready to complete apply pay session\n if (!response?.data?.id) {\n salla.logger.warn('🍏 Pay: create checkout success: No id, or redirect');\n return response;\n }\n\n window.SallaApplePay.id = response.data.id;\n\n salla.log('🍏 Pay: create checkout success: with id #' + window.SallaApplePay.id);\n });\n }\n },\n authorized: {\n // submit checkout route\n url: salla.url.get('checkout/{id}/payments/submit'),\n onFailed: (response) => {\n window.SallaApplePay.onCancel({}, response?.data?.error?.message || response?.data?.error?.code || salla.lang.get('pages.checkout.payment_failed'));\n },\n onSuccess: (response) => {\n window.location.href = response.redirect.url;\n salla.log('🍏 Pay: authorized Success:: redirect to thank you page, order placed');\n }\n },\n shippingMethodSelected: this.isRequireShipping ? {\n url: salla.url.get('checkout/{id}/shipping/details'),\n } : null,\n shippingContactSelected: this.isRequireShipping ? {\n url: salla.url.get('checkout/{id}/address/add'),\n } : null,\n oncouponcodechanged: {\n url: salla.url.get('checkout/{id}/coupons')\n },\n recalculateTotal: {\n url: salla.url.get('checkout/{id}/payments/recalculate?payment_method=apple_pay')\n },\n onError: function (message) {\n salla.log(message);\n salla.notify.error(message);\n }\n });\n }\n\n componentWillLoad() {\n return new Promise((resolve, reject) => {\n salla.onReady(async () => {\n\n // if (!this.currency) {\n // this.currency = salla.config.get('user.currency_code');\n // }\n\n if (!this.productId && salla.config.get('page.id')) {\n this.productId = salla.config.get('page.id');\n }\n\n if (!this.applePayOnly && !this.productId) {\n salla.logger.warn('🍏 Pay: Failed load the quick buy, the product id is missing')\n return reject()\n }\n\n /**\n * We should check the product if it's required shipping\n * in order for apple pay sdk to show the required Shipping Contact Fields\n * components..\n */\n if ((!this.amount || !this.isRequireShipping) && this.productId) {\n await salla.product.getDetails(this.productId, []).then((response) => {\n this.amount = response.data.base_currency_price.amount;\n this.currency = response.data.base_currency_price.currency;\n this.isRequireShipping = response?.data?.is_require_shipping || false;\n }).catch((error) => {\n salla.logger.warn('🍏 Pay: Failed load the quick buy, get the product details failed: ', error)\n return reject()\n })\n }\n\n\n\n if (this.type == 'donate') {\n salla.event.on('product-options::donation-changed', (data) => {\n if (String(data.id) !== String(this.productId)) {\n return;\n }\n\n this.amount = data.price;\n });\n if (salla.url.is_page('product.single')) {\n salla.product.event?.onPriceUpdated(response => {\n this.currency = response.data.base_currency_price.currency;\n });\n }\n } else if (salla.url.is_page('product.single')) {\n salla.product.event?.onPriceUpdated(response => {\n this.amount = response.data.base_currency_price.amount;\n this.currency = response.data.base_currency_price.currency;\n });\n }\n this.isApplePayActive = salla.helpers.hasApplePay()\n && salla.config.get('store.settings.payments')?.includes('apple_pay')\n && salla.config.get('store.settings.is_salla_gateway', false);\n\n let applePaySdk = document.getElementById('apple-pay-sdk');\n if (applePaySdk || !this.isApplePayActive) {\n salla.logger.warn('🍏 Pay: Skipped load apple pay because ' + (applePaySdk ? 'already loaded' : 'is not available in the browser'))\n resolve(true);\n return;\n }\n\n const script = document.createElement('script');\n script.src = 'https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js';\n script.setAttribute('id', 'apple-pay-sdk');\n script.async = true;\n\n document.body.appendChild(script);\n\n resolve(true);\n })\n })\n }\n\n render() {\n return <Host>{this.quickBuyButton()}</Host>\n }\n\n private quickBuyButton() {\n return this.isApplePayActive\n ? <apple-pay-button locale={salla.config.get('user.language_code')}\n onClick={() => this.quickBuyHandler()}\n data-quick-purchase=\"applepay\"\n class=\"s-quick-buy-apple-pay\"\n data-is-applepay=\"1\"\n buttonstyle=\"black\"\n type={this.type} />\n :\n !this.applePayOnly ?<salla-button onClick={() => this.quickBuyHandler()}\n class=\"s-quick-buy-button\"\n color=\"primary\"\n fill=\"outline\"\n size=\"medium\"\n width=\"wide\"\n shape=\"btn\">\n <span innerHTML={FullWallet}/>\n {this.quickBuy}\n </salla-button>\n : '';\n }\n}\n"]}
@@ -42,8 +42,9 @@ export class SallaReviews {
42
42
  componentWillLoad() {
43
43
  return (new Promise(resolve => salla.onReady(resolve)))
44
44
  .then(() => this.fetchReviews())
45
+ .then((resp) => resp.data || [])
45
46
  .then(reviews => {
46
- if (reviews.length > 0) {
47
+ if (reviews.length) {
47
48
  this.reviews = reviews;
48
49
  this.showReviews = true;
49
50
  Helper.generateReviewSchema(this.reviews);
@@ -1 +1 @@
1
- {"version":3,"file":"salla-reviews.js","sourceRoot":"","sources":["../../../src/components/salla-reviews/salla-reviews.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,aAAa,MAAM,iCAAiC,CAAA;AAC3D,OAAO,aAAa,MAAM,iCAAiC,CAAA;AAG3D,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAO1C,MAAM,OAAO,YAAY;EACvB;IAkEQ,kBAAa,GAAG,IAAI,CAAA;;kBA7Bc,OAAO;;iBAoBhB,CAAC;mBAGA,EAAE;;uBAEJ,KAAK;2BACF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC;8BACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;IA/D7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;MAClD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;IAEF,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;MACvB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,I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AK,KAAK,EAAC,+BAA+B;oBAExC,0BAAoB,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAuB,CACtE,CACF,CACF;cAEN,YAAM,KAAK,EAAC,6BAA6B,EAAC,SAAS,EAAE,aAAa,GAAI,CAClE,CACF,CACF,CACP,CAAC,CACE,CACO,CACX,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Prop, State, h } from '@stencil/core';\nimport IconArrowLeft from '../../assets/svg/arrow-left.svg'\nimport IconQuoteOpen from '../../assets/svg/quote-open.svg'\n\nimport {Source, Review} from \"./interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n\n@Component({\n tag: 'salla-reviews',\n styleUrl: 'salla-reviews.scss',\n})\nexport class SallaReviews {\n constructor(){\n this.source = this.source;\n salla.onReady(() => {\n this.displayAllURL = salla.url.get('testimonials')\n this.isRTL = salla.config.get('theme.is_rtl', true)\n })\n\n salla.lang.onLoaded(() => { \n this.testimonialText = salla.lang.get('blocks.home.testimonials')\n this.displayAllLinkText = salla.lang.get('blocks.home.display_all')\n })\n }\n\n /**\n * Controls the visibility of a link to the reviews page.\n * \n * When set to `true`, a link will be displayed allowing users to navigate to the full reviews section.\n * \n * @type {boolean}\n */\n @Prop({ reflect: true }) displayAllLink: boolean\n\n /**\n * Specifies the data source for reviews.\n * \n * Valid options include:\n * - 'store': Retrieves reviews for the entire store.\n * - 'all': Retrieves reviews from all sources.\n * - 'categories': Retrieves reviews for specific product categories.\n * - 'products': Retrieves reviews for individual products.\n * - 'json': Retrieves reviews from a custom JSON payload provided in `sourceValue`.\n * \n * When using 'json' as the source, a valid payload must be provided in `sourceValue`.\n * \n * @type {Source}\n * @default \"store\"\n */\n @Prop({ reflect: true }) source: Source = \"store\";\n\n /**\n * Provides data specific to the chosen source.\n * \n * Required when using 'categories', 'products', or 'json' as the source:\n * - 'categories': An array of category IDs.\n * - 'products': An array of product IDs.\n * - 'json': A custom JSON object containing review data.\n * \n * @type {number | string | object | Array<string | number>}\n */\n @Prop({ reflect: true }) sourceValue: number | string | object | Array<string | number>;\n\n /**\n * Defines the maximum number of reviews to retrieve from the API.\n * \n * @type {number}\n * @default 5\n */\n @Prop({ reflect: true }) limit = 5\n\n\n @State() reviews: Array<Review> = [];\n @State() isRTL: boolean\n @State() showReviews: boolean = false;\n @State() testimonialText: string = salla.lang.get('blocks.home.testimonials');\n @State() displayAllLinkText: string = salla.lang.get('blocks.home.display_all');\n\n private displayAllURL = null\n\n fetchReviews() {\n if (this.source === 'json') {\n return Promise.resolve(JSON.parse(this.sourceValue as string));\n }\n const isJsonEncoded = ['products', 'categories'].includes(this.source);\n const params = {\n per_page: this.limit,\n type: this.source,\n items: isJsonEncoded ? JSON.parse(this.sourceValue as string) : this.sourceValue,\n };\n return salla.api.request('reviews', { params }, 'get');\n }\n\n\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(resolve)))\n .then(() => this.fetchReviews())\n .then(reviews => {\n if (reviews.length > 0) {\n this.reviews = reviews;\n this.showReviews = true;\n Helper.generateReviewSchema(this.reviews);\n }\n });\n }\n\n render() {\n return (\n <div class=\"s-reviews-container\">\n <div class=\"s-reviews-header-wrapper\">\n <h1 class=\"s-reviews-header\">\n {this.testimonialText}\n </h1>\n {!!this.displayAllLink ? (\n <a href={this.displayAllURL} class=\"s-reviews-display-all\">\n {this.displayAllLinkText}\n <span class=\"s-reviews-display-all-icon\" innerHTML={IconArrowLeft} />\n </a>\n ) : null}\n </div>\n <salla-slider\n centered\n slides-per-view={1}\n type=\"testimonials\"\n class=\"s-reviews-testimonials-slider\"\n controls-outer\n auto-play\n id={`testimonials-${this.source}-slider`}\n >\n <div slot=\"items\">\n {this.reviews.map((item: Review, index) => (\n <div key={index} class=\"s-reviews-swiper-slide\">\n <div class=\"s-reviews-testimonial\">\n <div class=\"s-reviews-testimonial__inner\">\n <div class=\"s-reviews-testimonial__avatar\">\n <img\n src={'images/s-empty.png'}\n data-src={item.avatar}\n alt={item.name ? item.name : 'testimonial-' + index}\n class=\"lazy\"\n />\n </div>\n <div class=\"s-reviews-testimonial__text\">\n <p>{item.text}</p>\n <div class=\"s-reviews-testimonial__name_wrapper\">\n <div class=\"s-reviews-testimonial__info\">\n {item.name && <h2>{`${item.name}`}</h2>}\n </div>\n <div class=\"s-reviews-testimonial__rating\">\n {/* TODO stars is missing */}\n <salla-rating-stars size=\"small\" value={item.rating}></salla-rating-stars>\n </div>\n </div>\n </div>\n\n <span class=\"s-reviews-testimonial__icon\" innerHTML={IconQuoteOpen} />\n </div>\n </div>\n </div>\n ))}\n </div>\n </salla-slider>\n </div>\n );\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"salla-reviews.js","sourceRoot":"","sources":["../../../src/components/salla-reviews/salla-reviews.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,aAAa,MAAM,iCAAiC,CAAA;AAC3D,OAAO,aAAa,MAAM,iCAAiC,CAAA;AAG3D,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAO1C,MAAM,OAAO,YAAY;EACvB;IAkEQ,kBAAa,GAAG,IAAI,CAAA;;kBA7Bc,OAAO;;iBAoBhB,CAAC;mBAGA,EAAE;;uBAEJ,KAAK;2BACF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,0BAA0B,CAAC;8BACvC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAyB,CAAC;IA/D7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,GAA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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,GAAG,KAAK,EACnD,KAAK,EAAC,MAAM,GACZ,CACE;cACN,WAAK,KAAK,EAAC,6BAA6B;gBACtC,aAAI,IAAI,CAAC,IAAI,CAAK;gBAClB,WAAK,KAAK,EAAC,qCAAqC;kBAC9C,WAAK,KAAK,EAAC,6BAA6B,IACrC,IAAI,CAAC,IAAI,IAAI,cAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAM,CACnC;kBACN,WAAK,KAAK,EAAC,+BAA+B;oBAExC,0BAAoB,IAAI,EAAC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAuB,CACtE,CACF,CACF;cAEN,YAAM,KAAK,EAAC,6BAA6B,EAAC,SAAS,EAAE,aAAa,GAAI,CAClE,CACF,CACF,CACP,CAAC,CACE,CACO,CACX,CACP,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Prop, State, h } from '@stencil/core';\nimport IconArrowLeft from '../../assets/svg/arrow-left.svg'\nimport IconQuoteOpen from '../../assets/svg/quote-open.svg'\n\nimport {Source, Review} from \"./interfaces\"\nimport Helper from '../../Helpers/Helper';\n\n\n@Component({\n tag: 'salla-reviews',\n styleUrl: 'salla-reviews.scss',\n})\nexport class SallaReviews {\n constructor(){\n this.source = this.source;\n salla.onReady(() => {\n this.displayAllURL = salla.url.get('testimonials')\n this.isRTL = salla.config.get('theme.is_rtl', true)\n })\n\n salla.lang.onLoaded(() => { \n this.testimonialText = salla.lang.get('blocks.home.testimonials')\n this.displayAllLinkText = salla.lang.get('blocks.home.display_all')\n })\n }\n\n /**\n * Controls the visibility of a link to the reviews page.\n * \n * When set to `true`, a link will be displayed allowing users to navigate to the full reviews section.\n * \n * @type {boolean}\n */\n @Prop({ reflect: true }) displayAllLink: boolean\n\n /**\n * Specifies the data source for reviews.\n * \n * Valid options include:\n * - 'store': Retrieves reviews for the entire store.\n * - 'all': Retrieves reviews from all sources.\n * - 'categories': Retrieves reviews for specific product categories.\n * - 'products': Retrieves reviews for individual products.\n * - 'json': Retrieves reviews from a custom JSON payload provided in `sourceValue`.\n * \n * When using 'json' as the source, a valid payload must be provided in `sourceValue`.\n * \n * @type {Source}\n * @default \"store\"\n */\n @Prop({ reflect: true }) source: Source = \"store\";\n\n /**\n * Provides data specific to the chosen source.\n * \n * Required when using 'categories', 'products', or 'json' as the source:\n * - 'categories': An array of category IDs.\n * - 'products': An array of product IDs.\n * - 'json': A custom JSON object containing review data.\n * \n * @type {number | string | object | Array<string | number>}\n */\n @Prop({ reflect: true }) sourceValue: number | string | object | Array<string | number>;\n\n /**\n * Defines the maximum number of reviews to retrieve from the API.\n * \n * @type {number}\n * @default 5\n */\n @Prop({ reflect: true }) limit = 5\n\n\n @State() reviews: Array<Review> = [];\n @State() isRTL: boolean\n @State() showReviews: boolean = false;\n @State() testimonialText: string = salla.lang.get('blocks.home.testimonials');\n @State() displayAllLinkText: string = salla.lang.get('blocks.home.display_all');\n\n private displayAllURL = null\n\n fetchReviews() {\n if (this.source === 'json') {\n return Promise.resolve(JSON.parse(this.sourceValue as string));\n }\n const isJsonEncoded = ['products', 'categories'].includes(this.source);\n const params = {\n per_page: this.limit,\n type: this.source,\n items: isJsonEncoded ? JSON.parse(this.sourceValue as string) : this.sourceValue,\n };\n return salla.api.request('reviews', { params }, 'get');\n }\n\n\n componentWillLoad() {\n return (new Promise(resolve => salla.onReady(resolve)))\n .then(() => this.fetchReviews())\n .then((resp) => resp.data || [])\n .then(reviews => {\n if (reviews.length) {\n this.reviews = reviews;\n this.showReviews = true;\n Helper.generateReviewSchema(this.reviews);\n }\n });\n }\n\n render() {\n return (\n <div class=\"s-reviews-container\">\n <div class=\"s-reviews-header-wrapper\">\n <h1 class=\"s-reviews-header\">\n {this.testimonialText}\n </h1>\n {!!this.displayAllLink ? (\n <a href={this.displayAllURL} class=\"s-reviews-display-all\">\n {this.displayAllLinkText}\n <span class=\"s-reviews-display-all-icon\" innerHTML={IconArrowLeft} />\n </a>\n ) : null}\n </div>\n <salla-slider\n centered\n slides-per-view={1}\n type=\"testimonials\"\n class=\"s-reviews-testimonials-slider\"\n controls-outer\n auto-play\n id={`testimonials-${this.source}-slider`}\n >\n <div slot=\"items\">\n {this.reviews.map((item: Review, index) => (\n <div key={index} class=\"s-reviews-swiper-slide\">\n <div class=\"s-reviews-testimonial\">\n <div class=\"s-reviews-testimonial__inner\">\n <div class=\"s-reviews-testimonial__avatar\">\n <img\n src={'images/s-empty.png'}\n data-src={item.avatar}\n alt={item.name ? item.name : 'testimonial-' + index}\n class=\"lazy\"\n />\n </div>\n <div class=\"s-reviews-testimonial__text\">\n <p>{item.text}</p>\n <div class=\"s-reviews-testimonial__name_wrapper\">\n <div class=\"s-reviews-testimonial__info\">\n {item.name && <h2>{`${item.name}`}</h2>}\n </div>\n <div class=\"s-reviews-testimonial__rating\">\n {/* TODO stars is missing */}\n <salla-rating-stars size=\"small\" value={item.rating}></salla-rating-stars>\n </div>\n </div>\n </div>\n\n <span class=\"s-reviews-testimonial__icon\" innerHTML={IconQuoteOpen} />\n </div>\n </div>\n </div>\n ))}\n </div>\n </salla-slider>\n </div>\n );\n }\n\n}\n\n"]}