@3t-transform/threeteeui 0.1.43 → 0.1.45

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 (147) hide show
  1. package/dist/cjs/_commonjsHelpers-537d719a.js +20 -0
  2. package/dist/cjs/{domsanitiser.options-975e3317.js → domsanitiser.options-b2d88e35.js} +16 -30
  3. package/dist/cjs/{index-457ca775.js → index-1a35850c.js} +62 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/tttx-button.cjs.entry.js +24 -24
  6. package/dist/cjs/tttx-dialog-box.cjs.entry.js +81 -0
  7. package/dist/cjs/tttx-filter.cjs.entry.js +177 -177
  8. package/dist/cjs/tttx-form.cjs.entry.js +459 -458
  9. package/dist/cjs/tttx-icon.cjs.entry.js +11 -11
  10. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +59 -59
  11. package/dist/cjs/tttx-list.cjs.entry.js +33 -32
  12. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
  13. package/dist/cjs/tttx-qrcode.cjs.entry.js +37 -0
  14. package/dist/cjs/tttx-sorter.cjs.entry.js +102 -102
  15. package/dist/cjs/tttx-standalone-input.cjs.entry.js +79 -79
  16. package/dist/cjs/tttx-toolbar.cjs.entry.js +10 -10
  17. package/dist/cjs/tttx.cjs.js +2 -2
  18. package/dist/collection/collection-manifest.json +2 -0
  19. package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -110
  20. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
  21. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
  22. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
  23. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +109 -109
  24. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
  25. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
  26. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
  27. package/dist/collection/components/atoms/tttx-qrcode/tttx-qrcode.css +0 -0
  28. package/dist/collection/components/atoms/tttx-qrcode/tttx-qrcode.js +74 -0
  29. package/dist/collection/components/atoms/tttx-qrcode/tttx-qrcode.stories.js +22 -0
  30. package/dist/collection/components/molecules/tttx-dialog-box/tttx-dialog-box.css +146 -0
  31. package/dist/collection/components/molecules/tttx-dialog-box/tttx-dialog-box.js +172 -0
  32. package/dist/collection/components/molecules/tttx-dialog-box/tttx-dialog-box.stories.js +380 -0
  33. package/dist/collection/components/molecules/tttx-filter/tttx-filter.js +369 -369
  34. package/dist/collection/components/molecules/tttx-filter/tttx-filter.stories.js +72 -72
  35. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +37 -37
  36. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +61 -61
  37. package/dist/collection/components/molecules/tttx-form/tttx-form.js +479 -479
  38. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +272 -272
  39. package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
  40. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
  41. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.js +224 -224
  42. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.stories.js +42 -42
  43. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +759 -759
  44. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +172 -172
  45. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +44 -44
  46. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +14 -14
  47. package/dist/collection/components/palette.stories.js +7 -7
  48. package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
  49. package/dist/collection/icons.js +2838 -2838
  50. package/dist/collection/index.js +1 -1
  51. package/dist/collection/shared/domsanitiser.options.js +14 -14
  52. package/dist/components/_commonjsHelpers.js +17 -0
  53. package/dist/components/domsanitiser.options.js +13 -27
  54. package/dist/components/index.d.ts +2 -0
  55. package/dist/components/index.js +2 -0
  56. package/dist/components/tttx-button.js +1 -54
  57. package/dist/components/tttx-button2.js +56 -0
  58. package/dist/components/tttx-dialog-box.d.ts +11 -0
  59. package/dist/components/tttx-dialog-box.js +110 -0
  60. package/dist/components/tttx-filter.js +210 -210
  61. package/dist/components/tttx-form.js +475 -475
  62. package/dist/components/tttx-icon2.js +28 -28
  63. package/dist/components/tttx-keyvalue-block.js +76 -76
  64. package/dist/components/tttx-list.js +53 -53
  65. package/dist/components/tttx-loading-spinner.js +33 -33
  66. package/dist/components/tttx-qrcode.d.ts +11 -0
  67. package/dist/components/tttx-qrcode.js +53 -0
  68. package/dist/components/tttx-sorter.js +130 -130
  69. package/dist/components/tttx-standalone-input.js +130 -130
  70. package/dist/components/tttx-toolbar.js +26 -26
  71. package/dist/esm/_commonjsHelpers-9943807e.js +17 -0
  72. package/dist/esm/{domsanitiser.options-3c7ded83.js → domsanitiser.options-81611f82.js} +13 -27
  73. package/dist/esm/{index-d784fb3e.js → index-a848bfb4.js} +62 -1
  74. package/dist/esm/loader.js +3 -3
  75. package/dist/esm/polyfills/core-js.js +0 -0
  76. package/dist/esm/polyfills/dom.js +0 -0
  77. package/dist/esm/polyfills/es5-html-element.js +0 -0
  78. package/dist/esm/polyfills/index.js +0 -0
  79. package/dist/esm/polyfills/system.js +0 -0
  80. package/dist/esm/tttx-button.entry.js +24 -24
  81. package/dist/esm/tttx-dialog-box.entry.js +77 -0
  82. package/dist/esm/tttx-filter.entry.js +177 -177
  83. package/dist/esm/tttx-form.entry.js +459 -458
  84. package/dist/esm/tttx-icon.entry.js +11 -11
  85. package/dist/esm/tttx-keyvalue-block.entry.js +59 -59
  86. package/dist/esm/tttx-list.entry.js +33 -32
  87. package/dist/esm/tttx-loading-spinner.entry.js +16 -16
  88. package/dist/esm/tttx-qrcode.entry.js +33 -0
  89. package/dist/esm/tttx-sorter.entry.js +102 -102
  90. package/dist/esm/tttx-standalone-input.entry.js +79 -79
  91. package/dist/esm/tttx-toolbar.entry.js +10 -10
  92. package/dist/esm/tttx.js +3 -3
  93. package/dist/tttx/p-0b25ac9c.js +3 -0
  94. package/dist/tttx/p-112455b1.js +1 -0
  95. package/dist/tttx/{p-b720c4ad.entry.js → p-120a0732.entry.js} +1 -1
  96. package/dist/tttx/p-2d130f82.entry.js +1 -0
  97. package/dist/tttx/{p-aaf02902.entry.js → p-42349ae5.entry.js} +1 -1
  98. package/dist/tttx/{p-92cade7f.entry.js → p-623b9147.entry.js} +1 -1
  99. package/dist/tttx/{p-cac26a1b.entry.js → p-7428fc97.entry.js} +1 -1
  100. package/dist/tttx/{p-ab6ce9f6.entry.js → p-77fb8e0f.entry.js} +1 -1
  101. package/dist/tttx/p-83563ce9.entry.js +1 -0
  102. package/dist/tttx/p-a092cd71.entry.js +1 -0
  103. package/dist/tttx/p-ab4652a8.js +2 -0
  104. package/dist/tttx/p-af7ff3b3.entry.js +1 -0
  105. package/dist/tttx/{p-563605b2.entry.js → p-d0ca435d.entry.js} +1 -1
  106. package/dist/tttx/{p-798a098a.entry.js → p-d2b0ec0a.entry.js} +1 -1
  107. package/dist/tttx/{p-ec253eea.entry.js → p-e1efb888.entry.js} +1 -1
  108. package/dist/tttx/tttx.esm.js +1 -1
  109. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -10
  110. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
  111. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
  112. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
  113. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
  114. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
  115. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
  116. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
  117. package/dist/types/components/atoms/tttx-qrcode/tttx-qrcode.d.ts +6 -0
  118. package/dist/types/components/atoms/tttx-qrcode/tttx-qrcode.stories.d.ts +23 -0
  119. package/dist/types/components/molecules/tttx-dialog-box/interfaces.d.ts +25 -0
  120. package/dist/types/components/molecules/tttx-dialog-box/tttx-dialog-box.d.ts +18 -0
  121. package/dist/types/components/molecules/tttx-dialog-box/tttx-dialog-box.stories.d.ts +23 -0
  122. package/dist/types/components/molecules/tttx-filter/tttx-filter.d.ts +41 -41
  123. package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
  124. package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
  125. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +133 -133
  126. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +11 -11
  127. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.d.ts +19 -19
  128. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +69 -69
  129. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +143 -143
  130. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -4
  131. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -13
  132. package/dist/types/components/palette.stories.d.ts +6 -6
  133. package/dist/types/components.d.ts +41 -0
  134. package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
  135. package/dist/types/icons.d.ts +2 -2
  136. package/dist/types/index.d.ts +1 -1
  137. package/dist/types/shared/domsanitiser.options.d.ts +10 -10
  138. package/package.json +7 -5
  139. package/readme.md +19 -7
  140. package/dist/tttx/p-0ebffdfc.js +0 -2
  141. package/dist/tttx/p-1db3704e.entry.js +0 -1
  142. package/dist/tttx/p-350ddb03.js +0 -3
  143. package/dist/tttx/p-f702df4f.entry.js +0 -1
  144. package/dist/types/components/molecules/tttx-filter/tttx-filter.stories.d.ts +0 -70
  145. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +0 -278
  146. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +0 -14
  147. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.stories.d.ts +0 -30
