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