@webquark/browser 1.1.0-dev.10 → 1.1.0-dev.12
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/{dom-Dk77oFF6.js → dom-BYrqRYna.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 +3 -3
- package/dist/cjs/q-carousel.cjs.entry.js +2 -2
- 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 +4 -4
- 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 +5 -5
- 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 +9 -7
- 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 +7 -7
- 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 +4 -4
- 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 +2 -2
- package/dist/cjs/q-slider.cjs.entry.js +122 -0
- 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 +2 -2
- 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 +2 -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/internals/controls.js +1 -1
- 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/slider/slider.css +44 -0
- package/dist/collection/components/inputs/slider/slider.js +383 -0
- package/dist/collection/components/inputs/slider/test/slider.cmp.test.js +45 -0
- 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/collection/utils/dom.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-Cg0Mv7Vb.js → p-0feRVg70.js} +1 -1
- package/dist/components/{p-6PPZ2sIO.js → p-4mHh96ug.js} +1 -1
- package/dist/components/p-BDsIecIx.js +1 -0
- package/dist/components/{p-CKuPOxKN.js → p-BKly3Y6e.js} +1 -1
- package/dist/components/{p-Dfp_If-_.js → p-BbY1XC6_.js} +1 -1
- package/dist/components/p-CArIPzJU.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-DlIn_ZWk.js → p-DbI_F3z0.js} +1 -1
- package/dist/components/p-cSh-5xis.js +1 -0
- 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-slider.d.ts +11 -0
- package/dist/components/q-slider.js +1 -0
- 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/{dom-ByfrUWx1.js → dom-CArIPzJU.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 +3 -3
- package/dist/esm/q-carousel.entry.js +2 -2
- 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 +4 -4
- 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 +5 -5
- 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 +9 -7
- 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 +7 -7
- 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 +4 -4
- 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 +2 -2
- package/dist/esm/q-slider.entry.js +120 -0
- 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 +2 -2
- 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/slider/slider.d.ts +45 -0
- package/dist/types/components/inputs/slider/test/slider.cmp.test.d.ts +1 -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 +247 -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-01a59ac3.entry.js +1 -0
- package/dist/webquark/{p-4d61b70d.entry.js → p-156d2fcf.entry.js} +1 -1
- package/dist/webquark/p-253add6d.entry.js +1 -0
- package/dist/webquark/{p-fec6fe0a.entry.js → p-253fb28b.entry.js} +1 -1
- package/dist/webquark/{p-8ece2c62.entry.js → p-29897ae6.entry.js} +1 -1
- package/dist/webquark/{p-f98f9439.entry.js → p-2c195546.entry.js} +1 -1
- package/dist/webquark/p-2e26f158.entry.js +1 -0
- package/dist/webquark/{p-f4f97e74.entry.js → p-33234157.entry.js} +1 -1
- package/dist/webquark/{p-fe8c634a.entry.js → p-3430b43c.entry.js} +1 -1
- package/dist/webquark/{p-f63b7214.entry.js → p-3726655f.entry.js} +1 -1
- package/dist/webquark/{p-5f232b44.entry.js → p-3af50215.entry.js} +2 -2
- package/dist/webquark/{p-9ff7e5a4.entry.js → p-44eda084.entry.js} +1 -1
- package/dist/webquark/{p-09cca7b9.entry.js → p-45e0d213.entry.js} +1 -1
- package/dist/webquark/{p-d0253d64.entry.js → p-473a1810.entry.js} +1 -1
- package/dist/webquark/{p-f1bac94c.entry.js → p-58aaa98b.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-64096386.entry.js → p-78c56cd3.entry.js} +1 -1
- package/dist/webquark/p-7a47e0c3.entry.js +1 -0
- package/dist/webquark/p-848e040a.entry.js +1 -0
- package/dist/webquark/{p-97a89cae.entry.js → p-881ecd5b.entry.js} +1 -1
- package/dist/webquark/{p-d0fbd2b1.entry.js → p-8a0733a1.entry.js} +1 -1
- package/dist/webquark/p-99ed0b0d.entry.js +1 -0
- 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-CArIPzJU.js +1 -0
- 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-023f8437.entry.js → p-aca37b06.entry.js} +1 -1
- package/dist/webquark/p-b577b258.entry.js +1 -0
- package/dist/webquark/{p-6e28cfe2.entry.js → p-b702f60a.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-c2edfa2c.entry.js +1 -0
- package/dist/webquark/{p-030ecde3.entry.js → p-d2c4696f.entry.js} +1 -1
- package/dist/webquark/{p-6bfffa79.entry.js → p-dcea3702.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-90b0858c.entry.js → p-e7384b6e.entry.js} +1 -1
- package/dist/webquark/p-e930a769.entry.js +1 -0
- package/dist/webquark/{p-296fbdb1.entry.js → p-f20ed85a.entry.js} +1 -1
- package/dist/webquark/p-f95aeb8d.entry.js +1 -0
- package/dist/webquark/{p-059daa8a.entry.js → p-fa15a69b.entry.js} +1 -1
- 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-ByfrUWx1.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-144ef339.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-ByfrUWx1.js +0 -1
- package/dist/webquark/p-c523ec6f.entry.js +0 -1
- package/dist/webquark/p-fe200f68.entry.js +0 -1
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { isFieldDisabled } from "../../../utils/form-field-state";
|
|
3
|
+
import { registerFormField } from "../../../utils/form-field-adapter";
|
|
4
|
+
/**
|
|
5
|
+
* Single-value range input with a themed track, glowing thumb and optional value badge.
|
|
6
|
+
* @part label - Label and value row.
|
|
7
|
+
* @part value - Current-value badge.
|
|
8
|
+
* @part input - Native range control.
|
|
9
|
+
*/
|
|
10
|
+
export class QSlider {
|
|
11
|
+
el;
|
|
12
|
+
/** Current value. Defaults to the minimum when omitted. */
|
|
13
|
+
value;
|
|
14
|
+
label;
|
|
15
|
+
/** Suffix for the displayed value, such as px or %. */
|
|
16
|
+
suffix = '';
|
|
17
|
+
showValue = true;
|
|
18
|
+
disabled = false;
|
|
19
|
+
min = 0;
|
|
20
|
+
max = 100;
|
|
21
|
+
step = 1;
|
|
22
|
+
name;
|
|
23
|
+
ariaLabel = null;
|
|
24
|
+
internals;
|
|
25
|
+
/** Numeric value emitted continuously while dragging or using the keyboard. */
|
|
26
|
+
qInput;
|
|
27
|
+
/** Numeric value emitted when the interaction is committed. */
|
|
28
|
+
qChange;
|
|
29
|
+
fieldDisabled = false;
|
|
30
|
+
inputEl;
|
|
31
|
+
initialValue;
|
|
32
|
+
componentWillLoad() {
|
|
33
|
+
this.initialValue = this.value;
|
|
34
|
+
this.normalize();
|
|
35
|
+
}
|
|
36
|
+
constraintsChanged() { this.normalize(); }
|
|
37
|
+
disabledChanged() { this.syncForm(); }
|
|
38
|
+
get lower() { return Number.isFinite(this.min) ? this.min : 0; }
|
|
39
|
+
get upper() { return Math.max(this.lower, Number.isFinite(this.max) ? this.max : 100); }
|
|
40
|
+
get increment() { return Number.isFinite(this.step) && this.step > 0 ? this.step : 1; }
|
|
41
|
+
normalize() {
|
|
42
|
+
const candidate = Number.isFinite(this.value) ? this.value : this.lower;
|
|
43
|
+
const steps = Math.round((Math.min(this.upper, Math.max(this.lower, candidate)) - this.lower) / this.increment);
|
|
44
|
+
const lastStep = Math.floor((this.upper - this.lower) / this.increment + 1e-10);
|
|
45
|
+
const next = Number((this.lower + Math.min(steps, lastStep) * this.increment).toPrecision(12));
|
|
46
|
+
if (this.value !== next)
|
|
47
|
+
this.value = next;
|
|
48
|
+
this.syncForm();
|
|
49
|
+
}
|
|
50
|
+
syncForm() {
|
|
51
|
+
this.fieldDisabled = isFieldDisabled(this.el, this.disabled);
|
|
52
|
+
this.internals?.setFormValue?.(this.fieldDisabled ? null : String(this.value ?? this.lower));
|
|
53
|
+
}
|
|
54
|
+
componentDidLoad() {
|
|
55
|
+
registerFormField(this.el, {
|
|
56
|
+
kind: 'text',
|
|
57
|
+
owner: () => this.internals?.form ?? null,
|
|
58
|
+
active: () => true,
|
|
59
|
+
value: () => String(this.value),
|
|
60
|
+
assign: value => { this.value = Number(value); this.normalize(); },
|
|
61
|
+
reconcile: () => this.normalize(),
|
|
62
|
+
reset: () => this.formResetCallback(),
|
|
63
|
+
validate: () => true,
|
|
64
|
+
});
|
|
65
|
+
this.syncForm();
|
|
66
|
+
}
|
|
67
|
+
formDisabledCallback() { this.syncForm(); }
|
|
68
|
+
formResetCallback() { this.value = this.initialValue; this.normalize(); }
|
|
69
|
+
formStateRestoreCallback(state) {
|
|
70
|
+
if (typeof state === 'string') {
|
|
71
|
+
this.value = Number(state);
|
|
72
|
+
this.normalize();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async focusElement() { this.inputEl?.focus(); }
|
|
76
|
+
onValue(event, committed) {
|
|
77
|
+
if (this.fieldDisabled)
|
|
78
|
+
return;
|
|
79
|
+
this.value = event.target.valueAsNumber;
|
|
80
|
+
this.normalize();
|
|
81
|
+
if (committed)
|
|
82
|
+
this.qChange.emit(this.value);
|
|
83
|
+
else
|
|
84
|
+
this.qInput.emit(this.value);
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
return (h("div", { key: '2768a521f895ff4e060fbfad3844c7617d1ab454', class: "field" }, (this.label || this.showValue) && h("div", { key: 'b0317ffdb85a1bc87ed259f32291bd433aec7378', class: "label-row", part: "label" }, this.label && h("label", { key: '83cf1561c36c515304bf866fe645a8afcf75be39', htmlFor: "range" }, this.label), this.showValue && h("span", { key: '471ae15a9b5e951d955ddc3b2ebac4e7ef8868f4', class: "badge", part: "value", "aria-hidden": "true" }, this.value, this.suffix)), h("input", { key: 'a2e4d500b85a3e4548c14b063919fbf2894b314b', ref: el => this.inputEl = el, id: "range", part: "input", type: "range", min: this.lower, max: this.upper, step: this.increment, value: this.value, disabled: this.fieldDisabled, "aria-label": this.ariaLabel || (!this.label ? 'Value' : undefined), "aria-valuetext": this.suffix ? `${this.value}${this.suffix}` : undefined, onInput: event => this.onValue(event, false), onChange: event => this.onValue(event, true) })));
|
|
88
|
+
}
|
|
89
|
+
static get is() { return "q-slider"; }
|
|
90
|
+
static get encapsulation() { return "shadow"; }
|
|
91
|
+
static get delegatesFocus() { return true; }
|
|
92
|
+
static get formAssociated() { return true; }
|
|
93
|
+
static get originalStyleUrls() {
|
|
94
|
+
return {
|
|
95
|
+
"$": ["slider.css"]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
static get styleUrls() {
|
|
99
|
+
return {
|
|
100
|
+
"$": ["slider.css"]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
static get properties() {
|
|
104
|
+
return {
|
|
105
|
+
"value": {
|
|
106
|
+
"type": "number",
|
|
107
|
+
"mutable": true,
|
|
108
|
+
"complexType": {
|
|
109
|
+
"original": "number",
|
|
110
|
+
"resolved": "number",
|
|
111
|
+
"references": {}
|
|
112
|
+
},
|
|
113
|
+
"required": false,
|
|
114
|
+
"optional": true,
|
|
115
|
+
"docs": {
|
|
116
|
+
"tags": [],
|
|
117
|
+
"text": "Current value. Defaults to the minimum when omitted."
|
|
118
|
+
},
|
|
119
|
+
"getter": false,
|
|
120
|
+
"setter": false,
|
|
121
|
+
"reflect": false,
|
|
122
|
+
"attribute": "value"
|
|
123
|
+
},
|
|
124
|
+
"label": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"mutable": false,
|
|
127
|
+
"complexType": {
|
|
128
|
+
"original": "string",
|
|
129
|
+
"resolved": "string",
|
|
130
|
+
"references": {}
|
|
131
|
+
},
|
|
132
|
+
"required": false,
|
|
133
|
+
"optional": true,
|
|
134
|
+
"docs": {
|
|
135
|
+
"tags": [],
|
|
136
|
+
"text": ""
|
|
137
|
+
},
|
|
138
|
+
"getter": false,
|
|
139
|
+
"setter": false,
|
|
140
|
+
"reflect": false,
|
|
141
|
+
"attribute": "label"
|
|
142
|
+
},
|
|
143
|
+
"suffix": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"mutable": false,
|
|
146
|
+
"complexType": {
|
|
147
|
+
"original": "string",
|
|
148
|
+
"resolved": "string",
|
|
149
|
+
"references": {}
|
|
150
|
+
},
|
|
151
|
+
"required": false,
|
|
152
|
+
"optional": false,
|
|
153
|
+
"docs": {
|
|
154
|
+
"tags": [],
|
|
155
|
+
"text": "Suffix for the displayed value, such as px or %."
|
|
156
|
+
},
|
|
157
|
+
"getter": false,
|
|
158
|
+
"setter": false,
|
|
159
|
+
"reflect": false,
|
|
160
|
+
"attribute": "suffix",
|
|
161
|
+
"defaultValue": "''"
|
|
162
|
+
},
|
|
163
|
+
"showValue": {
|
|
164
|
+
"type": "boolean",
|
|
165
|
+
"mutable": false,
|
|
166
|
+
"complexType": {
|
|
167
|
+
"original": "boolean",
|
|
168
|
+
"resolved": "boolean",
|
|
169
|
+
"references": {}
|
|
170
|
+
},
|
|
171
|
+
"required": false,
|
|
172
|
+
"optional": false,
|
|
173
|
+
"docs": {
|
|
174
|
+
"tags": [],
|
|
175
|
+
"text": ""
|
|
176
|
+
},
|
|
177
|
+
"getter": false,
|
|
178
|
+
"setter": false,
|
|
179
|
+
"reflect": false,
|
|
180
|
+
"attribute": "show-value",
|
|
181
|
+
"defaultValue": "true"
|
|
182
|
+
},
|
|
183
|
+
"disabled": {
|
|
184
|
+
"type": "boolean",
|
|
185
|
+
"mutable": false,
|
|
186
|
+
"complexType": {
|
|
187
|
+
"original": "boolean",
|
|
188
|
+
"resolved": "boolean",
|
|
189
|
+
"references": {}
|
|
190
|
+
},
|
|
191
|
+
"required": false,
|
|
192
|
+
"optional": false,
|
|
193
|
+
"docs": {
|
|
194
|
+
"tags": [],
|
|
195
|
+
"text": ""
|
|
196
|
+
},
|
|
197
|
+
"getter": false,
|
|
198
|
+
"setter": false,
|
|
199
|
+
"reflect": true,
|
|
200
|
+
"attribute": "disabled",
|
|
201
|
+
"defaultValue": "false"
|
|
202
|
+
},
|
|
203
|
+
"min": {
|
|
204
|
+
"type": "number",
|
|
205
|
+
"mutable": false,
|
|
206
|
+
"complexType": {
|
|
207
|
+
"original": "number",
|
|
208
|
+
"resolved": "number",
|
|
209
|
+
"references": {}
|
|
210
|
+
},
|
|
211
|
+
"required": false,
|
|
212
|
+
"optional": false,
|
|
213
|
+
"docs": {
|
|
214
|
+
"tags": [],
|
|
215
|
+
"text": ""
|
|
216
|
+
},
|
|
217
|
+
"getter": false,
|
|
218
|
+
"setter": false,
|
|
219
|
+
"reflect": false,
|
|
220
|
+
"attribute": "min",
|
|
221
|
+
"defaultValue": "0"
|
|
222
|
+
},
|
|
223
|
+
"max": {
|
|
224
|
+
"type": "number",
|
|
225
|
+
"mutable": false,
|
|
226
|
+
"complexType": {
|
|
227
|
+
"original": "number",
|
|
228
|
+
"resolved": "number",
|
|
229
|
+
"references": {}
|
|
230
|
+
},
|
|
231
|
+
"required": false,
|
|
232
|
+
"optional": false,
|
|
233
|
+
"docs": {
|
|
234
|
+
"tags": [],
|
|
235
|
+
"text": ""
|
|
236
|
+
},
|
|
237
|
+
"getter": false,
|
|
238
|
+
"setter": false,
|
|
239
|
+
"reflect": false,
|
|
240
|
+
"attribute": "max",
|
|
241
|
+
"defaultValue": "100"
|
|
242
|
+
},
|
|
243
|
+
"step": {
|
|
244
|
+
"type": "number",
|
|
245
|
+
"mutable": false,
|
|
246
|
+
"complexType": {
|
|
247
|
+
"original": "number",
|
|
248
|
+
"resolved": "number",
|
|
249
|
+
"references": {}
|
|
250
|
+
},
|
|
251
|
+
"required": false,
|
|
252
|
+
"optional": false,
|
|
253
|
+
"docs": {
|
|
254
|
+
"tags": [],
|
|
255
|
+
"text": ""
|
|
256
|
+
},
|
|
257
|
+
"getter": false,
|
|
258
|
+
"setter": false,
|
|
259
|
+
"reflect": false,
|
|
260
|
+
"attribute": "step",
|
|
261
|
+
"defaultValue": "1"
|
|
262
|
+
},
|
|
263
|
+
"name": {
|
|
264
|
+
"type": "string",
|
|
265
|
+
"mutable": false,
|
|
266
|
+
"complexType": {
|
|
267
|
+
"original": "string",
|
|
268
|
+
"resolved": "string",
|
|
269
|
+
"references": {}
|
|
270
|
+
},
|
|
271
|
+
"required": false,
|
|
272
|
+
"optional": true,
|
|
273
|
+
"docs": {
|
|
274
|
+
"tags": [],
|
|
275
|
+
"text": ""
|
|
276
|
+
},
|
|
277
|
+
"getter": false,
|
|
278
|
+
"setter": false,
|
|
279
|
+
"reflect": true,
|
|
280
|
+
"attribute": "name"
|
|
281
|
+
},
|
|
282
|
+
"ariaLabel": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"mutable": false,
|
|
285
|
+
"complexType": {
|
|
286
|
+
"original": "string | null",
|
|
287
|
+
"resolved": "string",
|
|
288
|
+
"references": {}
|
|
289
|
+
},
|
|
290
|
+
"required": false,
|
|
291
|
+
"optional": false,
|
|
292
|
+
"docs": {
|
|
293
|
+
"tags": [],
|
|
294
|
+
"text": ""
|
|
295
|
+
},
|
|
296
|
+
"getter": false,
|
|
297
|
+
"setter": false,
|
|
298
|
+
"reflect": false,
|
|
299
|
+
"attribute": "aria-label",
|
|
300
|
+
"defaultValue": "null"
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
static get states() {
|
|
305
|
+
return {
|
|
306
|
+
"fieldDisabled": {}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
static get events() {
|
|
310
|
+
return [{
|
|
311
|
+
"method": "qInput",
|
|
312
|
+
"name": "qInput",
|
|
313
|
+
"bubbles": true,
|
|
314
|
+
"cancelable": true,
|
|
315
|
+
"composed": true,
|
|
316
|
+
"docs": {
|
|
317
|
+
"tags": [],
|
|
318
|
+
"text": "Numeric value emitted continuously while dragging or using the keyboard."
|
|
319
|
+
},
|
|
320
|
+
"complexType": {
|
|
321
|
+
"original": "number",
|
|
322
|
+
"resolved": "number",
|
|
323
|
+
"references": {}
|
|
324
|
+
}
|
|
325
|
+
}, {
|
|
326
|
+
"method": "qChange",
|
|
327
|
+
"name": "qChange",
|
|
328
|
+
"bubbles": true,
|
|
329
|
+
"cancelable": true,
|
|
330
|
+
"composed": true,
|
|
331
|
+
"docs": {
|
|
332
|
+
"tags": [],
|
|
333
|
+
"text": "Numeric value emitted when the interaction is committed."
|
|
334
|
+
},
|
|
335
|
+
"complexType": {
|
|
336
|
+
"original": "number",
|
|
337
|
+
"resolved": "number",
|
|
338
|
+
"references": {}
|
|
339
|
+
}
|
|
340
|
+
}];
|
|
341
|
+
}
|
|
342
|
+
static get methods() {
|
|
343
|
+
return {
|
|
344
|
+
"focusElement": {
|
|
345
|
+
"complexType": {
|
|
346
|
+
"signature": "() => Promise<void>",
|
|
347
|
+
"parameters": [],
|
|
348
|
+
"references": {
|
|
349
|
+
"Promise": {
|
|
350
|
+
"location": "global",
|
|
351
|
+
"id": "global::Promise"
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"return": "Promise<void>"
|
|
355
|
+
},
|
|
356
|
+
"docs": {
|
|
357
|
+
"text": "",
|
|
358
|
+
"tags": []
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
static get elementRef() { return "el"; }
|
|
364
|
+
static get watchers() {
|
|
365
|
+
return [{
|
|
366
|
+
"propName": "value",
|
|
367
|
+
"methodName": "constraintsChanged"
|
|
368
|
+
}, {
|
|
369
|
+
"propName": "min",
|
|
370
|
+
"methodName": "constraintsChanged"
|
|
371
|
+
}, {
|
|
372
|
+
"propName": "max",
|
|
373
|
+
"methodName": "constraintsChanged"
|
|
374
|
+
}, {
|
|
375
|
+
"propName": "step",
|
|
376
|
+
"methodName": "constraintsChanged"
|
|
377
|
+
}, {
|
|
378
|
+
"propName": "disabled",
|
|
379
|
+
"methodName": "disabledChanged"
|
|
380
|
+
}];
|
|
381
|
+
}
|
|
382
|
+
static get attachInternalsMemberName() { return "internals"; }
|
|
383
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { afterEach, beforeAll, expect, it } from "vitest";
|
|
2
|
+
import { userEvent } from "vitest/browser";
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { defineCustomElements } from "../../../../../../packages/browser/components/dist/loader";
|
|
5
|
+
defineCustomElements();
|
|
6
|
+
beforeAll(async () => { await customElements.whenDefined('q-slider'); });
|
|
7
|
+
afterEach(() => document.body.replaceChildren());
|
|
8
|
+
const settle = () => new Promise(resolve => setTimeout(resolve, 30));
|
|
9
|
+
it('supports keyboard, form submission, reset and disabled fieldsets', async () => {
|
|
10
|
+
const form = document.createElement('form');
|
|
11
|
+
form.innerHTML = '<fieldset><q-slider name="gap" label="Gap" min="4" max="40" value="16" suffix="px"></q-slider></fieldset>';
|
|
12
|
+
document.body.append(form);
|
|
13
|
+
const slider = form.querySelector('q-slider');
|
|
14
|
+
await slider.componentOnReady();
|
|
15
|
+
const input = slider.shadowRoot.querySelector('input');
|
|
16
|
+
await userEvent.click(input);
|
|
17
|
+
await userEvent.keyboard('{Home}');
|
|
18
|
+
await settle();
|
|
19
|
+
expect(slider.value).toBe(4);
|
|
20
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
21
|
+
await settle();
|
|
22
|
+
expect(slider.value).toBe(5);
|
|
23
|
+
expect(new FormData(form).get('gap')).toBe('5');
|
|
24
|
+
form.reset();
|
|
25
|
+
await settle();
|
|
26
|
+
expect(slider.value).toBe(16);
|
|
27
|
+
form.querySelector('fieldset').disabled = true;
|
|
28
|
+
await settle();
|
|
29
|
+
expect(input.disabled).toBe(true);
|
|
30
|
+
expect(new FormData(form).has('gap')).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
it('participates in q-form values and theme overrides', async () => {
|
|
33
|
+
const form = document.createElement('q-form');
|
|
34
|
+
form.innerHTML = '<q-slider name="columns" label="Columns" min="1" max="10" value="3"></q-slider>';
|
|
35
|
+
document.body.append(form);
|
|
36
|
+
await form.componentOnReady();
|
|
37
|
+
const slider = form.querySelector('q-slider');
|
|
38
|
+
await slider.componentOnReady();
|
|
39
|
+
await form.setValues({ columns: '7' });
|
|
40
|
+
await settle();
|
|
41
|
+
expect(slider.value).toBe(7);
|
|
42
|
+
expect((await form.getValues()).columns).toBe('7');
|
|
43
|
+
slider.style.setProperty('--q-slider-track-color', 'rgb(10, 20, 30)');
|
|
44
|
+
expect(getComputedStyle(slider.shadowRoot.querySelector('input')).backgroundColor).toBe('rgb(10, 20, 30)');
|
|
45
|
+
});
|
|
@@ -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"; }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--_q-divider-inset: var(--q-divider-inset, var(--q-space-sm, .5rem));
|
|
3
|
+
--_q-divider-usable: max(0px, calc(100% - var(--_q-divider-inset) - var(--_q-divider-inset)));
|
|
4
|
+
--_q-divider-thickness: var(--q-divider-thickness, 1px);
|
|
5
|
+
position: relative;
|
|
6
|
+
display: block;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
min-width: 0;
|
|
9
|
+
min-height: 0;
|
|
10
|
+
height: var(--_q-divider-thickness);
|
|
11
|
+
align-self: stretch;
|
|
12
|
+
flex: 0 0 auto;
|
|
13
|
+
margin-block: var(--_q-divider-spacing, 0px);
|
|
14
|
+
}
|
|
15
|
+
[part='line'] {
|
|
16
|
+
position: absolute;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
top: 50%;
|
|
19
|
+
left: 50%;
|
|
20
|
+
transform: translate(-50%, -50%);
|
|
21
|
+
width: clamp(0px, var(--_q-divider-length, 100%), var(--_q-divider-usable));
|
|
22
|
+
height: 0;
|
|
23
|
+
border: 0 solid var(--q-divider-color, var(--q-border-color, #374151));
|
|
24
|
+
border-top-width: var(--_q-divider-thickness);
|
|
25
|
+
}
|
|
26
|
+
:host([orientation='vertical']) {
|
|
27
|
+
width: var(--_q-divider-thickness);
|
|
28
|
+
height: auto;
|
|
29
|
+
margin-block: 0;
|
|
30
|
+
margin-inline: var(--_q-divider-spacing, 0px);
|
|
31
|
+
}
|
|
32
|
+
:host([orientation='vertical']) [part='line'] {
|
|
33
|
+
width: 0;
|
|
34
|
+
height: clamp(0px, var(--_q-divider-length, 100%), var(--_q-divider-usable));
|
|
35
|
+
border-top-width: 0;
|
|
36
|
+
border-left-width: var(--_q-divider-thickness);
|
|
37
|
+
}
|
|
38
|
+
@media (forced-colors: active) {
|
|
39
|
+
[part='line'] { border-color: CanvasText; }
|
|
40
|
+
}
|