v-float 0.9.1 → 0.10.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/dist/composables/interactions/use-focus-trap.d.ts +61 -24
- package/dist/composables/interactions/use-focus-trap.d.ts.map +1 -1
- package/dist/composables/interactions/use-focus.d.ts.map +1 -1
- package/dist/composables/interactions/use-list-navigation.d.ts +35 -0
- package/dist/composables/interactions/use-list-navigation.d.ts.map +1 -1
- package/dist/v-float.es.js +2201 -1894
- package/dist/v-float.umd.js +6 -2
- package/package.json +2 -1
- package/dist/composables/interactions/navigation-strategies.d.ts +0 -36
- package/dist/composables/interactions/navigation-strategies.d.ts.map +0 -1
|
@@ -1,41 +1,78 @@
|
|
|
1
|
-
import { MaybeRefOrGetter } from 'vue';
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
2
2
|
import { FloatingContext } from '../positioning/use-floating';
|
|
3
3
|
import { TreeNode } from '../positioning/use-floating-tree';
|
|
4
4
|
export interface UseFocusTrapOptions {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Determines if the focus trap should be enabled.
|
|
7
|
+
* When `true`, the focus trap is active.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
6
10
|
enabled?: MaybeRefOrGetter<boolean>;
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* When `true`, content outside the trap will be hidden from accessibility
|
|
13
|
+
* trees (via `aria-hidden`) and potentially made inert (via `inert` attribute
|
|
14
|
+
* if `outsideElementsInert` is `true` and supported).
|
|
15
|
+
* This mimics modal behavior.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
8
18
|
modal?: MaybeRefOrGetter<boolean>;
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the element that should receive initial focus when the trap is activated.
|
|
21
|
+
* - `undefined` or omitted: Focuses the first tabbable element within the trap.
|
|
22
|
+
* - CSS selector string: Queries and focuses the first matching element.
|
|
23
|
+
* - `HTMLElement`: Focuses the specific provided HTML element.
|
|
24
|
+
* - `Function`: A function that returns an `HTMLElement` or `false`. The returned
|
|
25
|
+
* element will receive focus.
|
|
26
|
+
* - `false`: Prevents any initial focus from being set by the trap.
|
|
27
|
+
*/
|
|
28
|
+
initialFocus?: HTMLElement | (() => HTMLElement | false) | string | false;
|
|
29
|
+
/**
|
|
30
|
+
* When `true`, focus will be returned to the element that was focused
|
|
31
|
+
* immediately before the trap was activated, upon deactivation.
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
16
34
|
returnFocus?: MaybeRefOrGetter<boolean>;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
35
|
+
/**
|
|
36
|
+
* When `true` and the trap is not `modal`, the trap will deactivate (and potentially close
|
|
37
|
+
* the associated component) if focus moves outside the defined trap elements.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
20
40
|
closeOnFocusOut?: MaybeRefOrGetter<boolean>;
|
|
21
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Controls whether the browser should scroll to the focused element.
|
|
43
|
+
* Passed directly to the `focus()` method's `preventScroll` option.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
22
46
|
preventScroll?: MaybeRefOrGetter<boolean>;
|
|
23
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* When `true` and `modal` is `true`, applies the `inert` attribute (if supported
|
|
49
|
+
* by the browser) to elements outside the focus trap to prevent user interaction
|
|
50
|
+
* and assistive technology access.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
24
53
|
outsideElementsInert?: MaybeRefOrGetter<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* An optional error handler function that will be called if there's an
|
|
56
|
+
* issue during the focus trap activation process.
|
|
57
|
+
* @param error - The error object.
|
|
58
|
+
*/
|
|
59
|
+
onError?: (error: unknown) => void;
|
|
25
60
|
}
|
|
26
61
|
export interface UseFocusTrapReturn {
|
|
27
|
-
|
|
62
|
+
/** Check if the focus trap is currently active */
|
|
63
|
+
isActive: ComputedRef<boolean>;
|
|
64
|
+
/** Manually activate the focus trap (if enabled and open) */
|
|
65
|
+
activate: () => void;
|
|
66
|
+
/** Manually deactivate the focus trap */
|
|
67
|
+
deactivate: () => void;
|
|
28
68
|
}
|
|
29
69
|
/**
|
|
30
|
-
*
|
|
70
|
+
* Creates a focus trap for a floating element using focus-trap library.
|
|
71
|
+
* Manages focus containment, modal behavior, and accessibility features.
|
|
31
72
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param context - FloatingContext or TreeNode<FloatingContext> to trap within
|
|
36
|
-
* @param options - Configuration options controlling trap behavior
|
|
37
|
-
* @returns Cleanup API
|
|
73
|
+
* @param context - FloatingContext or TreeNode containing floating element refs
|
|
74
|
+
* @param options - Configuration options for the focus trap
|
|
75
|
+
* @returns Object with isActive state, and manual control methods
|
|
38
76
|
*/
|
|
39
77
|
export declare function useFocusTrap(context: FloatingContext | TreeNode<FloatingContext>, options?: UseFocusTrapOptions): UseFocusTrapReturn;
|
|
40
|
-
export type { FloatingContext };
|
|
41
78
|
//# sourceMappingURL=use-focus-trap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-focus-trap.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus-trap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-focus-trap.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus-trap.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,gBAAgB,EAKtB,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAA;AAO3E,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACnC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACjC;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,MAAM,GAAG,KAAK,CAAA;IACzE;;;;OAIG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACvC;;;;OAIG;IACH,eAAe,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAC3C;;;;OAIG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACzC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAChD;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CACnC;AAED,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC9B,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,yCAAyC;IACzC,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB;AAiBD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC,EACpD,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CA2LpB"}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"use-focus.d.ts","sourceRoot":"","sources":["../../../src/composables/interactions/use-focus.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,gBAAgB,EAMtB,MAAM,KAAK,CAAA;AACZ,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAA;AAC7E,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,6CAA6C,CAAA;AAyBjF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,GAAE,eAAoB,GAAG,cAAc,CAsMhG;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"}
|
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
2
|
import { FloatingContext } from '../positioning/use-floating';
|
|
3
3
|
import { TreeNode } from '../positioning/use-floating-tree';
|
|
4
|
+
export type NavigationAction = {
|
|
5
|
+
type: "navigate";
|
|
6
|
+
index: number | null;
|
|
7
|
+
} | {
|
|
8
|
+
type: "close";
|
|
9
|
+
};
|
|
10
|
+
export interface StrategyContext {
|
|
11
|
+
current: number | null;
|
|
12
|
+
items: Array<HTMLElement | null>;
|
|
13
|
+
isRtl: boolean;
|
|
14
|
+
loop: boolean;
|
|
15
|
+
allowEscape: boolean;
|
|
16
|
+
isVirtual: boolean;
|
|
17
|
+
cols: number;
|
|
18
|
+
nested: boolean;
|
|
19
|
+
isDisabled: (index: number) => boolean;
|
|
20
|
+
findNextEnabled: (start: number, dir: 1 | -1, wrap: boolean) => number | null;
|
|
21
|
+
getFirstEnabledIndex: () => number | null;
|
|
22
|
+
getLastEnabledIndex: () => number | null;
|
|
23
|
+
}
|
|
24
|
+
export interface NavigationStrategy {
|
|
25
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
26
|
+
}
|
|
27
|
+
export declare class VerticalNavigationStrategy implements NavigationStrategy {
|
|
28
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
29
|
+
}
|
|
30
|
+
export declare class HorizontalNavigationStrategy implements NavigationStrategy {
|
|
31
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
32
|
+
}
|
|
33
|
+
export declare class GridNavigationStrategy implements NavigationStrategy {
|
|
34
|
+
private fallbackToLinear;
|
|
35
|
+
private loopDirection;
|
|
36
|
+
constructor(fallbackToLinear?: boolean, loopDirection?: "row" | "next");
|
|
37
|
+
handleKey(key: string, context: StrategyContext): NavigationAction | null;
|
|
38
|
+
}
|
|
4
39
|
/**
|
|
5
40
|
* Options for configuring list-style keyboard/mouse navigation behavior.
|
|
6
41
|
*
|
|
@@ -1 +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;
|
|
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,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