@mittwald/react-tunnel 0.1.0-alpha.213 → 0.1.0-alpha.215
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/dist/index.js +42 -42
- package/dist/types/components/TunnelEntry.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var o = (
|
|
6
|
-
import
|
|
7
|
-
import { observable as
|
|
8
|
-
import { observer as
|
|
3
|
+
var g = Object.defineProperty;
|
|
4
|
+
var E = (s, e, t) => e in s ? g(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
5
|
+
var o = (s, e, t) => E(s, typeof e != "symbol" ? e + "" : e, t);
|
|
6
|
+
import C, { useRef as f, createContext as b, useContext as m, useId as v, useLayoutEffect as w } from "react";
|
|
7
|
+
import { observable as a, makeObservable as x, action as p } from "mobx";
|
|
8
|
+
import { observer as y } from "mobx-react-lite";
|
|
9
9
|
const l = "default";
|
|
10
|
-
class
|
|
10
|
+
class c {
|
|
11
11
|
constructor() {
|
|
12
|
-
o(this, "children",
|
|
12
|
+
o(this, "children", a.map(
|
|
13
13
|
{},
|
|
14
14
|
{
|
|
15
15
|
deep: !1
|
|
16
16
|
}
|
|
17
17
|
));
|
|
18
18
|
o(this, "preparedChildren", /* @__PURE__ */ new Map());
|
|
19
|
-
|
|
20
|
-
deleteChildren:
|
|
21
|
-
setChildren:
|
|
19
|
+
x(this, {
|
|
20
|
+
deleteChildren: p.bound,
|
|
21
|
+
setChildren: p.bound
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
static useNew() {
|
|
25
|
-
return
|
|
25
|
+
return f(new c()).current;
|
|
26
26
|
}
|
|
27
|
-
setChildren(e = l,
|
|
28
|
-
var
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
setChildren(e = l, t, n) {
|
|
28
|
+
var i;
|
|
29
|
+
const r = this.children.get(e) ?? a.map({}, { deep: !1 });
|
|
30
|
+
r.set(t, n), (i = this.preparedChildren.get(e)) == null || i.delete(t), this.children.set(e, r);
|
|
31
31
|
}
|
|
32
|
-
prepareChildren(e = l,
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
prepareChildren(e = l, t, n) {
|
|
33
|
+
const r = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
34
|
+
r.set(t, n), this.preparedChildren.set(e, r);
|
|
35
35
|
}
|
|
36
|
-
deleteChildren(e = l,
|
|
37
|
-
var n,
|
|
38
|
-
(n = this.children.get(e)) == null || n.delete(
|
|
36
|
+
deleteChildren(e = l, t) {
|
|
37
|
+
var n, r;
|
|
38
|
+
(n = this.children.get(e)) == null || n.delete(t), (r = this.preparedChildren.get(e)) == null || r.delete(t);
|
|
39
39
|
}
|
|
40
40
|
getChildren(e = l) {
|
|
41
|
-
var n,
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return Array.from(
|
|
41
|
+
var n, r;
|
|
42
|
+
const t = ((n = this.children.get(e)) == null ? void 0 : n.entries()) ?? ((r = this.preparedChildren.get(e)) == null ? void 0 : r.entries());
|
|
43
|
+
if (t)
|
|
44
|
+
return Array.from(t);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
const { children: e } =
|
|
49
|
-
return /* @__PURE__ */
|
|
50
|
-
},
|
|
51
|
-
const { children: e, id:
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
}), [e,
|
|
55
|
-
},
|
|
56
|
-
const { children: e } =
|
|
47
|
+
const h = b(new c()), P = (s) => {
|
|
48
|
+
const { children: e } = s;
|
|
49
|
+
return /* @__PURE__ */ C.createElement(h.Provider, { value: c.useNew() }, e);
|
|
50
|
+
}, A = (s) => {
|
|
51
|
+
const { children: e, id: t, staticEntryId: n } = s, r = m(h), i = v(), d = n ?? i, u = f(!1);
|
|
52
|
+
return u.current || r.prepareChildren(t, d, e), w(() => (u.current = !0, r.setChildren(t, d, e), () => {
|
|
53
|
+
r.deleteChildren(t, d);
|
|
54
|
+
}), [e, t, d]), null;
|
|
55
|
+
}, R = (s) => {
|
|
56
|
+
const { children: e } = s;
|
|
57
57
|
return typeof e == "function" ? e() : e;
|
|
58
|
-
},
|
|
59
|
-
const { children: e, id:
|
|
60
|
-
return n ? n.map(([
|
|
58
|
+
}, L = y((s) => {
|
|
59
|
+
const { children: e, id: t } = s, n = m(h).getChildren(t);
|
|
60
|
+
return n ? n.map(([r, i]) => /* @__PURE__ */ C.createElement(R, { key: r }, i)) : e;
|
|
61
61
|
});
|
|
62
62
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
A as TunnelEntry,
|
|
64
|
+
L as TunnelExit,
|
|
65
|
+
P as TunnelProvider
|
|
66
66
|
};
|
|
@@ -3,6 +3,8 @@ import { TunnelChildren } from '../types';
|
|
|
3
3
|
interface Props {
|
|
4
4
|
id?: string;
|
|
5
5
|
children?: TunnelChildren;
|
|
6
|
+
/** Static entry ID instead of generated ID by `useId` */
|
|
7
|
+
staticEntryId?: string;
|
|
6
8
|
}
|
|
7
9
|
export declare const TunnelEntry: FC<Props>;
|
|
8
10
|
export default TunnelEntry;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/react-tunnel",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.215",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"react tree",
|
|
11
11
|
"teleport"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://github.com/mittwald/flow/tree/main/packages/react-tunnel",
|
|
14
14
|
"repository": "https://github.com/mittwald/flow",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"react": "^18.2.0",
|
|
59
59
|
"react-dom": "^18.2.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "507e9bf585c25bb42c3f79828c207f1419bba26f"
|
|
62
62
|
}
|