@webquark/browser 1.1.0-dev.10 → 1.1.0-dev.11
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.props-N0urQtdP.js → action.props-DmLaQuU2.js} +1 -1
- package/dist/cjs/{field-CsrQGhG-.js → field-CEZ9NsWK.js} +1 -1
- package/dist/cjs/{index-DWXhKHCB.js → index-CMAcJ6t1.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/q-accordion.cjs.entry.js +1 -1
- package/dist/cjs/q-alert.cjs.entry.js +1 -1
- package/dist/cjs/q-avatar.cjs.entry.js +2 -2
- package/dist/cjs/q-banner.cjs.entry.js +1 -1
- package/dist/cjs/q-button_2.cjs.entry.js +4 -4
- package/dist/cjs/q-card.cjs.entry.js +2 -2
- package/dist/cjs/q-carousel.cjs.entry.js +1 -1
- package/dist/cjs/q-chip.cjs.entry.js +2 -2
- package/dist/cjs/q-conversation-bubble.cjs.entry.js +1 -1
- package/dist/cjs/q-data-table.cjs.entry.js +1 -1
- package/dist/cjs/q-dialog.cjs.entry.js +3 -3
- package/dist/cjs/q-divider.cjs.entry.js +26 -0
- package/dist/cjs/q-dropdown.cjs.entry.js +111 -92
- package/dist/cjs/q-form.cjs.entry.js +4 -4
- package/dist/cjs/q-grid.cjs.entry.js +3 -3
- package/dist/cjs/q-icon.cjs.entry.js +1 -1
- package/dist/cjs/q-image-comparison.cjs.entry.js +2 -2
- package/dist/cjs/q-inline.cjs.entry.js +3 -3
- package/dist/cjs/q-input_2.cjs.entry.js +8 -6
- package/dist/cjs/q-link.cjs.entry.js +2 -2
- package/dist/cjs/q-map.cjs.entry.js +1 -1
- package/dist/cjs/q-media.cjs.entry.js +2 -2
- package/dist/cjs/q-navbar.cjs.entry.js +3 -3
- package/dist/cjs/q-pagination.cjs.entry.js +1 -1
- package/dist/cjs/q-panel.cjs.entry.js +6 -6
- package/dist/cjs/q-quantity-selector.cjs.entry.js +5 -5
- package/dist/cjs/q-radio-group.cjs.entry.js +4 -4
- package/dist/cjs/q-reel.cjs.entry.js +3 -3
- package/dist/cjs/q-scrollable.cjs.entry.js +4 -4
- package/dist/cjs/q-section.cjs.entry.js +2 -2
- package/dist/cjs/q-sidepanel.cjs.entry.js +1 -1
- package/dist/cjs/q-stack.cjs.entry.js +3 -3
- package/dist/cjs/q-step-diagram-item.cjs.entry.js +1 -1
- package/dist/cjs/q-step-diagram.cjs.entry.js +1 -1
- package/dist/cjs/q-syntax-box.cjs.entry.js +1 -1
- package/dist/cjs/q-tabs.cjs.entry.js +2 -2
- package/dist/cjs/q-textarea.cjs.entry.js +7 -5
- package/dist/cjs/q-thumbnail.cjs.entry.js +3 -3
- package/dist/cjs/q-toast.cjs.entry.js +1 -1
- package/dist/cjs/q-toggle.cjs.entry.js +6 -6
- package/dist/cjs/q-toolbar.cjs.entry.js +4 -4
- package/dist/cjs/{tokens-RMRaIOqv.js → tokens-Cd7g-VMz.js} +3 -0
- package/dist/cjs/webquark.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/inputs/dropdown/dropdown.css +33 -0
- package/dist/collection/components/inputs/dropdown/dropdown.js +158 -91
- package/dist/collection/components/inputs/dropdown/test/dropdown.cmp.test.js +28 -0
- package/dist/collection/components/inputs/dropdown/test/search-mode.cmp.test.js +186 -0
- package/dist/collection/components/inputs/form/form.js +2 -2
- package/dist/collection/components/inputs/form/test/form-submit.cmp.test.js +14 -8
- package/dist/collection/components/inputs/input/input.css +20 -0
- package/dist/collection/components/inputs/input/input.js +31 -3
- package/dist/collection/components/inputs/quantity-selector/quantity-selector.js +4 -4
- package/dist/collection/components/inputs/radio-group/radio-group.js +2 -2
- package/dist/collection/components/inputs/textarea/textarea.css +20 -0
- package/dist/collection/components/inputs/textarea/textarea.js +30 -2
- package/dist/collection/components/inputs/toggle/test/toggle-layout.cmp.test.js +69 -0
- package/dist/collection/components/inputs/toggle/toggle.css +5 -0
- package/dist/collection/components/inputs/toggle/toggle.js +3 -3
- package/dist/collection/components/layout/divider/divider.css +40 -0
- package/dist/collection/components/layout/divider/divider.js +121 -0
- package/dist/collection/components/layout/divider/test/divider.cmp.test.js +105 -0
- package/dist/collection/components/layout/grid/grid.js +1 -1
- package/dist/collection/components/layout/inline/inline.js +1 -1
- package/dist/collection/components/layout/navbar/navbar.js +2 -2
- package/dist/collection/components/layout/panel/panel.js +4 -4
- package/dist/collection/components/layout/scrollable/scrollable.js +3 -3
- package/dist/collection/components/layout/section/section.js +1 -1
- package/dist/collection/components/layout/stack/stack.js +1 -1
- package/dist/collection/components/layout/tabs/tabs.js +1 -1
- package/dist/collection/components/layout/toolbar/toolbar.js +2 -2
- package/dist/collection/components/media/avatar/avatar.js +1 -1
- package/dist/collection/components/media/image-comparison/image-comparison.js +1 -1
- package/dist/collection/components/media/media/media.js +1 -1
- package/dist/collection/components/media/reel/reel.js +2 -2
- package/dist/collection/components/media/thumbnail/thumbnail.js +2 -2
- package/dist/collection/components/overlays/dialog/dialog.js +2 -2
- package/dist/collection/components/overlays/tooltip/tooltip.js +2 -2
- package/dist/collection/theme/test/input-width.cmp.test.js +117 -0
- package/dist/collection/theme/test/presets.unit.test.js +20 -2
- package/dist/collection/theme/tokens.js +3 -0
- package/dist/components/index.js +1 -1
- package/dist/components/{p-Dfp_If-_.js → p--r63tfQH.js} +1 -1
- package/dist/components/{p-Cg0Mv7Vb.js → p-0feRVg70.js} +1 -1
- package/dist/components/p-BDsIecIx.js +1 -0
- package/dist/components/p-CLErjC1f.js +1 -0
- package/dist/{webquark/p-Dhsn99q4.js → components/p-CSucjZb7.js} +1 -1
- package/dist/components/{p-BH4gQWub.js → p-CYG3Oakz.js} +1 -1
- package/dist/components/{p-CKuPOxKN.js → p-DBbiaYqQ.js} +1 -1
- package/dist/components/{p-DlIn_ZWk.js → p-DbI_F3z0.js} +1 -1
- package/dist/components/p-cSh-5xis.js +1 -0
- package/dist/components/{p-6PPZ2sIO.js → p-iXEnb5d5.js} +1 -1
- package/dist/components/q-accordion.js +1 -1
- package/dist/components/q-alert.js +1 -1
- package/dist/components/q-avatar.js +1 -1
- package/dist/components/q-banner.js +1 -1
- package/dist/components/q-button.js +1 -1
- package/dist/components/q-card.js +1 -1
- package/dist/components/q-carousel.js +1 -1
- package/dist/components/q-chip.js +1 -1
- package/dist/components/q-conversation-bubble.js +1 -1
- package/dist/components/q-data-table.js +1 -1
- package/dist/components/q-dialog.js +1 -1
- package/dist/components/q-divider.d.ts +11 -0
- package/dist/components/q-divider.js +1 -0
- package/dist/components/q-dropdown.js +1 -1
- package/dist/components/q-form.js +1 -1
- package/dist/components/q-grid.js +1 -1
- package/dist/components/q-icon.js +1 -1
- package/dist/components/q-image-comparison.js +1 -1
- package/dist/components/q-inline.js +1 -1
- package/dist/components/q-input.js +1 -1
- package/dist/components/q-link.js +1 -1
- package/dist/components/q-map.js +1 -1
- package/dist/components/q-media.js +1 -1
- package/dist/components/q-navbar.js +1 -1
- package/dist/components/q-pagination.js +1 -1
- package/dist/components/q-panel.js +1 -1
- package/dist/components/q-progress.js +1 -1
- package/dist/components/q-quantity-selector.js +1 -1
- package/dist/components/q-radio-group.js +1 -1
- package/dist/components/q-reel.js +1 -1
- package/dist/components/q-scrollable.js +1 -1
- package/dist/components/q-section.js +1 -1
- package/dist/components/q-sidepanel.js +1 -1
- package/dist/components/q-stack.js +1 -1
- package/dist/components/q-step-diagram-item.js +1 -1
- package/dist/components/q-step-diagram.js +1 -1
- package/dist/components/q-syntax-box.js +2 -2
- package/dist/components/q-tabs.js +1 -1
- package/dist/components/q-textarea.js +1 -1
- package/dist/components/q-thumbnail.js +1 -1
- package/dist/components/q-toast.js +1 -1
- package/dist/components/q-toggle.js +1 -1
- package/dist/components/q-toolbar.js +1 -1
- package/dist/components/q-tooltip.js +1 -1
- package/dist/esm/{action.props-CpnGza8z.js → action.props-DhnvhbLl.js} +1 -1
- package/dist/esm/{field-zfD6OQ02.js → field-u-k7C7Rf.js} +1 -1
- package/dist/esm/{index-B5ElFlHv.js → index-DaJmsCb7.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/q-accordion.entry.js +1 -1
- package/dist/esm/q-alert.entry.js +1 -1
- package/dist/esm/q-avatar.entry.js +2 -2
- package/dist/esm/q-banner.entry.js +1 -1
- package/dist/esm/q-button_2.entry.js +4 -4
- package/dist/esm/q-card.entry.js +2 -2
- package/dist/esm/q-carousel.entry.js +1 -1
- package/dist/esm/q-chip.entry.js +2 -2
- package/dist/esm/q-conversation-bubble.entry.js +1 -1
- package/dist/esm/q-data-table.entry.js +1 -1
- package/dist/esm/q-dialog.entry.js +3 -3
- package/dist/esm/q-divider.entry.js +24 -0
- package/dist/esm/q-dropdown.entry.js +111 -92
- package/dist/esm/q-form.entry.js +4 -4
- package/dist/esm/q-grid.entry.js +3 -3
- package/dist/esm/q-icon.entry.js +1 -1
- package/dist/esm/q-image-comparison.entry.js +2 -2
- package/dist/esm/q-inline.entry.js +3 -3
- package/dist/esm/q-input_2.entry.js +8 -6
- package/dist/esm/q-link.entry.js +2 -2
- package/dist/esm/q-map.entry.js +1 -1
- package/dist/esm/q-media.entry.js +2 -2
- package/dist/esm/q-navbar.entry.js +3 -3
- package/dist/esm/q-pagination.entry.js +1 -1
- package/dist/esm/q-panel.entry.js +6 -6
- package/dist/esm/q-quantity-selector.entry.js +5 -5
- package/dist/esm/q-radio-group.entry.js +4 -4
- package/dist/esm/q-reel.entry.js +3 -3
- package/dist/esm/q-scrollable.entry.js +4 -4
- package/dist/esm/q-section.entry.js +2 -2
- package/dist/esm/q-sidepanel.entry.js +1 -1
- package/dist/esm/q-stack.entry.js +3 -3
- package/dist/esm/q-step-diagram-item.entry.js +1 -1
- package/dist/esm/q-step-diagram.entry.js +1 -1
- package/dist/esm/q-syntax-box.entry.js +1 -1
- package/dist/esm/q-tabs.entry.js +2 -2
- package/dist/esm/q-textarea.entry.js +7 -5
- package/dist/esm/q-thumbnail.entry.js +3 -3
- package/dist/esm/q-toast.entry.js +1 -1
- package/dist/esm/q-toggle.entry.js +6 -6
- package/dist/esm/q-toolbar.entry.js +4 -4
- package/dist/esm/{tokens-B4Mg1xEw.js → tokens-BDsIecIx.js} +3 -0
- package/dist/esm/webquark.js +3 -3
- package/dist/playground/components/theme-designer/dimension-tokens.js +9 -0
- package/dist/playground/components/theme-designer/token-row.js +89 -0
- package/dist/playground/dom-factory.js +76 -0
- package/dist/playground/utils/color.js +26 -0
- package/dist/playground/utils/dom.js +38 -0
- package/dist/playground/utils/index.js +2 -0
- package/dist/types/components/inputs/dropdown/dropdown.d.ts +18 -1
- package/dist/types/components/inputs/dropdown/test/search-mode.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/input/input.d.ts +3 -0
- package/dist/types/components/inputs/textarea/textarea.d.ts +3 -1
- package/dist/types/components/inputs/toggle/test/toggle-layout.cmp.test.d.ts +1 -0
- package/dist/types/components/layout/divider/divider.d.ts +15 -0
- package/dist/types/components/layout/divider/test/divider.cmp.test.d.ts +1 -0
- package/dist/types/components.d.ts +111 -2
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/components/theme-designer/dimension-tokens.d.ts +3 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/components/theme-designer/token-row.d.ts +14 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/dom-factory.d.ts +12 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/utils/color.d.ts +8 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/utils/dom.d.ts +15 -0
- package/dist/types/home/runner/work/WebQuark/WebQuark/.stencil/src/playground/utils/index.d.ts +2 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/theme/test/input-width.cmp.test.d.ts +3 -0
- package/dist/types/theme/tokens.d.ts +9 -0
- package/dist/webquark/{p-023f8437.entry.js → p-0f04ceab.entry.js} +1 -1
- package/dist/webquark/{p-97a89cae.entry.js → p-10dc5cce.entry.js} +1 -1
- package/dist/webquark/p-191a7063.entry.js +1 -0
- package/dist/webquark/p-1e8797d1.entry.js +1 -0
- package/dist/webquark/{p-09cca7b9.entry.js → p-220ec9cf.entry.js} +1 -1
- package/dist/webquark/p-2291095e.entry.js +1 -0
- package/dist/webquark/{p-fec6fe0a.entry.js → p-32055acd.entry.js} +1 -1
- package/dist/webquark/{p-5f232b44.entry.js → p-3af50215.entry.js} +2 -2
- package/dist/webquark/{p-6bfffa79.entry.js → p-41deb44c.entry.js} +1 -1
- package/dist/webquark/{p-9ff7e5a4.entry.js → p-44eda084.entry.js} +1 -1
- package/dist/webquark/{p-d0253d64.entry.js → p-473a1810.entry.js} +1 -1
- package/dist/webquark/p-4cf40080.entry.js +1 -0
- package/dist/webquark/{p-f98f9439.entry.js → p-4d611b93.entry.js} +1 -1
- package/dist/webquark/{p-0aa74ad6.entry.js → p-596737cc.entry.js} +1 -1
- package/dist/webquark/{p-36118d90.entry.js → p-5cccb6bc.entry.js} +1 -1
- package/dist/webquark/{p-9e78b796.entry.js → p-5d6fb0d1.entry.js} +1 -1
- package/dist/webquark/{p-f4f97e74.entry.js → p-687be7d4.entry.js} +1 -1
- package/dist/webquark/{p-144ef339.entry.js → p-6a5033da.entry.js} +1 -1
- package/dist/webquark/{p-059daa8a.entry.js → p-6d2d016a.entry.js} +1 -1
- package/dist/webquark/p-70e3a23a.entry.js +1 -0
- package/dist/webquark/p-7723e966.entry.js +1 -0
- package/dist/webquark/{p-64096386.entry.js → p-78c56cd3.entry.js} +1 -1
- package/dist/webquark/{p-d0fbd2b1.entry.js → p-8a0733a1.entry.js} +1 -1
- package/dist/webquark/p-BDsIecIx.js +1 -0
- package/dist/webquark/{p-DWO-pleQ.js → p-Bk4FnOfb.js} +1 -1
- package/dist/{components/p-BofcK-7Z.js → webquark/p-BuctNczf.js} +1 -1
- package/dist/webquark/p-DaJmsCb7.js +3 -0
- package/dist/webquark/{p-dd115868.entry.js → p-a199de7d.entry.js} +1 -1
- package/dist/webquark/{p-fe8c634a.entry.js → p-a30d212f.entry.js} +1 -1
- package/dist/webquark/{p-f1bac94c.entry.js → p-a87f0bde.entry.js} +1 -1
- package/dist/webquark/{p-f9ad63ff.entry.js → p-b75ec829.entry.js} +1 -1
- package/dist/webquark/{p-48fb5228.entry.js → p-b82aaf4c.entry.js} +1 -1
- package/dist/webquark/p-b8f4994a.entry.js +1 -0
- package/dist/webquark/{p-f63b7214.entry.js → p-b9c8c081.entry.js} +1 -1
- package/dist/webquark/{p-296fbdb1.entry.js → p-bf568cda.entry.js} +1 -1
- package/dist/webquark/{p-6e28cfe2.entry.js → p-c662904e.entry.js} +1 -1
- package/dist/webquark/{p-4d61b70d.entry.js → p-cab898c2.entry.js} +1 -1
- package/dist/webquark/{p-030ecde3.entry.js → p-d2c4696f.entry.js} +1 -1
- package/dist/webquark/{p-3bc4629c.entry.js → p-ddeb2d4c.entry.js} +1 -1
- package/dist/webquark/{p-888e46a8.entry.js → p-dee50f0a.entry.js} +1 -1
- package/dist/webquark/{p-8ece2c62.entry.js → p-e3c18c0e.entry.js} +1 -1
- package/dist/webquark/{p-90b0858c.entry.js → p-e7384b6e.entry.js} +1 -1
- package/dist/webquark/p-f63fd66f.entry.js +1 -0
- package/dist/webquark/p-f95aeb8d.entry.js +1 -0
- package/dist/webquark/{p-99d785ca.entry.js → p-fbd1cbbe.entry.js} +1 -1
- package/dist/webquark/webquark.css +1 -1
- package/dist/webquark/webquark.esm.js +1 -1
- package/package.json +1 -1
- package/dist/components/p-B4Mg1xEw.js +0 -1
- package/dist/components/p-CN1ut2Lb.js +0 -1
- package/dist/components/p-ye27qtRo.js +0 -1
- package/dist/webquark/p-04c8cb9e.entry.js +0 -1
- package/dist/webquark/p-0ae43d6c.entry.js +0 -1
- package/dist/webquark/p-0c3aac3f.entry.js +0 -1
- package/dist/webquark/p-70d9ffde.entry.js +0 -1
- package/dist/webquark/p-91fff6b6.entry.js +0 -1
- package/dist/webquark/p-923dac41.entry.js +0 -1
- package/dist/webquark/p-B4Mg1xEw.js +0 -1
- package/dist/webquark/p-B5ElFlHv.js +0 -3
- package/dist/webquark/p-c523ec6f.entry.js +0 -1
- package/dist/webquark/p-fe200f68.entry.js +0 -1
|
@@ -11,7 +11,7 @@ const MENU_OFFSET = 4;
|
|
|
11
11
|
* and externally loaded option pages.
|
|
12
12
|
* @slot icon-left - Optional leading content rendered inside the trigger.
|
|
13
13
|
* @part label - Optional field label.
|
|
14
|
-
* @part trigger -
|
|
14
|
+
* @part trigger - Active input or button that opens the option menu.
|
|
15
15
|
* @part menu - Floating option menu.
|
|
16
16
|
*/
|
|
17
17
|
export class QDropdown {
|
|
@@ -30,7 +30,11 @@ export class QDropdown {
|
|
|
30
30
|
/** Omitted inherits the enclosing form; false cancels reservation. */
|
|
31
31
|
reserveFeedback;
|
|
32
32
|
size = 'inherit';
|
|
33
|
+
/** Opt-in horizontal width; independent of size. Omitted uses the existing full-width layout. */
|
|
34
|
+
width;
|
|
33
35
|
searchable = false;
|
|
36
|
+
/** Search in the main editable control (default) or a separate menu field. Applies only when searchable. */
|
|
37
|
+
searchMode = 'default';
|
|
34
38
|
/** Delegates filtering and pagination to the consumer. */
|
|
35
39
|
externalSearch = false;
|
|
36
40
|
/** Indicates another externally loaded option page is available. */
|
|
@@ -78,6 +82,39 @@ export class QDropdown {
|
|
|
78
82
|
positionFrame = null;
|
|
79
83
|
floatingCleanup;
|
|
80
84
|
floatingResizeObserver;
|
|
85
|
+
draftEdited = false;
|
|
86
|
+
selectedLabelCache;
|
|
87
|
+
composing = false;
|
|
88
|
+
lastSearchValue;
|
|
89
|
+
get editableSearch() { return this.searchable && this.searchMode !== 'menu'; }
|
|
90
|
+
reconcileSelectedLabel() {
|
|
91
|
+
const selected = this.getSelectedOption();
|
|
92
|
+
if (selected)
|
|
93
|
+
this.selectedLabelCache = { value: this.value, label: this.getOptionLabel(selected) };
|
|
94
|
+
else if (!this.value || !this.externalSearch || this.selectedLabelCache?.value !== this.value)
|
|
95
|
+
this.selectedLabelCache = undefined;
|
|
96
|
+
}
|
|
97
|
+
closeMenu() {
|
|
98
|
+
this.isOpen = false;
|
|
99
|
+
this.focusedIndex = -1;
|
|
100
|
+
this.searchTerm = '';
|
|
101
|
+
this.lastSearchValue = undefined;
|
|
102
|
+
this.draftEdited = false;
|
|
103
|
+
this.composing = false;
|
|
104
|
+
this.visibleCount = 20;
|
|
105
|
+
this.clearScrollLoading();
|
|
106
|
+
if (this.triggerEl?.tagName === 'INPUT') {
|
|
107
|
+
const selected = this.getSelectedOption();
|
|
108
|
+
this.triggerEl.value = this.getOptionLabel(selected) || (this.externalSearch && this.selectedLabelCache?.value === this.value ? this.selectedLabelCache.label : '');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
watchSearchMode() {
|
|
112
|
+
const hadFocus = Boolean(this.el.shadowRoot?.activeElement);
|
|
113
|
+
this.closeMenu();
|
|
114
|
+
this.searchInputEl = undefined;
|
|
115
|
+
if (hadFocus)
|
|
116
|
+
requestAnimationFrame(() => focusWithoutScroll(this.triggerEl));
|
|
117
|
+
}
|
|
81
118
|
// ========================= [3] LIFECYCLE & WATCHERS ==========================
|
|
82
119
|
disconnectedCallback() {
|
|
83
120
|
this.clearScrollLoading();
|
|
@@ -109,6 +146,8 @@ export class QDropdown {
|
|
|
109
146
|
this.stopFloatingUpdates();
|
|
110
147
|
}
|
|
111
148
|
watchValue(newValue) {
|
|
149
|
+
this.reconcileSelectedLabel();
|
|
150
|
+
this.closeMenu();
|
|
112
151
|
if (this.internals && typeof this.internals.setFormValue === 'function') {
|
|
113
152
|
this.internals.setFormValue(newValue);
|
|
114
153
|
}
|
|
@@ -123,7 +162,7 @@ export class QDropdown {
|
|
|
123
162
|
if (this.searchInputEl)
|
|
124
163
|
this.searchInputEl.disabled = disabled;
|
|
125
164
|
if (disabled && this.isOpen) {
|
|
126
|
-
this.
|
|
165
|
+
this.closeMenu();
|
|
127
166
|
this.stopFloatingUpdates();
|
|
128
167
|
}
|
|
129
168
|
const selected = this.getFormSelection();
|
|
@@ -149,6 +188,8 @@ export class QDropdown {
|
|
|
149
188
|
this.triggerEl?.focus();
|
|
150
189
|
}
|
|
151
190
|
watchOptions() {
|
|
191
|
+
this.reconcileSelectedLabel();
|
|
192
|
+
this.focusedIndex = -1;
|
|
152
193
|
this.syncValidity();
|
|
153
194
|
if (this.externalSearch) {
|
|
154
195
|
this.isScrollingLoading = false;
|
|
@@ -160,6 +201,7 @@ export class QDropdown {
|
|
|
160
201
|
}
|
|
161
202
|
}
|
|
162
203
|
componentWillLoad() {
|
|
204
|
+
this.reconcileSelectedLabel();
|
|
163
205
|
this.initialValue = this.value || '';
|
|
164
206
|
if (this.internals && typeof this.internals.setFormValue === 'function') {
|
|
165
207
|
this.internals.setFormValue(this.value);
|
|
@@ -170,6 +212,7 @@ export class QDropdown {
|
|
|
170
212
|
this.syncValidity();
|
|
171
213
|
}
|
|
172
214
|
formResetCallback() {
|
|
215
|
+
this.closeMenu();
|
|
173
216
|
this.value = this.initialValue;
|
|
174
217
|
if (this.internals && typeof this.internals.setFormValue === 'function') {
|
|
175
218
|
this.internals.setFormValue(this.value);
|
|
@@ -221,7 +264,7 @@ export class QDropdown {
|
|
|
221
264
|
this.visibleCount = 20;
|
|
222
265
|
if (this.searchable) {
|
|
223
266
|
this.focusedIndex = -1;
|
|
224
|
-
requestAnimationFrame(() => focusWithoutScroll(this.searchInputEl));
|
|
267
|
+
requestAnimationFrame(() => focusWithoutScroll(this.editableSearch ? this.triggerEl : this.searchInputEl));
|
|
225
268
|
}
|
|
226
269
|
else {
|
|
227
270
|
const activeIdx = this.parsedOptions.findIndex(opt => opt.value === this.value);
|
|
@@ -230,9 +273,7 @@ export class QDropdown {
|
|
|
230
273
|
}
|
|
231
274
|
}
|
|
232
275
|
else {
|
|
233
|
-
this.
|
|
234
|
-
this.searchTerm = '';
|
|
235
|
-
this.visibleCount = 20;
|
|
276
|
+
this.closeMenu();
|
|
236
277
|
requestAnimationFrame(() => focusWithoutScroll(this.triggerEl));
|
|
237
278
|
}
|
|
238
279
|
};
|
|
@@ -240,10 +281,8 @@ export class QDropdown {
|
|
|
240
281
|
if (this.isDisabled)
|
|
241
282
|
return;
|
|
242
283
|
this.value = option.value;
|
|
243
|
-
this.
|
|
244
|
-
this.
|
|
245
|
-
this.searchTerm = '';
|
|
246
|
-
this.clearScrollLoading();
|
|
284
|
+
this.selectedLabelCache = { value: option.value, label: this.getOptionLabel(option) };
|
|
285
|
+
this.closeMenu();
|
|
247
286
|
this.qChange.emit(option.value);
|
|
248
287
|
this.qSelect.emit(option);
|
|
249
288
|
requestAnimationFrame(() => focusWithoutScroll(this.triggerEl));
|
|
@@ -254,6 +293,23 @@ export class QDropdown {
|
|
|
254
293
|
handleBlur = (ev) => {
|
|
255
294
|
this.qBlur.emit(ev);
|
|
256
295
|
};
|
|
296
|
+
handleFocusOut = (ev) => {
|
|
297
|
+
const next = ev.relatedTarget;
|
|
298
|
+
if (!next || (!this.el.contains(next) && !this.el.shadowRoot?.contains(next)))
|
|
299
|
+
this.closeMenu();
|
|
300
|
+
};
|
|
301
|
+
handleEditableClick = (ev) => {
|
|
302
|
+
if (this.isDisabled)
|
|
303
|
+
return;
|
|
304
|
+
this.qClick.emit(ev);
|
|
305
|
+
if (!this.isOpen)
|
|
306
|
+
this.toggleMenu();
|
|
307
|
+
};
|
|
308
|
+
handleCompositionStart = () => { this.composing = true; };
|
|
309
|
+
handleCompositionEnd = (ev) => {
|
|
310
|
+
this.composing = false;
|
|
311
|
+
this.handleSearchInput(ev);
|
|
312
|
+
};
|
|
257
313
|
handleTriggerClick = (ev) => {
|
|
258
314
|
if (this.isDisabled)
|
|
259
315
|
return;
|
|
@@ -264,11 +320,16 @@ export class QDropdown {
|
|
|
264
320
|
if (this.isDisabled)
|
|
265
321
|
return;
|
|
266
322
|
const target = ev.target;
|
|
323
|
+
if (this.composing || ev.isComposing)
|
|
324
|
+
return;
|
|
325
|
+
this.draftEdited = true;
|
|
267
326
|
this.searchTerm = target.value || '';
|
|
327
|
+
this.isOpen = true;
|
|
268
328
|
this.focusedIndex = -1;
|
|
269
329
|
this.visibleCount = 20;
|
|
270
330
|
this.clearScrollLoading();
|
|
271
|
-
if (this.externalSearch) {
|
|
331
|
+
if (this.externalSearch && this.searchTerm !== this.lastSearchValue) {
|
|
332
|
+
this.lastSearchValue = this.searchTerm;
|
|
272
333
|
this.qSearch.emit(this.searchTerm);
|
|
273
334
|
}
|
|
274
335
|
};
|
|
@@ -404,114 +465,70 @@ export class QDropdown {
|
|
|
404
465
|
menu.style.visibility = 'visible';
|
|
405
466
|
}
|
|
406
467
|
handleKeyDown = (ev) => {
|
|
407
|
-
if (this.isDisabled)
|
|
468
|
+
if (this.isDisabled || this.composing || ev.isComposing || ev.keyCode === 229)
|
|
408
469
|
return;
|
|
409
|
-
const
|
|
410
|
-
const isInput = target && target.tagName && target.tagName.toLowerCase() === 'input';
|
|
470
|
+
const isInput = ev.target?.tagName?.toLowerCase() === 'input';
|
|
411
471
|
const maxIndex = this.parsedOptions.length - 1;
|
|
412
472
|
switch (ev.key) {
|
|
413
473
|
case 'ArrowDown':
|
|
474
|
+
case 'ArrowUp': {
|
|
414
475
|
ev.preventDefault();
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
const activeIdx = this.parsedOptions.findIndex(opt => opt.value === this.value);
|
|
423
|
-
const nextIdx = activeIdx >= 0 ? activeIdx : 0;
|
|
424
|
-
this.updateFocusedIndex(nextIdx);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
if (isInput) {
|
|
429
|
-
if (maxIndex >= 0) {
|
|
430
|
-
this.updateFocusedIndex(0);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
else {
|
|
434
|
-
const nextIdx = Math.min(this.focusedIndex + 1, maxIndex);
|
|
435
|
-
this.updateFocusedIndex(nextIdx);
|
|
436
|
-
}
|
|
476
|
+
const opening = !this.isOpen;
|
|
477
|
+
this.isOpen = true;
|
|
478
|
+
if (opening && this.searchable && !this.editableSearch) {
|
|
479
|
+
this.focusedIndex = -1;
|
|
480
|
+
requestAnimationFrame(() => focusWithoutScroll(this.searchInputEl));
|
|
437
481
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (!this.isOpen) {
|
|
442
|
-
this.isOpen = true;
|
|
443
|
-
const activeIdx = this.parsedOptions.findIndex(opt => opt.value === this.value);
|
|
444
|
-
const nextIdx = activeIdx >= 0 ? activeIdx : maxIndex;
|
|
445
|
-
this.updateFocusedIndex(nextIdx);
|
|
482
|
+
else if (ev.key === 'ArrowDown') {
|
|
483
|
+
const selected = opening && !isInput ? this.parsedOptions.findIndex(option => option.value === this.value) : -1;
|
|
484
|
+
this.updateFocusedIndex(selected >= 0 ? selected : Math.min(this.focusedIndex + 1, maxIndex));
|
|
446
485
|
}
|
|
447
486
|
else {
|
|
448
|
-
|
|
449
|
-
this.focusedIndex = -1;
|
|
450
|
-
requestAnimationFrame(() => focusWithoutScroll(this.searchInputEl));
|
|
451
|
-
}
|
|
452
|
-
else if (this.focusedIndex > 0) {
|
|
453
|
-
const nextIdx = this.focusedIndex - 1;
|
|
454
|
-
this.updateFocusedIndex(nextIdx);
|
|
455
|
-
}
|
|
487
|
+
this.updateFocusedIndex(this.focusedIndex < 0 ? maxIndex : Math.max(-1, this.focusedIndex - 1));
|
|
456
488
|
}
|
|
457
489
|
break;
|
|
490
|
+
}
|
|
458
491
|
case 'Home':
|
|
459
|
-
if (this.isOpen && !isInput) {
|
|
460
|
-
ev.preventDefault();
|
|
461
|
-
this.updateFocusedIndex(0);
|
|
462
|
-
}
|
|
463
|
-
break;
|
|
464
492
|
case 'End':
|
|
465
493
|
if (this.isOpen && !isInput) {
|
|
466
494
|
ev.preventDefault();
|
|
467
|
-
this.updateFocusedIndex(maxIndex);
|
|
495
|
+
this.updateFocusedIndex(ev.key === 'Home' ? 0 : maxIndex);
|
|
468
496
|
}
|
|
469
497
|
break;
|
|
470
498
|
case 'Enter':
|
|
471
499
|
if (isInput) {
|
|
472
|
-
if (this.
|
|
500
|
+
if (this.isOpen) {
|
|
473
501
|
ev.preventDefault();
|
|
474
|
-
this.
|
|
502
|
+
if (this.focusedIndex >= 0 && this.focusedIndex <= maxIndex)
|
|
503
|
+
this.handleSelect(this.parsedOptions[this.focusedIndex]);
|
|
475
504
|
}
|
|
476
505
|
}
|
|
477
506
|
else {
|
|
478
507
|
ev.preventDefault();
|
|
479
|
-
if (this.isOpen && this.focusedIndex >= 0 && this.focusedIndex
|
|
508
|
+
if (this.isOpen && this.focusedIndex >= 0 && this.focusedIndex <= maxIndex)
|
|
480
509
|
this.handleSelect(this.parsedOptions[this.focusedIndex]);
|
|
481
|
-
|
|
482
|
-
else {
|
|
510
|
+
else
|
|
483
511
|
this.toggleMenu();
|
|
484
|
-
}
|
|
485
512
|
}
|
|
486
513
|
break;
|
|
487
514
|
case ' ':
|
|
488
515
|
if (!isInput) {
|
|
489
516
|
ev.preventDefault();
|
|
490
|
-
if (this.isOpen && this.focusedIndex >= 0 && this.focusedIndex
|
|
517
|
+
if (this.isOpen && this.focusedIndex >= 0 && this.focusedIndex <= maxIndex)
|
|
491
518
|
this.handleSelect(this.parsedOptions[this.focusedIndex]);
|
|
492
|
-
|
|
493
|
-
else {
|
|
519
|
+
else
|
|
494
520
|
this.toggleMenu();
|
|
495
|
-
}
|
|
496
521
|
}
|
|
497
522
|
break;
|
|
498
523
|
case 'Escape':
|
|
499
|
-
if (this.isOpen) {
|
|
524
|
+
if (this.isOpen || this.draftEdited) {
|
|
500
525
|
ev.preventDefault();
|
|
501
|
-
this.
|
|
502
|
-
this.focusedIndex = -1;
|
|
503
|
-
this.searchTerm = '';
|
|
504
|
-
this.clearScrollLoading();
|
|
526
|
+
this.closeMenu();
|
|
505
527
|
requestAnimationFrame(() => focusWithoutScroll(this.triggerEl));
|
|
506
528
|
}
|
|
507
529
|
break;
|
|
508
530
|
case 'Tab':
|
|
509
|
-
|
|
510
|
-
this.isOpen = false;
|
|
511
|
-
this.focusedIndex = -1;
|
|
512
|
-
this.searchTerm = '';
|
|
513
|
-
this.clearScrollLoading();
|
|
514
|
-
}
|
|
531
|
+
this.closeMenu();
|
|
515
532
|
break;
|
|
516
533
|
}
|
|
517
534
|
};
|
|
@@ -519,11 +536,7 @@ export class QDropdown {
|
|
|
519
536
|
handleClickOutside(ev) {
|
|
520
537
|
const path = ev.composedPath();
|
|
521
538
|
if (this.el && !path.includes(this.el)) {
|
|
522
|
-
this.
|
|
523
|
-
this.focusedIndex = -1;
|
|
524
|
-
this.searchTerm = '';
|
|
525
|
-
this.visibleCount = 20;
|
|
526
|
-
this.clearScrollLoading();
|
|
539
|
+
this.closeMenu();
|
|
527
540
|
}
|
|
528
541
|
}
|
|
529
542
|
// ===================== [6] RENDER (Visual Template Only) =====================
|
|
@@ -534,20 +547,20 @@ export class QDropdown {
|
|
|
534
547
|
warningContext: 'q-dropdown options',
|
|
535
548
|
});
|
|
536
549
|
const selectedOption = this.getSelectedOption(allOptions);
|
|
537
|
-
const selectedLabel = this.getOptionLabel(selectedOption);
|
|
538
|
-
const displayLabel =
|
|
539
|
-
const hasSelection = selectedOption !== undefined;
|
|
550
|
+
const selectedLabel = this.getOptionLabel(selectedOption) || (this.externalSearch && this.selectedLabelCache?.value === this.value ? this.selectedLabelCache.label : '');
|
|
551
|
+
const displayLabel = selectedLabel || this.placeholder;
|
|
552
|
+
const hasSelection = selectedOption !== undefined || Boolean(this.externalSearch && this.selectedLabelCache?.value === this.value);
|
|
540
553
|
const ariaLabel = this.ariaLabel?.trim() || undefined;
|
|
541
|
-
return (h("div", { key: '
|
|
554
|
+
return (h("div", { key: '2c3ac6a3001c9a68f0be6a16bd6305149c06784a', style: feedbackStyle(this.reserveFeedback), class: {
|
|
542
555
|
'dropdown-wrapper': true,
|
|
543
556
|
'is-open': this.isOpen,
|
|
544
557
|
'is-disabled': this.isDisabled,
|
|
545
558
|
[`size-${this.size}`]: true
|
|
546
|
-
}, onKeyDown: this.handleKeyDown }, this.label && (h("label", { key: '
|
|
559
|
+
}, onKeyDown: this.handleKeyDown, onFocusout: this.handleFocusOut }, this.label && (h("label", { key: '869b65fe2fb4f0fe67faa22849ec5f36148aaa9f', class: { 'dropdown-label': true, 'q-label-hidden': this.labelHidden }, htmlFor: "q-field", part: "label" }, this.label)), this.editableSearch ? h("div", { class: { 'editable-trigger': true, 'has-leading-icon': Boolean(this.el.querySelector('[slot="icon-left"]')) } }, h("span", { class: "editable-leading" }, h("slot", { name: "icon-left" })), h("input", { ref: el => (this.triggerEl = el), id: "q-field", class: "dropdown-trigger dropdown-main-input", part: "trigger", type: "text", role: "combobox", autocomplete: "off", disabled: this.isDisabled, value: this.composing ? this.triggerEl?.value ?? selectedLabel : this.draftEdited ? this.searchTerm : selectedLabel, placeholder: this.placeholder, onClick: this.handleEditableClick, onFocus: this.handleFocus, onBlur: this.handleBlur, onInput: this.handleSearchInput, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, "aria-autocomplete": "list", "aria-haspopup": "listbox", "aria-required": this.required ? 'true' : 'false', "aria-invalid": this.error || (this.required && !this.value) ? 'true' : 'false', "aria-describedby": this.error || this.description ? 'q-field-error' : undefined, "aria-label": ariaLabel, "aria-expanded": this.isOpen ? 'true' : 'false', "aria-controls": this.isOpen ? 'q-field-menu' : undefined, "aria-activedescendant": this.isOpen && this.focusedIndex >= 0 ? `q-field-item-${this.focusedIndex}` : undefined }), h("svg", { class: "chevron-icon", "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("polyline", { points: "6 9 12 15 18 9" }))) : h("button", { ref: (el) => (this.triggerEl = el), id: "q-field", class: "dropdown-trigger", part: "trigger", type: "button", disabled: this.isDisabled, onClick: this.handleTriggerClick, onFocus: this.handleFocus, onBlur: this.handleBlur, "aria-haspopup": "listbox", "aria-required": this.required ? 'true' : 'false', "aria-invalid": this.error || (this.required && !this.value) ? 'true' : 'false', "aria-describedby": this.error || this.description ? 'q-field-error' : undefined, "aria-label": ariaLabel, "aria-expanded": this.isOpen ? 'true' : 'false', "aria-controls": this.isOpen ? 'q-field-menu' : undefined, "aria-activedescendant": this.isOpen && this.focusedIndex >= 0 ? `q-field-item-${this.focusedIndex}` : undefined }, h("span", { class: "trigger-content" }, h("slot", { name: "icon-left" }), h("span", { class: { 'trigger-text': true, 'is-placeholder': !hasSelection } }, displayLabel)), h("svg", { class: "chevron-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("polyline", { points: "6 9 12 15 18 9" }))), fieldFeedback('q-field-error', this.error, this.description), this.isOpen && (h("div", { key: '1660f2411c485d2988f5a510ae5faa496f574e08', ref: (el) => (this.menuEl = el), id: "q-field-menu", class: "dropdown-menu", part: "menu", role: "listbox", popover: "manual", "aria-label": ariaLabel || this.label || 'Options' }, this.searchable && !this.editableSearch && (h("div", { key: '2f1cadc1aaa76b3403a16d5d620e1f2f02a5de19', class: "dropdown-search-container" }, h("input", { key: '324fa2f19e4aa2f35ecb613096f70c48eb1dbc46', ref: (el) => (this.searchInputEl = el), type: "text", class: "dropdown-search-input", placeholder: "Search...", value: this.searchTerm, onInput: this.handleSearchInput, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, "aria-label": ariaLabel || this.label || 'Search options', role: "combobox", "aria-autocomplete": "list", "aria-controls": "q-field-menu", "aria-expanded": this.isOpen ? 'true' : 'false', "aria-activedescendant": this.focusedIndex >= 0 ? `q-field-item-${this.focusedIndex}` : undefined }))), h("ul", { key: '1e5d5700839986475ccd46a86814ace71b8e4985', ref: (el) => (this.itemsListEl = el), class: "dropdown-items-list", onScroll: this.handleScroll }, opts.length === 0 && !this.loading ? (h("li", { class: "menu-item is-empty" }, "No matches found")) : (identifiedOptions.map(({ item: option, index, key }) => (h("li", { key: key, id: `q-field-item-${index}`, class: {
|
|
547
560
|
'menu-item': true,
|
|
548
561
|
'is-selected': option.value === this.value,
|
|
549
562
|
'is-focused': index === this.focusedIndex
|
|
550
|
-
}, tabindex: -1, part: `item ${option.value === this.value ? 'selected-item' : ''} ${index === this.focusedIndex ? 'focused-item' : ''}`, role: "option", "aria-selected": option.value === this.value ? 'true' : 'false', onClick: () => this.handleSelect(option) }, this.getOptionLabel(option))))), (this.loading || this.isScrollingLoading) && (h("li", { key: '
|
|
563
|
+
}, tabindex: -1, part: `item ${option.value === this.value ? 'selected-item' : ''} ${index === this.focusedIndex ? 'focused-item' : ''}`, role: "option", "aria-selected": option.value === this.value ? 'true' : 'false', onClick: () => this.handleSelect(option), onMouseDown: ev => ev.preventDefault() }, this.getOptionLabel(option))))), (this.loading || this.isScrollingLoading) && (h("li", { key: 'ac29617e51c86039b86be6ab3ebecb0c14a6e093', class: "menu-item is-loading-more" }, h("span", { key: 'ac9161bb78203625474898a32071ba58a638f12d', class: "spinner-circle" }), h("span", { key: '0e70057d70098ed830eedaa3eb22b4d90ef88924' }, "Loading..."))))))));
|
|
551
564
|
}
|
|
552
565
|
static get is() { return "q-dropdown"; }
|
|
553
566
|
static get encapsulation() { return "shadow"; }
|
|
@@ -756,6 +769,32 @@ export class QDropdown {
|
|
|
756
769
|
"attribute": "size",
|
|
757
770
|
"defaultValue": "'inherit'"
|
|
758
771
|
},
|
|
772
|
+
"width": {
|
|
773
|
+
"type": "string",
|
|
774
|
+
"mutable": false,
|
|
775
|
+
"complexType": {
|
|
776
|
+
"original": "QInputWidth",
|
|
777
|
+
"resolved": "\"full\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\"",
|
|
778
|
+
"references": {
|
|
779
|
+
"QInputWidth": {
|
|
780
|
+
"location": "import",
|
|
781
|
+
"path": "../../../theme/tokens",
|
|
782
|
+
"id": "../../../src/browser/theme/tokens.ts::QInputWidth",
|
|
783
|
+
"referenceLocation": "QInputWidth"
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
"required": false,
|
|
788
|
+
"optional": true,
|
|
789
|
+
"docs": {
|
|
790
|
+
"tags": [],
|
|
791
|
+
"text": "Opt-in horizontal width; independent of size. Omitted uses the existing full-width layout."
|
|
792
|
+
},
|
|
793
|
+
"getter": false,
|
|
794
|
+
"setter": false,
|
|
795
|
+
"reflect": true,
|
|
796
|
+
"attribute": "width"
|
|
797
|
+
},
|
|
759
798
|
"searchable": {
|
|
760
799
|
"type": "boolean",
|
|
761
800
|
"mutable": false,
|
|
@@ -776,6 +815,26 @@ export class QDropdown {
|
|
|
776
815
|
"attribute": "searchable",
|
|
777
816
|
"defaultValue": "false"
|
|
778
817
|
},
|
|
818
|
+
"searchMode": {
|
|
819
|
+
"type": "string",
|
|
820
|
+
"mutable": false,
|
|
821
|
+
"complexType": {
|
|
822
|
+
"original": "'default' | 'menu'",
|
|
823
|
+
"resolved": "\"default\" | \"menu\"",
|
|
824
|
+
"references": {}
|
|
825
|
+
},
|
|
826
|
+
"required": false,
|
|
827
|
+
"optional": false,
|
|
828
|
+
"docs": {
|
|
829
|
+
"tags": [],
|
|
830
|
+
"text": "Search in the main editable control (default) or a separate menu field. Applies only when searchable."
|
|
831
|
+
},
|
|
832
|
+
"getter": false,
|
|
833
|
+
"setter": false,
|
|
834
|
+
"reflect": false,
|
|
835
|
+
"attribute": "search-mode",
|
|
836
|
+
"defaultValue": "'default'"
|
|
837
|
+
},
|
|
779
838
|
"externalSearch": {
|
|
780
839
|
"type": "boolean",
|
|
781
840
|
"mutable": false,
|
|
@@ -970,7 +1029,9 @@ export class QDropdown {
|
|
|
970
1029
|
"searchTerm": {},
|
|
971
1030
|
"visibleCount": {},
|
|
972
1031
|
"isScrollingLoading": {},
|
|
973
|
-
"disabledState": {}
|
|
1032
|
+
"disabledState": {},
|
|
1033
|
+
"draftEdited": {},
|
|
1034
|
+
"selectedLabelCache": {}
|
|
974
1035
|
};
|
|
975
1036
|
}
|
|
976
1037
|
static get events() {
|
|
@@ -1161,6 +1222,12 @@ export class QDropdown {
|
|
|
1161
1222
|
static get elementRef() { return "el"; }
|
|
1162
1223
|
static get watchers() {
|
|
1163
1224
|
return [{
|
|
1225
|
+
"propName": "searchMode",
|
|
1226
|
+
"methodName": "watchSearchMode"
|
|
1227
|
+
}, {
|
|
1228
|
+
"propName": "searchable",
|
|
1229
|
+
"methodName": "watchSearchMode"
|
|
1230
|
+
}, {
|
|
1164
1231
|
"propName": "value",
|
|
1165
1232
|
"methodName": "watchValue"
|
|
1166
1233
|
}, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it } from "vitest";
|
|
2
2
|
import "../dropdown";
|
|
3
|
+
import dropdownCss from "../dropdown.css?inline";
|
|
3
4
|
async function nextFrame() {
|
|
4
5
|
await new Promise(resolve => requestAnimationFrame(() => resolve()));
|
|
5
6
|
}
|
|
@@ -10,12 +11,39 @@ async function createDropdown(options) {
|
|
|
10
11
|
document.body.append(element);
|
|
11
12
|
await customElements.whenDefined('q-dropdown');
|
|
12
13
|
await nextFrame();
|
|
14
|
+
const style = document.createElement('style');
|
|
15
|
+
style.textContent = dropdownCss;
|
|
16
|
+
element.shadowRoot.append(style);
|
|
13
17
|
return element;
|
|
14
18
|
}
|
|
15
19
|
describe('q-dropdown floating menu in Chromium', () => {
|
|
16
20
|
afterEach(() => {
|
|
17
21
|
document.body.replaceChildren();
|
|
18
22
|
});
|
|
23
|
+
it.each(['sm', 'md', 'lg', 'inherit'])('keeps search spacing even at size %s', async (size) => {
|
|
24
|
+
const element = await createDropdown([{ label: 'Option', value: 'option' }]);
|
|
25
|
+
element.size = size;
|
|
26
|
+
element.searchable = true;
|
|
27
|
+
element.searchMode = 'menu';
|
|
28
|
+
await nextFrame();
|
|
29
|
+
element.shadowRoot?.querySelector('.dropdown-trigger')?.click();
|
|
30
|
+
await nextFrame();
|
|
31
|
+
await nextFrame();
|
|
32
|
+
const menu = element.shadowRoot.querySelector('.dropdown-menu');
|
|
33
|
+
const container = element.shadowRoot.querySelector('.dropdown-search-container');
|
|
34
|
+
const input = element.shadowRoot.querySelector('.dropdown-search-input');
|
|
35
|
+
const menuBounds = menu.getBoundingClientRect();
|
|
36
|
+
const inputBounds = input.getBoundingClientRect();
|
|
37
|
+
const menuStyle = getComputedStyle(menu);
|
|
38
|
+
const topGap = inputBounds.top - menuBounds.top - parseFloat(menuStyle.borderTopWidth);
|
|
39
|
+
const leftGap = inputBounds.left - menuBounds.left - parseFloat(menuStyle.borderLeftWidth);
|
|
40
|
+
const rightGap = menuBounds.right - inputBounds.right - parseFloat(menuStyle.borderRightWidth);
|
|
41
|
+
const bottomGap = container.getBoundingClientRect().bottom - inputBounds.bottom
|
|
42
|
+
- parseFloat(getComputedStyle(container).borderBottomWidth);
|
|
43
|
+
expect(topGap).toBeCloseTo(leftGap, 0);
|
|
44
|
+
expect(topGap).toBeCloseTo(rightGap, 0);
|
|
45
|
+
expect(topGap).toBeCloseTo(bottomGap, 0);
|
|
46
|
+
});
|
|
19
47
|
it('keeps focus and scroll position on the trigger while opening', async () => {
|
|
20
48
|
const scroller = document.createElement('div');
|
|
21
49
|
scroller.style.cssText = 'position:fixed;left:20px;top:20px;width:280px;height:140px;overflow:auto;';
|