@superleapai/flow-ui 1.0.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/LICENSE +21 -0
  3. package/README.md +451 -0
  4. package/components/alert.js +282 -0
  5. package/components/avatar.js +195 -0
  6. package/components/badge.js +135 -0
  7. package/components/button.js +201 -0
  8. package/components/checkbox.js +254 -0
  9. package/components/currency.js +227 -0
  10. package/components/date-time-picker/date-time-picker-utils.js +253 -0
  11. package/components/date-time-picker/date-time-picker.js +532 -0
  12. package/components/duration/duration-constants.js +46 -0
  13. package/components/duration/duration-utils.js +164 -0
  14. package/components/duration/duration.js +448 -0
  15. package/components/enum-multiselect.js +869 -0
  16. package/components/enum-select.js +831 -0
  17. package/components/enumeration.js +213 -0
  18. package/components/file-input.js +533 -0
  19. package/components/icon.js +200 -0
  20. package/components/input.js +259 -0
  21. package/components/label.js +111 -0
  22. package/components/multiselect.js +351 -0
  23. package/components/phone-input/phone-input.js +392 -0
  24. package/components/phone-input/phone-utils.js +157 -0
  25. package/components/popover.js +240 -0
  26. package/components/radio-group.js +435 -0
  27. package/components/record-multiselect.js +956 -0
  28. package/components/record-select.js +930 -0
  29. package/components/select.js +544 -0
  30. package/components/spinner.js +136 -0
  31. package/components/table.js +335 -0
  32. package/components/textarea.js +114 -0
  33. package/components/time-picker.js +357 -0
  34. package/components/toast.js +343 -0
  35. package/core/flow.js +1729 -0
  36. package/core/superleapClient.js +146 -0
  37. package/dist/output.css +2 -0
  38. package/index.d.ts +458 -0
  39. package/index.js +253 -0
  40. package/package.json +70 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,65 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2026-02-06
