@salla.sa/twilight-components 2.12.50 → 2.12.52

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 (78) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/salla-add-product-button_41.cjs.entry.js +22 -9
  3. package/dist/cjs/salla-add-product-button_41.cjs.entry.js.map +1 -1
  4. package/dist/cjs/salla-products-list.cjs.entry.js +3 -2
  5. package/dist/cjs/salla-products-list.cjs.entry.js.map +1 -1
  6. package/dist/cjs/salla-products-slider.cjs.entry.js +10 -2
  7. package/dist/cjs/salla-products-slider.cjs.entry.js.map +1 -1
  8. package/dist/cjs/twilight.cjs.js +1 -1
  9. package/dist/collection/components/salla-login-modal/salla-login-modal.js +31 -7
  10. package/dist/collection/components/salla-login-modal/salla-login-modal.js.map +1 -1
  11. package/dist/collection/components/salla-product-card/salla-product-card.js +2 -2
  12. package/dist/collection/components/salla-product-card/salla-product-card.js.map +1 -1
  13. package/dist/collection/components/salla-products-list/salla-products-list.js +24 -2
  14. package/dist/collection/components/salla-products-list/salla-products-list.js.map +1 -1
  15. package/dist/collection/components/salla-products-slider/salla-products-slider.js +31 -2
  16. package/dist/collection/components/salla-products-slider/salla-products-slider.js.map +1 -1
  17. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +9 -2
  18. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js.map +1 -1
  19. package/dist/components/salla-login-modal.js +12 -5
  20. package/dist/components/salla-login-modal.js.map +1 -1
  21. package/dist/components/salla-product-card2.js +2 -2
  22. package/dist/components/salla-product-card2.js.map +1 -1
  23. package/dist/components/salla-products-list.js +4 -2
  24. package/dist/components/salla-products-list.js.map +1 -1
  25. package/dist/components/salla-products-slider.js +11 -2
  26. package/dist/components/salla-products-slider.js.map +1 -1
  27. package/dist/components/salla-quick-buy2.js +9 -2
  28. package/dist/components/salla-quick-buy2.js.map +1 -1
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/esm/salla-add-product-button_41.entry.js +22 -9
  31. package/dist/esm/salla-add-product-button_41.entry.js.map +1 -1
  32. package/dist/esm/salla-products-list.entry.js +3 -2
  33. package/dist/esm/salla-products-list.entry.js.map +1 -1
  34. package/dist/esm/salla-products-slider.entry.js +10 -2
  35. package/dist/esm/salla-products-slider.entry.js.map +1 -1
  36. package/dist/esm/twilight.js +1 -1
  37. package/dist/esm-es5/loader.js +1 -1
  38. package/dist/esm-es5/loader.js.map +1 -1
  39. package/dist/esm-es5/salla-add-product-button_41.entry.js +1 -1
  40. package/dist/esm-es5/salla-add-product-button_41.entry.js.map +1 -1
  41. package/dist/esm-es5/salla-products-list.entry.js +2 -2
  42. package/dist/esm-es5/salla-products-list.entry.js.map +1 -1
  43. package/dist/esm-es5/salla-products-slider.entry.js +1 -1
  44. package/dist/esm-es5/salla-products-slider.entry.js.map +1 -1
  45. package/dist/esm-es5/twilight.js +1 -1
  46. package/dist/esm-es5/twilight.js.map +1 -1
  47. package/dist/twilight/{p-f4183e87.entry.js → p-0057d0ef.entry.js} +2 -2
  48. package/dist/twilight/p-0057d0ef.entry.js.map +1 -0
  49. package/dist/twilight/p-5224c881.system.entry.js +5 -0
  50. package/dist/twilight/p-5224c881.system.entry.js.map +1 -0
  51. package/dist/twilight/p-7afe6b27.system.js +1 -1
  52. package/dist/twilight/p-7afe6b27.system.js.map +1 -1
  53. package/dist/twilight/p-7fda7b65.entry.js +5 -0
  54. package/dist/twilight/p-7fda7b65.entry.js.map +1 -0
  55. package/dist/twilight/p-dfe73459.entry.js +5 -0
  56. package/dist/twilight/p-dfe73459.entry.js.map +1 -0
  57. package/dist/twilight/p-e5148740.system.entry.js +5 -0
  58. package/dist/twilight/p-e5148740.system.entry.js.map +1 -0
  59. package/dist/twilight/{p-1328d1c6.system.entry.js → p-ed5569f5.system.entry.js} +2 -2
  60. package/dist/twilight/p-ed5569f5.system.entry.js.map +1 -0
  61. package/dist/twilight/twilight.esm.js +1 -1
  62. package/dist/twilight/twilight.esm.js.map +1 -1
  63. package/dist/types/components/salla-login-modal/salla-login-modal.d.ts +5 -1
  64. package/dist/types/components/salla-products-list/salla-products-list.d.ts +10 -0
  65. package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +10 -0
  66. package/dist/types/components/salla-quick-buy/salla-quick-buy.d.ts +1 -0
  67. package/dist/types/components.d.ts +29 -1
  68. package/package.json +2 -2
  69. package/dist/twilight/p-0bffd5bc.entry.js +0 -5
  70. package/dist/twilight/p-0bffd5bc.entry.js.map +0 -1
  71. package/dist/twilight/p-1328d1c6.system.entry.js.map +0 -1
  72. package/dist/twilight/p-6731663d.system.entry.js +0 -5
  73. package/dist/twilight/p-6731663d.system.entry.js.map +0 -1
  74. package/dist/twilight/p-780bccea.entry.js +0 -5
  75. package/dist/twilight/p-780bccea.entry.js.map +0 -1
  76. package/dist/twilight/p-787eb079.system.entry.js +0 -5
  77. package/dist/twilight/p-787eb079.system.entry.js.map +0 -1
  78. package/dist/twilight/p-f4183e87.entry.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"salla-login-modal.js","sourceRoot":"","sources":["../../../src/components/salla-login-modal/salla-login-modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,qDAAqD;AACrD,oDAAoD;AACpD,OAAO,UAAU,MAAM,6BAA6B,CAAC;AACrD,iFAAiF;AACjF,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAc,eAAe,EAAC,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;GAUG;AAOH,MAAM,OAAO,eAAe;EAC1B;IAmFQ,uBAAkB,GAAW,EAAE,CAAC;IAuGhC,WAAM,GAAG,CAAC,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, h, Listen, Method, Prop, State} from '@stencil/core';\nimport UserIcon from \"../../assets/svg/user.svg\";\n//import PhoneIcon from \"../../assets/svg/phone.svg\";\n//import EmailIcon from \"../../assets/svg/mail.svg\";\nimport CameraIcon from '../../assets/svg/camera.svg';\n//import KeyboardArrowRightIcon from \"../../assets/svg/keyboard_arrow_right.svg\";\nimport ArrowRightIcon from \"../../assets/svg/arrow-right.svg\";\nimport Helper from '../../Helpers/Helper';\nimport {CustomField, CustomFieldType} from './intefaces';\n\n/**\n * @slot footer - The footer of modal\n * @slot before-login-type - placeholder position\n * @slot after-login-type - placeholder position\n * @slot before-login-mobile - placeholder position\n * @slot after-login-mobile - placeholder position\n * @slot before-login-email - placeholder position\n * @slot after-login-email - placeholder position\n * @slot before-registration - placeholder position\n * @slot after-registration - placeholder position\n */\n@Component({\n tag: 'salla-login-modal',\n styleUrl: 'salla-login-modal.scss'\n})\n\n\nexport class SallaLoginModal {\n constructor() {\n\n this.title = this.host.title || salla.lang.get('blocks.header.login');\n this.host.removeAttribute('title');\n\n this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');\n this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.first_name')});\n this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.last_name')});\n\n salla.lang.onLoaded(() => {\n this.translationLoaded = true;\n this.title = salla.lang.get('blocks.header.login');\n this.dragAndDrop = salla.lang.get('common.uploader.drag_and_drop');\n this.browseFromFiles = salla.lang.get('common.uploader.browse');\n this.updateTranslations();\n });\n\n salla.event.on('login::open', (event) => {\n if(!this.isEmailAllowed && !this.isMobileAllowed){\n salla.logger.warn('Please enable atleast one login type to use this component.');\n return;\n }\n this.open(event)\n });\n salla.onReady( () => {\n this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', this.isEmailAllowed);\n this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', this.isMobileAllowed);\n this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', this.isEmailRequired);\n });\n }\n\n @Element() host: HTMLElement;\n /**\n * Does the merchant allow to login using email\n */\n @Prop({mutable: true}) isEmailAllowed: boolean ;\n /**\n * Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`\n */\n @Prop({mutable: true}) isMobileAllowed: boolean = true;\n /**\n * Does the merchant require registration with email & mobile\n */\n @Prop({mutable: true}) isEmailRequired: boolean = false;\n\n /**\n * Once the api verify success, it will be login the customer in web pages\n */\n @Prop({reflect: true}) supportWebAuth: boolean = true;\n\n private modal: HTMLSallaModalElement;\n //private homeTab: HTMLDivElement;\n private mobileTab: HTMLDivElement;\n private emailTab: HTMLDivElement;\n private verifyTab: HTMLSallaVerifyElement;\n private registrationTab: HTMLDivElement;\n private regTelInput: HTMLSallaTelInputElement;\n private regEmail: HTMLInputElement;\n private customFieldsWrapper: HTMLDivElement;\n private loginTelInput: HTMLSallaTelInputElement;\n private loginEmail: HTMLInputElement;\n private firstName: HTMLInputElement;\n private lastName: HTMLInputElement;\n private smsBtn: HTMLSallaButtonElement;\n private emailBtn: HTMLSallaButtonElement;\n private regBtn: HTMLSallaButtonElement;\n\n @State() currentTabName = 'home'\n @State() regType: 'phone' | 'email' = 'phone';\n\n\n @State() translationLoaded: boolean = false;\n @State() currentPhone: string = '';\n @State() currentEmail: string = '';\n @State() title: string;\n @State() emailErrorMsg: string;\n @State() firstNameErrorMsg: string;\n @State() lastNameErrorMsg: string;\n\n @State() dragAndDrop: string = salla.lang.get('common.uploader.drag_and_drop');\n @State() browseFromFiles: string = salla.lang.get('common.uploader.browse');\n @State() customFields: CustomField[] = [];\n\n private customFieldsValues: Object = {};\n @State() uploadedImage: string = undefined;\n\n @Listen('verified', {target: 'window'})\n /**\n * @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event\n */\n onVerified(event) {\n salla.log('verified', event);\n //there is a case when force login is activated & is new user, it will return case inside error key., so cover it.\n let verifyCase = event.detail?.data.case || event.detail?.error.case;\n if (!verifyCase) {\n salla.log('verified but without case!');\n return;\n }\n\n if (verifyCase === \"new_customer\") {\n this.customFields = event.detail?.data?.custom_fields || [];\n return this.showTab(this.registrationTab);\n }\n\n if (!salla.auth.canRedirect()) {\n salla.log('Will not auto redirect or reload, due to `salla.auth.canRedirect()`');\n this.modal.close();\n return;\n }\n\n if (event.detail.data.redirect_url) {\n return window.location.href = event.detail.data.redirect_url;\n }\n\n /**\n * we don't want to reload the page if this is not web auth\n * because we'll need the token in the page itself and its there\n * todo :: store the user data in storage for non-web auth and set the config.user from it\n */\n if (this.supportWebAuth) {\n window.location.reload();\n } else {\n this.modal.close();\n }\n }\n\n updateTranslations() {\n this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');\n this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.first_name')});\n this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.last_name')});\n this.modal?.setTitle(this.title);\n }\n\n /**\n * Open login component\n */\n @Method()\n // @ts-ignore\n async open(event = null) {\n // todo :: support change the settings from event details\n // if(event && event.hasOwnProperty('isEmailAllowed')){\n // this.isEmailAllowed = event?.isEmailAllowed;\n // }\n //\n // if(event && event.hasOwnProperty('isMobileAllowed')){\n // this.isMobileAllowed = event?.isMobileAllowed;\n // }\n\n /**\n * This is a workaround until we remove all the user objet from twig files\n * When the user is already login, let's reload the page\n */\n if(!salla.config.isGuest()){\n location.reload()\n return;\n }\n\n if (this.isMobileAllowed) {\n this.showTab(this.mobileTab);\n } else if (this.isEmailAllowed) {\n this.showTab(this.emailTab);\n }\n return this.modal.open();\n }\n\n private showTab(tab, evt?) {\n evt?.preventDefault();\n this.currentTabName = tab.getAttribute('data-name');\n\n // todo:: use better way for resize the modal\n // setTimeout(() => this.modal.querySelector('.s-login-modal-wrapper')?.setAttribute('style', 'height:' + tab?.scrollHeight + 'px'));\n\n if ([this.mobileTab, this.emailTab].includes(tab)) {\n this.regType = tab === this.mobileTab ? 'phone' : 'email';\n }\n\n const input = tab.querySelector('input[type=\"tel\"], input[type=\"email\"]');\n input && setTimeout(() => {\n input.focus();\n }, 100);\n\n this.modal?.setTitle(this.currentTabName === 'registration' ? salla.lang.get('common.titles.registration') : this.title);\n\n return this;\n }\n\n private typing = (e, submitMethod = null) => {\n const error = e.target.nextElementSibling;\n e.target.classList.remove('s-has-error');\n error?.classList.contains('s-login-modal-error-message') && (error.innerText = '');\n //it was sending two requests for send two verification requests\n submitMethod && e.key == 'Enter' && submitMethod();\n }\n\n private loginBySMS = async (event = null) => {\n event?.preventDefault();\n const {phone, countryCode, countryKey} = await this.loginTelInput.getValues();\n const isPhoneValid = await this.loginTelInput.isValid();\n if (!isPhoneValid) {\n return;\n }\n this.currentPhone = `${countryKey} ${phone}`;\n this.login(this.smsBtn, {type: 'mobile', phone: phone, country_code: countryCode});\n\n return false;\n }\n\n private loginByEmail = (event = null) => {\n event?.preventDefault();\n if (!Helper.isValidEmail(this.loginEmail.value)) {\n this.validateField(this.loginEmail, this.emailErrorMsg);\n return;\n }\n this.currentEmail = this.loginEmail.value;\n this.login(this.emailBtn, {type: 'email', email: this.loginEmail.value});\n }\n\n private login(btn: HTMLSallaButtonElement, data) {\n btn.load()\n .then(() => btn.disable())\n .then(() => salla.auth.api.login(data))\n .then(() => this.showTab(this.verifyTab))\n .then(() => this.verifyTab.open(data))\n .finally(() => btn.stop() && btn.enable());\n }\n\n private newUser = async () => {\n const {\n phone: regPhone,\n countryCode\n } = this.regType == \"email\" ? await this.regTelInput.getValues() : await this.loginTelInput.getValues(),\n emailValue = this.regEmail.value || this.loginEmail?.value\n await this.newUserValidation();\n await this.regBtn.load();\n await this.regBtn.disable();\n\n let data: any = {\n first_name: this.firstName.value,\n last_name: this.lastName.value,\n phone: regPhone || this.loginTelInput.phone,\n country_code: countryCode,\n verified_by: this.regType,\n custom_fields: this.customFieldsValues,\n };\n emailValue && (data = {...data, email: emailValue});\n this.verifyTab.getCode()\n .then(code => salla.auth.api.register({...data, code}))\n .then(() => salla.auth.canRedirect && window.location.reload())\n .catch((error) => {\n salla.logger.error(error);\n this.regBtn.stop() && this.regBtn.enable()\n })\n }\n\n private async newUserValidation() {\n const isLogByPhone = this.regType == \"phone\",\n isLogByEmail = this.regType == \"email\",\n emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value),\n isEmailValid = Helper.isValidEmail(emailValue),\n isFirstNameValid = this.firstName.value.length > 0,\n isLastNameValid = this.lastName.value.length > 0,\n isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(),\n emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);\n\n // Custom Fields Validation\n var isCustomFieldValid = true;\n //we should make sure that there is text nodes between children\n this.customFieldsWrapper.childNodes\n .forEach((field: HTMLSallaFileUploadElement | HTMLInputElement) => {\n this.customFieldsValues[field.id] = field['value'];\n if (!field.required || this.customFieldsValues[field.id].length) {\n return;\n }\n isCustomFieldValid = false;\n const errorMsg: string = salla.lang.get('common.errors.field_required', {attribute: field.title});\n this.validateField(field, errorMsg)\n });\n\n if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid && isCustomFieldValid) return;\n !isEmailValid && this.validateField(this.regEmail, this.emailErrorMsg);\n !isFirstNameValid && this.validateField(this.firstName, this.firstNameErrorMsg);\n !isLastNameValid && this.validateField(this.lastName, this.lastNameErrorMsg);\n throw 'Please insert required fields';\n }\n\n private getFilepondPlaceholder() {\n return `<div class=\"s-login-modal-filepond-placeholder\"><span class=\"s-login-modal-filepond-placeholder-icon\">${CameraIcon}</span><p class=\"s-login-modal-filepond-placeholder-text\">${this.dragAndDrop}</p> <span class=\"filepond--label-action\">${this.browseFromFiles}</span></div>`\n }\n\n // eslint-disable-next-line @stencil/own-methods-must-be-private\n validateField(field: HTMLInputElement | HTMLSallaFileUploadElement, errorMsg: string) {\n field.classList.add('s-has-error');\n field.nextElementSibling['innerText'] = '* ' + errorMsg;\n }\n\n generateTabClasses(tabName) {\n return {\n 's-login-modal-tab': tabName !== 'registration' && tabName !== 'otp',\n \"s-hidden\": this.currentTabName !== tabName,\n \"s-show\": this.currentTabName === tabName,\n 's-login-modal-unactive': tabName !== 'registration' && tabName !== 'otp' && this.currentTabName !== tabName,\n 's-login-modal-active': tabName !== 'registration' && tabName !== 'otp' && this.currentTabName === tabName\n }\n }\n\n generateRegClasses(regType) {\n return {\n \"mb-1.5\": true,\n \"s-hidden\": this.regType === regType\n }\n }\n\n render() {\n // @ts-ignore\n // @ts-ignore\n return (\n <salla-modal class=\"s-login-modal\" modal-title={this.title} ref={modal => this.modal = modal} width=\"xs\">\n <span slot='icon' class=\"s-login-modal-header-icon\" innerHTML={UserIcon}/>\n <div class=\"s-login-modal-wrapper\">\n\n {/* Tab 2 (Login By Mobile)*/}\n {this.isMobileAllowed ?\n <div class={this.generateTabClasses('login-phone')} data-name=\"login-phone\"\n ref={tab => this.mobileTab = tab}>\n <slot name=\"before-login-mobile\"/>\n <form onSubmit={(event) => this.loginBySMS(event)} method=\"POST\">\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.mobile')}</label>\n <salla-tel-input tabindex=\"0\" ref={el => this.loginTelInput = el}\n onKeyDown={e => this.typing(e)}></salla-tel-input>\n {/* @ts-ignore */}\n <salla-button class=\"s-login-modal-enter-button\" type=\"submit\" loader-position='center' width=\"wide\" ref={b => this.smsBtn = b}>\n {salla.lang.get('blocks.header.enter')}\n </salla-button>\n </form>\n {this.isEmailAllowed ?\n <a href=\"#\" onClick={() => this.showTab(this.emailTab)}\n class=\"s-login-modal-link\">{salla.lang.get('blocks.header.login_by_email')}</a> : ''}\n <slot name=\"after-login-mobile\"/>\n </div> : ''}\n\n\n {/* Tab 3 (Login By Email)*/}\n {this.isEmailAllowed ?\n <div class={this.generateTabClasses('login-email')} data-name=\"login-email\"\n ref={tab => this.emailTab = tab}>\n <slot name=\"before-login-email\"/>\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.email')}</label>\n <form onSubmit={() => this.loginByEmail(event)} method=\"POST\">\n <input type=\"email\" ref={el => this.loginEmail = el} onKeyDown={e => this.typing(e)}\n placeholder=\"your@email.com\"\n enterkeyhint=\"next\"\n class=\"s-login-modal-input s-ltr\"/>\n <span class=\"s-login-modal-error-message\"/>\n <salla-button loader-position='center' width=\"wide\" onClick={() => this.loginByEmail()}\n ref={b => this.emailBtn = b}>{salla.lang.get('blocks.header.enter')}</salla-button>\n </form>\n {this.isMobileAllowed ?\n <a href=\"#\" onClick={() => this.showTab(this.mobileTab)}\n class=\"s-login-modal-link\">{salla.lang.get('blocks.header.login_by_sms')}</a>\n : ''\n }\n <slot name=\"after-login-email\"/>\n </div> : ''}\n\n\n {/* Tab 4 (Verify OTP)*/}\n <salla-verify display=\"inline\" support-web-auth={this.supportWebAuth ? 'true' : 'false'}\n class={this.generateTabClasses('otp')} data-name=\"otp\" ref={tab => this.verifyTab = tab}\n autoReload={false}>\n <a onClick={() => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab)}\n class=\"s-verify-back\"\n innerHTML={ArrowRightIcon}\n slot=\"after-footer\"\n href=\"#\"/>\n {this.isMobileAllowed && this.regType == 'phone' ? <div dir=\"ltr\" class=\"s-login-modal-currentPhone\" slot=\"mobile\">{this.currentPhone}</div>: ''}\n {this.isEmailAllowed && this.regType == 'email' ? <div dir=\"ltr\" class=\"s-login-modal-currentEmail\" slot=\"email\">{this.currentEmail}</div>: ''}\n </salla-verify>\n\n {/* Tab 5 (Register New User)*/}\n <div data-name=\"registration\" class={this.generateTabClasses('registration')}\n ref={tab => this.registrationTab = tab}>\n <slot name=\"before-registration\"/>\n <div>\n <label class=\"s-login-modal-label\">{salla.lang.get('blocks.header.your_name')}</label>\n <input type=\"text\" class=\"s-login-modal-input\" ref={el => this.firstName = el}\n onKeyDown={e => this.typing(e, this.newUser)}\n placeholder={salla.lang.get('pages.profile.first_name')}/>\n <span class=\"s-login-modal-error-message\"/>\n </div>\n\n <div>\n <label class=\"s-login-modal-label\">{salla.lang.get('pages.profile.last_name')}</label>\n <input type=\"text\" class=\"s-login-modal-input\" ref={el => this.lastName = el}\n onKeyDown={e => this.typing(e, this.newUser)}\n placeholder={salla.lang.get('pages.profile.last_name')}/>\n <span class=\"s-login-modal-error-message\"/>\n </div>\n\n <div class={this.generateRegClasses('phone')}>\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.mobile')}</label>\n <salla-tel-input ref={el => this.regTelInput = el}\n onKeyDown={e => this.typing(e, this.newUser)}></salla-tel-input>\n </div>\n\n <div class={this.generateRegClasses('email')}>\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.email')}</label>\n <input type=\"email\" ref={el => this.regEmail = el} onKeyDown={e => this.typing(e, this.newUser)}\n placeholder=\"your@email.com\"\n class=\"s-login-modal-input s-ltr\"/>\n <span class=\"s-login-modal-error-message\"/>\n </div>\n <div class=\"s-login-modal-custom-fields\" ref={el => this.customFieldsWrapper = el}>{\n this.customFields.map((field: CustomField) => [\n <label class=\"s-login-modal-label\">{field.label}</label>,\n field.type === CustomFieldType.PHOTO\n ? <salla-file-upload\n name=\"image\"\n instant-upload={true}\n id={`${field.id}`}\n title={field.label}\n required={field.required}\n url={salla.url.get('upload-image')}\n // onUploaded={}\n labelIdle={this.getFilepondPlaceholder()}/>\n : <input\n onInput={el => field.type == CustomFieldType.NUMBER ? salla.helpers.inputDigitsOnly(el.target) : {}}\n onKeyDown={e => this.typing(e, this.newUser)}\n class=\"s-login-modal-input s-ltr\"\n maxlength={field.length || 1000}//todo:: support it by adding the maxlength or not, not setting static limit\n placeholder={field.description}\n required={field.required}\n title={field.label}\n id={`${field.id}`}\n type=\"text\"/>,\n <span class=\"s-login-modal-error-message\"/>\n ])\n }</div>\n\n <salla-button loader-position='center' width=\"wide\" onClick={() => this.newUser()}\n ref={b => this.regBtn = b}>{salla.lang.get('blocks.header.register')}</salla-button>\n <slot name=\"after-registration\"/>\n </div>\n </div>\n </salla-modal>\n );\n }\n}\n\n"]}
