react-iframe-plugin 0.1.2 → 0.1.3

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