@dorgtech/web3modal-angular
Version:
Web3Modal implementation for Angular
16 lines (14 loc) • 9.4 kB
JavaScript
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("@angular/core"),require("@mindsorg/web3modal-ts"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("@dorgtech/web3modal-angular",["exports","@angular/core","@mindsorg/web3modal-ts","rxjs/operators","@angular/common"],o):o(((e="undefined"!=typeof globalThis?globalThis:e||self).dorgtech=e.dorgtech||{},e.dorgtech["web3modal-angular"]={}),e.ng.core,e.web3modalTs,e.rxjs.operators,e.ng.common)}(this,(function(e,o,t,n,r){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function i(e,o){var t,n,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:d(0),throw:d(1),return:d(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function d(i){return function(d){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=o.call(e,a)}catch(e){i=[6,e],n=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,d])}}}Object.create;Object.create;var a=this&&this.__awaiter||function(e,o,t,n){return new(t||(t=Promise))((function(r,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function d(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):new t((function(o){o(e.value)})).then(a,d)}l((n=n.apply(e,o||[])).next())}))},d=function(){function e(e){this.shouldOpen=new o.EventEmitter,this.providers=new o.EventEmitter,this.web3WalletConnector=new t.Web3WalletConnector(e)}return e.prototype.open=function(){return a(this,void 0,void 0,(function(){var e=this;return i(this,(function(o){switch(o.label){case 0:return this.providers.next(this.web3WalletConnector.providers),[4,new Promise((function(o,r){e.web3WalletConnector.providerController.on(t.CONNECT_EVENT,(function(e){o(e)})),e.web3WalletConnector.providerController.on(t.ERROR_EVENT,(function(e){r(e)})),e.shouldOpen.next(!0),e.shouldOpen.pipe(n.take(1)).subscribe({next:function(e){e||r("Dismissed modal")}})})).finally((function(){e.close()}))];case 1:return[2,o.sent()]}}))}))},e.prototype.setConfiguration=function(e){this.web3WalletConnector.setConfiguration(e)},e.prototype.clearCachedProvider=function(){this.web3WalletConnector.providerController.clearCachedProvider()},e.prototype.setCachedProvider=function(e){this.web3WalletConnector.providerController.setCachedProvider(e)},e.prototype.close=function(){this.shouldOpen.next(!1)},e}();d.decorators=[{type:o.Injectable}],d.ctorParameters=function(){return[{type:void 0,decorators:[{type:o.Optional}]}]};var l=function(){function e(e){this.service=e,this.open=!1,this.providers=[]}return e.prototype.ngOnInit=function(){var e=this;this.openSubscription=this.service.shouldOpen.subscribe({next:function(o){e.open=o}}),this.providersSubscription=this.service.providers.subscribe({next:function(o){e.providers=o}})},e.prototype.ngOnDestroy=function(){this.openSubscription.unsubscribe(),this.providersSubscription.unsubscribe()},e.prototype.close=function(){this.service.close()},e}();l.decorators=[{type:o.Component,args:[{selector:"m-web3-modal",template:'<m-modal [open]="open" (closed)="close()">\n <div class="m-web3Modal">\n <div class="m-web3Modal__header">\n <h3 class="m-web3ModalHeader__title">\n {{ title }}\n </h3>\n <div class="m-web3ModalHeader__description">\n <p class="m-web3ModalHeader__text">\n {{ description }}\n </p>\n <p\n class="m-web3ModalHeader__text--gray m-web3ModalHeader__text"\n >\n {{ descriptionGray }}\n </p>\n </div>\n </div>\n <div class="m-web3Modal__body">\n <div class="m-web3ModalBody__provider">\n <div\n class="m-web3ModalProvider__body"\n *ngFor="let provider of providers"\n (click)="provider.onClick()"\n >\n <div class="m-web3ModalProviderBody__icon">\n <img [src]="provider.logo" [alt]="provider.logo" />\n </div>\n <div class="m-web3ModalProviderBody__name">\n {{ provider.name }}\n </div>\n </div>\n </div>\n </div>\n <div class="m-web3Modal__footer">\n <div class="m-web3ModalFooter__description">\n <p class="m-web3ModalFooter__text" (click)="close()">\n {{ dismissText }}\n </p>\n </div>\n </div>\n </div> \n</m-modal>\n',encapsulation:o.ViewEncapsulation.None,styles:[".m-web3Modal{background-color:#fff;box-sizing:border-box;display:block;margin:auto;position:relative;width:100%}@media screen and (max-width:540px){.m-web3Modal{border-radius:0;display:flex;flex:1;flex-direction:column;justify-content:space-between;margin:0}}.m-web3Modal__header{padding:40px 50px 0}.m-web3ModalHeader__title{color:#4f4f50;font-size:30px;font-weight:800;margin:0}.m-web3ModalHeader__text{color:#4f4f50;font-size:16px;font-weight:600;line-height:22px;margin:0}.m-web3ModalHeader__description{display:flex;flex-direction:column;justify-content:center;min-height:70px}.m-web3ModalHeader__text--gray{color:#7d7d82;margin:0}.m-web3Modal__footer{display:flex;flex-direction:column;height:100px;justify-content:center;margin-top:-40px;padding:0 50px}@media screen and (max-width:768px){.m-web3Modal__footer{margin-top:-20px}}.m-web3ModalFooter__text{color:#7d7d82;cursor:pointer;font-size:17px;font-weight:600;margin:0;text-align:center}.m-web3Modal__body{max-height:420px;overflow-y:auto;padding:20px 50px}.m-web3ModalBody__provider{display:flex;flex-wrap:wrap;justify-content:space-between}@media screen and (max-width:540px){.m-web3ModalBody__provider{justify-content:center}}.m-web3ModalProvider__body{align-items:center;background-color:#fff;border:1px solid #dce2e4;cursor:pointer;display:flex;flex-direction:column;height:165px;justify-content:center;margin-bottom:20px;width:194px}.m-web3ModalProviderBody__name{color:#4f4f50;font-size:15px;font-weight:600;margin-top:12px}.m-web3ModalProviderBody__icon{align-items:center;border-radius:50%;box-shadow:none;display:flex;height:60px;justify-content:center;overflow:visible;width:60px}.m-web3ModalProviderBody__icon img{height:100%;width:100%}"]}]}],l.ctorParameters=function(){return[{type:d}]},l.propDecorators={title:[{type:o.Input}],description:[{type:o.Input}],descriptionGray:[{type:o.Input}],dismissText:[{type:o.Input}]};var s=function(){function e(){this.allowClose=!0,this.hidden=!0,this.closed=new o.EventEmitter}return Object.defineProperty(e.prototype,"_hidden",{set:function(e){this.hidden=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"open",{set:function(e){this.hidden=!e},enumerable:!0,configurable:!0}),e.prototype.close=function(e){this.allowClose&&(this.hidden=!this.hidden,this.closed.next(!0),e.stopPropagation())},e}();s.decorators=[{type:o.Component,args:[{selector:"m-modal",host:{"[hidden]":"hidden"},inputs:["open","allowClose"],outputs:["closed"],encapsulation:o.ViewEncapsulation.None,template:'<div class="m-modal-bg" (click)="close($event)"></div>\n<div class="m-modal-container">\n <ng-content></ng-content>\n</div>',styles:["m-modal .m-modal-bg{background-color:rgba(0,0,0,.8);cursor:pointer;height:100%;left:0;position:fixed;top:0;width:100%;z-index:99999991}m-modal .m-modal-container{-webkit-overflow-scrolling:touch;border-radius:6px;box-sizing:border-box;display:block;font-family:Roboto,sans-serif;left:50%;margin:auto;max-height:98vh;max-width:100%;outline:0;overflow-y:auto;padding:32px;position:fixed;top:50%;transform:translate(-50%,-50%);width:800px;z-index:99999995}m-modal{bottom:0;height:100%;left:0;overflow:overlay;overflow:scroll;position:relative;right:0;top:0;width:100%}"]}]}];var c=function(){};c.decorators=[{type:o.NgModule,args:[{imports:[r.CommonModule],declarations:[s,l],exports:[l]}]}],e.Web3ModalComponent=l,e.Web3ModalModule=c,e.Web3ModalService=d,e.ɵa=s,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=dorgtech-web3modal-angular.umd.min.js.map