@orange-halo/components 2.1.0 → 3.0.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/custom-elements.json +968 -362
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +1 -2
- package/dist/base.js.map +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/oh-accordion.d.ts +53 -8
- package/dist/oh-accordion.d.ts.map +1 -1
- package/dist/oh-accordion.js +99 -29
- package/dist/oh-accordion.js.map +1 -1
- package/dist/oh-alert.d.ts +26 -8
- package/dist/oh-alert.d.ts.map +1 -1
- package/dist/oh-alert.js +96 -36
- package/dist/oh-alert.js.map +1 -1
- package/dist/oh-badge.d.ts +32 -13
- package/dist/oh-badge.d.ts.map +1 -1
- package/dist/oh-badge.js +38 -19
- package/dist/oh-badge.js.map +1 -1
- package/dist/oh-breadcrumb.d.ts +39 -12
- package/dist/oh-breadcrumb.d.ts.map +1 -1
- package/dist/oh-breadcrumb.js +66 -25
- package/dist/oh-breadcrumb.js.map +1 -1
- package/dist/oh-button.d.ts +49 -23
- package/dist/oh-button.d.ts.map +1 -1
- package/dist/oh-button.figma.js +1 -3
- package/dist/oh-button.figma.js.map +1 -1
- package/dist/oh-button.js +133 -82
- package/dist/oh-button.js.map +1 -1
- package/dist/oh-card.d.ts +47 -19
- package/dist/oh-card.d.ts.map +1 -1
- package/dist/oh-card.js +143 -96
- package/dist/oh-card.js.map +1 -1
- package/dist/oh-checkbox-group.d.ts +56 -12
- package/dist/oh-checkbox-group.d.ts.map +1 -1
- package/dist/oh-checkbox-group.figma.js +4 -6
- package/dist/oh-checkbox-group.figma.js.map +1 -1
- package/dist/oh-checkbox-group.js +114 -49
- package/dist/oh-checkbox-group.js.map +1 -1
- package/dist/oh-checkbox.d.ts +54 -17
- package/dist/oh-checkbox.d.ts.map +1 -1
- package/dist/oh-checkbox.js +117 -60
- package/dist/oh-checkbox.js.map +1 -1
- package/dist/oh-cluster.d.ts +19 -14
- package/dist/oh-cluster.d.ts.map +1 -1
- package/dist/oh-cluster.js +19 -19
- package/dist/oh-cluster.js.map +1 -1
- package/dist/oh-container.d.ts +19 -16
- package/dist/oh-container.d.ts.map +1 -1
- package/dist/oh-container.js +21 -23
- package/dist/oh-container.js.map +1 -1
- package/dist/oh-drawer.d.ts +28 -11
- package/dist/oh-drawer.d.ts.map +1 -1
- package/dist/oh-drawer.js +52 -24
- package/dist/oh-drawer.js.map +1 -1
- package/dist/oh-footer.d.ts +37 -18
- package/dist/oh-footer.d.ts.map +1 -1
- package/dist/oh-footer.js +38 -19
- package/dist/oh-footer.js.map +1 -1
- package/dist/oh-grid.d.ts +27 -14
- package/dist/oh-grid.d.ts.map +1 -1
- package/dist/oh-grid.js +28 -21
- package/dist/oh-grid.js.map +1 -1
- package/dist/oh-icon.d.ts +21 -5
- package/dist/oh-icon.d.ts.map +1 -1
- package/dist/oh-icon.js +27 -9
- package/dist/oh-icon.js.map +1 -1
- package/dist/oh-input.d.ts +110 -21
- package/dist/oh-input.d.ts.map +1 -1
- package/dist/oh-input.figma.js +2 -2
- package/dist/oh-input.figma.js.map +1 -1
- package/dist/oh-input.js +227 -71
- package/dist/oh-input.js.map +1 -1
- package/dist/oh-link.d.ts +42 -19
- package/dist/oh-link.d.ts.map +1 -1
- package/dist/oh-link.js +83 -38
- package/dist/oh-link.js.map +1 -1
- package/dist/oh-modal.d.ts +35 -6
- package/dist/oh-modal.d.ts.map +1 -1
- package/dist/oh-modal.js +90 -39
- package/dist/oh-modal.js.map +1 -1
- package/dist/oh-navbar.d.ts +42 -19
- package/dist/oh-navbar.d.ts.map +1 -1
- package/dist/oh-navbar.js +44 -20
- package/dist/oh-navbar.js.map +1 -1
- package/dist/oh-progress.d.ts +26 -7
- package/dist/oh-progress.d.ts.map +1 -1
- package/dist/oh-progress.js +35 -14
- package/dist/oh-progress.js.map +1 -1
- package/dist/oh-radio-group.d.ts +55 -13
- package/dist/oh-radio-group.d.ts.map +1 -1
- package/dist/oh-radio-group.figma.js +2 -2
- package/dist/oh-radio-group.figma.js.map +1 -1
- package/dist/oh-radio-group.js +122 -51
- package/dist/oh-radio-group.js.map +1 -1
- package/dist/oh-radio.d.ts +55 -17
- package/dist/oh-radio.d.ts.map +1 -1
- package/dist/oh-radio.js +120 -61
- package/dist/oh-radio.js.map +1 -1
- package/dist/oh-select.d.ts +59 -16
- package/dist/oh-select.d.ts.map +1 -1
- package/dist/oh-select.js +141 -69
- package/dist/oh-select.js.map +1 -1
- package/dist/oh-skip-link.d.ts +33 -15
- package/dist/oh-skip-link.d.ts.map +1 -1
- package/dist/oh-skip-link.js +43 -32
- package/dist/oh-skip-link.js.map +1 -1
- package/dist/oh-stack.d.ts +17 -14
- package/dist/oh-stack.d.ts.map +1 -1
- package/dist/oh-stack.js +18 -20
- package/dist/oh-stack.js.map +1 -1
- package/dist/oh-tabs.d.ts +55 -30
- package/dist/oh-tabs.d.ts.map +1 -1
- package/dist/oh-tabs.js +100 -76
- package/dist/oh-tabs.js.map +1 -1
- package/dist/oh-textarea.d.ts +129 -0
- package/dist/oh-textarea.d.ts.map +1 -0
- package/dist/oh-textarea.js +401 -0
- package/dist/oh-textarea.js.map +1 -0
- package/dist/oh-toggle.d.ts +45 -12
- package/dist/oh-toggle.d.ts.map +1 -1
- package/dist/oh-toggle.js +84 -34
- package/dist/oh-toggle.js.map +1 -1
- package/dist/styles/typography.js +1 -1
- package/package.json +7 -7
- package/dist/oh-hero.d.ts +0 -33
- package/dist/oh-hero.d.ts.map +0 -1
- package/dist/oh-hero.js +0 -246
- package/dist/oh-hero.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-checkbox-group
|
|
3
3
|
*
|
|
4
|
-
* A checkbox group with
|
|
4
|
+
* A checkbox group with fieldset semantics and group-level error handling.
|
|
5
5
|
* For single checkboxes, use oh-checkbox directly.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* - Uses <fieldset> and <legend
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
*
|
|
14
|
-
*
|
|
7
|
+
* DESIGN DECISIONS:
|
|
8
|
+
* ─────────────────
|
|
9
|
+
* - Uses <fieldset> and <legend>, so the legend names the group
|
|
10
|
+
* - One error for the group, after the legend and before the options,
|
|
11
|
+
* linked with aria-describedby; aria-invalid on the fieldset
|
|
12
|
+
* - Each option is a visually hidden native checkbox; focus underlines its
|
|
13
|
+
* label (a solid indicator)
|
|
14
|
+
* - The drawn boxes use the same tokens as oh-checkbox
|
|
15
15
|
*/
|
|
16
16
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
17
17
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -22,16 +22,59 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
22
22
|
import { html, css, nothing } from "lit";
|
|
23
23
|
import { customElement, property, state } from "lit/decorators.js";
|
|
24
24
|
import { OhElement, baseStyles } from "./base.js";
|
|
25
|
+
/**
|
|
26
|
+
* A set of related checkboxes under one legend, where any number can be
|
|
27
|
+
* chosen.
|
|
28
|
+
*
|
|
29
|
+
* **Use it for** choosing any number of options from a short list, such as
|
|
30
|
+
* interests or notification types. **Don't use it for** one standalone
|
|
31
|
+
* yes/no option (use `oh-checkbox`), exactly one choice (use
|
|
32
|
+
* `oh-radio-group`, or `oh-select` for a long list), or settings that apply
|
|
33
|
+
* straight away (use `oh-toggle`).
|
|
34
|
+
*
|
|
35
|
+
* **Parts:** a `label` (rendered as the fieldset's `<legend>`) and a list of `options` (`{ label, value }`).
|
|
36
|
+
* `value` is the array of checked option values. **States:** each option
|
|
37
|
+
* unchecked, checked, hover, active and focus; the group can be `required`
|
|
38
|
+
* (a marker on the label) and in error (set `error-text`).
|
|
39
|
+
*
|
|
40
|
+
* **Behaviour:** Tab moves through the options and Space toggles one. Each
|
|
41
|
+
* change updates `value` and fires `oh-change` with the new array. The
|
|
42
|
+
* native checkboxes sit in the shadow root, so they don't submit with a
|
|
43
|
+
* native form: read `value` or listen for `oh-change`. `required` doesn't
|
|
44
|
+
* validate; set the error yourself.
|
|
45
|
+
*
|
|
46
|
+
* **Accessibility:** a `<fieldset>` with a `<legend>`, so screen readers
|
|
47
|
+
* read the label with each option. Always set `label`. The error shows
|
|
48
|
+
* after the legend and before the options, with an icon; the fieldset gets
|
|
49
|
+
* `aria-invalid` and `aria-describedby`, and the error is announced
|
|
50
|
+
* (`role="alert"`) only when it appears after first render. Focus underlines
|
|
51
|
+
* the option's label.
|
|
52
|
+
*
|
|
53
|
+
* **Look:** set by tokens — the same as `oh-checkbox`: `stroke.control` in
|
|
54
|
+
* `color.border.emphasis` (border), `shape.compact` (corners),
|
|
55
|
+
* `elevation.offset.*` with `elevation.color.secondary` / `elevation.color.primary` (shadow),
|
|
56
|
+
* `lift.hoverSm` / `lift.pressSm` (movement on hover and press),
|
|
57
|
+
* `color.brand.primary` and `color.text.onBrand` (checked),
|
|
58
|
+
* `color.feedback.error` and `elevation.color.error` (error); `typography.control.*`
|
|
59
|
+
* for the legend and labels.
|
|
60
|
+
*
|
|
61
|
+
* @element oh-checkbox-group
|
|
62
|
+
* @fires oh-change - An option was toggled. detail: { value } (the checked values)
|
|
63
|
+
*/
|
|
25
64
|
let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
26
65
|
constructor() {
|
|
27
66
|
super(...arguments);
|
|
28
|
-
|
|
67
|
+
/** The group's label, rendered as the fieldset's <legend>. Always set one */
|
|
68
|
+
this.label = "";
|
|
29
69
|
this.name = "";
|
|
30
70
|
this.options = [];
|
|
31
71
|
this.value = [];
|
|
32
72
|
this.required = false;
|
|
33
|
-
|
|
34
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Error shown with the control and linked to it. Setting it puts the
|
|
75
|
+
* control in its error state; clear it to leave that state.
|
|
76
|
+
*/
|
|
77
|
+
this.errorText = "";
|
|
35
78
|
/**
|
|
36
79
|
* Errors that appear after first render (e.g. on submit) are announced via
|
|
37
80
|
* role="alert". Errors present on page load are only linked with
|
|
@@ -111,16 +154,17 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
111
154
|
border: var(--oh-stroke-control) solid var(--oh-color-border-emphasis);
|
|
112
155
|
border-radius: var(--oh-shape-compact);
|
|
113
156
|
background-color: var(--oh-color-surface-base);
|
|
114
|
-
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
157
|
+
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
158
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
159
|
+
transition:
|
|
160
|
+
transform var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
161
|
+
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
118
162
|
background-color var(--oh-motion-quick) ease,
|
|
119
163
|
border-color var(--oh-motion-quick) ease;
|
|
120
164
|
}
|
|
121
165
|
|
|
122
166
|
.checkbox-box::after {
|
|
123
|
-
content:
|
|
167
|
+
content: "";
|
|
124
168
|
position: absolute;
|
|
125
169
|
top: 3px;
|
|
126
170
|
left: 7px;
|
|
@@ -145,24 +189,27 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
145
189
|
STATES
|
|
146
190
|
═══════════════════════════════════════════════════════════════ */
|
|
147
191
|
|
|
148
|
-
/* Hover: lift
|
|
192
|
+
/* Hover: moves by lift.hoverSm; shadow offset elevation.offset.lg */
|
|
149
193
|
.checkbox-option:hover .checkbox-box {
|
|
150
194
|
border-color: var(--oh-color-border-hover);
|
|
151
195
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
152
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
196
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
197
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
153
198
|
}
|
|
154
199
|
|
|
155
|
-
/* Active:
|
|
200
|
+
/* Active: moves by lift.pressSm; shadow offset elevation.offset.xs */
|
|
156
201
|
.checkbox-option:active .checkbox-box {
|
|
157
202
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
158
|
-
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
203
|
+
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
204
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
159
205
|
}
|
|
160
206
|
|
|
161
|
-
/* Checked: primary color
|
|
207
|
+
/* Checked: color.brand.primary fill, elevation.color.primary shadow */
|
|
162
208
|
.native-checkbox:checked + .checkbox-box {
|
|
163
209
|
background-color: var(--oh-color-brand-primary);
|
|
164
210
|
border-color: var(--oh-color-brand-primary);
|
|
165
|
-
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
211
|
+
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
212
|
+
0 0 var(--oh-elevation-color-primary);
|
|
166
213
|
}
|
|
167
214
|
|
|
168
215
|
.native-checkbox:checked + .checkbox-box::after {
|
|
@@ -174,14 +221,16 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
174
221
|
background-color: var(--oh-color-brand-primary-hover);
|
|
175
222
|
border-color: var(--oh-color-brand-primary-hover);
|
|
176
223
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
177
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
224
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
225
|
+
0 0 var(--oh-elevation-color-primary);
|
|
178
226
|
}
|
|
179
227
|
|
|
180
228
|
/* Checked + Active */
|
|
181
229
|
.checkbox-option:active .native-checkbox:checked + .checkbox-box {
|
|
182
230
|
background-color: var(--oh-color-brand-primary-active);
|
|
183
231
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
184
|
-
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
232
|
+
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
233
|
+
0 0 var(--oh-elevation-color-primary);
|
|
185
234
|
}
|
|
186
235
|
|
|
187
236
|
/* Focus: underline the label (accessible indicator) */
|
|
@@ -194,14 +243,16 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
194
243
|
ERROR STATE
|
|
195
244
|
═══════════════════════════════════════════════════════════════ */
|
|
196
245
|
|
|
197
|
-
:host([
|
|
246
|
+
:host([data-invalid]) .checkbox-box {
|
|
198
247
|
border-color: var(--oh-color-feedback-error);
|
|
199
|
-
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
248
|
+
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
249
|
+
0 0 var(--oh-elevation-color-error);
|
|
200
250
|
}
|
|
201
251
|
|
|
202
|
-
:host([
|
|
252
|
+
:host([data-invalid]) .checkbox-option:hover .checkbox-box {
|
|
203
253
|
border-color: var(--oh-color-feedback-error-hover);
|
|
204
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
254
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
255
|
+
0 0 var(--oh-elevation-color-error);
|
|
205
256
|
}
|
|
206
257
|
|
|
207
258
|
.error-message {
|
|
@@ -238,40 +289,57 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
238
289
|
this.value = [...this.value, optionValue];
|
|
239
290
|
}
|
|
240
291
|
else {
|
|
241
|
-
this.value = this.value.filter(v => v !== optionValue);
|
|
292
|
+
this.value = this.value.filter((v) => v !== optionValue);
|
|
242
293
|
}
|
|
243
294
|
this.emit("oh-change", { value: this.value });
|
|
244
295
|
}
|
|
296
|
+
updated(changed) {
|
|
297
|
+
// Styling hook for the error state (data-invalid on the host)
|
|
298
|
+
if (changed.has("errorText"))
|
|
299
|
+
this.toggleAttribute("data-invalid", !!this.errorText);
|
|
300
|
+
}
|
|
245
301
|
willUpdate(changed) {
|
|
246
|
-
if (this.hasUpdated &&
|
|
247
|
-
this._announceError = !!
|
|
302
|
+
if (this.hasUpdated && changed.has("errorText")) {
|
|
303
|
+
this._announceError = !!this.errorText;
|
|
248
304
|
}
|
|
249
305
|
}
|
|
250
306
|
render() {
|
|
251
307
|
return html `
|
|
252
308
|
<fieldset
|
|
253
|
-
aria-invalid=${this.
|
|
254
|
-
aria-describedby=${this.
|
|
309
|
+
aria-invalid=${this.errorText ? "true" : nothing}
|
|
310
|
+
aria-describedby=${this.errorText ? "error-msg" : nothing}
|
|
255
311
|
>
|
|
256
|
-
${this.
|
|
312
|
+
${this.label
|
|
257
313
|
? html `
|
|
258
314
|
<legend class="${this.required ? "legend--required" : ""}">
|
|
259
|
-
${this.
|
|
315
|
+
${this.label}
|
|
260
316
|
</legend>
|
|
261
317
|
`
|
|
262
318
|
: nothing}
|
|
263
|
-
|
|
264
|
-
${this.error && this.errorMessage
|
|
319
|
+
${this.errorText
|
|
265
320
|
? html `
|
|
266
|
-
<div
|
|
267
|
-
|
|
268
|
-
|
|
321
|
+
<div
|
|
322
|
+
id="error-msg"
|
|
323
|
+
class="error-message"
|
|
324
|
+
role=${this._announceError ? "alert" : nothing}
|
|
325
|
+
>
|
|
326
|
+
<svg
|
|
327
|
+
class="error-icon"
|
|
328
|
+
viewBox="0 0 20 20"
|
|
329
|
+
fill="currentColor"
|
|
330
|
+
aria-hidden="true"
|
|
331
|
+
>
|
|
332
|
+
<path
|
|
333
|
+
fill-rule="evenodd"
|
|
334
|
+
d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z"
|
|
335
|
+
clip-rule="evenodd"
|
|
336
|
+
/>
|
|
269
337
|
</svg>
|
|
270
|
-
${this.
|
|
338
|
+
${this.errorText}
|
|
271
339
|
</div>
|
|
272
340
|
`
|
|
273
341
|
: nothing}
|
|
274
|
-
|
|
342
|
+
|
|
275
343
|
<div class="checkbox-group">
|
|
276
344
|
${this.options.map((option) => html `
|
|
277
345
|
<label class="checkbox-option">
|
|
@@ -294,7 +362,7 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
294
362
|
};
|
|
295
363
|
__decorate([
|
|
296
364
|
property({ type: String })
|
|
297
|
-
], OhCheckboxGroup.prototype, "
|
|
365
|
+
], OhCheckboxGroup.prototype, "label", void 0);
|
|
298
366
|
__decorate([
|
|
299
367
|
property({ type: String })
|
|
300
368
|
], OhCheckboxGroup.prototype, "name", void 0);
|
|
@@ -308,11 +376,8 @@ __decorate([
|
|
|
308
376
|
property({ type: Boolean, reflect: true })
|
|
309
377
|
], OhCheckboxGroup.prototype, "required", void 0);
|
|
310
378
|
__decorate([
|
|
311
|
-
property({ type:
|
|
312
|
-
], OhCheckboxGroup.prototype, "
|
|
313
|
-
__decorate([
|
|
314
|
-
property({ type: String })
|
|
315
|
-
], OhCheckboxGroup.prototype, "errorMessage", void 0);
|
|
379
|
+
property({ type: String, attribute: "error-text" })
|
|
380
|
+
], OhCheckboxGroup.prototype, "errorText", void 0);
|
|
316
381
|
__decorate([
|
|
317
382
|
state()
|
|
318
383
|
], OhCheckboxGroup.prototype, "_announceError", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-checkbox-group.js","sourceRoot":"","sources":["../src/oh-checkbox-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;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|
1
1
|
/**
|
|
2
2
|
* oh-checkbox
|
|
3
3
|
*
|
|
4
|
-
* A chunky, playful checkbox with hand-crafted feel.
|
|
5
|
-
* Matches the inset/pressed aesthetic of oh-input.
|
|
6
|
-
*
|
|
7
4
|
* DESIGN DECISIONS:
|
|
8
5
|
* ─────────────────
|
|
9
|
-
* 1.
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
6
|
+
* 1. LOOK FROM TOKENS
|
|
7
|
+
* - Border: stroke.control in color.border.emphasis
|
|
8
|
+
* - Corners: shape.compact (smaller than the other controls' shape.control)
|
|
9
|
+
* - Shadow: offset by elevation.offset.* in elevation.color.secondary; hover and
|
|
10
|
+
* press move the box by lift.hoverSm / lift.pressSm
|
|
13
11
|
*
|
|
14
12
|
* 2. CHECKED STATE
|
|
15
|
-
* - Filled with primary color
|
|
16
|
-
*
|
|
17
|
-
* - Shadow shifts to feel "activated"
|
|
13
|
+
* - Filled with color.brand.primary, a checkmark in color.text.onBrand,
|
|
14
|
+
* and the shadow in elevation.color.primary
|
|
18
15
|
*
|
|
19
16
|
* 3. ACCESSIBILITY
|
|
20
|
-
* -
|
|
17
|
+
* - A native checkbox, visually hidden but focusable and announced; the
|
|
18
|
+
* drawn box is decoration
|
|
21
19
|
* - Label always required
|
|
22
|
-
* - Focus
|
|
23
|
-
* - Minimum touch target 44px
|
|
24
|
-
*
|
|
25
|
-
* @element oh-checkbox
|
|
20
|
+
* - Focus underlines the label (a solid indicator)
|
|
26
21
|
*/
|
|
27
22
|
import { type PropertyValues } from "lit";
|
|
28
23
|
import { OhElement } from "./base.js";
|
|
29
24
|
export type CheckboxState = "default" | "hover" | "focus";
|
|
25
|
+
/**
|
|
26
|
+
* A single checkbox with its label, for turning one option on or off.
|
|
27
|
+
*
|
|
28
|
+
* **Use it for** one yes/no choice, such as agreeing to terms, or as part of
|
|
29
|
+
* a set where any number can be chosen. **Don't use it for** a set of
|
|
30
|
+
* related options on its own (use `oh-checkbox-group`, which adds the
|
|
31
|
+
* fieldset and legend), one choice from several (use `oh-radio-group`), or a
|
|
32
|
+
* setting that applies straight away (use `oh-toggle`).
|
|
33
|
+
*
|
|
34
|
+
* **States:** unchecked, checked, hover, active, focus, error (set `error-text`).
|
|
35
|
+
*
|
|
36
|
+
* **Behaviour:** clicking the box or the label toggles it, as does Space
|
|
37
|
+
* when it's focused. Each change sets `checked` and fires `oh-change`. The
|
|
38
|
+
* native `<input type="checkbox">` sits in the shadow root, so it doesn't
|
|
39
|
+
* submit with a native form: read `checked` or listen for `oh-change`. It
|
|
40
|
+
* has no `disabled` property.
|
|
41
|
+
*
|
|
42
|
+
* **Accessibility:** a real native checkbox, visually hidden, carries the
|
|
43
|
+
* role, state and keyboard behaviour; the drawn box is decoration. Always
|
|
44
|
+
* set `label`: it's the checkbox's name. Focus underlines the label. The
|
|
45
|
+
* error message shows under the checkbox with an icon, sets `aria-invalid`
|
|
46
|
+
* and is linked with `aria-describedby`; it's announced (`role="alert"`)
|
|
47
|
+
* only when it appears after first render.
|
|
48
|
+
*
|
|
49
|
+
* **Look:** set by tokens — `stroke.control` in `color.border.emphasis`
|
|
50
|
+
* (border), `shape.compact` (corners), `typography.control.*` (label),
|
|
51
|
+
* `elevation.offset.*` and `elevation.color.secondary` (shadow), `lift.hoverSm` /
|
|
52
|
+
* `lift.pressSm` (movement on hover and press), `color.border.hover`
|
|
53
|
+
* (hover), `color.brand.primary` (and its hover and active tokens),
|
|
54
|
+
* `color.text.onBrand` and `elevation.color.primary` (checked),
|
|
55
|
+
* `color.feedback.error` and `elevation.color.error` (error).
|
|
56
|
+
*
|
|
57
|
+
* @element oh-checkbox
|
|
58
|
+
* @fires oh-change - The checkbox was toggled. detail: { checked, value }
|
|
59
|
+
* @csspart box - The drawn checkbox
|
|
60
|
+
* @csspart label - The label text
|
|
61
|
+
* @csspart error - The error message
|
|
62
|
+
*/
|
|
30
63
|
export declare class OhCheckbox extends OhElement {
|
|
31
64
|
static styles: import("lit").CSSResult[];
|
|
32
65
|
checked: boolean;
|
|
33
66
|
label: string;
|
|
34
67
|
name: string;
|
|
35
68
|
value: string;
|
|
36
|
-
|
|
37
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Error shown with the control and linked to it. Setting it puts the
|
|
71
|
+
* control in its error state; clear it to leave that state.
|
|
72
|
+
*/
|
|
73
|
+
errorText: string;
|
|
38
74
|
/**
|
|
39
75
|
* Force a visual state (for documentation/Figma sync only)
|
|
40
76
|
* Values: 'hover' | 'focus'
|
|
@@ -48,6 +84,7 @@ export declare class OhCheckbox extends OhElement {
|
|
|
48
84
|
*/
|
|
49
85
|
private _announceError;
|
|
50
86
|
private _errorId;
|
|
87
|
+
updated(changed: PropertyValues): void;
|
|
51
88
|
willUpdate(changed: PropertyValues): void;
|
|
52
89
|
render(): import("lit").TemplateResult<1>;
|
|
53
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-checkbox.d.ts","sourceRoot":"","sources":["../src/oh-checkbox.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oh-checkbox.d.ts","sourceRoot":"","sources":["../src/oh-checkbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAc,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,qBACa,UAAW,SAAQ,SAAS;IACvC,OAAgB,MAAM,4BA8MpB;IAGF,OAAO,UAAS;IAGhB,KAAK,SAAM;IAGX,IAAI,SAAM;IAGV,KAAK,SAAM;IAEX;;;OAGG;IAEH,SAAS,SAAM;IAEf;;;OAGG;IAEH,UAAU,EAAE,aAAa,CAAa;IAEtC,OAAO,CAAC,aAAa;IAMrB;;;;OAIG;IAEH,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO,CAAC,QAAQ,CAAkE;IAElF,OAAO,CAAC,OAAO,EAAE,cAAc;IAM/B,UAAU,CAAC,OAAO,EAAE,cAAc;IAMlC,MAAM;CAgDP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|