1
+ {"version":3,"file":"salla-login-modal.js","sourceRoot":"","sources":["../../../src/components/salla-login-modal/salla-login-modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AACjF,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,qDAAqD;AACrD,oDAAoD;AACpD,OAAO,UAAU,MAAM,6BAA6B,CAAC;AACrD,iFAAiF;AACjF,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAc,eAAe,EAAC,MAAM,aAAa,CAAC;AAEzD;;;;;;;;;;GAUG;AAOH,MAAM,OAAO,eAAe;EAC1B;IAyFQ,uBAAkB,GAAW,EAAE,CAAC;IA0GhC,WAAM,GAAG,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,EAAE;MAC1C,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC;MAC1C,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;MACzC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC,QAAQ,CAAC,6BAA6B,CAAC,KAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;MACnF,gEAAgE;MAChE,YAAY,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;IACrD,CAAC,CAAA;IAEO,eAAU,GAAG,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE;MAC1C,KAAK,aAAL,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AC7C,CAAC,CAAC,aACA,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EACnG,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,EAC5C,KAAK,EAAC,2BAA2B,EACjC,SAAS,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI,EAC/B,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,EAAE,EAAE,GAAG,KAAK,CAAC,EAAE,EAAE,EACjB,IAAI,EAAC,MAAM,GAAE;YACjB,YAAM,KAAK,EAAC,6BAA6B,GAAE;WAC5C,CAAC,CACG;UAEP,uCAA8B,QAAQ,EAAC,KAAK,EAAC,MAAM,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EACnE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAgB;UAClG,YAAM,IAAI,EAAC,oBAAoB,GAAE,CAC7B,CACF,CACM,CACf,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Element, h, Listen, Method, Prop, State} from '@stencil/core';\nimport UserIcon from \"../../assets/svg/user.svg\";\n//import PhoneIcon from \"../../assets/svg/phone.svg\";\n//import EmailIcon from \"../../assets/svg/mail.svg\";\nimport CameraIcon from '../../assets/svg/camera.svg';\n//import KeyboardArrowRightIcon from \"../../assets/svg/keyboard_arrow_right.svg\";\nimport ArrowRightIcon from \"../../assets/svg/arrow-right.svg\";\nimport Helper from '../../Helpers/Helper';\nimport {CustomField, CustomFieldType} from './intefaces';\n\n/**\n * @slot footer - The footer of modal\n * @slot before-login-type - placeholder position\n * @slot after-login-type - placeholder position\n * @slot before-login-mobile - placeholder position\n * @slot after-login-mobile - placeholder position\n * @slot before-login-email - placeholder position\n * @slot after-login-email - placeholder position\n * @slot before-registration - placeholder position\n * @slot after-registration - placeholder position\n */\n@Component({\n tag: 'salla-login-modal',\n styleUrl: 'salla-login-modal.scss'\n})\n\n\nexport class SallaLoginModal {\n constructor() {\n\n this.title = this.host.title || salla.lang.get('blocks.header.login');\n this.host.removeAttribute('title');\n\n this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');\n this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.first_name')});\n this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.last_name')});\n\n salla.lang.onLoaded(() => {\n this.translationLoaded = true;\n this.title = salla.lang.get('blocks.header.login');\n this.dragAndDrop = salla.lang.get('common.uploader.drag_and_drop');\n this.browseFromFiles = salla.lang.get('common.uploader.browse');\n this.updateTranslations();\n });\n\n salla.event.on('login::open', (data) => {\n if(!this.isEmailAllowed && !this.isMobileAllowed){\n salla.logger.warn('Please enable atleast one login type to use this component.');\n return;\n }\n this.withoutReload = data?.withoutReload ?? this.withoutReload;\n this.open(data)\n });\n salla.onReady( () => {\n this.isEmailAllowed = salla.config.get('store.settings.auth.email_allowed', this.isEmailAllowed);\n this.isMobileAllowed = salla.config.get('store.settings.auth.mobile_allowed', this.isMobileAllowed);\n this.isEmailRequired = salla.config.get('store.settings.auth.is_email_required', this.isEmailRequired);\n });\n }\n\n @Element() host: HTMLElement;\n /**\n * Does the merchant allow to login using email\n */\n @Prop({mutable: true}) isEmailAllowed: boolean ;\n /**\n * Does the merchant/current location for visitor allow to login using mobile, By default outside KSA is `false`\n */\n @Prop({mutable: true}) isMobileAllowed: boolean = true;\n /**\n * Does the merchant require registration with email & mobile\n */\n @Prop({mutable: true}) isEmailRequired: boolean = false;\n\n /**\n * Once the api verify success, it will be login the customer in web pages\n */\n @Prop({reflect: true}) supportWebAuth: boolean = true;\n\n /**\n * Reload after a successful login\n */\n @Prop() withoutReload: boolean = false;\n\n private modal: HTMLSallaModalElement;\n //private homeTab: HTMLDivElement;\n private mobileTab: HTMLDivElement;\n private emailTab: HTMLDivElement;\n private verifyTab: HTMLSallaVerifyElement;\n private registrationTab: HTMLDivElement;\n private regTelInput: HTMLSallaTelInputElement;\n private regEmail: HTMLInputElement;\n private customFieldsWrapper: HTMLDivElement;\n private loginTelInput: HTMLSallaTelInputElement;\n private loginEmail: HTMLInputElement;\n private firstName: HTMLInputElement;\n private lastName: HTMLInputElement;\n private smsBtn: HTMLSallaButtonElement;\n private emailBtn: HTMLSallaButtonElement;\n private regBtn: HTMLSallaButtonElement;\n\n @State() currentTabName = 'home'\n @State() regType: 'phone' | 'email' = 'phone';\n\n\n @State() translationLoaded: boolean = false;\n @State() currentPhone: string = '';\n @State() currentEmail: string = '';\n @State() title: string;\n @State() emailErrorMsg: string;\n @State() firstNameErrorMsg: string;\n @State() lastNameErrorMsg: string;\n\n @State() dragAndDrop: string = salla.lang.get('common.uploader.drag_and_drop');\n @State() browseFromFiles: string = salla.lang.get('common.uploader.browse');\n @State() customFields: CustomField[] = [];\n\n private customFieldsValues: Object = {};\n @State() uploadedImage: string = undefined;\n\n @Listen('verified', {target: 'window'})\n /**\n * @param {CustomEvent|{details:{case:'new_customer'|'authenticated', redirect_url:string|null}}} event\n */\n onVerified(event) {\n salla.log('verified', event);\n //there is a case when force login is activated & is new user, it will return case inside error key., so cover it.\n let verifyCase = event.detail?.data.case || event.detail?.error.case;\n if (!verifyCase) {\n salla.log('verified but without case!');\n return;\n }\n\n if (verifyCase === \"new_customer\") {\n this.customFields = event.detail?.data?.custom_fields || [];\n return this.showTab(this.registrationTab);\n }\n\n if (!salla.auth.canRedirect()) {\n salla.log('Will not auto redirect or reload, due to `salla.auth.canRedirect()`');\n this.modal.close();\n return;\n }\n\n if (event.detail.data.redirect_url) {\n return window.location.href = event.detail.data.redirect_url;\n }\n\n /**\n * we don't want to reload the page if this is not web auth\n * because we'll need the token in the page itself and its there\n * todo :: store the user data in storage for non-web auth and set the config.user from it\n */\n if (this.supportWebAuth && !this.withoutReload) {\n window.location.reload();\n } else {\n this.modal.close();\n }\n }\n\n updateTranslations() {\n this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');\n this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.first_name')});\n this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', {attribute: salla.lang.get('pages.profile.last_name')});\n this.modal?.setTitle(this.title);\n }\n\n /**\n * Open login component\n */\n @Method()\n // @ts-ignore\n async open(event = null) {\n // todo :: support change the settings from event details\n // if(event && event.hasOwnProperty('isEmailAllowed')){\n // this.isEmailAllowed = event?.isEmailAllowed;\n // }\n //\n // if(event && event.hasOwnProperty('isMobileAllowed')){\n // this.isMobileAllowed = event?.isMobileAllowed;\n // }\n\n /**\n * This is a workaround until we remove all the user objet from twig files\n * When the user is already login, let's reload the page\n */\n if (!salla.config.isGuest()) {\n if (!this.withoutReload) {\n return location.reload();\n }\n // Fire an event if withoutReload is true\n return;\n }\n\n if (this.isMobileAllowed) {\n this.showTab(this.mobileTab);\n } else if (this.isEmailAllowed) {\n this.showTab(this.emailTab);\n }\n return this.modal.open();\n }\n\n private showTab(tab, evt?) {\n evt?.preventDefault();\n this.currentTabName = tab.getAttribute('data-name');\n\n // todo:: use better way for resize the modal\n // setTimeout(() => this.modal.querySelector('.s-login-modal-wrapper')?.setAttribute('style', 'height:' + tab?.scrollHeight + 'px'));\n\n if ([this.mobileTab, this.emailTab].includes(tab)) {\n this.regType = tab === this.mobileTab ? 'phone' : 'email';\n }\n\n const input = tab.querySelector('input[type=\"tel\"], input[type=\"email\"]');\n input && setTimeout(() => {\n input.focus();\n }, 100);\n\n this.modal?.setTitle(this.currentTabName === 'registration' ? salla.lang.get('common.titles.registration') : this.title);\n\n return this;\n }\n\n private typing = (e, submitMethod = null) => {\n const error = e.target.nextElementSibling;\n e.target.classList.remove('s-has-error');\n error?.classList.contains('s-login-modal-error-message') && (error.innerText = '');\n //it was sending two requests for send two verification requests\n submitMethod && e.key == 'Enter' && submitMethod();\n }\n\n private loginBySMS = async (event = null) => {\n event?.preventDefault();\n const {phone, countryCode, countryKey} = await this.loginTelInput.getValues();\n const isPhoneValid = await this.loginTelInput.isValid();\n if (!isPhoneValid) {\n return;\n }\n this.currentPhone = `${countryKey} ${phone}`;\n this.login(this.smsBtn, {type: 'mobile', phone: phone, country_code: countryCode});\n\n return false;\n }\n\n private loginByEmail = (event = null) => {\n event?.preventDefault();\n if (!Helper.isValidEmail(this.loginEmail.value)) {\n this.validateField(this.loginEmail, this.emailErrorMsg);\n return;\n }\n this.currentEmail = this.loginEmail.value;\n this.login(this.emailBtn, {type: 'email', email: this.loginEmail.value});\n }\n\n private login(btn: HTMLSallaButtonElement, data) {\n btn.load()\n .then(() => btn.disable())\n .then(() => salla.auth.api.login(data))\n .then(() => this.showTab(this.verifyTab))\n .then(() => this.verifyTab.open(data))\n .finally(() => btn.stop() && btn.enable());\n }\n\n private newUser = async () => {\n const {\n phone: regPhone,\n countryCode\n } = this.regType == \"email\" ? await this.regTelInput.getValues() : await this.loginTelInput.getValues(),\n emailValue = this.regEmail.value || this.loginEmail?.value\n await this.newUserValidation();\n await this.regBtn.load();\n await this.regBtn.disable();\n\n let data: any = {\n first_name: this.firstName.value,\n last_name: this.lastName.value,\n phone: regPhone || this.loginTelInput.phone,\n country_code: countryCode,\n verified_by: this.regType,\n custom_fields: this.customFieldsValues,\n };\n emailValue && (data = {...data, email: emailValue});\n this.verifyTab.getCode()\n .then(code => salla.auth.api.register({...data, code}))\n .then(() => salla.auth.canRedirect && !this.withoutReload && window.location.reload())\n .catch((error) => {\n salla.logger.error(error);\n this.regBtn.stop() && this.regBtn.enable()\n })\n }\n\n private async newUserValidation() {\n const isLogByPhone = this.regType == \"phone\",\n isLogByEmail = this.regType == \"email\",\n emailValue = this.regEmail.value || (isLogByEmail && this.loginEmail.value),\n isEmailValid = Helper.isValidEmail(emailValue),\n isFirstNameValid = this.firstName.value.length > 0,\n isLastNameValid = this.lastName.value.length > 0,\n isPhoneValid = await this.regTelInput.isValid() || isLogByPhone && await this.loginTelInput.isValid(),\n emailValidation = (emailValue && isEmailValid) || (!emailValue && !this.isEmailRequired);\n\n // Custom Fields Validation\n var isCustomFieldValid = true;\n //we should make sure that there is text nodes between children\n this.customFieldsWrapper.childNodes\n .forEach((field: HTMLSallaFileUploadElement | HTMLInputElement) => {\n this.customFieldsValues[field.id] = field['value'];\n if (!field.required || this.customFieldsValues[field.id].length) {\n return;\n }\n isCustomFieldValid = false;\n const errorMsg: string = salla.lang.get('common.errors.field_required', {attribute: field.title});\n this.validateField(field, errorMsg)\n });\n\n if (emailValidation && isPhoneValid && isFirstNameValid && isLastNameValid && isCustomFieldValid) return;\n !isEmailValid && this.validateField(this.regEmail, this.emailErrorMsg);\n !isFirstNameValid && this.validateField(this.firstName, this.firstNameErrorMsg);\n !isLastNameValid && this.validateField(this.lastName, this.lastNameErrorMsg);\n throw 'Please insert required fields';\n }\n\n private getFilepondPlaceholder() {\n return `<div class=\"s-login-modal-filepond-placeholder\"><span class=\"s-login-modal-filepond-placeholder-icon\">${CameraIcon}</span><p class=\"s-login-modal-filepond-placeholder-text\">${this.dragAndDrop}</p> <span class=\"filepond--label-action\">${this.browseFromFiles}</span></div>`\n }\n\n // eslint-disable-next-line @stencil/own-methods-must-be-private\n validateField(field: HTMLInputElement | HTMLSallaFileUploadElement, errorMsg: string) {\n field.classList.add('s-has-error');\n field.nextElementSibling['innerText'] = '* ' + errorMsg;\n }\n\n generateTabClasses(tabName) {\n return {\n 's-login-modal-tab': tabName !== 'registration' && tabName !== 'otp',\n \"s-hidden\": this.currentTabName !== tabName,\n \"s-show\": this.currentTabName === tabName,\n 's-login-modal-unactive': tabName !== 'registration' && tabName !== 'otp' && this.currentTabName !== tabName,\n 's-login-modal-active': tabName !== 'registration' && tabName !== 'otp' && this.currentTabName === tabName\n }\n }\n\n generateRegClasses(regType) {\n return {\n \"mb-1.5\": true,\n \"s-hidden\": this.regType === regType\n }\n }\n\n render() {\n // @ts-ignore\n // @ts-ignore\n return (\n <salla-modal class=\"s-login-modal\" modal-title={this.title} ref={modal => this.modal = modal} width=\"xs\">\n <span slot='icon' class=\"s-login-modal-header-icon\" innerHTML={UserIcon}/>\n <div class=\"s-login-modal-wrapper\">\n\n {/* Tab 2 (Login By Mobile)*/}\n {this.isMobileAllowed ?\n <div class={this.generateTabClasses('login-phone')} data-name=\"login-phone\"\n ref={tab => this.mobileTab = tab}>\n <slot name=\"before-login-mobile\"/>\n <form onSubmit={(event) => this.loginBySMS(event)} method=\"POST\">\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.mobile')}</label>\n <salla-tel-input tabindex=\"0\" ref={el => this.loginTelInput = el}\n onKeyDown={e => this.typing(e)}></salla-tel-input>\n {/* @ts-ignore */}\n <salla-button class=\"s-login-modal-enter-button\" type=\"submit\" loader-position='center' width=\"wide\" ref={b => this.smsBtn = b}>\n {salla.lang.get('blocks.header.enter')}\n </salla-button>\n </form>\n {this.isEmailAllowed ?\n <a href=\"#\" onClick={() => this.showTab(this.emailTab)}\n class=\"s-login-modal-link\">{salla.lang.get('blocks.header.login_by_email')}</a> : ''}\n <slot name=\"after-login-mobile\"/>\n </div> : ''}\n\n\n {/* Tab 3 (Login By Email)*/}\n {this.isEmailAllowed ?\n <div class={this.generateTabClasses('login-email')} data-name=\"login-email\"\n ref={tab => this.emailTab = tab}>\n <slot name=\"before-login-email\"/>\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.email')}</label>\n <form onSubmit={() => this.loginByEmail(event)} method=\"POST\">\n <input type=\"email\" ref={el => this.loginEmail = el} onKeyDown={e => this.typing(e)}\n placeholder=\"your@email.com\"\n enterkeyhint=\"next\"\n class=\"s-login-modal-input s-ltr\"/>\n <span class=\"s-login-modal-error-message\"/>\n <salla-button loader-position='center' width=\"wide\" onClick={() => this.loginByEmail()}\n ref={b => this.emailBtn = b}>{salla.lang.get('blocks.header.enter')}</salla-button>\n </form>\n {this.isMobileAllowed ?\n <a href=\"#\" onClick={() => this.showTab(this.mobileTab)}\n class=\"s-login-modal-link\">{salla.lang.get('blocks.header.login_by_sms')}</a>\n : ''\n }\n <slot name=\"after-login-email\"/>\n </div> : ''}\n\n\n {/* Tab 4 (Verify OTP)*/}\n <salla-verify display=\"inline\" support-web-auth={this.supportWebAuth ? 'true' : 'false'}\n class={this.generateTabClasses('otp')} data-name=\"otp\" ref={tab => this.verifyTab = tab}\n autoReload={false}>\n <a onClick={() => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab)}\n class=\"s-verify-back\"\n innerHTML={ArrowRightIcon}\n slot=\"after-footer\"\n href=\"#\"/>\n {this.isMobileAllowed && this.regType == 'phone' ? <div dir=\"ltr\" class=\"s-login-modal-currentPhone\" slot=\"mobile\">{this.currentPhone}</div>: ''}\n {this.isEmailAllowed && this.regType == 'email' ? <div dir=\"ltr\" class=\"s-login-modal-currentEmail\" slot=\"email\">{this.currentEmail}</div>: ''}\n </salla-verify>\n\n {/* Tab 5 (Register New User)*/}\n <div data-name=\"registration\" class={this.generateTabClasses('registration')}\n ref={tab => this.registrationTab = tab}>\n <slot name=\"before-registration\"/>\n <div>\n <label class=\"s-login-modal-label\">{salla.lang.get('blocks.header.your_name')}</label>\n <input type=\"text\" class=\"s-login-modal-input\" ref={el => this.firstName = el}\n onKeyDown={e => this.typing(e, this.newUser)}\n placeholder={salla.lang.get('pages.profile.first_name')}/>\n <span class=\"s-login-modal-error-message\"/>\n </div>\n\n <div>\n <label class=\"s-login-modal-label\">{salla.lang.get('pages.profile.last_name')}</label>\n <input type=\"text\" class=\"s-login-modal-input\" ref={el => this.lastName = el}\n onKeyDown={e => this.typing(e, this.newUser)}\n placeholder={salla.lang.get('pages.profile.last_name')}/>\n <span class=\"s-login-modal-error-message\"/>\n </div>\n\n <div class={this.generateRegClasses('phone')}>\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.mobile')}</label>\n <salla-tel-input ref={el => this.regTelInput = el}\n onKeyDown={e => this.typing(e, this.newUser)}></salla-tel-input>\n </div>\n\n <div class={this.generateRegClasses('email')}>\n <label class=\"s-login-modal-label\">{salla.lang.get('common.elements.email')}</label>\n <input type=\"email\" ref={el => this.regEmail = el} onKeyDown={e => this.typing(e, this.newUser)}\n placeholder=\"your@email.com\"\n class=\"s-login-modal-input s-ltr\"/>\n <span class=\"s-login-modal-error-message\"/>\n </div>\n <div class=\"s-login-modal-custom-fields\" ref={el => this.customFieldsWrapper = el}>{\n this.customFields.map((field: CustomField) => [\n <label class=\"s-login-modal-label\">{field.label}</label>,\n field.type === CustomFieldType.PHOTO\n ? <salla-file-upload\n name=\"image\"\n instant-upload={true}\n id={`${field.id}`}\n title={field.label}\n required={field.required}\n url={salla.url.get('upload-image')}\n // onUploaded={}\n labelIdle={this.getFilepondPlaceholder()}/>\n : <input\n onInput={el => field.type == CustomFieldType.NUMBER ? salla.helpers.inputDigitsOnly(el.target) : {}}\n onKeyDown={e => this.typing(e, this.newUser)}\n class=\"s-login-modal-input s-ltr\"\n maxlength={field.length || 1000}//todo:: support it by adding the maxlength or not, not setting static limit\n placeholder={field.description}\n required={field.required}\n title={field.label}\n id={`${field.id}`}\n type=\"text\"/>,\n <span class=\"s-login-modal-error-message\"/>\n ])\n }</div>\n\n <salla-button loader-position='center' width=\"wide\" onClick={() => this.newUser()}\n ref={b => this.regBtn = b}>{salla.lang.get('blocks.header.register')}</salla-button>\n <slot name=\"after-registration\"/>\n </div>\n </div>\n </salla-modal>\n );\n }\n}\n\n"]}
@@ -82,8 +82,8 @@ export class SallaProductCard {
82
82
  return '';
83
83
  }
