@3t-transform/threeteeui 0.1.52 → 0.1.57

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 (117) hide show
  1. package/dist/cjs/{domsanitiser.options-b2d88e35.js → domsanitiser.options-cd2932a9.js} +17 -17
  2. package/dist/cjs/tttx-button.cjs.entry.js +23 -23
  3. package/dist/cjs/tttx-dialog-box.cjs.entry.js +69 -69
  4. package/dist/cjs/tttx-filter.cjs.entry.js +182 -180
  5. package/dist/cjs/tttx-form.cjs.entry.js +457 -457
  6. package/dist/cjs/tttx-icon.cjs.entry.js +10 -10
  7. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +58 -58
  8. package/dist/cjs/tttx-list.cjs.entry.js +31 -31
  9. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +15 -15
  10. package/dist/cjs/tttx-qrcode.cjs.entry.js +27 -27
  11. package/dist/cjs/tttx-sorter.cjs.entry.js +107 -104
  12. package/dist/cjs/tttx-standalone-input.cjs.entry.js +78 -78
  13. package/dist/cjs/tttx-toolbar.cjs.entry.js +9 -9
  14. package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -110
  15. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
  16. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
  17. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
  18. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +109 -109
  19. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
  20. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
  21. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
  22. package/dist/collection/components/atoms/tttx-qrcode/tttx-qrcode.js +81 -81
  23. package/dist/collection/components/atoms/tttx-qrcode/tttx-qrcode.stories.js +22 -22
  24. package/dist/collection/components/molecules/tttx-dialog-box/tttx-dialog-box.js +172 -172
  25. package/dist/collection/components/molecules/tttx-dialog-box/tttx-dialog-box.stories.js +289 -289
  26. package/dist/collection/components/molecules/tttx-filter/tttx-filter.js +416 -400
  27. package/dist/collection/components/molecules/tttx-filter/tttx-filter.stories.js +80 -80
  28. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +37 -37
  29. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +61 -61
  30. package/dist/collection/components/molecules/tttx-form/tttx-form.js +479 -479
  31. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +272 -272
  32. package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
  33. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
  34. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.js +253 -236
  35. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.stories.js +42 -42
  36. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +759 -759
  37. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +172 -172
  38. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +44 -44
  39. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +14 -14
  40. package/dist/collection/components/palette.stories.js +7 -7
  41. package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
  42. package/dist/collection/icons.js +2838 -2838
  43. package/dist/collection/index.js +1 -1
  44. package/dist/collection/shared/domsanitiser.options.js +14 -14
  45. package/dist/components/domsanitiser.options.js +17 -17
  46. package/dist/components/tttx-button2.js +48 -48
  47. package/dist/components/tttx-dialog-box.js +97 -97
  48. package/dist/components/tttx-filter.js +217 -215
  49. package/dist/components/tttx-form.js +475 -475
  50. package/dist/components/tttx-icon2.js +28 -28
  51. package/dist/components/tttx-keyvalue-block.js +76 -76
  52. package/dist/components/tttx-list.js +53 -53
  53. package/dist/components/tttx-loading-spinner.js +33 -33
  54. package/dist/components/tttx-qrcode.js +45 -45
  55. package/dist/components/tttx-sorter.js +136 -133
  56. package/dist/components/tttx-standalone-input.js +130 -130
  57. package/dist/components/tttx-toolbar.js +26 -26
  58. package/dist/esm/{domsanitiser.options-81611f82.js → domsanitiser.options-563c1cf3.js} +17 -17
  59. package/dist/esm/polyfills/core-js.js +0 -0
  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 +23 -23
  65. package/dist/esm/tttx-dialog-box.entry.js +69 -69
  66. package/dist/esm/tttx-filter.entry.js +182 -180
  67. package/dist/esm/tttx-form.entry.js +457 -457
  68. package/dist/esm/tttx-icon.entry.js +10 -10
  69. package/dist/esm/tttx-keyvalue-block.entry.js +58 -58
  70. package/dist/esm/tttx-list.entry.js +31 -31
  71. package/dist/esm/tttx-loading-spinner.entry.js +15 -15
  72. package/dist/esm/tttx-qrcode.entry.js +27 -27
  73. package/dist/esm/tttx-sorter.entry.js +107 -104
  74. package/dist/esm/tttx-standalone-input.entry.js +78 -78
  75. package/dist/esm/tttx-toolbar.entry.js +9 -9
  76. package/dist/tttx/p-225e6fa6.entry.js +1 -0
  77. package/dist/tttx/{p-bc3b9283.entry.js → p-58d7c978.entry.js} +1 -1
  78. package/dist/tttx/{p-c751ebc2.entry.js → p-8b511fff.entry.js} +1 -1
  79. package/dist/tttx/{p-6a6ff7b7.entry.js → p-909c090d.entry.js} +1 -1
  80. package/dist/tttx/p-a658e1ac.entry.js +1 -0
  81. package/dist/tttx/{p-0b25ac9c.js → p-d3835fde.js} +2 -2
  82. package/dist/tttx/tttx.esm.js +1 -1
  83. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -10
  84. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
  85. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
  86. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
  87. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
  88. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
  89. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
  90. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
  91. package/dist/types/components/atoms/tttx-qrcode/tttx-qrcode.d.ts +8 -8
  92. package/dist/types/components/atoms/tttx-qrcode/tttx-qrcode.stories.d.ts +23 -23
  93. package/dist/types/components/molecules/tttx-dialog-box/tttx-dialog-box.d.ts +18 -18
  94. package/dist/types/components/molecules/tttx-dialog-box/tttx-dialog-box.stories.d.ts +24 -24
  95. package/dist/types/components/molecules/tttx-filter/tttx-filter.d.ts +44 -43
  96. package/dist/types/components/molecules/tttx-filter/tttx-filter.stories.d.ts +76 -0
  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 +133 -133
  100. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +278 -0
  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 -0
  103. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.d.ts +21 -20
  104. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.stories.d.ts +30 -0
  105. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +69 -69
  106. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +143 -143
  107. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -4
  108. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -13
  109. package/dist/types/components/palette.stories.d.ts +6 -6
  110. package/dist/types/components.d.ts +2 -0
  111. package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
  112. package/dist/types/icons.d.ts +2 -2
  113. package/dist/types/index.d.ts +1 -1
  114. package/dist/types/shared/domsanitiser.options.d.ts +10 -10
  115. package/package.json +1 -1
  116. package/dist/tttx/p-3b29e8af.entry.js +0 -1
  117. package/dist/tttx/p-637e7e88.entry.js +0 -1
