@lotics/ui 1.3.0 → 1.3.1
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/package.json +1 -1
- package/src/dom_portal.ts +20 -0
- package/src/dom_portal.web.ts +8 -0
- package/src/portal.tsx +1 -2
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode, ReactPortal } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Native stand-in for `react-dom`'s `createPortal`.
|
|
5
|
+
*
|
|
6
|
+
* `Portal` only calls `createPortal` inside its web (`isWeb`) branch, so on
|
|
7
|
+
* React Native this is never invoked. The file exists purely so the shared
|
|
8
|
+
* `portal.tsx` can `import { createPortal }` statically without pulling
|
|
9
|
+
* `react-dom` — which has no native build — into the Metro native bundle.
|
|
10
|
+
*
|
|
11
|
+
* Web targets resolve `dom_portal.web.ts` instead (Metro's `.web` extension
|
|
12
|
+
* resolution; Vite's `resolve.extensions`).
|
|
13
|
+
*/
|
|
14
|
+
export function createPortal(
|
|
15
|
+
_children: ReactNode,
|
|
16
|
+
_container: Element | DocumentFragment,
|
|
17
|
+
_key?: string | null,
|
|
18
|
+
): ReactPortal | null {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web variant: the real `react-dom` portal. Isolated into its own module so
|
|
3
|
+
* the native bundle (which resolves `dom_portal.ts`) never references
|
|
4
|
+
* `react-dom`. Imported statically by `portal.tsx` — no `require`, so it
|
|
5
|
+
* works under pure-ESM bundlers (Vite, used by custom-code apps) as well as
|
|
6
|
+
* Metro.
|
|
7
|
+
*/
|
|
8
|
+
export { createPortal } from "react-dom";
|
package/src/portal.tsx
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ReactNode,
|
|
12
12
|
} from "react";
|
|
13
13
|
import { Platform, View, StyleSheet } from "react-native";
|
|
14
|
+
import { createPortal } from "./dom_portal";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Cross-platform portal system inspired by Base UI and @gorhom/portal.
|
|
@@ -137,8 +138,6 @@ export function Portal({ children }: { children: ReactNode }) {
|
|
|
137
138
|
return null;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
141
|
-
const { createPortal } = require("react-dom");
|
|
142
141
|
return createPortal(children, target);
|
|
143
142
|
}
|
|
144
143
|
|