@aleph-alpha/ui-library 5.9.0 → 5.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.
Files changed (54) hide show
  1. package/config.js +157 -4
  2. package/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +3 -1
  3. package/dist/system/components/UiFileType/types.d.ts +2 -1
  4. package/dist/system/components/UiSwitch/UiSwitch.vue.d.ts +1 -0
  5. package/dist/system/components/UiSwitch/types.d.ts +12 -0
  6. package/dist/system/components/core/switch/Switch.vue.d.ts +2 -0
  7. package/dist/system/components/core/switch/index.d.ts +8 -0
  8. package/dist/system/index.d.ts +1 -0
  9. package/dist/system/lib/scrollbar.d.ts +37 -0
  10. package/dist/system/lib/useAnchorFloat.d.ts +0 -2
  11. package/dist/system/lib/useIsTruncated.d.ts +15 -0
  12. package/dist/system/lib.js +15052 -14843
  13. package/dist/system/patterns/UiFloatActions/types.d.ts +0 -1
  14. package/dist/system/story-sidebar-icons.json +4 -1
  15. package/docs/public-docs/foundations.md +17 -15
  16. package/package.json +3 -3
  17. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +54 -0
  18. package/src/components/UiCodeBlock/UiCodeBlock.vue +84 -32
  19. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +65 -21
  20. package/src/components/UiFileItem/UiFileItem.vue +17 -4
  21. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +49 -90
  22. package/src/components/UiFileType/UiFileType.stories.ts +13 -2
  23. package/src/components/UiFileType/UiFileType.vue +8 -0
  24. package/src/components/UiFileType/__tests__/UiFileType.test.ts +10 -0
  25. package/src/components/UiFileType/types.ts +3 -1
  26. package/src/components/UiSnackbar/UiSnackbar.stories.ts +4 -5
  27. package/src/components/UiSwitch/UiSwitch.stories.ts +658 -7
  28. package/src/components/UiSwitch/UiSwitch.vue +1 -0
  29. package/src/components/UiSwitch/__tests__/UiSwitch.test.ts +48 -0
  30. package/src/components/UiSwitch/types.ts +13 -0
  31. package/src/components/UiToggleGroup/UiToggleGroup.vue +1 -1
  32. package/src/components/core/field/FieldLabel.vue +1 -1
  33. package/src/components/core/label/Label.vue +1 -1
  34. package/src/components/core/switch/Switch.vue +23 -17
  35. package/src/components/core/switch/index.ts +36 -0
  36. package/src/index.ts +3 -0
  37. package/src/lib/scrollbar.ts +295 -0
  38. package/src/lib/useAnchorFloat.ts +0 -2
  39. package/src/lib/useIsTruncated.test.ts +174 -0
  40. package/src/lib/useIsTruncated.ts +75 -0
  41. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +1162 -0
  42. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +552 -1
  43. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +5 -21
  44. package/src/patterns/UiFloatActions/UiFloatActionItems.vue +0 -1
  45. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +0 -1
  46. package/src/patterns/UiFloatActions/UiFloatActions.vue +1 -2
  47. package/src/patterns/UiFloatActions/types.ts +0 -1
  48. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +132 -117
  49. package/src/theme/Background.stories.ts +27 -1
  50. package/src/theme/BorderRadius.stories.ts +5 -0
  51. package/src/theme/Overlay.stories.ts +12 -1
  52. package/src/theme/Scrollbar.stories.ts +260 -0
  53. package/tokens.json +224 -2
  54. package/src/components/UiFileItem/UiFileItem.stories.ts +0 -442
