UNPKG

@mornya/react-social-libs

Version:

The project of React.js Social Share and Widget modules.

1 lines 2.61 kB
var n,e,t=this&&this.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(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}n(t,e),t.prototype=null===e?Object.create(e):(__.prototype=e.prototype,new __)}),i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},r=(Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseWidgetComponent=void 0,o(require("react"))),o=o(require("./BaseComponent")),o=(e=o.default,t(BaseWidgetComponent,e),BaseWidgetComponent.prototype.componentDidMount=function(){var t,e=this,n=this.getDefaultMetaContent(),o=i(i({},this.defaultExtra),this.props.extra);null!=(t=o.hashtags)&&t.length||(o.hashtags=this.getDefaultHashtags(n.keywords)),this.setState({OG:n,extra:o},function(){return e.onMount(o)})},BaseWidgetComponent.prototype.componentWillUnmount=function(){this.onUnmount(this.state.extra)},BaseWidgetComponent.prototype.initialize=function(t,e){this.widgetId=t.toLowerCase(),this.defaultExtra=e},BaseWidgetComponent.prototype.getApiStep=function(){return this.state.apiStep},BaseWidgetComponent.prototype.setApiStep=function(t){this.setState({apiStep:this.state.apiStep+1},t)},BaseWidgetComponent.prototype.onInit=function(){},BaseWidgetComponent.prototype.onRender=function(t,e){return null},BaseWidgetComponent.prototype.onMount=function(t){},BaseWidgetComponent.prototype.onUnmount=function(t){},BaseWidgetComponent.prototype.render=function(){return this.state.extra&&this.state.OG?r.default.createElement("div",{className:"mornya-lib sns-widget ".concat(this.widgetId)},this.onRender(this.state.extra,this.state.OG)):null},BaseWidgetComponent);function BaseWidgetComponent(t){t=e.call(this,t)||this;return t.state={OG:void 0,extra:void 0,apiStep:0},t.widgetId="",t.initialize=t.initialize.bind(t),t.getApiStep=t.getApiStep.bind(t),t.setApiStep=t.setApiStep.bind(t),t.onInit=t.onInit.bind(t),t.onMount=t.onMount.bind(t),t.onRender=t.onRender.bind(t),t.onUnmount=t.onUnmount.bind(t),t.id="widget-".concat(e.prototype.getUID.call(t)).concat(e.prototype.getUID.call(t)),t.defaultExtra={},t.onInit(),t}exports.BaseWidgetComponent=o;