@rockshin/tao-ui 0.0.60 → 0.1.0
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/README.md +5 -1
- package/component-manifest.json +1 -1
- package/dist/components/affix/affix.css +1 -1
- package/dist/components/affix/affix.d.ts +1 -0
- package/dist/components/affix/affix.js +18 -17
- package/dist/components/alert/alert.css +123 -119
- package/dist/components/alert/alert.js +78 -188
- package/dist/components/app/app-modals.js +49 -98
- package/dist/components/app/app-notices.d.ts +2 -2
- package/dist/components/app/app-notices.js +294 -243
- package/dist/components/app/app-types.d.ts +6 -3
- package/dist/components/app/app.css +185 -183
- package/dist/components/app/app.js +1 -1
- package/dist/components/auto-complete/auto-complete.css +30 -28
- package/dist/components/auto-complete/auto-complete.d.ts +3 -1
- package/dist/components/auto-complete/auto-complete.js +2 -1
- package/dist/components/badge/badge.js +42 -127
- package/dist/components/border-beam/border-beam.css +1 -1
- package/dist/components/border-beam/border-beam.d.ts +1 -0
- package/dist/components/border-beam/border-beam.js +1 -0
- package/dist/components/breadcrumb/breadcrumb.css +123 -120
- package/dist/components/breadcrumb/breadcrumb.js +160 -265
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +52 -151
- package/dist/components/calendar/calendar.js +28 -27
- package/dist/components/card/card-tabs.d.ts +56 -5
- package/dist/components/card/card-tabs.js +214 -468
- package/dist/components/card/card.d.ts +1 -2
- package/dist/components/card/card.js +64 -226
- package/dist/components/carousel/carousel.css +1 -1
- package/dist/components/carousel/carousel.d.ts +59 -4
- package/dist/components/carousel/carousel.js +299 -243
- package/dist/components/cascader/cascader.css +186 -184
- package/dist/components/cascader/cascader.d.ts +3 -1
- package/dist/components/cascader/cascader.js +28 -34
- package/dist/components/checkbox/checkbox.css +93 -90
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +171 -499
- package/dist/components/collapse/collapse-panels.js +145 -400
- package/dist/components/collapse/collapse.css +172 -170
- package/dist/components/collapse/collapse.d.ts +1 -1
- package/dist/components/collapse/collapse.js +62 -181
- package/dist/components/color-picker/color-picker.js +418 -982
- package/dist/components/context-menu/context-menu.css +4 -4
- package/dist/components/context-menu/context-menu.d.ts +1 -1
- package/dist/components/context-menu/context-menu.js +52 -138
- package/dist/components/date-picker/calendar/calendar-grid.js +41 -41
- package/dist/components/date-picker/calendar/calendar-header.js +171 -337
- package/dist/components/date-picker/calendar/month-grid.js +33 -103
- package/dist/components/date-picker/calendar/time-panel.js +81 -210
- package/dist/components/date-picker/calendar/year-grid.js +36 -105
- package/dist/components/date-picker/date-localization.js +1 -1
- package/dist/components/date-picker/date-picker.css +599 -642
- package/dist/components/date-picker/date-picker.d.ts +2 -1
- package/dist/components/date-picker/date-picker.js +93 -104
- package/dist/components/date-picker/presets.js +12 -37
- package/dist/components/date-picker/range-picker.d.ts +2 -1
- package/dist/components/date-picker/range-picker.js +217 -252
- package/dist/components/date-picker/types.d.ts +2 -1
- package/dist/components/descriptions/descriptions.css +1 -1
- package/dist/components/descriptions/descriptions.js +30 -39
- package/dist/components/drawer/drawer.css +202 -200
- package/dist/components/drawer/drawer.js +28 -34
- package/dist/components/dropdown/dropdown-core.d.ts +32 -0
- package/dist/components/dropdown/dropdown-core.js +156 -0
- package/dist/components/dropdown/dropdown.css +38 -36
- package/dist/components/dropdown/dropdown.d.ts +4 -31
- package/dist/components/dropdown/dropdown.js +90 -276
- package/dist/components/empty/empty.css +30 -28
- package/dist/components/empty/empty.js +81 -236
- package/dist/components/float-button/float-button.css +1 -1
- package/dist/components/float-button/float-button.js +36 -47
- package/dist/components/form/field-control.js +2 -3
- package/dist/components/form/form-item.js +67 -129
- package/dist/components/form/form.css +36 -34
- package/dist/components/form/form.d.ts +1 -1
- package/dist/components/form/form.js +29 -100
- package/dist/components/form/index.d.ts +1 -1
- package/dist/components/form/use-form.js +48 -67
- package/dist/components/form-actions/form-actions.d.ts +1 -0
- package/dist/components/form-actions/form-actions.js +10 -36
- package/dist/components/form-field/form-field-view.d.ts +1 -0
- package/dist/components/form-field/form-field-view.js +81 -288
- package/dist/components/form-field/form-field.js +13 -31
- package/dist/components/form-field/form.css +74 -72
- package/dist/components/form-section/form-section.d.ts +1 -0
- package/dist/components/form-section/form-section.js +38 -91
- package/dist/components/image/image-icons.js +16 -31
- package/dist/components/image/image.css +1 -1
- package/dist/components/image/image.js +298 -911
- package/dist/components/input/base-input.d.ts +3 -1
- package/dist/components/input/base-input.js +8 -7
- package/dist/components/input/input-shared.css +62 -60
- package/dist/components/input/input-shared.d.ts +1 -1
- package/dist/components/input/input-shared.js +56 -100
- package/dist/components/input/input.css +222 -220
- package/dist/components/input/otp.d.ts +2 -1
- package/dist/components/input/otp.js +143 -324
- package/dist/components/input/password.js +12 -67
- package/dist/components/input/search.js +13 -13
- package/dist/components/input-number/input-number.d.ts +2 -1
- package/dist/components/input-number/input-number.js +30 -152
- package/dist/components/list/list-pagination.css +107 -105
- package/dist/components/list/list-pagination.d.ts +56 -5
- package/dist/components/list/list-pagination.js +249 -316
- package/dist/components/list/list.css +179 -177
- package/dist/components/list/list.js +170 -604
- package/dist/components/listy/listy.css +55 -53
- package/dist/components/listy/listy.d.ts +43 -4
- package/dist/components/listy/listy.js +198 -216
- package/dist/components/masonry/masonry.css +1 -1
- package/dist/components/masonry/masonry.d.ts +1 -0
- package/dist/components/masonry/masonry.js +90 -244
- package/dist/components/mentions/mentions.css +153 -151
- package/dist/components/mentions/mentions.d.ts +53 -11
- package/dist/components/mentions/mentions.js +288 -73
- package/dist/components/menu/menu-render.d.ts +2 -1
- package/dist/components/menu/menu-render.js +149 -307
- package/dist/components/menu/menu.css +142 -140
- package/dist/components/modal/confirm-dialog.js +8 -18
- package/dist/components/modal/modal.css +165 -162
- package/dist/components/modal/modal.js +285 -731
- package/dist/components/modal/use-modal.js +25 -25
- package/dist/components/pagination/pagination.css +134 -131
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/pagination/pagination.js +137 -290
- package/dist/components/popconfirm/popconfirm.css +38 -36
- package/dist/components/popconfirm/popconfirm.js +105 -288
- package/dist/components/popover/popover.css +89 -87
- package/dist/components/popover/popover.js +168 -275
- package/dist/components/progress/progress.css +153 -151
- package/dist/components/progress/progress.js +34 -43
- package/dist/components/qr-code/qr-code.css +36 -34
- package/dist/components/qr-code/qr-code.js +83 -277
- package/dist/components/radio/radio.css +95 -92
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +114 -376
- package/dist/components/rate/rate.css +80 -78
- package/dist/components/rate/rate.d.ts +34 -6
- package/dist/components/rate/rate.js +160 -244
- package/dist/components/result/result.css +59 -57
- package/dist/components/result/result.d.ts +1 -0
- package/dist/components/result/result.js +118 -291
- package/dist/components/scroll-area/scroll-area.css +160 -148
- package/dist/components/scroll-area/scroll-area.js +284 -488
- package/dist/components/segmented/segmented.css +1 -1
- package/dist/components/segmented/segmented.js +59 -58
- package/dist/components/select/mobile-select.css +166 -164
- package/dist/components/select/mobile-select.js +48 -131
- package/dist/components/select/select-icons.js +59 -128
- package/dist/components/select/select-searchable-list.js +19 -19
- package/dist/components/select/select-tags.js +70 -156
- package/dist/components/select/select-types.d.ts +2 -1
- package/dist/components/select/select.css +509 -506
- package/dist/components/select/select.d.ts +1 -0
- package/dist/components/select/select.js +67 -65
- package/dist/components/select/use-select-selection.js +181 -269
- package/dist/components/skeleton/skeleton.css +105 -103
- package/dist/components/skeleton/skeleton.js +140 -399
- package/dist/components/slider/slider.css +160 -158
- package/dist/components/slider/slider.d.ts +45 -6
- package/dist/components/slider/slider.js +359 -74
- package/dist/components/sonner/index.d.ts +1 -1
- package/dist/components/sonner/sonner.css +190 -182
- package/dist/components/sonner/sonner.js +12 -11
- package/dist/components/spinner/spinner.css +80 -76
- package/dist/components/spinner/spinner.d.ts +1 -1
- package/dist/components/spinner/spinner.js +75 -219
- package/dist/components/splitter/splitter.css +157 -154
- package/dist/components/splitter/splitter.js +271 -448
- package/dist/components/statistic/statistic.css +1 -1
- package/dist/components/statistic/statistic.js +121 -413
- package/dist/components/status-icon/status-icon.js +14 -26
- package/dist/components/steps/steps-icons.js +63 -100
- package/dist/components/steps/steps.css +817 -807
- package/dist/components/steps/steps.d.ts +1 -1
- package/dist/components/steps/steps.js +38 -94
- package/dist/components/steps/use-display-steps.js +21 -54
- package/dist/components/switch/switch-touch.css +17 -15
- package/dist/components/switch/switch.css +192 -190
- package/dist/components/switch/switch.js +63 -196
- package/dist/components/table/table-filter.d.ts +1 -1
- package/dist/components/table/table-filter.js +68 -155
- package/dist/components/table/table-icons.js +77 -152
- package/dist/components/table/table-summary.js +30 -77
- package/dist/components/table/table-types.d.ts +2 -1
- package/dist/components/table/table.css +468 -465
- package/dist/components/table/table.js +85 -84
- package/dist/components/table/use-table-data.js +137 -248
- package/dist/components/tabs/tabs.css +123 -120
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +156 -331
- package/dist/components/tag/tag.css +231 -221
- package/dist/components/tag/tag.js +110 -248
- package/dist/components/textarea/textarea.css +2 -1
- package/dist/components/textarea/textarea.d.ts +3 -1
- package/dist/components/textarea/textarea.js +16 -15
- package/dist/components/time-picker/time-picker.d.ts +1 -0
- package/dist/components/time-picker/time-picker.js +88 -220
- package/dist/components/timeline/timeline.css +1 -1
- package/dist/components/timeline/timeline.js +17 -17
- package/dist/components/tooltip/tooltip.css +79 -77
- package/dist/components/tooltip/tooltip.js +105 -215
- package/dist/components/tour/tour.css +1 -1
- package/dist/components/tour/tour.d.ts +59 -6
- package/dist/components/tour/tour.js +343 -622
- package/dist/components/transfer/transfer-list.js +19 -19
- package/dist/components/transfer/transfer-parts.js +63 -139
- package/dist/components/transfer/transfer.css +192 -190
- package/dist/components/transfer/transfer.js +57 -56
- package/dist/components/tree/tree-check.js +25 -32
- package/dist/components/tree/tree-keyboard.js +1 -1
- package/dist/components/tree/tree.css +204 -200
- package/dist/components/tree/tree.js +139 -277
- package/dist/components/tree-select/select-engine.css +200 -197
- package/dist/components/tree-select/select-engine.js +11 -38
- package/dist/components/tree-select/tree-select.css +21 -19
- package/dist/components/tree-select/tree-select.d.ts +3 -1
- package/dist/components/tree-select/tree-select.js +11 -10
- package/dist/components/upload/upload.js +193 -308
- package/dist/components/watermark/watermark-context.js +8 -14
- package/dist/components/watermark/watermark.css +1 -1
- package/dist/components/watermark/watermark.js +209 -400
- package/dist/docs/components/stack.doc.js +1 -1
- package/dist/docs/components/table.doc.js +1 -1
- package/dist/entries/affix.d.ts +0 -2
- package/dist/entries/affix.js +0 -2
- package/dist/entries/alert.d.ts +0 -2
- package/dist/entries/alert.js +0 -2
- package/dist/entries/app.d.ts +0 -2
- package/dist/entries/app.js +0 -2
- package/dist/entries/auto-complete.d.ts +0 -2
- package/dist/entries/auto-complete.js +0 -2
- package/dist/entries/avatar.d.ts +0 -2
- package/dist/entries/avatar.js +0 -2
- package/dist/entries/badge.d.ts +0 -2
- package/dist/entries/badge.js +0 -2
- package/dist/entries/border-beam.d.ts +0 -2
- package/dist/entries/border-beam.js +0 -2
- package/dist/entries/breadcrumb.d.ts +0 -2
- package/dist/entries/breadcrumb.js +0 -2
- package/dist/entries/button.d.ts +0 -2
- package/dist/entries/button.js +0 -2
- package/dist/entries/calendar.d.ts +0 -2
- package/dist/entries/calendar.js +0 -2
- package/dist/entries/card.d.ts +0 -2
- package/dist/entries/card.js +0 -2
- package/dist/entries/carousel.d.ts +0 -2
- package/dist/entries/carousel.js +0 -2
- package/dist/entries/cascader.d.ts +0 -2
- package/dist/entries/cascader.js +0 -2
- package/dist/entries/checkbox.d.ts +0 -2
- package/dist/entries/checkbox.js +0 -2
- package/dist/entries/collapse.d.ts +0 -2
- package/dist/entries/collapse.js +0 -2
- package/dist/entries/color-picker.d.ts +0 -2
- package/dist/entries/color-picker.js +0 -2
- package/dist/entries/context-menu.d.ts +0 -2
- package/dist/entries/context-menu.js +0 -2
- package/dist/entries/date-picker.d.ts +0 -2
- package/dist/entries/date-picker.js +0 -2
- package/dist/entries/descriptions.d.ts +0 -2
- package/dist/entries/descriptions.js +0 -2
- package/dist/entries/divider.d.ts +0 -2
- package/dist/entries/divider.js +0 -2
- package/dist/entries/drawer.d.ts +0 -2
- package/dist/entries/drawer.js +0 -2
- package/dist/entries/dropdown.d.ts +0 -2
- package/dist/entries/dropdown.js +0 -2
- package/dist/entries/empty.d.ts +0 -2
- package/dist/entries/empty.js +0 -2
- package/dist/entries/float-button.d.ts +0 -2
- package/dist/entries/float-button.js +0 -2
- package/dist/entries/form-actions.d.ts +0 -2
- package/dist/entries/form-actions.js +0 -2
- package/dist/entries/form-field.d.ts +0 -2
- package/dist/entries/form-field.js +0 -2
- package/dist/entries/form-layout.d.ts +0 -2
- package/dist/entries/form-layout.js +0 -2
- package/dist/entries/form-section.d.ts +0 -2
- package/dist/entries/form-section.js +0 -2
- package/dist/entries/form.d.ts +1 -3
- package/dist/entries/form.js +0 -2
- package/dist/entries/image.d.ts +0 -2
- package/dist/entries/image.js +0 -2
- package/dist/entries/input-number.d.ts +0 -2
- package/dist/entries/input-number.js +0 -2
- package/dist/entries/input.d.ts +1 -3
- package/dist/entries/input.js +0 -2
- package/dist/entries/list.d.ts +0 -2
- package/dist/entries/list.js +0 -2
- package/dist/entries/listy.d.ts +0 -2
- package/dist/entries/listy.js +0 -2
- package/dist/entries/masonry.d.ts +0 -2
- package/dist/entries/masonry.js +0 -2
- package/dist/entries/mentions.d.ts +0 -2
- package/dist/entries/mentions.js +0 -2
- package/dist/entries/modal.d.ts +0 -2
- package/dist/entries/modal.js +0 -2
- package/dist/entries/number-input.d.ts +0 -2
- package/dist/entries/number-input.js +0 -2
- package/dist/entries/pagination.d.ts +0 -2
- package/dist/entries/pagination.js +0 -2
- package/dist/entries/popconfirm.d.ts +0 -2
- package/dist/entries/popconfirm.js +0 -2
- package/dist/entries/popover.d.ts +0 -2
- package/dist/entries/popover.js +0 -2
- package/dist/entries/progress.d.ts +0 -2
- package/dist/entries/progress.js +0 -2
- package/dist/entries/provider.d.ts +1 -3
- package/dist/entries/provider.js +1 -3
- package/dist/entries/qr-code.d.ts +0 -2
- package/dist/entries/qr-code.js +0 -2
- package/dist/entries/radio.d.ts +0 -2
- package/dist/entries/radio.js +0 -2
- package/dist/entries/range-picker.d.ts +0 -2
- package/dist/entries/range-picker.js +0 -2
- package/dist/entries/rate.d.ts +0 -2
- package/dist/entries/rate.js +0 -2
- package/dist/entries/result.d.ts +0 -2
- package/dist/entries/result.js +0 -2
- package/dist/entries/scroll-area.d.ts +0 -2
- package/dist/entries/scroll-area.js +0 -2
- package/dist/entries/segmented.d.ts +0 -2
- package/dist/entries/segmented.js +0 -2
- package/dist/entries/select.d.ts +0 -2
- package/dist/entries/select.js +0 -2
- package/dist/entries/skeleton.d.ts +0 -2
- package/dist/entries/skeleton.js +0 -2
- package/dist/entries/slider.d.ts +0 -2
- package/dist/entries/slider.js +0 -2
- package/dist/entries/sonner.d.ts +0 -2
- package/dist/entries/sonner.js +0 -2
- package/dist/entries/spinner.d.ts +0 -2
- package/dist/entries/spinner.js +0 -2
- package/dist/entries/splitter.d.ts +0 -2
- package/dist/entries/splitter.js +0 -2
- package/dist/entries/stack.d.ts +0 -2
- package/dist/entries/stack.js +0 -2
- package/dist/entries/statistic.d.ts +0 -2
- package/dist/entries/statistic.js +0 -2
- package/dist/entries/steps.d.ts +0 -2
- package/dist/entries/steps.js +0 -2
- package/dist/entries/switch.d.ts +0 -2
- package/dist/entries/switch.js +0 -2
- package/dist/entries/table.d.ts +0 -2
- package/dist/entries/table.js +0 -2
- package/dist/entries/tabs.d.ts +0 -2
- package/dist/entries/tabs.js +0 -2
- package/dist/entries/tag.d.ts +0 -2
- package/dist/entries/tag.js +0 -2
- package/dist/entries/textarea.d.ts +0 -2
- package/dist/entries/textarea.js +0 -2
- package/dist/entries/time-picker.d.ts +0 -2
- package/dist/entries/time-picker.js +0 -2
- package/dist/entries/timeline.d.ts +0 -2
- package/dist/entries/timeline.js +0 -2
- package/dist/entries/tooltip.d.ts +0 -2
- package/dist/entries/tooltip.js +0 -2
- package/dist/entries/tour.d.ts +0 -2
- package/dist/entries/tour.js +0 -2
- package/dist/entries/transfer.d.ts +0 -2
- package/dist/entries/transfer.js +0 -2
- package/dist/entries/tree-select.d.ts +0 -2
- package/dist/entries/tree-select.js +0 -2
- package/dist/entries/tree.d.ts +0 -2
- package/dist/entries/tree.js +0 -2
- package/dist/entries/upload.d.ts +0 -2
- package/dist/entries/upload.js +0 -2
- package/dist/entries/watermark.d.ts +0 -2
- package/dist/entries/watermark.js +0 -2
- package/dist/index.d.ts +5 -7
- package/dist/index.js +2 -4
- package/dist/layouts/form-layout/form-layout.d.ts +1 -0
- package/dist/layouts/form-layout/form-layout.js +10 -36
- package/dist/layouts/stack/layout.css +46 -44
- package/dist/layouts/stack/stack.d.ts +1 -0
- package/dist/layouts/stack/stack.js +16 -69
- package/dist/locales/ar-EG.js +25 -2
- package/dist/locales/create-locale.d.ts +1 -2
- package/dist/locales/create-locale.js +0 -28
- package/dist/locales/de-DE.js +25 -2
- package/dist/locales/en-US.js +24 -1
- package/dist/locales/es-ES.js +25 -2
- package/dist/locales/fr-FR.js +25 -2
- package/dist/locales/hi-IN.js +25 -2
- package/dist/locales/id-ID.js +25 -2
- package/dist/locales/index.d.ts +10 -10
- package/dist/locales/index.js +9 -9
- package/dist/locales/it-IT.js +25 -2
- package/dist/locales/ja-JP.js +25 -2
- package/dist/locales/ko-KR.js +25 -2
- package/dist/locales/pt-BR.js +25 -2
- package/dist/locales/ru-RU.js +25 -2
- package/dist/locales/th-TH.js +25 -2
- package/dist/locales/tr-TR.js +25 -2
- package/dist/locales/vi-VN.js +25 -2
- package/dist/locales/zh-CN.js +25 -2
- package/dist/locales/zh-TW.js +25 -2
- package/dist/number-input/number-input.js +24 -81
- package/dist/number-input/use-number-input.js +42 -42
- package/dist/provider/locale.d.ts +1 -1
- package/dist/provider/tao-context.d.ts +38 -0
- package/dist/provider/tao-context.js +92 -0
- package/dist/provider/tao-portal-scope.d.ts +14 -0
- package/dist/provider/tao-portal-scope.js +54 -0
- package/dist/provider/tao-provider.d.ts +5 -55
- package/dist/provider/tao-provider.js +94 -378
- package/dist/theme/control.css +106 -126
- package/dist/theme/theme.css +2 -0
- package/dist/utils/dialog-content.js +55 -210
- package/dist/utils/overlay.js +15 -30
- package/dist/utils/rc-compat.d.ts +13 -0
- package/dist/utils/rc-compat.js +48 -0
- package/dist/utils/refs.js +5 -19
- package/package.json +10 -16
|
@@ -1,515 +1,311 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useTaoConfig
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useTaoDirection } from "../../provider/tao-context.js";
|
|
4
|
+
import { useTaoConfig } from "../../provider/tao-provider.js";
|
|
5
5
|
import { getScrollLeft, setScrollLeft } from "../../utils/scroll-left.js";
|
|
6
6
|
import { cx } from "../../utils/semantic.js";
|
|
7
7
|
import "./scroll-area.css";
|
|
8
8
|
const scrollIdleDelay = 600;
|
|
9
9
|
const keyboardScrollStep = 40;
|
|
10
|
-
function ScrollArea(
|
|
11
|
-
const $ = c(90);
|
|
12
|
-
const { children, type: t1, direction: t2, maxHeight, maxWidth, scrollbarSize: t3, scrollbarOffset: t4, scrollShadow: t5, onScroll: onScrollProp, onScrollEnd, scrollEndThreshold: t6, className, style, classNames, styles } = t0;
|
|
13
|
-
const type = void 0 === t1 ? "hover" : t1;
|
|
14
|
-
const direction = void 0 === t2 ? "vertical" : t2;
|
|
15
|
-
const scrollbarSize = void 0 === t3 ? 6 : t3;
|
|
16
|
-
const scrollbarOffset = void 0 === t4 ? 2 : t4;
|
|
17
|
-
const scrollShadow = void 0 === t5 ? false : t5;
|
|
18
|
-
const scrollEndThreshold = void 0 === t6 ? 10 : t6;
|
|
10
|
+
function ScrollArea({ children, type = 'hover', direction = 'vertical', maxHeight, maxWidth, scrollbarSize = 6, scrollbarOffset = 2, scrollShadow = false, onScroll: onScrollProp, onScrollEnd, scrollEndThreshold = 10, className, style, classNames, styles }) {
|
|
19
11
|
const viewportRef = useRef(null);
|
|
20
|
-
const showVertical =
|
|
21
|
-
const showHorizontal =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
$[0] = t7;
|
|
37
|
-
} else t7 = $[0];
|
|
38
|
-
const [scrollState, setScrollState] = useState(t7);
|
|
39
|
-
const [textDirection, directionRef] = useTaoDirection(void 0, "self");
|
|
12
|
+
const showVertical = 'horizontal' !== direction;
|
|
13
|
+
const showHorizontal = 'vertical' !== direction;
|
|
14
|
+
const [scrollState, setScrollState] = useState({
|
|
15
|
+
hasVertical: false,
|
|
16
|
+
hasHorizontal: false,
|
|
17
|
+
thumbYRatio: 0,
|
|
18
|
+
thumbXRatio: 0,
|
|
19
|
+
thumbYOffset: 0,
|
|
20
|
+
thumbXOffset: 0,
|
|
21
|
+
atTop: true,
|
|
22
|
+
atBottom: true,
|
|
23
|
+
atLeft: true,
|
|
24
|
+
atRight: true
|
|
25
|
+
});
|
|
26
|
+
const [textDirection, directionRef] = useTaoDirection(void 0, 'self');
|
|
40
27
|
const { locale } = useTaoConfig();
|
|
41
28
|
const firedScrollEnd = useRef(false);
|
|
42
29
|
const lastScrollTop = useRef(0);
|
|
43
30
|
const [scrolling, setScrolling] = useState(false);
|
|
44
31
|
const scrollTimer = useRef(void 0);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
$[4] = showHorizontal;
|
|
84
|
-
$[5] = showVertical;
|
|
85
|
-
$[6] = textDirection;
|
|
86
|
-
$[7] = t10;
|
|
87
|
-
} else t10 = $[7];
|
|
88
|
-
const updateScrollState = t10;
|
|
89
|
-
let t11;
|
|
90
|
-
let t12;
|
|
91
|
-
if ($[8] !== updateScrollState) {
|
|
92
|
-
t11 = ()=>{
|
|
93
|
-
const el_0 = viewportRef.current;
|
|
94
|
-
if (!el_0) return;
|
|
95
|
-
const observer = new ResizeObserver(updateScrollState);
|
|
96
|
-
const observeContent = ()=>{
|
|
97
|
-
observer.disconnect();
|
|
98
|
-
observer.observe(el_0);
|
|
99
|
-
for (const child of el_0.children)observer.observe(child);
|
|
100
|
-
updateScrollState();
|
|
101
|
-
};
|
|
102
|
-
const mutations = new MutationObserver(observeContent);
|
|
103
|
-
mutations.observe(el_0, {
|
|
104
|
-
childList: true
|
|
105
|
-
});
|
|
106
|
-
observeContent();
|
|
107
|
-
return ()=>{
|
|
108
|
-
mutations.disconnect();
|
|
109
|
-
observer.disconnect();
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
t12 = [
|
|
113
|
-
updateScrollState
|
|
114
|
-
];
|
|
115
|
-
$[8] = updateScrollState;
|
|
116
|
-
$[9] = t11;
|
|
117
|
-
$[10] = t12;
|
|
118
|
-
} else {
|
|
119
|
-
t11 = $[9];
|
|
120
|
-
t12 = $[10];
|
|
121
|
-
}
|
|
122
|
-
useEffect(t11, t12);
|
|
123
|
-
let t13;
|
|
124
|
-
if ($[11] !== onScrollEnd || $[12] !== onScrollProp || $[13] !== type || $[14] !== updateScrollState) {
|
|
125
|
-
t13 = (e)=>{
|
|
126
|
-
const scrollTop_0 = e.currentTarget.scrollTop;
|
|
127
|
-
const movedVertically = scrollTop_0 !== lastScrollTop.current;
|
|
128
|
-
lastScrollTop.current = scrollTop_0;
|
|
129
|
-
const nearBottom_0 = updateScrollState();
|
|
130
|
-
if ("auto" === type || "scroll" === type) {
|
|
131
|
-
setScrolling(true);
|
|
132
|
-
clearTimeout(scrollTimer.current);
|
|
133
|
-
scrollTimer.current = setTimeout(()=>setScrolling(false), scrollIdleDelay);
|
|
134
|
-
}
|
|
135
|
-
onScrollProp?.(e);
|
|
136
|
-
if (onScrollEnd && movedVertically && nearBottom_0 && !firedScrollEnd.current) {
|
|
137
|
-
firedScrollEnd.current = true;
|
|
138
|
-
onScrollEnd();
|
|
139
|
-
}
|
|
32
|
+
useEffect(()=>()=>clearTimeout(scrollTimer.current), []);
|
|
33
|
+
const updateScrollState = useCallback(()=>{
|
|
34
|
+
const el = viewportRef.current;
|
|
35
|
+
if (!el) return;
|
|
36
|
+
const { scrollTop, scrollHeight, scrollWidth, clientHeight, clientWidth } = el;
|
|
37
|
+
const scrollLeft = getScrollLeft(el, getComputedStyle(el).direction || textDirection);
|
|
38
|
+
const hasV = showVertical && scrollHeight > clientHeight + 1;
|
|
39
|
+
const hasH = showHorizontal && scrollWidth > clientWidth + 1;
|
|
40
|
+
setScrollState({
|
|
41
|
+
hasVertical: hasV,
|
|
42
|
+
hasHorizontal: hasH,
|
|
43
|
+
thumbYRatio: hasV ? clientHeight / scrollHeight : 0,
|
|
44
|
+
thumbXRatio: hasH ? clientWidth / scrollWidth : 0,
|
|
45
|
+
thumbYOffset: hasV ? Math.max(0, Math.min(1, scrollTop / (scrollHeight - clientHeight))) : 0,
|
|
46
|
+
thumbXOffset: hasH ? Math.max(0, Math.min(1, scrollLeft / (scrollWidth - clientWidth))) : 0,
|
|
47
|
+
atTop: scrollTop <= 1,
|
|
48
|
+
atBottom: scrollTop + clientHeight >= scrollHeight - 1,
|
|
49
|
+
atLeft: scrollLeft <= 1,
|
|
50
|
+
atRight: scrollLeft + clientWidth >= scrollWidth - 1
|
|
51
|
+
});
|
|
52
|
+
const nearBottom = showVertical && scrollHeight > clientHeight && scrollTop + clientHeight >= scrollHeight - scrollEndThreshold;
|
|
53
|
+
if (!nearBottom) firedScrollEnd.current = false;
|
|
54
|
+
return nearBottom;
|
|
55
|
+
}, [
|
|
56
|
+
showVertical,
|
|
57
|
+
showHorizontal,
|
|
58
|
+
textDirection,
|
|
59
|
+
scrollEndThreshold
|
|
60
|
+
]);
|
|
61
|
+
useEffect(()=>{
|
|
62
|
+
const el = viewportRef.current;
|
|
63
|
+
if (!el) return;
|
|
64
|
+
const observer = new ResizeObserver(updateScrollState);
|
|
65
|
+
const observeContent = ()=>{
|
|
66
|
+
observer.disconnect();
|
|
67
|
+
observer.observe(el);
|
|
68
|
+
for (const child of el.children)observer.observe(child);
|
|
69
|
+
updateScrollState();
|
|
140
70
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
|
|
150
|
-
t14 = (axis, event)=>{
|
|
151
|
-
const viewport = viewportRef.current;
|
|
152
|
-
if (!viewport || event.defaultPrevented) return;
|
|
153
|
-
const vertical = "y" === axis;
|
|
154
|
-
const current = vertical ? viewport.scrollTop : getScrollLeft(viewport);
|
|
155
|
-
const page = vertical ? viewport.clientHeight : viewport.clientWidth;
|
|
156
|
-
const limit = (vertical ? viewport.scrollHeight : viewport.scrollWidth) - page;
|
|
157
|
-
const previous = vertical ? "ArrowUp" : "ArrowLeft";
|
|
158
|
-
const next = vertical ? "ArrowDown" : "ArrowRight";
|
|
159
|
-
let position;
|
|
160
|
-
switch(event.key){
|
|
161
|
-
case previous:
|
|
162
|
-
position = current - keyboardScrollStep;
|
|
163
|
-
break;
|
|
164
|
-
case next:
|
|
165
|
-
position = current + keyboardScrollStep;
|
|
166
|
-
break;
|
|
167
|
-
case "PageUp":
|
|
168
|
-
position = current - page;
|
|
169
|
-
break;
|
|
170
|
-
case "PageDown":
|
|
171
|
-
case "Enter":
|
|
172
|
-
case " ":
|
|
173
|
-
position = current + page;
|
|
174
|
-
break;
|
|
175
|
-
case "Home":
|
|
176
|
-
position = 0;
|
|
177
|
-
break;
|
|
178
|
-
case "End":
|
|
179
|
-
position = limit;
|
|
180
|
-
break;
|
|
181
|
-
default:
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
event.preventDefault();
|
|
185
|
-
const offset = Math.max(0, Math.min(limit, position));
|
|
186
|
-
if (vertical) viewport.scrollTop = offset;
|
|
187
|
-
else setScrollLeft(viewport, offset);
|
|
71
|
+
const mutations = new MutationObserver(observeContent);
|
|
72
|
+
mutations.observe(el, {
|
|
73
|
+
childList: true
|
|
74
|
+
});
|
|
75
|
+
observeContent();
|
|
76
|
+
return ()=>{
|
|
77
|
+
mutations.disconnect();
|
|
78
|
+
observer.disconnect();
|
|
188
79
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
80
|
+
}, [
|
|
81
|
+
updateScrollState
|
|
82
|
+
]);
|
|
83
|
+
const handleScroll = useCallback((e)=>{
|
|
84
|
+
const scrollTop = e.currentTarget.scrollTop;
|
|
85
|
+
const movedVertically = scrollTop !== lastScrollTop.current;
|
|
86
|
+
lastScrollTop.current = scrollTop;
|
|
87
|
+
const nearBottom = updateScrollState();
|
|
88
|
+
if ('auto' === type || 'scroll' === type) {
|
|
89
|
+
setScrolling(true);
|
|
90
|
+
clearTimeout(scrollTimer.current);
|
|
91
|
+
scrollTimer.current = setTimeout(()=>setScrolling(false), scrollIdleDelay);
|
|
92
|
+
}
|
|
93
|
+
onScrollProp?.(e);
|
|
94
|
+
if (onScrollEnd && movedVertically && nearBottom && !firedScrollEnd.current) {
|
|
95
|
+
firedScrollEnd.current = true;
|
|
96
|
+
onScrollEnd();
|
|
97
|
+
}
|
|
98
|
+
}, [
|
|
99
|
+
updateScrollState,
|
|
100
|
+
onScrollProp,
|
|
101
|
+
onScrollEnd,
|
|
102
|
+
type
|
|
103
|
+
]);
|
|
104
|
+
const handleTrackKeyDown = (axis, event)=>{
|
|
105
|
+
const viewport = viewportRef.current;
|
|
106
|
+
if (!viewport || event.defaultPrevented) return;
|
|
107
|
+
const vertical = 'y' === axis;
|
|
108
|
+
const current = vertical ? viewport.scrollTop : getScrollLeft(viewport);
|
|
109
|
+
const page = vertical ? viewport.clientHeight : viewport.clientWidth;
|
|
110
|
+
const limit = (vertical ? viewport.scrollHeight : viewport.scrollWidth) - page;
|
|
111
|
+
const previous = vertical ? 'ArrowUp' : 'ArrowLeft';
|
|
112
|
+
const next = vertical ? 'ArrowDown' : 'ArrowRight';
|
|
113
|
+
let position;
|
|
114
|
+
switch(event.key){
|
|
115
|
+
case previous:
|
|
116
|
+
position = current - keyboardScrollStep;
|
|
117
|
+
break;
|
|
118
|
+
case next:
|
|
119
|
+
position = current + keyboardScrollStep;
|
|
120
|
+
break;
|
|
121
|
+
case 'PageUp':
|
|
122
|
+
position = current - page;
|
|
123
|
+
break;
|
|
124
|
+
case 'PageDown':
|
|
125
|
+
case 'Enter':
|
|
126
|
+
case ' ':
|
|
127
|
+
position = current + page;
|
|
128
|
+
break;
|
|
129
|
+
case 'Home':
|
|
130
|
+
position = 0;
|
|
131
|
+
break;
|
|
132
|
+
case 'End':
|
|
133
|
+
position = limit;
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
const offset = Math.max(0, Math.min(limit, position));
|
|
140
|
+
if (vertical) viewport.scrollTop = offset;
|
|
141
|
+
else setScrollLeft(viewport, offset);
|
|
142
|
+
};
|
|
192
143
|
const activeDrag = useRef(null);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
144
|
+
useEffect(()=>()=>activeDrag.current?.cleanup(), []);
|
|
145
|
+
useEffect(()=>{
|
|
146
|
+
const drag = activeDrag.current;
|
|
147
|
+
if (drag && !viewportRef.current?.parentElement?.contains(drag.thumb)) drag.cleanup();
|
|
148
|
+
});
|
|
149
|
+
const handleThumbPointerDown = useCallback((axis, e)=>{
|
|
150
|
+
if (0 !== e.button) return;
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
e.stopPropagation();
|
|
153
|
+
activeDrag.current?.cleanup();
|
|
154
|
+
const el = viewportRef.current;
|
|
155
|
+
if (!el) return;
|
|
156
|
+
const thumb = e.currentTarget;
|
|
157
|
+
const ownerDocument = thumb.ownerDocument;
|
|
158
|
+
const track = thumb.parentElement;
|
|
159
|
+
if (!track) return;
|
|
160
|
+
const pos = 'y' === axis ? e.clientY : e.clientX;
|
|
161
|
+
const scroll = 'y' === axis ? el.scrollTop : getScrollLeft(el);
|
|
162
|
+
const pointerId = e.pointerId;
|
|
163
|
+
const handleMove = (ev)=>{
|
|
164
|
+
if (ev.pointerId !== pointerId || !viewportRef.current) return;
|
|
165
|
+
const delta = ('y' === axis ? ev.clientY : ev.clientX) - pos;
|
|
166
|
+
const vp = viewportRef.current;
|
|
167
|
+
const trackRect = track.getBoundingClientRect();
|
|
168
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
169
|
+
const travel = 'y' === axis ? trackRect.height - thumbRect.height : trackRect.width - thumbRect.width;
|
|
170
|
+
const maxScroll = 'y' === axis ? vp.scrollHeight - vp.clientHeight : vp.scrollWidth - vp.clientWidth;
|
|
171
|
+
if (travel <= 0 || maxScroll <= 0) return;
|
|
172
|
+
const nextScroll = Math.max(0, Math.min(maxScroll, scroll + delta / travel * maxScroll));
|
|
173
|
+
if ('y' === axis) vp.scrollTop = nextScroll;
|
|
174
|
+
else setScrollLeft(vp, nextScroll);
|
|
210
175
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
t18 = (axis_0, e_0)=>{
|
|
217
|
-
if (0 !== e_0.button) return;
|
|
218
|
-
e_0.preventDefault();
|
|
219
|
-
e_0.stopPropagation();
|
|
220
|
-
activeDrag.current?.cleanup();
|
|
221
|
-
const el_1 = viewportRef.current;
|
|
222
|
-
if (!el_1) return;
|
|
223
|
-
const thumb = e_0.currentTarget;
|
|
224
|
-
const ownerDocument = thumb.ownerDocument;
|
|
225
|
-
const track = thumb.parentElement;
|
|
226
|
-
if (!track) return;
|
|
227
|
-
const pos = "y" === axis_0 ? e_0.clientY : e_0.clientX;
|
|
228
|
-
const scroll = "y" === axis_0 ? el_1.scrollTop : getScrollLeft(el_1);
|
|
229
|
-
const pointerId = e_0.pointerId;
|
|
230
|
-
const handleMove = (ev)=>{
|
|
231
|
-
if (ev.pointerId !== pointerId || !viewportRef.current) return;
|
|
232
|
-
const delta = ("y" === axis_0 ? ev.clientY : ev.clientX) - pos;
|
|
233
|
-
const vp = viewportRef.current;
|
|
234
|
-
const trackRect = track.getBoundingClientRect();
|
|
235
|
-
const thumbRect = thumb.getBoundingClientRect();
|
|
236
|
-
const travel = "y" === axis_0 ? trackRect.height - thumbRect.height : trackRect.width - thumbRect.width;
|
|
237
|
-
const maxScroll = "y" === axis_0 ? vp.scrollHeight - vp.clientHeight : vp.scrollWidth - vp.clientWidth;
|
|
238
|
-
if (travel <= 0 || maxScroll <= 0) return;
|
|
239
|
-
const nextScroll = Math.max(0, Math.min(maxScroll, scroll + delta / travel * maxScroll));
|
|
240
|
-
if ("y" === axis_0) vp.scrollTop = nextScroll;
|
|
241
|
-
else setScrollLeft(vp, nextScroll);
|
|
242
|
-
};
|
|
243
|
-
const cleanup = ()=>{
|
|
244
|
-
ownerDocument.removeEventListener("pointermove", handleMove);
|
|
245
|
-
ownerDocument.removeEventListener("pointerup", handleEnd);
|
|
246
|
-
ownerDocument.removeEventListener("pointercancel", handleEnd);
|
|
247
|
-
activeDrag.current = null;
|
|
248
|
-
};
|
|
249
|
-
const handleEnd = (ev_0)=>{
|
|
250
|
-
if (ev_0.pointerId === pointerId) cleanup();
|
|
251
|
-
};
|
|
252
|
-
activeDrag.current = {
|
|
253
|
-
thumb,
|
|
254
|
-
cleanup
|
|
255
|
-
};
|
|
256
|
-
ownerDocument.addEventListener("pointermove", handleMove);
|
|
257
|
-
ownerDocument.addEventListener("pointerup", handleEnd);
|
|
258
|
-
ownerDocument.addEventListener("pointercancel", handleEnd);
|
|
176
|
+
const cleanup = ()=>{
|
|
177
|
+
ownerDocument.removeEventListener('pointermove', handleMove);
|
|
178
|
+
ownerDocument.removeEventListener('pointerup', handleEnd);
|
|
179
|
+
ownerDocument.removeEventListener('pointercancel', handleEnd);
|
|
180
|
+
activeDrag.current = null;
|
|
259
181
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const handleThumbPointerDown = t18;
|
|
263
|
-
let t19;
|
|
264
|
-
if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
|
|
265
|
-
t19 = (axis_1, e_1)=>{
|
|
266
|
-
const el_2 = viewportRef.current;
|
|
267
|
-
if (!el_2) return;
|
|
268
|
-
if (e_1.target.hasAttribute("data-tao-scroll-thumb")) return;
|
|
269
|
-
const rect = e_1.currentTarget.getBoundingClientRect();
|
|
270
|
-
const trackSize = "y" === axis_1 ? rect.height : rect.width;
|
|
271
|
-
if (trackSize <= 0) return;
|
|
272
|
-
const clickPos = ("y" === axis_1 ? e_1.clientY - rect.top : e_1.clientX - rect.left) / trackSize;
|
|
273
|
-
if ("y" === axis_1) el_2.scrollTop = clickPos * (el_2.scrollHeight - el_2.clientHeight);
|
|
274
|
-
else setScrollLeft(el_2, clickPos * (el_2.scrollWidth - el_2.clientWidth));
|
|
182
|
+
const handleEnd = (ev)=>{
|
|
183
|
+
if (ev.pointerId === pointerId) cleanup();
|
|
275
184
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const t20 = maxHeight ?? void 0;
|
|
280
|
-
const t21 = maxWidth ?? void 0;
|
|
281
|
-
let t22;
|
|
282
|
-
if ($[22] !== t20 || $[23] !== t21) {
|
|
283
|
-
t22 = {
|
|
284
|
-
maxHeight: t20,
|
|
285
|
-
maxWidth: t21
|
|
185
|
+
activeDrag.current = {
|
|
186
|
+
thumb,
|
|
187
|
+
cleanup
|
|
286
188
|
};
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const t33 = classNames?.root;
|
|
325
|
-
let t34;
|
|
326
|
-
if ($[32] !== className || $[33] !== t33) {
|
|
327
|
-
t34 = cx(t33, className);
|
|
328
|
-
$[32] = className;
|
|
329
|
-
$[33] = t33;
|
|
330
|
-
$[34] = t34;
|
|
331
|
-
} else t34 = $[34];
|
|
332
|
-
const t35 = styles?.root;
|
|
333
|
-
let t36;
|
|
334
|
-
if ($[35] !== rootStyle || $[36] !== scrollbarVars || $[37] !== style || $[38] !== t35) {
|
|
335
|
-
t36 = {
|
|
189
|
+
ownerDocument.addEventListener('pointermove', handleMove);
|
|
190
|
+
ownerDocument.addEventListener('pointerup', handleEnd);
|
|
191
|
+
ownerDocument.addEventListener('pointercancel', handleEnd);
|
|
192
|
+
}, []);
|
|
193
|
+
const handleTrackClick = useCallback((axis, e)=>{
|
|
194
|
+
const el = viewportRef.current;
|
|
195
|
+
if (!el) return;
|
|
196
|
+
if (e.target.hasAttribute('data-tao-scroll-thumb')) return;
|
|
197
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
198
|
+
const trackSize = 'y' === axis ? rect.height : rect.width;
|
|
199
|
+
if (trackSize <= 0) return;
|
|
200
|
+
const clickPos = ('y' === axis ? e.clientY - rect.top : e.clientX - rect.left) / trackSize;
|
|
201
|
+
if ('y' === axis) el.scrollTop = clickPos * (el.scrollHeight - el.clientHeight);
|
|
202
|
+
else setScrollLeft(el, clickPos * (el.scrollWidth - el.clientWidth));
|
|
203
|
+
}, []);
|
|
204
|
+
const rootStyle = {
|
|
205
|
+
maxHeight: maxHeight ?? void 0,
|
|
206
|
+
maxWidth: maxWidth ?? void 0
|
|
207
|
+
};
|
|
208
|
+
const viewportStyle = {
|
|
209
|
+
overflowY: showVertical ? 'scroll' : 'hidden',
|
|
210
|
+
overflowX: showHorizontal ? 'scroll' : 'hidden',
|
|
211
|
+
...styles?.viewport
|
|
212
|
+
};
|
|
213
|
+
const scrollbarVars = {
|
|
214
|
+
'--tao-scrollbar-size': `${scrollbarSize}px`,
|
|
215
|
+
'--tao-scrollbar-offset': `${scrollbarOffset}px`
|
|
216
|
+
};
|
|
217
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
218
|
+
ref: directionRef,
|
|
219
|
+
"data-tao-scroll-area": "",
|
|
220
|
+
"data-tao-scroll-type": type,
|
|
221
|
+
"data-tao-scrolling": scrolling || void 0,
|
|
222
|
+
"data-tao-has-v": scrollState.hasVertical || void 0,
|
|
223
|
+
"data-tao-has-h": scrollState.hasHorizontal || void 0,
|
|
224
|
+
className: cx(classNames?.root, className),
|
|
225
|
+
style: {
|
|
336
226
|
...rootStyle,
|
|
337
227
|
...scrollbarVars,
|
|
338
|
-
...
|
|
228
|
+
...styles?.root,
|
|
339
229
|
...style
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}),
|
|
378
|
-
/*#__PURE__*/ jsx("div", {
|
|
379
|
-
"data-tao-scroll-shadow": "bottom",
|
|
380
|
-
"data-tao-visible": !scrollState.atBottom || void 0
|
|
381
|
-
})
|
|
382
|
-
]
|
|
383
|
-
});
|
|
384
|
-
$[47] = scrollShadow;
|
|
385
|
-
$[48] = scrollState.atBottom;
|
|
386
|
-
$[49] = scrollState.atTop;
|
|
387
|
-
$[50] = showVertical;
|
|
388
|
-
$[51] = t40;
|
|
389
|
-
} else t40 = $[51];
|
|
390
|
-
let t41;
|
|
391
|
-
if ($[52] !== scrollShadow || $[53] !== scrollState.atLeft || $[54] !== scrollState.atRight || $[55] !== showHorizontal) {
|
|
392
|
-
t41 = scrollShadow && showHorizontal && /*#__PURE__*/ jsxs(Fragment, {
|
|
393
|
-
children: [
|
|
394
|
-
/*#__PURE__*/ jsx("div", {
|
|
395
|
-
"data-tao-scroll-shadow": "left",
|
|
396
|
-
"data-tao-visible": !scrollState.atLeft || void 0
|
|
397
|
-
}),
|
|
398
|
-
/*#__PURE__*/ jsx("div", {
|
|
399
|
-
"data-tao-scroll-shadow": "right",
|
|
400
|
-
"data-tao-visible": !scrollState.atRight || void 0
|
|
401
|
-
})
|
|
402
|
-
]
|
|
403
|
-
});
|
|
404
|
-
$[52] = scrollShadow;
|
|
405
|
-
$[53] = scrollState.atLeft;
|
|
406
|
-
$[54] = scrollState.atRight;
|
|
407
|
-
$[55] = showHorizontal;
|
|
408
|
-
$[56] = t41;
|
|
409
|
-
} else t41 = $[56];
|
|
410
|
-
let t42;
|
|
411
|
-
if ($[57] !== classNames?.scrollbar || $[58] !== classNames?.thumb || $[59] !== locale || $[60] !== scrollState.hasVertical || $[61] !== scrollState.thumbYOffset || $[62] !== scrollState.thumbYRatio || $[63] !== showVertical || $[64] !== styles?.scrollbar || $[65] !== styles?.thumb) {
|
|
412
|
-
t42 = showVertical && scrollState.hasVertical && /*#__PURE__*/ jsx("button", {
|
|
413
|
-
type: "button",
|
|
414
|
-
"data-tao-scrollbar": "",
|
|
415
|
-
"data-tao-orientation": "vertical",
|
|
416
|
-
"aria-label": locale.messages.scrollVertically,
|
|
417
|
-
className: cx(classNames?.scrollbar),
|
|
418
|
-
style: styles?.scrollbar,
|
|
419
|
-
onClick: (e_2)=>handleTrackClick("y", e_2),
|
|
420
|
-
onKeyDown: (e_3)=>handleTrackKeyDown("y", e_3),
|
|
421
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
422
|
-
"data-tao-scroll-thumb": "",
|
|
230
|
+
},
|
|
231
|
+
children: [
|
|
232
|
+
/*#__PURE__*/ jsx("div", {
|
|
233
|
+
ref: viewportRef,
|
|
234
|
+
"data-tao-scroll-viewport": "",
|
|
235
|
+
className: cx(classNames?.viewport),
|
|
236
|
+
style: viewportStyle,
|
|
237
|
+
onScroll: handleScroll,
|
|
238
|
+
children: children
|
|
239
|
+
}),
|
|
240
|
+
scrollShadow && showVertical && /*#__PURE__*/ jsxs(Fragment, {
|
|
241
|
+
children: [
|
|
242
|
+
/*#__PURE__*/ jsx("div", {
|
|
243
|
+
"data-tao-scroll-shadow": "top",
|
|
244
|
+
"data-tao-visible": !scrollState.atTop || void 0
|
|
245
|
+
}),
|
|
246
|
+
/*#__PURE__*/ jsx("div", {
|
|
247
|
+
"data-tao-scroll-shadow": "bottom",
|
|
248
|
+
"data-tao-visible": !scrollState.atBottom || void 0
|
|
249
|
+
})
|
|
250
|
+
]
|
|
251
|
+
}),
|
|
252
|
+
scrollShadow && showHorizontal && /*#__PURE__*/ jsxs(Fragment, {
|
|
253
|
+
children: [
|
|
254
|
+
/*#__PURE__*/ jsx("div", {
|
|
255
|
+
"data-tao-scroll-shadow": "left",
|
|
256
|
+
"data-tao-visible": !scrollState.atLeft || void 0
|
|
257
|
+
}),
|
|
258
|
+
/*#__PURE__*/ jsx("div", {
|
|
259
|
+
"data-tao-scroll-shadow": "right",
|
|
260
|
+
"data-tao-visible": !scrollState.atRight || void 0
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
}),
|
|
264
|
+
showVertical && scrollState.hasVertical && /*#__PURE__*/ jsx("button", {
|
|
265
|
+
type: "button",
|
|
266
|
+
"data-tao-scrollbar": "",
|
|
423
267
|
"data-tao-orientation": "vertical",
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
let t43;
|
|
446
|
-
if ($[67] !== classNames?.scrollbar || $[68] !== classNames?.thumb || $[69] !== locale || $[70] !== scrollState.hasHorizontal || $[71] !== scrollState.thumbXOffset || $[72] !== scrollState.thumbXRatio || $[73] !== showHorizontal || $[74] !== styles?.scrollbar || $[75] !== styles?.thumb) {
|
|
447
|
-
t43 = showHorizontal && scrollState.hasHorizontal && /*#__PURE__*/ jsx("button", {
|
|
448
|
-
type: "button",
|
|
449
|
-
"data-tao-scrollbar": "",
|
|
450
|
-
"data-tao-orientation": "horizontal",
|
|
451
|
-
"aria-label": locale.messages.scrollHorizontally,
|
|
452
|
-
className: cx(classNames?.scrollbar),
|
|
453
|
-
style: styles?.scrollbar,
|
|
454
|
-
onClick: (e_5)=>handleTrackClick("x", e_5),
|
|
455
|
-
onKeyDown: (e_6)=>handleTrackKeyDown("x", e_6),
|
|
456
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
457
|
-
"data-tao-scroll-thumb": "",
|
|
268
|
+
"aria-label": locale.messages.scrollVertically,
|
|
269
|
+
className: cx(classNames?.scrollbar),
|
|
270
|
+
style: styles?.scrollbar,
|
|
271
|
+
onClick: (e)=>handleTrackClick('y', e),
|
|
272
|
+
onKeyDown: (e)=>handleTrackKeyDown('y', e),
|
|
273
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
274
|
+
"data-tao-scroll-thumb": "",
|
|
275
|
+
"data-tao-orientation": "vertical",
|
|
276
|
+
className: cx(classNames?.thumb),
|
|
277
|
+
style: {
|
|
278
|
+
height: `${Math.max(100 * scrollState.thumbYRatio, 10)}%`,
|
|
279
|
+
top: `${100 * scrollState.thumbYOffset}%`,
|
|
280
|
+
transform: `translateY(-${100 * scrollState.thumbYOffset}%)`,
|
|
281
|
+
...styles?.thumb
|
|
282
|
+
},
|
|
283
|
+
onPointerDown: (e)=>handleThumbPointerDown('y', e)
|
|
284
|
+
})
|
|
285
|
+
}),
|
|
286
|
+
showHorizontal && scrollState.hasHorizontal && /*#__PURE__*/ jsx("button", {
|
|
287
|
+
type: "button",
|
|
288
|
+
"data-tao-scrollbar": "",
|
|
458
289
|
"data-tao-orientation": "horizontal",
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
290
|
+
"aria-label": locale.messages.scrollHorizontally,
|
|
291
|
+
className: cx(classNames?.scrollbar),
|
|
292
|
+
style: styles?.scrollbar,
|
|
293
|
+
onClick: (e)=>handleTrackClick('x', e),
|
|
294
|
+
onKeyDown: (e)=>handleTrackKeyDown('x', e),
|
|
295
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
296
|
+
"data-tao-scroll-thumb": "",
|
|
297
|
+
"data-tao-orientation": "horizontal",
|
|
298
|
+
className: cx(classNames?.thumb),
|
|
299
|
+
style: {
|
|
300
|
+
width: `${Math.max(100 * scrollState.thumbXRatio, 10)}%`,
|
|
301
|
+
left: `${100 * scrollState.thumbXOffset}%`,
|
|
302
|
+
transform: `translateX(-${100 * scrollState.thumbXOffset}%)`,
|
|
303
|
+
...styles?.thumb
|
|
304
|
+
},
|
|
305
|
+
onPointerDown: (e)=>handleThumbPointerDown('x', e)
|
|
306
|
+
})
|
|
467
307
|
})
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
$[68] = classNames?.thumb;
|
|
471
|
-
$[69] = locale;
|
|
472
|
-
$[70] = scrollState.hasHorizontal;
|
|
473
|
-
$[71] = scrollState.thumbXOffset;
|
|
474
|
-
$[72] = scrollState.thumbXRatio;
|
|
475
|
-
$[73] = showHorizontal;
|
|
476
|
-
$[74] = styles?.scrollbar;
|
|
477
|
-
$[75] = styles?.thumb;
|
|
478
|
-
$[76] = t43;
|
|
479
|
-
} else t43 = $[76];
|
|
480
|
-
let t44;
|
|
481
|
-
if ($[77] !== directionRef || $[78] !== t30 || $[79] !== t31 || $[80] !== t32 || $[81] !== t34 || $[82] !== t36 || $[83] !== t39 || $[84] !== t40 || $[85] !== t41 || $[86] !== t42 || $[87] !== t43 || $[88] !== type) {
|
|
482
|
-
t44 = /*#__PURE__*/ jsxs("div", {
|
|
483
|
-
ref: directionRef,
|
|
484
|
-
"data-tao-scroll-area": "",
|
|
485
|
-
"data-tao-scroll-type": type,
|
|
486
|
-
"data-tao-scrolling": t30,
|
|
487
|
-
"data-tao-has-v": t31,
|
|
488
|
-
"data-tao-has-h": t32,
|
|
489
|
-
className: t34,
|
|
490
|
-
style: t36,
|
|
491
|
-
children: [
|
|
492
|
-
t39,
|
|
493
|
-
t40,
|
|
494
|
-
t41,
|
|
495
|
-
t42,
|
|
496
|
-
t43
|
|
497
|
-
]
|
|
498
|
-
});
|
|
499
|
-
$[77] = directionRef;
|
|
500
|
-
$[78] = t30;
|
|
501
|
-
$[79] = t31;
|
|
502
|
-
$[80] = t32;
|
|
503
|
-
$[81] = t34;
|
|
504
|
-
$[82] = t36;
|
|
505
|
-
$[83] = t39;
|
|
506
|
-
$[84] = t40;
|
|
507
|
-
$[85] = t41;
|
|
508
|
-
$[86] = t42;
|
|
509
|
-
$[87] = t43;
|
|
510
|
-
$[88] = type;
|
|
511
|
-
$[89] = t44;
|
|
512
|
-
} else t44 = $[89];
|
|
513
|
-
return t44;
|
|
308
|
+
]
|
|
309
|
+
});
|
|
514
310
|
}
|
|
515
311
|
export { ScrollArea };
|