@@ -9,6 +9,7 @@ defineOptions({
9
9
  const props = withDefaults(defineProps<UiSwitchProps>(), {
10
10
  disabled: false,
11
11
  required: false,
12
+ size: 'default',
12
13
  });
13
14
 
14
15
  const model = defineModel<boolean>({
@@ -47,4 +47,52 @@ describe('UiSwitch', () => {
47
47
  await userEvent.click(getByRole('switch'));
48
48
  expect(emitted('update:modelValue')).toBeUndefined();
49
49
  });
50
+
51
+ test('defaults to the roomier track and thumb', () => {
52
+ const { getByRole } = render(UiSwitch, {
53
+ props: { name: 'switch' },
54
+ });
55
+ const track = getByRole('switch');
56
+
57
+ expect(track).toHaveClass('h-5', 'w-9');
58
+ // The size variant wins over the conflicting base dimensions.
59
+ expect(track).not.toHaveClass('w-8');
60
+ expect(track.querySelector('[data-slot="switch-thumb"]')).toHaveClass(
61
+ 'size-4',
62
+ );
63
+ });
64
+
65
+ test('small size tightens the track and thumb', () => {
66
+ const { getByRole } = render(UiSwitch, {
67
+ props: { name: 'switch', size: 'sm' },
68
+ });
69
+ const track = getByRole('switch');
70
+
71
+ expect(track).toHaveClass('h-4', 'w-7');
72
+ expect(track.querySelector('[data-slot="switch-thumb"]')).toHaveClass(
73
+ 'size-3',
74
+ );
75
+ });
76
+
77
+ test('size only picks the variant and is not rendered as an attribute', () => {
78
+ const { getByRole } = render(UiSwitch, {
79
+ props: { name: 'switch', size: 'sm' },
80
+ });
81
+
82
+ // The switch renders a `button`, which has no `size` attribute.
83
+ expect(getByRole('switch')).not.toHaveAttribute('size');
84
+ });
85
+
86
+ test('small size keeps the switch semantics and stays operable', async () => {
87
+ const { getByRole, emitted } = render(UiSwitch, {
88
+ props: { name: 'switch', size: 'sm' },
89
+ });
90
+ const track = getByRole('switch');
91
+
92
+ expect(track).toHaveAttribute('role', 'switch');
93
+ expect(track).toHaveAttribute('aria-checked', 'false');
94
+
95
+ await userEvent.click(track);
96
+ expect(emitted('update:modelValue')[0][0]).toBe(true);
97
+ });
50
98
  });
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Size options for the UiSwitch component.
3
+ * - `default`: 36×20px track with a 16px thumb
4
+ * - `sm`: 28×16px track with a 12px thumb, for dense rows and table cells
5
+ */
6
+ export type UiSwitchSize = 'default' | 'sm';
7
+
1
8
  /**
2
9
  * A toggle switch for on/off states. Use for settings, preferences,
3
10
  * or any binary choice that takes effect immediately.
@@ -21,4 +28,10 @@ export type UiSwitchProps = {
21
28
  * @default false
22
29
  */
23
30
  required?: boolean;
31
+ /**
32
+ * Track and thumb scale. Neither size reaches the 24px minimum target height,
33
+ * so pair the switch with a label that extends the target (WCAG 2.5.8).
34
+ * @default 'default'
35
+ */
36
+ size?: UiSwitchSize;
24
37
  };
@@ -18,11 +18,11 @@ const props = withDefaults(
18
18
  /**
19
19
  * The default value when initially rendered (uncontrolled mode).
20
20
  */
21
- // eslint-disable-next-line vue/require-default-prop
22
21
  defaultValue?: UiToggleGroupModelValue<T>;
23
22
  }
24
23
  >(),
25
24
  {
25
+ defaultValue: undefined,
26
26
  disabled: false,
27
27
  variant: 'default',
28
28
  size: 'default',
@@ -10,7 +10,7 @@ const props = defineProps<{
10
10
  </script>
11
11
 
12
12
  <template>
13
- <!-- eslint-disable-next-line vuejs-accessibility/label-has-for -->
13
+ <!-- eslint-disable-next-line vuejs-accessibility/label-has-for -- false positive: `for` is forwarded to the underlying Label wrapper, which the rule cannot statically resolve -->
14
14
  <Label
15
15
  data-slot="field-label"
16
16
  :for="props.for"
@@ -11,7 +11,7 @@ const delegatedProps = reactiveOmit(props, 'class', 'for');
11
11
  </script>
12
12
 
13
13
  <template>
14
- <!-- eslint-disable-next-line vuejs-accessibility/label-has-for -->
14
+ <!-- eslint-disable-next-line vuejs-accessibility/label-has-for -- false positive: `for` is forwarded to the underlying reka-ui Label, which the rule cannot statically resolve -->
15
15
  <Label
16
16
  data-slot="label"
17
17
  v-bind="delegatedProps"
@@ -1,19 +1,37 @@
1
1
  <script setup lang="ts">
2
2
  import type { SwitchRootEmits, SwitchRootProps } from 'reka-ui';
3
- import type { HTMLAttributes } from 'vue';
3
+ import { computed, type HTMLAttributes } from 'vue';
4
4
  import { reactiveOmit } from '@vueuse/core';
5
5
  import { SwitchRoot, SwitchThumb, useForwardPropsEmits } from 'reka-ui';
6
6
  import { cn } from '@/lib/utils';
7
+ import {
8
+ switchRootVariants,
9
+ switchThumbVariants,
10
+ type SwitchVariants,
11
+ } from '.';
7
12
 
8
13
  const props = defineProps<
9
- SwitchRootProps & { class?: HTMLAttributes['class'] }
14
+ SwitchRootProps & {
15
+ class?: HTMLAttributes['class'];
16
+ size?: SwitchVariants['size'];
17
+ }
10
18
  >();
11
19
 
12
20
  const emits = defineEmits<SwitchRootEmits>();
13
21
 
14
- const delegatedProps = reactiveOmit(props, 'class');
22
+ // `size` only picks the cva variants — `SwitchRoot` renders a `button`, which has
23
+ // no `size` attribute, so forwarding it would leak an invalid attribute.
24
+ const delegatedProps = reactiveOmit(props, 'class', 'size');
15
25
 
16
26
  const forwarded = useForwardPropsEmits(delegatedProps, emits);
27
+
28
+ const switchRootClass = computed(() =>
29
+ cn(switchRootVariants({ size: props.size }), props.class),
30
+ );
31
+
32
+ const switchThumbClass = computed(() =>
33
+ cn(switchThumbVariants({ size: props.size })),
34
+ );
17
35
  </script>
18
36
 
19
37
  <template>
@@ -21,21 +39,9 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
21
39
  #default="slotProps"
22
40
  data-slot="switch"
23
41
  v-bind="forwarded"
24
- :class="
25
- cn(
26
- 'peer data-[state=checked]:bg-background-accent-default data-[state=unchecked]:bg-background-surface-muted-strong ui-focus-ring dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all disabled:cursor-not-allowed disabled:opacity-50 p-0.5 h-5 w-9',
27
- props.class,
28
- )
29
- "
42
+ :class="switchRootClass"
30
43
  >
31
- <SwitchThumb
32
- data-slot="switch-thumb"
33
- :class="
34
- cn(
35
- 'data-[state=checked]:bg-background-accent-soft data-[state=unchecked]:bg-background-surface-secondary dark:data-[state=unchecked]:bg-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0',
36
- )
37
- "
38
- >
44
+ <SwitchThumb data-slot="switch-thumb" :class="switchThumbClass">
39
45
  <slot name="thumb" v-bind="slotProps" />
40
46
  </SwitchThumb>
41
47
  </SwitchRoot>
@@ -1 +1,37 @@
1
+ import { cva, type VariantProps } from 'class-variance-authority';
2
+
1
3
  export { default as Switch } from './Switch.vue';
4
+
5
+ export const switchRootVariants = cva(
6
+ 'peer data-[state=checked]:bg-background-accent-default data-[state=unchecked]:bg-background-surface-muted-strong ui-focus-ring dark:data-[state=unchecked]:bg-input/80 inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all disabled:cursor-not-allowed disabled:opacity-50',
7
+ {
8
+ variants: {
9
+ size: {
10
+ default: 'h-5 w-9 p-0.5',
11
+ sm: 'h-4 w-7 p-0.25',
12
+ },
13
+ },
14
+ defaultVariants: {
15
+ size: 'default',
16
+ },
17
+ },
18
+ );
19
+
20
+ export const switchThumbVariants = cva(
21
+ 'data-[state=checked]:bg-background-accent-soft data-[state=unchecked]:bg-background-surface-secondary dark:data-[state=unchecked]:bg-foreground pointer-events-none block rounded-full ring-0 transition-transform data-[state=unchecked]:translate-x-0',
22
+ {
23
+ variants: {
24
+ // The checked offset is the free space inside the padding box, so it has
25
+ // to be declared per size for the thumb to rest against the far edge.
26
+ size: {
27
+ default: 'size-4 data-[state=checked]:translate-x-[calc(100%-2px)]',
28
+ sm: 'size-3 data-[state=checked]:translate-x-full',
29
+ },
30
+ },
31
+ defaultVariants: {
32
+ size: 'default',
33
+ },
34
+ },
35
+ );
36
+
37
+ export type SwitchVariants = VariantProps<typeof switchRootVariants>;
package/src/index.ts CHANGED
@@ -9,11 +9,13 @@ export * from './patterns';
9
9
  export * from './templates';
10
10
  export * from './lib/useDevice';
11
11
  export * from './lib/useAnchorFloat';
12
+ export * from './lib/scrollbar';
12
13
  export * from './directives';
13
14
  export { Primitive } from 'reka-ui';
14
15
  export type PrimitiveProps = RekaPrimitiveProps;
15
16
 
16
17
  import { vHover } from './directives/vHover';
18
+ import { installScrollbarBehavior } from './lib/scrollbar';
17
19
 
18
20
  /**
19
21
  * Vue SFC module shape used by the library installer.
@@ -46,6 +48,7 @@ const components = import.meta.glob<ComponentModule>(
46
48
  export default {
47
49
  install(app: App) {
48
50
  app.directive('hover', vHover);
51
+ installScrollbarBehavior();
49
52
  Object.values(components).forEach((component) => {
50
53
  const componentName = component.default.__name ?? component.default.name;
51
54
  if (componentName) {
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Auto-hide behavior for the library scrollbar.
3
+ *
4
+ * The look of the scrollbar (4px thumb, invisible track, reserved 16px lane) is
5
+ * pure CSS and ships with the UnoCSS preset. Only the *timing* rules need a
6
+ * runtime, because CSS has no way to express "one second after the last scroll":
7
+ *
8
+ * | Situation | Thumb |
9
+ * | -------------------------- | ------------------------------------------- |
10
+ * | At rest | Hidden |
11
+ * | Scrolling, incl. keyboard | Visible, fades in quickly |
12
+ * | Scrolling stops | Stays ~1s, then fades out |
13
+ * | Pointer hovering the lane | Visible, stays visible |
14
+ * | Being dragged | Visible until released, even off-element |
15
+ * | Content too short | No thumb, lane stays reserved |
16
+ * | Reduced motion | Appears and disappears instantly, no fade |
17
+ *
18
+ * The fades and the reduced-motion rule are CSS; this module only decides when
19
+ * a scroll container counts as active.
20
+ */
21
+
22
+ /** Set on `<html>` to switch the CSS from always-visible to auto-hide. */
23
+ const AUTO_HIDE_CLASS = 'ui-scrollbar-autohide';
24
+
25
+ /** Set on a scroll container while its thumb should be visible. */
26
+ const VISIBLE_ATTRIBUTE = 'data-ui-scrollbar';
27
+
28
+ const DEFAULT_IDLE_DELAY = 1000;
29
+
30
+ /**
31
+ * Not every browser dispatches pointer events over the scrollbar lane, so the
32
+ * lane hit test reaches a couple of pixels into the content. Without it the
33
+ * last known pointer position can stall just short of the lane.
34
+ */
35
+ const LANE_HIT_TOLERANCE = 2;
36
+
37
+ export type ScrollbarBehaviorOptions = {
38
+ /** Milliseconds the thumb stays visible after the last scroll. Defaults to 1000. */
39
+ idleDelay?: number;
40
+ /** Document to attach the listeners to. Defaults to the ambient `document`. */
41
+ document?: Document;
42
+ };
43
+
44
+ /** Teardown handles, keyed by document, so installing twice is a no-op. */
45
+ const installations = new WeakMap<Document, () => void>();
46
+
47
+ /** Teardown returned when there is nothing to install, e.g. during SSR. */
48
+ const noopTeardown = () => undefined;
49
+
50
+ function isElement(value: unknown): value is Element {
51
+ return (
52
+ typeof value === 'object' &&
53
+ value !== null &&
54
+ (value as Node).nodeType === 1
55
+ );
56
+ }
57
+
58
+ function readPx(value: string): number {
59
+ const parsed = Number.parseFloat(value);
60
+ return Number.isFinite(parsed) ? parsed : 0;
61
+ }
62
+
63
+ /**
64
+ * Installs the scroll, hover, and drag listeners that reveal and hide scrollbar
65
+ * thumbs, and puts the document into auto-hide mode.
66
+ *
67
+ * The library's Vue plugin calls this for you. Call it directly when you
68
+ * register components individually instead of installing the plugin. Safe to
69
+ * call during SSR and safe to call more than once per document.
70
+ * @param options Idle delay and target document overrides.
71
+ * @returns Teardown that removes the listeners and restores always-visible thumbs.
72
+ */
73
+ export function installScrollbarBehavior(
74
+ options: ScrollbarBehaviorOptions = {},
75
+ ): () => void {
76
+ const doc =
77
+ options.document ?? (typeof document === 'undefined' ? null : document);
78
+ const win = doc?.defaultView;
79
+ if (!doc || !win) return noopTeardown;
80
+
81
+ return (
82
+ installations.get(doc) ??
83
+ install(doc, win, options.idleDelay ?? DEFAULT_IDLE_DELAY)
84
+ );
85
+ }
86
+
87
+ function install(
88
+ doc: Document,
89
+ win: Window & typeof globalThis,
90
+ idleDelay: number,
91
+ ): () => void {
92
+ const root = doc.documentElement;
93
+
94
+ const hideTimers = new WeakMap<Element, number>();
95
+ /** Containers whose lane the pointer is currently over. */
96
+ const hovered = new Set<Element>();
97
+ /** Containers whose thumb is currently being dragged. */
98
+ const dragged = new Set<Element>();
99
+
100
+ let pointerX = Number.NaN;
101
+ let pointerY = Number.NaN;
102
+ let frame = 0;
103
+
104
+ function isHeld(element: Element) {
105
+ return hovered.has(element) || dragged.has(element);
106
+ }
107
+
108
+ function clearTimer(element: Element) {
109
+ const timer = hideTimers.get(element);
110
+ if (timer !== undefined) {
111
+ win.clearTimeout(timer);
112
+ hideTimers.delete(element);
113
+ }
114
+ }
115
+
116
+ function reveal(element: Element) {
117
+ clearTimer(element);
118
+ element.setAttribute(VISIBLE_ATTRIBUTE, 'visible');
119
+ }
120
+
121
+ function scheduleHide(element: Element) {
122
+ clearTimer(element);
123
+ if (isHeld(element)) return;
124
+
125
+ hideTimers.set(
126
+ element,
127
+ win.setTimeout(() => {
128
+ hideTimers.delete(element);
129
+ if (!isHeld(element)) element.removeAttribute(VISIBLE_ATTRIBUTE);
130
+ }, idleDelay),
131
+ );
132
+ }
133
+
134
+ /**
135
+ * True when the point sits in the strip of layout the scrollbar occupies.
136
+ * `offsetWidth - clientWidth` minus the borders is exactly the lane width, so
137
+ * this stays correct whatever the lane is sized to.
138
+ * @param element Candidate scroll container.
139
+ * @param x Viewport x coordinate.
140
+ * @param y Viewport y coordinate.
141
+ * @returns Whether the point is over the element's vertical or horizontal lane.
142
+ */
143
+ function isOnLane(element: Element, x: number, y: number): boolean {
144
+ let top: number;
145
+ let right: number;
146
+ let bottom: number;
147
+ let left: number;
148
+ let verticalLane: number;
149
+ let horizontalLane: number;
150
+
151
+ if (element === root) {
152
+ top = 0;
153
+ right = win.innerWidth;
154
+ bottom = win.innerHeight;
155
+ left = 0;
156
+ verticalLane = win.innerWidth - root.clientWidth;
157
+ horizontalLane = win.innerHeight - root.clientHeight;
158
+ } else {
159
+ if (!(element instanceof win.HTMLElement)) return false;
160
+
161
+ const rect = element.getBoundingClientRect();
162
+ const style = win.getComputedStyle(element);
163
+ const borderTop = readPx(style.borderTopWidth);
164
+ const borderRight = readPx(style.borderRightWidth);
165
+ const borderBottom = readPx(style.borderBottomWidth);
166
+ const borderLeft = readPx(style.borderLeftWidth);
167
+
168
+ top = rect.top + borderTop;
169
+ right = rect.right - borderRight;
170
+ bottom = rect.bottom - borderBottom;
171
+ left = rect.left + borderLeft;
172
+ verticalLane =
173
+ element.offsetWidth - element.clientWidth - borderLeft - borderRight;
174
+ horizontalLane =
175
+ element.offsetHeight - element.clientHeight - borderTop - borderBottom;
176
+ }
177
+
178
+ const isRtl = win.getComputedStyle(element).direction === 'rtl';
179
+ const onVerticalLane =
180
+ verticalLane > 0 &&
181
+ y >= top &&
182
+ y <= bottom &&
183
+ (isRtl
184
+ ? x >= left - LANE_HIT_TOLERANCE && x <= left + verticalLane
185
+ : x >= right - verticalLane - LANE_HIT_TOLERANCE && x <= right);
186
+ const onHorizontalLane =
187
+ horizontalLane > 0 &&
188
+ x >= left &&
189
+ x <= right &&
190
+ y >= bottom - horizontalLane - LANE_HIT_TOLERANCE &&
191
+ y <= bottom;
192
+
193
+ return onVerticalLane || onHorizontalLane;
194
+ }
195
+
196
+ function collectLanesAt(x: number, y: number): Set<Element> {
197
+ const found = new Set<Element>();
198
+ if (Number.isNaN(x) || Number.isNaN(y)) return found;
199
+
200
+ for (const element of [...doc.elementsFromPoint(x, y), root]) {
201
+ if (isOnLane(element, x, y)) found.add(element);
202
+ }
203
+
204
+ return found;
205
+ }
206
+
207
+ function syncHoveredLanes() {
208
+ frame = 0;
209
+ const next = collectLanesAt(pointerX, pointerY);
210
+
211
+ for (const element of hovered) {
212
+ if (next.has(element)) continue;
213
+ hovered.delete(element);
214
+ scheduleHide(element);
215
+ }
216
+
217
+ for (const element of next) {
218
+ if (hovered.has(element)) continue;
219
+ hovered.add(element);
220
+ reveal(element);
221
+ }
222
+ }
223
+
224
+ function onScroll(event: Event) {
225
+ const target = event.target;
226
+ const scroller = isElement(target) ? target : root;
227
+ reveal(scroller);
228
+ scheduleHide(scroller);
229
+ }
230
+
231
+ function onPointerMove(event: PointerEvent) {
232
+ pointerX = event.clientX;
233
+ pointerY = event.clientY;
234
+ if (frame) return;
235
+ frame = win.requestAnimationFrame(syncHoveredLanes);
236
+ }
237
+
238
+ function onPointerDown(event: PointerEvent) {
239
+ for (const element of collectLanesAt(event.clientX, event.clientY)) {
240
+ dragged.add(element);
241
+ reveal(element);
242
+ }
243
+ }
244
+
245
+ function onPointerUp() {
246
+ for (const element of dragged) scheduleHide(element);
247
+ dragged.clear();
248
+ }
249
+
250
+ function onPointerLeave() {
251
+ pointerX = Number.NaN;
252
+ pointerY = Number.NaN;
253
+ for (const element of hovered) scheduleHide(element);
254
+ hovered.clear();
255
+ }
256
+
257
+ root.classList.add(AUTO_HIDE_CLASS);
258
+ doc.addEventListener('scroll', onScroll, { capture: true, passive: true });
259
+ win.addEventListener('pointermove', onPointerMove, {
260
+ capture: true,
261
+ passive: true,
262
+ });
263
+ win.addEventListener('pointerdown', onPointerDown, {
264
+ capture: true,
265
+ passive: true,
266
+ });
267
+ win.addEventListener('pointerup', onPointerUp, { capture: true });
268
+ win.addEventListener('pointercancel', onPointerUp, { capture: true });
269
+ win.addEventListener('blur', onPointerUp);
270
+ doc.addEventListener('pointerleave', onPointerLeave);
271
+
272
+ const uninstall = () => {
273
+ installations.delete(doc);
274
+ doc.removeEventListener('scroll', onScroll, { capture: true });
275
+ win.removeEventListener('pointermove', onPointerMove, { capture: true });
276
+ win.removeEventListener('pointerdown', onPointerDown, { capture: true });
277
+ win.removeEventListener('pointerup', onPointerUp, { capture: true });
278
+ win.removeEventListener('pointercancel', onPointerUp, { capture: true });
279
+ win.removeEventListener('blur', onPointerUp);
280
+ doc.removeEventListener('pointerleave', onPointerLeave);
281
+
282
+ if (frame) win.cancelAnimationFrame(frame);
283
+ for (const element of [...hovered, ...dragged]) clearTimer(element);
284
+ hovered.clear();
285
+ dragged.clear();
286
+
287
+ for (const element of doc.querySelectorAll(`[${VISIBLE_ATTRIBUTE}]`)) {
288
+ element.removeAttribute(VISIBLE_ATTRIBUTE);
289
+ }
290
+ root.classList.remove(AUTO_HIDE_CLASS);
291
+ };
292
+
293
+ installations.set(doc, uninstall);
294
+ return uninstall;
295
+ }
@@ -33,7 +33,6 @@ export interface AnchorFloatOffset {
33
33
 
34
34
  /**
35
35
  * Options for {@link useAnchorFloat}.
36
- *
37
36
  * @category Composables
38
37
  * @useCases contextual toolbar positioning, custom floating panels
39
38
  * @keywords float, anchor, floating-ui, composable, positioning
@@ -124,7 +123,6 @@ function resolveOffset(value: number | AnchorFloatOffset | undefined) {
124
123
  *
125
124
  * Prefer {@link UiFloatActions} for the standard component API. Use this composable
126
125
  * when you need full control over markup, animation, or teleport targets.
127
- *
128
126
  * @param options - Trigger, placement, offset, and dismiss behaviour.
129
127
  * @returns Refs, computed styles, open state, and event handlers to wire up
130
128
  * anchor and floating elements manually.