@dropins/storefront-pdp 1.3.0 → 2.0.0-alpha100
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.
- package/api/getFetchedProductData/getFetchedProductData.d.ts +3 -1
- package/api/getProductConfigurationValues/getProductConfigurationValues.d.ts +3 -1
- package/api/initialize/initialize.d.ts +1 -0
- package/api/isProductConfigurationValid/isProductConfigurationValid.d.ts +3 -1
- package/api/setProductConfigurationValid/setProductConfigurationValid.d.ts +3 -1
- package/api/setProductConfigurationValues/setProductConfigurationValues.d.ts +3 -1
- package/chunks/getFetchedProductData.js +1 -1
- package/chunks/getFetchedProductData.js.map +1 -1
- package/chunks/isProductConfigurationValid.js +9 -9
- package/chunks/isProductConfigurationValid.js.map +1 -1
- package/containers/ProductAttributes/ProductAttributes.d.ts +1 -0
- package/containers/ProductAttributes.js +1 -1
- package/containers/ProductAttributes.js.map +1 -1
- package/containers/ProductDescription/ProductDescription.d.ts +1 -0
- package/containers/ProductDescription.js +1 -1
- package/containers/ProductDescription.js.map +1 -1
- package/containers/ProductGallery/ProductGallery.d.ts +1 -0
- package/containers/ProductGallery.js +1 -1
- package/containers/ProductGallery.js.map +1 -1
- package/containers/ProductHeader/ProductHeader.d.ts +1 -0
- package/containers/ProductHeader.js +1 -1
- package/containers/ProductHeader.js.map +1 -1
- package/containers/ProductOptions/ProductOptions.d.ts +1 -0
- package/containers/ProductOptions.js +1 -1
- package/containers/ProductOptions.js.map +1 -1
- package/containers/ProductPrice/ProductPrice.d.ts +1 -0
- package/containers/ProductPrice.js +1 -1
- package/containers/ProductPrice.js.map +1 -1
- package/containers/ProductQuantity/ProductQuantity.d.ts +1 -0
- package/containers/ProductQuantity.js +1 -1
- package/containers/ProductQuantity.js.map +1 -1
- package/containers/ProductShortDescription/ProductShortDescription.d.ts +1 -0
- package/containers/ProductShortDescription.js +1 -1
- package/containers/ProductShortDescription.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ProductModel } from '../../data/models/product-model';
|
|
2
2
|
|
|
3
|
-
export declare const getFetchedProductData: (
|
|
3
|
+
export declare const getFetchedProductData: ({ scope, }?: {
|
|
4
|
+
scope?: string | undefined;
|
|
5
|
+
}) => Promise<ProductModel | null>;
|
|
4
6
|
//# sourceMappingURL=getFetchedProductData.d.ts.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ValuesModel } from '../../data/models';
|
|
2
2
|
|
|
3
|
-
export declare const getProductConfigurationValues: (
|
|
3
|
+
export declare const getProductConfigurationValues: ({ scope, }?: {
|
|
4
|
+
scope?: string | undefined;
|
|
5
|
+
}) => ValuesModel | null;
|
|
4
6
|
//# sourceMappingURL=getProductConfigurationValues.d.ts.map
|
|
@@ -13,5 +13,7 @@
|
|
|
13
13
|
* is strictly forbidden unless prior written permission is obtained
|
|
14
14
|
* from Adobe.
|
|
15
15
|
*/
|
|
16
|
-
export declare const isProductConfigurationValid: (
|
|
16
|
+
export declare const isProductConfigurationValid: ({ scope, }?: {
|
|
17
|
+
scope?: string | undefined;
|
|
18
|
+
}) => boolean | null;
|
|
17
19
|
//# sourceMappingURL=isProductConfigurationValid.d.ts.map
|
|
@@ -13,5 +13,7 @@
|
|
|
13
13
|
* is strictly forbidden unless prior written permission is obtained
|
|
14
14
|
* from Adobe.
|
|
15
15
|
*/
|
|
16
|
-
export declare const setProductConfigurationValid: (callback: (prev: boolean) => boolean
|
|
16
|
+
export declare const setProductConfigurationValid: (callback: (prev: boolean) => boolean, options?: {
|
|
17
|
+
scope?: string;
|
|
18
|
+
}) => void;
|
|
17
19
|
//# sourceMappingURL=setProductConfigurationValid.d.ts.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ValuesModel } from '../../data/models';
|
|
2
2
|
|
|
3
|
-
export declare const setProductConfigurationValues: (callback: (prev: ValuesModel) => ValuesModel
|
|
3
|
+
export declare const setProductConfigurationValues: (callback: (prev: ValuesModel) => ValuesModel, options?: {
|
|
4
|
+
scope?: string;
|
|
5
|
+
}) => void;
|
|
4
6
|
//# sourceMappingURL=setProductConfigurationValues.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{events as
|
|
3
|
+
import{events as o}from"@dropins/tools/event-bus.js";const n=async({scope:a}={})=>{const e=o.lastPayload("pdp/data",{scope:a});return e?Promise.resolve(e):new Promise(r=>{const t=o.on("pdp/data",s=>{r(s),t==null||t.off()},{eager:!0,scope:a})})};export{n as g};
|
|
4
4
|
//# sourceMappingURL=getFetchedProductData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getFetchedProductData.js","sources":["/@dropins/storefront-pdp/src/api/getFetchedProductData/getFetchedProductData.ts"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models/product-model';\n\nexport const getFetchedProductData = async (): Promise<ProductModel | null> => {\n // if the event has already been emitted, return the last payload\n if (
|
|
1
|
+
{"version":3,"file":"getFetchedProductData.js","sources":["/@dropins/storefront-pdp/src/api/getFetchedProductData/getFetchedProductData.ts"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models/product-model';\n\nexport const getFetchedProductData = async ({\n scope,\n}: { scope?: string } = {}): Promise<ProductModel | null> => {\n const payload = events.lastPayload('pdp/data', { scope });\n // if the event has already been emitted, return the last payload\n if (payload) {\n return Promise.resolve(payload);\n }\n\n // otherwise, wait for the next event\n return new Promise((resolve) => {\n const event = events.on(\n 'pdp/data',\n (data) => {\n resolve(data);\n event?.off();\n },\n { eager: true, scope }\n );\n });\n};\n"],"names":["getFetchedProductData","scope","payload","events","resolve","event","data"],"mappings":"qDAmBO,MAAMA,EAAwB,MAAO,CAC1C,MAAAC,CACF,EAAwB,KAAqC,CAC3D,MAAMC,EAAUC,EAAO,YAAY,WAAY,CAAE,MAAAF,EAAO,EAExD,OAAIC,EACK,QAAQ,QAAQA,CAAO,EAIzB,IAAI,QAASE,GAAY,CAC9B,MAAMC,EAAQF,EAAO,GACnB,WACCG,GAAS,CACRF,EAAQE,CAAI,EACZD,GAAA,MAAAA,EAAO,KACT,EACA,CAAE,MAAO,GAAM,MAAAJ,CAAM,CACvB,CAAA,CACD,CACH"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{merge as me,Initializer as ce}from"@dropins/tools/lib.js";import{events as
|
|
3
|
+
import{merge as me,Initializer as ce}from"@dropins/tools/lib.js";import{events as E}from"@dropins/tools/event-bus.js";import{PRODUCT_FRAGMENT as re}from"../fragments.js";import{FetchGraphQL as fe}from"@dropins/tools/fetch-graphql.js";function He(e){const n=new URLSearchParams(window.location.search);Object.entries(e).forEach(([r,t])=>{t===null?n.delete(r):n.set(r,String(t))});let i=window.location.pathname;i+=`?${n.toString()}`,i+=window.location.hash,window.history.replaceState({},"",i)}function ie(){const e=new URLSearchParams(window.location.search),n={};return e.forEach((i,r)=>{n[r]=i}),n}function Pe(e=1){const i=(ie()||{}).quantity;if(i){const r=parseInt(i,10);if(!isNaN(r)&&Number.isInteger(r)&&r>0)return r}return e}function de(e){var n,i,r,t,s,a,o,u,m,l,c,f;return{productId:Number(e==null?void 0:e.externalId),name:e==null?void 0:e.name,sku:(e==null?void 0:e.variantSku)||(e==null?void 0:e.sku),topLevelSku:e==null?void 0:e.sku,specialToDate:void 0,specialFromDate:void 0,newToDate:void 0,newFromDate:void 0,createdAt:void 0,updatedAt:void 0,manufacturer:void 0,countryOfManufacture:void 0,categories:void 0,productType:e==null?void 0:e.productType,pricing:{regularPrice:((i=(n=e==null?void 0:e.prices)==null?void 0:n.regular)==null?void 0:i.amount)||0,minimalPrice:(t=(r=e==null?void 0:e.prices)==null?void 0:r.final)==null?void 0:t.minimumAmount,maximalPrice:(a=(s=e==null?void 0:e.prices)==null?void 0:s.final)==null?void 0:a.maximumAmount,specialPrice:(u=(o=e==null?void 0:e.prices)==null?void 0:o.final)==null?void 0:u.amount,tierPricing:void 0,currencyCode:((l=(m=e==null?void 0:e.prices)==null?void 0:m.final)==null?void 0:l.currency)||"USD"},canonicalUrl:e==null?void 0:e.url,mainImageUrl:(f=(c=e==null?void 0:e.images)==null?void 0:c[0])==null?void 0:f.url}}const se={PRODUCT_CONTEXT:"productContext",CHANNEL_CONTEXT:"channelContext"},he={PRODUCT_PAGE_VIEW:"product-page-view"};function ae(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function we(){return{_id:"https://ns.adobe.com/xdm/channels/web",_type:"https://ns.adobe.com/xdm/channel-types/web"}}function ue(e,n){const i=ae();i.push({[e]:null}),i.push({[e]:n})}function ye(){typeof window>"u"||ue(se.CHANNEL_CONTEXT,we())}function Ce(e,n){ae().push(r=>{const t=r.getState?r.getState():{};r.push({event:e,eventInfo:{...t,...n}})})}function ge(e){const n=de(e);ue(se.PRODUCT_CONTEXT,n),ye(),Ce(he.PRODUCT_PAGE_VIEW)}var H=(e=>(e.ComplexProduct="complex",e.SimpleProduct="simple",e))(H||{}),le=(e=>(e.ComplexProductView="ComplexProductView",e.SimpleProductView="SimpleProductView",e))(le||{});function q(e,n){var a,o,u,m,l,c,f,d,h,y,P,k;const i=((m=(u=(o=(a=e==null?void 0:e.options)==null?void 0:a[0])==null?void 0:o.values)==null?void 0:u[0])==null?void 0:m.__typename)==="ProductViewOptionValueProduct",r=be(e,i,n==null?void 0:n.preselectFirstOption),t=(e==null?void 0:e.__typename)===le.SimpleProductView?H.SimpleProduct:H.ComplexProduct,s=e?{name:e.name,sku:e.sku,isBundle:i,addToCartAllowed:e.addToCartAllowed,inStock:e.inStock,shortDescription:e.shortDescription,metaDescription:e.metaDescription,metaKeyword:e.metaKeyword,metaTitle:e.metaTitle,description:e.description,images:xe(e),prices:Se(e,i,r),attributes:De(e),options:Te(e,i),optionUIDs:r,url:e.url,urlKey:e.urlKey,externalId:e.externalId,externalParentId:e.externalParentId,variantSku:e.variantSku,productType:t}:null;return me(s,((d=(f=(c=(l=_.getConfig())==null?void 0:l.models)==null?void 0:c.ProductDetails)==null?void 0:f.transformer)==null?void 0:d.call(f,e))??((k=(P=(y=(h=_.getConfig())==null?void 0:h.models)==null?void 0:y.ProductDetails)==null?void 0:P.transform)==null?void 0:k.call(P,e)))}function xe(e){var n,i;return(i=(n=e.images)==null?void 0:n.filter(r=>{var t;return!((t=r.roles)!=null&&t.includes("hide_from_pdp"))}))==null?void 0:i.map(r=>(r.url=r.url.replace(/^https?:/,""),r))}function De(e){var n,i;return(i=(n=e.attributes)==null?void 0:n.filter(({roles:r})=>(r==null?void 0:r.indexOf("visible_in_pdp"))!==-1))==null?void 0:i.map(({label:r,value:t,name:s})=>({id:s,label:r,value:t.toString().split(",").join(", ")}))}function Te(e,n){const{options:i,optionUIDs:r}=e;return i==null?void 0:i.map(({id:t,title:s,required:a,multi:o,values:u})=>{var c;const m=(c=u==null?void 0:u[0])==null?void 0:c.__typename;let l=u==null?void 0:u[0].type;return l?l=l.replace("COLOR_HEX","color").replace("TEXT","text").replace("IMAGE","image"):l="dropdown",{id:t,type:l,typename:m,label:s,required:a,multiple:o,items:n?Ee(u,r):Oe(u,r,l)}})}function Ee(e,n){return e==null?void 0:e.filter(({enabled:i})=>typeof i>"u"||i).map(({id:i,title:r,inStock:t,isDefault:s,product:a})=>({id:i,inStock:t,label:r,selected:(n==null?void 0:n.indexOf(i))>-1||s,value:i,product:a}))}function Oe(e,n,i){return e==null?void 0:e.map(({id:r,title:t,inStock:s,value:a})=>({id:r,inStock:s,label:t,selected:(n==null?void 0:n.indexOf(r))>-1,value:(i==null?void 0:i.toLowerCase())==="dropdown"?r:a==null?void 0:a.replace(/^https?:/,"")}))}function Se(e,n,i){var P,k,K,B,z;const{price:r,priceRange:t,options:s,optionUIDs:a=i}=e;let{__typename:o}=e;function u(){var D;const g=r==null?void 0:r.regular.amount.value,w=((D=r==null?void 0:r.final)==null?void 0:D.amount.value)??(r==null?void 0:r.regular.amount.value),x=(r==null?void 0:r.regular.amount.currency)==="NONE"?"USD":r==null?void 0:r.regular.amount.currency;return[g,w,w,x]}function m(){var O,S,p,v,A,U,I,N,V,F,G,L;const g=(O=t==null?void 0:t.minimum)==null?void 0:O.final.amount.value,w=(S=t==null?void 0:t.maximum)==null?void 0:S.final.amount.value;let x;((v=(p=t==null?void 0:t.minimum)==null?void 0:p.regular)==null?void 0:v.amount.value)===((U=(A=t==null?void 0:t.maximum)==null?void 0:A.regular)==null?void 0:U.amount.value)&&(x=(N=(I=t==null?void 0:t.minimum)==null?void 0:I.regular)==null?void 0:N.amount.value);const D=((F=(V=t==null?void 0:t.minimum)==null?void 0:V.final)==null?void 0:F.amount.currency)==="NONE"?"USD":(L=(G=t==null?void 0:t.minimum)==null?void 0:G.final)==null?void 0:L.amount.currency;return[x,g,w,D]}function l(){var p,v,A,U,I,N,V,F,G,L,W,Y,J;let g=0,w=0;s==null||s.forEach(b=>{var Z;const j=b==null?void 0:b.values;if(j&&Array.isArray(j)){const T=j.map(C=>{var M,$,R,ee;return(ee=(R=($=(M=C==null?void 0:C.product)==null?void 0:M.price)==null?void 0:$.regular)==null?void 0:R.amount)==null?void 0:ee.value}).filter(C=>C!==void 0),Q=T.length>0?Math.max(...T):0;g+=Q}(Z=b==null?void 0:b.values)==null||Z.forEach(T=>{var Q,C,M,$;a!=null&&a.includes(T.id)&&(w+=($=(M=(C=(Q=T==null?void 0:T.product)==null?void 0:Q.price)==null?void 0:C.final)==null?void 0:M.amount)==null?void 0:$.value)})});const x=(p=t==null?void 0:t.minimum)==null?void 0:p.final.amount.value,D=(v=t==null?void 0:t.maximum)==null?void 0:v.final.amount.value;let O;((U=(A=t==null?void 0:t.minimum)==null?void 0:A.regular)==null?void 0:U.amount.value)===((N=(I=t==null?void 0:t.maximum)==null?void 0:I.regular)==null?void 0:N.amount.value)&&(O=(F=(V=t==null?void 0:t.minimum)==null?void 0:V.regular)==null?void 0:F.amount.value);const S=((L=(G=t==null?void 0:t.minimum)==null?void 0:G.final)==null?void 0:L.amount.currency)==="NONE"?"USD":(Y=(W=t==null?void 0:t.minimum)==null?void 0:W.final)==null?void 0:Y.amount.currency;return n&&(a==null?void 0:a.length)<1?[O,x,D,S]:g===((J=t==null?void 0:t.maximum)==null?void 0:J.regular.amount.value)?[w,w,w,S]:[O,x,D,S]}const[c,f,d,h]=o==="SimpleProductView"?u():n?l():m(),y=o==="SimpleProductView"?(P=r==null?void 0:r.roles)==null?void 0:P.includes("visible"):((K=(k=t==null?void 0:t.maximum)==null?void 0:k.roles)==null?void 0:K.includes("visible"))&&((z=(B=t==null?void 0:t.minimum)==null?void 0:B.roles)==null?void 0:z.includes("visible"));return d&&f===d?{regular:{amount:c,currency:h,variant:c&&f!==c?"strikethrough":"default"},final:{amount:d,currency:h,variant:"default"},visible:y}:{final:{minimumAmount:f,maximumAmount:d,currency:h},visible:y}}function be(e,n,i){var r;return n?((r=e==null?void 0:e.options)==null?void 0:r.map(({values:s})=>{var u;const a=((u=s==null?void 0:s.find(({isDefault:m})=>m))==null?void 0:u.id)??null,o=i?s[0].id:null;return a||o})).filter(s=>s!==null):e==null?void 0:e.optionUIDs}const X=new ce({init:async e=>{var o,u,m;const n=(u=(o=e==null?void 0:e.models)==null?void 0:o.ProductDetails)==null?void 0:u.initialData,r=((m=(ie()||{}).optionsUIDs)==null?void 0:m.split(","))||(n==null?void 0:n.optionsUIDs),t=Pe(1),a={...{defaultLocale:"en-US",persistURLParams:!1,acdl:!1,optionsUIDs:r},...e};if(X.config.setConfig({...a}),a!=null&&a.sku){const l=n?q(n):await ne(a.sku,{preselectFirstOption:a.preselectFirstOption});E.emit("pdp/data",l,{scope:a.scope});const c={sku:a.sku,quantity:t,optionsUIDs:l==null?void 0:l.optionUIDs};Ve(()=>({...c}),{scope:a.scope}),Ge(()=>{var f;return l!=null&&l.options?l.options.length===((f=l==null?void 0:l.optionUIDs)==null?void 0:f.length):!0},{scope:a.scope}),a.acdl&&l&&ge(l)}},listeners:()=>[E.on("locale",async()=>{const{sku:e,scope:n}=X.config.getConfig();if(e){const i=await ne(e);E.emit("pdp/data",i,{scope:n})}})]}),_=X.config,{setEndpoint:Xe,setFetchGraphQlHeader:qe,removeFetchGraphQlHeader:Ke,setFetchGraphQlHeaders:Be,fetchGraphQl:oe,getConfig:ze}=new fe().getMethods(),_e=`
|
|
4
4
|
query GET_PRODUCT_DATA($skus: [String]) {
|
|
5
5
|
products(skus: $skus) {
|
|
6
6
|
...PRODUCT_FRAGMENT
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
${
|
|
11
|
-
`,
|
|
10
|
+
${re}
|
|
11
|
+
`,ke=async(e,n,i)=>{var s;const{data:r}=await oe(_e,{method:"GET",variables:{skus:[e]}}),t=(s=r==null?void 0:r.products)==null?void 0:s[0];return n!=null&&n.optionsUIDs&&(t.optionUIDs=n.optionsUIDs),t?i?t:q(t,{preselectFirstOption:n==null?void 0:n.preselectFirstOption}):null},pe=`
|
|
12
12
|
query REFINE_PRODUCT_QUERY(
|
|
13
13
|
$optionIds: [String!]!
|
|
14
14
|
$sku: String!
|
|
@@ -29,13 +29,13 @@ query REFINE_PRODUCT_QUERY(
|
|
|
29
29
|
# %extendedPlaceholder%
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
${
|
|
33
|
-
`;async function te(e,
|
|
34
|
-
ProductOption${
|
|
32
|
+
${re}
|
|
33
|
+
`;async function te(e,n){const i=Ae(n),r=Ue(i,e),t=pe.replace("# %extendedPlaceholder%",r),{data:s}=await oe(t,{method:"GET",variables:{optionIds:n,sku:e}});return s}const ve=async(e,n,i,r)=>{var d,h,y;const t=await te(e,n);if(!t)return null;let{products:s,refineProduct:a,...o}=t;const u=s==null?void 0:s[0],m=Ie(Object.values(o),u.options,i);if(i!=null&&i.length&&a===null){n=Ne(m,n,i);const P=await te(e,n);a=P==null?void 0:P.refineProduct}const l={...a||u,sku:u.sku,name:u.name,externalParentId:u==null?void 0:u.externalId,options:m,optionUIDs:n,variantSku:(a==null?void 0:a.__typename)==="SimpleProductView"?a==null?void 0:a.sku:void 0},c=r?l:q(l),f=(y=(h=(d=_==null?void 0:_.getConfig())==null?void 0:d.models)==null?void 0:h.ProductDetails)==null?void 0:y.fallbackData;return f?f(u,c):c};function Ae(e){if(e.length<2)return[e];const n=[];return e.forEach(i=>{const r=[];e.forEach(t=>{i!==t&&r.push(t)}),n.push(r)}),n}function Ue(e,n){return e.map((i,r)=>`
|
|
34
|
+
ProductOption${r}: refineProduct(
|
|
35
35
|
optionIds: [
|
|
36
|
-
${
|
|
36
|
+
${i.map(t=>`"${t}"`).join(", ")}
|
|
37
37
|
]
|
|
38
|
-
sku: "${
|
|
38
|
+
sku: "${n}"
|
|
39
39
|
) {
|
|
40
40
|
... on ComplexProductView {
|
|
41
41
|
options {
|
|
@@ -43,5 +43,5 @@ ${ie}
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
`).join("")}function Ie(e,
|
|
46
|
+
`).join("")}function Ie(e,n=[],i){const r=Object.values(e).filter(s=>!!s).reduce((s,a)=>a.options?[...s,...a.options]:[...s],[]),t=new Map(n.map(s=>[s.id,s]));return r.forEach(s=>{i!=null&&i.includes(s.id)||t.set(s.id,s)}),[...t.values()]}function Ne(e,n,i){const r=[];let t;return e.forEach(s=>{var a,o,u,m;i.includes(s.id)?t=((o=(a=s.values)==null?void 0:a.find(l=>n.includes(l==null?void 0:l.id)))==null?void 0:o.id)||((u=s.values[0])==null?void 0:u.id):t=(m=s.values[0])==null?void 0:m.id,r.push(t)}),r}const ne=async(e,n)=>{const{anchors:i,optionsUIDs:r}=_.getConfig(),{optionsUIDs:t=r,anchors:s=i,preselectFirstOption:a,isBundle:o,skipTransform:u}=n??{};return!o&&t?await ve(e,t,s,u):await ke(e,{preselectFirstOption:a,optionsUIDs:t},u)},Ve=(e,n)=>{const i=Fe({scope:n==null?void 0:n.scope}),r=e(i);E.emit("pdp/values",{...r},{scope:n==null?void 0:n.scope})},Fe=({scope:e}={})=>E.lastPayload("pdp/values",{scope:e})??null,Ge=(e,n)=>{const i=Le({scope:n==null?void 0:n.scope}),r=e(i);E.emit("pdp/valid",r,{scope:n==null?void 0:n.scope})},Le=({scope:e}={})=>E.lastPayload("pdp/valid",{scope:e})??null;export{qe as a,Be as b,_ as c,ke as d,ve as e,oe as f,ze as g,ne as h,X as i,Ve as j,Fe as k,Ge as l,Le as m,Pe as n,He as o,ge as p,Ke as r,Xe as s,q as t};
|
|
47
47
|
//# sourceMappingURL=isProductConfigurationValid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isProductConfigurationValid.js","sources":["/@dropins/storefront-pdp/src/lib/url-params.ts","/@dropins/storefront-pdp/src/data/transforms/acdl-context.ts","/@dropins/storefront-pdp/src/lib/acdl.ts","/@dropins/storefront-pdp/src/data/models/acdl-models.ts","/@dropins/storefront-pdp/src/data/transforms/product-transform.ts","/@dropins/storefront-pdp/src/api/initialize/initialize.ts","/@dropins/storefront-pdp/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-pdp/src/api/getProductData/graphql/getProductData.graphql.ts","/@dropins/storefront-pdp/src/api/getProductData/getProductData.ts","/@dropins/storefront-pdp/src/api/getRefinedProduct/graphql/RefineProductQuery.graphql.ts","/@dropins/storefront-pdp/src/api/getRefinedProduct/getRefinedProduct.ts","/@dropins/storefront-pdp/src/api/fetchProductData/fetchProductData.ts","/@dropins/storefront-pdp/src/api/setProductConfigurationValues/setProductConfigurationValues.ts","/@dropins/storefront-pdp/src/api/getProductConfigurationValues/getProductConfigurationValues.ts","/@dropins/storefront-pdp/src/api/setProductConfigurationValid/setProductConfigurationValid.ts","/@dropins/storefront-pdp/src/api/isProductConfigurationValid/isProductConfigurationValid.ts"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nexport function setUrlParams(\n params: Record<string, string | number | null>\n): void {\n const urlSearchParams = new URLSearchParams(window.location.search);\n\n Object.entries(params).forEach(([key, value]) => {\n if (value === null) {\n urlSearchParams.delete(key);\n } else {\n urlSearchParams.set(key, String(value));\n }\n });\n\n let url = window.location.pathname;\n url += `?${urlSearchParams.toString()}`;\n url += window.location.hash;\n\n window.history.replaceState({}, '', url);\n}\n\nexport function getUrlParams(): Record<string, string> {\n const urlSearchParams = new URLSearchParams(window.location.search);\n const params: Record<string, string> = {};\n\n urlSearchParams.forEach((value, key) => {\n params[key] = value;\n });\n\n return params;\n}\n\nexport function getValidatedQuantityFromUrl(\n defaultQuantity: number = 1\n): number {\n const urlParams = getUrlParams() || {};\n const quantityParam = urlParams.quantity; // 'quantity' is the key\n\n if (quantityParam) {\n const parsedQuantity = parseInt(quantityParam, 10);\n\n if (\n !isNaN(parsedQuantity) &&\n Number.isInteger(parsedQuantity) &&\n parsedQuantity > 0\n ) {\n // Return the valid quantity from the URL\n return parsedQuantity;\n }\n }\n\n // Return the default quantity if the parameter is missing, invalid, or not positive\n return defaultQuantity;\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { ProductModel } from '../models';\n\nimport { Product } from '../models/acdl-models';\n\nexport function transformProduct(product: ProductModel): Product {\n return {\n productId: Number(product?.externalId),\n name: product?.name,\n sku: product?.variantSku || product?.sku,\n topLevelSku: product?.sku,\n specialToDate: undefined,\n specialFromDate: undefined,\n newToDate: undefined,\n newFromDate: undefined,\n createdAt: undefined,\n updatedAt: undefined,\n manufacturer: undefined,\n countryOfManufacture: undefined,\n categories: undefined,\n productType: product?.productType,\n pricing: {\n regularPrice: product?.prices?.regular?.amount || 0,\n minimalPrice: product?.prices?.final?.minimumAmount,\n maximalPrice: product?.prices?.final?.maximumAmount,\n specialPrice: product?.prices?.final?.amount,\n tierPricing: undefined,\n currencyCode: product?.prices?.final?.currency || 'USD',\n },\n canonicalUrl: product?.url,\n mainImageUrl: product?.images?.[0]?.url,\n };\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\n/* Publish functions for the Adobe Client Data Layer (ACDL) */\n\nimport { ProductModel } from '../data/models';\nimport { transformProduct } from '../data/transforms/acdl-context';\n\n/**\n * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/contexts.ts\n */\nexport const contexts = {\n PRODUCT_CONTEXT: 'productContext',\n CHANNEL_CONTEXT: 'channelContext',\n};\n\n/**\n * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/events.ts\n */\nexport const events = {\n PRODUCT_PAGE_VIEW: 'product-page-view',\n};\n\nexport function getAdobeDataLayer() {\n // @ts-ignore\n window.adobeDataLayer = window.adobeDataLayer || [];\n // @ts-ignore\n return window.adobeDataLayer;\n}\n\nexport function getChannelContext() {\n return {\n _id: 'https://ns.adobe.com/xdm/channels/web',\n _type: 'https://ns.adobe.com/xdm/channel-types/web',\n };\n}\n\n/**\n * Sets a context in the Adobe Client Data Layer (ACDL)\n * Logic based on: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/Base.ts#L6\n */\nfunction setContext(name: string, data: any) {\n const adobeDataLayer = getAdobeDataLayer();\n\n // Clear existing context\n adobeDataLayer.push({\n [name]: null,\n });\n\n // Set new context\n adobeDataLayer.push({\n [name]: data,\n });\n}\n\nexport function setChannelContext() {\n if (typeof window === 'undefined') {\n return;\n }\n\n setContext(contexts.CHANNEL_CONTEXT, getChannelContext());\n}\n\n/**\n * Pushes an event to the Adobe Client Data Layer (ACDL)\n * Logic based on: https://github.com/adobe/commerce-events/blob/1973d0ce28471ef190fa06dad6359ffa0ab51db6/packages/storefront-events-sdk/src/Base.ts#L34\n */\nfunction pushEvent(event: string, additionalContext?: any) {\n const adobeDataLayer = getAdobeDataLayer();\n\n adobeDataLayer.push((acdl: any) => {\n const state = acdl.getState ? acdl.getState() : {};\n\n acdl.push({\n event,\n eventInfo: {\n ...state,\n ...additionalContext,\n },\n });\n });\n}\n\n// Triggered when a product page is viewed\nexport function publishProductPageViewEvent(product: ProductModel) {\n const productItem = transformProduct(product);\n setContext(contexts.PRODUCT_CONTEXT, productItem);\n setChannelContext();\n pushEvent(events.PRODUCT_PAGE_VIEW);\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\n/**\n * ACDL Product Types from:\n * https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/types/schemas/product.ts\n */\n\nexport type Product = {\n productId: number;\n name: string;\n sku: string;\n topLevelSku?: string | null;\n specialToDate?: string | null;\n specialFromDate?: string | null;\n newToDate?: string | null;\n newFromDate?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n manufacturer?: string | null;\n countryOfManufacture?: string | null;\n categories?: string[] | null;\n productType?: ProductType;\n pricing?: {\n regularPrice: number;\n minimalPrice?: number;\n maximalPrice?: number;\n specialPrice?: number;\n tierPricing?: {\n customerGroupId?: number | null;\n qty: number;\n value: number;\n }[];\n currencyCode: string | null;\n };\n canonicalUrl?: string | null;\n mainImageUrl?: string | null;\n};\n\nexport enum ProductType {\n ComplexProduct = 'complex',\n SimpleProduct = 'simple'\n}\n\nexport enum ProductViewType {\n ComplexProductView = 'ComplexProductView',\n SimpleProductView = 'SimpleProductView'\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { config } from '@/pdp/api';\nimport { ProductModel } from '@/pdp/data/models';\nimport { ProductType, ProductViewType } from '../models/acdl-models';\n\nexport function transformProductData(\n data: any,\n options?: {\n preselectFirstOption?: boolean;\n }\n): ProductModel | null {\n const isBundle =\n data?.options?.[0]?.values?.[0]?.__typename ===\n 'ProductViewOptionValueProduct';\n const optionUIDs = getOptionUIDs(\n data,\n isBundle,\n options?.preselectFirstOption\n );\n const productType =\n data?.__typename === ProductViewType.SimpleProductView\n ? ProductType.SimpleProduct\n : ProductType.ComplexProduct;\n\n const productData = data\n ? ({\n name: data.name,\n sku: data.sku,\n isBundle,\n addToCartAllowed: data.addToCartAllowed,\n inStock: data.inStock,\n shortDescription: data.shortDescription,\n metaDescription: data.metaDescription,\n metaKeyword: data.metaKeyword,\n metaTitle: data.metaTitle,\n description: data.description,\n images: transformImages(data),\n prices: transformPrices(data, isBundle, optionUIDs),\n attributes: transformAttributes(data),\n options: transformOptions(data, isBundle),\n optionUIDs,\n url: data.url,\n urlKey: data.urlKey,\n externalId: data.externalId,\n externalParentId: data.externalParentId,\n variantSku: data.variantSku,\n productType,\n } as ProductModel)\n : null;\n\n // extend the model with custom transformer\n return merge(\n productData,\n config.getConfig()?.models?.ProductDetails?.transformer?.(data) ??\n config.getConfig()?.models?.ProductDetails?.transform?.(data)\n );\n}\n\nfunction transformImages(data: any) {\n return data.images\n ?.filter((image: any) => !image.roles?.includes('hide_from_pdp'))\n ?.map((image: any) => {\n // Remove protocol from image URL\n image.url = image.url.replace(/^https?:/, '');\n\n return image;\n });\n}\n\nfunction transformAttributes(data: any) {\n return (\n data.attributes\n // only show attributes that are visible in PDP\n ?.filter(({ roles }: any) => roles?.indexOf('visible_in_pdp') !== -1)\n // transform attribute values\n ?.map(({ label, value, name }: any) => {\n return {\n id: name,\n label,\n value: value.toString().split(',').join(', '),\n };\n })\n );\n}\n\nfunction transformOptions(data: any, isBundle?: boolean) {\n const { options, optionUIDs } = data;\n\n return options?.map(({ id, title, required, multi, values }: any) => {\n const typename = values?.[0]?.__typename;\n let type: string = values?.[0].type;\n\n if (type) {\n type = type\n .replace('COLOR_HEX', 'color')\n .replace('TEXT', 'text')\n .replace('IMAGE', 'image');\n } else {\n type = 'dropdown';\n }\n\n return {\n id,\n type,\n typename,\n label: title,\n required,\n multiple: multi,\n items: isBundle\n ? mapBundleOptionValues(values, optionUIDs)\n : mapOptionValues(values, optionUIDs, type),\n };\n });\n}\n\nfunction mapBundleOptionValues(values: any, optionUIDs: string[]) {\n return values\n ?.filter(({ enabled }: any) => typeof enabled === 'undefined' || enabled)\n .map(({ id, title, inStock, isDefault, product }: any) => {\n return {\n id,\n inStock,\n label: title,\n selected: optionUIDs?.indexOf(id) > -1 || isDefault,\n value: id,\n product,\n };\n });\n}\n\nfunction mapOptionValues(values: any, optionUIDs: string[], type: string) {\n return values?.map(({ id, title, inStock, value }: any) => {\n return {\n id,\n inStock,\n label: title,\n selected: optionUIDs?.indexOf(id) > -1,\n value:\n type?.toLowerCase() === 'dropdown'\n ? id\n : value?.replace(/^https?:/, ''),\n };\n });\n}\n\nfunction transformPrices(\n data: any,\n isBundle: boolean,\n defaultOptionUIDs?: string[]\n) {\n const { price, priceRange, options, optionUIDs = defaultOptionUIDs } = data;\n let { __typename: type } = data;\n\n function getSimpleProductPrices() {\n const regularPrice = price?.regular.amount.value;\n const finalPrice =\n price?.final?.amount.value ?? price?.regular.amount.value;\n\n const currency =\n price?.regular.amount.currency === 'NONE' //temporary fix if there is no currency\n ? 'USD'\n : price?.regular.amount.currency;\n\n return [regularPrice, finalPrice, finalPrice, currency];\n }\n\n function getComplexProductPrices() {\n const finalMinimumPrice = priceRange?.minimum?.final.amount.value;\n const finalMaximumPrice = priceRange?.maximum?.final.amount.value;\n let regularPrice;\n\n if (\n priceRange?.minimum?.regular?.amount.value ===\n priceRange?.maximum?.regular?.amount.value\n ) {\n regularPrice = priceRange?.minimum?.regular?.amount.value;\n }\n\n const currency =\n priceRange?.minimum?.final?.amount.currency === 'NONE'\n ? 'USD'\n : priceRange?.minimum?.final?.amount.currency;\n\n return [regularPrice, finalMinimumPrice, finalMaximumPrice, currency];\n }\n\n function getBundleProductPrice() {\n // Currently the Catalog Service does not have support for the individual prices of the options of a fixed bundle,\n // so the price used in UI is taken from the priceRange object.\n\n // The dynamic bundle has full support in Catalog Service.\n // If there are pre-selected values of the option, then the starting price is the sum of those and\n // after each selection, the price is updated with the sum of prices for the selected options.\n // This is not supported by default and needs to be updated in the drop-in upon each selection.\n\n let maxSumRegular = 0;\n let bundlePrice = 0;\n options?.forEach((option: any) => {\n const values = option?.values;\n if (values && Array.isArray(values)) {\n const regularAmounts = values\n .map((value) => value?.product?.price?.regular?.amount?.value)\n .filter((amount) => amount !== undefined);\n\n const maxRegularAmount =\n regularAmounts.length > 0 ? Math.max(...regularAmounts) : 0;\n maxSumRegular += maxRegularAmount;\n }\n option?.values?.forEach((value: any) => {\n if (optionUIDs?.includes(value.id)) {\n bundlePrice += value?.product?.price?.final?.amount?.value;\n }\n });\n });\n\n const finalMinimumPrice = priceRange?.minimum?.final.amount.value;\n const finalMaximumPrice = priceRange?.maximum?.final.amount.value;\n let regularPrice;\n\n if (\n priceRange?.minimum?.regular?.amount.value ===\n priceRange?.maximum?.regular?.amount.value\n ) {\n regularPrice = priceRange?.minimum?.regular?.amount.value;\n }\n\n const currency =\n priceRange?.minimum?.final?.amount.currency === 'NONE'\n ? 'USD'\n : priceRange?.minimum?.final?.amount.currency;\n\n if (isBundle && optionUIDs?.length < 1) {\n return [regularPrice, finalMinimumPrice, finalMaximumPrice, currency];\n }\n\n return maxSumRegular === priceRange?.maximum?.regular.amount.value\n ? [bundlePrice, bundlePrice, bundlePrice, currency]\n : [regularPrice, finalMinimumPrice, finalMaximumPrice, currency];\n }\n\n const [regularPrice, finalMinimumPrice, finalMaximumPrice, currency] =\n type === 'SimpleProductView'\n ? getSimpleProductPrices()\n : isBundle\n ? getBundleProductPrice()\n : getComplexProductPrices();\n\n const visible =\n type === 'SimpleProductView'\n ? price?.roles?.includes('visible')\n : priceRange?.maximum?.roles?.includes('visible') &&\n priceRange?.minimum?.roles?.includes('visible');\n\n if (finalMaximumPrice && finalMinimumPrice === finalMaximumPrice) {\n const hasDiscount = regularPrice && finalMinimumPrice !== regularPrice;\n\n return {\n regular: {\n amount: regularPrice,\n currency,\n variant: hasDiscount ? 'strikethrough' : 'default',\n },\n final: {\n amount: finalMaximumPrice,\n currency,\n variant: 'default',\n },\n visible,\n };\n }\n\n return {\n final: {\n minimumAmount: finalMinimumPrice,\n maximumAmount: finalMaximumPrice,\n currency,\n },\n visible,\n };\n}\n\nfunction getOptionUIDs(\n data: any,\n isBundle?: boolean,\n preselectFirstOption?: boolean\n): string[] {\n if (isBundle) {\n const selections: Array<string | null> = data?.options?.map(\n ({ values }: any) => {\n const defaultSelection =\n values?.find(({ isDefault }: any) => isDefault)?.id ?? null;\n const preselectedFirstOption = preselectFirstOption\n ? values[0].id\n : null;\n return defaultSelection || preselectedFirstOption;\n }\n );\n\n return selections.filter((selection) => selection !== null) as string[];\n }\n\n return data?.optionUIDs;\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { ProductModel } from '@/pdp/data/models';\nimport {\n fetchProductData,\n setProductConfigurationValid,\n setProductConfigurationValues,\n} from '@/pdp/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport {\n getUrlParams,\n getValidatedQuantityFromUrl,\n} from '@/pdp/lib/url-params';\nimport { publishProductPageViewEvent } from '@/pdp/lib/acdl';\nimport { transformProductData } from '@/pdp/data/transforms/product-transform';\n\ntype ConfigProps = {\n langDefinitions?: Lang;\n defaultLocale?: string;\n sku?: string;\n acdl?: boolean;\n anchors?: string[];\n persistURLParams?: boolean;\n preselectFirstOption?: boolean;\n optionsUIDs?: string[];\n models?: {\n [name: string]: {\n initialData: any;\n /** @deprecated Use \"transformer\" instead */\n transform?: (data?: ProductModel) => ProductModel;\n transformer?: (data?: ProductModel) => ProductModel;\n fallbackData?: (\n parentProduct: any,\n simpleProduct: ProductModel\n ) => ProductModel;\n };\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (_config) => {\n const initialData = _config?.models?.ProductDetails?.initialData;\n\n // Get URL parameters safely\n const urlParams = getUrlParams() || {};\n\n // Get optionsUIDs from URL params or config\n const optionsUIDs =\n urlParams.optionsUIDs?.split(',') || initialData?.optionsUIDs;\n\n // Get and validate quantity from URL params\n const initialQuantity = getValidatedQuantityFromUrl(1); // Default quantity to 1 - Ensures backward compatibility\n\n // Set default config\n const defaultConfig: ConfigProps = {\n defaultLocale: 'en-US',\n persistURLParams: false,\n acdl: false,\n optionsUIDs,\n };\n\n const config = { ...defaultConfig, ..._config };\n\n initialize.config.setConfig({ ...config });\n\n if (config?.sku) {\n // Get PDP data\n const data = initialData\n ? transformProductData(initialData)\n : await fetchProductData(config.sku, {\n preselectFirstOption: config.preselectFirstOption,\n });\n\n // Emit PDP initial data\n events.emit('pdp/data', data);\n\n // Set default values for product configuration\n const defaultValues = {\n sku: config.sku,\n quantity: initialQuantity, // Use the determined quantity from URL params or default to 1\n optionsUIDs: data?.optionUIDs,\n };\n\n setProductConfigurationValues(() => ({ ...defaultValues }));\n\n setProductConfigurationValid(() => {\n // configurable product, check if all options are selected\n if (data?.options) {\n // all selections should be made\n return data.options.length === data?.optionUIDs?.length;\n }\n\n // simple product\n return true;\n });\n\n // Publish ACDL event\n if (config.acdl && data) {\n publishProductPageViewEvent(data);\n }\n }\n },\n\n listeners: () => [\n events.on('locale', async () => {\n const { sku } = initialize.config.getConfig();\n\n if (sku) {\n const next = await fetchProductData(sku);\n events.emit('pdp/data', next);\n }\n }),\n ],\n});\n\nexport const config = initialize.config;\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { PRODUCT_FRAGMENT } from '@/pdp/api/graphql/ProductFragment.graphql';\n\nexport const GET_PRODUCT_DATA = `\nquery GET_PRODUCT_DATA($skus: [String]) {\n products(skus: $skus) {\n ...PRODUCT_FRAGMENT\n }\n}\n\n${PRODUCT_FRAGMENT}\n`;\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { fetchGraphQl } from '@/pdp/api';\nimport { ProductModel } from '@/pdp/data/models';\nimport { transformProductData } from '@/pdp/data/transforms';\nimport { GET_PRODUCT_DATA } from './graphql/getProductData.graphql';\n\nexport const getProductData = async (\n sku: string,\n options?: {\n preselectFirstOption?: boolean;\n optionsUIDs?: string[];\n },\n raw?: boolean\n): Promise<ProductModel | null> => {\n const { data } = await fetchGraphQl(GET_PRODUCT_DATA, {\n method: 'GET',\n variables: { skus: [sku] },\n });\n\n const product = data?.products?.[0];\n\n // If optionsUIDs are provided, override the optionsUIDs from the response\n if (options?.optionsUIDs) {\n product.optionUIDs = options.optionsUIDs;\n }\n\n if (!product) {\n return null;\n }\n return raw\n ? product\n : transformProductData(product, {\n preselectFirstOption: options?.preselectFirstOption,\n });\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { PRODUCT_FRAGMENT } from '@/pdp/api/graphql/ProductFragment.graphql';\n\nexport const REFINE_PRODUCT_QUERY = `\nquery REFINE_PRODUCT_QUERY(\n $optionIds: [String!]!\n $sku: String!\n) {\n # Refined Product\n refineProduct(\n optionIds: $optionIds \n sku: $sku\n ) {\n ...PRODUCT_FRAGMENT\n }\n\n # Parent Product\n products(skus: [$sku]) {\n ...PRODUCT_FRAGMENT\n }\n\n # %extendedPlaceholder%\n}\n\n${PRODUCT_FRAGMENT}\n`;\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { fetchGraphQl, config } from '@/pdp/api';\nimport { ProductModel } from '@/pdp/data/models';\nimport { transformProductData } from '@/pdp/data/transforms';\nimport { REFINE_PRODUCT_QUERY } from './graphql/RefineProductQuery.graphql';\n\nasync function getProductData(sku: string, optionUIDs: string[]): Promise<any> {\n const optionPairCombinations = getPairCombination(optionUIDs);\n const optionQueries = getProductOptionQuery(optionPairCombinations, sku);\n\n const mergedQueries = REFINE_PRODUCT_QUERY.replace(\n '# %extendedPlaceholder%',\n optionQueries\n );\n\n const { data } = await fetchGraphQl(mergedQueries, {\n method: 'GET',\n variables: { optionIds: optionUIDs, sku },\n });\n return data;\n}\n\nexport const getRefinedProduct = async (\n sku: string,\n optionUIDs: string[],\n anchorOptions?: string[],\n raw?: boolean\n): Promise<ProductModel | null> => {\n const data = await getProductData(sku, optionUIDs);\n if (!data) return null;\n\n let { products, refineProduct, ...refinedOptions } = data;\n\n const parent = products?.[0];\n\n const options = mergeRefinedOptions(\n Object.values(refinedOptions),\n parent.options,\n anchorOptions\n );\n\n // needed when anchor options exist\n if (anchorOptions?.length && refineProduct === null) {\n optionUIDs = updateSelections(options, optionUIDs, anchorOptions);\n const updatedRefinedData = await getProductData(sku, optionUIDs);\n refineProduct = updatedRefinedData?.refineProduct;\n }\n\n const response = {\n ...(refineProduct || parent),\n sku: parent.sku,\n name: parent.name,\n externalParentId: parent?.externalId,\n options,\n optionUIDs,\n variantSku:\n refineProduct?.__typename === 'SimpleProductView'\n ? refineProduct?.sku\n : undefined,\n };\n\n const refinedData = raw ? response : transformProductData(response);\n\n const fallback = config?.getConfig()?.models?.ProductDetails?.fallbackData;\n\n if (fallback) {\n return fallback(parent, refinedData!);\n }\n\n return refinedData;\n};\n\nfunction getPairCombination(arr: string[]): string[][] {\n if (arr.length < 2) {\n return [arr];\n }\n\n const result: string[][] = [];\n\n arr.forEach((item) => {\n const temp: string[] = [];\n\n arr.forEach((item2) => {\n if (item !== item2) {\n temp.push(item2);\n }\n });\n\n result.push(temp);\n });\n\n return result;\n}\n\nfunction getProductOptionQuery(optionUIDs: string[][], sku: string): string {\n return optionUIDs\n .map((ids: string[], i: number) => {\n return `\n ProductOption${i}: refineProduct(\n optionIds: [\n ${ids.map((id) => `\"${id}\"`).join(', ')}\n ]\n sku: \"${sku}\"\n ) {\n ... on ComplexProductView {\n options {\n ...PRODUCT_OPTION_FRAGMENT\n }\n }\n }\n `;\n })\n .join('');\n}\n\nfunction mergeRefinedOptions(\n options: {},\n parent: [] = [],\n anchorOptions?: string[]\n) {\n // flat _refined[].options[] to _refinedOptions[]\n const refinedOptions: any = Object.values(options)\n .filter((x) => !!x)\n .reduce((acc: any, curr: any) => {\n if (!curr.options) return [...acc];\n\n return [...acc, ...curr.options];\n }, []);\n\n // Create a map to store items by their id from original\n const map = new Map(parent.map((item: any) => [item.id, item]));\n\n // Iterate through refinedOptions and merge items\n refinedOptions.forEach((current: any) => {\n // anchor options should display all values, so no merge is performed\n if (anchorOptions?.includes(current.id)) {\n return;\n }\n\n map.set(current.id, current);\n });\n\n return [...map.values()];\n}\n\nfunction updateSelections(\n options: any[],\n optionsUIDs: string[],\n anchorOptions: string[]\n): string[] {\n const updatedOptionsUIDs: string[] = [];\n\n let optionValue: string;\n options.forEach((option: any) => {\n if (anchorOptions.includes(option.id)) {\n optionValue =\n option.values?.find((value: any) => optionsUIDs.includes(value?.id))\n ?.id || option.values[0]?.id;\n } else {\n optionValue = option.values[0]?.id; // TODO check if we should use default value instead\n }\n updatedOptionsUIDs.push(optionValue);\n });\n return updatedOptionsUIDs;\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { getProductData, getRefinedProduct, config } from '@/pdp/api';\n\nexport type Options = {\n anchors?: string[];\n optionsUIDs?: string[];\n preselectFirstOption?: boolean;\n isBundle?: boolean;\n skipTransform?: boolean;\n};\n\nexport const fetchProductData = async (sku: string, options?: Options) => {\n // Get the default configuration values\n const { anchors: defaultAnchors, optionsUIDs: defaultOptionsUIDs } =\n config.getConfig();\n\n // Destructure the options object\n const {\n optionsUIDs = defaultOptionsUIDs,\n anchors = defaultAnchors,\n preselectFirstOption,\n isBundle,\n skipTransform,\n } = options ?? {};\n\n // ❗️ Warning ❗️\n // If we have default selections, but we cannot determine that the product is of type bundle, then the response is going to result in null objects and error(s).\n // Only the `products` object will be populated correctly, the `ProductOption${i}` and `refinedProduct` will be set as null.\n // This does not affect the UI, but the error message(s) can be detected by 3rd party tools that the client might be using.\n // This is accepted as a known behaviour, since a bundle product does not have variants.\n // However, if initialData is passed from the integration layer, then we can determine if the product is a bundle and set the isBundle flag accordingly.\n return !isBundle && optionsUIDs\n ? await getRefinedProduct(sku, optionsUIDs, anchors, skipTransform)\n : await getProductData(\n sku,\n {\n preselectFirstOption,\n optionsUIDs,\n },\n skipTransform\n );\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { ValuesModel } from '@/pdp/data/models';\nimport { getProductConfigurationValues } from '@/pdp/api';\n\nexport const setProductConfigurationValues = (\n callback: (prev: ValuesModel) => ValuesModel\n) => {\n const prev = getProductConfigurationValues();\n\n const next = callback(prev as ValuesModel);\n\n events.emit('pdp/values', { ...next });\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { ValuesModel } from '@/pdp/data/models';\n\nexport const getProductConfigurationValues = (): ValuesModel | null => {\n return events._lastEvent['pdp/values']?.payload ?? null;\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { isProductConfigurationValid } from '@/pdp/api';\n\nexport const setProductConfigurationValid = (\n callback: (prev: boolean) => boolean\n) => {\n const prev = isProductConfigurationValid();\n\n const next = callback(prev as boolean);\n\n events.emit('pdp/valid', next);\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const isProductConfigurationValid = (): boolean | null => {\n return events._lastEvent['pdp/valid']?.payload ?? null;\n};\n"],"names":["setUrlParams","params","urlSearchParams","key","value","url","getUrlParams","getValidatedQuantityFromUrl","defaultQuantity","quantityParam","parsedQuantity","transformProduct","product","_b","_a","_d","_c","_f","_e","_h","_g","_j","_i","_l","_k","contexts","events","getAdobeDataLayer","getChannelContext","setContext","name","data","adobeDataLayer","setChannelContext","pushEvent","event","additionalContext","acdl","state","publishProductPageViewEvent","productItem","ProductType","ProductViewType","transformProductData","options","isBundle","optionUIDs","getOptionUIDs","productType","productData","transformImages","transformPrices","transformAttributes","transformOptions","merge","config","image","roles","label","id","title","required","multi","values","typename","type","mapBundleOptionValues","mapOptionValues","enabled","inStock","isDefault","defaultOptionUIDs","price","priceRange","getSimpleProductPrices","regularPrice","finalPrice","currency","getComplexProductPrices","finalMinimumPrice","finalMaximumPrice","getBundleProductPrice","maxSumRegular","bundlePrice","option","regularAmounts","amount","maxRegularAmount","_m","visible","preselectFirstOption","defaultSelection","preselectedFirstOption","selection","initialize","Initializer","_config","initialData","optionsUIDs","initialQuantity","fetchProductData","defaultValues","setProductConfigurationValues","setProductConfigurationValid","sku","next","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","GET_PRODUCT_DATA","PRODUCT_FRAGMENT","getProductData","raw","REFINE_PRODUCT_QUERY","optionPairCombinations","getPairCombination","optionQueries","getProductOptionQuery","mergedQueries","getRefinedProduct","anchorOptions","products","refineProduct","refinedOptions","parent","mergeRefinedOptions","updateSelections","updatedRefinedData","response","refinedData","fallback","arr","result","item","temp","item2","ids","i","x","acc","curr","map","current","updatedOptionsUIDs","optionValue","defaultAnchors","defaultOptionsUIDs","anchors","skipTransform","callback","prev","getProductConfigurationValues","isProductConfigurationValid"],"mappings":"0OAgBO,SAASA,GACdC,EACM,CACN,MAAMC,EAAkB,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAE3D,OAAA,QAAQD,CAAM,EAAE,QAAQ,CAAC,CAACE,EAAKC,CAAK,IAAM,CAC3CA,IAAU,KACZF,EAAgB,OAAOC,CAAG,EAE1BD,EAAgB,IAAIC,EAAK,OAAOC,CAAK,CAAC,CACxC,CACD,EAEG,IAAAC,EAAM,OAAO,SAAS,SACnBA,GAAA,IAAIH,EAAgB,SAAU,CAAA,GACrCG,GAAO,OAAO,SAAS,KAEvB,OAAO,QAAQ,aAAa,CAAA,EAAI,GAAIA,CAAG,CACzC,CAEO,SAASC,IAAuC,CACrD,MAAMJ,EAAkB,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAC5DD,EAAiC,CAAC,EAExB,OAAAC,EAAA,QAAQ,CAACE,EAAOD,IAAQ,CACtCF,EAAOE,CAAG,EAAIC,CAAA,CACf,EAEMH,CACT,CAEgB,SAAAM,GACdC,EAA0B,EAClB,CAER,MAAMC,GADYH,GAAa,GAAK,CAAC,GACL,SAEhC,GAAIG,EAAe,CACX,MAAAC,EAAiB,SAASD,EAAe,EAAE,EAG/C,GAAA,CAAC,MAAMC,CAAc,GACrB,OAAO,UAAUA,CAAc,GAC/BA,EAAiB,EAGV,OAAAA,CACT,CAIK,OAAAF,CACT,CChDO,SAASG,GAAiBC,EAAgC,6BACxD,MAAA,CACL,UAAW,OAAOA,GAAA,YAAAA,EAAS,UAAU,EACrC,KAAMA,GAAA,YAAAA,EAAS,KACf,KAAKA,GAAA,YAAAA,EAAS,cAAcA,GAAA,YAAAA,EAAS,KACrC,YAAaA,GAAA,YAAAA,EAAS,IACtB,cAAe,OACf,gBAAiB,OACjB,UAAW,OACX,YAAa,OACb,UAAW,OACX,UAAW,OACX,aAAc,OACd,qBAAsB,OACtB,WAAY,OACZ,YAAaA,GAAA,YAAA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ElCoI,EAAmB,KAAKC,CAAW,CAAA,CACpC,EACMD,CACT,CCzJa,MAAA/C,GAAmB,MAAOI,EAAa5D,IAAsB,CAExE,KAAM,CAAE,QAASyG,EAAgB,YAAaC,CAAmB,EAC/D/F,EAAO,UAAU,EAGb,CACJ,YAAA2C,EAAcoD,EACd,QAAAC,EAAUF,EACV,qBAAA3D,EACA,SAAA7C,EACA,cAAA2G,CACF,EAAI5G,GAAW,CAAC,EAQT,MAAA,CAACC,GAAYqD,EAChB,MAAMyB,GAAkBnB,EAAKN,EAAaqD,EAASC,CAAa,EAChE,MAAMrC,GACJX,EACA,CACE,qBAAAd,EACA,YAAAQ,CACF,EACAsD,CACF,CACN,ECpCalD,GACXmD,GACG,CACH,MAAMC,EAAOC,GAA8B,EAErClD,EAAOgD,EAASC,CAAmB,EAEzChI,EAAO,KAAK,aAAc,CAAE,GAAG+E,EAAM,CACvC,ECTakD,GAAiC,IAA0B,OACtE,QAAOjI,EAAAA,EAAO,WAAW,YAAY,IAA9BA,YAAAA,EAAiC,UAAW,IACrD,ECFa6E,GACXkD,GACG,CACH,MAAMC,EAAOE,GAA4B,EAEnCnD,EAAOgD,EAASC,CAAe,EAE9BhI,EAAA,KAAK,YAAa+E,CAAI,CAC/B,ECTamD,GAA8B,IAAsB,OAC/D,QAAOlI,EAAAA,EAAO,WAAW,WAAW,IAA7BA,YAAAA,EAAgC,UAAW,IACpD"}
|
|
1
|
+
{"version":3,"file":"isProductConfigurationValid.js","sources":["/@dropins/storefront-pdp/src/lib/url-params.ts","/@dropins/storefront-pdp/src/data/transforms/acdl-context.ts","/@dropins/storefront-pdp/src/lib/acdl.ts","/@dropins/storefront-pdp/src/data/models/acdl-models.ts","/@dropins/storefront-pdp/src/data/transforms/product-transform.ts","/@dropins/storefront-pdp/src/api/initialize/initialize.ts","/@dropins/storefront-pdp/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-pdp/src/api/getProductData/graphql/getProductData.graphql.ts","/@dropins/storefront-pdp/src/api/getProductData/getProductData.ts","/@dropins/storefront-pdp/src/api/getRefinedProduct/graphql/RefineProductQuery.graphql.ts","/@dropins/storefront-pdp/src/api/getRefinedProduct/getRefinedProduct.ts","/@dropins/storefront-pdp/src/api/fetchProductData/fetchProductData.ts","/@dropins/storefront-pdp/src/api/setProductConfigurationValues/setProductConfigurationValues.ts","/@dropins/storefront-pdp/src/api/getProductConfigurationValues/getProductConfigurationValues.ts","/@dropins/storefront-pdp/src/api/setProductConfigurationValid/setProductConfigurationValid.ts","/@dropins/storefront-pdp/src/api/isProductConfigurationValid/isProductConfigurationValid.ts"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nexport function setUrlParams(\n params: Record<string, string | number | null>\n): void {\n const urlSearchParams = new URLSearchParams(window.location.search);\n\n Object.entries(params).forEach(([key, value]) => {\n if (value === null) {\n urlSearchParams.delete(key);\n } else {\n urlSearchParams.set(key, String(value));\n }\n });\n\n let url = window.location.pathname;\n url += `?${urlSearchParams.toString()}`;\n url += window.location.hash;\n\n window.history.replaceState({}, '', url);\n}\n\nexport function getUrlParams(): Record<string, string> {\n const urlSearchParams = new URLSearchParams(window.location.search);\n const params: Record<string, string> = {};\n\n urlSearchParams.forEach((value, key) => {\n params[key] = value;\n });\n\n return params;\n}\n\nexport function getValidatedQuantityFromUrl(\n defaultQuantity: number = 1\n): number {\n const urlParams = getUrlParams() || {};\n const quantityParam = urlParams.quantity; // 'quantity' is the key\n\n if (quantityParam) {\n const parsedQuantity = parseInt(quantityParam, 10);\n\n if (\n !isNaN(parsedQuantity) &&\n Number.isInteger(parsedQuantity) &&\n parsedQuantity > 0\n ) {\n // Return the valid quantity from the URL\n return parsedQuantity;\n }\n }\n\n // Return the default quantity if the parameter is missing, invalid, or not positive\n return defaultQuantity;\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { ProductModel } from '../models';\n\nimport { Product } from '../models/acdl-models';\n\nexport function transformProduct(product: ProductModel): Product {\n return {\n productId: Number(product?.externalId),\n name: product?.name,\n sku: product?.variantSku || product?.sku,\n topLevelSku: product?.sku,\n specialToDate: undefined,\n specialFromDate: undefined,\n newToDate: undefined,\n newFromDate: undefined,\n createdAt: undefined,\n updatedAt: undefined,\n manufacturer: undefined,\n countryOfManufacture: undefined,\n categories: undefined,\n productType: product?.productType,\n pricing: {\n regularPrice: product?.prices?.regular?.amount || 0,\n minimalPrice: product?.prices?.final?.minimumAmount,\n maximalPrice: product?.prices?.final?.maximumAmount,\n specialPrice: product?.prices?.final?.amount,\n tierPricing: undefined,\n currencyCode: product?.prices?.final?.currency || 'USD',\n },\n canonicalUrl: product?.url,\n mainImageUrl: product?.images?.[0]?.url,\n };\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\n/* Publish functions for the Adobe Client Data Layer (ACDL) */\n\nimport { ProductModel } from '../data/models';\nimport { transformProduct } from '../data/transforms/acdl-context';\n\n/**\n * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/contexts.ts\n */\nexport const contexts = {\n PRODUCT_CONTEXT: 'productContext',\n CHANNEL_CONTEXT: 'channelContext',\n};\n\n/**\n * See: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/events.ts\n */\nexport const events = {\n PRODUCT_PAGE_VIEW: 'product-page-view',\n};\n\nexport function getAdobeDataLayer() {\n // @ts-ignore\n window.adobeDataLayer = window.adobeDataLayer || [];\n // @ts-ignore\n return window.adobeDataLayer;\n}\n\nexport function getChannelContext() {\n return {\n _id: 'https://ns.adobe.com/xdm/channels/web',\n _type: 'https://ns.adobe.com/xdm/channel-types/web',\n };\n}\n\n/**\n * Sets a context in the Adobe Client Data Layer (ACDL)\n * Logic based on: https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/Base.ts#L6\n */\nfunction setContext(name: string, data: any) {\n const adobeDataLayer = getAdobeDataLayer();\n\n // Clear existing context\n adobeDataLayer.push({\n [name]: null,\n });\n\n // Set new context\n adobeDataLayer.push({\n [name]: data,\n });\n}\n\nexport function setChannelContext() {\n if (typeof window === 'undefined') {\n return;\n }\n\n setContext(contexts.CHANNEL_CONTEXT, getChannelContext());\n}\n\n/**\n * Pushes an event to the Adobe Client Data Layer (ACDL)\n * Logic based on: https://github.com/adobe/commerce-events/blob/1973d0ce28471ef190fa06dad6359ffa0ab51db6/packages/storefront-events-sdk/src/Base.ts#L34\n */\nfunction pushEvent(event: string, additionalContext?: any) {\n const adobeDataLayer = getAdobeDataLayer();\n\n adobeDataLayer.push((acdl: any) => {\n const state = acdl.getState ? acdl.getState() : {};\n\n acdl.push({\n event,\n eventInfo: {\n ...state,\n ...additionalContext,\n },\n });\n });\n}\n\n// Triggered when a product page is viewed\nexport function publishProductPageViewEvent(product: ProductModel) {\n const productItem = transformProduct(product);\n setContext(contexts.PRODUCT_CONTEXT, productItem);\n setChannelContext();\n pushEvent(events.PRODUCT_PAGE_VIEW);\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\n/**\n * ACDL Product Types from:\n * https://github.com/adobe/commerce-events/blob/main/packages/storefront-events-sdk/src/types/schemas/product.ts\n */\n\nexport type Product = {\n productId: number;\n name: string;\n sku: string;\n topLevelSku?: string | null;\n specialToDate?: string | null;\n specialFromDate?: string | null;\n newToDate?: string | null;\n newFromDate?: string | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n manufacturer?: string | null;\n countryOfManufacture?: string | null;\n categories?: string[] | null;\n productType?: ProductType;\n pricing?: {\n regularPrice: number;\n minimalPrice?: number;\n maximalPrice?: number;\n specialPrice?: number;\n tierPricing?: {\n customerGroupId?: number | null;\n qty: number;\n value: number;\n }[];\n currencyCode: string | null;\n };\n canonicalUrl?: string | null;\n mainImageUrl?: string | null;\n};\n\nexport enum ProductType {\n ComplexProduct = 'complex',\n SimpleProduct = 'simple'\n}\n\nexport enum ProductViewType {\n ComplexProductView = 'ComplexProductView',\n SimpleProductView = 'SimpleProductView'\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { config } from '@/pdp/api';\nimport { ProductModel } from '@/pdp/data/models';\nimport { ProductType, ProductViewType } from '../models/acdl-models';\n\nexport function transformProductData(\n data: any,\n options?: {\n preselectFirstOption?: boolean;\n }\n): ProductModel | null {\n const isBundle =\n data?.options?.[0]?.values?.[0]?.__typename ===\n 'ProductViewOptionValueProduct';\n const optionUIDs = getOptionUIDs(\n data,\n isBundle,\n options?.preselectFirstOption\n );\n const productType =\n data?.__typename === ProductViewType.SimpleProductView\n ? ProductType.SimpleProduct\n : ProductType.ComplexProduct;\n\n const productData = data\n ? ({\n name: data.name,\n sku: data.sku,\n isBundle,\n addToCartAllowed: data.addToCartAllowed,\n inStock: data.inStock,\n shortDescription: data.shortDescription,\n metaDescription: data.metaDescription,\n metaKeyword: data.metaKeyword,\n metaTitle: data.metaTitle,\n description: data.description,\n images: transformImages(data),\n prices: transformPrices(data, isBundle, optionUIDs),\n attributes: transformAttributes(data),\n options: transformOptions(data, isBundle),\n optionUIDs,\n url: data.url,\n urlKey: data.urlKey,\n externalId: data.externalId,\n externalParentId: data.externalParentId,\n variantSku: data.variantSku,\n productType,\n } as ProductModel)\n : null;\n\n // extend the model with custom transformer\n return merge(\n productData,\n config.getConfig()?.models?.ProductDetails?.transformer?.(data) ??\n config.getConfig()?.models?.ProductDetails?.transform?.(data)\n );\n}\n\nfunction transformImages(data: any) {\n return data.images\n ?.filter((image: any) => !image.roles?.includes('hide_from_pdp'))\n ?.map((image: any) => {\n // Remove protocol from image URL\n image.url = image.url.replace(/^https?:/, '');\n\n return image;\n });\n}\n\nfunction transformAttributes(data: any) {\n return (\n data.attributes\n // only show attributes that are visible in PDP\n ?.filter(({ roles }: any) => roles?.indexOf('visible_in_pdp') !== -1)\n // transform attribute values\n ?.map(({ label, value, name }: any) => {\n return {\n id: name,\n label,\n value: value.toString().split(',').join(', '),\n };\n })\n );\n}\n\nfunction transformOptions(data: any, isBundle?: boolean) {\n const { options, optionUIDs } = data;\n\n return options?.map(({ id, title, required, multi, values }: any) => {\n const typename = values?.[0]?.__typename;\n let type: string = values?.[0].type;\n\n if (type) {\n type = type\n .replace('COLOR_HEX', 'color')\n .replace('TEXT', 'text')\n .replace('IMAGE', 'image');\n } else {\n type = 'dropdown';\n }\n\n return {\n id,\n type,\n typename,\n label: title,\n required,\n multiple: multi,\n items: isBundle\n ? mapBundleOptionValues(values, optionUIDs)\n : mapOptionValues(values, optionUIDs, type),\n };\n });\n}\n\nfunction mapBundleOptionValues(values: any, optionUIDs: string[]) {\n return values\n ?.filter(({ enabled }: any) => typeof enabled === 'undefined' || enabled)\n .map(({ id, title, inStock, isDefault, product }: any) => {\n return {\n id,\n inStock,\n label: title,\n selected: optionUIDs?.indexOf(id) > -1 || isDefault,\n value: id,\n product,\n };\n });\n}\n\nfunction mapOptionValues(values: any, optionUIDs: string[], type: string) {\n return values?.map(({ id, title, inStock, value }: any) => {\n return {\n id,\n inStock,\n label: title,\n selected: optionUIDs?.indexOf(id) > -1,\n value:\n type?.toLowerCase() === 'dropdown'\n ? id\n : value?.replace(/^https?:/, ''),\n };\n });\n}\n\nfunction transformPrices(\n data: any,\n isBundle: boolean,\n defaultOptionUIDs?: string[]\n) {\n const { price, priceRange, options, optionUIDs = defaultOptionUIDs } = data;\n let { __typename: type } = data;\n\n function getSimpleProductPrices() {\n const regularPrice = price?.regular.amount.value;\n const finalPrice =\n price?.final?.amount.value ?? price?.regular.amount.value;\n\n const currency =\n price?.regular.amount.currency === 'NONE' //temporary fix if there is no currency\n ? 'USD'\n : price?.regular.amount.currency;\n\n return [regularPrice, finalPrice, finalPrice, currency];\n }\n\n function getComplexProductPrices() {\n const finalMinimumPrice = priceRange?.minimum?.final.amount.value;\n const finalMaximumPrice = priceRange?.maximum?.final.amount.value;\n let regularPrice;\n\n if (\n priceRange?.minimum?.regular?.amount.value ===\n priceRange?.maximum?.regular?.amount.value\n ) {\n regularPrice = priceRange?.minimum?.regular?.amount.value;\n }\n\n const currency =\n priceRange?.minimum?.final?.amount.currency === 'NONE'\n ? 'USD'\n : priceRange?.minimum?.final?.amount.currency;\n\n return [regularPrice, finalMinimumPrice, finalMaximumPrice, currency];\n }\n\n function getBundleProductPrice() {\n // Currently the Catalog Service does not have support for the individual prices of the options of a fixed bundle,\n // so the price used in UI is taken from the priceRange object.\n\n // The dynamic bundle has full support in Catalog Service.\n // If there are pre-selected values of the option, then the starting price is the sum of those and\n // after each selection, the price is updated with the sum of prices for the selected options.\n // This is not supported by default and needs to be updated in the drop-in upon each selection.\n\n let maxSumRegular = 0;\n let bundlePrice = 0;\n options?.forEach((option: any) => {\n const values = option?.values;\n if (values && Array.isArray(values)) {\n const regularAmounts = values\n .map((value) => value?.product?.price?.regular?.amount?.value)\n .filter((amount) => amount !== undefined);\n\n const maxRegularAmount =\n regularAmounts.length > 0 ? Math.max(...regularAmounts) : 0;\n maxSumRegular += maxRegularAmount;\n }\n option?.values?.forEach((value: any) => {\n if (optionUIDs?.includes(value.id)) {\n bundlePrice += value?.product?.price?.final?.amount?.value;\n }\n });\n });\n\n const finalMinimumPrice = priceRange?.minimum?.final.amount.value;\n const finalMaximumPrice = priceRange?.maximum?.final.amount.value;\n let regularPrice;\n\n if (\n priceRange?.minimum?.regular?.amount.value ===\n priceRange?.maximum?.regular?.amount.value\n ) {\n regularPrice = priceRange?.minimum?.regular?.amount.value;\n }\n\n const currency =\n priceRange?.minimum?.final?.amount.currency === 'NONE'\n ? 'USD'\n : priceRange?.minimum?.final?.amount.currency;\n\n if (isBundle && optionUIDs?.length < 1) {\n return [regularPrice, finalMinimumPrice, finalMaximumPrice, currency];\n }\n\n return maxSumRegular === priceRange?.maximum?.regular.amount.value\n ? [bundlePrice, bundlePrice, bundlePrice, currency]\n : [regularPrice, finalMinimumPrice, finalMaximumPrice, currency];\n }\n\n const [regularPrice, finalMinimumPrice, finalMaximumPrice, currency] =\n type === 'SimpleProductView'\n ? getSimpleProductPrices()\n : isBundle\n ? getBundleProductPrice()\n : getComplexProductPrices();\n\n const visible =\n type === 'SimpleProductView'\n ? price?.roles?.includes('visible')\n : priceRange?.maximum?.roles?.includes('visible') &&\n priceRange?.minimum?.roles?.includes('visible');\n\n if (finalMaximumPrice && finalMinimumPrice === finalMaximumPrice) {\n const hasDiscount = regularPrice && finalMinimumPrice !== regularPrice;\n\n return {\n regular: {\n amount: regularPrice,\n currency,\n variant: hasDiscount ? 'strikethrough' : 'default',\n },\n final: {\n amount: finalMaximumPrice,\n currency,\n variant: 'default',\n },\n visible,\n };\n }\n\n return {\n final: {\n minimumAmount: finalMinimumPrice,\n maximumAmount: finalMaximumPrice,\n currency,\n },\n visible,\n };\n}\n\nfunction getOptionUIDs(\n data: any,\n isBundle?: boolean,\n preselectFirstOption?: boolean\n): string[] {\n if (isBundle) {\n const selections: Array<string | null> = data?.options?.map(\n ({ values }: any) => {\n const defaultSelection =\n values?.find(({ isDefault }: any) => isDefault)?.id ?? null;\n const preselectedFirstOption = preselectFirstOption\n ? values[0].id\n : null;\n return defaultSelection || preselectedFirstOption;\n }\n );\n\n return selections.filter((selection) => selection !== null) as string[];\n }\n\n return data?.optionUIDs;\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { Initializer } from '@adobe-commerce/elsie/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { ProductModel } from '@/pdp/data/models';\nimport {\n fetchProductData,\n setProductConfigurationValid,\n setProductConfigurationValues,\n} from '@/pdp/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport {\n getUrlParams,\n getValidatedQuantityFromUrl,\n} from '@/pdp/lib/url-params';\nimport { publishProductPageViewEvent } from '@/pdp/lib/acdl';\nimport { transformProductData } from '@/pdp/data/transforms/product-transform';\n\ntype ConfigProps = {\n scope?: string;\n langDefinitions?: Lang;\n defaultLocale?: string;\n sku?: string;\n acdl?: boolean;\n anchors?: string[];\n persistURLParams?: boolean;\n preselectFirstOption?: boolean;\n optionsUIDs?: string[];\n models?: {\n [name: string]: {\n initialData: any;\n /** @deprecated Use \"transformer\" instead */\n transform?: (data?: ProductModel) => ProductModel;\n transformer?: (data?: ProductModel) => ProductModel;\n fallbackData?: (\n parentProduct: any,\n simpleProduct: ProductModel\n ) => ProductModel;\n };\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (_config) => {\n const initialData = _config?.models?.ProductDetails?.initialData;\n\n // Get URL parameters safely\n const urlParams = getUrlParams() || {};\n\n // Get optionsUIDs from URL params or config\n const optionsUIDs =\n urlParams.optionsUIDs?.split(',') || initialData?.optionsUIDs;\n\n // Get and validate quantity from URL params\n const initialQuantity = getValidatedQuantityFromUrl(1); // Default quantity to 1 - Ensures backward compatibility\n\n // Set default config\n const defaultConfig: ConfigProps = {\n defaultLocale: 'en-US',\n persistURLParams: false,\n acdl: false,\n optionsUIDs,\n };\n\n const config = { ...defaultConfig, ..._config };\n\n initialize.config.setConfig({ ...config });\n\n if (config?.sku) {\n // Get PDP data\n const data = initialData\n ? transformProductData(initialData)\n : await fetchProductData(config.sku, {\n preselectFirstOption: config.preselectFirstOption,\n });\n\n // Emit PDP initial data\n events.emit('pdp/data', data, { scope: config.scope });\n\n // Set default values for product configuration\n const defaultValues = {\n sku: config.sku,\n quantity: initialQuantity, // Use the determined quantity from URL params or default to 1\n optionsUIDs: data?.optionUIDs,\n };\n\n setProductConfigurationValues(() => ({ ...defaultValues }), {\n scope: config.scope,\n });\n\n setProductConfigurationValid(\n () => {\n // configurable product, check if all options are selected\n if (data?.options) {\n // all selections should be made\n return data.options.length === data?.optionUIDs?.length;\n }\n\n // simple product\n return true;\n },\n { scope: config.scope }\n );\n\n // Publish ACDL event\n if (config.acdl && data) {\n publishProductPageViewEvent(data);\n }\n }\n },\n\n listeners: () => [\n events.on('locale', async () => {\n const { sku, scope } = initialize.config.getConfig();\n\n if (sku) {\n const next = await fetchProductData(sku);\n events.emit('pdp/data', next, { scope });\n }\n }),\n ],\n});\n\nexport const config = initialize.config;\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { PRODUCT_FRAGMENT } from '@/pdp/api/graphql/ProductFragment.graphql';\n\nexport const GET_PRODUCT_DATA = `\nquery GET_PRODUCT_DATA($skus: [String]) {\n products(skus: $skus) {\n ...PRODUCT_FRAGMENT\n }\n}\n\n${PRODUCT_FRAGMENT}\n`;\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { fetchGraphQl } from '@/pdp/api';\nimport { ProductModel } from '@/pdp/data/models';\nimport { transformProductData } from '@/pdp/data/transforms';\nimport { GET_PRODUCT_DATA } from './graphql/getProductData.graphql';\n\nexport const getProductData = async (\n sku: string,\n options?: {\n preselectFirstOption?: boolean;\n optionsUIDs?: string[];\n },\n raw?: boolean\n): Promise<ProductModel | null> => {\n const { data } = await fetchGraphQl(GET_PRODUCT_DATA, {\n method: 'GET',\n variables: { skus: [sku] },\n });\n\n const product = data?.products?.[0];\n\n // If optionsUIDs are provided, override the optionsUIDs from the response\n if (options?.optionsUIDs) {\n product.optionUIDs = options.optionsUIDs;\n }\n\n if (!product) {\n return null;\n }\n return raw\n ? product\n : transformProductData(product, {\n preselectFirstOption: options?.preselectFirstOption,\n });\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { PRODUCT_FRAGMENT } from '@/pdp/api/graphql/ProductFragment.graphql';\n\nexport const REFINE_PRODUCT_QUERY = `\nquery REFINE_PRODUCT_QUERY(\n $optionIds: [String!]!\n $sku: String!\n) {\n # Refined Product\n refineProduct(\n optionIds: $optionIds \n sku: $sku\n ) {\n ...PRODUCT_FRAGMENT\n }\n\n # Parent Product\n products(skus: [$sku]) {\n ...PRODUCT_FRAGMENT\n }\n\n # %extendedPlaceholder%\n}\n\n${PRODUCT_FRAGMENT}\n`;\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2023 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { fetchGraphQl, config } from '@/pdp/api';\nimport { ProductModel } from '@/pdp/data/models';\nimport { transformProductData } from '@/pdp/data/transforms';\nimport { REFINE_PRODUCT_QUERY } from './graphql/RefineProductQuery.graphql';\n\nasync function getProductData(sku: string, optionUIDs: string[]): Promise<any> {\n const optionPairCombinations = getPairCombination(optionUIDs);\n const optionQueries = getProductOptionQuery(optionPairCombinations, sku);\n\n const mergedQueries = REFINE_PRODUCT_QUERY.replace(\n '# %extendedPlaceholder%',\n optionQueries\n );\n\n const { data } = await fetchGraphQl(mergedQueries, {\n method: 'GET',\n variables: { optionIds: optionUIDs, sku },\n });\n return data;\n}\n\nexport const getRefinedProduct = async (\n sku: string,\n optionUIDs: string[],\n anchorOptions?: string[],\n raw?: boolean\n): Promise<ProductModel | null> => {\n const data = await getProductData(sku, optionUIDs);\n if (!data) return null;\n\n let { products, refineProduct, ...refinedOptions } = data;\n\n const parent = products?.[0];\n\n const options = mergeRefinedOptions(\n Object.values(refinedOptions),\n parent.options,\n anchorOptions\n );\n\n // needed when anchor options exist\n if (anchorOptions?.length && refineProduct === null) {\n optionUIDs = updateSelections(options, optionUIDs, anchorOptions);\n const updatedRefinedData = await getProductData(sku, optionUIDs);\n refineProduct = updatedRefinedData?.refineProduct;\n }\n\n const response = {\n ...(refineProduct || parent),\n sku: parent.sku,\n name: parent.name,\n externalParentId: parent?.externalId,\n options,\n optionUIDs,\n variantSku:\n refineProduct?.__typename === 'SimpleProductView'\n ? refineProduct?.sku\n : undefined,\n };\n\n const refinedData = raw ? response : transformProductData(response);\n\n const fallback = config?.getConfig()?.models?.ProductDetails?.fallbackData;\n\n if (fallback) {\n return fallback(parent, refinedData!);\n }\n\n return refinedData;\n};\n\nfunction getPairCombination(arr: string[]): string[][] {\n if (arr.length < 2) {\n return [arr];\n }\n\n const result: string[][] = [];\n\n arr.forEach((item) => {\n const temp: string[] = [];\n\n arr.forEach((item2) => {\n if (item !== item2) {\n temp.push(item2);\n }\n });\n\n result.push(temp);\n });\n\n return result;\n}\n\nfunction getProductOptionQuery(optionUIDs: string[][], sku: string): string {\n return optionUIDs\n .map((ids: string[], i: number) => {\n return `\n ProductOption${i}: refineProduct(\n optionIds: [\n ${ids.map((id) => `\"${id}\"`).join(', ')}\n ]\n sku: \"${sku}\"\n ) {\n ... on ComplexProductView {\n options {\n ...PRODUCT_OPTION_FRAGMENT\n }\n }\n }\n `;\n })\n .join('');\n}\n\nfunction mergeRefinedOptions(\n options: {},\n parent: [] = [],\n anchorOptions?: string[]\n) {\n // flat _refined[].options[] to _refinedOptions[]\n const refinedOptions: any = Object.values(options)\n .filter((x) => !!x)\n .reduce((acc: any, curr: any) => {\n if (!curr.options) return [...acc];\n\n return [...acc, ...curr.options];\n }, []);\n\n // Create a map to store items by their id from original\n const map = new Map(parent.map((item: any) => [item.id, item]));\n\n // Iterate through refinedOptions and merge items\n refinedOptions.forEach((current: any) => {\n // anchor options should display all values, so no merge is performed\n if (anchorOptions?.includes(current.id)) {\n return;\n }\n\n map.set(current.id, current);\n });\n\n return [...map.values()];\n}\n\nfunction updateSelections(\n options: any[],\n optionsUIDs: string[],\n anchorOptions: string[]\n): string[] {\n const updatedOptionsUIDs: string[] = [];\n\n let optionValue: string;\n options.forEach((option: any) => {\n if (anchorOptions.includes(option.id)) {\n optionValue =\n option.values?.find((value: any) => optionsUIDs.includes(value?.id))\n ?.id || option.values[0]?.id;\n } else {\n optionValue = option.values[0]?.id; // TODO check if we should use default value instead\n }\n updatedOptionsUIDs.push(optionValue);\n });\n return updatedOptionsUIDs;\n}\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { getProductData, getRefinedProduct, config } from '@/pdp/api';\n\nexport type Options = {\n anchors?: string[];\n optionsUIDs?: string[];\n preselectFirstOption?: boolean;\n isBundle?: boolean;\n skipTransform?: boolean;\n};\n\nexport const fetchProductData = async (sku: string, options?: Options) => {\n // Get the default configuration values\n const { anchors: defaultAnchors, optionsUIDs: defaultOptionsUIDs } =\n config.getConfig();\n\n // Destructure the options object\n const {\n optionsUIDs = defaultOptionsUIDs,\n anchors = defaultAnchors,\n preselectFirstOption,\n isBundle,\n skipTransform,\n } = options ?? {};\n\n // ❗️ Warning ❗️\n // If we have default selections, but we cannot determine that the product is of type bundle, then the response is going to result in null objects and error(s).\n // Only the `products` object will be populated correctly, the `ProductOption${i}` and `refinedProduct` will be set as null.\n // This does not affect the UI, but the error message(s) can be detected by 3rd party tools that the client might be using.\n // This is accepted as a known behaviour, since a bundle product does not have variants.\n // However, if initialData is passed from the integration layer, then we can determine if the product is a bundle and set the isBundle flag accordingly.\n return !isBundle && optionsUIDs\n ? await getRefinedProduct(sku, optionsUIDs, anchors, skipTransform)\n : await getProductData(\n sku,\n {\n preselectFirstOption,\n optionsUIDs,\n },\n skipTransform\n );\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { ValuesModel } from '@/pdp/data/models';\nimport { getProductConfigurationValues } from '@/pdp/api';\n\nexport const setProductConfigurationValues = (\n callback: (prev: ValuesModel) => ValuesModel,\n options?: { scope?: string }\n) => {\n const prev = getProductConfigurationValues({ scope: options?.scope });\n\n const next = callback(prev as ValuesModel);\n\n events.emit('pdp/values', { ...next }, { scope: options?.scope });\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { ValuesModel } from '@/pdp/data/models';\n\nexport const getProductConfigurationValues = ({\n scope,\n}: { scope?: string } = {}): ValuesModel | null => {\n return events.lastPayload('pdp/values', { scope }) ?? null;\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { isProductConfigurationValid } from '@/pdp/api';\n\nexport const setProductConfigurationValid = (\n callback: (prev: boolean) => boolean,\n options?: { scope?: string }\n) => {\n const prev = isProductConfigurationValid({ scope: options?.scope });\n\n const next = callback(prev as boolean);\n\n events.emit('pdp/valid', next, { scope: options?.scope });\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const isProductConfigurationValid = ({\n scope,\n}: { scope?: string } = {}): boolean | null => {\n return events.lastPayload('pdp/valid', { scope }) ?? null;\n};\n"],"names":["setUrlParams","params","urlSearchParams","key","value","url","getUrlParams","getValidatedQuantityFromUrl","defaultQuantity","quantityParam","parsedQuantity","transformProduct","product","_b","_a","_d","_c","_f","_e","_h","_g","_j","_i","_l","_k","contexts","events","getAdobeDataLayer","getChannelContext","setContext","name","data","adobeDataLayer","setChannelContext","pushEvent","event","additionalContext","acdl","state","publishProductPageViewEvent","productItem","ProductType","ProductViewType","transformProductData","options","isBundle","optionUIDs","getOptionUIDs","productType","productData","transformImages","transformPrices","transformAttributes","transformOptions","merge","config","image","roles","label","id","title","required","multi","values","typename","type","mapBundleOptionValues","mapOptionValues","enabled","inStock","isDefault","defaultOptionUIDs","price","priceRange","getSimpleProductPrices","regularPrice","finalPrice","currency","getComplexProductPrices","finalMinimumPrice","finalMaximumPrice","getBundleProductPrice","maxSumRegular","bundlePrice","option","regularAmounts","amount","maxRegularAmount","_m","visible","preselectFirstOption","defaultSelection","preselectedFirstOption","selection","initialize","Initializer","_config","initialData","optionsUIDs","initialQuantity","fetchProductData","defaultValues","setProductConfigurationValues","setProductConfigurationValid","sku","scope","next","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","fetchGraphQl","getConfig","FetchGraphQL","GET_PRODUCT_DATA","PRODUCT_FRAGMENT","getProductData","raw","REFINE_PRODUCT_QUERY","optionPairCombinations","getPairCombination","optionQueries","getProductOptionQuery","mergedQueries","getRefinedProduct","anchorOptions","products","refineProduct","refinedOptions","parent","mergeRefinedOptions","updateSelections","updatedRefinedData","response","refinedData","fallback","arr","result","item","temp","item2","ids","i","x","acc","curr","map","current","updatedOptionsUIDs","optionValue","defaultAnchors","defaultOptionsUIDs","anchors","skipTransform","callback","prev","getProductConfigurationValues","isProductConfigurationValid"],"mappings":"0OAgBO,SAASA,GACdC,EACM,CACN,MAAMC,EAAkB,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAE3D,OAAA,QAAQD,CAAM,EAAE,QAAQ,CAAC,CAACE,EAAKC,CAAK,IAAM,CAC3CA,IAAU,KACZF,EAAgB,OAAOC,CAAG,EAE1BD,EAAgB,IAAIC,EAAK,OAAOC,CAAK,CAAC,CACxC,CACD,EAEG,IAAAC,EAAM,OAAO,SAAS,SACnBA,GAAA,IAAIH,EAAgB,SAAU,CAAA,GACrCG,GAAO,OAAO,SAAS,KAEvB,OAAO,QAAQ,aAAa,CAAA,EAAI,GAAIA,CAAG,CACzC,CAEO,SAASC,IAAuC,CACrD,MAAMJ,EAAkB,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAC5DD,EAAiC,CAAC,EAExB,OAAAC,EAAA,QAAQ,CAACE,EAAOD,IAAQ,CACtCF,EAAOE,CAAG,EAAIC,CAAA,CACf,EAEMH,CACT,CAEgB,SAAAM,GACdC,EAA0B,EAClB,CAER,MAAMC,GADYH,GAAa,GAAK,CAAC,GACL,SAEhC,GAAIG,EAAe,CACX,MAAAC,EAAiB,SAASD,EAAe,EAAE,EAG/C,GAAA,CAAC,MAAMC,CAAc,GACrB,OAAO,UAAUA,CAAc,GAC/BA,EAAiB,EAGV,OAAAA,CACT,CAIK,OAAAF,CACT,CChDO,SAASG,GAAiBC,EAAgC,6BACxD,MAAA,CACL,UAAW,OAAOA,GAAA,YAAAA,EAAS,UAAU,EACrC,KAAMA,GAAA,YAAAA,EAAS,KACf,KAAKA,GAAA,YAAAA,EAAS,cAAcA,GAAA,YAAAA,EAAS,KACrC,YAAaA,GAAA,YAAAA,EAAS,IACtB,cAAe,OACf,gBAAiB,OACjB,UAAW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1C,MAAApD,CACF,EAAwB,KACf/E,EAAO,YAAY,YAAa,CAAE,MAAA+E,CAAA,CAAO,GAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as
|
|
3
|
+
import{jsxs as m,jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{useState as l,useMemo as x,useEffect as P}from"@dropins/tools/preact-compat.js";import{classes as A,Slot as L}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";import{i as j,t as C}from"../chunks/date.js";import{g as I}from"../chunks/getFetchedProductData.js";import{useText as M}from"@dropins/tools/i18n.js";import{c as N}from"../chunks/isProductConfigurationValid.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";const T=({initialData:u=null,scope:i,children:_,slots:e,...n})=>{var c;const f=M("PDP.Product.Details.label").label,{defaultLocale:d="en-US"}=N.getConfig(),[p,b]=l(d),[r,g]=l(u),D=x(()=>({data:r}),[r]);return P(()=>{const o=s.on("pdp/data",g,{scope:i}),t=s.on("locale",b);return()=>{o==null||o.off(),t==null||t.off()}},[i]),r?m("div",{...n,className:A(["pdp-attributes",n.className]),children:[f,e!=null&&e.Attributes?a(L,{name:"Attributes",slot:e==null?void 0:e.Attributes,context:{...D}}):a("ul",{children:(c=r==null?void 0:r.attributes)==null?void 0:c.map(({label:o,value:t},S)=>{const h=j(t)?C(t,p):t.toString();return m("li",{children:[o,": ",a("span",{dangerouslySetInnerHTML:{__html:h}})]},S)})})]}):null};T.getInitialData=I;export{T as ProductAttributes,T as default};
|
|
4
4
|
//# sourceMappingURL=ProductAttributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductAttributes.js","sources":["/@dropins/storefront-pdp/src/containers/ProductAttributes/ProductAttributes.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState, useMemo } from 'preact/compat';\nimport { classes, Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { isDateValid, toDateString } from '@/pdp/lib/date';\nimport { config, getFetchedProductData } from '@/pdp/api';\n\ntype DefaultSlotContext = {\n data: ProductModel | null;\n};\n\nexport interface ProductAttributesProps extends HTMLAttributes<HTMLDivElement> {\n slots?: {\n Attributes?: SlotProps<DefaultSlotContext>;\n };\n}\n\nexport const ProductAttributes: Container<\n ProductAttributesProps,\n ProductModel | null\n> = ({ initialData = null, children, slots, ...props }) => {\n const DetailsLabel = useText('PDP.Product.Details.label').label;\n const { defaultLocale = 'en-US' } = config.getConfig();\n\n const [locale, setLocale] = useState<string>(defaultLocale);\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const defaultSlotContext: DefaultSlotContext = useMemo(\n () => ({ data }),\n [data]\n );\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n const localeEvent = events.on('locale', setLocale);\n\n return () => {\n dataEvent?.off();\n localeEvent?.off();\n };\n }, []);\n\n if (!data) return null;\n\n return (\n <div {...props} className={classes(['pdp-attributes', props.className])}>\n {DetailsLabel}\n {slots?.Attributes ? (\n <Slot\n name=\"Attributes\"\n slot={slots?.Attributes}\n context={{ ...defaultSlotContext }}\n />\n ) : (\n <ul>\n {data?.attributes?.map(({ label, value }, key) => {\n const __html = isDateValid(value)\n ? toDateString(value, locale)\n : value.toString();\n\n return (\n <li key={key}>\n {/* eslint-disable-next-line react/no-danger */}\n {label}: <span dangerouslySetInnerHTML={{ __html }} />\n </li>\n );\n })}\n </ul>\n )}\n </div>\n );\n};\n\nProductAttributes.getInitialData = getFetchedProductData;\n"],"names":["ProductAttributes","initialData","children","slots","props","DetailsLabel","useText","defaultLocale","config","locale","setLocale","useState","data","setData","defaultSlotContext","useMemo","useEffect","dataEvent","events","localeEvent","jsxs","classes","jsx","Slot","_a","label","value","key","__html","isDateValid","toDateString","getFetchedProductData"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProductAttributes.js","sources":["/@dropins/storefront-pdp/src/containers/ProductAttributes/ProductAttributes.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState, useMemo } from 'preact/compat';\nimport { classes, Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { isDateValid, toDateString } from '@/pdp/lib/date';\nimport { config, getFetchedProductData } from '@/pdp/api';\n\ntype DefaultSlotContext = {\n data: ProductModel | null;\n};\n\nexport interface ProductAttributesProps extends HTMLAttributes<HTMLDivElement> {\n scope?: string;\n slots?: {\n Attributes?: SlotProps<DefaultSlotContext>;\n };\n}\n\nexport const ProductAttributes: Container<\n ProductAttributesProps,\n ProductModel | null\n> = ({ initialData = null, scope, children, slots, ...props }) => {\n const DetailsLabel = useText('PDP.Product.Details.label').label;\n const { defaultLocale = 'en-US' } = config.getConfig();\n\n const [locale, setLocale] = useState<string>(defaultLocale);\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const defaultSlotContext: DefaultSlotContext = useMemo(\n () => ({ data }),\n [data]\n );\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n const localeEvent = events.on('locale', setLocale);\n\n return () => {\n dataEvent?.off();\n localeEvent?.off();\n };\n }, [scope]);\n\n if (!data) return null;\n\n return (\n <div {...props} className={classes(['pdp-attributes', props.className])}>\n {DetailsLabel}\n {slots?.Attributes ? (\n <Slot\n name=\"Attributes\"\n slot={slots?.Attributes}\n context={{ ...defaultSlotContext }}\n />\n ) : (\n <ul>\n {data?.attributes?.map(({ label, value }, key) => {\n const __html = isDateValid(value)\n ? toDateString(value, locale)\n : value.toString();\n\n return (\n <li key={key}>\n {/* eslint-disable-next-line react/no-danger */}\n {label}: <span dangerouslySetInnerHTML={{ __html }} />\n </li>\n );\n })}\n </ul>\n )}\n </div>\n );\n};\n\nProductAttributes.getInitialData = getFetchedProductData;\n"],"names":["ProductAttributes","initialData","scope","children","slots","props","DetailsLabel","useText","defaultLocale","config","locale","setLocale","useState","data","setData","defaultSlotContext","useMemo","useEffect","dataEvent","events","localeEvent","jsxs","classes","jsx","Slot","_a","label","value","key","__html","isDateValid","toDateString","getFetchedProductData"],"mappings":"6hBAmCa,MAAAA,EAGT,CAAC,CAAE,YAAAC,EAAc,KAAM,MAAAC,EAAO,SAAAC,EAAU,MAAAC,EAAO,GAAGC,KAAY,OAC1D,MAAAC,EAAeC,EAAQ,2BAA2B,EAAE,MACpD,CAAE,cAAAC,EAAgB,SAAYC,EAAO,UAAU,EAE/C,CAACC,EAAQC,CAAS,EAAIC,EAAiBJ,CAAa,EAEpD,CAACK,EAAMC,CAAO,EAAIF,EAA8BX,CAAW,EAE3Dc,EAAyCC,EAC7C,KAAO,CAAE,KAAAH,CAAK,GACd,CAACA,CAAI,CACP,EAYI,OAVJI,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYL,EAAS,CAAE,MAAAZ,EAAO,EACpDkB,EAAcD,EAAO,GAAG,SAAUR,CAAS,EAEjD,MAAO,IAAM,CACXO,GAAA,MAAAA,EAAW,MACXE,GAAA,MAAAA,EAAa,KACf,CAAA,EACC,CAAClB,CAAK,CAAC,EAELW,EAGHQ,EAAC,MAAK,CAAA,GAAGhB,EAAO,UAAWiB,EAAQ,CAAC,iBAAkBjB,EAAM,SAAS,CAAC,EACnE,SAAA,CAAAC,EACAF,GAAA,MAAAA,EAAO,WACNmB,EAACC,EAAA,CACC,KAAK,aACL,KAAMpB,GAAA,YAAAA,EAAO,WACb,QAAS,CAAE,GAAGW,CAAmB,CAAA,CACnC,EAECQ,EAAA,KAAA,CACE,UAAME,EAAAZ,GAAA,YAAAA,EAAA,aAAA,YAAAY,EAAY,IAAI,CAAC,CAAE,MAAAC,EAAO,MAAAC,CAAM,EAAGC,IAAQ,CAC1C,MAAAC,EAASC,EAAYH,CAAK,EAC5BI,EAAaJ,EAAOjB,CAAM,EAC1BiB,EAAM,SAAS,EAEnB,SACG,KAEE,CAAA,SAAA,CAAAD,EAAM,KAAGH,EAAA,OAAA,CAAK,wBAAyB,CAAE,OAAAM,EAAU,CAAA,CAAA,CAAA,EAF7CD,CAGT,CAAA,EAGN,CAAA,CAAA,EAEJ,EA3BgB,IA6BpB,EAEA5B,EAAkB,eAAiBgC"}
|
|
@@ -3,6 +3,7 @@ import { Container } from '@dropins/tools/types/elsie/src/lib';
|
|
|
3
3
|
import { ProductModel } from '../../data/models';
|
|
4
4
|
|
|
5
5
|
export interface ProductDescriptionProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
scope?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare const ProductDescription: Container<ProductDescriptionProps, ProductModel | null>;
|
|
8
9
|
//# sourceMappingURL=ProductDescription.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as i}from"@dropins/tools/preact-jsx-runtime.js";import{useState as a,useEffect as c}from"@dropins/tools/preact-compat.js";import{classes as m}from"@dropins/tools/lib.js";import{events as l}from"@dropins/tools/event-bus.js";import{g as f}from"../chunks/getFetchedProductData.js";const u=({initialData:s=null,scope:r,children:d,...o})=>{const[t,n]=a(s);return c(()=>{const e=l.on("pdp/data",n,{scope:r});return()=>{e==null||e.off()}},[r]),t?i("div",{dangerouslySetInnerHTML:{__html:(t==null?void 0:t.description)??""},...o,className:m(["pdp-description",o.className])}):null};u.getInitialData=f;export{u as ProductDescription,u as default};
|
|
4
4
|
//# sourceMappingURL=ProductDescription.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductDescription.js","sources":["/@dropins/storefront-pdp/src/containers/ProductDescription/ProductDescription.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductDescriptionProps\n extends HTMLAttributes<HTMLDivElement> {}\n\nexport const ProductDescription: Container<\n ProductDescriptionProps,\n ProductModel | null\n> = ({ initialData = null, children, ...props }) => {\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n\n return () => {\n dataEvent?.off();\n };\n }, []);\n\n if (!data) return null;\n\n return (\n <div\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: data?.description ?? '' }}\n {...props}\n className={classes(['pdp-description', props.className])}\n />\n );\n};\n\nProductDescription.getInitialData = getFetchedProductData;\n"],"names":["ProductDescription","initialData","children","props","data","setData","useState","useEffect","dataEvent","events","jsx","classes","getFetchedProductData"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProductDescription.js","sources":["/@dropins/storefront-pdp/src/containers/ProductDescription/ProductDescription.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductDescriptionProps\n extends HTMLAttributes<HTMLDivElement> {\n scope?: string;\n}\n\nexport const ProductDescription: Container<\n ProductDescriptionProps,\n ProductModel | null\n> = ({ initialData = null, scope, children, ...props }) => {\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n\n return () => {\n dataEvent?.off();\n };\n }, [scope]);\n\n if (!data) return null;\n\n return (\n <div\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: data?.description ?? '' }}\n {...props}\n className={classes(['pdp-description', props.className])}\n />\n );\n};\n\nProductDescription.getInitialData = getFetchedProductData;\n"],"names":["ProductDescription","initialData","scope","children","props","data","setData","useState","useEffect","dataEvent","events","jsx","classes","getFetchedProductData"],"mappings":"iSA2Ba,MAAAA,EAGT,CAAC,CAAE,YAAAC,EAAc,KAAM,MAAAC,EAAO,SAAAC,EAAU,GAAGC,KAAY,CACzD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAA8BN,CAAW,EAU7D,OARJO,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYJ,EAAS,CAAE,MAAAJ,EAAO,EAE1D,MAAO,IAAM,CACXO,GAAA,MAAAA,EAAW,KACb,CAAA,EACC,CAACP,CAAK,CAAC,EAELG,EAGHM,EAAC,MAAA,CAEC,wBAAyB,CAAE,QAAQN,GAAA,YAAAA,EAAM,cAAe,EAAG,EAC1D,GAAGD,EACJ,UAAWQ,EAAQ,CAAC,kBAAmBR,EAAM,SAAS,CAAC,CAAA,CACzD,EARgB,IAUpB,EAEAJ,EAAmB,eAAiBa"}
|
|
@@ -7,6 +7,7 @@ type DefaultSlotContext = {
|
|
|
7
7
|
data: ProductModel | null;
|
|
8
8
|
};
|
|
9
9
|
export interface ProductGalleryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'controls'> {
|
|
10
|
+
scope?: string;
|
|
10
11
|
controls?: 'thumbnailsRow' | 'thumbnailsColumn' | 'dots' | null;
|
|
11
12
|
loop?: boolean;
|
|
12
13
|
peak?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as A,jsxs as
|
|
3
|
+
import{jsx as A,jsxs as K}from"@dropins/tools/preact-jsx-runtime.js";import{useState as R,useEffect as U,useMemo as w}from"@dropins/tools/preact-compat.js";import{Slot as Z}from"@dropins/tools/lib.js";import{Image as j}from"@dropins/tools/components.js";import{events as V}from"@dropins/tools/event-bus.js";import{g as W}from"../chunks/getFetchedProductData.js";import{Z as X,C as v,O as Y}from"../chunks/Zoom.js";/* empty css */import{useText as $}from"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";const s=({initialData:G=null,scope:I,controls:k="dots",loop:C=!0,peak:H=!1,gap:N=null,arrows:Q=!0,arrowsOnMainImage:F=!1,zoom:h=!1,imageParams:t,thumbnailParams:o,children:L,slots:l,...q})=>{var y,T,_,S,D,E;const r=$("PDP.Product.Image.label").label,[e,z]=R(G),[f,B]=R(null);U(()=>{const n=V.on("pdp/data",z,{scope:I});return()=>{n==null||n.off()}},[I]);const g=w(()=>({data:e}),[e]),x=w(()=>{var n;return((n=e==null?void 0:e.images)==null?void 0:n.map(({label:i,url:c},p)=>{const d=({...u})=>{var O;const M={title:i,src:c,alt:r==null?void 0:r.replace("{product}",i).replace("{key}",String(p+1)).replace("{total}",String((O=e==null?void 0:e.images)==null?void 0:O.length)),width:(t==null?void 0:t.width)??960,height:(t==null?void 0:t.height)??1191,params:t??{width:960},loading:p===0?"eager":"lazy",...u};return A(Z,{name:"CarouselMainImage",slot:l==null?void 0:l.CarouselMainImage,context:{...g,defaultImageProps:M},children:A(j,{...M})})};return h?A(X,{closeButton:typeof h=="object"?h.closeButton:!1,children:A(d,{})},c):A(d,{onClick:()=>B(p)},c)}))??A("img",{src:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",className:"pdp-product-gallery__images__placeholder",width:(t==null?void 0:t.width)??960,height:(t==null?void 0:t.height)??1191,"aria-hidden":!0},"pleaceholder")},[r,e==null?void 0:e.images,t,h,g,l==null?void 0:l.CarouselMainImage]),J=w(()=>{var n;return((n=e==null?void 0:e.images)==null?void 0:n.map(({label:i,url:c},p)=>{var u;const d={title:i,src:c,alt:r==null?void 0:r.replace("{product}",i).replace("{key}",String(p+1)).replace("{total}",String((u=e==null?void 0:e.images)==null?void 0:u.length)),width:(o==null?void 0:o.width)??200,height:(o==null?void 0:o.height)??248,params:o??{width:200},loading:"lazy"};return A(Z,{name:"CarouselThumbnail",slotTag:"span",contentTag:"span",slot:l==null?void 0:l.CarouselThumbnail,context:{...g,defaultImageProps:d},children:A(j,{...d})},c)}))??A("img",{src:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",className:"pdp-product-gallery__thumbnail__placeholder",width:(o==null?void 0:o.width)??200,height:(o==null?void 0:o.height)??248,"aria-hidden":!0},"pleaceholder")},[r,e==null?void 0:e.images,o,g,l==null?void 0:l.CarouselThumbnail]);return e?K("div",{...q,children:[A(v,{arrows:!!((y=e==null?void 0:e.images)!=null&&y.length)&&Q,arrowsOnMainImage:F,controls:(T=e==null?void 0:e.images)!=null&&T.length?k:void 0,loop:C&&!!((_=e.images)!=null&&_.length),peak:!!((S=e==null?void 0:e.images)!=null&&S.length)&&H,gap:N,defaultIndex:f||0,thumbnails:J,children:x}),f===null?null:A(Y,{onClose:()=>B(null),centered:!0,children:A(v,{arrows:!!((D=e==null?void 0:e.images)!=null&&D.length),width:"100%",height:"100%",defaultIndex:f,loop:C&&!!((E=e.images)!=null&&E.length),controls:"dots",isZoomed:!0,children:x})})]}):null};s.getInitialData=W;export{s as ProductGallery,s as default};
|
|
4
4
|
//# sourceMappingURL=ProductGallery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductGallery.js","sources":["/@dropins/storefront-pdp/src/containers/ProductGallery/ProductGallery.tsx"],"sourcesContent":["import { HTMLAttributes, useEffect, useMemo, useState } from 'preact/compat';\nimport {\n Container,\n ResolveImageUrlOptions,\n Slot,\n SlotProps,\n} from '@adobe-commerce/elsie/lib';\n\nimport { Image, ImageProps } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models/product-model';\nimport { getFetchedProductData } from '@/pdp/api';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Carousel, Overlay, Zoom } from '@/pdp/components';\n\ntype DefaultSlotContext = {\n data: ProductModel | null;\n};\n\nexport interface ProductGalleryProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'controls'> {\n controls?: 'thumbnailsRow' | 'thumbnailsColumn' | 'dots' | null;\n loop?: boolean;\n peak?: boolean;\n gap?: 'small' | 'medium' | 'large' | null;\n arrows?: boolean;\n arrowsOnMainImage?: boolean;\n imageParams?: ResolveImageUrlOptions;\n thumbnailParams?: ResolveImageUrlOptions;\n zoom?: { closeButton: boolean } | boolean;\n slots?: {\n CarouselThumbnail?: SlotProps<\n DefaultSlotContext & { defaultImageProps: ImageProps }\n >;\n CarouselMainImage?: SlotProps<\n DefaultSlotContext & { defaultImageProps: ImageProps }\n >;\n };\n}\n\nexport const ProductGallery: Container<\n ProductGalleryProps,\n ProductModel | null\n> = ({\n initialData = null,\n controls = 'dots',\n loop = true,\n peak = false,\n gap = null,\n arrows = true,\n arrowsOnMainImage = false,\n zoom = false,\n imageParams,\n thumbnailParams,\n children,\n slots,\n ...props\n}) => {\n const ImagesLabel = useText('PDP.Product.Image.label').label;\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const [zoomTo, setZoomTo] = useState<number | null>(null);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n return () => {\n dataEvent?.off();\n };\n }, []);\n\n const defaultSlotContext: DefaultSlotContext = useMemo(\n () => ({ data }),\n [data]\n );\n\n const images = useMemo(\n () =>\n data?.images?.map(({ label, url }, key) => {\n const Item = ({ ...itemProps }) => {\n const defaultProps = {\n title: label,\n src: url,\n alt: ImagesLabel?.replace('{product}', label)\n .replace('{key}', String(key + 1))\n .replace('{total}', String(data?.images?.length)),\n\n // TODO: change width/height for image aspect ratio\n // pending https://jira.corp.adobe.com/browse/DATA-5122\n width: imageParams?.width ?? 960,\n height: imageParams?.height ?? 1191,\n params: imageParams ?? { width: 960 },\n loading: key === 0 ? 'eager' : 'lazy',\n ...itemProps,\n } as const;\n\n return (\n <Slot\n name=\"CarouselMainImage\"\n slot={slots?.CarouselMainImage}\n context={{\n ...defaultSlotContext,\n defaultImageProps: defaultProps,\n }}\n >\n <Image {...defaultProps} />\n </Slot>\n );\n };\n\n return zoom ? (\n <Zoom\n key={url}\n closeButton={typeof zoom === 'object' ? zoom.closeButton : false}\n >\n <Item />\n </Zoom>\n ) : (\n <Item key={url} onClick={() => setZoomTo(key)} />\n );\n }) ?? (\n <img\n key=\"pleaceholder\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"\n className=\"pdp-product-gallery__images__placeholder\"\n width={imageParams?.width ?? 960}\n height={imageParams?.height ?? 1191}\n aria-hidden\n />\n ),\n [\n ImagesLabel,\n data?.images,\n imageParams,\n zoom,\n defaultSlotContext,\n slots?.CarouselMainImage,\n ]\n );\n\n const thumbnails = useMemo(() => {\n return (\n data?.images?.map(({ label, url }, key) => {\n const defaultProps = {\n title: label,\n src: url,\n alt: ImagesLabel?.replace('{product}', label)\n .replace('{key}', String(key + 1))\n .replace('{total}', String(data?.images?.length)),\n\n // TODO: change width/height for image aspect ratio\n // pending https://jira.corp.adobe.com/browse/DATA-5122\n width: thumbnailParams?.width ?? 200,\n height: thumbnailParams?.height ?? 248,\n params: thumbnailParams ?? { width: 200 },\n loading: 'lazy',\n } as const;\n\n return (\n <Slot\n key={url}\n name=\"CarouselThumbnail\"\n slotTag=\"span\"\n contentTag=\"span\"\n slot={slots?.CarouselThumbnail}\n context={{\n ...defaultSlotContext,\n defaultImageProps: defaultProps,\n }}\n >\n <Image {...defaultProps} />\n </Slot>\n );\n }) ?? (\n <img\n key=\"pleaceholder\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"\n className=\"pdp-product-gallery__thumbnail__placeholder\"\n width={thumbnailParams?.width ?? 200}\n height={thumbnailParams?.height ?? 248}\n aria-hidden\n />\n )\n );\n }, [\n ImagesLabel,\n data?.images,\n thumbnailParams,\n defaultSlotContext,\n slots?.CarouselThumbnail,\n ]);\n\n if (!data) return null;\n\n return (\n <div {...props}>\n {/* Carousel */}\n <Carousel\n arrows={!!data?.images?.length && arrows}\n arrowsOnMainImage={arrowsOnMainImage}\n controls={data?.images?.length ? controls : undefined}\n loop={loop && !!data.images?.length}\n peak={!!data?.images?.length && peak}\n gap={gap}\n defaultIndex={zoomTo || 0}\n thumbnails={thumbnails}\n >\n {images}\n </Carousel>\n\n {/* Zoom Overlay */}\n {zoomTo === null ? null : (\n <Overlay onClose={() => setZoomTo(null)} centered>\n <Carousel\n arrows={!!data?.images?.length}\n width=\"100%\"\n height=\"100%\"\n defaultIndex={zoomTo}\n loop={loop && !!data.images?.length}\n controls=\"dots\"\n isZoomed\n >\n {images}\n </Carousel>\n </Overlay>\n )}\n </div>\n );\n};\n\nProductGallery.getInitialData = getFetchedProductData;\n"],"names":["ProductGallery","initialData","controls","loop","peak","gap","arrows","arrowsOnMainImage","zoom","imageParams","thumbnailParams","children","slots","props","ImagesLabel","useText","data","setData","useState","zoomTo","setZoomTo","useEffect","dataEvent","events","defaultSlotContext","useMemo","images","_a","label","url","key","Item","itemProps","defaultProps","jsx","Slot","Image","Zoom","thumbnails","jsxs","Carousel","_b","_c","_d","Overlay","_e","_f","getFetchedProductData"],"mappings":"2gBAwCO,MAAMA,EAGT,CAAC,CACH,YAAAC,EAAc,KACd,SAAAC,EAAW,OACX,KAAAC,EAAO,GACP,KAAAC,EAAO,GACP,IAAAC,EAAM,KACN,OAAAC,EAAS,GACT,kBAAAC,EAAoB,GACpB,KAAAC,EAAO,GACP,YAAAC,EACA,gBAAAC,EACA,SAAAC,EACA,MAAAC,EACA,GAAGC,CACL,IAAM,iBACE,MAAAC,EAAcC,EAAQ,yBAAyB,EAAE,MAEjD,CAACC,EAAMC,CAAO,EAAIC,EAA8BjB,CAAW,EAE3D,CAACkB,EAAQC,CAAS,EAAIF,EAAwB,IAAI,EAExDG,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYN,CAAO,EAC/C,MAAO,IAAM,CACXK,GAAA,MAAAA,EAAW,KACb,CACF,EAAG,EAAE,EAEL,MAAME,EAAyCC,EAC7C,KAAO,CAAE,K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AAA1B,EAAK,SAAL,MAAA0B,EAAa,QAC7B,KAAM,CAAC,GAACC,EAAA3B,GAAA,YAAAA,EAAM,SAAN,MAAA2B,EAAc,SAAUvC,EAChC,IAAAC,EACA,aAAcc,GAAU,EACxB,WAAAmB,EAEC,SAAAZ,CAAA,CACH,EAGCP,IAAW,KAAO,KAChBe,EAAAU,EAAA,CAAQ,QAAS,IAAMxB,EAAU,IAAI,EAAG,SAAQ,GAC/C,SAAAc,EAACM,EAAA,CACC,OAAQ,CAAC,GAACK,EAAA7B,GAAA,YAAAA,EAAM,SAAN,MAAA6B,EAAc,QACxB,MAAM,OACN,OAAO,OACP,aAAc1B,EACd,KAAMhB,GAAQ,CAAC,GAAC2C,EAAA9B,EAAK,SAAL,MAAA8B,EAAa,QAC7B,SAAS,OACT,SAAQ,GAEP,SAAApB,CAAA,CAAA,CAEL,CAAA,CAAA,EAEJ,EAlCgB,IAoCpB,EAEA1B,EAAe,eAAiB+C"}
|
|
1
|
+
{"version":3,"file":"ProductGallery.js","sources":["/@dropins/storefront-pdp/src/containers/ProductGallery/ProductGallery.tsx"],"sourcesContent":["import { HTMLAttributes, useEffect, useMemo, useState } from 'preact/compat';\nimport {\n Container,\n ResolveImageUrlOptions,\n Slot,\n SlotProps,\n} from '@adobe-commerce/elsie/lib';\n\nimport { Image, ImageProps } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models/product-model';\nimport { getFetchedProductData } from '@/pdp/api';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Carousel, Overlay, Zoom } from '@/pdp/components';\n\ntype DefaultSlotContext = {\n data: ProductModel | null;\n};\n\nexport interface ProductGalleryProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'controls'> {\n scope?: string;\n controls?: 'thumbnailsRow' | 'thumbnailsColumn' | 'dots' | null;\n loop?: boolean;\n peak?: boolean;\n gap?: 'small' | 'medium' | 'large' | null;\n arrows?: boolean;\n arrowsOnMainImage?: boolean;\n imageParams?: ResolveImageUrlOptions;\n thumbnailParams?: ResolveImageUrlOptions;\n zoom?: { closeButton: boolean } | boolean;\n slots?: {\n CarouselThumbnail?: SlotProps<\n DefaultSlotContext & { defaultImageProps: ImageProps }\n >;\n CarouselMainImage?: SlotProps<\n DefaultSlotContext & { defaultImageProps: ImageProps }\n >;\n };\n}\n\nexport const ProductGallery: Container<\n ProductGalleryProps,\n ProductModel | null\n> = ({\n initialData = null,\n scope,\n controls = 'dots',\n loop = true,\n peak = false,\n gap = null,\n arrows = true,\n arrowsOnMainImage = false,\n zoom = false,\n imageParams,\n thumbnailParams,\n children,\n slots,\n ...props\n}) => {\n const ImagesLabel = useText('PDP.Product.Image.label').label;\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const [zoomTo, setZoomTo] = useState<number | null>(null);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n return () => {\n dataEvent?.off();\n };\n }, [scope]);\n\n const defaultSlotContext: DefaultSlotContext = useMemo(\n () => ({ data }),\n [data]\n );\n\n const images = useMemo(\n () =>\n data?.images?.map(({ label, url }, key) => {\n const Item = ({ ...itemProps }) => {\n const defaultProps = {\n title: label,\n src: url,\n alt: ImagesLabel?.replace('{product}', label)\n .replace('{key}', String(key + 1))\n .replace('{total}', String(data?.images?.length)),\n\n // TODO: change width/height for image aspect ratio\n // pending https://jira.corp.adobe.com/browse/DATA-5122\n width: imageParams?.width ?? 960,\n height: imageParams?.height ?? 1191,\n params: imageParams ?? { width: 960 },\n loading: key === 0 ? 'eager' : 'lazy',\n ...itemProps,\n } as const;\n\n return (\n <Slot\n name=\"CarouselMainImage\"\n slot={slots?.CarouselMainImage}\n context={{\n ...defaultSlotContext,\n defaultImageProps: defaultProps,\n }}\n >\n <Image {...defaultProps} />\n </Slot>\n );\n };\n\n return zoom ? (\n <Zoom\n key={url}\n closeButton={typeof zoom === 'object' ? zoom.closeButton : false}\n >\n <Item />\n </Zoom>\n ) : (\n <Item key={url} onClick={() => setZoomTo(key)} />\n );\n }) ?? (\n <img\n key=\"pleaceholder\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"\n className=\"pdp-product-gallery__images__placeholder\"\n width={imageParams?.width ?? 960}\n height={imageParams?.height ?? 1191}\n aria-hidden\n />\n ),\n [\n ImagesLabel,\n data?.images,\n imageParams,\n zoom,\n defaultSlotContext,\n slots?.CarouselMainImage,\n ]\n );\n\n const thumbnails = useMemo(() => {\n return (\n data?.images?.map(({ label, url }, key) => {\n const defaultProps = {\n title: label,\n src: url,\n alt: ImagesLabel?.replace('{product}', label)\n .replace('{key}', String(key + 1))\n .replace('{total}', String(data?.images?.length)),\n\n // TODO: change width/height for image aspect ratio\n // pending https://jira.corp.adobe.com/browse/DATA-5122\n width: thumbnailParams?.width ?? 200,\n height: thumbnailParams?.height ?? 248,\n params: thumbnailParams ?? { width: 200 },\n loading: 'lazy',\n } as const;\n\n return (\n <Slot\n key={url}\n name=\"CarouselThumbnail\"\n slotTag=\"span\"\n contentTag=\"span\"\n slot={slots?.CarouselThumbnail}\n context={{\n ...defaultSlotContext,\n defaultImageProps: defaultProps,\n }}\n >\n <Image {...defaultProps} />\n </Slot>\n );\n }) ?? (\n <img\n key=\"pleaceholder\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\"\n className=\"pdp-product-gallery__thumbnail__placeholder\"\n width={thumbnailParams?.width ?? 200}\n height={thumbnailParams?.height ?? 248}\n aria-hidden\n />\n )\n );\n }, [\n ImagesLabel,\n data?.images,\n thumbnailParams,\n defaultSlotContext,\n slots?.CarouselThumbnail,\n ]);\n\n if (!data) return null;\n\n return (\n <div {...props}>\n {/* Carousel */}\n <Carousel\n arrows={!!data?.images?.length && arrows}\n arrowsOnMainImage={arrowsOnMainImage}\n controls={data?.images?.length ? controls : undefined}\n loop={loop && !!data.images?.length}\n peak={!!data?.images?.length && peak}\n gap={gap}\n defaultIndex={zoomTo || 0}\n thumbnails={thumbnails}\n >\n {images}\n </Carousel>\n\n {/* Zoom Overlay */}\n {zoomTo === null ? null : (\n <Overlay onClose={() => setZoomTo(null)} centered>\n <Carousel\n arrows={!!data?.images?.length}\n width=\"100%\"\n height=\"100%\"\n defaultIndex={zoomTo}\n loop={loop && !!data.images?.length}\n controls=\"dots\"\n isZoomed\n >\n {images}\n </Carousel>\n </Overlay>\n )}\n </div>\n );\n};\n\nProductGallery.getInitialData = getFetchedProductData;\n"],"names":["ProductGallery","initialData","scope","controls","loop","peak","gap","arrows","arrowsOnMainImage","zoom","imageParams","thumbnailParams","children","slots","props","ImagesLabel","useText","data","setData","useState","zoomTo","setZoomTo","useEffect","dataEvent","events","defaultSlotContext","useMemo","images","_a","label","url","key","Item","itemProps","defaultProps","jsx","Slot","Image","Zoom","thumbnails","jsxs","Carousel","_b","_c","_d","Overlay","_e","_f","getFetchedProductData"],"mappings":"2gBAyCO,MAAMA,EAGT,CAAC,CACH,YAAAC,EAAc,KACd,MAAAC,EACA,SAAAC,EAAW,OACX,KAAAC,EAAO,GACP,KAAAC,EAAO,GACP,IAAAC,EAAM,KACN,OAAAC,EAAS,GACT,kBAAAC,EAAoB,GACpB,KAAAC,EAAO,GACP,YAAAC,EACA,gBAAAC,EACA,SAAAC,EACA,MAAAC,EACA,GAAGC,CACL,IAAM,iBACE,MAAAC,EAAcC,EAAQ,yBAAyB,EAAE,MAEjD,CAACC,EAAMC,CAAO,EAAIC,EAA8BlB,CAAW,EAE3D,CAACmB,EAAQC,CAAS,EAAIF,EAAwB,IAAI,EAExDG,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYN,EAAS,CAAE,MAAAhB,EAAO,EAC1D,MAAO,IAAM,CACXqB,GAAA,MAAAA,EAAW,KACb,CAAA,EACC,CAACrB,CAAK,CAAC,EAEV,MAAMuB,EAAyCC,EAC7C,KAAO,CAAE,KAA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A1B,EAAK,SAAL,MAAA0B,EAAa,QAC7B,KAAM,CAAC,GAACC,EAAA3B,GAAA,YAAAA,EAAM,SAAN,MAAA2B,EAAc,SAAUvC,EAChC,IAAAC,EACA,aAAcc,GAAU,EACxB,WAAAmB,EAEC,SAAAZ,CAAA,CACH,EAGCP,IAAW,KAAO,KAChBe,EAAAU,EAAA,CAAQ,QAAS,IAAMxB,EAAU,IAAI,EAAG,SAAQ,GAC/C,SAAAc,EAACM,EAAA,CACC,OAAQ,CAAC,GAACK,EAAA7B,GAAA,YAAAA,EAAM,SAAN,MAAA6B,EAAc,QACxB,MAAM,OACN,OAAO,OACP,aAAc1B,EACd,KAAMhB,GAAQ,CAAC,GAAC2C,EAAA9B,EAAK,SAAL,MAAA8B,EAAa,QAC7B,SAAS,OACT,SAAQ,GAEP,SAAApB,CAAA,CAAA,CAEL,CAAA,CAAA,EAEJ,EAlCgB,IAoCpB,EAEA3B,EAAe,eAAiBgD"}
|
|
@@ -3,6 +3,7 @@ import { Container } from '@dropins/tools/types/elsie/src/lib';
|
|
|
3
3
|
import { ProductModel } from '../../data/models';
|
|
4
4
|
|
|
5
5
|
export interface ProductHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
scope?: string;
|
|
6
7
|
hideSku?: boolean;
|
|
7
8
|
}
|
|
8
9
|
export declare const ProductHeader: Container<ProductHeaderProps, ProductModel | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as c,jsx as e,Fragment as i}from"@dropins/tools/preact-jsx-runtime.js";import{useState as
|
|
3
|
+
import{jsxs as c,jsx as e,Fragment as i}from"@dropins/tools/preact-jsx-runtime.js";import{useState as p,useEffect as u}from"@dropins/tools/preact-compat.js";import{classes as f,VComponent as l}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact.js";import{events as h}from"@dropins/tools/event-bus.js";import{g}from"../chunks/getFetchedProductData.js";const _=({className:a,title:r,sku:d,hideSku:n=!1,children:o,...t})=>c("div",{...t,className:f(["pdp-header",a]),children:[e("div",{className:"pdp-header__title",children:e(l,{node:r})}),!n&&e("div",{className:"pdp-header__sku",children:e(l,{node:d})})]}),k=({initialData:a=null,scope:r,hideSku:d=!1,children:n,...o})=>{const[t,m]=p(a);return u(()=>{const s=h.on("pdp/data",m,{scope:r});return()=>{s==null||s.off()}},[r]),t?e(_,{...o,title:e(i,{children:t.name}),sku:e(i,{children:t.sku}),hideSku:d}):null};k.getInitialData=g;export{k as ProductHeader,k as default};
|
|
4
4
|
//# sourceMappingURL=ProductHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductHeader.js","sources":["/@dropins/storefront-pdp/src/components/Header/Header.tsx","/@dropins/storefront-pdp/src/containers/ProductHeader/ProductHeader.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/pdp/components/Header/Header.css';\n\nexport interface HeaderProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n title: VNode;\n sku: VNode;\n hideSku?: boolean;\n}\n\nexport const Header: FunctionComponent<HeaderProps> = ({\n className,\n title,\n sku,\n hideSku = false,\n children,\n ...props\n}) => {\n return (\n <div {...props} className={classes(['pdp-header', className])}>\n <div className=\"pdp-header__title\">\n <VComponent node={title} />\n </div>\n {!hideSku && (\n <div className=\"pdp-header__sku\">\n <VComponent node={sku} />\n </div>\n )}\n </div>\n );\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Header } from '@/pdp/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductHeaderProps extends HTMLAttributes<HTMLDivElement> {\n hideSku?: boolean;\n}\n\nexport const ProductHeader: Container<\n ProductHeaderProps,\n ProductModel | null\n> = ({ initialData = null, hideSku = false, children, ...props }) => {\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n\n return () => {\n dataEvent?.off();\n };\n }, []);\n\n if (!data) return null;\n\n return (\n <Header\n {...props}\n title={<>{data.name}</>}\n sku={<>{data.sku}</>}\n hideSku={hideSku}\n />\n );\n};\n\nProductHeader.getInitialData = getFetchedProductData;\n"],"names":["Header","className","title","sku","hideSku","children","props","jsxs","classes","jsx","VComponent","ProductHeader","initialData","data","setData","useState","useEffect","dataEvent","events","Fragment","getFetchedProductData"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProductHeader.js","sources":["/@dropins/storefront-pdp/src/components/Header/Header.tsx","/@dropins/storefront-pdp/src/containers/ProductHeader/ProductHeader.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/pdp/components/Header/Header.css';\n\nexport interface HeaderProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n title: VNode;\n sku: VNode;\n hideSku?: boolean;\n}\n\nexport const Header: FunctionComponent<HeaderProps> = ({\n className,\n title,\n sku,\n hideSku = false,\n children,\n ...props\n}) => {\n return (\n <div {...props} className={classes(['pdp-header', className])}>\n <div className=\"pdp-header__title\">\n <VComponent node={title} />\n </div>\n {!hideSku && (\n <div className=\"pdp-header__sku\">\n <VComponent node={sku} />\n </div>\n )}\n </div>\n );\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Header } from '@/pdp/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductHeaderProps extends HTMLAttributes<HTMLDivElement> {\n scope?: string;\n hideSku?: boolean;\n}\n\nexport const ProductHeader: Container<\n ProductHeaderProps,\n ProductModel | null\n> = ({ initialData = null, scope, hideSku = false, children, ...props }) => {\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n\n return () => {\n dataEvent?.off();\n };\n }, [scope]);\n\n if (!data) return null;\n\n return (\n <Header\n {...props}\n title={<>{data.name}</>}\n sku={<>{data.sku}</>}\n hideSku={hideSku}\n />\n );\n};\n\nProductHeader.getInitialData = getFetchedProductData;\n"],"names":["Header","className","title","sku","hideSku","children","props","jsxs","classes","jsx","VComponent","ProductHeader","initialData","scope","data","setData","useState","useEffect","dataEvent","events","Fragment","getFetchedProductData"],"mappings":"qaA4BO,MAAMA,EAAyC,CAAC,CACrD,UAAAC,EACA,MAAAC,EACA,IAAAC,EACA,QAAAC,EAAU,GACV,SAAAC,EACA,GAAGC,CACL,IAEIC,EAAC,MAAK,CAAA,GAAGD,EAAO,UAAWE,EAAQ,CAAC,aAAcP,CAAS,CAAC,EAC1D,SAAA,CAAAQ,EAAC,OAAI,UAAU,oBACb,WAACC,EAAW,CAAA,KAAMR,EAAO,CAC3B,CAAA,EACC,CAACE,GACAK,EAAC,MAAI,CAAA,UAAU,kBACb,SAACA,EAAAC,EAAA,CAAW,KAAMP,CAAK,CAAA,CACzB,CAAA,CAAA,EAEJ,EClBSQ,EAGT,CAAC,CAAE,YAAAC,EAAc,KAAM,MAAAC,EAAO,QAAAT,EAAU,GAAO,SAAAC,EAAU,GAAGC,KAAY,CAC1E,KAAM,CAACQ,EAAMC,CAAO,EAAIC,EAA8BJ,CAAW,EAU7D,OARJK,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYJ,EAAS,CAAE,MAAAF,EAAO,EAE1D,MAAO,IAAM,CACXK,GAAA,MAAAA,EAAW,KACb,CAAA,EACC,CAACL,CAAK,CAAC,EAELC,EAGHL,EAACT,EAAA,CACE,GAAGM,EACJ,MAAUG,EAAAW,EAAA,CAAA,SAAAN,EAAK,KAAK,EACpB,IAAQL,EAAAW,EAAA,CAAA,SAAAN,EAAK,IAAI,EACjB,QAAAV,CAAA,CACF,EARgB,IAUpB,EAEAO,EAAc,eAAiBU"}
|
|
@@ -4,6 +4,7 @@ import { ProductModel } from '../../data/models';
|
|
|
4
4
|
import { ImageNodeRenderProps, ImageProps } from '@dropins/tools/types/elsie/src/components';
|
|
5
5
|
|
|
6
6
|
export interface ProductOptionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
scope?: string;
|
|
7
8
|
hideSelectedValue?: boolean;
|
|
8
9
|
onValues?: (optionsUIDs: string[]) => void;
|
|
9
10
|
onErrors?: (errors: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as d}from"@dropins/tools/preact-jsx-runtime.js";import{useState as h,useEffect as z,useCallback as j}from"@dropins/tools/preact-compat.js";import{Slot as C}from"@dropins/tools/lib.js";import{events as S}from"@dropins/tools/event-bus.js";import"@dropins/tools/components.js";/* empty css */import{S as A}from"../chunks/Swatches.js";import"@dropins/tools/preact.js";import{c as v,o as G,k as O,j as b,h as H,l as y,p as J}from"../chunks/isProductConfigurationValid.js";import{g as K}from"../chunks/getFetchedProductData.js";import"@dropins/tools/i18n.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";const Q=({initialData:r={data:null,optionsUIDs:[]},scope:i,hideSelectedValue:p=!1,slots:n,onValues:u,onErrors:l,children:V,...B})=>{var I;const[t,T]=h(r.data),[m,F]=h(r.optionsUIDs),[M,L]=h();z(()=>{const a=S.on("pdp/data",T,{scope:i}),c=S.on("pdp/values",({optionsUIDs:s})=>{s&&F(s)},{scope:i});return()=>{a==null||a.off(),c==null||c.off()}},[]);const N=j(async a=>{var P,U,w,D;if(!(t!=null&&t.sku))return;const{persistURLParams:c,anchors:s,acdl:q}=v.getConfig()??{};let o=Object.keys(a).map(e=>a[e].value).filter(e=>e!==void 0);if(c&&!(t!=null&&t.isBundle)&&G({optionsUIDs:o.join(",")}),((U=(P=O({scope:i}))==null?void 0:P.optionsUIDs)==null?void 0:U.join("|"))!==(o==null?void 0:o.join("|"))){b(f=>({...f,optionsUIDs:o}),{scope:i}),u==null||u(o);const e=await H(t.sku,{optionsUIDs:o??[],isBundle:t==null?void 0:t.isBundle,anchors:s});S.emit("pdp/data",e,{scope:i});let k=(o==null?void 0:o.length)===((w=e==null?void 0:e.options)==null?void 0:w.length);if(s!=null&&s.length){const f=(e==null?void 0:e.optionUIDs)??[];o.every(g=>f.includes(g))||(L(e==null?void 0:e.options),b(g=>({...g,optionsUIDs:f}),{scope:i}),k=(f==null?void 0:f.length)===((D=e==null?void 0:e.options)==null?void 0:D.length))}y(()=>k,{scope:i}),q&&e&&(e==null?void 0:e.variantSku)!==t.sku&&J(e)}},[t==null?void 0:t.isBundle,t==null?void 0:t.sku,u,i]),R=j(a=>{Object.keys(a).length!==0&&(y(()=>!1,{scope:i}),l==null||l(a))},[l,i]);return!t||!t.options?null:d(C,{name:"Swatches",slot:n==null?void 0:n.Swatches,context:{data:t,optionsUIDs:m},children:d(A,{...B,options:t.options,selectedUIDs:m,defaultOptions:m,selectionsToUpdate:M,hideSelectedValue:p,disablePreselections:!((I=v.getConfig())!=null&&I.preselectFirstOption),onValues:N,onErrors:R,imageSwatchNode:n!=null&&n.SwatchImage?({imageSwatchContext:a,...c})=>d(C,{name:"SwatchImage",slot:n==null?void 0:n.SwatchImage,slotTag:"span",contentTag:"span",context:{data:t,optionsUIDs:m,defaultImageProps:c,imageSwatchContext:a}}):void 0})})};Q.getInitialData=async function(r){var n;const i=await K({scope:r==null?void 0:r.scope}),p=((n=O({scope:r==null?void 0:r.scope}))==null?void 0:n.optionsUIDs)??[];return{data:i,optionsUIDs:p}};export{Q as ProductOptions,Q as default};
|
|
4
4
|
//# sourceMappingURL=ProductOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductOptions.js","sources":["/@dropins/storefront-pdp/src/containers/ProductOptions/ProductOptions.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport {\n HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { ProductModel } from '@/pdp/data/models';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Swatches } from '@/pdp/components';\nimport {\n setProductConfigurationValues,\n getProductConfigurationValues,\n setProductConfigurationValid,\n fetchProductData,\n getFetchedProductData,\n config,\n} from '@/pdp/api';\nimport { setUrlParams } from '@/pdp/lib/url-params';\nimport { publishProductPageViewEvent } from '@/pdp/lib/acdl';\nimport {\n ImageNodeRenderProps,\n ImageProps,\n} from '@adobe-commerce/elsie/components';\n\nexport interface ProductOptionsProps extends HTMLAttributes<HTMLDivElement> {\n hideSelectedValue?: boolean;\n onValues?: (optionsUIDs: string[]) => void;\n onErrors?: (errors: { [id: string]: string }) => void;\n slots?: {\n Swatches?: SlotProps<{ data: ProductModel | null; optionsUIDs: string[] }>;\n SwatchImage?: SlotProps<{\n data: ProductModel | null;\n optionsUIDs: string[];\n imageSwatchContext: ImageNodeRenderProps['imageSwatchContext'];\n defaultImageProps: ImageProps;\n }>;\n };\n}\n\nexport const ProductOptions: Container<\n ProductOptionsProps,\n { data: ProductModel | null; optionsUIDs: string[] }\n> = ({\n initialData = { data: null, optionsUIDs: [] },\n hideSelectedValue = false,\n slots,\n onValues,\n onErrors,\n children,\n ...props\n}) => {\n const [data, setData] = useState<ProductModel | null>(initialData.data);\n\n const [current, setCurrent] = useState<string[]>(initialData.optionsUIDs);\n\n const [selectionsToUpdate, setSelectionsToUpdate] =\n useState<ProductModel['options']>();\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n\n const valuesEvent = events.on('pdp/values', ({ optionsUIDs }) => {\n if (optionsUIDs) {\n setCurrent(optionsUIDs);\n }\n });\n\n return () => {\n dataEvent?.off();\n valuesEvent?.off();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleOptionSelected = useCallback(\n async (selections: { [id: string]: { label: string; value: string } }) => {\n if (!data?.sku) return;\n\n const { persistURLParams, anchors, acdl } = config.getConfig() ?? {};\n\n // options selected\n let optionsUIDs = Object.keys(selections)\n .map((id) => selections[id].value)\n .filter((element) => element !== undefined);\n\n // set optionUIDs to URL params\n // ?optionsUIDs=1,2,3\n // only set the URL params if the \"persistURLParams\" is set to true and the product is not a bundle type\n if (persistURLParams && !data?.isBundle) {\n setUrlParams({ optionsUIDs: optionsUIDs.join(',') });\n }\n\n // check if the options have changed\n if (\n getProductConfigurationValues()?.optionsUIDs?.join('|') !==\n optionsUIDs?.join('|')\n ) {\n // update values\n setProductConfigurationValues((prev) => ({ ...prev, optionsUIDs }));\n\n // pass the selected options to callback\n onValues?.(optionsUIDs);\n\n // refetch data\n const next = await fetchProductData(data.sku, {\n optionsUIDs: optionsUIDs ?? [],\n isBundle: data?.isBundle,\n anchors,\n });\n\n // emit the new data\n events.emit('pdp/data', next);\n\n let valid = optionsUIDs?.length === next?.options?.length;\n\n // special processing for anchor options (options that should not be refined when other options are selected)\n if (anchors?.length) {\n const updatedOptionsUIDs = next?.optionUIDs ?? [];\n\n const isMatching = optionsUIDs.every((item) =>\n updatedOptionsUIDs.includes(item)\n );\n\n if (!isMatching) {\n setSelectionsToUpdate(next?.options);\n setProductConfigurationValues((prev) => ({\n ...prev,\n optionsUIDs: updatedOptionsUIDs,\n }));\n\n valid = updatedOptionsUIDs?.length === next?.options?.length;\n }\n }\n\n // is the product valid\n setProductConfigurationValid(() => valid);\n\n // ACDL\n if (acdl && next && next?.variantSku !== data.sku) {\n publishProductPageViewEvent(next);\n }\n }\n },\n [data?.isBundle, data?.sku, onValues]\n );\n\n const handleErrors = useCallback(\n (errors: { [id: string]: string }) => {\n const hasErrors = Object.keys(errors).length !== 0;\n\n if (hasErrors) {\n setProductConfigurationValid(() => false);\n onErrors?.(errors);\n }\n },\n [onErrors]\n );\n\n if (!data) return null;\n\n // Only show if there are options in the data\n if (!data.options) return null;\n\n return (\n <Slot\n name=\"Swatches\"\n slot={slots?.Swatches}\n context={{ data, optionsUIDs: current }}\n >\n <Swatches\n {...props}\n options={data.options}\n selectedUIDs={current}\n defaultOptions={current}\n selectionsToUpdate={selectionsToUpdate}\n hideSelectedValue={hideSelectedValue}\n disablePreselections={!config.getConfig()?.preselectFirstOption}\n onValues={handleOptionSelected}\n onErrors={handleErrors}\n imageSwatchNode={\n slots?.SwatchImage\n ? ({ imageSwatchContext, ...imageProps }) => (\n <Slot\n name=\"SwatchImage\"\n slot={slots?.SwatchImage}\n slotTag=\"span\"\n contentTag=\"span\"\n context={{\n data,\n optionsUIDs: current,\n defaultImageProps: imageProps,\n imageSwatchContext,\n }}\n />\n )\n : undefined\n }\n />\n </Slot>\n );\n};\n\nProductOptions.getInitialData = async function () {\n const data = await getFetchedProductData();\n const optionsUIDs = getProductConfigurationValues()?.optionsUIDs ?? [];\n return { data, optionsUIDs };\n};\n"],"names":["ProductOptions","initialData","hideSelectedValue","slots","onValues","onErrors","children","props","data","setData","useState","current","setCurrent","selectionsToUpdate","setSelectionsToUpdate","useEffect","dataEvent","events","valuesEvent","optionsUIDs","handleOptionSelected","useCallback","selections","persistURLParams","anchors","acdl","config","id","element","setUrlParams","_b","_a","getProductConfigurationValues","setProductConfigurationValues","prev","next","fetchProductData","valid","_c","updatedOptionsUIDs","item","_d","setProductConfigurationValid","publishProductPageViewEvent","handleErrors","errors","jsx","Slot","Swatches","imageSwatchContext","imageProps","getFetchedProductData"],"mappings":"goBAwDO,MAAMA,EAGT,CAAC,CACH,YAAAC,EAAc,CAAE,KAAM,KAAM,YA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O,YACH,CAAC,CAAE,mBAAA8C,EAAoB,GAAGC,KACxBJ,EAACC,EAAA,CACC,KAAK,cACL,KAAM5C,GAAA,YAAAA,EAAO,YACb,QAAQ,OACR,WAAW,OACX,QAAS,CACP,KAAAK,EACA,YAAaG,EACb,kBAAmBuC,EACnB,mBAAAD,CAAA,CACF,CAAA,EAGJ,MAAA,CAAA,CAER,CACF,CAEJ,EAEAjD,EAAe,eAAiB,gBAAkB,OAC1C,MAAAQ,EAAO,MAAM2C,EAAsB,EACnChC,IAAcY,EAAAC,MAAA,YAAAD,EAAiC,cAAe,CAAC,EAC9D,MAAA,CAAE,KAAAvB,EAAM,YAAAW,CAAY,CAC7B"}
|
|
1
|
+
{"version":3,"file":"ProductOptions.js","sources":["/@dropins/storefront-pdp/src/containers/ProductOptions/ProductOptions.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport {\n HTMLAttributes,\n useCallback,\n useEffect,\n useState,\n} from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { ProductModel } from '@/pdp/data/models';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Swatches } from '@/pdp/components';\nimport {\n setProductConfigurationValues,\n getProductConfigurationValues,\n setProductConfigurationValid,\n fetchProductData,\n getFetchedProductData,\n config,\n} from '@/pdp/api';\nimport { setUrlParams } from '@/pdp/lib/url-params';\nimport { publishProductPageViewEvent } from '@/pdp/lib/acdl';\nimport {\n ImageNodeRenderProps,\n ImageProps,\n} from '@adobe-commerce/elsie/components';\n\nexport interface ProductOptionsProps extends HTMLAttributes<HTMLDivElement> {\n scope?: string;\n hideSelectedValue?: boolean;\n onValues?: (optionsUIDs: string[]) => void;\n onErrors?: (errors: { [id: string]: string }) => void;\n slots?: {\n Swatches?: SlotProps<{ data: ProductModel | null; optionsUIDs: string[] }>;\n SwatchImage?: SlotProps<{\n data: ProductModel | null;\n optionsUIDs: string[];\n imageSwatchContext: ImageNodeRenderProps['imageSwatchContext'];\n defaultImageProps: ImageProps;\n }>;\n };\n}\n\nexport const ProductOptions: Container<\n ProductOptionsProps,\n { data: ProductModel | null; optionsUIDs: string[] }\n> = ({\n initialData = { data: null, optionsUIDs: [] },\n scope,\n hideSelectedValue = false,\n slots,\n onValues,\n onErrors,\n children,\n ...props\n}) => {\n const [data, setData] = useState<ProductModel | null>(initialData.data);\n\n const [current, setCurrent] = useState<string[]>(initialData.optionsUIDs);\n\n const [selectionsToUpdate, setSelectionsToUpdate] =\n useState<ProductModel['options']>();\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n\n const valuesEvent = events.on(\n 'pdp/values',\n ({ optionsUIDs }) => {\n if (optionsUIDs) {\n setCurrent(optionsUIDs);\n }\n },\n { scope }\n );\n\n return () => {\n dataEvent?.off();\n valuesEvent?.off();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleOptionSelected = useCallback(\n async (selections: { [id: string]: { label: string; value: string } }) => {\n if (!data?.sku) return;\n\n const { persistURLParams, anchors, acdl } = config.getConfig() ?? {};\n\n // options selected\n let optionsUIDs = Object.keys(selections)\n .map((id) => selections[id].value)\n .filter((element) => element !== undefined);\n\n // set optionUIDs to URL params\n // ?optionsUIDs=1,2,3\n // only set the URL params if the \"persistURLParams\" is set to true and the product is not a bundle type\n if (persistURLParams && !data?.isBundle) {\n setUrlParams({ optionsUIDs: optionsUIDs.join(',') });\n }\n\n // check if the options have changed\n if (\n getProductConfigurationValues({ scope })?.optionsUIDs?.join('|') !==\n optionsUIDs?.join('|')\n ) {\n // update values\n setProductConfigurationValues((prev) => ({ ...prev, optionsUIDs }), {\n scope,\n });\n\n // pass the selected options to callback\n onValues?.(optionsUIDs);\n\n // refetch data\n const next = await fetchProductData(data.sku, {\n optionsUIDs: optionsUIDs ?? [],\n isBundle: data?.isBundle,\n anchors,\n });\n\n // emit the new data\n events.emit('pdp/data', next, { scope });\n\n let valid = optionsUIDs?.length === next?.options?.length;\n\n // special processing for anchor options (options that should not be refined when other options are selected)\n if (anchors?.length) {\n const updatedOptionsUIDs = next?.optionUIDs ?? [];\n\n const isMatching = optionsUIDs.every((item) =>\n updatedOptionsUIDs.includes(item)\n );\n\n if (!isMatching) {\n setSelectionsToUpdate(next?.options);\n setProductConfigurationValues(\n (prev) => ({\n ...prev,\n optionsUIDs: updatedOptionsUIDs,\n }),\n { scope }\n );\n\n valid = updatedOptionsUIDs?.length === next?.options?.length;\n }\n }\n\n // is the product valid\n setProductConfigurationValid(() => valid, { scope });\n\n // ACDL\n if (acdl && next && next?.variantSku !== data.sku) {\n publishProductPageViewEvent(next);\n }\n }\n },\n [data?.isBundle, data?.sku, onValues, scope]\n );\n\n const handleErrors = useCallback(\n (errors: { [id: string]: string }) => {\n const hasErrors = Object.keys(errors).length !== 0;\n\n if (hasErrors) {\n setProductConfigurationValid(() => false, { scope });\n onErrors?.(errors);\n }\n },\n [onErrors, scope]\n );\n\n if (!data) return null;\n\n // Only show if there are options in the data\n if (!data.options) return null;\n\n return (\n <Slot\n name=\"Swatches\"\n slot={slots?.Swatches}\n context={{ data, optionsUIDs: current }}\n >\n <Swatches\n {...props}\n options={data.options}\n selectedUIDs={current}\n defaultOptions={current}\n selectionsToUpdate={selectionsToUpdate}\n hideSelectedValue={hideSelectedValue}\n disablePreselections={!config.getConfig()?.preselectFirstOption}\n onValues={handleOptionSelected}\n onErrors={handleErrors}\n imageSwatchNode={\n slots?.SwatchImage\n ? ({ imageSwatchContext, ...imageProps }) => (\n <Slot\n name=\"SwatchImage\"\n slot={slots?.SwatchImage}\n slotTag=\"span\"\n contentTag=\"span\"\n context={{\n data,\n optionsUIDs: current,\n defaultImageProps: imageProps,\n imageSwatchContext,\n }}\n />\n )\n : undefined\n }\n />\n </Slot>\n );\n};\n\nProductOptions.getInitialData = async function (options) {\n const data = await getFetchedProductData({ scope: options?.scope });\n const optionsUIDs =\n getProductConfigurationValues({ scope: options?.scope })?.optionsUIDs ?? [];\n return { data, optionsUIDs };\n};\n"],"names":["ProductOptions","initialData","scope","hideSelectedValue","slots","onValues","onErrors","children","props","data","setData","useState","current","setCurrent","selectionsToUpdate","setSelectionsToUpdate","useEffect","dataEvent","events","valuesEvent","optionsUIDs","handleOptionSelected","useCallback","selections","persistURLParams","anchors","acdl","config","id","element","setUrlParams","_b","_a","getProductConfigurationValues","setProductConfigurationValues","prev","next","fetchProductData","valid","_c","updatedOptionsUIDs","item","_d","setProductConfigurationValid","publishProductPageViewEvent","handleErrors","errors","jsx","Slot","Swatches","imageSwatchContext","imageProps","options","getFetchedProductData"],"mappings":"goBAyDO,MAAMA,EAGT,CAAC,CACH,YAAAC,EAAc,CAAE,KAAM,KAAM,YAAa,CAAA,CAAG,EAC5C,MAAAC,EACA,kBAAAC,EAAoB,GACpB,MAAAC,EACA,SAAAC,EACA,SAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAM,OACJ,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAA8BV,EAAY,IAAI,EAEhE,CAACW,EAASC,CAAU,EAAIF,EAAmBV,EAAY,WAAW,EAElE,CAACa,EAAoBC,CAAqB,EAC9CJ,EAAkC,EAEpCK,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYR,EAAS,CAAE,MAAAR,EAAO,EAEpDiB,EAAcD,EAAO,GACzB,aACA,CAAC,CAAE,YAAAE,CAAA,IAAkB,CACfA,GACFP,EAAWO,CAAW,CAE1B,EACA,CAAE,MAAAlB,CAAM,CACV,EAEA,MAAO,IAAM,CACXe,GAAA,MAAAA,EAAW,MACXE,GAAA,MAAAA,EAAa,KACf,CAE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AS,MAAO,EAC5DhC,IACJY,EAAAC,EAA8B,CAAE,MAAOmB,GAAA,YAAAA,EAAS,KAAO,CAAA,IAAvD,YAAApB,EAA0D,cAAe,CAAC,EACrE,MAAA,CAAE,KAAAvB,EAAM,YAAAW,CAAY,CAC7B"}
|
|
@@ -3,6 +3,7 @@ import { Container } from '@dropins/tools/types/elsie/src/lib';
|
|
|
3
3
|
import { ProductModel } from '../../data/models';
|
|
4
4
|
|
|
5
5
|
export interface ProductPriceProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
scope?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare const ProductPrice: Container<ProductPriceProps, ProductModel | null>;
|
|
8
9
|
//# sourceMappingURL=ProductPrice.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as
|
|
3
|
+
import{jsxs as R,jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{useState as x,useEffect as j}from"@dropins/tools/preact-compat.js";import{classes as s,VComponent as D,toLanguageTag as L}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";/* empty css */import{P as h}from"../chunks/PriceRange.js";import"@dropins/tools/preact.js";import{useText as v}from"@dropins/tools/i18n.js";import{events as S}from"@dropins/tools/event-bus.js";import{g as C}from"../chunks/getFetchedProductData.js";import{c as T}from"../chunks/isProductConfigurationValid.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";const y=({className:o,price:r,specialPrice:t,children:n,...i})=>{const e=v("PDP.Product.RegularPrice.label").label,c=v("PDP.Product.SpecialPrice.label").label;return R("div",{...i,className:s(["pdp-price",o]),children:[t&&a(D,{node:t,className:s(["pdp-price__amount-special","pdp-price__amount"]),"aria-label":c,role:"text"}),r&&a(D,{node:r,className:s(["pdp-price__amount-regular","pdp-price__amount--grey"]),"aria-label":e,role:"text"})]})},F=({initialData:o=null,scope:r,children:t,...n})=>{var u,d,f,g,P,b,_;const{defaultLocale:i="en-US"}=T.getConfig(),[e,c]=x(o),[m,N]=x(i);return j(()=>{const l=S.on("pdp/data",c,{scope:r}),p=S.on("locale",N);return()=>{l==null||l.off(),p==null||p.off()}},[r]),!e||!e.prices?null:a(y,{...n,specialPrice:(u=e.prices)!=null&&u.visible?a(h,{...(d=e.prices)==null?void 0:d.final,locale:L(m)}):void 0,price:(f=e.prices)!=null&&f.visible&&((g=e.prices)!=null&&g.regular)&&((P=e.prices)==null?void 0:P.final.amount)!==((b=e.prices)==null?void 0:b.regular.amount)?a(h,{...(_=e.prices)==null?void 0:_.regular,locale:L(m)}):void 0})};F.getInitialData=C;export{F as ProductPrice,F as default};
|
|
4
4
|
//# sourceMappingURL=ProductPrice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductPrice.js","sources":["/@dropins/storefront-pdp/src/components/Price/Price.tsx","/@dropins/storefront-pdp/src/containers/ProductPrice/ProductPrice.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */import { FunctionComponent, VNode } from 'preact';\n\n \nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/pdp/components/Price/Price.css';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nexport interface PriceProps extends HTMLAttributes<HTMLDivElement> {\n price?: VNode;\n specialPrice?: VNode;\n}\n\nexport const Price: FunctionComponent<PriceProps> = ({\n className,\n price,\n specialPrice,\n children,\n ...props\n}) => {\n const RegularPriceLabel = useText('PDP.Product.RegularPrice.label').label;\n const SpecialPriceLabel = useText('PDP.Product.SpecialPrice.label').label;\n\n return (\n <div {...props} className={classes(['pdp-price', className])}>\n {specialPrice && (\n <VComponent\n node={specialPrice}\n className={classes([\n 'pdp-price__amount-special',\n 'pdp-price__amount',\n ])}\n aria-label={SpecialPriceLabel}\n role=\"text\"\n />\n )}\n {price && (\n <VComponent\n node={price}\n className={classes([\n 'pdp-price__amount-regular',\n 'pdp-price__amount--grey',\n ])}\n aria-label={RegularPriceLabel}\n role=\"text\"\n />\n )}\n </div>\n );\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, toLanguageTag } from '@adobe-commerce/elsie/lib';\nimport { Price, PriceRange } from '@/pdp/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { config, getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductPriceProps extends HTMLAttributes<HTMLDivElement> {}\n\nexport const ProductPrice: Container<\n ProductPriceProps,\n ProductModel | null\n> = ({ initialData = null, children, ...props }) => {\n const { defaultLocale = 'en-US' } = config.getConfig();\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const [locale, setLocale] = useState<string>(defaultLocale);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n const localeEvent = events.on('locale', setLocale);\n\n return () => {\n dataEvent?.off();\n localeEvent?.off();\n };\n }, []);\n\n if (!data || !data.prices) return null;\n\n return (\n <Price\n {...props}\n specialPrice={\n data.prices?.visible ? (\n <PriceRange {...data.prices?.final} locale={toLanguageTag(locale)} />\n ) : undefined\n }\n price={\n data.prices?.visible &&\n data.prices?.regular &&\n data.prices?.final.amount !== data.prices?.regular.amount ? (\n <PriceRange\n {...data.prices?.regular}\n locale={toLanguageTag(locale)}\n />\n ) : undefined\n }\n />\n );\n};\n\nProductPrice.getInitialData = getFetchedProductData;\n"],"names":["Price","className","price","specialPrice","children","props","RegularPriceLabel","useText","SpecialPriceLabel","jsxs","classes","jsx","VComponent","ProductPrice","initialData","defaultLocale","config","data","setData","useState","locale","setLocale","useEffect","dataEvent","events","localeEvent","_a","PriceRange","_b","toLanguageTag","_c","_d","_e","_f","_g","getFetchedProductData"],"mappings":"yoBA2BO,MAAMA,EAAuC,CAAC,CACnD,UAAAC,EACA,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAM,CACE,MAAAC,EAAoBC,EAAQ,gCAAgC,EAAE,MAC9DC,EAAoBD,EAAQ,gCAAgC,EAAE,MAGlE,OAAAE,EAAC,MAAK,CAAA,GAAGJ,EAAO,UAAWK,EAAQ,CAAC,YAAaT,CAAS,CAAC,EACxD,SAAA,CACCE,GAAAQ,EAACC,EAAA,CACC,KAAMT,EACN,UAAWO,EAAQ,CACjB,4BACA,mBAAA,CACD,EACD,aAAYF,EACZ,KAAK,MAAA,CACP,EAEDN,GACCS,EAACC,EAAA,CACC,KAAMV,EACN,UAAWQ,EAAQ,CACjB,4BACA,yBAAA,CACD,EACD,aAAYJ,EACZ,KAAK,MAAA,CAAA,CACP,EAEJ,CAEJ,
|
|
1
|
+
{"version":3,"file":"ProductPrice.js","sources":["/@dropins/storefront-pdp/src/components/Price/Price.tsx","/@dropins/storefront-pdp/src/containers/ProductPrice/ProductPrice.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */import { FunctionComponent, VNode } from 'preact';\n\n \nimport { HTMLAttributes } from 'preact/compat';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/pdp/components/Price/Price.css';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nexport interface PriceProps extends HTMLAttributes<HTMLDivElement> {\n price?: VNode;\n specialPrice?: VNode;\n}\n\nexport const Price: FunctionComponent<PriceProps> = ({\n className,\n price,\n specialPrice,\n children,\n ...props\n}) => {\n const RegularPriceLabel = useText('PDP.Product.RegularPrice.label').label;\n const SpecialPriceLabel = useText('PDP.Product.SpecialPrice.label').label;\n\n return (\n <div {...props} className={classes(['pdp-price', className])}>\n {specialPrice && (\n <VComponent\n node={specialPrice}\n className={classes([\n 'pdp-price__amount-special',\n 'pdp-price__amount',\n ])}\n aria-label={SpecialPriceLabel}\n role=\"text\"\n />\n )}\n {price && (\n <VComponent\n node={price}\n className={classes([\n 'pdp-price__amount-regular',\n 'pdp-price__amount--grey',\n ])}\n aria-label={RegularPriceLabel}\n role=\"text\"\n />\n )}\n </div>\n );\n};\n","/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, toLanguageTag } from '@adobe-commerce/elsie/lib';\nimport { Price, PriceRange } from '@/pdp/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { config, getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductPriceProps extends HTMLAttributes<HTMLDivElement> {\n scope?: string;\n}\n\nexport const ProductPrice: Container<\n ProductPriceProps,\n ProductModel | null\n> = ({ initialData = null, scope, children, ...props }) => {\n const { defaultLocale = 'en-US' } = config.getConfig();\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const [locale, setLocale] = useState<string>(defaultLocale);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n const localeEvent = events.on('locale', setLocale);\n\n return () => {\n dataEvent?.off();\n localeEvent?.off();\n };\n }, [scope]);\n\n if (!data || !data.prices) return null;\n\n return (\n <Price\n {...props}\n specialPrice={\n data.prices?.visible ? (\n <PriceRange {...data.prices?.final} locale={toLanguageTag(locale)} />\n ) : undefined\n }\n price={\n data.prices?.visible &&\n data.prices?.regular &&\n data.prices?.final.amount !== data.prices?.regular.amount ? (\n <PriceRange\n {...data.prices?.regular}\n locale={toLanguageTag(locale)}\n />\n ) : undefined\n }\n />\n );\n};\n\nProductPrice.getInitialData = getFetchedProductData;\n"],"names":["Price","className","price","specialPrice","children","props","RegularPriceLabel","useText","SpecialPriceLabel","jsxs","classes","jsx","VComponent","ProductPrice","initialData","scope","defaultLocale","config","data","setData","useState","locale","setLocale","useEffect","dataEvent","events","localeEvent","_a","PriceRange","_b","toLanguageTag","_c","_d","_e","_f","_g","getFetchedProductData"],"mappings":"yoBA2BO,MAAMA,EAAuC,CAAC,CACnD,UAAAC,EACA,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAM,CACE,MAAAC,EAAoBC,EAAQ,gCAAgC,EAAE,MAC9DC,EAAoBD,EAAQ,gCAAgC,EAAE,MAGlE,OAAAE,EAAC,MAAK,CAAA,GAAGJ,EAAO,UAAWK,EAAQ,CAAC,YAAaT,CAAS,CAAC,EACxD,SAAA,CACCE,GAAAQ,EAACC,EAAA,CACC,KAAMT,EACN,UAAWO,EAAQ,CACjB,4BACA,mBAAA,CACD,EACD,aAAYF,EACZ,KAAK,MAAA,CACP,EAEDN,GACC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'../../data/models';
|
|
4
4
|
|
|
5
5
|
export interface ProductQuantityProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
scope?: string;
|
|
6
7
|
onValue?: (quantity: number) => void;
|
|
7
8
|
}
|
|
8
9
|
export declare const ProductQuantity: Container<ProductQuantityProps, ProductModel | null>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as P}from"@dropins/tools/preact-jsx-runtime.js";import{useState as i,useEffect as y}from"@dropins/tools/preact-compat.js";import{classes as I}from"@dropins/tools/lib.js";import{Incrementer as b}from"@dropins/tools/components.js";import{events as m}from"@dropins/tools/event-bus.js";import{n as q,j as D,c as h,o as x}from"../chunks/isProductConfigurationValid.js";import{g as C}from"../chunks/getFetchedProductData.js";import{useText as S}from"@dropins/tools/i18n.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";const U=({initialData:u=null,scope:a,onValue:e,children:j,...o})=>{const l=S("PDP.Product.Incrementer.label").label,[c,f]=i(u),[s,d]=i(()=>q(1));y(()=>{const r=m.on("pdp/data",f,{scope:a}),t=m.on("pdp/values",({quantity:n})=>{d(n)},{eager:!0,scope:a});return()=>{r==null||r.off(),t==null||t.off()}},[a]);const p=r=>{const t=parseInt(r,10);D(g=>({...g,quantity:t}),{scope:a});const{persistURLParams:n}=h.getConfig()??{};n&&x({quantity:t}),e==null||e(t)};return c?P(b,{name:"quantity",defaultValue:String(s),value:String(s),min:1,"aria-label":l,onValue:p,...o,className:I(["pdp-quantity",o.className])},"quantity"):null};U.getInitialData=C;export{U as ProductQuantity,U as default};
|
|
4
4
|
//# sourceMappingURL=ProductQuantity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductQuantity.js","sources":["/@dropins/storefront-pdp/src/containers/ProductQuantity/ProductQuantity.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { Incrementer } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { ProductModel } from '@/pdp/data/models';\nimport {\n setProductConfigurationValues,\n getFetchedProductData,\n} from '@/pdp/api';\nimport {\n setUrlParams,\n getValidatedQuantityFromUrl,\n} from '@/pdp/lib/url-params';\nimport { config } from '@/pdp/api/initialize';\n\nexport interface ProductQuantityProps extends HTMLAttributes<HTMLDivElement> {\n onValue?: (quantity: number) => void;\n}\n\nexport const ProductQuantity: Container<\n ProductQuantityProps,\n ProductModel | null\n> = ({ initialData = null, onValue, children, ...props }) => {\n const IncrementerLabel = useText('PDP.Product.Incrementer.label').label;\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const [current, setCurrent] = useState(() => getValidatedQuantityFromUrl(1)); // Default quantity to 1\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n\n const valuesEvent = events.on(\n 'pdp/values',\n ({ quantity }) => {\n setCurrent(quantity);\n },\n { eager: true }\n );\n\n return () => {\n dataEvent?.off();\n valuesEvent?.off();\n };\n }, []);\n\n const handleOnValue = (value: string) => {\n const quantity = parseInt(value, 10);\n setProductConfigurationValues((prev) => ({ ...prev, quantity }));\n\n // Update URL parameters if persistURLParams is enabled\n const { persistURLParams } = config.getConfig() ?? {};\n if (persistURLParams) {\n setUrlParams({ quantity });\n }\n\n onValue?.(quantity);\n };\n\n if (!data) return null;\n\n return (\n <Incrementer\n key=\"quantity\"\n name=\"quantity\"\n defaultValue={String(current)}\n value={String(current)}\n min={1}\n aria-label={IncrementerLabel}\n onValue={handleOnValue}\n {...props}\n className={classes(['pdp-quantity', props.className])}\n />\n );\n};\n\nProductQuantity.getInitialData = getFetchedProductData;\n"],"names":["ProductQuantity","initialData","onValue","children","props","IncrementerLabel","useText","data","setData","useState","current","setCurrent","getValidatedQuantityFromUrl","useEffect","dataEvent","events","valuesEvent","quantity","handleOnValue","value","setProductConfigurationValues","prev","persistURLParams","config","setUrlParams","jsx","Incrementer","classes","getFetchedProductData"],"mappings":"+
|
|
1
|
+
{"version":3,"file":"ProductQuantity.js","sources":["/@dropins/storefront-pdp/src/containers/ProductQuantity/ProductQuantity.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { Incrementer } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { ProductModel } from '@/pdp/data/models';\nimport {\n setProductConfigurationValues,\n getFetchedProductData,\n} from '@/pdp/api';\nimport {\n setUrlParams,\n getValidatedQuantityFromUrl,\n} from '@/pdp/lib/url-params';\nimport { config } from '@/pdp/api/initialize';\n\nexport interface ProductQuantityProps extends HTMLAttributes<HTMLDivElement> {\n scope?: string;\n onValue?: (quantity: number) => void;\n}\n\nexport const ProductQuantity: Container<\n ProductQuantityProps,\n ProductModel | null\n> = ({ initialData = null, scope, onValue, children, ...props }) => {\n const IncrementerLabel = useText('PDP.Product.Incrementer.label').label;\n\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n const [current, setCurrent] = useState(() => getValidatedQuantityFromUrl(1)); // Default quantity to 1\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n\n const valuesEvent = events.on(\n 'pdp/values',\n ({ quantity }) => {\n setCurrent(quantity);\n },\n { eager: true, scope }\n );\n\n return () => {\n dataEvent?.off();\n valuesEvent?.off();\n };\n }, [scope]);\n\n const handleOnValue = (value: string) => {\n const quantity = parseInt(value, 10);\n setProductConfigurationValues((prev) => ({ ...prev, quantity }), { scope });\n\n // Update URL parameters if persistURLParams is enabled\n const { persistURLParams } = config.getConfig() ?? {};\n if (persistURLParams) {\n setUrlParams({ quantity });\n }\n\n onValue?.(quantity);\n };\n\n if (!data) return null;\n\n return (\n <Incrementer\n key=\"quantity\"\n name=\"quantity\"\n defaultValue={String(current)}\n value={String(current)}\n min={1}\n aria-label={IncrementerLabel}\n onValue={handleOnValue}\n {...props}\n className={classes(['pdp-quantity', props.className])}\n />\n );\n};\n\nProductQuantity.getInitialData = getFetchedProductData;\n"],"names":["ProductQuantity","initialData","scope","onValue","children","props","IncrementerLabel","useText","data","setData","useState","current","setCurrent","getValidatedQuantityFromUrl","useEffect","dataEvent","events","valuesEvent","quantity","handleOnValue","value","setProductConfigurationValues","prev","persistURLParams","config","setUrlParams","jsx","Incrementer","classes","getFetchedProductData"],"mappings":"+hBAqCa,MAAAA,EAGT,CAAC,CAAE,YAAAC,EAAc,KAAM,MAAAC,EAAO,QAAAC,EAAS,SAAAC,EAAU,GAAGC,KAAY,CAC5D,MAAAC,EAAmBC,EAAQ,+BAA+B,EAAE,MAE5D,CAACC,EAAMC,CAAO,EAAIC,EAA8BT,CAAW,EAE3D,CAACU,EAASC,CAAU,EAAIF,EAAS,IAAMG,EAA4B,CAAC,CAAC,EAE3EC,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYP,EAAS,CAAE,MAAAP,EAAO,EAEpDe,EAAcD,EAAO,GACzB,aACA,CAAC,CAAE,SAAAE,CAAA,IAAe,CAChBN,EAAWM,CAAQ,CACrB,EACA,CAAE,MAAO,GAAM,MAAAhB,CAAM,CACvB,EAEA,MAAO,IAAM,CACXa,GAAA,MAAAA,EAAW,MACXE,GAAA,MAAAA,EAAa,KACf,CAAA,EACC,CAACf,CAAK,CAAC,EAEJ,MAAAiB,EAAiBC,GAAkB,CACjC,MAAAF,EAAW,SAASE,EAAO,EAAE,EACLC,EAACC,IAAU,CAAE,GAAGA,EAAM,SAAAJ,IAAa,CAAE,MAAAhB,EAAO,EAG1E,KAAM,CAAE,iBAAAqB,CAAiB,EAAIC,EAAO,aAAe,CAAC,EAChDD,GACWE,EAAA,CAAE,SAAAP,EAAU,EAG3Bf,GAAA,MAAAA,EAAUe,EACZ,EAEI,OAACV,EAGHkB,EAACC,EAAA,CAEC,KAAK,WACL,aAAc,OAAOhB,CAAO,EAC5B,MAAO,OAAOA,CAAO,EACrB,IAAK,EACL,aAAYL,EACZ,QAASa,EACR,GAAGd,EACJ,UAAWuB,EAAQ,CAAC,eAAgBvB,EAAM,SAAS,CAAC,CAAA,EARhD,UASN,EAbgB,IAepB,EAEAL,EAAgB,eAAiB6B"}
|
|
@@ -3,6 +3,7 @@ import { Container } from '@dropins/tools/types/elsie/src/lib';
|
|
|
3
3
|
import { ProductModel } from '../../data/models';
|
|
4
4
|
|
|
5
5
|
export interface ProductShortDescriptionProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
scope?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare const ProductShortDescription: Container<ProductShortDescriptionProps, ProductModel | null>;
|
|
8
9
|
//# sourceMappingURL=ProductShortDescription.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as i}from"@dropins/tools/preact-jsx-runtime.js";import{useState as a,useEffect as c}from"@dropins/tools/preact-compat.js";import{classes as m}from"@dropins/tools/lib.js";import{events as l}from"@dropins/tools/event-bus.js";import{g as f}from"../chunks/getFetchedProductData.js";const u=({initialData:s=null,scope:e,children:p,...o})=>{const[t,n]=a(s);return c(()=>{const r=l.on("pdp/data",n,{scope:e});return()=>{r==null||r.off()}},[e]),t?i("div",{dangerouslySetInnerHTML:{__html:(t==null?void 0:t.shortDescription)??""},...o,className:m(["pdp-short-description",o.className])}):null};u.getInitialData=f;export{u as ProductShortDescription,u as default};
|
|
4
4
|
//# sourceMappingURL=ProductShortDescription.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductShortDescription.js","sources":["/@dropins/storefront-pdp/src/containers/ProductShortDescription/ProductShortDescription.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductShortDescriptionProps\n extends HTMLAttributes<HTMLDivElement> { }\n\nexport const ProductShortDescription: Container<\n ProductShortDescriptionProps,\n ProductModel | null\n> = ({ initialData = null, children, ...props }) => {\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData);\n\n return () => {\n dataEvent?.off();\n };\n }, []);\n\n if (!data) return null;\n\n return (\n <div\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: data?.shortDescription ?? '' }}\n {...props}\n className={classes(['pdp-short-description', props.className])}\n />\n );\n};\n\nProductShortDescription.getInitialData = getFetchedProductData;\n"],"names":["ProductShortDescription","initialData","children","props","data","setData","useState","useEffect","dataEvent","events","jsx","classes","getFetchedProductData"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProductShortDescription.js","sources":["/@dropins/storefront-pdp/src/containers/ProductShortDescription/ProductShortDescription.tsx"],"sourcesContent":["/**\n * ADOBE CONFIDENTIAL\n * __________________\n * Copyright 2024 Adobe\n * All Rights Reserved.\n * __________________\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n */\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { classes, Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ProductModel } from '@/pdp/data/models';\nimport { getFetchedProductData } from '@/pdp/api';\n\nexport interface ProductShortDescriptionProps\n extends HTMLAttributes<HTMLDivElement> {\n scope?: string;\n}\n\nexport const ProductShortDescription: Container<\n ProductShortDescriptionProps,\n ProductModel | null\n> = ({ initialData = null, scope, children, ...props }) => {\n const [data, setData] = useState<ProductModel | null>(initialData);\n\n useEffect(() => {\n const dataEvent = events.on('pdp/data', setData, { scope });\n\n return () => {\n dataEvent?.off();\n };\n }, [scope]);\n\n if (!data) return null;\n\n return (\n <div\n // eslint-disable-next-line react/no-danger\n dangerouslySetInnerHTML={{ __html: data?.shortDescription ?? '' }}\n {...props}\n className={classes(['pdp-short-description', props.className])}\n />\n );\n};\n\nProductShortDescription.getInitialData = getFetchedProductData;\n"],"names":["ProductShortDescription","initialData","scope","children","props","data","setData","useState","useEffect","dataEvent","events","jsx","classes","getFetchedProductData"],"mappings":"iSA2Ba,MAAAA,EAGT,CAAC,CAAE,YAAAC,EAAc,KAAM,MAAAC,EAAO,SAAAC,EAAU,GAAGC,KAAY,CACzD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAA8BN,CAAW,EAU7D,OARJO,EAAU,IAAM,CACd,MAAMC,EAAYC,EAAO,GAAG,WAAYJ,EAAS,CAAE,MAAAJ,EAAO,EAE1D,MAAO,IAAM,CACXO,GAAA,MAAAA,EAAW,KACb,CAAA,EACC,CAACP,CAAK,CAAC,EAELG,EAGHM,EAAC,MAAA,CAEC,wBAAyB,CAAE,QAAQN,GAAA,YAAAA,EAAM,mBAAoB,EAAG,EAC/D,GAAGD,EACJ,UAAWQ,EAAQ,CAAC,wBAAyBR,EAAM,SAAS,CAAC,CAAA,CAC/D,EARgB,IAUpB,EAEAJ,EAAwB,eAAiBa"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-pdp", "version": "
|
|
1
|
+
{"name": "@dropins/storefront-pdp", "version": "2.0.0-alpha100", "@dropins/tools": "1.4.1-alpha100", "license": "SEE LICENSE IN LICENSE.md"}
|