react-iframe-plugin 0.1.3 → 0.1.5

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.d.ts CHANGED
@@ -3,10 +3,10 @@ interface IframePluginProps {
3
3
  src: string;
4
4
  title?: string;
5
5
  width?: string;
6
- height: string;
6
+ height?: string;
7
7
  types?: string;
8
8
  iframeDomain: string;
9
- basicHeight: string;
9
+ basicHeight?: string;
10
10
  url: string;
11
11
  newWindow?: boolean;
12
12
  zIndex?: string;
package/dist/index.es.js CHANGED
@@ -1,129 +1,114 @@
1
- import { jsx as l, Fragment as b, jsxs as B } from "react/jsx-runtime";
2
- import { useState as h, useRef as D, useEffect as y } from "react";
3
- const L = (E) => {
4
- const [a, m] = h("250px"), [f, S] = h("250px"), {
5
- zIndex: u,
6
- newWindow: s,
1
+ import { jsx as l, Fragment as b } from "react/jsx-runtime";
2
+ import { useState as d, useRef as B, useEffect as w } from "react";
3
+ const L = (x) => {
4
+ const [m, h] = d("250px"), [E, S] = d("250px"), {
5
+ zIndex: y,
6
+ newWindow: a,
7
7
  url: c,
8
8
  basicHeight: o,
9
9
  iframeDomain: n,
10
10
  // currentDomain,
11
- types: r,
12
- src: g,
13
- title: p,
14
- width: w,
15
- height: d
16
- } = E, i = D(!1), [F, I] = h(!1);
17
- y(() => {
18
- const t = r == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin");
11
+ types: i,
12
+ src: f,
13
+ title: u,
14
+ width: g,
15
+ height: s
16
+ } = x, r = B(!1), [F, H] = d(!1);
17
+ w(() => {
18
+ const t = i == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin");
19
19
  console.log(
20
20
  87878787,
21
21
  t.contentWindow,
22
22
  // currentDomain,
23
23
  n,
24
24
  c,
25
- d,
25
+ s,
26
26
  o,
27
- s
27
+ a
28
28
  ), t.addEventListener("load", function() {
29
- console.log("currentDomain────────────", o), m(o || "250px");
29
+ console.log("currentDomain────────────", o), h(o || "250px");
30
30
  const e = window.location.origin;
31
31
  e && t.contentWindow.postMessage(
32
32
  {
33
33
  currentDomain: e,
34
34
  iframeDomain: n || "http://localhost:8086",
35
35
  url: c || "http://localhost:8081",
36
- height: d || "800px",
36
+ height: s || "800px",
37
37
  basicHeight: o,
38
- newWindow: s || !0
38
+ newWindow: a || !0
39
39
  },
40
40
  n || "http://localhost:8086"
41
- ), x(), window.addEventListener("scroll", (W) => {
42
- x();
41
+ ), p(), window.addEventListener("scroll", (D) => {
42
+ p();
43
43
  });
44
44
  }), window.addEventListener("message", function(e) {
45
45
  console.log("message", e), console.log(
46
46
  "plugin Fetch iframe:",
47
47
  e.data.height,
48
48
  e.data.footerHeight
49
- ), e.data && (e.data.height && m(e.data.height || o), e.data.footerHeight && S(e.data.footerHeight));
49
+ ), e.data && (e.data.height && h(e.data.height || o), e.data.footerHeight && S(e.data.footerHeight));
50
50
  });
51
51
  }, []);
52
- const H = () => (document.scrollingElement || document.documentElement).scrollTop, x = () => {
53
- var t = H();
54
- t > Number(a.replace("px", "")) ? i.current = !0 : i.current = !1, I(i.current);
52
+ const I = () => (document.scrollingElement || document.documentElement).scrollTop, p = () => {
53
+ var t = I();
54
+ t > Number(m.replace("px", "")) ? r.current = !0 : r.current = !1, H(r.current);
55
55
  };
56
- return y(() => {
57
- console.log("isScroll", i.current), (r == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin")).contentWindow.postMessage(
56
+ return w(() => {
57
+ console.log("isScroll", r.current), (i == "footer" ? document.getElementById("iframeFooter") : document.getElementById("iframePlugin")).contentWindow.postMessage(
58
58
  {
59
59
  currentDomain: window.location.origin,
60
60
  iframeDomain: n || "http://localhost:8086",
61
61
  url: c || "http://localhost:8081",
62
- height: d || "800px",
62
+ height: s || "800px",
63
63
  basicHeight: o,
64
- newWindow: s || !0,
65
- isScroll: i.current
64
+ newWindow: a || !0,
65
+ isScroll: r.current
66
66
  },
67
67
  n || "http://localhost:8086"
68
68
  );
69
- }, [F]), /* @__PURE__ */ l(b, { children: /* @__PURE__ */ B(
69
+ }, [F]), /* @__PURE__ */ l(b, { children: /* @__PURE__ */ l(
70
70
  "div",
71
71
  {
72
72
  style: {
73
73
  width: "100%",
74
74
  position: "relative",
75
- zIndex: u || 999,
76
- paddingBottom: r === "footer" ? "0px" : "250px"
75
+ zIndex: y || 999,
76
+ paddingBottom: i === "footer" ? "0px" : "250px"
77
77
  },
78
- children: [
79
- /* @__PURE__ */ l(
80
- "div",
81
- {
82
- style: {
83
- position: "absolute",
84
- left: "30%",
85
- top: 0,
86
- color: "white",
87
- zIndex: u || 999
88
- },
89
- children: r === "footer" ? f : a
90
- }
91
- ),
92
- r === "footer" ? /* @__PURE__ */ l(
93
- "iframe",
94
- {
95
- id: "iframeFooter",
96
- src: g,
97
- title: p,
98
- width: w,
99
- height: f,
100
- style: {
101
- border: "none",
102
- width: "100vw",
103
- background: "transparent"
104
- },
105
- allowFullScreen: !0
106
- }
107
- ) : /* @__PURE__ */ l(
108
- "iframe",
109
- {
110
- id: "iframePlugin",
111
- src: g,
112
- title: p,
113
- width: w,
114
- height: a,
115
- style: {
116
- border: "none",
117
- width: "100vw",
118
- background: "transparent",
119
- position: "fixed",
120
- top: 0,
121
- left: 0
122
- },
123
- allowFullScreen: !0
124
- }
125
- )
126
- ]
78
+ children: i === "footer" ? /* @__PURE__ */ l(
79
+ "iframe",
80
+ {
81
+ id: "iframeFooter",
82
+ src: f,
83
+ title: u,
84
+ width: g,
85
+ height: E,
86
+ style: {
87
+ border: "none",
88
+ width: "100vw",
89
+ background: "transparent"
90
+ },
91
+ allowFullScreen: !0
92
+ }
93
+ ) : /* @__PURE__ */ l(
94
+ "iframe",
95
+ {
96
+ id: "iframePlugin",
97
+ src: f,
98
+ title: u,
99
+ width: g,
100
+ height: m,
101
+ style: {
102
+ border: "none",
103
+ width: "100vw",
104
+ background: "transparent",
105
+ position: "fixed",
106
+ top: 0,
107
+ left: 0
108
+ },
109
+ allowFullScreen: !0
110
+ }
111
+ )
127
112
  }
128
113
  ) });
129
114
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-iframe-plugin",
3
3
  "private": false,
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "scripts": {
6
6
  "dev": "vite",
7
7
  "lint": "eslint .",