@orange-halo/components 2.2.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 +551 -314
- package/dist/index.d.ts +1 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -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 +77 -15
- 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 +32 -14
- 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 +35 -16
- 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 +39 -17
- 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.js +63 -44
- 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 +110 -82
- 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 +86 -44
- 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 +85 -55
- 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 +31 -14
- 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 +27 -19
- 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 +21 -5
- package/dist/oh-icon.js.map +1 -1
- package/dist/oh-input.d.ts +104 -20
- 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 +205 -66
- 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 +47 -29
- package/dist/oh-link.js.map +1 -1
- package/dist/oh-modal.d.ts +29 -6
- package/dist/oh-modal.d.ts.map +1 -1
- package/dist/oh-modal.js +37 -16
- 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 +42 -19
- 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 +31 -12
- 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 +83 -43
- 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 +87 -56
- package/dist/oh-radio.js.map +1 -1
- package/dist/oh-select.d.ts +58 -16
- package/dist/oh-select.d.ts.map +1 -1
- package/dist/oh-select.js +70 -33
- 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 +38 -25
- 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 +80 -65
- package/dist/oh-tabs.js.map +1 -1
- package/dist/oh-textarea.d.ts +37 -6
- package/dist/oh-textarea.d.ts.map +1 -1
- package/dist/oh-textarea.js +40 -9
- package/dist/oh-textarea.js.map +1 -1
- package/dist/oh-toggle.d.ts +45 -12
- package/dist/oh-toggle.d.ts.map +1 -1
- package/dist/oh-toggle.js +64 -29
- package/dist/oh-toggle.js.map +1 -1
- package/package.json +3 -7
- package/dist/oh-hero.d.ts +0 -33
- package/dist/oh-hero.d.ts.map +0 -1
- package/dist/oh-hero.js +0 -248
- 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
|
|
@@ -112,10 +155,10 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
112
155
|
border-radius: var(--oh-shape-compact);
|
|
113
156
|
background-color: var(--oh-color-surface-base);
|
|
114
157
|
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
115
|
-
0 0 var(--oh-
|
|
158
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
116
159
|
transition:
|
|
117
|
-
transform var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
118
|
-
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
160
|
+
transform var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
161
|
+
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
119
162
|
background-color var(--oh-motion-quick) ease,
|
|
120
163
|
border-color var(--oh-motion-quick) ease;
|
|
121
164
|
}
|
|
@@ -146,27 +189,27 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
146
189
|
STATES
|
|
147
190
|
═══════════════════════════════════════════════════════════════ */
|
|
148
191
|
|
|
149
|
-
/* Hover: lift
|
|
192
|
+
/* Hover: moves by lift.hoverSm; shadow offset elevation.offset.lg */
|
|
150
193
|
.checkbox-option:hover .checkbox-box {
|
|
151
194
|
border-color: var(--oh-color-border-hover);
|
|
152
195
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
153
196
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
154
|
-
0 0 var(--oh-
|
|
197
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
155
198
|
}
|
|
156
199
|
|
|
157
|
-
/* Active:
|
|
200
|
+
/* Active: moves by lift.pressSm; shadow offset elevation.offset.xs */
|
|
158
201
|
.checkbox-option:active .checkbox-box {
|
|
159
202
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
160
203
|
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
161
|
-
0 0 var(--oh-
|
|
204
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
162
205
|
}
|
|
163
206
|
|
|
164
|
-
/* Checked: primary color
|
|
207
|
+
/* Checked: color.brand.primary fill, elevation.color.primary shadow */
|
|
165
208
|
.native-checkbox:checked + .checkbox-box {
|
|
166
209
|
background-color: var(--oh-color-brand-primary);
|
|
167
210
|
border-color: var(--oh-color-brand-primary);
|
|
168
211
|
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
169
|
-
0 0 var(--oh-
|
|
212
|
+
0 0 var(--oh-elevation-color-primary);
|
|
170
213
|
}
|
|
171
214
|
|
|
172
215
|
.native-checkbox:checked + .checkbox-box::after {
|
|
@@ -179,7 +222,7 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
179
222
|
border-color: var(--oh-color-brand-primary-hover);
|
|
180
223
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
181
224
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
182
|
-
0 0 var(--oh-
|
|
225
|
+
0 0 var(--oh-elevation-color-primary);
|
|
183
226
|
}
|
|
184
227
|
|
|
185
228
|
/* Checked + Active */
|
|
@@ -187,7 +230,7 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
187
230
|
background-color: var(--oh-color-brand-primary-active);
|
|
188
231
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
189
232
|
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
190
|
-
0 0 var(--oh-
|
|
233
|
+
0 0 var(--oh-elevation-color-primary);
|
|
191
234
|
}
|
|
192
235
|
|
|
193
236
|
/* Focus: underline the label (accessible indicator) */
|
|
@@ -200,16 +243,16 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
200
243
|
ERROR STATE
|
|
201
244
|
═══════════════════════════════════════════════════════════════ */
|
|
202
245
|
|
|
203
|
-
:host([
|
|
246
|
+
:host([data-invalid]) .checkbox-box {
|
|
204
247
|
border-color: var(--oh-color-feedback-error);
|
|
205
248
|
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
206
|
-
0 0 var(--oh-
|
|
249
|
+
0 0 var(--oh-elevation-color-error);
|
|
207
250
|
}
|
|
208
251
|
|
|
209
|
-
:host([
|
|
252
|
+
:host([data-invalid]) .checkbox-option:hover .checkbox-box {
|
|
210
253
|
border-color: var(--oh-color-feedback-error-hover);
|
|
211
254
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
212
|
-
0 0 var(--oh-
|
|
255
|
+
0 0 var(--oh-elevation-color-error);
|
|
213
256
|
}
|
|
214
257
|
|
|
215
258
|
.error-message {
|
|
@@ -250,28 +293,30 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
250
293
|
}
|
|
251
294
|
this.emit("oh-change", { value: this.value });
|
|
252
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
|
+
}
|
|
253
301
|
willUpdate(changed) {
|
|
254
|
-
if (this.hasUpdated &&
|
|
255
|
-
|
|
256
|
-
this._announceError = !!(this.error && this.errorMessage);
|
|
302
|
+
if (this.hasUpdated && changed.has("errorText")) {
|
|
303
|
+
this._announceError = !!this.errorText;
|
|
257
304
|
}
|
|
258
305
|
}
|
|
259
306
|
render() {
|
|
260
307
|
return html `
|
|
261
308
|
<fieldset
|
|
262
|
-
aria-invalid=${this.
|
|
263
|
-
aria-describedby=${this.error
|
|
264
|
-
? "error-msg"
|
|
265
|
-
: nothing}
|
|
309
|
+
aria-invalid=${this.errorText ? "true" : nothing}
|
|
310
|
+
aria-describedby=${this.errorText ? "error-msg" : nothing}
|
|
266
311
|
>
|
|
267
|
-
${this.
|
|
312
|
+
${this.label
|
|
268
313
|
? html `
|
|
269
314
|
<legend class="${this.required ? "legend--required" : ""}">
|
|
270
|
-
${this.
|
|
315
|
+
${this.label}
|
|
271
316
|
</legend>
|
|
272
317
|
`
|
|
273
318
|
: nothing}
|
|
274
|
-
${this.
|
|
319
|
+
${this.errorText
|
|
275
320
|
? html `
|
|
276
321
|
<div
|
|
277
322
|
id="error-msg"
|
|
@@ -290,7 +335,7 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
290
335
|
clip-rule="evenodd"
|
|
291
336
|
/>
|
|
292
337
|
</svg>
|
|
293
|
-
${this.
|
|
338
|
+
${this.errorText}
|
|
294
339
|
</div>
|
|
295
340
|
`
|
|
296
341
|
: nothing}
|
|
@@ -317,7 +362,7 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
317
362
|
};
|
|
318
363
|
__decorate([
|
|
319
364
|
property({ type: String })
|
|
320
|
-
], OhCheckboxGroup.prototype, "
|
|
365
|
+
], OhCheckboxGroup.prototype, "label", void 0);
|
|
321
366
|
__decorate([
|
|
322
367
|
property({ type: String })
|
|
323
368
|
], OhCheckboxGroup.prototype, "name", void 0);
|
|
@@ -331,11 +376,8 @@ __decorate([
|
|
|
331
376
|
property({ type: Boolean, reflect: true })
|
|
332
377
|
], OhCheckboxGroup.prototype, "required", void 0);
|
|
333
378
|
__decorate([
|
|
334
|
-
property({ type:
|
|
335
|
-
], OhCheckboxGroup.prototype, "
|
|
336
|
-
__decorate([
|
|
337
|
-
property({ type: String })
|
|
338
|
-
], OhCheckboxGroup.prototype, "errorMessage", void 0);
|
|
379
|
+
property({ type: String, attribute: "error-text" })
|
|
380
|
+
], OhCheckboxGroup.prototype, "errorText", void 0);
|
|
339
381
|
__decorate([
|
|
340
382
|
state()
|
|
341
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;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"oh-checkbox-group.js","sourceRoot":"","sources":["../src/oh-checkbox-group.ts"],"names":[],"mappings":"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"}
|
package/dist/oh-checkbox.d.ts
CHANGED
|
@@ -1,40 +1,76 @@
|
|
|
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"}
|
package/dist/oh-checkbox.js
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
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
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
28
23
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -33,6 +28,44 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
33
28
|
import { html, css, nothing } from "lit";
|
|
34
29
|
import { customElement, property, state } from "lit/decorators.js";
|
|
35
30
|
import { OhElement, baseStyles } from "./base.js";
|
|
31
|
+
/**
|
|
32
|
+
* A single checkbox with its label, for turning one option on or off.
|
|
33
|
+
*
|
|
34
|
+
* **Use it for** one yes/no choice, such as agreeing to terms, or as part of
|
|
35
|
+
* a set where any number can be chosen. **Don't use it for** a set of
|
|
36
|
+
* related options on its own (use `oh-checkbox-group`, which adds the
|
|
37
|
+
* fieldset and legend), one choice from several (use `oh-radio-group`), or a
|
|
38
|
+
* setting that applies straight away (use `oh-toggle`).
|
|
39
|
+
*
|
|
40
|
+
* **States:** unchecked, checked, hover, active, focus, error (set `error-text`).
|
|
41
|
+
*
|
|
42
|
+
* **Behaviour:** clicking the box or the label toggles it, as does Space
|
|
43
|
+
* when it's focused. Each change sets `checked` and fires `oh-change`. The
|
|
44
|
+
* native `<input type="checkbox">` sits in the shadow root, so it doesn't
|
|
45
|
+
* submit with a native form: read `checked` or listen for `oh-change`. It
|
|
46
|
+
* has no `disabled` property.
|
|
47
|
+
*
|
|
48
|
+
* **Accessibility:** a real native checkbox, visually hidden, carries the
|
|
49
|
+
* role, state and keyboard behaviour; the drawn box is decoration. Always
|
|
50
|
+
* set `label`: it's the checkbox's name. Focus underlines the label. The
|
|
51
|
+
* error message shows under the checkbox with an icon, sets `aria-invalid`
|
|
52
|
+
* and is linked with `aria-describedby`; it's announced (`role="alert"`)
|
|
53
|
+
* only when it appears after first render.
|
|
54
|
+
*
|
|
55
|
+
* **Look:** set by tokens — `stroke.control` in `color.border.emphasis`
|
|
56
|
+
* (border), `shape.compact` (corners), `typography.control.*` (label),
|
|
57
|
+
* `elevation.offset.*` and `elevation.color.secondary` (shadow), `lift.hoverSm` /
|
|
58
|
+
* `lift.pressSm` (movement on hover and press), `color.border.hover`
|
|
59
|
+
* (hover), `color.brand.primary` (and its hover and active tokens),
|
|
60
|
+
* `color.text.onBrand` and `elevation.color.primary` (checked),
|
|
61
|
+
* `color.feedback.error` and `elevation.color.error` (error).
|
|
62
|
+
*
|
|
63
|
+
* @element oh-checkbox
|
|
64
|
+
* @fires oh-change - The checkbox was toggled. detail: { checked, value }
|
|
65
|
+
* @csspart box - The drawn checkbox
|
|
66
|
+
* @csspart label - The label text
|
|
67
|
+
* @csspart error - The error message
|
|
68
|
+
*/
|
|
36
69
|
let OhCheckbox = class OhCheckbox extends OhElement {
|
|
37
70
|
constructor() {
|
|
38
71
|
super(...arguments);
|
|
@@ -40,8 +73,11 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
40
73
|
this.label = "";
|
|
41
74
|
this.name = "";
|
|
42
75
|
this.value = "";
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Error shown with the control and linked to it. Setting it puts the
|
|
78
|
+
* control in its error state; clear it to leave that state.
|
|
79
|
+
*/
|
|
80
|
+
this.errorText = "";
|
|
45
81
|
/**
|
|
46
82
|
* Force a visual state (for documentation/Figma sync only)
|
|
47
83
|
* Values: 'hover' | 'focus'
|
|
@@ -58,11 +94,6 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
58
94
|
static { this.styles = [
|
|
59
95
|
baseStyles,
|
|
60
96
|
css `
|
|
61
|
-
/* ═══════════════════════════════════════════════════════════════
|
|
62
|
-
ORANGE HALO CHECKBOX
|
|
63
|
-
Chunky • Tactile • Playful
|
|
64
|
-
═══════════════════════════════════════════════════════════════ */
|
|
65
|
-
|
|
66
97
|
:host {
|
|
67
98
|
display: inline-block;
|
|
68
99
|
}
|
|
@@ -97,18 +128,18 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
97
128
|
height: 24px;
|
|
98
129
|
flex-shrink: 0;
|
|
99
130
|
|
|
100
|
-
/*
|
|
131
|
+
/* Border: stroke.control in color.border.emphasis */
|
|
101
132
|
border: var(--oh-stroke-control) solid var(--oh-color-border-emphasis);
|
|
102
133
|
border-radius: var(--oh-shape-compact);
|
|
103
134
|
|
|
104
|
-
/* Offset shadow
|
|
135
|
+
/* Offset shadow: elevation.offset.md in elevation.color.secondary */
|
|
105
136
|
background-color: var(--oh-color-surface-base);
|
|
106
137
|
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
107
|
-
0 0 var(--oh-
|
|
138
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
108
139
|
|
|
109
140
|
transition:
|
|
110
|
-
transform var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
111
|
-
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
141
|
+
transform var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
142
|
+
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
112
143
|
background-color var(--oh-motion-quick) ease,
|
|
113
144
|
border-color var(--oh-motion-quick) ease;
|
|
114
145
|
}
|
|
@@ -132,27 +163,27 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
132
163
|
STATES
|
|
133
164
|
═══════════════════════════════════════════════════════════════ */
|
|
134
165
|
|
|
135
|
-
/* Hover: lift
|
|
166
|
+
/* Hover: moves by lift.hoverSm; shadow offset elevation.offset.lg */
|
|
136
167
|
.checkbox-wrapper:hover .checkbox-box {
|
|
137
168
|
border-color: var(--oh-color-border-hover);
|
|
138
169
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
139
170
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
140
|
-
0 0 var(--oh-
|
|
171
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
141
172
|
}
|
|
142
173
|
|
|
143
|
-
/* Active:
|
|
174
|
+
/* Active: moves by lift.pressSm; shadow offset elevation.offset.xs */
|
|
144
175
|
.checkbox-wrapper:active .checkbox-box {
|
|
145
176
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
146
177
|
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
147
|
-
0 0 var(--oh-
|
|
178
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
148
179
|
}
|
|
149
180
|
|
|
150
|
-
/* Checked: primary color
|
|
181
|
+
/* Checked: color.brand.primary fill, elevation.color.primary shadow */
|
|
151
182
|
.native-checkbox:checked + .checkbox-box {
|
|
152
183
|
background-color: var(--oh-color-brand-primary);
|
|
153
184
|
border-color: var(--oh-color-brand-primary);
|
|
154
185
|
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
155
|
-
0 0 var(--oh-
|
|
186
|
+
0 0 var(--oh-elevation-color-primary);
|
|
156
187
|
}
|
|
157
188
|
|
|
158
189
|
.native-checkbox:checked + .checkbox-box::after {
|
|
@@ -165,7 +196,7 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
165
196
|
border-color: var(--oh-color-brand-primary-hover);
|
|
166
197
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
167
198
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
168
|
-
0 0 var(--oh-
|
|
199
|
+
0 0 var(--oh-elevation-color-primary);
|
|
169
200
|
}
|
|
170
201
|
|
|
171
202
|
/* Checked + Active */
|
|
@@ -173,7 +204,7 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
173
204
|
background-color: var(--oh-color-brand-primary-active);
|
|
174
205
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
175
206
|
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
176
|
-
0 0 var(--oh-
|
|
207
|
+
0 0 var(--oh-elevation-color-primary);
|
|
177
208
|
}
|
|
178
209
|
|
|
179
210
|
/* Focus: underline the label (accessible indicator) */
|
|
@@ -199,16 +230,16 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
199
230
|
ERROR STATE
|
|
200
231
|
═══════════════════════════════════════════════════════════════ */
|
|
201
232
|
|
|
202
|
-
:host([
|
|
233
|
+
:host([data-invalid]) .checkbox-box {
|
|
203
234
|
border-color: var(--oh-color-feedback-error);
|
|
204
235
|
box-shadow: var(--oh-elevation-offset-md) var(--oh-elevation-offset-md)
|
|
205
|
-
0 0 var(--oh-
|
|
236
|
+
0 0 var(--oh-elevation-color-error);
|
|
206
237
|
}
|
|
207
238
|
|
|
208
|
-
:host([
|
|
239
|
+
:host([data-invalid]) .checkbox-wrapper:hover .checkbox-box {
|
|
209
240
|
border-color: var(--oh-color-feedback-error-hover);
|
|
210
241
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
211
|
-
0 0 var(--oh-
|
|
242
|
+
0 0 var(--oh-elevation-color-error);
|
|
212
243
|
}
|
|
213
244
|
|
|
214
245
|
.error-message {
|
|
@@ -248,7 +279,7 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
248
279
|
border-color: var(--oh-color-border-hover);
|
|
249
280
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
250
281
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
251
|
-
0 0 var(--oh-
|
|
282
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
252
283
|
}
|
|
253
284
|
|
|
254
285
|
/* Forced Focus - Unchecked */
|
|
@@ -263,7 +294,7 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
263
294
|
border-color: var(--oh-color-brand-primary-hover);
|
|
264
295
|
transform: translate(var(--oh-lift-hover-sm), var(--oh-lift-hover-sm));
|
|
265
296
|
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
266
|
-
0 0 var(--oh-
|
|
297
|
+
0 0 var(--oh-elevation-color-primary);
|
|
267
298
|
}
|
|
268
299
|
`,
|
|
269
300
|
]; }
|
|
@@ -272,10 +303,14 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
272
303
|
this.checked = target.checked;
|
|
273
304
|
this.emit("oh-change", { checked: this.checked, value: this.value });
|
|
274
305
|
}
|
|
306
|
+
updated(changed) {
|
|
307
|
+
// Styling hook for the error state (data-invalid on the host)
|
|
308
|
+
if (changed.has("errorText"))
|
|
309
|
+
this.toggleAttribute("data-invalid", !!this.errorText);
|
|
310
|
+
}
|
|
275
311
|
willUpdate(changed) {
|
|
276
|
-
if (this.hasUpdated &&
|
|
277
|
-
|
|
278
|
-
this._announceError = !!(this.error && this.errorMessage);
|
|
312
|
+
if (this.hasUpdated && changed.has("errorText")) {
|
|
313
|
+
this._announceError = !!this.errorText;
|
|
279
314
|
}
|
|
280
315
|
}
|
|
281
316
|
render() {
|
|
@@ -290,16 +325,14 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
290
325
|
name=${this.name}
|
|
291
326
|
.value=${this.value}
|
|
292
327
|
.checked=${this.checked}
|
|
293
|
-
aria-invalid=${this.
|
|
294
|
-
aria-describedby=${this.
|
|
295
|
-
? this._errorId
|
|
296
|
-
: nothing}
|
|
328
|
+
aria-invalid=${this.errorText ? "true" : "false"}
|
|
329
|
+
aria-describedby=${this.errorText ? this._errorId : nothing}
|
|
297
330
|
@change=${this._handleChange}
|
|
298
331
|
/>
|
|
299
332
|
<span class="checkbox-box" part="box"></span>
|
|
300
333
|
<span class="label" part="label">${this.label}</span>
|
|
301
334
|
</label>
|
|
302
|
-
${this.
|
|
335
|
+
${this.errorText
|
|
303
336
|
? html `
|
|
304
337
|
<div
|
|
305
338
|
id=${this._errorId}
|
|
@@ -319,7 +352,7 @@ let OhCheckbox = class OhCheckbox extends OhElement {
|
|
|
319
352
|
clip-rule="evenodd"
|
|
320
353
|
/>
|
|
321
354
|
</svg>
|
|
322
|
-
${this.
|
|
355
|
+
${this.errorText}
|
|
323
356
|
</div>
|
|
324
357
|
`
|
|
325
358
|
: ""}
|
|
@@ -340,11 +373,8 @@ __decorate([
|
|
|
340
373
|
property({ type: String })
|
|
341
374
|
], OhCheckbox.prototype, "value", void 0);
|
|
342
375
|
__decorate([
|
|
343
|
-
property({ type:
|
|
344
|
-
], OhCheckbox.prototype, "
|
|
345
|
-
__decorate([
|
|
346
|
-
property({ type: String })
|
|
347
|
-
], OhCheckbox.prototype, "errorMessage", void 0);
|
|
376
|
+
property({ type: String, attribute: "error-text" })
|
|
377
|
+
], OhCheckbox.prototype, "errorText", void 0);
|
|
348
378
|
__decorate([
|
|
349
379
|
property({ type: String, reflect: true, attribute: "force-state" })
|
|
350
380
|
], OhCheckbox.prototype, "forceState", void 0);
|