@digital-realty/ix-grid 1.0.34 → 1.0.36
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.
- package/demo/index.html +20 -2
- package/dist/IxGrid.js +12 -10
- package/dist/IxGrid.js.map +1 -1
- package/dist/components/IxGridNav.d.ts +2 -1
- package/dist/components/IxGridNav.js +3 -2
- package/dist/components/IxGridNav.js.map +1 -1
- package/dist/ix-grid.min.js +1 -1
- package/dist/test/ix-grid.test.js +5 -2
- package/dist/test/ix-grid.test.js.map +1 -1
- package/package.json +2 -2
- package/src/IxGrid.ts +17 -15
- package/src/components/IxGridNav.ts +10 -2
- package/src/test/ix-grid.test.ts +5 -2
package/demo/index.html
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import '@digital-realty/theme';
|
|
25
25
|
import '@digital-realty/ix-button/ix-button.js';
|
|
26
26
|
import '../dist/ix-grid.js';
|
|
27
|
+
import '../dist/components/ix-grid-nav.js';
|
|
27
28
|
import { contacts } from './contacts.js';
|
|
28
29
|
import { columns } from './columns.js';
|
|
29
30
|
|
|
@@ -88,8 +89,25 @@
|
|
|
88
89
|
@download=${e => console.log(e)}
|
|
89
90
|
>
|
|
90
91
|
<div slot="header">
|
|
91
|
-
<ix-
|
|
92
|
-
|
|
92
|
+
<ix-grid-nav
|
|
93
|
+
class="reports-grid-nav"
|
|
94
|
+
.buttons=${[
|
|
95
|
+
{
|
|
96
|
+
path: '/reports/security',
|
|
97
|
+
text: 'Security Reports',
|
|
98
|
+
disabled: true,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
path: '/reports/dcim',
|
|
102
|
+
text: 'DCIM Reports',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
path: '/reports/maintenance',
|
|
106
|
+
text: 'Site Maintenance',
|
|
107
|
+
selected: true,
|
|
108
|
+
},
|
|
109
|
+
]}
|
|
110
|
+
></ix-grid-nav>
|
|
93
111
|
</div>
|
|
94
112
|
</ix-grid>
|
|
95
113
|
</div>
|
package/dist/IxGrid.js
CHANGED
|
@@ -206,16 +206,18 @@ export class IxGrid extends LitElement {
|
|
|
206
206
|
theme="no-border"
|
|
207
207
|
@mouseup=${this.reorderColumnsFromTable}
|
|
208
208
|
>
|
|
209
|
-
${
|
|
210
|
-
?
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
209
|
+
${this._columns.some(col => !col.hidden)
|
|
210
|
+
? (_a = this._columns) === null || _a === void 0 ? void 0 : _a.map((column) => column.name
|
|
211
|
+
? html `<vaadin-grid-column
|
|
212
|
+
${columnHeaderRenderer(() => this.renderColumnHeader(column), this.sortDirection)}
|
|
213
|
+
${columnBodyRenderer(column.bodyRenderer, [])}
|
|
214
|
+
resizable
|
|
215
|
+
width=${ifDefined(column.width)}
|
|
216
|
+
?hidden=${column.hidden}
|
|
217
|
+
?frozen-to-end=${column.frozenToEnd}
|
|
218
|
+
></vaadin-grid-column>`
|
|
219
|
+
: nothing)
|
|
220
|
+
: html `<vaadin-grid-column></vaadin-grid-column>`}
|
|
219
221
|
</vaadin-grid>`
|
|
220
222
|
: nothing}
|
|
221
223
|
${this.rowLimit > 0
|
package/dist/IxGrid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxGrid.js","sourceRoot":"","sources":["../src/IxGrid.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,kDAAkD,CAA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,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgD;AAE9C;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAqB;AAEY;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;8CACrD;AAEE;IAAR,KAAK,EAAE;uCAAgC;AAE/B;IAAR,KAAK,EAAE;wCAAyB;AAExB;IAAR,KAAK,EAAE;yCAAmB;AAElB;IAAR,KAAK,EAAE;0CAAoB","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport '@vaadin/grid';\nimport { columnBodyRenderer, columnHeaderRenderer } from '@vaadin/grid/lit.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport './components/IxGridDownloadMenu.js';\nimport './components/IxPagination.js';\nimport './components/IxGridColumnFilter.js';\nimport './components/IxGridRowFilter.js';\nimport type { Filter } from './components/IxGridRowFilter.js';\nimport { IxGridViewStyles } from './grid-view-styles.js';\nimport { copy } from './ix-grid-copy.js';\n\nexport interface Row {\n [key: string]: string;\n}\n\nexport interface Column {\n name: string;\n header: string;\n bodyRenderer: (row: Row) => any;\n width?: string;\n sortable?: boolean;\n filterable?: boolean;\n hidden?: boolean;\n frozenToEnd?: boolean;\n}\n\nexport class IxGrid extends LitElement {\n static readonly styles = [IxGridViewStyles];\n\n @query('vaadin-grid') grid!: HTMLElement;\n\n @property({ type: Array }) columns: Column[] = [];\n\n @property({ type: Array }) rows: Row[] = [];\n\n @property({ type: String }) defaultEmptyText = 'No data to display';\n\n @property({ type: String }) sortedColumn = '';\n\n @property({ type: String }) sortDirection = '';\n\n @property({ type: Boolean }) hideHeader = false;\n\n @property({ type: Boolean, attribute: 'hide-filters' }) hideFilters = false;\n\n @property({ type: Number }) rowLimit: number = 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 @property({ type: Number }) recordCount = 0;\n\n @property({ type: String }) localStorageID: string | undefined = undefined;\n\n @property({ type: Boolean }) showDownload = true;\n\n @property({ type: Boolean, attribute: 'add-params-to-url' }) addParamsToURL =\n true;\n\n @state() private filters: Filter[] = [];\n\n @state() _columns: Column[] = [];\n\n @state() isLoading = false;\n\n @state() isExpanded = false;\n\n get columnNames() {\n return this._columns.map((column: Column) => column.name);\n }\n\n private async updatePage() {\n const filters = this.filters.reduce(\n (columnFilters: { [key: string]: string }, { columnField, value }) => ({\n ...columnFilters,\n [columnField]: value,\n }),\n {}\n );\n\n if (this.addParamsToURL) {\n const urlParams: { [key: string]: string } = {\n sort: this.sortedColumn,\n order: this.sortDirection,\n page: this.page.toString(),\n size: this.pageSize.toString(),\n ...filters,\n };\n\n const url = new URL(window.location.href);\n const searchParams = new URLSearchParams(urlParams);\n url.search = searchParams.toString();\n window.history.replaceState(null, '', url.toString());\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: {\n columnName: this.sortedColumn,\n sortOrder: this.sortDirection,\n page: this.page,\n pageSize: this.pageSize,\n filters,\n },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n handleSort(column: string = '') {\n if (this.sortedColumn !== column) {\n this.sortDirection = 'asc';\n } else {\n this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';\n }\n this.sortedColumn = column;\n\n this.updatePage();\n }\n\n private renderColumnHeader = (column: Column) => html`\n <div\n @click=${() => column.sortable && this.handleSort(column.name)}\n @keyDown=${() => column.sortable && this.handleSort(column.name)}\n class=\"header\"\n >\n ${column.header}\n ${column.sortable\n ? html`<ix-icon title=\"Sort\" class=\"header-sort-icon\"\n >${this.sortDirection === 'desc' &&\n this.sortedColumn === column.name\n ? `arrow_upward`\n : `arrow_downward`}</ix-icon\n >`\n : nothing}\n </div>\n `;\n\n connectedCallback() {\n super.connectedCallback();\n this._columns = this.columns;\n }\n\n async reorderColumnsFromTable() {\n // calulate column order from table header flex order\n const headerNodes = Array.from(\n this.grid?.shadowRoot?.querySelectorAll('th') || []\n );\n if (headerNodes.length) {\n const columnOrder = headerNodes\n .map((el, id) => ({ id, flexPosition: Number(el.style.order) }))\n .sort((a, b) => a.flexPosition - b.flexPosition)\n .map(el => el.id);\n headerNodes.forEach((el, id) => {\n this._columns[id].width = el.style.width;\n });\n const columnsCorrectlyOrdered = columnOrder.every(\n (x, i) => i === 0 || x > columnOrder[i - 1]\n );\n if (!columnsCorrectlyOrdered) {\n const reorderedColumns = columnOrder.map(id => this._columns[id]);\n this._columns = [...reorderedColumns];\n this.isLoading = true;\n await this.updateComplete;\n this.isLoading = false;\n }\n }\n }\n\n async reorderColumnsFromFilter(e: CustomEvent) {\n this._columns = [...e.detail.reorderedColumns];\n this.isLoading = true;\n await this.updateComplete;\n this.isLoading = false;\n }\n\n private renderHeader = () => html`\n <div class=\"grid-header\">\n <slot name=\"header\"><div class=\"empty\"></div></slot>\n ${this.hideFilters\n ? nothing\n : html`<div class=\"grid-menu\">\n <ix-grid-column-filter\n .columns=${this._columns}\n localStorageID=${ifDefined(this.localStorageID)}\n @columnFilter=${(e: CustomEvent) => {\n e.detail.columns.forEach((column: Column, id: number) => {\n this._columns[id].hidden = column.hidden;\n });\n this.updatePage();\n }}\n @reorderColumns=${this.reorderColumnsFromFilter}\n ></ix-grid-column-filter>\n ${this.showDownload\n ? html`<ix-grid-download-menu></ix-grid-download-menu>`\n : nothing}\n <ix-grid-row-filter\n .columns=${this._columns}\n @rowFilter=${(e: CustomEvent) => {\n this.filters = e.detail.filters;\n this.updatePage();\n }}\n ></ix-grid-row-filter>\n </div>`}\n </div>\n <div class=\"touch-edge\">\n <slot name=\"under-header\"></slot>\n </div>\n `;\n\n private renderRowLimitControls = () => {\n if (this.rows.length <= this.rowLimit) return nothing;\n\n return html`\n <div class=\"row-limit\">\n <ix-button\n appearance=\"text\"\n @click=${() => {\n this.isExpanded = !this.isExpanded;\n }}\n has-icon\n >\n ${this.isExpanded ? copy.viewLess : copy.viewMore}\n <ix-icon slot=\"icon\">${this.isExpanded ? 'remove' : 'add'}</ix-icon>\n </ix-button>\n </div>\n `;\n };\n\n private renderPaginationControls = () => html`\n <ix-pagination\n .page=${this.page}\n .pageSize=${this.pageSize}\n .pageSizes=${this.pageSizes}\n .recordCount=${this.recordCount}\n @updatePagination=${(e: CustomEvent) => {\n this.page = e.detail.page;\n this.pageSize = e.detail.pageSize;\n this.updatePage();\n }}\n ></ix-pagination>\n `;\n\n render() {\n return html`\n <div class=${`grid-container ${this.isLoading ? 'loading' : ''}`}>\n ${this.hideHeader ? nothing : this.renderHeader()}\n ${!this.isLoading\n ? html`<vaadin-grid\n .items=${this.rowLimit > 0 && !this.isExpanded\n ? this.rows.slice(0, this.rowLimit)\n : this.rows}\n all-rows-visible\n column-reordering-allowed\n theme=\"no-border\"\n @mouseup=${this.reorderColumnsFromTable}\n >\n ${this._columns?.map((column: Column) =>\n column.name\n ? html`<vaadin-grid-column\n ${columnHeaderRenderer(\n () => this.renderColumnHeader(column),\n this.sortDirection\n )}\n ${columnBodyRenderer(column.bodyRenderer, [])}\n resizable\n width=${ifDefined(column.width)}\n ?hidden=${column.hidden}\n ?frozen-to-end=${column.frozenToEnd}\n ></vaadin-grid-column>`\n : nothing\n )}\n </vaadin-grid>`\n : nothing}\n ${this.rowLimit > 0\n ? this.renderRowLimitControls()\n : this.renderPaginationControls()}\n </div>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IxGrid.js","sourceRoot":"","sources":["../src/IxGrid.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,M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AQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAAU;AAET;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAAe;AAEf;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCAAwC;AAEtC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAiB;AAEhB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgD;AAE9C;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAqB;AAEY;IAA5D,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;8CACrD;AAEE;IAAR,KAAK,EAAE;uCAAgC;AAE/B;IAAR,KAAK,EAAE;wCAAyB;AAExB;IAAR,KAAK,EAAE;yCAAmB;AAElB;IAAR,KAAK,EAAE;0CAAoB","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state, query } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport '@vaadin/grid';\nimport { columnBodyRenderer, columnHeaderRenderer } from '@vaadin/grid/lit.js';\nimport '@digital-realty/ix-icon-button/ix-icon-button.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport './components/IxGridDownloadMenu.js';\nimport './components/IxPagination.js';\nimport './components/IxGridColumnFilter.js';\nimport './components/IxGridRowFilter.js';\nimport type { Filter } from './components/IxGridRowFilter.js';\nimport { IxGridViewStyles } from './grid-view-styles.js';\nimport { copy } from './ix-grid-copy.js';\n\nexport interface Row {\n [key: string]: string;\n}\n\nexport interface Column {\n name: string;\n header: string;\n bodyRenderer: (row: Row) => any;\n width?: string;\n sortable?: boolean;\n filterable?: boolean;\n hidden?: boolean;\n frozenToEnd?: boolean;\n}\n\nexport class IxGrid extends LitElement {\n static readonly styles = [IxGridViewStyles];\n\n @query('vaadin-grid') grid!: HTMLElement;\n\n @property({ type: Array }) columns: Column[] = [];\n\n @property({ type: Array }) rows: Row[] = [];\n\n @property({ type: String }) defaultEmptyText = 'No data to display';\n\n @property({ type: String }) sortedColumn = '';\n\n @property({ type: String }) sortDirection = '';\n\n @property({ type: Boolean }) hideHeader = false;\n\n @property({ type: Boolean, attribute: 'hide-filters' }) hideFilters = false;\n\n @property({ type: Number }) rowLimit: number = 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 @property({ type: Number }) recordCount = 0;\n\n @property({ type: String }) localStorageID: string | undefined = undefined;\n\n @property({ type: Boolean }) showDownload = true;\n\n @property({ type: Boolean, attribute: 'add-params-to-url' }) addParamsToURL =\n true;\n\n @state() private filters: Filter[] = [];\n\n @state() _columns: Column[] = [];\n\n @state() isLoading = false;\n\n @state() isExpanded = false;\n\n get columnNames() {\n return this._columns.map((column: Column) => column.name);\n }\n\n private async updatePage() {\n const filters = this.filters.reduce(\n (columnFilters: { [key: string]: string }, { columnField, value }) => ({\n ...columnFilters,\n [columnField]: value,\n }),\n {}\n );\n\n if (this.addParamsToURL) {\n const urlParams: { [key: string]: string } = {\n sort: this.sortedColumn,\n order: this.sortDirection,\n page: this.page.toString(),\n size: this.pageSize.toString(),\n ...filters,\n };\n\n const url = new URL(window.location.href);\n const searchParams = new URLSearchParams(urlParams);\n url.search = searchParams.toString();\n window.history.replaceState(null, '', url.toString());\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: {\n columnName: this.sortedColumn,\n sortOrder: this.sortDirection,\n page: this.page,\n pageSize: this.pageSize,\n filters,\n },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n handleSort(column: string = '') {\n if (this.sortedColumn !== column) {\n this.sortDirection = 'asc';\n } else {\n this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';\n }\n this.sortedColumn = column;\n\n this.updatePage();\n }\n\n private renderColumnHeader = (column: Column) => html`\n <div\n @click=${() => column.sortable && this.handleSort(column.name)}\n @keyDown=${() => column.sortable && this.handleSort(column.name)}\n class=\"header\"\n >\n ${column.header}\n ${column.sortable\n ? html`<ix-icon title=\"Sort\" class=\"header-sort-icon\"\n >${this.sortDirection === 'desc' &&\n this.sortedColumn === column.name\n ? `arrow_upward`\n : `arrow_downward`}</ix-icon\n >`\n : nothing}\n </div>\n `;\n\n connectedCallback() {\n super.connectedCallback();\n this._columns = this.columns;\n }\n\n async reorderColumnsFromTable() {\n // calulate column order from table header flex order\n const headerNodes = Array.from(\n this.grid?.shadowRoot?.querySelectorAll('th') || []\n );\n if (headerNodes.length) {\n const columnOrder = headerNodes\n .map((el, id) => ({ id, flexPosition: Number(el.style.order) }))\n .sort((a, b) => a.flexPosition - b.flexPosition)\n .map(el => el.id);\n headerNodes.forEach((el, id) => {\n this._columns[id].width = el.style.width;\n });\n const columnsCorrectlyOrdered = columnOrder.every(\n (x, i) => i === 0 || x > columnOrder[i - 1]\n );\n if (!columnsCorrectlyOrdered) {\n const reorderedColumns = columnOrder.map(id => this._columns[id]);\n this._columns = [...reorderedColumns];\n this.isLoading = true;\n await this.updateComplete;\n this.isLoading = false;\n }\n }\n }\n\n async reorderColumnsFromFilter(e: CustomEvent) {\n this._columns = [...e.detail.reorderedColumns];\n this.isLoading = true;\n await this.updateComplete;\n this.isLoading = false;\n }\n\n private renderHeader = () => html`\n <div class=\"grid-header\">\n <slot name=\"header\"><div class=\"empty\"></div></slot>\n ${this.hideFilters\n ? nothing\n : html`<div class=\"grid-menu\">\n <ix-grid-column-filter\n .columns=${this._columns}\n localStorageID=${ifDefined(this.localStorageID)}\n @columnFilter=${(e: CustomEvent) => {\n e.detail.columns.forEach((column: Column, id: number) => {\n this._columns[id].hidden = column.hidden;\n });\n this.updatePage();\n }}\n @reorderColumns=${this.reorderColumnsFromFilter}\n ></ix-grid-column-filter>\n ${this.showDownload\n ? html`<ix-grid-download-menu></ix-grid-download-menu>`\n : nothing}\n <ix-grid-row-filter\n .columns=${this._columns}\n @rowFilter=${(e: CustomEvent) => {\n this.filters = e.detail.filters;\n this.updatePage();\n }}\n ></ix-grid-row-filter>\n </div>`}\n </div>\n <div class=\"touch-edge\">\n <slot name=\"under-header\"></slot>\n </div>\n `;\n\n private renderRowLimitControls = () => {\n if (this.rows.length <= this.rowLimit) return nothing;\n\n return html`\n <div class=\"row-limit\">\n <ix-button\n appearance=\"text\"\n @click=${() => {\n this.isExpanded = !this.isExpanded;\n }}\n has-icon\n >\n ${this.isExpanded ? copy.viewLess : copy.viewMore}\n <ix-icon slot=\"icon\">${this.isExpanded ? 'remove' : 'add'}</ix-icon>\n </ix-button>\n </div>\n `;\n };\n\n private renderPaginationControls = () => html`\n <ix-pagination\n .page=${this.page}\n .pageSize=${this.pageSize}\n .pageSizes=${this.pageSizes}\n .recordCount=${this.recordCount}\n @updatePagination=${(e: CustomEvent) => {\n this.page = e.detail.page;\n this.pageSize = e.detail.pageSize;\n this.updatePage();\n }}\n ></ix-pagination>\n `;\n\n render() {\n return html`\n <div class=${`grid-container ${this.isLoading ? 'loading' : ''}`}>\n ${this.hideHeader ? nothing : this.renderHeader()}\n ${!this.isLoading\n ? html`<vaadin-grid\n .items=${this.rowLimit > 0 && !this.isExpanded\n ? this.rows.slice(0, this.rowLimit)\n : this.rows}\n all-rows-visible\n column-reordering-allowed\n theme=\"no-border\"\n @mouseup=${this.reorderColumnsFromTable}\n >\n ${this._columns.some(col => !col.hidden)\n ? this._columns?.map((column: Column) =>\n column.name\n ? html`<vaadin-grid-column\n ${columnHeaderRenderer(\n () => this.renderColumnHeader(column),\n this.sortDirection\n )}\n ${columnBodyRenderer(column.bodyRenderer, [])}\n resizable\n width=${ifDefined(column.width)}\n ?hidden=${column.hidden}\n ?frozen-to-end=${column.frozenToEnd}\n ></vaadin-grid-column>`\n : nothing\n )\n : html`<vaadin-grid-column></vaadin-grid-column>`}\n </vaadin-grid>`\n : nothing}\n ${this.rowLimit > 0\n ? this.renderRowLimitControls()\n : this.renderPaginationControls()}\n </div>\n `;\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { LitElement } from 'lit';
|
|
|
2
2
|
import '@digital-realty/ix-button';
|
|
3
3
|
export interface IGridNavButton {
|
|
4
4
|
path?: string;
|
|
5
|
+
selected?: boolean;
|
|
5
6
|
disabled?: boolean;
|
|
6
7
|
onClick?: () => void;
|
|
7
8
|
text: string;
|
|
@@ -9,6 +10,6 @@ export interface IGridNavButton {
|
|
|
9
10
|
export declare class IxGridNavigation extends LitElement {
|
|
10
11
|
buttons: IGridNavButton[];
|
|
11
12
|
static styles: import("lit").CSSResult;
|
|
12
|
-
renderButton: ({ path, text, onClick, disabled }: IGridNavButton) => import("lit").TemplateResult<1>;
|
|
13
|
+
renderButton: ({ path, text, onClick, disabled, selected, }: IGridNavButton) => import("lit").TemplateResult<1>;
|
|
13
14
|
render(): import("lit").TemplateResult<1>;
|
|
14
15
|
}
|
|
@@ -8,10 +8,11 @@ export class IxGridNavigation extends LitElement {
|
|
|
8
8
|
super(...arguments);
|
|
9
9
|
this.buttons = [];
|
|
10
10
|
// eslint-disable-next-line class-methods-use-this
|
|
11
|
-
this.renderButton = ({ path, text, onClick, disabled }) => html `
|
|
11
|
+
this.renderButton = ({ path, text, onClick, disabled, selected, }) => html `
|
|
12
12
|
<ix-button
|
|
13
13
|
?disabled=${disabled}
|
|
14
|
-
|
|
14
|
+
appearance=${selected ? 'filled' : 'text'}
|
|
15
|
+
href=${ifDefined(selected ? undefined : path)}
|
|
15
16
|
@click=${onClick}
|
|
16
17
|
class="button"
|
|
17
18
|
><div class="button-text">${text}</div></ix-button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxGridNav.js","sourceRoot":"","sources":["../../src/components/IxGridNav.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C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} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport '@digital-realty/ix-button';\n\nexport interface IGridNavButton {\n path?: string;\n selected?: boolean;\n disabled?: boolean;\n onClick?: () => void;\n text: string;\n}\n\nexport class IxGridNavigation extends LitElement {\n @property({ type: Array, attribute: false }) buttons: IGridNavButton[] = [];\n\n static styles = css`\n :host {\n --md-filled-button-container-color: var(\n --grid-nav-button-container-color,\n var(--ix-text-dark, #000)\n );\n --md-filled-button-container-height: var(\n --grid-nav-button-container-height,\n 2.5rem\n );\n --md-filled-button-leading-space: var(\n --grid-nav-button-leading-space,\n 20px\n );\n --md-filled-button-trailing-space: var(\n --grid-nav-button-trailing-space,\n 20px\n );\n }\n\n [disabled] {\n --md-filled-button-disabled-container-color: var(\n --grid-nav-button-disabled-container-color,\n transparent\n );\n --md-filled-button-disabled-label-text-color: var(\n --grid-nav-button-disabled-container-color,\n var(--ix-text-dark, #000)\n );\n }\n\n .container {\n display: var(--grid-nav-button-group-display, flex);\n gap: var(--grid-nav-button-group-gap, 0.5rem);\n }\n\n .button {\n margin: var(--grid-nav-button-margin, 0);\n }\n\n .button-text {\n text-transform: var(--grid-nav-button-text-transform, none);\n }\n `;\n\n // eslint-disable-next-line class-methods-use-this\n renderButton = ({\n path,\n text,\n onClick,\n disabled,\n selected,\n }: IGridNavButton) =>\n html`\n <ix-button\n ?disabled=${disabled}\n appearance=${selected ? 'filled' : 'text'}\n href=${ifDefined(selected ? undefined : path)}\n @click=${onClick}\n class=\"button\"\n ><div class=\"button-text\">${text}</div></ix-button\n >\n `;\n\n render() {\n return html`\n <div class=\"container\">\n ${this.buttons.map(button => this.renderButton(button))}\n </div>\n `;\n }\n}\n"]}
|
package/dist/ix-grid.min.js
CHANGED
|
@@ -2,4 +2,4 @@ import{__decorate}from"tslib";import{css,LitElement,html,nothing}from"lit";impor
|
|
|
2
2
|
--md-filled-select-text-field-focus-trailing-icon-color
|
|
3
3
|
)}ix-select-option{--md-menu-item-selected-container-color:rgba(20, 86, 224, 0.1)}`,copy={activeFilter:"active filter",filters:"Filters",hideFilters:"Hide Filters",showFilters:"Show Filters",rowsPerPage:"Rows per page",user:"user",viewMore:"VIEW MORE",viewLess:"VIEW LESS"};let 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(){const e=1<this.page,t=this.recordCount>this.page*this.pageSize;return html`<div class="pagination"><p>${copy.rowsPerPage}:</p><ix-select wide-menu 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}"><div slot="headline">${e}</div></ix-select-option>`)}</ix-select><p>${(this.page-1)*this.pageSize+1} - ${this.page*this.pageSize>this.recordCount?html`${this.recordCount}`:html`${this.page*this.pageSize}`} of ${this.recordCount}</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);const IxGridColumnFilterStyles=css`.dropdown-content{position:absolute;background-color:#f9f9f9;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}.dropdown-content>div{margin:0;font-family:'Open Sans',sans-serif;font-style:normal;font-weight:400;font-size:14px;line-height:24px;letter-spacing:.25px;color:#092241;display:block;cursor:pointer}.dropdown-content span:hover{background-color:#f1f1f1}.dropdown-content label{display:flex;align-items:center;background-color:#f9f9f9}.dropdown-content label.dragOrigin{background:#ff000017;outline:1px #ff9d9d dashed}.dropdown-content label p{flex:2}.dropdown-content label ix-icon.draggable{font-size:24px;color:var(--md-sys-color-primary,#1456e0);cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab;opacity:0}.dropdown-content label:hover ix-icon.draggable{opacity:1}.active{position:absolute;right:0;top:0;height:8px;width:8px;background-color:#db0028;border-radius:50%}ix-switch{padding:2px 4px;--md-switch-track-height:12px;--md-switch-track-width:35px;--md-sys-color-primary:rgba(20, 86, 224, 0.68);--md-sys-color-on-primary:#1456e0;--md-sys-color-primary-container:#1456e0;--md-switch-handle-height:19px;--md-switch-handle-width:18px;--md-sys-color-surface-container-highest:#9e9e9e;--md-sys-color-outline:#9e9e9e;--md-switch-pressed-handle-height:19px;--md-switch-pressed-handle-width:18px;--md-switch-handle-color:#fff;--md-sys-color-on-surface-variant:white;--selected-handle-height:19px;--selected-handle-width:18px;--_pressed-handle-height:19px;--_pressed-handle-width:18px;--md-switch-selected-handle-height:19px;--md-switch-selected-handle-width:18px;margin:11px 8px 1px 0}.list{position:relative}`,triggerKeys=[" ","Enter"];let IxGridColumnFilter=class extends LitElement{constructor(){super(...arguments),this.columns=[],this.localStorageID=void 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)}initializeLocalStorage(){if(this.localStorageID){var e=localStorage.getItem(this.localStorageID);if(e){const i=JSON.parse(e);this.columns.forEach((e,t)=>{i.includes(e.name)&&(this.columns[t].hidden=!0)})}this.dispatchUpdate()}}toggleColumn(e){this.columns[e].hidden=!this.columns[e].hidden,this.disabledColumns=this.columns.filter(e=>e.hidden).map(e=>e.name),void 0!==this.localStorageID&&localStorage.setItem(this.localStorageID,JSON.stringify(this.disabledColumns)),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.disabledColumns=this.columns.filter(e=>e.hidden).map(e=>e.name),void 0!==this.localStorageID&&localStorage.setItem(this.localStorageID,JSON.stringify(this.disabledColumns)),this.dispatchUpdate()}dispatchUpdate(e=this.columns){this.dispatchEvent(new CustomEvent("columnFilter",{detail:{columns:e},bubbles:!0,composed:!0}))}dragstart(e){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.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){var e=e.target;e.classList.contains("drag-target")&&(e=Number(e.getAttribute("data-id")),this.dragEvent.targetId=e)}render(){return html`<div class="grid-menu"><span @click="${()=>{this.isDropdownVisible=!0}}" @keyDown="${e=>{triggerKeys.includes(e.key)&&(this.isDropdownVisible=!0)}}" class="list list-dropdown"><ix-icon-button appearance="default" icon="list"></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,e=>e.name,(e,t)=>html`<div class="${e.hidden?"disabled":""}"><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><ix-icon class="draggable">drag_handle</ix-icon></label></div>`)}</div>`:nothing}</span></div>`}};IxGridColumnFilter.styles=[IxGridViewStyles,IxGridColumnFilterStyles],__decorate([property({type:Array})],IxGridColumnFilter.prototype,"columns",void 0),__decorate([property({type:String})],IxGridColumnFilter.prototype,"localStorageID",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);const IxGridRowFilterStyles=css`.slot-wrap{display:flex}.slot-wrap ix-icon{--ix-icon-font-size:24px;color:#1456e0;margin-right:5px}.grid-menu ix-button .filter{font-family:'Red Hat Display',sans-serif;font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px;margin-top:2px}.filter-form{white-space:nowrap;padding:9px;font-family:'Open Sans',sans-serif;color:#5d6d82}.filter-form-column{display:inline-block;vertical-align:middle}.filter-remove span{margin-right:0;color:#5d6d82}.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}.filter-form input,.filter-form option,.filter-form select{border-radius:0;cursor:pointer;letter-spacing:1.44px;line-height:1.4375em;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;font-size:16px;box-sizing:border-box;cursor:text;user-select:none;color:currentcolor;-webkit-tap-highlight-color:transparent;display:block;min-width:0;width:100%;font-family:'Open Sans',sans-serif;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:'Open Sans',sans-serif}.form-group label{font-family:'Open Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:1.4375em;letter-spacing:.44px;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:'Open Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:1.4375em;letter-spacing:.44px;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:'Open Sans',sans-serif}option{font-weight:400;display:block;min-height:1.2em;padding:0 2px 1px;white-space:nowrap}.add-filter-button .add{margin-right:0;margin-left:-6px}.filter-footer{margin-top:auto;display:flex;align-items:left;padding:0;font-family:'Red Hat Display',sans-serif;font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px;text-transform:uppercase;width:100%}.filter-footer button{align-items:center!important;margin-left:0}.filter-footer .add{display:inline-flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;outline:0;border:0;margin:0;cursor:pointer;user-select:none;vertical-align:middle;appearance:none;text-decoration:none;font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px;transition:background-color 250ms cubic-bezier(.4,0,.2,1) 0s,box-shadow 250ms cubic-bezier(.4,0,.2,1) 0s,border-color 250ms cubic-bezier(.4,0,.2,1) 0s,color 250ms cubic-bezier(.4,0,.2,1) 0s;box-shadow:none;min-height:36px}.filter-footer .clear{margin-left:auto!important}.form-group .close{user-select:none;width:1em;height:1em;display:inline-block;fill:currentcolor;flex-shrink:0;transition:fill .2s cubic-bezier(.4,0,.2,1) 0s;font-size:1.25rem;font-weight:lighter}.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:99;display:flex;align-items:center;justify-content:center;font-size:.75rem;padding:0;height:16px;width:16px;border-radius:50%;background-color:#1456e0;color:#fff}.filterlist{width:40px}.filterColumnField{width:150px}.filterValueField{width:190px}.filterOperatorField{width:120px}.add-filter-button.disabled{opacity:.5;cursor:not-allowed}select:hover{cursor:pointer}input:hover{cursor:text}.tooltip-container{position:relative;display:inline-block}.tool-tip{color:#fff;overflow-wrap:break-word;border-radius:3px;background-color:#071454;padding:5px 8px;font-family:'Open Sans',sans-serif;font-weight:400;font-style:normal;font-size:12px;line-height:16px;letter-spacing:.4px;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;color:#fff;overflow-wrap:break-word;border-radius:3px;font-family:'Open Sans',sans-serif;font-weight:400;font-style:normal;font-size:12px;line-height:16px;letter-spacing:.4px;max-width:250px;min-width:200px;white-space:wrap}.tool-tip p{margin:0;padding:0;font-family:'Open Sans',sans-serif;font-weight:400;font-style:normal;font-size:12px;line-height:16px;letter-spacing:.4px}.add-filter-button{display:inline-flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;outline:0;border:0;margin:0;cursor:pointer;user-select:none;vertical-align:middle;appearance:none;text-decoration:none;font-family:'Red Hat Display',sans-serif;font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px;text-transform:uppercase;color:#fff;min-width:64px;transition:background-color 250ms cubic-bezier(.4,0,.2,1) 0s,box-shadow 250ms cubic-bezier(.4,0,.2,1) 0s,border-color 250ms cubic-bezier(.4,0,.2,1) 0s,color 250ms cubic-bezier(.4,0,.2,1) 0s;box-shadow:none;min-height:36px;border-radius:100px;background-color:unset}.add-filter-button:disabled,.clear:disabled{opacity:.25;cursor:not-allowed}button{-webkit-box-align:center;-webkit-box-pack:center;justify-content:center;position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;outline:0;border:0;margin:0;cursor:pointer;user-select:none;vertical-align:middle;appearance:none;text-decoration:none;font-family:'Red Hat Display',sans-serif;font-weight:700;font-style:normal;font-size:14px;line-height:18.52px;letter-spacing:1.25px;text-transform:uppercase;color:#fff;min-width:64px;transition:background-color 250ms cubic-bezier(.4,0,.2,1) 0s,box-shadow 250ms cubic-bezier(.4,0,.2,1) 0s,border-color 250ms cubic-bezier(.4,0,.2,1) 0s,color 250ms cubic-bezier(.4,0,.2,1) 0s;box-shadow:none;min-height:36px;border-radius:100px;background-color:unset}ix-button.filter-button{padding-inline:0}.grid-menu ix-button{align-items:center;display:flex}`;let IxGridRowFilter=class extends LitElement{constructor(){super(...arguments),this.columns=[],this.isDropdownVisible=!1,this.filters=[],this.filterableColumns=[],this.filterColumns=[],this.activeFilters=[],this.mapSelect=!1,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.filters=this.parseFilterQueryString(),this.filters.length||this.addFilter(),this.updateActiveFilters(),this.dispatchUpdate()}get filterNames(){return this.filters.map(e=>e.columnField)}get unselectedFilters(){return this.filterColumns.filter(e=>!this.filterNames.includes(e))}parseFilterQueryString(){var e,t,i=[];for([e,t]of new URLSearchParams(window.location.search))this.filterColumns.includes(e)&&i.push({columnField:e,operatorValue:"contains",value:t});return i}dispatchUpdate(){this.dispatchEvent(new CustomEvent("rowFilter",{detail:{filters:this.filters.filter(e=>3<=e.value.length)},bubbles:!0,composed:!0}))}addFilter(){var e=this.filterColumns.find(e=>!this.filterNames.includes(e))||"";this.filters=[...this.filters,{columnField:e,operatorValue:"contains",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){t=t.target.value;this.filters[e].columnField=t,this.filters=[...this.filters],3<=this.filters[e].value.length&&this.dispatchUpdate()}onfilterValueChange(e,t){var i=this.filters[e].value.length,t=t.target["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}renderFilterInput(t,i){const o=[t.columnField,...this.unselectedFilters];var e=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" @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: ${e.map(e=>`value=${e.name}, selected=${e.name===t.columnField}, ${e.header}
|
|
4
4
|
`)}">Columns</label> <select @change="${e=>this.onfilterColumnChange(i,e)}" .value="${t.columnField}" data-v="${t.columnField}">${e.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: ${e.map(e=>`value=${e.name}, selected=${e.name===t.columnField}, ${e.header}
|
|
5
|
-
`)}"><span>Columns</span> <select @change="${e=>this.onfilterColumnChange(i,e)}" .value="${t.columnField}" data-v="${t.columnField}">${repeat(e,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><option select="select">contains</option></select></label></div></div><div class="filter-form-column filter-form-column-border filterValueField"><div class="filter-form-group"><label class="form-group-value-label"><span>Value</span> <input placeholder="Filter value" @input="${e=>this.onfilterValueChange(i,e)}" .value="${t.value}"></label></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"><button class="add-filter-button" @click="${()=>this.addFilter()}" ?disabled="${e}"><ix-icon-button icon="add"></ix-icon-button><span class="add">ADD FILTER</span></button> <button class="clear" @click="${()=>this.clearFilters()}" ?disabled="${0===this.activeFilters.length}"><span class="add">CLEAR ALL</span></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 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>`}};IxGridRowFilter.styles=[IxGridViewStyles,IxGridRowFilterStyles],__decorate([property({type:Array})],IxGridRowFilter.prototype,"columns",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),IxGridRowFilter=__decorate([customElement("ix-grid-row-filter")],IxGridRowFilter);class IxGrid extends LitElement{constructor(){super(...arguments),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=1,this.pageSize=10,this.pageSizes=[5,10,25,100],this.recordCount=0,this.localStorageID=void 0,this.showDownload=!0,this.addParamsToURL=!0,this.filters=[],this._columns=[],this.isLoading=!1,this.isExpanded=!1,this.renderColumnHeader=e=>html`<div @click="${()=>e.sortable&&this.handleSort(e.name)}" @keyDown="${()=>e.sortable&&this.handleSort(e.name)}" class="header">${e.header} ${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.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._columns}" localStorageID="${ifDefined(this.localStorageID)}" @columnFilter="${e=>{e.detail.columns.forEach((e,t)=>{this._columns[t].hidden=e.hidden}),this.updatePage()}}" @reorderColumns="${this.reorderColumnsFromFilter}"></ix-grid-column-filter>${this.showDownload?html`<ix-grid-download-menu></ix-grid-download-menu>`:nothing}<ix-grid-row-filter .columns="${this._columns}" @rowFilter="${e=>{this.filters=e.detail.filters,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-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`<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>`}get columnNames(){return this._columns.map(e=>e.name)}async updatePage(){var e,t,i=this.filters.reduce((e,{columnField:t,value:i})=>({...e,[t]:i}),{});this.addParamsToURL&&(t={sort:this.sortedColumn,order:this.sortDirection,page:this.page.toString(),size:this.pageSize.toString(),...i},e=new URL(window.location.href),t=new URLSearchParams(t),e.search=t.toString(),window.history.replaceState(null,"",e.toString())),this.dispatchEvent(new CustomEvent("change",{detail:{columnName:this.sortedColumn,sortOrder:this.sortDirection,page:this.page,pageSize:this.pageSize,filters:i},bubbles:!0,composed:!0}))}handleSort(e=""){this.sortedColumn!==e?this.sortDirection="asc":this.sortDirection="asc"===this.sortDirection?"desc":"asc",this.sortedColumn=e,this.updatePage()}connectedCallback(){super.connectedCallback(),this._columns=this.columns}async reorderColumnsFromTable(){var e=Array.from((null==(e=null==(e=this.grid)?void 0:e.shadowRoot)?void 0:e.querySelectorAll("th"))||[]);if(e.length){const i=e.map((e,t)=>({id:t,flexPosition:Number(e.style.order)})).sort((e,t)=>e.flexPosition-t.flexPosition).map(e=>e.id);e.forEach((e,t)=>{this._columns[t].width=e.style.width}),i.every((e,t)=>0===t||e>i[t-1])||(e=i.map(e=>this._columns[e]),this._columns=[...e],this.isLoading=!0,await this.updateComplete,this.isLoading=!1)}}async reorderColumnsFromFilter(e){this._columns=[...e.detail.reorderedColumns],this.isLoading=!0,await this.updateComplete,this.isLoading=!1}render(){var e;return html`<div class="${"grid-container "+(this.isLoading?"loading":"")}">${this.hideHeader?nothing:this.renderHeader()} ${this.isLoading?nothing:html`<vaadin-grid .items="${0<this.rowLimit&&!this.isExpanded?this.rows.slice(0,this.rowLimit):this.rows}" all-rows-visible column-reordering-allowed theme="no-border" @mouseup="${this.reorderColumnsFromTable}">${null==(e=this._columns)?void 0:e.map(e=>e.name?html`<vaadin-grid-column ${columnHeaderRenderer(()=>this.renderColumnHeader(e),this.sortDirection)} ${columnBodyRenderer(e.bodyRenderer,[])} resizable width="${ifDefined(e.width)}" ?hidden="${e.hidden}" ?frozen-to-end="${e.frozenToEnd}"></vaadin-grid-column>`:nothing)}</vaadin-grid>`} ${0<this.rowLimit?this.renderRowLimitControls():this.renderPaginationControls()}</div>`}}IxGrid.styles=[IxGridViewStyles],__decorate([query("vaadin-grid")],IxGrid.prototype,"grid",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,attribute:"add-params-to-url"})],IxGrid.prototype,"addParamsToURL",void 0),__decorate([state()],IxGrid.prototype,"filters",void 0),__decorate([state()],IxGrid.prototype,"_columns",void 0),__decorate([state()],IxGrid.prototype,"isLoading",void 0),__decorate([state()],IxGrid.prototype,"isExpanded",void 0),window.customElements.define("ix-grid",IxGrid);
|
|
5
|
+
`)}"><span>Columns</span> <select @change="${e=>this.onfilterColumnChange(i,e)}" .value="${t.columnField}" data-v="${t.columnField}">${repeat(e,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><option select="select">contains</option></select></label></div></div><div class="filter-form-column filter-form-column-border filterValueField"><div class="filter-form-group"><label class="form-group-value-label"><span>Value</span> <input placeholder="Filter value" @input="${e=>this.onfilterValueChange(i,e)}" .value="${t.value}"></label></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"><button class="add-filter-button" @click="${()=>this.addFilter()}" ?disabled="${e}"><ix-icon-button icon="add"></ix-icon-button><span class="add">ADD FILTER</span></button> <button class="clear" @click="${()=>this.clearFilters()}" ?disabled="${0===this.activeFilters.length}"><span class="add">CLEAR ALL</span></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 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>`}};IxGridRowFilter.styles=[IxGridViewStyles,IxGridRowFilterStyles],__decorate([property({type:Array})],IxGridRowFilter.prototype,"columns",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),IxGridRowFilter=__decorate([customElement("ix-grid-row-filter")],IxGridRowFilter);class IxGrid extends LitElement{constructor(){super(...arguments),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=1,this.pageSize=10,this.pageSizes=[5,10,25,100],this.recordCount=0,this.localStorageID=void 0,this.showDownload=!0,this.addParamsToURL=!0,this.filters=[],this._columns=[],this.isLoading=!1,this.isExpanded=!1,this.renderColumnHeader=e=>html`<div @click="${()=>e.sortable&&this.handleSort(e.name)}" @keyDown="${()=>e.sortable&&this.handleSort(e.name)}" class="header">${e.header} ${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.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._columns}" localStorageID="${ifDefined(this.localStorageID)}" @columnFilter="${e=>{e.detail.columns.forEach((e,t)=>{this._columns[t].hidden=e.hidden}),this.updatePage()}}" @reorderColumns="${this.reorderColumnsFromFilter}"></ix-grid-column-filter>${this.showDownload?html`<ix-grid-download-menu></ix-grid-download-menu>`:nothing}<ix-grid-row-filter .columns="${this._columns}" @rowFilter="${e=>{this.filters=e.detail.filters,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-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`<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>`}get columnNames(){return this._columns.map(e=>e.name)}async updatePage(){var e,t,i=this.filters.reduce((e,{columnField:t,value:i})=>({...e,[t]:i}),{});this.addParamsToURL&&(t={sort:this.sortedColumn,order:this.sortDirection,page:this.page.toString(),size:this.pageSize.toString(),...i},e=new URL(window.location.href),t=new URLSearchParams(t),e.search=t.toString(),window.history.replaceState(null,"",e.toString())),this.dispatchEvent(new CustomEvent("change",{detail:{columnName:this.sortedColumn,sortOrder:this.sortDirection,page:this.page,pageSize:this.pageSize,filters:i},bubbles:!0,composed:!0}))}handleSort(e=""){this.sortedColumn!==e?this.sortDirection="asc":this.sortDirection="asc"===this.sortDirection?"desc":"asc",this.sortedColumn=e,this.updatePage()}connectedCallback(){super.connectedCallback(),this._columns=this.columns}async reorderColumnsFromTable(){var e=Array.from((null==(e=null==(e=this.grid)?void 0:e.shadowRoot)?void 0:e.querySelectorAll("th"))||[]);if(e.length){const i=e.map((e,t)=>({id:t,flexPosition:Number(e.style.order)})).sort((e,t)=>e.flexPosition-t.flexPosition).map(e=>e.id);e.forEach((e,t)=>{this._columns[t].width=e.style.width}),i.every((e,t)=>0===t||e>i[t-1])||(e=i.map(e=>this._columns[e]),this._columns=[...e],this.isLoading=!0,await this.updateComplete,this.isLoading=!1)}}async reorderColumnsFromFilter(e){this._columns=[...e.detail.reorderedColumns],this.isLoading=!0,await this.updateComplete,this.isLoading=!1}render(){var e;return html`<div class="${"grid-container "+(this.isLoading?"loading":"")}">${this.hideHeader?nothing:this.renderHeader()} ${this.isLoading?nothing:html`<vaadin-grid .items="${0<this.rowLimit&&!this.isExpanded?this.rows.slice(0,this.rowLimit):this.rows}" all-rows-visible column-reordering-allowed theme="no-border" @mouseup="${this.reorderColumnsFromTable}">${this._columns.some(e=>!e.hidden)?null==(e=this._columns)?void 0:e.map(e=>e.name?html`<vaadin-grid-column ${columnHeaderRenderer(()=>this.renderColumnHeader(e),this.sortDirection)} ${columnBodyRenderer(e.bodyRenderer,[])} resizable width="${ifDefined(e.width)}" ?hidden="${e.hidden}" ?frozen-to-end="${e.frozenToEnd}"></vaadin-grid-column>`:nothing):html`<vaadin-grid-column></vaadin-grid-column>`}</vaadin-grid>`} ${0<this.rowLimit?this.renderRowLimitControls():this.renderPaginationControls()}</div>`}}IxGrid.styles=[IxGridViewStyles],__decorate([query("vaadin-grid")],IxGrid.prototype,"grid",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,attribute:"add-params-to-url"})],IxGrid.prototype,"addParamsToURL",void 0),__decorate([state()],IxGrid.prototype,"filters",void 0),__decorate([state()],IxGrid.prototype,"_columns",void 0),__decorate([state()],IxGrid.prototype,"isLoading",void 0),__decorate([state()],IxGrid.prototype,"isExpanded",void 0),window.customElements.define("ix-grid",IxGrid);
|
|
@@ -16,14 +16,17 @@ const columns = [
|
|
|
16
16
|
{
|
|
17
17
|
name: 'one',
|
|
18
18
|
header: 'one',
|
|
19
|
+
bodyRenderer: row => html ` <span>${row.name}</span>`,
|
|
19
20
|
},
|
|
20
21
|
{
|
|
21
22
|
name: 'two',
|
|
22
23
|
header: 'one',
|
|
24
|
+
bodyRenderer: row => html ` <span>${row.name}</span>`,
|
|
23
25
|
},
|
|
24
26
|
{
|
|
25
27
|
name: 'three',
|
|
26
28
|
header: 'one',
|
|
29
|
+
bodyRenderer: row => html ` <span>${row.name}</span>`,
|
|
27
30
|
},
|
|
28
31
|
];
|
|
29
32
|
describe('IxGrid', () => {
|
|
@@ -33,8 +36,8 @@ describe('IxGrid', () => {
|
|
|
33
36
|
});
|
|
34
37
|
it('renders the correct number of rows', async () => {
|
|
35
38
|
const el = await fixture(html `<ix-grid
|
|
36
|
-
columns=${columns}
|
|
37
|
-
rows=${rows}
|
|
39
|
+
.columns=${columns}
|
|
40
|
+
.rows=${rows}
|
|
38
41
|
></ix-grid>`);
|
|
39
42
|
expect(rows.length).to.equal(3);
|
|
40
43
|
expect(el).to.not.be.null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ix-grid.test.js","sourceRoot":"","sources":["../../src/test/ix-grid.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,eAAe,CAAC;AAEvB,MAAM,IAAI,GAAG;IACX;QACE,IAAI,EAAE,KAAK;KACZ;IACD;QACE,IAAI,EAAE,KAAK;KACZ;IACD;QACE,IAAI,EAAE,OAAO;KACd;CACF,CAAC;AAEF,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"ix-grid.test.js","sourceRoot":"","sources":["../../src/test/ix-grid.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,eAAe,CAAC;AAEvB,MAAM,IAAI,GAAG;IACX;QACE,IAAI,EAAE,KAAK;KACZ;IACD;QACE,IAAI,EAAE,KAAK;KACZ;IACD;QACE,IAAI,EAAE,OAAO;KACd;CACF,CAAC;AAEF,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAA,UAAU,GAAG,CAAC,IAAI,SAAS;KACrD;IACD;QACE,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAA,UAAU,GAAG,CAAC,IAAI,SAAS;KACrD;IACD;QACE,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAA,UAAU,GAAG,CAAC,IAAI,SAAS;KACrD;CACF,CAAC;AAEF,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,EAAE,GAAG,MAAM,OAAO,CAAS,IAAI,CAAA,qBAAqB,CAAC,CAAC;QAE5D,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAS,IAAI,CAAA;iBACxB,OAAO;cACV,IAAI;gBACF,CAAC,CAAC;QAEd,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEhC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\nimport { fixture, expect } from '@open-wc/testing';\nimport { IxGrid } from '../IxGrid.js';\nimport '../ix-grid.js';\n\nconst rows = [\n {\n name: 'one',\n },\n {\n name: 'two',\n },\n {\n name: 'three',\n },\n];\n\nconst columns = [\n {\n name: 'one',\n header: 'one',\n bodyRenderer: row => html` <span>${row.name}</span>`,\n },\n {\n name: 'two',\n header: 'one',\n bodyRenderer: row => html` <span>${row.name}</span>`,\n },\n {\n name: 'three',\n header: 'one',\n bodyRenderer: row => html` <span>${row.name}</span>`,\n },\n];\n\ndescribe('IxGrid', () => {\n it('renders a grid', async () => {\n const el = await fixture<IxGrid>(html`<ix-grid></ix-grid>`);\n\n expect(el).to.not.be.null;\n });\n\n it('renders the correct number of rows', async () => {\n const el = await fixture<IxGrid>(html`<ix-grid\n .columns=${columns}\n .rows=${rows}\n ></ix-grid>`);\n\n expect(rows.length).to.equal(3);\n\n expect(el).to.not.be.null;\n });\n});\n"]}
|
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.0.
|
|
6
|
+
"version": "1.0.36",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"prettier --write"
|
|
103
103
|
]
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "0b93fae7b231a1215f8c27e2b73ec82f55edfacc"
|
|
106
106
|
}
|
package/src/IxGrid.ts
CHANGED
|
@@ -263,21 +263,23 @@ export class IxGrid extends LitElement {
|
|
|
263
263
|
theme="no-border"
|
|
264
264
|
@mouseup=${this.reorderColumnsFromTable}
|
|
265
265
|
>
|
|
266
|
-
${this._columns
|
|
267
|
-
column
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
266
|
+
${this._columns.some(col => !col.hidden)
|
|
267
|
+
? this._columns?.map((column: Column) =>
|
|
268
|
+
column.name
|
|
269
|
+
? html`<vaadin-grid-column
|
|
270
|
+
${columnHeaderRenderer(
|
|
271
|
+
() => this.renderColumnHeader(column),
|
|
272
|
+
this.sortDirection
|
|
273
|
+
)}
|
|
274
|
+
${columnBodyRenderer(column.bodyRenderer, [])}
|
|
275
|
+
resizable
|
|
276
|
+
width=${ifDefined(column.width)}
|
|
277
|
+
?hidden=${column.hidden}
|
|
278
|
+
?frozen-to-end=${column.frozenToEnd}
|
|
279
|
+
></vaadin-grid-column>`
|
|
280
|
+
: nothing
|
|
281
|
+
)
|
|
282
|
+
: html`<vaadin-grid-column></vaadin-grid-column>`}
|
|
281
283
|
</vaadin-grid>`
|
|
282
284
|
: nothing}
|
|
283
285
|
${this.rowLimit > 0
|
|
@@ -5,6 +5,7 @@ import '@digital-realty/ix-button';
|
|
|
5
5
|
|
|
6
6
|
export interface IGridNavButton {
|
|
7
7
|
path?: string;
|
|
8
|
+
selected?: boolean;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
onClick?: () => void;
|
|
10
11
|
text: string;
|
|
@@ -59,11 +60,18 @@ export class IxGridNavigation extends LitElement {
|
|
|
59
60
|
`;
|
|
60
61
|
|
|
61
62
|
// eslint-disable-next-line class-methods-use-this
|
|
62
|
-
renderButton = ({
|
|
63
|
+
renderButton = ({
|
|
64
|
+
path,
|
|
65
|
+
text,
|
|
66
|
+
onClick,
|
|
67
|
+
disabled,
|
|
68
|
+
selected,
|
|
69
|
+
}: IGridNavButton) =>
|
|
63
70
|
html`
|
|
64
71
|
<ix-button
|
|
65
72
|
?disabled=${disabled}
|
|
66
|
-
|
|
73
|
+
appearance=${selected ? 'filled' : 'text'}
|
|
74
|
+
href=${ifDefined(selected ? undefined : path)}
|
|
67
75
|
@click=${onClick}
|
|
68
76
|
class="button"
|
|
69
77
|
><div class="button-text">${text}</div></ix-button
|
package/src/test/ix-grid.test.ts
CHANGED
|
@@ -19,14 +19,17 @@ const columns = [
|
|
|
19
19
|
{
|
|
20
20
|
name: 'one',
|
|
21
21
|
header: 'one',
|
|
22
|
+
bodyRenderer: row => html` <span>${row.name}</span>`,
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
25
|
name: 'two',
|
|
25
26
|
header: 'one',
|
|
27
|
+
bodyRenderer: row => html` <span>${row.name}</span>`,
|
|
26
28
|
},
|
|
27
29
|
{
|
|
28
30
|
name: 'three',
|
|
29
31
|
header: 'one',
|
|
32
|
+
bodyRenderer: row => html` <span>${row.name}</span>`,
|
|
30
33
|
},
|
|
31
34
|
];
|
|
32
35
|
|
|
@@ -39,8 +42,8 @@ describe('IxGrid', () => {
|
|
|
39
42
|
|
|
40
43
|
it('renders the correct number of rows', async () => {
|
|
41
44
|
const el = await fixture<IxGrid>(html`<ix-grid
|
|
42
|
-
columns=${columns}
|
|
43
|
-
rows=${rows}
|
|
45
|
+
.columns=${columns}
|
|
46
|
+
.rows=${rows}
|
|
44
47
|
></ix-grid>`);
|
|
45
48
|
|
|
46
49
|
expect(rows.length).to.equal(3);
|