Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@digital-realty/ix-account-switcher

Package Overview
Dependencies
Maintainers
5
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digital-realty/ix-account-switcher - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

2

dist/ix-account-switcher.min.js

@@ -1,1 +0,1 @@

import{html,nothing,css}from"lit";import{elementTheme}from"@digital-realty/theme";import{__decorate}from"tslib";import"@digital-realty/ix-dialog/ix-dialog.js";import"@digital-realty/ix-field/ix-field.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import"@digital-realty/ix-label-tag/ix-label-tag.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-tree/ix-tree.js";import{property,state}from"lit/decorators.js";import{MobxLitElement}from"@adobe/lit-mobx";import{makeAutoObservable}from"mobx";import{makePersistable}from"mobx-persist-store";class AuthedUserState{constructor(){this.account_number="",this.email="",this.name="",this.auth_time="",makeAutoObservable(this),makePersistable(this,{name:"x-auth",properties:["email","account_number","name","auth_time"],storage:window.localStorage})}setAccount({accountNumber:e,email:t,name:i,authTime:o}){this.account_number=e,this.email=t,this.name=i,this.auth_time=o}getAccount(){return{accountNumber:this.account_number,email:this.email,name:this.name,authTime:this.auth_time}}}const authedUser=new AuthedUserState,findAccountById=(e,t)=>{var i=e.find(e=>e.id===t);if(i)return i;for(const c of e)if(c.subaccounts){var o=findAccountById(c.subaccounts,t);if(o)return o}return null},mapAccountToTreeNode=(e,t)=>{const i={expanded:!1,id:e.id,label:e.name,parentId:t.id};return i.children=null==(t=e.subaccounts)?void 0:t.map(e=>mapAccountToTreeNode(e,i)),i},mapAccountsToTreeNode=e=>{const t={expanded:!1,id:"root",label:"",parentId:void 0};return t.children=e.map(e=>mapAccountToTreeNode(e,t)),t};class IxAccountSwitcher extends MobxLitElement{constructor(){super(...arguments),this.accounts=[],this.showDialog=!1}renderDialog(){var e=mapAccountsToTreeNode(this.accounts);return html`<ix-dialog id="account-switcher-dialog" class="relative z-50" ?open="${this.showDialog}" @blur="${()=>{this.showDialog=!1}}"><div class="headline" slot="headline"><span class="title">Switch Account</span><ix-icon-button @click="${()=>{this.showDialog=!1}}" icon="close"></ix-icon-button></div><form id="account-switcher-dialog-form" class="form" method="dialog" slot="content"><ix-tree .rootNode="${e}" .selectedNodeId="${authedUser.account_number}" @on-tree-node-selected="${e=>{this.showDialog=!1,this.dispatchEvent(new CustomEvent("account-switched",{detail:e.detail.message.id,bubbles:!0,composed:!0}))}}"></ix-tree></form></ix-dialog>`}getSelectedAccount(){return findAccountById(this.accounts,authedUser.account_number)}renderNestedAccountStructureSelect(){var e=this.getSelectedAccount();return html`<ix-field @click="${()=>{this.showDialog=!0}}"><div class="subaccount-wrap"><span class="subaccount-name">${null==e?void 0:e.name}</span><ix-icon class="dd-icon">arrow_drop_down</ix-icon></div></ix-field>`}renderFlatAccountStructureSelect(){const i=this.getSelectedAccount(),o=html`<ix-label-tag>Active</ix-label-tag>`;var e=this.accounts.map(e=>{var t=e.id===(null===i||void 0===i?void 0:i.id);return html`<ix-select-option value="${e.id}" .selected="${t}"><div slot="headline">${e.name}</div><div slot="end">${t?o:nothing}</div></ix-select-option>`});return html`<div class="account-switcher__select"><ix-select @request-selection="${e=>{e=e.target;this.dispatchEvent(new CustomEvent("account-switched",{detail:e.value,bubbles:!0,composed:!0}))}}">${e}</ix-select></div>`}render(){var e=this.accounts.some(e=>e.subaccounts&&0<e.subaccounts.length);return html`<div class="account-switcher-container">${e?this.renderNestedAccountStructureSelect():this.renderFlatAccountStructureSelect()}</div>${e?this.renderDialog():null}`}}__decorate([property({type:Array})],IxAccountSwitcher.prototype,"accounts",void 0),__decorate([state()],IxAccountSwitcher.prototype,"showDialog",void 0);const AccountSwitcherStyles=css`.subaccount-wrap{display:flex;--ix-icon-font-size:1.6rem}.subaccount-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:0;flex:1}.dd-icon{margin:-2px -5px -5px 0}.headline{display:flex}.title{flex:1}.form{border:1px solid #e0e0e0;border-radius:.25rem;height:calc(488px - 3rem);margin:1rem 1.5rem 1.5rem 1.5rem;padding:0;width:calc(560px - 3rem);overflow:auto}`;class IxAccountSwitcherStyled extends IxAccountSwitcher{}IxAccountSwitcherStyled.styles=[elementTheme,AccountSwitcherStyles,css`:host{--md-theme-primary:var(--ix-sys-primary, blue)}`],window.customElements.define("ix-account-switcher",IxAccountSwitcherStyled);export{IxAccountSwitcherStyled};
import{html,nothing,css}from"lit";import{elementTheme}from"@digital-realty/theme";import{__decorate}from"tslib";import"@digital-realty/ix-dialog/ix-dialog.js";import"@digital-realty/ix-field/ix-field.js";import"@digital-realty/ix-icon-button/ix-icon-button.js";import"@digital-realty/ix-label-tag/ix-label-tag.js";import"@digital-realty/ix-select/ix-select.js";import"@digital-realty/ix-select/ix-select-option.js";import"@digital-realty/ix-tree/ix-tree.js";import{property,state}from"lit/decorators.js";import{MobxLitElement}from"@adobe/lit-mobx";import{makeAutoObservable}from"mobx";import{makePersistable}from"mobx-persist-store";class AuthedUserState{constructor(){this.account_number="",this.email="",this.name="",this.auth_time="",this.access_token="",this.id_token="",makeAutoObservable(this),makePersistable(this,{name:"x-auth",properties:["email","account_number","name","auth_time","id_token","access_token"],storage:window.localStorage})}setAccount({accountNumber:e,email:t,name:i,authTime:o,accessToken:c,idToken:s}){this.account_number=e,this.email=t,this.name=i,this.auth_time=o,this.access_token=c,this.id_token=s}getAccount(){return{accountNumber:this.account_number,email:this.email,name:this.name,authTime:this.auth_time}}getAccessToken(){return this.access_token}getIdToken(){return this.id_token}}const authedUser=new AuthedUserState,findAccountById=(e,t)=>{var i=e.find(e=>e.id===t);if(i)return i;for(const c of e)if(c.subaccounts){var o=findAccountById(c.subaccounts,t);if(o)return o}return null},mapAccountToTreeNode=(e,t)=>{const i={expanded:!1,id:e.id,label:e.name,parentId:t.id};return i.children=null==(t=e.subaccounts)?void 0:t.map(e=>mapAccountToTreeNode(e,i)),i},mapAccountsToTreeNode=e=>{const t={expanded:!1,id:"root",label:"",parentId:void 0};return t.children=e.map(e=>mapAccountToTreeNode(e,t)),t};class IxAccountSwitcher extends MobxLitElement{constructor(){super(...arguments),this.accounts=[],this.showDialog=!1}renderDialog(){var e=mapAccountsToTreeNode(this.accounts);return html`<ix-dialog id="account-switcher-dialog" class="relative z-50" ?open="${this.showDialog}" @blur="${()=>{this.showDialog=!1}}"><div class="headline" slot="headline"><span class="title">Switch Account</span><ix-icon-button @click="${()=>{this.showDialog=!1}}" icon="close"></ix-icon-button></div><form id="account-switcher-dialog-form" class="form" method="dialog" slot="content"><ix-tree .rootNode="${e}" .selectedNodeId="${authedUser.account_number}" @on-tree-node-selected="${e=>{this.showDialog=!1,this.dispatchEvent(new CustomEvent("account-switched",{detail:e.detail.message.id,bubbles:!0,composed:!0}))}}"></ix-tree></form></ix-dialog>`}getSelectedAccount(){return findAccountById(this.accounts,authedUser.account_number)}renderNestedAccountStructureSelect(){var e=this.getSelectedAccount();return html`<ix-field @click="${()=>{this.showDialog=!0}}"><div class="subaccount-wrap"><span class="subaccount-name">${null==e?void 0:e.name}</span><ix-icon class="dd-icon">arrow_drop_down</ix-icon></div></ix-field>`}renderFlatAccountStructureSelect(){const i=this.getSelectedAccount(),o=html`<ix-label-tag>Active</ix-label-tag>`;var e=this.accounts.map(e=>{var t=e.id===(null===i||void 0===i?void 0:i.id);return html`<ix-select-option value="${e.id}" .selected="${t}"><div slot="headline">${e.name}</div><div slot="end">${t?o:nothing}</div></ix-select-option>`});return html`<div class="account-switcher__select"><ix-select @request-selection="${e=>{e=e.target;this.dispatchEvent(new CustomEvent("account-switched",{detail:e.value,bubbles:!0,composed:!0}))}}">${e}</ix-select></div>`}render(){var e=this.accounts.some(e=>e.subaccounts&&0<e.subaccounts.length);return html`<div class="account-switcher-container">${e?this.renderNestedAccountStructureSelect():this.renderFlatAccountStructureSelect()}</div>${e?this.renderDialog():null}`}}__decorate([property({type:Array})],IxAccountSwitcher.prototype,"accounts",void 0),__decorate([state()],IxAccountSwitcher.prototype,"showDialog",void 0);const AccountSwitcherStyles=css`.subaccount-wrap{display:flex;--ix-icon-font-size:1.6rem}.subaccount-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:0;flex:1}.dd-icon{margin:-2px -5px -5px 0}.headline{display:flex}.title{flex:1}.form{border:1px solid #e0e0e0;border-radius:.25rem;height:calc(488px - 3rem);margin:1rem 1.5rem 1.5rem 1.5rem;padding:0;width:calc(560px - 3rem);overflow:auto}`;class IxAccountSwitcherStyled extends IxAccountSwitcher{}IxAccountSwitcherStyled.styles=[elementTheme,AccountSwitcherStyles,css`:host{--md-theme-primary:var(--ix-sys-primary, blue)}`],window.customElements.define("ix-account-switcher",IxAccountSwitcherStyled);export{IxAccountSwitcherStyled};

