efficient-storefront-blocks 0.130.11 → 0.130.13

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.
@@ -5,6 +5,7 @@ export interface SetComponent {
5
5
  wheels: number;
6
6
  prices: Record<string, number | null>;
7
7
  hand?: SpareSide | null;
8
+ axle?: SpareAxle | null;
8
9
  }
9
10
  export declare function orderLinesForSets(components: SetComponent[], sets: number): {
10
11
  partNumber: string;
@@ -14,12 +15,15 @@ export declare function setPrice(components: SetComponent[], currency: string):
14
15
  export declare const UNITS_PER_SET = 4;
15
16
  export type PurchaseUnit = "set" | "single";
16
17
  export type SpareSide = "left" | "right";
18
+ export type SpareAxle = "front" | "rear";
17
19
  export declare const MAX_SPARES = 1;
18
20
  export interface PurchaseChoice {
19
21
  unit: PurchaseUnit;
20
22
  spares: number;
21
23
  spareSide: SpareSide;
24
+ spareAxle?: SpareAxle;
22
25
  }
26
+ export declare function spareAxleOf(choice: PurchaseChoice): SpareAxle;
23
27
  export declare const DEFAULT_PURCHASE_CHOICE: PurchaseChoice;
24
28
  export declare function unitsPerPack(choice: PurchaseChoice): number;
25
29
  export declare function packComposition(part: {
@@ -28,10 +32,12 @@ export declare function packComposition(part: {
28
32
  }, choice: PurchaseChoice): SetComponent[];
29
33
  export declare function setPackComposition(components: SetComponent[], choice: PurchaseChoice): SetComponent[];
30
34
  export declare function spareTargetsByHand(components: SetComponent[]): Record<SpareSide, number> | null;
35
+ export declare function spareTargetsByCorner(components: SetComponent[]): Record<SpareSide, Record<SpareAxle, number>> | null;
31
36
  export declare function purchaseChoiceFromPack(pack: {
32
37
  unit: PurchaseUnit;
33
38
  spares?: number;
34
39
  spareSide?: SpareSide | null;
40
+ spareAxle?: SpareAxle | null;
35
41
  spare?: boolean;
36
42
  }): PurchaseChoice;
37
43
  export declare function withSpare(label: string, choice: PurchaseChoice): string;
@@ -1 +1 @@
1
- const x=4;function E(e,t){return e.map(r=>({partNumber:r.partNumber,quantity:r.wheels*t}))}function _(e,t){if(e.length===0)return null;let r=0;for(const n of e){const s=n.prices?.[t];if(typeof s!="number"||!Number.isFinite(s)||s<=0)return null;r+=s*n.wheels}return r}const u=4,h=1,P={unit:"set",spares:0,spareSide:"left"};function f(e){return e.unit==="single"?1:u+e.spares}function g(e,t){return[{partNumber:e.partNumber,wheels:f(t),prices:e.prices}]}function T(e,t){const r=f(t)-u;if(r<=0||e.length===0)return e;const n=l(e),s=n?n[t.spareSide]:0;return e.map((o,p)=>p===s?{...o,wheels:o.wheels+r}:o)}function l(e){let t,r;for(let n=0;n<e.length;n+=1){const s=e[n].hand;if(s!=="left"&&s!=="right")continue;if((s==="left"?t:r)!==void 0)return null;s==="left"?t=n:r=n}return t!==void 0&&r!==void 0?{left:t,right:r}:null}function y(e){const t=typeof e.spares=="number"?e.spares:e.spare?1:0;return{unit:e.unit,spares:t,spareSide:e.spareSide??"left"}}function c(e,t){return t.spares>0?`${e} + spare`:e}function b(e){return e.unit==="single"?"Single":c(`Set of ${u}`,e)}const A="data-add-to-basket",C=9,d="en",i=new Map;function a(e,t,r){const n=`${e}|${t??""}|${r??""}`;let s=i.get(n);return s||(s=new Intl.NumberFormat(d,{style:"currency",currency:e,...t===void 0?{}:{minimumFractionDigits:t},...r===void 0?{}:{maximumFractionDigits:r}}),i.set(n,s)),s}function S(e,t,r=0){return a(t,0,r).format(e)}function w(e,t){return a(t).format(e)}function L(e,t){const r=e.savings[t];if(r===void 0)return null;const n=S(r,t);return e.savingIsFrom?`Save from ${n}`:`Save ${n}`}export{A as ADD_TO_BASKET_ATTR,P as DEFAULT_PURCHASE_CHOICE,C as MAX_QTY_PER_LINE,h as MAX_SPARES,d as PRICE_LOCALE,u as UNITS_PER_SET,x as WHEELS_PER_SET,L as bundleSaving,a as currencyFormat,w as formatMoneyInCurrency,S as formatPrice,E as orderLinesForSets,g as packComposition,b as packLabel,y as purchaseChoiceFromPack,T as setPackComposition,_ as setPrice,l as spareTargetsByHand,f as unitsPerPack,c as withSpare};
1
+ const A=4;function P(e,r){return e.map(t=>({partNumber:t.partNumber,quantity:t.wheels*r}))}function T(e,r){if(e.length===0)return null;let t=0;for(const n of e){const s=n.prices?.[r];if(typeof s!="number"||!Number.isFinite(s)||s<=0)return null;t+=s*n.wheels}return t}const l=4,y=1;function x(e){return e.spareAxle??"front"}const C={unit:"set",spares:0,spareSide:"left"};function p(e){return e.unit==="single"?1:l+e.spares}function b(e,r){return[{partNumber:e.partNumber,wheels:p(r),prices:e.prices}]}function $(e,r){const t=p(r)-l;if(t<=0||e.length===0)return e;const n=S(e),s=n?null:E(e),u=n?n[r.spareSide]:s?s[r.spareSide][x(r)]:0;return e.map((o,f)=>f===u?{...o,wheels:o.wheels+t}:o)}function S(e){let r,t;for(let n=0;n<e.length;n+=1){const s=e[n].hand;if(s!=="left"&&s!=="right")continue;if((s==="left"?r:t)!==void 0)return null;s==="left"?r=n:t=n}return r!==void 0&&t!==void 0?{left:r,right:t}:null}function E(e){const r={};for(let o=0;o<e.length;o+=1){const{hand:f,axle:i}=e[o];if(f!=="left"&&f!=="right"||i!=="front"&&i!=="rear")return null;const a=`${f}-${i}`;if(r[a]!==void 0)return null;r[a]=o}const{"left-front":t,"left-rear":n,"right-front":s,"right-rear":u}=r;return t!==void 0&&n!==void 0&&s!==void 0&&u!==void 0?{left:{front:t,rear:n},right:{front:s,rear:u}}:null}function w(e){const r=typeof e.spares=="number"?e.spares:e.spare?1:0;return{unit:e.unit,spares:r,spareSide:e.spareSide??"left",...e.spareAxle?{spareAxle:e.spareAxle}:{}}}function g(e,r){return r.spares>0?`${e} + spare`:e}function L(e){return e.unit==="single"?"Single":g(`Set of ${l}`,e)}const N="data-add-to-basket",R=9,h="en",d=new Map;function c(e,r,t){const n=`${e}|${r??""}|${t??""}`;let s=d.get(n);return s||(s=new Intl.NumberFormat(h,{style:"currency",currency:e,...r===void 0?{}:{minimumFractionDigits:r},...t===void 0?{}:{maximumFractionDigits:t}}),d.set(n,s)),s}function _(e,r,t=0){return c(r,0,t).format(e)}function I(e,r){return c(r).format(e)}function v(e,r){const t=e.savings[r];if(t===void 0)return null;const n=_(t,r);return e.savingIsFrom?`Save from ${n}`:`Save ${n}`}export{N as ADD_TO_BASKET_ATTR,C as DEFAULT_PURCHASE_CHOICE,R as MAX_QTY_PER_LINE,y as MAX_SPARES,h as PRICE_LOCALE,l as UNITS_PER_SET,A as WHEELS_PER_SET,v as bundleSaving,c as currencyFormat,I as formatMoneyInCurrency,_ as formatPrice,P as orderLinesForSets,b as packComposition,L as packLabel,w as purchaseChoiceFromPack,$ as setPackComposition,T as setPrice,x as spareAxleOf,E as spareTargetsByCorner,S as spareTargetsByHand,p as unitsPerPack,g as withSpare};