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
|
@@ -7,14 +7,14 @@ chui_file_explorer {
|
|
|
7
7
|
box-sizing: border-box;
|
|
8
8
|
width: -webkit-fill-available;
|
|
9
9
|
max-width: 100%;
|
|
10
|
-
margin: var(--
|
|
10
|
+
margin: var(--block_margin);
|
|
11
11
|
color: var(--text_color);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.file_explorer_title {
|
|
15
15
|
display: block;
|
|
16
16
|
width: max-content;
|
|
17
|
-
margin: var(--
|
|
17
|
+
margin: var(--block_margin);
|
|
18
18
|
color: var(--text_color);
|
|
19
19
|
font-size: var(--font_labels_size);
|
|
20
20
|
font-weight: 500;
|
|
@@ -57,7 +57,7 @@ chui_file_explorer {
|
|
|
57
57
|
margin: 0;
|
|
58
58
|
padding: 0;
|
|
59
59
|
border: none;
|
|
60
|
-
border-radius: var(--
|
|
60
|
+
border-radius: var(--radius_sm);
|
|
61
61
|
background: transparent;
|
|
62
62
|
color: var(--text_color);
|
|
63
63
|
cursor: pointer;
|
|
@@ -108,9 +108,10 @@ chui_file_explorer {
|
|
|
108
108
|
height: var(--control_height);
|
|
109
109
|
margin: 0;
|
|
110
110
|
/* Место под кнопку очистки, чтобы текст не заезжал под неё */
|
|
111
|
-
padding-block: 0 0;
|
|
111
|
+
padding-block: 0 0;
|
|
112
|
+
padding-inline: 12px 40px;
|
|
112
113
|
border: 1px solid var(--border_color);
|
|
113
|
-
border-radius: var(--
|
|
114
|
+
border-radius: var(--radius_sm);
|
|
114
115
|
background: var(--element_background);
|
|
115
116
|
color: var(--text_color);
|
|
116
117
|
font-family: inherit;
|
|
@@ -183,7 +184,7 @@ chui_file_explorer {
|
|
|
183
184
|
max-width: 100%;
|
|
184
185
|
overflow: hidden;
|
|
185
186
|
border: 1px solid var(--border_color);
|
|
186
|
-
border-radius: var(--
|
|
187
|
+
border-radius: var(--radius_sm);
|
|
187
188
|
background: var(--element_background);
|
|
188
189
|
}
|
|
189
190
|
|
|
@@ -361,7 +362,7 @@ file_explorer_name {
|
|
|
361
362
|
.file_explorer_error {
|
|
362
363
|
padding: 10px 12px;
|
|
363
364
|
border: 1px solid var(--badge_error_text);
|
|
364
|
-
border-radius: var(--
|
|
365
|
+
border-radius: var(--radius_sm);
|
|
365
366
|
color: var(--badge_error_text);
|
|
366
367
|
font-size: var(--font_labels_size);
|
|
367
368
|
}
|
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
const {Button} = require("../chui_button/button");
|
|
1
|
+
const { Button } = require("../chui_button/button");
|
|
2
2
|
|
|
3
3
|
class Form {
|
|
4
4
|
#id = require("randomstring").generate();
|
|
5
|
-
#
|
|
6
|
-
#form = document.createElement("form")
|
|
5
|
+
#chuiFormMain = document.createElement("chui_form_main");
|
|
6
|
+
#form = document.createElement("form");
|
|
7
7
|
#components = [];
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
#submitEvent = undefined;
|
|
9
|
+
#validateOnSubmit = true;
|
|
10
|
+
constructor(
|
|
11
|
+
options = {
|
|
12
|
+
action: String(),
|
|
13
|
+
method: String(),
|
|
14
|
+
components: [],
|
|
15
|
+
submitEvent: () => {},
|
|
16
|
+
validateOnSubmit: Boolean(),
|
|
17
|
+
}
|
|
18
|
+
) {
|
|
19
|
+
require("../../modules/chui_functions").setStyles(__dirname + "/styles.css", "chUiJS_Forms");
|
|
20
|
+
this.#chuiFormMain.id = this.#id;
|
|
21
|
+
this.#chuiFormMain.appendChild(this.#form);
|
|
20
22
|
|
|
21
23
|
// Установка компонентов в форму (частичный объект опций без components — пустая форма)
|
|
22
24
|
this.#components = Array.isArray(options.components) ? options.components : [];
|
|
23
|
-
for (
|
|
25
|
+
for (const component of this.#components) this.#form.appendChild(component.set());
|
|
24
26
|
// ===
|
|
25
27
|
|
|
26
28
|
//Установка опций
|
|
27
29
|
if (options.action) this.#form.action = options.action;
|
|
28
30
|
if (options.method) this.#form.method = options.method;
|
|
29
|
-
if (options.validateOnSubmit !== undefined) this.#
|
|
30
|
-
this.#
|
|
31
|
+
if (options.validateOnSubmit !== undefined) this.#validateOnSubmit = options.validateOnSubmit;
|
|
32
|
+
this.#submitEvent = options.submitEvent;
|
|
31
33
|
// Своя валидация вместо нативной: свои тексты ошибок и разметка
|
|
32
34
|
this.#form.setAttribute("novalidate", "true");
|
|
33
35
|
this.#form.addEventListener("submit", this.#onSubmit);
|
|
@@ -35,15 +37,15 @@ class Form {
|
|
|
35
37
|
}
|
|
36
38
|
#onSubmit = (event) => {
|
|
37
39
|
event.preventDefault();
|
|
38
|
-
if (this.#
|
|
40
|
+
if (this.#validateOnSubmit) {
|
|
39
41
|
const result = this.validate();
|
|
40
42
|
if (!result.valid) {
|
|
41
43
|
if (result.first !== undefined && typeof result.first.focus === "function") result.first.focus();
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
if (this.#
|
|
46
|
-
}
|
|
47
|
+
if (this.#submitEvent !== undefined) this.#submitEvent(event, this.getValues(), this);
|
|
48
|
+
};
|
|
47
49
|
/** Проверить все поля формы: сами ошибки выставляются в поля */
|
|
48
50
|
validate() {
|
|
49
51
|
this.clearErrors();
|
|
@@ -54,7 +56,11 @@ class Form {
|
|
|
54
56
|
const result = field.validate();
|
|
55
57
|
if (!result.valid) {
|
|
56
58
|
if (typeof field.setError === "function") field.setError(result.message);
|
|
57
|
-
errors.push({
|
|
59
|
+
errors.push({
|
|
60
|
+
name: typeof field.getName === "function" ? field.getName() : undefined,
|
|
61
|
+
message: result.message,
|
|
62
|
+
rule: result.rule,
|
|
63
|
+
});
|
|
58
64
|
if (first === undefined && typeof field.focus === "function") first = field;
|
|
59
65
|
}
|
|
60
66
|
}
|
|
@@ -111,9 +117,13 @@ class Form {
|
|
|
111
117
|
return this;
|
|
112
118
|
}
|
|
113
119
|
//addSubmitEvent(listener = () => {}) { this.#form.addEventListener("submit", listener); }
|
|
114
|
-
set() {
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
set() {
|
|
121
|
+
return this.#chuiFormMain;
|
|
122
|
+
}
|
|
123
|
+
static SubmitButton(title = String()) {
|
|
124
|
+
return new SubmitButton(title);
|
|
125
|
+
}
|
|
126
|
+
static METHOD = { GET: "GET", POST: "POST" };
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
/**
|
|
@@ -127,9 +137,11 @@ class Form {
|
|
|
127
137
|
class SubmitButton {
|
|
128
138
|
#button = undefined;
|
|
129
139
|
constructor(title = String()) {
|
|
130
|
-
this.#button = new Button({title: title});
|
|
140
|
+
this.#button = new Button({ title: title });
|
|
141
|
+
}
|
|
142
|
+
set() {
|
|
143
|
+
return this.#button.set();
|
|
131
144
|
}
|
|
132
|
-
set() { return this.#button.set(); }
|
|
133
145
|
}
|
|
134
146
|
|
|
135
|
-
exports.Form = Form
|
|
147
|
+
exports.Form = Form;
|
|
@@ -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
|
* Диаграмма Ганта: задачи полосами по шкале времени.
|
|
@@ -39,7 +39,7 @@ class Gantt {
|
|
|
39
39
|
static SCALE = {
|
|
40
40
|
DAY: "day",
|
|
41
41
|
WEEK: "week",
|
|
42
|
-
MONTH: "month"
|
|
42
|
+
MONTH: "month",
|
|
43
43
|
};
|
|
44
44
|
static DEFAULT_ROW_HEIGHT = 30;
|
|
45
45
|
static DEFAULT_BAR_HEIGHT = 18;
|
|
@@ -48,7 +48,7 @@ class Gantt {
|
|
|
48
48
|
|
|
49
49
|
#root = document.createElement("chui_gantt");
|
|
50
50
|
#corner = document.createElement("gantt_corner");
|
|
51
|
-
#
|
|
51
|
+
#scaleRow = document.createElement("gantt_scale");
|
|
52
52
|
#scroll = document.createElement("gantt_scroll");
|
|
53
53
|
#rows = document.createElement("gantt_rows");
|
|
54
54
|
#links = undefined;
|
|
@@ -57,32 +57,34 @@ class Gantt {
|
|
|
57
57
|
#from = undefined;
|
|
58
58
|
#to = undefined;
|
|
59
59
|
#scale = undefined;
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
-
#
|
|
63
|
-
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
60
|
+
#firstDay = 1;
|
|
61
|
+
#rowHeight = Gantt.DEFAULT_ROW_HEIGHT;
|
|
62
|
+
#barHeight = Gantt.DEFAULT_BAR_HEIGHT;
|
|
63
|
+
#labelWidth = Gantt.DEFAULT_LABEL_WIDTH;
|
|
64
|
+
#showProgress = true;
|
|
65
|
+
#showLinks = true;
|
|
66
66
|
#label = undefined;
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
|
|
70
|
-
constructor(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
67
|
+
#onTaskClick = undefined;
|
|
68
|
+
#rowsLayout = [];
|
|
69
|
+
|
|
70
|
+
constructor(
|
|
71
|
+
options = {
|
|
72
|
+
id: String(),
|
|
73
|
+
tasks: [],
|
|
74
|
+
from: undefined,
|
|
75
|
+
to: undefined,
|
|
76
|
+
scale: String(),
|
|
77
|
+
firstDay: Number(),
|
|
78
|
+
rowHeight: Number(),
|
|
79
|
+
barHeight: Number(),
|
|
80
|
+
labelWidth: Number(),
|
|
81
|
+
height: String(),
|
|
82
|
+
showProgress: Boolean(),
|
|
83
|
+
showLinks: Boolean(),
|
|
84
|
+
label: String(),
|
|
85
|
+
onTaskClick: undefined,
|
|
86
|
+
}
|
|
87
|
+
) {
|
|
86
88
|
setStyles(__dirname + "/styles.css", "chUiJS_Gantt");
|
|
87
89
|
Gantt.#counter += 1;
|
|
88
90
|
this.#id = options.id === undefined ? `chui_gantt_${Gantt.#counter}` : options.id;
|
|
@@ -92,28 +94,28 @@ class Gantt {
|
|
|
92
94
|
this.#from = options.from;
|
|
93
95
|
this.#to = options.to;
|
|
94
96
|
this.#scale = Gantt.#knownScale(options.scale);
|
|
95
|
-
this.#
|
|
96
|
-
this.#
|
|
97
|
-
this.#
|
|
98
|
-
this.#
|
|
99
|
-
this.#
|
|
100
|
-
this.#
|
|
101
|
-
this.#
|
|
97
|
+
this.#firstDay = options.firstDay === undefined ? this.#firstDay : options.firstDay;
|
|
98
|
+
this.#rowHeight = options.rowHeight === undefined ? this.#rowHeight : options.rowHeight;
|
|
99
|
+
this.#barHeight = options.barHeight === undefined ? this.#barHeight : options.barHeight;
|
|
100
|
+
this.#labelWidth = options.labelWidth === undefined ? this.#labelWidth : options.labelWidth;
|
|
101
|
+
this.#showProgress = options.showProgress !== false;
|
|
102
|
+
this.#showLinks = options.showLinks !== false;
|
|
103
|
+
this.#onTaskClick = options.onTaskClick;
|
|
102
104
|
this.setLabel(optionOr(options.label, I18n.t("gantt.title")));
|
|
103
105
|
this.setHeight(options.height);
|
|
104
106
|
this.#corner.innerText = I18n.t("gantt.task");
|
|
105
107
|
this.#corner.setAttribute("aria-hidden", "true");
|
|
106
108
|
const head = document.createElement("gantt_head");
|
|
107
109
|
head.appendChild(this.#corner);
|
|
108
|
-
head.appendChild(this.#
|
|
110
|
+
head.appendChild(this.#scaleRow);
|
|
109
111
|
this.#root.appendChild(head);
|
|
110
112
|
this.#rows.appendChild(this.#createLinks());
|
|
111
113
|
this.#scroll.appendChild(this.#rows);
|
|
112
114
|
this.#root.appendChild(this.#scroll);
|
|
113
115
|
this.#root.addEventListener("click", this.#onClick);
|
|
114
|
-
this.setProperty("--gantt_label_width", `${this.#
|
|
115
|
-
this.#root.style.setProperty("--gantt_row_height", `${this.#
|
|
116
|
-
this.#root.style.setProperty("--gantt_bar_height", `${this.#
|
|
116
|
+
this.setProperty("--gantt_label_width", `${this.#labelWidth}px`);
|
|
117
|
+
this.#root.style.setProperty("--gantt_row_height", `${this.#rowHeight}px`);
|
|
118
|
+
this.#root.style.setProperty("--gantt_bar_height", `${this.#barHeight}px`);
|
|
117
119
|
this.#render();
|
|
118
120
|
}
|
|
119
121
|
|
|
@@ -134,7 +136,7 @@ class Gantt {
|
|
|
134
136
|
/** Показанный период (начало и конец диапазона) */
|
|
135
137
|
getRange() {
|
|
136
138
|
const range = this.#period();
|
|
137
|
-
return {from: range.from, to: range.to};
|
|
139
|
+
return { from: range.from, to: range.to };
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
/** Шкала: заданная или выбранная по длине периода */
|
|
@@ -151,11 +153,11 @@ class Gantt {
|
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
getRowHeight() {
|
|
154
|
-
return this.#
|
|
156
|
+
return this.#rowHeight;
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
getLabelWidth() {
|
|
158
|
-
return this.#
|
|
160
|
+
return this.#labelWidth;
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
/** Полоса задачи на диаграмме (если задача показана) */
|
|
@@ -271,13 +273,20 @@ class Gantt {
|
|
|
271
273
|
const ends = this.#tasks.map((task) => Gantt.#taskEnd(task)).filter((date) => date !== undefined);
|
|
272
274
|
let from = Gantt.#toDate(this.#from);
|
|
273
275
|
let to = Gantt.#toDate(this.#to);
|
|
274
|
-
if (from === undefined)
|
|
276
|
+
if (from === undefined)
|
|
277
|
+
from =
|
|
278
|
+
starts.length === 0
|
|
279
|
+
? Gantt.#startOfDay(new Date())
|
|
280
|
+
: new Date(Math.min(...starts.map((date) => date.getTime())));
|
|
275
281
|
if (to === undefined) {
|
|
276
|
-
const last =
|
|
282
|
+
const last =
|
|
283
|
+
ends.length === 0
|
|
284
|
+
? new Date(from.getTime() + 86400000)
|
|
285
|
+
: new Date(Math.max(...ends.map((date) => date.getTime())));
|
|
277
286
|
to = last;
|
|
278
287
|
}
|
|
279
288
|
if (to <= from) to = new Date(from.getTime() + 86400000);
|
|
280
|
-
return {from: Gantt.#startOfDay(from), to: Gantt.#startOfDay(to)};
|
|
289
|
+
return { from: Gantt.#startOfDay(from), to: Gantt.#startOfDay(to) };
|
|
281
290
|
}
|
|
282
291
|
|
|
283
292
|
/** Начало колонки шкалы, в которую попадает дата */
|
|
@@ -286,7 +295,7 @@ class Gantt {
|
|
|
286
295
|
if (scale === Gantt.SCALE.MONTH) return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
287
296
|
const day = Gantt.#startOfDay(date);
|
|
288
297
|
if (scale === Gantt.SCALE.WEEK) {
|
|
289
|
-
const offset = (day.getDay() - this.#
|
|
298
|
+
const offset = (day.getDay() - this.#firstDay + 7) % 7;
|
|
290
299
|
day.setDate(day.getDate() - offset);
|
|
291
300
|
}
|
|
292
301
|
return day;
|
|
@@ -308,7 +317,7 @@ class Gantt {
|
|
|
308
317
|
let cursor = new Date(start);
|
|
309
318
|
while (cursor <= last && columns.length < 400) {
|
|
310
319
|
const next = this.#nextColumnStart(cursor);
|
|
311
|
-
columns.push({from: new Date(cursor), to: next});
|
|
320
|
+
columns.push({ from: new Date(cursor), to: next });
|
|
312
321
|
cursor = next;
|
|
313
322
|
}
|
|
314
323
|
return columns;
|
|
@@ -319,7 +328,7 @@ class Gantt {
|
|
|
319
328
|
const columns = this.#columns();
|
|
320
329
|
const first = columns[0];
|
|
321
330
|
const last = columns[columns.length - 1];
|
|
322
|
-
return {from: first.from, to: last.to, columns: columns};
|
|
331
|
+
return { from: first.from, to: last.to, columns: columns };
|
|
323
332
|
}
|
|
324
333
|
|
|
325
334
|
/** Доля позиции даты в периоде (0…1) */
|
|
@@ -334,11 +343,11 @@ class Gantt {
|
|
|
334
343
|
const scale = this.getScale();
|
|
335
344
|
const bounds = this.#periodBounds();
|
|
336
345
|
if (scale === Gantt.SCALE.MONTH) {
|
|
337
|
-
return `${bounds.from.toLocaleString(I18n.getLocale(), {month: "long", year: "numeric"})} – ${new Date(bounds.to.getTime() - 1).toLocaleString(I18n.getLocale(), {month: "long", year: "numeric"})}`;
|
|
346
|
+
return `${bounds.from.toLocaleString(I18n.getLocale(), { month: "long", year: "numeric" })} – ${new Date(bounds.to.getTime() - 1).toLocaleString(I18n.getLocale(), { month: "long", year: "numeric" })}`;
|
|
338
347
|
}
|
|
339
348
|
const last = new Date(bounds.to.getTime() - 1);
|
|
340
|
-
const until = last.toLocaleString(I18n.getLocale(), {day: "numeric", month: "long", year: "numeric"});
|
|
341
|
-
const from = bounds.from.toLocaleString(I18n.getLocale(), {day: "numeric", month: "long"});
|
|
349
|
+
const until = last.toLocaleString(I18n.getLocale(), { day: "numeric", month: "long", year: "numeric" });
|
|
350
|
+
const from = bounds.from.toLocaleString(I18n.getLocale(), { day: "numeric", month: "long" });
|
|
342
351
|
return `${from} – ${until}`;
|
|
343
352
|
}
|
|
344
353
|
|
|
@@ -352,36 +361,37 @@ class Gantt {
|
|
|
352
361
|
|
|
353
362
|
#renderScale(bounds = Object()) {
|
|
354
363
|
const scale = this.getScale();
|
|
355
|
-
this.#
|
|
356
|
-
this.#
|
|
364
|
+
this.#scaleRow.innerHTML = "";
|
|
365
|
+
this.#scaleRow.style.gridTemplateColumns = `repeat(${bounds.columns.length}, minmax(0, 1fr))`;
|
|
357
366
|
this.#root.style.setProperty("--gantt_columns", String(bounds.columns.length));
|
|
358
367
|
const today = Gantt.#startOfDay(new Date());
|
|
359
368
|
for (const column of bounds.columns) {
|
|
360
369
|
const cell = document.createElement("gantt_scale_cell");
|
|
361
370
|
const label = document.createElement("gantt_scale_label");
|
|
362
371
|
if (scale === Gantt.SCALE.MONTH) {
|
|
363
|
-
label.innerText = column.from.toLocaleString(I18n.getLocale(), {month: "short"});
|
|
372
|
+
label.innerText = column.from.toLocaleString(I18n.getLocale(), { month: "short" });
|
|
364
373
|
} else if (scale === Gantt.SCALE.WEEK) {
|
|
365
|
-
label.innerText = column.from.toLocaleString(I18n.getLocale(), {day: "numeric", month: "short"});
|
|
374
|
+
label.innerText = column.from.toLocaleString(I18n.getLocale(), { day: "numeric", month: "short" });
|
|
366
375
|
} else {
|
|
367
376
|
label.innerText = `${column.from.getDate()}.${String(column.from.getMonth() + 1).padStart(2, "0")}`;
|
|
368
377
|
}
|
|
369
378
|
cell.appendChild(label);
|
|
370
379
|
// Выходные подсвечиваем только на дневной шкале: на недельной и месячной колонка — не день
|
|
371
|
-
if (scale === Gantt.SCALE.DAY && (column.from.getDay() === 0 || column.from.getDay() === 6))
|
|
380
|
+
if (scale === Gantt.SCALE.DAY && (column.from.getDay() === 0 || column.from.getDay() === 6))
|
|
381
|
+
cell.classList.add("gantt_weekend");
|
|
372
382
|
if (today >= column.from && today < column.to) cell.classList.add("gantt_today_cell");
|
|
373
|
-
this.#
|
|
383
|
+
this.#scaleRow.appendChild(cell);
|
|
374
384
|
}
|
|
375
385
|
}
|
|
376
386
|
|
|
377
387
|
#renderRows(bounds = Object()) {
|
|
378
388
|
// Заглушка "задач нет" тоже пересобирается: иначе она оставалась бы на диаграмме после setTasks()
|
|
379
389
|
this.#rows.querySelectorAll("gantt_row, gantt_group_row, gantt_empty").forEach((row) => row.remove());
|
|
380
|
-
this.#
|
|
390
|
+
this.#rowsLayout = [];
|
|
381
391
|
const today = Gantt.#startOfDay(new Date());
|
|
382
392
|
const todayFraction = today >= bounds.from && today < bounds.to ? this.#fraction(today, bounds) : undefined;
|
|
383
393
|
let lastGroup = undefined;
|
|
384
|
-
for (const [
|
|
394
|
+
for (const [taskIndex, task] of this.#tasks.entries()) {
|
|
385
395
|
if (task.group !== undefined && task.group !== lastGroup) {
|
|
386
396
|
lastGroup = task.group;
|
|
387
397
|
this.#rows.appendChild(this.#createGroupRow(task.group));
|
|
@@ -400,7 +410,7 @@ class Gantt {
|
|
|
400
410
|
if (start !== undefined && end !== undefined && end > bounds.from && start < bounds.to) {
|
|
401
411
|
const left = this.#fraction(start, bounds);
|
|
402
412
|
const right = this.#fraction(end, bounds);
|
|
403
|
-
track.appendChild(this.#createBar(task, start, end, left, Math.max(0.02, right - left),
|
|
413
|
+
track.appendChild(this.#createBar(task, start, end, left, Math.max(0.02, right - left), taskIndex));
|
|
404
414
|
}
|
|
405
415
|
if (todayFraction !== undefined) {
|
|
406
416
|
const line = document.createElement("gantt_today_line");
|
|
@@ -411,14 +421,17 @@ class Gantt {
|
|
|
411
421
|
row.appendChild(label);
|
|
412
422
|
row.appendChild(track);
|
|
413
423
|
this.#rows.appendChild(row);
|
|
414
|
-
this.#
|
|
424
|
+
this.#rowsLayout.push({ task: task, row: row });
|
|
415
425
|
}
|
|
416
426
|
if (this.#tasks.length === 0) {
|
|
417
427
|
const empty = document.createElement("gantt_empty");
|
|
418
428
|
empty.innerText = I18n.t("gantt.empty");
|
|
419
429
|
this.#rows.appendChild(empty);
|
|
420
430
|
}
|
|
421
|
-
this.#rows.style.setProperty(
|
|
431
|
+
this.#rows.style.setProperty(
|
|
432
|
+
"--gantt_rows_height",
|
|
433
|
+
`${Math.max(1, this.#rowsLayout.length) * this.#rowHeight}px`
|
|
434
|
+
);
|
|
422
435
|
}
|
|
423
436
|
|
|
424
437
|
#createGroupRow(title = String()) {
|
|
@@ -434,12 +447,19 @@ class Gantt {
|
|
|
434
447
|
|
|
435
448
|
// `task_index` — номер задачи в данных: по нему клик находит именно ту задачу, чья полоса
|
|
436
449
|
// нажата (у задач без id и `data-id` пустой, и поиск по нему возвращал бы первую такую)
|
|
437
|
-
#createBar(
|
|
450
|
+
#createBar(
|
|
451
|
+
task = Object(),
|
|
452
|
+
start = new Date(),
|
|
453
|
+
end = new Date(),
|
|
454
|
+
left = Number(),
|
|
455
|
+
width = Number(),
|
|
456
|
+
taskIndex = Number()
|
|
457
|
+
) {
|
|
438
458
|
const bar = document.createElement("button");
|
|
439
459
|
bar.type = "button";
|
|
440
460
|
bar.className = "gantt_bar";
|
|
441
461
|
bar.dataset.id = task.id === undefined ? "" : String(task.id);
|
|
442
|
-
bar.dataset.index = String(
|
|
462
|
+
bar.dataset.index = String(taskIndex);
|
|
443
463
|
bar.style.left = `${left * 100}%`;
|
|
444
464
|
bar.style.width = `${width * 100}%`;
|
|
445
465
|
if (task.color !== undefined) bar.style.background = String(task.color);
|
|
@@ -447,7 +467,7 @@ class Gantt {
|
|
|
447
467
|
title.innerText = task.title === undefined ? I18n.t("gantt.task") : String(task.title);
|
|
448
468
|
bar.appendChild(title);
|
|
449
469
|
const progress = this.#progress(task);
|
|
450
|
-
if (this.#
|
|
470
|
+
if (this.#showProgress && progress !== undefined) {
|
|
451
471
|
const fill = document.createElement("gantt_bar_progress");
|
|
452
472
|
fill.style.width = `${progress}%`;
|
|
453
473
|
bar.appendChild(fill);
|
|
@@ -463,10 +483,14 @@ class Gantt {
|
|
|
463
483
|
}
|
|
464
484
|
|
|
465
485
|
#barLabel(task = Object(), start = new Date(), end = new Date(), progress = undefined) {
|
|
466
|
-
const format = (date) => date.toLocaleString(I18n.getLocale(), {day: "numeric", month: "long"});
|
|
467
|
-
const parts = [
|
|
468
|
-
|
|
469
|
-
|
|
486
|
+
const format = (date) => date.toLocaleString(I18n.getLocale(), { day: "numeric", month: "long" });
|
|
487
|
+
const parts = [
|
|
488
|
+
task.title === undefined ? I18n.t("gantt.task") : String(task.title),
|
|
489
|
+
`${format(start)} – ${format(end)}`,
|
|
490
|
+
];
|
|
491
|
+
if (progress !== undefined) parts.push(I18n.t("gantt.progress", { progress: progress }));
|
|
492
|
+
if (Array.isArray(task.dependencies) && task.dependencies.length > 0)
|
|
493
|
+
parts.push(I18n.t("gantt.dependsOn", { tasks: task.dependencies.join(", ") }));
|
|
470
494
|
return parts.join(", ");
|
|
471
495
|
}
|
|
472
496
|
|
|
@@ -486,18 +510,18 @@ class Gantt {
|
|
|
486
510
|
#renderLinks(bounds = Object()) {
|
|
487
511
|
if (this.#links === undefined) return;
|
|
488
512
|
this.#links.innerHTML = "";
|
|
489
|
-
if (!this.#
|
|
490
|
-
const index = new Map(this.#
|
|
491
|
-
const height = Math.max(1, this.#
|
|
513
|
+
if (!this.#showLinks) return;
|
|
514
|
+
const index = new Map(this.#rowsLayout.map((entry, position) => [String(entry.task.id), position]));
|
|
515
|
+
const height = Math.max(1, this.#rowsLayout.length) * this.#rowHeight;
|
|
492
516
|
this.#links.setAttribute("viewBox", `0 0 100 ${height}`);
|
|
493
517
|
this.#links.style.height = `${height}px`;
|
|
494
|
-
for (const {task} of this.#
|
|
518
|
+
for (const { task } of this.#rowsLayout) {
|
|
495
519
|
const dependencies = Array.isArray(task.dependencies) ? task.dependencies : [];
|
|
496
520
|
if (dependencies.length === 0) continue;
|
|
497
521
|
const start = Gantt.#taskStart(task);
|
|
498
522
|
if (start === undefined) continue;
|
|
499
523
|
const x2 = this.#fraction(start, bounds) * 100;
|
|
500
|
-
const y2 = (index.get(String(task.id)) + 0.5) * this.#
|
|
524
|
+
const y2 = (index.get(String(task.id)) + 0.5) * this.#rowHeight;
|
|
501
525
|
for (const dependency of dependencies) {
|
|
502
526
|
const position = index.get(String(dependency));
|
|
503
527
|
if (position === undefined) continue;
|
|
@@ -505,7 +529,7 @@ class Gantt {
|
|
|
505
529
|
const end = source === undefined ? undefined : Gantt.#taskEnd(source);
|
|
506
530
|
if (end === undefined) continue;
|
|
507
531
|
const x1 = this.#fraction(end, bounds) * 100;
|
|
508
|
-
const y1 = (position + 0.5) * this.#
|
|
532
|
+
const y1 = (position + 0.5) * this.#rowHeight;
|
|
509
533
|
// Колено всегда справа от конца предшественника: при наложении линия уйдёт назад
|
|
510
534
|
const elbow = x1 + 1.5;
|
|
511
535
|
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
@@ -531,8 +555,8 @@ class Gantt {
|
|
|
531
555
|
const bar = target.closest(".gantt_bar");
|
|
532
556
|
if (bar === null) return;
|
|
533
557
|
const task = this.#tasks[Number(bar.dataset.index)];
|
|
534
|
-
if (this.#
|
|
558
|
+
if (this.#onTaskClick !== undefined) this.#onTaskClick(task, bar);
|
|
535
559
|
};
|
|
536
560
|
}
|
|
537
561
|
|
|
538
|
-
exports.Gantt = Gantt
|
|
562
|
+
exports.Gantt = Gantt;
|
|
@@ -9,12 +9,12 @@ chui_gantt {
|
|
|
9
9
|
flex-direction: column;
|
|
10
10
|
width: -webkit-fill-available;
|
|
11
11
|
box-sizing: border-box;
|
|
12
|
-
margin: var(--
|
|
12
|
+
margin: var(--block_margin);
|
|
13
13
|
color: var(--text_color);
|
|
14
14
|
font-size: var(--font_default_size);
|
|
15
15
|
background: var(--element_background_2);
|
|
16
16
|
border: 1px solid var(--border_color);
|
|
17
|
-
border-radius: var(--
|
|
17
|
+
border-radius: var(--radius_sm);
|
|
18
18
|
overflow: hidden;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -128,7 +128,7 @@ button.gantt_bar {
|
|
|
128
128
|
padding: 0 6px;
|
|
129
129
|
overflow: hidden;
|
|
130
130
|
border: none;
|
|
131
|
-
border-radius: var(--
|
|
131
|
+
border-radius: var(--radius_sm);
|
|
132
132
|
background: var(--blue_prime_background);
|
|
133
133
|
color: var(--text_color_hover);
|
|
134
134
|
font-family: inherit;
|
|
@@ -163,7 +163,7 @@ gantt_bar_progress {
|
|
|
163
163
|
inset-inline-start: 0;
|
|
164
164
|
top: 0;
|
|
165
165
|
bottom: 0;
|
|
166
|
-
background:
|
|
166
|
+
background: var(--overlay_dim);
|
|
167
167
|
pointer-events: none;
|
|
168
168
|
}
|
|
169
169
|
|
|
@@ -199,7 +199,7 @@ svg.gantt_links circle.gantt_link_dot {
|
|
|
199
199
|
|
|
200
200
|
gantt_empty {
|
|
201
201
|
display: block;
|
|
202
|
-
padding: var(--
|
|
202
|
+
padding: var(--block_padding);
|
|
203
203
|
color: var(--text_color_disabled);
|
|
204
204
|
text-align: center;
|
|
205
205
|
}
|