@webquark/browser 1.1.0-dev.12 → 1.1.0-dev.13
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-DmLaQuU2.js → action.props-B6vl_1p5.js} +1 -1
- package/dist/cjs/{field-CEZ9NsWK.js → field-B5nxD8Kc.js} +1 -1
- package/dist/cjs/{index-CMAcJ6t1.js → index-BD6Jjssb.js} +4 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/q-accordion.cjs.entry.js +2 -2
- package/dist/cjs/q-alert.cjs.entry.js +1 -1
- package/dist/cjs/q-avatar.cjs.entry.js +1 -1
- package/dist/cjs/q-banner.cjs.entry.js +1 -1
- package/dist/cjs/q-button_2.cjs.entry.js +3 -3
- package/dist/cjs/q-card.cjs.entry.js +1 -1
- package/dist/cjs/q-carousel.cjs.entry.js +119 -17
- package/dist/cjs/q-chip.cjs.entry.js +2 -2
- package/dist/cjs/q-control-group.cjs.entry.js +64 -0
- package/dist/cjs/q-conversation-bubble.cjs.entry.js +1 -1
- package/dist/cjs/q-data-table.cjs.entry.js +4 -4
- package/dist/cjs/q-dialog.cjs.entry.js +1 -1
- package/dist/cjs/q-divider.cjs.entry.js +1 -1
- package/dist/cjs/q-dropdown.cjs.entry.js +218 -21
- package/dist/cjs/q-form.cjs.entry.js +14 -4
- package/dist/cjs/q-grid.cjs.entry.js +1 -1
- package/dist/cjs/q-icon.cjs.entry.js +1 -1
- package/dist/cjs/q-image-comparison.cjs.entry.js +1 -1
- package/dist/cjs/q-inline.cjs.entry.js +1 -1
- package/dist/cjs/q-input_2.cjs.entry.js +6 -6
- package/dist/cjs/q-link.cjs.entry.js +2 -2
- package/dist/cjs/q-map.cjs.entry.js +2 -2
- package/dist/cjs/q-media.cjs.entry.js +1 -1
- package/dist/cjs/q-navbar.cjs.entry.js +1 -1
- package/dist/cjs/q-pagination.cjs.entry.js +2 -2
- package/dist/cjs/q-panel.cjs.entry.js +1 -1
- package/dist/cjs/q-quantity-selector.cjs.entry.js +6 -6
- package/dist/cjs/q-radio-group.cjs.entry.js +4 -4
- package/dist/cjs/q-reel.cjs.entry.js +1 -1
- package/dist/cjs/q-scrollable.cjs.entry.js +1 -1
- package/dist/cjs/q-section.cjs.entry.js +1 -1
- package/dist/cjs/q-sidepanel.cjs.entry.js +1 -1
- package/dist/cjs/q-slider.cjs.entry.js +2 -2
- package/dist/cjs/q-stack.cjs.entry.js +1 -1
- package/dist/cjs/q-step-diagram-item.cjs.entry.js +2 -2
- package/dist/cjs/q-step-diagram.cjs.entry.js +3 -3
- package/dist/cjs/q-syntax-box.cjs.entry.js +1 -1
- package/dist/cjs/q-tabs.cjs.entry.js +1 -1
- package/dist/cjs/q-textarea.cjs.entry.js +4 -4
- package/dist/cjs/q-thumbnail.cjs.entry.js +1 -1
- 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 +1 -1
- package/dist/cjs/webquark.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/actions/button/button.css +22 -0
- package/dist/collection/components/content/carousel/carousel.css +7 -0
- package/dist/collection/components/content/carousel/carousel.js +256 -10
- package/dist/collection/components/content/carousel/internals/autoplay.js +31 -6
- package/dist/collection/components/content/carousel/test/transitions.cmp.test.js +122 -0
- package/dist/collection/components/data-display/accordion/accordion.js +1 -1
- package/dist/collection/components/data-display/data-table/data-table.js +3 -3
- package/dist/collection/components/data-display/map/map.js +1 -1
- package/dist/collection/components/data-display/map/test/map.cmp.test.js +1 -1
- package/dist/collection/components/data-display/pagination/pagination.js +1 -1
- package/dist/collection/components/indicators/step-diagram/step-diagram.js +2 -2
- package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.js +1 -1
- package/dist/collection/components/inputs/dropdown/dropdown.css +115 -0
- package/dist/collection/components/inputs/dropdown/dropdown.js +274 -23
- package/dist/collection/components/inputs/dropdown/test/fit-options.cmp.test.js +120 -0
- package/dist/collection/components/inputs/dropdown/test/multiple.cmp.test.js +124 -0
- package/dist/collection/components/inputs/form/form.js +2 -2
- package/dist/collection/components/inputs/form/internals/field-state.js +6 -1
- package/dist/collection/components/inputs/form/internals/values.js +5 -0
- package/dist/collection/components/inputs/input/input.css +22 -0
- package/dist/collection/components/inputs/input/input.js +3 -3
- package/dist/collection/components/inputs/quantity-selector/quantity-selector.css +22 -0
- 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/slider/slider.js +1 -1
- package/dist/collection/components/inputs/textarea/textarea.js +2 -2
- package/dist/collection/components/inputs/toggle/toggle.css +22 -0
- package/dist/collection/components/inputs/toggle/toggle.js +3 -3
- package/dist/collection/components/layout/control-group/control-group.css +108 -0
- package/dist/collection/components/layout/control-group/control-group.js +142 -0
- package/dist/collection/components/layout/control-group/test/control-group.cmp.test.js +163 -0
- package/dist/components/index.js +1 -1
- package/dist/components/{p-4mHh96ug.js → p-BGHNFaaC.js} +1 -1
- package/dist/components/{p-BbY1XC6_.js → p-BZXIeEKC.js} +1 -1
- package/dist/components/{p-DbI_F3z0.js → p-Bc2_QcLn.js} +1 -1
- package/dist/components/{p-BKly3Y6e.js → p-Bp6Xr92S.js} +1 -1
- package/dist/components/{p-CSucjZb7.js → p-BwPMm43W.js} +1 -1
- package/dist/components/p-CpkX9YAW.js +1 -0
- package/dist/components/{p-CLErjC1f.js → p-D2nxHd1b.js} +1 -1
- package/dist/components/{p-DQhiqYeq.js → p-DkanItP3.js} +1 -1
- package/dist/components/p-IwIJb0Mc.js +1 -0
- package/dist/components/{p-0feRVg70.js → p-kfrqZyfJ.js} +1 -1
- package/dist/components/{p-CYG3Oakz.js → p-x3C-wjU9.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-control-group.d.ts +11 -0
- package/dist/components/q-control-group.js +1 -0
- 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.js +1 -1
- 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-slider.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-DhnvhbLl.js → action.props-Di_LpF5H.js} +1 -1
- package/dist/esm/{field-u-k7C7Rf.js → field-C4Iilew6.js} +1 -1
- package/dist/esm/{index-DaJmsCb7.js → index-DoGM9gsC.js} +4 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/q-accordion.entry.js +2 -2
- package/dist/esm/q-alert.entry.js +1 -1
- package/dist/esm/q-avatar.entry.js +1 -1
- package/dist/esm/q-banner.entry.js +1 -1
- package/dist/esm/q-button_2.entry.js +3 -3
- package/dist/esm/q-card.entry.js +1 -1
- package/dist/esm/q-carousel.entry.js +119 -17
- package/dist/esm/q-chip.entry.js +2 -2
- package/dist/esm/q-control-group.entry.js +62 -0
- package/dist/esm/q-conversation-bubble.entry.js +1 -1
- package/dist/esm/q-data-table.entry.js +4 -4
- package/dist/esm/q-dialog.entry.js +1 -1
- package/dist/esm/q-divider.entry.js +1 -1
- package/dist/esm/q-dropdown.entry.js +218 -21
- package/dist/esm/q-form.entry.js +14 -4
- package/dist/esm/q-grid.entry.js +1 -1
- package/dist/esm/q-icon.entry.js +1 -1
- package/dist/esm/q-image-comparison.entry.js +1 -1
- package/dist/esm/q-inline.entry.js +1 -1
- package/dist/esm/q-input_2.entry.js +6 -6
- package/dist/esm/q-link.entry.js +2 -2
- package/dist/esm/q-map.entry.js +2 -2
- package/dist/esm/q-media.entry.js +1 -1
- package/dist/esm/q-navbar.entry.js +1 -1
- package/dist/esm/q-pagination.entry.js +2 -2
- package/dist/esm/q-panel.entry.js +1 -1
- package/dist/esm/q-quantity-selector.entry.js +6 -6
- package/dist/esm/q-radio-group.entry.js +4 -4
- package/dist/esm/q-reel.entry.js +1 -1
- package/dist/esm/q-scrollable.entry.js +1 -1
- package/dist/esm/q-section.entry.js +1 -1
- package/dist/esm/q-sidepanel.entry.js +1 -1
- package/dist/esm/q-slider.entry.js +2 -2
- package/dist/esm/q-stack.entry.js +1 -1
- package/dist/esm/q-step-diagram-item.entry.js +2 -2
- package/dist/esm/q-step-diagram.entry.js +3 -3
- package/dist/esm/q-syntax-box.entry.js +1 -1
- package/dist/esm/q-tabs.entry.js +1 -1
- package/dist/esm/q-textarea.entry.js +4 -4
- package/dist/esm/q-thumbnail.entry.js +1 -1
- 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 +1 -1
- package/dist/esm/webquark.js +3 -3
- package/dist/types/components/content/carousel/carousel.d.ts +23 -2
- package/dist/types/components/content/carousel/carousel.types.d.ts +6 -0
- package/dist/types/components/content/carousel/internals/autoplay.d.ts +5 -0
- package/dist/types/components/inputs/dropdown/dropdown.d.ts +29 -2
- package/dist/types/components/inputs/dropdown/test/fit-options.cmp.test.d.ts +3 -0
- package/dist/types/components/inputs/dropdown/test/multiple.cmp.test.d.ts +1 -0
- package/dist/types/components/inputs/form/internals/field-state.d.ts +1 -1
- package/dist/types/components/layout/control-group/control-group.d.ts +20 -0
- package/dist/types/components/layout/control-group/test/control-group.cmp.test.d.ts +7 -0
- package/dist/types/components.d.ts +148 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/form-field-adapter.d.ts +3 -3
- package/dist/webquark/{p-b8f4994a.entry.js → p-0182e114.entry.js} +1 -1
- package/dist/webquark/{p-2c195546.entry.js → p-048103e0.entry.js} +1 -1
- package/dist/webquark/{p-3430b43c.entry.js → p-0a2c52de.entry.js} +1 -1
- package/dist/webquark/{p-b577b258.entry.js → p-0baf478a.entry.js} +1 -1
- package/dist/webquark/{p-5d6fb0d1.entry.js → p-15bad9ef.entry.js} +1 -1
- package/dist/webquark/{p-253add6d.entry.js → p-17b9713f.entry.js} +1 -1
- package/dist/webquark/{p-253fb28b.entry.js → p-222405b8.entry.js} +1 -1
- package/dist/webquark/{p-7a47e0c3.entry.js → p-2eaa3a9f.entry.js} +1 -1
- package/dist/webquark/{p-e7384b6e.entry.js → p-3daafc56.entry.js} +1 -1
- package/dist/webquark/{p-45e0d213.entry.js → p-44bbe12f.entry.js} +1 -1
- package/dist/webquark/{p-dee50f0a.entry.js → p-4609c362.entry.js} +1 -1
- package/dist/webquark/{p-aca37b06.entry.js → p-5b584d3c.entry.js} +1 -1
- package/dist/webquark/p-65fe9cac.entry.js +1 -0
- package/dist/webquark/{p-e930a769.entry.js → p-846dc838.entry.js} +1 -1
- package/dist/webquark/{p-d2c4696f.entry.js → p-84b350a3.entry.js} +1 -1
- package/dist/webquark/p-85131314.entry.js +1 -0
- package/dist/webquark/{p-58aaa98b.entry.js → p-852e88ae.entry.js} +1 -1
- package/dist/webquark/{p-596737cc.entry.js → p-86c05afd.entry.js} +1 -1
- package/dist/webquark/p-8c5b2706.entry.js +1 -0
- package/dist/webquark/p-923527f0.entry.js +1 -0
- package/dist/webquark/{p-33234157.entry.js → p-9a76cd71.entry.js} +1 -1
- package/dist/webquark/{p-BuctNczf.js → p-DDUED8LT.js} +1 -1
- package/dist/webquark/{p-Bk4FnOfb.js → p-Dnz3WmdX.js} +1 -1
- package/dist/webquark/{p-DaJmsCb7.js → p-DoGM9gsC.js} +1 -1
- package/dist/webquark/p-a0d97367.entry.js +1 -0
- package/dist/webquark/{p-3af50215.entry.js → p-a16bd8d5.entry.js} +2 -2
- package/dist/webquark/{p-fa15a69b.entry.js → p-a2334abe.entry.js} +1 -1
- package/dist/webquark/{p-5cccb6bc.entry.js → p-a2ff1b64.entry.js} +1 -1
- package/dist/webquark/{p-a199de7d.entry.js → p-a314bc21.entry.js} +1 -1
- package/dist/webquark/{p-848e040a.entry.js → p-a3e1096d.entry.js} +1 -1
- package/dist/webquark/{p-3726655f.entry.js → p-a66550da.entry.js} +1 -1
- package/dist/webquark/{p-b75ec829.entry.js → p-aa342e81.entry.js} +1 -1
- package/dist/webquark/{p-b702f60a.entry.js → p-b1c771fb.entry.js} +1 -1
- package/dist/webquark/p-b21ad707.entry.js +1 -0
- package/dist/webquark/{p-99ed0b0d.entry.js → p-b45ca926.entry.js} +1 -1
- package/dist/webquark/{p-29897ae6.entry.js → p-b8fdef4f.entry.js} +1 -1
- package/dist/webquark/{p-78c56cd3.entry.js → p-d4788321.entry.js} +1 -1
- package/dist/webquark/{p-01a59ac3.entry.js → p-d86bd51d.entry.js} +1 -1
- package/dist/webquark/{p-b82aaf4c.entry.js → p-dbcf7592.entry.js} +1 -1
- package/dist/webquark/p-e0943d41.entry.js +1 -0
- package/dist/webquark/{p-dcea3702.entry.js → p-e2721e77.entry.js} +1 -1
- package/dist/webquark/{p-ddeb2d4c.entry.js → p-e723a7ae.entry.js} +1 -1
- package/dist/webquark/{p-c2edfa2c.entry.js → p-eb800d1e.entry.js} +1 -1
- package/dist/webquark/{p-fbd1cbbe.entry.js → p-f4d23ffe.entry.js} +1 -1
- package/dist/webquark/{p-156d2fcf.entry.js → p-f51e1098.entry.js} +1 -1
- package/dist/webquark/{p-44eda084.entry.js → p-fe14f038.entry.js} +1 -1
- package/dist/webquark/webquark.esm.js +1 -1
- package/package.json +2 -2
- package/dist/components/p-cSh-5xis.js +0 -1
- package/dist/webquark/p-2e26f158.entry.js +0 -1
- package/dist/webquark/p-473a1810.entry.js +0 -1
- package/dist/webquark/p-881ecd5b.entry.js +0 -1
- package/dist/webquark/p-8a0733a1.entry.js +0 -1
- package/dist/webquark/p-f20ed85a.entry.js +0 -1
- package/dist/webquark/p-f95aeb8d.entry.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFieldDisabled, syncFieldHost } from "../../../utils/form-field-state";
|
|
2
2
|
import { registerFormField } from "../../../utils/form-field-adapter";
|
|
3
3
|
import { fieldFeedback, feedbackStyle } from "../../shared/field";
|
|
4
|
-
import { h } from "@stencil/core";
|
|
4
|
+
import { Fragment, h } from "@stencil/core";
|
|
5
5
|
import { identifyItems } from "../../../utils/collection-identity";
|
|
6
6
|
import { getDropdownOptions, getFilteredOptions, getOptionLabel, getSelectedOption, getVisibleOptions } from "./internals/options";
|
|
7
7
|
import { computeDropdownPosition } from "./internals/position";
|
|
@@ -25,12 +25,16 @@ export class QDropdown {
|
|
|
25
25
|
/** Options to render; strings use the same text for label and value, while objects allow separate values. */
|
|
26
26
|
options = [];
|
|
27
27
|
value = '';
|
|
28
|
+
/** Select several options. Uses values/qValuesChange instead of value/qChange. */
|
|
29
|
+
multiple = false;
|
|
30
|
+
/** Selected identities in multiple mode. Replace the array to update selections. */
|
|
31
|
+
values = [];
|
|
28
32
|
/** Keep the label accessible without displaying it. */
|
|
29
33
|
labelHidden = false;
|
|
30
34
|
/** Omitted inherits the enclosing form; false cancels reservation. */
|
|
31
35
|
reserveFeedback;
|
|
32
36
|
size = 'inherit';
|
|
33
|
-
/** Opt-in horizontal width;
|
|
37
|
+
/** Opt-in horizontal width; fit-options sizes to loaded option labels. Omitted keeps the full-width layout. */
|
|
34
38
|
width;
|
|
35
39
|
searchable = false;
|
|
36
40
|
/** Search in the main editable control (default) or a separate menu field. Applies only when searchable. */
|
|
@@ -58,6 +62,8 @@ export class QDropdown {
|
|
|
58
62
|
internals;
|
|
59
63
|
/** Emitted with the selected option value when selection changes. */
|
|
60
64
|
qChange;
|
|
65
|
+
/** Complete selected identities after an add or removal in multiple mode. */
|
|
66
|
+
qValuesChange;
|
|
61
67
|
/** Emitted with the selected option object when selection changes. */
|
|
62
68
|
qSelect;
|
|
63
69
|
/** Emitted with the current search term when a searchable dropdown uses external search. */
|
|
@@ -82,11 +88,23 @@ export class QDropdown {
|
|
|
82
88
|
positionFrame = null;
|
|
83
89
|
floatingCleanup;
|
|
84
90
|
floatingResizeObserver;
|
|
91
|
+
fitOptionsMeasure;
|
|
92
|
+
fitOptionsObserver;
|
|
85
93
|
draftEdited = false;
|
|
86
94
|
selectedLabelCache;
|
|
87
95
|
composing = false;
|
|
88
96
|
lastSearchValue;
|
|
89
|
-
|
|
97
|
+
initialValues = [];
|
|
98
|
+
multipleLabels = new Map();
|
|
99
|
+
multipleFrame;
|
|
100
|
+
chipMeasure;
|
|
101
|
+
multipleObserver;
|
|
102
|
+
visibleChips = 0;
|
|
103
|
+
selectedPanel = false;
|
|
104
|
+
get editableSearch() { return this.multiple || this.searchable && this.searchMode !== 'menu'; }
|
|
105
|
+
get selectedValues() {
|
|
106
|
+
return Array.isArray(this.values) ? [...new Set(this.values.filter(value => typeof value === 'string'))] : [];
|
|
107
|
+
}
|
|
90
108
|
reconcileSelectedLabel() {
|
|
91
109
|
const selected = this.getSelectedOption();
|
|
92
110
|
if (selected)
|
|
@@ -96,6 +114,7 @@ export class QDropdown {
|
|
|
96
114
|
}
|
|
97
115
|
closeMenu() {
|
|
98
116
|
this.isOpen = false;
|
|
117
|
+
this.selectedPanel = false;
|
|
99
118
|
this.focusedIndex = -1;
|
|
100
119
|
this.searchTerm = '';
|
|
101
120
|
this.lastSearchValue = undefined;
|
|
@@ -105,7 +124,7 @@ export class QDropdown {
|
|
|
105
124
|
this.clearScrollLoading();
|
|
106
125
|
if (this.triggerEl?.tagName === 'INPUT') {
|
|
107
126
|
const selected = this.getSelectedOption();
|
|
108
|
-
this.triggerEl.value = this.getOptionLabel(selected) || (this.externalSearch && this.selectedLabelCache?.value === this.value ? this.selectedLabelCache.label : '');
|
|
127
|
+
this.triggerEl.value = this.multiple ? '' : this.getOptionLabel(selected) || (this.externalSearch && this.selectedLabelCache?.value === this.value ? this.selectedLabelCache.label : '');
|
|
109
128
|
}
|
|
110
129
|
}
|
|
111
130
|
watchSearchMode() {
|
|
@@ -116,20 +135,31 @@ export class QDropdown {
|
|
|
116
135
|
requestAnimationFrame(() => focusWithoutScroll(this.triggerEl));
|
|
117
136
|
}
|
|
118
137
|
// ========================= [3] LIFECYCLE & WATCHERS ==========================
|
|
138
|
+
connectedCallback() {
|
|
139
|
+
this.observeFitOptions();
|
|
140
|
+
}
|
|
119
141
|
disconnectedCallback() {
|
|
120
142
|
this.clearScrollLoading();
|
|
121
143
|
this.stopFloatingUpdates();
|
|
144
|
+
this.fitOptionsObserver?.disconnect();
|
|
145
|
+
this.multipleObserver?.disconnect();
|
|
122
146
|
}
|
|
123
147
|
formDisabledCallback() {
|
|
124
148
|
this.syncValidity();
|
|
125
149
|
}
|
|
126
150
|
componentDidLoad() {
|
|
151
|
+
const dropdown = this;
|
|
127
152
|
registerFormField(this.el, {
|
|
128
|
-
kind: 'selection',
|
|
153
|
+
get kind() { return dropdown.multiple ? 'multiselect' : 'selection'; },
|
|
129
154
|
owner: () => this.internals?.form ?? null,
|
|
130
155
|
active: () => true,
|
|
131
|
-
value: () => this.getFormSelection(),
|
|
132
|
-
assign: value => {
|
|
156
|
+
value: () => this.multiple ? this.getMultipleFormSelection() : this.getFormSelection(),
|
|
157
|
+
assign: value => {
|
|
158
|
+
if (this.multiple)
|
|
159
|
+
this.values = Array.isArray(value) ? [...value] : [];
|
|
160
|
+
else
|
|
161
|
+
this.value = value;
|
|
162
|
+
},
|
|
133
163
|
reconcile: () => {
|
|
134
164
|
this.syncValidity();
|
|
135
165
|
},
|
|
@@ -139,13 +169,50 @@ export class QDropdown {
|
|
|
139
169
|
}
|
|
140
170
|
componentDidRender() {
|
|
141
171
|
this.syncValidity();
|
|
172
|
+
this.observeFitOptions();
|
|
173
|
+
this.observeMultipleLayout();
|
|
142
174
|
if (this.isOpen) {
|
|
143
175
|
this.openFloatingMenu();
|
|
144
176
|
return;
|
|
145
177
|
}
|
|
146
178
|
this.stopFloatingUpdates();
|
|
147
179
|
}
|
|
180
|
+
observeFitOptions = () => {
|
|
181
|
+
this.fitOptionsObserver?.disconnect();
|
|
182
|
+
if (this.width !== 'fit-options' || !this.fitOptionsMeasure) {
|
|
183
|
+
this.el.style.removeProperty('--_q-dropdown-options-width');
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.fitOptionsObserver ??= new ResizeObserver(this.updateFitOptionsWidth);
|
|
187
|
+
this.fitOptionsObserver.observe(this.fitOptionsMeasure, { box: 'border-box' });
|
|
188
|
+
for (const icon of Array.from(this.el.querySelectorAll('[slot="icon-left"]'))) {
|
|
189
|
+
this.fitOptionsObserver.observe(icon);
|
|
190
|
+
}
|
|
191
|
+
this.updateFitOptionsWidth();
|
|
192
|
+
};
|
|
193
|
+
updateFitOptionsWidth = () => {
|
|
194
|
+
if (this.width !== 'fit-options' || !this.fitOptionsMeasure || !this.triggerEl)
|
|
195
|
+
return;
|
|
196
|
+
const icons = Array.from(this.el.querySelectorAll('[slot="icon-left"]'));
|
|
197
|
+
const triggerStyle = getComputedStyle(this.triggerEl);
|
|
198
|
+
const gap = parseFloat(triggerStyle.columnGap) || 0;
|
|
199
|
+
const leadingWidth = icons.reduce((total, icon) => {
|
|
200
|
+
const style = getComputedStyle(icon);
|
|
201
|
+
return total + icon.getBoundingClientRect().width + (parseFloat(style.marginInlineStart) || 0) + (parseFloat(style.marginInlineEnd) || 0);
|
|
202
|
+
}, 0);
|
|
203
|
+
const labelWidth = this.fitOptionsMeasure.querySelector('.fit-options-labels').getBoundingClientRect().width;
|
|
204
|
+
const arrowWidth = this.fitOptionsMeasure.querySelector('.chevron-icon').getBoundingClientRect().width;
|
|
205
|
+
const frameWidth = ['paddingInlineStart', 'paddingInlineEnd', 'borderInlineStartWidth', 'borderInlineEndWidth']
|
|
206
|
+
.reduce((total, property) => total + (parseFloat(triggerStyle[property]) || 0), 0);
|
|
207
|
+
const adornmentWidth = this.editableSearch ? 0 : arrowWidth + gap + leadingWidth + (leadingWidth ? gap : 0);
|
|
208
|
+
const width = `${Math.ceil(labelWidth + frameWidth + adornmentWidth)}px`;
|
|
209
|
+
if (this.el.style.getPropertyValue('--_q-dropdown-options-width') !== width) {
|
|
210
|
+
this.el.style.setProperty('--_q-dropdown-options-width', width);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
148
213
|
watchValue(newValue) {
|
|
214
|
+
if (this.multiple)
|
|
215
|
+
return;
|
|
149
216
|
this.reconcileSelectedLabel();
|
|
150
217
|
this.closeMenu();
|
|
151
218
|
if (this.internals && typeof this.internals.setFormValue === 'function') {
|
|
@@ -153,6 +220,15 @@ export class QDropdown {
|
|
|
153
220
|
}
|
|
154
221
|
this.syncValidity();
|
|
155
222
|
}
|
|
223
|
+
watchValues() {
|
|
224
|
+
this.reconcileMultipleLabels();
|
|
225
|
+
this.focusedIndex = -1;
|
|
226
|
+
this.syncValidity();
|
|
227
|
+
}
|
|
228
|
+
watchMultiple() {
|
|
229
|
+
this.closeMenu();
|
|
230
|
+
this.syncValidity();
|
|
231
|
+
}
|
|
156
232
|
syncValidity() {
|
|
157
233
|
const disabled = syncFieldHost(this.el, this.disabled, this.name, this.required);
|
|
158
234
|
if (this.disabledState !== disabled)
|
|
@@ -166,15 +242,22 @@ export class QDropdown {
|
|
|
166
242
|
this.stopFloatingUpdates();
|
|
167
243
|
}
|
|
168
244
|
const selected = this.getFormSelection();
|
|
169
|
-
this.
|
|
245
|
+
const selectedValues = this.getMultipleFormSelection();
|
|
246
|
+
const data = new FormData();
|
|
247
|
+
if (this.name)
|
|
248
|
+
for (const value of selectedValues)
|
|
249
|
+
data.append(this.name, value);
|
|
250
|
+
this.internals?.setFormValue?.(disabled ? null : this.multiple ? data : selected);
|
|
170
251
|
if (typeof this.internals?.setValidity !== 'function')
|
|
171
252
|
return;
|
|
172
|
-
const
|
|
253
|
+
const missing = this.multiple ? !selectedValues.length : !this.value || selected === null;
|
|
254
|
+
const message = this.isDisabled ? '' : this.error?.trim() || (this.required && missing ? 'Please select an option.' : '');
|
|
173
255
|
this.internals.setValidity(message ? this.error?.trim() ? { customError: true } : { valueMissing: true } : {}, message, this.triggerEl);
|
|
174
256
|
}
|
|
175
257
|
async checkValidity() {
|
|
176
258
|
this.syncValidity();
|
|
177
|
-
|
|
259
|
+
const missing = this.multiple ? !this.getMultipleFormSelection().length : !this.value || this.getFormSelection() === null;
|
|
260
|
+
return this.isDisabled || !(this.error?.trim() || (this.required && missing));
|
|
178
261
|
}
|
|
179
262
|
async reportValidity() {
|
|
180
263
|
const valid = await this.checkValidity();
|
|
@@ -189,6 +272,7 @@ export class QDropdown {
|
|
|
189
272
|
}
|
|
190
273
|
watchOptions() {
|
|
191
274
|
this.reconcileSelectedLabel();
|
|
275
|
+
this.reconcileMultipleLabels();
|
|
192
276
|
this.focusedIndex = -1;
|
|
193
277
|
this.syncValidity();
|
|
194
278
|
if (this.externalSearch) {
|
|
@@ -202,7 +286,9 @@ export class QDropdown {
|
|
|
202
286
|
}
|
|
203
287
|
componentWillLoad() {
|
|
204
288
|
this.reconcileSelectedLabel();
|
|
289
|
+
this.reconcileMultipleLabels();
|
|
205
290
|
this.initialValue = this.value || '';
|
|
291
|
+
this.initialValues = [...this.selectedValues];
|
|
206
292
|
if (this.internals && typeof this.internals.setFormValue === 'function') {
|
|
207
293
|
this.internals.setFormValue(this.value);
|
|
208
294
|
}
|
|
@@ -214,6 +300,7 @@ export class QDropdown {
|
|
|
214
300
|
formResetCallback() {
|
|
215
301
|
this.closeMenu();
|
|
216
302
|
this.value = this.initialValue;
|
|
303
|
+
this.values = [...this.initialValues];
|
|
217
304
|
if (this.internals && typeof this.internals.setFormValue === 'function') {
|
|
218
305
|
this.internals.setFormValue(this.value);
|
|
219
306
|
}
|
|
@@ -226,6 +313,77 @@ export class QDropdown {
|
|
|
226
313
|
return selected.value;
|
|
227
314
|
return this.externalSearch && !selected && this.value ? this.value : null;
|
|
228
315
|
}
|
|
316
|
+
getMultipleFormSelection() {
|
|
317
|
+
const options = this.getAllOptions();
|
|
318
|
+
return this.selectedValues.filter(value => {
|
|
319
|
+
const option = getSelectedOption(options, value);
|
|
320
|
+
return option ? option.disabled !== true : this.externalSearch;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
reconcileMultipleLabels() {
|
|
324
|
+
const next = new Map();
|
|
325
|
+
for (const value of this.selectedValues) {
|
|
326
|
+
const option = getSelectedOption(this.getAllOptions(), value);
|
|
327
|
+
next.set(value, option ? this.getOptionLabel(option) : this.multipleLabels.get(value) ?? value);
|
|
328
|
+
}
|
|
329
|
+
this.multipleLabels = next;
|
|
330
|
+
}
|
|
331
|
+
removeValue = (value, event) => {
|
|
332
|
+
event?.stopPropagation();
|
|
333
|
+
if (this.isDisabled)
|
|
334
|
+
return;
|
|
335
|
+
this.values = this.selectedValues.filter(selected => selected !== value);
|
|
336
|
+
this.qValuesChange.emit([...this.values]);
|
|
337
|
+
if (!this.values.length)
|
|
338
|
+
this.closeMenu();
|
|
339
|
+
requestAnimationFrame(() => focusWithoutScroll(this.selectedPanel
|
|
340
|
+
? this.menuEl?.querySelector('q-chip')?.shadowRoot?.querySelector('button') ?? this.triggerEl
|
|
341
|
+
: this.triggerEl));
|
|
342
|
+
};
|
|
343
|
+
observeMultipleLayout() {
|
|
344
|
+
this.multipleObserver?.disconnect();
|
|
345
|
+
if (!this.multiple || !this.multipleFrame || !this.chipMeasure)
|
|
346
|
+
return;
|
|
347
|
+
this.multipleObserver ??= new ResizeObserver(this.measureMultipleLayout);
|
|
348
|
+
this.multipleObserver.observe(this.multipleFrame);
|
|
349
|
+
this.multipleObserver.observe(this.chipMeasure);
|
|
350
|
+
this.measureMultipleLayout();
|
|
351
|
+
}
|
|
352
|
+
measureMultipleLayout = () => {
|
|
353
|
+
if (!this.multipleFrame || !this.chipMeasure)
|
|
354
|
+
return;
|
|
355
|
+
const style = getComputedStyle(this.multipleFrame);
|
|
356
|
+
const gap = parseFloat(style.columnGap) || 0;
|
|
357
|
+
const frame = ['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth']
|
|
358
|
+
.reduce((sum, key) => sum + (parseFloat(style.getPropertyValue(key.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()))) || 0), 0);
|
|
359
|
+
const searchWidth = parseFloat(getComputedStyle(this.triggerEl).minWidth) || 64;
|
|
360
|
+
const iconWidth = this.multipleFrame.querySelector('.chevron-icon')?.getBoundingClientRect().width ?? 16;
|
|
361
|
+
const leadingWidth = Array.from(this.el.querySelectorAll('[slot="icon-left"]')).reduce((sum, node) => sum + node.getBoundingClientRect().width + gap, 0);
|
|
362
|
+
const available = this.multipleFrame.getBoundingClientRect().width - frame - searchWidth - iconWidth - leadingWidth - gap * 2;
|
|
363
|
+
const chips = Array.from(this.chipMeasure.querySelectorAll('q-chip'));
|
|
364
|
+
const widths = chips.map(chip => chip.getBoundingClientRect().width + gap);
|
|
365
|
+
const overflowWidth = this.chipMeasure.querySelector('.multiple-more').getBoundingClientRect().width + gap;
|
|
366
|
+
const allFit = widths.reduce((sum, width) => sum + width, 0) <= available;
|
|
367
|
+
let remaining = available - (allFit ? 0 : overflowWidth);
|
|
368
|
+
let count = 0;
|
|
369
|
+
for (const width of widths) {
|
|
370
|
+
if (width > remaining)
|
|
371
|
+
break;
|
|
372
|
+
count++;
|
|
373
|
+
remaining -= width;
|
|
374
|
+
}
|
|
375
|
+
if (count !== this.visibleChips)
|
|
376
|
+
this.visibleChips = count;
|
|
377
|
+
};
|
|
378
|
+
openSelectedPanel = (event) => {
|
|
379
|
+
event.stopPropagation();
|
|
380
|
+
if (this.isDisabled)
|
|
381
|
+
return;
|
|
382
|
+
this.closeMenu();
|
|
383
|
+
this.selectedPanel = true;
|
|
384
|
+
this.isOpen = true;
|
|
385
|
+
requestAnimationFrame(() => focusWithoutScroll(this.menuEl?.querySelector('q-chip')?.shadowRoot?.querySelector('button')));
|
|
386
|
+
};
|
|
229
387
|
clearScrollLoading() {
|
|
230
388
|
this.isScrollingLoading = false;
|
|
231
389
|
if (this.scrollTimeout !== null) {
|
|
@@ -243,10 +401,11 @@ export class QDropdown {
|
|
|
243
401
|
return getSelectedOption(options, this.value);
|
|
244
402
|
}
|
|
245
403
|
getFilteredOptions() {
|
|
404
|
+
const available = this.multiple ? this.getAllOptions().filter(option => !this.selectedValues.includes(option.value)) : this.getAllOptions();
|
|
246
405
|
if (this.externalSearch) {
|
|
247
|
-
return
|
|
406
|
+
return available;
|
|
248
407
|
}
|
|
249
|
-
return getFilteredOptions(
|
|
408
|
+
return getFilteredOptions(available, this.searchTerm, this.multiple || this.searchable);
|
|
250
409
|
}
|
|
251
410
|
get parsedOptions() {
|
|
252
411
|
if (this.externalSearch) {
|
|
@@ -262,7 +421,7 @@ export class QDropdown {
|
|
|
262
421
|
if (this.isOpen) {
|
|
263
422
|
this.searchTerm = '';
|
|
264
423
|
this.visibleCount = 20;
|
|
265
|
-
if (this.searchable) {
|
|
424
|
+
if (this.multiple || this.searchable) {
|
|
266
425
|
this.focusedIndex = -1;
|
|
267
426
|
requestAnimationFrame(() => focusWithoutScroll(this.editableSearch ? this.triggerEl : this.searchInputEl));
|
|
268
427
|
}
|
|
@@ -280,6 +439,25 @@ export class QDropdown {
|
|
|
280
439
|
handleSelect = (option) => {
|
|
281
440
|
if (this.isDisabled)
|
|
282
441
|
return;
|
|
442
|
+
if (this.multiple) {
|
|
443
|
+
if (this.selectedValues.includes(option.value))
|
|
444
|
+
return;
|
|
445
|
+
this.values = [...this.selectedValues, option.value];
|
|
446
|
+
this.multipleLabels.set(option.value, this.getOptionLabel(option));
|
|
447
|
+
this.searchTerm = '';
|
|
448
|
+
if (this.triggerEl instanceof HTMLInputElement) {
|
|
449
|
+
this.triggerEl.value = '';
|
|
450
|
+
}
|
|
451
|
+
this.draftEdited = false;
|
|
452
|
+
this.focusedIndex = -1;
|
|
453
|
+
this.qValuesChange.emit([...this.values]);
|
|
454
|
+
this.qSelect.emit(option);
|
|
455
|
+
if (this.externalSearch && this.lastSearchValue)
|
|
456
|
+
this.qSearch.emit('');
|
|
457
|
+
this.lastSearchValue = '';
|
|
458
|
+
requestAnimationFrame(() => focusWithoutScroll(this.triggerEl));
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
283
461
|
this.value = option.value;
|
|
284
462
|
this.selectedLabelCache = { value: option.value, label: this.getOptionLabel(option) };
|
|
285
463
|
this.closeMenu();
|
|
@@ -302,6 +480,8 @@ export class QDropdown {
|
|
|
302
480
|
if (this.isDisabled)
|
|
303
481
|
return;
|
|
304
482
|
this.qClick.emit(ev);
|
|
483
|
+
if (this.selectedPanel)
|
|
484
|
+
this.closeMenu();
|
|
305
485
|
if (!this.isOpen)
|
|
306
486
|
this.toggleMenu();
|
|
307
487
|
};
|
|
@@ -323,6 +503,7 @@ export class QDropdown {
|
|
|
323
503
|
if (this.composing || ev.isComposing)
|
|
324
504
|
return;
|
|
325
505
|
this.draftEdited = true;
|
|
506
|
+
this.selectedPanel = false;
|
|
326
507
|
this.searchTerm = target.value || '';
|
|
327
508
|
this.isOpen = true;
|
|
328
509
|
this.focusedIndex = -1;
|
|
@@ -402,7 +583,7 @@ export class QDropdown {
|
|
|
402
583
|
window.addEventListener('scroll', update, true);
|
|
403
584
|
if (typeof ResizeObserver !== 'undefined') {
|
|
404
585
|
this.floatingResizeObserver = new ResizeObserver(update);
|
|
405
|
-
this.floatingResizeObserver.observe(this.triggerEl);
|
|
586
|
+
this.floatingResizeObserver.observe(this.multiple ? this.multipleFrame : this.triggerEl);
|
|
406
587
|
this.floatingResizeObserver.observe(this.menuEl);
|
|
407
588
|
}
|
|
408
589
|
this.floatingCleanup = () => {
|
|
@@ -435,7 +616,7 @@ export class QDropdown {
|
|
|
435
616
|
});
|
|
436
617
|
}
|
|
437
618
|
positionFloatingMenu() {
|
|
438
|
-
const trigger = this.triggerEl;
|
|
619
|
+
const trigger = this.multiple ? this.multipleFrame : this.triggerEl;
|
|
439
620
|
const menu = this.menuEl;
|
|
440
621
|
if (!this.isOpen || !trigger || !menu) {
|
|
441
622
|
return;
|
|
@@ -467,12 +648,21 @@ export class QDropdown {
|
|
|
467
648
|
handleKeyDown = (ev) => {
|
|
468
649
|
if (this.isDisabled || this.composing || ev.isComposing || ev.keyCode === 229)
|
|
469
650
|
return;
|
|
651
|
+
const source = ev.composedPath()[0];
|
|
652
|
+
if (this.multiple && source !== this.triggerEl && ev.key !== 'Escape')
|
|
653
|
+
return;
|
|
654
|
+
if (this.multiple && ev.key === 'Backspace' && !this.searchTerm && this.selectedValues.length && source === this.triggerEl) {
|
|
655
|
+
ev.preventDefault();
|
|
656
|
+
this.removeValue(this.selectedValues[this.selectedValues.length - 1]);
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
470
659
|
const isInput = ev.target?.tagName?.toLowerCase() === 'input';
|
|
471
660
|
const maxIndex = this.parsedOptions.length - 1;
|
|
472
661
|
switch (ev.key) {
|
|
473
662
|
case 'ArrowDown':
|
|
474
663
|
case 'ArrowUp': {
|
|
475
664
|
ev.preventDefault();
|
|
665
|
+
this.selectedPanel = false;
|
|
476
666
|
const opening = !this.isOpen;
|
|
477
667
|
this.isOpen = true;
|
|
478
668
|
if (opening && this.searchable && !this.editableSearch) {
|
|
@@ -551,16 +741,16 @@ export class QDropdown {
|
|
|
551
741
|
const displayLabel = selectedLabel || this.placeholder;
|
|
552
742
|
const hasSelection = selectedOption !== undefined || Boolean(this.externalSearch && this.selectedLabelCache?.value === this.value);
|
|
553
743
|
const ariaLabel = this.ariaLabel?.trim() || undefined;
|
|
554
|
-
return (h("div", { key: '
|
|
744
|
+
return (h("div", { key: '5b133f37727c1ec3f4dfe3b4ab3d6ea245befd70', style: feedbackStyle(this.reserveFeedback), class: {
|
|
555
745
|
'dropdown-wrapper': true,
|
|
556
746
|
'is-open': this.isOpen,
|
|
557
747
|
'is-disabled': this.isDisabled,
|
|
558
748
|
[`size-${this.size}`]: true
|
|
559
|
-
}, onKeyDown: this.handleKeyDown, onFocusout: this.handleFocusOut }, this.label && (h("label", { key: '
|
|
749
|
+
}, onKeyDown: this.handleKeyDown, onFocusout: this.handleFocusOut }, this.label && (h("label", { key: 'af6610e93e291d5cad7773292dc5f79828f75e81', class: { 'dropdown-label': true, 'q-label-hidden': this.labelHidden }, htmlFor: "q-field", part: "label" }, this.label)), this.width === 'fit-options' && (h("span", { key: 'ad2cd29a9cfb8219c141aefc2aa9b182e99fcc53', class: "fit-options-clip", "aria-hidden": "true" }, h("span", { key: '87f24485e0b55c4d155fca10b27b6ea5699be25e', class: "dropdown-trigger fit-options-measure", ref: el => (this.fitOptionsMeasure = el) }, h("span", { key: 'f869add381f98a4a404aea2570ecd61be29207c8', class: "fit-options-labels" }, (allOptions.length ? allOptions.map(option => this.getOptionLabel(option)) : [selectedLabel || this.placeholder]).map(text => h("span", null, text))), h("span", { key: '7493679916bd1b75f8053dc064ecc067cf693e9c', class: "chevron-icon" })))), this.multiple ? h("div", { class: "dropdown-trigger multiple-trigger", part: "trigger", ref: el => this.multipleFrame = el }, h("slot", { name: "icon-left", onSlotchange: this.measureMultipleLayout }), this.selectedValues.slice(0, this.visibleChips).map(value => h("q-chip", { key: value, size: "sm", removable: true, label: this.multipleLabels.get(value) ?? value, value: value, disabled: this.isDisabled, onQRemove: event => this.removeValue(value, event) })), this.visibleChips < this.selectedValues.length && h("button", { type: "button", class: "multiple-more", disabled: this.isDisabled, "aria-haspopup": "dialog", "aria-expanded": this.selectedPanel && this.isOpen ? 'true' : 'false', "aria-controls": this.selectedPanel && this.isOpen ? 'q-field-menu' : undefined, "aria-label": `${this.selectedValues.length - this.visibleChips} more selected options`, onClick: this.openSelectedPanel }, "+", this.selectedValues.length - this.visibleChips, " more"), h("input", { ref: el => this.triggerEl = el, id: "q-field", class: "multiple-input", type: "text", role: "combobox", autocomplete: "off", disabled: this.isDisabled, value: this.searchTerm, placeholder: this.selectedValues.length ? 'Search…' : this.placeholder, onClick: this.handleEditableClick, onInput: this.handleSearchInput, onFocus: this.handleFocus, onBlur: this.handleBlur, onCompositionstart: this.handleCompositionStart, onCompositionend: this.handleCompositionEnd, "aria-label": ariaLabel, "aria-autocomplete": "list", "aria-haspopup": "listbox", "aria-required": this.required ? 'true' : 'false', "aria-invalid": this.error || this.required && !this.getMultipleFormSelection().length ? 'true' : 'false', "aria-describedby": this.error || this.description ? 'q-field-error' : undefined, "aria-expanded": this.isOpen && !this.selectedPanel ? 'true' : 'false', "aria-controls": this.isOpen && !this.selectedPanel ? 'q-field-menu' : undefined, "aria-activedescendant": this.isOpen && !this.selectedPanel && 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("span", { class: "multiple-measure", "aria-hidden": "true", inert: true, ref: el => this.chipMeasure = el }, this.selectedValues.map(value => h("q-chip", { key: value, size: "sm", removable: true, label: this.multipleLabels.get(value) ?? value })), h("button", { type: "button", class: "multiple-more", tabindex: -1 }, "+", this.selectedValues.length, " more"))) : 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", onSlotchange: this.observeFitOptions })), 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", onSlotchange: this.observeFitOptions }), 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: 'd6b784f85c73a05415b417dfad92befff2f383ec', ref: (el) => (this.menuEl = el), id: "q-field-menu", class: "dropdown-menu", part: "menu", role: this.selectedPanel ? 'dialog' : 'listbox', popover: "manual", "aria-label": this.selectedPanel ? 'Selected options' : ariaLabel || this.label || 'Options', "aria-multiselectable": this.multiple && !this.selectedPanel ? 'true' : undefined }, this.selectedPanel ? h("div", { class: "selected-options" }, h("strong", null, "Selected options"), this.selectedValues.map(value => h("q-chip", { key: value, size: "sm", removable: true, label: this.multipleLabels.get(value) ?? value, value: value, disabled: this.isDisabled, onQRemove: event => this.removeValue(value, event) })), h("button", { type: "button", class: "multiple-more", onClick: () => { this.closeMenu(); focusWithoutScroll(this.triggerEl); } }, "Done")) : h(Fragment, null, this.searchable && !this.editableSearch && (h("div", { class: "dropdown-search-container" }, h("input", { 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", { 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: {
|
|
560
750
|
'menu-item': true,
|
|
561
|
-
'is-selected': option.value === this.value,
|
|
751
|
+
'is-selected': !this.multiple && option.value === this.value,
|
|
562
752
|
'is-focused': index === this.focusedIndex
|
|
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", {
|
|
753
|
+
}, tabindex: -1, part: `item ${!this.multiple && option.value === this.value ? 'selected-item' : ''} ${index === this.focusedIndex ? 'focused-item' : ''}`, role: "option", "aria-selected": !this.multiple && option.value === this.value ? 'true' : 'false', onClick: () => this.handleSelect(option), onMouseDown: ev => ev.preventDefault() }, this.getOptionLabel(option))))), (this.loading || this.isScrollingLoading) && (h("li", { class: "menu-item is-loading-more" }, h("span", { class: "spinner-circle" }), h("span", null, "Loading...")))))))));
|
|
564
754
|
}
|
|
565
755
|
static get is() { return "q-dropdown"; }
|
|
566
756
|
static get encapsulation() { return "shadow"; }
|
|
@@ -703,6 +893,44 @@ export class QDropdown {
|
|
|
703
893
|
"attribute": "value",
|
|
704
894
|
"defaultValue": "''"
|
|
705
895
|
},
|
|
896
|
+
"multiple": {
|
|
897
|
+
"type": "boolean",
|
|
898
|
+
"mutable": false,
|
|
899
|
+
"complexType": {
|
|
900
|
+
"original": "boolean",
|
|
901
|
+
"resolved": "boolean",
|
|
902
|
+
"references": {}
|
|
903
|
+
},
|
|
904
|
+
"required": false,
|
|
905
|
+
"optional": false,
|
|
906
|
+
"docs": {
|
|
907
|
+
"tags": [],
|
|
908
|
+
"text": "Select several options. Uses values/qValuesChange instead of value/qChange."
|
|
909
|
+
},
|
|
910
|
+
"getter": false,
|
|
911
|
+
"setter": false,
|
|
912
|
+
"reflect": true,
|
|
913
|
+
"attribute": "multiple",
|
|
914
|
+
"defaultValue": "false"
|
|
915
|
+
},
|
|
916
|
+
"values": {
|
|
917
|
+
"type": "unknown",
|
|
918
|
+
"mutable": true,
|
|
919
|
+
"complexType": {
|
|
920
|
+
"original": "string[]",
|
|
921
|
+
"resolved": "string[]",
|
|
922
|
+
"references": {}
|
|
923
|
+
},
|
|
924
|
+
"required": false,
|
|
925
|
+
"optional": false,
|
|
926
|
+
"docs": {
|
|
927
|
+
"tags": [],
|
|
928
|
+
"text": "Selected identities in multiple mode. Replace the array to update selections."
|
|
929
|
+
},
|
|
930
|
+
"getter": false,
|
|
931
|
+
"setter": false,
|
|
932
|
+
"defaultValue": "[]"
|
|
933
|
+
},
|
|
706
934
|
"labelHidden": {
|
|
707
935
|
"type": "boolean",
|
|
708
936
|
"mutable": false,
|
|
@@ -773,8 +1001,8 @@ export class QDropdown {
|
|
|
773
1001
|
"type": "string",
|
|
774
1002
|
"mutable": false,
|
|
775
1003
|
"complexType": {
|
|
776
|
-
"original": "QInputWidth",
|
|
777
|
-
"resolved": "\"full\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\"",
|
|
1004
|
+
"original": "QInputWidth | 'fit-options'",
|
|
1005
|
+
"resolved": "\"fit-options\" | \"full\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\"",
|
|
778
1006
|
"references": {
|
|
779
1007
|
"QInputWidth": {
|
|
780
1008
|
"location": "import",
|
|
@@ -788,7 +1016,7 @@ export class QDropdown {
|
|
|
788
1016
|
"optional": true,
|
|
789
1017
|
"docs": {
|
|
790
1018
|
"tags": [],
|
|
791
|
-
"text": "Opt-in horizontal width;
|
|
1019
|
+
"text": "Opt-in horizontal width; fit-options sizes to loaded option labels. Omitted keeps the full-width layout."
|
|
792
1020
|
},
|
|
793
1021
|
"getter": false,
|
|
794
1022
|
"setter": false,
|
|
@@ -1031,7 +1259,9 @@ export class QDropdown {
|
|
|
1031
1259
|
"isScrollingLoading": {},
|
|
1032
1260
|
"disabledState": {},
|
|
1033
1261
|
"draftEdited": {},
|
|
1034
|
-
"selectedLabelCache": {}
|
|
1262
|
+
"selectedLabelCache": {},
|
|
1263
|
+
"visibleChips": {},
|
|
1264
|
+
"selectedPanel": {}
|
|
1035
1265
|
};
|
|
1036
1266
|
}
|
|
1037
1267
|
static get events() {
|
|
@@ -1050,6 +1280,21 @@ export class QDropdown {
|
|
|
1050
1280
|
"resolved": "string",
|
|
1051
1281
|
"references": {}
|
|
1052
1282
|
}
|
|
1283
|
+
}, {
|
|
1284
|
+
"method": "qValuesChange",
|
|
1285
|
+
"name": "qValuesChange",
|
|
1286
|
+
"bubbles": true,
|
|
1287
|
+
"cancelable": true,
|
|
1288
|
+
"composed": true,
|
|
1289
|
+
"docs": {
|
|
1290
|
+
"tags": [],
|
|
1291
|
+
"text": "Complete selected identities after an add or removal in multiple mode."
|
|
1292
|
+
},
|
|
1293
|
+
"complexType": {
|
|
1294
|
+
"original": "string[]",
|
|
1295
|
+
"resolved": "string[]",
|
|
1296
|
+
"references": {}
|
|
1297
|
+
}
|
|
1053
1298
|
}, {
|
|
1054
1299
|
"method": "qSelect",
|
|
1055
1300
|
"name": "qSelect",
|
|
@@ -1230,6 +1475,12 @@ export class QDropdown {
|
|
|
1230
1475
|
}, {
|
|
1231
1476
|
"propName": "value",
|
|
1232
1477
|
"methodName": "watchValue"
|
|
1478
|
+
}, {
|
|
1479
|
+
"propName": "values",
|
|
1480
|
+
"methodName": "watchValues"
|
|
1481
|
+
}, {
|
|
1482
|
+
"propName": "multiple",
|
|
1483
|
+
"methodName": "watchMultiple"
|
|
1233
1484
|
}, {
|
|
1234
1485
|
"propName": "name",
|
|
1235
1486
|
"methodName": "syncValidity"
|