@salla.sa/embedded-sdk 0.1.0-beta.11 → 0.1.0-beta.2
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/README.md +244 -36
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +378 -535
- package/dist/esm/index.js.map +1 -1
- package/dist/system/index.js +3 -3
- package/dist/system/index.js.map +1 -1
- package/dist/types/index.d.ts +117 -558
- package/dist/umd/index.js +3 -3
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -1,107 +1,42 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Callback for action button clicks.
|
|
3
|
-
*/
|
|
4
|
-
declare type ActionClickCallback = (url?: string, value?: string) => void;
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Auth module interface.
|
|
8
3
|
*/
|
|
9
4
|
export declare interface AuthModule {
|
|
10
5
|
/**
|
|
11
|
-
* Get the
|
|
12
|
-
* The token
|
|
13
|
-
* @returns The token string or null if not present
|
|
6
|
+
* Get the current access token.
|
|
7
|
+
* @returns The access token or undefined if not authenticated
|
|
14
8
|
*/
|
|
15
|
-
|
|
9
|
+
getAccessToken(): string | undefined;
|
|
16
10
|
/**
|
|
17
|
-
*
|
|
18
|
-
* The app ID is passed to the iframe via ?app_id=XXX
|
|
19
|
-
* @returns The app ID string or null if not present
|
|
11
|
+
* Check if the SDK is authenticated.
|
|
20
12
|
*/
|
|
21
|
-
|
|
13
|
+
isAuthenticated(): boolean;
|
|
22
14
|
/**
|
|
23
|
-
*
|
|
24
|
-
* This will re-render the iframe with a new token URL.
|
|
15
|
+
* Get the current store ID.
|
|
25
16
|
*/
|
|
26
|
-
|
|
17
|
+
getStoreId(): number | undefined;
|
|
27
18
|
/**
|
|
28
|
-
*
|
|
29
|
-
* This method verifies the token and returns token information.
|
|
30
|
-
*
|
|
31
|
-
* @param options - Optional params (appId, token, refreshOnError); auto extracted from URL if not provided.
|
|
32
|
-
* @returns Promise with introspect result.
|
|
33
|
-
* @throws {Error} If required params missing.
|
|
19
|
+
* Get the current user ID.
|
|
34
20
|
*/
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Checkout module interface.
|
|
40
|
-
*/
|
|
41
|
-
export declare interface CheckoutModule {
|
|
21
|
+
getUserId(): number | undefined;
|
|
42
22
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @param payload - Checkout data
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* embedded.checkout.create({
|
|
50
|
-
* items: [{ productId: 123, quantity: 1 }],
|
|
51
|
-
* amount: 99.99,
|
|
52
|
-
* currency: 'SAR'
|
|
53
|
-
* });
|
|
54
|
-
* ```
|
|
23
|
+
* Get the merchant plan.
|
|
55
24
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
/**
|
|
63
|
-
* Checkout payload structure.
|
|
64
|
-
*/
|
|
65
|
-
export declare interface CheckoutPayload {
|
|
66
|
-
/** Cart items or product IDs */
|
|
67
|
-
items?: unknown[];
|
|
68
|
-
/** Total amount */
|
|
69
|
-
amount?: number;
|
|
70
|
-
/** Currency code */
|
|
71
|
-
currency?: string;
|
|
72
|
-
/** Additional checkout data */
|
|
73
|
-
[key: string]: unknown;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Confirm dialog options.
|
|
78
|
-
*/
|
|
79
|
-
export declare interface ConfirmOptions {
|
|
80
|
-
/** Dialog title */
|
|
81
|
-
title: string;
|
|
82
|
-
/** Dialog message/body */
|
|
83
|
-
message: string;
|
|
84
|
-
/** Text for the confirm button (default: "Confirm") */
|
|
85
|
-
confirmText?: string;
|
|
86
|
-
/** Text for the cancel button (default: "Cancel") */
|
|
87
|
-
cancelText?: string;
|
|
88
|
-
/** Visual variant for the dialog (default: "info") */
|
|
89
|
-
variant?: ConfirmVariant;
|
|
25
|
+
getMerchantPlan(): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Request a token refresh from the host.
|
|
28
|
+
*/
|
|
29
|
+
refreshToken(): void;
|
|
90
30
|
}
|
|
91
31
|
|
|
92
32
|
/**
|
|
93
|
-
*
|
|
33
|
+
* Breadcrumb item.
|
|
94
34
|
*/
|
|
95
|
-
export declare interface
|
|
96
|
-
|
|
97
|
-
|
|
35
|
+
export declare interface BreadcrumbItem {
|
|
36
|
+
label: string;
|
|
37
|
+
path?: string;
|
|
98
38
|
}
|
|
99
39
|
|
|
100
|
-
/**
|
|
101
|
-
* Confirm dialog variant.
|
|
102
|
-
*/
|
|
103
|
-
export declare type ConfirmVariant = "danger" | "warning" | "info";
|
|
104
|
-
|
|
105
40
|
export declare const embedded: EmbeddedApp;
|
|
106
41
|
|
|
107
42
|
/**
|
|
@@ -111,22 +46,15 @@ export declare const embedded: EmbeddedApp;
|
|
|
111
46
|
export declare class EmbeddedApp {
|
|
112
47
|
private config;
|
|
113
48
|
private state;
|
|
114
|
-
private themeCallbacks;
|
|
115
|
-
private initCallbacks;
|
|
116
|
-
private appReady;
|
|
117
49
|
/** Auth module for token management */
|
|
118
50
|
auth: AuthModule;
|
|
119
|
-
/** Page module for
|
|
51
|
+
/** Page module for loading, overlay, navigation */
|
|
120
52
|
page: PageModule;
|
|
121
53
|
/** Nav module for primary actions */
|
|
122
54
|
nav: NavModule;
|
|
123
|
-
/** UI module for loading, overlay, toast, modal */
|
|
124
|
-
ui: UIModule;
|
|
125
|
-
/** Checkout module for checkout flow */
|
|
126
|
-
checkout: CheckoutModule;
|
|
127
55
|
constructor();
|
|
128
56
|
/**
|
|
129
|
-
* Get current SDK state
|
|
57
|
+
* Get current SDK state.
|
|
130
58
|
*/
|
|
131
59
|
getState(): Readonly<EmbeddedState>;
|
|
132
60
|
/**
|
|
@@ -134,106 +62,40 @@ export declare class EmbeddedApp {
|
|
|
134
62
|
*/
|
|
135
63
|
getConfig(): Readonly<EmbeddedConfig>;
|
|
136
64
|
/**
|
|
137
|
-
* Check if SDK is
|
|
65
|
+
* Check if SDK is ready.
|
|
138
66
|
*/
|
|
139
67
|
isReady(): boolean;
|
|
140
68
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* @param type - Log type (log, warn, error, info, debug)
|
|
144
|
-
* @param args - Arguments to log
|
|
145
|
-
*/
|
|
146
|
-
private internalLog;
|
|
147
|
-
/**
|
|
148
|
-
* Set up listener for theme changes from host.
|
|
149
|
-
*/
|
|
150
|
-
private setupThemeListener;
|
|
151
|
-
/**
|
|
152
|
-
* Set up listeners for async response events from host.
|
|
153
|
-
*/
|
|
154
|
-
private setupResponseListeners;
|
|
155
|
-
/**
|
|
156
|
-
* Subscribe to theme changes.
|
|
157
|
-
*
|
|
158
|
-
* @param callback - Function called when theme changes
|
|
159
|
-
* @returns Unsubscribe function
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* ```typescript
|
|
163
|
-
* const unsubscribe = embedded.onThemeChange((theme) => {
|
|
164
|
-
* document.body.classList.toggle('dark-mode', theme === 'dark');
|
|
165
|
-
* });
|
|
166
|
-
* ```
|
|
167
|
-
*/
|
|
168
|
-
onThemeChange(callback: ThemeChangeCallback): () => void;
|
|
169
|
-
/**
|
|
170
|
-
* Subscribe to init completion. If called after init, fires immediately.
|
|
171
|
-
*
|
|
172
|
-
* @param callback - Function called when init completes
|
|
173
|
-
* @returns Unsubscribe function
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* ```typescript
|
|
177
|
-
* embedded.onInit((state) => {
|
|
178
|
-
* console.log('SDK initialized with layout:', state.layout);
|
|
179
|
-
* });
|
|
180
|
-
* ```
|
|
69
|
+
* Log debug messages if debug mode is enabled.
|
|
181
70
|
*/
|
|
182
|
-
|
|
71
|
+
private log;
|
|
183
72
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @param level - Log level (info, warn, error)
|
|
187
|
-
* @param message - Log message
|
|
188
|
-
* @param context - Additional context
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* ```typescript
|
|
192
|
-
* embedded.log('error', 'Failed to load data', { endpoint: '/api/data' });
|
|
193
|
-
* ```
|
|
194
|
-
*/
|
|
195
|
-
log(level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
196
|
-
/**
|
|
197
|
-
* Signal that the app is fully loaded and ready.
|
|
198
|
-
* This removes the host's loading overlay.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* // After verifying token and loading initial data
|
|
203
|
-
* embedded.ready();
|
|
204
|
-
* ```
|
|
73
|
+
* Log warnings.
|
|
205
74
|
*/
|
|
206
|
-
|
|
75
|
+
private warn;
|
|
207
76
|
/**
|
|
208
77
|
* Initialize the SDK and establish connection with the host.
|
|
209
78
|
*
|
|
210
|
-
* @param options - Initialization options
|
|
211
|
-
* @returns Promise that resolves
|
|
79
|
+
* @param options - Initialization options
|
|
80
|
+
* @returns Promise that resolves when SDK is ready
|
|
212
81
|
*
|
|
213
82
|
* @example
|
|
214
83
|
* ```typescript
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
84
|
+
* await salla.embedded.init({
|
|
85
|
+
* app_id: 'my-app-123',
|
|
86
|
+
* env: 'prod',
|
|
87
|
+
* debug: true
|
|
88
|
+
* });
|
|
218
89
|
* ```
|
|
219
90
|
*/
|
|
220
|
-
init(options
|
|
221
|
-
layout: LayoutInfo;
|
|
222
|
-
}>;
|
|
91
|
+
init(options: InitOptions): Promise<EmbeddedState>;
|
|
223
92
|
/**
|
|
224
|
-
* Wait for
|
|
93
|
+
* Wait for the SDK to be ready.
|
|
225
94
|
* Useful when multiple calls to init() might happen.
|
|
226
95
|
*/
|
|
227
|
-
private
|
|
96
|
+
private waitForReady;
|
|
228
97
|
/**
|
|
229
98
|
* Destroy the SDK instance and clean up resources.
|
|
230
|
-
* Sends a destroy event to the host to navigate away from the embedded view.
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```typescript
|
|
234
|
-
* // On auth failure or when app needs to exit
|
|
235
|
-
* embedded.destroy();
|
|
236
|
-
* ```
|
|
237
99
|
*/
|
|
238
100
|
destroy(): void;
|
|
239
101
|
}
|
|
@@ -242,6 +104,8 @@ export declare class EmbeddedApp {
|
|
|
242
104
|
* Internal configuration after initialization.
|
|
243
105
|
*/
|
|
244
106
|
declare interface EmbeddedConfig {
|
|
107
|
+
appId: string;
|
|
108
|
+
env: Environment;
|
|
245
109
|
debug: boolean;
|
|
246
110
|
initialized: boolean;
|
|
247
111
|
}
|
|
@@ -250,24 +114,42 @@ declare interface EmbeddedConfig {
|
|
|
250
114
|
* Current state of the embedded SDK.
|
|
251
115
|
*/
|
|
252
116
|
export declare interface EmbeddedState {
|
|
253
|
-
/** Whether the SDK is ready */
|
|
117
|
+
/** Whether the SDK is ready and authenticated */
|
|
254
118
|
ready: boolean;
|
|
255
119
|
/** Whether initialization is in progress */
|
|
256
120
|
initializing: boolean;
|
|
257
|
-
/**
|
|
258
|
-
|
|
121
|
+
/** Authentication token from the host */
|
|
122
|
+
token?: string;
|
|
123
|
+
/** Store ID from merchant context */
|
|
124
|
+
storeId?: number;
|
|
125
|
+
/** User ID from merchant context */
|
|
126
|
+
userId?: number;
|
|
127
|
+
/** Merchant plan */
|
|
128
|
+
merchantPlan?: string;
|
|
129
|
+
/** Current dark mode state */
|
|
130
|
+
isDarkMode?: boolean;
|
|
131
|
+
/** Parent window width */
|
|
132
|
+
parentWidth?: number;
|
|
133
|
+
/** Base URL of the host */
|
|
134
|
+
baseUrl?: string;
|
|
135
|
+
/** Base API URL */
|
|
136
|
+
baseApiUrl?: string;
|
|
259
137
|
}
|
|
260
138
|
|
|
139
|
+
/**
|
|
140
|
+
* @fileoverview Core type definitions for the Embedded SDK.
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* Environment mode for the SDK.
|
|
144
|
+
*/
|
|
145
|
+
export declare type Environment = "prod" | "dev";
|
|
146
|
+
|
|
261
147
|
/**
|
|
262
148
|
* Extended action for navigation.
|
|
263
149
|
*/
|
|
264
150
|
export declare interface ExtendedAction {
|
|
265
151
|
title: string;
|
|
266
|
-
subTitle?: string;
|
|
267
152
|
url?: string;
|
|
268
|
-
value?: string;
|
|
269
|
-
icon?: string;
|
|
270
|
-
disabled?: boolean;
|
|
271
153
|
}
|
|
272
154
|
|
|
273
155
|
/**
|
|
@@ -275,277 +157,107 @@ export declare interface ExtendedAction {
|
|
|
275
157
|
*/
|
|
276
158
|
export declare function getEmbeddedApp(): EmbeddedApp;
|
|
277
159
|
|
|
278
|
-
/**
|
|
279
|
-
* Init callback type for onInit subscribers.
|
|
280
|
-
*/
|
|
281
|
-
declare type InitCallback = (state: EmbeddedState) => void;
|
|
282
|
-
|
|
283
160
|
/**
|
|
284
161
|
* Options for initializing the embedded SDK.
|
|
285
162
|
*/
|
|
286
163
|
export declare interface InitOptions {
|
|
164
|
+
/** The unique identifier for the app */
|
|
165
|
+
app_id: string;
|
|
166
|
+
/** Environment mode (defaults to 'prod') */
|
|
167
|
+
env?: Environment;
|
|
287
168
|
/** Enable debug logging */
|
|
288
169
|
debug?: boolean;
|
|
289
170
|
}
|
|
290
171
|
|
|
291
172
|
/**
|
|
292
|
-
*
|
|
293
|
-
*/
|
|
294
|
-
declare interface IntrospectOptions {
|
|
295
|
-
/** Application ID (audience). If not provided, will be extracted from URL params. */
|
|
296
|
-
appId?: string;
|
|
297
|
-
/** Short-lived token. If not provided, will be extracted from URL params. */
|
|
298
|
-
token?: string;
|
|
299
|
-
/** Automatically refresh token on error (default: true) */
|
|
300
|
-
refreshOnError?: boolean;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Response from the introspect API.
|
|
305
|
-
*/
|
|
306
|
-
declare interface IntrospectResponse {
|
|
307
|
-
/** Whether the token was verified successfully */
|
|
308
|
-
isVerified: boolean;
|
|
309
|
-
/** Whether an error occurred */
|
|
310
|
-
isError: boolean;
|
|
311
|
-
/** Error content if an error occurred */
|
|
312
|
-
error?: unknown;
|
|
313
|
-
/** Response data (null on error) */
|
|
314
|
-
data: IntrospectResponseData | null;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Response data from the introspect API.
|
|
319
|
-
*/
|
|
320
|
-
declare interface IntrospectResponseData {
|
|
321
|
-
/** Token ID */
|
|
322
|
-
id: number;
|
|
323
|
-
/** User ID */
|
|
324
|
-
user_id: number;
|
|
325
|
-
/** Expiration time in ISO 8601 format */
|
|
326
|
-
exp: string;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Layout information from the host.
|
|
331
|
-
*/
|
|
332
|
-
declare interface LayoutInfo {
|
|
333
|
-
/** Current theme */
|
|
334
|
-
theme: Theme;
|
|
335
|
-
/** Parent window width */
|
|
336
|
-
width: number;
|
|
337
|
-
/** Current locale */
|
|
338
|
-
locale: string;
|
|
339
|
-
/** Current currency */
|
|
340
|
-
currency: string;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Loading mode.
|
|
173
|
+
* Loading mode for the page.
|
|
345
174
|
*/
|
|
346
175
|
export declare type LoadingMode = "full" | "component";
|
|
347
176
|
|
|
348
|
-
/**
|
|
349
|
-
* Loading sub-module interface.
|
|
350
|
-
*/
|
|
351
|
-
declare interface LoadingSubModule {
|
|
352
|
-
/**
|
|
353
|
-
* Show loading indicator.
|
|
354
|
-
* @param mode - Loading display mode
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
* ```typescript
|
|
358
|
-
* embedded.ui.loading.show();
|
|
359
|
-
* await fetchData();
|
|
360
|
-
* embedded.ui.loading.hide();
|
|
361
|
-
* ```
|
|
362
|
-
*/
|
|
363
|
-
show(mode?: LoadingMode): void;
|
|
364
|
-
/**
|
|
365
|
-
* Hide loading indicator.
|
|
366
|
-
*/
|
|
367
|
-
hide(): void;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Log level type.
|
|
372
|
-
*/
|
|
373
|
-
declare type LogLevel = "info" | "warn" | "error";
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Modal action types.
|
|
377
|
-
*/
|
|
378
|
-
export declare type ModalAction = "open" | "close";
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Modal action type.
|
|
382
|
-
*/
|
|
383
|
-
declare type ModalAction_2 = "open" | "close";
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Modal control options.
|
|
387
|
-
*/
|
|
388
|
-
export declare interface ModalOptions {
|
|
389
|
-
/** Modal action */
|
|
390
|
-
action: ModalAction_2;
|
|
391
|
-
/** Modal identifier */
|
|
392
|
-
id?: string;
|
|
393
|
-
/** Modal content/data */
|
|
394
|
-
content?: unknown;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Modal sub-module interface.
|
|
399
|
-
*/
|
|
400
|
-
declare interface ModalSubModule {
|
|
401
|
-
/**
|
|
402
|
-
* Open a modal.
|
|
403
|
-
* @param id - Modal identifier
|
|
404
|
-
* @param content - Modal content/data
|
|
405
|
-
*
|
|
406
|
-
* @example
|
|
407
|
-
* ```typescript
|
|
408
|
-
* embedded.ui.modal.open('confirm-delete', { itemId: 123 });
|
|
409
|
-
* ```
|
|
410
|
-
*/
|
|
411
|
-
open(id?: string, content?: unknown): void;
|
|
412
|
-
/**
|
|
413
|
-
* Close a modal.
|
|
414
|
-
* @param id - Modal identifier
|
|
415
|
-
*/
|
|
416
|
-
close(id?: string): void;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
177
|
/**
|
|
420
178
|
* Nav module interface.
|
|
421
179
|
*/
|
|
422
180
|
export declare interface NavModule {
|
|
423
181
|
/**
|
|
424
|
-
* Set the primary action button in the
|
|
182
|
+
* Set the primary action button in the navigation.
|
|
425
183
|
*
|
|
426
|
-
* @param config -
|
|
184
|
+
* @param config - Primary action configuration
|
|
427
185
|
*
|
|
428
186
|
* @example
|
|
429
187
|
* ```typescript
|
|
430
|
-
* embedded.nav.
|
|
188
|
+
* salla.embedded.nav.primaryAction({
|
|
431
189
|
* title: 'Create Product',
|
|
432
|
-
*
|
|
433
|
-
* // Handle click
|
|
434
|
-
* }
|
|
435
|
-
* });
|
|
436
|
-
*
|
|
437
|
-
* // With optional props
|
|
438
|
-
* embedded.nav.setAction({
|
|
439
|
-
* title: 'Save',
|
|
440
|
-
* subTitle: 'Save changes',
|
|
441
|
-
* icon: 'sicon-save',
|
|
442
|
-
* disabled: false,
|
|
443
|
-
* onClick: () => {
|
|
444
|
-
* handleSave();
|
|
445
|
-
* }
|
|
446
|
-
* });
|
|
447
|
-
*
|
|
448
|
-
* // With extended actions dropdown
|
|
449
|
-
* embedded.nav.setAction({
|
|
450
|
-
* title: 'Actions',
|
|
451
|
-
* value: 'main-action',
|
|
190
|
+
* url: '/products/create',
|
|
452
191
|
* extendedActions: [
|
|
453
|
-
* { title: 'Import', url: '/import' },
|
|
454
|
-
* { title: '
|
|
192
|
+
* { title: 'Import Products', url: '/products/import' },
|
|
193
|
+
* { title: 'Bulk Edit', url: '/products/bulk-edit' }
|
|
455
194
|
* ]
|
|
456
195
|
* });
|
|
457
196
|
* ```
|
|
458
197
|
*/
|
|
459
|
-
setAction(config: PrimaryActionConfig): void;
|
|
460
|
-
/**
|
|
461
|
-
* Clear the primary action button.
|
|
462
|
-
*
|
|
463
|
-
* @example
|
|
464
|
-
* ```typescript
|
|
465
|
-
* embedded.nav.clearAction();
|
|
466
|
-
* ```
|
|
467
|
-
*/
|
|
468
|
-
clearAction(): void;
|
|
469
|
-
/**
|
|
470
|
-
* Subscribe to action button click events.
|
|
471
|
-
*
|
|
472
|
-
* @param callback - Function called when action is clicked
|
|
473
|
-
* @returns Unsubscribe function
|
|
474
|
-
*
|
|
475
|
-
* @example
|
|
476
|
-
* ```typescript
|
|
477
|
-
* const unsubscribe = embedded.nav.onActionClick((url, value) => {
|
|
478
|
-
* if (value === 'export') {
|
|
479
|
-
* handleExport();
|
|
480
|
-
* }
|
|
481
|
-
* });
|
|
482
|
-
* ```
|
|
483
|
-
*/
|
|
484
|
-
onActionClick(callback: ActionClickCallback): Unsubscribe;
|
|
485
|
-
/**
|
|
486
|
-
* @deprecated Use setAction instead
|
|
487
|
-
*/
|
|
488
198
|
primaryAction(config: PrimaryActionConfig): void;
|
|
489
199
|
/**
|
|
490
|
-
*
|
|
200
|
+
* Clear the primary action button.
|
|
491
201
|
*/
|
|
492
202
|
clearPrimaryAction(): void;
|
|
493
203
|
}
|
|
494
204
|
|
|
495
205
|
/**
|
|
496
|
-
*
|
|
497
|
-
*/
|
|
498
|
-
/**
|
|
499
|
-
* Options for navigation.
|
|
206
|
+
* Navigation options.
|
|
500
207
|
*/
|
|
501
208
|
export declare interface NavToOptions {
|
|
502
|
-
/**
|
|
503
|
-
|
|
504
|
-
/** Replace history entry instead of push */
|
|
505
|
-
replace?: boolean;
|
|
209
|
+
/** Navigation mode */
|
|
210
|
+
mode?: "iframe" | "redirect";
|
|
506
211
|
}
|
|
507
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Overlay action.
|
|
215
|
+
*/
|
|
216
|
+
export declare type OverlayAction = "open" | "close";
|
|
217
|
+
|
|
508
218
|
/**
|
|
509
219
|
* Page module interface.
|
|
510
220
|
*/
|
|
511
221
|
export declare interface PageModule {
|
|
512
222
|
/**
|
|
513
|
-
*
|
|
514
|
-
* Use this for internal dashboard paths.
|
|
223
|
+
* Set the loading state of the page.
|
|
515
224
|
*
|
|
516
|
-
* @param
|
|
517
|
-
* @param
|
|
225
|
+
* @param status - true to show loading complete, false for loading
|
|
226
|
+
* @param mode - Loading mode ('full' or 'component')
|
|
518
227
|
*
|
|
519
228
|
* @example
|
|
520
229
|
* ```typescript
|
|
521
|
-
*
|
|
522
|
-
* embedded.page.
|
|
230
|
+
* // Show loading
|
|
231
|
+
* salla.embedded.page.loading(false);
|
|
232
|
+
*
|
|
233
|
+
* // Hide loading (content ready)
|
|
234
|
+
* salla.embedded.page.loading(true);
|
|
523
235
|
* ```
|
|
524
236
|
*/
|
|
525
|
-
|
|
237
|
+
loading(status: boolean, mode?: LoadingMode): void;
|
|
526
238
|
/**
|
|
527
|
-
*
|
|
528
|
-
* Use this for external URLs or when a full reload is needed.
|
|
239
|
+
* Control the overlay state.
|
|
529
240
|
*
|
|
530
|
-
* @param
|
|
241
|
+
* @param action - 'open' or 'close'
|
|
531
242
|
*
|
|
532
243
|
* @example
|
|
533
244
|
* ```typescript
|
|
534
|
-
* embedded.page.
|
|
245
|
+
* salla.embedded.page.overlay('open');
|
|
246
|
+
* // ... show modal content
|
|
247
|
+
* salla.embedded.page.overlay('close');
|
|
535
248
|
* ```
|
|
536
249
|
*/
|
|
537
|
-
|
|
250
|
+
overlay(action: OverlayAction): void;
|
|
538
251
|
/**
|
|
539
|
-
* Navigate to a path
|
|
540
|
-
* Internal paths use React Router, external URLs use redirect.
|
|
252
|
+
* Navigate to a path.
|
|
541
253
|
*
|
|
542
|
-
* @param path - The path
|
|
543
|
-
* @param options - Navigation options
|
|
254
|
+
* @param path - The path to navigate to
|
|
255
|
+
* @param options - Navigation options
|
|
544
256
|
*
|
|
545
257
|
* @example
|
|
546
258
|
* ```typescript
|
|
547
|
-
* embedded.page.navTo('/products');
|
|
548
|
-
* embedded.page.navTo('https://external.com'
|
|
259
|
+
* salla.embedded.page.navTo('/products');
|
|
260
|
+
* salla.embedded.page.navTo('https://external.com', { mode: 'redirect' });
|
|
549
261
|
* ```
|
|
550
262
|
*/
|
|
551
263
|
navTo(path: string, options?: NavToOptions): void;
|
|
@@ -553,54 +265,36 @@ export declare interface PageModule {
|
|
|
553
265
|
* Update the iframe height.
|
|
554
266
|
*
|
|
555
267
|
* @param height - Height in pixels
|
|
556
|
-
*
|
|
557
|
-
* @example
|
|
558
|
-
* ```typescript
|
|
559
|
-
* embedded.page.resize(800);
|
|
560
|
-
* ```
|
|
561
268
|
*/
|
|
562
269
|
resize(height: number): void;
|
|
563
270
|
/**
|
|
564
|
-
*
|
|
565
|
-
* Measures document.documentElement.scrollHeight and sends resize.
|
|
271
|
+
* Set breadcrumb items.
|
|
566
272
|
*
|
|
567
|
-
* @
|
|
568
|
-
* ```typescript
|
|
569
|
-
* // After content changes
|
|
570
|
-
* embedded.page.autoResize();
|
|
571
|
-
* ```
|
|
572
|
-
*/
|
|
573
|
-
autoResize(): void;
|
|
574
|
-
/**
|
|
575
|
-
* Set the page title in the host document.
|
|
576
|
-
*
|
|
577
|
-
* @param title - The title to set
|
|
273
|
+
* @param items - Array of breadcrumb items
|
|
578
274
|
*
|
|
579
275
|
* @example
|
|
580
276
|
* ```typescript
|
|
581
|
-
* embedded.page.
|
|
277
|
+
* salla.embedded.page.setBreadcrumbs([
|
|
278
|
+
* { label: 'Home', path: '/' },
|
|
279
|
+
* { label: 'Products', path: '/products' },
|
|
280
|
+
* { label: 'Current Product' }
|
|
281
|
+
* ]);
|
|
582
282
|
* ```
|
|
583
283
|
*/
|
|
584
|
-
|
|
284
|
+
setBreadcrumbs(items: BreadcrumbItem[]): void;
|
|
585
285
|
}
|
|
586
286
|
|
|
587
287
|
/**
|
|
588
|
-
*
|
|
288
|
+
* Primary action configuration.
|
|
589
289
|
*/
|
|
590
290
|
export declare interface PrimaryActionConfig {
|
|
591
291
|
/** Button title */
|
|
592
292
|
title: string;
|
|
593
|
-
/**
|
|
594
|
-
|
|
595
|
-
/** Custom value
|
|
293
|
+
/** URL to navigate to when clicked (optional) */
|
|
294
|
+
url?: string;
|
|
295
|
+
/** Custom value to send back on click */
|
|
596
296
|
value?: string;
|
|
597
|
-
/**
|
|
598
|
-
subTitle?: string;
|
|
599
|
-
/** Optional icon class name */
|
|
600
|
-
icon?: string;
|
|
601
|
-
/** Whether the button is disabled */
|
|
602
|
-
disabled?: boolean;
|
|
603
|
-
/** Extended dropdown actions */
|
|
297
|
+
/** Extended actions for dropdown menu */
|
|
604
298
|
extendedActions?: ExtendedAction[];
|
|
605
299
|
}
|
|
606
300
|
|
|
@@ -609,141 +303,6 @@ export declare interface PrimaryActionConfig {
|
|
|
609
303
|
*/
|
|
610
304
|
export declare function resetEmbeddedApp(): void;
|
|
611
305
|
|
|
612
|
-
|
|
613
|
-
* @fileoverview Core type definitions for the Embedded SDK.
|
|
614
|
-
*/
|
|
615
|
-
/**
|
|
616
|
-
* Theme type for the SDK.
|
|
617
|
-
*/
|
|
618
|
-
declare type Theme = "light" | "dark";
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Theme change callback type.
|
|
622
|
-
*/
|
|
623
|
-
declare type ThemeChangeCallback = (theme: "light" | "dark") => void;
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Toast notification options.
|
|
627
|
-
*/
|
|
628
|
-
export declare interface ToastOptions {
|
|
629
|
-
/** Toast type */
|
|
630
|
-
type: ToastType_2;
|
|
631
|
-
/** Message to display */
|
|
632
|
-
message: string;
|
|
633
|
-
/** Duration in milliseconds (optional) */
|
|
634
|
-
duration?: number;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Toast sub-module interface.
|
|
639
|
-
*/
|
|
640
|
-
declare interface ToastSubModule {
|
|
641
|
-
/**
|
|
642
|
-
* Show a toast notification.
|
|
643
|
-
* @param options - Toast configuration
|
|
644
|
-
*
|
|
645
|
-
* @example
|
|
646
|
-
* ```typescript
|
|
647
|
-
* embedded.ui.toast.show({
|
|
648
|
-
* type: 'success',
|
|
649
|
-
* message: 'Product saved!',
|
|
650
|
-
* duration: 3000
|
|
651
|
-
* });
|
|
652
|
-
* ```
|
|
653
|
-
*/
|
|
654
|
-
show(options: ToastOptions): void;
|
|
655
|
-
/**
|
|
656
|
-
* Show success toast.
|
|
657
|
-
* @param message - Message to display
|
|
658
|
-
* @param duration - Duration in ms
|
|
659
|
-
*/
|
|
660
|
-
success(message: string, duration?: number): void;
|
|
661
|
-
/**
|
|
662
|
-
* Show error toast.
|
|
663
|
-
* @param message - Message to display
|
|
664
|
-
* @param duration - Duration in ms
|
|
665
|
-
*/
|
|
666
|
-
error(message: string, duration?: number): void;
|
|
667
|
-
/**
|
|
668
|
-
* Show warning toast.
|
|
669
|
-
* @param message - Message to display
|
|
670
|
-
* @param duration - Duration in ms
|
|
671
|
-
*/
|
|
672
|
-
warning(message: string, duration?: number): void;
|
|
673
|
-
/**
|
|
674
|
-
* Show info toast.
|
|
675
|
-
* @param message - Message to display
|
|
676
|
-
* @param duration - Duration in ms
|
|
677
|
-
*/
|
|
678
|
-
info(message: string, duration?: number): void;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
/**
|
|
682
|
-
* Toast notification types.
|
|
683
|
-
*/
|
|
684
|
-
export declare type ToastType = "success" | "error" | "warning" | "info";
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* Toast type.
|
|
688
|
-
*/
|
|
689
|
-
declare type ToastType_2 = "success" | "error" | "warning" | "info";
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* UI module interface with nested sub-modules.
|
|
693
|
-
*/
|
|
694
|
-
export declare interface UIModule {
|
|
695
|
-
/**
|
|
696
|
-
* Loading state control.
|
|
697
|
-
*/
|
|
698
|
-
loading: LoadingSubModule;
|
|
699
|
-
/**
|
|
700
|
-
* Toast notifications.
|
|
701
|
-
*/
|
|
702
|
-
toast: ToastSubModule;
|
|
703
|
-
/**
|
|
704
|
-
* Modal control.
|
|
705
|
-
*/
|
|
706
|
-
modal: ModalSubModule;
|
|
707
|
-
/**
|
|
708
|
-
* Show a confirmation dialog and wait for user response.
|
|
709
|
-
*
|
|
710
|
-
* @param options - Confirm dialog options
|
|
711
|
-
* @returns Promise that resolves with the user's choice
|
|
712
|
-
*
|
|
713
|
-
* @example
|
|
714
|
-
* ```typescript
|
|
715
|
-
* const result = await embedded.ui.confirm({
|
|
716
|
-
* title: 'Delete Product?',
|
|
717
|
-
* message: 'This action cannot be undone.',
|
|
718
|
-
* confirmText: 'Delete',
|
|
719
|
-
* variant: 'danger',
|
|
720
|
-
* });
|
|
721
|
-
* if (result.confirmed) {
|
|
722
|
-
* // User confirmed
|
|
723
|
-
* }
|
|
724
|
-
* ```
|
|
725
|
-
*/
|
|
726
|
-
confirm(options: ConfirmOptions): Promise<ConfirmResult>;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Unsubscribe function returned by message listeners.
|
|
731
|
-
*/
|
|
732
|
-
declare type Unsubscribe = () => void;
|
|
733
|
-
|
|
734
|
-
/**
|
|
735
|
-
* @fileoverview Validation types for SDK payload validation.
|
|
736
|
-
*/
|
|
737
|
-
/**
|
|
738
|
-
* Result of a validation check.
|
|
739
|
-
*/
|
|
740
|
-
export declare interface ValidationResult {
|
|
741
|
-
/** Whether the validation passed */
|
|
742
|
-
valid: boolean;
|
|
743
|
-
/** Array of error messages if validation failed */
|
|
744
|
-
errors: string[];
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
export declare const version: string;
|
|
306
|
+
export declare const version = "0.1.0";
|
|
748
307
|
|
|
749
308
|
export { }
|