@rcarls/rc-common 0.6.0 → 0.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +295 -0
  2. package/README.md +148 -72
  3. package/dist/modules/ActiveDescendantController.js +89 -0
  4. package/dist/modules/AnchorController.js +317 -0
  5. package/dist/modules/ControllerEffects.js +60 -0
  6. package/dist/modules/DragController.js +128 -0
  7. package/dist/modules/DragGestureController.js +174 -0
  8. package/dist/modules/FlowController.js +35 -0
  9. package/dist/modules/ItemsCollectionController.js +233 -0
  10. package/dist/modules/KeyboardInteractionDirective.js +39 -0
  11. package/dist/modules/KeyboardNavigationDirective.js +88 -0
  12. package/dist/modules/LiveAnnouncer.js +36 -0
  13. package/dist/modules/MutationObserverController.js +30 -0
  14. package/dist/modules/NavigationIndicatorController.js +81 -0
  15. package/dist/modules/PopoverController.js +44 -0
  16. package/dist/modules/RafScheduler.js +83 -0
  17. package/dist/modules/ReorderController.js +361 -0
  18. package/dist/modules/ResizeController.js +425 -0
  19. package/dist/modules/RovingTabIndexMixin.js +87 -0
  20. package/dist/modules/ScrollObserverController.js +78 -0
  21. package/dist/modules/TypeaheadController.js +59 -0
  22. package/dist/modules/anchorPlacement.js +13 -0
  23. package/dist/modules/clickDelegate.js +31 -0
  24. package/dist/modules/cssText.js +6 -0
  25. package/dist/modules/cssTime.js +11 -0
  26. package/dist/modules/cssZoom.js +16 -0
  27. package/dist/modules/findNearestScrollAncestor.js +22 -0
  28. package/dist/modules/flow.js +94 -0
  29. package/dist/modules/isFocusable.js +6 -0
  30. package/dist/modules/localeFormat.js +38 -0
  31. package/dist/modules/messages.js +77 -0
  32. package/dist/modules/nativeChild.js +37 -0
  33. package/dist/modules/observeLocale.js +70 -0
  34. package/dist/modules/sliderUtils.js +14 -0
  35. package/dist/modules/snapUtils.js +25 -0
  36. package/dist/modules/softKeyboard.js +72 -0
  37. package/dist/modules/visualViewport.js +14 -0
  38. package/dist/rc-common.js +99 -1711
  39. package/dist/rc-common.umd.cjs +10 -26
  40. package/dist/types/AnchorController.d.ts +45 -22
  41. package/dist/types/ControllerEffects.d.ts +15 -0
  42. package/dist/types/DragController.d.ts +13 -0
  43. package/dist/types/DragGestureController.d.ts +31 -7
  44. package/dist/types/FlowController.d.ts +31 -0
  45. package/dist/types/ItemsCollectionController.d.ts +3 -2
  46. package/dist/types/KeyboardInteractionDirective.d.ts +1 -2
  47. package/dist/types/KeyboardNavigationDirective.d.ts +16 -7
  48. package/dist/types/LiveAnnouncer.d.ts +22 -0
  49. package/dist/types/MutationObserverController.d.ts +0 -1
  50. package/dist/types/NavigationIndicatorController.d.ts +1 -1
  51. package/dist/types/PopoverController.d.ts +21 -0
  52. package/dist/types/RafScheduler.d.ts +36 -1
  53. package/dist/types/ReorderController.d.ts +131 -0
  54. package/dist/types/ResizeController.d.ts +46 -0
  55. package/dist/types/ScrollObserverController.d.ts +13 -2
  56. package/dist/types/TypeaheadController.d.ts +8 -2
  57. package/dist/types/anchorPlacement.d.ts +24 -0
  58. package/dist/types/clickDelegate.d.ts +9 -56
  59. package/dist/types/cssText.d.ts +17 -0
  60. package/dist/types/cssTime.d.ts +14 -0
  61. package/dist/types/cssZoom.d.ts +12 -0
  62. package/dist/types/findNearestScrollAncestor.d.ts +3 -3
  63. package/dist/types/flow.d.ts +121 -0
  64. package/dist/types/index.d.ts +13 -1
  65. package/dist/types/localeFormat.d.ts +4 -0
  66. package/dist/types/messages.d.ts +105 -0
  67. package/dist/types/nativeChild.d.ts +0 -3
  68. package/dist/types/observeLocale.d.ts +23 -0
  69. package/dist/types/softKeyboard.d.ts +79 -0
  70. package/dist/types/visualViewport.d.ts +21 -0
  71. package/package.json +1 -4
  72. package/dist/css-anchor-positioning-fn-hFYJeBk4.js +0 -6371
  73. package/dist/types/MouseMoveDirective.d.ts +0 -42