@@ -7,6 +7,10 @@ declare class AuthedUserState {

auth_time: string;
setAccount({ accountNumber, email, name, authTime, }: Record<string, string>): void;
access_token: string;
id_token: string;
setAccount({ accountNumber, email, name, authTime, accessToken, idToken, }: Record<string, string>): void;
getAccount(): Record<string, string>;
getAccessToken(): string;
getIdToken(): string;
}
export declare const authedUser: AuthedUserState;
export {};

@@ -9,10 +9,19 @@ import { makeAutoObservable } from 'mobx';

this.auth_time = '';
this.access_token = '';
this.id_token = '';
makeAutoObservable(this);
makePersistable(this, {
name: 'x-auth',
properties: ['email', 'account_number', 'name', 'auth_time'],
properties: [
'email',
'account_number',
'name',
'auth_time',
'id_token',
'access_token',
],
storage: window.localStorage,
});
}
setAccount({ accountNumber, email, name, authTime, }) {
setAccount({ accountNumber, email, name, authTime, accessToken, idToken, }) {
this.account_number = accountNumber;

@@ -22,2 +31,4 @@ this.email = email;

this.auth_time = authTime;
this.access_token = accessToken;
this.id_token = idToken;
}

@@ -32,4 +43,10 @@ getAccount() {

}
getAccessToken() {
return this.access_token;
}
getIdToken() {
return this.id_token;
}
}
export const authedUser = new AuthedUserState();
//# sourceMappingURL=authedUser.js.map

@@ -6,3 +6,3 @@ {

"author": "Digital Realty",
"version": "1.0.6",
"version": "1.0.7",
"type": "module",

@@ -110,3 +110,3 @@ "main": "dist/index.js",

],
"gitHead": "c8089ae61b532ce8e7b0649d70974f329e6a4400"
"gitHead": "a59878f69290a4f76fad90db2657dcb932b4a478"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc