@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.
Files changed (354) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/INTEGRATION.md +440 -0
  3. package/PROJECT_SUMMARY.md +312 -0
  4. package/README.md +286 -0
  5. package/SKILL.md +572 -0
  6. package/css/accessibility.css +119 -0
  7. package/css/animations.css +224 -0
  8. package/css/brand-themes.css +300 -0
  9. package/css/colors_and_type.css +441 -0
  10. package/css/components-ext.css +4165 -0
  11. package/css/components.css +1483 -0
  12. package/css/kupola.css +12 -0
  13. package/css/responsive.css +697 -0
  14. package/css/scaffold.css +145 -0
  15. package/css/states.css +316 -0
  16. package/css/theme-dark.css +296 -0
  17. package/css/theme-light.css +296 -0
  18. package/css/utilities.css +171 -0
  19. package/dist/css/kupola.css +12 -0
  20. package/dist/icons/icons/activity.svg +3 -0
  21. package/dist/icons/icons/alert-circle.svg +1 -0
  22. package/dist/icons/icons/alert-triangle.svg +1 -0
  23. package/dist/icons/icons/alert.d27e24.svg +1 -0
  24. package/dist/icons/icons/alert.svg +1 -0
  25. package/dist/icons/icons/apple.svg +1 -0
  26. package/dist/icons/icons/arrow-down.svg +1 -0
  27. package/dist/icons/icons/arrow-expand.svg +1 -0
  28. package/dist/icons/icons/arrow-left.svg +1 -0
  29. package/dist/icons/icons/arrow-minimize.svg +1 -0
  30. package/dist/icons/icons/arrow-right-to-line.svg +1 -0
  31. package/dist/icons/icons/arrow-right.svg +1 -0
  32. package/dist/icons/icons/arrow-up-right.svg +1 -0
  33. package/dist/icons/icons/arrow-up.0c0c0d.svg +1 -0
  34. package/dist/icons/icons/arrow-up.svg +1 -0
  35. package/dist/icons/icons/at.svg +1 -0
  36. package/dist/icons/icons/atom.0c0c0d.svg +1 -0
  37. package/dist/icons/icons/atom.svg +1 -0
  38. package/dist/icons/icons/bar-chart-2.svg +1 -0
  39. package/dist/icons/icons/bar.svg +1 -0
  40. package/dist/icons/icons/bell.svg +1 -0
  41. package/dist/icons/icons/box.svg +1 -0
  42. package/dist/icons/icons/bug.svg +1 -0
  43. package/dist/icons/icons/button.svg +1 -0
  44. package/dist/icons/icons/calendar.svg +1 -0
  45. package/dist/icons/icons/check-circle.33c192.svg +1 -0
  46. package/dist/icons/icons/check-circle.svg +1 -0
  47. package/dist/icons/icons/check-square.svg +4 -0
  48. package/dist/icons/icons/check.d1d3db.svg +1 -0
  49. package/dist/icons/icons/check.svg +1 -0
  50. package/dist/icons/icons/chevron-down.svg +1 -0
  51. package/dist/icons/icons/chevron-left.svg +1 -0
  52. package/dist/icons/icons/chevron-right.svg +1 -0
  53. package/dist/icons/icons/chevron-up.svg +1 -0
  54. package/dist/icons/icons/circle.svg +1 -0
  55. package/dist/icons/icons/clock.svg +1 -0
  56. package/dist/icons/icons/cmd.svg +1 -0
  57. package/dist/icons/icons/code.svg +1 -0
  58. package/dist/icons/icons/columns.svg +1 -0
  59. package/dist/icons/icons/copy.svg +1 -0
  60. package/dist/icons/icons/cpu.svg +1 -0
  61. package/dist/icons/icons/dashboard.0c0c0d.svg +1 -0
  62. package/dist/icons/icons/dashboard.svg +1 -0
  63. package/dist/icons/icons/dollar.svg +1 -0
  64. package/dist/icons/icons/download.svg +1 -0
  65. package/dist/icons/icons/edit.svg +1 -0
  66. package/dist/icons/icons/extensions.svg +1 -0
  67. package/dist/icons/icons/external.svg +1 -0
  68. package/dist/icons/icons/eye.svg +1 -0
  69. package/dist/icons/icons/file-text.svg +1 -0
  70. package/dist/icons/icons/file.svg +1 -0
  71. package/dist/icons/icons/files.svg +1 -0
  72. package/dist/icons/icons/filter.svg +1 -0
  73. package/dist/icons/icons/folder-open.svg +4 -0
  74. package/dist/icons/icons/folder.svg +1 -0
  75. package/dist/icons/icons/gear.svg +1 -0
  76. package/dist/icons/icons/git.svg +1 -0
  77. package/dist/icons/icons/github.svg +1 -0
  78. package/dist/icons/icons/globe.svg +1 -0
  79. package/dist/icons/icons/grid-2x2.svg +1 -0
  80. package/dist/icons/icons/hash.svg +1 -0
  81. package/dist/icons/icons/heart.svg +1 -0
  82. package/dist/icons/icons/help-circle.svg +5 -0
  83. package/dist/icons/icons/help.svg +1 -0
  84. package/dist/icons/icons/home.svg +1 -0
  85. package/dist/icons/icons/icons.svg +153 -0
  86. package/dist/icons/icons/image.svg +1 -0
  87. package/dist/icons/icons/info-circle.svg +1 -0
  88. package/dist/icons/icons/info-square.svg +1 -0
  89. package/dist/icons/icons/info.387bff.svg +1 -0
  90. package/dist/icons/icons/info.svg +1 -0
  91. package/dist/icons/icons/input.svg +1 -0
  92. package/dist/icons/icons/key.svg +1 -0
  93. package/dist/icons/icons/layers.svg +1 -0
  94. package/dist/icons/icons/layout-grid.svg +6 -0
  95. package/dist/icons/icons/layout.svg +1 -0
  96. package/dist/icons/icons/link.svg +1 -0
  97. package/dist/icons/icons/list.svg +1 -0
  98. package/dist/icons/icons/lock.svg +1 -0
  99. package/dist/icons/icons/log-out.svg +1 -0
  100. package/dist/icons/icons/logo.svg +1 -0
  101. package/dist/icons/icons/mail.svg +1 -0
  102. package/dist/icons/icons/menu.svg +1 -0
  103. package/dist/icons/icons/message-circle.svg +1 -0
  104. package/dist/icons/icons/message-plus.svg +1 -0
  105. package/dist/icons/icons/message-square.svg +1 -0
  106. package/dist/icons/icons/mic.svg +1 -0
  107. package/dist/icons/icons/minus.svg +1 -0
  108. package/dist/icons/icons/moon.svg +1 -0
  109. package/dist/icons/icons/more-h.svg +1 -0
  110. package/dist/icons/icons/mouse.svg +1 -0
  111. package/dist/icons/icons/palette.svg +1 -0
  112. package/dist/icons/icons/panel-bottom.svg +1 -0
  113. package/dist/icons/icons/pause.svg +1 -0
  114. package/dist/icons/icons/play.svg +1 -0
  115. package/dist/icons/icons/plug.svg +1 -0
  116. package/dist/icons/icons/plus.0c0c0d.svg +1 -0
  117. package/dist/icons/icons/plus.svg +1 -0
  118. package/dist/icons/icons/refresh.svg +1 -0
  119. package/dist/icons/icons/ruler.svg +1 -0
  120. package/dist/icons/icons/scroll-text.svg +1 -0
  121. package/dist/icons/icons/search-menu.svg +1 -0
  122. package/dist/icons/icons/search.svg +1 -0
  123. package/dist/icons/icons/send.0c0c0d.svg +1 -0
  124. package/dist/icons/icons/send.svg +1 -0
  125. package/dist/icons/icons/settings.0c0c0d.svg +1 -0
  126. package/dist/icons/icons/settings.svg +1 -0
  127. package/dist/icons/icons/shield.svg +1 -0
  128. package/dist/icons/icons/sidebar-left.svg +1 -0
  129. package/dist/icons/icons/sidebar-right.svg +1 -0
  130. package/dist/icons/icons/sliders.svg +1 -0
  131. package/dist/icons/icons/sparkles.32f08c.svg +1 -0
  132. package/dist/icons/icons/sparkles.svg +1 -0
  133. package/dist/icons/icons/square.svg +1 -0
  134. package/dist/icons/icons/star.svg +1 -0
  135. package/dist/icons/icons/sun.svg +1 -0
  136. package/dist/icons/icons/table.svg +1 -0
  137. package/dist/icons/icons/terminal.svg +1 -0
  138. package/dist/icons/icons/trash.svg +1 -0
  139. package/dist/icons/icons/trending-down.svg +1 -0
  140. package/dist/icons/icons/trending-up.svg +1 -0
  141. package/dist/icons/icons/type.svg +1 -0
  142. package/dist/icons/icons/upload.svg +1 -0
  143. package/dist/icons/icons/user-circle.svg +1 -0
  144. package/dist/icons/icons/user-plus.svg +6 -0
  145. package/dist/icons/icons/user.svg +1 -0
  146. package/dist/icons/icons/users.svg +1 -0
  147. package/dist/icons/icons/warning.svg +1 -0
  148. package/dist/icons/icons/wrench.svg +1 -0
  149. package/dist/icons/icons/x-circle.svg +1 -0
  150. package/dist/icons/icons/x.svg +1 -0
  151. package/dist/icons/icons/zap.0c0c0d.svg +1 -0
  152. package/dist/icons/icons/zap.svg +1 -0
  153. package/dist/kupola.cjs.js +258 -0
  154. package/dist/kupola.cjs.js.map +1 -0
  155. package/dist/kupola.esm.js +7640 -0
  156. package/dist/kupola.esm.js.map +1 -0
  157. package/dist/kupola.umd.js +258 -0
  158. package/dist/kupola.umd.js.map +1 -0
  159. package/dist/types/kupola.d.ts +1359 -0
  160. package/dist/utils/utils/Kupola.cs +77 -0
  161. package/dist/utils/utils/Kupola.java +104 -0
  162. package/dist/utils/utils/kupola.go +120 -0
  163. package/dist/utils/utils/kupola.js +63 -0
  164. package/dist/utils/utils/kupola.py +1392 -0
  165. package/dist/utils/utils/kupola.rb +69 -0
  166. package/icons/activity.svg +3 -0
  167. package/icons/alert-circle.svg +1 -0
  168. package/icons/alert-triangle.svg +1 -0
  169. package/icons/alert.d27e24.svg +1 -0
  170. package/icons/alert.svg +1 -0
  171. package/icons/apple.svg +1 -0
  172. package/icons/arrow-down.svg +1 -0
  173. package/icons/arrow-expand.svg +1 -0
  174. package/icons/arrow-left.svg +1 -0
  175. package/icons/arrow-minimize.svg +1 -0
  176. package/icons/arrow-right-to-line.svg +1 -0
  177. package/icons/arrow-right.svg +1 -0
  178. package/icons/arrow-up-right.svg +1 -0
  179. package/icons/arrow-up.0c0c0d.svg +1 -0
  180. package/icons/arrow-up.svg +1 -0
  181. package/icons/at.svg +1 -0
  182. package/icons/atom.0c0c0d.svg +1 -0
  183. package/icons/atom.svg +1 -0
  184. package/icons/bar-chart-2.svg +1 -0
  185. package/icons/bar.svg +1 -0
  186. package/icons/bell.svg +1 -0
  187. package/icons/box.svg +1 -0
  188. package/icons/bug.svg +1 -0
  189. package/icons/button.svg +1 -0
  190. package/icons/calendar.svg +1 -0
  191. package/icons/check-circle.33c192.svg +1 -0
  192. package/icons/check-circle.svg +1 -0
  193. package/icons/check-square.svg +4 -0
  194. package/icons/check.d1d3db.svg +1 -0
  195. package/icons/check.svg +1 -0
  196. package/icons/chevron-down.svg +1 -0
  197. package/icons/chevron-left.svg +1 -0
  198. package/icons/chevron-right.svg +1 -0
  199. package/icons/chevron-up.svg +1 -0
  200. package/icons/circle.svg +1 -0
  201. package/icons/clock.svg +1 -0
  202. package/icons/cmd.svg +1 -0
  203. package/icons/code.svg +1 -0
  204. package/icons/columns.svg +1 -0
  205. package/icons/copy.svg +1 -0
  206. package/icons/cpu.svg +1 -0
  207. package/icons/dashboard.0c0c0d.svg +1 -0
  208. package/icons/dashboard.svg +1 -0
  209. package/icons/dollar.svg +1 -0
  210. package/icons/download.svg +1 -0
  211. package/icons/edit.svg +1 -0
  212. package/icons/extensions.svg +1 -0
  213. package/icons/external.svg +1 -0
  214. package/icons/eye.svg +1 -0
  215. package/icons/file-text.svg +1 -0
  216. package/icons/file.svg +1 -0
  217. package/icons/files.svg +1 -0
  218. package/icons/filter.svg +1 -0
  219. package/icons/folder-open.svg +4 -0
  220. package/icons/folder.svg +1 -0
  221. package/icons/gear.svg +1 -0
  222. package/icons/git.svg +1 -0
  223. package/icons/github.svg +1 -0
  224. package/icons/globe.svg +1 -0
  225. package/icons/grid-2x2.svg +1 -0
  226. package/icons/hash.svg +1 -0
  227. package/icons/heart.svg +1 -0
  228. package/icons/help-circle.svg +5 -0
  229. package/icons/help.svg +1 -0
  230. package/icons/home.svg +1 -0
  231. package/icons/icons.svg +153 -0
  232. package/icons/image.svg +1 -0
  233. package/icons/info-circle.svg +1 -0
  234. package/icons/info-square.svg +1 -0
  235. package/icons/info.387bff.svg +1 -0
  236. package/icons/info.svg +1 -0
  237. package/icons/input.svg +1 -0
  238. package/icons/key.svg +1 -0
  239. package/icons/layers.svg +1 -0
  240. package/icons/layout-grid.svg +6 -0
  241. package/icons/layout.svg +1 -0
  242. package/icons/link.svg +1 -0
  243. package/icons/list.svg +1 -0
  244. package/icons/lock.svg +1 -0
  245. package/icons/log-out.svg +1 -0
  246. package/icons/logo.svg +1 -0
  247. package/icons/mail.svg +1 -0
  248. package/icons/menu.svg +1 -0
  249. package/icons/message-circle.svg +1 -0
  250. package/icons/message-plus.svg +1 -0
  251. package/icons/message-square.svg +1 -0
  252. package/icons/mic.svg +1 -0
  253. package/icons/minus.svg +1 -0
  254. package/icons/moon.svg +1 -0
  255. package/icons/more-h.svg +1 -0
  256. package/icons/mouse.svg +1 -0
  257. package/icons/palette.svg +1 -0
  258. package/icons/panel-bottom.svg +1 -0
  259. package/icons/pause.svg +1 -0
  260. package/icons/play.svg +1 -0
  261. package/icons/plug.svg +1 -0
  262. package/icons/plus.0c0c0d.svg +1 -0
  263. package/icons/plus.svg +1 -0
  264. package/icons/refresh.svg +1 -0
  265. package/icons/ruler.svg +1 -0
  266. package/icons/scroll-text.svg +1 -0
  267. package/icons/search-menu.svg +1 -0
  268. package/icons/search.svg +1 -0
  269. package/icons/send.0c0c0d.svg +1 -0
  270. package/icons/send.svg +1 -0
  271. package/icons/settings.0c0c0d.svg +1 -0
  272. package/icons/settings.svg +1 -0
  273. package/icons/shield.svg +1 -0
  274. package/icons/sidebar-left.svg +1 -0
  275. package/icons/sidebar-right.svg +1 -0
  276. package/icons/sliders.svg +1 -0
  277. package/icons/sparkles.32f08c.svg +1 -0
  278. package/icons/sparkles.svg +1 -0
  279. package/icons/square.svg +1 -0
  280. package/icons/star.svg +1 -0
  281. package/icons/sun.svg +1 -0
  282. package/icons/table.svg +1 -0
  283. package/icons/terminal.svg +1 -0
  284. package/icons/trash.svg +1 -0
  285. package/icons/trending-down.svg +1 -0
  286. package/icons/trending-up.svg +1 -0
  287. package/icons/type.svg +1 -0
  288. package/icons/upload.svg +1 -0
  289. package/icons/user-circle.svg +1 -0
  290. package/icons/user-plus.svg +6 -0
  291. package/icons/user.svg +1 -0
  292. package/icons/users.svg +1 -0
  293. package/icons/warning.svg +1 -0
  294. package/icons/wrench.svg +1 -0
  295. package/icons/x-circle.svg +1 -0
  296. package/icons/x.svg +1 -0
  297. package/icons/zap.0c0c0d.svg +1 -0
  298. package/icons/zap.svg +1 -0
  299. package/js/calendar.js +184 -0
  300. package/js/carousel.js +173 -0
  301. package/js/collapse.js +127 -0
  302. package/js/color-picker.js +144 -0
  303. package/js/component.js +276 -0
  304. package/js/composition-api.js +458 -0
  305. package/js/countdown.js +144 -0
  306. package/js/data-bind.js +1286 -0
  307. package/js/datepicker.js +270 -0
  308. package/js/dialog.js +131 -0
  309. package/js/drawer.js +118 -0
  310. package/js/dropdown.js +122 -0
  311. package/js/dynamic-tags.js +156 -0
  312. package/js/error-handler.js +181 -0
  313. package/js/fileupload.js +392 -0
  314. package/js/form.js +291 -0
  315. package/js/global-events.js +203 -0
  316. package/js/heatmap.js +405 -0
  317. package/js/http.js +419 -0
  318. package/js/i18n.js +228 -0
  319. package/js/icons.js +165 -0
  320. package/js/image-preview.js +218 -0
  321. package/js/initializer.js +162 -0
  322. package/js/kupola-core.js +66 -0
  323. package/js/kupola-devtools.js +598 -0
  324. package/js/kupola-lifecycle.js +510 -0
  325. package/js/message.js +60 -0
  326. package/js/modal.js +191 -0
  327. package/js/notification.js +73 -0
  328. package/js/numberinput.js +146 -0
  329. package/js/performance.js +250 -0
  330. package/js/registry.js +205 -0
  331. package/js/router.js +396 -0
  332. package/js/security.js +189 -0
  333. package/js/select.js +143 -0
  334. package/js/slide-captcha.js +504 -0
  335. package/js/slider.js +94 -0
  336. package/js/statcard.js +219 -0
  337. package/js/tag.js +83 -0
  338. package/js/test-utils.js +251 -0
  339. package/js/theme.js +363 -0
  340. package/js/timepicker.js +238 -0
  341. package/js/tooltip.js +122 -0
  342. package/js/utils.js +1458 -0
  343. package/js/validation.js +553 -0
  344. package/js/virtual-list.js +593 -0
  345. package/package.json +105 -0
  346. package/templates/base.html +30 -0
  347. package/templates/base_dashboard.html +99 -0
  348. package/types/kupola.d.ts +1359 -0
  349. package/utils/Kupola.cs +77 -0
  350. package/utils/Kupola.java +104 -0
  351. package/utils/kupola.go +120 -0
  352. package/utils/kupola.js +63 -0
  353. package/utils/kupola.py +1392 -0
  354. package/utils/kupola.rb +69 -0
