@dropins/storefront-pdp 0.5.0-beta4 → 1.0.0-beta1
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/__mocks__/product-mocks.d.ts +1 -0
- package/api/fetchProductData/fetchProductData.d.ts +24 -0
- package/api/fetchProductData/index.d.ts +17 -0
- package/api/getFetchedProductData/getFetchedProductData.d.ts +4 -0
- package/api/getFetchedProductData/index.d.ts +17 -0
- package/api/getProductConfigurationValues/getProductConfigurationValues.d.ts +4 -0
- package/api/getProductConfigurationValues/index.d.ts +17 -0
- package/api/getProductData/getProductData.d.ts +4 -1
- package/api/getRefinedProduct/getRefinedProduct.d.ts +1 -1
- package/api/index.d.ts +6 -0
- package/api/initialize/initialize.d.ts +9 -1
- package/api/isProductConfigurationValid/index.d.ts +17 -0
- package/api/isProductConfigurationValid/isProductConfigurationValid.d.ts +17 -0
- package/api/setProductConfigurationValid/index.d.ts +17 -0
- package/api/setProductConfigurationValid/setProductConfigurationValid.d.ts +17 -0
- package/api/setProductConfigurationValues/index.d.ts +17 -0
- package/api/setProductConfigurationValues/setProductConfigurationValues.d.ts +4 -0
- package/api.js +3 -1
- package/chunks/PriceRange.js +3 -0
- package/chunks/Swatches.js +3 -0
- package/chunks/Zoom.js +3 -0
- package/chunks/date.js +3 -0
- package/chunks/fetchProductData.js +187 -0
- package/chunks/getFetchedProductData.js +3 -0
- package/chunks/getProductConfigurationValues.js +3 -0
- package/chunks/isProductConfigurationValid.js +3 -0
- package/components/Header/Header.d.ts +10 -0
- package/components/Header/index.d.ts +18 -0
- package/components/Price/Price.d.ts +9 -0
- package/components/Price/index.d.ts +18 -0
- package/components/index.d.ts +2 -0
- package/containers/ProductAttributes/ProductAttributes.d.ts +8 -0
- package/containers/ProductAttributes/index.d.ts +18 -0
- package/containers/ProductAttributes.d.ts +3 -0
- package/containers/ProductAttributes.js +3 -0
- package/containers/ProductDescription/ProductDescription.d.ts +8 -0
- package/containers/ProductDescription/index.d.ts +18 -0
- package/containers/ProductDescription.d.ts +3 -0
- package/containers/ProductDescription.js +3 -0
- package/containers/ProductDetails.js +3 -1
- package/containers/ProductGallery/ProductGallery.d.ts +18 -0
- package/containers/ProductGallery/index.d.ts +3 -0
- package/containers/ProductGallery.d.ts +3 -0
- package/containers/ProductGallery.js +3 -0
- package/containers/ProductHeader/ProductHeader.d.ts +9 -0
- package/containers/ProductHeader/index.d.ts +18 -0
- package/containers/ProductHeader.d.ts +3 -0
- package/containers/ProductHeader.js +3 -0
- package/containers/ProductOptions/ProductOptions.d.ts +22 -0
- package/containers/ProductOptions/index.d.ts +18 -0
- package/containers/ProductOptions.d.ts +3 -0
- package/containers/ProductOptions.js +3 -0
- package/containers/ProductPrice/ProductPrice.d.ts +8 -0
- package/containers/ProductPrice/index.d.ts +18 -0
- package/containers/ProductPrice.d.ts +3 -0
- package/containers/ProductPrice.js +3 -0
- package/containers/ProductQuantity/ProductQuantity.d.ts +9 -0
- package/containers/ProductQuantity/index.d.ts +18 -0
- package/containers/ProductQuantity.d.ts +3 -0
- package/containers/ProductQuantity.js +3 -0
- package/containers/ProductShortDescription/ProductShortDescription.d.ts +8 -0
- package/containers/ProductShortDescription/index.d.ts +18 -0
- package/containers/ProductShortDescription.d.ts +3 -0
- package/containers/ProductShortDescription.js +3 -0
- package/containers/index.d.ts +8 -0
- package/data/models/acdl-models.d.ts +9 -1
- package/data/models/index.d.ts +1 -0
- package/data/models/product-model.d.ts +4 -15
- package/data/models/values-model.d.ts +6 -0
- package/data/transforms/product-transform.d.ts +3 -1
- package/package.json +1 -1
- package/render.js +4 -2
- package/chunks/getRefinedProduct.js +0 -185
- package/chunks/initialize.js +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export type Options = {
|
|
17
|
+
anchors?: string[];
|
|
18
|
+
optionsUIDs?: string[];
|
|
19
|
+
preselectFirstOption?: boolean;
|
|
20
|
+
isBundle?: boolean;
|
|
21
|
+
initialData?: any;
|
|
22
|
+
};
|
|
23
|
+
export declare const fetchProductData: (sku: string, options?: Options) => Promise<import('../../data/models/product-model').ProductModel | null>;
|
|
24
|
+
//# sourceMappingURL=fetchProductData.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './fetchProductData';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './getFetchedProductData';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './getProductConfigurationValues';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ProductModel } from '../../data/models';
|
|
2
2
|
|
|
3
|
-
export declare const getProductData: (sku: string
|
|
3
|
+
export declare const getProductData: (sku: string, options?: {
|
|
4
|
+
preselectFirstOption?: boolean;
|
|
5
|
+
optionsUIDs?: string[];
|
|
6
|
+
}) => Promise<ProductModel | null>;
|
|
4
7
|
//# sourceMappingURL=getProductData.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ProductModel } from '../../data/models';
|
|
2
2
|
|
|
3
|
-
export declare const getRefinedProduct: (sku: string, optionUIDs: string[], anchorOptions?: string[]
|
|
3
|
+
export declare const getRefinedProduct: (sku: string, optionUIDs: string[], anchorOptions?: string[]) => Promise<ProductModel | null>;
|
|
4
4
|
//# sourceMappingURL=getRefinedProduct.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -17,4 +17,10 @@ export * from './initialize';
|
|
|
17
17
|
export * from './fetch-graphql';
|
|
18
18
|
export * from './getProductData';
|
|
19
19
|
export * from './getRefinedProduct';
|
|
20
|
+
export * from './fetchProductData';
|
|
21
|
+
export * from './setProductConfigurationValues';
|
|
22
|
+
export * from './getProductConfigurationValues';
|
|
23
|
+
export * from './setProductConfigurationValid';
|
|
24
|
+
export * from './getFetchedProductData';
|
|
25
|
+
export * from './isProductConfigurationValid';
|
|
20
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -5,10 +5,18 @@ import { ProductModel } from '../../data/models';
|
|
|
5
5
|
type ConfigProps = {
|
|
6
6
|
langDefinitions?: Lang;
|
|
7
7
|
defaultLocale?: string;
|
|
8
|
+
sku?: string;
|
|
9
|
+
acdl?: boolean;
|
|
10
|
+
anchors?: string[];
|
|
11
|
+
persistURLParams?: boolean;
|
|
12
|
+
preselectFirstOption?: boolean;
|
|
13
|
+
optionsUIDs?: string[];
|
|
8
14
|
models?: {
|
|
9
15
|
[name: string]: {
|
|
10
16
|
initialData: any;
|
|
11
|
-
|
|
17
|
+
/** @deprecated Use "transformer" instead */
|
|
18
|
+
transform?: (data?: ProductModel) => ProductModel;
|
|
19
|
+
transformer?: (data?: ProductModel) => ProductModel;
|
|
12
20
|
fallbackData?: (parentProduct: any, simpleProduct: ProductModel) => ProductModel;
|
|
13
21
|
};
|
|
14
22
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './isProductConfigurationValid';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isProductConfigurationValid: () => boolean | null;
|
|
17
|
+
//# sourceMappingURL=isProductConfigurationValid.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './setProductConfigurationValid';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export declare const setProductConfigurationValid: (callback: (prev: boolean) => boolean) => void;
|
|
17
|
+
//# sourceMappingURL=setProductConfigurationValid.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './setProductConfigurationValues';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
package/api.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{c as s,f as i,h as d,g as c,d as f,e as g,i as n,r as u,s as p,a as h,b as l}from"./chunks/fetchProductData.js";import{g as P,s as C}from"./chunks/getProductConfigurationValues.js";import{i as F,s as G}from"./chunks/isProductConfigurationValid.js";import{g as V}from"./chunks/getFetchedProductData.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";export{s as config,i as fetchGraphQl,d as fetchProductData,c as getConfig,V as getFetchedProductData,P as getProductConfigurationValues,f as getProductData,g as getRefinedProduct,n as initialize,F as isProductConfigurationValid,u as removeFetchGraphQlHeader,p as setEndpoint,h as setFetchGraphQlHeader,l as setFetchGraphQlHeaders,G as setProductConfigurationValid,C as setProductConfigurationValues};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsx as r,Fragment as h,jsxs as l}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Price as s}from"@dropins/tools/components.js";const o=({amount:e,currency:p,locale:d,variant:g,sale:t,minimumAmount:i,maximumAmount:n,className:a,...c})=>r(h,{children:e||i===n?r("div",{className:"pdp-price-range",...c,children:r(s,{amount:e||i,currency:p,locale:d,variant:g,sale:t,className:a})}):l("div",{className:"pdp-price-range",...c,children:[r(s,{amount:i,currency:p,locale:d,className:a}),r("span",{className:"pdp-price-range__label",children:"-"}),r(s,{amount:n,currency:p,locale:d,className:a})]})});export{o as P};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsx as h,jsxs as J}from"@dropins/tools/preact-jsx-runtime.js";import{useState as M,useEffect as P,useMemo as R,useCallback as _}from"@dropins/tools/preact-compat.js";import{classes as N}from"@dropins/tools/lib.js";import{Picker as z,ColorSwatch as A,ImageSwatch as y,TextSwatch as B}from"@dropins/tools/components.js";/* empty css */import{useText as C}from"@dropins/tools/i18n.js";const D=["text","image","color","dropdown"],F=d=>d.map(s=>({...s,text:s.label,disabled:!s.inStock}));function G(d,s){return d.reduce((x,i)=>{const n=s==null?void 0:s.find(f=>f.items.find(w=>w.id===i));if(!n)return x;const b=n.items.find(f=>f.id===i);return{...x,[n.id]:{label:b.label,value:b.id}}},{})}const E=({options:d,hideSelectedValue:s,disablePreselections:x,selectedUIDs:i,onValues:n,onErrors:b,defaultOptions:f,selectionsToUpdate:w,className:L,children:H,...O})=>{const q=C("PDP.Swatches.Required.label").label,k=C("PDP.Swatches.ChooseOption.label").label,[S,m]=M(()=>d==null?void 0:d.reduce((r,e)=>{const{items:a}=e,t=a==null?void 0:a.find(c=>f==null?void 0:f.includes(c.id)),u=a==null?void 0:a.find(c=>c.selected);return t?{...r,[e.id]:{label:t.label,value:t.id}}:u?{...r,[e.id]:{label:u.label,value:u.id}}:r},{}));P(()=>{if(i){const l=G(i,d);if(JSON.stringify(l)===JSON.stringify(S))return;m(r=>{let e={...r,...l};return n==null||n(e),e})}},[i]),P(()=>{w==null||w.forEach(l=>{m(r=>{var t;const e=(t=l==null?void 0:l.items)==null?void 0:t.find(u=>u.selected);return e?{...r,[l.id]:{label:e==null?void 0:e.label,value:e==null?void 0:e.id}}:r})})},[w,m]),R(()=>{const l=d==null?void 0:d.reduce((r,e)=>{var t;let a=!1;return(t=e==null?void 0:e.items)==null||t.forEach(u=>{var v;((v=S[e.id])==null?void 0:v.value)===u.id&&(a=!0)}),e.required&&!a&&(r[e.id]=q),r},{});return b==null||b(l),l},[S]);const g=_((l,r,e)=>{m(a=>{let t={...a,...l&&{[l]:{label:r,value:e}}};return r===k&&delete t[l],n==null||n(t,e),t})},[n]),$=_((l,r)=>{var a;const e=((a=r.selectedOptions[0])==null?void 0:a.label)??"";g(l,e,r.value)},[g]),j=_(({items:l,id:r,required:e,type:a,selected:t,label:u})=>(l==null?void 0:l.length)>0&&h("div",{className:N(["pdp-swatches__options"]),children:(a==null?void 0:a.toLowerCase())==="dropdown"?h(z,{"aria-label":u,placeholder:x?k:void 0,handleSelect:c=>$(r,c.target),options:F(l),value:t}):l==null?void 0:l.map(c=>{const v={key:c.id,id:c.id,name:r,value:c.value,label:c.label,groupAriaLabel:u,selected:t===c.id,outOfStock:!c.inStock,required:e===null?!0:e,onValue:()=>{g(r,c.label,c.id)}};switch(a){case"text":return h(B,{...v,label:c.label});case"image":return h(y,{...v,src:c.value,alt:c.label});case"color":return h(A,{...v,size:"large",color:c.value});default:return console.warn(`Invalid swatch type ${a}`),null}})}),[k,g,$]);return h("div",{...O,className:N(["pdp-swatches",L]),children:d==null?void 0:d.map(({type:l,label:r,id:e,multiple:a,required:t,items:u})=>{var c;return D.includes(l)||console.warn(`Invalid swatch type ${l}`),a&&console.warn("Multiple selection swatches are not currently supported."),J("div",{id:`swatch-item-${e}`,"data-slot-key":`product-swatch--${e}`,className:"pdp-swatches__field",children:[h("div",{className:"pdp-swatches__field__label",children:S[e]?s?`${r}`:`${r}: ${S[e].label}`:r}),h(j,{id:e,type:l,required:t,items:u,label:r,selected:(c=S[e])==null?void 0:c.value})]},`swatch-item-${e}`)})})};export{E as S};
|
package/chunks/Zoom.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{jsxs as z,jsx as L,Fragment as _e}from"@dropins/tools/preact-jsx-runtime.js";import*as I from"@dropins/tools/preact-compat.js";import{useState as k,Children as R,useRef as le,useMemo as be,useEffect as B,useCallback as V}from"@dropins/tools/preact-compat.js";import{debounce as ve,classes as M}from"@dropins/tools/lib.js";import{Button as he,Icon as Ne}from"@dropins/tools/components.js";/* empty css */import{useText as S}from"@dropins/tools/i18n.js";import{cloneElement as Ee}from"@dropins/tools/preact.js";const We=i=>I.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},I.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),Le=i=>I.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},I.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),I.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),ke=24,ye=16,H=2,De="32";var Ce=(i=>(i[i.small=16]="small",i[i.medium=24]="medium",i[i.large=64]="large",i))(Ce||{});const He=({show:i=1,scrollbar:y=!1,peak:v=!1,arrows:p=!1,controls:l="dots",arrowsOnMainImage:W=!1,loop:n=!1,gap:C=null,direction:P="horizontal",width:N="100%",height:X="100%",defaultIndex:D=0,className:ae,children:E,thumbnails:Y=null,isZoomed:J,...Q})=>{const G=S("PDP.Carousel.label").label,ee=S("PDP.Carousel.Slide.label").label,te=S("PDP.Carousel.Previous.label").label,re=S("PDP.Carousel.Next.label").label,ce=S("PDP.Carousel.Controls.label").label,oe=S("PDP.Carousel.Controls.Button.label").label,[d,ie]=k(()=>we(i)),r=Math.ceil(R.count(E)/d),h=v?ke:0,m=C?Ce[C]:0,x=R.count(E)%d,[a,O]=k(n?w()?D-1:D+1:D),$=le([]),[Z,ue]=k(0),[j,Me]=k(0),fe=be(()=>R.toArray(Y),[Y]),g=be(()=>{const e=R.toArray(E).reduce((t,s,o)=>o%d===0?[...t,[s]]:[...t.slice(0,-1),[...t[t.length-1],s]],[]);return!n||e.length===1?e:n&&R.count(E)%d===0?[e[r-1]].concat(e).concat([e[0],e[1]]):[R.toArray(E).slice(-d)].concat(e).concat([e[0],e[1]])},[E,d,r,n]),F=le(null),pe=le(null),_=l==="thumbnailsRow"||l==="thumbnailsColumn";B(()=>{const e=F.current;if(!e)return;const t=ve(()=>{ue(e.offsetWidth??0),Me(e.offsetHeight??0);const o=window.innerWidth,u=we(i,o);u!==d&&ie(u)},50),s=new ResizeObserver(t);return s.observe(e),()=>{s.unobserve(e)}},[d,i]);const K=V(e=>{const t=n?e-1:e,s=$==null?void 0:$.current[0],o=(s==null?void 0:s.offsetWidth)+ye,u=(s==null?void 0:s.offsetHeight)+ye,c=pe.current,T=l==="thumbnailsRow",ne=l==="thumbnailsColumn",A=T?c==null?void 0:c.offsetWidth:c==null?void 0:c.offsetHeight,f=T?o:u;(T||ne)&&A&&(f*(t+1)>A&&(c.style.scrollBehavior="smooth",T?c.scrollLeft=w()?c.scrollWidth-c.clientWidth-(t+H)*f:(t+H)*f:c.scrollTop=(t+H)*f),(w()&&(T?c.scrollLeft:c.scrollTop)<=-f*t||!w()&&(T?c.scrollLeft:c.scrollTop)>f*t)&&(c.style.scrollBehavior="smooth",T?c.scrollLeft=w()?-(t-H)*f:(t-H)*f:c.scrollTop=(t-H)*f))},[l,n]);B(()=>{K(a)},[a,K]);const b=V((e,t,s)=>{_&&K(e);const o=F.current,u=h?o.offsetWidth-h:o.offsetWidth-h+m;if(!Array.from(o.querySelectorAll("[data-index]")).filter(A=>{const f=Number(A.getAttribute("data-index"));return!isNaN(f)&&f>-1})[e])return;if(s){const A=e===0?r:0,f=u*(r+(x||d)/d);if(w()){if(o.scrollLeft<=0&&o.scrollLeft>-(u-5)){b(1,!0);return}if(o.scrollLeft<u-f&&o.scrollLeft>=-f){b(r,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=A===0?0:-f,b(A===0?1:r,!0)}else{if(o.scrollLeft>=0&&o.scrollLeft<u-5){b(1,!0);return}if(o.scrollLeft>f-u&&o.scrollLeft<=f){b(r,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=A===0?0:f,b(A===0?1:r,!0);return}}const ne=(o.offsetWidth-m)/d*g[e].length-h;o.style.scrollBehavior=t?"smooth":"auto",o.scrollLeft=w()?-(g[e].length===d?u*e:u*(e-1)-ne):g[e].length===d?u*e:u*(e-1)+ne},[m,r,h,d,x,g,K,l]),q=V(()=>{if(n){const t=a-1;b(t,!0,w()?a===r-1:a===1);return}const e=a<=0?0:a-1;b(e,!0)},[a,b,n]),U=V(()=>{const e=g.length-1;if(n){const s=a+1;b(s,!0,w()?a===0:a===r);return}const t=a>=e?e:a+1;b(t,!0)},[g.length,n,a,b,r]);B(()=>{const e=t=>{t.key==="ArrowLeft"&&(t.preventDefault(),w()?U():q()),t.key==="ArrowRight"&&(t.preventDefault(),w()?q():U())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[U,q]),B(()=>{b(n?D+1:D,!1)},[D,b,n]);const de=ve(()=>{const e=F.current,t=h?e.offsetWidth-h:e.offsetWidth-h+m,s=Math.abs(e.scrollLeft)/t,o=Math.abs(Math.round(s)-s<1?Math.round(s):Math.ceil(s));if(_&&K(o),n){const u=t*(r+(x||d)/d),c=w()?-e.scrollLeft:e.scrollLeft;if(Math.ceil(Math.abs(c))>=Math.ceil(u)-5){e.style.scrollBehavior="auto",e.scrollLeft=w()?-e.offsetWidth+(Math.ceil(c)-Math.ceil(u)-h):e.offsetWidth+(Math.ceil(c)-Math.ceil(u)-h);return}if(Math.abs(c)===0){e.style.scrollBehavior="auto",e.scrollLeft=w()?-(u-e.offsetWidth+h):u-e.offsetWidth+h;return}}a!==o&&O(o)},100);B(()=>{const e=F.current;return e==null||e.addEventListener("scroll",de),()=>{e==null||e.removeEventListener("scroll",de)}},[de]);const se=(e,t,s)=>L(he,{className:M([["pdp-carousel__button",!e],[`pdp-carousel__button--${t}`,!e],[`pdp-carousel__button--${l}`,e]]),style:{"--height":`${j}px`},variant:"tertiary","aria-label":t==="next"?re:te,onClick:s,disabled:n?!1:t==="next"?a>=g.length-1:a<1,children:L(Ne,{className:M([["pdp-carousel__button__icon",!e],[`pdp-carousel__button__icon--${t}`,!e],[`pdp-carousel__button__icon--${l}--${t}`,e]]),size:De,source:We})}),me=p&&g.length!=1&&se(_,"prev",q),ge=p&&g.length!=1&&se(_,"next",U),Pe=p&&g.length!=1&&se(!1,"prev",q),xe=p&&g.length!=1&&se(!1,"next",U);return z("div",{role:"region","aria-roledescription":G,className:M(["pdp-carousel",["pdp-carousel--main-image-controls",W],["pdp-carousel--arrows",p&&!_],[`pdp-carousel--${l}`,_],ae]),style:{"--flex-carousel":l==="thumbnailsColumn"?"row-reverse":"column","--gap":_?"0":"var(--spacing-small)","--width":N},...Q,children:[L("div",{ref:F,className:M(["pdp-carousel__wrapper",`pdp-carousel__wrapper--${P}`,["pdp-carousel__wrapper--scrollbar",y],["pdp-carousel__wrapper--peak",v]]),style:{"--total-width":l==="thumbnailsColumn"?"81.6%":"100%","--height":l==="thumbnailsColumn"?"auto":X,"--gap":C?`var(--spacing-${C})`:"0px","--per-page":d},tabIndex:0,children:g.map((e,t)=>{const s=e.length<d;return L("div",{role:"group","aria-roledescription":ee,"data-index":t,className:M(["pdp-carousel__slide",`pdp-carousel__slide--${P}`,["pdp-carousel__slide--active",a===t],["pdp-carousel__slide--orphan",s]]),style:{"--length":e.length},children:e},t)})}),!_&&z(_e,{children:[me,ge]}),_&&W&&z(_e,{children:[Pe,xe]}),l&&g.length!=1&&z("div",{className:M([[`pdp-carousel__controls__container--${l}`,_],["pdp-carousel__controls__container--no-arrows",!p||W]]),style:{"--width":l==="thumbnailsRow"?`${Z}px`:N,"--height":`${j}px`,"--nr-thumbnails":fe.length},children:[(_||J)&&!W&&me,L("div",{ref:pe,className:M([[`pdp-carousel__controls__wrapper--${l}`,_],["pdp-carousel__controls__wrapper",_]]),children:L("div",{role:"group","aria-label":ce,className:M(["pdp-carousel__controls",[`pdp-carousel__controls--${l}`,_]]),children:(n?g.slice(0,r):g).map((e,t)=>{const s=n?r:g.length,o=n?a-1===t:a===t;return _?z("label",{className:M(["pdp-carousel__thumbnail__container"]),ref:u=>{u&&($.current[t]=u)},children:[L("input",{type:"radio",name:"carousel-thumbnails","aria-label":oe.replace("{key}",String(t+1)).replace("{total}",String(s)),checked:o&&Z!==0,onChange:()=>{b(n?t+1:t,!0)},...Q,className:M(["pdp-carousel__thumbnail",["pdp-carousel__thumbnail--selected",o&&Z!==0]])}),L("span",{className:M(["pdp-carousel__thumbnail__span"]),children:fe[t]})]},t):L("button",{"aria-label":oe.replace("{key}",String(t+1)).replace("{total}",String(s)),onClick:()=>{b(n?t+1:t,!0)},className:M(["pdp-carousel__controls__button",["pdp-carousel__controls__button--active",o]])},t)})})}),(_||J)&&!W&&ge]})]})};function we(i,y=0){if(typeof i=="number")return i;const{small:v,medium:p,large:l}=i,n=[{breakpoint:1024,value:l},{breakpoint:786,value:p},{breakpoint:0,value:v}].find(({breakpoint:C})=>y>C);return n?n.value:v}function w(){return document.documentElement.dir==="rtl"}const Xe=({centered:i,onClose:y,className:v,children:p,...l})=>{const W=S("PDP.Overlay.Close.label").label,n=le(null),C=V(()=>{y==null||y()},[y]);return B(()=>{const P=N=>{N.key==="Escape"&&C()};return document.addEventListener("keydown",P),()=>{document.removeEventListener("keydown",P)}},[C]),B(()=>{const P=n.current;P==null||P.focus();const N=document.scrollingElement,X=N.style.overflow;return N.style.overflow="hidden",()=>{N.style.overflow=X}},[]),z("div",{...l,className:M(["pdp-overlay",["pdp-overlay--centered",i],v]),ref:n,role:"dialog","aria-describedby":"overlay-content",tabindex:0,children:[L("div",{className:"pdp-overlay__content",id:"overlay-content",children:p}),L(he,{"aria-label":W,variant:"tertiary",className:"pdp-overlay__close-button",onClick:C,icon:L(Le,{})})]})},Ye=({children:i,scale:y=2,closeButton:v=!0})=>{const[p,l]=k(!1),[W,n]=k("pdp-zoom"),[C,P]=k(!1),[N,X]=k({x:0,y:0}),[D,ae]=k({x:0,y:0}),[E,Y]=k({x:0,y:0}),J=r=>{!p||r.type!=="touchstart"||(X({x:r.touches[0].clientX,y:r.touches[0].clientY}),ae({x:E.x,y:E.y}),P(!0))},Q=r=>{var j;if(!C||r.type!=="touchmove")return;const h=(j=r.currentTarget)==null?void 0:j.getBoundingClientRect(),m=(100-100/y)/2,x=r.touches[0].clientX-N.x,a=r.touches[0].clientY-N.y,O=x*100/(h.width*y),$=a*100/(h.height*y),Z=D.x+O,ue=D.y+$;Y({x:Math.max(-m,Math.min(Z,m))||0,y:Math.max(-m,Math.min(ue,m))||0}),r.preventDefault()},G=r=>{var $;const h=($=r.currentTarget)==null?void 0:$.getBoundingClientRect(),m=(100-100/y)/2;let x;if("touches"in r)x=r.touches[0];else if(r instanceof MouseEvent)x=r;else return;const a=m-(x.clientX-h.left)/h.width*100,O=m-(x.clientY-h.top)/h.height*100;Y({x:Math.max(-m,Math.min(a,m))||0,y:Math.max(-m,Math.min(O,m))||0})},ee=r=>{if(!C){if(p){if(v&&"touches"in r){J(r);return}v||l(!1)}else l(!0),G(r);r.preventDefault()}},te=r=>{if(v&&"touches"in r){Q(r);return}p&&G(r)},re=()=>{if(v){P(!1);return}l(!1)},ce=r=>{l(!1),r.stopPropagation()},oe=p?`scale(${y}) translateX(${E.x}%) translateY(${E.y}%)`:"none",d=S("PDP.Zoom.Close.label").label,ie=Ee(R.only(i),{draggable:!1,style:{"--transform":oe}});return B(()=>{n(p?`pdp-zoom ${v?"pdp-zoom--no-effects":"pdp-zoom--zoomed"}`:"pdp-zoom")},[p,v]),z("figure",{className:W,onClick:ee,onMouseMove:te,onMouseLeave:re,onTouchStart:ee,onTouchMove:te,onTouchEnd:re,children:[ie,v&&p&&L(he,{"aria-label":d,variant:"tertiary",className:"pdp-zoom__close-button",icon:L(Le,{}),onClick:ce})]})};export{He as C,Xe as O,Ye as Z};
|
package/chunks/date.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{toLanguageTag as n}from"@dropins/tools/lib.js";function a(t,d="en_US"){if(!o(t))throw Error("Invalid date string");return t.split(" ")[1]||(t=`${t} 00:00:00`),new Date(t).toLocaleDateString(n(d)).toString()}function o(t){if(![/^\d{4}-\d{2}-\d{2}$/,/^\d{1,2}\/\d{1,2}\/\d{4}$/,/^\d{2}\/\d{2}\/\d{4}$/,/^\d{4}\/\d{2}\/\d{2}$/,/^\d{1,2}\.\d{1,2}\.\d{4}$/,/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/].some(i=>i.test(t)))return!1;const e=new Date(t);return!isNaN(e.getTime())}export{o as i,a as t};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{Initializer as ue,merge as oe}from"@dropins/tools/lib.js";import{events as K}from"@dropins/tools/event-bus.js";import{FetchGraphQL as se}from"@dropins/tools/fetch-graphql.js";import{s as le}from"./getProductConfigurationValues.js";function Le(e){const r=new URLSearchParams(window.location.search);Object.entries(e).forEach(([n,t])=>{t===null?r.delete(n):r.set(n,String(t))});let i=window.location.pathname;i+=`?${r.toString()}`,i+=window.location.hash,window.history.replaceState({},"",i)}function me(){const e=new URLSearchParams(window.location.search),r={};return e.forEach((i,n)=>{r[n]=i}),r}function ce(e){var r,i,n,t,a,u,o,s,l,m,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=(r=e==null?void 0:e.prices)==null?void 0:r.regular)==null?void 0:i.amount)||0,minimalPrice:(t=(n=e==null?void 0:e.prices)==null?void 0:n.final)==null?void 0:t.minimumAmount,maximalPrice:(u=(a=e==null?void 0:e.prices)==null?void 0:a.final)==null?void 0:u.maximumAmount,specialPrice:(s=(o=e==null?void 0:e.prices)==null?void 0:o.final)==null?void 0:s.amount,tierPricing:void 0,currencyCode:((m=(l=e==null?void 0:e.prices)==null?void 0:l.final)==null?void 0:m.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 fe={PRODUCT_CONTEXT:"productContext"},de={PRODUCT_PAGE_VIEW:"product-page-view"};function ne(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function Pe(e,r){const i=ne();i.push({[e]:null}),i.push({[e]:r})}function we(e,r){ne().push(n=>{const t=n.getState?n.getState():{};n.push({event:e,eventInfo:{...t,...r}})})}function ye(e){const r=ce(e);Pe(fe.PRODUCT_CONTEXT,r),we(de.PRODUCT_PAGE_VIEW)}const q=new ue({init:async e=>{var t,a,u,o,s;const n={...{defaultLocale:"en-US",persistURLParams:!1,acdl:!1,optionsUIDs:((t=me().optionsUIDs)==null?void 0:t.split(","))||((o=(u=(a=e==null?void 0:e.models)==null?void 0:a.ProductDetails)==null?void 0:u.initialData)==null?void 0:o.optionsUIDs)},...e};if(q.config.setConfig({...n}),n!=null&&n.sku){const l=await te(n.sku,{preselectFirstOption:n.preselectFirstOption,initialData:(s=n.models)==null?void 0:s.ProductDetails.initialData});K.emit("pdp/data",l);const m={sku:n.sku,quantity:1,optionsUIDs:l==null?void 0:l.optionUIDs};le(()=>({...m})),n.acdl&&l&&ye(l)}},listeners:()=>[K.on("locale",async()=>{const{sku:e}=q.config.getConfig();if(e){const r=await te(e);K.emit("pdp/data",r)}})]}),y=q.config,{setEndpoint:Ge,setFetchGraphQlHeader:Me,removeFetchGraphQlHeader:Ne,setFetchGraphQlHeaders:Qe,fetchGraphQl:re,getConfig:je}=new se().getMethods();var H=(e=>(e.ComplexProduct="complex",e.SimpleProduct="simple",e))(H||{}),ie=(e=>(e.ComplexProductView="ComplexProductView",e.SimpleProductView="SimpleProductView",e))(ie||{});function Q(e,r){var u,o,s,l,m,c,f,d,P,k,h,v;const i=((l=(s=(o=(u=e==null?void 0:e.options)==null?void 0:u[0])==null?void 0:o.values)==null?void 0:s[0])==null?void 0:l.__typename)==="ProductViewOptionValueProduct",n=Ce(e,i,r==null?void 0:r.preselectFirstOption),t=(e==null?void 0:e.__typename)===ie.SimpleProductView?H.SimpleProduct:H.ComplexProduct,a=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:ge(e),prices:Se(e,i,n),attributes:he(e),options:De(e,i),optionUIDs:n,url:e.url,urlKey:e.urlKey,externalId:e.externalId,externalParentId:e.externalParentId,variantSku:e.variantSku,productType:t}:null;return oe(a,((d=(f=(c=(m=y.getConfig())==null?void 0:m.models)==null?void 0:c.ProductDetails)==null?void 0:f.transformer)==null?void 0:d.call(f,e))??((v=(h=(k=(P=y.getConfig())==null?void 0:P.models)==null?void 0:k.ProductDetails)==null?void 0:h.transform)==null?void 0:v.call(h,e)))}function ge(e){var r,i;return(i=(r=e.images)==null?void 0:r.filter(n=>{var t;return!((t=n.roles)!=null&&t.includes("hide_from_pdp"))}))==null?void 0:i.map(n=>(n.url=n.url.replace(/^https?:/,""),n))}function he(e){var r,i;return(i=(r=e.attributes)==null?void 0:r.filter(({roles:n})=>(n==null?void 0:n.indexOf("visible_in_pdp"))!==-1))==null?void 0:i.map(({label:n,value:t,name:a})=>({id:a,label:n,value:t.toString().split(",").join(", ")}))}function De(e,r){const{options:i,optionUIDs:n}=e;return i==null?void 0:i.map(({id:t,title:a,required:u,multi:o,values:s})=>{var c;const l=(c=s==null?void 0:s[0])==null?void 0:c.__typename;let m=s==null?void 0:s[0].type;return m?m=m.replace("COLOR_HEX","color").replace("TEXT","text").replace("IMAGE","image"):m="dropdown",{id:t,type:m,typename:l,label:a,required:u,multiple:o,items:r?pe(s,n):xe(s,n,m)}})}function pe(e,r){return e==null?void 0:e.map(({id:i,title:n,inStock:t,isDefault:a,product:u})=>({id:i,inStock:t,label:n,selected:(r==null?void 0:r.indexOf(i))>-1||a,value:i,product:u}))}function xe(e,r,i){return e==null?void 0:e.map(({id:n,title:t,inStock:a,value:u})=>({id:n,inStock:a,label:t,selected:(r==null?void 0:r.indexOf(n))>-1,value:(i==null?void 0:i.toLowerCase())==="dropdown"?n:u==null?void 0:u.replace(/^https?:/,"")}))}function Se(e,r,i){var h,v,X,B,z;const{price:n,priceRange:t,options:a,optionUIDs:u=i}=e;let{__typename:o}=e;function s(){var x;const D=n.regular.amount.value,w=((x=n.final)==null?void 0:x.amount.value)??n.regular.amount.value,p=n.regular.amount.currency==="NONE"?"USD":n==null?void 0:n.regular.amount.currency;return[D,w,w,p]}function l(){var C,O,E,T,_,V,I,F,A,U,$,L;const D=(C=t==null?void 0:t.minimum)==null?void 0:C.final.amount.value,w=(O=t==null?void 0:t.maximum)==null?void 0:O.final.amount.value;let p;((T=(E=t==null?void 0:t.minimum)==null?void 0:E.regular)==null?void 0:T.amount.value)===((V=(_=t==null?void 0:t.maximum)==null?void 0:_.regular)==null?void 0:V.amount.value)&&(p=(F=(I=t==null?void 0:t.minimum)==null?void 0:I.regular)==null?void 0:F.amount.value);const x=((U=(A=t==null?void 0:t.minimum)==null?void 0:A.final)==null?void 0:U.amount.currency)==="NONE"?"USD":(L=($=t==null?void 0:t.minimum)==null?void 0:$.final)==null?void 0:L.amount.currency;return[p,D,w,x]}function m(){var E,T,_,V,I,F,A,U,$,L,W,Y;let D=0,w=0;a==null||a.forEach(b=>{var J;const j=b==null?void 0:b.values;if(j&&Array.isArray(j)){const S=j.map(g=>{var G,M,Z,R;return(R=(Z=(M=(G=g==null?void 0:g.product)==null?void 0:G.price)==null?void 0:M.regular)==null?void 0:Z.amount)==null?void 0:R.value}).filter(g=>g!==void 0),N=S.length>0?Math.max(...S):0;D+=N}(J=b==null?void 0:b.values)==null||J.forEach(S=>{var N,g,G,M;u!=null&&u.includes(S.id)&&(w+=(M=(G=(g=(N=S==null?void 0:S.product)==null?void 0:N.price)==null?void 0:g.final)==null?void 0:G.amount)==null?void 0:M.value)})});const p=(E=t==null?void 0:t.minimum)==null?void 0:E.final.amount.value,x=(T=t==null?void 0:t.maximum)==null?void 0:T.final.amount.value;let C;((V=(_=t==null?void 0:t.minimum)==null?void 0:_.regular)==null?void 0:V.amount.value)===((F=(I=t==null?void 0:t.maximum)==null?void 0:I.regular)==null?void 0:F.amount.value)&&(C=(U=(A=t==null?void 0:t.minimum)==null?void 0:A.regular)==null?void 0:U.amount.value);const O=((L=($=t==null?void 0:t.minimum)==null?void 0:$.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 r&&(u==null?void 0:u.length)<1?[C,p,x,O]:D===(t==null?void 0:t.maximum.regular.amount.value)?[w,w,w,O]:[C,p,x,O]}const[c,f,d,P]=o==="SimpleProductView"?s():r?m():l(),k=o==="SimpleProductView"?(h=n==null?void 0:n.roles)==null?void 0:h.includes("visible"):((X=(v=t==null?void 0:t.maximum)==null?void 0:v.roles)==null?void 0:X.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:P,variant:c&&f!==c?"strikethrough":"default"},final:{amount:d,currency:P,variant:"default"},visible:k}:{final:{minimumAmount:f,maximumAmount:d,currency:P},visible:k}}function Ce(e,r,i){var n;return r?((n=e==null?void 0:e.options)==null?void 0:n.map(({values:a})=>{var s;const u=((s=a==null?void 0:a.find(({isDefault:l})=>l))==null?void 0:s.id)??null,o=i?a[0].id:null;return u||o})).filter(a=>a!==null):e==null?void 0:e.optionUIDs}const Oe=`
|
|
4
|
+
fragment ProductOptionFragment on ProductViewOption {
|
|
5
|
+
id
|
|
6
|
+
title
|
|
7
|
+
required
|
|
8
|
+
multi
|
|
9
|
+
values {
|
|
10
|
+
id
|
|
11
|
+
title
|
|
12
|
+
inStock
|
|
13
|
+
__typename
|
|
14
|
+
... on ProductViewOptionValueProduct {
|
|
15
|
+
title
|
|
16
|
+
quantity
|
|
17
|
+
isDefault
|
|
18
|
+
__typename
|
|
19
|
+
product {
|
|
20
|
+
sku
|
|
21
|
+
shortDescription
|
|
22
|
+
metaDescription
|
|
23
|
+
metaKeyword
|
|
24
|
+
metaTitle
|
|
25
|
+
name
|
|
26
|
+
price {
|
|
27
|
+
final {
|
|
28
|
+
amount {
|
|
29
|
+
value
|
|
30
|
+
currency
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
regular {
|
|
34
|
+
amount {
|
|
35
|
+
value
|
|
36
|
+
currency
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
roles
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
... on ProductViewOptionValueSwatch {
|
|
44
|
+
id
|
|
45
|
+
title
|
|
46
|
+
type
|
|
47
|
+
value
|
|
48
|
+
inStock
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`,ae=`
|
|
53
|
+
fragment ProductFragment on ProductView {
|
|
54
|
+
__typename
|
|
55
|
+
id
|
|
56
|
+
sku
|
|
57
|
+
name
|
|
58
|
+
shortDescription
|
|
59
|
+
metaDescription
|
|
60
|
+
metaKeyword
|
|
61
|
+
metaTitle
|
|
62
|
+
description
|
|
63
|
+
inStock
|
|
64
|
+
addToCartAllowed
|
|
65
|
+
url
|
|
66
|
+
urlKey
|
|
67
|
+
externalId
|
|
68
|
+
|
|
69
|
+
images(roles: []) {
|
|
70
|
+
url
|
|
71
|
+
label
|
|
72
|
+
roles
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
attributes(roles: []) {
|
|
76
|
+
name
|
|
77
|
+
label
|
|
78
|
+
value
|
|
79
|
+
roles
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
... on SimpleProductView {
|
|
83
|
+
price {
|
|
84
|
+
roles
|
|
85
|
+
|
|
86
|
+
regular {
|
|
87
|
+
amount {
|
|
88
|
+
value
|
|
89
|
+
currency
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
final {
|
|
94
|
+
amount {
|
|
95
|
+
value
|
|
96
|
+
currency
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
... on ComplexProductView {
|
|
104
|
+
options {
|
|
105
|
+
...ProductOptionFragment
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
priceRange {
|
|
109
|
+
maximum {
|
|
110
|
+
final {
|
|
111
|
+
amount {
|
|
112
|
+
value
|
|
113
|
+
currency
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
regular {
|
|
117
|
+
amount {
|
|
118
|
+
value
|
|
119
|
+
currency
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
roles
|
|
123
|
+
}
|
|
124
|
+
minimum {
|
|
125
|
+
final {
|
|
126
|
+
amount {
|
|
127
|
+
value
|
|
128
|
+
currency
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
regular {
|
|
132
|
+
amount {
|
|
133
|
+
value
|
|
134
|
+
currency
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
roles
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
${Oe}
|
|
144
|
+
`,be=`
|
|
145
|
+
query GET_PRODUCT_DATA($skus: [String]) {
|
|
146
|
+
products(skus: $skus) {
|
|
147
|
+
...ProductFragment
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
${ae}
|
|
152
|
+
`,ke=async(e,r)=>{var a,u,o,s;const i=(o=(u=(a=y==null?void 0:y.getConfig())==null?void 0:a.models)==null?void 0:u.ProductDetails)==null?void 0:o.initialData;if(i)return Q(i);const{data:n}=await re(be,{method:"GET",variables:{skus:[e]}}),t=(s=n==null?void 0:n.products)==null?void 0:s[0];return r!=null&&r.optionsUIDs&&(t.optionUIDs=r.optionsUIDs),Q(t,{preselectFirstOption:r==null?void 0:r.preselectFirstOption})},ve=`
|
|
153
|
+
query REFINE_PRODUCT_QUERY(
|
|
154
|
+
$optionIds: [String!]!
|
|
155
|
+
$sku: String!
|
|
156
|
+
) {
|
|
157
|
+
# Refined Product
|
|
158
|
+
refineProduct(
|
|
159
|
+
optionIds: $optionIds
|
|
160
|
+
sku: $sku
|
|
161
|
+
) {
|
|
162
|
+
...ProductFragment
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
# Parent Product
|
|
166
|
+
products(skus: [$sku]) {
|
|
167
|
+
...ProductFragment
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
# %extendedPlaceholder%
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
${ae}
|
|
174
|
+
`;async function ee(e,r){const i=Te(r),n=_e(i,e),t=ve.replace("# %extendedPlaceholder%",n),{data:a}=await re(t,{method:"GET",variables:{optionIds:r,sku:e}});return a}const Ee=async(e,r,i)=>{var c,f,d;const n=await ee(e,r);if(!n)return null;let{products:t,refineProduct:a,...u}=n;const o=t==null?void 0:t[0],s=Ve(Object.values(u),o.options,i);if(i!=null&&i.length&&a===null){r=Ie(s,r,i);const P=await ee(e,r);a=P==null?void 0:P.refineProduct}const l=Q({...a||o,sku:o.sku,name:o.name,externalParentId:o==null?void 0:o.externalId,options:s,optionUIDs:r,variantSku:(a==null?void 0:a.__typename)==="SimpleProductView"?a==null?void 0:a.sku:void 0}),m=(d=(f=(c=y==null?void 0:y.getConfig())==null?void 0:c.models)==null?void 0:f.ProductDetails)==null?void 0:d.fallbackData;return m?m(o,l):l};function Te(e){if(e.length<2)return[e];const r=[];return e.forEach(i=>{const n=[];e.forEach(t=>{i!==t&&n.push(t)}),r.push(n)}),r}function _e(e,r){return e.map((i,n)=>`
|
|
175
|
+
ProductOption${n}: refineProduct(
|
|
176
|
+
optionIds: [
|
|
177
|
+
${i.map(t=>`"${t}"`).join(", ")}
|
|
178
|
+
]
|
|
179
|
+
sku: "${r}"
|
|
180
|
+
) {
|
|
181
|
+
... on ComplexProductView {
|
|
182
|
+
options {
|
|
183
|
+
...ProductOptionFragment
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
`).join("")}function Ve(e,r=[],i){const n=Object.values(e).filter(a=>!!a).reduce((a,u)=>u.options?[...a,...u.options]:[...a],[]),t=new Map(r.map(a=>[a.id,a]));return n.forEach(a=>{i!=null&&i.includes(a.id)||t.set(a.id,a)}),[...t.values()]}function Ie(e,r,i){const n=[];let t;return e.forEach(a=>{var u,o,s,l;i.includes(a.id)?t=((o=(u=a.values)==null?void 0:u.find(m=>r.includes(m==null?void 0:m.id)))==null?void 0:o.id)||((s=a.values[0])==null?void 0:s.id):t=(l=a.values[0])==null?void 0:l.id,n.push(t)}),n}const te=async(e,r)=>{const{anchors:i,optionsUIDs:n}=y.getConfig(),{optionsUIDs:t=n,anchors:a=i,preselectFirstOption:u,initialData:o,isBundle:s}=r??{};return o?Q(o):!s&&t?await Ee(e,t,a):await ke(e,{preselectFirstOption:u,optionsUIDs:t})};export{Me as a,Qe as b,y as c,ke as d,Ee as e,re as f,je as g,te as h,q as i,Le as j,ye as p,Ne as r,Ge as s};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as e}from"@dropins/tools/event-bus.js";const s=async()=>e._lastEvent["pdp/data"]?Promise.resolve(e._lastEvent["pdp/data"].payload):new Promise(a=>{const t=e.on("pdp/data",r=>{a(r),t==null||t.off()},{eager:!0})});export{s as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as o}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const a=t=>{const s=e(),n=t(s);JSON.stringify(s)!==JSON.stringify(n)&&o.emit("pdp/values",{...n})},e=()=>{var t;return((t=o._lastEvent["pdp/values"])==null?void 0:t.payload)??null};export{e as g,a as s};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! Copyright 2024 Adobe
|
|
2
|
+
All Rights Reserved. */
|
|
3
|
+
import{events as n}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const d=t=>{const o=a(),i=t(o);o!==i&&n.emit("pdp/valid",i)},a=()=>{var t;return((t=n._lastEvent["pdp/valid"])==null?void 0:t.payload)??null};export{a as i,d as s};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FunctionComponent, VNode } from 'preact';
|
|
2
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
+
|
|
4
|
+
export interface HeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
5
|
+
title: VNode;
|
|
6
|
+
sku: VNode;
|
|
7
|
+
hideSku?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const Header: FunctionComponent<HeaderProps>;
|
|
10
|
+
//# sourceMappingURL=Header.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './Header';
|
|
17
|
+
export { Header as default } from './Header';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionComponent, VNode } from 'preact';
|
|
2
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
3
|
+
|
|
4
|
+
export interface PriceProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
price?: VNode;
|
|
6
|
+
specialPrice?: VNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const Price: FunctionComponent<PriceProps>;
|
|
9
|
+
//# sourceMappingURL=Price.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './Price';
|
|
17
|
+
export { Price as default } from './Price';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
package/components/index.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'preact/compat';
|
|
2
|
+
import { Container } from '@dropins/tools/types/elsie/src/lib';
|
|
3
|
+
import { ProductModel } from '../../data/models';
|
|
4
|
+
|
|
5
|
+
export interface ProductAttributesProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
}
|
|
7
|
+
export declare const ProductAttributes: Container<ProductAttributesProps, ProductModel | null>;
|
|
8
|
+
//# sourceMappingURL=ProductAttributes.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
* Copyright 2024 Adobe
|
|
5
|
+
* All Rights Reserved.
|
|
6
|
+
* __________________
|
|
7
|
+
* NOTICE: All information contained herein is, and remains
|
|
8
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
9
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
10
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
11
|
+
* property laws, including trade secret and copyright laws.
|
|
12
|
+
* Dissemination of this information or reproduction of this material
|
|
13
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
14
|
+
* from Adobe.
|
|
15
|
+
*/
|
|
16
|
+
export * from './ProductAttributes';
|
|
17
|
+
export { ProductAttributes as default } from './ProductAttributes';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|