@kupola/kupola 1.2.0 → 1.3.1

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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -286
  3. package/adapters/axios.d.ts +34 -0
  4. package/adapters/axios.js +122 -0
  5. package/adapters/navios-http.d.ts +110 -0
  6. package/adapters/navios-http.js +151 -0
  7. package/dist/css/accessibility.css +119 -0
  8. package/dist/css/animations.css +224 -0
  9. package/dist/css/brand-themes.css +300 -0
  10. package/dist/css/colors_and_type.css +441 -0
  11. package/dist/css/components-ext.css +4165 -0
  12. package/dist/css/components.css +1483 -0
  13. package/dist/css/responsive.css +697 -0
  14. package/dist/css/scaffold.css +145 -0
  15. package/dist/css/states.css +316 -0
  16. package/dist/css/theme-dark.css +296 -0
  17. package/dist/css/theme-light.css +296 -0
  18. package/dist/css/utilities.css +171 -0
  19. package/dist/kupola.cjs.js +219 -161
  20. package/dist/kupola.cjs.js.map +1 -1
  21. package/dist/kupola.esm.js +6643 -5709
  22. package/dist/kupola.esm.js.map +1 -1
  23. package/dist/kupola.umd.js +219 -161
  24. package/dist/kupola.umd.js.map +1 -1
  25. package/dist/plugins/vite-plugin-kupola.js +120 -0
  26. package/dist/types/kupola.d.ts +421 -323
  27. package/js/calendar.js +334 -25
  28. package/js/carousel.js +182 -48
  29. package/js/collapse.js +148 -34
  30. package/js/color-picker.js +416 -108
  31. package/js/component.js +8 -19
  32. package/js/countdown.js +9 -8
  33. package/js/data-bind.js +73 -16
  34. package/js/datepicker.js +488 -110
  35. package/js/depends.js +710 -0
  36. package/js/dialog.js +4 -2
  37. package/js/drawer.js +172 -8
  38. package/js/dropdown.js +272 -17
  39. package/js/dynamic-tags.js +156 -40
  40. package/js/fileupload.js +9 -8
  41. package/js/form.js +280 -254
  42. package/js/global-events.js +281 -188
  43. package/js/heatmap.js +10 -7
  44. package/js/i18n.js +18 -10
  45. package/js/icons.js +141 -161
  46. package/js/image-preview.js +146 -2
  47. package/js/initializer.js +113 -71
  48. package/js/kupola-core.js +123 -45
  49. package/js/kupola-lifecycle.js +13 -11
  50. package/js/message.js +8 -1
  51. package/js/modal.js +207 -59
  52. package/js/notification.js +8 -1
  53. package/js/numberinput.js +9 -8
  54. package/js/pagination.js +263 -0
  55. package/js/registry.js +29 -12
  56. package/js/select.js +482 -27
  57. package/js/slide-captcha.js +11 -2
  58. package/js/slider.js +442 -25
  59. package/js/statcard.js +9 -7
  60. package/js/table.js +1210 -0
  61. package/js/tag.js +268 -14
  62. package/js/theme.js +14 -43
  63. package/js/timepicker.js +335 -66
  64. package/js/tooltip.js +317 -86
  65. package/js/utils.js +6 -2
  66. package/js/validation.js +6 -2
  67. package/js/virtual-list.js +11 -7
  68. package/js/web-components.js +288 -0
  69. package/package.json +77 -67
  70. package/plugins/vite-plugin-kupola.js +120 -0
  71. package/types/kupola.d.ts +421 -323
  72. package/CHANGELOG.md +0 -130
  73. package/INTEGRATION.md +0 -440
  74. package/PROJECT_SUMMARY.md +0 -312
  75. package/SKILL.md +0 -572
  76. package/dist/utils/utils/Kupola.cs +0 -77
  77. package/dist/utils/utils/Kupola.java +0 -104
  78. package/dist/utils/utils/kupola.go +0 -120
  79. package/dist/utils/utils/kupola.js +0 -63
  80. package/dist/utils/utils/kupola.py +0 -1392
  81. package/dist/utils/utils/kupola.rb +0 -69
  82. package/js/composition-api.js +0 -458
  83. package/js/error-handler.js +0 -181
  84. package/js/http.js +0 -419
  85. package/js/kupola-devtools.js +0 -598
  86. package/js/performance.js +0 -250
  87. package/js/router.js +0 -396
  88. package/js/security.js +0 -189
  89. package/js/test-utils.js +0 -251
  90. package/templates/base.html +0 -30
  91. package/templates/base_dashboard.html +0 -99
  92. package/utils/Kupola.cs +0 -77
  93. package/utils/Kupola.java +0 -104
  94. package/utils/kupola.go +0 -120
  95. package/utils/kupola.js +0 -63
  96. package/utils/kupola.py +0 -1392
  97. package/utils/kupola.rb +0 -69
