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.
@@ -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 = () => {
@@ -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 c(){o.src=""}function l(e){o.src=e}function p(){return o}function m(){return d}const h=new Event("ready"),u=new Event("open"),f=new Event("close");function g(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(){g(this)}setToken(e){var o;o=e.data.token,t=o,c(),window.dispatchEvent(h)}close(){c();const e=m();document.body.removeChild(e),e.onclick=null,document.body.removeChild(p()),window.dispatchEvent(f)}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=p().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=p(),o=m();l(`${b}/setup-interoperation/${e}`),t.width="0",t.style.width="0",document.body.appendChild(o),document.body.appendChild(t)}setStyle(e){const t=p(),o=m();t.style.position="fixed",t.style.zIndex="1000";Object.assign(o.style,{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",backgroundColor:"rgba(0,0,0,0.5)",zIndex:"1000"}),e?(Object.assign(t.style,{bottom:"0",left:"0",top:"0",right:"0",width:"100%"}),t.width="100%",t.height="100%"):Object.assign(t.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=p(),d=m();var r,c;r={darkMode:e.theme.darkMode??"light",color:e.theme.color??"default"},n=r.darkMode,i=r.color,c=e.language??"fa",a=c;var h;l(e.link||`${b}/department-selection?token=${t}`),(h=e.linkHandler)&&(s=h),this.setStyle(e.fullScreen),document.body.appendChild(d),document.body.appendChild(o),d.onclick=()=>{this.close()},window.dispatchEvent(u)}close(){var e;null==(e=this.interoperation)||e.close()}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
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"})}));
@@ -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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samandesk",
3
- "version": "1.0.25",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [