@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
@@ -0,0 +1,79 @@
1
+ /** Width and height of a viewport in CSS pixels. */
2
+ export interface ViewportSize {
3
+ /** Inline size in CSS pixels. */
4
+ width: number;
5
+ /** Block size in CSS pixels. */
6
+ height: number;
7
+ }
8
+ /**
9
+ * The block size a viewport reports while the software keyboard is up.
10
+ * `keyboard` follows the keyboard, so the result is the space left above it;
11
+ * `full` keeps the keyboard-free height, as window size classes should.
12
+ */
13
+ export type SoftKeyboardHeight = 'keyboard' | 'full';
14
+ /** Options for {@link SoftKeyboardViewport}. */
15
+ export interface SoftKeyboardViewportOptions {
16
+ /**
17
+ * The block size to report while the keyboard is up. Defaults to `keyboard`.
18
+ */
19
+ heightWhileOpen?: SoftKeyboardHeight;
20
+ /**
21
+ * How long, in milliseconds, a closing keyboard may take to give the viewport
22
+ * its full height back before a shorter measurement is accepted after all.
23
+ * Defaults to 1000.
24
+ */
25
+ closeTimeout?: number;
26
+ /**
27
+ * Called when the close timeout expires, so the consumer can measure again
28
+ * and apply the viewport as it has settled.
29
+ */
30
+ onCloseTimeout?: () => void;
31
+ }
32
+ /**
33
+ * Returns the focused element, following focus into open shadow roots, where
34
+ * custom elements keep their native fields.
35
+ */
36
+ export declare function deepActiveElement(document: Document): Element | null;
37
+ /** Whether the document's focused element, inside shadow roots too, takes typed text. */
38
+ export declare function isTextEntryFocused(document: Document): boolean;
39
+ /**
40
+ * Filters viewport measurements across a software keyboard opening and
41
+ * closing, so a surface sized to the viewport follows the keyboard without
42
+ * the transitional sizes some browsers report.
43
+ *
44
+ * A viewport that shrinks at the same width while a text field has focus is
45
+ * the keyboard opening. Once the field loses focus the keyboard is closing,
46
+ * and the viewport should only grow back. Firefox for Android reports a size
47
+ * shorter than the keyboard-open one for a few frames first; while closing,
48
+ * shrinks like that are ignored until the full height returns, a text field
49
+ * takes focus again, the width changes, or `closeTimeout` passes.
50
+ *
51
+ * Feed it every measurement with {@link SoftKeyboardViewport.next} and apply
52
+ * the size it returns. Call {@link SoftKeyboardViewport.reset} when tracking
53
+ * stops.
54
+ */
55
+ export declare class SoftKeyboardViewport {
56
+ private readonly _heightWhileOpen;
57
+ private readonly _closeTimeout;
58
+ private readonly _onCloseTimeout?;
59
+ private _full;
60
+ private _applied;
61
+ private _keyboardOpen;
62
+ private _closeTimer;
63
+ constructor(options?: SoftKeyboardViewportOptions);
64
+ /** Whether the keyboard is up or still closing, as far as the measurements show. */
65
+ get keyboardOpen(): boolean;
66
+ /**
67
+ * Returns the size to apply for a fresh measurement.
68
+ *
69
+ * @param measured - the viewport as measured now
70
+ * @param textEntryFocused - whether a field that raises the keyboard has focus
71
+ */
72
+ next(measured: ViewportSize, textEntryFocused: boolean): ViewportSize;
73
+ /** Forgets the measurements so far and cancels a pending close timeout. */
74
+ reset(): void;
75
+ private _settle;
76
+ private _apply;
77
+ private _startCloseTimer;
78
+ private _clearCloseTimer;
79
+ }
@@ -0,0 +1,21 @@
1
+ /** Bounds of the portion of a top-level document currently visible to the user. */
2
+ export interface VisualViewportBounds {
3
+ /** Inline-start offset from the layout viewport in CSS pixels. */
4
+ left: number;
5
+ /** Block-start offset from the layout viewport in CSS pixels. */
6
+ top: number;
7
+ /** Visible inline size in CSS pixels. */
8
+ width: number;
9
+ /** Visible block size in CSS pixels. */
10
+ height: number;
11
+ /** Inline-end coordinate in layout-viewport CSS pixels. */
12
+ right: number;
13
+ /** Block-end coordinate in layout-viewport CSS pixels. */
14
+ bottom: number;
15
+ }
16
+ /**
17
+ * Returns visual-viewport bounds in layout-viewport coordinates.
18
+ *
19
+ * Falls back to the layout viewport when `VisualViewport` is unavailable.
20
+ */
21
+ export declare function getVisualViewportBounds($window: Window): VisualViewportBounds;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.6.0",
6
+ "version": "0.7.0",
7
7
  "description": "Shared controllers, directives, and DOM utilities for rc-webcomponents.",
8
8
  "repository": {
9
9
  "type": "git",
@@ -39,9 +39,6 @@
39
39
  "test:browser:chrome": "vitest --run --project=chromium",
40
40
  "test:browser:firefox": "vitest --run --project=firefox"
41
41
  },
42
- "dependencies": {
43
- "@oddbird/css-anchor-positioning": "^0.7.0"
44
- },
45
42
  "devDependencies": {
46
43
  "@types/node": "^25.6.0",
47
44
  "@vitest/browser-playwright": "4.1.5",