@commercelayer/app-elements 1.14.5 → 1.15.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/dist/main.d.ts CHANGED
@@ -17,6 +17,7 @@ export { CoreSdkProvider, useCoreApi, useCoreSdkProvider } from './providers/Cor
17
17
  export { ErrorBoundary } from './providers/ErrorBoundary';
18
18
  export { GTMProvider, useTagManager } from './providers/GTMProvider';
19
19
  export { MetaTags, TokenProvider, useTokenProvider, type TokenProviderAllowedApp, type TokenProviderPermissionItem, type TokenProviderRoleActions, type TokenProviderRolePermissions, type TokenProviderTokenApplicationKind } from './providers/TokenProvider';
20
+ export { createApp, type ClAppProps } from './providers/createApp';
20
21
  export { A, type AProps } from './ui/atoms/A';
21
22
  export { Alert, type AlertProps } from './ui/atoms/Alert';
22
23
  export { Avatar, type AvatarProps } from './ui/atoms/Avatar';
@@ -56,6 +57,7 @@ export { Tooltip, type TooltipProps, type TooltipRefProps } from './ui/atoms/Too
56
57
  export { ActionButtons, type ActionButtonsProps } from './ui/composite/ActionButtons';
57
58
  export { CardDialog, type CardDialogProps } from './ui/composite/CardDialog';
58
59
  export { Dropdown, DropdownDivider, DropdownItem, DropdownSearch, type DropdownDividerProps, type DropdownItemProps, type DropdownProps, type DropdownSearchProps } from './ui/composite/Dropdown';
60
+ export { HomePageLayout, type HomePageLayoutProps } from './ui/composite/HomePageLayout';
59
61
  export { List, type ListProps } from './ui/composite/List';
60
62
  export { ListDetails, type ListDetailsProps } from './ui/composite/ListDetails';
61
63
  export { ListDetailsItem, type ListDetailsItemProps } from './ui/composite/ListDetailsItem';
package/dist/main.js CHANGED
@@ -1,180 +1,176 @@
1
1
  "use client";
