@3t-transform/threeteeui 0.1.41 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/cjs/{domsanitiser.options-277161b9.js → domsanitiser.options-975e3317.js} +12 -12
  2. package/dist/cjs/{index-76f14107.js → index-457ca775.js} +88 -2
  3. package/dist/cjs/loader.cjs.js +4 -3
  4. package/dist/cjs/tttx-button.cjs.entry.js +24 -24
  5. package/dist/cjs/tttx-filter.cjs.entry.js +177 -159
  6. package/dist/cjs/tttx-form.cjs.entry.js +458 -456
  7. package/dist/cjs/tttx-icon.cjs.entry.js +11 -11
  8. package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +59 -59
  9. package/dist/cjs/tttx-list.cjs.entry.js +32 -32
  10. package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
  11. package/dist/cjs/tttx-sorter.cjs.entry.js +102 -102
  12. package/dist/cjs/tttx-standalone-input.cjs.entry.js +79 -79
  13. package/dist/cjs/tttx-toolbar.cjs.entry.js +10 -10
  14. package/dist/cjs/tttx.cjs.js +7 -3
  15. package/dist/collection/collection-manifest.json +2 -2
  16. package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -110
  17. package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
  18. package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
  19. package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
  20. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +109 -109
  21. package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
  22. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
  23. package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
  24. package/dist/collection/components/molecules/tttx-filter/tttx-filter.js +369 -334
  25. package/dist/collection/components/molecules/tttx-filter/tttx-filter.stories.js +73 -62
  26. package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +37 -37
  27. package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +61 -61
  28. package/dist/collection/components/molecules/tttx-form/tttx-form.js +479 -477
  29. package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +272 -272
  30. package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
  31. package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
  32. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.js +224 -224
  33. package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.stories.js +42 -42
  34. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +759 -759
  35. package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +172 -172
  36. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +44 -44
  37. package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +14 -14
  38. package/dist/collection/components/palette.stories.js +7 -7
  39. package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
  40. package/dist/collection/icons.js +2838 -2838
  41. package/dist/collection/index.js +1 -1
  42. package/dist/collection/shared/domsanitiser.options.js +14 -14
  43. package/dist/components/domsanitiser.options.js +12 -12
  44. package/dist/components/index.d.ts +9 -0
  45. package/dist/components/index.js +1 -1
  46. package/dist/components/tttx-button.js +48 -48
  47. package/dist/components/tttx-filter.js +210 -191
  48. package/dist/components/tttx-form.js +475 -473
  49. package/dist/components/tttx-icon2.js +28 -28
  50. package/dist/components/tttx-keyvalue-block.js +76 -76
  51. package/dist/components/tttx-list.js +53 -53
  52. package/dist/components/tttx-loading-spinner.js +33 -33
  53. package/dist/components/tttx-sorter.js +130 -130
  54. package/dist/components/tttx-standalone-input.js +130 -130
  55. package/dist/components/tttx-toolbar.js +26 -26
  56. package/dist/esm/{domsanitiser.options-cc420431.js → domsanitiser.options-3c7ded83.js} +12 -12
  57. package/dist/esm/{index-9cde46a5.js → index-d784fb3e.js} +88 -3
  58. package/dist/esm/loader.js +4 -3
  59. package/dist/esm/polyfills/core-js.js +0 -0
  60. package/dist/esm/polyfills/css-shim.js +1 -1
  61. package/dist/esm/polyfills/dom.js +0 -0
  62. package/dist/esm/polyfills/es5-html-element.js +0 -0
  63. package/dist/esm/polyfills/index.js +0 -0
  64. package/dist/esm/polyfills/system.js +0 -0
  65. package/dist/esm/tttx-button.entry.js +24 -24
  66. package/dist/esm/tttx-filter.entry.js +177 -159
  67. package/dist/esm/tttx-form.entry.js +458 -456
  68. package/dist/esm/tttx-icon.entry.js +11 -11
  69. package/dist/esm/tttx-keyvalue-block.entry.js +59 -59
  70. package/dist/esm/tttx-list.entry.js +32 -32
  71. package/dist/esm/tttx-loading-spinner.entry.js +16 -16
  72. package/dist/esm/tttx-sorter.entry.js +102 -102
  73. package/dist/esm/tttx-standalone-input.entry.js +79 -79
  74. package/dist/esm/tttx-toolbar.entry.js +10 -10
  75. package/dist/esm/tttx.js +4 -3
  76. package/dist/tttx/p-0ebffdfc.js +2 -0
  77. package/dist/tttx/{p-dc2a37b0.entry.js → p-1db3704e.entry.js} +1 -1
  78. package/dist/tttx/p-350ddb03.js +3 -0
  79. package/dist/tttx/{p-561224f5.entry.js → p-563605b2.entry.js} +1 -1
  80. package/dist/tttx/{p-aef96333.entry.js → p-798a098a.entry.js} +1 -1
  81. package/dist/tttx/{p-f885f17a.entry.js → p-92cade7f.entry.js} +1 -1
  82. package/dist/tttx/{p-bd1edaed.entry.js → p-aaf02902.entry.js} +1 -1
  83. package/dist/tttx/{p-e53c7f9d.entry.js → p-ab6ce9f6.entry.js} +1 -1
  84. package/dist/tttx/{p-9f1e9cc1.entry.js → p-b720c4ad.entry.js} +1 -1
  85. package/dist/tttx/{p-d2f1aa8e.entry.js → p-cac26a1b.entry.js} +1 -1
  86. package/dist/tttx/p-ec253eea.entry.js +1 -0
  87. package/dist/tttx/p-f702df4f.entry.js +1 -0
  88. package/dist/tttx/tttx.esm.js +1 -1
  89. package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -10
  90. package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
  91. package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
  92. package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
  93. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
  94. package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
  95. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
  96. package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
  97. package/dist/types/components/molecules/tttx-filter/tttx-filter.d.ts +41 -39
  98. package/dist/types/components/molecules/tttx-filter/tttx-filter.stories.d.ts +70 -68
  99. package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
  100. package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
  101. package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +133 -133
  102. package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +278 -278
  103. package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +11 -11
  104. package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +14 -14
  105. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.d.ts +19 -19
  106. package/dist/types/components/molecules/tttx-sorter/tttx-sorter.stories.d.ts +30 -30
  107. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +69 -69
  108. package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +143 -143
  109. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -4
  110. package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -13
  111. package/dist/types/components/palette.stories.d.ts +6 -6
  112. package/dist/types/components.d.ts +2 -0
  113. package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
  114. package/dist/types/icons.d.ts +2 -2
  115. package/dist/types/index.d.ts +1 -1
  116. package/dist/types/shared/domsanitiser.options.d.ts +10 -10
  117. package/dist/types/stencil-public-runtime.d.ts +59 -3
  118. package/loader/index.d.ts +9 -0
  119. package/package.json +2 -2
  120. package/dist/tttx/p-3b1be372.entry.js +0 -1
  121. package/dist/tttx/p-b4290a5b.js +0 -3
  122. package/dist/tttx/p-d0ff9ad0.entry.js +0 -1
  123. package/dist/tttx/p-db059a69.js +0 -2
