@dropins/tools 1.6.0-alpha1 → 1.6.0-alpha11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"configs.js","sources":["/@dropins/tools/src/lib/aem/configs.ts"],"sourcesContent":["import { deepmerge } from '../deepmerge';\nimport { getPathValue } from '../get-path-value';\n\ninterface ConfigHeaders {\n all?: Record<string, string>;\n [key: string]: Record<string, string> | undefined;\n}\n\ninterface ConfigPublic {\n default: ConfigRoot;\n [key: string]: ConfigRoot;\n}\n\ninterface ConfigRoot {\n headers?: ConfigHeaders;\n [key: string]: any;\n}\n\ninterface Config {\n public: ConfigPublic;\n [key: string]: any;\n}\n\n// Private state\nlet config: Config | null = null;\nlet rootPath: string | null = null;\nlet rootConfig: ConfigRoot | null = null;\n\n/**\n * Reset the config state\n */\nfunction resetConfig() {\n config = null;\n rootPath = null;\n rootConfig = null;\n}\n\n/**\n * Get root path\n * @param {Object} [configObj=config] - The config object.\n * @returns {string} - The root path.\n */\nfunction getRootPath(configObj: Config | null = config, options?: { match?: (key: string) => boolean }): string {\n if (!configObj) {\n console.warn('No config found. Please call initializeConfig() first.');\n return '/';\n }\n\n const value = Object.keys(configObj?.public)\n // Sort by number of non-empty segments to find the deepest path\n .sort((a, b) => {\n const aSegments = a.split('/').filter(Boolean).length;\n const bSegments = b.split('/').filter(Boolean).length;\n return bSegments - aSegments;\n })\n .find(\n (key) =>\n window.location.pathname === key ||\n (options?.match?.(key) ?? window.location.pathname.startsWith(key))\n );\n\n return value ?? '/';\n}\n\n/**\n * Get list of root paths from public config\n * @returns {Array} - The list of root paths.\n */\nfunction getListOfRootPaths(): string[] {\n if (!config) {\n console.warn('No config found. Please call initializeConfig() first.');\n return [];\n }\n\n return Object.keys(config.public).filter((root) => root !== 'default');\n}\n\n/**\n * Checks if the public config contains more than \"default\"\n * @returns {boolean} - true if public config contains more than \"default\"\n */\nfunction isMultistore(): boolean {\n return getListOfRootPaths().length >= 1;\n}\n\n/**\n * Retrieves headers from config entries like commerce.headers.pdp.my-header, etc and\n * returns as object of all headers like { my-header: value, ... }\n * @param {string} scope - The scope of the headers to retrieve.\n * @returns {Object} - The headers.\n */\nfunction getHeaders(scope: string): Record<string, string> {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n const headers = rootConfig.headers ?? {};\n return {\n ...(headers.all ?? {}),\n ...(headers[scope] ?? {}),\n };\n}\n\n/**\n * Applies config overrides from metadata.\n *\n * @param {Object} [configObj] - The base config.\n * @param {string} [root] - The root path.\n * @returns {Object} - The config with overrides applied.\n */\nfunction applyConfigOverrides(\n configObj: Config | null,\n root: string | null\n): ConfigRoot {\n const defaultConfig = configObj!.public?.default;\n\n if (root === '/' || !configObj!.public[root as keyof ConfigPublic])\n return defaultConfig;\n\n return deepmerge(\n defaultConfig,\n configObj!.public[root as keyof ConfigPublic]\n );\n}\n\n/**\n * Initializes the configuration system.\n * @param {Object} configObj - The config object.\n * @param {Object} [options] - The options object.\n * @param {Function} [options.match] - The function to match the path to the config.\n * @returns {Object} The initialized root configuration\n */\nfunction initializeConfig(configObj: Config, options?: { match?: (key: string) => boolean }): ConfigRoot {\n config = configObj;\n rootPath = getRootPath(config, { match: options?.match });\n rootConfig = applyConfigOverrides(config, rootPath);\n return rootConfig;\n}\n\n/**\n * Retrieves a configuration value.\n *\n * @param {string} configParam - The configuration parameter to retrieve.\n * @returns {string|undefined} - The value of the configuration parameter, or undefined.\n */\nfunction getConfigValue(configParam: string): any {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n return getPathValue(rootConfig, configParam);\n}\n\nexport {\n initializeConfig,\n getRootPath,\n getListOfRootPaths,\n isMultistore,\n getConfigValue,\n getHeaders,\n resetConfig,\n};\n"],"names":["config","rootPath","rootConfig","resetConfig","getRootPath","configObj","options","a","b","aSegments","key","_a","getListOfRootPaths","root","isMultistore","getHeaders","scope","headers","applyConfigOverrides","defaultConfig","deepmerge","initializeConfig","getConfigValue","configParam","getPathValue"],"mappings":"2FAwBA,IAAIA,EAAwB,KACxBC,EAA0B,KAC1BC,EAAgC,KAKpC,SAASC,GAAc,CACZH,EAAA,KACEC,EAAA,KACEC,EAAA,IACf,CAOA,SAASE,EAAYC,EAA2BL,EAAQM,EAAwD,CAC9G,OAAKD,EAKS,OAAO,KAAKA,GAAA,YAAAA,EAAW,MAAM,EAExC,KAAK,CAACE,EAAGC,IAAM,CACd,MAAMC,EAAYF,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,OAE/C,OADkBC,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,OAC5BC,CACpB,CAAA,EACA,KACEC,GAAA,OACC,cAAO,SAAS,WAAaA,MAC5BC,EAAAL,GAAA,YAAAA,EAAS,QAAT,YAAAK,EAAA,KAAAL,EAAiBI,KAAQ,OAAO,SAAS,SAAS,WAAWA,CAAG,GACrE,GAEc,KAjBd,QAAQ,KAAK,wDAAwD,EAC9D,IAiBX,CAMA,SAASE,GAA+B,CACtC,OAAKZ,EAKE,OAAO,KAAKA,EAAO,MAAM,EAAE,OAAQa,GAASA,IAAS,SAAS,GAJnE,QAAQ,KAAK,wDAAwD,EAC9D,CAAC,EAIZ,CAMA,SAASC,GAAwB,CACxB,OAAAF,EAAA,EAAqB,QAAU,CACxC,CAQA,SAASG,EAAWC,EAAuC,CACzD,GAAI,CAACd,EACH,MAAM,IAAI,MACR,+DACF,EAEI,MAAAe,EAAUf,EAAW,SAAW,CAAC,EAChC,MAAA,CACL,GAAIe,EAAQ,KAAO,CAAC,EACpB,GAAIA,EAAQD,CAAK,GAAK,CAAA,CACxB,CACF,CASA,SAASE,EACPb,EACAQ,EACY,OACN,MAAAM,GAAgBR,EAAAN,EAAW,SAAX,YAAAM,EAAmB,QAEzC,OAAIE,IAAS,KAAO,CAACR,EAAW,OAAOQ,CAA0B,EACxDM,EAEFC,EACLD,EACAd,EAAW,OAAOQ,CAA0B,CAC9C,CACF,CASA,SAASQ,EAAiBhB,EAAmBC,EAA4D,CAC9F,OAAAN,EAAAK,EACTJ,EAAWG,EAAYJ,EAAQ,CAAE,MAAOM,GAAA,YAAAA,EAAS,MAAO,EAC3CJ,EAAAgB,EAAqBlB,EAAQC,CAAQ,EAC3CC,CACT,CAQA,SAASoB,EAAeC,EAA0B,CAChD,GAAI,CAACrB,EACH,MAAM,IAAI,MACR,+DACF,EAEK,OAAAsB,EAAatB,EAAYqB,CAAW,CAC7C"}
1
+ {"version":3,"file":"configs.js","sources":["/@dropins/tools/src/lib/aem/configs.ts"],"sourcesContent":["import { deepmerge } from '../deepmerge';\nimport { getPathValue } from '../get-path-value';\n\ninterface ConfigHeaders {\n all?: Record<string, string>;\n [key: string]: Record<string, string> | undefined;\n}\n\ninterface ConfigPublic {\n default: ConfigRoot;\n [key: string]: ConfigRoot;\n}\n\ninterface ConfigRoot {\n headers?: ConfigHeaders;\n [key: string]: any;\n}\n\ninterface Config {\n public: ConfigPublic;\n [key: string]: any;\n}\n\n// Private state\nlet config: Config | null = null;\nlet options: { match?: (key: string) => boolean } | null = null;\nlet rootPath: string | null = null;\nlet rootConfig: ConfigRoot | null = null;\n\n/**\n * Reset the config state\n */\nfunction resetConfig() {\n config = null;\n options = null;\n rootPath = null;\n rootConfig = null;\n}\n\n/**\n * Get root path\n * @param {Object} [configObj=config] - The config object.\n * @returns {string} - The root path.\n */\nfunction getRootPath(configObj: Config | null = config, optionsObj: { match?: (key: string) => boolean } | null = options): string {\n if (!configObj) {\n console.warn('No config found. Please call initializeConfig() first.');\n return '/';\n }\n\n const value = Object.keys(configObj?.public)\n // Sort by number of non-empty segments to find the deepest path\n .sort((a, b) => {\n const aSegments = a.split('/').filter(Boolean).length;\n const bSegments = b.split('/').filter(Boolean).length;\n return bSegments - aSegments;\n })\n .find(\n (key) =>\n window.location.pathname === key ||\n (optionsObj?.match?.(key) ?? window.location.pathname.startsWith(key))\n );\n\n return value ?? '/';\n}\n\n/**\n * Get list of root paths from public config\n * @returns {Array} - The list of root paths.\n */\nfunction getListOfRootPaths(): string[] {\n if (!config) {\n console.warn('No config found. Please call initializeConfig() first.');\n return [];\n }\n\n return Object.keys(config.public).filter((root) => root !== 'default');\n}\n\n/**\n * Checks if the public config contains more than \"default\"\n * @returns {boolean} - true if public config contains more than \"default\"\n */\nfunction isMultistore(): boolean {\n return getListOfRootPaths().length >= 1;\n}\n\n/**\n * Retrieves headers from config entries like commerce.headers.pdp.my-header, etc and\n * returns as object of all headers like { my-header: value, ... }\n * @param {string} scope - The scope of the headers to retrieve.\n * @returns {Object} - The headers.\n */\nfunction getHeaders(scope: string): Record<string, string> {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n const headers = rootConfig.headers ?? {};\n return {\n ...(headers.all ?? {}),\n ...(headers[scope] ?? {}),\n };\n}\n\n/**\n * Applies config overrides from metadata.\n *\n * @param {Object} [configObj] - The base config.\n * @param {string} [root] - The root path.\n * @returns {Object} - The config with overrides applied.\n */\nfunction applyConfigOverrides(\n configObj: Config | null,\n root: string | null\n): ConfigRoot {\n const defaultConfig = configObj!.public?.default;\n\n if (root === '/' || !configObj!.public[root as keyof ConfigPublic])\n return defaultConfig;\n\n return deepmerge(\n defaultConfig,\n configObj!.public[root as keyof ConfigPublic]\n );\n}\n\n/**\n * Initializes the configuration system.\n * @param {Object} configObj - The config object.\n * @param {Object} [options] - The options object.\n * @param {Function} [options.match] - The function to match the path to the config.\n * @returns {Object} The initialized root configuration\n */\nfunction initializeConfig(configObj: Config, optionsObj?: { match?: (key: string) => boolean }): ConfigRoot {\n config = configObj;\n options = optionsObj ?? null;\n rootPath = getRootPath(config, { match: optionsObj?.match });\n rootConfig = applyConfigOverrides(config, rootPath);\n return rootConfig;\n}\n\n/**\n * Retrieves a configuration value.\n *\n * @param {string} configParam - The configuration parameter to retrieve.\n * @returns {string|undefined} - The value of the configuration parameter, or undefined.\n */\nfunction getConfigValue(configParam: string): any {\n if (!rootConfig) {\n throw new Error(\n 'Configuration not initialized. Call initializeConfig() first.'\n );\n }\n return getPathValue(rootConfig, configParam);\n}\n\nexport {\n initializeConfig,\n getRootPath,\n getListOfRootPaths,\n isMultistore,\n getConfigValue,\n getHeaders,\n resetConfig,\n};\n"],"names":["config","options","rootPath","rootConfig","resetConfig","getRootPath","configObj","optionsObj","a","b","aSegments","key","_a","getListOfRootPaths","root","isMultistore","getHeaders","scope","headers","applyConfigOverrides","defaultConfig","deepmerge","initializeConfig","getConfigValue","configParam","getPathValue"],"mappings":"2FAwBA,IAAIA,EAAwB,KACxBC,EAAuD,KACvDC,EAA0B,KAC1BC,EAAgC,KAKpC,SAASC,GAAc,CACZJ,EAAA,KACCC,EAAA,KACCC,EAAA,KACEC,EAAA,IACf,CAOA,SAASE,EAAYC,EAA2BN,EAAQO,EAA0DN,EAAiB,CACjI,OAAKK,EAKS,OAAO,KAAKA,GAAA,YAAAA,EAAW,MAAM,EAExC,KAAK,CAACE,EAAGC,IAAM,CACd,MAAMC,EAAYF,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,OAE/C,OADkBC,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,OAC5BC,CACpB,CAAA,EACA,KACEC,GAAA,OACC,cAAO,SAAS,WAAaA,MAC5BC,EAAAL,GAAA,YAAAA,EAAY,QAAZ,YAAAK,EAAA,KAAAL,EAAoBI,KAAQ,OAAO,SAAS,SAAS,WAAWA,CAAG,GACxE,GAEc,KAjBd,QAAQ,KAAK,wDAAwD,EAC9D,IAiBX,CAMA,SAASE,GAA+B,CACtC,OAAKb,EAKE,OAAO,KAAKA,EAAO,MAAM,EAAE,OAAQc,GAASA,IAAS,SAAS,GAJnE,QAAQ,KAAK,wDAAwD,EAC9D,CAAC,EAIZ,CAMA,SAASC,GAAwB,CACxB,OAAAF,EAAA,EAAqB,QAAU,CACxC,CAQA,SAASG,EAAWC,EAAuC,CACzD,GAAI,CAACd,EACH,MAAM,IAAI,MACR,+DACF,EAEI,MAAAe,EAAUf,EAAW,SAAW,CAAC,EAChC,MAAA,CACL,GAAIe,EAAQ,KAAO,CAAC,EACpB,GAAIA,EAAQD,CAAK,GAAK,CAAA,CACxB,CACF,CASA,SAASE,EACPb,EACAQ,EACY,OACN,MAAAM,GAAgBR,EAAAN,EAAW,SAAX,YAAAM,EAAmB,QAEzC,OAAIE,IAAS,KAAO,CAACR,EAAW,OAAOQ,CAA0B,EACxDM,EAEFC,EACLD,EACAd,EAAW,OAAOQ,CAA0B,CAC9C,CACF,CASA,SAASQ,EAAiBhB,EAAmBC,EAA+D,CACjG,OAAAP,EAAAM,EACTL,EAAUM,GAAc,KACxBL,EAAWG,EAAYL,EAAQ,CAAE,MAAOO,GAAA,YAAAA,EAAY,MAAO,EAC9CJ,EAAAgB,EAAqBnB,EAAQE,CAAQ,EAC3CC,CACT,CAQA,SAASoB,EAAeC,EAA0B,CAChD,GAAI,CAACrB,EACH,MAAM,IAAI,MACR,+DACF,EAEK,OAAAsB,EAAatB,EAAYqB,CAAW,CAC7C"}
package/lib.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{S as M}from"./chunks/vcomponent.js";import{R as te,V as ne,c as se,g as ie}from"./chunks/vcomponent.js";import{d as E}from"./chunks/cjs.js";import{d as ae,a as de,i as ue}from"./chunks/deviceUtils.js";import{C as pe,I as ge,i as fe}from"./chunks/initializer.js";import{IntlContext as F}from"./i18n.js";import{x as R,A as P,h as _,T as L,E as b,q as p,_ as V,y as D,N as q,f as Q}from"./chunks/icons/Add.js";import{g as me,s as he}from"./chunks/image-params-keymap.js";import{g as ye,s as Ie}from"./chunks/locale-config.js";import{g as Ce}from"./chunks/get-path-value.js";import"./preact-jsx-runtime.js";import"./signals.js";const H=r=>{const o=new FormData(r);return Object.fromEntries(o)},X=r=>{const o=new FormData(r),n=Object.fromEntries(o);return Object.entries(n).reduce((s,[a])=>{const c=r.elements[a];return c!=null&&c.validationMessage?{...s,[a]:c.validationMessage}:{...s}},{})},T={arrayMerge:(r,o,n)=>{const l=r.slice();return o.forEach((s,a)=>{typeof l[a]>"u"?l[a]=n.cloneUnlessOtherwiseSpecified(s,n):n.isMergeableObject(s)?l[a]=E(r[a],s,n):r.indexOf(s)===-1&&l.push(s)}),l}};function Y(r,o){return o?E(r,o,T):r}const Z=r=>r.replace("_","-");function z(r,o={},n,l,s,a="div"){const c=R(M),g=P(null),h=P("pending"),S=P([]),[y,N]=_({children:[l]}),[I,B]=_({}),O=L(()=>({get:t=>I[t],set:(t,e)=>{B({...O,[t]:e})}}),[I]),{intl:j}=R(F);o.dictionary=j.dictionary,o._setProps=t=>{N(e=>{const i=typeof t=="function"?t(e):t;if(s){const u=b(s(e),{key:"render"}),m=e.children.findIndex(f=>(f==null?void 0:f.key)==="render");e.children[m]=u}return i})};const d=p(t=>{typeof t=="function"?S.current.push(t):console.warn("Skipped: Invalid _registerMethod",t)},[]);o._registerMethod=d;const w=p(t=>V(a,{"data-slot-html-element":t.tagName.toLowerCase(),ref:e=>{e==null||e.appendChild(t)}},null),[a]);o._htmlElementToVNode=w,o.getSlotElement=p(t=>{var i,u;const e=(i=g.current)==null?void 0:i.querySelector(`[data-slot-key="${t}"]`);if(C(`🟦 "${r}" Slot getSlotElement: ${t}`,(u=g.current)==null?void 0:u.cloneNode(!0),e==null?void 0:e.cloneNode(!0)),!!e)return{appendChild:m=>{e.appendChild(m)},prependChild:m=>{e.insertBefore(m,e.firstChild)},appendSibling:m=>{const f=e.parentNode;f==null||f.insertBefore(m,e.nextSibling)},prependSibling:m=>{const f=e.parentNode;f==null||f.insertBefore(m,e)},remove:()=>{e.remove()}}},[r]),o.onRender=p(t=>{S.current.push(t)},[]),o.onChange=o.onRender,o.replaceWith=p(t=>{d(e=>{const i=w(t);e._setProps({children:[i]})})},[w,d]),o.appendChild=p(t=>{d(e=>{const i=w(t);e._setProps(u=>({...u,children:[...u.children,i]}))})},[w,d]),o.prependChild=p(t=>{d(e=>{const i=w(t);e._setProps(u=>({...u,children:[i,...u.children]}))})},[w,d]),o.appendSibling=p(t=>{d(()=>{var i,u;const e=(i=g.current)==null?void 0:i.parentNode;e==null||e.insertBefore(t,((u=g.current)==null?void 0:u.nextSibling)??null)})},[d]),o.prependSibling=p(t=>{d(()=>{var i;const e=(i=g.current)==null?void 0:i.parentNode;e==null||e.insertBefore(t,g.current)})},[d]),o.remove=p(()=>{d(()=>{var t;(t=g.current)==null||t.remove()})},[d]);const v=p(async()=>{if(h.current==="loading")return;h.current="loading",C(`🟨 "${r}" Slot Rendered`);const t=s?b(s(y),{key:"render"}):null;N({children:[t??l]}),S.current.forEach(e=>{e(o,O)}),h.current="ready"},[l,o,r,y,s,O]),k=p(async()=>{if(n)try{h.current="loading",C(`🟩 "${r}" Slot Initialized`),await n(o,g.current)}catch(t){console.error(`Error in "${n.name}" Slot callback`,t)}finally{h.current="ready",await v()}},[n,o,v,r]);return D(()=>{k().finally(()=>{c&&c.value.has(r)&&(c.value.delete(r),c.value=new Set(c.value))})},[]),D(()=>{v()},[JSON.stringify(o),JSON.stringify(I)]),[g,y,h.current]}const $=(r,o)=>q.map(r,n=>Q(n)?n.props.src?b(n,{...n.props,src:o?n.props.src:"","data-original-src":n.props.src}):n.props&&n.props.children?b(n,{...n.props,children:$(n.props.children,o)}):n:n);function x({name:r,lazy:o=!1,context:n,slot:l,children:s,render:a,slotTag:c="div",contentTag:g="div",...h}){const S=R(M),[y,N,I]=z(r,n,l,s,a,g);return L(()=>{if(!r)return console.warn('Slot "name" is required');S&&o===!1&&(S.value.add(r),S.value=new Set(S.value))},[r,o,S]),V(c,{...h,ref:y,"data-slot":r},$(N.children,I==="ready"))}window.DROPINS=window.DROPINS||{};window.DROPINS.showSlots=async r=>{window.sessionStorage.setItem("dropin-debugger--show-slots",r.toString()),document.body.classList.toggle("dropin-debugger--show-slots",r)};let C=()=>{};window.DROPINS.logSlots=async r=>{window.sessionStorage.setItem("dropin-debugger--log-slots",r.toString()),C=r?(...o)=>console.log(...o):()=>{}};window.DROPINS.showSlots(window.sessionStorage.getItem("dropin-debugger--show-slots")==="true");window.DROPINS.logSlots(window.sessionStorage.getItem("dropin-debugger--log-slots")==="true");function ee(r){const o=document.cookie.split(";");let n;return o.forEach(l=>{const[s,a]=l.trim().split("=");s===r&&(n=decodeURIComponent(a))}),n}export{pe as Config,ge as Initializer,te as Render,x as Slot,M as SlotQueueContext,ne as VComponent,se as classes,ae as debounce,E as deepmerge,ie as generateSrcset,ee as getCookie,X as getFormErrors,H as getFormValues,ye as getGlobalLocale,me as getImageParamsKeyMap,Ce as getPathValue,fe as initializers,de as isIOSMobileDevice,ue as isNumber,Y as merge,Ie as setGlobalLocale,he as setImageParamsKeyMap,Z as toLanguageTag,z as useSlot};
3
+ import{S as M}from"./chunks/vcomponent.js";import{R as te,V as ne,c as se,g as ie}from"./chunks/vcomponent.js";import{d as E}from"./chunks/cjs.js";import{d as ae,g as de,b as ue,a as ce,i as pe}from"./chunks/get-price-formatter.js";import{C as fe,I as Se,i as me}from"./chunks/initializer.js";import{IntlContext as k}from"./i18n.js";import{x as R,A as P,h as _,T as L,E as C,q as p,_ as V,y as D,N as q,f as Q}from"./chunks/icons/Add.js";import{g as we,s as ye}from"./chunks/image-params-keymap.js";import{g as Ne,s as be}from"./chunks/locale-config.js";import{g as ve}from"./chunks/get-path-value.js";import"./preact-jsx-runtime.js";import"./signals.js";const H=r=>{const o=new FormData(r);return Object.fromEntries(o)},X=r=>{const o=new FormData(r),n=Object.fromEntries(o);return Object.entries(n).reduce((s,[a])=>{const c=r.elements[a];return c!=null&&c.validationMessage?{...s,[a]:c.validationMessage}:{...s}},{})},T={arrayMerge:(r,o,n)=>{const l=r.slice();return o.forEach((s,a)=>{typeof l[a]>"u"?l[a]=n.cloneUnlessOtherwiseSpecified(s,n):n.isMergeableObject(s)?l[a]=E(r[a],s,n):r.indexOf(s)===-1&&l.push(s)}),l}};function Y(r,o){return o?E(r,o,T):r}const Z=r=>r.replace("_","-");function z(r,o={},n,l,s,a="div"){const c=R(M),g=P(null),h=P("pending"),S=P([]),[y,N]=_({children:[l]}),[I,B]=_({}),v=L(()=>({get:t=>I[t],set:(t,e)=>{B({...v,[t]:e})}}),[I]),{intl:F}=R(k);o.dictionary=F.dictionary,o._setProps=t=>{N(e=>{const i=typeof t=="function"?t(e):t;if(s){const u=C(s(e),{key:"render"}),m=e.children.findIndex(f=>(f==null?void 0:f.key)==="render");e.children[m]=u}return i})};const d=p(t=>{typeof t=="function"?S.current.push(t):console.warn("Skipped: Invalid _registerMethod",t)},[]);o._registerMethod=d;const w=p(t=>V(a,{"data-slot-html-element":t.tagName.toLowerCase(),ref:e=>{e==null||e.appendChild(t)}},null),[a]);o._htmlElementToVNode=w,o.getSlotElement=p(t=>{var i,u;const e=(i=g.current)==null?void 0:i.querySelector(`[data-slot-key="${t}"]`);if(b(`🟦 "${r}" Slot getSlotElement: ${t}`,(u=g.current)==null?void 0:u.cloneNode(!0),e==null?void 0:e.cloneNode(!0)),!!e)return{appendChild:m=>{e.appendChild(m)},prependChild:m=>{e.insertBefore(m,e.firstChild)},appendSibling:m=>{const f=e.parentNode;f==null||f.insertBefore(m,e.nextSibling)},prependSibling:m=>{const f=e.parentNode;f==null||f.insertBefore(m,e)},remove:()=>{e.remove()}}},[r]),o.onRender=p(t=>{S.current.push(t)},[]),o.onChange=o.onRender,o.replaceWith=p(t=>{d(e=>{const i=w(t);e._setProps({children:[i]})})},[w,d]),o.appendChild=p(t=>{d(e=>{const i=w(t);e._setProps(u=>({...u,children:[...u.children,i]}))})},[w,d]),o.prependChild=p(t=>{d(e=>{const i=w(t);e._setProps(u=>({...u,children:[i,...u.children]}))})},[w,d]),o.appendSibling=p(t=>{d(()=>{var i,u;const e=(i=g.current)==null?void 0:i.parentNode;e==null||e.insertBefore(t,((u=g.current)==null?void 0:u.nextSibling)??null)})},[d]),o.prependSibling=p(t=>{d(()=>{var i;const e=(i=g.current)==null?void 0:i.parentNode;e==null||e.insertBefore(t,g.current)})},[d]),o.remove=p(()=>{d(()=>{var t;(t=g.current)==null||t.remove()})},[d]);const O=p(async()=>{if(h.current==="loading")return;h.current="loading",b(`🟨 "${r}" Slot Rendered`);const t=s?C(s(y),{key:"render"}):null;N({children:[t??l]}),S.current.forEach(e=>{e(o,v)}),h.current="ready"},[l,o,r,y,s,v]),j=p(async()=>{if(n)try{h.current="loading",b(`🟩 "${r}" Slot Initialized`),await n(o,g.current)}catch(t){console.error(`Error in "${n.name}" Slot callback`,t)}finally{h.current="ready",await O()}},[n,o,O,r]);return D(()=>{j().finally(()=>{c&&c.value.has(r)&&(c.value.delete(r),c.value=new Set(c.value))})},[]),D(()=>{O()},[JSON.stringify(o),JSON.stringify(I)]),[g,y,h.current]}const $=(r,o)=>q.map(r,n=>Q(n)?n.props.src?C(n,{...n.props,src:o?n.props.src:"","data-original-src":n.props.src}):n.props&&n.props.children?C(n,{...n.props,children:$(n.props.children,o)}):n:n);function x({name:r,lazy:o=!1,context:n,slot:l,children:s,render:a,slotTag:c="div",contentTag:g="div",...h}){const S=R(M),[y,N,I]=z(r,n,l,s,a,g);return L(()=>{if(!r)return console.warn('Slot "name" is required');S&&o===!1&&(S.value.add(r),S.value=new Set(S.value))},[r,o,S]),V(c,{...h,ref:y,"data-slot":r},$(N.children,I==="ready"))}window.DROPINS=window.DROPINS||{};window.DROPINS.showSlots=async r=>{window.sessionStorage.setItem("dropin-debugger--show-slots",r.toString()),document.body.classList.toggle("dropin-debugger--show-slots",r)};let b=()=>{};window.DROPINS.logSlots=async r=>{window.sessionStorage.setItem("dropin-debugger--log-slots",r.toString()),b=r?(...o)=>console.log(...o):()=>{}};window.DROPINS.showSlots(window.sessionStorage.getItem("dropin-debugger--show-slots")==="true");window.DROPINS.logSlots(window.sessionStorage.getItem("dropin-debugger--log-slots")==="true");function ee(r){const o=document.cookie.split(";");let n;return o.forEach(l=>{const[s,a]=l.trim().split("=");s===r&&(n=decodeURIComponent(a))}),n}export{fe as Config,Se as Initializer,te as Render,x as Slot,M as SlotQueueContext,ne as VComponent,se as classes,ae as debounce,E as deepmerge,ie as generateSrcset,ee as getCookie,de as getEffectiveLocale,X as getFormErrors,H as getFormValues,Ne as getGlobalLocale,we as getImageParamsKeyMap,ve as getPathValue,ue as getPriceFormatter,me as initializers,ce as isIOSMobileDevice,pe as isNumber,Y as merge,be as setGlobalLocale,ye as setImageParamsKeyMap,Z as toLanguageTag,z as useSlot};
4
4
  //# sourceMappingURL=lib.js.map
package/lib.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sources":["/@dropins/tools/src/lib/form-values.ts","/@dropins/tools/src/lib/deepmerge.ts","/@dropins/tools/src/lib/i18n.ts","/@dropins/tools/src/lib/slot.tsx","/@dropins/tools/src/lib/get-cookie.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const getFormValues = (form: HTMLFormElement) => {\n const formData: any = new FormData(form);\n const result = Object.fromEntries(formData);\n return result;\n};\n\nexport const getFormErrors = (form: HTMLFormElement) => {\n const formData: any = new FormData(form);\n\n const data = Object.fromEntries(formData);\n\n const result = Object.entries(data).reduce((result, [key]) => {\n // @ts-ignore\n const field = form.elements[key];\n\n return field?.validationMessage\n ? { ...result, [key]: field.validationMessage }\n : { ...result };\n }, {});\n\n return result;\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport deepmerge from 'deepmerge';\n\nexport { default as deepmerge } from 'deepmerge';\n\nconst mergeOptions = {\n arrayMerge: (target: any, source: any, options: any) => {\n const destination = target.slice();\n\n source.forEach((item: any, index: number) => {\n if (typeof destination[index] === 'undefined') {\n destination[index] = options.cloneUnlessOtherwiseSpecified(\n item,\n options\n );\n } else if (options.isMergeableObject(item)) {\n destination[index] = deepmerge(target[index], item, options);\n } else if (target.indexOf(item) === -1) {\n destination.push(item);\n }\n });\n return destination;\n },\n};\n\nexport function merge<T>(\n prev: T,\n next?: { [key: string]: any }\n) {\n if (!next) return prev;\n\n return deepmerge<T, { [key: string]: any }>(\n prev,\n next,\n mergeOptions\n );\n}\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\n/**\n * Convert locale from Magento standard to react-intl BCP 47 language tag\n *\n * @param {string} locale - A locale (e.g. `fr_FR`).\n * @returns {string} A BCP 47 language tag (e.g. `fr-FR`).\n */\nexport const toLanguageTag = (locale: string) => {\n return locale.replace('_', '-');\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { IntlContext, Lang } from '@adobe-commerce/elsie/i18n';\nimport {\n cloneElement,\n ComponentChildren,\n createElement,\n RefObject,\n VNode,\n} from 'preact';\nimport { Children, HTMLAttributes, isValidElement } from 'preact/compat';\nimport {\n StateUpdater,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\nimport { SlotQueueContext } from './render';\n\nimport '@adobe-commerce/elsie/components/UIProvider/debugger.css';\n\ntype MutateElement = (elem: HTMLElement) => void;\n\ninterface State {\n get: (key: string) => void;\n set: (key: string, value: any) => void;\n}\n\ninterface SlotElement {\n appendChild: MutateElement;\n prependChild: MutateElement;\n appendSibling: MutateElement;\n prependSibling: MutateElement;\n remove: () => void;\n}\n\ninterface PrivateContext<T> {\n _setProps: (s: StateUpdater<{}>) => void;\n _registerMethod: (\n cb: (next: T & DefaultSlotContext<T>, state: State) => void\n ) => void;\n // eslint-disable-next-line no-undef\n _htmlElementToVNode: (element: HTMLElement, tag: keyof HTMLElementTagNameMap) => VNode;\n}\n\ninterface DefaultSlotContext<T> extends PrivateContext<T> {\n dictionary: Lang;\n getSlotElement: (key: string) => SlotElement;\n replaceWith: MutateElement;\n appendChild: MutateElement;\n prependChild: MutateElement;\n appendSibling: MutateElement;\n prependSibling: MutateElement;\n remove: () => void;\n onRender: (cb: (next: T & DefaultSlotContext<T>) => void) => void;\n onChange: (cb: (next: T & DefaultSlotContext<T>) => void) => void;\n}\n\ntype Context<T> = T & ThisType<DefaultSlotContext<T>>; // NOSONAR\n\nexport type SlotProps<T = any> = (\n ctx: T & DefaultSlotContext<T>,\n element: HTMLDivElement | null\n) => Promise<void> | void;\n\nexport type SlotMethod<P = any> = (\n callback: (next: unknown, state: State) => P\n) => void;\n\n// Slot Hook\nexport function useSlot<K, V extends HTMLElement>(\n name: string,\n // @ts-ignore\n context: Context<K> = {},\n callback?: SlotProps<K>,\n children?: ComponentChildren,\n render?: Function,\n // eslint-disable-next-line no-undef\n contentTag: keyof HTMLElementTagNameMap = 'div'\n): [RefObject<V>, Record<string, any>, 'loading' | 'pending' | 'ready'] {\n const slotsQueue = useContext(SlotQueueContext);\n\n // HTML Element\n const elementRef = useRef<V>(null);\n\n const status = useRef<'pending' | 'ready' | 'loading'>('pending');\n\n // Methods\n const methodsRef = useRef<any>([]);\n\n // Children VNodes\n const [props, _setProps] = useState<Record<string, any>>({\n children: [children],\n });\n\n // Attributes\n const [_state, setState] = useState<any>({});\n\n const state = useMemo(\n () => ({\n get: (key: string) => _state[key],\n set: (key: string, value: any) => {\n setState({ ...state, [key]: value });\n },\n }),\n [_state]\n );\n\n /** Internationalization */\n // @ts-ignore\n const { intl }: any = useContext(IntlContext);\n\n // @ts-ignore\n context.dictionary = intl.dictionary;\n\n /** Privates */\n // @ts-ignore\n context._setProps = (next: State<any>) => {\n _setProps((prev) => {\n // next props\n const _next = typeof next === 'function' ? next(prev) : next;\n\n // On render method...\n if (render) {\n const renderNode = cloneElement(render(prev), { key: 'render' });\n\n // find index of existing render node\n const index = prev.children.findIndex((n: any) => n?.key === 'render');\n\n // replace existing render node\n prev.children[index] = renderNode;\n }\n\n return _next;\n });\n };\n\n const _registerMethod = useCallback((cb: Function) => {\n if (typeof cb === 'function') {\n methodsRef.current.push(cb);\n } else {\n console.warn('Skipped: Invalid _registerMethod', cb);\n }\n }, []);\n\n // @ts-ignore\n context._registerMethod = _registerMethod;\n\n const _htmlElementToVNode = useCallback(\n (elem: HTMLElement) => {\n return createElement(\n contentTag,\n {\n 'data-slot-html-element': elem.tagName.toLowerCase(),\n ref: (refElem: HTMLElement | null): void => {\n refElem?.appendChild(elem);\n },\n },\n null\n );\n },\n [contentTag]\n );\n\n // @ts-ignore\n context._htmlElementToVNode = _htmlElementToVNode;\n\n /** Prebuilt Methods */\n // @ts-ignore\n context.getSlotElement = useCallback(\n (key: string) => {\n const element = elementRef.current?.querySelector(\n `[data-slot-key=\"${key}\"]`\n );\n\n log(\n `🟦 \"${name}\" Slot getSlotElement: ${key}`,\n elementRef.current?.cloneNode(true),\n element?.cloneNode(true)\n );\n\n if (!element) return;\n\n return {\n appendChild: (elem: HTMLElement) => {\n element.appendChild(elem);\n },\n\n prependChild: (elem: HTMLElement) => {\n element.insertBefore(elem, element.firstChild);\n },\n\n appendSibling: (elem: HTMLElement) => {\n const parent = element.parentNode;\n parent?.insertBefore(elem, element.nextSibling);\n },\n\n prependSibling: (elem: HTMLElement) => {\n const parent = element.parentNode;\n parent?.insertBefore(elem, element);\n },\n\n remove: () => {\n element.remove();\n },\n };\n },\n [name]\n );\n\n // @ts-ignore\n context.onRender = useCallback((cb: Function) => {\n methodsRef.current.push(cb);\n }, []);\n\n /**\n * @deprecated Use `onRender` instead.\n */\n // @ts-ignore\n context.onChange = context.onRender;\n\n // @ts-ignore\n context.replaceWith = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod((next) => {\n // @ts-ignore\n const children = _htmlElementToVNode(elem);\n\n next._setProps({ children: [children] });\n });\n },\n [_htmlElementToVNode, _registerMethod]\n );\n\n // @ts-ignore\n context.appendChild = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod((next) => {\n // @ts-ignore\n const vnode = _htmlElementToVNode(elem);\n\n next._setProps((prev: any) => {\n return {\n ...prev,\n children: [...prev.children, vnode],\n };\n });\n });\n },\n [_htmlElementToVNode, _registerMethod]\n );\n\n // @ts-ignore\n context.prependChild = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod((next) => {\n // @ts-ignore\n const vnode = _htmlElementToVNode(elem);\n\n next._setProps((prev: any) => {\n return {\n ...prev,\n children: [vnode, ...prev.children],\n };\n });\n });\n },\n [_htmlElementToVNode, _registerMethod]\n );\n\n // @ts-ignore\n context.appendSibling = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod(() => {\n const parent = elementRef.current?.parentNode;\n\n parent?.insertBefore(elem, elementRef.current?.nextSibling ?? null);\n });\n },\n [_registerMethod]\n );\n\n // @ts-ignore\n context.prependSibling = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod(() => {\n const parent = elementRef.current?.parentNode;\n\n parent?.insertBefore(elem, elementRef.current);\n });\n },\n [_registerMethod]\n );\n\n // @ts-ignore\n context.remove = useCallback(() => {\n // @ts-ignore\n _registerMethod(() => {\n elementRef.current?.remove();\n });\n }, [_registerMethod]);\n\n const handleLifeCycleRender = useCallback(async () => {\n if (status.current === 'loading') return;\n\n status.current = 'loading';\n\n log(`🟨 \"${name}\" Slot Rendered`);\n\n // Reset\n const renderNode = render\n ? cloneElement(render(props), { key: 'render' })\n : null;\n _setProps({ children: [renderNode ?? children] });\n\n // Run all registered methods\n methodsRef.current.forEach((method: any) => {\n method(context, state);\n });\n\n status.current = 'ready';\n }, [children, context, name, props, render, state]);\n\n // Initialization\n const handleLifeCycleInit = useCallback(async () => {\n if (!callback) return;\n\n try {\n status.current = 'loading';\n\n log(`🟩 \"${name}\" Slot Initialized`);\n await callback(\n context as K & DefaultSlotContext<K>,\n elementRef.current as HTMLDivElement | null\n );\n } catch (error) {\n console.error(`Error in \"${callback.name}\" Slot callback`, error);\n } finally {\n status.current = 'ready';\n\n // first render\n await handleLifeCycleRender();\n }\n }, [callback, context, handleLifeCycleRender, name]);\n\n // Initialization\n useEffect(() => {\n handleLifeCycleInit().finally(() => {\n if (slotsQueue && slotsQueue.value.has(name)) {\n slotsQueue.value.delete(name);\n slotsQueue.value = new Set(slotsQueue.value);\n }\n });\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Update\n useEffect(() => {\n handleLifeCycleRender();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(context), JSON.stringify(_state)]);\n\n return [elementRef, props, status.current];\n}\n\n/**\n * Recursively processes children elements to conditionally prevent image loading.\n * \n * This function traverses the children tree and modifies img elements to prevent\n * premature loading during slot initialization. When isReady is false, img src\n * attributes are set to empty string to prevent network requests, while preserving\n * the original src in a data attribute for debugging purposes.\n * \n * @param children - The children elements to process (can be any React/Preact children)\n * @param isReady - Whether the slot is ready to load images (true) or should prevent loading (false)\n * @returns Processed children with conditional image src attributes\n */\nconst processChildren = (children: any, isReady: boolean): any => {\n return Children.map(children, child => {\n // Handle text nodes, numbers, etc.\n if (!isValidElement(child)) {\n return child;\n }\n\n // Handle img elements - conditionally set src\n if (child.props.src) {\n return cloneElement(child, {\n ...child.props,\n src: isReady ? child.props.src : \"\",\n // Optionally preserve original src in data attribute for debugging\n 'data-original-src': child.props.src,\n });\n }\n\n // Handle elements with children - recursively process them\n if (child.props && child.props.children) {\n return cloneElement(child, {\n ...child.props,\n children: processChildren(child.props.children, isReady),\n });\n }\n\n // Return other elements as-is\n return child;\n });\n};\n\n// Slot Component\ninterface SlotPropsComponent<T>\n extends Omit<HTMLAttributes<HTMLElement>, 'slot'> {\n name: string;\n lazy?: boolean;\n slot?: SlotProps<T>;\n context?: Context<T>;\n render?: (props: Record<string, any>) => VNode | VNode[];\n // eslint-disable-next-line no-undef\n slotTag?: keyof HTMLElementTagNameMap; // The tag for the slot wrapper itself\n // eslint-disable-next-line no-undef\n contentTag?: keyof HTMLElementTagNameMap; // The tag for dynamically inserted content\n children?: ComponentChildren;\n}\n\nexport function Slot<T>({\n name,\n lazy = false,\n context,\n slot,\n children,\n render,\n slotTag = 'div',\n contentTag = 'div',\n ...props\n}: Readonly<SlotPropsComponent<T>>): VNode<{\n ref: RefObject<HTMLElement>;\n 'data-slot': string;\n [key: string]: any;\n}> {\n const slotsQueue = useContext(SlotQueueContext);\n\n const [elementRef, slotProps, status] = useSlot<T, HTMLElement>(\n name,\n context,\n slot,\n children,\n render,\n contentTag\n );\n\n useMemo(() => {\n if (!name) {\n return console.warn('Slot \"name\" is required');\n }\n\n // add slot to queue\n if (slotsQueue && lazy === false) {\n slotsQueue.value.add(name);\n slotsQueue.value = new Set(slotsQueue.value);\n }\n }, [name, lazy, slotsQueue]);\n\n return createElement(\n slotTag,\n {\n ...props,\n ref: elementRef,\n 'data-slot': name,\n },\n processChildren(slotProps.children, status === 'ready')\n );\n}\n\n// Debugger\n\n// @ts-ignore\nwindow.DROPINS = window.DROPINS || {};\n\n// @ts-ignore\nwindow.DROPINS.showSlots = async (state) => {\n // cache state in session storage\n window.sessionStorage.setItem(\n 'dropin-debugger--show-slots',\n state.toString()\n );\n\n document.body.classList.toggle('dropin-debugger--show-slots', state);\n};\n\nlet log: (...attrs: any) => void = () => {};\n\n// @ts-ignore\nwindow.DROPINS.logSlots = async (state) => {\n // cache state in session storage\n window.sessionStorage.setItem('dropin-debugger--log-slots', state.toString());\n\n log = state ? (...attrs) => console.log(...attrs) : () => {};\n};\n\n/** Persistent Settings */\n\n// @ts-ignore\nwindow.DROPINS.showSlots(\n window.sessionStorage.getItem('dropin-debugger--show-slots') === 'true'\n);\n\n// @ts-ignore\nwindow.DROPINS.logSlots(\n window.sessionStorage.getItem('dropin-debugger--log-slots') === 'true'\n);\n","/**\n * Get cookie\n * @param {string} cookieName - The name of the cookie to get\n * @returns {string} - The value of the cookie\n */\nexport function getCookie(cookieName: string): string | undefined {\n const cookies = document.cookie.split(';');\n let foundValue;\n\n cookies.forEach((cookie) => {\n const [name, value] = cookie.trim().split('=');\n if (name === cookieName) {\n foundValue = decodeURIComponent(value);\n }\n });\n\n return foundValue;\n}\n"],"names":["getFormValues","form","formData","getFormErrors","data","result","key","field","mergeOptions","target","source","options","destination","item","index","deepmerge","merge","prev","next","toLanguageTag","locale","useSlot","name","context","callback","children","render","contentTag","slotsQueue","useContext","SlotQueueContext","elementRef","useRef","status","methodsRef","props","_setProps","useState","_state","setState","state","useMemo","value","intl","IntlContext","_next","renderNode","cloneElement","n","_registerMethod","useCallback","cb","_htmlElementToVNode","elem","createElement","refElem","element","_a","log","_b","parent","vnode","handleLifeCycleRender","method","handleLifeCycleInit","error","useEffect","processChildren","isReady","Children","child","isValidElement","Slot","lazy","slot","slotTag","slotProps","attrs","getCookie","cookieName","cookies","foundValue","cookie"],"mappings":"unBASa,MAAAA,EAAiBC,GAA0B,CAChD,MAAAC,EAAgB,IAAI,SAASD,CAAI,EAEhC,OADQ,OAAO,YAAYC,CAAQ,CAE5C,EAEaC,EAAiBF,GAA0B,CAChD,MAAAC,EAAgB,IAAI,SAASD,CAAI,EAEjCG,EAAO,OAAO,YAAYF,CAAQ,EAWjC,OATQ,OAAO,QAAQE,CAAI,EAAE,OAAO,CAACC,EAAQ,CAACC,CAAG,IAAM,CAEtD,MAAAC,EAAQN,EAAK,SAASK,CAAG,EAE/B,OAAOC,GAAA,MAAAA,EAAO,kBACV,CAAE,GAAGF,EAAQ,CAACC,CAAG,EAAGC,EAAM,iBAAA,EAC1B,CAAE,GAAGF,CAAO,CAClB,EAAG,EAAE,CAGP,ECjBMG,EAAe,CACnB,WAAY,CAACC,EAAaC,EAAaC,IAAiB,CAChD,MAA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M,SAAS,CACjB,EAEA,SAAS,KAAK,UAAU,OAAO,8BAA+BA,CAAK,CACrE,EAEA,IAAIkB,EAA+B,IAAM,CAAC,EAG1C,OAAO,QAAQ,SAAW,MAAOlB,GAAU,CAEzC,OAAO,eAAe,QAAQ,6BAA8BA,EAAM,UAAU,EAEtEkB,EAAAlB,EAAQ,IAAIqC,IAAU,QAAQ,IAAI,GAAGA,CAAK,EAAI,IAAM,CAAC,CAC7D,EAKA,OAAO,QAAQ,UACb,OAAO,eAAe,QAAQ,6BAA6B,IAAM,MACnE,EAGA,OAAO,QAAQ,SACb,OAAO,eAAe,QAAQ,4BAA4B,IAAM,MAClE,ECvgBO,SAASC,GAAUC,EAAwC,CAChE,MAAMC,EAAU,SAAS,OAAO,MAAM,GAAG,EACrC,IAAAC,EAEI,OAAAD,EAAA,QAASE,GAAW,CACpB,KAAA,CAAC5D,EAAMoB,CAAK,EAAIwC,EAAO,KAAK,EAAE,MAAM,GAAG,EACzC5D,IAASyD,IACXE,EAAa,mBAAmBvC,CAAK,EACvC,CACD,EAEMuC,CACT"}
1
+ {"version":3,"file":"lib.js","sources":["/@dropins/tools/src/lib/form-values.ts","/@dropins/tools/src/lib/deepmerge.ts","/@dropins/tools/src/lib/i18n.ts","/@dropins/tools/src/lib/slot.tsx","/@dropins/tools/src/lib/get-cookie.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const getFormValues = (form: HTMLFormElement) => {\n const formData: any = new FormData(form);\n const result = Object.fromEntries(formData);\n return result;\n};\n\nexport const getFormErrors = (form: HTMLFormElement) => {\n const formData: any = new FormData(form);\n\n const data = Object.fromEntries(formData);\n\n const result = Object.entries(data).reduce((result, [key]) => {\n // @ts-ignore\n const field = form.elements[key];\n\n return field?.validationMessage\n ? { ...result, [key]: field.validationMessage }\n : { ...result };\n }, {});\n\n return result;\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport deepmerge from 'deepmerge';\n\nexport { default as deepmerge } from 'deepmerge';\n\nconst mergeOptions = {\n arrayMerge: (target: any, source: any, options: any) => {\n const destination = target.slice();\n\n source.forEach((item: any, index: number) => {\n if (typeof destination[index] === 'undefined') {\n destination[index] = options.cloneUnlessOtherwiseSpecified(\n item,\n options\n );\n } else if (options.isMergeableObject(item)) {\n destination[index] = deepmerge(target[index], item, options);\n } else if (target.indexOf(item) === -1) {\n destination.push(item);\n }\n });\n return destination;\n },\n};\n\nexport function merge<T>(\n prev: T,\n next?: { [key: string]: any }\n) {\n if (!next) return prev;\n\n return deepmerge<T, { [key: string]: any }>(\n prev,\n next,\n mergeOptions\n );\n}\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\n/**\n * Convert locale from Magento standard to react-intl BCP 47 language tag\n *\n * @param {string} locale - A locale (e.g. `fr_FR`).\n * @returns {string} A BCP 47 language tag (e.g. `fr-FR`).\n */\nexport const toLanguageTag = (locale: string) => {\n return locale.replace('_', '-');\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { IntlContext, Lang } from '@adobe-commerce/elsie/i18n';\nimport {\n cloneElement,\n ComponentChildren,\n createElement,\n RefObject,\n VNode,\n} from 'preact';\nimport { Children, HTMLAttributes, isValidElement } from 'preact/compat';\nimport {\n StateUpdater,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\nimport { SlotQueueContext } from './render';\n\nimport '@adobe-commerce/elsie/components/UIProvider/debugger.css';\n\ntype MutateElement = (elem: HTMLElement) => void;\n\ninterface State {\n get: (key: string) => void;\n set: (key: string, value: any) => void;\n}\n\ninterface SlotElement {\n appendChild: MutateElement;\n prependChild: MutateElement;\n appendSibling: MutateElement;\n prependSibling: MutateElement;\n remove: () => void;\n}\n\ninterface PrivateContext<T> {\n _setProps: (s: StateUpdater<{}>) => void;\n _registerMethod: (\n cb: (next: T & DefaultSlotContext<T>, state: State) => void\n ) => void;\n // eslint-disable-next-line no-undef\n _htmlElementToVNode: (element: HTMLElement, tag: keyof HTMLElementTagNameMap) => VNode;\n}\n\ninterface DefaultSlotContext<T> extends PrivateContext<T> {\n dictionary: Lang;\n getSlotElement: (key: string) => SlotElement;\n replaceWith: MutateElement;\n appendChild: MutateElement;\n prependChild: MutateElement;\n appendSibling: MutateElement;\n prependSibling: MutateElement;\n remove: () => void;\n onRender: (cb: (next: T & DefaultSlotContext<T>) => void) => void;\n onChange: (cb: (next: T & DefaultSlotContext<T>) => void) => void;\n}\n\ntype Context<T> = T & ThisType<DefaultSlotContext<T>>; // NOSONAR\n\nexport type SlotProps<T = any> = (\n ctx: T & DefaultSlotContext<T>,\n element: HTMLDivElement | null\n) => Promise<void> | void;\n\nexport type SlotMethod<P = any> = (\n callback: (next: unknown, state: State) => P\n) => void;\n\n// Slot Hook\nexport function useSlot<K, V extends HTMLElement>(\n name: string,\n // @ts-ignore\n context: Context<K> = {},\n callback?: SlotProps<K>,\n children?: ComponentChildren,\n render?: Function,\n // eslint-disable-next-line no-undef\n contentTag: keyof HTMLElementTagNameMap = 'div'\n): [RefObject<V>, Record<string, any>, 'loading' | 'pending' | 'ready'] {\n const slotsQueue = useContext(SlotQueueContext);\n\n // HTML Element\n const elementRef = useRef<V>(null);\n\n const status = useRef<'pending' | 'ready' | 'loading'>('pending');\n\n // Methods\n const methodsRef = useRef<any>([]);\n\n // Children VNodes\n const [props, _setProps] = useState<Record<string, any>>({\n children: [children],\n });\n\n // Attributes\n const [_state, setState] = useState<any>({});\n\n const state = useMemo(\n () => ({\n get: (key: string) => _state[key],\n set: (key: string, value: any) => {\n setState({ ...state, [key]: value });\n },\n }),\n [_state]\n );\n\n /** Internationalization */\n // @ts-ignore\n const { intl }: any = useContext(IntlContext);\n\n // @ts-ignore\n context.dictionary = intl.dictionary;\n\n /** Privates */\n // @ts-ignore\n context._setProps = (next: State<any>) => {\n _setProps((prev) => {\n // next props\n const _next = typeof next === 'function' ? next(prev) : next;\n\n // On render method...\n if (render) {\n const renderNode = cloneElement(render(prev), { key: 'render' });\n\n // find index of existing render node\n const index = prev.children.findIndex((n: any) => n?.key === 'render');\n\n // replace existing render node\n prev.children[index] = renderNode;\n }\n\n return _next;\n });\n };\n\n const _registerMethod = useCallback((cb: Function) => {\n if (typeof cb === 'function') {\n methodsRef.current.push(cb);\n } else {\n console.warn('Skipped: Invalid _registerMethod', cb);\n }\n }, []);\n\n // @ts-ignore\n context._registerMethod = _registerMethod;\n\n const _htmlElementToVNode = useCallback(\n (elem: HTMLElement) => {\n return createElement(\n contentTag,\n {\n 'data-slot-html-element': elem.tagName.toLowerCase(),\n ref: (refElem: HTMLElement | null): void => {\n refElem?.appendChild(elem);\n },\n },\n null\n );\n },\n [contentTag]\n );\n\n // @ts-ignore\n context._htmlElementToVNode = _htmlElementToVNode;\n\n /** Prebuilt Methods */\n // @ts-ignore\n context.getSlotElement = useCallback(\n (key: string) => {\n const element = elementRef.current?.querySelector(\n `[data-slot-key=\"${key}\"]`\n );\n\n log(\n `🟦 \"${name}\" Slot getSlotElement: ${key}`,\n elementRef.current?.cloneNode(true),\n element?.cloneNode(true)\n );\n\n if (!element) return;\n\n return {\n appendChild: (elem: HTMLElement) => {\n element.appendChild(elem);\n },\n\n prependChild: (elem: HTMLElement) => {\n element.insertBefore(elem, element.firstChild);\n },\n\n appendSibling: (elem: HTMLElement) => {\n const parent = element.parentNode;\n parent?.insertBefore(elem, element.nextSibling);\n },\n\n prependSibling: (elem: HTMLElement) => {\n const parent = element.parentNode;\n parent?.insertBefore(elem, element);\n },\n\n remove: () => {\n element.remove();\n },\n };\n },\n [name]\n );\n\n // @ts-ignore\n context.onRender = useCallback((cb: Function) => {\n methodsRef.current.push(cb);\n }, []);\n\n /**\n * @deprecated Use `onRender` instead.\n */\n // @ts-ignore\n context.onChange = context.onRender;\n\n // @ts-ignore\n context.replaceWith = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod((next) => {\n // @ts-ignore\n const children = _htmlElementToVNode(elem);\n\n next._setProps({ children: [children] });\n });\n },\n [_htmlElementToVNode, _registerMethod]\n );\n\n // @ts-ignore\n context.appendChild = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod((next) => {\n // @ts-ignore\n const vnode = _htmlElementToVNode(elem);\n\n next._setProps((prev: any) => {\n return {\n ...prev,\n children: [...prev.children, vnode],\n };\n });\n });\n },\n [_htmlElementToVNode, _registerMethod]\n );\n\n // @ts-ignore\n context.prependChild = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod((next) => {\n // @ts-ignore\n const vnode = _htmlElementToVNode(elem);\n\n next._setProps((prev: any) => {\n return {\n ...prev,\n children: [vnode, ...prev.children],\n };\n });\n });\n },\n [_htmlElementToVNode, _registerMethod]\n );\n\n // @ts-ignore\n context.appendSibling = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod(() => {\n const parent = elementRef.current?.parentNode;\n\n parent?.insertBefore(elem, elementRef.current?.nextSibling ?? null);\n });\n },\n [_registerMethod]\n );\n\n // @ts-ignore\n context.prependSibling = useCallback(\n (elem: HTMLElement) => {\n // @ts-ignore\n _registerMethod(() => {\n const parent = elementRef.current?.parentNode;\n\n parent?.insertBefore(elem, elementRef.current);\n });\n },\n [_registerMethod]\n );\n\n // @ts-ignore\n context.remove = useCallback(() => {\n // @ts-ignore\n _registerMethod(() => {\n elementRef.current?.remove();\n });\n }, [_registerMethod]);\n\n const handleLifeCycleRender = useCallback(async () => {\n if (status.current === 'loading') return;\n\n status.current = 'loading';\n\n log(`🟨 \"${name}\" Slot Rendered`);\n\n // Reset\n const renderNode = render\n ? cloneElement(render(props), { key: 'render' })\n : null;\n _setProps({ children: [renderNode ?? children] });\n\n // Run all registered methods\n methodsRef.current.forEach((method: any) => {\n method(context, state);\n });\n\n status.current = 'ready';\n }, [children, context, name, props, render, state]);\n\n // Initialization\n const handleLifeCycleInit = useCallback(async () => {\n if (!callback) return;\n\n try {\n status.current = 'loading';\n\n log(`🟩 \"${name}\" Slot Initialized`);\n await callback(\n context as K & DefaultSlotContext<K>,\n elementRef.current as HTMLDivElement | null\n );\n } catch (error) {\n console.error(`Error in \"${callback.name}\" Slot callback`, error);\n } finally {\n status.current = 'ready';\n\n // first render\n await handleLifeCycleRender();\n }\n }, [callback, context, handleLifeCycleRender, name]);\n\n // Initialization\n useEffect(() => {\n handleLifeCycleInit().finally(() => {\n if (slotsQueue && slotsQueue.value.has(name)) {\n slotsQueue.value.delete(name);\n slotsQueue.value = new Set(slotsQueue.value);\n }\n });\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Update\n useEffect(() => {\n handleLifeCycleRender();\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [JSON.stringify(context), JSON.stringify(_state)]);\n\n return [elementRef, props, status.current];\n}\n\n/**\n * Recursively processes children elements to conditionally prevent image loading.\n * \n * This function traverses the children tree and modifies img elements to prevent\n * premature loading during slot initialization. When isReady is false, img src\n * attributes are set to empty string to prevent network requests, while preserving\n * the original src in a data attribute for debugging purposes.\n * \n * @param children - The children elements to process (can be any React/Preact children)\n * @param isReady - Whether the slot is ready to load images (true) or should prevent loading (false)\n * @returns Processed children with conditional image src attributes\n */\nconst processChildren = (children: any, isReady: boolean): any => {\n return Children.map(children, child => {\n // Handle text nodes, numbers, etc.\n if (!isValidElement(child)) {\n return child;\n }\n\n // Handle img elements - conditionally set src\n if (child.props.src) {\n return cloneElement(child, {\n ...child.props,\n src: isReady ? child.props.src : \"\",\n // Optionally preserve original src in data attribute for debugging\n 'data-original-src': child.props.src,\n });\n }\n\n // Handle elements with children - recursively process them\n if (child.props && child.props.children) {\n return cloneElement(child, {\n ...child.props,\n children: processChildren(child.props.children, isReady),\n });\n }\n\n // Return other elements as-is\n return child;\n });\n};\n\n// Slot Component\ninterface SlotPropsComponent<T>\n extends Omit<HTMLAttributes<HTMLElement>, 'slot'> {\n name: string;\n lazy?: boolean;\n slot?: SlotProps<T>;\n context?: Context<T>;\n render?: (props: Record<string, any>) => VNode | VNode[];\n // eslint-disable-next-line no-undef\n slotTag?: keyof HTMLElementTagNameMap; // The tag for the slot wrapper itself\n // eslint-disable-next-line no-undef\n contentTag?: keyof HTMLElementTagNameMap; // The tag for dynamically inserted content\n children?: ComponentChildren;\n}\n\nexport function Slot<T>({\n name,\n lazy = false,\n context,\n slot,\n children,\n render,\n slotTag = 'div',\n contentTag = 'div',\n ...props\n}: Readonly<SlotPropsComponent<T>>): VNode<{\n ref: RefObject<HTMLElement>;\n 'data-slot': string;\n [key: string]: any;\n}> {\n const slotsQueue = useContext(SlotQueueContext);\n\n const [elementRef, slotProps, status] = useSlot<T, HTMLElement>(\n name,\n context,\n slot,\n children,\n render,\n contentTag\n );\n\n useMemo(() => {\n if (!name) {\n return console.warn('Slot \"name\" is required');\n }\n\n // add slot to queue\n if (slotsQueue && lazy === false) {\n slotsQueue.value.add(name);\n slotsQueue.value = new Set(slotsQueue.value);\n }\n }, [name, lazy, slotsQueue]);\n\n return createElement(\n slotTag,\n {\n ...props,\n ref: elementRef,\n 'data-slot': name,\n },\n processChildren(slotProps.children, status === 'ready')\n );\n}\n\n// Debugger\n\n// @ts-ignore\nwindow.DROPINS = window.DROPINS || {};\n\n// @ts-ignore\nwindow.DROPINS.showSlots = async (state) => {\n // cache state in session storage\n window.sessionStorage.setItem(\n 'dropin-debugger--show-slots',\n state.toString()\n );\n\n document.body.classList.toggle('dropin-debugger--show-slots', state);\n};\n\nlet log: (...attrs: any) => void = () => {};\n\n// @ts-ignore\nwindow.DROPINS.logSlots = async (state) => {\n // cache state in session storage\n window.sessionStorage.setItem('dropin-debugger--log-slots', state.toString());\n\n log = state ? (...attrs) => console.log(...attrs) : () => {};\n};\n\n/** Persistent Settings */\n\n// @ts-ignore\nwindow.DROPINS.showSlots(\n window.sessionStorage.getItem('dropin-debugger--show-slots') === 'true'\n);\n\n// @ts-ignore\nwindow.DROPINS.logSlots(\n window.sessionStorage.getItem('dropin-debugger--log-slots') === 'true'\n);\n","/**\n * Get cookie\n * @param {string} cookieName - The name of the cookie to get\n * @returns {string} - The value of the cookie\n */\nexport function getCookie(cookieName: string): string | undefined {\n const cookies = document.cookie.split(';');\n let foundValue;\n\n cookies.forEach((cookie) => {\n const [name, value] = cookie.trim().split('=');\n if (name === cookieName) {\n foundValue = decodeURIComponent(value);\n }\n });\n\n return foundValue;\n}\n"],"names":["getFormValues","form","formData","getFormErrors","data","result","key","field","mergeOptions","target","source","options","destination","item","index","deepmerge","merge","prev","next","toLanguageTag","locale","useSlot","name","context","callback","children","render","contentTag","slotsQueue","useContext","SlotQueueContext","elementRef","useRef","status","methodsRef","props","_setProps","useState","_state","setState","state","useMemo","value","intl","IntlContext","_next","renderNode","cloneElement","n","_registerMethod","useCallback","cb","_htmlElementToVNode","elem","createElement","refElem","element","_a","log","_b","parent","vnode","handleLifeCycleRender","method","handleLifeCycleInit","error","useEffect","processChildren","isReady","Children","child","isValidElement","Slot","lazy","slot","slotTag","slotProps","attrs","getCookie","cookieName","cookies","foundValue","cookie"],"mappings":"+oBASa,MAAAA,EAAiBC,GAA0B,CAChD,MAAAC,EAAgB,IAAI,SAASD,CAAI,EAEhC,OADQ,OAAO,YAAYC,CAAQ,CAE5C,EAEaC,EAAiBF,GAA0B,CAChD,MAAAC,EAAgB,IAAI,SAASD,CAAI,EAEjCG,EAAO,OAAO,YAAYF,CAAQ,EAWjC,OATQ,OAAO,QAAQE,CA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IA,EAAW,KAAK,EAE5C,EAAA,CAACN,EAAMmD,EAAM7C,CAAU,CAAC,EAEpB0B,EACLqB,EACA,CACE,GAAGxC,EACH,IAAKJ,EACL,YAAaT,CACf,EACA6C,EAAgBS,EAAU,SAAU3C,IAAW,OAAO,CACxD,CACF,CAKA,OAAO,QAAU,OAAO,SAAW,CAAC,EAGpC,OAAO,QAAQ,UAAY,MAAOO,GAAU,CAE1C,OAAO,eAAe,QACpB,8BACAA,EAAM,SAAS,CACjB,EAEA,SAAS,KAAK,UAAU,OAAO,8BAA+BA,CAAK,CACrE,EAEA,IAAIkB,EAA+B,IAAM,CAAC,EAG1C,OAAO,QAAQ,SAAW,MAAOlB,GAAU,CAEzC,OAAO,eAAe,QAAQ,6BAA8BA,EAAM,UAAU,EAEtEkB,EAAAlB,EAAQ,IAAIqC,IAAU,QAAQ,IAAI,GAAGA,CAAK,EAAI,IAAM,CAAC,CAC7D,EAKA,OAAO,QAAQ,UACb,OAAO,eAAe,QAAQ,6BAA6B,IAAM,MACnE,EAGA,OAAO,QAAQ,SACb,OAAO,eAAe,QAAQ,4BAA4B,IAAM,MAClE,ECvgBO,SAASC,GAAUC,EAAwC,CAChE,MAAMC,EAAU,SAAS,OAAO,MAAM,GAAG,EACrC,IAAAC,EAEI,OAAAD,EAAA,QAASE,GAAW,CACpB,KAAA,CAAC5D,EAAMoB,CAAK,EAAIwC,EAAO,KAAK,EAAE,MAAM,GAAG,EACzC5D,IAASyD,IACXE,EAAa,mBAAmBvC,CAAK,EACvC,CACD,EAEMuC,CACT"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/tools", "version": "1.6.0-alpha1", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/tools", "version": "1.6.0-alpha11", "license": "SEE LICENSE IN LICENSE.md"}
@@ -4,7 +4,8 @@ export interface PaginationProps {
4
4
  className?: string;
5
5
  currentPage?: number;
6
6
  totalPages?: number;
7
- onChange?: (currentPage: number) => void;
7
+ onChange?: (currentPage: number, e?: Event) => void;
8
+ routePage?: (page: number) => string;
8
9
  }
9
10
  export type PaginationList = {
10
11
  page: number | string;
@@ -0,0 +1,11 @@
1
+ import { FunctionComponent, JSX } from 'preact';
2
+
3
+ type BaseProps = {
4
+ href?: string;
5
+ type?: 'button';
6
+ disabled?: boolean;
7
+ };
8
+ export type PaginationButtonProps = BaseProps & (Omit<JSX.HTMLAttributes<HTMLAnchorElement>, 'type'> | Omit<JSX.HTMLAttributes<HTMLButtonElement>, 'href'>);
9
+ export declare const PaginationButton: FunctionComponent<PaginationButtonProps>;
10
+ export {};
11
+ //# sourceMappingURL=PaginationButton.d.ts.map
@@ -1,44 +1,49 @@
1
1
  export { default as Add } from './Add.svg';
2
+ export { default as AddressBook } from './AddressBook.svg';
2
3
  export { default as Bulk } from './Bulk.svg';
3
4
  export { default as Burger } from './Burger.svg';
5
+ export { default as Business } from './Business.svg';
6
+ export { default as Card } from './Card.svg';
4
7
  export { default as Cart } from './Cart.svg';
5
8
  export { default as Check } from './Check.svg';
9
+ export { default as CheckWithCircle } from './CheckWithCircle.svg';
6
10
  export { default as ChevronDown } from './ChevronDown.svg';
7
- export { default as ChevronUp } from './ChevronUp.svg';
8
11
  export { default as ChevronRight } from './ChevronRight.svg';
12
+ export { default as ChevronUp } from './ChevronUp.svg';
9
13
  export { default as Close } from './Close.svg';
14
+ export { default as Coupon } from './Coupon.svg';
15
+ export { default as Date } from './Date.svg';
16
+ export { default as Delivery } from './Delivery.svg';
17
+ export { default as Edit } from './Edit.svg';
18
+ export { default as EmptyBox } from './EmptyBox.svg';
19
+ export { default as Eye } from './Eye.svg';
20
+ export { default as EyeClose } from './EyeClose.svg';
21
+ export { default as Gift } from './Gift.svg';
22
+ export { default as GiftCard } from './GiftCard.svg';
10
23
  export { default as Heart } from './Heart.svg';
24
+ export { default as HeartFilled } from './HeartFilled.svg';
25
+ export { default as InfoFilled } from './InfoFilled.svg';
26
+ export { default as List } from './List.svg';
27
+ export { default as Locker } from './Locker.svg';
11
28
  export { default as Minus } from './Minus.svg';
29
+ export { default as Order } from './Order.svg';
30
+ export { default as OrderError } from './OrderError.svg';
31
+ export { default as OrderSuccess } from './OrderSuccess.svg';
32
+ export { default as PaymentError } from './PaymentError.svg';
12
33
  export { default as Placeholder } from './Placeholder.svg';
13
34
  export { default as PlaceholderFilled } from './PlaceholderFilled.svg';
35
+ export { default as Quote } from './Quote.svg';
14
36
  export { default as Search } from './Search.svg';
15
37
  export { default as SearchFilled } from './SearchFilled.svg';
16
38
  export { default as Sort } from './Sort.svg';
17
39
  export { default as Star } from './Star.svg';
18
- export { default as View } from './View.svg';
40
+ export { default as Structure } from './Structure.svg';
41
+ export { default as Team } from './Team.svg';
42
+ export { default as Trash } from './Trash.svg';
19
43
  export { default as User } from './User.svg';
20
- export { default as Warning } from './Warning.svg';
21
- export { default as Locker } from './Locker.svg';
44
+ export { default as View } from './View.svg';
22
45
  export { default as Wallet } from './Wallet.svg';
23
- export { default as Card } from './Card.svg';
24
- export { default as Order } from './Order.svg';
25
- export { default as Delivery } from './Delivery.svg';
26
- export { default as OrderError } from './OrderError.svg';
27
- export { default as OrderSuccess } from './OrderSuccess.svg';
28
- export { default as PaymentError } from './PaymentError.svg';
29
- export { default as CheckWithCircle } from './CheckWithCircle.svg';
30
- export { default as WarningWithCircle } from './WarningWithCircle.svg';
46
+ export { default as Warning } from './Warning.svg';
31
47
  export { default as WarningFilled } from './WarningFilled.svg';
32
- export { default as InfoFilled } from './InfoFilled.svg';
33
- export { default as HeartFilled } from './HeartFilled.svg';
34
- export { default as Trash } from './Trash.svg';
35
- export { default as Eye } from './Eye.svg';
36
- export { default as EyeClose } from './EyeClose.svg';
37
- export { default as Date } from './Date.svg';
38
- export { default as AddressBook } from './AddressBook.svg';
39
- export { default as EmptyBox } from './EmptyBox.svg';
40
- export { default as Coupon } from './Coupon.svg';
41
- export { default as Gift } from './Gift.svg';
42
- export { default as GiftCard } from './GiftCard.svg';
43
- export { default as Edit } from './Edit.svg';
48
+ export { default as WarningWithCircle } from './WarningWithCircle.svg';
44
49
  //# sourceMappingURL=index.d.ts.map
@@ -23,9 +23,9 @@ declare function resetConfig(): void;
23
23
  * @param {Object} [configObj=config] - The config object.
24
24
  * @returns {string} - The root path.
25
25
  */
26
- declare function getRootPath(configObj?: Config | null, options?: {
26
+ declare function getRootPath(configObj?: Config | null, optionsObj?: {
27
27
  match?: (key: string) => boolean;
28
- }): string;
28
+ } | null): string;
29
29
  /**
30
30
  * Get list of root paths from public config
31
31
  * @returns {Array} - The list of root paths.
@@ -50,7 +50,7 @@ declare function getHeaders(scope: string): Record<string, string>;
50
50
  * @param {Function} [options.match] - The function to match the path to the config.
51
51
  * @returns {Object} The initialized root configuration
52
52
  */
53
- declare function initializeConfig(configObj: Config, options?: {
53
+ declare function initializeConfig(configObj: Config, optionsObj?: {
54
54
  match?: (key: string) => boolean;
55
55
  }): ConfigRoot;
56
56
  /**
@@ -0,0 +1,34 @@
1
+ /********************************************************************
2
+ * Copyright 2025 Adobe
3
+ * All Rights Reserved.
4
+ *
5
+ * NOTICE: Adobe permits you to use, modify, and distribute this
6
+ * file in accordance with the terms of the Adobe license agreement
7
+ * accompanying it.
8
+ *******************************************************************/
9
+ export interface PriceFormatterOptions {
10
+ currency?: string | null;
11
+ locale?: string;
12
+ formatOptions?: Intl.NumberFormatOptions;
13
+ }
14
+ /**
15
+ * Determines the effective locale to use for price formatting
16
+ * Priority: prop locale > global locale > browser locale > default 'en-US'
17
+ */
18
+ export declare function getEffectiveLocale(locale?: string): string;
19
+ /**
20
+ * Gets an Intl.NumberFormat instance for price formatting
21
+ * Uses getEffectiveLocale internally to determine the best locale
22
+ *
23
+ * @example
24
+ * // Single price formatting
25
+ * const formatter = getPriceFormatter({ currency: 'USD', locale: 'en-US' });
26
+ * const price = formatter.format(10.99); // "$10.99"
27
+ *
28
+ * @example
29
+ * // Bulk price formatting (more efficient)
30
+ * const formatter = getPriceFormatter({ currency: 'EUR', locale: 'fr-FR' });
31
+ * const prices = [10.99, 25.50, 99.99].map(amount => formatter.format(amount));
32
+ */
33
+ export declare function getPriceFormatter(options?: PriceFormatterOptions): Intl.NumberFormat;
34
+ //# sourceMappingURL=get-price-formatter.d.ts.map
@@ -24,4 +24,5 @@ export * from './is-number';
24
24
  export * from './deviceUtils';
25
25
  export * from './get-path-value';
26
26
  export * from './get-cookie';
27
+ export * from './get-price-formatter';
27
28
  //# sourceMappingURL=index.d.ts.map
@@ -32,22 +32,22 @@ export type AfterHook<T = any> = (requestInit: RequestInit, response: {
32
32
  data: T;
33
33
  };
34
34
  declare class FetchGraphQLMesh {
35
- _endpoint?: string;
36
- _inheritHeaders?: boolean;
37
- get endpoint(): string | undefined;
38
- get fetchGraphQlHeaders(): Header;
35
+ protected _endpoint?: string;
39
36
  _fetchGraphQlHeaders: Header;
40
37
  _beforeHooks: BeforeHook[];
41
38
  _afterHooks: AfterHook[];
39
+ get endpoint(): string | undefined;
40
+ get fetchGraphQlHeaders(): Header;
42
41
  /**
43
42
  * Sets the GraphQL endpoint.
44
- * @param endpoint - The GraphQL endpoint.
45
- * @param options - Optional configuration.
46
- * @param options.inheritHeaders - If true, headers from the global mesh will be inherited.
43
+ * @param endpoint - The GraphQL endpoint URL string.
44
+ * @example
45
+ * ```js
46
+ * // Set endpoint as string
47
+ * instance.setEndpoint('https://api.example.com/graphql');
48
+ * ```
47
49
  */
48
- setEndpoint(endpoint: string, options?: {
49
- inheritHeaders?: boolean;
50
- }): void;
50
+ setEndpoint(endpoint: string): void;
51
51
  /**
52
52
  * Sets the GraphQL headers.
53
53
  * @param key - The key of the header.
@@ -111,6 +111,16 @@ declare class FetchGraphQLMesh {
111
111
  * ```
112
112
  */
113
113
  addAfterHook(hook: AfterHook): void;
114
+ /**
115
+ * Collects all before hooks. Can be overridden by subclasses for inheritance.
116
+ * @protected
117
+ */
118
+ protected _collectBeforeHooks(): BeforeHook[];
119
+ /**
120
+ * Collects all after hooks. Can be overridden by subclasses for inheritance.
121
+ * @protected
122
+ */
123
+ protected _collectAfterHooks(): AfterHook[];
114
124
  /**
115
125
  * Fetches GraphQL data.
116
126
  * @param query - The GraphQL query.
@@ -129,9 +139,7 @@ declare class FetchGraphQLMesh {
129
139
  fetchGraphQlHeaders: Header;
130
140
  };
131
141
  getMethods(): {
132
- setEndpoint: (endpoint: string, options?: {
133
- inheritHeaders?: boolean | undefined;
134
- } | undefined) => void;
142
+ setEndpoint: (endpoint: string) => void;
135
143
  setFetchGraphQlHeader: (key: string, value: string | null) => void;
136
144
  getFetchGraphQlHeader: (key: string) => string | null | undefined;
137
145
  removeFetchGraphQlHeader: (key: string) => void;
@@ -150,14 +158,75 @@ declare class FetchGraphQLMesh {
150
158
  }
151
159
  /**
152
160
  * `FetchGraphQL` is a class that extends `FetchGraphQLMesh`.
153
- * It provides methods to get the GraphQL endpoint and headers.
161
+ * It provides methods to get the GraphQL endpoint and headers with support for inheritance.
154
162
  *
155
163
  * @class
156
164
  *
157
165
  */
158
166
  export declare class FetchGraphQL extends FetchGraphQLMesh {
167
+ private _mode;
168
+ private _source?;
159
169
  get endpoint(): string | undefined;
160
170
  get fetchGraphQlHeaders(): Header;
171
+ /**
172
+ * Sets the GraphQL endpoint or links to another FetchGraphQL instance.
173
+ * @param endpoint - The GraphQL endpoint URL string, or a FetchGraphQL instance to link to.
174
+ * @example
175
+ * ```js
176
+ * // Set endpoint as string
177
+ * instance.setEndpoint('https://api.example.com/graphql');
178
+ *
179
+ * // Link to another instance
180
+ * const parent = new FetchGraphQL();
181
+ * parent.setEndpoint('https://api.example.com/graphql');
182
+ *
183
+ * const child = new FetchGraphQL();
184
+ * child.setEndpoint(parent); // Links to parent, shares endpoint, headers, and hooks
185
+ * ```
186
+ */
187
+ setEndpoint(endpoint: string | FetchGraphQL): void;
188
+ /**
189
+ * Sets a GraphQL header. When linked to another instance, this sets the header on the linked instance.
190
+ * @param key - The key of the header.
191
+ * @param value - The value of the header.
192
+ */
193
+ setFetchGraphQlHeader(key: string, value: string | null): void;
194
+ /**
195
+ * Sets the GraphQL headers. When linked to another instance, this sets the headers on the linked instance.
196
+ * @param header - The header object or a function that returns a header object.
197
+ */
198
+ setFetchGraphQlHeaders(header: Header | ((prev: Header) => Header)): void;
199
+ /**
200
+ * Removes a specific GraphQL header. When linked to another instance, this removes the header from the linked instance.
201
+ * @param key - The key of the header.
202
+ */
203
+ removeFetchGraphQlHeader(key: string): void;
204
+ /**
205
+ * Gets the value of a specific GraphQL header. When linked to another instance, this gets the header from the linked instance.
206
+ * @param key - The key of the header.
207
+ * @returns The value of the header, or undefined if not found.
208
+ */
209
+ getFetchGraphQlHeader(key: string): string | null | undefined;
210
+ /**
211
+ * Adds a before hook. When linked to another instance, this adds the hook to the linked instance.
212
+ * @param hook - The hook function.
213
+ */
214
+ addBeforeHook(hook: BeforeHook): void;
215
+ /**
216
+ * Adds an after hook. When linked to another instance, this adds the hook to the linked instance.
217
+ * @param hook - The hook function.
218
+ */
219
+ addAfterHook(hook: AfterHook): void;
220
+ /**
221
+ * Collects all before hooks. When linked, delegates to the linked instance.
222
+ * @protected
223
+ */
224
+ protected _collectBeforeHooks(): BeforeHook[];
225
+ /**
226
+ * Collects all after hooks. When linked, delegates to the linked instance.
227
+ * @protected
228
+ */
229
+ protected _collectAfterHooks(): AfterHook[];
161
230
  }
162
231
  /**
163
232
  * Exports several methods from the `mesh` object.
@@ -169,10 +238,10 @@ export declare class FetchGraphQL extends FetchGraphQLMesh {
169
238
  * @property {Function} removeFetchGraphQlHeader - Removes a specific GraphQL header.
170
239
  * @property {Function} fetchGraphQl - Fetches GraphQL data.
171
240
  * @property {Function} getConfig - Gets the configuration.
241
+ * @property {Function} addBeforeHook - Adds a hook executed before the GraphQL call.
242
+ * @property {Function} addAfterHook - Adds a hook executed after the GraphQL call.
172
243
  */
173
- export declare const setEndpoint: (endpoint: string, options?: {
174
- inheritHeaders?: boolean;
175
- }) => void, setFetchGraphQlHeaders: (header: Header | ((prev: Header) => Header)) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, getFetchGraphQlHeader: (key: string) => string | null | undefined, removeFetchGraphQlHeader: (key: string) => void, fetchGraphQl: <T = any>(query: string, options?: FetchOptions) => Promise<{
244
+ export declare const setEndpoint: (endpoint: string) => void, setFetchGraphQlHeaders: (header: Header | ((prev: Header) => Header)) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, getFetchGraphQlHeader: (key: string) => string | null | undefined, removeFetchGraphQlHeader: (key: string) => void, fetchGraphQl: <T = any>(query: string, options?: FetchOptions) => Promise<{
176
245
  errors?: FetchQueryError | undefined;
177
246
  data: T;
178
247
  }>, getConfig: () => {
@@ -1,9 +1,7 @@
1
1
  import { ReCaptchaV3Response, PropsFormTypes, ReCaptchaV3Model } from './types/recaptcha.types';
2
2
 
3
3
  export declare const recaptchaFetchApi: {
4
- setEndpoint: (endpoint: string, options?: {
5
- inheritHeaders?: boolean | undefined;
6
- } | undefined) => void;
4
+ setEndpoint: (endpoint: string) => void;
7
5
  setFetchGraphQlHeader: (key: string, value: string | null) => void;
8
6
  getFetchGraphQlHeader: (key: string) => string | null | undefined;
9
7
  removeFetchGraphQlHeader: (key: string) => void;
@@ -1,4 +0,0 @@
1
- /*! Copyright 2025 Adobe
2
- All Rights Reserved. */
3
- const s=(e,o)=>{let t;return function(...n){clearTimeout(t),t=setTimeout(()=>e.apply(this,n),o)}},i=e=>typeof e=="number",c=()=>{const e=navigator.userAgent.toLowerCase(),o=/ipad|iphone|ipod/.test(e),t=e.includes("mac")&&"ontouchend"in document;return o||t};export{c as a,s as d,i};
4
- //# sourceMappingURL=deviceUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deviceUtils.js","sources":["/@dropins/tools/src/lib/debounce.ts","/@dropins/tools/src/lib/is-number.ts","/@dropins/tools/src/lib/deviceUtils.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const debounce = (fn: Function, ms: number) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function (this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const isNumber = (value: number | string): value is number => {\n return typeof value === 'number';\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const isIOSMobileDevice = () => {\n const userAgent = navigator.userAgent.toLowerCase();\n const isIOS = /ipad|iphone|ipod/.test(userAgent);\n const isMacWithTouch = userAgent.includes('mac') && 'ontouchend' in document;\n\n return isIOS || isMacWithTouch;\n};\n"],"names":["debounce","fn","ms","timeoutId","args","isNumber","value","isIOSMobileDevice","userAgent","isIOS","isMacWithTouch"],"mappings":"AASa,MAAAA,EAAW,CAACC,EAAcC,IAAe,CAChD,IAAAC,EACJ,OAAO,YAAwBC,EAAa,CAC1C,aAAaD,CAAS,EACtBA,EAAY,WAAW,IAAMF,EAAG,MAAM,KAAMG,CAAI,EAAGF,CAAE,CACvD,CACF,ECNaG,EAAYC,GAChB,OAAOA,GAAU,SCDbC,EAAoB,IAAM,CAC/B,MAAAC,EAAY,UAAU,UAAU,YAAY,EAC5CC,EAAQ,mBAAmB,KAAKD,CAAS,EACzCE,EAAiBF,EAAU,SAAS,KAAK,GAAK,eAAgB,SAEpE,OAAOC,GAASC,CAClB"}