@kupola/kupola 1.2.0 → 1.4.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 (111) 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/css/components-ext.css +157 -0
  8. package/css/components.css +69 -0
  9. package/css/theme-dark.css +5 -5
  10. package/css/utilities.css +119 -1
  11. package/dist/css/accessibility.css +119 -0
  12. package/dist/css/animations.css +224 -0
  13. package/dist/css/brand-themes.css +300 -0
  14. package/dist/css/colors_and_type.css +441 -0
  15. package/dist/css/components-ext.css +4165 -0
  16. package/dist/css/components.css +1483 -0
  17. package/dist/css/kupola.css +1 -12
  18. package/dist/css/kupola.min.css +1 -0
  19. package/dist/css/responsive.css +697 -0
  20. package/dist/css/scaffold.css +145 -0
  21. package/dist/css/states.css +316 -0
  22. package/dist/css/theme-dark.css +296 -0
  23. package/dist/css/theme-light.css +296 -0
  24. package/dist/css/utilities.css +171 -0
  25. package/dist/icons.svg +284 -0
  26. package/dist/kupola.cjs.js +17409 -257
  27. package/dist/kupola.cjs.js.map +1 -1
  28. package/dist/kupola.css +9000 -0
  29. package/dist/kupola.esm.js +17183 -7597
  30. package/dist/kupola.esm.js.map +1 -1
  31. package/dist/kupola.min.css +1 -0
  32. package/dist/kupola.min.js +2 -0
  33. package/dist/kupola.min.js.map +1 -0
  34. package/dist/kupola.umd.js +17415 -257
  35. package/dist/kupola.umd.js.map +1 -1
  36. package/dist/plugins/vite-plugin-kupola.js +120 -0
  37. package/dist/types/kupola.d.ts +421 -323
  38. package/js/calendar.js +334 -25
  39. package/js/carousel.js +182 -48
  40. package/js/collapse.js +148 -34
  41. package/js/color-picker.js +416 -108
  42. package/js/component.js +8 -19
  43. package/js/countdown.js +9 -8
  44. package/js/data-bind.js +73 -16
  45. package/js/datepicker.js +488 -110
  46. package/js/depends.js +710 -0
  47. package/js/dialog.js +4 -2
  48. package/js/drawer.js +172 -8
  49. package/js/dropdown.js +272 -17
  50. package/js/dynamic-tags.js +156 -40
  51. package/js/fileupload.js +9 -8
  52. package/js/form.js +280 -254
  53. package/js/global-events.js +281 -188
  54. package/js/heatmap.js +10 -7
  55. package/js/i18n.js +18 -10
  56. package/js/icons.js +141 -161
  57. package/js/image-preview.js +146 -2
  58. package/js/initializer.js +151 -71
  59. package/js/kupola-core.js +123 -45
  60. package/js/kupola-lifecycle.js +13 -11
  61. package/js/message.js +8 -1
  62. package/js/modal.js +207 -59
  63. package/js/notification.js +8 -1
  64. package/js/numberinput.js +9 -8
  65. package/js/pagination.js +263 -0
  66. package/js/registry.js +29 -12
  67. package/js/select.js +482 -27
  68. package/js/slide-captcha.js +11 -2
  69. package/js/slider.js +442 -25
  70. package/js/statcard.js +9 -7
  71. package/js/table.js +1210 -0
  72. package/js/tag.js +268 -14
  73. package/js/theme-standalone.js +88 -0
  74. package/js/theme.js +14 -43
  75. package/js/timepicker.js +335 -66
  76. package/js/tooltip.js +317 -86
  77. package/js/utils.js +6 -2
  78. package/js/validation.js +6 -2
  79. package/js/virtual-list.js +11 -7
  80. package/js/web-components.js +288 -0
  81. package/package.json +81 -67
  82. package/plugins/vite-plugin-kupola.js +120 -0
  83. package/scripts/build-css.cjs +113 -0
  84. package/scripts/build-svg-sprite.cjs +107 -0
  85. package/types/kupola.d.ts +421 -323
  86. package/CHANGELOG.md +0 -130
  87. package/INTEGRATION.md +0 -440
  88. package/PROJECT_SUMMARY.md +0 -312
  89. package/SKILL.md +0 -572
  90. package/dist/utils/utils/Kupola.cs +0 -77
  91. package/dist/utils/utils/Kupola.java +0 -104
  92. package/dist/utils/utils/kupola.go +0 -120
  93. package/dist/utils/utils/kupola.js +0 -63
  94. package/dist/utils/utils/kupola.py +0 -1392
  95. package/dist/utils/utils/kupola.rb +0 -69
  96. package/js/composition-api.js +0 -458
  97. package/js/error-handler.js +0 -181
  98. package/js/http.js +0 -419
  99. package/js/kupola-devtools.js +0 -598
  100. package/js/performance.js +0 -250
  101. package/js/router.js +0 -396
  102. package/js/security.js +0 -189
  103. package/js/test-utils.js +0 -251
  104. package/templates/base.html +0 -30
  105. package/templates/base_dashboard.html +0 -99
  106. package/utils/Kupola.cs +0 -77
  107. package/utils/Kupola.java +0 -104
  108. package/utils/kupola.go +0 -120
  109. package/utils/kupola.js +0 -63
  110. package/utils/kupola.py +0 -1392
  111. package/utils/kupola.rb +0 -69
