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.
- package/CHANGELOG.md +113 -0
- package/README.md +43 -632
- package/framework/appLayout/default/chui_app_layout.js +314 -273
- package/framework/appLayout/default/global_style.css +93 -53
- package/framework/components/chui_accordion/accordion.js +29 -26
- package/framework/components/chui_accordion/styles.css +6 -5
- package/framework/components/chui_action_sheet/action_sheet.js +59 -33
- package/framework/components/chui_action_sheet/styles.css +2 -1
- package/framework/components/chui_affix/affix.js +11 -6
- package/framework/components/chui_alert/alert.js +23 -14
- package/framework/components/chui_avatar/avatar.js +23 -22
- package/framework/components/chui_avatar_group/avatar_group.js +21 -19
- package/framework/components/chui_backtop/backtop.js +35 -19
- package/framework/components/chui_badge/badge.js +15 -13
- package/framework/components/chui_breadcrumb/breadcrumb.js +15 -13
- package/framework/components/chui_button/button.js +42 -22
- package/framework/components/chui_button/styles.css +2 -2
- package/framework/components/chui_calendar/calendar.js +12 -10
- package/framework/components/chui_card/card.js +43 -23
- package/framework/components/chui_chat/chat.js +72 -33
- package/framework/components/chui_clipboard_history/clipboard_history.js +30 -21
- package/framework/components/chui_clipboard_history/styles.css +4 -2
- package/framework/components/chui_code/code.js +2 -2
- package/framework/components/chui_code/styles.css +2 -2
- package/framework/components/chui_code_editor/code_editor.js +47 -31
- package/framework/components/chui_code_editor/styles.css +3 -2
- package/framework/components/chui_command_palette/command_palette.js +60 -37
- package/framework/components/chui_console/console.js +5 -5
- package/framework/components/chui_console/styles.css +1 -1
- package/framework/components/chui_content_block/content_block.js +33 -19
- package/framework/components/chui_content_block/styles.css +2 -2
- package/framework/components/chui_context_menu/context_menu.js +9 -4
- package/framework/components/chui_custom_element/custom_element.js +22 -15
- package/framework/components/chui_data_grid/data_grid.js +396 -234
- package/framework/components/chui_data_grid/styles.css +10 -8
- package/framework/components/chui_descriptions/descriptions.js +34 -17
- package/framework/components/chui_details/details.js +32 -26
- package/framework/components/chui_details/styles.css +5 -4
- package/framework/components/chui_diff_viewer/diff_viewer.js +91 -66
- package/framework/components/chui_diff_viewer/styles.css +1 -1
- package/framework/components/chui_divider/divider.js +13 -11
- package/framework/components/chui_drawer/drawer.js +27 -25
- package/framework/components/chui_drop_zone/drop_zone.js +31 -21
- package/framework/components/chui_empty_state/empty_state.js +20 -15
- package/framework/components/chui_fieldset/fieldset.js +37 -20
- package/framework/components/chui_fieldset/styles.css +1 -1
- package/framework/components/chui_file_explorer/file_explorer.js +157 -86
- package/framework/components/chui_file_explorer/styles.css +2 -1
- package/framework/components/chui_form/form.js +31 -19
- package/framework/components/chui_form/styles.css +1 -1
- package/framework/components/chui_gantt/gantt.js +64 -40
- package/framework/components/chui_graphs/graphs.js +301 -200
- package/framework/components/chui_graphs/styles.css +1 -1
- package/framework/components/chui_hero/hero.js +40 -22
- package/framework/components/chui_html_block/html_block.js +6 -6
- package/framework/components/chui_html_block/styles.css +2 -2
- package/framework/components/chui_hx/hx.js +3 -3
- package/framework/components/chui_hx/styles.css +11 -4
- package/framework/components/chui_icons/icons.js +2109 -2109
- package/framework/components/chui_icons/styles.css +2 -2
- package/framework/components/chui_inputs/chui_check_box/check_box.js +31 -19
- package/framework/components/chui_inputs/chui_check_box/styles.css +18 -18
- package/framework/components/chui_inputs/chui_chips/chips.js +50 -40
- package/framework/components/chui_inputs/chui_chips/styles.css +4 -2
- package/framework/components/chui_inputs/chui_color_picker/color_picker.js +36 -24
- package/framework/components/chui_inputs/chui_combo_box/combo_box.js +100 -82
- package/framework/components/chui_inputs/chui_combo_box/styles.css +14 -12
- package/framework/components/chui_inputs/chui_date/date.js +102 -66
- package/framework/components/chui_inputs/chui_date/styles.css +12 -11
- package/framework/components/chui_inputs/chui_date_range/date_range.js +40 -29
- package/framework/components/chui_inputs/chui_datetime/datetime.js +35 -27
- package/framework/components/chui_inputs/chui_email/email.js +43 -31
- package/framework/components/chui_inputs/chui_email/styles.css +5 -5
- package/framework/components/chui_inputs/chui_file/file.js +68 -41
- package/framework/components/chui_inputs/chui_file/styles.css +13 -12
- package/framework/components/chui_inputs/chui_hotkey/hotkey.js +61 -36
- package/framework/components/chui_inputs/chui_masked/masked.js +39 -28
- package/framework/components/chui_inputs/chui_mention/mention.js +77 -30
- package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +173 -153
- package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +9 -7
- package/framework/components/chui_inputs/chui_number/number.js +58 -41
- package/framework/components/chui_inputs/chui_number/styles.css +7 -7
- package/framework/components/chui_inputs/chui_otp/otp.js +38 -29
- package/framework/components/chui_inputs/chui_password/password.js +58 -36
- package/framework/components/chui_inputs/chui_password/styles.css +8 -8
- package/framework/components/chui_inputs/chui_radio_button/radio_button.js +37 -25
- package/framework/components/chui_inputs/chui_radio_button/styles.css +20 -20
- package/framework/components/chui_inputs/chui_rating/rating.js +26 -22
- package/framework/components/chui_inputs/chui_select_box/select_box.js +102 -78
- package/framework/components/chui_inputs/chui_select_box/styles.css +11 -11
- package/framework/components/chui_inputs/chui_slider/slider.js +29 -26
- package/framework/components/chui_inputs/chui_slider/styles.css +2 -1
- package/framework/components/chui_inputs/chui_text/styles.css +8 -8
- package/framework/components/chui_inputs/chui_text/text.js +65 -44
- package/framework/components/chui_inputs/chui_text_area/styles.css +6 -6
- package/framework/components/chui_inputs/chui_text_area/text_area.js +51 -28
- package/framework/components/chui_inputs/chui_time/styles.css +5 -3
- package/framework/components/chui_inputs/chui_time/time.js +38 -27
- package/framework/components/chui_inputs/chui_toggle/styles.css +3 -3
- package/framework/components/chui_inputs/chui_toggle/toggle.js +16 -16
- package/framework/components/chui_json_editor/json_editor.js +53 -43
- package/framework/components/chui_json_viewer/json_viewer.js +52 -33
- package/framework/components/chui_json_viewer/styles.css +3 -2
- package/framework/components/chui_kanban/kanban.js +52 -34
- package/framework/components/chui_kbd/kbd.js +12 -10
- package/framework/components/chui_label/label.js +14 -12
- package/framework/components/chui_label/styles.css +2 -2
- package/framework/components/chui_link/link.js +27 -20
- package/framework/components/chui_list/list.js +31 -27
- package/framework/components/chui_list/styles.css +2 -1
- package/framework/components/chui_markdown_editor/markdown_editor.js +60 -44
- package/framework/components/chui_media/audio.js +326 -227
- package/framework/components/chui_media/audio_styles.css +40 -21
- package/framework/components/chui_media/image.js +70 -38
- package/framework/components/chui_media/image_compare.js +52 -21
- package/framework/components/chui_media/image_styles.css +3 -3
- package/framework/components/chui_media/video.js +155 -62
- package/framework/components/chui_media/video_styles.css +33 -16
- package/framework/components/chui_menu_bar/menu_bar.js +26 -24
- package/framework/components/chui_menu_bar/styles.css +4 -2
- package/framework/components/chui_modal/modal.js +44 -43
- package/framework/components/chui_modal/styles.css +3 -2
- package/framework/components/chui_notification/notification.js +50 -34
- package/framework/components/chui_notification/notification_download.js +31 -25
- package/framework/components/chui_notification/notification_download_progress.css +3 -2
- package/framework/components/chui_notification/notification_download_progress.js +47 -41
- package/framework/components/chui_notification/notification_update.js +23 -16
- package/framework/components/chui_notification/status_plate.js +2 -2
- package/framework/components/chui_notification/styles_download.css +1 -1
- package/framework/components/chui_notification/styles_update.css +1 -1
- package/framework/components/chui_org_chart/org_chart.js +74 -35
- package/framework/components/chui_pagination/pagination.js +62 -27
- package/framework/components/chui_paragraph/paragraph.js +2 -2
- package/framework/components/chui_paragraph/styles.css +1 -1
- package/framework/components/chui_popover/popover.js +49 -28
- package/framework/components/chui_popups/popups.js +137 -108
- package/framework/components/chui_popups/styles.css +2 -2
- package/framework/components/chui_print_button/print_button.js +33 -23
- package/framework/components/chui_progress_bar/progress_bar.js +23 -15
- package/framework/components/chui_progress_bar/styles.css +2 -2
- package/framework/components/chui_progress_ring/progress_ring.js +17 -15
- package/framework/components/chui_qrcode/qrcode.js +75 -31
- package/framework/components/chui_query_builder/query_builder.js +216 -123
- package/framework/components/chui_radio_group/radio_group.js +36 -26
- package/framework/components/chui_radio_group/styles.css +1 -1
- package/framework/components/chui_result/result.js +26 -16
- package/framework/components/chui_scheduler/scheduler.js +57 -35
- package/framework/components/chui_scheduler/styles.css +6 -2
- package/framework/components/chui_segmented_control/segmented_control.js +27 -21
- package/framework/components/chui_settings/settings.js +122 -48
- package/framework/components/chui_shortcut_help/shortcut_help.js +55 -32
- package/framework/components/chui_sidebar_nav/sidebar_nav.js +33 -23
- package/framework/components/chui_skeleton/skeleton.js +29 -24
- package/framework/components/chui_slideshow/slideshow.js +60 -41
- package/framework/components/chui_slideshow/styles.css +18 -12
- package/framework/components/chui_spinner/spinner.js +8 -8
- package/framework/components/chui_spinner/styles.css +0 -1
- package/framework/components/chui_split_button/split_button.js +23 -18
- package/framework/components/chui_split_button/styles.css +1 -1
- package/framework/components/chui_splitter/splitter.js +35 -28
- package/framework/components/chui_statistic/statistic.js +65 -38
- package/framework/components/chui_status_bar/status_bar.js +11 -9
- package/framework/components/chui_stepper/stepper.js +27 -22
- package/framework/components/chui_sticky_bar/sticky_bar.js +9 -4
- package/framework/components/chui_sticky_bar/styles.css +3 -1
- package/framework/components/chui_tabs/chui_tabs.js +28 -22
- package/framework/components/chui_tabs/styles.css +3 -3
- package/framework/components/chui_text_editor/styles.css +20 -19
- package/framework/components/chui_text_editor/text_editor.js +85 -61
- package/framework/components/chui_text_editor/text_editor_panel.js +346 -284
- package/framework/components/chui_theme_toggle/theme_toggle.js +27 -22
- package/framework/components/chui_timeline/timeline.js +14 -12
- package/framework/components/chui_toast_queue/toast_queue.js +52 -46
- package/framework/components/chui_toolbar/toolbar.js +20 -13
- package/framework/components/chui_tooltip/tooltip.js +37 -24
- package/framework/components/chui_tour/styles.css +8 -3
- package/framework/components/chui_tour/tour.js +61 -27
- package/framework/components/chui_transfer/styles.css +2 -1
- package/framework/components/chui_transfer/transfer.js +75 -42
- package/framework/components/chui_tree_table/tree_table.js +43 -29
- package/framework/components/chui_tree_view/styles.css +4 -2
- package/framework/components/chui_tree_view/tree_view.js +142 -99
- package/framework/components/chui_watermark/watermark.js +24 -16
- package/framework/components/chui_webview/styles.css +2 -2
- package/framework/components/chui_webview/webview.js +62 -50
- package/framework/components/telegram_bot/chui_telegram_bot.js +71 -64
- package/framework/modules/chui_a11y/chui_a11y.js +77 -46
- package/framework/modules/chui_animations/animations.js +42 -42
- package/framework/modules/chui_animations/styles.css +1 -1
- package/framework/modules/chui_bridge/preload.js +56 -26
- package/framework/modules/chui_functions.js +52 -50
- package/framework/modules/chui_highlight/chui_highlight.js +25 -22
- package/framework/modules/chui_i18n/chui_i18n.js +9 -7
- package/framework/modules/chui_i18n/locales/a11y.js +5 -5
- package/framework/modules/chui_i18n/locales/app_layout.js +5 -5
- package/framework/modules/chui_i18n/locales/calendar.js +3 -3
- package/framework/modules/chui_i18n/locales/common.js +3 -3
- package/framework/modules/chui_i18n/locales/data.js +36 -26
- package/framework/modules/chui_i18n/locales/editors.js +40 -13
- package/framework/modules/chui_i18n/locales/feedback.js +3 -3
- package/framework/modules/chui_i18n/locales/forms.js +8 -8
- package/framework/modules/chui_i18n/locales/graphics.js +8 -8
- package/framework/modules/chui_i18n/locales/media.js +4 -4
- package/framework/modules/chui_i18n/locales/navigation.js +8 -8
- package/framework/modules/chui_i18n/locales/validate.js +3 -3
- package/framework/modules/chui_json/chui_json.js +9 -9
- package/framework/modules/chui_layout/chui_layout.js +12 -10
- package/framework/modules/chui_logger/chui_logger.js +29 -25
- package/framework/modules/chui_page/page.js +33 -27
- package/framework/modules/chui_page/styles.css +3 -26
- package/framework/modules/chui_qr/chui_qr.js +158 -67
- package/framework/modules/chui_scrollbar/chui_scrollbar.js +35 -24
- package/framework/modules/chui_scrollbar/styles.css +3 -1
- package/framework/modules/chui_services/chui_channels.js +76 -11
- package/framework/modules/chui_services/chui_services.js +39 -31
- package/framework/modules/chui_services/desktop.js +149 -30
- package/framework/modules/chui_sortable/chui_sortable.js +17 -12
- package/framework/modules/chui_validate/chui_validate.js +7 -4
- package/framework/tray_bar/chui_menu_items.js +136 -46
- package/index.d.ts +4814 -0
- package/index.js +449 -334
- package/package.json +79 -68
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const { Icon, Icons } = require(
|
|
2
|
-
const {makeKeyboardButton} = require(
|
|
3
|
-
const {I18n} = require(
|
|
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(
|
|
5
|
+
const { Validate } = require("../../../modules/chui_validate/chui_validate");
|
|
6
6
|
|
|
7
7
|
class NumberInput {
|
|
8
|
-
#chui_number_input = document.createElement(
|
|
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(
|
|
17
|
-
#label = document.createElement(
|
|
16
|
+
#input = document.createElement("input");
|
|
17
|
+
#label = document.createElement("label");
|
|
18
18
|
constructor(options = { name: String(), title: String(), required: Boolean(), width: String() }) {
|
|
19
|
-
require(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
39
|
-
this.#number_button_minus_disabled.innerHTML = this.#iconHTML(
|
|
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 =
|
|
44
|
-
this.#input.className =
|
|
45
|
-
this.#input.value =
|
|
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(
|
|
54
|
-
this.#label.setAttribute(
|
|
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(
|
|
70
|
+
this.#number_button_plus.addEventListener("mousedown", (event) => {
|
|
68
71
|
event.preventDefault();
|
|
69
72
|
return false;
|
|
70
73
|
});
|
|
71
|
-
this.#number_button_minus.addEventListener(
|
|
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(
|
|
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(
|
|
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 = () => {}) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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() {
|
|
101
|
-
|
|
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() {
|
|
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(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
11
|
-
#see_pass_button = document.createElement(
|
|
12
|
-
#see_pass_button_disabled = document.createElement(
|
|
13
|
-
#chui_password_input = document.createElement(
|
|
14
|
-
#label = document.createElement(
|
|
15
|
-
#input = document.createElement(
|
|
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(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 =
|
|
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 =
|
|
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(
|
|
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(
|
|
42
|
-
this.#label.setAttribute(
|
|
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(
|
|
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(
|
|
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() {
|
|
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(
|
|
4
|
-
#input = document.createElement(
|
|
5
|
-
#label = document.createElement(
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.#
|
|
19
|
-
this.#input.classList.add(
|
|
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(
|
|
25
|
-
this.#label.classList.add(
|
|
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() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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;
|