@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
@@ -1,144 +1,452 @@
1
1
  class ColorPicker {
2
- constructor(element) {
3
- this.element = element;
4
- this.trigger = element.querySelector('.ds-color-picker__trigger');
5
- this.panel = element.querySelector('.ds-color-picker__panel');
6
- this.valueSpan = element.querySelector('.ds-color-picker__value');
7
- this.customInput = element.querySelector('.ds-color-picker__input');
8
- this.scope = `colorpicker-${Math.random().toString(36).substr(2, 9)}`;
9
-
10
- this._triggerClickHandler = null;
11
- this._documentClickHandler = null;
12
- this._documentClickListener = null;
13
- this._colorClickHandler = null;
14
- this._inputInputHandler = null;
15
- }
16
-
17
- init() {
18
- if (!this.trigger || !this.panel) return;
19
- if (this.element.__kupolaInitialized) return;
20
-
21
- this._triggerClickHandler = (e) => {
22
- e.stopPropagation();
23
- this.togglePanel();
24
- };
25
-
26
- this._colorClickHandler = (e) => {
27
- const colorBtn = e.currentTarget;
28
- const color = colorBtn.getAttribute('data-color');
29
- this.updateColor(color);
30
- this.hidePanel();
31
- };
32
-
33
- this._inputInputHandler = (e) => {
34
- this.updateColor(e.target.value);
35
- };
36
-
37
- this._documentClickHandler = (e) => {
38
- if (!this.element.contains(e.target)) {
39
- this.hidePanel();
40
- }
41
- };
42
-
43
- this.trigger.addEventListener('click', this._triggerClickHandler);
44
-
45
- this.panel.querySelectorAll('.ds-color-picker__color').forEach(colorBtn => {
46
- colorBtn.addEventListener('click', this._colorClickHandler);
47
- colorBtn._colorPickerColorHandler = this._colorClickHandler;
48
- });
2
+ constructor(element, options = {}) {
3
+ this.element = element;
4
+ this.trigger = element.querySelector('.ds-color-picker__trigger');
5
+ this.panel = element.querySelector('.ds-color-picker__panel');
6
+ this.valueSpan = element.querySelector('.ds-color-picker__value');
7
+ this.customInput = element.querySelector('.ds-color-picker__input');
8
+ this.scope = `colorpicker-${Math.random().toString(36).substr(2, 9)}`;
9
+
10
+ this.options = options;
11
+ this.value = options.value || '#007bff';
12
+ this.showAlpha = options.showAlpha !== false;
13
+ this.mode = options.mode || 'hex'; // hex | rgb | hsl
14
+ this.previousColors = options.previousColors || this._getStoredColors();
15
+ this.previousColorsLimit = options.previousColorsLimit || 12;
16
+
17
+ this._triggerClickHandler = null;
18
+ this._documentClickHandler = null;
19
+ this._documentClickListener = null;
20
+ this._colorClickHandler = null;
21
+ this._inputInputHandler = null;
22
+ this._alphaChangeHandler = null;
23
+ this._modeChangeHandler = null;
24
+ this._hueChangeHandler = null;
25
+ this._saturationChangeHandler = null;
26
+ this._valueChangeHandler = null;
27
+
28
+ this.hue = 210;
29
+ this.saturation = 100;
30
+ this.brightness = 50;
31
+ this.alpha = 100;
32
+
33
+ this._colorStringToHSB(this.value);
34
+ }
35
+
36
+ _getStoredColors() {
37
+ try {
38
+ const stored = localStorage.getItem('kupola-color-picker-previous');
39
+ return stored ? JSON.parse(stored) : [];
40
+ } catch {
41
+ return [];
42
+ }
43
+ }
44
+
45
+ _storeColors() {
46
+ try {
47
+ localStorage.setItem('kupola-color-picker-previous', JSON.stringify(this.previousColors));
48
+ } catch {}
49
+ }
50
+
51
+ _addPreviousColor(color) {
52
+ const index = this.previousColors.indexOf(color);
53
+ if (index !== -1) {
54
+ this.previousColors.splice(index, 1);
55
+ }
56
+ this.previousColors.unshift(color);
57
+ this.previousColors = this.previousColors.slice(0, this.previousColorsLimit);
58
+ this._storeColors();
59
+ this._renderPreviousColors();
60
+ }
61
+
62
+ _colorStringToHSB(color) {
63
+ const hex = color.replace(/^#/, '');
64
+ const r = parseInt(hex.substring(0, 2), 16) / 255;
65
+ const g = parseInt(hex.substring(2, 4), 16) / 255;
66
+ const b = parseInt(hex.substring(4, 6), 16) / 255;
67
+ const a = hex.length === 8 ? parseInt(hex.substring(6, 8), 16) / 255 : 1;
68
+
69
+ const max = Math.max(r, g, b);
70
+ const min = Math.min(r, g, b);
71
+ let h = 0, s = 0, v = max;
72
+
73
+ const d = max - min;
74
+ s = max === 0 ? 0 : d / max;
75
+
76
+ if (max !== min) {
77
+ switch (max) {
78
+ case r: h = ((g - b) / d + (g < b ? 6 : 0)) / 6; break;
79
+ case g: h = ((b - r) / d + 2) / 6; break;
80
+ case b: h = ((r - g) / d + 4) / 6; break;
81
+ }
82
+ }
83
+
84
+ this.hue = Math.round(h * 360);
85
+ this.saturation = Math.round(s * 100);
86
+ this.brightness = Math.round(v * 100);
87
+ this.alpha = Math.round(a * 100);
88
+ }
89
+
90
+ _HSBToColorString(h, s, b, a = 1) {
91
+ s /= 100;
92
+ b /= 100;
93
+ a /= 100;
94
+
95
+ const k = n => (n + h / 60) % 6;
96
+ const f = n => b * (1 - s * Math.max(0, Math.min(k(n), 4 - k(n), 1)));
97
+
98
+ const r = Math.round(f(5) * 255);
99
+ const g = Math.round(f(3) * 255);
100
+ const bVal = Math.round(f(1) * 255);
101
+
102
+ if (this.mode === 'rgb') {
103
+ if (a < 1) {
104
+ return `rgba(${r}, ${g}, ${bVal}, ${a.toFixed(2)})`;
105
+ }
106
+ return `rgb(${r}, ${g}, ${bVal})`;
107
+ }
108
+
109
+ if (this.mode === 'hsl') {
110
+ if (a < 1) {
111
+ return `hsla(${h}, ${Math.round(s * 100)}%, ${Math.round(b * 100)}%, ${a.toFixed(2)})`;
112
+ }
113
+ return `hsl(${h}, ${Math.round(s * 100)}%, ${Math.round(b * 100)}%)`;
114
+ }
115
+
116
+ const hex = `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${bVal.toString(16).padStart(2, '0')}`;
117
+ if (a < 1) {
118
+ return hex + Math.round(a * 255).toString(16).padStart(2, '0');
119
+ }
120
+ return hex;
121
+ }
122
+
123
+ _renderPreviousColors() {
124
+ const container = this.panel.querySelector('.ds-color-picker__previous');
125
+ if (!container) return;
126
+
127
+ container.innerHTML = '';
128
+ this.previousColors.forEach(color => {
129
+ const btn = document.createElement('button');
130
+ btn.className = 'ds-color-picker__color';
131
+ btn.style.backgroundColor = color;
132
+ btn.setAttribute('data-color', color);
133
+ btn.addEventListener('click', this._colorClickHandler);
134
+ container.appendChild(btn);
135
+ });
136
+ }
137
+
138
+ _renderColorPanel() {
139
+ const hueSlider = this.panel.querySelector('.ds-color-picker__hue');
140
+ const svArea = this.panel.querySelector('.ds-color-picker__sv');
141
+ const alphaSlider = this.panel.querySelector('.ds-color-picker__alpha');
142
+
143
+ if (hueSlider) {
144
+ hueSlider.value = this.hue;
145
+ hueSlider.style.background = `linear-gradient(to right, hsl(0,100%,50%), hsl(60,100%,50%), hsl(120,100%,50%), hsl(180,100%,50%), hsl(240,100%,50%), hsl(300,100%,50%), hsl(360,100%,50%))`;
146
+ }
147
+
148
+ if (svArea) {
149
+ svArea.style.background = `hsl(${this.hue}, 100%, 50%)`;
150
+ }
151
+
152
+ if (alphaSlider && this.showAlpha) {
153
+ alphaSlider.value = this.alpha;
154
+ alphaSlider.style.background = `linear-gradient(to right, transparent, ${this._HSBToColorString(this.hue, this.saturation, this.brightness, 1)})`;
155
+ }
156
+ }
157
+
158
+ init() {
159
+ if (!this.trigger || !this.panel) return;
160
+ if (this.element.__kupolaInitialized) return;
161
+
162
+ this._triggerClickHandler = (e) => {
163
+ e.stopPropagation();
164
+ this.togglePanel();
165
+ };
166
+
167
+ this._colorClickHandler = (e) => {
168
+ const colorBtn = e.currentTarget;
169
+ const color = colorBtn.getAttribute('data-color');
170
+ this.updateColor(color);
171
+ this.hidePanel();
172
+ };
173
+
174
+ this._inputInputHandler = (e) => {
175
+ const color = e.target.value;
176
+ if (this._isValidColor(color)) {
177
+ this.updateColor(color);
178
+ }
179
+ };
180
+
181
+ this._alphaChangeHandler = (e) => {
182
+ this.alpha = parseInt(e.target.value);
183
+ this._updateFromHSB();
184
+ };
185
+
186
+ this._modeChangeHandler = (e) => {
187
+ const btn = e.currentTarget;
188
+ this.mode = btn.getAttribute('data-mode');
189
+ this.panel.querySelectorAll('.ds-color-picker__mode-btn').forEach(b => b.classList.remove('is-active'));
190
+ btn.classList.add('is-active');
191
+ this._updateDisplay();
192
+ };
193
+
194
+ this._hueChangeHandler = (e) => {
195
+ this.hue = parseInt(e.target.value);
196
+ this._renderColorPanel();
197
+ this._updateFromHSB();
198
+ };
199
+
200
+ this._saturationChangeHandler = (e) => {
201
+ const rect = e.currentTarget.getBoundingClientRect();
202
+ const x = e.clientX - rect.left;
203
+ const y = e.clientY - rect.top;
204
+ this.saturation = Math.round((x / rect.width) * 100);
205
+ this.brightness = Math.round((1 - y / rect.height) * 100);
206
+ this._updateFromHSB();
207
+ };
208
+
209
+ this._documentClickHandler = (e) => {
210
+ if (!this.element.contains(e.target)) {
211
+ this.hidePanel();
212
+ }
213
+ };
214
+
215
+ this.trigger.addEventListener('click', this._triggerClickHandler);
216
+
217
+ this.panel.querySelectorAll('.ds-color-picker__color').forEach(colorBtn => {
218
+ colorBtn.addEventListener('click', this._colorClickHandler);
219
+ colorBtn._colorPickerColorHandler = this._colorClickHandler;
220
+ });
49
221
 
50
- if (this.customInput) {
51
- this.customInput.addEventListener('input', this._inputInputHandler);
52
- this.customInput._colorPickerInputHandler = this._inputInputHandler;
222
+ if (this.customInput) {
223
+ this.customInput.addEventListener('input', this._inputInputHandler);
224
+ this.customInput._colorPickerInputHandler = this._inputInputHandler;
225
+ }
226
+
227
+ const hueSlider = this.panel.querySelector('.ds-color-picker__hue');
228
+ if (hueSlider) {
229
+ hueSlider.addEventListener('input', this._hueChangeHandler);
230
+ }
231
+
232
+ const svArea = this.panel.querySelector('.ds-color-picker__sv');
233
+ if (svArea) {
234
+ svArea.addEventListener('click', this._saturationChangeHandler);
235
+ svArea.addEventListener('mousemove', (e) => {
236
+ if (e.buttons === 1) {
237
+ this._saturationChangeHandler(e);
238
+ }
239
+ });
240
+ }
241
+
242
+ const alphaSlider = this.panel.querySelector('.ds-color-picker__alpha');
243
+ if (alphaSlider && this.showAlpha) {
244
+ alphaSlider.addEventListener('input', this._alphaChangeHandler);
245
+ }
246
+
247
+ this.panel.querySelectorAll('.ds-color-picker__mode-btn').forEach(btn => {
248
+ btn.addEventListener('click', this._modeChangeHandler);
249
+ if (btn.getAttribute('data-mode') === this.mode) {
250
+ btn.classList.add('is-active');
251
+ }
252
+ });
253
+
254
+ if (window.globalEvents) {
255
+ this._documentClickListener = window.globalEvents.on(document, 'click', this._documentClickHandler, { scope: this.scope });
256
+ } else {
257
+ document.addEventListener('click', this._documentClickHandler);
258
+ }
259
+
260
+ this._renderPreviousColors();
261
+ this._renderColorPanel();
262
+ this._updateDisplay();
263
+
264
+ this.element.__kupolaInitialized = true;
53
265
  }
54
266
 
55
- if (window.globalEvents) {
56
- this._documentClickListener = window.globalEvents.on(document, 'click', this._documentClickHandler, { scope: this.scope });
57
- } else {
58
- document.addEventListener('click', this._documentClickHandler);
267
+ _isValidColor(color) {
268
+ const s = new Option().style;
269
+ s.color = color;
270
+ return s.color !== '';
59
271
  }
60
272
 
61
- this.element.__kupolaInitialized = true;
62
- }
273
+ _updateFromHSB() {
274
+ const color = this._HSBToColorString(this.hue, this.saturation, this.brightness, this.alpha);
275
+ this.value = color;
276
+ this._updateDisplay();
277
+ this._addPreviousColor(color);
278
+ this.element.dispatchEvent(new CustomEvent('kupola:color-picker-change', {
279
+ detail: {
280
+ color: this.value,
281
+ hsb: { h: this.hue, s: this.saturation, b: this.brightness, a: this.alpha },
282
+ mode: this.mode
283
+ }
284
+ }));
285
+ }
63
286
 
64
- togglePanel() {
65
- this.panel.classList.toggle('is-visible');
66
- }
287
+ _updateDisplay() {
288
+ this.trigger.style.backgroundColor = this.value;
289
+ if (this.valueSpan) {
290
+ this.valueSpan.textContent = this.value.toUpperCase();
291
+ }
292
+ if (this.customInput) {
293
+ this.customInput.value = this.value;
294
+ }
295
+ this._renderColorPanel();
296
+ }
67
297
 
68
- hidePanel() {
69
- this.panel.classList.remove('is-visible');
70
- }
298
+ togglePanel() {
299
+ this.panel.classList.toggle('is-visible');
300
+ }
71
301
 
72
- updateColor(color) {
73
- this.trigger.style.backgroundColor = color;
74
- if (this.valueSpan) {
75
- this.valueSpan.textContent = color.toUpperCase();
302
+ hidePanel() {
303
+ this.panel.classList.remove('is-visible');
76
304
  }
77
- if (this.customInput) {
78
- this.customInput.value = color;
305
+
306
+ showPanel() {
307
+ this.panel.classList.add('is-visible');
79
308
  }
80
- this.element.dispatchEvent(new CustomEvent('colorchange', { detail: { color } }));
81
- }
82
309
 
83
- destroy() {
84
- if (!this.element.__kupolaInitialized) return;
310
+ updateColor(color) {
311
+ if (!this._isValidColor(color)) return;
312
+
313
+ this.value = color;
314
+ this._colorStringToHSB(color);
315
+ this._updateDisplay();
316
+ this._addPreviousColor(color);
317
+
318
+ this.element.dispatchEvent(new CustomEvent('kupola:color-picker-change', {
319
+ detail: {
320
+ color: this.value,
321
+ hsb: { h: this.hue, s: this.saturation, b: this.brightness, a: this.alpha },
322
+ mode: this.mode
323
+ }
324
+ }));
325
+ }
326
+
327
+ setValue(color) {
328
+ this.updateColor(color);
329
+ }
85
330
 
86
- if (this.trigger && this._triggerClickHandler) {
87
- this.trigger.removeEventListener('click', this._triggerClickHandler);
331
+ getValue() {
332
+ return this.value;
88
333
  }
89
334
 
90
- if (this.panel) {
91
- this.panel.querySelectorAll('.ds-color-picker__color').forEach(colorBtn => {
92
- if (colorBtn._colorPickerColorHandler) {
93
- colorBtn.removeEventListener('click', colorBtn._colorPickerColorHandler);
335
+ setMode(mode) {
336
+ if (mode === 'hex' || mode === 'rgb' || mode === 'hsl') {
337
+ this.mode = mode;
338
+ this._updateDisplay();
94
339
  }
95
- });
96
340
  }
97
341
 
98
- if (this.customInput && this._inputInputHandler) {
99
- this.customInput.removeEventListener('input', this._inputInputHandler);
342
+ getMode() {
343
+ return this.mode;
344
+ }
345
+
346
+ setAlpha(alpha) {
347
+ this.alpha = Math.max(0, Math.min(100, alpha));
348
+ this._updateFromHSB();
100
349
  }
101
350
 
102
- if (this._documentClickListener && this._documentClickListener.unsubscribe) {
103
- this._documentClickListener.unsubscribe();
104
- } else if (this._documentClickHandler) {
105
- document.removeEventListener('click', this._documentClickHandler);
351
+ getAlpha() {
352
+ return this.alpha;
106
353
  }
107
354
 
108
- this._documentClickHandler = null;
109
- this._documentClickListener = null;
110
- this._triggerClickHandler = null;
111
- this._colorClickHandler = null;
112
- this._inputInputHandler = null;
113
- this.element.__kupolaInitialized = false;
114
- }
355
+ destroy() {
356
+ if (!this.element.__kupolaInitialized) return;
357
+
358
+ if (this.trigger && this._triggerClickHandler) {
359
+ this.trigger.removeEventListener('click', this._triggerClickHandler);
360
+ }
361
+
362
+ if (this.panel) {
363
+ this.panel.querySelectorAll('.ds-color-picker__color').forEach(colorBtn => {
364
+ if (colorBtn._colorPickerColorHandler) {
365
+ colorBtn.removeEventListener('click', colorBtn._colorPickerColorHandler);
366
+ }
367
+ });
368
+ }
369
+
370
+ if (this.customInput && this._inputInputHandler) {
371
+ this.customInput.removeEventListener('input', this._inputInputHandler);
372
+ }
373
+
374
+ const hueSlider = this.panel?.querySelector('.ds-color-picker__hue');
375
+ if (hueSlider && this._hueChangeHandler) {
376
+ hueSlider.removeEventListener('input', this._hueChangeHandler);
377
+ }
378
+
379
+ const svArea = this.panel?.querySelector('.ds-color-picker__sv');
380
+ if (svArea && this._saturationChangeHandler) {
381
+ svArea.removeEventListener('click', this._saturationChangeHandler);
382
+ svArea.removeEventListener('mousemove', this._saturationChangeHandler);
383
+ }
384
+
385
+ const alphaSlider = this.panel?.querySelector('.ds-color-picker__alpha');
386
+ if (alphaSlider && this._alphaChangeHandler) {
387
+ alphaSlider.removeEventListener('input', this._alphaChangeHandler);
388
+ }
389
+
390
+ this.panel?.querySelectorAll('.ds-color-picker__mode-btn').forEach(btn => {
391
+ btn.removeEventListener('click', this._modeChangeHandler);
392
+ });
393
+
394
+ if (this._documentClickListener && this._documentClickListener.unsubscribe) {
395
+ this._documentClickListener.unsubscribe();
396
+ } else if (this._documentClickHandler) {
397
+ document.removeEventListener('click', this._documentClickHandler);
398
+ }
399
+
400
+ this._documentClickHandler = null;
401
+ this._documentClickListener = null;
402
+ this._triggerClickHandler = null;
403
+ this._colorClickHandler = null;
404
+ this._inputInputHandler = null;
405
+ this._alphaChangeHandler = null;
406
+ this._modeChangeHandler = null;
407
+ this._hueChangeHandler = null;
408
+ this._saturationChangeHandler = null;
409
+ this._valueChangeHandler = null;
410
+
411
+ this.element.__kupolaInitialized = false;
412
+ }
115
413
  }
116
414
 
117
- function initColorPicker(element) {
118
- const picker = new ColorPicker(element);
119
- picker.init();
120
- element._kupolaColorPicker = picker;
415
+ function initColorPicker(element, options) {
416
+ const picker = new ColorPicker(element, options);
417
+ picker.init();
418
+ element._kupolaColorPicker = picker;
121
419
  }
122
420
 
123
421
  function initColorPickers(root = document) {
124
- root.querySelectorAll('.ds-color-picker').forEach(picker => {
125
- initColorPicker(picker);
126
- });
422
+ root.querySelectorAll('.ds-color-picker').forEach(picker => {
423
+ initColorPicker(picker);
424
+ });
127
425
  }
128
426
 
129
427
  function cleanupColorPicker(picker) {
130
- if (picker._kupolaColorPicker) {
131
- picker._kupolaColorPicker.destroy();
132
- picker._kupolaColorPicker = null;
133
- }
428
+ if (picker._kupolaColorPicker) {
429
+ picker._kupolaColorPicker.destroy();
430
+ picker._kupolaColorPicker = null;
431
+ }
134
432
  }
135
433
 
136
434
  function cleanupAllColorPickers() {
137
- document.querySelectorAll('.ds-color-picker').forEach(picker => {
138
- cleanupColorPicker(picker);
139
- });
435
+ document.querySelectorAll('.ds-color-picker').forEach(picker => {
436
+ cleanupColorPicker(picker);
437
+ });
140
438
  }
141
439
 
142
- if (window.kupolaInitializer) {
143
- window.kupolaInitializer.register('color-picker', initColorPicker, cleanupColorPicker);
440
+ export { ColorPicker, initColorPicker, initColorPickers, cleanupColorPicker, cleanupAllColorPickers };
441
+
442
+ if (typeof window !== 'undefined') {
443
+ window.ColorPicker = ColorPicker;
444
+ window.initColorPicker = initColorPicker;
445
+ window.initColorPickers = initColorPickers;
446
+ window.cleanupColorPicker = cleanupColorPicker;
447
+ window.cleanupAllColorPickers = cleanupAllColorPickers;
448
+
449
+ if (window.kupolaInitializer) {
450
+ window.kupolaInitializer.register('color-picker', initColorPicker, cleanupColorPicker);
451
+ }
144
452
  }
package/js/component.js CHANGED
@@ -1,4 +1,6 @@
1
- class KupolaComponent {
1
+ import { KupolaLifecycle } from './kupola-lifecycle.js';
2
+
3
+ export class KupolaComponent {
2
4
  constructor(element) {
3
5
  this.element = element;
4
6
  this.isMounted = false;
@@ -8,18 +10,7 @@ class KupolaComponent {
8
10
  this.slots = this._parseSlots();
9
11
  this._eventListeners = {};
10
12
  this._appliedMixins = [];
11
- this.lifecycle = window.KupolaLifecycle
12
- ? new window.KupolaLifecycle()
13
- : {
14
- on: () => () => {},
15
- emit: () => {},
16
- bootstrap: () => {},
17
- mount: () => {},
18
- update: () => {},
19
- unmount: () => {},
20
- destroy: () => {},
21
- state: 'created'
22
- };
13
+ this.lifecycle = new KupolaLifecycle();
23
14
  this.setupContext = null;
24
15
  }
25
16
 
@@ -129,7 +120,7 @@ class KupolaComponent {
129
120
 
130
121
  await this.lifecycle.bootstrap();
131
122
 
132
- if (window._setCurrentSetupContext && window.SetupContext) {
123
+ if (typeof window !== 'undefined' && window._setCurrentSetupContext && window.SetupContext) {
133
124
  this.setupContext = new window.SetupContext(this);
134
125
  window._setCurrentSetupContext(this.setupContext);
135
126
 
@@ -146,7 +137,7 @@ class KupolaComponent {
146
137
 
147
138
  this.setupContext?._executeMounted();
148
139
 
149
- if (window._clearSetupContext) {
140
+ if (typeof window !== 'undefined' && window._clearSetupContext) {
150
141
  window._clearSetupContext();
151
142
  }
152
143
  } catch (error) {
@@ -249,7 +240,7 @@ class KupolaComponent {
249
240
  setup() {}
250
241
  }
251
242
 
252
- function applyMixin(componentClass, mixin) {
243
+ export function applyMixin(componentClass, mixin) {
253
244
  Object.keys(mixin).forEach(key => {
254
245
  if (key === 'constructor') return;
255
246
  if (typeof mixin[key] === 'function') {
@@ -268,9 +259,7 @@ function applyMixin(componentClass, mixin) {
268
259
  });
269
260
  }
270
261
 
271
- if (typeof module !== 'undefined' && module.exports) {
272
- module.exports = { KupolaComponent, applyMixin };
273
- } else {
262
+ if (typeof window !== 'undefined') {
274
263
  window.KupolaComponent = KupolaComponent;
275
264
  window.applyMixin = applyMixin;
276
265
  }
package/js/countdown.js CHANGED
@@ -92,7 +92,7 @@ class Countdown {
92
92
  }
93
93
 
94
94
  dispatchComplete() {
95
- this.element.dispatchEvent(new CustomEvent('ds-countdown-complete', {
95
+ this.element.dispatchEvent(new CustomEvent('kupola:countdown-complete', {
96
96
  detail: {}
97
97
  }));
98
98
  }
@@ -131,14 +131,15 @@ function initCountdowns() {
131
131
  });
132
132
  }
133
133
 
134
- if (typeof module !== 'undefined' && module.exports) {
135
- module.exports = { Countdown, initCountdowns, initCountdown, cleanupCountdown };
136
- } else {
134
+ export { Countdown, initCountdowns, initCountdown, cleanupCountdown };
135
+
136
+ if (typeof window !== 'undefined') {
137
137
  window.Countdown = Countdown;
138
138
  window.initCountdown = initCountdown;
139
139
  window.cleanupCountdown = cleanupCountdown;
140
- }
141
-
142
- if (window.kupolaInitializer) {
143
- window.kupolaInitializer.register('countdown', initCountdown, cleanupCountdown);
140
+ window.initCountdowns = initCountdowns;
141
+
142
+ if (window.kupolaInitializer) {
143
+ window.kupolaInitializer.register('countdown', initCountdown, cleanupCountdown);
144
+ }
144
145
  }