@3t-transform/threeteeui 0.1.36 → 0.1.41
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.
- package/dist/cjs/domsanitiser.options-277161b9.js +1667 -0
- package/dist/cjs/{index-457ca775.js → index-76f14107.js} +2 -88
- package/dist/cjs/loader.cjs.js +2 -3
- package/dist/cjs/tttx-button.cjs.entry.js +25 -25
- package/dist/cjs/tttx-filter.cjs.entry.js +159 -159
- package/dist/cjs/tttx-form.cjs.entry.js +457 -373
- package/dist/cjs/tttx-icon.cjs.entry.js +11 -11
- package/dist/cjs/tttx-keyvalue-block.cjs.entry.js +59 -59
- package/dist/cjs/tttx-list.cjs.entry.js +32 -1694
- package/dist/cjs/tttx-loading-spinner.cjs.entry.js +16 -16
- package/dist/cjs/tttx-sorter.cjs.entry.js +102 -102
- package/dist/cjs/tttx-standalone-input.cjs.entry.js +79 -79
- package/dist/cjs/tttx-toolbar.cjs.entry.js +10 -10
- package/dist/cjs/tttx.cjs.js +2 -6
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/atoms/tttx-button/tttx-button.css +4 -4
- package/dist/collection/components/atoms/tttx-button/tttx-button.js +110 -110
- package/dist/collection/components/atoms/tttx-button/tttx-button.stories.js +14 -14
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.js +62 -62
- package/dist/collection/components/atoms/tttx-icon/tttx-icon.stories.js +22 -22
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.js +109 -109
- package/dist/collection/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.js +38 -38
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.js +67 -67
- package/dist/collection/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.js +17 -17
- package/dist/collection/components/molecules/tttx-filter/tttx-filter.js +334 -334
- package/dist/collection/components/molecules/tttx-filter/tttx-filter.stories.js +62 -62
- package/dist/collection/components/molecules/tttx-form/lib/setErrorState.js +37 -37
- package/dist/collection/components/molecules/tttx-form/lib/validityCheck.js +61 -58
- package/dist/collection/components/molecules/tttx-form/tttx-form.css +98 -2
- package/dist/collection/components/molecules/tttx-form/tttx-form.js +477 -393
- package/dist/collection/components/molecules/tttx-form/tttx-form.stories.js +274 -218
- package/dist/collection/components/molecules/tttx-list/tttx-list.js +105 -105
- package/dist/collection/components/molecules/tttx-list/tttx-list.stories.js +43 -43
- package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.js +224 -224
- package/dist/collection/components/molecules/tttx-sorter/tttx-sorter.stories.js +42 -42
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.js +759 -759
- package/dist/collection/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.js +172 -172
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.js +44 -44
- package/dist/collection/components/molecules/tttx-toolbar/tttx-toolbar.stories.js +14 -14
- package/dist/collection/components/palette.stories.js +7 -7
- package/dist/collection/docs/gettingstarted-developer.stories.js +5 -5
- package/dist/collection/icons.js +2838 -2838
- package/dist/collection/index.js +1 -1
- package/dist/collection/shared/domsanitiser.options.js +14 -14
- package/dist/components/domsanitiser.options.js +1664 -0
- package/dist/components/index.d.ts +0 -9
- package/dist/components/index.js +1 -1
- package/dist/components/tttx-button.js +49 -49
- package/dist/components/tttx-filter.js +191 -191
- package/dist/components/tttx-form.js +475 -391
- package/dist/components/tttx-icon2.js +28 -28
- package/dist/components/tttx-keyvalue-block.js +76 -76
- package/dist/components/tttx-list.js +54 -1716
- package/dist/components/tttx-loading-spinner.js +33 -33
- package/dist/components/tttx-sorter.js +130 -130
- package/dist/components/tttx-standalone-input.js +130 -130
- package/dist/components/tttx-toolbar.js +26 -26
- package/dist/esm/domsanitiser.options-cc420431.js +1664 -0
- package/dist/esm/{index-d784fb3e.js → index-9cde46a5.js} +3 -88
- package/dist/esm/loader.js +2 -3
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/tttx-button.entry.js +25 -25
- package/dist/esm/tttx-filter.entry.js +159 -159
- package/dist/esm/tttx-form.entry.js +457 -373
- package/dist/esm/tttx-icon.entry.js +11 -11
- package/dist/esm/tttx-keyvalue-block.entry.js +59 -59
- package/dist/esm/tttx-list.entry.js +32 -1694
- package/dist/esm/tttx-loading-spinner.entry.js +16 -16
- package/dist/esm/tttx-sorter.entry.js +102 -102
- package/dist/esm/tttx-standalone-input.entry.js +79 -79
- package/dist/esm/tttx-toolbar.entry.js +10 -10
- package/dist/esm/tttx.js +2 -3
- package/dist/tttx/{p-400868f1.entry.js → p-3b1be372.entry.js} +1 -1
- package/dist/tttx/{p-563605b2.entry.js → p-561224f5.entry.js} +1 -1
- package/dist/tttx/{p-b720c4ad.entry.js → p-9f1e9cc1.entry.js} +1 -1
- package/dist/tttx/{p-798a098a.entry.js → p-aef96333.entry.js} +1 -1
- package/dist/tttx/p-b4290a5b.js +3 -0
- package/dist/tttx/p-bd1edaed.entry.js +1 -0
- package/dist/tttx/p-d0ff9ad0.entry.js +1 -0
- package/dist/tttx/{p-cac26a1b.entry.js → p-d2f1aa8e.entry.js} +1 -1
- package/dist/tttx/p-db059a69.js +2 -0
- package/dist/tttx/p-dc2a37b0.entry.js +1 -0
- package/dist/tttx/{p-ab6ce9f6.entry.js → p-e53c7f9d.entry.js} +1 -1
- package/dist/tttx/{p-92cade7f.entry.js → p-f885f17a.entry.js} +1 -1
- package/dist/tttx/tttx.esm.js +1 -1
- package/dist/types/components/atoms/tttx-button/tttx-button.d.ts +10 -10
- package/dist/types/components/atoms/tttx-button/tttx-button.stories.d.ts +10 -10
- package/dist/types/components/atoms/tttx-icon/tttx-icon.d.ts +5 -5
- package/dist/types/components/atoms/tttx-icon/tttx-icon.stories.d.ts +20 -20
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.d.ts +7 -7
- package/dist/types/components/atoms/tttx-keyvalue-block/tttx-keyvalue-block.stories.d.ts +9 -9
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.d.ts +6 -6
- package/dist/types/components/atoms/tttx-loading-spinner/tttx-loading-spinner.stories.d.ts +17 -17
- package/dist/types/components/molecules/tttx-filter/tttx-filter.d.ts +39 -39
- package/dist/types/components/molecules/tttx-filter/tttx-filter.stories.d.ts +68 -68
- package/dist/types/components/molecules/tttx-form/lib/setErrorState.d.ts +13 -13
- package/dist/types/components/molecules/tttx-form/lib/validityCheck.d.ts +17 -17
- package/dist/types/components/molecules/tttx-form/tttx-form.d.ts +133 -111
- package/dist/types/components/molecules/tttx-form/tttx-form.stories.d.ts +278 -13
- package/dist/types/components/molecules/tttx-list/tttx-list.d.ts +11 -11
- package/dist/types/components/molecules/tttx-list/tttx-list.stories.d.ts +14 -14
- package/dist/types/components/molecules/tttx-sorter/tttx-sorter.d.ts +19 -19
- package/dist/types/components/molecules/tttx-sorter/tttx-sorter.stories.d.ts +30 -30
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.d.ts +69 -69
- package/dist/types/components/molecules/tttx-standalone-input/tttx-standalone-input.stories.d.ts +143 -143
- package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.d.ts +4 -4
- package/dist/types/components/molecules/tttx-toolbar/tttx-toolbar.stories.d.ts +13 -13
- package/dist/types/components/palette.stories.d.ts +6 -6
- package/dist/types/components.d.ts +1 -1
- package/dist/types/docs/gettingstarted-developer.stories.d.ts +5 -5
- package/dist/types/icons.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/domsanitiser.options.d.ts +10 -10
- package/dist/types/stencil-public-runtime.d.ts +3 -59
- package/loader/index.d.ts +0 -9
- package/package.json +1 -1
- package/dist/tttx/p-0ebffdfc.js +0 -2
- package/dist/tttx/p-72e7f7dd.entry.js +0 -3
- package/dist/tttx/p-c4162029.entry.js +0 -1
- package/dist/tttx/p-eb126fd0.entry.js +0 -1
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-9cde46a5.js';
|
|
2
2
|
|
|
3
3
|
const tttxFilterCss = ".material-symbols-rounded{font-variation-settings:\"FILL\" 1, \"wght\" 400, \"GRAD\" 0, \"opsz\" 24}.material-symbols-rounded{font-family:\"Material Symbols Rounded\", sans-serif;font-weight:400;font-style:normal;font-size:24px;line-height:1;letter-spacing:normal;text-transform:none;display:inline-block;white-space:nowrap;word-wrap:normal;direction:ltr;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;color:#9e9e9e}.filter-container{background-color:white;position:relative}.filter-container .filter-button{display:inline-flex;justify-content:center;align-items:center;font-size:14px;font-weight:400;font-family:\"Roboto\", serif;text-transform:uppercase;color:#212121;border:1px solid #d5d5d5;border-radius:4px;background:transparent;height:36px;width:95px;margin:0;padding-right:16px}@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}";
|
|
4
4
|
|
|
5
|
-
const TttxFilter = class {
|
|
6
|
-
constructor(hostRef) {
|
|
7
|
-
registerInstance(this, hostRef);
|
|
8
|
-
this.filterChangeEvent = createEvent(this, "filterChangeEvent", 7);
|
|
9
|
-
this.filterKey = undefined;
|
|
10
|
-
this.filterOptions = [
|
|
11
|
-
{ optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
|
|
12
|
-
{ optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
|
|
13
|
-
{ optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
|
|
14
|
-
];
|
|
15
|
-
this.showSelectAll = true;
|
|
16
|
-
this.showSearchField = false;
|
|
17
|
-
this.showOptionIcons = true;
|
|
18
|
-
this.filterButtonStyle = 'list filter';
|
|
19
|
-
this.filterHeader = 'Qualification status';
|
|
20
|
-
this.showPopover = false;
|
|
21
|
-
this.displayedFilterSettings = undefined;
|
|
22
|
-
this.selectedFilters = undefined;
|
|
23
|
-
this.filterSearchTerm = '';
|
|
24
|
-
this.allSelected = true;
|
|
25
|
-
}
|
|
26
|
-
emitFilterEvent() {
|
|
27
|
-
this.filterChangeEvent.emit({
|
|
28
|
-
selectedFilters: this.selectedFilters,
|
|
29
|
-
filterKey: this.filterKey,
|
|
30
|
-
allSelected: this.allSelected,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
onFilterButtonClick() {
|
|
34
|
-
this.togglePopover();
|
|
35
|
-
}
|
|
36
|
-
onCloseButtonClick() {
|
|
37
|
-
this.togglePopover();
|
|
38
|
-
}
|
|
39
|
-
onApplyFilterButtonClick() {
|
|
40
|
-
this.emitFilterEvent();
|
|
41
|
-
this.togglePopover();
|
|
42
|
-
}
|
|
43
|
-
onFilterOptionSelected(selectedOption) {
|
|
44
|
-
this.allSelected = false;
|
|
45
|
-
if (this.selectedFilters.includes(selectedOption)) {
|
|
46
|
-
this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
this.selectedFilters = [...this.selectedFilters, selectedOption];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
componentWillLoad() {
|
|
53
|
-
this.displayedFilterSettings = this.parseFilterOptions();
|
|
54
|
-
this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
|
|
55
|
-
}
|
|
56
|
-
togglePopover() {
|
|
57
|
-
this.showPopover = !this.showPopover;
|
|
58
|
-
// if(!this.showPopover) {
|
|
59
|
-
// // this._focussedElementIndex = -1;
|
|
60
|
-
// }
|
|
61
|
-
}
|
|
62
|
-
// Commented out keyboard interaction for now
|
|
63
|
-
// @Listen('keyup')
|
|
64
|
-
// handleKeyUp(event: KeyboardEvent) {
|
|
65
|
-
// const keyboardEventValue = event.key;
|
|
66
|
-
// if (document.activeElement.id != `filter__${this.filterKey}`) return;
|
|
67
|
-
// if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
|
|
68
|
-
// if (this._focussedElementIndex == 0) {
|
|
69
|
-
// this.onSelectAllClick()
|
|
70
|
-
// } else {
|
|
71
|
-
// const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
|
|
72
|
-
// this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
|
|
73
|
-
// }
|
|
74
|
-
// return;
|
|
75
|
-
// }
|
|
76
|
-
// switch (keyboardEventValue) {
|
|
77
|
-
// case 'Enter':
|
|
78
|
-
// if(!this.showPopover) {
|
|
79
|
-
// this.showPopover=true
|
|
80
|
-
// } else {
|
|
81
|
-
// this.emitFilterEvent()
|
|
82
|
-
// }
|
|
83
|
-
// break;
|
|
84
|
-
// case 'Escape':
|
|
85
|
-
// this.showPopover = false;
|
|
86
|
-
// this._focussedElementIndex = -1;
|
|
87
|
-
// break;
|
|
88
|
-
// case 'ArrowDown':
|
|
89
|
-
// this.showPopover = true;
|
|
90
|
-
// if (this._focussedElementIndex == -1) {
|
|
91
|
-
// this._focussedElementIndex = 0;
|
|
92
|
-
// } else {
|
|
93
|
-
// const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
|
|
94
|
-
// const currentOption = options[this._focussedElementIndex] as HTMLElement;
|
|
95
|
-
// currentOption.blur();
|
|
96
|
-
// // options[this._focussedElementIndex].focus();
|
|
97
|
-
// this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
|
|
98
|
-
// }
|
|
99
|
-
// break;
|
|
100
|
-
// case 'ArrowUp':
|
|
101
|
-
// if (this._focussedElementIndex == -1) {
|
|
102
|
-
// this.showPopover = true;
|
|
103
|
-
// this._focussedElementIndex = 0;
|
|
104
|
-
// } else {
|
|
105
|
-
// const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
|
|
106
|
-
// const currentOption = options[this._focussedElementIndex] as HTMLElement;
|
|
107
|
-
// currentOption.blur();
|
|
108
|
-
// // options[this._focussedElementIndex].focus();
|
|
109
|
-
// this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
|
|
110
|
-
// }
|
|
111
|
-
// break;
|
|
112
|
-
// }
|
|
113
|
-
// }
|
|
114
|
-
handleFilterChange(event) {
|
|
115
|
-
const target = event.target;
|
|
116
|
-
this.filterSearchTerm = target.value;
|
|
117
|
-
const filteredResults = this.parseFilterOptions().filter((filterOption) => {
|
|
118
|
-
const lowercaseOption = filterOption.optionText.toLowerCase();
|
|
119
|
-
const filterTerm = this.filterSearchTerm.toLowerCase();
|
|
120
|
-
return lowercaseOption.includes(filterTerm);
|
|
121
|
-
});
|
|
122
|
-
this.displayedFilterSettings = filteredResults;
|
|
123
|
-
}
|
|
124
|
-
onSelectAllClick() {
|
|
125
|
-
this.allSelected = !this.allSelected;
|
|
126
|
-
if (this.allSelected) {
|
|
127
|
-
this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
this.selectedFilters = [];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
getFilterButtonClassName(buttonStyle) {
|
|
134
|
-
switch (buttonStyle) {
|
|
135
|
-
case 'table icon': {
|
|
136
|
-
return '--table-icon';
|
|
137
|
-
}
|
|
138
|
-
case 'list icon': {
|
|
139
|
-
return '--list-icon';
|
|
140
|
-
}
|
|
141
|
-
default: {
|
|
142
|
-
return '';
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
parseFilterOptions() {
|
|
147
|
-
return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
|
|
148
|
-
}
|
|
149
|
-
render() {
|
|
150
|
-
const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
|
|
151
|
-
const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
|
|
152
|
-
const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
|
|
153
|
-
const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
|
|
154
|
-
const filterKey = `filter__${this.filterKey}`;
|
|
155
|
-
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) => {
|
|
156
|
-
const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
|
|
157
|
-
const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
|
|
158
|
-
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));
|
|
159
|
-
})), 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")))))));
|
|
160
|
-
}
|
|
161
|
-
get el() { return getElement(this); }
|
|
162
|
-
};
|
|
5
|
+
const TttxFilter = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
8
|
+
this.filterChangeEvent = createEvent(this, "filterChangeEvent", 7);
|
|
9
|
+
this.filterKey = undefined;
|
|
10
|
+
this.filterOptions = [
|
|
11
|
+
{ optionIcon: 'cancel', optionIconColor: 'darkred', optionText: 'Expired' },
|
|
12
|
+
{ optionIcon: 'warning', optionIconColor: 'orange', optionText: 'Expiring soon' },
|
|
13
|
+
{ optionIcon: 'check_circle', optionIconColor: 'green', optionText: 'Active' },
|
|
14
|
+
];
|
|
15
|
+
this.showSelectAll = true;
|
|
16
|
+
this.showSearchField = false;
|
|
17
|
+
this.showOptionIcons = true;
|
|
18
|
+
this.filterButtonStyle = 'list filter';
|
|
19
|
+
this.filterHeader = 'Qualification status';
|
|
20
|
+
this.showPopover = false;
|
|
21
|
+
this.displayedFilterSettings = undefined;
|
|
22
|
+
this.selectedFilters = undefined;
|
|
23
|
+
this.filterSearchTerm = '';
|
|
24
|
+
this.allSelected = true;
|
|
25
|
+
}
|
|
26
|
+
emitFilterEvent() {
|
|
27
|
+
this.filterChangeEvent.emit({
|
|
28
|
+
selectedFilters: this.selectedFilters,
|
|
29
|
+
filterKey: this.filterKey,
|
|
30
|
+
allSelected: this.allSelected,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
onFilterButtonClick() {
|
|
34
|
+
this.togglePopover();
|
|
35
|
+
}
|
|
36
|
+
onCloseButtonClick() {
|
|
37
|
+
this.togglePopover();
|
|
38
|
+
}
|
|
39
|
+
onApplyFilterButtonClick() {
|
|
40
|
+
this.emitFilterEvent();
|
|
41
|
+
this.togglePopover();
|
|
42
|
+
}
|
|
43
|
+
onFilterOptionSelected(selectedOption) {
|
|
44
|
+
this.allSelected = false;
|
|
45
|
+
if (this.selectedFilters.includes(selectedOption)) {
|
|
46
|
+
this.selectedFilters = this.selectedFilters.filter((filter) => filter != selectedOption);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.selectedFilters = [...this.selectedFilters, selectedOption];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
componentWillLoad() {
|
|
53
|
+
this.displayedFilterSettings = this.parseFilterOptions();
|
|
54
|
+
this.selectedFilters = this.displayedFilterSettings.map((filterOption) => filterOption.optionText);
|
|
55
|
+
}
|
|
56
|
+
togglePopover() {
|
|
57
|
+
this.showPopover = !this.showPopover;
|
|
58
|
+
// if(!this.showPopover) {
|
|
59
|
+
// // this._focussedElementIndex = -1;
|
|
60
|
+
// }
|
|
61
|
+
}
|
|
62
|
+
// Commented out keyboard interaction for now
|
|
63
|
+
// @Listen('keyup')
|
|
64
|
+
// handleKeyUp(event: KeyboardEvent) {
|
|
65
|
+
// const keyboardEventValue = event.key;
|
|
66
|
+
// if (document.activeElement.id != `filter__${this.filterKey}`) return;
|
|
67
|
+
// if (event.key == " " || event.code == "Space" || event.keyCode == 32) {
|
|
68
|
+
// if (this._focussedElementIndex == 0) {
|
|
69
|
+
// this.onSelectAllClick()
|
|
70
|
+
// } else {
|
|
71
|
+
// const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
|
|
72
|
+
// this.onFilterOptionSelected(options[this._focussedElementIndex].textContent)
|
|
73
|
+
// }
|
|
74
|
+
// return;
|
|
75
|
+
// }
|
|
76
|
+
// switch (keyboardEventValue) {
|
|
77
|
+
// case 'Enter':
|
|
78
|
+
// if(!this.showPopover) {
|
|
79
|
+
// this.showPopover=true
|
|
80
|
+
// } else {
|
|
81
|
+
// this.emitFilterEvent()
|
|
82
|
+
// }
|
|
83
|
+
// break;
|
|
84
|
+
// case 'Escape':
|
|
85
|
+
// this.showPopover = false;
|
|
86
|
+
// this._focussedElementIndex = -1;
|
|
87
|
+
// break;
|
|
88
|
+
// case 'ArrowDown':
|
|
89
|
+
// this.showPopover = true;
|
|
90
|
+
// if (this._focussedElementIndex == -1) {
|
|
91
|
+
// this._focussedElementIndex = 0;
|
|
92
|
+
// } else {
|
|
93
|
+
// const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
|
|
94
|
+
// const currentOption = options[this._focussedElementIndex] as HTMLElement;
|
|
95
|
+
// currentOption.blur();
|
|
96
|
+
// // options[this._focussedElementIndex].focus();
|
|
97
|
+
// this._focussedElementIndex + 1 < options.length ? this._focussedElementIndex++ : (this._focussedElementIndex = 0);
|
|
98
|
+
// }
|
|
99
|
+
// break;
|
|
100
|
+
// case 'ArrowUp':
|
|
101
|
+
// if (this._focussedElementIndex == -1) {
|
|
102
|
+
// this.showPopover = true;
|
|
103
|
+
// this._focussedElementIndex = 0;
|
|
104
|
+
// } else {
|
|
105
|
+
// const options = this.el.shadowRoot.querySelectorAll('.filter-option') as HTMLElement[];
|
|
106
|
+
// const currentOption = options[this._focussedElementIndex] as HTMLElement;
|
|
107
|
+
// currentOption.blur();
|
|
108
|
+
// // options[this._focussedElementIndex].focus();
|
|
109
|
+
// this._focussedElementIndex > 0 ? this._focussedElementIndex-- : (this._focussedElementIndex = options.length - 1);
|
|
110
|
+
// }
|
|
111
|
+
// break;
|
|
112
|
+
// }
|
|
113
|
+
// }
|
|
114
|
+
handleFilterChange(event) {
|
|
115
|
+
const target = event.target;
|
|
116
|
+
this.filterSearchTerm = target.value;
|
|
117
|
+
const filteredResults = this.parseFilterOptions().filter((filterOption) => {
|
|
118
|
+
const lowercaseOption = filterOption.optionText.toLowerCase();
|
|
119
|
+
const filterTerm = this.filterSearchTerm.toLowerCase();
|
|
120
|
+
return lowercaseOption.includes(filterTerm);
|
|
121
|
+
});
|
|
122
|
+
this.displayedFilterSettings = filteredResults;
|
|
123
|
+
}
|
|
124
|
+
onSelectAllClick() {
|
|
125
|
+
this.allSelected = !this.allSelected;
|
|
126
|
+
if (this.allSelected) {
|
|
127
|
+
this.displayedFilterSettings.forEach((filterSetting) => { this.selectedFilters = [...this.selectedFilters, filterSetting.optionText]; });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.selectedFilters = [];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
getFilterButtonClassName(buttonStyle) {
|
|
134
|
+
switch (buttonStyle) {
|
|
135
|
+
case 'table icon': {
|
|
136
|
+
return '--table-icon';
|
|
137
|
+
}
|
|
138
|
+
case 'list icon': {
|
|
139
|
+
return '--list-icon';
|
|
140
|
+
}
|
|
141
|
+
default: {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
parseFilterOptions() {
|
|
147
|
+
return typeof this.filterOptions === 'string' ? JSON.parse(this.filterOptions) : this.filterOptions;
|
|
148
|
+
}
|
|
149
|
+
render() {
|
|
150
|
+
const filterPopoverContainerClassNameModifier = this.showSearchField ? '--with-search-field' : '';
|
|
151
|
+
const selectAllCheckboxIcon = this.allSelected ? 'check_box' : 'check_box_outline_blank';
|
|
152
|
+
const selectAllCheckboxColor = this.allSelected ? 'blue' : 'grey';
|
|
153
|
+
const buttonStyleClassNameModifier = this.getFilterButtonClassName(this.filterButtonStyle);
|
|
154
|
+
const filterKey = `filter__${this.filterKey}`;
|
|
155
|
+
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) => {
|
|
156
|
+
const checkboxIcon = this.selectedFilters.includes(option.optionText) ? 'check_box' : 'check_box_outline_blank';
|
|
157
|
+
const checkboxColor = this.selectedFilters.includes(option.optionText) ? 'blue' : 'grey';
|
|
158
|
+
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));
|
|
159
|
+
})), 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")))))));
|
|
160
|
+
}
|
|
161
|
+
get el() { return getElement(this); }
|
|
162
|
+
};
|
|
163
163
|
TttxFilter.style = tttxFilterCss;
|
|
164
164
|
|
|
165
165
|
export { TttxFilter as tttx_filter };
|