qureal-editor 1.0.13 → 1.0.14
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.es.js +15 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -106,7 +106,11 @@ function QurealViewer(_ref) {
|
|
|
106
106
|
_ref$style = _ref.style,
|
|
107
107
|
style = _ref$style === undefined ? {} : _ref$style,
|
|
108
108
|
_ref$actionRef = _ref.actionRef,
|
|
109
|
-
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef
|
|
109
|
+
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef,
|
|
110
|
+
_ref$organization = _ref.organization,
|
|
111
|
+
organization = _ref$organization === undefined ? null : _ref$organization,
|
|
112
|
+
_ref$person = _ref.person,
|
|
113
|
+
person = _ref$person === undefined ? null : _ref$person;
|
|
110
114
|
|
|
111
115
|
|
|
112
116
|
var sendToIFrame = function sendToIFrame(msg) {
|
|
@@ -149,6 +153,16 @@ function QurealViewer(_ref) {
|
|
|
149
153
|
}
|
|
150
154
|
}, [actionRef]);
|
|
151
155
|
|
|
156
|
+
useEffect(function () {
|
|
157
|
+
sendToIFrame({
|
|
158
|
+
message_type: "SET_ICTX",
|
|
159
|
+
data: {
|
|
160
|
+
organization: organization,
|
|
161
|
+
person: person
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}, [organization, person]);
|
|
165
|
+
|
|
152
166
|
useEffect(function () {
|
|
153
167
|
var handler = function handler(ev) {
|
|
154
168
|
if (ALLOWED_ORIGINS.includes(ev.origin) && _typeof(ev.data) === "object") {
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {}\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n if ([\"DOWNLOAD\", \"SHARE\"].includes(actionRef.type)) {\n sendToIFrame({\n message_type: actionRef.type,\n data: actionRef.data || {}\n })\n }\n }, [actionRef])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}","import { useState } from \"react\"\n\nfunction useQurealActions() {\n const [actionRef, setActionRef] = useState({});\n\n function download() {\n setActionRef({\n type: \"DOWNLOAD\",\n data: {}\n })\n }\n\n\n function share() {\n setActionRef({\n type: \"SHARE\",\n data: {}\n })\n }\n\n return { actionRef, download, share }\n}\n\nexport default useQurealActions;"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","actionRef","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","includes","data","handler","ev","origin","babelHelpers.typeof","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join","useQurealActions","useState","setActionRef","download","share"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;QAAvDC,IAAuD,QAAvDA,IAAuD;QAAjDC,OAAiD,QAAjDA,OAAiD;QAAxCC,KAAwC,QAAxCA,KAAwC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B;0BAAdC,KAAc;QAAdA,KAAc,8BAAN,EAAM;;;WAIvE;gBAAA;;;gBAEW,eADP;mBAEU;;cAEN,KAAKD,SAAS,UAAT,sCAAuDH,IAAvD,UAA+DC,UAAU,UAAV,GAAuB,EAAtF,IAA2FC,KAA3F,mCAAmIF;;cAExI;uBACW,MADX;wBAEY;eACLI,KAHP;;KARZ;;;;AAmBJ,qBAAeC,MAAMC,IAAN,CAAWP,YAAX,EAAyB;WAAM,IAAN;CAAzB,CAAf;;ACtBA,IAAMQ,kBAAkB,CAAC,yBAAD,EAA4B,uBAA5B,CAAxB;;AAEA,SAASC,YAAT,
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {},\n organization = null,\n person = null\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n if ([\"DOWNLOAD\", \"SHARE\"].includes(actionRef.type)) {\n sendToIFrame({\n message_type: actionRef.type,\n data: actionRef.data || {}\n })\n }\n }, [actionRef])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"SET_ICTX\",\n data: {\n organization: organization,\n person: person\n }\n })\n }, [organization, person])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}","import { useState } from \"react\"\n\nfunction useQurealActions() {\n const [actionRef, setActionRef] = useState({});\n\n function download() {\n setActionRef({\n type: \"DOWNLOAD\",\n data: {}\n })\n }\n\n\n function share() {\n setActionRef({\n type: \"SHARE\",\n data: {}\n })\n }\n\n return { actionRef, download, share }\n}\n\nexport default useQurealActions;"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","actionRef","organization","person","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","includes","data","handler","ev","origin","babelHelpers.typeof","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join","useQurealActions","useState","setActionRef","download","share"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;QAAvDC,IAAuD,QAAvDA,IAAuD;QAAjDC,OAAiD,QAAjDA,OAAiD;QAAxCC,KAAwC,QAAxCA,KAAwC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B;0BAAdC,KAAc;QAAdA,KAAc,8BAAN,EAAM;;;WAIvE;gBAAA;;;gBAEW,eADP;mBAEU;;cAEN,KAAKD,SAAS,UAAT,sCAAuDH,IAAvD,UAA+DC,UAAU,UAAV,GAAuB,EAAtF,IAA2FC,KAA3F,mCAAmIF;;cAExI;uBACW,MADX;wBAEY;eACLI,KAHP;;KARZ;;;;AAmBJ,qBAAeC,MAAMC,IAAN,CAAWP,YAAX,EAAyB;WAAM,IAAN;CAAzB,CAAf;;ACtBA,IAAMQ,kBAAkB,CAAC,yBAAD,EAA4B,uBAA5B,CAAxB;;AAEA,SAASC,YAAT,OAUG;yBATCR,IASD;QATCA,IASD,6BATQ,WASR;4BARCC,OAQD;QARCA,OAQD,gCARW,KAQX;4BAPCQ,OAOD;QAPCA,OAOD,gCAPW,EAOX;yBANCN,IAMD;QANCA,IAMD,6BANQ,UAMR;iCALCO,YAKD;QALCA,YAKD,qCALgB,YAAM,EAKtB;0BAJCN,KAID;QAJCA,KAID,8BAJS,EAIT;8BAHCO,SAG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AxB,EAAmCL,OAAnC;eACO;mBAAMM,OAAOC,mBAAP,CAA2B,SAA3B,EAAsCP,OAAtC,CAAN;SAAP;KAfJ,EAgBG,EAhBH;;WAmBI,oBAAC1B,cAAD;cACUC,IADV;iBAEaC,OAFb;eAGWgC,QAAQxB,OAAR,CAHX;cAIUN,IAJV;eAKWC;MANf;;;AAeJ,SAAS6B,OAAT,CAAiBC,GAAjB,EAAsB;QACZC,aAAa,SAAbA,UAAa,CAACC,MAAD,EAASF,GAAT,EAAiB;eACzBG,OAAOC,IAAP,CAAYJ,GAAZ,EACFK,GADE,CACE,eAAO;gBACFC,QAAQN,IAAIO,GAAJ,CAAd;gBACMC,cAAcN,SAAYA,MAAZ,SAAsBK,GAAtB,GAA8BA,GAAlD;gBACI,QAAOD,KAAP,yCAAOA,KAAP,OAAiB,QAAjB,IAA6BA,UAAU,IAA3C,EAAiD;uBACtCL,WAAWO,WAAX,EAAwBF,KAAxB,CAAP;aADJ,MAEO;uBACOE,WAAV,SAAyBF,KAAzB;;SAPL,EAUFG,IAVE,CAUG,GAVH,CAAP;KADJ;;WAcOR,WAAW,EAAX,EAAeD,GAAf,CAAP;;;ACjHJ,SAASU,gBAAT,GAA4B;oBACUC,SAAS,EAAT,CADV;;QACjBlC,SADiB;QACNmC,YADM;;aAGfC,QAAT,GAAoB;qBACH;kBACH,UADG;kBAEH;SAFV;;;aAOKC,KAAT,GAAiB;qBACA;kBACH,OADG;kBAEH;SAFV;;;WAMG,EAAErC,oBAAF,EAAaoC,kBAAb,EAAuBC,YAAvB,EAAP;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -113,7 +113,11 @@ function QurealViewer(_ref) {
|
|
|
113
113
|
_ref$style = _ref.style,
|
|
114
114
|
style = _ref$style === undefined ? {} : _ref$style,
|
|
115
115
|
_ref$actionRef = _ref.actionRef,
|
|
116
|
-
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef
|
|
116
|
+
actionRef = _ref$actionRef === undefined ? {} : _ref$actionRef,
|
|
117
|
+
_ref$organization = _ref.organization,
|
|
118
|
+
organization = _ref$organization === undefined ? null : _ref$organization,
|
|
119
|
+
_ref$person = _ref.person,
|
|
120
|
+
person = _ref$person === undefined ? null : _ref$person;
|
|
117
121
|
|
|
118
122
|
|
|
119
123
|
var sendToIFrame = function sendToIFrame(msg) {
|
|
@@ -156,6 +160,16 @@ function QurealViewer(_ref) {
|
|
|
156
160
|
}
|
|
157
161
|
}, [actionRef]);
|
|
158
162
|
|
|
163
|
+
React.useEffect(function () {
|
|
164
|
+
sendToIFrame({
|
|
165
|
+
message_type: "SET_ICTX",
|
|
166
|
+
data: {
|
|
167
|
+
organization: organization,
|
|
168
|
+
person: person
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}, [organization, person]);
|
|
172
|
+
|
|
159
173
|
React.useEffect(function () {
|
|
160
174
|
var handler = function handler(ev) {
|
|
161
175
|
if (ALLOWED_ORIGINS.includes(ev.origin) && _typeof(ev.data) === "object") {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {}\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n if ([\"DOWNLOAD\", \"SHARE\"].includes(actionRef.type)) {\n sendToIFrame({\n message_type: actionRef.type,\n data: actionRef.data || {}\n })\n }\n }, [actionRef])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}","import { useState } from \"react\"\n\nfunction useQurealActions() {\n const [actionRef, setActionRef] = useState({});\n\n function download() {\n setActionRef({\n type: \"DOWNLOAD\",\n data: {}\n })\n }\n\n\n function share() {\n setActionRef({\n type: \"SHARE\",\n data: {}\n })\n }\n\n return { actionRef, download, share }\n}\n\nexport default useQurealActions;"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","actionRef","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","includes","data","handler","ev","origin","babelHelpers.typeof","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join","useQurealActions","useState","setActionRef","download","share"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;QAAvDC,IAAuD,QAAvDA,IAAuD;QAAjDC,OAAiD,QAAjDA,OAAiD;QAAxCC,KAAwC,QAAxCA,KAAwC;yBAAjCC,IAAiC;QAAjCA,IAAiC,6BAA1B,UAA0B;0BAAdC,KAAc;QAAdA,KAAc,8BAAN,EAAM;;;WAIvEC;sBAAA;;;gBAEW,eADP;mBAEU;;cAEN,KAAKF,SAAS,UAAT,sCAAuDH,IAAvD,UAA+DC,UAAU,UAAV,GAAuB,EAAtF,IAA2FC,KAA3F,mCAAmIF;;cAExI;uBACW,MADX;wBAEY;eACLI,KAHP;;KARZ;;;;AAmBJ,qBAAeC,eAAMC,IAAN,CAAWP,YAAX,EAAyB;WAAM,IAAN;CAAzB,CAAf;;ACtBA,IAAMQ,kBAAkB,CAAC,yBAAD,EAA4B,uBAA5B,CAAxB;;AAEA,SAASC,YAAT,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/QurealiFrame.js","../src/QurealViewer.js","../src/use-action.js"],"sourcesContent":["import React, { Fragment, useEffect, useRef } from \"react\";\n\n\nfunction QurealiFrame({ slug, preview, query, type = \"creation\", style = {} }) {\n\n\n return (\n <Fragment>\n <iframe\n id=\"qureal_iframe\"\n title=\"Qureal\"\n // src={`http://localhost:3201/embed/${creation_slug}`}\n src={type === \"creation\" ? `https://show.qureal.com/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n // src={type === \"creation\" ? `http://localhost:3201/embed/${slug}?${preview ? \"preview&\" : \"\"}${query}` : `https://show.qureal.com/ts/${slug}`}\n style={{\n width: \"100%\",\n height: \"100vh\",\n ...style\n }}\n />\n </Fragment>\n );\n}\n\n// export default QurealiFrame;\nexport default React.memo(QurealiFrame, () => true)\n","import React, { Fragment, useEffect, useRef } from \"react\";\nimport QurealiFrame from \"./QurealiFrame\";\n\nconst ALLOWED_ORIGINS = [\"https://show.qureal.com\", \"http://localhost:3201\"];\n\nfunction QurealViewer({\n slug = \"qi_sample\",\n preview = false,\n prefill = {},\n type = \"creation\", // creation or template \n onFormSubmit = () => { },\n style = {},\n actionRef = {},\n organization = null,\n person = null\n}) {\n\n const sendToIFrame = (msg) => {\n console.log(\"Sending data to iFrame\")\n const qureal_element = document.getElementById(\"qureal_iframe\");\n\n const qureal_window = qureal_element ? qureal_element.contentWindow : null;\n if (qureal_window) {\n qureal_window.postMessage(msg, \"*\");\n console.log(\"Data sent to iframe\")\n }\n }\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"OPEN_CREATION\",\n data: {\n slug: slug,\n preview: preview,\n prefill: prefill\n }\n })\n }, [slug, preview])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"PREFILL\",\n data: {\n prefill: prefill\n }\n })\n }, [prefill])\n\n useEffect(() => {\n if ([\"DOWNLOAD\", \"SHARE\"].includes(actionRef.type)) {\n sendToIFrame({\n message_type: actionRef.type,\n data: actionRef.data || {}\n })\n }\n }, [actionRef])\n\n useEffect(() => {\n sendToIFrame({\n message_type: \"SET_ICTX\",\n data: {\n organization: organization,\n person: person\n }\n })\n }, [organization, person])\n\n useEffect(() => {\n const handler = (ev) => {\n if (ALLOWED_ORIGINS.includes(ev.origin) && typeof ev.data === \"object\") {\n switch (ev.data.event_type) {\n case \"FORM_SUBMIT\":\n onFormSubmit(ev.data.data);\n break;\n default:\n console.log(\"No event type found\");\n console.log(ev.data);\n }\n }\n };\n\n window.addEventListener(\"message\", handler);\n return () => window.removeEventListener(\"message\", handler);\n }, []);\n\n return (\n <QurealiFrame\n slug={slug}\n preview={preview}\n query={queryfy(prefill)}\n type={type}\n style={style}\n />\n );\n}\n\n// export default QurealiFrame;\nexport default QurealViewer\n\n\nfunction queryfy(obj) {\n const buildQuery = (prefix, obj) => {\n return Object.keys(obj)\n .map(key => {\n const value = obj[key];\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n if (typeof value === 'object' && value !== null) {\n return buildQuery(prefixedKey, value);\n } else {\n return `${prefixedKey}=${value}`;\n }\n })\n .join(\"&\");\n };\n\n return buildQuery(\"\", obj);\n}","import { useState } from \"react\"\n\nfunction useQurealActions() {\n const [actionRef, setActionRef] = useState({});\n\n function download() {\n setActionRef({\n type: \"DOWNLOAD\",\n data: {}\n })\n }\n\n\n function share() {\n setActionRef({\n type: \"SHARE\",\n data: {}\n })\n }\n\n return { actionRef, download, share }\n}\n\nexport default useQurealActions;"],"names":["QurealiFrame","slug","preview","query","type","style","React","memo","ALLOWED_ORIGINS","QurealViewer","prefill","onFormSubmit","actionRef","organization","person","sendToIFrame","msg","log","qureal_element","document","getElementById","qureal_window","contentWindow","postMessage","includes","data","handler","ev","origin","babelHelpers.typeof","event_type","addEventListener","window","removeEventListener","queryfy","obj","buildQuery","prefix","Object","keys","map","value","key","prefixedKey","join","useQurealActions","useState","setActionRef","download","share"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAT,OAA+E;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