@ansh-ui/react 0.2.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-5CFQFMP5.js +178 -0
  3. package/dist/chunk-5CFQFMP5.js.map +1 -0
  4. package/dist/chunk-6VRF7X5C.cjs +164 -0
  5. package/dist/chunk-6VRF7X5C.cjs.map +1 -0
  6. package/dist/chunk-AVPEA5PB.cjs +718 -0
  7. package/dist/chunk-AVPEA5PB.cjs.map +1 -0
  8. package/dist/chunk-C32LKF23.cjs +198 -0
  9. package/dist/chunk-C32LKF23.cjs.map +1 -0
  10. package/dist/chunk-C5JG6TMM.cjs +1200 -0
  11. package/dist/chunk-C5JG6TMM.cjs.map +1 -0
  12. package/dist/chunk-DATBU46V.cjs +614 -0
  13. package/dist/chunk-DATBU46V.cjs.map +1 -0
  14. package/dist/chunk-EGG4CP7C.js +320 -0
  15. package/dist/chunk-EGG4CP7C.js.map +1 -0
  16. package/dist/chunk-H34OXXJU.js +55 -0
  17. package/dist/chunk-H34OXXJU.js.map +1 -0
  18. package/dist/chunk-HO2YSF5O.js +187 -0
  19. package/dist/chunk-HO2YSF5O.js.map +1 -0
  20. package/dist/chunk-HPGCILO4.js +760 -0
  21. package/dist/chunk-HPGCILO4.js.map +1 -0
  22. package/dist/chunk-IBXLC5IE.js +154 -0
  23. package/dist/chunk-IBXLC5IE.js.map +1 -0
  24. package/dist/chunk-LDCZQP3R.js +1185 -0
  25. package/dist/chunk-LDCZQP3R.js.map +1 -0
  26. package/dist/chunk-LXCIXR5T.js +27 -0
  27. package/dist/chunk-LXCIXR5T.js.map +1 -0
  28. package/dist/chunk-O2PX54KX.js +94 -0
  29. package/dist/chunk-O2PX54KX.js.map +1 -0
  30. package/dist/chunk-OHBWBXLO.cjs +101 -0
  31. package/dist/chunk-OHBWBXLO.cjs.map +1 -0
  32. package/dist/chunk-OJN5JBNP.cjs +776 -0
  33. package/dist/chunk-OJN5JBNP.cjs.map +1 -0
  34. package/dist/chunk-OLTS6G5M.js +606 -0
  35. package/dist/chunk-OLTS6G5M.js.map +1 -0
  36. package/dist/chunk-PO5DU3FU.cjs +29 -0
  37. package/dist/chunk-PO5DU3FU.cjs.map +1 -0
  38. package/dist/chunk-QO3E7TJS.js +2940 -0
  39. package/dist/chunk-QO3E7TJS.js.map +1 -0
  40. package/dist/chunk-RHTLNSVW.cjs +2976 -0
  41. package/dist/chunk-RHTLNSVW.cjs.map +1 -0
  42. package/dist/chunk-SFU5EPSN.cjs +61 -0
  43. package/dist/chunk-SFU5EPSN.cjs.map +1 -0
  44. package/dist/chunk-T4AK2KLM.js +699 -0
  45. package/dist/chunk-T4AK2KLM.js.map +1 -0
  46. package/dist/chunk-WGYNCSTP.cjs +333 -0
  47. package/dist/chunk-WGYNCSTP.cjs.map +1 -0
  48. package/dist/chunk-XEP6P7E6.js +279 -0
  49. package/dist/chunk-XEP6P7E6.js.map +1 -0
  50. package/dist/chunk-XMXECSQO.cjs +286 -0
  51. package/dist/chunk-XMXECSQO.cjs.map +1 -0
  52. package/dist/chunk-ZWAFLHC2.cjs +181 -0
  53. package/dist/chunk-ZWAFLHC2.cjs.map +1 -0
  54. package/dist/data.cjs +71 -0
  55. package/dist/data.cjs.map +1 -0
  56. package/dist/data.d.cts +316 -0
  57. package/dist/data.d.ts +316 -0
  58. package/dist/data.js +6 -0
  59. package/dist/data.js.map +1 -0
  60. package/dist/form.cjs +153 -0
  61. package/dist/form.cjs.map +1 -0
  62. package/dist/form.d.cts +660 -0
  63. package/dist/form.d.ts +660 -0
  64. package/dist/form.js +8 -0
  65. package/dist/form.js.map +1 -0
  66. package/dist/index.cjs +1641 -0
  67. package/dist/index.cjs.map +1 -0
  68. package/dist/index.d.cts +552 -0
  69. package/dist/index.d.ts +552 -0
  70. package/dist/index.js +956 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/layout.cjs +68 -0
  73. package/dist/layout.cjs.map +1 -0
  74. package/dist/layout.d.cts +169 -0
  75. package/dist/layout.d.ts +169 -0
  76. package/dist/layout.js +7 -0
  77. package/dist/layout.js.map +1 -0
  78. package/dist/motion-CQmCq6_k.d.ts +395 -0
  79. package/dist/motion-CSX4g2N8.d.cts +395 -0
  80. package/dist/motion.cjs +79 -0
  81. package/dist/motion.cjs.map +1 -0
  82. package/dist/motion.d.cts +4 -0
  83. package/dist/motion.d.ts +4 -0
  84. package/dist/motion.js +6 -0
  85. package/dist/motion.js.map +1 -0
  86. package/dist/navigation.cjs +48 -0
  87. package/dist/navigation.cjs.map +1 -0
  88. package/dist/navigation.d.cts +210 -0
  89. package/dist/navigation.d.ts +210 -0
  90. package/dist/navigation.js +7 -0
  91. package/dist/navigation.js.map +1 -0
  92. package/dist/overlay.cjs +69 -0
  93. package/dist/overlay.cjs.map +1 -0
  94. package/dist/overlay.d.cts +330 -0
  95. package/dist/overlay.d.ts +330 -0
  96. package/dist/overlay.js +8 -0
  97. package/dist/overlay.js.map +1 -0
  98. package/dist/position-DVScKcaa.d.cts +66 -0
  99. package/dist/position-DVScKcaa.d.ts +66 -0
  100. package/dist/primitives.cjs +162 -0
  101. package/dist/primitives.cjs.map +1 -0
  102. package/dist/primitives.d.cts +294 -0
  103. package/dist/primitives.d.ts +294 -0
  104. package/dist/primitives.js +9 -0
  105. package/dist/primitives.js.map +1 -0
  106. package/dist/sidebar-D-PafAXw.d.cts +71 -0
  107. package/dist/sidebar-D-PafAXw.d.ts +71 -0
  108. package/dist/styles.css +5575 -0
  109. package/dist/use-observers-B9qtimrk.d.cts +99 -0
  110. package/dist/use-observers-B9qtimrk.d.ts +99 -0
  111. package/package.json +92 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Anchored positioning.