2
- import { a1 as i, aH as p, a2 as l, a3 as b, a4 as d, a5 as c, a6 as g, a7 as m, a8 as S, a9 as I, aa as k, aI as T, ab as D, ac as R, T as h, aJ as y, aK as C, aL as H, aM as P, ad as A, W as f, Y as B, ae as F, af as v, aY as N, aZ as L, a$ as O, b1 as G, b3 as w, b7 as V, b9 as x, be as E, bh as M, bj as W, bq as J, bs as U, bu as q, bw as z, by as K, bC as Q, bD as Y, ag as Z, ah as _, a_ as $, b0 as j, b2 as X, b4 as aa, b6 as ea, b8 as sa, ba as ta, bb as oa, bc as ra, bd as na, bf as ua, bg as ia, bi as pa, bk as la, br as ba, bt as da, bv as ca, bx as ga, bz as ma, bA as Sa, bB as Ia, aN as ka, aO as Ta, aP as Da, aQ as Ra, _ as ha, aR as ya, ai as Ca, aS as Ha, aT as Pa, aj as Aa, ak as fa, al as Ba, am as Fa, aU as va, bG as Na, bH as La, bI as Oa, bJ as Ga, bK as wa, bL as Va, bM as xa, bN as Ea, an as Ma, aV as Wa, ao as Ja, ap as Ua, aq as qa, ar as za, at as Ka, au as Qa, av as Ya, aw as Za, ax as _a, aC as $a, ay as ja, aW as Xa, aD as ae, aE as ee, az as se, aF as te, aA as oe, aX as re, $ as ne, aG as ue, aB as ie, z as pe, C as le, D as be, k as de, y as ce, bl as ge, b5 as me, l as Se, m as Ie, q as ke, A as Te, B as De, E as Re, bP as he, bQ as ye, bm as Ce, s as He, t as Pe, u as Ae, bR as fe, bS as Be, bT as Fe, bU as ve, bV as Ne, F as Le, G as Oe, bW as Ge, bX as we, bY as Ve, bZ as xe, H as Ee, J as Me, b_ as We, b$ as Je, c0 as Ue, M as qe, N as ze, e as Ke, K as Qe, L as Ye, h as Ze, bn as _e, bo as $e, bp as je, n as Xe, r as as, bE as es, v as ss, x as ts, O as os, U as rs, V as ns, P as us, Q as is, R as ps, S as ls, bO as bs, Z as ds, a0 as cs, bF as gs, as as ms } from "./main-TnhZckKL.js";
3
- import "react";
4
- import "react-dom";
5
- import "@commercelayer/sdk";
6
- import "react-gtm-module";
7
- import "react-hook-form";
8
- import "query-string";
2
+ import { a2 as s, aI as t, a3 as o, a4 as r, a5 as n, a6 as u, a7 as i, a8 as p, a9 as l, aa as b, ab as c, aJ as d, ac as g, ad as S, T as m, aK as I, aL as k, aM as T, aN as D, ae as R, W as y, Y as h, af as C, ag as H, aO as P, a_ as A, a$ as f, b1 as B, b3 as F, b5 as v, b9 as L, bb as N, bg as O, bj as G, bl as w, bs as V, bu as x, bw as E, by as M, bA as W, bE as J, bF as U, ah as q, ai as z, b0 as K, b2 as Q, b4 as Y, b6 as Z, b8 as _, ba as $, bc as j, bd as X, be as aa, bf as ea, bh as sa, bi as ta, bk as oa, bm as ra, bt as na, bv as ua, bx as ia, bz as pa, bB as la, bC as ba, bD as ca, aP as da, aQ as ga, aR as Sa, aS as ma, _ as Ia, aT as ka, aj as Ta, aU as Da, aV as Ra, ak as ya, al as ha, am as Ca, an as Ha, aW as Pa, bI as Aa, bJ as fa, bK as Ba, bL as Fa, bM as va, bN as La, bO as Na, bP as Oa, ao as Ga, aX as wa, ap as Va, aq as xa, ar as Ea, as as Ma, au as Wa, av as Ja, aw as Ua, ax as qa, ay as za, aD as Ka, az as Qa, aY as Ya, aE as Za, aF as _a, aA as $a, aG as ja, aB as Xa, aZ as ae, $ as ee, aH as se, aC as te, z as oe, a1 as re, C as ne, D as ue, k as ie, y as pe, bn as le, b7 as be, l as ce, m as de, q as ge, A as Se, B as me, E as Ie, bR as ke, bS as Te, bo as De, s as Re, t as ye, u as he, bT as Ce, bU as He, bV as Pe, bW as Ae, bX as fe, F as Be, G as Fe, bY as ve, bZ as Le, b_ as Ne, b$ as Oe, H as Ge, J as we, c0 as Ve, c1 as xe, c2 as Ee, M as Me, N as We, e as Je, K as Ue, L as qe, h as ze, bp as Ke, bq as Qe, br as Ye, n as Ze, r as _e, bG as $e, v as je, x as Xe, O as as, U as es, V as ss, P as ts, Q as os, R as rs, S as ns, bQ as us, Z as is, a0 as ps, bH as ls, at as bs } from "./main-B_P2rWFk.js";
9
3
  export {
10
- i as A,
11
- p as ActionButtons,
12
- l as Alert,
13
- b as Avatar,
14
- d as AvatarLetter,
15
- c as Badge,
16
- g as Button,
17
- m as ButtonCard,
18
- S as ButtonFilter,
19
- I as ButtonImageSelect,
20
- k as Card,
21
- T as CardDialog,
22
- D as Container,
23
- R as CopyToClipboard,
24
- h as CoreSdkProvider,
25
- y as Dropdown,
26
- C as DropdownDivider,
27
- H as DropdownItem,
28
- P as DropdownSearch,
29
- A as EmptyState,
30
- f as ErrorBoundary,
31
- B as GTMProvider,
32
- F as Grid,
33
- v as Hint,
34
- N as HookedForm,
35
- L as HookedInput,
36
- O as HookedInputCheckbox,
37
- G as HookedInputCheckboxGroup,
38
- w as HookedInputCurrency,
39
- V as HookedInputDate,
40
- x as HookedInputDateRange,
41
- E as HookedInputRadioGroup,
42
- M as HookedInputResourceGroup,
43
- W as HookedInputSelect,
44
- J as HookedInputSimpleSelect,
45
- U as HookedInputSpinner,
46
- q as HookedInputSwitch,
47
- z as HookedInputTextArea,
48
- K as HookedInputToggleButton,
49
- Q as HookedValidationApiError,
50
- Y as HookedValidationError,
51
- Z as Hr,
52
- _ as Icon,
53
- $ as Input,
54
- j as InputCheckbox,
55
- X as InputCheckboxGroup,
56
- aa as InputCurrency,
57
- ea as InputCurrencyRange,
58
- sa as InputDate,
59
- ta as InputDateRange,
60
- oa as InputFeedback,
61
- ra as InputFile,
62
- na as InputJson,
63
- ua as InputRadioGroup,
64
- ia as InputReadonly,
65
- pa as InputResourceGroup,
66
- la as InputSelect,
67
- ba as InputSimpleSelect,
68
- da as InputSpinner,
69
- ca as InputSwitch,
70
- ga as InputTextArea,
71
- ma as InputToggleButton,
72
- Sa as Label,
73
- Ia as Legend,
74
- ka as List,
75
- Ta as ListDetails,
76
- Da as ListDetailsItem,
77
- Ra as ListItem,
78
- ha as MetaTags,
79
- ya as PageError,
80
- Ca as PageHeading,
81
- Ha as PageLayout,
82
- Pa as PageSkeleton,
83
- Aa as Pagination,
84
- fa as Progress,
85
- Ba as RadialProgress,
86
- Fa as RemoveButton,
87
- va as Report,
88
- Na as ResourceAddress,
89
- La as ResourceLineItems,
90
- Oa as ResourceList,
91
- Ga as ResourceListItem,
92
- wa as ResourceMetadata,
93
- Va as ResourceOrderTimeline,
94
- xa as ResourceShipmentParcels,
95
- Ea as ResourceTags,
96
- Ma as ScrollToTop,
97
- Wa as SearchBar,
98
- Ja as Section,
99
- Ua as Skeleton,
100
- qa as SkeletonItem,
101
- za as SkeletonTemplate,
102
- Ka as Spacer,
103
- Qa as Stack,
104
- Ya as StatusDot,
105
- Za as StatusIcon,
106
- _a as Steps,
107
- $a as Tab,
108
- ja as Table,
109
- Xa as TableData,
110
- ae as Tabs,
111
- ee as Tag,
112
- se as Td,
113
- te as Text,
114
- oe as Th,
115
- re as Timeline,
116
- ne as TokenProvider,
117
- ue as Tooltip,
118
- ie as Tr,
119
- pe as computeFullname,
120
- le as createRoute,
121
- be as createTypedRoute,
122
- de as currencies,
123
- ce as downloadJsonAsFile,
124
- ge as flatSelectValues,
125
- me as formatCentsToCurrency,
126
- Se as formatDate,
127
- Ie as formatDateRange,
128
- ke as formatDateWithPredicate,
129
- Te as formatDisplayName,
130
- De as formatResourceName,
131
- Re as getAvatarSrcFromRate,
132
- he as getCustomerDisplayStatus,
133
- ye as getCustomerStatusName,
134
- Ce as getDefaultValueFromFlatten,
135
- He as getEventDateInfo,
136
- Pe as getIsoDateAtDayEdge,
137
- Ae as getIsoDateAtDaysBefore,
138
- fe as getOrderDisplayStatus,
139
- Be as getOrderFulfillmentStatusName,
140
- Fe as getOrderPaymentStatusName,
141
- ve as getOrderStatusName,
142
- Ne as getOrderTransactionName,
143
- Le as getParcelTrackingDetail,
144
- Oe as getParcelTrackingDetails,
145
- Ge as getPromotionDisplayStatus,
146
- we as getReturnDisplayStatus,
147
- Ve as getReturnStatusName,
148
- xe as getShipmentDisplayStatus,
149
- Ee as getShipmentRate,
150
- Me as getShipmentRates,
151
- We as getShipmentStatusName,
152
- Je as getStockTransferDisplayStatus,
153
- Ue as getStockTransferStatusName,
154
- qe as getUnitOfWeightName,
155
- ze as getUnitsOfWeightForSelect,
156
- Ke as goBack,
157
- Qe as hasBeenPurchased,
158
- Ye as hasSingleTracking,
159
- Ze as isAttachmentValidNote,
160
- _e as isGroupedSelectValues,
161
- $e as isMultiValueSelected,
162
- je as isSingleValueSelected,
163
- Xe as navigateTo,
164
- as as referenceOrigins,
165
- es as setApiFormErrors,
166
- ss as sortAndGroupByDate,
167
- ts as timeSeparator,
168
- os as useClickAway,
169
- rs as useCoreApi,
170
- ns as useCoreSdkProvider,
171
- us as useDelayShow,
172
- is as useIsChanged,
173
- ps as useOnBlurFromContainer,
174
- ls as useOverlay,
175
- bs as useResourceFilters,
176
- ds as useTagManager,
177
- cs as useTokenProvider,
178
- gs as useValidationFeedback,
179
- ms as withSkeletonTemplate
4
+ s as A,
5
+ t as ActionButtons,
6
+ o as Alert,
7
+ r as Avatar,
8
+ n as AvatarLetter,
9
+ u as Badge,
10
+ i as Button,
11
+ p as ButtonCard,
12
+ l as ButtonFilter,
13
+ b as ButtonImageSelect,
14
+ c as Card,
15
+ d as CardDialog,
16
+ g as Container,
17
+ S as CopyToClipboard,
18
+ m as CoreSdkProvider,
19
+ I as Dropdown,
20
+ k as DropdownDivider,
21
+ T as DropdownItem,
22
+ D as DropdownSearch,
23
+ R as EmptyState,
24
+ y as ErrorBoundary,
25
+ h as GTMProvider,
26
+ C as Grid,
27
+ H as Hint,
28
+ P as HomePageLayout,
29
+ A as HookedForm,
30
+ f as HookedInput,
31
+ B as HookedInputCheckbox,
32
+ F as HookedInputCheckboxGroup,
33
+ v as HookedInputCurrency,
34
+ L as HookedInputDate,
35
+ N as HookedInputDateRange,
36
+ O as HookedInputRadioGroup,
37
+ G as HookedInputResourceGroup,
38
+ w as HookedInputSelect,
39
+ V as HookedInputSimpleSelect,
40
+ x as HookedInputSpinner,
41
+ E as HookedInputSwitch,
42
+ M as HookedInputTextArea,
43
+ W as HookedInputToggleButton,
44
+ J as HookedValidationApiError,
45
+ U as HookedValidationError,
46
+ q as Hr,
47
+ z as Icon,
48
+ K as Input,
49
+ Q as InputCheckbox,
50
+ Y as InputCheckboxGroup,
51
+ Z as InputCurrency,
52
+ _ as InputCurrencyRange,
53
+ $ as InputDate,
54
+ j as InputDateRange,
55
+ X as InputFeedback,
56
+ aa as InputFile,
57
+ ea as InputJson,
58
+ sa as InputRadioGroup,
59
+ ta as InputReadonly,
60
+ oa as InputResourceGroup,
61
+ ra as InputSelect,
62
+ na as InputSimpleSelect,
63
+ ua as InputSpinner,
64
+ ia as InputSwitch,
65
+ pa as InputTextArea,
66
+ la as InputToggleButton,
67
+ ba as Label,
68
+ ca as Legend,
69
+ da as List,
70
+ ga as ListDetails,
71
+ Sa as ListDetailsItem,
72
+ ma as ListItem,
73
+ Ia as MetaTags,
74
+ ka as PageError,
75
+ Ta as PageHeading,
76
+ Da as PageLayout,
77
+ Ra as PageSkeleton,
78
+ ya as Pagination,
79
+ ha as Progress,
80
+ Ca as RadialProgress,
81
+ Ha as RemoveButton,
82
+ Pa as Report,
83
+ Aa as ResourceAddress,
84
+ fa as ResourceLineItems,
85
+ Ba as ResourceList,
86
+ Fa as ResourceListItem,
87
+ va as ResourceMetadata,
88
+ La as ResourceOrderTimeline,
89
+ Na as ResourceShipmentParcels,
90
+ Oa as ResourceTags,
91
+ Ga as ScrollToTop,
92
+ wa as SearchBar,
93
+ Va as Section,
94
+ xa as Skeleton,
95
+ Ea as SkeletonItem,
96
+ Ma as SkeletonTemplate,
97
+ Wa as Spacer,
98
+ Ja as Stack,
99
+ Ua as StatusDot,
100
+ qa as StatusIcon,
101
+ za as Steps,
102
+ Ka as Tab,
103
+ Qa as Table,
104
+ Ya as TableData,
105
+ Za as Tabs,
106
+ _a as Tag,
107
+ $a as Td,
108
+ ja as Text,
109
+ Xa as Th,
110
+ ae as Timeline,
111
+ ee as TokenProvider,
112
+ se as Tooltip,
113
+ te as Tr,
114
+ oe as computeFullname,
115
+ re as createApp,
116
+ ne as createRoute,
117
+ ue as createTypedRoute,
118
+ ie as currencies,
119
+ pe as downloadJsonAsFile,
120
+ le as flatSelectValues,
121
+ be as formatCentsToCurrency,
122
+ ce as formatDate,
123
+ de as formatDateRange,
124
+ ge as formatDateWithPredicate,
125
+ Se as formatDisplayName,
126
+ me as formatResourceName,
127
+ Ie as getAvatarSrcFromRate,
128
+ ke as getCustomerDisplayStatus,
129
+ Te as getCustomerStatusName,
130
+ De as getDefaultValueFromFlatten,
131
+ Re as getEventDateInfo,
132
+ ye as getIsoDateAtDayEdge,
133
+ he as getIsoDateAtDaysBefore,
134
+ Ce as getOrderDisplayStatus,
135
+ He as getOrderFulfillmentStatusName,
136
+ Pe as getOrderPaymentStatusName,
137
+ Ae as getOrderStatusName,
138
+ fe as getOrderTransactionName,
139
+ Be as getParcelTrackingDetail,
140
+ Fe as getParcelTrackingDetails,
141
+ ve as getPromotionDisplayStatus,
142
+ Le as getReturnDisplayStatus,
143
+ Ne as getReturnStatusName,
144
+ Oe as getShipmentDisplayStatus,
145
+ Ge as getShipmentRate,
146
+ we as getShipmentRates,
147
+ Ve as getShipmentStatusName,
148
+ xe as getStockTransferDisplayStatus,
149
+ Ee as getStockTransferStatusName,
150
+ Me as getUnitOfWeightName,
151
+ We as getUnitsOfWeightForSelect,
152
+ Je as goBack,
153
+ Ue as hasBeenPurchased,
154
+ qe as hasSingleTracking,
155
+ ze as isAttachmentValidNote,
156
+ Ke as isGroupedSelectValues,
157
+ Qe as isMultiValueSelected,
158
+ Ye as isSingleValueSelected,
159
+ Ze as navigateTo,
160
+ _e as referenceOrigins,
161
+ $e as setApiFormErrors,
162
+ je as sortAndGroupByDate,
163
+ Xe as timeSeparator,
164
+ as as useClickAway,
165
+ es as useCoreApi,
166
+ ss as useCoreSdkProvider,
167
+ ts as useDelayShow,
168
+ os as useIsChanged,
169
+ rs as useOnBlurFromContainer,
170
+ ns as useOverlay,
171
+ us as useResourceFilters,
172
+ is as useTagManager,
173
+ ps as useTokenProvider,
174
+ ls as useValidationFeedback,
175
+ bs as withSkeletonTemplate
180
176
  };
