q2-tecton-elements 1.23.0 → 1.25.0
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/action-sheet-4b366e9a.js +84 -0
- package/dist/cjs/{index-0648c2ec.js → index-dc92e71f.js} +32 -5
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-action-sheet.cjs.entry.js +218 -0
- package/dist/cjs/q2-badge_2.cjs.entry.js +46 -17
- package/dist/cjs/q2-btn_2.cjs.entry.js +1 -1
- package/dist/cjs/q2-calendar.cjs.entry.js +2 -4
- package/dist/cjs/q2-card.cjs.entry.js +1 -1
- package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-area.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-bar.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-donut.cjs.entry.js +1 -1
- package/dist/cjs/q2-checkbox-group.cjs.entry.js +1 -1
- package/dist/cjs/q2-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown.cjs.entry.js +1 -1
- package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
- package/dist/cjs/q2-icon.cjs.entry.js +1 -1
- package/dist/cjs/q2-loc.cjs.entry.js +1 -1
- package/dist/cjs/q2-message.cjs.entry.js +1 -1
- package/dist/cjs/q2-month-picker.cjs.entry.js +1 -1
- package/dist/cjs/q2-optgroup_2.cjs.entry.js +93 -0
- package/dist/cjs/q2-option-list_2.cjs.entry.js +226 -86
- package/dist/cjs/q2-pagination.cjs.entry.js +1 -1
- package/dist/cjs/q2-pill.cjs.entry.js +57 -18
- package/dist/cjs/q2-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/q2-radio.cjs.entry.js +1 -1
- package/dist/cjs/q2-section.cjs.entry.js +1 -1
- package/dist/cjs/q2-select.cjs.entry.js +148 -409
- package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper-vertical.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper.cjs.entry.js +1 -1
- package/dist/cjs/q2-tab-container.cjs.entry.js +1 -1
- package/dist/cjs/q2-tag.cjs.entry.js +21 -7
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/cjs/q2-textarea.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/q2-action-sheet/index.js +345 -0
- package/dist/collection/components/q2-action-sheet/styles.css +215 -0
- package/dist/collection/components/q2-calendar/index.js +2 -4
- package/dist/collection/components/q2-checkbox/index.js +2 -2
- package/dist/collection/components/q2-dropdown/index.js +1 -1
- package/dist/collection/components/q2-input/index.js +46 -17
- package/dist/collection/components/q2-loading/index.js +1 -1
- package/dist/collection/components/q2-optgroup/styles.css +2 -2
- package/dist/collection/components/q2-option/index.js +3 -58
- package/dist/collection/components/q2-option/styles.css +7 -0
- package/dist/collection/components/q2-option-list/index.js +290 -102
- package/dist/collection/components/q2-pill/index.js +79 -18
- package/dist/collection/components/q2-pill/styles.css +1 -2
- package/dist/collection/components/q2-popover/index.js +17 -3
- package/dist/collection/components/q2-popover/styles.css +10 -67
- package/dist/collection/components/q2-radio/index.js +2 -2
- package/dist/collection/components/q2-select/index.js +179 -427
- package/dist/collection/components/q2-select/styles.css +5 -11
- package/dist/collection/components/q2-tag/index.js +33 -19
- package/dist/collection/utils/action-sheet.js +79 -0
- package/dist/collection/utils/index.js +29 -5
- package/dist/components/action-sheet.js +81 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index10.js +1 -1
- package/dist/components/index11.js +42 -353
- package/dist/components/index12.js +44 -99
- package/dist/components/index13.js +495 -583
- package/dist/components/index14.js +137 -0
- package/dist/components/index15.js +629 -0
- package/dist/components/index5.js +1 -1
- package/dist/components/index6.js +1 -1
- package/dist/components/index7.js +1 -1
- package/dist/components/index8.js +46 -17
- package/dist/components/index9.js +2 -2
- package/dist/components/q2-action-sheet.d.ts +11 -0
- package/dist/components/q2-action-sheet.js +282 -0
- package/dist/components/q2-calendar.js +2 -4
- package/dist/components/q2-card.js +1 -1
- package/dist/components/q2-carousel-pane.js +1 -1
- package/dist/components/q2-carousel.js +1 -1
- package/dist/components/q2-chart-area.js +1 -1
- package/dist/components/q2-chart-bar.js +1 -1
- package/dist/components/q2-chart-donut.js +1 -1
- package/dist/components/q2-checkbox-group.js +1 -1
- package/dist/components/q2-checkbox.js +1 -1
- package/dist/components/q2-dropdown.js +2 -2
- package/dist/components/q2-editable-field.js +1 -1
- package/dist/components/q2-loc.js +1 -1
- package/dist/components/q2-month-picker.js +1 -1
- package/dist/components/q2-optgroup.js +1 -70
- package/dist/components/q2-option-list.js +1 -1
- package/dist/components/q2-option.js +1 -76
- package/dist/components/q2-pagination.js +1 -1
- package/dist/components/q2-pill.js +62 -21
- package/dist/components/q2-popover.js +1 -1
- package/dist/components/q2-radio-group.js +1 -1
- package/dist/components/q2-radio.js +3 -3
- package/dist/components/q2-section.js +1 -1
- package/dist/components/q2-select.js +179 -427
- package/dist/components/q2-stepper-pane.js +1 -1
- package/dist/components/q2-stepper-vertical.js +1 -1
- package/dist/components/q2-stepper.js +1 -1
- package/dist/components/q2-tab-container.js +1 -1
- package/dist/components/q2-tag.js +25 -11
- package/dist/components/q2-textarea.js +1 -1
- package/dist/docs.d.ts +148 -0
- package/dist/docs.json +8755 -0
- package/dist/esm/action-sheet-a9597b32.js +81 -0
- package/dist/esm/{index-501fd22e.js → index-d4a87058.js} +30 -6
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-action-sheet.entry.js +214 -0
- package/dist/esm/q2-badge_2.entry.js +46 -17
- package/dist/esm/q2-btn_2.entry.js +1 -1
- package/dist/esm/q2-calendar.entry.js +2 -4
- package/dist/esm/q2-card.entry.js +1 -1
- package/dist/esm/q2-carousel-pane.entry.js +1 -1
- package/dist/esm/q2-carousel.entry.js +1 -1
- package/dist/esm/q2-chart-area.entry.js +1 -1
- package/dist/esm/q2-chart-bar.entry.js +1 -1
- package/dist/esm/q2-chart-donut.entry.js +1 -1
- package/dist/esm/q2-checkbox-group.entry.js +1 -1
- package/dist/esm/q2-checkbox.entry.js +1 -1
- package/dist/esm/q2-dropdown-item.entry.js +1 -1
- package/dist/esm/q2-dropdown.entry.js +1 -1
- package/dist/esm/q2-editable-field.entry.js +1 -1
- package/dist/esm/q2-icon.entry.js +1 -1
- package/dist/esm/q2-loc.entry.js +1 -1
- package/dist/esm/q2-message.entry.js +1 -1
- package/dist/esm/q2-month-picker.entry.js +1 -1
- package/dist/esm/q2-optgroup_2.entry.js +88 -0
- package/dist/esm/q2-option-list_2.entry.js +226 -86
- package/dist/esm/q2-pagination.entry.js +1 -1
- package/dist/esm/q2-pill.entry.js +57 -18
- package/dist/esm/q2-radio-group.entry.js +1 -1
- package/dist/esm/q2-radio.entry.js +1 -1
- package/dist/esm/q2-section.entry.js +1 -1
- package/dist/esm/q2-select.entry.js +148 -409
- package/dist/esm/q2-stepper-pane.entry.js +1 -1
- package/dist/esm/q2-stepper-vertical.entry.js +1 -1
- package/dist/esm/q2-stepper.entry.js +1 -1
- package/dist/esm/q2-tab-container.entry.js +1 -1
- package/dist/esm/q2-tag.entry.js +22 -8
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/esm/q2-textarea.entry.js +1 -1
- package/dist/q2-tecton-elements/p-059065e4.js +1 -0
- package/dist/q2-tecton-elements/{p-9b101e22.entry.js → p-1a744921.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3fd5d010.entry.js → p-1b95e43f.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3603fcdc.entry.js → p-1ea4b8bd.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-53be87c8.entry.js → p-1f3eb04c.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-25839309.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-38a33baa.entry.js → p-274ec152.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-6be86940.entry.js → p-2ba9e1a2.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-ebd7efa5.entry.js → p-2c309c54.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3e9a30c4.entry.js → p-2cc70f49.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-604b22a8.entry.js → p-2ceb41c4.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-2e938b20.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-5b1aba1a.entry.js → p-306a4bc7.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-32f44993.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-d7b27803.entry.js → p-3a9aac19.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-3c73ce3f.entry.js +1 -0
- package/dist/q2-tecton-elements/p-4a95f78e.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-6b7e1ebd.entry.js → p-4b48a49d.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-4b92e44e.entry.js +1 -0
- package/dist/q2-tecton-elements/p-5ecb9c27.entry.js +1 -0
- package/dist/q2-tecton-elements/p-6779270e.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-70b01387.entry.js → p-72fc58e7.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-7ac02ae5.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-78fac0fa.entry.js → p-7c168977.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d27b2caa.entry.js → p-7c9bf80a.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-83d678c7.entry.js +1 -0
- package/dist/q2-tecton-elements/p-a1926e65.js +1 -0
- package/dist/q2-tecton-elements/{p-24f4571d.entry.js → p-a3a5b57b.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-a6296870.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-45d61789.entry.js → p-a64e7eb1.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-8dea9a0c.entry.js → p-ad83984e.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-bf41e71b.entry.js → p-bf0ed24a.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-a2add94e.entry.js → p-bff85959.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-7aa80653.entry.js → p-c4a9ab25.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-ea5383ba.entry.js +1 -0
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/test/helpers.js +3 -2
- package/dist/types/components/q2-action-sheet/index.d.ts +52 -0
- package/dist/types/components/q2-checkbox/index.d.ts +4 -1
- package/dist/types/components/q2-input/index.d.ts +5 -0
- package/dist/types/components/q2-option/index.d.ts +1 -4
- package/dist/types/components/q2-option-list/index.d.ts +16 -8
- package/dist/types/components/q2-pill/index.d.ts +10 -1
- package/dist/types/components/q2-popover/index.d.ts +2 -0
- package/dist/types/components/q2-select/index.d.ts +45 -47
- package/dist/types/components/q2-tag/index.d.ts +3 -3
- package/dist/types/components.d.ts +44 -17
- package/dist/types/global.d.ts +9 -2
- package/dist/types/utils/action-sheet.d.ts +12 -0
- package/dist/types/utils/index.d.ts +4 -1
- package/dist/types/workspace/workspace/Tecton_tecton-production_master/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +1 -1
- package/package.json +4 -2
- package/dist/cjs/q2-optgroup.cjs.entry.js +0 -56
- package/dist/cjs/q2-option.cjs.entry.js +0 -46
- package/dist/esm/q2-optgroup.entry.js +0 -52
- package/dist/esm/q2-option.entry.js +0 -42
- package/dist/q2-tecton-elements/p-18629cbf.entry.js +0 -1
- package/dist/q2-tecton-elements/p-2c20fc43.entry.js +0 -1
- package/dist/q2-tecton-elements/p-3813f51d.entry.js +0 -1
- package/dist/q2-tecton-elements/p-68ef0786.entry.js +0 -1
- package/dist/q2-tecton-elements/p-a510290a.js +0 -1
- package/dist/q2-tecton-elements/p-acc77332.entry.js +0 -1
- package/dist/q2-tecton-elements/p-ba73ee1f.entry.js +0 -1
- package/dist/q2-tecton-elements/p-ba76ecfd.entry.js +0 -1
- package/dist/q2-tecton-elements/p-bbdae095.entry.js +0 -1
- package/dist/q2-tecton-elements/p-d68b5eb3.entry.js +0 -1
- package/dist/q2-tecton-elements/p-d88e4383.entry.js +0 -1
- package/dist/q2-tecton-elements/p-f1d06917.entry.js +0 -1
- package/dist/q2-tecton-elements/p-f6e868c1.entry.js +0 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { h, } from '@stencil/core';
|
|
2
|
-
import {
|
|
2
|
+
import { handleAriaLabel, isEventFromElement, isHostLosingFocus, isRelatedTargetWithinHost, loc, overrideFocus, } from '../../utils';
|
|
3
|
+
import { shouldShowActionSheet, showActionSheetList } from 'src/utils/action-sheet';
|
|
3
4
|
export class Q2Select {
|
|
4
5
|
constructor() {
|
|
6
|
+
var _a;
|
|
5
7
|
this.scheduledAfterRender = [];
|
|
6
|
-
this.
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
this.showSelectedOptions = (event) => {
|
|
9
|
+
event.stopPropagation();
|
|
10
|
+
this.showSelected = true;
|
|
11
|
+
};
|
|
12
|
+
this.showAllOptions = (event) => {
|
|
13
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
14
|
+
this.showSelected = false;
|
|
9
15
|
};
|
|
10
|
-
this.guid = createGuid();
|
|
11
16
|
this.onMutationObserved = () => {
|
|
12
17
|
const slotContainer = this.hostElement.querySelector('.custom-display-content');
|
|
13
18
|
const displaySlot = this.hostElement.shadowRoot.querySelector('slot[name="q2-select-display"]');
|
|
@@ -17,201 +22,62 @@ export class Q2Select {
|
|
|
17
22
|
if (this.hasCustomDisplay !== hasCustomDisplay) {
|
|
18
23
|
this.hasCustomDisplay = hasCustomDisplay;
|
|
19
24
|
}
|
|
20
|
-
if (this.multiple) {
|
|
21
|
-
this.updateMultipleOptionAttrs();
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
this.updateSingleOptionAttrs();
|
|
25
|
-
const activeOption = this.optionElements[this.activeIndex];
|
|
26
|
-
if (!activeOption || activeOption.id !== this.activeOptionId) {
|
|
27
|
-
this.activeIndex = this.getDefaultActiveIndex();
|
|
28
|
-
this.setActiveOption();
|
|
29
|
-
}
|
|
30
25
|
};
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
const buildQueue = () => {
|
|
39
|
-
const now = new Date();
|
|
40
|
-
if (now.getTime() - this.keyStore.lastPressedAt.getTime() > 1000) {
|
|
41
|
-
// empty stored keys if delay > 1s
|
|
42
|
-
this.keyStore.queue = [];
|
|
43
|
-
}
|
|
44
|
-
if (this.keyStore.queue.length !== 1 || this.keyStore.queue[0] !== keyValue) {
|
|
45
|
-
this.keyStore.queue.push(keyValue);
|
|
46
|
-
}
|
|
47
|
-
this.keyStore.lastPressedAt = now;
|
|
48
|
-
};
|
|
49
|
-
const searchIndex = list => {
|
|
50
|
-
return list.find(v => {
|
|
51
|
-
return (!v.element.disabled &&
|
|
52
|
-
v.element.display &&
|
|
53
|
-
v.element.display.replace(/\s/g, '').match(new RegExp(`^${this.keyStore.queue.join('')}`, 'i')));
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
const setFocus = ({ element, index }) => {
|
|
57
|
-
if (this.dropdownOpen || this.multiple) {
|
|
58
|
-
// multiple: should open to make sure that which options are selected
|
|
59
|
-
this.openDropdownWithActiveElement(index);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.activeIndex = index;
|
|
63
|
-
this.change.emit({ value: element.value });
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
buildQueue();
|
|
67
|
-
const matched = searchIndex(reorder());
|
|
68
|
-
if (matched) {
|
|
69
|
-
setFocus(matched);
|
|
70
|
-
}
|
|
26
|
+
this.onOptionListChange = (event) => {
|
|
27
|
+
event.stopPropagation();
|
|
28
|
+
const { values } = event.detail;
|
|
29
|
+
if (values.length === 0)
|
|
30
|
+
this.showAllOptions();
|
|
31
|
+
this.handleSelectionChanges(event.detail);
|
|
71
32
|
};
|
|
72
33
|
/// Event handlers ///
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
const isInDropdown = this.dropdownContainer.contains(relatedTarget);
|
|
76
|
-
const isInLightDom = !isInDropdown && this.hostElement.contains(relatedTarget);
|
|
77
|
-
if (isInDropdown || isInLightDom)
|
|
34
|
+
this.popoverStateChanged = ({ detail: { open } }) => {
|
|
35
|
+
if (this.open === open)
|
|
78
36
|
return;
|
|
79
|
-
|
|
37
|
+
this.open = open;
|
|
38
|
+
if (open && !this.searchText)
|
|
80
39
|
return;
|
|
81
|
-
this.
|
|
40
|
+
this.optionList.setActiveElement(null);
|
|
41
|
+
this.inputField.focus();
|
|
82
42
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
event.stopPropagation();
|
|
86
|
-
const { activeIndex, searchable, optionElements, multiSelectHeader } = this;
|
|
87
|
-
const { key, shiftKey } = event;
|
|
88
|
-
if (this.readonly ||
|
|
89
|
-
(multiSelectHeader && multiSelectHeader.contains(event.target) && [' ', 'Enter'].includes(key)))
|
|
43
|
+
this.inputKeydownHandler = (event) => {
|
|
44
|
+
if (this.readonly || this.disabled)
|
|
90
45
|
return;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (isFirstOption)
|
|
104
|
-
break;
|
|
105
|
-
if (activeIndex !== undefined) {
|
|
106
|
-
const nextIndex = this.getNextVisibleIndex(-1);
|
|
107
|
-
if (nextIndex === -1)
|
|
108
|
-
break;
|
|
109
|
-
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
this.setDefaultActiveElement();
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
case 'ArrowDown':
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
const isLastOption = activeIndex === optionElements.length - 1;
|
|
118
|
-
if (isLastOption)
|
|
119
|
-
break;
|
|
120
|
-
if (activeIndex !== undefined) {
|
|
121
|
-
const nextIndex = this.getNextVisibleIndex(1);
|
|
122
|
-
if (nextIndex === -1)
|
|
123
|
-
break;
|
|
124
|
-
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
this.setDefaultActiveElement();
|
|
128
|
-
}
|
|
129
|
-
break;
|
|
130
|
-
case 'Home':
|
|
131
|
-
event.preventDefault();
|
|
132
|
-
this.openDropdownWithActiveElement(0);
|
|
133
|
-
break;
|
|
134
|
-
case 'End':
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
this.openDropdownWithActiveElement(optionElements.length - 1);
|
|
137
|
-
break;
|
|
138
|
-
case 'PageUp':
|
|
139
|
-
event.preventDefault();
|
|
140
|
-
this.openDropdownWithActiveElement(Math.max(activeIndex - 10, 0));
|
|
141
|
-
break;
|
|
142
|
-
case 'PageDown':
|
|
143
|
-
event.preventDefault();
|
|
144
|
-
this.openDropdownWithActiveElement(Math.min(activeIndex + 10, optionElements.length - 1));
|
|
145
|
-
break;
|
|
146
|
-
case 'Tab':
|
|
147
|
-
if (shiftKey)
|
|
148
|
-
break;
|
|
149
|
-
const myOption = this.hostElement.querySelector(`[option-id="${this.activeOptionId}"]`);
|
|
150
|
-
if (!myOption || myOption.disabled)
|
|
151
|
-
return;
|
|
152
|
-
if (myOption.selected)
|
|
153
|
-
return;
|
|
154
|
-
this.selectOption(myOption);
|
|
155
|
-
break;
|
|
156
|
-
case 'Esc':
|
|
157
|
-
case 'Escape':
|
|
158
|
-
this.closeDropdown();
|
|
159
|
-
this.focusInput();
|
|
160
|
-
break;
|
|
161
|
-
default:
|
|
162
|
-
if (searchable)
|
|
163
|
-
break;
|
|
164
|
-
if (!key.match(/^[A-Za-z0-9]$/))
|
|
165
|
-
break;
|
|
166
|
-
// search in non-searchable select: alpha-numeric only
|
|
167
|
-
this.searchAndFocus(key);
|
|
168
|
-
break;
|
|
46
|
+
const keysForOptionListToHandle = [
|
|
47
|
+
'ArrowDown',
|
|
48
|
+
'ArrowUp',
|
|
49
|
+
'PageDown',
|
|
50
|
+
'PageUp',
|
|
51
|
+
'Home',
|
|
52
|
+
'End',
|
|
53
|
+
'Escape',
|
|
54
|
+
'Tab',
|
|
55
|
+
];
|
|
56
|
+
if (shouldShowActionSheet(this, event)) {
|
|
57
|
+
return this.executeActionSheet(event);
|
|
169
58
|
}
|
|
59
|
+
if (this.searchable && !keysForOptionListToHandle.includes(event.key))
|
|
60
|
+
return;
|
|
61
|
+
if (this.shouldClearSearchText(event))
|
|
62
|
+
this.clearSearchText();
|
|
63
|
+
this.optionList.handleExternalKeydown(event);
|
|
170
64
|
};
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
break;
|
|
181
|
-
case 'ArrowUp':
|
|
182
|
-
event.preventDefault();
|
|
183
|
-
this.openDropdownWithActiveElement(this.getLastEnabledIndex());
|
|
184
|
-
this.setFocusedOption();
|
|
185
|
-
break;
|
|
186
|
-
case 'Home':
|
|
187
|
-
event.preventDefault();
|
|
188
|
-
this.openDropdownWithActiveElement(0);
|
|
189
|
-
break;
|
|
190
|
-
case 'End':
|
|
191
|
-
event.preventDefault();
|
|
192
|
-
this.openDropdownWithActiveElement(optionElements.length - 1);
|
|
193
|
-
break;
|
|
194
|
-
case 'Escape':
|
|
195
|
-
case 'Esc':
|
|
196
|
-
this.closeDropdown();
|
|
197
|
-
break;
|
|
198
|
-
case 'Tab':
|
|
199
|
-
this.closeDropdown();
|
|
200
|
-
break;
|
|
201
|
-
default:
|
|
202
|
-
if (!key.match(/^[A-Za-z0-9]$/))
|
|
203
|
-
break;
|
|
204
|
-
if (searchable) {
|
|
205
|
-
this.openDropdownWithoutActiveElement();
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
// search in non-searchable select: alpha-numeric only
|
|
209
|
-
this.searchAndFocus(key);
|
|
65
|
+
this.visibilityToggleKeyDown = (event) => {
|
|
66
|
+
const keysForOptionListToHandle = ['ArrowDown', 'ArrowUp'];
|
|
67
|
+
const keysThatTriggerClick = ['Enter', ' '];
|
|
68
|
+
const key = event.key;
|
|
69
|
+
if (keysForOptionListToHandle.includes(key)) {
|
|
70
|
+
this.optionList.handleExternalKeydown(event);
|
|
71
|
+
}
|
|
72
|
+
else if (keysThatTriggerClick.includes(key)) {
|
|
73
|
+
event.target.dispatchEvent(new MouseEvent('click'));
|
|
210
74
|
}
|
|
211
75
|
};
|
|
212
|
-
this.inputClickHandler = (event) => {
|
|
76
|
+
this.inputClickHandler = async (event) => {
|
|
213
77
|
event.stopPropagation();
|
|
214
|
-
|
|
78
|
+
if (shouldShowActionSheet(this)) {
|
|
79
|
+
return this.executeActionSheet(event);
|
|
80
|
+
}
|
|
215
81
|
this.toggleDropdown();
|
|
216
82
|
this.focusInput();
|
|
217
83
|
};
|
|
@@ -221,10 +87,9 @@ export class Q2Select {
|
|
|
221
87
|
const eventValue = event.detail.value;
|
|
222
88
|
const didChangeText = inputValue !== eventValue;
|
|
223
89
|
const shouldClearValue = !!this.value && didChangeText;
|
|
224
|
-
if (shouldClearValue)
|
|
225
|
-
this.
|
|
226
|
-
|
|
227
|
-
if (!this.dropdownOpen)
|
|
90
|
+
if (shouldClearValue)
|
|
91
|
+
this.clearValue();
|
|
92
|
+
if (!this.open)
|
|
228
93
|
this.openDropdownWithoutActiveElement();
|
|
229
94
|
this.prioritizeSearch = true;
|
|
230
95
|
this.searchText = eventValue;
|
|
@@ -241,32 +106,18 @@ export class Q2Select {
|
|
|
241
106
|
};
|
|
242
107
|
this.clickedElsewhere = (event) => {
|
|
243
108
|
const target = event.target;
|
|
244
|
-
if (target.localName
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
109
|
+
if (target.localName !== 'click-elsewhere')
|
|
110
|
+
return;
|
|
111
|
+
event.stopPropagation();
|
|
112
|
+
if (!this.open)
|
|
113
|
+
return;
|
|
114
|
+
this.closeDropdown();
|
|
250
115
|
};
|
|
251
116
|
this.onCustomDisplayClick = (event) => {
|
|
252
117
|
event.stopPropagation();
|
|
253
118
|
this.focusInput();
|
|
254
119
|
this.toggleDropdown();
|
|
255
120
|
};
|
|
256
|
-
this.showSelectedOptions = (event) => {
|
|
257
|
-
event.stopImmediatePropagation();
|
|
258
|
-
this.onlyShowingSelected = true;
|
|
259
|
-
this.optionElements.forEach(optionElement => {
|
|
260
|
-
optionElement._multiSelectHidden = !optionElement.selected;
|
|
261
|
-
});
|
|
262
|
-
};
|
|
263
|
-
this.showAllOptions = (event) => {
|
|
264
|
-
event.stopPropagation();
|
|
265
|
-
this.onlyShowingSelected = false;
|
|
266
|
-
this.optionElements.forEach(optionElement => {
|
|
267
|
-
optionElement._multiSelectHidden = false;
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
121
|
this.label = undefined;
|
|
271
122
|
this.hideLabel = undefined;
|
|
272
123
|
this.value = undefined;
|
|
@@ -283,18 +134,21 @@ export class Q2Select {
|
|
|
283
134
|
this.multilineOptions = false;
|
|
284
135
|
this.optional = false;
|
|
285
136
|
this.placeholder = undefined;
|
|
286
|
-
this.
|
|
287
|
-
this.
|
|
288
|
-
this.
|
|
137
|
+
this.hoist = !!((_a = window.Tecton) === null || _a === void 0 ? void 0 : _a.useActionSheets);
|
|
138
|
+
this.open = false;
|
|
139
|
+
this.showSelected = false;
|
|
289
140
|
this.searchText = '';
|
|
290
141
|
this.hasCustomDisplay = false;
|
|
291
142
|
this.inputFocused = false;
|
|
292
143
|
this.statusMessage = undefined;
|
|
293
144
|
this.prioritizeSearch = false;
|
|
145
|
+
this.structuredSelectedOptions = [];
|
|
294
146
|
}
|
|
295
147
|
/// Lifecycle Hooks ///
|
|
296
148
|
componentWillLoad() {
|
|
297
149
|
handleAriaLabel(this);
|
|
150
|
+
this.buildStructuredSelectedOptions();
|
|
151
|
+
this.handleMultilineOptionsUpdate(this.multilineOptions, false);
|
|
298
152
|
}
|
|
299
153
|
componentDidLoad() {
|
|
300
154
|
const observer = new MutationObserver(this.onMutationObserved);
|
|
@@ -316,22 +170,17 @@ export class Q2Select {
|
|
|
316
170
|
this.mutationObserver = null;
|
|
317
171
|
}
|
|
318
172
|
/// Getters ///
|
|
319
|
-
get isComponentFocused() {
|
|
320
|
-
return document.activeElement === this.hostElement || !!this.hostElement.querySelector(':focus');
|
|
321
|
-
}
|
|
322
|
-
get isSearchMode() {
|
|
323
|
-
return (this.searchable && this.inputFocused) || this.searchText;
|
|
324
|
-
}
|
|
325
173
|
get badgeValue() {
|
|
174
|
+
var _a, _b;
|
|
326
175
|
if (!this.multiple)
|
|
327
|
-
return;
|
|
328
|
-
const optionsLength = this.selectedOptions.length;
|
|
329
|
-
if (this.
|
|
330
|
-
return optionsLength
|
|
176
|
+
return null;
|
|
177
|
+
const optionsLength = (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
178
|
+
if (this.open && this.searchable)
|
|
179
|
+
return optionsLength ? `${optionsLength}` : null;
|
|
331
180
|
else
|
|
332
181
|
return optionsLength > 1 ? `+${optionsLength - 1}` : null;
|
|
333
182
|
}
|
|
334
|
-
get
|
|
183
|
+
get popoverMinHeight() {
|
|
335
184
|
const { minRows } = this;
|
|
336
185
|
const firstOption = this.hostElement.querySelector('q2-option:not([hidden])');
|
|
337
186
|
const minHeight = firstOption ? window.getComputedStyle(firstOption).minHeight : '44px';
|
|
@@ -348,10 +197,8 @@ export class Q2Select {
|
|
|
348
197
|
return this.hostElement.querySelector('[slot="_selected-display"]');
|
|
349
198
|
}
|
|
350
199
|
get firstSelectedValue() {
|
|
351
|
-
var _a
|
|
352
|
-
|
|
353
|
-
return (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
|
|
354
|
-
return this.value;
|
|
200
|
+
var _a;
|
|
201
|
+
return this.multiple ? (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a[0] : this.value;
|
|
355
202
|
}
|
|
356
203
|
get firstSelectedOptionElement() {
|
|
357
204
|
const { firstSelectedValue } = this;
|
|
@@ -360,14 +207,9 @@ export class Q2Select {
|
|
|
360
207
|
get optionElements() {
|
|
361
208
|
return Array.from(this.hostElement.querySelectorAll('q2-option'));
|
|
362
209
|
}
|
|
363
|
-
get visibleOptionElements() {
|
|
364
|
-
return Array.from(this.hostElement.querySelectorAll('q2-option:not([_multiselecthidden])'));
|
|
365
|
-
}
|
|
366
210
|
get wrapperClasses() {
|
|
367
211
|
const { errors } = this;
|
|
368
212
|
const classes = ['q2-select-container'];
|
|
369
|
-
if (this.dropdownOpen)
|
|
370
|
-
classes.push('dropdown-open');
|
|
371
213
|
if (Array.isArray(errors) && errors.length > 0)
|
|
372
214
|
classes.push('has-error');
|
|
373
215
|
if (this.inputFocused)
|
|
@@ -377,33 +219,39 @@ export class Q2Select {
|
|
|
377
219
|
return classes.join(' ');
|
|
378
220
|
}
|
|
379
221
|
/// Watchers ///
|
|
222
|
+
buildStructuredSelectedOptions() {
|
|
223
|
+
const { multiple, selectedOptions, value } = this;
|
|
224
|
+
if (multiple) {
|
|
225
|
+
this.structuredSelectedOptions = !!(selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length)
|
|
226
|
+
? selectedOptions.map(option => (typeof option === 'string' ? { value: option } : option))
|
|
227
|
+
: [];
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
this.structuredSelectedOptions = value ? [{ value }] : [];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
380
233
|
ariaLabelObserver() {
|
|
381
234
|
handleAriaLabel(this);
|
|
382
235
|
}
|
|
383
236
|
valueUpdated() {
|
|
384
237
|
if (this.multiple)
|
|
385
238
|
return;
|
|
386
|
-
this.
|
|
387
|
-
}
|
|
388
|
-
selectedOptionsUpdated() {
|
|
389
|
-
if (!this.multiple)
|
|
390
|
-
return;
|
|
391
|
-
this.updateMultipleOptionAttrs();
|
|
239
|
+
this.clearSearchText();
|
|
392
240
|
}
|
|
393
|
-
|
|
241
|
+
handleMultilineOptionsUpdate(newValue, oldValue) {
|
|
394
242
|
if (newValue === oldValue)
|
|
395
243
|
return;
|
|
396
244
|
this.optionElements.forEach(element => (element.multiline = newValue));
|
|
397
245
|
}
|
|
398
|
-
|
|
246
|
+
openChanged(isOpen) {
|
|
399
247
|
this.scheduledAfterRender.push(() => {
|
|
400
|
-
const { multiple, multiSelectHeader,
|
|
248
|
+
const { multiple, multiSelectHeader, popoverElement } = this;
|
|
401
249
|
const height = (isOpen && multiple && (multiSelectHeader === null || multiSelectHeader === void 0 ? void 0 : multiSelectHeader.offsetHeight)) || 0;
|
|
402
250
|
if (height) {
|
|
403
|
-
|
|
251
|
+
popoverElement.style.setProperty('--comp-multi-select-header-height', `${height}px`);
|
|
404
252
|
}
|
|
405
253
|
else {
|
|
406
|
-
|
|
254
|
+
popoverElement.style.removeProperty('--comp-multi-select-header-height');
|
|
407
255
|
}
|
|
408
256
|
});
|
|
409
257
|
}
|
|
@@ -412,15 +260,17 @@ export class Q2Select {
|
|
|
412
260
|
this.inputKeydownHandler(event);
|
|
413
261
|
}
|
|
414
262
|
onHostElementChange(event) {
|
|
415
|
-
if (this.readonly)
|
|
263
|
+
if (this.readonly || this.disabled)
|
|
416
264
|
return;
|
|
417
265
|
if (event.target !== this.hostElement || this.hostElement.onchange)
|
|
418
266
|
return;
|
|
419
267
|
if (this.multiple) {
|
|
268
|
+
this.value = null;
|
|
420
269
|
this.selectedOptions = event.detail.selectedOptions;
|
|
421
270
|
}
|
|
422
271
|
else {
|
|
423
272
|
this.value = event.detail.value;
|
|
273
|
+
this.selectedOptions = [];
|
|
424
274
|
}
|
|
425
275
|
}
|
|
426
276
|
onHostElementInput(event) {
|
|
@@ -462,54 +312,33 @@ export class Q2Select {
|
|
|
462
312
|
}
|
|
463
313
|
}
|
|
464
314
|
handleFocusout(event) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (!selectedOption ||
|
|
470
|
-
(selectedOption.hasAttribute('disabled') && selectedOption.getAttribute('disabled') !== 'false'))
|
|
471
|
-
return;
|
|
472
|
-
this.selectOption(selectedOption, true);
|
|
315
|
+
const isLeavingHost = isHostLosingFocus(event, this.hostElement);
|
|
316
|
+
if (isLeavingHost)
|
|
317
|
+
this.closeDropdown();
|
|
318
|
+
this.prioritizeSearch = !isLeavingHost && this.searchable;
|
|
473
319
|
}
|
|
474
320
|
/// Helpers ///
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
return acc;
|
|
490
|
-
}, []);
|
|
491
|
-
return enabledIndexes[enabledIndexes.length - 1];
|
|
492
|
-
}
|
|
493
|
-
setActiveOption() {
|
|
494
|
-
if (!this.dropdownOpen)
|
|
495
|
-
return;
|
|
496
|
-
const activeIndex = this.activeIndex;
|
|
497
|
-
this.optionElements.forEach((element, elementIndex) => {
|
|
498
|
-
if (activeIndex === elementIndex) {
|
|
499
|
-
element.active = true;
|
|
500
|
-
this.activeOptionId = element.optionId;
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
element.active = false;
|
|
504
|
-
}
|
|
321
|
+
async executeActionSheet(event) {
|
|
322
|
+
const result = await showActionSheetList(this, event);
|
|
323
|
+
this.handleSelectionChanges(result);
|
|
324
|
+
}
|
|
325
|
+
handleSelectionChanges(changeDetails) {
|
|
326
|
+
const { value = '', values = [] } = changeDetails;
|
|
327
|
+
const selectedOptionValues = values.map(value => value.value);
|
|
328
|
+
const { multiple } = this;
|
|
329
|
+
if (!this.hostElement.onchange) {
|
|
330
|
+
this.selectedOptions = selectedOptionValues;
|
|
331
|
+
}
|
|
332
|
+
this.change.emit({
|
|
333
|
+
value: multiple ? undefined : value,
|
|
334
|
+
selectedOptions: multiple ? selectedOptionValues : undefined,
|
|
505
335
|
});
|
|
506
336
|
}
|
|
507
|
-
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
option.focus();
|
|
337
|
+
clearValue() {
|
|
338
|
+
const { multiple } = this;
|
|
339
|
+
this.value = '';
|
|
340
|
+
this.selectedOptions = [];
|
|
341
|
+
this.change.emit({ value: multiple ? undefined : '', selectedOptions: multiple ? [] : undefined });
|
|
513
342
|
}
|
|
514
343
|
calculateMultiSelectSelectedDisplay() {
|
|
515
344
|
var _a;
|
|
@@ -528,130 +357,36 @@ export class Q2Select {
|
|
|
528
357
|
const { firstSelectedOptionElement } = this;
|
|
529
358
|
return ((firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.display) && loc(firstSelectedOptionElement.display)) || this.value || '';
|
|
530
359
|
}
|
|
531
|
-
updateSingleOptionAttrs() {
|
|
532
|
-
const { value, guid, multilineOptions } = this;
|
|
533
|
-
this.optionElements.forEach((element, index) => {
|
|
534
|
-
element.selected = element.value === value;
|
|
535
|
-
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
536
|
-
element.multiline = multilineOptions;
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
updateMultipleOptionAttrs() {
|
|
540
|
-
if (this.selectedOptions.length === 0) {
|
|
541
|
-
this.onlyShowingSelected = false;
|
|
542
|
-
}
|
|
543
|
-
const { selectedOptions, onlyShowingSelected, guid, multilineOptions } = this;
|
|
544
|
-
this.optionElements.forEach((element, index) => {
|
|
545
|
-
element.selected = selectedOptions.includes(element.value);
|
|
546
|
-
element._multiSelectHidden = onlyShowingSelected ? !element.selected : false;
|
|
547
|
-
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
548
|
-
element.multiline = multilineOptions;
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
focusSelectedSibling(option) {
|
|
552
|
-
if (!this.onlyShowingSelected)
|
|
553
|
-
return;
|
|
554
|
-
const { visibleOptionElements } = this;
|
|
555
|
-
if (visibleOptionElements.length < 2)
|
|
556
|
-
return;
|
|
557
|
-
const optionIndex = visibleOptionElements.indexOf(option);
|
|
558
|
-
const visibleFocusIndex = optionIndex ? optionIndex - 1 : optionIndex + 1;
|
|
559
|
-
const optionToFocus = visibleOptionElements[visibleFocusIndex];
|
|
560
|
-
const focusIndex = this.optionElements.indexOf(optionToFocus);
|
|
561
|
-
this.activeIndex = focusIndex;
|
|
562
|
-
this.setFocusedOption();
|
|
563
|
-
}
|
|
564
|
-
selectOption(option, focusInputOnClose = false) {
|
|
565
|
-
var _a;
|
|
566
|
-
const value = (_a = option === null || option === void 0 ? void 0 : option.value) !== null && _a !== void 0 ? _a : '';
|
|
567
|
-
if (this.multiple) {
|
|
568
|
-
const isSelected = this.selectedOptions.includes(value);
|
|
569
|
-
if (isSelected) {
|
|
570
|
-
this.focusSelectedSibling(option);
|
|
571
|
-
this.change.emit({
|
|
572
|
-
selectedOptions: this.selectedOptions.filter(selectedValue => selectedValue !== value),
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
else if (value) {
|
|
576
|
-
this.change.emit({ selectedOptions: [...this.selectedOptions, value] });
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
else {
|
|
580
|
-
this.change.emit({ value });
|
|
581
|
-
this.closeDropdown();
|
|
582
|
-
if (focusInputOnClose)
|
|
583
|
-
this.focusInput();
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
scrollToActiveOption() {
|
|
587
|
-
const activeOption = this.optionElements[this.activeIndex];
|
|
588
|
-
activeOption === null || activeOption === void 0 ? void 0 : activeOption.scrollIntoView({ block: 'nearest' });
|
|
589
|
-
}
|
|
590
360
|
openDropdownWithoutActiveElement() {
|
|
591
|
-
if (this.readonly)
|
|
361
|
+
if (this.readonly || this.disabled)
|
|
592
362
|
return;
|
|
593
|
-
this.
|
|
594
|
-
this.
|
|
595
|
-
this.dropdownOpen = true;
|
|
596
|
-
this.scheduledAfterRender.push(resizeIframe);
|
|
597
|
-
}
|
|
598
|
-
openDropdownWithActiveElement(activeIndex) {
|
|
599
|
-
if (this.readonly)
|
|
600
|
-
return;
|
|
601
|
-
this.activeIndex = activeIndex;
|
|
602
|
-
this.dropdownOpen = true;
|
|
603
|
-
this.setActiveOption();
|
|
604
|
-
this.scheduledAfterRender.push(() => {
|
|
605
|
-
this.setFocusedOption();
|
|
606
|
-
this.scrollToActiveOption();
|
|
607
|
-
resizeIframe();
|
|
608
|
-
});
|
|
363
|
+
this.optionList.setActiveElement(null);
|
|
364
|
+
this.open = true;
|
|
609
365
|
}
|
|
610
366
|
closeDropdown() {
|
|
611
|
-
this.
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
367
|
+
this.open = false;
|
|
368
|
+
this.clearSearchText();
|
|
369
|
+
}
|
|
370
|
+
clearSearchText() {
|
|
371
|
+
if (!this.searchText)
|
|
372
|
+
return;
|
|
373
|
+
this.searchText = '';
|
|
374
|
+
this.input.emit({ query: '' });
|
|
617
375
|
}
|
|
618
376
|
toggleDropdown() {
|
|
619
|
-
if (this.disabled)
|
|
377
|
+
if (this.readonly || this.disabled)
|
|
620
378
|
return;
|
|
621
|
-
if (this.
|
|
379
|
+
if (this.open && !this.searchText) {
|
|
622
380
|
this.closeDropdown();
|
|
623
381
|
}
|
|
624
382
|
else {
|
|
625
383
|
this.openDropdownWithoutActiveElement();
|
|
626
384
|
}
|
|
627
385
|
}
|
|
628
|
-
adjustActiveOptionAndScroll(numToAdd) {
|
|
629
|
-
this.activeIndex += numToAdd;
|
|
630
|
-
this.setActiveOption();
|
|
631
|
-
this.setFocusedOption();
|
|
632
|
-
this.scrollToActiveOption();
|
|
633
|
-
}
|
|
634
|
-
setDefaultActiveElement() {
|
|
635
|
-
this.activeIndex = this.getDefaultActiveIndex();
|
|
636
|
-
this.setActiveOption();
|
|
637
|
-
this.setFocusedOption();
|
|
638
|
-
}
|
|
639
386
|
focusInput() {
|
|
640
387
|
var _a;
|
|
641
388
|
(_a = this.inputField) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new FocusEvent('focus'));
|
|
642
389
|
}
|
|
643
|
-
getNextVisibleIndex(direction) {
|
|
644
|
-
let index = this.activeIndex + direction;
|
|
645
|
-
const { optionElements } = this;
|
|
646
|
-
while (index >= 0 && index <= optionElements.length - 1) {
|
|
647
|
-
const { display, visibility } = window.getComputedStyle(optionElements[index]);
|
|
648
|
-
if (display !== 'none' && visibility !== 'hidden') {
|
|
649
|
-
return index;
|
|
650
|
-
}
|
|
651
|
-
index = index + direction;
|
|
652
|
-
}
|
|
653
|
-
return -1;
|
|
654
|
-
}
|
|
655
390
|
setStatusMessage(message) {
|
|
656
391
|
clearTimeout(this.statusMessageTimer);
|
|
657
392
|
this.statusMessage = '';
|
|
@@ -666,7 +401,7 @@ export class Q2Select {
|
|
|
666
401
|
checkSelectedDisplay() {
|
|
667
402
|
let namedSlot = this.selectedDisplaySlot;
|
|
668
403
|
const { value, multiple, selectedOptions, multilineOptions, firstSelectedOptionElement, prioritizeSearch } = this;
|
|
669
|
-
const hasNoValue = !value && multiple && !selectedOptions.length;
|
|
404
|
+
const hasNoValue = !value && multiple && !(selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length);
|
|
670
405
|
if (prioritizeSearch || !multilineOptions || hasNoValue)
|
|
671
406
|
return this.clearSelectedDisplay();
|
|
672
407
|
if (!firstSelectedOptionElement || firstSelectedOptionElement.display)
|
|
@@ -695,6 +430,9 @@ export class Q2Select {
|
|
|
695
430
|
return;
|
|
696
431
|
selectedDisplaySlot.style.setProperty('--comp-selected-display-height', '44px');
|
|
697
432
|
}
|
|
433
|
+
shouldClearSearchText(event) {
|
|
434
|
+
return this.searchable && !!this.searchText && event.key === 'Escape';
|
|
435
|
+
}
|
|
698
436
|
/// DOM ///
|
|
699
437
|
renderCustomDisplay() {
|
|
700
438
|
const hasSelectedDisplay = this.checkSelectedDisplay();
|
|
@@ -709,15 +447,16 @@ export class Q2Select {
|
|
|
709
447
|
this.errors.length > 0 &&
|
|
710
448
|
this.errors.map(error => loc(error))) ||
|
|
711
449
|
(this.invalid && ['tecton.element.select.invalid']) ||
|
|
712
|
-
[], disabled: this.disabled, optional: this.optional, readonly: this.readonly, placeholder: this.placeholder || undefined, hideLabel: this.hideLabel, ariaExpanded: `${!!this.
|
|
450
|
+
[], disabled: this.disabled, optional: this.optional, readonly: this.readonly, placeholder: this.placeholder || undefined, hideLabel: this.hideLabel, ariaExpanded: `${!!this.open}`, ariaOwns: "option-list", ariaHaspopup: "listbox", role: this.searchable ? 'combobox' : null, pseudo: showAsPseudo, "test-id": "toggleDropdown", "hide-messages": true, iconRight: "chevron-down", onClick: this.inputClickHandler, onInput: this.inputInputHandler, onKeyDown: this.inputKeydownHandler, onFocus: this.inputFocusHandler, onBlur: this.inputBlurHandler, onChange: this.inputChangeHandler, badgeValue: this.badgeValue, badgeTheme: this.inputFocused ? 'primary' : undefined }, this.renderCustomDisplay()), h("div", { class: "custom-display-content", hidden: !this.hasCustomDisplay || !!this.searchText, onClick: this.onCustomDisplayClick }, h("slot", { name: "q2-select-display" })), this.optionsDropdown()));
|
|
713
451
|
}
|
|
714
452
|
optionsDropdown() {
|
|
715
|
-
|
|
716
|
-
return (h("div", { class: `q2-select-dropdown q2-element-dropdown ${dropDirection}`, ref: el => (this.dropdownContainer = el), onKeyDown: this.dropdownKeydownHandler, onFocusout: this.dropdownFocusoutHandler }, this.multiple ? this.visibilityToggle() : '', h("div", { class: "q2-select-options", id: "dropdown", role: "listbox" }, h("slot", null))));
|
|
453
|
+
return (h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.inputField, open: this.open, minHeight: this.popoverMinHeight, direction: this.popDirection, onPopoverStateChanged: this.popoverStateChanged, block: true }, this.multiple ? this.visibilityToggle() : '', h("q2-option-list", { ref: el => (this.optionList = el), id: "option-list", "show-selected": this.showSelected, multiple: this.multiple, selectedOptions: this.structuredSelectedOptions, onChange: this.onOptionListChange }, h("slot", null))));
|
|
717
454
|
}
|
|
718
455
|
visibilityToggle() {
|
|
719
|
-
|
|
720
|
-
|
|
456
|
+
var _a, _b;
|
|
457
|
+
const selectedOptionsCount = (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
458
|
+
const { showSelected } = this;
|
|
459
|
+
return (h("div", { class: "multi-select-header", ref: el => (this.multiSelectHeader = el) }, h("span", null, loc('tecton.element.select.multiHeader.showing')), h("q2-btn", { class: showSelected ? '' : 'selected', badge: true, "aria-selected": !showSelected || undefined, "test-id": "allOptionsButton", onClick: this.showAllOptions, onKeyDown: this.visibilityToggleKeyDown, label: loc('tecton.element.select.multiHeader.allAriaLabel'), "hide-label": true }, loc('tecton.element.select.multiHeader.all')), h("q2-btn", { class: showSelected ? 'selected' : '', "aria-selected": showSelected || undefined, disabled: selectedOptionsCount === 0, badge: true, "test-id": "selectedOptionsButton", onClick: this.showSelectedOptions, onKeyDown: this.visibilityToggleKeyDown, label: loc('tecton.element.select.multiHeader.selectedAriaLabel', [selectedOptionsCount]), "hide-label": true }, loc('tecton.element.select.multiHeader.selected', [selectedOptionsCount]))));
|
|
721
460
|
}
|
|
722
461
|
static get is() { return "q2-select"; }
|
|
723
462
|
static get encapsulation() { return "shadow"; }
|
|
@@ -802,11 +541,11 @@ export class Q2Select {
|
|
|
802
541
|
"reflect": true
|
|
803
542
|
},
|
|
804
543
|
"selectedOptions": {
|
|
805
|
-
"type": "
|
|
544
|
+
"type": "unknown",
|
|
806
545
|
"mutable": true,
|
|
807
546
|
"complexType": {
|
|
808
|
-
"original": "
|
|
809
|
-
"resolved": "
|
|
547
|
+
"original": "string[]",
|
|
548
|
+
"resolved": "string[]",
|
|
810
549
|
"references": {}
|
|
811
550
|
},
|
|
812
551
|
"required": false,
|
|
@@ -815,8 +554,6 @@ export class Q2Select {
|
|
|
815
554
|
"tags": [],
|
|
816
555
|
"text": ""
|
|
817
556
|
},
|
|
818
|
-
"attribute": "selected-options",
|
|
819
|
-
"reflect": false,
|
|
820
557
|
"defaultValue": "[]"
|
|
821
558
|
},
|
|
822
559
|
"disabled": {
|
|
@@ -1010,19 +747,37 @@ export class Q2Select {
|
|
|
1010
747
|
},
|
|
1011
748
|
"attribute": "placeholder",
|
|
1012
749
|
"reflect": true
|
|
750
|
+
},
|
|
751
|
+
"hoist": {
|
|
752
|
+
"type": "boolean",
|
|
753
|
+
"mutable": false,
|
|
754
|
+
"complexType": {
|
|
755
|
+
"original": "boolean",
|
|
756
|
+
"resolved": "boolean",
|
|
757
|
+
"references": {}
|
|
758
|
+
},
|
|
759
|
+
"required": false,
|
|
760
|
+
"optional": false,
|
|
761
|
+
"docs": {
|
|
762
|
+
"tags": [],
|
|
763
|
+
"text": ""
|
|
764
|
+
},
|
|
765
|
+
"attribute": "hoist",
|
|
766
|
+
"reflect": false,
|
|
767
|
+
"defaultValue": "!!window.Tecton?.useActionSheets"
|
|
1013
768
|
}
|
|
1014
769
|
};
|
|
1015
770
|
}
|
|
1016
771
|
static get states() {
|
|
1017
772
|
return {
|
|
1018
|
-
"
|
|
1019
|
-
"
|
|
1020
|
-
"activeOptionId": {},
|
|
773
|
+
"open": {},
|
|
774
|
+
"showSelected": {},
|
|
1021
775
|
"searchText": {},
|
|
1022
776
|
"hasCustomDisplay": {},
|
|
1023
777
|
"inputFocused": {},
|
|
1024
778
|
"statusMessage": {},
|
|
1025
|
-
"prioritizeSearch": {}
|
|
779
|
+
"prioritizeSearch": {},
|
|
780
|
+
"structuredSelectedOptions": {}
|
|
1026
781
|
};
|
|
1027
782
|
}
|
|
1028
783
|
static get events() {
|
|
@@ -1037,8 +792,8 @@ export class Q2Select {
|
|
|
1037
792
|
"text": ""
|
|
1038
793
|
},
|
|
1039
794
|
"complexType": {
|
|
1040
|
-
"original": "
|
|
1041
|
-
"resolved": "
|
|
795
|
+
"original": "{ value: string; selectedOptions: string[] }",
|
|
796
|
+
"resolved": "{ value: string; selectedOptions: string[]; }",
|
|
1042
797
|
"references": {}
|
|
1043
798
|
}
|
|
1044
799
|
}, {
|
|
@@ -1061,20 +816,23 @@ export class Q2Select {
|
|
|
1061
816
|
static get elementRef() { return "hostElement"; }
|
|
1062
817
|
static get watchers() {
|
|
1063
818
|
return [{
|
|
819
|
+
"propName": "value",
|
|
820
|
+
"methodName": "buildStructuredSelectedOptions"
|
|
821
|
+
}, {
|
|
822
|
+
"propName": "selectedOptions",
|
|
823
|
+
"methodName": "buildStructuredSelectedOptions"
|
|
824
|
+
}, {
|
|
1064
825
|
"propName": "ariaLabel",
|
|
1065
826
|
"methodName": "ariaLabelObserver"
|
|
1066
827
|
}, {
|
|
1067
828
|
"propName": "value",
|
|
1068
829
|
"methodName": "valueUpdated"
|
|
1069
|
-
}, {
|
|
1070
|
-
"propName": "selectedOptions",
|
|
1071
|
-
"methodName": "selectedOptionsUpdated"
|
|
1072
830
|
}, {
|
|
1073
831
|
"propName": "multilineOptions",
|
|
1074
|
-
"methodName": "
|
|
832
|
+
"methodName": "handleMultilineOptionsUpdate"
|
|
1075
833
|
}, {
|
|
1076
|
-
"propName": "
|
|
1077
|
-
"methodName": "
|
|
834
|
+
"propName": "open",
|
|
835
|
+
"methodName": "openChanged"
|
|
1078
836
|
}];
|
|
1079
837
|
}
|
|
1080
838
|
static get listeners() {
|
|
@@ -1108,12 +866,6 @@ export class Q2Select {
|
|
|
1108
866
|
"target": undefined,
|
|
1109
867
|
"capture": false,
|
|
1110
868
|
"passive": false
|
|
1111
|
-
}, {
|
|
1112
|
-
"name": "click",
|
|
1113
|
-
"method": "clickHandler",
|
|
1114
|
-
"target": undefined,
|
|
1115
|
-
"capture": false,
|
|
1116
|
-
"passive": false
|
|
1117
869
|
}];
|
|
1118
870
|
}
|
|
1119
871
|
}
|