@superleapai/flow-ui 1.0.2 → 2.2.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.
- package/README.md +161 -16
- package/core/bridge.js +524 -0
- package/core/crm.js +336 -0
- package/dist/output.css +1 -1
- package/dist/superleap-flow.js +14205 -0
- package/dist/superleap-flow.js.map +1 -0
- package/dist/superleap-flow.min.js +2 -0
- package/index.d.ts +190 -11
- package/index.js +182 -177
- package/package.json +14 -7
package/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
6
6
|
// ============================================================================
|
|
7
7
|
// SUPERLEAP SDK
|
|
8
8
|
// ============================================================================
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
export interface SuperLeapConfig {
|
|
11
11
|
apiKey?: string;
|
|
12
12
|
baseUrl?: string;
|
|
@@ -25,11 +25,135 @@ declare module "@superleapai/flow-ui" {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// CRM BRIDGE TYPES
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
/** Configuration passed to SuperLeap.connect() */
|
|
33
|
+
export interface ConnectOptions {
|
|
34
|
+
/** Unique identifier for this flow/form (must match CRM-side registration) */
|
|
35
|
+
flowId: string;
|
|
36
|
+
/** Expected CRM origin for validation (e.g., "https://app.superleap.com"). Optional for RN. */
|
|
37
|
+
crmOrigin?: string;
|
|
38
|
+
/** Whether to auto-call SuperLeap.init() with the SDK config from the CRM. Default: true */
|
|
39
|
+
autoInit?: boolean;
|
|
40
|
+
/** Handshake timeout in milliseconds. Default: 5000 */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Context data provided by the CRM during handshake */
|
|
45
|
+
export interface CRMContext {
|
|
46
|
+
/** Organization ID */
|
|
47
|
+
orgId: string;
|
|
48
|
+
/** Current user ID */
|
|
49
|
+
userId: string;
|
|
50
|
+
/** Record ID (if iframe is in a record context) */
|
|
51
|
+
recordId?: string;
|
|
52
|
+
/** Object slug (e.g., "accounts", "contacts") */
|
|
53
|
+
objectSlug?: string;
|
|
54
|
+
/** Form ID (if iframe is inside a form) */
|
|
55
|
+
formId?: string;
|
|
56
|
+
/** Component ID within the form */
|
|
57
|
+
componentId?: string;
|
|
58
|
+
/** Any additional context data */
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Configuration received from the CRM */
|
|
63
|
+
export interface CRMConfig {
|
|
64
|
+
/** SDK configuration for SuperLeap.init() */
|
|
65
|
+
sdkConfig?: SuperLeapConfig;
|
|
66
|
+
/** Any additional configuration */
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Result of a successful SuperLeap.connect() call */
|
|
71
|
+
export interface ConnectResult {
|
|
72
|
+
/** Context data from the CRM */
|
|
73
|
+
context: CRMContext;
|
|
74
|
+
/** Configuration from the CRM */
|
|
75
|
+
config: CRMConfig;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Unsubscribe function returned by SuperLeap.on() */
|
|
79
|
+
export type EventUnsubscribe = () => void;
|
|
80
|
+
|
|
28
81
|
export interface SuperLeap {
|
|
82
|
+
// SDK Methods (from superleapClient.js)
|
|
29
83
|
init(config?: SuperLeapConfig): void;
|
|
30
84
|
getSdk(): any;
|
|
31
85
|
isAvailable(): boolean;
|
|
32
86
|
getDefaultConfig(): SuperLeapConfig;
|
|
87
|
+
|
|
88
|
+
// Bridge Methods (from crm.js)
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Connect to the CRM via postMessage bridge.
|
|
92
|
+
* Performs handshake, receives config, optionally auto-initializes the SDK.
|
|
93
|
+
* @returns Promise that resolves with context and config from the CRM
|
|
94
|
+
*/
|
|
95
|
+
connect(options: ConnectOptions): Promise<ConnectResult>;
|
|
96
|
+
|
|
97
|
+
/** Check if the bridge is connected to the CRM */
|
|
98
|
+
isConnected(): boolean;
|
|
99
|
+
|
|
100
|
+
/** Disconnect from the CRM and clean up listeners */
|
|
101
|
+
disconnect(): void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Tell the CRM to show or hide a loading overlay
|
|
105
|
+
* @param loading - Whether to show loading state
|
|
106
|
+
*/
|
|
107
|
+
setLoading(loading: boolean): void;
|
|
108
|
+
|
|
109
|
+
/** Tell the CRM to close the current form/modal */
|
|
110
|
+
closeForm(): void;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Tell the CRM to show a toast notification
|
|
114
|
+
* @param message - Toast message
|
|
115
|
+
* @param type - Toast type
|
|
116
|
+
* @param duration - Duration in milliseconds
|
|
117
|
+
*/
|
|
118
|
+
toast(
|
|
119
|
+
message: string,
|
|
120
|
+
type?: "success" | "error" | "warning" | "info",
|
|
121
|
+
duration?: number
|
|
122
|
+
): void;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Tell the CRM to navigate to a path
|
|
126
|
+
* @param path - Navigation path
|
|
127
|
+
*/
|
|
128
|
+
navigate(path: string): void;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Get the context data received from the CRM during handshake
|
|
132
|
+
* @returns Context object or null if not connected
|
|
133
|
+
*/
|
|
134
|
+
getContext(): CRMContext | null;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Send a custom event to the CRM
|
|
138
|
+
* @param event - Event name
|
|
139
|
+
* @param payload - Event data
|
|
140
|
+
*/
|
|
141
|
+
send(event: string, payload?: any): void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Listen for a custom event from the CRM
|
|
145
|
+
* @param event - Event name
|
|
146
|
+
* @param callback - Handler function
|
|
147
|
+
* @returns Unsubscribe function
|
|
148
|
+
*/
|
|
149
|
+
on(event: string, callback: (payload: any) => void): EventUnsubscribe;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Remove a specific event listener
|
|
153
|
+
* @param event - Event name
|
|
154
|
+
* @param callback - The same callback that was passed to on()
|
|
155
|
+
*/
|
|
156
|
+
off(event: string, callback: (payload: any) => void): void;
|
|
33
157
|
}
|
|
34
158
|
|
|
35
159
|
export const SuperLeap: SuperLeap;
|
|
@@ -37,7 +161,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
37
161
|
// ============================================================================
|
|
38
162
|
// STATE MANAGEMENT
|
|
39
163
|
// ============================================================================
|
|
40
|
-
|
|
164
|
+
|
|
41
165
|
export interface FlowUIState {
|
|
42
166
|
[key: string]: any;
|
|
43
167
|
}
|
|
@@ -45,7 +169,19 @@ declare module "@superleapai/flow-ui" {
|
|
|
45
169
|
export interface ButtonConfig {
|
|
46
170
|
text?: string;
|
|
47
171
|
label?: string;
|
|
48
|
-
variant?:
|
|
172
|
+
variant?:
|
|
173
|
+
| "primary"
|
|
174
|
+
| "outline"
|
|
175
|
+
| "ghost"
|
|
176
|
+
| "link"
|
|
177
|
+
| "primaryDestructive"
|
|
178
|
+
| "outlineDestructive"
|
|
179
|
+
| "ghostDestructive"
|
|
180
|
+
| "dashed"
|
|
181
|
+
| "toggleOff"
|
|
182
|
+
| "toggleOn"
|
|
183
|
+
| "ghostInline"
|
|
184
|
+
| "linkInline";
|
|
49
185
|
size?: "small" | "medium" | "default" | "large";
|
|
50
186
|
type?: "button" | "submit" | "reset";
|
|
51
187
|
disabled?: boolean;
|
|
@@ -62,7 +198,13 @@ declare module "@superleapai/flow-ui" {
|
|
|
62
198
|
required?: boolean;
|
|
63
199
|
type?: "text" | "email" | "number" | "password" | "tel" | "url";
|
|
64
200
|
helpText?: string;
|
|
65
|
-
variant?:
|
|
201
|
+
variant?:
|
|
202
|
+
| "default"
|
|
203
|
+
| "error"
|
|
204
|
+
| "warning"
|
|
205
|
+
| "success"
|
|
206
|
+
| "borderless"
|
|
207
|
+
| "inline";
|
|
66
208
|
inputSize?: "default" | "large" | "small";
|
|
67
209
|
disabled?: boolean;
|
|
68
210
|
showReadOnlyIcon?: boolean;
|
|
@@ -223,7 +365,13 @@ declare module "@superleapai/flow-ui" {
|
|
|
223
365
|
required?: boolean;
|
|
224
366
|
onChange?: (value: number | null) => void;
|
|
225
367
|
disabled?: boolean;
|
|
226
|
-
variant?:
|
|
368
|
+
variant?:
|
|
369
|
+
| "default"
|
|
370
|
+
| "error"
|
|
371
|
+
| "warning"
|
|
372
|
+
| "success"
|
|
373
|
+
| "borderless"
|
|
374
|
+
| "inline";
|
|
227
375
|
size?: "small" | "default" | "large";
|
|
228
376
|
helpText?: string;
|
|
229
377
|
}
|
|
@@ -239,7 +387,13 @@ declare module "@superleapai/flow-ui" {
|
|
|
239
387
|
onChange?: (count: number) => void;
|
|
240
388
|
disabled?: boolean;
|
|
241
389
|
readOnly?: boolean;
|
|
242
|
-
variant?:
|
|
390
|
+
variant?:
|
|
391
|
+
| "default"
|
|
392
|
+
| "error"
|
|
393
|
+
| "warning"
|
|
394
|
+
| "success"
|
|
395
|
+
| "borderless"
|
|
396
|
+
| "inline";
|
|
243
397
|
size?: "default" | "large" | "small";
|
|
244
398
|
helpText?: string;
|
|
245
399
|
}
|
|
@@ -387,7 +541,10 @@ declare module "@superleapai/flow-ui" {
|
|
|
387
541
|
|
|
388
542
|
export interface FlowUI {
|
|
389
543
|
// State management
|
|
390
|
-
initState(
|
|
544
|
+
initState(
|
|
545
|
+
initialState: FlowUIState,
|
|
546
|
+
onChangeCallback?: (state: FlowUIState) => void
|
|
547
|
+
): void;
|
|
391
548
|
getState(): FlowUIState;
|
|
392
549
|
setState(partial: Partial<FlowUIState>): void;
|
|
393
550
|
get(key: string): any;
|
|
@@ -399,7 +556,11 @@ declare module "@superleapai/flow-ui" {
|
|
|
399
556
|
// Screen utilities
|
|
400
557
|
createScreen(title: string, description: string): HTMLElement;
|
|
401
558
|
createGrid(): HTMLElement;
|
|
402
|
-
createFieldWrapper(
|
|
559
|
+
createFieldWrapper(
|
|
560
|
+
label: string,
|
|
561
|
+
required?: boolean,
|
|
562
|
+
helpText?: string | null
|
|
563
|
+
): HTMLElement;
|
|
403
564
|
|
|
404
565
|
// Form components
|
|
405
566
|
createInput(config: InputConfig): HTMLElement;
|
|
@@ -422,11 +583,29 @@ declare module "@superleapai/flow-ui" {
|
|
|
422
583
|
createButton(config: ButtonConfig): HTMLElement;
|
|
423
584
|
|
|
424
585
|
// Stepper
|
|
425
|
-
renderStepper(
|
|
586
|
+
renderStepper(
|
|
587
|
+
container: HTMLElement,
|
|
588
|
+
steps: StepConfig[],
|
|
589
|
+
currentStepId: string
|
|
590
|
+
): void;
|
|
426
591
|
|
|
427
592
|
// Alerts & Toasts
|
|
428
|
-
showToast(
|
|
429
|
-
|
|
593
|
+
showToast(
|
|
594
|
+
message: string,
|
|
595
|
+
type?: "success" | "error" | "warning" | "info" | "loading",
|
|
596
|
+
duration?: number
|
|
597
|
+
): ToastAPI;
|
|
598
|
+
renderAlerts(
|
|
599
|
+
container: HTMLElement,
|
|
600
|
+
messages?: (string | { title?: string; description?: string })[],
|
|
601
|
+
type?:
|
|
602
|
+
| "error"
|
|
603
|
+
| "info"
|
|
604
|
+
| "success"
|
|
605
|
+
| "warning"
|
|
606
|
+
| "destructive"
|
|
607
|
+
| "default"
|
|
608
|
+
): void;
|
|
430
609
|
|
|
431
610
|
// Table
|
|
432
611
|
createDataTable(config: DataTableConfig): HTMLElement;
|