chuijs 3.6.3 → 3.6.5

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.

Potentially problematic release.


This version of chuijs might be problematic. Click here for more details.

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 +615 -570
  5. package/framework/appLayout/default/main_theme_style.css +124 -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 +300 -295
  51. package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +227 -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 +100 -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,296 +1,301 @@
1
- const { Animation } = require('../../../modules/chui_animations/animations');
2
- const { Icon, Icons } = require('../../chui_icons/icons');
3
- const {CheckBox} = require("../chui_check_box/check_box");
4
-
5
- class MultiComboBox {
6
- #id = require("randomstring").generate();
7
- #id_cb = require("randomstring").generate();
8
- #MultiComboBox_main = document.createElement('chui_multicombobox');
9
- #MultiComboBox_second = document.createElement('multicombobox');
10
- #MultiComboBox_options = document.createElement('multicombobox_options');
11
- #label = document.createElement('label');
12
- #input = document.createElement('input');
13
- #button_open = document.createElement('multicombo_button_open');
14
- #button_open_disabled = document.createElement('multicombo_button_open');
15
- #dropdown = document.createElement('multicombobox_dropdown');
16
- #value = []
17
- constructor(options = {
18
- name: String(),
19
- title: String(),
20
- placeholder: String(),
21
- width: String(),
22
- required: Boolean(),
23
- optionsLen: String(),
24
- }) {
25
- require('../../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_MultiComboBox');
26
- if (options.placeholder !== undefined) this.#input.placeholder = options.placeholder;
27
- if (options.width !== undefined) this.#MultiComboBox_main.style.width = options.width;
28
- if (options.title !== undefined) {
29
- this.#label.classList.add('multicombobox_label')
30
- this.#label.innerText = options.title;
31
- this.#label.setAttribute('for', this.#id_cb);
32
- this.#MultiComboBox_main.appendChild(this.#label);
33
- }
34
- if (options.optionsLen !== undefined) {
35
- this.#dropdown.style.height = (33 * options.optionsLen) + "px";
36
- } else {
37
- this.#dropdown.style.height = "max-content";
38
- }
39
- if (options.name !== undefined) this.#input.name = options.name;
40
- if (options.required !== undefined) this.#input.required = options.required;
41
- this.#input.setAttribute('id', this.#id_cb);
42
- this.#input.style.boxShadow = 'none';
43
- this.#input.classList.add('multicombobox_input');
44
- this.#input.type = 'text';
45
- this.#input.addEventListener('focus', () => {
46
- this.#MultiComboBox_second.style.border = '1px solid var(--blue_prime_background)';
47
- this.#label.style.color = 'var(--blue_prime_background)';
48
- })
49
- this.#input.addEventListener('blur', () => {
50
- this.#MultiComboBox_second.removeAttribute("style");
51
- this.#label.removeAttribute("style");
52
- })
53
- this.#button_open.innerHTML = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN, undefined, "var(--blue_prime_background)").getHTML();
54
- this.#button_open_disabled.innerHTML = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN, undefined, "var(--text_color_disabled)").getHTML();
55
- this.#button_open_disabled.style.cursor = "not-allowed";
56
- this.#dropdown.setAttribute('id', this.#id);
57
- this.#MultiComboBox_second.appendChild(this.#MultiComboBox_options)
58
- this.#MultiComboBox_second.appendChild(this.#input)
59
- this.#MultiComboBox_second.appendChild(this.#button_open)
60
- this.#MultiComboBox_second.appendChild(this.#dropdown)
61
- //LISTENERS
62
- this.#input.addEventListener('focus', () => {
63
- this.#button_open.style.transform = 'rotate(180deg)'
64
- this.#MultiComboBox_second.style.border = '1px solid var(--blue_prime_background)';
65
- this.#dropdown.style.height = (33 * options.optionsLen) + "px"
66
- })
67
- this.#input.addEventListener('blur', () => {
68
- this.#button_open.style.transform = 'rotate(0deg)'
69
- this.#MultiComboBox_second.removeAttribute('style')
70
- this.#dropdown.style.height = (33 * options.optionsLen) + "px"
71
- })
72
- this.#MultiComboBox_second.addEventListener('click', (event) => {
73
- if (!this.#input.disabled) {
74
- if (event.target.parentNode === this.#MultiComboBox_second) {
75
- this.#input.focus()
76
- this.#dropdown.style.marginTop = this.#MultiComboBox_second.offsetHeight + 'px'
77
- new Animation(this.#dropdown).fadeIn();
78
- setOptionDisplay(document.getElementById(this.#id));
79
- }
80
- }
81
- });
82
- window.addEventListener('click', (event) => {
83
- if (event.target.parentNode !== this.#MultiComboBox_second) {
84
- new Animation(this.#dropdown).fadeOut();
85
- }
86
- });
87
-
88
-
89
- this.#MultiComboBox_main.appendChild(this.#MultiComboBox_second)
90
- }
91
- addValueChangeListener(listener = () => {}) {
92
- this.#MultiComboBox_main.addEventListener("chui_multi_combo_option_changed", listener)
93
- }
94
- clearDropdown() {
95
- this.#dropdown.innerHTML = "";
96
- }
97
- addOptionsWithSections(options = []) {
98
- for (let sect of options) {
99
- const section = document.createElement(`section`);
100
- const section_title = document.createElement("label")
101
- section.className = "multi_combobox_section"
102
- section_title.className = "multi_combobox_section_title"
103
- section_title.innerText = sect.title;
104
- section.appendChild(section_title)
105
-
106
- for (let opt of sect.options) {
107
- const id_name = require("randomstring").generate();
108
- const option = document.createElement(`label`);
109
- option.className = "multi_combobox_option"
110
- option.setAttribute("option_title", opt.title)
111
- const checkbox_input_check = document.createElement("input_check");
112
- checkbox_input_check.className = "checkmark"
113
- const checkbox_input_label = document.createElement("input_text");
114
- checkbox_input_label.className = "option_input_label"
115
- checkbox_input_label.innerText = opt.title;
116
- const checkbox_input = document.createElement("input");
117
- checkbox_input.className = "option_input"
118
- checkbox_input.type = "checkbox"
119
- checkbox_input.id = id_name;
120
- checkbox_input.name = id_name;
121
- //
122
- option.appendChild(checkbox_input)
123
- option.appendChild(checkbox_input_check)
124
- option.appendChild(checkbox_input_label)
125
- section.appendChild(option)
126
- //
127
- checkbox_input.addEventListener("change", (evt) => {
128
- this.#input.value = ""
129
- const test_main = document.createElement("multicombobox_option_added_main")
130
- test_main.id = id_name
131
- const test_body = document.createElement("multicombobox_option_added_body")
132
- test_body.innerText = sect.title + ": " + opt.title;
133
- const test_remove = document.createElement("multicombobox_option_added_remove")
134
- test_remove.innerHTML = new Icon(Icons.NAVIGATION.CLOSE, "10pt").getHTML()
135
- test_main.appendChild(test_body)
136
- test_main.appendChild(test_remove)
137
- //
138
- if (evt.target.checked) {
139
- this.#MultiComboBox_options.appendChild(test_main)
140
- this.#value.push({
141
- section: sect.title,
142
- option: opt
143
- })
144
- } else {
145
- for (let node of this.#MultiComboBox_options.childNodes) {
146
- if (node.id === id_name) {
147
- node.remove()
148
- this.#value.splice(this.#value.indexOf({
149
- section: sect.title,
150
- option: opt
151
- }), 1);
152
- }
153
- }
154
- }
155
- //
156
- test_remove.addEventListener("click", () => {
157
- test_main.remove()
158
- checkbox_input.checked = false
159
- this.#value.splice(this.#value.indexOf(opt), 1);
160
- })
161
- //
162
- const eventAwesome = new CustomEvent("chui_multi_combo_option_changed", {
163
- detail: {
164
- values: this.#value
165
- },
166
- });
167
- this.#MultiComboBox_main.dispatchEvent(eventAwesome)
168
- })
169
- }
170
- this.#dropdown.appendChild(section);
171
- }
172
- this.#input.addEventListener('input', (event) => {
173
- let dropdown = document.getElementById(this.#id);
174
- for (let section of dropdown.childNodes) {
175
- for (let option of section.childNodes) {
176
- let attr = option.getAttribute("option_title")
177
- if (attr) {
178
- if (!attr.toLowerCase().includes(event.target.value.toLowerCase())) {
179
- option.style.display = 'none'
180
- dropdown.style.height = 'max-content'
181
- } else {
182
- option.style.display = 'flex'
183
- dropdown.style.height = (33 * options.optionsLen) + "px"
184
- }
185
- }
186
- }
187
- }
188
- });
189
- }
190
- addOptions(...options) {
191
- for (let opt of options) {
192
- const option = document.createElement(`label`);
193
- option.className = "multi_combobox_option"
194
- option.setAttribute("option_title", opt.title)
195
- const checkbox_input_check = document.createElement("input_check");
196
- checkbox_input_check.className = "checkmark"
197
- const checkbox_input_label = document.createElement("input_text");
198
- checkbox_input_label.className = "option_input_label"
199
- checkbox_input_label.innerText = opt.title;
200
- const checkbox_input = document.createElement("input");
201
- checkbox_input.className = "option_input"
202
- checkbox_input.type = "checkbox"
203
- checkbox_input.id = opt.title;
204
- checkbox_input.name = opt.title;
205
- //
206
- option.appendChild(checkbox_input)
207
- option.appendChild(checkbox_input_check)
208
- option.appendChild(checkbox_input_label)
209
- //
210
- checkbox_input.addEventListener("change", (evt) => {
211
- this.#input.value = ""
212
- const test_main = document.createElement("multicombobox_option_added_main")
213
- test_main.id = opt.title
214
- const test_body = document.createElement("multicombobox_option_added_body")
215
- test_body.innerText = opt.title;
216
- const test_remove = document.createElement("multicombobox_option_added_remove")
217
- test_remove.innerHTML = new Icon(Icons.NAVIGATION.CLOSE, "10pt").getHTML()
218
- test_main.appendChild(test_body)
219
- test_main.appendChild(test_remove)
220
- //
221
- test_remove.addEventListener("click", () => checkbox_input_label.click())
222
- //
223
- if (evt.target.checked) {
224
- this.#MultiComboBox_options.appendChild(test_main)
225
- this.#value.push(opt)
226
- } else {
227
- for (let node of this.#MultiComboBox_options.childNodes) {
228
- if (node.id === opt.title) {
229
- node.remove()
230
- this.#value.splice(this.#value.indexOf(opt), 1);
231
- }
232
- }
233
- }
234
- const eventAwesome = new CustomEvent("chui_multi_combo_option_changed", {
235
- detail: {
236
- values: this.#value
237
- },
238
- });
239
- this.#MultiComboBox_main.dispatchEvent(eventAwesome)
240
- })
241
- this.#dropdown.appendChild(option);
242
- }
243
- this.#input.addEventListener('input', (event) => {
244
- let dropdown = document.getElementById(this.#id);
245
- for (let option of dropdown.childNodes) {
246
- if (!option.getAttribute('option_title').toLowerCase().includes(event.target.value.toLowerCase())) {
247
- option.style.display = 'none'
248
- dropdown.style.height = 'max-content'
249
- } else {
250
- option.style.display = 'flex'
251
- dropdown.style.height = (33 * options.optionsLen) + "px"
252
- }
253
- }
254
- });
255
- }
256
- getName() { return this.#input.name; }
257
- getValue() { return this.#value }
258
- setDisabled(boolean = Boolean()) {
259
- this.#input.disabled = boolean
260
- if (boolean) {
261
- this.#MultiComboBox_second.classList.add("multicombobox_disabled")
262
- this.#input.className = "multicombobox_input_disabled"
263
- this.#label.className = "multicombobox_label_disabled"
264
- this.#button_open.remove();
265
- this.#MultiComboBox_second.appendChild(this.#button_open_disabled);
266
- } else {
267
- this.#MultiComboBox_second.classList.remove("multicombobox_disabled")
268
- this.#input.className = "multicombobox_input"
269
- this.#label.className = "multicombobox_label"
270
- this.#button_open_disabled.remove();
271
- this.#MultiComboBox_second.appendChild(this.#button_open);
272
- }
273
- }
274
- clear() {
275
- this.#input.value = ""
276
- this.#value = []
277
- this.#MultiComboBox_options.innerHTML = ""
278
-
279
- this.#dropdown.childNodes.forEach(child =>{
280
- if (child.tagName === "SECTION") {
281
- for (let child2 of child.childNodes) {
282
- child2.childNodes[0].checked = false
283
- }
284
- } else {
285
- child.childNodes[0].checked = false
286
- }
287
- })
288
- }
289
- set() { return this.#MultiComboBox_main; }
290
- }
291
-
292
- function setOptionDisplay(element) {
293
- for (let option of element.childNodes) { option.style.display = 'flex'; }
294
- }
295
-
1
+ const { Animation } = require('../../../modules/chui_animations/animations');
2
+ const { shouldOpenDropdownUp } = require('../../../modules/chui_functions');
3
+ const { Icon, Icons } = require('../../chui_icons/icons');
4
+ const {CheckBox} = require("../chui_check_box/check_box");
5
+
6
+ const OPTION_ROW_HEIGHT = 33;
7
+
8
+ class MultiComboBox {
9
+ #id = require("randomstring").generate();
10
+ #id_cb = require("randomstring").generate();
11
+ #MultiComboBox_main = document.createElement('chui_multicombobox');
12
+ #MultiComboBox_second = document.createElement('multicombobox');
13
+ #MultiComboBox_options = document.createElement('multicombobox_options');
14
+ #label = document.createElement('label');
15
+ #input = document.createElement('input');
16
+ #button_open = document.createElement('multicombo_button_open');
17
+ #button_open_disabled = document.createElement('multicombo_button_open');
18
+ #dropdown = document.createElement('multicombobox_dropdown');
19
+ #dropdown_height = "max-content";
20
+ #value = []
21
+ constructor(options = {
22
+ name: String(),
23
+ title: String(),
24
+ placeholder: String(),
25
+ width: String(),
26
+ required: Boolean(),
27
+ optionsLen: String(),
28
+ }) {
29
+ require('../../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_MultiComboBox');
30
+ if (options.placeholder !== undefined) this.#input.placeholder = options.placeholder;
31
+ if (options.width !== undefined) this.#MultiComboBox_main.style.width = options.width;
32
+ if (options.title !== undefined) {
33
+ this.#label.classList.add('multicombobox_label')
34
+ this.#label.innerText = options.title;
35
+ this.#label.setAttribute('for', this.#id_cb);
36
+ this.#MultiComboBox_main.appendChild(this.#label);
37
+ }
38
+ if (options.optionsLen !== undefined) {
39
+ this.#dropdown_height = (OPTION_ROW_HEIGHT * options.optionsLen) + "px";
40
+ }
41
+ this.#dropdown.style.height = this.#dropdown_height;
42
+ if (options.name !== undefined) this.#input.name = options.name;
43
+ if (options.required !== undefined) this.#input.required = options.required;
44
+ this.#input.setAttribute('id', this.#id_cb);
45
+ this.#input.style.boxShadow = 'none';
46
+ this.#input.classList.add('multicombobox_input');
47
+ this.#input.type = 'text';
48
+ this.#input.addEventListener('focus', () => {
49
+ this.#MultiComboBox_second.style.border = '1px solid var(--blue_prime_background)';
50
+ this.#label.style.color = 'var(--blue_prime_background)';
51
+ })
52
+ this.#input.addEventListener('blur', () => {
53
+ this.#MultiComboBox_second.removeAttribute("style");
54
+ this.#label.removeAttribute("style");
55
+ })
56
+ this.#button_open.innerHTML = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN, undefined, "var(--blue_prime_background)").getHTML();
57
+ this.#button_open_disabled.innerHTML = new Icon(Icons.HARDWARE.KEYBOARD_ARROW_DOWN, undefined, "var(--text_color_disabled)").getHTML();
58
+ this.#button_open_disabled.style.cursor = "not-allowed";
59
+ this.#dropdown.setAttribute('id', this.#id);
60
+ this.#MultiComboBox_second.appendChild(this.#MultiComboBox_options)
61
+ this.#MultiComboBox_options.appendChild(this.#input)
62
+ this.#MultiComboBox_second.appendChild(this.#button_open)
63
+ this.#MultiComboBox_second.appendChild(this.#dropdown)
64
+ //LISTENERS
65
+ this.#input.addEventListener('focus', () => {
66
+ this.#button_open.style.transform = 'rotate(180deg)'
67
+ this.#MultiComboBox_second.style.border = '1px solid var(--blue_prime_background)';
68
+ this.#dropdown.style.height = this.#dropdown_height
69
+ })
70
+ this.#input.addEventListener('blur', () => {
71
+ this.#button_open.style.transform = 'rotate(0deg)'
72
+ this.#MultiComboBox_second.removeAttribute('style')
73
+ this.#dropdown.style.height = this.#dropdown_height
74
+ })
75
+ this.#MultiComboBox_second.addEventListener('click', (event) => {
76
+ if (!this.#input.disabled) {
77
+ if (event.target.closest('multicombobox_dropdown') === null &&
78
+ event.target.closest('multicombobox_option_added_main') === null) {
79
+ this.#input.focus()
80
+ new Animation(this.#dropdown).fadeIn();
81
+ setOptionDisplay(document.getElementById(this.#id));
82
+ this.#setDropdownDirection();
83
+ }
84
+ }
85
+ });
86
+ window.addEventListener('click', (event) => {
87
+ if (!this.#MultiComboBox_second.contains(event.target)) {
88
+ new Animation(this.#dropdown).fadeOut();
89
+ }
90
+ });
91
+
92
+
93
+ this.#MultiComboBox_main.appendChild(this.#MultiComboBox_second)
94
+ }
95
+ addValueChangeListener(listener = () => {}) {
96
+ this.#MultiComboBox_main.addEventListener("chui_multi_combo_option_changed", listener)
97
+ }
98
+ clearDropdown() {
99
+ this.#dropdown.innerHTML = "";
100
+ }
101
+ addOptionsWithSections(options = []) {
102
+ for (let sect of options) {
103
+ const section = document.createElement(`section`);
104
+ const section_title = document.createElement("label")
105
+ section.className = "multi_combobox_section"
106
+ section_title.className = "multi_combobox_section_title"
107
+ section_title.innerText = sect.title;
108
+ section.appendChild(section_title)
109
+
110
+ for (let opt of sect.options) {
111
+ const id_name = require("randomstring").generate();
112
+ const option = document.createElement(`label`);
113
+ option.className = "multi_combobox_option"
114
+ option.setAttribute("option_title", opt.title)
115
+ const checkbox_input_check = document.createElement("input_check");
116
+ checkbox_input_check.className = "checkmark"
117
+ const checkbox_input_label = document.createElement("input_text");
118
+ checkbox_input_label.className = "option_input_label"
119
+ checkbox_input_label.innerText = opt.title;
120
+ const checkbox_input = document.createElement("input");
121
+ checkbox_input.className = "option_input"
122
+ checkbox_input.type = "checkbox"
123
+ checkbox_input.id = id_name;
124
+ checkbox_input.name = id_name;
125
+ //
126
+ option.appendChild(checkbox_input)
127
+ option.appendChild(checkbox_input_check)
128
+ option.appendChild(checkbox_input_label)
129
+ section.appendChild(option)
130
+ //
131
+ checkbox_input.addEventListener("change", (evt) => {
132
+ this.#input.value = ""
133
+ if (evt.target.checked) {
134
+ const test_main = document.createElement("multicombobox_option_added_main")
135
+ test_main.id = id_name
136
+ const test_body = document.createElement("multicombobox_option_added_body")
137
+ test_body.innerText = sect.title + ": " + opt.title;
138
+ test_body.title = sect.title + ": " + opt.title;
139
+ const test_remove = document.createElement("multicombobox_option_added_remove")
140
+ test_remove.innerHTML = new Icon(Icons.NAVIGATION.CLOSE, "10pt").getHTML()
141
+ test_remove.addEventListener("click", () => checkbox_input.click())
142
+ test_main.appendChild(test_body)
143
+ test_main.appendChild(test_remove)
144
+ this.#MultiComboBox_options.insertBefore(test_main, this.#input)
145
+ this.#value.push({
146
+ id: id_name,
147
+ section: sect.title,
148
+ option: opt
149
+ })
150
+ } else {
151
+ this.#removeOptionById(id_name)
152
+ }
153
+ //
154
+ const eventAwesome = new CustomEvent("chui_multi_combo_option_changed", {
155
+ detail: {
156
+ values: this.#value
157
+ },
158
+ });
159
+ this.#MultiComboBox_main.dispatchEvent(eventAwesome)
160
+ })
161
+ }
162
+ this.#dropdown.appendChild(section);
163
+ }
164
+ this.#input.addEventListener('input', (event) => {
165
+ let dropdown = document.getElementById(this.#id);
166
+ for (let section of dropdown.childNodes) {
167
+ for (let option of section.childNodes) {
168
+ let attr = option.getAttribute("option_title")
169
+ if (attr) {
170
+ if (!attr.toLowerCase().includes(event.target.value.toLowerCase())) {
171
+ option.style.display = 'none'
172
+ dropdown.style.height = 'max-content'
173
+ } else {
174
+ option.style.display = 'flex'
175
+ dropdown.style.height = this.#dropdown_height
176
+ }
177
+ }
178
+ }
179
+ }
180
+ });
181
+ }
182
+ addOptions(...options) {
183
+ for (let opt of options) {
184
+ const option = document.createElement(`label`);
185
+ option.className = "multi_combobox_option"
186
+ option.setAttribute("option_title", opt.title)
187
+ const checkbox_input_check = document.createElement("input_check");
188
+ checkbox_input_check.className = "checkmark"
189
+ const checkbox_input_label = document.createElement("input_text");
190
+ checkbox_input_label.className = "option_input_label"
191
+ checkbox_input_label.innerText = opt.title;
192
+ const checkbox_input = document.createElement("input");
193
+ checkbox_input.className = "option_input"
194
+ checkbox_input.type = "checkbox"
195
+ checkbox_input.id = opt.title;
196
+ checkbox_input.name = opt.title;
197
+ //
198
+ option.appendChild(checkbox_input)
199
+ option.appendChild(checkbox_input_check)
200
+ option.appendChild(checkbox_input_label)
201
+ //
202
+ checkbox_input.addEventListener("change", (evt) => {
203
+ this.#input.value = ""
204
+ const test_main = document.createElement("multicombobox_option_added_main")
205
+ test_main.id = opt.title
206
+ const test_body = document.createElement("multicombobox_option_added_body")
207
+ test_body.innerText = opt.title;
208
+ test_body.title = opt.title;
209
+ const test_remove = document.createElement("multicombobox_option_added_remove")
210
+ test_remove.innerHTML = new Icon(Icons.NAVIGATION.CLOSE, "10pt").getHTML()
211
+ test_main.appendChild(test_body)
212
+ test_main.appendChild(test_remove)
213
+ //
214
+ test_remove.addEventListener("click", () => checkbox_input.click())
215
+ //
216
+ if (evt.target.checked) {
217
+ this.#MultiComboBox_options.insertBefore(test_main, this.#input)
218
+ this.#value.push(opt)
219
+ } else {
220
+ for (let node of this.#MultiComboBox_options.childNodes) {
221
+ if (node.id === opt.title) {
222
+ node.remove()
223
+ this.#value.splice(this.#value.indexOf(opt), 1);
224
+ }
225
+ }
226
+ }
227
+ const eventAwesome = new CustomEvent("chui_multi_combo_option_changed", {
228
+ detail: {
229
+ values: this.#value
230
+ },
231
+ });
232
+ this.#MultiComboBox_main.dispatchEvent(eventAwesome)
233
+ })
234
+ this.#dropdown.appendChild(option);
235
+ }
236
+ this.#input.addEventListener('input', (event) => {
237
+ let dropdown = document.getElementById(this.#id);
238
+ let query = event.target.value.toLowerCase();
239
+ for (let option of dropdown.childNodes) {
240
+ if (typeof option.getAttribute !== "function") continue;
241
+ let title = option.getAttribute('option_title');
242
+ if (title === null) continue;
243
+ if (!title.toLowerCase().includes(query)) {
244
+ option.style.display = 'none'
245
+ dropdown.style.height = 'max-content'
246
+ } else {
247
+ option.style.display = 'flex'
248
+ dropdown.style.height = this.#dropdown_height
249
+ }
250
+ }
251
+ });
252
+ }
253
+ getName() { return this.#input.name; }
254
+ getValue() { return this.#value }
255
+ setDisabled(boolean = Boolean()) {
256
+ this.#input.disabled = boolean
257
+ if (boolean) {
258
+ this.#MultiComboBox_second.classList.add("multicombobox_disabled")
259
+ this.#input.className = "multicombobox_input_disabled"
260
+ this.#label.className = "multicombobox_label_disabled"
261
+ this.#button_open.remove();
262
+ this.#MultiComboBox_second.appendChild(this.#button_open_disabled);
263
+ } else {
264
+ this.#MultiComboBox_second.classList.remove("multicombobox_disabled")
265
+ this.#input.className = "multicombobox_input"
266
+ this.#label.className = "multicombobox_label"
267
+ this.#button_open_disabled.remove();
268
+ this.#MultiComboBox_second.appendChild(this.#button_open);
269
+ }
270
+ }
271
+ #removeOptionById(id) {
272
+ for (let node of [...this.#MultiComboBox_options.childNodes]) {
273
+ if (node.id === id) node.remove()
274
+ }
275
+ const index = this.#value.findIndex((item) => item.id === id)
276
+ if (index !== -1) this.#value.splice(index, 1)
277
+ }
278
+ clear() {
279
+ this.#input.value = ""
280
+ this.#value = []
281
+ for (let node of [...this.#MultiComboBox_options.childNodes]) {
282
+ if (node !== this.#input) node.remove()
283
+ }
284
+ for (let checkbox of this.#dropdown.querySelectorAll('input[type="checkbox"]')) {
285
+ checkbox.checked = false;
286
+ }
287
+ }
288
+ #setDropdownDirection() {
289
+ const openUp = shouldOpenDropdownUp(this.#dropdown, this.#MultiComboBox_second);
290
+ this.#dropdown.style.top = openUp ? 'auto' : '';
291
+ this.#dropdown.style.bottom = openUp ? '100%' : '';
292
+ this.#dropdown.style.marginTop = openUp ? '0' : this.#MultiComboBox_second.offsetHeight + 'px';
293
+ }
294
+ set() { return this.#MultiComboBox_main; }
295
+ }
296
+
297
+ function setOptionDisplay(element) {
298
+ for (let option of element.childNodes) { option.style.display = 'flex'; }
299
+ }
300
+
296
301
  exports.MultiComboBox = MultiComboBox