@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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* oh-textarea
|
|
3
|
+
*
|
|
4
|
+
* A multi-line text field for messages, comments and feedback.
|
|
5
|
+
*
|
|
6
|
+
* DESIGN DECISIONS:
|
|
7
|
+
* ─────────────────
|
|
8
|
+
* 1. SAME FAMILY AS oh-input
|
|
9
|
+
* - Same tokens: stroke.control border in color.border.emphasis,
|
|
10
|
+
* shape.control corners, an inset shadow offset by elevation.offset.md
|
|
11
|
+
* in elevation.color.field
|
|
12
|
+
* - Focus is a solid inset ring in focus.ringColor inside the border;
|
|
13
|
+
* background switches to color.surface.highlight
|
|
14
|
+
*
|
|
15
|
+
* 2. ON THE GRID
|
|
16
|
+
* - Line height is 1.5 times the text size, rounded up to the brand's
|
|
17
|
+
* grid (grid.unit), so every line of a long message sits on it
|
|
18
|
+
*
|
|
19
|
+
* 3. A REAL FORM CONTROL
|
|
20
|
+
* - Form-associated: its value submits with the form under its name,
|
|
21
|
+
* `required` blocks submission with the browser's own message, a
|
|
22
|
+
* form reset restores the starting text, and a disabled <fieldset>
|
|
23
|
+
* disables it
|
|
24
|
+
*
|
|
25
|
+
* 4. ERRORS BEFORE THE FIELD
|
|
26
|
+
* - Error text sits after the label and before the field, with an icon,
|
|
27
|
+
* so it's read before the field is reached. Helper text sits after
|
|
28
|
+
*/
|
|
29
|
+
import { type PropertyValues } from "lit";
|
|
30
|
+
import { OhElement } from "./base.js";
|
|
31
|
+
/**
|
|
32
|
+
* A multi-line text field that submits with a native form.
|
|
33
|
+
*
|
|
34
|
+
* **Use it for** messages, comments, feedback: text that may run to several
|
|
35
|
+
* lines. **Don't use it for** a single line of text (use `oh-input`).
|
|
36
|
+
*
|
|
37
|
+
* **States:** rest, hover, focus, error (set `error-text`), disabled,
|
|
38
|
+
* required. `rows` sets the visible lines (default 4); people can drag it
|
|
39
|
+
* taller. `maxlength` limits the length.
|
|
40
|
+
*
|
|
41
|
+
* **Behaviour:** form-associated. Give it a `name` and it submits with the
|
|
42
|
+
* form. `required` stops the form submitting while it's empty, with the
|
|
43
|
+
* browser's own message. A form reset restores its starting text, and a
|
|
44
|
+
* disabled `<fieldset>` disables it. Fires `oh-input` on every keystroke and
|
|
45
|
+
* `oh-change` when the value is committed. Its line height is 1.5 times the
|
|
46
|
+
* text size, rounded up to `grid.unit`, so long messages stay on the grid.
|
|
47
|
+
*
|
|
48
|
+
* **Accessibility:** always set `label`: it names the field. A placeholder
|
|
49
|
+
* isn't a label. Helper and error text are linked to the field with
|
|
50
|
+
* `aria-describedby`, so screen readers read them. Errors come before the
|
|
51
|
+
* field, with an icon, set `aria-invalid`, and are announced only when they
|
|
52
|
+
* appear after the page has loaded. Focus is a solid inset ring. Use
|
|
53
|
+
* `autocomplete` when the field asks for something a browser can fill in,
|
|
54
|
+
* such as an address (WCAG 1.3.5).
|
|
55
|
+
*
|
|
56
|
+
* **Look:** set by tokens — `stroke.control` in `color.border.emphasis`
|
|
57
|
+
* (border), `shape.control` (corners), `typography.control.*` (type),
|
|
58
|
+
* `elevation.offset.md` and `elevation.color.field` (inset shadow),
|
|
59
|
+
* `color.border.hover` (hover), `focus.ringColor` and
|
|
60
|
+
* `color.surface.highlight` (focus), `color.feedback.error`,
|
|
61
|
+
* `color.feedback.errorSubtle` and `elevation.color.error` (error),
|
|
62
|
+
* `color.surface.disabled`, `color.border.disabled` and
|
|
63
|
+
* `color.text.disabled` (disabled).
|
|
64
|
+
*
|
|
65
|
+
* @element oh-textarea
|
|
66
|
+
* @fires oh-input - On every keystroke. detail: { value, originalEvent }
|
|
67
|
+
* @fires oh-change - When the value is committed (on blur). detail: { value, originalEvent }
|
|
68
|
+
* @csspart label - The visible label
|
|
69
|
+
* @csspart textarea - The text field
|
|
70
|
+
* @csspart helper - The helper text
|
|
71
|
+
* @csspart error - The error message
|
|
72
|
+
*/
|
|
73
|
+
export declare class OhTextarea extends OhElement {
|
|
74
|
+
static formAssociated: boolean;
|
|
75
|
+
static styles: import("lit").CSSResult[];
|
|
76
|
+
/** The visible label. Always set one: it names the field. */
|
|
77
|
+
label: string;
|
|
78
|
+
/** The text in the field */
|
|
79
|
+
value: string;
|
|
80
|
+
/** Example text shown while the field is empty. Not a replacement for the label */
|
|
81
|
+
placeholder: string;
|
|
82
|
+
/** Help shown under the field and linked to it */
|
|
83
|
+
helperText: string;
|
|
84
|
+
/** Error shown before the field and linked to it. Setting it puts the field in its error state */
|
|
85
|
+
errorText: string;
|
|
86
|
+
/** The name the value is submitted under */
|
|
87
|
+
name: string;
|
|
88
|
+
/** Must be filled in before the form submits */
|
|
89
|
+
required: boolean;
|
|
90
|
+
/** Not editable, and left out of the form's data */
|
|
91
|
+
disabled: boolean;
|
|
92
|
+
/** Visible lines of text before the field scrolls (people can drag it taller) */
|
|
93
|
+
rows: number;
|
|
94
|
+
/** Longest allowed text, in characters */
|
|
95
|
+
maxlength?: number;
|
|
96
|
+
/** The field's purpose for autofill and assistive tech (WCAG 1.3.5), e.g. "street-address" */
|
|
97
|
+
autocomplete?: string;
|
|
98
|
+
private _textarea;
|
|
99
|
+
private _internals;
|
|
100
|
+
/** The starting text, restored when the form resets */
|
|
101
|
+
private _defaultValue;
|
|
102
|
+
/** Set when a disabled <fieldset> around it disables it */
|
|
103
|
+
private _formDisabled;
|
|
104
|
+
/**
|
|
105
|
+
* Errors that appear after first render (e.g. on submit) are announced via
|
|
106
|
+
* role="alert". Errors present on page load are only linked with
|
|
107
|
+
* aria-describedby, so they aren't read out unprompted.
|
|
108
|
+
*/
|
|
109
|
+
private _announceError;
|
|
110
|
+
connectedCallback(): void;
|
|
111
|
+
/** The form this field belongs to */
|
|
112
|
+
get form(): HTMLFormElement | null;
|
|
113
|
+
focus(options?: FocusOptions): void;
|
|
114
|
+
blur(): void;
|
|
115
|
+
formResetCallback(): void;
|
|
116
|
+
formDisabledCallback(disabled: boolean): void;
|
|
117
|
+
formStateRestoreCallback(state: string | File | FormData | null): void;
|
|
118
|
+
willUpdate(changed: PropertyValues): void;
|
|
119
|
+
updated(changed: PropertyValues): void;
|
|
120
|
+
private _handleInput;
|
|
121
|
+
private _handleChange;
|
|
122
|
+
render(): import("lit").TemplateResult<1>;
|
|
123
|
+
}
|
|
124
|
+
declare global {
|
|
125
|
+
interface HTMLElementTagNameMap {
|
|
126
|
+
"oh-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AiB;IAIjB,oBAAoB,CAAC,QAAQ,EAAE,OAAO;IAItC,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI;IAI/D,UAAU,CAAC,OAAO,EAAE,cAAc;IAMlC,OAAO,CAAC,OAAO,EAAE,cAAc;IAe/B,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,aAAa;IAIrB,MAAM;CAsEP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* oh-textarea
|
|
3
|
+
*
|
|
4
|
+
* A multi-line text field for messages, comments and feedback.
|
|
5
|
+
*
|
|
6
|
+
* DESIGN DECISIONS:
|
|
7
|
+
* ─────────────────
|
|
8
|
+
* 1. SAME FAMILY AS oh-input
|
|
9
|
+
* - Same tokens: stroke.control border in color.border.emphasis,
|
|
10
|
+
* shape.control corners, an inset shadow offset by elevation.offset.md
|
|
11
|
+
* in elevation.color.field
|
|
12
|
+
* - Focus is a solid inset ring in focus.ringColor inside the border;
|
|
13
|
+
* background switches to color.surface.highlight
|
|
14
|
+
*
|
|
15
|
+
* 2. ON THE GRID
|
|
16
|
+
* - Line height is 1.5 times the text size, rounded up to the brand's
|
|
17
|
+
* grid (grid.unit), so every line of a long message sits on it
|
|
18
|
+
*
|
|
19
|
+
* 3. A REAL FORM CONTROL
|
|
20
|
+
* - Form-associated: its value submits with the form under its name,
|
|
21
|
+
* `required` blocks submission with the browser's own message, a
|
|
22
|
+
* form reset restores the starting text, and a disabled <fieldset>
|
|
23
|
+
* disables it
|
|
24
|
+
*
|
|
25
|
+
* 4. ERRORS BEFORE THE FIELD
|
|
26
|
+
* - Error text sits after the label and before the field, with an icon,
|
|
27
|
+
* so it's read before the field is reached. Helper text sits after
|
|
28
|
+
*/
|
|
29
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
30
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
31
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
32
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
33
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
34
|
+
};
|
|
35
|
+
import { html, css, nothing } from "lit";
|
|
36
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
|
37
|
+
import { OhElement, baseStyles } from "./base.js";
|
|
38
|
+
/**
|
|
39
|
+
* A multi-line text field that submits with a native form.
|
|
40
|
+
*
|
|
41
|
+
* **Use it for** messages, comments, feedback: text that may run to several
|
|
42
|
+
* lines. **Don't use it for** a single line of text (use `oh-input`).
|
|
43
|
+
*
|
|
44
|
+
* **States:** rest, hover, focus, error (set `error-text`), disabled,
|
|
45
|
+
* required. `rows` sets the visible lines (default 4); people can drag it
|
|
46
|
+
* taller. `maxlength` limits the length.
|
|
47
|
+
*
|
|
48
|
+
* **Behaviour:** form-associated. Give it a `name` and it submits with the
|
|
49
|
+
* form. `required` stops the form submitting while it's empty, with the
|
|
50
|
+
* browser's own message. A form reset restores its starting text, and a
|
|
51
|
+
* disabled `<fieldset>` disables it. Fires `oh-input` on every keystroke and
|
|
52
|
+
* `oh-change` when the value is committed. Its line height is 1.5 times the
|
|
53
|
+
* text size, rounded up to `grid.unit`, so long messages stay on the grid.
|
|
54
|
+
*
|
|
55
|
+
* **Accessibility:** always set `label`: it names the field. A placeholder
|
|
56
|
+
* isn't a label. Helper and error text are linked to the field with
|
|
57
|
+
* `aria-describedby`, so screen readers read them. Errors come before the
|
|
58
|
+
* field, with an icon, set `aria-invalid`, and are announced only when they
|
|
59
|
+
* appear after the page has loaded. Focus is a solid inset ring. Use
|
|
60
|
+
* `autocomplete` when the field asks for something a browser can fill in,
|
|
61
|
+
* such as an address (WCAG 1.3.5).
|
|
62
|
+
*
|
|
63
|
+
* **Look:** set by tokens — `stroke.control` in `color.border.emphasis`
|
|
64
|
+
* (border), `shape.control` (corners), `typography.control.*` (type),
|
|
65
|
+
* `elevation.offset.md` and `elevation.color.field` (inset shadow),
|
|
66
|
+
* `color.border.hover` (hover), `focus.ringColor` and
|
|
67
|
+
* `color.surface.highlight` (focus), `color.feedback.error`,
|
|
68
|
+
* `color.feedback.errorSubtle` and `elevation.color.error` (error),
|
|
69
|
+
* `color.surface.disabled`, `color.border.disabled` and
|
|
70
|
+
* `color.text.disabled` (disabled).
|
|
71
|
+
*
|
|
72
|
+
* @element oh-textarea
|
|
73
|
+
* @fires oh-input - On every keystroke. detail: { value, originalEvent }
|
|
74
|
+
* @fires oh-change - When the value is committed (on blur). detail: { value, originalEvent }
|
|
75
|
+
* @csspart label - The visible label
|
|
76
|
+
* @csspart textarea - The text field
|
|
77
|
+
* @csspart helper - The helper text
|
|
78
|
+
* @csspart error - The error message
|
|
79
|
+
*/
|
|
80
|
+
let OhTextarea = class OhTextarea extends OhElement {
|
|
81
|
+
constructor() {
|
|
82
|
+
super(...arguments);
|
|
83
|
+
/** The visible label. Always set one: it names the field. */
|
|
84
|
+
this.label = "";
|
|
85
|
+
/** The text in the field */
|
|
86
|
+
this.value = "";
|
|
87
|
+
/** Example text shown while the field is empty. Not a replacement for the label */
|
|
88
|
+
this.placeholder = "";
|
|
89
|
+
/** Help shown under the field and linked to it */
|
|
90
|
+
this.helperText = "";
|
|
91
|
+
/** Error shown before the field and linked to it. Setting it puts the field in its error state */
|
|
92
|
+
this.errorText = "";
|
|
93
|
+
/** The name the value is submitted under */
|
|
94
|
+
this.name = "";
|
|
95
|
+
/** Must be filled in before the form submits */
|
|
96
|
+
this.required = false;
|
|
97
|
+
/** Not editable, and left out of the form's data */
|
|
98
|
+
this.disabled = false;
|
|
99
|
+
/** Visible lines of text before the field scrolls (people can drag it taller) */
|
|
100
|
+
this.rows = 4;
|
|
101
|
+
this._internals = this.attachInternals();
|
|
102
|
+
/** The starting text, restored when the form resets */
|
|
103
|
+
this._defaultValue = "";
|
|
104
|
+
/** Set when a disabled <fieldset> around it disables it */
|
|
105
|
+
this._formDisabled = false;
|
|
106
|
+
/**
|
|
107
|
+
* Errors that appear after first render (e.g. on submit) are announced via
|
|
108
|
+
* role="alert". Errors present on page load are only linked with
|
|
109
|
+
* aria-describedby, so they aren't read out unprompted.
|
|
110
|
+
*/
|
|
111
|
+
this._announceError = false;
|
|
112
|
+
}
|
|
113
|
+
static { this.formAssociated = true; }
|
|
114
|
+
static { this.styles = [
|
|
115
|
+
baseStyles,
|
|
116
|
+
css `
|
|
117
|
+
:host {
|
|
118
|
+
display: block;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.wrapper {
|
|
122
|
+
display: flex;
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
gap: var(--oh-spacing-2);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.label {
|
|
128
|
+
font-family: var(--oh-typography-control-font-family);
|
|
129
|
+
font-size: var(--oh-typography-control-font-size-sm);
|
|
130
|
+
font-weight: var(--oh-typography-control-font-weight);
|
|
131
|
+
color: var(--oh-color-text-primary);
|
|
132
|
+
letter-spacing: var(--oh-typography-control-letter-spacing);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.label--required::after {
|
|
136
|
+
content: " *";
|
|
137
|
+
color: var(--oh-color-feedback-error);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.textarea {
|
|
141
|
+
display: block;
|
|
142
|
+
width: 100%;
|
|
143
|
+
margin: 0;
|
|
144
|
+
resize: vertical;
|
|
145
|
+
font-family: var(--oh-typography-control-font-family);
|
|
146
|
+
font-size: var(--oh-typography-control-font-size-md);
|
|
147
|
+
/* 1.5 x the text size, rounded up to the brand's grid */
|
|
148
|
+
line-height: 1.5;
|
|
149
|
+
line-height: round(
|
|
150
|
+
up,
|
|
151
|
+
calc(var(--oh-typography-control-font-size-md) * 1.5),
|
|
152
|
+
var(--oh-grid-unit)
|
|
153
|
+
);
|
|
154
|
+
color: var(--oh-color-text-primary);
|
|
155
|
+
background-color: var(--oh-color-surface-base);
|
|
156
|
+
padding: var(--oh-spacing-3) var(--oh-spacing-4);
|
|
157
|
+
border: var(--oh-stroke-control) solid var(--oh-color-border-emphasis);
|
|
158
|
+
border-radius: var(--oh-shape-control);
|
|
159
|
+
box-shadow: inset var(--oh-elevation-offset-md)
|
|
160
|
+
var(--oh-elevation-offset-md) 0 0 var(--oh-elevation-color-field);
|
|
161
|
+
transition:
|
|
162
|
+
border-color var(--oh-motion-snappy) ease,
|
|
163
|
+
box-shadow var(--oh-motion-snappy) ease,
|
|
164
|
+
background-color var(--oh-motion-quick) ease;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.textarea::placeholder {
|
|
168
|
+
color: var(--oh-color-text-secondary);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.textarea:hover:not(:focus):not(:disabled) {
|
|
172
|
+
border-color: var(--oh-color-border-hover);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.textarea:focus {
|
|
176
|
+
outline: none;
|
|
177
|
+
background-color: var(--oh-color-surface-highlight);
|
|
178
|
+
border-color: var(--oh-focus-ring-color);
|
|
179
|
+
box-shadow: inset 0 0 0 2px var(--oh-focus-ring-color);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.textarea--error {
|
|
183
|
+
border-color: var(--oh-color-feedback-error);
|
|
184
|
+
background-color: var(--oh-color-feedback-error-subtle);
|
|
185
|
+
box-shadow: inset var(--oh-elevation-offset-md)
|
|
186
|
+
var(--oh-elevation-offset-md) 0 0 var(--oh-elevation-color-error);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.textarea--error:focus {
|
|
190
|
+
border-color: var(--oh-color-feedback-error);
|
|
191
|
+
box-shadow: inset 0 0 0 2px var(--oh-color-feedback-error);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Disabled: color.*.disabled tokens, no shadow, no resizing */
|
|
195
|
+
.textarea:disabled {
|
|
196
|
+
cursor: not-allowed;
|
|
197
|
+
resize: none;
|
|
198
|
+
color: var(--oh-color-text-disabled);
|
|
199
|
+
background-color: var(--oh-color-surface-disabled);
|
|
200
|
+
border-color: var(--oh-color-border-disabled);
|
|
201
|
+
box-shadow: none;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.label--disabled {
|
|
205
|
+
color: var(--oh-color-text-disabled);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.helper {
|
|
209
|
+
font-family: var(--oh-typography-body-font-family);
|
|
210
|
+
font-size: var(--oh-typography-body-base-font-size);
|
|
211
|
+
line-height: var(--oh-typography-body-base-line-height);
|
|
212
|
+
color: var(--oh-color-text-secondary);
|
|
213
|
+
letter-spacing: var(--oh-typography-control-letter-spacing);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.error {
|
|
217
|
+
display: flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
gap: var(--oh-spacing-2);
|
|
220
|
+
font-family: var(--oh-typography-body-font-family);
|
|
221
|
+
font-size: var(--oh-typography-body-base-font-size);
|
|
222
|
+
line-height: var(--oh-typography-body-base-line-height);
|
|
223
|
+
color: var(--oh-color-feedback-error);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.error-icon {
|
|
227
|
+
flex-shrink: 0;
|
|
228
|
+
width: var(--oh-spacing-4);
|
|
229
|
+
height: var(--oh-spacing-4);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
@media (prefers-reduced-motion: reduce) {
|
|
233
|
+
.textarea {
|
|
234
|
+
transition-duration: 0.01ms !important;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
`,
|
|
238
|
+
]; }
|
|
239
|
+
connectedCallback() {
|
|
240
|
+
super.connectedCallback();
|
|
241
|
+
if (!this.hasUpdated)
|
|
242
|
+
this._defaultValue = this.value;
|
|
243
|
+
}
|
|
244
|
+
/** The form this field belongs to */
|
|
245
|
+
get form() {
|
|
246
|
+
return this._internals.form;
|
|
247
|
+
}
|
|
248
|
+
focus(options) {
|
|
249
|
+
this._textarea?.focus(options);
|
|
250
|
+
}
|
|
251
|
+
blur() {
|
|
252
|
+
this._textarea?.blur();
|
|
253
|
+
}
|
|
254
|
+
formResetCallback() {
|
|
255
|
+
this.value = this._defaultValue;
|
|
256
|
+
}
|
|
257
|
+
formDisabledCallback(disabled) {
|
|
258
|
+
this._formDisabled = disabled;
|
|
259
|
+
}
|
|
260
|
+
formStateRestoreCallback(state) {
|
|
261
|
+
if (typeof state === "string")
|
|
262
|
+
this.value = state;
|
|
263
|
+
}
|
|
264
|
+
willUpdate(changed) {
|
|
265
|
+
if (this.hasUpdated && changed.has("errorText")) {
|
|
266
|
+
this._announceError = !!this.errorText;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
updated(changed) {
|
|
270
|
+
if (changed.has("value"))
|
|
271
|
+
this._internals.setFormValue(this.value);
|
|
272
|
+
if (changed.has("value") ||
|
|
273
|
+
changed.has("required") ||
|
|
274
|
+
changed.has("maxlength")) {
|
|
275
|
+
this._internals.setValidity(this._textarea.validity, this._textarea.validationMessage, this._textarea);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
_handleInput(event) {
|
|
279
|
+
this.value = event.target.value;
|
|
280
|
+
this.emit("oh-input", { value: this.value, originalEvent: event });
|
|
281
|
+
}
|
|
282
|
+
_handleChange(event) {
|
|
283
|
+
this.emit("oh-change", { value: this.value, originalEvent: event });
|
|
284
|
+
}
|
|
285
|
+
render() {
|
|
286
|
+
const hasError = !!this.errorText;
|
|
287
|
+
const disabled = this.disabled || this._formDisabled;
|
|
288
|
+
const describedBy = hasError ? "error" : this.helperText ? "helper" : "";
|
|
289
|
+
return html `
|
|
290
|
+
<div class="wrapper">
|
|
291
|
+
${this.label
|
|
292
|
+
? html `<label
|
|
293
|
+
class=${this.classMap({
|
|
294
|
+
label: true,
|
|
295
|
+
"label--required": this.required,
|
|
296
|
+
"label--disabled": disabled,
|
|
297
|
+
})}
|
|
298
|
+
part="label"
|
|
299
|
+
for="textarea"
|
|
300
|
+
>${this.label}</label
|
|
301
|
+
>`
|
|
302
|
+
: nothing}
|
|
303
|
+
${hasError
|
|
304
|
+
? html `<span
|
|
305
|
+
id="error"
|
|
306
|
+
class="error"
|
|
307
|
+
part="error"
|
|
308
|
+
role=${this._announceError ? "alert" : nothing}
|
|
309
|
+
>
|
|
310
|
+
<svg
|
|
311
|
+
class="error-icon"
|
|
312
|
+
viewBox="0 0 20 20"
|
|
313
|
+
fill="currentColor"
|
|
314
|
+
aria-hidden="true"
|
|
315
|
+
>
|
|
316
|
+
<path
|
|
317
|
+
fill-rule="evenodd"
|
|
318
|
+
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"
|
|
319
|
+
clip-rule="evenodd"
|
|
320
|
+
/>
|
|
321
|
+
</svg>
|
|
322
|
+
${this.errorText}
|
|
323
|
+
</span>`
|
|
324
|
+
: nothing}
|
|
325
|
+
|
|
326
|
+
<textarea
|
|
327
|
+
id="textarea"
|
|
328
|
+
part="textarea"
|
|
329
|
+
class=${this.classMap({
|
|
330
|
+
textarea: true,
|
|
331
|
+
"textarea--error": hasError,
|
|
332
|
+
})}
|
|
333
|
+
.value=${this.value}
|
|
334
|
+
rows=${this.rows}
|
|
335
|
+
placeholder=${this.placeholder || nothing}
|
|
336
|
+
maxlength=${this.maxlength ?? nothing}
|
|
337
|
+
autocomplete=${this.autocomplete || nothing}
|
|
338
|
+
?required=${this.required}
|
|
339
|
+
?disabled=${disabled}
|
|
340
|
+
aria-invalid=${hasError ? "true" : nothing}
|
|
341
|
+
aria-describedby=${describedBy || nothing}
|
|
342
|
+
@input=${this._handleInput}
|
|
343
|
+
@change=${this._handleChange}
|
|
344
|
+
></textarea>
|
|
345
|
+
|
|
346
|
+
${this.helperText && !hasError
|
|
347
|
+
? html `<span id="helper" class="helper" part="helper"
|
|
348
|
+
>${this.helperText}</span
|
|
349
|
+
>`
|
|
350
|
+
: nothing}
|
|
351
|
+
</div>
|
|
352
|
+
`;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
__decorate([
|
|
356
|
+
property({ type: String })
|
|
357
|
+
], OhTextarea.prototype, "label", void 0);
|
|
358
|
+
__decorate([
|
|
359
|
+
property({ type: String })
|
|
360
|
+
], OhTextarea.prototype, "value", void 0);
|
|
361
|
+
__decorate([
|
|
362
|
+
property({ type: String })
|
|
363
|
+
], OhTextarea.prototype, "placeholder", void 0);
|
|
364
|
+
__decorate([
|
|
365
|
+
property({ type: String, attribute: "helper-text" })
|
|
366
|
+
], OhTextarea.prototype, "helperText", void 0);
|
|
367
|
+
__decorate([
|
|
368
|
+
property({ type: String, attribute: "error-text" })
|
|
369
|
+
], OhTextarea.prototype, "errorText", void 0);
|
|
370
|
+
__decorate([
|
|
371
|
+
property({ type: String, reflect: true })
|
|
372
|
+
], OhTextarea.prototype, "name", void 0);
|
|
373
|
+
__decorate([
|
|
374
|
+
property({ type: Boolean, reflect: true })
|
|
375
|
+
], OhTextarea.prototype, "required", void 0);
|
|
376
|
+
__decorate([
|
|
377
|
+
property({ type: Boolean, reflect: true })
|
|
378
|
+
], OhTextarea.prototype, "disabled", void 0);
|
|
379
|
+
__decorate([
|
|
380
|
+
property({ type: Number })
|
|
381
|
+
], OhTextarea.prototype, "rows", void 0);
|
|
382
|
+
__decorate([
|
|
383
|
+
property({ type: Number })
|
|
384
|
+
], OhTextarea.prototype, "maxlength", void 0);
|
|
385
|
+
__decorate([
|
|
386
|
+
property({ type: String })
|
|
387
|
+
], OhTextarea.prototype, "autocomplete", void 0);
|
|
388
|
+
__decorate([
|
|
389
|
+
query("textarea")
|
|
390
|
+
], OhTextarea.prototype, "_textarea", void 0);
|
|
391
|
+
__decorate([
|
|
392
|
+
state()
|
|
393
|
+
], OhTextarea.prototype, "_formDisabled", void 0);
|
|
394
|
+
__decorate([
|
|
395
|
+
state()
|
|
396
|
+
], OhTextarea.prototype, "_announceError", void 0);
|
|
397
|
+
OhTextarea = __decorate([
|
|
398
|
+
customElement("oh-textarea")
|
|
399
|
+
], OhTextarea);
|
|
400
|
+
export { OhTextarea };
|
|
401
|
+
//# sourceMappingURL=oh-textarea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oh-textarea.js","sourceRoot":"","sources":["../src/oh-textarea.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,SAAS;IAAlC;;QAiIL,6DAA6D;QAE7D,UAAK,GAAG,EAAE,CAAC;QAEX,4BAA4B;QAE5B,UAAK,GAAG,EAAE,CAAC;QAEX,mFAAmF;QAEnF,gBAAW,GAAG,EAAE,CAAC;QAEjB,kDAAkD;QAElD,eAAU,GAAG,EAAE,CAAC;QAEhB,kGAAkG;QAElG,cAAS,GAAG,EAAE,CAAC;QAEf,4CAA4C;QAE5C,SAAI,GAAG,EAAE,CAAC;QAEV,gDAAgD;QAEhD,aAAQ,GAAG,KAAK,CAAC;QAEjB,oDAAoD;QAEpD,aAAQ,GAAG,KAAK,CAAC;QAEjB,iFAAiF;QAEjF,SAAI,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CAAC;yCAChB;AAIX;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACV;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;8CACrC;AAIhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;6CACrC;AAIf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAChC;AAIV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAC1B;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAC1B;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAClB;AAIT;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACR;AAInB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACL;AAGd;IADP,KAAK,CAAC,UAAU,CAAC;6CACsB;AAShC;IADP,KAAK,EAAE;iDACsB;AAQtB;IADP,KAAK,EAAE;kDACuB;AA/LpB,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAmUtB"}
|
package/dist/oh-toggle.d.ts
CHANGED
|
@@ -1,30 +1,63 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-toggle
|
|
3
3
|
*
|
|
4
|
-
* A
|
|
4
|
+
* A switch for binary on/off settings.
|
|
5
5
|
*
|
|
6
6
|
* DESIGN DECISIONS:
|
|
7
7
|
* ─────────────────
|
|
8
|
-
* 1.
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
8
|
+
* 1. LOOK FROM TOKENS
|
|
9
|
+
* - Track: shape.pill, color.surface.raised off, color.brand.primary on
|
|
10
|
+
* - Thumb: color.surface.base with a stroke.control border in
|
|
11
|
+
* color.border.emphasis, and a shadow offset by elevation.offset.*
|
|
12
|
+
* (elevation.color.secondary off, elevation.color.primary on). The shadow's horizontal
|
|
13
|
+
* offset flips when checked; hover and press move the thumb by
|
|
14
|
+
* lift.hoverSm / lift.pressSm
|
|
12
15
|
*
|
|
13
16
|
* 2. VISUAL STATES
|
|
14
|
-
* - Off:
|
|
15
|
-
* - On: Brand primary track, thumb on right, shadow bottom-left (flipped)
|
|
17
|
+
* - Off: thumb at the start of the track; on: thumb at the end
|
|
16
18
|
*
|
|
17
19
|
* 3. ACCESSIBILITY
|
|
18
|
-
* -
|
|
20
|
+
* - role="switch" with aria-checked on a focusable track
|
|
19
21
|
* - Keyboard: Space/Enter to toggle
|
|
20
|
-
* - Focus
|
|
21
|
-
*
|
|
22
|
+
* - Focus: a solid outline in focus.ringColor (focus.glowColor adds a
|
|
23
|
+
* glow around it, as decoration)
|
|
24
|
+
* - Named by its visible label (aria-labelledby) or accessible-label
|
|
25
|
+
*/
|
|
26
|
+
import { OhElement } from "./base.js";
|
|
27
|
+
/**
|
|
28
|
+
* A switch that turns a setting on or off.
|
|
29
|
+
*
|
|
30
|
+
* **Use it for** a setting that takes effect straight away, such as turning
|
|
31
|
+
* notifications on. **Don't use it for** a choice that's only applied when a
|
|
32
|
+
* form is submitted, or one that must be agreed to (use `oh-checkbox`), or
|
|
33
|
+
* a choice between more than two options (use `oh-radio-group`).
|
|
34
|
+
*
|
|
35
|
+
* **States:** off, on, hover, active, focus.
|
|
36
|
+
*
|
|
37
|
+
* **Behaviour:** clicking the switch or its label, or pressing Space or
|
|
38
|
+
* Enter while it's focused, flips `checked` and fires `oh-change` with
|
|
39
|
+
* `{ checked }`. `name` and `value` are stored but it isn't form-associated,
|
|
40
|
+
* so it doesn't submit with a native form: listen for `oh-change`. It has no
|
|
41
|
+
* `disabled` property. Under `prefers-reduced-motion` it doesn't animate.
|
|
42
|
+
*
|
|
43
|
+
* **Accessibility:** `role="switch"` with `aria-checked`, in the tab order.
|
|
44
|
+
* Set `label` (a visible label, linked with `aria-labelledby`), or
|
|
45
|
+
* `accessible-label` when there's no visible label (not `aria-label`, which
|
|
46
|
+
* isn't forwarded into the shadow root). Focus is a solid outline in
|
|
47
|
+
* `focus.ringColor`.
|
|
48
|
+
*
|
|
49
|
+
* **Look:** set by tokens — `shape.pill` (track), `color.surface.raised` /
|
|
50
|
+
* `color.brand.primary` (track off / on), `color.surface.base`,
|
|
51
|
+
* `stroke.control` and `color.border.emphasis` (thumb),
|
|
52
|
+
* `elevation.offset.*` with `elevation.color.secondary` / `elevation.color.primary` (thumb
|
|
53
|
+
* shadow off / on), `lift.hoverSm` / `lift.pressSm` (movement on hover and
|
|
54
|
+
* press), `focus.ringColor` and `focus.glowColor` (focus),
|
|
55
|
+
* `typography.body.*` (label).
|
|
22
56
|
*
|
|
23
57
|
* @element oh-toggle
|
|
24
58
|
*
|
|
25
|
-
* @fires oh-change - Fired when the toggle state changes
|
|
59
|
+
* @fires oh-change - Fired when the toggle state changes. detail: { checked }
|
|
26
60
|
*/
|
|
27
|
-
import { OhElement } from "./base.js";
|
|
28
61
|
export declare class OhToggle extends OhElement {
|
|
29
62
|
static styles: import("lit").CSSResult[];
|
|
30
63
|
/** Whether the toggle is checked/on */
|
package/dist/oh-toggle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-toggle.d.ts","sourceRoot":"","sources":["../src/oh-toggle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oh-toggle.d.ts","sourceRoot":"","sources":["../src/oh-toggle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,EAAE,SAAS,EAAc,MAAM,WAAW,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBACa,QAAS,SAAQ,SAAS;IACrC,OAAgB,MAAM,4BA4HpB;IAEF,uCAAuC;IAEvC,OAAO,UAAS;IAEhB,8CAA8C;IAE9C,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IAEH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,+BAA+B;IAE/B,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,gCAAgC;IAEhC,KAAK,SAAQ;IAEb,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+D;IAExF,MAAM;CA4BP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|