@repobit/dex-system-design 2.5.1 → 2.7.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.
Files changed (175) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +2 -1
  3. package/package.json +14 -27
  4. package/schemas/component-manifest.json +233 -33
  5. package/schemas/manifest-omissions.json +23 -0
  6. package/src/components/accordion/accordion-bg.css.js +39 -30
  7. package/src/components/accordion/accordion-bg.js +17 -28
  8. package/src/components/accordion/accordion-bg.stories.js +5 -0
  9. package/src/components/accordion/accordion-panel.js +24 -0
  10. package/src/components/accordion/accordion.css.js +105 -111
  11. package/src/components/accordion/accordion.js +23 -37
  12. package/src/components/accordion/accordion.stories.js +5 -1
  13. package/src/components/anchor/anchor-nav.css.js +131 -53
  14. package/src/components/anchor/anchor-nav.js +276 -201
  15. package/src/components/annotation/annotation.css.js +7 -4
  16. package/src/components/architecture.stories.js +8 -7
  17. package/src/components/audience-card/audience-card.css.js +30 -4
  18. package/src/components/audience-card/audience-card.js +8 -13
  19. package/src/components/awards/awards-flex.css.js +23 -6
  20. package/src/components/awards/awards-flex.js +21 -6
  21. package/src/components/awards/awards-spotlight.css.js +25 -5
  22. package/src/components/awards/awards-spotlight.js +19 -7
  23. package/src/components/awards/awards.css.js +20 -8
  24. package/src/components/awards/awards.js +30 -91
  25. package/src/components/awards/awards.stories.js +5 -5
  26. package/src/components/awards/scroll-slides.js +128 -0
  27. package/src/components/back/back.css.js +2 -0
  28. package/src/components/badge/badge.css.js +15 -0
  29. package/src/components/bento-grid/bento-grid.css.js +105 -11
  30. package/src/components/bento-grid/bento-grid.js +37 -124
  31. package/src/components/bento-grid/bento-grid.stories.js +3 -2
  32. package/src/components/bento-grid/bento-item.css.js +71 -32
  33. package/src/components/bento-grid/bento-item.js +1 -30
  34. package/src/components/blockquote/blockquote.css.js +2 -2
  35. package/src/components/breadcrumb/breadcrumb.css.js +10 -9
  36. package/src/components/breadcrumb/breadcrumb.js +35 -34
  37. package/src/components/button/button.css.js +42 -17
  38. package/src/components/button/button.js +84 -3
  39. package/src/components/button/button.stories.js +17 -0
  40. package/src/components/card-features/card-features.css.js +23 -2
  41. package/src/components/card-features/card-features.js +6 -48
  42. package/src/components/cards/card.css.js +43 -14
  43. package/src/components/cards/card.js +43 -177
  44. package/src/components/cards/card.stories.js +8 -10
  45. package/src/components/carousel/carousel.css.js +101 -70
  46. package/src/components/carousel/carousel.js +107 -71
  47. package/src/components/carousel/carousel.stories.js +18 -16
  48. package/src/components/checkbox/checkbox.css.js +26 -9
  49. package/src/components/checkbox/checkbox.js +73 -39
  50. package/src/components/checkbox/checkbox.stories.js +35 -18
  51. package/src/components/compare/compare.css.js +68 -10
  52. package/src/components/compare/compare.js +40 -103
  53. package/src/components/compare/compare.stories.js +1 -1
  54. package/src/components/compatibility-table/compatibility-table.css.js +70 -37
  55. package/src/components/compatibility-table/compatibility-table.js +47 -40
  56. package/src/components/compatibility-table/compatibility-table.stories.js +78 -1
  57. package/src/components/display/display.css.js +7 -0
  58. package/src/components/dropdown/dropdown.css.js +20 -3
  59. package/src/components/dropdown/dropdown.js +57 -21
  60. package/src/components/dropdown/dropdown.stories.js +31 -9
  61. package/src/components/features/features.css.js +56 -21
  62. package/src/components/features/features.js +7 -117
  63. package/src/components/fieldset/fieldset.stories.js +68 -0
  64. package/src/components/footer/footer-images.js +34 -0
  65. package/src/components/footer/footer-links-group.css.js +10 -10
  66. package/src/components/footer/footer-locale.js +47 -0
  67. package/src/components/footer/footer-lp.js +27 -114
  68. package/src/components/footer/footer-lp.stories.js +2 -2
  69. package/src/components/footer/footer-nav-menu.css.js +2 -2
  70. package/src/components/footer/footer-nav-menu.js +8 -3
  71. package/src/components/footer/footer.css.js +228 -197
  72. package/src/components/footer/footer.js +109 -187
  73. package/src/components/footer/footer.stories.js +14 -4
  74. package/src/components/grid/grid.css.js +56 -20
  75. package/src/components/grid/grid.js +20 -15
  76. package/src/components/grid/grid.stories.js +39 -11
  77. package/src/components/header/header-code.css.js +20 -11
  78. package/src/components/header/header-code.js +1 -1
  79. package/src/components/header/header.css.js +20 -14
  80. package/src/components/header/header.js +6 -7
  81. package/src/components/header/header.stories.js +29 -24
  82. package/src/components/heading/heading.css.js +11 -0
  83. package/src/components/hero/hero.js +10 -2
  84. package/src/components/highlight/highlight.css.js +30 -6
  85. package/src/components/icons/arrow-icon.js +4 -1
  86. package/src/components/icons/arrow-right-icon.js +5 -1
  87. package/src/components/icons/icon-element.js +18 -0
  88. package/src/components/image/image.js +29 -9
  89. package/src/components/image/image.stories.js +38 -2
  90. package/src/components/input/custom-form.stories.js +38 -7
  91. package/src/components/input/input-clipboard.css.js +15 -1
  92. package/src/components/input/input-clipboard.js +84 -21
  93. package/src/components/input/input.js +27 -7
  94. package/src/components/install-options/install-options.css.js +26 -6
  95. package/src/components/install-options/install-options.js +32 -8
  96. package/src/components/label/label.css.js +1 -1
  97. package/src/components/light-carousel/light-carousel.css.js +100 -48
  98. package/src/components/light-carousel/light-carousel.js +43 -5
  99. package/src/components/link/link.css.js +15 -15
  100. package/src/components/link/link.js +17 -1
  101. package/src/components/link/link.stories.js +20 -7
  102. package/src/components/list/list.css.js +3 -3
  103. package/src/components/logo-marquee/logo-marquee.css.js +12 -1
  104. package/src/components/logo-marquee/logo-marquee.js +33 -8
  105. package/src/components/logo-marquee/logo-marquee.stories.js +10 -4
  106. package/src/components/modal/modal.css.js +74 -40
  107. package/src/components/modal/modal.js +85 -74
  108. package/src/components/modal/modal.stories.js +27 -14
  109. package/src/components/motion-art/motion-art.js +67 -1
  110. package/src/components/page-switcher/page-switcher.css.js +27 -9
  111. package/src/components/page-switcher/page-switcher.js +11 -8
  112. package/src/components/partner-banner/partner-banner.css.js +2 -0
  113. package/src/components/picture/picture.css.js +4 -4
  114. package/src/components/picture/picture.js +13 -3
  115. package/src/components/picture/picture.stories.js +28 -2
  116. package/src/components/post-card/post-card.css.js +18 -3
  117. package/src/components/pricing-cards/adopt-styles.js +16 -0
  118. package/src/components/pricing-cards/new-pricing-card.js +2 -4
  119. package/src/components/pricing-cards/new-pricing-card.stories.js +20 -22
  120. package/src/components/pricing-cards/pricing-card-actions.css.js +8 -12
  121. package/src/components/pricing-cards/pricing-card-actions.js +26 -13
  122. package/src/components/pricing-cards/pricing-card-container.css.js +4 -3
  123. package/src/components/pricing-cards/pricing-card-container.js +10 -4
  124. package/src/components/pricing-cards/pricing-card-header.css.js +5 -4
  125. package/src/components/pricing-cards/pricing-card-header.js +18 -31
  126. package/src/components/pricing-cards/pricing-card-pricing.css.js +84 -61
  127. package/src/components/pricing-cards/pricing-card-pricing.js +38 -24
  128. package/src/components/pricing-cards/pricing-card-show-more.js +8 -3
  129. package/src/components/pricing-cards/pricing-card.css.js +75 -41
  130. package/src/components/pricing-cards/pricing-card.js +356 -308
  131. package/src/components/progress/progress.css.js +58 -13
  132. package/src/components/progress/progress.js +13 -10
  133. package/src/components/progress/progress.stories.js +9 -7
  134. package/src/components/radio/radio-group.css.js +42 -0
  135. package/src/components/radio/radio-group.js +89 -0
  136. package/src/components/radio/radio.css.js +63 -6
  137. package/src/components/radio/radio.js +173 -140
  138. package/src/components/radio/radio.stories.js +99 -44
  139. package/src/components/radio/toggle-radio.js +44 -0
  140. package/src/components/review/review-grid.css.js +5 -1
  141. package/src/components/review/review-grid.js +2 -0
  142. package/src/components/review/review.js +13 -0
  143. package/src/components/shared/announcer.js +37 -0
  144. package/src/components/shared/fill-width.css.js +29 -0
  145. package/src/components/shared/form-control.js +194 -0
  146. package/src/components/shared/form-field.css.js +31 -3
  147. package/src/components/shared/token-scales.js +75 -26
  148. package/src/components/spotlight-section/spotlight-section.js +2 -2
  149. package/src/components/stat/stat-highlight.js +1 -1
  150. package/src/components/stat/stat.css.js +18 -3
  151. package/src/components/switch/switch.css.js +58 -5
  152. package/src/components/switch/switch.js +53 -5
  153. package/src/components/switch/switch.stories.js +30 -8
  154. package/src/components/tab-list/tab-list.css.js +51 -13
  155. package/src/components/tab-list/tab-list.js +7 -2
  156. package/src/components/tab-list/tab-list.stories.js +2 -2
  157. package/src/components/tabs/tabs.css.js +18 -1
  158. package/src/components/tabs/tabs.js +119 -41
  159. package/src/components/terminal/terminal-message.css.js +6 -1
  160. package/src/components/termsOfUse/terms.css.js +4 -2
  161. package/src/components/textarea/textarea.js +22 -7
  162. package/src/components/textarea/textarea.stories.js +12 -9
  163. package/src/components/trust-panel/trust-panel.css.js +13 -3
  164. package/src/components/ultimate-security-demo.stories.js +5 -5
  165. package/src/components/video/video.css.js +5 -0
  166. package/src/components/video/video.js +5 -0
  167. package/src/components/video/video.stories.js +12 -0
  168. package/src/components/video-player/video-player.css.js +20 -8
  169. package/src/components/video-player/video-player.js +74 -20
  170. package/src/components/video-player/video-player.stories.js +17 -3
  171. package/src/tokens/brands.stories.js +1 -1
  172. package/src/tokens/themes/index.js +2 -2
  173. package/src/tokens/typography.stories.js +4 -3
  174. package/src/vendor/motion-art/README.md +4 -1
  175. package/src/components/footer/footer-lp.css.js +0 -159