package/js/http.js DELETED
@@ -1,419 +0,0 @@
1
- class KupolaHttp {
2
- constructor(options = {}) {
3
- this.baseURL = options.baseURL || '';
4
- this.timeout = options.timeout || 30000;
5
- this.headers = options.headers || {};
6
- this.cache = new Map();
7
- this.cacheTTL = options.cacheTTL || 60000;
8
- this.maxRetries = options.maxRetries || 0;
9
- this.retryDelay = options.retryDelay || 1000;
10
- this.activeRequests = new Map();
11
- this.withCredentials = options.withCredentials || false;
12
-
13
- this._useAxios = typeof axios !== 'undefined';
14
- if (this._useAxios) {
15
- this._initAxios(options);
16
- }
17
-
18
- if (options.interceptors) {
19
- this.interceptors = options.interceptors;
20
- }
21
- }
22
-
23
- _initAxios(options) {
24
- this.axios = axios.create({
25
- baseURL: this.baseURL,
26
- timeout: this.timeout,
27
- headers: this.headers
28
- });
29
-
30
- this.axios.defaults.withCredentials = options.withCredentials || false;
31
- }
32
-
33
- _generateCacheKey(config) {
34
- const { url, method = 'GET', params = {}, data = null } = config;
35
- const query = params ? new URLSearchParams(params).toString() : '';
36
- const dataKey = data ? JSON.stringify(data) : '';
37
- return `${method}:${url}:${query}:${dataKey}`;
38
- }
39
-
40
- _getCache(key) {
41
- const cached = this.cache.get(key);
42
- if (cached && Date.now() - cached.timestamp < this.cacheTTL) {
43
- return cached.data;
44
- }
45
- this.cache.delete(key);
46
- return null;
47
- }
48
-
49
- _setCache(key, data) {
50
- this.cache.set(key, { data, timestamp: Date.now() });
51
- }
52
-
53
- async _requestWithRetry(config, retryCount = 0) {
54
- try {
55
- return await this._request(config);
56
- } catch (error) {
57
- if (retryCount < this.maxRetries) {
58
- await new Promise(resolve => setTimeout(resolve, this.retryDelay * Math.pow(2, retryCount)));
59
- return this._requestWithRetry(config, retryCount + 1);
60
- }
61
- throw error;
62
- }
63
- }
64
-
65
- async _request(config) {
66
- const {
67
- url,
68
- method = 'GET',
69
- headers = {},
70
- params = {},
71
- data = null,
72
- timeout = this.timeout,
73
- cache = false
74
- } = config;
75
-
76
- const cacheKey = this._generateCacheKey({ url, method, params, data });
77
-
78
- if (cache && method === 'GET') {
79
- const cached = this._getCache(cacheKey);
80
- if (cached) {
81
- return cached;
82
- }
83
- }
84
-
85
- const controller = new AbortController();
86
- this.activeRequests.set(cacheKey, controller);
87
-
88
- const requestHeaders = { ...this.headers, ...headers };
89
-
90
- if (!requestHeaders['Content-Type'] && data && !(data instanceof FormData)) {
91
- requestHeaders['Content-Type'] = 'application/json';
92
- }
93
-
94
- let requestConfig = {
95
- url: this.baseURL ? new URL(url, this.baseURL).toString() : url,
96
- method,
97
- headers: requestHeaders,
98
- signal: controller.signal,
99
- credentials: this.withCredentials ? 'include' : 'same-origin'
100
- };
101
-
102
- if (Object.keys(params).length > 0) {
103
- const urlObj = new URL(requestConfig.url);
104
- Object.keys(params).forEach(key => {
105
- urlObj.searchParams.append(key, params[key]);
106
- });
107
- requestConfig.url = urlObj.toString();
108
- }
109
-
110
- if (data !== null) {
111
- requestConfig.body = data instanceof FormData ? data : JSON.stringify(data);
112
- }
113
-
114
- if (this.interceptors && this.interceptors.request) {
115
- try {
116
- const intercepted = await this.interceptors.request(requestConfig);
117
- if (intercepted) requestConfig = intercepted;
118
- } catch (error) {
119
- this.activeRequests.delete(cacheKey);
120
- if (this.interceptors.requestError) {
121
- return this.interceptors.requestError(error);
122
- }
123
- throw error;
124
- }
125
- }
126
-
127
- try {
128
- let response;
129
- if (this._useAxios) {
130
- const axiosConfig = {
131
- url: requestConfig.url.replace(this.baseURL, ''),
132
- method: requestConfig.method,
133
- headers: requestConfig.headers,
134
- signal: requestConfig.signal,
135
- timeout
136
- };
137
- if (data !== null) axiosConfig.data = data;
138
- if (params && Object.keys(params).length > 0) axiosConfig.params = params;
139
-
140
- response = await this.axios(axiosConfig);
141
- } else {
142
- response = await this._fetchWithTimeout(requestConfig, timeout);
143
-
144
- if (!response.ok) {
145
- const error = new Error(`HTTP error! status: ${response.status}`);
146
- error.status = response.status;
147
- error.statusText = response.statusText;
148
- throw error;
149
- }
150
- }
151
-
152
- const result = {
153
- data: this._useAxios ? response.data : await this._parseResponse(response),
154
- status: this._useAxios ? response.status : response.status,
155
- statusText: this._useAxios ? response.statusText : response.statusText,
156
- headers: this._useAxios ? response.headers : this._parseHeaders(response.headers),
157
- config: requestConfig
158
- };
159
-
160
- if (this.interceptors && this.interceptors.response) {
161
- return this.interceptors.response(result);
162
- }
163
-
164
- if (cache && method === 'GET') {
165
- this._setCache(cacheKey, result);
166
- }
167
-
168
- return result;
169
- } catch (error) {
170
- if (error.name === 'AbortError' || (this._useAxios && error.code === 'ERR_CANCELED')) {
171
- return null;
172
- }
173
- if (this.interceptors && this.interceptors.responseError) {
174
- return this.interceptors.responseError(error);
175
- }
176
- throw error;
177
- } finally {
178
- this.activeRequests.delete(cacheKey);
179
- }
180
- }
181
-
182
- async _fetchWithTimeout(config, timeout) {
183
- const controller = new AbortController();
184
- const signal = controller.signal;
185
-
186
- const timeoutPromise = new Promise((_, reject) => {
187
- const timerId = setTimeout(() => {
188
- controller.abort();
189
- reject(new Error('Request timeout'));
190
- }, timeout);
191
-
192
- signal.addEventListener('abort', () => {
193
- clearTimeout(timerId);
194
- });
195
- });
196
-
197
- const fetchPromise = fetch({ ...config, signal });
198
-
199
- return Promise.race([fetchPromise, timeoutPromise]);
200
- }
201
-
202
- async _parseResponse(response) {
203
- const contentType = response.headers.get('content-type');
204
- if (contentType && contentType.includes('application/json')) {
205
- return response.json();
206
- }
207
- return response.text();
208
- }
209
-
210
- _parseHeaders(headers) {
211
- const result = {};
212
- headers.forEach((value, key) => {
213
- result[key] = value;
214
- });
215
- return result;
216
- }
217
-
218
- cancelRequest(url, params = {}, method = 'GET', data = null) {
219
- const cacheKey = this._generateCacheKey({ url, method, params, data });
220
- if (this.activeRequests.has(cacheKey)) {
221
- this.activeRequests.get(cacheKey).abort();
222
- this.activeRequests.delete(cacheKey);
223
- return true;
224
- }
225
- return false;
226
- }
227
-
228
- cancelAllRequests() {
229
- this.activeRequests.forEach((controller) => {
230
- controller.abort();
231
- });
232
- this.activeRequests.clear();
233
- }
234
-
235
- clearCache() {
236
- this.cache.clear();
237
- }
238
-
239
- clearCacheByUrl(url) {
240
- this.cache.forEach((_, key) => {
241
- if (key.startsWith(`GET:${url}`)) {
242
- this.cache.delete(key);
243
- }
244
- });
245
- }
246
-
247
- get(url, config = {}) {
248
- const useCache = config.cache ?? true;
249
- const useRetry = config.retry ?? this.maxRetries > 0;
250
-
251
- const requestConfig = { ...config, url, method: 'GET', cache: useCache };
252
-
253
- if (useRetry) {
254
- return this._requestWithRetry(requestConfig);
255
- }
256
- return this._request(requestConfig);
257
- }
258
-
259
- post(url, data = null, config = {}) {
260
- const useRetry = config.retry ?? this.maxRetries > 0;
261
- const requestConfig = { ...config, url, method: 'POST', data, cache: false };
262
-
263
- if (useRetry) {
264
- return this._requestWithRetry(requestConfig);
265
- }
266
- return this._request(requestConfig);
267
- }
268
-
269
- async uploadFile(url, file, options = {}) {
270
- const {
271
- chunkSize = 2 * 1024 * 1024,
272
- onProgress,
273
- headers = {},
274
- parallel = false
275
- } = options;
276
-
277
- const totalChunks = Math.ceil(file.size / chunkSize);
278
- let uploadedChunks = 0;
279
- let progress = 0;
280
-
281
- const fileId = this._generateFileId(file);
282
-
283
- if (parallel) {
284
- const promises = [];
285
- for (let i = 0; i < totalChunks; i++) {
286
- const promise = this._uploadChunk(url, file, i, totalChunks, chunkSize, fileId, headers)
287
- .then(() => {
288
- uploadedChunks++;
289
- progress = Math.round((uploadedChunks / totalChunks) * 100);
290
-
291
- if (onProgress) {
292
- onProgress({
293
- progress,
294
- uploaded: uploadedChunks * chunkSize,
295
- total: file.size,
296
- currentChunk: uploadedChunks,
297
- totalChunks
298
- });
299
- }
300
- });
301
- promises.push(promise);
302
- }
303
- await Promise.all(promises);
304
- return this._completeUpload(url, fileId, totalChunks, file.name);
305
- }
306
-
307
- for (let i = 0; i < totalChunks; i++) {
308
- await this._uploadChunk(url, file, i, totalChunks, chunkSize, fileId, headers);
309
-
310
- uploadedChunks++;
311
- progress = Math.round((uploadedChunks / totalChunks) * 100);
312
-
313
- if (onProgress) {
314
- onProgress({
315
- progress,
316
- uploaded: uploadedChunks * chunkSize,
317
- total: file.size,
318
- currentChunk: i + 1,
319
- totalChunks
320
- });
321
- }
322
- }
323
-
324
- return this._completeUpload(url, fileId, totalChunks, file.name);
325
- }
326
-
327
- async _uploadChunk(url, file, chunkIndex, totalChunks, chunkSize, fileId, headers) {
328
- const start = chunkIndex * chunkSize;
329
- const end = Math.min(start + chunkSize, file.size);
330
- const chunk = file.slice(start, end);
331
-
332
- const formData = new FormData();
333
- formData.append('chunk', chunk);
334
- formData.append('chunkIndex', chunkIndex);
335
- formData.append('totalChunks', totalChunks);
336
- formData.append('fileId', fileId);
337
- formData.append('fileName', file.name);
338
- formData.append('fileSize', file.size);
339
-
340
- return this.post(`${url}/chunk`, formData, { headers });
341
- }
342
-
343
- async _completeUpload(url, fileId, totalChunks, fileName) {
344
- return this.post(`${url}/complete`, { fileId, totalChunks, fileName });
345
- }
346
-
347
- _generateFileId(file) {
348
- const hash = `${file.name}-${file.size}-${file.lastModified}`;
349
- let result = 0;
350
- for (let i = 0; i < hash.length; i++) {
351
- result = ((result << 5) - result) + hash.charCodeAt(i);
352
- result |= 0;
353
- }
354
- return Math.abs(result).toString(36) + Date.now().toString(36);
355
- }
356
-
357
- put(url, data = null, config = {}) {
358
- const useRetry = config.retry ?? this.maxRetries > 0;
359
- const requestConfig = { ...config, url, method: 'PUT', data, cache: false };
360
-
361
- if (useRetry) {
362
- return this._requestWithRetry(requestConfig);
363
- }
364
- return this._request(requestConfig);
365
- }
366
-
367
- delete(url, config = {}) {
368
- const useRetry = config.retry ?? this.maxRetries > 0;
369
- const requestConfig = { ...config, url, method: 'DELETE', cache: false };
370
-
371
- if (useRetry) {
372
- return this._requestWithRetry(requestConfig);
373
- }
374
- return this._request(requestConfig);
375
- }
376
-
377
- patch(url, data = null, config = {}) {
378
- const useRetry = config.retry ?? this.maxRetries > 0;
379
- const requestConfig = { ...config, url, method: 'PATCH', data, cache: false };
380
-
381
- if (useRetry) {
382
- return this._requestWithRetry(requestConfig);
383
- }
384
- return this._request(requestConfig);
385
- }
386
-
387
- setHeader(name, value) {
388
- this.headers[name] = value;
389
- if (this.axios) {
390
- this.axios.defaults.headers.common[name] = value;
391
- }
392
- }
393
-
394
- setToken(token, type = 'Bearer') {
395
- this.headers['Authorization'] = `${type} ${token}`;
396
- if (this.axios) {
397
- this.axios.defaults.headers.common['Authorization'] = `${type} ${token}`;
398
- }
399
- }
400
-
401
- setCacheTTL(ttl) {
402
- this.cacheTTL = ttl;
403
- }
404
-
405
- setMaxRetries(retries) {
406
- this.maxRetries = retries;
407
- }
408
- }
409
-
410
- function createHttp(options) {
411
- return new KupolaHttp(options);
412
- }
413
-
414
- if (typeof module !== 'undefined' && module.exports) {
415
- module.exports = { KupolaHttp, createHttp };
416
- } else {
417
- window.KupolaHttp = KupolaHttp;
418
- window.createHttp = createHttp;
419
- }