@@ -2,168 +2,186 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-76f14107.js');
5
+ const index = require('./index-457ca775.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}@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}";
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.showPopover = false;
25
- this.displayedFilterSettings = undefined;
26
- this.selectedFilters = undefined;
27
- this.filterSearchTerm = '';
28
- this.allSelected = true;
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
- this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
59
- }
60
- togglePopover() {
61
- this.showPopover = !this.showPopover;
62
- // if(!this.showPopover) {
63
- // // this._focussedElementIndex = -1;
64
- // }
65
- }
66
- // Commented out keyboard interaction for now
67
- // @Listen('keyup')
68
- // handleKeyUp(event: KeyboardEvent) {
69
- // const keyboardEventValue = event.key;
70
- // if (document.activeElement.id != `filter__${this.filterKey}`) return;
71
- // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
72
- // if (this._focussedElementIndex == 0) {
73
- // this.onSelectAllClick()
74
- // } else {
75
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
76
- // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
77
- // }
78
- // return;
79
- // }
80
- // switch (keyboardEventValue) {
81
- // case 'Enter':
82
- // if(!this.showPopover) {
83
- // this.showPopover=true
84
- // } else {
85
- // this.emitFilterEvent()
86
- // }
87
- // break;
88
- // case 'Escape':
89
- // this.showPopover = false;
90
- // this._focussedElementIndex = -1;
91
- // break;
92
- // case 'ArrowDown':
93
- // this.showPopover = true;
94
- // if (this._focussedElementIndex == -1) {
95
- // this._focussedElementIndex = 0;
96
- // } else {
97
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
98
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
99
- // currentOption.blur();
100
- // // options[this._focussedElementIndex].focus();
101
- // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
102
- // }
103
- // break;
104
- // case 'ArrowUp':
105
- // if (this._focussedElementIndex == -1) {
106
- // this.showPopover = true;
107
- // this._focussedElementIndex = 0;
108
- // } else {
109
- // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
110
- // const currentOption = options[this._focussedElementIndex] as HTMLElement;
111
- // currentOption.blur();
112
- // // options[this._focussedElementIndex].focus();
113
- // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
114
- // }
115
- // break;
116
- // }
117
- // }
118
- handleFilterChange(event) {
119
- const target = event.target;
120
- this.filterSearchTerm = target.value;
121
- const filteredResults = this.parseFilterOptions().filter((filterOption) => {
122
- const lowercaseOption = filterOption.optionText.toLowerCase();
123
- const filterTerm = this.filterSearchTerm.toLowerCase();
124
- return lowercaseOption.includes(filterTerm);
125
- });
126
- this.displayedFilterSettings = filteredResults;
127
- }
128
- onSelectAllClick() {
129
- this.allSelected = !this.allSelected;
130
- if (this.allSelected) {
131
- this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
132
- }
133
- else {
134
- this.selectedFilters = [];
135
- }
136
- }
137
- getFilterButtonClassName(buttonStyle) {
138
- switch (buttonStyle) {
139
- case 'table icon': {
140
- return '--table-icon';
141
- }
142
- case 'list icon': {
143
- return '--list-icon';
144
- }
145
- default: {
146
- return '';
147
- }
148
- }
149
- }
150
- parseFilterOptions() {
151
- return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
152
- }
153
- render() {
154
- const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
155
- const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
156
- const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
157
- const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
158
- const filterKey = `filter__${this.filterKey}`;
159
- 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}` }, 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) => {
160
- const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
161
- const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
162
- 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));
163
- })), 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")))))));
164
- }
165
- get el() { return index.getElement(this); }
166
- };
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.showPopover = false;
26
+ this.displayedFilterSettings = undefined;
27
+ this.selectedFilters = undefined;
28
+ this.filterSearchTerm = '';
29
+ this.allSelected = undefined;
30
+ }
31
+ emitFilterEvent() {
32
+ this.filterChangeEvent.emit({
33
+ selectedFilters: this.selectedFilters,
34
+ filterKey: this.filterKey,
35
+ allSelected: this.allSelected,
36
+ });
37
+ }
38
+ onFilterButtonClick() {
39
+ this.togglePopover();
40
+ }
41
+ onCloseButtonClick() {
42
+ this.togglePopover();
43
+ }
44
+ onApplyFilterButtonClick() {
45
+ this.emitFilterEvent();
46
+ this.togglePopover();
47
+ }
48
+ onFilterOptionSelected(selectedOption) {
49
+ this.allSelected = false;
50
+ if (this.selectedFilters.includes(selectedOption)) {
51
+ this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
52
+ }
53
+ else {
54
+ this.selectedFilters = [...this.selectedFilters, selectedOption];
55
+ }
56
+ }
57
+ componentWillLoad() {
58
+ this.displayedFilterSettings = this.parseFilterOptions();
59
+ if (this.defaultFilterOptions !== undefined) {
60
+ const parsedDefaultFilterOptions = this.parseDefaultFilterOptions();
61
+ this.selectedFilters = parsedDefaultFilterOptions;
62
+ let allSelected = true;
63
+ this.parseFilterOptions().map(filterOption => {
64
+ if (!this.selectedFilters.includes(filterOption.optionText)) {
65
+ allSelected = false;
66
+ }
67
+ });
68
+ this.allSelected = allSelected;
69
+ }
70
+ else {
71
+ this.allSelected = true;
72
+ this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
73
+ }
74
+ }
75
+ togglePopover() {
76
+ this.showPopover = !this.showPopover;
77
+ // if(!this.showPopover) {
78
+ // // this._focussedElementIndex = -1;
79
+ // }
80
+ }
81
+ // Commented out keyboard interaction for now
82
+ // @Listen('keyup')
83
+ // handleKeyUp(event: KeyboardEvent) {
84
+ // const keyboardEventValue = event.key;
85
+ // if (document.activeElement.id != `filter__${this.filterKey}`) return;
86
+ // if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
87
+ // if (this._focussedElementIndex == 0) {
88
+ // this.onSelectAllClick()
89
+ // } else {
90
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
91
+ // this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
92
+ // }
93
+ // return;
94
+ // }
95
+ // switch (keyboardEventValue) {
96
+ // case 'Enter':
97
+ // if(!this.showPopover) {
98
+ // this.showPopover=true
99
+ // } else {
100
+ // this.emitFilterEvent()
101
+ // }
102
+ // break;
103
+ // case 'Escape':
104
+ // this.showPopover = false;
105
+ // this._focussedElementIndex = -1;
106
+ // break;
107
+ // case 'ArrowDown':
108
+ // this.showPopover = true;
109
+ // if (this._focussedElementIndex == -1) {
110
+ // this._focussedElementIndex = 0;
111
+ // } else {
112
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
113
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
114
+ // currentOption.blur();
115
+ // // options[this._focussedElementIndex].focus();
116
+ // this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
117
+ // }
118
+ // break;
119
+ // case 'ArrowUp':
120
+ // if (this._focussedElementIndex == -1) {
121
+ // this.showPopover = true;
122
+ // this._focussedElementIndex = 0;
123
+ // } else {
124
+ // const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
125
+ // const currentOption = options[this._focussedElementIndex] as HTMLElement;
126
+ // currentOption.blur();
127
+ // // options[this._focussedElementIndex].focus();
128
+ // this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
129
+ // }
130
+ // break;
131
+ // }
132
+ // }
133
+ handleFilterChange(event) {
134
+ const target = event.target;
135
+ this.filterSearchTerm = target.value;
136
+ const filteredResults = this.parseFilterOptions().filter((filterOption) => {
137
+ const lowercaseOption = filterOption.optionText.toLowerCase();
138
+ const filterTerm = this.filterSearchTerm.toLowerCase();
139
+ return lowercaseOption.includes(filterTerm);
140
+ });
141
+ this.displayedFilterSettings = filteredResults;
142
+ }
143
+ onSelectAllClick() {
144
+ this.allSelected = !this.allSelected;
145
+ if (this.allSelected) {
146
+ this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
147
+ }
148
+ else {
149
+ this.selectedFilters = [];
150
+ }
151
+ }
152
+ getFilterButtonClassName(buttonStyle) {
153
+ switch (buttonStyle) {
154
+ case 'table icon': {
155
+ return '--table-icon';
156
+ }
157
+ case 'list icon': {
158
+ return '--list-icon';
159
+ }
160
+ default: {
161
+ return '';
162
+ }
163
+ }
164
+ }
165
+ parseFilterOptions() {
166
+ return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
167
+ }
168
+ parseDefaultFilterOptions() {
169
+ return typeof this.defaultFilterOptions === 'string' ? JSON.parse(this.defaultFilterOptions) : this.defaultFilterOptions;
170
+ }
171
+ render() {
172
+ const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
173
+ const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
174
+ const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
175
+ const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
176
+ const filterKey = `filter__${this.filterKey}`;
177
+ return (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}` }, 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) => {
178
+ const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
179
+ const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
180
+ return 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));
181
+ })), 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")))))));
182
+ }
183
+ get el() { return index.getElement(this); }
184
+ };
167
185
  TttxFilter.style = tttxFilterCss;
168
186
 
169
187
  exports.tttx_filter = TttxFilter;