@kupola/kupola 1.2.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 +130 -0
- package/INTEGRATION.md +440 -0
- package/PROJECT_SUMMARY.md +312 -0
- package/README.md +286 -0
- package/SKILL.md +572 -0
- package/css/accessibility.css +119 -0
- package/css/animations.css +224 -0
- package/css/brand-themes.css +300 -0
- package/css/colors_and_type.css +441 -0
- package/css/components-ext.css +4165 -0
- package/css/components.css +1483 -0
- package/css/kupola.css +12 -0
- package/css/responsive.css +697 -0
- package/css/scaffold.css +145 -0
- package/css/states.css +316 -0
- package/css/theme-dark.css +296 -0
- package/css/theme-light.css +296 -0
- package/css/utilities.css +171 -0
- package/dist/css/kupola.css +12 -0
- package/dist/icons/icons/activity.svg +3 -0
- package/dist/icons/icons/alert-circle.svg +1 -0
- package/dist/icons/icons/alert-triangle.svg +1 -0
- package/dist/icons/icons/alert.d27e24.svg +1 -0
- package/dist/icons/icons/alert.svg +1 -0
- package/dist/icons/icons/apple.svg +1 -0
- package/dist/icons/icons/arrow-down.svg +1 -0
- package/dist/icons/icons/arrow-expand.svg +1 -0
- package/dist/icons/icons/arrow-left.svg +1 -0
- package/dist/icons/icons/arrow-minimize.svg +1 -0
- package/dist/icons/icons/arrow-right-to-line.svg +1 -0
- package/dist/icons/icons/arrow-right.svg +1 -0
- package/dist/icons/icons/arrow-up-right.svg +1 -0
- package/dist/icons/icons/arrow-up.0c0c0d.svg +1 -0
- package/dist/icons/icons/arrow-up.svg +1 -0
- package/dist/icons/icons/at.svg +1 -0
- package/dist/icons/icons/atom.0c0c0d.svg +1 -0
- package/dist/icons/icons/atom.svg +1 -0
- package/dist/icons/icons/bar-chart-2.svg +1 -0
- package/dist/icons/icons/bar.svg +1 -0
- package/dist/icons/icons/bell.svg +1 -0
- package/dist/icons/icons/box.svg +1 -0
- package/dist/icons/icons/bug.svg +1 -0
- package/dist/icons/icons/button.svg +1 -0
- package/dist/icons/icons/calendar.svg +1 -0
- package/dist/icons/icons/check-circle.33c192.svg +1 -0
- package/dist/icons/icons/check-circle.svg +1 -0
- package/dist/icons/icons/check-square.svg +4 -0
- package/dist/icons/icons/check.d1d3db.svg +1 -0
- package/dist/icons/icons/check.svg +1 -0
- package/dist/icons/icons/chevron-down.svg +1 -0
- package/dist/icons/icons/chevron-left.svg +1 -0
- package/dist/icons/icons/chevron-right.svg +1 -0
- package/dist/icons/icons/chevron-up.svg +1 -0
- package/dist/icons/icons/circle.svg +1 -0
- package/dist/icons/icons/clock.svg +1 -0
- package/dist/icons/icons/cmd.svg +1 -0
- package/dist/icons/icons/code.svg +1 -0
- package/dist/icons/icons/columns.svg +1 -0
- package/dist/icons/icons/copy.svg +1 -0
- package/dist/icons/icons/cpu.svg +1 -0
- package/dist/icons/icons/dashboard.0c0c0d.svg +1 -0
- package/dist/icons/icons/dashboard.svg +1 -0
- package/dist/icons/icons/dollar.svg +1 -0
- package/dist/icons/icons/download.svg +1 -0
- package/dist/icons/icons/edit.svg +1 -0
- package/dist/icons/icons/extensions.svg +1 -0
- package/dist/icons/icons/external.svg +1 -0
- package/dist/icons/icons/eye.svg +1 -0
- package/dist/icons/icons/file-text.svg +1 -0
- package/dist/icons/icons/file.svg +1 -0
- package/dist/icons/icons/files.svg +1 -0
- package/dist/icons/icons/filter.svg +1 -0
- package/dist/icons/icons/folder-open.svg +4 -0
- package/dist/icons/icons/folder.svg +1 -0
- package/dist/icons/icons/gear.svg +1 -0
- package/dist/icons/icons/git.svg +1 -0
- package/dist/icons/icons/github.svg +1 -0
- package/dist/icons/icons/globe.svg +1 -0
- package/dist/icons/icons/grid-2x2.svg +1 -0
- package/dist/icons/icons/hash.svg +1 -0
- package/dist/icons/icons/heart.svg +1 -0
- package/dist/icons/icons/help-circle.svg +5 -0
- package/dist/icons/icons/help.svg +1 -0
- package/dist/icons/icons/home.svg +1 -0
- package/dist/icons/icons/icons.svg +153 -0
- package/dist/icons/icons/image.svg +1 -0
- package/dist/icons/icons/info-circle.svg +1 -0
- package/dist/icons/icons/info-square.svg +1 -0
- package/dist/icons/icons/info.387bff.svg +1 -0
- package/dist/icons/icons/info.svg +1 -0
- package/dist/icons/icons/input.svg +1 -0
- package/dist/icons/icons/key.svg +1 -0
- package/dist/icons/icons/layers.svg +1 -0
- package/dist/icons/icons/layout-grid.svg +6 -0
- package/dist/icons/icons/layout.svg +1 -0
- package/dist/icons/icons/link.svg +1 -0
- package/dist/icons/icons/list.svg +1 -0
- package/dist/icons/icons/lock.svg +1 -0
- package/dist/icons/icons/log-out.svg +1 -0
- package/dist/icons/icons/logo.svg +1 -0
- package/dist/icons/icons/mail.svg +1 -0
- package/dist/icons/icons/menu.svg +1 -0
- package/dist/icons/icons/message-circle.svg +1 -0
- package/dist/icons/icons/message-plus.svg +1 -0
- package/dist/icons/icons/message-square.svg +1 -0
- package/dist/icons/icons/mic.svg +1 -0
- package/dist/icons/icons/minus.svg +1 -0
- package/dist/icons/icons/moon.svg +1 -0
- package/dist/icons/icons/more-h.svg +1 -0
- package/dist/icons/icons/mouse.svg +1 -0
- package/dist/icons/icons/palette.svg +1 -0
- package/dist/icons/icons/panel-bottom.svg +1 -0
- package/dist/icons/icons/pause.svg +1 -0
- package/dist/icons/icons/play.svg +1 -0
- package/dist/icons/icons/plug.svg +1 -0
- package/dist/icons/icons/plus.0c0c0d.svg +1 -0
- package/dist/icons/icons/plus.svg +1 -0
- package/dist/icons/icons/refresh.svg +1 -0
- package/dist/icons/icons/ruler.svg +1 -0
- package/dist/icons/icons/scroll-text.svg +1 -0
- package/dist/icons/icons/search-menu.svg +1 -0
- package/dist/icons/icons/search.svg +1 -0
- package/dist/icons/icons/send.0c0c0d.svg +1 -0
- package/dist/icons/icons/send.svg +1 -0
- package/dist/icons/icons/settings.0c0c0d.svg +1 -0
- package/dist/icons/icons/settings.svg +1 -0
- package/dist/icons/icons/shield.svg +1 -0
- package/dist/icons/icons/sidebar-left.svg +1 -0
- package/dist/icons/icons/sidebar-right.svg +1 -0
- package/dist/icons/icons/sliders.svg +1 -0
- package/dist/icons/icons/sparkles.32f08c.svg +1 -0
- package/dist/icons/icons/sparkles.svg +1 -0
- package/dist/icons/icons/square.svg +1 -0
- package/dist/icons/icons/star.svg +1 -0
- package/dist/icons/icons/sun.svg +1 -0
- package/dist/icons/icons/table.svg +1 -0
- package/dist/icons/icons/terminal.svg +1 -0
- package/dist/icons/icons/trash.svg +1 -0
- package/dist/icons/icons/trending-down.svg +1 -0
- package/dist/icons/icons/trending-up.svg +1 -0
- package/dist/icons/icons/type.svg +1 -0
- package/dist/icons/icons/upload.svg +1 -0
- package/dist/icons/icons/user-circle.svg +1 -0
- package/dist/icons/icons/user-plus.svg +6 -0
- package/dist/icons/icons/user.svg +1 -0
- package/dist/icons/icons/users.svg +1 -0
- package/dist/icons/icons/warning.svg +1 -0
- package/dist/icons/icons/wrench.svg +1 -0
- package/dist/icons/icons/x-circle.svg +1 -0
- package/dist/icons/icons/x.svg +1 -0
- package/dist/icons/icons/zap.0c0c0d.svg +1 -0
- package/dist/icons/icons/zap.svg +1 -0
- package/dist/kupola.cjs.js +258 -0
- package/dist/kupola.cjs.js.map +1 -0
- package/dist/kupola.esm.js +7640 -0
- package/dist/kupola.esm.js.map +1 -0
- package/dist/kupola.umd.js +258 -0
- package/dist/kupola.umd.js.map +1 -0
- package/dist/types/kupola.d.ts +1359 -0
- package/dist/utils/utils/Kupola.cs +77 -0
- package/dist/utils/utils/Kupola.java +104 -0
- package/dist/utils/utils/kupola.go +120 -0
- package/dist/utils/utils/kupola.js +63 -0
- package/dist/utils/utils/kupola.py +1392 -0
- package/dist/utils/utils/kupola.rb +69 -0
- package/icons/activity.svg +3 -0
- package/icons/alert-circle.svg +1 -0
- package/icons/alert-triangle.svg +1 -0
- package/icons/alert.d27e24.svg +1 -0
- package/icons/alert.svg +1 -0
- package/icons/apple.svg +1 -0
- package/icons/arrow-down.svg +1 -0
- package/icons/arrow-expand.svg +1 -0
- package/icons/arrow-left.svg +1 -0
- package/icons/arrow-minimize.svg +1 -0
- package/icons/arrow-right-to-line.svg +1 -0
- package/icons/arrow-right.svg +1 -0
- package/icons/arrow-up-right.svg +1 -0
- package/icons/arrow-up.0c0c0d.svg +1 -0
- package/icons/arrow-up.svg +1 -0
- package/icons/at.svg +1 -0
- package/icons/atom.0c0c0d.svg +1 -0
- package/icons/atom.svg +1 -0
- package/icons/bar-chart-2.svg +1 -0
- package/icons/bar.svg +1 -0
- package/icons/bell.svg +1 -0
- package/icons/box.svg +1 -0
- package/icons/bug.svg +1 -0
- package/icons/button.svg +1 -0
- package/icons/calendar.svg +1 -0
- package/icons/check-circle.33c192.svg +1 -0
- package/icons/check-circle.svg +1 -0
- package/icons/check-square.svg +4 -0
- package/icons/check.d1d3db.svg +1 -0
- package/icons/check.svg +1 -0
- package/icons/chevron-down.svg +1 -0
- package/icons/chevron-left.svg +1 -0
- package/icons/chevron-right.svg +1 -0
- package/icons/chevron-up.svg +1 -0
- package/icons/circle.svg +1 -0
- package/icons/clock.svg +1 -0
- package/icons/cmd.svg +1 -0
- package/icons/code.svg +1 -0
- package/icons/columns.svg +1 -0
- package/icons/copy.svg +1 -0
- package/icons/cpu.svg +1 -0
- package/icons/dashboard.0c0c0d.svg +1 -0
- package/icons/dashboard.svg +1 -0
- package/icons/dollar.svg +1 -0
- package/icons/download.svg +1 -0
- package/icons/edit.svg +1 -0
- package/icons/extensions.svg +1 -0
- package/icons/external.svg +1 -0
- package/icons/eye.svg +1 -0
- package/icons/file-text.svg +1 -0
- package/icons/file.svg +1 -0
- package/icons/files.svg +1 -0
- package/icons/filter.svg +1 -0
- package/icons/folder-open.svg +4 -0
- package/icons/folder.svg +1 -0
- package/icons/gear.svg +1 -0
- package/icons/git.svg +1 -0
- package/icons/github.svg +1 -0
- package/icons/globe.svg +1 -0
- package/icons/grid-2x2.svg +1 -0
- package/icons/hash.svg +1 -0
- package/icons/heart.svg +1 -0
- package/icons/help-circle.svg +5 -0
- package/icons/help.svg +1 -0
- package/icons/home.svg +1 -0
- package/icons/icons.svg +153 -0
- package/icons/image.svg +1 -0
- package/icons/info-circle.svg +1 -0
- package/icons/info-square.svg +1 -0
- package/icons/info.387bff.svg +1 -0
- package/icons/info.svg +1 -0
- package/icons/input.svg +1 -0
- package/icons/key.svg +1 -0
- package/icons/layers.svg +1 -0
- package/icons/layout-grid.svg +6 -0
- package/icons/layout.svg +1 -0
- package/icons/link.svg +1 -0
- package/icons/list.svg +1 -0
- package/icons/lock.svg +1 -0
- package/icons/log-out.svg +1 -0
- package/icons/logo.svg +1 -0
- package/icons/mail.svg +1 -0
- package/icons/menu.svg +1 -0
- package/icons/message-circle.svg +1 -0
- package/icons/message-plus.svg +1 -0
- package/icons/message-square.svg +1 -0
- package/icons/mic.svg +1 -0
- package/icons/minus.svg +1 -0
- package/icons/moon.svg +1 -0
- package/icons/more-h.svg +1 -0
- package/icons/mouse.svg +1 -0
- package/icons/palette.svg +1 -0
- package/icons/panel-bottom.svg +1 -0
- package/icons/pause.svg +1 -0
- package/icons/play.svg +1 -0
- package/icons/plug.svg +1 -0
- package/icons/plus.0c0c0d.svg +1 -0
- package/icons/plus.svg +1 -0
- package/icons/refresh.svg +1 -0
- package/icons/ruler.svg +1 -0
- package/icons/scroll-text.svg +1 -0
- package/icons/search-menu.svg +1 -0
- package/icons/search.svg +1 -0
- package/icons/send.0c0c0d.svg +1 -0
- package/icons/send.svg +1 -0
- package/icons/settings.0c0c0d.svg +1 -0
- package/icons/settings.svg +1 -0
- package/icons/shield.svg +1 -0
- package/icons/sidebar-left.svg +1 -0
- package/icons/sidebar-right.svg +1 -0
- package/icons/sliders.svg +1 -0
- package/icons/sparkles.32f08c.svg +1 -0
- package/icons/sparkles.svg +1 -0
- package/icons/square.svg +1 -0
- package/icons/star.svg +1 -0
- package/icons/sun.svg +1 -0
- package/icons/table.svg +1 -0
- package/icons/terminal.svg +1 -0
- package/icons/trash.svg +1 -0
- package/icons/trending-down.svg +1 -0
- package/icons/trending-up.svg +1 -0
- package/icons/type.svg +1 -0
- package/icons/upload.svg +1 -0
- package/icons/user-circle.svg +1 -0
- package/icons/user-plus.svg +6 -0
- package/icons/user.svg +1 -0
- package/icons/users.svg +1 -0
- package/icons/warning.svg +1 -0
- package/icons/wrench.svg +1 -0
- package/icons/x-circle.svg +1 -0
- package/icons/x.svg +1 -0
- package/icons/zap.0c0c0d.svg +1 -0
- package/icons/zap.svg +1 -0
- package/js/calendar.js +184 -0
- package/js/carousel.js +173 -0
- package/js/collapse.js +127 -0
- package/js/color-picker.js +144 -0
- package/js/component.js +276 -0
- package/js/composition-api.js +458 -0
- package/js/countdown.js +144 -0
- package/js/data-bind.js +1286 -0
- package/js/datepicker.js +270 -0
- package/js/dialog.js +131 -0
- package/js/drawer.js +118 -0
- package/js/dropdown.js +122 -0
- package/js/dynamic-tags.js +156 -0
- package/js/error-handler.js +181 -0
- package/js/fileupload.js +392 -0
- package/js/form.js +291 -0
- package/js/global-events.js +203 -0
- package/js/heatmap.js +405 -0
- package/js/http.js +419 -0
- package/js/i18n.js +228 -0
- package/js/icons.js +165 -0
- package/js/image-preview.js +218 -0
- package/js/initializer.js +162 -0
- package/js/kupola-core.js +66 -0
- package/js/kupola-devtools.js +598 -0
- package/js/kupola-lifecycle.js +510 -0
- package/js/message.js +60 -0
- package/js/modal.js +191 -0
- package/js/notification.js +73 -0
- package/js/numberinput.js +146 -0
- package/js/performance.js +250 -0
- package/js/registry.js +205 -0
- package/js/router.js +396 -0
- package/js/security.js +189 -0
- package/js/select.js +143 -0
- package/js/slide-captcha.js +504 -0
- package/js/slider.js +94 -0
- package/js/statcard.js +219 -0
- package/js/tag.js +83 -0
- package/js/test-utils.js +251 -0
- package/js/theme.js +363 -0
- package/js/timepicker.js +238 -0
- package/js/tooltip.js +122 -0
- package/js/utils.js +1458 -0
- package/js/validation.js +553 -0
- package/js/virtual-list.js +593 -0
- package/package.json +105 -0
- package/templates/base.html +30 -0
- package/templates/base_dashboard.html +99 -0
- package/types/kupola.d.ts +1359 -0
- package/utils/Kupola.cs +77 -0
- package/utils/Kupola.java +104 -0
- package/utils/kupola.go +120 -0
- package/utils/kupola.js +63 -0
- package/utils/kupola.py +1392 -0
- package/utils/kupola.rb +69 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
class DynamicTags {
|
|
2
|
+
constructor(element) {
|
|
3
|
+
this.element = element;
|
|
4
|
+
this.input = element.querySelector('.ds-dynamic-tags__input');
|
|
5
|
+
this._listeners = [];
|
|
6
|
+
this.init();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
init() {
|
|
10
|
+
this.bindEvents();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
bindEvents() {
|
|
14
|
+
this.element.querySelectorAll('.ds-dynamic-tags__remove').forEach(removeBtn => {
|
|
15
|
+
const removeHandler = (e) => {
|
|
16
|
+
e.stopPropagation();
|
|
17
|
+
const tag = removeBtn.closest('.ds-dynamic-tags__tag');
|
|
18
|
+
if (tag) {
|
|
19
|
+
tag.remove();
|
|
20
|
+
this.dispatchChange();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
removeBtn.addEventListener('click', removeHandler);
|
|
24
|
+
this._listeners.push({ el: removeBtn, event: 'click', handler: removeHandler });
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (this.input) {
|
|
28
|
+
const addTag = () => {
|
|
29
|
+
const value = this.input.value.trim();
|
|
30
|
+
if (!value) return;
|
|
31
|
+
|
|
32
|
+
const tag = document.createElement('span');
|
|
33
|
+
tag.className = 'ds-dynamic-tags__tag';
|
|
34
|
+
const textNode = document.createTextNode(value);
|
|
35
|
+
tag.appendChild(textNode);
|
|
36
|
+
const removeBtn = document.createElement('button');
|
|
37
|
+
removeBtn.className = 'ds-dynamic-tags__remove';
|
|
38
|
+
removeBtn.innerHTML = '<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>';
|
|
39
|
+
tag.appendChild(removeBtn);
|
|
40
|
+
|
|
41
|
+
const tagRemoveHandler = (e) => {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
tag.remove();
|
|
44
|
+
this.dispatchChange();
|
|
45
|
+
};
|
|
46
|
+
removeBtn.addEventListener('click', tagRemoveHandler);
|
|
47
|
+
this._listeners.push({ el: removeBtn, event: 'click', handler: tagRemoveHandler });
|
|
48
|
+
|
|
49
|
+
this.element.insertBefore(tag, this.input);
|
|
50
|
+
this.input.value = '';
|
|
51
|
+
this.input.focus();
|
|
52
|
+
this.dispatchChange();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const keydownHandler = (e) => {
|
|
56
|
+
if (e.key === 'Enter') {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
addTag();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
this.input.addEventListener('keydown', keydownHandler);
|
|
63
|
+
this._listeners.push({ el: this.input, event: 'keydown', handler: keydownHandler });
|
|
64
|
+
|
|
65
|
+
const clickHandler = () => {
|
|
66
|
+
this.input.focus();
|
|
67
|
+
};
|
|
68
|
+
this.element.addEventListener('click', clickHandler);
|
|
69
|
+
this._listeners.push({ el: this.element, event: 'click', handler: clickHandler });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
addTag(value) {
|
|
74
|
+
if (!value || !this.input) return;
|
|
75
|
+
this.input.value = value;
|
|
76
|
+
this.input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
removeTag(index) {
|
|
80
|
+
const tags = this.element.querySelectorAll('.ds-dynamic-tags__tag');
|
|
81
|
+
const tag = tags[index];
|
|
82
|
+
if (tag) {
|
|
83
|
+
tag.remove();
|
|
84
|
+
this.dispatchChange();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getTags() {
|
|
89
|
+
const tags = [];
|
|
90
|
+
this.element.querySelectorAll('.ds-dynamic-tags__tag').forEach(tag => {
|
|
91
|
+
tags.push(tag.textContent);
|
|
92
|
+
});
|
|
93
|
+
return tags;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
clearTags() {
|
|
97
|
+
this.element.querySelectorAll('.ds-dynamic-tags__tag').forEach(tag => {
|
|
98
|
+
tag.remove();
|
|
99
|
+
});
|
|
100
|
+
this.dispatchChange();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
dispatchChange() {
|
|
104
|
+
this.element.dispatchEvent(new CustomEvent('ds-dynamic-tags-change', {
|
|
105
|
+
detail: {
|
|
106
|
+
tags: this.getTags(),
|
|
107
|
+
count: this.getTags().length
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
destroy() {
|
|
113
|
+
this._listeners.forEach(({ el, event, handler }) => {
|
|
114
|
+
el.removeEventListener(event, handler);
|
|
115
|
+
});
|
|
116
|
+
this._listeners = null;
|
|
117
|
+
this.input = null;
|
|
118
|
+
this.element = null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function initDynamicTags(element) {
|
|
123
|
+
if (element.__kupolaInitialized) return;
|
|
124
|
+
|
|
125
|
+
const instance = new DynamicTags(element);
|
|
126
|
+
element.__kupolaInstance = instance;
|
|
127
|
+
element.__kupolaInitialized = true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function cleanupDynamicTags(element) {
|
|
131
|
+
if (!element.__kupolaInitialized || !element.__kupolaInstance) return;
|
|
132
|
+
|
|
133
|
+
const instance = element.__kupolaInstance;
|
|
134
|
+
instance.destroy();
|
|
135
|
+
|
|
136
|
+
element.__kupolaInstance = null;
|
|
137
|
+
element.__kupolaInitialized = false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function initDynamicTagsAll() {
|
|
141
|
+
document.querySelectorAll('.ds-dynamic-tags').forEach(tags => {
|
|
142
|
+
initDynamicTags(tags);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
147
|
+
module.exports = { DynamicTags, initDynamicTagsAll, initDynamicTags, cleanupDynamicTags };
|
|
148
|
+
} else {
|
|
149
|
+
window.DynamicTags = DynamicTags;
|
|
150
|
+
window.initDynamicTags = initDynamicTags;
|
|
151
|
+
window.cleanupDynamicTags = cleanupDynamicTags;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (window.kupolaInitializer) {
|
|
155
|
+
window.kupolaInitializer.register('dynamic-tags', initDynamicTags, cleanupDynamicTags);
|
|
156
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
class KupolaErrorHandler {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.handlers = new Map();
|
|
4
|
+
this.errorLog = [];
|
|
5
|
+
this.maxLogs = 100;
|
|
6
|
+
this.globalHandler = null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
init() {
|
|
10
|
+
this._installGlobalHandlers();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_installGlobalHandlers() {
|
|
14
|
+
window.addEventListener('error', (event) => {
|
|
15
|
+
this.handleError(event.error || event.message, {
|
|
16
|
+
source: event.filename,
|
|
17
|
+
line: event.lineno,
|
|
18
|
+
column: event.colno,
|
|
19
|
+
type: 'global'
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
window.addEventListener('unhandledrejection', (event) => {
|
|
24
|
+
this.handleError(event.reason, {
|
|
25
|
+
type: 'promise',
|
|
26
|
+
rejection: true
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setGlobalHandler(handler) {
|
|
32
|
+
if (typeof handler === 'function') {
|
|
33
|
+
this.globalHandler = handler;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
handleError(error, context = {}) {
|
|
38
|
+
const errorInfo = this._normalizeError(error, context);
|
|
39
|
+
|
|
40
|
+
this._logError(errorInfo);
|
|
41
|
+
this._notifyHandlers(errorInfo);
|
|
42
|
+
|
|
43
|
+
if (this.globalHandler) {
|
|
44
|
+
try {
|
|
45
|
+
this.globalHandler(errorInfo);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error('[KupolaErrorHandler] Error in global handler:', e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return errorInfo;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_normalizeError(error, context) {
|
|
55
|
+
const errorInfo = {
|
|
56
|
+
id: this._generateId(),
|
|
57
|
+
timestamp: Date.now(),
|
|
58
|
+
message: '',
|
|
59
|
+
stack: '',
|
|
60
|
+
type: context.type || 'unknown',
|
|
61
|
+
source: context.source || '',
|
|
62
|
+
line: context.line || 0,
|
|
63
|
+
column: context.column || 0,
|
|
64
|
+
component: context.component || '',
|
|
65
|
+
hook: context.hook || '',
|
|
66
|
+
args: context.args || [],
|
|
67
|
+
...context
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (error instanceof Error) {
|
|
71
|
+
errorInfo.message = error.message;
|
|
72
|
+
errorInfo.stack = error.stack || '';
|
|
73
|
+
errorInfo.name = error.name;
|
|
74
|
+
} else if (typeof error === 'string') {
|
|
75
|
+
errorInfo.message = error;
|
|
76
|
+
} else if (error && typeof error === 'object') {
|
|
77
|
+
errorInfo.message = error.message || JSON.stringify(error);
|
|
78
|
+
errorInfo.stack = error.stack || '';
|
|
79
|
+
errorInfo.name = error.name || '';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return errorInfo;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
_generateId() {
|
|
86
|
+
return `err-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_logError(errorInfo) {
|
|
90
|
+
this.errorLog.unshift(errorInfo);
|
|
91
|
+
if (this.errorLog.length > this.maxLogs) {
|
|
92
|
+
this.errorLog.pop();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.error(`[KupolaError] [${errorInfo.type}] ${errorInfo.message}`, errorInfo);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_notifyHandlers(errorInfo) {
|
|
99
|
+
this.handlers.forEach((handler, key) => {
|
|
100
|
+
try {
|
|
101
|
+
handler(errorInfo);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
console.error(`[KupolaErrorHandler] Error in handler "${key}":`, e);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
on(type, handler) {
|
|
109
|
+
if (!this.handlers.has(type)) {
|
|
110
|
+
this.handlers.set(type, []);
|
|
111
|
+
}
|
|
112
|
+
this.handlers.get(type).push(handler);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
off(type, handler) {
|
|
116
|
+
if (!this.handlers.has(type)) return;
|
|
117
|
+
|
|
118
|
+
const handlers = this.handlers.get(type);
|
|
119
|
+
const index = handlers.indexOf(handler);
|
|
120
|
+
if (index > -1) {
|
|
121
|
+
handlers.splice(index, 1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
getErrorLog() {
|
|
126
|
+
return [...this.errorLog];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
clearErrorLog() {
|
|
130
|
+
this.errorLog = [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
getErrorCount() {
|
|
134
|
+
return this.errorLog.length;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
getErrorByType(type) {
|
|
138
|
+
return this.errorLog.filter(err => err.type === type);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
captureErrors(target, methodNames) {
|
|
142
|
+
if (!target || !methodNames || !Array.isArray(methodNames)) return;
|
|
143
|
+
|
|
144
|
+
methodNames.forEach(methodName => {
|
|
145
|
+
if (typeof target[methodName] === 'function') {
|
|
146
|
+
const originalMethod = target[methodName];
|
|
147
|
+
target[methodName] = function(...args) {
|
|
148
|
+
try {
|
|
149
|
+
const result = originalMethod.apply(this, args);
|
|
150
|
+
if (result instanceof Promise) {
|
|
151
|
+
return result.catch(error => {
|
|
152
|
+
kupolaErrorHandler.handleError(error, {
|
|
153
|
+
type: 'method',
|
|
154
|
+
component: target.constructor?.name || '',
|
|
155
|
+
hook: methodName,
|
|
156
|
+
args
|
|
157
|
+
});
|
|
158
|
+
throw error;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
kupolaErrorHandler.handleError(error, {
|
|
164
|
+
type: 'method',
|
|
165
|
+
component: target.constructor?.name || '',
|
|
166
|
+
hook: methodName,
|
|
167
|
+
args
|
|
168
|
+
});
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const kupolaErrorHandler = new KupolaErrorHandler();
|
|
178
|
+
window.kupolaErrorHandler = kupolaErrorHandler;
|
|
179
|
+
window.KupolaErrorHandler = KupolaErrorHandler;
|
|
180
|
+
|
|
181
|
+
export default KupolaErrorHandler;
|