@digital-realty/ix-grid 1.0.49-alpha.0 → 1.0.49-alpha.2

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.
Files changed (66) hide show
  1. package/dist/IxGrid.d.ts +74 -74
  2. package/dist/IxGrid.js +280 -280
  3. package/dist/IxGridNav.d.ts +2 -0
  4. package/dist/IxGridNav.js +9 -0
  5. package/dist/IxGridNav.js.map +1 -0
  6. package/dist/components/IxGridColumnFilter.d.ts +29 -29
  7. package/dist/components/IxGridColumnFilter.js +158 -158
  8. package/dist/components/IxGridDownloadMenu.d.ts +15 -15
  9. package/dist/components/IxGridDownloadMenu.js +51 -51
  10. package/dist/components/IxGridNav.d.ts +15 -15
  11. package/dist/components/IxGridNav.js +20 -20
  12. package/dist/components/IxGridNoRows.d.ts +10 -9
  13. package/dist/components/IxGridNoRows.js +49 -36
  14. package/dist/components/IxGridNoRows.js.map +1 -1
  15. package/dist/components/IxGridRowFilter.d.ts +41 -41
  16. package/dist/components/IxGridRowFilter.js +201 -201
  17. package/dist/components/IxPagination.d.ts +13 -13
  18. package/dist/components/IxPagination.js +59 -59
  19. package/dist/components/grid-column-filter-styles.d.ts +1 -1
  20. package/dist/components/grid-column-filter-styles.js +2 -2
  21. package/dist/components/grid-download-menu-styles.d.ts +1 -1
  22. package/dist/components/grid-download-menu-styles.js +2 -2
  23. package/dist/components/grid-row-filter-styles.d.ts +1 -1
  24. package/dist/components/grid-row-filter-styles.js +3 -3
  25. package/dist/components/grid-row-filter-styles.js.map +1 -1
  26. package/dist/components/ix-grid-nav.d.ts +1 -1
  27. package/dist/components/ix-grid-nav.js +2 -2
  28. package/dist/components/ix-grid-no-rows.d.ts +1 -1
  29. package/dist/components/ix-grid-no-rows.js +2 -2
  30. package/dist/components/pagination-styles.d.ts +1 -1
  31. package/dist/components/pagination-styles.js +2 -2
  32. package/dist/grid-view-styles.d.ts +1 -1
  33. package/dist/grid-view-styles.js +2 -2
  34. package/dist/index.d.ts +3 -3
  35. package/dist/index.js +3 -3
  36. package/dist/ix-grid-copy.d.ts +10 -10
  37. package/dist/ix-grid-copy.js +10 -10
  38. package/dist/ix-grid-nav.d.ts +1 -0
  39. package/dist/ix-grid-nav.js +3 -0
  40. package/dist/ix-grid-nav.js.map +1 -0
  41. package/dist/ix-grid-no-rows.d.ts +1 -0
  42. package/dist/ix-grid-no-rows.js +3 -0
  43. package/dist/ix-grid-no-rows.js.map +1 -0
  44. package/dist/ix-grid.d.ts +1 -1
  45. package/dist/ix-grid.js +2 -2
  46. package/dist/ix-grid.min.js +1 -1
  47. package/dist/models/IxGridDownloadMenuItemModel.d.ts +7 -7
  48. package/dist/models/IxGridDownloadMenuItemModel.js +1 -1
  49. package/dist/react/IxGridNav.d.ts +2 -2
  50. package/dist/react/IxGridNav.js +8 -8
  51. package/dist/test/ix-grid-column-filter.test.d.ts +1 -1
  52. package/dist/test/ix-grid-column-filter.test.js +35 -35
  53. package/dist/test/ix-grid-row-filter.test.d.ts +1 -1
  54. package/dist/test/ix-grid-row-filter.test.js +36 -36
  55. package/dist/test/ix-grid.test.d.ts +2 -2
  56. package/dist/test/ix-grid.test.js +49 -49
  57. package/dist/test/ix-grid.test.js.map +1 -1
  58. package/dist/test/ix-pagination.test.d.ts +1 -1
  59. package/dist/test/ix-pagination.test.js +21 -21
  60. package/package.json +9 -9
  61. package/src/{react/IxGridNav.ts → IxGridNav.ts} +1 -1
  62. package/src/components/IxGridNoRows.ts +22 -11
  63. package/src/components/grid-row-filter-styles.ts +1 -1
  64. package/src/{components/ix-grid-nav.ts → ix-grid-nav.ts} +1 -1
  65. package/src/ix-grid-no-rows.ts +3 -0
  66. package/src/test/ix-grid.test.ts +1 -1
