chuijs 4.0.1 → 4.0.3

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 (222) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +43 -632
  3. package/framework/appLayout/default/chui_app_layout.js +314 -273
  4. package/framework/appLayout/default/global_style.css +93 -53
  5. package/framework/components/chui_accordion/accordion.js +29 -26
  6. package/framework/components/chui_accordion/styles.css +6 -5
  7. package/framework/components/chui_action_sheet/action_sheet.js +59 -33
  8. package/framework/components/chui_action_sheet/styles.css +2 -1
  9. package/framework/components/chui_affix/affix.js +11 -6
  10. package/framework/components/chui_alert/alert.js +23 -14
  11. package/framework/components/chui_avatar/avatar.js +23 -22
  12. package/framework/components/chui_avatar_group/avatar_group.js +21 -19
  13. package/framework/components/chui_backtop/backtop.js +35 -19
  14. package/framework/components/chui_badge/badge.js +15 -13
  15. package/framework/components/chui_breadcrumb/breadcrumb.js +15 -13
  16. package/framework/components/chui_button/button.js +42 -22
  17. package/framework/components/chui_button/styles.css +2 -2
  18. package/framework/components/chui_calendar/calendar.js +12 -10
  19. package/framework/components/chui_card/card.js +43 -23
  20. package/framework/components/chui_chat/chat.js +72 -33
  21. package/framework/components/chui_clipboard_history/clipboard_history.js +30 -21
  22. package/framework/components/chui_clipboard_history/styles.css +4 -2
  23. package/framework/components/chui_code/code.js +2 -2
  24. package/framework/components/chui_code/styles.css +2 -2
  25. package/framework/components/chui_code_editor/code_editor.js +47 -31
  26. package/framework/components/chui_code_editor/styles.css +3 -2
  27. package/framework/components/chui_command_palette/command_palette.js +60 -37
  28. package/framework/components/chui_console/console.js +5 -5
  29. package/framework/components/chui_console/styles.css +1 -1
  30. package/framework/components/chui_content_block/content_block.js +33 -19
  31. package/framework/components/chui_content_block/styles.css +2 -2
  32. package/framework/components/chui_context_menu/context_menu.js +9 -4
  33. package/framework/components/chui_custom_element/custom_element.js +22 -15
  34. package/framework/components/chui_data_grid/data_grid.js +396 -234
  35. package/framework/components/chui_data_grid/styles.css +10 -8
  36. package/framework/components/chui_descriptions/descriptions.js +34 -17
  37. package/framework/components/chui_details/details.js +32 -26
  38. package/framework/components/chui_details/styles.css +5 -4
  39. package/framework/components/chui_diff_viewer/diff_viewer.js +91 -66
  40. package/framework/components/chui_diff_viewer/styles.css +1 -1
  41. package/framework/components/chui_divider/divider.js +13 -11
  42. package/framework/components/chui_drawer/drawer.js +27 -25
  43. package/framework/components/chui_drop_zone/drop_zone.js +31 -21
  44. package/framework/components/chui_empty_state/empty_state.js +20 -15
  45. package/framework/components/chui_fieldset/fieldset.js +37 -20
  46. package/framework/components/chui_fieldset/styles.css +1 -1
  47. package/framework/components/chui_file_explorer/file_explorer.js +157 -86
  48. package/framework/components/chui_file_explorer/styles.css +2 -1
  49. package/framework/components/chui_form/form.js +31 -19
  50. package/framework/components/chui_form/styles.css +1 -1
  51. package/framework/components/chui_gantt/gantt.js +64 -40
  52. package/framework/components/chui_graphs/graphs.js +301 -200
  53. package/framework/components/chui_graphs/styles.css +1 -1
  54. package/framework/components/chui_hero/hero.js +40 -22
  55. package/framework/components/chui_html_block/html_block.js +6 -6
  56. package/framework/components/chui_html_block/styles.css +2 -2
  57. package/framework/components/chui_hx/hx.js +3 -3
  58. package/framework/components/chui_hx/styles.css +11 -4
  59. package/framework/components/chui_icons/icons.js +2109 -2109
  60. package/framework/components/chui_icons/styles.css +2 -2
  61. package/framework/components/chui_inputs/chui_check_box/check_box.js +31 -19
  62. package/framework/components/chui_inputs/chui_check_box/styles.css +18 -18
  63. package/framework/components/chui_inputs/chui_chips/chips.js +50 -40
  64. package/framework/components/chui_inputs/chui_chips/styles.css +4 -2
  65. package/framework/components/chui_inputs/chui_color_picker/color_picker.js +36 -24
  66. package/framework/components/chui_inputs/chui_combo_box/combo_box.js +100 -82
  67. package/framework/components/chui_inputs/chui_combo_box/styles.css +14 -12
  68. package/framework/components/chui_inputs/chui_date/date.js +102 -66
  69. package/framework/components/chui_inputs/chui_date/styles.css +12 -11
  70. package/framework/components/chui_inputs/chui_date_range/date_range.js +40 -29
  71. package/framework/components/chui_inputs/chui_datetime/datetime.js +35 -27
  72. package/framework/components/chui_inputs/chui_email/email.js +43 -31
  73. package/framework/components/chui_inputs/chui_email/styles.css +5 -5
  74. package/framework/components/chui_inputs/chui_file/file.js +68 -41
  75. package/framework/components/chui_inputs/chui_file/styles.css +13 -12
  76. package/framework/components/chui_inputs/chui_hotkey/hotkey.js +61 -36
  77. package/framework/components/chui_inputs/chui_masked/masked.js +39 -28
  78. package/framework/components/chui_inputs/chui_mention/mention.js +77 -30
  79. package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +173 -153
  80. package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +9 -7
  81. package/framework/components/chui_inputs/chui_number/number.js +58 -41
  82. package/framework/components/chui_inputs/chui_number/styles.css +7 -7
  83. package/framework/components/chui_inputs/chui_otp/otp.js +38 -29
  84. package/framework/components/chui_inputs/chui_password/password.js +58 -36
  85. package/framework/components/chui_inputs/chui_password/styles.css +8 -8
  86. package/framework/components/chui_inputs/chui_radio_button/radio_button.js +37 -25
  87. package/framework/components/chui_inputs/chui_radio_button/styles.css +20 -20
  88. package/framework/components/chui_inputs/chui_rating/rating.js +26 -22
  89. package/framework/components/chui_inputs/chui_select_box/select_box.js +102 -78
  90. package/framework/components/chui_inputs/chui_select_box/styles.css +11 -11
  91. package/framework/components/chui_inputs/chui_slider/slider.js +29 -26
  92. package/framework/components/chui_inputs/chui_slider/styles.css +2 -1
  93. package/framework/components/chui_inputs/chui_text/styles.css +8 -8
  94. package/framework/components/chui_inputs/chui_text/text.js +65 -44
  95. package/framework/components/chui_inputs/chui_text_area/styles.css +6 -6
  96. package/framework/components/chui_inputs/chui_text_area/text_area.js +51 -28
  97. package/framework/components/chui_inputs/chui_time/styles.css +5 -3
  98. package/framework/components/chui_inputs/chui_time/time.js +38 -27
  99. package/framework/components/chui_inputs/chui_toggle/styles.css +3 -3
  100. package/framework/components/chui_inputs/chui_toggle/toggle.js +16 -16
  101. package/framework/components/chui_json_editor/json_editor.js +53 -43
  102. package/framework/components/chui_json_viewer/json_viewer.js +52 -33
  103. package/framework/components/chui_json_viewer/styles.css +3 -2
  104. package/framework/components/chui_kanban/kanban.js +52 -34
  105. package/framework/components/chui_kbd/kbd.js +12 -10
  106. package/framework/components/chui_label/label.js +14 -12
  107. package/framework/components/chui_label/styles.css +2 -2
  108. package/framework/components/chui_link/link.js +27 -20
  109. package/framework/components/chui_list/list.js +31 -27
  110. package/framework/components/chui_list/styles.css +2 -1
  111. package/framework/components/chui_markdown_editor/markdown_editor.js +60 -44
  112. package/framework/components/chui_media/audio.js +326 -227
  113. package/framework/components/chui_media/audio_styles.css +40 -21
  114. package/framework/components/chui_media/image.js +70 -38
  115. package/framework/components/chui_media/image_compare.js +52 -21
  116. package/framework/components/chui_media/image_styles.css +3 -3
  117. package/framework/components/chui_media/video.js +155 -62
  118. package/framework/components/chui_media/video_styles.css +33 -16
  119. package/framework/components/chui_menu_bar/menu_bar.js +26 -24
  120. package/framework/components/chui_menu_bar/styles.css +4 -2
  121. package/framework/components/chui_modal/modal.js +44 -43
  122. package/framework/components/chui_modal/styles.css +3 -2
  123. package/framework/components/chui_notification/notification.js +50 -34
  124. package/framework/components/chui_notification/notification_download.js +31 -25
  125. package/framework/components/chui_notification/notification_download_progress.css +3 -2
  126. package/framework/components/chui_notification/notification_download_progress.js +47 -41
  127. package/framework/components/chui_notification/notification_update.js +23 -16
  128. package/framework/components/chui_notification/status_plate.js +2 -2
  129. package/framework/components/chui_notification/styles_download.css +1 -1
  130. package/framework/components/chui_notification/styles_update.css +1 -1
  131. package/framework/components/chui_org_chart/org_chart.js +74 -35
  132. package/framework/components/chui_pagination/pagination.js +62 -27
  133. package/framework/components/chui_paragraph/paragraph.js +2 -2
  134. package/framework/components/chui_paragraph/styles.css +1 -1
  135. package/framework/components/chui_popover/popover.js +49 -28
  136. package/framework/components/chui_popups/popups.js +137 -108
  137. package/framework/components/chui_popups/styles.css +2 -2
  138. package/framework/components/chui_print_button/print_button.js +33 -23
  139. package/framework/components/chui_progress_bar/progress_bar.js +23 -15
  140. package/framework/components/chui_progress_bar/styles.css +2 -2
  141. package/framework/components/chui_progress_ring/progress_ring.js +17 -15
  142. package/framework/components/chui_qrcode/qrcode.js +75 -31
  143. package/framework/components/chui_query_builder/query_builder.js +216 -123
  144. package/framework/components/chui_radio_group/radio_group.js +36 -26
  145. package/framework/components/chui_radio_group/styles.css +1 -1
  146. package/framework/components/chui_result/result.js +26 -16
  147. package/framework/components/chui_scheduler/scheduler.js +57 -35
  148. package/framework/components/chui_scheduler/styles.css +6 -2
  149. package/framework/components/chui_segmented_control/segmented_control.js +27 -21
  150. package/framework/components/chui_settings/settings.js +122 -48
  151. package/framework/components/chui_shortcut_help/shortcut_help.js +55 -32
  152. package/framework/components/chui_sidebar_nav/sidebar_nav.js +33 -23
  153. package/framework/components/chui_skeleton/skeleton.js +29 -24
  154. package/framework/components/chui_slideshow/slideshow.js +60 -41
  155. package/framework/components/chui_slideshow/styles.css +18 -12
  156. package/framework/components/chui_spinner/spinner.js +8 -8
  157. package/framework/components/chui_spinner/styles.css +0 -1
  158. package/framework/components/chui_split_button/split_button.js +23 -18
  159. package/framework/components/chui_split_button/styles.css +1 -1
  160. package/framework/components/chui_splitter/splitter.js +35 -28
  161. package/framework/components/chui_statistic/statistic.js +65 -38
  162. package/framework/components/chui_status_bar/status_bar.js +11 -9
  163. package/framework/components/chui_stepper/stepper.js +27 -22
  164. package/framework/components/chui_sticky_bar/sticky_bar.js +9 -4
  165. package/framework/components/chui_sticky_bar/styles.css +3 -1
  166. package/framework/components/chui_tabs/chui_tabs.js +28 -22
  167. package/framework/components/chui_tabs/styles.css +3 -3
  168. package/framework/components/chui_text_editor/styles.css +20 -19
  169. package/framework/components/chui_text_editor/text_editor.js +85 -61
  170. package/framework/components/chui_text_editor/text_editor_panel.js +346 -284
  171. package/framework/components/chui_theme_toggle/theme_toggle.js +27 -22
  172. package/framework/components/chui_timeline/timeline.js +14 -12
  173. package/framework/components/chui_toast_queue/toast_queue.js +52 -46
  174. package/framework/components/chui_toolbar/toolbar.js +20 -13
  175. package/framework/components/chui_tooltip/tooltip.js +37 -24
  176. package/framework/components/chui_tour/styles.css +8 -3
  177. package/framework/components/chui_tour/tour.js +61 -27
  178. package/framework/components/chui_transfer/styles.css +2 -1
  179. package/framework/components/chui_transfer/transfer.js +75 -42
  180. package/framework/components/chui_tree_table/tree_table.js +43 -29
  181. package/framework/components/chui_tree_view/styles.css +4 -2
  182. package/framework/components/chui_tree_view/tree_view.js +142 -99
  183. package/framework/components/chui_watermark/watermark.js +24 -16
  184. package/framework/components/chui_webview/styles.css +2 -2
  185. package/framework/components/chui_webview/webview.js +62 -50
  186. package/framework/components/telegram_bot/chui_telegram_bot.js +71 -64
  187. package/framework/modules/chui_a11y/chui_a11y.js +77 -46
  188. package/framework/modules/chui_animations/animations.js +42 -42
  189. package/framework/modules/chui_animations/styles.css +1 -1
  190. package/framework/modules/chui_bridge/preload.js +56 -26
  191. package/framework/modules/chui_functions.js +52 -50
  192. package/framework/modules/chui_highlight/chui_highlight.js +25 -22
  193. package/framework/modules/chui_i18n/chui_i18n.js +9 -7
  194. package/framework/modules/chui_i18n/locales/a11y.js +5 -5
  195. package/framework/modules/chui_i18n/locales/app_layout.js +5 -5
  196. package/framework/modules/chui_i18n/locales/calendar.js +3 -3
  197. package/framework/modules/chui_i18n/locales/common.js +3 -3
  198. package/framework/modules/chui_i18n/locales/data.js +36 -26
  199. package/framework/modules/chui_i18n/locales/editors.js +40 -13
  200. package/framework/modules/chui_i18n/locales/feedback.js +3 -3
  201. package/framework/modules/chui_i18n/locales/forms.js +8 -8
  202. package/framework/modules/chui_i18n/locales/graphics.js +8 -8
  203. package/framework/modules/chui_i18n/locales/media.js +4 -4
  204. package/framework/modules/chui_i18n/locales/navigation.js +8 -8
  205. package/framework/modules/chui_i18n/locales/validate.js +3 -3
  206. package/framework/modules/chui_json/chui_json.js +9 -9
  207. package/framework/modules/chui_layout/chui_layout.js +12 -10
  208. package/framework/modules/chui_logger/chui_logger.js +29 -25
  209. package/framework/modules/chui_page/page.js +33 -27
  210. package/framework/modules/chui_page/styles.css +3 -26
  211. package/framework/modules/chui_qr/chui_qr.js +158 -67
  212. package/framework/modules/chui_scrollbar/chui_scrollbar.js +35 -24
  213. package/framework/modules/chui_scrollbar/styles.css +3 -1
  214. package/framework/modules/chui_services/chui_channels.js +76 -11
  215. package/framework/modules/chui_services/chui_services.js +39 -31
  216. package/framework/modules/chui_services/desktop.js +149 -30
  217. package/framework/modules/chui_sortable/chui_sortable.js +17 -12
  218. package/framework/modules/chui_validate/chui_validate.js +7 -4
  219. package/framework/tray_bar/chui_menu_items.js +136 -46
  220. package/index.d.ts +4814 -0
  221. package/index.js +449 -334
  222. package/package.json +79 -68
