@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
@@ -1,47 +1,63 @@
1
1
  import { ReactiveController, ReactiveControllerHost } from 'lit';
2
- export type AnchorPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
2
+ import { AnchorPlacement } from './anchorPlacement.js';
3
+ export type { AnchorPlacement };
3
4
  export interface AnchorOptions {
4
5
  /** The anchor (trigger) element. Accepts an element reference or getter. */
5
6
  anchor: Element | (() => Element | null);
6
7
  /** The floating element to position. Accepts an element reference or getter. */
7
8
  floating: Element | (() => Element | null);
8
- /** Preferred placement relative to the anchor. Defaults to `'bottom-start'`. */
9
+ /** Preferred placement relative to the anchor. Defaults to `'block-end-start'`. */
9
10
  placement?: AnchorPlacement;
10
11
  /** Gap between anchor and floating in px. Defaults to `4`. */
11
12
  offset?: number;
12
13
  /** Flip to opposite side when clipped by viewport. Defaults to `true`. */
13
14
  flip?: boolean;
14
- disabled?: boolean;
15
+ /** Whether positioning is inactive. Accepts a boolean or a getter for live popup state. */
16
+ disabled?: boolean | (() => boolean);
15
17
  /**
16
18
  * The LitElement shadow host. When provided, positioning CSS is injected into
17
19
  * the shadow root's adoptedStyleSheets so it reaches shadow-DOM floating elements,
18
- * including those promoted to the popover top layer. The polyfill is invoked
19
- * with roots: [shadowHost] to scope its traversal to this shadow root.
20
+ * including those promoted to the popover top layer.
20
21
  */
21
22
  shadowHost?: HTMLElement | (() => HTMLElement | null);
22
23
  }
23
24
  /**
24
25
  * Positions a floating element relative to an anchor element using CSS
25
- * Anchor Positioning (native-first, polyfill on unsupported browsers via
26
- * `@oddbird/css-anchor-positioning`).
26
+ * Anchor Positioning where the browser supports it fully, and script
27
+ * positioning with the same placement and flip rules elsewhere. The script
28
+ * fallback re-runs when the page scrolls or the viewport, anchor, or
29
+ * floating element resizes.
27
30
  *
28
31
  * For shadow DOM components (pass `shadowHost`), positioning CSS is injected
29
32
  * into the shadow root's `adoptedStyleSheets` so it reaches floating elements
30
- * including those promoted to the popover top layer. The polyfill is invoked
31
- * with `roots: [shadowHost]` to scope its stylesheet traversal correctly.
33
+ * including those promoted to the popover top layer.
32
34
  *
33
35
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_anchor_positioning
34
36
  */
