chuijs 3.6.3 → 3.6.4

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 (119) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1203 -162
  3. package/framework/appLayout/default/chui_app_layout.js +747 -747
  4. package/framework/appLayout/default/global_style.css +592 -570
  5. package/framework/appLayout/default/main_theme_style.css +118 -101
  6. package/framework/components/chui_accordion/accordion.js +63 -63
  7. package/framework/components/chui_accordion/styles.css +79 -75
  8. package/framework/components/chui_badge/badge.js +55 -55
  9. package/framework/components/chui_badge/styles.css +29 -29
  10. package/framework/components/chui_button/button.js +48 -48
  11. package/framework/components/chui_button/styles.css +75 -70
  12. package/framework/components/chui_calendar/calendar.js +97 -97
  13. package/framework/components/chui_card/card.js +87 -0
  14. package/framework/components/chui_card/styles.css +72 -0
  15. package/framework/components/chui_code/code.js +18 -18
  16. package/framework/components/chui_code/styles.css +9 -9
  17. package/framework/components/chui_console/console.js +27 -27
  18. package/framework/components/chui_console/styles.css +31 -31
  19. package/framework/components/chui_content_block/content_block.js +51 -51
  20. package/framework/components/chui_content_block/styles.css +2 -2
  21. package/framework/components/chui_context_menu/context_menu.js +230 -0
  22. package/framework/components/chui_context_menu/styles.css +136 -0
  23. package/framework/components/chui_custom_element/custom_element.js +24 -24
  24. package/framework/components/chui_details/details.js +85 -85
  25. package/framework/components/chui_details/styles.css +70 -66
  26. package/framework/components/chui_fieldset/fieldset.js +40 -40
  27. package/framework/components/chui_fieldset/styles.css +24 -24
  28. package/framework/components/chui_form/form.js +40 -40
  29. package/framework/components/chui_form/styles.css +21 -21
  30. package/framework/components/chui_graphs/graphs.js +234 -190
  31. package/framework/components/chui_graphs/styles.css +37 -32
  32. package/framework/components/chui_hero/hero.js +98 -0
  33. package/framework/components/chui_hero/styles.css +91 -0
  34. package/framework/components/chui_html_block/html_block.js +16 -16
  35. package/framework/components/chui_html_block/styles.css +5 -5
  36. package/framework/components/chui_hx/hx.js +15 -15
  37. package/framework/components/chui_hx/styles.css +38 -38
  38. package/framework/components/chui_icons/icons.js +2144 -2144
  39. package/framework/components/chui_icons/styles.css +13 -13
  40. package/framework/components/chui_inputs/chui_check_box/check_box.js +32 -32
  41. package/framework/components/chui_inputs/chui_check_box/styles.css +91 -86
  42. package/framework/components/chui_inputs/chui_combo_box/combo_box.js +166 -150
  43. package/framework/components/chui_inputs/chui_combo_box/styles.css +113 -107
  44. package/framework/components/chui_inputs/chui_date/date.js +177 -174
  45. package/framework/components/chui_inputs/chui_date/styles.css +163 -128
  46. package/framework/components/chui_inputs/chui_email/email.js +61 -61
  47. package/framework/components/chui_inputs/chui_email/styles.css +69 -71
  48. package/framework/components/chui_inputs/chui_file/file.js +76 -76
  49. package/framework/components/chui_inputs/chui_file/styles.css +99 -99
  50. package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +295 -295
  51. package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +212 -235
  52. package/framework/components/chui_inputs/chui_number/number.js +108 -108
  53. package/framework/components/chui_inputs/chui_number/styles.css +84 -84
  54. package/framework/components/chui_inputs/chui_password/password.js +99 -99
  55. package/framework/components/chui_inputs/chui_password/styles.css +97 -97
  56. package/framework/components/chui_inputs/chui_radio_button/radio_button.js +45 -45
  57. package/framework/components/chui_inputs/chui_radio_button/styles.css +76 -73
  58. package/framework/components/chui_inputs/chui_select_box/select_box.js +187 -170
  59. package/framework/components/chui_inputs/chui_select_box/styles.css +123 -117
  60. package/framework/components/chui_inputs/chui_text/styles.css +83 -84
  61. package/framework/components/chui_inputs/chui_text/text.js +91 -91
  62. package/framework/components/chui_inputs/chui_text_area/styles.css +57 -57
  63. package/framework/components/chui_inputs/chui_text_area/text_area.js +61 -61
  64. package/framework/components/chui_inputs/chui_toggle/styles.css +66 -61
  65. package/framework/components/chui_inputs/chui_toggle/toggle.js +36 -36
  66. package/framework/components/chui_label/label.js +54 -54
  67. package/framework/components/chui_label/styles.css +11 -11
  68. package/framework/components/chui_media/audio.js +908 -908
  69. package/framework/components/chui_media/audio_styles.css +458 -458
  70. package/framework/components/chui_media/image.js +105 -105
  71. package/framework/components/chui_media/image_styles.css +61 -61
  72. package/framework/components/chui_media/video.js +248 -248
  73. package/framework/components/chui_media/video_styles.css +160 -160
  74. package/framework/components/chui_menu_bar/menu_bar.js +66 -74
  75. package/framework/components/chui_menu_bar/styles.css +114 -76
  76. package/framework/components/chui_modal/modal.js +142 -135
  77. package/framework/components/chui_modal/styles.css +36 -36
  78. package/framework/components/chui_notification/notification.js +72 -72
  79. package/framework/components/chui_notification/notification_download.js +78 -78
  80. package/framework/components/chui_notification/notification_download_progress.css +119 -123
  81. package/framework/components/chui_notification/notification_download_progress.js +105 -105
  82. package/framework/components/chui_notification/notification_update.js +54 -54
  83. package/framework/components/chui_notification/styles.css +91 -91
  84. package/framework/components/chui_notification/styles_download.css +85 -85
  85. package/framework/components/chui_notification/styles_update.css +73 -73
  86. package/framework/components/chui_paragraph/paragraph.js +14 -14
  87. package/framework/components/chui_paragraph/styles.css +6 -6
  88. package/framework/components/chui_popups/popups.js +250 -250
  89. package/framework/components/chui_popups/styles.css +129 -115
  90. package/framework/components/chui_progress_bar/progress_bar.js +28 -28
  91. package/framework/components/chui_progress_bar/styles.css +28 -28
  92. package/framework/components/chui_radio_group/radio_group.js +57 -57
  93. package/framework/components/chui_radio_group/styles.css +3 -3
  94. package/framework/components/chui_slideshow/slideshow.js +75 -75
  95. package/framework/components/chui_slideshow/styles.css +94 -85
  96. package/framework/components/chui_spinner/spinner.js +45 -45
  97. package/framework/components/chui_spinner/styles.css +23 -23
  98. package/framework/components/chui_table/styles.css +42 -42
  99. package/framework/components/chui_table/table.js +234 -234
  100. package/framework/components/chui_tabs/chui_tabs.js +77 -77
  101. package/framework/components/chui_tabs/styles.css +54 -48
  102. package/framework/components/chui_text_editor/styles.css +217 -217
  103. package/framework/components/chui_text_editor/text_editor.js +144 -144
  104. package/framework/components/chui_text_editor/text_editor_panel.js +568 -568
  105. package/framework/components/chui_tree_view/styles.css +81 -75
  106. package/framework/components/chui_tree_view/tree_view.js +90 -90
  107. package/framework/components/chui_webview/styles.css +27 -27
  108. package/framework/components/chui_webview/webview.js +103 -103
  109. package/framework/components/telegram_bot/chui_telegram_bot.js +183 -183
  110. package/framework/modules/chui_animations/animations.js +121 -121
  111. package/framework/modules/chui_animations/styles.css +79 -79
  112. package/framework/modules/chui_fonts.js +7128 -7128
  113. package/framework/modules/chui_functions.js +106 -78
  114. package/framework/modules/chui_logger/chui_logger.js +53 -53
  115. package/framework/modules/chui_page/page.js +86 -86
  116. package/framework/modules/chui_page/styles.css +9 -9
  117. package/framework/tray_bar/chui_menu_items.js +48 -48
  118. package/index.js +570 -555
  119. package/package.json +51 -46
