@aleph-alpha/ui-library 5.2.0 → 5.3.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/system/index.d.ts +1 -0
- package/dist/system/lib/useAnchorFloat.d.ts +143 -0
- package/dist/system/lib.js +19412 -18916
- package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +35 -0
- package/dist/system/patterns/UiFloatActions/UiFloatActions.vue.d.ts +43 -0
- package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +16 -0
- package/dist/system/patterns/UiFloatActions/index.d.ts +3 -0
- package/dist/system/patterns/UiFloatActions/types.d.ts +127 -0
- package/dist/system/patterns/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/lib/useAnchorFloat.test.ts +166 -0
- package/src/lib/useAnchorFloat.ts +437 -0
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +321 -0
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +767 -0
- package/src/patterns/UiFloatActions/UiFloatActions.vue +220 -0
- package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +104 -0
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +152 -0
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.test.ts +86 -0
- package/src/patterns/UiFloatActions/floatActionItemContext.ts +20 -0
- package/src/patterns/UiFloatActions/index.ts +3 -0
- package/src/patterns/UiFloatActions/types.ts +155 -0
- package/src/patterns/index.ts +1 -0
package/dist/system/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './components';
|
|
|
4
4
|
export * from './patterns';
|
|
5
5
|
export * from './templates';
|
|
6
6
|
export * from './lib/useDevice';
|
|
7
|
+
export * from './lib/useAnchorFloat';
|
|
7
8
|
export * from './directives';
|
|
8
9
|
export { Primitive } from 'reka-ui';
|
|
9
10
|
export type PrimitiveProps = RekaPrimitiveProps;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Placement } from '@floating-ui/vue';
|
|
2
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
3
|
+
export type AnchorFloatTrigger = 'hover' | 'click' | 'focus' | 'manual';
|
|
4
|
+
/** Per-axis distance between the anchor and the floating element, in pixels. */
|
|
5
|
+
export interface AnchorFloatOffset {
|
|
6
|
+
/** Distance along the placement axis (e.g. vertical gap for top/bottom). */
|
|
7
|
+
mainAxis?: number;
|
|
8
|
+
/** Distance along the cross axis (shifts the panel sideways). */
|
|
9
|
+
crossAxis?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Options for {@link useAnchorFloat}.
|
|
13
|
+
*
|
|
14
|
+
* @category Composables
|
|
15
|
+
* @useCases contextual toolbar positioning, custom floating panels
|
|
16
|
+
* @keywords float, anchor, floating-ui, composable, positioning
|
|
17
|
+
* @related UiFloatActions, UiFloatActionItems
|
|
18
|
+
*/
|
|
19
|
+
export interface UseAnchorFloatOptions {
|
|
20
|
+
/**
|
|
21
|
+
* How the floating panel opens.
|
|
22
|
+
* - `hover` — pointer hover and keyboard focus
|
|
23
|
+
* - `focus` — keyboard focus
|
|
24
|
+
* - `click` — click or Enter/Space on the anchor
|
|
25
|
+
* - `manual` — controlled via `open`
|
|
26
|
+
* @default 'hover'
|
|
27
|
+
*/
|
|
28
|
+
trigger?: MaybeRefOrGetter<AnchorFloatTrigger>;
|
|
29
|
+
/**
|
|
30
|
+
* Preferred placement relative to the anchor element.
|
|
31
|
+
* Auto-flips via floating-ui when there is not enough room.
|
|
32
|
+
* @default 'top'
|
|
33
|
+
*/
|
|
34
|
+
placement?: MaybeRefOrGetter<Placement>;
|
|
35
|
+
/**
|
|
36
|
+
* Distance from the anchor. A number sets the main-axis offset only.
|
|
37
|
+
* @default 8
|
|
38
|
+
*/
|
|
39
|
+
offset?: MaybeRefOrGetter<number | AnchorFloatOffset>;
|
|
40
|
+
/**
|
|
41
|
+
* Controlled open state. When omitted, the composable manages state internally.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const open = ref(false);
|
|
45
|
+
* const float = useAnchorFloat({ trigger: 'manual', open });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
open?: Ref<boolean | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Delay in ms before opening on pointer hover.
|
|
51
|
+
* Does not apply to keyboard focus (opens immediately).
|
|
52
|
+
* @default 150
|
|
53
|
+
*/
|
|
54
|
+
openDelay?: MaybeRefOrGetter<number>;
|
|
55
|
+
/**
|
|
56
|
+
* Delay in ms before closing on pointer leave.
|
|
57
|
+
* @default 150
|
|
58
|
+
*/
|
|
59
|
+
closeDelay?: MaybeRefOrGetter<number>;
|
|
60
|
+
/**
|
|
61
|
+
* Close when clicking outside the anchor and floating panel.
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
dismissOnOutsideClick?: MaybeRefOrGetter<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Close when Escape is pressed and restore focus to the anchor.
|
|
67
|
+
* @default true
|
|
68
|
+
*/
|
|
69
|
+
dismissOnEscape?: MaybeRefOrGetter<boolean>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Anchors floating content to a reference element with configurable triggers,
|
|
73
|
+
* placement, and offset. Built on `@floating-ui/vue`.
|
|
74
|
+
*
|
|
75
|
+
* Prefer {@link UiFloatActions} for the standard component API. Use this composable
|
|
76
|
+
* when you need full control over markup, animation, or teleport targets.
|
|
77
|
+
*
|
|
78
|
+
* @param options - Trigger, placement, offset, and dismiss behaviour.
|
|
79
|
+
* @returns Refs, computed styles, open state, and event handlers to wire up
|
|
80
|
+
* anchor and floating elements manually.
|
|
81
|
+
* @example Hover trigger
|
|
82
|
+
* ```ts
|
|
83
|
+
* const {
|
|
84
|
+
* referenceRef,
|
|
85
|
+
* floatingRef,
|
|
86
|
+
* open,
|
|
87
|
+
* floatingStyles,
|
|
88
|
+
* isPositioned,
|
|
89
|
+
* onReferenceMouseEnter,
|
|
90
|
+
* onReferenceMouseLeave,
|
|
91
|
+
* onFloatingMouseEnter,
|
|
92
|
+
* onFloatingMouseLeave,
|
|
93
|
+
* } = useAnchorFloat({ trigger: 'hover', placement: 'top', offset: 8 });
|
|
94
|
+
* ```
|
|
95
|
+
* @example Controlled manual mode
|
|
96
|
+
* ```ts
|
|
97
|
+
* const open = ref(false);
|
|
98
|
+
* const { show, hide, referenceRef, floatingRef, floatingStyles } =
|
|
99
|
+
* useAnchorFloat({ trigger: 'manual', open });
|
|
100
|
+
* ```
|
|
101
|
+
* @category Composables
|
|
102
|
+
* @useCases custom floating panels, headless toolbar positioning
|
|
103
|
+
* @keywords float, anchor, floating-ui, composable
|
|
104
|
+
* @related UiFloatActions, UiFloatActionItems
|
|
105
|
+
*/
|
|
106
|
+
export declare function useAnchorFloat(options?: UseAnchorFloatOptions): {
|
|
107
|
+
anchorRef: Ref<HTMLElement | null, HTMLElement | null>;
|
|
108
|
+
referenceRef: Ref<HTMLElement | null, HTMLElement | null>;
|
|
109
|
+
floatingRef: Ref<HTMLElement | null, HTMLElement | null>;
|
|
110
|
+
open: Ref<boolean | undefined, boolean | undefined>;
|
|
111
|
+
side: import('vue').ComputedRef<"top" | "right" | "bottom" | "left">;
|
|
112
|
+
placement: Readonly<Ref<Placement, Placement>>;
|
|
113
|
+
middlewareData: Readonly<Ref<import('@floating-ui/vue').MiddlewareData, import('@floating-ui/vue').MiddlewareData>>;
|
|
114
|
+
floatingStyles: Readonly<Ref<{
|
|
115
|
+
position: import('@floating-ui/vue').Strategy;
|
|
116
|
+
top: string;
|
|
117
|
+
left: string;
|
|
118
|
+
transform?: string;
|
|
119
|
+
willChange?: string;
|
|
120
|
+
}, {
|
|
121
|
+
position: import('@floating-ui/vue').Strategy;
|
|
122
|
+
top: string;
|
|
123
|
+
left: string;
|
|
124
|
+
transform?: string;
|
|
125
|
+
willChange?: string;
|
|
126
|
+
}>>;
|
|
127
|
+
isPositioned: Readonly<Ref<boolean, boolean>>;
|
|
128
|
+
show: () => void;
|
|
129
|
+
hide: (restoreFocus?: boolean) => void;
|
|
130
|
+
toggle: () => void;
|
|
131
|
+
onReferenceMouseEnter: () => void;
|
|
132
|
+
onReferenceMouseLeave: () => void;
|
|
133
|
+
onReferenceFocus: () => void;
|
|
134
|
+
onReferenceBlur: (event: FocusEvent) => void;
|
|
135
|
+
onFloatingMouseEnter: () => void;
|
|
136
|
+
onFloatingMouseLeave: () => void;
|
|
137
|
+
onFloatingFocusIn: () => void;
|
|
138
|
+
onFloatingFocusOut: (event: FocusEvent) => void;
|
|
139
|
+
onReferenceClick: (event: MouseEvent) => void;
|
|
140
|
+
onReferenceKeydown: (event: KeyboardEvent) => void;
|
|
141
|
+
};
|
|
142
|
+
/** @deprecated Use `useAnchorFloat` instead. */
|
|
143
|
+
export declare const useFloat: typeof useAnchorFloat;
|