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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const {setStyles, optionOr} = require(
|
|
2
|
-
const {I18n} = require(
|
|
1
|
+
const { setStyles, optionOr } = require("../../modules/chui_functions");
|
|
2
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Канбан-доска: колонки со карточками и переносом между ними.
|
|
@@ -37,25 +37,27 @@ class Kanban {
|
|
|
37
37
|
static #counter = 0;
|
|
38
38
|
|
|
39
39
|
#root = document.createElement("chui_kanban");
|
|
40
|
-
#
|
|
40
|
+
#columnsBox = document.createElement("kanban_columns");
|
|
41
41
|
#status = document.createElement("kanban_status");
|
|
42
42
|
#id = undefined;
|
|
43
43
|
#columns = [];
|
|
44
44
|
#draggable = true;
|
|
45
45
|
#label = I18n.t("graphics.kanbanBoard");
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
constructor(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
46
|
+
#onCardMove = undefined;
|
|
47
|
+
#onCardClick = undefined;
|
|
48
|
+
#dragCard = undefined;
|
|
49
|
+
#dragColumn = undefined;
|
|
50
|
+
|
|
51
|
+
constructor(
|
|
52
|
+
options = {
|
|
53
|
+
id: String(),
|
|
54
|
+
columns: [],
|
|
55
|
+
draggable: Boolean(),
|
|
56
|
+
label: String(),
|
|
57
|
+
onCardMove: undefined,
|
|
58
|
+
onCardClick: undefined,
|
|
59
|
+
}
|
|
60
|
+
) {
|
|
59
61
|
setStyles(__dirname + "/styles.css", "chUiJS_Kanban");
|
|
60
62
|
Kanban.#counter += 1;
|
|
61
63
|
this.#id = options.id === undefined ? `chui_kanban_${Kanban.#counter}` : options.id;
|
|
@@ -63,14 +65,14 @@ class Kanban {
|
|
|
63
65
|
this.#root.setAttribute("role", "region");
|
|
64
66
|
this.#draggable = options.draggable !== false;
|
|
65
67
|
this.#root.classList.toggle("kanban_disabled", !this.#draggable);
|
|
66
|
-
this.#
|
|
67
|
-
this.#
|
|
68
|
+
this.#onCardMove = options.onCardMove;
|
|
69
|
+
this.#onCardClick = options.onCardClick;
|
|
68
70
|
this.setLabel(optionOr(options.label, this.#label));
|
|
69
71
|
this.#columns = Kanban.#normalize(options.columns);
|
|
70
72
|
this.#status.classList.add("chui_visually_hidden");
|
|
71
73
|
this.#status.setAttribute("role", "status");
|
|
72
74
|
this.#status.setAttribute("aria-live", "polite");
|
|
73
|
-
this.#root.appendChild(this.#
|
|
75
|
+
this.#root.appendChild(this.#columnsBox);
|
|
74
76
|
this.#root.appendChild(this.#status);
|
|
75
77
|
this.#root.addEventListener("click", this.#onClick);
|
|
76
78
|
this.#root.addEventListener("keydown", this.#onKeyDown);
|
|
@@ -90,7 +92,7 @@ class Kanban {
|
|
|
90
92
|
|
|
91
93
|
/** Колонки с карточками (копия данных) */
|
|
92
94
|
getColumns() {
|
|
93
|
-
return this.#columns.map((column) => ({...column, cards: column.cards.map((card) => ({...card}))}));
|
|
95
|
+
return this.#columns.map((column) => ({ ...column, cards: column.cards.map((card) => ({ ...card })) }));
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
getColumn(id = String()) {
|
|
@@ -99,13 +101,13 @@ class Kanban {
|
|
|
99
101
|
|
|
100
102
|
getCards(columnId = String()) {
|
|
101
103
|
const column = this.getColumn(columnId);
|
|
102
|
-
return column === undefined ? [] : column.cards.map((card) => ({...card}));
|
|
104
|
+
return column === undefined ? [] : column.cards.map((card) => ({ ...card }));
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
getCard(id = undefined) {
|
|
106
108
|
for (const column of this.#columns) {
|
|
107
109
|
const card = column.cards.find((item) => String(item.id) === String(id));
|
|
108
|
-
if (card !== undefined) return {...card};
|
|
110
|
+
if (card !== undefined) return { ...card };
|
|
109
111
|
}
|
|
110
112
|
return undefined;
|
|
111
113
|
}
|
|
@@ -146,7 +148,7 @@ class Kanban {
|
|
|
146
148
|
const column = this.getColumn(columnId);
|
|
147
149
|
if (column === undefined) return this;
|
|
148
150
|
const position = index === undefined ? column.cards.length : Math.max(0, Math.min(index, column.cards.length));
|
|
149
|
-
column.cards.splice(position, 0, {...card});
|
|
151
|
+
column.cards.splice(position, 0, { ...card });
|
|
150
152
|
this.#render();
|
|
151
153
|
return this;
|
|
152
154
|
}
|
|
@@ -182,19 +184,19 @@ class Kanban {
|
|
|
182
184
|
if (!Array.isArray(columns)) return [];
|
|
183
185
|
return columns.map((column, index) => ({
|
|
184
186
|
id: column.id === undefined ? `column_${index}` : column.id,
|
|
185
|
-
title: column.title === undefined ? I18n.t("graphics.kanbanColumn", {index: index + 1}) : column.title,
|
|
187
|
+
title: column.title === undefined ? I18n.t("graphics.kanbanColumn", { index: index + 1 }) : column.title,
|
|
186
188
|
limit: column.limit,
|
|
187
189
|
cards: (column.cards === undefined ? [] : column.cards).map((card, position) => ({
|
|
188
190
|
id: card.id === undefined ? `card_${index}_${position}` : card.id,
|
|
189
|
-
...card
|
|
190
|
-
}))
|
|
191
|
+
...card,
|
|
192
|
+
})),
|
|
191
193
|
}));
|
|
192
194
|
}
|
|
193
195
|
|
|
194
196
|
#findCard(cardId = undefined) {
|
|
195
197
|
for (const column of this.#columns) {
|
|
196
198
|
const index = column.cards.findIndex((card) => String(card.id) === String(cardId));
|
|
197
|
-
if (index !== -1) return {column: column, index: index, card: column.cards[index]};
|
|
199
|
+
if (index !== -1) return { column: column, index: index, card: column.cards[index] };
|
|
198
200
|
}
|
|
199
201
|
return undefined;
|
|
200
202
|
}
|
|
@@ -217,7 +219,7 @@ class Kanban {
|
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
#emitMove(card = Object(), from = String(), to = String(), index = Number()) {
|
|
220
|
-
if (this.#
|
|
222
|
+
if (this.#onCardMove !== undefined) this.#onCardMove(card, { from: from, to: to, index: index });
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
#announce(text = String()) {
|
|
@@ -227,22 +229,23 @@ class Kanban {
|
|
|
227
229
|
#cardLabel(column = Object(), card = Object()) {
|
|
228
230
|
const parts = [card.title === undefined ? I18n.t("graphics.kanbanCard") : String(card.title)];
|
|
229
231
|
if (card.description !== undefined) parts.push(String(card.description));
|
|
230
|
-
if (Array.isArray(card.tags) && card.tags.length > 0)
|
|
231
|
-
|
|
232
|
+
if (Array.isArray(card.tags) && card.tags.length > 0)
|
|
233
|
+
parts.push(I18n.t("graphics.kanbanTags", { value: card.tags.join(", ") }));
|
|
234
|
+
parts.push(I18n.t("graphics.kanbanColumnOf", { value: column.title }));
|
|
232
235
|
return parts.join(", ");
|
|
233
236
|
}
|
|
234
237
|
|
|
235
238
|
#columnLabel(column = Object()) {
|
|
236
239
|
const count = column.cards.length;
|
|
237
240
|
return column.limit === undefined
|
|
238
|
-
? I18n.t("graphics.kanbanColumnCount", {title: column.title, count: count})
|
|
239
|
-
: I18n.t("graphics.kanbanColumnCountLimit", {title: column.title, count: count, limit: column.limit});
|
|
241
|
+
? I18n.t("graphics.kanbanColumnCount", { title: column.title, count: count })
|
|
242
|
+
: I18n.t("graphics.kanbanColumnCountLimit", { title: column.title, count: count, limit: column.limit });
|
|
240
243
|
}
|
|
241
244
|
|
|
242
245
|
#render() {
|
|
243
|
-
this.#
|
|
246
|
+
this.#columnsBox.innerHTML = "";
|
|
244
247
|
for (const column of this.#columns) {
|
|
245
|
-
this.#
|
|
248
|
+
this.#columnsBox.appendChild(this.#createColumn(column));
|
|
246
249
|
}
|
|
247
250
|
}
|
|
248
251
|
|
|
@@ -256,7 +259,8 @@ class Kanban {
|
|
|
256
259
|
const title = document.createElement("kanban_column_title");
|
|
257
260
|
title.innerText = column.title;
|
|
258
261
|
const count = document.createElement("kanban_column_count");
|
|
259
|
-
count.innerText =
|
|
262
|
+
count.innerText =
|
|
263
|
+
column.limit === undefined ? String(column.cards.length) : `${column.cards.length} / ${column.limit}`;
|
|
260
264
|
head.appendChild(title);
|
|
261
265
|
head.appendChild(count);
|
|
262
266
|
node.appendChild(head);
|
|
@@ -305,8 +309,8 @@ class Kanban {
|
|
|
305
309
|
const target = event.target instanceof Element ? event.target : null;
|
|
306
310
|
if (target === null) return undefined;
|
|
307
311
|
const node = target.closest("kanban_column");
|
|
308
|
-
if (node === null || !this.#
|
|
309
|
-
return {node: node, column: this.getColumn(node.dataset.column)};
|
|
312
|
+
if (node === null || !this.#columnsBox.contains(node)) return undefined;
|
|
313
|
+
return { node: node, column: this.getColumn(node.dataset.column) };
|
|
310
314
|
}
|
|
311
315
|
|
|
312
316
|
/** Карточка под элементом */
|
|
@@ -314,7 +318,7 @@ class Kanban {
|
|
|
314
318
|
const target = event.target instanceof Element ? event.target : null;
|
|
315
319
|
if (target === null) return undefined;
|
|
316
320
|
const node = target.closest(".kanban_card");
|
|
317
|
-
if (node === null || !this.#
|
|
321
|
+
if (node === null || !this.#columnsBox.contains(node)) return undefined;
|
|
318
322
|
return node;
|
|
319
323
|
}
|
|
320
324
|
|
|
@@ -332,8 +336,8 @@ class Kanban {
|
|
|
332
336
|
#onDragStart = (event) => {
|
|
333
337
|
const node = this.#cardFromEvent(event);
|
|
334
338
|
if (node === null || node === undefined) return;
|
|
335
|
-
this.#
|
|
336
|
-
this.#
|
|
339
|
+
this.#dragCard = node;
|
|
340
|
+
this.#dragColumn = node.dataset.column;
|
|
337
341
|
node.classList.add("kanban_card_dragging");
|
|
338
342
|
if (event.dataTransfer === null) return;
|
|
339
343
|
event.dataTransfer.effectAllowed = "move";
|
|
@@ -341,12 +345,16 @@ class Kanban {
|
|
|
341
345
|
};
|
|
342
346
|
|
|
343
347
|
#onDragOver = (event) => {
|
|
344
|
-
if (this.#
|
|
348
|
+
if (this.#dragCard === undefined) return;
|
|
345
349
|
const target = this.#columnFromEvent(event);
|
|
346
350
|
if (target === undefined) return;
|
|
347
|
-
const source = this.getColumn(this.#
|
|
351
|
+
const source = this.getColumn(this.#dragColumn);
|
|
348
352
|
// Лимит: карточку из другой колонки в полную колонку не пускаем
|
|
349
|
-
if (
|
|
353
|
+
if (
|
|
354
|
+
target.column.limit !== undefined &&
|
|
355
|
+
source !== target.column &&
|
|
356
|
+
target.column.cards.length >= target.column.limit
|
|
357
|
+
) {
|
|
350
358
|
target.node.classList.add("kanban_column_reject");
|
|
351
359
|
if (event.dataTransfer !== null) event.dataTransfer.dropEffect = "none";
|
|
352
360
|
return;
|
|
@@ -363,15 +371,15 @@ class Kanban {
|
|
|
363
371
|
*/
|
|
364
372
|
#moveToPoint(columnNode = new HTMLElement(), event = Object()) {
|
|
365
373
|
const body = columnNode.querySelector("kanban_column_body");
|
|
366
|
-
const reference = this.#referenceFor(body, event, this.#
|
|
374
|
+
const reference = this.#referenceFor(body, event, this.#dragCard);
|
|
367
375
|
const empty = body.querySelector("kanban_empty");
|
|
368
376
|
if (empty !== null) empty.remove();
|
|
369
|
-
if (reference === null) body.appendChild(this.#
|
|
370
|
-
else body.insertBefore(this.#
|
|
377
|
+
if (reference === null) body.appendChild(this.#dragCard);
|
|
378
|
+
else body.insertBefore(this.#dragCard, reference);
|
|
371
379
|
}
|
|
372
380
|
|
|
373
381
|
#onDropEvent = (event) => {
|
|
374
|
-
if (this.#
|
|
382
|
+
if (this.#dragCard === undefined) return;
|
|
375
383
|
const target = this.#columnFromEvent(event);
|
|
376
384
|
if (target === undefined) return;
|
|
377
385
|
event.preventDefault();
|
|
@@ -383,11 +391,13 @@ class Kanban {
|
|
|
383
391
|
};
|
|
384
392
|
|
|
385
393
|
#finishDrag() {
|
|
386
|
-
const card = this.#
|
|
387
|
-
const from = this.#
|
|
388
|
-
this.#
|
|
389
|
-
this.#
|
|
390
|
-
this.#
|
|
394
|
+
const card = this.#dragCard;
|
|
395
|
+
const from = this.#dragColumn;
|
|
396
|
+
this.#dragCard = undefined;
|
|
397
|
+
this.#dragColumn = undefined;
|
|
398
|
+
this.#columnsBox
|
|
399
|
+
.querySelectorAll(".kanban_column_reject")
|
|
400
|
+
.forEach((node) => node.classList.remove("kanban_column_reject"));
|
|
391
401
|
if (card === undefined) return;
|
|
392
402
|
card.classList.remove("kanban_card_dragging");
|
|
393
403
|
const columnNode = card.closest("kanban_column");
|
|
@@ -396,22 +406,28 @@ class Kanban {
|
|
|
396
406
|
const cards = [...columnNode.querySelectorAll(".kanban_card")];
|
|
397
407
|
const index = cards.indexOf(card);
|
|
398
408
|
const cardId = card.dataset.id;
|
|
399
|
-
if (
|
|
409
|
+
if (
|
|
410
|
+
String(from) === String(to) &&
|
|
411
|
+
this.getColumn(to).cards.findIndex((item) => String(item.id) === String(cardId)) === index
|
|
412
|
+
)
|
|
413
|
+
return;
|
|
400
414
|
// Лимит уже проверен при наведении, поэтому модель приводим к тому, что видно в DOM
|
|
401
415
|
this.#applyMove(cardId, to, index);
|
|
402
|
-
this.#announce(
|
|
416
|
+
this.#announce(
|
|
417
|
+
I18n.t("graphics.kanbanMovedTo", { card: this.#titleOf(cardId), column: this.getColumn(to).title })
|
|
418
|
+
);
|
|
403
419
|
}
|
|
404
420
|
|
|
405
421
|
#titleOf(cardId = undefined) {
|
|
406
422
|
const card = this.getCard(cardId);
|
|
407
|
-
return card === undefined ? "" : I18n.t("graphics.quotedName", {name: card.title});
|
|
423
|
+
return card === undefined ? "" : I18n.t("graphics.quotedName", { name: card.title });
|
|
408
424
|
}
|
|
409
425
|
|
|
410
426
|
// === КЛИК И КЛАВИАТУРА ===
|
|
411
427
|
#onClick = (event) => {
|
|
412
428
|
const node = this.#cardFromEvent(event);
|
|
413
429
|
if (node === null || node === undefined) return;
|
|
414
|
-
if (this.#
|
|
430
|
+
if (this.#onCardClick !== undefined) this.#onCardClick(this.getCard(node.dataset.id), node);
|
|
415
431
|
};
|
|
416
432
|
|
|
417
433
|
#onKeyDown = (event) => {
|
|
@@ -425,7 +441,9 @@ class Kanban {
|
|
|
425
441
|
const before = this.#findCard(node.dataset.id);
|
|
426
442
|
if (before === undefined) return;
|
|
427
443
|
if (vertical) {
|
|
428
|
-
const index = forward
|
|
444
|
+
const index = forward
|
|
445
|
+
? Math.min(before.index + 1, before.column.cards.length - 1)
|
|
446
|
+
: Math.max(before.index - 1, 0);
|
|
429
447
|
if (index === before.index) return;
|
|
430
448
|
this.moveCard(node.dataset.id, before.column.id, index);
|
|
431
449
|
} else {
|
|
@@ -437,13 +455,13 @@ class Kanban {
|
|
|
437
455
|
const after = this.#findCard(node.dataset.id);
|
|
438
456
|
// Единственная причина отказа — предел колонки: тогда ничего не объявляем о переносе
|
|
439
457
|
if (after.column === before.column && after.index === before.index) {
|
|
440
|
-
this.#announce(I18n.t("graphics.kanbanMoveRefused", {card: this.#titleOf(node.dataset.id)}));
|
|
458
|
+
this.#announce(I18n.t("graphics.kanbanMoveRefused", { card: this.#titleOf(node.dataset.id) }));
|
|
441
459
|
return;
|
|
442
460
|
}
|
|
443
461
|
const moved = this.#root.querySelector(`.kanban_card[data-id="${String(node.dataset.id)}"]`);
|
|
444
462
|
if (moved !== null) moved.focus();
|
|
445
|
-
this.#announce(I18n.t("graphics.kanbanMoved", {card: this.#titleOf(node.dataset.id)}));
|
|
463
|
+
this.#announce(I18n.t("graphics.kanbanMoved", { card: this.#titleOf(node.dataset.id) }));
|
|
446
464
|
};
|
|
447
465
|
}
|
|
448
466
|
|
|
449
|
-
exports.Kanban = Kanban
|
|
467
|
+
exports.Kanban = Kanban;
|
|
@@ -3,7 +3,7 @@ chui_kanban {
|
|
|
3
3
|
display: block;
|
|
4
4
|
width: -webkit-fill-available;
|
|
5
5
|
box-sizing: border-box;
|
|
6
|
-
margin: var(--
|
|
6
|
+
margin: var(--block_margin);
|
|
7
7
|
color: var(--text_color);
|
|
8
8
|
font-size: var(--font_default_size);
|
|
9
9
|
}
|
|
@@ -24,7 +24,7 @@ kanban_column {
|
|
|
24
24
|
min-width: 0;
|
|
25
25
|
background: var(--element_background);
|
|
26
26
|
border: 1px solid var(--border_color);
|
|
27
|
-
border-radius: var(--
|
|
27
|
+
border-radius: var(--radius_sm);
|
|
28
28
|
box-sizing: border-box;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -74,7 +74,7 @@ kanban_column.kanban_column_reject {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
kanban_column.kanban_column_reject kanban_column_body {
|
|
77
|
-
background: var(--
|
|
77
|
+
background: var(--badge_error_background);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
button.kanban_card {
|
|
@@ -84,7 +84,7 @@ button.kanban_card {
|
|
|
84
84
|
padding: 8px 10px;
|
|
85
85
|
border: 1px solid var(--border_color);
|
|
86
86
|
border-inline-start: 3px solid var(--kanban_card_color, var(--blue_prime_background));
|
|
87
|
-
border-radius: var(--
|
|
87
|
+
border-radius: var(--radius_sm);
|
|
88
88
|
background: var(--element_background_2);
|
|
89
89
|
color: var(--text_color);
|
|
90
90
|
font-family: inherit;
|
|
@@ -105,6 +105,10 @@ button.kanban_card:focus-visible {
|
|
|
105
105
|
button.kanban_card.kanban_card_dragging {
|
|
106
106
|
opacity: 0.5;
|
|
107
107
|
cursor: grabbing;
|
|
108
|
+
/* Карточка чуть приподнята и наклонена: взятая в руку вещь, а не просто поблёкшая
|
|
109
|
+
строка. Тень — та же, что у поднятых слоёв */
|
|
110
|
+
transform: scale(1.02) rotate(1deg);
|
|
111
|
+
box-shadow: var(--box_shadow_drop);
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
kanban_card_title {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {setStyles} = require("../../modules/chui_functions");
|
|
1
|
+
const { setStyles } = require("../../modules/chui_functions");
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Обозначение горячей клавиши: одна или несколько клавиш в «кнопках», между ними разделитель.
|
|
@@ -21,7 +21,7 @@ const {setStyles} = require("../../modules/chui_functions");
|
|
|
21
21
|
class Kbd {
|
|
22
22
|
static SIZE = {
|
|
23
23
|
SMALL: "small",
|
|
24
|
-
DEFAULT: "default"
|
|
24
|
+
DEFAULT: "default",
|
|
25
25
|
};
|
|
26
26
|
static #counter = 0;
|
|
27
27
|
|
|
@@ -30,13 +30,15 @@ class Kbd {
|
|
|
30
30
|
#keys = [];
|
|
31
31
|
#separator = "+";
|
|
32
32
|
|
|
33
|
-
constructor(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
constructor(
|
|
34
|
+
options = {
|
|
35
|
+
id: String(),
|
|
36
|
+
keys: [],
|
|
37
|
+
separator: String(),
|
|
38
|
+
size: String(),
|
|
39
|
+
label: String(),
|
|
40
|
+
}
|
|
41
|
+
) {
|
|
40
42
|
setStyles(__dirname + "/styles.css", "chUiJS_Kbd");
|
|
41
43
|
Kbd.#counter += 1;
|
|
42
44
|
this.#id = options.id === undefined ? `chui_kbd_${Kbd.#counter}` : options.id;
|
|
@@ -123,4 +125,4 @@ class Kbd {
|
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
exports.Kbd = Kbd
|
|
128
|
+
exports.Kbd = Kbd;
|
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
const {setStyles, htmlToMarkdown, markdownToHtml, optionOr} = require(
|
|
1
|
+
const { setStyles, htmlToMarkdown, markdownToHtml, optionOr } = require("../../modules/chui_functions");
|
|
2
2
|
|
|
3
3
|
class Label {
|
|
4
|
-
#
|
|
5
|
-
constructor(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
#chuiLabel = document.createElement(`chui_label`);
|
|
5
|
+
constructor(
|
|
6
|
+
options = {
|
|
7
|
+
id: String(),
|
|
8
|
+
text: String(),
|
|
9
|
+
markdownText: String(),
|
|
10
|
+
textAlign: String(),
|
|
11
|
+
wordBreak: String(),
|
|
12
|
+
width: String(),
|
|
13
|
+
fontSize: String(),
|
|
14
|
+
}
|
|
15
|
+
) {
|
|
16
|
+
setStyles(__dirname + "/styles.css", "chUiJS_Label");
|
|
15
17
|
// Стили текста лейбла: пустая заготовка опции равносильна отсутствующей
|
|
16
18
|
const text = optionOr(options.text, undefined);
|
|
17
|
-
const
|
|
18
|
-
if (text !== undefined &&
|
|
19
|
+
const markdownText = optionOr(options.markdownText, undefined);
|
|
20
|
+
if (text !== undefined && markdownText !== undefined) {
|
|
19
21
|
throw new Error("Должна быть установлена одна опция text или markdownText");
|
|
20
22
|
} else {
|
|
21
|
-
if (text !== undefined) this.#
|
|
22
|
-
if (
|
|
23
|
+
if (text !== undefined) this.#chuiLabel.innerText = text;
|
|
24
|
+
if (markdownText !== undefined) this.#chuiLabel.innerHTML = markdownToHtml(markdownText);
|
|
23
25
|
}
|
|
24
26
|
//
|
|
25
|
-
if (options.id !== undefined) this.#
|
|
26
|
-
if (options.textAlign !== undefined) this.#
|
|
27
|
-
if (options.wordBreak !== undefined) this.#
|
|
28
|
-
if (options.width !== undefined) this.#
|
|
29
|
-
if (options.fontSize !== undefined) this.#
|
|
27
|
+
if (options.id !== undefined) this.#chuiLabel.id = options.id;
|
|
28
|
+
if (options.textAlign !== undefined) this.#chuiLabel.style.textAlign = options.textAlign;
|
|
29
|
+
if (options.wordBreak !== undefined) this.#chuiLabel.style.wordBreak = options.wordBreak;
|
|
30
|
+
if (options.width !== undefined) this.#chuiLabel.style.width = options.width;
|
|
31
|
+
if (options.fontSize !== undefined) this.#chuiLabel.style.fontSize = options.fontSize;
|
|
30
32
|
}
|
|
31
33
|
// GET
|
|
32
34
|
getId() {
|
|
33
|
-
return this.#
|
|
35
|
+
return this.#chuiLabel.id;
|
|
34
36
|
}
|
|
35
37
|
getText() {
|
|
36
|
-
return this.#
|
|
38
|
+
return this.#chuiLabel.innerText;
|
|
37
39
|
}
|
|
38
40
|
getMarkdownText() {
|
|
39
|
-
return htmlToMarkdown(this.#
|
|
41
|
+
return htmlToMarkdown(this.#chuiLabel.innerHTML);
|
|
40
42
|
}
|
|
41
43
|
// SET
|
|
42
44
|
setId(id = String()) {
|
|
43
|
-
this.#
|
|
45
|
+
this.#chuiLabel.id = id;
|
|
44
46
|
}
|
|
45
47
|
setText(text = String()) {
|
|
46
|
-
this.#
|
|
48
|
+
this.#chuiLabel.innerText = text;
|
|
47
49
|
}
|
|
48
50
|
setMarkdownText(text = String()) {
|
|
49
|
-
this.#
|
|
51
|
+
this.#chuiLabel.innerHTML = markdownToHtml(text);
|
|
50
52
|
}
|
|
51
53
|
// RENDER
|
|
52
54
|
set() {
|
|
53
|
-
return this.#
|
|
55
|
+
return this.#chuiLabel;
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
exports.Label = Label
|
|
59
|
+
exports.Label = Label;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
chui_label {
|
|
2
2
|
height: max-content;
|
|
3
3
|
width: max-content;
|
|
4
|
-
margin: var(--
|
|
4
|
+
margin: var(--block_margin);
|
|
5
5
|
font-size: var(--font_default_size);
|
|
6
|
-
font-weight:500;
|
|
6
|
+
font-weight: 500;
|
|
7
7
|
color: var(--text_color);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
chui_label p {
|
|
11
11
|
margin: 0;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const {setStyles} = require(
|
|
2
|
-
const {Desktop} = require(
|
|
3
|
-
const {Icon} = require(
|
|
1
|
+
const { setStyles } = require("../../modules/chui_functions");
|
|
2
|
+
const { Desktop } = require("../../modules/chui_services/desktop");
|
|
3
|
+
const { Icon } = require("../chui_icons/icons");
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Ссылка: текст, который открывает адрес во внешнем браузере или вызывает свой обработчик.
|
|
@@ -29,37 +29,39 @@ class Link {
|
|
|
29
29
|
#icon = undefined;
|
|
30
30
|
#id = undefined;
|
|
31
31
|
#href = undefined;
|
|
32
|
-
#
|
|
33
|
-
#
|
|
32
|
+
#clickEvent = undefined;
|
|
33
|
+
#clickListeners = [];
|
|
34
34
|
#disabled = false;
|
|
35
35
|
#external = undefined;
|
|
36
36
|
|
|
37
|
-
constructor(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
constructor(
|
|
38
|
+
options = {
|
|
39
|
+
id: String(),
|
|
40
|
+
text: String(),
|
|
41
|
+
href: String(),
|
|
42
|
+
icon: String(),
|
|
43
|
+
external: Boolean(),
|
|
44
|
+
disabled: Boolean(),
|
|
45
|
+
width: String(),
|
|
46
|
+
title: String(),
|
|
47
|
+
clickEvent: undefined,
|
|
48
|
+
clickListener: undefined,
|
|
49
|
+
}
|
|
50
|
+
) {
|
|
49
51
|
setStyles(__dirname + "/styles.css", "chUiJS_Link");
|
|
50
52
|
Link.#counter += 1;
|
|
51
53
|
this.#id = options.id === undefined ? `chui_link_${Link.#counter}` : options.id;
|
|
52
54
|
this.#root.id = this.#id;
|
|
53
55
|
this.#root.classList.add("chui_link");
|
|
54
56
|
this.#external = options.external;
|
|
55
|
-
this.#
|
|
57
|
+
this.#clickEvent = options.clickEvent;
|
|
56
58
|
this.#root.addEventListener("click", this.#onClick);
|
|
57
59
|
this.#root.innerText = options.text === undefined ? "" : options.text;
|
|
58
60
|
if (options.title !== undefined) this.#root.setAttribute("title", options.title);
|
|
59
61
|
if (options.width !== undefined) this.setWidth(options.width);
|
|
60
62
|
if (options.href !== undefined) this.setHref(options.href);
|
|
61
63
|
if (options.icon !== undefined) this.setIcon(options.icon);
|
|
62
|
-
if (this.#href === undefined && this.#
|
|
64
|
+
if (this.#href === undefined && this.#clickEvent !== undefined) this.#applyLinkRole();
|
|
63
65
|
if (options.disabled === true) this.setDisabled(true);
|
|
64
66
|
if (options.clickListener !== undefined) this.addClickListener(options.clickListener);
|
|
65
67
|
}
|
|
@@ -120,9 +122,12 @@ class Link {
|
|
|
120
122
|
if (this.#icon !== undefined) this.#icon.remove();
|
|
121
123
|
this.#icon = undefined;
|
|
122
124
|
if (icon === undefined) return this;
|
|
123
|
-
this.#icon =
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
this.#icon =
|
|
126
|
+
typeof icon === "string"
|
|
127
|
+
? new Icon(icon, "14px").set()
|
|
128
|
+
: typeof icon.set === "function"
|
|
129
|
+
? icon.set()
|
|
130
|
+
: icon;
|
|
126
131
|
this.#icon.setAttribute("aria-hidden", "true");
|
|
127
132
|
this.#root.appendChild(this.#icon);
|
|
128
133
|
return this;
|
|
@@ -143,13 +148,13 @@ class Link {
|
|
|
143
148
|
|
|
144
149
|
/** Свой обработчик клика; вызывается вместо открытия адреса */
|
|
145
150
|
setClickEvent(listener = () => {}) {
|
|
146
|
-
this.#
|
|
151
|
+
this.#clickEvent = listener;
|
|
147
152
|
if (this.#href === undefined) this.#applyLinkRole();
|
|
148
153
|
return this;
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
addClickListener(listener = () => {}) {
|
|
152
|
-
this.#
|
|
157
|
+
this.#clickListeners.push(listener);
|
|
153
158
|
return this;
|
|
154
159
|
}
|
|
155
160
|
|
|
@@ -182,19 +187,21 @@ class Link {
|
|
|
182
187
|
event.preventDefault();
|
|
183
188
|
return;
|
|
184
189
|
}
|
|
185
|
-
for (const listener of [...this.#
|
|
186
|
-
if (this.#
|
|
190
|
+
for (const listener of [...this.#clickListeners]) listener(event);
|
|
191
|
+
if (this.#clickEvent !== undefined) {
|
|
187
192
|
event.preventDefault();
|
|
188
|
-
this.#
|
|
193
|
+
this.#clickEvent(event);
|
|
189
194
|
return;
|
|
190
195
|
}
|
|
191
196
|
if (!this.isExternal()) return;
|
|
192
197
|
// Своё окно Electron для внешней ссылки не открываем: отдаём адрес системе
|
|
193
198
|
event.preventDefault();
|
|
194
199
|
Desktop.shell.openExternal(this.#href).catch((error) => {
|
|
195
|
-
require(
|
|
200
|
+
require("../../modules/chui_logger/chui_logger").Log.error(
|
|
201
|
+
`Link: не удалось открыть «${this.#href}»: ${error}`
|
|
202
|
+
);
|
|
196
203
|
});
|
|
197
204
|
};
|
|
198
205
|
}
|
|
199
206
|
|
|
200
|
-
exports.Link = Link
|
|
207
|
+
exports.Link = Link;
|