@superleapai/flow-ui 2.5.19 → 2.5.21

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/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 SuperLeap.connect() */
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 SuperLeap.init() with the SDK config from the CRM. Default: true */
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 SuperLeap.init() */
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 SuperLeap.connect() call */
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 SuperLeap.on() */
78
+ /** Unsubscribe function returned by Superleap.on() */
79
79
  export type EventUnsubscribe = () => void;
80
80
 
81
- export interface SuperLeap {
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
- * Register a callback for when the CRM form is submitted successfully.
116
- * The CRM sends a notification after the form saves.
117
- * @param callback - Handler called with the submission payload
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
- onFormSubmitSuccess(callback: (payload: any) => void): EventUnsubscribe;
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 SuperLeap: SuperLeap;
169
+ export const Superleap: Superleap;
171
170
 
172
171
  // ============================================================================
173
172
  // STATE MANAGEMENT
@@ -263,7 +262,13 @@ declare module "@superleapai/flow-ui" {
263
262
  /** 'default' | 'small' | 'large' */
264
263
  size?: "default" | "small" | "large";
265
264
  /** 'default' | 'error' | 'warning' | 'success' | 'borderless' | 'inline' */
266
- variant?: "default" | "error" | "warning" | "success" | "borderless" | "inline";
265
+ variant?:
266
+ | "default"
267
+ | "error"
268
+ | "warning"
269
+ | "success"
270
+ | "borderless"
271
+ | "inline";
267
272
  helpText?: string;
268
273
  }
269
274
 
@@ -279,7 +284,13 @@ declare module "@superleapai/flow-ui" {
279
284
  granularity?: "day" | "hour" | "minute" | "second";
280
285
  size?: "small" | "default" | "large";
281
286
  /** 'default' | 'error' | 'warning' | 'success' | 'borderless' | 'inline' */
282
- variant?: "default" | "error" | "warning" | "success" | "borderless" | "inline";
287
+ variant?:
288
+ | "default"
289
+ | "error"
290
+ | "warning"
291
+ | "success"
292
+ | "borderless"
293
+ | "inline";
283
294
  fromDate?: Date;
284
295
  toDate?: Date;
285
296
  helpText?: string;
@@ -596,7 +607,7 @@ declare module "@superleapai/flow-ui" {
596
607
  // State management
597
608
  initState(
598
609
  initialState: FlowUIState,
599
- onChangeCallback?: (state: FlowUIState) => void
610
+ onChangeCallback?: (state: FlowUIState) => void,
600
611
  ): void;
601
612
  getState(): FlowUIState;
602
613
  setState(partial: Partial<FlowUIState>): void;
@@ -612,7 +623,7 @@ declare module "@superleapai/flow-ui" {
612
623
  createFieldWrapper(
613
624
  label: string,
614
625
  required?: boolean,
615
- helpText?: string | null
626
+ helpText?: string | null,
616
627
  ): HTMLElement;
617
628
 
618
629
  // Form components
@@ -639,7 +650,7 @@ declare module "@superleapai/flow-ui" {
639
650
  renderStepper(
640
651
  container: HTMLElement,
641
652
  steps: StepConfig[],
642
- currentStepId: string
653
+ currentStepId: string,
643
654
  ): void;
644
655
  createTabs(config: TabsConfig): HTMLElement;
645
656
  createSteps(config: StepsConfig): HTMLElement;
@@ -648,7 +659,7 @@ declare module "@superleapai/flow-ui" {
648
659
  showToast(
649
660
  message: string,
650
661
  type?: "success" | "error" | "warning" | "info" | "loading",
651
- duration?: number
662
+ duration?: number,
652
663
  ): ToastAPI;
653
664
 
654
665
  // Table
@@ -676,6 +687,6 @@ declare module "@superleapai/flow-ui" {
676
687
  declare global {
677
688
  interface Window {
678
689
  FlowUI: FlowUI;
679
- SuperLeap: SuperLeap;
690
+ Superleap: Superleap;
680
691
  }
681
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 SuperLeap SDK and all components.
6
- * Only FlowUI and SuperLeap are exposed to global scope.
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 SuperLeap.connect({
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
- * SuperLeap.toast('Saved!', 'success');
24
- * SuperLeap.closeForm();
23
+ * Superleap.toast('Saved!', 'success');
24
+ * Superleap.closeForm();
25
25
  * </script>
26
26
  *
27
27
  * ES Module:
28
- * import { FlowUI, SuperLeap } from '@superleapai/flow-ui';
28
+ * import { FlowUI, Superleap } from '@superleapai/flow-ui';
29
29
  *
30
30
  * CommonJS:
31
- * const { FlowUI, SuperLeap } = require('@superleapai/flow-ui');
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, SuperLeap SDK should be installed separately via npm
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] SuperLeap SDK not found. Install with: npm install superleap-sdk"
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 SuperLeap from global scope
100
+ // Export FlowUI and Superleap from global scope
101
101
  if (typeof global !== "undefined" && global.FlowUI) {
102
- // Create SuperLeap export
103
- const SuperLeap = global.superleapClient
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
- SuperLeap: SuperLeap,
114
+ Superleap: Superleap,
115
115
  };
116
116
  } else if (typeof window !== "undefined" && window.FlowUI) {
117
- // Create SuperLeap export
118
- const SuperLeap = window.superleapClient
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
- SuperLeap: SuperLeap,
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 SuperLeap will remain
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 SuperLeap from captured superleapClient (must use _components - superleapClient was already deleted from window)
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.SuperLeap = {
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
- onFormSubmitSuccess: client.onFormSubmitSuccess
222
- ? client.onFormSubmitSuccess.bind(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 (typeof CustomEvent !== "undefined" && typeof document !== "undefined") {
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
- SuperLeap: window.SuperLeap,
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 (isInIframe && bridgeId && window.SuperLeap && window.SuperLeap.connect) {
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.SuperLeap.connect({ bridgeId: bridgeId })
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 (window.SuperLeap && typeof window.SuperLeap.getSdk === "function") {
267
- window.sdkInstance = window.SuperLeap.getSdk();
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 SuperLeap.init(config) manually
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.SuperLeap = window.SuperLeap;
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.SuperLeap = global.SuperLeap;
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.19",
3
+ "version": "2.5.21",
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": "SuperLeap",
53
+ "author": "Superleap",
54
54
  "license": "MIT",
55
55
  "repository": {
56
56
  "type": "git",