@rcarls/rc-common 0.5.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.
- package/CHANGELOG.md +315 -0
- package/README.md +167 -50
- package/dist/modules/ActiveDescendantController.js +89 -0
- package/dist/modules/AnchorController.js +317 -0
- package/dist/modules/ControllerEffects.js +60 -0
- package/dist/modules/DragController.js +128 -0
- package/dist/modules/DragGestureController.js +174 -0
- package/dist/modules/FlowController.js +35 -0
- package/dist/modules/ItemsCollectionController.js +233 -0
- package/dist/modules/KeyboardInteractionDirective.js +39 -0
- package/dist/modules/KeyboardNavigationDirective.js +88 -0
- package/dist/modules/LiveAnnouncer.js +36 -0
- package/dist/modules/MutationObserverController.js +30 -0
- package/dist/modules/NavigationIndicatorController.js +81 -0
- package/dist/modules/PopoverController.js +44 -0
- package/dist/modules/RafScheduler.js +83 -0
- package/dist/modules/ReorderController.js +361 -0
- package/dist/modules/ResizeController.js +425 -0
- package/dist/modules/RovingTabIndexMixin.js +87 -0
- package/dist/modules/ScrollObserverController.js +78 -0
- package/dist/modules/TypeaheadController.js +59 -0
- package/dist/modules/anchorPlacement.js +13 -0
- package/dist/modules/clickDelegate.js +31 -0
- package/dist/modules/cssText.js +6 -0
- package/dist/modules/cssTime.js +11 -0
- package/dist/modules/cssZoom.js +16 -0
- package/dist/modules/findNearestScrollAncestor.js +22 -0
- package/dist/modules/flow.js +94 -0
- package/dist/modules/isFocusable.js +6 -0
- package/dist/modules/localeFormat.js +38 -0
- package/dist/modules/messages.js +77 -0
- package/dist/modules/nativeChild.js +37 -0
- package/dist/modules/observeLocale.js +70 -0
- package/dist/modules/sliderUtils.js +14 -0
- package/dist/modules/snapUtils.js +25 -0
- package/dist/modules/softKeyboard.js +72 -0
- package/dist/modules/visualViewport.js +14 -0
- package/dist/rc-common.js +99 -1575
- package/dist/rc-common.umd.cjs +10 -26
- package/dist/types/AnchorController.d.ts +82 -12
- package/dist/types/ControllerEffects.d.ts +15 -0
- package/dist/types/DragController.d.ts +13 -0
- package/dist/types/DragGestureController.d.ts +31 -7
- package/dist/types/FlowController.d.ts +31 -0
- package/dist/types/ItemsCollectionController.d.ts +3 -2
- package/dist/types/KeyboardInteractionDirective.d.ts +1 -2
- package/dist/types/KeyboardNavigationDirective.d.ts +16 -7
- package/dist/types/LiveAnnouncer.d.ts +22 -0
- package/dist/types/MutationObserverController.d.ts +0 -1
- package/dist/types/NavigationIndicatorController.d.ts +1 -1
- package/dist/types/PopoverController.d.ts +21 -0
- package/dist/types/RafScheduler.d.ts +36 -1
- package/dist/types/ReorderController.d.ts +131 -0
- package/dist/types/ResizeController.d.ts +46 -0
- package/dist/types/RovingTabIndexMixin.d.ts +1 -1
- package/dist/types/ScrollObserverController.d.ts +13 -2
- package/dist/types/TypeaheadController.d.ts +8 -2
- package/dist/types/anchorPlacement.d.ts +24 -0
- package/dist/types/clickDelegate.d.ts +69 -0
- package/dist/types/cssText.d.ts +17 -0
- package/dist/types/cssTime.d.ts +14 -0
- package/dist/types/cssZoom.d.ts +12 -0
- package/dist/types/findNearestScrollAncestor.d.ts +3 -3
- package/dist/types/flow.d.ts +121 -0
- package/dist/types/index.d.ts +33 -20
- package/dist/types/localeFormat.d.ts +4 -0
- package/dist/types/messages.d.ts +105 -0
- package/dist/types/nativeChild.d.ts +0 -3
- package/dist/types/observeLocale.d.ts +23 -0
- package/dist/types/softKeyboard.d.ts +79 -0
- package/dist/types/visualViewport.d.ts +21 -0
- package/package.json +1 -4
- package/dist/css-anchor-positioning-fn-hFYJeBk4.js +0 -6371
- package/dist/types/DragGestureController.test.d.ts +0 -1
- package/dist/types/KeyboardInteractionDirective.test.d.ts +0 -1
- package/dist/types/KeyboardNavigationDirective.test.d.ts +0 -1
- package/dist/types/MouseMoveDirective.d.ts +0 -42
- package/dist/types/MouseMoveDirective.test.d.ts +0 -1
- package/dist/types/MutationObserverController.test.d.ts +0 -1
- package/dist/types/RafScheduler.test.d.ts +0 -1
- package/dist/types/ScrollObserverController.test.d.ts +0 -1
- package/dist/types/TypeaheadController.test.d.ts +0 -1
- package/dist/types/isFocusable.test.d.ts +0 -1
- package/dist/types/nativeChild.test.d.ts +0 -1
- package/dist/types/snapUtils.unit.test.d.ts +0 -1
|
@@ -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
|
+
"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",
|