@@ -3,216 +3,216 @@ 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}@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:0 16px}.filter-container .filter-popover-container .filter-header{color:#757575;text-transform:uppercase;font-size:14px;font-weight:500;font-family:\"Roboto\", serif;padding:12px 0}.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}.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;padding-bottom:8px}.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;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.showPopover = false;
25
- this.displayedFilterSettings = undefined;
26
- this.selectedFilters = undefined;
27
- this.filterSearchTerm = '';
28
- this.allSelected = undefined;
29
- }
30
- emitFilterEvent() {
31
- this.filterChangeEvent.emit({
32
- selectedFilters: this.selectedFilters,
33
- filterKey: this.filterKey,
34
- allSelected: this.allSelected,
35
- });
36
- }
37
- onFilterButtonClick() {
38
- this.togglePopover();
39
- }
40
- onCloseButtonClick() {
41
- this.togglePopover();
42
- }
43
- onApplyFilterButtonClick() {
44
- this.emitFilterEvent();
45
- this.togglePopover();
46
- }
47
- onFilterOptionSelected(selectedOption) {
48
- this.allSelected = false;
49
- if (this.selectedFilters.includes(selectedOption)) {
50
- this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
51
- }
52
- else {
53
- this.selectedFilters = [...this.selectedFilters, selectedOption];
54
- }
55
- }
56
- componentWillLoad() {
57
- this.displayedFilterSettings = this.parseFilterOptions();
58
- if (this.defaultFilterOptions !== undefined) {
59
- const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
60
- this.selectedFilters = parsedDefaultFilterOptions;
61
- let allSelected = true;
62
- this.parseFilterOptions().map(filterOption => {
63
- if (!this.selectedFilters.includes(filterOption.optionText)) {
64
- allSelected = false;
65
- }
66
- });
67
- this.allSelected = allSelected;
68
- }
69
- else {
70
- this.allSelected = true;
71
- this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
72
- }
73
- }
74
- togglePopover() {
75
- this.showPopover = !this.showPopover;
76
- // if(!this.showPopover) {
77
- // // this._focussedElementIndex = -1;
78
- // }
79
- }
80
- // Commented out keyboard interaction for now
81
- // @Listen('keyup')
82
- // handleKeyUp(event: KeyboardEvent) {
83
- // const keyboardEventValue = event.key;
84
- // if (document.activeElement.id != `filter__${this.filterKey}`) return;
85
- // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
86
- // if (this._focussedElementIndex == 0) {
87
- // this.onSelectAllClick()
88
- // } else {
89
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
90
- // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
91
- // }
92
- // return;
93
- // }
94
- // switch (keyboardEventValue) {
95
- // case 'Enter':
96
- // if(!this.showPopover) {
97
- // this.showPopover=true
98
- // } else {
99
- // this.emitFilterEvent()
100
- // }
101
- // break;
102
- // case 'Escape':
103
- // this.showPopover = false;
104
- // this._focussedElementIndex = -1;
105
- // break;
106
- // case 'ArrowDown':
107
- // this.showPopover = true;
108
- // if (this._focussedElementIndex == -1) {
109
- // this._focussedElementIndex = 0;
110
- // } else {
111
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
112
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
113
- // currentOption.blur();
114
- // // options[this._focussedElementIndex].focus();
115
- // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
116
- // }
117
- // break;
118
- // case 'ArrowUp':
119
- // if (this._focussedElementIndex == -1) {
120
- // this.showPopover = true;
121
- // this._focussedElementIndex = 0;
122
- // } else {
123
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
124
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
125
- // currentOption.blur();
126
- // // options[this._focussedElementIndex].focus();
127
- // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
128
- // }
129
- // break;
130
- // }
131
- // }
132
- handleFilterChange(event) {
133
- const target = event.target;
134
- this.filterSearchTerm = target.value;
135
- const filteredResults = this.parseFilterOptions().filter((filterOption) => {
136
- const lowercaseOption = filterOption.optionText.toLowerCase();
137
- const filterTerm = this.filterSearchTerm.toLowerCase();
138
- return lowercaseOption.includes(filterTerm);
139
- });
140
- this.displayedFilterSettings = filteredResults;
141
- }
142
- onSelectAllClick() {
143
- this.allSelected = !this.allSelected;
144
- if (this.allSelected) {
145
- this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
146
- }
147
- else {
148
- this.selectedFilters = [];
149
- }
150
- }
151
- getFilterButtonClassName(buttonStyle) {
152
- switch (buttonStyle) {
153
- case 'table icon': {
154
- return '--table-icon';
155
- }
156
- case 'list icon': {
157
- return '--list-icon';
158
- }
159
- default: {
160
- return '';
161
- }
162
- }
163
- }
164
- parseFilterOptions() {
165
- return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
166
- }
167
- parseDefaultFilterOptions() {
168
- return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
169
- }
170
- render() {
171
- const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
172
- const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
173
- const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
174
- const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
175
- const filterKey = `filter__${this.filterKey}`;
176
- return (h(Host, { id: filterKey }, h("div", { class: 'filter-container' }, h("button", { class: `filter-button ${buttonStyleClassNameModifier}`, type: 'button', onClick: this.onFilterButtonClick.bind(this) }, h("tttx-icon", { icon: 'filter_list', class: 'filter-icon', color: 'black' }), "Filter"), this.showPopover && (h("div", { class: `filter-popover-container ${filterPopoverContainerClassNameModifier}` }, h("div", { class: 'filter-header' }, this.filterHeader), this.showSearchField ? (h("div", { class: 'search-field-container' }, h("tttx-icon", { icon: 'search', class: 'search-icon' }), h("input", { type: 'text', class: 'search-input', placeholder: 'Search', value: this.filterSearchTerm, onInput: this.handleFilterChange.bind(this) }))) : (''), h("div", { class: 'filter-options-container' }, this.showSelectAll ? (h("div", { class: 'filter-option', tabIndex: -1, onClick: this.onSelectAllClick.bind(this) }, h("tttx-icon", { icon: selectAllCheckboxIcon, color: selectAllCheckboxColor, class: 'select-all-icon' }), h("label", { class: 'filter-label' }, "Select all"))) : (''), this.displayedFilterSettings.map((option) => {
177
- const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
178
- const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
179
- 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));
180
- })), 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")))))));
181
- }
182
- get el() { return this; }
183
- static get style() { return tttxFilterCss; }
184
- }, [1, "tttx-filter", {
185
- "filterKey": [1, "filter-key"],
186
- "filterOptions": [1, "filter-options"],
187
- "showSelectAll": [4, "show-select-all"],
188
- "showSearchField": [4, "show-search-field"],
189
- "showOptionIcons": [4, "show-option-icons"],
190
- "filterButtonStyle": [1, "filter-button-style"],
191
- "filterHeader": [1, "filter-header"],
192
- "defaultFilterOptions": [1, "default-filter-options"],
193
- "showPopover": [32],
194
- "displayedFilterSettings": [32],
195
- "selectedFilters": [32],
196
- "filterSearchTerm": [32],
197
- "allSelected": [32]
198
- }]);
199
- function defineCustomElement$1() {
200
- if (typeof customElements === "undefined") {
201
- return;
202
- }
203
- const components = ["tttx-filter", "tttx-icon"];
204
- components.forEach(tagName => { switch (tagName) {
205
- case "tttx-filter":
206
- if (!customElements.get(tagName)) {
207
- customElements.define(tagName, TttxFilter$1);
208
- }
209
- break;
210
- case "tttx-icon":
211
- if (!customElements.get(tagName)) {
212
- defineCustomElement$2();
213
- }
214
- break;
215
- } });
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.showPopover = false;
25
+ this.displayedFilterSettings = undefined;
26
+ this.selectedFilters = undefined;
27
+ this.filterSearchTerm = '';
28
+ this.allSelected = undefined;
29
+ }
30
+ emitFilterEvent() {
31
+ this.filterChangeEvent.emit({
32
+ selectedFilters: this.selectedFilters,
33
+ filterKey: this.filterKey,
34
+ allSelected: this.allSelected,
35
+ });
36
+ }
37
+ onFilterButtonClick() {
38
+ this.togglePopover();
39
+ }
40
+ onCloseButtonClick() {
41
+ this.togglePopover();
42
+ }
43
+ onApplyFilterButtonClick() {
44
+ this.emitFilterEvent();
45
+ this.togglePopover();
46
+ }
47
+ onFilterOptionSelected(selectedOption) {
48
+ this.allSelected = false;
49
+ if (this.selectedFilters.includes(selectedOption)) {
50
+ this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
51
+ }
52
+ else {
53
+ this.selectedFilters = [...this.selectedFilters, selectedOption];
54
+ }
55
+ }
56
+ componentWillLoad() {
57
+ this.displayedFilterSettings = this.parseFilterOptions();
58
+ if (this.defaultFilterOptions !== undefined) {
59
+ const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
60
+ this.selectedFilters = parsedDefaultFilterOptions;
61
+ let allSelected = true;
62
+ this.parseFilterOptions().map(filterOption => {
63
+ if (!this.selectedFilters.includes(filterOption.optionText)) {
64
+ allSelected = false;
65
+ }
66
+ });
67
+ this.allSelected = allSelected;
68
+ }
69
+ else {
70
+ this.allSelected = true;
71
+ this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
72
+ }
73
+ }
74
+ togglePopover() {
75
+ this.showPopover = !this.showPopover;
76
+ // if(!this.showPopover) {
77
+ // // this._focussedElementIndex = -1;
78
+ // }
79
+ }
80
+ // Commented out keyboard interaction for now
81
+ // @Listen('keyup')
82
+ // handleKeyUp(event: KeyboardEvent) {
83
+ // const keyboardEventValue = event.key;
84
+ // if (document.activeElement.id != `filter__${this.filterKey}`) return;
85
+ // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
86
+ // if (this._focussedElementIndex == 0) {
87
+ // this.onSelectAllClick()
88
+ // } else {
89
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
90
+ // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
91
+ // }
92
+ // return;
93
+ // }
94
+ // switch (keyboardEventValue) {
95
+ // case 'Enter':
96
+ // if(!this.showPopover) {
97
+ // this.showPopover=true
98
+ // } else {
99
+ // this.emitFilterEvent()
100
+ // }
101
+ // break;
102
+ // case 'Escape':
103
+ // this.showPopover = false;
104
+ // this._focussedElementIndex = -1;
105
+ // break;
106
+ // case 'ArrowDown':
107
+ // this.showPopover = true;
108
+ // if (this._focussedElementIndex == -1) {
109
+ // this._focussedElementIndex = 0;
110
+ // } else {
111
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
112
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
113
+ // currentOption.blur();
114
+ // // options[this._focussedElementIndex].focus();
115
+ // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
116
+ // }
117
+ // break;
118
+ // case 'ArrowUp':
119
+ // if (this._focussedElementIndex == -1) {
120
+ // this.showPopover = true;
121
+ // this._focussedElementIndex = 0;
122
+ // } else {
123
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
124
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
125
+ // currentOption.blur();
126
+ // // options[this._focussedElementIndex].focus();
127
+ // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
128
+ // }
129
+ // break;
130
+ // }
131
+ // }
132
+ handleFilterChange(event) {
133
+ const target = event.target;
134
+ this.filterSearchTerm = target.value;
135
+ const filteredResults = this.parseFilterOptions().filter((filterOption) => {
136
+ const lowercaseOption = filterOption.optionText.toLowerCase();
137
+ const filterTerm = this.filterSearchTerm.toLowerCase();
138
+ return lowercaseOption.includes(filterTerm);
139
+ });
140
+ this.displayedFilterSettings = filteredResults;
141
+ }
142
+ onSelectAllClick() {
143
+ this.allSelected = !this.allSelected;
144
+ if (this.allSelected) {
145
+ this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
146
+ }
147
+ else {
148
+ this.selectedFilters = [];
149
+ }
150
+ }
151
+ getFilterButtonClassName(buttonStyle) {
152
+ switch (buttonStyle) {
153
+ case 'table icon': {
154
+ return '--table-icon';
155
+ }
156
+ case 'list icon': {
157
+ return '--list-icon';
158
+ }
159
+ default: {
160
+ return '';
161
+ }
162
+ }
163
+ }
164
+ parseFilterOptions() {
165
+ return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
166
+ }
167
+ parseDefaultFilterOptions() {
168
+ return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
169
+ }
170
+ render() {
171
+ const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
172
+ const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
173
+ const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
174
+ const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
175
+ const filterKey = `filter__${this.filterKey}`;
176
+ return (h(Host, { id: filterKey }, h("div", { class: 'filter-container' }, h("button", { class: `filter-button ${buttonStyleClassNameModifier}`, type: 'button', onClick: this.onFilterButtonClick.bind(this) }, h("tttx-icon", { icon: 'filter_list', class: 'filter-icon', color: 'black' }), "Filter"), this.showPopover && (h("div", { class: `filter-popover-container ${filterPopoverContainerClassNameModifier}` }, h("div", { class: 'filter-header' }, this.filterHeader), this.showSearchField ? (h("div", { class: 'search-field-container' }, h("tttx-icon", { icon: 'search', class: 'search-icon' }), h("input", { type: 'text', class: 'search-input', placeholder: 'Search', value: this.filterSearchTerm, onInput: this.handleFilterChange.bind(this) }))) : (''), h("div", { class: 'filter-options-container' }, this.showSelectAll ? (h("div", { class: 'filter-option', tabIndex: -1, onClick: this.onSelectAllClick.bind(this) }, h("tttx-icon", { icon: selectAllCheckboxIcon, color: selectAllCheckboxColor, class: 'select-all-icon' }), h("label", { class: 'filter-label' }, "Select all"))) : (''), this.displayedFilterSettings.map((option) => {
177
+ const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
178
+ const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
179
+ 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));
180
+ })), 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")))))));
181
+ }
182
+ get el() { return this; }
183
+ static get style() { return tttxFilterCss; }
184
+ }, [1, "tttx-filter", {
185
+ "filterKey": [1, "filter-key"],
186
+ "filterOptions": [1, "filter-options"],
187
+ "showSelectAll": [4, "show-select-all"],
188
+ "showSearchField": [4, "show-search-field"],
189
+ "showOptionIcons": [4, "show-option-icons"],
190
+ "filterButtonStyle": [1, "filter-button-style"],
191
+ "filterHeader": [1, "filter-header"],
192
+ "defaultFilterOptions": [1, "default-filter-options"],
193
+ "showPopover": [32],
194
+ "displayedFilterSettings": [32],
195
+ "selectedFilters": [32],
196
+ "filterSearchTerm": [32],
197
+ "allSelected": [32]
198
+ }]);
199
+ function defineCustomElement$1() {
200
+ if (typeof customElements === "undefined") {
201
+ return;
202
+ }
203
+ const components = ["tttx-filter", "tttx-icon"];
204
+ components.forEach(tagName => { switch (tagName) {
205
+ case "tttx-filter":
206
+ if (!customElements.get(tagName)) {
207
+ customElements.define(tagName, TttxFilter$1);
208
+ }
209
+ break;
210
+ case "tttx-icon":
211
+ if (!customElements.get(tagName)) {
212
+ defineCustomElement$2();
213
+ }
214
+ break;
215
+ } });
216
216
  }
217
217
 
218
218
  const TttxFilter = TttxFilter$1;