sb-floating-panel-vue 1.0.0 → 4.0.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 +305 -128
- package/dist/components/SbContainer.vue.d.ts +31 -61
- package/dist/components/SbFloating.vue.d.ts +22 -69
- package/dist/components/SbReference.vue.d.ts +11 -34
- package/dist/composables/useSbFloatingPanel.d.ts +26 -76
- package/dist/context.d.ts +32 -0
- package/dist/focus.d.ts +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/sb-floating-panel.es.js +375 -218
- package/dist/sb-floating-panel.umd.js +1 -1
- package/dist/types.d.ts +200 -0
- package/package.json +32 -34
- package/dist/sb-floating-panel-vue.css +0 -1
|
@@ -1,75 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
interface SbFloatingProps {
|
|
8
|
-
/**
|
|
9
|
-
* The ref to bind to the floating panel element.
|
|
10
|
-
*/
|
|
11
|
-
floatingRef: Ref<HTMLElement | null>;
|
|
12
|
-
/**
|
|
13
|
-
* Optional ref to bind to the floating arrow element.
|
|
14
|
-
*/
|
|
15
|
-
floatingArrowRef?: Ref<HTMLElement | null>;
|
|
16
|
-
/**
|
|
17
|
-
* Whether the floating panel is open (visible).
|
|
18
|
-
*/
|
|
19
|
-
isOpen: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* The final placement resolved by Floating UI (e.g., 'bottom-start').
|
|
22
|
-
*/
|
|
23
|
-
floatingPlacement: Placement;
|
|
24
|
-
/**
|
|
25
|
-
* Computed inline styles for the floating panel.
|
|
26
|
-
*/
|
|
27
|
-
floatingStyle: CSSProperties;
|
|
28
|
-
/**
|
|
29
|
-
* Computed inline styles for the floating arrow (optional).
|
|
30
|
-
*/
|
|
31
|
-
floatingArrowStyle?: CSSProperties;
|
|
32
|
-
/**
|
|
33
|
-
* Optional dimension (width & height) of the floating arrow.
|
|
34
|
-
* If provided, will override default arrow size.
|
|
35
|
-
*/
|
|
36
|
-
arrowDimensions?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Optional z-index to apply to the floating panel and arrow.
|
|
39
|
-
*/
|
|
40
|
-
zIndex?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Animation name used in Vue <transition>.
|
|
43
|
-
* Supported values: 'fade', 'scale-fade', 'none'.
|
|
44
|
-
* @default 'scale-fade'
|
|
45
|
-
*/
|
|
46
|
-
animation?: 'fade' | 'scale-fade' | 'none';
|
|
47
|
-
/**
|
|
48
|
-
* Duration of the transition animation in milliseconds.
|
|
49
|
-
* @default 300
|
|
50
|
-
*/
|
|
51
|
-
duration?: number;
|
|
52
|
-
}
|
|
53
|
-
declare function __VLS_template(): {
|
|
54
|
-
attrs: Partial<{}>;
|
|
55
|
-
slots: {
|
|
56
|
-
default?(_: {}): any;
|
|
57
|
-
};
|
|
58
|
-
refs: {};
|
|
59
|
-
rootEl: any;
|
|
1
|
+
import { TransitionProps } from 'vue';
|
|
2
|
+
import { SbFloatingProps } from '../types';
|
|
3
|
+
declare var __VLS_23: {};
|
|
4
|
+
type __VLS_Slots = {} & {
|
|
5
|
+
default?: (props: typeof __VLS_23) => any;
|
|
60
6
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
7
|
+
declare const __VLS_base: import('vue').DefineComponent<SbFloatingProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
8
|
+
"after-enter": () => any;
|
|
9
|
+
"after-leave": () => any;
|
|
10
|
+
}, string, import('vue').PublicProps, Readonly<SbFloatingProps> & Readonly<{
|
|
11
|
+
"onAfter-enter"?: (() => any) | undefined;
|
|
12
|
+
"onAfter-leave"?: (() => any) | undefined;
|
|
13
|
+
}>, {
|
|
14
|
+
as: string;
|
|
15
|
+
role: string | null;
|
|
16
|
+
transition: string | TransitionProps;
|
|
17
|
+
teleportTo: string | HTMLElement;
|
|
18
|
+
teleportDisabled: boolean;
|
|
19
|
+
zIndex: string | number;
|
|
20
|
+
autoFocus: boolean;
|
|
69
21
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
70
|
-
declare const
|
|
22
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
23
|
+
declare const _default: typeof __VLS_export;
|
|
71
24
|
export default _default;
|
|
72
|
-
type
|
|
25
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
73
26
|
new (): {
|
|
74
27
|
$slots: S;
|
|
75
28
|
};
|
|
@@ -1,40 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
interface SbReferenceProps {
|
|
7
|
-
/**
|
|
8
|
-
* The ref to bind to the reference DOM element.
|
|
9
|
-
*/
|
|
10
|
-
referenceRef: Ref<HTMLElement | null>;
|
|
11
|
-
/**
|
|
12
|
-
* HTML tag to render as the reference.
|
|
13
|
-
* Useful for accessibility and customization.
|
|
14
|
-
* @default 'button'
|
|
15
|
-
*/
|
|
16
|
-
as?: 'button' | 'a' | 'div' | 'span';
|
|
17
|
-
/**
|
|
18
|
-
* Optional click handler for toggling the floating panel.
|
|
19
|
-
*/
|
|
20
|
-
onClick?: () => void;
|
|
21
|
-
}
|
|
22
|
-
declare function __VLS_template(): {
|
|
23
|
-
attrs: Partial<{}>;
|
|
24
|
-
slots: {
|
|
25
|
-
default?(_: {}): any;
|
|
26
|
-
};
|
|
27
|
-
refs: {};
|
|
28
|
-
rootEl: any;
|
|
1
|
+
import { SbReferenceProps } from '../types';
|
|
2
|
+
declare var __VLS_10: {};
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
default?: (props: typeof __VLS_10) => any;
|
|
29
5
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<SbReferenceProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SbReferenceProps> & Readonly<{}>, {
|
|
7
|
+
as: string | import('vue').Component;
|
|
8
|
+
id: string;
|
|
9
|
+
ariaHaspopup: "dialog" | "menu" | "listbox" | "tree" | "grid" | "true" | "false";
|
|
34
10
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
35
|
-
declare const
|
|
11
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
36
13
|
export default _default;
|
|
37
|
-
type
|
|
14
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
38
15
|
new (): {
|
|
39
16
|
$slots: S;
|
|
40
17
|
};
|
|
@@ -1,81 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ComputedRef, CSSProperties, MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
import { SbAlignment, SbPlacement, SbSide, SbStrategy } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Options of the internal `useSbFloatingPanel` composable. Every option can be a value,
|
|
5
|
+
* a ref or a getter, so `SbContainer` props stay reactive.
|
|
5
6
|
*/
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* When enabled, synchronizes the width of the floating element to match the reference element.
|
|
27
|
-
* Useful for dropdowns or inputs.
|
|
28
|
-
*/
|
|
29
|
-
hasResize?: boolean;
|
|
7
|
+
export interface FloatingPanelOptions {
|
|
8
|
+
isOpen: MaybeRefOrGetter<boolean>;
|
|
9
|
+
placement: MaybeRefOrGetter<SbPlacement>;
|
|
10
|
+
strategy: MaybeRefOrGetter<SbStrategy>;
|
|
11
|
+
offset: MaybeRefOrGetter<number>;
|
|
12
|
+
padding: MaybeRefOrGetter<number>;
|
|
13
|
+
matchWidth: MaybeRefOrGetter<boolean | 'min'>;
|
|
14
|
+
hideWhenDetached: MaybeRefOrGetter<boolean>;
|
|
15
|
+
}
|
|
16
|
+
export interface FloatingPanel {
|
|
17
|
+
reference: Ref<HTMLElement | null>;
|
|
18
|
+
floating: Ref<HTMLElement | null>;
|
|
19
|
+
/** Positioning styles for the outer wrapper (Floating UI styles + `visibility` from `hide`). */
|
|
20
|
+
floatingStyles: ComputedRef<CSSProperties>;
|
|
21
|
+
/** Placement resolved after `flip`. */
|
|
22
|
+
placement: Readonly<Ref<SbPlacement>>;
|
|
23
|
+
side: ComputedRef<SbSide>;
|
|
24
|
+
align: ComputedRef<SbAlignment | undefined>;
|
|
25
|
+
isPositioned: Readonly<Ref<boolean>>;
|
|
26
|
+
update: () => void;
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
|
-
*
|
|
33
|
-
* floating elements with optional arrow and dynamic width support.
|
|
34
|
-
*
|
|
35
|
-
* It provides bindings and style objects ready to apply to your `ref` elements in Vue templates.
|
|
36
|
-
*
|
|
37
|
-
* @param settings - Configuration options for placement, offset, and behavior.
|
|
38
|
-
* @returns Bindings and utility functions to control the floating panel.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
42
|
-
* const {
|
|
43
|
-
* reference,
|
|
44
|
-
* floating,
|
|
45
|
-
* floatingArrow,
|
|
46
|
-
* floatingPlacement,
|
|
47
|
-
* floatingStyle,
|
|
48
|
-
* floatingArrowStyle,
|
|
49
|
-
* isOpen,
|
|
50
|
-
* toggle,
|
|
51
|
-
* open,
|
|
52
|
-
* close
|
|
53
|
-
* } = useSbFloatingPanel({
|
|
54
|
-
* placement: 'bottom',
|
|
55
|
-
* strategy: 'absolute',
|
|
56
|
-
* offsetValue: 10,
|
|
57
|
-
* hasArrow: true,
|
|
58
|
-
* hasResize: false
|
|
59
|
-
* });
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```html
|
|
64
|
-
* <div ref="reference">Anchor</div>
|
|
65
|
-
* <div ref="floating" v-if="isOpen">Panel</div>
|
|
66
|
-
* <div ref="floatingArrow" v-if="isOpen">Arrow</div>
|
|
67
|
-
* ```
|
|
29
|
+
* Wraps Floating UI for the components. Not part of the public API.
|
|
68
30
|
*/
|
|
69
|
-
export declare function useSbFloatingPanel(
|
|
70
|
-
reference: Ref<HTMLElement | null>;
|
|
71
|
-
floating: Ref<FloatingElement | null>;
|
|
72
|
-
floatingArrow: Ref<HTMLElement | null>;
|
|
73
|
-
floatingPlacement: Ref<Placement>;
|
|
74
|
-
floatingStyle: ComputedRef<CSSProperties>;
|
|
75
|
-
floatingArrowStyle: ComputedRef<CSSProperties>;
|
|
76
|
-
isOpen: Ref<boolean>;
|
|
77
|
-
toggle: () => void;
|
|
78
|
-
open: () => void;
|
|
79
|
-
close: () => void;
|
|
80
|
-
};
|
|
81
|
-
export {};
|
|
31
|
+
export declare function useSbFloatingPanel(options: FloatingPanelOptions): FloatingPanel;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { InjectionKey, Ref } from 'vue';
|
|
2
|
+
import { FloatingPanel } from './composables/useSbFloatingPanel';
|
|
3
|
+
import { SbTrigger } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* State shared by `SbContainer` with `SbReference` and `SbFloating`.
|
|
6
|
+
*/
|
|
7
|
+
export interface SbFloatingContext extends FloatingPanel {
|
|
8
|
+
isOpen: Readonly<Ref<boolean>>;
|
|
9
|
+
disabled: Readonly<Ref<boolean>>;
|
|
10
|
+
trigger: Readonly<Ref<SbTrigger>>;
|
|
11
|
+
floatingId: string;
|
|
12
|
+
/** Id of the mounted `SbReference`, used to name the panel with `aria-labelledby`. */
|
|
13
|
+
referenceId: Ref<string | undefined>;
|
|
14
|
+
/** `role` of the mounted `SbFloating`, used to derive `aria-haspopup` on the reference. */
|
|
15
|
+
floatingRole: Ref<string | null>;
|
|
16
|
+
/** Set when an outside press closes the panel on a focusable element, which keeps focus. */
|
|
17
|
+
skipFocusReturn: boolean;
|
|
18
|
+
open: () => void;
|
|
19
|
+
close: () => void;
|
|
20
|
+
toggle: () => void;
|
|
21
|
+
/** Whether an event target is inside the reference, the panel or a nested container. */
|
|
22
|
+
contains: (target: EventTarget | null) => boolean;
|
|
23
|
+
/** Registers a nested container; returns the function that unregisters it. */
|
|
24
|
+
registerChild: (child: SbFloatingContext) => () => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Panel roles that make the reference a popup trigger, with their `aria-haspopup` value.
|
|
28
|
+
* Panels with these roles are also named after the reference.
|
|
29
|
+
*/
|
|
30
|
+
export declare const POPUP_ROLES: Record<string, 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid'>;
|
|
31
|
+
export declare const sbFloatingContextKey: InjectionKey<SbFloatingContext>;
|
|
32
|
+
export declare function useSbFloatingContext(component: string): SbFloatingContext;
|
package/dist/focus.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Marks the hidden elements placed around a teleported panel to keep the Tab order. */
|
|
2
|
+
export declare const FOCUS_GUARD_ATTRIBUTE = "data-sbf-focus-guard";
|
|
3
|
+
/** Whether pressing `target` moves focus to it (or to a focusable ancestor). */
|
|
4
|
+
export declare function isFocusable(target: EventTarget | null): boolean;
|
|
5
|
+
/** Elements reachable with Tab inside `root`, in document order (focus guards excluded). */
|
|
6
|
+
export declare function getTabbables(root: ParentNode): HTMLElement[];
|
|
7
|
+
/** First element reachable with Tab after `anchor` in document order, skipping the excluded ones. */
|
|
8
|
+
export declare function getNextTabbable(anchor: Element, exclude: (el: HTMLElement) => boolean): HTMLElement | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useSbFloatingPanel } from './composables/useSbFloatingPanel';
|
|
2
1
|
export { default as SbContainer } from './components/SbContainer.vue';
|
|
3
2
|
export { default as SbReference } from './components/SbReference.vue';
|
|
4
3
|
export { default as SbFloating } from './components/SbFloating.vue';
|
|
4
|
+
export type { SbContainerProps, SbContainerSlotProps, SbContainerExposed, SbReferenceProps, SbFloatingProps, SbTrigger, SbPlacement, SbSide, SbAlignment, SbStrategy, } from './types';
|