@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 CHANGED
@@ -1,11 +1,14 @@
1
1
  # Inertia UI Vanilla
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@inertiaui/vanilla)](https://www.npmjs.com/package/@inertiaui/vanilla)
4
+
3
5
  A lightweight vanilla TypeScript library providing UI utilities for dialogs, animations, focus management, menu/listbox navigation, click outside detection, floating and native popover positioning, reorder interactions, color parsing, debounce helpers, and common helper functions. Framework-agnostic and designed to integrate seamlessly with Vue, React, or any JavaScript application.
4
6
 
5
7
  This package is part of the [Inertia UI](https://inertiaui.com) suite. Check out our other packages:
6
8
 
7
9
  - **[Inertia Modal](https://inertiaui.com/inertia-modal/docs/)**: Turn any Laravel route into a modal or slideover with a single component. No backend changes needed, with support for nested/stacked modals and inter-modal communication. Works with Vue and React.
8
10
  - **[Inertia Table](https://inertiaui.com/inertia-table)**: The most complete data table package for Laravel and Inertia.js. Sorting, searching, and filtering across relationships, bulk actions, CSV/Excel/PDF exports, sticky headers, and much more. Works with Vue and React.
11
+ - **[Inertia Forms](https://inertiaui.com/inertia-forms)**: Define forms in Laravel and render them with a single Vue or React component. Includes validation, file uploads, conditional fields, and multi-step flows.
9
12
 
10
13
  [![Inertia UI](https://inertiaui.com/visit-card.jpg)](https://inertiaui.com)
11
14
 
@@ -28,6 +31,7 @@ npm install @inertiaui/vanilla
28
31
  - [Native Popovers](#native-popovers)
29
32
  - [Tooltip Controllers](#tooltip-controllers)
30
33
  - [Dialog Controllers](#dialog-controllers)
34
+ - [Inline styles](#inline-styles)
31
35
  - [CSS Variable Inheritance](#css-variable-inheritance)
32
36
  - [Accessibility](#accessibility)
33
37
  - [Animation](#animation)
@@ -408,71 +412,199 @@ focusOut.cleanup()
408
412
 
409
413
  ## Reorder
410
414
 
411
- Framework-neutral helpers for keyboard and pointer reordering.
412
-
413
415
  ### createReorderableList
414
416
 
415
- Use `createReorderableList` when you want a headless list controller that owns item registration, live pointer preview state, keyboard moves, pointer commits, optional bounds, optional auto-scroll, and cleanup. Rendering, announcements, focus handling, and animations stay in your package or framework adapter.
417
+ `createReorderableList` manages item registration, preview order, keyboard moves, pointer drags, and cleanup. Bounds and auto-scroll are optional. Your application controls rendering, announcements, focus, and animation.
416
418
 
417
419
  ```typescript
418
420
  import {
419
- animateFromSnapshot,
420
- captureAnimationSnapshot,
421
- createReorderableList,
422
- REORDERABLE_LIST_HANDLE_ATTRIBUTE,
423
- type AnimationSnapshot,
421
+ animateFromSnapshot,
422
+ captureAnimationSnapshot,
423
+ createReorderableList,
424
+ REORDERABLE_LIST_HANDLE_ATTRIBUTE,
425
+ type AnimationSnapshot,
424
426
  } from '@inertiaui/vanilla'
425
427
 
426
428
  let items = ['Apple', 'Banana', 'Cherry']
427
429
  let animationSnapshot: AnimationSnapshot | null = null
428
430
 
429
431
  const controller = createReorderableList({
430
- getItems: () => items,
431
- setItems: (nextItems) => {
432
- items = nextItems
433
- render()
434
- },
435
- getBounds: () => listElement.getBoundingClientRect(),
436
- autoScroll: true,
437
- onChange: () => render(),
438
- onBeforeReorder: (move, context) => {
439
- if (!context.alreadyPreviewed) {
440
- animationSnapshot = captureAnimationSnapshot(itemElements)
441
- }
442
- },
443
- onReorder: (move) => {
444
- animateFromSnapshot(animationSnapshot, itemElements)
445
- animationSnapshot = null
446
- announce(`Moved ${move.item}`)
447
- },
432
+ getItems: () => items,
433
+ setItems: (nextItems) => {
434
+ items = nextItems
435
+ render()
436
+ },
437
+ getBounds: () => listElement.getBoundingClientRect(),
438
+ autoScroll: true,
439
+ onChange: () => render(),
440
+ onBeforeReorder: (move, context) => {
441
+ if (!context.alreadyPreviewed) {
442
+ animationSnapshot = captureAnimationSnapshot(itemElements)
443
+ }
444
+ },
445
+ onReorder: (move) => {
446
+ animateFromSnapshot(animationSnapshot, itemElements)
447
+ animationSnapshot = null
448
+ announce(`Moved ${move.item}`)
449
+ },
448
450
  })
449
451
 
450
452
  controller.setListElement(listElement)
451
453
 
452
454
  items.forEach((_, index) => {
453
- controller.setItemElement(index, itemElements[index])
454
- handles[index].setAttribute(REORDERABLE_LIST_HANDLE_ATTRIBUTE, 'true')
455
- handles[index].addEventListener('pointerdown', (event) => controller.pointerDown(index, event))
455
+ controller.setItemElement(index, itemElements[index])
456
+ handles[index].setAttribute(REORDERABLE_LIST_HANDLE_ATTRIBUTE, 'true')
457
+ handles[index].addEventListener('pointerdown', (event) => controller.pointerDown(index, event))
456
458
  })
457
459
 
458
460
  moveUpButton.addEventListener('click', () => controller.moveItem(index, 'up'))
459
461
  ```
460
462
 
461
- Use `getPreviewOrder()` or `getPreviewItems()` during pointer dragging when your renderer needs to show the future order before release. The reorder detail includes `alreadyPreviewed`, so consumers can avoid replaying the same release animation when the list already animated into the committed position.
463
+ `getPreviewOrder()` and `getPreviewItems()` return the preview order during a pointer drag. The reorder callbacks receive `context.alreadyPreviewed`, which indicates whether the controller already reported the committed target through `onChange`.
464
+
465
+ #### Pointer activation
466
+
467
+ By default, a press on a handle starts a drag immediately. The controller prevents the browser's default action, attempts pointer capture, and calls `onChange`.
468
+
469
+ `activationDistance` delays the drag until the pointer travels the specified distance in CSS pixels. Below that distance, the press retains native click, focus, and scroll behavior. A release before activation does not call `onChange`.
470
+
471
+ `suppressClickAfterDrag: true` blocks the next click after a drag ends. A new pointer press or key press clears the suppression before that interaction produces a click.
472
+
473
+ The following example combines delayed activation with click suppression:
474
+
475
+ ```typescript
476
+ const controller = createReorderableList({
477
+ getItems: () => columns,
478
+ setItems: (nextColumns) => (columns = nextColumns),
479
+ activationDistance: 4,
480
+ suppressClickAfterDrag: true,
481
+ onChange: (state) => {
482
+ const pointer = controller.getPointer()
483
+
484
+ if (state.draggedIndex !== null && pointer) {
485
+ // Keep the dragged item under the pointer.
486
+ translate(state.draggedIndex, pointer.position.clientX - pointer.origin.clientX)
487
+ }
488
+ },
489
+ })
490
+
491
+ window.addEventListener('keydown', (event) => {
492
+ if (event.key === 'Escape') controller.cancel()
493
+ })
494
+ ```
495
+
496
+ #### Pointer state and cancellation
497
+
498
+ `getPointer()` returns the press origin and the latest pointer position during an active drag. The method returns `null` before activation and while idle. The same object lasts for the drag, but each pointer move replaces its `position` property. A copy of the coordinates preserves an earlier position.
499
+
500
+ `cancel()` ends a pending press or an active drag without committing the move. Window focus loss also cancels the gesture. Cancellation of an active drag calls `onChange` with the idle state. The controller remains available for the next press.
501
+
502
+ `cleanup()` ends the gesture and removes listeners without calling `onChange`. A browser `pointercancel` ends the gesture without suppressing a later click. The canceled pointer does not generate a click.
503
+
504
+ #### Collision points
505
+
506
+ By default, the pointer position determines the insertion index. An item moves past a neighbor when the pointer crosses that neighbor's midpoint.
507
+
508
+ `getCollisionPoint(pointer, item)` supplies a different point for the insertion calculation. `item` contains the dragged item's bounds at drag start. The controller clamps the returned point to the bounding area of the measured items. A `null` result or nonfinite coordinates fall back to the pointer position.
509
+
510
+ The example uses the right edge when the item moves right and the left edge when the item moves left. A wide item can then pass a narrow neighbor before the pointer reaches that neighbor's midpoint:
511
+
512
+ ```ts
513
+ const controller = createReorderableList({
514
+ getItems: () => columns,
515
+ setItems: (next) => (columns = next),
516
+ getCollisionPoint: ({ origin, position }, item) => {
517
+ const offset = position.clientX - origin.clientX
518
+
519
+ return { clientX: (offset > 0 ? item.right : item.left) + offset, clientY: position.clientY }
520
+ },
521
+ })
522
+ ```
523
+
524
+ The last pointer move determines whether release commits the move. A pointer outside the reorder bounds cancels the drop, even if the collision point remains inside.
525
+
526
+ #### Writing direction
462
527
 
463
- #### Reorderable List Options
528
+ At drag start, the controller reads the list element's writing direction. Without a registered list element, the controller reads the first registered item's direction. Horizontal auto-scroll supports right-to-left containers, where the horizontal scroll position starts at zero and decreases as the content scrolls left.
529
+
530
+ #### Reorderable list options
464
531
 
465
532
  | Option | Type | Default | Description |
466
533
  |--------|------|---------|-------------|
467
534
  | `getItems` | `() => readonly T[]` | Required | Current ordered items |
468
535
  | `setItems` | `(items: T[]) => void` | `undefined` | Optional writer used by `moveItem` and pointer commits |
469
536
  | `canReorder` | `() => boolean` | `true` | Guard before starting or committing a reorder |
470
- | `getBounds` | `() => ReorderBounds \| null` | Registered list rect | Optional outer active area |
537
+ | `getBounds` | `() => ReorderBounds \| null` | Registered list bounds | Optional outer active area |
471
538
  | `autoScroll` | `boolean \| AutoScrollerOptions` | `false` | Edge auto-scroll while dragging |
539
+ | `activationDistance` | `number` | `0` | Pointer travel in CSS pixels before a press starts dragging |
540
+ | `suppressClickAfterDrag` | `boolean` | `false` | Whether the controller suppresses the click after a pointer drag |
541
+ | `getCollisionPoint` | `(pointer, item) => ReorderPoint \| null` | Pointer position | Point used to calculate the insertion index during a drag |
472
542
  | `onChange` | `(state) => void` | `undefined` | Called when pointer drag state changes |
473
543
  | `onBeforeReorder` | `(move, context) => void` | `undefined` | Called before writing items or firing `onReorder` |
474
544
  | `onReorder` | `(move, context) => void` | `undefined` | Called after a valid keyboard or pointer reorder |
475
545
 
546
+ #### Reorderable list controller
547
+
548
+ | Method | Description |
549
+ |--------|-------------|
550
+ | `setListElement(element)` | Sets the element used for default bounds and writing direction |
551
+ | `setItemElement(index, element)` | Registers an item element by index, or unregisters it when `element` is `null` or `undefined` |
552
+ | `getItemElements()` | Returns registered item elements in index order |
553
+ | `getPreviewOrder()` | Returns item indices in preview order |
554
+ | `getPreviewItems()` | Returns items with their source and visual indices in preview order |
555
+ | `moveItem(index, direction)` | Commits an `'up'` or `'down'` keyboard reorder |
556
+ | `pointerDown(index, event)` | Starts a pending press or an active drag from a handle's `pointerdown` event |
557
+ | `getPointer()` | Returns the origin and the latest position of an active drag, or `null` |
558
+ | `cancel()` | Ends a pending press or an active drag without committing the move |
559
+ | `cleanup()` | Ends pointer work and removes listeners without calling `onChange` |
560
+
561
+ ### getReorderOffsets
562
+
563
+ `getReorderOffsets(rects, order, options?)` returns each item's offset along the layout axis after a reorder. `rects` contains item bounds in source order. `order` contains source indices in the new order. The returned offsets use source order.
564
+
565
+ The following example applies vertical offsets to preview an order:
566
+
567
+ ```ts
568
+ import { getReorderOffsets } from '@inertiaui/vanilla'
569
+
570
+ const rects = items.map((item) => item.getBoundingClientRect())
571
+ const offsets = getReorderOffsets(rects, [2, 0, 1])
572
+
573
+ items.forEach((item, index) => (item.style.transform = `translateY(${offsets[index]}px)`))
574
+ ```
575
+
576
+ `getReorderOffsets` supports one row or one column with items of different sizes. It does not support layouts that wrap onto several rows. Each measured gap remains between the same layout positions after a reorder.
577
+
578
+ The `gap` option replaces the measured gaps in both the source and destination layouts. An explicit gap accounts for boxes displaced by sticky positioning. With `gap: 0`, the calculation places items edge to edge.
579
+
580
+ The function returns zero offsets when `order` is unchanged or is not a permutation of the source indices.
581
+
582
+ | Option | Type | Default | Description |
583
+ |--------|------|---------|-------------|
584
+ | `axis` | `'x' \| 'y'` | `'y'` | Axis the items are laid out along |
585
+ | `reverse` | `boolean` | `false` | The items run toward the start of the axis, as in a right-to-left row |
586
+ | `gap` | `number` | Measured | Space between neighboring items |
587
+
588
+ ### getScrollableAncestors
589
+
590
+ `getScrollableAncestors(element, axis?)` returns scrollable ancestors, nearest first, followed by the element's window. The traversal follows assigned slots and crosses shadow roots through their hosts. `axis` defaults to `'both'`. A value of `'x'` or `'y'` restricts the ancestors to those that scroll along that axis. The window remains the last entry.
591
+
592
+ The following example caches horizontal scroll containers until the drag ends:
593
+
594
+ ```ts
595
+ import { createReorderableList, getScrollableAncestors, type AutoScrollContainer } from '@inertiaui/vanilla'
596
+
597
+ let containers: AutoScrollContainer[] | null = null
598
+
599
+ const controller = createReorderableList({
600
+ getItems: () => columns,
601
+ autoScroll: { axis: 'x', getScrollContainers: () => (containers ??= getScrollableAncestors(row, 'x')) },
602
+ onChange: (state) => state.draggedIndex === null && (containers = null),
603
+ })
604
+ ```
605
+
606
+ With auto-scroll enabled and no `getScrollContainers` callback, the controller discovers scrollable ancestors along both axes on each pointer move.
607
+
476
608
  ## Positioning
477
609
 
478
610
  Utilities for positioning floating elements (dropdowns, tooltips, popovers) relative to a reference element. Uses [CSS Anchor Positioning](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_anchor_positioning) when supported, with an automatic JavaScript fallback.
@@ -514,6 +646,7 @@ The function applies positioning styles to the floating element automatically (`
514
646
  | `offset` | `number` | `0` | Distance in pixels between reference and floating element |
515
647
  | `flip` | `boolean` | `true` | Flip to opposite side when overflowing viewport |
516
648
  | `autoSize` | `boolean` | `false` | Constrain the floating element to the available viewport space (sets `max-height` and `overflow-y: auto`) |
649
+ | `anchorPositioning` | `boolean` | `true` | Use CSS anchors when supported. Set to `false` to use numeric positioning. |
517
650
 
518
651
  #### Placements
519
652
 
@@ -823,6 +956,8 @@ popover.addEventListener('focusout', (event) => {
823
956
 
824
957
  `createTooltipController(options)` coordinates hover and focus intent, delayed opening, positioning, Escape dismissal, and cleanup. It never moves focus. It keeps a tooltip open while either pointer or keyboard focus remains in its trigger, and ignores completion of an obsolete closing transition.
825
958
 
959
+ The default `position` is `{ placement: 'top', offset: 6, anchorPositioning: false }`. Tooltips use numeric positioning unless `position.anchorPositioning` is `true` and the browser supports CSS anchors.
960
+
826
961
  ```ts
827
962
  import { createTooltipController } from '@inertiaui/vanilla'
828
963
 
@@ -867,6 +1002,25 @@ Use `<dialog>` when `native` is true. Otherwise render a container with `role="d
867
1002
 
868
1003
  `transition(visible)` and `onMount({ dialog, panel, native })` follow the same transition/cleanup contract as tooltips. Reopening during a closing transition keeps the dialog open. Call `cleanup()` before removing DOM or disposing the owner. It releases mounted behavior without changing logical `isOpen`, allowing framework effect replay. Call `close()` for an actual state change.
869
1004
 
1005
+ ## Inline styles
1006
+
1007
+ `captureInlineStyles(element, properties)` records the inline values and `!important` priorities of the specified CSS properties. Property names use CSS syntax, such as `z-index`.
1008
+
1009
+ `restore()` restores all captured properties. `restore(properties)` restores only the captured properties in that list. Both methods leave other properties unchanged. If a captured property had no inline value, `restore` removes the property.
1010
+
1011
+ The following example restores `transform` before it restores the other captured properties:
1012
+
1013
+ ```ts
1014
+ import { captureInlineStyles } from '@inertiaui/vanilla'
1015
+
1016
+ const styles = captureInlineStyles(row, ['transform', 'z-index'])
1017
+ row.style.zIndex = '10'
1018
+ row.style.transform = 'translateY(40px)'
1019
+
1020
+ styles.restore(['transform'])
1021
+ styles.restore()
1022
+ ```
1023
+
870
1024
  ## CSS Variable Inheritance
871
1025
 
872
1026
  `inheritCssVariables(source, target, { filter, mediaQueries })` copies selected computed custom properties to a portal and returns a cleanup function. It watches ancestor class/style changes and the supplied media queries. Cleanup restores prior inline values and priorities when its own value is still present; consumer value overrides are preserved.
@@ -884,7 +1038,7 @@ The helper is intentionally scoped to caller-selected variables. It does not obs
884
1038
 
885
1039
  ## Accessibility
886
1040
 
887
- Accessibility utilities for managing `aria-hidden` attributes with reference counting support.
1041
+ Accessibility utilities for managing `aria-hidden` attributes with reference counting support, and for announcing messages to screen readers.
888
1042
 
889
1043
  ### markAriaHidden
890
1044
 
@@ -993,6 +1147,39 @@ function openDialog(dialogElement: HTMLElement) {
993
1147
  }
994
1148
  ```
995
1149
 
1150
+ ### createAnnouncer
1151
+
1152
+ Announces messages to screen readers through two live regions that you render: one polite and one assertive. Render both regions when the page loads and keep them in the DOM. A screen reader ignores text that a new live region contains when it appears.
1153
+
1154
+ ```html
1155
+ <div class="sr-only" role="status" aria-live="polite" aria-atomic="true"></div>
1156
+ <div class="sr-only" aria-live="assertive" aria-atomic="true"></div>
1157
+ ```
1158
+
1159
+ ```typescript
1160
+ import { createAnnouncer } from '@inertiaui/vanilla'
1161
+
1162
+ const announcer = createAnnouncer({
1163
+ polite: document.querySelector('[aria-live="polite"]')!,
1164
+ assertive: document.querySelector('[aria-live="assertive"]')!,
1165
+ })
1166
+
1167
+ announcer.announce('Invoice saved.', 'polite')
1168
+ announcer.announce('Payment failed.', 'assertive')
1169
+
1170
+ // When the regions unmount
1171
+ announcer.destroy()
1172
+ ```
1173
+
1174
+ The announcer writes only plain text to the regions, so a screen reader does not read buttons or other markup with the message. It also handles the timing that screen readers need:
1175
+
1176
+ - It writes nothing until 150ms after you create it, so the regions exist before their first text arrives.
1177
+ - It joins messages that arrive within 50ms into one announcement for each region.
1178
+ - It empties a region 1 second after its last write, so the virtual cursor does not find old messages.
1179
+ - It empties a region before it writes the same text again, so a repeated message is announced again.
1180
+
1181
+ `destroy()` cancels pending writes and clearing timers, and ignores future announcements. It does not empty the regions.
1182
+
996
1183
  ## Animation
997
1184
 
998
1185
  The animation module provides a simple wrapper around the Web Animations API with Tailwind CSS-compatible easing functions.
@@ -1097,6 +1284,42 @@ if (!prefersReducedMotion() && supportsWebAnimations()) {
1097
1284
  }
1098
1285
  ```
1099
1286
 
1287
+ ### createLayoutAnimation
1288
+
1289
+ `createLayoutAnimation(options?)` schedules animations from a layout snapshot and tracks scheduled and active animations. The snapshot contains element bounds before a layout change. `getElements` returns the elements after the renderer applies that change.
1290
+
1291
+ The following example animates a reordered list and restores the moved row's `z-index` when the animations settle:
1292
+
1293
+ ```typescript
1294
+ import { captureAnimationSnapshot, captureInlineStyles, createLayoutAnimation } from '@inertiaui/vanilla'
1295
+
1296
+ const layout = createLayoutAnimation({ duration: 160, easing: 'cubic-bezier(0.22, 1, 0.36, 1)', fill: 'none' })
1297
+
1298
+ const snapshot = captureAnimationSnapshot(rows())
1299
+ const styles = captureInlineStyles(movedRow, ['z-index'])
1300
+ movedRow.style.zIndex = '10'
1301
+ renderItemsInNewOrder()
1302
+
1303
+ layout.animate(snapshot, rows, {
1304
+ onStart: () => movedRow.focus({ preventScroll: true }),
1305
+ onSettle: () => styles.restore(),
1306
+ })
1307
+ ```
1308
+
1309
+ Animations start on the next animation frame by default. The `schedule` option replaces that scheduler. The callback receives a `run` function to call after the renderer updates the layout. `schedule` can return a function that cancels the scheduled call. For Vue, `schedule: (run) => void nextTick(run)` starts the animation after the next DOM update.
1310
+
1311
+ `onStart(animations)` runs immediately after the animations start. `onSettle()` runs asynchronously after all animations from that call finish or are canceled. Cancellation includes both `cancel()` and a later animation that replaces an animation on the same element.
1312
+
1313
+ When no elements animate, `onStart` receives an empty array and `onSettle` still runs asynchronously. For example, no elements animate when the user prefers reduced motion. If `cancel()` stops a scheduled call before it starts, neither callback runs. `cleanup()` prevents later callbacks.
1314
+
1315
+ | Method | Description |
1316
+ |--------|-------------|
1317
+ | `animate(snapshot, getElements, callbacks?)` | Schedules animations from the snapshot to the new layout |
1318
+ | `cancel()` | Cancels scheduled calls and active animations. Active animations still invoke `onSettle` |
1319
+ | `cleanup()` | Cancels all work, prevents callbacks, and ignores later `animate()` calls |
1320
+
1321
+ The options are those of [`animateFromSnapshot`](#captureanimationsnapshot-and-animatefromsnapshot), plus `schedule`.
1322
+
1100
1323
  ### cancelAnimations
1101
1324
 
1102
1325
  Cancel any running animations on an element:
@@ -1170,7 +1393,7 @@ prefersDarkMode(() => document.body.dataset.theme === 'dark')
1170
1393
 
1171
1394
  ## RTL Support
1172
1395
 
1173
- Utilities for detecting and observing right-to-left document direction.
1396
+ Utilities for detecting and observing right-to-left direction, for the document and for single elements.
1174
1397
 
1175
1398
  ### isRtl
1176
1399
 
@@ -1199,6 +1422,30 @@ const cleanup = onRtlChange((rtl) => {
1199
1422
  cleanup()
1200
1423
  ```
1201
1424
 
1425
+ ### isRightToLeft
1426
+
1427
+ Check whether an element is written right to left, from its computed `direction`. Unlike `isRtl()`, it follows a `dir` attribute on any ancestor, such as a right-to-left section in a left-to-right page.
1428
+
1429
+ ```typescript
1430
+ import { isRightToLeft } from '@inertiaui/vanilla'
1431
+
1432
+ const forward = isRightToLeft(list) ? 'ArrowLeft' : 'ArrowRight'
1433
+ ```
1434
+
1435
+ ### followReferenceDirection
1436
+
1437
+ Give a panel that renders away from its reference, such as in `document.body`, the direction of the reference. A panel that has its own `dir` attribute keeps it. Returns a cleanup function that removes the direction again.
1438
+
1439
+ ```typescript
1440
+ import { followReferenceDirection } from '@inertiaui/vanilla'
1441
+
1442
+ document.body.append(panel)
1443
+ const cleanup = followReferenceDirection(trigger, panel)
1444
+
1445
+ // When the panel closes
1446
+ cleanup()
1447
+ ```
1448
+
1202
1449
  ## Debounce
1203
1450
 
1204
1451
  ### debounce
@@ -1618,6 +1865,26 @@ for (const [key, value] of Object.entries(props)) {
1618
1865
  // customEvents: { onModalReady, onUserUpdated }
1619
1866
  ```
1620
1867
 
1868
+ #### replacePlaceholders
1869
+
1870
+ Replaces placeholders in the format of Laravel translation strings, such as `:name`, with values.
1871
+
1872
+ ```typescript
1873
+ import { replacePlaceholders } from '@inertiaui/vanilla'
1874
+
1875
+ replacePlaceholders('Hello, :name!', { name: 'Taylor' }) // 'Hello, Taylor!'
1876
+ replacePlaceholders(':count unread', { count: 3 }) // '3 unread'
1877
+ replacePlaceholders('Show :names to :name', { name: 'Taylor', names: 'Jess, Nuno' })
1878
+ // 'Show Jess, Nuno to Taylor'
1879
+ ```
1880
+
1881
+ The replacement follows these rules:
1882
+
1883
+ - A longer key wins over a shorter key that starts it, whatever order the keys have.
1884
+ - A placeholder ends at a character that is not a letter, digit, combining mark, or underscore. `:named` is not `:name` followed by `d`.
1885
+ - A placeholder without a value stays in the string.
1886
+ - The values are written as they are. A value that contains `:count` does not get a count.
1887
+
1621
1888
  ### URL Utilities
1622
1889
 
1623
1890
  #### sameUrlPath
@@ -1710,6 +1977,8 @@ This library is written in TypeScript and exports the following types:
1710
1977
  ```typescript
1711
1978
  import type {
1712
1979
  AnimateOptions,
1980
+ Announcer,
1981
+ AnnouncerPoliteness,
1713
1982
  AutoScrollAxis,
1714
1983
  AutoScrollContainer,
1715
1984
  AutoScrollerOptions,
@@ -1743,6 +2012,8 @@ import type {
1743
2012
  ReorderCommitContext,
1744
2013
  ReorderDirection,
1745
2014
  ReorderMove,
2015
+ ReorderPoint,
2016
+ ReorderPointer,
1746
2017
  ReorderPreviewItem,
1747
2018
  ReorderableListController,
1748
2019
  ReorderableListOptions,