@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
package/dist/oh-select.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-select
|
|
3
3
|
*
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
4
|
+
* A custom dropdown select (not a native <select>), so the trigger and the
|
|
5
|
+
* list can be styled with tokens.
|
|
6
6
|
*
|
|
7
7
|
* DESIGN DECISIONS:
|
|
8
8
|
* ─────────────────
|
|
9
|
-
* 1.
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* 1. TRIGGER
|
|
10
|
+
* - A <button role="combobox">, with the same tokens as the other
|
|
11
|
+
* controls: stroke.control border in color.border.emphasis,
|
|
12
|
+
* shape.control corners, an outset shadow offset by
|
|
13
|
+
* elevation.offset.lg in elevation.color.secondary
|
|
14
|
+
* - Hover and press move it by lift.hoverMd / lift.pressSm, like oh-button
|
|
14
15
|
*
|
|
15
16
|
* 2. DROPDOWN PANEL
|
|
16
|
-
* -
|
|
17
|
-
*
|
|
18
|
-
* -
|
|
19
|
-
*
|
|
17
|
+
* - A listbox below the trigger, on color.surface.highlight with
|
|
18
|
+
* shape.container corners
|
|
19
|
+
* - The highlighted option is underlined; the selected option is marked
|
|
20
|
+
* in color.brand.primary and set in typography.emphasis.fontWeight
|
|
21
|
+
* - Opens and closes with a transition (none under reduced motion)
|
|
20
22
|
*
|
|
21
23
|
* 3. ACCESSIBILITY
|
|
22
|
-
* - role="combobox" with
|
|
23
|
-
*
|
|
24
|
+
* - role="combobox" with aria-expanded, aria-controls and
|
|
25
|
+
* aria-activedescendant; focus stays on the trigger
|
|
26
|
+
* - Keyboard navigation (arrows, Enter, Space, Escape, Home, End, Tab)
|
|
24
27
|
* - Type-ahead search
|
|
25
|
-
* - Focus management
|
|
26
28
|
* - Label always required
|
|
27
|
-
*
|
|
28
|
-
* @element oh-select
|
|
29
29
|
*/
|
|
30
30
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
31
31
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -36,6 +36,48 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
36
36
|
import { html, css, nothing } from "lit";
|
|
37
37
|
import { customElement, property, state, query } from "lit/decorators.js";
|
|
38
38
|
import { OhElement, baseStyles } from "./base.js";
|
|
39
|
+
/**
|
|
40
|
+
* A dropdown for choosing one option from a list.
|
|
41
|
+
*
|
|
42
|
+
* **Use it for** one choice from a list too long to show every option.
|
|
43
|
+
* **Don't use it for** a few options (use `oh-radio-group`, which shows them
|
|
44
|
+
* all), several choices (use `oh-checkbox-group`) or free text (use
|
|
45
|
+
* `oh-input` with `suggestions`).
|
|
46
|
+
*
|
|
47
|
+
* **Parts:** a trigger showing the selected option's label (or
|
|
48
|
+
* `placeholder`), and a list of `options` (`{ label, value }`). One size.
|
|
49
|
+
* **States:** rest, hover, active, focus, open, error (set `error-text`),
|
|
50
|
+
* required.
|
|
51
|
+
*
|
|
52
|
+
* **Behaviour:** click the trigger, or press Enter, Space or an arrow key,
|
|
53
|
+
* to open the list. Arrow keys, Home and End move the highlight, Enter or
|
|
54
|
+
* Space selects, Escape and Tab close, and clicking outside closes. Typing
|
|
55
|
+
* letters jumps to a matching option (and selects it while the list is
|
|
56
|
+
* closed). Selecting sets `value`, returns focus to the trigger and fires
|
|
57
|
+
* `oh-change`. It isn't form-associated: it doesn't submit with a native
|
|
58
|
+
* form, so read `value` or listen for `oh-change`. It has no `disabled`
|
|
59
|
+
* property.
|
|
60
|
+
*
|
|
61
|
+
* **Accessibility:** the trigger is a `combobox` controlling a `listbox`,
|
|
62
|
+
* with `aria-activedescendant` for the highlighted option, so focus stays
|
|
63
|
+
* on the trigger. Always set `label`: it names the trigger and the list.
|
|
64
|
+
* The error shows after the label and before the trigger, with an icon, sets
|
|
65
|
+
* `aria-invalid` and is linked with `aria-describedby`; it's announced
|
|
66
|
+
* (`role="alert"`) only when it appears after first render. Focus is a
|
|
67
|
+
* solid underline on the trigger text.
|
|
68
|
+
*
|
|
69
|
+
* **Look:** set by tokens — `stroke.control` in `color.border.emphasis`
|
|
70
|
+
* (border), `shape.control` (trigger corners), `shape.container` (list
|
|
71
|
+
* corners), `typography.control.*` (type), `elevation.offset.*` and
|
|
72
|
+
* `elevation.color.secondary` (shadow), `lift.hoverMd` / `lift.pressSm` (movement
|
|
73
|
+
* on hover and press), `color.border.hover` (hover), `focus.ringColor` and
|
|
74
|
+
* `color.surface.highlight` (open), `color.surface.hover` and
|
|
75
|
+
* `color.brand.primary` (selected option), `color.feedback.error` and
|
|
76
|
+
* `elevation.color.error` (error).
|
|
77
|
+
*
|
|
78
|
+
* @element oh-select
|
|
79
|
+
* @fires oh-change - An option was selected. detail: { value }
|
|
80
|
+
*/
|
|
39
81
|
let OhSelect = class OhSelect extends OhElement {
|
|
40
82
|
constructor() {
|
|
41
83
|
super(...arguments);
|
|
@@ -53,6 +95,7 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
53
95
|
this._labelId = `oh-select-label-${Math.random().toString(36).substr(2, 9)}`;
|
|
54
96
|
this._listboxId = `oh-select-listbox-${Math.random().toString(36).substr(2, 9)}`;
|
|
55
97
|
this._errorId = `oh-select-error-${Math.random().toString(36).substr(2, 9)}`;
|
|
98
|
+
this._helperId = `oh-select-helper-${Math.random().toString(36).substr(2, 9)}`;
|
|
56
99
|
this._typeaheadBuffer = "";
|
|
57
100
|
this._typeaheadTimeout = null;
|
|
58
101
|
this._handleClickOutside = (event) => {
|
|
@@ -70,11 +113,6 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
70
113
|
static { this.styles = [
|
|
71
114
|
baseStyles,
|
|
72
115
|
css `
|
|
73
|
-
/* ═══════════════════════════════════════════════════════════════
|
|
74
|
-
ORANGE HALO SELECT
|
|
75
|
-
Chunky • Playful • Tactile Dropdown
|
|
76
|
-
═══════════════════════════════════════════════════════════════ */
|
|
77
|
-
|
|
78
116
|
:host {
|
|
79
117
|
display: block;
|
|
80
118
|
position: relative;
|
|
@@ -113,25 +151,26 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
113
151
|
width: 100%;
|
|
114
152
|
min-height: var(--oh-input-size-md-min-height);
|
|
115
153
|
padding: var(--oh-spacing-3) var(--oh-spacing-4);
|
|
116
|
-
|
|
154
|
+
|
|
117
155
|
font-family: var(--oh-typography-control-font-family);
|
|
118
156
|
font-size: var(--oh-typography-control-font-size-md);
|
|
119
157
|
color: var(--oh-color-text-primary);
|
|
120
158
|
text-align: left;
|
|
121
|
-
|
|
159
|
+
|
|
122
160
|
background-color: var(--oh-color-surface-base);
|
|
123
161
|
border: var(--oh-stroke-control) solid var(--oh-color-border-emphasis);
|
|
124
162
|
border-radius: var(--oh-shape-control);
|
|
125
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
126
|
-
|
|
163
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
164
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
165
|
+
|
|
127
166
|
cursor: pointer;
|
|
128
167
|
-webkit-appearance: none;
|
|
129
168
|
-moz-appearance: none;
|
|
130
169
|
appearance: none;
|
|
131
|
-
|
|
132
|
-
transition:
|
|
133
|
-
transform var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
134
|
-
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
170
|
+
|
|
171
|
+
transition:
|
|
172
|
+
transform var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
173
|
+
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
135
174
|
border-color var(--oh-motion-snappy) ease,
|
|
136
175
|
background-color var(--oh-motion-quick) ease;
|
|
137
176
|
}
|
|
@@ -168,12 +207,14 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
168
207
|
.trigger:hover {
|
|
169
208
|
border-color: var(--oh-color-border-hover);
|
|
170
209
|
transform: translate(var(--oh-lift-hover-md), var(--oh-lift-hover-md));
|
|
171
|
-
box-shadow: var(--oh-elevation-offset-2xl)
|
|
210
|
+
box-shadow: var(--oh-elevation-offset-2xl)
|
|
211
|
+
var(--oh-elevation-offset-2xl) 0 0 var(--oh-elevation-color-secondary);
|
|
172
212
|
}
|
|
173
213
|
|
|
174
214
|
.trigger:active {
|
|
175
215
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
176
|
-
box-shadow: var(--oh-elevation-offset-sm) var(--oh-elevation-offset-sm)
|
|
216
|
+
box-shadow: var(--oh-elevation-offset-sm) var(--oh-elevation-offset-sm)
|
|
217
|
+
0 0 var(--oh-elevation-color-secondary);
|
|
177
218
|
}
|
|
178
219
|
|
|
179
220
|
.trigger--open {
|
|
@@ -181,7 +222,7 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
181
222
|
background-color: var(--oh-color-surface-highlight);
|
|
182
223
|
}
|
|
183
224
|
|
|
184
|
-
/* Focus: underline trigger text (
|
|
225
|
+
/* Focus: underline the trigger text (a solid indicator, like oh-button) */
|
|
185
226
|
.trigger:focus {
|
|
186
227
|
outline: none;
|
|
187
228
|
}
|
|
@@ -208,21 +249,22 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
208
249
|
right: 0;
|
|
209
250
|
z-index: var(--oh-z-index-dropdown);
|
|
210
251
|
margin-top: var(--oh-spacing-1);
|
|
211
|
-
|
|
252
|
+
|
|
212
253
|
background-color: var(--oh-color-surface-highlight);
|
|
213
254
|
border: var(--oh-stroke-control) solid var(--oh-color-border-emphasis);
|
|
214
255
|
border-radius: var(--oh-shape-container);
|
|
215
|
-
box-shadow: var(--oh-elevation-offset-2xl)
|
|
216
|
-
|
|
256
|
+
box-shadow: var(--oh-elevation-offset-2xl)
|
|
257
|
+
var(--oh-elevation-offset-2xl) 0 0 var(--oh-elevation-color-secondary);
|
|
258
|
+
|
|
217
259
|
max-height: 0;
|
|
218
260
|
overflow: hidden;
|
|
219
261
|
opacity: 0;
|
|
220
262
|
transform: translateY(-8px);
|
|
221
|
-
|
|
222
|
-
transition:
|
|
263
|
+
|
|
264
|
+
transition:
|
|
223
265
|
max-height var(--oh-motion-gentle) ease,
|
|
224
266
|
opacity var(--oh-motion-snappy) ease,
|
|
225
|
-
transform var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
267
|
+
transform var(--oh-motion-snappy) var(--oh-motion-ease-emphasized);
|
|
226
268
|
}
|
|
227
269
|
|
|
228
270
|
.dropdown--open {
|
|
@@ -244,11 +286,11 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
244
286
|
align-items: center;
|
|
245
287
|
gap: var(--oh-spacing-3);
|
|
246
288
|
padding: var(--oh-spacing-3) var(--oh-spacing-4);
|
|
247
|
-
|
|
289
|
+
|
|
248
290
|
font-family: var(--oh-typography-control-font-family);
|
|
249
291
|
font-size: var(--oh-typography-control-font-size-md);
|
|
250
292
|
color: var(--oh-color-text-primary);
|
|
251
|
-
|
|
293
|
+
|
|
252
294
|
cursor: pointer;
|
|
253
295
|
transition: background-color var(--oh-motion-quick) ease;
|
|
254
296
|
}
|
|
@@ -270,7 +312,7 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
270
312
|
}
|
|
271
313
|
|
|
272
314
|
.option--selected::before {
|
|
273
|
-
content:
|
|
315
|
+
content: "";
|
|
274
316
|
width: 8px;
|
|
275
317
|
height: 8px;
|
|
276
318
|
background-color: var(--oh-color-brand-primary);
|
|
@@ -284,12 +326,14 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
284
326
|
|
|
285
327
|
.trigger--error {
|
|
286
328
|
border-color: var(--oh-color-feedback-error);
|
|
287
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
329
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
330
|
+
0 0 var(--oh-elevation-color-error);
|
|
288
331
|
}
|
|
289
332
|
|
|
290
333
|
.trigger--error:hover {
|
|
291
334
|
border-color: var(--oh-color-feedback-error-hover);
|
|
292
|
-
box-shadow: var(--oh-elevation-offset-2xl)
|
|
335
|
+
box-shadow: var(--oh-elevation-offset-2xl)
|
|
336
|
+
var(--oh-elevation-offset-2xl) 0 0 var(--oh-elevation-color-error);
|
|
293
337
|
}
|
|
294
338
|
|
|
295
339
|
.helper {
|
|
@@ -329,11 +373,11 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
329
373
|
`,
|
|
330
374
|
]; }
|
|
331
375
|
get _selectedOption() {
|
|
332
|
-
return this.options.find(opt => opt.value === this.value);
|
|
376
|
+
return this.options.find((opt) => opt.value === this.value);
|
|
333
377
|
}
|
|
334
378
|
_open_dropdown() {
|
|
335
379
|
this._open = true;
|
|
336
|
-
this._highlightedIndex = this.options.findIndex(opt => opt.value === this.value);
|
|
380
|
+
this._highlightedIndex = this.options.findIndex((opt) => opt.value === this.value);
|
|
337
381
|
if (this._highlightedIndex === -1 && this.options.length > 0) {
|
|
338
382
|
this._highlightedIndex = 0;
|
|
339
383
|
}
|
|
@@ -431,7 +475,7 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
431
475
|
this._typeaheadTimeout = window.setTimeout(() => {
|
|
432
476
|
this._typeaheadBuffer = "";
|
|
433
477
|
}, 500);
|
|
434
|
-
const matchIndex = this.options.findIndex(opt => opt.label.toLowerCase().startsWith(this._typeaheadBuffer));
|
|
478
|
+
const matchIndex = this.options.findIndex((opt) => opt.label.toLowerCase().startsWith(this._typeaheadBuffer));
|
|
435
479
|
if (matchIndex >= 0) {
|
|
436
480
|
if (this._open) {
|
|
437
481
|
this._highlightedIndex = matchIndex;
|
|
@@ -450,9 +494,10 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
450
494
|
_highlightPrevious() {
|
|
451
495
|
if (this.options.length === 0)
|
|
452
496
|
return;
|
|
453
|
-
this._highlightedIndex =
|
|
454
|
-
|
|
455
|
-
|
|
497
|
+
this._highlightedIndex =
|
|
498
|
+
this._highlightedIndex <= 0
|
|
499
|
+
? this.options.length - 1
|
|
500
|
+
: this._highlightedIndex - 1;
|
|
456
501
|
this._scrollToHighlighted();
|
|
457
502
|
}
|
|
458
503
|
_highlightFirst() {
|
|
@@ -469,8 +514,8 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
469
514
|
}
|
|
470
515
|
_scrollToHighlighted() {
|
|
471
516
|
requestAnimationFrame(() => {
|
|
472
|
-
const highlighted = this._listbox?.querySelector(
|
|
473
|
-
highlighted?.scrollIntoView({ block:
|
|
517
|
+
const highlighted = this._listbox?.querySelector(".option--highlighted");
|
|
518
|
+
highlighted?.scrollIntoView({ block: "nearest" });
|
|
474
519
|
});
|
|
475
520
|
}
|
|
476
521
|
_handleOptionClick(option, event) {
|
|
@@ -494,14 +539,14 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
494
539
|
}
|
|
495
540
|
connectedCallback() {
|
|
496
541
|
super.connectedCallback();
|
|
497
|
-
document.addEventListener(
|
|
542
|
+
document.addEventListener("click", this._handleClickOutside);
|
|
498
543
|
}
|
|
499
544
|
disconnectedCallback() {
|
|
500
545
|
super.disconnectedCallback();
|
|
501
|
-
document.removeEventListener(
|
|
546
|
+
document.removeEventListener("click", this._handleClickOutside);
|
|
502
547
|
}
|
|
503
548
|
willUpdate(changed) {
|
|
504
|
-
if (this.hasUpdated &&
|
|
549
|
+
if (this.hasUpdated && changed.has("errorText")) {
|
|
505
550
|
this._announceError = !!this.errorText;
|
|
506
551
|
}
|
|
507
552
|
}
|
|
@@ -519,7 +564,7 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
519
564
|
<div class="label-container">
|
|
520
565
|
${this.label
|
|
521
566
|
? html `
|
|
522
|
-
<label
|
|
567
|
+
<label
|
|
523
568
|
id=${this._labelId}
|
|
524
569
|
class="label ${this.required ? "label--required" : ""}"
|
|
525
570
|
>
|
|
@@ -531,9 +576,22 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
531
576
|
|
|
532
577
|
${hasError
|
|
533
578
|
? html `
|
|
534
|
-
<div
|
|
535
|
-
|
|
536
|
-
|
|
579
|
+
<div
|
|
580
|
+
id=${this._errorId}
|
|
581
|
+
class="error-message"
|
|
582
|
+
role=${this._announceError ? "alert" : nothing}
|
|
583
|
+
>
|
|
584
|
+
<svg
|
|
585
|
+
class="error-icon"
|
|
586
|
+
viewBox="0 0 20 20"
|
|
587
|
+
fill="currentColor"
|
|
588
|
+
aria-hidden="true"
|
|
589
|
+
>
|
|
590
|
+
<path
|
|
591
|
+
fill-rule="evenodd"
|
|
592
|
+
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"
|
|
593
|
+
clip-rule="evenodd"
|
|
594
|
+
/>
|
|
537
595
|
</svg>
|
|
538
596
|
${this.errorText}
|
|
539
597
|
</div>
|
|
@@ -553,27 +611,39 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
553
611
|
: nothing}
|
|
554
612
|
aria-required=${this.required ? "true" : nothing}
|
|
555
613
|
aria-invalid=${hasError ? "true" : nothing}
|
|
556
|
-
aria-describedby=${hasError
|
|
614
|
+
aria-describedby=${hasError
|
|
615
|
+
? this._errorId
|
|
616
|
+
: this.helperText
|
|
617
|
+
? this._helperId
|
|
618
|
+
: nothing}
|
|
557
619
|
@click=${this._handleTriggerClick}
|
|
558
620
|
@keydown=${this._handleTriggerKeydown}
|
|
559
621
|
@focus=${this._handleFocus}
|
|
560
622
|
@blur=${this._handleBlur}
|
|
561
623
|
>
|
|
562
|
-
<span
|
|
624
|
+
<span
|
|
625
|
+
class="trigger__text ${!selectedLabel
|
|
626
|
+
? "trigger__text--placeholder"
|
|
627
|
+
: ""}"
|
|
628
|
+
>
|
|
563
629
|
${selectedLabel || this.placeholder}
|
|
564
630
|
</span>
|
|
565
|
-
<svg
|
|
566
|
-
class="trigger__icon ${this._open ?
|
|
567
|
-
viewBox="0 0 20 20"
|
|
631
|
+
<svg
|
|
632
|
+
class="trigger__icon ${this._open ? "trigger__icon--open" : ""}"
|
|
633
|
+
viewBox="0 0 20 20"
|
|
568
634
|
fill="currentColor"
|
|
569
635
|
aria-hidden="true"
|
|
570
636
|
>
|
|
571
|
-
<path
|
|
637
|
+
<path
|
|
638
|
+
fill-rule="evenodd"
|
|
639
|
+
d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z"
|
|
640
|
+
clip-rule="evenodd"
|
|
641
|
+
/>
|
|
572
642
|
</svg>
|
|
573
643
|
</button>
|
|
574
644
|
|
|
575
|
-
<ul
|
|
576
|
-
class="dropdown ${this._open ?
|
|
645
|
+
<ul
|
|
646
|
+
class="dropdown ${this._open ? "dropdown--open" : ""}"
|
|
577
647
|
role="listbox"
|
|
578
648
|
id=${this._listboxId}
|
|
579
649
|
aria-labelledby=${this.label ? this._labelId : nothing}
|
|
@@ -602,7 +672,9 @@ let OhSelect = class OhSelect extends OhElement {
|
|
|
602
672
|
</ul>
|
|
603
673
|
|
|
604
674
|
${this.helperText && !hasError
|
|
605
|
-
? html `<span class="helper"
|
|
675
|
+
? html `<span id=${this._helperId} class="helper"
|
|
676
|
+
>${this.helperText}</span
|
|
677
|
+
>`
|
|
606
678
|
: nothing}
|
|
607
679
|
</div>
|
|
608
680
|
`;
|
|
@@ -627,10 +699,10 @@ __decorate([
|
|
|
627
699
|
property({ type: Boolean, reflect: true })
|
|
628
700
|
], OhSelect.prototype, "required", void 0);
|
|
629
701
|
__decorate([
|
|
630
|
-
property({ type: String })
|
|
702
|
+
property({ type: String, attribute: "helper-text" })
|
|
631
703
|
], OhSelect.prototype, "helperText", void 0);
|
|
632
704
|
__decorate([
|
|
633
|
-
property({ type: String })
|
|
705
|
+
property({ type: String, attribute: "error-text" })
|
|
634
706
|
], OhSelect.prototype, "errorText", void 0);
|
|
635
707
|
__decorate([
|
|
636
708
|
state()
|
package/dist/oh-select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-select.js","sourceRoot":"","sources":["../src/oh-select.ts"],"names":[],"mappings":"AAAA;;;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AAC;IACJ,CAAC;;AA1YD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAChB;AAGX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACM;AAGjC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCACG;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAChB;AAGX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC1B;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;4CACrC;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;2CACrC;AAGP;IADP,KAAK,EAAE;uCACc;AAGd;IADP,KAAK,EAAE;mDACuB;AAGvB;IADP,KAAK,EAAE;0CACiB;AAGjB;IADP,KAAK,CAAC,UAAU,CAAC;0CACmB;AAG7B;IADP,KAAK,CAAC,WAAW,CAAC;0CACiB;AA2N5B;IADP,KAAK,EAAE;gDACuB;AAxgBpB,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAopBpB"}
|
package/dist/oh-skip-link.d.ts
CHANGED
|
@@ -1,28 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-skip-link
|
|
3
3
|
*
|
|
4
|
-
* Accessibility skip link for keyboard navigation.
|
|
5
|
-
*
|
|
6
4
|
* DESIGN DECISIONS:
|
|
7
5
|
* ─────────────────
|
|
8
|
-
* 1.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* 1. A native anchor, visually hidden (but still read by screen readers)
|
|
7
|
+
* until it has focus.
|
|
8
|
+
* 2. On focus it appears fixed at the top-left of the viewport, above other
|
|
9
|
+
* content, and transitions in.
|
|
10
|
+
* 3. Focus is shown by a border in `color.brand.primary` on a raised
|
|
11
|
+
* surface; look comes from tokens only.
|
|
12
|
+
*/
|
|
13
|
+
import { OhElement } from "./base.js";
|
|
14
|
+
/**
|
|
15
|
+
* A "skip to content" link that lets keyboard users jump past repeated content, such as navigation.
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* **Use it for** the first focusable element on every page, pointing at the
|
|
18
|
+
* main content. Add more for other landmarks (search results, footer) if
|
|
19
|
+
* useful. **Don't use it for** in-page navigation that everyone sees (use
|
|
20
|
+
* `oh-link`).
|
|
17
21
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
+
* **Parts:** `href` is the target (defaults to `#main`); `text` is the label
|
|
23
|
+
* (defaults to "Skip to main content").
|
|
24
|
+
*
|
|
25
|
+
* **Behaviour:** hidden until it receives keyboard focus, then shown fixed at
|
|
26
|
+
* the top-left of the viewport, above other content. Enter follows the link.
|
|
27
|
+
* Transitions are cut short under `prefers-reduced-motion`.
|
|
28
|
+
*
|
|
29
|
+
* **Accessibility:** screen readers can read it at all times. Put it first in
|
|
30
|
+
* the page, and give the target an `id` and `tabindex="-1"` so focus moves to
|
|
31
|
+
* it.
|
|
32
|
+
*
|
|
33
|
+
* **Look:** set by tokens — `color.surface.base`, `color.border.emphasis` and
|
|
34
|
+
* `color.text.link` at rest; `color.surface.raised`, `color.text.linkRaised`
|
|
35
|
+
* and `color.brand.primary` (border) on focus; `stroke.control` the border,
|
|
36
|
+
* `shape.control` the corners; `elevation.offset.lg` with `elevation.color.neutral`
|
|
37
|
+
* (`elevation.color.primary` on focus) the shadow; `typography.body.*` and
|
|
38
|
+
* `typography.label.base.fontWeight` the text; `spacing.*` the padding and
|
|
39
|
+
* position; `motion.gentle`, `motion.quick` and `motion.snappy` the
|
|
40
|
+
* transitions.
|
|
22
41
|
*
|
|
23
42
|
* @element oh-skip-link
|
|
24
43
|
*/
|
|
25
|
-
import { OhElement } from "./base.js";
|
|
26
44
|
export declare class OhSkipLink extends OhElement {
|
|
27
45
|
static styles: import("lit").CSSResult[];
|
|
28
46
|
href: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-skip-link.d.ts","sourceRoot":"","sources":["../src/oh-skip-link.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oh-skip-link.d.ts","sourceRoot":"","sources":["../src/oh-skip-link.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,SAAS,EAAc,MAAM,WAAW,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBACa,UAAW,SAAQ,SAAS;IACvC,OAAgB,MAAM,4BAgFpB;IAGF,IAAI,SAAW;IAGf,IAAI,SAA0B;IAE9B,MAAM;CAOP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,UAAU,CAAC;KAC5B;CACF"}
|
package/dist/oh-skip-link.js
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-skip-link
|
|
3
3
|
*
|
|
4
|
-
* Accessibility skip link for keyboard navigation.
|
|
5
|
-
*
|
|
6
4
|
* DESIGN DECISIONS:
|
|
7
5
|
* ─────────────────
|
|
8
|
-
* 1.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* - Fixed top-left position
|
|
15
|
-
* - Smooth transition on focus
|
|
16
|
-
* - Z-index above other content
|
|
17
|
-
*
|
|
18
|
-
* 3. STYLING
|
|
19
|
-
* - Warm orange focus state
|
|
20
|
-
* - Chunky padding and border
|
|
21
|
-
* - Clear typography
|
|
22
|
-
*
|
|
23
|
-
* @element oh-skip-link
|
|
6
|
+
* 1. A native anchor, visually hidden (but still read by screen readers)
|
|
7
|
+
* until it has focus.
|
|
8
|
+
* 2. On focus it appears fixed at the top-left of the viewport, above other
|
|
9
|
+
* content, and transitions in.
|
|
10
|
+
* 3. Focus is shown by a border in `color.brand.primary` on a raised
|
|
11
|
+
* surface; look comes from tokens only.
|
|
24
12
|
*/
|
|
25
13
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
26
14
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -31,6 +19,36 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
31
19
|
import { html, css } from "lit";
|
|
32
20
|
import { customElement, property } from "lit/decorators.js";
|
|
33
21
|
import { OhElement, baseStyles } from "./base.js";
|
|
22
|
+
/**
|
|
23
|
+
* A "skip to content" link that lets keyboard users jump past repeated content, such as navigation.
|
|
24
|
+
*
|
|
25
|
+
* **Use it for** the first focusable element on every page, pointing at the
|
|
26
|
+
* main content. Add more for other landmarks (search results, footer) if
|
|
27
|
+
* useful. **Don't use it for** in-page navigation that everyone sees (use
|
|
28
|
+
* `oh-link`).
|
|
29
|
+
*
|
|
30
|
+
* **Parts:** `href` is the target (defaults to `#main`); `text` is the label
|
|
31
|
+
* (defaults to "Skip to main content").
|
|
32
|
+
*
|
|
33
|
+
* **Behaviour:** hidden until it receives keyboard focus, then shown fixed at
|
|
34
|
+
* the top-left of the viewport, above other content. Enter follows the link.
|
|
35
|
+
* Transitions are cut short under `prefers-reduced-motion`.
|
|
36
|
+
*
|
|
37
|
+
* **Accessibility:** screen readers can read it at all times. Put it first in
|
|
38
|
+
* the page, and give the target an `id` and `tabindex="-1"` so focus moves to
|
|
39
|
+
* it.
|
|
40
|
+
*
|
|
41
|
+
* **Look:** set by tokens — `color.surface.base`, `color.border.emphasis` and
|
|
42
|
+
* `color.text.link` at rest; `color.surface.raised`, `color.text.linkRaised`
|
|
43
|
+
* and `color.brand.primary` (border) on focus; `stroke.control` the border,
|
|
44
|
+
* `shape.control` the corners; `elevation.offset.lg` with `elevation.color.neutral`
|
|
45
|
+
* (`elevation.color.primary` on focus) the shadow; `typography.body.*` and
|
|
46
|
+
* `typography.label.base.fontWeight` the text; `spacing.*` the padding and
|
|
47
|
+
* position; `motion.gentle`, `motion.quick` and `motion.snappy` the
|
|
48
|
+
* transitions.
|
|
49
|
+
*
|
|
50
|
+
* @element oh-skip-link
|
|
51
|
+
*/
|
|
34
52
|
let OhSkipLink = class OhSkipLink extends OhElement {
|
|
35
53
|
constructor() {
|
|
36
54
|
super(...arguments);
|
|
@@ -40,11 +58,6 @@ let OhSkipLink = class OhSkipLink extends OhElement {
|
|
|
40
58
|
static { this.styles = [
|
|
41
59
|
baseStyles,
|
|
42
60
|
css `
|
|
43
|
-
/* ═══════════════════════════════════════════════════════════════
|
|
44
|
-
ORANGE HALO SKIP LINK
|
|
45
|
-
Accessibility • Keyboard Navigation • Hidden until focus
|
|
46
|
-
═══════════════════════════════════════════════════════════════ */
|
|
47
|
-
|
|
48
61
|
:host {
|
|
49
62
|
display: contents;
|
|
50
63
|
}
|
|
@@ -61,7 +74,7 @@ let OhSkipLink = class OhSkipLink extends OhElement {
|
|
|
61
74
|
pointer-events: none;
|
|
62
75
|
|
|
63
76
|
/* Smooth transition */
|
|
64
|
-
transition:
|
|
77
|
+
transition:
|
|
65
78
|
opacity var(--oh-motion-gentle) ease,
|
|
66
79
|
transform var(--oh-motion-gentle) ease;
|
|
67
80
|
|
|
@@ -71,7 +84,8 @@ let OhSkipLink = class OhSkipLink extends OhElement {
|
|
|
71
84
|
background-color: var(--oh-color-surface-base);
|
|
72
85
|
border: var(--oh-stroke-control) solid var(--oh-color-border-emphasis);
|
|
73
86
|
border-radius: var(--oh-shape-control);
|
|
74
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
87
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
88
|
+
0 0 var(--oh-elevation-color-neutral);
|
|
75
89
|
|
|
76
90
|
font-family: var(--oh-typography-body-font-family);
|
|
77
91
|
font-size: var(--oh-typography-body-base-font-size);
|
|
@@ -80,7 +94,7 @@ let OhSkipLink = class OhSkipLink extends OhElement {
|
|
|
80
94
|
text-decoration: none;
|
|
81
95
|
|
|
82
96
|
/* Focus state */
|
|
83
|
-
transition:
|
|
97
|
+
transition:
|
|
84
98
|
opacity var(--oh-motion-gentle) ease,
|
|
85
99
|
transform var(--oh-motion-gentle) ease,
|
|
86
100
|
background-color var(--oh-motion-quick) ease,
|
|
@@ -96,7 +110,8 @@ let OhSkipLink = class OhSkipLink extends OhElement {
|
|
|
96
110
|
background-color: var(--oh-color-surface-raised);
|
|
97
111
|
color: var(--oh-color-text-link-raised);
|
|
98
112
|
border-color: var(--oh-color-brand-primary);
|
|
99
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
113
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
114
|
+
0 0 var(--oh-elevation-color-primary);
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
/* Screen reader only when not focused */
|
|
@@ -123,11 +138,7 @@ let OhSkipLink = class OhSkipLink extends OhElement {
|
|
|
123
138
|
]; }
|
|
124
139
|
render() {
|
|
125
140
|
return html `
|
|
126
|
-
<a
|
|
127
|
-
class="skip-link"
|
|
128
|
-
href=${this.href}
|
|
129
|
-
aria-label=${this.text}
|
|
130
|
-
>
|
|
141
|
+
<a class="skip-link" href=${this.href} aria-label=${this.text}>
|
|
131
142
|
${this.text}
|
|
132
143
|
</a>
|
|
133
144
|
`;
|