UNPKG

@odilo/buttons

Version:

Share buttons components for Angular and Ionic.

2 lines 5.58 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/common"),require("@odilo/button"),require("@odilo/core"),require("rxjs"),require("rxjs/operators"),require("@angular/core")):"function"==typeof define&&define.amd?define("@odilo/buttons",["exports","@angular/common","@odilo/button","@odilo/core","rxjs","rxjs/operators","@angular/core"],e):e((t.odilo=t.odilo||{},t.odilo.buttons={}),t.ng.common,t.button,t.core,t.rxjs,t.rxjs.operators,t.ng.core)}(this,function(t,e,n,o,s,u,r){"use strict";var i=function(){return(i=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},a=(Object.defineProperty(c.prototype,"includedButtons",{set:function(t){this.updateState({includedButtons:t})},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"excludedButtons",{set:function(t){this.updateState({excludedButtons:t})},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"shownButtons",{set:function(t){this.updateState({shownCount:t})},enumerable:!0,configurable:!0}),c.prototype.ngOnInit=function(){var n=this;this.state$=this._state$.pipe(u.map(function(e){var t=(e.includedButtons.length?e.includedButtons:e.userButtons).filter(function(t){return e.excludedButtons.indexOf(t)<0}),n=t.slice(0,e.expanded?t.length:e.shownCount);return{userButtons:t,selectedButtons:n,expanded:e.expanded,shownCount:e.shownCount,moreIcon:e.moreIcon,lessIcon:e.lessIcon}})),this._configSub$=this._share.config$.subscribe(function(e){var t=(e.include.length?e.include:Object.keys(o.SHARE_BUTTONS)).filter(function(t){return e.exclude.indexOf(t)<0});n.updateState({userButtons:t,expanded:!1,moreIcon:e.moreButtonIcon,lessIcon:e.lessButtonIcon})})},c.prototype.ngOnDestroy=function(){this._configSub$.unsubscribe(),this._state$.complete()},c.prototype.updateState=function(t){this._state$.next(i({},this._state$.value,t))},c.decorators=[{type:r.Component,args:[{selector:"share-buttons",template:'<div *ngIf="state$ | async; let state" class="sb-group sb-{{theme}}">\n\n <share-button *ngFor="let button of state.selectedButtons"\n [button]="button"\n [theme]="theme"\n [url]="url"\n [title]="title"\n [description]="description"\n [image]="image"\n [tags]="tags"\n [autoSetMeta]="autoSetMeta"\n [showCount]="showCount"\n [showIcon]="showIcon"\n [showText]="showText"\n [size]="size"\n (opened)="opened.emit($event)"\n (closed)="closed.emit($event)"\n (count)="count.emit($event)"></share-button>\n\n <div class="sb-button sb-{{theme}}">\n\n <expand-button *ngIf="state.shownCount < state.userButtons.length"\n [expanded]="state.expanded"\n [moreIcon]="state.moreIcon"\n [lessIcon]="state.lessIcon"\n [size]="(1 + size/20) * 14"\n (toggle)="updateState({expanded: $event})">\n </expand-button>\n\n </div>\n</div>\n',changeDetection:r.ChangeDetectionStrategy.OnPush,styles:[":host{display:inherit}"]}]}],c.ctorParameters=function(){return[{type:o.ShareService}]},c.propDecorators={theme:[{type:r.Input}],includedButtons:[{type:r.Input,args:["include"]}],excludedButtons:[{type:r.Input,args:["exclude"]}],shownButtons:[{type:r.Input,args:["show"]}],url:[{type:r.Input}],title:[{type:r.Input}],description:[{type:r.Input}],image:[{type:r.Input}],tags:[{type:r.Input}],autoSetMeta:[{type:r.Input}],showIcon:[{type:r.Input}],showText:[{type:r.Input}],showCount:[{type:r.Input}],size:[{type:r.Input}],count:[{type:r.Output}],opened:[{type:r.Output}],closed:[{type:r.Output}]},c);function c(t){this._share=t,this._state$=new s.BehaviorSubject({includedButtons:[],excludedButtons:[],userButtons:[],selectedButtons:[],expanded:!0,shownCount:Object.keys(o.SHARE_BUTTONS).length}),this._configSub$=s.Subscription.EMPTY,this.theme=this._share.config.theme,this.showIcon=!0,this.showText=!1,this.showCount=!1,this.size=0,this.count=new r.EventEmitter,this.opened=new r.EventEmitter,this.closed=new r.EventEmitter}var p=(d.decorators=[{type:r.Component,args:[{selector:"expand-button",changeDetection:r.ChangeDetectionStrategy.OnPush,template:'\n <button class="sb-wrapper sb-expand sb-show-icon"\n [style.fontSize.px]="size"\n [attr.aria-label]="\'share\'"\n (click)="toggle.emit(!expanded)">\n\n <div class="sb-inner">\n <div class="sb-content">\n <div class="sb-icon">\n <fa-icon [icon]="expanded ? lessIcon : moreIcon"></fa-icon>\n </div>\n </div>\n </div>\n </button>\n '}]}],d.ctorParameters=function(){return[{type:r.ElementRef}]},d.propDecorators={moreIcon:[{type:r.Input}],lessIcon:[{type:r.Input}],expanded:[{type:r.Input}],size:[{type:r.Input}],toggle:[{type:r.Output}]},d);function d(t){this.toggle=new r.EventEmitter,t.nativeElement.style.setProperty("--button-color","#FF6651")}var l=(h.withConfig=function(t){return{ngModule:h,providers:[{provide:o.SHARE_BUTTONS_CONFIG,useValue:t}]}},h.decorators=[{type:r.NgModule,args:[{declarations:[a,p],imports:[n.ShareButtonModule,e.CommonModule],exports:[n.ShareButtonModule,a]}]}],h);function h(){}t.ShareButtonsModule=l,t.ShareButtons=a,t.ɵa=p,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=odilo-buttons.umd.min.js.map