@salla.sa/embedded-sdk 0.1.0-beta.12 → 0.1.0-beta.3
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 +261 -35
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +294 -447
- 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 -557
- 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,276 +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
|
-
*
|
|
355
|
-
* @example
|
|
356
|
-
* ```typescript
|
|
357
|
-
* embedded.ui.loading.show();
|
|
358
|
-
* await fetchData();
|
|
359
|
-
* embedded.ui.loading.hide();
|
|
360
|
-
* ```
|
|
361
|
-
*/
|
|
362
|
-
show(): void;
|
|
363
|
-
/**
|
|
364
|
-
* Hide loading indicator.
|
|
365
|
-
*/
|
|
366
|
-
hide(): void;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Log level type.
|
|
371
|
-
*/
|
|
372
|
-
declare type LogLevel = "info" | "warn" | "error";
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Modal action types.
|
|
376
|
-
*/
|
|
377
|
-
export declare type ModalAction = "open" | "close";
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Modal action type.
|
|
381
|
-
*/
|
|
382
|
-
declare type ModalAction_2 = "open" | "close";
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Modal control options.
|
|
386
|
-
*/
|
|
387
|
-
export declare interface ModalOptions {
|
|
388
|
-
/** Modal action */
|
|
389
|
-
action: ModalAction_2;
|
|
390
|
-
/** Modal identifier */
|
|
391
|
-
id?: string;
|
|
392
|
-
/** Modal content/data */
|
|
393
|
-
content?: unknown;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Modal sub-module interface.
|
|
398
|
-
*/
|
|
399
|
-
declare interface ModalSubModule {
|
|
400
|
-
/**
|
|
401
|
-
* Open a modal.
|
|
402
|
-
* @param id - Modal identifier
|
|
403
|
-
* @param content - Modal content/data
|
|
404
|
-
*
|
|
405
|
-
* @example
|
|
406
|
-
* ```typescript
|
|
407
|
-
* embedded.ui.modal.open('confirm-delete', { itemId: 123 });
|
|
408
|
-
* ```
|
|
409
|
-
*/
|
|
410
|
-
open(id?: string, content?: unknown): void;
|
|
411
|
-
/**
|
|
412
|
-
* Close a modal.
|
|
413
|
-
* @param id - Modal identifier
|
|
414
|
-
*/
|
|
415
|
-
close(id?: string): void;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
177
|
/**
|
|
419
178
|
* Nav module interface.
|
|
420
179
|
*/
|
|
421
180
|
export declare interface NavModule {
|
|
422
181
|
/**
|
|
423
|
-
* Set the primary action button in the
|
|
182
|
+
* Set the primary action button in the navigation.
|
|
424
183
|
*
|
|
425
|
-
* @param config -
|
|
184
|
+
* @param config - Primary action configuration
|
|
426
185
|
*
|
|
427
186
|
* @example
|
|
428
187
|
* ```typescript
|
|
429
|
-
* embedded.nav.
|
|
188
|
+
* salla.embedded.nav.primaryAction({
|
|
430
189
|
* title: 'Create Product',
|
|
431
|
-
*
|
|
432
|
-
* // Handle click
|
|
433
|
-
* }
|
|
434
|
-
* });
|
|
435
|
-
*
|
|
436
|
-
* // With optional props
|
|
437
|
-
* embedded.nav.setAction({
|
|
438
|
-
* title: 'Save',
|
|
439
|
-
* subTitle: 'Save changes',
|
|
440
|
-
* icon: 'sicon-save',
|
|
441
|
-
* disabled: false,
|
|
442
|
-
* onClick: () => {
|
|
443
|
-
* handleSave();
|
|
444
|
-
* }
|
|
445
|
-
* });
|
|
446
|
-
*
|
|
447
|
-
* // With extended actions dropdown
|
|
448
|
-
* embedded.nav.setAction({
|
|
449
|
-
* title: 'Actions',
|
|
450
|
-
* value: 'main-action',
|
|
190
|
+
* url: '/products/create',
|
|
451
191
|
* extendedActions: [
|
|
452
|
-
* { title: 'Import', url: '/import' },
|
|
453
|
-
* { title: '
|
|
192
|
+
* { title: 'Import Products', url: '/products/import' },
|
|
193
|
+
* { title: 'Bulk Edit', url: '/products/bulk-edit' }
|
|
454
194
|
* ]
|
|
455
195
|
* });
|
|
456
196
|
* ```
|
|
457
197
|
*/
|
|
458
|
-
setAction(config: PrimaryActionConfig): void;
|
|
459
|
-
/**
|
|
460
|
-
* Clear the primary action button.
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* ```typescript
|
|
464
|
-
* embedded.nav.clearAction();
|
|
465
|
-
* ```
|
|
466
|
-
*/
|
|
467
|
-
clearAction(): void;
|
|
468
|
-
/**
|
|
469
|
-
* Subscribe to action button click events.
|
|
470
|
-
*
|
|
471
|
-
* @param callback - Function called when action is clicked
|
|
472
|
-
* @returns Unsubscribe function
|
|
473
|
-
*
|
|
474
|
-
* @example
|
|
475
|
-
* ```typescript
|
|
476
|
-
* const unsubscribe = embedded.nav.onActionClick((url, value) => {
|
|
477
|
-
* if (value === 'export') {
|
|
478
|
-
* handleExport();
|
|
479
|
-
* }
|
|
480
|
-
* });
|
|
481
|
-
* ```
|
|
482
|
-
*/
|
|
483
|
-
onActionClick(callback: ActionClickCallback): Unsubscribe;
|
|
484
|
-
/**
|
|
485
|
-
* @deprecated Use setAction instead
|
|
486
|
-
*/
|
|
487
198
|
primaryAction(config: PrimaryActionConfig): void;
|
|
488
199
|
/**
|
|
489
|
-
*
|
|
200
|
+
* Clear the primary action button.
|
|
490
201
|
*/
|
|
491
202
|
clearPrimaryAction(): void;
|
|
492
203
|
}
|
|
493
204
|
|
|
494
205
|
/**
|
|
495
|
-
*
|
|
496
|
-
*/
|
|
497
|
-
/**
|
|
498
|
-
* Options for navigation.
|
|
206
|
+
* Navigation options.
|
|
499
207
|
*/
|
|
500
208
|
export declare interface NavToOptions {
|
|
501
|
-
/**
|
|
502
|
-
|
|
503
|
-
/** Replace history entry instead of push */
|
|
504
|
-
replace?: boolean;
|
|
209
|
+
/** Navigation mode */
|
|
210
|
+
mode?: "iframe" | "redirect";
|
|
505
211
|
}
|
|
506
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Overlay action.
|
|
215
|
+
*/
|
|
216
|
+
export declare type OverlayAction = "open" | "close";
|
|
217
|
+
|
|
507
218
|
/**
|
|
508
219
|
* Page module interface.
|
|
509
220
|
*/
|
|
510
221
|
export declare interface PageModule {
|
|
511
222
|
/**
|
|
512
|
-
*
|
|
513
|
-
* Use this for internal dashboard paths.
|
|
223
|
+
* Set the loading state of the page.
|
|
514
224
|
*
|
|
515
|
-
* @param
|
|
516
|
-
* @param
|
|
225
|
+
* @param status - true to show loading complete, false for loading
|
|
226
|
+
* @param mode - Loading mode ('full' or 'component')
|
|
517
227
|
*
|
|
518
228
|
* @example
|
|
519
229
|
* ```typescript
|
|
520
|
-
*
|
|
521
|
-
* embedded.page.
|
|
230
|
+
* // Show loading
|
|
231
|
+
* salla.embedded.page.loading(false);
|
|
232
|
+
*
|
|
233
|
+
* // Hide loading (content ready)
|
|
234
|
+
* salla.embedded.page.loading(true);
|
|
522
235
|
* ```
|
|
523
236
|
*/
|
|
524
|
-
|
|
237
|
+
loading(status: boolean, mode?: LoadingMode): void;
|
|
525
238
|
/**
|
|
526
|
-
*
|
|
527
|
-
* Use this for external URLs or when a full reload is needed.
|
|
239
|
+
* Control the overlay state.
|
|
528
240
|
*
|
|
529
|
-
* @param
|
|
241
|
+
* @param action - 'open' or 'close'
|
|
530
242
|
*
|
|
531
243
|
* @example
|
|
532
244
|
* ```typescript
|
|
533
|
-
* embedded.page.
|
|
245
|
+
* salla.embedded.page.overlay('open');
|
|
246
|
+
* // ... show modal content
|
|
247
|
+
* salla.embedded.page.overlay('close');
|
|
534
248
|
* ```
|
|
535
249
|
*/
|
|
536
|
-
|
|
250
|
+
overlay(action: OverlayAction): void;
|
|
537
251
|
/**
|
|
538
|
-
* Navigate to a path
|
|
539
|
-
* Internal paths use React Router, external URLs use redirect.
|
|
252
|
+
* Navigate to a path.
|
|
540
253
|
*
|
|
541
|
-
* @param path - The path
|
|
542
|
-
* @param options - Navigation options
|
|
254
|
+
* @param path - The path to navigate to
|
|
255
|
+
* @param options - Navigation options
|
|
543
256
|
*
|
|
544
257
|
* @example
|
|
545
258
|
* ```typescript
|
|
546
|
-
* embedded.page.navTo('/products');
|
|
547
|
-
* embedded.page.navTo('https://external.com'
|
|
259
|
+
* salla.embedded.page.navTo('/products');
|
|
260
|
+
* salla.embedded.page.navTo('https://external.com', { mode: 'redirect' });
|
|
548
261
|
* ```
|
|
549
262
|
*/
|
|
550
263
|
navTo(path: string, options?: NavToOptions): void;
|
|
@@ -552,54 +265,36 @@ export declare interface PageModule {
|
|
|
552
265
|
* Update the iframe height.
|
|
553
266
|
*
|
|
554
267
|
* @param height - Height in pixels
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```typescript
|
|
558
|
-
* embedded.page.resize(800);
|
|
559
|
-
* ```
|
|
560
268
|
*/
|
|
561
269
|
resize(height: number): void;
|
|
562
270
|
/**
|
|
563
|
-
*
|
|
564
|
-
* Measures document.documentElement.scrollHeight and sends resize.
|
|
271
|
+
* Set breadcrumb items.
|
|
565
272
|
*
|
|
566
|
-
* @
|
|
567
|
-
* ```typescript
|
|
568
|
-
* // After content changes
|
|
569
|
-
* embedded.page.autoResize();
|
|
570
|
-
* ```
|
|
571
|
-
*/
|
|
572
|
-
autoResize(): void;
|
|
573
|
-
/**
|
|
574
|
-
* Set the page title in the host document.
|
|
575
|
-
*
|
|
576
|
-
* @param title - The title to set
|
|
273
|
+
* @param items - Array of breadcrumb items
|
|
577
274
|
*
|
|
578
275
|
* @example
|
|
579
276
|
* ```typescript
|
|
580
|
-
* embedded.page.
|
|
277
|
+
* salla.embedded.page.setBreadcrumbs([
|
|
278
|
+
* { label: 'Home', path: '/' },
|
|
279
|
+
* { label: 'Products', path: '/products' },
|
|
280
|
+
* { label: 'Current Product' }
|
|
281
|
+
* ]);
|
|
581
282
|
* ```
|
|
582
283
|
*/
|
|
583
|
-
|
|
284
|
+
setBreadcrumbs(items: BreadcrumbItem[]): void;
|
|
584
285
|
}
|
|
585
286
|
|
|
586
287
|
/**
|
|
587
|
-
*
|
|
288
|
+
* Primary action configuration.
|
|
588
289
|
*/
|
|
589
290
|
export declare interface PrimaryActionConfig {
|
|
590
291
|
/** Button title */
|
|
591
292
|
title: string;
|
|
592
|
-
/**
|
|
593
|
-
|
|
594
|
-
/** Custom value
|
|
293
|
+
/** URL to navigate to when clicked (optional) */
|
|
294
|
+
url?: string;
|
|
295
|
+
/** Custom value to send back on click */
|
|
595
296
|
value?: string;
|
|
596
|
-
/**
|
|
597
|
-
subTitle?: string;
|
|
598
|
-
/** Optional icon class name */
|
|
599
|
-
icon?: string;
|
|
600
|
-
/** Whether the button is disabled */
|
|
601
|
-
disabled?: boolean;
|
|
602
|
-
/** Extended dropdown actions */
|
|
297
|
+
/** Extended actions for dropdown menu */
|
|
603
298
|
extendedActions?: ExtendedAction[];
|
|
604
299
|
}
|
|
605
300
|
|
|
@@ -608,141 +303,6 @@ export declare interface PrimaryActionConfig {
|
|
|
608
303
|
*/
|
|
609
304
|
export declare function resetEmbeddedApp(): void;
|
|
610
305
|
|
|
611
|
-
|
|
612
|
-
* @fileoverview Core type definitions for the Embedded SDK.
|
|
613
|
-
*/
|
|
614
|
-
/**
|
|
615
|
-
* Theme type for the SDK.
|
|
616
|
-
*/
|
|
617
|
-
declare type Theme = "light" | "dark";
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* Theme change callback type.
|
|
621
|
-
*/
|
|
622
|
-
declare type ThemeChangeCallback = (theme: "light" | "dark") => void;
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
* Toast notification options.
|
|
626
|
-
*/
|
|
627
|
-
export declare interface ToastOptions {
|
|
628
|
-
/** Toast type */
|
|
629
|
-
type: ToastType_2;
|
|
630
|
-
/** Message to display */
|
|
631
|
-
message: string;
|
|
632
|
-
/** Duration in milliseconds (optional) */
|
|
633
|
-
duration?: number;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Toast sub-module interface.
|
|
638
|
-
*/
|
|
639
|
-
declare interface ToastSubModule {
|
|
640
|
-
/**
|
|
641
|
-
* Show a toast notification.
|
|
642
|
-
* @param options - Toast configuration
|
|
643
|
-
*
|
|
644
|
-
* @example
|
|
645
|
-
* ```typescript
|
|
646
|
-
* embedded.ui.toast.show({
|
|
647
|
-
* type: 'success',
|
|
648
|
-
* message: 'Product saved!',
|
|
649
|
-
* duration: 3000
|
|
650
|
-
* });
|
|
651
|
-
* ```
|
|
652
|
-
*/
|
|
653
|
-
show(options: ToastOptions): void;
|
|
654
|
-
/**
|
|
655
|
-
* Show success toast.
|
|
656
|
-
* @param message - Message to display
|
|
657
|
-
* @param duration - Duration in ms
|
|
658
|
-
*/
|
|
659
|
-
success(message: string, duration?: number): void;
|
|
660
|
-
/**
|
|
661
|
-
* Show error toast.
|
|
662
|
-
* @param message - Message to display
|
|
663
|
-
* @param duration - Duration in ms
|
|
664
|
-
*/
|
|
665
|
-
error(message: string, duration?: number): void;
|
|
666
|
-
/**
|
|
667
|
-
* Show warning toast.
|
|
668
|
-
* @param message - Message to display
|
|
669
|
-
* @param duration - Duration in ms
|
|
670
|
-
*/
|
|
671
|
-
warning(message: string, duration?: number): void;
|
|
672
|
-
/**
|
|
673
|
-
* Show info toast.
|
|
674
|
-
* @param message - Message to display
|
|
675
|
-
* @param duration - Duration in ms
|
|
676
|
-
*/
|
|
677
|
-
info(message: string, duration?: number): void;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
* Toast notification types.
|
|
682
|
-
*/
|
|
683
|
-
export declare type ToastType = "success" | "error" | "warning" | "info";
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Toast type.
|
|
687
|
-
*/
|
|
688
|
-
declare type ToastType_2 = "success" | "error" | "warning" | "info";
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* UI module interface with nested sub-modules.
|
|
692
|
-
*/
|
|
693
|
-
export declare interface UIModule {
|
|
694
|
-
/**
|
|
695
|
-
* Loading state control.
|
|
696
|
-
*/
|
|
697
|
-
loading: LoadingSubModule;
|
|
698
|
-
/**
|
|
699
|
-
* Toast notifications.
|
|
700
|
-
*/
|
|
701
|
-
toast: ToastSubModule;
|
|
702
|
-
/**
|
|
703
|
-
* Modal control.
|
|
704
|
-
*/
|
|
705
|
-
modal: ModalSubModule;
|
|
706
|
-
/**
|
|
707
|
-
* Show a confirmation dialog and wait for user response.
|
|
708
|
-
*
|
|
709
|
-
* @param options - Confirm dialog options
|
|
710
|
-
* @returns Promise that resolves with the user's choice
|
|
711
|
-
*
|
|
712
|
-
* @example
|
|
713
|
-
* ```typescript
|
|
714
|
-
* const result = await embedded.ui.confirm({
|
|
715
|
-
* title: 'Delete Product?',
|
|
716
|
-
* message: 'This action cannot be undone.',
|
|
717
|
-
* confirmText: 'Delete',
|
|
718
|
-
* variant: 'danger',
|
|
719
|
-
* });
|
|
720
|
-
* if (result.confirmed) {
|
|
721
|
-
* // User confirmed
|
|
722
|
-
* }
|
|
723
|
-
* ```
|
|
724
|
-
*/
|
|
725
|
-
confirm(options: ConfirmOptions): Promise<ConfirmResult>;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
/**
|
|
729
|
-
* Unsubscribe function returned by message listeners.
|
|
730
|
-
*/
|
|
731
|
-
declare type Unsubscribe = () => void;
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* @fileoverview Validation types for SDK payload validation.
|
|
735
|
-
*/
|
|
736
|
-
/**
|
|
737
|
-
* Result of a validation check.
|
|
738
|
-
*/
|
|
739
|
-
export declare interface ValidationResult {
|
|
740
|
-
/** Whether the validation passed */
|
|
741
|
-
valid: boolean;
|
|
742
|
-
/** Array of error messages if validation failed */
|
|
743
|
-
errors: string[];
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
export declare const version: string;
|
|
306
|
+
export declare const version = "0.1.0";
|
|
747
307
|
|
|
748
308
|
export { }
|