@3t-transform/threeteeui 0.1.21 → 0.1.22

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 (120) hide show
  1. package/dist/cjs/{index-b8a62ede.js → index-dc6cc829.js} +2 -88
  2. package/dist/cjs/loader.cjs.js +3 -4
  3. package/dist/cjs/tttx-button.cjs.entry.js +24 -24
  4. package/dist/cjs/tttx-filter.cjs.entry.js +152 -152
  5. package/dist/cjs/tttx-form.cjs.entry.js +363 -363
  6. package/dist/cjs/tttx-icon.cjs.entry.js +11 -11
  7. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +59 -59
  8. package/dist/cjs/tttx-list.cjs.entry.js +43 -43
  9. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
  10. package/dist/cjs/tttx-sorter.cjs.entry.js +112 -0
  11. package/dist/cjs/tttx-standalone-input.cjs.entry.js +60 -60
  12. package/dist/cjs/tttx-toolbar.cjs.entry.js +10 -10
  13. package/dist/cjs/tttx.cjs.js +3 -7
  14. package/dist/collection/collection-manifest.json +3 -2
  15. package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -110
  16. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
  17. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
  18. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
  19. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +109 -109
  20. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
  21. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
  22. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
  23. package/dist/collection/components/molecules/tttx-filter/tttx-filter.js +325 -325
  24. package/dist/collection/components/molecules/tttx-filter/tttx-filter.stories.js +89 -89
  25. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +35 -35
  26. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +58 -58
  27. package/dist/collection/components/molecules/tttx-form/tttx-form.js +364 -364
  28. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +127 -127
  29. package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
  30. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
  31. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.css +116 -0
  32. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.js +224 -0
  33. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.stories.js +47 -0
  34. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +627 -627
  35. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +157 -157
  36. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +44 -44
  37. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +14 -14
  38. package/dist/collection/components/palette.stories.js +7 -7
  39. package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
  40. package/dist/collection/icons.js +2838 -2838
  41. package/dist/collection/index.js +1 -1
  42. package/dist/collection/shared/domsanitiser.options.js +14 -14
  43. package/dist/components/index.d.ts +1 -9
  44. package/dist/components/index.js +2 -1
  45. package/dist/components/tttx-button.js +48 -48
  46. package/dist/components/tttx-filter.js +184 -184
  47. package/dist/components/tttx-form.js +380 -380
  48. package/dist/components/tttx-icon2.js +28 -28
  49. package/dist/components/tttx-keyvalue-block.js +76 -76
  50. package/dist/components/tttx-list.js +65 -65
  51. package/dist/components/tttx-loading-spinner.js +33 -33
  52. package/dist/components/tttx-sorter.d.ts +11 -0
  53. package/dist/components/tttx-sorter.js +141 -0
  54. package/dist/components/tttx-standalone-input.js +107 -107
  55. package/dist/components/tttx-toolbar.js +26 -26
  56. package/dist/esm/{index-e888a5f4.js → index-86faeaab.js} +3 -88
  57. package/dist/esm/loader.js +3 -4
  58. package/dist/esm/polyfills/core-js.js +0 -0
  59. package/dist/esm/polyfills/css-shim.js +1 -1
  60. package/dist/esm/polyfills/dom.js +0 -0
  61. package/dist/esm/polyfills/es5-html-element.js +0 -0
  62. package/dist/esm/polyfills/index.js +0 -0
  63. package/dist/esm/polyfills/system.js +0 -0
  64. package/dist/esm/tttx-button.entry.js +24 -24
  65. package/dist/esm/tttx-filter.entry.js +152 -152
  66. package/dist/esm/tttx-form.entry.js +363 -363
  67. package/dist/esm/tttx-icon.entry.js +11 -11
  68. package/dist/esm/tttx-keyvalue-block.entry.js +59 -59
  69. package/dist/esm/tttx-list.entry.js +43 -43
  70. package/dist/esm/tttx-loading-spinner.entry.js +16 -16
  71. package/dist/esm/tttx-sorter.entry.js +108 -0
  72. package/dist/esm/tttx-standalone-input.entry.js +60 -60
  73. package/dist/esm/tttx-toolbar.entry.js +10 -10
  74. package/dist/esm/tttx.js +3 -4
  75. package/dist/tttx/p-12fc0b16.entry.js +3 -0
  76. package/dist/tttx/p-52a47b7c.js +2 -0
  77. package/dist/tttx/p-5d9b6bc0.entry.js +1 -0
  78. package/dist/tttx/{p-41f5b296.entry.js → p-603f6ebe.entry.js} +1 -1
  79. package/dist/tttx/{p-e145951b.entry.js → p-72b4c98a.entry.js} +1 -1
  80. package/dist/tttx/{p-043f9b8a.entry.js → p-8f3badad.entry.js} +1 -1
  81. package/dist/tttx/{p-4cf3e1e0.entry.js → p-ae48fe5a.entry.js} +1 -1
  82. package/dist/tttx/{p-01f4628e.entry.js → p-bdb054b2.entry.js} +1 -1
  83. package/dist/tttx/{p-dc5c356b.entry.js → p-c72d1a03.entry.js} +1 -1
  84. package/dist/tttx/{p-96bbf1ed.entry.js → p-e25d5fe2.entry.js} +1 -1
  85. package/dist/tttx/{p-b3a03986.entry.js → p-f1d7eb35.entry.js} +1 -1
  86. package/dist/tttx/tttx.esm.js +1 -1
  87. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -10
  88. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
  89. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
  90. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
  91. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
  92. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
  93. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
  94. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
  95. package/dist/types/components/molecules/tttx-filter/tttx-filter.d.ts +37 -37
  96. package/dist/types/components/molecules/tttx-filter/tttx-filter.stories.d.ts +43 -43
  97. package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
  98. package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
  99. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +114 -114
  100. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +13 -13
  101. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +11 -11
  102. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +14 -14
  103. package/dist/types/components/molecules/tttx-sorter/interfaces.d.ts +9 -0
  104. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.d.ts +19 -0
  105. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.stories.d.ts +30 -0
  106. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +56 -56
  107. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +123 -123
  108. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -4
  109. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -13
  110. package/dist/types/components/palette.stories.d.ts +6 -6
  111. package/dist/types/components.d.ts +27 -0
  112. package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
  113. package/dist/types/icons.d.ts +2 -2
  114. package/dist/types/index.d.ts +1 -1
  115. package/dist/types/shared/domsanitiser.options.d.ts +10 -10
  116. package/dist/types/stencil-public-runtime.d.ts +3 -59
  117. package/loader/index.d.ts +0 -9
  118. package/package.json +1 -1
  119. package/dist/tttx/p-6dff6b5a.entry.js +0 -3
  120. package/dist/tttx/p-f764ffc4.js +0 -2
