@superleapai/flow-ui 2.1.1 → 2.2.2

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
@@ -123,64 +123,12 @@
123
123
  };
124
124
  }
125
125
  } else if (isBrowser) {
126
- // Browser environment - load all scripts dynamically
127
- console.log("[Superleap-Flow] Initializing library...");
126
+ // Browser environment - when bundled by Rollup, all components are already loaded
127
+ // When loaded directly (not bundled), this won't execute as all components are in same file
128
128
 
129
129
  // Internal component storage (keeps components in closure)
130
130
  const _components = {};
131
131
 
132
- // Get the script's base path
133
- const scripts = document.getElementsByTagName("script");
134
- const currentScript = scripts[scripts.length - 1];
135
- const basePath = currentScript.src.substring(
136
- 0,
137
- currentScript.src.lastIndexOf("/") + 1
138
- );
139
-
140
- // List of scripts to load in order
141
- const scriptsToLoad = [
142
- // Load SuperLeap SDK first
143
- "https://cdn.jsdelivr.net/npm/superleap-sdk@2.4.1/superleap.js",
144
- "core/superleapClient.js",
145
- "core/bridge.js",
146
- "core/crm.js",
147
- "components/toast.js",
148
- "components/alert.js",
149
- "components/label.js",
150
- "core/flow.js",
151
- "components/button.js",
152
- "components/spinner.js",
153
- "components/popover.js",
154
- "components/select.js",
155
- "components/enum-select.js",
156
- "components/record-select.js",
157
- "components/record-multiselect.js",
158
- "components/time-picker.js",
159
- "components/input.js",
160
- "components/currency.js",
161
- "components/textarea.js",
162
- "components/duration/duration-utils.js",
163
- "components/duration/duration-constants.js",
164
- "components/duration/duration.js",
165
- "components/date-time-picker/date-time-picker-utils.js",
166
- "components/date-time-picker/date-time-picker.js",
167
- "components/enumeration.js",
168
- "components/multiselect.js",
169
- "components/enum-multiselect.js",
170
- "components/badge.js",
171
- "components/avatar.js",
172
- "components/icon.js",
173
- "components/file-input.js",
174
- "components/phone-input/phone-utils.js",
175
- "components/phone-input/phone-input.js",
176
- "components/checkbox.js",
177
- "components/radio-group.js",
178
- "components/table.js",
179
- ];
180
-
181
- // Load scripts sequentially
182
- let loadedCount = 0;
183
-
184
132
  // Capture components from global scope into internal storage
185
133
  function captureComponents() {
186
134
  const componentNames = [
@@ -269,50 +217,25 @@
269
217
  }
270
218
  }
271
219
 
272
- function loadScript(index) {
273
- if (index >= scriptsToLoad.length) {
274
- console.log("[Superleap-Flow] All components loaded successfully");
275
-
276
- // Capture components into internal storage (also sets window.SuperLeap)
277
- captureComponents();
278
-
279
- // Dispatch custom event when library is ready
280
- if (typeof CustomEvent !== "undefined") {
281
- const event = new CustomEvent("superleap-flow:ready", {
282
- detail: {
283
- FlowUI: window.FlowUI,
284
- SuperLeap: window.SuperLeap,
285
- components: _components,
286
- },
287
- });
288
- document.dispatchEvent(event);
289
- }
290
- return;
291
- }
220
+ // When bundled, all components are already loaded - just capture and emit ready event
221
+ // Execute immediately (synchronously)
222
+ captureComponents();
292
223
 
293
- const script = document.createElement("script");
294
- // Handle CDN URLs vs local paths
295
- const scriptPath = scriptsToLoad[index];
296
- script.src = scriptPath.startsWith("http")
297
- ? scriptPath
298
- : basePath + scriptPath;
299
- script.async = false; // Ensure sequential loading
300
-
301
- script.onload = function () {
302
- loadedCount++;
303
- loadScript(index + 1);
304
- };
305
-
306
- script.onerror = function () {
307
- console.error("[Superleap-Flow] Failed to load:", scriptsToLoad[index]);
308
- loadScript(index + 1); // Continue loading other scripts
309
- };
310
-
311
- document.head.appendChild(script);
224
+ // Dispatch custom event when library is ready
225
+ if (typeof CustomEvent !== "undefined" && typeof document !== "undefined") {
226
+ // Use setTimeout to ensure this runs after all IIFEs have executed
227
+ setTimeout(function() {
228
+ const event = new CustomEvent("superleap-flow:ready", {
229
+ detail: {
230
+ FlowUI: window.FlowUI,
231
+ SuperLeap: window.SuperLeap,
232
+ components: _components,
233
+ },
234
+ });
235
+ document.dispatchEvent(event);
236
+ console.log("[Superleap-Flow] Library ready - v2.2.1");
237
+ }, 0);
312
238
  }
313
-
314
- // Start loading scripts
315
- loadScript(0);
316
239
  }
317
240
 
318
241
  // ES Module export (for bundlers like webpack, rollup, vite)
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@superleapai/flow-ui",
3
- "version": "2.1.1",
3
+ "version": "2.2.2",
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
- "main": "index.js",
5
+ "main": "dist/superleap-flow.min.js",
6
6
  "types": "index.d.ts",
7
- "browser": "index.js",
7
+ "browser": "dist/superleap-flow.min.js",
8
+ "unpkg": "dist/superleap-flow.min.js",
9
+ "jsdelivr": "dist/superleap-flow.min.js",
8
10
  "files": [
9
11
  "core/",
10
12
  "components/",
@@ -17,9 +19,14 @@
17
19
  "CHANGELOG.md"
18
20
  ],
19
21
  "scripts": {
22
+ "build": "npm run build:js && npm run build:css",
23
+ "build:js": "rollup -c",
24
+ "build:js:dev": "BUILD=development rollup -c",
25
+ "build:js:prod": "BUILD=production rollup -c",
20
26
  "build:css": "npx tailwindcss -i ./tailwind-input.css -o ./dist/output.css --minify",
27
+ "watch": "rollup -c -w",
21
28
  "watch:css": "npx tailwindcss -i ./tailwind-input.css -o ./dist/output.css --watch",
22
- "prepublishOnly": "npm run build:css"
29
+ "prepublishOnly": "npm run build"
23
30
  },
24
31
  "keywords": [
25
32
  "ui",
@@ -61,6 +68,10 @@
61
68
  "tailwindcss": "^3.0.0"
62
69
  },
63
70
  "devDependencies": {
71
+ "@rollup/plugin-terser": "^0.4.4",
72
+ "glob": "^13.0.2",
73
+ "rollup": "^4.57.1",
74
+ "superleap-sdk": "^2.4.1",
64
75
  "tailwindcss": "^3.4.0",
65
76
  "tailwindcss-animate": "^1.0.7"
66
77
  }