package/CHANGELOG.md CHANGED
@@ -1,5 +1,300 @@
1
1
  # @rcarls/rc-common
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9ee769c: Anchor popups in logical terms only. A placement is now `block-start`,
8
+ `block-end`, `inline-start`, or `inline-end`, each with an optional
9
+ `-start`/`-end` edge alignment, and all of them follow the writing mode and
10
+ direction. Block sides open above or below a row in horizontal text and
11
+ beside it in vertical text; inline sides open along the reading direction,
12
+ so `inline-end` opens to the left in RTL. `resolveAnchorPlacement` exposes
13
+ the resolution for other consumers.
14
+
15
+ **Breaking:** the physical placements `top*`, `bottom*`, `left*`, and
16
+ `right*` are removed from `AnchorPlacement`, `rc-menu-button`'s and
17
+ `rc-fab-menu`'s `placement`, and the React and Solid typings. Migrate:
18
+
19
+ - `bottom*` → `block-end*`
20
+ - `top*` → `block-start*`
21
+ - `right*` → `inline-end*` (in LTR)
22
+ - `left*` → `inline-start*` (in LTR)
23
+
24
+ Defaults move with them and render the same in horizontal LTR text:
25
+ `rc-menu-button`, `rc-select`, and `rc-combobox` open at `block-end-start`,
26
+ `rc-adaptive-menu`'s overflow menu at `block-end-end`, and `rc-fab-menu` at
27
+ `block-start-end`. In vertical text these popups now open beside their
28
+ trigger instead of over the next item. Vertical menubars and vertical
29
+ adaptive menus open submenus at `inline-end-start`. Open popups also
30
+ re-resolve their physical side and alignment when an ancestor's `dir`
31
+ changes, and `rc-fab-menu` keeps its corner-aware default even when nested in
32
+ a vertical menubar.
33
+
34
+ - 595fe37: `rc-combobox` now falls back to text registered under `rc-select`, below
35
+ its own `rc-combobox` text, so an app no longer registers the shared keys
36
+ twice. `resolveMessages()` and `MessagesController` take an `inherit` scope
37
+ for the same layering in other components: within each locale the
38
+ component's own scope wins, a more specific locale wins over its base
39
+ language, and only keys the component has defaults for are taken.
40
+ - 5c006de: Ship component CSS minified. Package builds now run the CSS in Lit `css` styles
41
+ and light-DOM structural styles through Lightning CSS, removing comments and
42
+ whitespace while keeping source maps that resolve to each template. Rendered
43
+ styles are unchanged.
44
+
45
+ `@rcarls/rc-common` adds `cssText`, an identity tag that marks a plain CSS
46
+ string for minification. `rc-chip`, `rc-disclosure`, and `rc-accordion` now
47
+ depend on `@rcarls/rc-common` for it.
48
+
49
+ - a6553ff: Batch layout sampling into a shared animation-frame read phase so mounting a
50
+ large component route no longer alternates forced layout reads with component
51
+ writes. Closed anchored popups now skip placement work until they open, while
52
+ scroller boundaries, carousel positioning, flow state, and opted-in initial
53
+ scroll observation settle before the next paint.
54
+
55
+ Add `RafScheduler.schedulePhased()`, live `AnchorController.disabled` getters,
56
+ and the `ScrollObserverController.initialEvaluation` timing option.
57
+
58
+ - 2205478: Keep a fullscreen `rc-dialog` from shrinking for a moment when a software
59
+ keyboard closes. Firefox for Android reports a viewport shorter than the
60
+ keyboard-open one for a few frames on the way back to full height; while the
61
+ keyboard closes, the surface now takes only growth until the full height
62
+ returns, a text field takes focus again, the width changes, or a one-second
63
+ backstop passes.
64
+
65
+ `rc-common` adds `SoftKeyboardViewport`, which applies that filtering to any
66
+ viewport measurement and can instead hold the keyboard-free height for window
67
+ size classes, along with the `deepActiveElement`, `isTextEntryElement`, and
68
+ `isTextEntryFocused` helpers it uses.
69
+
70
+ - 4341311: Add reusable fullscreen dialogs and declarative dialog popup mode to `rc-select` and
71
+ `rc-combobox`. Dialog selection and creation are staged until Done, while close and Escape
72
+ discard the draft. Fullscreen surfaces follow the visual viewport under browser zoom and
73
+ software keyboards, and anchored popups now clamp to the visual viewport.
74
+ - 51f6403: Arrow keys follow the reading direction everywhere. `keyNavigation` now also
75
+ flips the cross axis in RTL, so a vertical menu opens its submenu with
76
+ ArrowLeft, as the APG describes. A horizontal menubar and segmented button
77
+ advance with ArrowLeft in RTL, Alt+ArrowLeft moves items toward the selected
78
+ list of a transfer list in RTL, and the arrow toward the inline start reaches
79
+ the chips of a multiple select or combobox (ArrowRight in RTL).
80
+
81
+ Add `inlineArrowKeys(flow)` for content that runs along the inline axis, such
82
+ as chips or text.
83
+
84
+ - 9caca6b: Add `layoutOrientation(rendered, flow)`, the inverse of
85
+ `renderedOrientation`, for code that can only read `aria-orientation` and
86
+ needs the layout behind it.
87
+ - b764a3c: Observe interface locale changes through containing shadow roots and the host's own document.
88
+ An explicit empty `lang` now means an unknown locale rather than falling back to `<html lang>`.
89
+ Typeahead compares complete grapheme prefixes, including decomposed accents and collation
90
+ expansions. Default interpolating messages format numeric positions in the interface locale
91
+ while translation callbacks continue to receive numbers and can accept an optional locale.
92
+ Default messages isolate consumer text whose direction is unknown. Textarea content direction
93
+ uses the native LTR fallback for neutral `dir="auto"` content, recognizes Arabic Letter Mark and
94
+ isolate controls, and reruns plugins when the native textarea's `lang` or `dir` changes.
95
+ - 54d9ead: Localize every component's built-in text. Button names, role
96
+ descriptions, announcements, and default labels now resolve per key from
97
+ the element's `messages` property, then from text registered with
98
+ `registerMessages(locale, catalog)` in `@rcarls/rc-common`, then from the
99
+ English defaults. The locale is the element's own `lang`, else
100
+ `<html lang>`; an ancestor's `lang` is ignored, because it usually marks
101
+ content rather than the interface. Components re-render when that locale
102
+ changes or new text is registered. `RcMessageCatalog` types the catalog,
103
+ and each package adds its scope to it.
104
+
105
+ Numbers a component formats as text follow the same locale:
106
+ `rc-progress`'s default percentage and `rc-splitter`'s `aria-valuetext`
107
+ use `Intl.NumberFormat`. `TypeaheadController` matches prefixes with an
108
+ `Intl.Collator`, so case and accents are ignored the way the locale
109
+ ignores them, and takes a `locale` option. `ItemsCollectionController`'s
110
+ `setCreateOption(text, label?)` takes the option's visible text from its
111
+ caller.
112
+
113
+ `rc-transfer-list`'s direction arrows are now decorative: screen readers
114
+ read only the action name, and the arrows turn over in RTL.
115
+
116
+ **Breaking:** chrome-text properties are replaced by `messages`. Migrate:
117
+
118
+ - `rc-search-bar` `clear-label` / `clearLabel` → `messages.clear`
119
+ - `rc-adaptive-menu` `overflow-label` / `overflowLabel` → `messages.overflow`
120
+ - `rc-chip-group` `show-all-label` / `showAllLabel` and `show-less-label` /
121
+ `showLessLabel` → `messages.showAll` and `messages.showLess`
122
+ - `rc-select` and `rc-combobox` `dialog-confirm-label` /
123
+ `dialogConfirmLabel` and `dialog-cancel-label` / `dialogCancelLabel` →
124
+ `messages.done` and `messages.cancel`
125
+ - `rc-editor-toolbar` `label` → `messages.toolbar`
126
+
127
+ Per-instance names stay attributes, but now default to `undefined` and fall
128
+ back to a message: `label` on `rc-adaptive-menu`, `rc-chip-group`,
129
+ `rc-menubar`, and `rc-splitter`; `available-label` and `selected-label`
130
+ on `rc-transfer-list`; `low-label` and `high-label` on `rc-range-slider`.
131
+ Read the resolved name from the rendered `aria-label` instead of the
132
+ property.
133
+
134
+ - b9175e9: Position the navigation indicator in logical coordinates, so it lands on the
135
+ current link in RTL and in vertical writing modes instead of mirroring to
136
+ the opposite side or swapping its width and height.
137
+
138
+ Add `physicalOffset`, the inverse of `logicalRect`: it turns a logical
139
+ offset from the start corner into the physical `translate` an element
140
+ anchored at `inset-inline-start`/`inset-block-start` needs.
141
+
142
+ - 55e1e7f: Add `observeLocale(listener, host?)`, shared observers that report a `dir` or
143
+ `lang` attribute change in the host's document and containing shadow roots,
144
+ since the platform fires no event for either. `FlowController` and `NavigationIndicatorController`
145
+ follow it, so the navigation bar and rail indicator stay on the current
146
+ link when a page switches direction at runtime, and localized component
147
+ text re-renders when a page switches language.
148
+ - f1ca82d: Add an anchored, non-modal popover package with a Material rich-tooltip recipe. Share native Popover API visibility and fallback behavior across existing popup components.
149
+ - b87f27b: Remove exports that no component uses.
150
+
151
+ Breaking changes and migration:
152
+
153
+ - `mouseMove` and `MouseMoveDirective` are removed. Use
154
+ `DragGestureController`, which captures the pointer and reports deltas.
155
+ - `delegateClickTo`, `isEventFromInteractiveDescendant`, and
156
+ `DEFAULT_INTERACTIVE_SELECTOR` are removed. Use `ClickDelegateController`,
157
+ which now takes the `interactiveSelector` option directly. The
158
+ `DelegateClickOptions` and `InteractiveDescendantOptions` types are removed
159
+ with them.
160
+ - `getDirectChild(host, selector)` is removed. Use
161
+ `host.querySelector(selector)`.
162
+ - `resolveAnchorPlacement`, `PhysicalAnchorPlacement`, `isTextEntryElement`,
163
+ and `POPOVER_FALLBACK_OPEN` are no longer exported. They remain internal to
164
+ `AnchorController`, `SoftKeyboardViewport`, and `PopoverController`.
165
+ - Modules no longer carry default exports, which the package entry never
166
+ re-exported.
167
+
168
+ - 32ebead: Add writing-mode and direction aware geometry helpers.
169
+
170
+ `resolveFlow(el)` reads an element's computed `writing-mode` and `direction`
171
+ and reports which physical axis the inline and block axes run along, and on
172
+ which side each starts. The other helpers translate through it:
173
+ `getScrollOffset`/`setScrollOffset` measure scroll distance from the logical
174
+ start (absorbing the negative `scrollLeft` of RTL and `vertical-rl` scroll
175
+ containers), `clientSize`/`scrollSize` read sizes along a logical axis,
176
+ `logicalRect` expresses a rect as logical offsets from its container,
177
+ `logicalDelta` projects a pointer delta onto a logical axis, and
178
+ `arrowKeys(orientation, flow)` maps an ARIA orientation to its next,
179
+ previous, and cross-axis arrow keys, flipped for RTL.
180
+
181
+ Components use these instead of comparing `direction` by hand, so RTL and
182
+ vertical writing modes are handled the same way everywhere.
183
+
184
+ - c130173: Add pointer and keyboard reordering to `rc-list`.
185
+
186
+ Set `reorderable` and give each item a native `<button data-rc-reorder-handle>`. People can drag
187
+ a handle, and the items it passes shift out of the way while the nearest scroll container
188
+ scrolls near its edges. On touch and pen, a long press on an item also starts a drag, while
189
+ movement before activation remains available for scrolling. Or they can focus a handle and use
190
+ Space, the block-axis arrow keys, Home, End, and Escape. Each step is announced, focus stays on
191
+ the moved item's handle, and geometry and keys follow the writing mode. `reorderable` implies
192
+ `ordered`.
193
+
194
+ Each committed move fires a cancelable `rc-list-reorder` event with `{ item, from, to }`. Left
195
+ alone, the list moves the node itself; a framework that renders the items cancels the event and
196
+ reorders its own data. `reorderMessages` overrides the announcements and the handle hint.
197
+
198
+ `rc-common` gains the `ReorderController` behind it and a `LiveAnnouncer` live-region helper.
199
+ `rc-theme-material` styles the lifted item with the dragged elevation, surface, and state layer,
200
+ animates the shifting items with standard motion, and presents plain handles as standard icon
201
+ buttons.
202
+
203
+ - 11680b6: Expose and navigate the orientation a widget actually renders in. An
204
+ `orientation` attribute names a layout: `horizontal` runs along the inline
205
+ axis and `vertical` along the block axis, so both turn over in vertical
206
+ writing modes, the way a native `<input type="range">` does. Toolbar,
207
+ menubar, and adaptive menu now report the rendered orientation as
208
+ `aria-orientation`, and their arrow keys follow it, so a horizontal toolbar
209
+ in vertical text navigates with ArrowDown.
210
+
211
+ `keyNavigation` treats an explicit `navigationAxis` and role defaults as
212
+ layout orientations and converts them the same way; an explicit
213
+ `aria-orientation` attribute is still used as is. Add `renderedOrientation`
214
+ and a `FlowController` that keeps a host's writing mode and direction current
215
+ for rendering.
216
+
217
+ `rc-toolbar` now reflects `orientation` to its host attribute, and its
218
+ vertical layout is keyed off that attribute rather than `aria-orientation`.
219
+
220
+ ### Patch Changes
221
+
222
+ - e3dfa59: Convert anchor fallback positions, popup measurements, and viewport spacing
223
+ between viewport and local CSS pixels under zoom.
224
+ - 50d5610: Stop anchor-positioned popups from polling layout on every animation frame while idle. Geometry
225
+ is now checked during a bounded settling window and restarted by resize, scroll, visibility, or
226
+ relevant element changes.
227
+ - 1179f24: Drop the `@oddbird/css-anchor-positioning` polyfill. Browsers without full
228
+ native anchor positioning now use `AnchorController`'s script positioning,
229
+ which applies the same placement and flip rules and re-positions when the page
230
+ scrolls or the viewport, anchor, or floating element resizes. Those browsers no
231
+ longer download the 41 kB polyfill the first time a popup opens.
232
+ - 38cd00c: Convert viewport measurements to local CSS pixels when reordering items,
233
+ positioning navigation indicators, and clamping anchored popups under CSS zoom.
234
+ Reorder previews now account for the scroll container's zoom, while anchor
235
+ corrections settle without repeated overshoot.
236
+ - 899bb5e: Make `rc-dialog` move and resize options reactive. Toggling `movable`,
237
+ changing `resize`, or changing any other `move-*` or `resize-*` option after
238
+ setup now rebuilds that behavior, so `resize="none"` turns resizing off on a
239
+ mounted `rc-dialog` or `rc-bottom-sheet` and a later value turns it back on.
240
+ Re-wiring the inner `<dialog>` no longer leaves stale move or resize
241
+ controllers attached. `DragController`, `ResizeController`, and
242
+ `DragGestureController` gain `dispose()`. Detaching a handle restores its
243
+ focusability and inline resize styles when they still have controller-written
244
+ values, while preserving later author edits. Active gestures cancel
245
+ and release pointer capture when their controller is removed. `rc-fab` uses
246
+ the new `ScrollObserverController.dispose()` for its optional scroll fallback.
247
+ - 25fcfe0: Dialogs, sheets, and their drag and resize gestures now keep their geometry under an
248
+ ancestor's CSS `zoom`, such as an app-wide interface size set on the root. Measured boxes and
249
+ pointer positions are viewport pixels, while a length written to an element's style is zoomed
250
+ again, so a full-screen dialog fell short of or overflowed the viewport, a dragged bottom sheet
251
+ lifted off its docked edge, and each snap shrank or grew the sheet. Positions and sizes are now
252
+ converted to the element's own pixels through a new `cssZoom()` helper in `@rcarls/rc-common`.
253
+ `rc-bottom-sheet-snap` reports `height` in the sheet's own pixels, the unit of its snap points.
254
+ - c8b762b: `observeLocale(listener, host)` notifies only for a `dir` or `lang` change on the host, one of its
255
+ ancestors across shadow roots, or inside its subtree. A `lang` on unrelated content no longer
256
+ makes every component on the page re-read its writing direction, a forced layout each, including
257
+ components inside a `content-visibility: hidden` subtree. An optional `scope` names extra elements
258
+ whose locale matters; `AnchorController` passes the popup and its anchor. Subscribers without a host
259
+ still hear every change. Scoped anchors inside shadow roots are observed as well.
260
+ - bfefedd: Ship the ES module build as one file per source module behind the same
261
+ `rc-common.js` entry, so application bundlers can place shared code in lazily
262
+ loaded chunks instead of keeping every used export in the initial load. The
263
+ package exports and the UMD build are unchanged.
264
+ - 223d36c: Put the default resize grip at the target's end corner, where browsers put
265
+ the native resize grip: bottom-right in LTR, bottom-left in RTL and in
266
+ `vertical-rl`. Keyboard resizing and the grip cursor act on the same corner,
267
+ so ArrowLeft widens a box from its left edge in RTL. An explicit `origin`
268
+ still selects the edge as before.
269
+ - 7b91a44: Keep `ResizeController`'s resize grip at the end corner after the page
270
+ direction changes at runtime, and re-derive an author handle's resize
271
+ cursor too. A writing-mode change is picked up the next time a pointer
272
+ enters the element or the grip takes focus, since no event reports it.
273
+ - aa04ead: Preserve an element's rendered position when pinning its box inside a scrolled,
274
+ zoomed containing block. Scroll offsets and border widths are already local CSS
275
+ pixels, so only viewport measurements need zoom conversion.
276
+ On browsers without `currentCSSZoom`, derive the effective zoom from computed
277
+ styles so resize and placement stay aligned.
278
+ - ac65b5b: A pointer resize now starts only after the pointer moves 8 pixels, like Android's touch slop.
279
+ A tap on a resize handle that is also a button, such as a bottom sheet's drag handle, stays a
280
+ click: it no longer starts a resize, settles the sheet to its nearest snap point, and fires
281
+ resize events before the click runs.
282
+ - afcfef8: Read snap duration custom properties as CSS times. `--rc-bottom-sheet-snap-duration` and
283
+ `--rc-splitter-snap-duration` now accept seconds as well as milliseconds, so a theme motion
284
+ token such as `.3s` animates for 300 ms instead of finishing in a fraction of a millisecond.
285
+ `rc-common` exports the shared `parseCssTime` helper.
286
+ - 11ef1ad: Harden virtual scrolling for document and element scroll containers, viewport resizing,
287
+ shadow-root focus, hidden panes, and uniform spanning grids. Separate layout
288
+ sampling from range calculation and avoid repeating item measurements during
289
+ unchanged scroll frames. Scroll ancestor discovery now follows slots and shadow hosts.
290
+
291
+ Breaking: `first` and `last` are read-only computed outputs. Use `scrollToIndex()`
292
+ for navigation and read `range` for rendering instead of assigning output values.
293
+ Virtualization requires uniform line pitch and capacity in sequential DOM order;
294
+ detected unsupported layouts render the full collection. Set `items-per-line`
295
+ for ambiguous uniform grid capacity, or remove it to restore automatic inference.
296
+ Numeric inputs now normalize invalid values and floor integer configuration.
297
+
3
298
  ## 0.6.0
