@3t-transform/threeteeui 0.1.41 → 0.1.43

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 (123) hide show
  1. package/dist/cjs/{domsanitiser.options-277161b9.js → domsanitiser.options-975e3317.js} +12 -12
  2. package/dist/cjs/{index-76f14107.js → index-457ca775.js} +88 -2
  3. package/dist/cjs/loader.cjs.js +4 -3
  4. package/dist/cjs/tttx-button.cjs.entry.js +24 -24
  5. package/dist/cjs/tttx-filter.cjs.entry.js +177 -159
  6. package/dist/cjs/tttx-form.cjs.entry.js +458 -456
  7. package/dist/cjs/tttx-icon.cjs.entry.js +11 -11
  8. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +59 -59
  9. package/dist/cjs/tttx-list.cjs.entry.js +32 -32
  10. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
  11. package/dist/cjs/tttx-sorter.cjs.entry.js +102 -102
  12. package/dist/cjs/tttx-standalone-input.cjs.entry.js +79 -79
  13. package/dist/cjs/tttx-toolbar.cjs.entry.js +10 -10
  14. package/dist/cjs/tttx.cjs.js +7 -3
  15. package/dist/collection/collection-manifest.json +2 -2
  16. package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -110
  17. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
  18. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
  19. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
  20. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +109 -109
  21. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
  22. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
  23. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
  24. package/dist/collection/components/molecules/tttx-filter/tttx-filter.js +369 -334
  25. package/dist/collection/components/molecules/tttx-filter/tttx-filter.stories.js +73 -62
  26. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +37 -37
  27. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +61 -61
  28. package/dist/collection/components/molecules/tttx-form/tttx-form.js +479 -477
  29. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +272 -272
  30. package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
  31. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
  32. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.js +224 -224
  33. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.stories.js +42 -42
  34. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +759 -759
  35. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +172 -172
  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/domsanitiser.options.js +12 -12
  44. package/dist/components/index.d.ts +9 -0
  45. package/dist/components/index.js +1 -1
  46. package/dist/components/tttx-button.js +48 -48
  47. package/dist/components/tttx-filter.js +210 -191
  48. package/dist/components/tttx-form.js +475 -473
  49. package/dist/components/tttx-icon2.js +28 -28
  50. package/dist/components/tttx-keyvalue-block.js +76 -76
  51. package/dist/components/tttx-list.js +53 -53
  52. package/dist/components/tttx-loading-spinner.js +33 -33
  53. package/dist/components/tttx-sorter.js +130 -130
  54. package/dist/components/tttx-standalone-input.js +130 -130
  55. package/dist/components/tttx-toolbar.js +26 -26
  56. package/dist/esm/{domsanitiser.options-cc420431.js → domsanitiser.options-3c7ded83.js} +12 -12
  57. package/dist/esm/{index-9cde46a5.js → index-d784fb3e.js} +88 -3
  58. package/dist/esm/loader.js +4 -3
  59. package/dist/esm/polyfills/core-js.js +0 -0
  60. package/dist/esm/polyfills/css-shim.js +1 -1
  61. package/dist/esm/polyfills/dom.js +0 -0
  62. package/dist/esm/polyfills/es5-html-element.js +0 -0
  63. package/dist/esm/polyfills/index.js +0 -0
  64. package/dist/esm/polyfills/system.js +0 -0
  65. package/dist/esm/tttx-button.entry.js +24 -24
  66. package/dist/esm/tttx-filter.entry.js +177 -159
  67. package/dist/esm/tttx-form.entry.js +458 -456
  68. package/dist/esm/tttx-icon.entry.js +11 -11
  69. package/dist/esm/tttx-keyvalue-block.entry.js +59 -59
  70. package/dist/esm/tttx-list.entry.js +32 -32
  71. package/dist/esm/tttx-loading-spinner.entry.js +16 -16
  72. package/dist/esm/tttx-sorter.entry.js +102 -102
  73. package/dist/esm/tttx-standalone-input.entry.js +79 -79
  74. package/dist/esm/tttx-toolbar.entry.js +10 -10
  75. package/dist/esm/tttx.js +4 -3
  76. package/dist/tttx/p-0ebffdfc.js +2 -0
  77. package/dist/tttx/{p-dc2a37b0.entry.js → p-1db3704e.entry.js} +1 -1
  78. package/dist/tttx/p-350ddb03.js +3 -0
  79. package/dist/tttx/{p-561224f5.entry.js → p-563605b2.entry.js} +1 -1
  80. package/dist/tttx/{p-aef96333.entry.js → p-798a098a.entry.js} +1 -1
  81. package/dist/tttx/{p-f885f17a.entry.js → p-92cade7f.entry.js} +1 -1
  82. package/dist/tttx/{p-bd1edaed.entry.js → p-aaf02902.entry.js} +1 -1
  83. package/dist/tttx/{p-e53c7f9d.entry.js → p-ab6ce9f6.entry.js} +1 -1
  84. package/dist/tttx/{p-9f1e9cc1.entry.js → p-b720c4ad.entry.js} +1 -1
  85. package/dist/tttx/{p-d2f1aa8e.entry.js → p-cac26a1b.entry.js} +1 -1
  86. package/dist/tttx/p-ec253eea.entry.js +1 -0
  87. package/dist/tttx/p-f702df4f.entry.js +1 -0
  88. package/dist/tttx/tttx.esm.js +1 -1
  89. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -10
  90. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
  91. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
  92. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
  93. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
  94. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
  95. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
  96. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
  97. package/dist/types/components/molecules/tttx-filter/tttx-filter.d.ts +41 -39
  98. package/dist/types/components/molecules/tttx-filter/tttx-filter.stories.d.ts +70 -68
  99. package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
  100. package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
  101. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +133 -133
  102. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +278 -278
  103. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +11 -11
  104. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +14 -14
  105. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.d.ts +19 -19
  106. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.stories.d.ts +30 -30
  107. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +69 -69
  108. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +143 -143
  109. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -4
  110. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -13
  111. package/dist/types/components/palette.stories.d.ts +6 -6
  112. package/dist/types/components.d.ts +2 -0
  113. package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
  114. package/dist/types/icons.d.ts +2 -2
  115. package/dist/types/index.d.ts +1 -1
  116. package/dist/types/shared/domsanitiser.options.d.ts +10 -10
  117. package/dist/types/stencil-public-runtime.d.ts +59 -3
  118. package/loader/index.d.ts +9 -0
  119. package/package.json +2 -2
  120. package/dist/tttx/p-3b1be372.entry.js +0 -1
  121. package/dist/tttx/p-b4290a5b.js +0 -3
  122. package/dist/tttx/p-d0ff9ad0.entry.js +0 -1
  123. package/dist/tttx/p-db059a69.js +0 -2