@@ -1,325 +1,325 @@
1
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
- import { h, Host } from '@stencil/core';
3
- export class TttxFilter {
4
- constructor() {
5
- this.filterKey = undefined;
6
- this.filterOptions = [
7
- { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
8
- { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
9
- { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
10
- ];
11
- this.showSelectAll = true;
12
- this.showSearchField = false;
13
- this.showOptionIcons = true;
14
- this.filterButtonStyle = 'list filter';
15
- this.filterHeader = 'Qualification status';
16
- this.showPopover = false;
17
- this.selectedFilters = this.filterOptions.map((filterOption) => filterOption.optionText);
18
- this.filterSearchTerm = '';
19
- this.displayedFilterSettings = this.filterOptions;
20
- this.allSelected = true;
21
- }
22
- emitFilterEvent() {
23
- this.filterChangeEvent.emit({
24
- selectedFilters: this.selectedFilters,
25
- filterKey: this.filterKey,
26
- allSelected: this.allSelected,
27
- });
28
- }
29
- onFilterButtonClick() {
30
- this.togglePopover();
31
- }
32
- onCloseButtonClick() {
33
- this.togglePopover();
34
- }
35
- onApplyFilterButtonClick() {
36
- this.emitFilterEvent();
37
- this.togglePopover();
38
- }
39
- onFilterOptionSelected(selectedOption) {
40
- this.allSelected = false;
41
- if (this.selectedFilters.includes(selectedOption)) {
42
- this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
43
- }
44
- else {
45
- this.selectedFilters = [...this.selectedFilters, selectedOption];
46
- }
47
- }
48
- togglePopover() {
49
- this.showPopover = !this.showPopover;
50
- // if(!this.showPopover) {
51
- // // this._focussedElementIndex = -1;
52
- // }
53
- }
54
- // Commented out keyboard interaction for now
55
- // @Listen('keyup')
56
- // handleKeyUp(event: KeyboardEvent) {
57
- // const keyboardEventValue = event.key;
58
- // if (document.activeElement.id != `filter__${this.filterKey}`) return;
59
- // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
60
- // if (this._focussedElementIndex == 0) {
61
- // this.onSelectAllClick()
62
- // } else {
63
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
64
- // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
65
- // }
66
- // return;
67
- // }
68
- // switch (keyboardEventValue) {
69
- // case 'Enter':
70
- // if(!this.showPopover) {
71
- // this.showPopover=true
72
- // } else {
73
- // this.emitFilterEvent()
74
- // }
75
- // break;
76
- // case 'Escape':
77
- // this.showPopover = false;
78
- // this._focussedElementIndex = -1;
79
- // break;
80
- // case 'ArrowDown':
81
- // this.showPopover = true;
82
- // if (this._focussedElementIndex == -1) {
83
- // this._focussedElementIndex = 0;
84
- // } else {
85
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
86
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
87
- // currentOption.blur();
88
- // // options[this._focussedElementIndex].focus();
89
- // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
90
- // }
91
- // break;
92
- // case 'ArrowUp':
93
- // if (this._focussedElementIndex == -1) {
94
- // this.showPopover = true;
95
- // this._focussedElementIndex = 0;
96
- // } else {
97
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
98
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
99
- // currentOption.blur();
100
- // // options[this._focussedElementIndex].focus();
101
- // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
102
- // }
103
- // break;
104
- // }
105
- // }
106
- handleFilterChange(event) {
107
- const target = event.target;
108
- this.filterSearchTerm = target.value;
109
- const filteredResults = this.filterOptions.filter((filterOption) => {
110
- const lowercaseOption = filterOption.optionText.toLowerCase();
111
- const filterTerm = this.filterSearchTerm.toLowerCase();
112
- return lowercaseOption.includes(filterTerm);
113
- });
114
- this.displayedFilterSettings = filteredResults;
115
- }
116
- onSelectAllClick() {
117
- this.allSelected = !this.allSelected;
118
- if (this.allSelected) {
119
- this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
120
- }
121
- else {
122
- this.selectedFilters = [];
123
- }
124
- }
125
- getFilterButtonClassName(buttonStyle) {
126
- switch (buttonStyle) {
127
- case 'table icon': {
128
- return '--table-icon';
129
- }
130
- case 'list icon': {
131
- return '--list-icon';
132
- }
133
- default: {
134
- return '';
135
- }
136
- }
137
- }
138
- render() {
139
- const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
140
- const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
141
- const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
142
- const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
143
- const filterKey = `filter__${this.filterKey}`;
144
- return (h(Host, { id: filterKey }, h("div", { class: 'filter-container' }, h("button", { class: `filter-button ${buttonStyleClassNameModifier}`, type: 'button', onClick: this.onFilterButtonClick.bind(this) }, h("tttx-icon", { icon: 'filter_list', class: 'filter-icon', color: 'black' }), "Filter"), this.showPopover && (h("div", { class: `filter-popover-container ${filterPopoverContainerClassNameModifier}` }, h("h4", { class: 'filter-header' }, this.filterHeader), h("hr", { class: 'popover-divider' }), this.showSearchField ? (h("div", { class: 'search-field-container' }, h("tttx-icon", { icon: 'search', class: 'search-icon' }), h("input", { type: 'text', class: 'search-input', placeholder: 'Search', value: this.filterSearchTerm, onInput: this.handleFilterChange.bind(this) }), h("hr", { class: 'popover-divider' }))) : (''), h("div", { class: 'filter-options-container' }, this.showSelectAll ? (h("div", { class: 'filter-option', tabIndex: -1, onClick: this.onSelectAllClick.bind(this) }, h("tttx-icon", { icon: selectAllCheckboxIcon, color: selectAllCheckboxColor, class: 'select-all-icon' }), h("label", { class: 'filter-label' }, "Select all"))) : (''), this.displayedFilterSettings.map((option) => {
145
- const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
146
- const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
147
- return h("div", { class: 'filter-option', tabIndex: -1, onClick: () => this.onFilterOptionSelected(option.optionText), key: option.optionText }, h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), this.showOptionIcons && h("tttx-icon", { icon: option.optionIcon, color: option.optionIconColor }), h("label", { class: 'filter-label' }, option.optionText));
148
- })), h("hr", { class: 'popover-divider' }), h("div", { class: 'filter-popover-button-container' }, h("button", { type: 'button', class: 'close-button', onClick: this.onCloseButtonClick.bind(this) }, "Close"), h("button", { type: 'button', class: 'apply-button', onClick: this.onApplyFilterButtonClick.bind(this) }, "Apply")))))));
149
- }
150
- static get is() { return "tttx-filter"; }
151
- static get encapsulation() { return "shadow"; }
152
- static get originalStyleUrls() {
153
- return {
154
- "$": ["tttx-filter.scss"]
155
- };
156
- }
157
- static get styleUrls() {
158
- return {
159
- "$": ["tttx-filter.css"]
160
- };
161
- }
162
- static get properties() {
163
- return {
164
- "filterKey": {
165
- "type": "string",
166
- "mutable": false,
167
- "complexType": {
168
- "original": "string",
169
- "resolved": "string",
170
- "references": {}
171
- },
172
- "required": false,
173
- "optional": false,
174
- "docs": {
175
- "tags": [],
176
- "text": ""
177
- },
178
- "attribute": "filter-key",
179
- "reflect": false
180
- },
181
- "filterOptions": {
182
- "type": "unknown",
183
- "mutable": false,
184
- "complexType": {
185
- "original": "FilterSettings[]",
186
- "resolved": "FilterSettings[]",
187
- "references": {
188
- "FilterSettings": {
189
- "location": "local"
190
- }
191
- }
192
- },
193
- "required": false,
194
- "optional": false,
195
- "docs": {
196
- "tags": [],
197
- "text": ""
198
- },
199
- "defaultValue": "[\n { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },\n { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },\n { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },\n ]"
200
- },
201
- "showSelectAll": {
202
- "type": "boolean",
203
- "mutable": false,
204
- "complexType": {
205
- "original": "boolean",
206
- "resolved": "boolean",
207
- "references": {}
208
- },
209
- "required": false,
210
- "optional": false,
211
- "docs": {
212
- "tags": [],
213
- "text": ""
214
- },
215
- "attribute": "show-select-all",
216
- "reflect": false,
217
- "defaultValue": "true"
218
- },
219
- "showSearchField": {
220
- "type": "boolean",
221
- "mutable": false,
222
- "complexType": {
223
- "original": "boolean",
224
- "resolved": "boolean",
225
- "references": {}
226
- },
227
- "required": false,
228
- "optional": false,
229
- "docs": {
230
- "tags": [],
231
- "text": ""
232
- },
233
- "attribute": "show-search-field",
234
- "reflect": false,
235
- "defaultValue": "false"
236
- },
237
- "showOptionIcons": {
238
- "type": "boolean",
239
- "mutable": false,
240
- "complexType": {
241
- "original": "boolean",
242
- "resolved": "boolean",
243
- "references": {}
244
- },
245
- "required": false,
246
- "optional": false,
247
- "docs": {
248
- "tags": [],
249
- "text": ""
250
- },
251
- "attribute": "show-option-icons",
252
- "reflect": false,
253
- "defaultValue": "true"
254
- },
255
- "filterButtonStyle": {
256
- "type": "string",
257
- "mutable": false,
258
- "complexType": {
259
- "original": "'list filter' | 'list icon' | 'table icon'",
260
- "resolved": "\"list filter\" | \"list icon\" | \"table icon\"",
261
- "references": {}
262
- },
263
- "required": false,
264
- "optional": false,
265
- "docs": {
266
- "tags": [],
267
- "text": ""
268
- },
269
- "attribute": "filter-button-style",
270
- "reflect": false,
271
- "defaultValue": "'list filter'"
272
- },
273
- "filterHeader": {
274
- "type": "string",
275
- "mutable": false,
276
- "complexType": {
277
- "original": "string",
278
- "resolved": "string",
279
- "references": {}
280
- },
281
- "required": false,
282
- "optional": false,
283
- "docs": {
284
- "tags": [],
285
- "text": ""
286
- },
287
- "attribute": "filter-header",
288
- "reflect": false,
289
- "defaultValue": "'Qualification status'"
290
- }
291
- };
292
- }
293
- static get states() {
294
- return {
295
- "showPopover": {},
296
- "selectedFilters": {},
297
- "filterSearchTerm": {},
298
- "displayedFilterSettings": {},
299
- "allSelected": {}
300
- };
301
- }
302
- static get events() {
303
- return [{
304
- "method": "filterChangeEvent",
305
- "name": "filterChangeEvent",
306
- "bubbles": true,
307
- "cancelable": true,
308
- "composed": true,
309
- "docs": {
310
- "tags": [],
311
- "text": ""
312
- },
313
- "complexType": {
314
- "original": "FilterChangeEvent",
315
- "resolved": "FilterChangeEvent",
316
- "references": {
317
- "FilterChangeEvent": {
318
- "location": "local"
319
- }
320
- }
321
- }
322
- }];
323
- }
324
- static get elementRef() { return "el"; }
325
- }
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+ import { h, Host } from '@stencil/core';
3
+ export class TttxFilter {
4
+ constructor() {
5
+ this.filterKey = undefined;
6
+ this.filterOptions = [
7
+ { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
8
+ { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
9
+ { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
10
+ ];
11
+ this.showSelectAll = true;
12
+ this.showSearchField = false;
13
+ this.showOptionIcons = true;
14
+ this.filterButtonStyle = 'list filter';
15
+ this.filterHeader = 'Qualification status';
16
+ this.showPopover = false;
17
+ this.selectedFilters = this.filterOptions.map((filterOption) => filterOption.optionText);
18
+ this.filterSearchTerm = '';
19
+ this.displayedFilterSettings = this.filterOptions;
20
+ this.allSelected = true;
21
+ }
22
+ emitFilterEvent() {
23
+ this.filterChangeEvent.emit({
24
+ selectedFilters: this.selectedFilters,
25
+ filterKey: this.filterKey,
26
+ allSelected: this.allSelected,
27
+ });
28
+ }
29
+ onFilterButtonClick() {
30
+ this.togglePopover();
31
+ }
32
+ onCloseButtonClick() {
33
+ this.togglePopover();
34
+ }
35
+ onApplyFilterButtonClick() {
36
+ this.emitFilterEvent();
37
+ this.togglePopover();
38
+ }
39
+ onFilterOptionSelected(selectedOption) {
40
+ this.allSelected = false;
41
+ if (this.selectedFilters.includes(selectedOption)) {
42
+ this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
43
+ }
44
+ else {
45
+ this.selectedFilters = [...this.selectedFilters, selectedOption];
46
+ }
47
+ }
48
+ togglePopover() {
49
+ this.showPopover = !this.showPopover;
50
+ // if(!this.showPopover) {
51
+ // // this._focussedElementIndex = -1;
52
+ // }
53
+ }
54
+ // Commented out keyboard interaction for now
55
+ // @Listen('keyup')
56
+ // handleKeyUp(event: KeyboardEvent) {
57
+ // const keyboardEventValue = event.key;
58
+ // if (document.activeElement.id != `filter__${this.filterKey}`) return;
59
+ // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
60
+ // if (this._focussedElementIndex == 0) {
61
+ // this.onSelectAllClick()
62
+ // } else {
63
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
64
+ // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
65
+ // }
66
+ // return;
67
+ // }
68
+ // switch (keyboardEventValue) {
69
+ // case 'Enter':
70
+ // if(!this.showPopover) {
71
+ // this.showPopover=true
72
+ // } else {
73
+ // this.emitFilterEvent()
74
+ // }
75
+ // break;
76
+ // case 'Escape':
77
+ // this.showPopover = false;
78
+ // this._focussedElementIndex = -1;
79
+ // break;
80
+ // case 'ArrowDown':
81
+ // this.showPopover = true;
82
+ // if (this._focussedElementIndex == -1) {
83
+ // this._focussedElementIndex = 0;
84
+ // } else {
85
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
86
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
87
+ // currentOption.blur();
88
+ // // options[this._focussedElementIndex].focus();
89
+ // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
90
+ // }
91
+ // break;
92
+ // case 'ArrowUp':
93
+ // if (this._focussedElementIndex == -1) {
94
+ // this.showPopover = true;
95
+ // this._focussedElementIndex = 0;
96
+ // } else {
97
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
98
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
99
+ // currentOption.blur();
100
+ // // options[this._focussedElementIndex].focus();
101
+ // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
102
+ // }
103
+ // break;
104
+ // }
105
+ // }
106
+ handleFilterChange(event) {
107
+ const target = event.target;
108
+ this.filterSearchTerm = target.value;
109
+ const filteredResults = this.filterOptions.filter((filterOption) => {
110
+ const lowercaseOption = filterOption.optionText.toLowerCase();
111
+ const filterTerm = this.filterSearchTerm.toLowerCase();
112
+ return lowercaseOption.includes(filterTerm);
113
+ });
114
+ this.displayedFilterSettings = filteredResults;
115
+ }
116
+ onSelectAllClick() {
117
+ this.allSelected = !this.allSelected;
118
+ if (this.allSelected) {
119
+ this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
120
+ }
121
+ else {
122
+ this.selectedFilters = [];
123
+ }
124
+ }
125
+ getFilterButtonClassName(buttonStyle) {
126
+ switch (buttonStyle) {
127
+ case 'table icon': {
128
+ return '--table-icon';
129
+ }
130
+ case 'list icon': {
131
+ return '--list-icon';
132
+ }
133
+ default: {
134
+ return '';
135
+ }
136
+ }
137
+ }
138
+ render() {
139
+ const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
140
+ const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
141
+ const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
142
+ const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
143
+ const filterKey = `filter__${this.filterKey}`;
144
+ return (h(Host, { id: filterKey }, h("div", { class: 'filter-container' }, h("button", { class: `filter-button ${buttonStyleClassNameModifier}`, type: 'button', onClick: this.onFilterButtonClick.bind(this) }, h("tttx-icon", { icon: 'filter_list', class: 'filter-icon', color: 'black' }), "Filter"), this.showPopover && (h("div", { class: `filter-popover-container ${filterPopoverContainerClassNameModifier}` }, h("h4", { class: 'filter-header' }, this.filterHeader), h("hr", { class: 'popover-divider' }), this.showSearchField ? (h("div", { class: 'search-field-container' }, h("tttx-icon", { icon: 'search', class: 'search-icon' }), h("input", { type: 'text', class: 'search-input', placeholder: 'Search', value: this.filterSearchTerm, onInput: this.handleFilterChange.bind(this) }), h("hr", { class: 'popover-divider' }))) : (''), h("div", { class: 'filter-options-container' }, this.showSelectAll ? (h("div", { class: 'filter-option', tabIndex: -1, onClick: this.onSelectAllClick.bind(this) }, h("tttx-icon", { icon: selectAllCheckboxIcon, color: selectAllCheckboxColor, class: 'select-all-icon' }), h("label", { class: 'filter-label' }, "Select all"))) : (''), this.displayedFilterSettings.map((option) => {
145
+ const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
146
+ const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
147
+ return h("div", { class: 'filter-option', tabIndex: -1, onClick: () => this.onFilterOptionSelected(option.optionText), key: option.optionText }, h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), this.showOptionIcons && h("tttx-icon", { icon: option.optionIcon, color: option.optionIconColor }), h("label", { class: 'filter-label' }, option.optionText));
148
+ })), h("hr", { class: 'popover-divider' }), h("div", { class: 'filter-popover-button-container' }, h("button", { type: 'button', class: 'close-button', onClick: this.onCloseButtonClick.bind(this) }, "Close"), h("button", { type: 'button', class: 'apply-button', onClick: this.onApplyFilterButtonClick.bind(this) }, "Apply")))))));
149
+ }
150
+ static get is() { return "tttx-filter"; }
151
+ static get encapsulation() { return "shadow"; }
152
+ static get originalStyleUrls() {
153
+ return {
154
+ "$": ["tttx-filter.scss"]
155
+ };
156
+ }
157
+ static get styleUrls() {
158
+ return {
159
+ "$": ["tttx-filter.css"]
160
+ };
161
+ }
162
+ static get properties() {
163
+ return {
164
+ "filterKey": {
165
+ "type": "string",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "string",
169
+ "resolved": "string",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": ""
177
+ },
178
+ "attribute": "filter-key",
179
+ "reflect": false
180
+ },
181
+ "filterOptions": {
182
+ "type": "unknown",
183
+ "mutable": false,
184
+ "complexType": {
185
+ "original": "FilterSettings[]",
186
+ "resolved": "FilterSettings[]",
187
+ "references": {
188
+ "FilterSettings": {
189
+ "location": "local"
190
+ }
191
+ }
192
+ },
193
+ "required": false,
194
+ "optional": false,
195
+ "docs": {
196
+ "tags": [],
197
+ "text": ""
198
+ },
199
+ "defaultValue": "[\n { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },\n { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },\n { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },\n ]"
200
+ },
201
+ "showSelectAll": {
202
+ "type": "boolean",
203
+ "mutable": false,
204
+ "complexType": {
205
+ "original": "boolean",
206
+ "resolved": "boolean",
207
+ "references": {}
208
+ },
209
+ "required": false,
210
+ "optional": false,
211
+ "docs": {
212
+ "tags": [],
213
+ "text": ""
214
+ },
215
+ "attribute": "show-select-all",
216
+ "reflect": false,
217
+ "defaultValue": "true"
218
+ },
219
+ "showSearchField": {
220
+ "type": "boolean",
221
+ "mutable": false,
222
+ "complexType": {
223
+ "original": "boolean",
224
+ "resolved": "boolean",
225
+ "references": {}
226
+ },
227
+ "required": false,
228
+ "optional": false,
229
+ "docs": {
230
+ "tags": [],
231
+ "text": ""
232
+ },
233
+ "attribute": "show-search-field",
234
+ "reflect": false,
235
+ "defaultValue": "false"
236
+ },
237
+ "showOptionIcons": {
238
+ "type": "boolean",
239
+ "mutable": false,
240
+ "complexType": {
241
+ "original": "boolean",
242
+ "resolved": "boolean",
243
+ "references": {}
244
+ },
245
+ "required": false,
246
+ "optional": false,
247
+ "docs": {
248
+ "tags": [],
249
+ "text": ""
250
+ },
251
+ "attribute": "show-option-icons",
252
+ "reflect": false,
253
+ "defaultValue": "true"
254
+ },
255
+ "filterButtonStyle": {
256
+ "type": "string",
257
+ "mutable": false,
258
+ "complexType": {
259
+ "original": "'list filter' | 'list icon' | 'table icon'",
260
+ "resolved": "\"list filter\" | \"list icon\" | \"table icon\"",
261
+ "references": {}
262
+ },
263
+ "required": false,
264
+ "optional": false,
265
+ "docs": {
266
+ "tags": [],
267
+ "text": ""
268
+ },
269
+ "attribute": "filter-button-style",
270
+ "reflect": false,
271
+ "defaultValue": "'list filter'"
272
+ },
273
+ "filterHeader": {
274
+ "type": "string",
275
+ "mutable": false,
276
+ "complexType": {
277
+ "original": "string",
278
+ "resolved": "string",
279
+ "references": {}
280
+ },
281
+ "required": false,
282
+ "optional": false,
283
+ "docs": {
284
+ "tags": [],
285
+ "text": ""
286
+ },
287
+ "attribute": "filter-header",
288
+ "reflect": false,
289
+ "defaultValue": "'Qualification status'"
290
+ }
291
+ };
292
+ }
293
+ static get states() {
294
+ return {
295
+ "showPopover": {},
296
+ "selectedFilters": {},
297
+ "filterSearchTerm": {},
298
+ "displayedFilterSettings": {},
299
+ "allSelected": {}
300
+ };
301
+ }
302
+ static get events() {
303
+ return [{
304
+ "method": "filterChangeEvent",
305
+ "name": "filterChangeEvent",
306
+ "bubbles": true,
307
+ "cancelable": true,
308
+ "composed": true,
309
+ "docs": {
310
+ "tags": [],
311
+ "text": ""
312
+ },
313
+ "complexType": {
314
+ "original": "FilterChangeEvent",
315
+ "resolved": "FilterChangeEvent",
316
+ "references": {
317
+ "FilterChangeEvent": {
318
+ "location": "local"
319
+ }
320
+ }
321
+ }
322
+ }];
323
+ }
324
+ static get elementRef() { return "el"; }
325
+ }