84
84
  getPriceFormat(price) {
85
- if (!price) {
86
- return;
85
+ if (!price || price == 0) {
86
+ return salla.config.get('store.settings.product.show_price_as_dash') ? '-' : '';
87
87
  }
88
88
  return salla.money(price);
89
89
  }
@@ -1 +1 @@
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,CA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BACrB,2BAA2B,EACtC,KAAK,EAAC,sCAAsC,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) {\n return;\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 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 href={this.productData?.url}>\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 href={this.productData?.url} 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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AAG,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 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 href={this.productData?.url}>\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 href={this.productData?.url} 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"]}
@@ -13,6 +13,7 @@ export class SallaProductsList {
13
13
  this.sortBy = undefined;
14
14
  this.filtersResults = undefined;
15
15
  this.horizontalCards = undefined;
16
+ this.productCardComponent = 'custom-salla-product-card';
16
17
  this.page = 1;
17
18
  this.nextPage = undefined;
18
19
  this.hasInfiniteScroll = undefined;
@@ -134,7 +135,7 @@ export class SallaProductsList {
134
135
  this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
135
136
  }
136
137
  getItemHTML(product) {
137
- const customComponentTag = this.hasCustomComponent ? 'custom-salla-product-card' : 'salla-product-card';
138
+ const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';
138
139
  const productCard = document.createElement(customComponentTag);
139
140
  productCard.product = product;
140
141
  this.applyLandingPageStyles(productCard);
@@ -199,7 +200,7 @@ export class SallaProductsList {
199
200
  }
200
201
  componentWillLoad() {
201
202
  return Helper.onSallaReadyPromise(() => {
202
- this.hasCustomComponent = !!customElements.get('custom-salla-product-card');
203
+ this.hasCustomComponent = !!customElements.get(this.productCardComponent);
203
204
  this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());
204
205
  this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource()) && !this.limit;
205
206
  try {
@@ -435,6 +436,27 @@ export class SallaProductsList {
435
436
  },
436
437
  "attribute": "horizontal-cards",
437
438
  "reflect": true
439
+ },
440
+ "productCardComponent": {
441
+ "type": "string",
442
+ "mutable": false,
443
+ "complexType": {
444
+ "original": "string",
445
+ "resolved": "string",
446
+ "references": {}
447
+ },
448
+ "required": false,
449
+ "optional": false,
450
+ "docs": {
451
+ "tags": [{
452
+ "name": "example",
453
+ "text": "<salla-products-list product-card-component=\"my-custom-card-style1\" ...\n<salla-products-list product-card-component=\"my-custom-card-style2\" ..."
454
+ }],
455
+ "text": "Custom Card Component for the Salla Products List.\n\nThis component allows you to customize the appearance of individual product cards within a Salla Products List."
456
+ },
457
+ "attribute": "product-card-component",
458
+ "reflect": false,
459
+ "defaultValue": "'custom-salla-product-card'"
438
460
  }
439
461
  };
440
462
  }
@@ -1 +1 @@
1
- {"version":3,"file":"salla-products-list.js","sourceRoot":"","sources":["../../../src/components/salla-products-list/salla-products-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACtG,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,WAAW,MAAM,mCAAmC,CAAC;AAC5D,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAK1C,MAAM,OAAO,iBAAiB;;;;;;;;gBA8EJ,CAAC;;;;;;;;;;EA7EzB,iBAAiB;IACf,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,wBAAwB,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;EAC/E,CAAC;EAED;;;KAGG;EAEH,KAAK,CAAC,UAAU,CAAC,OAAO;IACtB,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;MAC/E,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;IAC7B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;EACvB,CAAC;EAED;;KAEG;EAEH,KAAK,CAAC,MAAM;IACV,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClD,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACx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,CAAC,CAAC;KACnF;IACD,OAAO,CAAA,MAAA,QAAQ,CAAC,IAAI,0CAAE,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAI,EAAE,CAAC;EACxE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Method, Event, EventEmitter } from '@stencil/core';\nimport anime from 'animejs';\nimport ShoppingBag from '../../assets/svg/shopping-bag.svg';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-products-list',\n styleUrl: 'salla-products-list.scss'\n})\nexport class SallaProductsList {\n connectedCallback() {\n salla.event.on('salla-filters::changed', filters => this.setFilters(filters))\n }\n\n /**\n * Set parsed filters data from URI\n * @param filters\n */\n @Method()\n async setFilters(filters) {\n if (!!filters && JSON.stringify(this.parsedFilters) === JSON.stringify(filters)) {\n return;\n }\n window.scrollTo({ top: 0, behavior: 'smooth' });\n this.parsedFilters = filters;\n return this.reload();\n }\n\n /**\n * Reload the list of products (entire content of the component).\n */\n @Method()\n async reload() {\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.buildNextPageUrl();\n // TODO: this is problematic in testing, for the time being it's been resolved like this\n this.wrapper.innerHTML = '';\n this.init();\n }\n\n\n private status: HTMLDivElement;\n private btnLoader: HTMLAnchorElement;\n @Element() host: HTMLElement;\n private wrapper: any;\n private infiniteScroll: any;\n /**\n * The source of the products list\n * @type {string}\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - keyword when `source` = 'search'\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop({ mutable: true }) sourceValue: any;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({ mutable: true }) limit: number;\n\n /**\n * Sorting the list of products\n */\n @Prop({ mutable: true }) sortBy?: string | 'ourSuggest' | 'bestSell' | 'topRated' | 'priceFromTopToLow' | 'priceFromLowToTop';\n\n /**\n * should listen to filters events `salla-filters::changed` and re-render\n */\n @Prop({ reflect: true, mutable: true }) filtersResults: boolean;\n\n /**\n * Horizontal cards\n */\n @Prop({ reflect: true }) horizontalCards: boolean\n\n // State\n @State() page: number = 1;\n @State() nextPage: string;\n @State() hasInfiniteScroll: boolean;\n @State() hasCustomComponent: boolean;\n @State() sourceValueIsValid: boolean;\n @State() placeholderText: string;\n @State() isReady: boolean;\n @State() showPlaceholder: boolean;\n @State() parsedFilters: any;\n\n /**\n * Custom event fired when the the products fetched.\n */\n @Event() productsFetched: EventEmitter;\n\n private isFilterable() {\n return salla.config.get('store.settings.product.filters') && this.filtersResults;\n }\n\n private isSourceWithoutValue() {\n return ['offers', 'latest', 'sales'].includes(this.getSource());\n }\n\n private animateItems() {\n anime({\n targets: 'salla-products-list salla-product-card',\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n })\n }\n\n private createStatusDom() {\n this.status = document.createElement('div');\n this.status.className = 's-infinite-scroll-wrapper';\n this.status.innerHTML = `<div class=\"s-infinite-scroll-status\">\n <p class=\"s-infinite-scroll-last infinite-scroll-last s-hidden\" >${salla.lang.get('common.elements.end_of_content')}</p>\n <p class=\"s-infinite-scroll-error infinite-scroll-error s-hidden\">${salla.lang.get('common.elements.failed_to_load_more')}</p>\n </div>\n <a href=\"#\" class=\"s-infinite-scroll-btn s-button-btn\">\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" style=\"display: none\"></span>\n </a>`;\n this.btnLoader = this.status.querySelector('.s-button-loader');\n salla.lang.onLoaded(() => {\n this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');\n this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');\n this.placeholderText = salla.lang.get('pages.categories.no_products');\n });\n }\n\n private initBaseNextPageUrl(source: string) {\n\n this.nextPage = salla.url.api(`products?source=${source}`);\n\n if (this.limit) {\n this.nextPage += `&per_page=${this.limit > 32 ? 32 : this.limit}`;\n }\n if (this.sortBy) {\n this.nextPage += `&sort=${this.sortBy}`;\n }\n // if (!this.isFilterable()) {\n // return this.nextPage;\n // }\n this.nextPage += '&filterable=1';\n for (const [key, value] of Object.entries(this.parsedFilters || {})) {\n if ([\"string\", \"number\"].includes(typeof value)) {\n // @ts-ignore\n this.nextPage += `&filters[${encodeURIComponent(key)}]=${encodeURIComponent(value)}`;\n } else if (Array.isArray(value)) {\n value.forEach(item => this.nextPage += `&filters[${encodeURIComponent(key)}][]=${encodeURIComponent(item)}`);\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n this.nextPage += `&filters[${encodeURIComponent(key)}][${encodeURIComponent(k)}]=${encodeURIComponent(v)}`;\n }\n }\n }\n }\n\n private buildNextPageUrl() {\n let source = this.getSource();\n if (source === 'json') {\n return;\n }\n this.initBaseNextPageUrl(source);\n if (this.isSourceWithoutValue()) {\n return;\n }\n\n if (['search', 'related', 'landing-page'].includes(source)) {\n this.nextPage += `&source_value=${this.getSourceValue()}`;\n return;\n }\n\n try {\n this.nextPage += `&source_value[]=${this.getSourceValue().join('&source_value[]=')}`;\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n\n private loading(isLoading = true) {\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n\n private getItemHTML(product) {\n const customComponentTag = this.hasCustomComponent ? 'custom-salla-product-card' : 'salla-product-card';\n const productCard = document.createElement(customComponentTag) as HTMLSallaProductCardElement;\n productCard.product = product;\n\n this.applyLandingPageStyles(productCard);\n this.applyHorizontalCardStyles(productCard);\n\n return productCard;\n }\n\n private applyLandingPageStyles(productCard) {\n if (this.getSource() === 'landing-page' && !this.hasCustomComponent) {\n productCard.toggleAttribute('hide-add-btn', true);\n productCard.classList.add('s-product-card-fit-height');\n }\n }\n\n private applyHorizontalCardStyles(productCard) {\n if (!this.horizontalCards) {\n return;\n }\n productCard.setAttribute('horizontal', true);\n if (!this.hasCustomComponent) {\n productCard.setAttribute('shadow-on-hover', true);\n }\n\n }\n\n private getSource() {\n return Helper.getProductsSource(this.source);\n }\n\n private getSourceValue() {\n return Helper.getProductsSourceValue(this.source, this.sourceValue);\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n this.host.insertAdjacentElement('beforeend', this.status);\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: 100,\n }, /* infinite via api*/true);\n this.infiniteScroll?.on('request', () => this.loading())\n this.infiniteScroll?.on('load', response => {\n if (!response.data?.length && this.infiniteScroll.pageIndex == 2) {\n this.showPlaceholder = true;\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.loading(false);\n return;\n } else {\n this.showPlaceholder = false;\n\n }\n this.infiniteScroll.appendItems(this.handleResponse(response))\n if (this.infiniteScroll.pageIndex == 2) {\n this.animateItems();\n }\n })\n this.infiniteScroll?.on('error', () => {\n this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden')\n this.loading(false);\n });\n salla.onReady(() => salla.infiniteScroll.loadNextPage(this.infiniteScroll))\n }\n\n componentWillLoad() {\n return Helper.onSallaReadyPromise( () => {\n this.hasCustomComponent = !!customElements.get('custom-salla-product-card');\n this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());\n this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource()) && !this.limit;\n try {\n let searchParams = new URLSearchParams(window.location.search);\n this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');\n let filters = searchParams.get('filters')\n this.parsedFilters = filters ? JSON.parse(decodeURIComponent(filters)) : {};\n } catch (e) {\n salla.logger.warn('failed to get filters from url', e.message);\n }\n this.buildNextPageUrl();\n this.createStatusDom();\n\n this.isReady = true;\n\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);\n return;\n }\n if (this.hasInfiniteScroll) {\n return;\n }\n\n // Handle json source\n if (this.getSource() === 'json') {\n if (!this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n setTimeout(() => {\n this.getSourceValue().map(product => this.wrapper.append(this.getItemHTML(product)));\n });\n return;\n }\n\n // Handle selected source\n if (this.getSource() === 'selected' && !this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n\n return Helper.fetchProducts(this.getSource(), this.getSourceValue(), this.limit).then(res => {\n if (!res.data.length) {\n this.showPlaceholder = true;\n this.loading(false);\n return;\n }\n setTimeout(() => {\n this.handleResponse(res).forEach(card => this.wrapper.append(card));\n }, 100);\n });\n });\n }\n\n\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n render() {\n if (!this.canRender()) {\n return '';\n }\n\n if (this.showPlaceholder) {\n return <div class=\"s-products-list-placeholder\">\n <span innerHTML={ShoppingBag} />\n <p>{this.placeholderText}</p>\n </div>;\n }\n return (\n <Host class=\"s-products-list\">\n <div class={{\n \"s-products-list-wrapper\": true,\n 's-products-list-horizontal-cards': this.horizontalCards && !this.filtersResults,\n 's-products-list-vertical-cards': !this.horizontalCards && !this.filtersResults,\n 's-products-list-filters-results': this.filtersResults,\n }}\n ref={wrapper => this.wrapper = wrapper} />\n </Host>\n );\n }\n\n componentDidLoad() {\n this.hasInfiniteScroll && this.init();\n }\n\n private init() {\n this.initiateInfiniteScroll();\n this.loading();\n }\n\n private handleResponse(response): Array<HTMLElement> {\n let source=this.getSource();\n let title = '';\n //help the developer to know the current page title\n if (response.cursor?.current === 1) {\n title = Helper.getPageTitleForSource(source);\n try {\n if (this.getSource() === 'search') {\n title = salla.lang.get('common.elements.search_about', {'word': this.getSourceValue()});\n } else if (!title) {\n let catId = this.parsedFilters.category_id || this.getSourceValue()[0];\n // get the first filter that its key is category_id, then get the value when filter.value.*.key==catId\n title = response.filters.find(filter => filter.key == 'category_id') ?. values ?. find(cat => cat.key == catId) ?. value || '';\n }\n title += (title ? ' - ' : '') + salla.lang.choice('blocks.header.products_count', response.data ?. length);\n if (response.data.length === 15) {\n title = title.replace(response.data.length, salla.lang.get('common.elements.more_than') + ' ' + response.data.length)\n }\n response.title = title;\n } catch (e) {}\n }\n\n salla.event.emit('salla-products-list::products.fetched', response);\n this.productsFetched.emit(response);\n //💡 when source is related, cursor will not be existed\n if (response.filters && this.isFilterable()) {\n this.filtersResults = true;\n salla.event.emit('filters::fetched', { filters: response.filters });\n } else if (this.isFilterable()) {\n salla.event.emit('filters::hidden');\n }\n this.nextPage = response.cursor ? response.cursor.next : this.nextPage;\n this.loading(false);\n if (this.hasInfiniteScroll && !this.nextPage) {\n this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });\n this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');\n }\n return response.data?.map(product => this.getItemHTML(product)) || [];\n }\n}\n"]}
1
+ {"version":3,"file":"salla-products-list.js","sourceRoot":"","sources":["../../../src/components/salla-products-list/salla-products-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AACtG,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,O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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Method, Event, EventEmitter } from '@stencil/core';\nimport anime from 'animejs';\nimport ShoppingBag from '../../assets/svg/shopping-bag.svg';\nimport Helper from '../../Helpers/Helper';\n@Component({\n tag: 'salla-products-list',\n styleUrl: 'salla-products-list.scss'\n})\nexport class SallaProductsList {\n connectedCallback() {\n salla.event.on('salla-filters::changed', filters => this.setFilters(filters))\n }\n\n /**\n * Set parsed filters data from URI\n * @param filters\n */\n @Method()\n async setFilters(filters) {\n if (!!filters && JSON.stringify(this.parsedFilters) === JSON.stringify(filters)) {\n return;\n }\n window.scrollTo({ top: 0, behavior: 'smooth' });\n this.parsedFilters = filters;\n return this.reload();\n }\n\n /**\n * Reload the list of products (entire content of the component).\n */\n @Method()\n async reload() {\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.buildNextPageUrl();\n // TODO: this is problematic in testing, for the time being it's been resolved like this\n this.wrapper.innerHTML = '';\n this.init();\n }\n\n\n private status: HTMLDivElement;\n private btnLoader: HTMLAnchorElement;\n @Element() host: HTMLElement;\n private wrapper: any;\n private infiniteScroll: any;\n /**\n * The source of the products list\n * @type {string}\n * */\n @Prop({\n reflect: true,\n mutable: true\n }) source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page' | 'sales';\n\n /**\n * The source value, cloud be different values as following:\n * - array of ids when `source` in ['categories', 'brands', 'tags', 'selected']\n * - keyword when `source` = 'search'\n * - products payload when `source` = 'json'\n * - product_id when `source` = 'related'\n *\n * @type {string}\n * */\n @Prop({ mutable: true }) sourceValue: any;\n\n /**\n * Limit for number of products in the list.\n */\n @Prop({ mutable: true }) limit: number;\n\n /**\n * Sorting the list of products\n */\n @Prop({ mutable: true }) sortBy?: string | 'ourSuggest' | 'bestSell' | 'topRated' | 'priceFromTopToLow' | 'priceFromLowToTop';\n\n /**\n * should listen to filters events `salla-filters::changed` and re-render\n */\n @Prop({ reflect: true, mutable: true }) filtersResults: boolean;\n\n /**\n * Horizontal cards\n */\n @Prop({ reflect: true }) horizontalCards: boolean\n\n /**\n * Custom Card Component for the Salla Products List.\n *\n * This component allows you to customize the appearance of individual product cards within a Salla Products List.\n *\n * @example\n * <salla-products-list product-card-component=\"my-custom-card-style1\" ...\n * <salla-products-list product-card-component=\"my-custom-card-style2\" ...\n */\n @Prop() productCardComponent: string = 'custom-salla-product-card';\n\n // State\n @State() page: number = 1;\n @State() nextPage: string;\n @State() hasInfiniteScroll: boolean;\n @State() hasCustomComponent: boolean;\n @State() sourceValueIsValid: boolean;\n @State() placeholderText: string;\n @State() isReady: boolean;\n @State() showPlaceholder: boolean;\n @State() parsedFilters: any;\n\n /**\n * Custom event fired when the the products fetched.\n */\n @Event() productsFetched: EventEmitter;\n\n private isFilterable() {\n return salla.config.get('store.settings.product.filters') && this.filtersResults;\n }\n\n private isSourceWithoutValue() {\n return ['offers', 'latest', 'sales'].includes(this.getSource());\n }\n\n private animateItems() {\n anime({\n targets: 'salla-products-list salla-product-card',\n opacity: [0, 1],\n duration: 1200,\n translateY: [20, 0],\n delay: function (_el, i) {\n return i * 100;\n },\n })\n }\n\n private createStatusDom() {\n this.status = document.createElement('div');\n this.status.className = 's-infinite-scroll-wrapper';\n this.status.innerHTML = `<div class=\"s-infinite-scroll-status\">\n <p class=\"s-infinite-scroll-last infinite-scroll-last s-hidden\" >${salla.lang.get('common.elements.end_of_content')}</p>\n <p class=\"s-infinite-scroll-error infinite-scroll-error s-hidden\">${salla.lang.get('common.elements.failed_to_load_more')}</p>\n </div>\n <a href=\"#\" class=\"s-infinite-scroll-btn s-button-btn\">\n <span class=\"s-button-loader s-button-loader-center s-infinite-scroll-btn-loader\" style=\"display: none\"></span>\n </a>`;\n this.btnLoader = this.status.querySelector('.s-button-loader');\n salla.lang.onLoaded(() => {\n this.status.querySelector('.s-infinite-scroll-last').innerHTML = salla.lang.get('common.elements.end_of_content');\n this.status.querySelector('.s-infinite-scroll-error').innerHTML = salla.lang.get('common.elements.failed_to_load_more');\n this.placeholderText = salla.lang.get('pages.categories.no_products');\n });\n }\n\n private initBaseNextPageUrl(source: string) {\n\n this.nextPage = salla.url.api(`products?source=${source}`);\n\n if (this.limit) {\n this.nextPage += `&per_page=${this.limit > 32 ? 32 : this.limit}`;\n }\n if (this.sortBy) {\n this.nextPage += `&sort=${this.sortBy}`;\n }\n // if (!this.isFilterable()) {\n // return this.nextPage;\n // }\n this.nextPage += '&filterable=1';\n for (const [key, value] of Object.entries(this.parsedFilters || {})) {\n if ([\"string\", \"number\"].includes(typeof value)) {\n // @ts-ignore\n this.nextPage += `&filters[${encodeURIComponent(key)}]=${encodeURIComponent(value)}`;\n } else if (Array.isArray(value)) {\n value.forEach(item => this.nextPage += `&filters[${encodeURIComponent(key)}][]=${encodeURIComponent(item)}`);\n } else if (typeof value === 'object') {\n for (const [k, v] of Object.entries(value)) {\n this.nextPage += `&filters[${encodeURIComponent(key)}][${encodeURIComponent(k)}]=${encodeURIComponent(v)}`;\n }\n }\n }\n }\n\n private buildNextPageUrl() {\n let source = this.getSource();\n if (source === 'json') {\n return;\n }\n this.initBaseNextPageUrl(source);\n if (this.isSourceWithoutValue()) {\n return;\n }\n\n if (['search', 'related', 'landing-page'].includes(source)) {\n this.nextPage += `&source_value=${this.getSourceValue()}`;\n return;\n }\n\n try {\n this.nextPage += `&source_value[]=${this.getSourceValue().join('&source_value[]=')}`;\n } catch (e) {\n salla.logger.warn(`source-value prop should be array of ids ex source-value=\"[1,2,3]\" for the source [${source}]`);\n this.sourceValueIsValid = false;\n }\n }\n\n\n private loading(isLoading = true) {\n this.btnLoader.style.display = isLoading ? 'inherit' : 'none';\n }\n\n private getItemHTML(product) {\n const customComponentTag = this.hasCustomComponent ? this.productCardComponent : 'salla-product-card';\n const productCard = document.createElement(customComponentTag) as HTMLSallaProductCardElement;\n productCard.product = product;\n\n this.applyLandingPageStyles(productCard);\n this.applyHorizontalCardStyles(productCard);\n\n return productCard;\n }\n\n private applyLandingPageStyles(productCard) {\n if (this.getSource() === 'landing-page' && !this.hasCustomComponent) {\n productCard.toggleAttribute('hide-add-btn', true);\n productCard.classList.add('s-product-card-fit-height');\n }\n }\n\n private applyHorizontalCardStyles(productCard) {\n if (!this.horizontalCards) {\n return;\n }\n productCard.setAttribute('horizontal', true);\n if (!this.hasCustomComponent) {\n productCard.setAttribute('shadow-on-hover', true);\n }\n\n }\n\n private getSource() {\n return Helper.getProductsSource(this.source);\n }\n\n private getSourceValue() {\n return Helper.getProductsSourceValue(this.source, this.sourceValue);\n }\n\n private initiateInfiniteScroll() {\n if (!this.hasInfiniteScroll) {\n return;\n }\n\n this.host.insertAdjacentElement('beforeend', this.status);\n this.infiniteScroll = salla.infiniteScroll.initiate(this.wrapper, this.wrapper, {\n path: () => this.nextPage,\n history: false,\n nextPage: this.nextPage,\n scrollThreshold: 100,\n }, /* infinite via api*/true);\n this.infiniteScroll?.on('request', () => this.loading())\n this.infiniteScroll?.on('load', response => {\n if (!response.data?.length && this.infiniteScroll.pageIndex == 2) {\n this.showPlaceholder = true;\n salla.infiniteScroll.destroy(this.infiniteScroll);\n this.loading(false);\n return;\n } else {\n this.showPlaceholder = false;\n\n }\n this.infiniteScroll.appendItems(this.handleResponse(response))\n if (this.infiniteScroll.pageIndex == 2) {\n this.animateItems();\n }\n })\n this.infiniteScroll?.on('error', () => {\n this.status.querySelector('.s-infinite-scroll-error').classList.remove('s-hidden')\n this.loading(false);\n });\n salla.onReady(() => salla.infiniteScroll.loadNextPage(this.infiniteScroll))\n }\n\n componentWillLoad() {\n return Helper.onSallaReadyPromise( () => {\n this.hasCustomComponent = !!customElements.get(this.productCardComponent);\n this.sourceValueIsValid = !!(this.getSourceValue() || this.isSourceWithoutValue());\n this.hasInfiniteScroll = !['json', 'selected', 'related', 'landing-page'].includes(this.getSource()) && !this.limit;\n try {\n let searchParams = new URLSearchParams(window.location.search);\n this.sortBy = this.sortBy || searchParams.get('sort') || searchParams.get('by');\n let filters = searchParams.get('filters')\n this.parsedFilters = filters ? JSON.parse(decodeURIComponent(filters)) : {};\n } catch (e) {\n salla.logger.warn('failed to get filters from url', e.message);\n }\n this.buildNextPageUrl();\n this.createStatusDom();\n\n this.isReady = true;\n\n if (!this.sourceValueIsValid) {\n salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);\n return;\n }\n if (this.hasInfiniteScroll) {\n return;\n }\n\n // Handle json source\n if (this.getSource() === 'json') {\n if (!this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n setTimeout(() => {\n this.getSourceValue().map(product => this.wrapper.append(this.getItemHTML(product)));\n });\n return;\n }\n\n // Handle selected source\n if (this.getSource() === 'selected' && !this.getSourceValue().length) {\n this.showPlaceholder = true;\n return;\n }\n\n return Helper.fetchProducts(this.getSource(), this.getSourceValue(), this.limit).then(res => {\n if (!res.data.length) {\n this.showPlaceholder = true;\n this.loading(false);\n return;\n }\n setTimeout(() => {\n this.handleResponse(res).forEach(card => this.wrapper.append(card));\n }, 100);\n });\n });\n }\n\n\n\n private canRender() {\n return this.sourceValueIsValid && this.isReady;\n }\n\n render() {\n if (!this.canRender()) {\n return '';\n }\n\n if (this.showPlaceholder) {\n return <div class=\"s-products-list-placeholder\">\n <span innerHTML={ShoppingBag} />\n <p>{this.placeholderText}</p>\n </div>;\n }\n return (\n <Host class=\"s-products-list\">\n <div class={{\n \"s-products-list-wrapper\": true,\n 's-products-list-horizontal-cards': this.horizontalCards && !this.filtersResults,\n 's-products-list-vertical-cards': !this.horizontalCards && !this.filtersResults,\n 's-products-list-filters-results': this.filtersResults,\n }}\n ref={wrapper => this.wrapper = wrapper} />\n </Host>\n );\n }\n\n componentDidLoad() {\n this.hasInfiniteScroll && this.init();\n }\n\n private init() {\n this.initiateInfiniteScroll();\n this.loading();\n }\n\n private handleResponse(response): Array<HTMLElement> {\n let source=this.getSource();\n let title = '';\n //help the developer to know the current page title\n if (response.cursor?.current === 1) {\n title = Helper.getPageTitleForSource(source);\n try {\n if (this.getSource() === 'search') {\n title = salla.lang.get('common.elements.search_about', {'word': this.getSourceValue()});\n } else if (!title) {\n let catId = this.parsedFilters.category_id || this.getSourceValue()[0];\n // get the first filter that its key is category_id, then get the value when filter.value.*.key==catId\n title = response.filters.find(filter => filter.key == 'category_id') ?. values ?. find(cat => cat.key == catId) ?. value || '';\n }\n title += (title ? ' - ' : '') + salla.lang.choice('blocks.header.products_count', response.data ?. length);\n if (response.data.length === 15) {\n title = title.replace(response.data.length, salla.lang.get('common.elements.more_than') + ' ' + response.data.length)\n }\n response.title = title;\n } catch (e) {}\n }\n\n salla.event.emit('salla-products-list::products.fetched', response);\n this.productsFetched.emit(response);\n //💡 when source is related, cursor will not be existed\n if (response.filters && this.isFilterable()) {\n this.filtersResults = true;\n salla.event.emit('filters::fetched', { filters: response.filters });\n } else if (this.isFilterable()) {\n salla.event.emit('filters::hidden');\n }\n this.nextPage = response.cursor ? response.cursor.next : this.nextPage;\n this.loading(false);\n if (this.hasInfiniteScroll && !this.nextPage) {\n this.infiniteScroll.option({ scrollThreshold: false, loadOnScroll: false });\n this.status.querySelector('.s-infinite-scroll-last').classList.remove('s-hidden');\n }\n return response.data?.map(product => this.getItemHTML(product)) || [];\n }\n}\n"]}
@@ -15,6 +15,7 @@ export class SallaProductsSlider {
15
15
  this.sourceValue = undefined;
16
16
  this.limit = undefined;
17
17
  this.sliderConfig = undefined;
18
+ this.productCardComponent = 'custom-salla-product-card';
18
19
  this.productsData = undefined;
19
20
  this.isReady = undefined;
20
21
  this.sourceValueIsValid = undefined;
@@ -26,9 +27,16 @@ export class SallaProductsSlider {
26
27
  return ['offers', 'latest', 'sales'].includes(this.getSource());
27
28
  }
28
29
  getItemHTML(product) {
29
- if (this.hasCustomComponent) {
30
+ if (this.hasCustomComponent && this.productCardComponent.toLowerCase() == 'custom-salla-product-card') {
30
31
  return h("div", { class: "s-products-slider-card" }, h("custom-salla-product-card", { product: product, source: this.getSource(), "source-value": this.getSourceValue() }));
31
32
  }
33
+ if (this.hasCustomComponent) {
34
+ const customElem = document.createElement(this.productCardComponent);
35
+ customElem.setAttribute('product', JSON.stringify(product));
36
+ customElem.setAttribute('source', this.getSource());
37
+ customElem.setAttribute('source-value', this.getSourceValue());
38
+ return h("div", { class: "s-products-slider-card", innerHTML: customElem.outerHTML });
39
+ }
32
40
  return h("div", { class: "s-products-slider-card" }, h("salla-product-card", { "show-quantity": this.getSource() == 'landing-page', "hide-add-btn": this.getSource() == 'landing-page', "shadow-on-hover": true, product: product }));
33
41
  }
34
42
  canRender() {
@@ -41,7 +49,7 @@ export class SallaProductsSlider {
41
49
  salla.logger.warn(`source-value prop is required for source [${this.getSource()}]`);
42
50
  return;
43
51
  }
44
- this.hasCustomComponent = !!customElements.get('custom-salla-product-card');
52
+ this.hasCustomComponent = !!customElements.get(this.productCardComponent);
45
53
  if (this.source === 'json') {
46
54
  this.productsData = this.getSourceValue();
47
55
  this.isReady = true;
@@ -271,6 +279,27 @@ export class SallaProductsSlider {
271
279
  },
272
280
  "attribute": "slider-config",
273
281
  "reflect": true
282
+ },
283
+ "productCardComponent": {
284
+ "type": "string",
285
+ "mutable": false,
286
+ "complexType": {
287
+ "original": "string",
288
+ "resolved": "string",
289
+ "references": {}
290
+ },
291
+ "required": false,
292
+ "optional": false,
293
+ "docs": {
294
+ "tags": [{
295
+ "name": "example",
296
+ "text": "<salla-products-slider product-card-component=\"my-custom-card-style1\" ...\n<salla-products-slider product-card-component=\"my-custom-card-style2\" ..."
297
+ }],
298
+ "text": "Custom Card Component for the Salla Products Slider.\n\nThis component allows you to customize the appearance of individual product cards within a Salla Products Slider."
299
+ },
300
+ "attribute": "product-card-component",
301
+ "reflect": false,
302
+ "defaultValue": "'custom-salla-product-card'"
274
303
  }
275
304
  };
276
305
  }