q2-tecton-elements 1.15.1 → 1.16.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/{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_tecton-production_master}/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_tecton-production_master}/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,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-6d5ed7cc.js';
|
|
2
|
-
import { c as createGuid, s as setPopProperties,
|
|
2
|
+
import { c as createGuid, s as setPopProperties, h as handleAriaLabel, o as overrideFocus, l as loc, b as isRelatedTargetWithinHost, i as isEventFromElement, r as resizeIframe } from './index-2ca8c93c.js';
|
|
3
3
|
|
|
4
|
-
const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.q2-element-dropdown{display:none;position:absolute;background-color:var(--app-white);color:var(--t-
|
|
4
|
+
const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-global-focus, 0 0 0 2px #33b4ff)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit}:host(.sr),:host(.sr) button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.sr,.sr button{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;white-space:nowrap}.hidden{display:none}:host([hidden]){display:none}.invisible{visibility:hidden}.q2-element-dropdown{display:none;position:absolute;background-color:var(--app-white, #ffffff);color:var(--t-text, #4d4d4d);left:0;width:100%;z-index:100;margin-top:1px;box-shadow:var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3));height:0;overflow:hidden;opacity:0;visibility:hidden;transition:opacity var(--app-tween-1, 0.2s ease);border-radius:var(--tct-dropdown-border-radius, --t-dropdown-border-radius, 0);--comp-scrollbar-size:var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));--comp-scrollbar-border-radius:var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));--comp-scrollbar-color:var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));scrollbar-width:thin;scrollbar-color:var(--comp-scrollbar-color) transparent}.q2-element-dropdown::-webkit-scrollbar{width:var(--comp-scrollbar-size);height:var(--comp-scrollbar-size);margin:5px}.q2-element-dropdown::-webkit-scrollbar-thumb{background:var(--comp-scrollbar-color);border-radius:var(--comp-scrollbar-border-radius)}.q2-element-dropdown::-webkit-scrollbar-track{background:transparent;border-radius:var(--comp-scrollbar-border-radius)}.q2-element-dropdown.sizable{display:block;height:auto}.dropdown-open .q2-element-dropdown{display:block;height:auto;overflow:auto;opacity:1;visibility:visible}:host([alignment=right]) .q2-element-dropdown{left:auto;right:0}:host([block]) q2-btn,:host([block]){display:block}:host{display:block;margin-top:var(--tct-select-margin-top, var(--app-scale-4, 30px));margin-bottom:var(--tct-select-margin-bottom, var(--app-scale-4, 30px))}.q2-select-container{position:relative;display:block}.q2-select-input{margin:0;--tct-input-min-height:var(--tct-select-input-min-height, var(--t-select-input-min-height));--tct-input-max-height:var(--tct-select-input-max-height, var(--t-select-input-max-height, 100px))}::slotted([slot=_selected-display]){width:100%;min-height:var(--comp-selected-display-height, 44px)}.custom-display-content{position:absolute;bottom:0;left:calc(var(--tct-scale-2, var(--app-scale-2x, 10px)) + 1px);height:44px;width:calc(100% - 34px - var(--tct-scale-3, var(--app-scale-3x, 15px)));overflow:hidden;cursor:pointer;transition:left var(--tct-tween-2, var(--app-tween-1, 0.2s ease))}.custom-display-content:not([hidden]){display:flex;align-items:center}.is-searchable.is-focused .custom-display-content,.is-searchable .custom-display-content:active{left:calc(var(--tct-scale-3, var(--app-scale-3x, 15px)) + 1px)}.has-error .custom-display-content{width:calc(100% - 68px - var(--tct-scale-3, var(--app-scale-3x, 15px)))}.dropdown-open .q2-select-dropdown{overflow-y:auto;max-height:300px}.multi-select-header{padding:var(--tct-scale-1, var(--app-scale-1x, 5px)) var(--tct-scale-2, var(--app-scale-2x, 10px));position:sticky;top:0;z-index:5;background:var(--app-white)}.show-all-options{margin-right:var(--tct-scale-1, var(--app-scale-1x, 5px));margin-left:var(--tct-scale-2, var(--app-scale-2x, 10px))}.q2-element-dropdown.dropup{bottom:var(--comp-dropup-offset)}";
|
|
5
5
|
|
|
6
6
|
const Q2Select = class {
|
|
7
7
|
constructor(hostRef) {
|
|
@@ -21,6 +21,7 @@ const Q2Select = class {
|
|
|
21
21
|
this.searchText = '';
|
|
22
22
|
this.hasCustomDisplay = false;
|
|
23
23
|
this.inputFocused = false;
|
|
24
|
+
this.prioritizeSearch = false;
|
|
24
25
|
this.scheduledAfterRender = [];
|
|
25
26
|
this.keyStore = {
|
|
26
27
|
queue: [],
|
|
@@ -88,7 +89,7 @@ const Q2Select = class {
|
|
|
88
89
|
setFocus(matched);
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
|
-
|
|
92
|
+
/// Event handlers ///
|
|
92
93
|
this.dropdownFocusoutHandler = (event) => {
|
|
93
94
|
const { relatedTarget } = event;
|
|
94
95
|
const isInDropdown = this.dropdownContainer.contains(relatedTarget);
|
|
@@ -111,11 +112,10 @@ const Q2Select = class {
|
|
|
111
112
|
case ' ':
|
|
112
113
|
case 'Enter':
|
|
113
114
|
event.preventDefault();
|
|
114
|
-
event.stopPropagation();
|
|
115
115
|
const newOption = this.hostElement.querySelector(`[option-id="${this.activeOptionId}"]`);
|
|
116
116
|
if (!newOption || newOption.disabled)
|
|
117
117
|
break;
|
|
118
|
-
this.selectOption(newOption
|
|
118
|
+
this.selectOption(newOption, true);
|
|
119
119
|
break;
|
|
120
120
|
case 'ArrowUp':
|
|
121
121
|
event.preventDefault();
|
|
@@ -169,7 +169,9 @@ const Q2Select = class {
|
|
|
169
169
|
const myOption = this.hostElement.querySelector(`[option-id="${this.activeOptionId}"]`);
|
|
170
170
|
if (!myOption || myOption.disabled)
|
|
171
171
|
return;
|
|
172
|
-
|
|
172
|
+
if (myOption.selected)
|
|
173
|
+
return;
|
|
174
|
+
this.selectOption(myOption);
|
|
173
175
|
break;
|
|
174
176
|
case 'Esc':
|
|
175
177
|
case 'Escape':
|
|
@@ -186,10 +188,11 @@ const Q2Select = class {
|
|
|
186
188
|
break;
|
|
187
189
|
}
|
|
188
190
|
};
|
|
191
|
+
/* tslint:enable:cyclomatic-complexity */
|
|
189
192
|
this.inputKeydownHandler = (event) => {
|
|
190
193
|
event.stopPropagation();
|
|
191
|
-
const { key } = event;
|
|
192
|
-
const { optionElements,
|
|
194
|
+
const { key, shiftKey } = event;
|
|
195
|
+
const { optionElements, searchable } = this;
|
|
193
196
|
switch (key) {
|
|
194
197
|
case 'ArrowDown':
|
|
195
198
|
event.preventDefault();
|
|
@@ -210,19 +213,14 @@ const Q2Select = class {
|
|
|
210
213
|
break;
|
|
211
214
|
case 'Escape':
|
|
212
215
|
case 'Esc':
|
|
213
|
-
|
|
214
|
-
this.closeDropdown();
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
this.searchText = '';
|
|
218
|
-
}
|
|
216
|
+
this.closeDropdown();
|
|
219
217
|
break;
|
|
220
218
|
case 'Tab':
|
|
221
|
-
|
|
222
|
-
this.closeDropdown();
|
|
223
|
-
}
|
|
219
|
+
this.closeDropdown();
|
|
224
220
|
break;
|
|
225
221
|
default:
|
|
222
|
+
if (shiftKey)
|
|
223
|
+
break;
|
|
226
224
|
if (searchable) {
|
|
227
225
|
this.openDropdownWithoutActiveElement();
|
|
228
226
|
break;
|
|
@@ -246,10 +244,11 @@ const Q2Select = class {
|
|
|
246
244
|
const didChangeText = inputValue !== eventValue;
|
|
247
245
|
const shouldClearValue = !!this.value && didChangeText;
|
|
248
246
|
if (shouldClearValue) {
|
|
249
|
-
this.selectOption(
|
|
247
|
+
this.selectOption(null);
|
|
250
248
|
}
|
|
251
249
|
if (!this.dropdownOpen)
|
|
252
250
|
this.openDropdownWithoutActiveElement();
|
|
251
|
+
this.prioritizeSearch = true;
|
|
253
252
|
this.searchText = eventValue;
|
|
254
253
|
this.input.emit({ query: eventValue });
|
|
255
254
|
};
|
|
@@ -271,6 +270,11 @@ const Q2Select = class {
|
|
|
271
270
|
}
|
|
272
271
|
}
|
|
273
272
|
};
|
|
273
|
+
this.onCustomDisplayClick = (event) => {
|
|
274
|
+
event.stopPropagation();
|
|
275
|
+
this.focusInput();
|
|
276
|
+
this.toggleDropdown();
|
|
277
|
+
};
|
|
274
278
|
this.showSelectedOptions = (event) => {
|
|
275
279
|
event.stopImmediatePropagation();
|
|
276
280
|
this.onlyShowingSelected = true;
|
|
@@ -285,17 +289,189 @@ const Q2Select = class {
|
|
|
285
289
|
optionElement._multiSelectHidden = false;
|
|
286
290
|
});
|
|
287
291
|
};
|
|
288
|
-
this.onCustomDisplayClick = (event) => {
|
|
289
|
-
event.stopPropagation();
|
|
290
|
-
this.focusInput();
|
|
291
|
-
this.toggleDropdown();
|
|
292
|
-
};
|
|
293
292
|
}
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
/// Lifecycle Hooks ///
|
|
294
|
+
componentWillLoad() {
|
|
295
|
+
handleAriaLabel(this);
|
|
296
|
+
}
|
|
297
|
+
componentDidLoad() {
|
|
298
|
+
const observer = new MutationObserver(this.onMutationObserved);
|
|
299
|
+
observer.observe(this.hostElement, { childList: true, subtree: true });
|
|
300
|
+
this.mutationObserver = observer;
|
|
301
|
+
this.onMutationObserved();
|
|
302
|
+
overrideFocus(this.hostElement);
|
|
303
|
+
setTimeout(() => this.checkSelectedDisplay(), 0);
|
|
304
|
+
}
|
|
305
|
+
componentDidRender() {
|
|
306
|
+
setTimeout(() => {
|
|
307
|
+
this.scheduledAfterRender.forEach(fn => fn());
|
|
308
|
+
this.scheduledAfterRender = [];
|
|
309
|
+
}, 25);
|
|
310
|
+
}
|
|
311
|
+
disconnectedCallback() {
|
|
312
|
+
var _a;
|
|
313
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
314
|
+
this.mutationObserver = null;
|
|
315
|
+
}
|
|
316
|
+
/// Getters ///
|
|
317
|
+
get isComponentFocused() {
|
|
318
|
+
return document.activeElement === this.hostElement || !!this.hostElement.querySelector(':focus');
|
|
319
|
+
}
|
|
320
|
+
get isSearchMode() {
|
|
321
|
+
return (this.searchable && this.inputFocused) || this.searchText;
|
|
322
|
+
}
|
|
323
|
+
get badgeValue() {
|
|
324
|
+
if (!this.multiple)
|
|
325
|
+
return;
|
|
326
|
+
const optionsLength = this.selectedOptions.length;
|
|
327
|
+
if (this.dropdownOpen && this.searchable)
|
|
328
|
+
return optionsLength || null;
|
|
329
|
+
else
|
|
330
|
+
return optionsLength > 1 ? `+${optionsLength - 1}` : null;
|
|
331
|
+
}
|
|
332
|
+
get minPopHeight() {
|
|
333
|
+
const { minRows } = this;
|
|
334
|
+
const firstOption = this.hostElement.querySelector('q2-option:not([hidden])');
|
|
335
|
+
const minHeight = firstOption ? window.getComputedStyle(firstOption).minHeight : '44px';
|
|
336
|
+
return minRows * parseInt(minHeight);
|
|
337
|
+
}
|
|
338
|
+
get selectedDisplay() {
|
|
339
|
+
if (this.prioritizeSearch || this.searchText)
|
|
340
|
+
return this.searchText;
|
|
341
|
+
if (this.hasCustomDisplay)
|
|
342
|
+
return '';
|
|
343
|
+
return this.multiple ? this.calculateMultiSelectSelectedDisplay() : this.calculateSingleSelectSelectedDisplay();
|
|
344
|
+
}
|
|
345
|
+
get selectedDisplaySlot() {
|
|
346
|
+
return this.hostElement.querySelector('[slot="_selected-display"]');
|
|
296
347
|
}
|
|
348
|
+
get firstSelectedValue() {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
if (this.multiple)
|
|
351
|
+
return (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
|
|
352
|
+
return this.value;
|
|
353
|
+
}
|
|
354
|
+
get firstSelectedOptionElement() {
|
|
355
|
+
const { firstSelectedValue } = this;
|
|
356
|
+
return firstSelectedValue ? this.optionElements.find(({ value }) => value === firstSelectedValue) : null;
|
|
357
|
+
}
|
|
358
|
+
get optionElements() {
|
|
359
|
+
return Array.from(this.hostElement.querySelectorAll('q2-option'));
|
|
360
|
+
}
|
|
361
|
+
get visibleOptionElements() {
|
|
362
|
+
return Array.from(this.hostElement.querySelectorAll('q2-option:not([_multiselecthidden])'));
|
|
363
|
+
}
|
|
364
|
+
get wrapperClasses() {
|
|
365
|
+
const { errors } = this;
|
|
366
|
+
const classes = ['q2-select-container'];
|
|
367
|
+
if (this.dropdownOpen)
|
|
368
|
+
classes.push('dropdown-open');
|
|
369
|
+
if (Array.isArray(errors) && errors.length > 0)
|
|
370
|
+
classes.push('has-error');
|
|
371
|
+
if (this.inputFocused)
|
|
372
|
+
classes.push('is-focused');
|
|
373
|
+
if (this.searchable)
|
|
374
|
+
classes.push('is-searchable');
|
|
375
|
+
return classes.join(' ');
|
|
376
|
+
}
|
|
377
|
+
/// Watchers ///
|
|
378
|
+
ariaLabelObserver() {
|
|
379
|
+
handleAriaLabel(this);
|
|
380
|
+
}
|
|
381
|
+
valueUpdated() {
|
|
382
|
+
if (this.multiple)
|
|
383
|
+
return;
|
|
384
|
+
this.updateSingleOptionAttrs();
|
|
385
|
+
}
|
|
386
|
+
selectedOptionsUpdated() {
|
|
387
|
+
if (!this.multiple)
|
|
388
|
+
return;
|
|
389
|
+
this.updateMultipleOptionAttrs();
|
|
390
|
+
}
|
|
391
|
+
multilineOptionsChanged(newValue, oldValue) {
|
|
392
|
+
if (newValue === oldValue)
|
|
393
|
+
return;
|
|
394
|
+
this.optionElements.forEach(element => (element.multiline = newValue));
|
|
395
|
+
}
|
|
396
|
+
dropdownOpenChanged(isOpen) {
|
|
397
|
+
this.scheduledAfterRender.push(() => {
|
|
398
|
+
const { multiple, multiSelectHeader, dropdownContainer } = this;
|
|
399
|
+
const height = (isOpen && multiple && (multiSelectHeader === null || multiSelectHeader === void 0 ? void 0 : multiSelectHeader.offsetHeight)) || 0;
|
|
400
|
+
if (height) {
|
|
401
|
+
dropdownContainer.style.setProperty('--comp-multi-select-header-height', `${height}px`);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
dropdownContainer.style.removeProperty('--comp-multi-select-header-height');
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
/// Listeners ///
|
|
409
|
+
keydownHandler(event) {
|
|
410
|
+
this.inputKeydownHandler(event);
|
|
411
|
+
}
|
|
412
|
+
onHostElementChange(event) {
|
|
413
|
+
if (this.readonly)
|
|
414
|
+
return;
|
|
415
|
+
if (event.target !== this.hostElement || this.hostElement.onchange)
|
|
416
|
+
return;
|
|
417
|
+
if (this.multiple) {
|
|
418
|
+
this.selectedOptions = event.detail.selectedOptions;
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
this.value = event.detail.value;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
onHostElementInput(event) {
|
|
425
|
+
if (!this.searchable || event.target !== this.hostElement || this.hostElement.oninput)
|
|
426
|
+
return;
|
|
427
|
+
const options = this.optionElements;
|
|
428
|
+
const query = this.searchText.trim().toLocaleLowerCase();
|
|
429
|
+
let matchedCount = 0;
|
|
430
|
+
options.forEach(option => {
|
|
431
|
+
var _a;
|
|
432
|
+
if (query === '') {
|
|
433
|
+
option.hidden = false;
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const title = ((_a = option.firstElementChild) === null || _a === void 0 ? void 0 : _a.tagName) === 'Q2-CARD'
|
|
437
|
+
? option.firstElementChild.title
|
|
438
|
+
: null;
|
|
439
|
+
const { display = '', innerText = '' } = option;
|
|
440
|
+
const searchParams = [display, title, innerText];
|
|
441
|
+
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; });
|
|
442
|
+
option.hidden = !matched;
|
|
443
|
+
if (matched)
|
|
444
|
+
matchedCount++;
|
|
445
|
+
});
|
|
446
|
+
const statusMessageLocString = query
|
|
447
|
+
? 'tecton.element.select.searchable.results'
|
|
448
|
+
: 'tecton.element.select.allOptions';
|
|
449
|
+
const count = query ? matchedCount : options.length;
|
|
450
|
+
this.setStatusMessage(loc(statusMessageLocString, [count]));
|
|
451
|
+
}
|
|
452
|
+
delegateFocus(event) {
|
|
453
|
+
const fromHost = isRelatedTargetWithinHost(event, this.hostElement);
|
|
454
|
+
const prioritizeSearch = (this.prioritizeSearch = fromHost && this.searchable);
|
|
455
|
+
if (prioritizeSearch) {
|
|
456
|
+
this.clearSelectedDisplay();
|
|
457
|
+
}
|
|
458
|
+
else if (isEventFromElement(event, this.hostElement)) {
|
|
459
|
+
this.inputField.shadowRoot.querySelector('.input-field').focus();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
handleFocusout(event) {
|
|
463
|
+
this.prioritizeSearch = !isRelatedTargetWithinHost(event, this.hostElement) && this.searchable;
|
|
464
|
+
}
|
|
465
|
+
clickHandler(event) {
|
|
466
|
+
const selectedOption = event.target.closest('q2-option');
|
|
467
|
+
if (!selectedOption ||
|
|
468
|
+
(selectedOption.hasAttribute('disabled') && selectedOption.getAttribute('disabled') !== 'false'))
|
|
469
|
+
return;
|
|
470
|
+
this.selectOption(selectedOption, true);
|
|
471
|
+
}
|
|
472
|
+
/// Helpers ///
|
|
297
473
|
getDefaultActiveIndex() {
|
|
298
|
-
const firstSelected = this.optionElements.findIndex(element => element.selected);
|
|
474
|
+
const firstSelected = this.optionElements.findIndex(element => element.selected && !element.hidden);
|
|
299
475
|
if (firstSelected > -1)
|
|
300
476
|
return firstSelected;
|
|
301
477
|
const firstEnabled = this.optionElements.findIndex(element => !element.hidden);
|
|
@@ -334,84 +510,67 @@ const Q2Select = class {
|
|
|
334
510
|
option.focus();
|
|
335
511
|
}
|
|
336
512
|
calculateMultiSelectSelectedDisplay() {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
});
|
|
341
|
-
return ((selectedOption && selectedOption.display && loc(selectedOption.display)) ||
|
|
342
|
-
(selectedOption && selectedOption.value) ||
|
|
343
|
-
this.selectedOptions[0]);
|
|
344
|
-
}
|
|
345
|
-
else if (this.selectedOptions.length > 1) {
|
|
346
|
-
return loc('tecton.element.select.multiDisplay', [this.selectedOptions.length]);
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
513
|
+
var _a;
|
|
514
|
+
const { firstSelectedOptionElement, firstSelectedValue, multilineOptions } = this;
|
|
515
|
+
if (!firstSelectedValue)
|
|
349
516
|
return '';
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
});
|
|
356
|
-
return (selectedOption && selectedOption.display && loc(selectedOption.display)) || this.value || '';
|
|
357
|
-
}
|
|
358
|
-
get minPopHeight() {
|
|
359
|
-
const { minRows } = this;
|
|
360
|
-
const firstOption = this.hostElement.querySelector('q2-option:not([hidden])');
|
|
361
|
-
const minHeight = firstOption ? window.getComputedStyle(firstOption).minHeight : '44px';
|
|
362
|
-
return minRows * parseInt(minHeight);
|
|
363
|
-
}
|
|
364
|
-
get selectedDisplay() {
|
|
365
|
-
if (this.hasCustomDisplay && !this.searchText) {
|
|
517
|
+
if (firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.display)
|
|
518
|
+
return loc(firstSelectedOptionElement.display);
|
|
519
|
+
if (multilineOptions && this.searchable)
|
|
520
|
+
return this.searchText;
|
|
521
|
+
if (multilineOptions)
|
|
366
522
|
return '';
|
|
367
|
-
|
|
368
|
-
if (this.searchable && this.dropdownOpen && !this.value) {
|
|
369
|
-
// when dropdown is open search selects show typing
|
|
370
|
-
// when closed they display the same as non searchable select (what is selected)
|
|
371
|
-
return this.searchText || '';
|
|
372
|
-
}
|
|
373
|
-
return this.multiple ? this.calculateMultiSelectSelectedDisplay() : this.calculateSingleSelectSelectedDisplay();
|
|
374
|
-
}
|
|
375
|
-
get selectedOptionsCount() {
|
|
376
|
-
return this.selectedOptions.length;
|
|
523
|
+
return (_a = firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.value) !== null && _a !== void 0 ? _a : firstSelectedValue;
|
|
377
524
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
get wrapperClasses() {
|
|
382
|
-
const dropdownOpenClass = (this.dropdownOpen && ' dropdown-open') || '';
|
|
383
|
-
const errorClass = Array.isArray(this.errors) && this.errors.length > 0 ? ' has-error' : '';
|
|
384
|
-
const focusClass = this.inputFocused ? ' is-focused' : '';
|
|
385
|
-
const searchableClass = this.searchable ? ' is-searchable' : '';
|
|
386
|
-
return `q2-select-container${dropdownOpenClass}${errorClass}${focusClass}${searchableClass}`;
|
|
525
|
+
calculateSingleSelectSelectedDisplay() {
|
|
526
|
+
const { firstSelectedOptionElement } = this;
|
|
527
|
+
return ((firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.display) && loc(firstSelectedOptionElement.display)) || this.value || '';
|
|
387
528
|
}
|
|
388
529
|
updateSingleOptionAttrs() {
|
|
530
|
+
const { value, guid, multilineOptions } = this;
|
|
389
531
|
this.optionElements.forEach((element, index) => {
|
|
390
|
-
element.selected =
|
|
391
|
-
element.optionId = `q2-select-${
|
|
392
|
-
element.multiline =
|
|
532
|
+
element.selected = element.value === value;
|
|
533
|
+
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
534
|
+
element.multiline = multilineOptions;
|
|
393
535
|
});
|
|
394
536
|
}
|
|
395
537
|
updateMultipleOptionAttrs() {
|
|
396
538
|
if (this.selectedOptions.length === 0) {
|
|
397
539
|
this.onlyShowingSelected = false;
|
|
398
540
|
}
|
|
541
|
+
const { selectedOptions, onlyShowingSelected, guid, multilineOptions } = this;
|
|
399
542
|
this.optionElements.forEach((element, index) => {
|
|
400
|
-
element.selected =
|
|
401
|
-
element._multiSelectHidden =
|
|
402
|
-
element.optionId = `q2-select-${
|
|
403
|
-
element.multiline =
|
|
543
|
+
element.selected = selectedOptions.includes(element.value);
|
|
544
|
+
element._multiSelectHidden = onlyShowingSelected ? !element.selected : false;
|
|
545
|
+
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
546
|
+
element.multiline = multilineOptions;
|
|
404
547
|
});
|
|
405
548
|
}
|
|
406
|
-
|
|
549
|
+
focusSelectedSibling(option) {
|
|
550
|
+
if (!this.onlyShowingSelected)
|
|
551
|
+
return;
|
|
552
|
+
const { visibleOptionElements } = this;
|
|
553
|
+
if (visibleOptionElements.length < 2)
|
|
554
|
+
return;
|
|
555
|
+
const optionIndex = visibleOptionElements.indexOf(option);
|
|
556
|
+
const visibleFocusIndex = optionIndex ? optionIndex - 1 : optionIndex + 1;
|
|
557
|
+
const optionToFocus = visibleOptionElements[visibleFocusIndex];
|
|
558
|
+
const focusIndex = this.optionElements.indexOf(optionToFocus);
|
|
559
|
+
this.activeIndex = focusIndex;
|
|
560
|
+
this.setFocusedOption();
|
|
561
|
+
}
|
|
562
|
+
selectOption(option, focusInputOnClose = false) {
|
|
563
|
+
var _a;
|
|
564
|
+
const value = (_a = option === null || option === void 0 ? void 0 : option.value) !== null && _a !== void 0 ? _a : '';
|
|
407
565
|
if (this.multiple) {
|
|
408
566
|
const isSelected = this.selectedOptions.includes(value);
|
|
409
567
|
if (isSelected) {
|
|
568
|
+
this.focusSelectedSibling(option);
|
|
410
569
|
this.change.emit({
|
|
411
570
|
selectedOptions: this.selectedOptions.filter(selectedValue => selectedValue !== value),
|
|
412
571
|
});
|
|
413
572
|
}
|
|
414
|
-
else {
|
|
573
|
+
else if (value) {
|
|
415
574
|
this.change.emit({ selectedOptions: [...this.selectedOptions, value] });
|
|
416
575
|
}
|
|
417
576
|
}
|
|
@@ -432,7 +591,7 @@ const Q2Select = class {
|
|
|
432
591
|
this.activeIndex = undefined;
|
|
433
592
|
this.setActiveOption();
|
|
434
593
|
this.dropdownOpen = true;
|
|
435
|
-
this.scheduledAfterRender.push(
|
|
594
|
+
this.scheduledAfterRender.push(resizeIframe);
|
|
436
595
|
}
|
|
437
596
|
openDropdownWithActiveElement(activeIndex) {
|
|
438
597
|
if (this.readonly)
|
|
@@ -443,7 +602,7 @@ const Q2Select = class {
|
|
|
443
602
|
this.scheduledAfterRender.push(() => {
|
|
444
603
|
this.setFocusedOption();
|
|
445
604
|
this.scrollToActiveOption();
|
|
446
|
-
|
|
605
|
+
resizeIframe();
|
|
447
606
|
});
|
|
448
607
|
}
|
|
449
608
|
closeDropdown() {
|
|
@@ -452,24 +611,16 @@ const Q2Select = class {
|
|
|
452
611
|
this.searchText = '';
|
|
453
612
|
this.input.emit({ query: '' });
|
|
454
613
|
}
|
|
455
|
-
this.scheduledAfterRender.push(
|
|
614
|
+
this.scheduledAfterRender.push(resizeIframe);
|
|
456
615
|
}
|
|
457
616
|
toggleDropdown() {
|
|
458
|
-
if (this.disabled)
|
|
617
|
+
if (this.disabled)
|
|
459
618
|
return;
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (!this.dropdownOpen) {
|
|
463
|
-
this.openDropdownWithoutActiveElement();
|
|
464
|
-
}
|
|
619
|
+
if (this.dropdownOpen && !this.searchText) {
|
|
620
|
+
this.closeDropdown();
|
|
465
621
|
}
|
|
466
622
|
else {
|
|
467
|
-
|
|
468
|
-
this.closeDropdown();
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
this.openDropdownWithoutActiveElement();
|
|
472
|
-
}
|
|
623
|
+
this.openDropdownWithoutActiveElement();
|
|
473
624
|
}
|
|
474
625
|
}
|
|
475
626
|
adjustActiveOptionAndScroll(numToAdd) {
|
|
@@ -489,8 +640,9 @@ const Q2Select = class {
|
|
|
489
640
|
}
|
|
490
641
|
getNextVisibleIndex(direction) {
|
|
491
642
|
let index = this.activeIndex + direction;
|
|
492
|
-
|
|
493
|
-
|
|
643
|
+
const { optionElements } = this;
|
|
644
|
+
while (index >= 0 && index <= optionElements.length - 1) {
|
|
645
|
+
const { display, visibility } = window.getComputedStyle(optionElements[index]);
|
|
494
646
|
if (display !== 'none' && visibility !== 'hidden') {
|
|
495
647
|
return index;
|
|
496
648
|
}
|
|
@@ -498,95 +650,6 @@ const Q2Select = class {
|
|
|
498
650
|
}
|
|
499
651
|
return -1;
|
|
500
652
|
}
|
|
501
|
-
////////// LIFECYCLE HOOKS ////////
|
|
502
|
-
componentWillLoad() {
|
|
503
|
-
handleAriaLabel(this);
|
|
504
|
-
}
|
|
505
|
-
componentDidLoad() {
|
|
506
|
-
const observer = new MutationObserver(this.onMutationObserved);
|
|
507
|
-
observer.observe(this.hostElement, { childList: true, subtree: true });
|
|
508
|
-
this.mutationObserver = observer;
|
|
509
|
-
this.onMutationObserved();
|
|
510
|
-
overrideFocus(this.hostElement);
|
|
511
|
-
}
|
|
512
|
-
componentDidRender() {
|
|
513
|
-
setTimeout(() => {
|
|
514
|
-
this.scheduledAfterRender.forEach(fn => fn());
|
|
515
|
-
this.scheduledAfterRender = [];
|
|
516
|
-
}, 25);
|
|
517
|
-
}
|
|
518
|
-
disconnectedCallback() {
|
|
519
|
-
if (this.mutationObserver) {
|
|
520
|
-
this.mutationObserver.disconnect();
|
|
521
|
-
this.mutationObserver = null;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
////////// OBSERVERS //////////
|
|
525
|
-
ariaLabelObserver() {
|
|
526
|
-
handleAriaLabel(this);
|
|
527
|
-
}
|
|
528
|
-
valueUpdated() {
|
|
529
|
-
if (this.multiple) {
|
|
530
|
-
return;
|
|
531
|
-
}
|
|
532
|
-
this.updateSingleOptionAttrs();
|
|
533
|
-
}
|
|
534
|
-
selectedOptionsUpdated() {
|
|
535
|
-
if (!this.multiple) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
this.updateMultipleOptionAttrs();
|
|
539
|
-
}
|
|
540
|
-
multilineOptionsChanged(newValue, oldValue) {
|
|
541
|
-
if (newValue === oldValue) {
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
this.optionElements.forEach(element => {
|
|
545
|
-
element.multiline = this.multilineOptions;
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
onHostElementChange(event) {
|
|
549
|
-
if (this.readonly)
|
|
550
|
-
return;
|
|
551
|
-
if (event.target === this.hostElement && !this.hostElement.onchange) {
|
|
552
|
-
if (this.multiple) {
|
|
553
|
-
this.selectedOptions = event.detail.selectedOptions;
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
this.value = event.detail.value;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
onHostElementInput(event) {
|
|
561
|
-
if (this.searchable && event.target === this.hostElement && !this.hostElement.oninput) {
|
|
562
|
-
const options = this.optionElements;
|
|
563
|
-
const query = event.detail.query.trim().toLowerCase();
|
|
564
|
-
let matchedCount = 0;
|
|
565
|
-
options.forEach(option => {
|
|
566
|
-
if (query === '') {
|
|
567
|
-
option.style.display = '';
|
|
568
|
-
option.hidden = false;
|
|
569
|
-
}
|
|
570
|
-
else {
|
|
571
|
-
const { display = '', innerText = '' } = option;
|
|
572
|
-
const matched = display.toLowerCase().includes(query) || innerText.toLowerCase().includes(query);
|
|
573
|
-
option.hidden = !matched;
|
|
574
|
-
if (matched)
|
|
575
|
-
matchedCount++;
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
const statusMessageLocString = query
|
|
579
|
-
? 'tecton.element.select.searchable.results'
|
|
580
|
-
: 'tecton.element.select.allOptions';
|
|
581
|
-
const count = query ? matchedCount : options.length;
|
|
582
|
-
this.setStatusMessage(loc(statusMessageLocString, [count]));
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
delegateFocus(event) {
|
|
586
|
-
if (!isEventFromElement(event, this.hostElement))
|
|
587
|
-
return;
|
|
588
|
-
this.inputField.shadowRoot.querySelector('.input-field').focus();
|
|
589
|
-
}
|
|
590
653
|
setStatusMessage(message) {
|
|
591
654
|
clearTimeout(this.statusMessageTimer);
|
|
592
655
|
this.statusMessage = '';
|
|
@@ -594,37 +657,73 @@ const Q2Select = class {
|
|
|
594
657
|
this.statusMessage = message;
|
|
595
658
|
}, 1000);
|
|
596
659
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
660
|
+
clearSelectedDisplay() {
|
|
661
|
+
var _a;
|
|
662
|
+
(_a = this.selectedDisplaySlot) === null || _a === void 0 ? void 0 : _a.remove();
|
|
663
|
+
}
|
|
664
|
+
checkSelectedDisplay() {
|
|
665
|
+
let namedSlot = this.selectedDisplaySlot;
|
|
666
|
+
const { value, multiple, selectedOptions, multilineOptions, firstSelectedOptionElement, prioritizeSearch } = this;
|
|
667
|
+
const hasNoValue = !value && multiple && !selectedOptions.length;
|
|
668
|
+
if (prioritizeSearch || !multilineOptions || hasNoValue)
|
|
669
|
+
return this.clearSelectedDisplay();
|
|
670
|
+
if (!firstSelectedOptionElement || firstSelectedOptionElement.display)
|
|
671
|
+
return this.clearSelectedDisplay();
|
|
672
|
+
// Clone selected option and remove elements with hide-on-select attribute
|
|
673
|
+
const selectionClone = firstSelectedOptionElement.firstElementChild.cloneNode(true);
|
|
674
|
+
selectionClone.querySelectorAll('[hide-on-select]').forEach(element => element.remove());
|
|
675
|
+
if (namedSlot) {
|
|
676
|
+
const height = namedSlot.clientHeight === 0 ? 'auto' : `${namedSlot.clientHeight}px`;
|
|
677
|
+
namedSlot.style.setProperty('--comp-selected-display-height', height);
|
|
678
|
+
if (namedSlot.firstElementChild.outerHTML !== selectionClone.outerHTML) {
|
|
679
|
+
namedSlot.replaceChild(selectionClone, namedSlot.firstElementChild);
|
|
680
|
+
}
|
|
601
681
|
}
|
|
602
|
-
|
|
682
|
+
else {
|
|
683
|
+
namedSlot = document.createElement('div');
|
|
684
|
+
namedSlot.slot = '_selected-display';
|
|
685
|
+
namedSlot.appendChild(selectionClone);
|
|
686
|
+
this.hostElement.appendChild(namedSlot);
|
|
687
|
+
}
|
|
688
|
+
return namedSlot;
|
|
603
689
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
690
|
+
checkSelectedDisplayHeight() {
|
|
691
|
+
const { selectedDisplaySlot } = this;
|
|
692
|
+
if (!selectedDisplaySlot)
|
|
693
|
+
return;
|
|
694
|
+
selectedDisplaySlot.style.setProperty('--comp-selected-display-height', '44px');
|
|
695
|
+
}
|
|
696
|
+
/// DOM ///
|
|
697
|
+
renderCustomDisplay() {
|
|
698
|
+
const hasSelectedDisplay = this.checkSelectedDisplay();
|
|
699
|
+
if (!hasSelectedDisplay)
|
|
700
|
+
return;
|
|
701
|
+
this.checkSelectedDisplayHeight();
|
|
702
|
+
return (h("slot", { name: "_selected-display", slot: "custom-display" }));
|
|
607
703
|
}
|
|
608
704
|
render() {
|
|
705
|
+
const showAsPseudo = !this.searchable;
|
|
609
706
|
return (h("click-elsewhere", { class: this.wrapperClasses, onChange: this.clickedElsewhere }, h("div", { "aria-live": "polite", "aria-atomic": "true", role: "status", class: "sr" }, this.statusMessage), 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) &&
|
|
610
707
|
this.errors.length > 0 &&
|
|
611
708
|
this.errors.map(error => loc(error))) ||
|
|
612
709
|
(this.invalid && ['tecton.element.select.invalid']) ||
|
|
613
|
-
[], 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:
|
|
710
|
+
[], 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()), h("div", { class: "custom-display-content", hidden: !this.hasCustomDisplay || !!this.searchText, onClick: this.onCustomDisplayClick }, h("slot", { name: "q2-select-display" })), this.optionsDropdown()));
|
|
614
711
|
}
|
|
615
712
|
optionsDropdown() {
|
|
616
713
|
const dropDirection = this.privatePopDirection === 'up' ? 'dropup' : '';
|
|
617
714
|
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))));
|
|
618
715
|
}
|
|
619
716
|
visibilityToggle() {
|
|
620
|
-
|
|
717
|
+
const selectedOptionsCount = this.selectedOptions.length;
|
|
718
|
+
return (h("div", { class: "multi-select-header", ref: el => (this.multiSelectHeader = el) }, loc('tecton.element.select.multiHeader.showing'), 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')), 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]))));
|
|
621
719
|
}
|
|
622
720
|
get hostElement() { return getElement(this); }
|
|
623
721
|
static get watchers() { return {
|
|
624
722
|
"ariaLabel": ["ariaLabelObserver"],
|
|
625
723
|
"value": ["valueUpdated"],
|
|
626
724
|
"selectedOptions": ["selectedOptionsUpdated"],
|
|
627
|
-
"multilineOptions": ["multilineOptionsChanged"]
|
|
725
|
+
"multilineOptions": ["multilineOptionsChanged"],
|
|
726
|
+
"dropdownOpen": ["dropdownOpenChanged"]
|
|
628
727
|
}; }
|
|
629
728
|
};
|
|
630
729
|
Q2Select.style = stylesCss;
|