@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
@@ -6,186 +6,188 @@ const index = require('./index-43af0e62.js');
6
6
 
7
7
  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}";
8
8
 
9
- const TttxFilter = class {
10
- constructor(hostRef) {
11
- index.registerInstance(this, hostRef);
12
- this.filterChangeEvent = index.createEvent(this, "filterChangeEvent", 7);
13
- this.filterKey = undefined;
14
- this.filterOptions = [
15
- { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
16
- { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
17
- { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
18
- ];
19
- this.showSelectAll = true;
20
- this.showSearchField = false;
21
- this.showOptionIcons = true;
22
- this.filterButtonStyle = 'list filter';
23
- this.filterHeader = 'Qualification status';
24
- this.defaultFilterOptions = undefined;
25
- this.popoverWidth = '193px';
26
- this.showPopover = false;
27
- this.displayedFilterSettings = undefined;
28
- this.selectedFilters = undefined;
29
- this.filterSearchTerm = '';
30
- this.allSelected = undefined;
31
- }
32
- handleCloseFilter() {
33
- this.showPopover = false;
34
- }
35
- emitFilterEvent() {
36
- this.filterChangeEvent.emit({
37
- selectedFilters: this.selectedFilters,
38
- filterKey: this.filterKey,
39
- allSelected: this.allSelected,
40
- });
41
- }
42
- onFilterButtonClick() {
43
- this.togglePopover();
44
- }
45
- onCloseButtonClick() {
46
- this.togglePopover();
47
- }
48
- onApplyFilterButtonClick() {
49
- this.emitFilterEvent();
50
- this.togglePopover();
51
- }
52
- onFilterOptionSelected(selectedOption) {
53
- this.allSelected = false;
54
- if (this.selectedFilters.includes(selectedOption)) {
55
- this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
56
- }
57
- else {
58
- this.selectedFilters = [...this.selectedFilters, selectedOption];
59
- }
60
- }
61
- componentWillLoad() {
62
- this.displayedFilterSettings = this.parseFilterOptions();
63
- if (this.defaultFilterOptions !== undefined) {
64
- const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
65
- this.selectedFilters = parsedDefaultFilterOptions;
66
- let allSelected = true;
67
- this.parseFilterOptions().map(filterOption => {
68
- if (!this.selectedFilters.includes(filterOption.optionText)) {
69
- allSelected = false;
70
- }
71
- });
72
- this.allSelected = allSelected;
73
- }
74
- else {
75
- this.allSelected = true;
76
- this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
77
- }
78
- }
79
- togglePopover() {
80
- this.showPopover = !this.showPopover;
81
- // if(!this.showPopover) {
82
- // // this._focussedElementIndex = -1;
83
- // }
84
- }
85
- // Commented out keyboard interaction for now
86
- // @Listen('keyup')
87
- // handleKeyUp(event: KeyboardEvent) {
88
- // const keyboardEventValue = event.key;
89
- // if (document.activeElement.id != `filter__${this.filterKey}`) return;
90
- // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
91
- // if (this._focussedElementIndex == 0) {
92
- // this.onSelectAllClick()
93
- // } else {
94
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
95
- // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
96
- // }
97
- // return;
98
- // }
99
- // switch (keyboardEventValue) {
100
- // case 'Enter':
101
- // if(!this.showPopover) {
102
- // this.showPopover=true
103
- // } else {
104
- // this.emitFilterEvent()
105
- // }
106
- // break;
107
- // case 'Escape':
108
- // this.showPopover = false;
109
- // this._focussedElementIndex = -1;
110
- // break;
111
- // case 'ArrowDown':
112
- // this.showPopover = true;
113
- // if (this._focussedElementIndex == -1) {
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 + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
121
- // }
122
- // break;
123
- // case 'ArrowUp':
124
- // if (this._focussedElementIndex == -1) {
125
- // this.showPopover = true;
126
- // this._focussedElementIndex = 0;
127
- // } else {
128
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
129
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
130
- // currentOption.blur();
131
- // // options[this._focussedElementIndex].focus();
132
- // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
133
- // }
134
- // break;
135
- // }
136
- // }
137
- handleFilterChange(event) {
138
- const target = event.target;
139
- this.filterSearchTerm = target.value;
140
- const filteredResults = this.parseFilterOptions().filter((filterOption) => {
141
- const lowercaseOption = filterOption.optionText.toLowerCase();
142
- const filterTerm = this.filterSearchTerm.toLowerCase();
143
- return lowercaseOption.includes(filterTerm);
144
- });
145
- this.displayedFilterSettings = filteredResults;
146
- }
147
- onSelectAllClick() {
148
- this.allSelected = !this.allSelected;
149
- if (this.allSelected) {
150
- this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
151
- }
152
- else {
153
- this.selectedFilters = [];
154
- }
155
- }
156
- getFilterButtonClassName(buttonStyle) {
157
- switch (buttonStyle) {
158
- case 'table icon': {
159
- return '--table-icon';
160
- }
161
- case 'list icon': {
162
- return '--list-icon';
163
- }
164
- default: {
165
- return '';
166
- }
167
- }
168
- }
169
- parseFilterOptions() {
170
- return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
171
- }
172
- parseDefaultFilterOptions() {
173
- return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
174
- }
175
- render() {
176
- const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
177
- const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
178
- const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
179
- const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
180
- const filterKey = `filter__${this.filterKey}`;
181
- return (index.h(index.Host, { id: filterKey }, index.h("div", { class: 'filter-container' }, index.h("button", { class: `filter-button ${buttonStyleClassNameModifier}`, type: 'button', onClick: this.onFilterButtonClick.bind(this) }, index.h("tttx-icon", { icon: 'filter_list', class: 'filter-icon', color: 'black' }), "Filter"), this.showPopover && (index.h("div", { class: `filter-popover-container ${filterPopoverContainerClassNameModifier}`, style: { width: this.popoverWidth } }, index.h("div", { class: 'filter-header' }, this.filterHeader), this.showSearchField ? (index.h("div", { class: 'search-field-container' }, index.h("tttx-icon", { icon: 'search', class: 'search-icon' }), index.h("input", { type: 'text', class: 'search-input', placeholder: 'Search', value: this.filterSearchTerm, onInput: this.handleFilterChange.bind(this) }))) : (''), index.h("div", { class: 'filter-options-container' }, this.showSelectAll ? (index.h("div", { class: 'filter-option', tabIndex: -1, onClick: this.onSelectAllClick.bind(this) }, index.h("tttx-icon", { icon: selectAllCheckboxIcon, color: selectAllCheckboxColor, class: 'select-all-icon' }), index.h("label", { class: 'filter-label' }, "Select all"))) : (''), this.displayedFilterSettings.map((option) => {
182
- const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
183
- const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
184
- return index.h("div", { class: 'filter-option', tabIndex: -1, onClick: () => this.onFilterOptionSelected(option.optionText), key: option.optionText }, index.h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), this.showOptionIcons && index.h("tttx-icon", { icon: option.optionIcon, color: option.optionIconColor }), index.h("label", { class: 'filter-label' }, option.optionText));
185
- })), index.h("div", { class: 'filter-popover-button-container' }, index.h("button", { type: 'button', class: 'close-button', onClick: this.onCloseButtonClick.bind(this) }, "Close"), index.h("button", { type: 'button', class: 'apply-button', onClick: this.onApplyFilterButtonClick.bind(this) }, "Apply")))))));
186
- }
187
- get el() { return index.getElement(this); }
188
- };
9
+ const TttxFilter = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.filterChangeEvent = index.createEvent(this, "filterChangeEvent", 7);
13
+ this.toggleFilter = index.createEvent(this, "toggleFilter", 7);
14
+ this.filterKey = undefined;
15
+ this.filterOptions = [
16
+ { optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
17
+ { optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
18
+ { optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
19
+ ];
20
+ this.showSelectAll = true;
21
+ this.showSearchField = false;
22
+ this.showOptionIcons = true;
23
+ this.filterButtonStyle = 'list filter';
24
+ this.filterHeader = 'Qualification status';
25
+ this.defaultFilterOptions = undefined;
26
+ this.popoverWidth = '193px';
27
+ this.showPopover = false;
28
+ this.displayedFilterSettings = undefined;
29
+ this.selectedFilters = undefined;
30
+ this.filterSearchTerm = '';
31
+ this.allSelected = undefined;
32
+ }
33
+ handleCloseFilter() {
34
+ this.showPopover = false;
35
+ }
36
+ emitFilterEvent() {
37
+ this.filterChangeEvent.emit({
38
+ selectedFilters: this.selectedFilters,
39
+ filterKey: this.filterKey,
40
+ allSelected: this.allSelected,
41
+ });
42
+ }
43
+ onFilterButtonClick() {
44
+ this.togglePopover();
45
+ }
46
+ onCloseButtonClick() {
47
+ this.togglePopover();
48
+ }
49
+ onApplyFilterButtonClick() {
50
+ this.emitFilterEvent();
51
+ this.togglePopover();
52
+ }
53
+ onFilterOptionSelected(selectedOption) {
54
+ this.allSelected = false;
55
+ if (this.selectedFilters.includes(selectedOption)) {
56
+ this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
57
+ }
58
+ else {
59
+ this.selectedFilters = [...this.selectedFilters, selectedOption];
60
+ }
61
+ }
62
+ componentWillLoad() {
63
+ this.displayedFilterSettings = this.parseFilterOptions();
64
+ if (this.defaultFilterOptions !== undefined) {
65
+ const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
66
+ this.selectedFilters = parsedDefaultFilterOptions;
67
+ let allSelected = true;
68
+ this.parseFilterOptions().map(filterOption => {
69
+ if (!this.selectedFilters.includes(filterOption.optionText)) {
70
+ allSelected = false;
71
+ }
72
+ });
73
+ this.allSelected = allSelected;
74
+ }
75
+ else {
76
+ this.allSelected = true;
77
+ this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
78
+ }
79
+ }
80
+ togglePopover() {
81
+ this.showPopover = !this.showPopover;
82
+ this.toggleFilter.emit(this.showPopover);
83
+ // if(!this.showPopover) {
84
+ // // this._focussedElementIndex = -1;
85
+ // }
86
+ }
87
+ // Commented out keyboard interaction for now
88
+ // @Listen('keyup')
89
+ // handleKeyUp(event: KeyboardEvent) {
90
+ // const keyboardEventValue = event.key;
91
+ // if (document.activeElement.id != `filter__${this.filterKey}`) return;
92
+ // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
93
+ // if (this._focussedElementIndex == 0) {
94
+ // this.onSelectAllClick()
95
+ // } else {
96
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
97
+ // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
98
+ // }
99
+ // return;
100
+ // }
101
+ // switch (keyboardEventValue) {
102
+ // case 'Enter':
103
+ // if(!this.showPopover) {
104
+ // this.showPopover=true
105
+ // } else {
106
+ // this.emitFilterEvent()
107
+ // }
108
+ // break;
109
+ // case 'Escape':
110
+ // this.showPopover = false;
111
+ // this._focussedElementIndex = -1;
112
+ // break;
113
+ // case 'ArrowDown':
114
+ // this.showPopover = true;
115
+ // if (this._focussedElementIndex == -1) {
116
+ // this._focussedElementIndex = 0;
117
+ // } else {
118
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
119
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
120
+ // currentOption.blur();
121
+ // // options[this._focussedElementIndex].focus();
122
+ // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
123
+ // }
124
+ // break;
125
+ // case 'ArrowUp':
126
+ // if (this._focussedElementIndex == -1) {
127
+ // this.showPopover = true;
128
+ // this._focussedElementIndex = 0;
129
+ // } else {
130
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
131
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
132
+ // currentOption.blur();
133
+ // // options[this._focussedElementIndex].focus();
134
+ // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
135
+ // }
136
+ // break;
137
+ // }
138
+ // }
139
+ handleFilterChange(event) {
140
+ const target = event.target;
141
+ this.filterSearchTerm = target.value;
142
+ const filteredResults = this.parseFilterOptions().filter((filterOption) => {
143
+ const lowercaseOption = filterOption.optionText.toLowerCase();
144
+ const filterTerm = this.filterSearchTerm.toLowerCase();
145
+ return lowercaseOption.includes(filterTerm);
146
+ });
147
+ this.displayedFilterSettings = filteredResults;
148
+ }
149
+ onSelectAllClick() {
150
+ this.allSelected = !this.allSelected;
151
+ if (this.allSelected) {
152
+ this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
153
+ }
154
+ else {
155
+ this.selectedFilters = [];
156
+ }
157
+ }
158
+ getFilterButtonClassName(buttonStyle) {
159
+ switch (buttonStyle) {
160
+ case 'table icon': {
161
+ return '--table-icon';
162
+ }
163
+ case 'list icon': {
164
+ return '--list-icon';
165
+ }
166
+ default: {
167
+ return '';
168
+ }
169
+ }
170
+ }
171
+ parseFilterOptions() {
172
+ return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
173
+ }
174
+ parseDefaultFilterOptions() {
175
+ return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
176
+ }
177
+ render() {
178
+ const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
179
+ const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
180
+ const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
181
+ const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
182
+ const filterKey = `filter__${this.filterKey}`;
183
+ return (index.h(index.Host, { id: filterKey }, index.h("div", { class: 'filter-container' }, index.h("button", { class: `filter-button ${buttonStyleClassNameModifier}`, type: 'button', onClick: this.onFilterButtonClick.bind(this) }, index.h("tttx-icon", { icon: 'filter_list', class: 'filter-icon', color: 'black' }), "Filter"), this.showPopover && (index.h("div", { class: `filter-popover-container ${filterPopoverContainerClassNameModifier}`, style: { width: this.popoverWidth } }, index.h("div", { class: 'filter-header' }, this.filterHeader), this.showSearchField ? (index.h("div", { class: 'search-field-container' }, index.h("tttx-icon", { icon: 'search', class: 'search-icon' }), index.h("input", { type: 'text', class: 'search-input', placeholder: 'Search', value: this.filterSearchTerm, onInput: this.handleFilterChange.bind(this) }))) : (''), index.h("div", { class: 'filter-options-container' }, this.showSelectAll ? (index.h("div", { class: 'filter-option', tabIndex: -1, onClick: this.onSelectAllClick.bind(this) }, index.h("tttx-icon", { icon: selectAllCheckboxIcon, color: selectAllCheckboxColor, class: 'select-all-icon' }), index.h("label", { class: 'filter-label' }, "Select all"))) : (''), this.displayedFilterSettings.map((option) => {
184
+ const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
185
+ const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
186
+ return index.h("div", { class: 'filter-option', tabIndex: -1, onClick: () => this.onFilterOptionSelected(option.optionText), key: option.optionText }, index.h("tttx-icon", { icon: checkboxIcon, color: checkboxColor, class: 'checkbox-icon' }), this.showOptionIcons && index.h("tttx-icon", { icon: option.optionIcon, color: option.optionIconColor }), index.h("label", { class: 'filter-label' }, option.optionText));
187
+ })), index.h("div", { class: 'filter-popover-button-container' }, index.h("button", { type: 'button', class: 'close-button', onClick: this.onCloseButtonClick.bind(this) }, "Close"), index.h("button", { type: 'button', class: 'apply-button', onClick: this.onApplyFilterButtonClick.bind(this) }, "Apply")))))));
188
+ }
189
+ get el() { return index.getElement(this); }
190
+ };
189
191
  TttxFilter.style = tttxFilterCss;
190
192
 
191
193
  exports.tttx_filter = TttxFilter;