@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 CHANGED
@@ -1,66 +1,66 @@
1
1
  "use client"
2
2
  /* */
3
- var f = Object.defineProperty;
4
- var m = (i, e, r) => e in i ? f(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
5
- var o = (i, e, r) => m(i, typeof e != "symbol" ? e + "" : e, r);
6
- import a, { useRef as p, createContext as g, useContext as C, useId as E, useLayoutEffect as b } from "react";
7
- import { observable as h, makeObservable as v, action as u } from "mobx";
8
- import { observer as w } from "mobx-react-lite";
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 d {
10
+ class c {
11
11
  constructor() {
12
- o(this, "children", h.map(
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
- v(this, {
20
- deleteChildren: u.bound,
21
- setChildren: u.bound
19
+ x(this, {
20
+ deleteChildren: p.bound,
21
+ setChildren: p.bound
22
22
  });
23
23
  }
24
24
  static useNew() {
25
- return p(new d()).current;
25
+ return f(new c()).current;
26
26
  }
27
- setChildren(e = l, r, n) {
28
- var s;
29
- const t = this.children.get(e) ?? h.map({}, { deep: !1 });
30
- t.set(r, n), (s = this.preparedChildren.get(e)) == null || s.delete(r), this.children.set(e, t);
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, r, n) {
33
- const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
34
- t.set(r, n), this.preparedChildren.set(e, t);
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, r) {
37
- var n, t;
38
- (n = this.children.get(e)) == null || n.delete(r), (t = this.preparedChildren.get(e)) == null || t.delete(r);
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, t;
42
- const r = ((n = this.children.get(e)) == null ? void 0 : n.entries()) ?? ((t = this.preparedChildren.get(e)) == null ? void 0 : t.entries());
43
- if (r)
44
- return Array.from(r);
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 c = g(new d()), M = (i) => {
48
- const { children: e } = i;
49
- return /* @__PURE__ */ a.createElement(c.Provider, { value: d.useNew() }, e);
50
- }, N = (i) => {
51
- const { children: e, id: r } = i, n = C(c), t = E(), s = p(!1);
52
- return s.current || n.prepareChildren(r, t, e), b(() => (s.current = !0, n.setChildren(r, t, e), () => {
53
- n.deleteChildren(r, t);
54
- }), [e, r, t]), null;
55
- }, x = (i) => {
56
- const { children: e } = i;
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
- }, P = w((i) => {
59
- const { children: e, id: r } = i, n = C(c).getChildren(r);
60
- return n ? n.map(([t, s]) => /* @__PURE__ */ a.createElement(x, { key: t }, s)) : e;
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
- N as TunnelEntry,
64
- P as TunnelExit,
65
- M as TunnelProvider
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.213",
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://mittwald.github.io/flow",
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": "55762085349b863e540002372c91cb08b68e41c4"
61
+ "gitHead": "507e9bf585c25bb42c3f79828c207f1419bba26f"
62
62
  }