@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
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { page, userEvent } from "vitest/browser";
|
|
3
|
+
import "../dropdown";
|
|
4
|
+
import css from "../dropdown.css?inline";
|
|
5
|
+
const frame = async () => { await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))); };
|
|
6
|
+
async function create(props = {}) {
|
|
7
|
+
const el = document.createElement('q-dropdown');
|
|
8
|
+
Object.assign(el, { label: 'Destination', searchable: true, options: [{ label: 'Alpha', value: 'a' }, { label: 'Beta', value: 'b' }], value: 'a', ...props });
|
|
9
|
+
el.style.width = '240px';
|
|
10
|
+
document.body.append(el);
|
|
11
|
+
await customElements.whenDefined('q-dropdown');
|
|
12
|
+
await frame();
|
|
13
|
+
const style = document.createElement('style');
|
|
14
|
+
style.textContent = css;
|
|
15
|
+
el.shadowRoot.append(style);
|
|
16
|
+
return el;
|
|
17
|
+
}
|
|
18
|
+
describe('q-dropdown search modes in Chromium', () => {
|
|
19
|
+
afterEach(() => document.body.replaceChildren());
|
|
20
|
+
it('filters from the main field without committing draft text and commits a pointer choice once', async () => {
|
|
21
|
+
const el = await create();
|
|
22
|
+
const change = vi.fn(), select = vi.fn();
|
|
23
|
+
el.addEventListener('qChange', change);
|
|
24
|
+
el.addEventListener('qSelect', select);
|
|
25
|
+
const input = page.getByRole('combobox', { name: 'Destination' });
|
|
26
|
+
await input.fill('Bet');
|
|
27
|
+
await frame();
|
|
28
|
+
expect(el.value).toBe('a');
|
|
29
|
+
expect(change).not.toHaveBeenCalled();
|
|
30
|
+
expect(el.shadowRoot.querySelector('.dropdown-search-container')).toBeNull();
|
|
31
|
+
expect(el.shadowRoot.querySelectorAll('[role=option]')).toHaveLength(1);
|
|
32
|
+
await userEvent.click(page.getByRole('option', { name: 'Beta' }));
|
|
33
|
+
await frame();
|
|
34
|
+
expect(el.value).toBe('b');
|
|
35
|
+
expect(change).toHaveBeenCalledTimes(1);
|
|
36
|
+
expect(select).toHaveBeenCalledTimes(1);
|
|
37
|
+
expect(el.shadowRoot.querySelector('.dropdown-main-input').value).toBe('Beta');
|
|
38
|
+
expect(el.shadowRoot.activeElement).toBe(el.shadowRoot.querySelector('.dropdown-main-input'));
|
|
39
|
+
});
|
|
40
|
+
it('moves the active option with arrows, commits only that option, and restores drafts on Escape and Tab', async () => {
|
|
41
|
+
const el = await create();
|
|
42
|
+
const input = page.getByRole('combobox', { name: 'Destination' });
|
|
43
|
+
await userEvent.click(input);
|
|
44
|
+
await userEvent.keyboard('{ArrowDown}{ArrowDown}');
|
|
45
|
+
await frame();
|
|
46
|
+
const field = el.shadowRoot.querySelector('.dropdown-main-input');
|
|
47
|
+
expect(field.getAttribute('aria-activedescendant')).toBe('q-field-item-1');
|
|
48
|
+
await userEvent.keyboard('{Enter}');
|
|
49
|
+
await frame();
|
|
50
|
+
expect(el.value).toBe('b');
|
|
51
|
+
await input.fill('uncommitted');
|
|
52
|
+
await userEvent.keyboard('{Escape}');
|
|
53
|
+
await frame();
|
|
54
|
+
expect(field.value).toBe('Beta');
|
|
55
|
+
expect(el.value).toBe('b');
|
|
56
|
+
await input.fill('another draft');
|
|
57
|
+
await userEvent.keyboard('{Tab}');
|
|
58
|
+
await frame();
|
|
59
|
+
expect(field.value).toBe('Beta');
|
|
60
|
+
expect(el.value).toBe('b');
|
|
61
|
+
});
|
|
62
|
+
it('restores on outside blur without a choice and does not submit draft text', async () => {
|
|
63
|
+
const el = await create({ name: 'destination', required: true });
|
|
64
|
+
const form = document.createElement('form');
|
|
65
|
+
document.body.append(form);
|
|
66
|
+
form.append(el);
|
|
67
|
+
const outside = document.createElement('button');
|
|
68
|
+
outside.textContent = 'Outside';
|
|
69
|
+
outside.style.cssText = 'position:fixed;right:10px;bottom:10px';
|
|
70
|
+
document.body.append(outside);
|
|
71
|
+
await frame();
|
|
72
|
+
const input = page.getByRole('combobox', { name: 'Destination' });
|
|
73
|
+
await input.fill('draft');
|
|
74
|
+
await userEvent.click(outside);
|
|
75
|
+
await frame();
|
|
76
|
+
expect(el.shadowRoot.querySelector('.dropdown-main-input').value).toBe('Alpha');
|
|
77
|
+
expect(new FormData(form).getAll('destination')).toEqual(['a']);
|
|
78
|
+
el.value = 'b';
|
|
79
|
+
await frame();
|
|
80
|
+
form.reset();
|
|
81
|
+
await frame();
|
|
82
|
+
expect(el.value).toBe('a');
|
|
83
|
+
await el.focusElement();
|
|
84
|
+
expect(el.shadowRoot.activeElement).toBe(el.shadowRoot.querySelector('input'));
|
|
85
|
+
el.value = '';
|
|
86
|
+
await frame();
|
|
87
|
+
expect(await el.reportValidity()).toBe(false);
|
|
88
|
+
expect(el.shadowRoot.activeElement).toBe(el.shadowRoot.querySelector('input'));
|
|
89
|
+
});
|
|
90
|
+
it('emits immediate completed external edits once, including clear, while retaining the committed remote label', async () => {
|
|
91
|
+
const el = await create({ externalSearch: true });
|
|
92
|
+
const search = vi.fn(), change = vi.fn();
|
|
93
|
+
el.addEventListener('qSearch', search);
|
|
94
|
+
el.addEventListener('qChange', change);
|
|
95
|
+
await userEvent.click(page.getByRole('combobox', { name: 'Destination' }));
|
|
96
|
+
await frame();
|
|
97
|
+
expect(search).not.toHaveBeenCalled();
|
|
98
|
+
const field = el.shadowRoot.querySelector('input');
|
|
99
|
+
field.dispatchEvent(new CompositionEvent('compositionstart', { bubbles: true }));
|
|
100
|
+
field.value = '日';
|
|
101
|
+
field.dispatchEvent(new InputEvent('input', { bubbles: true, isComposing: true }));
|
|
102
|
+
field.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, isComposing: true }));
|
|
103
|
+
expect(search).not.toHaveBeenCalled();
|
|
104
|
+
expect(el.value).toBe('a');
|
|
105
|
+
field.value = '日本';
|
|
106
|
+
field.dispatchEvent(new CompositionEvent('compositionend', { bubbles: true }));
|
|
107
|
+
field.dispatchEvent(new InputEvent('input', { bubbles: true }));
|
|
108
|
+
await frame();
|
|
109
|
+
expect(search).toHaveBeenCalledTimes(1);
|
|
110
|
+
expect(search.mock.calls[0][0].detail).toBe('日本');
|
|
111
|
+
el.options = [{ label: 'Other remote result', value: 'other' }];
|
|
112
|
+
await frame();
|
|
113
|
+
await userEvent.keyboard('{Escape}');
|
|
114
|
+
await frame();
|
|
115
|
+
expect(field.value).toBe('Alpha');
|
|
116
|
+
expect(search).toHaveBeenCalledTimes(1);
|
|
117
|
+
expect(change).not.toHaveBeenCalled();
|
|
118
|
+
await page.getByRole('combobox', { name: 'Destination' }).fill('');
|
|
119
|
+
await frame();
|
|
120
|
+
expect(search.mock.calls.at(-1)[0].detail).toBe('');
|
|
121
|
+
el.value = 'unknown';
|
|
122
|
+
await frame();
|
|
123
|
+
expect(field.value).toBe('');
|
|
124
|
+
el.value = '';
|
|
125
|
+
await frame();
|
|
126
|
+
expect(field.value).toBe('');
|
|
127
|
+
});
|
|
128
|
+
it('keeps menu mode separate, cancels mode switches, and disables the active control', async () => {
|
|
129
|
+
const el = await create({ searchMode: 'menu' });
|
|
130
|
+
await userEvent.click(el.shadowRoot.querySelector('.dropdown-trigger'));
|
|
131
|
+
await frame();
|
|
132
|
+
expect(el.shadowRoot.querySelector('.dropdown-search-input')).not.toBeNull();
|
|
133
|
+
expect(el.shadowRoot.querySelector('.dropdown-main-input')).toBeNull();
|
|
134
|
+
el.searchMode = 'default';
|
|
135
|
+
await frame();
|
|
136
|
+
expect(el.shadowRoot.querySelector('.dropdown-menu')).toBeNull();
|
|
137
|
+
await page.getByRole('combobox', { name: 'Destination' }).fill('draft');
|
|
138
|
+
el.disabled = true;
|
|
139
|
+
await frame();
|
|
140
|
+
expect(el.shadowRoot.querySelector('input').disabled).toBe(true);
|
|
141
|
+
expect(el.shadowRoot.querySelector('.dropdown-menu')).toBeNull();
|
|
142
|
+
el.disabled = false;
|
|
143
|
+
el.searchable = false;
|
|
144
|
+
await frame();
|
|
145
|
+
expect(el.shadowRoot.querySelector('input')).toBeNull();
|
|
146
|
+
expect(el.shadowRoot.querySelector('button')?.textContent).toContain('Alpha');
|
|
147
|
+
});
|
|
148
|
+
it('keeps local removed selections invalid without creating a change event', async () => {
|
|
149
|
+
const el = await create({ required: true });
|
|
150
|
+
const change = vi.fn();
|
|
151
|
+
el.addEventListener('qChange', change);
|
|
152
|
+
el.options = ['Gamma'];
|
|
153
|
+
await frame();
|
|
154
|
+
expect(el.value).toBe('a');
|
|
155
|
+
expect(await el.checkValidity()).toBe(false);
|
|
156
|
+
expect(change).not.toHaveBeenCalled();
|
|
157
|
+
expect(el.shadowRoot.querySelector('input').value).toBe('');
|
|
158
|
+
});
|
|
159
|
+
it('anchors the popup to the actual input and retains external paging/loading behavior', async () => {
|
|
160
|
+
const el = await create({ externalSearch: true, hasMore: true });
|
|
161
|
+
const more = vi.fn();
|
|
162
|
+
el.addEventListener('qLoadMore', more);
|
|
163
|
+
await userEvent.click(page.getByRole('combobox', { name: 'Destination' }));
|
|
164
|
+
await frame();
|
|
165
|
+
const input = el.shadowRoot.querySelector('.dropdown-main-input');
|
|
166
|
+
const menu = el.shadowRoot.querySelector('.dropdown-menu');
|
|
167
|
+
expect(menu.getBoundingClientRect().width).toBeCloseTo(input.getBoundingClientRect().width);
|
|
168
|
+
expect(menu.getBoundingClientRect().top - input.getBoundingClientRect().bottom).toBeCloseTo(4);
|
|
169
|
+
const list = el.shadowRoot.querySelector('.dropdown-items-list');
|
|
170
|
+
list.dispatchEvent(new Event('scroll'));
|
|
171
|
+
await frame();
|
|
172
|
+
expect(more).toHaveBeenCalledTimes(1);
|
|
173
|
+
el.loading = true;
|
|
174
|
+
await frame();
|
|
175
|
+
expect(el.shadowRoot.querySelector('.is-loading-more')).not.toBeNull();
|
|
176
|
+
list.dispatchEvent(new Event('scroll'));
|
|
177
|
+
await frame();
|
|
178
|
+
expect(more).toHaveBeenCalledTimes(1);
|
|
179
|
+
el.options = [{ label: 'Remote page', value: 'page' }];
|
|
180
|
+
el.loading = false;
|
|
181
|
+
await frame();
|
|
182
|
+
list.dispatchEvent(new Event('scroll'));
|
|
183
|
+
await frame();
|
|
184
|
+
expect(more).toHaveBeenCalledTimes(2);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -294,11 +294,11 @@ export class QForm {
|
|
|
294
294
|
const hasHeaderContent = Boolean(this.label) || this.hasHeaderSlot;
|
|
295
295
|
const formLabelledBy = !this.ariaLabel && this.label && !this.hasHeaderSlot ? this.titleId : undefined;
|
|
296
296
|
const formAriaLabel = this.ariaLabel?.trim() || (this.label && this.hasHeaderSlot ? this.label : undefined);
|
|
297
|
-
return (h(Host, { key: '
|
|
297
|
+
return (h(Host, { key: '9eeca5dbe6783954ba5915ae2cbed2da36c23cb5', style: { ...controlScope(this.size), '--q-context-feedback-min': this.reserveFeedback === undefined ? '' : 'initial', '--_q-context-feedback-reserve': this.reserveFeedback === undefined ? '' : this.reserveFeedback ? '1' : '0' } }, h("div", { key: '2c80bf5712898a180d193a530beb6f208f0d2702', class: "form-shell" }, h("div", { key: 'a45188e5b3df0fa0b37400feacd95edfbe1110c4', class: { 'form-header': true, 'is-hidden': !hasHeaderContent, 'q-label-hidden': this.labelHidden }, part: "header" }, h("slot", { key: '4855d5fffa98f1f4dc39878f063f3323216c17d5', name: "header", ref: (el) => (this.headerSlot = el), onSlotchange: this.handleHeaderSlotChange }, this.label && h("h2", { key: '6482a98a6a0a99a7311a01f1b43b99b011d022d8', id: this.titleId, class: "form-title" }, this.label))), h("form", { key: '1f4b42eec4b633eaa3de7225c3b5bf918ad71079', ref: (el) => (this.formEl = el), action: this.action, method: this.method, autocomplete: this.autocomplete, enctype: this.enctype, target: this.target, noValidate: this.noValidate, "aria-labelledby": formLabelledBy, "aria-label": formAriaLabel, part: "form", onSubmit: this.handleSubmit, onClick: (ev) => {
|
|
298
298
|
const image = ev.target;
|
|
299
299
|
if (image instanceof HTMLInputElement && image.type === 'image' && image.getRootNode() === this.formEl?.getRootNode())
|
|
300
300
|
this.handleComposedClick(ev);
|
|
301
|
-
}, onReset: this.handleReset }, h("div", { key: '
|
|
301
|
+
}, onReset: this.handleReset }, h("div", { key: '347a28b99b61212aaa644aa3db1fbde51c93d819', class: "form-body", part: "body" }, h("slot", { key: '334454b4bfc0e2a51d745991bcdc73549e4ca5a4' })), h("div", { key: '1f45d5c6aa912456169d75a54598c141f5543952', class: { 'form-actions': true, 'is-hidden': !this.hasActionsSlot }, part: "actions" }, h("slot", { key: 'd6102796fdb4d53ef3c21f60fd595120ef403cc9', name: "actions", ref: (el) => (this.actionsSlot = el), onSlotchange: this.handleActionsSlotChange }))))));
|
|
302
302
|
}
|
|
303
303
|
static get is() { return "q-form"; }
|
|
304
304
|
static get encapsulation() { return "shadow"; }
|
|
@@ -367,16 +367,22 @@ describe('originating Enter and native dialog submission', () => {
|
|
|
367
367
|
input.dispatchEvent(ev);
|
|
368
368
|
expect(ev.defaultPrevented).toBe(true);
|
|
369
369
|
});
|
|
370
|
-
it('never borrows an unrelated active field for popup or unowned Enter', async () => {
|
|
371
|
-
const form = await create(
|
|
370
|
+
it.each(['default', 'menu'])('never borrows an unrelated active field for popup or unowned Enter in %s search mode', async (searchMode) => {
|
|
371
|
+
const form = await create(`<input name="a"><q-dropdown name="choice" searchable search-mode="${searchMode}"></q-dropdown><q-input name="foreign" form="missing"></q-input>`);
|
|
372
372
|
form.enterBehavior = 'none';
|
|
373
|
-
form.querySelector('input')
|
|
373
|
+
const activeField = form.querySelector('input');
|
|
374
|
+
activeField.focus();
|
|
374
375
|
const dropdown = form.querySelector('q-dropdown');
|
|
375
|
-
dropdown.shadowRoot.querySelector('
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const
|
|
379
|
-
|
|
376
|
+
const trigger = dropdown.shadowRoot.querySelector('[part="trigger"]');
|
|
377
|
+
expect(trigger).not.toBeNull();
|
|
378
|
+
await userEvent.click(trigger);
|
|
379
|
+
const searchSelector = searchMode === 'menu' ? '.dropdown-search-input' : '.dropdown-main-input';
|
|
380
|
+
await vi.waitFor(() => {
|
|
381
|
+
expect(trigger.getAttribute('aria-expanded')).toBe('true');
|
|
382
|
+
expect(dropdown.shadowRoot.querySelector(searchSelector)).not.toBeNull();
|
|
383
|
+
});
|
|
384
|
+
const search = dropdown.shadowRoot.querySelector(searchSelector);
|
|
385
|
+
activeField.focus();
|
|
380
386
|
for (const target of [search, form.querySelector('q-input').shadowRoot.querySelector('input'), form]) {
|
|
381
387
|
const ev = new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, composed: true, cancelable: true });
|
|
382
388
|
target.dispatchEvent(ev);
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/* Generated by scripts/generate-theme.ts. */
|
|
2
|
+
:host([width="xs"]),
|
|
3
|
+
:host([width="sm"]),
|
|
4
|
+
:host([width="md"]),
|
|
5
|
+
:host([width="lg"]),
|
|
6
|
+
:host([width="xl"]),
|
|
7
|
+
:host([width="xxl"]),
|
|
8
|
+
:host([width="full"]) {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
max-width: 100%;
|
|
12
|
+
}
|
|
13
|
+
:host([width="xs"]) { width: var(--q-input-width-xs, 5rem); }
|
|
14
|
+
:host([width="sm"]) { width: var(--q-input-width-sm, 7.5rem); }
|
|
15
|
+
:host([width="md"]) { width: var(--q-input-width-md, 11.25rem); }
|
|
16
|
+
:host([width="lg"]) { width: var(--q-input-width-lg, 15rem); }
|
|
17
|
+
:host([width="xl"]) { width: var(--q-input-width-xl, 18.125rem); }
|
|
18
|
+
:host([width="xxl"]) { width: var(--q-input-width-xxl, 22.5rem); }
|
|
19
|
+
:host([width="full"]) { width: 100%; }
|
|
20
|
+
|
|
1
21
|
/* Generated by scripts/generate-theme.ts. */
|
|
2
22
|
:host {
|
|
3
23
|
min-width: 0;
|
|
@@ -30,6 +30,8 @@ export class QInput {
|
|
|
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
|
/** Shows a clear button when the field has a value. */
|
|
34
36
|
clearable = false;
|
|
35
37
|
disabled = false;
|
|
@@ -298,16 +300,16 @@ export class QInput {
|
|
|
298
300
|
const isMinDisabled = hasNumericValue && this.min !== undefined && this.min !== null && numericValue <= this.min;
|
|
299
301
|
const isMaxDisabled = hasNumericValue && this.max !== undefined && this.max !== null && numericValue >= this.max;
|
|
300
302
|
const ariaLabel = this.ariaLabel?.trim() || undefined;
|
|
301
|
-
return (h("div", { key: '
|
|
303
|
+
return (h("div", { key: '8b42ceb7344bcf7d7e612d25363a273ac8595d73', style: feedbackStyle(this.reserveFeedback), class: {
|
|
302
304
|
'input-wrapper': true,
|
|
303
305
|
'is-disabled': this.isDisabled,
|
|
304
306
|
'has-error': hasError,
|
|
305
307
|
[`size-${this.size}`]: true
|
|
306
|
-
} }, this.label && (h("label", { key: '
|
|
308
|
+
} }, this.label && (h("label", { key: 'd4f0419f6acec43a62bd67b56eb8111da8e92694', class: { 'input-label': true, 'q-label-hidden': this.labelHidden }, htmlFor: "q-field", part: "label" }, this.label)), h("div", { key: '0776ffdbd55a4e83beeb86da353ef3f3275c19d5', class: "input-control", part: "control" }, h("span", { key: 'b6e56e21986c2b80b0e6b371e761dd3d1f70db5f', class: "prefix-container", style: { display: this.hasPrefix ? 'flex' : 'none' }, part: "prefix" }, h("slot", { key: '8158e89e4680516aaa430328256a928ac6d541c9', name: "prefix", onSlotchange: this.handlePrefixSlotChange })), h("input", { key: this.type, ref: (el) => (this.inputEl = el), id: "q-field", class: {
|
|
307
309
|
'input-box': true,
|
|
308
310
|
'has-prefix-padding': this.hasPrefix,
|
|
309
311
|
'has-suffix-padding': showSuffixContainer
|
|
310
|
-
}, type: inputType, name: this.name, value: this.value, placeholder: this.placeholder, disabled: this.isDisabled, required: this.required, min: this.min, max: this.max, step: this.step, onInput: this.handleInput, onChange: this.handleChange, onBlur: this.handleBlur, onFocus: this.handleFocus, onClick: this.handleClick, onKeyDown: this.handleKeyDown, role: this.type === 'number' ? 'spinbutton' : undefined, "aria-valuenow": hasNumericValue ? String(numericValue) : undefined, "aria-valuemin": this.type === 'number' && this.min !== undefined && this.min !== null ? String(this.min) : undefined, "aria-valuemax": this.type === 'number' && this.max !== undefined && this.max !== null ? String(this.max) : undefined, "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": hasError || this.description ? 'q-field-error' : undefined, "aria-label": ariaLabel }), this.type === 'number' && !this.isDisabled && (h("div", { key: '
|
|
312
|
+
}, type: inputType, name: this.name, value: this.value, placeholder: this.placeholder, disabled: this.isDisabled, required: this.required, min: this.min, max: this.max, step: this.step, onInput: this.handleInput, onChange: this.handleChange, onBlur: this.handleBlur, onFocus: this.handleFocus, onClick: this.handleClick, onKeyDown: this.handleKeyDown, role: this.type === 'number' ? 'spinbutton' : undefined, "aria-valuenow": hasNumericValue ? String(numericValue) : undefined, "aria-valuemin": this.type === 'number' && this.min !== undefined && this.min !== null ? String(this.min) : undefined, "aria-valuemax": this.type === 'number' && this.max !== undefined && this.max !== null ? String(this.max) : undefined, "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": hasError || this.description ? 'q-field-error' : undefined, "aria-label": ariaLabel }), this.type === 'number' && !this.isDisabled && (h("div", { key: 'f0f1937bc3ee7467f311f9c3037d5e9d6b067b35', class: "input-spinners", part: "spinners" }, h("button", { key: '2b6748cdf0d6b702593f01ab125e479192cec01f', class: "spinner-btn spinner-up", type: "button", onClick: this.handleIncrement, disabled: isMaxDisabled, "aria-label": "Increase value" }, h("svg", { key: '41ea7701ce869c76fa0c608464040cf402471506', viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, h("path", { key: '0d55f92912d4b965daf1ee703147c5794f998407', d: "M18 15l-6-6-6 6" }))), h("button", { key: '1fe024df336b0302d15696672a9806ea4dab523a', class: "spinner-btn spinner-down", type: "button", onClick: this.handleDecrement, disabled: isMinDisabled, "aria-label": "Decrease value" }, h("svg", { key: 'a893df82780770e5e14fc190c846c18605688a27', viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, h("path", { key: 'f9e9f18fb2205c39e52e2bc1eb8736c5d78ce683', d: "M6 9l6 6 6-6" }))))), h("span", { key: 'cf742d4de79337a7ed23f1e92526054db97e46e9', class: "suffix-container", style: { display: showSuffixContainer ? 'flex' : 'none' }, part: "suffix" }, showClearBtn && (h("button", { key: '18fb167f0cff4d38bc4d27a247494e8229534cec', class: "clear-btn", type: "button", onClick: this.handleClear, "aria-label": "Clear input" }, h("svg", { key: '129c1fa6c4bfb87cc108ed98b7293cb21b8e5bec', viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("path", { key: 'b21f70435ca270b45a60bddc97ea2780fe79c0f4', d: "M18 6L6 18M6 6l12 12" })))), showPasswordToggle && (h("button", { key: '6b8b9a7d77fc4dc4080981bebd6a4f0268bd94ab', class: "password-toggle-btn", type: "button", onClick: this.handlePasswordToggle, "aria-label": this.passwordVisible ? 'Hide password' : 'Show password', "aria-pressed": this.passwordVisible ? 'true' : 'false' }, this.passwordVisible ? (h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, h("path", { d: "M3 3l18 18" }), h("path", { d: "M10.58 10.58A2 2 0 0 0 12 14a2 2 0 0 0 1.42-.58" }), h("path", { d: "M9.88 4.24A10.2 10.2 0 0 1 12 4c7 0 10 8 10 8a18.5 18.5 0 0 1-4.08 5.19" }), h("path", { d: "M6.61 6.61A18.5 18.5 0 0 0 2 12s3 8 10 8a10.7 10.7 0 0 0 5.39-1.61" }))) : (h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" }, h("path", { d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" }), h("circle", { cx: "12", cy: "12", r: "3" }))))), h("span", { key: '94eaabb7303710ce3cf0ad753a5f46d77af27183', style: { display: !showClearBtn && this.hasSuffix ? 'block' : 'none' } }, h("slot", { key: '0a79e017573b9c992287f30a0372cb2e3e06e3c9', name: "suffix", onSlotchange: this.handleSuffixSlotChange })))), fieldFeedback('q-field-error', displayError, this.description)));
|
|
311
313
|
}
|
|
312
314
|
static get is() { return "q-input"; }
|
|
313
315
|
static get encapsulation() { return "shadow"; }
|
|
@@ -489,6 +491,32 @@ export class QInput {
|
|
|
489
491
|
"attribute": "size",
|
|
490
492
|
"defaultValue": "'inherit'"
|
|
491
493
|
},
|
|
494
|
+
"width": {
|
|
495
|
+
"type": "string",
|
|
496
|
+
"mutable": false,
|
|
497
|
+
"complexType": {
|
|
498
|
+
"original": "QInputWidth",
|
|
499
|
+
"resolved": "\"full\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\"",
|
|
500
|
+
"references": {
|
|
501
|
+
"QInputWidth": {
|
|
502
|
+
"location": "import",
|
|
503
|
+
"path": "../../../theme/tokens",
|
|
504
|
+
"id": "../../../src/browser/theme/tokens.ts::QInputWidth",
|
|
505
|
+
"referenceLocation": "QInputWidth"
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
"required": false,
|
|
510
|
+
"optional": true,
|
|
511
|
+
"docs": {
|
|
512
|
+
"tags": [],
|
|
513
|
+
"text": "Opt-in horizontal width; independent of size. Omitted uses the existing full-width layout."
|
|
514
|
+
},
|
|
515
|
+
"getter": false,
|
|
516
|
+
"setter": false,
|
|
517
|
+
"reflect": true,
|
|
518
|
+
"attribute": "width"
|
|
519
|
+
},
|
|
492
520
|
"clearable": {
|
|
493
521
|
"type": "boolean",
|
|
494
522
|
"mutable": false,
|
|
@@ -111,15 +111,15 @@ export class QQuantitySelector {
|
|
|
111
111
|
const hasFiniteValue = Number.isFinite(this.value);
|
|
112
112
|
const isMinDisabled = hasFiniteValue && hasQuantityBound(this.min) && finiteValue <= this.min;
|
|
113
113
|
const isMaxDisabled = hasFiniteValue && hasQuantityBound(this.max) && finiteValue >= this.max;
|
|
114
|
-
const decBtn = (h("button", { key: '
|
|
115
|
-
const incBtn = (h("button", { key: '
|
|
114
|
+
const decBtn = (h("button", { key: 'ec0597ccef7335f6eb6915e6e606e7dfd82a6877', type: "button", class: "quantity-btn quantity-btn-decrement", onClick: this.decrement, disabled: isMinDisabled, "aria-label": "Decrement quantity" }, h("svg", { key: 'f08f4647d713929d7bcfd3f2cd2f38e887251d04', viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "btn-icon", "aria-hidden": "true" }, h("line", { key: 'ce57365bc6c891c9e8aa3ec9558d67d82011031d', x1: "5", y1: "12", x2: "19", y2: "12" }))));
|
|
115
|
+
const incBtn = (h("button", { key: '0fe3c85711b2403b234f9ccd93cb69fb84727d11', type: "button", class: "quantity-btn quantity-btn-increment", onClick: this.increment, disabled: isMaxDisabled, "aria-label": "Increment quantity" }, h("svg", { key: '72e2f169ebbb2dbb5a5b208517c9cd7833866de5', viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "btn-icon", "aria-hidden": "true" }, h("line", { key: '78184e34c8d5a2b55ba9b641ebb1873653c12265', x1: "12", y1: "5", x2: "12", y2: "19" }), h("line", { key: '9d7039973b4f3ac60cf316640f6ce4b658ddef32', x1: "5", y1: "12", x2: "19", y2: "12" }))));
|
|
116
116
|
const calculatedWidth = orientation === 'horizontal' ? this.getCalculatedWidth() : '100%';
|
|
117
|
-
return (h("div", { key: '
|
|
117
|
+
return (h("div", { key: '264f7f182e7871533d15ee3625cb8e75d233f3d6', class: {
|
|
118
118
|
'quantity-selector': true,
|
|
119
119
|
[`size-${this.size}`]: true,
|
|
120
120
|
[`orientation-${orientation}`]: true,
|
|
121
121
|
[`variant-${orientation}`]: true,
|
|
122
|
-
}, onClick: this.handleClick }, orientation === 'vertical' ? incBtn : decBtn, h("input", { key: '
|
|
122
|
+
}, onClick: this.handleClick }, orientation === 'vertical' ? incBtn : decBtn, h("input", { key: '2102dd8d9544fbe35de6e0da5705ed29bc391a4a', type: "text", class: "quantity-input", value: this.inputValue, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus, onChange: this.handleChange, onKeyDown: this.handleKeyDown, role: "spinbutton", "aria-valuenow": hasFiniteValue ? String(this.value) : undefined, "aria-valuemin": hasQuantityBound(this.min) ? String(this.min) : undefined, "aria-valuemax": hasQuantityBound(this.max) ? String(this.max) : undefined, "aria-label": "Quantity", style: { width: calculatedWidth }, part: "input" }), orientation === 'vertical' ? decBtn : incBtn));
|
|
123
123
|
}
|
|
124
124
|
static get is() { return "q-quantity-selector"; }
|
|
125
125
|
static get encapsulation() { return "shadow"; }
|
|
@@ -193,13 +193,13 @@ export class QRadioGroup {
|
|
|
193
193
|
const hasError = !!displayError;
|
|
194
194
|
const ariaLabel = this.ariaLabel?.trim() || undefined;
|
|
195
195
|
const radioName = this.name || this.internalName;
|
|
196
|
-
return (h("div", { key: '
|
|
196
|
+
return (h("div", { key: 'ca721052881ef003c67a6c137d1ece018e66db95', style: feedbackStyle(this.reserveFeedback), class: {
|
|
197
197
|
'radio-group': true,
|
|
198
198
|
'is-disabled': this.isDisabled,
|
|
199
199
|
'has-error': hasError,
|
|
200
200
|
[`size-${this.size}`]: true,
|
|
201
201
|
[`orientation-${this.orientation}`]: true,
|
|
202
|
-
} }, h("fieldset", { key: '
|
|
202
|
+
} }, h("fieldset", { key: '1b95846df14f3ac209a821d96875d0fbf1c7f4c3', ref: element => (this.fieldsetEl = element), class: "group-fieldset", part: "group", disabled: this.isDisabled, role: "radiogroup", "aria-label": !this.label ? ariaLabel : undefined, "aria-required": this.required ? 'true' : 'false', "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": hasError || this.description ? 'q-radio-group-error' : undefined }, this.label && h("legend", { key: 'c449725ee7ea6e8ca7e97c57e44cc7d95468025e', part: "label", class: { 'q-label-hidden': this.labelHidden } }, this.label), h("div", { key: 'b648e3db6f3984b2f778b8ccc2fc9120faa12f7a', class: "options", part: "options", style: { '--q-radio-group-option-count': String(Math.max(identifiedOptions.length, 1)) } }, identifiedOptions.map(({ item: option, key }) => (h("label", { key: key, class: {
|
|
203
203
|
option: true,
|
|
204
204
|
'is-selected': option.value === this.value,
|
|
205
205
|
'is-disabled': this.isDisabled || option.disabled === true,
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/* Generated by scripts/generate-theme.ts. */
|
|
2
|
+
:host([width="xs"]),
|
|
3
|
+
:host([width="sm"]),
|
|
4
|
+
:host([width="md"]),
|
|
5
|
+
:host([width="lg"]),
|
|
6
|
+
:host([width="xl"]),
|
|
7
|
+
:host([width="xxl"]),
|
|
8
|
+
:host([width="full"]) {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
max-width: 100%;
|
|
12
|
+
}
|
|
13
|
+
:host([width="xs"]) { width: var(--q-input-width-xs, 5rem); }
|
|
14
|
+
:host([width="sm"]) { width: var(--q-input-width-sm, 7.5rem); }
|
|
15
|
+
:host([width="md"]) { width: var(--q-input-width-md, 11.25rem); }
|
|
16
|
+
:host([width="lg"]) { width: var(--q-input-width-lg, 15rem); }
|
|
17
|
+
:host([width="xl"]) { width: var(--q-input-width-xl, 18.125rem); }
|
|
18
|
+
:host([width="xxl"]) { width: var(--q-input-width-xxl, 22.5rem); }
|
|
19
|
+
:host([width="full"]) { width: 100%; }
|
|
20
|
+
|
|
1
21
|
/* Generated by scripts/generate-theme.ts. */
|
|
2
22
|
:host {
|
|
3
23
|
min-width: 0;
|
|
@@ -20,6 +20,8 @@ export class QTextarea {
|
|
|
20
20
|
/** Supporting text, replaced by an active error. */
|
|
21
21
|
description;
|
|
22
22
|
size = 'inherit';
|
|
23
|
+
/** Opt-in horizontal width; independent of size. Omitted uses the existing full-width layout. */
|
|
24
|
+
width;
|
|
23
25
|
/** Keep the label accessible without displaying it. */
|
|
24
26
|
labelHidden = false;
|
|
25
27
|
/** Omitted inherits the enclosing form; false cancels reservation. */
|
|
@@ -232,12 +234,12 @@ export class QTextarea {
|
|
|
232
234
|
const hasError = !!(this.error || this.errorMessage);
|
|
233
235
|
const displayError = this.error || this.errorMessage;
|
|
234
236
|
const ariaLabel = this.ariaLabel?.trim() || (!this.label && this.placeholder ? this.placeholder : undefined);
|
|
235
|
-
return (h("div", { key: '
|
|
237
|
+
return (h("div", { key: 'de9538ea2d7219be226da601fd034a87f9c03c6e', style: feedbackStyle(this.reserveFeedback), class: {
|
|
236
238
|
'textarea-wrapper': true,
|
|
237
239
|
'is-disabled': this.isDisabled,
|
|
238
240
|
'has-error': hasError,
|
|
239
241
|
[`size-${this.size}`]: true
|
|
240
|
-
} }, h("span", { key: '
|
|
242
|
+
} }, h("span", { key: 'cd983f3817f41b3df19a46b541982e1a2f2f08a4', class: "textarea-size-probe", "aria-hidden": "true", ref: el => (this.sizeProbeEl = el) }, "M"), this.label && (h("label", { key: 'a13d6e1c3ea718a8d1d3c6278056fd4429e0abd4', class: { 'textarea-label': true, 'q-label-hidden': this.labelHidden }, htmlFor: "q-field", part: "label" }, this.label)), h("textarea", { key: '02deeabf34bc333a559267fe7c04d23584e2ff8a', ref: (el) => (this.textareaEl = el), id: "q-field", class: {
|
|
241
243
|
'textarea-box': true,
|
|
242
244
|
'resize-manual': this.activeResizeMode === 'manual'
|
|
243
245
|
}, part: "textarea", value: this.value, name: this.name, placeholder: this.placeholder, rows: this.rows, disabled: this.isDisabled, required: this.required, onInput: this.handleInput, onChange: this.handleChange, onBlur: this.handleBlur, onFocus: this.handleFocus, onClick: this.handleClick, "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": hasError || this.description ? 'q-field-error' : undefined, "aria-label": ariaLabel }), fieldFeedback('q-field-error', displayError, this.description)));
|
|
@@ -383,6 +385,32 @@ export class QTextarea {
|
|
|
383
385
|
"attribute": "size",
|
|
384
386
|
"defaultValue": "'inherit'"
|
|
385
387
|
},
|
|
388
|
+
"width": {
|
|
389
|
+
"type": "string",
|
|
390
|
+
"mutable": false,
|
|
391
|
+
"complexType": {
|
|
392
|
+
"original": "QInputWidth",
|
|
393
|
+
"resolved": "\"full\" | \"lg\" | \"md\" | \"sm\" | \"xl\" | \"xs\" | \"xxl\"",
|
|
394
|
+
"references": {
|
|
395
|
+
"QInputWidth": {
|
|
396
|
+
"location": "import",
|
|
397
|
+
"path": "../../../theme/tokens",
|
|
398
|
+
"id": "../../../src/browser/theme/tokens.ts::QInputWidth",
|
|
399
|
+
"referenceLocation": "QInputWidth"
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
"required": false,
|
|
404
|
+
"optional": true,
|
|
405
|
+
"docs": {
|
|
406
|
+
"tags": [],
|
|
407
|
+
"text": "Opt-in horizontal width; independent of size. Omitted uses the existing full-width layout."
|
|
408
|
+
},
|
|
409
|
+
"getter": false,
|
|
410
|
+
"setter": false,
|
|
411
|
+
"reflect": true,
|
|
412
|
+
"attribute": "width"
|
|
413
|
+
},
|
|
386
414
|
"labelHidden": {
|
|
387
415
|
"type": "boolean",
|
|
388
416
|
"mutable": false,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { afterEach, expect, it } from "vitest";
|
|
2
|
+
import "../../../../../../packages/browser/components/dist/components/q-toggle.js";
|
|
3
|
+
import tokens from "../../../../theme/tokens.css?raw";
|
|
4
|
+
import presets from "../../../../theme/token-presets.css?raw";
|
|
5
|
+
const frame = async () => { await new Promise(requestAnimationFrame); await new Promise(requestAnimationFrame); };
|
|
6
|
+
async function fixture(markup) {
|
|
7
|
+
document.body.innerHTML = `<style>${tokens}\n${presets}</style>${markup}`;
|
|
8
|
+
await customElements.whenDefined('q-toggle');
|
|
9
|
+
await frame();
|
|
10
|
+
return document.querySelector('q-toggle');
|
|
11
|
+
}
|
|
12
|
+
const part = (element, name) => element.shadowRoot.querySelector(`[part~="${name}"]`);
|
|
13
|
+
afterEach(() => document.body.replaceChildren());
|
|
14
|
+
it.each(['ltr', 'rtl'])('places switches after their label at the trailing edge in %s', async (direction) => {
|
|
15
|
+
const element = await fixture(`<q-toggle dir="${direction}" style="width:320px" label="Required before checkout"></q-toggle>`);
|
|
16
|
+
const control = part(element, 'control').getBoundingClientRect();
|
|
17
|
+
const label = part(element, 'label').getBoundingClientRect();
|
|
18
|
+
const host = element.getBoundingClientRect();
|
|
19
|
+
if (direction === 'ltr') {
|
|
20
|
+
expect(label.right).toBeLessThan(control.left);
|
|
21
|
+
expect(control.right).toBe(host.right);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
expect(control.right).toBeLessThan(label.left);
|
|
25
|
+
expect(control.left).toBe(host.left);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
it.each(['ltr', 'rtl'])('keeps checkboxes before their label in %s', async (direction) => {
|
|
29
|
+
const element = await fixture(`<q-toggle type="checkbox" dir="${direction}" style="width:320px" label="Visit slot"></q-toggle>`);
|
|
30
|
+
const control = part(element, 'control').getBoundingClientRect();
|
|
31
|
+
const label = part(element, 'label').getBoundingClientRect();
|
|
32
|
+
if (direction === 'ltr')
|
|
33
|
+
expect(control.right).toBeLessThan(label.left);
|
|
34
|
+
else
|
|
35
|
+
expect(label.right).toBeLessThan(control.left);
|
|
36
|
+
});
|
|
37
|
+
it('supports slotted and hidden labels, long text, errors and a control-first part override', async () => {
|
|
38
|
+
const element = await fixture('<q-toggle style="width:160px" error="Review this setting"><span>Long setting label that wraps across multiple lines</span></q-toggle>');
|
|
39
|
+
expect(part(element, 'control').getBoundingClientRect().right).toBe(element.getBoundingClientRect().right);
|
|
40
|
+
expect(part(element, 'label').getBoundingClientRect().height).toBeGreaterThan(20);
|
|
41
|
+
expect(part(element, 'error-msg').getBoundingClientRect().top).toBeGreaterThanOrEqual(part(element, 'label').getBoundingClientRect().bottom);
|
|
42
|
+
element.labelHidden = true;
|
|
43
|
+
await frame();
|
|
44
|
+
expect(part(element, 'label').classList.contains('q-label-hidden')).toBe(true);
|
|
45
|
+
expect(part(element, 'control').getBoundingClientRect().right).toBe(element.getBoundingClientRect().right);
|
|
46
|
+
element.labelHidden = false;
|
|
47
|
+
const override = document.createElement('style');
|
|
48
|
+
override.textContent = 'q-toggle::part(control) { order: 0; margin-inline-start: 0; }';
|
|
49
|
+
document.body.append(override);
|
|
50
|
+
await frame();
|
|
51
|
+
expect(part(element, 'control').getBoundingClientRect().right).toBeLessThan(part(element, 'label').getBoundingClientRect().left);
|
|
52
|
+
});
|
|
53
|
+
it('preserves label click, keyboard activation, disabled semantics and form value', async () => {
|
|
54
|
+
const element = await fixture('<form><q-toggle name="required" label="Required before checkout"></q-toggle></form>');
|
|
55
|
+
part(element, 'label').click();
|
|
56
|
+
await frame();
|
|
57
|
+
expect(element.checked).toBe(true);
|
|
58
|
+
expect(new FormData(document.querySelector('form')).get('required')).toBe('true');
|
|
59
|
+
const wrapper = element.shadowRoot.querySelector('[role="switch"]');
|
|
60
|
+
wrapper.dispatchEvent(new KeyboardEvent('keydown', { key: ' ', bubbles: true }));
|
|
61
|
+
await frame();
|
|
62
|
+
expect(element.checked).toBe(false);
|
|
63
|
+
element.disabled = true;
|
|
64
|
+
await frame();
|
|
65
|
+
expect(wrapper.getAttribute('aria-disabled')).toBe('true');
|
|
66
|
+
expect(wrapper.tabIndex).toBe(-1);
|
|
67
|
+
part(element, 'label').click();
|
|
68
|
+
expect(element.checked).toBe(false);
|
|
69
|
+
});
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
.toggle-control {
|
|
91
|
+
flex-shrink: 0;
|
|
91
92
|
display: flex;
|
|
92
93
|
align-items: center;
|
|
93
94
|
justify-content: center;
|
|
@@ -250,3 +251,7 @@
|
|
|
250
251
|
.switch-thumb { width: var(--_q-thumb-size); height: var(--_q-thumb-size); }
|
|
251
252
|
.type-switch.is-checked .switch-thumb { transform: translate(calc(var(--_q-switch-width) - var(--_q-thumb-size) - 6px), -50%); }
|
|
252
253
|
.checkbox-box { width: var(--q-toggle-checkbox-size, var(--q-toggle-box-size, var(--_q-control-icon))); height: var(--q-toggle-checkbox-size, var(--q-toggle-box-size, var(--_q-control-icon))); }
|
|
254
|
+
|
|
255
|
+
/* Switch settings read label-first; checkbox choices retain control-first order. */
|
|
256
|
+
.type-switch .toggle-control { order: 1; margin-inline-start: auto; }
|
|
257
|
+
.toggle-label-text { min-width: 0; overflow-wrap: anywhere; }
|
|
@@ -191,7 +191,7 @@ export class QToggle {
|
|
|
191
191
|
const hasLabel = this.label !== undefined && this.label !== '';
|
|
192
192
|
const showLabel = hasLabel || this.hasDefaultSlot;
|
|
193
193
|
const hasError = !!this.error;
|
|
194
|
-
return (h("div", { key: '
|
|
194
|
+
return (h("div", { key: '9cfe9bc23f52b1f7b9b084f8feddfc26dd8f3071', class: "toggle-container", style: feedbackStyle(this.reserveFeedback) }, h("div", { key: 'ec36954facc5a2fcff74e943a5211b2f496dc138', ref: el => (this.controlEl = el), class: {
|
|
195
195
|
'toggle-wrapper': true,
|
|
196
196
|
'is-checked': this.checked,
|
|
197
197
|
'is-disabled': this.isDisabled,
|
|
@@ -199,11 +199,11 @@ export class QToggle {
|
|
|
199
199
|
'has-error': hasError,
|
|
200
200
|
[`type-${this.type}`]: true,
|
|
201
201
|
[`size-${this.size}`]: true,
|
|
202
|
-
}, role: this.type === 'switch' ? 'switch' : 'checkbox', "aria-checked": this.checked ? 'true' : 'false', "aria-disabled": this.isDisabled ? 'true' : 'false', "aria-required": this.required ? 'true' : 'false', "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": hasError || this.description ? 'toggle-error-msg' : undefined, tabindex: this.isDisabled ? -1 : 0, onClick: this.handleClick, onKeyDown: this.handleKeyDown, onFocus: this.handleFocus, onBlur: this.handleBlur }, h("div", { key: '
|
|
202
|
+
}, role: this.type === 'switch' ? 'switch' : 'checkbox', "aria-checked": this.checked ? 'true' : 'false', "aria-disabled": this.isDisabled ? 'true' : 'false', "aria-required": this.required ? 'true' : 'false', "aria-invalid": hasError ? 'true' : 'false', "aria-describedby": hasError || this.description ? 'toggle-error-msg' : undefined, tabindex: this.isDisabled ? -1 : 0, onClick: this.handleClick, onKeyDown: this.handleKeyDown, onFocus: this.handleFocus, onBlur: this.handleBlur }, h("div", { key: 'f821a8f66d21a11bd1a0eaaae8dfee4863e567a7', class: "toggle-control", part: "control" }, this.type === 'switch' ? (h("div", { class: "switch-track", part: "track" }, h("div", { class: "switch-thumb", part: "thumb" }))) : (h("div", { class: "checkbox-box", part: "box" }, h("span", { class: { 'icon-wrap': true, 'is-hidden': !this.checked }, part: "icon-checked" }, h("slot", { name: "checked-icon", onSlotchange: this.handleSlotChange }, h("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "3", "stroke-linecap": "round", "stroke-linejoin": "round", class: "default-check-icon", "aria-hidden": "true" }, h("polyline", { points: "20 6 9 17 4 12" })))), h("span", { class: { 'icon-wrap': true, 'is-hidden': this.checked }, part: "icon-unchecked" }, h("slot", { name: "unchecked-icon", onSlotchange: this.handleSlotChange }))))), h("span", { key: '64209658594c4c4f80ae75cdf28998ffba67041d', class: {
|
|
203
203
|
'toggle-label-text': true,
|
|
204
204
|
'q-label-hidden': this.labelHidden,
|
|
205
205
|
'is-hidden': !showLabel
|
|
206
|
-
}, part: "label" }, h("slot", { key: '
|
|
206
|
+
}, part: "label" }, h("slot", { key: 'cdf69787b364adbc4775283987451740d878abc1', onSlotchange: this.handleSlotChange }, this.label))), fieldFeedback('toggle-error-msg', this.error, this.description)));
|
|
207
207
|
}
|
|
208
208
|
static get is() { return "q-toggle"; }
|
|
209
209
|
static get encapsulation() { return "shadow"; }
|