@@ -2,186 +2,188 @@ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement
2
2
 
3
3
  const tttxFilterCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.material-symbols-rounded{font-family:\"Material Symbols Rounded\", sans-serif;font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;color:#9e9e9e}.filter-container{background-color:white;position:relative}.filter-container .filter-button{display:inline-flex;justify-content:center;align-items:center;font-size:14px;font-weight:400;font-family:\"Roboto\", serif;text-transform:uppercase;color:#212121;border:1px solid #d5d5d5;border-radius:4px;background:transparent;height:36px;width:95px;margin:0;padding-right:16px;cursor:pointer}@media (max-width: 475px){.filter-container .filter-button{padding-left:4px}}.filter-container .filter-button .filter-icon{padding-left:8px;padding-right:4px}.filter-container .filter-button.--list-icon{font-size:0;width:36px;height:36px;padding:0}.filter-container .filter-button.--list-icon .filter-icon{padding:0}.filter-container .filter-button.--list-icon:hover{background:#e3e3e3}.filter-container .filter-button.--table-icon{font-size:0;width:36px;height:36px;padding:0;border:none}.filter-container .filter-button.--table-icon .filter-icon{padding:0;width:24px;height:24px}.filter-container .filter-button.--table-icon:hover{background:#e3e3e3;border-radius:50%;width:36px;height:36px}.filter-container .filter-button:hover{background:#e3e3e3}.filter-container .filter-popover-container{display:flex;flex-direction:column;gap:8px;border-radius:4px;box-shadow:0px 1px 5px #1111114D;position:absolute;top:36px;left:0px;background-color:white;padding:8px 16px}.filter-container .filter-popover-container .filter-header{color:#757575;text-transform:uppercase;font-size:14px;font-weight:500;font-family:\"Roboto\", serif;padding-top:4px;padding-bottom:5px}.filter-container .filter-popover-container .filter-options-container{display:flex;flex-direction:column;gap:4px;border-top:1px solid #d5d5d5;border-bottom:1px solid #d5d5d5;padding-bottom:8px}.filter-container .filter-popover-container .filter-option{display:flex;flex-direction:row;align-items:center;min-height:36px;padding-left:8px}.filter-container .filter-popover-container .filter-option .select-all-icon{padding-right:6px}.filter-container .filter-popover-container .filter-option .checkbox-icon{padding-right:8px}.filter-container .filter-popover-container .filter-option .filter-label{padding-left:8px;padding-bottom:3px;font-size:16px;font-weight:500;font-family:\"Roboto\", serif}.filter-container .filter-popover-container .filter-option:first-child{padding-top:8px}.filter-container .filter-popover-container .filter-popover-button-container{display:flex;justify-content:flex-end;align-items:center}.filter-container .filter-popover-container .filter-popover-button-container .close-button{height:36px;width:74px;background-color:white;border:1px solid #d5d5d5;border-radius:4px;text-transform:uppercase;margin-right:8px;font-size:14px;font-weight:400;font-family:\"Roboto\", serif;color:#212121}.filter-container .filter-popover-container .filter-popover-button-container .apply-button{height:36px;width:73px;background-color:#1479c6;color:white;border-radius:4px;border:none;text-transform:uppercase;font-size:14px;font-weight:400;font-family:\"Roboto\", serif}.filter-container .filter-popover-container.--with-search-field .filter-header{border-bottom:1px solid #d5d5d5}.filter-container .filter-popover-container.--with-search-field .search-field-container{position:relative;color:#d5d5d5;height:36px}.filter-container .filter-popover-container.--with-search-field .search-field-container .search-icon{position:absolute;top:6px;left:8px}.filter-container .filter-popover-container.--with-search-field .search-field-container .search-input{padding-left:36px;border:1px solid #d5d5d5;border-radius:4px;height:36px;width:100%;font-size:16px;font-family:\"Roboto\", serif;font-weight:500;box-sizing:border-box}.filter-container .filter-popover-container.--with-search-field .search-field-container .search-input:focus-visible,.filter-container .filter-popover-container.--with-search-field .search-field-container .search-input:focus{outline:none;border:1px solid #1479c6}.filter-container .filter-popover-container.--with-search-field .search-field-container .search-input::placeholder{color:#9e9e9e;font-size:16px;font-family:\"Roboto\", serif;font-weight:500}";
4
4
 
5
- const TttxFilter = class {
6
- constructor(hostRef) {
7
- registerInstance(this, hostRef);
8
- this.filterChangeEvent = createEvent(this, "filterChangeEvent", 7);
9
- this.filterKey = undefined;
10
- this.filterOptions = [
11
- { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
12
- { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
13
- { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
14
- ];
15
- this.showSelectAll = true;
16
- this.showSearchField = false;
17
- this.showOptionIcons = true;
18
- this.filterButtonStyle = 'list filter';
19
- this.filterHeader = 'Qualification status';
20
- this.defaultFilterOptions = undefined;
21
- this.popoverWidth = '193px';
22
- this.showPopover = false;
23
- this.displayedFilterSettings = undefined;
24
- this.selectedFilters = undefined;
25
- this.filterSearchTerm = '';
26
- this.allSelected = undefined;
27
- }
28
- handleCloseFilter() {
29
- this.showPopover = false;
30
- }
31
- emitFilterEvent() {
32
- this.filterChangeEvent.emit({
33
- selectedFilters: this.selectedFilters,
34
- filterKey: this.filterKey,
35
- allSelected: this.allSelected,
36
- });
37
- }
38
- onFilterButtonClick() {
39
- this.togglePopover();
40
- }
41
- onCloseButtonClick() {
42
- this.togglePopover();
43
- }
44
- onApplyFilterButtonClick() {
45
- this.emitFilterEvent();
46
- this.togglePopover();
47
- }
48
- onFilterOptionSelected(selectedOption) {
49
- this.allSelected = false;
50
- if (this.selectedFilters.includes(selectedOption)) {
51
- this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
52
- }
53
- else {
54
- this.selectedFilters = [...this.selectedFilters, selectedOption];
55
- }
56
- }
57
- componentWillLoad() {
58
- this.displayedFilterSettings = this.parseFilterOptions();
59
- if (this.defaultFilterOptions !== undefined) {
60
- const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
61
- this.selectedFilters = parsedDefaultFilterOptions;
62
- let allSelected = true;
63
- this.parseFilterOptions().map(filterOption => {
64
- if (!this.selectedFilters.includes(filterOption.optionText)) {
65
- allSelected = false;
66
- }
67
- });
68
- this.allSelected = allSelected;
69
- }
70
- else {
71
- this.allSelected = true;
72
- this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
73
- }
74
- }
75
- togglePopover() {
76
- this.showPopover = !this.showPopover;
77
- // if(!this.showPopover) {
78
- // // this._focussedElementIndex = -1;
79
- // }
80
- }
81
- // Commented out keyboard interaction for now
82
- // @Listen('keyup')
83
- // handleKeyUp(event: KeyboardEvent) {
84
- // const keyboardEventValue = event.key;
85
- // if (document.activeElement.id != `filter__${this.filterKey}`) return;
86
- // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
87
- // if (this._focussedElementIndex == 0) {
88
- // this.onSelectAllClick()
89
- // } else {
90
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
91
- // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
92
- // }
93
- // return;
94
- // }
95
- // switch (keyboardEventValue) {
96
- // case 'Enter':
97
- // if(!this.showPopover) {
98
- // this.showPopover=true
99
- // } else {
100
- // this.emitFilterEvent()
101
- // }
102
- // break;
103
- // case 'Escape':
104
- // this.showPopover = false;
105
- // this._focussedElementIndex = -1;
106
- // break;
107
- // case 'ArrowDown':
108
- // this.showPopover = true;
109
- // if (this._focussedElementIndex == -1) {
110
- // this._focussedElementIndex = 0;
111
- // } else {
112
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
113
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
114
- // currentOption.blur();
115
- // // options[this._focussedElementIndex].focus();
116
- // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
117
- // }
118
- // break;
119
- // case 'ArrowUp':
120
- // if (this._focussedElementIndex == -1) {
121
- // this.showPopover = true;
122
- // this._focussedElementIndex = 0;
123
- // } else {
124
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
125
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
126
- // currentOption.blur();
127
- // // options[this._focussedElementIndex].focus();
128
- // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
129
- // }
130
- // break;
131
- // }
132
- // }
133
- handleFilterChange(event) {
134
- const target = event.target;
135
- this.filterSearchTerm = target.value;
136
- const filteredResults = this.parseFilterOptions().filter((filterOption) => {
137
- const lowercaseOption = filterOption.optionText.toLowerCase();
138
- const filterTerm = this.filterSearchTerm.toLowerCase();
139
- return lowercaseOption.includes(filterTerm);
140
- });
141
- this.displayedFilterSettings = filteredResults;
142
- }
143
- onSelectAllClick() {
144
- this.allSelected = !this.allSelected;
145
- if (this.allSelected) {
146
- this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
147
- }
148
- else {
149
- this.selectedFilters = [];
150
- }
151
- }
152
- getFilterButtonClassName(buttonStyle) {
153
- switch (buttonStyle) {
154
- case 'table icon': {
155
- return '--table-icon';
156
- }
157
- case 'list icon': {
158
- return '--list-icon';
159
- }
160
- default: {
161
- return '';
162
- }
163
- }
164
- }
165
- parseFilterOptions() {
166
- return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
167
- }
168
- parseDefaultFilterOptions() {
169
- return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
170
- }
171
- render() {
172
- const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
173
- const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
174
- const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
175
- const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
176
- const filterKey = `filter__${this.filterKey}`;
177
- 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}`, style: { width: this.popoverWidth } }, 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) => {
178
- const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
179
- const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
180
- 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));
181
- })), 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")))))));
182
- }
183
- get el() { return getElement(this); }
184
- };
5
+ const TttxFilter = class {
6
+ constructor(hostRef) {
7
+ registerInstance(this, hostRef);
8
+ this.filterChangeEvent = createEvent(this, "filterChangeEvent", 7);
9
+ this.toggleFilter = createEvent(this, "toggleFilter", 7);
10
+ this.filterKey = undefined;
11
+ this.filterOptions = [
12
+ { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
13
+ { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
14
+ { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
15
+ ];
16
+ this.showSelectAll = true;
17
+ this.showSearchField = false;
18
+ this.showOptionIcons = true;
19
+ this.filterButtonStyle = 'list filter';
20
+ this.filterHeader = 'Qualification status';
21
+ this.defaultFilterOptions = undefined;
22
+ this.popoverWidth = '193px';
23
+ this.showPopover = false;
24
+ this.displayedFilterSettings = undefined;
25
+ this.selectedFilters = undefined;
26
+ this.filterSearchTerm = '';
27
+ this.allSelected = undefined;
28
+ }
29
+ handleCloseFilter() {
30
+ this.showPopover = false;
31
+ }
32
+ emitFilterEvent() {
33
+ this.filterChangeEvent.emit({
34
+ selectedFilters: this.selectedFilters,
35
+ filterKey: this.filterKey,
36
+ allSelected: this.allSelected,
37
+ });
38
+ }
39
+ onFilterButtonClick() {
40
+ this.togglePopover();
41
+ }
42
+ onCloseButtonClick() {
43
+ this.togglePopover();
44
+ }
45
+ onApplyFilterButtonClick() {
46
+ this.emitFilterEvent();
47
+ this.togglePopover();
48
+ }
49
+ onFilterOptionSelected(selectedOption) {
50
+ this.allSelected = false;
51
+ if (this.selectedFilters.includes(selectedOption)) {
52
+ this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
53
+ }
54
+ else {
55
+ this.selectedFilters = [...this.selectedFilters, selectedOption];
56
+ }
57
+ }
58
+ componentWillLoad() {
59
+ this.displayedFilterSettings = this.parseFilterOptions();
60
+ if (this.defaultFilterOptions !== undefined) {
61
+ const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
62
+ this.selectedFilters = parsedDefaultFilterOptions;
63
+ let allSelected = true;
64
+ this.parseFilterOptions().map(filterOption => {
65
+ if (!this.selectedFilters.includes(filterOption.optionText)) {
66
+ allSelected = false;
67
+ }
68
+ });
69
+ this.allSelected = allSelected;
70
+ }
71
+ else {
72
+ this.allSelected = true;
73
+ this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
74
+ }
75
+ }
76
+ togglePopover() {
77
+ this.showPopover = !this.showPopover;
78
+ this.toggleFilter.emit(this.showPopover);
79
+ // if(!this.showPopover) {
80
+ // // this._focussedElementIndex = -1;
81
+ // }
82
+ }
83
+ // Commented out keyboard interaction for now
84
+ // @Listen('keyup')
85
+ // handleKeyUp(event: KeyboardEvent) {
86
+ // const keyboardEventValue = event.key;
87
+ // if (document.activeElement.id != `filter__${this.filterKey}`) return;
88
+ // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
89
+ // if (this._focussedElementIndex == 0) {
90
+ // this.onSelectAllClick()
91
+ // } else {
92
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
93
+ // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
94
+ // }
95
+ // return;
96
+ // }
97
+ // switch (keyboardEventValue) {
98
+ // case 'Enter':
99
+ // if(!this.showPopover) {
100
+ // this.showPopover=true
101
+ // } else {
102
+ // this.emitFilterEvent()
103
+ // }
104
+ // break;
105
+ // case 'Escape':
106
+ // this.showPopover = false;
107
+ // this._focussedElementIndex = -1;
108
+ // break;
109
+ // case 'ArrowDown':
110
+ // this.showPopover = true;
111
+ // if (this._focussedElementIndex == -1) {
112
+ // this._focussedElementIndex = 0;
113
+ // } else {
114
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
115
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
116
+ // currentOption.blur();
117
+ // // options[this._focussedElementIndex].focus();
118
+ // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
119
+ // }
120
+ // break;
121
+ // case 'ArrowUp':
122
+ // if (this._focussedElementIndex == -1) {
123
+ // this.showPopover = true;
124
+ // this._focussedElementIndex = 0;
125
+ // } else {
126
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
127
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
128
+ // currentOption.blur();
129
+ // // options[this._focussedElementIndex].focus();
130
+ // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
131
+ // }
132
+ // break;
133
+ // }
134
+ // }
135
+ handleFilterChange(event) {
136
+ const target = event.target;
137
+ this.filterSearchTerm = target.value;
138
+ const filteredResults = this.parseFilterOptions().filter((filterOption) => {
139
+ const lowercaseOption = filterOption.optionText.toLowerCase();
140
+ const filterTerm = this.filterSearchTerm.toLowerCase();
141
+ return lowercaseOption.includes(filterTerm);
142
+ });
143
+ this.displayedFilterSettings = filteredResults;
144
+ }
145
+ onSelectAllClick() {
146
+ this.allSelected = !this.allSelected;
147
+ if (this.allSelected) {
148
+ this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
149
+ }
150
+ else {
151
+ this.selectedFilters = [];
152
+ }
153
+ }
154
+ getFilterButtonClassName(buttonStyle) {
155
+ switch (buttonStyle) {
156
+ case 'table icon': {
157
+ return '--table-icon';
158
+ }
159
+ case 'list icon': {
160
+ return '--list-icon';
161
+ }
162
+ default: {
163
+ return '';
164
+ }
165
+ }
166
+ }
167
+ parseFilterOptions() {
168
+ return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
169
+ }
170
+ parseDefaultFilterOptions() {
171
+ return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
172
+ }
173
+ render() {
174
+ const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
175
+ const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
176
+ const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
177
+ const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
178
+ const filterKey = `filter__${this.filterKey}`;
179
+ 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}`, style: { width: this.popoverWidth } }, 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) => {
180
+ const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
181
+ const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
182
+ 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));
183
+ })), 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")))))));
184
+ }
185
+ get el() { return getElement(this); }
186
+ };
185
187
  TttxFilter.style = tttxFilterCss;
186
188
 
187
189
  export { TttxFilter as tttx_filter };