mealz-components 1.3.8 → 1.3.9

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.
@@ -1 +1 @@
1
- import{t as l}from"../assets/custom-element-BhZVzxrc.js";import"../assets/lit-element-4gw3YGga.js";import{N as u}from"../assets/no-shadow-element-CaVIVF-o.js";import{k as h,O as f,o as p,c as o}from"../assets/OperatorSubscriber-CcnWrfoX.js";import{S as d}from"../assets/Subject-rBVVIydv.js";var g=function(e){h(r,e);function r(i){var t=e.call(this)||this;return t._value=i,t}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(i){var t=e.prototype._subscribe.call(this,i);return!t.closed&&i.next(this._value),t},r.prototype.getValue=function(){var i=this,t=i.hasError,s=i.thrownError,c=i._value;if(t)throw s;return this._throwIfClosed(),c},r.prototype.next=function(i){e.prototype.next.call(this,this._value=i)},r}(d),m=new f(function(e){return e.complete()});function b(e){return e<=0?function(){return m}:p(function(r,i){var t=0;r.subscribe(o(i,function(s){++t<=e&&(i.next(s),e<=t&&i.complete())}))})}function v(e){return p(function(r,i){var t=!1,s=0;r.subscribe(o(i,function(c){return(t||(t=!e(c,s++)))&&i.next(c)}))})}var P=Object.defineProperty,_=Object.getOwnPropertyDescriptor,y=(e,r,i,t)=>{for(var s=t>1?void 0:t?_(r,i):r,c=e.length-1,n;c>=0;c--)(n=e[c])&&(s=(t?n(r,i,s):n(s))||s);return t&&s&&P(r,i,s),s};let a=class extends u{constructor(){super(...arguments),this.formattedPrice="",this.rendered=new g(!1),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),this.subscriptions.push(window.mealzInternal.recipes.guestsUpdated().subscribe(e=>{e.recipeId===this.recipeId&&(this.serves=e.guests,this.recalculatePrice())}),this.rendered.pipe(v(e=>!e),b(1)).subscribe(()=>{this.subscriptions.push(window.mealzInternal.basket.recipeDataInBasket$().subscribe(e=>{e&&(this.recipePricingValue=e.find(r=>r.id===this.recipeId),this.recalculatePrice(),this.showPrice())}))}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}fetchPrice(e,r,i=null){i||(i=this.recipeId),this.subscriptions.push(window.mealzInternal.recipes.fetchPricing(i,e,r).subscribe(t=>{t!=null&&t.price_per_serve&&this.applyCurrencyDisplay(t.price_per_serve)}))}render(){this.recipePricing=this.querySelector(".mealz-recipe-pricing"),this.recipePricing&&this.rendered.next(!0)}getInitialStatus(){var s;const e=(s=this.attributes["starting-data"])==null?void 0:s.value;if(!e)return;const{recipeId:r,pricePerServe:i,serves:t}=JSON.parse(e);this.recipeId=r,this.pricePerServe=(i==null?void 0:i.toString())??null,this.serves=t,this.applyCurrencyDisplay(this.pricePerServe)}applyCurrencyDisplay(e){const r=parseFloat(e);isNaN(r)||(this.formattedPrice=r.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),this.updateDOM())}showPrice(){var i,t;let e=(i=this.recipePricing)==null?void 0:i.querySelector(".mealz-recipe-pricing__loading"),r=(t=this.recipePricing)==null?void 0:t.querySelector(".mealz-recipe-pricing__wrapper");e&&e.classList.contains("active")&&(e.classList.replace("active","hidden"),r.classList.replace("hidden","active"))}updateDOM(){var r;const e=(r=this.recipePricing)==null?void 0:r.querySelector(".mealz-recipe-pricing__wrapper__price");e&&(e.innerHTML=this.formattedPrice+" €")}recalculatePrice(){if(this.recipePricingValue){const e=(parseFloat(this.recipePricingValue.price)/this.recipePricingValue.guests).toString();this.applyCurrencyDisplay(e)}}};a=y([l("mealz-recipe-pricing")],a);customElements.get("mealz-recipe-pricing")||customElements.define("mealz-recipe-pricing",a);
1
+ import{t as l}from"../assets/custom-element-BhZVzxrc.js";import"../assets/lit-element-4gw3YGga.js";import{N as u}from"../assets/no-shadow-element-CaVIVF-o.js";import{k as h,O as f,o as p,c as o}from"../assets/OperatorSubscriber-CcnWrfoX.js";import{S as d}from"../assets/Subject-rBVVIydv.js";var g=function(e){h(r,e);function r(i){var t=e.call(this)||this;return t._value=i,t}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(i){var t=e.prototype._subscribe.call(this,i);return!t.closed&&i.next(this._value),t},r.prototype.getValue=function(){var i=this,t=i.hasError,s=i.thrownError,c=i._value;if(t)throw s;return this._throwIfClosed(),c},r.prototype.next=function(i){e.prototype.next.call(this,this._value=i)},r}(d),m=new f(function(e){return e.complete()});function b(e){return e<=0?function(){return m}:p(function(r,i){var t=0;r.subscribe(o(i,function(s){++t<=e&&(i.next(s),e<=t&&i.complete())}))})}function v(e){return p(function(r,i){var t=!1,s=0;r.subscribe(o(i,function(c){return(t||(t=!e(c,s++)))&&i.next(c)}))})}var P=Object.defineProperty,_=Object.getOwnPropertyDescriptor,y=(e,r,i,t)=>{for(var s=t>1?void 0:t?_(r,i):r,c=e.length-1,n;c>=0;c--)(n=e[c])&&(s=(t?n(r,i,s):n(s))||s);return t&&s&&P(r,i,s),s};let a=class extends u{constructor(){super(...arguments),this.formattedPrice="",this.rendered=new g(!1),this.subscriptions=[]}connectedCallback(){super.connectedCallback(),this.getInitialStatus(),this.subscriptions.push(window.mealzInternal.recipes.guestsUpdated().subscribe(e=>{e.recipeId===this.recipeId&&(this.serves=e.guests,this.recalculatePrice())}),this.rendered.pipe(v(e=>!e),b(1)).subscribe(()=>{this.subscriptions.push(window.mealzInternal.basket.recipeDataInBasket$().subscribe(e=>{e&&(this.recipePricingValue=e.find(r=>r.id===this.recipeId),this.recalculatePrice(),this.showPrice())}))}))}disconnectedCallback(){super.disconnectedCallback(),this.subscriptions.forEach(e=>e.unsubscribe())}fetchPrice(e,r,i=null){i||(i=this.recipeId),this.subscriptions.push(window.mealzInternal.recipes.fetchPricing(i,e,r).subscribe(t=>{t!=null&&t.price_per_serve&&this.applyCurrencyDisplay(t.price_per_serve)}))}render(){this.recipePricing=this.querySelector(".mealz-recipe-pricing"),this.recipePricing&&this.rendered.next(!0)}getInitialStatus(){var s;const e=(s=this.attributes["starting-data"])==null?void 0:s.value;if(!e)return;const{recipeId:r,pricePerServe:i,serves:t}=JSON.parse(e);this.recipeId=r,this.pricePerServe=(i==null?void 0:i.toString())??null,this.serves=t,this.applyCurrencyDisplay(this.pricePerServe)}applyCurrencyDisplay(e){const r=parseFloat(e);isNaN(r)||(this.formattedPrice=r.toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),this.updateDOM())}showPrice(){var i,t;let e=(i=this.recipePricing)==null?void 0:i.querySelector(".mealz-recipe-pricing__loading"),r=(t=this.recipePricing)==null?void 0:t.querySelector(".mealz-recipe-pricing__wrapper");e&&e.classList.contains("active")&&(e.classList.replace("active","hidden"),r.classList.replace("hidden","active"))}updateDOM(){var r;const e=(r=this.recipePricing)==null?void 0:r.querySelector(".mealz-recipe-pricing__wrapper__price");e&&(e.innerHTML=this.formattedPrice+" €",this.showPrice())}recalculatePrice(){if(this.recipePricingValue){const e=(parseFloat(this.recipePricingValue.price)/this.recipePricingValue.guests).toString();this.applyCurrencyDisplay(e)}}};a=y([l("mealz-recipe-pricing")],a);customElements.get("mealz-recipe-pricing")||customElements.define("mealz-recipe-pricing",a);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mealz-components",
3
3
  "type": "module",
4
- "version": "1.3.8",
4
+ "version": "1.3.9",
5
5
  "main": "./dist/mealz-components.js",
6
6
  "module": "./dist/mealz-components.js",
7
7
  "scripts": {