samandesk 1.0.25 → 1.1.1
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/saman-desk.js +9 -7
- package/dist/saman-desk.umd.cjs +1 -1
- package/dist/src/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/saman-desk.js
CHANGED
|
@@ -141,7 +141,7 @@ class SamanDesk {
|
|
|
141
141
|
* @param fullScreen - تمام صفحه باز شود یا خیر
|
|
142
142
|
*
|
|
143
143
|
*/
|
|
144
|
-
setStyle(fullScreen) {
|
|
144
|
+
setStyle(fullScreen, style) {
|
|
145
145
|
const frame2 = getFrame();
|
|
146
146
|
const backdrop2 = getBackdrop();
|
|
147
147
|
frame2.style.position = "fixed";
|
|
@@ -157,15 +157,17 @@ class SamanDesk {
|
|
|
157
157
|
};
|
|
158
158
|
Object.assign(backdrop2.style, backdropStyles);
|
|
159
159
|
if (fullScreen) {
|
|
160
|
+
const marginTopVal = (style == null ? void 0 : style.marginTop) ?? 0;
|
|
161
|
+
const marginBottomVal = (style == null ? void 0 : style.marginBottom) ?? 0;
|
|
162
|
+
const totalMargin = marginTopVal + marginBottomVal;
|
|
160
163
|
Object.assign(frame2.style, {
|
|
161
|
-
bottom: "0",
|
|
164
|
+
bottom: (style == null ? void 0 : style.marginBottom) ? `${style.marginBottom.toString()}px` : "0",
|
|
162
165
|
left: "0",
|
|
163
|
-
top: "0",
|
|
166
|
+
top: (style == null ? void 0 : style.marginTop) ? `${style.marginTop.toString()}px` : "0",
|
|
164
167
|
right: "0",
|
|
165
|
-
width: "100%"
|
|
168
|
+
width: "100%",
|
|
169
|
+
height: `calc(100% - ${totalMargin}px)`
|
|
166
170
|
});
|
|
167
|
-
frame2.width = "100%";
|
|
168
|
-
frame2.height = "100%";
|
|
169
171
|
} else {
|
|
170
172
|
Object.assign(frame2.style, {
|
|
171
173
|
top: "50%",
|
|
@@ -194,7 +196,7 @@ class SamanDesk {
|
|
|
194
196
|
const src = config.link || `${SITE_URL}/department-selection?token=${getToken()}`;
|
|
195
197
|
setFrameSrc(src);
|
|
196
198
|
setOpenLinkFn(config.linkHandler);
|
|
197
|
-
this.setStyle(config.fullScreen);
|
|
199
|
+
this.setStyle(config.fullScreen, config.style);
|
|
198
200
|
document.body.appendChild(backdrop2);
|
|
199
201
|
document.body.appendChild(frame2);
|
|
200
202
|
backdrop2.onclick = () => {
|
package/dist/saman-desk.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SamanDesk={})}(this,(function(e){"use strict";let t;const o=document.createElement("iframe");let n,i,a,s=e=>window.open(e,"_blank","noopener");const d=document.createElement("div"),r={count:0,promises:{}};function
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SamanDesk={})}(this,(function(e){"use strict";let t;const o=document.createElement("iframe");let n,i,a,s=e=>window.open(e,"_blank","noopener");const d=document.createElement("div"),r={count:0,promises:{}};function l(){o.src=""}function c(e){o.src=e}function m(){return o}function p(){return d}const u=new Event("ready"),f=new Event("open"),g=new Event("close");function h(e){window.addEventListener("message",(t=>{if(!t.data.from||"SamanDesk"!==t.data.from)return;let o=!1;console.log(`message from (${t.origin})`,t);try{e[t.data.action](t.data),o=!0}catch(s){console.error("error while run event action")}const n=t.data,i=n.id,a=r;i in a.promises?(a.promises[i](n),delete a.promises[i]):o||console.error("Message from outside of frame is invalid")}))}class y{async init(){h(this)}setToken(e){var o;o=e.data.token,t=o,l(),window.dispatchEvent(u)}close(){l();const e=p();document.body.removeChild(e),e.onclick=null,document.body.removeChild(m()),window.dispatchEvent(g)}getConfig(e){const t={theme:n,color:i},o={language:a};!function(e,t,o){var n;const i={from:"SamanDesk",action:o,data:t,id:e};null==(n=m().contentWindow)||n.postMessage(i,"*")}(e.id,{color:t.color,theme:t.theme,language:o.language},e.action)}openLink(e){s(e.data.link)}}const b="https://samandesk.com";e.SamanDesk=class{async init(e){this.interoperation=new y,this.interoperation.init();const t=m(),o=p();c(`${b}/setup-interoperation/${e}`),t.width="0",t.style.width="0",document.body.appendChild(o),document.body.appendChild(t)}setStyle(e,t){const o=m(),n=p();o.style.position="fixed",o.style.zIndex="1000";if(Object.assign(n.style,{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",backgroundColor:"rgba(0,0,0,0.5)",zIndex:"1000"}),e){const e=((null==t?void 0:t.marginTop)??0)+((null==t?void 0:t.marginBottom)??0);Object.assign(o.style,{bottom:(null==t?void 0:t.marginBottom)?`${t.marginBottom.toString()}px`:"0",left:"0",top:(null==t?void 0:t.marginTop)?`${t.marginTop.toString()}px`:"0",right:"0",width:"100%",height:`calc(100% - ${e}px)`})}else Object.assign(o.style,{top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"100%",maxWidth:"500px",boxShadow:"0px 0px 100px 0px rgba(0,0,0,0.48)",borderRadius:"24px",height:"100%",maxHeight:"660px"})}open(e){const o=m(),d=p();var r,l;r={darkMode:e.theme.darkMode??"light",color:e.theme.color??"default"},n=r.darkMode,i=r.color,l=e.language??"fa",a=l;var u;c(e.link||`${b}/department-selection?token=${t}`),(u=e.linkHandler)&&(s=u),this.setStyle(e.fullScreen,e.style),document.body.appendChild(d),document.body.appendChild(o),d.onclick=()=>{this.close()},window.dispatchEvent(f)}close(){var e;null==(e=this.interoperation)||e.close()}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/src/index.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface OpenConfig {
|
|
|
22
22
|
language: string;
|
|
23
23
|
/** تابع مدیریتکنندهی لینکها */
|
|
24
24
|
linkHandler?: (link: string) => void;
|
|
25
|
+
style?: {
|
|
26
|
+
/** فاصله از بالا در حالت تمام صفحه */
|
|
27
|
+
marginTop?: number;
|
|
28
|
+
/** فاصله از پایین در حالت تمام صفحه */
|
|
29
|
+
marginBottom?: number;
|
|
30
|
+
};
|
|
25
31
|
}
|
|
26
32
|
export declare class SamanDesk {
|
|
27
33
|
/**
|