9
+
10
+ ### Added
11
+ - Initial release of @superleap/superleap-flow
12
+ - Core state management system with `initState`, `getState`, `setState`, `get`, `set`
13
+ - Screen utilities: `createScreen`, `createGrid`, `createFieldWrapper`
14
+ - Form components:
15
+ - Input (text, email, number, password, tel, url)
16
+ - Textarea
17
+ - Select dropdown
18
+ - Multi-select (count and tags display)
19
+ - Radio group
20
+ - Checkbox (with indeterminate state)
21
+ - Button (multiple variants)
22
+ - Time picker (12/24 hour)
23
+ - Date-time picker
24
+ - Phone input (international)
25
+ - Currency input
26
+ - File upload
27
+ - Record select (SuperLeap integration)
28
+ - Record multi-select
29
+ - Enumeration select/multi-select
30
+ - Advanced components:
31
+ - Data table with selection
32
+ - Search input
33
+ - Stepper for multi-step forms
34
+ - Toast notifications (success, error, warning, info, loading)
35
+ - Alert messages
36
+ - Summary/review rows
37
+ - Badge
38
+ - Popover
39
+ - Spinner
40
+ - Duration picker
41
+ - Comprehensive TypeScript type definitions
42
+ - Tailwind CSS styling with custom configuration
43
+ - Complete documentation and examples
44
+ - MIT License
45
+
46
+ ### Features
47
+ - Vanilla JavaScript implementation (no framework dependencies)
48
+ - State management with change listeners
49
+ - Component variants (default, error, warning, success, borderless, inline)
50
+ - Size options (small, default, large)
51
+ - Disabled and read-only states
52
+ - Form validation support
53
+ - Accessibility features
54
+ - Responsive design
55
+ - Dark mode compatible
56
+ - SuperLeap client integration
57
+
58
+ ### Documentation
59
+ - README.md with complete API reference
60
+ - EXAMPLES.md with component examples
61
+ - QUICKSTART.md for getting started
62
+ - TypeScript definitions (index.d.ts)
63
+ - Example HTML files for testing
64
+
65
+ [1.0.0]: https://github.com/superleap/superleap-flow/releases/tag/v1.0.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SuperLeap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,451 @@
1
+ # @superleap/superleap-flow
2
+
3
+ A comprehensive, reusable design system for building multi-step forms and UI components with vanilla JavaScript and Tailwind CSS.
4
+
5
+ **✨ Clean Architecture:** Only `FlowUI` and `SuperLeap` are exposed to global scope. All components are internal.
6
+
7
+ ## 📦 Installation
8
+
9
+ ```bash
10
+ npm install @superleap/superleap-flow
11
+ ```
12
+
13
+ ## 🚀 Quick Start
14
+
15
+ ### Browser Usage (Single Script Tag)
16
+
17
+ ```html
18
+ <!DOCTYPE html>
19
+ <html>
20
+ <head>
21
+ <link rel="stylesheet" href="node_modules/@superleap/superleap-flow/dist/output.css">
22
+ </head>
23
+ <body>
24
+ <div id="app"></div>
25
+
26
+ <!-- Single script tag - includes SuperLeap SDK and all components -->
27
+ <script src="node_modules/@superleap/superleap-flow/index.js"></script>
28
+
29
+ <script>
30
+ // Wait for library to be ready
31
+ document.addEventListener('superleap-flow:ready', function() {
32
+ // Initialize SuperLeap SDK (optional, for Record Select)
33
+ SuperLeap.init({
34
+ // apiKey: 'YOUR_API_KEY'
35
+ });
36
+
37
+ // Initialize state
38
+ FlowUI.initState({ name: '', email: '' });
39
+
40
+ // Create UI
41
+ const app = document.getElementById('app');
42
+ const screen = FlowUI.createScreen('Welcome', 'Please enter your details');
43
+ const grid = FlowUI.createGrid();
44
+
45
+ grid.appendChild(FlowUI.createInput({
46
+ label: 'Name',
47
+ fieldId: 'name',
48
+ placeholder: 'Enter your name',
49
+ required: true
50
+ }));
51
+
52
+ grid.appendChild(FlowUI.createInput({
53
+ label: 'Email',
54
+ fieldId: 'email',
55
+ type: 'email',
56
+ required: true
57
+ }));
58
+
59
+ const submitBtn = FlowUI.createButton({
60
+ variant: 'primary',
61
+ text: 'Submit',
62
+ onClick: () => {
63
+ const data = FlowUI.getState();
64
+ console.log(data);
65
+ FlowUI.showToast('Form submitted!', 'success');
66
+ }
67
+ });
68
+
69
+ screen.appendChild(grid);
70
+ screen.appendChild(submitBtn);
71
+ app.appendChild(screen);
72
+ });
73
+ </script>
74
+ </body>
75
+ </html>
76
+ ```
77
+
78
+ ### ES Module Usage
79
+
80
+ ```javascript
81
+ import { FlowUI, SuperLeap } from '@superleap/superleap-flow';
82
+
83
+ // Initialize SuperLeap SDK
84
+ SuperLeap.init({ apiKey: 'YOUR_KEY' });
85
+
86
+ // Initialize state
87
+ FlowUI.initState({ name: '', email: '' });
88
+
89
+ // Create components
90
+ const nameInput = FlowUI.createInput({
91
+ label: 'Name',
92
+ fieldId: 'name',
93
+ required: true
94
+ });
95
+ ```
96
+
97
+ ### CommonJS Usage
98
+
99
+ ```javascript
100
+ const { FlowUI, SuperLeap } = require('@superleap/superleap-flow');
101
+
102
+ SuperLeap.init({ apiKey: 'YOUR_KEY' });
103
+ FlowUI.initState({ name: '' });
104
+ ```
105
+
106
+ ## 🎯 What's Exposed
107
+
108
+ ```javascript
109
+ // Only 2 objects in global scope
110
+ window.FlowUI // ✅ UI Framework with all components
111
+ window.SuperLeap // ✅ SDK Client for API integration
112
+
113
+ // All components are internal (not global)
114
+ window.Toast // ❌ Not available
115
+ window.Button // ❌ Not available
116
+ window.Alert // ❌ Not available
117
+ // ... 20+ components kept internal
118
+ ```
119
+
120
+ ## ✨ Features
121
+
122
+ - 🎨 **Complete Design System** - Pre-built components matching modern UI standards
123
+ - 📝 **Form Components** - Input, Select, Textarea, Checkbox, Radio, and more
124
+ - 📅 **Date & Time** - Date picker, time picker, and date-time picker
125
+ - 💰 **Specialized Inputs** - Currency, phone number, file upload
126
+ - 🔄 **State Management** - Built-in reactive state management
127
+ - 🎯 **Multi-step Forms** - Stepper component for wizard-style forms
128
+ - 📊 **Data Tables** - Sortable, searchable tables
129
+ - 🎨 **Customizable** - Tailwind CSS for easy styling
130
+ - 📱 **Responsive** - Mobile-first design
131
+ - ✨ **Clean Architecture** - Only FlowUI and SuperLeap exposed globally
132
+ - 📦 **Single Script** - One file includes everything (SDK + components)
133
+ - 🚀 **Zero Dependencies** - Pure vanilla JavaScript
134
+
135
+ ## 📚 API Reference
136
+
137
+ ### FlowUI API
138
+
139
+ #### State Management
140
+
141
+ ```javascript
142
+ // Initialize state
143
+ FlowUI.initState(initialState, onChangeCallback)
144
+
145
+ // Get entire state
146
+ const state = FlowUI.getState()
147
+
148
+ // Update state
149
+ FlowUI.setState({ name: 'John' })
150
+
151
+ // Get single value
152
+ const name = FlowUI.get('name')
153
+
154
+ // Set single value
155
+ FlowUI.set('name', 'John')
156
+ ```
157
+
158
+ #### Layout Components
159
+
160
+ ```javascript
161
+ // Create screen wrapper
162
+ FlowUI.createScreen(title, description)
163
+
164
+ // Create form grid
165
+ FlowUI.createGrid()
166
+
167
+ // Create field wrapper
168
+ FlowUI.createFieldWrapper(label, required, helpText)
169
+ ```
170
+
171
+ #### Form Components
172
+
173
+ ```javascript
174
+ // Text input
175
+ FlowUI.createInput({
176
+ label: 'Name',
177
+ fieldId: 'name',
178
+ placeholder: 'Enter name',
179
+ required: true,
180
+ type: 'text', // text, email, password, number, tel, url
181
+ variant: 'default', // default, error, warning, success, borderless, inline
182
+ inputSize: 'default', // default, large, small
183
+ disabled: false,
184
+ helpText: 'Your full name'
185
+ })
186
+
187
+ // Textarea
188
+ FlowUI.createTextarea({
189
+ label: 'Comments',
190
+ fieldId: 'comments',
191
+ placeholder: 'Enter comments',
192
+ required: false
193
+ })
194
+
195
+ // Select dropdown
196
+ FlowUI.createSelect({
197
+ label: 'Role',
198
+ fieldId: 'role',
199
+ options: [
200
+ { value: 'admin', label: 'Administrator' },
201
+ { value: 'user', label: 'User' }
202
+ ],
203
+ required: true,
204
+ onChange: (value) => console.log(value)
205
+ })
206
+
207
+ // Multi-select
208
+ FlowUI.createMultiSelect({
209
+ label: 'Tags',
210
+ fieldId: 'tags',
211
+ options: [...],
212
+ placeholder: 'Select tags',
213
+ type: 'default', // default (count) or tags (show tags)
214
+ onChange: (values) => console.log(values)
215
+ })
216
+
217
+ // Radio group
218
+ FlowUI.createRadioGroup({
219
+ label: 'Plan',
220
+ fieldId: 'plan',
221
+ options: [...],
222
+ onChange: (value) => console.log(value)
223
+ })
224
+
225
+ // Checkbox
226
+ FlowUI.createCheckbox({
227
+ label: 'I accept terms',
228
+ fieldId: 'acceptTerms',
229
+ size: 'default', // default, small, large
230
+ align: 'left', // left, right
231
+ onChange: (checked) => console.log(checked)
232
+ })
233
+
234
+ // Time picker
235
+ FlowUI.createTimePicker({
236
+ label: 'Time',
237
+ fieldId: 'time',
238
+ use24Hour: false, // false = 12-hour AM/PM, true = 24-hour
239
+ onChange: (value) => console.log(value)
240
+ })
241
+
242
+ // Date-time picker
243
+ FlowUI.createDateTimePicker({
244
+ label: 'Date & Time',
245
+ fieldId: 'datetime',
246
+ granularity: 'minute', // day, hour, minute, second
247
+ hourCycle: 12, // 12 or 24
248
+ onChange: (date) => console.log(date)
249
+ })
250
+
251
+ // Currency input
252
+ FlowUI.createCurrency({
253
+ label: 'Amount',
254
+ fieldId: 'amount',
255
+ column: {
256
+ properties: {
257
+ currency: { currency: 'USD' }
258
+ }
259
+ },
260
+ onChange: (value) => console.log(value)
261
+ })
262
+
263
+ // Phone input
264
+ FlowUI.createPhoneInput({
265
+ label: 'Phone',
266
+ fieldId: 'phone',
267
+ defaultCountryCode: 'IN',
268
+ onChange: (fullValue, country) => console.log(fullValue, country)
269
+ })
270
+
271
+ // File upload
272
+ FlowUI.createFileUpload({
273
+ label: 'Attachments',
274
+ fieldId: 'files',
275
+ multiple: true,
276
+ accept: '.pdf,.jpg,.png'
277
+ })
278
+
279
+ // Record select (requires SuperLeap SDK)
280
+ FlowUI.createRecordSelect({
281
+ label: 'Account',
282
+ fieldId: 'account',
283
+ objectSlug: 'account',
284
+ placeholder: 'Select account',
285
+ onChange: (value, record) => console.log(value, record)
286
+ })
287
+ ```
288
+
289
+ #### UI Components
290
+
291
+ ```javascript
292
+ // Button
293
+ FlowUI.createButton({
294
+ variant: 'primary', // primary, outline, ghost, link, etc.
295
+ size: 'default', // small, default, large
296
+ text: 'Submit',
297
+ icon: '<svg>...</svg>',
298
+ iconPosition: 'left', // left, right
299
+ loading: false,
300
+ disabled: false,
301
+ onClick: (event) => console.log('Clicked')
302
+ })
303
+
304
+ // Toast notification
305
+ FlowUI.showToast(message, type, duration)
306
+ // type: success, error, warning, info, loading
307
+ // duration: milliseconds (0 for persistent)
308
+
309
+ // Example:
310
+ FlowUI.showToast('Success!', 'success', 3000)
311
+ const loadingToast = FlowUI.showToast('Loading...', 'loading', 0)
312
+ loadingToast.close() // Close manually
313
+ ```
314
+
315
+ #### Table Components
316
+
317
+ ```javascript
318
+ // Data table
319
+ FlowUI.createDataTable({
320
+ columns: [
321
+ { key: 'name', label: 'Name' },
322
+ { key: 'email', label: 'Email' }
323
+ ],
324
+ data: [...],
325
+ fieldId: 'selectedRow',
326
+ idKey: 'id',
327
+ onSelect: (row) => console.log(row)
328
+ })
329
+
330
+ // Search input
331
+ FlowUI.createSearchInput({
332
+ placeholder: 'Search...',
333
+ fieldId: 'search',
334
+ onSearch: (query) => console.log(query)
335
+ })
336
+ ```
337
+
338
+ #### Stepper
339
+
340
+ ```javascript
341
+ FlowUI.renderStepper(
342
+ container,
343
+ [
344
+ { id: 'step1', label: 'Step 1' },
345
+ { id: 'step2', label: 'Step 2' },
346
+ { id: 'step3', label: 'Step 3' }
347
+ ],
348
+ 'step1' // current step
349
+ )
350
+ ```
351
+
352
+ #### Summary
353
+
354
+ ```javascript
355
+ FlowUI.createSummaryRow(label, value)
356
+ ```
357
+
358
+ #### Alerts
359
+
360
+ ```javascript
361
+ FlowUI.renderAlerts(container, messages, type)
362
+ // type: error, info, success
363
+ ```
364
+
365
+ #### Advanced: Direct Component Access
366
+
367
+ ```javascript
368
+ // Get internal component reference (advanced use)
369
+ const Toast = FlowUI._getComponent('Toast')
370
+ const Button = FlowUI._getComponent('Button')
371
+
372
+ // Use directly
373
+ Toast.success('Hello!')
374
+ Button.create({ text: 'Click me' })
375
+ ```
376
+
377
+ ### SuperLeap API
378
+
379
+ ```javascript
380
+ // Initialize SDK
381
+ SuperLeap.init({
382
+ apiKey: 'YOUR_API_KEY',
383
+ baseUrl: 'https://app.superleap.com/api/v1'
384
+ })
385
+
386
+ // Get SDK instance
387
+ const sdk = SuperLeap.getSdk()
388
+
389
+ // Check availability
390
+ if (SuperLeap.isAvailable()) {
391
+ // SDK is ready
392
+ }
393
+
394
+ // Get default config
395
+ const config = SuperLeap.getDefaultConfig()
396
+ ```
397
+
398
+ ## 🎨 Component Variants
399
+
400
+ ### Input/Select Variants
401
+ - `default` - Standard appearance
402
+ - `error` - Red border for errors
403
+ - `warning` - Orange border for warnings
404
+ - `success` - Green border for success
405
+ - `borderless` - No border
406
+ - `inline` - Inline style
407
+
408
+ ### Button Variants
409
+ - `primary` - Primary action button
410
+ - `outline` - Outlined button
411
+ - `ghost` - Ghost/transparent button
412
+ - `link` - Link-styled button
413
+ - `primaryDestructive` - Destructive primary
414
+ - `outlineDestructive` - Destructive outline
415
+ - `ghostDestructive` - Destructive ghost
416
+
417
+ ### Sizes
418
+ - `small` - Small size
419
+ - `default` - Default size
420
+ - `large` - Large size
421
+
422
+ ## 📖 Examples
423
+
424
+ See `example.html` for a comprehensive demonstration of all components.
425
+
426
+ ## 🔧 TypeScript Support
427
+
428
+ Full TypeScript definitions included:
429
+
430
+ ```typescript
431
+ import { FlowUI, SuperLeap, SuperLeapConfig } from '@superleap/superleap-flow';
432
+
433
+ const config: SuperLeapConfig = {
434
+ apiKey: 'YOUR_KEY'
435
+ };
436
+
437
+ SuperLeap.init(config);
438
+ FlowUI.initState({ name: '' });
439
+ ```
440
+
441
+ ## 📄 License
442
+
443
+ MIT
444
+
445
+ ## 🤝 Contributing
446
+
447
+ See CONTRIBUTING.md for contribution guidelines.
448
+
449
+ ## 📝 Changelog
450
+
451
+ See CHANGELOG.md for version history.