3
+ *
4
+ * Popovers, tooltips, menus and comboboxes all need the same thing: place a floating box next to an
5
+ * anchor, keep it on screen, and report where it actually ended up so the arrow can point the right
6
+ * way. This is that calculation, as a **pure function** of rectangles.
7
+ *
8
+ * Keeping it pure is deliberate. Positioning bugs are notoriously hard to reproduce — they depend
9
+ * on scroll offset, viewport size and element dimensions all at once. As a pure function the whole
10
+ * space is testable in milliseconds without a browser, which is why the edge cases below (flipping
11
+ * into *less* space, shifting past the anchor, both axes at once) are covered by tests rather than
12
+ * by hoping.
13
+ *
14
+ * This is a focused ~200-line implementation, not a Floating UI replacement: it does offset, flip,
15
+ * shift, size-matching and arrow placement, which is what these components need. It does not do
16
+ * auto-placement search, virtual elements or `position: absolute` containing-block resolution —
17
+ * everything here assumes `position: fixed` against the viewport, which is the only strategy that
18
+ * is correct inside transformed and clipped ancestors.
19
+ */
20
+ type Side = 'top' | 'right' | 'bottom' | 'left';
21
+ type Align = 'start' | 'center' | 'end';
22
+ type Placement = Side | `${Side}-${Align}`;
23
+ interface Rect {
24
+ x: number;
25
+ y: number;
26
+ width: number;
27
+ height: number;
28
+ }
29
+ interface PositionOptions {
30
+ /** Preferred placement. Default `'bottom'`. */
31
+ placement?: Placement;
32
+ /** Gap between anchor and floating element, in px. Default `8`. */
33
+ offset?: number;
34
+ /** Minimum distance to keep from the viewport edge, in px. Default `8`. */
35
+ padding?: number;
36
+ /** Flip to the opposite side when there isn't room. Default `true`. */
37
+ flip?: boolean;
38
+ /** Slide along the cross axis to stay on screen. Default `true`. */
39
+ shift?: boolean;
40
+ /** Size of the arrow, in px, if one is being positioned. Default `0` (no arrow). */
41
+ arrowSize?: number;
42
+ }
43
+ interface PositionResult {
44
+ /** Viewport coordinates for the floating element's top-left corner. */
45
+ x: number;
46
+ y: number;
47
+ /** Where it actually ended up — may differ from the request if it flipped. */
48
+ placement: Placement;
49
+ side: Side;
50
+ align: Align;
51
+ /** Arrow offset along the anchor's edge, or `null` when `arrowSize` is 0. */
52
+ arrow: {
53
+ x: number;
54
+ y: number;
55
+ } | null;
56
+ /** True when the anchor is entirely outside the viewport — callers usually hide the surface. */
57
+ hidden: boolean;
58
+ }
59
+ /**
60
+ * Compute where a floating element should sit.
61
+ *
62
+ * All rectangles are in viewport coordinates, as `getBoundingClientRect` returns them.
63
+ */
64
+ declare function computePosition(anchor: Rect, floating: Rect, viewport: Rect, options?: PositionOptions): PositionResult;
65
+
66
+ export { type Align as A, type Placement as P, type Rect as R, type Side as S, type PositionOptions as a, type PositionResult as b, computePosition as c };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Anchored positioning.
3
+ *
4
+ * Popovers, tooltips, menus and comboboxes all need the same thing: place a floating box next to an
5
+ * anchor, keep it on screen, and report where it actually ended up so the arrow can point the right
6
+ * way. This is that calculation, as a **pure function** of rectangles.
7
+ *
8
+ * Keeping it pure is deliberate. Positioning bugs are notoriously hard to reproduce — they depend
9
+ * on scroll offset, viewport size and element dimensions all at once. As a pure function the whole
10
+ * space is testable in milliseconds without a browser, which is why the edge cases below (flipping
11
+ * into *less* space, shifting past the anchor, both axes at once) are covered by tests rather than
12
+ * by hoping.
13
+ *
14
+ * This is a focused ~200-line implementation, not a Floating UI replacement: it does offset, flip,
15
+ * shift, size-matching and arrow placement, which is what these components need. It does not do
16
+ * auto-placement search, virtual elements or `position: absolute` containing-block resolution —
17
+ * everything here assumes `position: fixed` against the viewport, which is the only strategy that
18
+ * is correct inside transformed and clipped ancestors.
19
+ */
20
+ type Side = 'top' | 'right' | 'bottom' | 'left';
21
+ type Align = 'start' | 'center' | 'end';
22
+ type Placement = Side | `${Side}-${Align}`;
23
+ interface Rect {
24
+ x: number;
25
+ y: number;
26
+ width: number;
27
+ height: number;
28
+ }
29
+ interface PositionOptions {
30
+ /** Preferred placement. Default `'bottom'`. */
31
+ placement?: Placement;
32
+ /** Gap between anchor and floating element, in px. Default `8`. */
33
+ offset?: number;
34
+ /** Minimum distance to keep from the viewport edge, in px. Default `8`. */
35
+ padding?: number;
36
+ /** Flip to the opposite side when there isn't room. Default `true`. */
37
+ flip?: boolean;
38
+ /** Slide along the cross axis to stay on screen. Default `true`. */
39
+ shift?: boolean;
40
+ /** Size of the arrow, in px, if one is being positioned. Default `0` (no arrow). */
41
+ arrowSize?: number;
42
+ }
43
+ interface PositionResult {
44
+ /** Viewport coordinates for the floating element's top-left corner. */
45
+ x: number;
46
+ y: number;
47
+ /** Where it actually ended up — may differ from the request if it flipped. */
48
+ placement: Placement;
49
+ side: Side;
50
+ align: Align;
51
+ /** Arrow offset along the anchor's edge, or `null` when `arrowSize` is 0. */
52
+ arrow: {
53
+ x: number;
54
+ y: number;
55
+ } | null;
56
+ /** True when the anchor is entirely outside the viewport — callers usually hide the surface. */
57
+ hidden: boolean;
58
+ }
59
+ /**
60
+ * Compute where a floating element should sit.
61
+ *
62
+ * All rectangles are in viewport coordinates, as `getBoundingClientRect` returns them.
63
+ */
64
+ declare function computePosition(anchor: Rect, floating: Rect, viewport: Rect, options?: PositionOptions): PositionResult;
65
+
66
+ export { type Align as A, type Placement as P, type Rect as R, type Side as S, type PositionOptions as a, type PositionResult as b, computePosition as c };
@@ -0,0 +1,162 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var chunkOHBWBXLO_cjs = require('./chunk-OHBWBXLO.cjs');
5
+ var chunkC32LKF23_cjs = require('./chunk-C32LKF23.cjs');
6
+ var chunkXMXECSQO_cjs = require('./chunk-XMXECSQO.cjs');
7
+ var chunkPO5DU3FU_cjs = require('./chunk-PO5DU3FU.cjs');
8
+ var chunk6VRF7X5C_cjs = require('./chunk-6VRF7X5C.cjs');
9
+ var chunkSFU5EPSN_cjs = require('./chunk-SFU5EPSN.cjs');
10
+
11
+
12
+
13
+ Object.defineProperty(exports, "useAnimate", {
14
+ enumerable: true,
15
+ get: function () { return chunkOHBWBXLO_cjs.useAnimate; }
16
+ });
17
+ Object.defineProperty(exports, "useIsMounted", {
18
+ enumerable: true,
19
+ get: function () { return chunkOHBWBXLO_cjs.useIsMounted; }
20
+ });
21
+ Object.defineProperty(exports, "useMotionStyle", {
22
+ enumerable: true,
23
+ get: function () { return chunkOHBWBXLO_cjs.useMotionStyle; }
24
+ });
25
+ Object.defineProperty(exports, "useMotionValue", {
26
+ enumerable: true,
27
+ get: function () { return chunkOHBWBXLO_cjs.useMotionValue; }
28
+ });
29
+ Object.defineProperty(exports, "useMotionValueState", {
30
+ enumerable: true,
31
+ get: function () { return chunkOHBWBXLO_cjs.useMotionValueState; }
32
+ });
33
+ Object.defineProperty(exports, "useSpringValue", {
34
+ enumerable: true,
35
+ get: function () { return chunkOHBWBXLO_cjs.useSpringValue; }
36
+ });
37
+ Object.defineProperty(exports, "Presence", {
38
+ enumerable: true,
39
+ get: function () { return chunkC32LKF23_cjs.Presence; }
40
+ });
41
+ Object.defineProperty(exports, "Slot", {
42
+ enumerable: true,
43
+ get: function () { return chunkC32LKF23_cjs.Slot; }
44
+ });
45
+ Object.defineProperty(exports, "countElements", {
46
+ enumerable: true,
47
+ get: function () { return chunkC32LKF23_cjs.countElements; }
48
+ });
49
+ Object.defineProperty(exports, "getTabbable", {
50
+ enumerable: true,
51
+ get: function () { return chunkC32LKF23_cjs.getTabbable; }
52
+ });
53
+ Object.defineProperty(exports, "slotted", {
54
+ enumerable: true,
55
+ get: function () { return chunkC32LKF23_cjs.slotted; }
56
+ });
57
+ Object.defineProperty(exports, "useAutoFocus", {
58
+ enumerable: true,
59
+ get: function () { return chunkC32LKF23_cjs.useAutoFocus; }
60
+ });
61
+ Object.defineProperty(exports, "useFocusRestore", {
62
+ enumerable: true,
63
+ get: function () { return chunkC32LKF23_cjs.useFocusRestore; }
64
+ });
65
+ Object.defineProperty(exports, "useFocusTrap", {
66
+ enumerable: true,
67
+ get: function () { return chunkC32LKF23_cjs.useFocusTrap; }
68
+ });
69
+ Object.defineProperty(exports, "usePresence", {
70
+ enumerable: true,
71
+ get: function () { return chunkC32LKF23_cjs.usePresence; }
72
+ });
73
+ Object.defineProperty(exports, "useRovingFocus", {
74
+ enumerable: true,
75
+ get: function () { return chunkC32LKF23_cjs.useRovingFocus; }
76
+ });
77
+ Object.defineProperty(exports, "Portal", {
78
+ enumerable: true,
79
+ get: function () { return chunkXMXECSQO_cjs.Portal; }
80
+ });
81
+ Object.defineProperty(exports, "computePosition", {
82
+ enumerable: true,
83
+ get: function () { return chunkXMXECSQO_cjs.computePosition; }
84
+ });
85
+ Object.defineProperty(exports, "getLayerStack", {
86
+ enumerable: true,
87
+ get: function () { return chunkXMXECSQO_cjs.getLayerStack; }
88
+ });
89
+ Object.defineProperty(exports, "useAnchoredPosition", {
90
+ enumerable: true,
91
+ get: function () { return chunkXMXECSQO_cjs.useAnchoredPosition; }
92
+ });
93
+ Object.defineProperty(exports, "useDismiss", {
94
+ enumerable: true,
95
+ get: function () { return chunkXMXECSQO_cjs.useDismiss; }
96
+ });
97
+ Object.defineProperty(exports, "useScrollLock", {
98
+ enumerable: true,
99
+ get: function () { return chunkXMXECSQO_cjs.useScrollLock; }
100
+ });
101
+ Object.defineProperty(exports, "useControllableState", {
102
+ enumerable: true,
103
+ get: function () { return chunkPO5DU3FU_cjs.useControllableState; }
104
+ });
105
+ Object.defineProperty(exports, "useElementSize", {
106
+ enumerable: true,
107
+ get: function () { return chunk6VRF7X5C_cjs.useElementSize; }
108
+ });
109
+ Object.defineProperty(exports, "useFrameBudget", {
110
+ enumerable: true,
111
+ get: function () { return chunk6VRF7X5C_cjs.useFrameBudget; }
112
+ });
113
+ Object.defineProperty(exports, "useInView", {
114
+ enumerable: true,
115
+ get: function () { return chunk6VRF7X5C_cjs.useInView; }
116
+ });
117
+ Object.defineProperty(exports, "useMergedRef", {
118
+ enumerable: true,
119
+ get: function () { return chunk6VRF7X5C_cjs.useMergedRef; }
120
+ });
121
+ Object.defineProperty(exports, "usePointer", {
122
+ enumerable: true,
123
+ get: function () { return chunk6VRF7X5C_cjs.usePointer; }
124
+ });
125
+ Object.defineProperty(exports, "useReducedMotion", {
126
+ enumerable: true,
127
+ get: function () { return chunk6VRF7X5C_cjs.useReducedMotion; }
128
+ });
129
+ Object.defineProperty(exports, "useScrollProgress", {
130
+ enumerable: true,
131
+ get: function () { return chunk6VRF7X5C_cjs.useScrollProgress; }
132
+ });
133
+ Object.defineProperty(exports, "useTicker", {
134
+ enumerable: true,
135
+ get: function () { return chunk6VRF7X5C_cjs.useTicker; }
136
+ });
137
+ Object.defineProperty(exports, "useWindowScroll", {
138
+ enumerable: true,
139
+ get: function () { return chunk6VRF7X5C_cjs.useWindowScroll; }
140
+ });
141
+ Object.defineProperty(exports, "assignRef", {
142
+ enumerable: true,
143
+ get: function () { return chunkSFU5EPSN_cjs.assignRef; }
144
+ });
145
+ Object.defineProperty(exports, "composeEventHandlers", {
146
+ enumerable: true,
147
+ get: function () { return chunkSFU5EPSN_cjs.composeEventHandlers; }
148
+ });
149
+ Object.defineProperty(exports, "cx", {
150
+ enumerable: true,
151
+ get: function () { return chunkSFU5EPSN_cjs.cx; }
152
+ });
153
+ Object.defineProperty(exports, "mergeProps", {
154
+ enumerable: true,
155
+ get: function () { return chunkSFU5EPSN_cjs.mergeProps; }
156
+ });
157
+ Object.defineProperty(exports, "mergeRefs", {
158
+ enumerable: true,
159
+ get: function () { return chunkSFU5EPSN_cjs.mergeRefs; }
160
+ });
161
+ //# sourceMappingURL=primitives.cjs.map
162
+ //# sourceMappingURL=primitives.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"primitives.cjs"}
@@ -0,0 +1,294 @@
1
+ import * as react from 'react';
2
+ import { Ref, SyntheticEvent, ReactNode, RefObject, CSSProperties } from 'react';
3
+ import { b as PositionResult, a as PositionOptions } from './position-DVScKcaa.cjs';
4
+ export { A as Align, P as Placement, R as Rect, S as Side, c as computePosition } from './position-DVScKcaa.cjs';
5
+ export { I as InViewOptions, u as useElementSize, a as useFrameBudget, b as useInView, c as useMergedRef, d as usePointer, e as useReducedMotion, f as useScrollProgress, g as useTicker, h as useWindowScroll } from './use-observers-B9qtimrk.cjs';
6
+ import * as _ansh_ui_core from '@ansh-ui/core';
7
+ import { MotionValue, AnimationOptions, SpringOptions } from '@ansh-ui/core';
8
+
9
+ /**
10
+ * Create a stable {@link MotionValue}.
11
+ *
12
+ * The value survives re-renders and — critically — **does not cause them**. That is the whole
13
+ * point: 60 renders per second of a React tree is not viable at any realistic component count,
14
+ * so animated values live outside React's reactivity and are written straight to the DOM.
15
+ *
16
+ * Reach for {@link useMotionValueState} only when you genuinely need the value in render output.
17
+ */
18
+ declare function useMotionValue<T>(initial: T): MotionValue<T>;
19
+ /**
20
+ * Subscribe to a MotionValue as React state.
21
+ *
22
+ * Uses `useSyncExternalStore`, which is the correct primitive here rather than
23
+ * `useState` + `useEffect`: it is tear-free under concurrent rendering, and it reads the value
24
+ * during render so there is never a frame showing a stale value.
25
+ *
26
+ * **This re-renders on every change.** For a value driven by an animation that is 60 renders per
27
+ * second. Use it for values that change at interaction rate (a toggle, a settled spring's final
28
+ * state), never for a value being animated continuously.
29
+ */
30
+ declare function useMotionValueState<T>(value: MotionValue<T>): T;
31
+ /**
32
+ * Write a MotionValue directly to a DOM property, bypassing React entirely.
33
+ *
34
+ * This is the mechanism that makes smooth animation possible in React. The returned ref is
35
+ * attached to an element; every change to the MotionValue writes straight to the node in the
36
+ * ticker's `write` phase.
37
+ *
38
+ * ```tsx
39
+ * const x = useMotionValue(0)
40
+ * const ref = useMotionStyle(x, (v) => `translateX(${v}px)`, 'transform')
41
+ * return <div ref={ref} />
42
+ * ```
43
+ */
44
+ declare function useMotionStyle<T, El extends HTMLElement = HTMLDivElement>(value: MotionValue<T>, format: (value: T) => string, property?: keyof CSSStyleDeclaration & string): (node: El | null) => void;
45
+ /**
46
+ * A spring that continuously chases a target.
47
+ *
48
+ * Returns a MotionValue and a setter. Unlike `animate(…, { type: 'spring' })` the target may
49
+ * change at any time and the spring carries its momentum through — which is what a cursor
50
+ * follower or a drag handle needs.
51
+ */
52
+ declare function useSpringValue(initial: number, options?: SpringOptions): [MotionValue<number>, (target: number) => void];
53
+ /**
54
+ * Imperative animation, scoped to the component's lifetime.
55
+ *
56
+ * Returns a `start` function and cancels any in-flight animation on unmount — the leak that
57
+ * hand-rolled `useEffect` animation code almost always has.
58
+ */
59
+ declare function useAnimate(): <T>(from: T | MotionValue<T>, to: T | readonly T[], options?: AnimationOptions<T>) => _ansh_ui_core.AnimationControls;
60
+ /**
61
+ * A boolean that flips to `true` once the component has mounted on the client.
62
+ *
63
+ * The idiomatic guard for anything that must not run during SSR. Returning `false` on the server
64
+ * and on the first client render means the two agree, so React never reports a hydration
65
+ * mismatch — which is what a naive `typeof window !== 'undefined'` check in render *does* cause.
66
+ */
67
+ declare function useIsMounted(): boolean;
68
+
69
+ /**
70
+ * State that works both controlled and uncontrolled.
71
+ *
72
+ * Every non-trivial component in this library needs this. A `<Select>` must work as
73
+ * `<Select />` (it owns its value), as `<Select defaultValue="a" />` (it owns its value, seeded),
74
+ * and as `<Select value={v} onChange={setV} />` (the parent owns it). Writing that logic per
75
+ * component is how libraries end up with a `Dialog` that supports controlled mode and a `Popover`
76
+ * that silently doesn't.
77
+ *
78
+ * The rule this encodes: **`value !== undefined` means controlled**, checked per render rather than
79
+ * latched on mount. Latching would be more "correct" in React's own terms, but it makes a component
80
+ * that starts uncontrolled and later receives a value fail silently, which is a real pattern when
81
+ * data arrives asynchronously.
82
+ */
83
+ declare function useControllableState<T>(options: {
84
+ /** The controlled value. Pass `undefined` to stay uncontrolled. */
85
+ value?: T | undefined;
86
+ /** Initial value when uncontrolled. */
87
+ defaultValue: T;
88
+ /** Called on every change, in both modes. */
89
+ onChange?: ((value: T) => void) | undefined;
90
+ }): [T, (next: T | ((previous: T) => T)) => void];
91
+
92
+ /**
93
+ * Run a component's own handler after the consumer's, unless the consumer prevented default.
94
+ *
95
+ * The order matters and so does the check. A consumer's `onClick` on a `<Dialog.Close>` should be
96
+ * able to call `event.preventDefault()` to stop the dialog closing — that is the escape hatch that
97
+ * keeps composed components usable. Calling the internal handler first would make it impossible.
98
+ */
99
+ declare function composeEventHandlers<E extends SyntheticEvent | Event>(theirs: ((event: E) => void) | undefined, ours: (event: E) => void, options?: {
100
+ checkForDefaultPrevented?: boolean;
101
+ }): (event: E) => void;
102
+ /** Assign a node to any ref shape — callback, object, or nothing. */
103
+ declare function assignRef<T>(ref: Ref<T> | undefined | null, node: T | null): void;
104
+ /**
105
+ * Merge refs without a hook.
106
+ *
107
+ * `useMergedRef` is the hook form and should be preferred inside components. This exists for the
108
+ * places a ref must be merged outside of a render — cloning an element in a `Slot`, for instance.
109
+ */
110
+ declare function mergeRefs<T>(...refs: Array<Ref<T> | undefined | null>): (node: T | null) => void;
111
+ /**
112
+ * Merge two sets of props, with the child's winning for everything except handlers, `className`
113
+ * and `style`, which compose.
114
+ *
115
+ * This is the merge strategy `asChild` needs. A naive spread would let a child's `onClick`
116
+ * silently delete a `Popover.Trigger`'s open handler, producing a trigger that renders perfectly
117
+ * and does nothing.
118
+ */
119
+ declare function mergeProps(slotProps: Record<string, unknown>, childProps: Record<string, unknown>): Record<string, unknown>;
120
+ /** Join class names, dropping falsy entries. The whole of `clsx` that this library actually uses. */
121
+ declare function cx(...parts: Array<string | false | null | undefined>): string;
122
+
123
+ interface SlotProps {
124
+ children?: ReactNode;
125
+ [key: string]: unknown;
126
+ }
127
+ /**
128
+ * Render into the child element instead of rendering a wrapper.
129
+ *
130
+ * This is what powers `asChild`. Without it, a `<Tooltip.Trigger>` wrapping a `<Button>` emits a
131
+ * `<span>` around the button — which breaks flex layouts, adds a node that inherits nothing, and
132
+ * puts the trigger's ARIA attributes on the wrong element for assistive technology.
133
+ *
134
+ * ```tsx
135
+ * <Tooltip.Trigger asChild>
136
+ * <Button>Save</Button>
137
+ * </Tooltip.Trigger>
138
+ * ```
139
+ *
140
+ * The button *is* the trigger: it carries `aria-describedby` and the handlers, and no extra DOM
141
+ * node exists.
142
+ */
143
+ declare const Slot: react.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & react.RefAttributes<HTMLElement>>;
144
+ /**
145
+ * Pick between a host element and its child based on `asChild`.
146
+ *
147
+ * Every component in this library that accepts `asChild` uses this, so the behaviour is identical
148
+ * across all of them rather than reimplemented with small differences.
149
+ */
150
+ declare function slotted(asChild: boolean | undefined, fallback: React.ElementType): React.ElementType;
151
+ /** Count element children, ignoring `null`/`false` from conditional rendering. */
152
+ declare function countElements(children: ReactNode): number;
153
+
154
+ interface PortalProps {
155
+ children: ReactNode;
156
+ /** Where to mount. Defaults to `document.body`. */
157
+ container?: Element | null;
158
+ /** Skip the portal and render in place. Useful inside an already-portalled surface. */
159
+ disabled?: boolean;
160
+ }
161
+ /**
162
+ * Render children elsewhere in the DOM.
163
+ *
164
+ * Overlays must escape their parent's stacking and clipping context. A popover inside a container
165
+ * with `overflow: hidden` gets clipped; one inside a `transform`ed ancestor has its `position:
166
+ * fixed` resolved against that ancestor instead of the viewport, so it lands in the wrong place.
167
+ * Neither is fixable with z-index, and both are the single most common overlay bug.
168
+ *
169
+ * SSR-safe: renders nothing on the server and on the first client render, then portals after mount.
170
+ * Portalling during SSR is impossible (no DOM), and portalling on the first client render would
171
+ * produce markup the server didn't emit — a hydration mismatch.
172
+ */
173
+ declare function Portal({ children, container, disabled }: PortalProps): react.JSX.Element | null;
174
+
175
+ /** Every tabbable descendant, in tab order. */
176
+ declare function getTabbable(container: HTMLElement | null): HTMLElement[];
177
+ /**
178
+ * Trap Tab within a container while `active`.
179
+ *
180
+ * Implemented on `keydown` at the container rather than with sentinel elements at either end. The
181
+ * sentinel approach adds two focusable nodes to the accessibility tree that screen readers can
182
+ * land on and announce as blank; intercepting the key does not.
183
+ */
184
+ declare function useFocusTrap(ref: RefObject<HTMLElement | null>, active: boolean): void;
185
+ /**
186
+ * Restore focus to whatever was focused before `active` became true.
187
+ *
188
+ * The element is captured on activation, not on mount, because a component can be mounted long
189
+ * before it opens.
190
+ */
191
+ declare function useFocusRestore(active: boolean): void;
192
+ /**
193
+ * Move focus into a surface when it opens.
194
+ *
195
+ * Prefers an explicitly marked element, then the first tabbable one, then the container itself.
196
+ * The container fallback matters for a dialog whose only content is text: focus must land inside
197
+ * it so a screen reader announces the dialog rather than continuing from the page behind.
198
+ */
199
+ declare function useAutoFocus(ref: RefObject<HTMLElement | null>, active: boolean, initialFocus?: RefObject<HTMLElement | null>): void;
200
+ /**
201
+ * Roving tabindex for a composite widget (toolbar, tab list, menu).
202
+ *
203
+ * The ARIA authoring practice: a composite has exactly **one** tab stop, and arrow keys move
204
+ * within it. Ten tabs that are each a tab stop means a keyboard user presses Tab ten times to get
205
+ * past the tab bar — technically operable, practically hostile.
206
+ */
207
+ declare function useRovingFocus(options: {
208
+ /** Items in DOM order. */
209
+ itemsRef: RefObject<Array<HTMLElement | null>>;
210
+ /** Index that currently owns the tab stop. */
211
+ active: number;
212
+ onActiveChange: (index: number) => void;
213
+ orientation?: 'horizontal' | 'vertical' | 'both';
214
+ loop?: boolean;
215
+ }): (event: React.KeyboardEvent) => void;
216
+
217
+ /** Ids of the currently open dismissable layers, outermost first. Exposed for tests. */
218
+ declare function getLayerStack(): readonly string[];
219
+ interface DismissOptions {
220
+ /** Close on pointer press outside the surface. Default `true`. */
221
+ outsidePress?: boolean;
222
+ /** Close on Escape. Only the topmost layer responds. Default `true`. */
223
+ escapeKey?: boolean;
224
+ /**
225
+ * Extra elements that count as "inside" — normally the trigger.
226
+ *
227
+ * Without this the trigger's own click closes the surface via the outside handler and then
228
+ * immediately reopens it via its own onClick, so the surface appears not to close at all.
229
+ */
230
+ ignore?: Array<RefObject<HTMLElement | null>>;
231
+ }
232
+ declare function useDismiss(ref: RefObject<HTMLElement | null>, open: boolean, onDismiss: () => void, options?: DismissOptions): void;
233
+ declare function useScrollLock(active: boolean): void;
234
+
235
+ /**
236
+ * Keep an element mounted while it animates out.
237
+ *
238
+ * The problem: `{open && <Dialog />}` cannot animate on close, because React removes the node the
239
+ * instant `open` flips. The fix is to keep rendering it and unmount when the exit animation
240
+ * actually finishes.
241
+ *
242
+ * Finishing is detected from `animationend`/`transitionend` rather than a duration prop. A duration
243
+ * prop has to be kept in sync with the CSS by hand, and it drifts the moment someone retimes the
244
+ * animation in the stylesheet — leaving either a flash (unmount too early) or a surface that lingers
245
+ * invisibly and swallows clicks (too late). The timeout below is only a safety net for the case
246
+ * where no animation is declared at all and no event ever fires.
247
+ */
248
+ declare function usePresence(open: boolean, ref: RefObject<HTMLElement | null>): {
249
+ mounted: boolean;
250
+ state: 'open' | 'closed';
251
+ };
252
+ interface PresenceProps {
253
+ open: boolean;
254
+ children: (props: {
255
+ ref: RefObject<HTMLElement | null>;
256
+ state: 'open' | 'closed';
257
+ }) => ReactNode;
258
+ }
259
+ /**
260
+ * Render-prop form of `usePresence`, for callers that would otherwise need to hoist a ref.
261
+ *
262
+ * ```tsx
263
+ * <Presence open={open}>
264
+ * {({ ref, state }) => <div ref={ref} data-state={state} className="fade" />}
265
+ * </Presence>
266
+ * ```
267
+ */
268
+ declare function Presence({ open, children }: PresenceProps): react.JSX.Element | null;
269
+
270
+ interface AnchoredPositionOptions extends PositionOptions {
271
+ /** Set the floating element's width to the anchor's — what a combobox listbox wants. */
272
+ matchWidth?: boolean;
273
+ /** Recompute while open. Default `true`. */
274
+ enabled?: boolean;
275
+ }
276
+ interface AnchoredPosition {
277
+ style: CSSProperties;
278
+ arrowStyle: CSSProperties | undefined;
279
+ placement: PositionResult['placement'];
280
+ side: PositionResult['side'];
281
+ /** Force a recompute — call after content changes size in a way observers can't see. */
282
+ update: () => void;
283
+ }
284
+ /**
285
+ * Keep a floating element positioned against an anchor.
286
+ *
287
+ * Recomputes on scroll (capture phase, so nested scroll containers are caught), on viewport
288
+ * resize, and whenever either element changes size. It deliberately does **not** poll on every
289
+ * frame: that costs a forced layout per frame for a value that changes only on discrete events,
290
+ * and it is the reason some popover libraries make scrolling janky.
291
+ */
292
+ declare function useAnchoredPosition(anchorRef: RefObject<HTMLElement | null>, floatingRef: RefObject<HTMLElement | null>, open: boolean, options?: AnchoredPositionOptions): AnchoredPosition;
293
+
294
+ export { type AnchoredPosition, type AnchoredPositionOptions, type DismissOptions, Portal, type PortalProps, PositionOptions, PositionResult, Presence, type PresenceProps, Slot, type SlotProps, assignRef, composeEventHandlers, countElements, cx, getLayerStack, getTabbable, mergeProps, mergeRefs, slotted, useAnchoredPosition, useAnimate, useAutoFocus, useControllableState, useDismiss, useFocusRestore, useFocusTrap, useIsMounted, useMotionStyle, useMotionValue, useMotionValueState, usePresence, useRovingFocus, useScrollLock, useSpringValue };