ropav 0.1.6 → 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 +6 -0
- 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/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/card.js +1 -1
- package/dist/checkbox.css +32 -32
- package/dist/checkbox.js +22 -28
- 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 +221 -200
- 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/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/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/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} +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-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-trigger.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +1 -1
- package/dist/components/dropdown-menu/{dropdown-menu-primitive-core.d.ts → dropdownMenuContext.d.ts} +16 -18
- 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/number-input/numberInputModel.d.ts +15 -0
- package/dist/components/number-input/useNumberInput.d.ts +3 -17
- 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 +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 +10 -8
- package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +15 -20
- 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 +8 -16
- 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/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/css.js +12 -0
- package/dist/dialog.js +226 -218
- package/dist/dropdown-menu.js +1458 -1097
- package/dist/events.js +59 -0
- package/dist/field.css +8 -8
- package/dist/field.js +13 -25
- package/dist/floating.js +548 -319
- package/dist/floatingOffset.js +11 -0
- package/dist/focus-trap.js +7 -5
- package/dist/focusNavigation.js +37 -0
- package/dist/icon-button.css +8 -8
- package/dist/icon-button.js +7 -6
- package/dist/index.js +6 -6
- package/dist/input.css +24 -24
- package/dist/input.js +19 -31
- package/dist/interactive.js +18 -0
- package/dist/modal.js +1 -1
- package/dist/number-input.css +18 -18
- package/dist/number-input.js +14 -12
- package/dist/number.js +22 -0
- package/dist/overlay.js +3 -2
- package/dist/pagination.css +28 -28
- package/dist/pagination.js +65 -63
- package/dist/pointer.js +9 -0
- package/dist/popover.css +34 -34
- package/dist/popover.js +85 -86
- 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 +512 -516
- package/dist/select.css +45 -45
- package/dist/select.js +36 -44
- package/dist/slider.css +191 -191
- package/dist/slider.js +691 -618
- 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/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 +36 -40
- package/dist/useCollapse.js +8 -11
- package/dist/useControlState.js +3 -6
- package/dist/useFloatingPosition.js +140 -10
- package/dist/useOverlayZIndex.js +1 -5
- 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-floating-api.md +6 -5
- package/package.json +13 -12
- 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/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,71 @@
|
|
|
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 { 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";
|
|
12
15
|
}
|
|
13
|
-
function
|
|
16
|
+
function getLogicalHorizontalScrollPosition(scrollLeft, maxPosition, direction) {
|
|
14
17
|
return clamp(direction === "rtl" ? -scrollLeft : scrollLeft, 0, maxPosition);
|
|
15
18
|
}
|
|
16
|
-
function
|
|
19
|
+
function getRawHorizontalScrollPosition(position, maxPosition, direction) {
|
|
17
20
|
const logicalPosition = clamp(position, 0, maxPosition);
|
|
18
21
|
return direction === "rtl" && logicalPosition !== 0 ? -logicalPosition : logicalPosition;
|
|
19
22
|
}
|
|
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) {
|
|
23
|
+
function getScrollThumbGeometry(trackSize, viewportSize, scrollSize, minimumSize) {
|
|
30
24
|
if (trackSize <= 0 || viewportSize <= 0 || scrollSize <= viewportSize) return {
|
|
31
25
|
size: 100,
|
|
32
26
|
offsetRatio: 1
|
|
33
27
|
};
|
|
34
|
-
const sizeRatio = clamp(viewportSize / scrollSize * trackSize,
|
|
28
|
+
const sizeRatio = clamp(viewportSize / scrollSize * trackSize, minimumSize, trackSize) / trackSize;
|
|
35
29
|
return {
|
|
36
30
|
size: sizeRatio * 100,
|
|
37
31
|
offsetRatio: sizeRatio
|
|
38
32
|
};
|
|
39
33
|
}
|
|
40
|
-
function
|
|
34
|
+
function getScrollThumbOffset(position, maxPosition, sizeRatio) {
|
|
41
35
|
if (sizeRatio >= 1 || maxPosition <= 0) return 0;
|
|
42
36
|
return position / maxPosition * ((1 - sizeRatio) / sizeRatio) * 100;
|
|
43
37
|
}
|
|
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) {
|
|
38
|
+
function getKeyboardScrollPosition({ axis, key, current, pageSize, maxPosition, direction, lineStep }) {
|
|
157
39
|
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 +
|
|
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;
|
|
162
44
|
case "PageUp": return current - pageSize;
|
|
163
45
|
case "PageDown": return current + pageSize;
|
|
164
46
|
case "Home": return 0;
|
|
165
|
-
case "End": return
|
|
47
|
+
case "End": return maxPosition;
|
|
166
48
|
default: return;
|
|
167
49
|
}
|
|
168
50
|
}
|
|
169
|
-
function
|
|
51
|
+
function getWheelScrollDelta(axis, event, direction) {
|
|
170
52
|
if (axis === "y") return event.deltaY;
|
|
171
53
|
if (!event.deltaX) return event.deltaY;
|
|
172
54
|
return direction === "rtl" ? -event.deltaX : event.deltaX;
|
|
173
55
|
}
|
|
174
|
-
function
|
|
175
|
-
|
|
176
|
-
if (
|
|
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;
|
|
177
60
|
}
|
|
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
|
-
};
|
|
61
|
+
function getPointerAxisCoordinate(axis, event) {
|
|
62
|
+
return axis === "x" ? event.clientX : event.clientY;
|
|
210
63
|
}
|
|
211
64
|
//#endregion
|
|
212
|
-
//#region src/components/scroll-area/
|
|
213
|
-
|
|
214
|
-
|
|
65
|
+
//#region src/components/scroll-area/scrollAreaModel.ts
|
|
66
|
+
var boundaryTolerance = 1;
|
|
67
|
+
function createScrollAreaMetrics() {
|
|
68
|
+
return {
|
|
215
69
|
direction: "ltr",
|
|
216
70
|
clientWidth: 0,
|
|
217
71
|
clientHeight: 0,
|
|
@@ -225,20 +79,210 @@ function useScrollAreaMetrics(options) {
|
|
|
225
79
|
horizontalThumbOffset: 0,
|
|
226
80
|
verticalThumbSize: 100,
|
|
227
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
|
+
};
|
|
228
193
|
});
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
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
|
+
};
|
|
204
|
+
});
|
|
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)
|
|
232
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());
|
|
233
276
|
let resizeObserver;
|
|
234
|
-
let
|
|
277
|
+
let contentObserver;
|
|
235
278
|
let directionObserver;
|
|
279
|
+
let observerView;
|
|
236
280
|
let horizontalThumbSizeRatio = 1;
|
|
237
281
|
let verticalThumbSizeRatio = 1;
|
|
238
|
-
const
|
|
239
|
-
const positionScheduler = createRafScheduler(updatePosition, () =>
|
|
282
|
+
const updateScheduler = createRafScheduler(update, () => elements.viewport.value?.ownerDocument.defaultView);
|
|
283
|
+
const positionScheduler = createRafScheduler(updatePosition, () => elements.viewport.value?.ownerDocument.defaultView);
|
|
240
284
|
function update() {
|
|
241
|
-
const viewport =
|
|
285
|
+
const viewport = elements.viewport.value;
|
|
242
286
|
if (!viewport) return;
|
|
243
287
|
readViewportGeometry(viewport);
|
|
244
288
|
updateThumbGeometry(viewport);
|
|
@@ -249,46 +293,38 @@ function useScrollAreaMetrics(options) {
|
|
|
249
293
|
metrics.clientHeight = viewport.clientHeight;
|
|
250
294
|
metrics.scrollWidth = viewport.scrollWidth;
|
|
251
295
|
metrics.scrollHeight = viewport.scrollHeight;
|
|
252
|
-
metrics.overflowX =
|
|
253
|
-
metrics.overflowY =
|
|
296
|
+
metrics.overflowX = isAxisEnabled("x") && viewport.scrollWidth > viewport.clientWidth + 1;
|
|
297
|
+
metrics.overflowY = isAxisEnabled("y") && viewport.scrollHeight > viewport.clientHeight + 1;
|
|
254
298
|
}
|
|
255
299
|
function updateThumbGeometry(viewport) {
|
|
256
|
-
const horizontalGeometry =
|
|
257
|
-
const verticalGeometry =
|
|
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);
|
|
258
302
|
metrics.horizontalThumbSize = horizontalGeometry.size;
|
|
259
303
|
horizontalThumbSizeRatio = horizontalGeometry.offsetRatio;
|
|
260
304
|
metrics.verticalThumbSize = verticalGeometry.size;
|
|
261
305
|
verticalThumbSizeRatio = verticalGeometry.offsetRatio;
|
|
262
306
|
}
|
|
263
|
-
function updatePosition(viewport =
|
|
307
|
+
function updatePosition(viewport = elements.viewport.value) {
|
|
264
308
|
if (!viewport) return;
|
|
265
309
|
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;
|
|
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);
|
|
279
314
|
}
|
|
280
315
|
function attachObservers() {
|
|
281
|
-
const viewport =
|
|
316
|
+
const viewport = elements.viewport.value;
|
|
282
317
|
if (!viewport) return;
|
|
283
|
-
|
|
284
|
-
const ResizeObserverConstructor =
|
|
318
|
+
observerView = viewport.ownerDocument.defaultView;
|
|
319
|
+
const ResizeObserverConstructor = observerView?.ResizeObserver ?? globalThis.ResizeObserver;
|
|
285
320
|
if (ResizeObserverConstructor) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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);
|
|
292
328
|
}
|
|
293
329
|
function attachDirectionObserver(view, viewport) {
|
|
294
330
|
const MutationObserverConstructor = view?.MutationObserver ?? globalThis.MutationObserver;
|
|
@@ -307,13 +343,12 @@ function useScrollAreaMetrics(options) {
|
|
|
307
343
|
element = element.parentElement;
|
|
308
344
|
}
|
|
309
345
|
}
|
|
310
|
-
function
|
|
346
|
+
function attachContentObserver(view) {
|
|
311
347
|
const MutationObserverConstructor = view?.MutationObserver ?? globalThis.MutationObserver;
|
|
312
|
-
const content =
|
|
348
|
+
const content = elements.content.value;
|
|
313
349
|
if (!MutationObserverConstructor || !content) return;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
observer.observe(content, {
|
|
350
|
+
contentObserver = new MutationObserverConstructor(updateScheduler.schedule);
|
|
351
|
+
contentObserver.observe(content, {
|
|
317
352
|
attributes: true,
|
|
318
353
|
childList: true,
|
|
319
354
|
characterData: true,
|
|
@@ -321,34 +356,30 @@ function useScrollAreaMetrics(options) {
|
|
|
321
356
|
});
|
|
322
357
|
}
|
|
323
358
|
function detachObservers() {
|
|
324
|
-
const view = options.viewportRef.value?.ownerDocument.defaultView;
|
|
325
359
|
resizeObserver?.disconnect();
|
|
326
|
-
|
|
360
|
+
contentObserver?.disconnect();
|
|
327
361
|
directionObserver?.disconnect();
|
|
328
362
|
resizeObserver = void 0;
|
|
329
|
-
|
|
363
|
+
contentObserver = void 0;
|
|
330
364
|
directionObserver = void 0;
|
|
331
|
-
|
|
365
|
+
observerView?.removeEventListener("resize", updateScheduler.schedule);
|
|
366
|
+
observerView = void 0;
|
|
332
367
|
}
|
|
333
368
|
onMounted(() => {
|
|
334
369
|
attachObservers();
|
|
335
|
-
nextTick(
|
|
370
|
+
nextTick(updateScheduler.schedule);
|
|
336
371
|
});
|
|
337
372
|
onBeforeUnmount(() => {
|
|
338
373
|
detachObservers();
|
|
339
|
-
|
|
374
|
+
updateScheduler.cancel();
|
|
340
375
|
positionScheduler.cancel();
|
|
341
376
|
});
|
|
342
377
|
return {
|
|
343
378
|
metrics,
|
|
344
|
-
position,
|
|
345
|
-
update,
|
|
346
|
-
updatePosition,
|
|
347
|
-
scheduleUpdate: scheduler.schedule,
|
|
348
379
|
schedulePositionUpdate: positionScheduler.schedule,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
380
|
+
scheduleUpdate: updateScheduler.schedule,
|
|
381
|
+
update,
|
|
382
|
+
updatePosition
|
|
352
383
|
};
|
|
353
384
|
}
|
|
354
385
|
//#endregion
|
|
@@ -357,52 +388,55 @@ function useScrollAreaPointer(options) {
|
|
|
357
388
|
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
412
|
if (event.button !== 0 || event.isPrimary === false) return;
|
|
379
|
-
|
|
380
|
-
|
|
413
|
+
const state = options.refreshAxis(axis);
|
|
414
|
+
if (!state.overflow) return;
|
|
381
415
|
const scrollbar = getScrollbar(axis);
|
|
382
416
|
const thumb = event.currentTarget;
|
|
383
417
|
if (!scrollbar) return;
|
|
384
418
|
const trackRect = scrollbar.getBoundingClientRect();
|
|
385
419
|
const thumbRect = thumb.getBoundingClientRect();
|
|
386
|
-
const
|
|
387
|
-
const
|
|
420
|
+
const horizontal = axis === "x";
|
|
421
|
+
const trackSize = horizontal ? trackRect.width : trackRect.height;
|
|
422
|
+
const thumbSize = horizontal ? thumbRect.width : thumbRect.height;
|
|
388
423
|
const travel = Math.max(0, trackSize - thumbSize);
|
|
389
424
|
if (travel === 0) return;
|
|
390
425
|
event.preventDefault();
|
|
391
|
-
event.stopPropagation();
|
|
392
426
|
stopDragging();
|
|
393
|
-
if (options.
|
|
394
|
-
startDragging(axis, event, scrollbar, travel);
|
|
427
|
+
if (!options.isEmbedded()) scrollbar.focus({ preventScroll: true });
|
|
428
|
+
startDragging(axis, event, scrollbar, travel, state);
|
|
395
429
|
}
|
|
396
|
-
function startDragging(axis, event, scrollbar, travel) {
|
|
430
|
+
function startDragging(axis, event, scrollbar, travel, state) {
|
|
397
431
|
const view = scrollbar.ownerDocument.defaultView;
|
|
398
432
|
dragSession = {
|
|
399
433
|
axis,
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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,
|
|
404
439
|
travel,
|
|
405
|
-
coordinateDirection: axis === "x" && options.metrics.metrics.direction === "rtl" ? -1 : 1,
|
|
406
440
|
view
|
|
407
441
|
};
|
|
408
442
|
options.setDraggingAxis(axis);
|
|
@@ -412,12 +446,18 @@ function useScrollAreaPointer(options) {
|
|
|
412
446
|
}
|
|
413
447
|
function onPointermove(event) {
|
|
414
448
|
const session = dragSession;
|
|
415
|
-
if (!session || !
|
|
416
|
-
|
|
417
|
-
|
|
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
|
+
}));
|
|
418
458
|
}
|
|
419
459
|
function onPointerend(event) {
|
|
420
|
-
if (!dragSession || !
|
|
460
|
+
if (!dragSession || !isMatchingPointer(event, dragSession.pointerId)) return;
|
|
421
461
|
stopDragging();
|
|
422
462
|
}
|
|
423
463
|
function stopDragging() {
|
|
@@ -429,7 +469,7 @@ function useScrollAreaPointer(options) {
|
|
|
429
469
|
options.setDraggingAxis(null);
|
|
430
470
|
}
|
|
431
471
|
function getScrollbar(axis) {
|
|
432
|
-
return axis === "x" ? options.
|
|
472
|
+
return axis === "x" ? options.elements.horizontalScrollbar.value : options.elements.verticalScrollbar.value;
|
|
433
473
|
}
|
|
434
474
|
onBeforeUnmount(stopDragging);
|
|
435
475
|
return {
|
|
@@ -437,260 +477,226 @@ function useScrollAreaPointer(options) {
|
|
|
437
477
|
onThumbPointerdown
|
|
438
478
|
};
|
|
439
479
|
}
|
|
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
480
|
//#endregion
|
|
447
481
|
//#region src/components/scroll-area/useScrollAreaVisibility.ts
|
|
448
482
|
function useScrollAreaVisibility(options) {
|
|
449
|
-
const
|
|
450
|
-
const
|
|
451
|
-
const
|
|
483
|
+
const hovered = ref(false);
|
|
484
|
+
const focusWithin = ref(false);
|
|
485
|
+
const scrolling = ref(false);
|
|
452
486
|
const draggingAxis = ref(null);
|
|
453
487
|
let scrollEndTimer;
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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;
|
|
468
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
|
+
});
|
|
469
515
|
}
|
|
470
516
|
function showDuringScroll() {
|
|
471
|
-
|
|
472
|
-
|
|
517
|
+
scrolling.value = true;
|
|
518
|
+
clearScrollEndTimer();
|
|
473
519
|
scrollEndTimer = setTimeout(() => {
|
|
474
|
-
|
|
520
|
+
scrolling.value = false;
|
|
475
521
|
scrollEndTimer = void 0;
|
|
476
|
-
}, normalizeDelay(options.
|
|
522
|
+
}, normalizeDelay(options.getHideDelay()));
|
|
523
|
+
}
|
|
524
|
+
function clearScrollEndTimer() {
|
|
525
|
+
if (scrollEndTimer === void 0) return;
|
|
526
|
+
clearTimeout(scrollEndTimer);
|
|
527
|
+
scrollEndTimer = void 0;
|
|
477
528
|
}
|
|
478
529
|
function setDraggingAxis(axis) {
|
|
479
530
|
draggingAxis.value = axis;
|
|
480
531
|
}
|
|
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();
|
|
532
|
+
watch(options.getHideDelay, () => {
|
|
533
|
+
if (scrolling.value) showDuringScroll();
|
|
500
534
|
});
|
|
501
|
-
onBeforeUnmount(
|
|
535
|
+
onBeforeUnmount(clearScrollEndTimer);
|
|
502
536
|
return {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
horizontalScrollbarActive,
|
|
506
|
-
verticalScrollbarActive,
|
|
507
|
-
horizontalScrollbarVisible,
|
|
508
|
-
verticalScrollbarVisible,
|
|
509
|
-
showDuringScroll,
|
|
537
|
+
horizontalVisible,
|
|
538
|
+
rootHandlers,
|
|
510
539
|
setDraggingAxis,
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
onFocusin,
|
|
514
|
-
onFocusout
|
|
540
|
+
showDuringScroll,
|
|
541
|
+
verticalVisible
|
|
515
542
|
};
|
|
516
543
|
}
|
|
517
|
-
function normalizeDelay(delay) {
|
|
518
|
-
return Number.isFinite(delay) ? Math.max(0, delay ?? 0) : 0;
|
|
519
|
-
}
|
|
520
544
|
//#endregion
|
|
521
545
|
//#region src/components/scroll-area/useScrollArea.ts
|
|
522
|
-
|
|
546
|
+
var minimumThumbSize = 18;
|
|
547
|
+
var keyboardScrollStep = 40;
|
|
548
|
+
function useScrollArea(props, emit) {
|
|
523
549
|
const rootRef = ref(null);
|
|
524
550
|
const viewportRef = ref(null);
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
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
|
|
537
562
|
});
|
|
563
|
+
const { horizontalScrollbarActive, renderHorizontalScrollbar, renderVerticalScrollbar, verticalScrollbarActive } = useScrollAreaDerivedState(props, metrics);
|
|
538
564
|
const visibility = useScrollAreaVisibility({
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
overflowX: () => measurements.metrics.overflowX,
|
|
544
|
-
overflowY: () => measurements.metrics.overflowY
|
|
565
|
+
getHideDelay: () => props.scrollHideDelay,
|
|
566
|
+
getType: () => props.type ?? "hover",
|
|
567
|
+
isScrollbarActive: (axis) => axis === "x" ? horizontalScrollbarActive.value : verticalScrollbarActive.value,
|
|
568
|
+
root: rootRef
|
|
545
569
|
});
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
emitScroll: options.emitScroll,
|
|
551
|
-
emitPositionChange: options.emitPositionChange,
|
|
552
|
-
emitReachTop: options.emitReachTop,
|
|
553
|
-
emitReachBottom: options.emitReachBottom,
|
|
554
|
-
emitReachLeft: options.emitReachLeft,
|
|
555
|
-
emitReachRight: options.emitReachRight
|
|
556
|
-
});
|
|
557
|
-
const pointer = useScrollAreaPointer({
|
|
558
|
-
horizontalScrollbarRef,
|
|
559
|
-
verticalScrollbarRef,
|
|
560
|
-
metrics: measurements,
|
|
561
|
-
controls,
|
|
570
|
+
const { onScrollbarPointerdown, onThumbPointerdown } = useScrollAreaPointer({
|
|
571
|
+
elements: templateRefs,
|
|
572
|
+
isEmbedded: () => Boolean(props.embedded),
|
|
573
|
+
refreshAxis,
|
|
562
574
|
setDraggingAxis: visibility.setDraggingAxis,
|
|
563
|
-
|
|
575
|
+
writeAxisPosition
|
|
564
576
|
});
|
|
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
|
|
577
|
+
let previousPosition = {
|
|
578
|
+
x: 0,
|
|
579
|
+
y: 0
|
|
586
580
|
};
|
|
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
|
-
};
|
|
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
|
|
643
593
|
});
|
|
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
594
|
const slotProps = computed(() => ({
|
|
655
|
-
position:
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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
|
|
661
604
|
}));
|
|
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)
|
|
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")
|
|
681
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);
|
|
682
624
|
}
|
|
683
|
-
function
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
"
|
|
690
|
-
|
|
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
|
|
691
663
|
});
|
|
664
|
+
if (nextPosition === void 0) return;
|
|
665
|
+
event.preventDefault();
|
|
666
|
+
writeAxisPosition(axis, nextPosition);
|
|
692
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));
|
|
693
696
|
return {
|
|
697
|
+
templateRefs,
|
|
698
|
+
renderHorizontalScrollbar,
|
|
699
|
+
renderVerticalScrollbar,
|
|
694
700
|
rootAttrs,
|
|
695
701
|
viewportAttrs,
|
|
696
702
|
contentAttrs,
|
|
@@ -699,22 +705,21 @@ function useScrollAreaPresentation(props, scrollArea) {
|
|
|
699
705
|
horizontalThumbAttrs,
|
|
700
706
|
verticalThumbAttrs,
|
|
701
707
|
cornerAttrs,
|
|
702
|
-
slotProps
|
|
708
|
+
slotProps,
|
|
709
|
+
onScrollbarKeydown,
|
|
710
|
+
onScrollbarWheel,
|
|
711
|
+
onScrollbarPointerdown,
|
|
712
|
+
onThumbPointerdown,
|
|
713
|
+
scrollTo,
|
|
714
|
+
scrollBy,
|
|
715
|
+
update
|
|
703
716
|
};
|
|
704
717
|
}
|
|
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
718
|
//#endregion
|
|
713
719
|
//#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");
|
|
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);
|
|
718
723
|
//#endregion
|
|
719
724
|
//#region src/components/scroll-area/scroll-area.vue
|
|
720
725
|
var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
@@ -760,21 +765,9 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
760
765
|
"reachRight"
|
|
761
766
|
],
|
|
762
767
|
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);
|
|
768
|
+
const { templateRefs, renderHorizontalScrollbar, renderVerticalScrollbar, rootAttrs, viewportAttrs, contentAttrs, horizontalScrollbarAttrs, verticalScrollbarAttrs, horizontalThumbAttrs, verticalThumbAttrs, cornerAttrs, slotProps, onScrollbarKeydown, onScrollbarWheel, onScrollbarPointerdown, onThumbPointerdown, scrollTo, scrollBy, update } = useScrollArea(__props, __emit);
|
|
776
769
|
__expose({
|
|
777
|
-
viewport:
|
|
770
|
+
viewport: templateRefs.viewport,
|
|
778
771
|
scrollTo,
|
|
779
772
|
scrollBy,
|
|
780
773
|
update
|
|
@@ -790,20 +783,23 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
790
783
|
});
|
|
791
784
|
setInsertionState(n1, null, 0);
|
|
792
785
|
createSlot("default", { $: [() => unref(slotProps)] }, null, 1);
|
|
793
|
-
|
|
794
|
-
|
|
786
|
+
renderEffect(() => {
|
|
787
|
+
const _templateRefs = unref(templateRefs);
|
|
788
|
+
_setTemplateRef(n1, _templateRefs.content);
|
|
789
|
+
_setTemplateRef(n2, _templateRefs.viewport);
|
|
790
|
+
});
|
|
795
791
|
setInsertionState(n14, null, 1);
|
|
796
792
|
createIf(() => unref(renderHorizontalScrollbar), () => {
|
|
797
793
|
const n6 = t0();
|
|
798
794
|
const n5 = child(n6);
|
|
799
|
-
n5
|
|
800
|
-
n6
|
|
801
|
-
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));
|
|
802
798
|
on(n6, "wheel", ($event) => unref(onScrollbarWheel)("x", $event));
|
|
803
|
-
_setTemplateRef(n6, horizontalScrollbarRef, null, "horizontalScrollbarRef");
|
|
804
799
|
renderEffect(() => {
|
|
805
800
|
setDynamicProps(n6, [unref(horizontalScrollbarAttrs)]);
|
|
806
801
|
setDynamicProps(n5, [unref(horizontalThumbAttrs)]);
|
|
802
|
+
_setTemplateRef(n6, unref(templateRefs).horizontalScrollbar);
|
|
807
803
|
});
|
|
808
804
|
return n6;
|
|
809
805
|
});
|
|
@@ -811,14 +807,14 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
811
807
|
createIf(() => unref(renderVerticalScrollbar), () => {
|
|
812
808
|
const n10 = t0();
|
|
813
809
|
const n9 = child(n10);
|
|
814
|
-
n9
|
|
815
|
-
n10
|
|
816
|
-
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));
|
|
817
813
|
on(n10, "wheel", ($event) => unref(onScrollbarWheel)("y", $event));
|
|
818
|
-
_setTemplateRef(n10, verticalScrollbarRef, null, "verticalScrollbarRef");
|
|
819
814
|
renderEffect(() => {
|
|
820
815
|
setDynamicProps(n10, [unref(verticalScrollbarAttrs)]);
|
|
821
816
|
setDynamicProps(n9, [unref(verticalThumbAttrs)]);
|
|
817
|
+
_setTemplateRef(n10, unref(templateRefs).verticalScrollbar);
|
|
822
818
|
});
|
|
823
819
|
return n10;
|
|
824
820
|
});
|
|
@@ -828,9 +824,9 @@ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
|
|
|
828
824
|
renderEffect(() => setDynamicProps(n13, [unref(cornerAttrs)]));
|
|
829
825
|
return n13;
|
|
830
826
|
});
|
|
831
|
-
|
|
827
|
+
setTemplateRefBinding(n14, () => unref(templateRefs).root);
|
|
832
828
|
return n14;
|
|
833
829
|
}
|
|
834
|
-
}), [["__scopeId", "data-v-
|
|
830
|
+
}), [["__scopeId", "data-v-cd2fe353"]]);
|
|
835
831
|
//#endregion
|
|
836
832
|
export { scroll_area_default as t };
|