From 2b7bcfa65e3b3742d83b3e3065a583f0f5550ed2 Mon Sep 17 00:00:00 2001 From: Parsa Gholipour <12parsa@gmail.com> Date: Sun, 24 Sep 2023 21:43:13 +0330 Subject: [PATCH] fix copy in fixed mode --- ...{Sharee.55f9ad49.js => Sharee.f3e8422a.js} | 32 +++++++++++-------- dist/sharee-react.js.js | 2 +- dist/sharee-vue.js.js | 2 +- dist/sharee.js | 2 +- dist/sharee.min.js | 10 +++--- src/lib/strategies/FixedStrategy.ts | 7 ++++ 6 files changed, 33 insertions(+), 22 deletions(-) rename dist/{Sharee.55f9ad49.js => Sharee.f3e8422a.js} (96%) diff --git a/dist/Sharee.55f9ad49.js b/dist/Sharee.f3e8422a.js similarity index 96% rename from dist/Sharee.55f9ad49.js rename to dist/Sharee.f3e8422a.js index 8f68370..62f4b94 100644 --- a/dist/Sharee.55f9ad49.js +++ b/dist/Sharee.f3e8422a.js @@ -10,13 +10,13 @@ const p = { drivers: ["copy", "telegram", "facebook", "whatsapp", "twitter", "linkedin"], ripple: !0, mode: "normal" -}, g = "rtl", E = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0644\u06AF\u0631\u0627\u0645", f = "\u06A9\u067E\u06CC \u0644\u06CC\u0646\u06A9", C = "\u0628\u0627 \u0645\u0648\u0641\u0642\u06CC\u062A \u06A9\u067E\u06CC \u0634\u062F!", L = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0648\u0627\u062A\u0633\u0627\u067E", v = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0648\u06CC\u06CC\u062A\u0631", w = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0644\u06CC\u0646\u06A9\u062F\u06CC\u0646", x = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0641\u06CC\u0633\u0628\u0648\u06A9", y = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0627\u06CC\u062A\u0627", h = { +}, g = "rtl", E = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0644\u06AF\u0631\u0627\u0645", f = "\u06A9\u067E\u06CC \u0644\u06CC\u0646\u06A9", C = "\u0628\u0627 \u0645\u0648\u0641\u0642\u06CC\u062A \u06A9\u067E\u06CC \u0634\u062F!", v = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0648\u0627\u062A\u0633\u0627\u067E", L = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0648\u06CC\u06CC\u062A\u0631", w = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0644\u06CC\u0646\u06A9\u062F\u06CC\u0646", x = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0641\u06CC\u0633\u0628\u0648\u06A9", y = "\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0627\u06CC\u062A\u0627", h = { Direction: g, Telegram: E, Copy_Link: f, CopiedSuccessfully: C, - Whatsapp: L, - Twitter: v, + Whatsapp: v, + Twitter: L, Linkedin: w, Facebook: x, Eitaa: y @@ -26,8 +26,8 @@ const p = { Telegram: E, Copy_Link: f, CopiedSuccessfully: C, - Whatsapp: L, - Twitter: v, + Whatsapp: v, + Twitter: L, Linkedin: w, Facebook: x, Eitaa: y, @@ -388,12 +388,16 @@ class O extends d { })); } renderDriver(e) { - e.mainEl = document.createElement("a"), "getLink" in e && (e.mainEl.href = e.getLink()), this.initDriverStyles(e); + e.mainEl = document.createElement("a"), "getLink" in e && (e.mainEl.href = e.getLink()), this.initDriverStyles(e), this.listenDriverEvents(e); const t = document.createElement("div"); t.innerHTML = e.icon; const i = document.createElement("div"); return i.innerHTML = e.getButtonText(), e.mainEl.appendChild(t), this.options.noTitle ? (e.mainEl.title = e.getButtonText(), e.mainEl.classList.add("sharee__no-title")) : e.mainEl.appendChild(i), e.mainEl.classList.add("sharee__driver__" + e.getName()), e.mainEl; } + listenDriverEvents(e) { + const t = this.onDriverClick(e); + this.driverListeners[e.buttonText] = [t], e.mainEl.addEventListener("click", t); + } } class z extends u { constructor(s) { @@ -502,7 +506,7 @@ class P extends a { } getLink() { var e, t; - return `whatsapp://send?text=${(e = this.options) == null ? void 0 : e.shareText} + return `https://wa.me?text=${(e = this.options) == null ? void 0 : e.shareText} ${(t = this.options) == null ? void 0 : t.shareLink}`; } } @@ -561,16 +565,16 @@ class W extends a { } getLink() { var e, t; - return `https://twitter.com/share?text=${encodeURIComponent((e = this.options) == null ? void 0 : e.shareText)}&url=${(t = this.options) == null ? void 0 : t.shareLink}`; + return `https://twitter.com/intent/tweet?text=${encodeURIComponent((e = this.options) == null ? void 0 : e.shareText)}&url=${(t = this.options) == null ? void 0 : t.shareLink}`; } } -const U = `\r +const A = `\r `; -class A extends a { +class U extends a { constructor(e, t) { super(e, t); n(this, "buttonText", "Linkedin"); - n(this, "icon", U); + n(this, "icon", A); n(this, "backgroundColor", "#0077B5"); n(this, "backgroundHoverColor", "#026092"); n(this, "textColor", "#fff"); @@ -578,7 +582,7 @@ class A extends a { } getLink() { var e; - return `https://www.linkedin.com/sharing/share-offsite/?url=${(e = this.options) == null ? void 0 : e.shareLink}`; + return `https://www.linkedin.com/shareArticle?url=${(e = this.options) == null ? void 0 : e.shareLink}`; } } const X = `\r @@ -597,7 +601,7 @@ class G extends a { } getLink() { var e, t; - return `https://twitter.com/share?text=${encodeURIComponent((e = this.options) == null ? void 0 : e.shareText)}&url=${(t = this.options) == null ? void 0 : t.shareLink}`; + return `https://facebook.com/sharer/sharer.php?u=${(e = this.options) == null ? void 0 : e.shareLink}&t=${encodeURIComponent((t = this.options) == null ? void 0 : t.shareText)}`; } } const q = `\r @@ -627,7 +631,7 @@ const J = new Object({ whatsapp: P, copy: F, twitter: W, - linkedin: A, + linkedin: U, facebook: G, eitaa: Z }); diff --git a/dist/sharee-react.js.js b/dist/sharee-react.js.js index 21bda2b..834eea8 100644 --- a/dist/sharee-react.js.js +++ b/dist/sharee-react.js.js @@ -1,5 +1,5 @@ import { useRef as n, useEffect as u } from "react"; -import { S as o } from "./Sharee.55f9ad49.js"; +import { S as o } from "./Sharee.f3e8422a.js"; import { jsx as f } from "react/jsx-runtime"; import "lodash.merge"; function m(e) { diff --git a/dist/sharee-vue.js.js b/dist/sharee-vue.js.js index e6a0625..9d19702 100644 --- a/dist/sharee-vue.js.js +++ b/dist/sharee-vue.js.js @@ -1,5 +1,5 @@ import { defineComponent as a, ref as o, onMounted as u, onUnmounted as s, openBlock as p, createElementBlock as i } from "vue"; -import { S as m } from "./Sharee.55f9ad49.js"; +import { S as m } from "./Sharee.f3e8422a.js"; import "lodash.merge"; const _ = /* @__PURE__ */ a({ __name: "Sharee", diff --git a/dist/sharee.js b/dist/sharee.js index f400607..9da0de3 100644 --- a/dist/sharee.js +++ b/dist/sharee.js @@ -1,4 +1,4 @@ -import { S as a } from "./Sharee.55f9ad49.js"; +import { S as a } from "./Sharee.f3e8422a.js"; import "lodash.merge"; export { a as default diff --git a/dist/sharee.min.js b/dist/sharee.min.js index 2456752..71573b1 100644 --- a/dist/sharee.min.js +++ b/dist/sharee.min.js @@ -1,5 +1,5 @@ (function(){"use strict";try{if(typeof document!="undefined"){var r=document.createElement("style");r.appendChild(document.createTextNode(".sharee__normal{min-width:13em;display:flex;flex-direction:row;background:white;--border-radius: 5px;border-radius:var(--border-radius);border:none}.sharee__normal a[href]{text-decoration:none}.sharee__normal svg{width:1.9em;max-height:1.9em;vertical-align:middle}.sharee__normal.sharee__rtl{direction:rtl}.sharee__normal>*{display:flex;justify-content:flex-start;align-items:center;background:white;padding-top:3px;padding-bottom:4px;padding-inline-end:10px;padding-inline-start:5px;cursor:pointer;max-width:1.58em;white-space:nowrap;overflow:hidden}.sharee__normal>*:not(.sharee__no-title):hover{max-width:10em}.sharee__normal>*>*:first-child{margin-inline-end:.3em}.sharee__normal>*:hover{background:#ebebeb}.sharee__normal>*:first-child:not(:last-child){border-start-start-radius:var(--border-radius);border-end-start-radius:var(--border-radius)}.sharee__normal>*:last-child:not(:first-child){border-start-end-radius:var(--border-radius);border-end-end-radius:var(--border-radius)}.sharee__normal.sharee__normal__grid{display:grid;grid-template-columns:1fr 1fr;overflow:hidden}.sharee__normal.sharee__normal__grid>*{border-radius:0!important}.sharee__modal{display:none;position:fixed;z-index:1;padding-top:100px;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:#0006;opacity:0;transition:.3s all}.sharee__modal.showing{display:block}.sharee__modal.show{opacity:1}.sharee__modal .sharee__modal__content{background-color:#fefefe;margin:auto;padding:20px;border:1px solid #888;width:80%}.sharee__modal__close{color:#aaa;float:right;font-size:28px;font-weight:700}.sharee__modal__close:hover,.sharee__modal__close:focus{color:#000;text-decoration:none;cursor:pointer}.sharee__modal svg{width:1.9em;max-height:1.9em}.sharee__modal.sharee__rtl{direction:rtl}.sharee__modal>*{display:flex;justify-content:flex-start;align-items:center;background:white;padding:2px 7px 2px 10px;cursor:pointer;max-width:1.58em;white-space:nowrap;overflow:hidden}.sharee__modal>*:hover{max-width:10em}.sharee__modal>* svg{transform:translateY(.13em)}.sharee__modal>*>*:first-child{margin-inline-end:.3em}.sharee__modal>*:hover{background:#ebebeb}.sharee__modal>*:first-child:not(:last-child){border-start-start-radius:var(--border-radius);border-end-start-radius:var(--border-radius)}.sharee__modal>*:last-child:not(:first-child){border-start-end-radius:var(--border-radius);border-end-end-radius:var(--border-radius)}.sharee__modal.sharee__modal__grid{display:grid;grid-template-columns:1fr 1fr;overflow:hidden}.sharee__modal.sharee__modal__grid>*{border-radius:0!important}.sharee__fixed{display:block;position:fixed;z-index:1;overflow:auto;transition:.3s all;border-start-end-radius:5px;border-end-end-radius:5px;--border-radius: 5px}.sharee__fixed a[href]{text-decoration:none}.sharee__fixed.sharee__position__top-right{right:0;top:10vh;direction:rtl!important}.sharee__fixed.sharee__position__top-left{left:0;top:10vh;direction:ltr!important}.sharee__fixed.sharee__position__bottom-left{left:0;bottom:10vh;direction:ltr!important}.sharee__fixed.sharee__position__bottom-right{bottom:10vh;right:0;direction:rtl!important}.sharee__fixed svg{width:1.9em;max-height:1.9em;vertical-align:middle}.sharee__fixed.sharee__rtl{direction:rtl}.sharee__fixed>*{display:flex;justify-content:flex-start;align-items:center;background:white;padding-inline-start:2px;padding-inline-end:9px;padding-top:5px;padding-bottom:4px;cursor:pointer;max-width:1.58em;white-space:nowrap;overflow:hidden}.sharee__fixed>*:not(.sharee__no-title):hover{max-width:10em}.sharee__fixed>*>*:first-child{margin-inline-end:.3em}.sharee__fixed>*:hover{background:#ebebeb}.sharee__fixed>*:not(.sharee__no-title):hover{border-start-end-radius:var(--border-radius);border-end-end-radius:var(--border-radius)}.sharee__fixed>*:first-child{border-start-end-radius:var(--border-radius)}.sharee__fixed>*:last-child{border-end-end-radius:var(--border-radius)}.sharee__text.sharee__dropdown{min-width:unset;left:-1000px}.sharee__text.sharee__dropdown>*{padding:0 4px}.sharee__dropdown.sharee__text>*>*:first-child{margin-inline-end:unset}.sharee__text.sharee__dropdown svg{vertical-align:middle}.sharee__dropdown{position:fixed;min-width:13em;display:flex;flex-direction:column;background:white;--border-radius: 5px;border-radius:var(--border-radius);border:1px solid #c5c5c5;box-shadow:#3a3d42a6 0 1px,#0000007f 0 4px 16px -7px}.sharee__dropdown a[href]{text-decoration:none}.sharee__dropdown:not(.show):not(.showing){display:none!important}.sharee__dropdown.sharee__dropdown__row{border:none;box-shadow:#0000007f 0 1px 16px -7px}.sharee__dropdown.sharee__dropdown__row{flex-direction:row}.sharee__dropdown svg{width:1.9em;max-height:1.9em;vertical-align:middle}.sharee__dropdown.sharee__rtl{direction:rtl}.sharee__dropdown>*{display:flex;justify-content:flex-start;align-items:center;background:white;padding:2px 7px 2px 10px;cursor:pointer;min-height:2.6em}.sharee__dropdown:not(.sharee__dropdown__row)>*:first-child:last-child{border-radius:inherit}.sharee__dropdown:not(.sharee__dropdown__row)>*:first-child:not(:last-child){border-radius:var(--border-radius) var(--border-radius) 0 0}.sharee__dropdown:not(.sharee__dropdown__row)>*:last-child:not(:first-child){border-radius:0 0 var(--border-radius) var(--border-radius)}.sharee__dropdown>*>*:first-child{margin-inline-end:.3em}.sharee__dropdown>*:hover{background:#ebebeb}.sharee__dropdown.fade:not(.show){opacity:0}.sharee__dropdown.fade.show{opacity:1}.sharee__dropdown.fade-down:not(.show){opacity:0;transform:translateY(-10px)}.sharee__dropdown.fade-down.show{opacity:1;transform:translateY(0)}.sharee__dropdown.sharee__dropdown__row>*:first-child:not(:last-child){border-start-start-radius:var(--border-radius);border-end-start-radius:var(--border-radius)}.sharee__dropdown.sharee__dropdown__row>*:last-child:not(:first-child){border-start-end-radius:var(--border-radius);border-end-end-radius:var(--border-radius)}.sharee__dropdown.sharee__dropdown__grid{display:grid;grid-template-columns:1fr 1fr;overflow:hidden}.sharee__dropdown.sharee__dropdown__grid>*{border-radius:0!important}.sharee__hover,.sharee__dropdown.fade-down.sharee__hover.show{transform:translate(-50%)}.sharee__dropdown.fade-down:not(.show){transform:translate(-50%,-10px)}")),document.head.appendChild(r)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})(); -(function(x,_){typeof exports=="object"&&typeof module<"u"?module.exports=_():typeof define=="function"&&define.amd?define(_):(x=typeof globalThis<"u"?globalThis:x||self,x.Sharee=_())})(this,function(){"use strict";var vr=Object.defineProperty;var Er=(x,_,S)=>_ in x?vr(x,_,{enumerable:!0,configurable:!0,writable:!0,value:S}):x[_]=S;var o=(x,_,S)=>(Er(x,typeof _!="symbol"?_+"":_,S),S);function x(d,s){for(var t=0;ti[l]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}const _={showTransitionDuration:"200ms",lang:"fa",onLoad:()=>{},drivers:["copy","telegram","facebook","whatsapp","twitter","linkedin"],ripple:!0,mode:"normal"},S="rtl",Je="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0644\u06AF\u0631\u0627\u0645",Qe="\u06A9\u067E\u06CC \u0644\u06CC\u0646\u06A9",et="\u0628\u0627 \u0645\u0648\u0641\u0642\u06CC\u062A \u06A9\u067E\u06CC \u0634\u062F!",tt="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0648\u0627\u062A\u0633\u0627\u067E",nt="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0648\u06CC\u06CC\u062A\u0631",rt="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0644\u06CC\u0646\u06A9\u062F\u06CC\u0646",it="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0641\u06CC\u0633\u0628\u0648\u06A9",st="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0627\u06CC\u062A\u0627",xe={Direction:S,Telegram:Je,Copy_Link:Qe,CopiedSuccessfully:et,Whatsapp:tt,Twitter:nt,Linkedin:rt,Facebook:it,Eitaa:st},zt=Object.freeze(Object.defineProperty({__proto__:null,Direction:S,Telegram:Je,Copy_Link:Qe,CopiedSuccessfully:et,Whatsapp:tt,Twitter:nt,Linkedin:rt,Facebook:it,Eitaa:st,default:xe},Symbol.toStringTag,{value:"Module"}));class De{constructor(){o(this,"eventListeners",[])}resolveDriver(s){if(te.drivers.hasOwnProperty(s))return te.drivers[s];throw new Error(`Unknown driver: ${s}`)}shouldRenderDriver(s){return!0}}var W=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Oe={exports:{}};(function(d,s){var t=200,i="__lodash_hash_undefined__",l=800,p=16,M=9007199254740991,$="[object Arguments]",ne="[object Array]",re="[object AsyncFunction]",ie="[object Boolean]",se="[object Date]",oe="[object Error]",ae="[object Function]",He="[object GeneratorFunction]",X="[object Map]",B="[object Number]",le="[object Null]",Z="[object Object]",je="[object Proxy]",q="[object RegExp]",ce="[object Set]",c="[object String]",u="[object Undefined]",h="[object WeakMap]",C="[object ArrayBuffer]",w="[object DataView]",z="[object Float32Array]",ze="[object Float64Array]",Pe="[object Int8Array]",Ae="[object Int16Array]",Re="[object Int32Array]",he="[object Uint8Array]",Ie="[object Uint8ClampedArray]",ue="[object Uint16Array]",$e="[object Uint32Array]",de=/[\\^$.*+?()[\]{}|]/g,pe=/^\[object .+?Constructor\]$/,fe=/^(?:0|[1-9]\d*)$/,m={};m[z]=m[ze]=m[Pe]=m[Ae]=m[Re]=m[he]=m[Ie]=m[ue]=m[$e]=!0,m[$]=m[ne]=m[C]=m[ie]=m[w]=m[se]=m[oe]=m[ae]=m[X]=m[B]=m[Z]=m[q]=m[ce]=m[c]=m[h]=!1;var K=typeof W=="object"&&W&&W.Object===Object&&W,b=typeof self=="object"&&self&&self.Object===Object&&self,D=K||b||Function("return this")(),N=s&&!s.nodeType&&s,H=N&&!0&&d&&!d.nodeType&&d,Y=H&&H.exports===N,P=Y&&K.process,ge=function(){try{var e=H&&H.require&&H.require("util").types;return e||P&&P.binding&&P.binding("util")}catch{}}(),F=ge&&ge.isTypedArray;function me(e,n,r){switch(r.length){case 0:return e.call(n);case 1:return e.call(n,r[0]);case 2:return e.call(n,r[0],r[1]);case 3:return e.call(n,r[0],r[1],r[2])}return e.apply(n,r)}function ve(e,n){for(var r=-1,a=Array(e);++r-1}function Dn(e,n){var r=this.__data__,a=_e(r,e);return a<0?(++this.size,r.push([e,n])):r[a][1]=n,this}k.prototype.clear=bn,k.prototype.delete=Ln,k.prototype.get=Tn,k.prototype.has=xn,k.prototype.set=Dn;function U(e){var n=-1,r=e==null?0:e.length;for(this.clear();++n1?r[g-1]:void 0,E=g>2?r[2]:void 0;for(v=e.length>3&&typeof v=="function"?(g--,v):void 0,E&&nr(r[0],r[1],E)&&(v=g<3?void 0:v,g=1),n=Object(n);++a-1&&e%1==0&&e0){if(++n>=l)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}function hr(e){if(e!=null){try{return ye.call(e)}catch{}try{return e+""}catch{}}return""}function Te(e,n){return e===n||e!==e&&n!==n}var Ge=Lt(function(){return arguments}())?Lt:function(e){return Q(e)&&O.call(e,"callee")&&!pn.call(e,"callee")},Xe=Array.isArray;function Ze(e){return e!=null&&kt(e.length)&&!qe(e)}function ur(e){return Q(e)&&Ze(e)}var Ot=gn||mr;function qe(e){if(!I(e))return!1;var n=be(e);return n==ae||n==He||n==re||n==je}function kt(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=M}function I(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function Q(e){return e!=null&&typeof e=="object"}function dr(e){if(!Q(e)||be(e)!=Z)return!1;var n=Ct(e);if(n===null)return!0;var r=O.call(n,"constructor")&&n.constructor;return typeof r=="function"&&r instanceof r&&ye.call(r)==un}var St=F?Be(F):Fn;function pr(e){return Yn(e,Mt(e))}function Mt(e){return Ze(e)?In(e,!0):Un(e)}var fr=Jn(function(e,n,r){Tt(e,n,r)});function gr(e){return function(){return e}}function Ht(e){return e}function mr(){return!1}d.exports=fr})(Oe,Oe.exports);const G=Oe.exports,Pt={type:"column",animation:"fade-down"};class ke extends De{constructor(t){super();o(this,"sharee");o(this,"elementHovering",!1);o(this,"shareeElHovering",!1);o(this,"shareeEl");o(this,"driverListeners",{});o(this,"hideTimeout",0);o(this,"options");this.sharee=t,this.shareeEl=document.createElement("div"),this.options=G({},Pt,t.options.modeOptions)}show(){this.shareeEl.classList.add("showing"),setTimeout(()=>{this.shareeEl.classList.add("show");const t=this.sharee.targetElement.getBoundingClientRect(),i=t.x,l=t.y;this.sharee.lang.Direction==="ltr"?(this.shareeEl.style.left=`${i}px`,this.shareeEl.style.right="unset"):(this.shareeEl.style.right=`${i}px`,this.shareeEl.style.left="unset"),this.shareeEl.style.top=`${l+t.height}px`})}hide(){var t;(t=this.shareeEl)==null||t.classList.remove("show"),clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{var i;(i=this.shareeEl)==null||i.classList.remove("showing")},Number.parseInt(this.sharee.options.showTransitionDuration))}elementOnMouseEnter(){this.elementHovering=!0,this.show()}elementOnMouseLeave(){setTimeout(()=>this.elementHovering=!1),setTimeout(()=>{this.shareeElHovering||this.hide()})}shareElOnMouseEnter(){this.elementHovering&&this.show(),this.shareeElHovering=!0}shareElOnMouseLeave(){setTimeout(()=>this.shareeElHovering=!1),setTimeout(()=>{this.elementHovering||this.hide()})}listenEvents(){this.shareeEl.addEventListener("mouseenter",this.shareElOnMouseEnter.bind(this)),this.shareeEl.addEventListener("mouseleave",this.shareElOnMouseLeave.bind(this));const t=this.elementOnMouseEnter.bind(this),i=this.elementOnMouseLeave.bind(this);this.sharee.targetElement.addEventListener("mouseenter",t),this.sharee.targetElement.addEventListener("mouseleave",i),this.eventListeners.push([this.sharee.targetElement,"mouseenter",t]),this.eventListeners.push([this.sharee.targetElement,"mouseleave",i])}destroy(){var t;window.shareeEl=this.shareeEl,this.eventListeners.forEach(i=>{i[0].removeEventListener(i[1],i[2])}),(t=this.shareeEl.parentElement)==null||t.removeChild(this.shareeEl)}reRender(){this.destroy(),setTimeout(()=>{this.render()})}render(){this.shareeEl=document.createElement("div"),this.shareeEl.classList.add("sharee__dropdown"),this.shareeEl.classList.add("sharee__"+this.sharee.lang.Direction),this.shareeEl.classList.add(this.options.animation),this.shareeEl.style.transition="all "+this.sharee.options.showTransitionDuration,this.shareeEl.style.transitionProperty="transform, opacity";for(let t of this.sharee.options.drivers){if(!this.shouldRenderDriver(t))continue;const i=this.resolveDriver(t),l=new i(this.sharee.lang,{lang:this.sharee.lang,shareText:this.sharee.getShareText(),shareLink:this.sharee.getShareLink(),ripple:this.sharee.options.ripple}),p=this.renderDriver(l);this.shareeEl.appendChild(p)}document.body.appendChild(this.shareeEl),this.listenEvents(),this.options.type==="grid"?this.shareeEl.classList.add("sharee__dropdown__grid"):this.options.type==="row"&&this.shareeEl.classList.add("sharee__dropdown__row")}onDriverMouseEnter(t){return()=>{t.mainEl.style.backgroundColor=t.backgroundHoverColor,t.mainEl.style.color=t.textHoverColor}}onDriverMouseLeave(t){return()=>{this.initDriverStyles(t)}}onDriverClick(t){return i=>{t.onClick(i)}}initDriverStyles(t){var i,l;t.mainEl.style.backgroundColor=t.backgroundColor,t.mainEl.style.color=t.textColor,t.mainEl.style.transition=(((i=t.options)==null?void 0:i.transitionDuration)||"200ms")+" all",(l=t.options)!=null&&l.ripple&&this.initRipple(t)}initRipple(t){t.rippleInitialized||(t.rippleInitialized=!0,Promise.resolve().then(()=>Me).then(i=>{i.default(t.mainEl,{background:t.rippleColor})}))}renderDriver(t){t.mainEl=document.createElement("a"),"getLink"in t&&(t.mainEl.href=t.getLink()),this.initDriverStyles(t),this.listenDriverEvents(t);const i=document.createElement("div");i.innerHTML=t.icon;const l=document.createElement("div");return l.innerHTML=t.getButtonText(),t.mainEl.appendChild(i),t.mainEl.appendChild(l),t.mainEl}listenDriverEvents(t){const i=this.onDriverMouseEnter(t),l=this.onDriverMouseLeave(t),p=this.onDriverClick(t);this.driverListeners[t.buttonText]=[i,l,p],t.mainEl.addEventListener("mouseenter",i),t.mainEl.addEventListener("mouseleave",l),t.mainEl.addEventListener("click",p)}}function ot(d,s){var t,i;do{if(typeof((t=d==null?void 0:d.className)==null?void 0:t.includes)<"u"&&((i=d==null?void 0:d.className)==null?void 0:i.includes(s)))return!0;d=d.parentNode}while(d);return!1}class At extends ke{constructor(s){super(s),this.options.type="row"}show(){this.shareeEl.classList.add("showing"),setTimeout(()=>{this.shareeEl.classList.add("show")})}getDistanceFromTop(){return window.pageXOffset||document.documentElement.scrollTop||document.body.scrollTop}getTooltipPosition(){let s;try{s=window.getSelection().getRangeAt(0).getBoundingClientRect()}catch{return{left:0,top:0}}const t=30,i=s.top,l=s.left+(s.width-t*this.sharee.options.drivers.length)/2;return{top:i,left:l}}setPosition(s){this.shareeEl.style.right="unset";const{left:t,top:i}=this.getTooltipPosition();return t===0?(this.hide(),!1):(s.x+300>window.innerWidth?this.shareeEl.style.left=t+"px":this.shareeEl.style.left=t+"px",this.shareeEl.style.top=`${i+26}px`,!0)}shouldRenderDriver(s){return s!=="copy"}getSelectedText(){var s;try{window.getSelection().getRangeAt(0)}catch{return!1}return window.getSelection?(s=window.getSelection())==null?void 0:s.toString():typeof document.selection<"u"?document.selection.createRange().text:""}destroy(){super.destroy(),window.removeEventListener("resize",this.windowOnResize)}render(){super.render(),this.shareeEl.classList.add("sharee__text")}documentOnClick(s){ot(s.target,"sharee__text")||this.hide()}elementOnMouseUp(s){const t=s.currentTarget;setTimeout(()=>{const i=this.getSelectedText();!i||ot(t,"sharee__text")||(this.sharee.options.shareText=i,this.reRender(),setTimeout(()=>{this.show(),setTimeout(()=>{this.setPosition(s)})}))})}windowOnResize(){this.hide()}listenEvents(){const s=this.elementOnMouseUp.bind(this),t=this.documentOnClick.bind(this);this.sharee.targetElement.addEventListener("mouseup",s),document.addEventListener("click",t);const i=this.windowOnResize.bind(this);window.addEventListener("resize",i),this.eventListeners.push([this.sharee.targetElement,"mouseup",s]),this.eventListeners.push([document,"click",t]),this.eventListeners.push([window,"resize",i])}renderDriver(s){s.mainEl=document.createElement("a"),s.mainEl.title=s.getButtonText(),"getLink"in s&&(s.mainEl.href=s.getLink()),this.initDriverStyles(s),this.listenDriverEvents(s);const t=document.createElement("div");return t.innerHTML=s.icon,s.mainEl.appendChild(t),s.mainEl}}const Rt={noTitle:!1};class It extends De{constructor(t){super();o(this,"sharee");o(this,"elementHovering",!1);o(this,"shareeElHovering",!1);o(this,"shareeEl");o(this,"driverListeners",{});o(this,"hideTimeout",0);o(this,"options");this.sharee=t,this.shareeEl=document.createElement("div"),this.options=G({},Rt,t.options.modeOptions)}hide(){var t;(t=this.shareeEl)==null||t.classList.remove("show"),clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{var i;(i=this.shareeEl)==null||i.classList.remove("showing")},Number.parseInt(this.sharee.options.showTransitionDuration))}destroy(){var t;this.eventListeners.forEach(i=>{i[0].removeEventListener(i[1],i[2])}),(t=this.shareeEl.parentElement)==null||t.removeChild(this.shareeEl)}reRender(){this.destroy(),setTimeout(()=>{this.render()})}render(){this.shareeEl=document.createElement("div"),this.shareeEl.classList.add("sharee__normal"),this.shareeEl.classList.add("sharee__"+this.sharee.lang.Direction),this.shareeEl.style.transition="all "+this.sharee.options.showTransitionDuration,this.shareeEl.style.transitionProperty="transform, opacity";for(let t of this.sharee.options.drivers){if(!this.shouldRenderDriver(t))continue;const i=this.resolveDriver(t),l=new i(this.sharee.lang,{lang:this.sharee.lang,shareText:this.sharee.getShareText(),shareLink:this.sharee.getShareLink(),ripple:this.sharee.options.ripple}),p=this.renderDriver(l);this.shareeEl.appendChild(p)}this.sharee.targetElement.appendChild(this.shareeEl)}onDriverClick(t){return i=>{t.onClick(i)}}initDriverStyles(t){var i,l;t.mainEl.style.backgroundColor=t.backgroundColor,t.mainEl.style.color=t.textColor,t.mainEl.style.transition=(((i=t.options)==null?void 0:i.transitionDuration)||"200ms")+" background, 1s max-width",(l=t.options)!=null&&l.ripple&&this.initRipple(t)}initRipple(t){t.rippleInitialized||(t.rippleInitialized=!0,Promise.resolve().then(()=>Me).then(i=>{i.default(t.mainEl,{background:t.rippleColor})}))}renderDriver(t){t.mainEl=document.createElement("a"),"getLink"in t&&(t.mainEl.href=t.getLink()),this.initDriverStyles(t),this.listenDriverEvents(t);const i=document.createElement("div");i.innerHTML=t.icon;const l=document.createElement("div");return l.innerHTML=t.getButtonText(),t.mainEl.appendChild(i),this.options.noTitle?(t.mainEl.title=t.getButtonText(),t.mainEl.classList.add("sharee__no-title")):t.mainEl.appendChild(l),t.mainEl.classList.add("sharee__driver__"+t.getName()),t.mainEl}listenDriverEvents(t){const i=this.onDriverClick(t);this.driverListeners[t.buttonText]=[i],t.mainEl.addEventListener("click",i)}}const $t={position:"top-right",noTitle:!1};class Bt extends De{constructor(t){super();o(this,"sharee");o(this,"shareeEl");o(this,"driverListeners",{});o(this,"options");this.sharee=t,this.shareeEl=document.createElement("div"),this.options=G({},$t,t.options.modeOptions)}destroy(){var t;window.shareeEl=this.shareeEl,this.eventListeners.forEach(i=>{i[0].removeEventListener(i[1],i[2])}),(t=this.shareeEl.parentElement)==null||t.removeChild(this.shareeEl)}reRender(){this.destroy(),setTimeout(()=>{this.render()})}getPositionClass(){}render(){this.shareeEl=document.createElement("div"),this.shareeEl.classList.add("sharee__fixed"),this.shareeEl.classList.add("sharee__"+this.sharee.lang.Direction),this.shareeEl.classList.add("sharee__position__"+this.options.position),this.shareeEl.style.transition="all "+this.sharee.options.showTransitionDuration,this.shareeEl.style.transitionProperty="transform, opacity";for(let t of this.sharee.options.drivers){if(!this.shouldRenderDriver(t))continue;const i=this.resolveDriver(t),l=new i(this.sharee.lang,{lang:this.sharee.lang,shareText:this.sharee.getShareText(),shareLink:this.sharee.getShareLink(),ripple:this.sharee.options.ripple}),p=this.renderDriver(l);this.shareeEl.appendChild(p)}document.body.appendChild(this.shareeEl)}onDriverMouseEnter(t){return()=>{t.mainEl.style.backgroundColor=t.backgroundHoverColor,t.mainEl.style.color=t.textHoverColor}}onDriverMouseLeave(t){return()=>{this.initDriverStyles(t)}}onDriverClick(t){return i=>{t.onClick(i)}}initDriverStyles(t){var i,l;t.mainEl.style.backgroundColor=t.backgroundColor,t.mainEl.style.color=t.textColor,t.mainEl.style.transition=(((i=t.options)==null?void 0:i.transitionDuration)||"200ms")+" all",(l=t.options)!=null&&l.ripple&&this.initRipple(t)}initRipple(t){t.rippleInitialized||(t.rippleInitialized=!0,Promise.resolve().then(()=>Me).then(i=>{i.default(t.mainEl,{background:t.rippleColor})}))}renderDriver(t){t.mainEl=document.createElement("a"),"getLink"in t&&(t.mainEl.href=t.getLink()),this.initDriverStyles(t);const i=document.createElement("div");i.innerHTML=t.icon;const l=document.createElement("div");return l.innerHTML=t.getButtonText(),t.mainEl.appendChild(i),this.options.noTitle?(t.mainEl.title=t.getButtonText(),t.mainEl.classList.add("sharee__no-title")):t.mainEl.appendChild(l),t.mainEl.classList.add("sharee__driver__"+t.getName()),t.mainEl}}class Nt extends ke{constructor(s){super(s),this.options.type="row"}destroy(){super.destroy()}render(){super.render(),this.shareeEl.classList.add("sharee__text"),this.shareeEl.classList.add("sharee__hover")}show(){this.shareeEl.classList.add("showing"),setTimeout(()=>{this.shareeEl.classList.add("show");const s=this.sharee.targetElement.getBoundingClientRect(),t=s.x,i=s.y,l=this.shareeEl.getBoundingClientRect().width,p=Math.max(Math.min(t+s.width/2,window.innerWidth-l/2),l/2);console.log(window.innerWidth,l),this.shareeEl.style.left=`${p}px`,this.shareeEl.style.right="unset",this.shareeEl.style.top=`${i+s.height}px`})}listenEvents(){this.shareeEl.addEventListener("mouseenter",this.shareElOnMouseEnter.bind(this)),this.shareeEl.addEventListener("mouseleave",this.shareElOnMouseLeave.bind(this));const s=this.elementOnMouseEnter.bind(this),t=this.elementOnMouseLeave.bind(this);this.sharee.targetElement.addEventListener("mouseenter",s),this.sharee.targetElement.addEventListener("mouseleave",t),this.eventListeners.push([this.sharee.targetElement,"mouseenter",s]),this.eventListeners.push([this.sharee.targetElement,"mouseleave",t])}renderDriver(s){s.mainEl=document.createElement("a"),s.mainEl.title=s.getButtonText(),"getLink"in s&&(s.mainEl.href=s.getLink()),this.initDriverStyles(s),this.listenDriverEvents(s);const t=document.createElement("div");return t.innerHTML=s.icon,s.mainEl.appendChild(t),s.mainEl}}const Ft={dropdown:ke,text:At,normal:It,fixed:Bt,hover:Nt},yr="";class j{constructor(s,t){o(this,"lang");o(this,"mainEl",null);o(this,"options");o(this,"rippleColor","#ffffff75");o(this,"rippleInitialized",!1);this.options=t,this.lang=s}getButtonText(){return this.lang[this.buttonText.replaceAll(" ","_")]||this.buttonText}onClick(s){}getName(){return this.constructor.name}}const Ut=`\r +(function(x,_){typeof exports=="object"&&typeof module<"u"?module.exports=_():typeof define=="function"&&define.amd?define(_):(x=typeof globalThis<"u"?globalThis:x||self,x.Sharee=_())})(this,function(){"use strict";var vr=Object.defineProperty;var Er=(x,_,S)=>_ in x?vr(x,_,{enumerable:!0,configurable:!0,writable:!0,value:S}):x[_]=S;var o=(x,_,S)=>(Er(x,typeof _!="symbol"?_+"":_,S),S);function x(d,s){for(var t=0;ti[l]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}const _={showTransitionDuration:"200ms",lang:"fa",onLoad:()=>{},drivers:["copy","telegram","facebook","whatsapp","twitter","linkedin"],ripple:!0,mode:"normal"},S="rtl",Je="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0644\u06AF\u0631\u0627\u0645",Qe="\u06A9\u067E\u06CC \u0644\u06CC\u0646\u06A9",et="\u0628\u0627 \u0645\u0648\u0641\u0642\u06CC\u062A \u06A9\u067E\u06CC \u0634\u062F!",tt="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0648\u0627\u062A\u0633\u0627\u067E",nt="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u062A\u0648\u06CC\u06CC\u062A\u0631",rt="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0644\u06CC\u0646\u06A9\u062F\u06CC\u0646",it="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0641\u06CC\u0633\u0628\u0648\u06A9",st="\u0627\u0634\u062A\u0631\u0627\u06A9 \u062F\u0631 \u0627\u06CC\u062A\u0627",xe={Direction:S,Telegram:Je,Copy_Link:Qe,CopiedSuccessfully:et,Whatsapp:tt,Twitter:nt,Linkedin:rt,Facebook:it,Eitaa:st},zt=Object.freeze(Object.defineProperty({__proto__:null,Direction:S,Telegram:Je,Copy_Link:Qe,CopiedSuccessfully:et,Whatsapp:tt,Twitter:nt,Linkedin:rt,Facebook:it,Eitaa:st,default:xe},Symbol.toStringTag,{value:"Module"}));class De{constructor(){o(this,"eventListeners",[])}resolveDriver(s){if(te.drivers.hasOwnProperty(s))return te.drivers[s];throw new Error(`Unknown driver: ${s}`)}shouldRenderDriver(s){return!0}}var W=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ke={exports:{}};(function(d,s){var t=200,i="__lodash_hash_undefined__",l=800,p=16,M=9007199254740991,$="[object Arguments]",ne="[object Array]",re="[object AsyncFunction]",ie="[object Boolean]",se="[object Date]",oe="[object Error]",ae="[object Function]",He="[object GeneratorFunction]",X="[object Map]",B="[object Number]",le="[object Null]",Z="[object Object]",je="[object Proxy]",q="[object RegExp]",ce="[object Set]",c="[object String]",u="[object Undefined]",h="[object WeakMap]",C="[object ArrayBuffer]",w="[object DataView]",z="[object Float32Array]",ze="[object Float64Array]",Pe="[object Int8Array]",Ae="[object Int16Array]",Re="[object Int32Array]",he="[object Uint8Array]",Ie="[object Uint8ClampedArray]",ue="[object Uint16Array]",$e="[object Uint32Array]",de=/[\\^$.*+?()[\]{}|]/g,pe=/^\[object .+?Constructor\]$/,fe=/^(?:0|[1-9]\d*)$/,m={};m[z]=m[ze]=m[Pe]=m[Ae]=m[Re]=m[he]=m[Ie]=m[ue]=m[$e]=!0,m[$]=m[ne]=m[C]=m[ie]=m[w]=m[se]=m[oe]=m[ae]=m[X]=m[B]=m[Z]=m[q]=m[ce]=m[c]=m[h]=!1;var K=typeof W=="object"&&W&&W.Object===Object&&W,b=typeof self=="object"&&self&&self.Object===Object&&self,D=K||b||Function("return this")(),N=s&&!s.nodeType&&s,H=N&&!0&&d&&!d.nodeType&&d,Y=H&&H.exports===N,P=Y&&K.process,ge=function(){try{var e=H&&H.require&&H.require("util").types;return e||P&&P.binding&&P.binding("util")}catch{}}(),F=ge&&ge.isTypedArray;function me(e,n,r){switch(r.length){case 0:return e.call(n);case 1:return e.call(n,r[0]);case 2:return e.call(n,r[0],r[1]);case 3:return e.call(n,r[0],r[1],r[2])}return e.apply(n,r)}function ve(e,n){for(var r=-1,a=Array(e);++r-1}function Dn(e,n){var r=this.__data__,a=_e(r,e);return a<0?(++this.size,r.push([e,n])):r[a][1]=n,this}O.prototype.clear=bn,O.prototype.delete=Ln,O.prototype.get=Tn,O.prototype.has=xn,O.prototype.set=Dn;function U(e){var n=-1,r=e==null?0:e.length;for(this.clear();++n1?r[g-1]:void 0,E=g>2?r[2]:void 0;for(v=e.length>3&&typeof v=="function"?(g--,v):void 0,E&&nr(r[0],r[1],E)&&(v=g<3?void 0:v,g=1),n=Object(n);++a-1&&e%1==0&&e0){if(++n>=l)return arguments[0]}else n=0;return e.apply(void 0,arguments)}}function hr(e){if(e!=null){try{return ye.call(e)}catch{}try{return e+""}catch{}}return""}function Te(e,n){return e===n||e!==e&&n!==n}var Ge=Lt(function(){return arguments}())?Lt:function(e){return Q(e)&&k.call(e,"callee")&&!pn.call(e,"callee")},Xe=Array.isArray;function Ze(e){return e!=null&&Ot(e.length)&&!qe(e)}function ur(e){return Q(e)&&Ze(e)}var kt=gn||mr;function qe(e){if(!I(e))return!1;var n=be(e);return n==ae||n==He||n==re||n==je}function Ot(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=M}function I(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}function Q(e){return e!=null&&typeof e=="object"}function dr(e){if(!Q(e)||be(e)!=Z)return!1;var n=Ct(e);if(n===null)return!0;var r=k.call(n,"constructor")&&n.constructor;return typeof r=="function"&&r instanceof r&&ye.call(r)==un}var St=F?Be(F):Fn;function pr(e){return Yn(e,Mt(e))}function Mt(e){return Ze(e)?In(e,!0):Un(e)}var fr=Jn(function(e,n,r){Tt(e,n,r)});function gr(e){return function(){return e}}function Ht(e){return e}function mr(){return!1}d.exports=fr})(ke,ke.exports);const G=ke.exports,Pt={type:"column",animation:"fade-down"};class Oe extends De{constructor(t){super();o(this,"sharee");o(this,"elementHovering",!1);o(this,"shareeElHovering",!1);o(this,"shareeEl");o(this,"driverListeners",{});o(this,"hideTimeout",0);o(this,"options");this.sharee=t,this.shareeEl=document.createElement("div"),this.options=G({},Pt,t.options.modeOptions)}show(){this.shareeEl.classList.add("showing"),setTimeout(()=>{this.shareeEl.classList.add("show");const t=this.sharee.targetElement.getBoundingClientRect(),i=t.x,l=t.y;this.sharee.lang.Direction==="ltr"?(this.shareeEl.style.left=`${i}px`,this.shareeEl.style.right="unset"):(this.shareeEl.style.right=`${i}px`,this.shareeEl.style.left="unset"),this.shareeEl.style.top=`${l+t.height}px`})}hide(){var t;(t=this.shareeEl)==null||t.classList.remove("show"),clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{var i;(i=this.shareeEl)==null||i.classList.remove("showing")},Number.parseInt(this.sharee.options.showTransitionDuration))}elementOnMouseEnter(){this.elementHovering=!0,this.show()}elementOnMouseLeave(){setTimeout(()=>this.elementHovering=!1),setTimeout(()=>{this.shareeElHovering||this.hide()})}shareElOnMouseEnter(){this.elementHovering&&this.show(),this.shareeElHovering=!0}shareElOnMouseLeave(){setTimeout(()=>this.shareeElHovering=!1),setTimeout(()=>{this.elementHovering||this.hide()})}listenEvents(){this.shareeEl.addEventListener("mouseenter",this.shareElOnMouseEnter.bind(this)),this.shareeEl.addEventListener("mouseleave",this.shareElOnMouseLeave.bind(this));const t=this.elementOnMouseEnter.bind(this),i=this.elementOnMouseLeave.bind(this);this.sharee.targetElement.addEventListener("mouseenter",t),this.sharee.targetElement.addEventListener("mouseleave",i),this.eventListeners.push([this.sharee.targetElement,"mouseenter",t]),this.eventListeners.push([this.sharee.targetElement,"mouseleave",i])}destroy(){var t;window.shareeEl=this.shareeEl,this.eventListeners.forEach(i=>{i[0].removeEventListener(i[1],i[2])}),(t=this.shareeEl.parentElement)==null||t.removeChild(this.shareeEl)}reRender(){this.destroy(),setTimeout(()=>{this.render()})}render(){this.shareeEl=document.createElement("div"),this.shareeEl.classList.add("sharee__dropdown"),this.shareeEl.classList.add("sharee__"+this.sharee.lang.Direction),this.shareeEl.classList.add(this.options.animation),this.shareeEl.style.transition="all "+this.sharee.options.showTransitionDuration,this.shareeEl.style.transitionProperty="transform, opacity";for(let t of this.sharee.options.drivers){if(!this.shouldRenderDriver(t))continue;const i=this.resolveDriver(t),l=new i(this.sharee.lang,{lang:this.sharee.lang,shareText:this.sharee.getShareText(),shareLink:this.sharee.getShareLink(),ripple:this.sharee.options.ripple}),p=this.renderDriver(l);this.shareeEl.appendChild(p)}document.body.appendChild(this.shareeEl),this.listenEvents(),this.options.type==="grid"?this.shareeEl.classList.add("sharee__dropdown__grid"):this.options.type==="row"&&this.shareeEl.classList.add("sharee__dropdown__row")}onDriverMouseEnter(t){return()=>{t.mainEl.style.backgroundColor=t.backgroundHoverColor,t.mainEl.style.color=t.textHoverColor}}onDriverMouseLeave(t){return()=>{this.initDriverStyles(t)}}onDriverClick(t){return i=>{t.onClick(i)}}initDriverStyles(t){var i,l;t.mainEl.style.backgroundColor=t.backgroundColor,t.mainEl.style.color=t.textColor,t.mainEl.style.transition=(((i=t.options)==null?void 0:i.transitionDuration)||"200ms")+" all",(l=t.options)!=null&&l.ripple&&this.initRipple(t)}initRipple(t){t.rippleInitialized||(t.rippleInitialized=!0,Promise.resolve().then(()=>Me).then(i=>{i.default(t.mainEl,{background:t.rippleColor})}))}renderDriver(t){t.mainEl=document.createElement("a"),"getLink"in t&&(t.mainEl.href=t.getLink()),this.initDriverStyles(t),this.listenDriverEvents(t);const i=document.createElement("div");i.innerHTML=t.icon;const l=document.createElement("div");return l.innerHTML=t.getButtonText(),t.mainEl.appendChild(i),t.mainEl.appendChild(l),t.mainEl}listenDriverEvents(t){const i=this.onDriverMouseEnter(t),l=this.onDriverMouseLeave(t),p=this.onDriverClick(t);this.driverListeners[t.buttonText]=[i,l,p],t.mainEl.addEventListener("mouseenter",i),t.mainEl.addEventListener("mouseleave",l),t.mainEl.addEventListener("click",p)}}function ot(d,s){var t,i;do{if(typeof((t=d==null?void 0:d.className)==null?void 0:t.includes)<"u"&&((i=d==null?void 0:d.className)==null?void 0:i.includes(s)))return!0;d=d.parentNode}while(d);return!1}class At extends Oe{constructor(s){super(s),this.options.type="row"}show(){this.shareeEl.classList.add("showing"),setTimeout(()=>{this.shareeEl.classList.add("show")})}getDistanceFromTop(){return window.pageXOffset||document.documentElement.scrollTop||document.body.scrollTop}getTooltipPosition(){let s;try{s=window.getSelection().getRangeAt(0).getBoundingClientRect()}catch{return{left:0,top:0}}const t=30,i=s.top,l=s.left+(s.width-t*this.sharee.options.drivers.length)/2;return{top:i,left:l}}setPosition(s){this.shareeEl.style.right="unset";const{left:t,top:i}=this.getTooltipPosition();return t===0?(this.hide(),!1):(s.x+300>window.innerWidth?this.shareeEl.style.left=t+"px":this.shareeEl.style.left=t+"px",this.shareeEl.style.top=`${i+26}px`,!0)}shouldRenderDriver(s){return s!=="copy"}getSelectedText(){var s;try{window.getSelection().getRangeAt(0)}catch{return!1}return window.getSelection?(s=window.getSelection())==null?void 0:s.toString():typeof document.selection<"u"?document.selection.createRange().text:""}destroy(){super.destroy(),window.removeEventListener("resize",this.windowOnResize)}render(){super.render(),this.shareeEl.classList.add("sharee__text")}documentOnClick(s){ot(s.target,"sharee__text")||this.hide()}elementOnMouseUp(s){const t=s.currentTarget;setTimeout(()=>{const i=this.getSelectedText();!i||ot(t,"sharee__text")||(this.sharee.options.shareText=i,this.reRender(),setTimeout(()=>{this.show(),setTimeout(()=>{this.setPosition(s)})}))})}windowOnResize(){this.hide()}listenEvents(){const s=this.elementOnMouseUp.bind(this),t=this.documentOnClick.bind(this);this.sharee.targetElement.addEventListener("mouseup",s),document.addEventListener("click",t);const i=this.windowOnResize.bind(this);window.addEventListener("resize",i),this.eventListeners.push([this.sharee.targetElement,"mouseup",s]),this.eventListeners.push([document,"click",t]),this.eventListeners.push([window,"resize",i])}renderDriver(s){s.mainEl=document.createElement("a"),s.mainEl.title=s.getButtonText(),"getLink"in s&&(s.mainEl.href=s.getLink()),this.initDriverStyles(s),this.listenDriverEvents(s);const t=document.createElement("div");return t.innerHTML=s.icon,s.mainEl.appendChild(t),s.mainEl}}const Rt={noTitle:!1};class It extends De{constructor(t){super();o(this,"sharee");o(this,"elementHovering",!1);o(this,"shareeElHovering",!1);o(this,"shareeEl");o(this,"driverListeners",{});o(this,"hideTimeout",0);o(this,"options");this.sharee=t,this.shareeEl=document.createElement("div"),this.options=G({},Rt,t.options.modeOptions)}hide(){var t;(t=this.shareeEl)==null||t.classList.remove("show"),clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(()=>{var i;(i=this.shareeEl)==null||i.classList.remove("showing")},Number.parseInt(this.sharee.options.showTransitionDuration))}destroy(){var t;this.eventListeners.forEach(i=>{i[0].removeEventListener(i[1],i[2])}),(t=this.shareeEl.parentElement)==null||t.removeChild(this.shareeEl)}reRender(){this.destroy(),setTimeout(()=>{this.render()})}render(){this.shareeEl=document.createElement("div"),this.shareeEl.classList.add("sharee__normal"),this.shareeEl.classList.add("sharee__"+this.sharee.lang.Direction),this.shareeEl.style.transition="all "+this.sharee.options.showTransitionDuration,this.shareeEl.style.transitionProperty="transform, opacity";for(let t of this.sharee.options.drivers){if(!this.shouldRenderDriver(t))continue;const i=this.resolveDriver(t),l=new i(this.sharee.lang,{lang:this.sharee.lang,shareText:this.sharee.getShareText(),shareLink:this.sharee.getShareLink(),ripple:this.sharee.options.ripple}),p=this.renderDriver(l);this.shareeEl.appendChild(p)}this.sharee.targetElement.appendChild(this.shareeEl)}onDriverClick(t){return i=>{t.onClick(i)}}initDriverStyles(t){var i,l;t.mainEl.style.backgroundColor=t.backgroundColor,t.mainEl.style.color=t.textColor,t.mainEl.style.transition=(((i=t.options)==null?void 0:i.transitionDuration)||"200ms")+" background, 1s max-width",(l=t.options)!=null&&l.ripple&&this.initRipple(t)}initRipple(t){t.rippleInitialized||(t.rippleInitialized=!0,Promise.resolve().then(()=>Me).then(i=>{i.default(t.mainEl,{background:t.rippleColor})}))}renderDriver(t){t.mainEl=document.createElement("a"),"getLink"in t&&(t.mainEl.href=t.getLink()),this.initDriverStyles(t),this.listenDriverEvents(t);const i=document.createElement("div");i.innerHTML=t.icon;const l=document.createElement("div");return l.innerHTML=t.getButtonText(),t.mainEl.appendChild(i),this.options.noTitle?(t.mainEl.title=t.getButtonText(),t.mainEl.classList.add("sharee__no-title")):t.mainEl.appendChild(l),t.mainEl.classList.add("sharee__driver__"+t.getName()),t.mainEl}listenDriverEvents(t){const i=this.onDriverClick(t);this.driverListeners[t.buttonText]=[i],t.mainEl.addEventListener("click",i)}}const $t={position:"top-right",noTitle:!1};class Bt extends De{constructor(t){super();o(this,"sharee");o(this,"shareeEl");o(this,"driverListeners",{});o(this,"options");this.sharee=t,this.shareeEl=document.createElement("div"),this.options=G({},$t,t.options.modeOptions)}destroy(){var t;window.shareeEl=this.shareeEl,this.eventListeners.forEach(i=>{i[0].removeEventListener(i[1],i[2])}),(t=this.shareeEl.parentElement)==null||t.removeChild(this.shareeEl)}reRender(){this.destroy(),setTimeout(()=>{this.render()})}getPositionClass(){}render(){this.shareeEl=document.createElement("div"),this.shareeEl.classList.add("sharee__fixed"),this.shareeEl.classList.add("sharee__"+this.sharee.lang.Direction),this.shareeEl.classList.add("sharee__position__"+this.options.position),this.shareeEl.style.transition="all "+this.sharee.options.showTransitionDuration,this.shareeEl.style.transitionProperty="transform, opacity";for(let t of this.sharee.options.drivers){if(!this.shouldRenderDriver(t))continue;const i=this.resolveDriver(t),l=new i(this.sharee.lang,{lang:this.sharee.lang,shareText:this.sharee.getShareText(),shareLink:this.sharee.getShareLink(),ripple:this.sharee.options.ripple}),p=this.renderDriver(l);this.shareeEl.appendChild(p)}document.body.appendChild(this.shareeEl)}onDriverMouseEnter(t){return()=>{t.mainEl.style.backgroundColor=t.backgroundHoverColor,t.mainEl.style.color=t.textHoverColor}}onDriverMouseLeave(t){return()=>{this.initDriverStyles(t)}}onDriverClick(t){return i=>{t.onClick(i)}}initDriverStyles(t){var i,l;t.mainEl.style.backgroundColor=t.backgroundColor,t.mainEl.style.color=t.textColor,t.mainEl.style.transition=(((i=t.options)==null?void 0:i.transitionDuration)||"200ms")+" all",(l=t.options)!=null&&l.ripple&&this.initRipple(t)}initRipple(t){t.rippleInitialized||(t.rippleInitialized=!0,Promise.resolve().then(()=>Me).then(i=>{i.default(t.mainEl,{background:t.rippleColor})}))}renderDriver(t){t.mainEl=document.createElement("a"),"getLink"in t&&(t.mainEl.href=t.getLink()),this.initDriverStyles(t),this.listenDriverEvents(t);const i=document.createElement("div");i.innerHTML=t.icon;const l=document.createElement("div");return l.innerHTML=t.getButtonText(),t.mainEl.appendChild(i),this.options.noTitle?(t.mainEl.title=t.getButtonText(),t.mainEl.classList.add("sharee__no-title")):t.mainEl.appendChild(l),t.mainEl.classList.add("sharee__driver__"+t.getName()),t.mainEl}listenDriverEvents(t){const i=this.onDriverClick(t);this.driverListeners[t.buttonText]=[i],t.mainEl.addEventListener("click",i)}}class Nt extends Oe{constructor(s){super(s),this.options.type="row"}destroy(){super.destroy()}render(){super.render(),this.shareeEl.classList.add("sharee__text"),this.shareeEl.classList.add("sharee__hover")}show(){this.shareeEl.classList.add("showing"),setTimeout(()=>{this.shareeEl.classList.add("show");const s=this.sharee.targetElement.getBoundingClientRect(),t=s.x,i=s.y,l=this.shareeEl.getBoundingClientRect().width,p=Math.max(Math.min(t+s.width/2,window.innerWidth-l/2),l/2);console.log(window.innerWidth,l),this.shareeEl.style.left=`${p}px`,this.shareeEl.style.right="unset",this.shareeEl.style.top=`${i+s.height}px`})}listenEvents(){this.shareeEl.addEventListener("mouseenter",this.shareElOnMouseEnter.bind(this)),this.shareeEl.addEventListener("mouseleave",this.shareElOnMouseLeave.bind(this));const s=this.elementOnMouseEnter.bind(this),t=this.elementOnMouseLeave.bind(this);this.sharee.targetElement.addEventListener("mouseenter",s),this.sharee.targetElement.addEventListener("mouseleave",t),this.eventListeners.push([this.sharee.targetElement,"mouseenter",s]),this.eventListeners.push([this.sharee.targetElement,"mouseleave",t])}renderDriver(s){s.mainEl=document.createElement("a"),s.mainEl.title=s.getButtonText(),"getLink"in s&&(s.mainEl.href=s.getLink()),this.initDriverStyles(s),this.listenDriverEvents(s);const t=document.createElement("div");return t.innerHTML=s.icon,s.mainEl.appendChild(t),s.mainEl}}const Ft={dropdown:Oe,text:At,normal:It,fixed:Bt,hover:Nt},yr="";class j{constructor(s,t){o(this,"lang");o(this,"mainEl",null);o(this,"options");o(this,"rippleColor","#ffffff75");o(this,"rippleInitialized",!1);this.options=t,this.lang=s}getButtonText(){return this.lang[this.buttonText.replaceAll(" ","_")]||this.buttonText}onClick(s){}getName(){return this.constructor.name}}const Ut=`\r `;class Vt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Telegram");o(this,"icon",Ut);o(this,"backgroundColor","#0088CC");o(this,"backgroundHoverColor","#0371aa");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t,i;return`https://telegram.me/share/url?url=${(t=this.options)==null?void 0:t.shareLink}&text=${encodeURIComponent((i=this.options)==null?void 0:i.shareText)}`}}const Wt=`\r \r @@ -24,7 +24,7 @@ \r \r \r -`;class Gt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Whatsapp");o(this,"icon",Wt);o(this,"backgroundColor","#25D366");o(this,"backgroundHoverColor","#20bd5a");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t,i;return`whatsapp://send?text=${(t=this.options)==null?void 0:t.shareText} +`;class Gt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Whatsapp");o(this,"icon",Wt);o(this,"backgroundColor","#25D366");o(this,"backgroundHoverColor","#20bd5a");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t,i;return`https://wa.me?text=${(t=this.options)==null?void 0:t.shareText} ${(i=this.options)==null?void 0:i.shareLink}`}}const Xt=`\r \r `;class Zt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Copy Link");o(this,"icon",Xt);o(this,"backgroundColor","#797979");o(this,"backgroundHoverColor","#5e5e5e");o(this,"textColor","#fff");o(this,"textHoverColor","#fff");o(this,"timeout",0)}onClick(t){super.onClick(t);const i=this.lang.CopiedSuccessfully,p=t.currentTarget.querySelector("div:nth-child(2)");if(p.innerHTML===i){p.innerHTML=this.getButtonText();return}let M=window.location.href;navigator.clipboard.writeText(M).then(()=>{p.innerHTML=i,p.style.transition="300ms all",p.style.transform="scale(1)",p.style.transform=`scale(1.07) translateX(${this.lang.Direction==="rtl"?"-":""}4px)`,clearTimeout(this.timeout),this.timeout=setTimeout(()=>{p.innerHTML=this.getButtonText(),p.style.transition="none",p.style.transform="scale(1)"},5e3)})}}const qt=`\r \r \r -`;class Kt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Twitter");o(this,"icon",qt);o(this,"backgroundColor","#1DA1F2");o(this,"backgroundHoverColor","#1a93dd");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t,i;return`https://twitter.com/share?text=${encodeURIComponent((t=this.options)==null?void 0:t.shareText)}&url=${(i=this.options)==null?void 0:i.shareLink}`}}const Yt=`\r -`;class Jt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Linkedin");o(this,"icon",Yt);o(this,"backgroundColor","#0077B5");o(this,"backgroundHoverColor","#026092");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t;return`https://www.linkedin.com/sharing/share-offsite/?url=${(t=this.options)==null?void 0:t.shareLink}`}}const Qt=`\r +`;class Kt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Twitter");o(this,"icon",qt);o(this,"backgroundColor","#1DA1F2");o(this,"backgroundHoverColor","#1a93dd");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t,i;return`https://twitter.com/intent/tweet?text=${encodeURIComponent((t=this.options)==null?void 0:t.shareText)}&url=${(i=this.options)==null?void 0:i.shareLink}`}}const Yt=`\r +`;class Jt extends j{constructor(t,i){super(t,i);o(this,"buttonText","Linkedin");o(this,"icon",Yt);o(this,"backgroundColor","#0077B5");o(this,"backgroundHoverColor","#026092");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t;return`https://www.linkedin.com/shareArticle?url=${(t=this.options)==null?void 0:t.shareLink}`}}const Qt=`\r \r \r -`;class en extends j{constructor(t,i){super(t,i);o(this,"buttonText","Facebook");o(this,"icon",Qt);o(this,"backgroundColor","#4267B2");o(this,"backgroundHoverColor","#355696");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t,i;return`https://twitter.com/share?text=${encodeURIComponent((t=this.options)==null?void 0:t.shareText)}&url=${(i=this.options)==null?void 0:i.shareLink}`}}const tn=`\r +`;class en extends j{constructor(t,i){super(t,i);o(this,"buttonText","Facebook");o(this,"icon",Qt);o(this,"backgroundColor","#4267B2");o(this,"backgroundHoverColor","#355696");o(this,"textColor","#fff");o(this,"textHoverColor","#fff")}getLink(){var t,i;return`https://facebook.com/sharer/sharer.php?u=${(t=this.options)==null?void 0:t.shareLink}&t=${encodeURIComponent((i=this.options)==null?void 0:i.shareText)}`}}const tn=`\r \r \r \r diff --git a/src/lib/strategies/FixedStrategy.ts b/src/lib/strategies/FixedStrategy.ts index c8b7c4b..e5fa540 100644 --- a/src/lib/strategies/FixedStrategy.ts +++ b/src/lib/strategies/FixedStrategy.ts @@ -120,6 +120,7 @@ export default class FixedStrategy extends BaseStrategy { driver.mainEl.href = driver.getLink(); } this.initDriverStyles(driver); + this.listenDriverEvents(driver); const icon = document.createElement('div'); icon.innerHTML = driver.icon; const text = document.createElement('div'); @@ -135,4 +136,10 @@ export default class FixedStrategy extends BaseStrategy { return driver.mainEl; } + + protected listenDriverEvents(driver: Driver) { + const onDriverClick = this.onDriverClick(driver) + this.driverListeners[driver.buttonText] = [onDriverClick] + driver.mainEl!.addEventListener('click', onDriverClick); + } }