@@ -13,23 +13,31 @@ const SHADOWS = ['none', 'sm', 'md', 'lg', 'xl'];
13
13
 
14
14
  export class BdImg extends LitElement {
15
15
  static properties = {
16
- src : { type: String },
17
- alt : { type: String },
18
- width : { type: Number },
19
- height : { type: Number },
20
- loading: { type: String },
21
- fit : { type: String },
22
- radius : { type: String },
23
- shadow : { type: String }
16
+ src : { type: String },
17
+ srcset : { type: String },
18
+ sizes : { type: String },
19
+ alt : { type: String },
20
+ width : { type: Number },
21
+ height : { type: Number },
22
+ loading : { type: String },
23
+ fetchPriority: { type: String, attribute: 'fetchpriority' },
24
+ decoding : { type: String },
25
+ fit : { type: String },
26
+ radius : { type: String },
27
+ shadow : { type: String }
24
28
  };
25
29
 
26
30
  constructor() {
27
31
  super();
28
32
  this.src = "";
33
+ this.srcset = "";
34
+ this.sizes = "";
29
35
  this.alt = "";
30
36
  this.width = null;
31
37
  this.height = null;
32
38
  this.loading = "lazy";
39
+ this.fetchPriority = "";
40
+ this.decoding = "";
33
41
  this.fit = "cover";
34
42
  this.radius = "none";
35
43
  this.shadow = "none";
@@ -44,13 +52,25 @@ export class BdImg extends LitElement {
44
52
 
45
53
  const finalClass = `${baseClass} ${fitClass} ${radiusClass} ${shadowClass}`;
46
54
 
55
+ /* fetchpriority="high" marks the image the page is waiting for -- its
56
+ Largest Contentful Paint -- so it is never lazy as well: a lazy image is
57
+ held back until layout puts it near the viewport, which is the very
58
+ delay the priority is there to remove. lazy stays the default for every
59
+ other image. No guard: fetchpriority and decoding are hints, and a
60
+ browser that does not know them loads the image as it always has. */
61
+ const lcp = this.fetchPriority === 'high';
62
+
47
63
  return html`
48
64
  <img
49
65
  src="${this.src}"
66
+ srcset="${this.srcset || nothing}"
67
+ sizes="${this.sizes || nothing}"
50
68
  alt="${this.alt}"
51
69
  width="${this.width ?? nothing}"
52
70
  height="${this.height ?? nothing}"
53
- loading="${this.loading}"
71
+ loading="${lcp ? nothing : this.loading}"
72
+ fetchpriority="${this.fetchPriority || nothing}"
73
+ decoding="${this.decoding || nothing}"
54
74
  class="${finalClass}"
55
75
  @load="${this._handleLoad}"
56
76
  @error="${this._handleError}"
@@ -1,4 +1,4 @@
1
- import { html } from 'lit';
1
+ import { html, nothing } from 'lit';
2
2
  import './image.js';
3
3
 
4
4
  export default {
@@ -24,6 +24,10 @@ export default {
24
24
  ></bd-img>
25
25
  \`\`\`
26
26
 
27
+ The image a page is waiting for -- a hero, its Largest Contentful Paint --
28
+ takes \`fetchpriority="high"\`, which also stops it being lazy. \`srcset\` and
29
+ \`sizes\` pass straight to the \`<img>\`.
30
+
27
31
  ### CSS Classes Applied
28
32
  | Prop | Class Pattern |
29
33
  |---|---|
@@ -44,6 +48,16 @@ export default {
44
48
  description: 'Image source URL',
45
49
  table : { type: { summary: 'string' }, defaultValue: { summary: '' }, category: 'Content' }
46
50
  },
51
+ srcset: {
52
+ control : 'text',
53
+ description: 'Candidate sources for the `<img>`, as in HTML',
54
+ table : { type: { summary: 'string' }, defaultValue: { summary: '' }, category: 'Content' }
55
+ },
56
+ sizes: {
57
+ control : 'text',
58
+ description: 'The rendered width for each condition, so the browser can pick from `srcset`',
59
+ table : { type: { summary: 'string' }, defaultValue: { summary: '' }, category: 'Content' }
60
+ },
47
61
  alt: {
48
62
  control : 'text',
49
63
  description: 'Alt text for accessibility',
@@ -65,6 +79,18 @@ export default {
65
79
  description: 'Native browser loading strategy',
66
80
  table : { type: { summary: "'lazy' | 'eager'" }, defaultValue: { summary: 'lazy' }, category: 'Performance' }
67
81
  },
82
+ fetchpriority: {
83
+ control : { type: 'select' },
84
+ options : [undefined, 'high', 'low'],
85
+ description: '`high` for the image the page is waiting for (its Largest Contentful Paint) -- never lazy then; `low` for one that is above the fold but hidden at first. Leave it unset otherwise.',
86
+ table : { type: { summary: "'high' | 'low'" }, defaultValue: { summary: 'unset' }, category: 'Performance' }
87
+ },
88
+ decoding: {
89
+ control : { type: 'select' },
90
+ options : [undefined, 'async', 'sync'],
91
+ description: 'Decoding hint for the browser',
92
+ table : { type: { summary: "'async' | 'sync' | 'auto'" }, defaultValue: { summary: 'unset' }, category: 'Performance' }
93
+ },
68
94
  fit: {
69
95
  control : { type: 'select' },
70
96
  options : ['cover', 'contain', 'fill', 'none', 'scale-down'],
@@ -86,7 +112,7 @@ export default {
86
112
  }
87
113
  };
88
114
 
89
- const sampleSrc = 'https://via.placeholder.com/800x450';
115
+ const sampleSrc = '/assets/bd-header-img.jpg';
90
116
  const defaultArgs = { src: sampleSrc, alt: 'Sample image', width: 800, height: 450, loading: 'lazy', fit: 'cover', radius: 'none', shadow: 'none' };
91
117
 
92
118
  const render = (args) => html`
@@ -96,6 +122,8 @@ const render = (args) => html`
96
122
  width="${args.width}"
97
123
  height="${args.height}"
98
124
  loading="${args.loading}"
125
+ fetchpriority="${args.fetchpriority || nothing}"
126
+ decoding="${args.decoding || nothing}"
99
127
  fit="${args.fit}"
100
128
  radius="${args.radius}"
101
129
  shadow="${args.shadow}"
@@ -171,6 +199,14 @@ export const EagerLoading = {
171
199
  parameters: { docs: { description: { story: '`loading="eager"` — image loads immediately regardless of viewport position.' } } }
172
200
  };
173
201
 
202
+ export const HighPriority = {
203
+ name : 'High Priority (LCP)',
204
+ render: () => html`
205
+ <bd-img src="${sampleSrc}" alt="Product screenshot" width="800" height="450" fetchpriority="high"></bd-img>
206
+ `,
207
+ parameters: { docs: { description: { story: '`fetchpriority="high"` -- the image the page is waiting for, such as a hero. It is never lazy: the `<img>` renders without `loading`, so it is requested as soon as it is parsed.' } } }
208
+ };
209
+
174
210
  export const RoundedWithShadow = {
175
211
  name : 'Rounded + Shadow',
176
212
  render: () => html`
@@ -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\` | Failed validation — red border + helper text |
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
- The element is **not** form-associated: the \`<input>\` lives in a shadow root,
82
- so a \`<form>\` containing it yields no \`FormData\` entry. \`name\` is carried on
83
- the events for your own use.
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
- | \`inputmode\`, \`autocomplete\`, \`enterkeyhint\` | yes | **no** | **no** |
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: 'Applies the error / invalid styling — red border, warning icon, helper text',
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
- right: var(--spacing-8);
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
- class CustomInputClipboard extends LitElement {
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 : { type: String },
11
- type : { type: String },
12
- size : { type: String, reflect: true },
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 : { type: String },
15
- placeholder: { type: String },
16
- required : { type: Boolean },
17
- focused : { type: Boolean, reflect: true },
18
- tooltip : { type: String },
19
- invalid : { type: Boolean },
20
- validated : { type: Boolean, reflect: true },
21
- disabled : { type: Boolean, reflect: true },
22
- value : { type: String },
23
- /** Carried on the event detail, as on bd-custom-input. */
24
- name : { type: String }
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 inputStateClass = this.disabled
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
- <input
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="${this.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="${this.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 : { type: String },
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 inputStateClass = this.disabled
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
- <input
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="${this.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
- word-break: break-word;
161
- padding-right: var(--spacing-56);
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
- right: var(--spacing-12);
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
- outline: none;
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-right: var(--spacing-64);
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
- right: var(--spacing-12);
274
+ inset-inline-end: var(--spacing-12);
255
275
  }
256
276
 
257
277
  .bd-installoptions-prompt-note {