@dropins/storefront-company-switcher 1.0.6-beta1 → 1.0.6-beta3

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/LICENSE.md CHANGED
@@ -1,21 +1,19 @@
1
-
2
- Last Updated: 28 October 2024
1
+ Last Updated: 8 December 2025
3
2
 
4
3
  ADOBE COMMERCE DROP-IN LICENSE AGREEMENT
5
4
 
6
- applicable to Adobe Commerce Customers
5
+ applicable to Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer Customers
7
6
 
8
7
  **Effective Date:** first date you download or use the Drop-in
9
8
 
10
- NOTICE TO USER: The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
9
+ NOTICE TO USER: The Adobe Commerce Drop-ins are licensed only for use with Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer. The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in.**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
11
10
 
12
- Your access to and use of the Drop-in is governed by the Adobe Enterprise Licensing Terms previously agreed to by you and Adobe or an authorized Adobe Reseller in a separate agreement. If you have not previously agreed to licensing terms then your installation and use of the Drop-in is subject to the current applicable Adobe Enterprise Licensing Terms available at <http://www.adobe.com/legal/terms/enterprise-licensing.html>. You agree that this agreement will have the same effect as any written negotiated agreement signed by you.
11
+ Your access to and use of the Drop-in is governed by the Adobe Enterprise Licensing Terms previously agreed to by you and Adobe or an authorized Adobe Reseller in a separate agreement. If you have not previously agreed to licensing terms then your installation and use of the Drop-in is subject to the current applicable Adobe Enterprise Licensing Terms available at http://www.adobe.com/legal/terms/enterprise-licensing.html. You agree that this agreement will have the same effect as any written negotiated agreement signed by you.
13
12
 
14
13
  By downloading, installing or making use of any portion of the Drop-in, you accept and agree to be bound by all the terms and conditions of this agreement including all terms incorporated herein by reference.
15
-
16
14
  This agreement is enforceable against any person or entity that installs and uses the Drop-in and any person or entity (e.g., system integrator, consultant or contractor) that installs or uses the drop-in on another person's or entity's behalf (e.g., Adobe Customer).
17
15
 
18
- Notice to U.S. Government End Users: Products and services are “Commercial Product(s),” and “Commercial Service(s)” as those terms are defined at 48 C.F.R. section 2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
16
+ Notice to U.S. Government End Users: Products and services are “Commercial Product(s),” and “Commercial Service(s)” as those terms are defined at 48 C.F.R. section 2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
19
17
 
20
18
  **ADOBE COMMERCE DROP-IN LICENSE AGREEMENT**
21
19
 
@@ -23,25 +21,25 @@ applicable to Developers
23
21
 
24
22
  **Effective Date:** first date you download or use the Drop-in
25
23
 
26
- The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
24
+ The Adobe Commerce Drop-ins are licensed only for use with Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer. The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
27
25
 
28
26
  **AGREED TERMS AND CONDITIONS**
29
27
 
30
28
  1. **DEFINITIONS**.
31
29
 
32
- 1.1 “**Adobe**” means collectively, Adobe Inc., a company incorporated in Delaware, U.S.A., having a place of business at 345 Park Avenue, San Jose, California USA 95110-2704, U.S.A. (“**Adobe US**”) and Adobe Systems Software Ireland, company incorporated in Ireland, having a place of business 4-6 Riverwalk, City West Business Campus, Saggart, Dublin 24, Ireland (“**Adobe Ireland**”).__
30
+ 1.1 “**Adobe**” means collectively, Adobe Inc., a company incorporated in Delaware, U.S.A., having a place of business at 345 Park Avenue, San Jose, California USA 95110-2704, U.S.A. (“**Adobe US**”) and Adobe Systems Software Ireland, company incorporated in Ireland, having a place of business 4-6 Riverwalk, City West Business Campus, Saggart, Dublin 24, Ireland (“**Adobe Ireland**”).
33
31
 
34
32
  1.2 “**Adobe Product(s)**” means software applications, programs and other technologies not included in or with the Drop-in which are or may be made available by Adobe for licensing to the general public. This agreement does not govern use of Adobe Products. See the end user license agreement accompanying an Adobe Product for terms governing its use.
35
-
33
+
36
34
  1.3 “**Developer Product(s)**” means any software application(s), program(s) and other teconolog(y/ies) you develop with use of the Drop-in to function or interoperate with Adobe Products.
37
35
 
38
36
  1.4 “**Intellectual Property Rights**” means copyright, moral rights, trademark, trade dress, patent, trade secret, unfair competition, and any other intellectual and proprietary rights.
39
37
 