@@ -1,11 +1,11 @@
1
- const { Icon, Icons } = require('../../chui_icons/icons');
2
- const {makeKeyboardButton} = require('../../../modules/chui_a11y/chui_a11y');
3
- const {I18n} = require('../../../modules/chui_i18n/chui_i18n');
1
+ const { Icon, Icons } = require("../../chui_icons/icons");
2
+ const { makeKeyboardButton } = require("../../../modules/chui_a11y/chui_a11y");
3
+ const { I18n } = require("../../../modules/chui_i18n/chui_i18n");
4
4
 
5
- const {Validate} = require('../../../modules/chui_validate/chui_validate');
5
+ const { Validate } = require("../../../modules/chui_validate/chui_validate");
6
6
 
7
7
  class NumberInput {
8
- #chui_number_input = document.createElement('chui_number_input');
8
+ #chui_number_input = document.createElement("chui_number_input");
9
9
  #number_main = document.createElement("number_main");
10
10
  #number_button_minus = document.createElement("number_button_minus");
11
11
  #number_button_plus = document.createElement("number_button_plus");
@@ -13,16 +13,16 @@ class NumberInput {
13
13
  #number_button_plus_disabled = document.createElement("number_button_plus");
14
14
  #title = undefined;
15
15
  #id = require("randomstring").generate();
16
- #input = document.createElement('input');
17
- #label = document.createElement('label');
16
+ #input = document.createElement("input");
17
+ #label = document.createElement("label");
18
18
  constructor(options = { name: String(), title: String(), required: Boolean(), width: String() }) {
19
- require('../../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_NumberInput');
19
+ require("../../../modules/chui_functions").setStyles(__dirname + "/styles.css", "chUiJS_NumberInput");
20
20
  this.#title = options.title;
21
21
 
22
22
  // Кнопки «плюс» и «минус» — у правого и левого края поля (позицию держит CSS)
23
- this.#number_button_plus.className = 'number_buttons number_buttons_plus';
23
+ this.#number_button_plus.className = "number_buttons number_buttons_plus";
24
24
  this.#number_button_plus.innerHTML = this.#iconHTML(Icons.CONTENT.ADD, "var(--blue_prime_background)");
25
- this.#number_button_minus.className = 'number_buttons number_buttons_minus';
25
+ this.#number_button_minus.className = "number_buttons number_buttons_minus";
26
26
  this.#number_button_minus.innerHTML = this.#iconHTML(Icons.CONTENT.REMOVE, "var(--blue_prime_background)");
27
27
  // Кнопки — не нативные: делаем их доступными с клавиатуры и даём имена (глиф в дерево доступности не идёт)
28
28
  makeKeyboardButton(this.#number_button_minus);
@@ -32,17 +32,20 @@ class NumberInput {
32
32
 
33
33
  // Выключенные кнопки: только вид, действий нет — скринридеру их не отдаём.
34
34
  // Курсор берётся наследованием от корня `.number_main_disabled`
35
- this.#number_button_plus_disabled.className = 'number_buttons number_buttons_plus';
35
+ this.#number_button_plus_disabled.className = "number_buttons number_buttons_plus";
36
36
  this.#number_button_plus_disabled.innerHTML = this.#iconHTML(Icons.CONTENT.ADD, "var(--text_color_disabled)");
37
37
  this.#number_button_plus_disabled.setAttribute("aria-hidden", "true");
38
- this.#number_button_minus_disabled.className = 'number_buttons number_buttons_minus';
39
- this.#number_button_minus_disabled.innerHTML = this.#iconHTML(Icons.CONTENT.REMOVE, "var(--text_color_disabled)");
38
+ this.#number_button_minus_disabled.className = "number_buttons number_buttons_minus";
39
+ this.#number_button_minus_disabled.innerHTML = this.#iconHTML(
40
+ Icons.CONTENT.REMOVE,
41
+ "var(--text_color_disabled)"
42
+ );
40
43
  this.#number_button_minus_disabled.setAttribute("aria-hidden", "true");
41
44
  //
42
45
 
43
- this.#input.type = 'number';
44
- this.#input.className = 'number_input';
45
- this.#input.value = '0';
46
+ this.#input.type = "number";
47
+ this.#input.className = "number_input";
48
+ this.#input.value = "0";
46
49
  this.#input.id = this.#id;
47
50
  if (options.name !== undefined) this.#input.name = options.name;
48
51
  if (options.required !== undefined) this.#input.required = options.required;
@@ -50,8 +53,8 @@ class NumberInput {
50
53
  Validate.installField(this, options, this.#number_main, undefined, () => this.#input.value);
51
54
  if (options.title !== undefined) {
52
55
  this.#label.innerText = options.title;
53
- this.#label.classList.add('number_label')
54
- this.#label.setAttribute('for', this.#id);
56
+ this.#label.classList.add("number_label");
57
+ this.#label.setAttribute("for", this.#id);
55
58
  this.#chui_number_input.appendChild(this.#label);
56
59
  }
57
60
  if (options.width !== undefined) this.#chui_number_input.style.width = options.width;
@@ -64,11 +67,11 @@ class NumberInput {
64
67
  this.#number_main.appendChild(this.#number_button_plus);
65
68
  this.#chui_number_input.appendChild(this.#number_main);
66
69
 
67
- this.#number_button_plus.addEventListener('mousedown', (event) => {
70
+ this.#number_button_plus.addEventListener("mousedown", (event) => {
68
71
  event.preventDefault();
69
72
  return false;
70
73
  });
71
- this.#number_button_minus.addEventListener('mousedown', (event) => {
74
+ this.#number_button_minus.addEventListener("mousedown", (event) => {
72
75
  event.preventDefault();
73
76
  return false;
74
77
  });
@@ -76,50 +79,64 @@ class NumberInput {
76
79
  // Клавиатура: фокус остаётся на кнопке (можно нажимать подряд), мышь — уводит в поле
77
80
  // Свои кнопки меняют значение программно, поэтому событие шлём сами: иначе о правке
78
81
  // не узнали бы ни слушатели, ни составные компоненты
79
- this.#number_button_plus.addEventListener('click', (event) => {
82
+ this.#number_button_plus.addEventListener("click", (event) => {
80
83
  if (event.detail > 0) this.#input.focus();
81
- this.#input.value++
82
- this.#input.dispatchEvent(new Event("change", {bubbles: true}));
84
+ this.#input.value++;
85
+ this.#input.dispatchEvent(new Event("change", { bubbles: true }));
83
86
  });
84
- this.#number_button_minus.addEventListener('click', (event) => {
87
+ this.#number_button_minus.addEventListener("click", (event) => {
85
88
  if (event.detail > 0) this.#input.focus();
86
- this.#input.value--
87
- this.#input.dispatchEvent(new Event("change", {bubbles: true}));
89
+ this.#input.value--;
90
+ this.#input.dispatchEvent(new Event("change", { bubbles: true }));
88
91
  });
89
92
  }
90
- addInputListener(listener = () => {}) { this.#input.addEventListener("input", listener); }
91
- addChangeListener(listener = () => {}) { this.#input.addEventListener("change", listener); }
92
- getName() { return this.#input.name; }
93
- getTitle() { return this.#title; }
93
+ addInputListener(listener = () => {}) {
94
+ this.#input.addEventListener("input", listener);
95
+ }
96
+ addChangeListener(listener = () => {}) {
97
+ this.#input.addEventListener("change", listener);
98
+ }
99
+ getName() {
100
+ return this.#input.name;
101
+ }
102
+ getTitle() {
103
+ return this.#title;
104
+ }
94
105
  /** HTML глифа: иконка-лигатура не должна попадать в дерево доступности */
95
106
  #iconHTML(icon = String(), color = String()) {
96
107
  const glyph = new Icon(icon, undefined, color);
97
108
  glyph.set().setAttribute("aria-hidden", "true");
98
109
  return glyph.getHTML();
99
110
  }
100
- getValue() { return this.#input.value; }
101
- setValue(num = Number()) { this.#input.value = num; }
111
+ getValue() {
112
+ return this.#input.value;
113
+ }
114
+ setValue(num = Number()) {
115
+ this.#input.value = num;
116
+ }
102
117
  setDisabled(boolean = Boolean()) {
103
- this.#input.disabled = boolean
118
+ this.#input.disabled = boolean;
104
119
  if (boolean) {
105
- this.#number_main.classList.add("number_main_disabled")
106
- this.#input.className = "number_input_disabled"
107
- this.#label.className = "number_label_disabled"
120
+ this.#number_main.classList.add("number_main_disabled");
121
+ this.#input.className = "number_input_disabled";
122
+ this.#label.className = "number_label_disabled";
108
123
  this.#number_button_minus.remove();
109
124
  this.#number_button_plus.remove();
110
125
  this.#number_main.appendChild(this.#number_button_minus_disabled);
111
126
  this.#number_main.appendChild(this.#number_button_plus_disabled);
112
127
  } else {
113
- this.#number_main.classList.remove("number_main_disabled")
114
- this.#input.className = "number_input"
115
- this.#label.className = "number_label"
128
+ this.#number_main.classList.remove("number_main_disabled");
129
+ this.#input.className = "number_input";
130
+ this.#label.className = "number_label";
116
131
  this.#number_button_minus_disabled.remove();
117
132
  this.#number_button_plus_disabled.remove();
118
133
  this.#number_main.appendChild(this.#number_button_minus);
119
134
  this.#number_main.appendChild(this.#number_button_plus);
120
135
  }
121
136
  }
122
- set() { return this.#chui_number_input; }
137
+ set() {
138
+ return this.#chui_number_input;
139
+ }
123
140
  }
124
141
 
125
- exports.NumberInput = NumberInput
142
+ exports.NumberInput = NumberInput;
@@ -54,8 +54,8 @@ number_main {
54
54
 
55
55
  /* Крутилка числа — системная: значение правят свои кнопки «плюс»/«минус». Правило только
56
56
  для своего поля, иначе оно скрывало бы чужие нативные поля во всём приложении */
57
- chui_number_input input[type=number]::-webkit-inner-spin-button {
58
- -webkit-appearance: none
57
+ chui_number_input input[type="number"]::-webkit-inner-spin-button {
58
+ -webkit-appearance: none;
59
59
  }
60
60
 
61
61
  .number_input {
@@ -74,8 +74,8 @@ chui_number_input input[type=number]::-webkit-inner-spin-button {
74
74
  width: max-content;
75
75
  margin: 0 0 var(--margin);
76
76
  font-size: var(--font_labels_size);
77
- font-weight:500;
78
- color: var(--text_color)
77
+ font-weight: 500;
78
+ color: var(--text_color);
79
79
  }
80
80
 
81
81
  /* DISABLED STYLES */
@@ -91,8 +91,8 @@ chui_number_input input[type=number]::-webkit-inner-spin-button {
91
91
  width: max-content;
92
92
  margin: 0 0 var(--margin);
93
93
  font-size: var(--font_labels_size);
94
- font-weight:500;
95
- color: var(--text_color_disabled)
94
+ font-weight: 500;
95
+ color: var(--text_color_disabled);
96
96
  }
97
97
 
98
98
  .number_input_disabled {
@@ -105,4 +105,4 @@ chui_number_input input[type=number]::-webkit-inner-spin-button {
105
105
  text-align: center;
106
106
  border: none;
107
107
  font-size: var(--font_default_size);
108
- }
108
+ }
@@ -1,7 +1,7 @@
1
- const {setStyles} = require("../../../modules/chui_functions");
2
- const {Validate} = require("../../../modules/chui_validate/chui_validate");
3
- const {RovingKeyboard} = require("../../../modules/chui_a11y/chui_a11y");
4
- const {I18n} = require("../../../modules/chui_i18n/chui_i18n");
1
+ const { setStyles } = require("../../../modules/chui_functions");
2
+ const { Validate } = require("../../../modules/chui_validate/chui_validate");
3
+ const { RovingKeyboard } = require("../../../modules/chui_a11y/chui_a11y");
4
+ const { I18n } = require("../../../modules/chui_i18n/chui_i18n");
5
5
 
6
6
  /**
7
7
  * Поле одноразового кода: несколько клеток по одному символу.
@@ -101,22 +101,24 @@ class OtpInput {
101
101
  #on_change = undefined;
102
102
  #on_complete = undefined;
103
103
 
104
- constructor(options = {
105
- id: String(),
106
- name: String(),
107
- title: String(),
108
- label: String(),
109
- hint: String(),
110
- length: Number(),
111
- type: String(),
112
- value: String(),
113
- obscure: Boolean(),
114
- disabled: Boolean(),
115
- readOnly: Boolean(),
116
- changeListener: undefined,
117
- onChange: undefined,
118
- onComplete: undefined
119
- }) {
104
+ constructor(
105
+ options = {
106
+ id: String(),
107
+ name: String(),
108
+ title: String(),
109
+ label: String(),
110
+ hint: String(),
111
+ length: Number(),
112
+ type: String(),
113
+ value: String(),
114
+ obscure: Boolean(),
115
+ disabled: Boolean(),
116
+ readOnly: Boolean(),
117
+ changeListener: undefined,
118
+ onChange: undefined,
119
+ onComplete: undefined,
120
+ }
121
+ ) {
120
122
  setStyles(__dirname + "/styles.css", "chUiJS_OtpInput");
121
123
  OtpInput.#counter += 1;
122
124
  this.#id = options.id === undefined ? `chui_otp_input_${OtpInput.#counter}` : options.id;
@@ -147,13 +149,20 @@ class OtpInput {
147
149
  this.setLabel(this.#label_text === undefined ? I18n.t("forms.otpLabel") : this.#label_text);
148
150
  if (options.hint !== undefined) this.setHint(options.hint);
149
151
  this.#build();
150
- this.#roving = new RovingKeyboard(this.#row, {itemSelector: ".otp_cell"});
152
+ this.#roving = new RovingKeyboard(this.#row, { itemSelector: ".otp_cell" });
151
153
  // «Неверный формат» у кода значит «код не до конца» — так и говорим
152
- const messages = Object.assign({pattern: I18n.t("forms.otpIncomplete")}, options.messages);
153
- Validate.installField(this, Object.assign({}, options, {
154
- pattern: OtpInput.pattern(this.#type, this.#length),
155
- messages: messages,
156
- }), this.#root, this.#error, () => this.#value, this.#row);
154
+ const messages = Object.assign({ pattern: I18n.t("forms.otpIncomplete") }, options.messages);
155
+ Validate.installField(
156
+ this,
157
+ Object.assign({}, options, {
158
+ pattern: OtpInput.pattern(this.#type, this.#length),
159
+ messages: messages,
160
+ }),
161
+ this.#root,
162
+ this.#error,
163
+ () => this.#value,
164
+ this.#row
165
+ );
157
166
  if (options.value !== undefined && options.value !== "") this.setValue(options.value);
158
167
  this.setObscure(options.obscure === true);
159
168
  this.setReadOnly(options.readOnly === true);
@@ -406,7 +415,7 @@ class OtpInput {
406
415
  cell.setAttribute("autocomplete", "one-time-code");
407
416
  cell.setAttribute("autocapitalize", "off");
408
417
  cell.setAttribute("spellcheck", "false");
409
- cell.setAttribute("aria-label", I18n.t("forms.otpCell", {index: index + 1, total: this.#length}));
418
+ cell.setAttribute("aria-label", I18n.t("forms.otpCell", { index: index + 1, total: this.#length }));
410
419
  cell.setAttribute("tabindex", index === 0 ? "0" : "-1");
411
420
  cell.addEventListener("input", this.#onInput);
412
421
  cell.addEventListener("keydown", this.#onKeyDown);
@@ -462,7 +471,7 @@ class OtpInput {
462
471
  #announce() {
463
472
  if (this.#value.length === 0) this.#status.innerText = "";
464
473
  else if (this.isComplete()) this.#status.innerText = I18n.t("forms.otpComplete");
465
- else this.#status.innerText = I18n.t("forms.otpEntered", {entered: this.#value.length, total: this.#length});
474
+ else this.#status.innerText = I18n.t("forms.otpEntered", { entered: this.#value.length, total: this.#length });
466
475
  }
467
476
 
468
477
  // Раскладывает символы по клеткам от `start`; если места не хватает — с начала
@@ -555,4 +564,4 @@ class OtpInput {
555
564
  };
556
565
  }
557
566
 
558
- exports.OtpInput = OtpInput
567
+ exports.OtpInput = OtpInput;
@@ -1,32 +1,44 @@
1
- const { Icon, Icons } = require('../../chui_icons/icons');
2
- const {Animation} = require("../../../modules/chui_animations/animations");
3
- const {I18n} = require("../../../modules/chui_i18n/chui_i18n");
4
- const {makeKeyboardButton} = require("../../../modules/chui_a11y/chui_a11y");
1
+ const { Icon, Icons } = require("../../chui_icons/icons");
2
+ const { Animation } = require("../../../modules/chui_animations/animations");
3
+ const { I18n } = require("../../../modules/chui_i18n/chui_i18n");
4
+ const { makeKeyboardButton } = require("../../../modules/chui_a11y/chui_a11y");
5
5
 
6
- const {Validate} = require('../../../modules/chui_validate/chui_validate');
6
+ const { Validate } = require("../../../modules/chui_validate/chui_validate");
7
7
 
8
8
  class PasswordInput {
9
9
  #id = require("randomstring").generate();
10
- #password_main = document.createElement('password_main');
11
- #see_pass_button = document.createElement('see_pass_button');
12
- #see_pass_button_disabled = document.createElement('see_pass_button');
13
- #chui_password_input = document.createElement('chui_password_input');
14
- #label = document.createElement('label');
15
- #input = document.createElement('input');
10
+ #password_main = document.createElement("password_main");
11
+ #see_pass_button = document.createElement("see_pass_button");
12
+ #see_pass_button_disabled = document.createElement("see_pass_button");
13
+ #chui_password_input = document.createElement("chui_password_input");
14
+ #label = document.createElement("label");
15
+ #input = document.createElement("input");
16
16
  #title = undefined;
17
17
  #error_message_password = document.createElement("error_message_password");
18
- constructor(options = {
19
- name: String(), title: String(), placeholder: String(), width: String(), required: Boolean()
20
- }) {
21
- require('../../../modules/chui_functions').setStyles(__dirname + "/styles.css", 'chUiJS_PasswordInput');
18
+ constructor(
19
+ options = {
20
+ name: String(),
21
+ title: String(),
22
+ placeholder: String(),
23
+ width: String(),
24
+ required: Boolean(),
25
+ }
26
+ ) {
27
+ require("../../../modules/chui_functions").setStyles(__dirname + "/styles.css", "chUiJS_PasswordInput");
22
28
  this.#title = options.title;
23
- this.#input.type = 'password';
29
+ this.#input.type = "password";
24
30
  this.#input.id = this.#id;
25
31
  if (options.name !== undefined) this.#input.name = options.name;
26
- this.#input.className = 'password_input';
32
+ this.#input.className = "password_input";
27
33
  if (options.required !== undefined) this.#input.required = options.required;
28
34
  // Валидация: тот же контракт validate/setError/clearError, своё сообщение под полем
29
- Validate.installField(this, options, this.#password_main, this.#error_message_password, () => this.#input.value);
35
+ Validate.installField(
36
+ this,
37
+ options,
38
+ this.#password_main,
39
+ this.#error_message_password,
40
+ () => this.#input.value
41
+ );
30
42
  // Кнопка показа пароля — не значок, а кнопка: роль, остановка обхода и Enter/Space
31
43
  makeKeyboardButton(this.#see_pass_button);
32
44
  // У выключенного поля кнопка декоративна: фокус в неё не попадает
@@ -38,8 +50,8 @@ class PasswordInput {
38
50
  this.#syncSeeLabel();
39
51
  if (options.title !== undefined) {
40
52
  this.#label.innerText = options.title;
41
- this.#label.classList.add('password_label')
42
- this.#label.setAttribute('for', this.#id);
53
+ this.#label.classList.add("password_label");
54
+ this.#label.setAttribute("for", this.#id);
43
55
  this.#chui_password_input.appendChild(this.#label);
44
56
  }
45
57
  if (options.placeholder !== undefined) this.#input.placeholder = options.placeholder;
@@ -48,38 +60,46 @@ class PasswordInput {
48
60
  // `:focus-within`), а не компонент: прежде он ставил то же самое инлайном,
49
61
  // а на `blur` снимал весь атрибут `style`
50
62
 
51
- this.#see_pass_button.addEventListener('mousedown', (event) => {
63
+ this.#see_pass_button.addEventListener("mousedown", (event) => {
52
64
  event.preventDefault();
53
65
  return false;
54
66
  });
55
67
 
56
68
  this.#password_main.appendChild(this.#input);
57
69
  this.#password_main.appendChild(this.#see_pass_button);
58
- this.#see_pass_button.addEventListener('click', () => this.#showPassword());
70
+ this.#see_pass_button.addEventListener("click", () => this.#showPassword());
59
71
  this.#chui_password_input.appendChild(this.#password_main);
60
72
 
61
73
  //
62
74
  this.#input.addEventListener("input", () => {
63
75
  this.clearError();
64
76
  new Animation(this.#error_message_password).fadeOut();
65
- })
77
+ });
78
+ }
79
+ getName() {
80
+ return this.#input.name;
81
+ }
82
+ getTitle() {
83
+ return this.#title;
84
+ }
85
+ getValue() {
86
+ return this.#input.value;
87
+ }
88
+ setValue(text = String()) {
89
+ this.#input.value = text;
66
90
  }
67
- getName() { return this.#input.name; }
68
- getTitle() { return this.#title; }
69
- getValue() { return this.#input.value; }
70
- setValue(text = String()) { this.#input.value = text; }
71
91
  setDisabled(boolean = Boolean()) {
72
- this.#input.disabled = boolean
92
+ this.#input.disabled = boolean;
73
93
  if (boolean) {
74
- this.#password_main.classList.add("password_main_disabled")
75
- this.#input.className = "password_input_disabled"
76
- this.#label.className = "password_label_disabled"
94
+ this.#password_main.classList.add("password_main_disabled");
95
+ this.#input.className = "password_input_disabled";
96
+ this.#label.className = "password_label_disabled";
77
97
  this.#see_pass_button.remove();
78
98
  this.#password_main.appendChild(this.#see_pass_button_disabled);
79
99
  } else {
80
- this.#password_main.classList.remove("password_main_disabled")
81
- this.#input.className = "password_input"
82
- this.#label.className = "password_label"
100
+ this.#password_main.classList.remove("password_main_disabled");
101
+ this.#input.className = "password_input";
102
+ this.#label.className = "password_label";
83
103
  this.#see_pass_button_disabled.remove();
84
104
  this.#password_main.appendChild(this.#see_pass_button);
85
105
  }
@@ -91,7 +111,9 @@ class PasswordInput {
91
111
  // У поля сообщение скрыто по умолчанию (`display: none`) — показываем анимацией
92
112
  new Animation(this.#error_message_password).fadeIn();
93
113
  }
94
- set() { return this.#chui_password_input; }
114
+ set() {
115
+ return this.#chui_password_input;
116
+ }
95
117
  /** Значок кнопки: узел помечается скрытым — имя кнопки даёт `aria-label`, а не лигатура */
96
118
  #setSeeGlyph(button = new HTMLElement(), icon = String(), color = String()) {
97
119
  const glyph = new Icon(icon, undefined, color).set();
@@ -119,4 +141,4 @@ class PasswordInput {
119
141
  }
120
142
  }
121
143
 
122
- exports.PasswordInput = PasswordInput
144
+ exports.PasswordInput = PasswordInput;
@@ -48,7 +48,7 @@ see_pass_button {
48
48
  margin: 0;
49
49
  display: inline-flex;
50
50
  justify-content: center;
51
- align-items: center
51
+ align-items: center;
52
52
  }
53
53
 
54
54
  .password_label {
@@ -56,8 +56,8 @@ see_pass_button {
56
56
  width: max-content;
57
57
  margin: 0 0 var(--margin);
58
58
  font-size: var(--font_labels_size);
59
- font-weight:500;
60
- color: var(--text_color)
59
+ font-weight: 500;
60
+ color: var(--text_color);
61
61
  }
62
62
 
63
63
  .error_border {
@@ -70,8 +70,8 @@ error_message_password {
70
70
  width: max-content;
71
71
  margin: var(--margin) var(--margin) 0 var(--margin);
72
72
  font-size: var(--font_labels_size);
73
- font-weight:500;
74
- color: var(--red_prime_background)
73
+ font-weight: 500;
74
+ color: var(--red_prime_background);
75
75
  }
76
76
 
77
77
  /* DISABLED STYLES */
@@ -87,8 +87,8 @@ error_message_password {
87
87
  width: max-content;
88
88
  margin: 0 0 var(--margin);
89
89
  font-size: var(--font_labels_size);
90
- font-weight:500;
91
- color: var(--text_color_disabled)
90
+ font-weight: 500;
91
+ color: var(--text_color_disabled);
92
92
  }
93
93
 
94
94
  .password_input_disabled {
@@ -101,4 +101,4 @@ error_message_password {
101
101
  text-align: start;
102
102
  border: none;
103
103
  font-size: var(--font_default_size);
104
- }
104
+ }
@@ -1,28 +1,30 @@
1
1
  class RadioButton {
2
2
  #id = require("randomstring").generate();
3
- #radioButton = document.createElement('radiobutton');
4
- #input = document.createElement('input');
5
- #label = document.createElement('label');
6
- constructor(options = {
7
- name: String(),
8
- title: String(),
9
- stringValue: String(),
10
- value: Boolean(),
11
- required: Boolean(),
12
- width: String()
13
- }) {
14
- const {setStyles, optionOr} = require('../../../modules/chui_functions');
15
- setStyles(__dirname + "/styles.css", 'chUiJS_RadioButton');
16
- this.#radioButton.style.getPropertyValue('display')
17
- this.#input.classList.add('radiobutton');
18
- this.#input.type = 'radio';
19
- this.#input.classList.add('radiobutton_input');
3
+ #radioButton = document.createElement("radiobutton");
4
+ #input = document.createElement("input");
5
+ #label = document.createElement("label");
6
+ constructor(
7
+ options = {
8
+ name: String(),
9
+ title: String(),
10
+ stringValue: String(),
11
+ value: Boolean(),
12
+ required: Boolean(),
13
+ width: String(),
14
+ }
15
+ ) {
16
+ const { setStyles, optionOr } = require("../../../modules/chui_functions");
17
+ setStyles(__dirname + "/styles.css", "chUiJS_RadioButton");
18
+ this.#radioButton.style.getPropertyValue("display");
19
+ this.#input.classList.add("radiobutton");
20
+ this.#input.type = "radio";
21
+ this.#input.classList.add("radiobutton_input");
20
22
  this.#input.id = this.#id;
21
23
  // Пустая заготовка опции равносильна отсутствующей: иначе в value и подписи попадало «undefined»
22
24
  this.#input.value = optionOr(options.stringValue, "");
23
25
  if (optionOr(options.title, undefined) !== undefined) this.#label.innerText = options.title;
24
- this.#label.setAttribute('for', this.#id);
25
- this.#label.classList.add('labelr')
26
+ this.#label.setAttribute("for", this.#id);
27
+ this.#label.classList.add("labelr");
26
28
  if (options.name !== undefined) this.#input.name = options.name;
27
29
  if (options.value !== undefined) this.#input.checked = options.value;
28
30
  if (options.required !== undefined) this.#input.required = options.required;
@@ -33,11 +35,21 @@ class RadioButton {
33
35
  }
34
36
  }
35
37
  }
36
- getName() { return this.#input.name; }
37
- getValue() { return this.#input.checked; }
38
- setValue(value = Boolean()) { this.#input.checked = value; }
39
- addChangeListener(listener) { this.#input.addEventListener('change', listener); }
40
- setDisabled(boolean = Boolean()) { this.#input.disabled = boolean; }
38
+ getName() {
39
+ return this.#input.name;
40
+ }
41
+ getValue() {
42
+ return this.#input.checked;
43
+ }
44
+ setValue(value = Boolean()) {
45
+ this.#input.checked = value;
46
+ }
47
+ addChangeListener(listener) {
48
+ this.#input.addEventListener("change", listener);
49
+ }
50
+ setDisabled(boolean = Boolean()) {
51
+ this.#input.disabled = boolean;
52
+ }
41
53
  set() {
42
54
  this.#radioButton.appendChild(this.#input);
43
55
  this.#radioButton.appendChild(this.#label);
@@ -45,4 +57,4 @@ class RadioButton {
45
57
  }
46
58
  }
47
59
 
48
- exports.RadioButton = RadioButton
60
+ exports.RadioButton = RadioButton;