@salla.sa/twilight-components 1.0.10 → 1.0.12

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 (86) hide show
  1. package/dist/cjs/Helper-8852feaa.js +23 -0
  2. package/dist/cjs/index-23da2c6b.js +1601 -0
  3. package/dist/cjs/index.cjs.js +12 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/multi-warehouse_4.cjs.entry.js +242 -0
  6. package/dist/cjs/salla-localization.cjs.entry.js +76 -0
  7. package/dist/cjs/salla-login-476fb312.js +14 -0
  8. package/dist/cjs/salla-product-availability.cjs.entry.js +78 -0
  9. package/dist/cjs/salla-rating.cjs.entry.js +299 -0
  10. package/dist/cjs/salla-search-f9e00be9.js +97 -0
  11. package/dist/cjs/salla-search.cjs.entry.js +10 -0
  12. package/dist/cjs/salla-verify.cjs.entry.js +96 -0
  13. package/dist/cjs/twilight-components.cjs.js +19 -0
  14. package/dist/collection/Helpers/Helper.js +19 -0
  15. package/dist/collection/collection-manifest.json +20 -0
  16. package/dist/collection/components/generate-summary.js +35 -0
  17. package/dist/collection/components/multi-warehouse/multi-warehouse.css +13 -0
  18. package/dist/collection/components/multi-warehouse/multi-warehouse.js +238 -0
  19. package/dist/collection/components/salla-button/salla-button.css +3 -0
  20. package/dist/collection/components/salla-button/salla-button.js +219 -0
  21. package/dist/collection/components/salla-localization/salla-localization.js +201 -0
  22. package/dist/collection/components/salla-login/salla-login.js +31 -0
  23. package/dist/collection/components/salla-modal/salla-modal.js +316 -0
  24. package/dist/collection/components/salla-product-availability/salla-product-availability.js +316 -0
  25. package/dist/collection/components/salla-rating/salla-rating.css +3 -0
  26. package/dist/collection/components/salla-rating/salla-rating.js +484 -0
  27. package/dist/collection/components/salla-search/salla-search.js +155 -0
  28. package/dist/collection/components/salla-verify/salla-verify.js +99 -0
  29. package/dist/collection/index.js +2 -0
  30. package/dist/collection/interfaces/colors.js +1 -0
  31. package/dist/collection/interfaces/index.js +2 -0
  32. package/dist/collection/interfaces/ratio.js +1 -0
  33. package/dist/collection/plugins/tailwind-theme/generator.js +53 -0
  34. package/dist/collection/plugins/tailwind-theme/index.js +26 -0
  35. package/dist/{twilight-components/Helper-23b2de40.js → esm/Helper-81ac9a8c.js} +3 -0
  36. package/dist/esm/index-643344dc.js +1573 -0
  37. package/dist/esm/index.js +3 -0
  38. package/dist/esm/loader.js +17 -0
  39. package/dist/esm/multi-warehouse_4.entry.js +235 -0
  40. package/dist/esm/polyfills/core-js.js +11 -0
  41. package/dist/esm/polyfills/css-shim.js +1 -0
  42. package/dist/esm/polyfills/dom.js +79 -0
  43. package/dist/esm/polyfills/es5-html-element.js +1 -0
  44. package/dist/esm/polyfills/index.js +34 -0
  45. package/dist/esm/polyfills/system.js +6 -0
  46. package/dist/esm/salla-localization.entry.js +72 -0
  47. package/dist/{twilight-components/salla-login-97e0a9ab.js → esm/salla-login-0e85b2d8.js} +1 -1
  48. package/dist/{twilight-components → esm}/salla-product-availability.entry.js +38 -19
  49. package/dist/esm/salla-rating.entry.js +295 -0
  50. package/dist/{twilight-components/salla-search-df1c9b54.js → esm/salla-search-615b8f94.js} +1 -1
  51. package/dist/esm/salla-search.entry.js +2 -0
  52. package/dist/{twilight-components → esm}/salla-verify.entry.js +2 -2
  53. package/dist/esm/twilight-components.js +17 -0
  54. package/dist/index.cjs.js +1 -0
  55. package/dist/index.js +1 -0
  56. package/dist/twilight-components/index.esm.js +1 -3
  57. package/dist/twilight-components/p-2b8a5fa4.entry.js +1 -0
  58. package/dist/twilight-components/p-36c87e2e.js +1 -0
  59. package/dist/twilight-components/p-4e37a6cb.entry.js +1 -0
  60. package/dist/twilight-components/p-751643d8.entry.js +1 -0
  61. package/dist/twilight-components/p-8a2410e6.js +1 -0
  62. package/dist/twilight-components/p-94b18718.entry.js +1 -0
  63. package/dist/twilight-components/p-9bc28e0c.js +1 -0
  64. package/dist/twilight-components/p-bb503365.entry.js +1 -0
  65. package/dist/twilight-components/p-d1ef2268.js +1 -0
  66. package/dist/twilight-components/p-d34bbfc4.entry.js +1 -0
  67. package/dist/twilight-components/twilight-components.esm.js +1 -125
  68. package/dist/types/Helpers/Helper.d.ts +1 -0
  69. package/dist/types/components/salla-button/salla-button.d.ts +2 -1
  70. package/dist/types/components/salla-localization/salla-localization.d.ts +9 -2
  71. package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +6 -3
  72. package/dist/types/components/{order-rating/order-rating.d.ts → salla-rating/salla-rating.d.ts} +13 -4
  73. package/dist/types/components.d.ts +40 -24
  74. package/package.json +1 -1
  75. package/dist/twilight-components/app-globals-0f993ce5.js +0 -3
  76. package/dist/twilight-components/css-shim-a64b8820.js +0 -4
  77. package/dist/twilight-components/dom-d08ba8aa.js +0 -73
  78. package/dist/twilight-components/index-8cf58712.js +0 -3010
  79. package/dist/twilight-components/multi-warehouse.entry.js +0 -86
  80. package/dist/twilight-components/order-rating.entry.js +0 -257
  81. package/dist/twilight-components/salla-button.entry.js +0 -57
  82. package/dist/twilight-components/salla-localization.entry.js +0 -48
  83. package/dist/twilight-components/salla-login.entry.js +0 -2
  84. package/dist/twilight-components/salla-modal.entry.js +0 -84
  85. package/dist/twilight-components/salla-search.entry.js +0 -2
  86. package/dist/twilight-components/shadow-css-bc14d9fd.js +0 -389
