@inertiaui/vanilla 1.5.0 → 1.7.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/README.md +305 -34
- package/dist/index.d.ts +154 -1
- package/dist/index.js +844 -310
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,13 @@ export declare interface AnimateOptions {
|
|
|
32
32
|
|
|
33
33
|
export declare type AnimationSnapshot = Map<HTMLElement, DOMRect>;
|
|
34
34
|
|
|
35
|
+
export declare interface Announcer {
|
|
36
|
+
announce(text: string, politeness: AnnouncerPoliteness): void;
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare type AnnouncerPoliteness = 'polite' | 'assertive';
|
|
41
|
+
|
|
35
42
|
export declare type AutoScrollAxis = 'x' | 'y' | 'both';
|
|
36
43
|
|
|
37
44
|
export declare type AutoScrollContainer = Element | Window;
|
|
@@ -70,6 +77,13 @@ export declare function cancelAnimations(element: HTMLElement): void;
|
|
|
70
77
|
*/
|
|
71
78
|
export declare function captureAnimationSnapshot(elements: Iterable<HTMLElement | null | undefined>): AnimationSnapshot | null;
|
|
72
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Remember an element's inline values for some CSS properties, with their
|
|
82
|
+
* priorities, so temporary changes can be undone without touching other inline
|
|
83
|
+
* styles. Name properties as in CSS, such as `z-index`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function captureInlineStyles(element: HTMLElement, properties: readonly string[]): InlineStyleSnapshot;
|
|
86
|
+
|
|
73
87
|
export declare type CleanupFunction = () => void;
|
|
74
88
|
|
|
75
89
|
/**
|
|
@@ -79,6 +93,12 @@ export declare type ColorFormat = 'hex' | 'rgb' | 'hsl';
|
|
|
79
93
|
|
|
80
94
|
export declare function computePosition(reference: HTMLElement, floating: HTMLElement, options?: PositionOptions_2): PositionResult;
|
|
81
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Announces messages through two persistent, visually hidden live regions. The regions only ever contain
|
|
98
|
+
* plain text, so screen readers do not read button labels or other markup along with a message.
|
|
99
|
+
*/
|
|
100
|
+
export declare function createAnnouncer(regions: Record<AnnouncerPoliteness, HTMLElement>): Announcer;
|
|
101
|
+
|
|
82
102
|
/**
|
|
83
103
|
* Create a {@link Debouncer} with a fixed delay or a getter read on each schedule.
|
|
84
104
|
*
|
|
@@ -93,6 +113,12 @@ export declare function createFocusOutDismiss(options: FocusOutDismissOptions):
|
|
|
93
113
|
|
|
94
114
|
export declare function createFocusTrap(container: HTMLElement, options?: FocusTrapOptions): CleanupFunction;
|
|
95
115
|
|
|
116
|
+
/**
|
|
117
|
+
* Animate layout changes a renderer makes after a snapshot, keeping track of
|
|
118
|
+
* scheduled and running moves so they can be interrupted.
|
|
119
|
+
*/
|
|
120
|
+
export declare function createLayoutAnimation(options?: LayoutAnimationOptions): LayoutAnimationController;
|
|
121
|
+
|
|
96
122
|
export declare function createMenuNavigation(container: HTMLElement, options?: MenuNavigationOptions): CleanupFunction;
|
|
97
123
|
|
|
98
124
|
export declare function createNativePopoverDisclosure(options: NativePopoverDisclosureOptions): NativePopoverDisclosureController;
|
|
@@ -215,6 +241,13 @@ export declare interface FocusTrapOptions {
|
|
|
215
241
|
returnFocus?: boolean;
|
|
216
242
|
}
|
|
217
243
|
|
|
244
|
+
/**
|
|
245
|
+
* Give a panel rendered away from its reference, such as in the body, the
|
|
246
|
+
* direction the reference is written in. A panel with its own `dir` keeps it.
|
|
247
|
+
* Returns a cleanup function that removes the direction again.
|
|
248
|
+
*/
|
|
249
|
+
export declare function followReferenceDirection(reference: Element, panel: HTMLElement): CleanupFunction;
|
|
250
|
+
|
|
218
251
|
/**
|
|
219
252
|
* Format an alpha value as a compact decimal string (e.g. `0.5`, `1`),
|
|
220
253
|
* dropping trailing zeros.
|
|
@@ -244,6 +277,24 @@ export declare interface FormatColorOptions {
|
|
|
244
277
|
|
|
245
278
|
export declare function generateId(prefix?: string): string;
|
|
246
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Return how far each item moves along the axis when the items are laid out in
|
|
282
|
+
* `order`, a permutation of their indices. The offsets describe the movement
|
|
283
|
+
* between the items packed in their current order and packed in `order`, so items
|
|
284
|
+
* of different sizes line up and an unchanged order returns zero offsets. Each gap
|
|
285
|
+
* between neighboring slots stays in place, or is `gap` in both layouts when
|
|
286
|
+
* given. An order that is not a permutation of the items leaves every item where
|
|
287
|
+
* it is.
|
|
288
|
+
*/
|
|
289
|
+
export declare function getReorderOffsets(rects: readonly ReorderBounds[], order: readonly number[], options?: ReorderOffsetsOptions): number[];
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Ancestors of `element` that can scroll, nearest first, followed by its window.
|
|
293
|
+
* Pass an axis to keep only the ancestors that scroll along it. Shadow roots are
|
|
294
|
+
* crossed through their hosts.
|
|
295
|
+
*/
|
|
296
|
+
export declare function getScrollableAncestors(element: Element | null, axis?: AutoScrollAxis): AutoScrollContainer[];
|
|
297
|
+
|
|
247
298
|
/**
|
|
248
299
|
* Convert a hex color string to HSL values.
|
|
249
300
|
* Accepts with or without leading '#'.
|
|
@@ -272,6 +323,17 @@ export declare function hslToHex(h: number, s: number, l: number): string;
|
|
|
272
323
|
/** Copy selected computed custom properties and restore owned inline values on cleanup. */
|
|
273
324
|
export declare function inheritCssVariables(source: HTMLElement, target: HTMLElement, options: CssVariableInheritanceOptions): () => void;
|
|
274
325
|
|
|
326
|
+
export declare interface InlineStyleSnapshot {
|
|
327
|
+
/** Put back the captured inline values and priorities, of every captured property or only of the given ones. */
|
|
328
|
+
restore: (properties?: readonly string[]) => void;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Check whether an element is written right to left, from its computed `direction`. Unlike `isRtl()`, this follows a
|
|
333
|
+
* `dir` attribute on any ancestor, such as a right-to-left section in a left-to-right page.
|
|
334
|
+
*/
|
|
335
|
+
export declare function isRightToLeft(element: Element): boolean;
|
|
336
|
+
|
|
275
337
|
/**
|
|
276
338
|
* Check whether the document is currently in RTL direction.
|
|
277
339
|
*/
|
|
@@ -281,6 +343,34 @@ export declare function isStandardDomEvent(eventName: string): boolean;
|
|
|
281
343
|
|
|
282
344
|
export declare function kebabCase(string: string): string;
|
|
283
345
|
|
|
346
|
+
export declare interface LayoutAnimationCallbacks {
|
|
347
|
+
/** Called with the started animations, in the same task that starts them. */
|
|
348
|
+
onStart?: (animations: Animation[]) => void;
|
|
349
|
+
/**
|
|
350
|
+
* Called once every animation of the run has finished or been canceled, by a
|
|
351
|
+
* later run taking over its elements or by `cancel()`. Use it to undo styles
|
|
352
|
+
* the move needed. Still runs, shortly after `onStart`, when nothing animates.
|
|
353
|
+
*/
|
|
354
|
+
onSettle?: () => void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export declare interface LayoutAnimationController {
|
|
358
|
+
/** Animate the elements from `snapshot` to their layout once the renderer has updated. */
|
|
359
|
+
animate: (snapshot: AnimationSnapshot | null, getElements: () => Iterable<HTMLElement | null | undefined>, callbacks?: LayoutAnimationCallbacks) => void;
|
|
360
|
+
/** Drop runs that have not started and cancel running animations, which still settle. */
|
|
361
|
+
cancel: () => void;
|
|
362
|
+
/** Stop everything without calling back, and ignore later runs. Idempotent. */
|
|
363
|
+
cleanup: CleanupFunction;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export declare interface LayoutAnimationOptions extends AnimateFromSnapshotOptions {
|
|
367
|
+
/**
|
|
368
|
+
* Run the callback once the renderer has applied the new layout, and return a
|
|
369
|
+
* function that cancels it. Defaults to the next animation frame.
|
|
370
|
+
*/
|
|
371
|
+
schedule?: (run: () => void) => (() => void) | void;
|
|
372
|
+
}
|
|
373
|
+
|
|
284
374
|
export declare interface ListboxNavigationOptions<T> {
|
|
285
375
|
items: readonly T[];
|
|
286
376
|
currentIndex: number;
|
|
@@ -483,6 +573,8 @@ declare interface PositionOptions_2 {
|
|
|
483
573
|
* applied via its `anchor` prop, so long menus scroll instead of overflowing.
|
|
484
574
|
*/
|
|
485
575
|
autoSize?: boolean;
|
|
576
|
+
/** Use CSS anchors when supported. Set false to use numeric positioning. */
|
|
577
|
+
anchorPositioning?: boolean;
|
|
486
578
|
}
|
|
487
579
|
export { PositionOptions_2 as PositionOptions }
|
|
488
580
|
|
|
@@ -532,7 +624,18 @@ export declare interface ReorderableListController<T> {
|
|
|
532
624
|
moveItem: (index: number, direction: ReorderDirection) => ReorderMove<T> | null;
|
|
533
625
|
/** Begin a pointer reorder from a registered handle event. */
|
|
534
626
|
pointerDown: (index: number, event: PointerEvent) => void;
|
|
535
|
-
/**
|
|
627
|
+
/**
|
|
628
|
+
* Pointer positions of the active drag, or null while idle and before a press
|
|
629
|
+
* starts dragging. The object lives for the whole gesture and its `position`
|
|
630
|
+
* is replaced as the pointer moves, so copy the values you need to keep.
|
|
631
|
+
*/
|
|
632
|
+
getPointer: () => ReorderPointer | null;
|
|
633
|
+
/**
|
|
634
|
+
* End a pending press or active pointer drag without committing it. An active
|
|
635
|
+
* drag notifies `onChange` with the idle state. The controller stays usable.
|
|
636
|
+
*/
|
|
637
|
+
cancel: () => void;
|
|
638
|
+
/** Cancel active pointer work and remove global listeners without notifying `onChange`. Idempotent. */
|
|
536
639
|
cleanup: CleanupFunction;
|
|
537
640
|
}
|
|
538
641
|
|
|
@@ -547,6 +650,23 @@ export declare interface ReorderableListOptions<T> {
|
|
|
547
650
|
getBounds?: () => ReorderBounds | null;
|
|
548
651
|
/** Optional edge auto-scroll while pointer-dragging. Disabled by default. */
|
|
549
652
|
autoScroll?: boolean | AutoScrollerOptions;
|
|
653
|
+
/**
|
|
654
|
+
* Pointer travel in CSS pixels before a press starts dragging. Until then the
|
|
655
|
+
* press keeps its native click, focus, and scrolling. Defaults to 0, which
|
|
656
|
+
* starts dragging on press.
|
|
657
|
+
*/
|
|
658
|
+
activationDistance?: number;
|
|
659
|
+
/** Ignore the click that follows a pointer drag, so releasing over a control does not activate it. Defaults to false. */
|
|
660
|
+
suppressClickAfterDrag?: boolean;
|
|
661
|
+
/**
|
|
662
|
+
* Point that picks the drop slot while pointer-dragging, given the pointer and
|
|
663
|
+
* the dragged item's box as measured when the drag started. Returning the
|
|
664
|
+
* item's leading edge lets items of different sizes swap once the dragged
|
|
665
|
+
* item covers half of a neighbor. The point is clamped to the items' extent,
|
|
666
|
+
* and returning null uses the pointer, which is also the default. Whether a
|
|
667
|
+
* release drops or cancels always follows the pointer itself.
|
|
668
|
+
*/
|
|
669
|
+
getCollisionPoint?: (pointer: ReorderPointer, item: ReorderBounds) => ReorderPoint | null;
|
|
550
670
|
/** Called whenever pointer drag state changes. */
|
|
551
671
|
onChange?: (state: ReorderableListState) => void;
|
|
552
672
|
/** Called immediately before items are written or `onReorder` fires. */
|
|
@@ -586,6 +706,32 @@ export declare type ReorderMove<T> = {
|
|
|
586
706
|
source: ReorderSource;
|
|
587
707
|
};
|
|
588
708
|
|
|
709
|
+
export declare interface ReorderOffsetsOptions {
|
|
710
|
+
/** Axis the items are laid out along. Defaults to `'y'`. */
|
|
711
|
+
axis?: 'x' | 'y';
|
|
712
|
+
/** The items run toward the start of the axis, as in a right-to-left row. Defaults to false. */
|
|
713
|
+
reverse?: boolean;
|
|
714
|
+
/**
|
|
715
|
+
* Space between neighboring items, used for both orders. Defaults to the gap
|
|
716
|
+
* each slot has now, which suits lists whose items are measured where they lie
|
|
717
|
+
* in the flow. Pass 0 for items that touch, such as table cells, when some boxes
|
|
718
|
+
* are measured elsewhere, for instance stuck in place by sticky positioning.
|
|
719
|
+
*/
|
|
720
|
+
gap?: number;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
export declare type ReorderPoint = {
|
|
724
|
+
clientX: number;
|
|
725
|
+
clientY: number;
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
export declare type ReorderPointer = {
|
|
729
|
+
/** Where the press started. */
|
|
730
|
+
readonly origin: ReorderPoint;
|
|
731
|
+
/** The latest pointer position. */
|
|
732
|
+
readonly position: ReorderPoint;
|
|
733
|
+
};
|
|
734
|
+
|
|
589
735
|
export declare type ReorderPreviewItem<T> = {
|
|
590
736
|
item: T;
|
|
591
737
|
/** Index in the source item array. */
|
|
@@ -596,6 +742,13 @@ export declare type ReorderPreviewItem<T> = {
|
|
|
596
742
|
|
|
597
743
|
export declare type ReorderSource = 'keyboard' | 'pointer';
|
|
598
744
|
|
|
745
|
+
/**
|
|
746
|
+
* Replaces Laravel-style placeholders, such as `:name`, with the given values in one pass. A longer key wins over a
|
|
747
|
+
* shorter one that starts it, so `:names` is not read as `:name` followed by `s`. A placeholder followed by a letter,
|
|
748
|
+
* digit, or underscore is left alone, as are placeholders without a value. Values are not searched for placeholders.
|
|
749
|
+
*/
|
|
750
|
+
export declare function replacePlaceholders(template: string, params: Record<string, string | number>): string;
|
|
751
|
+
|
|
599
752
|
export declare function resolveListboxNavigation<T>(options: ListboxNavigationOptions<T>): ListboxNavigationResult;
|
|
600
753
|
|
|
601
754
|
/**
|