@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.
- package/LICENSE +21 -0
- package/dist/chunk-5CFQFMP5.js +178 -0
- package/dist/chunk-5CFQFMP5.js.map +1 -0
- package/dist/chunk-6VRF7X5C.cjs +164 -0
- package/dist/chunk-6VRF7X5C.cjs.map +1 -0
- package/dist/chunk-AVPEA5PB.cjs +718 -0
- package/dist/chunk-AVPEA5PB.cjs.map +1 -0
- package/dist/chunk-C32LKF23.cjs +198 -0
- package/dist/chunk-C32LKF23.cjs.map +1 -0
- package/dist/chunk-C5JG6TMM.cjs +1200 -0
- package/dist/chunk-C5JG6TMM.cjs.map +1 -0
- package/dist/chunk-DATBU46V.cjs +614 -0
- package/dist/chunk-DATBU46V.cjs.map +1 -0
- package/dist/chunk-EGG4CP7C.js +320 -0
- package/dist/chunk-EGG4CP7C.js.map +1 -0
- package/dist/chunk-H34OXXJU.js +55 -0
- package/dist/chunk-H34OXXJU.js.map +1 -0
- package/dist/chunk-HO2YSF5O.js +187 -0
- package/dist/chunk-HO2YSF5O.js.map +1 -0
- package/dist/chunk-HPGCILO4.js +760 -0
- package/dist/chunk-HPGCILO4.js.map +1 -0
- package/dist/chunk-IBXLC5IE.js +154 -0
- package/dist/chunk-IBXLC5IE.js.map +1 -0
- package/dist/chunk-LDCZQP3R.js +1185 -0
- package/dist/chunk-LDCZQP3R.js.map +1 -0
- package/dist/chunk-LXCIXR5T.js +27 -0
- package/dist/chunk-LXCIXR5T.js.map +1 -0
- package/dist/chunk-O2PX54KX.js +94 -0
- package/dist/chunk-O2PX54KX.js.map +1 -0
- package/dist/chunk-OHBWBXLO.cjs +101 -0
- package/dist/chunk-OHBWBXLO.cjs.map +1 -0
- package/dist/chunk-OJN5JBNP.cjs +776 -0
- package/dist/chunk-OJN5JBNP.cjs.map +1 -0
- package/dist/chunk-OLTS6G5M.js +606 -0
- package/dist/chunk-OLTS6G5M.js.map +1 -0
- package/dist/chunk-PO5DU3FU.cjs +29 -0
- package/dist/chunk-PO5DU3FU.cjs.map +1 -0
- package/dist/chunk-QO3E7TJS.js +2940 -0
- package/dist/chunk-QO3E7TJS.js.map +1 -0
- package/dist/chunk-RHTLNSVW.cjs +2976 -0
- package/dist/chunk-RHTLNSVW.cjs.map +1 -0
- package/dist/chunk-SFU5EPSN.cjs +61 -0
- package/dist/chunk-SFU5EPSN.cjs.map +1 -0
- package/dist/chunk-T4AK2KLM.js +699 -0
- package/dist/chunk-T4AK2KLM.js.map +1 -0
- package/dist/chunk-WGYNCSTP.cjs +333 -0
- package/dist/chunk-WGYNCSTP.cjs.map +1 -0
- package/dist/chunk-XEP6P7E6.js +279 -0
- package/dist/chunk-XEP6P7E6.js.map +1 -0
- package/dist/chunk-XMXECSQO.cjs +286 -0
- package/dist/chunk-XMXECSQO.cjs.map +1 -0
- package/dist/chunk-ZWAFLHC2.cjs +181 -0
- package/dist/chunk-ZWAFLHC2.cjs.map +1 -0
- package/dist/data.cjs +71 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +316 -0
- package/dist/data.d.ts +316 -0
- package/dist/data.js +6 -0
- package/dist/data.js.map +1 -0
- package/dist/form.cjs +153 -0
- package/dist/form.cjs.map +1 -0
- package/dist/form.d.cts +660 -0
- package/dist/form.d.ts +660 -0
- package/dist/form.js +8 -0
- package/dist/form.js.map +1 -0
- package/dist/index.cjs +1641 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +552 -0
- package/dist/index.d.ts +552 -0
- package/dist/index.js +956 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.cjs +68 -0
- package/dist/layout.cjs.map +1 -0
- package/dist/layout.d.cts +169 -0
- package/dist/layout.d.ts +169 -0
- package/dist/layout.js +7 -0
- package/dist/layout.js.map +1 -0
- package/dist/motion-CQmCq6_k.d.ts +395 -0
- package/dist/motion-CSX4g2N8.d.cts +395 -0
- package/dist/motion.cjs +79 -0
- package/dist/motion.cjs.map +1 -0
- package/dist/motion.d.cts +4 -0
- package/dist/motion.d.ts +4 -0
- package/dist/motion.js +6 -0
- package/dist/motion.js.map +1 -0
- package/dist/navigation.cjs +48 -0
- package/dist/navigation.cjs.map +1 -0
- package/dist/navigation.d.cts +210 -0
- package/dist/navigation.d.ts +210 -0
- package/dist/navigation.js +7 -0
- package/dist/navigation.js.map +1 -0
- package/dist/overlay.cjs +69 -0
- package/dist/overlay.cjs.map +1 -0
- package/dist/overlay.d.cts +330 -0
- package/dist/overlay.d.ts +330 -0
- package/dist/overlay.js +8 -0
- package/dist/overlay.js.map +1 -0
- package/dist/position-DVScKcaa.d.cts +66 -0
- package/dist/position-DVScKcaa.d.ts +66 -0
- package/dist/primitives.cjs +162 -0
- package/dist/primitives.cjs.map +1 -0
- package/dist/primitives.d.cts +294 -0
- package/dist/primitives.d.ts +294 -0
- package/dist/primitives.js +9 -0
- package/dist/primitives.js.map +1 -0
- package/dist/sidebar-D-PafAXw.d.cts +71 -0
- package/dist/sidebar-D-PafAXw.d.ts +71 -0
- package/dist/styles.css +5575 -0
- package/dist/use-observers-B9qtimrk.d.cts +99 -0
- package/dist/use-observers-B9qtimrk.d.ts +99 -0
- package/package.json +92 -0
|
@@ -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.js';
|
|
4
|
+
export { A as Align, P as Placement, R as Rect, S as Side, c as computePosition } from './position-DVScKcaa.js';
|
|
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.js';
|
|
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 };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
export { useAnimate, useIsMounted, useMotionStyle, useMotionValue, useMotionValueState, useSpringValue } from './chunk-O2PX54KX.js';
|
|
3
|
+
export { Presence, Slot, countElements, getTabbable, slotted, useAutoFocus, useFocusRestore, useFocusTrap, usePresence, useRovingFocus } from './chunk-HO2YSF5O.js';
|
|
4
|
+
export { Portal, computePosition, getLayerStack, useAnchoredPosition, useDismiss, useScrollLock } from './chunk-XEP6P7E6.js';
|
|
5
|
+
export { useControllableState } from './chunk-LXCIXR5T.js';
|
|
6
|
+
export { useElementSize, useFrameBudget, useInView, useMergedRef, usePointer, useReducedMotion, useScrollProgress, useTicker, useWindowScroll } from './chunk-IBXLC5IE.js';
|
|
7
|
+
export { assignRef, composeEventHandlers, cx, mergeProps, mergeRefs } from './chunk-H34OXXJU.js';
|
|
8
|
+
//# sourceMappingURL=primitives.js.map
|
|
9
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"primitives.js"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface NavItem {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Count or status shown on the right. */
|
|
10
|
+
badge?: ReactNode;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
/** Nested items, rendered in a collapsible group. */
|
|
14
|
+
items?: readonly NavItem[];
|
|
15
|
+
}
|
|
16
|
+
interface NavSection {
|
|
17
|
+
id: string;
|
|
18
|
+
/** Heading above the group. Omit for an unlabelled block. */
|
|
19
|
+
label?: string;
|
|
20
|
+
items: readonly NavItem[];
|
|
21
|
+
}
|
|
22
|
+
interface SidebarProps {
|
|
23
|
+
sections: readonly NavSection[];
|
|
24
|
+
/** Id of the active item. */
|
|
25
|
+
activeId?: string;
|
|
26
|
+
onNavigate?: (item: NavItem) => void;
|
|
27
|
+
/** Collapse to an icon rail. */
|
|
28
|
+
collapsed?: boolean;
|
|
29
|
+
defaultCollapsed?: boolean;
|
|
30
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
31
|
+
/** Content above the nav — a logo, a workspace switcher. */
|
|
32
|
+
header?: ReactNode;
|
|
33
|
+
/** Content pinned to the bottom — the user menu, usually. */
|
|
34
|
+
footer?: ReactNode;
|
|
35
|
+
/** Show the collapse toggle. Default `true`. */
|
|
36
|
+
collapsible?: boolean;
|
|
37
|
+
label?: string;
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The application sidebar.
|
|
42
|
+
*
|
|
43
|
+
* A `<nav>` containing lists of links — the structure a screen reader user navigates by landmark,
|
|
44
|
+
* and the reason this isn't a stack of divs. Nested groups are `<button aria-expanded>` controlling
|
|
45
|
+
* a `<ul>`, so their state is announced.
|
|
46
|
+
*
|
|
47
|
+
* Collapsing to an icon rail keeps the labels in the DOM (visually hidden), rather than removing
|
|
48
|
+
* them. Removing them would leave a rail of unlabelled icons for anyone using assistive technology,
|
|
49
|
+
* which is exactly the population for whom the space saving is irrelevant.
|
|
50
|
+
*/
|
|
51
|
+
declare function Sidebar({ sections, activeId, onNavigate, collapsed, defaultCollapsed, onCollapsedChange, header, footer, collapsible, label, className, }: SidebarProps): react.JSX.Element;
|
|
52
|
+
interface AppShellProps {
|
|
53
|
+
sidebar?: ReactNode;
|
|
54
|
+
header?: ReactNode;
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
className?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The header + sidebar + content frame.
|
|
60
|
+
*
|
|
61
|
+
* A grid rather than nested flex containers, so the sidebar and header can be `position: sticky`
|
|
62
|
+
* without the content needing compensating margins — the arrangement that breaks the moment the
|
|
63
|
+
* header's height changes.
|
|
64
|
+
*
|
|
65
|
+
* The skip link is the first focusable element on the page. It is the cheapest accessibility win
|
|
66
|
+
* available and it is missing from almost every application shell: without it, a keyboard user
|
|
67
|
+
* traverses the entire navigation on every single page load.
|
|
68
|
+
*/
|
|
69
|
+
declare function AppShell({ sidebar, header, children, className }: AppShellProps): react.JSX.Element;
|
|
70
|
+
|
|
71
|
+
export { AppShell as A, type NavItem as N, Sidebar as S, type AppShellProps as a, type NavSection as b, type SidebarProps as c };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface NavItem {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Count or status shown on the right. */
|
|
10
|
+
badge?: ReactNode;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
/** Nested items, rendered in a collapsible group. */
|
|
14
|
+
items?: readonly NavItem[];
|
|
15
|
+
}
|
|
16
|
+
interface NavSection {
|
|
17
|
+
id: string;
|
|
18
|
+
/** Heading above the group. Omit for an unlabelled block. */
|
|
19
|
+
label?: string;
|
|
20
|
+
items: readonly NavItem[];
|
|
21
|
+
}
|
|
22
|
+
interface SidebarProps {
|
|
23
|
+
sections: readonly NavSection[];
|
|
24
|
+
/** Id of the active item. */
|
|
25
|
+
activeId?: string;
|
|
26
|
+
onNavigate?: (item: NavItem) => void;
|
|
27
|
+
/** Collapse to an icon rail. */
|
|
28
|
+
collapsed?: boolean;
|
|
29
|
+
defaultCollapsed?: boolean;
|
|
30
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
31
|
+
/** Content above the nav — a logo, a workspace switcher. */
|
|
32
|
+
header?: ReactNode;
|
|
33
|
+
/** Content pinned to the bottom — the user menu, usually. */
|
|
34
|
+
footer?: ReactNode;
|
|
35
|
+
/** Show the collapse toggle. Default `true`. */
|
|
36
|
+
collapsible?: boolean;
|
|
37
|
+
label?: string;
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The application sidebar.
|
|
42
|
+
*
|
|
43
|
+
* A `<nav>` containing lists of links — the structure a screen reader user navigates by landmark,
|
|
44
|
+
* and the reason this isn't a stack of divs. Nested groups are `<button aria-expanded>` controlling
|
|
45
|
+
* a `<ul>`, so their state is announced.
|
|
46
|
+
*
|
|
47
|
+
* Collapsing to an icon rail keeps the labels in the DOM (visually hidden), rather than removing
|
|
48
|
+
* them. Removing them would leave a rail of unlabelled icons for anyone using assistive technology,
|
|
49
|
+
* which is exactly the population for whom the space saving is irrelevant.
|
|
50
|
+
*/
|
|
51
|
+
declare function Sidebar({ sections, activeId, onNavigate, collapsed, defaultCollapsed, onCollapsedChange, header, footer, collapsible, label, className, }: SidebarProps): react.JSX.Element;
|
|
52
|
+
interface AppShellProps {
|
|
53
|
+
sidebar?: ReactNode;
|
|
54
|
+
header?: ReactNode;
|
|
55
|
+
children: ReactNode;
|
|
56
|
+
className?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The header + sidebar + content frame.
|
|
60
|
+
*
|
|
61
|
+
* A grid rather than nested flex containers, so the sidebar and header can be `position: sticky`
|
|
62
|
+
* without the content needing compensating margins — the arrangement that breaks the moment the
|
|
63
|
+
* header's height changes.
|
|
64
|
+
*
|
|
65
|
+
* The skip link is the first focusable element on the page. It is the cheapest accessibility win
|
|
66
|
+
* available and it is missing from almost every application shell: without it, a keyboard user
|
|
67
|
+
* traverses the entire navigation on every single page load.
|
|
68
|
+
*/
|
|
69
|
+
declare function AppShell({ sidebar, header, children, className }: AppShellProps): react.JSX.Element;
|
|
70
|
+
|
|
71
|
+
export { AppShell as A, type NavItem as N, Sidebar as S, type AppShellProps as a, type NavSection as b, type SidebarProps as c };
|