q2-tecton-elements 1.15.1 → 1.16.2
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/{index-0fec9f3b.js → index-afc50fbb.js} +18 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
- package/dist/cjs/{q2-input.cjs.entry.js → q2-badge_2.cjs.entry.js} +77 -18
- package/dist/cjs/q2-btn_2.cjs.entry.js +7 -6
- package/dist/cjs/q2-calendar.cjs.entry.js +2 -2
- package/dist/cjs/q2-card.cjs.entry.js +15 -8
- package/dist/cjs/q2-carousel-pane.cjs.entry.js +2 -2
- package/dist/cjs/q2-carousel.cjs.entry.js +2 -2
- package/dist/cjs/q2-chart-donut.cjs.entry.js +2 -2
- package/dist/cjs/q2-checkbox-group.cjs.entry.js +2 -2
- package/dist/cjs/q2-checkbox.cjs.entry.js +3 -3
- package/dist/cjs/q2-dropdown-item.cjs.entry.js +2 -2
- package/dist/cjs/q2-dropdown.cjs.entry.js +2 -2
- package/dist/cjs/q2-editable-field.cjs.entry.js +2 -2
- package/dist/cjs/q2-icon.cjs.entry.js +2 -2
- package/dist/cjs/q2-loc.cjs.entry.js +2 -2
- package/dist/cjs/q2-message.cjs.entry.js +2 -2
- package/dist/cjs/q2-optgroup.cjs.entry.js +2 -2
- package/dist/cjs/q2-option-list.cjs.entry.js +2 -2
- package/dist/cjs/q2-option.cjs.entry.js +12 -1
- package/dist/cjs/q2-pagination.cjs.entry.js +2 -2
- package/dist/cjs/q2-pill.cjs.entry.js +2 -2
- package/dist/cjs/q2-radio-group.cjs.entry.js +2 -2
- package/dist/cjs/q2-radio.cjs.entry.js +2 -2
- package/dist/cjs/q2-section.cjs.entry.js +2 -2
- package/dist/cjs/q2-select.cjs.entry.js +298 -199
- package/dist/cjs/q2-stepper-pane.cjs.entry.js +2 -2
- package/dist/cjs/q2-stepper-vertical.cjs.entry.js +3 -2
- package/dist/cjs/q2-stepper.cjs.entry.js +2 -2
- package/dist/cjs/q2-tab-container.cjs.entry.js +2 -2
- package/dist/cjs/q2-tab-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-tag.cjs.entry.js +2 -2
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/cjs/q2-textarea.cjs.entry.js +2 -2
- package/dist/cjs/q2-tooltip.cjs.entry.js +33 -0
- package/dist/cjs/tecton-tab-pane.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/q2-avatar/styles.css +1 -1
- package/dist/collection/components/q2-badge/index.js +4 -7
- package/dist/collection/components/q2-badge/styles.css +19 -12
- package/dist/collection/components/q2-btn/index.js +7 -6
- package/dist/collection/components/q2-btn/styles.css +10 -12
- package/dist/collection/components/q2-calendar/styles.css +7 -7
- package/dist/collection/components/q2-card/index.js +33 -8
- package/dist/collection/components/q2-card/styles.css +33 -36
- package/dist/collection/components/q2-carousel/styles.css +1 -1
- package/dist/collection/components/q2-carousel-pane/styles.css +1 -1
- package/dist/collection/components/q2-chart-donut/styles.css +3 -2
- package/dist/collection/components/q2-checkbox/index.js +1 -1
- package/dist/collection/components/q2-checkbox/styles.css +2 -2
- package/dist/collection/components/q2-checkbox-group/styles.css +3 -3
- package/dist/collection/components/q2-dropdown/styles.css +6 -6
- package/dist/collection/components/q2-dropdown-item/styles.css +3 -3
- package/dist/collection/components/q2-editable-field/styles.css +4 -4
- package/dist/collection/components/q2-icon/styles.css +1 -1
- package/dist/collection/components/q2-input/index.js +90 -23
- package/dist/collection/components/q2-input/styles.css +33 -26
- package/dist/collection/components/q2-loading/styles.css +4 -4
- package/dist/collection/components/q2-loc/styles.css +1 -1
- package/dist/collection/components/q2-message/styles.css +19 -17
- package/dist/collection/components/q2-optgroup/styles.css +7 -11
- package/dist/collection/components/q2-option/index.js +15 -3
- package/dist/collection/components/q2-option/styles.css +12 -5
- package/dist/collection/components/q2-option-list/styles.css +5 -5
- package/dist/collection/components/q2-pagination/styles.css +1 -1
- package/dist/collection/components/q2-pill/styles.css +18 -17
- package/dist/collection/components/q2-radio/styles.css +2 -2
- package/dist/collection/components/q2-radio-group/styles.css +3 -3
- package/dist/collection/components/q2-section/styles.css +6 -6
- package/dist/collection/components/q2-select/index.js +314 -206
- package/dist/collection/components/q2-select/styles.css +24 -13
- package/dist/collection/components/q2-stepper/styles.css +19 -13
- package/dist/collection/components/q2-stepper-pane/styles.css +1 -1
- package/dist/collection/components/q2-stepper-vertical/index.js +1 -0
- package/dist/collection/components/q2-stepper-vertical/styles.css +14 -14
- package/dist/collection/components/q2-tab-container/styles.css +7 -7
- package/dist/collection/components/q2-tab-pane/styles.css +1 -1
- package/dist/collection/components/q2-tag/styles.css +4 -6
- package/dist/collection/components/q2-textarea/styles.css +2 -2
- package/dist/collection/components/q2-tooltip/index.js +120 -0
- package/dist/collection/components/q2-tooltip/styles.css +276 -0
- package/dist/collection/components/tecton-tab-pane/styles.css +1 -1
- package/dist/collection/utils/index.js +18 -2
- package/dist/esm/{index-14e81efa.js → index-2ca8c93c.js} +18 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-avatar.entry.js +1 -1
- package/dist/esm/{q2-input.entry.js → q2-badge_2.entry.js} +78 -20
- package/dist/esm/q2-btn_2.entry.js +7 -6
- package/dist/esm/q2-calendar.entry.js +2 -2
- package/dist/esm/q2-card.entry.js +15 -8
- package/dist/esm/q2-carousel-pane.entry.js +2 -2
- package/dist/esm/q2-carousel.entry.js +2 -2
- package/dist/esm/q2-chart-donut.entry.js +2 -2
- package/dist/esm/q2-checkbox-group.entry.js +2 -2
- package/dist/esm/q2-checkbox.entry.js +3 -3
- package/dist/esm/q2-dropdown-item.entry.js +2 -2
- package/dist/esm/q2-dropdown.entry.js +2 -2
- package/dist/esm/q2-editable-field.entry.js +2 -2
- package/dist/esm/q2-icon.entry.js +2 -2
- package/dist/esm/q2-loc.entry.js +2 -2
- package/dist/esm/q2-message.entry.js +2 -2
- package/dist/esm/q2-optgroup.entry.js +2 -2
- package/dist/esm/q2-option-list.entry.js +2 -2
- package/dist/esm/q2-option.entry.js +12 -1
- package/dist/esm/q2-pagination.entry.js +2 -2
- package/dist/esm/q2-pill.entry.js +2 -2
- package/dist/esm/q2-radio-group.entry.js +2 -2
- package/dist/esm/q2-radio.entry.js +2 -2
- package/dist/esm/q2-section.entry.js +2 -2
- package/dist/esm/q2-select.entry.js +298 -199
- package/dist/esm/q2-stepper-pane.entry.js +2 -2
- package/dist/esm/q2-stepper-vertical.entry.js +3 -2
- package/dist/esm/q2-stepper.entry.js +2 -2
- package/dist/esm/q2-tab-container.entry.js +2 -2
- package/dist/esm/q2-tab-pane.entry.js +1 -1
- package/dist/esm/q2-tag.entry.js +2 -2
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/esm/q2-textarea.entry.js +2 -2
- package/dist/esm/q2-tooltip.entry.js +29 -0
- package/dist/esm/tecton-tab-pane.entry.js +1 -1
- package/dist/q2-tecton-elements/{p-77263ed4.entry.js → p-0a8b8d14.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-0b5fbbe8.entry.js +1 -0
- package/dist/q2-tecton-elements/p-0d00030f.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-85cff6ec.entry.js → p-0e9c7220.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-1b0f826e.entry.js +1 -0
- package/dist/q2-tecton-elements/p-1c430c2a.entry.js +1 -0
- package/dist/q2-tecton-elements/p-2d2008fd.entry.js +1 -0
- package/dist/q2-tecton-elements/p-34f99830.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-ead64414.entry.js → p-35bde69c.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d46efe36.entry.js → p-376988ef.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-41fcf343.js +1 -0
- package/dist/q2-tecton-elements/p-49612230.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-e3406026.entry.js → p-4b48fde6.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-4ec2cb69.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-ea2a290e.entry.js → p-5270b0ff.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-dc1ef3fa.entry.js → p-5e990654.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-60400f59.entry.js → p-60a7a11e.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-677faf2c.entry.js +1 -0
- package/dist/q2-tecton-elements/p-6e10db80.entry.js +1 -0
- package/dist/q2-tecton-elements/p-6f884c60.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-991d7d22.entry.js → p-822d3d6c.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-8584c6bc.entry.js +1 -0
- package/dist/q2-tecton-elements/p-87766054.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-b0dc920c.entry.js → p-879aa7ac.entry.js} +2 -2
- package/dist/q2-tecton-elements/p-92e9f290.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-627df469.entry.js → p-b6c45ef6.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-cf9e8120.entry.js → p-b7dc4e93.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-c59d601e.entry.js +1 -0
- package/dist/q2-tecton-elements/p-d040bf99.entry.js +1 -0
- package/dist/q2-tecton-elements/p-d79386c6.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-fbfb3615.entry.js → p-dd3f64a7.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-58e42fc5.entry.js → p-dd792081.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-ef2f68b2.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-9b2bc894.entry.js → p-f617c54a.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-f66adef0.entry.js +1 -0
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/types/components/q2-badge/index.d.ts +0 -1
- package/dist/types/components/q2-card/index.d.ts +1 -0
- package/dist/types/components/q2-input/index.d.ts +6 -2
- package/dist/types/components/q2-option/index.d.ts +2 -0
- package/dist/types/components/q2-select/index.d.ts +37 -24
- package/dist/types/components/q2-tooltip/index.d.ts +10 -0
- package/dist/types/components.d.ts +29 -0
- package/dist/types/utils/index.d.ts +3 -1
- package/dist/types/workspace/workspace/{tecton-production_release_1.15.x → tecton-production_release_1.16.x}/packages/q2-tecton-elements/.stencil/test/elements/q2-tag-test.d.ts +0 -0
- package/dist/types/workspace/workspace/{tecton-production_release_1.15.x → tecton-production_release_1.16.x}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +0 -0
- package/package.json +2 -2
- package/dist/cjs/q2-badge.cjs.entry.js +0 -41
- package/dist/esm/q2-badge.entry.js +0 -37
- package/dist/q2-tecton-elements/p-0e13d5ba.entry.js +0 -1
- package/dist/q2-tecton-elements/p-1b3c4cb2.entry.js +0 -1
- package/dist/q2-tecton-elements/p-2f13d873.entry.js +0 -1
- package/dist/q2-tecton-elements/p-37f1984c.entry.js +0 -1
- package/dist/q2-tecton-elements/p-3cfc0cb4.entry.js +0 -1
- package/dist/q2-tecton-elements/p-431bf43e.js +0 -1
- package/dist/q2-tecton-elements/p-50615a56.entry.js +0 -1
- package/dist/q2-tecton-elements/p-663cb6e8.entry.js +0 -1
- package/dist/q2-tecton-elements/p-6ced7858.entry.js +0 -1
- package/dist/q2-tecton-elements/p-704d7f41.entry.js +0 -1
- package/dist/q2-tecton-elements/p-7249de38.entry.js +0 -1
- package/dist/q2-tecton-elements/p-8a8c6374.entry.js +0 -1
- package/dist/q2-tecton-elements/p-8f815678.entry.js +0 -1
- package/dist/q2-tecton-elements/p-9af46ffc.entry.js +0 -1
- package/dist/q2-tecton-elements/p-9d8a963b.entry.js +0 -1
- package/dist/q2-tecton-elements/p-bd6c6239.entry.js +0 -1
- package/dist/q2-tecton-elements/p-c4eff511.entry.js +0 -1
- package/dist/q2-tecton-elements/p-d5ecb3ba.entry.js +0 -1
- package/dist/q2-tecton-elements/p-e0ddf788.entry.js +0 -1
- package/dist/q2-tecton-elements/p-e435159b.entry.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component, Prop, Element, h, Listen, State, Event, Watch, } from '@stencil/core';
|
|
2
|
-
import { createGuid, handleAriaLabel, isEventFromElement, loc, overrideFocus, setPopProperties } from 'src/utils';
|
|
2
|
+
import { createGuid, handleAriaLabel, isEventFromElement, isRelatedTargetWithinHost, loc, overrideFocus, resizeIframe, setPopProperties, } from 'src/utils';
|
|
3
3
|
export class Q2Select {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.selectedOptions = [];
|
|
@@ -15,6 +15,7 @@ export class Q2Select {
|
|
|
15
15
|
this.searchText = '';
|
|
16
16
|
this.hasCustomDisplay = false;
|
|
17
17
|
this.inputFocused = false;
|
|
18
|
+
this.prioritizeSearch = false;
|
|
18
19
|
this.scheduledAfterRender = [];
|
|
19
20
|
this.keyStore = {
|
|
20
21
|
queue: [],
|
|
@@ -82,7 +83,7 @@ export class Q2Select {
|
|
|
82
83
|
setFocus(matched);
|
|
83
84
|
}
|
|
84
85
|
};
|
|
85
|
-
|
|
86
|
+
/// Event handlers ///
|
|
86
87
|
this.dropdownFocusoutHandler = (event) => {
|
|
87
88
|
const { relatedTarget } = event;
|
|
88
89
|
const isInDropdown = this.dropdownContainer.contains(relatedTarget);
|
|
@@ -105,11 +106,10 @@ export class Q2Select {
|
|
|
105
106
|
case ' ':
|
|
106
107
|
case 'Enter':
|
|
107
108
|
event.preventDefault();
|
|
108
|
-
event.stopPropagation();
|
|
109
109
|
const newOption = this.hostElement.querySelector(`[option-id="${this.activeOptionId}"]`);
|
|
110
110
|
if (!newOption || newOption.disabled)
|
|
111
111
|
break;
|
|
112
|
-
this.selectOption(newOption
|
|
112
|
+
this.selectOption(newOption, true);
|
|
113
113
|
break;
|
|
114
114
|
case 'ArrowUp':
|
|
115
115
|
event.preventDefault();
|
|
@@ -163,7 +163,9 @@ export class Q2Select {
|
|
|
163
163
|
const myOption = this.hostElement.querySelector(`[option-id="${this.activeOptionId}"]`);
|
|
164
164
|
if (!myOption || myOption.disabled)
|
|
165
165
|
return;
|
|
166
|
-
|
|
166
|
+
if (myOption.selected)
|
|
167
|
+
return;
|
|
168
|
+
this.selectOption(myOption);
|
|
167
169
|
break;
|
|
168
170
|
case 'Esc':
|
|
169
171
|
case 'Escape':
|
|
@@ -180,10 +182,11 @@ export class Q2Select {
|
|
|
180
182
|
break;
|
|
181
183
|
}
|
|
182
184
|
};
|
|
185
|
+
/* tslint:enable:cyclomatic-complexity */
|
|
183
186
|
this.inputKeydownHandler = (event) => {
|
|
184
187
|
event.stopPropagation();
|
|
185
|
-
const { key } = event;
|
|
186
|
-
const { optionElements,
|
|
188
|
+
const { key, shiftKey } = event;
|
|
189
|
+
const { optionElements, searchable } = this;
|
|
187
190
|
switch (key) {
|
|
188
191
|
case 'ArrowDown':
|
|
189
192
|
event.preventDefault();
|
|
@@ -204,19 +207,14 @@ export class Q2Select {
|
|
|
204
207
|
break;
|
|
205
208
|
case 'Escape':
|
|
206
209
|
case 'Esc':
|
|
207
|
-
|
|
208
|
-
this.closeDropdown();
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
this.searchText = '';
|
|
212
|
-
}
|
|
210
|
+
this.closeDropdown();
|
|
213
211
|
break;
|
|
214
212
|
case 'Tab':
|
|
215
|
-
|
|
216
|
-
this.closeDropdown();
|
|
217
|
-
}
|
|
213
|
+
this.closeDropdown();
|
|
218
214
|
break;
|
|
219
215
|
default:
|
|
216
|
+
if (shiftKey)
|
|
217
|
+
break;
|
|
220
218
|
if (searchable) {
|
|
221
219
|
this.openDropdownWithoutActiveElement();
|
|
222
220
|
break;
|
|
@@ -240,10 +238,11 @@ export class Q2Select {
|
|
|
240
238
|
const didChangeText = inputValue !== eventValue;
|
|
241
239
|
const shouldClearValue = !!this.value && didChangeText;
|
|
242
240
|
if (shouldClearValue) {
|
|
243
|
-
this.selectOption(
|
|
241
|
+
this.selectOption(null);
|
|
244
242
|
}
|
|
245
243
|
if (!this.dropdownOpen)
|
|
246
244
|
this.openDropdownWithoutActiveElement();
|
|
245
|
+
this.prioritizeSearch = true;
|
|
247
246
|
this.searchText = eventValue;
|
|
248
247
|
this.input.emit({ query: eventValue });
|
|
249
248
|
};
|
|
@@ -265,6 +264,11 @@ export class Q2Select {
|
|
|
265
264
|
}
|
|
266
265
|
}
|
|
267
266
|
};
|
|
267
|
+
this.onCustomDisplayClick = (event) => {
|
|
268
|
+
event.stopPropagation();
|
|
269
|
+
this.focusInput();
|
|
270
|
+
this.toggleDropdown();
|
|
271
|
+
};
|
|
268
272
|
this.showSelectedOptions = (event) => {
|
|
269
273
|
event.stopImmediatePropagation();
|
|
270
274
|
this.onlyShowingSelected = true;
|
|
@@ -279,17 +283,189 @@ export class Q2Select {
|
|
|
279
283
|
optionElement._multiSelectHidden = false;
|
|
280
284
|
});
|
|
281
285
|
};
|
|
282
|
-
this.onCustomDisplayClick = (event) => {
|
|
283
|
-
event.stopPropagation();
|
|
284
|
-
this.focusInput();
|
|
285
|
-
this.toggleDropdown();
|
|
286
|
-
};
|
|
287
286
|
}
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
/// Lifecycle Hooks ///
|
|
288
|
+
componentWillLoad() {
|
|
289
|
+
handleAriaLabel(this);
|
|
290
|
+
}
|
|
291
|
+
componentDidLoad() {
|
|
292
|
+
const observer = new MutationObserver(this.onMutationObserved);
|
|
293
|
+
observer.observe(this.hostElement, { childList: true, subtree: true });
|
|
294
|
+
this.mutationObserver = observer;
|
|
295
|
+
this.onMutationObserved();
|
|
296
|
+
overrideFocus(this.hostElement);
|
|
297
|
+
setTimeout(() => this.checkSelectedDisplay(), 0);
|
|
298
|
+
}
|
|
299
|
+
componentDidRender() {
|
|
300
|
+
setTimeout(() => {
|
|
301
|
+
this.scheduledAfterRender.forEach(fn => fn());
|
|
302
|
+
this.scheduledAfterRender = [];
|
|
303
|
+
}, 25);
|
|
304
|
+
}
|
|
305
|
+
disconnectedCallback() {
|
|
306
|
+
var _a;
|
|
307
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
308
|
+
this.mutationObserver = null;
|
|
309
|
+
}
|
|
310
|
+
/// Getters ///
|
|
311
|
+
get isComponentFocused() {
|
|
312
|
+
return document.activeElement === this.hostElement || !!this.hostElement.querySelector(':focus');
|
|
313
|
+
}
|
|
314
|
+
get isSearchMode() {
|
|
315
|
+
return (this.searchable && this.inputFocused) || this.searchText;
|
|
316
|
+
}
|
|
317
|
+
get badgeValue() {
|
|
318
|
+
if (!this.multiple)
|
|
319
|
+
return;
|
|
320
|
+
const optionsLength = this.selectedOptions.length;
|
|
321
|
+
if (this.dropdownOpen && this.searchable)
|
|
322
|
+
return optionsLength || null;
|
|
323
|
+
else
|
|
324
|
+
return optionsLength > 1 ? `+${optionsLength - 1}` : null;
|
|
325
|
+
}
|
|
326
|
+
get minPopHeight() {
|
|
327
|
+
const { minRows } = this;
|
|
328
|
+
const firstOption = this.hostElement.querySelector('q2-option:not([hidden])');
|
|
329
|
+
const minHeight = firstOption ? window.getComputedStyle(firstOption).minHeight : '44px';
|
|
330
|
+
return minRows * parseInt(minHeight);
|
|
331
|
+
}
|
|
332
|
+
get selectedDisplay() {
|
|
333
|
+
if (this.prioritizeSearch || this.searchText)
|
|
334
|
+
return this.searchText;
|
|
335
|
+
if (this.hasCustomDisplay)
|
|
336
|
+
return '';
|
|
337
|
+
return this.multiple ? this.calculateMultiSelectSelectedDisplay() : this.calculateSingleSelectSelectedDisplay();
|
|
338
|
+
}
|
|
339
|
+
get selectedDisplaySlot() {
|
|
340
|
+
return this.hostElement.querySelector('[slot="_selected-display"]');
|
|
341
|
+
}
|
|
342
|
+
get firstSelectedValue() {
|
|
343
|
+
var _a, _b;
|
|
344
|
+
if (this.multiple)
|
|
345
|
+
return (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
|
|
346
|
+
return this.value;
|
|
347
|
+
}
|
|
348
|
+
get firstSelectedOptionElement() {
|
|
349
|
+
const { firstSelectedValue } = this;
|
|
350
|
+
return firstSelectedValue ? this.optionElements.find(({ value }) => value === firstSelectedValue) : null;
|
|
351
|
+
}
|
|
352
|
+
get optionElements() {
|
|
353
|
+
return Array.from(this.hostElement.querySelectorAll('q2-option'));
|
|
354
|
+
}
|
|
355
|
+
get visibleOptionElements() {
|
|
356
|
+
return Array.from(this.hostElement.querySelectorAll('q2-option:not([_multiselecthidden])'));
|
|
357
|
+
}
|
|
358
|
+
get wrapperClasses() {
|
|
359
|
+
const { errors } = this;
|
|
360
|
+
const classes = ['q2-select-container'];
|
|
361
|
+
if (this.dropdownOpen)
|
|
362
|
+
classes.push('dropdown-open');
|
|
363
|
+
if (Array.isArray(errors) && errors.length > 0)
|
|
364
|
+
classes.push('has-error');
|
|
365
|
+
if (this.inputFocused)
|
|
366
|
+
classes.push('is-focused');
|
|
367
|
+
if (this.searchable)
|
|
368
|
+
classes.push('is-searchable');
|
|
369
|
+
return classes.join(' ');
|
|
370
|
+
}
|
|
371
|
+
/// Watchers ///
|
|
372
|
+
ariaLabelObserver() {
|
|
373
|
+
handleAriaLabel(this);
|
|
374
|
+
}
|
|
375
|
+
valueUpdated() {
|
|
376
|
+
if (this.multiple)
|
|
377
|
+
return;
|
|
378
|
+
this.updateSingleOptionAttrs();
|
|
379
|
+
}
|
|
380
|
+
selectedOptionsUpdated() {
|
|
381
|
+
if (!this.multiple)
|
|
382
|
+
return;
|
|
383
|
+
this.updateMultipleOptionAttrs();
|
|
384
|
+
}
|
|
385
|
+
multilineOptionsChanged(newValue, oldValue) {
|
|
386
|
+
if (newValue === oldValue)
|
|
387
|
+
return;
|
|
388
|
+
this.optionElements.forEach(element => (element.multiline = newValue));
|
|
389
|
+
}
|
|
390
|
+
dropdownOpenChanged(isOpen) {
|
|
391
|
+
this.scheduledAfterRender.push(() => {
|
|
392
|
+
const { multiple, multiSelectHeader, dropdownContainer } = this;
|
|
393
|
+
const height = (isOpen && multiple && (multiSelectHeader === null || multiSelectHeader === void 0 ? void 0 : multiSelectHeader.offsetHeight)) || 0;
|
|
394
|
+
if (height) {
|
|
395
|
+
dropdownContainer.style.setProperty('--comp-multi-select-header-height', `${height}px`);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
dropdownContainer.style.removeProperty('--comp-multi-select-header-height');
|
|
399
|
+
}
|
|
400
|
+
});
|
|
290
401
|
}
|
|
402
|
+
/// Listeners ///
|
|
403
|
+
keydownHandler(event) {
|
|
404
|
+
this.inputKeydownHandler(event);
|
|
405
|
+
}
|
|
406
|
+
onHostElementChange(event) {
|
|
407
|
+
if (this.readonly)
|
|
408
|
+
return;
|
|
409
|
+
if (event.target !== this.hostElement || this.hostElement.onchange)
|
|
410
|
+
return;
|
|
411
|
+
if (this.multiple) {
|
|
412
|
+
this.selectedOptions = event.detail.selectedOptions;
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
this.value = event.detail.value;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
onHostElementInput(event) {
|
|
419
|
+
if (!this.searchable || event.target !== this.hostElement || this.hostElement.oninput)
|
|
420
|
+
return;
|
|
421
|
+
const options = this.optionElements;
|
|
422
|
+
const query = this.searchText.trim().toLocaleLowerCase();
|
|
423
|
+
let matchedCount = 0;
|
|
424
|
+
options.forEach(option => {
|
|
425
|
+
var _a;
|
|
426
|
+
if (query === '') {
|
|
427
|
+
option.hidden = false;
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
const title = ((_a = option.firstElementChild) === null || _a === void 0 ? void 0 : _a.tagName) === 'Q2-CARD'
|
|
431
|
+
? option.firstElementChild.title
|
|
432
|
+
: null;
|
|
433
|
+
const { display = '', innerText = '' } = option;
|
|
434
|
+
const searchParams = [display, title, innerText];
|
|
435
|
+
const matched = searchParams.some(text => { var _a; return (_a = text === null || text === void 0 ? void 0 : text.toLocaleLowerCase().includes(query)) !== null && _a !== void 0 ? _a : false; });
|
|
436
|
+
option.hidden = !matched;
|
|
437
|
+
if (matched)
|
|
438
|
+
matchedCount++;
|
|
439
|
+
});
|
|
440
|
+
const statusMessageLocString = query
|
|
441
|
+
? 'tecton.element.select.searchable.results'
|
|
442
|
+
: 'tecton.element.select.allOptions';
|
|
443
|
+
const count = query ? matchedCount : options.length;
|
|
444
|
+
this.setStatusMessage(loc(statusMessageLocString, [count]));
|
|
445
|
+
}
|
|
446
|
+
delegateFocus(event) {
|
|
447
|
+
const fromHost = isRelatedTargetWithinHost(event, this.hostElement);
|
|
448
|
+
const prioritizeSearch = (this.prioritizeSearch = fromHost && this.searchable);
|
|
449
|
+
if (prioritizeSearch) {
|
|
450
|
+
this.clearSelectedDisplay();
|
|
451
|
+
}
|
|
452
|
+
else if (isEventFromElement(event, this.hostElement)) {
|
|
453
|
+
this.inputField.shadowRoot.querySelector('.input-field').focus();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
handleFocusout(event) {
|
|
457
|
+
this.prioritizeSearch = !isRelatedTargetWithinHost(event, this.hostElement) && this.searchable;
|
|
458
|
+
}
|
|
459
|
+
clickHandler(event) {
|
|
460
|
+
const selectedOption = event.target.closest('q2-option');
|
|
461
|
+
if (!selectedOption ||
|
|
462
|
+
(selectedOption.hasAttribute('disabled') && selectedOption.getAttribute('disabled') !== 'false'))
|
|
463
|
+
return;
|
|
464
|
+
this.selectOption(selectedOption, true);
|
|
465
|
+
}
|
|
466
|
+
/// Helpers ///
|
|
291
467
|
getDefaultActiveIndex() {
|
|
292
|
-
const firstSelected = this.optionElements.findIndex(element => element.selected);
|
|
468
|
+
const firstSelected = this.optionElements.findIndex(element => element.selected && !element.hidden);
|
|
293
469
|
if (firstSelected > -1)
|
|
294
470
|
return firstSelected;
|
|
295
471
|
const firstEnabled = this.optionElements.findIndex(element => !element.hidden);
|
|
@@ -328,84 +504,67 @@ export class Q2Select {
|
|
|
328
504
|
option.focus();
|
|
329
505
|
}
|
|
330
506
|
calculateMultiSelectSelectedDisplay() {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
});
|
|
335
|
-
return ((selectedOption && selectedOption.display && loc(selectedOption.display)) ||
|
|
336
|
-
(selectedOption && selectedOption.value) ||
|
|
337
|
-
this.selectedOptions[0]);
|
|
338
|
-
}
|
|
339
|
-
else if (this.selectedOptions.length > 1) {
|
|
340
|
-
return loc('tecton.element.select.multiDisplay', [this.selectedOptions.length]);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
507
|
+
var _a;
|
|
508
|
+
const { firstSelectedOptionElement, firstSelectedValue, multilineOptions } = this;
|
|
509
|
+
if (!firstSelectedValue)
|
|
343
510
|
return '';
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
});
|
|
350
|
-
return (selectedOption && selectedOption.display && loc(selectedOption.display)) || this.value || '';
|
|
351
|
-
}
|
|
352
|
-
get minPopHeight() {
|
|
353
|
-
const { minRows } = this;
|
|
354
|
-
const firstOption = this.hostElement.querySelector('q2-option:not([hidden])');
|
|
355
|
-
const minHeight = firstOption ? window.getComputedStyle(firstOption).minHeight : '44px';
|
|
356
|
-
return minRows * parseInt(minHeight);
|
|
357
|
-
}
|
|
358
|
-
get selectedDisplay() {
|
|
359
|
-
if (this.hasCustomDisplay && !this.searchText) {
|
|
511
|
+
if (firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.display)
|
|
512
|
+
return loc(firstSelectedOptionElement.display);
|
|
513
|
+
if (multilineOptions && this.searchable)
|
|
514
|
+
return this.searchText;
|
|
515
|
+
if (multilineOptions)
|
|
360
516
|
return '';
|
|
361
|
-
|
|
362
|
-
if (this.searchable && this.dropdownOpen && !this.value) {
|
|
363
|
-
// when dropdown is open search selects show typing
|
|
364
|
-
// when closed they display the same as non searchable select (what is selected)
|
|
365
|
-
return this.searchText || '';
|
|
366
|
-
}
|
|
367
|
-
return this.multiple ? this.calculateMultiSelectSelectedDisplay() : this.calculateSingleSelectSelectedDisplay();
|
|
517
|
+
return (_a = firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.value) !== null && _a !== void 0 ? _a : firstSelectedValue;
|
|
368
518
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
get optionElements() {
|
|
373
|
-
return Array.from(this.hostElement.querySelectorAll('q2-option'));
|
|
374
|
-
}
|
|
375
|
-
get wrapperClasses() {
|
|
376
|
-
const dropdownOpenClass = (this.dropdownOpen && ' dropdown-open') || '';
|
|
377
|
-
const errorClass = Array.isArray(this.errors) && this.errors.length > 0 ? ' has-error' : '';
|
|
378
|
-
const focusClass = this.inputFocused ? ' is-focused' : '';
|
|
379
|
-
const searchableClass = this.searchable ? ' is-searchable' : '';
|
|
380
|
-
return `q2-select-container${dropdownOpenClass}${errorClass}${focusClass}${searchableClass}`;
|
|
519
|
+
calculateSingleSelectSelectedDisplay() {
|
|
520
|
+
const { firstSelectedOptionElement } = this;
|
|
521
|
+
return ((firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.display) && loc(firstSelectedOptionElement.display)) || this.value || '';
|
|
381
522
|
}
|
|
382
523
|
updateSingleOptionAttrs() {
|
|
524
|
+
const { value, guid, multilineOptions } = this;
|
|
383
525
|
this.optionElements.forEach((element, index) => {
|
|
384
|
-
element.selected =
|
|
385
|
-
element.optionId = `q2-select-${
|
|
386
|
-
element.multiline =
|
|
526
|
+
element.selected = element.value === value;
|
|
527
|
+
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
528
|
+
element.multiline = multilineOptions;
|
|
387
529
|
});
|
|
388
530
|
}
|
|
389
531
|
updateMultipleOptionAttrs() {
|
|
390
532
|
if (this.selectedOptions.length === 0) {
|
|
391
533
|
this.onlyShowingSelected = false;
|
|
392
534
|
}
|
|
535
|
+
const { selectedOptions, onlyShowingSelected, guid, multilineOptions } = this;
|
|
393
536
|
this.optionElements.forEach((element, index) => {
|
|
394
|
-
element.selected =
|
|
395
|
-
element._multiSelectHidden =
|
|
396
|
-
element.optionId = `q2-select-${
|
|
397
|
-
element.multiline =
|
|
537
|
+
element.selected = selectedOptions.includes(element.value);
|
|
538
|
+
element._multiSelectHidden = onlyShowingSelected ? !element.selected : false;
|
|
539
|
+
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
540
|
+
element.multiline = multilineOptions;
|
|
398
541
|
});
|
|
399
542
|
}
|
|
400
|
-
|
|
543
|
+
focusSelectedSibling(option) {
|
|
544
|
+
if (!this.onlyShowingSelected)
|
|
545
|
+
return;
|
|
546
|
+
const { visibleOptionElements } = this;
|
|
547
|
+
if (visibleOptionElements.length < 2)
|
|
548
|
+
return;
|
|
549
|
+
const optionIndex = visibleOptionElements.indexOf(option);
|
|
550
|
+
const visibleFocusIndex = optionIndex ? optionIndex - 1 : optionIndex + 1;
|
|
551
|
+
const optionToFocus = visibleOptionElements[visibleFocusIndex];
|
|
552
|
+
const focusIndex = this.optionElements.indexOf(optionToFocus);
|
|
553
|
+
this.activeIndex = focusIndex;
|
|
554
|
+
this.setFocusedOption();
|
|
555
|
+
}
|
|
556
|
+
selectOption(option, focusInputOnClose = false) {
|
|
557
|
+
var _a;
|
|
558
|
+
const value = (_a = option === null || option === void 0 ? void 0 : option.value) !== null && _a !== void 0 ? _a : '';
|
|
401
559
|
if (this.multiple) {
|
|
402
560
|
const isSelected = this.selectedOptions.includes(value);
|
|
403
561
|
if (isSelected) {
|
|
562
|
+
this.focusSelectedSibling(option);
|
|
404
563
|
this.change.emit({
|
|
405
564
|
selectedOptions: this.selectedOptions.filter(selectedValue => selectedValue !== value),
|
|
406
565
|
});
|
|
407
566
|
}
|
|
408
|
-
else {
|
|
567
|
+
else if (value) {
|
|
409
568
|
this.change.emit({ selectedOptions: [...this.selectedOptions, value] });
|
|
410
569
|
}
|
|
411
570
|
}
|
|
@@ -426,7 +585,7 @@ export class Q2Select {
|
|
|
426
585
|
this.activeIndex = undefined;
|
|
427
586
|
this.setActiveOption();
|
|
428
587
|
this.dropdownOpen = true;
|
|
429
|
-
this.scheduledAfterRender.push(
|
|
588
|
+
this.scheduledAfterRender.push(resizeIframe);
|
|
430
589
|
}
|
|
431
590
|
openDropdownWithActiveElement(activeIndex) {
|
|
432
591
|
if (this.readonly)
|
|
@@ -437,7 +596,7 @@ export class Q2Select {
|
|
|
437
596
|
this.scheduledAfterRender.push(() => {
|
|
438
597
|
this.setFocusedOption();
|
|
439
598
|
this.scrollToActiveOption();
|
|
440
|
-
|
|
599
|
+
resizeIframe();
|
|
441
600
|
});
|
|
442
601
|
}
|
|
443
602
|
closeDropdown() {
|
|
@@ -446,24 +605,16 @@ export class Q2Select {
|
|
|
446
605
|
this.searchText = '';
|
|
447
606
|
this.input.emit({ query: '' });
|
|
448
607
|
}
|
|
449
|
-
this.scheduledAfterRender.push(
|
|
608
|
+
this.scheduledAfterRender.push(resizeIframe);
|
|
450
609
|
}
|
|
451
610
|
toggleDropdown() {
|
|
452
|
-
if (this.disabled)
|
|
611
|
+
if (this.disabled)
|
|
453
612
|
return;
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if (!this.dropdownOpen) {
|
|
457
|
-
this.openDropdownWithoutActiveElement();
|
|
458
|
-
}
|
|
613
|
+
if (this.dropdownOpen && !this.searchText) {
|
|
614
|
+
this.closeDropdown();
|
|
459
615
|
}
|
|
460
616
|
else {
|
|
461
|
-
|
|
462
|
-
this.closeDropdown();
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
this.openDropdownWithoutActiveElement();
|
|
466
|
-
}
|
|
617
|
+
this.openDropdownWithoutActiveElement();
|
|
467
618
|
}
|
|
468
619
|
}
|
|
469
620
|
adjustActiveOptionAndScroll(numToAdd) {
|
|
@@ -483,8 +634,9 @@ export class Q2Select {
|
|
|
483
634
|
}
|
|
484
635
|
getNextVisibleIndex(direction) {
|
|
485
636
|
let index = this.activeIndex + direction;
|
|
486
|
-
|
|
487
|
-
|
|
637
|
+
const { optionElements } = this;
|
|
638
|
+
while (index >= 0 && index <= optionElements.length - 1) {
|
|
639
|
+
const { display, visibility } = window.getComputedStyle(optionElements[index]);
|
|
488
640
|
if (display !== 'none' && visibility !== 'hidden') {
|
|
489
641
|
return index;
|
|
490
642
|
}
|
|
@@ -492,95 +644,6 @@ export class Q2Select {
|
|
|
492
644
|
}
|
|
493
645
|
return -1;
|
|
494
646
|
}
|
|
495
|
-
////////// LIFECYCLE HOOKS ////////
|
|
496
|
-
componentWillLoad() {
|
|
497
|
-
handleAriaLabel(this);
|
|
498
|
-
}
|
|
499
|
-
componentDidLoad() {
|
|
500
|
-
const observer = new MutationObserver(this.onMutationObserved);
|
|
501
|
-
observer.observe(this.hostElement, { childList: true, subtree: true });
|
|
502
|
-
this.mutationObserver = observer;
|
|
503
|
-
this.onMutationObserved();
|
|
504
|
-
overrideFocus(this.hostElement);
|
|
505
|
-
}
|
|
506
|
-
componentDidRender() {
|
|
507
|
-
setTimeout(() => {
|
|
508
|
-
this.scheduledAfterRender.forEach(fn => fn());
|
|
509
|
-
this.scheduledAfterRender = [];
|
|
510
|
-
}, 25);
|
|
511
|
-
}
|
|
512
|
-
disconnectedCallback() {
|
|
513
|
-
if (this.mutationObserver) {
|
|
514
|
-
this.mutationObserver.disconnect();
|
|
515
|
-
this.mutationObserver = null;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
////////// OBSERVERS //////////
|
|
519
|
-
ariaLabelObserver() {
|
|
520
|
-
handleAriaLabel(this);
|
|
521
|
-
}
|
|
522
|
-
valueUpdated() {
|
|
523
|
-
if (this.multiple) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
this.updateSingleOptionAttrs();
|
|
527
|
-
}
|
|
528
|
-
selectedOptionsUpdated() {
|
|
529
|
-
if (!this.multiple) {
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
this.updateMultipleOptionAttrs();
|
|
533
|
-
}
|
|
534
|
-
multilineOptionsChanged(newValue, oldValue) {
|
|
535
|
-
if (newValue === oldValue) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
this.optionElements.forEach(element => {
|
|
539
|
-
element.multiline = this.multilineOptions;
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
onHostElementChange(event) {
|
|
543
|
-
if (this.readonly)
|
|
544
|
-
return;
|
|
545
|
-
if (event.target === this.hostElement && !this.hostElement.onchange) {
|
|
546
|
-
if (this.multiple) {
|
|
547
|
-
this.selectedOptions = event.detail.selectedOptions;
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
this.value = event.detail.value;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
onHostElementInput(event) {
|
|
555
|
-
if (this.searchable && event.target === this.hostElement && !this.hostElement.oninput) {
|
|
556
|
-
const options = this.optionElements;
|
|
557
|
-
const query = event.detail.query.trim().toLowerCase();
|
|
558
|
-
let matchedCount = 0;
|
|
559
|
-
options.forEach(option => {
|
|
560
|
-
if (query === '') {
|
|
561
|
-
option.style.display = '';
|
|
562
|
-
option.hidden = false;
|
|
563
|
-
}
|
|
564
|
-
else {
|
|
565
|
-
const { display = '', innerText = '' } = option;
|
|
566
|
-
const matched = display.toLowerCase().includes(query) || innerText.toLowerCase().includes(query);
|
|
567
|
-
option.hidden = !matched;
|
|
568
|
-
if (matched)
|
|
569
|
-
matchedCount++;
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
const statusMessageLocString = query
|
|
573
|
-
? 'tecton.element.select.searchable.results'
|
|
574
|
-
: 'tecton.element.select.allOptions';
|
|
575
|
-
const count = query ? matchedCount : options.length;
|
|
576
|
-
this.setStatusMessage(loc(statusMessageLocString, [count]));
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
delegateFocus(event) {
|
|
580
|
-
if (!isEventFromElement(event, this.hostElement))
|
|
581
|
-
return;
|
|
582
|
-
this.inputField.shadowRoot.querySelector('.input-field').focus();
|
|
583
|
-
}
|
|
584
647
|
setStatusMessage(message) {
|
|
585
648
|
clearTimeout(this.statusMessageTimer);
|
|
586
649
|
this.statusMessage = '';
|
|
@@ -588,25 +651,59 @@ export class Q2Select {
|
|
|
588
651
|
this.statusMessage = message;
|
|
589
652
|
}, 1000);
|
|
590
653
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
654
|
+
clearSelectedDisplay() {
|
|
655
|
+
var _a;
|
|
656
|
+
(_a = this.selectedDisplaySlot) === null || _a === void 0 ? void 0 : _a.remove();
|
|
657
|
+
}
|
|
658
|
+
checkSelectedDisplay() {
|
|
659
|
+
let namedSlot = this.selectedDisplaySlot;
|
|
660
|
+
const { value, multiple, selectedOptions, multilineOptions, firstSelectedOptionElement, prioritizeSearch } = this;
|
|
661
|
+
const hasNoValue = !value && multiple && !selectedOptions.length;
|
|
662
|
+
if (prioritizeSearch || !multilineOptions || hasNoValue)
|
|
663
|
+
return this.clearSelectedDisplay();
|
|
664
|
+
if (!firstSelectedOptionElement || firstSelectedOptionElement.display)
|
|
665
|
+
return this.clearSelectedDisplay();
|
|
666
|
+
// Clone selected option and remove elements with hide-on-select attribute
|
|
667
|
+
const selectionClone = firstSelectedOptionElement.firstElementChild.cloneNode(true);
|
|
668
|
+
selectionClone.querySelectorAll('[hide-on-select]').forEach(element => element.remove());
|
|
669
|
+
if (namedSlot) {
|
|
670
|
+
const height = namedSlot.clientHeight === 0 ? 'auto' : `${namedSlot.clientHeight}px`;
|
|
671
|
+
namedSlot.style.setProperty('--comp-selected-display-height', height);
|
|
672
|
+
if (namedSlot.firstElementChild.outerHTML !== selectionClone.outerHTML) {
|
|
673
|
+
namedSlot.replaceChild(selectionClone, namedSlot.firstElementChild);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
namedSlot = document.createElement('div');
|
|
678
|
+
namedSlot.slot = '_selected-display';
|
|
679
|
+
namedSlot.appendChild(selectionClone);
|
|
680
|
+
this.hostElement.appendChild(namedSlot);
|
|
595
681
|
}
|
|
596
|
-
|
|
682
|
+
return namedSlot;
|
|
597
683
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
684
|
+
checkSelectedDisplayHeight() {
|
|
685
|
+
const { selectedDisplaySlot } = this;
|
|
686
|
+
if (!selectedDisplaySlot)
|
|
687
|
+
return;
|
|
688
|
+
selectedDisplaySlot.style.setProperty('--comp-selected-display-height', '44px');
|
|
689
|
+
}
|
|
690
|
+
/// DOM ///
|
|
691
|
+
renderCustomDisplay() {
|
|
692
|
+
const hasSelectedDisplay = this.checkSelectedDisplay();
|
|
693
|
+
if (!hasSelectedDisplay)
|
|
694
|
+
return;
|
|
695
|
+
this.checkSelectedDisplayHeight();
|
|
696
|
+
return (h("slot", { name: "_selected-display", slot: "custom-display" }));
|
|
601
697
|
}
|
|
602
698
|
render() {
|
|
699
|
+
const showAsPseudo = !this.searchable;
|
|
603
700
|
return (h("click-elsewhere", { class: this.wrapperClasses, onChange: this.clickedElsewhere },
|
|
604
701
|
h("div", { "aria-live": "polite", "aria-atomic": "true", role: "status", class: "sr" }, this.statusMessage),
|
|
605
702
|
h("q2-input", { ref: el => (this.inputField = el), class: "q2-select-input", label: (this.label && loc(this.label)) || '', value: this.selectedDisplay, errors: (Array.isArray(this.errors) &&
|
|
606
703
|
this.errors.length > 0 &&
|
|
607
704
|
this.errors.map(error => loc(error))) ||
|
|
608
705
|
(this.invalid && ['tecton.element.select.invalid']) ||
|
|
609
|
-
[], disabled: this.disabled, optional: this.optional, readonly: this.readonly, hideLabel: this.hideLabel, ariaExpanded: `${!!this.dropdownOpen}`, ariaOwns: "dropdown", ariaHaspopup: "listbox", role: this.searchable ? 'combobox' : null, pseudo:
|
|
706
|
+
[], disabled: this.disabled, optional: this.optional, readonly: this.readonly, hideLabel: this.hideLabel, ariaExpanded: `${!!this.dropdownOpen}`, ariaOwns: "dropdown", 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.isComponentFocused ? 'primary' : undefined }, this.renderCustomDisplay()),
|
|
610
707
|
h("div", { class: "custom-display-content", hidden: !this.hasCustomDisplay || !!this.searchText, onClick: this.onCustomDisplayClick },
|
|
611
708
|
h("slot", { name: "q2-select-display" })),
|
|
612
709
|
this.optionsDropdown()));
|
|
@@ -619,10 +716,11 @@ export class Q2Select {
|
|
|
619
716
|
h("slot", null))));
|
|
620
717
|
}
|
|
621
718
|
visibilityToggle() {
|
|
719
|
+
const selectedOptionsCount = this.selectedOptions.length;
|
|
622
720
|
return (h("div", { class: "multi-select-header", ref: el => (this.multiSelectHeader = el) },
|
|
623
721
|
loc('tecton.element.select.multiHeader.showing'),
|
|
624
|
-
h("q2-btn", { class: `
|
|
625
|
-
h("q2-btn", { class: `
|
|
722
|
+
h("q2-btn", { class: `show-all-options${this.onlyShowingSelected ? '' : ' selected'}`, badge: true, "aria-selected": !this.onlyShowingSelected || undefined, "test-id": "allOptionsButton", onClick: this.showAllOptions, label: loc('tecton.element.select.multiHeader.allAriaLabel'), "hide-label": true }, loc('tecton.element.select.multiHeader.all')),
|
|
723
|
+
h("q2-btn", { class: `show-selected-options${this.onlyShowingSelected ? ' selected' : ''}`, "aria-selected": this.onlyShowingSelected || undefined, disabled: this.selectedOptions.length === 0, badge: true, "test-id": "selectedOptionsButton", onClick: this.showSelectedOptions, label: loc('tecton.element.select.multiHeader.selectedAriaLabel', [selectedOptionsCount]), "hide-label": true }, loc('tecton.element.select.multiHeader.selected', [selectedOptionsCount]))));
|
|
626
724
|
}
|
|
627
725
|
static get is() { return "q2-select"; }
|
|
628
726
|
static get encapsulation() { return "shadow"; }
|
|
@@ -635,7 +733,7 @@ export class Q2Select {
|
|
|
635
733
|
static get properties() { return {
|
|
636
734
|
"label": {
|
|
637
735
|
"type": "string",
|
|
638
|
-
"mutable":
|
|
736
|
+
"mutable": true,
|
|
639
737
|
"complexType": {
|
|
640
738
|
"original": "string",
|
|
641
739
|
"resolved": "string",
|
|
@@ -652,7 +750,7 @@ export class Q2Select {
|
|
|
652
750
|
},
|
|
653
751
|
"hideLabel": {
|
|
654
752
|
"type": "boolean",
|
|
655
|
-
"mutable":
|
|
753
|
+
"mutable": true,
|
|
656
754
|
"complexType": {
|
|
657
755
|
"original": "boolean",
|
|
658
756
|
"resolved": "boolean",
|
|
@@ -686,7 +784,7 @@ export class Q2Select {
|
|
|
686
784
|
},
|
|
687
785
|
"ariaLabel": {
|
|
688
786
|
"type": "string",
|
|
689
|
-
"mutable":
|
|
787
|
+
"mutable": true,
|
|
690
788
|
"complexType": {
|
|
691
789
|
"original": "string",
|
|
692
790
|
"resolved": "string",
|
|
@@ -902,7 +1000,8 @@ export class Q2Select {
|
|
|
902
1000
|
"searchText": {},
|
|
903
1001
|
"hasCustomDisplay": {},
|
|
904
1002
|
"inputFocused": {},
|
|
905
|
-
"statusMessage": {}
|
|
1003
|
+
"statusMessage": {},
|
|
1004
|
+
"prioritizeSearch": {}
|
|
906
1005
|
}; }
|
|
907
1006
|
static get events() { return [{
|
|
908
1007
|
"method": "change",
|
|
@@ -948,8 +1047,17 @@ export class Q2Select {
|
|
|
948
1047
|
}, {
|
|
949
1048
|
"propName": "multilineOptions",
|
|
950
1049
|
"methodName": "multilineOptionsChanged"
|
|
1050
|
+
}, {
|
|
1051
|
+
"propName": "dropdownOpen",
|
|
1052
|
+
"methodName": "dropdownOpenChanged"
|
|
951
1053
|
}]; }
|
|
952
1054
|
static get listeners() { return [{
|
|
1055
|
+
"name": "keydown",
|
|
1056
|
+
"method": "keydownHandler",
|
|
1057
|
+
"target": undefined,
|
|
1058
|
+
"capture": false,
|
|
1059
|
+
"passive": false
|
|
1060
|
+
}, {
|
|
953
1061
|
"name": "change",
|
|
954
1062
|
"method": "onHostElementChange",
|
|
955
1063
|
"target": undefined,
|
|
@@ -968,14 +1076,14 @@ export class Q2Select {
|
|
|
968
1076
|
"capture": false,
|
|
969
1077
|
"passive": false
|
|
970
1078
|
}, {
|
|
971
|
-
"name": "
|
|
972
|
-
"method": "
|
|
1079
|
+
"name": "focusout",
|
|
1080
|
+
"method": "handleFocusout",
|
|
973
1081
|
"target": undefined,
|
|
974
1082
|
"capture": false,
|
|
975
1083
|
"passive": false
|
|
976
1084
|
}, {
|
|
977
|
-
"name": "
|
|
978
|
-
"method": "
|
|
1085
|
+
"name": "click",
|
|
1086
|
+
"method": "clickHandler",
|
|
979
1087
|
"target": undefined,
|
|
980
1088
|
"capture": false,
|
|
981
1089
|
"passive": false
|