package/js/tooltip.js CHANGED
@@ -1,27 +1,172 @@
1
1
  class Tooltip {
2
- constructor(element) {
3
- this.element = element;
4
- this.tooltipEl = null;
5
-
6
- this._showTooltip = null;
7
- this._hideTooltip = null;
8
- }
9
-
10
- init() {
11
- if (this.element.__kupolaInitialized) return;
12
-
13
- this._showTooltip = () => {
14
- const text = this.element.getAttribute('data-tooltip');
15
- const position = this.element.getAttribute('data-tooltip-position') || 'top';
16
- if (!text) return;
17
-
18
- this.tooltipEl = document.createElement('div');
19
- this.tooltipEl.className = 'ds-tooltip is-visible';
20
- this.tooltipEl.textContent = text;
21
-
22
- document.body.appendChild(this.tooltipEl);
23
-
24
- requestAnimationFrame(() => {
2
+ constructor(element, options = {}) {
3
+ this.element = element;
4
+ this.tooltipEl = null;
5
+
6
+ this.options = options;
7
+ this.delay = options.delay || parseInt(element.getAttribute('data-tooltip-delay')) || 0;
8
+ this.hideDelay = options.hideDelay || parseInt(element.getAttribute('data-tooltip-hide-delay')) || 0;
9
+ this.trigger = options.trigger || element.getAttribute('data-tooltip-trigger') || 'hover'; // hover | click | focus | manual
10
+ this.html = options.html || element.hasAttribute('data-tooltip-html');
11
+ this.theme = options.theme || element.getAttribute('data-tooltip-theme') || 'default'; // default | dark | light
12
+ this.position = options.position || element.getAttribute('data-tooltip-position') || 'top';
13
+ this.animation = options.animation !== false;
14
+ this.mouseFollow = options.mouseFollow || element.hasAttribute('data-tooltip-mouse-follow');
15
+
16
+ this._showTooltip = null;
17
+ this._hideTooltip = null;
18
+ this._showTimer = null;
19
+ this._hideTimer = null;
20
+ this._clickHandler = null;
21
+ this._focusHandler = null;
22
+ this._blurHandler = null;
23
+ this._mouseMoveHandler = null;
24
+
25
+ this.isVisible = false;
26
+ }
27
+
28
+ init() {
29
+ if (this.element.__kupolaInitialized) return;
30
+
31
+ this._showTooltip = () => {
32
+ if (this.delay > 0) {
33
+ this._showTimer = setTimeout(() => this.show(), this.delay);
34
+ } else {
35
+ this.show();
36
+ }
37
+ };
38
+
39
+ this._hideTooltip = () => {
40
+ if (this._showTimer) {
41
+ clearTimeout(this._showTimer);
42
+ this._showTimer = null;
43
+ }
44
+ if (this.hideDelay > 0) {
45
+ this._hideTimer = setTimeout(() => this.hide(), this.hideDelay);
46
+ } else {
47
+ this.hide();
48
+ }
49
+ };
50
+
51
+ this._clickHandler = () => {
52
+ if (this.isVisible) {
53
+ this.hide();
54
+ } else {
55
+ this.show();
56
+ }
57
+ };
58
+
59
+ this._mouseMoveHandler = (e) => {
60
+ if (!this.isVisible || !this.mouseFollow || !this.tooltipEl) return;
61
+
62
+ const tooltipRect = this.tooltipEl.getBoundingClientRect();
63
+ let left = e.clientX + 10;
64
+ let top = e.clientY + 10;
65
+
66
+ const viewportWidth = window.innerWidth;
67
+ const viewportHeight = window.innerHeight;
68
+
69
+ if (left + tooltipRect.width > viewportWidth) {
70
+ left = e.clientX - tooltipRect.width - 10;
71
+ }
72
+ if (top + tooltipRect.height > viewportHeight) {
73
+ top = e.clientY - tooltipRect.height - 10;
74
+ }
75
+
76
+ this.tooltipEl.style.left = `${left}px`;
77
+ this.tooltipEl.style.top = `${top}px`;
78
+ };
79
+
80
+ if (this.trigger === 'hover' || this.trigger === 'focus') {
81
+ this.element.addEventListener('mouseenter', this._showTooltip);
82
+ this.element.addEventListener('mouseleave', this._hideTooltip);
83
+
84
+ if (this.mouseFollow) {
85
+ this.element.addEventListener('mousemove', this._mouseMoveHandler);
86
+ }
87
+ }
88
+
89
+ if (this.trigger === 'click') {
90
+ this.element.addEventListener('click', this._clickHandler);
91
+
92
+ document.addEventListener('click', (e) => {
93
+ if (this.isVisible && !this.element.contains(e.target) && !this.tooltipEl?.contains(e.target)) {
94
+ this.hide();
95
+ }
96
+ });
97
+ }
98
+
99
+ if (this.trigger === 'focus' || this.trigger === 'hover') {
100
+ this.element.addEventListener('focus', this._showTooltip);
101
+ this.element.addEventListener('blur', this._hideTooltip);
102
+ }
103
+
104
+ this.element.__kupolaInitialized = true;
105
+ }
106
+
107
+ show() {
108
+ if (this.isVisible) return;
109
+
110
+ const text = this.element.getAttribute('data-tooltip');
111
+ if (!text) return;
112
+
113
+ this.tooltipEl = document.createElement('div');
114
+ this.tooltipEl.className = `ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;
115
+
116
+ if (this.html) {
117
+ this.tooltipEl.innerHTML = text;
118
+ } else {
119
+ this.tooltipEl.textContent = text;
120
+ }
121
+
122
+ document.body.appendChild(this.tooltipEl);
123
+
124
+ requestAnimationFrame(() => {
125
+ this.tooltipEl.classList.add('is-visible');
126
+
127
+ if (!this.mouseFollow) {
128
+ this._positionTooltip();
129
+ }
130
+
131
+ this.isVisible = true;
132
+ this.element.dispatchEvent(new CustomEvent('kupola:tooltip-show', {
133
+ detail: { tooltip: this.tooltipEl },
134
+ bubbles: true
135
+ }));
136
+ });
137
+ }
138
+
139
+ hide() {
140
+ if (!this.isVisible || !this.tooltipEl) return;
141
+
142
+ this.tooltipEl.classList.remove('is-visible');
143
+
144
+ const removeEl = this.tooltipEl;
145
+ setTimeout(() => {
146
+ if (removeEl === this.tooltipEl) {
147
+ removeEl.remove();
148
+ this.tooltipEl = null;
149
+ }
150
+ }, this.animation ? 200 : 0);
151
+
152
+ this.isVisible = false;
153
+ this.element.dispatchEvent(new CustomEvent('kupola:tooltip-hide', {
154
+ detail: { tooltip: removeEl },
155
+ bubbles: true
156
+ }));
157
+ }
158
+
159
+ toggle() {
160
+ if (this.isVisible) {
161
+ this.hide();
162
+ } else {
163
+ this.show();
164
+ }
165
+ }
166
+
167
+ _positionTooltip() {
168
+ if (!this.tooltipEl) return;
169
+
25
170
  const rect = this.element.getBoundingClientRect();
26
171
  const tooltipRect = this.tooltipEl.getBoundingClientRect();
27
172
  const viewportWidth = window.innerWidth;
@@ -29,24 +174,24 @@ class Tooltip {
29
174
 
30
175
  let left, top;
31
176
 
32
- switch (position) {
33
- case 'bottom':
34
- left = rect.left + rect.width / 2 - tooltipRect.width / 2;
35
- top = rect.bottom + 8;
36
- break;
37
- case 'right':
38
- left = rect.right + 8;
39
- top = rect.top + rect.height / 2 - tooltipRect.height / 2;
40
- break;
41
- case 'left':
42
- left = rect.left - tooltipRect.width - 8;
43
- top = rect.top + rect.height / 2 - tooltipRect.height / 2;
44
- break;
45
- case 'top':
46
- default:
47
- left = rect.left + rect.width / 2 - tooltipRect.width / 2;
48
- top = rect.top - tooltipRect.height - 8;
49
- break;
177
+ switch (this.position) {
178
+ case 'bottom':
179
+ left = rect.left + rect.width / 2 - tooltipRect.width / 2;
180
+ top = rect.bottom + 8;
181
+ break;
182
+ case 'right':
183
+ left = rect.right + 8;
184
+ top = rect.top + rect.height / 2 - tooltipRect.height / 2;
185
+ break;
186
+ case 'left':
187
+ left = rect.left - tooltipRect.width - 8;
188
+ top = rect.top + rect.height / 2 - tooltipRect.height / 2;
189
+ break;
190
+ case 'top':
191
+ default:
192
+ left = rect.left + rect.width / 2 - tooltipRect.width / 2;
193
+ top = rect.top - tooltipRect.height - 8;
194
+ break;
50
195
  }
51
196
 
52
197
  if (left < 8) left = 8;
@@ -57,66 +202,152 @@ class Tooltip {
57
202
  this.tooltipEl.style.left = `${left}px`;
58
203
  this.tooltipEl.style.top = `${top}px`;
59
204
  this.tooltipEl.style.position = 'fixed';
60
- });
61
- };
205
+ }
62
206
 
63
- this._hideTooltip = () => {
64
- if (this.tooltipEl) {
65
- this.tooltipEl.remove();
66
- this.tooltipEl = null;
67
- }
68
- };
207
+ updateContent(content, isHtml = false) {
208
+ this.element.setAttribute('data-tooltip', content);
209
+ if (isHtml) {
210
+ this.element.setAttribute('data-tooltip-html', '');
211
+ } else {
212
+ this.element.removeAttribute('data-tooltip-html');
213
+ }
214
+ this.html = isHtml;
215
+
216
+ if (this.isVisible && this.tooltipEl) {
217
+ if (this.html) {
218
+ this.tooltipEl.innerHTML = content;
219
+ } else {
220
+ this.tooltipEl.textContent = content;
221
+ }
222
+ this._positionTooltip();
223
+ }
224
+ }
69
225
 
70
- this.element.addEventListener('mouseenter', this._showTooltip);
71
- this.element.addEventListener('mouseleave', this._hideTooltip);
72
- this.element.addEventListener('focus', this._showTooltip);
73
- this.element.addEventListener('blur', this._hideTooltip);
74
-
75
- this.element.__kupolaInitialized = true;
76
- }
226
+ setPosition(position) {
227
+ if (['top', 'bottom', 'left', 'right'].includes(position)) {
228
+ this.position = position;
229
+ this.element.setAttribute('data-tooltip-position', position);
230
+
231
+ if (this.tooltipEl) {
232
+ this.tooltipEl.className = `ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;
233
+ if (this.isVisible) {
234
+ this._positionTooltip();
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ setTheme(theme) {
241
+ this.theme = theme;
242
+ this.element.setAttribute('data-tooltip-theme', theme);
243
+
244
+ if (this.tooltipEl) {
245
+ this.tooltipEl.className = `ds-tooltip ds-tooltip--${this.position} ds-tooltip--${this.theme}`;
246
+ }
247
+ }
77
248
 
78
- destroy() {
79
- if (!this.element.__kupolaInitialized) return;
249
+ setDelay(delay) {
250
+ this.delay = delay;
251
+ this.element.setAttribute('data-tooltip-delay', delay);
252
+ }
80
253
 
81
- if (this._showTooltip) {
82
- this.element.removeEventListener('mouseenter', this._showTooltip);
83
- this.element.removeEventListener('focus', this._showTooltip);
254
+ setHideDelay(delay) {
255
+ this.hideDelay = delay;
256
+ this.element.setAttribute('data-tooltip-hide-delay', delay);
84
257
  }
85
-
86
- if (this._hideTooltip) {
87
- this.element.removeEventListener('mouseleave', this._hideTooltip);
88
- this.element.removeEventListener('blur', this._hideTooltip);
258
+
259
+ setTrigger(trigger) {
260
+ if (['hover', 'click', 'focus', 'manual'].includes(trigger)) {
261
+ this.destroy();
262
+ this.trigger = trigger;
263
+ this.element.setAttribute('data-tooltip-trigger', trigger);
264
+ this.init();
265
+ }
89
266
  }
90
-
91
- if (this._showTooltip && this._hideTooltip) {
92
- this._hideTooltip();
267
+
268
+ enableMouseFollow(enable) {
269
+ this.mouseFollow = enable;
270
+ if (enable) {
271
+ this.element.setAttribute('data-tooltip-mouse-follow', '');
272
+ this.element.addEventListener('mousemove', this._mouseMoveHandler);
273
+ } else {
274
+ this.element.removeAttribute('data-tooltip-mouse-follow');
275
+ this.element.removeEventListener('mousemove', this._mouseMoveHandler);
276
+ }
277
+ }
278
+
279
+ destroy() {
280
+ if (!this.element.__kupolaInitialized) return;
281
+
282
+ if (this._showTimer) {
283
+ clearTimeout(this._showTimer);
284
+ this._showTimer = null;
285
+ }
286
+ if (this._hideTimer) {
287
+ clearTimeout(this._hideTimer);
288
+ this._hideTimer = null;
289
+ }
290
+
291
+ if (this.trigger === 'hover' || this.trigger === 'focus') {
292
+ this.element.removeEventListener('mouseenter', this._showTooltip);
293
+ this.element.removeEventListener('mouseleave', this._hideTooltip);
294
+ }
295
+
296
+ if (this.trigger === 'click') {
297
+ this.element.removeEventListener('click', this._clickHandler);
298
+ }
299
+
300
+ if (this.trigger === 'focus' || this.trigger === 'hover') {
301
+ this.element.removeEventListener('focus', this._showTooltip);
302
+ this.element.removeEventListener('blur', this._hideTooltip);
303
+ }
304
+
305
+ if (this.mouseFollow) {
306
+ this.element.removeEventListener('mousemove', this._mouseMoveHandler);
307
+ }
308
+
309
+ if (this.tooltipEl) {
310
+ this.tooltipEl.remove();
311
+ this.tooltipEl = null;
312
+ }
313
+
314
+ this.isVisible = false;
315
+ this._showTooltip = null;
316
+ this._hideTooltip = null;
317
+ this._clickHandler = null;
318
+ this._mouseMoveHandler = null;
319
+ this.element.__kupolaInitialized = false;
93
320
  }
94
-
95
- this._showTooltip = null;
96
- this._hideTooltip = null;
97
- this.element.__kupolaInitialized = false;
98
- }
99
321
  }
100
322
 
101
- function initTooltip(element) {
102
- const tooltip = new Tooltip(element);
103
- tooltip.init();
104
- element._kupolaTooltip = tooltip;
323
+ function initTooltip(element, options) {
324
+ const tooltip = new Tooltip(element, options);
325
+ tooltip.init();
326
+ element._kupolaTooltip = tooltip;
105
327
  }
106
328
 
107
329
  function initTooltips(root = document) {
108
- root.querySelectorAll('[data-tooltip]').forEach(element => {
109
- initTooltip(element);
110
- });
330
+ root.querySelectorAll('[data-tooltip]').forEach(element => {
331
+ initTooltip(element);
332
+ });
111
333
  }
112
334
 
113
335
  function cleanupTooltip(element) {
114
- if (element._kupolaTooltip) {
115
- element._kupolaTooltip.destroy();
116
- element._kupolaTooltip = null;
117
- }
336
+ if (element._kupolaTooltip) {
337
+ element._kupolaTooltip.destroy();
338
+ element._kupolaTooltip = null;
339
+ }
118
340
  }
119
341
 
120
- if (window.kupolaInitializer) {
121
- window.kupolaInitializer.register('tooltip', initTooltip, cleanupTooltip);
342
+ export { Tooltip, initTooltip, initTooltips, cleanupTooltip };
343
+
344
+ if (typeof window !== 'undefined') {
345
+ window.Tooltip = Tooltip;
346
+ window.initTooltip = initTooltip;
347
+ window.initTooltips = initTooltips;
348
+ window.cleanupTooltip = cleanupTooltip;
349
+
350
+ if (window.kupolaInitializer) {
351
+ window.kupolaInitializer.register('tooltip', initTooltip, cleanupTooltip);
352
+ }
122
353
  }
package/js/utils.js CHANGED
@@ -1454,5 +1454,9 @@ const KupolaUtils = {
1454
1454
  }
1455
1455
  };
1456
1456
 
1457
- window.KupolaUtils = KupolaUtils;
1458
- window.kupolaUtils = KupolaUtils;
1457
+ export { KupolaUtils };
1458
+
1459
+ if (typeof window !== 'undefined') {
1460
+ window.KupolaUtils = KupolaUtils;
1461
+ window.kupolaUtils = KupolaUtils;
1462
+ }
package/js/validation.js CHANGED
@@ -549,5 +549,9 @@ if (!window.__kupolaValidationInitialized) {
549
549
  });
550
550
  }
551
551
 
552
- window.KupolaValidator = KupolaValidator;
553
- window.kupolaValidator = validator;
552
+ export { KupolaValidator, validator };
553
+
554
+ if (typeof window !== 'undefined') {
555
+ window.KupolaValidator = KupolaValidator;
556
+ window.kupolaValidator = validator;
557
+ }
@@ -581,13 +581,17 @@ function initVirtualLists() {
581
581
  });
582
582
  }
583
583
 
584
- if (typeof module !== 'undefined' && module.exports) {
585
- module.exports = { VirtualList, initVirtualLists, initVirtualList, cleanupVirtualList, createVirtualList, generateMockVirtualListData };
586
- } else {
584
+ export { VirtualList, initVirtualLists, initVirtualList, cleanupVirtualList, createVirtualList, generateMockVirtualListData };
585
+
586
+ if (typeof window !== 'undefined') {
587
+ window.VirtualList = VirtualList;
587
588
  window.initVirtualList = initVirtualList;
588
589
  window.cleanupVirtualList = cleanupVirtualList;
589
- }
590
-
591
- if (window.kupolaInitializer) {
592
- window.kupolaInitializer.register('virtual-list', initVirtualList, cleanupVirtualList);
590
+ window.initVirtualLists = initVirtualLists;
591
+ window.createVirtualList = createVirtualList;
592
+ window.generateMockVirtualListData = generateMockVirtualListData;
593
+
594
+ if (window.kupolaInitializer) {
595
+ window.kupolaInitializer.register('virtual-list', initVirtualList, cleanupVirtualList);
596
+ }
593
597
  }