@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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Superleap-Flow SDK client
|
|
3
|
+
* Thin wrapper around the SuperLeap SDK (createSuperLeapSDK from sdk.js or superleap.js).
|
|
4
|
+
* Exposes getSdk() for record-select, file-input, etc.
|
|
5
|
+
* Load the SDK script before this script; then call superleapClient.init(config).
|
|
6
|
+
*
|
|
7
|
+
* Config shape matches SuperLeapSDK constructor options (see sdk.js).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
(function (global) {
|
|
11
|
+
"use strict";
|
|
12
|
+
|
|
13
|
+
var _config = null;
|
|
14
|
+
var _sdkInstance = null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Default config merged with user config when calling init().
|
|
18
|
+
* Matches SuperLeapSDK constructor defaults (sdk.js).
|
|
19
|
+
*/
|
|
20
|
+
var DEFAULT_CONFIG = {
|
|
21
|
+
apiKey: "",
|
|
22
|
+
baseUrl: "",
|
|
23
|
+
clientId: "",
|
|
24
|
+
clientSecret: "",
|
|
25
|
+
cache: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
maxSize: 1000,
|
|
28
|
+
defaultTTL: 5 * 60 * 1000,
|
|
29
|
+
ttl: {
|
|
30
|
+
schema: 30 * 60 * 1000,
|
|
31
|
+
records: 2 * 60 * 1000,
|
|
32
|
+
count: 60 * 1000,
|
|
33
|
+
user: 10 * 60 * 1000,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Deep-merge source into target (only own enumerable properties; arrays replaced, not merged).
|
|
40
|
+
*/
|
|
41
|
+
function mergeConfig(target, source) {
|
|
42
|
+
if (!source || typeof source !== "object") return target;
|
|
43
|
+
var result = {};
|
|
44
|
+
var key;
|
|
45
|
+
for (key in target) {
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(target, key)) {
|
|
47
|
+
result[key] = target[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (key in source) {
|
|
51
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
52
|
+
var s = source[key];
|
|
53
|
+
var t = result[key];
|
|
54
|
+
if (
|
|
55
|
+
t &&
|
|
56
|
+
s &&
|
|
57
|
+
typeof t === "object" &&
|
|
58
|
+
typeof s === "object" &&
|
|
59
|
+
!Array.isArray(t) &&
|
|
60
|
+
!Array.isArray(s)
|
|
61
|
+
) {
|
|
62
|
+
result[key] = mergeConfig(t, s);
|
|
63
|
+
} else {
|
|
64
|
+
result[key] = s;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Initialize the client with API config. Call this before using record-select or other SDK-dependent components.
|
|
73
|
+
* Config is merged with defaults; you can pass only baseUrl and apiKey.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} config - Options passed to createSuperLeapSDK (same as SuperLeapSDK constructor in sdk.js)
|
|
76
|
+
* @param {string} [config.apiKey] - Bearer token for authentication
|
|
77
|
+
* @param {string} [config.baseUrl] - Base URL for API (default: "https://app.superleap.dev/api/v1")
|
|
78
|
+
* @param {string} [config.clientId] - Client ID (if using client credentials)
|
|
79
|
+
* @param {string} [config.clientSecret] - Client secret (if using client credentials)
|
|
80
|
+
* @param {Object} [config.cache] - Cache configuration
|
|
81
|
+
* @param {boolean} [config.cache.enabled] - Enable caching (default: true)
|
|
82
|
+
* @param {number} [config.cache.maxSize] - Max cache entries (default: 1000)
|
|
83
|
+
* @param {number} [config.cache.defaultTTL] - Default TTL in ms (default: 5 minutes)
|
|
84
|
+
* @param {Object} [config.cache.ttl] - TTL per operation
|
|
85
|
+
* @param {number} [config.cache.ttl.schema] - Schema cache TTL (default: 30 min)
|
|
86
|
+
* @param {number} [config.cache.ttl.records] - Record query cache TTL (default: 2 min)
|
|
87
|
+
* @param {number} [config.cache.ttl.count] - Count query cache TTL (default: 1 min)
|
|
88
|
+
* @param {number} [config.cache.ttl.user] - User/me cache TTL (default: 10 min)
|
|
89
|
+
*/
|
|
90
|
+
function init(config) {
|
|
91
|
+
if (config == null) {
|
|
92
|
+
_config = null;
|
|
93
|
+
} else {
|
|
94
|
+
_config = mergeConfig(DEFAULT_CONFIG, config);
|
|
95
|
+
}
|
|
96
|
+
_sdkInstance = null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get the SDK instance. Creates it via createSuperLeapSDK(mergedConfig) on first call.
|
|
101
|
+
* Returns null if init() was not called or the SDK script is not loaded (components can show empty state).
|
|
102
|
+
*
|
|
103
|
+
* @returns {SuperLeapSDK|null} SDK instance or null
|
|
104
|
+
*/
|
|
105
|
+
function getSdk() {
|
|
106
|
+
if (typeof global.createSuperLeapSDK !== "function") {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (!_config) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (!_sdkInstance) {
|
|
113
|
+
_sdkInstance = global.createSuperLeapSDK(_config);
|
|
114
|
+
}
|
|
115
|
+
return _sdkInstance;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check if the client is initialized and the SDK factory is available (does not create the instance).
|
|
120
|
+
*
|
|
121
|
+
* @returns {boolean}
|
|
122
|
+
*/
|
|
123
|
+
function isAvailable() {
|
|
124
|
+
return typeof global.createSuperLeapSDK === "function" && _config != null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Return the default config object (for reference or to override specific keys).
|
|
129
|
+
*
|
|
130
|
+
* @returns {Object}
|
|
131
|
+
*/
|
|
132
|
+
function getDefaultConfig() {
|
|
133
|
+
return mergeConfig({}, DEFAULT_CONFIG);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var superleapClient = {
|
|
137
|
+
init: init,
|
|
138
|
+
getSdk: getSdk,
|
|
139
|
+
isAvailable: isAvailable,
|
|
140
|
+
getDefaultConfig: getDefaultConfig,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
if (global) {
|
|
144
|
+
global.superleapClient = superleapClient;
|
|
145
|
+
}
|
|
146
|
+
})(typeof window !== "undefined" ? window : this);
|