v-float 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -124
- package/dist/composables/interactions/index.d.ts +2 -0
- package/dist/composables/interactions/index.d.ts.map +1 -1
- package/dist/composables/interactions/navigation-strategies.d.ts +36 -0
- package/dist/composables/interactions/navigation-strategies.d.ts.map +1 -0
- package/dist/composables/interactions/use-focus-trap.d.ts +41 -0
- package/dist/composables/interactions/use-focus-trap.d.ts.map +1 -0
- package/dist/composables/interactions/use-focus.d.ts.map +1 -1
- package/dist/composables/interactions/use-list-navigation.d.ts +109 -0
- package/dist/composables/interactions/use-list-navigation.d.ts.map +1 -0
- package/dist/composables/utils/is-using-keyboard.d.ts +2 -0
- package/dist/composables/utils/is-using-keyboard.d.ts.map +1 -0
- package/dist/composables/utils/use-active-descendant.d.ts +8 -0
- package/dist/composables/utils/use-active-descendant.d.ts.map +1 -0
- package/dist/v-float.es.js +2338 -1537
- package/dist/v-float.umd.js +4 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -3,130 +3,130 @@
|
|
|
3
3
|
[](#project-status)
|
|
4
4
|
|
|
5
5
|
> Work in progress: This library is under active development. APIs may change without notice and breaking changes can land without deprecation windows or warnings. Not recommended for production use yet.
|
|
6
|
-
|
|
7
|
-
A Vue 3 library for positioning floating UI elements like tooltips, popovers, dropdowns, and modals. Built on top
|
|
8
|
-
of [
|
|
9
|
-
|
|
10
|
-
## Features
|
|
11
|
-
|
|
12
|
-
- **Precise Positioning**: Pixel-perfect positioning with automatic collision detection
|
|
13
|
-
- **Vue 3 Composables**: Reactive composables designed for the Composition API
|
|
14
|
-
- **Interaction Handling**: Built-in hover, focus, click, and dismiss behaviors
|
|
15
|
-
- **Nested Elements**: Support for floating element trees and hierarchies
|
|
16
|
-
- **Arrow Positioning**: `useArrow` composable for positioning arrow elements
|
|
17
|
-
- **Lightweight**: Tree-shakable with minimal bundle impact
|
|
18
|
-
- **Cross-platform**: Works on desktop, mobile, and touch devices
|
|
19
|
-
- **TypeScript**: Full TypeScript support with comprehensive type definitions
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
# With pnpm (recommended)
|
|
25
|
-
pnpm add v-float
|
|
26
|
-
|
|
27
|
-
# With npm
|
|
28
|
-
npm install v-float
|
|
29
|
-
|
|
30
|
-
# With yarn
|
|
31
|
-
yarn add v-float
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Quick Start
|
|
35
|
-
|
|
36
|
-
### Basic Tooltip
|
|
37
|
-
|
|
38
|
-
```vue
|
|
39
|
-
<script setup lang="ts">
|
|
40
|
-
import { useTemplateRef } from "vue"
|
|
41
|
-
import { useFloating, useHover, offset } from "v-float"
|
|
42
|
-
|
|
43
|
-
const anchorEl = useTemplateRef("anchorEl")
|
|
44
|
-
const floatingEl = useTemplateRef("floatingEl")
|
|
45
|
-
|
|
46
|
-
const context = useFloating(anchorEl, floatingEl, {
|
|
47
|
-
placement: "top",
|
|
48
|
-
middlewares: [offset(8)],
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
useHover(context)
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<template>
|
|
55
|
-
<button ref="anchorEl">Hover me</button>
|
|
56
|
-
|
|
57
|
-
<div v-if="context.open.value" ref="floatingEl" :style="context.floatingStyles.value">
|
|
58
|
-
This is a tooltip
|
|
59
|
-
</div>
|
|
60
|
-
</template>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Dropdown Menu
|
|
64
|
-
|
|
65
|
-
```vue
|
|
66
|
-
<script setup lang="ts">
|
|
67
|
-
import { useTemplateRef } from "vue"
|
|
68
|
-
import { useFloating, useClick, useEscapeKey, offset, flip, shift } from "v-float"
|
|
69
|
-
|
|
70
|
-
const triggerEl = useTemplateRef("triggerEl")
|
|
71
|
-
const menuEl = useTemplateRef("menuEl")
|
|
72
|
-
|
|
73
|
-
const context = useFloating(triggerEl, menuEl, {
|
|
74
|
-
placement: "bottom-start",
|
|
75
|
-
middlewares: [offset(4), flip(), shift({ padding: 8 })],
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
useClick(context)
|
|
79
|
-
useEscapeKey({
|
|
80
|
-
onEscape: () => context.setOpen(false),
|
|
81
|
-
})
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<template>
|
|
85
|
-
<button ref="triggerEl">Open Menu</button>
|
|
86
|
-
|
|
87
|
-
<div v-if="context.open.value" ref="menuEl" :style="context.floatingStyles.value">
|
|
88
|
-
<div>Menu Item 1</div>
|
|
89
|
-
<div>Menu Item 2</div>
|
|
90
|
-
<div>Menu Item 3</div>
|
|
91
|
-
</div>
|
|
92
|
-
</template>
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Tooltip with Arrow
|
|
96
|
-
|
|
97
|
-
```vue
|
|
98
|
-
<script setup lang="ts">
|
|
99
|
-
import { useTemplateRef } from "vue"
|
|
100
|
-
import { useFloating, useHover, useArrow, offset, flip } from "v-float"
|
|
101
|
-
|
|
102
|
-
const anchorEl = useTemplateRef("anchorEl")
|
|
103
|
-
const tooltipEl = useTemplateRef("tooltipEl")
|
|
104
|
-
const arrowEl = useTemplateRef("arrowEl")
|
|
105
|
-
|
|
106
|
-
const context = useFloating(anchorEl, tooltipEl, {
|
|
107
|
-
placement: "top",
|
|
108
|
-
middlewares: [offset(8), flip()],
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
useHover(context)
|
|
112
|
-
|
|
113
|
-
// Arrow middleware is automatically registered
|
|
114
|
-
const { arrowStyles } = useArrow(arrowEl, context, {
|
|
115
|
-
offset: "-4px",
|
|
116
|
-
})
|
|
117
|
-
</script>
|
|
118
|
-
|
|
119
|
-
<template>
|
|
120
|
-
<button ref="anchorEl">Hover me</button>
|
|
121
|
-
|
|
122
|
-
<div
|
|
123
|
-
v-if="context.open.value"
|
|
124
|
-
ref="tooltipEl"
|
|
125
|
-
:style="context.floatingStyles.value"
|
|
126
|
-
class="tooltip"
|
|
127
|
-
>
|
|
128
|
-
This is a tooltip with an arrow
|
|
129
|
-
<div ref="arrowEl" class="arrow" :style="arrowStyles"></div>
|
|
6
|
+
|
|
7
|
+
A Vue 3 library for positioning floating UI elements like tooltips, popovers, dropdowns, and modals. Built on top
|
|
8
|
+
of [@floating-ui/dom](https://floating-ui.com/) with Vue 3 Composition API.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Precise Positioning**: Pixel-perfect positioning with automatic collision detection
|
|
13
|
+
- **Vue 3 Composables**: Reactive composables designed for the Composition API
|
|
14
|
+
- **Interaction Handling**: Built-in hover, focus, click, and dismiss behaviors
|
|
15
|
+
- **Nested Elements**: Support for floating element trees and hierarchies
|
|
16
|
+
- **Arrow Positioning**: `useArrow` composable for positioning arrow elements
|
|
17
|
+
- **Lightweight**: Tree-shakable with minimal bundle impact
|
|
18
|
+
- **Cross-platform**: Works on desktop, mobile, and touch devices
|
|
19
|
+
- **TypeScript**: Full TypeScript support with comprehensive type definitions
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# With pnpm (recommended)
|
|
25
|
+
pnpm add v-float
|
|
26
|
+
|
|
27
|
+
# With npm
|
|
28
|
+
npm install v-float
|
|
29
|
+
|
|
30
|
+
# With yarn
|
|
31
|
+
yarn add v-float
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### Basic Tooltip
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import { useTemplateRef } from "vue"
|
|
41
|
+
import { useFloating, useHover, offset } from "v-float"
|
|
42
|
+
|
|
43
|
+
const anchorEl = useTemplateRef("anchorEl")
|
|
44
|
+
const floatingEl = useTemplateRef("floatingEl")
|
|
45
|
+
|
|
46
|
+
const context = useFloating(anchorEl, floatingEl, {
|
|
47
|
+
placement: "top",
|
|
48
|
+
middlewares: [offset(8)],
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
useHover(context)
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<button ref="anchorEl">Hover me</button>
|
|
56
|
+
|
|
57
|
+
<div v-if="context.open.value" ref="floatingEl" :style="context.floatingStyles.value">
|
|
58
|
+
This is a tooltip
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Dropdown Menu
|
|
64
|
+
|
|
65
|
+
```vue
|
|
66
|
+
<script setup lang="ts">
|
|
67
|
+
import { useTemplateRef } from "vue"
|
|
68
|
+
import { useFloating, useClick, useEscapeKey, offset, flip, shift } from "v-float"
|
|
69
|
+
|
|
70
|
+
const triggerEl = useTemplateRef("triggerEl")
|
|
71
|
+
const menuEl = useTemplateRef("menuEl")
|
|
72
|
+
|
|
73
|
+
const context = useFloating(triggerEl, menuEl, {
|
|
74
|
+
placement: "bottom-start",
|
|
75
|
+
middlewares: [offset(4), flip(), shift({ padding: 8 })],
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
useClick(context)
|
|
79
|
+
useEscapeKey({
|
|
80
|
+
onEscape: () => context.setOpen(false),
|
|
81
|
+
})
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
<button ref="triggerEl">Open Menu</button>
|
|
86
|
+
|
|
87
|
+
<div v-if="context.open.value" ref="menuEl" :style="context.floatingStyles.value">
|
|
88
|
+
<div>Menu Item 1</div>
|
|
89
|
+
<div>Menu Item 2</div>
|
|
90
|
+
<div>Menu Item 3</div>
|
|
91
|
+
</div>
|
|
92
|
+
</template>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Tooltip with Arrow
|
|
96
|
+
|
|
97
|
+
```vue
|
|
98
|
+
<script setup lang="ts">
|
|
99
|
+
import { useTemplateRef } from "vue"
|
|
100
|
+
import { useFloating, useHover, useArrow, offset, flip } from "v-float"
|
|
101
|
+
|
|
102
|
+
const anchorEl = useTemplateRef("anchorEl")
|
|
103
|
+
const tooltipEl = useTemplateRef("tooltipEl")
|
|
104
|
+
const arrowEl = useTemplateRef("arrowEl")
|
|
105
|
+
|
|
106
|
+
const context = useFloating(anchorEl, tooltipEl, {
|
|
107
|
+
placement: "top",
|
|
108
|
+
middlewares: [offset(8), flip()],
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
useHover(context)
|
|
112
|
+
|
|
113
|
+
// Arrow middleware is automatically registered
|
|
114
|
+
const { arrowStyles } = useArrow(arrowEl, context, {
|
|
115
|
+
offset: "-4px",
|
|
116
|
+
})
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<template>
|
|
120
|
+
<button ref="anchorEl">Hover me</button>
|
|
121
|
+
|
|
122
|
+
<div
|
|
123
|
+
v-if="context.open.value"
|
|
124
|
+
ref="tooltipEl"
|
|
125
|
+
:style="context.floatingStyles.value"
|
|
126
|
+
class="tooltip"
|
|
127
|
+
>
|
|
128
|
+
This is a tooltip with an arrow
|
|
129
|
+
<div ref="arrowEl" class="arrow" :style="arrowStyles"></div>
|
|
130
130
|
</div>
|
|
131
131
|
</template>
|
|
132
132
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type NavigationAction = {
|
|
2
|
+
type: "navigate";
|
|
3
|
+
index: number | null;
|
|
4
|
+
} | {
|
|
5
|
+
type: "close";
|
|
6
|
+
};
|
|
7
|
+
export interface StrategyContext {
|
|
8
|
+
current: number | null;
|
|
9
|
+
items: Array<HTMLElement | null>;
|
|
10
|
+
isRtl: boolean;
|
|
11
|
+
loop: boolean;
|
|
12
|
+
allowEscape: boolean;
|
|
13
|
+
isVirtual: boolean;
|
|
14
|
+
cols: number;
|
|
15
|
+
nested: boolean;
|
|
16
|
+
isDisabled: (index: number) => boolean;
|
|
17
|
+
findNextEnabled: (start: number, dir: 1 | -1, wrap: boolean) => number | null;
|
|
18
|
+
getFirstEnabledIndex: () => number | null;
|
|
19
|
+
getLastEnabledIndex: () => number | null;
|
|
20
|
+
}
|
|
21
|
+
export interface NavigationStrategy {
|
|
22
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
23
|
+
}
|
|
24
|
+
export declare class VerticalNavigationStrategy implements NavigationStrategy {
|
|
25
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
26
|
+
}
|
|
27
|
+
export declare class HorizontalNavigationStrategy implements NavigationStrategy {
|
|
28
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
29
|
+
}
|
|
30
|
+
export declare class GridNavigationStrategy implements NavigationStrategy {
|
|
31
|
+
private fallbackToLinear;
|
|
32
|
+
private loopDirection;
|
|
33
|
+
constructor(fallbackToLinear?: boolean, loopDirection?: "row" | "next");
|
|
34
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=navigation-strategies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-strategies.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/navigation-strategies.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAA;AAE7F,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,KAAK,EAAE,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAChC,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;IACtC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,CAAA;IAC7E,oBAAoB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;IACzC,mBAAmB,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CACzC;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI,CAAA;CAC1E;AAkCD,qBAAa,0BAA2B,YAAW,kBAAkB;IACnE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI;CAa1E;AAED,qBAAa,4BAA6B,YAAW,kBAAkB;IACrE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI;CAY1E;AAED,qBAAa,sBAAuB,YAAW,kBAAkB;IAE7D,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,aAAa;gBADb,gBAAgB,GAAE,OAAe,EACjC,aAAa,GAAE,KAAK,GAAG,MAAc;IAG/C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI;CA8K1E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { FloatingContext } from '../positioning/use-floating';
|
|
3
|
+
import { TreeNode } from '../positioning/use-floating-tree';
|
|
4
|
+
export interface UseFocusTrapOptions {
|
|
5
|
+
/** Enables the focus trap when true. @default true */
|
|
6
|
+
enabled?: MaybeRefOrGetter<boolean>;
|
|
7
|
+
/** When true, hides/inerts content outside the trap. @default false */
|
|
8
|
+
modal?: MaybeRefOrGetter<boolean>;
|
|
9
|
+
/** When true, inserts hidden focus guards to aid wrap-around. @default true */
|
|
10
|
+
guards?: MaybeRefOrGetter<boolean>;
|
|
11
|
+
/** Wrap order preference when cycling with Tab. @default ['content'] */
|
|
12
|
+
order?: MaybeRefOrGetter<Array<"content" | "reference" | "floating">>;
|
|
13
|
+
/** Initial focus target policy on activation. @default 'first' */
|
|
14
|
+
initialFocus?: MaybeRefOrGetter<number | HTMLElement | (() => HTMLElement | null) | "first" | "last">;
|
|
15
|
+
/** Returns focus to previously focused element on deactivate. @default true */
|
|
16
|
+
returnFocus?: MaybeRefOrGetter<boolean>;
|
|
17
|
+
/** Restores focus to nearest tabbable if active node disappears. @default false */
|
|
18
|
+
restoreFocus?: MaybeRefOrGetter<boolean>;
|
|
19
|
+
/** On non-modal, close when focus escapes the trap. @default false */
|
|
20
|
+
closeOnFocusOut?: MaybeRefOrGetter<boolean>;
|
|
21
|
+
/** Pass preventScroll to focus operations. @default true */
|
|
22
|
+
preventScroll?: MaybeRefOrGetter<boolean>;
|
|
23
|
+
/** Apply `inert` (when supported) to outside elements while modal. @default false */
|
|
24
|
+
outsideElementsInert?: MaybeRefOrGetter<boolean>;
|
|
25
|
+
}
|
|
26
|
+
export interface UseFocusTrapReturn {
|
|
27
|
+
cleanup: () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Traps keyboard focus within the floating element, optionally in a modal manner.
|
|
31
|
+
*
|
|
32
|
+
* Supports nested traps; only the deepest open node activates trapping when used with a tree.
|
|
33
|
+
* Provides optional focus guards, initial focus, focus return, and close-on-escape behavior.
|
|
34
|
+
*
|
|
35
|
+
* @param context - FloatingContext or TreeNode<FloatingContext> to trap within
|
|
36
|
+
* @param options - Configuration options controlling trap behavior
|
|
37
|
+
* @returns Cleanup API
|
|
38
|
+
*/
|
|
39
|
+
export declare function useFocusTrap(context: FloatingContext | TreeNode<FloatingContext>, options?: UseFocusTrapOptions): UseFocusTrapReturn;
|
|
40
|
+
export type { FloatingContext };
|
|
41
|
+
//# sourceMappingURL=use-focus-trap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-focus-trap.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus-trap.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,gBAAgB,EAOtB,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAA;AAY3E,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACnC,uEAAuE;IACvE,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACjC,+EAA+E;IAC/E,MAAM,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAClC,wEAAwE;IACxE,KAAK,CAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC,CAAC,CAAA;IACrE,kEAAkE;IAClE,YAAY,CAAC,EAAE,gBAAgB,CAC7B,MAAM,GAAG,WAAW,GAAG,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,OAAO,GAAG,MAAM,CACrE,CAAA;IACD,+EAA+E;IAC/E,WAAW,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACvC,mFAAmF;IACnF,YAAY,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACxC,sEAAsE;IACtE,eAAe,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC3C,4DAA4D;IAC5D,aAAa,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACzC,qFAAqF;IACrF,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;CACjD;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAMD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,EACpD,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CA+cpB;AAMD,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-focus.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAOtB,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,6CAA6C,CAAA;
|
|
1
|
+
{"version":3,"file":"use-focus.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAOtB,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,6CAA6C,CAAA;AAmBjF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAsMhB;AAMD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEnC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE/C;;OAEG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
import { FloatingContext } from '../positioning/use-floating';
|
|
3
|
+
import { TreeNode } from '../positioning/use-floating-tree';
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring list-style keyboard/mouse navigation behavior.
|
|
6
|
+
*
|
|
7
|
+
* This interface drives how items in a floating list/grid are navigated,
|
|
8
|
+
* focused, and announced (including support for virtual focus).
|
|
9
|
+
*/
|
|
10
|
+
export interface UseListNavigationOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Reactive collection of list item elements in DOM order.
|
|
13
|
+
* Null entries are allowed while items mount/unmount.
|
|
14
|
+
*/
|
|
15
|
+
listRef: Ref<Array<HTMLElement | null>>;
|
|
16
|
+
/**
|
|
17
|
+
* The currently active (navigated) index. Null means no active item.
|
|
18
|
+
*/
|
|
19
|
+
activeIndex?: MaybeRefOrGetter<number | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Callback invoked when navigation sets a new active index.
|
|
22
|
+
*/
|
|
23
|
+
onNavigate?: (index: number | null) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Whether navigation behavior is enabled.
|
|
26
|
+
*/
|
|
27
|
+
enabled?: MaybeRefOrGetter<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* If true, arrow-key navigation wraps from end-to-start and vice versa.
|
|
30
|
+
*/
|
|
31
|
+
loop?: MaybeRefOrGetter<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Primary navigation orientation.
|
|
34
|
+
* - "vertical": Up/Down to navigate
|
|
35
|
+
* - "horizontal": Left/Right to navigate
|
|
36
|
+
* - "both": Grid navigation (supports cols/itemSizes)
|
|
37
|
+
*/
|
|
38
|
+
orientation?: MaybeRefOrGetter<"vertical" | "horizontal" | "both">;
|
|
39
|
+
/**
|
|
40
|
+
* Indices that should be treated as disabled and skipped by navigation.
|
|
41
|
+
* Can be an array of indices or a predicate.
|
|
42
|
+
*/
|
|
43
|
+
disabledIndices?: Array<number> | ((index: number) => boolean);
|
|
44
|
+
/**
|
|
45
|
+
* If true, hovering an item moves the active index to that item.
|
|
46
|
+
*/
|
|
47
|
+
focusItemOnHover?: MaybeRefOrGetter<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* If true, pressing an arrow key when closed opens and moves focus.
|
|
50
|
+
*/
|
|
51
|
+
openOnArrowKeyDown?: MaybeRefOrGetter<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Controls automatic scrolling when the active item changes.
|
|
54
|
+
* true for default "nearest" behavior or a custom ScrollIntoViewOptions.
|
|
55
|
+
*/
|
|
56
|
+
scrollItemIntoView?: boolean | ScrollIntoViewOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Index to prefer when opening (e.g., currently selected option).
|
|
59
|
+
*/
|
|
60
|
+
selectedIndex?: MaybeRefOrGetter<number | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Controls focusing an item when the list opens.
|
|
63
|
+
* - true: always focus an item
|
|
64
|
+
* - false: never focus an item
|
|
65
|
+
* - "auto": focus based on input modality/heuristics
|
|
66
|
+
*/
|
|
67
|
+
focusItemOnOpen?: MaybeRefOrGetter<boolean | "auto">;
|
|
68
|
+
/**
|
|
69
|
+
* Whether this list is nested inside another navigable list.
|
|
70
|
+
* Affects cross-orientation close/open key handling.
|
|
71
|
+
*/
|
|
72
|
+
nested?: MaybeRefOrGetter<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Parent list orientation when nested, for cross-navigation behavior.
|
|
75
|
+
*/
|
|
76
|
+
parentOrientation?: MaybeRefOrGetter<"vertical" | "horizontal" | "both">;
|
|
77
|
+
/**
|
|
78
|
+
* Right-to-left layout flag affecting horizontal arrow semantics.
|
|
79
|
+
*/
|
|
80
|
+
rtl?: MaybeRefOrGetter<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Enables virtual focus mode (aria-activedescendant) instead of DOM focus.
|
|
83
|
+
*/
|
|
84
|
+
virtual?: MaybeRefOrGetter<boolean>;
|
|
85
|
+
/**
|
|
86
|
+
* Receives the HTMLElement corresponding to the virtual active item.
|
|
87
|
+
* Used for aria-activedescendant and screen reader announcement.
|
|
88
|
+
*/
|
|
89
|
+
virtualItemRef?: Ref<HTMLElement | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Column count for grid navigation when orientation is "both".
|
|
92
|
+
*/
|
|
93
|
+
cols?: MaybeRefOrGetter<number>;
|
|
94
|
+
/**
|
|
95
|
+
* If true, allows escaping to a null active index via keyboard (e.g., ArrowDown on last).
|
|
96
|
+
*/
|
|
97
|
+
allowEscape?: MaybeRefOrGetter<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* Defines the wrapping behavior for grid navigation when moving horizontally past the end of a row.
|
|
100
|
+
* - "row": Wraps to the start of the *same* row (default).
|
|
101
|
+
* - "next": Moves to the start of the *next* row (or previous row if moving left).
|
|
102
|
+
*/
|
|
103
|
+
gridLoopDirection?: MaybeRefOrGetter<"row" | "next">;
|
|
104
|
+
}
|
|
105
|
+
export interface UseListNavigationReturn {
|
|
106
|
+
cleanup: () => void;
|
|
107
|
+
}
|
|
108
|
+
export declare function useListNavigation(context: FloatingContext | TreeNode<FloatingContext>, options: UseListNavigationOptions): UseListNavigationReturn;
|
|
109
|
+
//# sourceMappingURL=use-list-navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-list-navigation.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-list-navigation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,GAAG,EAKT,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAA;AAY3E;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAA;IAEvC;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAE7C;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAE3C;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEnC;;OAEG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEhC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC,CAAA;IAElE;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAA;IAE9D;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE5C;;OAEG;IACH,kBAAkB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE9C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,GAAG,qBAAqB,CAAA;IAEpD;;OAEG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAE/C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,gBAAgB,CAAC,OAAO,GAAG,MAAM,CAAC,CAAA;IAEpD;;;OAGG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAElC;;OAEG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC,CAAA;IAExE;;OAEG;IACH,GAAG,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE/B;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEnC;;;OAGG;IACH,cAAc,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAExC;;OAEG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAE/B;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAEvC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,CAAC,KAAK,GAAG,MAAM,CAAC,CAAA;CACrD;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,EACpD,OAAO,EAAE,wBAAwB,GAChC,uBAAuB,CA+VzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-using-keyboard.d.ts","sourceRoot":"","sources":["../../../src/composables/utils/is-using-keyboard.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,eAAe,+CAAuB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
export interface UseActiveDescendantOptions {
|
|
3
|
+
virtual: MaybeRefOrGetter<boolean>;
|
|
4
|
+
open: Ref<boolean>;
|
|
5
|
+
virtualItemRef?: Ref<HTMLElement | null>;
|
|
6
|
+
}
|
|
7
|
+
export declare function useActiveDescendant(anchorEl: ComputedRef<HTMLElement | null>, listRef: Ref<Array<HTMLElement | null>>, activeIndex: MaybeRefOrGetter<number | null>, options: UseActiveDescendantOptions): void;
|
|
8
|
+
//# sourceMappingURL=use-active-descendant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-active-descendant.d.ts","sourceRoot":"","sources":["../../../src/composables/utils/use-active-descendant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAkB,MAAM,KAAK,CAAA;AAEjG,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAClC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,cAAc,CAAC,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;CACzC;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,CAAC,WAAW,GAAG,IAAI,CAAC,EACzC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,EACvC,WAAW,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,EAC5C,OAAO,EAAE,0BAA0B,GAClC,IAAI,CAmBN"}
|