@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,458 @@
|
|
|
1
|
+
(function(window) {
|
|
2
|
+
let currentSetupContext = null;
|
|
3
|
+
|
|
4
|
+
class SetupContext {
|
|
5
|
+
constructor(component) {
|
|
6
|
+
this.component = component;
|
|
7
|
+
this.lifecycle = (component && component.lifecycle) || null;
|
|
8
|
+
this._onMountedHandlers = [];
|
|
9
|
+
this._onUnmountedHandlers = [];
|
|
10
|
+
this._onUpdatedHandlers = [];
|
|
11
|
+
this._watches = [];
|
|
12
|
+
this._refs = new Map();
|
|
13
|
+
this._computedDeps = new Map();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
ref(initialValue = null) {
|
|
17
|
+
if (window.kupolaData) {
|
|
18
|
+
const key = `__ref_${Math.random().toString(36).slice(2, 11)}__`;
|
|
19
|
+
window.kupolaData.set(key, initialValue);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
get value() {
|
|
23
|
+
return window.kupolaData.get(key);
|
|
24
|
+
},
|
|
25
|
+
set value(newValue) {
|
|
26
|
+
window.kupolaData.set(key, newValue);
|
|
27
|
+
},
|
|
28
|
+
_key: key
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const refObj = {
|
|
33
|
+
_value: initialValue,
|
|
34
|
+
_subscribers: new Set()
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Object.defineProperty(refObj, 'value', {
|
|
38
|
+
get() {
|
|
39
|
+
return refObj._value;
|
|
40
|
+
},
|
|
41
|
+
set(newValue) {
|
|
42
|
+
if (newValue !== refObj._value) {
|
|
43
|
+
refObj._value = newValue;
|
|
44
|
+
refObj._subscribers.forEach(sub => sub(newValue));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return refObj;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
reactive(target) {
|
|
53
|
+
if (window.kupolaData) {
|
|
54
|
+
return window.kupolaData.createReactive(target);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const self = this;
|
|
58
|
+
const handler = {
|
|
59
|
+
get(target, key) {
|
|
60
|
+
if (key === '__isReactive') return true;
|
|
61
|
+
if (key === '__raw') return target;
|
|
62
|
+
const result = target[key];
|
|
63
|
+
if (typeof result === 'object' && result !== null && !result.__isReactive) {
|
|
64
|
+
target[key] = self.reactive(result);
|
|
65
|
+
}
|
|
66
|
+
return target[key];
|
|
67
|
+
},
|
|
68
|
+
set(target, key, value) {
|
|
69
|
+
if (target[key] === value) return true;
|
|
70
|
+
target[key] = value;
|
|
71
|
+
self._notifyWatchers(key, value);
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
deleteProperty(target, key) {
|
|
75
|
+
delete target[key];
|
|
76
|
+
self._notifyWatchers(key, undefined);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const proxy = new Proxy(target, handler);
|
|
82
|
+
proxy.__isReactive = true;
|
|
83
|
+
return proxy;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
onMounted(handler) {
|
|
87
|
+
if (this.lifecycle) {
|
|
88
|
+
this.lifecycle.on('mount', handler, { name: 'onMounted' });
|
|
89
|
+
} else {
|
|
90
|
+
this._onMountedHandlers.push(handler);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
onUnmounted(handler) {
|
|
95
|
+
if (this.lifecycle) {
|
|
96
|
+
this.lifecycle.on('unmount', handler, { name: 'onUnmounted' });
|
|
97
|
+
} else {
|
|
98
|
+
this._onUnmountedHandlers.push(handler);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
onUpdated(handler) {
|
|
103
|
+
if (this.lifecycle) {
|
|
104
|
+
this.lifecycle.on('update', handler, { name: 'onUpdated' });
|
|
105
|
+
} else {
|
|
106
|
+
this._onUpdatedHandlers.push(handler);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
watch(source, handler, options = {}) {
|
|
111
|
+
if (typeof source === 'function') {
|
|
112
|
+
const watcher = () => {
|
|
113
|
+
const newValue = source();
|
|
114
|
+
if (newValue !== watcher._oldValue) {
|
|
115
|
+
handler(newValue, watcher._oldValue);
|
|
116
|
+
watcher._oldValue = newValue;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
watcher._oldValue = undefined;
|
|
120
|
+
this._watches.push(watcher);
|
|
121
|
+
watcher();
|
|
122
|
+
|
|
123
|
+
if (window.kupolaData) {
|
|
124
|
+
const trackedPaths = [];
|
|
125
|
+
const originalGet = window.kupolaData.get;
|
|
126
|
+
window.kupolaData.get = function(k) {
|
|
127
|
+
trackedPaths.push(k);
|
|
128
|
+
return originalGet.call(this, k);
|
|
129
|
+
};
|
|
130
|
+
source();
|
|
131
|
+
window.kupolaData.get = originalGet;
|
|
132
|
+
|
|
133
|
+
trackedPaths.forEach(path => {
|
|
134
|
+
window.kupolaData.observe(path, watcher);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
} else if (typeof source === 'object' && source !== null) {
|
|
138
|
+
if (source._subscribers) {
|
|
139
|
+
source._subscribers.add(handler);
|
|
140
|
+
} else if (source._key && window.kupolaData) {
|
|
141
|
+
window.kupolaData.observe(source._key, () => {
|
|
142
|
+
handler(source.value);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
computed(getter) {
|
|
149
|
+
const result = this.ref();
|
|
150
|
+
const self = this;
|
|
151
|
+
|
|
152
|
+
let update = () => {
|
|
153
|
+
try {
|
|
154
|
+
result.value = getter();
|
|
155
|
+
} catch (e) {
|
|
156
|
+
console.error('Computed property error:', e);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const trackedPaths = [];
|
|
161
|
+
if (window.kupolaData) {
|
|
162
|
+
const originalGet = window.kupolaData.get;
|
|
163
|
+
window.kupolaData.get = function(k) {
|
|
164
|
+
trackedPaths.push(k);
|
|
165
|
+
return originalGet.call(this, k);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
update();
|
|
169
|
+
|
|
170
|
+
window.kupolaData.get = originalGet;
|
|
171
|
+
|
|
172
|
+
trackedPaths.forEach(path => {
|
|
173
|
+
window.kupolaData.observe(path, update);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
this._computedDeps.set(result, trackedPaths);
|
|
177
|
+
} else {
|
|
178
|
+
update();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let computedValue = result._value;
|
|
182
|
+
|
|
183
|
+
Object.defineProperty(result, 'value', {
|
|
184
|
+
get: () => computedValue,
|
|
185
|
+
set: (newValue) => {
|
|
186
|
+
console.warn('Cannot assign to a computed property');
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const originalUpdate = update;
|
|
191
|
+
update = () => {
|
|
192
|
+
try {
|
|
193
|
+
computedValue = getter();
|
|
194
|
+
} catch (e) {
|
|
195
|
+
console.error('Computed property error:', e);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
emit(eventName, data) {
|
|
203
|
+
if (this.component) {
|
|
204
|
+
this.component.$emit(eventName, data);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
_notifyWatchers(key, value) {
|
|
209
|
+
this._watches.forEach(watcher => {
|
|
210
|
+
try { watcher(); } catch (e) { console.error(e); }
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
_executeMounted() {
|
|
215
|
+
this._onMountedHandlers.forEach(handler => {
|
|
216
|
+
try { handler(); } catch (e) { console.error(e); }
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
_executeUnmounted() {
|
|
221
|
+
this._onUnmountedHandlers.forEach(handler => {
|
|
222
|
+
try { handler(); } catch (e) { console.error(e); }
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
_executeUpdated() {
|
|
227
|
+
this._onUpdatedHandlers.forEach(handler => {
|
|
228
|
+
try { handler(); } catch (e) { console.error(e); }
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
destroy() {
|
|
233
|
+
this._watches.forEach(watcher => {
|
|
234
|
+
if (watcher._subscribers) {
|
|
235
|
+
watcher._subscribers.clear();
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
this._watches = [];
|
|
239
|
+
|
|
240
|
+
this._computedDeps.forEach((paths, result) => {
|
|
241
|
+
paths.forEach(path => {
|
|
242
|
+
if (window.kupolaData) {
|
|
243
|
+
window.kupolaData.unobserve(path);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
this._computedDeps.clear();
|
|
248
|
+
|
|
249
|
+
this._refs.clear();
|
|
250
|
+
this._onMountedHandlers = [];
|
|
251
|
+
this._onUnmountedHandlers = [];
|
|
252
|
+
this._onUpdatedHandlers = [];
|
|
253
|
+
|
|
254
|
+
this.component = null;
|
|
255
|
+
this.lifecycle = null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function ref(initialValue = null) {
|
|
260
|
+
if (currentSetupContext) {
|
|
261
|
+
return currentSetupContext.ref(initialValue);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (window.kupolaData) {
|
|
265
|
+
const key = `__ref_${Math.random().toString(36).slice(2, 11)}__`;
|
|
266
|
+
window.kupolaData.set(key, initialValue);
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
get value() {
|
|
270
|
+
return window.kupolaData.get(key);
|
|
271
|
+
},
|
|
272
|
+
set value(newValue) {
|
|
273
|
+
window.kupolaData.set(key, newValue);
|
|
274
|
+
},
|
|
275
|
+
_key: key
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const refObj = {
|
|
280
|
+
_value: initialValue,
|
|
281
|
+
_subscribers: new Set()
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
Object.defineProperty(refObj, 'value', {
|
|
285
|
+
get() {
|
|
286
|
+
return refObj._value;
|
|
287
|
+
},
|
|
288
|
+
set(newValue) {
|
|
289
|
+
if (newValue !== refObj._value) {
|
|
290
|
+
refObj._value = newValue;
|
|
291
|
+
refObj._subscribers.forEach(sub => sub(newValue));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
return refObj;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function reactive(target) {
|
|
300
|
+
if (currentSetupContext) {
|
|
301
|
+
return currentSetupContext.reactive(target);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (window.kupolaData) {
|
|
305
|
+
return window.kupolaData.createReactive(target);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const handler = {
|
|
309
|
+
get(target, key) {
|
|
310
|
+
if (key === '__isReactive') return true;
|
|
311
|
+
if (key === '__raw') return target;
|
|
312
|
+
const result = target[key];
|
|
313
|
+
if (typeof result === 'object' && result !== null && !result.__isReactive) {
|
|
314
|
+
target[key] = new Proxy(result, handler);
|
|
315
|
+
target[key].__isReactive = true;
|
|
316
|
+
}
|
|
317
|
+
return target[key];
|
|
318
|
+
},
|
|
319
|
+
set(target, key, value) {
|
|
320
|
+
if (target[key] === value) return true;
|
|
321
|
+
target[key] = value;
|
|
322
|
+
if (currentSetupContext) {
|
|
323
|
+
currentSetupContext._notifyWatchers(key, value);
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
},
|
|
327
|
+
deleteProperty(target, key) {
|
|
328
|
+
delete target[key];
|
|
329
|
+
if (currentSetupContext) {
|
|
330
|
+
currentSetupContext._notifyWatchers(key, undefined);
|
|
331
|
+
}
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
const proxy = new Proxy(target, handler);
|
|
337
|
+
proxy.__isReactive = true;
|
|
338
|
+
return proxy;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function onMounted(handler) {
|
|
342
|
+
if (currentSetupContext) {
|
|
343
|
+
currentSetupContext.onMounted(handler);
|
|
344
|
+
} else {
|
|
345
|
+
console.warn('onMounted called outside of setup()');
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function onUnmounted(handler) {
|
|
350
|
+
if (currentSetupContext) {
|
|
351
|
+
currentSetupContext.onUnmounted(handler);
|
|
352
|
+
} else {
|
|
353
|
+
console.warn('onUnmounted called outside of setup()');
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function onUpdated(handler) {
|
|
358
|
+
if (currentSetupContext) {
|
|
359
|
+
currentSetupContext.onUpdated(handler);
|
|
360
|
+
} else {
|
|
361
|
+
console.warn('onUpdated called outside of setup()');
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function watch(source, handler, options = {}) {
|
|
366
|
+
if (currentSetupContext) {
|
|
367
|
+
currentSetupContext.watch(source, handler, options);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function computed(getter) {
|
|
372
|
+
if (currentSetupContext) {
|
|
373
|
+
return currentSetupContext.computed(getter);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const result = ref();
|
|
377
|
+
|
|
378
|
+
let update = () => {
|
|
379
|
+
try {
|
|
380
|
+
result.value = getter();
|
|
381
|
+
} catch (e) {
|
|
382
|
+
console.error('Computed property error:', e);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
if (window.kupolaData) {
|
|
387
|
+
const trackedPaths = [];
|
|
388
|
+
const originalGet = window.kupolaData.get;
|
|
389
|
+
window.kupolaData.get = function(k) {
|
|
390
|
+
trackedPaths.push(k);
|
|
391
|
+
return originalGet.call(this, k);
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
update();
|
|
395
|
+
|
|
396
|
+
window.kupolaData.get = originalGet;
|
|
397
|
+
|
|
398
|
+
trackedPaths.forEach(path => {
|
|
399
|
+
window.kupolaData.observe(path, update);
|
|
400
|
+
});
|
|
401
|
+
} else {
|
|
402
|
+
update();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
let computedValue = result._value;
|
|
406
|
+
|
|
407
|
+
Object.defineProperty(result, 'value', {
|
|
408
|
+
get: () => computedValue,
|
|
409
|
+
set: (newValue) => {
|
|
410
|
+
console.warn('Cannot assign to a computed property');
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
const originalUpdate = update;
|
|
415
|
+
update = () => {
|
|
416
|
+
try {
|
|
417
|
+
computedValue = getter();
|
|
418
|
+
} catch (e) {
|
|
419
|
+
console.error('Computed property error:', e);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
return result;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function setup(setupFn) {
|
|
427
|
+
if (typeof setupFn !== 'function') {
|
|
428
|
+
console.error('setup() requires a function argument');
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const setupContext = new SetupContext();
|
|
433
|
+
const prevContext = currentSetupContext;
|
|
434
|
+
currentSetupContext = setupContext;
|
|
435
|
+
|
|
436
|
+
let result;
|
|
437
|
+
try {
|
|
438
|
+
result = setupFn(setupContext);
|
|
439
|
+
} finally {
|
|
440
|
+
currentSetupContext = prevContext;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return result;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
window.SetupContext = SetupContext;
|
|
447
|
+
window.ref = ref;
|
|
448
|
+
window.reactive = reactive;
|
|
449
|
+
window.onMounted = onMounted;
|
|
450
|
+
window.onUnmounted = onUnmounted;
|
|
451
|
+
window.onUpdated = onUpdated;
|
|
452
|
+
window.watch = watch;
|
|
453
|
+
window.computed = computed;
|
|
454
|
+
window.setup = setup;
|
|
455
|
+
window._getCurrentSetupContext = () => currentSetupContext;
|
|
456
|
+
window._setCurrentSetupContext = (ctx) => { currentSetupContext = ctx; };
|
|
457
|
+
window._clearSetupContext = () => { currentSetupContext = null; };
|
|
458
|
+
})(window);
|
package/js/countdown.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
class Countdown {
|
|
2
|
+
constructor(element) {
|
|
3
|
+
this.element = element;
|
|
4
|
+
this.hoursEl = element.querySelector('.ds-countdown__item--hours .ds-countdown__value');
|
|
5
|
+
this.minutesEl = element.querySelector('.ds-countdown__item--minutes .ds-countdown__value');
|
|
6
|
+
this.secondsEl = element.querySelector('.ds-countdown__item--seconds .ds-countdown__value');
|
|
7
|
+
|
|
8
|
+
this.endTime = this.parseEndTime();
|
|
9
|
+
this.interval = null;
|
|
10
|
+
|
|
11
|
+
this.init();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
parseEndTime() {
|
|
15
|
+
const dataEndTime = this.element.getAttribute('data-end-time');
|
|
16
|
+
if (dataEndTime) {
|
|
17
|
+
return new Date(dataEndTime).getTime();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const dataHours = parseInt(this.element.getAttribute('data-hours')) || 0;
|
|
21
|
+
const dataMinutes = parseInt(this.element.getAttribute('data-minutes')) || 0;
|
|
22
|
+
const dataSeconds = parseInt(this.element.getAttribute('data-seconds')) || 0;
|
|
23
|
+
|
|
24
|
+
return new Date().getTime() + (dataHours * 3600 + dataMinutes * 60 + dataSeconds) * 1000;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
init() {
|
|
28
|
+
this.update();
|
|
29
|
+
this.start();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
start() {
|
|
33
|
+
if (this.interval) {
|
|
34
|
+
clearInterval(this.interval);
|
|
35
|
+
}
|
|
36
|
+
this.interval = setInterval(() => {
|
|
37
|
+
this.update();
|
|
38
|
+
}, 1000);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
stop() {
|
|
42
|
+
if (this.interval) {
|
|
43
|
+
clearInterval(this.interval);
|
|
44
|
+
this.interval = null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
reset() {
|
|
49
|
+
this.stop();
|
|
50
|
+
this.endTime = this.parseEndTime();
|
|
51
|
+
this.init();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
update() {
|
|
55
|
+
const now = new Date().getTime();
|
|
56
|
+
const distance = this.endTime - now;
|
|
57
|
+
|
|
58
|
+
if (distance <= 0) {
|
|
59
|
+
this.stop();
|
|
60
|
+
this.displayTime(0, 0, 0);
|
|
61
|
+
this.dispatchComplete();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
66
|
+
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
|
67
|
+
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
|
68
|
+
|
|
69
|
+
this.displayTime(hours, minutes, seconds);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
displayTime(hours, minutes, seconds) {
|
|
73
|
+
if (this.hoursEl) {
|
|
74
|
+
this.hoursEl.textContent = String(hours).padStart(2, '0');
|
|
75
|
+
}
|
|
76
|
+
if (this.minutesEl) {
|
|
77
|
+
this.minutesEl.textContent = String(minutes).padStart(2, '0');
|
|
78
|
+
}
|
|
79
|
+
if (this.secondsEl) {
|
|
80
|
+
this.secondsEl.textContent = String(seconds).padStart(2, '0');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setEndTime(date) {
|
|
85
|
+
this.endTime = date.getTime();
|
|
86
|
+
this.update();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
addTime(seconds) {
|
|
90
|
+
this.endTime += seconds * 1000;
|
|
91
|
+
this.update();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
dispatchComplete() {
|
|
95
|
+
this.element.dispatchEvent(new CustomEvent('ds-countdown-complete', {
|
|
96
|
+
detail: {}
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
destroy() {
|
|
101
|
+
this.stop();
|
|
102
|
+
this.hoursEl = null;
|
|
103
|
+
this.minutesEl = null;
|
|
104
|
+
this.secondsEl = null;
|
|
105
|
+
this.element = null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function initCountdown(element) {
|
|
110
|
+
if (element.__kupolaInitialized) return;
|
|
111
|
+
|
|
112
|
+
const instance = new Countdown(element);
|
|
113
|
+
element.__kupolaInstance = instance;
|
|
114
|
+
element.__kupolaInitialized = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function cleanupCountdown(element) {
|
|
118
|
+
if (!element.__kupolaInitialized || !element.__kupolaInstance) return;
|
|
119
|
+
|
|
120
|
+
const instance = element.__kupolaInstance;
|
|
121
|
+
instance.destroy();
|
|
122
|
+
|
|
123
|
+
element.__kupolaInstance = null;
|
|
124
|
+
element.__kupolaInitialized = false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function initCountdowns() {
|
|
128
|
+
const countdowns = document.querySelectorAll('.ds-countdown');
|
|
129
|
+
countdowns.forEach(el => {
|
|
130
|
+
initCountdown(el);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
135
|
+
module.exports = { Countdown, initCountdowns, initCountdown, cleanupCountdown };
|
|
136
|
+
} else {
|
|
137
|
+
window.Countdown = Countdown;
|
|
138
|
+
window.initCountdown = initCountdown;
|
|
139
|
+
window.cleanupCountdown = cleanupCountdown;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (window.kupolaInitializer) {
|
|
143
|
+
window.kupolaInitializer.register('countdown', initCountdown, cleanupCountdown);
|
|
144
|
+
}
|