40
- 1.5 “**Adobe Commerce Drop-in**” or “Drop-in” means all items comprising the application and all associated materials licensed to you by Adobe as part of the Drop-in, including all Drop-in system files, tools, programs and utilities, as well as any plug-ins or other application programming interfaces, header or JAR files (“**API**”), sample images, sounds, or similar assets (“**Content** **Files**”), software code samples, runtimes and libraries, including any portion(s) that is modified by you, or merged or incorporated with your Developer Products (“**Sample Code**”), and any related documentation, technical specifications, notes and explanatory materials, as well any modifications, updates, upgrades, or copies of, any of the foregoing items, that may be made available by Adobe, whether online or recorded on media, or manually downloaded by you.
38
+ 1.5 “**Adobe Commerce Drop-in**” or “Drop-in” means all items comprising the application and all associated materials licensed to you by Adobe as part of the Drop-in, including all Drop-in system files, tools, programs and utilities, as well as any plug-ins or other application programming interfaces, header or JAR files (“**API**”), sample images, sounds, or similar assets (“**Content** **Files**”), software code samples, runtimes and libraries, including any portion(s) that is modified by you, or merged or incorporated with your Developer Products (“**Sample Code**”), nd any related documentation, technical specifications, notes and explanatory materials, as well any modifications, updates, upgrades, or copies of, any of the foregoing items, that may be made available by Adobe, whether online or recorded on media, or manually downloaded by you.
41
39
 
42
40
  2. **LICENSES GRANTED TO YOU**.
43
41
 
44
- 2.1 **Drop-in**. Subject to your compliance with terms of this agreement, Adobe grants to you a non-exclusive, non-sublicensable, non-transferable license to install and use the Drop-in solely for your internal design, development and testing of your Developer Products, subject further to the requirements and limitations below.
42
+ 2.1 **Drop-in**. Subject to your compliance with terms of this agreement, Adobe grants to you a non-exclusive, non-sublicensable, non-transferable license to install and use the Drop-in solely for your internal design, development and testing of your Developer Products, subject further to the requirements and limitations below.
45
43
 
46
44
  2.2 **API.** Subject to your compliance with terms of this agreement, Adobe grants to you a non-exclusive, non-sublicensable, non-transferable license to use the API only as provided in or by the applicable specification and to distribute the API solely in, with, and on the same media as, your Developer Products. For clarification, you may not modify the API.
47
45
 
@@ -51,9 +49,9 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
51
49
 
52
50
  3. **SCOPE OF LICENSE; LIMITATIONS AND RESTRICTIONS**
53
51
 
54
- 3.1 You may not distribute the Drop-ins or any of its component parts to interoperate with or to run on a platform other than the Adobe-approved platform.
52
+ 3.1 You may not distribute the Drop-ins or any of its component parts to interoperate with or to run on a platform other than Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer.
55
53
 
56
- 3.2 Third-Party Software. The Drop-ins may contain third-party software, subject to additional terms and conditions, available at <http://www.adobe.com/go/thirdparty>; and
54
+ 3.2 Third-Party Software. The Drop-ins may contain third-party software, subject to additional terms and conditions, available at http://www.adobe.com/go/thirdparty; and
57
55
 
58
56
  3.3 You may not modify, port, adapt, creative derivate works, redistribute, or translate any portion of this Drop-in; or add or delete any Drop-in program files that would in any way result in modifying the functionality or appearance of any element of the Adobe Products.
59
57
 
@@ -81,7 +79,7 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
81
79
 
82
80
  7. **CONFIDENTIAL INFORMATION**
83
81
 
84
- With respect to the API, and any portion, included in the Drop-in (for purposes of this Section, “**Adobe Confidential Information**”), you will treat the Adobe Confidential Information, and exercise the same degree of care to protect it, as you afford to your own confidential information. Your obligations under this Section will terminate when you can document that (a) the Adobe Confidential Information was in the public domain at or subsequent to the time Adobe communicated or provided it to you with no fault of your own; (b) your employees or agents developed independently without reference to any Adobe Confidential Information Adobe communicated or provided to you; or (c) your communication of Adobe Confidential Information was in response to a valid order by a court or other governmental body, was otherwise required by law, or was necessary to establish the rights of a party under this agreement.
82
+ With respect to the API, and any portion, included in the Drop-in (for purposes of this Section, “**Adobe Confidential Information**”), you will treat the Adobe Confidential Information, and exercise the same degree of care to protect it, as you afford to your own confidential information. Your obligations under this Section will terminate when you can document that (a) the Adobe Confidential Information was in the public domain at or subsequent to the time Adobe communicated or provided it to you with no fault of your own; (b) your employees or agents developed independently without reference to any Adobe Confidential Information Adobe communicated or provided to you; or (c) your communication of Adobe Confidential Information was in response to a valid order by a court or other governmental body, was otherwise required by law, or was necessary to establish the rights of a party under this agreement.
85
83
 
86
84
  8. **TERM; TERMINATION**
87
85
 
@@ -113,7 +111,7 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
113
111
 
114
112
  13. **NOTICE TO U.S. GOVERNMENT END USERS**