@@ -1,43 +1,45 @@
1
- import { __decorate } from "tslib";
2
- import { LitElement, html, css } from 'lit';
3
- import { property } from 'lit/decorators.js';
4
- import '@digital-realty/ix-icon/ix-icon.js';
5
- export class IxGridNoRows extends LitElement {
6
- constructor() {
7
- super(...arguments);
8
- this.type = 'error';
9
- this.icon = 'error';
10
- this.message = 'No data to display';
11
- }
12
- render() {
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, css } from 'lit';
3
+ import { property } from 'lit/decorators.js';
4
+ import '@digital-realty/ix-icon/ix-icon.js';
5
+ export class IxGridNoRows extends LitElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.type = 'error';
9
+ this.icon = 'error';
10
+ this.message = 'No data to display';
11
+ this.iconFontSize = '3rem';
12
+ }
13
+ render() {
13
14
  return html `
14
- <div class="container">
15
+ <div class="container" style="--ix-icon-font-size: ${this.iconFontSize};">
15
16
  <ix-icon class="icon ${this.type}">${this.icon}</ix-icon>
16
17
  <h2 class="dlr-text-heading">${this.message}</h2>
17
18
  </div>
18
- `;
19
- }
20
- }
19
+ `;
20
+ }
21
+ }
21
22
  IxGridNoRows.styles = css `
22
23
  .container {
23
24
  display: flex;
24
- align-items: center;
25
25
  justify-content: center;
26
- padding: 1rem;
26
+ align-items: center;
27
27
  flex-direction: column;
28
+ text-align: center;
29
+ padding: 3.125rem 0;
28
30
  }
29
31
  .icon {
30
- margin: 4rem 0 0;
31
- width: var(--no-rows-icon-size, 48px);
32
- height: var(--no-rows-icon-size, 48px);
33
- --ix-icon-font-size: var(--no-rows-icon-size, 48px);
34
- --ix-icon-line-height: var(--no-rows-icon-line-height, 1);
32
+ user-select: none;
33
+ display: inline-block;
34
+ fill: currentcolor;
35
+ flex-shrink: 0;
36
+ font-size: 1.5rem;
37
+ color: rgb(255, 152, 0);
38
+ transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1);
35
39
  }
36
40
  .warning,
