@ansh-ui/vue 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-2VSROZ2N.js +1281 -0
- package/dist/chunk-2VSROZ2N.js.map +1 -0
- package/dist/chunk-5BQEZYG6.cjs +1294 -0
- package/dist/chunk-5BQEZYG6.cjs.map +1 -0
- package/dist/chunk-6732H4BQ.cjs +28 -0
- package/dist/chunk-6732H4BQ.cjs.map +1 -0
- package/dist/chunk-6ABPGOJP.js +722 -0
- package/dist/chunk-6ABPGOJP.js.map +1 -0
- package/dist/chunk-6XJOB6LE.js +62 -0
- package/dist/chunk-6XJOB6LE.js.map +1 -0
- package/dist/chunk-774WBLDR.cjs +24 -0
- package/dist/chunk-774WBLDR.cjs.map +1 -0
- package/dist/chunk-B6OXKW5Q.js +567 -0
- package/dist/chunk-B6OXKW5Q.js.map +1 -0
- package/dist/chunk-DMPNT3MY.cjs +64 -0
- package/dist/chunk-DMPNT3MY.cjs.map +1 -0
- package/dist/chunk-EISHOEB6.cjs +158 -0
- package/dist/chunk-EISHOEB6.cjs.map +1 -0
- package/dist/chunk-EVO23GUS.js +223 -0
- package/dist/chunk-EVO23GUS.js.map +1 -0
- package/dist/chunk-FVKLCGA4.js +1035 -0
- package/dist/chunk-FVKLCGA4.js.map +1 -0
- package/dist/chunk-IOXGBPOV.cjs +3681 -0
- package/dist/chunk-IOXGBPOV.cjs.map +1 -0
- package/dist/chunk-J2LA4GRP.cjs +1051 -0
- package/dist/chunk-J2LA4GRP.cjs.map +1 -0
- package/dist/chunk-JQ4YLXXM.cjs +580 -0
- package/dist/chunk-JQ4YLXXM.cjs.map +1 -0
- package/dist/chunk-KCA7RNJ4.cjs +781 -0
- package/dist/chunk-KCA7RNJ4.cjs.map +1 -0
- package/dist/chunk-NJDDNO4C.js +23 -0
- package/dist/chunk-NJDDNO4C.js.map +1 -0
- package/dist/chunk-OAQ7MDYX.js +22 -0
- package/dist/chunk-OAQ7MDYX.js.map +1 -0
- package/dist/chunk-PP6OYURM.cjs +238 -0
- package/dist/chunk-PP6OYURM.cjs.map +1 -0
- package/dist/chunk-SHX2JGID.cjs +269 -0
- package/dist/chunk-SHX2JGID.cjs.map +1 -0
- package/dist/chunk-SOYRICHU.js +3645 -0
- package/dist/chunk-SOYRICHU.js.map +1 -0
- package/dist/chunk-T425FIC7.js +773 -0
- package/dist/chunk-T425FIC7.js.map +1 -0
- package/dist/chunk-TMG3M6TK.js +152 -0
- package/dist/chunk-TMG3M6TK.js.map +1 -0
- package/dist/chunk-XLLSS464.cjs +286 -0
- package/dist/chunk-XLLSS464.cjs.map +1 -0
- package/dist/chunk-XZ5ZFLZM.js +280 -0
- package/dist/chunk-XZ5ZFLZM.js.map +1 -0
- package/dist/chunk-Z7XOFKM4.cjs +733 -0
- package/dist/chunk-Z7XOFKM4.cjs.map +1 -0
- package/dist/chunk-ZGMXOMCB.js +266 -0
- package/dist/chunk-ZGMXOMCB.js.map +1 -0
- package/dist/data.cjs +70 -0
- package/dist/data.cjs.map +1 -0
- package/dist/data.d.cts +963 -0
- package/dist/data.d.ts +963 -0
- package/dist/data.js +5 -0
- package/dist/data.js.map +1 -0
- package/dist/form.cjs +151 -0
- package/dist/form.cjs.map +1 -0
- package/dist/form.d.cts +2639 -0
- package/dist/form.d.ts +2639 -0
- package/dist/form.js +6 -0
- package/dist/form.js.map +1 -0
- package/dist/index.cjs +1158 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +439 -0
- package/dist/index.d.ts +439 -0
- package/dist/index.js +547 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.cjs +67 -0
- package/dist/layout.cjs.map +1 -0
- package/dist/layout.d.cts +729 -0
- package/dist/layout.d.ts +729 -0
- package/dist/layout.js +6 -0
- package/dist/layout.js.map +1 -0
- package/dist/motion.cjs +50 -0
- package/dist/motion.cjs.map +1 -0
- package/dist/motion.d.cts +681 -0
- package/dist/motion.d.ts +681 -0
- package/dist/motion.js +5 -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 +515 -0
- package/dist/navigation.d.ts +515 -0
- package/dist/navigation.js +7 -0
- package/dist/navigation.js.map +1 -0
- package/dist/overlay.cjs +61 -0
- package/dist/overlay.cjs.map +1 -0
- package/dist/overlay.d.cts +772 -0
- package/dist/overlay.d.ts +772 -0
- package/dist/overlay.js +8 -0
- package/dist/overlay.js.map +1 -0
- package/dist/position-Cn7qP1pn.d.cts +50 -0
- package/dist/position-Cn7qP1pn.d.ts +50 -0
- package/dist/primitives.cjs +129 -0
- package/dist/primitives.cjs.map +1 -0
- package/dist/primitives.d.cts +300 -0
- package/dist/primitives.d.ts +300 -0
- package/dist/primitives.js +8 -0
- package/dist/primitives.js.map +1 -0
- package/dist/sidebar-CQqEmpid.d.cts +124 -0
- package/dist/sidebar-CTZ-Ckko.d.ts +124 -0
- package/dist/styles.css +5593 -0
- package/dist/utils-IKPG3zcC.d.cts +46 -0
- package/dist/utils-IKPG3zcC.d.ts +46 -0
- package/package.json +91 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { R as ReadonlyRef } from './utils-IKPG3zcC.js';
|
|
2
|
+
export { S as SlotContent, c as cx, r as resolveSlotContent, u as useId } from './utils-IKPG3zcC.js';
|
|
3
|
+
import { b as PositionResult, a as PositionOptions } from './position-Cn7qP1pn.js';
|
|
4
|
+
export { A as Align, P as Placement, R as Rect, S as Side, c as computePosition } from './position-Cn7qP1pn.js';
|
|
5
|
+
import { ComputedRef, Ref, ShallowRef } from 'vue';
|
|
6
|
+
import * as _ansh_ui_core from '@ansh-ui/core';
|
|
7
|
+
import { BudgetReport, PointerState, ScrollTrackOptions, ScrollProgress, FrameState, MotionValue, AnimationOptions, SpringOptions } from '@ansh-ui/core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* State that works both controlled and uncontrolled — the Vue counterpart of
|
|
11
|
+
* `@ansh-ui/react`'s hook of the same name, and just as load-bearing here.
|
|
12
|
+
*
|
|
13
|
+
* A `<Select>` must work as `<Select />` (owns its value), `<Select :default-value="a" />` (owns
|
|
14
|
+
* its value, seeded), `v-model="v"` (the parent owns it via `modelValue`/`update:modelValue`), and
|
|
15
|
+
* `<Select :open="open" @update:open="…" />` for a named prop like a dialog's `open`. All four are
|
|
16
|
+
* the same shape: **the prop is controlled when the reactive getter returns something other than
|
|
17
|
+
* `undefined`**, evaluated on every read rather than latched once — so a component that starts
|
|
18
|
+
* uncontrolled and later receives a value (an async-loaded form) switches over instead of silently
|
|
19
|
+
* ignoring the prop from then on.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const [value, setValue] = useControllableState(
|
|
23
|
+
* () => props.modelValue,
|
|
24
|
+
* defaultValue,
|
|
25
|
+
* (next) => emit('update:modelValue', next),
|
|
26
|
+
* )
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* `getProp` is a plain function rather than a `Ref` so it can read straight off `props` — Vue's
|
|
30
|
+
* `computed` tracks whatever reactive properties it touches, `props.foo` included, with no need to
|
|
31
|
+
* wrap the caller's access pattern.
|
|
32
|
+
*/
|
|
33
|
+
declare function useControllableState<T>(getProp: () => T | undefined, defaultValue: T, onChange?: (value: T) => void): [ComputedRef<T>, (next: T | ((previous: T) => T)) => void];
|
|
34
|
+
|
|
35
|
+
/** Ids of the currently open dismissable layers, outermost first. Exposed for tests. */
|
|
36
|
+
declare function getLayerStack(): readonly string[];
|
|
37
|
+
interface DismissOptions {
|
|
38
|
+
/** Close on pointer press outside the surface. Default `true`. */
|
|
39
|
+
outsidePress?: boolean;
|
|
40
|
+
/** Close on Escape. Only the topmost layer responds. Default `true`. */
|
|
41
|
+
escapeKey?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Extra elements that count as "inside" — normally the trigger.
|
|
44
|
+
*
|
|
45
|
+
* Without this the trigger's own click closes the surface via the outside handler and then
|
|
46
|
+
* immediately reopens it via its own click handler, so the surface appears not to close at all.
|
|
47
|
+
*/
|
|
48
|
+
ignore?: Array<Ref<HTMLElement | null | undefined>>;
|
|
49
|
+
}
|
|
50
|
+
declare function useDismiss(target: Ref<HTMLElement | null | undefined>, open: ReadonlyRef<boolean>, onDismiss: () => void, options?: DismissOptions): void;
|
|
51
|
+
declare function useScrollLock(active: ReadonlyRef<boolean>): void;
|
|
52
|
+
|
|
53
|
+
/** Every tabbable descendant, in tab order. */
|
|
54
|
+
declare function getTabbable(container: HTMLElement | null | undefined): HTMLElement[];
|
|
55
|
+
/**
|
|
56
|
+
* Trap Tab within a container while `active`.
|
|
57
|
+
*
|
|
58
|
+
* Implemented on `keydown` at the container rather than with sentinel elements at either end. The
|
|
59
|
+
* sentinel approach adds two focusable nodes to the accessibility tree that screen readers can land
|
|
60
|
+
* on and announce as blank; intercepting the key does not.
|
|
61
|
+
*/
|
|
62
|
+
declare function useFocusTrap(target: Ref<HTMLElement | null | undefined>, active: ReadonlyRef<boolean>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Restore focus to whatever was focused before `active` became true.
|
|
65
|
+
*
|
|
66
|
+
* The element is captured on activation, not on mount, because a component can be mounted long
|
|
67
|
+
* before it opens.
|
|
68
|
+
*/
|
|
69
|
+
declare function useFocusRestore(active: ReadonlyRef<boolean>): void;
|
|
70
|
+
/**
|
|
71
|
+
* Move focus into a surface when it opens.
|
|
72
|
+
*
|
|
73
|
+
* Prefers an explicitly marked element, then the first tabbable one, then the container itself. The
|
|
74
|
+
* container fallback matters for a dialog whose only content is text: focus must land inside it so a
|
|
75
|
+
* screen reader announces the dialog rather than continuing from the page behind.
|
|
76
|
+
*/
|
|
77
|
+
declare function useAutoFocus(target: Ref<HTMLElement | null | undefined>, active: ReadonlyRef<boolean>, initialFocus?: Ref<HTMLElement | null | undefined>): void;
|
|
78
|
+
/**
|
|
79
|
+
* Roving tabindex for a composite widget (toolbar, tab list, menu).
|
|
80
|
+
*
|
|
81
|
+
* The ARIA authoring practice: a composite has exactly **one** tab stop, and arrow keys move within
|
|
82
|
+
* it. Returns a keydown handler to bind on the composite's container.
|
|
83
|
+
*/
|
|
84
|
+
declare function useRovingFocus(options: {
|
|
85
|
+
/** Items in DOM order. */
|
|
86
|
+
items: Ref<Array<HTMLElement | null>>;
|
|
87
|
+
/** Index that currently owns the tab stop. */
|
|
88
|
+
active: () => number;
|
|
89
|
+
onActiveChange: (index: number) => void;
|
|
90
|
+
orientation?: 'horizontal' | 'vertical' | 'both';
|
|
91
|
+
loop?: boolean;
|
|
92
|
+
}): (event: KeyboardEvent) => void;
|
|
93
|
+
|
|
94
|
+
interface AnchoredPositionOptions extends PositionOptions {
|
|
95
|
+
/** Set the floating element's width to the anchor's — what a combobox listbox wants. */
|
|
96
|
+
matchWidth?: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface AnchoredPosition {
|
|
99
|
+
style: Record<string, string>;
|
|
100
|
+
arrowStyle: Record<string, string> | undefined;
|
|
101
|
+
placement: PositionResult['placement'];
|
|
102
|
+
side: PositionResult['side'];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Keep a floating element positioned against an anchor — the Vue counterpart of `@ansh-ui/react`'s
|
|
106
|
+
* `useAnchoredPosition`.
|
|
107
|
+
*
|
|
108
|
+
* Recomputes on scroll (capture phase, so nested scroll containers are caught), on viewport resize,
|
|
109
|
+
* and whenever either element changes size. It deliberately does **not** poll on every frame: that
|
|
110
|
+
* costs a forced layout per frame for a value that changes only on discrete events.
|
|
111
|
+
*
|
|
112
|
+
* Bound to `open` rather than a separate `enabled` flag — every consumer in this package positions
|
|
113
|
+
* only while its surface is open, so a second flag would be unused surface area.
|
|
114
|
+
*/
|
|
115
|
+
declare function useAnchoredPosition(anchorRef: Ref<HTMLElement | null | undefined>, floatingRef: Ref<HTMLElement | null | undefined>, open: ReadonlyRef<boolean>, options?: AnchoredPositionOptions): {
|
|
116
|
+
position: ComputedRef<AnchoredPosition>;
|
|
117
|
+
update: () => void;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Keep an element mounted while it animates out — the Vue counterpart of `@ansh-ui/react`'s
|
|
122
|
+
* `usePresence`.
|
|
123
|
+
*
|
|
124
|
+
* The problem: `v-if="open"` cannot animate on close, because Vue removes the node the instant
|
|
125
|
+
* `open` flips (Vue's own `<Transition>` solves this for simple cases, but our overlay components
|
|
126
|
+
* need the resolved `mounted`/`state` pair to drive `data-state` for CSS *and* to gate focus
|
|
127
|
+
* trapping and scroll locking off the same signal). The fix is the same as React's: keep rendering
|
|
128
|
+
* it and unmount when the exit animation actually finishes.
|
|
129
|
+
*
|
|
130
|
+
* Finishing is detected from `animationend`/`transitionend` rather than a duration prop, which would
|
|
131
|
+
* have to be kept in sync with the CSS by hand and drifts the moment someone retimes the animation
|
|
132
|
+
* in the stylesheet. The timeout is only a safety net for the case where no animation is declared at
|
|
133
|
+
* all and no event ever fires.
|
|
134
|
+
*/
|
|
135
|
+
declare function usePresence(open: ReadonlyRef<boolean>, target: Ref<HTMLElement | null | undefined>): {
|
|
136
|
+
mounted: Ref<boolean>;
|
|
137
|
+
state: Ref<'open' | 'closed'>;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Observer and lifecycle composables.
|
|
142
|
+
*
|
|
143
|
+
* A consistent pattern throughout: composables that take an element accept a **ref you bind in the
|
|
144
|
+
* template**, and watch it rather than reading it once. This matters because a template ref is
|
|
145
|
+
* `null` during `setup()` and only populated after mount — and stays null across a `v-if` toggle,
|
|
146
|
+
* then repopulates. Watching handles all of that; reading once in `onMounted` silently fails for
|
|
147
|
+
* conditionally-rendered elements, which is the most common bug in hand-written Vue composables.
|
|
148
|
+
*/
|
|
149
|
+
/** Subscribe to the shared ticker for the current scope's lifetime. */
|
|
150
|
+
declare function useTicker(callback: (state: FrameState) => void, options?: {
|
|
151
|
+
phase?: 'read' | 'compute' | 'write' | 'post';
|
|
152
|
+
priority?: number;
|
|
153
|
+
enabled?: Ref<boolean> | boolean;
|
|
154
|
+
}): () => void;
|
|
155
|
+
interface UseInViewOptions {
|
|
156
|
+
threshold?: number;
|
|
157
|
+
rootMargin?: string;
|
|
158
|
+
once?: boolean;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Is the element in view?
|
|
162
|
+
*
|
|
163
|
+
* @param target A template ref. Watched, so it works with `v-if` and with elements that mount late.
|
|
164
|
+
*/
|
|
165
|
+
declare function useInView(target: Ref<HTMLElement | null | undefined>, options?: UseInViewOptions): Ref<boolean>;
|
|
166
|
+
/** Track an element's size as a reactive value. */
|
|
167
|
+
declare function useElementSize(target: Ref<HTMLElement | null | undefined>): Ref<{
|
|
168
|
+
width: number;
|
|
169
|
+
height: number;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Track an element's scroll progress.
|
|
173
|
+
*
|
|
174
|
+
* Returns a **shallowRef holding a mutable state object**, not a reactive number. Scroll progress
|
|
175
|
+
* changes every frame; making it reactive would flush an effect per frame and undo the phase
|
|
176
|
+
* separation the kernel provides. Read `progress.value.progress` inside a `useTicker` callback, or
|
|
177
|
+
* pass `onChange` and write to the DOM directly.
|
|
178
|
+
*/
|
|
179
|
+
declare function useScrollProgress(target: Ref<HTMLElement | null | undefined>, options?: ScrollTrackOptions & {
|
|
180
|
+
onChange?: (progress: ScrollProgress) => void;
|
|
181
|
+
}): ShallowRef<ScrollProgress>;
|
|
182
|
+
/** Track the window's (or a container's) overall scroll. */
|
|
183
|
+
declare function useWindowScroll(onChange?: (info: {
|
|
184
|
+
progress: number;
|
|
185
|
+
scroll: number;
|
|
186
|
+
velocity: number;
|
|
187
|
+
max: number;
|
|
188
|
+
}) => void, options?: {
|
|
189
|
+
axis?: 'y' | 'x';
|
|
190
|
+
container?: HTMLElement | null;
|
|
191
|
+
}): ShallowRef<{
|
|
192
|
+
progress: number;
|
|
193
|
+
scroll: number;
|
|
194
|
+
velocity: number;
|
|
195
|
+
max: number;
|
|
196
|
+
}>;
|
|
197
|
+
/**
|
|
198
|
+
* Track pointer position over an element.
|
|
199
|
+
*
|
|
200
|
+
* The returned object is mutated in place by the tracker each frame and is deliberately **not**
|
|
201
|
+
* reactive — reading it in a template would flush on every pointer move.
|
|
202
|
+
*/
|
|
203
|
+
declare function usePointer(target: Ref<HTMLElement | null | undefined>, options?: {
|
|
204
|
+
smoothing?: number;
|
|
205
|
+
trackOutside?: boolean;
|
|
206
|
+
}): ShallowRef<Readonly<PointerState> | null>;
|
|
207
|
+
/**
|
|
208
|
+
* Does the user prefer reduced motion?
|
|
209
|
+
*
|
|
210
|
+
* Returns `false` during SSR, which is the hydration-safe default: the server cannot know, and
|
|
211
|
+
* differing between server and first client render would be a mismatch.
|
|
212
|
+
*/
|
|
213
|
+
declare function useReducedMotion(): Ref<boolean>;
|
|
214
|
+
/**
|
|
215
|
+
* Live frame-budget telemetry for a development overlay.
|
|
216
|
+
*
|
|
217
|
+
* Sampled at 4 Hz rather than per frame: a number changing 60 times a second is unreadable, and
|
|
218
|
+
* rendering it that often distorts the measurement it is reporting.
|
|
219
|
+
*/
|
|
220
|
+
declare function useFrameBudget(): Ref<BudgetReport | null>;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Vue motion composables.
|
|
224
|
+
*
|
|
225
|
+
* The design principle mirrors the React package: animated values live **outside** Vue's
|
|
226
|
+
* reactivity. A `ref` that updates 60 times a second triggers 60 reactive effect flushes and, if
|
|
227
|
+
* anything in a template reads it, 60 patch cycles — which is precisely the cost that makes
|
|
228
|
+
* "animation in a framework" slow.
|
|
229
|
+
*
|
|
230
|
+
* So {@link useMotionValue} returns the engine's `MotionValue` directly and writes to the DOM. Where
|
|
231
|
+
* a value genuinely belongs in a template, {@link useMotionRef} bridges it into a `shallowRef` and
|
|
232
|
+
* says plainly what that costs.
|
|
233
|
+
*
|
|
234
|
+
* Cleanup uses `onScopeDispose` rather than `onBeforeUnmount`, so these compose correctly inside
|
|
235
|
+
* `effectScope()` — including in Pinia stores and outside a component instance entirely.
|
|
236
|
+
*/
|
|
237
|
+
/**
|
|
238
|
+
* Create a {@link MotionValue} bound to the current effect scope.
|
|
239
|
+
*
|
|
240
|
+
* Does not trigger re-renders. Pass it to `useMotionStyle` or read it in a `useTicker` callback.
|
|
241
|
+
*/
|
|
242
|
+
declare function useMotionValue<T>(initial: T): MotionValue<T>;
|
|
243
|
+
/**
|
|
244
|
+
* Bridge a MotionValue into a Vue ref.
|
|
245
|
+
*
|
|
246
|
+
* **This makes the value reactive, which means a component update on every change.** For a value
|
|
247
|
+
* being animated continuously that is 60 updates per second. Use it for values that change at
|
|
248
|
+
* interaction rate — a settled spring, a toggle — not for anything mid-animation.
|
|
249
|
+
*
|
|
250
|
+
* A `shallowRef` rather than `ref` because the value is replaced wholesale, never mutated, so deep
|
|
251
|
+
* reactivity would be pure overhead.
|
|
252
|
+
*/
|
|
253
|
+
declare function useMotionRef<T>(value: MotionValue<T>): Readonly<ShallowRef<T>>;
|
|
254
|
+
/**
|
|
255
|
+
* Write a MotionValue straight to an element's style property, bypassing Vue's renderer.
|
|
256
|
+
*
|
|
257
|
+
* This is the mechanism for smooth animation in Vue. Bind the returned ref to an element:
|
|
258
|
+
*
|
|
259
|
+
* ```vue
|
|
260
|
+
* <script setup>
|
|
261
|
+
* const x = useMotionValue(0)
|
|
262
|
+
* const el = useMotionStyle(x, (v) => `translateX(${v}px)`)
|
|
263
|
+
* </script>
|
|
264
|
+
* <template><div :ref="el" /></template>
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
declare function useMotionStyle<T, El extends HTMLElement = HTMLElement>(value: MotionValue<T>, format: (value: T) => string, property?: string): ShallowRef<El | null>;
|
|
268
|
+
/**
|
|
269
|
+
* A spring that continuously chases a target.
|
|
270
|
+
*
|
|
271
|
+
* The target is a plain setter rather than a reactive ref, deliberately: reading a ref inside the
|
|
272
|
+
* spring's per-frame callback would register a reactive dependency and flush an effect every
|
|
273
|
+
* frame, which defeats the purpose of keeping the animation outside the reactivity system.
|
|
274
|
+
*/
|
|
275
|
+
declare function useSpringValue(initial: number, options?: SpringOptions): {
|
|
276
|
+
value: MotionValue<number>;
|
|
277
|
+
set: (target: number) => void;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Scope-bound imperative animation.
|
|
281
|
+
*
|
|
282
|
+
* Any in-flight animation is stopped when the scope disposes, and when `start` is called again —
|
|
283
|
+
* which is the behaviour you want, since two animations driving one value fight each other.
|
|
284
|
+
*/
|
|
285
|
+
declare function useAnimate(): <T>(from: T | MotionValue<T>, to: T | readonly T[], options?: AnimationOptions<T>) => _ansh_ui_core.AnimationControls;
|
|
286
|
+
/**
|
|
287
|
+
* Drive a MotionValue from a reactive source.
|
|
288
|
+
*
|
|
289
|
+
* The bridge in the other direction: when a `ref` in your component changes, animate toward the new
|
|
290
|
+
* value. This is the idiomatic way to connect Vue state to Ansh motion.
|
|
291
|
+
*
|
|
292
|
+
* ```ts
|
|
293
|
+
* const open = ref(false)
|
|
294
|
+
* const height = useMotionValue(0)
|
|
295
|
+
* useAnimatedFrom(open, height, (isOpen) => (isOpen ? 320 : 0), { spring: 'snappy' })
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
declare function useAnimatedFrom<Source, T>(source: Ref<Source>, target: MotionValue<T>, map: (value: Source) => T, options?: AnimationOptions<T>): void;
|
|
299
|
+
|
|
300
|
+
export { type AnchoredPosition, type AnchoredPositionOptions, type DismissOptions, PositionOptions, PositionResult, ReadonlyRef, type UseInViewOptions, getLayerStack, getTabbable, useAnchoredPosition, useAnimate, useAnimatedFrom, useAutoFocus, useControllableState, useDismiss, useElementSize, useFocusRestore, useFocusTrap, useFrameBudget, useInView, useMotionRef, useMotionStyle, useMotionValue, usePointer, usePresence, useReducedMotion, useRovingFocus, useScrollLock, useScrollProgress, useSpringValue, useTicker, useWindowScroll };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { usePresence } from './chunk-6XJOB6LE.js';
|
|
2
|
+
export { computePosition, getLayerStack, useAnchoredPosition, useDismiss, useScrollLock } from './chunk-XZ5ZFLZM.js';
|
|
3
|
+
export { getTabbable, useAutoFocus, useFocusRestore, useFocusTrap, useRovingFocus } from './chunk-TMG3M6TK.js';
|
|
4
|
+
export { useControllableState } from './chunk-OAQ7MDYX.js';
|
|
5
|
+
export { useAnimate, useAnimatedFrom, useElementSize, useFrameBudget, useInView, useMotionRef, useMotionStyle, useMotionValue, usePointer, useReducedMotion, useScrollProgress, useSpringValue, useTicker, useWindowScroll } from './chunk-EVO23GUS.js';
|
|
6
|
+
export { cx, resolveSlotContent, useId } from './chunk-NJDDNO4C.js';
|
|
7
|
+
//# sourceMappingURL=primitives.js.map
|
|
8
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"primitives.js"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { VNode, PropType } from 'vue';
|
|
3
|
+
import { S as SlotContent } from './utils-IKPG3zcC.cjs';
|
|
4
|
+
|
|
5
|
+
interface NavItem {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
href?: string;
|
|
9
|
+
icon?: SlotContent;
|
|
10
|
+
/** Count or status shown on the right. */
|
|
11
|
+
badge?: SlotContent;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
/** Nested items, rendered in a collapsible group. */
|
|
15
|
+
items?: readonly NavItem[];
|
|
16
|
+
}
|
|
17
|
+
interface NavSection {
|
|
18
|
+
id: string;
|
|
19
|
+
/** Heading above the group. Omit for an unlabelled block. */
|
|
20
|
+
label?: string;
|
|
21
|
+
items: readonly NavItem[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The application sidebar — the Vue counterpart of `@ansh-ui/react`'s `Sidebar`.
|
|
25
|
+
*
|
|
26
|
+
* A `<nav>` containing lists of links — the structure a screen reader user navigates by landmark,
|
|
27
|
+
* and the reason this isn't a stack of divs. Nested groups are `<button aria-expanded>` controlling
|
|
28
|
+
* a `<ul>`, so their state is announced.
|
|
29
|
+
*
|
|
30
|
+
* Collapsing to an icon rail keeps the labels in the DOM (visually hidden), rather than removing
|
|
31
|
+
* them. Removing them would leave a rail of unlabelled icons for anyone using assistive technology,
|
|
32
|
+
* which is exactly the population for whom the space saving is irrelevant.
|
|
33
|
+
*
|
|
34
|
+
* `header`/`footer` are React props of arbitrary content in the source; here they are the `#header`
|
|
35
|
+
* and `#footer` slots — passing a whole render tree through a prop is idiomatic React and awkward
|
|
36
|
+
* Vue, the same reasoning `HoverCard`'s `#content` slot documents.
|
|
37
|
+
*/
|
|
38
|
+
declare const Sidebar: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
39
|
+
sections: {
|
|
40
|
+
type: PropType<readonly NavSection[]>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
/** Id of the active item. */
|
|
44
|
+
activeId: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
/** Collapse to an icon rail. */
|
|
49
|
+
collapsed: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
defaultCollapsed: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** Show the collapse toggle. Default `true`. */
|
|
58
|
+
collapsible: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
default: boolean;
|
|
61
|
+
};
|
|
62
|
+
label: {
|
|
63
|
+
type: StringConstructor;
|
|
64
|
+
default: string;
|
|
65
|
+
};
|
|
66
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("navigate" | "update:collapsed")[], "navigate" | "update:collapsed", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
69
|
+
sections: {
|
|
70
|
+
type: PropType<readonly NavSection[]>;
|
|
71
|
+
required: true;
|
|
72
|
+
};
|
|
73
|
+
/** Id of the active item. */
|
|
74
|
+
activeId: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
/** Collapse to an icon rail. */
|
|
79
|
+
collapsed: {
|
|
80
|
+
type: BooleanConstructor;
|
|
81
|
+
default: undefined;
|
|
82
|
+
};
|
|
83
|
+
defaultCollapsed: {
|
|
84
|
+
type: BooleanConstructor;
|
|
85
|
+
default: boolean;
|
|
86
|
+
};
|
|
87
|
+
/** Show the collapse toggle. Default `true`. */
|
|
88
|
+
collapsible: {
|
|
89
|
+
type: BooleanConstructor;
|
|
90
|
+
default: boolean;
|
|
91
|
+
};
|
|
92
|
+
label: {
|
|
93
|
+
type: StringConstructor;
|
|
94
|
+
default: string;
|
|
95
|
+
};
|
|
96
|
+
}>> & Readonly<{
|
|
97
|
+
onNavigate?: ((...args: any[]) => any) | undefined;
|
|
98
|
+
"onUpdate:collapsed"?: ((...args: any[]) => any) | undefined;
|
|
99
|
+
}>, {
|
|
100
|
+
label: string;
|
|
101
|
+
activeId: string;
|
|
102
|
+
collapsed: boolean;
|
|
103
|
+
defaultCollapsed: boolean;
|
|
104
|
+
collapsible: boolean;
|
|
105
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
106
|
+
/**
|
|
107
|
+
* The header + sidebar + content frame — the Vue counterpart of `@ansh-ui/react`'s `AppShell`.
|
|
108
|
+
*
|
|
109
|
+
* A grid rather than nested flex containers, so the sidebar and header can be `position: sticky`
|
|
110
|
+
* without the content needing compensating margins — the arrangement that breaks the moment the
|
|
111
|
+
* header's height changes.
|
|
112
|
+
*
|
|
113
|
+
* The skip link is the first focusable element on the page. It is the cheapest accessibility win
|
|
114
|
+
* available and it is missing from almost every application shell: without it, a keyboard user
|
|
115
|
+
* traverses the entire navigation on every single page load.
|
|
116
|
+
*
|
|
117
|
+
* `sidebar`/`header` are the `#sidebar`/`#header` slots (see `Sidebar`'s doc comment for why); the
|
|
118
|
+
* main content is the default slot.
|
|
119
|
+
*/
|
|
120
|
+
declare const AppShell: vue.DefineComponent<{}, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
123
|
+
|
|
124
|
+
export { AppShell as A, type NavItem as N, Sidebar as S, type NavSection as a };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { VNode, PropType } from 'vue';
|
|
3
|
+
import { S as SlotContent } from './utils-IKPG3zcC.js';
|
|
4
|
+
|
|
5
|
+
interface NavItem {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
href?: string;
|
|
9
|
+
icon?: SlotContent;
|
|
10
|
+
/** Count or status shown on the right. */
|
|
11
|
+
badge?: SlotContent;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
/** Nested items, rendered in a collapsible group. */
|
|
15
|
+
items?: readonly NavItem[];
|
|
16
|
+
}
|
|
17
|
+
interface NavSection {
|
|
18
|
+
id: string;
|
|
19
|
+
/** Heading above the group. Omit for an unlabelled block. */
|
|
20
|
+
label?: string;
|
|
21
|
+
items: readonly NavItem[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The application sidebar — the Vue counterpart of `@ansh-ui/react`'s `Sidebar`.
|
|
25
|
+
*
|
|
26
|
+
* A `<nav>` containing lists of links — the structure a screen reader user navigates by landmark,
|
|
27
|
+
* and the reason this isn't a stack of divs. Nested groups are `<button aria-expanded>` controlling
|
|
28
|
+
* a `<ul>`, so their state is announced.
|
|
29
|
+
*
|
|
30
|
+
* Collapsing to an icon rail keeps the labels in the DOM (visually hidden), rather than removing
|
|
31
|
+
* them. Removing them would leave a rail of unlabelled icons for anyone using assistive technology,
|
|
32
|
+
* which is exactly the population for whom the space saving is irrelevant.
|
|
33
|
+
*
|
|
34
|
+
* `header`/`footer` are React props of arbitrary content in the source; here they are the `#header`
|
|
35
|
+
* and `#footer` slots — passing a whole render tree through a prop is idiomatic React and awkward
|
|
36
|
+
* Vue, the same reasoning `HoverCard`'s `#content` slot documents.
|
|
37
|
+
*/
|
|
38
|
+
declare const Sidebar: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
39
|
+
sections: {
|
|
40
|
+
type: PropType<readonly NavSection[]>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
/** Id of the active item. */
|
|
44
|
+
activeId: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
default: undefined;
|
|
47
|
+
};
|
|
48
|
+
/** Collapse to an icon rail. */
|
|
49
|
+
collapsed: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
defaultCollapsed: {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
};
|
|
57
|
+
/** Show the collapse toggle. Default `true`. */
|
|
58
|
+
collapsible: {
|
|
59
|
+
type: BooleanConstructor;
|
|
60
|
+
default: boolean;
|
|
61
|
+
};
|
|
62
|
+
label: {
|
|
63
|
+
type: StringConstructor;
|
|
64
|
+
default: string;
|
|
65
|
+
};
|
|
66
|
+
}>, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("navigate" | "update:collapsed")[], "navigate" | "update:collapsed", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
69
|
+
sections: {
|
|
70
|
+
type: PropType<readonly NavSection[]>;
|
|
71
|
+
required: true;
|
|
72
|
+
};
|
|
73
|
+
/** Id of the active item. */
|
|
74
|
+
activeId: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
/** Collapse to an icon rail. */
|
|
79
|
+
collapsed: {
|
|
80
|
+
type: BooleanConstructor;
|
|
81
|
+
default: undefined;
|
|
82
|
+
};
|
|
83
|
+
defaultCollapsed: {
|
|
84
|
+
type: BooleanConstructor;
|
|
85
|
+
default: boolean;
|
|
86
|
+
};
|
|
87
|
+
/** Show the collapse toggle. Default `true`. */
|
|
88
|
+
collapsible: {
|
|
89
|
+
type: BooleanConstructor;
|
|
90
|
+
default: boolean;
|
|
91
|
+
};
|
|
92
|
+
label: {
|
|
93
|
+
type: StringConstructor;
|
|
94
|
+
default: string;
|
|
95
|
+
};
|
|
96
|
+
}>> & Readonly<{
|
|
97
|
+
onNavigate?: ((...args: any[]) => any) | undefined;
|
|
98
|
+
"onUpdate:collapsed"?: ((...args: any[]) => any) | undefined;
|
|
99
|
+
}>, {
|
|
100
|
+
label: string;
|
|
101
|
+
activeId: string;
|
|
102
|
+
collapsed: boolean;
|
|
103
|
+
defaultCollapsed: boolean;
|
|
104
|
+
collapsible: boolean;
|
|
105
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
106
|
+
/**
|
|
107
|
+
* The header + sidebar + content frame — the Vue counterpart of `@ansh-ui/react`'s `AppShell`.
|
|
108
|
+
*
|
|
109
|
+
* A grid rather than nested flex containers, so the sidebar and header can be `position: sticky`
|
|
110
|
+
* without the content needing compensating margins — the arrangement that breaks the moment the
|
|
111
|
+
* header's height changes.
|
|
112
|
+
*
|
|
113
|
+
* The skip link is the first focusable element on the page. It is the cheapest accessibility win
|
|
114
|
+
* available and it is missing from almost every application shell: without it, a keyboard user
|
|
115
|
+
* traverses the entire navigation on every single page load.
|
|
116
|
+
*
|
|
117
|
+
* `sidebar`/`header` are the `#sidebar`/`#header` slots (see `Sidebar`'s doc comment for why); the
|
|
118
|
+
* main content is the default slot.
|
|
119
|
+
*/
|
|
120
|
+
declare const AppShell: vue.DefineComponent<{}, () => VNode<vue.RendererNode, vue.RendererElement, {
|
|
121
|
+
[key: string]: any;
|
|
122
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
123
|
+
|
|
124
|
+
export { AppShell as A, type NavItem as N, Sidebar as S, type NavSection as a };
|