@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.
- package/CHANGELOG.md +65 -0
- package/LICENSE +21 -0
- package/README.md +451 -0
- package/components/alert.js +282 -0
- package/components/avatar.js +195 -0
- package/components/badge.js +135 -0
- package/components/button.js +201 -0
- package/components/checkbox.js +254 -0
- package/components/currency.js +227 -0
- package/components/date-time-picker/date-time-picker-utils.js +253 -0
- package/components/date-time-picker/date-time-picker.js +532 -0
- package/components/duration/duration-constants.js +46 -0
- package/components/duration/duration-utils.js +164 -0
- package/components/duration/duration.js +448 -0
- package/components/enum-multiselect.js +869 -0
- package/components/enum-select.js +831 -0
- package/components/enumeration.js +213 -0
- package/components/file-input.js +533 -0
- package/components/icon.js +200 -0
- package/components/input.js +259 -0
- package/components/label.js +111 -0
- package/components/multiselect.js +351 -0
- package/components/phone-input/phone-input.js +392 -0
- package/components/phone-input/phone-utils.js +157 -0
- package/components/popover.js +240 -0
- package/components/radio-group.js +435 -0
- package/components/record-multiselect.js +956 -0
- package/components/record-select.js +930 -0
- package/components/select.js +544 -0
- package/components/spinner.js +136 -0
- package/components/table.js +335 -0
- package/components/textarea.js +114 -0
- package/components/time-picker.js +357 -0
- package/components/toast.js +343 -0
- package/core/flow.js +1729 -0
- package/core/superleapClient.js +146 -0
- package/dist/output.css +2 -0
- package/index.d.ts +458 -0
- package/index.js +253 -0
- package/package.json +70 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript definitions for @superleap/superleap-flow
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
declare module "@superleap/superleap-flow" {
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// SUPERLEAP SDK
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
export interface SuperLeapConfig {
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
clientId?: string;
|
|
14
|
+
clientSecret?: string;
|
|
15
|
+
cache?: {
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
maxSize?: number;
|
|
18
|
+
defaultTTL?: number;
|
|
19
|
+
ttl?: {
|
|
20
|
+
schema?: number;
|
|
21
|
+
records?: number;
|
|
22
|
+
count?: number;
|
|
23
|
+
user?: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SuperLeap {
|
|
29
|
+
init(config?: SuperLeapConfig): void;
|
|
30
|
+
getSdk(): any;
|
|
31
|
+
isAvailable(): boolean;
|
|
32
|
+
getDefaultConfig(): SuperLeapConfig;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const SuperLeap: SuperLeap;
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// STATE MANAGEMENT
|
|
39
|
+
// ============================================================================
|
|
40
|
+
|
|
41
|
+
export interface FlowUIState {
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ButtonConfig {
|
|
46
|
+
text?: string;
|
|
47
|
+
label?: string;
|
|
48
|
+
variant?: "primary" | "outline" | "ghost" | "link" | "primaryDestructive" | "outlineDestructive" | "ghostDestructive" | "dashed" | "toggleOff" | "toggleOn" | "ghostInline" | "linkInline";
|
|
49
|
+
size?: "small" | "medium" | "default" | "large";
|
|
50
|
+
type?: "button" | "submit" | "reset";
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
onClick?: (event: MouseEvent) => void;
|
|
53
|
+
icon?: string;
|
|
54
|
+
iconPosition?: "left" | "right";
|
|
55
|
+
loading?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface InputConfig {
|
|
59
|
+
label: string;
|
|
60
|
+
fieldId: string;
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
required?: boolean;
|
|
63
|
+
type?: "text" | "email" | "number" | "password" | "tel" | "url";
|
|
64
|
+
helpText?: string;
|
|
65
|
+
variant?: "default" | "error" | "warning" | "success" | "borderless" | "inline";
|
|
66
|
+
inputSize?: "default" | "large" | "small";
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
showReadOnlyIcon?: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface TextareaConfig {
|
|
72
|
+
label: string;
|
|
73
|
+
fieldId: string;
|
|
74
|
+
placeholder?: string;
|
|
75
|
+
required?: boolean;
|
|
76
|
+
helpText?: string;
|
|
77
|
+
variant?: "default" | "borderless" | "inline" | "error" | "warning";
|
|
78
|
+
rows?: number;
|
|
79
|
+
disabled?: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface SelectOption {
|
|
83
|
+
value: string;
|
|
84
|
+
label: string;
|
|
85
|
+
slug?: string;
|
|
86
|
+
id?: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface SelectConfig {
|
|
91
|
+
label: string;
|
|
92
|
+
fieldId: string;
|
|
93
|
+
options: SelectOption[];
|
|
94
|
+
required?: boolean;
|
|
95
|
+
onChange?: (value: string) => void;
|
|
96
|
+
disabled?: boolean;
|
|
97
|
+
helpText?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface TimePickerConfig {
|
|
101
|
+
label: string;
|
|
102
|
+
fieldId: string;
|
|
103
|
+
value?: string;
|
|
104
|
+
placeholder?: string;
|
|
105
|
+
required?: boolean;
|
|
106
|
+
onChange?: (value: string) => void;
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
use24Hour?: boolean;
|
|
109
|
+
helpText?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface DateTimePickerConfig {
|
|
113
|
+
label: string;
|
|
114
|
+
fieldId: string;
|
|
115
|
+
value?: Date | string | null;
|
|
116
|
+
placeholder?: string;
|
|
117
|
+
required?: boolean;
|
|
118
|
+
onChange?: (date: Date | undefined) => void;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
hourCycle?: 12 | 24;
|
|
121
|
+
granularity?: "day" | "hour" | "minute" | "second";
|
|
122
|
+
size?: "small" | "default" | "large";
|
|
123
|
+
fromDate?: Date;
|
|
124
|
+
toDate?: Date;
|
|
125
|
+
helpText?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface RadioGroupConfig {
|
|
129
|
+
label: string;
|
|
130
|
+
fieldId: string;
|
|
131
|
+
options: Array<{ value: string; label?: string; disabled?: boolean }>;
|
|
132
|
+
required?: boolean;
|
|
133
|
+
onChange?: (value: string) => void;
|
|
134
|
+
helpText?: string;
|
|
135
|
+
orientation?: "horizontal" | "vertical";
|
|
136
|
+
disabled?: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface MultiSelectConfig {
|
|
140
|
+
label: string;
|
|
141
|
+
fieldId: string;
|
|
142
|
+
options: SelectOption[];
|
|
143
|
+
required?: boolean;
|
|
144
|
+
onChange?: (values: string[]) => void;
|
|
145
|
+
placeholder?: string;
|
|
146
|
+
helpText?: string;
|
|
147
|
+
variant?: "default" | "error" | "warning" | "borderless" | "inline";
|
|
148
|
+
size?: "default" | "large" | "small";
|
|
149
|
+
type?: "default" | "tags";
|
|
150
|
+
disabled?: boolean;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface RecordSelectConfig {
|
|
154
|
+
label: string;
|
|
155
|
+
fieldId: string;
|
|
156
|
+
objectSlug: string;
|
|
157
|
+
placeholder?: string;
|
|
158
|
+
searchPlaceholder?: string;
|
|
159
|
+
required?: boolean;
|
|
160
|
+
onChange?: (value: string, record?: any) => void;
|
|
161
|
+
disabled?: boolean;
|
|
162
|
+
variant?: "default" | "error" | "warning" | "borderless" | "inline";
|
|
163
|
+
size?: "default" | "large" | "small";
|
|
164
|
+
canClear?: boolean;
|
|
165
|
+
initialLimit?: number;
|
|
166
|
+
helpText?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface RecordMultiSelectConfig {
|
|
170
|
+
label: string;
|
|
171
|
+
fieldId: string;
|
|
172
|
+
objectSlug: string;
|
|
173
|
+
placeholder?: string;
|
|
174
|
+
searchPlaceholder?: string;
|
|
175
|
+
required?: boolean;
|
|
176
|
+
onChange?: (values: string[], records?: any[]) => void;
|
|
177
|
+
disabled?: boolean;
|
|
178
|
+
variant?: "default" | "error" | "warning" | "borderless" | "inline";
|
|
179
|
+
size?: "default" | "large" | "small";
|
|
180
|
+
initialLimit?: number;
|
|
181
|
+
displayFields?: string[];
|
|
182
|
+
helpText?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface EnumSelectConfig {
|
|
186
|
+
label: string;
|
|
187
|
+
fieldId: string;
|
|
188
|
+
objectSlug: string;
|
|
189
|
+
columnSlug: string;
|
|
190
|
+
placeholder?: string;
|
|
191
|
+
required?: boolean;
|
|
192
|
+
onChange?: (value: string) => void;
|
|
193
|
+
disabled?: boolean;
|
|
194
|
+
variant?: "default" | "error" | "warning" | "borderless" | "inline";
|
|
195
|
+
size?: "default" | "large" | "small";
|
|
196
|
+
canClear?: boolean;
|
|
197
|
+
currentRecordData?: Record<string, any>;
|
|
198
|
+
helpText?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface EnumMultiSelectConfig {
|
|
202
|
+
label: string;
|
|
203
|
+
fieldId: string;
|
|
204
|
+
objectSlug: string;
|
|
205
|
+
columnSlug: string;
|
|
206
|
+
placeholder?: string;
|
|
207
|
+
required?: boolean;
|
|
208
|
+
onChange?: (values: string[]) => void;
|
|
209
|
+
disabled?: boolean;
|
|
210
|
+
variant?: "default" | "error" | "warning" | "borderless" | "inline";
|
|
211
|
+
size?: "default" | "large" | "small";
|
|
212
|
+
canClear?: boolean;
|
|
213
|
+
currentRecordData?: Record<string, any>;
|
|
214
|
+
helpText?: string;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface DurationConfig {
|
|
218
|
+
label: string;
|
|
219
|
+
fieldId: string;
|
|
220
|
+
value?: number | null;
|
|
221
|
+
formatType?: "seconds" | "milliseconds";
|
|
222
|
+
placeholder?: string;
|
|
223
|
+
required?: boolean;
|
|
224
|
+
onChange?: (value: number | null) => void;
|
|
225
|
+
disabled?: boolean;
|
|
226
|
+
variant?: "default" | "error" | "warning" | "success" | "borderless" | "inline";
|
|
227
|
+
size?: "small" | "default" | "large";
|
|
228
|
+
helpText?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface EnumerationConfig {
|
|
232
|
+
label: string;
|
|
233
|
+
fieldId: string;
|
|
234
|
+
totalElements: number;
|
|
235
|
+
enabledIcon: string | HTMLElement;
|
|
236
|
+
disabledIcon: string | HTMLElement;
|
|
237
|
+
defaultValue?: number;
|
|
238
|
+
required?: boolean;
|
|
239
|
+
onChange?: (count: number) => void;
|
|
240
|
+
disabled?: boolean;
|
|
241
|
+
readOnly?: boolean;
|
|
242
|
+
variant?: "default" | "error" | "warning" | "success" | "borderless" | "inline";
|
|
243
|
+
size?: "default" | "large" | "small";
|
|
244
|
+
helpText?: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface FileUploadConfig {
|
|
248
|
+
label: string;
|
|
249
|
+
fieldId: string;
|
|
250
|
+
multiple?: boolean;
|
|
251
|
+
accept?: string;
|
|
252
|
+
required?: boolean;
|
|
253
|
+
helpText?: string;
|
|
254
|
+
isPrivate?: boolean;
|
|
255
|
+
maxFiles?: number;
|
|
256
|
+
maxFileSize?: number;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface CurrencyConfig {
|
|
260
|
+
label?: string;
|
|
261
|
+
fieldId: string;
|
|
262
|
+
column?: {
|
|
263
|
+
properties?: {
|
|
264
|
+
currency?: {
|
|
265
|
+
currency?: string;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
placeholder?: string;
|
|
269
|
+
};
|
|
270
|
+
placeholder?: string;
|
|
271
|
+
required?: boolean;
|
|
272
|
+
helpText?: string;
|
|
273
|
+
variant?: "inline" | "default" | "borderless" | "error" | "warning";
|
|
274
|
+
size?: "small" | "default" | "large";
|
|
275
|
+
disabled?: boolean;
|
|
276
|
+
onChange?: (value: number | null) => void;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface PhoneInputConfig {
|
|
280
|
+
label: string;
|
|
281
|
+
fieldId: string;
|
|
282
|
+
defaultCountryCode?: string;
|
|
283
|
+
placeholder?: string;
|
|
284
|
+
required?: boolean;
|
|
285
|
+
helpText?: string;
|
|
286
|
+
variant?: "default" | "error" | "warning" | "borderless" | "inline";
|
|
287
|
+
inputSize?: "default" | "large" | "small";
|
|
288
|
+
disabled?: boolean;
|
|
289
|
+
disableCountrySelect?: boolean;
|
|
290
|
+
hideCountrySelect?: boolean;
|
|
291
|
+
onChange?: (fullValue: string, country: any) => void;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export interface CheckboxConfig {
|
|
295
|
+
label: string;
|
|
296
|
+
fieldId: string;
|
|
297
|
+
checked?: boolean;
|
|
298
|
+
indeterminate?: boolean;
|
|
299
|
+
disabled?: boolean;
|
|
300
|
+
helpText?: string;
|
|
301
|
+
size?: "default" | "small" | "large";
|
|
302
|
+
align?: "left" | "right";
|
|
303
|
+
isLabelCaps?: boolean;
|
|
304
|
+
onChange?: (isChecked: boolean) => void;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface DataTableConfig {
|
|
308
|
+
columns: Array<{ key: string; label: string }>;
|
|
309
|
+
data: any[];
|
|
310
|
+
fieldId: string;
|
|
311
|
+
idKey?: string;
|
|
312
|
+
onSelect?: (row: any) => void;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export interface SearchInputConfig {
|
|
316
|
+
placeholder?: string;
|
|
317
|
+
fieldId: string;
|
|
318
|
+
onSearch?: (query: string) => void;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface TableColumnConfig {
|
|
322
|
+
header: string;
|
|
323
|
+
accessor?: string;
|
|
324
|
+
cell?: (row: any) => string | HTMLElement;
|
|
325
|
+
width?: string;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export interface TableConfig {
|
|
329
|
+
data: any[];
|
|
330
|
+
columns: TableColumnConfig[];
|
|
331
|
+
showHeader?: boolean;
|
|
332
|
+
headerSize?: "small" | "default" | "large";
|
|
333
|
+
hasBorder?: boolean;
|
|
334
|
+
onRowClick?: (rowId: string) => void;
|
|
335
|
+
onFetch?: () => void;
|
|
336
|
+
hasMore?: boolean;
|
|
337
|
+
isLoading?: boolean;
|
|
338
|
+
emptyMessage?: string;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface BadgeConfig {
|
|
342
|
+
variant?: "default" | "primary";
|
|
343
|
+
color?: "default" | "info" | "warning" | "error" | "success";
|
|
344
|
+
size?: "small" | "medium" | "large";
|
|
345
|
+
startIcon?: string | HTMLElement;
|
|
346
|
+
endIcon?: string | HTMLElement;
|
|
347
|
+
icon?: string | HTMLElement;
|
|
348
|
+
content?: string | HTMLElement;
|
|
349
|
+
className?: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface AvatarUser {
|
|
353
|
+
id: number;
|
|
354
|
+
name: string;
|
|
355
|
+
image?: string;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export interface AvatarConfig {
|
|
359
|
+
name?: string;
|
|
360
|
+
image?: string;
|
|
361
|
+
size?: "small" | "default" | "large" | "custom";
|
|
362
|
+
shape?: "circle" | "square";
|
|
363
|
+
className?: string;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export interface AvatarGroupConfig {
|
|
367
|
+
users: AvatarUser[];
|
|
368
|
+
size?: "small" | "default" | "large" | "custom";
|
|
369
|
+
className?: string;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export interface LoaderConfig {
|
|
373
|
+
size?: "small" | "medium" | "large";
|
|
374
|
+
color?: string;
|
|
375
|
+
text?: string;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export interface StepConfig {
|
|
379
|
+
id: string;
|
|
380
|
+
label: string;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export interface ToastAPI {
|
|
384
|
+
close: () => void;
|
|
385
|
+
element: HTMLElement | null;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface FlowUI {
|
|
389
|
+
// State management
|
|
390
|
+
initState(initialState: FlowUIState, onChangeCallback?: (state: FlowUIState) => void): void;
|
|
391
|
+
getState(): FlowUIState;
|
|
392
|
+
setState(partial: Partial<FlowUIState>): void;
|
|
393
|
+
get(key: string): any;
|
|
394
|
+
set(key: string, value: any): void;
|
|
395
|
+
|
|
396
|
+
// Internal component access (for advanced use in clean globals mode)
|
|
397
|
+
_getComponent(name: string): any;
|
|
398
|
+
|
|
399
|
+
// Screen utilities
|
|
400
|
+
createScreen(title: string, description: string): HTMLElement;
|
|
401
|
+
createGrid(): HTMLElement;
|
|
402
|
+
createFieldWrapper(label: string, required?: boolean, helpText?: string | null): HTMLElement;
|
|
403
|
+
|
|
404
|
+
// Form components
|
|
405
|
+
createInput(config: InputConfig): HTMLElement;
|
|
406
|
+
createTextarea(config: TextareaConfig): HTMLElement;
|
|
407
|
+
createSelect(config: SelectConfig): HTMLElement;
|
|
408
|
+
createTimePicker(config: TimePickerConfig): HTMLElement;
|
|
409
|
+
createDateTimePicker(config: DateTimePickerConfig): HTMLElement;
|
|
410
|
+
createRadioGroup(config: RadioGroupConfig): HTMLElement;
|
|
411
|
+
createMultiSelect(config: MultiSelectConfig): HTMLElement;
|
|
412
|
+
createRecordSelect(config: RecordSelectConfig): HTMLElement;
|
|
413
|
+
createRecordMultiSelect(config: RecordMultiSelectConfig): HTMLElement;
|
|
414
|
+
createEnumSelect(config: EnumSelectConfig): HTMLElement;
|
|
415
|
+
createEnumMultiSelect(config: EnumMultiSelectConfig): HTMLElement;
|
|
416
|
+
createDuration(config: DurationConfig): HTMLElement;
|
|
417
|
+
createEnumeration(config: EnumerationConfig): HTMLElement;
|
|
418
|
+
createFileUpload(config: FileUploadConfig): HTMLElement;
|
|
419
|
+
createCurrency(config: CurrencyConfig): HTMLElement;
|
|
420
|
+
createPhoneInput(config: PhoneInputConfig): HTMLElement;
|
|
421
|
+
createCheckbox(config: CheckboxConfig): HTMLElement;
|
|
422
|
+
createButton(config: ButtonConfig): HTMLElement;
|
|
423
|
+
|
|
424
|
+
// Stepper
|
|
425
|
+
renderStepper(container: HTMLElement, steps: StepConfig[], currentStepId: string): void;
|
|
426
|
+
|
|
427
|
+
// Alerts & Toasts
|
|
428
|
+
showToast(message: string, type?: "success" | "error" | "warning" | "info" | "loading", duration?: number): ToastAPI;
|
|
429
|
+
renderAlerts(container: HTMLElement, messages?: (string | { title?: string; description?: string })[], type?: "error" | "info" | "success" | "warning" | "destructive" | "default"): void;
|
|
430
|
+
|
|
431
|
+
// Table
|
|
432
|
+
createDataTable(config: DataTableConfig): HTMLElement;
|
|
433
|
+
createTable(config: TableConfig): HTMLElement | any;
|
|
434
|
+
createSearchInput(config: SearchInputConfig): HTMLElement;
|
|
435
|
+
|
|
436
|
+
// Summary
|
|
437
|
+
createSummaryRow(label: string, value: string): HTMLElement;
|
|
438
|
+
|
|
439
|
+
// Badge & Loader
|
|
440
|
+
createBadge(config: BadgeConfig): HTMLElement;
|
|
441
|
+
createLoader(config?: LoaderConfig): HTMLElement;
|
|
442
|
+
|
|
443
|
+
// Avatar
|
|
444
|
+
createAvatar(config: AvatarConfig): HTMLElement;
|
|
445
|
+
createVividAvatar(config: AvatarConfig): HTMLElement;
|
|
446
|
+
createAvatarGroup(config: AvatarGroupConfig): HTMLElement;
|
|
447
|
+
createVividAvatarGroup(config: AvatarGroupConfig): HTMLElement;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
export const FlowUI: FlowUI;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
declare global {
|
|
454
|
+
interface Window {
|
|
455
|
+
FlowUI: FlowUI;
|
|
456
|
+
SuperLeap: SuperLeap;
|
|
457
|
+
}
|
|
458
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Superleap-Flow Library Entry Point
|
|
3
|
+
* @superleap/superleap-flow
|
|
4
|
+
*
|
|
5
|
+
* Single-file bundle that includes SuperLeap SDK and all components.
|
|
6
|
+
* Only FlowUI and SuperLeap are exposed to global scope.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
*
|
|
10
|
+
* Browser (via CDN or script tag):
|
|
11
|
+
* <script src="path/to/superleap-flow/index.js"></script>
|
|
12
|
+
* <script>
|
|
13
|
+
* // Initialize SuperLeap SDK
|
|
14
|
+
* SuperLeap.init({ apiKey: 'YOUR_API_KEY' });
|
|
15
|
+
*
|
|
16
|
+
* // Use FlowUI
|
|
17
|
+
* FlowUI.initState({ name: '' });
|
|
18
|
+
* </script>
|
|
19
|
+
*
|
|
20
|
+
* ES Module:
|
|
21
|
+
* import { FlowUI, SuperLeap } from '@superleap/superleap-flow';
|
|
22
|
+
*
|
|
23
|
+
* CommonJS:
|
|
24
|
+
* const { FlowUI, SuperLeap } = require('@superleap/superleap-flow');
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
(function(global) {
|
|
28
|
+
'use strict';
|
|
29
|
+
|
|
30
|
+
// Check if we're in a browser environment
|
|
31
|
+
const isBrowser = typeof window !== 'undefined';
|
|
32
|
+
const isNode = typeof require !== 'undefined' && typeof module !== 'undefined';
|
|
33
|
+
|
|
34
|
+
// In Node.js/CommonJS environment, load all modules
|
|
35
|
+
if (isNode && !isBrowser) {
|
|
36
|
+
// Note: In Node.js, SuperLeap SDK should be installed separately via npm
|
|
37
|
+
// npm install superleap-sdk
|
|
38
|
+
try {
|
|
39
|
+
global.createSuperLeapSDK = require('superleap-sdk');
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.warn('[Superleap-Flow] SuperLeap SDK not found. Install with: npm install superleap-sdk');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Load core modules
|
|
45
|
+
require('./core/superleapClient.js');
|
|
46
|
+
require('./components/label.js');
|
|
47
|
+
require('./core/flow.js');
|
|
48
|
+
|
|
49
|
+
// Load components in dependency order
|
|
50
|
+
require('./components/toast.js');
|
|
51
|
+
require('./components/alert.js');
|
|
52
|
+
require('./components/button.js');
|
|
53
|
+
require('./components/spinner.js');
|
|
54
|
+
require('./components/popover.js');
|
|
55
|
+
require('./components/select.js');
|
|
56
|
+
require('./components/enum-select.js');
|
|
57
|
+
require('./components/record-select.js');
|
|
58
|
+
require('./components/record-multiselect.js');
|
|
59
|
+
require('./components/time-picker.js');
|
|
60
|
+
require('./components/input.js');
|
|
61
|
+
require('./components/currency.js');
|
|
62
|
+
require('./components/textarea.js');
|
|
63
|
+
require('./components/duration/duration-utils.js');
|
|
64
|
+
require('./components/duration/duration-constants.js');
|
|
65
|
+
require('./components/duration/duration.js');
|
|
66
|
+
require('./components/date-time-picker/date-time-picker-utils.js');
|
|
67
|
+
require('./components/date-time-picker/date-time-picker.js');
|
|
68
|
+
require('./components/enumeration.js');
|
|
69
|
+
require('./components/multiselect.js');
|
|
70
|
+
require('./components/enum-multiselect.js');
|
|
71
|
+
require('./components/badge.js');
|
|
72
|
+
require('./components/avatar.js');
|
|
73
|
+
require('./components/icon.js');
|
|
74
|
+
require('./components/file-input.js');
|
|
75
|
+
require('./components/phone-input/phone-utils.js');
|
|
76
|
+
require('./components/phone-input/phone-input.js');
|
|
77
|
+
require('./components/checkbox.js');
|
|
78
|
+
require('./components/radio-group.js');
|
|
79
|
+
require('./components/table.js');
|
|
80
|
+
|
|
81
|
+
// Export FlowUI and SuperLeap from global scope
|
|
82
|
+
if (typeof global !== 'undefined' && global.FlowUI) {
|
|
83
|
+
// Create SuperLeap export
|
|
84
|
+
const SuperLeap = global.superleapClient ? {
|
|
85
|
+
init: global.superleapClient.init,
|
|
86
|
+
getSdk: global.superleapClient.getSdk,
|
|
87
|
+
isAvailable: global.superleapClient.isAvailable,
|
|
88
|
+
getDefaultConfig: global.superleapClient.getDefaultConfig
|
|
89
|
+
} : null;
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
FlowUI: global.FlowUI,
|
|
93
|
+
SuperLeap: SuperLeap
|
|
94
|
+
};
|
|
95
|
+
} else if (typeof window !== 'undefined' && window.FlowUI) {
|
|
96
|
+
// Create SuperLeap export
|
|
97
|
+
const SuperLeap = window.superleapClient ? {
|
|
98
|
+
init: window.superleapClient.init,
|
|
99
|
+
getSdk: window.superleapClient.getSdk,
|
|
100
|
+
isAvailable: window.superleapClient.isAvailable,
|
|
101
|
+
getDefaultConfig: window.superleapClient.getDefaultConfig
|
|
102
|
+
} : null;
|
|
103
|
+
|
|
104
|
+
module.exports = {
|
|
105
|
+
FlowUI: window.FlowUI,
|
|
106
|
+
SuperLeap: SuperLeap
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
} else if (isBrowser) {
|
|
110
|
+
// Browser environment - load all scripts dynamically
|
|
111
|
+
console.log("[Superleap-Flow] Initializing library...");
|
|
112
|
+
|
|
113
|
+
// Internal component storage (keeps components in closure)
|
|
114
|
+
const _components = {};
|
|
115
|
+
|
|
116
|
+
// Get the script's base path
|
|
117
|
+
const scripts = document.getElementsByTagName('script');
|
|
118
|
+
const currentScript = scripts[scripts.length - 1];
|
|
119
|
+
const basePath = currentScript.src.substring(0, currentScript.src.lastIndexOf('/') + 1);
|
|
120
|
+
|
|
121
|
+
// List of scripts to load in order
|
|
122
|
+
const scriptsToLoad = [
|
|
123
|
+
// Load SuperLeap SDK first
|
|
124
|
+
'https://cdn.jsdelivr.net/npm/superleap-sdk@2.4.1/superleap.js',
|
|
125
|
+
'core/superleapClient.js',
|
|
126
|
+
'components/toast.js',
|
|
127
|
+
'components/alert.js',
|
|
128
|
+
'components/label.js',
|
|
129
|
+
'core/flow.js',
|
|
130
|
+
'components/button.js',
|
|
131
|
+
'components/spinner.js',
|
|
132
|
+
'components/popover.js',
|
|
133
|
+
'components/select.js',
|
|
134
|
+
'components/enum-select.js',
|
|
135
|
+
'components/record-select.js',
|
|
136
|
+
'components/record-multiselect.js',
|
|
137
|
+
'components/time-picker.js',
|
|
138
|
+
'components/input.js',
|
|
139
|
+
'components/currency.js',
|
|
140
|
+
'components/textarea.js',
|
|
141
|
+
'components/duration/duration-utils.js',
|
|
142
|
+
'components/duration/duration-constants.js',
|
|
143
|
+
'components/duration/duration.js',
|
|
144
|
+
'components/date-time-picker/date-time-picker-utils.js',
|
|
145
|
+
'components/date-time-picker/date-time-picker.js',
|
|
146
|
+
'components/enumeration.js',
|
|
147
|
+
'components/multiselect.js',
|
|
148
|
+
'components/enum-multiselect.js',
|
|
149
|
+
'components/badge.js',
|
|
150
|
+
'components/avatar.js',
|
|
151
|
+
'components/icon.js',
|
|
152
|
+
'components/file-input.js',
|
|
153
|
+
'components/phone-input/phone-utils.js',
|
|
154
|
+
'components/phone-input/phone-input.js',
|
|
155
|
+
'components/checkbox.js',
|
|
156
|
+
'components/radio-group.js',
|
|
157
|
+
'components/table.js',
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
// Load scripts sequentially
|
|
161
|
+
let loadedCount = 0;
|
|
162
|
+
|
|
163
|
+
// Capture components from global scope into internal storage
|
|
164
|
+
function captureComponents() {
|
|
165
|
+
const componentNames = [
|
|
166
|
+
'superleapClient', 'Toast', 'Alert', 'Label', 'Button', 'Loader', 'Popover', 'Tooltip',
|
|
167
|
+
'Select', 'EnumSelect', 'RecordSelect', 'RecordMultiSelect', 'TimePicker',
|
|
168
|
+
'InputComponent', 'CurrencyComponent', 'TextareaComponent', 'Duration',
|
|
169
|
+
'DateTimePicker', 'Enumeration', 'MultiSelect', 'EnumMultiSelect', 'Badge', 'Avatar', 'Icon',
|
|
170
|
+
'FileInput', 'PhoneInput', 'Checkbox', 'RadioGroup', 'SuperleapTable'
|
|
171
|
+
];
|
|
172
|
+
|
|
173
|
+
componentNames.forEach(name => {
|
|
174
|
+
if (window[name]) {
|
|
175
|
+
_components[name] = window[name];
|
|
176
|
+
|
|
177
|
+
// Clean up global scope - remove all component globals
|
|
178
|
+
// Only FlowUI and SuperLeap will remain
|
|
179
|
+
delete window[name];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Add helper method to FlowUI for accessing internal components (advanced use)
|
|
184
|
+
if (window.FlowUI) {
|
|
185
|
+
window.FlowUI._getComponent = function(name) {
|
|
186
|
+
return _components[name];
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Expose SuperLeap from captured superleapClient (must use _components - superleapClient was already deleted from window)
|
|
191
|
+
const client = _components['superleapClient'];
|
|
192
|
+
if (client) {
|
|
193
|
+
window.SuperLeap = {
|
|
194
|
+
init: client.init.bind(client),
|
|
195
|
+
getSdk: client.getSdk.bind(client),
|
|
196
|
+
isAvailable: client.isAvailable.bind(client),
|
|
197
|
+
getDefaultConfig: client.getDefaultConfig.bind(client)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function loadScript(index) {
|
|
203
|
+
if (index >= scriptsToLoad.length) {
|
|
204
|
+
console.log("[Superleap-Flow] All components loaded successfully");
|
|
205
|
+
|
|
206
|
+
// Capture components into internal storage (also sets window.SuperLeap)
|
|
207
|
+
captureComponents();
|
|
208
|
+
|
|
209
|
+
// Dispatch custom event when library is ready
|
|
210
|
+
if (typeof CustomEvent !== 'undefined') {
|
|
211
|
+
const event = new CustomEvent('superleap-flow:ready', {
|
|
212
|
+
detail: {
|
|
213
|
+
FlowUI: window.FlowUI,
|
|
214
|
+
SuperLeap: window.SuperLeap,
|
|
215
|
+
components: _components
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
document.dispatchEvent(event);
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const script = document.createElement('script');
|
|
224
|
+
// Handle CDN URLs vs local paths
|
|
225
|
+
const scriptPath = scriptsToLoad[index];
|
|
226
|
+
script.src = scriptPath.startsWith('http') ? scriptPath : basePath + scriptPath;
|
|
227
|
+
script.async = false; // Ensure sequential loading
|
|
228
|
+
|
|
229
|
+
script.onload = function() {
|
|
230
|
+
loadedCount++;
|
|
231
|
+
loadScript(index + 1);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
script.onerror = function() {
|
|
235
|
+
console.error('[Superleap-Flow] Failed to load:', scriptsToLoad[index]);
|
|
236
|
+
loadScript(index + 1); // Continue loading other scripts
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
document.head.appendChild(script);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Start loading scripts
|
|
243
|
+
loadScript(0);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ES Module export (for bundlers like webpack, rollup, vite)
|
|
247
|
+
if (typeof window !== 'undefined' && window.FlowUI) {
|
|
248
|
+
if (typeof exports !== 'undefined') {
|
|
249
|
+
exports.FlowUI = window.FlowUI;
|
|
250
|
+
exports.SuperLeap = window.SuperLeap;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
})(typeof window !== 'undefined' ? window : this);
|