@@ -0,0 +1,79 @@
1
+ (function(){
2
+ /*
3
+ Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
+ Code distributed by Google as part of the polymer project is also
8
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
+ */
10
+ 'use strict';var aa=new Set("annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" "));function g(a){var b=aa.has(a);a=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(a);return!b&&a}function l(a){var b=a.isConnected;if(void 0!==b)return b;for(;a&&!(a.__CE_isImportDocument||a instanceof Document);)a=a.parentNode||(window.ShadowRoot&&a instanceof ShadowRoot?a.host:void 0);return!(!a||!(a.__CE_isImportDocument||a instanceof Document))}
11
+ function n(a,b){for(;b&&b!==a&&!b.nextSibling;)b=b.parentNode;return b&&b!==a?b.nextSibling:null}
12
+ function p(a,b,d){d=void 0===d?new Set:d;for(var c=a;c;){if(c.nodeType===Node.ELEMENT_NODE){var e=c;b(e);var f=e.localName;if("link"===f&&"import"===e.getAttribute("rel")){c=e.import;if(c instanceof Node&&!d.has(c))for(d.add(c),c=c.firstChild;c;c=c.nextSibling)p(c,b,d);c=n(a,e);continue}else if("template"===f){c=n(a,e);continue}if(e=e.__CE_shadowRoot)for(e=e.firstChild;e;e=e.nextSibling)p(e,b,d)}c=c.firstChild?c.firstChild:n(a,c)}}function r(a,b,d){a[b]=d};function u(){this.a=new Map;this.g=new Map;this.c=[];this.f=[];this.b=!1}function ba(a,b,d){a.a.set(b,d);a.g.set(d.constructorFunction,d)}function ca(a,b){a.b=!0;a.c.push(b)}function da(a,b){a.b=!0;a.f.push(b)}function v(a,b){a.b&&p(b,function(b){return w(a,b)})}function w(a,b){if(a.b&&!b.__CE_patched){b.__CE_patched=!0;for(var d=0;d<a.c.length;d++)a.c[d](b);for(d=0;d<a.f.length;d++)a.f[d](b)}}
13
+ function x(a,b){var d=[];p(b,function(b){return d.push(b)});for(b=0;b<d.length;b++){var c=d[b];1===c.__CE_state?a.connectedCallback(c):y(a,c)}}function z(a,b){var d=[];p(b,function(b){return d.push(b)});for(b=0;b<d.length;b++){var c=d[b];1===c.__CE_state&&a.disconnectedCallback(c)}}
14
+ function A(a,b,d){d=void 0===d?{}:d;var c=d.u||new Set,e=d.i||function(b){return y(a,b)},f=[];p(b,function(b){if("link"===b.localName&&"import"===b.getAttribute("rel")){var d=b.import;d instanceof Node&&(d.__CE_isImportDocument=!0,d.__CE_hasRegistry=!0);d&&"complete"===d.readyState?d.__CE_documentLoadHandled=!0:b.addEventListener("load",function(){var d=b.import;if(!d.__CE_documentLoadHandled){d.__CE_documentLoadHandled=!0;var f=new Set(c);f.delete(d);A(a,d,{u:f,i:e})}})}else f.push(b)},c);if(a.b)for(b=
15
+ 0;b<f.length;b++)w(a,f[b]);for(b=0;b<f.length;b++)e(f[b])}
16
+ function y(a,b){if(void 0===b.__CE_state){var d=b.ownerDocument;if(d.defaultView||d.__CE_isImportDocument&&d.__CE_hasRegistry)if(d=a.a.get(b.localName)){d.constructionStack.push(b);var c=d.constructorFunction;try{try{if(new c!==b)throw Error("The custom element constructor did not produce the element being upgraded.");}finally{d.constructionStack.pop()}}catch(t){throw b.__CE_state=2,t;}b.__CE_state=1;b.__CE_definition=d;if(d.attributeChangedCallback)for(d=d.observedAttributes,c=0;c<d.length;c++){var e=
17
+ d[c],f=b.getAttribute(e);null!==f&&a.attributeChangedCallback(b,e,null,f,null)}l(b)&&a.connectedCallback(b)}}}u.prototype.connectedCallback=function(a){var b=a.__CE_definition;b.connectedCallback&&b.connectedCallback.call(a)};u.prototype.disconnectedCallback=function(a){var b=a.__CE_definition;b.disconnectedCallback&&b.disconnectedCallback.call(a)};
18
+ u.prototype.attributeChangedCallback=function(a,b,d,c,e){var f=a.__CE_definition;f.attributeChangedCallback&&-1<f.observedAttributes.indexOf(b)&&f.attributeChangedCallback.call(a,b,d,c,e)};function B(a){var b=document;this.c=a;this.a=b;this.b=void 0;A(this.c,this.a);"loading"===this.a.readyState&&(this.b=new MutationObserver(this.f.bind(this)),this.b.observe(this.a,{childList:!0,subtree:!0}))}function C(a){a.b&&a.b.disconnect()}B.prototype.f=function(a){var b=this.a.readyState;"interactive"!==b&&"complete"!==b||C(this);for(b=0;b<a.length;b++)for(var d=a[b].addedNodes,c=0;c<d.length;c++)A(this.c,d[c])};function ea(){var a=this;this.b=this.a=void 0;this.c=new Promise(function(b){a.b=b;a.a&&b(a.a)})}function D(a){if(a.a)throw Error("Already resolved.");a.a=void 0;a.b&&a.b(void 0)};function E(a){this.c=!1;this.a=a;this.j=new Map;this.f=function(b){return b()};this.b=!1;this.g=[];this.o=new B(a)}
19
+ E.prototype.l=function(a,b){var d=this;if(!(b instanceof Function))throw new TypeError("Custom element constructors must be functions.");if(!g(a))throw new SyntaxError("The element name '"+a+"' is not valid.");if(this.a.a.get(a))throw Error("A custom element with name '"+a+"' has already been defined.");if(this.c)throw Error("A custom element is already being defined.");this.c=!0;try{var c=function(b){var a=e[b];if(void 0!==a&&!(a instanceof Function))throw Error("The '"+b+"' callback must be a function.");
20
+ return a},e=b.prototype;if(!(e instanceof Object))throw new TypeError("The custom element constructor's prototype is not an object.");var f=c("connectedCallback");var t=c("disconnectedCallback");var k=c("adoptedCallback");var h=c("attributeChangedCallback");var m=b.observedAttributes||[]}catch(q){return}finally{this.c=!1}b={localName:a,constructorFunction:b,connectedCallback:f,disconnectedCallback:t,adoptedCallback:k,attributeChangedCallback:h,observedAttributes:m,constructionStack:[]};ba(this.a,
21
+ a,b);this.g.push(b);this.b||(this.b=!0,this.f(function(){return fa(d)}))};E.prototype.i=function(a){A(this.a,a)};
22
+ function fa(a){if(!1!==a.b){a.b=!1;for(var b=a.g,d=[],c=new Map,e=0;e<b.length;e++)c.set(b[e].localName,[]);A(a.a,document,{i:function(b){if(void 0===b.__CE_state){var e=b.localName,f=c.get(e);f?f.push(b):a.a.a.get(e)&&d.push(b)}}});for(e=0;e<d.length;e++)y(a.a,d[e]);for(;0<b.length;){var f=b.shift();e=f.localName;f=c.get(f.localName);for(var t=0;t<f.length;t++)y(a.a,f[t]);(e=a.j.get(e))&&D(e)}}}E.prototype.get=function(a){if(a=this.a.a.get(a))return a.constructorFunction};
23
+ E.prototype.m=function(a){if(!g(a))return Promise.reject(new SyntaxError("'"+a+"' is not a valid custom element name."));var b=this.j.get(a);if(b)return b.c;b=new ea;this.j.set(a,b);this.a.a.get(a)&&!this.g.some(function(b){return b.localName===a})&&D(b);return b.c};E.prototype.s=function(a){C(this.o);var b=this.f;this.f=function(d){return a(function(){return b(d)})}};window.CustomElementRegistry=E;E.prototype.define=E.prototype.l;E.prototype.upgrade=E.prototype.i;E.prototype.get=E.prototype.get;
24
+ E.prototype.whenDefined=E.prototype.m;E.prototype.polyfillWrapFlushCallback=E.prototype.s;var F=window.Document.prototype.createElement,G=window.Document.prototype.createElementNS,ha=window.Document.prototype.importNode,ia=window.Document.prototype.prepend,ja=window.Document.prototype.append,ka=window.DocumentFragment.prototype.prepend,la=window.DocumentFragment.prototype.append,H=window.Node.prototype.cloneNode,I=window.Node.prototype.appendChild,J=window.Node.prototype.insertBefore,K=window.Node.prototype.removeChild,L=window.Node.prototype.replaceChild,M=Object.getOwnPropertyDescriptor(window.Node.prototype,
25
+ "textContent"),N=window.Element.prototype.attachShadow,O=Object.getOwnPropertyDescriptor(window.Element.prototype,"innerHTML"),P=window.Element.prototype.getAttribute,Q=window.Element.prototype.setAttribute,R=window.Element.prototype.removeAttribute,S=window.Element.prototype.getAttributeNS,T=window.Element.prototype.setAttributeNS,U=window.Element.prototype.removeAttributeNS,ma=window.Element.prototype.insertAdjacentElement,na=window.Element.prototype.insertAdjacentHTML,oa=window.Element.prototype.prepend,
26
+ pa=window.Element.prototype.append,V=window.Element.prototype.before,qa=window.Element.prototype.after,ra=window.Element.prototype.replaceWith,sa=window.Element.prototype.remove,ta=window.HTMLElement,W=Object.getOwnPropertyDescriptor(window.HTMLElement.prototype,"innerHTML"),ua=window.HTMLElement.prototype.insertAdjacentElement,va=window.HTMLElement.prototype.insertAdjacentHTML;var wa=new function(){};function xa(){var a=X;window.HTMLElement=function(){function b(){var b=this.constructor,c=a.g.get(b);if(!c)throw Error("The custom element being constructed was not registered with `customElements`.");var e=c.constructionStack;if(0===e.length)return e=F.call(document,c.localName),Object.setPrototypeOf(e,b.prototype),e.__CE_state=1,e.__CE_definition=c,w(a,e),e;c=e.length-1;var f=e[c];if(f===wa)throw Error("The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.");
27
+ e[c]=wa;Object.setPrototypeOf(f,b.prototype);w(a,f);return f}b.prototype=ta.prototype;Object.defineProperty(b.prototype,"constructor",{writable:!0,configurable:!0,enumerable:!1,value:b});return b}()};function Y(a,b,d){function c(b){return function(d){for(var e=[],c=0;c<arguments.length;++c)e[c]=arguments[c];c=[];for(var f=[],m=0;m<e.length;m++){var q=e[m];q instanceof Element&&l(q)&&f.push(q);if(q instanceof DocumentFragment)for(q=q.firstChild;q;q=q.nextSibling)c.push(q);else c.push(q)}b.apply(this,e);for(e=0;e<f.length;e++)z(a,f[e]);if(l(this))for(e=0;e<c.length;e++)f=c[e],f instanceof Element&&x(a,f)}}void 0!==d.h&&(b.prepend=c(d.h));void 0!==d.append&&(b.append=c(d.append))};function ya(){var a=X;r(Document.prototype,"createElement",function(b){if(this.__CE_hasRegistry){var d=a.a.get(b);if(d)return new d.constructorFunction}b=F.call(this,b);w(a,b);return b});r(Document.prototype,"importNode",function(b,d){b=ha.call(this,b,!!d);this.__CE_hasRegistry?A(a,b):v(a,b);return b});r(Document.prototype,"createElementNS",function(b,d){if(this.__CE_hasRegistry&&(null===b||"http://www.w3.org/1999/xhtml"===b)){var c=a.a.get(d);if(c)return new c.constructorFunction}b=G.call(this,b,
28
+ d);w(a,b);return b});Y(a,Document.prototype,{h:ia,append:ja})};function za(){function a(a,c){Object.defineProperty(a,"textContent",{enumerable:c.enumerable,configurable:!0,get:c.get,set:function(a){if(this.nodeType===Node.TEXT_NODE)c.set.call(this,a);else{var d=void 0;if(this.firstChild){var e=this.childNodes,k=e.length;if(0<k&&l(this)){d=Array(k);for(var h=0;h<k;h++)d[h]=e[h]}}c.set.call(this,a);if(d)for(a=0;a<d.length;a++)z(b,d[a])}}})}var b=X;r(Node.prototype,"insertBefore",function(a,c){if(a instanceof DocumentFragment){var e=Array.prototype.slice.apply(a.childNodes);
29
+ a=J.call(this,a,c);if(l(this))for(c=0;c<e.length;c++)x(b,e[c]);return a}e=l(a);c=J.call(this,a,c);e&&z(b,a);l(this)&&x(b,a);return c});r(Node.prototype,"appendChild",function(a){if(a instanceof DocumentFragment){var c=Array.prototype.slice.apply(a.childNodes);a=I.call(this,a);if(l(this))for(var e=0;e<c.length;e++)x(b,c[e]);return a}c=l(a);e=I.call(this,a);c&&z(b,a);l(this)&&x(b,a);return e});r(Node.prototype,"cloneNode",function(a){a=H.call(this,!!a);this.ownerDocument.__CE_hasRegistry?A(b,a):v(b,
30
+ a);return a});r(Node.prototype,"removeChild",function(a){var c=l(a),e=K.call(this,a);c&&z(b,a);return e});r(Node.prototype,"replaceChild",function(a,c){if(a instanceof DocumentFragment){var e=Array.prototype.slice.apply(a.childNodes);a=L.call(this,a,c);if(l(this))for(z(b,c),c=0;c<e.length;c++)x(b,e[c]);return a}e=l(a);var f=L.call(this,a,c),d=l(this);d&&z(b,c);e&&z(b,a);d&&x(b,a);return f});M&&M.get?a(Node.prototype,M):ca(b,function(b){a(b,{enumerable:!0,configurable:!0,get:function(){for(var a=[],
31
+ b=0;b<this.childNodes.length;b++){var f=this.childNodes[b];f.nodeType!==Node.COMMENT_NODE&&a.push(f.textContent)}return a.join("")},set:function(a){for(;this.firstChild;)K.call(this,this.firstChild);null!=a&&""!==a&&I.call(this,document.createTextNode(a))}})})};function Aa(a){function b(b){return function(e){for(var c=[],d=0;d<arguments.length;++d)c[d]=arguments[d];d=[];for(var k=[],h=0;h<c.length;h++){var m=c[h];m instanceof Element&&l(m)&&k.push(m);if(m instanceof DocumentFragment)for(m=m.firstChild;m;m=m.nextSibling)d.push(m);else d.push(m)}b.apply(this,c);for(c=0;c<k.length;c++)z(a,k[c]);if(l(this))for(c=0;c<d.length;c++)k=d[c],k instanceof Element&&x(a,k)}}var d=Element.prototype;void 0!==V&&(d.before=b(V));void 0!==V&&(d.after=b(qa));void 0!==ra&&
32
+ r(d,"replaceWith",function(b){for(var e=[],c=0;c<arguments.length;++c)e[c]=arguments[c];c=[];for(var d=[],k=0;k<e.length;k++){var h=e[k];h instanceof Element&&l(h)&&d.push(h);if(h instanceof DocumentFragment)for(h=h.firstChild;h;h=h.nextSibling)c.push(h);else c.push(h)}k=l(this);ra.apply(this,e);for(e=0;e<d.length;e++)z(a,d[e]);if(k)for(z(a,this),e=0;e<c.length;e++)d=c[e],d instanceof Element&&x(a,d)});void 0!==sa&&r(d,"remove",function(){var b=l(this);sa.call(this);b&&z(a,this)})};function Ba(){function a(a,b){Object.defineProperty(a,"innerHTML",{enumerable:b.enumerable,configurable:!0,get:b.get,set:function(a){var e=this,d=void 0;l(this)&&(d=[],p(this,function(a){a!==e&&d.push(a)}));b.set.call(this,a);if(d)for(var f=0;f<d.length;f++){var t=d[f];1===t.__CE_state&&c.disconnectedCallback(t)}this.ownerDocument.__CE_hasRegistry?A(c,this):v(c,this);return a}})}function b(a,b){r(a,"insertAdjacentElement",function(a,e){var d=l(e);a=b.call(this,a,e);d&&z(c,e);l(a)&&x(c,e);return a})}
33
+ function d(a,b){function e(a,b){for(var e=[];a!==b;a=a.nextSibling)e.push(a);for(b=0;b<e.length;b++)A(c,e[b])}r(a,"insertAdjacentHTML",function(a,c){a=a.toLowerCase();if("beforebegin"===a){var d=this.previousSibling;b.call(this,a,c);e(d||this.parentNode.firstChild,this)}else if("afterbegin"===a)d=this.firstChild,b.call(this,a,c),e(this.firstChild,d);else if("beforeend"===a)d=this.lastChild,b.call(this,a,c),e(d||this.firstChild,null);else if("afterend"===a)d=this.nextSibling,b.call(this,a,c),e(this.nextSibling,
34
+ d);else throw new SyntaxError("The value provided ("+String(a)+") is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'.");})}var c=X;N&&r(Element.prototype,"attachShadow",function(a){a=N.call(this,a);var b=c;if(b.b&&!a.__CE_patched){a.__CE_patched=!0;for(var e=0;e<b.c.length;e++)b.c[e](a)}return this.__CE_shadowRoot=a});O&&O.get?a(Element.prototype,O):W&&W.get?a(HTMLElement.prototype,W):da(c,function(b){a(b,{enumerable:!0,configurable:!0,get:function(){return H.call(this,!0).innerHTML},
35
+ set:function(a){var b="template"===this.localName,c=b?this.content:this,e=G.call(document,this.namespaceURI,this.localName);for(e.innerHTML=a;0<c.childNodes.length;)K.call(c,c.childNodes[0]);for(a=b?e.content:e;0<a.childNodes.length;)I.call(c,a.childNodes[0])}})});r(Element.prototype,"setAttribute",function(a,b){if(1!==this.__CE_state)return Q.call(this,a,b);var e=P.call(this,a);Q.call(this,a,b);b=P.call(this,a);c.attributeChangedCallback(this,a,e,b,null)});r(Element.prototype,"setAttributeNS",function(a,
36
+ b,d){if(1!==this.__CE_state)return T.call(this,a,b,d);var e=S.call(this,a,b);T.call(this,a,b,d);d=S.call(this,a,b);c.attributeChangedCallback(this,b,e,d,a)});r(Element.prototype,"removeAttribute",function(a){if(1!==this.__CE_state)return R.call(this,a);var b=P.call(this,a);R.call(this,a);null!==b&&c.attributeChangedCallback(this,a,b,null,null)});r(Element.prototype,"removeAttributeNS",function(a,b){if(1!==this.__CE_state)return U.call(this,a,b);var d=S.call(this,a,b);U.call(this,a,b);var e=S.call(this,
37
+ a,b);d!==e&&c.attributeChangedCallback(this,b,d,e,a)});ua?b(HTMLElement.prototype,ua):ma?b(Element.prototype,ma):console.warn("Custom Elements: `Element#insertAdjacentElement` was not patched.");va?d(HTMLElement.prototype,va):na?d(Element.prototype,na):console.warn("Custom Elements: `Element#insertAdjacentHTML` was not patched.");Y(c,Element.prototype,{h:oa,append:pa});Aa(c)};var Z=window.customElements;if(!Z||Z.forcePolyfill||"function"!=typeof Z.define||"function"!=typeof Z.get){var X=new u;xa();ya();Y(X,DocumentFragment.prototype,{h:ka,append:la});za();Ba();document.__CE_hasRegistry=!0;var customElements=new E(X);Object.defineProperty(window,"customElements",{configurable:!0,enumerable:!0,value:customElements})};
38
+ }).call(self);
39
+
40
+ // Polyfill document.baseURI
41
+ "string"!==typeof document.baseURI&&Object.defineProperty(Document.prototype,"baseURI",{enumerable:!0,configurable:!0,get:function(){var a=document.querySelector("base");return a&&a.href?a.href:document.URL}});
42
+
43
+ // Polyfill CustomEvent
44
+ "function"!==typeof window.CustomEvent&&(window.CustomEvent=function(c,a){a=a||{bubbles:!1,cancelable:!1,detail:void 0};var b=document.createEvent("CustomEvent");b.initCustomEvent(c,a.bubbles,a.cancelable,a.detail);return b},window.CustomEvent.prototype=window.Event.prototype);
45
+
46
+ // Event.composedPath
47
+ (function(b,c,d){b.composedPath||(b.composedPath=function(){if(this.path)return this.path;var a=this.target;for(this.path=[];null!==a.parentNode;)this.path.push(a),a=a.parentNode;this.path.push(c,d);return this.path})})(Event.prototype,document,window);
48
+
49
+ /*!
50
+ Element.closest and Element.matches
51
+ https://github.com/jonathantneal/closest
52
+ Creative Commons Zero v1.0 Universal
53
+ */
54
+ (function(a){"function"!==typeof a.matches&&(a.matches=a.msMatchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||function(a){a=(this.document||this.ownerDocument).querySelectorAll(a);for(var b=0;a[b]&&a[b]!==this;)++b;return!!a[b]});"function"!==typeof a.closest&&(a.closest=function(a){for(var b=this;b&&1===b.nodeType;){if(b.matches(a))return b;b=b.parentNode}return null})})(window.Element.prototype);
55
+
56
+ /*!
57
+ Element.getRootNode()
58
+ */
59
+ (function(c){function d(a){a=b(a);return a&&11===a.nodeType?d(a.host):a}function b(a){return a&&a.parentNode?b(a.parentNode):a}"function"!==typeof c.getRootNode&&(c.getRootNode=function(a){return a&&a.composed?d(this):b(this)})})(Element.prototype);
60
+
61
+ /*!
62
+ Element.isConnected()
63
+ */
64
+ (function(a){"isConnected"in a||Object.defineProperty(a,"isConnected",{configurable:!0,enumerable:!0,get:function(){var a=this.getRootNode({composed:!0});return a&&9===a.nodeType}})})(Element.prototype);
65
+
66
+ /*!
67
+ Element.remove()
68
+ */
69
+ (function(b){b.forEach(function(a){a.hasOwnProperty("remove")||Object.defineProperty(a,"remove",{configurable:!0,enumerable:!0,writable:!0,value:function(){null!==this.parentNode&&this.parentNode.removeChild(this)}})})})([Element.prototype,CharacterData.prototype,DocumentType.prototype]);
70
+
71
+ /*!
72
+ Element.classList
73
+ */
74
+ !function(e){'classList'in e||Object.defineProperty(e,"classList",{get:function(){var e=this,t=(e.getAttribute("class")||"").replace(/^\s+|\s$/g,"").split(/\s+/g);function n(){t.length>0?e.setAttribute("class",t.join(" ")):e.removeAttribute("class")}return""===t[0]&&t.splice(0,1),t.toggle=function(e,i){void 0!==i?i?t.add(e):t.remove(e):-1!==t.indexOf(e)?t.splice(t.indexOf(e),1):t.push(e),n()},t.add=function(){for(var e=[].slice.call(arguments),i=0,s=e.length;i<s;i++)-1===t.indexOf(e[i])&&t.push(e[i]);n()},t.remove=function(){for(var e=[].slice.call(arguments),i=0,s=e.length;i<s;i++)-1!==t.indexOf(e[i])&&t.splice(t.indexOf(e[i]),1);n()},t.item=function(e){return t[e]},t.contains=function(e){return-1!==t.indexOf(e)},t.replace=function(e,i){-1!==t.indexOf(e)&&t.splice(t.indexOf(e),1,i),n()},t.value=e.getAttribute("class")||"",t}})}(Element.prototype);
75
+
76
+ /*!
77
+ DOMTokenList
78
+ */
79
+ (function(b){try{document.body.classList.add()}catch(e){var c=b.add,d=b.remove;b.add=function(){for(var a=0;a<arguments.length;a++)c.call(this,arguments[a])};b.remove=function(){for(var a=0;a<arguments.length;a++)d.call(this,arguments[a])}}})(DOMTokenList.prototype);
@@ -0,0 +1 @@
1
+ (function(){if("undefined"!==typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var a=HTMLElement;window.HTMLElement=function(){return Reflect.construct(a,[],this.constructor)};HTMLElement.prototype=a.prototype;HTMLElement.prototype.constructor=HTMLElement;Object.setPrototypeOf(HTMLElement,a)}})();
@@ -0,0 +1,34 @@
1
+ export function applyPolyfills() {
2
+ var promises = [];
3
+ if (typeof window !== 'undefined') {
4
+ var win = window;
5
+
6
+ if (!win.customElements ||
7
+ (win.Element && (!win.Element.prototype.closest || !win.Element.prototype.matches || !win.Element.prototype.remove || !win.Element.prototype.getRootNode))) {
8
+ promises.push(import(/* webpackChunkName: "polyfills-dom" */ './dom.js'));
9
+ }
10
+
11
+ var checkIfURLIsSupported = function() {
12
+ try {
13
+ var u = new URL('b', 'http://a');
14
+ u.pathname = 'c%20d';
15
+ return (u.href === 'http://a/c%20d') && u.searchParams;
16
+ } catch (e) {
17
+ return false;
18
+ }
19
+ };
20
+
21
+ if (
22
+ 'function' !== typeof Object.assign || !Object.entries ||
23
+ !Array.prototype.find || !Array.prototype.includes ||
24
+ !String.prototype.startsWith || !String.prototype.endsWith ||
25
+ (win.NodeList && !win.NodeList.prototype.forEach) ||
26
+ !win.fetch ||
27
+ !checkIfURLIsSupported() ||
28
+ typeof WeakMap == 'undefined'
29
+ ) {
30
+ promises.push(import(/* webpackChunkName: "polyfills-core-js" */ './core-js.js'));
31
+ }
32
+ }
33
+ return Promise.all(promises);
34
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * SystemJS 4.0.2
3
+ * MANUAL PATCH: remove script.crossOrigin = "anonymous"
4
+ * MANUAL PATCH: add conditionally apply, n.System=n.System||new u
5
+ */
6
+ !function(){var e="undefined"!=typeof self,n=e?self:global;var t;if("undefined"!=typeof document){var e=document.querySelector("base[href]");e&&(t=e.href)}if(!t&&"undefined"!=typeof location){var e=(t=location.href.split("#")[0].split("?")[0]).lastIndexOf("/");-1!==e&&(t=t.slice(0,e+1))}var r=/\\/g,o="undefined"!=typeof Symbol,i=o&&Symbol.toStringTag,c=o?Symbol():"@";function u(){this[c]={}}var s=u.prototype;var l;s.import=function(e,n){var t=this;return Promise.resolve(t.resolve(e,n)).then(function(e){var n=function e(n,t,r){var o=n[c][t];if(o)return o;var u=[],s=Object.create(null);i&&Object.defineProperty(s,i,{value:"Module"});var l=Promise.resolve().then(function(){return n.instantiate(t,r)}).then(function(e){if(!e)throw Error("Module "+t+" did not instantiate");var r=e[1](function(e,n){o.h=!0;var t=!1;if("object"!=typeof e)e in s&&s[e]===n||(s[e]=n,t=!0);else for(var n in e){var r=e[n];n in s&&s[n]===r||(s[n]=r,t=!0)}if(t)for(var e=0;e<u.length;e++)u[e](s);return n},2===e[1].length?{import:function(e){return n.import(e,t)},meta:n.createContext(t)}:void 0);return o.e=r.execute||function(){},[e[0],r.setters||[]]});var f=l.then(function(r){return Promise.all(r[0].map(function(o,i){var c=r[1][i];return Promise.resolve(n.resolve(o,t)).then(function(r){var o=e(n,r,t);return Promise.resolve(o.I).then(function(){return c&&(o.i.push(c),!o.h&&o.I||c(o.n)),o})})})).then(function(e){o.d=e})});return f.catch(function(e){o.e=null,o.er=e}),o=n[c][t]={id:t,i:u,n:s,I:l,L:f,h:!1,d:void 0,e:void 0,er:void 0,E:void 0,C:void 0}}(t,e);return n.C||function(e,n){return n.C=function e(n,t,r){if(!r[t.id])return r[t.id]=!0,Promise.resolve(t.L).then(function(){return Promise.all(t.d.map(function(t){return e(n,t,r)}))})}(e,n,{}).then(function(){return function e(n,t,r){if(r[t.id])return;if(r[t.id]=!0,!t.e){if(t.er)throw t.er;return t.E?t.E:void 0}var o;return t.d.forEach(function(t){{var i=e(n,t,r);i&&(o=o||[]).push(i)}}),o?Promise.all(o).then(i):i();function i(){try{var e=t.e.call(f);if(e)return e=e.then(function(){t.C=t.n,t.E=null}),t.E=t.E||e;t.C=t.n}catch(e){throw t.er=e,e}finally{t.L=t.I=void 0,t.e=null}}}(e,n,{})}).then(function(){return n.n})}(t,n)})},s.createContext=function(e){return{url:e}},s.register=function(e,n){l=[e,n]},s.getRegister=function(){var e=l;return l=void 0,e};var f=Object.freeze(Object.create(null));n.System=n.System||new u;var d=s.register;s.register=function(e,n){d.call(this,e,n)},s.instantiate=function(e,n){var t=this;return".json"===e.substr(-5)?fetch(e).then(function(e){return e.text()}).then(function(e){return[[],function(n){return{execute:function(){n("default",JSON.parse(e))}}}]}):new Promise(function(r,o){var i;function c(n){n.filename===e&&(i=n.error)}window.addEventListener("error",c);var u=document.createElement("script");u.charset="utf-8",u.async=!0,u.addEventListener("error",function(){window.removeEventListener("error",c),o(Error("Error loading "+e+(n?" from "+n:"")))}),u.addEventListener("load",function(){window.removeEventListener("error",c),document.head.removeChild(u),i?o(i):r(t.getRegister())}),u.src=e,document.head.appendChild(u)})},e&&"function"==typeof importScripts&&(s.instantiate=function(e){var n=this;return new Promise(function(t,r){try{importScripts(e)}catch(e){r(e)}t(n.getRegister())})}),s.resolve=function(e,n){var o=function(e,n){if(-1!==e.indexOf("\\")&&(e=e.replace(r,"/")),"/"===e[0]&&"/"===e[1])return n.slice(0,n.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){var t=n.slice(0,n.indexOf(":")+1);var r;if(r="/"===n[t.length+1]?"file:"!==t?(r=n.slice(t.length+2)).slice(r.indexOf("/")+1):n.slice(8):n.slice(t.length+("/"===n[t.length])),"/"===e[0])return n.slice(0,n.length-r.length-1)+e;var o=r.slice(0,r.lastIndexOf("/")+1)+e,i=[];var c=-1;for(var e=0;e<o.length;e++)-1!==c?"/"===o[e]&&(i.push(o.slice(c,e+1)),c=-1):"."===o[e]?"."!==o[e+1]||"/"!==o[e+2]&&e+2!==o.length?"/"===o[e+1]||e+1===o.length?e+=1:c=e:(i.pop(),e+=2):c=e;return-1!==c&&i.push(o.slice(c)),n.slice(0,n.length-r.length)+i.join("")}}(e,n||t);if(!o){if(-1!==e.indexOf(":"))return Promise.resolve(e);throw Error('Cannot resolve "'+e+(n?'" from '+n:'"'))}return Promise.resolve(o)}}();
@@ -0,0 +1,72 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-643344dc.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+
4
+ const SallaLocalization = class {
5
+ constructor(hostRef) {
6
+ registerInstance(this, hostRef);
7
+ var _a, _b;
8
+ this.language = salla.config.language;
9
+ this.currency = salla.config.currency;
10
+ this.languages = salla.lang.get('common.titles.language');
11
+ this.currencies = salla.lang.get('common.titles.currency');
12
+ this.ok = salla.lang.get('common.elements.ok');
13
+ Helper.setHost(this.host);
14
+ salla.event.on('localization::show', () => this.show());
15
+ /**
16
+ * letting developer to insert his own slot like:
17
+ * <salla-localization>
18
+ * <div slot="language">...{name}....</div>
19
+ * <div slot="currency">...{name}....</div>
20
+ * </salla-localization>
21
+ * Because scoped templates not supported in stencil );
22
+ * we made a workaround to pass language & currency attributes, then replace names in rendering
23
+ */
24
+ this.languageSlot = ((_a = Helper.getElement('[slot="language"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<label class="s-localization-label" for"lang-{code}"><span>{name}</span><div class="s-localization-flag flag iti__flag iti__{country_code}"></div></label>';
25
+ this.currencySlot = ((_b = Helper.getElement('[slot="currency"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || '<label class="s-localization-label" for="currency-{code}"><span>{name}</span><small class="s-localization-currency">{code}</small></label>';
26
+ }
27
+ async show() {
28
+ return this.modal.show();
29
+ }
30
+ async hide() {
31
+ return this.modal.hide();
32
+ }
33
+ async submit() {
34
+ let url;
35
+ this.btn.load()
36
+ .then(() => {
37
+ if (this.currency && this.currency.code !== salla.config.currency.code) {
38
+ url = window.location.href;
39
+ return salla.currency.api.change(this.currency.code);
40
+ }
41
+ }).then(() => {
42
+ if (this.language && this.language.code !== salla.config.language.code) {
43
+ url = this.language.url;
44
+ }
45
+ }).then(() => this.btn.stop())
46
+ .then(() => this.hide())
47
+ .then(() => url && (window.location.href = url));
48
+ }
49
+ render() {
50
+ return (h("salla-modal", { id: "salla-localization", class: "hidden", ref: modal => this.modal = modal }, h("slot", { name: "header" }, h("div", { slot: "header" })), h("div", { class: "s-localization-inner" }, salla.config.languages
51
+ ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.languages), h("fieldset", { class: "s-localization-fieldset" }, h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_language')), h("div", { class: "s-localization-section-inner" }, salla.config.languages.map(lang => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", checked: this.language.code == lang.code, onChange: () => this.language = lang, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), h("div", { id: "language-slot", innerHTML: this.languageSlot
52
+ .replace(/\{name\}/g, lang.name)
53
+ .replace(/\{code\}/g, lang.code)
54
+ .replace(/\{country_code\}/g, lang.country_code) }))))))
55
+ : '', salla.config.currencies
56
+ ? h("div", { class: "s-localization-section" }, h("label", { class: "s-localization-title" }, this.currencies), h("fieldset", { class: "s-localization-fieldset" }, h("legend", { class: "sr-only" }, salla.lang.get('blocks.header.change_currency')), h("div", { class: "s-localization-section-inner" }, salla.config.currencies.map(currency => h("div", { class: "s-localization-item" }, h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency.code == currency.code, onChange: () => this.currency = currency, id: 'currency-' + currency.code, value: currency.code }), h("div", { id: "currency-slot", innerHTML: this.currencySlot
57
+ .replace(/\{name\}/g, currency.name)
58
+ .replace(/\{code\}/g, currency.code)
59
+ .replace(/\{country_code\}/g, currency.country_code) }))))))
60
+ : ''), h("p", { slot: "footer" }, h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.submit(), class: "w-full" }, this.ok)))));
61
+ }
62
+ /**
63
+ * to reduce dom levels we will move slot data into the parent dom
64
+ */
65
+ componentDidRender() {
66
+ this.host.querySelectorAll('#currency-slot').forEach(el => el.replaceWith(el.firstChild));
67
+ this.host.querySelectorAll('#language-slot').forEach(el => el.replaceWith(el.firstChild));
68
+ }
69
+ get host() { return getElement(this); }
70
+ };
71
+
72
+ export { SallaLocalization as salla_localization };
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, h } from './index-8cf58712.js';
1
+ import { r as registerInstance, h } from './index-643344dc.js';
2
2
 
