@orange-halo/components 2.2.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +565 -328
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +7 -0
- package/dist/base.js.map +1 -1
- package/dist/index.d.ts +2 -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 +83 -21
- 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 +43 -21
- package/dist/oh-breadcrumb.js.map +1 -1
- package/dist/oh-button.d.ts +50 -24
- package/dist/oh-button.d.ts.map +1 -1
- package/dist/oh-button.js +66 -47
- 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.js +87 -45
- package/dist/oh-checkbox-group.js.map +1 -1
- package/dist/oh-checkbox.d.ts +55 -18
- package/dist/oh-checkbox.d.ts.map +1 -1
- package/dist/oh-checkbox.js +91 -59
- 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 +26 -33
- package/dist/oh-container.js.map +1 -1
- package/dist/oh-drawer.d.ts +36 -14
- package/dist/oh-drawer.d.ts.map +1 -1
- package/dist/oh-drawer.js +57 -26
- 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 +28 -5
- package/dist/oh-icon.js.map +1 -1
- package/dist/oh-input.d.ts +105 -21
- package/dist/oh-input.d.ts.map +1 -1
- package/dist/oh-input.js +207 -68
- 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 +56 -34
- 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 +44 -21
- 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 +32 -13
- 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.js +84 -44
- package/dist/oh-radio-group.js.map +1 -1
- package/dist/oh-radio.d.ts +56 -18
- package/dist/oh-radio.d.ts.map +1 -1
- package/dist/oh-radio.js +93 -60
- 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 +72 -36
- 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 +39 -26
- 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 +56 -30
- package/dist/oh-tabs.d.ts.map +1 -1
- package/dist/oh-tabs.js +89 -70
- 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 +68 -33
- package/dist/oh-toggle.js.map +1 -1
- package/dist/styles/typography.d.ts.map +1 -1
- package/dist/styles/typography.js +1 -2
- package/dist/styles/typography.js.map +1 -1
- package/package.json +3 -7
- package/dist/oh-button.figma.d.ts +0 -2
- package/dist/oh-button.figma.d.ts.map +0 -1
- package/dist/oh-button.figma.js +0 -18
- package/dist/oh-button.figma.js.map +0 -1
- package/dist/oh-checkbox-group.figma.d.ts +0 -2
- package/dist/oh-checkbox-group.figma.d.ts.map +0 -1
- package/dist/oh-checkbox-group.figma.js +0 -24
- package/dist/oh-checkbox-group.figma.js.map +0 -1
- 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
- package/dist/oh-input.figma.d.ts +0 -2
- package/dist/oh-input.figma.d.ts.map +0 -1
- package/dist/oh-input.figma.js +0 -36
- package/dist/oh-input.figma.js.map +0 -1
- package/dist/oh-radio-group.figma.d.ts +0 -2
- package/dist/oh-radio-group.figma.d.ts.map +0 -1
- package/dist/oh-radio-group.figma.js +0 -22
- package/dist/oh-radio-group.figma.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
|
}
|
|
@@ -124,7 +167,7 @@ let OhCheckboxGroup = class OhCheckboxGroup extends OhElement {
|
|
|
124
167
|
content: "";
|
|
125
168
|
position: absolute;
|
|
126
169
|
top: 3px;
|
|
127
|
-
left: 7px;
|
|
170
|
+
left: 7px; /* physical: a checkmark isn't mirrored in RTL */
|
|
128
171
|
width: 6px;
|
|
129
172
|
height: 12px;
|
|
130
173
|
border: solid var(--oh-color-text-on-brand);
|
|
@@ -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":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAA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AAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;4BAClC,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;;;6CAGhC,MAAM,CAAC,KAAK;;aAE5C,CACF;;;KAGN,CAAC;IACJ,CAAC;;AA9GD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAChB;AAGX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gDACK;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CACL;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDAC1B;AAOjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACrC;AAoBP;IADP,KAAK,EAAE;uDACuB;AApPpB,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CA4T3B"}
|
package/dist/oh-checkbox.d.ts
CHANGED
|
@@ -1,42 +1,78 @@
|
|
|
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
|
-
error: boolean;
|
|
37
|
-
errorMessage: string;
|
|
38
69
|
/**
|
|
39
|
-
*
|
|
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;
|
|
74
|
+
/**
|
|
75
|
+
* Force a visual state (for documentation only)
|
|
40
76
|
* Values: 'hover' | 'focus'
|
|
41
77
|
*/
|
|
42
78
|
forceState: CheckboxState;
|
|
@@ -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,4BAgNpB;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"}
|