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,8 +1,8 @@
|
|
|
1
|
-
const {Icon, Icons} = require("../chui_icons/icons");
|
|
2
|
-
const {I18n} = require("../../modules/chui_i18n/chui_i18n");
|
|
3
|
-
const {optionOr} = require("../../modules/chui_functions");
|
|
4
|
-
const {SegmentedControl} = require("../chui_segmented_control/segmented_control");
|
|
5
|
-
const {Desktop} = require("../../modules/chui_services/desktop");
|
|
1
|
+
const { Icon, Icons } = require("../chui_icons/icons");
|
|
2
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
3
|
+
const { optionOr } = require("../../modules/chui_functions");
|
|
4
|
+
const { SegmentedControl } = require("../chui_segmented_control/segmented_control");
|
|
5
|
+
const { Desktop } = require("../../modules/chui_services/desktop");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Переключатель темы: светлая, тёмная и системная (набор задаётся опцией `modes`).
|
|
@@ -21,18 +21,18 @@ class ThemeToggle {
|
|
|
21
21
|
static MODE = {
|
|
22
22
|
LIGHT: "light",
|
|
23
23
|
DARK: "dark",
|
|
24
|
-
SYSTEM: "system"
|
|
24
|
+
SYSTEM: "system",
|
|
25
25
|
};
|
|
26
26
|
// Ключи подписей режимов; сам текст берётся лениво — язык может смениться между запусками
|
|
27
27
|
static #DEFAULT_LABEL_KEYS = {
|
|
28
28
|
light: "graphics.themeLight",
|
|
29
29
|
dark: "graphics.themeDark",
|
|
30
|
-
system: "graphics.themeSystem"
|
|
30
|
+
system: "graphics.themeSystem",
|
|
31
31
|
};
|
|
32
32
|
static #ICONS = {
|
|
33
33
|
light: "LIGHT_MODE",
|
|
34
34
|
dark: "DARK_MODE",
|
|
35
|
-
system: "BRIGHTNESS_AUTO"
|
|
35
|
+
system: "BRIGHTNESS_AUTO",
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
#control = undefined;
|
|
@@ -43,30 +43,35 @@ class ThemeToggle {
|
|
|
43
43
|
#unsubscribe = undefined;
|
|
44
44
|
#bound = false;
|
|
45
45
|
|
|
46
|
-
constructor(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
constructor(
|
|
47
|
+
options = {
|
|
48
|
+
modes: [],
|
|
49
|
+
labels: {},
|
|
50
|
+
label: String(),
|
|
51
|
+
onChange: undefined,
|
|
52
|
+
}
|
|
53
|
+
) {
|
|
52
54
|
if (Array.isArray(options.modes) && options.modes.length > 0) this.#modes = options.modes;
|
|
53
55
|
this.#labels = options.labels === undefined ? {} : options.labels;
|
|
54
56
|
this.#on_change = options.onChange;
|
|
55
57
|
this.#control = new SegmentedControl({
|
|
56
58
|
id: options.id,
|
|
57
59
|
label: optionOr(options.label, I18n.t("graphics.settingsAppearance")),
|
|
58
|
-
options: this.#modes.map((mode) => ({value: mode, title: this.#title(mode), icon: this.#icon(mode)})),
|
|
60
|
+
options: this.#modes.map((mode) => ({ value: mode, title: this.#title(mode), icon: this.#icon(mode) })),
|
|
59
61
|
// Нажатие в переключателе — это выбор темы, а не просто новая подсветка
|
|
60
|
-
onChange: (mode) => this.setTheme(mode).catch(() => {})
|
|
62
|
+
onChange: (mode) => this.setTheme(mode).catch(() => {}),
|
|
61
63
|
});
|
|
62
64
|
this.#bound = true;
|
|
63
65
|
// Смена темы системой не проходит через переключатель — вид обновляем подпиской
|
|
64
66
|
this.#unsubscribe = Desktop.theme.onChange((theme) => this.#syncView(theme));
|
|
65
|
-
Desktop.theme
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
Desktop.theme
|
|
68
|
+
.get()
|
|
69
|
+
.then((state) => {
|
|
70
|
+
if (!this.#bound) return;
|
|
71
|
+
this.#source = state.source;
|
|
72
|
+
this.#syncView(state.theme);
|
|
73
|
+
})
|
|
74
|
+
.catch(() => {});
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
// GET
|
|
@@ -155,4 +160,4 @@ class ThemeToggle {
|
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
|
|
158
|
-
exports.ThemeToggle = ThemeToggle
|
|
163
|
+
exports.ThemeToggle = ThemeToggle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const {setStyles, optionOr} = require("../../modules/chui_functions");
|
|
2
|
-
const {I18n} = require("../../modules/chui_i18n/chui_i18n");
|
|
3
|
-
const {Icon} = require("../chui_icons/icons");
|
|
1
|
+
const { setStyles, optionOr } = require("../../modules/chui_functions");
|
|
2
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
3
|
+
const { Icon } = require("../chui_icons/icons");
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Лента событий: что случилось и когда.
|
|
@@ -29,7 +29,7 @@ class Timeline {
|
|
|
29
29
|
DEFAULT: "default",
|
|
30
30
|
SUCCESS: "success",
|
|
31
31
|
WARNING: "warning",
|
|
32
|
-
ERROR: "error"
|
|
32
|
+
ERROR: "error",
|
|
33
33
|
};
|
|
34
34
|
static #counter = 0;
|
|
35
35
|
|
|
@@ -39,12 +39,14 @@ class Timeline {
|
|
|
39
39
|
#items = [];
|
|
40
40
|
#label = undefined;
|
|
41
41
|
|
|
42
|
-
constructor(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
constructor(
|
|
43
|
+
options = {
|
|
44
|
+
id: String(),
|
|
45
|
+
items: [],
|
|
46
|
+
label: String(),
|
|
47
|
+
size: String(),
|
|
48
|
+
}
|
|
49
|
+
) {
|
|
48
50
|
setStyles(__dirname + "/styles.css", "chUiJS_Timeline");
|
|
49
51
|
Timeline.#counter += 1;
|
|
50
52
|
this.#id = options.id === undefined ? `chui_timeline_${Timeline.#counter}` : options.id;
|
|
@@ -215,9 +217,9 @@ class Timeline {
|
|
|
215
217
|
|
|
216
218
|
static SIZE = {
|
|
217
219
|
SMALL: "small",
|
|
218
|
-
DEFAULT: "default"
|
|
220
|
+
DEFAULT: "default",
|
|
219
221
|
};
|
|
220
222
|
static ICON_SIZE = "16px";
|
|
221
223
|
}
|
|
222
224
|
|
|
223
|
-
exports.Timeline = Timeline
|
|
225
|
+
exports.Timeline = Timeline;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const {Animation} = require(
|
|
2
|
-
const {makeKeyboardButton} = require(
|
|
3
|
-
const {Icon, Icons} = require(
|
|
4
|
-
const {Button} = require(
|
|
5
|
-
const {setStyles, markdownToHtml, optionOr} = require(
|
|
6
|
-
const {I18n} = require(
|
|
1
|
+
const { Animation } = require("../../modules/chui_animations/animations");
|
|
2
|
+
const { makeKeyboardButton } = require("../../modules/chui_a11y/chui_a11y");
|
|
3
|
+
const { Icon, Icons } = require("../chui_icons/icons");
|
|
4
|
+
const { Button } = require("../chui_button/button");
|
|
5
|
+
const { setStyles, markdownToHtml, optionOr } = require("../../modules/chui_functions");
|
|
6
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
7
7
|
// Плашка значка — общая с карточками уведомлений: одна фигура и одни цвета статуса
|
|
8
|
-
const {createStatusPlate, setStatusPlate} = require("../chui_notification/status_plate");
|
|
8
|
+
const { createStatusPlate, setStatusPlate } = require("../chui_notification/status_plate");
|
|
9
9
|
|
|
10
10
|
/** Стили тостов. `ERROR` объявляется скринридером сразу (`role="alert"`), остальные — вежливо (`role="status"`). */
|
|
11
11
|
const STYLE = {
|
|
12
12
|
INFO: "toast_info",
|
|
13
13
|
SUCCESS: "toast_success",
|
|
14
14
|
WARNING: "toast_warning",
|
|
15
|
-
ERROR: "toast_error"
|
|
15
|
+
ERROR: "toast_error",
|
|
16
16
|
};
|
|
17
17
|
/** Угол окна, в котором растёт стопка тостов */
|
|
18
18
|
const POSITION = {
|
|
19
19
|
TOP_LEFT: "top_left",
|
|
20
20
|
TOP_RIGHT: "top_right",
|
|
21
21
|
BOTTOM_LEFT: "bottom_left",
|
|
22
|
-
BOTTOM_RIGHT: "bottom_right"
|
|
22
|
+
BOTTOM_RIGHT: "bottom_right",
|
|
23
23
|
};
|
|
24
24
|
/** Ключ статуса для общей плашки значка: глифы и цвета те же, что у карточек уведомлений */
|
|
25
25
|
const PLATE_STATUS = {
|
|
26
26
|
[STYLE.INFO]: undefined,
|
|
27
27
|
[STYLE.SUCCESS]: "success",
|
|
28
28
|
[STYLE.WARNING]: "warning",
|
|
29
|
-
[STYLE.ERROR]: "error"
|
|
29
|
+
[STYLE.ERROR]: "error",
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -67,17 +67,19 @@ class Toast {
|
|
|
67
67
|
#on_dismiss = undefined;
|
|
68
68
|
#listeners = [];
|
|
69
69
|
|
|
70
|
-
constructor(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
constructor(
|
|
71
|
+
options = {
|
|
72
|
+
id: String(),
|
|
73
|
+
style: String(),
|
|
74
|
+
title: String(),
|
|
75
|
+
text: String(),
|
|
76
|
+
markdownText: String(),
|
|
77
|
+
duration: Number(),
|
|
78
|
+
closable: Boolean(),
|
|
79
|
+
icon: String(),
|
|
80
|
+
action: { title: String(), listener: undefined, close: Boolean() },
|
|
81
|
+
}
|
|
82
|
+
) {
|
|
81
83
|
setStyles(__dirname + "/styles.css", "chUiJS_ToastQueue");
|
|
82
84
|
Toast.#counter += 1;
|
|
83
85
|
this.#id = options.id === undefined ? `chui_toast_${Toast.#counter}` : options.id;
|
|
@@ -263,7 +265,7 @@ class Toast {
|
|
|
263
265
|
#onTimeout = () => {
|
|
264
266
|
this.#timer = undefined;
|
|
265
267
|
this.dismiss();
|
|
266
|
-
}
|
|
268
|
+
};
|
|
267
269
|
|
|
268
270
|
#clearTimer() {
|
|
269
271
|
if (this.#timer !== undefined) clearTimeout(this.#timer);
|
|
@@ -284,7 +286,7 @@ class Toast {
|
|
|
284
286
|
clickEvent: () => {
|
|
285
287
|
if (action.listener !== undefined) action.listener();
|
|
286
288
|
if (action.close !== false) this.dismiss();
|
|
287
|
-
}
|
|
289
|
+
},
|
|
288
290
|
});
|
|
289
291
|
this.#actions.appendChild(button.set());
|
|
290
292
|
}
|
|
@@ -347,15 +349,17 @@ class ToastQueue {
|
|
|
347
349
|
#duration = ToastQueue.DEFAULT_DURATION;
|
|
348
350
|
#closable = true;
|
|
349
351
|
|
|
350
|
-
constructor(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
352
|
+
constructor(
|
|
353
|
+
options = {
|
|
354
|
+
id: String(),
|
|
355
|
+
position: String(),
|
|
356
|
+
max: Number(),
|
|
357
|
+
duration: Number(),
|
|
358
|
+
width: String(),
|
|
359
|
+
closable: Boolean(),
|
|
360
|
+
label: String(),
|
|
361
|
+
}
|
|
362
|
+
) {
|
|
359
363
|
setStyles(__dirname + "/styles.css", "chUiJS_ToastQueue");
|
|
360
364
|
ToastQueue.#counter += 1;
|
|
361
365
|
this.#id = options.id === undefined ? `chui_toast_queue_${ToastQueue.#counter}` : options.id;
|
|
@@ -425,20 +429,22 @@ class ToastQueue {
|
|
|
425
429
|
|
|
426
430
|
// ОЧЕРЕДЬ
|
|
427
431
|
/** Добавить тост: title, text, markdownText, style, duration, closable, icon, action, id */
|
|
428
|
-
push(
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
432
|
+
push(
|
|
433
|
+
options = {
|
|
434
|
+
title: String(),
|
|
435
|
+
text: String(),
|
|
436
|
+
markdownText: String(),
|
|
437
|
+
style: String(),
|
|
438
|
+
duration: Number(),
|
|
439
|
+
closable: Boolean(),
|
|
440
|
+
icon: String(),
|
|
441
|
+
action: { title: String(), listener: undefined, close: Boolean() },
|
|
442
|
+
}
|
|
443
|
+
) {
|
|
438
444
|
const toast = new Toast({
|
|
439
445
|
...options,
|
|
440
446
|
duration: options.duration === undefined ? this.#duration : options.duration,
|
|
441
|
-
closable: options.closable === undefined ? this.#closable : options.closable
|
|
447
|
+
closable: options.closable === undefined ? this.#closable : options.closable,
|
|
442
448
|
});
|
|
443
449
|
toast.onDismiss(() => this.#forget(toast));
|
|
444
450
|
this.#toasts.push(toast);
|
|
@@ -451,7 +457,7 @@ class ToastQueue {
|
|
|
451
457
|
|
|
452
458
|
/** Убрать тост по объекту или по id (без id — ничего не делает) */
|
|
453
459
|
dismiss(target) {
|
|
454
|
-
const toast = typeof target === "string" ? this.#toasts.find(item => item.getId() === target) : target;
|
|
460
|
+
const toast = typeof target === "string" ? this.#toasts.find((item) => item.getId() === target) : target;
|
|
455
461
|
if (toast === undefined || toast === null) return this;
|
|
456
462
|
toast.dismiss();
|
|
457
463
|
return this;
|
|
@@ -491,5 +497,5 @@ class ToastQueue {
|
|
|
491
497
|
}
|
|
492
498
|
}
|
|
493
499
|
|
|
494
|
-
exports.ToastQueue = ToastQueue
|
|
495
|
-
exports.Toast = Toast
|
|
500
|
+
exports.ToastQueue = ToastQueue;
|
|
501
|
+
exports.Toast = Toast;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const {setStyles, optionOr} = require(
|
|
2
|
-
const {A11Y_FOCUSABLE_SELECTOR} = require(
|
|
3
|
-
const {I18n} = require(
|
|
1
|
+
const { setStyles, optionOr } = require("../../modules/chui_functions");
|
|
2
|
+
const { A11Y_FOCUSABLE_SELECTOR } = require("../../modules/chui_a11y/chui_a11y");
|
|
3
|
+
const { I18n } = require("../../modules/chui_i18n/chui_i18n");
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Панель инструментов: ряд кнопок и контролов с одним «стопом» клавиатуры.
|
|
@@ -26,7 +26,7 @@ const {I18n} = require('../../modules/chui_i18n/chui_i18n');
|
|
|
26
26
|
class Toolbar {
|
|
27
27
|
static ORIENTATION = {
|
|
28
28
|
HORIZONTAL: "horizontal",
|
|
29
|
-
VERTICAL: "vertical"
|
|
29
|
+
VERTICAL: "vertical",
|
|
30
30
|
};
|
|
31
31
|
static #counter = 0;
|
|
32
32
|
|
|
@@ -35,12 +35,14 @@ class Toolbar {
|
|
|
35
35
|
#orientation = Toolbar.ORIENTATION.HORIZONTAL;
|
|
36
36
|
#label = I18n.t("navigation.toolbar");
|
|
37
37
|
|
|
38
|
-
constructor(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
constructor(
|
|
39
|
+
options = {
|
|
40
|
+
id: String(),
|
|
41
|
+
orientation: String(),
|
|
42
|
+
label: String(),
|
|
43
|
+
items: [],
|
|
44
|
+
}
|
|
45
|
+
) {
|
|
44
46
|
setStyles(__dirname + "/styles.css", "chUiJS_Toolbar");
|
|
45
47
|
Toolbar.#counter += 1;
|
|
46
48
|
this.#id = options.id === undefined ? `chui_toolbar_${Toolbar.#counter}` : options.id;
|
|
@@ -80,7 +82,10 @@ class Toolbar {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
setOrientation(orientation = String()) {
|
|
83
|
-
this.#orientation =
|
|
85
|
+
this.#orientation =
|
|
86
|
+
orientation === Toolbar.ORIENTATION.VERTICAL
|
|
87
|
+
? Toolbar.ORIENTATION.VERTICAL
|
|
88
|
+
: Toolbar.ORIENTATION.HORIZONTAL;
|
|
84
89
|
this.#root.dataset.orientation = this.#orientation;
|
|
85
90
|
this.#root.setAttribute("aria-orientation", this.#orientation);
|
|
86
91
|
return this;
|
|
@@ -129,7 +134,9 @@ class Toolbar {
|
|
|
129
134
|
const forward = this.#orientation === Toolbar.ORIENTATION.VERTICAL ? "ArrowDown" : "ArrowRight";
|
|
130
135
|
if (![backward, forward, "Home", "End"].includes(event.key)) return;
|
|
131
136
|
const items = this.#focusable();
|
|
132
|
-
const current = items.findIndex(
|
|
137
|
+
const current = items.findIndex(
|
|
138
|
+
(node) => node === document.activeElement || node.contains(document.activeElement)
|
|
139
|
+
);
|
|
133
140
|
if (current === -1) return;
|
|
134
141
|
event.preventDefault();
|
|
135
142
|
if (event.key === "Home") items[0].focus();
|
|
@@ -142,4 +149,4 @@ class Toolbar {
|
|
|
142
149
|
};
|
|
143
150
|
}
|
|
144
151
|
|
|
145
|
-
exports.Toolbar = Toolbar
|
|
152
|
+
exports.Toolbar = Toolbar;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {setStyles, markdownToHtml, htmlToMarkdown, optionOr} = require(
|
|
1
|
+
const { setStyles, markdownToHtml, htmlToMarkdown, optionOr } = require("../../modules/chui_functions");
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Всплывающая подсказка (тултип) к любому элементу.
|
|
@@ -24,7 +24,7 @@ class Tooltip {
|
|
|
24
24
|
TOP: "top",
|
|
25
25
|
BOTTOM: "bottom",
|
|
26
26
|
LEFT: "left",
|
|
27
|
-
RIGHT: "right"
|
|
27
|
+
RIGHT: "right",
|
|
28
28
|
};
|
|
29
29
|
/** Зазор между целью и подсказкой, px */
|
|
30
30
|
static GAP = 8;
|
|
@@ -45,13 +45,15 @@ class Tooltip {
|
|
|
45
45
|
// destroy() сделан окончательным: после него инстанс не показывает подсказку и не вешает описания
|
|
46
46
|
#destroyed = false;
|
|
47
47
|
|
|
48
|
-
constructor(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
constructor(
|
|
49
|
+
options = {
|
|
50
|
+
id: String(),
|
|
51
|
+
text: String(),
|
|
52
|
+
markdownText: String(),
|
|
53
|
+
placement: String(),
|
|
54
|
+
delay: Number(),
|
|
55
|
+
}
|
|
56
|
+
) {
|
|
55
57
|
setStyles(__dirname + "/styles.css", "chUiJS_Tooltip");
|
|
56
58
|
// Пустая заготовка опции равносильна отсутствующей
|
|
57
59
|
const text = optionOr(options.text, undefined);
|
|
@@ -119,11 +121,15 @@ class Tooltip {
|
|
|
119
121
|
if (this.#destroyed) return this;
|
|
120
122
|
const element = Tooltip.#resolve(target);
|
|
121
123
|
if (element === undefined || element === null) return this;
|
|
122
|
-
if (this.#targets.some(entry => entry.element === element)) return this;
|
|
124
|
+
if (this.#targets.some((entry) => entry.element === element)) return this;
|
|
123
125
|
// Описание вешается на фокусируемый узел: у обёртки-компонента (Button → chui_button)
|
|
124
126
|
// свой aria-describedby скринридеру не достаётся — читают кнопку, а не обёртку
|
|
125
127
|
const described = Tooltip.#describedTarget(element);
|
|
126
|
-
const entry = {
|
|
128
|
+
const entry = {
|
|
129
|
+
element: element,
|
|
130
|
+
described: described,
|
|
131
|
+
describedBy: described.getAttribute("aria-describedby"),
|
|
132
|
+
};
|
|
127
133
|
entry.onMouseEnter = () => this.#scheduleShow(element);
|
|
128
134
|
entry.onMouseLeave = (event) => {
|
|
129
135
|
// Переход внутрь цели (к её детям) подсказку не закрывает
|
|
@@ -153,7 +159,7 @@ class Tooltip {
|
|
|
153
159
|
|
|
154
160
|
detach(target) {
|
|
155
161
|
const element = Tooltip.#resolve(target);
|
|
156
|
-
const index = this.#targets.findIndex(entry => entry.element === element);
|
|
162
|
+
const index = this.#targets.findIndex((entry) => entry.element === element);
|
|
157
163
|
if (index === -1) return this;
|
|
158
164
|
const entry = this.#targets[index];
|
|
159
165
|
element.removeEventListener("mouseenter", entry.onMouseEnter);
|
|
@@ -170,9 +176,12 @@ class Tooltip {
|
|
|
170
176
|
// ПОКАЗ / СКРЫТИЕ
|
|
171
177
|
show(target = undefined) {
|
|
172
178
|
if (this.#destroyed || !document.body.contains(this.#tooltip)) return;
|
|
173
|
-
const element =
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
const element =
|
|
180
|
+
target === undefined
|
|
181
|
+
? this.#current !== undefined
|
|
182
|
+
? this.#current
|
|
183
|
+
: Tooltip.#resolve((this.#targets[0] || {}).element)
|
|
184
|
+
: Tooltip.#resolve(target);
|
|
176
185
|
if (element === undefined || element === null || !document.body.contains(element)) return;
|
|
177
186
|
this.#clearTimer();
|
|
178
187
|
this.#current = element;
|
|
@@ -224,7 +233,7 @@ class Tooltip {
|
|
|
224
233
|
}
|
|
225
234
|
const ids = String(entry.describedBy === null ? "" : entry.describedBy)
|
|
226
235
|
.split(/\s+/)
|
|
227
|
-
.filter(id => id !== "");
|
|
236
|
+
.filter((id) => id !== "");
|
|
228
237
|
if (!ids.includes(this.#id)) ids.push(this.#id);
|
|
229
238
|
entry.described.setAttribute("aria-describedby", ids.join(" "));
|
|
230
239
|
}
|
|
@@ -265,9 +274,12 @@ class Tooltip {
|
|
|
265
274
|
let placement = this.#placement;
|
|
266
275
|
// Флип на противоположную сторону, если по выбранной подсказка не помещается
|
|
267
276
|
if (placement === Tooltip.PLACEMENT.TOP && rect.top - height - gap < edge) placement = Tooltip.PLACEMENT.BOTTOM;
|
|
268
|
-
else if (placement === Tooltip.PLACEMENT.BOTTOM && rect.bottom + height + gap > window.innerHeight - edge)
|
|
269
|
-
|
|
270
|
-
else if (placement === Tooltip.PLACEMENT.
|
|
277
|
+
else if (placement === Tooltip.PLACEMENT.BOTTOM && rect.bottom + height + gap > window.innerHeight - edge)
|
|
278
|
+
placement = Tooltip.PLACEMENT.TOP;
|
|
279
|
+
else if (placement === Tooltip.PLACEMENT.LEFT && rect.left - width - gap < edge)
|
|
280
|
+
placement = Tooltip.PLACEMENT.RIGHT;
|
|
281
|
+
else if (placement === Tooltip.PLACEMENT.RIGHT && rect.right + width + gap > window.innerWidth - edge)
|
|
282
|
+
placement = Tooltip.PLACEMENT.LEFT;
|
|
271
283
|
|
|
272
284
|
let left, top;
|
|
273
285
|
if (placement === Tooltip.PLACEMENT.LEFT || placement === Tooltip.PLACEMENT.RIGHT) {
|
|
@@ -303,10 +315,11 @@ class Tooltip {
|
|
|
303
315
|
#scheduleShow(element) {
|
|
304
316
|
if (!document.body.contains(element)) return;
|
|
305
317
|
this.#clearTimer();
|
|
306
|
-
if (this.#delay > 0)
|
|
307
|
-
this.#timer =
|
|
308
|
-
|
|
309
|
-
|
|
318
|
+
if (this.#delay > 0)
|
|
319
|
+
this.#timer = setTimeout(() => {
|
|
320
|
+
this.#timer = undefined;
|
|
321
|
+
this.show(element);
|
|
322
|
+
}, this.#delay);
|
|
310
323
|
else this.show(element);
|
|
311
324
|
}
|
|
312
325
|
|
|
@@ -317,4 +330,4 @@ class Tooltip {
|
|
|
317
330
|
}
|
|
318
331
|
}
|
|
319
332
|
|
|
320
|
-
exports.Tooltip = Tooltip
|
|
333
|
+
exports.Tooltip = Tooltip;
|
|
@@ -17,10 +17,15 @@ chui_tour {
|
|
|
17
17
|
tour_highlight {
|
|
18
18
|
position: absolute;
|
|
19
19
|
border-radius: var(--border_radius);
|
|
20
|
-
box-shadow:
|
|
20
|
+
box-shadow:
|
|
21
|
+
0 0 0 1px var(--blue_prime_background),
|
|
22
|
+
0 0 0 9999px var(--modal_scrim);
|
|
21
23
|
pointer-events: none;
|
|
22
|
-
transition:
|
|
23
|
-
|
|
24
|
+
transition:
|
|
25
|
+
left var(--transition_time) ease,
|
|
26
|
+
top var(--transition_time) ease,
|
|
27
|
+
width var(--transition_time) ease,
|
|
28
|
+
height var(--transition_time) ease;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
/* Без затемнения остаётся только рамка подсветки */
|