@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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -2
  3. package/custom-elements.json +6126 -0
  4. package/dist/components/qds-accordion/qds-accordion.d.ts +39 -0
  5. package/dist/components/qds-accordion/qds-accordion.d.ts.map +1 -0
  6. package/dist/components/qds-accordion/qds-accordion.js +130 -0
  7. package/dist/components/qds-accordion/qds-accordion.js.map +1 -0
  8. package/dist/components/qds-accordion-item/qds-accordion-item.d.ts +68 -0
  9. package/dist/components/qds-accordion-item/qds-accordion-item.d.ts.map +1 -0
  10. package/dist/components/qds-accordion-item/qds-accordion-item.js +247 -0
  11. package/dist/components/qds-accordion-item/qds-accordion-item.js.map +1 -0
  12. package/dist/components/qds-button/qds-button.d.ts +92 -0
  13. package/dist/components/qds-button/qds-button.d.ts.map +1 -0
  14. package/dist/components/qds-button/qds-button.js +418 -0
  15. package/dist/components/qds-button/qds-button.js.map +1 -0
  16. package/dist/components/qds-card/qds-card.d.ts +48 -0
  17. package/dist/components/qds-card/qds-card.d.ts.map +1 -0
  18. package/dist/components/qds-card/qds-card.js +152 -0
  19. package/dist/components/qds-card/qds-card.js.map +1 -0
  20. package/dist/components/qds-checkbox/qds-checkbox.d.ts +85 -0
  21. package/dist/components/qds-checkbox/qds-checkbox.d.ts.map +1 -0
  22. package/dist/components/qds-checkbox/qds-checkbox.js +316 -0
  23. package/dist/components/qds-checkbox/qds-checkbox.js.map +1 -0
  24. package/dist/components/qds-chip/qds-chip.d.ts +79 -0
  25. package/dist/components/qds-chip/qds-chip.d.ts.map +1 -0
  26. package/dist/components/qds-chip/qds-chip.js +314 -0
  27. package/dist/components/qds-chip/qds-chip.js.map +1 -0
  28. package/dist/components/qds-input/qds-input.d.ts +64 -0
  29. package/dist/components/qds-input/qds-input.d.ts.map +1 -0
  30. package/dist/components/qds-input/qds-input.js +224 -0
  31. package/dist/components/qds-input/qds-input.js.map +1 -0
  32. package/dist/components/qds-modal/qds-modal.d.ts +76 -0
  33. package/dist/components/qds-modal/qds-modal.d.ts.map +1 -0
  34. package/dist/components/qds-modal/qds-modal.js +362 -0
  35. package/dist/components/qds-modal/qds-modal.js.map +1 -0
  36. package/dist/components/qds-progress-bar/qds-progress-bar.d.ts +47 -0
  37. package/dist/components/qds-progress-bar/qds-progress-bar.d.ts.map +1 -0
  38. package/dist/components/qds-progress-bar/qds-progress-bar.js +180 -0
  39. package/dist/components/qds-progress-bar/qds-progress-bar.js.map +1 -0
  40. package/dist/components/qds-radio/qds-radio.d.ts +62 -0
  41. package/dist/components/qds-radio/qds-radio.d.ts.map +1 -0
  42. package/dist/components/qds-radio/qds-radio.js +213 -0
  43. package/dist/components/qds-radio/qds-radio.js.map +1 -0
  44. package/dist/components/qds-radio-group/qds-radio-group.d.ts +72 -0
  45. package/dist/components/qds-radio-group/qds-radio-group.d.ts.map +1 -0
  46. package/dist/components/qds-radio-group/qds-radio-group.js +317 -0
  47. package/dist/components/qds-radio-group/qds-radio-group.js.map +1 -0
  48. package/dist/components/qds-stack/qds-stack.d.ts +46 -0
  49. package/dist/components/qds-stack/qds-stack.d.ts.map +1 -0
  50. package/dist/components/qds-stack/qds-stack.js +149 -0
  51. package/dist/components/qds-stack/qds-stack.js.map +1 -0
  52. package/dist/components/qds-tab/qds-tab.d.ts +55 -0
  53. package/dist/components/qds-tab/qds-tab.d.ts.map +1 -0
  54. package/dist/components/qds-tab/qds-tab.js +162 -0
  55. package/dist/components/qds-tab/qds-tab.js.map +1 -0
  56. package/dist/components/qds-tab-panel/qds-tab-panel.d.ts +32 -0
  57. package/dist/components/qds-tab-panel/qds-tab-panel.d.ts.map +1 -0
  58. package/dist/components/qds-tab-panel/qds-tab-panel.js +72 -0
  59. package/dist/components/qds-tab-panel/qds-tab-panel.js.map +1 -0
  60. package/dist/components/qds-tabs/qds-tabs.d.ts +54 -0
  61. package/dist/components/qds-tabs/qds-tabs.d.ts.map +1 -0
  62. package/dist/components/qds-tabs/qds-tabs.js +196 -0
  63. package/dist/components/qds-tabs/qds-tabs.js.map +1 -0
  64. package/dist/components/qds-text-field/qds-text-field.d.ts +94 -0
  65. package/dist/components/qds-text-field/qds-text-field.d.ts.map +1 -0
  66. package/dist/components/qds-text-field/qds-text-field.js +332 -0
  67. package/dist/components/qds-text-field/qds-text-field.js.map +1 -0
  68. package/dist/components/qds-toggle/qds-toggle.d.ts +68 -0
  69. package/dist/components/qds-toggle/qds-toggle.d.ts.map +1 -0
  70. package/dist/components/qds-toggle/qds-toggle.js +260 -0
  71. package/dist/components/qds-toggle/qds-toggle.js.map +1 -0
  72. package/dist/index.d.ts +50 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +40 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/internal/qds-element.d.ts +31 -0
  77. package/dist/internal/qds-element.d.ts.map +1 -0
  78. package/dist/internal/qds-element.js +68 -0
  79. package/dist/internal/qds-element.js.map +1 -0
  80. package/dist/internal/qds-text-control.d.ts +79 -0
  81. package/dist/internal/qds-text-control.d.ts.map +1 -0
  82. package/dist/internal/qds-text-control.js +159 -0
  83. package/dist/internal/qds-text-control.js.map +1 -0
  84. package/package.json +125 -3
