@mornya/react-social-libs
Version:
The project of React.js Social Share and Widget modules.
1 lines • 2.7 kB
JavaScript
var o,t,e=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}))(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function __(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}),i=this&&this.__read||function(t,e){var o="function"==typeof Symbol&&t[Symbol.iterator];if(!o)return t;var r,n,a=o.call(t),i=[];try{for(;(void 0===e||0<e--)&&!(r=a.next()).done;)i.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}return i},r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},r=(Object.defineProperty(exports,"__esModule",{value:!0}),r(require("react"))),r=(t=r.default.Component,e(BaseComponent,t),BaseComponent.prototype.mapToParam=function(t,e){void 0===t&&(t="");var n=decodeURIComponent(t).includes("?"),a=!n||!t.endsWith("?");return e?Object.entries(e).reduce(function(t,e){var o,e=i(e,2),r=e[0],e=e[1];return e&&(o=void 0,o=Array.isArray(e)?e.map(function(t){return encodeURIComponent(t)}).join(","):"boolean"==typeof e?e?"true":"false":encodeURIComponent(String(e)),t+=(a?n?"&":"?":"")+"".concat(r,"=").concat(o),a=n=!0),t},t):t},BaseComponent.prototype.getUID=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)},BaseComponent.prototype.getDefaultMetaContent=function(){var r={title:"",description:"",url:"",type:"",siteName:"",image:"",keywords:"",videoDuration:"",musicDuration:""},t=(document.querySelectorAll("meta[property]").forEach(function(t){if(t){var e=t.getAttribute("property"),t=t.getAttribute("content");if(e&&t){var e=e.trim(),o=t.trim();switch(e){case"og:title":r.title=o;break;case"og:description":r.description=o;break;case"og:url":r.url=o;break;case"og:type":r.type=o;break;case"og:site_name":r.siteName=o;break;case"og:image":r.image=o;break;case"video:duration":r.videoDuration=o;break;case"music:duration":r.musicDuration=o}}}}),document.querySelector('meta[name="keywords"]'));return t&&(t=t.getAttribute("content"))&&(r.keywords=t),r},BaseComponent.prototype.getDefaultHashtags=function(t){return(t=void 0===t?"":t)?t.split(",").map(function(t){return t.trim().replace(/\s/g,"_")}):[]},BaseComponent.prototype.getHashtag=function(t,e){return void 0===e&&(e=""),(t=void 0===t?[]:t).length?e+t.map(function(t){return"#".concat(t.trim())}).join(" "):""},BaseComponent);function BaseComponent(){return null!==t&&t.apply(this,arguments)||this}exports.default=r;