chuijs 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +597 -0
- package/README.md +43 -644
- package/framework/appLayout/default/chui_app_layout.js +602 -496
- package/framework/appLayout/default/global_style.css +288 -97
- package/framework/appLayout/default/main_theme_style.css +188 -101
- package/framework/components/chui_accordion/accordion.js +38 -35
- package/framework/components/chui_accordion/styles.css +13 -12
- package/framework/components/chui_action_sheet/action_sheet.js +93 -64
- package/framework/components/chui_action_sheet/styles.css +12 -5
- package/framework/components/chui_actions_bar/actions_bar.js +338 -0
- package/framework/components/chui_actions_bar/styles.css +139 -0
- package/framework/components/chui_affix/affix.js +16 -11
- package/framework/components/chui_affix/styles.css +5 -0
- package/framework/components/chui_alert/alert.js +34 -19
- package/framework/components/chui_alert/styles.css +7 -0
- package/framework/components/chui_avatar/avatar.js +36 -35
- package/framework/components/chui_avatar/styles.css +1 -1
- package/framework/components/chui_avatar_group/avatar_group.js +25 -23
- package/framework/components/chui_avatar_group/styles.css +1 -1
- package/framework/components/chui_backtop/backtop.js +60 -21
- package/framework/components/chui_backtop/styles.css +21 -0
- package/framework/components/chui_badge/badge.js +30 -28
- package/framework/components/chui_badge/styles.css +6 -6
- package/framework/components/chui_banner/banner.js +222 -0
- package/framework/components/chui_banner/styles.css +170 -0
- package/framework/components/chui_breadcrumb/breadcrumb.js +15 -13
- package/framework/components/chui_breadcrumb/styles.css +1 -1
- package/framework/components/chui_button/button.js +52 -36
- package/framework/components/chui_button/styles.css +7 -7
- package/framework/components/chui_calendar/calendar.js +18 -16
- package/framework/components/chui_card/card.js +52 -32
- package/framework/components/chui_card_scroll/card_scroll.js +169 -0
- package/framework/components/chui_card_scroll/styles.css +86 -0
- package/framework/components/chui_chat/chat.js +140 -79
- package/framework/components/chui_chat/styles.css +18 -7
- package/framework/components/chui_clipboard_history/clipboard_history.js +53 -39
- package/framework/components/chui_clipboard_history/styles.css +13 -9
- package/framework/components/chui_code/code.js +10 -10
- package/framework/components/chui_code/styles.css +4 -4
- package/framework/components/chui_code_editor/code_editor.js +73 -57
- package/framework/components/chui_code_editor/styles.css +6 -5
- package/framework/components/chui_command_palette/command_palette.js +87 -64
- package/framework/components/chui_command_palette/styles.css +5 -5
- package/framework/components/chui_console/console.js +13 -13
- package/framework/components/chui_console/styles.css +6 -3
- package/framework/components/chui_content_block/content_block.js +35 -21
- package/framework/components/chui_content_block/styles.css +2 -2
- package/framework/components/chui_context_menu/context_menu.js +171 -58
- package/framework/components/chui_context_menu/styles.css +82 -8
- package/framework/components/chui_custom_element/custom_element.js +25 -18
- package/framework/components/chui_data_grid/data_grid.js +633 -471
- package/framework/components/chui_data_grid/styles.css +24 -22
- package/framework/components/chui_descriptions/descriptions.js +34 -17
- package/framework/components/chui_descriptions/styles.css +1 -1
- package/framework/components/chui_details/details.js +42 -36
- package/framework/components/chui_details/styles.css +12 -11
- package/framework/components/chui_diff_viewer/diff_viewer.js +172 -147
- package/framework/components/chui_diff_viewer/styles.css +10 -10
- package/framework/components/chui_divider/divider.js +19 -17
- package/framework/components/chui_divider/styles.css +2 -2
- package/framework/components/chui_drawer/drawer.js +63 -38
- package/framework/components/chui_drawer/styles.css +18 -4
- package/framework/components/chui_drop_zone/drop_zone.js +37 -27
- package/framework/components/chui_drop_zone/styles.css +10 -6
- package/framework/components/chui_empty_state/empty_state.js +20 -15
- package/framework/components/chui_fieldset/fieldset.js +40 -23
- package/framework/components/chui_fieldset/styles.css +6 -6
- package/framework/components/chui_file_explorer/file_explorer.js +260 -189
- package/framework/components/chui_file_explorer/styles.css +8 -7
- package/framework/components/chui_form/form.js +40 -28
- package/framework/components/chui_form/styles.css +1 -1
- package/framework/components/chui_gantt/gantt.js +102 -78
- package/framework/components/chui_gantt/styles.css +5 -5
- package/framework/components/chui_graphs/graphs.js +376 -239
- package/framework/components/chui_graphs/styles.css +27 -6
- package/framework/components/chui_hero/hero.js +98 -37
- package/framework/components/chui_hero/styles.css +176 -7
- package/framework/components/chui_html_block/html_block.js +8 -8
- package/framework/components/chui_html_block/styles.css +3 -3
- package/framework/components/chui_hx/hx.js +3 -3
- package/framework/components/chui_hx/styles.css +13 -6
- package/framework/components/chui_icons/icons.js +2115 -2115
- package/framework/components/chui_icons/styles.css +4 -3
- package/framework/components/chui_inputs/chui_check_box/check_box.js +31 -19
- package/framework/components/chui_inputs/chui_check_box/styles.css +30 -21
- package/framework/components/chui_inputs/chui_chips/chips.js +141 -70
- package/framework/components/chui_inputs/chui_chips/styles.css +32 -7
- package/framework/components/chui_inputs/chui_color_picker/color_picker.js +55 -38
- package/framework/components/chui_inputs/chui_color_picker/styles.css +7 -7
- package/framework/components/chui_inputs/chui_combo_box/combo_box.js +127 -109
- package/framework/components/chui_inputs/chui_combo_box/styles.css +23 -21
- package/framework/components/chui_inputs/chui_date/date.js +161 -127
- package/framework/components/chui_inputs/chui_date/styles.css +20 -19
- package/framework/components/chui_inputs/chui_date_range/date_range.js +61 -50
- package/framework/components/chui_inputs/chui_date_range/styles.css +3 -3
- package/framework/components/chui_inputs/chui_datetime/datetime.js +47 -39
- package/framework/components/chui_inputs/chui_datetime/styles.css +3 -3
- package/framework/components/chui_inputs/chui_email/email.js +48 -36
- package/framework/components/chui_inputs/chui_email/styles.css +11 -11
- package/framework/components/chui_inputs/chui_file/file.js +71 -44
- package/framework/components/chui_inputs/chui_file/styles.css +23 -19
- package/framework/components/chui_inputs/chui_hotkey/hotkey.js +101 -76
- package/framework/components/chui_inputs/chui_hotkey/styles.css +6 -6
- package/framework/components/chui_inputs/chui_masked/masked.js +83 -72
- package/framework/components/chui_inputs/chui_masked/styles.css +5 -5
- package/framework/components/chui_inputs/chui_mention/mention.js +87 -40
- package/framework/components/chui_inputs/chui_mention/styles.css +14 -8
- package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +242 -212
- package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +23 -15
- package/framework/components/chui_inputs/chui_number/number.js +84 -70
- package/framework/components/chui_inputs/chui_number/styles.css +13 -13
- package/framework/components/chui_inputs/chui_otp/otp.js +71 -62
- package/framework/components/chui_inputs/chui_otp/styles.css +5 -5
- package/framework/components/chui_inputs/chui_password/password.js +72 -56
- package/framework/components/chui_inputs/chui_password/styles.css +15 -15
- package/framework/components/chui_inputs/chui_radio_button/radio_button.js +37 -25
- package/framework/components/chui_inputs/chui_radio_button/styles.css +22 -22
- package/framework/components/chui_inputs/chui_rating/rating.js +54 -50
- package/framework/components/chui_inputs/chui_rating/styles.css +3 -3
- package/framework/components/chui_inputs/chui_select_box/select_box.js +132 -108
- package/framework/components/chui_inputs/chui_select_box/styles.css +21 -21
- package/framework/components/chui_inputs/chui_slider/slider.js +41 -38
- package/framework/components/chui_inputs/chui_slider/styles.css +7 -5
- package/framework/components/chui_inputs/chui_text/styles.css +14 -14
- package/framework/components/chui_inputs/chui_text/text.js +69 -52
- package/framework/components/chui_inputs/chui_text_area/styles.css +14 -14
- package/framework/components/chui_inputs/chui_text_area/text_area.js +59 -36
- package/framework/components/chui_inputs/chui_time/styles.css +18 -20
- package/framework/components/chui_inputs/chui_time/time.js +71 -49
- package/framework/components/chui_inputs/chui_toggle/styles.css +13 -6
- package/framework/components/chui_inputs/chui_toggle/toggle.js +27 -27
- package/framework/components/chui_json_editor/json_editor.js +137 -127
- package/framework/components/chui_json_editor/styles.css +5 -5
- package/framework/components/chui_json_viewer/json_viewer.js +133 -114
- package/framework/components/chui_json_viewer/styles.css +9 -8
- package/framework/components/chui_kanban/kanban.js +78 -60
- package/framework/components/chui_kanban/styles.css +8 -4
- package/framework/components/chui_kbd/kbd.js +12 -10
- package/framework/components/chui_kbd/styles.css +1 -1
- package/framework/components/chui_label/label.js +31 -29
- package/framework/components/chui_label/styles.css +3 -3
- package/framework/components/chui_link/link.js +36 -29
- package/framework/components/chui_link/styles.css +11 -4
- package/framework/components/chui_list/list.js +42 -38
- package/framework/components/chui_list/styles.css +4 -3
- package/framework/components/chui_markdown_editor/markdown_editor.js +125 -109
- package/framework/components/chui_markdown_editor/styles.css +5 -5
- package/framework/components/chui_media/audio.js +457 -364
- package/framework/components/chui_media/audio_styles.css +74 -37
- package/framework/components/chui_media/image.js +99 -64
- package/framework/components/chui_media/image_compare.js +86 -55
- package/framework/components/chui_media/image_compare_styles.css +5 -5
- package/framework/components/chui_media/image_styles.css +4 -4
- package/framework/components/chui_media/video.js +264 -171
- package/framework/components/chui_media/video_styles.css +57 -24
- package/framework/components/chui_menu_bar/menu_bar.js +67 -65
- package/framework/components/chui_menu_bar/styles.css +14 -12
- package/framework/components/chui_message_bar/message_bar.js +551 -0
- package/framework/components/chui_message_bar/styles.css +248 -0
- package/framework/components/chui_modal/modal.js +81 -56
- package/framework/components/chui_modal/styles.css +3 -2
- package/framework/components/chui_notification/notification.js +107 -69
- package/framework/components/chui_notification/notification_download.js +28 -77
- package/framework/components/chui_notification/notification_download_card.js +115 -0
- package/framework/components/chui_notification/notification_download_progress.css +5 -4
- package/framework/components/chui_notification/notification_download_progress.js +73 -105
- package/framework/components/chui_notification/notification_update.js +44 -37
- package/framework/components/chui_notification/status_plate.css +3 -3
- package/framework/components/chui_notification/status_plate.js +2 -2
- package/framework/components/chui_notification/styles.css +6 -1
- package/framework/components/chui_notification/styles_download.css +2 -2
- package/framework/components/chui_notification/styles_update.css +3 -3
- package/framework/components/chui_org_chart/org_chart.js +101 -62
- package/framework/components/chui_org_chart/styles.css +2 -2
- package/framework/components/chui_pagination/pagination.js +65 -30
- package/framework/components/chui_pagination/styles.css +1 -1
- package/framework/components/chui_paragraph/paragraph.js +2 -2
- package/framework/components/chui_paragraph/styles.css +3 -3
- package/framework/components/chui_popover/popover.js +77 -50
- package/framework/components/chui_popover/styles.css +1 -1
- package/framework/components/chui_popups/popups.js +210 -181
- package/framework/components/chui_popups/styles.css +7 -7
- package/framework/components/chui_print_button/print_button.js +48 -33
- package/framework/components/chui_progress_bar/progress_bar.js +49 -19
- package/framework/components/chui_progress_bar/styles.css +6 -6
- package/framework/components/chui_progress_ring/progress_ring.js +32 -30
- package/framework/components/chui_progress_ring/styles.css +1 -1
- package/framework/components/chui_qrcode/qrcode.js +85 -41
- package/framework/components/chui_query_builder/query_builder.js +263 -170
- package/framework/components/chui_query_builder/styles.css +4 -4
- package/framework/components/chui_radio_group/radio_group.js +36 -26
- package/framework/components/chui_radio_group/styles.css +2 -2
- package/framework/components/chui_result/result.js +41 -31
- package/framework/components/chui_result/styles.css +3 -3
- package/framework/components/chui_scheduler/scheduler.js +126 -104
- package/framework/components/chui_scheduler/styles.css +11 -7
- package/framework/components/chui_screen_spinner/screen_spinner.js +167 -0
- package/framework/components/chui_screen_spinner/styles.css +49 -0
- package/framework/components/chui_segmented_control/segmented_control.js +90 -27
- package/framework/components/chui_segmented_control/styles.css +32 -6
- package/framework/components/chui_settings/settings.js +160 -87
- package/framework/components/chui_settings/styles.css +4 -4
- package/framework/components/chui_shortcut_help/shortcut_help.js +82 -61
- package/framework/components/chui_sidebar_nav/sidebar_nav.js +132 -53
- package/framework/components/chui_sidebar_nav/styles.css +9 -3
- package/framework/components/chui_skeleton/skeleton.js +29 -24
- package/framework/components/chui_slideshow/slideshow.js +122 -103
- package/framework/components/chui_slideshow/styles.css +22 -16
- package/framework/components/chui_spinner/spinner.js +17 -17
- package/framework/components/chui_spinner/styles.css +0 -1
- package/framework/components/chui_split_button/split_button.js +53 -30
- package/framework/components/chui_split_button/styles.css +22 -6
- package/framework/components/chui_splitter/splitter.js +46 -39
- package/framework/components/chui_splitter/styles.css +2 -2
- package/framework/components/chui_statistic/statistic.js +111 -84
- package/framework/components/chui_status_bar/status_bar.js +11 -9
- package/framework/components/chui_status_bar/styles.css +2 -2
- package/framework/components/chui_stepper/stepper.js +230 -54
- package/framework/components/chui_stepper/styles.css +79 -14
- package/framework/components/chui_sticky_bar/sticky_bar.js +53 -17
- package/framework/components/chui_sticky_bar/styles.css +11 -7
- package/framework/components/chui_tabs/chui_tabs.js +100 -46
- package/framework/components/chui_tabs/styles.css +43 -15
- package/framework/components/chui_text_editor/styles.css +24 -23
- package/framework/components/chui_text_editor/text_editor.js +103 -79
- package/framework/components/chui_text_editor/text_editor_panel.js +428 -367
- package/framework/components/chui_theme_toggle/theme_toggle.js +46 -25
- package/framework/components/chui_timeline/styles.css +3 -1
- package/framework/components/chui_timeline/timeline.js +14 -12
- package/framework/components/chui_toast_queue/styles.css +11 -11
- package/framework/components/chui_toast_queue/toast_queue.js +82 -73
- package/framework/components/chui_toolbar/styles.css +2 -2
- package/framework/components/chui_toolbar/toolbar.js +20 -13
- package/framework/components/chui_tooltip/styles.css +2 -2
- package/framework/components/chui_tooltip/tooltip.js +40 -27
- package/framework/components/chui_tour/styles.css +12 -7
- package/framework/components/chui_tour/tour.js +132 -98
- package/framework/components/chui_transfer/styles.css +8 -7
- package/framework/components/chui_transfer/transfer.js +143 -123
- package/framework/components/chui_tree_table/styles.css +4 -4
- package/framework/components/chui_tree_table/tree_table.js +88 -74
- package/framework/components/chui_tree_view/styles.css +14 -10
- package/framework/components/chui_tree_view/tree_view.js +298 -253
- package/framework/components/chui_user_bar/styles.css +145 -0
- package/framework/components/chui_user_bar/user_bar.js +402 -0
- package/framework/components/chui_user_list_bar/styles.css +173 -0
- package/framework/components/chui_user_list_bar/user_list_bar.js +485 -0
- package/framework/components/chui_watermark/watermark.js +41 -33
- package/framework/components/chui_webview/styles.css +2 -2
- package/framework/components/chui_webview/webview.js +64 -52
- package/framework/components/chui_write_bar/styles.css +172 -0
- package/framework/components/chui_write_bar/write_bar.js +320 -0
- package/framework/main_window.js +1234 -0
- package/framework/modules/chui_a11y/chui_a11y.js +153 -123
- package/framework/modules/chui_animations/animations.js +105 -43
- package/framework/modules/chui_animations/motion.js +120 -0
- package/framework/modules/chui_animations/styles.css +37 -4
- package/framework/modules/chui_bridge/preload.js +36 -25
- package/framework/modules/chui_functions.js +69 -63
- package/framework/modules/chui_highlight/chui_highlight.js +25 -22
- package/framework/modules/chui_highlight/styles.css +13 -10
- package/framework/modules/chui_i18n/chui_i18n.js +12 -10
- 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 +65 -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 +12 -8
- package/framework/modules/chui_i18n/locales/validate.js +3 -3
- package/framework/modules/chui_json/chui_json.js +11 -11
- package/framework/modules/chui_layout/chui_layout.js +12 -10
- package/framework/modules/chui_logger/chui_logger.js +47 -28
- package/framework/modules/chui_page/page.js +39 -33
- package/framework/modules/chui_palette/palette.js +61 -0
- package/framework/modules/chui_qr/chui_qr.js +179 -88
- package/framework/modules/chui_scrollbar/chui_scrollbar.js +79 -68
- package/framework/modules/chui_scrollbar/styles.css +4 -2
- package/framework/modules/chui_services/chui_channels.js +27 -13
- package/framework/modules/chui_services/chui_services.js +47 -39
- package/framework/modules/chui_services/desktop.js +108 -101
- package/framework/modules/chui_sortable/chui_sortable.js +33 -28
- package/framework/modules/chui_validate/chui_validate.js +10 -7
- package/framework/tray_bar/chui_menu_items.js +136 -46
- package/index.d.ts +5046 -0
- package/index.js +199 -1254
- package/package.json +81 -68
- package/framework/components/telegram_bot/chui_telegram_bot.js +0 -184
|
@@ -2,76 +2,103 @@
|
|
|
2
2
|
|
|
3
3
|
class AcceptTypes {
|
|
4
4
|
//Изображения
|
|
5
|
-
static ALL_IMAGE = "image/*"
|
|
6
|
-
static PNG = "image/png"
|
|
7
|
-
static GIF = "image/gif"
|
|
8
|
-
static JPEG = "image/jpeg"
|
|
5
|
+
static ALL_IMAGE = "image/*";
|
|
6
|
+
static PNG = "image/png";
|
|
7
|
+
static GIF = "image/gif";
|
|
8
|
+
static JPEG = "image/jpeg";
|
|
9
9
|
//===========
|
|
10
10
|
//Аудио
|
|
11
|
-
static ALL_AUDIO = "audio/*"
|
|
11
|
+
static ALL_AUDIO = "audio/*";
|
|
12
12
|
//===========
|
|
13
13
|
//Видео
|
|
14
|
-
static ALL_VIDEO = "video/*"
|
|
14
|
+
static ALL_VIDEO = "video/*";
|
|
15
15
|
//===========
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
exports.AcceptTypes = AcceptTypes
|
|
18
|
+
exports.AcceptTypes = AcceptTypes;
|
|
19
19
|
|
|
20
20
|
class FileInput {
|
|
21
|
-
#
|
|
22
|
-
#
|
|
21
|
+
#chuiFileMain = document.createElement("chui_file_main");
|
|
22
|
+
#chuiFileInput = document.createElement("chui_file_input");
|
|
23
23
|
#id = require("randomstring").generate();
|
|
24
24
|
#title = String();
|
|
25
|
-
#input = document.createElement(
|
|
26
|
-
#label = document.createElement(
|
|
27
|
-
constructor(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
#input = document.createElement("input");
|
|
26
|
+
#label = document.createElement("label");
|
|
27
|
+
constructor(
|
|
28
|
+
options = {
|
|
29
|
+
name: String(),
|
|
30
|
+
title: String(),
|
|
31
|
+
accept: [],
|
|
32
|
+
required: Boolean(),
|
|
33
|
+
disableFocus: Boolean(),
|
|
34
|
+
multiple: Boolean(),
|
|
35
|
+
changeListener: () => {},
|
|
36
|
+
focusListener: () => {},
|
|
37
|
+
blurListener: () => {},
|
|
38
|
+
}
|
|
39
|
+
) {
|
|
40
|
+
require("../../../modules/chui_functions").setStyles(__dirname + "/styles.css", "chUiJS_fileInput");
|
|
41
|
+
this.#input.type = "file";
|
|
42
|
+
this.#input.className = "file_input";
|
|
35
43
|
this.#input.id = this.#id;
|
|
36
44
|
//Options
|
|
37
45
|
if (options.name !== undefined) this.#input.name = options.name;
|
|
38
|
-
if (options.changeListener !== undefined) this.#input.addEventListener(
|
|
39
|
-
if (options.focusListener !== undefined) this.#input.addEventListener(
|
|
40
|
-
if (options.blurListener !== undefined) this.#input.addEventListener(
|
|
46
|
+
if (options.changeListener !== undefined) this.#input.addEventListener("change", options.changeListener);
|
|
47
|
+
if (options.focusListener !== undefined) this.#input.addEventListener("focus", options.focusListener);
|
|
48
|
+
if (options.blurListener !== undefined) this.#input.addEventListener("blur", options.blurListener);
|
|
41
49
|
if (options.required !== undefined) this.#input.required = options.required;
|
|
42
|
-
if (options.disableFocus !== undefined)
|
|
50
|
+
if (options.disableFocus !== undefined)
|
|
51
|
+
this.#input.addEventListener("mousedown", () => {
|
|
52
|
+
return false;
|
|
53
|
+
});
|
|
43
54
|
if (options.accept) this.#input.accept = options.accept.join(", ");
|
|
44
55
|
if (options.multiple) this.#input.multiple = options.multiple;
|
|
45
56
|
if (options.title !== undefined) {
|
|
46
57
|
this.#title = options.title;
|
|
47
58
|
this.#label.innerText = options.title;
|
|
48
|
-
this.#label.className =
|
|
49
|
-
this.#label.setAttribute(
|
|
50
|
-
this.#
|
|
59
|
+
this.#label.className = "input_label";
|
|
60
|
+
this.#label.setAttribute("for", this.#id);
|
|
61
|
+
this.#chuiFileInput.appendChild(this.#label);
|
|
51
62
|
}
|
|
52
|
-
this.#
|
|
53
|
-
this.#
|
|
63
|
+
this.#chuiFileMain.appendChild(this.#input);
|
|
64
|
+
this.#chuiFileInput.appendChild(this.#chuiFileMain);
|
|
65
|
+
}
|
|
66
|
+
addChangeListener(listener = () => {}) {
|
|
67
|
+
this.#input.addEventListener("change", listener);
|
|
68
|
+
}
|
|
69
|
+
addFocusListener(listener = () => {}) {
|
|
70
|
+
this.#input.addEventListener("focus", listener);
|
|
71
|
+
}
|
|
72
|
+
addBlurListener(listener = () => {}) {
|
|
73
|
+
this.#input.addEventListener("blur", listener);
|
|
74
|
+
}
|
|
75
|
+
getName() {
|
|
76
|
+
return this.#input.name;
|
|
77
|
+
}
|
|
78
|
+
getTitle() {
|
|
79
|
+
return this.#title;
|
|
80
|
+
}
|
|
81
|
+
getFile(index = Number()) {
|
|
82
|
+
return this.#input.files[index];
|
|
83
|
+
}
|
|
84
|
+
getFiles() {
|
|
85
|
+
return this.#input.files;
|
|
54
86
|
}
|
|
55
|
-
addChangeListener(listener = () => {}) { this.#input.addEventListener('change', listener); }
|
|
56
|
-
addFocusListener(listener = () => {}) { this.#input.addEventListener('focus', listener); }
|
|
57
|
-
addBlurListener(listener = () => {}) { this.#input.addEventListener('blur', listener); }
|
|
58
|
-
getName() { return this.#input.name; }
|
|
59
|
-
getTitle() { return this.#title; }
|
|
60
|
-
getFile(index = Number()) { return this.#input.files[index]; }
|
|
61
|
-
getFiles() { return this.#input.files; }
|
|
62
87
|
setDisabled(value = Boolean()) {
|
|
63
|
-
this.#input.disabled = value
|
|
88
|
+
this.#input.disabled = value;
|
|
64
89
|
if (value) {
|
|
65
|
-
this.#
|
|
66
|
-
this.#input.className = "file_input_disabled"
|
|
67
|
-
this.#label.className = "input_label_disabled"
|
|
90
|
+
this.#chuiFileMain.classList.add("chui_file_main_disabled");
|
|
91
|
+
this.#input.className = "file_input_disabled";
|
|
92
|
+
this.#label.className = "input_label_disabled";
|
|
68
93
|
} else {
|
|
69
|
-
this.#
|
|
70
|
-
this.#input.className = "file_input"
|
|
71
|
-
this.#label.className = "input_label"
|
|
94
|
+
this.#chuiFileMain.classList.remove("chui_file_main_disabled");
|
|
95
|
+
this.#input.className = "file_input";
|
|
96
|
+
this.#label.className = "input_label";
|
|
72
97
|
}
|
|
73
98
|
}
|
|
74
|
-
set() {
|
|
99
|
+
set() {
|
|
100
|
+
return this.#chuiFileInput;
|
|
101
|
+
}
|
|
75
102
|
}
|
|
76
103
|
|
|
77
|
-
exports.FileInput = FileInput
|
|
104
|
+
exports.FileInput = FileInput;
|
|
@@ -4,12 +4,12 @@ chui_file_input {
|
|
|
4
4
|
карточку. Токены переопределены у корня поля, поэтому действуют только внутри него
|
|
5
5
|
(тот же приём у полосы меню-бара). */
|
|
6
6
|
--control_padding: var(--control_padding_sm);
|
|
7
|
-
--
|
|
7
|
+
--block_padding: var(--block_padding_sm);
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
10
10
|
width: max-content;
|
|
11
11
|
height: max-content;
|
|
12
|
-
margin: var(--
|
|
12
|
+
margin: var(--block_margin);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
chui_file_main {
|
|
@@ -17,7 +17,7 @@ chui_file_main {
|
|
|
17
17
|
width: max-content;
|
|
18
18
|
height: max-content;
|
|
19
19
|
margin: 0;
|
|
20
|
-
border-radius: var(--
|
|
20
|
+
border-radius: var(--radius_sm);
|
|
21
21
|
background: transparent;
|
|
22
22
|
color: var(--text_color);
|
|
23
23
|
border: none;
|
|
@@ -46,10 +46,10 @@ chui_file_main {
|
|
|
46
46
|
cursor: not-allowed;
|
|
47
47
|
height: max-content;
|
|
48
48
|
width: max-content;
|
|
49
|
-
margin: 0 0 var(--
|
|
49
|
+
margin: 0 0 var(--block_margin);
|
|
50
50
|
font-size: var(--font_labels_size);
|
|
51
|
-
font-weight:500;
|
|
52
|
-
color: var(--text_color_disabled)
|
|
51
|
+
font-weight: 500;
|
|
52
|
+
color: var(--text_color_disabled);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.file_input {
|
|
@@ -65,42 +65,46 @@ chui_file_main {
|
|
|
65
65
|
.input_label {
|
|
66
66
|
height: max-content;
|
|
67
67
|
width: max-content;
|
|
68
|
-
margin: 0 0 var(--
|
|
68
|
+
margin: 0 0 var(--block_margin);
|
|
69
69
|
font-size: var(--font_labels_size);
|
|
70
|
-
font-weight:500;
|
|
71
|
-
color: var(--text_color)
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
color: var(--text_color);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
input[type=file]::file-selector-button {
|
|
74
|
+
input[type="file"]::file-selector-button {
|
|
75
75
|
cursor: pointer;
|
|
76
76
|
height: max-content;
|
|
77
77
|
width: max-content;
|
|
78
|
-
border-radius: var(--
|
|
79
|
-
padding: var(--
|
|
78
|
+
border-radius: var(--radius_sm);
|
|
79
|
+
padding: var(--block_padding);
|
|
80
80
|
font-size: var(--font_default_size);
|
|
81
81
|
font-weight: 400;
|
|
82
|
-
margin-block: 0 0;
|
|
82
|
+
margin-block: 0 0;
|
|
83
|
+
margin-inline: 0 var(--block_margin);
|
|
83
84
|
color: var(--text_color);
|
|
84
|
-
transition:
|
|
85
|
-
|
|
85
|
+
transition:
|
|
86
|
+
background-color var(--motion_fast) var(--motion_ease),
|
|
87
|
+
color var(--motion_fast) var(--motion_ease),
|
|
88
|
+
border-color var(--motion_fast) var(--motion_ease);
|
|
89
|
+
font-family: "chui_I";
|
|
86
90
|
background: var(--button_background);
|
|
87
91
|
border: 1px solid var(--button_border_color);
|
|
88
92
|
}
|
|
89
93
|
|
|
90
|
-
input[type=file]::file-selector-button:hover {
|
|
94
|
+
input[type="file"]::file-selector-button:hover {
|
|
91
95
|
background: var(--element_background_hover);
|
|
92
96
|
color: var(--text_color);
|
|
93
97
|
border: 1px solid var(--button_border_color_hover);
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
input[type=file]:disabled::file-selector-button {
|
|
100
|
+
input[type="file"]:disabled::file-selector-button {
|
|
97
101
|
cursor: not-allowed;
|
|
98
102
|
color: var(--text_color_disabled);
|
|
99
103
|
background: var(--button_background_disabled);
|
|
100
104
|
border: 1px solid var(--border_color);
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
input[type=file]:disabled::file-selector-button:hover {
|
|
107
|
+
input[type="file"]:disabled::file-selector-button:hover {
|
|
104
108
|
background: var(--button_background_disabled);
|
|
105
109
|
color: var(--text_color_disabled);
|
|
106
|
-
}
|
|
110
|
+
}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
const {setStyles, optionOr} = require(
|
|
2
|
-
const {Kbd} = require(
|
|
3
|
-
const {Icon, Icons} = require(
|
|
4
|
-
const {Validate} = require(
|
|
5
|
-
const {I18n} = require(
|
|
1
|
+
const { setStyles, optionOr } = require("../../../modules/chui_functions");
|
|
2
|
+
const { Kbd } = require("../../chui_kbd/kbd");
|
|
3
|
+
const { Icon, Icons } = require("../../chui_icons/icons");
|
|
4
|
+
const { Validate } = require("../../../modules/chui_validate/chui_validate");
|
|
5
|
+
const { I18n } = require("../../../modules/chui_i18n/chui_i18n");
|
|
6
6
|
|
|
7
7
|
// Канонический вид сочетания: только буквы, цифры и «+» между клавишами
|
|
8
8
|
const HOTKEY_PATTERN = "^[A-Za-z0-9]+(\\+[A-Za-z0-9]+)*$";
|
|
9
9
|
/** Порядок модификаторов в записи сочетания — один и тот же, как его ни набери */
|
|
10
10
|
const MODIFIER_ORDER = ["Ctrl", "Alt", "Shift", "Meta"];
|
|
11
11
|
const MODIFIER_ALIASES = {
|
|
12
|
-
ctrl: "Ctrl",
|
|
13
|
-
|
|
12
|
+
ctrl: "Ctrl",
|
|
13
|
+
control: "Ctrl",
|
|
14
|
+
alt: "Alt",
|
|
15
|
+
option: "Alt",
|
|
14
16
|
shift: "Shift",
|
|
15
|
-
meta: "Meta",
|
|
17
|
+
meta: "Meta",
|
|
18
|
+
cmd: "Meta",
|
|
19
|
+
command: "Meta",
|
|
20
|
+
super: "Meta",
|
|
21
|
+
win: "Meta",
|
|
16
22
|
};
|
|
17
23
|
// Как эти же клавиши называет ARIA в aria-keyshortcuts
|
|
18
|
-
const ARIA_MODIFIERS = {Ctrl: "Control", Alt: "Alt", Shift: "Shift", Meta: "Meta"};
|
|
19
|
-
const KEY_ALIASES = {space: "Space", enter: "Enter", return: "Enter", tab: "Tab", escape: "Escape", esc: "Escape"};
|
|
24
|
+
const ARIA_MODIFIERS = { Ctrl: "Control", Alt: "Alt", Shift: "Shift", Meta: "Meta" };
|
|
25
|
+
const KEY_ALIASES = { space: "Space", enter: "Enter", return: "Enter", tab: "Tab", escape: "Escape", esc: "Escape" };
|
|
20
26
|
|
|
21
27
|
/**
|
|
22
28
|
* Поле горячей клавиши: нажатое сочетание записывается в значение.
|
|
@@ -53,41 +59,43 @@ class HotkeyInput {
|
|
|
53
59
|
#row = document.createElement("hotkey_row");
|
|
54
60
|
#field = document.createElement("hotkey_field");
|
|
55
61
|
#kbd = undefined;
|
|
56
|
-
#
|
|
62
|
+
#clearButton = document.createElement("button");
|
|
57
63
|
#hint = document.createElement("hotkey_hint");
|
|
58
64
|
#status = document.createElement("hotkey_status");
|
|
59
65
|
#id = undefined;
|
|
60
66
|
#name = undefined;
|
|
61
|
-
#
|
|
62
|
-
#
|
|
67
|
+
#titleText = undefined;
|
|
68
|
+
#labelText = undefined;
|
|
63
69
|
#value = "";
|
|
64
|
-
#
|
|
65
|
-
#
|
|
70
|
+
#allowSingle = false;
|
|
71
|
+
#readOnly = false;
|
|
66
72
|
#disabled = false;
|
|
67
73
|
#listeners = [];
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
constructor(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
#onChange = undefined;
|
|
75
|
+
|
|
76
|
+
constructor(
|
|
77
|
+
options = {
|
|
78
|
+
id: String(),
|
|
79
|
+
name: String(),
|
|
80
|
+
title: String(),
|
|
81
|
+
label: String(),
|
|
82
|
+
hint: String(),
|
|
83
|
+
value: String(),
|
|
84
|
+
allowSingle: Boolean(),
|
|
85
|
+
readOnly: Boolean(),
|
|
86
|
+
disabled: Boolean(),
|
|
87
|
+
size: String(),
|
|
88
|
+
changeListener: undefined,
|
|
89
|
+
onChange: undefined,
|
|
90
|
+
}
|
|
91
|
+
) {
|
|
84
92
|
setStyles(__dirname + "/styles.css", "chUiJS_HotkeyInput");
|
|
85
93
|
HotkeyInput.#counter += 1;
|
|
86
94
|
this.#id = options.id === undefined ? `chui_hotkey_input_${HotkeyInput.#counter}` : options.id;
|
|
87
95
|
this.#name = options.name;
|
|
88
|
-
this.#
|
|
89
|
-
this.#
|
|
90
|
-
this.#
|
|
96
|
+
this.#labelText = options.label;
|
|
97
|
+
this.#allowSingle = options.allowSingle === true;
|
|
98
|
+
this.#onChange = options.onChange;
|
|
91
99
|
if (options.changeListener !== undefined) this.addChangeListener(options.changeListener);
|
|
92
100
|
this.#root.id = this.#id;
|
|
93
101
|
this.#label.className = "hotkey_label";
|
|
@@ -99,34 +107,32 @@ class HotkeyInput {
|
|
|
99
107
|
this.#field.addEventListener("keydown", this.#onKeyDown);
|
|
100
108
|
this.#field.addEventListener("focus", () => this.#field.classList.add("hotkey_field_focused"));
|
|
101
109
|
this.#field.addEventListener("blur", () => this.#field.classList.remove("hotkey_field_focused"));
|
|
102
|
-
this.#kbd = new Kbd({keys: []});
|
|
110
|
+
this.#kbd = new Kbd({ keys: [] });
|
|
103
111
|
const keys = this.#kbd.set();
|
|
104
112
|
// Клавиши — внешний вид: имя и значение несёт само поле
|
|
105
113
|
keys.setAttribute("aria-hidden", "true");
|
|
106
114
|
this.#field.appendChild(keys);
|
|
107
|
-
this.#
|
|
108
|
-
this.#
|
|
109
|
-
this.#
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
this.#
|
|
113
|
-
this.#
|
|
115
|
+
this.#clearButton.type = "button";
|
|
116
|
+
this.#clearButton.className = "hotkey_clear";
|
|
117
|
+
this.#clearButton.setAttribute("aria-label", I18n.t("forms.hotkeyClear"));
|
|
118
|
+
const clearIcon = new Icon(Icons.NAVIGATION.CLOSE).set();
|
|
119
|
+
clearIcon.setAttribute("aria-hidden", "true");
|
|
120
|
+
this.#clearButton.appendChild(clearIcon);
|
|
121
|
+
this.#clearButton.addEventListener("click", () => {
|
|
114
122
|
if (this.#disabled) return;
|
|
115
123
|
this.#apply("", true);
|
|
116
124
|
this.#field.focus();
|
|
117
125
|
});
|
|
118
126
|
this.#hint.id = `${this.#id}_hint`;
|
|
119
127
|
this.#hint.className = "hotkey_hint";
|
|
120
|
-
this.#hint.innerText = options.hint === undefined
|
|
121
|
-
? I18n.t("forms.hotkeyHint")
|
|
122
|
-
: String(options.hint);
|
|
128
|
+
this.#hint.innerText = options.hint === undefined ? I18n.t("forms.hotkeyHint") : String(options.hint);
|
|
123
129
|
this.#field.setAttribute("aria-describedby", this.#hint.id);
|
|
124
130
|
// Единственный live-регион: без него о записи узнать неоткуда
|
|
125
131
|
this.#status.classList.add("chui_visually_hidden");
|
|
126
132
|
this.#status.setAttribute("role", "status");
|
|
127
133
|
this.#status.setAttribute("aria-live", "polite");
|
|
128
134
|
this.#row.appendChild(this.#field);
|
|
129
|
-
this.#row.appendChild(this.#
|
|
135
|
+
this.#row.appendChild(this.#clearButton);
|
|
130
136
|
if (options.title !== undefined) this.setTitle(options.title);
|
|
131
137
|
else this.#label.hidden = true;
|
|
132
138
|
this.#root.appendChild(this.#label);
|
|
@@ -134,8 +140,14 @@ class HotkeyInput {
|
|
|
134
140
|
this.#root.appendChild(this.#hint);
|
|
135
141
|
this.#root.appendChild(this.#status);
|
|
136
142
|
this.setLabel(optionOr(options.label, I18n.t("forms.hotkeyLabel")));
|
|
137
|
-
Validate.installField(
|
|
138
|
-
|
|
143
|
+
Validate.installField(
|
|
144
|
+
this,
|
|
145
|
+
Object.assign({ pattern: HOTKEY_PATTERN }, options),
|
|
146
|
+
this.#root,
|
|
147
|
+
undefined,
|
|
148
|
+
() => this.#value,
|
|
149
|
+
this.#field
|
|
150
|
+
);
|
|
139
151
|
if (options.value !== undefined && options.value !== "") this.setValue(options.value);
|
|
140
152
|
this.setReadOnly(options.readOnly === true);
|
|
141
153
|
this.setDisabled(options.disabled === true);
|
|
@@ -152,12 +164,12 @@ class HotkeyInput {
|
|
|
152
164
|
}
|
|
153
165
|
|
|
154
166
|
getTitle() {
|
|
155
|
-
return this.#
|
|
167
|
+
return this.#titleText;
|
|
156
168
|
}
|
|
157
169
|
|
|
158
170
|
/** Доступное имя поля, заданное в `label` */
|
|
159
171
|
getLabel() {
|
|
160
|
-
return this.#
|
|
172
|
+
return this.#labelText;
|
|
161
173
|
}
|
|
162
174
|
|
|
163
175
|
/** Сочетание в каноническом виде («Ctrl+Shift+S»); пустая строка — не задано */
|
|
@@ -175,11 +187,11 @@ class HotkeyInput {
|
|
|
175
187
|
}
|
|
176
188
|
|
|
177
189
|
isReadOnly() {
|
|
178
|
-
return this.#
|
|
190
|
+
return this.#readOnly;
|
|
179
191
|
}
|
|
180
192
|
|
|
181
193
|
isAllowSingle() {
|
|
182
|
-
return this.#
|
|
194
|
+
return this.#allowSingle;
|
|
183
195
|
}
|
|
184
196
|
|
|
185
197
|
/**
|
|
@@ -189,7 +201,10 @@ class HotkeyInput {
|
|
|
189
201
|
*/
|
|
190
202
|
static parse(value = String()) {
|
|
191
203
|
if (typeof value !== "string") return undefined;
|
|
192
|
-
const parts = value
|
|
204
|
+
const parts = value
|
|
205
|
+
.split("+")
|
|
206
|
+
.map((part) => part.trim())
|
|
207
|
+
.filter((part) => part !== "");
|
|
193
208
|
const modifiers = [];
|
|
194
209
|
let main = undefined;
|
|
195
210
|
for (const part of parts) {
|
|
@@ -204,7 +219,9 @@ class HotkeyInput {
|
|
|
204
219
|
}
|
|
205
220
|
// Одни модификаторы — ещё не сочетание
|
|
206
221
|
if (main === undefined) return undefined;
|
|
207
|
-
return MODIFIER_ORDER.filter((modifier) => modifiers.includes(modifier))
|
|
222
|
+
return MODIFIER_ORDER.filter((modifier) => modifiers.includes(modifier))
|
|
223
|
+
.concat(main)
|
|
224
|
+
.join("+");
|
|
208
225
|
}
|
|
209
226
|
|
|
210
227
|
// SET
|
|
@@ -221,7 +238,7 @@ class HotkeyInput {
|
|
|
221
238
|
|
|
222
239
|
/** Подпись над полем; `undefined` её убирает */
|
|
223
240
|
setTitle(text = undefined) {
|
|
224
|
-
this.#
|
|
241
|
+
this.#titleText = text;
|
|
225
242
|
this.#label.id = `${this.#id}_label`;
|
|
226
243
|
if (text === undefined || text === "") {
|
|
227
244
|
this.#label.hidden = true;
|
|
@@ -241,8 +258,8 @@ class HotkeyInput {
|
|
|
241
258
|
|
|
242
259
|
/** Доступное имя поля, когда подписи в разметке нет */
|
|
243
260
|
setLabel(text = undefined) {
|
|
244
|
-
this.#
|
|
245
|
-
if (this.#
|
|
261
|
+
this.#labelText = text;
|
|
262
|
+
if (this.#titleText === undefined || this.#titleText === "") {
|
|
246
263
|
if (text === undefined) this.#field.removeAttribute("aria-label");
|
|
247
264
|
else this.#field.setAttribute("aria-label", String(text));
|
|
248
265
|
}
|
|
@@ -281,15 +298,15 @@ class HotkeyInput {
|
|
|
281
298
|
|
|
282
299
|
/** Разрешить одиночные клавиши без модификаторов (`F5`, `A`) */
|
|
283
300
|
setAllowSingle(allow = Boolean()) {
|
|
284
|
-
this.#
|
|
301
|
+
this.#allowSingle = allow === true;
|
|
285
302
|
return this;
|
|
286
303
|
}
|
|
287
304
|
|
|
288
305
|
/** Режим показа: сочетание видно, но поле не принимает фокус и нажатия */
|
|
289
|
-
setReadOnly(
|
|
290
|
-
this.#
|
|
291
|
-
this.#root.classList.toggle("hotkey_readonly", this.#
|
|
292
|
-
if (this.#
|
|
306
|
+
setReadOnly(readOnly = Boolean()) {
|
|
307
|
+
this.#readOnly = readOnly === true;
|
|
308
|
+
this.#root.classList.toggle("hotkey_readonly", this.#readOnly);
|
|
309
|
+
if (this.#readOnly) {
|
|
293
310
|
this.#field.removeAttribute("tabindex");
|
|
294
311
|
this.#hint.hidden = true;
|
|
295
312
|
this.#field.removeAttribute("aria-describedby");
|
|
@@ -313,11 +330,11 @@ class HotkeyInput {
|
|
|
313
330
|
if (this.#disabled) {
|
|
314
331
|
this.#field.setAttribute("tabindex", "-1");
|
|
315
332
|
this.#field.setAttribute("aria-disabled", "true");
|
|
316
|
-
this.#
|
|
333
|
+
this.#clearButton.disabled = true;
|
|
317
334
|
} else {
|
|
318
335
|
this.#field.removeAttribute("aria-disabled");
|
|
319
|
-
this.#
|
|
320
|
-
if (!this.#
|
|
336
|
+
this.#clearButton.disabled = false;
|
|
337
|
+
if (!this.#readOnly) this.#field.setAttribute("tabindex", "0");
|
|
321
338
|
}
|
|
322
339
|
this.#render();
|
|
323
340
|
return this;
|
|
@@ -331,7 +348,7 @@ class HotkeyInput {
|
|
|
331
348
|
|
|
332
349
|
/** Фокус на поле: `Form` зовёт это при ошибке валидации */
|
|
333
350
|
focus() {
|
|
334
|
-
if (!this.#disabled && !this.#
|
|
351
|
+
if (!this.#disabled && !this.#readOnly) this.#field.focus();
|
|
335
352
|
return this;
|
|
336
353
|
}
|
|
337
354
|
|
|
@@ -342,8 +359,8 @@ class HotkeyInput {
|
|
|
342
359
|
|
|
343
360
|
// === ВНУТРЕННЕЕ ===
|
|
344
361
|
#accessibleName() {
|
|
345
|
-
if (this.#
|
|
346
|
-
if (this.#
|
|
362
|
+
if (this.#titleText !== undefined && this.#titleText !== "") return this.#titleText;
|
|
363
|
+
if (this.#labelText !== undefined && this.#labelText !== "") return this.#labelText;
|
|
347
364
|
return I18n.t("forms.hotkeyLabel");
|
|
348
365
|
}
|
|
349
366
|
|
|
@@ -354,9 +371,13 @@ class HotkeyInput {
|
|
|
354
371
|
this.#value = value;
|
|
355
372
|
this.#render();
|
|
356
373
|
if (!changed || notify !== true) return;
|
|
357
|
-
this.#announce(
|
|
374
|
+
this.#announce(
|
|
375
|
+
value === ""
|
|
376
|
+
? I18n.t("forms.hotkeyCleared")
|
|
377
|
+
: I18n.t("forms.hotkeyRecorded", { value: value.split("+").join(" + ") })
|
|
378
|
+
);
|
|
358
379
|
for (const listener of [...this.#listeners]) listener(value, this);
|
|
359
|
-
if (this.#
|
|
380
|
+
if (this.#onChange !== undefined) this.#onChange(value, this);
|
|
360
381
|
}
|
|
361
382
|
|
|
362
383
|
#render() {
|
|
@@ -365,13 +386,15 @@ class HotkeyInput {
|
|
|
365
386
|
keys.setAttribute("aria-hidden", "true");
|
|
366
387
|
if (this.#value === "") this.#field.removeAttribute("aria-keyshortcuts");
|
|
367
388
|
else this.#field.setAttribute("aria-keyshortcuts", this.#ariaShortcut());
|
|
368
|
-
this.#
|
|
389
|
+
this.#clearButton.hidden = this.#value === "" || this.#readOnly;
|
|
369
390
|
this.#field.classList.toggle("hotkey_field_empty", this.#value === "");
|
|
370
391
|
}
|
|
371
392
|
|
|
372
393
|
// Синтаксис ARIA: модификаторы называются Control, Meta и т.д.
|
|
373
394
|
#ariaShortcut() {
|
|
374
|
-
return this.getKeys()
|
|
395
|
+
return this.getKeys()
|
|
396
|
+
.map((key) => (ARIA_MODIFIERS[key] === undefined ? key : ARIA_MODIFIERS[key]))
|
|
397
|
+
.join("+");
|
|
375
398
|
}
|
|
376
399
|
|
|
377
400
|
#announce(text = String()) {
|
|
@@ -379,7 +402,7 @@ class HotkeyInput {
|
|
|
379
402
|
}
|
|
380
403
|
|
|
381
404
|
#onKeyDown = (event) => {
|
|
382
|
-
if (this.#disabled || this.#
|
|
405
|
+
if (this.#disabled || this.#readOnly) return;
|
|
383
406
|
// Tab не перехватываем: иначе поле нельзя было бы покинуть
|
|
384
407
|
if (event.key === "Tab") return;
|
|
385
408
|
// Escape, Delete и Backspace снимают сочетание, поэтому связать их нельзя
|
|
@@ -398,10 +421,12 @@ class HotkeyInput {
|
|
|
398
421
|
const main = HotkeyInput.#canonicalKey(event.key);
|
|
399
422
|
if (main === undefined) {
|
|
400
423
|
// Нажаты только модификаторы: ждём основную клавишу
|
|
401
|
-
this.#announce(
|
|
424
|
+
this.#announce(
|
|
425
|
+
modifiers.length === 0 ? "" : I18n.t("forms.hotkeyModifiers", { value: modifiers.join(" + ") })
|
|
426
|
+
);
|
|
402
427
|
return;
|
|
403
428
|
}
|
|
404
|
-
if (modifiers.length === 0 && !this.#
|
|
429
|
+
if (modifiers.length === 0 && !this.#allowSingle) {
|
|
405
430
|
event.preventDefault();
|
|
406
431
|
this.#announce(I18n.t("forms.hotkeyNeedModifier"));
|
|
407
432
|
return;
|
|
@@ -426,4 +451,4 @@ class HotkeyInput {
|
|
|
426
451
|
}
|
|
427
452
|
}
|
|
428
453
|
|
|
429
|
-
exports.HotkeyInput = HotkeyInput
|
|
454
|
+
exports.HotkeyInput = HotkeyInput;
|
|
@@ -5,20 +5,20 @@ chui_hotkey_input {
|
|
|
5
5
|
карточку. Токены переопределены у корня поля, поэтому действуют только внутри него
|
|
6
6
|
(тот же приём у полосы меню-бара). */
|
|
7
7
|
--control_padding: var(--control_padding_sm);
|
|
8
|
-
--
|
|
8
|
+
--block_padding: var(--block_padding_sm);
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
width: max-content;
|
|
12
12
|
max-width: 100%;
|
|
13
|
-
margin: var(--
|
|
13
|
+
margin: var(--block_margin);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.hotkey_label {
|
|
17
17
|
display: block;
|
|
18
18
|
width: max-content;
|
|
19
|
-
/* Только нижний отступ: верхний и боковые уже даёт корень поля (--
|
|
19
|
+
/* Только нижний отступ: верхний и боковые уже даёт корень поля (--block_margin), а свой
|
|
20
20
|
боковой отступ сдвигал подпись вправо от коробки поля */
|
|
21
|
-
margin: 0 0 var(--
|
|
21
|
+
margin: 0 0 var(--block_margin);
|
|
22
22
|
color: var(--text_color);
|
|
23
23
|
font-size: var(--font_labels_size);
|
|
24
24
|
font-weight: 500;
|
|
@@ -34,7 +34,7 @@ chui_hotkey_input {
|
|
|
34
34
|
gap: 8px;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/* Поле — та же коробка, что у текстового поля: --control_height, hairline и --
|
|
37
|
+
/* Поле — та же коробка, что у текстового поля: --control_height, hairline и --radius_sm */
|
|
38
38
|
.hotkey_field {
|
|
39
39
|
display: flex;
|
|
40
40
|
align-items: center;
|
|
@@ -43,7 +43,7 @@ chui_hotkey_input {
|
|
|
43
43
|
min-height: var(--control_height);
|
|
44
44
|
padding: 3px 10px;
|
|
45
45
|
border: 1px solid var(--border_color);
|
|
46
|
-
border-radius: var(--
|
|
46
|
+
border-radius: var(--radius_sm);
|
|
47
47
|
background: var(--element_background);
|
|
48
48
|
color: var(--text_color);
|
|
49
49
|
cursor: text;
|