chuijs 4.0.3 → 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 +536 -0
- package/framework/appLayout/default/chui_app_layout.js +361 -303
- package/framework/appLayout/default/global_style.css +243 -89
- package/framework/appLayout/default/main_theme_style.css +188 -101
- package/framework/components/chui_accordion/accordion.js +17 -17
- package/framework/components/chui_accordion/styles.css +7 -7
- package/framework/components/chui_action_sheet/action_sheet.js +35 -32
- package/framework/components/chui_action_sheet/styles.css +10 -4
- 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 +4 -4
- package/framework/components/chui_affix/styles.css +5 -0
- package/framework/components/chui_alert/alert.js +11 -5
- package/framework/components/chui_alert/styles.css +7 -0
- package/framework/components/chui_avatar/avatar.js +13 -13
- package/framework/components/chui_avatar/styles.css +1 -1
- package/framework/components/chui_avatar_group/avatar_group.js +4 -4
- package/framework/components/chui_avatar_group/styles.css +1 -1
- package/framework/components/chui_backtop/backtop.js +25 -2
- package/framework/components/chui_backtop/styles.css +21 -0
- package/framework/components/chui_badge/badge.js +15 -15
- 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/styles.css +1 -1
- package/framework/components/chui_button/button.js +24 -28
- package/framework/components/chui_button/styles.css +5 -5
- package/framework/components/chui_calendar/calendar.js +6 -6
- package/framework/components/chui_card/card.js +14 -14
- 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 +73 -51
- package/framework/components/chui_chat/styles.css +18 -7
- package/framework/components/chui_clipboard_history/clipboard_history.js +25 -20
- package/framework/components/chui_clipboard_history/styles.css +10 -8
- package/framework/components/chui_code/code.js +8 -8
- package/framework/components/chui_code/styles.css +2 -2
- package/framework/components/chui_code_editor/code_editor.js +26 -26
- package/framework/components/chui_code_editor/styles.css +3 -3
- package/framework/components/chui_command_palette/command_palette.js +29 -29
- package/framework/components/chui_command_palette/styles.css +5 -5
- package/framework/components/chui_console/console.js +9 -9
- package/framework/components/chui_console/styles.css +5 -2
- package/framework/components/chui_content_block/content_block.js +2 -2
- package/framework/components/chui_context_menu/context_menu.js +162 -54
- package/framework/components/chui_context_menu/styles.css +82 -8
- package/framework/components/chui_custom_element/custom_element.js +11 -11
- package/framework/components/chui_data_grid/data_grid.js +268 -268
- package/framework/components/chui_data_grid/styles.css +14 -14
- package/framework/components/chui_descriptions/styles.css +1 -1
- package/framework/components/chui_details/details.js +12 -12
- package/framework/components/chui_details/styles.css +7 -7
- package/framework/components/chui_diff_viewer/diff_viewer.js +88 -88
- package/framework/components/chui_diff_viewer/styles.css +9 -9
- package/framework/components/chui_divider/divider.js +6 -6
- package/framework/components/chui_divider/styles.css +2 -2
- package/framework/components/chui_drawer/drawer.js +37 -14
- package/framework/components/chui_drawer/styles.css +18 -4
- package/framework/components/chui_drop_zone/drop_zone.js +6 -6
- package/framework/components/chui_drop_zone/styles.css +10 -6
- package/framework/components/chui_fieldset/fieldset.js +6 -6
- package/framework/components/chui_fieldset/styles.css +5 -5
- package/framework/components/chui_file_explorer/file_explorer.js +115 -115
- package/framework/components/chui_file_explorer/styles.css +6 -6
- package/framework/components/chui_form/form.js +11 -11
- package/framework/components/chui_gantt/gantt.js +41 -41
- package/framework/components/chui_gantt/styles.css +5 -5
- package/framework/components/chui_graphs/graphs.js +82 -46
- package/framework/components/chui_graphs/styles.css +26 -5
- package/framework/components/chui_hero/hero.js +63 -20
- package/framework/components/chui_hero/styles.css +176 -7
- package/framework/components/chui_html_block/html_block.js +5 -5
- package/framework/components/chui_html_block/styles.css +1 -1
- package/framework/components/chui_hx/styles.css +2 -2
- package/framework/components/chui_icons/icons.js +7 -7
- package/framework/components/chui_icons/styles.css +2 -1
- package/framework/components/chui_inputs/chui_check_box/styles.css +12 -3
- package/framework/components/chui_inputs/chui_chips/chips.js +92 -31
- package/framework/components/chui_inputs/chui_chips/styles.css +28 -5
- package/framework/components/chui_inputs/chui_color_picker/color_picker.js +20 -15
- package/framework/components/chui_inputs/chui_color_picker/styles.css +7 -7
- package/framework/components/chui_inputs/chui_combo_box/combo_box.js +58 -58
- package/framework/components/chui_inputs/chui_combo_box/styles.css +9 -9
- package/framework/components/chui_inputs/chui_date/date.js +93 -95
- package/framework/components/chui_inputs/chui_date/styles.css +8 -8
- package/framework/components/chui_inputs/chui_date_range/date_range.js +22 -22
- package/framework/components/chui_inputs/chui_date_range/styles.css +3 -3
- package/framework/components/chui_inputs/chui_datetime/datetime.js +12 -12
- package/framework/components/chui_inputs/chui_datetime/styles.css +3 -3
- package/framework/components/chui_inputs/chui_email/email.js +10 -10
- package/framework/components/chui_inputs/chui_email/styles.css +6 -6
- package/framework/components/chui_inputs/chui_file/file.js +8 -8
- package/framework/components/chui_inputs/chui_file/styles.css +12 -9
- package/framework/components/chui_inputs/chui_hotkey/hotkey.js +39 -39
- package/framework/components/chui_inputs/chui_hotkey/styles.css +6 -6
- package/framework/components/chui_inputs/chui_masked/masked.js +44 -44
- package/framework/components/chui_inputs/chui_masked/styles.css +5 -5
- package/framework/components/chui_inputs/chui_mention/mention.js +13 -13
- package/framework/components/chui_inputs/chui_mention/styles.css +14 -8
- package/framework/components/chui_inputs/chui_multi_combo_box/multi_combo_box.js +147 -137
- package/framework/components/chui_inputs/chui_multi_combo_box/styles.css +14 -8
- package/framework/components/chui_inputs/chui_number/number.js +42 -45
- package/framework/components/chui_inputs/chui_number/styles.css +6 -6
- package/framework/components/chui_inputs/chui_otp/otp.js +32 -32
- package/framework/components/chui_inputs/chui_otp/styles.css +5 -5
- package/framework/components/chui_inputs/chui_password/password.js +30 -36
- package/framework/components/chui_inputs/chui_password/styles.css +7 -7
- package/framework/components/chui_inputs/chui_radio_button/styles.css +2 -2
- package/framework/components/chui_inputs/chui_rating/rating.js +28 -28
- package/framework/components/chui_inputs/chui_rating/styles.css +3 -3
- package/framework/components/chui_inputs/chui_select_box/select_box.js +54 -54
- package/framework/components/chui_inputs/chui_select_box/styles.css +10 -10
- package/framework/components/chui_inputs/chui_slider/slider.js +14 -14
- package/framework/components/chui_inputs/chui_slider/styles.css +5 -4
- package/framework/components/chui_inputs/chui_text/styles.css +7 -7
- package/framework/components/chui_inputs/chui_text/text.js +13 -17
- package/framework/components/chui_inputs/chui_text_area/styles.css +8 -8
- package/framework/components/chui_inputs/chui_text_area/text_area.js +23 -23
- package/framework/components/chui_inputs/chui_time/styles.css +13 -17
- package/framework/components/chui_inputs/chui_time/time.js +35 -24
- package/framework/components/chui_inputs/chui_toggle/styles.css +10 -3
- package/framework/components/chui_inputs/chui_toggle/toggle.js +16 -16
- package/framework/components/chui_json_editor/json_editor.js +87 -87
- package/framework/components/chui_json_editor/styles.css +5 -5
- package/framework/components/chui_json_viewer/json_viewer.js +80 -80
- package/framework/components/chui_json_viewer/styles.css +6 -6
- package/framework/components/chui_kanban/kanban.js +27 -27
- package/framework/components/chui_kanban/styles.css +8 -4
- package/framework/components/chui_kbd/styles.css +1 -1
- package/framework/components/chui_label/label.js +17 -17
- package/framework/components/chui_label/styles.css +1 -1
- package/framework/components/chui_link/link.js +9 -9
- package/framework/components/chui_link/styles.css +11 -4
- package/framework/components/chui_list/list.js +11 -11
- package/framework/components/chui_list/styles.css +2 -2
- package/framework/components/chui_markdown_editor/markdown_editor.js +66 -66
- package/framework/components/chui_markdown_editor/styles.css +5 -5
- package/framework/components/chui_media/audio.js +240 -246
- package/framework/components/chui_media/audio_styles.css +41 -23
- package/framework/components/chui_media/image.js +49 -46
- package/framework/components/chui_media/image_compare.js +35 -35
- package/framework/components/chui_media/image_compare_styles.css +5 -5
- package/framework/components/chui_media/image_styles.css +1 -1
- package/framework/components/chui_media/video.js +148 -148
- package/framework/components/chui_media/video_styles.css +27 -11
- package/framework/components/chui_menu_bar/menu_bar.js +54 -54
- package/framework/components/chui_menu_bar/styles.css +10 -10
- 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 +37 -13
- package/framework/components/chui_notification/notification.js +76 -54
- package/framework/components/chui_notification/notification_download.js +26 -81
- package/framework/components/chui_notification/notification_download_card.js +115 -0
- package/framework/components/chui_notification/notification_download_progress.css +2 -2
- package/framework/components/chui_notification/notification_download_progress.js +70 -108
- package/framework/components/chui_notification/notification_update.js +31 -31
- package/framework/components/chui_notification/status_plate.css +3 -3
- package/framework/components/chui_notification/styles.css +6 -1
- package/framework/components/chui_notification/styles_download.css +1 -1
- package/framework/components/chui_notification/styles_update.css +2 -2
- package/framework/components/chui_org_chart/org_chart.js +29 -29
- package/framework/components/chui_org_chart/styles.css +2 -2
- package/framework/components/chui_pagination/pagination.js +3 -3
- package/framework/components/chui_pagination/styles.css +1 -1
- package/framework/components/chui_paragraph/styles.css +2 -2
- package/framework/components/chui_popover/popover.js +29 -23
- package/framework/components/chui_popover/styles.css +1 -1
- package/framework/components/chui_popups/popups.js +124 -124
- package/framework/components/chui_popups/styles.css +5 -5
- package/framework/components/chui_print_button/print_button.js +15 -10
- package/framework/components/chui_progress_bar/progress_bar.js +34 -12
- package/framework/components/chui_progress_bar/styles.css +4 -4
- package/framework/components/chui_progress_ring/progress_ring.js +15 -15
- package/framework/components/chui_progress_ring/styles.css +1 -1
- package/framework/components/chui_qrcode/qrcode.js +12 -12
- package/framework/components/chui_query_builder/query_builder.js +46 -46
- package/framework/components/chui_query_builder/styles.css +4 -4
- package/framework/components/chui_radio_group/styles.css +1 -1
- package/framework/components/chui_result/result.js +15 -15
- package/framework/components/chui_result/styles.css +3 -3
- package/framework/components/chui_scheduler/scheduler.js +74 -74
- package/framework/components/chui_scheduler/styles.css +5 -5
- 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 +63 -6
- package/framework/components/chui_segmented_control/styles.css +32 -6
- package/framework/components/chui_settings/settings.js +45 -46
- package/framework/components/chui_settings/styles.css +4 -4
- package/framework/components/chui_shortcut_help/shortcut_help.js +32 -34
- package/framework/components/chui_sidebar_nav/sidebar_nav.js +98 -29
- package/framework/components/chui_sidebar_nav/styles.css +9 -3
- package/framework/components/chui_slideshow/slideshow.js +85 -85
- package/framework/components/chui_slideshow/styles.css +6 -6
- package/framework/components/chui_spinner/spinner.js +10 -10
- package/framework/components/chui_split_button/split_button.js +30 -12
- package/framework/components/chui_split_button/styles.css +21 -5
- package/framework/components/chui_splitter/splitter.js +11 -11
- package/framework/components/chui_splitter/styles.css +2 -2
- package/framework/components/chui_statistic/statistic.js +47 -47
- package/framework/components/chui_status_bar/styles.css +2 -2
- package/framework/components/chui_stepper/stepper.js +202 -31
- package/framework/components/chui_stepper/styles.css +79 -14
- package/framework/components/chui_sticky_bar/sticky_bar.js +44 -13
- package/framework/components/chui_sticky_bar/styles.css +10 -8
- package/framework/components/chui_tabs/chui_tabs.js +74 -26
- package/framework/components/chui_tabs/styles.css +40 -12
- package/framework/components/chui_text_editor/styles.css +7 -7
- package/framework/components/chui_text_editor/text_editor.js +56 -56
- package/framework/components/chui_text_editor/text_editor_panel.js +173 -174
- package/framework/components/chui_theme_toggle/theme_toggle.js +21 -5
- package/framework/components/chui_timeline/styles.css +3 -1
- package/framework/components/chui_toast_queue/styles.css +11 -11
- package/framework/components/chui_toast_queue/toast_queue.js +30 -27
- package/framework/components/chui_toolbar/styles.css +2 -2
- package/framework/components/chui_tooltip/styles.css +2 -2
- package/framework/components/chui_tooltip/tooltip.js +3 -3
- package/framework/components/chui_tour/styles.css +8 -8
- package/framework/components/chui_tour/tour.js +72 -72
- package/framework/components/chui_transfer/styles.css +6 -6
- package/framework/components/chui_transfer/transfer.js +93 -106
- package/framework/components/chui_tree_table/styles.css +4 -4
- package/framework/components/chui_tree_table/tree_table.js +45 -45
- package/framework/components/chui_tree_view/styles.css +10 -8
- package/framework/components/chui_tree_view/tree_view.js +185 -183
- 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 +17 -17
- package/framework/components/chui_webview/webview.js +9 -9
- 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 +78 -79
- package/framework/modules/chui_animations/animations.js +77 -15
- package/framework/modules/chui_animations/motion.js +120 -0
- package/framework/modules/chui_animations/styles.css +36 -3
- package/framework/modules/chui_functions.js +31 -27
- package/framework/modules/chui_highlight/styles.css +13 -10
- package/framework/modules/chui_i18n/chui_i18n.js +3 -3
- package/framework/modules/chui_i18n/locales/feedback.js +62 -0
- package/framework/modules/chui_i18n/locales/navigation.js +4 -0
- package/framework/modules/chui_json/chui_json.js +2 -2
- package/framework/modules/chui_logger/chui_logger.js +23 -8
- package/framework/modules/chui_page/page.js +10 -10
- package/framework/modules/chui_palette/palette.js +61 -0
- package/framework/modules/chui_qr/chui_qr.js +23 -23
- package/framework/modules/chui_scrollbar/chui_scrollbar.js +45 -45
- package/framework/modules/chui_scrollbar/styles.css +3 -3
- package/framework/modules/chui_services/chui_services.js +8 -8
- package/framework/modules/chui_services/desktop.js +77 -71
- package/framework/modules/chui_sortable/chui_sortable.js +17 -17
- package/framework/modules/chui_validate/chui_validate.js +3 -3
- package/framework/tray_bar/chui_menu_items.js +2 -2
- package/index.d.ts +266 -34
- package/index.js +20 -1168
- package/package.json +6 -4
- package/framework/components/telegram_bot/chui_telegram_bot.js +0 -191
|
@@ -161,11 +161,11 @@ class QR {
|
|
|
161
161
|
* `version` по умолчанию — 40: это предел всего формата.
|
|
162
162
|
*/
|
|
163
163
|
static capacity(version = MAX_VERSION, level = LEVELS.MEDIUM, mode = MODES.AUTO) {
|
|
164
|
-
const
|
|
164
|
+
const checkedLevel = QR.#checkLevel(QR.#option(level));
|
|
165
165
|
const chosen = QR.#option(mode);
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
return QR.#capacity(
|
|
166
|
+
const checkedMode = chosen === undefined || chosen === MODES.AUTO ? MODES.BYTE : QR.#checkMode(chosen);
|
|
167
|
+
const checkedVersion = QR.#checkVersion(QR.#option(version) === undefined ? MAX_VERSION : version);
|
|
168
|
+
return QR.#capacity(checkedVersion, checkedLevel, checkedMode);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/** Режим, который выберет `AUTO` для этой строки: цифры, буквы и цифры или байты */
|
|
@@ -217,10 +217,10 @@ class QR {
|
|
|
217
217
|
const level = QR.#checkLevel(QR.#option(options.level));
|
|
218
218
|
const requested = QR.#option(options.mode);
|
|
219
219
|
const mode = requested === undefined || requested === MODES.AUTO ? MODES.AUTO : QR.#checkMode(requested);
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
const first = QR.#checkVersion(
|
|
223
|
-
const last = QR.#checkVersion(
|
|
220
|
+
const minVersion = QR.#option(options.minVersion);
|
|
221
|
+
const maxVersion = QR.#option(options.maxVersion);
|
|
222
|
+
const first = QR.#checkVersion(minVersion === undefined ? MIN_VERSION : minVersion);
|
|
223
|
+
const last = QR.#checkVersion(maxVersion === undefined ? MAX_VERSION : maxVersion);
|
|
224
224
|
if (first > last) throw new RangeError("QR: minVersion больше maxVersion");
|
|
225
225
|
const mask = QR.#option(options.mask) === undefined ? undefined : QR.#checkMask(options.mask);
|
|
226
226
|
|
|
@@ -254,15 +254,15 @@ class QR {
|
|
|
254
254
|
const size = QR.size(version);
|
|
255
255
|
const pattern = QR.#functionPatterns(version, level);
|
|
256
256
|
QR.#placeData(pattern.modules, pattern.isFunction, codewords, size);
|
|
257
|
-
const
|
|
258
|
-
QR.#applyMask(pattern.modules, pattern.isFunction, size,
|
|
259
|
-
QR.#drawFormat(pattern.modules, pattern.isFunction, size, level,
|
|
257
|
+
const chosenMask = mask === undefined ? QR.#bestMask(pattern.modules, pattern.isFunction, size, level) : mask;
|
|
258
|
+
QR.#applyMask(pattern.modules, pattern.isFunction, size, chosenMask);
|
|
259
|
+
QR.#drawFormat(pattern.modules, pattern.isFunction, size, level, chosenMask);
|
|
260
260
|
return {
|
|
261
261
|
ok: true,
|
|
262
262
|
matrix: pattern.modules,
|
|
263
263
|
size: size,
|
|
264
264
|
version: version,
|
|
265
|
-
mask:
|
|
265
|
+
mask: chosenMask,
|
|
266
266
|
level: level,
|
|
267
267
|
mode: payload.mode,
|
|
268
268
|
length: payload.length,
|
|
@@ -343,27 +343,27 @@ class QR {
|
|
|
343
343
|
*/
|
|
344
344
|
static #interleave(data = [], version = MIN_VERSION, level = LEVELS.MEDIUM) {
|
|
345
345
|
const blocks = EC_BLOCKS[LEVEL_INFO[level].index][version - 1];
|
|
346
|
-
const
|
|
346
|
+
const errorCorrectionLength = EC_CODEWORDS[LEVEL_INFO[level].index][version - 1];
|
|
347
347
|
const total = QR.#rawDataModules(version) >> 3;
|
|
348
|
-
const
|
|
349
|
-
const
|
|
350
|
-
const divisor = QR.#divisor(
|
|
348
|
+
const shortLength = Math.floor(total / blocks) - errorCorrectionLength;
|
|
349
|
+
const shortBlocks = blocks - (total % blocks);
|
|
350
|
+
const divisor = QR.#divisor(errorCorrectionLength);
|
|
351
351
|
const chunks = [];
|
|
352
352
|
let offset = 0;
|
|
353
353
|
for (let index = 0; index < blocks; index += 1) {
|
|
354
|
-
const length =
|
|
354
|
+
const length = shortLength + (index < shortBlocks ? 0 : 1);
|
|
355
355
|
const chunk = data.slice(offset, offset + length);
|
|
356
356
|
offset += length;
|
|
357
357
|
chunks.push({ data: chunk, ec: QR.#remainder(chunk, divisor) });
|
|
358
358
|
}
|
|
359
359
|
const result = [];
|
|
360
|
-
const longest =
|
|
360
|
+
const longest = shortLength + 1;
|
|
361
361
|
for (let position = 0; position < longest; position += 1) {
|
|
362
362
|
for (const chunk of chunks) {
|
|
363
363
|
if (position < chunk.data.length) result.push(chunk.data[position]);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
for (let position = 0; position <
|
|
366
|
+
for (let position = 0; position < errorCorrectionLength; position += 1) {
|
|
367
367
|
for (const chunk of chunks) result.push(chunk.ec[position]);
|
|
368
368
|
}
|
|
369
369
|
return result;
|
|
@@ -371,7 +371,7 @@ class QR {
|
|
|
371
371
|
|
|
372
372
|
/** Порождающий полином коррекции степени `degree` (без старшего члена) */
|
|
373
373
|
static #divisor(degree = Number()) {
|
|
374
|
-
|
|
374
|
+
const result = new Array(degree).fill(0);
|
|
375
375
|
result[degree - 1] = 1;
|
|
376
376
|
let root = 1;
|
|
377
377
|
for (let index = 0; index < degree; index += 1) {
|
|
@@ -578,14 +578,14 @@ class QR {
|
|
|
578
578
|
/** Маска с наименьшим штрафом; повторное применение снимает маску */
|
|
579
579
|
static #bestMask(modules = [], isFunction = [], size = Number(), level = LEVELS.MEDIUM) {
|
|
580
580
|
let best = 0;
|
|
581
|
-
let
|
|
581
|
+
let bestScore = Infinity;
|
|
582
582
|
for (let mask = 0; mask < 8; mask += 1) {
|
|
583
583
|
QR.#applyMask(modules, isFunction, size, mask);
|
|
584
584
|
QR.#drawFormat(modules, isFunction, size, level, mask);
|
|
585
585
|
const score = QR.#penalty(modules, size);
|
|
586
|
-
if (score <
|
|
586
|
+
if (score < bestScore) {
|
|
587
587
|
best = mask;
|
|
588
|
-
|
|
588
|
+
bestScore = score;
|
|
589
589
|
}
|
|
590
590
|
QR.#applyMask(modules, isFunction, size, mask);
|
|
591
591
|
}
|
|
@@ -122,22 +122,22 @@ class Scrollbar {
|
|
|
122
122
|
#listeners = [];
|
|
123
123
|
#thickness = THICKNESS;
|
|
124
124
|
#inset = INSET;
|
|
125
|
-
#
|
|
126
|
-
#
|
|
125
|
+
#insetCache = undefined;
|
|
126
|
+
#zIndex = 0;
|
|
127
127
|
#hovered = false;
|
|
128
128
|
#dragging = undefined;
|
|
129
|
-
#
|
|
129
|
+
#shouldShow = false;
|
|
130
130
|
#timer = 0;
|
|
131
131
|
#frame = 0;
|
|
132
|
-
#
|
|
133
|
-
#
|
|
132
|
+
#dragStart = 0;
|
|
133
|
+
#dragScroll = 0;
|
|
134
134
|
|
|
135
135
|
constructor(element = undefined, options = { thickness: Number(), inset: Number(), zIndex: Number() }) {
|
|
136
136
|
setStyles(__dirname + "/styles.css", "chUiJS_Scrollbar");
|
|
137
137
|
this.#element = element;
|
|
138
138
|
this.#thickness = Scrollbar.#numberOr(options.thickness, THICKNESS);
|
|
139
139
|
this.#inset = Scrollbar.#numberOr(options.inset, INSET);
|
|
140
|
-
this.#
|
|
140
|
+
this.#zIndex = Scrollbar.#zIndexFor(element, options.zIndex);
|
|
141
141
|
// Нативная полоса скрыта: место под неё не резервируется, иначе содержимое уезжало бы
|
|
142
142
|
// из центра, а поверх системной полосы лёг бы второй глиф
|
|
143
143
|
element.classList.add(HOST_CLASS);
|
|
@@ -203,7 +203,7 @@ class Scrollbar {
|
|
|
203
203
|
thumb = document.createElement("chui_scrollbar_thumb");
|
|
204
204
|
thumb.dataset.axis = axis;
|
|
205
205
|
thumb.setAttribute("aria-hidden", "true");
|
|
206
|
-
thumb.style.zIndex = String(this.#
|
|
206
|
+
thumb.style.zIndex = String(this.#zIndex);
|
|
207
207
|
document.body.appendChild(thumb);
|
|
208
208
|
this.#thumbs.set(axis, thumb);
|
|
209
209
|
this.#listen(thumb, "pointerenter", () => this.#onEnter());
|
|
@@ -229,24 +229,24 @@ class Scrollbar {
|
|
|
229
229
|
* `refreshInsets()` (наблюдатель за размерами и resize окна).
|
|
230
230
|
*/
|
|
231
231
|
#insets() {
|
|
232
|
-
if (this.#
|
|
232
|
+
if (this.#insetCache !== undefined) return this.#insetCache;
|
|
233
233
|
const style = getComputedStyle(this.#element);
|
|
234
234
|
const read = (name) => {
|
|
235
235
|
const value = Number.parseFloat(style.getPropertyValue(name));
|
|
236
236
|
return Number.isFinite(value) === true && value > 0 ? value : 0;
|
|
237
237
|
};
|
|
238
|
-
this.#
|
|
238
|
+
this.#insetCache = {
|
|
239
239
|
top: read("--scrollbar_inset_top"),
|
|
240
240
|
right: read("--scrollbar_inset_right"),
|
|
241
241
|
bottom: read("--scrollbar_inset_bottom"),
|
|
242
242
|
left: read("--scrollbar_inset_left"),
|
|
243
243
|
};
|
|
244
|
-
return this.#
|
|
244
|
+
return this.#insetCache;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
/** Сбросить кэш отступов и пересчитать: вместе с раскладкой мог смениться и токен */
|
|
248
248
|
refreshInsets() {
|
|
249
|
-
this.#
|
|
249
|
+
this.#insetCache = undefined;
|
|
250
250
|
this.#render();
|
|
251
251
|
return this;
|
|
252
252
|
}
|
|
@@ -269,13 +269,13 @@ class Scrollbar {
|
|
|
269
269
|
// ползунок не доезжает до конца (замер: недоезд 14px на странице 2917px).
|
|
270
270
|
const overflow = content - view;
|
|
271
271
|
if (track <= 0 || overflow <= 1) return undefined;
|
|
272
|
-
const
|
|
272
|
+
const thumbSize = Math.max(MIN_THUMB, Math.round((track * track) / content));
|
|
273
273
|
return {
|
|
274
274
|
track: track,
|
|
275
275
|
content: content,
|
|
276
276
|
overflow: overflow,
|
|
277
|
-
thumb_size:
|
|
278
|
-
travel: track -
|
|
277
|
+
thumb_size: thumbSize,
|
|
278
|
+
travel: track - thumbSize,
|
|
279
279
|
offset: vertical ? element.scrollTop : element.scrollLeft,
|
|
280
280
|
start: vertical ? insets.top : insets.left,
|
|
281
281
|
end: vertical ? insets.bottom : insets.right,
|
|
@@ -321,7 +321,7 @@ class Scrollbar {
|
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
323
323
|
const rect = element.getBoundingClientRect();
|
|
324
|
-
const
|
|
324
|
+
const onScreen =
|
|
325
325
|
rect.width > 0 &&
|
|
326
326
|
rect.height > 0 &&
|
|
327
327
|
rect.bottom > 0 &&
|
|
@@ -330,7 +330,7 @@ class Scrollbar {
|
|
|
330
330
|
rect.left < window.innerWidth;
|
|
331
331
|
// Узел за пределами окна (его вытянет прокрутка родителя): писать в глифы нечего,
|
|
332
332
|
// кроме снятия видимости при уходе — иначе на каждый узел приходился бы reflow
|
|
333
|
-
if (
|
|
333
|
+
if (onScreen === false) {
|
|
334
334
|
if (this.#ready.size === 0) return;
|
|
335
335
|
this.#ready.clear();
|
|
336
336
|
this.#paint();
|
|
@@ -350,16 +350,16 @@ class Scrollbar {
|
|
|
350
350
|
for (const axis of AXES) {
|
|
351
351
|
const thumb = this.#thumbs.get(axis);
|
|
352
352
|
if (thumb === undefined) continue;
|
|
353
|
-
const shown = this.#
|
|
353
|
+
const shown = this.#shouldShow === true && this.#ready.has(axis) === true;
|
|
354
354
|
// Лишняя запись класса — тоже изменение разметки, поэтому только по факту смены
|
|
355
355
|
if (thumb.classList.contains(VISIBLE_CLASS) !== shown) thumb.classList.toggle(VISIBLE_CLASS, shown);
|
|
356
356
|
}
|
|
357
|
-
if (this.#
|
|
357
|
+
if (this.#shouldShow === true && this.#ready.size > 0) this.#startFollowFrame();
|
|
358
358
|
else this.#stopFollowFrame();
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
#onScroll() {
|
|
362
|
-
this.#
|
|
362
|
+
this.#shouldShow = true;
|
|
363
363
|
this.#render();
|
|
364
364
|
// Курсор над узлом — глиф и так держится наведением; иначе показываем и убираем
|
|
365
365
|
if (this.#hovered === false) this.#scheduleHide(HIDE_DELAY);
|
|
@@ -367,7 +367,7 @@ class Scrollbar {
|
|
|
367
367
|
|
|
368
368
|
#onEnter() {
|
|
369
369
|
this.#hovered = true;
|
|
370
|
-
this.#
|
|
370
|
+
this.#shouldShow = true;
|
|
371
371
|
this.#cancelHide();
|
|
372
372
|
this.#render();
|
|
373
373
|
}
|
|
@@ -383,7 +383,7 @@ class Scrollbar {
|
|
|
383
383
|
this.#timer = setTimeout(() => {
|
|
384
384
|
this.#timer = 0;
|
|
385
385
|
if (this.#hovered === true || this.#dragging !== undefined) return;
|
|
386
|
-
this.#
|
|
386
|
+
this.#shouldShow = false;
|
|
387
387
|
this.#paint();
|
|
388
388
|
}, delay);
|
|
389
389
|
}
|
|
@@ -415,14 +415,14 @@ class Scrollbar {
|
|
|
415
415
|
// Без preventDefault указатель увёл бы фокус и начал выделение текста под глифом
|
|
416
416
|
event.preventDefault();
|
|
417
417
|
this.#dragging = axis;
|
|
418
|
-
this.#
|
|
418
|
+
this.#shouldShow = true;
|
|
419
419
|
this.#cancelHide();
|
|
420
420
|
const thumb = this.#thumbFor(axis);
|
|
421
421
|
thumb.classList.add(DRAGGING_CLASS);
|
|
422
422
|
if (typeof thumb.setPointerCapture === "function") thumb.setPointerCapture(event.pointerId);
|
|
423
423
|
const vertical = axis === AXIS.VERTICAL;
|
|
424
|
-
this.#
|
|
425
|
-
this.#
|
|
424
|
+
this.#dragStart = vertical ? event.clientY : event.clientX;
|
|
425
|
+
this.#dragScroll = vertical ? this.#element.scrollTop : this.#element.scrollLeft;
|
|
426
426
|
this.#render();
|
|
427
427
|
}
|
|
428
428
|
|
|
@@ -434,9 +434,9 @@ class Scrollbar {
|
|
|
434
434
|
const vertical = axis === AXIS.VERTICAL;
|
|
435
435
|
const pointer = vertical ? event.clientY : event.clientX;
|
|
436
436
|
// Глиф проходит `travel` пикселей, содержимое за это время — `overflow`: отсюда масштаб
|
|
437
|
-
const delta = (pointer - this.#
|
|
438
|
-
if (vertical) this.#element.scrollTop = this.#
|
|
439
|
-
else this.#element.scrollLeft = this.#
|
|
437
|
+
const delta = (pointer - this.#dragStart) * (metrics.overflow / metrics.travel);
|
|
438
|
+
if (vertical) this.#element.scrollTop = this.#dragScroll + delta;
|
|
439
|
+
else this.#element.scrollLeft = this.#dragScroll + delta;
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
#onDragEnd(event = Object()) {
|
|
@@ -467,8 +467,8 @@ class OverlayScrollbars {
|
|
|
467
467
|
/** Что перепроверить в ближайшем кадре: узел → надо ли обойти его поддерево */
|
|
468
468
|
static #pending = new Map();
|
|
469
469
|
static #frame = 0;
|
|
470
|
-
static #
|
|
471
|
-
static #
|
|
470
|
+
static #scrollFrame = 0;
|
|
471
|
+
static #scanFrame = 0;
|
|
472
472
|
/** Прокрутка и изменение окна: глифы надо догнать (прокрутка родителя двигает и детей) */
|
|
473
473
|
static #onViewportChange = () => OverlayScrollbars.#scheduleRefresh();
|
|
474
474
|
/*
|
|
@@ -489,9 +489,9 @@ class OverlayScrollbars {
|
|
|
489
489
|
};
|
|
490
490
|
|
|
491
491
|
static #scheduleScan() {
|
|
492
|
-
if (OverlayScrollbars.#
|
|
493
|
-
OverlayScrollbars.#
|
|
494
|
-
OverlayScrollbars.#
|
|
492
|
+
if (OverlayScrollbars.#scanFrame !== 0) return;
|
|
493
|
+
OverlayScrollbars.#scanFrame = requestAnimationFrame(() => {
|
|
494
|
+
OverlayScrollbars.#scanFrame = 0;
|
|
495
495
|
OverlayScrollbars.refreshAll();
|
|
496
496
|
OverlayScrollbars.scan(document.body);
|
|
497
497
|
});
|
|
@@ -562,11 +562,11 @@ class OverlayScrollbars {
|
|
|
562
562
|
OverlayScrollbars.#observer = undefined;
|
|
563
563
|
OverlayScrollbars.#resize = undefined;
|
|
564
564
|
if (OverlayScrollbars.#frame !== 0) cancelAnimationFrame(OverlayScrollbars.#frame);
|
|
565
|
-
if (OverlayScrollbars.#
|
|
566
|
-
if (OverlayScrollbars.#
|
|
565
|
+
if (OverlayScrollbars.#scrollFrame !== 0) cancelAnimationFrame(OverlayScrollbars.#scrollFrame);
|
|
566
|
+
if (OverlayScrollbars.#scanFrame !== 0) cancelAnimationFrame(OverlayScrollbars.#scanFrame);
|
|
567
567
|
OverlayScrollbars.#frame = 0;
|
|
568
|
-
OverlayScrollbars.#
|
|
569
|
-
OverlayScrollbars.#
|
|
568
|
+
OverlayScrollbars.#scrollFrame = 0;
|
|
569
|
+
OverlayScrollbars.#scanFrame = 0;
|
|
570
570
|
OverlayScrollbars.#pending.clear();
|
|
571
571
|
for (const element of [...OverlayScrollbars.#instances]) OverlayScrollbars.#detach(element);
|
|
572
572
|
return OverlayScrollbars;
|
|
@@ -582,9 +582,9 @@ class OverlayScrollbars {
|
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
static #scheduleRefresh() {
|
|
585
|
-
if (OverlayScrollbars.#
|
|
586
|
-
OverlayScrollbars.#
|
|
587
|
-
OverlayScrollbars.#
|
|
585
|
+
if (OverlayScrollbars.#scrollFrame !== 0) return;
|
|
586
|
+
OverlayScrollbars.#scrollFrame = requestAnimationFrame(() => {
|
|
587
|
+
OverlayScrollbars.#scrollFrame = 0;
|
|
588
588
|
OverlayScrollbars.refreshAll();
|
|
589
589
|
});
|
|
590
590
|
}
|
|
@@ -634,13 +634,13 @@ class OverlayScrollbars {
|
|
|
634
634
|
if (node === document.body || node === document.documentElement) return false;
|
|
635
635
|
if (node.tagName === "CHUI_SCROLLBAR_THUMB") return false;
|
|
636
636
|
// Быстрая отсечка до чтения стилей: переполнения нет — прокручивать нечего
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
if (
|
|
637
|
+
const overflowY = node.scrollHeight - node.clientHeight > 1;
|
|
638
|
+
const overflowX = node.scrollWidth - node.clientWidth > 1;
|
|
639
|
+
if (overflowY === false && overflowX === false) return false;
|
|
640
640
|
const style = getComputedStyle(node);
|
|
641
|
-
const
|
|
642
|
-
const
|
|
643
|
-
return
|
|
641
|
+
const scrollsY = overflowY === true && (style.overflowY === "auto" || style.overflowY === "scroll");
|
|
642
|
+
const scrollsX = overflowX === true && (style.overflowX === "auto" || style.overflowX === "scroll");
|
|
643
|
+
return scrollsY === true || scrollsX === true;
|
|
644
644
|
}
|
|
645
645
|
|
|
646
646
|
static #onMutations(records = []) {
|
|
@@ -15,7 +15,7 @@ chui_scrollbar_thumb {
|
|
|
15
15
|
z-index: 900;
|
|
16
16
|
display: block;
|
|
17
17
|
box-sizing: border-box;
|
|
18
|
-
border-radius: var(--
|
|
18
|
+
border-radius: var(--radius_sm);
|
|
19
19
|
background: var(--scrollbar_thumb);
|
|
20
20
|
/* Пока глиф не виден, он не должен перехватывать курсор: наведение ловит сам узел */
|
|
21
21
|
pointer-events: none;
|
|
@@ -23,8 +23,8 @@ chui_scrollbar_thumb {
|
|
|
23
23
|
/* Плавно только появление и цвет: `top`/`left`/`width`/`height` анимировать нельзя —
|
|
24
24
|
глиф отставал бы от прокрутки и «плыл» за содержимым */
|
|
25
25
|
transition:
|
|
26
|
-
opacity var(--
|
|
27
|
-
background-color var(--
|
|
26
|
+
opacity var(--motion_fast) var(--motion_ease),
|
|
27
|
+
background-color var(--motion_fast) var(--motion_ease);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
chui_scrollbar_thumb.chui_scrollbar_visible {
|
|
@@ -52,9 +52,9 @@ class Shell {
|
|
|
52
52
|
*/
|
|
53
53
|
class Shortcuts {
|
|
54
54
|
#registered = new Map();
|
|
55
|
-
#
|
|
55
|
+
#boundQuit = false;
|
|
56
56
|
#destroyed = false;
|
|
57
|
-
#
|
|
57
|
+
#onQuit = () => this.unregisterAll();
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* `register("Mod+Shift+P", () => {})` — вернёт `false`, если комбинацию уже занял
|
|
@@ -113,15 +113,15 @@ class Shortcuts {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
#bindQuit() {
|
|
116
|
-
if (this.#
|
|
117
|
-
this.#
|
|
118
|
-
app.on("will-quit", this.#
|
|
116
|
+
if (this.#boundQuit) return;
|
|
117
|
+
this.#boundQuit = true;
|
|
118
|
+
app.on("will-quit", this.#onQuit);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
#unbindQuit() {
|
|
122
|
-
if (!this.#
|
|
123
|
-
this.#
|
|
124
|
-
app.removeListener("will-quit", this.#
|
|
122
|
+
if (!this.#boundQuit) return;
|
|
123
|
+
this.#boundQuit = false;
|
|
124
|
+
app.removeListener("will-quit", this.#onQuit);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|