ropav 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/accordion.css +5 -16
  2. package/dist/accordion.js +10 -24
  3. package/dist/components/accordion/index.d.ts +1 -1
  4. package/dist/components/accordion/types.d.ts +0 -4
  5. package/dist/components/dialog/dialog-core.d.ts +4 -2
  6. package/dist/components/scroll-area/index.d.ts +3 -0
  7. package/dist/components/scroll-area/index.js +3 -0
  8. package/dist/components/scroll-area/scroll-area.d.ts +76 -0
  9. package/dist/components/scroll-area/scrollAreaCore.d.ts +25 -0
  10. package/dist/components/scroll-area/types.d.ts +34 -0
  11. package/dist/components/scroll-area/useScrollArea.d.ts +58 -0
  12. package/dist/components/scroll-area/useScrollAreaControls.d.ts +25 -0
  13. package/dist/components/scroll-area/useScrollAreaMetrics.d.ts +35 -0
  14. package/dist/components/scroll-area/useScrollAreaPointer.d.ts +17 -0
  15. package/dist/components/scroll-area/useScrollAreaPresentation.d.ts +49 -0
  16. package/dist/components/scroll-area/useScrollAreaVisibility.d.ts +27 -0
  17. package/dist/components/select/useSelect.d.ts +7 -5
  18. package/dist/components/select/useSelectNativeControl.d.ts +9 -0
  19. package/dist/components/select/useSelectNativeValue.d.ts +15 -0
  20. package/dist/dialog.js +23 -6
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +3 -1
  23. package/dist/modal.css +28 -29
  24. package/dist/modal.js +10 -8
  25. package/dist/number-input.css +3 -6
  26. package/dist/scroll-area.css +131 -0
  27. package/dist/scroll-area.js +779 -0
  28. package/dist/scroll-area2.js +23 -0
  29. package/dist/select.css +47 -45
  30. package/dist/select.js +167 -129
  31. package/dist/tabs.css +23 -18
  32. package/dist/tabs.js +51 -20
  33. package/docs/public-styles-api.md +1 -1
  34. package/package.json +6 -2
