@repobit/dex-system-design 2.5.0 → 2.6.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/CHANGELOG.md +91 -0
- package/README.md +2 -1
- package/package.json +14 -27
- package/schemas/component-manifest.json +226 -33
- package/schemas/manifest-omissions.json +23 -0
- package/src/components/accordion/accordion-bg.css.js +39 -30
- package/src/components/accordion/accordion-bg.js +17 -28
- package/src/components/accordion/accordion-bg.stories.js +5 -0
- package/src/components/accordion/accordion-panel.js +24 -0
- package/src/components/accordion/accordion.css.js +105 -111
- package/src/components/accordion/accordion.js +23 -37
- package/src/components/accordion/accordion.stories.js +5 -1
- package/src/components/anchor/anchor-nav.css.js +131 -53
- package/src/components/anchor/anchor-nav.js +276 -201
- package/src/components/annotation/annotation.css.js +7 -4
- package/src/components/architecture.stories.js +8 -7
- package/src/components/audience-card/audience-card.css.js +30 -4
- package/src/components/audience-card/audience-card.js +8 -13
- package/src/components/awards/awards-flex.css.js +23 -6
- package/src/components/awards/awards-flex.js +21 -6
- package/src/components/awards/awards-spotlight.css.js +25 -5
- package/src/components/awards/awards-spotlight.js +19 -7
- package/src/components/awards/awards.css.js +20 -8
- package/src/components/awards/awards.js +30 -91
- package/src/components/awards/awards.stories.js +5 -5
- package/src/components/awards/scroll-slides.js +128 -0
- package/src/components/back/back.css.js +2 -0
- package/src/components/badge/badge.css.js +15 -0
- package/src/components/bento-grid/bento-grid.css.js +105 -11
- package/src/components/bento-grid/bento-grid.js +37 -124
- package/src/components/bento-grid/bento-grid.stories.js +3 -2
- package/src/components/bento-grid/bento-item.css.js +71 -32
- package/src/components/bento-grid/bento-item.js +3 -30
- package/src/components/blockquote/blockquote.css.js +2 -2
- package/src/components/breadcrumb/breadcrumb.css.js +10 -9
- package/src/components/breadcrumb/breadcrumb.js +35 -34
- package/src/components/button/button.css.js +42 -17
- package/src/components/button/button.js +84 -3
- package/src/components/button/button.stories.js +17 -0
- package/src/components/card-features/card-features.css.js +23 -2
- package/src/components/card-features/card-features.js +6 -48
- package/src/components/cards/card.css.js +43 -14
- package/src/components/cards/card.js +43 -177
- package/src/components/cards/card.stories.js +8 -10
- package/src/components/carousel/carousel.css.js +101 -70
- package/src/components/carousel/carousel.js +107 -71
- package/src/components/carousel/carousel.stories.js +18 -16
- package/src/components/checkbox/checkbox.css.js +26 -9
- package/src/components/checkbox/checkbox.js +73 -39
- package/src/components/checkbox/checkbox.stories.js +35 -18
- package/src/components/compare/compare.css.js +68 -10
- package/src/components/compare/compare.js +40 -103
- package/src/components/compare/compare.stories.js +1 -1
- package/src/components/compatibility-table/compatibility-table.css.js +70 -37
- package/src/components/compatibility-table/compatibility-table.js +47 -40
- package/src/components/compatibility-table/compatibility-table.stories.js +78 -1
- package/src/components/display/display.css.js +7 -0
- package/src/components/dropdown/dropdown.css.js +20 -3
- package/src/components/dropdown/dropdown.js +57 -21
- package/src/components/dropdown/dropdown.stories.js +31 -9
- package/src/components/features/features.css.js +56 -21
- package/src/components/features/features.js +7 -117
- package/src/components/fieldset/fieldset.stories.js +68 -0
- package/src/components/footer/footer-images.js +34 -0
- package/src/components/footer/footer-links-group.css.js +10 -10
- package/src/components/footer/footer-locale.js +47 -0
- package/src/components/footer/footer-lp.js +27 -114
- package/src/components/footer/footer-lp.stories.js +2 -2
- package/src/components/footer/footer-nav-menu.css.js +2 -2
- package/src/components/footer/footer-nav-menu.js +8 -3
- package/src/components/footer/footer.css.js +238 -197
- package/src/components/footer/footer.js +109 -187
- package/src/components/footer/footer.stories.js +14 -4
- package/src/components/grid/grid.css.js +64 -5
- package/src/components/header/header-code.css.js +20 -11
- package/src/components/header/header-code.js +1 -1
- package/src/components/header/header.css.js +20 -14
- package/src/components/header/header.js +6 -7
- package/src/components/header/header.stories.js +29 -24
- package/src/components/heading/heading.css.js +11 -0
- package/src/components/hero/hero.js +10 -2
- package/src/components/highlight/highlight.css.js +30 -6
- package/src/components/icons/arrow-icon.js +4 -1
- package/src/components/icons/arrow-right-icon.js +5 -1
- package/src/components/icons/icon-element.js +18 -0
- package/src/components/image/image.js +29 -9
- package/src/components/image/image.stories.js +38 -2
- package/src/components/input/custom-form.stories.js +38 -7
- package/src/components/input/input-clipboard.css.js +15 -1
- package/src/components/input/input-clipboard.js +84 -21
- package/src/components/input/input.js +27 -7
- package/src/components/install-options/install-options.css.js +26 -6
- package/src/components/install-options/install-options.js +32 -8
- package/src/components/label/label.css.js +1 -1
- package/src/components/light-carousel/light-carousel.css.js +100 -48
- package/src/components/light-carousel/light-carousel.js +43 -5
- package/src/components/link/link.css.js +15 -15
- package/src/components/link/link.js +17 -1
- package/src/components/link/link.stories.js +20 -7
- package/src/components/list/list.css.js +3 -3
- package/src/components/logo-marquee/logo-marquee.css.js +12 -1
- package/src/components/logo-marquee/logo-marquee.js +33 -8
- package/src/components/logo-marquee/logo-marquee.stories.js +10 -4
- package/src/components/modal/modal.css.js +74 -40
- package/src/components/modal/modal.js +85 -74
- package/src/components/modal/modal.stories.js +27 -14
- package/src/components/motion-art/motion-art.js +67 -1
- package/src/components/page-switcher/page-switcher.css.js +27 -9
- package/src/components/page-switcher/page-switcher.js +11 -8
- package/src/components/partner-banner/partner-banner.css.js +2 -0
- package/src/components/picture/picture.css.js +4 -4
- package/src/components/picture/picture.js +13 -3
- package/src/components/picture/picture.stories.js +28 -2
- package/src/components/post-card/post-card.css.js +18 -3
- package/src/components/pricing-cards/adopt-styles.js +16 -0
- package/src/components/pricing-cards/new-pricing-card.js +2 -4
- package/src/components/pricing-cards/new-pricing-card.stories.js +20 -22
- package/src/components/pricing-cards/pricing-card-actions.css.js +8 -12
- package/src/components/pricing-cards/pricing-card-actions.js +26 -13
- package/src/components/pricing-cards/pricing-card-container.css.js +4 -3
- package/src/components/pricing-cards/pricing-card-container.js +10 -4
- package/src/components/pricing-cards/pricing-card-header.css.js +5 -4
- package/src/components/pricing-cards/pricing-card-header.js +18 -31
- package/src/components/pricing-cards/pricing-card-pricing.css.js +84 -61
- package/src/components/pricing-cards/pricing-card-pricing.js +38 -24
- package/src/components/pricing-cards/pricing-card-show-more.js +8 -3
- package/src/components/pricing-cards/pricing-card.css.js +75 -41
- package/src/components/pricing-cards/pricing-card.js +356 -308
- package/src/components/progress/progress.css.js +58 -13
- package/src/components/progress/progress.js +13 -10
- package/src/components/progress/progress.stories.js +9 -7
- package/src/components/radio/radio-group.css.js +42 -0
- package/src/components/radio/radio-group.js +89 -0
- package/src/components/radio/radio.css.js +63 -6
- package/src/components/radio/radio.js +173 -140
- package/src/components/radio/radio.stories.js +99 -44
- package/src/components/radio/toggle-radio.js +44 -0
- package/src/components/review/review-grid.css.js +5 -1
- package/src/components/review/review-grid.js +2 -0
- package/src/components/review/review.js +13 -0
- package/src/components/shared/announcer.js +37 -0
- package/src/components/shared/fill-width.css.js +33 -0
- package/src/components/shared/form-control.js +194 -0
- package/src/components/shared/form-field.css.js +31 -3
- package/src/components/shared/token-scales.js +75 -26
- package/src/components/spotlight-section/spotlight-section.js +2 -2
- package/src/components/stat/stat-highlight.js +1 -1
- package/src/components/stat/stat.css.js +18 -3
- package/src/components/switch/switch.css.js +58 -5
- package/src/components/switch/switch.js +53 -5
- package/src/components/switch/switch.stories.js +30 -8
- package/src/components/tab-list/tab-list.css.js +51 -13
- package/src/components/tab-list/tab-list.js +7 -2
- package/src/components/tab-list/tab-list.stories.js +2 -2
- package/src/components/tabs/tabs.css.js +18 -1
- package/src/components/tabs/tabs.js +119 -41
- package/src/components/terminal/terminal-message.css.js +6 -1
- package/src/components/termsOfUse/terms.css.js +4 -2
- package/src/components/textarea/textarea.js +22 -7
- package/src/components/textarea/textarea.stories.js +12 -9
- package/src/components/trust-panel/trust-panel.css.js +13 -3
- package/src/components/ultimate-security-demo.stories.js +5 -5
- package/src/components/video/video.css.js +5 -0
- package/src/components/video/video.js +5 -0
- package/src/components/video/video.stories.js +12 -0
- package/src/components/video-player/video-player.css.js +20 -8
- package/src/components/video-player/video-player.js +74 -20
- package/src/components/video-player/video-player.stories.js +17 -3
- package/src/tokens/brands.stories.js +1 -1
- package/src/tokens/themes/index.js +2 -2
- package/src/tokens/typography.stories.js +4 -3
- package/src/vendor/motion-art/README.md +4 -1
- package/src/components/footer/footer-lp.css.js +0 -159
|
@@ -24,7 +24,7 @@ It includes:
|
|
|
24
24
|
|---|---|
|
|
25
25
|
| \`default\` | Idle, no interaction |
|
|
26
26
|
| \`focused\` | Has keyboard focus — set it to move focus into the field; it reflects whether the field is focused |
|
|
27
|
-
| \`invalid\` |
|
|
27
|
+
| \`invalid\` | Forced error — red border + helper text, for what only the page knows. The browser's own checks show the same state on their own; see below. |
|
|
28
28
|
| \`validated\` | Passed validation — green border + check icon |
|
|
29
29
|
| \`disabled\` | Non-interactive, visually muted |
|
|
30
30
|
|
|
@@ -78,9 +78,33 @@ Do **not** read \`e.target.value\` from a native \`input\` event. That event doe
|
|
|
78
78
|
escape the shadow root, but it retargets to the host, so \`e.target\` is the
|
|
79
79
|
\`<bd-custom-input>\` element — use \`bd-input\` or the \`value\` property.
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
the
|
|
81
|
+
### In a form
|
|
82
|
+
\`bd-custom-input\` and \`bd-custom-dropdown\` are **form-associated**: a
|
|
83
|
+
\`<form>\` around them sees each as the native control inside it. A dropdown
|
|
84
|
+
needs a \`placeholder\` for \`required\` to be able to fail — see
|
|
85
|
+
**Atoms/Dropdown**.
|
|
86
|
+
|
|
87
|
+
| | |
|
|
88
|
+
|---|---|
|
|
89
|
+
| Submit | \`name=value\`. |
|
|
90
|
+
| Reset | Back to the \`value\` **attribute**, as on a native field — the property is the current value, the attribute the default. |
|
|
91
|
+
| Constraints | \`required\`, \`type\` and the rest are the native control's own checks, reported to the form in the browser's own words: a submit is blocked, the first bad field is focused and its message shown. |
|
|
92
|
+
| \`<fieldset disabled>\` | Disables the field and leaves it out of the submit, without touching its \`disabled\`. |
|
|
93
|
+
| \`<label for>\` | Focuses the field. |
|
|
94
|
+
|
|
95
|
+
\`form\`, \`validity\`, \`validationMessage\`, \`willValidate\`,
|
|
96
|
+
\`checkValidity()\` and \`reportValidity()\` are on the element.
|
|
97
|
+
|
|
98
|
+
**The error state follows the browser's checks.** A field that fails them
|
|
99
|
+
turns red once the reader has changed it and left (\`:user-invalid\`), or once
|
|
100
|
+
a submit has been tried — not while an empty required field is merely
|
|
101
|
+
untouched. Correcting it clears the state as soon as it is valid. \`invalid\`
|
|
102
|
+
still forces the state, for a reason only the page has.
|
|
103
|
+
|
|
104
|
+
Enter does **not** submit the form, as it would from a native field: the
|
|
105
|
+
native field has no form of its own to submit, and a script doing it instead
|
|
106
|
+
would submit mid-composition for a reader typing through an IME in Safari,
|
|
107
|
+
which does not report composition on the key event.
|
|
84
108
|
|
|
85
109
|
### Validation is announced, not just coloured
|
|
86
110
|
\`invalid\` sets \`aria-invalid="true"\`, and when \`tooltip\` is present the input
|
|
@@ -133,7 +157,10 @@ everything else is not:
|
|
|
133
157
|
| \`value\` | yes | yes | yes |
|
|
134
158
|
| \`type\`, \`placeholder\`, \`focused\` | yes | **no** | yes |
|
|
135
159
|
| \`name\` | yes | yes | yes |
|
|
136
|
-
| \`
|
|
160
|
+
| \`autocomplete\`, \`enterkeyhint\` | yes | **no** | yes |
|
|
161
|
+
| \`inputmode\` | yes | **no** | **no** |
|
|
162
|
+
| \`spellcheck\`, \`aria-label\` passed to the field | **no** | **no** | yes |
|
|
163
|
+
| form-associated (submits, resets, \`required\`, \`<fieldset disabled>\`) | yes | yes | yes |
|
|
137
164
|
| \`options\` | **no** | yes | **no** |
|
|
138
165
|
| emits | \`bd-input\`, \`bd-change\` | \`bd-input\`, \`bd-change\` | \`bd-input\`, \`bd-change\` |
|
|
139
166
|
|
|
@@ -144,6 +171,10 @@ All three emit the same events with the same \`detail\`, so one form handler
|
|
|
144
171
|
reads them. The clipboard field used to fire \`input\` — the native event's
|
|
145
172
|
name — with a bare string; a paste fires \`bd-input\` and then \`bd-change\`.
|
|
146
173
|
|
|
174
|
+
The clipboard field takes \`spellcheck\` (a pasted key or code usually wants
|
|
175
|
+
\`spellcheck="false"\`), and with no visible \`label\` it names its field from
|
|
176
|
+
\`aria-label\` on the element, or from a \`<label for>\` pointing at it.
|
|
177
|
+
|
|
147
178
|
### The clipboard field pastes, it does not copy
|
|
148
179
|
The button reads the system clipboard with \`navigator.clipboard.readText()\` and
|
|
149
180
|
writes the result **into** the field. It is a paste affordance — the direction
|
|
@@ -207,7 +238,7 @@ misses 2.5.5 (AAA, 44px) at every size.
|
|
|
207
238
|
},
|
|
208
239
|
required: {
|
|
209
240
|
control : 'boolean',
|
|
210
|
-
description: 'Marks the field as required and appends an asterisk to the label',
|
|
241
|
+
description: 'Marks the field as required and appends an asterisk to the label. In a form, an empty required field blocks the submit.',
|
|
211
242
|
table : {
|
|
212
243
|
type : { summary: 'boolean' },
|
|
213
244
|
defaultValue: { summary: false },
|
|
@@ -225,7 +256,7 @@ misses 2.5.5 (AAA, 44px) at every size.
|
|
|
225
256
|
},
|
|
226
257
|
invalid: {
|
|
227
258
|
control : 'boolean',
|
|
228
|
-
description: '
|
|
259
|
+
description: 'Forces the error / invalid styling — red border, helper text — for a reason only the page knows. A field the browser finds invalid shows it on its own once touched or submitted.',
|
|
229
260
|
table : {
|
|
230
261
|
type : { summary: 'boolean' },
|
|
231
262
|
defaultValue: { summary: false },
|
|
@@ -23,7 +23,7 @@ export default css`
|
|
|
23
23
|
|
|
24
24
|
.paste-button {
|
|
25
25
|
position: absolute;
|
|
26
|
-
|
|
26
|
+
inset-inline-end: var(--spacing-8);
|
|
27
27
|
display: inline-flex;
|
|
28
28
|
align-items: center;
|
|
29
29
|
background: transparent;
|
|
@@ -60,6 +60,20 @@ export default css`
|
|
|
60
60
|
border-radius: var(--focus-outline-radius);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/* The live region a paste is announced through; see _say() in
|
|
64
|
+
input-clipboard.js. Out of view, in the accessibility tree. */
|
|
65
|
+
.paste-status {
|
|
66
|
+
position: absolute;
|
|
67
|
+
/* no token: 1px is the clip idiom's own measure, not a border -- the same
|
|
68
|
+
sanctioned literal as visually-hidden.css.js. */
|
|
69
|
+
width: 1px;
|
|
70
|
+
height: 1px;
|
|
71
|
+
margin: -1px;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
clip-path: inset(50%);
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
.paste-button:hover {
|
|
64
78
|
color: var(--color-text-primary);
|
|
65
79
|
}
|
|
@@ -1,27 +1,50 @@
|
|
|
1
1
|
import { LitElement, html, nothing } from "lit";
|
|
2
|
+
import { keyed } from "lit/directives/keyed.js";
|
|
2
3
|
// Installs the design tokens into document scope; see src/tokens/tokens.js
|
|
3
4
|
import "../../tokens/tokens.js";
|
|
4
5
|
import { formFieldCSS } from "../shared/form-field.css.js";
|
|
5
6
|
import inputClipboardCSS from "../input/input-clipboard.css.js";
|
|
6
7
|
import { resolveSize } from '../shared/prop-vocabulary.js';
|
|
8
|
+
import { ValueControl, omitEmpty } from "../shared/form-control.js";
|
|
9
|
+
import { Announcer } from "../shared/announcer.js";
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A text field with a paste button. Form-associated, as bd-custom-input is
|
|
13
|
+
* (shared/form-control.js): the <input> is in this shadow root, where it has
|
|
14
|
+
* no form owner, so the <form> around the element could not see it -- it was
|
|
15
|
+
* the one field in the family a form submitted, reset and validated none of.
|
|
16
|
+
*/
|
|
17
|
+
class CustomInputClipboard extends ValueControl(LitElement) {
|
|
9
18
|
static properties = {
|
|
10
|
-
label
|
|
11
|
-
type
|
|
12
|
-
size
|
|
19
|
+
label : { type: String },
|
|
20
|
+
type : { type: String },
|
|
21
|
+
size : { type: String, reflect: true },
|
|
13
22
|
/** @deprecated pass `size`. It named the size, not the kind. */
|
|
14
|
-
kind
|
|
15
|
-
placeholder: { type: String },
|
|
16
|
-
required
|
|
17
|
-
focused
|
|
18
|
-
tooltip
|
|
19
|
-
invalid
|
|
20
|
-
validated
|
|
21
|
-
disabled
|
|
22
|
-
value
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
kind : { type: String },
|
|
24
|
+
placeholder : { type: String },
|
|
25
|
+
required : { type: Boolean },
|
|
26
|
+
focused : { type: Boolean, reflect: true },
|
|
27
|
+
tooltip : { type: String },
|
|
28
|
+
invalid : { type: Boolean },
|
|
29
|
+
validated : { type: Boolean, reflect: true },
|
|
30
|
+
disabled : { type: Boolean, reflect: true },
|
|
31
|
+
/* The current value; the value ATTRIBUTE is what reset returns to, as on
|
|
32
|
+
bd-custom-input. */
|
|
33
|
+
value : { type: String },
|
|
34
|
+
/* Carried on the event detail, as on bd-custom-input, and the name the
|
|
35
|
+
form submits under, which FACE reads off the attribute. */
|
|
36
|
+
name : { type: String, reflect: true, converter: omitEmpty },
|
|
37
|
+
/* Passed to the <input>, as bd-custom-input passes them: what autofill
|
|
38
|
+
may offer, whether the field is spellchecked -- a pasted key or code
|
|
39
|
+
usually wants spellcheck="false" -- and what the mobile Enter key
|
|
40
|
+
says. spellcheck is the global attribute, read under its own name. */
|
|
41
|
+
autocomplete: { type: String },
|
|
42
|
+
spellCheck : { type: String, attribute: "spellcheck" },
|
|
43
|
+
enterkeyhint: { type: String },
|
|
44
|
+
/* The field's name when there is no visible label: aria-label on the
|
|
45
|
+
element is passed to the <input>, which is what a screen reader
|
|
46
|
+
focuses -- on the element itself it named nothing. */
|
|
47
|
+
fieldLabel : { type: String, attribute: "aria-label" }
|
|
25
48
|
};
|
|
26
49
|
|
|
27
50
|
constructor() {
|
|
@@ -40,6 +63,31 @@ class CustomInputClipboard extends LitElement {
|
|
|
40
63
|
this.disabled = false;
|
|
41
64
|
this.value = "";
|
|
42
65
|
this.name = "";
|
|
66
|
+
this.autocomplete = "";
|
|
67
|
+
this.spellCheck = null;
|
|
68
|
+
this.enterkeyhint = "";
|
|
69
|
+
this.fieldLabel = "";
|
|
70
|
+
/* What the paste button did is said, not left to be inferred: the field
|
|
71
|
+
fills silently, and a refused clipboard -- the reader declined the
|
|
72
|
+
permission, or the page is not allowed it -- used to do nothing at all
|
|
73
|
+
but log. Through the live region, as in bd-install-options
|
|
74
|
+
(shared/announcer.js). */
|
|
75
|
+
this._announcer = new Announcer(this);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get _control() {
|
|
79
|
+
return this.renderRoot?.querySelector?.("input");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* With no visible label, the <input> is named by aria-label on the
|
|
83
|
+
element, or else by the text of a <label for> pointing at the element --
|
|
84
|
+
FACE gives the element its labels, but a label outside cannot name the
|
|
85
|
+
<input> inside. Past both, the browser falls back on the placeholder. */
|
|
86
|
+
get _accessibleName() {
|
|
87
|
+
if (this.label) return "";
|
|
88
|
+
if (this.fieldLabel) return this.fieldLabel;
|
|
89
|
+
return [...(this._internals.labels ?? [])].map(l => l.textContent.trim()).filter(Boolean)
|
|
90
|
+
.join(" ");
|
|
43
91
|
}
|
|
44
92
|
|
|
45
93
|
/* THE EVENTS ARE bd-custom-input's.
|
|
@@ -63,15 +111,22 @@ class CustomInputClipboard extends LitElement {
|
|
|
63
111
|
try {
|
|
64
112
|
const text = await navigator.clipboard.readText();
|
|
65
113
|
this.value = text;
|
|
114
|
+
// before the events, as handleInput does: the form is not told until
|
|
115
|
+
// the next update otherwise, and a handler asking it got the old value
|
|
116
|
+
this._sync();
|
|
66
117
|
this._emit("bd-input");
|
|
67
118
|
this._emit("bd-change");
|
|
119
|
+
this._announcer.say("Pasted from clipboard");
|
|
68
120
|
} catch (err) {
|
|
69
121
|
console.error("Clipboard paste failed:", err);
|
|
122
|
+
this._announcer.say("Could not paste from clipboard");
|
|
70
123
|
}
|
|
71
124
|
}
|
|
72
125
|
|
|
73
126
|
handleInput(e) {
|
|
74
127
|
this.value = e.target.value;
|
|
128
|
+
// before the event, as in bd-custom-input
|
|
129
|
+
this._sync();
|
|
75
130
|
this._emit("bd-input");
|
|
76
131
|
}
|
|
77
132
|
|
|
@@ -94,6 +149,7 @@ class CustomInputClipboard extends LitElement {
|
|
|
94
149
|
indicator on any page that set it. The ring is now only the browser's
|
|
95
150
|
:focus-visible, which a text field shows whenever it is focused. */
|
|
96
151
|
updated(changed) {
|
|
152
|
+
this._sync();
|
|
97
153
|
if (!changed.has('focused')) return;
|
|
98
154
|
const input = this.shadowRoot.querySelector('input');
|
|
99
155
|
const has = this.shadowRoot.activeElement === input;
|
|
@@ -114,7 +170,8 @@ class CustomInputClipboard extends LitElement {
|
|
|
114
170
|
lg: "label-lg"
|
|
115
171
|
}[this.size];
|
|
116
172
|
|
|
117
|
-
const
|
|
173
|
+
const disabled = this.disabled || this._formDisabled;
|
|
174
|
+
const inputStateClass = disabled
|
|
118
175
|
? "form-input--disabled"
|
|
119
176
|
: this.invalid
|
|
120
177
|
? "form-input--error"
|
|
@@ -143,27 +200,32 @@ class CustomInputClipboard extends LitElement {
|
|
|
143
200
|
</label>`
|
|
144
201
|
: nothing}
|
|
145
202
|
<div class="input-with-button">
|
|
146
|
-
|
|
203
|
+
${keyed(this._resets, html`<input
|
|
147
204
|
id="clipboard-input"
|
|
148
|
-
class="form-input-bd ${inputClass} ${inputStateClass}"
|
|
205
|
+
class="form-input-bd ${inputClass} ${inputStateClass} ${this._attempted ? "form-input--attempted" : ""}"
|
|
149
206
|
type="${this.type}"
|
|
150
207
|
placeholder="${this.placeholder}"
|
|
151
208
|
.value="${this.value}"
|
|
209
|
+
autocomplete="${this.autocomplete || nothing}"
|
|
210
|
+
spellcheck="${this.spellCheck ?? nothing}"
|
|
211
|
+
enterkeyhint="${this.enterkeyhint || nothing}"
|
|
152
212
|
?required="${this.required}"
|
|
153
|
-
?disabled="${
|
|
213
|
+
?disabled="${disabled}"
|
|
154
214
|
name="${this.name || nothing}"
|
|
215
|
+
aria-label="${this._accessibleName || nothing}"
|
|
155
216
|
aria-invalid="${this.invalid ? "true" : nothing}"
|
|
156
217
|
aria-describedby="${this.tooltip ? "clipboard-input-help" : nothing}"
|
|
157
218
|
@focus="${() => { this.focused = true; }}"
|
|
158
219
|
@blur="${() => { this.focused = false; }}"
|
|
159
220
|
@input="${this.handleInput}"
|
|
160
221
|
@change="${this.handleChange}"
|
|
161
|
-
|
|
222
|
+
@keydown="${this._onFieldKeydown}"
|
|
223
|
+
/>`)}
|
|
162
224
|
<button
|
|
163
225
|
class="paste-button"
|
|
164
226
|
@click="${this.pasteFromClipboard}"
|
|
165
227
|
title="Paste from clipboard"
|
|
166
|
-
?disabled="${
|
|
228
|
+
?disabled="${disabled}"
|
|
167
229
|
type="button"
|
|
168
230
|
aria-label="Paste from clipboard"
|
|
169
231
|
>
|
|
@@ -191,6 +253,7 @@ class CustomInputClipboard extends LitElement {
|
|
|
191
253
|
${this.tooltip}
|
|
192
254
|
</div>`
|
|
193
255
|
: ""}
|
|
256
|
+
<span class="paste-status" role="status">${this._announcer.status}</span>
|
|
194
257
|
</div>
|
|
195
258
|
`;
|
|
196
259
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { LitElement, html, nothing } from "lit";
|
|
2
|
+
import { keyed } from "lit/directives/keyed.js";
|
|
2
3
|
// Installs the design tokens into document scope; see src/tokens/tokens.js
|
|
3
4
|
import "../../tokens/tokens.js";
|
|
4
5
|
import { formFieldCSS } from "../shared/form-field.css.js";
|
|
5
6
|
import inputCSS from "./input.css.js";
|
|
6
7
|
import { resolveSize } from '../shared/prop-vocabulary.js';
|
|
8
|
+
import { ValueControl, omitEmpty } from "../shared/form-control.js";
|
|
7
9
|
|
|
8
10
|
// ids are scoped to the shadow root, so fixed ones are safe here
|
|
9
11
|
const INPUT_ID = "custom-input";
|
|
10
12
|
const HELP_ID = "custom-input-help";
|
|
11
13
|
|
|
12
|
-
class CustomInput extends LitElement {
|
|
14
|
+
class CustomInput extends ValueControl(LitElement) {
|
|
13
15
|
static properties = {
|
|
14
16
|
label : { type: String },
|
|
15
17
|
type : { type: String },
|
|
@@ -23,8 +25,12 @@ class CustomInput extends LitElement {
|
|
|
23
25
|
invalid : { type: Boolean },
|
|
24
26
|
validated : { type: Boolean, reflect: true },
|
|
25
27
|
disabled : { type: Boolean, reflect: true },
|
|
28
|
+
/* The current value. The value ATTRIBUTE is the default a form reset
|
|
29
|
+
returns to, as on a native input: the property does not reflect, so the
|
|
30
|
+
attribute keeps what the page wrote. See ValueControl. */
|
|
26
31
|
value : { type: String },
|
|
27
|
-
name
|
|
32
|
+
// reflected, because a form reads the name off the element
|
|
33
|
+
name : { type: String, reflect: true, converter: omitEmpty },
|
|
28
34
|
// mobile keyboard controls — see the story
|
|
29
35
|
inputmode : { type: String },
|
|
30
36
|
autocomplete: { type: String },
|
|
@@ -55,6 +61,10 @@ class CustomInput extends LitElement {
|
|
|
55
61
|
this.enterkeyhint = "";
|
|
56
62
|
}
|
|
57
63
|
|
|
64
|
+
get _control() {
|
|
65
|
+
return this.renderRoot?.querySelector?.("input");
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
/**
|
|
59
69
|
* The value used to be unreachable. The native input event escapes the
|
|
60
70
|
* shadow root, but it retargets to the host, and the host had no value
|
|
@@ -63,6 +73,9 @@ class CustomInput extends LitElement {
|
|
|
63
73
|
*/
|
|
64
74
|
_onInput(e) {
|
|
65
75
|
this.value = e.target.value;
|
|
76
|
+
// before the event, so a handler asking the form about it gets the answer
|
|
77
|
+
// for what was just typed
|
|
78
|
+
this._sync();
|
|
66
79
|
this.dispatchEvent(new CustomEvent("bd-input", {
|
|
67
80
|
detail : { value: this.value, name: this.name },
|
|
68
81
|
bubbles : true,
|
|
@@ -94,6 +107,11 @@ class CustomInput extends LitElement {
|
|
|
94
107
|
indicator on any page that set it. The ring is now only the browser's
|
|
95
108
|
:focus-visible, which a text field shows whenever it is focused. */
|
|
96
109
|
updated(changed) {
|
|
110
|
+
this._sync();
|
|
111
|
+
this._followFocused(changed);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_followFocused(changed) {
|
|
97
115
|
if (!changed.has('focused')) return;
|
|
98
116
|
const input = this.shadowRoot.querySelector('input');
|
|
99
117
|
const has = this.shadowRoot.activeElement === input;
|
|
@@ -105,7 +123,8 @@ class CustomInput extends LitElement {
|
|
|
105
123
|
const inputClass = { sm: "input-sm", md: "input-md", lg: "input-lg" }[this.size];
|
|
106
124
|
const labelClass = { sm: "label-sm", md: "label-md", lg: "label-lg" }[this.size];
|
|
107
125
|
|
|
108
|
-
const
|
|
126
|
+
const disabled = this.disabled || this._formDisabled;
|
|
127
|
+
const inputStateClass = disabled
|
|
109
128
|
? "form-input--disabled"
|
|
110
129
|
: this.invalid
|
|
111
130
|
? "form-input--error"
|
|
@@ -129,9 +148,9 @@ class CustomInput extends LitElement {
|
|
|
129
148
|
: ""}
|
|
130
149
|
</label>`
|
|
131
150
|
: nothing}
|
|
132
|
-
|
|
151
|
+
${keyed(this._resets, html`<input
|
|
133
152
|
id="${INPUT_ID}"
|
|
134
|
-
class="form-input-bd ${inputClass} ${inputStateClass}"
|
|
153
|
+
class="form-input-bd ${inputClass} ${inputStateClass} ${this._attempted ? "form-input--attempted" : ""}"
|
|
135
154
|
type="${this.type}"
|
|
136
155
|
name="${this.name || nothing}"
|
|
137
156
|
placeholder="${this.placeholder}"
|
|
@@ -140,14 +159,15 @@ class CustomInput extends LitElement {
|
|
|
140
159
|
autocomplete="${this.autocomplete || nothing}"
|
|
141
160
|
enterkeyhint="${this.enterkeyhint || nothing}"
|
|
142
161
|
?required="${this.required}"
|
|
143
|
-
?disabled="${
|
|
162
|
+
?disabled="${disabled}"
|
|
144
163
|
aria-invalid="${this.invalid ? "true" : nothing}"
|
|
145
164
|
aria-describedby="${this.tooltip ? HELP_ID : nothing}"
|
|
146
165
|
@focus="${() => { this.focused = true; }}"
|
|
147
166
|
@blur="${() => { this.focused = false; }}"
|
|
148
167
|
@input="${this._onInput}"
|
|
149
168
|
@change="${this._onChange}"
|
|
150
|
-
|
|
169
|
+
@keydown="${this._onFieldKeydown}"
|
|
170
|
+
/>`)}
|
|
151
171
|
${this.tooltip
|
|
152
172
|
? html`<div id="${HELP_ID}" class="form-help-text ${helpTextClass}">
|
|
153
173
|
${this.tooltip}
|
|
@@ -157,14 +157,28 @@ export default css`
|
|
|
157
157
|
line-height: var(--typography-code-block-lineHeight);
|
|
158
158
|
letter-spacing: var(--typography-code-block-letterSpacing);
|
|
159
159
|
white-space: pre-wrap;
|
|
160
|
-
|
|
161
|
-
padding-
|
|
160
|
+
overflow-wrap: anywhere;
|
|
161
|
+
padding-inline-end: var(--spacing-56);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* The live region "Copied" is said through; see _say() in
|
|
165
|
+
install-options.js. Out of view, in the accessibility tree. */
|
|
166
|
+
.bd-installoptions-status {
|
|
167
|
+
position: absolute;
|
|
168
|
+
/* no token: 1px is the clip idiom's own measure, not a border -- the same
|
|
169
|
+
sanctioned literal as visually-hidden.css.js. */
|
|
170
|
+
width: 1px;
|
|
171
|
+
height: 1px;
|
|
172
|
+
margin: -1px;
|
|
173
|
+
overflow: hidden;
|
|
174
|
+
clip-path: inset(50%);
|
|
175
|
+
white-space: nowrap;
|
|
162
176
|
}
|
|
163
177
|
|
|
164
178
|
.bd-installoptions-copy {
|
|
165
179
|
position: absolute;
|
|
166
180
|
top: var(--spacing-12);
|
|
167
|
-
|
|
181
|
+
inset-inline-end: var(--spacing-12);
|
|
168
182
|
padding: var(--spacing-4) var(--spacing-10);
|
|
169
183
|
/* no role: a control fill on an inverse ground -- the vocabulary gap
|
|
170
184
|
button.css.js's SURFACE block records. Mixed from the inverse ink so
|
|
@@ -188,7 +202,13 @@ export default css`
|
|
|
188
202
|
}
|
|
189
203
|
|
|
190
204
|
.bd-installoptions-copy:focus-visible {
|
|
191
|
-
|
|
205
|
+
/* forced-colors mode does not paint box-shadow, so the ring
|
|
206
|
+
vanishes there; it does paint an outline, in a system colour. This one
|
|
207
|
+
is transparent everywhere else, and the offset lands it on the ring's
|
|
208
|
+
outer band. It was outline: none, the one ring in the package with
|
|
209
|
+
nothing left in High Contrast. */
|
|
210
|
+
outline: var(--border-width-2) solid transparent;
|
|
211
|
+
outline-offset: var(--focus-outline-offset);
|
|
192
212
|
box-shadow: var(--focus-outline-primary);
|
|
193
213
|
}
|
|
194
214
|
|
|
@@ -229,7 +249,7 @@ export default css`
|
|
|
229
249
|
border: var(--border-width-2) solid var(--color-border-brand);
|
|
230
250
|
border-radius: var(--shape-radius-md);
|
|
231
251
|
padding: var(--spacing-16);
|
|
232
|
-
padding-
|
|
252
|
+
padding-inline-end: var(--spacing-64);
|
|
233
253
|
box-sizing: border-box;
|
|
234
254
|
margin-bottom: var(--spacing-24);
|
|
235
255
|
}
|
|
@@ -251,7 +271,7 @@ export default css`
|
|
|
251
271
|
|
|
252
272
|
.bd-installoptions-copy--prompt {
|
|
253
273
|
top: var(--spacing-12);
|
|
254
|
-
|
|
274
|
+
inset-inline-end: var(--spacing-12);
|
|
255
275
|
}
|
|
256
276
|
|
|
257
277
|
.bd-installoptions-prompt-note {
|
|
@@ -5,6 +5,7 @@ import "../link/link.js";
|
|
|
5
5
|
import "../paragraph/paragraph.js";
|
|
6
6
|
import installOptionsCSS from "./install-options.css.js";
|
|
7
7
|
import { ensembleCSS } from "../shared/ensemble.css.js";
|
|
8
|
+
import { Announcer } from "../shared/announcer.js";
|
|
8
9
|
|
|
9
10
|
class BdInstallOptions extends LitElement {
|
|
10
11
|
static properties = {
|
|
@@ -31,20 +32,36 @@ class BdInstallOptions extends LitElement {
|
|
|
31
32
|
this.cards = [];
|
|
32
33
|
this.promptPanel = false;
|
|
33
34
|
this.promptLabel = "";
|
|
35
|
+
/* "Copied" is said, not only shown. The button's own text changes too,
|
|
36
|
+
but a screen reader does not reliably read a focused button's new name,
|
|
37
|
+
so the message goes through the live region (shared/announcer.js). */
|
|
38
|
+
this._announcer = new Announcer(this);
|
|
34
39
|
}
|
|
35
40
|
|
|
41
|
+
/* The button says "Copied" for 1.5s and ignores presses meanwhile. It is not
|
|
42
|
+
disabled for it: disabling the focused button threw keyboard focus back to
|
|
43
|
+
the top of the page, mid-card.
|
|
44
|
+
|
|
45
|
+
The flag is data-copied, present or absent: its value is "", which reads
|
|
46
|
+
as false, so asking for its value let a second press through, and that
|
|
47
|
+
press took "Copied" as the text to restore. It is set before the
|
|
48
|
+
clipboard is awaited, so two presses in quick succession cannot both
|
|
49
|
+
start a copy. */
|
|
36
50
|
async _copy(text, btn) {
|
|
51
|
+
if ("copied" in btn.dataset) return;
|
|
52
|
+
btn.dataset.copied = "";
|
|
37
53
|
try {
|
|
38
54
|
await navigator.clipboard.writeText(text);
|
|
39
55
|
const original = btn.textContent;
|
|
40
56
|
btn.textContent = "Copied";
|
|
41
|
-
|
|
57
|
+
this._announcer.say("Copied");
|
|
42
58
|
setTimeout(() => {
|
|
43
59
|
btn.textContent = original;
|
|
44
|
-
btn.
|
|
60
|
+
delete btn.dataset.copied;
|
|
45
61
|
}, 1500);
|
|
46
62
|
} catch {
|
|
47
63
|
// clipboard permission denied or unavailable — button stays as "Copy"
|
|
64
|
+
delete btn.dataset.copied;
|
|
48
65
|
}
|
|
49
66
|
}
|
|
50
67
|
|
|
@@ -80,18 +97,22 @@ class BdInstallOptions extends LitElement {
|
|
|
80
97
|
`;
|
|
81
98
|
}
|
|
82
99
|
|
|
83
|
-
|
|
100
|
+
/* Every card's button says "Copy", so each is described by its card's
|
|
101
|
+
title: a screen reader reading the buttons on their own hears which
|
|
102
|
+
command each one copies. */
|
|
103
|
+
_renderCard(card, index) {
|
|
104
|
+
const titleId = `bd-installoptions-card-title-${index}`;
|
|
84
105
|
return html`
|
|
85
106
|
<div class="bd-installoptions-card">
|
|
86
107
|
<div class="bd-installoptions-card-head">
|
|
87
|
-
<bd-h as="h3" class="bd-installoptions-card-title">${card.title}</bd-h>
|
|
108
|
+
<bd-h as="h3" id=${titleId} class="bd-installoptions-card-title">${card.title}</bd-h>
|
|
88
109
|
${card.badge
|
|
89
110
|
? html`<span class="bd-installoptions-badge">${card.badge}</span>`
|
|
90
111
|
: nothing}
|
|
91
112
|
</div>
|
|
92
113
|
|
|
93
114
|
${card.description
|
|
94
|
-
? html`<bd-p
|
|
115
|
+
? html`<bd-p variant="small" class="bd-installoptions-card-description">${card.description}</bd-p>`
|
|
95
116
|
: nothing}
|
|
96
117
|
|
|
97
118
|
${card.code
|
|
@@ -101,6 +122,7 @@ class BdInstallOptions extends LitElement {
|
|
|
101
122
|
<button
|
|
102
123
|
type="button"
|
|
103
124
|
class="bd-installoptions-copy"
|
|
125
|
+
aria-describedby=${titleId}
|
|
104
126
|
@click=${(e) => this._copy(card.code, e.currentTarget)}
|
|
105
127
|
>Copy</button>
|
|
106
128
|
</div>
|
|
@@ -109,7 +131,7 @@ class BdInstallOptions extends LitElement {
|
|
|
109
131
|
|
|
110
132
|
${card.linkLabel
|
|
111
133
|
? html`
|
|
112
|
-
<bd-link href=${card.linkHref || "#"}
|
|
134
|
+
<bd-link href=${card.linkHref || "#"} variant="primary" class="bd-installoptions-card-link">
|
|
113
135
|
${card.linkLabel} →
|
|
114
136
|
</bd-link>
|
|
115
137
|
`
|
|
@@ -123,7 +145,7 @@ class BdInstallOptions extends LitElement {
|
|
|
123
145
|
|
|
124
146
|
return html`
|
|
125
147
|
<div class="bd-installoptions-promptpanel">
|
|
126
|
-
<bd-h as="h2" class="bd-installoptions-prompt-title">
|
|
148
|
+
<bd-h as="h2" id="bd-installoptions-prompt-title" class="bd-installoptions-prompt-title">
|
|
127
149
|
<slot name="prompt-title"></slot>
|
|
128
150
|
</bd-h>
|
|
129
151
|
|
|
@@ -142,6 +164,7 @@ class BdInstallOptions extends LitElement {
|
|
|
142
164
|
<button
|
|
143
165
|
type="button"
|
|
144
166
|
class="bd-installoptions-copy bd-installoptions-copy--prompt"
|
|
167
|
+
aria-describedby="bd-installoptions-prompt-title"
|
|
145
168
|
@click=${(e) => this._copyPromptSlot(e.currentTarget)}
|
|
146
169
|
>Copy</button>
|
|
147
170
|
</div>
|
|
@@ -187,13 +210,14 @@ class BdInstallOptions extends LitElement {
|
|
|
187
210
|
${this.cards.length
|
|
188
211
|
? html`
|
|
189
212
|
<div class="bd-installoptions-grid">
|
|
190
|
-
${this.cards.map((card) => this._renderCard(card))}
|
|
213
|
+
${this.cards.map((card, index) => this._renderCard(card, index))}
|
|
191
214
|
</div>
|
|
192
215
|
`
|
|
193
216
|
: nothing}
|
|
194
217
|
|
|
195
218
|
${this._renderPromptPanel()}
|
|
196
219
|
</div>
|
|
220
|
+
<span class="bd-installoptions-status" role="status">${this._announcer.status}</span>
|
|
197
221
|
</div>
|
|
198
222
|
`;
|
|
199
223
|
}
|