@digital-realty/ix-grid 1.2.2 → 1.2.3
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.
|
@@ -67,12 +67,14 @@ let IxPagination = class IxPagination extends LitElement {
|
|
|
67
67
|
?disabled=${!back}
|
|
68
68
|
@click=${() => back && this.changePage(-1)}
|
|
69
69
|
icon="chevron_left"
|
|
70
|
+
data-testid="ix-pagination-prev"
|
|
70
71
|
>
|
|
71
72
|
</ix-icon-button>
|
|
72
73
|
<ix-icon-button
|
|
73
74
|
?disabled=${!next}
|
|
74
75
|
@click=${() => next && this.changePage(+1)}
|
|
75
76
|
icon="chevron_right"
|
|
77
|
+
data-testid="ix-pagination-next"
|
|
76
78
|
>
|
|
77
79
|
</ix-icon-button>
|
|
78
80
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxPagination.js","sourceRoot":"","sources":["../../src/components/IxPagination.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,kDAAkD,CAAC;AAC1D,OAAO,wCAAwC,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAGnC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAGuB,gBAAW,GAAG,CAAC,CAAC;QAEhB,SAAI,GAAG,CAAC,CAAC;QAET,aAAQ,GAAG,EAAE,CAAC;QAEf,cAAS,GAAa,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"IxPagination.js","sourceRoot":"","sources":["../../src/components/IxPagination.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,kDAAkD,CAAC;AAC1D,OAAO,wCAAwC,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAGnC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAGuB,gBAAW,GAAG,CAAC,CAAC;QAEhB,SAAI,GAAG,CAAC,CAAC;QAET,aAAQ,GAAG,EAAE,CAAC;QAEf,cAAS,GAAa,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IA0EpE,CAAC;IAxES,UAAU,CAAC,MAAc;QAC/B,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC;QACpB,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,gBAAgB,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC,QAAQ;QACzD,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,kBAAkB,EAAE;YAClC,MAAM,EAAE;gBACN,IAAI;gBACJ,QAAQ;aACT;YACD,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC1D,OAAO,IAAI,CAAA;iCACkB,IAAI,CAAC,WAAW;;;;;6BAKpB,CAAC,CAAQ,EAAE,EAAE;YAChC,MAAM,EAAE,GAAG,CAAC,CAAC,MAA0B,CAAC;YACxC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YACjC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,CAAC;yBACgB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;;;UAGpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAClB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAA;;;sBAGF,MAAM;0BACF,MAAM,KAAK,IAAI,CAAC,QAAQ;;qCAEb,MAAM;;WAEhC,CACF;;;UAGC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;UAC9D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW;YAC5C,CAAC,CAAC,IAAI,CAAA,GAAG,IAAI,CAAC,WAAW,EAAE;YAC3B,CAAC,CAAC,IAAI,CAAA,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE;aACjC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;;;;sBAIlC,CAAC,IAAI;mBACR,GAAG,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;;;;;;sBAM9B,CAAC,IAAI;mBACR,GAAG,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;;;;;;WAMzC,CAAC;IACV,CAAC;;AAjFe,mBAAM,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;AAElC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAiB;AAEhB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAU;AAET;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAe;AAEf;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;+CAAwC;AATvD,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAmFxB;SAnFY,YAAY","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-select/ix-select.js';\nimport { IxGridViewStyles } from '../grid-view-styles.js';\nimport { PaginationStyles } from './pagination-styles.js';\nimport { copy } from '../ix-grid-copy.js';\n\n@customElement('ix-pagination')\nexport class IxPagination extends LitElement {\n static readonly styles = [IxGridViewStyles, PaginationStyles];\n\n @property({ type: Number }) recordCount = 0;\n\n @property({ type: Number }) page = 1;\n\n @property({ type: Number }) pageSize = 10;\n\n @property({ type: Array }) pageSizes: number[] = [5, 10, 25, 100];\n\n private changePage(offset: number) {\n this.page += offset;\n this.updatePagination();\n }\n\n updatePagination(page = this.page, pageSize = this.pageSize) {\n this.dispatchEvent(\n new CustomEvent('updatePagination', {\n detail: {\n page,\n pageSize,\n },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n render() {\n const back = this.page > 1;\n const next = this.recordCount > this.page * this.pageSize;\n return html` <div class=\"pagination\">\n <p class=\"rows-per-page\">${copy.rowsPerPage}:</p>\n <ix-select\n wide-menu\n menu-positioning=\"fixed\"\n class=\"pagination__select-input\"\n @request-selection=${(e: Event) => {\n const el = e.target as HTMLInputElement;\n this.pageSize = Number(el.value);\n this.updatePagination();\n }}\n selected-index=${this.pageSizes.indexOf(this.pageSize)}\n filled\n >\n ${this.pageSizes.map(\n option => html`\n <ix-select-option\n class=\"select-option\"\n value=${option}\n ?selected=${option === this.pageSize}\n >\n <div slot=\"headline\">${option}</div>\n </ix-select-option>\n `\n )}\n </ix-select>\n <p>\n ${this.recordCount > 0 ? (this.page - 1) * this.pageSize + 1 : 0} -\n ${this.page * this.pageSize > this.recordCount\n ? html`${this.recordCount}`\n : html`${this.page * this.pageSize}`}\n of ${this.recordCount > 0 ? this.recordCount : 0}\n </p>\n <div class=\"pagination-nav\">\n <ix-icon-button\n ?disabled=${!back}\n @click=${() => back && this.changePage(-1)}\n icon=\"chevron_left\"\n data-testid=\"ix-pagination-prev\"\n >\n </ix-icon-button>\n <ix-icon-button\n ?disabled=${!next}\n @click=${() => next && this.changePage(+1)}\n icon=\"chevron_right\"\n data-testid=\"ix-pagination-next\"\n >\n </ix-icon-button>\n </div>\n </div>`;\n }\n}\n"]}
|
package/dist/ix-grid.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import"@digital-realty/ix-icon-button/ix-icon-button.js";import"@digital-realty/ix-icon/ix-icon.js";import"@digital-realty/ix-progress/ix-progress.js";import"@vaadin/grid";import{columnHeaderRenderer}from"@vaadin/grid/lit.js";import{css,svg,LitElement,html,nothing,render}from"lit";import{query,property,state,customElement}from"lit/decorators.js";import{classMap}from"lit/directives/class-map.js";import{ifDefined}from"lit/directives/if-defined.js";import{repeat}from"lit/directives/repeat.js";import"@digital-realty/ix-switch/ix-switch.js";import"@digital-realty/ix-menu/ix-menu.js";import"@digital-realty/ix-menu/ix-menu-item.js";import"@digital-realty/ix-button/ix-button.js";import"@digital-realty/ix-date/ix-date.js";import"@digital-realty/ix-select/ix-select.js";import{formatDate}from"date-fns/format.js";let IxGridViewStyles=css`:host{--_ix-grid-cell-padding:var(--ix-grid-cell-padding, 1rem);--lumo-primary-color-50pct:transparent}*{font-family:inherit}vaadin-grid::part(cell){cursor:var(--ix-grid-cell-pointer,pointer)}vaadin-grid::part(header-cell){cursor:default;--vaadin-grid-cell-background:#fff}vaadin-grid::part(row):hover{--vaadin-grid-cell-background:#f5f5f5}vaadin-grid-cell-content{font-size:14px;--_cell-padding:var(--ix-grid-cell-padding, 14px 10px)}.hide-column-headers::part(header-cell){display:none}vaadin-grid::part(ix-disabled-cell){cursor:default;color:var(--cp-neutral-blue-60p);--vaadin-grid-cell-background:var(--cp-neutral-blue-12p)}ix-grid-download-menu{width:38px;margin-right:2px}ix-grid-column-filter{width:36px}.grid-container{background-color:var(--clr-surface-container-lowest,#fff);border-radius:8px;box-shadow:rgba(0,0,0,.12) 0 12px 20px -12px,#e1e4e8 0 0 0 1px inset;box-sizing:border-box;padding:2px}.touch-edge{margin:0 -3px}.grid-header{display:flex;-webkit-box-pack:justify;place-content:space-between;-webkit-box-align:center;align-items:center;padding:16px 24px;flex-wrap:wrap;gap:18px;margin:-3px 0 0 -3px}.grid-menu{display:flex;align-items:center;margin-left:auto}.grid-menu ix-button{--md-text-button-leading-space:4px;--md-text-button-trailing-space:4px}.grid-menu span{color:var(--clr-primary,#1456e0);cursor:pointer}.header{font-weight:700;display:flex;user-select:none;align-items:center;padding-right:calc(var(--_ix-grid-cell-padding)/ 2);position:relative;text-overflow:ellipsis;overflow:hidden;flex-grow:1;z-index:2}.header:hover .header-sort-icon{display:block}.columns-reordering{opacity:.25}.progress-container{position:relative;top:60px;z-index:1}span .disabled{color:var(--clr-on-surface-variant,rgba(9,34,65,.7))}.disable-cursor{cursor:default!important}.accounts{display:flex;align-items:center}.account-name{margin:0 8px 0 3px}vaadin-grid-cell-content{font-family:var(--text-small-font,sans-serif);font-size:var(--text-small-size,.875rem);letter-spacing:var(--text-small-letter-spacing,.0275em);line-height:var(--text-small-line-height,1.42857143em);font-weight:var(--text-small-weight,normal);text-decoration:var(--text-small-decoration,none);text-transform:var(--text-small-transform,none);--_cell-padding:var(--ix-grid-cell-padding, 14px 10px)}.row-controls{border-top:solid 1px var(--clr-border-outline,#0922411f)}.row-limit{display:flex;padding:8px}.launchpad vaadin-grid{--_lumo-grid-border-width:0;--lumo-size-xl:auto}.launchpad vaadin-grid-cell-content{padding:11px 24px;border-bottom:0}.launchpad vaadin-grid::part(body-row){border-bottom:1px solid var(--clr-border-outline,rgba(9,34,65,.12))}.launchpad .grid-header{padding:.5rem 18px 0}.launchpad .header{font-family:var(--text-caption-font,sans-serif);font-size:var(--text-caption-size,.75rem);letter-spacing:var(--text-caption-letter-spacing,.03333333em);line-height:var(--text-caption-line-height,1.33333333em);font-weight:var(--text-caption-weight,normal);text-transform:var(--text-caption-transform,none);text-decoration:var(--text-caption-decoration,none)}.launchpad .grid-header h2{font-family:var(--text-page-title-font,sans-serif);font-size:var(--text-page-title-size,2.125rem);letter-spacing:var(--text-page-title-letter-spacing,.01029412em);line-height:var(--text-page-title-line-height,1.17647059em);font-weight:var(--text-page-title-weight,bold);text-decoration:var(--text-page-title-decoration,none);text-transform:var(--text-page-title-transform,none)}`,IxGridColumnFilterStyles=css`.dropdown-content{position:absolute;background-color:var(--clr-surface-container-lowest,#fff);min-width:160px;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);z-index:1;-webkit-box-align:center;align-items:center;cursor:pointer;vertical-align:middle;-webkit-tap-highlight-color:transparent;padding:10px;width:247px;left:-100px;border-radius:16px}.dropdown-content>div{margin:0;color:var(--clr-on-surface,#092241);font-family:var(--text-small-font,sans-serif);font-size:var(--text-small-size,.875rem);letter-spacing:var(--text-small-letter-spacing,.0275em);line-height:var(--text-small-line-height,1.42857143em);font-weight:var(--text-small-weight,normal);text-decoration:var(--text-small-decoration,none);text-transform:var(--text-small-transform,none);display:block;cursor:pointer}.dropdown-content span:hover{background-color:#f1f1f1}.dropdown-content label{display:flex;align-items:center}.dropdown-content label.dragOrigin{background:#ff000017;outline:1px #ff9d9d dashed}.dropdown-content label p{width:158px}.dropdown-content label .draggable{font-size:24px;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}.dropdown-content label .draggable path{fill:var(--clr-primary,#1456e0)}.active{position:absolute;right:0;top:0;height:8px;width:8px;background-color:var(--clr-critical,#db0028);border-radius:50%}ix-switch{padding:0 0 0 6px;display:flex;width:48px}.list{position:relative}`,triggerKeys=[" ","Enter"],handleIcon=svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4C7.9 4 7 4.9 7 6C7 7.1 7.9 8 9 8C10.1 8 11 7.1 11 6C11 4.9 10.1 4 9 4ZM7 12C7 10.9 7.9 10 9 10C10.1 10 11 10.9 11 12C11 13.1 10.1 14 9 14C7.9 14 7 13.1 7 12ZM9 20C10.1 20 11 19.1 11 18C11 16.9 10.1 16 9 16C7.9 16 7 16.9 7 18C7 19.1 7.9 20 9 20ZM17 6C17 7.1 16.1 8 15 8C13.9 8 13 7.1 13 6C13 4.9 13.9 4 15 4C16.1 4 17 4.9 17 6ZM15 10C13.9 10 13 10.9 13 12C13 13.1 13.9 14 15 14C16.1 14 17 13.1 17 12C17 10.9 16.1 10 15 10ZM13 18C13 16.9 13.9 16 15 16C16.1 16 17 16.9 17 18C17 19.1 16.1 20 15 20C13.9 20 13 19.1 13 18Z" fill="#1456e0"/></svg>`,IxGridColumnFilter=class extends LitElement{constructor(){super(...arguments),this.columns=[],this.columnsLocalStorageKey=void 0,this.columnReorderingAllowed=!1,this.refreshDataOnColumnVisibilityChange=!0,this.isDropdownVisible=!1,this.disabledColumns=[],this.dragEvent={sourceEl:null,startId:-1,targetId:-1},this.outerInteraction=e=>{e.composedPath().includes(this)||(this.isDropdownVisible=!1)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.outerInteraction),this.initializeLocalStorage()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.outerInteraction)}get preservedColumns(){let e=[];return e=this.columnsLocalStorageKey?JSON.parse(localStorage.getItem(this.columnsLocalStorageKey)||"[]"):e}initializeLocalStorage(){0<this.preservedColumns.length&&(this.disabledColumns=this.preservedColumns.filter(t=>t.hidden&&this.columns.some(e=>e.name===t.name)).map(e=>e.name),this.columns.forEach((e,t)=>{this.disabledColumns.includes(e.name)&&(this.columns[t].hidden=!0)})),this.dispatchUpdate()}update(e){super.update(e),e.has("columnsLocalStorageKey")&&this.initializeLocalStorage()}toggleColumn(e){this.columns[e].hidden=!this.columns[e].hidden,this.disabledColumns=this.columns.filter(e=>e.hidden).map(e=>e.name),this.columnsLocalStorageKey&&localStorage.setItem(this.columnsLocalStorageKey,JSON.stringify([...this.columns])),this.dispatchUpdate()}updateColumn(e,t){e=null==(e=e.target.shadowRoot)?void 0:e.querySelector("input");this.columns[t].hidden!==!(null!=e&&e.checked)&&this.dispatchEvent(new CustomEvent("columnVisibilityChange",{detail:{column:this.columns[t]},bubbles:!0,composed:!0})),this.columns[t].hidden=!(null!=e&&e.checked),this.disabledColumns=this.columns.filter(e=>e.hidden).map(e=>e.name),this.columnsLocalStorageKey&&localStorage.setItem(this.columnsLocalStorageKey,JSON.stringify([...this.columns])),this.refreshDataOnColumnVisibilityChange?this.dispatchUpdate():this.requestGridUpdate()}dispatchUpdate(e=this.columns){this.dispatchEvent(new CustomEvent("columnFilter",{detail:{columns:e},bubbles:!0,composed:!0}))}dragstart(e){this.columnReorderingAllowed&&(e=e.target,(this.dragEvent.sourceEl=e).style.opacity="0.3",e=Number(e.getAttribute("data-id")),this.dragEvent.startId=e)}dragend(){var e,t;this.columnReorderingAllowed&&(this.dragEvent.startId!==this.dragEvent.targetId&&(t=(e=[...this.columns]).splice(this.dragEvent.startId,1)[0],e.splice(this.dragEvent.targetId,0,t),this.dispatchEvent(new CustomEvent("reorderColumns",{detail:{reorderedColumns:e},bubbles:!0,composed:!0}))),null!=(t=this.dragEvent.sourceEl)&&t.style.removeProperty("opacity"),this.dragEvent={sourceEl:null,startId:-1,targetId:-1})}dragenter(e){this.columnReorderingAllowed&&(e=e.target).classList.contains("drag-target")&&(e=Number(e.getAttribute("data-id")),this.dragEvent.targetId=e)}handleDropdownToggle(e){e instanceof KeyboardEvent&&!triggerKeys.includes(e.key)||e.composedPath().includes(this.dropdown)||(this.isDropdownVisible=!this.isDropdownVisible)}render(){return html`<div class="grid-menu"><span @click="${this.handleDropdownToggle}" @keyDown="${this.handleDropdownToggle}" class="list list-dropdown"><ix-icon-button appearance="default"><svg slot="default" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M3 9H7V5H3V9ZM7 14H3V10H7V14ZM7 19H3V15H7V19ZM20 14H8V10H20V14ZM8 19H20V15H8V19ZM8 9V5H20V9H8Z" fill="#1456E0"/></svg></ix-icon-button>${0<this.disabledColumns.length?html`<div class="active"></div>`:nothing} ${this.isDropdownVisible?html`<div class="dropdown-content" @dragover="${e=>e.preventDefault()}" @dragstart="${this.dragstart}" @dragend="${this.dragend}" @dragenter="${this.dragenter}">${repeat(this.columns.filter(e=>!1!==e.filterable),e=>e.name,(e,t)=>html`<div><label class="${"ix-switch-label drag-target "+(this.dragEvent.startId===t?"dragOrigin":"")}" draggable="true" data-id="${t}"><ix-switch .selected="${!e.hidden}" @change="${e=>this.updateColumn(e,t)}"></ix-switch><p>${e.header}</p><div class="draggable">${handleIcon}</div></label></div>`)}</div>`:nothing}</span></div>`}},IxGridDownloadMenu=(IxGridColumnFilter.styles=[IxGridViewStyles,IxGridColumnFilterStyles],__decorate([query(".dropdown-content")],IxGridColumnFilter.prototype,"dropdown",void 0),__decorate([property({type:Array})],IxGridColumnFilter.prototype,"columns",void 0),__decorate([property({type:String})],IxGridColumnFilter.prototype,"columnsLocalStorageKey",void 0),__decorate([property({type:Boolean})],IxGridColumnFilter.prototype,"columnReorderingAllowed",void 0),__decorate([property({type:Boolean})],IxGridColumnFilter.prototype,"refreshDataOnColumnVisibilityChange",void 0),__decorate([property({attribute:!1})],IxGridColumnFilter.prototype,"requestGridUpdate",void 0),__decorate([state()],IxGridColumnFilter.prototype,"isDropdownVisible",void 0),__decorate([state()],IxGridColumnFilter.prototype,"disabledColumns",void 0),__decorate([state()],IxGridColumnFilter.prototype,"dragEvent",void 0),IxGridColumnFilter=__decorate([customElement("ix-grid-column-filter")],IxGridColumnFilter),class extends LitElement{constructor(){super(...arguments),this.items=[],this.isDownloading=!1}toggleMenu(){this.downloadMenu.open=!this.downloadMenu.open}renderMenuItems(){var e;return 0===(null==(e=this.items)?void 0:e.length)?html`<ix-menu-item @click="${()=>this.dispatchEvent(new CustomEvent("download",{detail:"all",bubbles:!0,composed:!0}))}"><div slot="headline">Download All Records</div></ix-menu-item><ix-menu-item @click="${()=>this.dispatchEvent(new CustomEvent("download",{detail:"filter",bubbles:!0,composed:!0}))}"><div slot="headline">Download Current Filter</div></ix-menu-item>`:this.items.filter(e=>!e.hidden).map(e=>html`<ix-menu-item .disabled="${e.disabled}" @click="${()=>e.onClick(e.name)}"><div slot="headline">${e.label}</div></ix-menu-item>`)}render(){return this.isDownloading?html`<ix-progress .indeterminate="${!0}" .linear="${!1}" style="--md-circular-progress-size:1.75REM;text-align:center"></ix-progress>`:html`<div style="position:relative"><ix-icon-button id="anchor" @click="${this.toggleMenu}"><svg slot="default" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M15 9H19L12 16L5 9H9V3H15V9ZM5 20V18H19V20H5Z" fill="#1456E0"/></svg></ix-icon-button><ix-menu id="menu" anchor="anchor" has-overflow>${this.renderMenuItems()}</ix-menu></div>`}}),copy=(IxGridDownloadMenu.styles=[IxGridViewStyles],__decorate([query("#menu")],IxGridDownloadMenu.prototype,"downloadMenu",void 0),__decorate([query("#anchor")],IxGridDownloadMenu.prototype,"downloadMenuAnchor",void 0),__decorate([property({type:Array})],IxGridDownloadMenu.prototype,"items",void 0),__decorate([property({type:Boolean})],IxGridDownloadMenu.prototype,"isDownloading",void 0),IxGridDownloadMenu=__decorate([customElement("ix-grid-download-menu")],IxGridDownloadMenu),{activeFilter:"active filter",filters:"Filters",hideFilters:"Hide Filters",showFilters:"Show Filters",rowsPerPage:"Rows per page",user:"user",viewMore:"VIEW MORE",viewLess:"VIEW LESS"}),IxGridRowFilterStyles=css`.slot-wrap{display:flex}.slot-wrap ix-icon{--ix-icon-font-size:24px;color:var(--clr-primary,#1456e0);margin-right:5px}.grid-menu ix-button .filter{margin-top:2px}.filter-form{white-space:nowrap;padding:9px;color:var(--clr-on-surface-variant,#092241b3)}.filter-form-column{display:inline-block;vertical-align:middle}.filter-remove span{margin-right:0;color:var(--clr-on-surface-variant,#092241b3)}.filter-dropdown-content{position:absolute;display:inline;right:0;top:78%;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);z-index:3;transition:box-shadow .3s cubic-bezier(.4,0,.2,1) 0s;border-radius:12px;box-shadow:rgba(0,0,0,.2) 0 5px 5px -3px,rgba(0,0,0,.14) 0 8px 10px 1px,rgba(0,0,0,.12) 0 3px 14px 2px;background-color:#fff;z-index:10}.filter-form input,.filter-form option,.filter-form select{font-family:var(--text-default-font,sans-serif);font-size:var(--text-default-size,16px);letter-spacing:var(--text-default-letter-spacing,.0275em);line-height:var(--text-default-line-height,1.75em);font-weight:var(--text-default-weight,normal);text-transform:var(--text-default-decoration,none);text-decoration:var(--text-default-transform,none);border-radius:0;cursor:pointer;box-sizing:content-box;background:0 0;height:1.4375em;margin:0;animation-name:mui-auto-fill-cancel;animation-duration:10ms;border:none;border-image:initial;box-sizing:border-box;cursor:text;user-select:none;color:currentcolor;-webkit-tap-highlight-color:transparent;display:block;min-width:0;width:100%;height:25px;border-bottom:1px solid #000}.filter-form option{-webkit-tap-highlight-color:#9ca6b2}.filter-form input:hover,.filter-form select:hover{outline:0!important;border-bottom:2px solid #000}.filter-form input:focus,.filter-form select:focus{outline:0!important;border-bottom:2px solid #1456e0}.filter-form select:focus{background-color:rgba(0,0,0,.05)}.form-group{display:flex;flex-direction:column;align-items:baseline;height:54px;justify-content:flex-end;font-family:var(--text-default-font,sans-serif)}.form-group label{font-family:var(--text-default-font,sans-serif);font-size:var(--text-default-size,16px);letter-spacing:var(--text-default-letter-spacing,.0275em);line-height:var(--text-default-line-height,1.75em);font-weight:var(--text-default-weight,normal);text-transform:var(--text-default-decoration,none);text-decoration:var(--text-default-transform,none);padding:0;color:#092241;display:block;transform-origin:left top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:133%;transform:translate(0,-1.5px) scale(.75);transition:color .2s cubic-bezier(0,0,.2,1) 0s,transform .2s cubic-bezier(0,0,.2,1) 0s,max-width .2s cubic-bezier(0,0,.2,1) 0s}.filter-form-group label span{font-family:var(--text-default-font,sans-serif);font-size:var(--text-default-size,16px);letter-spacing:var(--text-default-letter-spacing,.0275em);line-height:var(--text-default-line-height,1.75em);font-weight:var(--text-default-weight,normal);text-transform:var(--text-default-decoration,none);text-decoration:var(--text-default-transform,none);padding:0;color:#092241;display:block;transform-origin:left top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:133%;transform:translate(0,-1.5px) scale(.75);transition:color .2s cubic-bezier(0,0,.2,1) 0s,transform .2s cubic-bezier(0,0,.2,1) 0s,max-width .2s cubic-bezier(0,0,.2,1) 0s}.filter-form-group label:focus-within span{color:#1456e0}.filter-form-group{display:flex;flex-direction:column;align-items:baseline;height:54px;justify-content:flex-end;font-family:var(--text-default-font,sans-serif)}option{font-weight:400;display:block;min-height:1.2em;padding:0 2px 1px;white-space:nowrap}.filter-footer{padding:9px;display:flex;justify-content:space-between}.no-display{display:none}.filter-local-operator-empty{width:54px;border:none}.grid-menu span.filter-superscript{position:absolute;top:6px;left:14px;z-index:1;display:flex;align-items:center;justify-content:center;font-family:var(--text-caption-font,sans-serif);font-size:var(--text-caption-size,.75rem);letter-spacing:var(--text-caption-letter-spacing,.03333333em);line-height:var(--text-caption-line-height,1.33333333em);font-weight:var(--text-caption-weight,normal);text-transform:var(--text-caption-transform,none);text-decoration:var(--text-caption-decoration,none);padding:0;height:16px;width:16px;border-radius:50%;background-color:var(--clr-primary,#1456e0);color:var(--clr-on-primary,#fff)}.filterlist{width:40px}.filterColumnField{width:150px}.filterValueField{width:190px}.filterOperatorField{width:120px}.form-group-operator-label{width:100%}.filter-form .filterOperatorInput{min-width:96px}select:hover{cursor:pointer}input:hover{cursor:text}.tooltip-container{position:relative;display:inline-block}.tool-tip{color:var(--clr-on-secondary,#fff);overflow-wrap:break-word;border-radius:3px;background-color:var(--clr-secondary,#071454);padding:5px 8px;font-family:var(--text-caption-font,sans-serif);font-size:var(--text-caption-size,.75rem);letter-spacing:var(--text-caption-letter-spacing,.03333333em);line-height:var(--text-caption-line-height,1.33333333em);font-weight:var(--text-caption-weight,normal);text-transform:var(--text-caption-transform,none);text-decoration:var(--text-caption-decoration,none);position:absolute;top:42px;right:0;z-index:3;white-space:nowrap;display:none}.filter-button:hover~.tool-tip{display:block}.tool-tip li{margin-left:-21px;overflow-wrap:break-word;border-radius:3px;max-width:250px;min-width:200px;white-space:wrap}.tool-tip p{margin:0;padding:0}.grid-menu ix-button{align-items:center;display:flex}`,IxGridRowFilter=class extends LitElement{constructor(){super(...arguments),this.columns=[],this.filterValueChangeDebounceTime=300,this.readParamsFromURL=!1,this.isDropdownVisible=!1,this.filters=[],this.filterableColumns=[],this.filterColumns=[],this.activeFilters=[],this.mapSelect=!1,this.maxDate=formatDate(new Date,"yyyy-MM-dd"),this.fromDateErrorText="",this.debouncedOnFilterValueChange=()=>{},this.closeOnOuterClick=e=>{e.composedPath().includes(this)||(this.isDropdownVisible=!1)}}updateActiveFilters(){this.activeFilters=this.filters.filter(e=>0<e.value.length)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.closeOnOuterClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.closeOnOuterClick)}firstUpdated(){this.filterableColumns=this.columns.filter(e=>e.filterable),this.filterColumns=this.filterableColumns.map(e=>e.name),this.readParamsFromURL&&(this.filters=this.parseFilterQueryString()),this.filters.length||this.addFilter(),this.updateActiveFilters(),this.dispatchUpdate(!1),this.debouncedOnFilterValueChange=(e,t)=>{clearTimeout(this.debounceEvent),this.debounceEvent=setTimeout(()=>this.onfilterValueChange.bind(this)(e,t),this.filterValueChangeDebounceTime)}}get filterNames(){return this.filters.map(e=>e.columnField)}get unselectedFilters(){return this.filterColumns.filter(e=>!this.filterNames.includes(e))}parseFilterQueryString(){let r=new URLSearchParams(window.location.search),o=[];return this.filterableColumns.forEach(i=>{var e;null!=(e=i.filterOperators)&&e.forEach(e=>{var t=i.name+"_"+e;r.has(t)&&o.push({columnField:i.name,operatorValue:e,dataType:i.dataType,value:null!=(e=r.get(t))?e:""})})}),o}dispatchUpdate(e=!0){this.dispatchEvent(new CustomEvent("rowFilter",{detail:{filters:this.filters.filter(e=>3<=e.value.length),resetPage:e},bubbles:!0,composed:!0}))}addFilter(){let e,t,i=this.filterColumns.find(e=>!this.filterNames.includes(e))||"";var r=(null==(e=this.filterableColumns.find(e=>e.name===i))?void 0:e.filterOperators)||["contains"],o=(null==(t=this.filterableColumns.find(e=>e.name===i))?void 0:t.dataType)||"string";this.filters=[...this.filters,{columnField:i,operatorValue:r[0],dataType:o,value:""}],this.updateActiveFilters()}clearFilters(){this.filters=[],this.addFilter(),this.dispatchUpdate()}removeFilter(i){this.filters=this.filters.filter((e,t)=>t!==i),this.dispatchUpdate(),0===this.filters.length&&(this.isDropdownVisible=!1,this.addFilter())}onfilterColumnChange(e,t){let i,r=t.target.value;t=this.filterableColumns.find(e=>e.name===r);this.filters[e].columnField=r,this.filters[e].dataType=null==t?void 0:t.dataType,this.filters[e].operatorValue=(null==(i=null==t?void 0:t.filterOperators)?void 0:i[0])||"contains",this.filters=[...this.filters],3<=this.filters[e].value.length&&this.dispatchUpdate()}onfilterOperatorChange(e,t){t=t.target.value;this.filters[e].operatorValue=t,this.filters=[...this.filters],3<=this.filters[e].value.length&&this.dispatchUpdate()}onDatefilterValueChange(e,t){this.filters[e].value=t,this.dispatchUpdate(),this.updateActiveFilters()}onfilterValueChange(e,t){var i=this.filters[e].value.length,t=t.value,t=(this.filters[e].value=t,this.filters[e].value.length);0<this.filters[e].columnField.length&&(3<=t||t<i)&&this.dispatchUpdate(),this.updateActiveFilters()}formatCamelCaseToEnglish(e){e=e.replace(/([A-Z])/g," $1").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}renderToolTip(){return this.isDropdownVisible?copy.hideFilters:this.activeFilters.length?html`<p>${this.activeFilters.length} ${copy.activeFilter}</p><ul>${this.activeFilters.map(e=>html`<li>${this.formatCamelCaseToEnglish(e.columnField)} ${e.operatorValue} ${e.value}</li>`)}</ul>`:copy.showFilters}renderStringInput(e,t){return html`<label class="form-group-operator-label"><span>Value</span> <input data-testid="${"filterValueInput-"+t}" placeholder="Filter value" @input="${e=>this.debouncedOnFilterValueChange(t,e.target)}" .value="${e.value}"></label>`}renderDateInput(e,t){return html`<ix-date data-testid="${"filterValueInput-"+t}" .value="${e.value}" max="${this.maxDate}" name="${e.columnField}-valueDate" .errorText="${this.fromDateErrorText}" .onChanged="${e=>this.onDatefilterValueChange(t,e)}"></ix-date>`}renderFilterInputControl(e,t){switch(e.dataType){case"string":case void 0:return this.renderStringInput(e,t);case"dateTime":return this.renderDateInput(e,t);default:return nothing}}renderFilterInput(t,i){let e,r,o=[t.columnField,...this.unselectedFilters];var a=this.filterableColumns.filter(e=>o.includes(e.name));return html`<div class="filter-form"><div class="filter-remove filter-form-column"><div class="form-group"><ix-icon-button icon="close" data-testid="clearFilterButton" @click="${()=>this.removeFilter(i)}" @keyDown="${e=>{" "!==e.key&&"Enter"!==e.key||this.removeFilter(i)}}"></ix-icon-button></div></div>${this.mapSelect?html`<div class="filter-form-column filter-form-column-border filterColumnField"><div class="form-group"><label class="form-group-column-label" title="select: ${t.columnField}, options: ${a.map(e=>`value=${e.name}, selected=${e.name===t.columnField}, ${e.header}
|
|
1
|
+
import{__decorate}from"tslib";import"@digital-realty/ix-icon-button/ix-icon-button.js";import"@digital-realty/ix-icon/ix-icon.js";import"@digital-realty/ix-progress/ix-progress.js";import"@vaadin/grid";import{columnHeaderRenderer}from"@vaadin/grid/lit.js";import{css,svg,LitElement,nothing,html,render}from"lit";import{query,property,state,customElement}from"lit/decorators.js";import{classMap}from"lit/directives/class-map.js";import{ifDefined}from"lit/directives/if-defined.js";import{repeat}from"lit/directives/repeat.js";import"@digital-realty/ix-switch/ix-switch.js";import"@digital-realty/ix-menu/ix-menu.js";import"@digital-realty/ix-menu/ix-menu-item.js";import"@digital-realty/ix-button/ix-button.js";import"@digital-realty/ix-date/ix-date.js";import"@digital-realty/ix-select/ix-select.js";import{formatDate}from"date-fns/format.js";let IxGridViewStyles=css`:host{--_ix-grid-cell-padding:var(--ix-grid-cell-padding, 1rem);--lumo-primary-color-50pct:transparent}*{font-family:inherit}vaadin-grid::part(cell){cursor:var(--ix-grid-cell-pointer,pointer)}vaadin-grid::part(header-cell){cursor:default;--vaadin-grid-cell-background:#fff}vaadin-grid::part(row):hover{--vaadin-grid-cell-background:#f5f5f5}vaadin-grid-cell-content{font-size:14px;--_cell-padding:var(--ix-grid-cell-padding, 14px 10px)}.hide-column-headers::part(header-cell){display:none}vaadin-grid::part(ix-disabled-cell){cursor:default;color:var(--cp-neutral-blue-60p);--vaadin-grid-cell-background:var(--cp-neutral-blue-12p)}ix-grid-download-menu{width:38px;margin-right:2px}ix-grid-column-filter{width:36px}.grid-container{background-color:var(--clr-surface-container-lowest,#fff);border-radius:8px;box-shadow:rgba(0,0,0,.12) 0 12px 20px -12px,#e1e4e8 0 0 0 1px inset;box-sizing:border-box;padding:2px}.touch-edge{margin:0 -3px}.grid-header{display:flex;-webkit-box-pack:justify;place-content:space-between;-webkit-box-align:center;align-items:center;padding:16px 24px;flex-wrap:wrap;gap:18px;margin:-3px 0 0 -3px}.grid-menu{display:flex;align-items:center;margin-left:auto}.grid-menu ix-button{--md-text-button-leading-space:4px;--md-text-button-trailing-space:4px}.grid-menu span{color:var(--clr-primary,#1456e0);cursor:pointer}.header{font-weight:700;display:flex;user-select:none;align-items:center;padding-right:calc(var(--_ix-grid-cell-padding)/ 2);position:relative;text-overflow:ellipsis;overflow:hidden;flex-grow:1;z-index:2}.header:hover .header-sort-icon{display:block}.columns-reordering{opacity:.25}.progress-container{position:relative;top:60px;z-index:1}span .disabled{color:var(--clr-on-surface-variant,rgba(9,34,65,.7))}.disable-cursor{cursor:default!important}.accounts{display:flex;align-items:center}.account-name{margin:0 8px 0 3px}vaadin-grid-cell-content{font-family:var(--text-small-font,sans-serif);font-size:var(--text-small-size,.875rem);letter-spacing:var(--text-small-letter-spacing,.0275em);line-height:var(--text-small-line-height,1.42857143em);font-weight:var(--text-small-weight,normal);text-decoration:var(--text-small-decoration,none);text-transform:var(--text-small-transform,none);--_cell-padding:var(--ix-grid-cell-padding, 14px 10px)}.row-controls{border-top:solid 1px var(--clr-border-outline,#0922411f)}.row-limit{display:flex;padding:8px}.launchpad vaadin-grid{--_lumo-grid-border-width:0;--lumo-size-xl:auto}.launchpad vaadin-grid-cell-content{padding:11px 24px;border-bottom:0}.launchpad vaadin-grid::part(body-row){border-bottom:1px solid var(--clr-border-outline,rgba(9,34,65,.12))}.launchpad .grid-header{padding:.5rem 18px 0}.launchpad .header{font-family:var(--text-caption-font,sans-serif);font-size:var(--text-caption-size,.75rem);letter-spacing:var(--text-caption-letter-spacing,.03333333em);line-height:var(--text-caption-line-height,1.33333333em);font-weight:var(--text-caption-weight,normal);text-transform:var(--text-caption-transform,none);text-decoration:var(--text-caption-decoration,none)}.launchpad .grid-header h2{font-family:var(--text-page-title-font,sans-serif);font-size:var(--text-page-title-size,2.125rem);letter-spacing:var(--text-page-title-letter-spacing,.01029412em);line-height:var(--text-page-title-line-height,1.17647059em);font-weight:var(--text-page-title-weight,bold);text-decoration:var(--text-page-title-decoration,none);text-transform:var(--text-page-title-transform,none)}`,IxGridColumnFilterStyles=css`.dropdown-content{position:absolute;background-color:var(--clr-surface-container-lowest,#fff);min-width:160px;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);z-index:1;-webkit-box-align:center;align-items:center;cursor:pointer;vertical-align:middle;-webkit-tap-highlight-color:transparent;padding:10px;width:247px;left:-100px;border-radius:16px}.dropdown-content>div{margin:0;color:var(--clr-on-surface,#092241);font-family:var(--text-small-font,sans-serif);font-size:var(--text-small-size,.875rem);letter-spacing:var(--text-small-letter-spacing,.0275em);line-height:var(--text-small-line-height,1.42857143em);font-weight:var(--text-small-weight,normal);text-decoration:var(--text-small-decoration,none);text-transform:var(--text-small-transform,none);display:block;cursor:pointer}.dropdown-content span:hover{background-color:#f1f1f1}.dropdown-content label{display:flex;align-items:center}.dropdown-content label.dragOrigin{background:#ff000017;outline:1px #ff9d9d dashed}.dropdown-content label p{width:158px}.dropdown-content label .draggable{font-size:24px;cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab}.dropdown-content label .draggable path{fill:var(--clr-primary,#1456e0)}.active{position:absolute;right:0;top:0;height:8px;width:8px;background-color:var(--clr-critical,#db0028);border-radius:50%}ix-switch{padding:0 0 0 6px;display:flex;width:48px}.list{position:relative}`,triggerKeys=[" ","Enter"],handleIcon=svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4C7.9 4 7 4.9 7 6C7 7.1 7.9 8 9 8C10.1 8 11 7.1 11 6C11 4.9 10.1 4 9 4ZM7 12C7 10.9 7.9 10 9 10C10.1 10 11 10.9 11 12C11 13.1 10.1 14 9 14C7.9 14 7 13.1 7 12ZM9 20C10.1 20 11 19.1 11 18C11 16.9 10.1 16 9 16C7.9 16 7 16.9 7 18C7 19.1 7.9 20 9 20ZM17 6C17 7.1 16.1 8 15 8C13.9 8 13 7.1 13 6C13 4.9 13.9 4 15 4C16.1 4 17 4.9 17 6ZM15 10C13.9 10 13 10.9 13 12C13 13.1 13.9 14 15 14C16.1 14 17 13.1 17 12C17 10.9 16.1 10 15 10ZM13 18C13 16.9 13.9 16 15 16C16.1 16 17 16.9 17 18C17 19.1 16.1 20 15 20C13.9 20 13 19.1 13 18Z" fill="#1456e0"/></svg>`,IxGridColumnFilter=class extends LitElement{constructor(){super(...arguments),this.columns=[],this.columnsLocalStorageKey=void 0,this.columnReorderingAllowed=!1,this.refreshDataOnColumnVisibilityChange=!0,this.isDropdownVisible=!1,this.disabledColumns=[],this.dragEvent={sourceEl:null,startId:-1,targetId:-1},this.outerInteraction=e=>{e.composedPath().includes(this)||(this.isDropdownVisible=!1)}}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.outerInteraction),this.initializeLocalStorage()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.outerInteraction)}get preservedColumns(){let e=[];return e=this.columnsLocalStorageKey?JSON.parse(localStorage.getItem(this.columnsLocalStorageKey)||"[]"):e}initializeLocalStorage(){0<this.preservedColumns.length&&(this.disabledColumns=this.preservedColumns.filter(t=>t.hidden&&this.columns.some(e=>e.name===t.name)).map(e=>e.name),this.columns.forEach((e,t)=>{this.disabledColumns.includes(e.name)&&(this.columns[t].hidden=!0)})),this.dispatchUpdate()}update(e){super.update(e),e.has("columnsLocalStorageKey")&&this.initializeLocalStorage()}toggleColumn(e){this.columns[e].hidden=!this.columns[e].hidden,this.disabledColumns=this.columns.filter(e=>e.hidden).map(e=>e.name),this.columnsLocalStorageKey&&localStorage.setItem(this.columnsLocalStorageKey,JSON.stringify([...this.columns])),this.dispatchUpdate()}updateColumn(e,t){e=null==(e=e.target.shadowRoot)?void 0:e.querySelector("input");this.columns[t].hidden!==!(null!=e&&e.checked)&&this.dispatchEvent(new CustomEvent("columnVisibilityChange",{detail:{column:this.columns[t]},bubbles:!0,composed:!0})),this.columns[t].hidden=!(null!=e&&e.checked),this.disabledColumns=this.columns.filter(e=>e.hidden).map(e=>e.name),this.columnsLocalStorageKey&&localStorage.setItem(this.columnsLocalStorageKey,JSON.stringify([...this.columns])),this.refreshDataOnColumnVisibilityChange?this.dispatchUpdate():this.requestGridUpdate()}dispatchUpdate(e=this.columns){this.dispatchEvent(new CustomEvent("columnFilter",{detail:{columns:e},bubbles:!0,composed:!0}))}dragstart(e){this.columnReorderingAllowed&&(e=e.target,(this.dragEvent.sourceEl=e).style.opacity="0.3",e=Number(e.getAttribute("data-id")),this.dragEvent.startId=e)}dragend(){var e,t;this.columnReorderingAllowed&&(this.dragEvent.startId!==this.dragEvent.targetId&&(t=(e=[...this.columns]).splice(this.dragEvent.startId,1)[0],e.splice(this.dragEvent.targetId,0,t),this.dispatchEvent(new CustomEvent("reorderColumns",{detail:{reorderedColumns:e},bubbles:!0,composed:!0}))),null!=(t=this.dragEvent.sourceEl)&&t.style.removeProperty("opacity"),this.dragEvent={sourceEl:null,startId:-1,targetId:-1})}dragenter(e){this.columnReorderingAllowed&&(e=e.target).classList.contains("drag-target")&&(e=Number(e.getAttribute("data-id")),this.dragEvent.targetId=e)}handleDropdownToggle(e){e instanceof KeyboardEvent&&!triggerKeys.includes(e.key)||e.composedPath().includes(this.dropdown)||(this.isDropdownVisible=!this.isDropdownVisible)}render(){return html`<div class="grid-menu"><span @click="${this.handleDropdownToggle}" @keyDown="${this.handleDropdownToggle}" class="list list-dropdown"><ix-icon-button appearance="default"><svg slot="default" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M3 9H7V5H3V9ZM7 14H3V10H7V14ZM7 19H3V15H7V19ZM20 14H8V10H20V14ZM8 19H20V15H8V19ZM8 9V5H20V9H8Z" fill="#1456E0"/></svg></ix-icon-button>${0<this.disabledColumns.length?html`<div class="active"></div>`:nothing} ${this.isDropdownVisible?html`<div class="dropdown-content" @dragover="${e=>e.preventDefault()}" @dragstart="${this.dragstart}" @dragend="${this.dragend}" @dragenter="${this.dragenter}">${repeat(this.columns.filter(e=>!1!==e.filterable),e=>e.name,(e,t)=>html`<div><label class="${"ix-switch-label drag-target "+(this.dragEvent.startId===t?"dragOrigin":"")}" draggable="true" data-id="${t}"><ix-switch .selected="${!e.hidden}" @change="${e=>this.updateColumn(e,t)}"></ix-switch><p>${e.header}</p><div class="draggable">${handleIcon}</div></label></div>`)}</div>`:nothing}</span></div>`}},IxGridDownloadMenu=(IxGridColumnFilter.styles=[IxGridViewStyles,IxGridColumnFilterStyles],__decorate([query(".dropdown-content")],IxGridColumnFilter.prototype,"dropdown",void 0),__decorate([property({type:Array})],IxGridColumnFilter.prototype,"columns",void 0),__decorate([property({type:String})],IxGridColumnFilter.prototype,"columnsLocalStorageKey",void 0),__decorate([property({type:Boolean})],IxGridColumnFilter.prototype,"columnReorderingAllowed",void 0),__decorate([property({type:Boolean})],IxGridColumnFilter.prototype,"refreshDataOnColumnVisibilityChange",void 0),__decorate([property({attribute:!1})],IxGridColumnFilter.prototype,"requestGridUpdate",void 0),__decorate([state()],IxGridColumnFilter.prototype,"isDropdownVisible",void 0),__decorate([state()],IxGridColumnFilter.prototype,"disabledColumns",void 0),__decorate([state()],IxGridColumnFilter.prototype,"dragEvent",void 0),IxGridColumnFilter=__decorate([customElement("ix-grid-column-filter")],IxGridColumnFilter),class extends LitElement{constructor(){super(...arguments),this.items=[],this.isDownloading=!1}toggleMenu(){this.downloadMenu.open=!this.downloadMenu.open}renderMenuItems(){var e;return 0===(null==(e=this.items)?void 0:e.length)?html`<ix-menu-item @click="${()=>this.dispatchEvent(new CustomEvent("download",{detail:"all",bubbles:!0,composed:!0}))}"><div slot="headline">Download All Records</div></ix-menu-item><ix-menu-item @click="${()=>this.dispatchEvent(new CustomEvent("download",{detail:"filter",bubbles:!0,composed:!0}))}"><div slot="headline">Download Current Filter</div></ix-menu-item>`:this.items.filter(e=>!e.hidden).map(e=>html`<ix-menu-item .disabled="${e.disabled}" @click="${()=>e.onClick(e.name)}"><div slot="headline">${e.label}</div></ix-menu-item>`)}render(){return this.isDownloading?html`<ix-progress .indeterminate="${!0}" .linear="${!1}" style="--md-circular-progress-size:1.75REM;text-align:center"></ix-progress>`:html`<div style="position:relative"><ix-icon-button id="anchor" @click="${this.toggleMenu}"><svg slot="default" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M15 9H19L12 16L5 9H9V3H15V9ZM5 20V18H19V20H5Z" fill="#1456E0"/></svg></ix-icon-button><ix-menu id="menu" anchor="anchor" has-overflow>${this.renderMenuItems()}</ix-menu></div>`}}),copy=(IxGridDownloadMenu.styles=[IxGridViewStyles],__decorate([query("#menu")],IxGridDownloadMenu.prototype,"downloadMenu",void 0),__decorate([query("#anchor")],IxGridDownloadMenu.prototype,"downloadMenuAnchor",void 0),__decorate([property({type:Array})],IxGridDownloadMenu.prototype,"items",void 0),__decorate([property({type:Boolean})],IxGridDownloadMenu.prototype,"isDownloading",void 0),IxGridDownloadMenu=__decorate([customElement("ix-grid-download-menu")],IxGridDownloadMenu),{activeFilter:"active filter",filters:"Filters",hideFilters:"Hide Filters",showFilters:"Show Filters",rowsPerPage:"Rows per page",viewMore:"VIEW MORE",viewLess:"VIEW LESS"}),IxGridRowFilterStyles=css`.slot-wrap{display:flex}.slot-wrap ix-icon{--ix-icon-font-size:24px;color:var(--clr-primary,#1456e0);margin-right:5px}.grid-menu ix-button .filter{margin-top:2px}.filter-form{white-space:nowrap;padding:9px;color:var(--clr-on-surface-variant,#092241b3)}.filter-form-column{display:inline-block;vertical-align:middle}.filter-remove span{margin-right:0;color:var(--clr-on-surface-variant,#092241b3)}.filter-dropdown-content{position:absolute;display:inline;right:0;top:78%;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);z-index:3;transition:box-shadow .3s cubic-bezier(.4,0,.2,1) 0s;border-radius:12px;box-shadow:rgba(0,0,0,.2) 0 5px 5px -3px,rgba(0,0,0,.14) 0 8px 10px 1px,rgba(0,0,0,.12) 0 3px 14px 2px;background-color:#fff;z-index:10}.filter-form input,.filter-form option,.filter-form select{font-family:var(--text-default-font,sans-serif);font-size:var(--text-default-size,16px);letter-spacing:var(--text-default-letter-spacing,.0275em);line-height:var(--text-default-line-height,1.75em);font-weight:var(--text-default-weight,normal);text-transform:var(--text-default-decoration,none);text-decoration:var(--text-default-transform,none);border-radius:0;cursor:pointer;box-sizing:content-box;background:0 0;height:1.4375em;margin:0;animation-name:mui-auto-fill-cancel;animation-duration:10ms;border:none;border-image:initial;box-sizing:border-box;cursor:text;user-select:none;color:currentcolor;-webkit-tap-highlight-color:transparent;display:block;min-width:0;width:100%;height:25px;border-bottom:1px solid #000}.filter-form option{-webkit-tap-highlight-color:#9ca6b2}.filter-form input:hover,.filter-form select:hover{outline:0!important;border-bottom:2px solid #000}.filter-form input:focus,.filter-form select:focus{outline:0!important;border-bottom:2px solid #1456e0}.filter-form select:focus{background-color:rgba(0,0,0,.05)}.form-group{display:flex;flex-direction:column;align-items:baseline;height:54px;justify-content:flex-end;font-family:var(--text-default-font,sans-serif)}.form-group label{font-family:var(--text-default-font,sans-serif);font-size:var(--text-default-size,16px);letter-spacing:var(--text-default-letter-spacing,.0275em);line-height:var(--text-default-line-height,1.75em);font-weight:var(--text-default-weight,normal);text-transform:var(--text-default-decoration,none);text-decoration:var(--text-default-transform,none);padding:0;color:#092241;display:block;transform-origin:left top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:133%;transform:translate(0,-1.5px) scale(.75);transition:color .2s cubic-bezier(0,0,.2,1) 0s,transform .2s cubic-bezier(0,0,.2,1) 0s,max-width .2s cubic-bezier(0,0,.2,1) 0s}.filter-form-group label span{font-family:var(--text-default-font,sans-serif);font-size:var(--text-default-size,16px);letter-spacing:var(--text-default-letter-spacing,.0275em);line-height:var(--text-default-line-height,1.75em);font-weight:var(--text-default-weight,normal);text-transform:var(--text-default-decoration,none);text-decoration:var(--text-default-transform,none);padding:0;color:#092241;display:block;transform-origin:left top;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:133%;transform:translate(0,-1.5px) scale(.75);transition:color .2s cubic-bezier(0,0,.2,1) 0s,transform .2s cubic-bezier(0,0,.2,1) 0s,max-width .2s cubic-bezier(0,0,.2,1) 0s}.filter-form-group label:focus-within span{color:#1456e0}.filter-form-group{display:flex;flex-direction:column;align-items:baseline;height:54px;justify-content:flex-end;font-family:var(--text-default-font,sans-serif)}option{font-weight:400;display:block;min-height:1.2em;padding:0 2px 1px;white-space:nowrap}.filter-footer{padding:9px;display:flex;justify-content:space-between}.no-display{display:none}.filter-local-operator-empty{width:54px;border:none}.grid-menu span.filter-superscript{position:absolute;top:6px;left:14px;z-index:1;display:flex;align-items:center;justify-content:center;font-family:var(--text-caption-font,sans-serif);font-size:var(--text-caption-size,.75rem);letter-spacing:var(--text-caption-letter-spacing,.03333333em);line-height:var(--text-caption-line-height,1.33333333em);font-weight:var(--text-caption-weight,normal);text-transform:var(--text-caption-transform,none);text-decoration:var(--text-caption-decoration,none);padding:0;height:16px;width:16px;border-radius:50%;background-color:var(--clr-primary,#1456e0);color:var(--clr-on-primary,#fff)}.filterlist{width:40px}.filterColumnField{width:150px}.filterValueField{width:190px}.filterOperatorField{width:120px}.form-group-operator-label{width:100%}.filter-form .filterOperatorInput{min-width:96px}select:hover{cursor:pointer}input:hover{cursor:text}.tooltip-container{position:relative;display:inline-block}.tool-tip{color:var(--clr-on-secondary,#fff);overflow-wrap:break-word;border-radius:3px;background-color:var(--clr-secondary,#071454);padding:5px 8px;font-family:var(--text-caption-font,sans-serif);font-size:var(--text-caption-size,.75rem);letter-spacing:var(--text-caption-letter-spacing,.03333333em);line-height:var(--text-caption-line-height,1.33333333em);font-weight:var(--text-caption-weight,normal);text-transform:var(--text-caption-transform,none);text-decoration:var(--text-caption-decoration,none);position:absolute;top:42px;right:0;z-index:3;white-space:nowrap;display:none}.filter-button:hover~.tool-tip{display:block}.tool-tip li{margin-left:-21px;overflow-wrap:break-word;border-radius:3px;max-width:250px;min-width:200px;white-space:wrap}.tool-tip p{margin:0;padding:0}.grid-menu ix-button{align-items:center;display:flex}`,IxGridRowFilter=class extends LitElement{constructor(){super(...arguments),this.columns=[],this.filterValueChangeDebounceTime=300,this.readParamsFromURL=!1,this.isDropdownVisible=!1,this.filters=[],this.filterableColumns=[],this.filterColumns=[],this.activeFilters=[],this.mapSelect=!1,this.maxDate=formatDate(new Date,"yyyy-MM-dd"),this.fromDateErrorText="",this.debouncedOnFilterValueChange=()=>{},this.closeOnOuterClick=e=>{e.composedPath().includes(this)||(this.isDropdownVisible=!1)}}updateActiveFilters(){this.activeFilters=this.filters.filter(e=>0<e.value.length)}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.closeOnOuterClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.closeOnOuterClick)}firstUpdated(){this.filterableColumns=this.columns.filter(e=>e.filterable),this.filterColumns=this.filterableColumns.map(e=>e.name),this.readParamsFromURL&&(this.filters=this.parseFilterQueryString()),this.filters.length||this.addFilter(),this.updateActiveFilters(),this.dispatchUpdate(!1),this.debouncedOnFilterValueChange=(e,t)=>{clearTimeout(this.debounceEvent),this.debounceEvent=setTimeout(()=>this.onfilterValueChange.bind(this)(e,t),this.filterValueChangeDebounceTime)}}get filterNames(){return this.filters.map(e=>e.columnField)}get unselectedFilters(){return this.filterColumns.filter(e=>!this.filterNames.includes(e))}parseFilterQueryString(){let r=new URLSearchParams(window.location.search),o=[];return this.filterableColumns.forEach(i=>{var e;null!=(e=i.filterOperators)&&e.forEach(e=>{var t=i.name+"_"+e;r.has(t)&&o.push({columnField:i.name,operatorValue:e,dataType:i.dataType,value:null!=(e=r.get(t))?e:""})})}),o}dispatchUpdate(e=!0){this.dispatchEvent(new CustomEvent("rowFilter",{detail:{filters:this.filters.filter(e=>3<=e.value.length),resetPage:e},bubbles:!0,composed:!0}))}addFilter(){let e,t,i=this.filterColumns.find(e=>!this.filterNames.includes(e))||"";var r=(null==(e=this.filterableColumns.find(e=>e.name===i))?void 0:e.filterOperators)||["contains"],o=(null==(t=this.filterableColumns.find(e=>e.name===i))?void 0:t.dataType)||"string";this.filters=[...this.filters,{columnField:i,operatorValue:r[0],dataType:o,value:""}],this.updateActiveFilters()}clearFilters(){this.filters=[],this.addFilter(),this.dispatchUpdate()}removeFilter(i){this.filters=this.filters.filter((e,t)=>t!==i),this.dispatchUpdate(),0===this.filters.length&&(this.isDropdownVisible=!1,this.addFilter())}onfilterColumnChange(e,t){let i,r=t.target.value;t=this.filterableColumns.find(e=>e.name===r);this.filters[e].columnField=r,this.filters[e].dataType=null==t?void 0:t.dataType,this.filters[e].operatorValue=(null==(i=null==t?void 0:t.filterOperators)?void 0:i[0])||"contains",this.filters=[...this.filters],3<=this.filters[e].value.length&&this.dispatchUpdate()}onfilterOperatorChange(e,t){t=t.target.value;this.filters[e].operatorValue=t,this.filters=[...this.filters],3<=this.filters[e].value.length&&this.dispatchUpdate()}onDatefilterValueChange(e,t){this.filters[e].value=t,this.dispatchUpdate(),this.updateActiveFilters()}onfilterValueChange(e,t){var i=this.filters[e].value.length,t=t.value,t=(this.filters[e].value=t,this.filters[e].value.length);0<this.filters[e].columnField.length&&(3<=t||t<i)&&this.dispatchUpdate(),this.updateActiveFilters()}formatCamelCaseToEnglish(e){e=e.replace(/([A-Z])/g," $1").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}renderToolTip(){return this.isDropdownVisible?copy.hideFilters:this.activeFilters.length?html`<p>${this.activeFilters.length} ${copy.activeFilter}</p><ul>${this.activeFilters.map(e=>html`<li>${this.formatCamelCaseToEnglish(e.columnField)} ${e.operatorValue} ${e.value}</li>`)}</ul>`:copy.showFilters}renderStringInput(e,t){return html`<label class="form-group-operator-label"><span>Value</span> <input data-testid="${"filterValueInput-"+t}" placeholder="Filter value" @input="${e=>this.debouncedOnFilterValueChange(t,e.target)}" .value="${e.value}"></label>`}renderDateInput(e,t){return html`<ix-date data-testid="${"filterValueInput-"+t}" .value="${e.value}" max="${this.maxDate}" name="${e.columnField}-valueDate" .errorText="${this.fromDateErrorText}" .onChanged="${e=>this.onDatefilterValueChange(t,e)}"></ix-date>`}renderFilterInputControl(e,t){switch(e.dataType){case"string":case void 0:return this.renderStringInput(e,t);case"dateTime":return this.renderDateInput(e,t);default:return nothing}}renderFilterInput(t,i){let e,r,o=[t.columnField,...this.unselectedFilters];var a=this.filterableColumns.filter(e=>o.includes(e.name));return html`<div class="filter-form"><div class="filter-remove filter-form-column"><div class="form-group"><ix-icon-button icon="close" data-testid="clearFilterButton" @click="${()=>this.removeFilter(i)}" @keyDown="${e=>{" "!==e.key&&"Enter"!==e.key||this.removeFilter(i)}}"></ix-icon-button></div></div>${this.mapSelect?html`<div class="filter-form-column filter-form-column-border filterColumnField"><div class="form-group"><label class="form-group-column-label" title="select: ${t.columnField}, options: ${a.map(e=>`value=${e.name}, selected=${e.name===t.columnField}, ${e.header}
|
|
2
2
|
`)}">Columns</label> <select @change="${e=>this.onfilterColumnChange(i,e)}" .value="${t.columnField}" data-v="${t.columnField}">${a.map(e=>html`<option value="${e.name}" ?selected="${e.name===t.columnField}">${e.header}</option>`)}</select></div></div>`:nothing}<div class="filter-form-column filter-form-column-border filterColumnField"><div class="filter-form-group"><label class="form-group-column-label" title="select: ${t.columnField}, options: ${a.map(e=>`value=${e.name}, selected=${e.name===t.columnField}, ${e.header}
|
|
3
3
|
`)}"><span>Columns</span> <select data-testid="${"filterColumnInput-"+i}" @change="${e=>this.onfilterColumnChange(i,e)}" .value="${t.columnField}" data-v="${t.columnField}">${repeat(a,e=>e.name,e=>html`<option value="${e.name}" ?selected="${e.name===t.columnField}">${e.header}</option>`)}</select></label></div></div><div class="filter-form-column filter-form-column-border filterOperatorField"><div class="filter-form-group"><label class="form-group-operator-label"><span>Operator</span> <select data-testid="${"filterOperatorInput-"+i}" class="filterOperatorInput" @change="${e=>this.onfilterOperatorChange(i,e)}" .value="${t.operatorValue}" data-v="${t.operatorValue}">${repeat(null!=(r=null==(e=a.find(e=>e.name===t.columnField))?void 0:e.filterOperators)?r:["contains"],e=>html`<option value="${e}" ?selected="${e===t.operatorValue}">${e}</option>`)}</select></label></div></div><div class="filter-form-column filter-form-column-border filterValueField"><div class="filter-form-group">${this.renderFilterInputControl(t,i)}</div></div></div>`}renderDropdown(){var e=this.filters.length>=this.filterColumns.length||this.activeFilters.length<this.filters.length;return html`<div class="filter-dropdown-content"><div class="filter-body">${this.filters.map((e,t)=>this.renderFilterInput(e,t))}</div><div class="filter-footer"><ix-button data-testid="addFilterButton" class="add-filter-button" @click="${()=>this.addFilter()}" ?disabled="${e}" appearance="text"><ix-icon slot="icon">add</ix-icon>Add filter</ix-button><ix-button data-testid="clearAllFiltersButton" @click="${()=>this.clearFilters()}" ?disabled="${0===this.activeFilters.length}" appearance="text">Clear all</ix-button></div></div>`}render(){return html`<div class="grid-menu"><div class="filter-container tooltip-container">${0<this.activeFilters.length?html`<span class="filter-superscript">${this.activeFilters.length}</span>`:nothing}<ix-button data-testid="showFiltersButton" appearance="text" class="filter_list filter-button" @click="${()=>{this.isDropdownVisible=!this.isDropdownVisible}}" @keyDown="${()=>{this.isDropdownVisible=!this.isDropdownVisible}}"><div class="slot-wrap"><ix-icon appearance="default" class="filter-icon">filter_list</ix-icon><span class="filter">${copy.filters}</span></div></ix-button><div class="tool-tip">${this.renderToolTip()}</div>${this.isDropdownVisible?this.renderDropdown():nothing}</div></div>`}},PaginationStyles=(IxGridRowFilter.styles=[IxGridViewStyles,IxGridRowFilterStyles],__decorate([property({type:Array})],IxGridRowFilter.prototype,"columns",void 0),__decorate([property({type:Number})],IxGridRowFilter.prototype,"filterValueChangeDebounceTime",void 0),__decorate([property({type:Boolean})],IxGridRowFilter.prototype,"readParamsFromURL",void 0),__decorate([state()],IxGridRowFilter.prototype,"isDropdownVisible",void 0),__decorate([state()],IxGridRowFilter.prototype,"filters",void 0),__decorate([state()],IxGridRowFilter.prototype,"filterableColumns",void 0),__decorate([state()],IxGridRowFilter.prototype,"filterColumns",void 0),__decorate([state()],IxGridRowFilter.prototype,"activeFilters",void 0),__decorate([state()],IxGridRowFilter.prototype,"mapSelect",void 0),__decorate([state()],IxGridRowFilter.prototype,"maxDate",void 0),__decorate([state()],IxGridRowFilter.prototype,"fromDateErrorText",void 0),IxGridRowFilter=__decorate([customElement("ix-grid-row-filter")],IxGridRowFilter),css`:host{--md-filled-select-text-field-input-text-size:var(
|
|
4
4
|
--ix-filled-select-text-field-input-text-size,
|
|
@@ -11,4 +11,4 @@ import{__decorate}from"tslib";import"@digital-realty/ix-icon-button/ix-icon-butt
|
|
|
11
11
|
#1456e0
|
|
12
12
|
);--md-filled-select-text-field-focus-active-indicator-color:var(
|
|
13
13
|
--md-filled-select-text-field-focus-trailing-icon-color
|
|
14
|
-
)}ix-select-option{--md-menu-item-selected-container-color:rgba(20, 86, 224, 0.1)}`),IxPagination=class extends LitElement{constructor(){super(...arguments),this.recordCount=0,this.page=1,this.pageSize=10,this.pageSizes=[5,10,25,100]}changePage(e){this.page+=e,this.updatePagination()}updatePagination(e=this.page,t=this.pageSize){this.dispatchEvent(new CustomEvent("updatePagination",{detail:{page:e,pageSize:t},bubbles:!0,composed:!0}))}render(){let e=1<this.page,t=this.recordCount>this.page*this.pageSize;return html`<div class="pagination"><p class="rows-per-page">${copy.rowsPerPage}:</p><ix-select wide-menu menu-positioning="fixed" class="pagination__select-input" @request-selection="${e=>{e=e.target;this.pageSize=Number(e.value),this.updatePagination()}}" selected-index="${this.pageSizes.indexOf(this.pageSize)}" filled>${this.pageSizes.map(e=>html`<ix-select-option class="select-option" value="${e}" ?selected="${e===this.pageSize}"><div slot="headline">${e}</div></ix-select-option>`)}</ix-select><p>${0<this.recordCount?(this.page-1)*this.pageSize+1:0} - ${this.page*this.pageSize>this.recordCount?html`${this.recordCount}`:html`${this.page*this.pageSize}`} of ${0<this.recordCount?this.recordCount:0}</p><div class="pagination-nav"><ix-icon-button ?disabled="${!e}" @click="${()=>e&&this.changePage(-1)}" icon="chevron_left"></ix-icon-button><ix-icon-button ?disabled="${!t}" @click="${()=>t&&this.changePage(1)}" icon="chevron_right"></ix-icon-button></div></div>`}};IxPagination.styles=[IxGridViewStyles,PaginationStyles],__decorate([property({type:Number})],IxPagination.prototype,"recordCount",void 0),__decorate([property({type:Number})],IxPagination.prototype,"page",void 0),__decorate([property({type:Number})],IxPagination.prototype,"pageSize",void 0),__decorate([property({type:Array})],IxPagination.prototype,"pageSizes",void 0),IxPagination=__decorate([customElement("ix-pagination")],IxPagination);class IxGrid extends LitElement{constructor(){super(...arguments),this.defaultPageSize=10,this.defaultPage=1,this.originalSearchParams=void 0,this.columnReorderingAllowed=!1,this.variantClass="",this.columns=[],this.rows=[],this.defaultEmptyText="No data to display",this.sortedColumn="",this.sortDirection="",this.hideHeader=!1,this.hideFilters=!1,this.rowLimit=0,this.page=this.defaultPage,this.pageSize=this.defaultPageSize,this.pageSizes=[5,10,25,100],this.recordCount=0,this.localStorageID=void 0,this.showDownload=!0,this.isDownloading=!1,this.isLoading=!1,this.downloadMenuItems=[],this.addParamsToURL=!0,this.readParamsFromURL=!1,this.refreshDataOnColumnVisibilityChange=!0,this.filterValueChangeDebounceTime=300,this.hideColumnHeaders=!1,this.filters=[],this.isColumnsReordering=!1,this.isExpanded=!1,this.displayColumns=[],this.hashedTableState="",this.initialised=!1,this.renderColumnHeader=(e,t,i)=>{t=classMap({header:!0,frozen:!!e.frozenToEnd,first:0===t,last:t===i-1});return html`<div @click="${()=>e.sortable&&this.handleSort(e.name)}" @keyDown="${()=>e.sortable&&this.handleSort(e.name)}" class="${t}"><span class="header-label">${e.header}</span> ${e.sortable?html`<ix-icon title="Sort" class="header-sort-icon">${"desc"===this.sortDirection&&this.sortedColumn===e.name?"arrow_upward":"arrow_downward"}</ix-icon>`:nothing}</div>`},this.columnRenderer=(e,t,i,r)=>{render(nothing,t);e=e.bodyRenderer(r.item,r,i);render(e,t)},this.renderHeader=()=>html`<div class="grid-header"><slot name="header"><div class="empty"></div></slot>${this.hideFilters?nothing:html`<div class="grid-menu"><ix-grid-column-filter .columns="${this.arrangedColumns}" columnsLocalStorageKey="${ifDefined(this.columnsLocalStorageKey)}" @columnFilter="${e=>this.handleOnColumnFilter(e)}" @reorderColumns="${this.reorderColumnsFromFilter}" .columnReorderingAllowed="${this.columnReorderingAllowed}" .refreshDataOnColumnVisibilityChange="${this.refreshDataOnColumnVisibilityChange}" .requestGridUpdate="${()=>this.requestUpdate()}"></ix-grid-column-filter>${this.showDownload?html`<ix-grid-download-menu .items="${this.downloadMenuItems}" .isDownloading="${this.isDownloading}"></ix-grid-download-menu>`:nothing}<ix-grid-row-filter .columns="${this.displayColumns}" .filterValueChangeDebounceTime="${this.filterValueChangeDebounceTime}" .readParamsFromURL="${this.readParamsFromURL}" @rowFilter="${e=>{this.filters=e.detail.filters,e.detail.resetPage&&(this.page=this.defaultPage),this.updatePage()}}"></ix-grid-row-filter></div>`}</div><div class="touch-edge"><slot name="under-header"></slot></div>`,this.renderRowLimitControls=()=>this.rows.length<=this.rowLimit?nothing:html`<div class="row-controls row-limit"><ix-button appearance="text" @click="${()=>{this.isExpanded=!this.isExpanded}}" has-icon>${this.isExpanded?copy.viewLess:copy.viewMore}<ix-icon slot="icon">${this.isExpanded?"remove":"add"}</ix-icon></ix-button></div>`,this.renderPaginationControls=()=>html`<div class="row-controls pagination"><ix-pagination .page="${this.page}" .pageSize="${this.pageSize}" .pageSizes="${this.pageSizes}" .recordCount="${this.recordCount}" @updatePagination="${e=>{this.page=e.detail.page,this.pageSize=e.detail.pageSize,this.updatePage()}}"></ix-pagination></div>`}get isPersistable(){return!!this.localStorageID}get columnNames(){return this.columns.map(e=>e.name)}get columnsLocalStorageKey(){if(""===this.hashedTableState){var e=this.columns.map(({bodyRenderer:e,...t})=>t),i=JSON.stringify(e);let t=0;for(let e=0;e<i.length;e+=1)t=31*t+i.charCodeAt(e)>>>0;this.hashedTableState=t.toString(36)}return`ix-grid-${this.localStorageID}-${this.hashedTableState}-columns`}get arrangedColumns(){let e=[];return(e=0===(e=this.getColumnsToDisplayFromLocalStorage()).length?[...this.columns]:e).filter(e=>e).map(e=>({...e,width:e.width||void 0}))}update(e){!this.initialised&&0<this.columns.length&&(this.displayColumns=[...this.columns],this.checkLocalStorageUpdate(),this.initialised=!0),super.update(e)}firstUpdated(){var e,t,i,r;this.readParamsFromURL&&(r=new URL(window.location.href),e=(r=new URLSearchParams(r.search)).get("sort"),t=r.get("order"),i=r.get("page"),r=r.get("size"),e&&t&&(this.sortedColumn=e,this.sortDirection=t),i&&(this.page=parseInt(i,10)||this.defaultPage),r)&&(this.pageSize=parseInt(r,10)||this.defaultPageSize),this.removeOldLocalStorageValues()}checkLocalStorageUpdate(){if(this.isPersistable){let i=JSON.parse(localStorage.getItem(this.columnsLocalStorageKey)||"[]");if(0<i.length){let e=!1;i.length!==this.columns.length&&(e=!0);var t=this.columns.every(t=>i.some(e=>e.name===t.name))&&i.every(t=>this.columns.some(e=>e.name===t.name));(e=t?e:!0)&&this.setColumnsToLocalStorage(this.columns)}}}buildQueryFromFilters(){let t=new URLSearchParams;return this.filters.forEach(e=>{t.append(e.columnField+"_"+e.operatorValue,e.value)}),Object.fromEntries(t)}getColumnsToDisplayFromLocalStorage(){let e=[];var t;return e=this.isPersistable&&0<(t=JSON.parse(localStorage.getItem(this.columnsLocalStorageKey)||"[]")).length?this.mapColumnsWithPersistedSettings(t):e}mapColumnsWithPersistedSettings(o){let i=new Map(o.map(e=>[e.name,e]));var e=this.columns.map(e=>{var t=i.get(e.name);return t?{...e,hidden:t.hidden,frozenToEnd:t.frozenToEnd,width:t.width||void 0}:{...e}});return e.sort((t,i)=>{var e=o.findIndex(e=>e.name===t.name),r=o.findIndex(e=>e.name===i.name);return-1===e&&-1===r?0:-1===e?1:-1===r?-1:e-r}),e}removeOldLocalStorageValues(){var t=this.findMatchingLocalStorageKeys(`ix-grid-${this.localStorageID}-`,"-columns",this.hashedTableState);for(let e=0;e<=t.length;e+=1)localStorage.removeItem(t[e])}findMatchingLocalStorageKeys(t,i,e){var r=[],o=t+e+i;for(let e=0;e<localStorage.length;e+=1){var a=localStorage.key(e);a&&a.startsWith(t)&&a.endsWith(i)&&a!==o&&r.push(a)}return r}async updatePage(e=!0){var t,i=this.filters.reduce((e,{columnField:t,value:i})=>({...e,[t]:i}),{});this.dispatchEvent(new CustomEvent("change",{detail:{columnName:this.sortedColumn,sortOrder:this.sortDirection,page:this.page,pageSize:this.pageSize,filters:i,filtersOperators:this.filters.map(e=>({columnField:e.columnField,operator:e.operatorValue}))},bubbles:!0,composed:!0})),this.addParamsToURL&&e&&(i={sort:this.sortedColumn,order:this.sortDirection,page:this.page.toString(),size:this.pageSize.toString(),...this.buildQueryFromFilters()},e=new URL(window.location.href),i=new URLSearchParams(i),this.originalSearchParams||this.saveOriginalSearchParams(i),t=new URLSearchParams([...null!=(t=this.originalSearchParams)?t:[],...i]),e.search=t.toString(),window.history.replaceState(null,"",e.toString()))}saveOriginalSearchParams(e){var t=new URL(window.location.href);let i=new URLSearchParams(t.search);this.filters.forEach(e=>{i.delete(e.columnField+"_"+e.operatorValue)}),e.forEach((e,t)=>{i.delete(t)}),this.originalSearchParams=i}handleSort(e=""){this.sortedColumn!==e?this.sortDirection="asc":this.sortDirection="asc"===this.sortDirection?"desc":"asc",this.sortedColumn=e,this.updatePage()}setColumnsToLocalStorage(e){this.isPersistable&&localStorage.setItem(this.columnsLocalStorageKey,JSON.stringify(e))}async reorderColumnsFromTable(){var e=[...this.arrangedColumns],t=e.filter(e=>!0!==e.hidden),r=e.filter(e=>!0===e.hidden),e=e.filter(e=>!0===e.frozenToEnd);let o=[...t.filter(e=>!0!==(null==e?void 0:e.frozenToEnd)),...r.filter(e=>!0!==(null==e?void 0:e.frozenToEnd)),...e];t=Array.from((null==(t=null==(t=this.grid)?void 0:t.shadowRoot)?void 0:t.querySelectorAll("th"))||[]);if(t.length){let i=t.map((e,t)=>({id:t,flexPosition:Number(e.style.order)})).sort((e,t)=>e.flexPosition-t.flexPosition).map(e=>e.id);t=[];i.every((e,t)=>0===t||e>i[t-1])||(t=i.map(e=>o[e]),this.displayColumns=[...t.filter(e=>!0!==e.hidden&&!0!==(null==e?void 0:e.frozenToEnd)),...r.filter(e=>!0!==(null==e?void 0:e.frozenToEnd)),...e],this.isColumnsReordering=!0,await this.updateComplete,this.isColumnsReordering=!1,this.setColumnsToLocalStorage(this.displayColumns))}}async reorderColumnsFromFilter(e){this.displayColumns=[...e.detail.reorderedColumns],this.setColumnsToLocalStorage([...this.displayColumns]),this.isColumnsReordering=!0,await this.updateComplete,this.isColumnsReordering=!1}handleOnColumnFilter(e){e.detail.columns.forEach((e,t)=>{this.displayColumns[t]&&(this.displayColumns[t].hidden=null==e?void 0:e.hidden)}),this.updatePage(!1)}cellPartNameGenerator(e,t){let i="";return t.item.disabled&&(i+=" ix-disabled-cell"),i}renderColumns(){let t=[...this.arrangedColumns];return 0<t.length?html`${t.map((r,e)=>!0===r.hidden?nothing:html`<vaadin-grid-column ${columnHeaderRenderer(()=>this.renderColumnHeader(r,e,t.length),this.sortDirection)} .renderer="${(e,t,i)=>this.columnRenderer(r,e,t,i)}" resizable width="${ifDefined(r.width)}" ?hidden="${r.hidden}" ?frozen-to-end="${r.frozenToEnd}" path="${r.name}" ?auto-width="${r.autoWidth}" flex-grow="${ifDefined(r.flexGrow)}"></vaadin-grid-column>`)}`:html`<vaadin-grid-column></vaadin-grid-column>`}renderLoading(){return html`<div class="progress-container" style="display:${this.isLoading?"":"none"}"><ix-progress .indeterminate="${!0}"></ix-progress></div>`}render(){return html`<div class="${`grid-container ${this.isColumnsReordering?"columns-reordering":""} `+this.variantClass}">${this.hideHeader?nothing:this.renderHeader()} ${this.renderLoading()} ${this.isColumnsReordering?nothing:html`<vaadin-grid class="${this.hideColumnHeaders?"hide-column-headers":""}" .items="${0<this.rowLimit&&!this.isExpanded?this.rows.slice(0,this.rowLimit):this.rows}" all-rows-visible ?column-reordering-allowed="${this.columnReorderingAllowed}" theme="no-border" .cellPartNameGenerator="${this.cellPartNameGenerator}" @mouseup="${this.reorderColumnsFromTable}">${this.renderColumns()}</vaadin-grid>${0!==this.rows.length||this.isColumnsReordering?nothing:html`<slot name="no-rows"></slot>`}`} ${0<this.rowLimit?this.renderRowLimitControls():this.renderPaginationControls()}<slot name="footer"></slot></div>`}}IxGrid.styles=[IxGridViewStyles],__decorate([query("vaadin-grid")],IxGrid.prototype,"grid",void 0),__decorate([property({type:Boolean,attribute:"column-reordering-allowed"})],IxGrid.prototype,"columnReorderingAllowed",void 0),__decorate([property({type:String})],IxGrid.prototype,"variantClass",void 0),__decorate([property({type:Array})],IxGrid.prototype,"columns",void 0),__decorate([property({type:Array})],IxGrid.prototype,"rows",void 0),__decorate([property({type:String})],IxGrid.prototype,"defaultEmptyText",void 0),__decorate([property({type:String})],IxGrid.prototype,"sortedColumn",void 0),__decorate([property({type:String})],IxGrid.prototype,"sortDirection",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"hideHeader",void 0),__decorate([property({type:Boolean,attribute:"hide-filters"})],IxGrid.prototype,"hideFilters",void 0),__decorate([property({type:Number})],IxGrid.prototype,"rowLimit",void 0),__decorate([property({type:Number})],IxGrid.prototype,"page",void 0),__decorate([property({type:Number})],IxGrid.prototype,"pageSize",void 0),__decorate([property({type:Array})],IxGrid.prototype,"pageSizes",void 0),__decorate([property({type:Number})],IxGrid.prototype,"recordCount",void 0),__decorate([property({type:String})],IxGrid.prototype,"localStorageID",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"showDownload",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"isDownloading",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"isLoading",void 0),__decorate([property({type:Array})],IxGrid.prototype,"downloadMenuItems",void 0),__decorate([property({type:Boolean,attribute:"add-params-to-url"})],IxGrid.prototype,"addParamsToURL",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"readParamsFromURL",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"refreshDataOnColumnVisibilityChange",void 0),__decorate([property({type:Number})],IxGrid.prototype,"filterValueChangeDebounceTime",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"hideColumnHeaders",void 0),__decorate([state()],IxGrid.prototype,"filters",void 0),__decorate([state()],IxGrid.prototype,"isColumnsReordering",void 0),__decorate([state()],IxGrid.prototype,"isExpanded",void 0),__decorate([state()],IxGrid.prototype,"displayColumns",void 0),window.customElements.define("ix-grid",IxGrid);
|
|
14
|
+
)}ix-select-option{--md-menu-item-selected-container-color:rgba(20, 86, 224, 0.1)}`),IxPagination=class extends LitElement{constructor(){super(...arguments),this.recordCount=0,this.page=1,this.pageSize=10,this.pageSizes=[5,10,25,100]}changePage(e){this.page+=e,this.updatePagination()}updatePagination(e=this.page,t=this.pageSize){this.dispatchEvent(new CustomEvent("updatePagination",{detail:{page:e,pageSize:t},bubbles:!0,composed:!0}))}render(){let e=1<this.page,t=this.recordCount>this.page*this.pageSize;return html`<div class="pagination"><p class="rows-per-page">${copy.rowsPerPage}:</p><ix-select wide-menu menu-positioning="fixed" class="pagination__select-input" @request-selection="${e=>{e=e.target;this.pageSize=Number(e.value),this.updatePagination()}}" selected-index="${this.pageSizes.indexOf(this.pageSize)}" filled>${this.pageSizes.map(e=>html`<ix-select-option class="select-option" value="${e}" ?selected="${e===this.pageSize}"><div slot="headline">${e}</div></ix-select-option>`)}</ix-select><p>${0<this.recordCount?(this.page-1)*this.pageSize+1:0} - ${this.page*this.pageSize>this.recordCount?html`${this.recordCount}`:html`${this.page*this.pageSize}`} of ${0<this.recordCount?this.recordCount:0}</p><div class="pagination-nav"><ix-icon-button ?disabled="${!e}" @click="${()=>e&&this.changePage(-1)}" icon="chevron_left" data-testid="ix-pagination-prev"></ix-icon-button><ix-icon-button ?disabled="${!t}" @click="${()=>t&&this.changePage(1)}" icon="chevron_right" data-testid="ix-pagination-next"></ix-icon-button></div></div>`}};IxPagination.styles=[IxGridViewStyles,PaginationStyles],__decorate([property({type:Number})],IxPagination.prototype,"recordCount",void 0),__decorate([property({type:Number})],IxPagination.prototype,"page",void 0),__decorate([property({type:Number})],IxPagination.prototype,"pageSize",void 0),__decorate([property({type:Array})],IxPagination.prototype,"pageSizes",void 0),IxPagination=__decorate([customElement("ix-pagination")],IxPagination);class IxGrid extends LitElement{constructor(){super(...arguments),this.defaultPageSize=10,this.defaultPage=1,this.originalSearchParams=void 0,this.columnReorderingAllowed=!1,this.variantClass="",this.columns=[],this.rows=[],this.defaultEmptyText="No data to display",this.sortedColumn="",this.sortDirection="",this.hideHeader=!1,this.hideFilters=!1,this.rowLimit=0,this.page=this.defaultPage,this.pageSize=this.defaultPageSize,this.pageSizes=[5,10,25,100],this.recordCount=0,this.localStorageID=void 0,this.showDownload=!0,this.isDownloading=!1,this.isLoading=!1,this.downloadMenuItems=[],this.addParamsToURL=!0,this.readParamsFromURL=!1,this.refreshDataOnColumnVisibilityChange=!0,this.filterValueChangeDebounceTime=300,this.hideColumnHeaders=!1,this.filters=[],this.isColumnsReordering=!1,this.isExpanded=!1,this.displayColumns=[],this.hashedTableState="",this.initialised=!1,this.renderColumnHeader=(e,t,i)=>{t=classMap({header:!0,frozen:!!e.frozenToEnd,first:0===t,last:t===i-1});return html`<div @click="${()=>e.sortable&&this.handleSort(e.name)}" @keyDown="${()=>e.sortable&&this.handleSort(e.name)}" class="${t}"><span class="header-label">${e.header}</span> ${e.sortable?html`<ix-icon title="Sort" class="header-sort-icon">${"desc"===this.sortDirection&&this.sortedColumn===e.name?"arrow_upward":"arrow_downward"}</ix-icon>`:nothing}</div>`},this.columnRenderer=(e,t,i,r)=>{render(nothing,t);e=e.bodyRenderer(r.item,r,i);render(e,t)},this.renderHeader=()=>html`<div class="grid-header"><slot name="header"><div class="empty"></div></slot>${this.hideFilters?nothing:html`<div class="grid-menu"><ix-grid-column-filter .columns="${this.arrangedColumns}" columnsLocalStorageKey="${ifDefined(this.columnsLocalStorageKey)}" @columnFilter="${e=>this.handleOnColumnFilter(e)}" @reorderColumns="${this.reorderColumnsFromFilter}" .columnReorderingAllowed="${this.columnReorderingAllowed}" .refreshDataOnColumnVisibilityChange="${this.refreshDataOnColumnVisibilityChange}" .requestGridUpdate="${()=>this.requestUpdate()}"></ix-grid-column-filter>${this.showDownload?html`<ix-grid-download-menu .items="${this.downloadMenuItems}" .isDownloading="${this.isDownloading}"></ix-grid-download-menu>`:nothing}<ix-grid-row-filter .columns="${this.displayColumns}" .filterValueChangeDebounceTime="${this.filterValueChangeDebounceTime}" .readParamsFromURL="${this.readParamsFromURL}" @rowFilter="${e=>{this.filters=e.detail.filters,e.detail.resetPage&&(this.page=this.defaultPage),this.updatePage()}}"></ix-grid-row-filter></div>`}</div><div class="touch-edge"><slot name="under-header"></slot></div>`,this.renderRowLimitControls=()=>this.rows.length<=this.rowLimit?nothing:html`<div class="row-controls row-limit"><ix-button appearance="text" @click="${()=>{this.isExpanded=!this.isExpanded}}" has-icon>${this.isExpanded?copy.viewLess:copy.viewMore}<ix-icon slot="icon">${this.isExpanded?"remove":"add"}</ix-icon></ix-button></div>`,this.renderPaginationControls=()=>html`<div class="row-controls pagination"><ix-pagination .page="${this.page}" .pageSize="${this.pageSize}" .pageSizes="${this.pageSizes}" .recordCount="${this.recordCount}" @updatePagination="${e=>{this.page=e.detail.page,this.pageSize=e.detail.pageSize,this.updatePage()}}"></ix-pagination></div>`}get isPersistable(){return!!this.localStorageID}get columnNames(){return this.columns.map(e=>e.name)}get columnsLocalStorageKey(){if(""===this.hashedTableState){var e=this.columns.map(({bodyRenderer:e,...t})=>t),i=JSON.stringify(e);let t=0;for(let e=0;e<i.length;e+=1)t=31*t+i.charCodeAt(e)>>>0;this.hashedTableState=t.toString(36)}return`ix-grid-${this.localStorageID}-${this.hashedTableState}-columns`}get arrangedColumns(){let e=[];return(e=0===(e=this.getColumnsToDisplayFromLocalStorage()).length?[...this.columns]:e).filter(e=>e).map(e=>({...e,width:e.width||void 0}))}update(e){!this.initialised&&0<this.columns.length&&(this.displayColumns=[...this.columns],this.checkLocalStorageUpdate(),this.initialised=!0),super.update(e)}firstUpdated(){var e,t,i,r;this.readParamsFromURL&&(r=new URL(window.location.href),e=(r=new URLSearchParams(r.search)).get("sort"),t=r.get("order"),i=r.get("page"),r=r.get("size"),e&&t&&(this.sortedColumn=e,this.sortDirection=t),i&&(this.page=parseInt(i,10)||this.defaultPage),r)&&(this.pageSize=parseInt(r,10)||this.defaultPageSize),this.removeOldLocalStorageValues()}checkLocalStorageUpdate(){if(this.isPersistable){let i=JSON.parse(localStorage.getItem(this.columnsLocalStorageKey)||"[]");if(0<i.length){let e=!1;i.length!==this.columns.length&&(e=!0);var t=this.columns.every(t=>i.some(e=>e.name===t.name))&&i.every(t=>this.columns.some(e=>e.name===t.name));(e=t?e:!0)&&this.setColumnsToLocalStorage(this.columns)}}}buildQueryFromFilters(){let t=new URLSearchParams;return this.filters.forEach(e=>{t.append(e.columnField+"_"+e.operatorValue,e.value)}),Object.fromEntries(t)}getColumnsToDisplayFromLocalStorage(){let e=[];var t;return e=this.isPersistable&&0<(t=JSON.parse(localStorage.getItem(this.columnsLocalStorageKey)||"[]")).length?this.mapColumnsWithPersistedSettings(t):e}mapColumnsWithPersistedSettings(o){let i=new Map(o.map(e=>[e.name,e]));var e=this.columns.map(e=>{var t=i.get(e.name);return t?{...e,hidden:t.hidden,frozenToEnd:t.frozenToEnd,width:t.width||void 0}:{...e}});return e.sort((t,i)=>{var e=o.findIndex(e=>e.name===t.name),r=o.findIndex(e=>e.name===i.name);return-1===e&&-1===r?0:-1===e?1:-1===r?-1:e-r}),e}removeOldLocalStorageValues(){var t=this.findMatchingLocalStorageKeys(`ix-grid-${this.localStorageID}-`,"-columns",this.hashedTableState);for(let e=0;e<=t.length;e+=1)localStorage.removeItem(t[e])}findMatchingLocalStorageKeys(t,i,e){var r=[],o=t+e+i;for(let e=0;e<localStorage.length;e+=1){var a=localStorage.key(e);a&&a.startsWith(t)&&a.endsWith(i)&&a!==o&&r.push(a)}return r}async updatePage(e=!0){var t,i=this.filters.reduce((e,{columnField:t,value:i})=>({...e,[t]:i}),{});this.dispatchEvent(new CustomEvent("change",{detail:{columnName:this.sortedColumn,sortOrder:this.sortDirection,page:this.page,pageSize:this.pageSize,filters:i,filtersOperators:this.filters.map(e=>({columnField:e.columnField,operator:e.operatorValue}))},bubbles:!0,composed:!0})),this.addParamsToURL&&e&&(i={sort:this.sortedColumn,order:this.sortDirection,page:this.page.toString(),size:this.pageSize.toString(),...this.buildQueryFromFilters()},e=new URL(window.location.href),i=new URLSearchParams(i),this.originalSearchParams||this.saveOriginalSearchParams(i),t=new URLSearchParams([...null!=(t=this.originalSearchParams)?t:[],...i]),e.search=t.toString(),window.history.replaceState(null,"",e.toString()))}saveOriginalSearchParams(e){var t=new URL(window.location.href);let i=new URLSearchParams(t.search);this.filters.forEach(e=>{i.delete(e.columnField+"_"+e.operatorValue)}),e.forEach((e,t)=>{i.delete(t)}),this.originalSearchParams=i}handleSort(e=""){this.sortedColumn!==e?this.sortDirection="asc":this.sortDirection="asc"===this.sortDirection?"desc":"asc",this.sortedColumn=e,this.updatePage()}setColumnsToLocalStorage(e){this.isPersistable&&localStorage.setItem(this.columnsLocalStorageKey,JSON.stringify(e))}async reorderColumnsFromTable(){var e=[...this.arrangedColumns],t=e.filter(e=>!0!==e.hidden),r=e.filter(e=>!0===e.hidden),e=e.filter(e=>!0===e.frozenToEnd);let o=[...t.filter(e=>!0!==(null==e?void 0:e.frozenToEnd)),...r.filter(e=>!0!==(null==e?void 0:e.frozenToEnd)),...e];t=Array.from((null==(t=null==(t=this.grid)?void 0:t.shadowRoot)?void 0:t.querySelectorAll("th"))||[]);if(t.length){let i=t.map((e,t)=>({id:t,flexPosition:Number(e.style.order)})).sort((e,t)=>e.flexPosition-t.flexPosition).map(e=>e.id);t=[];i.every((e,t)=>0===t||e>i[t-1])||(t=i.map(e=>o[e]),this.displayColumns=[...t.filter(e=>!0!==e.hidden&&!0!==(null==e?void 0:e.frozenToEnd)),...r.filter(e=>!0!==(null==e?void 0:e.frozenToEnd)),...e],this.isColumnsReordering=!0,await this.updateComplete,this.isColumnsReordering=!1,this.setColumnsToLocalStorage(this.displayColumns))}}async reorderColumnsFromFilter(e){this.displayColumns=[...e.detail.reorderedColumns],this.setColumnsToLocalStorage([...this.displayColumns]),this.isColumnsReordering=!0,await this.updateComplete,this.isColumnsReordering=!1}handleOnColumnFilter(e){e.detail.columns.forEach((e,t)=>{this.displayColumns[t]&&(this.displayColumns[t].hidden=null==e?void 0:e.hidden)}),this.updatePage(!1)}cellPartNameGenerator(e,t){let i="";return t.item.disabled&&(i+=" ix-disabled-cell"),i}renderColumns(){let t=[...this.arrangedColumns];return 0<t.length?html`${t.map((r,e)=>!0===r.hidden?nothing:html`<vaadin-grid-column ${columnHeaderRenderer(()=>this.renderColumnHeader(r,e,t.length),this.sortDirection)} .renderer="${(e,t,i)=>this.columnRenderer(r,e,t,i)}" resizable width="${ifDefined(r.width)}" ?hidden="${r.hidden}" ?frozen-to-end="${r.frozenToEnd}" path="${r.name}" ?auto-width="${r.autoWidth}" flex-grow="${ifDefined(r.flexGrow)}"></vaadin-grid-column>`)}`:html`<vaadin-grid-column></vaadin-grid-column>`}renderLoading(){return html`<div class="progress-container" style="display:${this.isLoading?"":"none"}"><ix-progress .indeterminate="${!0}"></ix-progress></div>`}render(){return html`<div class="${`grid-container ${this.isColumnsReordering?"columns-reordering":""} `+this.variantClass}">${this.hideHeader?nothing:this.renderHeader()} ${this.renderLoading()} ${this.isColumnsReordering?nothing:html`<vaadin-grid class="${this.hideColumnHeaders?"hide-column-headers":""}" .items="${0<this.rowLimit&&!this.isExpanded?this.rows.slice(0,this.rowLimit):this.rows}" all-rows-visible ?column-reordering-allowed="${this.columnReorderingAllowed}" theme="no-border" .cellPartNameGenerator="${this.cellPartNameGenerator}" @mouseup="${this.reorderColumnsFromTable}">${this.renderColumns()}</vaadin-grid>${0!==this.rows.length||this.isColumnsReordering?nothing:html`<slot name="no-rows"></slot>`}`} ${0<this.rowLimit?this.renderRowLimitControls():this.renderPaginationControls()}<slot name="footer"></slot></div>`}}IxGrid.styles=[IxGridViewStyles],__decorate([query("vaadin-grid")],IxGrid.prototype,"grid",void 0),__decorate([property({type:Boolean,attribute:"column-reordering-allowed"})],IxGrid.prototype,"columnReorderingAllowed",void 0),__decorate([property({type:String})],IxGrid.prototype,"variantClass",void 0),__decorate([property({type:Array})],IxGrid.prototype,"columns",void 0),__decorate([property({type:Array})],IxGrid.prototype,"rows",void 0),__decorate([property({type:String})],IxGrid.prototype,"defaultEmptyText",void 0),__decorate([property({type:String})],IxGrid.prototype,"sortedColumn",void 0),__decorate([property({type:String})],IxGrid.prototype,"sortDirection",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"hideHeader",void 0),__decorate([property({type:Boolean,attribute:"hide-filters"})],IxGrid.prototype,"hideFilters",void 0),__decorate([property({type:Number})],IxGrid.prototype,"rowLimit",void 0),__decorate([property({type:Number})],IxGrid.prototype,"page",void 0),__decorate([property({type:Number})],IxGrid.prototype,"pageSize",void 0),__decorate([property({type:Array})],IxGrid.prototype,"pageSizes",void 0),__decorate([property({type:Number})],IxGrid.prototype,"recordCount",void 0),__decorate([property({type:String})],IxGrid.prototype,"localStorageID",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"showDownload",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"isDownloading",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"isLoading",void 0),__decorate([property({type:Array})],IxGrid.prototype,"downloadMenuItems",void 0),__decorate([property({type:Boolean,attribute:"add-params-to-url"})],IxGrid.prototype,"addParamsToURL",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"readParamsFromURL",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"refreshDataOnColumnVisibilityChange",void 0),__decorate([property({type:Number})],IxGrid.prototype,"filterValueChangeDebounceTime",void 0),__decorate([property({type:Boolean})],IxGrid.prototype,"hideColumnHeaders",void 0),__decorate([state()],IxGrid.prototype,"filters",void 0),__decorate([state()],IxGrid.prototype,"isColumnsReordering",void 0),__decorate([state()],IxGrid.prototype,"isExpanded",void 0),__decorate([state()],IxGrid.prototype,"displayColumns",void 0),window.customElements.define("ix-grid",IxGrid);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ix-grid following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Digital Realty",
|
|
6
|
-
"version": "1.2.
|
|
6
|
+
"version": "1.2.3",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"prettier --write"
|
|
112
112
|
]
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "580ca2419bf433dcef772180f74e5add493c08b5"
|
|
115
115
|
}
|
|
@@ -77,12 +77,14 @@ export class IxPagination extends LitElement {
|
|
|
77
77
|
?disabled=${!back}
|
|
78
78
|
@click=${() => back && this.changePage(-1)}
|
|
79
79
|
icon="chevron_left"
|
|
80
|
+
data-testid="ix-pagination-prev"
|
|
80
81
|
>
|
|
81
82
|
</ix-icon-button>
|
|
82
83
|
<ix-icon-button
|
|
83
84
|
?disabled=${!next}
|
|
84
85
|
@click=${() => next && this.changePage(+1)}
|
|
85
86
|
icon="chevron_right"
|
|
87
|
+
data-testid="ix-pagination-next"
|
|
86
88
|
>
|
|
87
89
|
</ix-icon-button>
|
|
88
90
|
</div>
|