@@ -1 +1 @@
1
- export declare const server: import("msw/lib/node").SetupServer;
1
+ export declare const server: import("msw/lib/node").SetupServerApi;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { type TokenProviderProps } from './TokenProvider';
3
- export declare function MockTokenProvider({ children }: TokenProviderProps): JSX.Element;
3
+ export declare function MockTokenProvider({ children, isInDashboard, onAppClose }: TokenProviderProps): JSX.Element;
4
4
  export declare namespace MockTokenProvider {
5
5
  var displayName: string;
6
6
  }
@@ -4,7 +4,6 @@ import { type ListableResourceType } from '@commercelayer/sdk/lib/cjs/api';
4
4
  import { type ReactNode } from 'react';
5
5
  import { type TokenProviderAllowedApp, type TokenProviderAuthSettings, type TokenProviderAuthUser, type TokenProviderRoleActions } from './types';
6
6
  export interface TokenProviderValue {
7
- dashboardUrl?: string;
8
7
  settings: TokenProviderAuthSettings;
9
8
  user: TokenProviderAuthUser | null;
10
9
  organization: Organization | null;
@@ -65,6 +64,17 @@ export interface TokenProviderProps {
65
64
  * When `undefined` (default scenario), the token is expected to be retrieved from the `?accessToken=xxxx` query string or localStorage (in this order).
66
65
  */
67
66
  accessToken?: string;
67
+ /**
68
+ * Optional. Set to `true` to enable the app to be used within the dashboard.
69
+ * In this way the UI can be adapted.
70
+ */
71
+ isInDashboard?: boolean;
72
+ /**
73
+ * Optional. Define a callback to be invoked when the app is closed.
74
+ * When this is defined, it means the app is running as micro-frontend (eg: initialized from the dashboard, that needs to handle the go back).
75
+ * This methods will also be returned within the context as part of `TokenProviderValue` object.
76
+ */
77
+ onAppClose?: () => void;
68
78
  }
69
79
  export declare const AuthContext: import("react").Context<TokenProviderValue>;
70
80
  export declare const useTokenProvider: () => TokenProviderValue;
@@ -3,7 +3,6 @@ import { type Organization } from '@commercelayer/sdk';
3
3
  import { type TokenProviderAuthSettings, type TokenProviderAuthUser, type TokenProviderRolePermissions } from './types';
4
4
  interface TokenProviderInternalState {
5
5
  validAuthToken?: string;
6
- dashboardUrl: string;
7
6
  isLoading: boolean;
8
7
  isTokenError: boolean;
9
8
  rolePermissions: TokenProviderRolePermissions;
@@ -1,5 +1,5 @@
1
1
  import { type ListableResourceType } from '@commercelayer/sdk/lib/cjs/api';
2
- export type TokenProviderAllowedApp = 'bundles' | 'customers' | 'exports' | 'gift_cards' | 'imports' | 'inventory' | 'orders' | 'price_lists' | 'promotions' | 'returns' | 'shipments' | 'skus' | 'stock_transfers' | 'subscriptions' | 'tags' | 'webhooks' | 'dashboard';
2
+ export type TokenProviderAllowedApp = 'bundles' | 'customers' | 'exports' | 'gift_cards' | 'imports' | 'inventory' | 'orders' | 'price_lists' | 'promotions' | 'returns' | 'shipments' | 'sku_lists' | 'skus' | 'stock_transfers' | 'subscriptions' | 'tags' | 'webhooks' | 'dashboard';
3
3
  export type TokenProviderTokenApplicationKind = 'integration' | 'sales_channel' | 'webapp' | 'resources' | TokenProviderAllowedApp;
4
4
  export type TokenProviderRoleActions = 'create' | 'destroy' | 'read' | 'update';
5
5
  export type TokenProviderPermissionItem = Record<TokenProviderRoleActions, boolean>;
@@ -73,11 +73,40 @@ export interface TokenProviderTokenInfo {
73
73
  }
74
74
  export type Mode = 'live' | 'test';
75
75
  export interface TokenProviderAuthSettings {
76
+ /**
77
+ * Access token that is being used to authenticate Core API requests.
78
+ */
76
79
  accessToken: string;
80
+ /**
81
+ * Domain used for Core API requests.
82
+ */
83
+ domain: string;
84
+ /**
85
+ * Current organization slug.
86
+ */
77
87
  organizationSlug: string;
88
+ /**
89
+ * Current app slug.
90
+ */
78
91
  appSlug: string;
79
- domain: string;
92
+ /**
93
+ * Current mode (live or test)
94
+ */
80
95
  mode: Mode;
96
+ /**
97
+ * URL of the dashboard (eg: `https://your-org-slug.commercelayer.io`)
98
+ */
99
+ dashboardUrl: string;
100
+ /**
101
+ * When `true` it means that the app has been initialized from the Dashboard.
102
+ * Useful when is needed to tweak some UI elements.
103
+ */
104
+ isInDashboard: boolean;
105
+ /**
106
+ * Optional callback available within the TokenProvider context to be invoked when the app is closed.
107
+ * This is defined only if it has been declared when TokenProvider has been initialized.
108
+ */
109
+ onAppClose?: () => void;
81
110
  }
82
111
  export interface TokenProviderAuthUser {
83
112
  id: string;
@@ -0,0 +1,57 @@
1
+ import { type FC } from 'react';
2
+ import { type Root } from 'react-dom/client';
3
+ declare global {
4
+ interface Window {
5
+ clAppConfig: {
6
+ /**
7
+ * Specific domain to use for Commerce Layer API requests.
8
+ * It must be set as `commercelayer.io`.
9
+ */
10
+ domain: string;
11
+ /**
12
+ * Enable Google Tag Manager for the provided GTM ID.
13
+ */
14
+ gtmId?: string;
15
+ };
16
+ /**
17
+ * Method to mount the React application in the provider `node` with the set of options passed as `props`.
18
+ */
19
+ clApp?: {
20
+ init: (node?: HTMLElement, props?: ClAppProps) => Root | undefined;
21
+ };
22
+ }
23
+ }
24
+ export interface ClAppProps {
25
+ /**
26
+ * Base path for internal routing.
27
+ * Example: `my-app` if you want to serve the app at `https://my-domain.com/my-app/`.
28
+ */
29
+ routerBase?: string;
30
+ /**
31
+ * Organization slug to use for Commerce Layer API requests.
32
+ */
33
+ organizationSlug?: string;
34
+ /**
35
+ * Callback to be called when the user is not authenticated or the token is invalid/expired.
36
+ */
37
+ onInvalidAuth?: () => void;
38
+ /**
39
+ * Callback to be called when the app is closed (when go-back button from the app home page is clicked)
40
+ */
41
+ onAppClose?: () => void;
42
+ /**
43
+ * Handle some UI elements to be hidden when the app is loaded in the dashboard.
44
+ */
45
+ isInDashboard?: boolean;
46
+ /**
47
+ * Domain used for Core API requests
48
+ * @default 'commercelayer.io'
49
+ */
50
+ domain?: string;
51
+ }
52
+ /**
53
+ * Create a new app instance by adding the `clApp` methods into the global `window` object.
54
+ * The React application will them be mounted into the provided `node` element, when the `init` method is called.
55
+ * @param children - The root component of the app.
56
+ **/
57
+ export declare function createApp(children: FC<ClAppProps>): void;