35
37
  export declare class AnchorController implements ReactiveController {
38
+ private readonly _host;
36
39
  private _opts;
37
40
  private readonly _uid;
38
41
  private _styleEl;
39
42
  private _adoptedSheet;
40
43
  private _connected;
44
+ private readonly _clampScheduler;
41
45
  private _clampLoopActive;
42
- private _clampFrame;
43
- private _appliedDx;
44
- private _appliedDy;
46
+ private _settleFramesRemaining;
47
+ private _stableFrames;
48
+ private _lastNaturalRect;
49
+ private _appliedTranslateXCssPx;
50
+ private _appliedTranslateYCssPx;
51
+ private _geometryAbort;
52
+ private _resizeObserver;
53
+ private _intersectionObserver;
54
+ private _mutationObserver;
55
+ private _unobserveLocale;
56
+ private _$observedAnchor;
57
+ private _$observedFloating;
58
+ private readonly _handleGeometryChange;
59
+ private readonly _handlePositionChange;
60
+ private readonly _handleDirectionChange;
45
61
  constructor(host: ReactiveControllerHost, options: AnchorOptions);
46
62
  setOptions(next: Partial<AnchorOptions>): void;
47
63
  /** Re-apply positioning after the popup becomes visible or the anchor moves. */
@@ -51,16 +67,19 @@ export declare class AnchorController implements ReactiveController {
51
67
  private _anchor;
52
68
  private _floating;
53
69
  private _shadowHost;
54
- private _applyAndPolyfill;
70
+ private _disabled;
71
+ private _usesNativeAnchor;
72
+ private _applyAndPosition;
55
73
  /**
56
- * Checks viewport overflow on every frame while the floating element is
57
- * visible. Anchor geometry can settle well after the popup opens, so the
58
- * loop follows visibility rather than a fixed timeout. A hidden initial
59
- * state stops immediately; consumers restart positioning after showing the
60
- * popup by calling `update()`.
74
+ * Checks viewport overflow during a bounded post-open settling window.
75
+ * Observers and viewport events restart the window when geometry changes,
76
+ * avoiding permanent layout polling while a popup is idle.
61
77
  */
62
78
  private _scheduleClamp;
79
+ private _runClampTick;
63
80
  private _stopClampLoop;
81
+ private _startWatchingGeometry;
82
+ private _stopWatchingGeometry;
64
83
  /**
65
84
  * Nudges the floating element back on-screen via `translate` if whatever
66
85
  * positioned it (native or otherwise) still left it overflowing the
@@ -80,17 +99,21 @@ export declare class AnchorController implements ReactiveController {
80
99
  * clear the correction as unnecessary, then reapply it next frame once
81
100
  * the underlying overflow reappears — an every-frame flicker confirmed
82
101
  * by a real click landing on a mid-flicker frame in the browser test
83
- * suite. `_appliedDx`/`_appliedDy` track the offset this method itself
102
+ * suite. `_appliedTranslateXCssPx`/`_appliedTranslateYCssPx` track the offset this method itself
84
103
  * last applied so it can subtract it back out and compute against the
85
104
  * element's natural, uncorrected position each time.
86
105
  */
87
106
  private _clampToViewport;
88
- private _applyPolyfillOrFallback;
107
+ /**
108
+ * The configured placement resolved against the anchor's writing mode and
109
+ * direction. Read at every apply, since a `dir` change fires no event.
110
+ */
111
+ private _physicalPlacement;
89
112
  private _apply;
90
113
  private _injectStyles;
91
114
  /**
92
- * Hand-rolled positioning for browsers where neither native anchor
93
- * positioning nor the polyfill is usable. Handles all four placement
115
+ * Hand-rolled positioning for browsers without full native anchor
116
+ * positioning. Handles all four placement
94
117
  * sides (not just top/bottom — a side flyout like a cascading submenu
95
118
  * needs its primary axis to be horizontal, offsetting by the anchor's
96
119
  * own width/height rather than always stacking below it), with the
@@ -0,0 +1,15 @@
1
+ /** Resources owned by one controller attachment. Create a new scope on reconnect. */
2
+ export declare class ControllerEffects {
3
+ private readonly _cleanups;
4
+ private readonly _attributes;
5
+ private readonly _styles;
6
+ private _disposed;
7
+ add(cleanup: () => void): void;
8
+ listen($target: EventTarget, type: string, listener: EventListener, options?: AddEventListenerOptions): void;
9
+ append($parent: Node, $node: Node): void;
10
+ setAttribute($target: Element, name: string, value: string): void;
11
+ setStyle($target: HTMLElement, name: string, value: string, priority?: string): void;
12
+ dispose(): void;
13
+ /** Keep current effects when another owner takes over their state. */
14
+ abandon(): void;
15
+ }
@@ -27,12 +27,25 @@ export declare class DragController implements ReactiveController {
27
27
  private _dragging;
28
28
  private _startLeft;
29
29
  private _startTop;
30
+ /** The target's effective CSS zoom for the current drag. */
31
+ private _zoom;
30
32
  private readonly _gesture;
31
33
  private readonly _onKeyDown;
34
+ private readonly _host;
35
+ private readonly _handleEffects;
36
+ private _connected;
37
+ private _disposed;
32
38
  constructor(host: ReactiveControllerHost, options: DragOptions);
39
+ /** Reconfigures drag behavior and rebinds the handle when it changes. */
33
40
  setOptions(next: Partial<DragOptions>): void;
34
41
  hostConnected(): void;
35
42
  hostDisconnected(): void;
43
+ /**
44
+ * Detaches the handle (undoing the `tabindex` it added) and removes the
45
+ * controller and its gesture from the host for good. Use it to replace a
46
+ * controller when move options change after setup.
47
+ */
48
+ dispose(): void;
36
49
  private _handle;
37
50
  private _target;
38
51
  private _attachTo;
@@ -1,6 +1,6 @@
1
1
  import { ReactiveController, ReactiveControllerHost } from 'lit';
2
2
  export type DragGestureAxis = 'both' | 'x' | 'y';
3
- export type DragGestureActivation = 'axis' | 'immediate';
3
+ export type DragGestureActivation = 'axis' | 'immediate' | 'press';
4
4
  export interface DragGestureDetail {
5
5
  /** Pointer event that produced this lifecycle update. */
6
6
  event: PointerEvent;
@@ -34,12 +34,20 @@ export interface DragGestureOptions {
34
34
  /** Allowed drag axis. Defaults to both axes. */
35
35
  axis?: DragGestureAxis;
36
36
  /**
37
- * Whether to activate immediately or wait for dominant-axis intent.
38
- * Delayed axis activation preserves cross-axis scrolling.
37
+ * When the gesture activates. `immediate` activates on press. `axis` waits
38
+ * for movement along the allowed axis, which preserves cross-axis
39
+ * scrolling. `press` waits for the pointer to be held still for
40
+ * `pressDelay`, a long press, which preserves scrolling in every direction:
41
+ * moving `activationDistance` first gives the pointer back to the browser.
39
42
  */
40
43
  activation?: DragGestureActivation;
41
- /** Distance required before delayed axis activation. Defaults to 8 pixels. */
44
+ /**
45
+ * Distance required before axis activation, or that gives up a press
46
+ * before it activates. Defaults to 8 pixels.
47
+ */
42
48
  activationDistance?: number;
49
+ /** How long a press must be held before press activation. Defaults to 400 milliseconds. */
50
+ pressDelay?: number;
43
51
  /** Required allowed-axis dominance over the cross axis. Defaults to 1.25. */
44
52
  axisLockRatio?: number;
45
53
  /** Recent sample window used for velocity. Defaults to 100 milliseconds. */
@@ -62,7 +70,7 @@ export interface DragGestureOptions {
62
70
  onMove?: (detail: DragGestureDetail) => void;
63
71
  /** Called when the active pointer is released. */
64
72
  onEnd?: (detail: DragGestureDetail) => void;
65
- /** Called when the active gesture is cancelled or loses pointer capture. */
73
+ /** Called when the active gesture is cancelled, loses capture, or is detached. */
66
74
  onCancel?: (detail: DragGestureDetail) => void;
67
75
  }
68
76
  /**
@@ -75,6 +83,7 @@ export interface DragGestureOptions {
75
83
  export declare class DragGestureController implements ReactiveController {
76
84
  private _options;
77
85
  private _$target;
86
+ private _$captureTarget;
78
87
  private _pointerId;
79
88
  private _startX;
80
89
  private _startY;
@@ -82,19 +91,35 @@ export declare class DragGestureController implements ReactiveController {
82
91
  private _samples;
83
92
  private _activated;
84
93
  private _rejected;
94
+ private readonly _host;
95
+ private _lastEvent;
96
+ private _boundCapture;
97
+ private _disposed;
98
+ private _pressTimer;
85
99
  constructor(host: ReactiveControllerHost, options: DragGestureOptions);
86
- /** Updates behavior or the target resolver and safely rebinds listeners. */
100
+ /** Updates behavior or the target resolver, cancelling any active gesture first. */
87
101
  setOptions(options: Partial<DragGestureOptions>): void;
88
102
  hostConnected(): void;
89
103
  hostUpdated(): void;
90
104
  hostDisconnected(): void;
105
+ /** Cancels an active gesture, then removes listeners and the controller permanently. */
106
+ dispose(): void;
91
107
  private _resolveTarget;
92
108
  private _bindTarget;
93
109
  private _unbindTarget;
94
110
  private _onPointerDown;
111
+ /**
112
+ * Waits out a long press. Until it activates, the browser keeps the pointer
113
+ * and may scroll. Once it does, touch scrolling and the browser's own
114
+ * long-press behavior, a context menu or text selection, are held off.
115
+ */
116
+ private _startPress;
117
+ private _onTouchMove;
118
+ private _onContextMenu;
95
119
  private _onPointerMove;
96
120
  private _onPointerUp;
97
121
  private _onPointerCancel;
122
+ private _onDocumentPointerUp;
98
123
  private _onLostPointerCapture;
99
124
  private _resolveIntent;
100
125
  private _activate;
@@ -107,4 +132,3 @@ export declare class DragGestureController implements ReactiveController {
107
132
  private _releasePointer;
108
133
  private _reset;
109
134
  }
110
- export default DragGestureController;
@@ -0,0 +1,31 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ import { Flow } from './flow.js';
3
+ /**
4
+ * Keeps a host's resolved writing mode and direction current for rendering,
5
+ * such as an `aria-orientation` that must report the rendered orientation.
6
+ *
7
+ * Re-resolves in a shared animation-frame sampling phase after connect,
8
+ * whenever a `dir` attribute changes in the document, and whenever the host
9
+ * resizes. Requests an update only when the flow actually changed. The public
10
+ * {@link refresh} method remains synchronous for explicit invalidation. A
11
+ * writing-mode switch is only caught when it changes the
12
+ * host's logical size: ResizeObserver compares inline and block sizes, so a
13
+ * logically sized host that turns keeps both and reports nothing. Call
14
+ * {@link refresh} after such a switch, or after `direction` set by a
15
+ * stylesheet. Event handlers should resolve the flow themselves at event time
16
+ * instead.
17
+ */
18
+ export declare class FlowController implements ReactiveController {
19
+ private readonly _host;
20
+ private _flow;
21
+ private _observer;
22
+ private _unobserveLocale;
23
+ private readonly _frame;
24
+ constructor(host: ReactiveControllerHost & Element);
25
+ get flow(): Flow;
26
+ hostConnected(): void;
27
+ hostDisconnected(): void;
28
+ refresh(): void;
29
+ private _scheduleRefresh;
30
+ private _apply;
31
+ }
@@ -88,9 +88,10 @@ export declare class ItemsCollectionController implements ReactiveController {
88
88
  clearFilter(): void;
89
89
  /**
90
90
  * Show or hide the synthetic "Create" option at the end of the list.
91
- * Pass `null` to remove it.
91
+ * Pass `null` to remove it. `label` is the option's visible text, such as
92
+ * `Create "pears"`; it defaults to the text itself.
92
93
  */
93
- setCreateOption(label: string | null): void;
94
+ setCreateOption(text: string | null, label?: string): void;
94
95
  private _ensureContainer;
95
96
  private _bootstrapFromDom;
96
97
  private _syncOptionsToDom;
@@ -27,6 +27,5 @@ declare class KeyboardInteractionDirective extends AsyncDirective {
27
27
  disconnected(): void;
28
28
  reconnected(): void;
29
29
  }
30
- export declare const keyInteraction: (_options?: KeyInteractionOptions | undefined) => import('lit/directive.js').DirectiveResult<typeof KeyboardInteractionDirective>;
30
+ export declare const keyInteraction: (_options?: KeyInteractionOptions | undefined) => import('lit-html/directive.js').DirectiveResult<typeof KeyboardInteractionDirective>;
31
31
  export type { KeyboardInteractionDirective };
32
- export default keyInteraction;
@@ -20,6 +20,11 @@ export interface KeyNavigationOptions {
20
20
  * Explicitly set the navigation axis, overriding role-based auto-detection.
21
21
  * The navigation axis determines which arrow keys map to 'next'/'prev'.
22
22
  * Required when the element has no ARIA role (e.g. a menu-button trigger wrapper).
23
+ *
24
+ * This is a layout orientation: `horizontal` means items run along the
25
+ * inline axis, `vertical` along the block axis. It is converted to the
26
+ * rendered physical orientation per keydown, so a horizontal layout in
27
+ * vertical text navigates with ArrowUp/ArrowDown.
23
28
  */
24
29
  navigationAxis?: 'horizontal' | 'vertical';
25
30
  /**
@@ -44,24 +49,28 @@ declare class KeyboardNavigationDirective extends AsyncDirective {
44
49
  private _callback;
45
50
  private _options;
46
51
  /**
47
- * The navigation axis determines which arrow keys map to 'next'/'prev'.
48
- * Checks the explicit `navigationAxis` option first, then auto-detects
49
- * from the element's ARIA role and aria-orientation attribute.
52
+ * The physical axis whose arrow keys map to 'next'/'prev'.
53
+ *
54
+ * An explicit `aria-orientation` attribute is already physical and is used
55
+ * as is. Everything else describes layout, so it is converted to the
56
+ * orientation it renders in: an explicit `navigationAxis` option or a role
57
+ * default of `horizontal` runs along the inline axis and turns vertical in
58
+ * vertical writing modes, like a native range input does.
50
59
  */
51
60
  protected get navigationAxis(): 'horizontal' | 'vertical';
61
+ private _resolveAxis;
52
62
  constructor(partInfo: PartInfo);
53
63
  private _normalizeKey;
54
64
  protected _onKeydown(e: KeyboardEvent): void;
55
65
  protected _init(): void;
56
66
  /**
57
- * @param _cb - Callback function invoked with the navigation action
58
- * @param _options - Keyboard navigation behavior options.
67
+ * @param _cb - callback function invoked with the navigation action
68
+ * @param _options - keyboard navigation behavior options
59
69
  */
60
70
  render(_cb: (action: KeyboardNavigationAction) => void, _options?: KeyNavigationOptions): symbol;
61
71
  update(part: ElementPart, [cb, options]: Parameters<this['render']>): void;
62
72
  disconnected(): void;
63
73
  reconnected(): void;
64
74
  }
65
- export declare const keyNavigation: (_cb: (action: KeyboardNavigationAction) => void, _options?: KeyNavigationOptions | undefined) => import('lit/directive.js').DirectiveResult<typeof KeyboardNavigationDirective>;
75
+ export declare const keyNavigation: (_cb: (action: KeyboardNavigationAction) => void, _options?: KeyNavigationOptions | undefined) => import('lit-html/directive.js').DirectiveResult<typeof KeyboardNavigationDirective>;
66
76
  export type { KeyboardNavigationDirective };
67
- export default keyNavigation;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * A polite, visually hidden live region for status messages that have no
3
+ * visible text of their own, such as the steps of a drag reorder.
4
+ *
5
+ * Mount it where it is both reachable and valid: inside any open modal
6
+ * `<dialog>` around the component, since everything outside one is inert, and
7
+ * outside any widget whose role restricts its children, such as a list.
8
+ */
9
+ export declare class LiveAnnouncer {
10
+ private readonly _$region;
11
+ private _clearTimer;
12
+ constructor(root: ParentNode & Node);
13
+ /** The region element, for tests and for callers that need to reposition it. */
14
+ get element(): HTMLElement;
15
+ /**
16
+ * Speaks `message`. The region is emptied first so a message identical to
17
+ * the previous one is still announced.
18
+ */
19
+ announce(message: string): void;
20
+ /** Removes the region. */
21
+ dispose(): void;
22
+ }
@@ -27,4 +27,3 @@ export declare class MutationObserverController implements ReactiveController {
27
27
  private _attach;
28
28
  private _detach;
29
29
  }
30
- export default MutationObserverController;
@@ -17,6 +17,7 @@ export declare class NavigationIndicatorController implements ReactiveController
17
17
  private readonly _options;
18
18
  private _mutationObserver?;
19
19
  private _resizeObserver?;
20
+ private _unobserveLocale?;
20
21
  private _frame;
21
22
  private _links;
22
23
  constructor(host: ReactiveControllerHost & HTMLElement, options: NavigationIndicatorControllerOptions);
@@ -30,4 +31,3 @@ export declare class NavigationIndicatorController implements ReactiveController
30
31
  private _targetFor;
31
32
  private _positionIndicator;
32
33
  }
33
- export default NavigationIndicatorController;
@@ -0,0 +1,21 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ export interface PopoverControllerOptions {
3
+ /** The authored or rendered element with `popover="manual"`. */
4
+ element: HTMLElement | (() => HTMLElement | null);
5
+ }
6
+ /**
7
+ * Keeps a manual popover visible through the native API or a CSS fallback.
8
+ * The caller owns open state, dismissal, focus, semantics, and positioning.
9
+ * Its CSS must show `[data-rc-popover-fallback-open]` when native opening fails.
10
+ */
11
+ export declare class PopoverController implements ReactiveController {
12
+ private readonly _element;
13
+ private _current;
14
+ private _connected;
15
+ constructor(host: ReactiveControllerHost, options: PopoverControllerOptions);
16
+ hostConnected(): void;
17
+ hostDisconnected(): void;
18
+ /** Synchronize visibility after the popup exists in the DOM. */
19
+ sync(open: boolean): void;
20
+ private _close;
21
+ }
@@ -1,5 +1,23 @@
1
1
  import { ReactiveController, ReactiveControllerHost } from 'lit';
2
2
  export type RafSchedulerCallback = (timestamp: DOMHighResTimeStamp) => void;
3
+ /**
4
+ * Samples browser state during the shared read phase.
5
+ *
6
+ * @callback RafSchedulerSample
7
+ * @typeParam T - Snapshot returned for the matching apply callback.
8
+ * @param timestamp - The animation frame timestamp.
9
+ * @returns A snapshot containing everything the apply callback needs.
10
+ */
11
+ export type RafSchedulerSample<T> = (timestamp: DOMHighResTimeStamp) => T;
12
+ /**
13
+ * Applies a previously sampled snapshot during the shared write phase.
14
+ *
15
+ * @callback RafSchedulerApply
16
+ * @typeParam T - Snapshot produced by the matching sample callback.
17
+ * @param sample - The snapshot produced during the read phase.
18
+ * @param timestamp - The animation frame timestamp.
19
+ */
20
+ export type RafSchedulerApply<T> = (sample: T, timestamp: DOMHighResTimeStamp) => void;
3
21
  /**
4
22
  * Coalesces repeated work into one `requestAnimationFrame` callback and
5
23
  * cancels pending work when the host disconnects.
@@ -10,7 +28,24 @@ export declare class RafScheduler implements ReactiveController {
10
28
  constructor(host?: ReactiveControllerHost);
11
29
  get pending(): boolean;
12
30
  schedule(callback: RafSchedulerCallback): void;
31
+ /**
32
+ * Coalesces measurement and mutation into a shared animation frame.
33
+ * Every queued sample runs before any queued apply, including work from
34
+ * other scheduler instances. Repeated calls keep only the latest task.
35
+ *
36
+ * @typeParam T - Snapshot returned by `sample` and passed to `apply`.
37
+ * @param sample - reads browser state and returns a compact snapshot
38
+ * @param apply - mutates state or DOM from the sampled snapshot
39
+ * @example
40
+ * ```ts
41
+ * scheduler.schedulePhased(
42
+ * () => element.getBoundingClientRect(),
43
+ * (rect) => element.style.setProperty('--measured-width', `${rect.width}px`),
44
+ * );
45
+ * ```
46
+ */
47
+ schedulePhased<T>(sample: RafSchedulerSample<T>, apply: RafSchedulerApply<T>): void;
13
48
  cancel(): void;
14
49
  hostDisconnected(): void;
50
+ private _cancelPhased;
15
51
  }
16
- export default RafScheduler;
@@ -0,0 +1,131 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ /** How the active reorder was started. */
3
+ export type ReorderMode = 'pointer' | 'keyboard';
4
+ /** Announcement text for each reorder step. Positions are 1-based. */
5
+ export interface ReorderMessages {
6
+ /** Description written to handles that have no authored `aria-description`. */
7
+ instructions: string;
8
+ grabbed: (position: number, count: number, locale?: string) => string;
9
+ moved: (position: number, count: number, locale?: string) => string;
10
+ dropped: (position: number, count: number, locale?: string) => string;
11
+ canceled: (position: number, count: number, locale?: string) => string;
12
+ }
13
+ export declare const DEFAULT_REORDER_MESSAGES: Readonly<ReorderMessages>;
14
+ export interface ReorderOptions {
15
+ /** Reorderable items in order. Hidden items should be left out. */
16
+ items: () => readonly HTMLElement[];
17
+ /** Selector for the handle inside an item that starts a reorder. */
18
+ handleSelector: string;
19
+ /**
20
+ * Where the live region is mounted. Defaults to the nearest open `dialog` or popover around
21
+ * the host, else the document body. The region must not sit inside a widget whose role
22
+ * restricts its children, such as a list, and must not sit outside an open modal dialog,
23
+ * where it would be inert.
24
+ */
25
+ announcerRoot?: () => (ParentNode & Node) | null;
26
+ /**
27
+ * Announcement overrides, read when each message is spoken. They win over
28
+ * text registered with `registerMessages()` under `reorder`.
29
+ */
30
+ messages?: () => Partial<ReorderMessages> | undefined;
31
+ /** Whether reordering is currently unavailable. */
32
+ disabled?: () => boolean;
33
+ /** Distance from the scroll container's block edges that starts autoscroll, in px. */
34
+ autoScrollEdge?: number;
35
+ /**
36
+ * Applies a move. Called once at the end of a pointer drag, and for every
37
+ * step of a keyboard reorder, including the move back when it is canceled.
38
+ */
39
+ onMove: (item: HTMLElement, from: number, to: number, mode: ReorderMode) => void;
40
+ /** Called when an item is lifted (`item` set) and when it is put down (`null`). */
41
+ onActiveChange?: (item: HTMLElement | null, mode: ReorderMode | null) => void;
42
+ }
43
+ /**
44
+ * Reorders a list of items by dragging a handle or with the keyboard.
45
+ *
46
+ * The controller never moves DOM nodes. It previews a pointer drag with
47
+ * inline `translate` offsets on the lifted item and the items it passes, and
48
+ * reports each committed move through `onMove`; the host applies it, or lets
49
+ * its consumer do so.
50
+ *
51
+ * Pointer: a drag starts once a handle is pressed and moved a few pixels, so a
52
+ * plain click still focuses or activates the handle. On touch and pen, as on
53
+ * Android, a long press anywhere else on an item also picks it up; moving
54
+ * before the press completes scrolls instead, and the click that would follow
55
+ * the drop is swallowed so the press does not also activate a control in the
56
+ * item. A mouse drags only by the handle. The nearest scroll
57
+ * container scrolls while the pointer is near its block edges, and Escape
58
+ * cancels.
59
+ *
60
+ * Keyboard: Space or Enter on a focused handle picks the item up, the block-axis
61
+ * arrow keys, Home, and End move it, Space or Enter drops it, and Escape moves it
62
+ * back to where it started. Moving focus away drops it. Each step is announced
63
+ * through a {@link LiveAnnouncer}, and focus follows the item's handle, including
64
+ * when a framework re-creates the item's nodes.
65
+ *
66
+ * Geometry and arrow keys resolve through the flow helpers, so the block axis
67
+ * may run in any direction.
68
+ */
69
+ export declare class ReorderController implements ReactiveController {
70
+ private readonly _host;
71
+ private readonly _options;
72
+ private readonly _gesture;
73
+ private readonly _pressGesture;
74
+ private _activeGesture;
75
+ private _pending;
76
+ private _session;
77
+ private readonly _translated;
78
+ private _announcer;
79
+ private _autoScrollFrame;
80
+ private _restoringFocus;
81
+ constructor(host: ReactiveControllerHost & HTMLElement, options: ReorderOptions);
82
+ /** Whether an item is currently lifted. */
83
+ get active(): boolean;
84
+ hostConnected(): void;
85
+ hostDisconnected(): void;
86
+ /** Cancels any active reorder, restoring the starting position. */
87
+ cancel(): void;
88
+ /**
89
+ * The text of a message in the host's locale: an override, else registered
90
+ * text, else the English default.
91
+ */
92
+ message<K extends keyof ReorderMessages>(key: K): ReorderMessages[K];
93
+ private _items;
94
+ private _isDisabled;
95
+ /** The item and handle an event landed in, if it landed on a handle. */
96
+ private _resolve;
97
+ private _handleOf;
98
+ private _announce;
99
+ private _canStart;
100
+ /** Whether a touch or pen press on an item, away from its handle, may long-press it. */
101
+ private _canStartPress;
102
+ /**
103
+ * Swallows the click that follows lifting a pointer after a long-press
104
+ * drag, which would otherwise activate whatever control the press began on.
105
+ */
106
+ private _swallowNextClick;
107
+ private _pointerStart;
108
+ private _pointerMove;
109
+ private _layoutPointer;
110
+ private _translate;
111
+ private _clearTranslations;
112
+ private _restoreTranslation;
113
+ private _queueAutoScroll;
114
+ /** Physical scroll speed for the pointer's distance from the scroller's block edges. */
115
+ private _autoScrollSpeed;
116
+ private _pointerEnd;
117
+ private readonly _onKeyDown;
118
+ private _keyboardStep;
119
+ private readonly _onFocusOut;
120
+ private readonly _onDocumentPointerDown;
121
+ /** Ends a keyboard reorder where the item now is. */
122
+ private _drop;
123
+ /**
124
+ * Applies a move and keeps focus on the moved item's handle. Moving a node
125
+ * drops its focus, and a framework may replace the node outright, so the
126
+ * handle is looked up again once the host has rendered.
127
+ */
128
+ private _commit;
129
+ private _cancel;
130
+ private _end;
131
+ }