ropav 0.1.6 → 0.1.8
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 +7 -1
- package/dist/accordion.css +17 -17
- package/dist/accordion.js +123 -155
- package/dist/alert.css +18 -18
- package/dist/alert.js +10 -11
- package/dist/ancestry.js +136 -0
- package/dist/aria.js +14 -0
- package/dist/aspect-ratio.js +1 -1
- package/dist/attributes.js +9 -0
- package/dist/attributes2.js +29 -0
- package/dist/avatar.css +19 -19
- package/dist/avatar.js +9 -17
- package/dist/badge.css +16 -16
- package/dist/badge.js +5 -5
- package/dist/button-group.js +1 -1
- package/dist/button-link.js +4 -3
- package/dist/button.js +4 -3
- package/dist/button.scss_vue_type_style_index_0_src_true_lang.js +1 -1
- package/dist/calendar.css +173 -0
- package/dist/calendar.js +714 -0
- package/dist/calendar2.js +37 -0
- package/dist/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +22 -28
- package/dist/chevron-left.js +12 -0
- package/dist/collapse.css +6 -6
- package/dist/collapse.js +7 -6
- package/dist/collectionNavigation.js +2 -99
- package/dist/color-input.css +19 -19
- package/dist/color-input.js +14 -13
- package/dist/color-picker.css +40 -40
- package/dist/color-picker.js +247 -276
- package/dist/color-picker2.js +1 -9
- package/dist/color-swatch.css +4 -4
- package/dist/color-swatch.js +6 -8
- package/dist/color.js +5 -10
- package/dist/combobox.css +251 -0
- package/dist/combobox.js +410 -0
- package/dist/componentColors.js +125 -84
- package/dist/componentRef.js +26 -0
- package/dist/components/accordion/accordionContext.d.ts +3 -0
- package/dist/components/accordion/accordionModel.d.ts +14 -0
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/accordion/types.d.ts +1 -2
- package/dist/components/accordion/useAccordion.d.ts +2 -2
- package/dist/components/accordion/useAccordionItem.d.ts +2 -0
- package/dist/components/calendar/calendar.d.ts +30 -0
- package/dist/components/calendar/calendarBehavior.d.ts +49 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/calendar/index.js +3 -0
- package/dist/components/calendar/types.d.ts +53 -0
- package/dist/components/calendar/useCalendar.d.ts +24 -0
- package/dist/components/checkbox/useCheckbox.d.ts +1 -2
- package/dist/components/color-picker/index.js +2 -2
- package/dist/components/color-picker/types.d.ts +2 -2
- package/dist/components/color-picker/useColorPickerDrag.d.ts +1 -1
- package/dist/components/color-picker/useColorPickerSaturation.d.ts +22 -0
- package/dist/components/color-picker/useColorPickerSlider.d.ts +20 -0
- package/dist/components/color-picker/useColorPickerValue.d.ts +1 -1
- package/dist/components/combobox/combobox.d.ts +29 -0
- package/dist/components/combobox/comboboxModel.d.ts +4 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/combobox/types.d.ts +43 -0
- package/dist/components/combobox/useCombobox.d.ts +45 -0
- package/dist/components/date-picker/date-picker.d.ts +33 -0
- package/dist/components/date-picker/datePickerModel.d.ts +10 -0
- package/dist/components/date-picker/index.d.ts +4 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/date-picker/types.d.ts +57 -0
- package/dist/components/date-picker/useDatePicker.d.ts +29 -0
- package/dist/components/date-picker/useDatePickerValueState.d.ts +21 -0
- package/dist/components/dialog/{dialog-core.d.ts → dialogContext.d.ts} +1 -5
- package/dist/components/dialog/useDialogContentInteractions.d.ts +18 -0
- package/dist/components/dialog/useDialogRootState.d.ts +19 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-model.d.ts +8 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +2 -2
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +17 -30
- package/dist/components/dropdown-menu/dropdownMenuDataModel.d.ts +20 -0
- package/dist/components/dropdown-menu/dropdownMenuInteraction.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionNavigation.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionRegistry.d.ts +42 -0
- package/dist/components/dropdown-menu/dropdownMenuInteractionTypes.d.ts +114 -0
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +11 -11
- package/dist/components/dropdown-menu/useDropdownMenuContextTrigger.d.ts +9 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataController.d.ts +35 -0
- package/dist/components/dropdown-menu/useDropdownMenuDataRegistration.d.ts +24 -0
- package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +6 -5
- package/dist/components/dropdown-menu/useDropdownMenuInteractionDismissal.d.ts +17 -0
- package/dist/components/dropdown-menu/useDropdownMenuInteractionKeyboard.d.ts +19 -0
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +0 -1
- package/dist/components/dropdown-menu/useDropdownMenuPresentation.d.ts +28 -0
- package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +2 -2
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +1 -1
- package/dist/components/dropdown-menu/useDropdownMenuTargetBindings.d.ts +19 -0
- package/dist/components/dropzone/dropzone.d.ts +31 -0
- package/dist/components/dropzone/dropzoneModel.d.ts +16 -0
- package/dist/components/dropzone/index.d.ts +3 -0
- package/dist/components/dropzone/index.js +2 -0
- package/dist/components/dropzone/types.d.ts +56 -0
- package/dist/components/dropzone/useDropzone.d.ts +25 -0
- package/dist/components/file-input/file-input.d.ts +29 -0
- package/dist/components/file-input/index.d.ts +3 -0
- package/dist/components/file-input/index.js +2 -0
- package/dist/components/file-input/types.d.ts +37 -0
- package/dist/components/file-input/useFileInput.d.ts +15 -0
- package/dist/components/floating/index.js +2 -2
- package/dist/components/floating/useFloatingPosition.d.ts +1 -14
- package/dist/components/floating/useFloatingTargetLifecycle.d.ts +32 -0
- package/dist/components/floating/useHoverDisclosure.d.ts +10 -0
- package/dist/components/hover-card/hover-card.d.ts +25 -0
- package/dist/components/hover-card/index.d.ts +3 -0
- package/dist/components/hover-card/index.js +2 -0
- package/dist/components/hover-card/types.d.ts +45 -0
- package/dist/components/hover-card/useHoverCard.d.ts +22 -0
- package/dist/components/hover-card/useHoverCardDisclosure.d.ts +19 -0
- package/dist/components/multi-select/index.d.ts +3 -0
- package/dist/components/multi-select/index.js +2 -0
- package/dist/components/multi-select/multi-select.d.ts +30 -0
- package/dist/components/multi-select/multiSelectModel.d.ts +3 -0
- package/dist/components/multi-select/types.d.ts +49 -0
- package/dist/components/multi-select/useMultiSelect.d.ts +46 -0
- package/dist/components/number-input/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +3 -19
- package/dist/components/pagination/index.d.ts +1 -1
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/pagination/paginationModel.d.ts +4 -0
- package/dist/components/pagination/types.d.ts +15 -0
- package/dist/components/pagination/usePagination.d.ts +3 -19
- package/dist/components/popover/usePopoverBindings.d.ts +13 -0
- package/dist/components/progress/progressModel.d.ts +8 -0
- package/dist/components/progress/useProgress.d.ts +0 -6
- package/dist/components/radio/useRadio.d.ts +1 -2
- package/dist/components/scroll-area/scroll-area.d.ts +1 -1
- package/dist/components/scroll-area/scrollAreaModel.d.ts +64 -0
- package/dist/components/scroll-area/useScrollArea.d.ts +70 -53
- package/dist/components/scroll-area/{useScrollAreaPresentation.d.ts → useScrollAreaAttributes.d.ts} +37 -17
- package/dist/components/scroll-area/useScrollAreaDerivedState.d.ts +8 -0
- package/dist/components/scroll-area/useScrollAreaMeasurement.d.ts +35 -0
- package/dist/components/scroll-area/useScrollAreaPointer.d.ts +11 -9
- package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +15 -20
- package/dist/components/segmented-control/index.d.ts +3 -0
- package/dist/components/segmented-control/index.js +2 -0
- package/dist/components/segmented-control/segmented-control.d.ts +26 -0
- package/dist/components/segmented-control/types.d.ts +47 -0
- package/dist/components/segmented-control/useSegmentedControl.d.ts +15 -0
- package/dist/components/select/useSelect.d.ts +31 -19
- package/dist/components/slider/rangeSliderModel.d.ts +41 -0
- package/dist/components/slider/{sliderCore.d.ts → sliderModel.d.ts} +0 -1
- package/dist/components/slider/useRangeSlider.d.ts +9 -17
- package/dist/components/slider/useRangeSliderPointer.d.ts +1 -1
- package/dist/components/slider/useRangeSliderValueState.d.ts +40 -0
- package/dist/components/slider/useSlider.d.ts +7 -13
- package/dist/components/slider/useSliderPointerPreview.d.ts +22 -0
- package/dist/components/slider/useSliderTooltipState.d.ts +40 -0
- package/dist/components/slider/useSliderValueState.d.ts +33 -0
- package/dist/components/tags-input/index.d.ts +3 -0
- package/dist/components/tags-input/index.js +2 -0
- package/dist/components/tags-input/tags-input.d.ts +27 -0
- package/dist/components/tags-input/tagsInputModel.d.ts +12 -0
- package/dist/components/tags-input/types.d.ts +37 -0
- package/dist/components/tags-input/useTagsInput.d.ts +23 -0
- package/dist/components/teleport-provider/index.js +1 -1
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +1 -2
- package/dist/components/toast/useToastLifecycle.d.ts +19 -0
- package/dist/components/tooltip/useTooltip.d.ts +1 -2
- package/dist/components/tooltip/useTooltipTargetBindings.d.ts +12 -0
- package/dist/css.js +12 -0
- package/dist/date-picker.css +49 -0
- package/dist/date-picker.js +809 -0
- package/dist/dialog.js +215 -218
- package/dist/direction.js +6 -0
- package/dist/dropdown-menu.css +21 -3
- package/dist/dropdown-menu.js +1626 -1185
- package/dist/dropzone.css +135 -0
- package/dist/dropzone.js +431 -0
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/file-input.css +135 -0
- package/dist/file-input.js +198 -0
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/hover-card.css +80 -0
- package/dist/hover-card.js +402 -0
- package/dist/icon-button.css +8 -8
- package/dist/icon-button.js +7 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -9
- package/dist/input.css +24 -24
- package/dist/input.js +19 -31
- package/dist/interactive.js +18 -0
- package/dist/internal/composables/useOverlayLayer.d.ts +12 -0
- package/dist/modal.js +2 -2
- package/dist/multi-select.css +316 -0
- package/dist/multi-select.js +481 -0
- package/dist/nativeChoice.js +169 -0
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +44 -44
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +66 -73
- package/dist/pointerSession.js +130 -0
- package/dist/popover.css +55 -37
- package/dist/popover.js +75 -101
- package/dist/progress.js +10 -13
- package/dist/query.js +40 -0
- package/dist/radio.css +18 -18
- package/dist/radio.js +30 -36
- package/dist/rafScheduler.js +34 -0
- package/dist/scroll-area.css +28 -28
- package/dist/scroll-area.js +540 -554
- package/dist/segmented-control.css +176 -0
- package/dist/segmented-control.js +382 -0
- package/dist/select.css +50 -48
- package/dist/select.js +131 -289
- package/dist/slider.css +191 -191
- package/dist/slider.js +720 -706
- package/dist/styles-api.d.ts +0 -1
- package/dist/styles-api.js +1 -4
- package/dist/switch.css +17 -17
- package/dist/switch.js +14 -15
- package/dist/tabs.css +43 -43
- package/dist/tabs.js +29 -56
- package/dist/tags-input.css +197 -0
- package/dist/tags-input.js +380 -0
- package/dist/text.js +17 -0
- package/dist/textarea.css +26 -26
- package/dist/textarea.js +21 -32
- package/dist/toast.css +26 -26
- package/dist/toast.js +141 -118
- package/dist/tooltip.css +12 -12
- package/dist/tooltip.js +64 -63
- package/dist/useCollapse.js +8 -11
- package/dist/useControlState.js +3 -6
- package/dist/useEditableOptionList.js +216 -0
- package/dist/useFlatOptionCollection.js +134 -0
- package/dist/useFloatingPosition.js +14 -40
- package/dist/useFloatingTargetLifecycle.js +127 -0
- package/dist/useFormControl.js +1 -0
- package/dist/useHoverDisclosure.js +561 -0
- package/dist/useNativeChoiceTransaction.js +46 -0
- package/dist/useNativeFileSelection.js +86 -0
- package/dist/useOverlayZIndex.js +246 -19
- package/dist/useTeleportTarget.js +3 -14
- package/dist/useTypeahead.js +94 -0
- package/dist/utils/aria.d.ts +3 -0
- package/dist/utils/attributes.d.ts +2 -0
- package/dist/utils/bem.d.ts +3 -0
- package/dist/utils/collectionNavigation.d.ts +2 -0
- package/dist/utils/color.d.ts +7 -0
- package/dist/{components/color-picker/color-picker-utils.d.ts → utils/colorPicker.d.ts} +5 -4
- package/dist/utils/componentColors.d.ts +7 -0
- package/dist/utils/css.d.ts +3 -0
- package/dist/utils/date.d.ts +13 -0
- package/dist/utils/dateAvailability.d.ts +7 -0
- package/dist/utils/dom/ancestry.d.ts +8 -0
- package/dist/utils/dom/attributes.d.ts +16 -0
- package/dist/utils/dom/componentRef.d.ts +4 -0
- package/dist/utils/dom/direction.d.ts +2 -0
- package/dist/utils/dom/events.d.ts +5 -0
- package/dist/utils/dom/files.d.ts +3 -0
- package/dist/utils/dom/focusNavigation.d.ts +7 -0
- package/dist/utils/dom/interactive.d.ts +2 -0
- package/dist/utils/dom/nativeChoice.d.ts +17 -0
- package/dist/utils/dom/pointerSession.d.ts +20 -0
- package/dist/utils/dom/query.d.ts +4 -0
- package/dist/utils/dom/scroll.d.ts +24 -0
- package/dist/utils/floatingOffset.d.ts +10 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/indexPath.d.ts +6 -0
- package/dist/utils/number.d.ts +4 -0
- package/dist/utils/optionFilter.d.ts +5 -0
- package/dist/utils/rafScheduler.d.ts +4 -0
- package/dist/utils/text.d.ts +2 -0
- package/docs/code-architecture.md +118 -0
- package/docs/public-floating-api.md +13 -9
- package/docs/public-styles-api.md +25 -12
- package/package.json +51 -14
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/styles-manifest.json +1 -2
- package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +0 -3
- package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +0 -21
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +0 -36
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +0 -29
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +0 -52
- package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +0 -17
- package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +0 -18
- package/dist/components/scroll-area/scrollAreaCore.d.ts +0 -30
- package/dist/components/scroll-area/useScrollAreaControls.d.ts +0 -25
- package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +0 -38
- package/dist/components/select/useSelectNativeControl.d.ts +0 -9
- package/dist/components/select/useSelectNativeValue.d.ts +0 -9
- package/dist/floating.js +0 -415
- /package/dist/components/alert/{useAlertColor.d.ts → alertColor.d.ts} +0 -0
- /package/dist/components/avatar/{useAvatarColor.d.ts → avatarColor.d.ts} +0 -0
- /package/dist/components/badge/{useBadgeColor.d.ts → badgeColor.d.ts} +0 -0
- /package/dist/components/button/{useButtonColor.d.ts → buttonColor.d.ts} +0 -0
- /package/dist/components/color-swatch/{useColorSwatchColor.d.ts → colorSwatchColor.d.ts} +0 -0
- /package/dist/components/toast/{useToastColor.d.ts → toastColor.d.ts} +0 -0
package/dist/scroll-area.js
CHANGED
|
@@ -1,217 +1,72 @@
|
|
|
1
1
|
import './scroll-area.css';
|
|
2
|
-
import {
|
|
2
|
+
import { t as useStylesApi } from "./styles-api.js";
|
|
3
|
+
import { n as toPresenceAttribute } from "./attributes.js";
|
|
3
4
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import { r as normalizeDelay, t as clamp } from "./number.js";
|
|
6
|
+
import { o as splitCompatibilityAttributes, t as composeEventHandlers } from "./attributes2.js";
|
|
7
|
+
import { n as toPositiveCssLength } from "./css.js";
|
|
8
|
+
import { t as createRafScheduler } from "./rafScheduler.js";
|
|
9
|
+
import { t as createPointerSession } from "./pointerSession.js";
|
|
10
|
+
import { i as isNodeWithinElement } from "./events.js";
|
|
11
|
+
import { t as getElementDirection } from "./direction.js";
|
|
12
|
+
import { child, computed, createIf, createSlot, createTemplateRefSetter, defineVaporComponent, nextTick, on, onBeforeUnmount, onMounted, reactive, ref, renderEffect, setDynamicProps, setInsertionState, setTemplateRefBinding, template, unref, useId, watch } from "vue";
|
|
13
|
+
//#region src/utils/dom/scroll.ts
|
|
14
|
+
function getScrollDirection(element) {
|
|
15
|
+
return getElementDirection(element);
|
|
12
16
|
}
|
|
13
|
-
function
|
|
17
|
+
function getLogicalHorizontalScrollPosition(scrollLeft, maxPosition, direction) {
|
|
14
18
|
return clamp(direction === "rtl" ? -scrollLeft : scrollLeft, 0, maxPosition);
|
|
15
19
|
}
|
|
16
|
-
function
|
|
20
|
+
function getRawHorizontalScrollPosition(position, maxPosition, direction) {
|
|
17
21
|
const logicalPosition = clamp(position, 0, maxPosition);
|
|
18
22
|
return direction === "rtl" && logicalPosition !== 0 ? -logicalPosition : logicalPosition;
|
|
19
23
|
}
|
|
20
|
-
function
|
|
21
|
-
if (scrollbars === false) return false;
|
|
22
|
-
if (axis === "x") return scrollbars === "x" || scrollbars === "both";
|
|
23
|
-
return scrollbars === "y" || scrollbars === "both";
|
|
24
|
-
}
|
|
25
|
-
function isScrollbarActive(type, enabled, overflowing) {
|
|
26
|
-
if (!enabled || type === "never") return false;
|
|
27
|
-
return type === "always" || overflowing;
|
|
28
|
-
}
|
|
29
|
-
function getThumbGeometry(trackSize, viewportSize, scrollSize) {
|
|
24
|
+
function getScrollThumbGeometry(trackSize, viewportSize, scrollSize, minimumSize) {
|
|
30
25
|
if (trackSize <= 0 || viewportSize <= 0 || scrollSize <= viewportSize) return {
|
|
31
26
|
size: 100,
|
|
32
27
|
offsetRatio: 1
|
|
33
28
|
};
|
|
34
|
-
const sizeRatio = clamp(viewportSize / scrollSize * trackSize,
|
|
29
|
+
const sizeRatio = clamp(viewportSize / scrollSize * trackSize, minimumSize, trackSize) / trackSize;
|
|
35
30
|
return {
|
|
36
31
|
size: sizeRatio * 100,
|
|
37
32
|
offsetRatio: sizeRatio
|
|
38
33
|
};
|
|
39
34
|
}
|
|
40
|
-
function
|
|
35
|
+
function getScrollThumbOffset(position, maxPosition, sizeRatio) {
|
|
41
36
|
if (sizeRatio >= 1 || maxPosition <= 0) return 0;
|
|
42
37
|
return position / maxPosition * ((1 - sizeRatio) / sizeRatio) * 100;
|
|
43
38
|
}
|
|
44
|
-
function
|
|
45
|
-
if (typeof value === "number") return Number.isFinite(value) && value > 0 ? `${value}px` : "";
|
|
46
|
-
return value?.trim() ?? "";
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/components/scroll-area/useScrollAreaControls.ts
|
|
50
|
-
function useScrollAreaControls(options) {
|
|
51
|
-
let previousPosition = {
|
|
52
|
-
x: 0,
|
|
53
|
-
y: 0
|
|
54
|
-
};
|
|
55
|
-
function onViewportScroll(event) {
|
|
56
|
-
options.metrics.updatePosition();
|
|
57
|
-
options.showDuringScroll();
|
|
58
|
-
const position = {
|
|
59
|
-
x: options.metrics.getPosition("x"),
|
|
60
|
-
y: options.metrics.getPosition("y")
|
|
61
|
-
};
|
|
62
|
-
const reachedBoundaries = getReachedBoundaries(position);
|
|
63
|
-
previousPosition = position;
|
|
64
|
-
options.emitScroll(event);
|
|
65
|
-
options.emitPositionChange({
|
|
66
|
-
x: options.metrics.metrics.x,
|
|
67
|
-
y: options.metrics.metrics.y
|
|
68
|
-
});
|
|
69
|
-
for (const boundary of reachedBoundaries) emitReachedBoundary(boundary, event);
|
|
70
|
-
}
|
|
71
|
-
function getReachedBoundaries(position) {
|
|
72
|
-
const boundaries = [];
|
|
73
|
-
if (options.metrics.getOverflow("y")) {
|
|
74
|
-
const maxPosition = options.metrics.getMaxPosition("y");
|
|
75
|
-
if (position.y <= 1 && previousPosition.y > 1) boundaries.push("top");
|
|
76
|
-
if (position.y >= maxPosition - 1 && previousPosition.y < maxPosition - 1) boundaries.push("bottom");
|
|
77
|
-
}
|
|
78
|
-
if (options.metrics.getOverflow("x")) {
|
|
79
|
-
const maxPosition = options.metrics.getMaxPosition("x");
|
|
80
|
-
const reachedStart = position.x <= 1 && previousPosition.x > 1;
|
|
81
|
-
const reachedEnd = position.x >= maxPosition - 1 && previousPosition.x < maxPosition - 1;
|
|
82
|
-
if (reachedStart || reachedEnd) {
|
|
83
|
-
const rtl = options.metrics.metrics.direction === "rtl";
|
|
84
|
-
if (reachedStart) boundaries.push(rtl ? "right" : "left");
|
|
85
|
-
if (reachedEnd) boundaries.push(rtl ? "left" : "right");
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return boundaries;
|
|
89
|
-
}
|
|
90
|
-
function emitReachedBoundary(boundary, event) {
|
|
91
|
-
switch (boundary) {
|
|
92
|
-
case "top":
|
|
93
|
-
options.emitReachTop(event);
|
|
94
|
-
break;
|
|
95
|
-
case "bottom":
|
|
96
|
-
options.emitReachBottom(event);
|
|
97
|
-
break;
|
|
98
|
-
case "left":
|
|
99
|
-
options.emitReachLeft(event);
|
|
100
|
-
break;
|
|
101
|
-
case "right":
|
|
102
|
-
options.emitReachRight(event);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function writeAxisPosition(axis, value) {
|
|
107
|
-
const viewport = options.viewportRef.value;
|
|
108
|
-
if (!viewport) return;
|
|
109
|
-
if (axis === "x") viewport.scrollLeft = getRawHorizontalPosition(value, options.metrics.getMaxPosition("x"), options.metrics.metrics.direction);
|
|
110
|
-
else viewport.scrollTop = clamp(value, 0, options.metrics.getMaxPosition("y"));
|
|
111
|
-
options.metrics.updatePosition();
|
|
112
|
-
options.showDuringScroll();
|
|
113
|
-
}
|
|
114
|
-
function onScrollbarKeydown(axis, event) {
|
|
115
|
-
const viewport = options.viewportRef.value;
|
|
116
|
-
if (!viewport || !options.metrics.getOverflow(axis)) return;
|
|
117
|
-
options.metrics.updatePosition(viewport);
|
|
118
|
-
const current = options.metrics.getPosition(axis);
|
|
119
|
-
const pageSize = axis === "x" ? viewport.clientWidth : viewport.clientHeight;
|
|
120
|
-
const nextPosition = getKeyboardPosition(axis, event.key, current, pageSize, options.metrics.getMaxPosition(axis), options.metrics.metrics.direction);
|
|
121
|
-
if (nextPosition === void 0) return;
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
writeAxisPosition(axis, nextPosition);
|
|
124
|
-
}
|
|
125
|
-
function onScrollbarWheel(axis, event) {
|
|
126
|
-
if (!options.metrics.getOverflow(axis)) return;
|
|
127
|
-
options.metrics.updatePosition();
|
|
128
|
-
const delta = getWheelDelta(axis, event, options.metrics.metrics.direction);
|
|
129
|
-
if (!delta) return;
|
|
130
|
-
event.preventDefault();
|
|
131
|
-
writeAxisPosition(axis, options.metrics.getPosition(axis) + delta);
|
|
132
|
-
}
|
|
133
|
-
function scrollTo(scrollOptions) {
|
|
134
|
-
const viewport = options.viewportRef.value;
|
|
135
|
-
if (!viewport) return;
|
|
136
|
-
if (typeof viewport.scrollTo === "function") viewport.scrollTo(scrollOptions);
|
|
137
|
-
else setFallbackPosition(viewport, scrollOptions, false);
|
|
138
|
-
options.metrics.schedulePositionUpdate();
|
|
139
|
-
}
|
|
140
|
-
function scrollBy(scrollOptions) {
|
|
141
|
-
const viewport = options.viewportRef.value;
|
|
142
|
-
if (!viewport) return;
|
|
143
|
-
if (typeof viewport.scrollBy === "function") viewport.scrollBy(scrollOptions);
|
|
144
|
-
else setFallbackPosition(viewport, scrollOptions, true);
|
|
145
|
-
options.metrics.schedulePositionUpdate();
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
onViewportScroll,
|
|
149
|
-
onScrollbarKeydown,
|
|
150
|
-
onScrollbarWheel,
|
|
151
|
-
writeAxisPosition,
|
|
152
|
-
scrollTo,
|
|
153
|
-
scrollBy
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function getKeyboardPosition(axis, key, current, pageSize, max, direction) {
|
|
39
|
+
function getKeyboardScrollPosition({ axis, key, current, pageSize, maxPosition, direction, lineStep }) {
|
|
157
40
|
switch (key) {
|
|
158
|
-
case "ArrowLeft": return current + (axis === "x" && direction === "rtl" ?
|
|
159
|
-
case "ArrowUp": return current -
|
|
160
|
-
case "ArrowRight": return current + (axis === "x" && direction === "rtl" ? -
|
|
161
|
-
case "ArrowDown": return current +
|
|
41
|
+
case "ArrowLeft": return current + (axis === "x" && direction === "rtl" ? lineStep : -lineStep);
|
|
42
|
+
case "ArrowUp": return current - lineStep;
|
|
43
|
+
case "ArrowRight": return current + (axis === "x" && direction === "rtl" ? -lineStep : lineStep);
|
|
44
|
+
case "ArrowDown": return current + lineStep;
|
|
162
45
|
case "PageUp": return current - pageSize;
|
|
163
46
|
case "PageDown": return current + pageSize;
|
|
164
47
|
case "Home": return 0;
|
|
165
|
-
case "End": return
|
|
48
|
+
case "End": return maxPosition;
|
|
166
49
|
default: return;
|
|
167
50
|
}
|
|
168
51
|
}
|
|
169
|
-
function
|
|
52
|
+
function getWheelScrollDelta(axis, event, direction) {
|
|
170
53
|
if (axis === "y") return event.deltaY;
|
|
171
54
|
if (!event.deltaX) return event.deltaY;
|
|
172
55
|
return direction === "rtl" ? -event.deltaX : event.deltaX;
|
|
173
56
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
176
|
-
if (
|
|
57
|
+
function applyFallbackScrollPosition(element, options, mode) {
|
|
58
|
+
const relative = mode === "relative";
|
|
59
|
+
if (options.left !== void 0) element.scrollLeft = (relative ? element.scrollLeft : 0) + options.left;
|
|
60
|
+
if (options.top !== void 0) element.scrollTop = (relative ? element.scrollTop : 0) + options.top;
|
|
177
61
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
function createRafScheduler(callback, getView) {
|
|
181
|
-
let frameId;
|
|
182
|
-
let frameView;
|
|
183
|
-
let generation = 0;
|
|
184
|
-
function cancel() {
|
|
185
|
-
generation += 1;
|
|
186
|
-
if (frameId !== void 0) frameView?.cancelAnimationFrame(frameId);
|
|
187
|
-
frameId = void 0;
|
|
188
|
-
frameView = void 0;
|
|
189
|
-
}
|
|
190
|
-
function schedule() {
|
|
191
|
-
if (frameId !== void 0) return;
|
|
192
|
-
const view = getView();
|
|
193
|
-
if (!view?.requestAnimationFrame) {
|
|
194
|
-
callback();
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const scheduledGeneration = generation;
|
|
198
|
-
frameView = view;
|
|
199
|
-
frameId = view.requestAnimationFrame(() => {
|
|
200
|
-
if (generation !== scheduledGeneration || frameView !== view) return;
|
|
201
|
-
frameId = void 0;
|
|
202
|
-
frameView = void 0;
|
|
203
|
-
callback();
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
cancel,
|
|
208
|
-
schedule
|
|
209
|
-
};
|
|
62
|
+
function getPointerAxisCoordinate(axis, event) {
|
|
63
|
+
return axis === "x" ? event.clientX : event.clientY;
|
|
210
64
|
}
|
|
211
65
|
//#endregion
|
|
212
|
-
//#region src/components/scroll-area/
|
|
213
|
-
|
|
214
|
-
|
|
66
|
+
//#region src/components/scroll-area/scrollAreaModel.ts
|
|
67
|
+
var boundaryTolerance = 1;
|
|
68
|
+
function createScrollAreaMetrics() {
|
|
69
|
+
return {
|
|
215
70
|
direction: "ltr",
|
|
216
71
|
clientWidth: 0,
|
|
217
72
|
clientHeight: 0,
|
|
@@ -225,20 +80,210 @@ function useScrollAreaMetrics(options) {
|
|
|
225
80
|
horizontalThumbOffset: 0,
|
|
226
81
|
verticalThumbSize: 100,
|
|
227
82
|
verticalThumbOffset: 0
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function isScrollAreaAxisEnabled(scrollbars, axis) {
|
|
86
|
+
if (scrollbars === false) return false;
|
|
87
|
+
if (axis === "x") return scrollbars === "x" || scrollbars === "both";
|
|
88
|
+
return scrollbars === "y" || scrollbars === "both";
|
|
89
|
+
}
|
|
90
|
+
function isScrollAreaScrollbarActive(type, enabled, overflowing) {
|
|
91
|
+
if (!enabled || type === "never") return false;
|
|
92
|
+
return type === "always" || overflowing;
|
|
93
|
+
}
|
|
94
|
+
function isScrollAreaScrollbarVisible({ active, axis, draggingAxis, focusWithin, hovered, scrolling, type }) {
|
|
95
|
+
if (!active) return false;
|
|
96
|
+
switch (type) {
|
|
97
|
+
case "always":
|
|
98
|
+
case "auto": return true;
|
|
99
|
+
case "hover": return hovered || focusWithin || draggingAxis === axis;
|
|
100
|
+
case "scroll": return scrolling || draggingAxis === axis;
|
|
101
|
+
default: return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function getScrollAreaAxisPosition(metrics, axis) {
|
|
105
|
+
return axis === "x" ? metrics.x : metrics.y;
|
|
106
|
+
}
|
|
107
|
+
function getScrollAreaMaxPosition(metrics, axis) {
|
|
108
|
+
return axis === "x" ? Math.max(0, metrics.scrollWidth - metrics.clientWidth) : Math.max(0, metrics.scrollHeight - metrics.clientHeight);
|
|
109
|
+
}
|
|
110
|
+
function getScrollAreaOverflow(metrics, axis) {
|
|
111
|
+
return axis === "x" ? metrics.overflowX : metrics.overflowY;
|
|
112
|
+
}
|
|
113
|
+
function getScrollAreaAxisState(metrics, axis) {
|
|
114
|
+
return {
|
|
115
|
+
direction: metrics.direction,
|
|
116
|
+
maxPosition: getScrollAreaMaxPosition(metrics, axis),
|
|
117
|
+
overflow: getScrollAreaOverflow(metrics, axis),
|
|
118
|
+
position: getScrollAreaAxisPosition(metrics, axis)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function getReachedScrollAreaBoundaries(position, previousPosition, metrics) {
|
|
122
|
+
const boundaries = [];
|
|
123
|
+
appendVerticalBoundaries(boundaries, position, previousPosition, metrics);
|
|
124
|
+
appendHorizontalBoundaries(boundaries, position, previousPosition, metrics);
|
|
125
|
+
return boundaries;
|
|
126
|
+
}
|
|
127
|
+
function appendVerticalBoundaries(boundaries, position, previousPosition, metrics) {
|
|
128
|
+
if (!metrics.overflowY) return;
|
|
129
|
+
const maxPosition = getScrollAreaMaxPosition(metrics, "y");
|
|
130
|
+
if (position.y <= boundaryTolerance && previousPosition.y > boundaryTolerance) boundaries.push("top");
|
|
131
|
+
if (position.y >= maxPosition - boundaryTolerance && previousPosition.y < maxPosition - boundaryTolerance) boundaries.push("bottom");
|
|
132
|
+
}
|
|
133
|
+
function appendHorizontalBoundaries(boundaries, position, previousPosition, metrics) {
|
|
134
|
+
if (!metrics.overflowX) return;
|
|
135
|
+
const maxPosition = getScrollAreaMaxPosition(metrics, "x");
|
|
136
|
+
const reachedStart = position.x <= boundaryTolerance && previousPosition.x > boundaryTolerance;
|
|
137
|
+
const reachedEnd = position.x >= maxPosition - boundaryTolerance && previousPosition.x < maxPosition - boundaryTolerance;
|
|
138
|
+
if (reachedStart) boundaries.push(metrics.direction === "rtl" ? "right" : "left");
|
|
139
|
+
if (reachedEnd) boundaries.push(metrics.direction === "rtl" ? "left" : "right");
|
|
140
|
+
}
|
|
141
|
+
function getScrollAreaTrackPosition({ axis, coordinate, direction, maxPosition, thumbSize, trackSize, trackStart }) {
|
|
142
|
+
const travel = Math.max(0, trackSize - thumbSize);
|
|
143
|
+
if (travel === 0) return void 0;
|
|
144
|
+
const physicalRatio = clamp((coordinate - trackStart - thumbSize / 2) / travel, 0, 1);
|
|
145
|
+
return (axis === "x" && direction === "rtl" ? 1 - physicalRatio : physicalRatio) * maxPosition;
|
|
146
|
+
}
|
|
147
|
+
function getScrollAreaDragPosition({ coordinate, coordinateDirection, maxPosition, startCoordinate, startPosition, travel }) {
|
|
148
|
+
if (travel <= 0) return startPosition;
|
|
149
|
+
return startPosition + coordinateDirection * (coordinate - startCoordinate) * maxPosition / travel;
|
|
150
|
+
}
|
|
151
|
+
function getScrollAreaRootStyle(scrollbarSize) {
|
|
152
|
+
const length = toPositiveCssLength(scrollbarSize);
|
|
153
|
+
return length ? { "--_rp-scroll-area-scrollbar-size": length } : {};
|
|
154
|
+
}
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/components/scroll-area/useScrollAreaAttributes.ts
|
|
157
|
+
function useScrollAreaAttributes({ metrics, onViewportScroll, props, rootHandlers, state, viewport }) {
|
|
158
|
+
const generatedId = useId();
|
|
159
|
+
const viewportId = computed(() => `${props.id || generatedId}-viewport`);
|
|
160
|
+
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
161
|
+
const rootAttrs = computed(() => getRootAttrs({
|
|
162
|
+
id: props.id,
|
|
163
|
+
class: "rp-scroll-area",
|
|
164
|
+
style: getScrollAreaRootStyle(props.scrollbarSize),
|
|
165
|
+
"data-type": props.type,
|
|
166
|
+
"data-direction": metrics.direction,
|
|
167
|
+
"data-scrollbars": props.scrollbars === false ? "none" : props.scrollbars,
|
|
168
|
+
"data-overflow-x": toPresenceAttribute(metrics.overflowX),
|
|
169
|
+
"data-overflow-y": toPresenceAttribute(metrics.overflowY),
|
|
170
|
+
"data-scrollbar-x-active": toPresenceAttribute(state.horizontalActive.value),
|
|
171
|
+
"data-scrollbar-y-active": toPresenceAttribute(state.verticalActive.value),
|
|
172
|
+
"data-scrollbar-x-visible": toPresenceAttribute(state.horizontalVisible.value),
|
|
173
|
+
"data-scrollbar-y-visible": toPresenceAttribute(state.verticalVisible.value),
|
|
174
|
+
...rootHandlers
|
|
175
|
+
}));
|
|
176
|
+
const viewportAttrs = computed(() => {
|
|
177
|
+
const compatibilityAttrs = props.viewportAttrs ?? {};
|
|
178
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(compatibilityAttrs);
|
|
179
|
+
return {
|
|
180
|
+
...forwardedAttributes,
|
|
181
|
+
...getPartAttrs("viewport", {
|
|
182
|
+
class: "rp-scroll-area__viewport",
|
|
183
|
+
compatibilityClass,
|
|
184
|
+
compatibilityStyle
|
|
185
|
+
}),
|
|
186
|
+
id: viewportId.value,
|
|
187
|
+
role: forwardedAttributes.role ?? (hasAccessibleName(props, forwardedAttributes) ? "region" : void 0),
|
|
188
|
+
tabindex: forwardedAttributes.tabindex ?? 0,
|
|
189
|
+
"aria-label": props.ariaLabel || forwardedAttributes["aria-label"] || void 0,
|
|
190
|
+
"aria-labelledby": props.ariaLabelledby || forwardedAttributes["aria-labelledby"] || void 0,
|
|
191
|
+
"aria-describedby": props.ariaDescribedby || forwardedAttributes["aria-describedby"] || void 0,
|
|
192
|
+
onScroll: composeEventHandlers(onViewportScroll, compatibilityAttrs.onScroll)
|
|
193
|
+
};
|
|
228
194
|
});
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
195
|
+
const contentAttrs = computed(() => {
|
|
196
|
+
const { compatibilityClass, compatibilityStyle, forwardedAttributes } = splitCompatibilityAttributes(props.contentAttrs ?? {});
|
|
197
|
+
return {
|
|
198
|
+
...forwardedAttributes,
|
|
199
|
+
...getPartAttrs("content", {
|
|
200
|
+
class: "rp-scroll-area__content",
|
|
201
|
+
compatibilityClass,
|
|
202
|
+
compatibilityStyle
|
|
203
|
+
})
|
|
204
|
+
};
|
|
205
|
+
});
|
|
206
|
+
const horizontalScrollbarAttrs = computed(() => getScrollbarAttrs("x"));
|
|
207
|
+
const verticalScrollbarAttrs = computed(() => getScrollbarAttrs("y"));
|
|
208
|
+
const horizontalThumbAttrs = computed(() => getThumbAttrs("x"));
|
|
209
|
+
const verticalThumbAttrs = computed(() => getThumbAttrs("y"));
|
|
210
|
+
const cornerAttrs = computed(() => ({
|
|
211
|
+
...getPartAttrs("corner", { class: "rp-scroll-area__corner" }),
|
|
212
|
+
"aria-hidden": true,
|
|
213
|
+
"data-direction": metrics.direction,
|
|
214
|
+
"data-visible": toPresenceAttribute(state.horizontalActive.value && state.verticalActive.value)
|
|
232
215
|
}));
|
|
216
|
+
function getScrollbarAttrs(axis) {
|
|
217
|
+
const vertical = axis === "y";
|
|
218
|
+
const active = vertical ? state.verticalActive.value : state.horizontalActive.value;
|
|
219
|
+
const visible = vertical ? state.verticalVisible.value : state.horizontalVisible.value;
|
|
220
|
+
return {
|
|
221
|
+
...getPartAttrs("scrollbar", { class: ["rp-scroll-area__scrollbar", `rp-scroll-area__scrollbar--${vertical ? "vertical" : "horizontal"}`] }),
|
|
222
|
+
role: "scrollbar",
|
|
223
|
+
tabindex: !props.embedded && active ? 0 : -1,
|
|
224
|
+
"aria-controls": viewport.value?.id || void 0,
|
|
225
|
+
"aria-orientation": vertical ? "vertical" : "horizontal",
|
|
226
|
+
"aria-valuemin": 0,
|
|
227
|
+
"aria-valuemax": getScrollAreaMaxPosition(metrics, axis),
|
|
228
|
+
"aria-valuenow": Math.round(getScrollAreaAxisPosition(metrics, axis)),
|
|
229
|
+
"aria-disabled": !getScrollAreaOverflow(metrics, axis) || void 0,
|
|
230
|
+
"aria-hidden": props.embedded || !active || void 0,
|
|
231
|
+
"data-orientation": vertical ? "vertical" : "horizontal",
|
|
232
|
+
"data-direction": metrics.direction,
|
|
233
|
+
"data-active": toPresenceAttribute(active),
|
|
234
|
+
"data-visible": toPresenceAttribute(visible)
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function getThumbAttrs(axis) {
|
|
238
|
+
const horizontal = axis === "x";
|
|
239
|
+
return getPartAttrs("thumb", {
|
|
240
|
+
class: "rp-scroll-area__thumb",
|
|
241
|
+
style: {
|
|
242
|
+
"--_rp-scroll-area-thumb-size": `${horizontal ? metrics.horizontalThumbSize : metrics.verticalThumbSize}%`,
|
|
243
|
+
"--_rp-scroll-area-thumb-offset": `${horizontal ? metrics.horizontalThumbOffset : metrics.verticalThumbOffset}%`
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
contentAttrs,
|
|
249
|
+
cornerAttrs,
|
|
250
|
+
horizontalScrollbarAttrs,
|
|
251
|
+
horizontalThumbAttrs,
|
|
252
|
+
rootAttrs,
|
|
253
|
+
verticalScrollbarAttrs,
|
|
254
|
+
verticalThumbAttrs,
|
|
255
|
+
viewportAttrs
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function hasAccessibleName(props, attrs) {
|
|
259
|
+
return Boolean(props.ariaLabel || props.ariaLabelledby || attrs["aria-label"] || attrs["aria-labelledby"]);
|
|
260
|
+
}
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/components/scroll-area/useScrollAreaDerivedState.ts
|
|
263
|
+
function useScrollAreaDerivedState(props, metrics) {
|
|
264
|
+
const renderHorizontalScrollbar = computed(() => isScrollAreaAxisEnabled(props.scrollbars, "x") && props.type !== "never");
|
|
265
|
+
const renderVerticalScrollbar = computed(() => isScrollAreaAxisEnabled(props.scrollbars, "y") && props.type !== "never");
|
|
266
|
+
return {
|
|
267
|
+
horizontalScrollbarActive: computed(() => isScrollAreaScrollbarActive(props.type ?? "hover", isScrollAreaAxisEnabled(props.scrollbars, "x"), metrics.overflowX)),
|
|
268
|
+
renderHorizontalScrollbar,
|
|
269
|
+
renderVerticalScrollbar,
|
|
270
|
+
verticalScrollbarActive: computed(() => isScrollAreaScrollbarActive(props.type ?? "hover", isScrollAreaAxisEnabled(props.scrollbars, "y"), metrics.overflowY))
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/components/scroll-area/useScrollAreaMeasurement.ts
|
|
275
|
+
function useScrollAreaMeasurement({ elements, isAxisEnabled, minimumThumbSize }) {
|
|
276
|
+
const metrics = reactive(createScrollAreaMetrics());
|
|
233
277
|
let resizeObserver;
|
|
234
|
-
let
|
|
278
|
+
let contentObserver;
|
|
235
279
|
let directionObserver;
|
|
280
|
+
let observerView;
|
|
236
281
|
let horizontalThumbSizeRatio = 1;
|
|
237
282
|
let verticalThumbSizeRatio = 1;
|
|
238
|
-
const
|
|
239
|
-
const positionScheduler = createRafScheduler(updatePosition, () =>
|
|
283
|
+
const updateScheduler = createRafScheduler(update, () => elements.viewport.value?.ownerDocument.defaultView);
|
|
284
|
+
const positionScheduler = createRafScheduler(updatePosition, () => elements.viewport.value?.ownerDocument.defaultView);
|
|
240
285
|
function update() {
|
|
241
|
-
const viewport =
|
|
286
|
+
const viewport = elements.viewport.value;
|
|
242
287
|
if (!viewport) return;
|
|
243
288
|
readViewportGeometry(viewport);
|
|
244
289
|
updateThumbGeometry(viewport);
|
|
@@ -249,46 +294,38 @@ function useScrollAreaMetrics(options) {
|
|
|
249
294
|
metrics.clientHeight = viewport.clientHeight;
|
|
250
295
|
metrics.scrollWidth = viewport.scrollWidth;
|
|
251
296
|
metrics.scrollHeight = viewport.scrollHeight;
|
|
252
|
-
metrics.overflowX =
|
|
253
|
-
metrics.overflowY =
|
|
297
|
+
metrics.overflowX = isAxisEnabled("x") && viewport.scrollWidth > viewport.clientWidth + 1;
|
|
298
|
+
metrics.overflowY = isAxisEnabled("y") && viewport.scrollHeight > viewport.clientHeight + 1;
|
|
254
299
|
}
|
|
255
300
|
function updateThumbGeometry(viewport) {
|
|
256
|
-
const horizontalGeometry =
|
|
257
|
-
const verticalGeometry =
|
|
301
|
+
const horizontalGeometry = getScrollThumbGeometry(elements.horizontalScrollbar.value?.clientWidth ?? viewport.clientWidth, viewport.clientWidth, viewport.scrollWidth, minimumThumbSize);
|
|
302
|
+
const verticalGeometry = getScrollThumbGeometry(elements.verticalScrollbar.value?.clientHeight ?? viewport.clientHeight, viewport.clientHeight, viewport.scrollHeight, minimumThumbSize);
|
|
258
303
|
metrics.horizontalThumbSize = horizontalGeometry.size;
|
|
259
304
|
horizontalThumbSizeRatio = horizontalGeometry.offsetRatio;
|
|
260
305
|
metrics.verticalThumbSize = verticalGeometry.size;
|
|
261
306
|
verticalThumbSizeRatio = verticalGeometry.offsetRatio;
|
|
262
307
|
}
|
|
263
|
-
function updatePosition(viewport =
|
|
308
|
+
function updatePosition(viewport = elements.viewport.value) {
|
|
264
309
|
if (!viewport) return;
|
|
265
310
|
metrics.direction = getScrollDirection(viewport);
|
|
266
|
-
metrics.x =
|
|
267
|
-
metrics.y = clamp(viewport.scrollTop, 0,
|
|
268
|
-
metrics.horizontalThumbOffset =
|
|
269
|
-
metrics.verticalThumbOffset =
|
|
270
|
-
}
|
|
271
|
-
function getPosition(axis) {
|
|
272
|
-
return axis === "x" ? metrics.x : metrics.y;
|
|
273
|
-
}
|
|
274
|
-
function getMaxPosition(axis) {
|
|
275
|
-
return axis === "x" ? Math.max(0, metrics.scrollWidth - metrics.clientWidth) : Math.max(0, metrics.scrollHeight - metrics.clientHeight);
|
|
276
|
-
}
|
|
277
|
-
function getOverflow(axis) {
|
|
278
|
-
return axis === "x" ? metrics.overflowX : metrics.overflowY;
|
|
311
|
+
metrics.x = getLogicalHorizontalScrollPosition(viewport.scrollLeft, getScrollAreaMaxPosition(metrics, "x"), metrics.direction);
|
|
312
|
+
metrics.y = clamp(viewport.scrollTop, 0, getScrollAreaMaxPosition(metrics, "y"));
|
|
313
|
+
metrics.horizontalThumbOffset = getScrollThumbOffset(metrics.x, getScrollAreaMaxPosition(metrics, "x"), horizontalThumbSizeRatio);
|
|
314
|
+
metrics.verticalThumbOffset = getScrollThumbOffset(metrics.y, getScrollAreaMaxPosition(metrics, "y"), verticalThumbSizeRatio);
|
|
279
315
|
}
|
|
280
316
|
function attachObservers() {
|
|
281
|
-
const viewport =
|
|
317
|
+
const viewport = elements.viewport.value;
|
|
282
318
|
if (!viewport) return;
|
|
283
|
-
|
|
284
|
-
const ResizeObserverConstructor =
|
|
319
|
+
observerView = viewport.ownerDocument.defaultView;
|
|
320
|
+
const ResizeObserverConstructor = observerView?.ResizeObserver ?? globalThis.ResizeObserver;
|
|
285
321
|
if (ResizeObserverConstructor) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
322
|
+
const observer = new ResizeObserverConstructor(updateScheduler.schedule);
|
|
323
|
+
observer.observe(viewport);
|
|
324
|
+
if (elements.content.value) observer.observe(elements.content.value);
|
|
325
|
+
resizeObserver = observer;
|
|
326
|
+
} else attachContentObserver(observerView);
|
|
327
|
+
attachDirectionObserver(observerView, viewport);
|
|
328
|
+
observerView?.addEventListener("resize", updateScheduler.schedule);
|
|
292
329
|
}
|
|
293
330
|
function attachDirectionObserver(view, viewport) {
|
|
294
331
|
const MutationObserverConstructor = view?.MutationObserver ?? globalThis.MutationObserver;
|
|
@@ -307,13 +344,12 @@ function useScrollAreaMetrics(options) {
|
|
|
307
344
|
element = element.parentElement;
|
|
308
345
|
}
|
|
309
346
|
}
|
|
310
|
-
function
|
|
347
|
+
function attachContentObserver(view) {
|
|
311
348
|
const MutationObserverConstructor = view?.MutationObserver ?? globalThis.MutationObserver;
|
|
312
|
-
const content =
|
|
349
|
+
const content = elements.content.value;
|
|
313
350
|
if (!MutationObserverConstructor || !content) return;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
observer.observe(content, {
|
|
351
|
+
contentObserver = new MutationObserverConstructor(updateScheduler.schedule);
|
|
352
|
+
contentObserver.observe(content, {
|
|
317
353
|
attributes: true,
|
|
318
354
|
childList: true,
|
|
319
355
|
characterData: true,
|
|
@@ -321,376 +357,336 @@ function useScrollAreaMetrics(options) {
|
|
|
321
357
|
});
|
|
322
358
|
}
|
|
323
359
|
function detachObservers() {
|
|
324
|
-
const view = options.viewportRef.value?.ownerDocument.defaultView;
|
|
325
360
|
resizeObserver?.disconnect();
|
|
326
|
-
|
|
361
|
+
contentObserver?.disconnect();
|
|
327
362
|
directionObserver?.disconnect();
|
|
328
363
|
resizeObserver = void 0;
|
|
329
|
-
|
|
364
|
+
contentObserver = void 0;
|
|
330
365
|
directionObserver = void 0;
|
|
331
|
-
|
|
366
|
+
observerView?.removeEventListener("resize", updateScheduler.schedule);
|
|
367
|
+
observerView = void 0;
|
|
332
368
|
}
|
|
333
369
|
onMounted(() => {
|
|
334
370
|
attachObservers();
|
|
335
|
-
nextTick(
|
|
371
|
+
nextTick(updateScheduler.schedule);
|
|
336
372
|
});
|
|
337
373
|
onBeforeUnmount(() => {
|
|
338
374
|
detachObservers();
|
|
339
|
-
|
|
375
|
+
updateScheduler.cancel();
|
|
340
376
|
positionScheduler.cancel();
|
|
341
377
|
});
|
|
342
378
|
return {
|
|
343
379
|
metrics,
|
|
344
|
-
position,
|
|
345
|
-
update,
|
|
346
|
-
updatePosition,
|
|
347
|
-
scheduleUpdate: scheduler.schedule,
|
|
348
380
|
schedulePositionUpdate: positionScheduler.schedule,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
381
|
+
scheduleUpdate: updateScheduler.schedule,
|
|
382
|
+
update,
|
|
383
|
+
updatePosition
|
|
352
384
|
};
|
|
353
385
|
}
|
|
354
386
|
//#endregion
|
|
355
387
|
//#region src/components/scroll-area/useScrollAreaPointer.ts
|
|
356
388
|
function useScrollAreaPointer(options) {
|
|
357
|
-
let dragSession;
|
|
358
389
|
function onScrollbarPointerdown(axis, event) {
|
|
359
390
|
if (event.target !== event.currentTarget || event.button !== 0) return;
|
|
360
|
-
|
|
361
|
-
|
|
391
|
+
const state = options.refreshAxis(axis);
|
|
392
|
+
if (!state.overflow) return;
|
|
362
393
|
const scrollbar = event.currentTarget;
|
|
363
394
|
const thumb = scrollbar.firstElementChild;
|
|
364
395
|
const trackRect = scrollbar.getBoundingClientRect();
|
|
365
396
|
const thumbRect = thumb?.getBoundingClientRect();
|
|
366
|
-
const
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
397
|
+
const horizontal = axis === "x";
|
|
398
|
+
const position = getScrollAreaTrackPosition({
|
|
399
|
+
axis,
|
|
400
|
+
coordinate: getPointerAxisCoordinate(axis, event),
|
|
401
|
+
direction: state.direction,
|
|
402
|
+
maxPosition: state.maxPosition,
|
|
403
|
+
thumbSize: thumbRect ? horizontal ? thumbRect.width : thumbRect.height : 0,
|
|
404
|
+
trackSize: horizontal ? trackRect.width : trackRect.height,
|
|
405
|
+
trackStart: horizontal ? trackRect.left : trackRect.top
|
|
406
|
+
});
|
|
407
|
+
if (position === void 0) return;
|
|
372
408
|
event.preventDefault();
|
|
373
|
-
|
|
374
|
-
const logicalRatio = axis === "x" && options.metrics.metrics.direction === "rtl" ? 1 - physicalRatio : physicalRatio;
|
|
375
|
-
options.controls.writeAxisPosition(axis, logicalRatio * options.metrics.getMaxPosition(axis));
|
|
409
|
+
options.writeAxisPosition(axis, position);
|
|
376
410
|
}
|
|
377
411
|
function onThumbPointerdown(axis, event) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
travel,
|
|
405
|
-
coordinateDirection: axis === "x" && options.metrics.metrics.direction === "rtl" ? -1 : 1,
|
|
406
|
-
view
|
|
407
|
-
};
|
|
408
|
-
options.setDraggingAxis(axis);
|
|
409
|
-
view?.addEventListener("pointermove", onPointermove);
|
|
410
|
-
view?.addEventListener("pointerup", onPointerend);
|
|
411
|
-
view?.addEventListener("pointercancel", onPointerend);
|
|
412
|
-
}
|
|
413
|
-
function onPointermove(event) {
|
|
414
|
-
const session = dragSession;
|
|
415
|
-
if (!session || !isCurrentPointer(event, session)) return;
|
|
416
|
-
const delta = getPointerCoordinate(session.axis, event) - session.startCoordinate;
|
|
417
|
-
options.controls.writeAxisPosition(session.axis, session.startPosition + session.coordinateDirection * delta * session.maxPosition / session.travel);
|
|
418
|
-
}
|
|
419
|
-
function onPointerend(event) {
|
|
420
|
-
if (!dragSession || !isCurrentPointer(event, dragSession)) return;
|
|
421
|
-
stopDragging();
|
|
422
|
-
}
|
|
423
|
-
function stopDragging() {
|
|
424
|
-
const view = dragSession?.view;
|
|
425
|
-
view?.removeEventListener("pointermove", onPointermove);
|
|
426
|
-
view?.removeEventListener("pointerup", onPointerend);
|
|
427
|
-
view?.removeEventListener("pointercancel", onPointerend);
|
|
428
|
-
dragSession = void 0;
|
|
429
|
-
options.setDraggingAxis(null);
|
|
412
|
+
return pointerSession.start(event, () => {
|
|
413
|
+
const state = options.refreshAxis(axis);
|
|
414
|
+
if (!state.overflow) return;
|
|
415
|
+
const scrollbar = getScrollbar(axis);
|
|
416
|
+
const thumb = event.currentTarget;
|
|
417
|
+
if (!scrollbar) return;
|
|
418
|
+
const trackRect = scrollbar.getBoundingClientRect();
|
|
419
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
420
|
+
const horizontal = axis === "x";
|
|
421
|
+
const trackSize = horizontal ? trackRect.width : trackRect.height;
|
|
422
|
+
const thumbSize = horizontal ? thumbRect.width : thumbRect.height;
|
|
423
|
+
const travel = Math.max(0, trackSize - thumbSize);
|
|
424
|
+
if (travel === 0) return;
|
|
425
|
+
return {
|
|
426
|
+
state: {
|
|
427
|
+
axis,
|
|
428
|
+
coordinateDirection: axis === "x" && state.direction === "rtl" ? -1 : 1,
|
|
429
|
+
maxPosition: state.maxPosition,
|
|
430
|
+
scrollbar,
|
|
431
|
+
startCoordinate: getPointerAxisCoordinate(axis, event),
|
|
432
|
+
startPosition: state.position,
|
|
433
|
+
travel
|
|
434
|
+
},
|
|
435
|
+
target: scrollbar
|
|
436
|
+
};
|
|
437
|
+
});
|
|
430
438
|
}
|
|
431
439
|
function getScrollbar(axis) {
|
|
432
|
-
return axis === "x" ? options.
|
|
433
|
-
}
|
|
434
|
-
|
|
440
|
+
return axis === "x" ? options.elements.horizontalScrollbar.value : options.elements.verticalScrollbar.value;
|
|
441
|
+
}
|
|
442
|
+
const pointerSession = createPointerSession({
|
|
443
|
+
endUpdate: "none",
|
|
444
|
+
onStart(event, session) {
|
|
445
|
+
event.preventDefault();
|
|
446
|
+
if (!options.isEmbedded()) session.scrollbar.focus({ preventScroll: true });
|
|
447
|
+
options.setDraggingAxis(session.axis);
|
|
448
|
+
},
|
|
449
|
+
onStop() {
|
|
450
|
+
options.setDraggingAxis(null);
|
|
451
|
+
},
|
|
452
|
+
onUpdate(event, session) {
|
|
453
|
+
options.writeAxisPosition(session.axis, getScrollAreaDragPosition({
|
|
454
|
+
coordinate: getPointerAxisCoordinate(session.axis, event),
|
|
455
|
+
coordinateDirection: session.coordinateDirection,
|
|
456
|
+
maxPosition: session.maxPosition,
|
|
457
|
+
startCoordinate: session.startCoordinate,
|
|
458
|
+
startPosition: session.startPosition,
|
|
459
|
+
travel: session.travel
|
|
460
|
+
}));
|
|
461
|
+
},
|
|
462
|
+
updateMode: "immediate"
|
|
463
|
+
});
|
|
464
|
+
onBeforeUnmount(pointerSession.stop);
|
|
435
465
|
return {
|
|
436
466
|
onScrollbarPointerdown,
|
|
437
467
|
onThumbPointerdown
|
|
438
468
|
};
|
|
439
469
|
}
|
|
440
|
-
function getPointerCoordinate(axis, event) {
|
|
441
|
-
return axis === "x" ? event.clientX : event.clientY;
|
|
442
|
-
}
|
|
443
|
-
function isCurrentPointer(event, session) {
|
|
444
|
-
return session.pointerId === void 0 || event.pointerId === session.pointerId;
|
|
445
|
-
}
|
|
446
470
|
//#endregion
|
|
447
471
|
//#region src/components/scroll-area/useScrollAreaVisibility.ts
|
|
448
472
|
function useScrollAreaVisibility(options) {
|
|
449
|
-
const
|
|
450
|
-
const
|
|
451
|
-
const
|
|
473
|
+
const hovered = ref(false);
|
|
474
|
+
const focusWithin = ref(false);
|
|
475
|
+
const scrolling = ref(false);
|
|
452
476
|
const draggingAxis = ref(null);
|
|
453
477
|
let scrollEndTimer;
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
478
|
+
const horizontalVisible = computed(() => isVisible("x"));
|
|
479
|
+
const verticalVisible = computed(() => isVisible("y"));
|
|
480
|
+
const rootHandlers = {
|
|
481
|
+
onPointerenter() {
|
|
482
|
+
hovered.value = true;
|
|
483
|
+
},
|
|
484
|
+
onPointerleave() {
|
|
485
|
+
hovered.value = false;
|
|
486
|
+
},
|
|
487
|
+
onFocusin() {
|
|
488
|
+
focusWithin.value = true;
|
|
489
|
+
},
|
|
490
|
+
onFocusout(event) {
|
|
491
|
+
if (isNodeWithinElement(event.relatedTarget, options.root.value)) return;
|
|
492
|
+
focusWithin.value = false;
|
|
468
493
|
}
|
|
494
|
+
};
|
|
495
|
+
function isVisible(axis) {
|
|
496
|
+
return isScrollAreaScrollbarVisible({
|
|
497
|
+
active: options.isScrollbarActive(axis),
|
|
498
|
+
axis,
|
|
499
|
+
draggingAxis: draggingAxis.value,
|
|
500
|
+
focusWithin: focusWithin.value,
|
|
501
|
+
hovered: hovered.value,
|
|
502
|
+
scrolling: scrolling.value,
|
|
503
|
+
type: options.getType()
|
|
504
|
+
});
|
|
469
505
|
}
|
|
470
506
|
function showDuringScroll() {
|
|
471
|
-
|
|
472
|
-
|
|
507
|
+
scrolling.value = true;
|
|
508
|
+
clearScrollEndTimer();
|
|
473
509
|
scrollEndTimer = setTimeout(() => {
|
|
474
|
-
|
|
510
|
+
scrolling.value = false;
|
|
475
511
|
scrollEndTimer = void 0;
|
|
476
|
-
}, normalizeDelay(options.
|
|
512
|
+
}, normalizeDelay(options.getHideDelay()));
|
|
513
|
+
}
|
|
514
|
+
function clearScrollEndTimer() {
|
|
515
|
+
if (scrollEndTimer === void 0) return;
|
|
516
|
+
clearTimeout(scrollEndTimer);
|
|
517
|
+
scrollEndTimer = void 0;
|
|
477
518
|
}
|
|
478
519
|
function setDraggingAxis(axis) {
|
|
479
520
|
draggingAxis.value = axis;
|
|
480
521
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
function onPointerleave() {
|
|
485
|
-
isHovered.value = false;
|
|
486
|
-
}
|
|
487
|
-
function onFocusin() {
|
|
488
|
-
hasFocusWithin.value = true;
|
|
489
|
-
}
|
|
490
|
-
function onFocusout(event) {
|
|
491
|
-
const nextTarget = event.relatedTarget;
|
|
492
|
-
if (nextTarget instanceof Node && options.rootRef.value?.contains(nextTarget)) return;
|
|
493
|
-
hasFocusWithin.value = false;
|
|
494
|
-
}
|
|
495
|
-
function resetScrollEndTimer() {
|
|
496
|
-
if (scrollEndTimer !== void 0) clearTimeout(scrollEndTimer);
|
|
497
|
-
}
|
|
498
|
-
watch(() => options.props.scrollHideDelay, () => {
|
|
499
|
-
if (isScrolling.value) showDuringScroll();
|
|
522
|
+
watch(options.getHideDelay, () => {
|
|
523
|
+
if (scrolling.value) showDuringScroll();
|
|
500
524
|
});
|
|
501
|
-
onBeforeUnmount(
|
|
525
|
+
onBeforeUnmount(clearScrollEndTimer);
|
|
502
526
|
return {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
horizontalScrollbarActive,
|
|
506
|
-
verticalScrollbarActive,
|
|
507
|
-
horizontalScrollbarVisible,
|
|
508
|
-
verticalScrollbarVisible,
|
|
509
|
-
showDuringScroll,
|
|
527
|
+
horizontalVisible,
|
|
528
|
+
rootHandlers,
|
|
510
529
|
setDraggingAxis,
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
onFocusin,
|
|
514
|
-
onFocusout
|
|
530
|
+
showDuringScroll,
|
|
531
|
+
verticalVisible
|
|
515
532
|
};
|
|
516
533
|
}
|
|
517
|
-
function normalizeDelay(delay) {
|
|
518
|
-
return Number.isFinite(delay) ? Math.max(0, delay ?? 0) : 0;
|
|
519
|
-
}
|
|
520
534
|
//#endregion
|
|
521
535
|
//#region src/components/scroll-area/useScrollArea.ts
|
|
522
|
-
|
|
536
|
+
var minimumThumbSize = 18;
|
|
537
|
+
var keyboardScrollStep = 40;
|
|
538
|
+
function useScrollArea(props, emit) {
|
|
523
539
|
const rootRef = ref(null);
|
|
524
540
|
const viewportRef = ref(null);
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
verticalEnabled
|
|
541
|
+
const templateRefs = {
|
|
542
|
+
root: rootRef,
|
|
543
|
+
viewport: viewportRef,
|
|
544
|
+
content: ref(null),
|
|
545
|
+
horizontalScrollbar: ref(null),
|
|
546
|
+
verticalScrollbar: ref(null)
|
|
547
|
+
};
|
|
548
|
+
const { metrics, schedulePositionUpdate, scheduleUpdate, update, updatePosition } = useScrollAreaMeasurement({
|
|
549
|
+
elements: templateRefs,
|
|
550
|
+
isAxisEnabled: (axis) => isScrollAreaAxisEnabled(props.scrollbars, axis),
|
|
551
|
+
minimumThumbSize
|
|
537
552
|
});
|
|
553
|
+
const { horizontalScrollbarActive, renderHorizontalScrollbar, renderVerticalScrollbar, verticalScrollbarActive } = useScrollAreaDerivedState(props, metrics);
|
|
538
554
|
const visibility = useScrollAreaVisibility({
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
overflowX: () => measurements.metrics.overflowX,
|
|
544
|
-
overflowY: () => measurements.metrics.overflowY
|
|
545
|
-
});
|
|
546
|
-
const controls = useScrollAreaControls({
|
|
547
|
-
viewportRef,
|
|
548
|
-
metrics: measurements,
|
|
549
|
-
showDuringScroll: visibility.showDuringScroll,
|
|
550
|
-
emitScroll: options.emitScroll,
|
|
551
|
-
emitPositionChange: options.emitPositionChange,
|
|
552
|
-
emitReachTop: options.emitReachTop,
|
|
553
|
-
emitReachBottom: options.emitReachBottom,
|
|
554
|
-
emitReachLeft: options.emitReachLeft,
|
|
555
|
-
emitReachRight: options.emitReachRight
|
|
555
|
+
getHideDelay: () => props.scrollHideDelay,
|
|
556
|
+
getType: () => props.type ?? "hover",
|
|
557
|
+
isScrollbarActive: (axis) => axis === "x" ? horizontalScrollbarActive.value : verticalScrollbarActive.value,
|
|
558
|
+
root: rootRef
|
|
556
559
|
});
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
controls,
|
|
560
|
+
const { onScrollbarPointerdown, onThumbPointerdown } = useScrollAreaPointer({
|
|
561
|
+
elements: templateRefs,
|
|
562
|
+
isEmbedded: () => Boolean(props.embedded),
|
|
563
|
+
refreshAxis,
|
|
562
564
|
setDraggingAxis: visibility.setDraggingAxis,
|
|
563
|
-
|
|
565
|
+
writeAxisPosition
|
|
564
566
|
});
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
visibility.renderHorizontalScrollbar,
|
|
569
|
-
visibility.renderVerticalScrollbar
|
|
570
|
-
], () => void nextTick(measurements.scheduleUpdate));
|
|
571
|
-
return {
|
|
572
|
-
rootRef,
|
|
573
|
-
viewportRef,
|
|
574
|
-
contentRef,
|
|
575
|
-
horizontalScrollbarRef,
|
|
576
|
-
verticalScrollbarRef,
|
|
577
|
-
metrics: measurements.metrics,
|
|
578
|
-
position: measurements.position,
|
|
579
|
-
update: measurements.update,
|
|
580
|
-
getPosition: measurements.getPosition,
|
|
581
|
-
getMaxPosition: measurements.getMaxPosition,
|
|
582
|
-
getOverflow: measurements.getOverflow,
|
|
583
|
-
...visibility,
|
|
584
|
-
...controls,
|
|
585
|
-
...pointer
|
|
567
|
+
let previousPosition = {
|
|
568
|
+
x: 0,
|
|
569
|
+
y: 0
|
|
586
570
|
};
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
"data-direction": scrollArea.metrics.direction,
|
|
600
|
-
"data-scrollbars": props.scrollbars === false ? "none" : props.scrollbars,
|
|
601
|
-
"data-overflow-x": presence(scrollArea.metrics.overflowX),
|
|
602
|
-
"data-overflow-y": presence(scrollArea.metrics.overflowY),
|
|
603
|
-
"data-scrollbar-x-active": presence(scrollArea.horizontalScrollbarActive.value),
|
|
604
|
-
"data-scrollbar-y-active": presence(scrollArea.verticalScrollbarActive.value),
|
|
605
|
-
"data-scrollbar-x-visible": presence(scrollArea.horizontalScrollbarVisible.value),
|
|
606
|
-
"data-scrollbar-y-visible": presence(scrollArea.verticalScrollbarVisible.value),
|
|
607
|
-
onPointerenter: scrollArea.onPointerenter,
|
|
608
|
-
onPointerleave: scrollArea.onPointerleave,
|
|
609
|
-
onFocusin: scrollArea.onFocusin,
|
|
610
|
-
onFocusout: scrollArea.onFocusout
|
|
611
|
-
}));
|
|
612
|
-
const viewportAttrs = computed(() => {
|
|
613
|
-
const { class: compatibilityClass, style: compatibilityStyle, onScroll: compatibilityOnScroll, ...attrs } = props.viewportAttrs ?? {};
|
|
614
|
-
return {
|
|
615
|
-
...attrs,
|
|
616
|
-
...getPartAttrs("viewport", {
|
|
617
|
-
class: "rp-scroll-area__viewport",
|
|
618
|
-
compatibilityClass,
|
|
619
|
-
compatibilityStyle
|
|
620
|
-
}),
|
|
621
|
-
id: viewportId.value,
|
|
622
|
-
role: attrs.role ?? (hasAccessibleName(props, attrs) ? "region" : void 0),
|
|
623
|
-
tabindex: attrs.tabindex ?? 0,
|
|
624
|
-
"aria-label": props.ariaLabel || attrs["aria-label"] || void 0,
|
|
625
|
-
"aria-labelledby": props.ariaLabelledby || attrs["aria-labelledby"] || void 0,
|
|
626
|
-
"aria-describedby": props.ariaDescribedby || attrs["aria-describedby"] || void 0,
|
|
627
|
-
onScroll(event) {
|
|
628
|
-
scrollArea.onViewportScroll(event);
|
|
629
|
-
compatibilityOnScroll?.(event);
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
});
|
|
633
|
-
const contentAttrs = computed(() => {
|
|
634
|
-
const { class: compatibilityClass, style: compatibilityStyle, ...attrs } = props.contentAttrs ?? {};
|
|
635
|
-
return {
|
|
636
|
-
...attrs,
|
|
637
|
-
...getPartAttrs("content", {
|
|
638
|
-
class: "rp-scroll-area__content",
|
|
639
|
-
compatibilityClass,
|
|
640
|
-
compatibilityStyle
|
|
641
|
-
})
|
|
642
|
-
};
|
|
571
|
+
const { contentAttrs, cornerAttrs, horizontalScrollbarAttrs, horizontalThumbAttrs, rootAttrs, verticalScrollbarAttrs, verticalThumbAttrs, viewportAttrs } = useScrollAreaAttributes({
|
|
572
|
+
metrics,
|
|
573
|
+
onViewportScroll,
|
|
574
|
+
props,
|
|
575
|
+
rootHandlers: visibility.rootHandlers,
|
|
576
|
+
state: {
|
|
577
|
+
horizontalActive: horizontalScrollbarActive,
|
|
578
|
+
horizontalVisible: visibility.horizontalVisible,
|
|
579
|
+
verticalActive: verticalScrollbarActive,
|
|
580
|
+
verticalVisible: visibility.verticalVisible
|
|
581
|
+
},
|
|
582
|
+
viewport: viewportRef
|
|
643
583
|
});
|
|
644
|
-
const horizontalScrollbarAttrs = computed(() => getScrollbarAttrs("x"));
|
|
645
|
-
const verticalScrollbarAttrs = computed(() => getScrollbarAttrs("y"));
|
|
646
|
-
const horizontalThumbAttrs = computed(() => getThumbAttrs("x"));
|
|
647
|
-
const verticalThumbAttrs = computed(() => getThumbAttrs("y"));
|
|
648
|
-
const cornerAttrs = computed(() => ({
|
|
649
|
-
...getPartAttrs("corner", { class: "rp-scroll-area__corner" }),
|
|
650
|
-
"aria-hidden": true,
|
|
651
|
-
"data-direction": scrollArea.metrics.direction,
|
|
652
|
-
"data-visible": presence(scrollArea.horizontalScrollbarActive.value && scrollArea.verticalScrollbarActive.value)
|
|
653
|
-
}));
|
|
654
584
|
const slotProps = computed(() => ({
|
|
655
|
-
position:
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
585
|
+
position: {
|
|
586
|
+
x: metrics.x,
|
|
587
|
+
y: metrics.y
|
|
588
|
+
},
|
|
589
|
+
overflowX: metrics.overflowX,
|
|
590
|
+
overflowY: metrics.overflowY,
|
|
591
|
+
scrollTo,
|
|
592
|
+
scrollBy,
|
|
593
|
+
update
|
|
661
594
|
}));
|
|
662
|
-
function
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
"aria-valuemin": 0,
|
|
673
|
-
"aria-valuemax": scrollArea.getMaxPosition(axis),
|
|
674
|
-
"aria-valuenow": Math.round(scrollArea.getPosition(axis)),
|
|
675
|
-
"aria-disabled": !scrollArea.getOverflow(axis) || void 0,
|
|
676
|
-
"aria-hidden": props.embedded || !active || void 0,
|
|
677
|
-
"data-orientation": vertical ? "vertical" : "horizontal",
|
|
678
|
-
"data-direction": scrollArea.metrics.direction,
|
|
679
|
-
"data-active": presence(active),
|
|
680
|
-
"data-visible": presence(visible)
|
|
595
|
+
function refreshAxis(axis) {
|
|
596
|
+
updatePosition();
|
|
597
|
+
return getScrollAreaAxisState(metrics, axis);
|
|
598
|
+
}
|
|
599
|
+
function onViewportScroll(event) {
|
|
600
|
+
updatePosition();
|
|
601
|
+
visibility.showDuringScroll();
|
|
602
|
+
const position = {
|
|
603
|
+
x: getScrollAreaAxisPosition(metrics, "x"),
|
|
604
|
+
y: getScrollAreaAxisPosition(metrics, "y")
|
|
681
605
|
};
|
|
606
|
+
const reachedBoundaries = getReachedScrollAreaBoundaries(position, previousPosition, metrics);
|
|
607
|
+
previousPosition = position;
|
|
608
|
+
emit("scroll", event);
|
|
609
|
+
emit("scrollPositionChange", {
|
|
610
|
+
x: metrics.x,
|
|
611
|
+
y: metrics.y
|
|
612
|
+
});
|
|
613
|
+
for (const boundary of reachedBoundaries) emitReachedBoundary(boundary, event);
|
|
682
614
|
}
|
|
683
|
-
function
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
"
|
|
690
|
-
|
|
615
|
+
function emitReachedBoundary(boundary, event) {
|
|
616
|
+
switch (boundary) {
|
|
617
|
+
case "top":
|
|
618
|
+
emit("reachTop", event);
|
|
619
|
+
break;
|
|
620
|
+
case "bottom":
|
|
621
|
+
emit("reachBottom", event);
|
|
622
|
+
break;
|
|
623
|
+
case "left":
|
|
624
|
+
emit("reachLeft", event);
|
|
625
|
+
break;
|
|
626
|
+
case "right":
|
|
627
|
+
emit("reachRight", event);
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
function writeAxisPosition(axis, value) {
|
|
632
|
+
const viewport = viewportRef.value;
|
|
633
|
+
if (!viewport) return;
|
|
634
|
+
if (axis === "x") viewport.scrollLeft = getRawHorizontalScrollPosition(value, getScrollAreaMaxPosition(metrics, "x"), metrics.direction);
|
|
635
|
+
else viewport.scrollTop = clamp(value, 0, getScrollAreaMaxPosition(metrics, "y"));
|
|
636
|
+
updatePosition();
|
|
637
|
+
visibility.showDuringScroll();
|
|
638
|
+
}
|
|
639
|
+
function onScrollbarKeydown(axis, event) {
|
|
640
|
+
const viewport = viewportRef.value;
|
|
641
|
+
if (!viewport || !getScrollAreaOverflow(metrics, axis)) return;
|
|
642
|
+
updatePosition(viewport);
|
|
643
|
+
const current = getScrollAreaAxisPosition(metrics, axis);
|
|
644
|
+
const pageSize = axis === "x" ? viewport.clientWidth : viewport.clientHeight;
|
|
645
|
+
const nextPosition = getKeyboardScrollPosition({
|
|
646
|
+
axis,
|
|
647
|
+
key: event.key,
|
|
648
|
+
current,
|
|
649
|
+
pageSize,
|
|
650
|
+
maxPosition: getScrollAreaMaxPosition(metrics, axis),
|
|
651
|
+
direction: metrics.direction,
|
|
652
|
+
lineStep: keyboardScrollStep
|
|
691
653
|
});
|
|
654
|
+
if (nextPosition === void 0) return;
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
writeAxisPosition(axis, nextPosition);
|
|
657
|
+
}
|
|
658
|
+
function onScrollbarWheel(axis, event) {
|
|
659
|
+
if (!getScrollAreaOverflow(metrics, axis)) return;
|
|
660
|
+
updatePosition();
|
|
661
|
+
const delta = getWheelScrollDelta(axis, event, metrics.direction);
|
|
662
|
+
if (!delta) return;
|
|
663
|
+
event.preventDefault();
|
|
664
|
+
writeAxisPosition(axis, getScrollAreaAxisPosition(metrics, axis) + delta);
|
|
665
|
+
}
|
|
666
|
+
function scrollTo(scrollOptions) {
|
|
667
|
+
const viewport = viewportRef.value;
|
|
668
|
+
if (!viewport) return;
|
|
669
|
+
if (typeof viewport.scrollTo === "function") viewport.scrollTo(scrollOptions);
|
|
670
|
+
else applyFallbackScrollPosition(viewport, scrollOptions, "absolute");
|
|
671
|
+
schedulePositionUpdate();
|
|
672
|
+
}
|
|
673
|
+
function scrollBy(scrollOptions) {
|
|
674
|
+
const viewport = viewportRef.value;
|
|
675
|
+
if (!viewport) return;
|
|
676
|
+
if (typeof viewport.scrollBy === "function") viewport.scrollBy(scrollOptions);
|
|
677
|
+
else applyFallbackScrollPosition(viewport, scrollOptions, "relative");
|
|
678
|
+
schedulePositionUpdate();
|
|
692
679
|
}
|
|
680
|
+
watch([
|
|
681
|
+
horizontalScrollbarActive,
|
|
682
|
+
verticalScrollbarActive,
|
|
683
|
+
renderHorizontalScrollbar,
|
|
684
|
+
renderVerticalScrollbar
|
|
685
|
+
], () => void nextTick(scheduleUpdate));
|
|
693
686
|
return {
|
|
687
|
+
templateRefs,
|
|
688
|
+
renderHorizontalScrollbar,
|
|
689
|
+
renderVerticalScrollbar,
|
|
694
690
|
rootAttrs,
|
|
695
691
|
viewportAttrs,
|
|
696
692
|
contentAttrs,
|
|
@@ -699,22 +695,21 @@ function useScrollAreaPresentation(props, scrollArea) {
|
|
|
699
695
|
horizontalThumbAttrs,
|
|
700
696
|
verticalThumbAttrs,
|
|
701
697
|
cornerAttrs,
|
|
702
|
-
slotProps
|
|
698
|
+
slotProps,
|
|
699
|
+
onScrollbarKeydown,
|
|
700
|
+
onScrollbarWheel,
|
|
701
|
+
onScrollbarPointerdown,
|
|
702
|
+
onThumbPointerdown,
|
|
703
|
+
scrollTo,
|
|
704
|
+
scrollBy,
|
|
705
|
+
update
|
|
703
706
|
};
|
|
704
707
|
}
|
|
705
|
-
function getRootStyle(scrollbarSize) {
|
|
706
|
-
const length = getLengthValue(scrollbarSize);
|
|
707
|
-
return length ? { "--_rp-scroll-area-scrollbar-size": length } : {};
|
|
708
|
-
}
|
|
709
|
-
function hasAccessibleName(props, attrs) {
|
|
710
|
-
return Boolean(props.ariaLabel || props.ariaLabelledby || attrs["aria-label"] || attrs["aria-labelledby"]);
|
|
711
|
-
}
|
|
712
708
|
//#endregion
|
|
713
709
|
//#region src/components/scroll-area/scroll-area.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
714
|
-
var t0 = template("<div data-v-
|
|
715
|
-
var t1 = template("<div data-v-
|
|
716
|
-
var t2 = template("<div data-v-
|
|
717
|
-
delegateEvents("pointerdown", "keydown");
|
|
710
|
+
var t0 = template("<div data-v-cd2fe353><div data-v-cd2fe353></div>");
|
|
711
|
+
var t1 = template("<div data-v-cd2fe353>");
|
|
712
|
+
var t2 = template("<div data-v-cd2fe353><div data-v-cd2fe353><div data-v-cd2fe353></div></div>", 1);
|
|
718
713
|
//#endregion
|
|
719
714
|
//#region src/components/scroll-area/scroll-area.vue
|
|
720
715
|
var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -760,21 +755,9 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
760
755
|
"reachRight"
|
|
761
756
|
],
|
|
762
757
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
763
|
-
const
|
|
764
|
-
const emit = __emit;
|
|
765
|
-
const scrollArea = useScrollArea({
|
|
766
|
-
props,
|
|
767
|
-
emitScroll: (event) => emit("scroll", event),
|
|
768
|
-
emitPositionChange: (position) => emit("scrollPositionChange", position),
|
|
769
|
-
emitReachTop: (event) => emit("reachTop", event),
|
|
770
|
-
emitReachBottom: (event) => emit("reachBottom", event),
|
|
771
|
-
emitReachLeft: (event) => emit("reachLeft", event),
|
|
772
|
-
emitReachRight: (event) => emit("reachRight", event)
|
|
773
|
-
});
|
|
774
|
-
const { rootRef, viewportRef, contentRef, horizontalScrollbarRef, verticalScrollbarRef, renderHorizontalScrollbar, renderVerticalScrollbar, onScrollbarKeydown, onScrollbarWheel, onScrollbarPointerdown, onThumbPointerdown, scrollTo, scrollBy, update } = scrollArea;
|
|
775
|
-
const { rootAttrs, viewportAttrs, contentAttrs, horizontalScrollbarAttrs, verticalScrollbarAttrs, horizontalThumbAttrs, verticalThumbAttrs, cornerAttrs, slotProps } = useScrollAreaPresentation(props, scrollArea);
|
|
758
|
+
const { templateRefs, renderHorizontalScrollbar, renderVerticalScrollbar, rootAttrs, viewportAttrs, contentAttrs, horizontalScrollbarAttrs, verticalScrollbarAttrs, horizontalThumbAttrs, verticalThumbAttrs, cornerAttrs, slotProps, onScrollbarKeydown, onScrollbarWheel, onScrollbarPointerdown, onThumbPointerdown, scrollTo, scrollBy, update } = useScrollArea(__props, __emit);
|
|
776
759
|
__expose({
|
|
777
|
-
viewport:
|
|
760
|
+
viewport: templateRefs.viewport,
|
|
778
761
|
scrollTo,
|
|
779
762
|
scrollBy,
|
|
780
763
|
update
|
|
@@ -790,20 +773,23 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
790
773
|
});
|
|
791
774
|
setInsertionState(n1, null, 0);
|
|
792
775
|
createSlot("default", { $: [() => unref(slotProps)] }, null, 1);
|
|
793
|
-
|
|
794
|
-
|
|
776
|
+
renderEffect(() => {
|
|
777
|
+
const _templateRefs = unref(templateRefs);
|
|
778
|
+
_setTemplateRef(n1, _templateRefs.content);
|
|
779
|
+
_setTemplateRef(n2, _templateRefs.viewport);
|
|
780
|
+
});
|
|
795
781
|
setInsertionState(n14, null, 1);
|
|
796
782
|
createIf(() => unref(renderHorizontalScrollbar), () => {
|
|
797
783
|
const n6 = t0();
|
|
798
784
|
const n5 = child(n6);
|
|
799
|
-
n5
|
|
800
|
-
n6
|
|
801
|
-
n6
|
|
785
|
+
on(n5, "pointerdown", ($event) => unref(onThumbPointerdown)("x", $event));
|
|
786
|
+
on(n6, "keydown", ($event) => unref(onScrollbarKeydown)("x", $event));
|
|
787
|
+
on(n6, "pointerdown", ($event) => unref(onScrollbarPointerdown)("x", $event));
|
|
802
788
|
on(n6, "wheel", ($event) => unref(onScrollbarWheel)("x", $event));
|
|
803
|
-
_setTemplateRef(n6, horizontalScrollbarRef, null, "horizontalScrollbarRef");
|
|
804
789
|
renderEffect(() => {
|
|
805
790
|
setDynamicProps(n6, [unref(horizontalScrollbarAttrs)]);
|
|
806
791
|
setDynamicProps(n5, [unref(horizontalThumbAttrs)]);
|
|
792
|
+
_setTemplateRef(n6, unref(templateRefs).horizontalScrollbar);
|
|
807
793
|
});
|
|
808
794
|
return n6;
|
|
809
795
|
});
|
|
@@ -811,14 +797,14 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
811
797
|
createIf(() => unref(renderVerticalScrollbar), () => {
|
|
812
798
|
const n10 = t0();
|
|
813
799
|
const n9 = child(n10);
|
|
814
|
-
n9
|
|
815
|
-
n10
|
|
816
|
-
n10
|
|
800
|
+
on(n9, "pointerdown", ($event) => unref(onThumbPointerdown)("y", $event));
|
|
801
|
+
on(n10, "keydown", ($event) => unref(onScrollbarKeydown)("y", $event));
|
|
802
|
+
on(n10, "pointerdown", ($event) => unref(onScrollbarPointerdown)("y", $event));
|
|
817
803
|
on(n10, "wheel", ($event) => unref(onScrollbarWheel)("y", $event));
|
|
818
|
-
_setTemplateRef(n10, verticalScrollbarRef, null, "verticalScrollbarRef");
|
|
819
804
|
renderEffect(() => {
|
|
820
805
|
setDynamicProps(n10, [unref(verticalScrollbarAttrs)]);
|
|
821
806
|
setDynamicProps(n9, [unref(verticalThumbAttrs)]);
|
|
807
|
+
_setTemplateRef(n10, unref(templateRefs).verticalScrollbar);
|
|
822
808
|
});
|
|
823
809
|
return n10;
|
|
824
810
|
});
|
|
@@ -828,9 +814,9 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
828
814
|
renderEffect(() => setDynamicProps(n13, [unref(cornerAttrs)]));
|
|
829
815
|
return n13;
|
|
830
816
|
});
|
|
831
|
-
|
|
817
|
+
setTemplateRefBinding(n14, () => unref(templateRefs).root);
|
|
832
818
|
return n14;
|
|
833
819
|
}
|
|
834
|
-
}), [["__scopeId", "data-v-
|
|
820
|
+
}), [["__scopeId", "data-v-cd2fe353"]]);
|
|
835
821
|
//#endregion
|
|
836
822
|
export { scroll_area_default as t };
|