q2-tecton-elements 1.23.0 → 1.24.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-e00b4210.js} +28 -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 +1 -1
- package/dist/cjs/q2-btn_2.cjs.entry.js +1 -1
- package/dist/cjs/q2-calendar.cjs.entry.js +1 -1
- 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 -6
- 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-checkbox/index.js +2 -2
- package/dist/collection/components/q2-dropdown/index.js +1 -1
- 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 +1 -56
- 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 +38 -5
- package/dist/collection/utils/action-sheet.js +79 -0
- package/dist/collection/utils/index.js +26 -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 +626 -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 +1 -1
- 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 +1 -1
- 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 +24 -8
- package/dist/components/q2-textarea.js +1 -1
- package/dist/esm/action-sheet-a9597b32.js +81 -0
- package/dist/esm/{index-501fd22e.js → index-ca21e539.js} +27 -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 +1 -1
- package/dist/esm/q2-btn_2.entry.js +1 -1
- package/dist/esm/q2-calendar.entry.js +1 -1
- 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 +21 -6
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/esm/q2-textarea.entry.js +1 -1
- package/dist/q2-tecton-elements/{p-3e9a30c4.entry.js → p-0473f4f7.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-5b1aba1a.entry.js → p-13a1390b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-ebd7efa5.entry.js → p-13deb3ed.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-45d61789.entry.js → p-1d854203.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-1f71774f.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-6b7e1ebd.entry.js → p-256d3fe6.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-8dea9a0c.entry.js → p-282f0f8c.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3603fcdc.entry.js → p-30969629.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-30cd888b.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-3fd5d010.entry.js → p-37cf9c97.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-53be87c8.entry.js → p-388349b5.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-5589ae0f.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-604b22a8.entry.js → p-619aed74.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d68b5eb3.entry.js → p-63b67260.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-ba73ee1f.entry.js → p-63e363ad.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d7b27803.entry.js → p-6736df05.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-72fe10cc.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-68ef0786.entry.js → p-75b817c6.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-a2add94e.entry.js → p-7a116095.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d88e4383.entry.js → p-7c94119b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-24f4571d.entry.js → p-90572e43.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-91153c61.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-70b01387.entry.js → p-9792de8a.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-9acfa94e.js +1 -0
- package/dist/q2-tecton-elements/p-a1926e65.js +1 -0
- package/dist/q2-tecton-elements/{p-d27b2caa.entry.js → p-b3a8cdc5.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-9b101e22.entry.js → p-ce3f203c.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-bf41e71b.entry.js → p-ce91cd9b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-18629cbf.entry.js → p-cefc9d0b.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-d05beeb7.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-6be86940.entry.js → p-dc7c8371.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-acc77332.entry.js → p-e58581fc.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-38a33baa.entry.js → p-e886c55b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-7aa80653.entry.js → p-f94e7043.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-78fac0fa.entry.js → p-fcb7d191.entry.js} +1 -1
- 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-option/index.d.ts +0 -3
- 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 -2
- package/dist/types/components.d.ts +42 -13
- 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 +3 -1
- package/dist/types/workspace/workspace/Tecton_tecton-production_master/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +1 -1
- package/package.json +3 -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-2c20fc43.entry.js +0 -1
- package/dist/q2-tecton-elements/p-3813f51d.entry.js +0 -1
- package/dist/q2-tecton-elements/p-a510290a.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-f1d06917.entry.js +0 -1
- package/dist/q2-tecton-elements/p-f6e868c1.entry.js +0 -1
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-bb1c8c7f.js';
|
|
2
|
-
import {
|
|
2
|
+
import { h as handleAriaLabel, o as overrideFocus, l as loc, b as isRelatedTargetWithinHost, i as isEventFromElement, d as isHostLosingFocus } from './index-ca21e539.js';
|
|
3
|
+
import { s as shouldShowActionSheet, a as showActionSheetList } from './action-sheet-a9597b32.js';
|
|
3
4
|
|
|
4
|
-
const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-double-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #33b4ff #06C)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch: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,
|
|
5
|
+
const stylesCss = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;box-shadow:var(--const-double-focus-ring, 0 0 0 2px #ffffff, 0 0 0 4px #33b4ff #06C)}:host{box-shadow:none !important}::-moz-focus-inner{border:none}input,textarea,button{font-family:inherit;font-size:inherit;font-stretch: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, none))}::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)))}.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);display:inline-grid;grid-template-columns:repeat(3, auto);gap:var(--app-scale-2x, 10px);align-items:center}.q2-element-dropdown.dropup{bottom:var(--comp-dropup-offset)}";
|
|
5
6
|
|
|
6
7
|
const Q2Select = class {
|
|
7
8
|
constructor(hostRef) {
|
|
8
9
|
registerInstance(this, hostRef);
|
|
9
10
|
this.change = createEvent(this, "change", 7);
|
|
10
11
|
this.input = createEvent(this, "input", 7);
|
|
12
|
+
var _a;
|
|
11
13
|
this.scheduledAfterRender = [];
|
|
12
|
-
this.
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
this.showSelectedOptions = (event) => {
|
|
15
|
+
event.stopPropagation();
|
|
16
|
+
this.showSelected = true;
|
|
17
|
+
};
|
|
18
|
+
this.showAllOptions = (event) => {
|
|
19
|
+
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
20
|
+
this.showSelected = false;
|
|
15
21
|
};
|
|
16
|
-
this.guid = createGuid();
|
|
17
22
|
this.onMutationObserved = () => {
|
|
18
23
|
const slotContainer = this.hostElement.querySelector('.custom-display-content');
|
|
19
24
|
const displaySlot = this.hostElement.shadowRoot.querySelector('slot[name="q2-select-display"]');
|
|
@@ -23,201 +28,62 @@ const Q2Select = class {
|
|
|
23
28
|
if (this.hasCustomDisplay !== hasCustomDisplay) {
|
|
24
29
|
this.hasCustomDisplay = hasCustomDisplay;
|
|
25
30
|
}
|
|
26
|
-
if (this.multiple) {
|
|
27
|
-
this.updateMultipleOptionAttrs();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
this.updateSingleOptionAttrs();
|
|
31
|
-
const activeOption = this.optionElements[this.activeIndex];
|
|
32
|
-
if (!activeOption || activeOption.id !== this.activeOptionId) {
|
|
33
|
-
this.activeIndex = this.getDefaultActiveIndex();
|
|
34
|
-
this.setActiveOption();
|
|
35
|
-
}
|
|
36
31
|
};
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
const buildQueue = () => {
|
|
45
|
-
const now = new Date();
|
|
46
|
-
if (now.getTime() - this.keyStore.lastPressedAt.getTime() > 1000) {
|
|
47
|
-
// empty stored keys if delay > 1s
|
|
48
|
-
this.keyStore.queue = [];
|
|
49
|
-
}
|
|
50
|
-
if (this.keyStore.queue.length !== 1 || this.keyStore.queue[0] !== keyValue) {
|
|
51
|
-
this.keyStore.queue.push(keyValue);
|
|
52
|
-
}
|
|
53
|
-
this.keyStore.lastPressedAt = now;
|
|
54
|
-
};
|
|
55
|
-
const searchIndex = list => {
|
|
56
|
-
return list.find(v => {
|
|
57
|
-
return (!v.element.disabled &&
|
|
58
|
-
v.element.display &&
|
|
59
|
-
v.element.display.replace(/\s/g, '').match(new RegExp(`^${this.keyStore.queue.join('')}`, 'i')));
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
const setFocus = ({ element, index }) => {
|
|
63
|
-
if (this.dropdownOpen || this.multiple) {
|
|
64
|
-
// multiple: should open to make sure that which options are selected
|
|
65
|
-
this.openDropdownWithActiveElement(index);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this.activeIndex = index;
|
|
69
|
-
this.change.emit({ value: element.value });
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
buildQueue();
|
|
73
|
-
const matched = searchIndex(reorder());
|
|
74
|
-
if (matched) {
|
|
75
|
-
setFocus(matched);
|
|
76
|
-
}
|
|
32
|
+
this.onOptionListChange = (event) => {
|
|
33
|
+
event.stopPropagation();
|
|
34
|
+
const { values } = event.detail;
|
|
35
|
+
if (values.length === 0)
|
|
36
|
+
this.showAllOptions();
|
|
37
|
+
this.handleSelectionChanges(event.detail);
|
|
77
38
|
};
|
|
78
39
|
/// Event handlers ///
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
const isInDropdown = this.dropdownContainer.contains(relatedTarget);
|
|
82
|
-
const isInLightDom = !isInDropdown && this.hostElement.contains(relatedTarget);
|
|
83
|
-
if (isInDropdown || isInLightDom)
|
|
40
|
+
this.popoverStateChanged = ({ detail: { open } }) => {
|
|
41
|
+
if (this.open === open)
|
|
84
42
|
return;
|
|
85
|
-
|
|
43
|
+
this.open = open;
|
|
44
|
+
if (open && !this.searchText)
|
|
86
45
|
return;
|
|
87
|
-
this.
|
|
46
|
+
this.optionList.setActiveElement(null);
|
|
47
|
+
this.inputField.focus();
|
|
88
48
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
event.stopPropagation();
|
|
92
|
-
const { activeIndex, searchable, optionElements, multiSelectHeader } = this;
|
|
93
|
-
const { key, shiftKey } = event;
|
|
94
|
-
if (this.readonly ||
|
|
95
|
-
(multiSelectHeader && multiSelectHeader.contains(event.target) && [' ', 'Enter'].includes(key)))
|
|
49
|
+
this.inputKeydownHandler = (event) => {
|
|
50
|
+
if (this.readonly || this.disabled)
|
|
96
51
|
return;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (isFirstOption)
|
|
110
|
-
break;
|
|
111
|
-
if (activeIndex !== undefined) {
|
|
112
|
-
const nextIndex = this.getNextVisibleIndex(-1);
|
|
113
|
-
if (nextIndex === -1)
|
|
114
|
-
break;
|
|
115
|
-
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
this.setDefaultActiveElement();
|
|
119
|
-
}
|
|
120
|
-
break;
|
|
121
|
-
case 'ArrowDown':
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
const isLastOption = activeIndex === optionElements.length - 1;
|
|
124
|
-
if (isLastOption)
|
|
125
|
-
break;
|
|
126
|
-
if (activeIndex !== undefined) {
|
|
127
|
-
const nextIndex = this.getNextVisibleIndex(1);
|
|
128
|
-
if (nextIndex === -1)
|
|
129
|
-
break;
|
|
130
|
-
this.adjustActiveOptionAndScroll(nextIndex - activeIndex);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
this.setDefaultActiveElement();
|
|
134
|
-
}
|
|
135
|
-
break;
|
|
136
|
-
case 'Home':
|
|
137
|
-
event.preventDefault();
|
|
138
|
-
this.openDropdownWithActiveElement(0);
|
|
139
|
-
break;
|
|
140
|
-
case 'End':
|
|
141
|
-
event.preventDefault();
|
|
142
|
-
this.openDropdownWithActiveElement(optionElements.length - 1);
|
|
143
|
-
break;
|
|
144
|
-
case 'PageUp':
|
|
145
|
-
event.preventDefault();
|
|
146
|
-
this.openDropdownWithActiveElement(Math.max(activeIndex - 10, 0));
|
|
147
|
-
break;
|
|
148
|
-
case 'PageDown':
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
this.openDropdownWithActiveElement(Math.min(activeIndex + 10, optionElements.length - 1));
|
|
151
|
-
break;
|
|
152
|
-
case 'Tab':
|
|
153
|
-
if (shiftKey)
|
|
154
|
-
break;
|
|
155
|
-
const myOption = this.hostElement.querySelector(`[option-id="${this.activeOptionId}"]`);
|
|
156
|
-
if (!myOption || myOption.disabled)
|
|
157
|
-
return;
|
|
158
|
-
if (myOption.selected)
|
|
159
|
-
return;
|
|
160
|
-
this.selectOption(myOption);
|
|
161
|
-
break;
|
|
162
|
-
case 'Esc':
|
|
163
|
-
case 'Escape':
|
|
164
|
-
this.closeDropdown();
|
|
165
|
-
this.focusInput();
|
|
166
|
-
break;
|
|
167
|
-
default:
|
|
168
|
-
if (searchable)
|
|
169
|
-
break;
|
|
170
|
-
if (!key.match(/^[A-Za-z0-9]$/))
|
|
171
|
-
break;
|
|
172
|
-
// search in non-searchable select: alpha-numeric only
|
|
173
|
-
this.searchAndFocus(key);
|
|
174
|
-
break;
|
|
52
|
+
const keysForOptionListToHandle = [
|
|
53
|
+
'ArrowDown',
|
|
54
|
+
'ArrowUp',
|
|
55
|
+
'PageDown',
|
|
56
|
+
'PageUp',
|
|
57
|
+
'Home',
|
|
58
|
+
'End',
|
|
59
|
+
'Escape',
|
|
60
|
+
'Tab',
|
|
61
|
+
];
|
|
62
|
+
if (shouldShowActionSheet(this, event)) {
|
|
63
|
+
return this.executeActionSheet(event);
|
|
175
64
|
}
|
|
65
|
+
if (this.searchable && !keysForOptionListToHandle.includes(event.key))
|
|
66
|
+
return;
|
|
67
|
+
if (this.shouldClearSearchText(event))
|
|
68
|
+
this.clearSearchText();
|
|
69
|
+
this.optionList.handleExternalKeydown(event);
|
|
176
70
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
break;
|
|
187
|
-
case 'ArrowUp':
|
|
188
|
-
event.preventDefault();
|
|
189
|
-
this.openDropdownWithActiveElement(this.getLastEnabledIndex());
|
|
190
|
-
this.setFocusedOption();
|
|
191
|
-
break;
|
|
192
|
-
case 'Home':
|
|
193
|
-
event.preventDefault();
|
|
194
|
-
this.openDropdownWithActiveElement(0);
|
|
195
|
-
break;
|
|
196
|
-
case 'End':
|
|
197
|
-
event.preventDefault();
|
|
198
|
-
this.openDropdownWithActiveElement(optionElements.length - 1);
|
|
199
|
-
break;
|
|
200
|
-
case 'Escape':
|
|
201
|
-
case 'Esc':
|
|
202
|
-
this.closeDropdown();
|
|
203
|
-
break;
|
|
204
|
-
case 'Tab':
|
|
205
|
-
this.closeDropdown();
|
|
206
|
-
break;
|
|
207
|
-
default:
|
|
208
|
-
if (!key.match(/^[A-Za-z0-9]$/))
|
|
209
|
-
break;
|
|
210
|
-
if (searchable) {
|
|
211
|
-
this.openDropdownWithoutActiveElement();
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
// search in non-searchable select: alpha-numeric only
|
|
215
|
-
this.searchAndFocus(key);
|
|
71
|
+
this.visibilityToggleKeyDown = (event) => {
|
|
72
|
+
const keysForOptionListToHandle = ['ArrowDown', 'ArrowUp'];
|
|
73
|
+
const keysThatTriggerClick = ['Enter', ' '];
|
|
74
|
+
const key = event.key;
|
|
75
|
+
if (keysForOptionListToHandle.includes(key)) {
|
|
76
|
+
this.optionList.handleExternalKeydown(event);
|
|
77
|
+
}
|
|
78
|
+
else if (keysThatTriggerClick.includes(key)) {
|
|
79
|
+
event.target.dispatchEvent(new MouseEvent('click'));
|
|
216
80
|
}
|
|
217
81
|
};
|
|
218
|
-
this.inputClickHandler = (event) => {
|
|
82
|
+
this.inputClickHandler = async (event) => {
|
|
219
83
|
event.stopPropagation();
|
|
220
|
-
|
|
84
|
+
if (shouldShowActionSheet(this)) {
|
|
85
|
+
return this.executeActionSheet(event);
|
|
86
|
+
}
|
|
221
87
|
this.toggleDropdown();
|
|
222
88
|
this.focusInput();
|
|
223
89
|
};
|
|
@@ -227,10 +93,9 @@ const Q2Select = class {
|
|
|
227
93
|
const eventValue = event.detail.value;
|
|
228
94
|
const didChangeText = inputValue !== eventValue;
|
|
229
95
|
const shouldClearValue = !!this.value && didChangeText;
|
|
230
|
-
if (shouldClearValue)
|
|
231
|
-
this.
|
|
232
|
-
|
|
233
|
-
if (!this.dropdownOpen)
|
|
96
|
+
if (shouldClearValue)
|
|
97
|
+
this.clearValue();
|
|
98
|
+
if (!this.open)
|
|
234
99
|
this.openDropdownWithoutActiveElement();
|
|
235
100
|
this.prioritizeSearch = true;
|
|
236
101
|
this.searchText = eventValue;
|
|
@@ -247,32 +112,18 @@ const Q2Select = class {
|
|
|
247
112
|
};
|
|
248
113
|
this.clickedElsewhere = (event) => {
|
|
249
114
|
const target = event.target;
|
|
250
|
-
if (target.localName
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
115
|
+
if (target.localName !== 'click-elsewhere')
|
|
116
|
+
return;
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
if (!this.open)
|
|
119
|
+
return;
|
|
120
|
+
this.closeDropdown();
|
|
256
121
|
};
|
|
257
122
|
this.onCustomDisplayClick = (event) => {
|
|
258
123
|
event.stopPropagation();
|
|
259
124
|
this.focusInput();
|
|
260
125
|
this.toggleDropdown();
|
|
261
126
|
};
|
|
262
|
-
this.showSelectedOptions = (event) => {
|
|
263
|
-
event.stopImmediatePropagation();
|
|
264
|
-
this.onlyShowingSelected = true;
|
|
265
|
-
this.optionElements.forEach(optionElement => {
|
|
266
|
-
optionElement._multiSelectHidden = !optionElement.selected;
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
this.showAllOptions = (event) => {
|
|
270
|
-
event.stopPropagation();
|
|
271
|
-
this.onlyShowingSelected = false;
|
|
272
|
-
this.optionElements.forEach(optionElement => {
|
|
273
|
-
optionElement._multiSelectHidden = false;
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
127
|
this.label = undefined;
|
|
277
128
|
this.hideLabel = undefined;
|
|
278
129
|
this.value = undefined;
|
|
@@ -289,18 +140,21 @@ const Q2Select = class {
|
|
|
289
140
|
this.multilineOptions = false;
|
|
290
141
|
this.optional = false;
|
|
291
142
|
this.placeholder = undefined;
|
|
292
|
-
this.
|
|
293
|
-
this.
|
|
294
|
-
this.
|
|
143
|
+
this.hoist = !!((_a = window.Tecton) === null || _a === void 0 ? void 0 : _a.useActionSheets);
|
|
144
|
+
this.open = false;
|
|
145
|
+
this.showSelected = false;
|
|
295
146
|
this.searchText = '';
|
|
296
147
|
this.hasCustomDisplay = false;
|
|
297
148
|
this.inputFocused = false;
|
|
298
149
|
this.statusMessage = undefined;
|
|
299
150
|
this.prioritizeSearch = false;
|
|
151
|
+
this.structuredSelectedOptions = [];
|
|
300
152
|
}
|
|
301
153
|
/// Lifecycle Hooks ///
|
|
302
154
|
componentWillLoad() {
|
|
303
155
|
handleAriaLabel(this);
|
|
156
|
+
this.buildStructuredSelectedOptions();
|
|
157
|
+
this.handleMultilineOptionsUpdate(this.multilineOptions, false);
|
|
304
158
|
}
|
|
305
159
|
componentDidLoad() {
|
|
306
160
|
const observer = new MutationObserver(this.onMutationObserved);
|
|
@@ -322,22 +176,17 @@ const Q2Select = class {
|
|
|
322
176
|
this.mutationObserver = null;
|
|
323
177
|
}
|
|
324
178
|
/// Getters ///
|
|
325
|
-
get isComponentFocused() {
|
|
326
|
-
return document.activeElement === this.hostElement || !!this.hostElement.querySelector(':focus');
|
|
327
|
-
}
|
|
328
|
-
get isSearchMode() {
|
|
329
|
-
return (this.searchable && this.inputFocused) || this.searchText;
|
|
330
|
-
}
|
|
331
179
|
get badgeValue() {
|
|
180
|
+
var _a, _b;
|
|
332
181
|
if (!this.multiple)
|
|
333
|
-
return;
|
|
334
|
-
const optionsLength = this.selectedOptions.length;
|
|
335
|
-
if (this.
|
|
336
|
-
return optionsLength
|
|
182
|
+
return null;
|
|
183
|
+
const optionsLength = (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
184
|
+
if (this.open && this.searchable)
|
|
185
|
+
return optionsLength ? `${optionsLength}` : null;
|
|
337
186
|
else
|
|
338
187
|
return optionsLength > 1 ? `+${optionsLength - 1}` : null;
|
|
339
188
|
}
|
|
340
|
-
get
|
|
189
|
+
get popoverMinHeight() {
|
|
341
190
|
const { minRows } = this;
|
|
342
191
|
const firstOption = this.hostElement.querySelector('q2-option:not([hidden])');
|
|
343
192
|
const minHeight = firstOption ? window.getComputedStyle(firstOption).minHeight : '44px';
|
|
@@ -354,10 +203,8 @@ const Q2Select = class {
|
|
|
354
203
|
return this.hostElement.querySelector('[slot="_selected-display"]');
|
|
355
204
|
}
|
|
356
205
|
get firstSelectedValue() {
|
|
357
|
-
var _a
|
|
358
|
-
|
|
359
|
-
return (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
|
|
360
|
-
return this.value;
|
|
206
|
+
var _a;
|
|
207
|
+
return this.multiple ? (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a[0] : this.value;
|
|
361
208
|
}
|
|
362
209
|
get firstSelectedOptionElement() {
|
|
363
210
|
const { firstSelectedValue } = this;
|
|
@@ -366,14 +213,9 @@ const Q2Select = class {
|
|
|
366
213
|
get optionElements() {
|
|
367
214
|
return Array.from(this.hostElement.querySelectorAll('q2-option'));
|
|
368
215
|
}
|
|
369
|
-
get visibleOptionElements() {
|
|
370
|
-
return Array.from(this.hostElement.querySelectorAll('q2-option:not([_multiselecthidden])'));
|
|
371
|
-
}
|
|
372
216
|
get wrapperClasses() {
|
|
373
217
|
const { errors } = this;
|
|
374
218
|
const classes = ['q2-select-container'];
|
|
375
|
-
if (this.dropdownOpen)
|
|
376
|
-
classes.push('dropdown-open');
|
|
377
219
|
if (Array.isArray(errors) && errors.length > 0)
|
|
378
220
|
classes.push('has-error');
|
|
379
221
|
if (this.inputFocused)
|
|
@@ -383,33 +225,39 @@ const Q2Select = class {
|
|
|
383
225
|
return classes.join(' ');
|
|
384
226
|
}
|
|
385
227
|
/// Watchers ///
|
|
228
|
+
buildStructuredSelectedOptions() {
|
|
229
|
+
const { multiple, selectedOptions, value } = this;
|
|
230
|
+
if (multiple) {
|
|
231
|
+
this.structuredSelectedOptions = !!(selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length)
|
|
232
|
+
? selectedOptions.map(option => (typeof option === 'string' ? { value: option } : option))
|
|
233
|
+
: [];
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
this.structuredSelectedOptions = value ? [{ value }] : [];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
386
239
|
ariaLabelObserver() {
|
|
387
240
|
handleAriaLabel(this);
|
|
388
241
|
}
|
|
389
242
|
valueUpdated() {
|
|
390
243
|
if (this.multiple)
|
|
391
244
|
return;
|
|
392
|
-
this.
|
|
393
|
-
}
|
|
394
|
-
selectedOptionsUpdated() {
|
|
395
|
-
if (!this.multiple)
|
|
396
|
-
return;
|
|
397
|
-
this.updateMultipleOptionAttrs();
|
|
245
|
+
this.clearSearchText();
|
|
398
246
|
}
|
|
399
|
-
|
|
247
|
+
handleMultilineOptionsUpdate(newValue, oldValue) {
|
|
400
248
|
if (newValue === oldValue)
|
|
401
249
|
return;
|
|
402
250
|
this.optionElements.forEach(element => (element.multiline = newValue));
|
|
403
251
|
}
|
|
404
|
-
|
|
252
|
+
openChanged(isOpen) {
|
|
405
253
|
this.scheduledAfterRender.push(() => {
|
|
406
|
-
const { multiple, multiSelectHeader,
|
|
254
|
+
const { multiple, multiSelectHeader, popoverElement } = this;
|
|
407
255
|
const height = (isOpen && multiple && (multiSelectHeader === null || multiSelectHeader === void 0 ? void 0 : multiSelectHeader.offsetHeight)) || 0;
|
|
408
256
|
if (height) {
|
|
409
|
-
|
|
257
|
+
popoverElement.style.setProperty('--comp-multi-select-header-height', `${height}px`);
|
|
410
258
|
}
|
|
411
259
|
else {
|
|
412
|
-
|
|
260
|
+
popoverElement.style.removeProperty('--comp-multi-select-header-height');
|
|
413
261
|
}
|
|
414
262
|
});
|
|
415
263
|
}
|
|
@@ -418,15 +266,17 @@ const Q2Select = class {
|
|
|
418
266
|
this.inputKeydownHandler(event);
|
|
419
267
|
}
|
|
420
268
|
onHostElementChange(event) {
|
|
421
|
-
if (this.readonly)
|
|
269
|
+
if (this.readonly || this.disabled)
|
|
422
270
|
return;
|
|
423
271
|
if (event.target !== this.hostElement || this.hostElement.onchange)
|
|
424
272
|
return;
|
|
425
273
|
if (this.multiple) {
|
|
274
|
+
this.value = null;
|
|
426
275
|
this.selectedOptions = event.detail.selectedOptions;
|
|
427
276
|
}
|
|
428
277
|
else {
|
|
429
278
|
this.value = event.detail.value;
|
|
279
|
+
this.selectedOptions = [];
|
|
430
280
|
}
|
|
431
281
|
}
|
|
432
282
|
onHostElementInput(event) {
|
|
@@ -468,54 +318,33 @@ const Q2Select = class {
|
|
|
468
318
|
}
|
|
469
319
|
}
|
|
470
320
|
handleFocusout(event) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
if (!selectedOption ||
|
|
476
|
-
(selectedOption.hasAttribute('disabled') && selectedOption.getAttribute('disabled') !== 'false'))
|
|
477
|
-
return;
|
|
478
|
-
this.selectOption(selectedOption, true);
|
|
321
|
+
const isLeavingHost = isHostLosingFocus(event, this.hostElement);
|
|
322
|
+
if (isLeavingHost)
|
|
323
|
+
this.closeDropdown();
|
|
324
|
+
this.prioritizeSearch = !isLeavingHost && this.searchable;
|
|
479
325
|
}
|
|
480
326
|
/// Helpers ///
|
|
481
|
-
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
return acc;
|
|
496
|
-
}, []);
|
|
497
|
-
return enabledIndexes[enabledIndexes.length - 1];
|
|
498
|
-
}
|
|
499
|
-
setActiveOption() {
|
|
500
|
-
if (!this.dropdownOpen)
|
|
501
|
-
return;
|
|
502
|
-
const activeIndex = this.activeIndex;
|
|
503
|
-
this.optionElements.forEach((element, elementIndex) => {
|
|
504
|
-
if (activeIndex === elementIndex) {
|
|
505
|
-
element.active = true;
|
|
506
|
-
this.activeOptionId = element.optionId;
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
509
|
-
element.active = false;
|
|
510
|
-
}
|
|
327
|
+
async executeActionSheet(event) {
|
|
328
|
+
const result = await showActionSheetList(this, event);
|
|
329
|
+
this.handleSelectionChanges(result);
|
|
330
|
+
}
|
|
331
|
+
handleSelectionChanges(changeDetails) {
|
|
332
|
+
const { value = '', values = [] } = changeDetails;
|
|
333
|
+
const selectedOptionValues = values.map(value => value.value);
|
|
334
|
+
const { multiple } = this;
|
|
335
|
+
if (!this.hostElement.onchange) {
|
|
336
|
+
this.selectedOptions = selectedOptionValues;
|
|
337
|
+
}
|
|
338
|
+
this.change.emit({
|
|
339
|
+
value: multiple ? undefined : value,
|
|
340
|
+
selectedOptions: multiple ? selectedOptionValues : undefined,
|
|
511
341
|
});
|
|
512
342
|
}
|
|
513
|
-
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
option.focus();
|
|
343
|
+
clearValue() {
|
|
344
|
+
const { multiple } = this;
|
|
345
|
+
this.value = '';
|
|
346
|
+
this.selectedOptions = [];
|
|
347
|
+
this.change.emit({ value: multiple ? undefined : '', selectedOptions: multiple ? [] : undefined });
|
|
519
348
|
}
|
|
520
349
|
calculateMultiSelectSelectedDisplay() {
|
|
521
350
|
var _a;
|
|
@@ -534,130 +363,36 @@ const Q2Select = class {
|
|
|
534
363
|
const { firstSelectedOptionElement } = this;
|
|
535
364
|
return ((firstSelectedOptionElement === null || firstSelectedOptionElement === void 0 ? void 0 : firstSelectedOptionElement.display) && loc(firstSelectedOptionElement.display)) || this.value || '';
|
|
536
365
|
}
|
|
537
|
-
updateSingleOptionAttrs() {
|
|
538
|
-
const { value, guid, multilineOptions } = this;
|
|
539
|
-
this.optionElements.forEach((element, index) => {
|
|
540
|
-
element.selected = element.value === value;
|
|
541
|
-
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
542
|
-
element.multiline = multilineOptions;
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
updateMultipleOptionAttrs() {
|
|
546
|
-
if (this.selectedOptions.length === 0) {
|
|
547
|
-
this.onlyShowingSelected = false;
|
|
548
|
-
}
|
|
549
|
-
const { selectedOptions, onlyShowingSelected, guid, multilineOptions } = this;
|
|
550
|
-
this.optionElements.forEach((element, index) => {
|
|
551
|
-
element.selected = selectedOptions.includes(element.value);
|
|
552
|
-
element._multiSelectHidden = onlyShowingSelected ? !element.selected : false;
|
|
553
|
-
element.optionId = `q2-select-${guid}-option-${index}`;
|
|
554
|
-
element.multiline = multilineOptions;
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
focusSelectedSibling(option) {
|
|
558
|
-
if (!this.onlyShowingSelected)
|
|
559
|
-
return;
|
|
560
|
-
const { visibleOptionElements } = this;
|
|
561
|
-
if (visibleOptionElements.length < 2)
|
|
562
|
-
return;
|
|
563
|
-
const optionIndex = visibleOptionElements.indexOf(option);
|
|
564
|
-
const visibleFocusIndex = optionIndex ? optionIndex - 1 : optionIndex + 1;
|
|
565
|
-
const optionToFocus = visibleOptionElements[visibleFocusIndex];
|
|
566
|
-
const focusIndex = this.optionElements.indexOf(optionToFocus);
|
|
567
|
-
this.activeIndex = focusIndex;
|
|
568
|
-
this.setFocusedOption();
|
|
569
|
-
}
|
|
570
|
-
selectOption(option, focusInputOnClose = false) {
|
|
571
|
-
var _a;
|
|
572
|
-
const value = (_a = option === null || option === void 0 ? void 0 : option.value) !== null && _a !== void 0 ? _a : '';
|
|
573
|
-
if (this.multiple) {
|
|
574
|
-
const isSelected = this.selectedOptions.includes(value);
|
|
575
|
-
if (isSelected) {
|
|
576
|
-
this.focusSelectedSibling(option);
|
|
577
|
-
this.change.emit({
|
|
578
|
-
selectedOptions: this.selectedOptions.filter(selectedValue => selectedValue !== value),
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
else if (value) {
|
|
582
|
-
this.change.emit({ selectedOptions: [...this.selectedOptions, value] });
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
this.change.emit({ value });
|
|
587
|
-
this.closeDropdown();
|
|
588
|
-
if (focusInputOnClose)
|
|
589
|
-
this.focusInput();
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
scrollToActiveOption() {
|
|
593
|
-
const activeOption = this.optionElements[this.activeIndex];
|
|
594
|
-
activeOption === null || activeOption === void 0 ? void 0 : activeOption.scrollIntoView({ block: 'nearest' });
|
|
595
|
-
}
|
|
596
366
|
openDropdownWithoutActiveElement() {
|
|
597
|
-
if (this.readonly)
|
|
367
|
+
if (this.readonly || this.disabled)
|
|
598
368
|
return;
|
|
599
|
-
this.
|
|
600
|
-
this.
|
|
601
|
-
this.dropdownOpen = true;
|
|
602
|
-
this.scheduledAfterRender.push(resizeIframe);
|
|
603
|
-
}
|
|
604
|
-
openDropdownWithActiveElement(activeIndex) {
|
|
605
|
-
if (this.readonly)
|
|
606
|
-
return;
|
|
607
|
-
this.activeIndex = activeIndex;
|
|
608
|
-
this.dropdownOpen = true;
|
|
609
|
-
this.setActiveOption();
|
|
610
|
-
this.scheduledAfterRender.push(() => {
|
|
611
|
-
this.setFocusedOption();
|
|
612
|
-
this.scrollToActiveOption();
|
|
613
|
-
resizeIframe();
|
|
614
|
-
});
|
|
369
|
+
this.optionList.setActiveElement(null);
|
|
370
|
+
this.open = true;
|
|
615
371
|
}
|
|
616
372
|
closeDropdown() {
|
|
617
|
-
this.
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
373
|
+
this.open = false;
|
|
374
|
+
this.clearSearchText();
|
|
375
|
+
}
|
|
376
|
+
clearSearchText() {
|
|
377
|
+
if (!this.searchText)
|
|
378
|
+
return;
|
|
379
|
+
this.searchText = '';
|
|
380
|
+
this.input.emit({ query: '' });
|
|
623
381
|
}
|
|
624
382
|
toggleDropdown() {
|
|
625
|
-
if (this.disabled)
|
|
383
|
+
if (this.readonly || this.disabled)
|
|
626
384
|
return;
|
|
627
|
-
if (this.
|
|
385
|
+
if (this.open && !this.searchText) {
|
|
628
386
|
this.closeDropdown();
|
|
629
387
|
}
|
|
630
388
|
else {
|
|
631
389
|
this.openDropdownWithoutActiveElement();
|
|
632
390
|
}
|
|
633
391
|
}
|
|
634
|
-
adjustActiveOptionAndScroll(numToAdd) {
|
|
635
|
-
this.activeIndex += numToAdd;
|
|
636
|
-
this.setActiveOption();
|
|
637
|
-
this.setFocusedOption();
|
|
638
|
-
this.scrollToActiveOption();
|
|
639
|
-
}
|
|
640
|
-
setDefaultActiveElement() {
|
|
641
|
-
this.activeIndex = this.getDefaultActiveIndex();
|
|
642
|
-
this.setActiveOption();
|
|
643
|
-
this.setFocusedOption();
|
|
644
|
-
}
|
|
645
392
|
focusInput() {
|
|
646
393
|
var _a;
|
|
647
394
|
(_a = this.inputField) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new FocusEvent('focus'));
|
|
648
395
|
}
|
|
649
|
-
getNextVisibleIndex(direction) {
|
|
650
|
-
let index = this.activeIndex + direction;
|
|
651
|
-
const { optionElements } = this;
|
|
652
|
-
while (index >= 0 && index <= optionElements.length - 1) {
|
|
653
|
-
const { display, visibility } = window.getComputedStyle(optionElements[index]);
|
|
654
|
-
if (display !== 'none' && visibility !== 'hidden') {
|
|
655
|
-
return index;
|
|
656
|
-
}
|
|
657
|
-
index = index + direction;
|
|
658
|
-
}
|
|
659
|
-
return -1;
|
|
660
|
-
}
|
|
661
396
|
setStatusMessage(message) {
|
|
662
397
|
clearTimeout(this.statusMessageTimer);
|
|
663
398
|
this.statusMessage = '';
|
|
@@ -672,7 +407,7 @@ const Q2Select = class {
|
|
|
672
407
|
checkSelectedDisplay() {
|
|
673
408
|
let namedSlot = this.selectedDisplaySlot;
|
|
674
409
|
const { value, multiple, selectedOptions, multilineOptions, firstSelectedOptionElement, prioritizeSearch } = this;
|
|
675
|
-
const hasNoValue = !value && multiple && !selectedOptions.length;
|
|
410
|
+
const hasNoValue = !value && multiple && !(selectedOptions === null || selectedOptions === void 0 ? void 0 : selectedOptions.length);
|
|
676
411
|
if (prioritizeSearch || !multilineOptions || hasNoValue)
|
|
677
412
|
return this.clearSelectedDisplay();
|
|
678
413
|
if (!firstSelectedOptionElement || firstSelectedOptionElement.display)
|
|
@@ -701,6 +436,9 @@ const Q2Select = class {
|
|
|
701
436
|
return;
|
|
702
437
|
selectedDisplaySlot.style.setProperty('--comp-selected-display-height', '44px');
|
|
703
438
|
}
|
|
439
|
+
shouldClearSearchText(event) {
|
|
440
|
+
return this.searchable && !!this.searchText && event.key === 'Escape';
|
|
441
|
+
}
|
|
704
442
|
/// DOM ///
|
|
705
443
|
renderCustomDisplay() {
|
|
706
444
|
const hasSelectedDisplay = this.checkSelectedDisplay();
|
|
@@ -715,23 +453,24 @@ const Q2Select = class {
|
|
|
715
453
|
this.errors.length > 0 &&
|
|
716
454
|
this.errors.map(error => loc(error))) ||
|
|
717
455
|
(this.invalid && ['tecton.element.select.invalid']) ||
|
|
718
|
-
[], disabled: this.disabled, optional: this.optional, readonly: this.readonly, placeholder: this.placeholder || undefined, hideLabel: this.hideLabel, ariaExpanded: `${!!this.
|
|
456
|
+
[], 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()));
|
|
719
457
|
}
|
|
720
458
|
optionsDropdown() {
|
|
721
|
-
|
|
722
|
-
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))));
|
|
459
|
+
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))));
|
|
723
460
|
}
|
|
724
461
|
visibilityToggle() {
|
|
725
|
-
|
|
726
|
-
|
|
462
|
+
var _a, _b;
|
|
463
|
+
const selectedOptionsCount = (_b = (_a = this.selectedOptions) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
464
|
+
const { showSelected } = this;
|
|
465
|
+
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]))));
|
|
727
466
|
}
|
|
728
467
|
get hostElement() { return getElement(this); }
|
|
729
468
|
static get watchers() { return {
|
|
469
|
+
"value": ["buildStructuredSelectedOptions", "valueUpdated"],
|
|
470
|
+
"selectedOptions": ["buildStructuredSelectedOptions"],
|
|
730
471
|
"ariaLabel": ["ariaLabelObserver"],
|
|
731
|
-
"
|
|
732
|
-
"
|
|
733
|
-
"multilineOptions": ["multilineOptionsChanged"],
|
|
734
|
-
"dropdownOpen": ["dropdownOpenChanged"]
|
|
472
|
+
"multilineOptions": ["handleMultilineOptionsUpdate"],
|
|
473
|
+
"open": ["openChanged"]
|
|
735
474
|
}; }
|
|
736
475
|
};
|
|
737
476
|
Q2Select.style = stylesCss;
|