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
|
* Расписание: сетка времени по дням с событиями.
|
|
@@ -36,7 +36,7 @@ const {I18n} = require('../../modules/chui_i18n/chui_i18n');
|
|
|
36
36
|
class Scheduler {
|
|
37
37
|
static VIEW = {
|
|
38
38
|
DAY: "day",
|
|
39
|
-
WEEK: "week"
|
|
39
|
+
WEEK: "week",
|
|
40
40
|
};
|
|
41
41
|
static DEFAULT_HOUR_HEIGHT = 48;
|
|
42
42
|
static DEFAULT_SLOT_MINUTES = 30;
|
|
@@ -45,11 +45,11 @@ class Scheduler {
|
|
|
45
45
|
|
|
46
46
|
#root = document.createElement("chui_scheduler");
|
|
47
47
|
#title = document.createElement("scheduler_title");
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
48
|
+
#prevButton = document.createElement("button");
|
|
49
|
+
#nextButton = document.createElement("button");
|
|
50
|
+
#todayButton = document.createElement("button");
|
|
51
|
+
#viewButtons = new Map();
|
|
52
|
+
#daysHead = document.createElement("scheduler_days_head");
|
|
53
53
|
#scroll = document.createElement("scheduler_scroll");
|
|
54
54
|
#times = document.createElement("scheduler_times");
|
|
55
55
|
#days = document.createElement("scheduler_days");
|
|
@@ -57,32 +57,34 @@ class Scheduler {
|
|
|
57
57
|
#date = new Date();
|
|
58
58
|
#view = Scheduler.VIEW.WEEK;
|
|
59
59
|
#events = [];
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
60
|
+
#startHour = 8;
|
|
61
|
+
#endHour = 20;
|
|
62
|
+
#slotMinutes = Scheduler.DEFAULT_SLOT_MINUTES;
|
|
63
|
+
#hourHeight = Scheduler.DEFAULT_HOUR_HEIGHT;
|
|
64
|
+
#firstDay = Scheduler.DEFAULT_FIRST_DAY;
|
|
65
65
|
#label = undefined;
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
constructor(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
#onEventClick = undefined;
|
|
67
|
+
#onSlotClick = undefined;
|
|
68
|
+
#onPeriodChangeCallback = undefined;
|
|
69
|
+
|
|
70
|
+
constructor(
|
|
71
|
+
options = {
|
|
72
|
+
id: String(),
|
|
73
|
+
date: undefined,
|
|
74
|
+
view: String(),
|
|
75
|
+
events: [],
|
|
76
|
+
startHour: Number(),
|
|
77
|
+
endHour: Number(),
|
|
78
|
+
slotMinutes: Number(),
|
|
79
|
+
hourHeight: Number(),
|
|
80
|
+
firstDay: Number(),
|
|
81
|
+
height: String(),
|
|
82
|
+
label: String(),
|
|
83
|
+
onEventClick: undefined,
|
|
84
|
+
onSlotClick: undefined,
|
|
85
|
+
onPeriodChange: undefined,
|
|
86
|
+
}
|
|
87
|
+
) {
|
|
86
88
|
setStyles(__dirname + "/styles.css", "chUiJS_Scheduler");
|
|
87
89
|
Scheduler.#counter += 1;
|
|
88
90
|
this.#id = options.id === undefined ? `chui_scheduler_${Scheduler.#counter}` : options.id;
|
|
@@ -93,18 +95,18 @@ class Scheduler {
|
|
|
93
95
|
// вид, которого сетка не рисует
|
|
94
96
|
this.#view = options.view === Scheduler.VIEW.DAY ? Scheduler.VIEW.DAY : Scheduler.VIEW.WEEK;
|
|
95
97
|
this.#events = Array.isArray(options.events) ? [...options.events] : [];
|
|
96
|
-
this.#
|
|
97
|
-
this.#
|
|
98
|
-
this.#
|
|
99
|
-
this.#
|
|
100
|
-
this.#
|
|
101
|
-
this.#
|
|
102
|
-
this.#
|
|
103
|
-
this.#
|
|
98
|
+
this.#startHour = options.startHour === undefined ? this.#startHour : options.startHour;
|
|
99
|
+
this.#endHour = options.endHour === undefined ? this.#endHour : options.endHour;
|
|
100
|
+
this.#slotMinutes = options.slotMinutes === undefined ? this.#slotMinutes : options.slotMinutes;
|
|
101
|
+
this.#hourHeight = options.hourHeight === undefined ? this.#hourHeight : options.hourHeight;
|
|
102
|
+
this.#firstDay = options.firstDay === undefined ? this.#firstDay : options.firstDay;
|
|
103
|
+
this.#onEventClick = options.onEventClick;
|
|
104
|
+
this.#onSlotClick = options.onSlotClick;
|
|
105
|
+
this.#onPeriodChangeCallback = options.onPeriodChange;
|
|
104
106
|
this.setLabel(optionOr(options.label, I18n.t("scheduler.title")));
|
|
105
107
|
if (options.height !== undefined) this.setHeight(options.height);
|
|
106
108
|
this.#buildHead();
|
|
107
|
-
this.#root.appendChild(this.#
|
|
109
|
+
this.#root.appendChild(this.#daysHead);
|
|
108
110
|
this.#scroll.appendChild(this.#times);
|
|
109
111
|
this.#scroll.appendChild(this.#days);
|
|
110
112
|
this.#root.appendChild(this.#scroll);
|
|
@@ -129,7 +131,7 @@ class Scheduler {
|
|
|
129
131
|
/** Начало и конец показанного периода (включительно) */
|
|
130
132
|
getRange() {
|
|
131
133
|
const days = this.#dayDates();
|
|
132
|
-
return {from: days[0], to: days[days.length - 1]};
|
|
134
|
+
return { from: days[0], to: days[days.length - 1] };
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
getEvents() {
|
|
@@ -137,15 +139,15 @@ class Scheduler {
|
|
|
137
139
|
}
|
|
138
140
|
|
|
139
141
|
getStartHour() {
|
|
140
|
-
return this.#
|
|
142
|
+
return this.#startHour;
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
getEndHour() {
|
|
144
|
-
return this.#
|
|
146
|
+
return this.#endHour;
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
getSlotMinutes() {
|
|
148
|
-
return this.#
|
|
150
|
+
return this.#slotMinutes;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
/** События, попавшие на день (с учётом пересечения полуночи) */
|
|
@@ -250,7 +252,11 @@ class Scheduler {
|
|
|
250
252
|
}
|
|
251
253
|
|
|
252
254
|
static #sameDay(left = new Date(), right = new Date()) {
|
|
253
|
-
return
|
|
255
|
+
return (
|
|
256
|
+
left.getFullYear() === right.getFullYear() &&
|
|
257
|
+
left.getMonth() === right.getMonth() &&
|
|
258
|
+
left.getDate() === right.getDate()
|
|
259
|
+
);
|
|
254
260
|
}
|
|
255
261
|
|
|
256
262
|
static #eventDate(event = Object(), key = "start") {
|
|
@@ -260,7 +266,7 @@ class Scheduler {
|
|
|
260
266
|
#startOfPeriod() {
|
|
261
267
|
const day = Scheduler.#startOfDay(this.#date);
|
|
262
268
|
if (this.#view === Scheduler.VIEW.DAY) return day;
|
|
263
|
-
const offset = (day.getDay() - this.#
|
|
269
|
+
const offset = (day.getDay() - this.#firstDay + 7) % 7;
|
|
264
270
|
day.setDate(day.getDate() - offset);
|
|
265
271
|
return day;
|
|
266
272
|
}
|
|
@@ -268,7 +274,7 @@ class Scheduler {
|
|
|
268
274
|
#dayDates() {
|
|
269
275
|
const start = this.#startOfPeriod();
|
|
270
276
|
const count = this.#view === Scheduler.VIEW.DAY ? 1 : 7;
|
|
271
|
-
return Array.from({length: count}, (_, index) => {
|
|
277
|
+
return Array.from({ length: count }, (_, index) => {
|
|
272
278
|
const day = new Date(start);
|
|
273
279
|
day.setDate(start.getDate() + index);
|
|
274
280
|
return day;
|
|
@@ -299,13 +305,13 @@ class Scheduler {
|
|
|
299
305
|
*/
|
|
300
306
|
#layout(date = new Date()) {
|
|
301
307
|
const dayStart = this.#startOfDayMinutes();
|
|
302
|
-
const dayEnd = this.#
|
|
308
|
+
const dayEnd = this.#endHour * 60;
|
|
303
309
|
const items = [];
|
|
304
310
|
for (const event of this.#events) {
|
|
305
311
|
if (!this.#overlapsDay(event, date)) continue;
|
|
306
312
|
const start = Scheduler.#eventDate(event, "start");
|
|
307
313
|
const end = Scheduler.#eventDate(event, "end");
|
|
308
|
-
const finished = Number.isNaN(end.getTime()) ? new Date(start.getTime() + this.#
|
|
314
|
+
const finished = Number.isNaN(end.getTime()) ? new Date(start.getTime() + this.#slotMinutes * 60000) : end;
|
|
309
315
|
const sameStartDay = Scheduler.#sameDay(Scheduler.#startOfDay(start), date);
|
|
310
316
|
const sameEndDay = Scheduler.#sameDay(Scheduler.#startOfDay(finished), date);
|
|
311
317
|
let from = sameStartDay ? Scheduler.#minutesOf(start) : 0;
|
|
@@ -314,16 +320,16 @@ class Scheduler {
|
|
|
314
320
|
from = 0;
|
|
315
321
|
to = 24 * 60;
|
|
316
322
|
}
|
|
317
|
-
if (to <= from) to = from + this.#
|
|
323
|
+
if (to <= from) to = from + this.#slotMinutes;
|
|
318
324
|
from = Math.max(from, dayStart);
|
|
319
325
|
to = Math.min(to, dayEnd);
|
|
320
326
|
if (to <= from) continue;
|
|
321
|
-
items.push({event: event, index: this.#events.indexOf(event), start: from, end: to, lane: 0, lanes: 1});
|
|
327
|
+
items.push({ event: event, index: this.#events.indexOf(event), start: from, end: to, lane: 0, lanes: 1 });
|
|
322
328
|
}
|
|
323
329
|
items.sort((left, right) => left.start - right.start || left.end - right.end);
|
|
324
330
|
// Кластеры пересекающихся событий и дорожки внутри них
|
|
325
331
|
let cluster = [];
|
|
326
|
-
let
|
|
332
|
+
let clusterEnd = -1;
|
|
327
333
|
const flush = () => {
|
|
328
334
|
if (cluster.length === 0) return;
|
|
329
335
|
const lanes = [];
|
|
@@ -339,54 +345,57 @@ class Scheduler {
|
|
|
339
345
|
}
|
|
340
346
|
for (const item of cluster) item.lanes = lanes.length;
|
|
341
347
|
cluster = [];
|
|
342
|
-
|
|
348
|
+
clusterEnd = -1;
|
|
343
349
|
};
|
|
344
350
|
for (const item of items) {
|
|
345
|
-
if (cluster.length > 0 && item.start >=
|
|
351
|
+
if (cluster.length > 0 && item.start >= clusterEnd) flush();
|
|
346
352
|
cluster.push(item);
|
|
347
|
-
|
|
353
|
+
clusterEnd = Math.max(clusterEnd, item.end);
|
|
348
354
|
}
|
|
349
355
|
flush();
|
|
350
356
|
return items;
|
|
351
357
|
}
|
|
352
358
|
|
|
353
359
|
#startOfDayMinutes() {
|
|
354
|
-
return this.#
|
|
360
|
+
return this.#startHour * 60;
|
|
355
361
|
}
|
|
356
362
|
|
|
357
363
|
// === РЕНДЕР ===
|
|
358
364
|
#buildHead() {
|
|
359
365
|
const head = document.createElement("scheduler_head");
|
|
360
|
-
this.#
|
|
361
|
-
this.#
|
|
362
|
-
this.#
|
|
363
|
-
this.#
|
|
364
|
-
this.#
|
|
365
|
-
this.#
|
|
366
|
-
this.#
|
|
367
|
-
this.#
|
|
368
|
-
this.#
|
|
369
|
-
this.#
|
|
370
|
-
this.#
|
|
371
|
-
this.#
|
|
372
|
-
this.#
|
|
373
|
-
this.#
|
|
366
|
+
this.#prevButton.type = "button";
|
|
367
|
+
this.#nextButton.type = "button";
|
|
368
|
+
this.#todayButton.type = "button";
|
|
369
|
+
this.#prevButton.className = "scheduler_nav";
|
|
370
|
+
this.#nextButton.className = "scheduler_nav";
|
|
371
|
+
this.#todayButton.className = "scheduler_today";
|
|
372
|
+
this.#prevButton.dataset.action = "prev";
|
|
373
|
+
this.#nextButton.dataset.action = "next";
|
|
374
|
+
this.#todayButton.dataset.action = "today";
|
|
375
|
+
this.#prevButton.innerText = "‹";
|
|
376
|
+
this.#nextButton.innerText = "›";
|
|
377
|
+
this.#todayButton.innerText = I18n.t("scheduler.today");
|
|
378
|
+
this.#prevButton.setAttribute("aria-label", I18n.t("scheduler.previousPeriod"));
|
|
379
|
+
this.#nextButton.setAttribute("aria-label", I18n.t("scheduler.nextPeriod"));
|
|
374
380
|
this.#title.setAttribute("aria-live", "polite");
|
|
375
381
|
const views = document.createElement("scheduler_views");
|
|
376
382
|
views.setAttribute("role", "group");
|
|
377
383
|
views.setAttribute("aria-label", I18n.t("scheduler.view"));
|
|
378
|
-
for (const [view, label] of [
|
|
384
|
+
for (const [view, label] of [
|
|
385
|
+
[Scheduler.VIEW.DAY, I18n.t("scheduler.day")],
|
|
386
|
+
[Scheduler.VIEW.WEEK, I18n.t("scheduler.week")],
|
|
387
|
+
]) {
|
|
379
388
|
const button = document.createElement("button");
|
|
380
389
|
button.type = "button";
|
|
381
390
|
button.className = "scheduler_view";
|
|
382
391
|
button.dataset.view = view;
|
|
383
392
|
button.innerText = label;
|
|
384
393
|
views.appendChild(button);
|
|
385
|
-
this.#
|
|
394
|
+
this.#viewButtons.set(view, button);
|
|
386
395
|
}
|
|
387
|
-
head.appendChild(this.#
|
|
388
|
-
head.appendChild(this.#
|
|
389
|
-
head.appendChild(this.#
|
|
396
|
+
head.appendChild(this.#prevButton);
|
|
397
|
+
head.appendChild(this.#nextButton);
|
|
398
|
+
head.appendChild(this.#todayButton);
|
|
390
399
|
head.appendChild(this.#title);
|
|
391
400
|
head.appendChild(views);
|
|
392
401
|
this.#root.appendChild(head);
|
|
@@ -396,28 +405,35 @@ class Scheduler {
|
|
|
396
405
|
const days = this.#dayDates();
|
|
397
406
|
const today = new Date();
|
|
398
407
|
this.#title.innerText = this.#periodTitle(days);
|
|
399
|
-
for (const [view, button] of this.#
|
|
400
|
-
|
|
401
|
-
this.#
|
|
408
|
+
for (const [view, button] of this.#viewButtons)
|
|
409
|
+
button.setAttribute("aria-pressed", view === this.#view ? "true" : "false");
|
|
410
|
+
this.#prevButton.setAttribute(
|
|
411
|
+
"aria-label",
|
|
412
|
+
this.#view === Scheduler.VIEW.DAY ? I18n.t("scheduler.previousDay") : I18n.t("scheduler.previousWeek")
|
|
413
|
+
);
|
|
414
|
+
this.#nextButton.setAttribute(
|
|
415
|
+
"aria-label",
|
|
416
|
+
this.#view === Scheduler.VIEW.DAY ? I18n.t("scheduler.nextDay") : I18n.t("scheduler.nextWeek")
|
|
417
|
+
);
|
|
402
418
|
// Заголовки дней лежат вне области прокрутки и повторяют колонки сетки; ширина
|
|
403
419
|
// вертикальной полосы прокрутки компенсируется, иначе заголовки уехали бы вправо
|
|
404
420
|
const scrollbar = Math.max(0, this.#scroll.offsetWidth - this.#scroll.clientWidth);
|
|
405
|
-
this.#
|
|
406
|
-
this.#
|
|
407
|
-
this.#
|
|
421
|
+
this.#daysHead.style.paddingRight = `${scrollbar}px`;
|
|
422
|
+
this.#daysHead.innerHTML = "";
|
|
423
|
+
this.#daysHead.style.gridTemplateColumns = `56px repeat(${days.length}, minmax(0, 1fr))`;
|
|
408
424
|
const corner = document.createElement("scheduler_corner");
|
|
409
425
|
corner.setAttribute("aria-hidden", "true");
|
|
410
|
-
this.#
|
|
426
|
+
this.#daysHead.appendChild(corner);
|
|
411
427
|
for (const day of days) {
|
|
412
428
|
const head = document.createElement("scheduler_day_head");
|
|
413
429
|
if (Scheduler.#sameDay(day, today)) head.classList.add("scheduler_today_head");
|
|
414
430
|
const name = document.createElement("scheduler_day_name");
|
|
415
|
-
name.innerText = day.toLocaleString(I18n.getLocale(), {weekday: "short"}).toUpperCase();
|
|
431
|
+
name.innerText = day.toLocaleString(I18n.getLocale(), { weekday: "short" }).toUpperCase();
|
|
416
432
|
const number = document.createElement("scheduler_day_number");
|
|
417
433
|
number.innerText = String(day.getDate());
|
|
418
434
|
head.appendChild(name);
|
|
419
435
|
head.appendChild(number);
|
|
420
|
-
this.#
|
|
436
|
+
this.#daysHead.appendChild(head);
|
|
421
437
|
}
|
|
422
438
|
this.#renderTimes();
|
|
423
439
|
this.#renderDays(days, today);
|
|
@@ -425,9 +441,9 @@ class Scheduler {
|
|
|
425
441
|
|
|
426
442
|
#renderTimes() {
|
|
427
443
|
this.#times.innerHTML = "";
|
|
428
|
-
for (let hour = this.#
|
|
444
|
+
for (let hour = this.#startHour; hour < this.#endHour; hour++) {
|
|
429
445
|
const cell = document.createElement("scheduler_hour");
|
|
430
|
-
cell.style.height = `${this.#
|
|
446
|
+
cell.style.height = `${this.#hourHeight}px`;
|
|
431
447
|
cell.innerText = `${String(hour).padStart(2, "0")}:00`;
|
|
432
448
|
this.#times.appendChild(cell);
|
|
433
449
|
}
|
|
@@ -439,10 +455,10 @@ class Scheduler {
|
|
|
439
455
|
for (const day of days) {
|
|
440
456
|
const column = document.createElement("scheduler_day");
|
|
441
457
|
column.dataset.day = Scheduler.#key(day);
|
|
442
|
-
column.style.height = `${(this.#
|
|
458
|
+
column.style.height = `${(this.#endHour - this.#startHour) * this.#hourHeight}px`;
|
|
443
459
|
if (Scheduler.#sameDay(day, today)) column.classList.add("scheduler_today");
|
|
444
460
|
// Часовые линии рисует фон: узлы на каждый час не нужны
|
|
445
|
-
column.style.backgroundSize = `100% ${this.#
|
|
461
|
+
column.style.backgroundSize = `100% ${this.#hourHeight}px`;
|
|
446
462
|
for (const item of this.#layout(day)) column.appendChild(this.#createEvent(item, day));
|
|
447
463
|
this.#days.appendChild(column);
|
|
448
464
|
}
|
|
@@ -454,8 +470,8 @@ class Scheduler {
|
|
|
454
470
|
|
|
455
471
|
#createEvent(item = Object(), day = new Date()) {
|
|
456
472
|
const event = item.event;
|
|
457
|
-
const top = ((item.start - this.#startOfDayMinutes()) / 60) * this.#
|
|
458
|
-
const height = Math.max(18, ((item.end - item.start) / 60) * this.#
|
|
473
|
+
const top = ((item.start - this.#startOfDayMinutes()) / 60) * this.#hourHeight;
|
|
474
|
+
const height = Math.max(18, ((item.end - item.start) / 60) * this.#hourHeight);
|
|
459
475
|
const lanes = Math.max(1, item.lanes);
|
|
460
476
|
const width = 100 / lanes;
|
|
461
477
|
const node = document.createElement("button");
|
|
@@ -486,20 +502,25 @@ class Scheduler {
|
|
|
486
502
|
}
|
|
487
503
|
|
|
488
504
|
static #dayText(day = new Date()) {
|
|
489
|
-
return day.toLocaleString(I18n.getLocale(), {weekday: "long", day: "numeric", month: "long"});
|
|
505
|
+
return day.toLocaleString(I18n.getLocale(), { weekday: "long", day: "numeric", month: "long" });
|
|
490
506
|
}
|
|
491
507
|
|
|
492
508
|
#periodTitle(days = []) {
|
|
493
509
|
const first = days[0];
|
|
494
510
|
const last = days[days.length - 1];
|
|
495
511
|
if (this.#view === Scheduler.VIEW.DAY) {
|
|
496
|
-
return first.toLocaleString(I18n.getLocale(), {
|
|
512
|
+
return first.toLocaleString(I18n.getLocale(), {
|
|
513
|
+
weekday: "long",
|
|
514
|
+
day: "numeric",
|
|
515
|
+
month: "long",
|
|
516
|
+
year: "numeric",
|
|
517
|
+
});
|
|
497
518
|
}
|
|
498
519
|
// Дата с числом даёт месяц в родительном падеже, поэтому диапазон собирается из дня
|
|
499
520
|
// и полной даты конца периода, а не из отдельного названия месяца
|
|
500
|
-
const until = last.toLocaleString(I18n.getLocale(), {day: "numeric", month: "long", year: "numeric"});
|
|
521
|
+
const until = last.toLocaleString(I18n.getLocale(), { day: "numeric", month: "long", year: "numeric" });
|
|
501
522
|
if (first.getMonth() === last.getMonth()) return `${first.getDate()} – ${until}`;
|
|
502
|
-
const from = first.toLocaleString(I18n.getLocale(), {day: "numeric", month: "long"});
|
|
523
|
+
const from = first.toLocaleString(I18n.getLocale(), { day: "numeric", month: "long" });
|
|
503
524
|
return `${from} – ${until}`;
|
|
504
525
|
}
|
|
505
526
|
|
|
@@ -523,18 +544,19 @@ class Scheduler {
|
|
|
523
544
|
const eventNode = target.closest(".scheduler_event");
|
|
524
545
|
if (eventNode !== null) {
|
|
525
546
|
const found = this.#events[Number(eventNode.dataset.index)];
|
|
526
|
-
if (this.#
|
|
547
|
+
if (this.#onEventClick !== undefined)
|
|
548
|
+
this.#onEventClick(found === undefined ? undefined : found, eventNode);
|
|
527
549
|
return;
|
|
528
550
|
}
|
|
529
551
|
const dayNode = target.closest("scheduler_day");
|
|
530
552
|
if (dayNode !== null) {
|
|
531
553
|
const column = dayNode.getBoundingClientRect();
|
|
532
554
|
const offset = Math.max(0, Math.min(event.clientY - column.top, column.height));
|
|
533
|
-
const raw = this.#startOfDayMinutes() + (offset / this.#
|
|
534
|
-
const minutes = Math.round(raw / this.#
|
|
555
|
+
const raw = this.#startOfDayMinutes() + (offset / this.#hourHeight) * 60;
|
|
556
|
+
const minutes = Math.round(raw / this.#slotMinutes) * this.#slotMinutes;
|
|
535
557
|
const date = this.#dayDates().find((day) => Scheduler.#key(day) === dayNode.dataset.day);
|
|
536
|
-
if (date !== undefined && this.#
|
|
537
|
-
this.#
|
|
558
|
+
if (date !== undefined && this.#onSlotClick !== undefined) {
|
|
559
|
+
this.#onSlotClick({ date: date, minutes: minutes, time: Scheduler.#timeText(minutes) });
|
|
538
560
|
}
|
|
539
561
|
}
|
|
540
562
|
};
|
|
@@ -557,10 +579,10 @@ class Scheduler {
|
|
|
557
579
|
};
|
|
558
580
|
|
|
559
581
|
#onPeriodChange() {
|
|
560
|
-
if (this.#
|
|
582
|
+
if (this.#onPeriodChangeCallback === undefined) return;
|
|
561
583
|
const range = this.getRange();
|
|
562
|
-
this.#
|
|
584
|
+
this.#onPeriodChangeCallback(range.from, range.to);
|
|
563
585
|
}
|
|
564
586
|
}
|
|
565
587
|
|
|
566
|
-
exports.Scheduler = Scheduler
|
|
588
|
+
exports.Scheduler = Scheduler;
|
|
@@ -4,12 +4,12 @@ chui_scheduler {
|
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
width: -webkit-fill-available;
|
|
6
6
|
box-sizing: border-box;
|
|
7
|
-
margin: var(--
|
|
7
|
+
margin: var(--block_margin);
|
|
8
8
|
color: var(--text_color);
|
|
9
9
|
font-size: var(--font_default_size);
|
|
10
10
|
background: var(--element_background_2);
|
|
11
11
|
border: 1px solid var(--border_color);
|
|
12
|
-
border-radius: var(--
|
|
12
|
+
border-radius: var(--radius_sm);
|
|
13
13
|
overflow: hidden;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ scheduler_head {
|
|
|
17
17
|
display: flex;
|
|
18
18
|
align-items: center;
|
|
19
19
|
gap: 6px;
|
|
20
|
-
padding: var(--
|
|
20
|
+
padding: var(--block_padding);
|
|
21
21
|
border-bottom: 1px solid var(--border_color);
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ button.scheduler_nav,
|
|
|
25
25
|
button.scheduler_today,
|
|
26
26
|
button.scheduler_view {
|
|
27
27
|
border: none;
|
|
28
|
-
border-radius: var(--
|
|
28
|
+
border-radius: var(--radius_sm);
|
|
29
29
|
background: var(--element_background);
|
|
30
30
|
color: var(--text_color);
|
|
31
31
|
font-family: inherit;
|
|
@@ -52,7 +52,10 @@ button.scheduler_view[aria-pressed="true"] {
|
|
|
52
52
|
color: var(--text_color_hover);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
button.scheduler_nav:focus-visible,
|
|
55
|
+
button.scheduler_nav:focus-visible,
|
|
56
|
+
button.scheduler_today:focus-visible,
|
|
57
|
+
button.scheduler_view:focus-visible,
|
|
58
|
+
button.scheduler_event:focus-visible {
|
|
56
59
|
outline: var(--focus_outline);
|
|
57
60
|
outline-offset: var(--focus_outline_offset);
|
|
58
61
|
}
|
|
@@ -119,7 +122,8 @@ scheduler_times {
|
|
|
119
122
|
scheduler_hour {
|
|
120
123
|
display: block;
|
|
121
124
|
box-sizing: border-box;
|
|
122
|
-
padding-block: 2px 0;
|
|
125
|
+
padding-block: 2px 0;
|
|
126
|
+
padding-inline: 0 6px;
|
|
123
127
|
text-align: end;
|
|
124
128
|
color: var(--text_color_disabled);
|
|
125
129
|
font-size: 0.85em;
|
|
@@ -153,7 +157,7 @@ button.scheduler_event {
|
|
|
153
157
|
overflow: hidden;
|
|
154
158
|
text-align: start;
|
|
155
159
|
border: none;
|
|
156
|
-
border-radius: var(--
|
|
160
|
+
border-radius: var(--radius_sm);
|
|
157
161
|
background: var(--blue_prime_background);
|
|
158
162
|
color: var(--text_color_hover);
|
|
159
163
|
font-family: inherit;
|