@@ -0,0 +1,270 @@
1
+ class Datepicker {
2
+ constructor(element) {
3
+ this.element = element;
4
+ this.input = element.querySelector('input');
5
+ this.icon = element.querySelector('.ds-datepicker__icon');
6
+ this.calendarEl = element.querySelector('.ds-datepicker__calendar');
7
+ this.scope = `datepicker-${Math.random().toString(36).substr(2, 9)}`;
8
+
9
+ this._iconClickHandler = null;
10
+ this._inputClickHandler = null;
11
+ this._documentClickHandler = null;
12
+ this._documentClickListener = null;
13
+ this._resizeHandler = null;
14
+ this._resizeListener = null;
15
+ }
16
+
17
+ init() {
18
+ if (!this.calendarEl) return;
19
+ if (this.element.__kupolaInitialized) return;
20
+
21
+ this._iconClickHandler = (e) => this.toggleCalendar(e);
22
+ this._inputClickHandler = (e) => this.toggleCalendar(e);
23
+
24
+ if (this.icon) {
25
+ this.icon.addEventListener('click', this._iconClickHandler);
26
+ }
27
+
28
+ this.input.addEventListener('click', this._inputClickHandler);
29
+
30
+ if (window.globalEvents) {
31
+ this._documentClickListener = window.globalEvents.on(document, 'click', (e) => this.hideCalendar(e), { scope: this.scope });
32
+ this._resizeListener = window.globalEvents.on(window, 'resize', () => this.resizeHandler(), { scope: this.scope });
33
+ } else {
34
+ document.addEventListener('click', (e) => this.hideCalendar(e));
35
+ window.addEventListener('resize', () => this.resizeHandler());
36
+ this._documentClickHandler = (e) => this.hideCalendar(e);
37
+ this._resizeHandler = () => this.resizeHandler();
38
+ }
39
+
40
+ this.element.__kupolaInitialized = true;
41
+ this.initCalendar();
42
+ }
43
+
44
+ calculatePosition() {
45
+ const pickerRect = this.element.getBoundingClientRect();
46
+ const calendarRect = this.calendarEl.getBoundingClientRect();
47
+ const viewportHeight = window.innerHeight;
48
+
49
+ const spaceBelow = viewportHeight - pickerRect.bottom;
50
+ const spaceAbove = pickerRect.top;
51
+ const calendarHeight = calendarRect.height || 280;
52
+
53
+ if (spaceBelow >= calendarHeight) {
54
+ this.calendarEl.style.top = 'calc(100% + 4px)';
55
+ this.calendarEl.style.bottom = 'auto';
56
+ } else if (spaceAbove >= calendarHeight) {
57
+ this.calendarEl.style.top = 'auto';
58
+ this.calendarEl.style.bottom = 'calc(100% + 4px)';
59
+ } else {
60
+ this.calendarEl.style.top = 'calc(100% + 4px)';
61
+ this.calendarEl.style.bottom = 'auto';
62
+ }
63
+ }
64
+
65
+ toggleCalendar(e) {
66
+ e.preventDefault();
67
+ e.stopPropagation();
68
+
69
+ const isVisible = this.calendarEl.style.display === 'block';
70
+
71
+ document.querySelectorAll('.ds-datepicker__calendar').forEach(c => {
72
+ c.style.display = 'none';
73
+ c.setAttribute('hidden', '');
74
+ });
75
+
76
+ if (!isVisible) {
77
+ this.calendarEl.style.display = 'block';
78
+ this.calendarEl.removeAttribute('hidden');
79
+ this.calculatePosition();
80
+ }
81
+ }
82
+
83
+ hideCalendar(e) {
84
+ if (!this.element.contains(e.target)) {
85
+ this.calendarEl.style.display = 'none';
86
+ this.calendarEl.setAttribute('hidden', '');
87
+ }
88
+ }
89
+
90
+ resizeHandler() {
91
+ if (this.calendarEl.style.display === 'block') {
92
+ this.calculatePosition();
93
+ }
94
+ }
95
+
96
+ initCalendar() {
97
+ const calendar = this.calendarEl;
98
+ const input = this.input;
99
+ const titleEl = calendar.querySelector('.ds-datepicker__title');
100
+ const daysEl = calendar.querySelector('.ds-datepicker__days');
101
+ const prevBtn = calendar.querySelector('.ds-datepicker__nav--prev');
102
+ const nextBtn = calendar.querySelector('.ds-datepicker__nav--next');
103
+
104
+ let currentDate = new Date();
105
+ if (input.value) {
106
+ const parts = input.value.split('-');
107
+ if (parts.length === 3) {
108
+ currentDate = new Date(parts[0], parts[1] - 1, parts[2]);
109
+ }
110
+ }
111
+
112
+ function renderCalendar() {
113
+ daysEl.querySelectorAll('.ds-datepicker__day').forEach(dayEl => {
114
+ if (dayEl._dayClickHandler) {
115
+ dayEl.removeEventListener('click', dayEl._dayClickHandler);
116
+ }
117
+ });
118
+
119
+ daysEl.innerHTML = '';
120
+
121
+ const year = currentDate.getFullYear();
122
+ const month = currentDate.getMonth();
123
+
124
+ titleEl.textContent = `${year} ${['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][month]}`;
125
+
126
+ const firstDay = new Date(year, month, 1).getDay();
127
+ const daysInMonth = new Date(year, month + 1, 0).getDate();
128
+
129
+ for (let i = 0; i < firstDay; i++) {
130
+ const emptyDay = document.createElement('span');
131
+ emptyDay.className = 'ds-datepicker__day--empty';
132
+ daysEl.appendChild(emptyDay);
133
+ }
134
+
135
+ for (let day = 1; day <= daysInMonth; day++) {
136
+ const dayEl = document.createElement('button');
137
+ dayEl.className = 'ds-datepicker__day';
138
+ dayEl.textContent = day;
139
+
140
+ const dateStr = `${year}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
141
+ if (input.value === dateStr) {
142
+ dayEl.classList.add('is-selected');
143
+ }
144
+
145
+ const today = new Date();
146
+ const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
147
+ if (dateStr === todayStr) {
148
+ dayEl.classList.add('is-today');
149
+ }
150
+
151
+ const dayClickHandler = () => {
152
+ input.value = dateStr;
153
+ calendar.style.display = 'none';
154
+ calendar.setAttribute('hidden', '');
155
+ input.dispatchEvent(new Event('change'));
156
+ };
157
+
158
+ dayEl.addEventListener('click', dayClickHandler);
159
+ dayEl._dayClickHandler = dayClickHandler;
160
+
161
+ daysEl.appendChild(dayEl);
162
+ }
163
+ }
164
+
165
+ const prevClickHandler = (e) => {
166
+ e.stopPropagation();
167
+ currentDate.setMonth(currentDate.getMonth() - 1);
168
+ renderCalendar();
169
+ };
170
+
171
+ const nextClickHandler = (e) => {
172
+ e.stopPropagation();
173
+ currentDate.setMonth(currentDate.getMonth() + 1);
174
+ renderCalendar();
175
+ };
176
+
177
+ if (prevBtn) {
178
+ prevBtn.addEventListener('click', prevClickHandler);
179
+ prevBtn._prevClickHandler = prevClickHandler;
180
+ }
181
+
182
+ if (nextBtn) {
183
+ nextBtn.addEventListener('click', nextClickHandler);
184
+ nextBtn._nextClickHandler = nextClickHandler;
185
+ }
186
+
187
+ calendar._calendarInitialized = true;
188
+ renderCalendar();
189
+ }
190
+
191
+ destroy() {
192
+ if (!this.element.__kupolaInitialized) return;
193
+
194
+ if (this.icon && this._iconClickHandler) {
195
+ this.icon.removeEventListener('click', this._iconClickHandler);
196
+ }
197
+
198
+ if (this.input && this._inputClickHandler) {
199
+ this.input.removeEventListener('click', this._inputClickHandler);
200
+ }
201
+
202
+ if (this._documentClickListener && this._documentClickListener.unsubscribe) {
203
+ this._documentClickListener.unsubscribe();
204
+ } else if (this._documentClickHandler) {
205
+ document.removeEventListener('click', this._documentClickHandler);
206
+ }
207
+
208
+ if (this._resizeListener && this._resizeListener.unsubscribe) {
209
+ this._resizeListener.unsubscribe();
210
+ } else if (this._resizeHandler) {
211
+ window.removeEventListener('resize', this._resizeHandler);
212
+ }
213
+
214
+ if (this.calendarEl) {
215
+ const daysEl = this.calendarEl.querySelector('.ds-datepicker__days');
216
+ if (daysEl) {
217
+ daysEl.querySelectorAll('.ds-datepicker__day').forEach(dayEl => {
218
+ if (dayEl._dayClickHandler) {
219
+ dayEl.removeEventListener('click', dayEl._dayClickHandler);
220
+ }
221
+ });
222
+ }
223
+ const prevBtn = this.calendarEl.querySelector('.ds-datepicker__nav--prev');
224
+ const nextBtn = this.calendarEl.querySelector('.ds-datepicker__nav--next');
225
+ if (prevBtn && prevBtn._prevClickHandler) {
226
+ prevBtn.removeEventListener('click', prevBtn._prevClickHandler);
227
+ }
228
+ if (nextBtn && nextBtn._nextClickHandler) {
229
+ nextBtn.removeEventListener('click', nextBtn._nextClickHandler);
230
+ }
231
+ }
232
+
233
+ this._documentClickHandler = null;
234
+ this._resizeHandler = null;
235
+ this._documentClickListener = null;
236
+ this._resizeListener = null;
237
+ this._iconClickHandler = null;
238
+ this._inputClickHandler = null;
239
+ this.element.__kupolaInitialized = false;
240
+ }
241
+ }
242
+
243
+ function initDatepicker(element) {
244
+ const picker = new Datepicker(element);
245
+ picker.init();
246
+ element._kupolaDatepicker = picker;
247
+ }
248
+
249
+ function initDatepickers(root = document) {
250
+ root.querySelectorAll('.ds-datepicker').forEach(picker => {
251
+ initDatepicker(picker);
252
+ });
253
+ }
254
+
255
+ function cleanupDatepicker(picker) {
256
+ if (picker._kupolaDatepicker) {
257
+ picker._kupolaDatepicker.destroy();
258
+ picker._kupolaDatepicker = null;
259
+ }
260
+ }
261
+
262
+ function cleanupAllDatepickers() {
263
+ document.querySelectorAll('.ds-datepicker').forEach(picker => {
264
+ cleanupDatepicker(picker);
265
+ });
266
+ }
267
+
268
+ if (window.kupolaInitializer) {
269
+ window.kupolaInitializer.register('datepicker', initDatepicker, cleanupDatepicker);
270
+ }
package/js/dialog.js ADDED
@@ -0,0 +1,131 @@
1
+ class Dialog {
2
+ static normal(options = {}) {
3
+ return this._create({ type: 'normal', ...options });
4
+ }
5
+
6
+ static success(options = {}) {
7
+ return this._create({ type: 'success', ...options });
8
+ }
9
+
10
+ static warning(options = {}) {
11
+ return this._create({ type: 'warning', ...options });
12
+ }
13
+
14
+ static error(options = {}) {
15
+ return this._create({ type: 'error', ...options });
16
+ }
17
+
18
+ static info(options = {}) {
19
+ return this._create({ type: 'info', ...options });
20
+ }
21
+
22
+ static confirm(options = {}) {
23
+ return this._create({ type: 'confirm', ...options });
24
+ }
25
+
26
+ static _create(options) {
27
+ const {
28
+ type = 'normal',
29
+ title = '',
30
+ content = '',
31
+ onConfirm,
32
+ onCancel
33
+ } = options;
34
+
35
+ const icons = {
36
+ normal: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`,
37
+ success: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>`,
38
+ warning: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>`,
39
+ error: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>`,
40
+ info: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`,
41
+ confirm: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 9v4M12 17h.01"/><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/></svg>`
42
+ };
43
+
44
+ const container = document.createElement('div');
45
+ container.className = 'ds-modal-container';
46
+ container.innerHTML = `
47
+ <div class="ds-modal-mask">
48
+ <div class="ds-modal" style="max-width: 360px">
49
+ <div class="ds-modal__body" style="text-align: center; padding: 24px 16px;">
50
+ <div class="ds-dialog__icon ds-dialog__icon--${type}">${icons[type]}</div>
51
+ ${title ? '<div class="ds-dialog__title"></div>' : ''}
52
+ <div class="ds-dialog__content"></div>
53
+ <div class="ds-dialog__actions">
54
+ ${type === 'confirm' || onCancel ? `<button class="ds-btn ds-btn--ghost" data-dialog-cancel>Cancel</button>` : ''}
55
+ <button class="ds-btn ${type === 'confirm' ? 'ds-btn--brand' : 'ds-btn--ghost'}" data-dialog-confirm>
56
+ ${type === 'confirm' ? 'Confirm' : 'OK'}
57
+ </button>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ `;
63
+
64
+ document.body.appendChild(container);
65
+
66
+ if (title) container.querySelector('.ds-dialog__title').textContent = title;
67
+ container.querySelector('.ds-dialog__content').textContent = content;
68
+
69
+ const mask = container.querySelector('.ds-modal-mask');
70
+ const confirmBtn = container.querySelector('[data-dialog-confirm]');
71
+ const cancelBtn = container.querySelector('[data-dialog-cancel]');
72
+
73
+ const keydownHandler = function(e) {
74
+ if (e.key === 'Escape') {
75
+ if (onCancel) onCancel();
76
+ close();
77
+ }
78
+ };
79
+
80
+ const maskClickHandler = function(e) {
81
+ if (e.target === mask) {
82
+ if (onCancel) onCancel();
83
+ close();
84
+ }
85
+ };
86
+
87
+ const confirmClickHandler = function() {
88
+ if (onConfirm) onConfirm();
89
+ close();
90
+ };
91
+
92
+ const cancelClickHandler = function() {
93
+ if (onCancel) onCancel();
94
+ close();
95
+ };
96
+
97
+ const close = () => {
98
+ mask.classList.remove('is-visible');
99
+ document.body.style.overflow = '';
100
+ document.removeEventListener('keydown', keydownHandler);
101
+ mask.removeEventListener('click', maskClickHandler);
102
+ if (confirmBtn) {
103
+ confirmBtn.removeEventListener('click', confirmClickHandler);
104
+ }
105
+ if (cancelBtn) {
106
+ cancelBtn.removeEventListener('click', cancelClickHandler);
107
+ }
108
+ setTimeout(() => container.remove(), 300);
109
+ };
110
+
111
+ mask.classList.add('is-visible');
112
+ document.body.style.overflow = 'hidden';
113
+
114
+ if (confirmBtn) {
115
+ confirmBtn.addEventListener('click', confirmClickHandler);
116
+ }
117
+
118
+ if (cancelBtn) {
119
+ cancelBtn.addEventListener('click', cancelClickHandler);
120
+ }
121
+
122
+ mask.addEventListener('click', maskClickHandler);
123
+ document.addEventListener('keydown', keydownHandler);
124
+
125
+ return { close };
126
+ }
127
+ }
128
+
129
+ if (typeof module !== 'undefined' && module.exports) {
130
+ module.exports = Dialog;
131
+ }
package/js/drawer.js ADDED
@@ -0,0 +1,118 @@
1
+ class Drawer {
2
+ constructor(element) {
3
+ this.element = element;
4
+ this.mask = element.querySelector('.ds-drawer-mask');
5
+ this.drawerEl = element.querySelector('.ds-drawer');
6
+ this._bindEvents();
7
+ }
8
+
9
+ _bindEvents() {
10
+ const closeBtn = this.mask?.querySelector('.ds-drawer__close');
11
+ const cancelBtn = this.mask?.querySelector('.ds-drawer__footer .ds-btn--ghost');
12
+ const confirmBtn = this.mask?.querySelector('.ds-drawer__footer .ds-btn--brand');
13
+
14
+ this.closeDrawer = () => {
15
+ if (this.mask) {
16
+ this.mask.classList.remove('is-visible');
17
+ }
18
+ if (this.drawerEl) {
19
+ this.drawerEl.classList.remove('is-visible');
20
+ }
21
+ };
22
+
23
+ this.handleMaskClick = (e) => {
24
+ if (e.target === this.mask) {
25
+ this.closeDrawer();
26
+ }
27
+ };
28
+
29
+ if (this.mask) {
30
+ this.mask.addEventListener('click', this.handleMaskClick);
31
+ }
32
+
33
+ if (closeBtn) {
34
+ closeBtn.addEventListener('click', this.closeDrawer);
35
+ }
36
+
37
+ if (cancelBtn) {
38
+ cancelBtn.addEventListener('click', this.closeDrawer);
39
+ }
40
+
41
+ if (confirmBtn) {
42
+ confirmBtn.addEventListener('click', this.closeDrawer);
43
+ }
44
+
45
+ this._listeners = [
46
+ { el: this.mask, event: 'click', handler: this.handleMaskClick },
47
+ { el: closeBtn, event: 'click', handler: this.closeDrawer },
48
+ { el: cancelBtn, event: 'click', handler: this.closeDrawer },
49
+ { el: confirmBtn, event: 'click', handler: this.closeDrawer }
50
+ ].filter(item => item.el);
51
+ }
52
+
53
+ destroy() {
54
+ this._listeners?.forEach(({ el, event, handler }) => {
55
+ el.removeEventListener(event, handler);
56
+ });
57
+ this._listeners = null;
58
+ this.mask = null;
59
+ this.drawerEl = null;
60
+ this.element = null;
61
+ }
62
+
63
+ open() {
64
+ if (this.mask) {
65
+ this.mask.classList.add('is-visible');
66
+ }
67
+ if (this.drawerEl) {
68
+ this.drawerEl.classList.add('is-visible');
69
+ }
70
+ }
71
+
72
+ close() {
73
+ this.closeDrawer();
74
+ }
75
+ }
76
+
77
+ function initDrawer(element) {
78
+ if (element.__kupolaInitialized) return;
79
+
80
+ const drawer = new Drawer(element);
81
+ element.__kupolaInstance = drawer;
82
+ element.__kupolaInitialized = true;
83
+ }
84
+
85
+ function cleanupDrawer(element) {
86
+ if (!element.__kupolaInitialized || !element.__kupolaInstance) return;
87
+
88
+ const drawer = element.__kupolaInstance;
89
+ drawer.destroy();
90
+
91
+ element.__kupolaInstance = null;
92
+ element.__kupolaInitialized = false;
93
+ }
94
+
95
+ function initDrawers() {
96
+ document.querySelectorAll('[data-drawer]').forEach(trigger => {
97
+ trigger.addEventListener('click', () => {
98
+ const drawerId = trigger.getAttribute('data-drawer');
99
+ const drawer = document.getElementById(drawerId);
100
+
101
+ if (!drawer) return;
102
+
103
+ initDrawer(drawer);
104
+ drawer.__kupolaInstance?.open();
105
+ });
106
+ });
107
+
108
+ document.querySelectorAll('.ds-drawer-mask').forEach(mask => {
109
+ const drawerEl = mask.parentElement;
110
+ if (drawerEl) {
111
+ initDrawer(drawerEl);
112
+ }
113
+ });
114
+ }
115
+
116
+ if (window.kupolaInitializer) {
117
+ window.kupolaInitializer.register('drawer', initDrawer, cleanupDrawer);
118
+ }
package/js/dropdown.js ADDED
@@ -0,0 +1,122 @@
1
+ class Dropdown {
2
+ constructor(element) {
3
+ this.element = element;
4
+ this.trigger = element.querySelector('.ds-dropdown__trigger');
5
+ this.menu = element.querySelector('.ds-dropdown__menu');
6
+ this.triggerText = this.trigger ? this.trigger.querySelector('span') : null;
7
+ this.scope = `dropdown-${Math.random().toString(36).substr(2, 9)}`;
8
+
9
+ this._triggerClickHandler = null;
10
+ this._documentClickHandler = null;
11
+ this._documentClickListener = null;
12
+ this._itemClickHandler = null;
13
+ }
14
+
15
+ init() {
16
+ if (!this.trigger || !this.menu) return;
17
+ if (this.element.__kupolaInitialized) return;
18
+
19
+ this._itemClickHandler = (e) => {
20
+ const item = e.currentTarget;
21
+ if (this.triggerText) {
22
+ this.triggerText.textContent = item.textContent.trim();
23
+ }
24
+ this.hideMenu();
25
+ };
26
+
27
+ this.menu.querySelectorAll('.ds-dropdown__item').forEach(item => {
28
+ item.addEventListener('click', this._itemClickHandler);
29
+ item._dropdownItemClickHandler = this._itemClickHandler;
30
+ });
31
+
32
+ this._triggerClickHandler = (e) => {
33
+ e.stopPropagation();
34
+ this.toggleMenu();
35
+ };
36
+
37
+ this.trigger.addEventListener('click', this._triggerClickHandler);
38
+
39
+ this._documentClickHandler = (e) => {
40
+ if (!this.element.contains(e.target)) {
41
+ this.hideMenu();
42
+ }
43
+ };
44
+
45
+ if (window.globalEvents) {
46
+ this._documentClickListener = window.globalEvents.on(document, 'click', this._documentClickHandler, { scope: this.scope });
47
+ } else {
48
+ document.addEventListener('click', this._documentClickHandler);
49
+ }
50
+
51
+ this.menu.style.display = 'none';
52
+ this.element.__kupolaInitialized = true;
53
+ }
54
+
55
+ toggleMenu() {
56
+ const isOpen = this.menu.style.display === 'block';
57
+ this.menu.style.display = isOpen ? 'none' : 'block';
58
+ this.element.classList.toggle('is-open', !isOpen);
59
+ }
60
+
61
+ hideMenu() {
62
+ this.menu.style.display = 'none';
63
+ this.element.classList.remove('is-open');
64
+ }
65
+
66
+ destroy() {
67
+ if (!this.element.__kupolaInitialized) return;
68
+
69
+ if (this.trigger && this._triggerClickHandler) {
70
+ this.trigger.removeEventListener('click', this._triggerClickHandler);
71
+ }
72
+
73
+ if (this.menu) {
74
+ this.menu.querySelectorAll('.ds-dropdown__item').forEach(item => {
75
+ if (item._dropdownItemClickHandler) {
76
+ item.removeEventListener('click', item._dropdownItemClickHandler);
77
+ }
78
+ });
79
+ }
80
+
81
+ if (this._documentClickListener && this._documentClickListener.unsubscribe) {
82
+ this._documentClickListener.unsubscribe();
83
+ } else if (this._documentClickHandler) {
84
+ document.removeEventListener('click', this._documentClickHandler);
85
+ }
86
+
87
+ this._documentClickHandler = null;
88
+ this._documentClickListener = null;
89
+ this._triggerClickHandler = null;
90
+ this._itemClickHandler = null;
91
+ this.element.__kupolaInitialized = false;
92
+ }
93
+ }
94
+
95
+ function initDropdown(element) {
96
+ const dropdown = new Dropdown(element);
97
+ dropdown.init();
98
+ element._kupolaDropdown = dropdown;
99
+ }
100
+
101
+ function initDropdowns(root = document) {
102
+ root.querySelectorAll('.ds-dropdown').forEach(dropdown => {
103
+ initDropdown(dropdown);
104
+ });
105
+ }
106
+
107
+ function cleanupDropdown(dropdown) {
108
+ if (dropdown._kupolaDropdown) {
109
+ dropdown._kupolaDropdown.destroy();
110
+ dropdown._kupolaDropdown = null;
111
+ }
112
+ }
113
+
114
+ function cleanupAllDropdowns() {
115
+ document.querySelectorAll('.ds-dropdown').forEach(dropdown => {
116
+ cleanupDropdown(dropdown);
117
+ });
118
+ }
119
+
120
+ if (window.kupolaInitializer) {
121
+ window.kupolaInitializer.register('dropdown', initDropdown, cleanupDropdown);
122
+ }