37
41
  .error {
38
42
  user-select: none;
39
- width: 48px;
40
- height: 44px;
41
43
  color: var(--clr-warning, #ff9800);
42
44
  }
43
45
  .critical {
@@ -47,16 +49,27 @@ IxGridNoRows.styles = css `
47
49
  font-family: var(--ix-font-family, 'Red Hat Display');
48
50
  }
49
51
  h2.dlr-text-heading {
50
- margin-top: 10px;
52
+ margin: 0.5rem 0 0;
53
+ font-family: 'Red Hat Display', sans-serif;
54
+ font-style: normal;
55
+ font-size: 1.5rem;
56
+ line-height: 2rem;
57
+ letter-spacing: 0em;
58
+ color: rgb(9, 34, 65);
59
+ text-align: center;
60
+ font-weight: 700;
51
61
  }
52
- `;
53
- __decorate([
54
- property({ type: String })
55
- ], IxGridNoRows.prototype, "type", void 0);
56
- __decorate([
57
- property({ type: String })
58
- ], IxGridNoRows.prototype, "icon", void 0);
59
- __decorate([
60
- property({ type: String })
61
- ], IxGridNoRows.prototype, "message", void 0);
62
+ `;
63
+ __decorate([
64
+ property({ type: String })
65
+ ], IxGridNoRows.prototype, "type", void 0);
66
+ __decorate([
67
+ property({ type: String })
68
+ ], IxGridNoRows.prototype, "icon", void 0);
69
+ __decorate([
70
+ property({ type: String })
71
+ ], IxGridNoRows.prototype, "message", void 0);
72
+ __decorate([
73
+ property({ type: String })
74
+ ], IxGridNoRows.prototype, "iconFontSize", void 0);
62
75
  //# sourceMappingURL=IxGridNoRows.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IxGridNoRows.js","sourceRoot":"","sources":["../../src/components/IxGridNoRows.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,oCAAoC,CAAC;AAE5C,MAAM,OAAO,YAAa,SAAQ,UAAU;IAA5C;;QAkC8B,SAAI,GAAiC,OAAO,CAAC;QAE7C,SAAI,GAAW,OAAO,CAAC;QAEvB,YAAO,GAAW,oBAAoB,CAAC;IAUrE,CAAC;IARC,MAAM;QACJ,OAAO,IAAI,CAAA;;+BAEgB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;uCACf,IAAI,CAAC,OAAO;;KAE9C,CAAC;IACJ,CAAC;;AA9CM,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC;AAE0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAwC","sourcesContent":["import { LitElement, html, css } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\n\nexport class IxGridNoRows extends LitElement {\n static styles = css`\n .container {\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 1rem;\n flex-direction: column;\n }\n .icon {\n margin: 4rem 0 0;\n width: var(--no-rows-icon-size, 48px);\n height: var(--no-rows-icon-size, 48px);\n --ix-icon-font-size: var(--no-rows-icon-size, 48px);\n --ix-icon-line-height: var(--no-rows-icon-line-height, 1);\n }\n .warning,\n .error {\n user-select: none;\n width: 48px;\n height: 44px;\n color: var(--clr-warning, #ff9800);\n }\n .critical {\n color: var(--clr-critical, #db0028);\n }\n h2 {\n font-family: var(--ix-font-family, 'Red Hat Display');\n }\n h2.dlr-text-heading {\n margin-top: 10px;\n }\n `;\n\n @property({ type: String }) type: 'warning' | 'info' | 'error' = 'error';\n\n @property({ type: String }) icon: string = 'error';\n\n @property({ type: String }) message: string = 'No data to display';\n\n render() {\n return html`\n <div class=\"container\">\n <ix-icon class=\"icon ${this.type}\">${this.icon}</ix-icon>\n <h2 class=\"dlr-text-heading\">${this.message}</h2>\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"IxGridNoRows.js","sourceRoot":"","sources":["../../src/components/IxGridNoRows.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,oCAAoC,CAAC;AAE5C,MAAM,OAAO,YAAa,SAAQ,UAAU;IAA5C;;QA2C8B,SAAI,GAAiC,OAAO,CAAC;QAE7C,SAAI,GAAW,OAAO,CAAC;QAEvB,YAAO,GAAW,oBAAoB,CAAC;QAEvC,iBAAY,GAAW,MAAM,CAAC;IAU5D,CAAC;IARC,MAAM;QACJ,OAAO,IAAI,CAAA;2DAC4C,IAAI,CAAC,YAAY;+BAC7C,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;uCACf,IAAI,CAAC,OAAO;;KAE9C,CAAC;IACJ,CAAC;;AAzDM,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwClB,CAAC;AAE0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAA8C;AAE7C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAwC;AAEvC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAA+B","sourcesContent":["import { LitElement, html, css } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport '@digital-realty/ix-icon/ix-icon.js';\n\nexport class IxGridNoRows extends LitElement {\n static styles = css`\n .container {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: column;\n text-align: center;\n padding: 3.125rem 0;\n }\n .icon {\n user-select: none;\n display: inline-block;\n fill: currentcolor;\n flex-shrink: 0;\n font-size: 1.5rem;\n color: rgb(255, 152, 0);\n transition: fill 200ms cubic-bezier(0.4, 0, 0.2, 1);\n }\n .warning,\n .error {\n user-select: none;\n color: var(--clr-warning, #ff9800);\n }\n .critical {\n color: var(--clr-critical, #db0028);\n }\n h2 {\n font-family: var(--ix-font-family, 'Red Hat Display');\n }\n h2.dlr-text-heading {\n margin: 0.5rem 0 0;\n font-family: 'Red Hat Display', sans-serif;\n font-style: normal;\n font-size: 1.5rem;\n line-height: 2rem;\n letter-spacing: 0em;\n color: rgb(9, 34, 65);\n text-align: center;\n font-weight: 700;\n }\n `;\n\n @property({ type: String }) type: 'warning' | 'info' | 'error' = 'error';\n\n @property({ type: String }) icon: string = 'error';\n\n @property({ type: String }) message: string = 'No data to display';\n\n @property({ type: String }) iconFontSize: string = '3rem';\n\n render() {\n return html`\n <div class=\"container\" style=\"--ix-icon-font-size: ${this.iconFontSize};\">\n <ix-icon class=\"icon ${this.type}\">${this.icon}</ix-icon>\n <h2 class=\"dlr-text-heading\">${this.message}</h2>\n </div>\n `;\n }\n}\n"]}
@@ -1,41 +1,41 @@
1
- import { LitElement } from 'lit';
2
- import '@digital-realty/ix-icon/ix-icon.js';
3
- import '@digital-realty/ix-icon-button/ix-icon-button.js';
4
- import '@digital-realty/ix-button/ix-button.js';
5
- import '@digital-realty/ix-select/ix-select.js';
6
- import type { Column } from '../IxGrid.js';
7
- export interface Filter {
8
- columnField: string;
9
- operatorValue: string;
10
- value: string;
11
- }
12
- export declare class IxGridRowFilter extends LitElement {
13
- static readonly styles: import("lit").CSSResult[];
14
- columns: Column[];
15
- private isDropdownVisible;
16
- private filters;
17
- private filterableColumns;
18
- private filterColumns;
19
- private activeFilters;
20
- private mapSelect;
21
- updateActiveFilters(): void;
22
- connectedCallback(): void;
23
- disconnectedCallback(): void;
24
- firstUpdated(): void;
25
- get filterNames(): string[];
26
- get unselectedFilters(): string[];
27
- closeOnOuterClick: (e: Event) => void;
28
- parseFilterQueryString(): Filter[];
29
- dispatchUpdate(): void;
30
- addFilter(): void;
31
- clearFilters(): void;
32
- removeFilter(index: number): void;
33
- private onfilterColumnChange;
34
- private onfilterOperatorChange;
35
- private onfilterValueChange;
36
- formatCamelCaseToEnglish(text: string): string;
37
- renderToolTip(): string | import("lit").TemplateResult<1>;
38
- renderFilterInput(value: Filter, index: number): import("lit").TemplateResult<1>;
39
- renderDropdown(): import("lit").TemplateResult<1>;
40
- render(): import("lit").TemplateResult<1>;
41
- }
1
+ import { LitElement } from 'lit';
2
+ import '@digital-realty/ix-icon/ix-icon.js';
3
+ import '@digital-realty/ix-icon-button/ix-icon-button.js';
4
+ import '@digital-realty/ix-button/ix-button.js';
5
+ import '@digital-realty/ix-select/ix-select.js';
6
+ import type { Column } from '../IxGrid.js';
7
+ export interface Filter {
8
+ columnField: string;
9
+ operatorValue: string;
10
+ value: string;
11
+ }
12
+ export declare class IxGridRowFilter extends LitElement {
13
+ static readonly styles: import("lit").CSSResult[];
14
+ columns: Column[];
15
+ private isDropdownVisible;
16
+ private filters;
17
+ private filterableColumns;
18
+ private filterColumns;
19
+ private activeFilters;
20
+ private mapSelect;
21
+ updateActiveFilters(): void;
22
+ connectedCallback(): void;
23
+ disconnectedCallback(): void;
24
+ firstUpdated(): void;
25
+ get filterNames(): string[];
26
+ get unselectedFilters(): string[];
27
+ closeOnOuterClick: (e: Event) => void;
28
+ parseFilterQueryString(): Filter[];
29
+ dispatchUpdate(): void;
30
+ addFilter(): void;
31
+ clearFilters(): void;
32
+ removeFilter(index: number): void;
33
+ private onfilterColumnChange;
34
+ private onfilterOperatorChange;
35
+ private onfilterValueChange;
36
+ formatCamelCaseToEnglish(text: string): string;
37
+ renderToolTip(): string | import("lit").TemplateResult<1>;
38
+ renderFilterInput(value: Filter, index: number): import("lit").TemplateResult<1>;
39
+ renderDropdown(): import("lit").TemplateResult<1>;
40
+ render(): import("lit").TemplateResult<1>;
41
+ }
@@ -1,161 +1,161 @@
1
- import { __decorate } from "tslib";
2
- import { LitElement, html, nothing } from 'lit';
3
- import { customElement, property, state } from 'lit/decorators.js';
4
- import { repeat } from 'lit/directives/repeat.js';
5
- import '@digital-realty/ix-icon/ix-icon.js';
6
- import '@digital-realty/ix-icon-button/ix-icon-button.js';
7
- import '@digital-realty/ix-button/ix-button.js';
8
- import '@digital-realty/ix-select/ix-select.js';
9
- import { IxGridViewStyles } from '../grid-view-styles.js';
10
- import { IxGridRowFilterStyles } from './grid-row-filter-styles.js';
11
- import { copy } from '../ix-grid-copy.js';
12
- let IxGridRowFilter = class IxGridRowFilter extends LitElement {
13
- constructor() {
14
- super(...arguments);
15
- this.columns = [];
16
- this.isDropdownVisible = false;
17
- this.filters = [];
18
- this.filterableColumns = [];
19
- this.filterColumns = [];
20
- this.activeFilters = [];
21
- this.mapSelect = false;
22
- this.closeOnOuterClick = (e) => {
23
- if (!e.composedPath().includes(this)) {
24
- this.isDropdownVisible = false;
25
- }
26
- };
27
- }
28
- updateActiveFilters() {
29
- this.activeFilters = this.filters.filter(filter => filter.value.length > 0);
30
- }
31
- connectedCallback() {
32
- super.connectedCallback();
33
- document.addEventListener('click', this.closeOnOuterClick);
34
- }
35
- disconnectedCallback() {
36
- super.disconnectedCallback();
37
- document.removeEventListener('click', this.closeOnOuterClick);
38
- }
39
- firstUpdated() {
40
- this.filterableColumns = this.columns.filter(column => column.filterable);
41
- this.filterColumns = this.filterableColumns.map(column => column.name);
42
- this.filters = this.parseFilterQueryString();
43
- if (!this.filters.length) {
44
- this.addFilter();
45
- }
46
- this.updateActiveFilters();
47
- this.dispatchUpdate();
48
- }
49
- get filterNames() {
50
- return this.filters.map(filter => filter.columnField);
51
- }
52
- get unselectedFilters() {
53
- return this.filterColumns.filter(f => !this.filterNames.includes(f));
54
- }
55
- parseFilterQueryString() {
56
- var _a;
57
- const params = new URLSearchParams(window.location.search);
58
- const filters = [];
59
- for (const [key, value] of params) {
60
- const filterOperators = ((_a = this.filterableColumns.find(c => c.name === key)) === null || _a === void 0 ? void 0 : _a.filterOperators) || ['contains'];
61
- if (this.filterColumns.includes(key)) {
62
- filters.push({
63
- columnField: key,
64
- operatorValue: filterOperators[0],
65
- value,
66
- });
67
- }
68
- }
69
- return filters;
70
- }
71
- dispatchUpdate() {
72
- this.dispatchEvent(new CustomEvent('rowFilter', {
73
- detail: {
74
- filters: this.filters.filter(filter => filter.value.length >= 3),
75
- },
76
- bubbles: true,
77
- composed: true,
78
- }));
79
- }
80
- addFilter() {
81
- var _a;
82
- const nextFilter = this.filterColumns.find(filter => !this.filterNames.includes(filter)) ||
83
- '';
84
- const filterOperators = ((_a = this.filterableColumns.find(c => c.name === nextFilter)) === null || _a === void 0 ? void 0 : _a.filterOperators) || ['contains'];
85
- this.filters = [
86
- ...this.filters,
87
- {
88
- columnField: nextFilter,
89
- operatorValue: filterOperators[0],
90
- value: '',
91
- },
92
- ];
93
- this.updateActiveFilters();
94
- }
95
- clearFilters() {
96
- this.filters = [];
97
- this.addFilter();
98
- this.dispatchUpdate();
99
- }
100
- removeFilter(index) {
101
- this.filters = this.filters.filter((_, i) => i !== index);
102
- this.dispatchUpdate();
103
- if (this.filters.length === 0) {
104
- this.isDropdownVisible = false;
105
- this.addFilter();
106
- }
107
- }
108
- onfilterColumnChange(index, e) {
109
- const selectedValue = e.target.value;
110
- this.filters[index].columnField = selectedValue;
111
- this.filters = [...this.filters];
112
- if (this.filters[index].value.length >= 3) {
113
- this.dispatchUpdate();
114
- }
115
- }
116
- onfilterOperatorChange(index, e) {
117
- const selectedValue = e.target.value;
118
- this.filters[index].operatorValue = selectedValue;
119
- this.filters = [...this.filters];
120
- if (this.filters[index].value.length >= 3) {
121
- this.dispatchUpdate();
122
- }
123
- }
124
- onfilterValueChange(index, e) {
125
- const oldValueLength = this.filters[index].value.length;
126
- const { value } = e.target;
127
- this.filters[index].value = value;
128
- const newValueLength = this.filters[index].value.length;
129
- if (this.filters[index].columnField.length > 0 &&
130
- (newValueLength >= 3 || newValueLength < oldValueLength)) {
131
- this.dispatchUpdate();
132
- }
133
- this.updateActiveFilters();
134
- }
135
- formatCamelCaseToEnglish(text) {
136
- const spaced = text.replace(/([A-Z])/g, ' $1').toLowerCase();
137
- const english = spaced.charAt(0).toUpperCase() + spaced.slice(1);
138
- return english;
139
- }
140
- renderToolTip() {
141
- if (this.isDropdownVisible) {
142
- return copy.hideFilters;
143
- }
144
- if (!this.activeFilters.length) {
145
- return copy.showFilters;
146
- }
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, nothing } from 'lit';
3
+ import { customElement, property, state } from 'lit/decorators.js';
4
+ import { repeat } from 'lit/directives/repeat.js';
5
+ import '@digital-realty/ix-icon/ix-icon.js';
6
+ import '@digital-realty/ix-icon-button/ix-icon-button.js';
7
+ import '@digital-realty/ix-button/ix-button.js';
8
+ import '@digital-realty/ix-select/ix-select.js';
9
+ import { IxGridViewStyles } from '../grid-view-styles.js';
10
+ import { IxGridRowFilterStyles } from './grid-row-filter-styles.js';
11
+ import { copy } from '../ix-grid-copy.js';
12
+ let IxGridRowFilter = class IxGridRowFilter extends LitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.columns = [];
16
+ this.isDropdownVisible = false;
17
+ this.filters = [];
18
+ this.filterableColumns = [];
19
+ this.filterColumns = [];
20
+ this.activeFilters = [];
21
+ this.mapSelect = false;
22
+ this.closeOnOuterClick = (e) => {
23
+ if (!e.composedPath().includes(this)) {
24
+ this.isDropdownVisible = false;
25
+ }
26
+ };
27
+ }
28
+ updateActiveFilters() {
29
+ this.activeFilters = this.filters.filter(filter => filter.value.length > 0);
30
+ }
31
+ connectedCallback() {
32
+ super.connectedCallback();
33
+ document.addEventListener('click', this.closeOnOuterClick);
34
+ }
35
+ disconnectedCallback() {
36
+ super.disconnectedCallback();
37
+ document.removeEventListener('click', this.closeOnOuterClick);
38
+ }
39
+ firstUpdated() {
40
+ this.filterableColumns = this.columns.filter(column => column.filterable);
41
+ this.filterColumns = this.filterableColumns.map(column => column.name);
42
+ this.filters = this.parseFilterQueryString();
43
+ if (!this.filters.length) {
44
+ this.addFilter();
45
+ }
46
+ this.updateActiveFilters();
47
+ this.dispatchUpdate();
48
+ }
49
+ get filterNames() {
50
+ return this.filters.map(filter => filter.columnField);
51
+ }
52
+ get unselectedFilters() {
53
+ return this.filterColumns.filter(f => !this.filterNames.includes(f));
54
+ }
55
+ parseFilterQueryString() {
56
+ var _a;
57
+ const params = new URLSearchParams(window.location.search);
58
+ const filters = [];
59
+ for (const [key, value] of params) {
60
+ const filterOperators = ((_a = this.filterableColumns.find(c => c.name === key)) === null || _a === void 0 ? void 0 : _a.filterOperators) || ['contains'];
61
+ if (this.filterColumns.includes(key)) {
62
+ filters.push({
63
+ columnField: key,
64
+ operatorValue: filterOperators[0],
65
+ value,
66
+ });
67
+ }
68
+ }
69
+ return filters;
70
+ }
71
+ dispatchUpdate() {
72
+ this.dispatchEvent(new CustomEvent('rowFilter', {
73
+ detail: {
74
+ filters: this.filters.filter(filter => filter.value.length >= 3),
75
+ },
76
+ bubbles: true,
77
+ composed: true,
78
+ }));
79
+ }
80
+ addFilter() {
81
+ var _a;
82
+ const nextFilter = this.filterColumns.find(filter => !this.filterNames.includes(filter)) ||
83
+ '';
84
+ const filterOperators = ((_a = this.filterableColumns.find(c => c.name === nextFilter)) === null || _a === void 0 ? void 0 : _a.filterOperators) || ['contains'];
85
+ this.filters = [
86
+ ...this.filters,
87
+ {
88
+ columnField: nextFilter,
89
+ operatorValue: filterOperators[0],
90
+ value: '',
91
+ },
92
+ ];
93
+ this.updateActiveFilters();
94
+ }
95
+ clearFilters() {
96
+ this.filters = [];
97
+ this.addFilter();
98
+ this.dispatchUpdate();
99
+ }
100
+ removeFilter(index) {
101
+ this.filters = this.filters.filter((_, i) => i !== index);
102
+ this.dispatchUpdate();
103
+ if (this.filters.length === 0) {
104
+ this.isDropdownVisible = false;
105
+ this.addFilter();
106
+ }
107
+ }
108
+ onfilterColumnChange(index, e) {
109
+ const selectedValue = e.target.value;
110
+ this.filters[index].columnField = selectedValue;
111
+ this.filters = [...this.filters];
112
+ if (this.filters[index].value.length >= 3) {
113
+ this.dispatchUpdate();
114
+ }
115
+ }
116
+ onfilterOperatorChange(index, e) {
117
+ const selectedValue = e.target.value;
118
+ this.filters[index].operatorValue = selectedValue;
119
+ this.filters = [...this.filters];
120
+ if (this.filters[index].value.length >= 3) {
121
+ this.dispatchUpdate();
122
+ }
123
+ }
124
+ onfilterValueChange(index, e) {
125
+ const oldValueLength = this.filters[index].value.length;
126
+ const { value } = e.target;
127
+ this.filters[index].value = value;
128
+ const newValueLength = this.filters[index].value.length;
129
+ if (this.filters[index].columnField.length > 0 &&
130
+ (newValueLength >= 3 || newValueLength < oldValueLength)) {
131
+ this.dispatchUpdate();
132
+ }
133
+ this.updateActiveFilters();
134
+ }
135
+ formatCamelCaseToEnglish(text) {
136
+ const spaced = text.replace(/([A-Z])/g, ' $1').toLowerCase();
137
+ const english = spaced.charAt(0).toUpperCase() + spaced.slice(1);
138
+ return english;
139
+ }
140
+ renderToolTip() {
141
+ if (this.isDropdownVisible) {
142
+ return copy.hideFilters;
143
+ }
144
+ if (!this.activeFilters.length) {
145
+ return copy.showFilters;
146
+ }
147
147
  return html ` <p>${this.activeFilters.length} ${copy.activeFilter}</p>
148
148
  <ul>
149
149
  ${this.activeFilters.map(filter => html `<li>
150
150
  ${this.formatCamelCaseToEnglish(filter.columnField)}
151
151
  ${filter.operatorValue} ${filter.value}
152
152
  </li>`)}
153
- </ul>`;
154
- }
155
- renderFilterInput(value, index) {
156
- var _a, _b;
157
- const options = [value.columnField, ...this.unselectedFilters];
158
- const filterOptions = this.filterableColumns.filter(column => options.includes(column.name));
153
+ </ul>`;
154
+ }
155
+ renderFilterInput(value, index) {
156
+ var _a, _b;
157
+ const options = [value.columnField, ...this.unselectedFilters];
158
+ const filterOptions = this.filterableColumns.filter(column => options.includes(column.name));
159
159
  return html `
160
160
  <div class="filter-form">
161
161
  <div class="filter-remove filter-form-column">
@@ -163,15 +163,15 @@ let IxGridRowFilter = class IxGridRowFilter extends LitElement {
163
163
  <ix-icon-button
164
164
  icon="close"
165
165
  @click=${() => this.removeFilter(index)}
166
- @keyDown=${(e) => {
167
- if (e.key === ' ' || e.key === 'Enter') {
168
- this.removeFilter(index);
169
- }
166
+ @keyDown=${(e) => {
167
+ if (e.key === ' ' || e.key === 'Enter') {
168
+ this.removeFilter(index);
169
+ }
170
170
  }}
171
171
  ></ix-icon-button>
172
172
  </div>
173
173
  </div>
174
- ${this.mapSelect
174
+ ${this.mapSelect
175
175
  ? html `<div
176
176
  class="filter-form-column filter-form-column-border filterColumnField"
177
177
  >
@@ -198,7 +198,7 @@ let IxGridRowFilter = class IxGridRowFilter extends LitElement {
198
198
  `)}
199
199
  </select>
200
200
  </div>
201
- </div>`
201
+ </div>`
202
202
  : nothing}
203
203
 
204
204
  <div
@@ -266,11 +266,11 @@ let IxGridRowFilter = class IxGridRowFilter extends LitElement {
266
266
  </div>
267
267
  </div>
268
268
  </div>
269
- `;
270
- }
271
- renderDropdown() {
272
- const disableAddButton = this.filters.length >= this.filterColumns.length ||
273
- this.activeFilters.length < this.filters.length;
269
+ `;
270
+ }
271
+ renderDropdown() {
272
+ const disableAddButton = this.filters.length >= this.filterColumns.length ||
273
+ this.activeFilters.length < this.filters.length;
274
274
  return html ` <div class="filter-dropdown-content">
275
275
  <div class="filter-body">
276
276
  ${this.filters.map((filter, index) => this.renderFilterInput(filter, index))}
@@ -292,24 +292,24 @@ let IxGridRowFilter = class IxGridRowFilter extends LitElement {
292
292
  <span class="add">CLEAR ALL</span>
293
293
  </button>
294
294
  </div>
295
- </div>`;
296
- }
297
- render() {
295
+ </div>`;
296
+ }
297
+ render() {
298
298
  return html ` <div class="grid-menu">
299
299
  <div class="filter-container tooltip-container">
300
- ${this.activeFilters.length > 0
300
+ ${this.activeFilters.length > 0
301
301
  ? html `<span class="filter-superscript"
302
302
  >${this.activeFilters.length}</span
303
- >`
303
+ >`
304
304
  : nothing}
305
305
  <ix-button
306
306
  appearance="text"
307
307
  class="filter_list filter-button"
308
- @click=${() => {
309
- this.isDropdownVisible = !this.isDropdownVisible;
308
+ @click=${() => {
309
+ this.isDropdownVisible = !this.isDropdownVisible;
310
310
  }}
311
- @keyDown=${() => {
312
- this.isDropdownVisible = !this.isDropdownVisible;
311
+ @keyDown=${() => {
312
+ this.isDropdownVisible = !this.isDropdownVisible;
313
313
  }}
314
314
  >
315
315
  <div class="slot-wrap">
@@ -322,33 +322,33 @@ let IxGridRowFilter = class IxGridRowFilter extends LitElement {
322
322
  <div class="tool-tip">${this.renderToolTip()}</div>
323
323
  ${this.isDropdownVisible ? this.renderDropdown() : nothing}
324
324
  </div>
325
- </div>`;
326
- }
327
- };
328
- IxGridRowFilter.styles = [IxGridViewStyles, IxGridRowFilterStyles];
329
- __decorate([
330
- property({ type: Array })
331
- ], IxGridRowFilter.prototype, "columns", void 0);
332
- __decorate([
333
- state()
334
- ], IxGridRowFilter.prototype, "isDropdownVisible", void 0);
335
- __decorate([
336
- state()
337
- ], IxGridRowFilter.prototype, "filters", void 0);
338
- __decorate([
339
- state()
340
- ], IxGridRowFilter.prototype, "filterableColumns", void 0);
341
- __decorate([
342
- state()
343
- ], IxGridRowFilter.prototype, "filterColumns", void 0);
344
- __decorate([
345
- state()
346
- ], IxGridRowFilter.prototype, "activeFilters", void 0);
347
- __decorate([
348
- state()
349
- ], IxGridRowFilter.prototype, "mapSelect", void 0);
350
- IxGridRowFilter = __decorate([
351
- customElement('ix-grid-row-filter')
352
- ], IxGridRowFilter);
353
- export { IxGridRowFilter };
325
+ </div>`;
326
+ }
327
+ };
328
+ IxGridRowFilter.styles = [IxGridViewStyles, IxGridRowFilterStyles];
329
+ __decorate([
330
+ property({ type: Array })
331
+ ], IxGridRowFilter.prototype, "columns", void 0);
332
+ __decorate([
333
+ state()
334
+ ], IxGridRowFilter.prototype, "isDropdownVisible", void 0);
335
+ __decorate([
336
+ state()
337
+ ], IxGridRowFilter.prototype, "filters", void 0);
338
+ __decorate([
339
+ state()
340
+ ], IxGridRowFilter.prototype, "filterableColumns", void 0);
341
+ __decorate([
342
+ state()
343
+ ], IxGridRowFilter.prototype, "filterColumns", void 0);
344
+ __decorate([
345
+ state()
346
+ ], IxGridRowFilter.prototype, "activeFilters", void 0);
347
+ __decorate([
348
+ state()
349
+ ], IxGridRowFilter.prototype, "mapSelect", void 0);
350
+ IxGridRowFilter = __decorate([
351
+ customElement('ix-grid-row-filter')
352
+ ], IxGridRowFilter);
353
+ export { IxGridRowFilter };
354
354
  //# sourceMappingURL=IxGridRowFilter.js.map