3
3
  const SallaLogin = class {
4
4
  constructor(hostRef) {
@@ -1,10 +1,12 @@
1
- import { r as registerInstance, h, e as Host, g as getElement } from './index-8cf58712.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-643344dc.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
2
3
 
3
4
  const SallaProductAvailability = class {
4
5
  constructor(hostRef) {
5
6
  registerInstance(this, hostRef);
6
- this.hasButton = true;
7
- this.countryCode = 'SA';
7
+ this.isUser = Helper.isUser();
8
+ this.buttonText = salla.lang.get('pages.products.notify_availability');
9
+ this.countryCode = salla.config.country_code || 'SA';
8
10
  this.subscribe = salla.lang.get('common.elements.submit');
9
11
  this.cancel = salla.lang.get('common.elements.cancel');
10
12
  this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
@@ -13,6 +15,10 @@ const SallaProductAvailability = class {
13
15
  this.mobilePlaceholder = salla.lang.get('common.elements.mobile_placeholder');
14
16
  this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
15
17
  this.productId = salla.config.page.id;
18
+ this.subscribed = salla.lang.get('pages.products.notify_availability_success');
19
+ if (this.isUser) {
20
+ return;
21
+ }
16
22
  this.channelsWatcher(this.channels);
17
23
  this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
18
24
  this.host.removeAttribute('title');
@@ -21,30 +27,43 @@ const SallaProductAvailability = class {
21
27
  this.channels_ = newValue.split(',');
22
28
  }
23
29
  async submit() {
24
- this.btn.load()
25
- .then(this.btn.disable)
26
- .then(() => salla.api.product.availabilitySubscribe({
27
- id: this.productId,
28
- mobile: this.mobile.value,
29
- email: this.email.value,
30
- country_code: this.countryCode,
31
- }))
32
- .then(() => salla.success(salla.lang.get('pages.products.notify_availability_success')))
33
- .then(this.btn.stop)
34
- .then(this.modal.hide)
35
- .then(() => this.host.remove());
30
+ if (this.isUser) {
31
+ return salla.api.product.availabilitySubscribe(this.productId)
32
+ .then(() => {
33
+ salla.success(this.subscribed);
34
+ }) //no need to wait until finishing alert animation
35
+ .then(() => this.host.remove());
36
+ }
37
+ let data = { id: this.productId, country_code: this.countryCode };
38
+ if (this.mobile.value !== '') {
39
+ data['mobile'] = this.mobile.value;
40
+ }
41
+ if (this.email.value !== '') {
42
+ data['email'] = this.email.value;
43
+ }
44
+ return this.btn.load()
45
+ .then(() => this.btn.disable())
46
+ .then(() => salla.api.product.availabilitySubscribe(data))
47
+ .then(() => {
48
+ salla.success(this.subscribed);
49
+ }) //no need to wait until finishing alert animation
50
+ .then(() => this.btn.stop())
51
+ .then(() => this.modal.hide())
52
+ .then(() => this.host.remove())
53
+ .catch(() => this.btn.stop() && this.btn.enable());
36
54
  }
37
55
  render() {
38
- return (h(Host, null, this.hasButton
39
- ? h("salla-button", { onClick: () => this.modal.show() }, h("slot", null, salla.lang.get('pages.products.notify_availability')))
40
- : h("slot", null), h("salla-modal", { ref: modal => this.modal = modal, id: "product-availability-modal", title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-full" }, h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
56
+ return (h(Host, null, h("slot", null, h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show() }, this.buttonText)), this.isUser ? '' : this.renderModal()));
57
+ }
58
+ renderModal() {
59
+ return (h("salla-modal", { ref: modal => this.modal = modal, id: "product-availability-modal", title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", modalWidth: "w-full" }, h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
41
60
  h("label", { class: "s-product-availability-label" }, this.emailLabel),
42
61
  h("input", { class: "s-product-availability-input", placeholder: this.emailPlaceholder, ref: el => this.email = el, type: "email" })
43
62
  ] : '', this.channels_.includes('sms') ? [
44
63
  h("label", { class: "s-product-availability-label" }, this.mobileLabel),
45
64
  h("input", { class: "s-product-availability-input", placeholder: this.mobilePlaceholder, ref: el => this.mobile = el, type: "text" }),
46
65
  h("input", { type: "hidden", value: this.countryCode }),
47
- ] : ''), h("div", { slot: "footer", class: "common-anime flex justify-between space-s-4" }, h("salla-button", { ref: btn => this.btn = btn, class: "w-full", onClick: () => this.submit() }, this.subscribe), h("salla-button", { class: "w-full", color: "outline" }, this.cancel)))));
66
+ ] : ''), h("div", { slot: "footer", class: "common-anime flex justify-between space-s-4" }, h("salla-button", { ref: btn => this.btn = btn, class: "w-full", onClick: () => this.submit() }, this.subscribe), h("salla-button", { class: "w-full", color: "outline" }, this.cancel))));
48
67
  }
49
68
  get host() { return getElement(this); }
50
69
  static get watchers() { return {
@@ -0,0 +1,295 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-643344dc.js';
2
+ import { H as Helper } from './Helper-81ac9a8c.js';
3
+
4
+ const sallaRatingCss = ":host{display:block}";
5
+
6
+ const SallaRating = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.stars = [1, 2, 3, 4, 5];
10
+ this.order = {
11
+ shipping: { id: 5622 },
12
+ products: [
13
+ {
14
+ "title": "ميكروفون عالى الجودة",
15
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
16
+ "price": "‏10,978.00 ر.س",
17
+ "qty": "‏2",
18
+ "totalBefore": "‏1120 ر.س",
19
+ "discount": "-5%",
20
+ "total": "‏1064 ر.س",
21
+ "id": "2314513454",
22
+ "getOptimusRouteKey": "7351233357"
23
+ },
24
+ // {
25
+ // "title": "وحدة تحكم لمشغل العاب",
26
+ // "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg",
27
+ // "price": "‏10,978.00 ر.س",
28
+ // "qty": "‏2",
29
+ // "totalBefore": "‏1120 ر.س",
30
+ // "discount": "-5%",
31
+ // "total": "‏1064 ر.س",
32
+ // "id": "9842833",
33
+ // "getOptimusRouteKey": "735152357"
34
+ // },
35
+ {
36
+ "title": "ساعة ذكية بنظام اندرويد",
37
+ "image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
38
+ "price": "‏10,978.00 ر.س",
39
+ "qty": "‏2",
40
+ "totalBefore": "‏1120 ر.س",
41
+ "discount": "-5%",
42
+ "total": "‏1064 ر.س",
43
+ "id": "679822376",
44
+ "getOptimusRouteKey": "73233357"
45
+ }
46
+ ],
47
+ };
48
+ this.isProductsRating = false;
49
+ this.ratingChain = Promise.resolve();
50
+ this.stepsCount = 0;
51
+ Helper.setHost(this.host);
52
+ }
53
+ async show() {
54
+ return this.modal.show();
55
+ }
56
+ async hide() {
57
+ return this.modal.hide();
58
+ }
59
+ componentWillLoad() {
60
+ this.stepsCount = [this.isStoreRating, this.isProductsRating, this.isShippingRating].filter(item => item).length;
61
+ this.getData();
62
+ }
63
+ componentDidRender() {
64
+ this.show();
65
+ this.initiateRating();
66
+ }
67
+ initiateRating() {
68
+ this.highlightSelectedStars();
69
+ this.starsRating();
70
+ this.handleWizard();
71
+ const step = this.host.querySelector('.step:first-child');
72
+ this.setModalHeight(step);
73
+ salla.event.on('submit::order-rating', () => this.sendRating().then(() => {
74
+ let seconds = 10;
75
+ let timeToClose = setInterval(() => {
76
+ seconds--;
77
+ this.host.querySelector('.close-time').innerHTML = `00:0${seconds}`;
78
+ if (seconds == 0) {
79
+ this.hide();
80
+ clearInterval(timeToClose);
81
+ }
82
+ }, 1000);
83
+ this.host.querySelector('.wizard-footer').classList.add('opacity-0', 'pointer-events-0');
84
+ this.host.querySelector('.s-order-rating-title').classList.add('opacity-0', 'pointer-events-0');
85
+ Helper.toggle('.step', 'hidden', 'block', () => true);
86
+ Helper.toggle('.thankyou-view', 'is-opened', 'hidden', () => true);
87
+ const thankYouView = this.host.querySelector('.thankyou-view');
88
+ this.setModalHeight(thankYouView);
89
+ setTimeout(() => {
90
+ Helper.toggleElement(thankYouView, ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3'], () => true);
91
+ }, 200);
92
+ }));
93
+ }
94
+ // handle wizard
95
+ handleWizard() {
96
+ let currentIndex = 0, steps = document.querySelectorAll(".step"), dots = document.querySelectorAll(".step-dot");
97
+ // show first step
98
+ Helper.toggleElement(steps[0], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3', 'hidden'], () => true);
99
+ console.log("🚀 ~ file: order-rating.tsx ~ line 129 ~ OrderRating ~ handleWizard ~ steps[0]", steps[0]);
100
+ Helper.onClick("#prev-btn", () => {
101
+ currentIndex > 0 && currentIndex--;
102
+ this.showActiveStep(steps, dots, currentIndex);
103
+ currentIndex == 0 && Helper.toggle('#prev-btn', ['pointer-events-none', 'opacity-0'], 'block', () => true);
104
+ });
105
+ Helper.onClick("#next-btn", () => {
106
+ this.ratingValidation();
107
+ if (currentIndex == this.stepsCount - 1) {
108
+ salla.event.dispatch("submit::order-rating");
109
+ }
110
+ else {
111
+ currentIndex < this.stepsCount - 1 && currentIndex++;
112
+ this.showActiveStep(steps, dots, currentIndex);
113
+ Helper.toggle('#prev-btn', 'block', ['pointer-events-none', 'opacity-0'], () => true);
114
+ }
115
+ });
116
+ }
117
+ showActiveStep(steps, dots, currentIndex) {
118
+ Helper.toggle('.step-dot', 'bg-gray-200', 'bg-primay', () => true);
119
+ Helper.toggleElement(dots[currentIndex], 'bg-primary', 'bg-gray-200', () => true);
120
+ // hide all steps
121
+ Helper.toggle('.step', ['hidden', 'opacity-0', 'translate-x-3'], ['active', 'opacity-1', 'translate-x-0'], () => true);
122
+ Helper.toggleElement(steps[currentIndex], 'active', 'hidden', () => true);
123
+ this.setModalHeight(steps[currentIndex]);
124
+ setTimeout(() => {
125
+ Helper.toggleElement(steps[currentIndex], ['opacity-1', 'translate-x-0'], ['opacity-0', 'translate-x-3',], () => true);
126
+ }, 200);
127
+ }
128
+ setModalHeight(current) {
129
+ const wrapper = this.host.querySelector('.s-order-rating-steps-wrapper');
130
+ setTimeout(() => {
131
+ wrapper === null || wrapper === void 0 ? void 0 : wrapper.setAttribute('style', 'height:' + (current === null || current === void 0 ? void 0 : current.scrollHeight) + 'px');
132
+ });
133
+ }
134
+ // send feedback rating and validation
135
+ sendRating() {
136
+ Helper.all('.rating-section', ratingSection => {
137
+ let type = ratingSection.dataset.type;
138
+ let formsData = [];
139
+ ratingSection.querySelectorAll('.rating-outer-form')
140
+ .forEach((form) => {
141
+ let formData = {};
142
+ form.querySelectorAll('[name]')
143
+ .forEach(function (input) {
144
+ let inputData = salla.helpers.inputData(input.name, input.value, formData);
145
+ formData[inputData.name] = inputData.value;
146
+ });
147
+ formsData = [];
148
+ formsData.push(formData);
149
+ this.sendFeedback(type, formsData);
150
+ });
151
+ });
152
+ return this.ratingChain;
153
+ }
154
+ sendFeedback(type, formsData) {
155
+ if (!formsData || formsData.length == 0) {
156
+ return;
157
+ }
158
+ this.nextBtn.load();
159
+ salla.config.canLeave = false;
160
+ this.ratingChain = salla.feedback.api[type](formsData[0])
161
+ .then(function () {
162
+ salla.config.canLeave = true;
163
+ }).catch(() => salla.config.canLeave = true);
164
+ }
165
+ ratingValidation() {
166
+ let errorMsg = '';
167
+ document.querySelectorAll('.rating-section.active')
168
+ .forEach((ratingSection) => {
169
+ ratingSection.querySelectorAll('.rating-outer-form')
170
+ .forEach((rating) => {
171
+ let ratingInput = rating.querySelector('.rating_hidden_input');
172
+ let commentInput = rating.querySelector('.comment');
173
+ // let sectionTitle = rating.querySelector('.section-title');
174
+ let validationMessage = rating.querySelector('.validation-message');
175
+ if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
176
+ commentInput.classList.remove('has-error');
177
+ // sectionTitle?.classList.remove('has-error', 'text-red-400');
178
+ validationMessage.innerHTML = '';
179
+ return;
180
+ }
181
+ else if (commentInput.value && commentInput.value.length > 3) {
182
+ commentInput.classList.remove('has-error');
183
+ }
184
+ else {
185
+ commentInput.classList.add('has-error');
186
+ }
187
+ // sectionTitle?.classList.add('has-error', 'text-red-400');
188
+ errorMsg = ratingInput.value
189
+ ? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
190
+ : (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
191
+ validationMessage.innerHTML = errorMsg;
192
+ });
193
+ });
194
+ //Fire error to prevent sending rating
195
+ if (errorMsg) {
196
+ // scroll to first error
197
+ let ratingErrors = document.querySelectorAll('.has-error');
198
+ if (ratingErrors.length) {
199
+ let firstError = ratingErrors[0].offsetTop;
200
+ window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
201
+ }
202
+ throw new Error(errorMsg);
203
+ }
204
+ }
205
+ // getdata
206
+ getData() {
207
+ salla.api.order.endpointsMethods.details = 'get';
208
+ // salla.order.api.details(this.orderId).then(data => console.log(''));
209
+ console.log("🚀 ~ file", salla.order.api.details(this.orderId));
210
+ }
211
+ // handle star rating
212
+ starsRating() {
213
+ let selectedClasses = ['selected', 'text-theme-yellow'];
214
+ // Listen for form submissions
215
+ salla.document.event.onSubmit('.rate-element', function (event) {
216
+ // Prevent form from submitting
217
+ event.preventDefault();
218
+ // Get the selected star - activeElement is not supported in safari
219
+ var activeStars = event.target.querySelectorAll('.btn--star.hovered');
220
+ var selected = activeStars[activeStars.length - 1];
221
+ if (!selected)
222
+ return;
223
+ var selectedIndex = parseInt(selected.dataset.star, 10);
224
+ event.target.querySelector('.rating_hidden_input').value = selectedIndex;
225
+ // Get all stars in this form (only search in the form, not the whole document)
226
+ // Loop through each star, and add or remove the `.selected` class to toggle highlighting
227
+ event.target
228
+ .querySelectorAll('.btn--star')
229
+ .forEach(function (star, index) {
230
+ if (index < selectedIndex) {
231
+ // Selected star or before it, Add highlighting
232
+ star.classList.add(...selectedClasses);
233
+ return;
234
+ }
235
+ // After selected star, Remove highlight
236
+ star.classList.remove(...selectedClasses);
237
+ });
238
+ // Remove aria-pressed from any previously selected star
239
+ var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
240
+ if (previousRating) {
241
+ previousRating.removeAttribute('aria-pressed');
242
+ }
243
+ // Add aria-pressed role to the selected button
244
+ selected.setAttribute('aria-pressed', true);
245
+ });
246
+ }
247
+ highlightSelectedStars() {
248
+ let hover = ['hovered', 'text-theme-yellow'];
249
+ Helper.all('.rate-element', el => {
250
+ let starElements = el.querySelectorAll('.btn--star');
251
+ // remove hovered state from stars ---
252
+ el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
253
+ starElements.forEach((starElement, index) => {
254
+ starElement.addEventListener('mouseover', () => {
255
+ starElement.classList.add(...hover);
256
+ if (index <= 1) {
257
+ starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
258
+ }
259
+ else {
260
+ for (let i = 0; i < index; i++) {
261
+ starElements[i].classList.add(...hover);
262
+ }
263
+ }
264
+ });
265
+ starElement.addEventListener('mouseout', () => {
266
+ starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
267
+ });
268
+ });
269
+ });
270
+ }
271
+ // render
272
+ render() {
273
+ return (h(Host, null, h("salla-modal", { class: "hidden", "modal-width": "w-[800px]", ref: modal => this.modal = modal, title: salla.lang.get('pages.rating.rate_order') + ' <span class="unicode">(#' + this.orderId + ')</span>' }, h("div", { class: "s-order-rating-steps-wrapper mt-12 mb-10 transition-all duration-300 ease-elastic" }, this.isStoreRating && this.renderStoreRating(), this.isProductsRating && this.renderProductsRating(), this.isShippingRating && this.renderShippingRating(), this.renderThanksView()), h("div", { class: "wizard-footer relative flex justify-between items-center" }, h("button", { id: "prev-btn", class: "font-bold text-sm w-28 h-10 px-4 text-primary hover:text-primary-d opacity-0 pointer-events-none duration-300 transition-all" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), this.stepsCount > 1 ?
274
+ h("ul", { class: "flex justify-center text-center space-s-1.5 flex-1" }, [0, 1, 2].slice(0, this.stepsCount).map(index => h("li", { class: `${index == 0 ? 'bg-primary' : 'bg-gray-200'} step-dot w-2.5 h-2.5 rounded-full transition-colors duration-300` }))) : '', h("salla-button", { id: "next-btn", class: "w-28", ref: nextBtn => this.nextBtn = nextBtn }, "\u0627\u0644\u062A\u0627\u0644\u064A")))));
275
+ }
276
+ renderStoreRating() {
277
+ return (h("section", { class: "step rating-section active transition-all duration-500", "data-type": "store" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_store_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "type", value: "store" }), h("div", { class: "flex flex-col items-center " }, h("div", { class: "w-28 h-28 border border-gray-200 rounded-full flex items-center justify-center mb-4" }, h("img", { src: "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/X3NKcY7nhaFQlR7kBBHvfDpMY48cerunKrmDA1gi.png", alt: "store name", class: "w-12 object-contain" })), h("h2", { class: "section-title text-lg font-bold mb-4" }, salla.lang.get('pages.rating.rate_the_store'))), h("div", { class: "rating-wrap flex items-center flex justify-center mb-4" }, h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())), h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "text-red-400 validation-message" }))));
278
+ }
279
+ renderProductsRating() {
280
+ return (h("section", { class: "step rating-section products-section transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "product" }, h("div", { class: "overflow-hidden" }, this.order.products.map((item, index) => h("div", { class: "rating-outer-form mb-8 last:mb-0", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars', { "item": item.title }) }, h("div", { class: "product-item" }, h("div", { class: "flex space-s-5" }, h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }), h("div", { class: "flex-1" }, h("h3", { class: "section-title leading-5 mb-1.5 font-bold md:text-sm" }, " ", item.title), h("div", { class: "rw-product-entry__rate" }, h("div", { class: "rating-wrap flex items-center space-s-4" }, h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating())), h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }), h("input", { type: "hidden", name: "type", value: "products" }), h("textarea", { "data-product-id": item.id, name: `products[${index}][comment]`, id: `productReview_${item.id}`, class: "comment form-input h-20 product-review", placeholder: salla.lang.get('pages.rating.write_product_rate') }), h("small", { class: "text-red-400 validation-message" }))))))))));
281
+ }
282
+ renderShippingRating() {
283
+ return (h("section", { class: "step rating-section py-5 rounded-md transition-all duration-500 opacity-0 translate-x-3 hidden", "data-type": "shipping" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_shipping_stars') }, h("input", { type: "hidden", name: "order_id", value: this.orderId }), h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), h("input", { type: "hidden", name: "type", value: "shipping" }), h("div", { class: "flex flex-col items-center " }, h("div", { class: "w-28 h-28 overflow-hidden border border-gray-200 rounded-full flex items-center justify-center mb-4" }, h("img", { src: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcScPt4R6KaKDldrXb-9pUljFwL3m6A72BhN6p1qZJKprwC6VbCWC_8ASZgiJAoL_l7DepM&usqp=CAU", alt: "company name", class: "w-full h-full object-contain" })), h("h2", { class: "section-title text-lg font-bold mb-4" }, " ", salla.lang.get('pages.rating.rate_shipping'), " \u0627\u0631\u0627\u0645\u0643\u0633")), h("div", { class: "rating-wrap flex flex justify-center mb-4" }, h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating())), h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "text-red-400 validation-message" }))));
284
+ }
285
+ renderThanksView() {
286
+ return (h("div", { class: "thankyou-view px-8 text-center transition-all duration-500 opacity-0 translate-x-3 hidden" }, h("span", { class: "w-20 h-20 text-4xl inline-flex justify-center items-center bg-gray-50 rounded-full text-primary sicon-check-circle2" }), h("div", { class: "mt-4 mb-6" }, h("h3", { class: "font-bold" }, salla.lang.get('pages.rating.thanks')), h("div", { class: "text-gray-400 text-sm", innerHTML: this.thanksMsg })), h("a", { href: "#!", onClick: () => this.hide(), class: "btn btn-primary h-10 flex-none px-8" }, "\u0639\u0648\u062F\u0629 \u0625\u0644\u064A \u062A\u0641\u0627\u0635\u064A\u0644 \u0627\u0644\u0637\u0644\u0628"), h("time", { class: "close-time text-gray-400 block h-6 mt-3 text-sm" })));
287
+ }
288
+ getStarsRating() {
289
+ return (h("div", { class: "mb-1" }, h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), this.stars.map((star) => h("button", { type: "submit", class: "btn btn--transparent px-1 text-2xl text-gray-400 btn--star", "data-star": star }, h("i", { class: "sicon-star2" })))));
290
+ }
291
+ get host() { return getElement(this); }
292
+ };
293
+ SallaRating.style = sallaRatingCss;
294
+
295
+ export { SallaRating as salla_rating };