@digital-realty/ix-account-switcher 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,7 +22,6 @@ export class IxAccountSwitcher extends LitElement {
|
|
|
22
22
|
const rootNode = mapAccountsToTreeNode(this.accounts);
|
|
23
23
|
return html `<ix-dialog
|
|
24
24
|
id="account-switcher-dialog"
|
|
25
|
-
class="relative z-50"
|
|
26
25
|
?open=${this.showDialog}
|
|
27
26
|
@blur=${() => {
|
|
28
27
|
this.showDialog = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxAccountSwitcher.js","sourceRoot":"","sources":["../src/IxAccountSwitcher.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,kDAAkD,CAAC;AAC1D,OAAO,8CAA8C,CAAC;AACtD,OAAO,wCAAwC,CAAC;AAChD,OAAO,+CAA+C,CAAC;AACvD,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAAjD;;QAC6C,0BAAqB,GAAW,EAAE,CAAC;QAEnD,aAAQ,GAAqB,EAAE,CAAC;QAE9B,aAAQ,GAAY,KAAK,CAAC;QAE9C,eAAU,GAAY,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"IxAccountSwitcher.js","sourceRoot":"","sources":["../src/IxAccountSwitcher.ts"],"names":[],"mappings":";AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,sCAAsC,CAAC;AAC9C,OAAO,kDA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N,CAAC;IACV,CAAC;IAED,MAAM;QACJ,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CACvC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAC/C,CAAC;QAEF,OAAO,IAAI,CAAA;;UAEL,cAAc;YACd,CAAC,CAAC,IAAI,CAAC,kCAAkC,EAAE;YAC3C,CAAC,CAAC,IAAI,CAAC,gCAAgC,EAAE;;;QAG3C,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI;KAC9C,CAAC;IACJ,CAAC;CACF;AA5H4C;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gEAAoC;AAEnD;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mDAAiC;AAE9B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAA2B;AAE9C;IAAR,KAAK,EAAE;qDAA6B","sourcesContent":["import '@digital-realty/ix-dialog/ix-dialog.js';\nimport '@digital-realty/ix-field/ix-field.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-label-tag/ix-label-tag.js';\nimport '@digital-realty/ix-select/ix-select.js';\nimport '@digital-realty/ix-select/ix-select-option.js';\nimport '@digital-realty/ix-tree/ix-tree.js';\nimport type { IIxTreeNode } from '@digital-realty/ix-tree';\nimport { html, LitElement, nothing, TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport findAccountById from './utils/find-account-by-id.js';\nimport { mapAccountsToTreeNode } from './utils/map-accounts-to-tree.js';\nimport type { NestedAccounts } from './types.js';\n\nexport class IxAccountSwitcher extends LitElement {\n @property({ type: String, reflect: true }) selectedAccountNumber: string = '';\n\n @property({ type: Array }) accounts: NestedAccounts[] = [];\n\n @property({ type: Boolean }) disabled: boolean = false;\n\n @state() showDialog: boolean = false;\n\n private renderDialog(): TemplateResult<1> {\n const rootNode: IIxTreeNode = mapAccountsToTreeNode(this.accounts);\n\n return html`<ix-dialog\n id=\"account-switcher-dialog\"\n ?open=${this.showDialog}\n @blur=${() => {\n this.showDialog = false;\n }}\n >\n <div class=\"headline\" slot=\"headline\">\n <span class=\"title\">Switch Account</span>\n <ix-icon-button\n @click=${() => {\n this.showDialog = false;\n }}\n icon=\"close\"\n >\n </ix-icon-button>\n </div>\n <form\n id=\"account-switcher-dialog-form\"\n class=\"form\"\n method=\"dialog\"\n slot=\"content\"\n >\n <ix-tree\n hasIcons\n .rootNode=${rootNode}\n .selectedNodeId=${this.selectedAccountNumber}\n @on-tree-node-selected=${(e: CustomEvent) => {\n this.showDialog = false;\n this.dispatchEvent(\n new CustomEvent('account-switched', {\n detail: e.detail.message.id,\n bubbles: true,\n composed: true,\n })\n );\n }}\n ></ix-tree>\n </form>\n </ix-dialog>`;\n }\n\n getSelectedAccount() {\n return findAccountById(this.accounts, this.selectedAccountNumber as string);\n }\n\n private renderNestedAccountStructureSelect(): TemplateResult<1> {\n const selectedAccount = this.getSelectedAccount();\n\n return html`\n <ix-field\n ?disabled=${this.disabled}\n @click=${() => {\n if (!this.disabled) {\n this.showDialog = true;\n }\n }}\n >\n <div class=\"subaccount-wrap\">\n <span class=\"subaccount-name\"> ${selectedAccount?.name} </span>\n <ix-icon class=\"dd-icon\">arrow_drop_down</ix-icon>\n </div>\n </ix-field>\n `;\n }\n\n private renderFlatAccountStructureSelect(): TemplateResult<1> {\n const selectedAccount = this.getSelectedAccount();\n const activeLabelTag = html`<ix-label-tag>Active</ix-label-tag>`;\n\n const options = this.accounts.map(account => {\n const isSelected = account.id === selectedAccount?.id;\n\n return html`<ix-select-option value=${account.id} .selected=${isSelected}>\n <div slot=\"headline\">${account.name}</div>\n <div slot=\"end\">${isSelected ? activeLabelTag : nothing}</div>\n </ix-select-option>`;\n });\n\n return html`<div class=\"account-switcher__select\">\n <ix-select\n ?disabled=${this.disabled}\n @request-selection=${(e: Event) => {\n const target = e.target as HTMLSelectElement;\n this.dispatchEvent(\n new CustomEvent('account-switched', {\n detail: target.value,\n bubbles: true,\n composed: true,\n })\n );\n }}\n >\n ${options}\n </ix-select>\n </div>`;\n }\n\n render(): TemplateResult<1> {\n const hasSubaccounts = this.accounts.some(\n a => a.subaccounts && a.subaccounts.length > 0\n );\n\n return html`\n <div class=\"account-switcher-container\">\n ${hasSubaccounts\n ? this.renderNestedAccountStructureSelect()\n : this.renderFlatAccountStructureSelect()}\n </div>\n\n ${hasSubaccounts ? this.renderDialog() : null}\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-switcher-styles.js","sourceRoot":"","sources":["../src/account-switcher-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"account-switcher-styles.js","sourceRoot":"","sources":["../src/account-switcher-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCvC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const AccountSwitcherStyles = css`\n #account-switcher-dialog {\n position: relative;\n z-index: var(--ix-account-switcher-z-index, 50);\n }\n .subaccount-wrap {\n display: flex;\n --ix-icon-font-size: 1.6rem;\n }\n .subaccount-name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 0;\n flex: 1;\n }\n .dd-icon {\n margin: -2px -5px -5px 0px;\n }\n .headline {\n display: flex;\n }\n .title {\n flex: 1;\n }\n .form {\n border: 1px solid #e0e0e0;\n border-radius: 0.25rem;\n height: calc(488px - 3rem);\n margin: 1rem 1.5rem 1.5rem 1.5rem;\n padding: 0;\n width: calc(560px - 3rem);\n overflow: auto;\n }\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LitElement,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";const findAccountById=(e,t)=>{var i=e.find(e=>e.id===t);if(i)return i;for(const o of e)if(o.subaccounts){var c=findAccountById(o.subaccounts,t);if(c)return c}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 LitElement{constructor(){super(...arguments),this.selectedAccountNumber="",this.accounts=[],this.disabled=!1,this.showDialog=!1}renderDialog(){var e=mapAccountsToTreeNode(this.accounts);return html`<ix-dialog id="account-switcher-dialog"
|
|
1
|
+
import{LitElement,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";const findAccountById=(e,t)=>{var i=e.find(e=>e.id===t);if(i)return i;for(const o of e)if(o.subaccounts){var c=findAccountById(o.subaccounts,t);if(c)return c}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 LitElement{constructor(){super(...arguments),this.selectedAccountNumber="",this.accounts=[],this.disabled=!1,this.showDialog=!1}renderDialog(){var e=mapAccountsToTreeNode(this.accounts);return html`<ix-dialog id="account-switcher-dialog" ?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 hasIcons .rootNode="${e}" .selectedNodeId="${this.selectedAccountNumber}" @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,this.selectedAccountNumber)}renderNestedAccountStructureSelect(){var e=this.getSelectedAccount();return html`<ix-field ?disabled="${this.disabled}" @click="${()=>{this.disabled||(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(),c=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?c:nothing}</div></ix-select-option>`});return html`<div class="account-switcher__select"><ix-select ?disabled="${this.disabled}" @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:String,reflect:!0})],IxAccountSwitcher.prototype,"selectedAccountNumber",void 0),__decorate([property({type:Array})],IxAccountSwitcher.prototype,"accounts",void 0),__decorate([property({type:Boolean})],IxAccountSwitcher.prototype,"disabled",void 0),__decorate([state()],IxAccountSwitcher.prototype,"showDialog",void 0);const AccountSwitcherStyles=css`#account-switcher-dialog{position:relative;z-index:var(--ix-account-switcher-z-index,50)}.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};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-account-switcher following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Digital Realty",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.13",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"README.md",
|
|
107
107
|
"LICENSE"
|
|
108
108
|
],
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "2a24e02cb5dc810e4ec36efd5c76c65e3b90da31"
|
|
110
110
|
}
|