115
113
 
116
- Products and services are “Commercial Product(s),” and “Commercial Service(s)” as those terms are defined at 48 C.F.R. section 2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
114
+ Products and services are “Commercial Product(s),” and “Commercial Service(s)” as those terms are defined at 48 C.F.R. section 2.101, consisting of “Commercial Computer Software” and “Commercial Computer Software Documentation,” as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
117
115
 
118
116
  14. **GENERAL PROVISIONS**
119
117
 
@@ -1,9 +1,12 @@
1
1
  import { HTMLAttributes } from 'preact/compat';
2
2
  import { Container } from '@dropins/tools/types/elsie/src/lib';
3
+ import { Company } from '../../types/company';
3
4
 
4
5
  export interface CompanySwitcherProps extends HTMLAttributes<HTMLDivElement> {
5
6
  /** Custom aria-label for the picker */
6
7
  ariaLabel?: string;
8
+ /** Callback function to be called when the company changes */
9
+ onCompanyChange?: (company: Company) => void;
7
10
  }
8
11
  /**
9
12
  * CompanySwitcher component allows users to switch between companies they have access to.
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as S}from"@dropins/tools/preact-jsx-runtime.js";import{useState as x,useCallback as p,useEffect as I,useMemo as k}from"@dropins/tools/preact-hooks.js";import{Picker as H}from"@dropins/tools/components.js";import{events as C}from"@dropins/tools/event-bus.js";import{C as v,e as w,c as u,u as K,h as G}from"../chunks/customerCompanyContext.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const M=()=>{const[y,s]=x([]),[g,r]=x({text:"",value:""}),l=p(async()=>{var e,o;try{const n=await v.getInstance().getCustomerCompanyInfo();s(n.customerCompanies),(e=n.currentCompany)!=null&&e.name&&((o=n.currentCompany)!=null&&o.id)&&r({text:n.currentCompany.name,value:n.currentCompany.id})}catch(t){console.error("Failed to load company data:",t)}},[]),h=p(async e=>{const t=e.target.value,n=y.find(i=>i.value===t);n&&r(n),w().setCompanyHeaders(t),t?sessionStorage.setItem(u.getConfig().companySessionStorageKey,t):sessionStorage.removeItem(u.getConfig().companySessionStorageKey);const a=await K();G().setGroupHeaders(a),a?sessionStorage.setItem(u.getConfig().groupSessionStorageKey,a):sessionStorage.removeItem(u.getConfig().groupSessionStorageKey),C.emit("companyContext/changed",t)},[y]),c=p(()=>{v.getInstance().resetCache(),s([]),r({text:"",value:""})},[]),d=p(e=>{e?l():c()},[l,c]),f=p(e=>{if(!e){c();return}s(o=>{const t=o.find(n=>n.value===e);return t&&r(t),o})},[c,s,r]),m=p(e=>{const{company:o}=e;s(t=>{const n=t.findIndex(a=>a.value===o.id);return n===-1?t:t.map((a,i)=>i===n?{...a,text:o.name}:a)}),r({text:o.name,value:o.id})},[]);return I(()=>{const e=C.on("authenticated",d,{eager:!0}),o=C.on("companyContext/changed",f,{eager:!0}),t=C.on("company/updated",m);return()=>{var n,a,i;(n=e==null?void 0:e.off)==null||n.call(e),(a=o==null?void 0:o.off)==null||a.call(o),(i=t==null?void 0:t.off)==null||i.call(t)}},[d,f,m]),{companies:y,currentCompany:g,handleCompanyChange:h}},q=({ariaLabel:y,...s})=>{const{companies:g,currentCompany:r,handleCompanyChange:l}=M(),[h,c]=x(!0),d=k(()=>g,[g]);return I(()=>{const f=()=>{c(!1)},m=C.on("checkout/initialized",f),e=C.on("checkout/updated",f);return()=>{m==null||m.off(),e==null||e.off()}},[]),g.length<2||!h?null:S("div",{...s,children:S(H,{options:d,value:r.value,onChange:l,"aria-label":y||"Select company","aria-describedby":"company-switcher-description"})})};export{q as CompanySwitcher,q as default};
3
+ import{jsx as v}from"@dropins/tools/preact-jsx-runtime.js";import{useState as S,useCallback as f,useEffect as k,useMemo as H}from"@dropins/tools/preact-hooks.js";import{Picker as w}from"@dropins/tools/components.js";import{events as d}from"@dropins/tools/event-bus.js";import{C as I,e as K,c as x,u as G,h as M}from"../chunks/customerCompanyContext.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";const D=({onCompanyChange:c}={})=>{const[l,s]=S([]),[g,r]=S({text:"",value:""}),C=f(async()=>{var e,n;try{const o=await I.getInstance().getCustomerCompanyInfo();s(o.customerCompanies),(e=o.currentCompany)!=null&&e.name&&((n=o.currentCompany)!=null&&n.id)&&r({text:o.currentCompany.name,value:o.currentCompany.id})}catch(t){console.error("Failed to load company data:",t)}},[]),h=f(async e=>{const t=e.target.value,o=l.find(p=>p.value===t);o&&r(o),K().setCompanyHeaders(t),t?sessionStorage.setItem(x.getConfig().companySessionStorageKey,t):sessionStorage.removeItem(x.getConfig().companySessionStorageKey);const a=await G();M().setGroupHeaders(a),a?sessionStorage.setItem(x.getConfig().groupSessionStorageKey,a):sessionStorage.removeItem(x.getConfig().groupSessionStorageKey),c==null||c({id:t,name:(o==null?void 0:o.text)||""}),d.emit("companyContext/changed",t)},[l,c]),m=f(()=>{I.getInstance().resetCache(),s([]),r({text:"",value:""})},[]),u=f(e=>{e?C():m()},[C,m]),y=f(e=>{if(!e){m();return}s(n=>{const t=n.find(o=>o.value===e);return t&&r(t),n})},[m,s,r]),i=f(e=>{const{company:n}=e;s(t=>{const o=t.findIndex(a=>a.value===n.id);return o===-1?t:t.map((a,p)=>p===o?{...a,text:n.name}:a)}),r({text:n.name,value:n.id})},[]);return k(()=>{const e=d.on("authenticated",u,{eager:!0}),n=d.on("companyContext/changed",y,{eager:!0}),t=d.on("company/updated",i);return()=>{var o,a,p;(o=e==null?void 0:e.off)==null||o.call(e),(a=n==null?void 0:n.off)==null||a.call(n),(p=t==null?void 0:t.off)==null||p.call(t)}},[u,y,i]),{companies:l,currentCompany:g,handleCompanyChange:h}},B=({ariaLabel:c,onCompanyChange:l,...s})=>{const{companies:g,currentCompany:r,handleCompanyChange:C}=D({onCompanyChange:l}),[h,m]=S(!0),u=H(()=>g,[g]);return k(()=>{const y=()=>{m(!1)},i=d.on("checkout/initialized",y),e=d.on("checkout/updated",y);return()=>{i==null||i.off(),e==null||e.off()}},[]),g.length<2||!h?null:v("div",{...s,children:v(w,{options:u,value:r.value,onChange:C,"aria-label":c||"Select company","aria-describedby":"company-switcher-description"})})};export{B as CompanySwitcher,B as default};
4
4
  //# sourceMappingURL=CompanySwitcher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompanySwitcher.js","sources":["/@dropins/storefront-company-switcher/src/hooks/useCompanyData.ts","/@dropins/storefront-company-switcher/src/containers/CompanySwitcher/CompanySwitcher.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { useState, useCallback, useEffect } from 'preact/hooks';\nimport { events } from '@adobe-commerce/event-bus';\nimport { CustomerCompanyContext, updateCustomerGroup } from '@/company-switcher/api/customerCompanyContext';\nimport type { CompanyOption, CustomerCompanyInfo, UseCompanyDataReturn } from '@/company-switcher/types/company';\nimport { config } from '@/company-switcher/api/initialize';\nimport { getGroupHeaderManager } from '@/company-switcher/api/setGroupHeaders';\nimport { getCompanyHeaderManager } from '@/company-switcher/api/setCompanyHeaders';\n\n/**\n * Custom hook that manages company data fetching and state management\n * @returns {UseCompanyDataReturn} Company data and handlers\n */\nexport const useCompanyData = (): UseCompanyDataReturn => {\n const [companies, setCompanies] = useState<CompanyOption[]>([]);\n const [currentCompany, setCurrentCompany] = useState<CompanyOption>({ text: '', value: '' });\n\n\n /**\n * Loads company information from the API and updates state\n */\n const loadCompanyData = useCallback(async (): Promise<void> => {\n try {\n const customerCompanyContext = CustomerCompanyContext.getInstance();\n const companyInfo: CustomerCompanyInfo = await customerCompanyContext.getCustomerCompanyInfo();\n setCompanies(companyInfo.customerCompanies);\n \n if (companyInfo.currentCompany?.name && companyInfo.currentCompany?.id) {\n setCurrentCompany({\n text: companyInfo.currentCompany.name, \n value: companyInfo.currentCompany.id\n });\n }\n } catch (err) {\n console.error('Failed to load company data:', err);\n }\n }, []);\n\n /**\n * Handles company selection change\n */\n const handleCompanyChange = useCallback(async (event: Event): Promise<void> => {\n const target = event.target as HTMLSelectElement;\n const companyId = target.value;\n \n // Update local state\n const selectedCompany = companies.find(c => c.value === companyId);\n if (selectedCompany) {\n setCurrentCompany(selectedCompany);\n }\n \n getCompanyHeaderManager().setCompanyHeaders(companyId);\n if (companyId) {\n sessionStorage.setItem(config.getConfig().companySessionStorageKey, companyId);\n } else {\n sessionStorage.removeItem(config.getConfig().companySessionStorageKey);\n }\n const groupId = await updateCustomerGroup();\n getGroupHeaderManager().setGroupHeaders(groupId);\n if (groupId) {\n sessionStorage.setItem(config.getConfig().groupSessionStorageKey, groupId);\n } else {\n sessionStorage.removeItem(config.getConfig().groupSessionStorageKey);\n }\n\n events.emit('companyContext/changed', companyId);\n }, [companies]);\n\n /**\n * Clears company context\n */\n const clearCompanyContext = useCallback((): void => {\n const customerCompanyContext = CustomerCompanyContext.getInstance();\n customerCompanyContext.resetCache();\n setCompanies([]);\n setCurrentCompany({ text: '', value: '' });\n }, []);\n\n /**\n * Handles authentication state changes\n */\n const handleAuthenticationChange = useCallback((authenticated: boolean) => {\n if (authenticated) {\n loadCompanyData();\n } else {\n clearCompanyContext();\n }\n }, [loadCompanyData, clearCompanyContext]);\n\n /**\n * Handles company context restoration\n */\n const handleCompanyContextRestored = useCallback((companyId: string | null) => {\n if (!companyId) {\n clearCompanyContext();\n return;\n }\n // Store the company ID to be restored when companies are loaded\n setCompanies(prevCompanies => {\n const restoredCompany = prevCompanies.find(company => company.value === companyId);\n if (restoredCompany) {\n setCurrentCompany(restoredCompany);\n }\n return prevCompanies;\n });\n }, [clearCompanyContext, setCompanies, setCurrentCompany]);\n\n /**\n * Handles company updated event\n */\n const handleCompanyUpdated = useCallback((eventData: { company: { id: string; name: string; } }) => {\n const { company } = eventData;\n\n setCompanies(prevCompanies => {\n const companyIndex = prevCompanies.findIndex(c => c.value === company.id);\n if (companyIndex === -1) {\n return prevCompanies;\n }\n return prevCompanies.map((c, i) =>\n i === companyIndex ? { ...c, text: company.name } : c\n );\n });\n \n setCurrentCompany({\n text: company.name,\n value: company.id\n });\n }, []);\n\n // Set up event listeners\n useEffect(() => {\n const unsubscribeAuth = events.on('authenticated', handleAuthenticationChange, { eager: true });\n const unsubscribeRestore = events.on('companyContext/changed', handleCompanyContextRestored, { eager: true });\n const unsubscribeCompanyUpdated = events.on('company/updated', handleCompanyUpdated);\n \n return () => {\n unsubscribeAuth?.off?.();\n unsubscribeRestore?.off?.();\n unsubscribeCompanyUpdated?.off?.();\n };\n }, [handleAuthenticationChange, handleCompanyContextRestored, handleCompanyUpdated]);\n\n return {\n companies,\n currentCompany,\n handleCompanyChange\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { useMemo, useState, useEffect } from 'preact/hooks';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Picker } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { useCompanyData } from '@/company-switcher/hooks/useCompanyData';\n\nexport interface CompanySwitcherProps extends HTMLAttributes<HTMLDivElement> {\n /** Custom aria-label for the picker */\n ariaLabel?: string;\n}\n\n/**\n * CompanySwitcher component allows users to switch between companies they have access to.\n * It only renders when a user has access to multiple companies.\n * This is a presentational component that uses the useCompanyData hook for all business logic.\n */\nexport const CompanySwitcher: Container<CompanySwitcherProps> = ({ \n ariaLabel,\n ...props \n}) => {\n const { companies, currentCompany, handleCompanyChange } = useCompanyData();\n const [isVisible, setIsVisible] = useState(true);\n\n // Memoize the companies array to prevent unnecessary re-renders\n const memoizedCompanies = useMemo(() => companies, [companies]);\n\n // Listen for checkout/initialized and checkout/updated events to hide the picker\n useEffect(() => {\n const hidePickerHandler = () => {\n setIsVisible(false);\n };\n\n const unsubscribeInitialized = events.on('checkout/initialized', hidePickerHandler);\n const unsubscribeUpdated = events.on('checkout/updated', hidePickerHandler);\n\n return () => {\n unsubscribeInitialized?.off();\n unsubscribeUpdated?.off();\n };\n }, []);\n\n // Only render if user has access to multiple companies and picker is visible\n if (companies.length < 2 || !isVisible) {\n return null;\n }\n\n return (\n <div {...props}>\n <Picker \n options={memoizedCompanies} \n value={currentCompany.value} \n onChange={handleCompanyChange}\n aria-label={ariaLabel || 'Select company'}\n aria-describedby=\"company-switcher-description\"\n />\n </div>\n );\n};\n"],"names":["useCompanyData","companies","setCompanies","useState","currentCompany","setCurrentCompany","loadCompanyData","useCallback","companyInfo","CustomerCompanyContext","_a","_b","err","handleCompanyChange","event","companyId","selectedCompany","c","getCompanyHeaderManager","config","groupId","updateCustomerGroup","getGroupHeaderManager","events","clearCompanyContext","handleAuthenticationChange","authenticated","handleCompanyContextRestored","prevCompanies","restoredCompany","company","handleCompanyUpdated","eventData","companyIndex","useEffect","unsubscribeAuth","unsubscribeRestore","unsubscribeCompanyUpdated","_c","CompanySwitcher","ariaLabel","props","isVisible","setIsVisible","memoizedCompanies","useMemo","hidePickerHandler","unsubscribeInitialized","unsubscribeUpdated","jsx","Picker"],"mappings":"uaA6BO,MAAMA,EAAiB,IAA4B,CACxD,KAAM,CAACC,EAAWC,CAAY,EAAIC,EAA0B,CAAA,CAAE,EACxD,CAACC,EAAgBC,CAAiB,EAAIF,EAAwB,CAAE,KAAM,GAAI,MAAO,GAAI,EAMrFG,EAAkBC,EAAY,SAA2B,SAC7D,GAAI,CAEF,MAAMC,EAAmC,MADVC,EAAuB,YAAA,EACgB,uBAAA,EACtEP,EAAaM,EAAY,iBAAiB,GAEtCE,EAAAF,EAAY,iBAAZ,MAAAE,EAA4B,QAAQC,EAAAH,EAAY,iBAAZ,MAAAG,EAA4B,KAClEN,EAAkB,CAChB,KAAMG,EAAY,eAAe,KACjC,MAAOA,EAAY,eAAe,EAAA,CACnC,CAEL,OAASI,EAAK,CACZ,QAAQ,MAAM,+BAAgCA,CAAG,CACnD,CACF,EAAG,CAAA,CAAE,EAKCC,EAAsBN,EAAY,MAAOO,GAAgC,CAE7E,MAAMC,EADSD,EAAM,OACI,MAGnBE,EAAkBf,EAAU,KAAKgB,GAAKA,EAAE,QAAUF,C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ACP,SAAAQ,EAACC,EAAA,CACC,QAASN,EACT,MAAOxC,EAAe,MACtB,SAAUS,EACV,aAAY2B,GAAa,iBACzB,mBAAiB,8BAAA,CAAA,EAErB,CAEJ"}
1
+ {"version":3,"file":"CompanySwitcher.js","sources":["/@dropins/storefront-company-switcher/src/hooks/useCompanyData.ts","/@dropins/storefront-company-switcher/src/containers/CompanySwitcher/CompanySwitcher.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { useState, useCallback, useEffect } from 'preact/hooks';\nimport { events } from '@adobe-commerce/event-bus';\nimport { CustomerCompanyContext, updateCustomerGroup } from '@/company-switcher/api/customerCompanyContext';\nimport type { CompanyOption, CustomerCompanyInfo, UseCompanyDataProps, UseCompanyDataReturn } from '@/company-switcher/types/company';\nimport { config } from '@/company-switcher/api/initialize';\nimport { getGroupHeaderManager } from '@/company-switcher/api/setGroupHeaders';\nimport { getCompanyHeaderManager } from '@/company-switcher/api/setCompanyHeaders';\n\n/**\n * Custom hook that manages company data fetching and state management\n * @returns {UseCompanyDataReturn} Company data and handlers\n */\nexport const useCompanyData = ({ onCompanyChange }: UseCompanyDataProps = {}): UseCompanyDataReturn => {\n const [companies, setCompanies] = useState<CompanyOption[]>([]);\n const [currentCompany, setCurrentCompany] = useState<CompanyOption>({ text: '', value: '' });\n\n\n /**\n * Loads company information from the API and updates state\n */\n const loadCompanyData = useCallback(async (): Promise<void> => {\n try {\n const customerCompanyContext = CustomerCompanyContext.getInstance();\n const companyInfo: CustomerCompanyInfo = await customerCompanyContext.getCustomerCompanyInfo();\n setCompanies(companyInfo.customerCompanies);\n \n if (companyInfo.currentCompany?.name && companyInfo.currentCompany?.id) {\n setCurrentCompany({\n text: companyInfo.currentCompany.name, \n value: companyInfo.currentCompany.id\n });\n }\n } catch (err) {\n console.error('Failed to load company data:', err);\n }\n }, []);\n\n /**\n * Handles company selection change\n */\n const handleCompanyChange = useCallback(async (event: Event): Promise<void> => {\n const target = event.target as HTMLSelectElement;\n const companyId = target.value;\n \n // Update local state\n const selectedCompany = companies.find(c => c.value === companyId);\n if (selectedCompany) {\n setCurrentCompany(selectedCompany);\n }\n \n getCompanyHeaderManager().setCompanyHeaders(companyId);\n if (companyId) {\n sessionStorage.setItem(config.getConfig().companySessionStorageKey, companyId);\n } else {\n sessionStorage.removeItem(config.getConfig().companySessionStorageKey);\n }\n const groupId = await updateCustomerGroup();\n getGroupHeaderManager().setGroupHeaders(groupId);\n if (groupId) {\n sessionStorage.setItem(config.getConfig().groupSessionStorageKey, groupId);\n } else {\n sessionStorage.removeItem(config.getConfig().groupSessionStorageKey);\n }\n\n onCompanyChange?.({ id: companyId, name: selectedCompany?.text || '' });\n\n events.emit('companyContext/changed', companyId);\n }, [companies, onCompanyChange]);\n\n /**\n * Clears company context\n */\n const clearCompanyContext = useCallback((): void => {\n const customerCompanyContext = CustomerCompanyContext.getInstance();\n customerCompanyContext.resetCache();\n setCompanies([]);\n setCurrentCompany({ text: '', value: '' });\n }, []);\n\n /**\n * Handles authentication state changes\n */\n const handleAuthenticationChange = useCallback((authenticated: boolean) => {\n if (authenticated) {\n loadCompanyData();\n } else {\n clearCompanyContext();\n }\n }, [loadCompanyData, clearCompanyContext]);\n\n /**\n * Handles company context restoration\n */\n const handleCompanyContextRestored = useCallback((companyId: string | null) => {\n if (!companyId) {\n clearCompanyContext();\n return;\n }\n // Store the company ID to be restored when companies are loaded\n setCompanies(prevCompanies => {\n const restoredCompany = prevCompanies.find(company => company.value === companyId);\n if (restoredCompany) {\n setCurrentCompany(restoredCompany);\n }\n return prevCompanies;\n });\n }, [clearCompanyContext, setCompanies, setCurrentCompany]);\n\n /**\n * Handles company updated event\n */\n const handleCompanyUpdated = useCallback((eventData: { company: { id: string; name: string; } }) => {\n const { company } = eventData;\n\n setCompanies(prevCompanies => {\n const companyIndex = prevCompanies.findIndex(c => c.value === company.id);\n if (companyIndex === -1) {\n return prevCompanies;\n }\n return prevCompanies.map((c, i) =>\n i === companyIndex ? { ...c, text: company.name } : c\n );\n });\n \n setCurrentCompany({\n text: company.name,\n value: company.id\n });\n }, []);\n\n // Set up event listeners\n useEffect(() => {\n const unsubscribeAuth = events.on('authenticated', handleAuthenticationChange, { eager: true });\n const unsubscribeRestore = events.on('companyContext/changed', handleCompanyContextRestored, { eager: true });\n const unsubscribeCompanyUpdated = events.on('company/updated', handleCompanyUpdated);\n \n return () => {\n unsubscribeAuth?.off?.();\n unsubscribeRestore?.off?.();\n unsubscribeCompanyUpdated?.off?.();\n };\n }, [handleAuthenticationChange, handleCompanyContextRestored, handleCompanyUpdated]);\n\n return {\n companies,\n currentCompany,\n handleCompanyChange\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 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 { useMemo, useState, useEffect } from 'preact/hooks';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Picker } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { useCompanyData } from '@/company-switcher/hooks/useCompanyData';\nimport { Company } from '@/company-switcher/types/company';\n\nexport interface CompanySwitcherProps extends HTMLAttributes<HTMLDivElement> {\n /** Custom aria-label for the picker */\n ariaLabel?: string;\n /** Callback function to be called when the company changes */\n onCompanyChange?: (company: Company) => void;\n}\n\n/**\n * CompanySwitcher component allows users to switch between companies they have access to.\n * It only renders when a user has access to multiple companies.\n * This is a presentational component that uses the useCompanyData hook for all business logic.\n */\nexport const CompanySwitcher: Container<CompanySwitcherProps> = ({ \n ariaLabel,\n onCompanyChange,\n ...props \n}) => {\n const { companies, currentCompany, handleCompanyChange } = useCompanyData({ onCompanyChange });\n const [isVisible, setIsVisible] = useState(true);\n\n // Memoize the companies array to prevent unnecessary re-renders\n const memoizedCompanies = useMemo(() => companies, [companies]);\n\n // Listen for checkout/initialized and checkout/updated events to hide the picker\n useEffect(() => {\n const hidePickerHandler = () => {\n setIsVisible(false);\n };\n\n const unsubscribeInitialized = events.on('checkout/initialized', hidePickerHandler);\n const unsubscribeUpdated = events.on('checkout/updated', hidePickerHandler);\n\n return () => {\n unsubscribeInitialized?.off();\n unsubscribeUpdated?.off();\n };\n }, []);\n\n // Only render if user has access to multiple companies and picker is visible\n if (companies.length < 2 || !isVisible) {\n return null;\n }\n\n return (\n <div {...props}>\n <Picker \n options={memoizedCompanies} \n value={currentCompany.value} \n onChange={handleCompanyChange}\n aria-label={ariaLabel || 'Select company'}\n aria-describedby=\"company-switcher-description\"\n />\n </div>\n );\n};\n"],"names":["useCompanyData","onCompanyChange","companies","setCompanies","useState","currentCompany","setCurrentCompany","loadCompanyData","useCallback","companyInfo","CustomerCompanyContext","_a","_b","err","handleCompanyChange","event","companyId","selectedCompany","c","getCompanyHeaderManager","config","groupId","updateCustomerGroup","getGroupHeaderManager","events","clearCompanyContext","handleAuthenticationChange","authenticated","handleCompanyContextRestored","prevCompanies","restoredCompany","company","handleCompanyUpdated","eventData","companyIndex","i","useEffect","unsubscribeAuth","unsubscribeRestore","unsubscribeCompanyUpdated","_c","CompanySwitcher","ariaLabel","props","isVisible","setIsVisible","memoizedCompanies","useMemo","hidePickerHandler","unsubscribeInitialized","unsubscribeUpdated","jsx","Picker"],"mappings":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AAA,KAAA0B,IACAE,EAAAD,GAAA,YAAAA,EAA2B,MAA3B,MAAAC,EAAA,KAAAD,EACF,CACF,EAAG,CAACb,EAA4BE,EAA8BI,CAAoB,CAAC,EAE5E,CACL,UAAA9B,EACA,eAAAG,EACA,oBAAAS,CAAA,CAEJ,EChIa2B,EAAmD,CAAC,CAC/D,UAAAC,EACA,gBAAAzC,EACA,GAAG0C,CACL,IAAM,CACJ,KAAM,CAAE,UAAAzC,EAAW,eAAAG,EAAgB,oBAAAS,CAAA,EAAwBd,EAAe,CAAE,gBAAAC,EAAiB,EACvF,CAAC2C,EAAWC,CAAY,EAAIzC,EAAS,EAAI,EAGzC0C,EAAoBC,EAAQ,IAAM7C,EAAW,CAACA,CAAS,CAAC,EAkB9D,OAfAkC,EAAU,IAAM,CACd,MAAMY,EAAoB,IAAM,CAC9BH,EAAa,EAAK,CACpB,EAEMI,EAAyBzB,EAAO,GAAG,uBAAwBwB,CAAiB,EAC5EE,EAAqB1B,EAAO,GAAG,mBAAoBwB,CAAiB,EAE1E,MAAO,IAAM,CACXC,GAAA,MAAAA,EAAwB,MACxBC,GAAA,MAAAA,EAAoB,KACtB,CACF,EAAG,CAAA,CAAE,EAGDhD,EAAU,OAAS,GAAK,CAAC0C,EACpB,KAIPO,EAAC,MAAA,CAAK,GAAGR,EACP,SAAAQ,EAACC,EAAA,CACC,QAASN,EACT,MAAOzC,EAAe,MACtB,SAAUS,EACV,aAAY4B,GAAa,iBACzB,mBAAiB,8BAAA,CAAA,EAErB,CAEJ"}
@@ -1,8 +1,8 @@
1
- import { UseCompanyDataReturn } from '../types/company';
1
+ import { UseCompanyDataProps, UseCompanyDataReturn } from '../types/company';
2
2
 
3
3
  /**
4
4
  * Custom hook that manages company data fetching and state management
5
5
  * @returns {UseCompanyDataReturn} Company data and handlers
6
6
  */
7
- export declare const useCompanyData: () => UseCompanyDataReturn;
7
+ export declare const useCompanyData: ({ onCompanyChange }?: UseCompanyDataProps) => UseCompanyDataReturn;
8
8
  //# sourceMappingURL=useCompanyData.d.ts.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-company-switcher", "version": "1.0.6-beta1", "@dropins/tools": "^1.6.0-beta3", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-company-switcher", "version": "1.0.6-beta3", "@dropins/tools": "^1.6.0-beta3", "license": "SEE LICENSE IN LICENSE.md"}
@@ -36,6 +36,12 @@ export interface CustomerCompanyInfo {
36
36
  customerCompanies: CompanyOption[];
37
37
  customerGroupId: string;
38
38
  }
39
+ /**
40
+ * Props for the useCompanyData hook
41
+ */
42
+ export interface UseCompanyDataProps {
43
+ onCompanyChange?: (company: Company) => void;
44
+ }
39
45
  /**
40
46
  * Return type for the useCompanyData hook
41
47
  */