@@ -1,136 +1,143 @@
1
- const {Animation} = require('../../modules/chui_animations/animations');
2
-
3
- class Dialog {
4
- #id = require("randomstring").generate();
5
- #dialog = document.createElement(`chui_dialog`);
6
- #header = document.createElement('dialog_header');
7
- #body = document.createElement('dialog_body');
8
- #footer = document.createElement('dialog_footer');
9
- //
10
- #width = undefined;
11
- #height = undefined;
12
- isOpen = false;
13
-
14
- constructor(options = {
15
- width: String(),
16
- height: String(),
17
- closeOutSideClick: false
18
- }) {
19
-
20
- require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_Dialogs');
21
- this.#dialog.id = this.#id
22
-
23
- if (options.width === undefined) {
24
- this.#width = "max-content";
25
- this.#dialog.style.width = "max-content";
26
- } else {
27
- this.#width = options.width
28
- this.#dialog.style.width = options.width;
29
- }
30
- if (options.height === undefined) {
31
- this.#height = "max-content";
32
- this.#dialog.style.height = "max-content";
33
- } else {
34
- this.#height = options.height
35
- this.#dialog.style.height = options.height;
36
- }
37
-
38
- if (options.closeOutSideClick) {
39
- this.#dialog.addEventListener("animationend", (evt) => {
40
- if (evt.animationName === "fade-in") window.addEventListener('click', this.#closeOutsideEvent)
41
- })
42
- }
43
- //ADDS
44
- this.#dialog.appendChild(this.#body)
45
- }
46
-
47
- #closeOutsideEvent = (event) => {
48
- const dialog = document.getElementById(this.#id);
49
- if (!dialog.contains(event.target)) {
50
- window.removeEventListener("click", this.#closeOutsideEvent)
51
- this.close()
52
- }
53
- }
54
-
55
- addToHeader(...components) {
56
- this.#dialog.insertBefore(this.#header, this.#body)
57
- for (let component of components) this.#header.appendChild(component.set());
58
- }
59
-
60
- addToBody(...components) {
61
- for (let component of components) this.#body.appendChild(component.set());
62
- }
63
-
64
- addToFooter(...components) {
65
- this.#dialog.appendChild(this.#footer)
66
- for (let component of components) this.#footer.appendChild(component.set());
67
- }
68
-
69
- removeFromHeader(...components) {
70
- for (let component of components) new Animation(component.set()).fadeOutAndRemove();
71
- }
72
-
73
- removeFromBody(...components) {
74
- for (let component of components) new Animation(component.set()).fadeOutAndRemove();
75
- }
76
-
77
- removeFromFooter(...components) {
78
- for (let component of components) new Animation(component.set()).fadeOutAndRemove();
79
- }
80
-
81
- open() {
82
- this.isOpen = true
83
- const dialog = document.getElementById(this.#id);
84
- // if (this.#width === "-webkit-fill-available" && this.#height === "-webkit-fill-available") {
85
- // dialog.style.top = "0"
86
- // dialog.style.left = "0"
87
- // new Animation(dialog).fadeIn();
88
- // } else {
89
- // window.addEventListener("resize", (event) => this.#setCenter(dialog, event.currentTarget))
90
- // new Animation(dialog).fadeIn();
91
- // this.#setCenter(dialog, window)
92
- // }
93
-
94
- window.addEventListener("resize", (event) => this.#setCenter(dialog, event.currentTarget))
95
- new Animation(dialog).fadeIn();
96
- this.#setCenter(dialog, window)
97
- }
98
-
99
- openAndClose() {
100
- if (!this.isOpen) {
101
- this.open()
102
- } else {
103
- this.close()
104
- }
105
- }
106
-
107
- close() {
108
- window.removeEventListener("click", this.#closeOutsideEvent)
109
- this.isOpen = false
110
- const dialog = document.getElementById(this.#id);
111
- new Animation(dialog).fadeOut();
112
- }
113
-
114
- set() {
115
- return this.#dialog;
116
- }
117
-
118
- #setCenter(element, window) {
119
- // Ширина
120
- const width = parseInt(window.getComputedStyle(element).width) + "px"
121
- if (element.style.width === "-webkit-fill-available") {
122
- element.style.left = "0"
123
- } else {
124
- element.style.left = `calc(100% / 2 - ${width} / 2)`;
125
- }
126
- // Высота
127
- const height = parseInt(window.getComputedStyle(element).height) + "px"
128
- if (element.style.height === "-webkit-fill-available") {
129
- element.style.top = "0"
130
- } else {
131
- element.style.top = `calc(100% / 2 - ${height} / 2)`;
132
- }
133
- }
134
- }
135
-
1
+ const {Animation} = require('../../modules/chui_animations/animations');
2
+
3
+ class Dialog {
4
+ #id = require("randomstring").generate();
5
+ #dialog = document.createElement(`chui_dialog`);
6
+ #header = document.createElement('dialog_header');
7
+ #body = document.createElement('dialog_body');
8
+ #footer = document.createElement('dialog_footer');
9
+ //
10
+ #width = undefined;
11
+ #height = undefined;
12
+ isOpen = false;
13
+
14
+ constructor(options = {
15
+ width: String(),
16
+ height: String(),
17
+ closeOutSideClick: false
18
+ }) {
19
+
20
+ require('../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_Dialogs');
21
+ this.#dialog.id = this.#id
22
+
23
+ if (options.width === undefined) {
24
+ this.#width = "max-content";
25
+ this.#dialog.style.width = "max-content";
26
+ } else {
27
+ this.#width = options.width
28
+ this.#dialog.style.width = options.width;
29
+ }
30
+ if (options.height === undefined) {
31
+ this.#height = "max-content";
32
+ this.#dialog.style.height = "max-content";
33
+ } else {
34
+ this.#height = options.height
35
+ this.#dialog.style.height = options.height;
36
+ }
37
+
38
+ if (options.closeOutSideClick) {
39
+ this.#dialog.addEventListener("animationend", (evt) => {
40
+ if (evt.animationName === "fade-in") window.addEventListener('click', this.#closeOutsideEvent)
41
+ })
42
+ }
43
+ //ADDS
44
+ this.#dialog.appendChild(this.#body)
45
+ }
46
+
47
+ #closeOutsideEvent = (event) => {
48
+ const dialog = document.getElementById(this.#id);
49
+ if (!dialog.contains(event.target)) {
50
+ window.removeEventListener("click", this.#closeOutsideEvent)
51
+ this.close()
52
+ }
53
+ }
54
+
55
+ #resizeEvent = () => {
56
+ const dialog = document.getElementById(this.#id);
57
+ if (dialog === null) return;
58
+ this.#setCenter(dialog, window)
59
+ }
60
+
61
+ addToHeader(...components) {
62
+ this.#dialog.insertBefore(this.#header, this.#body)
63
+ for (let component of components) this.#header.appendChild(component.set());
64
+ }
65
+
66
+ addToBody(...components) {
67
+ for (let component of components) this.#body.appendChild(component.set());
68
+ }
69
+
70
+ addToFooter(...components) {
71
+ this.#dialog.appendChild(this.#footer)
72
+ for (let component of components) this.#footer.appendChild(component.set());
73
+ }
74
+
75
+ removeFromHeader(...components) {
76
+ for (let component of components) new Animation(component.set()).fadeOutAndRemove();
77
+ }
78
+
79
+ removeFromBody(...components) {
80
+ for (let component of components) new Animation(component.set()).fadeOutAndRemove();
81
+ }
82
+
83
+ removeFromFooter(...components) {
84
+ for (let component of components) new Animation(component.set()).fadeOutAndRemove();
85
+ }
86
+
87
+ open() {
88
+ this.isOpen = true
89
+ const dialog = document.getElementById(this.#id);
90
+ // if (this.#width === "-webkit-fill-available" && this.#height === "-webkit-fill-available") {
91
+ // dialog.style.top = "0"
92
+ // dialog.style.left = "0"
93
+ // new Animation(dialog).fadeIn();
94
+ // } else {
95
+ // window.addEventListener("resize", (event) => this.#setCenter(dialog, event.currentTarget))
96
+ // new Animation(dialog).fadeIn();
97
+ // this.#setCenter(dialog, window)
98
+ // }
99
+
100
+ window.addEventListener("resize", this.#resizeEvent)
101
+ new Animation(dialog).fadeIn();
102
+ this.#setCenter(dialog, window)
103
+ }
104
+
105
+ openAndClose() {
106
+ if (!this.isOpen) {
107
+ this.open()
108
+ } else {
109
+ this.close()
110
+ }
111
+ }
112
+
113
+ close() {
114
+ window.removeEventListener("click", this.#closeOutsideEvent)
115
+ window.removeEventListener("resize", this.#resizeEvent)
116
+ this.isOpen = false
117
+ const dialog = document.getElementById(this.#id);
118
+ new Animation(dialog).fadeOut();
119
+ }
120
+
121
+ set() {
122
+ return this.#dialog;
123
+ }
124
+
125
+ #setCenter(element, window) {
126
+ // Ширина
127
+ const width = parseInt(window.getComputedStyle(element).width) + "px"
128
+ if (element.style.width === "-webkit-fill-available") {
129
+ element.style.left = "0"
130
+ } else {
131
+ element.style.left = `calc(100% / 2 - ${width} / 2)`;
132
+ }
133
+ // Высота
134
+ const height = parseInt(window.getComputedStyle(element).height) + "px"
135
+ if (element.style.height === "-webkit-fill-available") {
136
+ element.style.top = "0"
137
+ } else {
138
+ element.style.top = `calc(100% / 2 - ${height} / 2)`;
139
+ }
140
+ }
141
+ }
142
+
136
143
  exports.Dialog = Dialog
@@ -1,37 +1,37 @@
1
- chui_dialog {
2
- display: none;
3
- position: fixed;
4
- z-index: 1000;
5
- left: calc(100% / 2);
6
- top: calc(100% / 2);
7
- width: max-content;
8
- height: max-content;
9
- overflow: hidden;
10
- background-color: var(--modal_background);
11
- border: 1px solid var(--border_color);
12
- border-radius: var(--border_radius);
13
- box-shadow: var(--box_shadow_main);
14
- margin: auto;
15
- flex-direction: column;
16
- padding: var(--test_padding);
17
- color: var(--text_color);
18
- backdrop-filter: var(--global_blur);
19
- }
20
-
21
- dialog_header {
22
- display: flex;
23
- margin-bottom: var(--test_padding);
24
- }
25
-
26
- dialog_body {
27
- /*padding: 6px 0px;*/
28
- display: flex;
29
- height: -webkit-fill-available;
30
- width: -webkit-fill-available;
31
- overflow: auto;
32
- }
33
-
34
- dialog_footer {
35
- display: flex;
36
- margin-top: var(--test_padding);
1
+ chui_dialog {
2
+ display: none;
3
+ position: fixed;
4
+ z-index: 1000;
5
+ left: calc(100% / 2);
6
+ top: calc(100% / 2);
7
+ width: max-content;
8
+ height: max-content;
9
+ overflow: hidden;
10
+ background-color: var(--modal_background);
11
+ border: 1px solid var(--border_color);
12
+ border-radius: var(--radius_md);
13
+ box-shadow: var(--box_shadow_modal);
14
+ margin: auto;
15
+ flex-direction: column;
16
+ padding: var(--test_padding);
17
+ color: var(--text_color);
18
+ backdrop-filter: var(--global_blur);
19
+ }
20
+
21
+ dialog_header {
22
+ display: flex;
23
+ margin-bottom: var(--test_padding);
24
+ }
25
+
26
+ dialog_body {
27
+ /*padding: 6px 0px;*/
28
+ display: flex;
29
+ height: -webkit-fill-available;
30
+ width: -webkit-fill-available;
31
+ overflow: auto;
32
+ }
33
+
34
+ dialog_footer {
35
+ display: flex;
36
+ margin-top: var(--test_padding);
37
37
  }
@@ -1,73 +1,73 @@
1
- const {Animation} = require('../../modules/chui_animations/animations');
2
- const {setStyles, markdownToHtml, getDate} = require('../../modules/chui_functions');
3
-
4
- class Notification {
5
- #id = require("randomstring").generate();
6
- #time = 5000;
7
- #notification = document.createElement(`notification`);
8
- #notification_content = document.createElement("notification_content");
9
- #notification_header = document.createElement("notification_header");
10
- #notification_title = document.createElement("notification_title");
11
- #notification_date = document.createElement("notification_date");
12
- #notification_text = document.createElement("notification_text")
13
- constructor(options = {
14
- title: String(), markdownTitle: String(),
15
- text: String(), markdownText: String(),
16
- style: undefined, showTime: Number()
17
- }) {
18
- setStyles(__dirname + "/styles.css", 'chUiJS_Notification');
19
- if (options.showTime !== undefined) this.#time = options.showTime;
20
- this.#notification.id = this.#id;
21
- // Стили заголовка уведомления
22
- if (options.title !== undefined && options.markdownTitle !== undefined) {
23
- throw new Error("Должна быть установлена одна опция title или markdownTitle");
24
- } else {
25
- if (options.title !== undefined) this.#notification_title.innerText = options.title;
26
- if (options.markdownTitle !== undefined) this.#notification_title.innerHTML = markdownToHtml(options.markdownTitle);
27
- }
28
- // Стили текста уведомления
29
- if (options.text !== undefined && options.markdownText !== undefined) {
30
- throw new Error("Должна быть установлена одна опция text или markdownText");
31
- } else {
32
- if (options.text !== undefined) this.#notification_text.innerText = options.text;
33
- if (options.markdownText !== undefined) this.#notification_text.innerHTML = markdownToHtml(options.markdownText);
34
- }
35
- this.#notification_date.innerHTML = getDate();
36
- //
37
- if (options.style !== undefined) this.#notification.classList.add(options.style);
38
- //
39
- this.#notification_header.appendChild(this.#notification_title)
40
- this.#notification_header.appendChild(this.#notification_date)
41
- //
42
- this.#notification_content.appendChild(this.#notification_header)
43
- this.#notification_content.appendChild(this.#notification_text)
44
- this.#notification.appendChild(this.#notification_content)
45
- }
46
- show(showOnSystem = Boolean()) {
47
- document.getElementsByTagName('notification_panel')[0].appendChild(this.#notification);
48
- let notification = document.getElementById(this.#id);
49
- new Animation(notification).slideRightIn();
50
- notification.addEventListener('animationend', () => setTimeout(() => this.#removeNotification(notification), this.#time));
51
- notification.addEventListener("click", () => this.#removeNotification(notification));
52
- if (showOnSystem) require("electron").ipcRenderer.send("show_system_notification", this.#notification_title.innerText, this.#notification_text.innerText);
53
- }
54
- #removeNotification(notification) {
55
- new Animation(notification).slideRightOutAndRemove();
56
- notification.addEventListener("animationend", (e) => {
57
- notification.removeAttribute("style");
58
- notification.style.display = 'flex';
59
- notification.style.width = '-webkit-fill-available';
60
- notification.style.opacity = "0"
61
- notification.style.transform = "translateX(100%)"
62
- let box = document.getElementById("chui_notification_box");
63
- box.appendChild(notification)
64
- setTimeout(() => {
65
- notification.style.opacity = "1"
66
- notification.style.transform = "translateX(0)"
67
- }, 500)
68
- })
69
- }
70
- static STYLE = { ERROR: 'notification_error', SUCCESS: 'notification_success', WARNING: 'notification_warning' }
71
- }
72
-
1
+ const {Animation} = require('../../modules/chui_animations/animations');
2
+ const {setStyles, markdownToHtml, getDate} = require('../../modules/chui_functions');
3
+
4
+ class Notification {
5
+ #id = require("randomstring").generate();
6
+ #time = 5000;
7
+ #notification = document.createElement(`notification`);
8
+ #notification_content = document.createElement("notification_content");
9
+ #notification_header = document.createElement("notification_header");
10
+ #notification_title = document.createElement("notification_title");
11
+ #notification_date = document.createElement("notification_date");
12
+ #notification_text = document.createElement("notification_text")
13
+ constructor(options = {
14
+ title: String(), markdownTitle: String(),
15
+ text: String(), markdownText: String(),
16
+ style: undefined, showTime: Number()
17
+ }) {
18
+ setStyles(__dirname + "/styles.css", 'chUiJS_Notification');
19
+ if (options.showTime !== undefined) this.#time = options.showTime;
20
+ this.#notification.id = this.#id;
21
+ // Стили заголовка уведомления
22
+ if (options.title !== undefined && options.markdownTitle !== undefined) {
23
+ throw new Error("Должна быть установлена одна опция title или markdownTitle");
24
+ } else {
25
+ if (options.title !== undefined) this.#notification_title.innerText = options.title;
26
+ if (options.markdownTitle !== undefined) this.#notification_title.innerHTML = markdownToHtml(options.markdownTitle);
27
+ }
28
+ // Стили текста уведомления
29
+ if (options.text !== undefined && options.markdownText !== undefined) {
30
+ throw new Error("Должна быть установлена одна опция text или markdownText");
31
+ } else {
32
+ if (options.text !== undefined) this.#notification_text.innerText = options.text;
33
+ if (options.markdownText !== undefined) this.#notification_text.innerHTML = markdownToHtml(options.markdownText);
34
+ }
35
+ this.#notification_date.innerHTML = getDate();
36
+ //
37
+ if (options.style !== undefined) this.#notification.classList.add(options.style);
38
+ //
39
+ this.#notification_header.appendChild(this.#notification_title)
40
+ this.#notification_header.appendChild(this.#notification_date)
41
+ //
42
+ this.#notification_content.appendChild(this.#notification_header)
43
+ this.#notification_content.appendChild(this.#notification_text)
44
+ this.#notification.appendChild(this.#notification_content)
45
+ }
46
+ show(showOnSystem = Boolean()) {
47
+ document.getElementsByTagName('notification_panel')[0].appendChild(this.#notification);
48
+ let notification = document.getElementById(this.#id);
49
+ new Animation(notification).slideRightIn();
50
+ notification.addEventListener('animationend', () => setTimeout(() => this.#removeNotification(notification), this.#time));
51
+ notification.addEventListener("click", () => this.#removeNotification(notification));
52
+ if (showOnSystem) require("electron").ipcRenderer.send("show_system_notification", this.#notification_title.innerText, this.#notification_text.innerText);
53
+ }
54
+ #removeNotification(notification) {
55
+ new Animation(notification).slideRightOutAndRemove();
56
+ notification.addEventListener("animationend", (e) => {
57
+ notification.removeAttribute("style");
58
+ notification.style.display = 'flex';
59
+ notification.style.width = '-webkit-fill-available';
60
+ notification.style.opacity = "0"
61
+ notification.style.transform = "translateX(100%)"
62
+ let box = document.getElementById("chui_notification_box");
63
+ box.appendChild(notification)
64
+ setTimeout(() => {
65
+ notification.style.opacity = "1"
66
+ notification.style.transform = "translateX(0)"
67
+ }, 500)
68
+ })
69
+ }
70
+ static STYLE = { ERROR: 'notification_error', SUCCESS: 'notification_success', WARNING: 'notification_warning' }
71
+ }
72
+
73
73
  exports.Notification = Notification