avada-crossapp-banner 0.0.1

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.
@@ -0,0 +1,413 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as react from 'react';
3
+ import { ReactNode } from 'react';
4
+
5
+ /**
6
+ * App handle identifiers
7
+ */
8
+ type AppHandle = 'cookieBar' | 'ageVerification' | 'accessibility' | 'orderLimit';
9
+ /**
10
+ * App prefix for event tracking
11
+ */
12
+ type AppPrefix = 'cb' | 'av' | 'ac' | 'ol';
13
+ /**
14
+ * Banner event actions
15
+ */
16
+ type BannerEventAction = 'display' | 'close' | 'access';
17
+ /**
18
+ * Target storage type for display banner logic
19
+ */
20
+ type TargetStorageType = 'next_day' | '7_days_after' | '30_days_after';
21
+ /**
22
+ * API client function type
23
+ */
24
+ type ApiClient = (url: string, options?: {
25
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
26
+ body?: Record<string, unknown>;
27
+ }) => Promise<{
28
+ data?: Record<string, unknown>;
29
+ error?: unknown;
30
+ }>;
31
+ /**
32
+ * Store dispatch function type
33
+ */
34
+ type StoreDispatch = (action: unknown) => void;
35
+ /**
36
+ * CrossApp banner configuration
37
+ */
38
+ interface CrossAppConfig {
39
+ /**
40
+ * App prefix for event tracking (e.g., 'cb', 'ol', 'ac')
41
+ */
42
+ appPrefix: AppPrefix;
43
+ /**
44
+ * API client function for making requests
45
+ */
46
+ apiClient: ApiClient;
47
+ /**
48
+ * Store dispatch function for state updates
49
+ */
50
+ storeDispatch?: StoreDispatch;
51
+ /**
52
+ * Custom close icon component
53
+ */
54
+ closeIcon?: ReactNode;
55
+ /**
56
+ * Banner event endpoint
57
+ * @default '/banner-event'
58
+ */
59
+ bannerEventEndpoint?: string;
60
+ /**
61
+ * Shop update endpoint
62
+ * @default '/shop'
63
+ */
64
+ shopUpdateEndpoint?: string;
65
+ }
66
+ /**
67
+ * App data for CrossApp banner
68
+ */
69
+ interface CrossAppData {
70
+ /**
71
+ * App handle identifier
72
+ */
73
+ appHandle: AppHandle;
74
+ /**
75
+ * Translation key prefix for i18n
76
+ */
77
+ translationKey: string;
78
+ /**
79
+ * Target URL for the CTA button
80
+ */
81
+ targetUrl: string;
82
+ /**
83
+ * Whether to show the plan button
84
+ */
85
+ showPlanBtn?: boolean;
86
+ /**
87
+ * URL for the plan button
88
+ */
89
+ planUrl?: string;
90
+ /**
91
+ * Background color for the banner
92
+ */
93
+ bgColor?: string;
94
+ /**
95
+ * Whether the banner should be hidden
96
+ */
97
+ isHideBanner?: boolean;
98
+ /**
99
+ * Event prefix for tracking
100
+ */
101
+ eventPrefix?: string;
102
+ /**
103
+ * LocalStorage key for tracking close count
104
+ */
105
+ bannerCloseKey?: string;
106
+ /**
107
+ * Image URL for the app icon
108
+ */
109
+ imageUrl?: string;
110
+ /**
111
+ * Image alt text
112
+ */
113
+ imageAlt?: string;
114
+ }
115
+ /**
116
+ * CrossApp banner component props
117
+ */
118
+ interface CrossAppBannerProps {
119
+ /**
120
+ * Configuration for the banner
121
+ */
122
+ config: CrossAppConfig;
123
+ /**
124
+ * App data for the banner
125
+ */
126
+ appData: CrossAppData;
127
+ /**
128
+ * Source page for tracking
129
+ */
130
+ sourcePage?: string;
131
+ /**
132
+ * Current shop data
133
+ */
134
+ shop?: Record<string, unknown>;
135
+ /**
136
+ * Callback when banner is closed
137
+ */
138
+ onClose?: () => void;
139
+ /**
140
+ * Callback when shop data needs to be updated
141
+ */
142
+ onShopUpdate?: (shopData: Record<string, unknown>) => void;
143
+ }
144
+ /**
145
+ * useDisplayBanner options
146
+ */
147
+ interface UseDisplayBannerOptions {
148
+ /**
149
+ * Configuration for the banner
150
+ */
151
+ config: CrossAppConfig;
152
+ /**
153
+ * Storage key for tracking display state
154
+ */
155
+ storageKey: string;
156
+ /**
157
+ * Target storage type
158
+ * @default 'next_day'
159
+ */
160
+ targetDateType?: TargetStorageType;
161
+ /**
162
+ * Whether to check storage for display state
163
+ * @default true
164
+ */
165
+ checkStorage?: boolean;
166
+ /**
167
+ * Current shop data
168
+ */
169
+ shop?: Record<string, unknown>;
170
+ /**
171
+ * Callback when banner is closed
172
+ */
173
+ onClose?: () => void;
174
+ }
175
+ /**
176
+ * useDisplayBanner return type
177
+ */
178
+ interface UseDisplayBannerReturn {
179
+ /**
180
+ * Whether the banner should be displayed
181
+ */
182
+ shouldDisplay: boolean;
183
+ /**
184
+ * Hide the banner
185
+ */
186
+ hideBanner: () => void;
187
+ /**
188
+ * Show the banner
189
+ */
190
+ showBanner: () => void;
191
+ /**
192
+ * Handle closing the banner with API call
193
+ */
194
+ handleCloseBanner: (data?: Record<string, unknown>) => Promise<void>;
195
+ }
196
+ /**
197
+ * CrossApp icon props
198
+ */
199
+ interface CrossAppIconProps$1 {
200
+ /**
201
+ * App handle to render icon for
202
+ */
203
+ app: AppHandle;
204
+ /**
205
+ * Icon size
206
+ * @default 48
207
+ */
208
+ size?: number;
209
+ }
210
+
211
+ /**
212
+ * CrossApp Banner Component
213
+ *
214
+ * A reusable banner component for cross-promoting Avada apps.
215
+ * Supports configuration-based customization for different apps.
216
+ */
217
+ declare function CrossAppBanner({ config, appData, sourcePage, shop, onClose, onShopUpdate, }: CrossAppBannerProps): react_jsx_runtime.JSX.Element | null;
218
+
219
+ /**
220
+ * CrossApp Banner Component with i18n support
221
+ *
222
+ * A reusable banner component for cross-promoting Avada apps.
223
+ * Uses @shopify/react-i18n for translations.
224
+ */
225
+ declare function CrossAppBannerWithI18n({ config, appData, sourcePage, shop, onClose, onShopUpdate, }: CrossAppBannerProps): react_jsx_runtime.JSX.Element | null;
226
+
227
+ interface DownloadIconProps {
228
+ width?: number;
229
+ height?: number;
230
+ fill?: string;
231
+ }
232
+ declare function DownloadIcon({ width, height, fill, }: DownloadIconProps): react_jsx_runtime.JSX.Element;
233
+
234
+ interface CrossAppIconProps {
235
+ app: AppHandle;
236
+ size?: number;
237
+ }
238
+ /**
239
+ * CrossApp icon component that renders the appropriate icon based on app handle
240
+ */
241
+ declare function CrossAppIcon({ app, size }: CrossAppIconProps): react_jsx_runtime.JSX.Element;
242
+
243
+ interface UseDisplayBannerConfig {
244
+ /**
245
+ * Storage key for tracking display state
246
+ */
247
+ storageKey: string;
248
+ /**
249
+ * Shop key for tracking dismissed banners per shop
250
+ */
251
+ shopKey?: string;
252
+ /**
253
+ * Current shop data
254
+ */
255
+ shop?: {
256
+ dismissedBanners?: string[];
257
+ [key: string]: unknown;
258
+ };
259
+ /**
260
+ * Whether to check shop dismissed banners
261
+ * @default false
262
+ */
263
+ checkShop?: boolean;
264
+ /**
265
+ * Number of closes before permanently dismissing
266
+ * @default 3
267
+ */
268
+ disableCount?: number;
269
+ /**
270
+ * Target storage type for next display
271
+ * @default 'next_day'
272
+ */
273
+ targetDateType?: TargetStorageType;
274
+ /**
275
+ * API client function for making requests
276
+ */
277
+ apiClient?: (url: string, options?: {
278
+ method?: string;
279
+ body?: Record<string, unknown>;
280
+ }) => Promise<{
281
+ success?: boolean;
282
+ data?: Record<string, unknown>;
283
+ }>;
284
+ /**
285
+ * Endpoint for updating shop data
286
+ * @default '/shops?type=banner'
287
+ */
288
+ shopUpdateEndpoint?: string;
289
+ /**
290
+ * Callback when shop data is updated
291
+ */
292
+ onShopUpdate?: (shopData: Record<string, unknown>) => void;
293
+ /**
294
+ * Callback when banner is closed
295
+ */
296
+ onClose?: () => void;
297
+ /**
298
+ * Whether to check storage for display state
299
+ * @default true
300
+ */
301
+ checkStorage?: boolean;
302
+ }
303
+ /**
304
+ * Hook to manage banner display state with localStorage persistence
305
+ */
306
+ declare function useDisplayBanner({ storageKey, shopKey, shop, checkShop, disableCount, targetDateType, apiClient, shopUpdateEndpoint, onShopUpdate, onClose, checkStorage, }: UseDisplayBannerConfig): UseDisplayBannerReturn;
307
+
308
+ /**
309
+ * App handle constants
310
+ */
311
+ declare const APP_HANDLES: {
312
+ readonly ORDER_LIMIT: AppHandle;
313
+ readonly ACCESSIBILITY: AppHandle;
314
+ readonly COOKIE_BAR: AppHandle;
315
+ readonly AGE_VERIFICATION: AppHandle;
316
+ };
317
+ /**
318
+ * App domains
319
+ */
320
+ declare const APP_DOMAINS: {
321
+ readonly COOKIE_BAR: "cookie.avada.io";
322
+ readonly AGE_VERIFICATION: "age-verification-b0fa4.firebaseapp.com";
323
+ readonly ACCESSIBILITY: "accessibility.avada.io";
324
+ };
325
+ /**
326
+ * Shopify app handles
327
+ */
328
+ declare const SHOPIFY_APP_HANDLES: {
329
+ readonly COOKIE_BAR: "avada-cookie-bar";
330
+ readonly AGE_VERIFICATION: "sun-age-verification-popup";
331
+ readonly ACCESSIBILITY: "avada-accessibility";
332
+ };
333
+ /**
334
+ * Shopify plans to exclude from cross-app promotion
335
+ */
336
+ declare const EXCLUDED_SHOPIFY_PLANS: readonly ["partner_test", "affiliate", "staff", "frozen", "fraudulent", "cancelled", "paused"];
337
+ /**
338
+ * Countries to exclude from cross-app promotion
339
+ */
340
+ declare const EXCLUDED_COUNTRIES: readonly ["IN", "VN"];
341
+ /**
342
+ * Target storage types for display banner
343
+ */
344
+ declare const TARGET_STORAGE_TYPES: Record<string, TargetStorageType>;
345
+ /**
346
+ * Get Shopify store name from domain
347
+ */
348
+ declare function getShopifyName(domain: string): string;
349
+ /**
350
+ * Check if shop should be excluded from cross-app promotion
351
+ */
352
+ declare function shouldExcludeShop(shop: {
353
+ shopifyPlan?: string;
354
+ country?: string;
355
+ email?: string;
356
+ }): boolean;
357
+ /**
358
+ * Get Cookie Bar app data for cross-app promotion
359
+ */
360
+ declare function getCookieBarAppData(shop: {
361
+ shopifyDomain: string;
362
+ cookieBarInstalled?: boolean;
363
+ }, options?: {
364
+ showPlanBtn?: boolean;
365
+ eventPrefix?: string;
366
+ }): CrossAppData;
367
+ /**
368
+ * Get Age Verification app data for cross-app promotion
369
+ */
370
+ declare function getAgeVerificationAppData(shop: {
371
+ shopifyDomain: string;
372
+ ageVerificationInstalled?: boolean;
373
+ hideVerificationBanner?: boolean;
374
+ }, options?: {
375
+ eventPrefix?: string;
376
+ utmSource?: string;
377
+ }): CrossAppData;
378
+ /**
379
+ * Get Accessibility app data for cross-app promotion
380
+ */
381
+ declare function getAccessibilityAppData(shop: {
382
+ shopifyDomain: string;
383
+ accessibilityInstalled?: boolean;
384
+ }, options?: {
385
+ eventPrefix?: string;
386
+ }): CrossAppData;
387
+ /**
388
+ * Create cross-app config helper
389
+ */
390
+ declare function createCrossAppConfig(config: {
391
+ appPrefix: 'cb' | 'av' | 'ac' | 'ol';
392
+ apiClient: (url: string, options?: {
393
+ method?: string;
394
+ body?: Record<string, unknown>;
395
+ }) => Promise<unknown>;
396
+ storeDispatch?: (action: unknown) => void;
397
+ closeIcon?: React.ReactNode;
398
+ bannerEventEndpoint?: string;
399
+ shopUpdateEndpoint?: string;
400
+ }): {
401
+ appPrefix: "cb" | "av" | "ac" | "ol";
402
+ apiClient: (url: string, options?: {
403
+ method?: string;
404
+ body?: Record<string, unknown>;
405
+ }) => Promise<unknown>;
406
+ storeDispatch: ((action: unknown) => void) | undefined;
407
+ closeIcon: react.ReactNode;
408
+ bannerEventEndpoint: string;
409
+ shopUpdateEndpoint: string;
410
+ };
411
+
412
+ export { APP_DOMAINS, APP_HANDLES, CrossAppBanner, CrossAppBannerWithI18n, CrossAppIcon, DownloadIcon, EXCLUDED_COUNTRIES, EXCLUDED_SHOPIFY_PLANS, SHOPIFY_APP_HANDLES, TARGET_STORAGE_TYPES, createCrossAppConfig, CrossAppBanner as default, getAccessibilityAppData, getAgeVerificationAppData, getCookieBarAppData, getShopifyName, shouldExcludeShop, useDisplayBanner };
413
+ export type { ApiClient, AppHandle, AppPrefix, BannerEventAction, CrossAppBannerProps, CrossAppConfig, CrossAppData, CrossAppIconProps$1 as CrossAppIconProps, StoreDispatch, TargetStorageType, UseDisplayBannerConfig, UseDisplayBannerOptions, UseDisplayBannerReturn };