akar 2.0.10 → 2.0.12
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/dist/AlertDialog/AlertDialogRoot.cjs +4 -0
- package/dist/AlertDialog/AlertDialogRoot.cjs.map +1 -1
- package/dist/AlertDialog/AlertDialogRoot.js +4 -0
- package/dist/AlertDialog/AlertDialogRoot.js.map +1 -1
- package/dist/Collection/Collection.cjs +2 -1
- package/dist/Collection/Collection.cjs.map +1 -1
- package/dist/Collection/Collection.js +2 -1
- package/dist/Collection/Collection.js.map +1 -1
- package/dist/Combobox/ComboboxContent.cjs +4 -0
- package/dist/Combobox/ComboboxContent.cjs.map +1 -1
- package/dist/Combobox/ComboboxContent.js +4 -0
- package/dist/Combobox/ComboboxContent.js.map +1 -1
- package/dist/Combobox/ComboboxContentImpl.cjs +4 -0
- package/dist/Combobox/ComboboxContentImpl.cjs.map +1 -1
- package/dist/Combobox/ComboboxContentImpl.js +4 -0
- package/dist/Combobox/ComboboxContentImpl.js.map +1 -1
- package/dist/DatePicker/DatePickerContent.cjs +4 -0
- package/dist/DatePicker/DatePickerContent.cjs.map +1 -1
- package/dist/DatePicker/DatePickerContent.js +4 -0
- package/dist/DatePicker/DatePickerContent.js.map +1 -1
- package/dist/DateRangePicker/DateRangePickerContent.cjs +4 -0
- package/dist/DateRangePicker/DateRangePickerContent.cjs.map +1 -1
- package/dist/DateRangePicker/DateRangePickerContent.js +4 -0
- package/dist/DateRangePicker/DateRangePickerContent.js.map +1 -1
- package/dist/Dialog/DialogContent.cjs +14 -9
- package/dist/Dialog/DialogContent.cjs.map +1 -1
- package/dist/Dialog/DialogContent.js +15 -10
- package/dist/Dialog/DialogContent.js.map +1 -1
- package/dist/Dialog/DialogContentImpl.cjs +8 -1
- package/dist/Dialog/DialogContentImpl.cjs.map +1 -1
- package/dist/Dialog/DialogContentImpl.js +8 -1
- package/dist/Dialog/DialogContentImpl.js.map +1 -1
- package/dist/Dialog/DialogContentModal.cjs +20 -3
- package/dist/Dialog/DialogContentModal.cjs.map +1 -1
- package/dist/Dialog/DialogContentModal.js +21 -4
- package/dist/Dialog/DialogContentModal.js.map +1 -1
- package/dist/Dialog/DialogContentNonModal.cjs +18 -2
- package/dist/Dialog/DialogContentNonModal.cjs.map +1 -1
- package/dist/Dialog/DialogContentNonModal.js +19 -3
- package/dist/Dialog/DialogContentNonModal.js.map +1 -1
- package/dist/Dialog/DialogOverlay.cjs +12 -6
- package/dist/Dialog/DialogOverlay.cjs.map +1 -1
- package/dist/Dialog/DialogOverlay.js +13 -7
- package/dist/Dialog/DialogOverlay.js.map +1 -1
- package/dist/Dialog/DialogOverlayImpl.cjs +10 -1
- package/dist/Dialog/DialogOverlayImpl.cjs.map +1 -1
- package/dist/Dialog/DialogOverlayImpl.js +11 -2
- package/dist/Dialog/DialogOverlayImpl.js.map +1 -1
- package/dist/Dialog/DialogRoot.cjs +7 -1
- package/dist/Dialog/DialogRoot.cjs.map +1 -1
- package/dist/Dialog/DialogRoot.js +7 -1
- package/dist/Dialog/DialogRoot.js.map +1 -1
- package/dist/DismissableLayer/DismissableLayer.cjs +20 -4
- package/dist/DismissableLayer/DismissableLayer.cjs.map +1 -1
- package/dist/DismissableLayer/DismissableLayer.js +20 -4
- package/dist/DismissableLayer/DismissableLayer.js.map +1 -1
- package/dist/Drawer/DrawerClose.cjs +48 -0
- package/dist/Drawer/DrawerClose.cjs.map +1 -0
- package/dist/Drawer/DrawerClose.js +42 -0
- package/dist/Drawer/DrawerClose.js.map +1 -0
- package/dist/Drawer/DrawerContent.cjs +139 -0
- package/dist/Drawer/DrawerContent.cjs.map +1 -0
- package/dist/Drawer/DrawerContent.js +133 -0
- package/dist/Drawer/DrawerContent.js.map +1 -0
- package/dist/Drawer/DrawerContentImpl.cjs +298 -0
- package/dist/Drawer/DrawerContentImpl.cjs.map +1 -0
- package/dist/Drawer/DrawerContentImpl.js +292 -0
- package/dist/Drawer/DrawerContentImpl.js.map +1 -0
- package/dist/Drawer/DrawerDescription.cjs +45 -0
- package/dist/Drawer/DrawerDescription.cjs.map +1 -0
- package/dist/Drawer/DrawerDescription.js +39 -0
- package/dist/Drawer/DrawerDescription.js.map +1 -0
- package/dist/Drawer/DrawerHandle.cjs +48 -0
- package/dist/Drawer/DrawerHandle.cjs.map +1 -0
- package/dist/Drawer/DrawerHandle.js +42 -0
- package/dist/Drawer/DrawerHandle.js.map +1 -0
- package/dist/Drawer/DrawerIndent.cjs +78 -0
- package/dist/Drawer/DrawerIndent.cjs.map +1 -0
- package/dist/Drawer/DrawerIndent.js +72 -0
- package/dist/Drawer/DrawerIndent.js.map +1 -0
- package/dist/Drawer/DrawerIndentBackground.cjs +49 -0
- package/dist/Drawer/DrawerIndentBackground.cjs.map +1 -0
- package/dist/Drawer/DrawerIndentBackground.js +43 -0
- package/dist/Drawer/DrawerIndentBackground.js.map +1 -0
- package/dist/Drawer/DrawerOverlay.cjs +66 -0
- package/dist/Drawer/DrawerOverlay.cjs.map +1 -0
- package/dist/Drawer/DrawerOverlay.js +60 -0
- package/dist/Drawer/DrawerOverlay.js.map +1 -0
- package/dist/Drawer/DrawerOverlayImpl.cjs +69 -0
- package/dist/Drawer/DrawerOverlayImpl.cjs.map +1 -0
- package/dist/Drawer/DrawerOverlayImpl.js +63 -0
- package/dist/Drawer/DrawerOverlayImpl.js.map +1 -0
- package/dist/Drawer/DrawerPortal.cjs +47 -0
- package/dist/Drawer/DrawerPortal.cjs.map +1 -0
- package/dist/Drawer/DrawerPortal.js +41 -0
- package/dist/Drawer/DrawerPortal.js.map +1 -0
- package/dist/Drawer/DrawerProvider.cjs +82 -0
- package/dist/Drawer/DrawerProvider.cjs.map +1 -0
- package/dist/Drawer/DrawerProvider.js +70 -0
- package/dist/Drawer/DrawerProvider.js.map +1 -0
- package/dist/Drawer/DrawerRoot.cjs +197 -0
- package/dist/Drawer/DrawerRoot.cjs.map +1 -0
- package/dist/Drawer/DrawerRoot.js +185 -0
- package/dist/Drawer/DrawerRoot.js.map +1 -0
- package/dist/Drawer/DrawerSwipeArea.cjs +87 -0
- package/dist/Drawer/DrawerSwipeArea.cjs.map +1 -0
- package/dist/Drawer/DrawerSwipeArea.js +81 -0
- package/dist/Drawer/DrawerSwipeArea.js.map +1 -0
- package/dist/Drawer/DrawerTitle.cjs +45 -0
- package/dist/Drawer/DrawerTitle.cjs.map +1 -0
- package/dist/Drawer/DrawerTitle.js +39 -0
- package/dist/Drawer/DrawerTitle.js.map +1 -0
- package/dist/Drawer/DrawerTrigger.cjs +64 -0
- package/dist/Drawer/DrawerTrigger.cjs.map +1 -0
- package/dist/Drawer/DrawerTrigger.js +58 -0
- package/dist/Drawer/DrawerTrigger.js.map +1 -0
- package/dist/Drawer/DrawerViewport.cjs +49 -0
- package/dist/Drawer/DrawerViewport.cjs.map +1 -0
- package/dist/Drawer/DrawerViewport.js +43 -0
- package/dist/Drawer/DrawerViewport.js.map +1 -0
- package/dist/Drawer/utils.cjs +185 -0
- package/dist/Drawer/utils.cjs.map +1 -0
- package/dist/Drawer/utils.js +149 -0
- package/dist/Drawer/utils.js.map +1 -0
- package/dist/FocusScope/FocusScope.cjs +31 -11
- package/dist/FocusScope/FocusScope.cjs.map +1 -1
- package/dist/FocusScope/FocusScope.js +32 -12
- package/dist/FocusScope/FocusScope.js.map +1 -1
- package/dist/HoverCard/HoverCardContent.cjs +4 -0
- package/dist/HoverCard/HoverCardContent.cjs.map +1 -1
- package/dist/HoverCard/HoverCardContent.js +4 -0
- package/dist/HoverCard/HoverCardContent.js.map +1 -1
- package/dist/HoverCard/HoverCardContentImpl.cjs +4 -0
- package/dist/HoverCard/HoverCardContentImpl.cjs.map +1 -1
- package/dist/HoverCard/HoverCardContentImpl.js +4 -0
- package/dist/HoverCard/HoverCardContentImpl.js.map +1 -1
- package/dist/Popover/PopoverContent.cjs +4 -0
- package/dist/Popover/PopoverContent.cjs.map +1 -1
- package/dist/Popover/PopoverContent.js +4 -0
- package/dist/Popover/PopoverContent.js.map +1 -1
- package/dist/Popover/PopoverContentImpl.cjs +4 -0
- package/dist/Popover/PopoverContentImpl.cjs.map +1 -1
- package/dist/Popover/PopoverContentImpl.js +4 -0
- package/dist/Popover/PopoverContentImpl.js.map +1 -1
- package/dist/Popover/PopoverContentModal.cjs +4 -0
- package/dist/Popover/PopoverContentModal.cjs.map +1 -1
- package/dist/Popover/PopoverContentModal.js +4 -0
- package/dist/Popover/PopoverContentModal.js.map +1 -1
- package/dist/Popover/PopoverContentNonModal.cjs +4 -0
- package/dist/Popover/PopoverContentNonModal.cjs.map +1 -1
- package/dist/Popover/PopoverContentNonModal.js +4 -0
- package/dist/Popover/PopoverContentNonModal.js.map +1 -1
- package/dist/Popper/PopperContent.cjs +14 -4
- package/dist/Popper/PopperContent.cjs.map +1 -1
- package/dist/Popper/PopperContent.js +14 -4
- package/dist/Popper/PopperContent.js.map +1 -1
- package/dist/Popper/utils.cjs +10 -5
- package/dist/Popper/utils.cjs.map +1 -1
- package/dist/Popper/utils.js +10 -5
- package/dist/Popper/utils.js.map +1 -1
- package/dist/Rating/RatingItem.cjs +66 -0
- package/dist/Rating/RatingItem.cjs.map +1 -0
- package/dist/Rating/RatingItem.js +54 -0
- package/dist/Rating/RatingItem.js.map +1 -0
- package/dist/Rating/RatingItemIndicator.cjs +89 -0
- package/dist/Rating/RatingItemIndicator.cjs.map +1 -0
- package/dist/Rating/RatingItemIndicator.js +83 -0
- package/dist/Rating/RatingItemIndicator.js.map +1 -0
- package/dist/Rating/RatingRoot.cjs +136 -0
- package/dist/Rating/RatingRoot.cjs.map +1 -0
- package/dist/Rating/RatingRoot.js +124 -0
- package/dist/Rating/RatingRoot.js.map +1 -0
- package/dist/Select/SelectContent.cjs +4 -0
- package/dist/Select/SelectContent.cjs.map +1 -1
- package/dist/Select/SelectContent.js +4 -0
- package/dist/Select/SelectContent.js.map +1 -1
- package/dist/Select/SelectContentImpl.cjs +4 -0
- package/dist/Select/SelectContentImpl.cjs.map +1 -1
- package/dist/Select/SelectContentImpl.js +4 -0
- package/dist/Select/SelectContentImpl.js.map +1 -1
- package/dist/Select/SelectPopperPosition.cjs +4 -0
- package/dist/Select/SelectPopperPosition.cjs.map +1 -1
- package/dist/Select/SelectPopperPosition.js +4 -0
- package/dist/Select/SelectPopperPosition.js.map +1 -1
- package/dist/composables/useDrawerSnapPoints.cjs +130 -0
- package/dist/composables/useDrawerSnapPoints.cjs.map +1 -0
- package/dist/composables/useDrawerSnapPoints.js +124 -0
- package/dist/composables/useDrawerSnapPoints.js.map +1 -0
- package/dist/composables/useSwipeDismiss.cjs +401 -0
- package/dist/composables/useSwipeDismiss.cjs.map +1 -0
- package/dist/composables/useSwipeDismiss.js +395 -0
- package/dist/composables/useSwipeDismiss.js.map +1 -0
- package/dist/constant/components.cjs +20 -0
- package/dist/constant/components.cjs.map +1 -1
- package/dist/constant/components.js +20 -0
- package/dist/constant/components.js.map +1 -1
- package/dist/constant.d.cts +2 -0
- package/dist/constant.d.cts.map +1 -1
- package/dist/constant.d.ts +2 -0
- package/dist/constant.d.ts.map +1 -1
- package/dist/index.cjs +44 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -2
- package/dist/index2.d.cts.map +1 -1
- package/dist/index3.d.cts +5 -9
- package/dist/index3.d.cts.map +1 -1
- package/dist/index3.d.ts +1 -5
- package/dist/index3.d.ts.map +1 -1
- package/dist/index4.d.cts +1647 -1216
- package/dist/index4.d.cts.map +1 -1
- package/dist/index4.d.ts +1635 -1204
- package/dist/index4.d.ts.map +1 -1
- package/dist/internal.cjs +0 -1
- package/dist/internal.d.cts +3 -3
- package/dist/internal.d.cts.map +1 -1
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +0 -1
- package/dist/namespaced/index.cjs +22 -0
- package/dist/namespaced/index.d.cts +22 -2
- package/dist/namespaced/index.d.mts +22 -2
- package/dist/namespaced/index.mjs +22 -2
- package/dist/nuxt/index.d.cts +2 -1
- package/dist/nuxt/index.d.mts +2 -1
- package/dist/resolver/index.d.cts +2 -1
- package/dist/resolver/index.d.mts +2 -1
- package/dist/shared/useSize.cjs +6 -2
- package/dist/shared/useSize.cjs.map +1 -1
- package/dist/shared/useSize.js +7 -3
- package/dist/shared/useSize.js.map +1 -1
- package/dist/shared.cjs +0 -2
- package/dist/shared.d.cts +2 -2
- package/dist/shared.d.ts +2 -2
- package/dist/shared.js +1 -2
- package/dist/utils/style.cjs +1 -1
- package/dist/utils/style.cjs.map +1 -1
- package/dist/utils/style.js +1 -1
- package/dist/utils/style.js.map +1 -1
- package/package.json +1 -1
- package/src/Collection/Collection.ts +2 -1
- package/src/Dialog/DialogContent.vue +9 -1
- package/src/Dialog/DialogContentImpl.vue +9 -2
- package/src/Dialog/DialogContentModal.vue +21 -3
- package/src/Dialog/DialogContentNonModal.vue +22 -3
- package/src/Dialog/DialogOverlay.vue +4 -0
- package/src/Dialog/DialogOverlayImpl.vue +8 -2
- package/src/Dialog/DialogRoot.vue +10 -1
- package/src/DismissableLayer/DismissableLayer.vue +44 -8
- package/src/Drawer/DrawerClose.vue +25 -0
- package/src/Drawer/DrawerContent.vue +102 -0
- package/src/Drawer/DrawerContentImpl.vue +395 -0
- package/src/Drawer/DrawerDescription.vue +24 -0
- package/src/Drawer/DrawerHandle.vue +25 -0
- package/src/Drawer/DrawerIndent.vue +64 -0
- package/src/Drawer/DrawerIndentBackground.vue +26 -0
- package/src/Drawer/DrawerOverlay.vue +42 -0
- package/src/Drawer/DrawerOverlayImpl.vue +55 -0
- package/src/Drawer/DrawerPortal.vue +17 -0
- package/src/Drawer/DrawerProvider.vue +95 -0
- package/src/Drawer/DrawerRoot.vue +252 -0
- package/src/Drawer/DrawerSwipeArea.vue +74 -0
- package/src/Drawer/DrawerTitle.vue +24 -0
- package/src/Drawer/DrawerTrigger.vue +45 -0
- package/src/Drawer/DrawerViewport.vue +34 -0
- package/src/Drawer/composables/useDrawerSnapPoints.ts +207 -0
- package/src/Drawer/composables/useSwipeDismiss.ts +586 -0
- package/src/Drawer/index.ts +74 -0
- package/src/Drawer/utils.ts +205 -0
- package/src/FocusScope/FocusScope.vue +82 -20
- package/src/Popper/PopperContent.vue +11 -3
- package/src/Popper/utils.ts +21 -11
- package/src/Rating/RatingItem.vue +1 -0
- package/src/Rating/RatingItemIndicator.vue +3 -2
- package/src/Rating/RatingRoot.vue +6 -2
- package/src/Rating/index.ts +3 -3
- package/src/Splitter/utils/style.ts +1 -1
- package/src/Tree/TreeRoot.vue +2 -2
- package/src/index.ts +2 -0
- package/src/shared/index.ts +0 -1
- package/src/shared/useEmitAsProps.test-d.ts +0 -1
- package/src/shared/useSize.ts +9 -4
- package/dist/shared/trap-focus.cjs +0 -35
- package/dist/shared/trap-focus.cjs.map +0 -1
- package/dist/shared/trap-focus.js +0 -30
- package/dist/shared/trap-focus.js.map +0 -1
- package/src/shared/trap-focus.ts +0 -44
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// packages/core/src/Drawer/utils.ts
|
|
2
|
+
|
|
3
|
+
export type SwipeDirection = 'up' | 'down' | 'left' | 'right'
|
|
4
|
+
export type DrawerSnapPoint = number | string
|
|
5
|
+
|
|
6
|
+
export const DRAWER_CSS_VARS = {
|
|
7
|
+
swipeMovementX: '--drawer-swipe-movement-x',
|
|
8
|
+
swipeMovementY: '--drawer-swipe-movement-y',
|
|
9
|
+
snapPointOffset: '--drawer-snap-point-offset',
|
|
10
|
+
height: '--drawer-height',
|
|
11
|
+
frontmostHeight: '--drawer-frontmost-height',
|
|
12
|
+
swipeProgress: '--drawer-swipe-progress',
|
|
13
|
+
swipeStrength: '--drawer-swipe-strength',
|
|
14
|
+
nestedDrawers: '--nested-drawers',
|
|
15
|
+
} as const
|
|
16
|
+
|
|
17
|
+
export interface NestedSwipeProgressStore {
|
|
18
|
+
getSnapshot: () => number
|
|
19
|
+
subscribe: (listener: () => void) => () => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createNestedSwipeProgressStore(): NestedSwipeProgressStore & {
|
|
23
|
+
set: (progress: number) => void
|
|
24
|
+
} {
|
|
25
|
+
let progress = 0
|
|
26
|
+
const listeners = new Set<() => void>()
|
|
27
|
+
return {
|
|
28
|
+
getSnapshot: () => progress,
|
|
29
|
+
subscribe(listener) {
|
|
30
|
+
listeners.add(listener)
|
|
31
|
+
return () => listeners.delete(listener)
|
|
32
|
+
},
|
|
33
|
+
set(next: number) {
|
|
34
|
+
if (next !== progress) {
|
|
35
|
+
progress = next
|
|
36
|
+
listeners.forEach(l => l())
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getDisplacement(
|
|
43
|
+
direction: SwipeDirection,
|
|
44
|
+
deltaX: number,
|
|
45
|
+
deltaY: number,
|
|
46
|
+
): number {
|
|
47
|
+
switch (direction) {
|
|
48
|
+
case 'up': return -deltaY
|
|
49
|
+
case 'down': return deltaY
|
|
50
|
+
case 'left': return -deltaX
|
|
51
|
+
case 'right': return deltaX
|
|
52
|
+
default: return 0
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// BaseUI swipe release scalar constants (DrawerViewport.tsx:41-46)
|
|
57
|
+
const MIN_SWIPE_RELEASE_VELOCITY = 0.2
|
|
58
|
+
const MAX_SWIPE_RELEASE_VELOCITY = 4
|
|
59
|
+
const MIN_SWIPE_RELEASE_DURATION_MS = 80
|
|
60
|
+
const MAX_SWIPE_RELEASE_DURATION_MS = 360
|
|
61
|
+
const MIN_SWIPE_RELEASE_SCALAR = 0.1
|
|
62
|
+
const MAX_SWIPE_RELEASE_SCALAR = 1
|
|
63
|
+
|
|
64
|
+
function clamp(v: number, lo: number, hi: number): number {
|
|
65
|
+
return Math.max(lo, Math.min(hi, v))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Computes a 0.1 - 1.0 scalar for the `--drawer-swipe-strength` CSS var.
|
|
70
|
+
* Ported from BaseUI `DrawerViewport.tsx:resolveSwipeRelease` (lines 243-337).
|
|
71
|
+
*
|
|
72
|
+
* The scalar is derived from how much further the drawer still has to travel
|
|
73
|
+
* vs how fast the user flung it. A short remaining distance with high velocity
|
|
74
|
+
* → near-zero scalar (fast release). A long distance / low velocity → near-1
|
|
75
|
+
* (default release).
|
|
76
|
+
*
|
|
77
|
+
* Returns `null` when the formula is degenerate (no velocity, no distance, or
|
|
78
|
+
* moving in the wrong direction).
|
|
79
|
+
*/
|
|
80
|
+
export function computeSwipeReleaseScalar(params: {
|
|
81
|
+
direction: SwipeDirection
|
|
82
|
+
size: number
|
|
83
|
+
axisDelta: number
|
|
84
|
+
snapPointOffset: number
|
|
85
|
+
releaseVelocity: number
|
|
86
|
+
}): number | null {
|
|
87
|
+
const { direction, size, axisDelta, snapPointOffset, releaseVelocity } = params
|
|
88
|
+
if (!Number.isFinite(size) || size <= 0)
|
|
89
|
+
return null
|
|
90
|
+
|
|
91
|
+
// Seed the translation with the active snap offset along the dismiss axis so
|
|
92
|
+
// horizontal drawers honor snap points too: down/right collapse toward
|
|
93
|
+
// positive translation, up/left toward negative.
|
|
94
|
+
let baseOffset = 0
|
|
95
|
+
if (direction === 'down' || direction === 'right')
|
|
96
|
+
baseOffset = snapPointOffset
|
|
97
|
+
else if (direction === 'up' || direction === 'left')
|
|
98
|
+
baseOffset = -snapPointOffset
|
|
99
|
+
|
|
100
|
+
const translation = baseOffset + axisDelta
|
|
101
|
+
const translationAlongDirection
|
|
102
|
+
= (direction === 'left' || direction === 'up') ? -translation : translation
|
|
103
|
+
const remainingDistance = Math.max(0, size - translationAlongDirection)
|
|
104
|
+
if (!Number.isFinite(remainingDistance) || remainingDistance <= 0)
|
|
105
|
+
return null
|
|
106
|
+
|
|
107
|
+
const directionalVelocity
|
|
108
|
+
= (direction === 'left' || direction === 'up') ? -releaseVelocity : releaseVelocity
|
|
109
|
+
if (!Number.isFinite(directionalVelocity) || directionalVelocity <= MIN_SWIPE_RELEASE_VELOCITY)
|
|
110
|
+
return null
|
|
111
|
+
|
|
112
|
+
const clampedVelocity = clamp(
|
|
113
|
+
directionalVelocity,
|
|
114
|
+
MIN_SWIPE_RELEASE_VELOCITY,
|
|
115
|
+
MAX_SWIPE_RELEASE_VELOCITY,
|
|
116
|
+
)
|
|
117
|
+
const durationMs = clamp(
|
|
118
|
+
remainingDistance / clampedVelocity,
|
|
119
|
+
MIN_SWIPE_RELEASE_DURATION_MS,
|
|
120
|
+
MAX_SWIPE_RELEASE_DURATION_MS,
|
|
121
|
+
)
|
|
122
|
+
if (!Number.isFinite(durationMs))
|
|
123
|
+
return null
|
|
124
|
+
|
|
125
|
+
const normalized
|
|
126
|
+
= (durationMs - MIN_SWIPE_RELEASE_DURATION_MS)
|
|
127
|
+
/ (MAX_SWIPE_RELEASE_DURATION_MS - MIN_SWIPE_RELEASE_DURATION_MS)
|
|
128
|
+
const scalar = clamp(
|
|
129
|
+
MIN_SWIPE_RELEASE_SCALAR + normalized * (MAX_SWIPE_RELEASE_SCALAR - MIN_SWIPE_RELEASE_SCALAR),
|
|
130
|
+
MIN_SWIPE_RELEASE_SCALAR,
|
|
131
|
+
MAX_SWIPE_RELEASE_SCALAR,
|
|
132
|
+
)
|
|
133
|
+
if (!Number.isFinite(scalar) || scalar <= 0)
|
|
134
|
+
return null
|
|
135
|
+
return scalar
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const MATRIX_RE = /matrix(?:3d)?\(([^)]+)\)/
|
|
139
|
+
|
|
140
|
+
export function getElementTransform(element: HTMLElement): {
|
|
141
|
+
x: number
|
|
142
|
+
y: number
|
|
143
|
+
scale: number
|
|
144
|
+
} {
|
|
145
|
+
const style = window.getComputedStyle(element)
|
|
146
|
+
const transform = style.transform
|
|
147
|
+
let x = 0
|
|
148
|
+
let y = 0
|
|
149
|
+
let scale = 1
|
|
150
|
+
if (transform && transform !== 'none') {
|
|
151
|
+
const matrix = transform.match(MATRIX_RE)
|
|
152
|
+
if (matrix) {
|
|
153
|
+
const v = matrix[1].split(', ').map(Number)
|
|
154
|
+
if (v.length === 6) {
|
|
155
|
+
x = v[4]
|
|
156
|
+
y = v[5]
|
|
157
|
+
scale = Math.sqrt(v[0] * v[0] + v[1] * v[1])
|
|
158
|
+
}
|
|
159
|
+
else if (v.length === 16) {
|
|
160
|
+
x = v[12]
|
|
161
|
+
y = v[13]
|
|
162
|
+
scale = v[0]
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return { x, y, scale }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let drawerCssVarsRegistered = false
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Removes CSS variable inheritance for high-frequency drawer swipe vars.
|
|
173
|
+
* Uses proper syntax types matching BaseUI:
|
|
174
|
+
* - Length vars (<length>) with initialValue '0px' for use in calc()/translateY()
|
|
175
|
+
* - Number vars (<number>) for opacity/strength scalars
|
|
176
|
+
*/
|
|
177
|
+
export function registerDrawerCssProperties() {
|
|
178
|
+
if (drawerCssVarsRegistered || typeof CSS === 'undefined' || !CSS.registerProperty)
|
|
179
|
+
return
|
|
180
|
+
|
|
181
|
+
const lengthVars = [
|
|
182
|
+
DRAWER_CSS_VARS.swipeMovementX,
|
|
183
|
+
DRAWER_CSS_VARS.swipeMovementY,
|
|
184
|
+
DRAWER_CSS_VARS.snapPointOffset,
|
|
185
|
+
]
|
|
186
|
+
for (const name of lengthVars) {
|
|
187
|
+
try {
|
|
188
|
+
CSS.registerProperty({ name, syntax: '<length>', inherits: false, initialValue: '0px' })
|
|
189
|
+
}
|
|
190
|
+
catch {}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const numberVars = [
|
|
194
|
+
{ name: DRAWER_CSS_VARS.swipeProgress, initialValue: '0' },
|
|
195
|
+
{ name: DRAWER_CSS_VARS.swipeStrength, initialValue: '1' },
|
|
196
|
+
]
|
|
197
|
+
for (const { name, initialValue } of numberVars) {
|
|
198
|
+
try {
|
|
199
|
+
CSS.registerProperty({ name, syntax: '<number>', inherits: false, initialValue })
|
|
200
|
+
}
|
|
201
|
+
catch {}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
drawerCssVarsRegistered = true
|
|
205
|
+
}
|
|
@@ -30,12 +30,22 @@ export interface FocusScopeProps extends PrimitiveProps {
|
|
|
30
30
|
* @defaultValue false
|
|
31
31
|
*/
|
|
32
32
|
trapped?: boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether the scope is currently visible. Lets a consumer keep the scope
|
|
36
|
+
* mounted but hidden (e.g. `display: none`) and still get correct auto-focus:
|
|
37
|
+
* the mount auto-focus is skipped while not present, and re-runs when it
|
|
38
|
+
* becomes present again. Defaults to `true` so consumers that mount the scope
|
|
39
|
+
* only while visible are unaffected.
|
|
40
|
+
* @defaultValue true
|
|
41
|
+
*/
|
|
42
|
+
present?: boolean;
|
|
33
43
|
}
|
|
34
44
|
</script>
|
|
35
45
|
|
|
36
46
|
<script setup lang="ts">
|
|
37
47
|
import { isClient } from '@vueuse/shared';
|
|
38
|
-
import { nextTick, reactive, ref, watchEffect } from 'vue';
|
|
48
|
+
import { nextTick, reactive, ref, watch, watchEffect } from 'vue';
|
|
39
49
|
import { Primitive } from '@/Primitive';
|
|
40
50
|
import { createFocusScopesStack } from './stack';
|
|
41
51
|
import {
|
|
@@ -157,6 +167,25 @@ watchEffect((cleanupFn) => {
|
|
|
157
167
|
});
|
|
158
168
|
});
|
|
159
169
|
|
|
170
|
+
// Dispatch the mount auto-focus event and move focus to the first tabbable
|
|
171
|
+
// candidate (or the container as a fallback). Shared by the physical-mount path
|
|
172
|
+
// and the visibility path below so both behave identically. Consumers (e.g.
|
|
173
|
+
// Dialog's `openAutoFocus`) may `preventDefault()` to opt out of default focus.
|
|
174
|
+
function dispatchMountAutoFocus(container: HTMLElement, previouslyFocusedElement: HTMLElement | null) {
|
|
175
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
176
|
+
const handleMountAutoFocus = (ev: Event) => emits('mountAutoFocus', ev);
|
|
177
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, handleMountAutoFocus);
|
|
178
|
+
container.dispatchEvent(mountEvent);
|
|
179
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, handleMountAutoFocus);
|
|
180
|
+
|
|
181
|
+
if (!mountEvent.defaultPrevented) {
|
|
182
|
+
focusFirst(getTabbableCandidates(container), { select: true });
|
|
183
|
+
if (getActiveElement() === previouslyFocusedElement) {
|
|
184
|
+
focus(container);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
160
189
|
watchEffect(async (cleanupFn) => {
|
|
161
190
|
const container = currentElement.value;
|
|
162
191
|
|
|
@@ -164,30 +193,29 @@ watchEffect(async (cleanupFn) => {
|
|
|
164
193
|
if (!container) {
|
|
165
194
|
return;
|
|
166
195
|
}
|
|
167
|
-
|
|
196
|
+
// A scope that mounts hidden (`present: false`, e.g. a closed Dialog with
|
|
197
|
+
// `unmountOnHide: false`) must stay out of the scope stack: adding it would
|
|
198
|
+
// pause the currently active scope and break its focus trap. The `present`
|
|
199
|
+
// watcher below adds/removes it as it becomes visible.
|
|
200
|
+
if (props.present !== false) {
|
|
201
|
+
focusScopesStack.add(focusScope);
|
|
202
|
+
}
|
|
168
203
|
const previouslyFocusedElement = getActiveElement() as HTMLElement | null;
|
|
169
204
|
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
170
205
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (getActiveElement() === previouslyFocusedElement) {
|
|
182
|
-
focus(container);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
206
|
+
// When force-mounted while closed (e.g. Dialog `unmountOnHide: false`), the
|
|
207
|
+
// consumer keeps the scope mounted but flags it as not present. Skip the
|
|
208
|
+
// mount auto-focus in that case, otherwise it fires `mountAutoFocus` and
|
|
209
|
+
// steals focus into a hidden scope. The `present` watcher below re-runs the
|
|
210
|
+
// auto-focus once the scope becomes present again.
|
|
211
|
+
// NOTE: `props.present` must stay read *after* the `await` above so this
|
|
212
|
+
// effect does not track it — re-running on `present` changes would dispatch
|
|
213
|
+
// the unmount auto-focus cleanup below on every close.
|
|
214
|
+
if (!hasFocusedCandidate && props.present !== false) {
|
|
215
|
+
dispatchMountAutoFocus(container, previouslyFocusedElement);
|
|
185
216
|
}
|
|
186
217
|
|
|
187
218
|
cleanupFn(() => {
|
|
188
|
-
container.removeEventListener(AUTOFOCUS_ON_MOUNT, (ev: Event) =>
|
|
189
|
-
emits('mountAutoFocus', ev));
|
|
190
|
-
|
|
191
219
|
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
192
220
|
const unmountEventHandler = (ev: Event) => {
|
|
193
221
|
emits('unmountAutoFocus', ev);
|
|
@@ -208,12 +236,46 @@ watchEffect(async (cleanupFn) => {
|
|
|
208
236
|
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, unmountEventHandler);
|
|
209
237
|
|
|
210
238
|
focusScopesStack.remove(focusScope);
|
|
211
|
-
|
|
212
239
|
container.removeAttribute('data-focus-scope-unmounting');
|
|
213
240
|
}, 0);
|
|
214
241
|
});
|
|
215
242
|
});
|
|
216
243
|
|
|
244
|
+
// Force-mounted scopes (e.g. Dialog `unmountOnHide: false`) stay mounted across
|
|
245
|
+
// open/close and toggle `present` instead of unmounting, so mount/unmount-keyed
|
|
246
|
+
// behavior must be re-keyed on `present`: stack membership (which pauses other
|
|
247
|
+
// scopes' traps) and the mount auto-focus (which only fires on physical mount).
|
|
248
|
+
// Awaiting `nextTick` lets the consumer's visibility change (e.g. `v-show`)
|
|
249
|
+
// apply first, so the focus targets exist. Consumers that don't pass `present`
|
|
250
|
+
// never hit this — it stays `undefined`.
|
|
251
|
+
watch(() => props.present, async (present, prevPresent) => {
|
|
252
|
+
if (!isClient) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (present === false && prevPresent === true) {
|
|
257
|
+
focusScopesStack.remove(focusScope);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (present !== true || prevPresent !== false) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
focusScopesStack.add(focusScope);
|
|
266
|
+
|
|
267
|
+
await nextTick();
|
|
268
|
+
const container = currentElement.value;
|
|
269
|
+
if (!container) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const previouslyFocusedElement = getActiveElement() as HTMLElement | null;
|
|
274
|
+
if (!container.contains(previouslyFocusedElement)) {
|
|
275
|
+
dispatchMountAutoFocus(container, previouslyFocusedElement);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
217
279
|
function handleKeyDown(event: KeyboardEvent) {
|
|
218
280
|
if (!props.loop && !props.trapped) {
|
|
219
281
|
return;
|
|
@@ -10,7 +10,8 @@ import type {
|
|
|
10
10
|
Side,
|
|
11
11
|
} from './utils';
|
|
12
12
|
import type { PrimitiveProps } from '@/Primitive';
|
|
13
|
-
import {
|
|
13
|
+
import type { Direction } from '@/shared/types';
|
|
14
|
+
import { createContext, useDirection, useForwardExpose, useSize } from '@/shared';
|
|
14
15
|
|
|
15
16
|
export const PopperContentPropsDefaultValue = {
|
|
16
17
|
side: 'bottom' as Side,
|
|
@@ -177,6 +178,10 @@ export interface PopperContentProps extends PrimitiveProps {
|
|
|
177
178
|
* If provided, it will replace the default anchor element.
|
|
178
179
|
*/
|
|
179
180
|
reference?: ReferenceElement;
|
|
181
|
+
/**
|
|
182
|
+
* The reading direction of the popper content when applicable. <br> If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode.
|
|
183
|
+
*/
|
|
184
|
+
dir?: Direction;
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
export interface PopperContentContext {
|
|
@@ -204,7 +209,6 @@ import {
|
|
|
204
209
|
useFloating,
|
|
205
210
|
} from '@floating-ui/vue';
|
|
206
211
|
import { isNumber } from '@vinicunca/perkakas';
|
|
207
|
-
import { computedEager } from '@vueuse/core';
|
|
208
212
|
import { computed, ref, watchEffect, watchPostEffect } from 'vue';
|
|
209
213
|
import {
|
|
210
214
|
Primitive,
|
|
@@ -229,6 +233,7 @@ const emits = defineEmits<{
|
|
|
229
233
|
|
|
230
234
|
const rootContext = injectPopperRootContext();
|
|
231
235
|
const { forwardRef, currentElement: contentElement } = useForwardExpose();
|
|
236
|
+
const dir = useDirection(computed(() => props.dir));
|
|
232
237
|
|
|
233
238
|
const floatingRef = ref<HTMLElement>();
|
|
234
239
|
|
|
@@ -269,7 +274,7 @@ const flipOptions = computed(() => {
|
|
|
269
274
|
};
|
|
270
275
|
});
|
|
271
276
|
|
|
272
|
-
const computedMiddleware =
|
|
277
|
+
const computedMiddleware = computed(() => {
|
|
273
278
|
return [
|
|
274
279
|
offset({
|
|
275
280
|
mainAxis: props.sideOffset + arrowHeight.value,
|
|
@@ -322,6 +327,7 @@ const computedMiddleware = computedEager(() => {
|
|
|
322
327
|
transformOrigin({
|
|
323
328
|
arrowWidth: arrowWidth.value,
|
|
324
329
|
arrowHeight: arrowHeight.value,
|
|
330
|
+
dir: dir.value,
|
|
325
331
|
}),
|
|
326
332
|
props.hideWhenDetached
|
|
327
333
|
&& hide({ strategy: 'referenceHidden', ...detectOverflowOptions.value }),
|
|
@@ -391,6 +397,7 @@ providePopperContentContext({
|
|
|
391
397
|
<div
|
|
392
398
|
ref="floatingRef"
|
|
393
399
|
data-akar-popper-content-wrapper=""
|
|
400
|
+
:dir="dir"
|
|
394
401
|
:style="{
|
|
395
402
|
...floatingStyles,
|
|
396
403
|
transform: isPositioned ? floatingStyles.transform : 'translate(0, -200%)', // keep off the page when measuring
|
|
@@ -427,6 +434,7 @@ providePopperContentContext({
|
|
|
427
434
|
:as="props.as"
|
|
428
435
|
:data-side="placedSide"
|
|
429
436
|
:data-align="placedAlign"
|
|
437
|
+
:dir="dir"
|
|
430
438
|
:style="{
|
|
431
439
|
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
432
440
|
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
package/src/Popper/utils.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Middleware, Placement } from '@floating-ui/vue';
|
|
2
|
+
import type { Direction } from '@/shared/types';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
4
|
+
const _SIDE_OPTIONS = ['top', 'right', 'bottom', 'left'] as const;
|
|
5
|
+
const _ALIGN_OPTIONS = ['start', 'center', 'end'] as const;
|
|
5
6
|
|
|
6
|
-
export type Side = (typeof
|
|
7
|
-
export type Align = (typeof
|
|
7
|
+
export type Side = (typeof _SIDE_OPTIONS)[number];
|
|
8
|
+
export type Align = (typeof _ALIGN_OPTIONS)[number];
|
|
8
9
|
|
|
9
10
|
export function isNotNull<T>(value: T | null): value is T {
|
|
10
11
|
return value !== null;
|
|
@@ -13,6 +14,7 @@ export function isNotNull<T>(value: T | null): value is T {
|
|
|
13
14
|
export function transformOrigin(options: {
|
|
14
15
|
arrowWidth: number;
|
|
15
16
|
arrowHeight: number;
|
|
17
|
+
dir?: Direction;
|
|
16
18
|
}): Middleware {
|
|
17
19
|
return {
|
|
18
20
|
name: 'transformOrigin',
|
|
@@ -26,9 +28,17 @@ export function transformOrigin(options: {
|
|
|
26
28
|
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
27
29
|
|
|
28
30
|
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const noArrowAlignX = {
|
|
32
|
+
start: options.dir === 'rtl' ? '100%' : '0%',
|
|
33
|
+
center: '50%',
|
|
34
|
+
end: options.dir === 'rtl' ? '0%' : '100%',
|
|
35
|
+
}[placedAlign];
|
|
36
|
+
|
|
37
|
+
const noArrowAlignY = {
|
|
38
|
+
start: '0%',
|
|
39
|
+
center: '50%',
|
|
40
|
+
end: '100%',
|
|
41
|
+
}[placedAlign];
|
|
32
42
|
|
|
33
43
|
const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
|
|
34
44
|
const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
|
|
@@ -37,17 +47,17 @@ export function transformOrigin(options: {
|
|
|
37
47
|
let y = '';
|
|
38
48
|
|
|
39
49
|
if (placedSide === 'bottom') {
|
|
40
|
-
x = isArrowHidden ?
|
|
50
|
+
x = isArrowHidden ? noArrowAlignX : `${arrowXCenter}px`;
|
|
41
51
|
y = `${-arrowHeight}px`;
|
|
42
52
|
} else if (placedSide === 'top') {
|
|
43
|
-
x = isArrowHidden ?
|
|
53
|
+
x = isArrowHidden ? noArrowAlignX : `${arrowXCenter}px`;
|
|
44
54
|
y = `${rects.floating.height + arrowHeight}px`;
|
|
45
55
|
} else if (placedSide === 'right') {
|
|
46
56
|
x = `${-arrowHeight}px`;
|
|
47
|
-
y = isArrowHidden ?
|
|
57
|
+
y = isArrowHidden ? noArrowAlignY : `${arrowYCenter}px`;
|
|
48
58
|
} else if (placedSide === 'left') {
|
|
49
59
|
x = `${rects.floating.width + arrowHeight}px`;
|
|
50
|
-
y = isArrowHidden ?
|
|
60
|
+
y = isArrowHidden ? noArrowAlignY : `${arrowYCenter}px`;
|
|
51
61
|
}
|
|
52
62
|
return { data: { x, y } };
|
|
53
63
|
},
|
|
@@ -7,13 +7,14 @@ import { useForwardExpose } from '@/shared';
|
|
|
7
7
|
import { injectRatingItemContext } from './RatingItem.vue';
|
|
8
8
|
import { injectRatingRootContext } from './RatingRoot.vue';
|
|
9
9
|
|
|
10
|
-
export interface
|
|
10
|
+
export interface RatingItemIndicatorProps extends PrimitiveProps {
|
|
11
|
+
/** The step value this indicator represents. */
|
|
11
12
|
step: number;
|
|
12
13
|
}
|
|
13
14
|
</script>
|
|
14
15
|
|
|
15
16
|
<script setup lang="ts">
|
|
16
|
-
const props = defineProps<
|
|
17
|
+
const props = defineProps<RatingItemIndicatorProps>();
|
|
17
18
|
|
|
18
19
|
const rootContext = injectRatingRootContext();
|
|
19
20
|
const { currentElement, forwardRef } = useForwardExpose();
|
|
@@ -16,14 +16,18 @@ export interface RatingRootContext {
|
|
|
16
16
|
|
|
17
17
|
export interface RatingRootProps extends Omit<RadioGroupRootProps, 'modelValue' | 'defaultValue'> {
|
|
18
18
|
/**
|
|
19
|
-
* The value
|
|
19
|
+
* The rating value when initially rendered. Use when you do not need to control the state of the rating.
|
|
20
20
|
*/
|
|
21
21
|
defaultValue?: number;
|
|
22
|
-
/** The controlled value
|
|
22
|
+
/** The controlled rating value. Can be bound with `v-model`. */
|
|
23
23
|
modelValue?: number;
|
|
24
|
+
/** The number of rating items to render. */
|
|
24
25
|
length?: number;
|
|
26
|
+
/** When `true`, clicking the currently selected rating resets the value to `0`. */
|
|
25
27
|
clearable?: boolean;
|
|
28
|
+
/** When `true`, the rating previews the value under the pointer on hover. */
|
|
26
29
|
hoverable?: boolean;
|
|
30
|
+
/** The granularity each rating item is divided into. */
|
|
27
31
|
step?: 1 | 0.5 | 0.25 | 0.1;
|
|
28
32
|
|
|
29
33
|
}
|
package/src/Rating/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as RatingItem, type RatingItemProps } from './RatingItem.vue';
|
|
2
|
-
export { default as RatingItemIndicator } from './RatingItemIndicator.vue';
|
|
3
|
-
export { default as RatingRoot, type RatingRootProps } from './RatingRoot.vue';
|
|
1
|
+
export { injectRatingItemContext, default as RatingItem, type RatingItemProps } from './RatingItem.vue';
|
|
2
|
+
export { default as RatingItemIndicator, type RatingItemIndicatorProps } from './RatingItemIndicator.vue';
|
|
3
|
+
export { injectRatingRootContext, default as RatingRoot, type RatingRootEmits, type RatingRootProps } from './RatingRoot.vue';
|
|
@@ -86,7 +86,7 @@ export function setGlobalCursorStyle(
|
|
|
86
86
|
document.head.appendChild(styleElement);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
styleElement.
|
|
89
|
+
styleElement.textContent = `*{cursor: ${style}!important;}`;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// the % of the group's overall space this panel should occupy.
|
package/src/Tree/TreeRoot.vue
CHANGED
|
@@ -26,9 +26,9 @@ export interface TreeRootProps<T = Record<string, any>, U extends Record<string,
|
|
|
26
26
|
dir?: Direction;
|
|
27
27
|
/** When `true`, prevents the user from interacting with tree */
|
|
28
28
|
disabled?: boolean;
|
|
29
|
-
/** When `true`, selecting parent will select the descendants. */
|
|
29
|
+
/** When `true`, selecting parent will select the descendants. Requires `multiple` to be `true`. */
|
|
30
30
|
propagateSelect?: boolean;
|
|
31
|
-
/** When `true`, selecting children will update the parent state. */
|
|
31
|
+
/** When `true`, selecting children will update the parent state. Requires `multiple` to be `true`. */
|
|
32
32
|
bubbleSelect?: boolean;
|
|
33
33
|
}
|
|
34
34
|
|
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './DateRangeField';
|
|
|
21
21
|
export * from './DateRangePicker';
|
|
22
22
|
export * from './Dialog';
|
|
23
23
|
export { type FocusOutsideEvent, type PointerDownOutsideEvent } from './DismissableLayer';
|
|
24
|
+
export * from './Drawer';
|
|
24
25
|
export * from './DropdownMenu';
|
|
25
26
|
export * from './Editable';
|
|
26
27
|
export * from './FocusScope';
|
|
@@ -40,6 +41,7 @@ export { type AsTag, Primitive, type PrimitiveProps, Slot } from './Primitive';
|
|
|
40
41
|
export * from './Progress';
|
|
41
42
|
export * from './RadioGroup';
|
|
42
43
|
export * from './RangeCalendar';
|
|
44
|
+
export * from './Rating';
|
|
43
45
|
export * from './RovingFocus';
|
|
44
46
|
export * from './ScrollArea';
|
|
45
47
|
export * from './Select';
|
package/src/shared/index.ts
CHANGED
|
@@ -8,7 +8,6 @@ export { isValidVNodeElement } from './isValidVNodeElement';
|
|
|
8
8
|
export { isValueEqualOrExist } from './isValueEqualOrExist';
|
|
9
9
|
export { onFocusOutside } from './onFocusOutside';
|
|
10
10
|
export { renderSlotFragments } from './renderSlotFragments';
|
|
11
|
-
export { trapFocus } from './trap-focus';
|
|
12
11
|
export { useArrowNavigation } from './useArrowNavigation';
|
|
13
12
|
export { useBodyScrollLock } from './useBodyScrollLock';
|
|
14
13
|
export { useComposing } from './useComposing';
|
package/src/shared/useSize.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { MaybeElementRef } from '@vueuse/core';
|
|
2
2
|
import { unrefElement } from '@vueuse/core';
|
|
3
|
-
import { computed, onMounted, ref } from 'vue';
|
|
3
|
+
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
4
4
|
|
|
5
5
|
export function useSize(element: MaybeElementRef) {
|
|
6
6
|
const size = ref<{ width: number; height: number }>();
|
|
7
7
|
const width = computed(() => size.value?.width ?? 0);
|
|
8
8
|
const height = computed(() => size.value?.height ?? 0);
|
|
9
9
|
|
|
10
|
+
let resizeObserver: ResizeObserver | undefined;
|
|
11
|
+
|
|
10
12
|
onMounted(() => {
|
|
11
13
|
const el = unrefElement(element) as HTMLElement;
|
|
12
14
|
if (el) {
|
|
13
15
|
// provide size as early as possible
|
|
14
16
|
size.value = { width: el.offsetWidth, height: el.offsetHeight };
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
resizeObserver = new ResizeObserver((entries) => {
|
|
17
19
|
if (!Array.isArray(entries)) {
|
|
18
20
|
return;
|
|
19
21
|
}
|
|
@@ -48,8 +50,6 @@ export function useSize(element: MaybeElementRef) {
|
|
|
48
50
|
});
|
|
49
51
|
|
|
50
52
|
resizeObserver.observe(el, { box: 'border-box' });
|
|
51
|
-
|
|
52
|
-
return () => resizeObserver.unobserve(el);
|
|
53
53
|
} else {
|
|
54
54
|
// We only want to reset to `undefined` when the element becomes `null`,
|
|
55
55
|
// not if it changes to another element.
|
|
@@ -57,6 +57,11 @@ export function useSize(element: MaybeElementRef) {
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
onUnmounted(() => {
|
|
61
|
+
resizeObserver?.disconnect();
|
|
62
|
+
resizeObserver = undefined;
|
|
63
|
+
});
|
|
64
|
+
|
|
60
65
|
return {
|
|
61
66
|
width,
|
|
62
67
|
height,
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const require_shared_getActiveElement = require('./getActiveElement.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/shared/trap-focus.ts
|
|
4
|
-
function trapFocus(element) {
|
|
5
|
-
if (element) {
|
|
6
|
-
const focusableEls = [...Array.from(element.querySelectorAll("a[href], button, input, textarea, select, details,[tabindex]:not([tabindex=\"-1\"])"))].filter((el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden"));
|
|
7
|
-
const firstFocusableEl = focusableEls[0];
|
|
8
|
-
const lastFocusableEl = focusableEls.at(-1);
|
|
9
|
-
const KEYCODE_TAB = 9;
|
|
10
|
-
if (firstFocusableEl) firstFocusableEl.focus();
|
|
11
|
-
element.addEventListener("keydown", (e) => {
|
|
12
|
-
const isTabPressed = e.key === "Tab" || e.keyCode === KEYCODE_TAB;
|
|
13
|
-
if (!isTabPressed) return;
|
|
14
|
-
if (e.shiftKey) {
|
|
15
|
-
if (require_shared_getActiveElement.getActiveElement() === firstFocusableEl) {
|
|
16
|
-
lastFocusableEl.focus();
|
|
17
|
-
e.preventDefault();
|
|
18
|
-
}
|
|
19
|
-
} else if (require_shared_getActiveElement.getActiveElement() === lastFocusableEl) {
|
|
20
|
-
firstFocusableEl.focus();
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return firstFocusableEl;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
Object.defineProperty(exports, 'trapFocus', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return trapFocus;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=trap-focus.cjs.map
|