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