@dropins/storefront-company-switcher 1.2.0 → 1.2.1-beta.0
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/CHANGELOG.md +6 -0
- package/api/customerCompanyContext/customerCompanyContext.d.ts +17 -3
- package/api/customerCompanyContext/graphql/customerCompanyContext.graphql.d.ts +0 -1
- package/api/customerCompanyContext/graphql/customerGroupContext.graphql.d.ts +0 -1
- package/api/customerCompanyContext/index.d.ts +0 -1
- package/api/fetch-graphql/fetch-graphql.d.ts +4 -5
- package/api/fetch-graphql/index.d.ts +0 -1
- package/api/fragments.d.ts +0 -1
- package/api/graphql/CompanyFragment.graphql.d.ts +0 -1
- package/api/graphql/CustomerFragment.graphql.d.ts +0 -1
- package/api/index.d.ts +0 -1
- package/api/initialize/index.d.ts +0 -1
- package/api/initialize/initialize.d.ts +18 -27
- package/api/setCompanyHeaders/index.d.ts +0 -1
- package/api/setCompanyHeaders/setCompanyHeaders.d.ts +17 -3
- package/api/setGroupHeaders/index.d.ts +0 -1
- package/api/setGroupHeaders/setGroupHeaders.d.ts +17 -3
- package/api.d.ts +1 -1
- package/containers/CompanySwitcher/CompanySwitcher.d.ts +17 -3
- package/containers/CompanySwitcher/index.d.ts +0 -1
- package/containers/CompanySwitcher.d.ts +1 -3
- package/containers/CompanySwitcher.js +1 -1
- package/containers/index.d.ts +0 -1
- package/fragments.d.ts +1 -1
- package/hooks/index.d.ts +0 -1
- package/hooks/useCompanyData.d.ts +17 -3
- package/package.json +1 -1
- package/render/Provider.d.ts +16 -2
- package/render/index.d.ts +0 -1
- package/render/render.d.ts +17 -4
- package/render.d.ts +1 -1
- package/types/company.d.ts +0 -1
- package/i18n/en_US.json.d.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
import type { CustomerCompanyInfo } from '../../types/company';
|
|
3
18
|
export declare class CustomerCompanyContext {
|
|
4
19
|
private static instance;
|
|
5
20
|
private readonly EMPTY_CUSTOMER_COMPANY_CONTEXT;
|
|
@@ -38,4 +53,3 @@ export declare class CustomerCompanyContext {
|
|
|
38
53
|
}
|
|
39
54
|
export declare const getCustomerCompanyInfo: (pageSize?: number) => Promise<CustomerCompanyInfo>;
|
|
40
55
|
export declare const updateCustomerGroup: () => Promise<string | null>;
|
|
41
|
-
//# sourceMappingURL=customerCompanyContext.d.ts.map
|
|
@@ -26,15 +26,14 @@ setFetchGraphQlHeader: (key: string, value: string | null) => void,
|
|
|
26
26
|
/** Removes a GraphQL header */
|
|
27
27
|
removeFetchGraphQlHeader: (key: string) => void,
|
|
28
28
|
/** Sets multiple GraphQL headers at once */
|
|
29
|
-
setFetchGraphQlHeaders: (header: import(
|
|
29
|
+
setFetchGraphQlHeaders: (header: import("@adobe-commerce/fetch-graphql").Header | ((prev: import("@adobe-commerce/fetch-graphql").Header) => import("@adobe-commerce/fetch-graphql").Header)) => void,
|
|
30
30
|
/** Executes a GraphQL query or mutation */
|
|
31
|
-
fetchGraphQl: <T = any>(query: string, options?: import(
|
|
32
|
-
errors?: import(
|
|
31
|
+
fetchGraphQl: <T = any>(query: string, options?: import("@adobe-commerce/fetch-graphql").FetchOptions) => Promise<{
|
|
32
|
+
errors?: import("@adobe-commerce/fetch-graphql").FetchQueryError;
|
|
33
33
|
data: T;
|
|
34
34
|
}>,
|
|
35
35
|
/** Gets the current configuration */
|
|
36
36
|
getConfig: () => {
|
|
37
37
|
endpoint: string | undefined;
|
|
38
|
-
fetchGraphQlHeaders: import(
|
|
38
|
+
fetchGraphQlHeaders: import("@adobe-commerce/fetch-graphql").Header;
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=fetch-graphql.d.ts.map
|
package/api/fragments.d.ts
CHANGED
|
@@ -15,4 +15,3 @@
|
|
|
15
15
|
* from Adobe.
|
|
16
16
|
*******************************************************************/
|
|
17
17
|
export declare const CUSTOMER_FRAGMENT = "\n fragment CUSTOMER_FRAGMENT on Customer {\n companies(input: { pageSize: $pageSize }) {\n items {\n name\n id\n status\n }\n }\n }\n";
|
|
18
|
-
//# sourceMappingURL=CustomerFragment.graphql.d.ts.map
|
package/api/index.d.ts
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** Session storage key for persisting group context */
|
|
18
|
-
groupSessionStorageKey: string;
|
|
19
|
-
/** GraphQL modules that will have company headers applied */
|
|
20
|
-
fetchGraphQlModules: FetchGraphQL[];
|
|
21
|
-
/** GraphQL modules that will have group headers applied */
|
|
22
|
-
groupGraphQlModules: FetchGraphQL[];
|
|
23
|
-
}
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
24
17
|
/**
|
|
25
18
|
* Initializer for the company switcher drop-in.
|
|
26
19
|
* Configures headers, storage, and GraphQL modules for company management.
|
|
27
20
|
*/
|
|
28
|
-
export declare const initialize:
|
|
21
|
+
export declare const initialize: any;
|
|
29
22
|
/**
|
|
30
23
|
* Configuration object for getting and setting company switcher configuration.
|
|
31
24
|
* Provides methods to access and update the current configuration.
|
|
32
25
|
*/
|
|
33
|
-
export declare const config:
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=initialize.d.ts.map
|
|
26
|
+
export declare const config: any;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
import type { FetchGraphQL } from '@adobe-commerce/fetch-graphql';
|
|
3
18
|
/**
|
|
4
19
|
* Manages company-specific headers for GraphQL requests.
|
|
5
20
|
* Singleton class that handles setting and removing company headers across multiple GraphQL modules.
|
|
@@ -41,4 +56,3 @@ declare class CompanyHeaderManager {
|
|
|
41
56
|
*/
|
|
42
57
|
export declare const getCompanyHeaderManager: () => CompanyHeaderManager;
|
|
43
58
|
export {};
|
|
44
|
-
//# sourceMappingURL=setCompanyHeaders.d.ts.map
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
import type { FetchGraphQL } from '@adobe-commerce/fetch-graphql';
|
|
3
18
|
/**
|
|
4
19
|
* Manages customer group headers for GraphQL requests.
|
|
5
20
|
* Singleton class that handles setting and removing group headers across multiple GraphQL modules.
|
|
@@ -43,4 +58,3 @@ declare class GroupHeaderManager {
|
|
|
43
58
|
*/
|
|
44
59
|
export declare const getGroupHeaderManager: () => GroupHeaderManager;
|
|
45
60
|
export {};
|
|
46
|
-
//# sourceMappingURL=setGroupHeaders.d.ts.map
|
package/api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './api/index'
|
|
1
|
+
export * from './api/index';
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
1
17
|
import { HTMLAttributes } from 'preact/compat';
|
|
2
|
-
import { Container } from '@dropins/tools/
|
|
18
|
+
import { Container } from '@dropins/tools/lib';
|
|
3
19
|
import { Company } from '../../types/company';
|
|
4
|
-
|
|
5
20
|
export interface CompanySwitcherProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
21
|
/** Custom aria-label for the picker */
|
|
7
22
|
ariaLabel?: string;
|
|
@@ -16,4 +31,3 @@ export interface CompanySwitcherProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
31
|
* This is a presentational component that uses the useCompanyData hook for all business logic.
|
|
17
32
|
*/
|
|
18
33
|
export declare const CompanySwitcher: Container<CompanySwitcherProps>;
|
|
19
|
-
//# sourceMappingURL=CompanySwitcher.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2026 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as I}from"@dropins/tools/preact-jsx-runtime.js";import{useState as v,useCallback as f,useEffect as
|
|
3
|
+
import{jsx as I}from"@dropins/tools/preact-jsx-runtime.js";import{useState as v,useCallback as f,useEffect as w,useMemo as H}from"@dropins/tools/preact-hooks.js";import{Picker as K}from"@dropins/tools/components.js";import{events as d}from"@dropins/tools/event-bus.js";import{CustomerCompanyContext as k,getCompanyHeaderManager as G,config as S,updateCustomerGroup as M,getGroupHeaderManager as D}from"../api.js";import"../fragments.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const P=({onCompanyChange:c,pageSize:C=100}={})=>{const[l,s]=v([]),[y,r]=v({text:"",value:""}),u=f(async()=>{var e,n;try{const o=await k.getInstance().getCustomerCompanyInfo(C);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)}},[C]),h=f(async e=>{const t=e.target.value,o=l.find(p=>p.value===t);o&&r(o),G().setCompanyHeaders(t),t?sessionStorage.setItem(S.getConfig().companySessionStorageKey,t):sessionStorage.removeItem(S.getConfig().companySessionStorageKey);const a=await M();D().setGroupHeaders(a),a?sessionStorage.setItem(S.getConfig().groupSessionStorageKey,a):sessionStorage.removeItem(S.getConfig().groupSessionStorageKey),c==null||c({id:t,name:(o==null?void 0:o.text)||""}),d.emit("companyContext/changed",t)},[l,c]),m=f(()=>{k.getInstance().resetCache(),s([]),r({text:"",value:""})},[]),x=f(e=>{e?u():m()},[u,m]),g=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 w(()=>{const e=d.on("authenticated",x,{eager:!0}),n=d.on("companyContext/changed",g,{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)}},[x,g,i]),{companies:l,currentCompany:y,handleCompanyChange:h}},V=({ariaLabel:c,onCompanyChange:C,size:l=100,...s})=>{const{companies:y,currentCompany:r,handleCompanyChange:u}=P({onCompanyChange:C,pageSize:l}),[h,m]=v(!0),x=H(()=>y,[y]);return w(()=>{const g=()=>{m(!1)},i=d.on("checkout/initialized",g),e=d.on("checkout/updated",g);return()=>{i==null||i.off(),e==null||e.off()}},[]),y.length<2||!h?null:I("div",{...s,children:I(K,{options:x,value:r.value,onChange:u,"aria-label":c||"Select company","aria-describedby":"company-switcher-description"})})};V.displayName="CompanySwitcher";export{V as CompanySwitcher,V as default};
|
|
4
4
|
//# sourceMappingURL=CompanySwitcher.js.map
|
package/containers/index.d.ts
CHANGED
package/fragments.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './api/fragments'
|
|
1
|
+
export * from './api/fragments';
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
17
|
+
import type { UseCompanyDataProps, UseCompanyDataReturn } from '../types/company';
|
|
3
18
|
/**
|
|
4
19
|
* Custom hook that manages company data fetching and state management
|
|
5
20
|
* @returns {UseCompanyDataReturn} Company data and handlers
|
|
6
21
|
*/
|
|
7
22
|
export declare const useCompanyData: ({ onCompanyChange, pageSize }?: UseCompanyDataProps) => UseCompanyDataReturn;
|
|
8
|
-
//# sourceMappingURL=useCompanyData.d.ts.map
|
package/package.json
CHANGED
package/render/Provider.d.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
1
17
|
import { FunctionComponent, ComponentChildren } from 'preact';
|
|
2
|
-
|
|
3
18
|
interface ProviderProps {
|
|
4
19
|
children?: ComponentChildren;
|
|
5
20
|
}
|
|
6
21
|
export declare const Provider: FunctionComponent<ProviderProps>;
|
|
7
22
|
export {};
|
|
8
|
-
//# sourceMappingURL=Provider.d.ts.map
|
package/render/index.d.ts
CHANGED
package/render/render.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2025 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
3
17
|
/**
|
|
4
18
|
* Render instance for the company switcher drop-in.
|
|
5
19
|
* Wraps the Provider component to handle initialization and rendering.
|
|
6
20
|
*/
|
|
7
|
-
export declare const render:
|
|
8
|
-
//# sourceMappingURL=render.d.ts.map
|
|
21
|
+
export declare const render: any;
|
package/render.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './render/index'
|
|
1
|
+
export * from './render/index';
|
package/types/company.d.ts
CHANGED