@quieto/ui 0.0.0-stage → 0.1.1
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 +6121 -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 +250 -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,162 @@
|
|
|
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 } from 'lit/decorators.js';
|
|
9
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
10
|
+
/**
|
|
11
|
+
* One tab in a `qds-tabs` tab list.
|
|
12
|
+
*
|
|
13
|
+
* The host takes the `tab` role itself rather than wrapping a button, because
|
|
14
|
+
* `aria-controls` must point at its panel by ID, and an ID reference only
|
|
15
|
+
* resolves within one tree: the tab host and the `qds-tab-panel` host are both
|
|
16
|
+
* in the light DOM, so the reference works. `qds-tabs` manages the IDs, the
|
|
17
|
+
* selection, and the tab order.
|
|
18
|
+
*
|
|
19
|
+
* The role and states are host attributes, not ElementInternals ARIA. Browsers
|
|
20
|
+
* read either, but auditing tools such as axe only read attributes, and would
|
|
21
|
+
* report a tab list with no tabs in it.
|
|
22
|
+
*
|
|
23
|
+
* Put it in the `tab` slot: `<qds-tab slot="tab">`. If the slot is left off the
|
|
24
|
+
* tab assigns it when it upgrades, but setting it in the markup keeps the tab
|
|
25
|
+
* in the tab list before then, too.
|
|
26
|
+
*
|
|
27
|
+
* @element qds-tab
|
|
28
|
+
*
|
|
29
|
+
* @slot - The tab label.
|
|
30
|
+
*
|
|
31
|
+
* @cssprop [--qds-component-tabs-tab-padding-block] - Vertical padding.
|
|
32
|
+
* @cssprop [--qds-component-tabs-tab-padding-inline] - Horizontal padding.
|
|
33
|
+
* @cssprop [--qds-component-tabs-tab-font-size] - Label size.
|
|
34
|
+
* @cssprop [--qds-component-tabs-tab-font-weight] - Label weight.
|
|
35
|
+
* @cssprop [--qds-component-tabs-tab-line-height] - Label line height.
|
|
36
|
+
* @cssprop [--qds-component-tabs-tab-color-content-{state}] - Label color: `rest`, `hover`, `selected`, `disabled`.
|
|
37
|
+
* @cssprop [--qds-component-tabs-tab-color-background-hover] - Fill under the pointer.
|
|
38
|
+
* @cssprop [--qds-component-tabs-indicator-border-width] - Thickness of the selected tab's underline.
|
|
39
|
+
* @cssprop [--qds-component-tabs-indicator-color-border-selected] - Color of the selected tab's underline.
|
|
40
|
+
* @cssprop [--qds-component-tabs-duration] - Color transition duration.
|
|
41
|
+
*/
|
|
42
|
+
let QdsTab = class QdsTab extends QdsElement {
|
|
43
|
+
static { this.styles = [
|
|
44
|
+
QdsElement.baseStyles,
|
|
45
|
+
css `
|
|
46
|
+
:host {
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
padding: var(--qds-component-tabs-tab-padding-block, 0.5rem)
|
|
50
|
+
var(--qds-component-tabs-tab-padding-inline, 0.75rem);
|
|
51
|
+
|
|
52
|
+
font-family: var(--qds-typography-font-family-sans, inherit);
|
|
53
|
+
font-size: var(--qds-component-tabs-tab-font-size, 0.875rem);
|
|
54
|
+
font-weight: var(--qds-component-tabs-tab-font-weight, 500);
|
|
55
|
+
line-height: var(--qds-component-tabs-tab-line-height, 1.375);
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
color: var(--qds-component-tabs-tab-color-content-rest, #64748b);
|
|
58
|
+
|
|
59
|
+
/* The underline sits over the tab list's own bottom border. */
|
|
60
|
+
margin-block-end: calc(-1 * var(--qds-component-tabs-border-width, 0.0625rem));
|
|
61
|
+
border-block-end: var(--qds-component-tabs-indicator-border-width, 0.125rem) solid
|
|
62
|
+
transparent;
|
|
63
|
+
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
user-select: none;
|
|
66
|
+
transition:
|
|
67
|
+
color var(--qds-component-tabs-duration, 120ms),
|
|
68
|
+
border-color var(--qds-component-tabs-duration, 120ms);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host(:where(:hover)) {
|
|
72
|
+
color: var(--qds-component-tabs-tab-color-content-hover, #0f172a);
|
|
73
|
+
background-color: var(--qds-component-tabs-tab-color-background-hover, #f1f5f9);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([selected]) {
|
|
77
|
+
color: var(--qds-component-tabs-tab-color-content-selected, #1d4ed8);
|
|
78
|
+
border-block-end-color: var(
|
|
79
|
+
--qds-component-tabs-indicator-color-border-selected,
|
|
80
|
+
#2563eb
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
:host(:focus-visible) {
|
|
85
|
+
outline: var(--_focus-ring);
|
|
86
|
+
outline-offset: -0.125rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:host([disabled]) {
|
|
90
|
+
color: var(--qds-component-tabs-tab-color-content-disabled, #94a3b8);
|
|
91
|
+
background: none;
|
|
92
|
+
cursor: not-allowed;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@media (prefers-reduced-motion: reduce) {
|
|
96
|
+
:host {
|
|
97
|
+
transition: none;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* The underline is the only selected cue; give it a system color. */
|
|
102
|
+
@media (forced-colors: active) {
|
|
103
|
+
:host([selected]) {
|
|
104
|
+
border-block-end-color: Highlight;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([disabled]) {
|
|
108
|
+
color: GrayText;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`,
|
|
112
|
+
]; }
|
|
113
|
+
constructor() {
|
|
114
|
+
super();
|
|
115
|
+
/**
|
|
116
|
+
* Whether this tab is the selected one. `qds-tabs` manages this; as an
|
|
117
|
+
* attribute in markup it marks the tab selected initially.
|
|
118
|
+
*/
|
|
119
|
+
this.selected = false;
|
|
120
|
+
/** Prevents selecting this tab. Arrow keys skip it. */
|
|
121
|
+
this.disabled = false;
|
|
122
|
+
this.#handleClick = () => {
|
|
123
|
+
if (this.disabled)
|
|
124
|
+
return;
|
|
125
|
+
this.dispatchEvent(new Event('qds-tab-select', { bubbles: true }));
|
|
126
|
+
};
|
|
127
|
+
this.addEventListener('click', this.#handleClick);
|
|
128
|
+
}
|
|
129
|
+
connectedCallback() {
|
|
130
|
+
super.connectedCallback();
|
|
131
|
+
// Not in the constructor: a custom element must not gain attributes there.
|
|
132
|
+
this.setAttribute('role', 'tab');
|
|
133
|
+
if (!this.slot)
|
|
134
|
+
this.slot = 'tab';
|
|
135
|
+
}
|
|
136
|
+
updated(changed) {
|
|
137
|
+
if (changed.has('selected')) {
|
|
138
|
+
this.setAttribute('aria-selected', String(this.selected));
|
|
139
|
+
}
|
|
140
|
+
if (changed.has('disabled')) {
|
|
141
|
+
if (this.disabled)
|
|
142
|
+
this.setAttribute('aria-disabled', 'true');
|
|
143
|
+
else
|
|
144
|
+
this.removeAttribute('aria-disabled');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
#handleClick;
|
|
148
|
+
render() {
|
|
149
|
+
return html `<slot></slot>`;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
__decorate([
|
|
153
|
+
property({ type: Boolean, reflect: true })
|
|
154
|
+
], QdsTab.prototype, "selected", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
property({ type: Boolean, reflect: true })
|
|
157
|
+
], QdsTab.prototype, "disabled", void 0);
|
|
158
|
+
QdsTab = __decorate([
|
|
159
|
+
customElement('qds-tab')
|
|
160
|
+
], QdsTab);
|
|
161
|
+
export { QdsTab };
|
|
162
|
+
//# sourceMappingURL=qds-tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-tab.js","sourceRoot":"","sources":["../../../src/components/qds-tab/qds-tab.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAA4C,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEI,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,UAAU;aACpB,WAAM,GAAG;QACvB,UAAU,CAAC,UAAU;QACrB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkEF;KACF,AArEqB,CAqEpB;IAaF;QACE,KAAK,EAAE,CAAC;QAZV;;;WAGG;QAEH,aAAQ,GAAG,KAAK,CAAC;QAEjB,uDAAuD;QAEvD,aAAQ,GAAG,KAAK,CAAC;QAwBjB,iBAAY,GAAG,GAAS,EAAE;YACxB,IAAI,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-0,0 +1,32 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* The content shown for one tab in a `qds-tabs`.
|
|
5
|
+
*
|
|
6
|
+
* Panels pair with tabs by position: the first panel belongs to the first tab.
|
|
7
|
+
* Each is hidden until `qds-tabs` marks it active, so a page never shows every
|
|
8
|
+
* panel stacked on top of one another, even before the components upgrade.
|
|
9
|
+
*
|
|
10
|
+
* @element qds-tab-panel
|
|
11
|
+
*
|
|
12
|
+
* @slot - The panel content.
|
|
13
|
+
*
|
|
14
|
+
* @cssprop [--qds-component-tabs-panel-padding-block] - Space above and below the content.
|
|
15
|
+
*/
|
|
16
|
+
export declare class QdsTabPanel extends QdsElement {
|
|
17
|
+
static styles: import("lit").CSSResult[];
|
|
18
|
+
/**
|
|
19
|
+
* Whether this panel is shown. Managed by `qds-tabs`.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
active: boolean;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
render(): TemplateResult;
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
interface HTMLElementTagNameMap {
|
|
29
|
+
'qds-tab-panel': QdsTabPanel;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=qds-tab-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-tab-panel.d.ts","sourceRoot":"","sources":["../../../src/components/qds-tab-panel/qds-tab-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;GAYG;AACH,qBACa,WAAY,SAAQ,UAAU;IACzC,OAAgB,MAAM,4BAiBpB;IAEF;;;;OAIG;IAEH,MAAM,UAAS;IAEN,iBAAiB,IAAI,IAAI;IAUzB,MAAM,IAAI,cAAc;CAGlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,WAAW,CAAC;KAC9B;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 } from 'lit/decorators.js';
|
|
9
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
10
|
+
/**
|
|
11
|
+
* The content shown for one tab in a `qds-tabs`.
|
|
12
|
+
*
|
|
13
|
+
* Panels pair with tabs by position: the first panel belongs to the first tab.
|
|
14
|
+
* Each is hidden until `qds-tabs` marks it active, so a page never shows every
|
|
15
|
+
* panel stacked on top of one another, even before the components upgrade.
|
|
16
|
+
*
|
|
17
|
+
* @element qds-tab-panel
|
|
18
|
+
*
|
|
19
|
+
* @slot - The panel content.
|
|
20
|
+
*
|
|
21
|
+
* @cssprop [--qds-component-tabs-panel-padding-block] - Space above and below the content.
|
|
22
|
+
*/
|
|
23
|
+
let QdsTabPanel = class QdsTabPanel extends QdsElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
/**
|
|
27
|
+
* Whether this panel is shown. Managed by `qds-tabs`.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
this.active = false;
|
|
32
|
+
}
|
|
33
|
+
static { this.styles = [
|
|
34
|
+
QdsElement.baseStyles,
|
|
35
|
+
css `
|
|
36
|
+
:host {
|
|
37
|
+
display: block;
|
|
38
|
+
padding-block: var(--qds-component-tabs-panel-padding-block, 1rem);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host(:not([active])) {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:host(:focus-visible) {
|
|
46
|
+
outline: var(--_focus-ring);
|
|
47
|
+
outline-offset: 0.125rem;
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
]; }
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
super.connectedCallback();
|
|
53
|
+
// A host attribute rather than ElementInternals ARIA, for the same reason as
|
|
54
|
+
// qds-tab: auditing tools only read attributes.
|
|
55
|
+
this.setAttribute('role', 'tabpanel');
|
|
56
|
+
// Focusable, so a keyboard user can reach a panel that has nothing
|
|
57
|
+
// focusable inside it, as the ARIA tabs pattern recommends.
|
|
58
|
+
if (!this.hasAttribute('tabindex'))
|
|
59
|
+
this.tabIndex = 0;
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
return html `<slot></slot>`;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
__decorate([
|
|
66
|
+
property({ type: Boolean, reflect: true })
|
|
67
|
+
], QdsTabPanel.prototype, "active", void 0);
|
|
68
|
+
QdsTabPanel = __decorate([
|
|
69
|
+
customElement('qds-tab-panel')
|
|
70
|
+
], QdsTabPanel);
|
|
71
|
+
export { QdsTabPanel };
|
|
72
|
+
//# sourceMappingURL=qds-tab-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-tab-panel.js","sourceRoot":"","sources":["../../../src/components/qds-tab-panel/qds-tab-panel.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;GAYG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAoBL;;;;WAIG;QAEH,WAAM,GAAG,KAAK,CAAC;IAejB,CAAC;aAxCiB,WAAM,GAAG;QACvB,UAAU,CAAC,UAAU;QACrB,GAAG,CAAA;;;;;;;;;;;;;;KAcF;KACF,AAjBqB,CAiBpB;IAUO,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,6EAA6E;QAC7E,gDAAgD;QAChD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QACtC,mEAAmE;QACnE,4DAA4D;QAC5D,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;YAAE,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IACxD,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AAdD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAC5B;AA1BJ,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAyCvB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* A set of tabs, each showing one panel at a time.
|
|
5
|
+
*
|
|
6
|
+
* Follows the ARIA tabs pattern with automatic activation: Left and Right move
|
|
7
|
+
* between tabs and select as they go, Home and End jump to the first and last,
|
|
8
|
+
* and only the selected tab is in the tab order — Tab moves from it straight
|
|
9
|
+
* into the panel. Tabs pair with panels by position.
|
|
10
|
+
*
|
|
11
|
+
* ```html
|
|
12
|
+
* <qds-tabs label="Account">
|
|
13
|
+
* <qds-tab slot="tab">Profile</qds-tab>
|
|
14
|
+
* <qds-tab slot="tab">Security</qds-tab>
|
|
15
|
+
* <qds-tab-panel>…</qds-tab-panel>
|
|
16
|
+
* <qds-tab-panel>…</qds-tab-panel>
|
|
17
|
+
* </qds-tabs>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @element qds-tabs
|
|
21
|
+
*
|
|
22
|
+
* @slot - The `qds-tab-panel` panels.
|
|
23
|
+
* @slot tab - The `qds-tab` tabs.
|
|
24
|
+
*
|
|
25
|
+
* @fires {CustomEvent<{ index: number }>} qds-change - Fired when the user
|
|
26
|
+
* selects a tab. Not fired for programmatic changes.
|
|
27
|
+
*
|
|
28
|
+
* @csspart tablist - The element carrying the tablist role.
|
|
29
|
+
*
|
|
30
|
+
* @cssprop [--qds-component-tabs-gap] - Space between tabs.
|
|
31
|
+
* @cssprop [--qds-component-tabs-border-width] - Thickness of the line under the tab list.
|
|
32
|
+
* @cssprop [--qds-component-tabs-color-border-rest] - Color of the line under the tab list.
|
|
33
|
+
*/
|
|
34
|
+
export declare class QdsTabs extends QdsElement {
|
|
35
|
+
#private;
|
|
36
|
+
static styles: import("lit").CSSResult[];
|
|
37
|
+
/** Accessible name for the tab list. */
|
|
38
|
+
label: string;
|
|
39
|
+
/**
|
|
40
|
+
* The selected tab's position, from 0. Set it to select a tab. Initially the
|
|
41
|
+
* tab marked `selected` in the markup, or the first enabled tab.
|
|
42
|
+
*/
|
|
43
|
+
selectedIndex: number;
|
|
44
|
+
constructor();
|
|
45
|
+
protected firstUpdated(): void;
|
|
46
|
+
protected updated(): void;
|
|
47
|
+
render(): TemplateResult;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementTagNameMap {
|
|
51
|
+
'qds-tabs': QdsTabs;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=qds-tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-tabs.d.ts","sourceRoot":"","sources":["../../../src/components/qds-tabs/qds-tabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAM3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,OAAQ,SAAQ,UAAU;;IACrC,OAAgB,MAAM,4BAepB;IAEF,wCAAwC;IAExC,KAAK,SAAM;IAEX;;;OAGG;IAEH,aAAa,SAAM;;cAmBA,YAAY,IAAI,IAAI;cAOpB,OAAO,IAAI,IAAI;IA6FzB,MAAM,IAAI,cAAc;CAQlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,OAAO,CAAC;KACrB;CACF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
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, nothing } from 'lit';
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
import { QdsElement } from '../../internal/qds-element.js';
|
|
10
|
+
import { QdsTab } from '../qds-tab/qds-tab.js';
|
|
11
|
+
import { QdsTabPanel } from '../qds-tab-panel/qds-tab-panel.js';
|
|
12
|
+
let nextId = 0;
|
|
13
|
+
/**
|
|
14
|
+
* A set of tabs, each showing one panel at a time.
|
|
15
|
+
*
|
|
16
|
+
* Follows the ARIA tabs pattern with automatic activation: Left and Right move
|
|
17
|
+
* between tabs and select as they go, Home and End jump to the first and last,
|
|
18
|
+
* and only the selected tab is in the tab order — Tab moves from it straight
|
|
19
|
+
* into the panel. Tabs pair with panels by position.
|
|
20
|
+
*
|
|
21
|
+
* ```html
|
|
22
|
+
* <qds-tabs label="Account">
|
|
23
|
+
* <qds-tab slot="tab">Profile</qds-tab>
|
|
24
|
+
* <qds-tab slot="tab">Security</qds-tab>
|
|
25
|
+
* <qds-tab-panel>…</qds-tab-panel>
|
|
26
|
+
* <qds-tab-panel>…</qds-tab-panel>
|
|
27
|
+
* </qds-tabs>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @element qds-tabs
|
|
31
|
+
*
|
|
32
|
+
* @slot - The `qds-tab-panel` panels.
|
|
33
|
+
* @slot tab - The `qds-tab` tabs.
|
|
34
|
+
*
|
|
35
|
+
* @fires {CustomEvent<{ index: number }>} qds-change - Fired when the user
|
|
36
|
+
* selects a tab. Not fired for programmatic changes.
|
|
37
|
+
*
|
|
38
|
+
* @csspart tablist - The element carrying the tablist role.
|
|
39
|
+
*
|
|
40
|
+
* @cssprop [--qds-component-tabs-gap] - Space between tabs.
|
|
41
|
+
* @cssprop [--qds-component-tabs-border-width] - Thickness of the line under the tab list.
|
|
42
|
+
* @cssprop [--qds-component-tabs-color-border-rest] - Color of the line under the tab list.
|
|
43
|
+
*/
|
|
44
|
+
let QdsTabs = class QdsTabs extends QdsElement {
|
|
45
|
+
static { this.styles = [
|
|
46
|
+
QdsElement.baseStyles,
|
|
47
|
+
css `
|
|
48
|
+
:host {
|
|
49
|
+
display: block;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.tablist {
|
|
53
|
+
display: flex;
|
|
54
|
+
gap: var(--qds-component-tabs-gap, 0.25rem);
|
|
55
|
+
overflow-x: auto;
|
|
56
|
+
border-block-end: var(--qds-component-tabs-border-width, 0.0625rem) solid
|
|
57
|
+
var(--qds-component-tabs-color-border-rest, #e2e8f0);
|
|
58
|
+
}
|
|
59
|
+
`,
|
|
60
|
+
]; }
|
|
61
|
+
/** Prefix for the IDs given to tabs and panels that have none. */
|
|
62
|
+
#idBase;
|
|
63
|
+
constructor() {
|
|
64
|
+
super();
|
|
65
|
+
/** Accessible name for the tab list. */
|
|
66
|
+
this.label = '';
|
|
67
|
+
/**
|
|
68
|
+
* The selected tab's position, from 0. Set it to select a tab. Initially the
|
|
69
|
+
* tab marked `selected` in the markup, or the first enabled tab.
|
|
70
|
+
*/
|
|
71
|
+
this.selectedIndex = -1;
|
|
72
|
+
/** Prefix for the IDs given to tabs and panels that have none. */
|
|
73
|
+
this.#idBase = `qds-tabs-${nextId++}`;
|
|
74
|
+
this.#handleSelect = (event) => {
|
|
75
|
+
const index = this.#tabs.indexOf(event.target);
|
|
76
|
+
if (index === -1)
|
|
77
|
+
return;
|
|
78
|
+
this.#select(index);
|
|
79
|
+
};
|
|
80
|
+
this.#handleKeydown = (event) => {
|
|
81
|
+
// Alt+Left is the browser's Back; leave every modified key to the browser.
|
|
82
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
83
|
+
return;
|
|
84
|
+
const tabs = this.#tabs;
|
|
85
|
+
const current = tabs.indexOf(event.target);
|
|
86
|
+
if (current === -1)
|
|
87
|
+
return;
|
|
88
|
+
const enabled = tabs.filter((tab) => !tab.disabled);
|
|
89
|
+
const position = enabled.indexOf(tabs[current]);
|
|
90
|
+
// Arrow keys follow the visual order, which reverses under RTL.
|
|
91
|
+
const rtl = getComputedStyle(this).direction === 'rtl';
|
|
92
|
+
let target;
|
|
93
|
+
switch (event.key) {
|
|
94
|
+
case 'ArrowRight':
|
|
95
|
+
target = enabled[(position + (rtl ? -1 : 1) + enabled.length) % enabled.length];
|
|
96
|
+
break;
|
|
97
|
+
case 'ArrowLeft':
|
|
98
|
+
target = enabled[(position + (rtl ? 1 : -1) + enabled.length) % enabled.length];
|
|
99
|
+
break;
|
|
100
|
+
case 'Home':
|
|
101
|
+
target = enabled[0];
|
|
102
|
+
break;
|
|
103
|
+
case 'End':
|
|
104
|
+
target = enabled.at(-1);
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!target)
|
|
110
|
+
return;
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
this.#select(tabs.indexOf(target));
|
|
113
|
+
target.focus();
|
|
114
|
+
};
|
|
115
|
+
this.addEventListener('qds-tab-select', this.#handleSelect);
|
|
116
|
+
this.addEventListener('keydown', this.#handleKeydown);
|
|
117
|
+
}
|
|
118
|
+
get #tabs() {
|
|
119
|
+
return [...this.querySelectorAll(':scope > qds-tab')];
|
|
120
|
+
}
|
|
121
|
+
get #panels() {
|
|
122
|
+
return [...this.querySelectorAll(':scope > qds-tab-panel')];
|
|
123
|
+
}
|
|
124
|
+
firstUpdated() {
|
|
125
|
+
// Not left to slotchange alone: server-rendered children are already
|
|
126
|
+
// slotted when the element hydrates, so slotchange never fires for them.
|
|
127
|
+
// Panels stay hidden until this runs, so nothing flashes in the meantime.
|
|
128
|
+
void this.updateComplete.then(() => this.#sync());
|
|
129
|
+
}
|
|
130
|
+
updated() {
|
|
131
|
+
// Only once a selection exists. Resolving the initial one assigns
|
|
132
|
+
// selectedIndex, which from inside updated() would schedule a second render;
|
|
133
|
+
// firstUpdated and slotchange do that instead.
|
|
134
|
+
if (this.selectedIndex >= 0)
|
|
135
|
+
this.#sync();
|
|
136
|
+
}
|
|
137
|
+
#sync() {
|
|
138
|
+
const tabs = this.#tabs;
|
|
139
|
+
const panels = this.#panels;
|
|
140
|
+
if (tabs.length === 0)
|
|
141
|
+
return;
|
|
142
|
+
const current = tabs[this.selectedIndex];
|
|
143
|
+
if (!current || current.disabled) {
|
|
144
|
+
const marked = tabs.findIndex((tab) => tab.hasAttribute('selected') && !tab.disabled);
|
|
145
|
+
// Assigning re-runs updated() and so #sync(); finish there.
|
|
146
|
+
const fallback = marked >= 0 ? marked : tabs.findIndex((tab) => !tab.disabled);
|
|
147
|
+
if (fallback !== this.selectedIndex) {
|
|
148
|
+
this.selectedIndex = fallback;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
tabs.forEach((tab, index) => {
|
|
153
|
+
const panel = panels[index];
|
|
154
|
+
tab.id ||= `${this.#idBase}-tab-${index}`;
|
|
155
|
+
if (panel) {
|
|
156
|
+
panel.id ||= `${this.#idBase}-panel-${index}`;
|
|
157
|
+
tab.setAttribute('aria-controls', panel.id);
|
|
158
|
+
panel.setAttribute('aria-labelledby', tab.id);
|
|
159
|
+
}
|
|
160
|
+
const selected = index === this.selectedIndex;
|
|
161
|
+
tab.selected = selected;
|
|
162
|
+
// Roving tabindex: only the selected tab is in the tab order.
|
|
163
|
+
tab.tabIndex = selected ? 0 : -1;
|
|
164
|
+
});
|
|
165
|
+
panels.forEach((panel, index) => {
|
|
166
|
+
panel.active = index === this.selectedIndex;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
#select(index) {
|
|
170
|
+
if (index === this.selectedIndex)
|
|
171
|
+
return;
|
|
172
|
+
this.selectedIndex = index;
|
|
173
|
+
this.dispatchEvent(new CustomEvent('qds-change', { detail: { index }, bubbles: true, composed: true }));
|
|
174
|
+
}
|
|
175
|
+
#handleSelect;
|
|
176
|
+
#handleKeydown;
|
|
177
|
+
render() {
|
|
178
|
+
return html `
|
|
179
|
+
<div class="tablist" part="tablist" role="tablist" aria-label=${this.label || nothing}>
|
|
180
|
+
<slot name="tab" @slotchange=${() => this.#sync()}></slot>
|
|
181
|
+
</div>
|
|
182
|
+
<slot @slotchange=${() => this.#sync()}></slot>
|
|
183
|
+
`;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
__decorate([
|
|
187
|
+
property()
|
|
188
|
+
], QdsTabs.prototype, "label", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
property({ type: Number, attribute: 'selected-index' })
|
|
191
|
+
], QdsTabs.prototype, "selectedIndex", void 0);
|
|
192
|
+
QdsTabs = __decorate([
|
|
193
|
+
customElement('qds-tabs')
|
|
194
|
+
], QdsTabs);
|
|
195
|
+
export { QdsTabs };
|
|
196
|
+
//# sourceMappingURL=qds-tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-tabs.js","sourceRoot":"","sources":["../../../src/components/qds-tabs/qds-tabs.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,IAAI,MAAM,GAAG,CAAC,CAAC;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;aACrB,WAAM,GAAG;QACvB,UAAU,CAAC,UAAU;QACrB,GAAG,CAAA;;;;;;;;;;;;KAYF;KACF,AAfqB,CAepB;IAaF,kEAAkE;IACzD,OAAO,CAA0B;IAE1C;QACE,KAAK,EAAE,CAAC;QAfV,wCAAwC;QAExC,UAAK,GAAG,EAAE,CAAC;QAEX;;;WAGG;QAEH,kBAAa,GAAG,CAAC,CAAC,CAAC;QAEnB,kEAAkE;QACzD,YAAO,GAAG,YAAY,MAAM,EAAE,EAAE,CAAC;QA0E1C,kBAAa,GAAG,CAAC,KAAY,EAAQ,EAAE;YACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAgB,CAAC,CAAC;YACzD,IAAI,KAAK,KAAK,CAAC,CAAC;gB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8D;YAC9D,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC9B,KAAK,CAAC,MAAM,GAAG,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,KAAa;QACnB,IAAI,KAAK,KAAK,IAAI,CAAC,aAAa;YAAE,OAAO;QACzC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CACpF,CAAC;IACJ,CAAC;IAED,aAAa,CAIX;IAEF,cAAc,CAkCZ;IAEO,MAAM;QACb,OAAO,IAAI,CAAA;sEACuD,IAAI,CAAC,KAAK,IAAI,OAAO;uCACpD,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;;0BAE/B,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;KACvC,CAAC;IACJ,CAAC;;AArID;IADC,QAAQ,EAAE;sCACA;AAOX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;8CACrC;AA3BR,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA0JnB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { QdsTextControl, type QdsTextControlType } from '../../internal/qds-text-control.js';
|
|
3
|
+
export type QdsTextFieldType = QdsTextControlType;
|
|
4
|
+
/**
|
|
5
|
+
* A complete text field: a visible label, the input, an optional hint, and an
|
|
6
|
+
* error message.
|
|
7
|
+
*
|
|
8
|
+
* All four live in one shadow root, which is what makes the wiring possible.
|
|
9
|
+
* `<label for>` and `aria-describedby` are ID references, and an ID reference
|
|
10
|
+
* cannot cross a shadow boundary — so a label outside the component could never
|
|
11
|
+
* name the input inside it, and a hint outside could never describe it.
|
|
12
|
+
*
|
|
13
|
+
* Errors come from two places. An `error` message set by the author is always
|
|
14
|
+
* shown. Otherwise, once the user has left the field (or tried to submit the
|
|
15
|
+
* form), the browser's own validation message is shown for any failing
|
|
16
|
+
* constraint — `required`, `type="email"`, `minlength`, `pattern` — so the common
|
|
17
|
+
* cases need no code at all. A `required` field marks its label with an asterisk,
|
|
18
|
+
* hidden from assistive technology, which announces the input as required.
|
|
19
|
+
*
|
|
20
|
+
* @element qds-text-field
|
|
21
|
+
*
|
|
22
|
+
* @slot label - The label, in place of the `label` attribute when it needs markup.
|
|
23
|
+
* @slot hint - The hint, in place of the `hint` attribute when it needs markup, such as a link.
|
|
24
|
+
* @slot start - Content before the text, such as an icon or a prefix.
|
|
25
|
+
* @slot end - Content after the text, such as a unit or a button.
|
|
26
|
+
*
|
|
27
|
+
* @fires {CustomEvent<{ value: string }>} qds-input - Fired on every keystroke.
|
|
28
|
+
* @fires {CustomEvent<{ value: string }>} qds-change - Fired when the value is
|
|
29
|
+
* committed: on blur after editing, or on Enter.
|
|
30
|
+
*
|
|
31
|
+
* @csspart base - The wrapper around the whole field.
|
|
32
|
+
* @csspart label - The label element.
|
|
33
|
+
* @csspart control - The box drawn around the input and its affixes.
|
|
34
|
+
* @csspart input - The native input.
|
|
35
|
+
* @csspart hint - The hint text.
|
|
36
|
+
* @csspart error - The error message.
|
|
37
|
+
*
|
|
38
|
+
* @cssprop [--qds-component-text-field-gap] - Space between the label, control, and messages.
|
|
39
|
+
* @cssprop [--qds-component-text-field-duration] - Border transition duration.
|
|
40
|
+
* @cssprop [--qds-component-text-field-label-font-size] - Label size.
|
|
41
|
+
* @cssprop [--qds-component-text-field-label-font-weight] - Label weight.
|
|
42
|
+
* @cssprop [--qds-component-text-field-label-color-content-{state}] - Label color: `rest`, `disabled`.
|
|
43
|
+
* @cssprop [--qds-component-text-field-hint-font-size] - Hint and error size.
|
|
44
|
+
* @cssprop [--qds-component-text-field-hint-color-content-rest] - Hint color.
|
|
45
|
+
* @cssprop [--qds-component-text-field-error-color-content-rest] - Error message color.
|
|
46
|
+
* @cssprop [--qds-component-text-field-control-gap] - Space between the text and the affixes.
|
|
47
|
+
* @cssprop [--qds-component-text-field-control-padding-block] - Control vertical padding.
|
|
48
|
+
* @cssprop [--qds-component-text-field-control-padding-inline] - Control horizontal padding.
|
|
49
|
+
* @cssprop [--qds-component-text-field-control-font-size] - Input text size.
|
|
50
|
+
* @cssprop [--qds-component-text-field-control-line-height] - Input line height.
|
|
51
|
+
* @cssprop [--qds-component-text-field-control-border-radius] - Control corner radius.
|
|
52
|
+
* @cssprop [--qds-component-text-field-control-border-width] - Control border thickness.
|
|
53
|
+
* @cssprop [--qds-component-text-field-control-color-background-{state}] - Control fill: `rest`, `disabled`.
|
|
54
|
+
* @cssprop [--qds-component-text-field-control-color-border-{state}] - Control border: `rest`, `focus`, `disabled`.
|
|
55
|
+
* @cssprop [--qds-component-text-field-control-color-content-{state}] - Input text: `rest`, `disabled`.
|
|
56
|
+
* @cssprop [--qds-component-text-field-invalid-color-border-rest] - Control border while showing an error.
|
|
57
|
+
* @cssprop [--qds-component-text-field-placeholder-color-content-rest] - Placeholder text.
|
|
58
|
+
* @cssprop [--qds-component-text-field-affix-color-content-rest] - Color of slotted start and end content.
|
|
59
|
+
*/
|
|
60
|
+
export declare class QdsTextField extends QdsTextControl {
|
|
61
|
+
#private;
|
|
62
|
+
static styles: import("lit").CSSResult[];
|
|
63
|
+
/** The visible label. Also the input's accessible name. */
|
|
64
|
+
label: string;
|
|
65
|
+
/** Help text shown under the input, and read out with it. */
|
|
66
|
+
hint: string;
|
|
67
|
+
/**
|
|
68
|
+
* An error message to show, for errors the browser cannot detect, such as a
|
|
69
|
+
* server-side check. Shown immediately, and marks the field invalid to
|
|
70
|
+
* assistive technology, but does not block form submission.
|
|
71
|
+
*/
|
|
72
|
+
error: string;
|
|
73
|
+
/**
|
|
74
|
+
* Whether native validation messages may be shown yet: after the user leaves
|
|
75
|
+
* the field, or tries to submit the form. Before that, a required field that
|
|
76
|
+
* nobody has touched is not an error.
|
|
77
|
+
*/
|
|
78
|
+
private touched;
|
|
79
|
+
private hasHintSlot;
|
|
80
|
+
constructor();
|
|
81
|
+
/** Same as the native `reportValidity()`, and shows the field's message. */
|
|
82
|
+
reportValidity(): boolean;
|
|
83
|
+
protected firstUpdated(): void;
|
|
84
|
+
/** Called by the form on reset: restore the declared value and hide messages again. */
|
|
85
|
+
formResetCallback(): void;
|
|
86
|
+
protected syncValidity(): void;
|
|
87
|
+
render(): TemplateResult;
|
|
88
|
+
}
|
|
89
|
+
declare global {
|
|
90
|
+
interface HTMLElementTagNameMap {
|
|
91
|
+
'qds-text-field': QdsTextField;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=qds-text-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qds-text-field.d.ts","sourceRoot":"","sources":["../../../src/components/qds-text-field/qds-text-field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAK9D,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE7F,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,qBACa,YAAa,SAAQ,cAAc;;IAC9C,OAAgB,MAAM,4BA2HpB;IAEF,2DAA2D;IAE3D,KAAK,SAAM;IAEX,6DAA6D;IAE7D,IAAI,SAAM;IAEV;;;;OAIG;IAEH,KAAK,SAAM;IAEX;;;;OAIG;IAEH,OAAO,CAAC,OAAO,CAAS;IAUxB,OAAO,CAAC,WAAW,CAAS;;IAS5B,4EAA4E;IACnE,cAAc,IAAI,OAAO;cAUf,YAAY,IAAI,IAAI;IAcvC,uFAAuF;IAC9E,iBAAiB,IAAI,IAAI;cAKf,YAAY,IAAI,IAAI;IAU9B,MAAM,IAAI,cAAc;CAgDlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,YAAY,CAAC;KAChC;CACF"}
|