@superleapai/flow-ui 2.5.13 → 2.5.15

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.js CHANGED
@@ -105,7 +105,6 @@
105
105
  init: global.superleapClient.init,
106
106
  getSdk: global.superleapClient.getSdk,
107
107
  isAvailable: global.superleapClient.isAvailable,
108
- getDefaultConfig: global.superleapClient.getDefaultConfig,
109
108
  getBaseUrl: global.superleapClient.getBaseUrl,
110
109
  }
111
110
  : null;
@@ -121,7 +120,6 @@
121
120
  init: window.superleapClient.init,
122
121
  getSdk: window.superleapClient.getSdk,
123
122
  isAvailable: window.superleapClient.isAvailable,
124
- getDefaultConfig: window.superleapClient.getDefaultConfig,
125
123
  getBaseUrl: window.superleapClient.getBaseUrl,
126
124
  }
127
125
  : null;
@@ -205,7 +203,6 @@
205
203
  init: client.init.bind(client),
206
204
  getSdk: client.getSdk.bind(client),
207
205
  isAvailable: client.isAvailable.bind(client),
208
- getDefaultConfig: client.getDefaultConfig.bind(client),
209
206
  getBaseUrl: client.getBaseUrl.bind(client),
210
207
  // Bridge methods (from crm.js)
211
208
  connect: client.connect ? client.connect.bind(client) : undefined,
@@ -237,27 +234,10 @@
237
234
  // Execute immediately (synchronously)
238
235
  captureComponents();
239
236
 
240
- // Auto-initialize SDK with default config if not in iframe context
241
- // This allows standalone testing without calling SuperLeap.init() manually
242
- // In iframe context, SuperLeap.connect() will reinitialize with CRM config
243
- const client = _components["superleapClient"];
244
- if (client && typeof client.init === "function") {
245
- // Check if we're NOT in an iframe context (standalone usage)
246
- const isStandalone = window === window.parent;
247
- if (isStandalone && !client.isAvailable()) {
248
- // Auto-init with default config for standalone testing
249
- client.init(client.getDefaultConfig());
250
- console.log(
251
- "[Superleap-Flow] SDK auto-initialized for standalone mode"
252
- );
253
- }
254
- }
255
-
256
- // Dispatch custom event when library is ready
257
- if (typeof CustomEvent !== "undefined" && typeof document !== "undefined") {
258
- // Function to dispatch the ready event
259
- function dispatchReady() {
260
- const event = new CustomEvent("superleap-flow:ready", {
237
+ // Function to dispatch the ready event
238
+ function dispatchReady() {
239
+ if (typeof CustomEvent !== "undefined" && typeof document !== "undefined") {
240
+ var event = new CustomEvent("superleap-flow:ready", {
261
241
  detail: {
262
242
  FlowUI: window.FlowUI,
263
243
  SuperLeap: window.SuperLeap,
@@ -267,13 +247,43 @@
267
247
  document.dispatchEvent(event);
268
248
  console.log("[Superleap-Flow] Library ready - v__VERSION__");
269
249
  }
250
+ }
251
+
252
+ // Check if we're in an iframe context with a bridgeId
253
+ var isInIframe = window !== window.parent;
254
+ var urlParams = new URLSearchParams(window.location.search);
255
+ var bridgeId = urlParams.get("_bridgeId");
256
+
257
+ if (isInIframe && bridgeId && window.SuperLeap && window.SuperLeap.connect) {
258
+ // Auto-connect to CRM — defer ready event until connected
259
+ function doAutoConnect() {
260
+ window.SuperLeap.connect({ bridgeId: bridgeId })
261
+ .then(function () {
262
+ // Expose SDK as a direct global so users can write sdkInstance.getModel() directly
263
+ if (window.SuperLeap && typeof window.SuperLeap.getSdk === "function") {
264
+ window.sdkInstance = window.SuperLeap.getSdk();
265
+ }
266
+ dispatchReady();
267
+ })
268
+ .catch(function (err) {
269
+ console.error("[Superleap-Flow] Auto-connect failed:", err);
270
+ // Still dispatch ready so user code can handle the error
271
+ dispatchReady();
272
+ });
273
+ }
270
274
 
271
- // Wait for DOM to be ready before dispatching event
275
+ // Wait for DOM to be ready before auto-connecting
276
+ if (document.readyState === "loading") {
277
+ document.addEventListener("DOMContentLoaded", doAutoConnect);
278
+ } else {
279
+ setTimeout(doAutoConnect, 0);
280
+ }
281
+ } else {
282
+ // Standalone mode — user must call SuperLeap.init(config) manually
283
+ // Dispatch ready immediately (no connection needed)
272
284
  if (document.readyState === "loading") {
273
- // DOM is still loading, wait for DOMContentLoaded
274
285
  document.addEventListener("DOMContentLoaded", dispatchReady);
275
286
  } else {
276
- // DOM is already ready, dispatch immediately (but async)
277
287
  setTimeout(dispatchReady, 0);
278
288
  }
279
289
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superleapai/flow-ui",
3
- "version": "2.5.13",
3
+ "version": "2.5.15",
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",