@dropins/storefront-pdp 1.2.1-alpha1 → 1.2.1-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/api/fetch-graphql/fetch-graphql.d.ts +2 -2
- package/api/initialize/initialize.d.ts +3 -3
- package/api.js +1 -0
- package/api.js.map +1 -0
- package/chunks/PriceRange.js +1 -0
- package/chunks/PriceRange.js.map +1 -0
- package/chunks/Swatches.js +1 -0
- package/chunks/Swatches.js.map +1 -0
- package/chunks/Zoom.js +2 -1
- package/chunks/Zoom.js.map +1 -0
- package/chunks/date.js +1 -0
- package/chunks/date.js.map +1 -0
- package/chunks/getFetchedProductData.js +1 -0
- package/chunks/getFetchedProductData.js.map +1 -0
- package/chunks/isProductConfigurationValid.js +7 -6
- package/chunks/isProductConfigurationValid.js.map +1 -0
- package/components/Swatches/Swatches.d.ts +1 -1
- package/containers/ProductAttributes/ProductAttributes.d.ts +8 -1
- package/containers/ProductAttributes.js +2 -1
- package/containers/ProductAttributes.js.map +1 -0
- package/containers/ProductDescription/ProductDescription.d.ts +1 -1
- package/containers/ProductDescription.js +1 -0
- package/containers/ProductDescription.js.map +1 -0
- package/containers/ProductDetails/ProductDetails.d.ts +3 -3
- package/containers/ProductDetails.js +2 -1
- package/containers/ProductDetails.js.map +1 -0
- package/containers/ProductGallery/ProductGallery.d.ts +2 -2
- package/containers/ProductGallery.js +1 -0
- package/containers/ProductGallery.js.map +1 -0
- package/containers/ProductHeader/ProductHeader.d.ts +1 -1
- package/containers/ProductHeader.js +1 -0
- package/containers/ProductHeader.js.map +1 -0
- package/containers/ProductOptions/ProductOptions.d.ts +2 -2
- package/containers/ProductOptions.js +1 -0
- package/containers/ProductOptions.js.map +1 -0
- package/containers/ProductPrice/ProductPrice.d.ts +1 -1
- package/containers/ProductPrice.js +1 -0
- package/containers/ProductPrice.js.map +1 -0
- package/containers/ProductQuantity/ProductQuantity.d.ts +1 -1
- package/containers/ProductQuantity.js +2 -1
- package/containers/ProductQuantity.js.map +1 -0
- package/containers/ProductShortDescription/ProductShortDescription.d.ts +1 -1
- package/containers/ProductShortDescription.js +1 -0
- package/containers/ProductShortDescription.js.map +1 -0
- package/fragments.js +1 -0
- package/fragments.js.map +1 -0
- package/lib/url-params.d.ts +1 -0
- package/package.json +1 -1
- package/render/render.d.ts +1 -1
- package/render.js +2 -1
- package/render.js.map +1 -0
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* is strictly forbidden unless prior written permission is obtained
|
|
14
14
|
* from Adobe.
|
|
15
15
|
*/
|
|
16
|
-
export declare const setEndpoint: (endpoint: string) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, removeFetchGraphQlHeader: (key: string) => void, setFetchGraphQlHeaders: (header: import('@adobe-commerce/fetch-graphql').Header) => void, fetchGraphQl: <T = any>(query: string, options?: import('@adobe-commerce/fetch-graphql').FetchOptions | undefined) => Promise<{
|
|
16
|
+
export declare const setEndpoint: (endpoint: string) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, removeFetchGraphQlHeader: (key: string) => void, setFetchGraphQlHeaders: (header: import('@adobe-commerce/fetch-graphql').Header | ((prev: import('@adobe-commerce/fetch-graphql').Header) => import('@adobe-commerce/fetch-graphql').Header)) => void, fetchGraphQl: <T = any>(query: string, options?: import('@adobe-commerce/fetch-graphql').FetchOptions | undefined) => Promise<{
|
|
17
17
|
errors?: import('@adobe-commerce/fetch-graphql').FetchQueryError | undefined;
|
|
18
18
|
data: T;
|
|
19
19
|
}>, getConfig: () => {
|
|
20
20
|
endpoint: string | undefined;
|
|
21
|
-
fetchGraphQlHeaders: import('@adobe-commerce/fetch-graphql').Header
|
|
21
|
+
fetchGraphQlHeaders: import('@adobe-commerce/fetch-graphql').Header;
|
|
22
22
|
};
|
|
23
23
|
//# sourceMappingURL=fetch-graphql.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Initializer } from '
|
|
2
|
-
import { Lang } from '
|
|
1
|
+
import { Initializer } from '@dropins/tools/types/elsie/src/lib';
|
|
2
|
+
import { Lang } from '@dropins/tools/types/elsie/src/i18n';
|
|
3
3
|
import { ProductModel } from '../../data/models';
|
|
4
4
|
|
|
5
5
|
type ConfigProps = {
|
|
@@ -22,6 +22,6 @@ type ConfigProps = {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
export declare const initialize: Initializer<ConfigProps>;
|
|
25
|
-
export declare const config: import('
|
|
25
|
+
export declare const config: import('@dropins/tools/types/elsie/src/lib').Config<ConfigProps>;
|
|
26
26
|
export {};
|
|
27
27
|
//# sourceMappingURL=initialize.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{c as i,f as d,h as c,g as n,k as u,d as g,e as f,i as h,m as p,r as l,s as m,a as P,b as C,l as F,j 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"./fragments.js";import"@dropins/tools/fetch-graphql.js";export{i as config,d as fetchGraphQl,c as fetchProductData,n as getConfig,V as getFetchedProductData,u as getProductConfigurationValues,g as getProductData,f as getRefinedProduct,h as initialize,p as isProductConfigurationValid,l as removeFetchGraphQlHeader,m as setEndpoint,P as setFetchGraphQlHeader,C as setFetchGraphQlHeaders,F as setProductConfigurationValid,G as setProductConfigurationValues};
|
|
4
|
+
//# sourceMappingURL=api.js.map
|
package/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/chunks/PriceRange.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
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};
|
|
4
|
+
//# sourceMappingURL=PriceRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PriceRange.js","sources":["/@dropins/storefront-pdp/src/components/PriceRange/PriceRange.tsx"],"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\nimport { HTMLAttributes } from 'preact/compat';\nimport '@/pdp/components/PriceRange/PriceRange.css';\nimport { FunctionalComponent } from 'preact';\nimport { Price } from '@adobe-commerce/elsie/components';\n\nexport interface PriceRangeProps extends HTMLAttributes<HTMLDivElement> {\n locale?: string;\n variant?: 'default' | 'strikethrough';\n currency?: string;\n\n // Simple product\n amount?: number;\n sale?: boolean;\n\n // Complex product (range)\n minimumAmount?: number;\n maximumAmount?: number;\n}\n\nexport const PriceRange: FunctionalComponent<PriceRangeProps> = ({\n amount,\n currency,\n locale,\n variant,\n sale,\n minimumAmount,\n maximumAmount,\n className,\n ...props\n}) => {\n return (\n <>\n {amount || minimumAmount === maximumAmount ? (\n <div className={'pdp-price-range'} {...props}>\n <Price\n amount={amount ? amount : minimumAmount}\n currency={currency}\n locale={locale}\n variant={variant}\n sale={sale}\n className={className}\n />\n </div>\n ) : (\n <div className={'pdp-price-range'} {...props}>\n <Price\n amount={minimumAmount}\n currency={currency}\n locale={locale}\n className={className}\n />\n <span className=\"pdp-price-range__label\">{'-'}</span>\n <Price\n amount={maximumAmount}\n currency={currency}\n locale={locale}\n className={className}\n />\n </div>\n )}\n </>\n );\n};\n"],"names":["PriceRange","amount","currency","locale","variant","sale","minimumAmount","maximumAmount","className","props","jsx","Fragment","Price","jsxs"],"mappings":"2JAmCO,MAAMA,EAAmD,CAAC,CAC/D,OAAAC,EACA,SAAAC,EACA,OAAAC,EACA,QAAAC,EACA,KAAAC,EACA,cAAAC,EACA,cAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IAEIC,EAAAC,EAAA,CACG,YAAUL,IAAkBC,IAC1B,MAAI,CAAA,UAAW,kBAAoB,GAAGE,EACrC,SAAAC,EAACE,EAAA,CACC,OAAQX,GAAkBK,EAC1B,SAAAJ,EACA,OAAAC,EACA,QAAAC,EACA,KAAAC,EACA,UAAAG,CAAA,CAAA,EAEJ,EAEAK,EAAC,OAAI,UAAW,kBAAoB,GAAGJ,EACrC,SAAA,CAAAC,EAACE,EAAA,CACC,OAAQN,EACR,SAAAJ,EACA,OAAAC,EACA,UAAAK,CAAA,CACF,EACCE,EAAA,OAAA,CAAK,UAAU,yBAA0B,SAAI,IAAA,EAC9CA,EAACE,EAAA,CACC,OAAQL,EACR,SAAAL,EACA,OAAAC,EACA,UAAAK,CAAA,CAAA,CACF,CAAA,CACF,CAEJ,CAAA"}
|
package/chunks/Swatches.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
3
|
import{jsx as h,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{useState as R,useEffect as N,useMemo as z,useCallback as _}from"@dropins/tools/preact-compat.js";import{classes as P}from"@dropins/tools/lib.js";import{Picker as A,ColorSwatch as y,ImageSwatch as B,TextSwatch as D}from"@dropins/tools/components.js";/* empty css */import{useText as C}from"@dropins/tools/i18n.js";const F=["text","image","color","dropdown"],G=t=>t.map(s=>({...s,text:s.label,disabled:!s.inStock}));function H(t,s){return t.reduce((m,i)=>{const n=s==null?void 0:s.find(f=>f.items.find(w=>w.id===i));if(!n)return m;const b=n.items.find(f=>f.id===i);return{...m,[n.id]:{label:b.label,value:b.id}}},{})}const I=({options:t,hideSelectedValue:s,disablePreselections:m,selectedUIDs:i,onValues:n,onErrors:b,defaultOptions:f,selectionsToUpdate:w,className:L,children:K,imageSwatchNode:O,...q})=>{const j=C("PDP.Swatches.Required.label").label,k=C("PDP.Swatches.ChooseOption.label").label,[S,x]=R(()=>t==null?void 0:t.reduce((r,e)=>{const{items:a}=e,d=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 d?{...r,[e.id]:{label:d.label,value:d.id}}:u?{...r,[e.id]:{label:u.label,value:u.id}}:r},{}));N(()=>{if(i){const l=H(i,t);if(JSON.stringify(l)===JSON.stringify(S))return;x(r=>{let e={...r,...l};return n==null||n(e),e})}},[i]),N(()=>{w==null||w.forEach(l=>{x(r=>{var d;const e=(d=l==null?void 0:l.items)==null?void 0:d.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,x]),z(()=>{const l=t==null?void 0:t.reduce((r,e)=>{var d;let a=!1;return(d=e==null?void 0:e.items)==null||d.forEach(u=>{var v;((v=S[e.id])==null?void 0:v.value)===u.id&&(a=!0)}),e.required&&!a&&(r[e.id]=j),r},{});return b==null||b(l),l},[S]);const g=_((l,r,e)=>{x(a=>{let d={...a,...l&&{[l]:{label:r,value:e}}};return r===k&&delete d[l],n==null||n(d,e),d})},[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:d,label:u})=>(l==null?void 0:l.length)>0&&h("div",{className:P(["pdp-swatches__options"]),children:(a==null?void 0:a.toLowerCase())==="dropdown"?h(A,{"aria-label":u,placeholder:m?k:void 0,handleSelect:c=>$(r,c.target),options:G(l),value:d}):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:d===c.id,outOfStock:!c.inStock,required:e===null?!0:e,onValue:()=>{g(r,c.label,c.id)}};switch(a){case"text":return h(D,{...v,label:c.label});case"image":return h(B,{...v,src:c.value,alt:c.label,imageNode:O});case"color":return h(y,{...v,size:"large",color:c.value});default:return console.warn(`Invalid swatch type ${a}`),null}})}),[k,g,$]);return h("div",{...q,className:P(["pdp-swatches",L]),children:t==null?void 0:t.map(({type:l,label:r,id:e,multiple:a,required:d,items:u})=>{var c;return F.includes(l)||console.warn(`Invalid swatch type ${l}`),a&&console.warn("Multiple selection swatches are not currently supported."),M("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:d,items:u,label:r,selected:(c=S[e])==null?void 0:c.value})]},`swatch-item-${e}`)})})};export{I as S};
|
|
4
|
+
//# sourceMappingURL=Swatches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swatches.js","sources":["/@dropins/storefront-pdp/src/components/Swatches/Swatches.tsx"],"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\nimport { FunctionComponent, VNode } from 'preact';\nimport {\n HTMLAttributes,\n useState,\n useMemo,\n useCallback,\n useEffect,\n JSX,\n} from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport {\n ColorSwatch,\n ImageSwatch,\n TextSwatch,\n Picker,\n PickerOption,\n ImageNodeRenderProps,\n} from '@adobe-commerce/elsie/components';\n\nimport '@/pdp/components/Swatches/Swatches.css';\n\nconst supportedTypes = ['text', 'image', 'color', 'dropdown'];\n\nconst mapToPickerOptions = (items: OptionValue[]): PickerOption[] => {\n return items.map((item: OptionValue) => ({\n ...item,\n text: item.label,\n disabled: !item.inStock,\n }));\n};\n\ntype OptionValue = {\n id: string;\n label: string;\n inStock: boolean;\n value: string;\n selected?: boolean;\n};\n\nexport type Option = {\n id: string;\n type: (typeof supportedTypes)[number];\n label: string;\n required?: boolean;\n multiple?: boolean;\n items: OptionValue[];\n};\n\ntype Selection = { [id: string]: { label: string; value: string } };\n\nfunction optionUIDsToSelection(\n optionUIDs: string[],\n options: Array<Option>\n): Selection {\n return optionUIDs.reduce((accum, optionUID) => {\n const option = options?.find((option) =>\n option.items.find((item) => item.id === optionUID)\n );\n if (!option) return accum;\n\n const item = option.items.find((item) => item.id === optionUID);\n\n return {\n ...accum,\n [option.id]: {\n label: item!.label,\n value: item!.id,\n },\n };\n }, {});\n}\n\nexport interface SwatchesProps extends HTMLAttributes<HTMLDivElement> {\n options: Array<Option>;\n hideSelectedValue?: boolean;\n disablePreselections?: boolean;\n defaultOptions?: string[];\n selectionsToUpdate?: Option[];\n onValues?: (uids: Selection, current: string) => void;\n onErrors?: (errors: { [id: string]: string }) => void;\n selectedUIDs?: string[];\n imageSwatchNode?: VNode | ((props: ImageNodeRenderProps) => JSX.Element);\n}\n\nexport const Swatches: FunctionComponent<SwatchesProps> = ({\n options,\n hideSelectedValue,\n disablePreselections,\n selectedUIDs,\n onValues,\n onErrors,\n defaultOptions,\n selectionsToUpdate,\n className,\n children,\n imageSwatchNode,\n ...props\n}) => {\n // i18n\n const RequiredLabel = useText('PDP.Swatches.Required.label').label;\n const ChooseOptionLabel = useText('PDP.Swatches.ChooseOption.label').label;\n\n const [selections, setSelections] = useState<Selection>(() => {\n const initial = options?.reduce((accum, option) => {\n const { items } = option;\n const defaultSelection = items?.find((item) =>\n defaultOptions?.includes(item.id)\n );\n const selected = items?.find((item) => item.selected);\n if (defaultSelection) {\n return {\n ...accum,\n [option.id]: {\n label: defaultSelection.label,\n value: defaultSelection.id,\n },\n };\n } else if (selected) {\n return {\n ...accum,\n [option.id]: { label: selected.label, value: selected.id },\n };\n }\n return accum;\n }, {} as Selection);\n\n return initial;\n });\n\n // set selected options from props\n useEffect(() => {\n if (selectedUIDs) {\n const selection = optionUIDsToSelection(selectedUIDs, options);\n // if the internal state is already the same as the props, do nothing\n if (JSON.stringify(selection) === JSON.stringify(selections)) return;\n\n setSelections((prev) => {\n let next = {\n ...prev,\n ...selection,\n };\n onValues?.(next);\n return next;\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedUIDs]);\n\n // this only applies for the case with anchor options\n // update selections in the swatches if they are updated in the parent component\n useEffect(() => {\n selectionsToUpdate?.forEach((selectionToUpdate) => {\n setSelections((prev) => {\n const selectedItem = selectionToUpdate?.items?.find(\n (item) => item.selected\n );\n if (!selectedItem) return prev;\n\n const next = {\n ...prev,\n [selectionToUpdate.id]: {\n label: selectedItem?.label,\n value: selectedItem?.id,\n },\n };\n return next;\n });\n });\n }, [selectionsToUpdate, setSelections]);\n\n // Update invalid options\n useMemo(() => {\n const errors = options?.reduce((accum, option) => {\n let valueSelected = false;\n option?.items?.forEach((item) => {\n const selected = selections[option.id]?.value === item.id;\n if (selected) {\n valueSelected = true;\n }\n });\n\n // Validate required\n if (option.required && !valueSelected) {\n accum[option.id] = RequiredLabel;\n }\n return accum;\n }, {} as { [id: string]: string });\n\n // Call the callback\n onErrors?.(errors);\n\n return errors;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selections]);\n\n const handleOnSelection = useCallback(\n (id: string, label: string, optionId: string) => {\n setSelections((prev) => {\n let next = {\n ...prev,\n ...(id && { [id]: { label, value: optionId } }),\n };\n\n if (label === ChooseOptionLabel) {\n delete next[id];\n }\n\n // Call the callback\n onValues?.(next, optionId);\n\n // Return the next state\n return next;\n });\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [onValues]\n );\n\n // Function to handle the picker selection\n const handlePickerSelect = useCallback(\n (optionId: string, selection: any) => {\n const label = selection.selectedOptions[0]?.label ?? '';\n handleOnSelection(optionId, label, selection.value);\n },\n [handleOnSelection]\n );\n\n const Swatches = useCallback(\n ({ items, id, required, type, selected, label }: any) => {\n return (\n items?.length > 0 && (\n <div className={classes(['pdp-swatches__options'])}>\n {type?.toLowerCase() === 'dropdown' ? (\n <Picker\n aria-label={label}\n placeholder={\n disablePreselections ? ChooseOptionLabel : undefined\n }\n handleSelect={(event) => handlePickerSelect(id, event.target)}\n options={mapToPickerOptions(items)}\n value={selected}\n />\n ) : (\n items?.map((option: any) => {\n const common = {\n key: option.id,\n id: option.id,\n name: id,\n value: option.value,\n label: option.label,\n groupAriaLabel: label,\n selected: selected === option.id,\n outOfStock: !option.inStock,\n // API may return null, we default to true as all swatches are required.\n // we still comply to this in case the api return \"false\".\n required: required === null ? true : required,\n onValue: () => {\n handleOnSelection(id, option.label, option.id);\n },\n };\n\n switch (type) {\n case 'text':\n return <TextSwatch {...common} label={option.label} />;\n\n case 'image':\n return (\n <ImageSwatch\n {...common}\n src={option.value}\n alt={option.label}\n imageNode={imageSwatchNode}\n />\n );\n\n case 'color':\n return (\n <ColorSwatch\n {...common}\n size=\"large\"\n color={option.value}\n />\n );\n\n default:\n console.warn(`Invalid swatch type ${type}`);\n return null;\n }\n })\n )}\n </div>\n )\n );\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [ChooseOptionLabel, handleOnSelection, handlePickerSelect]\n );\n\n return (\n <div {...props} className={classes(['pdp-swatches', className])}>\n {options?.map(({ type, label, id, multiple, required, items }) => {\n // Only render supported types\n if (!supportedTypes.includes(type)) {\n console.warn(`Invalid swatch type ${type}`);\n }\n\n if (multiple) {\n console.warn(\n 'Multiple selection swatches are not currently supported.'\n );\n }\n\n return (\n <div\n key={`swatch-item-${id}`}\n id={`swatch-item-${id}`}\n data-slot-key={`product-swatch--${id}`}\n className=\"pdp-swatches__field\"\n >\n <div className=\"pdp-swatches__field__label\">\n {selections[id]\n ? hideSelectedValue\n ? `${label}`\n : `${label}: ${selections[id].label}`\n : label}\n </div>\n\n <Swatches\n id={id}\n type={type}\n required={required}\n items={items}\n label={label} //label referring to the name of the swatchGroup\n selected={selections[id]?.value}\n />\n </div>\n );\n })}\n </div>\n );\n};\n"],"names":["supportedTypes","mapToPickerOptions","items","item","optionUIDsToSelection","optionUIDs","options","accum","optionUID","option","Swatches","hideSelectedValue","disablePreselections","selectedUIDs","onValues","onErrors","defaultOptions","selectionsToUpdate","className","children","imageSwatchNode","props","RequiredLabel","useText","ChooseOptionLabel","selections","setSelections","useState","defaultSelection","selected","useEffect","selection","prev","next","selectionToUpdate","selectedItem","_a","useMemo","errors","valueSelected","handleOnSelection","useCallback","id","label","optionId","handlePickerSelect","required","type","jsx","classes","Picker","event","common","TextSwatch","ImageSwatch","ColorSwatch","multiple","jsxs"],"mappings":"yYAsCA,MAAMA,EAAiB,CAAC,OAAQ,QAAS,QAAS,UAAU,EAEtDC,EAAsBC,GACnBA,EAAM,IAAKC,IAAuB,CACvC,GAAGA,EACH,KAAMA,EAAK,MACX,SAAU,CAACA,EAAK,OAAA,EAChB,EAsBJ,SAASC,EACPC,EACAC,EACW,CACX,OAAOD,EAAW,OAAO,CAACE,EAAOC,IAAc,CAC7C,MAAMC,EAASH,GAAA,YAAAA,EAAS,KAAMG,GAC5BA,EAAO,MAAM,KAAMN,GAASA,EAAK,KAAOK,CAAS,GAE/C,GAAA,CAACC,EAAe,OAAAF,EAEd,MAAAJ,EAAOM,EAAO,MAAM,KAAM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B,EAAmBgB,EAAmBK,CAAkB,CAC3D,EAGE,OAAAG,EAAC,OAAK,GAAG3B,EAAO,UAAW4B,EAAQ,CAAC,eAAgB/B,CAAS,CAAC,EAC3D,SAASZ,GAAA,YAAAA,EAAA,IAAI,CAAC,CAAE,KAAAyC,EAAM,MAAAJ,EAAO,GAAAD,EAAI,SAAAc,EAAU,SAAAV,EAAU,MAAA5C,KAAY,OAEhE,OAAKF,EAAe,SAAS+C,CAAI,GACvB,QAAA,KAAK,uBAAuBA,CAAI,EAAE,EAGxCS,GACM,QAAA,KACN,0DACF,EAIAC,EAAC,MAAA,CAEC,GAAI,eAAef,CAAE,GACrB,gBAAe,mBAAmBA,CAAE,GACpC,UAAU,sBAEV,SAAA,CAAAM,EAAC,OAAI,UAAU,6BACZ,WAAWN,CAAE,EACV/B,EACE,GAAGgC,CAAK,GACR,GAAGA,CAAK,KAAKlB,EAAWiB,CAAE,EAAE,KAAK,GACnCC,EACN,EAEAK,EAACtC,EAAA,CACC,GAAAgC,EACA,KAAAK,EACA,SAAAD,EACA,MAAA5C,EACA,MAAAyC,EACA,UAAUP,EAAAX,EAAWiB,CAAE,IAAb,YAAAN,EAAgB,KAAA,CAAA,CAC5B,CAAA,EApBK,eAAeM,CAAE,EAqBxB,CAEH,GACH,CAEJ"}
|
package/chunks/Zoom.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as F,jsx as C,Fragment as bt}from"@dropins/tools/preact-jsx-runtime.js";import*as ot from"@dropins/tools/preact-compat.js";import{useState as X,Children as j,useRef as K,useMemo as vt,useEffect as R,useCallback as rt}from"@dropins/tools/preact-compat.js";import{debounce as yt,classes as N}from"@dropins/tools/lib.js";import{Button as mt,Icon as Wt}from"@dropins/tools/components.js";/* empty css */import{useText as A}from"@dropins/tools/i18n.js";import{cloneElement as Et}from"@dropins/tools/preact.js";const kt=c=>ot.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},ot.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),Ct=c=>ot.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...c},ot.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),ot.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),$t=24,wt=16,Xt="32";var Mt=(c=>(c[c.small=16]="small",c[c.medium=24]="medium",c[c.large=64]="large",c))(Mt||{});const Ht=({show:c=1,scrollbar:m=!1,peak:_=!1,arrows:i=!1,controls:n="dots",arrowsOnMainImage:$=!1,loop:l=!1,gap:b=null,direction:M="horizontal",width:W="100%",height:J="100%",defaultIndex:Y=0,className:ct,children:E,thumbnails:Q=null,isZoomed:P,...V})=>{const z=A("PDP.Carousel.label").label,at=A("PDP.Carousel.Slide.label").label,it=A("PDP.Carousel.Previous.label").label,B=A("PDP.Carousel.Next.label").label,ut=A("PDP.Carousel.Controls.label").label,nt=A("PDP.Carousel.Controls.Button.label").label,[h,ht]=X(()=>Lt(c)),g=Math.ceil(j.count(E)/h),L=_?$t:0,q=b?Mt[b]:0,H=j.count(E)%h,[u,ft]=X(l?k()?Y-1:Y+1:Y),e=K([]),[y,x]=X(0),[w,O]=X(0),I=vt(()=>j.toArray(Q),[Q]),f=vt(()=>{const t=j.toArray(E).reduce((r,s,o)=>o%h===0?[...r,[s]]:[...r.slice(0,-1),[...r[r.length-1],s]],[]);return!l||t.length===1?t:l&&j.count(E)%h===0?[t[g-1]].concat(t).concat([t[0],t[1]]):[j.toArray(E).slice(-h)].concat(t).concat([t[0],t[1]])},[E,h,g,l]),S=K(null),Z=K(null),d=n==="thumbnailsRow"||n==="thumbnailsColumn";R(()=>{const t=S.current;if(!t)return;const r=yt(()=>{x(t.offsetWidth??0),O(t.offsetHeight??0);const o=window.innerWidth,a=Lt(c,o);a!==h&&ht(a)},50),s=new ResizeObserver(r);return s.observe(t),()=>{s.unobserve(t)}},[h,c]);const G=rt(t=>{const r=l?t-1:t,s=e==null?void 0:e.current[0],o=(s==null?void 0:s.offsetWidth)+wt,a=(s==null?void 0:s.offsetHeight)+wt,p=Z.current,U=n==="thumbnailsRow",lt=n==="thumbnailsColumn",T=U?p==null?void 0:p.offsetWidth:p==null?void 0:p.offsetHeight,D=U?o:a;if((U||lt)&&T){const Nt=Math.floor((U?p.clientWidth:p.clientHeight)/D),Dt=Math.floor(Nt/2),pt=(r-Dt)*D;p.style.scrollBehavior="smooth",U?p.scrollLeft=k()?-(p.scrollWidth-p.clientWidth-pt):pt:p.scrollTop=pt}},[n,l]);R(()=>{G(u)},[u,G]);const v=rt((t,r,s)=>{d&&G(t);const o=S.current,a=L?o.offsetWidth-L:o.offsetWidth-L+q;if(!Array.from(o.querySelectorAll("[data-index]")).filter(T=>{const D=Number(T.getAttribute("data-index"));return!isNaN(D)&&D>-1})[t])return;if(s){const T=t===0?g:0,D=a*(g+(H||h)/h);if(k()){if(o.scrollLeft<=0&&o.scrollLeft>-(a-5)){v(1,!0);return}if(o.scrollLeft<a-D&&o.scrollLeft>=-D){v(g,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=T===0?0:-D,v(T===0?1:g,!0)}else{if(o.scrollLeft>=0&&o.scrollLeft<a-5){v(1,!0);return}if(o.scrollLeft>D-a&&o.scrollLeft<=D){v(g,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=T===0?0:D,v(T===0?1:g,!0);return}}const lt=(o.offsetWidth-q)/h*f[t].length-L;o.style.scrollBehavior=r?"smooth":"auto",o.scrollLeft=k()?-(f[t].length===h?a*t:a*(t-1)-lt):f[t].length===h?a*t:a*(t-1)+lt},[q,g,L,h,H,f,G,n]),tt=rt(()=>{if(l){const r=u-1;v(r,!0,k()?u===g-1:u===1);return}const t=u<=0?0:u-1;v(t,!0)},[u,v,l]),et=rt(()=>{const t=f.length-1;if(l){const s=u+1;v(s,!0,k()?u===0:u===g);return}const r=u>=t?t:u+1;v(r,!0)},[f.length,l,u,v,g]);R(()=>{const t=r=>{r.key==="ArrowLeft"&&(r.preventDefault(),k()?et():tt()),r.key==="ArrowRight"&&(r.preventDefault(),k()?tt():et())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}},[et,tt]),R(()=>{v(l?Y+1:Y,!1)},[Y,v,l]);const dt=yt(()=>{const t=S.current,r=L?t.offsetWidth-L:t.offsetWidth-L+q,s=Math.abs(t.scrollLeft)/r,o=Math.abs(Math.round(s)-s<1?Math.round(s):Math.ceil(s));if(d&&G(o),l){const a=r*(g+(H||h)/h),p=k()?-t.scrollLeft:t.scrollLeft;if(Math.ceil(Math.abs(p))>=Math.ceil(a)-5){t.style.scrollBehavior="auto",t.scrollLeft=k()?-t.offsetWidth+(Math.ceil(p)-Math.ceil(a)-L):t.offsetWidth+(Math.ceil(p)-Math.ceil(a)-L);return}if(Math.abs(p)===0){t.style.scrollBehavior="auto",t.scrollLeft=k()?-(a-t.offsetWidth+L):a-t.offsetWidth+L;return}}u!==o&&ft(o)},100);R(()=>{const t=S.current;return t==null||t.addEventListener("scroll",dt),()=>{t==null||t.removeEventListener("scroll",dt)}},[dt]);const st=(t,r,s)=>C(mt,{className:N([["pdp-carousel__button",!t],[`pdp-carousel__button--${r}`,!t],[`pdp-carousel__button--${n}`,t]]),style:{"--height":`${w}px`},variant:"tertiary","aria-label":r==="next"?B:it,onClick:s,disabled:l?!1:r==="next"?u>=f.length-1:u<1,children:C(Wt,{className:N([["pdp-carousel__button__icon",!t],[`pdp-carousel__button__icon--${r}`,!t],[`pdp-carousel__button__icon--${n}--${r}`,t]]),size:Xt,source:kt})}),gt=i&&f.length!=1&&st(d,"prev",tt),_t=i&&f.length!=1&&st(d,"next",et),Pt=i&&f.length!=1&&st(!1,"prev",tt),xt=i&&f.length!=1&&st(!1,"next",et);return F("div",{role:"region","aria-roledescription":z,className:N(["pdp-carousel",["pdp-carousel--main-image-controls",$],["pdp-carousel--arrows",i&&!d],[`pdp-carousel--${n}`,d],ct]),style:{"--flex-carousel":n==="thumbnailsColumn"?"row-reverse":"column","--gap":d?"0":"var(--spacing-small)","--width":W},...V,children:[C("div",{ref:S,className:N(["pdp-carousel__wrapper",`pdp-carousel__wrapper--${M}`,["pdp-carousel__wrapper--scrollbar",m],["pdp-carousel__wrapper--peak",_]]),style:{"--total-width":n==="thumbnailsColumn"?"81.6%":"100%","--height":n==="thumbnailsColumn"?"auto":J,"--gap":b?`var(--spacing-${b})`:"0px","--per-page":h},tabIndex:0,children:f.map((t,r)=>{const s=t.length<h;return C("div",{role:"group","aria-roledescription":at,"data-index":r,className:N(["pdp-carousel__slide",`pdp-carousel__slide--${M}`,["pdp-carousel__slide--active",u===r],["pdp-carousel__slide--orphan",s]]),style:{"--length":t.length},children:t},r)})}),!d&&F(bt,{children:[gt,_t]}),d&&$&&F(bt,{children:[Pt,xt]}),n&&f.length!=1&&F("div",{className:N([[`pdp-carousel__controls__container--${n}`,d],["pdp-carousel__controls__container--no-arrows",!i||$]]),style:{"--width":n==="thumbnailsRow"?`${y}px`:W,"--height":`${w}px`,"--nr-thumbnails":I.length},children:[(d||P)&&!$&>,C("div",{ref:Z,className:N([[`pdp-carousel__controls__wrapper--${n}`,d],["pdp-carousel__controls__wrapper",d]]),children:C("div",{role:"group","aria-label":ut,className:N(["pdp-carousel__controls",[`pdp-carousel__controls--${n}`,d]]),children:(l?f.slice(0,g):f).map((t,r)=>{const s=l?g:f.length,o=l?u-1===r:u===r;return d?F("label",{className:N(["pdp-carousel__thumbnail__container"]),ref:a=>{a&&(e.current[r]=a)},children:[C("input",{type:"radio",name:"carousel-thumbnails","aria-label":nt.replace("{key}",String(r+1)).replace("{total}",String(s)),checked:o&&y!==0,onChange:()=>{v(l?r+1:r,!0)},...V,className:N(["pdp-carousel__thumbnail",["pdp-carousel__thumbnail--selected",o&&y!==0]])}),C("span",{className:N(["pdp-carousel__thumbnail__span"]),children:I[r]})]},r):C("button",{"aria-label":nt.replace("{key}",String(r+1)).replace("{total}",String(s)),onClick:()=>{v(l?r+1:r,!0)},className:N(["pdp-carousel__controls__button",["pdp-carousel__controls__button--active",o]])},r)})})}),(d||P)&&!$&&_t]})]})};function Lt(c,m=0){if(typeof c=="number")return c;const{small:_,medium:i,large:n}=c,l=[{breakpoint:1024,value:n},{breakpoint:786,value:i},{breakpoint:0,value:_}].find(({breakpoint:b})=>m>b);return l?l.value:_}function k(){return document.documentElement.dir==="rtl"}const Ot=({centered:c,onClose:m,className:_,children:i,...n})=>{const $=A("PDP.Overlay.Close.label").label,l=K(null),b=rt(()=>{m==null||m()},[m]);return R(()=>{const M=W=>{W.key==="Escape"&&b()};return document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M)}},[b]),R(()=>{const M=l.current;M==null||M.focus();const W=document.scrollingElement,J=W.style.overflow;return W.style.overflow="hidden",()=>{W.style.overflow=J}},[]),F("div",{...n,className:N(["pdp-overlay",["pdp-overlay--centered",c],_]),ref:l,role:"dialog","aria-describedby":"overlay-content",tabindex:0,children:[C("div",{className:"pdp-overlay__content",id:"overlay-content",children:i}),C(mt,{"aria-label":$,variant:"tertiary",className:"pdp-overlay__close-button",onClick:b,icon:C(Ct,{})})]})},Zt=({children:c,scale:m=2,closeButton:_=!0})=>{const[i,n]=X(!1),[$,l]=X("pdp-zoom"),[b,M]=X(!1),[W,J]=X({x:0,y:0}),[Y,ct]=X({x:0,y:0}),[E,Q]=X({x:0,y:0}),P=K(null),V=K(!1),z=K(null),at=e=>{!i||e.type!=="touchstart"||(J({x:e.touches[0].clientX,y:e.touches[0].clientY}),ct({x:E.x,y:E.y}),M(!0))},it=e=>{var d;if(!b||e.type!=="touchmove")return;const y=(d=e.currentTarget)==null?void 0:d.getBoundingClientRect(),x=(100-100/m)/2,w=e.touches[0].clientX-W.x,O=e.touches[0].clientY-W.y,I=w*100/(y.width*m),f=O*100/(y.height*m),S=Y.x+I,Z=Y.y+f;Q({x:Math.max(-x,Math.min(S,x))||0,y:Math.max(-x,Math.min(Z,x))||0}),e.preventDefault()},B=e=>{var Z;const y=(Z=e.currentTarget)==null?void 0:Z.getBoundingClientRect(),x=(100-100/m)/2;let w=null;if("touches"in e)if(e.touches.length>0)w=e.touches[0],z.current={clientX:w.clientX,clientY:w.clientY};else if(e.type==="touchend"&&P.current)w={clientX:P.current.x,clientY:P.current.y};else if(z.current)w=z.current;else return;else if(e instanceof MouseEvent)w=e;else return;const O=(w.clientX-y.left)/y.width*100,I=(w.clientY-y.top)/y.height*100,f=(50-O)*(m-1)/m,S=(50-I)*(m-1)/m;Q({x:Math.max(-x,Math.min(f,x))||0,y:Math.max(-x,Math.min(S,x))||0})},ut=e=>{if(_)P.current={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()},z.current={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY},V.current=!1,i&&at(e);else{if(b)return;!i&&B(e),n(!i),e.preventDefault()}},nt=e=>{if(e.touches.length!==0){if(z.current={clientX:e.touches[0].clientX,clientY:e.touches[0].clientY},_){if(!P.current)return;if(b){it(e);return}const y=e.touches[0].clientX,x=e.touches[0].clientY,w=Math.abs(y-P.current.x),O=Math.abs(x-P.current.y);(w>10||O>10)&&(V.current=!0)}i&&B(e)}},h=e=>{if(_){if(!P.current)return;const y=Date.now()-P.current.time;!V.current&&y<300&&!b&&(n(!0),B(e),e.preventDefault()),M(!1),P.current=null}else n(!1)},ht=e=>{"touches"in e||b||(i?!_&&n(!1):(n(!0),B(e)),e.preventDefault())},g=e=>{"touches"in e||i&&B(e)},L=e=>{if(!("touches"in e)){if(_){M(!1);return}n(!1)}},q=e=>{n(!1),e.stopPropagation()},H=i?`scale(${m}) translateX(${E.x}%) translateY(${E.y}%)`:"none",u=A("PDP.Zoom.Close.label").label,ft=Et(j.only(c),{draggable:!1,style:{"--transform":H}});return R(()=>{l(i?`pdp-zoom ${_?"pdp-zoom--no-effects":"pdp-zoom--zoomed"}`:"pdp-zoom")},[i,_]),F("figure",{className:$,onClick:ht,onMouseMove:g,onMouseLeave:L,onTouchStart:ut,onTouchMove:nt,onTouchEnd:h,children:[ft,_&&i&&C(mt,{"aria-label":u,variant:"tertiary",className:"pdp-zoom__close-button",icon:C(Ct,{}),onClick:q})]})};export{Ht as C,Ot as O,Zt as Z};
|
|
3
|
+
import{jsxs as U,jsx as M,Fragment as be}from"@dropins/tools/preact-jsx-runtime.js";import*as le from"@dropins/tools/preact-compat.js";import{useState as $,Children as I,useRef as A,useMemo as ve,useEffect as E,useCallback as re}from"@dropins/tools/preact-compat.js";import{debounce as ye,classes as P}from"@dropins/tools/lib.js";import{Button as pe,Icon as De}from"@dropins/tools/components.js";/* empty css */import{useText as q}from"@dropins/tools/i18n.js";import{cloneElement as We}from"@dropins/tools/preact.js";const ke=i=>le.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},le.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),Ce=i=>le.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},le.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),le.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),Ae=24,we=16,Re="32";var Me=(i=>(i[i.small=16]="small",i[i.medium=24]="medium",i[i.large=64]="large",i))(Me||{});const He=({show:i=1,scrollbar:p=!1,peak:y=!1,arrows:l=!1,controls:o="dots",arrowsOnMainImage:R=!1,loop:c=!1,gap:w=null,direction:L="horizontal",width:D="100%",height:ne="100%",defaultIndex:X=0,className:ie,children:W,thumbnails:J=null,isZoomed:Y,...O})=>{const Z=q("PDP.Carousel.label").label,ce=q("PDP.Carousel.Slide.label").label,x=q("PDP.Carousel.Previous.label").label,oe=q("PDP.Carousel.Next.label").label,j=q("PDP.Carousel.Controls.label").label,H=q("PDP.Carousel.Controls.Button.label").label,[d,ue]=$(()=>Le(i)),v=Math.ceil(I.count(W)/d),C=y?Ae:0,Q=w?Me[w]:0,K=I.count(W)%d,[f,fe]=$(c?k()?X-1:X+1:X),G=A([]),[S,he]=$(0),[ee,de]=$(0),se=ve(()=>I.toArray(J),[J]),t=ve(()=>{const e=I.toArray(W).reduce((r,s,n)=>n%d===0?[...r,[s]]:[...r.slice(0,-1),[...r[r.length-1],s]],[]);return!c||e.length===1?e:c&&I.count(W)%d===0?[e[v-1]].concat(e).concat([e[0],e[1]]):[I.toArray(W).slice(-d)].concat(e).concat([e[0],e[1]])},[W,d,v,c]),g=A(null),h=A(null),a=o==="thumbnailsRow"||o==="thumbnailsColumn";E(()=>{const e=g.current;if(!e)return;const r=ye(()=>{he(e.offsetWidth??0),de(e.offsetHeight??0);const n=window.innerWidth,u=Le(i,n);u!==d&&ue(u)},50),s=new ResizeObserver(r);return s.observe(e),()=>{s.unobserve(e)}},[d,i]);const b=re(e=>{const r=c?e-1:e,s=G==null?void 0:G.current[0],n=(s==null?void 0:s.offsetWidth)+we,u=(s==null?void 0:s.offsetHeight)+we,_=h.current,te=o==="thumbnailsRow",ae=o==="thumbnailsColumn",F=te?_==null?void 0:_.offsetWidth:_==null?void 0:_.offsetHeight,N=te?n:u;if((te||ae)&&F){const Ne=Math.floor((te?_.clientWidth:_.clientHeight)/N),Ee=Math.floor(Ne/2),me=(r-Ee)*N;_.style.scrollBehavior="smooth",te?_.scrollLeft=k()?-(_.scrollWidth-_.clientWidth-me):me:_.scrollTop=me}},[o,c]);E(()=>{b(f)},[f,b]);const m=re((e,r,s)=>{a&&b(e);const n=g.current,u=C?n.offsetWidth-C:n.offsetWidth-C+Q;if(!Array.from(n.querySelectorAll("[data-index]")).filter(F=>{const N=Number(F.getAttribute("data-index"));return!isNaN(N)&&N>-1})[e])return;if(s){const F=e===0?v:0,N=u*(v+(K||d)/d);if(k()){if(n.scrollLeft<=0&&n.scrollLeft>-(u-5)){m(1,!0);return}if(n.scrollLeft<u-N&&n.scrollLeft>=-N){m(v,!0);return}n.style.scrollBehavior="auto",n.scrollLeft=F===0?0:-N,m(F===0?1:v,!0)}else{if(n.scrollLeft>=0&&n.scrollLeft<u-5){m(1,!0);return}if(n.scrollLeft>N-u&&n.scrollLeft<=N){m(v,!0);return}n.style.scrollBehavior="auto",n.scrollLeft=F===0?0:N,m(F===0?1:v,!0);return}}const ae=(n.offsetWidth-Q)/d*t[e].length-C;n.style.scrollBehavior=r?"smooth":"auto",n.scrollLeft=k()?-(t[e].length===d?u*e:u*(e-1)-ae):t[e].length===d?u*e:u*(e-1)+ae},[Q,v,C,d,K,t,b,o]),B=re(()=>{if(c){const r=f-1;m(r,!0,k()?f===v-1:f===1);return}const e=f<=0?0:f-1;m(e,!0)},[f,m,c]),z=re(()=>{const e=t.length-1;if(c){const s=f+1;m(s,!0,k()?f===0:f===v);return}const r=f>=e?e:f+1;m(r,!0)},[t.length,c,f,m,v]);E(()=>{const e=r=>{r.key==="ArrowLeft"&&(r.preventDefault(),k()?z():B()),r.key==="ArrowRight"&&(r.preventDefault(),k()?B():z())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[z,B]),E(()=>{m(c?X+1:X,!1)},[X,m,c]);const V=ye(()=>{const e=g.current,r=C?e.offsetWidth-C:e.offsetWidth-C+Q,s=Math.abs(e.scrollLeft)/r,n=Math.abs(Math.round(s)-s<1?Math.round(s):Math.ceil(s));if(a&&b(n),c){const u=r*(v+(K||d)/d),_=k()?-e.scrollLeft:e.scrollLeft;if(Math.ceil(Math.abs(_))>=Math.ceil(u)-5){e.style.scrollBehavior="auto",e.scrollLeft=k()?-e.offsetWidth+(Math.ceil(_)-Math.ceil(u)-C):e.offsetWidth+(Math.ceil(_)-Math.ceil(u)-C);return}if(Math.abs(_)===0){e.style.scrollBehavior="auto",e.scrollLeft=k()?-(u-e.offsetWidth+C):u-e.offsetWidth+C;return}}f!==n&&fe(n)},100);E(()=>{const e=g.current;return e==null||e.addEventListener("scroll",V),()=>{e==null||e.removeEventListener("scroll",V)}},[V]);const T=(e,r,s)=>M(pe,{className:P([["pdp-carousel__button",!e],[`pdp-carousel__button--${r}`,!e],[`pdp-carousel__button--${o}`,e]]),style:{"--height":`${ee}px`},variant:"tertiary","aria-label":r==="next"?oe:x,onClick:s,disabled:c?!1:r==="next"?f>=t.length-1:f<1,children:M(De,{className:P([["pdp-carousel__button__icon",!e],[`pdp-carousel__button__icon--${r}`,!e],[`pdp-carousel__button__icon--${o}--${r}`,e]]),size:Re,source:ke})}),ge=l&&t.length!=1&&T(a,"prev",B),_e=l&&t.length!=1&&T(a,"next",z),Pe=l&&t.length!=1&&T(!1,"prev",B),xe=l&&t.length!=1&&T(!1,"next",z);return U("div",{role:"region","aria-roledescription":Z,className:P(["pdp-carousel",["pdp-carousel--main-image-controls",R],["pdp-carousel--arrows",l&&!a],[`pdp-carousel--${o}`,a],ie]),style:{"--flex-carousel":o==="thumbnailsColumn"?"row-reverse":"column","--gap":a?"0":"var(--spacing-small)","--width":D},...O,children:[M("div",{ref:g,className:P(["pdp-carousel__wrapper",`pdp-carousel__wrapper--${L}`,["pdp-carousel__wrapper--scrollbar",p],["pdp-carousel__wrapper--peak",y]]),style:{"--total-width":o==="thumbnailsColumn"?"81.6%":"100%","--height":o==="thumbnailsColumn"?"auto":ne,"--gap":w?`var(--spacing-${w})`:"0px","--per-page":d},tabIndex:0,children:t.map((e,r)=>{const s=e.length<d;return M("div",{role:"group","aria-roledescription":ce,"data-index":r,className:P(["pdp-carousel__slide",`pdp-carousel__slide--${L}`,["pdp-carousel__slide--active",f===r],["pdp-carousel__slide--orphan",s]]),style:{"--length":e.length},children:e},r)})}),!a&&U(be,{children:[ge,_e]}),a&&R&&U(be,{children:[Pe,xe]}),o&&t.length!=1&&U("div",{className:P([[`pdp-carousel__controls__container--${o}`,a],["pdp-carousel__controls__container--no-arrows",!l||R]]),style:{"--width":o==="thumbnailsRow"?`${S}px`:D,"--height":`${ee}px`,"--nr-thumbnails":se.length},children:[(a||Y)&&!R&&ge,M("div",{ref:h,className:P([[`pdp-carousel__controls__wrapper--${o}`,a],["pdp-carousel__controls__wrapper",a]]),children:M("div",{role:"group","aria-label":j,className:P(["pdp-carousel__controls",[`pdp-carousel__controls--${o}`,a]]),children:(c?t.slice(0,v):t).map((e,r)=>{const s=c?v:t.length,n=c?f-1===r:f===r;return a?U("label",{className:P(["pdp-carousel__thumbnail__container"]),ref:u=>{u&&(G.current[r]=u)},children:[M("input",{type:"radio",name:"carousel-thumbnails","aria-label":H.replace("{key}",String(r+1)).replace("{total}",String(s)),checked:n&&S!==0,onChange:()=>{m(c?r+1:r,!0)},...O,className:P(["pdp-carousel__thumbnail",["pdp-carousel__thumbnail--selected",n&&S!==0]])}),M("span",{className:P(["pdp-carousel__thumbnail__span"]),children:se[r]})]},r):M("button",{"aria-label":H.replace("{key}",String(r+1)).replace("{total}",String(s)),onClick:()=>{m(c?r+1:r,!0)},className:P(["pdp-carousel__controls__button",["pdp-carousel__controls__button--active",n]])},r)})})}),(a||Y)&&!R&&_e]})]})};function Le(i,p=0){if(typeof i=="number")return i;const{small:y,medium:l,large:o}=i,c=[{breakpoint:1024,value:o},{breakpoint:786,value:l},{breakpoint:0,value:y}].find(({breakpoint:w})=>p>w);return c?c.value:y}function k(){return document.documentElement.dir==="rtl"}const Fe=({centered:i,onClose:p,className:y,children:l,...o})=>{const R=q("PDP.Overlay.Close.label").label,c=A(null),w=re(()=>{p==null||p()},[p]);return E(()=>{const L=D=>{D.key==="Escape"&&w()};return document.addEventListener("keydown",L),()=>{document.removeEventListener("keydown",L)}},[w]),E(()=>{const L=c.current;L==null||L.focus();const D=document.scrollingElement,ne=D.style.overflow;return D.style.overflow="hidden",()=>{D.style.overflow=ne}},[]),U("div",{...o,className:P(["pdp-overlay",["pdp-overlay--centered",i],y]),ref:c,role:"dialog","aria-describedby":"overlay-content",tabindex:0,children:[M("div",{className:"pdp-overlay__content",id:"overlay-content",children:l}),M(pe,{"aria-label":R,variant:"tertiary",className:"pdp-overlay__close-button",onClick:w,icon:M(Ce,{})})]})},qe=({children:i,scale:p=2,closeButton:y=!0})=>{var se;const[l,o]=$(!1),[R,c]=$("pdp-zoom"),[w,L]=$(!1),[D,ne]=$({x:0,y:0}),[X,ie]=$({x:0,y:0}),[W,J]=$({x:0,y:0}),Y=A(null),O=A(null),Z=A(null),ce=A("none"),x=A(null),oe=A(!1),j=A(null),H=re(t=>{const g=()=>{var T;let h;O.current&&Y.current?h=O.current:Y.current?(h=Y.current.getBoundingClientRect(),O.current=h):h=(T=t.currentTarget)==null?void 0:T.getBoundingClientRect();const a=(100-100/p)/2;let b=null;if("touches"in t)if(t.touches.length>0)b=t.touches[0],j.current={clientX:b.clientX,clientY:b.clientY};else if(t.type==="touchend"&&x.current)b={clientX:x.current.x,clientY:x.current.y};else if(j.current)b=j.current;else return;else if(t instanceof MouseEvent)b=t;else return;const m=(b.clientX-h.left)/h.width*100,B=(b.clientY-h.top)/h.height*100,z=(50-m)*(p-1)/p,V=(50-B)*(p-1)/p;J({x:Math.max(-a,Math.min(z,a))||0,y:Math.max(-a,Math.min(V,a))||0})};Z.current&&cancelAnimationFrame(Z.current),Z.current=requestAnimationFrame(g)},[p]);E(()=>{O.current=null},[l]);const d=t=>{!l||t.type!=="touchstart"||(ne({x:t.touches[0].clientX,y:t.touches[0].clientY}),ie({x:W.x,y:W.y}),L(!0))},ue=t=>{var T;if(!w||t.type!=="touchmove")return;const g=(T=t.currentTarget)==null?void 0:T.getBoundingClientRect(),h=(100-100/p)/2,a=t.touches[0].clientX-D.x,b=t.touches[0].clientY-D.y,m=a*100/(g.width*p),B=b*100/(g.height*p),z=X.x+m,V=X.y+B;J({x:Math.max(-h,Math.min(z,h))||0,y:Math.max(-h,Math.min(V,h))||0}),t.preventDefault()},v=t=>{if(y)x.current={x:t.touches[0].clientX,y:t.touches[0].clientY,time:Date.now()},j.current={clientX:t.touches[0].clientX,clientY:t.touches[0].clientY},oe.current=!1,l&&d(t);else{if(w)return;!l&&H(t),o(!l),t.preventDefault()}},C=t=>{if(t.touches.length!==0){if(j.current={clientX:t.touches[0].clientX,clientY:t.touches[0].clientY},y){if(!x.current)return;if(w){ue(t);return}const g=t.touches[0].clientX,h=t.touches[0].clientY,a=Math.abs(g-x.current.x),b=Math.abs(h-x.current.y);(a>10||b>10)&&(oe.current=!0)}l&&H(t)}},Q=t=>{if(y){if(!x.current)return;const g=Date.now()-x.current.time;!oe.current&&g<300&&!w&&(o(!0),H(t),t.preventDefault()),L(!1),x.current=null}else o(!1)},K=t=>{"touches"in t||w||(l?!y&&o(!1):(o(!0),H(t)),t.preventDefault())},f=t=>{"touches"in t||l&&H(t)},fe=t=>{if(!("touches"in t)){if(y){L(!1);return}o(!1)}},G=t=>{o(!1),t.stopPropagation()},S=l?`scale(${p}) translateX(${W.x}%) translateY(${W.y}%)`:"none",he=q("PDP.Zoom.Close.label").label,ee=I.only(i);E(()=>{const t=()=>{l&&(o(!1),J({x:0,y:0}),L(!1))},g=document.querySelector("#gallery");if(g)return g.addEventListener("click",t),()=>g.removeEventListener("click",t)},[l]);const de=We(ee,{...ee.props,draggable:!1,style:{...(se=ee.props)==null?void 0:se.style,"--transform":S}});return E(()=>{c(l?`pdp-zoom ${y?"pdp-zoom--no-effects":"pdp-zoom--zoomed"}`:"pdp-zoom")},[l,y]),E(()=>{if(ce.current===S)return;ce.current=S,requestAnimationFrame(()=>{if(!Y.current)return;Y.current.querySelectorAll("img").forEach(h=>{l&&S!=="none"?h.style.setProperty("transform",S,"important"):h.style.removeProperty("transform")})})},[S,l]),E(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]),U("figure",{ref:Y,className:R,onClick:K,onMouseMove:f,onMouseLeave:fe,onTouchStart:v,onTouchMove:C,onTouchEnd:Q,children:[de,y&&l&&M(pe,{"aria-label":he,variant:"tertiary",className:"pdp-zoom__close-button",icon:M(Ce,{}),onClick:G})]})};export{He as C,Fe as O,qe as Z};
|
|
4
|
+
//# sourceMappingURL=Zoom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Zoom.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/ChevronDown.svg","../../node_modules/@adobe-commerce/elsie/src/icons/Close.svg","/@dropins/storefront-pdp/src/components/Carousel/Carousel.tsx","/@dropins/storefront-pdp/src/components/Overlay/Overlay.tsx","/@dropins/storefront-pdp/src/components/Zoom/Zoom.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgChevronDown = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { d: \"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701\", stroke: \"currentColor\", strokeWidth: 1.5, strokeLinecap: \"square\", strokeLinejoin: \"round\" }));\nexport default SvgChevronDown;\n","import * as React from \"react\";\nconst SvgClose = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M18.3599 5.64001L5.62988 18.37\", stroke: \"currentColor\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M18.3599 18.37L5.62988 5.64001\", stroke: \"currentColor\" }));\nexport default SvgClose;\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 { FunctionComponent, VNode } from 'preact';\nimport {\n HTMLAttributes,\n Children,\n useState,\n useRef,\n useEffect,\n useMemo,\n useCallback,\n} from 'preact/compat';\nimport { classes, debounce } from '@adobe-commerce/elsie/lib';\nimport { Button, Icon } from '@adobe-commerce/elsie/components';\nimport { ChevronDown } from '@adobe-commerce/elsie/icons';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nimport '@/pdp/components/Carousel/Carousel.css';\n\ntype Show = number;\n\nconst PEAK_WIDTH = 24;\nconst THUMB_GAP = 16;\nconst ICON_SIZE = '32';\n\nenum GapSize {\n small = 16,\n medium = 24,\n large = 64,\n}\n\nexport interface CarouselProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'controls'> {\n children: VNode[] | VNode;\n thumbnails?: VNode[] | VNode;\n show?: Show | { small: Show; medium: Show; large: Show };\n gap?: 'small' | 'medium' | 'large' | null;\n scrollbar?: boolean;\n peak?: boolean;\n arrows?: boolean;\n controls?: 'thumbnailsRow' | 'thumbnailsColumn' | 'dots' | null;\n arrowsOnMainImage?: boolean;\n loop?: boolean;\n direction?: 'horizontal';\n style?: Record<string, string | number>;\n width?: string;\n height?: string;\n defaultIndex?: number;\n infinite?: boolean;\n isZoomed?: boolean;\n}\n\nexport const Carousel: FunctionComponent<CarouselProps> = ({\n show = 1,\n scrollbar = false,\n peak = false,\n arrows = false,\n controls = 'dots',\n arrowsOnMainImage = false,\n loop = false,\n gap = null,\n direction = 'horizontal',\n width = '100%',\n height = '100%',\n defaultIndex = 0,\n className,\n children,\n thumbnails = null,\n isZoomed,\n ...props\n}) => {\n // i18n\n const Label = useText('PDP.Carousel.label').label;\n const SlideLabel = useText('PDP.Carousel.Slide.label').label;\n const PreviousLabel = useText('PDP.Carousel.Previous.label').label;\n const NextLabel = useText('PDP.Carousel.Next.label').label;\n const ControlsLabel = useText('PDP.Carousel.Controls.label').label;\n const ControlsBtnLabel = useText('PDP.Carousel.Controls.Button.label').label;\n\n // States\n const [perPage, setPerPage] = useState(() => getPerPageFromBreakpoint(show));\n\n // Constants\n const length = Math.ceil(Children.count(children) / perPage);\n\n const peakWidth = peak ? PEAK_WIDTH : 0;\n const gapWidth = gap ? GapSize[gap] : 0;\n const rest = Children.count(children) % perPage;\n\n // States\n const [current, setCurrent] = useState(\n loop ? (isRTL() ? defaultIndex - 1 : defaultIndex + 1) : defaultIndex\n );\n\n // Thumbnails (refs for each thumbnail item)\n const thumbnailsRefs = useRef<HTMLLabelElement[]>([]);\n const [thumbWidth, setThumbWidth] = useState(0);\n const [thumbHeight, setThumbHeight] = useState(0);\n\n // VNodes\n const thumbnailSlides = useMemo<VNode[]>(() => {\n return Children.toArray(thumbnails);\n }, [thumbnails]);\n\n // Slides\n const slides = useMemo<VNode[][]>(() => {\n const returnValue = Children.toArray(children).reduce((acc, child, i) => {\n if (i % perPage === 0) {\n return [...acc, [child]];\n }\n\n return [...acc.slice(0, -1), [...acc[acc.length - 1], child]];\n }, [] as VNode[][]);\n\n if (!loop || returnValue.length === 1) {\n return returnValue;\n }\n\n if (loop && !(Children.count(children) % perPage !== 0)) {\n return [returnValue[length - 1]]\n .concat(returnValue)\n .concat([returnValue[0], returnValue[1]]);\n }\n\n return [Children.toArray(children).slice(-perPage)]\n .concat(returnValue)\n .concat([returnValue[0], returnValue[1]]);\n }, [children, perPage, length, loop]);\n\n // Wrapper\n const wrapperRef = useRef<HTMLDivElement>(null);\n const thumbnailsWrapperRef = useRef<HTMLDivElement>(null);\n\n const thumbnailControls =\n controls === 'thumbnailsRow' || controls === 'thumbnailsColumn';\n\n // Observe Resize (responsive)\n useEffect(() => {\n const wrapper = wrapperRef.current;\n\n if (!wrapper) return; // Guard clause in case the ref is not set yet\n\n const handleResize = debounce(() => {\n setThumbWidth(wrapper.offsetWidth ?? 0);\n setThumbHeight(wrapper.offsetHeight ?? 0);\n const width = window.innerWidth;\n const newPerPage = getPerPageFromBreakpoint(show, width);\n\n if (newPerPage !== perPage) {\n setPerPage(newPerPage);\n }\n }, 50);\n\n const observer = new ResizeObserver(handleResize);\n observer.observe(wrapper);\n\n return () => {\n observer.unobserve(wrapper);\n };\n }, [perPage, show]);\n\n // Scrolling logic controls\n const handleThumbnailsScroll = useCallback(\n (nextSlideIndex: number) => {\n const nextItem = loop ? nextSlideIndex - 1 : nextSlideIndex;\n const thumbnailRef = thumbnailsRefs?.current[0];\n const oneItemWidth = thumbnailRef?.offsetWidth + THUMB_GAP;\n const oneItemHeight = thumbnailRef?.offsetHeight + THUMB_GAP;\n const thumbnailsWrapper = thumbnailsWrapperRef.current!;\n\n const isRow = controls === 'thumbnailsRow';\n const isColumn = controls === 'thumbnailsColumn';\n const offset = isRow\n ? thumbnailsWrapper?.offsetWidth\n : thumbnailsWrapper?.offsetHeight;\n const oneItemSize = isRow ? oneItemWidth : oneItemHeight;\n\n if ((isRow || isColumn) && offset) {\n const visibleThumbnails = Math.floor(\n (isRow\n ? thumbnailsWrapper.clientWidth\n : thumbnailsWrapper.clientHeight) / oneItemSize\n );\n const centerOffset = Math.floor(visibleThumbnails / 2);\n const targetScrollPosition = (nextItem - centerOffset) * oneItemSize;\n thumbnailsWrapper.style.scrollBehavior = 'smooth';\n\n if (isRow) {\n thumbnailsWrapper.scrollLeft = isRTL()\n ? -(\n thumbnailsWrapper.scrollWidth -\n thumbnailsWrapper.clientWidth -\n targetScrollPosition\n )\n : targetScrollPosition;\n } else {\n thumbnailsWrapper.scrollTop = targetScrollPosition;\n }\n }\n },\n [controls, loop]\n );\n\n useEffect(() => {\n handleThumbnailsScroll(current);\n }, [current, handleThumbnailsScroll]);\n\n // Navigation\n const handleScrollTo = useCallback(\n (nextSlideIndex: number, smooth?: boolean, reset?: boolean) => {\n if (thumbnailControls) {\n handleThumbnailsScroll(nextSlideIndex);\n }\n\n const wrapper = wrapperRef.current!;\n const realWidth = peakWidth\n ? wrapper.offsetWidth - peakWidth\n : wrapper.offsetWidth - peakWidth + gapWidth;\n\n const items = Array.from(wrapper.querySelectorAll('[data-index]')).filter(\n (element) => {\n const dataIndex = Number(element.getAttribute('data-index')!);\n return !isNaN(dataIndex) && dataIndex > -1;\n }\n );\n\n const item = items[nextSlideIndex];\n\n if (!item) {\n return;\n }\n\n if (reset) {\n const futureIndex = nextSlideIndex === 0 ? length : 0;\n const scrollWidth =\n realWidth * (length + (rest ? rest : perPage) / perPage);\n\n if (isRTL()) {\n if (\n wrapper.scrollLeft <= 0 &&\n wrapper.scrollLeft > -(realWidth - 5)\n ) {\n handleScrollTo(1, true);\n return;\n }\n if (\n wrapper.scrollLeft < realWidth - scrollWidth &&\n wrapper.scrollLeft >= -scrollWidth\n ) {\n handleScrollTo(length, true);\n return;\n }\n\n wrapper.style.scrollBehavior = 'auto';\n wrapper.scrollLeft = futureIndex === 0 ? 0 : -scrollWidth;\n handleScrollTo(futureIndex === 0 ? 1 : length, true);\n } else {\n if (wrapper.scrollLeft >= 0 && wrapper.scrollLeft < realWidth - 5) {\n handleScrollTo(1, true);\n return;\n }\n\n if (\n wrapper.scrollLeft > scrollWidth - realWidth &&\n wrapper.scrollLeft <= scrollWidth\n ) {\n handleScrollTo(length, true);\n return;\n }\n\n wrapper.style.scrollBehavior = 'auto';\n wrapper.scrollLeft = futureIndex === 0 ? 0 : scrollWidth;\n handleScrollTo(futureIndex === 0 ? 1 : length, true);\n return;\n }\n }\n\n const diff =\n ((wrapper.offsetWidth - gapWidth) / perPage) *\n slides[nextSlideIndex].length -\n peakWidth;\n\n wrapper.style.scrollBehavior = smooth ? 'smooth' : 'auto';\n wrapper.scrollLeft = isRTL()\n ? -(slides[nextSlideIndex].length === perPage\n ? realWidth * nextSlideIndex\n : realWidth * (nextSlideIndex - 1) - diff)\n : slides[nextSlideIndex].length === perPage\n ? realWidth * nextSlideIndex\n : realWidth * (nextSlideIndex - 1) + diff;\n return;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n gapWidth,\n length,\n peakWidth,\n perPage,\n rest,\n slides,\n handleThumbnailsScroll,\n controls,\n ]\n );\n\n const handleGoToPrev = useCallback(() => {\n if (loop) {\n const nextSlideIndex = current - 1;\n handleScrollTo(\n nextSlideIndex,\n true,\n isRTL() ? current === length - 1 : current === 1\n );\n return;\n }\n\n const nextSlideIndex = current <= 0 ? 0 : current - 1;\n handleScrollTo(nextSlideIndex, true);\n }, [current, handleScrollTo, loop]); //eslint-disable-line react-hooks/exhaustive-deps\n\n const handleGoToNext = useCallback(() => {\n const lastSlideIndex = slides.length - 1;\n\n if (loop) {\n const nextSlideIndex = current + 1;\n handleScrollTo(\n nextSlideIndex,\n true,\n isRTL() ? current === 0 : current === length\n );\n return;\n }\n\n const nextSlideIndex =\n current >= lastSlideIndex ? lastSlideIndex : current + 1;\n\n handleScrollTo(nextSlideIndex, true);\n }, [slides.length, loop, current, handleScrollTo, length]);\n\n // Navigate with keyboard\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowLeft') {\n event.preventDefault();\n isRTL() ? handleGoToNext() : handleGoToPrev();\n }\n\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n isRTL() ? handleGoToPrev() : handleGoToNext();\n }\n };\n\n window.addEventListener('keydown', handleKeyDown);\n\n return () => {\n window.removeEventListener('keydown', handleKeyDown);\n };\n }, [handleGoToNext, handleGoToPrev]);\n\n // Set default index\n useEffect(() => {\n handleScrollTo(loop ? defaultIndex + 1 : defaultIndex, false);\n }, [defaultIndex, handleScrollTo, loop]);\n\n // Track scrolling (swipes)\n const handleOnScroll = debounce(() => {\n const wrapper = wrapperRef.current!;\n const realWidth = peakWidth\n ? wrapper.offsetWidth - peakWidth\n : wrapper.offsetWidth - peakWidth + gapWidth;\n\n const dividing = Math.abs(wrapper.scrollLeft) / realWidth;\n const nextSlideIndex = Math.abs(\n Math.round(dividing) - dividing < 1\n ? Math.round(dividing)\n : Math.ceil(dividing)\n );\n\n if (thumbnailControls) {\n handleThumbnailsScroll(nextSlideIndex);\n }\n\n if (loop) {\n const totalWidth =\n realWidth * (length + (rest ? rest : perPage) / perPage);\n const scrollOffset = isRTL() ? -wrapper.scrollLeft : wrapper.scrollLeft;\n\n if (Math.ceil(Math.abs(scrollOffset)) >= Math.ceil(totalWidth) - 5) {\n wrapper.style.scrollBehavior = 'auto';\n wrapper.scrollLeft = isRTL()\n ? -wrapper.offsetWidth +\n (Math.ceil(scrollOffset) - Math.ceil(totalWidth) - peakWidth)\n : wrapper.offsetWidth +\n (Math.ceil(scrollOffset) - Math.ceil(totalWidth) - peakWidth);\n return;\n }\n\n if (Math.abs(scrollOffset) === 0) {\n wrapper.style.scrollBehavior = 'auto';\n\n wrapper.scrollLeft = isRTL()\n ? -(totalWidth - wrapper.offsetWidth + peakWidth)\n : totalWidth - wrapper.offsetWidth + peakWidth;\n return;\n }\n }\n\n if (current !== nextSlideIndex) {\n setCurrent(nextSlideIndex);\n }\n }, 100);\n\n useEffect(() => {\n const wrapper = wrapperRef.current;\n wrapper?.addEventListener('scroll', handleOnScroll);\n\n return () => {\n wrapper?.removeEventListener('scroll', handleOnScroll);\n };\n }, [handleOnScroll]);\n\n // thumbnails is column -> container is row reverse, controls is column\n // thumbnails is row -> container is column, controls is row\n const getArrow = (\n forThumbnails: boolean,\n direction: string,\n callback: () => void\n ) => {\n return (\n <Button\n className={classes([\n ['pdp-carousel__button', !forThumbnails],\n [`pdp-carousel__button--${direction}`, !forThumbnails],\n [`pdp-carousel__button--${controls}`, forThumbnails],\n ])}\n style={{\n '--height': `${thumbHeight}px`,\n }}\n variant=\"tertiary\"\n aria-label={direction === 'next' ? NextLabel : PreviousLabel}\n onClick={callback}\n disabled={\n loop\n ? false\n : direction === 'next'\n ? current >= slides.length - 1\n : current < 1\n }\n >\n <Icon\n className={classes([\n ['pdp-carousel__button__icon', !forThumbnails],\n [`pdp-carousel__button__icon--${direction}`, !forThumbnails],\n [\n `pdp-carousel__button__icon--${controls}--${direction}`,\n forThumbnails,\n ],\n ])}\n size={ICON_SIZE}\n source={ChevronDown}\n />\n </Button>\n );\n };\n\n const prevArrow =\n arrows &&\n slides.length != 1 &&\n getArrow(thumbnailControls, 'prev', handleGoToPrev);\n\n const nextArrow =\n arrows &&\n slides.length != 1 &&\n getArrow(thumbnailControls, 'next', handleGoToNext);\n\n const prevArrowMainImage =\n arrows && slides.length != 1 && getArrow(false, 'prev', handleGoToPrev);\n\n const nextArrowMainImage =\n arrows && slides.length != 1 && getArrow(false, 'next', handleGoToNext);\n\n return (\n <div\n role=\"region\"\n aria-roledescription={Label}\n className={classes([\n 'pdp-carousel',\n ['pdp-carousel--main-image-controls', arrowsOnMainImage],\n ['pdp-carousel--arrows', arrows && !thumbnailControls],\n [`pdp-carousel--${controls}`, thumbnailControls],\n className,\n ])}\n style={{\n '--flex-carousel':\n controls === 'thumbnailsColumn' ? 'row-reverse' : 'column',\n '--gap': thumbnailControls ? '0' : 'var(--spacing-small)',\n '--width': width,\n }}\n {...props}\n >\n {/* Slideshow */}\n <div\n ref={wrapperRef}\n className={classes([\n 'pdp-carousel__wrapper',\n `pdp-carousel__wrapper--${direction}`,\n ['pdp-carousel__wrapper--scrollbar', scrollbar],\n ['pdp-carousel__wrapper--peak', peak],\n ])}\n style={{\n '--total-width': controls === 'thumbnailsColumn' ? `81.6%` : `100%`,\n '--height': controls === 'thumbnailsColumn' ? 'auto' : height,\n '--gap': gap ? `var(--spacing-${gap})` : '0px',\n '--per-page': perPage,\n }}\n tabIndex={0}\n >\n {slides.map((page, index) => {\n const orphan = page.length < perPage;\n\n return (\n <div\n key={index}\n role=\"group\"\n aria-roledescription={SlideLabel}\n data-index={index}\n className={classes([\n 'pdp-carousel__slide',\n `pdp-carousel__slide--${direction}`,\n ['pdp-carousel__slide--active', current === index],\n ['pdp-carousel__slide--orphan', orphan],\n ])}\n style={{\n '--length': page.length,\n }}\n >\n {page}\n </div>\n );\n })}\n </div>\n\n {/* Previous and next arrows for Carousel without thumbnails */}\n {!thumbnailControls && (\n <>\n {prevArrow}\n {nextArrow}\n </>\n )}\n\n {thumbnailControls && arrowsOnMainImage && (\n <>\n {prevArrowMainImage}\n {nextArrowMainImage}\n </>\n )}\n\n {/* Controls */}\n {controls && slides.length != 1 && (\n <div\n className={classes([\n [\n `pdp-carousel__controls__container--${controls}`,\n thumbnailControls,\n ],\n [\n 'pdp-carousel__controls__container--no-arrows',\n !arrows || arrowsOnMainImage,\n ],\n ])}\n style={{\n '--width': controls === 'thumbnailsRow' ? `${thumbWidth}px` : width,\n '--height': `${thumbHeight}px`,\n '--nr-thumbnails': thumbnailSlides.length,\n }}\n >\n {(thumbnailControls || isZoomed) && !arrowsOnMainImage && prevArrow}\n\n <div\n ref={thumbnailsWrapperRef}\n className={classes([\n [\n `pdp-carousel__controls__wrapper--${controls}`,\n thumbnailControls,\n ],\n [`pdp-carousel__controls__wrapper`, thumbnailControls],\n ])}\n >\n <div\n role=\"group\"\n aria-label={ControlsLabel}\n className={classes([\n 'pdp-carousel__controls',\n [`pdp-carousel__controls--${controls}`, thumbnailControls],\n ])}\n >\n {(loop ? slides.slice(0, length) : slides).map((_, key) => {\n const buttonsLength = loop ? length : slides.length;\n const active = loop ? current - 1 === key : current === key;\n\n if (!thumbnailControls) {\n return (\n <button\n key={key}\n aria-label={ControlsBtnLabel.replace(\n '{key}',\n String(key + 1)\n ).replace('{total}', String(buttonsLength))}\n onClick={() => {\n handleScrollTo(loop ? key + 1 : key, true);\n }}\n className={classes([\n 'pdp-carousel__controls__button',\n ['pdp-carousel__controls__button--active', active],\n ])}\n />\n );\n }\n return (\n <label\n className={classes(['pdp-carousel__thumbnail__container'])}\n key={key}\n ref={(el: HTMLLabelElement | null) => {\n if (el) {\n thumbnailsRefs.current[key] = el;\n }\n }}\n >\n <input\n type=\"radio\"\n name={'carousel-thumbnails'}\n aria-label={ControlsBtnLabel.replace(\n '{key}',\n String(key + 1)\n ).replace('{total}', String(buttonsLength))}\n checked={active && thumbWidth !== 0}\n onChange={() => {\n handleScrollTo(loop ? key + 1 : key, true);\n }}\n {...props}\n className={classes([\n 'pdp-carousel__thumbnail',\n [\n 'pdp-carousel__thumbnail--selected',\n active && thumbWidth !== 0,\n ],\n ])}\n />\n\n <span\n className={classes(['pdp-carousel__thumbnail__span'])}\n >\n {thumbnailSlides[key]}\n </span>\n </label>\n );\n })}\n </div>\n </div>\n\n {(thumbnailControls || isZoomed) && !arrowsOnMainImage && nextArrow}\n </div>\n )}\n </div>\n );\n};\n\n// Utilities\nfunction getPerPageFromBreakpoint(\n breakpoints: { small: number; medium: number; large: number } | number,\n width = 0\n) {\n if (typeof breakpoints === 'number') return breakpoints;\n\n const { small, medium, large } = breakpoints;\n const breakpointsMap = [\n { breakpoint: 1024, value: large },\n { breakpoint: 786, value: medium },\n { breakpoint: 0, value: small },\n ];\n\n const matchingBreakpoint = breakpointsMap.find(\n ({ breakpoint }) => width > breakpoint\n );\n\n return matchingBreakpoint ? matchingBreakpoint.value : small;\n}\n\nfunction isRTL() {\n return document.documentElement.dir === 'rtl';\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 { FunctionComponent } from 'preact';\nimport { HTMLAttributes, useCallback, useEffect, useRef } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Close as CloseSVG } from '@adobe-commerce/elsie/icons';\nimport { Button } from '@adobe-commerce/elsie/components';\n\nimport '@/pdp/components/Overlay/Overlay.css';\n\nexport interface OverlayProps extends HTMLAttributes<HTMLDivElement> {\n centered?: boolean;\n onClose?: () => void;\n}\n\nexport const Overlay: FunctionComponent<OverlayProps> = ({\n centered,\n onClose,\n className,\n children,\n ...props\n}) => {\n // i18n\n const CloseLabel = useText('PDP.Overlay.Close.label').label;\n const overlayRef = useRef<HTMLInputElement>(null);\n const handleOnClose = useCallback(() => {\n onClose?.();\n }, [onClose]);\n\n // Close on ESC\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleOnClose();\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n }, [handleOnClose]);\n\n // Prevent document scrolling\n useEffect(() => {\n const input = overlayRef.current;\n input?.focus();\n\n const scrollingElement = document.scrollingElement as HTMLElement;\n\n const defaultOverflowValue = scrollingElement.style.overflow;\n\n scrollingElement.style.overflow = 'hidden';\n\n return () => {\n scrollingElement.style.overflow = defaultOverflowValue;\n };\n }, []);\n\n return (\n <div\n {...props}\n className={classes([\n 'pdp-overlay',\n ['pdp-overlay--centered', centered],\n className,\n ])}\n ref={overlayRef}\n role=\"dialog\"\n aria-describedby=\"overlay-content\"\n tabindex={0}\n >\n <div className=\"pdp-overlay__content\" id=\"overlay-content\">\n {children}\n </div>\n <Button\n aria-label={CloseLabel}\n variant=\"tertiary\"\n className=\"pdp-overlay__close-button\"\n onClick={handleOnClose}\n icon={<CloseSVG />}\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 */\nimport { cloneElement, FunctionComponent, VNode } from 'preact';\nimport {\n Children,\n useEffect,\n useState,\n useRef,\n useCallback,\n} from 'preact/compat';\n\nimport '@/pdp/components/Zoom/Zoom.css';\nimport { Button } from '@adobe-commerce/elsie/components';\nimport { Close as CloseSVG } from '@adobe-commerce/elsie/icons';\nimport { useText } from '@adobe-commerce/elsie/i18n';\n\nexport interface ZoomProps {\n children: VNode[] | VNode;\n scale?: number;\n closeButton?: boolean;\n}\n\nexport const Zoom: FunctionComponent<ZoomProps> = ({\n children,\n scale = 2.0,\n closeButton = true,\n}) => {\n const [zoomed, setZoomed] = useState(false);\n const [figureClassName, setFigureClassName] = useState('pdp-zoom');\n const [drag, setDrag] = useState(false);\n const [dragStart, setDragStart] = useState({ x: 0, y: 0 });\n const [dragStartPosition, setDragStartPosition] = useState({ x: 0, y: 0 });\n const [position, setPosition] = useState({ x: 0, y: 0 });\n\n const containerRef = useRef<HTMLElement>(null);\n const cachedBoundsRef = useRef<DOMRect | null>(null);\n const animationFrameRef = useRef<number | null>(null);\n const lastTransformRef = useRef<string>('none');\n\n const touchStartRef = useRef<{ x: number; y: number; time: number } | null>(\n null\n );\n const isSwipingRef = useRef<boolean>(false);\n const lastValidTouchRef = useRef<{ clientX: number; clientY: number } | null>(\n null\n );\n\n const updatePosition = useCallback(\n (event: MouseEvent | TouchEvent) => {\n const updatePositionLogic = () => {\n let zoomer: DOMRect;\n\n if (cachedBoundsRef.current && containerRef.current) {\n zoomer = cachedBoundsRef.current;\n } else if (containerRef.current) {\n zoomer = containerRef.current.getBoundingClientRect();\n cachedBoundsRef.current = zoomer;\n } else {\n zoomer = (\n event.currentTarget as HTMLElement\n )?.getBoundingClientRect();\n }\n\n const overlap = (100 - 100 / scale) / 2;\n let coordinates: { clientX: number; clientY: number } | null = null;\n\n if ('touches' in event) {\n if (event.touches.length > 0) {\n coordinates = event.touches[0];\n lastValidTouchRef.current = {\n clientX: coordinates.clientX,\n clientY: coordinates.clientY,\n };\n } else if (event.type === 'touchend' && touchStartRef.current) {\n coordinates = {\n clientX: touchStartRef.current.x,\n clientY: touchStartRef.current.y,\n };\n } else if (lastValidTouchRef.current) {\n coordinates = lastValidTouchRef.current;\n } else {\n return;\n }\n } else if (event instanceof MouseEvent) {\n coordinates = event;\n } else {\n return;\n }\n\n const relativeX =\n ((coordinates.clientX - zoomer.left) / zoomer.width) * 100;\n const relativeY =\n ((coordinates.clientY - zoomer.top) / zoomer.height) * 100;\n\n const x = ((50 - relativeX) * (scale - 1)) / scale;\n const y = ((50 - relativeY) * (scale - 1)) / scale;\n\n setPosition({\n x: Math.max(-overlap, Math.min(x, overlap)) || 0,\n y: Math.max(-overlap, Math.min(y, overlap)) || 0,\n });\n };\n\n if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'test') {\n updatePositionLogic();\n } else {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n animationFrameRef.current = requestAnimationFrame(updatePositionLogic);\n }\n },\n [scale]\n );\n\n useEffect(() => {\n cachedBoundsRef.current = null;\n }, [zoomed]);\n\n const startDrag = (event: TouchEvent) => {\n if (!zoomed || event.type !== 'touchstart') return;\n setDragStart({ x: event.touches[0].clientX, y: event.touches[0].clientY });\n setDragStartPosition({ x: position.x, y: position.y });\n setDrag(true);\n };\n\n const dragMove = (event: TouchEvent) => {\n if (!drag || event.type !== 'touchmove') return;\n const zoomer = (\n event.currentTarget as HTMLElement\n )?.getBoundingClientRect();\n const overlap = (100 - 100 / scale) / 2;\n const movedX = event.touches[0].clientX - dragStart.x;\n const movedY = event.touches[0].clientY - dragStart.y;\n const movedXPercent = (movedX * 100) / (zoomer.width * scale);\n const movedYPercent = (movedY * 100) / (zoomer.height * scale);\n const x = dragStartPosition.x + movedXPercent;\n const y = dragStartPosition.y + movedYPercent;\n setPosition({\n x: Math.max(-overlap, Math.min(x, overlap)) || 0,\n y: Math.max(-overlap, Math.min(y, overlap)) || 0,\n });\n event.preventDefault();\n };\n\n const handleTouchStart = (event: TouchEvent) => {\n if (closeButton) {\n touchStartRef.current = {\n x: event.touches[0].clientX,\n y: event.touches[0].clientY,\n time: Date.now(),\n };\n\n lastValidTouchRef.current = {\n clientX: event.touches[0].clientX,\n clientY: event.touches[0].clientY,\n };\n\n isSwipingRef.current = false;\n\n if (zoomed) {\n startDrag(event);\n }\n } else {\n if (drag) return;\n\n !zoomed && updatePosition(event);\n\n setZoomed(!zoomed);\n\n event.preventDefault();\n }\n };\n\n const handleTouchMove = (event: TouchEvent) => {\n if (event.touches.length === 0) return;\n\n lastValidTouchRef.current = {\n clientX: event.touches[0].clientX,\n clientY: event.touches[0].clientY,\n };\n\n if (closeButton) {\n if (!touchStartRef.current) return;\n\n if (drag) {\n dragMove(event);\n return;\n }\n\n const touchX = event.touches[0].clientX;\n const touchY = event.touches[0].clientY;\n const deltaX = Math.abs(touchX - touchStartRef.current.x);\n const deltaY = Math.abs(touchY - touchStartRef.current.y);\n\n if (deltaX > 10 || deltaY > 10) {\n isSwipingRef.current = true;\n }\n }\n\n if (zoomed) {\n updatePosition(event);\n }\n };\n\n const handleTouchEnd = (event: TouchEvent) => {\n if (closeButton) {\n if (!touchStartRef.current) return;\n\n const tapDuration = Date.now() - touchStartRef.current.time;\n\n if (!isSwipingRef.current && tapDuration < 300 && !drag) {\n setZoomed(true);\n updatePosition(event);\n event.preventDefault();\n }\n\n setDrag(false);\n touchStartRef.current = null;\n } else {\n setZoomed(false);\n }\n };\n\n const handleClick = (event: MouseEvent) => {\n if ('touches' in event) return;\n\n if (drag) return;\n\n if (zoomed) {\n !closeButton && setZoomed(false);\n } else {\n setZoomed(true);\n updatePosition(event);\n }\n event.preventDefault();\n };\n\n const handleMove = (event: MouseEvent) => {\n if ('touches' in event) return;\n\n if (zoomed) {\n updatePosition(event);\n }\n };\n\n const handleLeave = (event: MouseEvent) => {\n if ('touches' in event) return;\n\n if (closeButton) {\n setDrag(false);\n return;\n }\n setZoomed(false);\n };\n\n const closeButtonClick = (event: MouseEvent | TouchEvent) => {\n setZoomed(false);\n event.stopPropagation();\n };\n\n const transformStyle = zoomed\n ? `scale(${scale}) translateX(${position.x}%) translateY(${position.y}%)`\n : 'none';\n\n const CloseLabel = useText('PDP.Zoom.Close.label').label;\n const child = Children.only(children) as any;\n\n useEffect(() => {\n const handleGalleryChange = () => {\n if (zoomed) {\n setZoomed(false);\n setPosition({ x: 0, y: 0 });\n setDrag(false);\n }\n };\n\n const gallery = document.querySelector('#gallery');\n if (gallery) {\n gallery.addEventListener('click', handleGalleryChange);\n return () => gallery.removeEventListener('click', handleGalleryChange);\n }\n }, [zoomed]);\n\n const ImageClone = cloneElement(child, {\n ...child.props,\n draggable: false,\n style: {\n ...child.props?.style,\n '--transform': transformStyle,\n },\n });\n\n useEffect(() => {\n const className = zoomed\n ? `pdp-zoom ${closeButton ? 'pdp-zoom--no-effects' : 'pdp-zoom--zoomed'}`\n : 'pdp-zoom';\n setFigureClassName(className);\n }, [zoomed, closeButton]);\n\n useEffect(() => {\n if (lastTransformRef.current === transformStyle) return;\n lastTransformRef.current = transformStyle;\n\n const updateTransforms = () => {\n if (!containerRef.current) return;\n\n const images = containerRef.current.querySelectorAll('img');\n images.forEach((img) => {\n if (zoomed && transformStyle !== 'none') {\n img.style.setProperty('transform', transformStyle, 'important');\n } else {\n img.style.removeProperty('transform');\n }\n });\n };\n\n requestAnimationFrame(updateTransforms);\n }, [transformStyle, zoomed]);\n\n useEffect(() => {\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n };\n }, []);\n\n return (\n <figure\n ref={containerRef}\n className={figureClassName}\n onClick={handleClick}\n onMouseMove={handleMove}\n onMouseLeave={handleLeave}\n onTouchStart={handleTouchStart}\n onTouchMove={handleTouchMove}\n onTouchEnd={handleTouchEnd}\n >\n {ImageClone}\n {closeButton && zoomed && (\n <Button\n aria-label={CloseLabel}\n variant=\"tertiary\"\n className=\"pdp-zoom__close-button\"\n icon={<CloseSVG />}\n onClick={closeButtonClick}\n />\n )}\n </figure>\n );\n};\n"],"names":["SvgChevronDown","props","React","SvgClose","PEAK_WIDTH","THUMB_GAP","ICON_SIZE","GapSize","Carousel","show","scrollbar","peak","arrows","controls","arrowsOnMainImage","loop","gap","direction","width","height","defaultIndex","className","children","thumbnails","isZoomed","Label","useText","SlideLabel","PreviousLabel","NextLabel","ControlsLabel","ControlsBtnLabel","perPage","setPerPage","useState","getPerPageFromBreakpoint","length","Children","peakWidth","gapWidth","rest","current","setCurrent","isRTL","thumbnailsRefs","useRef","thumbWidth","setThumbWidth","thumbHeight","setThumbHeight","thumbnailSlides","useMemo","slides","returnValue","acc","child","i","wrapperRef","thumbnailsWrapperRef","thumbnailControls","useEffect","wrapper","handleResize","debounce","newPerPage","observer","handleThumbnailsScroll","useCallback","nextSlideIndex","nextItem","thumbnailRef","oneItemWidth","oneItemHeight","thumbnailsWrapper","isRow","isColumn","offset","oneItemSize","visibleThumbnails","centerOffset","targetScrollPosition","handleScrollTo","smooth","reset","realWidth","element","dataIndex","futureIndex","scrollWidth","diff","handleGoToPrev","handleGoToNext","lastSlideIndex","handleKeyDown","event","handleOnScroll","dividing","totalWidth","scrollOffset","getArrow","forThumbnails","callback","jsx","Button","classes","Icon","ChevronDown","prevArrow","nextArrow","prevArrowMainImage","nextArrowMainImage","jsxs","page","index","orphan","Fragment","_","key","buttonsLength","active","el","breakpoints","small","medium","large","matchingBreakpoint","breakpoint","Overlay","centered","onClose","CloseLabel","overlayRef","handleOnClose","input","scrollingElement","defaultOverflowValue","CloseSVG","Zoom","scale","closeButton","zoomed","setZoomed","figureClassName","setFigureClassName","drag","setDrag","dragStart","setDragStart","dragStartPosition","setDragStartPosition","position","setPosition","containerRef","cachedBoundsRef","animationFrameRef","lastTransformRef","touchStartRef","isSwipingRef","lastValidTouchRef","updatePosition","updatePositionLogic","zoomer","_a","overlap","coordinates","relativeX","relativeY","x","y","startDrag","dragMove","movedX","movedY","movedXPercent","movedYPercent","handleTouchStart","handleTouchMove","touchX","touchY","deltaX","deltaY","handleTouchEnd","tapDuration","handleClick","handleMove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AHkBH,EACd,YAAYD,EAAc,uBAAyB,kBAAkB,GACrE,UACwB,CAAA,EAC3B,CAACC,EAAQD,CAAW,CAAC,EAExB/E,EAAU,IAAM,CACV,GAAA+F,GAAiB,UAAYgC,EAAgB,OACjDhC,GAAiB,QAAUgC,EAe3B,sBAbyB,IAAM,CACzB,GAAA,CAACnC,EAAa,QAAS,OAEZA,EAAa,QAAQ,iBAAiB,KAAK,EACnD,QAASwC,GAAQ,CAClBpD,GAAU+C,IAAmB,OAC/BK,EAAI,MAAM,YAAY,YAAaL,EAAgB,WAAW,EAE1DK,EAAA,MAAM,eAAe,WAAW,CACtC,CACD,CACH,CAEsC,CAAA,EACrC,CAACL,EAAgB/C,CAAM,CAAC,EAE3BhF,EAAU,IACD,IAAM,CACP8F,EAAkB,SACpB,qBAAqBA,EAAkB,OAAO,CAElD,EACC,EAAE,EAGH3C,EAAC,SAAA,CACC,IAAKyC,EACL,UAAWV,EACX,QAASyC,EACT,YAAaC,EACb,aAAcC,GACd,aAAcV,EACd,YAAaC,EACb,WAAYK,EAEX,SAAA,CAAAS,GACAnD,GAAeC,GACdtC,EAACC,GAAA,CACC,aAAY2B,GACZ,QAAQ,WACR,UAAU,yBACV,OAAOM,GAAS,EAAA,EAChB,QAASkD,CAAA,CAAA,CACX,CAAA,CAEJ,CAEJ","x_google_ignoreList":[0,1]}
|
package/chunks/date.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
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};
|
|
4
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sources":["/@dropins/storefront-pdp/src/lib/date.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\nimport { toLanguageTag } from '@adobe-commerce/elsie/lib';\n\nexport function toDateString(value: string, locale = 'en_US') {\n if (!isDateValid(value)) throw Error('Invalid date string');\n\n // normalize time to 00:00:00\n const time = value.split(' ')[1];\n if (!time) value = `${value} 00:00:00`;\n\n return new Date(value).toLocaleDateString(toLanguageTag(locale)).toString();\n}\n\nexport function isDateValid(dateString: string) {\n const acceptedFormats = [\n /^\\d{4}-\\d{2}-\\d{2}$/, // YYYY-MM-DD\n /^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$/, // MM/DD/YYYY\n /^\\d{2}\\/\\d{2}\\/\\d{4}$/, // MM/DD/YYYY\n /^\\d{4}\\/\\d{2}\\/\\d{2}$/, // YYYY/MM/DD\n /^\\d{1,2}\\.\\d{1,2}\\.\\d{4}$/, // DD.MM.YYYY\n /^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/, // YYYY-MM-DD HH:mm:ss\n ];\n\n if (!acceptedFormats.some((format) => format.test(dateString))) return false;\n\n const date = new Date(dateString);\n return !isNaN(date.getTime());\n}\n"],"names":["toDateString","value","locale","isDateValid","toLanguageTag","dateString","format","date"],"mappings":"sDAkBgB,SAAAA,EAAaC,EAAeC,EAAS,QAAS,CAC5D,GAAI,CAACC,EAAYF,CAAK,EAAG,MAAM,MAAM,qBAAqB,EAI1D,OADaA,EAAM,MAAM,GAAG,EAAE,CAAC,IACZA,EAAA,GAAGA,CAAK,aAEpB,IAAI,KAAKA,CAAK,EAAE,mBAAmBG,EAAcF,CAAM,CAAC,EAAE,SAAS,CAC5E,CAEO,SAASC,EAAYE,EAAoB,CAU1C,GAAA,CAToB,CACtB,sBACA,4BACA,wBACA,wBACA,4BACA,uCACF,EAEqB,KAAMC,GAAWA,EAAO,KAAKD,CAAU,CAAC,EAAU,MAAA,GAEjE,MAAAE,EAAO,IAAI,KAAKF,CAAU,EAChC,MAAO,CAAC,MAAME,EAAK,SAAS,CAC9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
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};
|
|
4
|
+
//# sourceMappingURL=getFetchedProductData.js.map
|
|
@@ -0,0 +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 (events._lastEvent['pdp/data']) {\n return Promise.resolve(events._lastEvent['pdp/data'].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 }\n );\n });\n};\n"],"names":["getFetchedProductData","events","resolve","event","data"],"mappings":"qDAmBO,MAAMA,EAAwB,SAE/BC,EAAO,WAAW,UAAU,EACvB,QAAQ,QAAQA,EAAO,WAAW,UAAU,EAAE,OAAO,EAIvD,IAAI,QAASC,GAAY,CAC9B,MAAMC,EAAQF,EAAO,GACnB,WACCG,GAAS,CACRF,EAAQE,CAAI,EACZD,GAAA,MAAAA,EAAO,KACT,EACA,CAAE,MAAO,EAAK,CAChB,CAAA,CACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{merge as oe,Initializer as
|
|
3
|
+
import{merge as oe,Initializer as ue}from"@dropins/tools/lib.js";import{events as p}from"@dropins/tools/event-bus.js";import{PRODUCT_FRAGMENT as ne}from"../fragments.js";import{FetchGraphQL as le}from"@dropins/tools/fetch-graphql.js";function Le(e){const n=new URLSearchParams(window.location.search);Object.entries(e).forEach(([i,t])=>{t===null?n.delete(i):n.set(i,String(t))});let r=window.location.pathname;r+=`?${n.toString()}`,r+=window.location.hash,window.history.replaceState({},"",r)}function ie(){const e=new URLSearchParams(window.location.search),n={};return e.forEach((r,i)=>{n[i]=r}),n}function me(e=1){const r=(ie()||{}).quantity;if(r){const i=parseInt(r,10);if(!isNaN(i)&&Number.isInteger(i)&&i>0)return i}return e}function ce(e){var n,r,i,t,s,a,l,o,m,u,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:((r=(n=e==null?void 0:e.prices)==null?void 0:n.regular)==null?void 0:r.amount)||0,minimalPrice:(t=(i=e==null?void 0:e.prices)==null?void 0:i.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:(o=(l=e==null?void 0:e.prices)==null?void 0:l.final)==null?void 0:o.amount,tierPricing:void 0,currencyCode:((u=(m=e==null?void 0:e.prices)==null?void 0:m.final)==null?void 0:u.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"},Pe={PRODUCT_PAGE_VIEW:"product-page-view"};function re(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function de(e,n){const r=re();r.push({[e]:null}),r.push({[e]:n})}function he(e,n){re().push(i=>{const t=i.getState?i.getState():{};i.push({event:e,eventInfo:{...t,...n}})})}function ye(e){const n=ce(e);de(fe.PRODUCT_CONTEXT,n),he(Pe.PRODUCT_PAGE_VIEW)}var q=(e=>(e.ComplexProduct="complex",e.SimpleProduct="simple",e))(q||{}),se=(e=>(e.ComplexProductView="ComplexProductView",e.SimpleProductView="SimpleProductView",e))(se||{});function K(e,n){var a,l,o,m,u,c,f,d,h,w,P,b;const r=((m=(o=(l=(a=e==null?void 0:e.options)==null?void 0:a[0])==null?void 0:l.values)==null?void 0:o[0])==null?void 0:m.__typename)==="ProductViewOptionValueProduct",i=pe(e,r,n==null?void 0:n.preselectFirstOption),t=(e==null?void 0:e.__typename)===se.SimpleProductView?q.SimpleProduct:q.ComplexProduct,s=e?{name:e.name,sku:e.sku,isBundle:r,addToCartAllowed:e.addToCartAllowed,inStock:e.inStock,shortDescription:e.shortDescription,metaDescription:e.metaDescription,metaKeyword:e.metaKeyword,metaTitle:e.metaTitle,description:e.description,images:we(e),prices:Ee(e,r,i),attributes:ge(e),options:De(e,r),optionUIDs:i,url:e.url,urlKey:e.urlKey,externalId:e.externalId,externalParentId:e.externalParentId,variantSku:e.variantSku,productType:t}:null;return oe(s,((d=(f=(c=(u=_.getConfig())==null?void 0:u.models)==null?void 0:c.ProductDetails)==null?void 0:f.transformer)==null?void 0:d.call(f,e))??((b=(P=(w=(h=_.getConfig())==null?void 0:h.models)==null?void 0:w.ProductDetails)==null?void 0:P.transform)==null?void 0:b.call(P,e)))}function we(e){var n,r;return(r=(n=e.images)==null?void 0:n.filter(i=>{var t;return!((t=i.roles)!=null&&t.includes("hide_from_pdp"))}))==null?void 0:r.map(i=>(i.url=i.url.replace(/^https?:/,""),i))}function ge(e){var n,r;return(r=(n=e.attributes)==null?void 0:n.filter(({roles:i})=>(i==null?void 0:i.indexOf("visible_in_pdp"))!==-1))==null?void 0:r.map(({label:i,value:t,name:s})=>({id:s,label:i,value:t.toString().split(",").join(", ")}))}function De(e,n){const{options:r,optionUIDs:i}=e;return r==null?void 0:r.map(({id:t,title:s,required:a,multi:l,values:o})=>{var c;const m=(c=o==null?void 0:o[0])==null?void 0:c.__typename;let u=o==null?void 0:o[0].type;return u?u=u.replace("COLOR_HEX","color").replace("TEXT","text").replace("IMAGE","image"):u="dropdown",{id:t,type:u,typename:m,label:s,required:a,multiple:l,items:n?Ce(o,i):xe(o,i,u)}})}function Ce(e,n){return e==null?void 0:e.filter(({enabled:r})=>typeof r>"u"||r).map(({id:r,title:i,inStock:t,isDefault:s,product:a})=>({id:r,inStock:t,label:i,selected:(n==null?void 0:n.indexOf(r))>-1||s,value:r,product:a}))}function xe(e,n,r){return e==null?void 0:e.map(({id:i,title:t,inStock:s,value:a})=>({id:i,inStock:s,label:t,selected:(n==null?void 0:n.indexOf(i))>-1,value:(r==null?void 0:r.toLowerCase())==="dropdown"?i:a==null?void 0:a.replace(/^https?:/,"")}))}function Ee(e,n,r){var P,b,X,B,z;const{price:i,priceRange:t,options:s,optionUIDs:a=r}=e;let{__typename:l}=e;function o(){var x;const D=i.regular.amount.value,y=((x=i.final)==null?void 0:x.amount.value)??i.regular.amount.value,C=i.regular.amount.currency==="NONE"?"USD":i==null?void 0:i.regular.amount.currency;return[D,y,y,C]}function m(){var T,O,k,v,U,A,I,V,F,N,G,M;const D=(T=t==null?void 0:t.minimum)==null?void 0:T.final.amount.value,y=(O=t==null?void 0:t.maximum)==null?void 0:O.final.amount.value;let C;((v=(k=t==null?void 0:t.minimum)==null?void 0:k.regular)==null?void 0:v.amount.value)===((A=(U=t==null?void 0:t.maximum)==null?void 0:U.regular)==null?void 0:A.amount.value)&&(C=(V=(I=t==null?void 0:t.minimum)==null?void 0:I.regular)==null?void 0:V.amount.value);const x=((N=(F=t==null?void 0:t.minimum)==null?void 0:F.final)==null?void 0:N.amount.currency)==="NONE"?"USD":(M=(G=t==null?void 0:t.minimum)==null?void 0:G.final)==null?void 0:M.amount.currency;return[C,D,y,x]}function u(){var k,v,U,A,I,V,F,N,G,M,W,Y;let D=0,y=0;s==null||s.forEach(S=>{var J;const j=S==null?void 0:S.values;if(j&&Array.isArray(j)){const E=j.map(g=>{var $,L,Z,R;return(R=(Z=(L=($=g==null?void 0:g.product)==null?void 0:$.price)==null?void 0:L.regular)==null?void 0:Z.amount)==null?void 0:R.value}).filter(g=>g!==void 0),Q=E.length>0?Math.max(...E):0;D+=Q}(J=S==null?void 0:S.values)==null||J.forEach(E=>{var Q,g,$,L;a!=null&&a.includes(E.id)&&(y+=(L=($=(g=(Q=E==null?void 0:E.product)==null?void 0:Q.price)==null?void 0:g.final)==null?void 0:$.amount)==null?void 0:L.value)})});const C=(k=t==null?void 0:t.minimum)==null?void 0:k.final.amount.value,x=(v=t==null?void 0:t.maximum)==null?void 0:v.final.amount.value;let T;((A=(U=t==null?void 0:t.minimum)==null?void 0:U.regular)==null?void 0:A.amount.value)===((V=(I=t==null?void 0:t.maximum)==null?void 0:I.regular)==null?void 0:V.amount.value)&&(T=(N=(F=t==null?void 0:t.minimum)==null?void 0:F.regular)==null?void 0:N.amount.value);const O=((M=(G=t==null?void 0:t.minimum)==null?void 0:G.final)==null?void 0:M.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?[T,C,x,O]:D===(t==null?void 0:t.maximum.regular.amount.value)?[y,y,y,O]:[T,C,x,O]}const[c,f,d,h]=l==="SimpleProductView"?o():n?u():m(),w=l==="SimpleProductView"?(P=i==null?void 0:i.roles)==null?void 0:P.includes("visible"):((X=(b=t==null?void 0:t.maximum)==null?void 0:b.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:h,variant:c&&f!==c?"strikethrough":"default"},final:{amount:d,currency:h,variant:"default"},visible:w}:{final:{minimumAmount:f,maximumAmount:d,currency:h},visible:w}}function pe(e,n,r){var i;return n?((i=e==null?void 0:e.options)==null?void 0:i.map(({values:s})=>{var o;const a=((o=s==null?void 0:s.find(({isDefault:m})=>m))==null?void 0:o.id)??null,l=r?s[0].id:null;return a||l})).filter(s=>s!==null):e==null?void 0:e.optionUIDs}const H=new ue({init:async e=>{var l,o,m;const n=(o=(l=e==null?void 0:e.models)==null?void 0:l.ProductDetails)==null?void 0:o.initialData,i=((m=(ie()||{}).optionsUIDs)==null?void 0:m.split(","))||(n==null?void 0:n.optionsUIDs),t=me(1),a={...{defaultLocale:"en-US",persistURLParams:!1,acdl:!1,optionsUIDs:i},...e};if(H.config.setConfig({...a}),a!=null&&a.sku){const u=n?K(n):await te(a.sku,{preselectFirstOption:a.preselectFirstOption});p.emit("pdp/data",u);const c={sku:a.sku,quantity:t,optionsUIDs:u==null?void 0:u.optionUIDs};Ae(()=>({...c})),Ve(()=>{var f;return u!=null&&u.options?u.options.length===((f=u==null?void 0:u.optionUIDs)==null?void 0:f.length):!0}),a.acdl&&u&&ye(u)}},listeners:()=>[p.on("locale",async()=>{const{sku:e}=H.config.getConfig();if(e){const n=await te(e);p.emit("pdp/data",n)}})]}),_=H.config,{setEndpoint:Qe,setFetchGraphQlHeader:je,removeFetchGraphQlHeader:qe,setFetchGraphQlHeaders:He,fetchGraphQl:ae,getConfig:Ke}=new le().getMethods(),Te=`
|
|
4
4
|
query GET_PRODUCT_DATA($skus: [String]) {
|
|
5
5
|
products(skus: $skus) {
|
|
6
6
|
...PRODUCT_FRAGMENT
|
|
@@ -8,7 +8,7 @@ query GET_PRODUCT_DATA($skus: [String]) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
${ne}
|
|
11
|
-
`,
|
|
11
|
+
`,Oe=async(e,n,r)=>{var s;const{data:i}=await ae(Te,{method:"GET",variables:{skus:[e]}}),t=(s=i==null?void 0:i.products)==null?void 0:s[0];return n!=null&&n.optionsUIDs&&(t.optionUIDs=n.optionsUIDs),t?r?t:K(t,{preselectFirstOption:n==null?void 0:n.preselectFirstOption}):null},Se=`
|
|
12
12
|
query REFINE_PRODUCT_QUERY(
|
|
13
13
|
$optionIds: [String!]!
|
|
14
14
|
$sku: String!
|
|
@@ -30,10 +30,10 @@ query REFINE_PRODUCT_QUERY(
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
${ne}
|
|
33
|
-
`;async function ee(e,n){const
|
|
34
|
-
ProductOption${
|
|
33
|
+
`;async function ee(e,n){const r=be(n),i=ke(r,e),t=Se.replace("# %extendedPlaceholder%",i),{data:s}=await ae(t,{method:"GET",variables:{optionIds:n,sku:e}});return s}const _e=async(e,n,r,i)=>{var d,h,w;const t=await ee(e,n);if(!t)return null;let{products:s,refineProduct:a,...l}=t;const o=s==null?void 0:s[0],m=ve(Object.values(l),o.options,r);if(r!=null&&r.length&&a===null){n=Ue(m,n,r);const P=await ee(e,n);a=P==null?void 0:P.refineProduct}const u={...a||o,sku:o.sku,name:o.name,externalParentId:o==null?void 0:o.externalId,options:m,optionUIDs:n,variantSku:(a==null?void 0:a.__typename)==="SimpleProductView"?a==null?void 0:a.sku:void 0},c=i?u:K(u),f=(w=(h=(d=_==null?void 0:_.getConfig())==null?void 0:d.models)==null?void 0:h.ProductDetails)==null?void 0:w.fallbackData;return f?f(o,c):c};function be(e){if(e.length<2)return[e];const n=[];return e.forEach(r=>{const i=[];e.forEach(t=>{r!==t&&i.push(t)}),n.push(i)}),n}function ke(e,n){return e.map((r,i)=>`
|
|
34
|
+
ProductOption${i}: refineProduct(
|
|
35
35
|
optionIds: [
|
|
36
|
-
${
|
|
36
|
+
${r.map(t=>`"${t}"`).join(", ")}
|
|
37
37
|
]
|
|
38
38
|
sku: "${n}"
|
|
39
39
|
) {
|
|
@@ -43,4 +43,5 @@ ${ne}
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
`).join("")}function
|
|
46
|
+
`).join("")}function ve(e,n=[],r){const i=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 i.forEach(s=>{r!=null&&r.includes(s.id)||t.set(s.id,s)}),[...t.values()]}function Ue(e,n,r){const i=[];let t;return e.forEach(s=>{var a,l,o,m;r.includes(s.id)?t=((l=(a=s.values)==null?void 0:a.find(u=>n.includes(u==null?void 0:u.id)))==null?void 0:l.id)||((o=s.values[0])==null?void 0:o.id):t=(m=s.values[0])==null?void 0:m.id,i.push(t)}),i}const te=async(e,n)=>{const{anchors:r,optionsUIDs:i}=_.getConfig(),{optionsUIDs:t=i,anchors:s=r,preselectFirstOption:a,isBundle:l,skipTransform:o}=n??{};return!l&&t?await _e(e,t,s,o):await Oe(e,{preselectFirstOption:a,optionsUIDs:t},o)},Ae=e=>{const n=Ie(),r=e(n);p.emit("pdp/values",{...r})},Ie=()=>{var e;return((e=p._lastEvent["pdp/values"])==null?void 0:e.payload)??null},Ve=e=>{const n=Fe(),r=e(n);p.emit("pdp/valid",r)},Fe=()=>{var e;return((e=p._lastEvent["pdp/valid"])==null?void 0:e.payload)??null};export{je as a,He as b,_ as c,Oe as d,_e as e,ae as f,Ke as g,te as h,H as i,Ae as j,Ie as k,Ve as l,Fe as m,me as n,Le as o,ye as p,qe as r,Qe as s,K as t};
|
|
47
|
+
//# sourceMappingURL=isProductConfigurationValid.js.map
|