4
299
 
5
300
  ### Minor Changes
package/README.md CHANGED
@@ -31,17 +31,13 @@ import {
31
31
  ScrollObserverController,
32
32
  TypeaheadController,
33
33
  } from '@rcarls/rc-common';
34
- import { RovingTabIndexMixin, keyInteraction, keyNavigation, mouseMove } from '@rcarls/rc-common';
34
+ import { RovingTabIndexMixin, keyInteraction, keyNavigation } from '@rcarls/rc-common';
35
35
  import {
36
- delegateClickTo,
37
- DEFAULT_INTERACTIVE_SELECTOR,
38
36
  findExtremeSnapIndex,
39
37
  findNearestScrollAncestor,
40
38
  findNearestSnapIndex,
41
39
  findNextSnapIndex,
42
- getDirectChild,
43
40
  getDirectChildren,
44
- isEventFromInteractiveDescendant,
45
41
  isFocusable,
46
42
  pinElementBox,
47
43
  snapToStep,
@@ -56,35 +52,75 @@ All exports are tree-shakeable (`sideEffects: false`).
56
52
 
57
53
  Check this inventory before adding package-local interaction or DOM utility code.
58
54
 
59
- | Export | Use for |
60
- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
61
- | `ActiveDescendantController` | Managing `aria-activedescendant` virtual focus in listbox / combobox patterns |
62
- | `AnchorController` | Positioning floating UI relative to an anchor with native CSS anchor positioning and polyfill fallback |
63
- | `ClickDelegateController` / `delegateClickTo` | Extending plain pointer clicks on a host to a same-root native anchor or button target |
64
- | `DragController` | Pointer and keyboard drag-to-move behavior |
65
- | `DragGestureController` | Single-pointer activation, capture, deltas, duration, and recent velocity |
66
- | `ItemsCollectionController` | Filtering selectable and action items while preserving their distinct option kinds |
67
- | `KeyboardInteractionDirective` / `keyInteraction` | Tracking pointer vs keyboard interaction mode on a rendered element |
68
- | `KeyboardNavigationDirective` / `keyNavigation` | Mapping APG arrow-key models to navigation actions |
69
- | `MutationObserverController` | Lifecycle-safe `MutationObserver` wiring for light-DOM or shadow-DOM changes |
70
- | `MouseMoveDirective` / `mouseMove` | Pointermove callbacks while a pointer drag is active |
71
- | `NavigationIndicatorController` | Positioning a shared visual indicator against the current navigation item |
72
- | `NativeChildController`, `getDirectChild`, `getDirectChildren`, `warnMissingDirectChild` | Finding, validating, and tracking consumer-provided native light-DOM children |
73
- | `RafScheduler` | Coalescing repeated work into one animation frame and canceling on disconnect |
74
- | `ResizeController` | Pointer and keyboard resize behavior |
75
- | `RovingTabIndexMixin` | Roving tabindex for components whose child controls receive real DOM focus |
76
- | `ScrollObserverController` | Scroll threshold and delta observation for scroll-driven component state |
77
- | `TypeaheadController` | Printable-key buffering for composite widget typeahead |
78
- | `findNearestScrollAncestor` | Locating the nearest scrollable ancestor for scroll-driven behavior |
79
- | `findNearestSnapIndex`, `findNextSnapIndex`, `findExtremeSnapIndex` | Choosing numeric anchor indices without assigning component meaning |
80
- | `isFocusable` | Filtering focusable items for keyboard navigation |
81
- | `isEventFromInteractiveDescendant` | Detecting composed clicks already owned by a nested interactive control |
82
- | `DEFAULT_INTERACTIVE_SELECTOR` | Reusing the default selector used to identify nested interactive descendants |
83
- | `pinElementBox` | Converting an element's rendered box into explicit inline geometry for resize interactions |
84
- | `snapToStep`, `valueToPercent` | Slider and range-slider numeric helpers |
55
+ | Export | Use for |
56
+ | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
57
+ | `ActiveDescendantController` | Managing `aria-activedescendant` virtual focus in listbox / combobox patterns |
58
+ | `AnchorController` | Positioning floating UI relative to an anchor with native CSS anchor positioning and a script fallback |
59
+ | `ClickDelegateController` | Extending plain pointer clicks on a host to a same-root native anchor or button target |
60
+ | `DragController` | Pointer and keyboard drag-to-move behavior |
61
+ | `DragGestureController` | Single-pointer activation, capture, deltas, duration, and recent velocity |
62
+ | `ItemsCollectionController` | Filtering selectable and action items while preserving their distinct option kinds |
63
+ | `KeyboardInteractionDirective` / `keyInteraction` | Tracking pointer vs keyboard interaction mode on a rendered element |
64
+ | `KeyboardNavigationDirective` / `keyNavigation` | Mapping APG arrow-key models to navigation actions |
65
+ | `LocaleController` | Re-rendering on a host's UI locale change, for `Intl` formatting in render |
66
+ | `MessagesController`, `registerMessages`, `resolveMessages` | Built-in component text: per-element overrides, registered translations, English defaults |
67
+ | `messagesLocale`, `observeLocale` | Resolving a host's UI locale and reacting to any `dir` or `lang` change in the document |
68
+ | `numberFormat`, `collator` | Shared, cached `Intl.NumberFormat` and `Intl.Collator` instances that tolerate an invalid locale |
69
+ | `syncDefaultAttribute` | Writing a localized default attribute without overwriting an authored one |
70
+ | `MutationObserverController` | Lifecycle-safe `MutationObserver` wiring for light-DOM or shadow-DOM changes |
71
+ | `NavigationIndicatorController` | Positioning a shared visual indicator against the current navigation item |
72
+ | `NativeChildController`, `getDirectChildren`, `warnMissingDirectChild` | Finding, validating, and tracking consumer-provided native light-DOM children |
73
+ | `RafScheduler` | Coalescing repeated work into one animation frame and canceling on disconnect |
74
+ | `ResizeController` | Pointer and keyboard resize behavior |
75
+ | `RovingTabIndexMixin` | Roving tabindex for components whose child controls receive real DOM focus |
76
+ | `ScrollObserverController` | Scroll threshold and delta observation for scroll-driven component state |
77
+ | `TypeaheadController` | Printable-key buffering for composite widget typeahead |
78
+ | `findNearestScrollAncestor` | Locating the nearest scrolling ancestor through assigned slots and shadow hosts; falls back to the element's owner document |
79
+ | `findNearestSnapIndex`, `findNextSnapIndex`, `findExtremeSnapIndex` | Choosing numeric anchor indices without assigning component meaning |
80
+ | `parseCssTime` | Reading a CSS `<time>` custom property (`300ms`, `.3s`) as milliseconds for Web Animations |
81
+ | `cssText` | Tagging light-DOM structural CSS strings so package builds minify them |
82
+ | `isFocusable` | Filtering focusable items for keyboard navigation |
83
+ | `pinElementBox` | Converting an element's rendered box into explicit inline geometry for resize interactions |
84
+ | `snapToStep`, `valueToPercent` | Slider and range-slider numeric helpers |
85
85
 
86
86
  ---
87
87
 
88
+ ## Localization
89
+
90
+ Components ship English text only. Each one resolves its built-in strings (button names, role
91
+ descriptions, announcements) per key, in this order:
92
+
93
+ 1. The element's `messages` property (`reorderMessages` on `rc-list`).
94
+ 1. Text registered with `registerMessages()` for the element's locale: the exact tag, then its
95
+ base language (`de-CH`, then `de`). A component that extends another can also read the base
96
+ component's scope, below its own within each locale: `rc-combobox` takes any `rc-select`
97
+ text it has a key for. Pass `inherit` to `resolveMessages()` or `MessagesController` for the
98
+ same in your own components.
99
+ 1. The English default.
100
+
101
+ ```ts
102
+ import { registerMessages } from '@rcarls/rc-common';
103
+
104
+ registerMessages('de', {
105
+ 'rc-carousel': { previous: 'Vorherige Folie', next: 'Nächste Folie' },
106
+ 'rc-search-bar': { clear: 'Suche löschen' },
107
+ });
108
+ ```
109
+
110
+ The locale is the element's own `lang` attribute, else `<html lang>`. An explicit `lang=""`
111
+ means the language is unknown. An ancestor's `lang` usually marks content, such as a German
112
+ recipe on an English page, so component chrome skips it. Interpolating entries are functions,
113
+ such as `goToSlide: (position, count, locale?) => string`. Positions stay numeric for custom
114
+ translations; built-in messages format them with `Intl.NumberFormat` for the interface locale.
115
+ Custom translations can use `numberFormat(locale)` from this package. Use `bidiIsolate(text)`
116
+ when inserting consumer text of unknown direction into a plain-text message.
117
+
118
+ Each package declares its entry in the `RcMessageCatalog` interface, so `registerMessages()`
119
+ type-checks scope names and keys for the packages you import. Registering text, or changing a
120
+ `lang` or `dir` attribute, re-renders the affected components through `observeLocale()`, so a
121
+ language switch needs no reload. Register before components connect to avoid a flash of
122
+ English.
123
+
88
124
  ## API
89
125
 
90
126
  ### `DragGestureController`
@@ -99,6 +135,10 @@ The controller owns pointer capture and cleanup, but leaves state changes,
99
135
  thresholds, logical direction, snapping, and action confirmation to its
100
136
  consumer.
101
137
 
138
+ Changing options or detaching the host cancels an active gesture. Call
139
+ `dispose()` when removing the controller permanently; it releases pointer
140
+ capture and reports cancellation before removing itself from the host.
141
+
102
142
  ### `DragController`
103
143
 
104
144
  A `ReactiveController` that adds pointer-driven drag-to-move to any `LitElement` host. It binds
@@ -122,6 +162,10 @@ The controller pins explicit `top` and `left` values on the host the first time
122
162
  clearing centering transforms that would fight manual positioning. Pointer capture provides
123
163
  reliable drag-end detection across shadow boundaries.
124
164
 
165
+ Use `setOptions()` to reconfigure an attached controller. Call `dispose()`
166
+ when removing it permanently; owned handle focusability is restored without
167
+ overwriting later author changes.
168
+
125
169
  **Keyboard:** Arrow keys move by `step` px; Shift multiplies by 10.
126
170
 
127
171
  **Options:**
@@ -155,6 +199,10 @@ class MyPanel extends LitElement {
155
199
  It works alongside `DragController`: `ResizeController` registers a capture-phase listener that
156
200
  intercepts pointer events before the drag handler.
157
201
 
202
+ `dispose()` removes the injected grip, listeners, and temporary handle styles.
203
+ Author styles and later author changes are preserved. Completed resize geometry
204
+ remains on the target.
205
+
158
206
  **Options:**
159
207
 
160
208
  | Option | Type | Default | Description |
@@ -167,9 +215,9 @@ intercepts pointer events before the drag handler.
167
215
  ### `AnchorController`
168
216
 
169
217
  A `ReactiveController` that positions a floating element relative to an anchor using
170
- [CSS Anchor Positioning](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_anchor_positioning),
171
- with automatic fallback through
172
- [`@oddbird/css-anchor-positioning`](https://github.com/oddbird/css-anchor-positioning).
218
+ [CSS Anchor Positioning](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_anchor_positioning)
219
+ where the browser supports it fully, and script positioning with the same placement and flip
220
+ rules elsewhere.
173
221
 
174
222
  ```ts
175
223
  import { LitElement } from 'lit';
@@ -179,21 +227,73 @@ class MyTooltip extends LitElement {
179
227
  private _anchor = new AnchorController(this, {
180
228
  anchor: () => document.querySelector('#trigger')!,
181
229
  floating: () => this.shadowRoot!.querySelector('#popup')!,
230
+ disabled: () => !this.hasAttribute('open'),
182
231
  });
183
232
  }
184
233
  ```
185
234
 
186
235
  It injects a `<style>` block into `<head>` for the `anchor-name` and `position-anchor`
187
236
  declarations. It supports `@position-try` fallback blocks for automatic flip behavior in native
188
- browsers; the polyfill does not support `position-try`.
237
+ browsers. The script fallback flips on its own and re-positions when the page scrolls or the
238
+ viewport, anchor, or floating element resizes.
189
239
 
190
240
  **Options:**
191
241
 
192
- | Option | Type | Description |
193
- | -------------- | ----------------------- | ------------------------------------------------------------------ |
194
- | `anchor` | `() => Element \| null` | The anchor element getter |
195
- | `floating` | `() => Element \| null` | The floating element getter |
196
- | `positionArea` | `string` | CSS `position-area` value (for example, `'block-end span-inline'`) |
242
+ | Option | Type | Default | Description |
243
+ | ------------ | ------------------------------------------ | ------------------- | --------------------------------------------- |
244
+ | `anchor` | `Element \| () => Element \| null` | required | Anchor element or live getter |
245
+ | `floating` | `Element \| () => Element \| null` | required | Floating element or live getter |
246
+ | `placement` | `AnchorPlacement` | `block-end-start` | Logical side and cross-axis alignment |
247
+ | `offset` | `number` | `4` | Gap from the anchor in pixels |
248
+ | `flip` | `boolean` | `true` | Allow viewport fallback placements |
249
+ | `disabled` | `boolean \| () => boolean` | `false` | Skip all positioning while inactive or closed |
250
+ | `shadowHost` | `HTMLElement \| () => HTMLElement \| null` | document stylesheet | Shadow host that owns the floating element |
251
+
252
+ Use a live `disabled` getter for popups that stay mounted while closed. The
253
+ controller checks it before resolving writing mode or reading geometry, so a
254
+ closed popup does not pay placement cost during route mount.
255
+
256
+ ---
257
+
258
+ ### `RafScheduler`
259
+
260
+ `schedule(callback)` coalesces ordinary work to one animation frame.
261
+ `schedulePhased(sample, apply)` additionally coordinates every scheduler
262
+ instance in the module: all `sample` callbacks run before any `apply`
263
+ callback. Repeated schedules keep only the latest task, and disconnecting a
264
+ host cancels pending work.
265
+
266
+ Use `schedulePhased` when a component must read layout and then write reactive
267
+ state or inline geometry. Return a compact snapshot from `sample`; keep
268
+ calculation that does not need the DOM pure; perform mutations in `apply`.
269
+
270
+ ---
271
+
272
+ ### `FlowController`
273
+
274
+ Lifecycle-driven flow resolution is frame-settled. Connection, ancestor
275
+ direction changes, and resize signals sample writing mode and direction
276
+ in the shared frame read phase, then request the host update before paint. The
277
+ controller starts with horizontal left-to-right flow, so await the next frame
278
+ before reading derived rendered orientation or other flow-dependent state.
279
+
280
+ Call `refresh()` when an explicit operation requires the current flow
281
+ synchronously, including after a stylesheet-only writing-mode change. Pointer,
282
+ keyboard, and geometry interactions should continue to resolve flow at the
283
+ time of the interaction rather than relying on cached lifecycle state.
284
+
285
+ ---
286
+
287
+ ### `ScrollObserverController`
288
+
289
+ Scroll events are evaluated synchronously. Initial attachment is synchronous
290
+ by default so restored scroll state is immediately observable. Set
291
+ `initialEvaluation: 'frame'` when mounting many scroll-driven components: the
292
+ controller resolves the target and samples its initial offset in the shared
293
+ frame read phase, then attaches and applies state before paint.
294
+
295
+ Call `dispose()` when removing the observer permanently; it also cancels a
296
+ pending frame evaluation.
197
297
 
198
298
  ---
199
299
 
@@ -273,33 +373,9 @@ class ActionRow extends LitElement {
273
373
  }
274
374
  ```
275
375
 
276
- Use `delegateClickTo()` directly for a non-Lit host. The target remains its own
277
- keyboard tab stop; delegation extends pointer reach only.
278
-
279
- ---
280
-
281
- ### `mouseMove` directive
282
-
283
- An `AsyncDirective` that fires a callback on pointer movement while a pointer drag is active. It
284
- supports drag-to-resize handles that need continuous delta tracking while preserving the
285
- historical `mouseMove` export name.
286
-
287
- ```ts
288
- import { mouseMove } from '@rcarls/rc-common';
289
-
290
- // Inside a Lit render() method:
291
- html`
292
- <div id="handle" ${mouseMove(this._onDrag)}></div>
293
- `;
294
-
295
- private _onDrag(e: MouseEvent) {
296
- this._resize(e.movementX, e.movementY);
297
- }
298
- ```
299
-
300
- It attaches `pointerdown` to the element, captures that pointer, then listens for `pointermove`,
301
- `pointerup`, `pointercancel`, and `lostpointercapture` on the same element for the active drag
302
- cycle. It focuses the handle on pointerdown.
376
+ The target remains its own keyboard tab stop; delegation extends pointer reach
377
+ only. Pass `interactiveSelector` to change which descendants count as already
378
+ interactive.
303
379
 
304
380
  ---
305
381
 
@@ -322,8 +398,8 @@ tabindex values during roving-tabindex management. Any `tabindex` attribute is t
322
398
 
323
399
  ## Browser support
324
400
 
325
- | Feature | Requirement |
326
- | ------------------------------- | ------------------------------------------------------ |
327
- | Controllers and directives | Any browser supporting Web Components + Pointer Events |
328
- | `AnchorController` (native) | Chrome 125+, Safari 18+, Firefox (in development) |
329
- | `AnchorController` (polyfilled) | Chrome 80+, Firefox 85+, Safari 14+ |
401
+ | Feature | Requirement |
402
+ | --------------------------- | ------------------------------------------------------ |
403
+ | Controllers and directives | Any browser supporting Web Components + Pointer Events |
404
+ | `AnchorController` (native) | Chrome 125+, Safari 18+, Firefox (in development) |
405
+ | `AnchorController` (script) | Any browser supporting Web Components |