@quieto/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +142 -2
- package/custom-elements.json +6126 -0
- package/dist/components/qds-accordion/qds-accordion.d.ts +39 -0
- package/dist/components/qds-accordion/qds-accordion.d.ts.map +1 -0
- package/dist/components/qds-accordion/qds-accordion.js +130 -0
- package/dist/components/qds-accordion/qds-accordion.js.map +1 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.d.ts +68 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.d.ts.map +1 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.js +247 -0
- package/dist/components/qds-accordion-item/qds-accordion-item.js.map +1 -0
- package/dist/components/qds-button/qds-button.d.ts +92 -0
- package/dist/components/qds-button/qds-button.d.ts.map +1 -0
- package/dist/components/qds-button/qds-button.js +418 -0
- package/dist/components/qds-button/qds-button.js.map +1 -0
- package/dist/components/qds-card/qds-card.d.ts +48 -0
- package/dist/components/qds-card/qds-card.d.ts.map +1 -0
- package/dist/components/qds-card/qds-card.js +152 -0
- package/dist/components/qds-card/qds-card.js.map +1 -0
- package/dist/components/qds-checkbox/qds-checkbox.d.ts +85 -0
- package/dist/components/qds-checkbox/qds-checkbox.d.ts.map +1 -0
- package/dist/components/qds-checkbox/qds-checkbox.js +316 -0
- package/dist/components/qds-checkbox/qds-checkbox.js.map +1 -0
- package/dist/components/qds-chip/qds-chip.d.ts +79 -0
- package/dist/components/qds-chip/qds-chip.d.ts.map +1 -0
- package/dist/components/qds-chip/qds-chip.js +314 -0
- package/dist/components/qds-chip/qds-chip.js.map +1 -0
- package/dist/components/qds-input/qds-input.d.ts +64 -0
- package/dist/components/qds-input/qds-input.d.ts.map +1 -0
- package/dist/components/qds-input/qds-input.js +224 -0
- package/dist/components/qds-input/qds-input.js.map +1 -0
- package/dist/components/qds-modal/qds-modal.d.ts +76 -0
- package/dist/components/qds-modal/qds-modal.d.ts.map +1 -0
- package/dist/components/qds-modal/qds-modal.js +362 -0
- package/dist/components/qds-modal/qds-modal.js.map +1 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.d.ts +47 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.d.ts.map +1 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.js +180 -0
- package/dist/components/qds-progress-bar/qds-progress-bar.js.map +1 -0
- package/dist/components/qds-radio/qds-radio.d.ts +62 -0
- package/dist/components/qds-radio/qds-radio.d.ts.map +1 -0
- package/dist/components/qds-radio/qds-radio.js +213 -0
- package/dist/components/qds-radio/qds-radio.js.map +1 -0
- package/dist/components/qds-radio-group/qds-radio-group.d.ts +72 -0
- package/dist/components/qds-radio-group/qds-radio-group.d.ts.map +1 -0
- package/dist/components/qds-radio-group/qds-radio-group.js +317 -0
- package/dist/components/qds-radio-group/qds-radio-group.js.map +1 -0
- package/dist/components/qds-stack/qds-stack.d.ts +46 -0
- package/dist/components/qds-stack/qds-stack.d.ts.map +1 -0
- package/dist/components/qds-stack/qds-stack.js +149 -0
- package/dist/components/qds-stack/qds-stack.js.map +1 -0
- package/dist/components/qds-tab/qds-tab.d.ts +55 -0
- package/dist/components/qds-tab/qds-tab.d.ts.map +1 -0
- package/dist/components/qds-tab/qds-tab.js +162 -0
- package/dist/components/qds-tab/qds-tab.js.map +1 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.d.ts +32 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.d.ts.map +1 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.js +72 -0
- package/dist/components/qds-tab-panel/qds-tab-panel.js.map +1 -0
- package/dist/components/qds-tabs/qds-tabs.d.ts +54 -0
- package/dist/components/qds-tabs/qds-tabs.d.ts.map +1 -0
- package/dist/components/qds-tabs/qds-tabs.js +196 -0
- package/dist/components/qds-tabs/qds-tabs.js.map +1 -0
- package/dist/components/qds-text-field/qds-text-field.d.ts +94 -0
- package/dist/components/qds-text-field/qds-text-field.d.ts.map +1 -0
- package/dist/components/qds-text-field/qds-text-field.js +332 -0
- package/dist/components/qds-text-field/qds-text-field.js.map +1 -0
- package/dist/components/qds-toggle/qds-toggle.d.ts +68 -0
- package/dist/components/qds-toggle/qds-toggle.d.ts.map +1 -0
- package/dist/components/qds-toggle/qds-toggle.js +260 -0
- package/dist/components/qds-toggle/qds-toggle.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/qds-element.d.ts +31 -0
- package/dist/internal/qds-element.d.ts.map +1 -0
- package/dist/internal/qds-element.js +68 -0
- package/dist/internal/qds-element.js.map +1 -0
- package/dist/internal/qds-text-control.d.ts +79 -0
- package/dist/internal/qds-text-control.d.ts.map +1 -0
- package/dist/internal/qds-text-control.js +159 -0
- package/dist/internal/qds-text-control.js.map +1 -0
- package/package.json +125 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* A checkbox.
|
|
5
|
+
*
|
|
6
|
+
* A native `<input type="checkbox">` sits inside the shadow root, visually
|
|
7
|
+
* hidden, with a token-styled box drawn over it. Keeping the native input is
|
|
8
|
+
* what gives the component keyboard handling, `indeterminate`, and a correct
|
|
9
|
+
* accessibility role for free; the drawn box is purely presentational.
|
|
10
|
+
*
|
|
11
|
+
* @element qds-checkbox
|
|
12
|
+
*
|
|
13
|
+
* @slot - The label.
|
|
14
|
+
*
|
|
15
|
+
* @fires {CustomEvent<{ checked: boolean }>} qds-change - Fired when the user
|
|
16
|
+
* toggles the checkbox. Not fired for programmatic changes.
|
|
17
|
+
*
|
|
18
|
+
* @csspart base - The label element wrapping the control and its text.
|
|
19
|
+
* @csspart control - The drawn box.
|
|
20
|
+
* @csspart label - The wrapper around the default slot.
|
|
21
|
+
*
|
|
22
|
+
* @cssprop [--qds-component-checkbox-gap] - Space between the box and the label.
|
|
23
|
+
* @cssprop [--qds-component-checkbox-font-size] - Label size.
|
|
24
|
+
* @cssprop [--qds-component-checkbox-line-height] - Label line height.
|
|
25
|
+
* @cssprop [--qds-component-checkbox-duration] - State transition duration.
|
|
26
|
+
* @cssprop [--qds-component-checkbox-control-width] - Box width.
|
|
27
|
+
* @cssprop [--qds-component-checkbox-control-height] - Box height.
|
|
28
|
+
* @cssprop [--qds-component-checkbox-control-border-radius] - Box corner radius.
|
|
29
|
+
* @cssprop [--qds-component-checkbox-control-border-width] - Box border thickness.
|
|
30
|
+
* @cssprop [--qds-component-checkbox-control-color-background-{state}] - Box fill: `unchecked`, `checked`, `hover` (checked, under the pointer), `disabled`.
|
|
31
|
+
* @cssprop [--qds-component-checkbox-control-color-border-{state}] - Box border: `unchecked`, `hover` (unchecked, under the pointer), `checked`, `disabled`.
|
|
32
|
+
* @cssprop [--qds-component-checkbox-control-color-content-{state}] - Check mark color: `checked`, `disabled`.
|
|
33
|
+
* @cssprop [--qds-component-checkbox-label-color-content-{state}] - Label color: `rest`, `disabled`.
|
|
34
|
+
*/
|
|
35
|
+
export declare class QdsCheckbox extends QdsElement {
|
|
36
|
+
#private;
|
|
37
|
+
static shadowRootOptions: ShadowRootInit;
|
|
38
|
+
static formAssociated: boolean;
|
|
39
|
+
static styles: import("lit").CSSResult[];
|
|
40
|
+
/** Whether the box is checked. The `checked` attribute sets the initial state, restored on form reset. */
|
|
41
|
+
checked: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Shows a dash instead of a check, for a parent checkbox whose children are
|
|
44
|
+
* partly checked. Cleared as soon as the user toggles the box, like the native
|
|
45
|
+
* property.
|
|
46
|
+
*/
|
|
47
|
+
indeterminate: boolean;
|
|
48
|
+
/** Prevents interaction and excludes the value from form submission. */
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
/** Makes the form invalid until the box is checked. */
|
|
51
|
+
required: boolean;
|
|
52
|
+
/** Field name used when the form is submitted. */
|
|
53
|
+
name: string;
|
|
54
|
+
/** Value submitted when checked. */
|
|
55
|
+
value: string;
|
|
56
|
+
private readonly input;
|
|
57
|
+
/**
|
|
58
|
+
* Disabled by the form machinery: this element's own attribute OR an ancestor
|
|
59
|
+
* `<fieldset disabled>`. Kept apart from `disabled` so that re-enabling the
|
|
60
|
+
* fieldset does not clear a checkbox that was disabled on its own.
|
|
61
|
+
*/
|
|
62
|
+
private formDisabled;
|
|
63
|
+
constructor();
|
|
64
|
+
/** The form this checkbox belongs to, if any. */
|
|
65
|
+
get form(): HTMLFormElement | null;
|
|
66
|
+
/** Same as the native `checkValidity()`. */
|
|
67
|
+
checkValidity(): boolean;
|
|
68
|
+
/** Same as the native `reportValidity()`. */
|
|
69
|
+
reportValidity(): boolean;
|
|
70
|
+
/** Same as the native `validity`. */
|
|
71
|
+
get validity(): ValidityState;
|
|
72
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
73
|
+
protected updated(): void;
|
|
74
|
+
/** Called by the form on reset: restore the state the markup declared. */
|
|
75
|
+
formResetCallback(): void;
|
|
76
|
+
/** Called when this element's disabled state changes, from its own attribute or a fieldset. */
|
|
77
|
+
formDisabledCallback(disabled: boolean): void;
|
|
78
|
+
render(): TemplateResult;
|
|
79
|
+
}
|
|
80
|
+
declare global {
|
|
81
|
+
interface HTMLElementTagNameMap {
|
|
82
|
+
'qds-checkbox': QdsCheckbox;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=qds-checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/qds-checkbox/qds-checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG1E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBACa,WAAY,SAAQ,UAAU;;IACzC,OAAgB,iBAAiB,EAAE,cAAc,CAG/C;IAEF,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAgB,MAAM,4BAiIpB;IAEF,0GAA0G;IAE1G,OAAO,UAAS;IAEhB;;;;OAIG;IAEH,aAAa,UAAS;IAEtB,wEAAwE;IAExE,QAAQ,UAAS;IAEjB,uDAAuD;IAEvD,QAAQ,UAAS;IAEjB,kDAAkD;IAElD,IAAI,SAAM;IAEV,oCAAoC;IAEpC,KAAK,SAAQ;IAGb,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAE1C;;;;OAIG;IAEH,OAAO,CAAC,YAAY,CAAS;;IAS7B,iDAAiD;IACjD,IAAI,IAAI,IAAI,eAAe,GAAG,IAAI,CAEjC;IAED,4CAA4C;IAC5C,aAAa,IAAI,OAAO;IAIxB,6CAA6C;IAC7C,cAAc,IAAI,OAAO;IAIzB,qCAAqC;IACrC,IAAI,QAAQ,IAAI,aAAa,CAE5B;cAEkB,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;cAM/C,OAAO,IAAI,IAAI;IAqBlC,0EAA0E;IAC1E,iBAAiB,IAAI,IAAI;IAKzB,+FAA+F;IAC/F,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAoBpC,MAAM,IAAI,cAAc;CAuBlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { css, html } from 'lit';
|
|
8
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
10
|
+
/**
|
|
11
|
+
* A checkbox.
|
|
12
|
+
*
|
|
13
|
+
* A native `<input type="checkbox">` sits inside the shadow root, visually
|
|
14
|
+
* hidden, with a token-styled box drawn over it. Keeping the native input is
|
|
15
|
+
* what gives the component keyboard handling, `indeterminate`, and a correct
|
|
16
|
+
* accessibility role for free; the drawn box is purely presentational.
|
|
17
|
+
*
|
|
18
|
+
* @element qds-checkbox
|
|
19
|
+
*
|
|
20
|
+
* @slot - The label.
|
|
21
|
+
*
|
|
22
|
+
* @fires {CustomEvent<{ checked: boolean }>} qds-change - Fired when the user
|
|
23
|
+
* toggles the checkbox. Not fired for programmatic changes.
|
|
24
|
+
*
|
|
25
|
+
* @csspart base - The label element wrapping the control and its text.
|
|
26
|
+
* @csspart control - The drawn box.
|
|
27
|
+
* @csspart label - The wrapper around the default slot.
|
|
28
|
+
*
|
|
29
|
+
* @cssprop [--qds-component-checkbox-gap] - Space between the box and the label.
|
|
30
|
+
* @cssprop [--qds-component-checkbox-font-size] - Label size.
|
|
31
|
+
* @cssprop [--qds-component-checkbox-line-height] - Label line height.
|
|
32
|
+
* @cssprop [--qds-component-checkbox-duration] - State transition duration.
|
|
33
|
+
* @cssprop [--qds-component-checkbox-control-width] - Box width.
|
|
34
|
+
* @cssprop [--qds-component-checkbox-control-height] - Box height.
|
|
35
|
+
* @cssprop [--qds-component-checkbox-control-border-radius] - Box corner radius.
|
|
36
|
+
* @cssprop [--qds-component-checkbox-control-border-width] - Box border thickness.
|
|
37
|
+
* @cssprop [--qds-component-checkbox-control-color-background-{state}] - Box fill: `unchecked`, `checked`, `hover` (checked, under the pointer), `disabled`.
|
|
38
|
+
* @cssprop [--qds-component-checkbox-control-color-border-{state}] - Box border: `unchecked`, `hover` (unchecked, under the pointer), `checked`, `disabled`.
|
|
39
|
+
* @cssprop [--qds-component-checkbox-control-color-content-{state}] - Check mark color: `checked`, `disabled`.
|
|
40
|
+
* @cssprop [--qds-component-checkbox-label-color-content-{state}] - Label color: `rest`, `disabled`.
|
|
41
|
+
*/
|
|
42
|
+
let QdsCheckbox = class QdsCheckbox extends QdsElement {
|
|
43
|
+
static { this.shadowRootOptions = {
|
|
44
|
+
...QdsElement.shadowRootOptions,
|
|
45
|
+
delegatesFocus: true,
|
|
46
|
+
}; }
|
|
47
|
+
static { this.formAssociated = true; }
|
|
48
|
+
static { this.styles = [
|
|
49
|
+
QdsElement.baseStyles,
|
|
50
|
+
css `
|
|
51
|
+
:host {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
label {
|
|
56
|
+
position: relative;
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: flex-start;
|
|
59
|
+
gap: var(--qds-component-checkbox-gap, 0.5rem);
|
|
60
|
+
|
|
61
|
+
font-family: var(--qds-typography-font-family-sans, inherit);
|
|
62
|
+
font-size: var(--qds-component-checkbox-font-size, 0.875rem);
|
|
63
|
+
line-height: var(--qds-component-checkbox-line-height, 1.375);
|
|
64
|
+
color: var(--qds-component-checkbox-label-color-content-rest, #0f172a);
|
|
65
|
+
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* Visually hidden, not display:none: the native input has to stay focusable
|
|
71
|
+
* and in the accessibility tree, since it is the actual control.
|
|
72
|
+
*/
|
|
73
|
+
input {
|
|
74
|
+
position: absolute;
|
|
75
|
+
inset-block-start: 0;
|
|
76
|
+
inset-inline-start: 0;
|
|
77
|
+
width: var(--qds-component-checkbox-control-width, 1rem);
|
|
78
|
+
height: var(--qds-component-checkbox-control-height, 1rem);
|
|
79
|
+
margin: 0;
|
|
80
|
+
opacity: 0;
|
|
81
|
+
cursor: inherit;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.control {
|
|
85
|
+
display: inline-grid;
|
|
86
|
+
place-items: center;
|
|
87
|
+
flex: none;
|
|
88
|
+
width: var(--qds-component-checkbox-control-width, 1rem);
|
|
89
|
+
height: var(--qds-component-checkbox-control-height, 1rem);
|
|
90
|
+
/* Centre the box on the first line of the label, however tall the text. */
|
|
91
|
+
margin-block-start: calc((1lh - var(--qds-component-checkbox-control-height, 1rem)) / 2);
|
|
92
|
+
|
|
93
|
+
color: var(--qds-component-checkbox-control-color-content-checked, #f8fafc);
|
|
94
|
+
background-color: var(--qds-component-checkbox-control-color-background-unchecked, #f8fafc);
|
|
95
|
+
border: var(--qds-component-checkbox-control-border-width, 0.0625rem) solid
|
|
96
|
+
var(--qds-component-checkbox-control-color-border-unchecked, #64748b);
|
|
97
|
+
border-radius: var(--qds-component-checkbox-control-border-radius, 0.25rem);
|
|
98
|
+
|
|
99
|
+
transition:
|
|
100
|
+
background-color var(--qds-component-checkbox-duration, 120ms),
|
|
101
|
+
border-color var(--qds-component-checkbox-duration, 120ms);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Both marks share the one grid cell; only one is ever visible. */
|
|
105
|
+
.mark {
|
|
106
|
+
grid-area: 1 / 1;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
visibility: hidden;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:where(label:hover) .control {
|
|
113
|
+
border-color: var(--qds-component-checkbox-control-color-border-hover, #2563eb);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
input:checked + .control,
|
|
117
|
+
input:indeterminate + .control {
|
|
118
|
+
background-color: var(--qds-component-checkbox-control-color-background-checked, #2563eb);
|
|
119
|
+
border-color: var(--qds-component-checkbox-control-color-border-checked, #2563eb);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
:where(label:hover) input:checked + .control,
|
|
123
|
+
:where(label:hover) input:indeterminate + .control {
|
|
124
|
+
background-color: var(--qds-component-checkbox-control-color-background-hover, #1d4ed8);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
input:checked:not(:indeterminate) + .control .check,
|
|
128
|
+
input:indeterminate + .control .dash {
|
|
129
|
+
visibility: visible;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
input:focus-visible + .control {
|
|
133
|
+
outline: var(--_focus-ring);
|
|
134
|
+
outline-offset: 0.125rem;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/*
|
|
138
|
+
* :disabled rather than [disabled]: a form-associated element matches it
|
|
139
|
+
* when either its own attribute or an ancestor fieldset disables it.
|
|
140
|
+
*/
|
|
141
|
+
:host(:disabled) label {
|
|
142
|
+
color: var(--qds-component-checkbox-label-color-content-disabled, #64748b);
|
|
143
|
+
cursor: not-allowed;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
:host(:disabled) .control,
|
|
147
|
+
:host(:disabled) input:checked + .control,
|
|
148
|
+
:host(:disabled) input:indeterminate + .control {
|
|
149
|
+
color: var(--qds-component-checkbox-control-color-content-disabled, #64748b);
|
|
150
|
+
background-color: var(--qds-component-checkbox-control-color-background-disabled, #f1f5f9);
|
|
151
|
+
border-color: var(--qds-component-checkbox-control-color-border-disabled, #e2e8f0);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@media (prefers-reduced-motion: reduce) {
|
|
155
|
+
.control {
|
|
156
|
+
transition: none;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/*
|
|
161
|
+
* Forced colors discards the drawn box's fill, so a checked box would be
|
|
162
|
+
* indistinguishable from an unchecked one apart from the mark. Give the mark
|
|
163
|
+
* a system color, and keep the border visible.
|
|
164
|
+
*/
|
|
165
|
+
@media (forced-colors: active) {
|
|
166
|
+
.control {
|
|
167
|
+
border-color: ButtonText;
|
|
168
|
+
color: Highlight;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
:host(:disabled) .control {
|
|
172
|
+
border-color: GrayText;
|
|
173
|
+
color: GrayText;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
`,
|
|
177
|
+
]; }
|
|
178
|
+
#internals;
|
|
179
|
+
constructor() {
|
|
180
|
+
super();
|
|
181
|
+
/** Whether the box is checked. The `checked` attribute sets the initial state, restored on form reset. */
|
|
182
|
+
this.checked = false;
|
|
183
|
+
/**
|
|
184
|
+
* Shows a dash instead of a check, for a parent checkbox whose children are
|
|
185
|
+
* partly checked. Cleared as soon as the user toggles the box, like the native
|
|
186
|
+
* property.
|
|
187
|
+
*/
|
|
188
|
+
this.indeterminate = false;
|
|
189
|
+
/** Prevents interaction and excludes the value from form submission. */
|
|
190
|
+
this.disabled = false;
|
|
191
|
+
/** Makes the form invalid until the box is checked. */
|
|
192
|
+
this.required = false;
|
|
193
|
+
/** Field name used when the form is submitted. */
|
|
194
|
+
this.name = '';
|
|
195
|
+
/** Value submitted when checked. */
|
|
196
|
+
this.value = 'on';
|
|
197
|
+
/**
|
|
198
|
+
* Disabled by the form machinery: this element's own attribute OR an ancestor
|
|
199
|
+
* `<fieldset disabled>`. Kept apart from `disabled` so that re-enabling the
|
|
200
|
+
* fieldset does not clear a checkbox that was disabled on its own.
|
|
201
|
+
*/
|
|
202
|
+
this.formDisabled = false;
|
|
203
|
+
this.#internals = this.attachInternals();
|
|
204
|
+
}
|
|
205
|
+
/** The form this checkbox belongs to, if any. */
|
|
206
|
+
get form() {
|
|
207
|
+
return this.#internals.form;
|
|
208
|
+
}
|
|
209
|
+
/** Same as the native `checkValidity()`. */
|
|
210
|
+
checkValidity() {
|
|
211
|
+
return this.#internals.checkValidity();
|
|
212
|
+
}
|
|
213
|
+
/** Same as the native `reportValidity()`. */
|
|
214
|
+
reportValidity() {
|
|
215
|
+
return this.#internals.reportValidity();
|
|
216
|
+
}
|
|
217
|
+
/** Same as the native `validity`. */
|
|
218
|
+
get validity() {
|
|
219
|
+
return this.#internals.validity;
|
|
220
|
+
}
|
|
221
|
+
willUpdate(changed) {
|
|
222
|
+
if (changed.has('checked') || changed.has('value')) {
|
|
223
|
+
this.#internals.setFormValue(this.checked ? this.value : null);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
updated() {
|
|
227
|
+
this.#syncValidity();
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Validity is anchored to the native input so reportValidity() points the
|
|
231
|
+
* browser's bubble at the box rather than the host's corner. Not run before the
|
|
232
|
+
* first render, because the input does not exist until then.
|
|
233
|
+
*/
|
|
234
|
+
#syncValidity() {
|
|
235
|
+
if (this.required && !this.checked) {
|
|
236
|
+
this.#internals.setValidity({ valueMissing: true }, this.input.validationMessage || 'Check this box to continue.', this.input);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.#internals.setValidity({});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/** Called by the form on reset: restore the state the markup declared. */
|
|
243
|
+
formResetCallback() {
|
|
244
|
+
this.checked = this.hasAttribute('checked');
|
|
245
|
+
this.indeterminate = false;
|
|
246
|
+
}
|
|
247
|
+
/** Called when this element's disabled state changes, from its own attribute or a fieldset. */
|
|
248
|
+
formDisabledCallback(disabled) {
|
|
249
|
+
this.formDisabled = disabled;
|
|
250
|
+
}
|
|
251
|
+
#handleChange() {
|
|
252
|
+
this.checked = this.input.checked;
|
|
253
|
+
this.indeterminate = false;
|
|
254
|
+
// Synchronously, not left to willUpdate and updated: a qds-change listener
|
|
255
|
+
// reading FormData or validity would otherwise see the previous state.
|
|
256
|
+
this.#internals.setFormValue(this.checked ? this.value : null);
|
|
257
|
+
this.#syncValidity();
|
|
258
|
+
this.dispatchEvent(new CustomEvent('qds-change', {
|
|
259
|
+
detail: { checked: this.checked },
|
|
260
|
+
bubbles: true,
|
|
261
|
+
composed: true,
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
render() {
|
|
265
|
+
return html `
|
|
266
|
+
<label part="base">
|
|
267
|
+
<input
|
|
268
|
+
type="checkbox"
|
|
269
|
+
.checked=${this.checked}
|
|
270
|
+
.indeterminate=${this.indeterminate}
|
|
271
|
+
?disabled=${this.disabled || this.formDisabled}
|
|
272
|
+
?required=${this.required}
|
|
273
|
+
@change=${this.#handleChange}
|
|
274
|
+
/>
|
|
275
|
+
<span class="control" part="control" aria-hidden="true">
|
|
276
|
+
<svg class="mark check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
277
|
+
<polyline points="3.5 8.5 6.5 11.5 12.5 4.5"></polyline>
|
|
278
|
+
</svg>
|
|
279
|
+
<svg class="mark dash" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
280
|
+
<line x1="4" y1="8" x2="12" y2="8"></line>
|
|
281
|
+
</svg>
|
|
282
|
+
</span>
|
|
283
|
+
<span part="label"><slot></slot></span>
|
|
284
|
+
</label>
|
|
285
|
+
`;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
__decorate([
|
|
289
|
+
property({ type: Boolean })
|
|
290
|
+
], QdsCheckbox.prototype, "checked", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
property({ type: Boolean, reflect: true })
|
|
293
|
+
], QdsCheckbox.prototype, "indeterminate", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
property({ type: Boolean, reflect: true })
|
|
296
|
+
], QdsCheckbox.prototype, "disabled", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
property({ type: Boolean, reflect: true })
|
|
299
|
+
], QdsCheckbox.prototype, "required", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
property()
|
|
302
|
+
], QdsCheckbox.prototype, "name", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
property()
|
|
305
|
+
], QdsCheckbox.prototype, "value", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
query('input')
|
|
308
|
+
], QdsCheckbox.prototype, "input", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
state()
|
|
311
|
+
], QdsCheckbox.prototype, "formDisabled", void 0);
|
|
312
|
+
QdsCheckbox = __decorate([
|
|
313
|
+
customElement('qds-checkbox')
|
|
314
|
+
], QdsCheckbox);
|
|
315
|
+
export { QdsCheckbox };
|
|
316
|
+
//# sourceMappingURL=qds-checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-checkbox.js","sourceRoot":"","sources":["../../../src/components/qds-checkbox/qds-checkbox.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAA4C,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;aACzB,sBAAiB,GAAmB;QAClD,GAAG,UAAU,CAAC,iBAAiB;QAC/B,cAAc,EAAE,IAAI;KACrB,AAHgC,CAG/B;aAEK,mBAAc,GAAG,IAAI,AAAP,CAAQ;aAEb,WAAM,GAAG;QACvB,UAAU,CAAC,UAAU;QACrB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8HF;KACF,AAjIqB,CAiIpB;IAyCO,UAAU,CAAmB;IAEtC;QACE,KAAK,EAAE,CAAC;QA1CV,0GAA0G;QAE1G,YAAO,GAAG,KAAK,CAAC;QAEhB;;;;WAIG;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AAE,OAAO,EAAE,CAAC;4CACZ;AAQhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDACrB;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAC1B;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAC1B;AAIjB;IADC,QAAQ,EAAE;yCACD;AAIV;IADC,QAAQ,EAAE;0CACE;AAGI;IADhB,KAAK,CAAC,OAAO,CAAC;0CAC2B;AAQlC;IADP,KAAK,EAAE;iDACqB;AAhLlB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA0RvB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
export type QdsChipVariant = 'neutral' | 'info' | 'success' | 'warning' | 'error';
|
|
4
|
+
/**
|
|
5
|
+
* A compact label for a status, category, or applied filter.
|
|
6
|
+
*
|
|
7
|
+
* A chip is not interactive on its own. With `removable` it gains a remove
|
|
8
|
+
* button — the only focusable thing in it — which fires `qds-remove` and leaves
|
|
9
|
+
* the decision to the page: the chip does not delete itself, because the page
|
|
10
|
+
* usually needs to update its own state (a filter list, a set of tags) first.
|
|
11
|
+
*
|
|
12
|
+
* With `selectable` it becomes a filter chip instead: the whole chip is a toggle
|
|
13
|
+
* button, announced as pressed or not, showing a check mark while selected.
|
|
14
|
+
* Wrap a set of them in an element with `role="group"` and an `aria-label` so
|
|
15
|
+
* the set is announced together. A selectable chip ignores `removable`, since a
|
|
16
|
+
* button cannot contain another button.
|
|
17
|
+
*
|
|
18
|
+
* Meaning is never carried by color alone: the variant tints the chip, but the
|
|
19
|
+
* text has to say what it means.
|
|
20
|
+
*
|
|
21
|
+
* @element qds-chip
|
|
22
|
+
*
|
|
23
|
+
* @slot - The chip text.
|
|
24
|
+
* @slot start - Content before the text, typically an icon.
|
|
25
|
+
*
|
|
26
|
+
* @fires {CustomEvent<void>} qds-remove - Fired when the remove button is
|
|
27
|
+
* activated. The chip stays in the DOM; remove it in the handler.
|
|
28
|
+
* @fires {CustomEvent<{ selected: boolean }>} qds-change - Fired when the user
|
|
29
|
+
* toggles a selectable chip. Not fired for programmatic changes.
|
|
30
|
+
*
|
|
31
|
+
* @csspart base - The chip body. A button when the chip is selectable.
|
|
32
|
+
* @csspart label - The wrapper around the default slot.
|
|
33
|
+
* @csspart remove - The remove button.
|
|
34
|
+
*
|
|
35
|
+
* @cssprop [--qds-component-chip-gap] - Space between the icon, text, and remove button.
|
|
36
|
+
* @cssprop [--qds-component-chip-padding-block] - Vertical padding.
|
|
37
|
+
* @cssprop [--qds-component-chip-padding-inline] - Horizontal padding.
|
|
38
|
+
* @cssprop [--qds-component-chip-border-radius] - Corner radius.
|
|
39
|
+
* @cssprop [--qds-component-chip-border-width] - Border thickness.
|
|
40
|
+
* @cssprop [--qds-component-chip-font-size] - Text size.
|
|
41
|
+
* @cssprop [--qds-component-chip-font-weight] - Text weight.
|
|
42
|
+
* @cssprop [--qds-component-chip-line-height] - Text line height.
|
|
43
|
+
* @cssprop [--qds-component-chip-{variant}-color-background-rest] - Fill per variant.
|
|
44
|
+
* @cssprop [--qds-component-chip-{variant}-color-content-rest] - Text color per variant.
|
|
45
|
+
* @cssprop [--qds-component-chip-{variant}-color-border-rest] - Border color per variant.
|
|
46
|
+
* @cssprop [--qds-component-chip-selectable-color-border-rest] - Border of an unselected selectable chip.
|
|
47
|
+
* @cssprop [--qds-component-chip-selectable-color-background-hover] - Fill of an unselected selectable chip under the pointer.
|
|
48
|
+
* @cssprop [--qds-component-chip-selected-color-background-{state}] - Fill of a selected chip: `rest`, `hover`.
|
|
49
|
+
* @cssprop [--qds-component-chip-selected-color-content-rest] - Text of a selected chip.
|
|
50
|
+
* @cssprop [--qds-component-chip-selected-color-border-rest] - Border of a selected chip.
|
|
51
|
+
*/
|
|
52
|
+
export declare class QdsChip extends QdsElement {
|
|
53
|
+
#private;
|
|
54
|
+
static styles: import("lit").CSSResult[];
|
|
55
|
+
/** Tone. Pair it with text that states the meaning; color alone does not. */
|
|
56
|
+
variant: QdsChipVariant;
|
|
57
|
+
/** Makes the chip a toggle button, for filtering. */
|
|
58
|
+
selectable: boolean;
|
|
59
|
+
/** Whether a selectable chip is selected. */
|
|
60
|
+
selected: boolean;
|
|
61
|
+
/** Prevents toggling a selectable chip. */
|
|
62
|
+
disabled: boolean;
|
|
63
|
+
/** Adds a remove button that fires `qds-remove`. Ignored when `selectable`. */
|
|
64
|
+
removable: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Accessible name for the remove button. Defaults to "Remove" followed by the
|
|
67
|
+
* chip's text, so a list of chips does not read as a list of identical
|
|
68
|
+
* "Remove" buttons. Set it when the chip text alone would not make sense after
|
|
69
|
+
* "Remove", or to translate it.
|
|
70
|
+
*/
|
|
71
|
+
removeLabel: string;
|
|
72
|
+
render(): TemplateResult;
|
|
73
|
+
}
|
|
74
|
+
declare global {
|
|
75
|
+
interface HTMLElementTagNameMap {
|
|
76
|
+
'qds-chip': QdsChip;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=qds-chip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-chip.d.ts","sourceRoot":"","sources":["../../../src/components/qds-chip/qds-chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBACa,OAAQ,SAAQ,UAAU;;IACrC,OAAgB,MAAM,4BAyJpB;IAEF,6EAA6E;IAE7E,OAAO,EAAE,cAAc,CAAa;IAEpC,qDAAqD;IAErD,UAAU,UAAS;IAEnB,6CAA6C;IAE7C,QAAQ,UAAS;IAEjB,2CAA2C;IAE3C,QAAQ,UAAS;IAEjB,+EAA+E;IAE/E,SAAS,UAAS;IAElB;;;;;OAKG;IAEH,WAAW,SAAM;IAiBR,MAAM,IAAI,cAAc;CAgDlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,OAAO,CAAC;KACrB;CACF"}
|