@flighthq/keyboard 0.4.0-next.1920.b93ad0f → 0.4.0-next.1932.1ef883a
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/LICENSE.md +9 -0
- package/README.md +10 -98
- package/package.json +3 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013-2026 Joshua Granick and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,105 +1,17 @@
|
|
|
1
1
|
# @flighthq/keyboard
|
|
2
2
|
|
|
3
|
-
On-screen (soft) keyboard visibility, height, and
|
|
3
|
+
On-screen (soft) keyboard visibility, height, and show/hide/resize signals over a swappable web/native backend
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
| Function | Purpose |
|
|
12
|
-
| --- | --- |
|
|
13
|
-
| `attachSoftKeyboard(keyboard)` | Start delivering backend changes to the entity's signals. Idempotent — a prior subscription is torn down first. |
|
|
14
|
-
| `createSoftKeyboard()` | Allocate a `SoftKeyboard` with inert signals. |
|
|
15
|
-
| `createSoftKeyboardInfo()` | Allocate a zeroed `SoftKeyboardInfo` to pass as `out`. |
|
|
16
|
-
| `createSoftKeyboardTransition()` | Allocate a zeroed `SoftKeyboardTransition` (`durationSeconds: 0`, `height: 0`). |
|
|
17
|
-
| `createWebSoftKeyboardBackend()` | Build the default web backend. |
|
|
18
|
-
| `detachSoftKeyboard(keyboard)` | Stop delivery and forget the subscription. Safe when not attached. |
|
|
19
|
-
| `disposeSoftKeyboard(keyboard)` | Detach the subscription so the entity is GC-eligible. |
|
|
20
|
-
| `getSoftKeyboardBackend()` | Return the active backend, lazily creating the web default. There is always a backend. |
|
|
21
|
-
| `getSoftKeyboardHeight()` | Return the current keyboard height in CSS pixels (`0` when hidden), no allocation. |
|
|
22
|
-
| `getSoftKeyboardInfo(out)` | Fill `out` with the current keyboard snapshot and return it. |
|
|
23
|
-
| `getSoftKeyboardResizeMode()` | Return the backend resize mode, or `SoftKeyboardResizeNoneKind` when unsupported. |
|
|
24
|
-
| `hideSoftKeyboard()` | Request dismissal. No-op on web unless the Chromium VirtualKeyboard API is available. |
|
|
25
|
-
| `isSoftKeyboardAccessoryBarVisible()` | Whether the iOS accessory bar is visible. `false` when unsupported. |
|
|
26
|
-
| `isSoftKeyboardScrollAssistEnabled()` | Whether scroll-assist is enabled. `false` when unsupported. |
|
|
27
|
-
| `setSoftKeyboardAccessoryBarVisible(visible)` | Show/hide the iOS accessory bar. No-op when unsupported. |
|
|
28
|
-
| `setSoftKeyboardBackend(backend)` | Install a native host backend; pass `null` to fall back to the web default. |
|
|
29
|
-
| `setSoftKeyboardResizeMode(mode)` | Set how the viewport reacts to the keyboard. No-op when unsupported. |
|
|
30
|
-
| `setSoftKeyboardScrollAssistEnabled(enabled)` | Enable/disable scroll-assist. No-op when unsupported. |
|
|
31
|
-
| `setSoftKeyboardStyle(style)` | Set the keyboard's light/dark appearance. No-op when unsupported. |
|
|
32
|
-
| `showSoftKeyboard()` | Request presentation. No-op on web unless the Chromium VirtualKeyboard API is available. |
|
|
33
|
-
|
|
34
|
-
## Signals
|
|
35
|
-
|
|
36
|
-
`attachSoftKeyboard` drives nine signals on a `SoftKeyboard`. The **will** signals fire before the animation begins and carry a `SoftKeyboardTransition` (timing + target height); the **did** signals fire after it settles and carry the settled height. The simple-path aliases (`onShow` / `onHide` / `onResize`) fire alongside their did-phase counterparts.
|
|
37
|
-
|
|
38
|
-
| Signal | Phase | Payload | Fires on |
|
|
39
|
-
| -------------- | ----- | ------------------------ | ---------------------------------------------------------- |
|
|
40
|
-
| `onWillShow` | will | `SoftKeyboardTransition` | keyboard about to appear (hidden → visible) |
|
|
41
|
-
| `onWillHide` | will | `SoftKeyboardTransition` | keyboard about to disappear (visible → hidden) |
|
|
42
|
-
| `onWillResize` | will | `SoftKeyboardTransition` | height about to change while staying visible |
|
|
43
|
-
| `onDidShow` | did | `height: number` | keyboard finished appearing |
|
|
44
|
-
| `onDidHide` | did | _(none)_ | keyboard finished disappearing |
|
|
45
|
-
| `onDidResize` | did | `height: number` | keyboard settled at a new height (fires on every did edge) |
|
|
46
|
-
| `onShow` | did | `height: number` | alias firing with `onDidShow` |
|
|
47
|
-
| `onHide` | did | _(none)_ | alias firing with `onDidHide` |
|
|
48
|
-
| `onResize` | did | `height: number` | alias firing with `onDidResize` |
|
|
49
|
-
|
|
50
|
-
The web default reports only the settled **did** phase (`durationSeconds: 0`); a native host that knows its animation timing emits the **will** phase first, so an app can animate in lockstep with the slide.
|
|
51
|
-
|
|
52
|
-
## `SoftKeyboardInfo` fields
|
|
53
|
-
|
|
54
|
-
| Field | Type | Unit | Hidden value |
|
|
55
|
-
| --------- | --------- | ------------------------- | ------------ |
|
|
56
|
-
| `visible` | `boolean` | — | `false` |
|
|
57
|
-
| `height` | `number` | CSS pixels | `0` |
|
|
58
|
-
| `x` | `number` | CSS pixels (frame origin) | `0` |
|
|
59
|
-
| `y` | `number` | CSS pixels (frame origin) | `0` |
|
|
60
|
-
| `width` | `number` | CSS pixels (frame width) | `0` |
|
|
61
|
-
|
|
62
|
-
The web backend prefers the Chromium VirtualKeyboard API's `boundingRect` for a precise frame; it otherwise infers `height` from the `window.visualViewport` shrink relative to `window.innerHeight`, reporting `y` as the viewport height and `width` as `window.innerWidth`. Where neither is present (no `window`, no `visualViewport`, no `navigator.virtualKeyboard`) it degrades to a hidden snapshot.
|
|
63
|
-
|
|
64
|
-
## Resize-mode / style matrix
|
|
65
|
-
|
|
66
|
-
These are optional backend capabilities. Each kind is an **open** string contract — a native host may register its own vendor-prefixed value (`'acme.custom'`).
|
|
67
|
-
|
|
68
|
-
| Concern | Kind constants | Web default |
|
|
69
|
-
| --- | --- | --- |
|
|
70
|
-
| Resize mode | `SoftKeyboardResizeNoneKind` (`'None'`), `SoftKeyboardResizeBodyKind` (`'Body'`) | unsupported — `getSoftKeyboardResizeMode()` returns `None`, `setSoftKeyboardResizeMode` is a no-op |
|
|
71
|
-
| Style | `SoftKeyboardStyleDefaultKind` (`'Default'`), `SoftKeyboardStyleDarkKind` (`'Dark'`) | unsupported — `setSoftKeyboardStyle` is a no-op |
|
|
72
|
-
| Accessory bar (iOS) | — | unsupported — query returns `false`, setter is a no-op |
|
|
73
|
-
| Scroll-assist | — | unsupported — query returns `false`, setter is a no-op |
|
|
74
|
-
|
|
75
|
-
## Keyboard-aware layout recipe
|
|
76
|
-
|
|
77
|
-
Animate your content in sync with the keyboard slide by listening on the **will** phase and using the transition's `durationSeconds` and target `height`. Fall back to the **did** phase for backends (the web default) that report only the settled state.
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
import { attachSoftKeyboard, createSoftKeyboard, disposeSoftKeyboard } from '@flighthq/keyboard';
|
|
81
|
-
import { connectSignal } from '@flighthq/signals';
|
|
82
|
-
|
|
83
|
-
const keyboard = createSoftKeyboard();
|
|
84
|
-
|
|
85
|
-
// Will phase: a native host that knows its timing lets you start the matching animation early.
|
|
86
|
-
connectSignal(keyboard.onWillShow, (transition) => {
|
|
87
|
-
// transition.height is the settled keyboard height; transition.durationSeconds is the slide time.
|
|
88
|
-
animateContentInset(transition.height, transition.durationSeconds);
|
|
89
|
-
});
|
|
90
|
-
connectSignal(keyboard.onWillHide, (transition) => {
|
|
91
|
-
animateContentInset(0, transition.durationSeconds);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Did phase / web fallback: snap to the settled height (durationSeconds is 0 here).
|
|
95
|
-
connectSignal(keyboard.onDidResize, (height) => {
|
|
96
|
-
animateContentInset(height, 0);
|
|
97
|
-
});
|
|
7
|
+
```sh
|
|
8
|
+
npm install @flighthq/keyboard
|
|
9
|
+
```
|
|
98
10
|
|
|
99
|
-
|
|
11
|
+
Import the supported application-facing API from `@flighthq/keyboard`. The `@flighthq/keyboard/contract` export is the wider package-to-package contract used to compose Flight itself.
|
|
100
12
|
|
|
101
|
-
|
|
102
|
-
disposeSoftKeyboard(keyboard);
|
|
103
|
-
```
|
|
13
|
+
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
104
14
|
|
|
105
|
-
|
|
15
|
+
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
+
- [Source for @flighthq/keyboard@0.4.0-next.1932.1ef883a](https://github.com/flighthq/flight/tree/1ef883a866729a9bc6f461111970f6377de1499f/packages/keyboard)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/1ef883a866729a9bc6f461111970f6377de1499f/LICENSE.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/keyboard",
|
|
3
|
-
"version": "0.4.0-next.
|
|
3
|
+
"version": "0.4.0-next.1932.1ef883a",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/signals": "0.4.0-next.
|
|
42
|
-
"@flighthq/types": "0.4.0-next.
|
|
41
|
+
"@flighthq/signals": "0.4.0-next.1932.1ef883a",
|
|
42
|
+
"@flighthq/types": "0.4.0-next.1932.1ef883a"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.3.0"
|