@@ -0,0 +1,314 @@
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
+ /**
11
+ * A compact label for a status, category, or applied filter.
12
+ *
13
+ * A chip is not interactive on its own. With `removable` it gains a remove
14
+ * button — the only focusable thing in it — which fires `qds-remove` and leaves
15
+ * the decision to the page: the chip does not delete itself, because the page
16
+ * usually needs to update its own state (a filter list, a set of tags) first.
17
+ *
18
+ * With `selectable` it becomes a filter chip instead: the whole chip is a toggle
19
+ * button, announced as pressed or not, showing a check mark while selected.
20
+ * Wrap a set of them in an element with `role="group"` and an `aria-label` so
21
+ * the set is announced together. A selectable chip ignores `removable`, since a
22
+ * button cannot contain another button.
23
+ *
24
+ * Meaning is never carried by color alone: the variant tints the chip, but the
25
+ * text has to say what it means.
26
+ *
27
+ * @element qds-chip
28
+ *
29
+ * @slot - The chip text.
30
+ * @slot start - Content before the text, typically an icon.
31
+ *
32
+ * @fires {CustomEvent<void>} qds-remove - Fired when the remove button is
33
+ * activated. The chip stays in the DOM; remove it in the handler.
34
+ * @fires {CustomEvent<{ selected: boolean }>} qds-change - Fired when the user
35
+ * toggles a selectable chip. Not fired for programmatic changes.
36
+ *
37
+ * @csspart base - The chip body. A button when the chip is selectable.
38
+ * @csspart label - The wrapper around the default slot.
39
+ * @csspart remove - The remove button.
40
+ *
41
+ * @cssprop [--qds-component-chip-gap] - Space between the icon, text, and remove button.
42
+ * @cssprop [--qds-component-chip-padding-block] - Vertical padding.
43
+ * @cssprop [--qds-component-chip-padding-inline] - Horizontal padding.
44
+ * @cssprop [--qds-component-chip-border-radius] - Corner radius.
45
+ * @cssprop [--qds-component-chip-border-width] - Border thickness.
46
+ * @cssprop [--qds-component-chip-font-size] - Text size.
47
+ * @cssprop [--qds-component-chip-font-weight] - Text weight.
48
+ * @cssprop [--qds-component-chip-line-height] - Text line height.
49
+ * @cssprop [--qds-component-chip-{variant}-color-background-rest] - Fill per variant.
50
+ * @cssprop [--qds-component-chip-{variant}-color-content-rest] - Text color per variant.
51
+ * @cssprop [--qds-component-chip-{variant}-color-border-rest] - Border color per variant.
52
+ * @cssprop [--qds-component-chip-selectable-color-border-rest] - Border of an unselected selectable chip.
53
+ * @cssprop [--qds-component-chip-selectable-color-background-hover] - Fill of an unselected selectable chip under the pointer.
54
+ * @cssprop [--qds-component-chip-selected-color-background-{state}] - Fill of a selected chip: `rest`, `hover`.
55
+ * @cssprop [--qds-component-chip-selected-color-content-rest] - Text of a selected chip.
56
+ * @cssprop [--qds-component-chip-selected-color-border-rest] - Border of a selected chip.
57
+ */
58
+ let QdsChip = class QdsChip extends QdsElement {
59
+ constructor() {
60
+ super(...arguments);
61
+ /** Tone. Pair it with text that states the meaning; color alone does not. */
62
+ this.variant = 'neutral';
63
+ /** Makes the chip a toggle button, for filtering. */
64
+ this.selectable = false;
65
+ /** Whether a selectable chip is selected. */
66
+ this.selected = false;
67
+ /** Prevents toggling a selectable chip. */
68
+ this.disabled = false;
69
+ /** Adds a remove button that fires `qds-remove`. Ignored when `selectable`. */
70
+ this.removable = false;
71
+ /**
72
+ * Accessible name for the remove button. Defaults to "Remove" followed by the
73
+ * chip's text, so a list of chips does not read as a list of identical
74
+ * "Remove" buttons. Set it when the chip text alone would not make sense after
75
+ * "Remove", or to translate it.
76
+ */
77
+ this.removeLabel = '';
78
+ }
79
+ static { this.styles = [
80
+ QdsElement.baseStyles,
81
+ css `
82
+ :host {
83
+ display: inline-block;
84
+ vertical-align: middle;
85
+
86
+ --_bg: var(--qds-component-chip-neutral-color-background-rest, #f1f5f9);
87
+ --_fg: var(--qds-component-chip-neutral-color-content-rest, #0f172a);
88
+ --_border: var(--qds-component-chip-neutral-color-border-rest, #cbd5e1);
89
+ }
90
+
91
+ :host([variant='info']) {
92
+ --_bg: var(--qds-component-chip-info-color-background-rest, #dbeafe);
93
+ --_fg: var(--qds-component-chip-info-color-content-rest, #1d4ed8);
94
+ --_border: var(--qds-component-chip-info-color-border-rest, transparent);
95
+ }
96
+
97
+ :host([variant='success']) {
98
+ --_bg: var(--qds-component-chip-success-color-background-rest, #dcfce7);
99
+ --_fg: var(--qds-component-chip-success-color-content-rest, #15803d);
100
+ --_border: var(--qds-component-chip-success-color-border-rest, transparent);
101
+ }
102
+
103
+ :host([variant='warning']) {
104
+ --_bg: var(--qds-component-chip-warning-color-background-rest, #fef9c3);
105
+ --_fg: var(--qds-component-chip-warning-color-content-rest, #854d0e);
106
+ --_border: var(--qds-component-chip-warning-color-border-rest, transparent);
107
+ }
108
+
109
+ :host([variant='error']) {
110
+ --_bg: var(--qds-component-chip-error-color-background-rest, #fee2e2);
111
+ --_fg: var(--qds-component-chip-error-color-content-rest, #b91c1c);
112
+ --_border: var(--qds-component-chip-error-color-border-rest, transparent);
113
+ }
114
+
115
+ .base {
116
+ display: inline-flex;
117
+ align-items: center;
118
+ gap: var(--qds-component-chip-gap, 0.25rem);
119
+ padding: var(--qds-component-chip-padding-block, 0.25rem)
120
+ var(--qds-component-chip-padding-inline, 0.75rem);
121
+
122
+ font-family: var(--qds-typography-font-family-sans, inherit);
123
+ font-size: var(--qds-component-chip-font-size, 0.75rem);
124
+ font-weight: var(--qds-component-chip-font-weight, 500);
125
+ line-height: var(--qds-component-chip-line-height, 1.375);
126
+ white-space: nowrap;
127
+
128
+ color: var(--_fg);
129
+ background-color: var(--_bg);
130
+ border: var(--qds-component-chip-border-width, 0.0625rem) solid var(--_border);
131
+ border-radius: var(--qds-component-chip-border-radius, 9999px);
132
+ }
133
+
134
+ /* Pull the remove button toward the edge so the padding looks even. */
135
+ :host([removable]) .base {
136
+ padding-inline-end: var(--qds-component-chip-padding-block, 0.25rem);
137
+ }
138
+
139
+ .remove {
140
+ display: inline-grid;
141
+ place-items: center;
142
+ width: 1.25em;
143
+ height: 1.25em;
144
+ margin: 0;
145
+ padding: 0;
146
+
147
+ font: inherit;
148
+ line-height: 1;
149
+ color: inherit;
150
+ background: none;
151
+ border: 0;
152
+ border-radius: 50%;
153
+ cursor: pointer;
154
+ }
155
+
156
+ /*
157
+ * Tinted from the text color, so the hover state works on every variant
158
+ * without a token per variant.
159
+ */
160
+ .remove:hover {
161
+ background-color: color-mix(in srgb, currentColor 15%, transparent);
162
+ }
163
+
164
+ .remove:focus-visible {
165
+ outline: var(--_focus-ring);
166
+ outline-offset: 0.0625rem;
167
+ }
168
+
169
+ .remove svg {
170
+ width: 0.75em;
171
+ height: 0.75em;
172
+ }
173
+
174
+ /*
175
+ * Selectable: an interactive control, so its border must reach 3:1 against
176
+ * the page, which the decorative variant borders do not.
177
+ */
178
+ :host([selectable]) {
179
+ --_border: var(--qds-component-chip-selectable-color-border-rest, #64748b);
180
+ }
181
+
182
+ :host([selectable][selected]) {
183
+ --_bg: var(--qds-component-chip-selected-color-background-rest, #2563eb);
184
+ --_fg: var(--qds-component-chip-selected-color-content-rest, #f8fafc);
185
+ --_border: var(--qds-component-chip-selected-color-border-rest, transparent);
186
+ }
187
+
188
+ button.base {
189
+ margin: 0;
190
+ font-family: var(--qds-typography-font-family-sans, inherit);
191
+ cursor: pointer;
192
+ -webkit-appearance: none;
193
+ appearance: none;
194
+ }
195
+
196
+ /* Hover only while enabled: a disabled chip must not look interactive. */
197
+ button.base:where(:hover:not(:disabled)) {
198
+ background-color: var(--qds-component-chip-selectable-color-background-hover, #e2e8f0);
199
+ }
200
+
201
+ :host([selected]) button.base:where(:hover:not(:disabled)) {
202
+ background-color: var(--qds-component-chip-selected-color-background-hover, #1d4ed8);
203
+ }
204
+
205
+ button.base:focus-visible {
206
+ outline: var(--_focus-ring);
207
+ outline-offset: 0.125rem;
208
+ }
209
+
210
+ button.base:disabled {
211
+ opacity: 0.5;
212
+ cursor: not-allowed;
213
+ }
214
+
215
+ .check {
216
+ width: 0.875em;
217
+ height: 0.875em;
218
+ /* Pull it toward the edge so the chip does not grow lopsided when selected. */
219
+ margin-inline-start: -0.25em;
220
+ }
221
+
222
+ @media (forced-colors: active) {
223
+ .base {
224
+ border-color: CanvasText;
225
+ }
226
+
227
+ :host([selected]) .base {
228
+ border-color: Highlight;
229
+ }
230
+ }
231
+ `,
232
+ ]; }
233
+ #handleRemove() {
234
+ this.dispatchEvent(new CustomEvent('qds-remove', { bubbles: true, composed: true }));
235
+ }
236
+ #handleToggle() {
237
+ this.selected = !this.selected;
238
+ this.dispatchEvent(new CustomEvent('qds-change', {
239
+ detail: { selected: this.selected },
240
+ bubbles: true,
241
+ composed: true,
242
+ }));
243
+ }
244
+ render() {
245
+ if (this.selectable) {
246
+ return html `
247
+ <button
248
+ class="base"
249
+ part="base"
250
+ type="button"
251
+ aria-pressed=${String(this.selected)}
252
+ ?disabled=${this.disabled}
253
+ @click=${this.#handleToggle}
254
+ >
255
+ ${this.selected
256
+ ? html `<svg class="check" viewBox="0 0 16 16" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
257
+ <polyline points="3.5 8.5 6.5 11.5 12.5 4.5"></polyline>
258
+ </svg>`
259
+ : html `<slot name="start"></slot>`}
260
+ <span id="label" part="label"><slot></slot></span>
261
+ </button>
262
+ `;
263
+ }
264
+ return html `
265
+ <span class="base" part="base">
266
+ <slot name="start"></slot>
267
+ <span id="label" part="label"><slot></slot></span>
268
+ ${this.removable
269
+ ? html `<button
270
+ class="remove"
271
+ part="remove"
272
+ type="button"
273
+ aria-label=${this.removeLabel || nothing}
274
+ aria-labelledby=${this.removeLabel ? nothing : 'remove-text label'}
275
+ @click=${this.#handleRemove}
276
+ >
277
+ <!--
278
+ Named by reference rather than by reading textContent: the
279
+ server has no light DOM to read, and a hydrating render does not
280
+ correct an attribute that differs from the server's.
281
+ -->
282
+ <span id="remove-text" hidden>Remove</span>
283
+ <svg viewBox="0 0 12 12" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round">
284
+ <path d="M3 3l6 6M9 3l-6 6"></path>
285
+ </svg>
286
+ </button>`
287
+ : nothing}
288
+ </span>
289
+ `;
290
+ }
291
+ };
292
+ __decorate([
293
+ property({ reflect: true })
294
+ ], QdsChip.prototype, "variant", void 0);
295
+ __decorate([
296
+ property({ type: Boolean, reflect: true })
297
+ ], QdsChip.prototype, "selectable", void 0);
298
+ __decorate([
299
+ property({ type: Boolean, reflect: true })
300
+ ], QdsChip.prototype, "selected", void 0);
301
+ __decorate([
302
+ property({ type: Boolean, reflect: true })
303
+ ], QdsChip.prototype, "disabled", void 0);
304
+ __decorate([
305
+ property({ type: Boolean, reflect: true })
306
+ ], QdsChip.prototype, "removable", void 0);
307
+ __decorate([
308
+ property({ attribute: 'remove-label' })
309
+ ], QdsChip.prototype, "removeLabel", void 0);
310
+ QdsChip = __decorate([
311
+ customElement('qds-chip')
312
+ ], QdsChip);
313
+ export { QdsChip };
314
+ //# sourceMappingURL=qds-chip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qds-chip.js","sourceRoot":"","sources":["../../../src/components/qds-chip/qds-chip.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;AAI3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QA4JL,6EAA6E;QAE7E,YAAO,GAAmB,SAAS,CAAC;QAEpC,qDAAqD;QAErD,eAAU,GAAG,KAAK,CAAC;QAEnB,6CAA6C;QAE7C,aAAQ,GAAG,KAAK,CAAC;QAEjB,2CAA2C;QAE3C,aAAQ,GAAG,KAAK,CAAC;QAEjB,+EAA+E;QAE/E,cAAS,GAAG,KAAK,CAAC;QAElB;;;;;WAKG;QAEH,gBAAW,GAAG,EAAE,CAAC;IAiEnB,CAAC;aAvPiB,WAAM,GAAG;QACvB,UAAU,CAAC,UAAU;QACrB,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO,EAAE,IAAI,EAAE,CAAC;wCACQ;AAIpC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CACxB;AAInB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAC1B;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAC1B;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CACzB;AASlB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;4CACvB;AAvLN,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAwPnB"}
@@ -0,0 +1,64 @@
1
+ import { type TemplateResult } from 'lit';
2
+ import { QdsTextControl, type QdsTextControlType } from '../../internal/qds-text-control.js';
3
+ export type QdsInputType = QdsTextControlType;
4
+ export type QdsInputSize = 'sm' | 'md' | 'lg';
5
+ /**
6
+ * A single-line text input, on its own.
7
+ *
8
+ * This is the bare control. It has no visible label, so it takes its accessible
9
+ * name from the `label` attribute — a `<label for>` outside cannot reach an input
10
+ * inside a shadow root. Where a visible label, hint, or error message is wanted,
11
+ * use `qds-text-field`, which renders all three inside its own shadow root so
12
+ * they can be wired to the input.
13
+ *
14
+ * Constraint validation is the native input's: `required`, `minlength`,
15
+ * `pattern`, and the type's own rules (`email`, `url`) are mirrored to the form,
16
+ * and the error border appears only after the user has interacted, via
17
+ * `:user-invalid`.
18
+ *
19
+ * @element qds-input
20
+ *
21
+ * @slot start - Content before the text, such as an icon or a prefix.
22
+ * @slot end - Content after the text, such as a unit or a button.
23
+ *
24
+ * @fires {CustomEvent<{ value: string }>} qds-input - Fired on every keystroke.
25
+ * @fires {CustomEvent<{ value: string }>} qds-change - Fired when the value is
26
+ * committed: on blur after editing, or on Enter.
27
+ *
28
+ * @csspart base - The box drawn around the input and its affixes.
29
+ * @csspart input - The native input.
30
+ *
31
+ * @cssprop [--qds-component-input-gap] - Space between the text and the affixes.
32
+ * @cssprop [--qds-component-input-border-radius] - Corner radius.
33
+ * @cssprop [--qds-component-input-border-width] - Border thickness.
34
+ * @cssprop [--qds-component-input-line-height] - Text line height.
35
+ * @cssprop [--qds-component-input-duration] - Border transition duration.
36
+ * @cssprop [--qds-component-input-{size}-padding-block] - Vertical padding per size.
37
+ * @cssprop [--qds-component-input-{size}-padding-inline] - Horizontal padding per size.
38
+ * @cssprop [--qds-component-input-{size}-font-size] - Text size per size.
39
+ * @cssprop [--qds-component-input-color-background-{state}] - Fill: `rest`, `disabled`.
40
+ * @cssprop [--qds-component-input-color-border-{state}] - Border: `rest`, `focus`, `disabled`.
41
+ * @cssprop [--qds-component-input-color-content-{state}] - Text: `rest`, `disabled`.
42
+ * @cssprop [--qds-component-input-invalid-color-border-rest] - Border while invalid.
43
+ * @cssprop [--qds-component-input-placeholder-color-content-rest] - Placeholder text.
44
+ * @cssprop [--qds-component-input-affix-color-content-rest] - Color of slotted start and end content.
45
+ */
46
+ export declare class QdsInput extends QdsTextControl {
47
+ static styles: import("lit").CSSResult[];
48
+ /** Accessible name. Required, since this control has no visible label. */
49
+ label: string;
50
+ /** Control size. */
51
+ size: QdsInputSize;
52
+ /**
53
+ * Shows the error state and sets `aria-invalid`, for errors the form itself
54
+ * cannot detect, such as a server-side check. Does not block submission.
55
+ */
56
+ invalid: boolean;
57
+ render(): TemplateResult;
58
+ }
59
+ declare global {
60
+ interface HTMLElementTagNameMap {
61
+ 'qds-input': QdsInput;
62
+ }
63
+ }
64
+ //# sourceMappingURL=qds-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qds-input.d.ts","sourceRoot":"","sources":["../../../src/components/qds-input/qds-input.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,YAAY,GAAG,kBAAkB,CAAC;AAC9C,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBACa,QAAS,SAAQ,cAAc;IAC1C,OAAgB,MAAM,4BAqHpB;IAEF,0EAA0E;IAE1E,KAAK,SAAM;IAEX,oBAAoB;IAEpB,IAAI,EAAE,YAAY,CAAQ;IAE1B;;;OAGG;IAEH,OAAO,UAAS;IAEP,MAAM,IAAI,cAAc;CA0BlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
@@ -0,0 +1,224 @@
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 { live } from 'lit/directives/live.js';
10
+ import { QdsElement } from '../../internal/qds-element.js';
11
+ import { QdsTextControl } from '../../internal/qds-text-control.js';
12
+ /**
13
+ * A single-line text input, on its own.
14
+ *
15
+ * This is the bare control. It has no visible label, so it takes its accessible
16
+ * name from the `label` attribute — a `<label for>` outside cannot reach an input
17
+ * inside a shadow root. Where a visible label, hint, or error message is wanted,
18
+ * use `qds-text-field`, which renders all three inside its own shadow root so
19
+ * they can be wired to the input.
20
+ *
21
+ * Constraint validation is the native input's: `required`, `minlength`,
22
+ * `pattern`, and the type's own rules (`email`, `url`) are mirrored to the form,
23
+ * and the error border appears only after the user has interacted, via
24
+ * `:user-invalid`.
25
+ *
26
+ * @element qds-input
27
+ *
28
+ * @slot start - Content before the text, such as an icon or a prefix.
29
+ * @slot end - Content after the text, such as a unit or a button.
30
+ *
31
+ * @fires {CustomEvent<{ value: string }>} qds-input - Fired on every keystroke.
32
+ * @fires {CustomEvent<{ value: string }>} qds-change - Fired when the value is
33
+ * committed: on blur after editing, or on Enter.
34
+ *
35
+ * @csspart base - The box drawn around the input and its affixes.
36
+ * @csspart input - The native input.
37
+ *
38
+ * @cssprop [--qds-component-input-gap] - Space between the text and the affixes.
39
+ * @cssprop [--qds-component-input-border-radius] - Corner radius.
40
+ * @cssprop [--qds-component-input-border-width] - Border thickness.
41
+ * @cssprop [--qds-component-input-line-height] - Text line height.
42
+ * @cssprop [--qds-component-input-duration] - Border transition duration.
43
+ * @cssprop [--qds-component-input-{size}-padding-block] - Vertical padding per size.
44
+ * @cssprop [--qds-component-input-{size}-padding-inline] - Horizontal padding per size.
45
+ * @cssprop [--qds-component-input-{size}-font-size] - Text size per size.
46
+ * @cssprop [--qds-component-input-color-background-{state}] - Fill: `rest`, `disabled`.
47
+ * @cssprop [--qds-component-input-color-border-{state}] - Border: `rest`, `focus`, `disabled`.
48
+ * @cssprop [--qds-component-input-color-content-{state}] - Text: `rest`, `disabled`.
49
+ * @cssprop [--qds-component-input-invalid-color-border-rest] - Border while invalid.
50
+ * @cssprop [--qds-component-input-placeholder-color-content-rest] - Placeholder text.
51
+ * @cssprop [--qds-component-input-affix-color-content-rest] - Color of slotted start and end content.
52
+ */
53
+ let QdsInput = class QdsInput extends QdsTextControl {
54
+ constructor() {
55
+ super(...arguments);
56
+ /** Accessible name. Required, since this control has no visible label. */
57
+ this.label = '';
58
+ /** Control size. */
59
+ this.size = 'md';
60
+ /**
61
+ * Shows the error state and sets `aria-invalid`, for errors the form itself
62
+ * cannot detect, such as a server-side check. Does not block submission.
63
+ */
64
+ this.invalid = false;
65
+ }
66
+ static { this.styles = [
67
+ QdsElement.baseStyles,
68
+ css `
69
+ :host {
70
+ display: inline-block;
71
+
72
+ --_padding-block: var(--qds-component-input-md-padding-block, 0.5rem);
73
+ --_padding-inline: var(--qds-component-input-md-padding-inline, 0.75rem);
74
+ --_font-size: var(--qds-component-input-md-font-size, 0.875rem);
75
+ --_border: var(--qds-component-input-color-border-rest, #64748b);
76
+ }
77
+
78
+ :host([size='sm']) {
79
+ --_padding-block: var(--qds-component-input-sm-padding-block, 0.25rem);
80
+ --_padding-inline: var(--qds-component-input-sm-padding-inline, 0.5rem);
81
+ --_font-size: var(--qds-component-input-sm-font-size, 0.75rem);
82
+ }
83
+
84
+ :host([size='lg']) {
85
+ --_padding-block: var(--qds-component-input-lg-padding-block, 0.75rem);
86
+ --_padding-inline: var(--qds-component-input-lg-padding-inline, 1rem);
87
+ --_font-size: var(--qds-component-input-lg-font-size, 1rem);
88
+ }
89
+
90
+ /*
91
+ * Invalid either because the author said so, or because the user has
92
+ * interacted and native validation fails. :user-invalid rather than
93
+ * :invalid, so an empty required field is not red before anyone touched it.
94
+ *
95
+ * Set on .base, not :host — :host(:has()) only sees light DOM children, so
96
+ * it can never match the input inside this shadow root.
97
+ */
98
+ :host([invalid]) .base,
99
+ .base:has(input:user-invalid) {
100
+ --_border: var(--qds-component-input-invalid-color-border-rest, #dc2626);
101
+ }
102
+
103
+ .base {
104
+ display: flex;
105
+ align-items: center;
106
+ gap: var(--qds-component-input-gap, 0.5rem);
107
+ width: 100%;
108
+ padding: 0 var(--_padding-inline);
109
+
110
+ font-family: var(--qds-typography-font-family-sans, inherit);
111
+ font-size: var(--_font-size);
112
+ line-height: var(--qds-component-input-line-height, 1.5);
113
+ color: var(--qds-component-input-color-content-rest, #0f172a);
114
+
115
+ background-color: var(--qds-component-input-color-background-rest, #f8fafc);
116
+ border: var(--qds-component-input-border-width, 0.0625rem) solid var(--_border);
117
+ border-radius: var(--qds-component-input-border-radius, 0.375rem);
118
+ cursor: text;
119
+
120
+ transition: border-color var(--qds-component-input-duration, 120ms);
121
+ }
122
+
123
+ /*
124
+ * The focus ring goes on the box rather than the input, so that it wraps
125
+ * the affixes too and reads as one control.
126
+ */
127
+ .base:focus-within {
128
+ border-color: var(--qds-component-input-color-border-focus, #2563eb);
129
+ outline: var(--_focus-ring);
130
+ outline-offset: 0.0625rem;
131
+ }
132
+
133
+ input {
134
+ flex: 1;
135
+ min-width: 0;
136
+ margin: 0;
137
+ padding: var(--_padding-block) 0;
138
+
139
+ font: inherit;
140
+ color: inherit;
141
+ background: none;
142
+ border: 0;
143
+ outline: none;
144
+ }
145
+
146
+ input::placeholder {
147
+ color: var(--qds-component-input-placeholder-color-content-rest, #64748b);
148
+ opacity: 1;
149
+ }
150
+
151
+ ::slotted(*) {
152
+ flex: none;
153
+ color: var(--qds-component-input-affix-color-content-rest, #64748b);
154
+ }
155
+
156
+ :host(:disabled) .base {
157
+ color: var(--qds-component-input-color-content-disabled, #64748b);
158
+ background-color: var(--qds-component-input-color-background-disabled, #f1f5f9);
159
+ border-color: var(--qds-component-input-color-border-disabled, #e2e8f0);
160
+ cursor: not-allowed;
161
+ }
162
+
163
+ :host(:disabled) input {
164
+ cursor: not-allowed;
165
+ }
166
+
167
+ @media (prefers-reduced-motion: reduce) {
168
+ .base {
169
+ transition: none;
170
+ }
171
+ }
172
+
173
+ @media (forced-colors: active) {
174
+ .base {
175
+ border-color: FieldText;
176
+ }
177
+
178
+ :host(:disabled) .base {
179
+ border-color: GrayText;
180
+ }
181
+ }
182
+ `,
183
+ ]; }
184
+ render() {
185
+ return html `
186
+ <div class="base" part="base" @click=${this.focusInput}>
187
+ <slot name="start"></slot>
188
+ <input
189
+ part="input"
190
+ type=${this.type}
191
+ .value=${live(this.value)}
192
+ name=${this.name || nothing}
193
+ placeholder=${this.placeholder || nothing}
194
+ aria-label=${this.label || nothing}
195
+ aria-invalid=${this.invalid ? 'true' : nothing}
196
+ autocomplete=${this.autocomplete ?? nothing}
197
+ minlength=${this.minlength ?? nothing}
198
+ maxlength=${this.maxlength ?? nothing}
199
+ pattern=${this.pattern ?? nothing}
200
+ ?disabled=${this.disabled || this.formDisabled}
201
+ ?readonly=${this.readonly}
202
+ ?required=${this.required}
203
+ @input=${this.handleInput}
204
+ @change=${this.handleChange}
205
+ />
206
+ <slot name="end"></slot>
207
+ </div>
208
+ `;
209
+ }
210
+ };
211
+ __decorate([
212
+ property()
213
+ ], QdsInput.prototype, "label", void 0);
214
+ __decorate([
215
+ property({ reflect: true })
216
+ ], QdsInput.prototype, "size", void 0);
217
+ __decorate([
218
+ property({ type: Boolean, reflect: true })
219
+ ], QdsInput.prototype, "invalid", void 0);
220
+ QdsInput = __decorate([
221
+ customElement('qds-input')
222
+ ], QdsInput);
223
+ export { QdsInput };
224
+ //# sourceMappingURL=qds-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qds-input.js","sourceRoot":"","sources":["../../../src/components/qds-input/qds-input.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;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAA2B,MAAM,oCAAoC,CAAC;AAK7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,cAAc;IAArC;;QAwHL,0EAA0E;QAE1E,UAAK,GAAG,EAAE,CAAC;QAEX,oBAAoB;QAEpB,SAAI,GAAiB,IAAI,CAAC;QAE1B;;;WAGG;QAEH,Y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