@@ -0,0 +1,779 @@
1
+ import './scroll-area.css';
2
+ import { n as useStylesApi, t as presence } from "./styles-api.js";
3
+ import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
4
+ import { child, computed, createIf, createInvoker, createSlot, createTemplateRefSetter, defineVaporComponent, delegateEvents, nextTick, on, onBeforeUnmount, onMounted, reactive, ref, renderEffect, setDynamicProps, setInsertionState, template, unref, useId, watch } from "vue";
5
+ //#region src/components/scroll-area/scrollAreaCore.ts
6
+ var minimumThumbSize = 18;
7
+ function clamp(value, min, max) {
8
+ return Math.min(max, Math.max(min, value));
9
+ }
10
+ function isAxisEnabled(scrollbars, axis) {
11
+ if (scrollbars === false) return false;
12
+ if (axis === "x") return scrollbars === "x" || scrollbars === "both";
13
+ return scrollbars === "y" || scrollbars === "both";
14
+ }
15
+ function isScrollbarActive(type, enabled, overflowing) {
16
+ if (!enabled || type === "never") return false;
17
+ return type === "always" || overflowing;
18
+ }
19
+ function getThumbGeometry(trackSize, viewportSize, scrollSize) {
20
+ if (trackSize <= 0 || viewportSize <= 0 || scrollSize <= viewportSize) return {
21
+ size: 100,
22
+ offsetRatio: 1
23
+ };
24
+ const sizeRatio = clamp(viewportSize / scrollSize * trackSize, minimumThumbSize, trackSize) / trackSize;
25
+ return {
26
+ size: sizeRatio * 100,
27
+ offsetRatio: sizeRatio
28
+ };
29
+ }
30
+ function getThumbOffset(position, maxPosition, sizeRatio) {
31
+ if (sizeRatio >= 1 || maxPosition <= 0) return 0;
32
+ return position / maxPosition * ((1 - sizeRatio) / sizeRatio) * 100;
33
+ }
34
+ function getLengthValue(value) {
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) {
147
+ switch (key) {
148
+ case "ArrowLeft":
149
+ case "ArrowUp": return current - 40;
150
+ case "ArrowRight":
151
+ case "ArrowDown": return current + 40;
152
+ case "PageUp": return current - pageSize;
153
+ case "PageDown": return current + pageSize;
154
+ case "Home": return 0;
155
+ case "End": return max;
156
+ default: return;
157
+ }
158
+ }
159
+ function setFallbackPosition(viewport, scrollOptions, relative) {
160
+ if (scrollOptions.left !== void 0) viewport.scrollLeft = (relative ? viewport.scrollLeft : 0) + scrollOptions.left;
161
+ if (scrollOptions.top !== void 0) viewport.scrollTop = (relative ? viewport.scrollTop : 0) + scrollOptions.top;
162
+ }
163
+ //#endregion
164
+ //#region src/utils/rafScheduler.ts
165
+ function createRafScheduler(callback, getView) {
166
+ let frameId;
167
+ let frameView;
168
+ let generation = 0;
169
+ function cancel() {
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
+ };
195
+ }
196
+ //#endregion
197
+ //#region src/components/scroll-area/useScrollAreaMetrics.ts
198
+ function useScrollAreaMetrics(options) {
199
+ const metrics = reactive({
200
+ clientWidth: 0,
201
+ clientHeight: 0,
202
+ scrollWidth: 0,
203
+ scrollHeight: 0,
204
+ x: 0,
205
+ y: 0,
206
+ overflowX: false,
207
+ overflowY: false,
208
+ horizontalThumbSize: 100,
209
+ horizontalThumbOffset: 0,
210
+ verticalThumbSize: 100,
211
+ verticalThumbOffset: 0
212
+ });
213
+ const position = computed(() => ({
214
+ x: metrics.x,
215
+ y: metrics.y
216
+ }));
217
+ let resizeObserver;
218
+ let mutationObserver;
219
+ const scheduler = createRafScheduler(update, () => options.viewportRef.value?.ownerDocument.defaultView);
220
+ function update() {
221
+ const viewport = options.viewportRef.value;
222
+ if (!viewport) return;
223
+ readViewportMetrics(viewport);
224
+ updateThumbMetrics(viewport);
225
+ }
226
+ function readViewportMetrics(viewport) {
227
+ metrics.clientWidth = viewport.clientWidth;
228
+ metrics.clientHeight = viewport.clientHeight;
229
+ metrics.scrollWidth = viewport.scrollWidth;
230
+ metrics.scrollHeight = viewport.scrollHeight;
231
+ metrics.x = viewport.scrollLeft;
232
+ metrics.y = viewport.scrollTop;
233
+ metrics.overflowX = options.horizontalEnabled.value && viewport.scrollWidth > viewport.clientWidth + 1;
234
+ metrics.overflowY = options.verticalEnabled.value && viewport.scrollHeight > viewport.clientHeight + 1;
235
+ }
236
+ function updateThumbMetrics(viewport) {
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);
239
+ metrics.horizontalThumbSize = horizontalGeometry.size;
240
+ metrics.horizontalThumbOffset = getThumbOffset(clamp(Math.abs(viewport.scrollLeft), 0, getMaxPosition("x")), getMaxPosition("x"), horizontalGeometry.offsetRatio);
241
+ metrics.verticalThumbSize = verticalGeometry.size;
242
+ metrics.verticalThumbOffset = getThumbOffset(clamp(viewport.scrollTop, 0, getMaxPosition("y")), getMaxPosition("y"), verticalGeometry.offsetRatio);
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);
249
+ }
250
+ function getOverflow(axis) {
251
+ return axis === "x" ? metrics.overflowX : metrics.overflowY;
252
+ }
253
+ function attachObservers() {
254
+ const viewport = options.viewportRef.value;
255
+ if (!viewport) return;
256
+ const view = viewport.ownerDocument.defaultView;
257
+ const ResizeObserverConstructor = view?.ResizeObserver ?? globalThis.ResizeObserver;
258
+ if (ResizeObserverConstructor) {
259
+ resizeObserver = new ResizeObserverConstructor(scheduler.schedule);
260
+ resizeObserver.observe(viewport);
261
+ if (options.contentRef.value) resizeObserver.observe(options.contentRef.value);
262
+ } else attachMutationObserver(view);
263
+ view?.addEventListener("resize", scheduler.schedule);
264
+ }
265
+ function attachMutationObserver(view) {
266
+ const MutationObserverConstructor = view?.MutationObserver ?? globalThis.MutationObserver;
267
+ const content = options.contentRef.value;
268
+ if (!MutationObserverConstructor || !content) return;
269
+ const observer = new MutationObserverConstructor(scheduler.schedule);
270
+ mutationObserver = observer;
271
+ observer.observe(content, {
272
+ attributes: true,
273
+ childList: true,
274
+ characterData: true,
275
+ subtree: true
276
+ });
277
+ }
278
+ function detachObservers() {
279
+ const view = options.viewportRef.value?.ownerDocument.defaultView;
280
+ resizeObserver?.disconnect();
281
+ mutationObserver?.disconnect();
282
+ resizeObserver = void 0;
283
+ mutationObserver = void 0;
284
+ view?.removeEventListener("resize", scheduler.schedule);
285
+ }
286
+ onMounted(() => {
287
+ attachObservers();
288
+ nextTick(scheduler.schedule);
289
+ });
290
+ onBeforeUnmount(() => {
291
+ detachObservers();
292
+ scheduler.cancel();
293
+ });
294
+ return {
295
+ metrics,
296
+ position,
297
+ update,
298
+ scheduleUpdate: scheduler.schedule,
299
+ getPosition,
300
+ getMaxPosition,
301
+ getOverflow
302
+ };
303
+ }
304
+ //#endregion
305
+ //#region src/components/scroll-area/useScrollAreaPointer.ts
306
+ function useScrollAreaPointer(options) {
307
+ let dragSession;
308
+ function onScrollbarPointerdown(axis, event) {
309
+ if (event.target !== event.currentTarget || event.button !== 0) return;
310
+ if (!options.metrics.getOverflow(axis)) return;
311
+ const scrollbar = event.currentTarget;
312
+ const thumb = scrollbar.firstElementChild;
313
+ const trackRect = scrollbar.getBoundingClientRect();
314
+ const thumbRect = thumb?.getBoundingClientRect();
315
+ const trackStart = axis === "x" ? trackRect.left : trackRect.top;
316
+ const trackSize = axis === "x" ? trackRect.width : trackRect.height;
317
+ const thumbSize = thumbRect ? axis === "x" ? thumbRect.width : thumbRect.height : 0;
318
+ const coordinate = getPointerCoordinate(axis, event);
319
+ const travel = Math.max(0, trackSize - thumbSize);
320
+ if (travel === 0) return;
321
+ event.preventDefault();
322
+ const ratio = clamp((coordinate - trackStart - thumbSize / 2) / travel, 0, 1);
323
+ options.controls.writeAxisPosition(axis, ratio * options.metrics.getMaxPosition(axis));
324
+ }
325
+ function onThumbPointerdown(axis, event) {
326
+ if (event.button !== 0 || event.isPrimary === false) return;
327
+ if (!options.metrics.getOverflow(axis)) return;
328
+ const scrollbar = getScrollbar(axis);
329
+ const thumb = event.currentTarget;
330
+ if (!scrollbar) return;
331
+ const trackRect = scrollbar.getBoundingClientRect();
332
+ const thumbRect = thumb.getBoundingClientRect();
333
+ const trackSize = axis === "x" ? trackRect.width : trackRect.height;
334
+ const thumbSize = axis === "x" ? thumbRect.width : thumbRect.height;
335
+ const travel = Math.max(0, trackSize - thumbSize);
336
+ if (travel === 0) return;
337
+ event.preventDefault();
338
+ event.stopPropagation();
339
+ stopDragging();
340
+ if (options.shouldFocusScrollbar()) scrollbar.focus({ preventScroll: true });
341
+ startDragging(axis, event, scrollbar, travel);
342
+ }
343
+ function startDragging(axis, event, scrollbar, travel) {
344
+ const view = scrollbar.ownerDocument.defaultView;
345
+ dragSession = {
346
+ axis,
347
+ pointerId: Number.isFinite(event.pointerId) ? event.pointerId : void 0,
348
+ startCoordinate: getPointerCoordinate(axis, event),
349
+ startPosition: options.metrics.getPosition(axis),
350
+ maxPosition: options.metrics.getMaxPosition(axis),
351
+ travel,
352
+ view
353
+ };
354
+ options.setDraggingAxis(axis);
355
+ view?.addEventListener("pointermove", onPointermove);
356
+ view?.addEventListener("pointerup", onPointerend);
357
+ view?.addEventListener("pointercancel", onPointerend);
358
+ }
359
+ function onPointermove(event) {
360
+ const session = dragSession;
361
+ if (!session || !isCurrentPointer(event, session)) return;
362
+ const delta = getPointerCoordinate(session.axis, event) - session.startCoordinate;
363
+ options.controls.writeAxisPosition(session.axis, session.startPosition + delta / session.travel * session.maxPosition);
364
+ }
365
+ function onPointerend(event) {
366
+ if (!dragSession || !isCurrentPointer(event, dragSession)) return;
367
+ stopDragging();
368
+ }
369
+ function stopDragging() {
370
+ const view = dragSession?.view;
371
+ view?.removeEventListener("pointermove", onPointermove);
372
+ view?.removeEventListener("pointerup", onPointerend);
373
+ view?.removeEventListener("pointercancel", onPointerend);
374
+ dragSession = void 0;
375
+ options.setDraggingAxis(null);
376
+ }
377
+ function getScrollbar(axis) {
378
+ return axis === "x" ? options.horizontalScrollbarRef.value : options.verticalScrollbarRef.value;
379
+ }
380
+ onBeforeUnmount(stopDragging);
381
+ return {
382
+ onScrollbarPointerdown,
383
+ onThumbPointerdown
384
+ };
385
+ }
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
+ //#endregion
393
+ //#region src/components/scroll-area/useScrollAreaVisibility.ts
394
+ function useScrollAreaVisibility(options) {
395
+ const isHovered = ref(false);
396
+ const hasFocusWithin = ref(false);
397
+ const isScrolling = ref(false);
398
+ const draggingAxis = ref(null);
399
+ let scrollEndTimer;
400
+ const renderHorizontalScrollbar = computed(() => options.horizontalEnabled.value && options.props.type !== "never");
401
+ const renderVerticalScrollbar = computed(() => options.verticalEnabled.value && options.props.type !== "never");
402
+ const horizontalScrollbarActive = computed(() => isScrollbarActive(options.props.type ?? "hover", options.horizontalEnabled.value, options.overflowX()));
403
+ const verticalScrollbarActive = computed(() => isScrollbarActive(options.props.type ?? "hover", options.verticalEnabled.value, options.overflowY()));
404
+ const horizontalScrollbarVisible = computed(() => isVisible(horizontalScrollbarActive.value, "x"));
405
+ const verticalScrollbarVisible = computed(() => isVisible(verticalScrollbarActive.value, "y"));
406
+ function isVisible(active, axis) {
407
+ if (!active) return false;
408
+ switch (options.props.type) {
409
+ case "always":
410
+ case "auto": return true;
411
+ case "hover": return isHovered.value || hasFocusWithin.value || draggingAxis.value === axis;
412
+ case "scroll": return isScrolling.value || draggingAxis.value === axis;
413
+ default: return false;
414
+ }
415
+ }
416
+ function showDuringScroll() {
417
+ isScrolling.value = true;
418
+ resetScrollEndTimer();
419
+ scrollEndTimer = setTimeout(() => {
420
+ isScrolling.value = false;
421
+ scrollEndTimer = void 0;
422
+ }, normalizeDelay(options.props.scrollHideDelay));
423
+ }
424
+ function setDraggingAxis(axis) {
425
+ draggingAxis.value = axis;
426
+ }
427
+ function onPointerenter() {
428
+ isHovered.value = true;
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();
446
+ });
447
+ onBeforeUnmount(resetScrollEndTimer);
448
+ return {
449
+ renderHorizontalScrollbar,
450
+ renderVerticalScrollbar,
451
+ horizontalScrollbarActive,
452
+ verticalScrollbarActive,
453
+ horizontalScrollbarVisible,
454
+ verticalScrollbarVisible,
455
+ showDuringScroll,
456
+ setDraggingAxis,
457
+ onPointerenter,
458
+ onPointerleave,
459
+ onFocusin,
460
+ onFocusout
461
+ };
462
+ }
463
+ function normalizeDelay(delay) {
464
+ return Number.isFinite(delay) ? Math.max(0, delay ?? 0) : 0;
465
+ }
466
+ //#endregion
467
+ //#region src/components/scroll-area/useScrollArea.ts
468
+ function useScrollArea(options) {
469
+ const rootRef = ref(null);
470
+ const viewportRef = ref(null);
471
+ const contentRef = ref(null);
472
+ const horizontalScrollbarRef = ref(null);
473
+ const verticalScrollbarRef = ref(null);
474
+ const horizontalEnabled = computed(() => isAxisEnabled(options.props.scrollbars, "x"));
475
+ const verticalEnabled = computed(() => isAxisEnabled(options.props.scrollbars, "y"));
476
+ const measurements = useScrollAreaMetrics({
477
+ viewportRef,
478
+ contentRef,
479
+ horizontalScrollbarRef,
480
+ verticalScrollbarRef,
481
+ horizontalEnabled,
482
+ verticalEnabled
483
+ });
484
+ const visibility = useScrollAreaVisibility({
485
+ props: options.props,
486
+ rootRef,
487
+ horizontalEnabled,
488
+ verticalEnabled,
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
502
+ });
503
+ const pointer = useScrollAreaPointer({
504
+ horizontalScrollbarRef,
505
+ verticalScrollbarRef,
506
+ metrics: measurements,
507
+ controls,
508
+ setDraggingAxis: visibility.setDraggingAxis,
509
+ shouldFocusScrollbar: () => !options.props.embedded
510
+ });
511
+ watch([
512
+ visibility.horizontalScrollbarActive,
513
+ visibility.verticalScrollbarActive,
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
532
+ };
533
+ }
534
+ //#endregion
535
+ //#region src/components/scroll-area/useScrollAreaPresentation.ts
536
+ function useScrollAreaPresentation(props, scrollArea) {
537
+ const generatedId = useId();
538
+ const viewportId = computed(() => `${props.id || generatedId}-viewport`);
539
+ const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
540
+ const rootAttrs = computed(() => getRootAttrs({
541
+ id: props.id,
542
+ class: "rp-scroll-area",
543
+ style: getRootStyle(props.scrollbarSize),
544
+ "data-type": props.type,
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
+ };
588
+ });
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
+ const slotProps = computed(() => ({
599
+ position: scrollArea.position.value,
600
+ overflowX: scrollArea.metrics.overflowX,
601
+ overflowY: scrollArea.metrics.overflowY,
602
+ scrollTo: scrollArea.scrollTo,
603
+ scrollBy: scrollArea.scrollBy,
604
+ update: scrollArea.update
605
+ }));
606
+ function getScrollbarAttrs(axis) {
607
+ const vertical = axis === "y";
608
+ const active = vertical ? scrollArea.verticalScrollbarActive.value : scrollArea.horizontalScrollbarActive.value;
609
+ const visible = vertical ? scrollArea.verticalScrollbarVisible.value : scrollArea.horizontalScrollbarVisible.value;
610
+ return {
611
+ ...getPartAttrs("scrollbar", { class: ["rp-scroll-area__scrollbar", `rp-scroll-area__scrollbar--${vertical ? "vertical" : "horizontal"}`] }),
612
+ role: "scrollbar",
613
+ tabindex: !props.embedded && active ? 0 : -1,
614
+ "aria-controls": scrollArea.viewportRef.value?.id || void 0,
615
+ "aria-orientation": vertical ? "vertical" : "horizontal",
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)
624
+ };
625
+ }
626
+ function getThumbAttrs(axis) {
627
+ const horizontal = axis === "x";
628
+ return getPartAttrs("thumb", {
629
+ class: "rp-scroll-area__thumb",
630
+ style: {
631
+ "--_rp-scroll-area-thumb-size": `${horizontal ? scrollArea.metrics.horizontalThumbSize : scrollArea.metrics.verticalThumbSize}%`,
632
+ "--_rp-scroll-area-thumb-offset": `${horizontal ? scrollArea.metrics.horizontalThumbOffset : scrollArea.metrics.verticalThumbOffset}%`
633
+ }
634
+ });
635
+ }
636
+ return {
637
+ rootAttrs,
638
+ viewportAttrs,
639
+ contentAttrs,
640
+ horizontalScrollbarAttrs,
641
+ verticalScrollbarAttrs,
642
+ horizontalThumbAttrs,
643
+ verticalThumbAttrs,
644
+ cornerAttrs,
645
+ slotProps
646
+ };
647
+ }
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
+ //#endregion
656
+ //#region src/components/scroll-area/scroll-area.vue?vue&type=script&setup=true&vapor=true&lang.ts
657
+ var t0 = template("<div data-v-f5c4e940><div data-v-f5c4e940></div>");
658
+ var t1 = template("<div data-v-f5c4e940>");
659
+ var t2 = template("<div data-v-f5c4e940><div data-v-f5c4e940><div data-v-f5c4e940></div></div>", 1);
660
+ delegateEvents("pointerdown", "keydown");
661
+ //#endregion
662
+ //#region src/components/scroll-area/scroll-area.vue
663
+ var scroll_area_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
664
+ name: "RpScrollArea",
665
+ inheritAttrs: false,
666
+ __name: "scroll-area",
667
+ props: {
668
+ id: String,
669
+ embedded: {
670
+ type: Boolean,
671
+ default: false
672
+ },
673
+ type: {
674
+ type: String,
675
+ default: "hover"
676
+ },
677
+ scrollbars: {
678
+ type: [String, Boolean],
679
+ default: "both"
680
+ },
681
+ scrollbarSize: {
682
+ type: [Number, String],
683
+ default: 10
684
+ },
685
+ scrollHideDelay: {
686
+ type: Number,
687
+ default: 600
688
+ },
689
+ ariaLabel: String,
690
+ ariaLabelledby: String,
691
+ ariaDescribedby: String,
692
+ viewportAttrs: Object,
693
+ contentAttrs: Object,
694
+ classNames: Object,
695
+ styles: Object
696
+ },
697
+ emits: [
698
+ "scroll",
699
+ "scrollPositionChange",
700
+ "reachTop",
701
+ "reachBottom",
702
+ "reachLeft",
703
+ "reachRight"
704
+ ],
705
+ setup(__props, { expose: __expose, emit: __emit }) {
706
+ const props = __props;
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);
719
+ __expose({
720
+ viewport: viewportRef,
721
+ scrollTo,
722
+ scrollBy,
723
+ update
724
+ });
725
+ const _setTemplateRef = createTemplateRefSetter();
726
+ const n14 = t2();
727
+ const n2 = child(n14);
728
+ const n1 = child(n2);
729
+ renderEffect(() => {
730
+ setDynamicProps(n14, [unref(rootAttrs)]);
731
+ setDynamicProps(n2, [unref(viewportAttrs)]);
732
+ setDynamicProps(n1, [unref(contentAttrs)]);
733
+ });
734
+ setInsertionState(n1, null, 0);
735
+ createSlot("default", { $: [() => unref(slotProps)] }, null, 1);
736
+ _setTemplateRef(n1, contentRef, null, "contentRef");
737
+ _setTemplateRef(n2, viewportRef, null, "viewportRef");
738
+ setInsertionState(n14, null, 1);
739
+ createIf(() => unref(renderHorizontalScrollbar), () => {
740
+ const n6 = t0();
741
+ const n5 = child(n6);
742
+ n5.$evtpointerdown = createInvoker(($event) => unref(onThumbPointerdown)("x", $event));
743
+ n6.$evtkeydown = createInvoker(($event) => unref(onScrollbarKeydown)("x", $event));
744
+ n6.$evtpointerdown = createInvoker(($event) => unref(onScrollbarPointerdown)("x", $event));
745
+ on(n6, "wheel", ($event) => unref(onScrollbarWheel)("x", $event));
746
+ _setTemplateRef(n6, horizontalScrollbarRef, null, "horizontalScrollbarRef");
747
+ renderEffect(() => {
748
+ setDynamicProps(n6, [unref(horizontalScrollbarAttrs)]);
749
+ setDynamicProps(n5, [unref(horizontalThumbAttrs)]);
750
+ });
751
+ return n6;
752
+ });
753
+ setInsertionState(n14, null, 2);
754
+ createIf(() => unref(renderVerticalScrollbar), () => {
755
+ const n10 = t0();
756
+ const n9 = child(n10);
757
+ n9.$evtpointerdown = createInvoker(($event) => unref(onThumbPointerdown)("y", $event));
758
+ n10.$evtkeydown = createInvoker(($event) => unref(onScrollbarKeydown)("y", $event));
759
+ n10.$evtpointerdown = createInvoker(($event) => unref(onScrollbarPointerdown)("y", $event));
760
+ on(n10, "wheel", ($event) => unref(onScrollbarWheel)("y", $event));
761
+ _setTemplateRef(n10, verticalScrollbarRef, null, "verticalScrollbarRef");
762
+ renderEffect(() => {
763
+ setDynamicProps(n10, [unref(verticalScrollbarAttrs)]);
764
+ setDynamicProps(n9, [unref(verticalThumbAttrs)]);
765
+ });
766
+ return n10;
767
+ });
768
+ setInsertionState(n14, null, 3);
769
+ createIf(() => unref(renderHorizontalScrollbar) && unref(renderVerticalScrollbar), () => {
770
+ const n13 = t1();
771
+ renderEffect(() => setDynamicProps(n13, [unref(cornerAttrs)]));
772
+ return n13;
773
+ });
774
+ _setTemplateRef(n14, rootRef, null, "rootRef");
775
+ return n14;
776
+ }
777
+ }), [["__scopeId", "data-v-f5c4e940"]]);
778
+ //#endregion
779
+ export { scroll_area_default as t };