chuijs 4.0.2 → 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 +61 -0
- package/README.md +43 -644
- package/framework/appLayout/default/chui_app_layout.js +308 -260
- package/framework/appLayout/default/global_style.css +85 -48
- 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 +36 -25
- 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_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 +27 -13
- package/framework/modules/chui_services/chui_services.js +39 -31
- package/framework/modules/chui_services/desktop.js +32 -31
- 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 +385 -292
- package/package.json +79 -68
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const {Animation} = require(
|
|
2
|
-
const {OverlayA11y} = require(
|
|
3
|
-
const {optionOr} = require(
|
|
4
|
-
const {I18n} = require(
|
|
1
|
+
const { Animation } = require("../../modules/chui_animations/animations");
|
|
2
|
+
const { OverlayA11y } = require("../../modules/chui_a11y/chui_a11y");
|
|
3
|
+
const { optionOr } = require("../../modules/chui_functions");
|
|
4
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
5
5
|
|
|
6
6
|
class Dialog {
|
|
7
7
|
#id = require("randomstring").generate();
|
|
@@ -9,23 +9,24 @@ class Dialog {
|
|
|
9
9
|
// Занавес под диалогом: размывает и затемняет окно. Живёт отдельным узлом в body
|
|
10
10
|
// (внутри диалога его бы срезал собственный overflow), клики пропускает насквозь.
|
|
11
11
|
#scrim = document.createElement(`dialog_scrim`);
|
|
12
|
-
#header = document.createElement(
|
|
13
|
-
#body = document.createElement(
|
|
14
|
-
#footer = document.createElement(
|
|
12
|
+
#header = document.createElement("dialog_header");
|
|
13
|
+
#body = document.createElement("dialog_body");
|
|
14
|
+
#footer = document.createElement("dialog_footer");
|
|
15
15
|
//
|
|
16
16
|
#a11y = undefined;
|
|
17
17
|
#outside_click_bound = false;
|
|
18
18
|
isOpen = false;
|
|
19
19
|
|
|
20
|
-
constructor(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
constructor(
|
|
21
|
+
options = {
|
|
22
|
+
width: String(),
|
|
23
|
+
height: String(),
|
|
24
|
+
title: String(),
|
|
25
|
+
closeOutSideClick: false,
|
|
26
|
+
}
|
|
27
|
+
) {
|
|
28
|
+
require("../../modules/chui_functions").setStyles(__dirname + "/styles.css", "chUiJS_Dialogs");
|
|
29
|
+
this.#dialog.id = this.#id;
|
|
29
30
|
this.#scrim.setAttribute("aria-hidden", "true");
|
|
30
31
|
// Занавес встаёт в body при открытии: у неоткрытого диалога в документе не остаётся
|
|
31
32
|
// лишнего узла (TextEditor и витрина создают диалоги заранее — каждый оставлял занавес)
|
|
@@ -35,7 +36,7 @@ class Dialog {
|
|
|
35
36
|
this.#a11y = new OverlayA11y(this.#dialog, {
|
|
36
37
|
role: "dialog",
|
|
37
38
|
label: optionOr(options.title, I18n.t("feedback.dialog")),
|
|
38
|
-
onEscape: () => this.close()
|
|
39
|
+
onEscape: () => this.close(),
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
this.#dialog.style.width = options.width === undefined ? "max-content" : options.width;
|
|
@@ -45,31 +46,31 @@ class Dialog {
|
|
|
45
46
|
this.#dialog.addEventListener("animationend", (evt) => {
|
|
46
47
|
if (evt.animationName === "fade-in" && !this.#outside_click_bound) {
|
|
47
48
|
this.#outside_click_bound = true;
|
|
48
|
-
window.addEventListener(
|
|
49
|
+
window.addEventListener("click", this.#closeOutsideEvent);
|
|
49
50
|
}
|
|
50
|
-
})
|
|
51
|
+
});
|
|
51
52
|
}
|
|
52
53
|
//ADDS
|
|
53
|
-
this.#dialog.appendChild(this.#body)
|
|
54
|
+
this.#dialog.appendChild(this.#body);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
#closeOutsideEvent = (event) => {
|
|
57
58
|
if (!this.#dialog.contains(event.target)) {
|
|
58
59
|
if (this.#outside_click_bound) {
|
|
59
60
|
this.#outside_click_bound = false;
|
|
60
|
-
window.removeEventListener("click", this.#closeOutsideEvent)
|
|
61
|
+
window.removeEventListener("click", this.#closeOutsideEvent);
|
|
61
62
|
}
|
|
62
|
-
this.close()
|
|
63
|
+
this.close();
|
|
63
64
|
}
|
|
64
|
-
}
|
|
65
|
+
};
|
|
65
66
|
|
|
66
67
|
#resizeEvent = () => {
|
|
67
68
|
if (!document.contains(this.#dialog)) return;
|
|
68
|
-
this.#setCenter(this.#dialog, window)
|
|
69
|
-
}
|
|
69
|
+
this.#setCenter(this.#dialog, window);
|
|
70
|
+
};
|
|
70
71
|
|
|
71
72
|
addToHeader(...components) {
|
|
72
|
-
this.#dialog.insertBefore(this.#header, this.#body)
|
|
73
|
+
this.#dialog.insertBefore(this.#header, this.#body);
|
|
73
74
|
for (let component of components) this.#header.appendChild(component.set());
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -78,7 +79,7 @@ class Dialog {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
addToFooter(...components) {
|
|
81
|
-
this.#dialog.appendChild(this.#footer)
|
|
82
|
+
this.#dialog.appendChild(this.#footer);
|
|
82
83
|
for (let component of components) this.#footer.appendChild(component.set());
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -95,7 +96,7 @@ class Dialog {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
open() {
|
|
98
|
-
this.isOpen = true
|
|
99
|
+
this.isOpen = true;
|
|
99
100
|
// if (this.#width === "-webkit-fill-available" && this.#height === "-webkit-fill-available") {
|
|
100
101
|
// dialog.style.top = "0"
|
|
101
102
|
// dialog.style.left = "0"
|
|
@@ -106,38 +107,38 @@ class Dialog {
|
|
|
106
107
|
// this.#setCenter(dialog, window)
|
|
107
108
|
// }
|
|
108
109
|
|
|
109
|
-
window.addEventListener("resize", this.#resizeEvent)
|
|
110
|
+
window.addEventListener("resize", this.#resizeEvent);
|
|
110
111
|
// Занавес нужен только открытому слою
|
|
111
112
|
if (document.body.contains(this.#scrim) === false) document.body.appendChild(this.#scrim);
|
|
112
113
|
new Animation(this.#dialog).fadeIn();
|
|
113
114
|
new Animation(this.#scrim).fadeIn();
|
|
114
|
-
this.#setCenter(this.#dialog, window)
|
|
115
|
-
this.#a11y.open()
|
|
115
|
+
this.#setCenter(this.#dialog, window);
|
|
116
|
+
this.#a11y.open();
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/** Доступное имя диалога (aria-label), если заголовок в разметке не годится.
|
|
119
120
|
* Пустое значение имя не затирает — иначе слой остался бы безымянным */
|
|
120
121
|
setAriaLabel(text = String()) {
|
|
121
122
|
if (typeof text !== "string" || text.trim() === "") return;
|
|
122
|
-
this.#a11y.setLabel(text)
|
|
123
|
+
this.#a11y.setLabel(text);
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
openAndClose() {
|
|
126
127
|
if (!this.isOpen) {
|
|
127
|
-
this.open()
|
|
128
|
+
this.open();
|
|
128
129
|
} else {
|
|
129
|
-
this.close()
|
|
130
|
+
this.close();
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
close() {
|
|
134
135
|
if (this.#outside_click_bound) {
|
|
135
136
|
this.#outside_click_bound = false;
|
|
136
|
-
window.removeEventListener("click", this.#closeOutsideEvent)
|
|
137
|
+
window.removeEventListener("click", this.#closeOutsideEvent);
|
|
137
138
|
}
|
|
138
|
-
window.removeEventListener("resize", this.#resizeEvent)
|
|
139
|
-
this.isOpen = false
|
|
140
|
-
this.#a11y.close()
|
|
139
|
+
window.removeEventListener("resize", this.#resizeEvent);
|
|
140
|
+
this.isOpen = false;
|
|
141
|
+
this.#a11y.close();
|
|
141
142
|
new Animation(this.#dialog).fadeOut();
|
|
142
143
|
new Animation(this.#scrim).fadeOut();
|
|
143
144
|
}
|
|
@@ -155,20 +156,20 @@ class Dialog {
|
|
|
155
156
|
|
|
156
157
|
#setCenter(element, window) {
|
|
157
158
|
// Ширина
|
|
158
|
-
const width = parseInt(window.getComputedStyle(element).width) + "px"
|
|
159
|
+
const width = parseInt(window.getComputedStyle(element).width) + "px";
|
|
159
160
|
if (element.style.width === "-webkit-fill-available") {
|
|
160
|
-
element.style.left = "0"
|
|
161
|
+
element.style.left = "0";
|
|
161
162
|
} else {
|
|
162
163
|
element.style.left = `calc(100% / 2 - ${width} / 2)`;
|
|
163
164
|
}
|
|
164
165
|
// Высота
|
|
165
|
-
const height = parseInt(window.getComputedStyle(element).height) + "px"
|
|
166
|
+
const height = parseInt(window.getComputedStyle(element).height) + "px";
|
|
166
167
|
if (element.style.height === "-webkit-fill-available") {
|
|
167
|
-
element.style.top = "0"
|
|
168
|
+
element.style.top = "0";
|
|
168
169
|
} else {
|
|
169
170
|
element.style.top = `calc(100% / 2 - ${height} / 2)`;
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
exports.Dialog = Dialog
|
|
175
|
+
exports.Dialog = Dialog;
|
|
@@ -59,7 +59,8 @@ dialog_header .chui_button:not(:disabled):hover {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
dialog_header .chui_button:not(:disabled):active {
|
|
62
|
-
background: var(--element_background_prime);
|
|
62
|
+
background: var(--element_background_prime);
|
|
63
|
+
color: var(--text_color_hover);
|
|
63
64
|
border: none;
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -91,4 +92,4 @@ dialog_footer {
|
|
|
91
92
|
margin-top: 12px;
|
|
92
93
|
padding-top: 12px;
|
|
93
94
|
border-top: 1px solid var(--border_color);
|
|
94
|
-
}
|
|
95
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const {Animation} = require(
|
|
2
|
-
const {setStyles, markdownToHtml, getTime, getDayKey, optionOr} = require(
|
|
3
|
-
const {LAYOUT_ROLE, requireLayoutNode} = require(
|
|
4
|
-
const {Icon, Icons} = require(
|
|
5
|
-
const {I18n} = require(
|
|
1
|
+
const { Animation } = require("../../modules/chui_animations/animations");
|
|
2
|
+
const { setStyles, markdownToHtml, getTime, getDayKey, optionOr } = require("../../modules/chui_functions");
|
|
3
|
+
const { LAYOUT_ROLE, requireLayoutNode } = require("../../modules/chui_layout/chui_layout");
|
|
4
|
+
const { Icon, Icons } = require("../chui_icons/icons");
|
|
5
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
6
6
|
// Плашка значка состояния — общая на всё семейство карточек уведомлений
|
|
7
|
-
const {setStatusPlate} = require("./status_plate");
|
|
7
|
+
const { setStatusPlate } = require("./status_plate");
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Карточка уведомления в панели: значок состояния, заголовок с отметкой времени, текст,
|
|
@@ -38,7 +38,7 @@ class Notification {
|
|
|
38
38
|
#notification_header = document.createElement("notification_header");
|
|
39
39
|
#notification_title = document.createElement("notification_title");
|
|
40
40
|
#notification_date = document.createElement("notification_date");
|
|
41
|
-
#notification_text = document.createElement("notification_text")
|
|
41
|
+
#notification_text = document.createElement("notification_text");
|
|
42
42
|
#notification_progress = document.createElement("notification_progress");
|
|
43
43
|
#notification_close = document.createElement("button");
|
|
44
44
|
// Отсчёт автоскрытия: таймер, дедлайн и остаток — чтобы пауза не теряла время
|
|
@@ -47,12 +47,17 @@ class Notification {
|
|
|
47
47
|
#remaining = 0;
|
|
48
48
|
#dismissed = false;
|
|
49
49
|
|
|
50
|
-
constructor(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
constructor(
|
|
51
|
+
options = {
|
|
52
|
+
title: String(),
|
|
53
|
+
markdownTitle: String(),
|
|
54
|
+
text: String(),
|
|
55
|
+
markdownText: String(),
|
|
56
|
+
style: undefined,
|
|
57
|
+
showTime: Number(),
|
|
58
|
+
}
|
|
59
|
+
) {
|
|
60
|
+
setStyles(__dirname + "/styles.css", "chUiJS_Notification");
|
|
56
61
|
// Время показа — только настоящее число: заготовка `Number()` из описания опций
|
|
57
62
|
// раньше доезжала как значение и карточка без опций исчезала мгновенно
|
|
58
63
|
const show_time = Number(options.showTime);
|
|
@@ -86,10 +91,16 @@ class Notification {
|
|
|
86
91
|
//
|
|
87
92
|
const style = optionOr(options.style, undefined);
|
|
88
93
|
if (style !== undefined) this.#notification.classList.add(style);
|
|
94
|
+
// Карточка появляется сама, без фокуса, поэтому о ней сообщает роль: ошибку
|
|
95
|
+
// объявляем сразу, остальное — вежливо (то же правило, что у `Toast`)
|
|
96
|
+
this.#notification.setAttribute("role", style === Notification.STYLE.ERROR ? "alert" : "status");
|
|
89
97
|
// Иконка состояния — украшение: стиль читается и по тексту уведомления.
|
|
90
98
|
// Цвет и глиф плашки выбирает общий помощник семейства — по ключу стиля
|
|
91
99
|
this.#notification_icon.setAttribute("aria-hidden", "true");
|
|
92
|
-
setStatusPlate(
|
|
100
|
+
setStatusPlate(
|
|
101
|
+
this.#notification_icon,
|
|
102
|
+
typeof style === "string" ? style.replace("notification_", "") : undefined
|
|
103
|
+
);
|
|
93
104
|
// Закрытие — настоящая кнопка: доступна мышью, с клавиатуры и скринридеру
|
|
94
105
|
this.#notification_close.className = "notification_close";
|
|
95
106
|
this.#notification_close.type = "button";
|
|
@@ -97,14 +108,14 @@ class Notification {
|
|
|
97
108
|
this.#notification_close.setAttribute("title", I18n.t("common.close"));
|
|
98
109
|
this.#notification_close.innerHTML = new Icon(Icons.NAVIGATION.CLOSE, "16px").getHTML();
|
|
99
110
|
//
|
|
100
|
-
this.#notification_header.appendChild(this.#notification_title)
|
|
101
|
-
this.#notification_header.appendChild(this.#notification_date)
|
|
111
|
+
this.#notification_header.appendChild(this.#notification_title);
|
|
112
|
+
this.#notification_header.appendChild(this.#notification_date);
|
|
102
113
|
//
|
|
103
|
-
this.#notification_content.appendChild(this.#notification_header)
|
|
104
|
-
this.#notification_content.appendChild(this.#notification_text)
|
|
105
|
-
this.#notification.appendChild(this.#notification_icon)
|
|
106
|
-
this.#notification.appendChild(this.#notification_content)
|
|
107
|
-
this.#notification.appendChild(this.#notification_close)
|
|
114
|
+
this.#notification_content.appendChild(this.#notification_header);
|
|
115
|
+
this.#notification_content.appendChild(this.#notification_text);
|
|
116
|
+
this.#notification.appendChild(this.#notification_icon);
|
|
117
|
+
this.#notification.appendChild(this.#notification_content);
|
|
118
|
+
this.#notification.appendChild(this.#notification_close);
|
|
108
119
|
// Полоса отсчёта нужна только тем уведомлениям, которые закрываются сами
|
|
109
120
|
if (this.#time > 0) {
|
|
110
121
|
this.#notification_progress.style.animationDuration = `${this.#time}ms`;
|
|
@@ -128,12 +139,17 @@ class Notification {
|
|
|
128
139
|
panel.appendChild(this.#notification);
|
|
129
140
|
new Animation(this.#notification).slideRightIn();
|
|
130
141
|
// animationend прилетает и от детей (полоса отсчёта) — отсчёт запускаем только по своему
|
|
131
|
-
this.#notification.addEventListener(
|
|
142
|
+
this.#notification.addEventListener("animationend", (event) => {
|
|
132
143
|
if (event.target !== this.#notification) return;
|
|
133
144
|
this.#start(this.#time);
|
|
134
145
|
});
|
|
135
146
|
this.#notification.addEventListener("click", () => this.dismiss());
|
|
136
|
-
if (showOnSystem)
|
|
147
|
+
if (showOnSystem)
|
|
148
|
+
require("electron").ipcRenderer.send(
|
|
149
|
+
"show_system_notification",
|
|
150
|
+
this.#notification_title.innerText,
|
|
151
|
+
this.#notification_text.innerText
|
|
152
|
+
);
|
|
137
153
|
return this;
|
|
138
154
|
}
|
|
139
155
|
|
|
@@ -196,24 +212,24 @@ class Notification {
|
|
|
196
212
|
// инлайновые значения (в карточке их несколько — отсчёт, отклик на наведение)
|
|
197
213
|
notification.style.removeProperty("animation-name");
|
|
198
214
|
notification.style.removeProperty("transition");
|
|
199
|
-
notification.style.display =
|
|
200
|
-
notification.style.width =
|
|
201
|
-
notification.style.opacity = "0"
|
|
202
|
-
notification.style.transform = "translateX(100%)"
|
|
215
|
+
notification.style.display = "flex";
|
|
216
|
+
notification.style.width = "-webkit-fill-available";
|
|
217
|
+
notification.style.opacity = "0";
|
|
218
|
+
notification.style.transform = "translateX(100%)";
|
|
203
219
|
// В ящике карточка — запись истории: полоса отсчёта и закрытие там лишние
|
|
204
220
|
notification.classList.add("notification_in_box");
|
|
205
221
|
const box = requireLayoutNode(LAYOUT_ROLE.NOTIFICATION_BOX_MAIN, notification);
|
|
206
222
|
// Новые записи идут сверху: история читается от свежего к старому, и группы дней
|
|
207
223
|
// (их расставляет NotificationBox) ложатся в том же порядке — «Сегодня» первой.
|
|
208
|
-
box.prepend(notification)
|
|
224
|
+
box.prepend(notification);
|
|
209
225
|
setTimeout(() => {
|
|
210
|
-
notification.style.opacity = "1"
|
|
211
|
-
notification.style.transform = "translateX(0)"
|
|
212
|
-
}, 500)
|
|
213
|
-
})
|
|
226
|
+
notification.style.opacity = "1";
|
|
227
|
+
notification.style.transform = "translateX(0)";
|
|
228
|
+
}, 500);
|
|
229
|
+
});
|
|
214
230
|
}
|
|
215
231
|
|
|
216
|
-
static STYLE = { ERROR:
|
|
232
|
+
static STYLE = { ERROR: "notification_error", SUCCESS: "notification_success", WARNING: "notification_warning" };
|
|
217
233
|
}
|
|
218
234
|
|
|
219
|
-
exports.Notification = Notification
|
|
235
|
+
exports.Notification = Notification;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const {Animation} = require(
|
|
2
|
-
const {setStyles, getTime, optionOr} = require(
|
|
3
|
-
const {LAYOUT_ROLE, requireLayoutNode} = require(
|
|
4
|
-
const {Icons} = require("../chui_icons/icons");
|
|
1
|
+
const { Animation } = require("../../modules/chui_animations/animations");
|
|
2
|
+
const { setStyles, getTime, optionOr } = require("../../modules/chui_functions");
|
|
3
|
+
const { LAYOUT_ROLE, requireLayoutNode } = require("../../modules/chui_layout/chui_layout");
|
|
4
|
+
const { Icons } = require("../chui_icons/icons");
|
|
5
5
|
// Плашка значка — общая на всё семейство карточек уведомлений
|
|
6
|
-
const {createStatusPlate, setStatusPlate} = require("./status_plate");
|
|
6
|
+
const { createStatusPlate, setStatusPlate } = require("./status_plate");
|
|
7
7
|
|
|
8
8
|
class DownloadNotification {
|
|
9
9
|
#id = require("randomstring").generate();
|
|
@@ -16,8 +16,10 @@ class DownloadNotification {
|
|
|
16
16
|
#download_notification_body = document.createElement("download_notification_body");
|
|
17
17
|
#download_notification_text = document.createElement("download_notification_text");
|
|
18
18
|
constructor(options = { title: String(), text: String(), type: String() }) {
|
|
19
|
-
setStyles(__dirname + "/styles_download.css",
|
|
19
|
+
setStyles(__dirname + "/styles_download.css", "chUiJS_downloadNotification");
|
|
20
20
|
this.#download_notification.id = this.#id;
|
|
21
|
+
// Ход загрузки объявляется вежливо; итог с ошибкой меняет роль в `#renderTest()`
|
|
22
|
+
this.#download_notification.setAttribute("role", "status");
|
|
21
23
|
// Пустая заготовка опции равносильна отсутствующей: пустое уведомление не собирается
|
|
22
24
|
const title = optionOr(options.title, undefined);
|
|
23
25
|
const text = optionOr(options.text, undefined);
|
|
@@ -26,22 +28,22 @@ class DownloadNotification {
|
|
|
26
28
|
} else {
|
|
27
29
|
throw new Error("Должна быть установлена опция title");
|
|
28
30
|
}
|
|
29
|
-
this.#download_notification_body.style.width = "-webkit-fill-available"
|
|
31
|
+
this.#download_notification_body.style.width = "-webkit-fill-available";
|
|
30
32
|
this.#download_notification_date.innerHTML = getTime();
|
|
31
33
|
if (text !== undefined) {
|
|
32
34
|
this.#download_notification_text.innerText = text;
|
|
33
35
|
} else {
|
|
34
36
|
throw new Error("Должна быть установлена опция text");
|
|
35
37
|
}
|
|
36
|
-
this.#download_notification_header.appendChild(this.#download_notification_title)
|
|
37
|
-
this.#download_notification_header.appendChild(this.#download_notification_date)
|
|
38
|
-
this.#download_notification_content.appendChild(this.#download_notification_header)
|
|
39
|
-
this.#download_notification_body.appendChild(this.#download_notification_text)
|
|
40
|
-
this.#download_notification_content.appendChild(this.#download_notification_body)
|
|
38
|
+
this.#download_notification_header.appendChild(this.#download_notification_title);
|
|
39
|
+
this.#download_notification_header.appendChild(this.#download_notification_date);
|
|
40
|
+
this.#download_notification_content.appendChild(this.#download_notification_header);
|
|
41
|
+
this.#download_notification_body.appendChild(this.#download_notification_text);
|
|
42
|
+
this.#download_notification_content.appendChild(this.#download_notification_body);
|
|
41
43
|
// Значок состояния — в плашке слева, как у Notification
|
|
42
44
|
this.#download_notification_icon = createStatusPlate(undefined, Icons.FILE.DOWNLOAD_FOR_OFFLINE);
|
|
43
|
-
this.#download_notification.appendChild(this.#download_notification_icon)
|
|
44
|
-
this.#download_notification.appendChild(this.#download_notification_content)
|
|
45
|
+
this.#download_notification.appendChild(this.#download_notification_icon);
|
|
46
|
+
this.#download_notification.appendChild(this.#download_notification_content);
|
|
45
47
|
}
|
|
46
48
|
update(title = String(), text = String()) {
|
|
47
49
|
this.#download_notification_title.innerText = title;
|
|
@@ -52,7 +54,9 @@ class DownloadNotification {
|
|
|
52
54
|
const panel = requireLayoutNode(LAYOUT_ROLE.NOTIFICATION_PANEL, this.#download_notification);
|
|
53
55
|
panel.appendChild(this.#download_notification);
|
|
54
56
|
new Animation(this.#download_notification).slideRightIn();
|
|
55
|
-
this.#download_notification.addEventListener("click", () =>
|
|
57
|
+
this.#download_notification.addEventListener("click", () =>
|
|
58
|
+
this.#hideNotification(this.#download_notification)
|
|
59
|
+
);
|
|
56
60
|
}
|
|
57
61
|
done() {
|
|
58
62
|
this.#renderTest("download_notification_success", "success");
|
|
@@ -64,6 +68,8 @@ class DownloadNotification {
|
|
|
64
68
|
#renderTest(className, status) {
|
|
65
69
|
const notification = this.#download_notification;
|
|
66
70
|
notification.className = className;
|
|
71
|
+
// Ошибку объявляем сразу, успех — вежливо (как у `Toast`)
|
|
72
|
+
notification.setAttribute("role", status === "error" ? "alert" : "status");
|
|
67
73
|
setStatusPlate(this.#download_notification_icon, status);
|
|
68
74
|
setTimeout(() => this.#hideNotification(notification), 2000);
|
|
69
75
|
}
|
|
@@ -73,20 +79,20 @@ class DownloadNotification {
|
|
|
73
79
|
// Точечный сброс следов анимации вместо стирания всего атрибута `style`
|
|
74
80
|
notification.style.removeProperty("animation-name");
|
|
75
81
|
notification.style.removeProperty("transition");
|
|
76
|
-
notification.style.display =
|
|
77
|
-
notification.style.width =
|
|
78
|
-
notification.style.opacity = "0"
|
|
79
|
-
notification.style.transform = "translateX(100%)"
|
|
82
|
+
notification.style.display = "flex";
|
|
83
|
+
notification.style.width = "-webkit-fill-available";
|
|
84
|
+
notification.style.opacity = "0";
|
|
85
|
+
notification.style.transform = "translateX(100%)";
|
|
80
86
|
let box = requireLayoutNode(LAYOUT_ROLE.NOTIFICATION_BOX_MAIN, notification);
|
|
81
87
|
// В истории запись плоская и без курсора: класс снимает стекло, тень и отклик на наведение
|
|
82
88
|
notification.classList.add("notification_in_box");
|
|
83
|
-
box.appendChild(notification)
|
|
89
|
+
box.appendChild(notification);
|
|
84
90
|
setTimeout(() => {
|
|
85
|
-
notification.style.opacity = "1"
|
|
86
|
-
notification.style.transform = "translateX(0)"
|
|
87
|
-
}, 500)
|
|
88
|
-
})
|
|
91
|
+
notification.style.opacity = "1";
|
|
92
|
+
notification.style.transform = "translateX(0)";
|
|
93
|
+
}, 500);
|
|
94
|
+
});
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
exports.DownloadNotification = DownloadNotification
|
|
98
|
+
exports.DownloadNotification = DownloadNotification;
|
|
@@ -108,7 +108,8 @@ download_progress_text_block {
|
|
|
108
108
|
margin: 0 0 4px;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
download_progress_text,
|
|
111
|
+
download_progress_text,
|
|
112
|
+
download_progress_count {
|
|
112
113
|
font-size: var(--font_notification_size);
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -137,4 +138,4 @@ download_progress_count {
|
|
|
137
138
|
.download_progress_bar::-webkit-progress-value {
|
|
138
139
|
background: var(--blue_prime_background);
|
|
139
140
|
border-radius: var(--radius_pill);
|
|
140
|
-
}
|
|
141
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const {Animation} = require(
|
|
2
|
-
const {setStyles, getTime, optionOr} = require(
|
|
3
|
-
const {LAYOUT_ROLE, requireLayoutNode} = require(
|
|
4
|
-
const {I18n} = require(
|
|
5
|
-
const {Icons} = require("../chui_icons/icons");
|
|
1
|
+
const { Animation } = require("../../modules/chui_animations/animations");
|
|
2
|
+
const { setStyles, getTime, optionOr } = require("../../modules/chui_functions");
|
|
3
|
+
const { LAYOUT_ROLE, requireLayoutNode } = require("../../modules/chui_layout/chui_layout");
|
|
4
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
5
|
+
const { Icons } = require("../chui_icons/icons");
|
|
6
6
|
// Плашка значка — общая на всё семейство карточек уведомлений
|
|
7
|
-
const {createStatusPlate, setStatusPlate} = require("./status_plate");
|
|
7
|
+
const { createStatusPlate, setStatusPlate } = require("./status_plate");
|
|
8
8
|
|
|
9
9
|
class DownloadProgressNotification {
|
|
10
10
|
#id = require("randomstring").generate();
|
|
@@ -20,56 +20,58 @@ class DownloadProgressNotification {
|
|
|
20
20
|
#id_progress = require("randomstring").generate();
|
|
21
21
|
#ProgressBar = document.createElement(`progress`);
|
|
22
22
|
#main = document.createElement("download_progress_block");
|
|
23
|
-
#progress_text_block = document.createElement(
|
|
23
|
+
#progress_text_block = document.createElement("download_progress_text_block");
|
|
24
24
|
#id_progress_count = require("randomstring").generate();
|
|
25
|
-
#progress_count = document.createElement(
|
|
25
|
+
#progress_count = document.createElement("download_progress_count");
|
|
26
26
|
#id_progress_text = require("randomstring").generate();
|
|
27
|
-
#progress_text = document.createElement(
|
|
27
|
+
#progress_text = document.createElement("download_progress_text");
|
|
28
28
|
constructor(options = { title: String(), text: String(), type: String() }) {
|
|
29
|
-
setStyles(__dirname + "/notification_download_progress.css",
|
|
29
|
+
setStyles(__dirname + "/notification_download_progress.css", "chUiJS_downloadProgressNotification");
|
|
30
30
|
this.#download_notification.id = this.#id;
|
|
31
|
-
|
|
31
|
+
// Ход загрузки объявляется вежливо; итог с ошибкой меняет роль в `#renderTest()`
|
|
32
|
+
this.#download_notification.setAttribute("role", "status");
|
|
33
|
+
this.#download_notification_title.id = this.#id_download_notification_title;
|
|
32
34
|
// Пустая заготовка опции равносильна отсутствующей
|
|
33
35
|
if (optionOr(options.title, undefined) !== undefined) {
|
|
34
36
|
this.#download_notification_title.innerText = options.title;
|
|
35
37
|
} else {
|
|
36
38
|
throw new Error("Должна быть установлена опция title");
|
|
37
39
|
}
|
|
38
|
-
this.#download_notification_body.style.width = "-webkit-fill-available"
|
|
40
|
+
this.#download_notification_body.style.width = "-webkit-fill-available";
|
|
39
41
|
this.#download_notification_date.innerHTML = getTime();
|
|
40
|
-
this.#download_notification_header.appendChild(this.#download_notification_title)
|
|
41
|
-
this.#download_notification_header.appendChild(this.#download_notification_date)
|
|
42
|
-
this.#download_notification_content.appendChild(this.#download_notification_header)
|
|
43
|
-
this.#download_notification_content.appendChild(this.#download_notification_body)
|
|
42
|
+
this.#download_notification_header.appendChild(this.#download_notification_title);
|
|
43
|
+
this.#download_notification_header.appendChild(this.#download_notification_date);
|
|
44
|
+
this.#download_notification_content.appendChild(this.#download_notification_header);
|
|
45
|
+
this.#download_notification_content.appendChild(this.#download_notification_body);
|
|
44
46
|
// Значок состояния — в плашке слева, как у Notification
|
|
45
47
|
this.#download_notification_icon = createStatusPlate(undefined, Icons.FILE.DOWNLOADING);
|
|
46
|
-
this.#download_notification.appendChild(this.#download_notification_icon)
|
|
47
|
-
this.#download_notification.appendChild(this.#download_notification_content)
|
|
48
|
+
this.#download_notification.appendChild(this.#download_notification_icon);
|
|
49
|
+
this.#download_notification.appendChild(this.#download_notification_content);
|
|
48
50
|
|
|
49
51
|
//
|
|
50
52
|
if (options.max !== undefined) this.#ProgressBar.max = options.max;
|
|
51
53
|
this.#ProgressBar.id = this.#id_progress;
|
|
52
|
-
this.#ProgressBar.className = "download_progress_bar"
|
|
53
|
-
this.#progress_count.id = this.#id_progress_count
|
|
54
|
-
this.#progress_count.setAttribute(
|
|
55
|
-
this.#progress_text.id = this.#id_progress_text
|
|
56
|
-
this.#progress_text.setAttribute(
|
|
57
|
-
this.#progress_text_block.appendChild(this.#progress_text)
|
|
58
|
-
this.#progress_text_block.appendChild(this.#progress_count)
|
|
54
|
+
this.#ProgressBar.className = "download_progress_bar";
|
|
55
|
+
this.#progress_count.id = this.#id_progress_count;
|
|
56
|
+
this.#progress_count.setAttribute("for", this.#id_progress);
|
|
57
|
+
this.#progress_text.id = this.#id_progress_text;
|
|
58
|
+
this.#progress_text.setAttribute("for", this.#id_progress);
|
|
59
|
+
this.#progress_text_block.appendChild(this.#progress_text);
|
|
60
|
+
this.#progress_text_block.appendChild(this.#progress_count);
|
|
59
61
|
|
|
60
|
-
this.#main.appendChild(this.#progress_text_block)
|
|
61
|
-
this.#main.appendChild(this.#ProgressBar)
|
|
62
|
+
this.#main.appendChild(this.#progress_text_block);
|
|
63
|
+
this.#main.appendChild(this.#ProgressBar);
|
|
62
64
|
//
|
|
63
65
|
this.#main.style.width = "-webkit-fill-available";
|
|
64
66
|
this.#progress_text.innerText = "...";
|
|
65
|
-
this.#progress_count.innerText = I18n.t("feedback.progressCount", {value: 0, max: 0})
|
|
67
|
+
this.#progress_count.innerText = I18n.t("feedback.progressCount", { value: 0, max: 0 });
|
|
66
68
|
this.#ProgressBar.value = 0;
|
|
67
|
-
this.#download_notification_body.appendChild(this.#main)
|
|
69
|
+
this.#download_notification_body.appendChild(this.#main);
|
|
68
70
|
}
|
|
69
71
|
update(title = String(), text = String(), value = Number(), max = Number()) {
|
|
70
72
|
this.#download_notification_title.innerText = title;
|
|
71
73
|
this.#progress_text.innerText = text;
|
|
72
|
-
this.#progress_count.innerText = I18n.t("feedback.progressCount", {value: value, max: max})
|
|
74
|
+
this.#progress_count.innerText = I18n.t("feedback.progressCount", { value: value, max: max });
|
|
73
75
|
this.#ProgressBar.value = value;
|
|
74
76
|
this.#ProgressBar.max = max;
|
|
75
77
|
}
|
|
@@ -77,7 +79,9 @@ class DownloadProgressNotification {
|
|
|
77
79
|
const panel = requireLayoutNode(LAYOUT_ROLE.NOTIFICATION_PANEL, this.#download_notification);
|
|
78
80
|
panel.appendChild(this.#download_notification);
|
|
79
81
|
new Animation(this.#download_notification).slideRightIn();
|
|
80
|
-
this.#download_notification.addEventListener("click", () =>
|
|
82
|
+
this.#download_notification.addEventListener("click", () =>
|
|
83
|
+
this.#hideNotification(this.#download_notification)
|
|
84
|
+
);
|
|
81
85
|
}
|
|
82
86
|
done() {
|
|
83
87
|
this.#renderTest("download_notification_success", "success");
|
|
@@ -89,6 +93,8 @@ class DownloadProgressNotification {
|
|
|
89
93
|
#renderTest(className, status) {
|
|
90
94
|
const notification = this.#download_notification;
|
|
91
95
|
notification.className = className;
|
|
96
|
+
// Ошибку объявляем сразу, успех — вежливо (как у `Toast`)
|
|
97
|
+
notification.setAttribute("role", status === "error" ? "alert" : "status");
|
|
92
98
|
setStatusPlate(this.#download_notification_icon, status);
|
|
93
99
|
setTimeout(() => this.#hideNotification(notification), 2000);
|
|
94
100
|
}
|
|
@@ -98,20 +104,20 @@ class DownloadProgressNotification {
|
|
|
98
104
|
// Точечный сброс следов анимации вместо стирания всего атрибута `style`
|
|
99
105
|
notification.style.removeProperty("animation-name");
|
|
100
106
|
notification.style.removeProperty("transition");
|
|
101
|
-
notification.style.display =
|
|
102
|
-
notification.style.width =
|
|
103
|
-
notification.style.opacity = "0"
|
|
104
|
-
notification.style.transform = "translateX(100%)"
|
|
107
|
+
notification.style.display = "flex";
|
|
108
|
+
notification.style.width = "-webkit-fill-available";
|
|
109
|
+
notification.style.opacity = "0";
|
|
110
|
+
notification.style.transform = "translateX(100%)";
|
|
105
111
|
let box = requireLayoutNode(LAYOUT_ROLE.NOTIFICATION_BOX_MAIN, notification);
|
|
106
112
|
// В истории запись плоская и без курсора: класс снимает стекло, тень и отклик на наведение
|
|
107
113
|
notification.classList.add("notification_in_box");
|
|
108
|
-
box.appendChild(notification)
|
|
114
|
+
box.appendChild(notification);
|
|
109
115
|
setTimeout(() => {
|
|
110
|
-
notification.style.opacity = "1"
|
|
111
|
-
notification.style.transform = "translateX(0)"
|
|
112
|
-
}, 500)
|
|
113
|
-
})
|
|
116
|
+
notification.style.opacity = "1";
|
|
117
|
+
notification.style.transform = "translateX(0)";
|
|
118
|
+
}, 500);
|
|
119
|
+
});
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
|
|
117
|
-
exports.DownloadProgressNotification = DownloadProgressNotification
|
|
123
|
+
exports.DownloadProgressNotification = DownloadProgressNotification;
|