@onekeyfe/react-native-native-overlay 6.7.0-46 → 6.7.0-48

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 (2) hide show
  1. package/README.md +119 -21
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,35 +1,133 @@
1
+ <div align="center">
2
+
1
3
  # @onekeyfe/react-native-native-overlay
2
4
 
3
- Native and Web overlay hosts with ordered levels, page scope, lifecycle events,
4
- keyboard avoidance and Fabric measurement. See [SPEC](docs/SPEC.md) for the
5
- behavioral contract, platform differences and outstanding runtime acceptance.
5
+ **Overlay hosts that draw above the app on iOS, Android and Web while keeping the caller's React subtree and hit testing intact.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/%40onekeyfe%2Freact-native-native-overlay?label=npm&color=4D6BFE)](https://www.npmjs.com/package/@onekeyfe/react-native-native-overlay)
8
+ [![license](https://img.shields.io/npm/l/%40onekeyfe%2Freact-native-native-overlay?label=license&color=4D6BFE)](LICENSE)
9
+ ![iOS](https://img.shields.io/badge/iOS-000000?logo=apple&logoColor=white)
10
+ ![Android](https://img.shields.io/badge/Android-3DDC84?logo=android&logoColor=white)
11
+ ![Web](https://img.shields.io/badge/Web-4285F4?logo=googlechrome&logoColor=white)
12
+ ![Fabric](https://img.shields.io/badge/Fabric-4D6BFE)
13
+
14
+ </div>
15
+
16
+ Owns where an overlay is drawn, which overlay is on top and how it enters and
17
+ exits. Levels are fixed (`modal`, `hardware`, `secure`, `toast`, `lock`,
18
+ `debug`), each entry picks a `global` or `page` scope and a lane strategy, and
19
+ the native host reparents the caller's content so React context, refs and
20
+ `measureInWindow` keep working. Sheet, center, fullscreen, toast and anchored
21
+ presentations are available; the application owns the content and business UI.
22
+
23
+ ## Features
24
+
25
+ - **Predictable ordering** — every page entry renders below every global entry,
26
+ and inside a scope entries sort by level and then by request order.
27
+ - **Lane strategies** — `stack`, `queue` and `replace` apply per
28
+ (scope, host, level) lane, with `priority`, `replaceKey` and de-duplicated ids.
29
+ - **Preserved React identity** — the overlay view stays where the caller
30
+ rendered it; native code moves its content into the host, so there is no
31
+ portal that drops context.
32
+ - **Page scope that covers chrome** — `OverlayPageHost` as the last child of a
33
+ root route lets page overlays cover native headers and the tab bar.
34
+ - **Native presentation and motion** — sheet drag, back handling, keyboard
35
+ avoidance, status bar styling and configurable enter/exit animations.
36
+ - **Web parity** — the Web implementation portals into z-indexed level layers
37
+ with a focus trap and page isolation.
38
+
39
+ ## Installation
40
+
41
+ ```sh
42
+ yarn add @onekeyfe/react-native-native-overlay
43
+ ```
44
+
45
+ The native hosts are React Native Fabric codegen components, not Nitro views.
46
+ Install the app's iOS pods and rebuild the native application after adding the
47
+ package. Web additionally needs `react-dom`; it is declared as an optional peer
48
+ dependency.
49
+
50
+ ## Usage
6
51
 
7
52
  ```tsx
8
- import { OverlayView } from '@onekeyfe/react-native-native-overlay';
53
+ import { useState } from 'react';
54
+ import {
55
+ OverlayPageHost,
56
+ OverlayView,
57
+ } from '@onekeyfe/react-native-native-overlay';
9
58
 
10
- <OverlayView open={open} presentation="sheet" level="modal">
11
- {content}
12
- </OverlayView>;
59
+ function MainRoute() {
60
+ const [visible, setVisible] = useState(false);
61
+ return (
62
+ <>
63
+ {screen}
64
+ <OverlayView
65
+ visible={visible}
66
+ presentation="sheet"
67
+ level="modal"
68
+ sheet={{ dismissOnPanDown: true, cornerRadius: 24 }}
69
+ onRequestDismiss={() => setVisible(false)}
70
+ >
71
+ {content}
72
+ </OverlayView>
73
+ {/* Last child of the root route, after its navigator. */}
74
+ <OverlayPageHost hostKey="main" />
75
+ </>
76
+ );
77
+ }
13
78
  ```
14
79
 
15
- Global levels are ordered modal, hardware, secure, toast, lock, then debug.
16
- React context stays attached to the original subtree while the native host
17
- reparents its contents. Page overlays use `OverlayPageHost` and
18
- `OverlayPageHostScope` / `OverlayPageOwnerScope`. Android and iOS require the React Native new
19
- architecture; Web additionally requires `react-dom`.
80
+ The application still owns `visible` and the content. `scope="page"` resolves
81
+ `hostKey`/`ownerKey` from the nearest `OverlayPageHostScope` and
82
+ `OverlayPageOwnerScope` providers.
83
+
84
+ ## API
85
+
86
+ | Export | Shape | Description | Platforms |
87
+ | --- | --- | --- | :-: |
88
+ | `OverlayView` | component | Declarative overlay: `visible`, `scope`, `level`, `strategy`, `priority`, `replaceKey`, `presentation`, `sheet`, `animation`, `backdrop`, `blocking`, `keepContentMounted`, `statusBarStyle`, `contentSize`, dismiss/present callbacks. | iOS, Android, Web |
89
+ | `OverlayPageHost` | component | Renders the page-scope overlays of one root route from `hostKey`. | iOS, Android, Web |
90
+ | `OverlayPageHostScope`, `OverlayPageOwnerScope` | providers | Supply `hostKey` per root route and `ownerKey` per page. | iOS, Android, Web |
91
+ | `overlayStore` | store | Imperative `request`, `dismiss`, `finalize`, `reopen`, `dismissAll`, `setPageVisible`, `removePage`, `resolveBack`. | iOS, Android, Web |
92
+ | `OverlayRequestError` | error class | Thrown for invalid requests such as a page entry without keys. | iOS, Android, Web |
93
+ | `OVERLAY_LEVELS`, `OVERLAY_LEVEL_ORDER` | constants | The level list and their numeric order. | iOS, Android, Web |
94
+ | `resolveOverlayAnimation`, `OVERLAY_MOTION_PRESETS`, `NATIVE_MOTION_PRESETS`, `WEB_MOTION_PRESETS` | helpers | Resolve animation configs per platform. | iOS, Android, Web |
95
+
96
+ `presentation` accepts `sheet`, `center`, `fullscreen`, `toast` and `anchored`.
97
+ `strategy` accepts `stack`, `queue` and `replace`. See
98
+ [`docs/SPEC.md`](docs/SPEC.md) for the ownership model, platform differences and
99
+ acceptance record.
100
+
101
+ ## Platform support
102
+
103
+ | Capability | iOS | Android | Web |
104
+ | --- | :-: | :-: | :-: |
105
+ | Global overlays and level ordering | ✅ | ✅ | ✅ |
106
+ | Page scope via `OverlayPageHost` | ✅ | ✅ | ✅ |
107
+ | Sheet presentation | ✅ | ✅ | ✅ |
108
+ | Keyboard avoidance | ✅ | ✅ | ✅ |
109
+ | `windowOffsetRequest` for modal-relative anchors | ✅ | — | — |
110
+ | `contentSize` for pre-rotation layout | ✅ | ✅ | — |
111
+ | Status bar styling | ✅ | ✅ | — |
112
+
113
+ ## Caveats
20
114
 
21
- ## Development
115
+ > [!IMPORTANT]
116
+ > Page-scope entries need both `hostKey` and `ownerKey`. A declarative
117
+ > `OverlayView` waits until the nearest scope providers supply them, but a
118
+ > direct `overlayStore.request` with a missing key throws `OverlayRequestError`.
22
119
 
23
- Run `yarn typecheck`, `yarn lint`, `yarn test --runInBand`, and `yarn prepare`.
24
- This package was initialized from the repository view template and retains
25
- Fabric rather than Nitro under the explicit exception recorded in the SPEC.
120
+ > [!NOTE]
121
+ > The `windowOffsetRequest`/`onWindowOffset` and `contentSize` props are
122
+ > native-only layout aids; they do nothing on Web. On Web the overlay portals
123
+ > into a level layer and relies on `react-dom`.
26
124
 
27
- ## Release
125
+ ## References
28
126
 
29
- Use the repository `package-publish` CI workflow. This branch's synchronized
30
- 42-package batch is `3.0.162-alpha.270`, published under `next`; no PR merge or
31
- stable-tag change is required. Consumers must pin the exact verified version.
127
+ - [Package spec](docs/SPEC.md)
128
+ - [Public exports](src/index.ts)
129
+ - [Changelog](../../CHANGELOG.md)
32
130
 
33
131
  ## License
34
132
 
35
- MIT
133
+ MIT. See [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-overlay",
3
- "version": "6.7.0-46",
3
+ "version": "6.7.0-48",
4
4
  "description": "Native and Web overlay hosts with ordered levels, page scope and Fabric measurement",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",