akar 2.0.10 → 2.0.11
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/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/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/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/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 +5 -0
- package/dist/constant/components.cjs.map +1 -1
- package/dist/constant/components.js +5 -0
- package/dist/constant/components.js.map +1 -1
- package/dist/constant.d.cts +1 -0
- package/dist/constant.d.cts.map +1 -1
- package/dist/constant.d.ts +1 -0
- package/dist/constant.d.ts.map +1 -1
- package/dist/index.cjs +44 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -1
- package/dist/index2.d.ts.map +1 -1
- package/dist/index3.d.cts +4 -4
- package/dist/index3.d.ts +15 -15
- package/dist/index4.d.cts +1612 -1201
- package/dist/index4.d.cts.map +1 -1
- package/dist/index4.d.ts +1618 -1207
- package/dist/index4.d.ts.map +1 -1
- package/dist/internal.d.cts +3 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/namespaced/index.cjs +6 -0
- package/dist/namespaced/index.d.cts +7 -2
- package/dist/namespaced/index.d.mts +7 -2
- package/dist/namespaced/index.mjs +7 -2
- 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/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/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/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/index.ts +2 -0
- package/src/shared/useEmitAsProps.test-d.ts +0 -1
- package/src/shared/useSize.ts +9 -4
|
@@ -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
|
+
}
|
|
@@ -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/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/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,
|