@superleapai/flow-ui 2.5.18 → 2.5.20
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/CHANGELOG.md +2 -2
- package/LICENSE +1 -1
- package/README.md +38 -38
- package/components/enum-multiselect.js +119 -56
- package/components/enum-select.js +90 -48
- package/components/file-input.js +111 -49
- package/components/multiselect.js +70 -3
- package/components/select.js +87 -55
- package/core/bridge.js +4 -6
- package/core/crm.js +17 -17
- package/core/flow.js +236 -61
- package/core/superleapClient.js +2 -2
- package/dist/superleap-flow.min.js +2 -2
- package/index.d.ts +33 -20
- package/index.js +41 -30
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -29,13 +29,13 @@ declare module "@superleapai/flow-ui" {
|
|
|
29
29
|
// CRM BRIDGE TYPES
|
|
30
30
|
// ============================================================================
|
|
31
31
|
|
|
32
|
-
/** Configuration passed to
|
|
32
|
+
/** Configuration passed to Superleap.connect() */
|
|
33
33
|
export interface ConnectOptions {
|
|
34
34
|
/** Unique identifier for this flow/form (must match CRM-side registration) */
|
|
35
35
|
flowId: string;
|
|
36
36
|
/** Expected CRM origin for validation (e.g., "https://app.superleap.com"). Optional for RN. */
|
|
37
37
|
crmOrigin?: string;
|
|
38
|
-
/** Whether to auto-call
|
|
38
|
+
/** Whether to auto-call Superleap.init() with the SDK config from the CRM. Default: true */
|
|
39
39
|
autoInit?: boolean;
|
|
40
40
|
/** Handshake timeout in milliseconds. Default: 5000 */
|
|
41
41
|
timeout?: number;
|
|
@@ -61,13 +61,13 @@ declare module "@superleapai/flow-ui" {
|
|
|
61
61
|
|
|
62
62
|
/** Configuration received from the CRM */
|
|
63
63
|
export interface CRMConfig {
|
|
64
|
-
/** SDK configuration for
|
|
64
|
+
/** SDK configuration for Superleap.init() */
|
|
65
65
|
sdkConfig?: SuperLeapConfig;
|
|
66
66
|
/** Any additional configuration */
|
|
67
67
|
[key: string]: any;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/** Result of a successful
|
|
70
|
+
/** Result of a successful Superleap.connect() call */
|
|
71
71
|
export interface ConnectResult {
|
|
72
72
|
/** Context data from the CRM */
|
|
73
73
|
context: CRMContext;
|
|
@@ -75,10 +75,10 @@ declare module "@superleapai/flow-ui" {
|
|
|
75
75
|
config: CRMConfig;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/** Unsubscribe function returned by
|
|
78
|
+
/** Unsubscribe function returned by Superleap.on() */
|
|
79
79
|
export type EventUnsubscribe = () => void;
|
|
80
80
|
|
|
81
|
-
export interface
|
|
81
|
+
export interface Superleap {
|
|
82
82
|
// SDK Methods (from superleapClient.js)
|
|
83
83
|
init(config?: SuperLeapConfig): void;
|
|
84
84
|
getSdk(): any;
|
|
@@ -112,12 +112,11 @@ declare module "@superleapai/flow-ui" {
|
|
|
112
112
|
closeForm(): void;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
116
|
-
* The CRM
|
|
117
|
-
* @param
|
|
118
|
-
* @returns Unsubscribe function
|
|
115
|
+
* Notify the CRM that the form was submitted successfully.
|
|
116
|
+
* The CRM listens for this event and can react (e.g. close the form, refresh data).
|
|
117
|
+
* @param payload - Optional data about the submission
|
|
119
118
|
*/
|
|
120
|
-
|
|
119
|
+
formSubmittedSuccessfully(payload?: any): void;
|
|
121
120
|
|
|
122
121
|
/**
|
|
123
122
|
* Tell the CRM to show a toast notification
|
|
@@ -128,7 +127,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
128
127
|
toast(
|
|
129
128
|
message: string,
|
|
130
129
|
type?: "success" | "error" | "warning" | "info",
|
|
131
|
-
duration?: number
|
|
130
|
+
duration?: number,
|
|
132
131
|
): void;
|
|
133
132
|
|
|
134
133
|
/**
|
|
@@ -167,7 +166,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
167
166
|
off(event: string, callback: (payload: any) => void): void;
|
|
168
167
|
}
|
|
169
168
|
|
|
170
|
-
export const
|
|
169
|
+
export const Superleap: Superleap;
|
|
171
170
|
|
|
172
171
|
// ============================================================================
|
|
173
172
|
// STATE MANAGEMENT
|
|
@@ -246,6 +245,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
246
245
|
options: SelectOption[];
|
|
247
246
|
required?: boolean;
|
|
248
247
|
onChange?: (value: string) => void;
|
|
248
|
+
showSearch?: boolean;
|
|
249
249
|
disabled?: boolean;
|
|
250
250
|
helpText?: string;
|
|
251
251
|
}
|
|
@@ -262,7 +262,13 @@ declare module "@superleapai/flow-ui" {
|
|
|
262
262
|
/** 'default' | 'small' | 'large' */
|
|
263
263
|
size?: "default" | "small" | "large";
|
|
264
264
|
/** 'default' | 'error' | 'warning' | 'success' | 'borderless' | 'inline' */
|
|
265
|
-
variant?:
|
|
265
|
+
variant?:
|
|
266
|
+
| "default"
|
|
267
|
+
| "error"
|
|
268
|
+
| "warning"
|
|
269
|
+
| "success"
|
|
270
|
+
| "borderless"
|
|
271
|
+
| "inline";
|
|
266
272
|
helpText?: string;
|
|
267
273
|
}
|
|
268
274
|
|
|
@@ -278,7 +284,13 @@ declare module "@superleapai/flow-ui" {
|
|
|
278
284
|
granularity?: "day" | "hour" | "minute" | "second";
|
|
279
285
|
size?: "small" | "default" | "large";
|
|
280
286
|
/** 'default' | 'error' | 'warning' | 'success' | 'borderless' | 'inline' */
|
|
281
|
-
variant?:
|
|
287
|
+
variant?:
|
|
288
|
+
| "default"
|
|
289
|
+
| "error"
|
|
290
|
+
| "warning"
|
|
291
|
+
| "success"
|
|
292
|
+
| "borderless"
|
|
293
|
+
| "inline";
|
|
282
294
|
fromDate?: Date;
|
|
283
295
|
toDate?: Date;
|
|
284
296
|
helpText?: string;
|
|
@@ -301,6 +313,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
301
313
|
options: SelectOption[];
|
|
302
314
|
required?: boolean;
|
|
303
315
|
onChange?: (values: string[]) => void;
|
|
316
|
+
showSearch?: boolean;
|
|
304
317
|
placeholder?: string;
|
|
305
318
|
helpText?: string;
|
|
306
319
|
variant?: "default" | "error" | "warning" | "borderless" | "inline";
|
|
@@ -594,7 +607,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
594
607
|
// State management
|
|
595
608
|
initState(
|
|
596
609
|
initialState: FlowUIState,
|
|
597
|
-
onChangeCallback?: (state: FlowUIState) => void
|
|
610
|
+
onChangeCallback?: (state: FlowUIState) => void,
|
|
598
611
|
): void;
|
|
599
612
|
getState(): FlowUIState;
|
|
600
613
|
setState(partial: Partial<FlowUIState>): void;
|
|
@@ -610,7 +623,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
610
623
|
createFieldWrapper(
|
|
611
624
|
label: string,
|
|
612
625
|
required?: boolean,
|
|
613
|
-
helpText?: string | null
|
|
626
|
+
helpText?: string | null,
|
|
614
627
|
): HTMLElement;
|
|
615
628
|
|
|
616
629
|
// Form components
|
|
@@ -637,7 +650,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
637
650
|
renderStepper(
|
|
638
651
|
container: HTMLElement,
|
|
639
652
|
steps: StepConfig[],
|
|
640
|
-
currentStepId: string
|
|
653
|
+
currentStepId: string,
|
|
641
654
|
): void;
|
|
642
655
|
createTabs(config: TabsConfig): HTMLElement;
|
|
643
656
|
createSteps(config: StepsConfig): HTMLElement;
|
|
@@ -646,7 +659,7 @@ declare module "@superleapai/flow-ui" {
|
|
|
646
659
|
showToast(
|
|
647
660
|
message: string,
|
|
648
661
|
type?: "success" | "error" | "warning" | "info" | "loading",
|
|
649
|
-
duration?: number
|
|
662
|
+
duration?: number,
|
|
650
663
|
): ToastAPI;
|
|
651
664
|
|
|
652
665
|
// Table
|
|
@@ -674,6 +687,6 @@ declare module "@superleapai/flow-ui" {
|
|
|
674
687
|
declare global {
|
|
675
688
|
interface Window {
|
|
676
689
|
FlowUI: FlowUI;
|
|
677
|
-
|
|
690
|
+
Superleap: Superleap;
|
|
678
691
|
}
|
|
679
692
|
}
|
package/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Superleap-Flow Library Entry Point
|
|
3
3
|
* @superleapai/flow-ui
|
|
4
4
|
*
|
|
5
|
-
* Single-file bundle that includes
|
|
6
|
-
* Only FlowUI and
|
|
5
|
+
* Single-file bundle that includes Superleap SDK and all components.
|
|
6
|
+
* Only FlowUI and Superleap are exposed to global scope.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
9
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* <script src="path/to/superleap-flow/index.js"></script>
|
|
12
12
|
* <script>
|
|
13
13
|
* // Connect to CRM (inside an iframe)
|
|
14
|
-
* const { context, config } = await
|
|
14
|
+
* const { context, config } = await Superleap.connect({
|
|
15
15
|
* flowId: 'my-flow'
|
|
16
16
|
* });
|
|
17
17
|
* // SDK is auto-initialized, context has orgId/userId/etc.
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
* FlowUI.initState({ name: '' });
|
|
21
21
|
*
|
|
22
22
|
* // CRM actions
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Superleap.toast('Saved!', 'success');
|
|
24
|
+
* Superleap.closeForm();
|
|
25
25
|
* </script>
|
|
26
26
|
*
|
|
27
27
|
* ES Module:
|
|
28
|
-
* import { FlowUI,
|
|
28
|
+
* import { FlowUI, Superleap } from '@superleapai/flow-ui';
|
|
29
29
|
*
|
|
30
30
|
* CommonJS:
|
|
31
|
-
* const { FlowUI,
|
|
31
|
+
* const { FlowUI, Superleap } = require('@superleapai/flow-ui');
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
(function (global) {
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
|
|
42
42
|
// In Node.js/CommonJS environment, load all modules
|
|
43
43
|
if (isNode && !isBrowser) {
|
|
44
|
-
// Note: In Node.js,
|
|
44
|
+
// Note: In Node.js, Superleap SDK should be installed separately via npm
|
|
45
45
|
// npm install superleap-sdk
|
|
46
46
|
try {
|
|
47
47
|
global.createSuperLeapSDK = require("superleap-sdk");
|
|
48
48
|
} catch (e) {
|
|
49
49
|
console.warn(
|
|
50
|
-
"[Superleap-Flow]
|
|
50
|
+
"[Superleap-Flow] Superleap SDK not found. Install with: npm install superleap-sdk",
|
|
51
51
|
);
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -97,10 +97,10 @@
|
|
|
97
97
|
require("./components/tabs.js");
|
|
98
98
|
require("./components/steps.js");
|
|
99
99
|
|
|
100
|
-
// Export FlowUI and
|
|
100
|
+
// Export FlowUI and Superleap from global scope
|
|
101
101
|
if (typeof global !== "undefined" && global.FlowUI) {
|
|
102
|
-
// Create
|
|
103
|
-
const
|
|
102
|
+
// Create Superleap export
|
|
103
|
+
const Superleap = global.superleapClient
|
|
104
104
|
? {
|
|
105
105
|
init: global.superleapClient.init,
|
|
106
106
|
getSdk: global.superleapClient.getSdk,
|
|
@@ -111,11 +111,11 @@
|
|
|
111
111
|
|
|
112
112
|
module.exports = {
|
|
113
113
|
FlowUI: global.FlowUI,
|
|
114
|
-
|
|
114
|
+
Superleap: Superleap,
|
|
115
115
|
};
|
|
116
116
|
} else if (typeof window !== "undefined" && window.FlowUI) {
|
|
117
|
-
// Create
|
|
118
|
-
const
|
|
117
|
+
// Create Superleap export
|
|
118
|
+
const Superleap = window.superleapClient
|
|
119
119
|
? {
|
|
120
120
|
init: window.superleapClient.init,
|
|
121
121
|
getSdk: window.superleapClient.getSdk,
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
|
|
127
127
|
module.exports = {
|
|
128
128
|
FlowUI: window.FlowUI,
|
|
129
|
-
|
|
129
|
+
Superleap: Superleap,
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
} else if (isBrowser) {
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
_components[name] = window[name];
|
|
183
183
|
|
|
184
184
|
// Clean up global scope - remove all component globals
|
|
185
|
-
// Only FlowUI and
|
|
185
|
+
// Only FlowUI and Superleap will remain
|
|
186
186
|
delete window[name];
|
|
187
187
|
}
|
|
188
188
|
});
|
|
@@ -194,11 +194,11 @@
|
|
|
194
194
|
};
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
// Expose
|
|
197
|
+
// Expose Superleap from captured superleapClient (must use _components - superleapClient was already deleted from window)
|
|
198
198
|
// Note: crm.js has already extended superleapClient with bridge methods (connect, toast, etc.)
|
|
199
199
|
const client = _components["superleapClient"];
|
|
200
200
|
if (client) {
|
|
201
|
-
window.
|
|
201
|
+
window.Superleap = {
|
|
202
202
|
// SDK methods (from superleapClient.js)
|
|
203
203
|
init: client.init.bind(client),
|
|
204
204
|
getSdk: client.getSdk.bind(client),
|
|
@@ -218,8 +218,8 @@
|
|
|
218
218
|
closeForm: client.closeForm
|
|
219
219
|
? client.closeForm.bind(client)
|
|
220
220
|
: undefined,
|
|
221
|
-
|
|
222
|
-
? client.
|
|
221
|
+
formSubmittedSuccessfully: client.formSubmittedSuccessfully
|
|
222
|
+
? client.formSubmittedSuccessfully.bind(client)
|
|
223
223
|
: undefined,
|
|
224
224
|
toast: client.toast ? client.toast.bind(client) : undefined,
|
|
225
225
|
navigate: client.navigate ? client.navigate.bind(client) : undefined,
|
|
@@ -239,11 +239,14 @@
|
|
|
239
239
|
|
|
240
240
|
// Function to dispatch the ready event
|
|
241
241
|
function dispatchReady() {
|
|
242
|
-
if (
|
|
242
|
+
if (
|
|
243
|
+
typeof CustomEvent !== "undefined" &&
|
|
244
|
+
typeof document !== "undefined"
|
|
245
|
+
) {
|
|
243
246
|
var event = new CustomEvent("superleap-flow:ready", {
|
|
244
247
|
detail: {
|
|
245
248
|
FlowUI: window.FlowUI,
|
|
246
|
-
|
|
249
|
+
Superleap: window.Superleap,
|
|
247
250
|
components: _components,
|
|
248
251
|
},
|
|
249
252
|
});
|
|
@@ -257,14 +260,22 @@
|
|
|
257
260
|
var urlParams = new URLSearchParams(window.location.search);
|
|
258
261
|
var bridgeId = urlParams.get("_bridgeId");
|
|
259
262
|
|
|
260
|
-
if (
|
|
263
|
+
if (
|
|
264
|
+
isInIframe &&
|
|
265
|
+
bridgeId &&
|
|
266
|
+
window.Superleap &&
|
|
267
|
+
window.Superleap.connect
|
|
268
|
+
) {
|
|
261
269
|
// Auto-connect to CRM — defer ready event until connected
|
|
262
270
|
function doAutoConnect() {
|
|
263
|
-
window.
|
|
271
|
+
window.Superleap.connect({ bridgeId: bridgeId })
|
|
264
272
|
.then(function () {
|
|
265
273
|
// Expose SDK as a direct global so users can write sdkInstance.getModel() directly
|
|
266
|
-
if (
|
|
267
|
-
window.
|
|
274
|
+
if (
|
|
275
|
+
window.Superleap &&
|
|
276
|
+
typeof window.Superleap.getSdk === "function"
|
|
277
|
+
) {
|
|
278
|
+
window.sdkInstance = window.Superleap.getSdk();
|
|
268
279
|
}
|
|
269
280
|
dispatchReady();
|
|
270
281
|
})
|
|
@@ -282,7 +293,7 @@
|
|
|
282
293
|
setTimeout(doAutoConnect, 0);
|
|
283
294
|
}
|
|
284
295
|
} else {
|
|
285
|
-
// Standalone mode — user must call
|
|
296
|
+
// Standalone mode — user must call Superleap.init(config) manually
|
|
286
297
|
// Dispatch ready immediately (no connection needed)
|
|
287
298
|
if (document.readyState === "loading") {
|
|
288
299
|
document.addEventListener("DOMContentLoaded", dispatchReady);
|
|
@@ -296,7 +307,7 @@
|
|
|
296
307
|
if (typeof window !== "undefined" && window.FlowUI) {
|
|
297
308
|
if (typeof exports !== "undefined") {
|
|
298
309
|
exports.FlowUI = window.FlowUI;
|
|
299
|
-
exports.
|
|
310
|
+
exports.Superleap = window.Superleap;
|
|
300
311
|
}
|
|
301
312
|
}
|
|
302
313
|
|
|
@@ -307,6 +318,6 @@
|
|
|
307
318
|
typeof exports !== "undefined"
|
|
308
319
|
) {
|
|
309
320
|
exports.FlowUI = global.FlowUI;
|
|
310
|
-
exports.
|
|
321
|
+
exports.Superleap = global.Superleap;
|
|
311
322
|
}
|
|
312
323
|
})(typeof window !== "undefined" ? window : this);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superleapai/flow-ui",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.20",
|
|
4
4
|
"description": "A reusable design system for building multi-step forms with comprehensive UI components. Single file, clean globals, SDK included. Only FlowUI and SuperLeap exposed.",
|
|
5
5
|
"main": "dist/superleap-flow.min.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"notifications",
|
|
51
51
|
"superleap"
|
|
52
52
|
],
|
|
53
|
-
"author": "
|
|
53
|
+
"author": "Superleap",
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"repository": {
|
|
56
56
|
"type": "git",
|