@superleapai/flow-ui 2.2.2 → 2.2.4

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
@@ -223,8 +223,8 @@
223
223
 
224
224
  // Dispatch custom event when library is ready
225
225
  if (typeof CustomEvent !== "undefined" && typeof document !== "undefined") {
226
- // Use setTimeout to ensure this runs after all IIFEs have executed
227
- setTimeout(function() {
226
+ // Function to dispatch the ready event
227
+ function dispatchReady() {
228
228
  const event = new CustomEvent("superleap-flow:ready", {
229
229
  detail: {
230
230
  FlowUI: window.FlowUI,
@@ -233,8 +233,17 @@
233
233
  },
234
234
  });
235
235
  document.dispatchEvent(event);
236
- console.log("[Superleap-Flow] Library ready - v2.2.1");
237
- }, 0);
236
+ console.log("[Superleap-Flow] Library ready - v2.2.2");
237
+ }
238
+
239
+ // Wait for DOM to be ready before dispatching event
240
+ if (document.readyState === "loading") {
241
+ // DOM is still loading, wait for DOMContentLoaded
242
+ document.addEventListener("DOMContentLoaded", dispatchReady);
243
+ } else {
244
+ // DOM is already ready, dispatch immediately (but async)
245
+ setTimeout(dispatchReady, 0);
246
+ }
238
247
  }
239
248
  }
240
249
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superleapai/flow-ui",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
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",