@@ -1,334 +1,369 @@
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.displayedFilterSettings = undefined;
18
- this.selectedFilters = undefined;
19
- this.filterSearchTerm = '';
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
- componentWillLoad() {
49
- this.displayedFilterSettings = this.parseFilterOptions();
50
- this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
51
- }
52
- togglePopover() {
53
- this.showPopover = !this.showPopover;
54
- // if(!this.showPopover) {
55
- // // this._focussedElementIndex = -1;
56
- // }
57
- }
58
- // Commented out keyboard interaction for now
59
- // @Listen('keyup')
60
- // handleKeyUp(event: KeyboardEvent) {
61
- // const keyboardEventValue = event.key;
62
- // if (document.activeElement.id != `filter__${this.filterKey}`) return;
63
- // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
64
- // if (this._focussedElementIndex == 0) {
65
- // this.onSelectAllClick()
66
- // } else {
67
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
68
- // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
69
- // }
70
- // return;
71
- // }
72
- // switch (keyboardEventValue) {
73
- // case 'Enter':
74
- // if(!this.showPopover) {
75
- // this.showPopover=true
76
- // } else {
77
- // this.emitFilterEvent()
78
- // }
79
- // break;
80
- // case 'Escape':
81
- // this.showPopover = false;
82
- // this._focussedElementIndex = -1;
83
- // break;
84
- // case 'ArrowDown':
85
- // this.showPopover = true;
86
- // if (this._focussedElementIndex == -1) {
87
- // this._focussedElementIndex = 0;
88
- // } else {
89
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
90
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
91
- // currentOption.blur();
92
- // // options[this._focussedElementIndex].focus();
93
- // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
94
- // }
95
- // break;
96
- // case 'ArrowUp':
97
- // if (this._focussedElementIndex == -1) {
98
- // this.showPopover = true;
99
- // this._focussedElementIndex = 0;
100
- // } else {
101
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
102
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
103
- // currentOption.blur();
104
- // // options[this._focussedElementIndex].focus();
105
- // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
106
- // }
107
- // break;
108
- // }
109
- // }
110
- handleFilterChange(event) {
111
- const target = event.target;
112
- this.filterSearchTerm = target.value;
113
- const filteredResults = this.parseFilterOptions().filter((filterOption) => {
114
- const lowercaseOption = filterOption.optionText.toLowerCase();
115
- const filterTerm = this.filterSearchTerm.toLowerCase();
116
- return lowercaseOption.includes(filterTerm);
117
- });
118
- this.displayedFilterSettings = filteredResults;
119
- }
120
- onSelectAllClick() {
121
- this.allSelected = !this.allSelected;
122
- if (this.allSelected) {
123
- this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
124
- }
125
- else {
126
- this.selectedFilters = [];
127
- }
128
- }
129
- getFilterButtonClassName(buttonStyle) {
130
- switch (buttonStyle) {
131
- case 'table icon': {
132
- return '--table-icon';
133
- }
134
- case 'list icon': {
135
- return '--list-icon';
136
- }
137
- default: {
138
- return '';
139
- }
140
- }
141
- }
142
- parseFilterOptions() {
143
- return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
144
- }
145
- render() {
146
- const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
147
- const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
148
- const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
149
- const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
150
- const filterKey = `filter__${this.filterKey}`;
151
- 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("div", { class: 'filter-header' }, this.filterHeader), 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("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) => {
152
- const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
153
- const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
154
- 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));
155
- })), 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")))))));
156
- }
157
- static get is() { return "tttx-filter"; }
158
- static get encapsulation() { return "shadow"; }
159
- static get originalStyleUrls() {
160
- return {
161
- "$": ["tttx-filter.scss"]
162
- };
163
- }
164
- static get styleUrls() {
165
- return {
166
- "$": ["tttx-filter.css"]
167
- };
168
- }
169
- static get properties() {
170
- return {
171
- "filterKey": {
172
- "type": "string",
173
- "mutable": false,
174
- "complexType": {
175
- "original": "string",
176
- "resolved": "string",
177
- "references": {}
178
- },
179
- "required": false,
180
- "optional": false,
181
- "docs": {
182
- "tags": [],
183
- "text": ""
184
- },
185
- "attribute": "filter-key",
186
- "reflect": false
187
- },
188
- "filterOptions": {
189
- "type": "string",
190
- "mutable": false,
191
- "complexType": {
192
- "original": "string | FilterSettings[]",
193
- "resolved": "FilterSettings[] | string",
194
- "references": {
195
- "FilterSettings": {
196
- "location": "local"
197
- }
198
- }
199
- },
200
- "required": false,
201
- "optional": false,
202
- "docs": {
203
- "tags": [],
204
- "text": ""
205
- },
206
- "attribute": "filter-options",
207
- "reflect": false,
208
- "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 ]"
209
- },
210
- "showSelectAll": {
211
- "type": "boolean",
212
- "mutable": false,
213
- "complexType": {
214
- "original": "boolean",
215
- "resolved": "boolean",
216
- "references": {}
217
- },
218
- "required": false,
219
- "optional": false,
220
- "docs": {
221
- "tags": [],
222
- "text": ""
223
- },
224
- "attribute": "show-select-all",
225
- "reflect": false,
226
- "defaultValue": "true"
227
- },
228
- "showSearchField": {
229
- "type": "boolean",
230
- "mutable": false,
231
- "complexType": {
232
- "original": "boolean",
233
- "resolved": "boolean",
234
- "references": {}
235
- },
236
- "required": false,
237
- "optional": false,
238
- "docs": {
239
- "tags": [],
240
- "text": ""
241
- },
242
- "attribute": "show-search-field",
243
- "reflect": false,
244
- "defaultValue": "false"
245
- },
246
- "showOptionIcons": {
247
- "type": "boolean",
248
- "mutable": false,
249
- "complexType": {
250
- "original": "boolean",
251
- "resolved": "boolean",
252
- "references": {}
253
- },
254
- "required": false,
255
- "optional": false,
256
- "docs": {
257
- "tags": [],
258
- "text": ""
259
- },
260
- "attribute": "show-option-icons",
261
- "reflect": false,
262
- "defaultValue": "true"
263
- },
264
- "filterButtonStyle": {
265
- "type": "string",
266
- "mutable": false,
267
- "complexType": {
268
- "original": "'list filter' | 'list icon' | 'table icon'",
269
- "resolved": "\"list filter\" | \"list icon\" | \"table icon\"",
270
- "references": {}
271
- },
272
- "required": false,
273
- "optional": false,
274
- "docs": {
275
- "tags": [],
276
- "text": ""
277
- },
278
- "attribute": "filter-button-style",
279
- "reflect": false,
280
- "defaultValue": "'list filter'"
281
- },
282
- "filterHeader": {
283
- "type": "string",
284
- "mutable": false,
285
- "complexType": {
286
- "original": "string",
287
- "resolved": "string",
288
- "references": {}
289
- },
290
- "required": false,
291
- "optional": false,
292
- "docs": {
293
- "tags": [],
294
- "text": ""
295
- },
296
- "attribute": "filter-header",
297
- "reflect": false,
298
- "defaultValue": "'Qualification status'"
299
- }
300
- };
301
- }
302
- static get states() {
303
- return {
304
- "showPopover": {},
305
- "displayedFilterSettings": {},
306
- "selectedFilters": {},
307
- "filterSearchTerm": {},
308
- "allSelected": {}
309
- };
310
- }
311
- static get events() {
312
- return [{
313
- "method": "filterChangeEvent",
314
- "name": "filterChangeEvent",
315
- "bubbles": true,
316
- "cancelable": true,
317
- "composed": true,
318
- "docs": {
319
- "tags": [],
320
- "text": ""
321
- },
322
- "complexType": {
323
- "original": "FilterChangeEvent",
324
- "resolved": "FilterChangeEvent",
325
- "references": {
326
- "FilterChangeEvent": {
327
- "location": "local"
328
- }
329
- }
330
- }
331
- }];
332
- }
333
- static get elementRef() { return "el"; }
334
- }
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.defaultFilterOptions = undefined;
17
+ this.showPopover = false;
18
+ this.displayedFilterSettings = undefined;
19
+ this.selectedFilters = undefined;
20
+ this.filterSearchTerm = '';
21
+ this.allSelected = undefined;
22
+ }
23
+ emitFilterEvent() {
24
+ this.filterChangeEvent.emit({
25
+ selectedFilters: this.selectedFilters,
26
+ filterKey: this.filterKey,
27
+ allSelected: this.allSelected,
28
+ });
29
+ }
30
+ onFilterButtonClick() {
31
+ this.togglePopover();
32
+ }
33
+ onCloseButtonClick() {
34
+ this.togglePopover();
35
+ }
36
+ onApplyFilterButtonClick() {
37
+ this.emitFilterEvent();
38
+ this.togglePopover();
39
+ }
40
+ onFilterOptionSelected(selectedOption) {
41
+ this.allSelected = false;
42
+ if (this.selectedFilters.includes(selectedOption)) {
43
+ this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
44
+ }
45
+ else {
46
+ this.selectedFilters = [...this.selectedFilters, selectedOption];
47
+ }
48
+ }
49
+ componentWillLoad() {
50
+ this.displayedFilterSettings = this.parseFilterOptions();
51
+ if (this.defaultFilterOptions !== undefined) {
52
+ const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
53
+ this.selectedFilters = parsedDefaultFilterOptions;
54
+ let allSelected = true;
55
+ this.parseFilterOptions().map(filterOption => {
56
+ if (!this.selectedFilters.includes(filterOption.optionText)) {
57
+ allSelected = false;
58
+ }
59
+ });
60
+ this.allSelected = allSelected;
61
+ }
62
+ else {
63
+ this.allSelected = true;
64
+ this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
65
+ }
66
+ }
67
+ togglePopover() {
68
+ this.showPopover = !this.showPopover;
69
+ // if(!this.showPopover) {
70
+ // // this._focussedElementIndex = -1;
71
+ // }
72
+ }
73
+ // Commented out keyboard interaction for now
74
+ // @Listen('keyup')
75
+ // handleKeyUp(event: KeyboardEvent) {
76
+ // const keyboardEventValue = event.key;
77
+ // if (document.activeElement.id != `filter__${this.filterKey}`) return;
78
+ // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
79
+ // if (this._focussedElementIndex == 0) {
80
+ // this.onSelectAllClick()
81
+ // } else {
82
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
83
+ // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
84
+ // }
85
+ // return;
86
+ // }
87
+ // switch (keyboardEventValue) {
88
+ // case 'Enter':
89
+ // if(!this.showPopover) {
90
+ // this.showPopover=true
91
+ // } else {
92
+ // this.emitFilterEvent()
93
+ // }
94
+ // break;
95
+ // case 'Escape':
96
+ // this.showPopover = false;
97
+ // this._focussedElementIndex = -1;
98
+ // break;
99
+ // case 'ArrowDown':
100
+ // this.showPopover = true;
101
+ // if (this._focussedElementIndex == -1) {
102
+ // this._focussedElementIndex = 0;
103
+ // } else {
104
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
105
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
106
+ // currentOption.blur();
107
+ // // options[this._focussedElementIndex].focus();
108
+ // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
109
+ // }
110
+ // break;
111
+ // case 'ArrowUp':
112
+ // if (this._focussedElementIndex == -1) {
113
+ // this.showPopover = true;
114
+ // this._focussedElementIndex = 0;
115
+ // } else {
116
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
117
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
118
+ // currentOption.blur();
119
+ // // options[this._focussedElementIndex].focus();
120
+ // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
121
+ // }
122
+ // break;
123
+ // }
124
+ // }
125
+ handleFilterChange(event) {
126
+ const target = event.target;
127
+ this.filterSearchTerm = target.value;
128
+ const filteredResults = this.parseFilterOptions().filter((filterOption) => {
129
+ const lowercaseOption = filterOption.optionText.toLowerCase();
130
+ const filterTerm = this.filterSearchTerm.toLowerCase();
131
+ return lowercaseOption.includes(filterTerm);
132
+ });
133
+ this.displayedFilterSettings = filteredResults;
134
+ }
135
+ onSelectAllClick() {
136
+ this.allSelected = !this.allSelected;
137
+ if (this.allSelected) {
138
+ this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
139
+ }
140
+ else {
141
+ this.selectedFilters = [];
142
+ }
143
+ }
144
+ getFilterButtonClassName(buttonStyle) {
145
+ switch (buttonStyle) {
146
+ case 'table icon': {
147
+ return '--table-icon';
148
+ }
149
+ case 'list icon': {
150
+ return '--list-icon';
151
+ }
152
+ default: {
153
+ return '';
154
+ }
155
+ }
156
+ }
157
+ parseFilterOptions() {
158
+ return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
159
+ }
160
+ parseDefaultFilterOptions() {
161
+ return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
162
+ }
163
+ render() {
164
+ const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
165
+ const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
166
+ const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
167
+ const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
168
+ const filterKey = `filter__${this.filterKey}`;
169
+ 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("div", { class: 'filter-header' }, this.filterHeader), 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("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) => {
170
+ const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
171
+ const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
172
+ 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));
173
+ })), 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")))))));
174
+ }
175
+ static get is() { return "tttx-filter"; }
176
+ static get encapsulation() { return "shadow"; }
177
+ static get originalStyleUrls() {
178
+ return {
179
+ "$": ["tttx-filter.scss"]
180
+ };
181
+ }
182
+ static get styleUrls() {
183
+ return {
184
+ "$": ["tttx-filter.css"]
185
+ };
186
+ }
187
+ static get properties() {
188
+ return {
189
+ "filterKey": {
190
+ "type": "string",
191
+ "mutable": false,
192
+ "complexType": {
193
+ "original": "string",
194
+ "resolved": "string",
195
+ "references": {}
196
+ },
197
+ "required": false,
198
+ "optional": false,
199
+ "docs": {
200
+ "tags": [],
201
+ "text": ""
202
+ },
203
+ "attribute": "filter-key",
204
+ "reflect": false
205
+ },
206
+ "filterOptions": {
207
+ "type": "string",
208
+ "mutable": false,
209
+ "complexType": {
210
+ "original": "string | FilterSettings[]",
211
+ "resolved": "FilterSettings[] | string",
212
+ "references": {
213
+ "FilterSettings": {
214
+ "location": "local"
215
+ }
216
+ }
217
+ },
218
+ "required": false,
219
+ "optional": false,
220
+ "docs": {
221
+ "tags": [],
222
+ "text": ""
223
+ },
224
+ "attribute": "filter-options",
225
+ "reflect": false,
226
+ "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 ]"
227
+ },
228
+ "showSelectAll": {
229
+ "type": "boolean",
230
+ "mutable": false,
231
+ "complexType": {
232
+ "original": "boolean",
233
+ "resolved": "boolean",
234
+ "references": {}
235
+ },
236
+ "required": false,
237
+ "optional": false,
238
+ "docs": {
239
+ "tags": [],
240
+ "text": ""
241
+ },
242
+ "attribute": "show-select-all",
243
+ "reflect": false,
244
+ "defaultValue": "true"
245
+ },
246
+ "showSearchField": {
247
+ "type": "boolean",
248
+ "mutable": false,
249
+ "complexType": {
250
+ "original": "boolean",
251
+ "resolved": "boolean",
252
+ "references": {}
253
+ },
254
+ "required": false,
255
+ "optional": false,
256
+ "docs": {
257
+ "tags": [],
258
+ "text": ""
259
+ },
260
+ "attribute": "show-search-field",
261
+ "reflect": false,
262
+ "defaultValue": "false"
263
+ },
264
+ "showOptionIcons": {
265
+ "type": "boolean",
266
+ "mutable": false,
267
+ "complexType": {
268
+ "original": "boolean",
269
+ "resolved": "boolean",
270
+ "references": {}
271
+ },
272
+ "required": false,
273
+ "optional": false,
274
+ "docs": {
275
+ "tags": [],
276
+ "text": ""
277
+ },
278
+ "attribute": "show-option-icons",
279
+ "reflect": false,
280
+ "defaultValue": "true"
281
+ },
282
+ "filterButtonStyle": {
283
+ "type": "string",
284
+ "mutable": false,
285
+ "complexType": {
286
+ "original": "'list filter' | 'list icon' | 'table icon'",
287
+ "resolved": "\"list filter\" | \"list icon\" | \"table icon\"",
288
+ "references": {}
289
+ },
290
+ "required": false,
291
+ "optional": false,
292
+ "docs": {
293
+ "tags": [],
294
+ "text": ""
295
+ },
296
+ "attribute": "filter-button-style",
297
+ "reflect": false,
298
+ "defaultValue": "'list filter'"
299
+ },
300
+ "filterHeader": {
301
+ "type": "string",
302
+ "mutable": false,
303
+ "complexType": {
304
+ "original": "string",
305
+ "resolved": "string",
306
+ "references": {}
307
+ },
308
+ "required": false,
309
+ "optional": false,
310
+ "docs": {
311
+ "tags": [],
312
+ "text": ""
313
+ },
314
+ "attribute": "filter-header",
315
+ "reflect": false,
316
+ "defaultValue": "'Qualification status'"
317
+ },
318
+ "defaultFilterOptions": {
319
+ "type": "string",
320
+ "mutable": false,
321
+ "complexType": {
322
+ "original": "string[] | string",
323
+ "resolved": "string | string[]",
324
+ "references": {}
325
+ },
326
+ "required": false,
327
+ "optional": false,
328
+ "docs": {
329
+ "tags": [],
330
+ "text": ""
331
+ },
332
+ "attribute": "default-filter-options",
333
+ "reflect": false
334
+ }
335
+ };
336
+ }
337
+ static get states() {
338
+ return {
339
+ "showPopover": {},
340
+ "displayedFilterSettings": {},
341
+ "selectedFilters": {},
342
+ "filterSearchTerm": {},
343
+ "allSelected": {}
344
+ };
345
+ }
346
+ static get events() {
347
+ return [{
348
+ "method": "filterChangeEvent",
349
+ "name": "filterChangeEvent",
350
+ "bubbles": true,
351
+ "cancelable": true,
352
+ "composed": true,
353
+ "docs": {
354
+ "tags": [],
355
+ "text": ""
356
+ },
357
+ "complexType": {
358
+ "original": "FilterChangeEvent",
359
+ "resolved": "FilterChangeEvent",
360
+ "references": {
361
+ "FilterChangeEvent": {
362
+ "location": "local"
363
+ }
364
+ }
365
+ }
366
+ }];
367
+ }
368
+ static get elementRef() { return "el"; }
369
+ }