@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.
Files changed (173) 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 +226 -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 +3 -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 +238 -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 +64 -5
  75. package/src/components/header/header-code.css.js +20 -11
  76. package/src/components/header/header-code.js +1 -1
  77. package/src/components/header/header.css.js +20 -14
  78. package/src/components/header/header.js +6 -7
  79. package/src/components/header/header.stories.js +29 -24
  80. package/src/components/heading/heading.css.js +11 -0
  81. package/src/components/hero/hero.js +10 -2
  82. package/src/components/highlight/highlight.css.js +30 -6
  83. package/src/components/icons/arrow-icon.js +4 -1
  84. package/src/components/icons/arrow-right-icon.js +5 -1
  85. package/src/components/icons/icon-element.js +18 -0
  86. package/src/components/image/image.js +29 -9
  87. package/src/components/image/image.stories.js +38 -2
  88. package/src/components/input/custom-form.stories.js +38 -7
  89. package/src/components/input/input-clipboard.css.js +15 -1
  90. package/src/components/input/input-clipboard.js +84 -21
  91. package/src/components/input/input.js +27 -7
  92. package/src/components/install-options/install-options.css.js +26 -6
  93. package/src/components/install-options/install-options.js +32 -8
  94. package/src/components/label/label.css.js +1 -1
  95. package/src/components/light-carousel/light-carousel.css.js +100 -48
  96. package/src/components/light-carousel/light-carousel.js +43 -5
  97. package/src/components/link/link.css.js +15 -15
  98. package/src/components/link/link.js +17 -1
  99. package/src/components/link/link.stories.js +20 -7
  100. package/src/components/list/list.css.js +3 -3
  101. package/src/components/logo-marquee/logo-marquee.css.js +12 -1
  102. package/src/components/logo-marquee/logo-marquee.js +33 -8
  103. package/src/components/logo-marquee/logo-marquee.stories.js +10 -4
  104. package/src/components/modal/modal.css.js +74 -40
  105. package/src/components/modal/modal.js +85 -74
  106. package/src/components/modal/modal.stories.js +27 -14
  107. package/src/components/motion-art/motion-art.js +67 -1
  108. package/src/components/page-switcher/page-switcher.css.js +27 -9
  109. package/src/components/page-switcher/page-switcher.js +11 -8
  110. package/src/components/partner-banner/partner-banner.css.js +2 -0
  111. package/src/components/picture/picture.css.js +4 -4
  112. package/src/components/picture/picture.js +13 -3
  113. package/src/components/picture/picture.stories.js +28 -2
  114. package/src/components/post-card/post-card.css.js +18 -3
  115. package/src/components/pricing-cards/adopt-styles.js +16 -0
  116. package/src/components/pricing-cards/new-pricing-card.js +2 -4
  117. package/src/components/pricing-cards/new-pricing-card.stories.js +20 -22
  118. package/src/components/pricing-cards/pricing-card-actions.css.js +8 -12
  119. package/src/components/pricing-cards/pricing-card-actions.js +26 -13
  120. package/src/components/pricing-cards/pricing-card-container.css.js +4 -3
  121. package/src/components/pricing-cards/pricing-card-container.js +10 -4
  122. package/src/components/pricing-cards/pricing-card-header.css.js +5 -4
  123. package/src/components/pricing-cards/pricing-card-header.js +18 -31
  124. package/src/components/pricing-cards/pricing-card-pricing.css.js +84 -61
  125. package/src/components/pricing-cards/pricing-card-pricing.js +38 -24
  126. package/src/components/pricing-cards/pricing-card-show-more.js +8 -3
  127. package/src/components/pricing-cards/pricing-card.css.js +75 -41
  128. package/src/components/pricing-cards/pricing-card.js +356 -308
  129. package/src/components/progress/progress.css.js +58 -13
  130. package/src/components/progress/progress.js +13 -10
  131. package/src/components/progress/progress.stories.js +9 -7
  132. package/src/components/radio/radio-group.css.js +42 -0
  133. package/src/components/radio/radio-group.js +89 -0
  134. package/src/components/radio/radio.css.js +63 -6
  135. package/src/components/radio/radio.js +173 -140
  136. package/src/components/radio/radio.stories.js +99 -44
  137. package/src/components/radio/toggle-radio.js +44 -0
  138. package/src/components/review/review-grid.css.js +5 -1
  139. package/src/components/review/review-grid.js +2 -0
  140. package/src/components/review/review.js +13 -0
  141. package/src/components/shared/announcer.js +37 -0
  142. package/src/components/shared/fill-width.css.js +33 -0
  143. package/src/components/shared/form-control.js +194 -0
  144. package/src/components/shared/form-field.css.js +31 -3
  145. package/src/components/shared/token-scales.js +75 -26
  146. package/src/components/spotlight-section/spotlight-section.js +2 -2
  147. package/src/components/stat/stat-highlight.js +1 -1
  148. package/src/components/stat/stat.css.js +18 -3
  149. package/src/components/switch/switch.css.js +58 -5
  150. package/src/components/switch/switch.js +53 -5
  151. package/src/components/switch/switch.stories.js +30 -8
  152. package/src/components/tab-list/tab-list.css.js +51 -13
  153. package/src/components/tab-list/tab-list.js +7 -2
  154. package/src/components/tab-list/tab-list.stories.js +2 -2
  155. package/src/components/tabs/tabs.css.js +18 -1
  156. package/src/components/tabs/tabs.js +119 -41
  157. package/src/components/terminal/terminal-message.css.js +6 -1
  158. package/src/components/termsOfUse/terms.css.js +4 -2
  159. package/src/components/textarea/textarea.js +22 -7
  160. package/src/components/textarea/textarea.stories.js +12 -9
  161. package/src/components/trust-panel/trust-panel.css.js +13 -3
  162. package/src/components/ultimate-security-demo.stories.js +5 -5
  163. package/src/components/video/video.css.js +5 -0
  164. package/src/components/video/video.js +5 -0
  165. package/src/components/video/video.stories.js +12 -0
  166. package/src/components/video-player/video-player.css.js +20 -8
  167. package/src/components/video-player/video-player.js +74 -20
  168. package/src/components/video-player/video-player.stories.js +17 -3
  169. package/src/tokens/brands.stories.js +1 -1
  170. package/src/tokens/themes/index.js +2 -2
  171. package/src/tokens/typography.stories.js +4 -3
  172. package/src/vendor/motion-art/README.md +4 -1
  173. package/src/components/footer/footer-lp.css.js +0 -159
@@ -54,7 +54,12 @@ bordered, rounded card. It has two variants:
54
54
  |-----------------|----------------------------------------------------------|
55
55
  | \`title\` | Overrides the \`title\` attribute if content is provided |
56
56
  | \`description\` | Overrides the \`description\` attribute if content is provided |
57
- | \`rows\` | Extra freeform rows appended after the ones from \`rows\` |
57
+ | \`rows\` | Extra content after the table, inside the card — a slotted element cannot become a row of a native table |
58
+
59
+ ### Accessibility
60
+ A native \`<table>\`: a \`<thead>\` of \`<th scope="col">\`, and each row's first
61
+ cell is its \`<th scope="row">\`. Below md the rows stack into cards, the header
62
+ row goes, and each cell shows its column's name in front of its value.
58
63
  `
59
64
  }
60
65
  }
@@ -160,6 +165,78 @@ export const OutcomeWithDescription = {
160
165
  }
161
166
  };
162
167
 
168
+ // ─── Risk and light variants ────────────────────────────────────────────────
169
+
170
+ export const Risk = {
171
+ name : "4. Risk Variant — Category / Coverage",
172
+ render: () => html`
173
+ <bd-compatibility-table
174
+ variant="risk"
175
+ .rows=${[
176
+ { category: "Prompt injection", coverage: "Inspects agent inputs and actions; returns allowed, flagged or blocked" },
177
+ { category: "Tool and MCP misuse", coverage: "Detects and blocks malicious or tampered MCP tools before invocation" },
178
+ { category: "Sensitive data exposure", coverage: "Detects credential and secret exposure before it leaves the machine" }
179
+ ]}
180
+ ></bd-compatibility-table>
181
+ `,
182
+ parameters: {
183
+ docs: {
184
+ description: {
185
+ story: "Two columns, Risk category / AI Guardian coverage, from rows of `{ category, coverage }`."
186
+ }
187
+ }
188
+ }
189
+ };
190
+
191
+ export const Light = {
192
+ name : "5. Light Variant — Label / Value",
193
+ render: () => html`
194
+ <bd-compatibility-table
195
+ variant="light"
196
+ .rows=${[
197
+ { label: "Runs as", value: "Background service on the endpoint" },
198
+ { label: "Install method", value: "Download the macOS installer (.dmg)" },
199
+ { label: "Where analysis happens", value: "On-device, with some checks using Bitdefender cloud services" },
200
+ { label: "Offline operation", value: "Some features" },
201
+ { label: "Availability", value: "Open BETA, free download" },
202
+ { label: "Price during BETA", value: "Free" }
203
+ ]}
204
+ ></bd-compatibility-table>
205
+ `,
206
+ parameters: {
207
+ docs: {
208
+ description: {
209
+ story: "No card: label / value rows from `{ label, value }`, flowed into `light-columns` columns (2 by default) with a rule under each."
210
+ }
211
+ }
212
+ }
213
+ };
214
+
215
+ export const LightBordered = {
216
+ name : "6. Light Variant — Bordered, One Column",
217
+ render: () => html`
218
+ <bd-compatibility-table
219
+ variant="light"
220
+ background="bordered"
221
+ light-columns="1"
222
+ title="Minimum"
223
+ .rows=${[
224
+ { label: "macOS", value: "13 or later" },
225
+ { label: "Processor", value: "Apple silicon" },
226
+ { label: "Memory", value: "8 GB" },
227
+ { label: "Free disk", value: "About 10 GB" }
228
+ ]}
229
+ ></bd-compatibility-table>
230
+ `,
231
+ parameters: {
232
+ docs: {
233
+ description: {
234
+ story: "`background=\"bordered\"` draws the card itself; `light-columns=\"1\"` keeps one column, as the system-requirements pair does."
235
+ }
236
+ }
237
+ }
238
+ };
239
+
163
240
  export const Playground = {
164
241
  name: "Playground",
165
242
  args: {
@@ -33,6 +33,13 @@ export default css`
33
33
  overflow-wrap: break-word;
34
34
  }
35
35
 
36
+ /* Balanced lines, as bd-h's, behind the same guard -- see the reason there. */
37
+ @supports (text-wrap: balance) {
38
+ .bd-display {
39
+ text-wrap: balance;
40
+ }
41
+ }
42
+
36
43
 
37
44
  /* xxxl */
38
45
  .bd-display.xxxl {
@@ -22,8 +22,6 @@ export default css`
22
22
 
23
23
  select.form-input-bd {
24
24
  appearance: none;
25
- -webkit-appearance: none;
26
- -moz-appearance: none;
27
25
  cursor: pointer;
28
26
  /* Clearance for the chevron: its own width plus the gap on either side.
29
27
  This used to be a padding-right on a bare select type selector, which the
@@ -71,7 +69,7 @@ export default css`
71
69
  color: var(--color-text-muted);
72
70
  position: absolute;
73
71
  top: 50%;
74
- right: var(--spacing-12);
72
+ inset-inline-end: var(--spacing-12);
75
73
  transform: translateY(-50%);
76
74
  pointer-events: none;
77
75
  /* normal, not fast: bd-anchor-nav's chevron turns on the same gesture and
@@ -98,6 +96,25 @@ export default css`
98
96
  }
99
97
  }
100
98
 
99
+ /* The placeholder option, while it is the choice, takes the placeholder ink
100
+ an empty input shows -- and, as there, the next step up on a tinted
101
+ field, where text-subtle falls under 4.5:1 (form-field.css.js has the
102
+ measurements). :enabled, so a disabled field keeps the disabled ink. */
103
+ select.form-input--placeholder:enabled {
104
+ color: var(--color-text-subtle);
105
+ }
106
+
107
+ select.form-input--placeholder:enabled:is(.form-input--error, .form-input--success, :user-invalid, .form-input--attempted:invalid) {
108
+ color: var(--color-text-muted);
109
+ }
110
+
111
+ /* The options keep the field's ink. Where the picker is drawn by the page
112
+ rather than the OS, an option inherits the select's colour, and would
113
+ otherwise list every choice in the placeholder's grey. */
114
+ select.form-input-bd option {
115
+ color: var(--form-input-default-color);
116
+ }
117
+
101
118
  /* The chevron is part of the control, so it greys with it. */
102
119
  .select-wrap:has(.form-input--disabled) .select-caret {
103
120
  color: var(--form-input-disabled-color);
@@ -1,10 +1,12 @@
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 "../icons/arrow-down-icon.js";
5
6
  import { formFieldCSS } from "../shared/form-field.css.js";
6
7
  import dropdownCSS from "../dropdown/dropdown.css.js";
7
8
  import { resolveSize } from '../shared/prop-vocabulary.js';
9
+ import { ValueControl, omitEmpty } from "../shared/form-control.js";
8
10
 
9
11
 
10
12
  /* options is a JSON array, as a property or as an attribute. Anything else --
@@ -23,28 +25,41 @@ const toOptions = value => {
23
25
  }
24
26
  };
25
27
 
26
- class CustomDropdown extends LitElement {
28
+ class CustomDropdown extends ValueControl(LitElement) {
27
29
  static properties = {
28
- label : { type: String },
29
- options : { converter: { fromAttribute: toOptions } },
30
- size : { type: String, reflect: true },
30
+ label : { type: String },
31
+ options : { converter: { fromAttribute: toOptions } },
32
+ size : { type: String, reflect: true },
31
33
  /** @deprecated pass `size`. It named the size, not the kind. */
32
- kind : { type: String },
33
- required : { type: Boolean },
34
- tooltip : { type: String },
35
- invalid : { type: Boolean },
36
- validated: { type: Boolean },
37
- disabled : { type: Boolean },
34
+ kind : { type: String },
35
+ required : { type: Boolean },
36
+ tooltip : { type: String },
37
+ invalid : { type: Boolean },
38
+ validated : { type: Boolean },
39
+ /* Reflected, as on the other fields: a form-associated element is left
40
+ out of a submit by its disabled ATTRIBUTE, so a disabled set as a
41
+ property has to reach it. */
42
+ disabled : { type: Boolean, reflect: true },
38
43
  /* The chosen option, and what the events carry, so a form handler written
39
44
  for bd-custom-input reads this one unchanged. It always names an option
40
- that exists: unset, or set to one that is not there, it is the first. */
41
- value : { type: String },
42
- /** Carried on the event detail, as on bd-custom-input. */
43
- name : { type: String },
45
+ that exists: unset, or set to one that is not there, it is the first --
46
+ or the placeholder, when there is one. The value attribute is the
47
+ default a form reset returns to. */
48
+ value : { type: String },
49
+ /* The name it submits under in a form, carried on the event detail too,
50
+ as on bd-custom-input; reflected, because a form reads it off the
51
+ element. */
52
+ name : { type: String, reflect: true, converter: omitEmpty },
53
+ /* A first option with no value, standing for "nothing chosen yet". It is
54
+ what makes `required` mean anything here: a select is missing a value
55
+ only while that option is the chosen one. Without it the first real
56
+ option is chosen from the start, as before, and required can never
57
+ fail. */
58
+ placeholder: { type: String },
44
59
  /* Whether the native picker is showing. A best effort, not a fact: a
45
60
  <select> renders its popup in the OS, so the page is never told when it
46
61
  opens or closes. See _onSelectMouseDown. */
47
- _open : { type: Boolean, state: true }
62
+ _open : { type: Boolean, state: true }
48
63
  };
49
64
 
50
65
  constructor() {
@@ -61,9 +76,23 @@ class CustomDropdown extends LitElement {
61
76
  this.disabled = false;
62
77
  this.value = "";
63
78
  this.name = "";
79
+ this.placeholder = "";
64
80
  this._open = false;
65
81
  }
66
82
 
83
+ get _control() {
84
+ return this.renderRoot?.querySelector?.("select");
85
+ }
86
+
87
+ /** The values the select can hold, in order: the placeholder's, then the options'. */
88
+ get _values() {
89
+ return [...(this.placeholder ? [""] : []), ...this.options.map(String)];
90
+ }
91
+
92
+ /* Reset is ValueControl's: the value attribute, which willUpdate settles
93
+ on the first value when it is missing or unknown, as a native select's
94
+ reset does. */
95
+
67
96
  /* WHY THIS IS APPROXIMATED RATHER THAN OBSERVED.
68
97
  A native select's picker is drawn by the operating system, so there is no
69
98
  event for "opened" and no state to read. Chrome 152 does support
@@ -132,7 +161,8 @@ class CustomDropdown extends LitElement {
132
161
  // so it moved; see shared/prop-vocabulary.js
133
162
  if (changed.has("kind") && this.kind) this.size = this.kind;
134
163
  if (changed.has("size") || changed.has("kind")) this.size = resolveSize(this.size);
135
- if (!this.options.map(String).includes(this.value)) this.value = this.options.length ? String(this.options[0]) : "";
164
+ const values = this._values;
165
+ if (!values.includes(this.value)) this.value = values[0] ?? "";
136
166
  }
137
167
 
138
168
  /* The select is told its value after its options exist. A binding on the
@@ -142,6 +172,7 @@ class CustomDropdown extends LitElement {
142
172
  updated() {
143
173
  const select = this.shadowRoot.querySelector("select");
144
174
  if (select && select.value !== this.value) select.value = this.value;
175
+ this._sync();
145
176
  }
146
177
 
147
178
  /* WHY TWO EVENTS FOR ONE CHOICE.
@@ -159,6 +190,7 @@ class CustomDropdown extends LitElement {
159
190
  _onChange(e) {
160
191
  this._closePicker();
161
192
  this.value = e.target.value;
193
+ this._sync();
162
194
  const detail = { value: this.value, name: this.name };
163
195
  for (const type of ["bd-input", "bd-change"]) {
164
196
  this.dispatchEvent(new CustomEvent(type, { detail, bubbles: true, composed: true }));
@@ -178,7 +210,8 @@ class CustomDropdown extends LitElement {
178
210
  lg: "label-lg"
179
211
  }[this.size];
180
212
 
181
- const inputStateClass = this.disabled
213
+ const disabled = this.disabled || this._formDisabled;
214
+ const inputStateClass = disabled
182
215
  ? "form-input--disabled"
183
216
  : this.invalid
184
217
  ? "form-input--error"
@@ -207,11 +240,11 @@ class CustomDropdown extends LitElement {
207
240
  </label>`
208
241
  : nothing}
209
242
  <div class="select-wrap">
210
- <select
243
+ ${keyed(this._resets, html`<select
211
244
  id="custom-dropdown"
212
- class="form-input-bd ${inputClass} ${inputStateClass}"
245
+ class="form-input-bd ${inputClass} ${inputStateClass} ${this._attempted ? "form-input--attempted" : ""} ${this.placeholder && this.value === "" ? "form-input--placeholder" : ""}"
213
246
  ?required="${this.required}"
214
- ?disabled="${this.disabled}"
247
+ ?disabled="${disabled}"
215
248
  aria-invalid="${this.invalid ? "true" : nothing}"
216
249
  aria-describedby="${this.tooltip ? "custom-dropdown-help" : nothing}"
217
250
  @mousedown="${this._onSelectMouseDown}"
@@ -220,12 +253,15 @@ class CustomDropdown extends LitElement {
220
253
  @change="${this._onChange}"
221
254
  @blur="${this._closePicker}"
222
255
  >
256
+ ${this.placeholder
257
+ ? html`<option value="" ?selected="${this.value === ""}">${this.placeholder}</option>`
258
+ : nothing}
223
259
  ${this.options.map(
224
260
  option => html`<option value="${option}" ?selected="${String(option) === this.value}">
225
261
  ${option}
226
262
  </option>`
227
263
  )}
228
- </select>
264
+ </select>`)}
229
265
  <bd-arrow-down-icon
230
266
  size="sm"
231
267
  class="select-caret ${this._open ? "select-caret--open" : ""}"
@@ -49,7 +49,8 @@ descender.
49
49
 
50
50
  ### Notes
51
51
  - Options can be passed as an Array or a JSON string
52
- - First option is auto-selected by default
52
+ - First option is auto-selected by default — or, with \`placeholder\`, a first
53
+ option with no value that stands for "nothing chosen yet"
53
54
  - Tooltip/help text is only rendered when \`tooltip\` prop is non-empty
54
55
  - This component is documented in **two** places: here, and as the Dropdown
55
56
  stories under **Atoms/Input**. They are one component; the Atoms/Input page
@@ -57,7 +58,8 @@ descender.
57
58
 
58
59
  ### Value and events
59
60
  \`value\` is the chosen option — read it, or set it to choose one; unset, or
60
- set to an option that is not there, it is the first. Choosing an option fires
61
+ set to an option that is not there, it is the first (the placeholder's empty
62
+ value, when there is one). Choosing an option fires
61
63
  \`bd-input\` and then \`bd-change\`, both with \`detail\` \`{ value, name }\`,
62
64
  bubbling and composed — the same names, shape and flags as
63
65
  \`bd-custom-input\`, so one form handler reads both. A select commits on choice,
@@ -69,9 +71,24 @@ border, and \`tooltip\` is the select's description through
69
71
  \`aria-describedby\`, so the reason a field is invalid is announced, not only
70
72
  drawn — as on \`bd-custom-input\`.
71
73
 
72
- ### Known gap
73
- Being in a shadow root, the select also does not participate in an enclosing
74
- \`<form>\` — a \`<form>\` containing it yields no \`FormData\` entry.
74
+ ### In a form
75
+ \`bd-custom-dropdown\` is **form-associated**, as \`bd-custom-input\` is: a
76
+ \`<form>\` around it submits \`name=value\`, reset returns it to its \`value\`
77
+ attribute or the first choice, a \`<fieldset disabled>\` disables it, and the
78
+ select's own validity reaches the form in the browser's words.
79
+
80
+ **\`required\` needs a \`placeholder\`.** A select is missing a value only while
81
+ its empty first option is chosen; without one, the first real option is chosen
82
+ from the start and a required field can never be empty. With a placeholder the
83
+ submit is blocked until something else is chosen, and the field turns red once
84
+ touched or once a submit has been tried, as the input does.
85
+
86
+ ### The native picker stays
87
+ The field is still \`appearance: none\` over a native \`<select>\`, not the
88
+ customizable \`appearance: base-select\`. That would let the picker be styled,
89
+ but it replaces the operating system's own picker — the wheel on iOS, the
90
+ sheet on Android — with a page-drawn list, which is a design decision rather
91
+ than a form one, and it is short of Baseline Widely available. Not adopted.
75
92
  `
76
93
  }
77
94
  }
@@ -95,7 +112,7 @@ Being in a shadow root, the select also does not participate in an enclosing
95
112
  },
96
113
  required: {
97
114
  control : 'boolean',
98
- description: 'Adds a required asterisk to the label and `required` attribute to the select',
115
+ description: 'Adds a required asterisk to the label and `required` to the select. In a form, blocks the submit while the placeholder is chosen.',
99
116
  table : { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, category: 'Validation' }
100
117
  },
101
118
  invalid: {
@@ -110,9 +127,14 @@ Being in a shadow root, the select also does not participate in an enclosing
110
127
  },
111
128
  disabled: {
112
129
  control : 'boolean',
113
- description: 'Disables the select element',
130
+ description: 'Disables the select element, and leaves it out of a form submit',
114
131
  table : { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, category: 'State' }
115
132
  },
133
+ placeholder: {
134
+ control : 'text',
135
+ description: 'A first option with no value, chosen until something else is. What makes `required` able to fail.',
136
+ table : { type: { summary: 'string' }, defaultValue: { summary: '' }, category: 'Content' }
137
+ },
116
138
  tooltip: {
117
139
  control : 'text',
118
140
  description: 'Help text shown below the select. Empty string hides it.',
@@ -167,9 +189,9 @@ export const AllSizes = {
167
189
  export const Required = {
168
190
  name : 'Required',
169
191
  render: () => html`
170
- <bd-custom-dropdown label="Select a plan" .options="${defaultOptions}" size="md" required></bd-custom-dropdown>
192
+ <bd-custom-dropdown label="Plan" placeholder="Select a plan" .options="${defaultOptions.slice(1)}" size="md" required></bd-custom-dropdown>
171
193
  `,
172
- parameters: { docs: { description: { story: 'Required field — shows a `*` after the label.' } } }
194
+ parameters: { docs: { description: { story: 'Required field — shows a `*` after the label. The placeholder is chosen until something else is, and in a form the submit is blocked until then.' } } }
173
195
  };
174
196
 
175
197
  export const WithTooltip = {
@@ -1,5 +1,4 @@
1
- import { css, unsafeCSS } from "lit";
2
- import { below } from "../shared/token-scales.js";
1
+ import { css } from "lit";
3
2
 
4
3
  export default css`
5
4
  /* padding-block, not padding-top alone. This section opened with 64px above
@@ -14,6 +13,14 @@ export default css`
14
13
  applied. */
15
14
  :host {
16
15
  --bd-acc-header-margin-bottom: var(--spacing-8);
16
+ /* The section is the container that decides when the columns stack, not
17
+ the screen: across the page the two are the same width, inside
18
+ bd-tabs or any narrower column the columns stack with it. width: 100%
19
+ because a size container contributes nothing to its own intrinsic
20
+ width. */
21
+ container-type: inline-size;
22
+ width: 100%;
23
+ box-sizing: border-box;
17
24
  display: flex;
18
25
  justify-content: center;
19
26
  padding-top: var(--spacing-64);
@@ -26,23 +33,44 @@ export default css`
26
33
  other section's edge. */
27
34
  }
28
35
 
29
- /* Columns grid: its own measure -- N columns of 400 -- centred inside the column */
36
+ /* Columns grid: its own measure -- one track of up to 400 per column, as
37
+ many as there are columns -- centred inside the page column. The column
38
+ count and the N x 400 cap used to be written inline by features.js; an
39
+ auto-flowing column track says both. */
30
40
  .bd-features-container {
31
41
  margin-inline: auto;
32
42
  display: grid;
33
- gap: var(--spacing-32);
34
- width: 100%;
35
- justify-content: center;
43
+ grid-auto-flow: column;
44
+ /* no token: the column's measure, the 400 the design gives each one */
45
+ grid-auto-columns: minmax(0, 400px);
46
+ /* The rows every column shares: icon, title, description, accordion. */
47
+ grid-template-rows: repeat(4, auto);
48
+ column-gap: var(--spacing-32);
49
+ row-gap: 0;
50
+ /* as wide as its columns, and no wider than the page column */
51
+ width: fit-content;
52
+ max-width: 100%;
36
53
  }
37
54
 
38
- /* Coloana individuala */
55
+ /* Each column is a subgrid of those four rows, so a title that wraps to two
56
+ lines, or a longer description, moves the next row down in every column
57
+ at once. Each part names its row: a column without a description leaves
58
+ that row empty rather than pulling its accordion up into it. */
39
59
  .bd-col {
40
- display: flex;
41
- flex-direction: column;
42
- width: 100%;
43
- max-width: 400px;
60
+ display: grid;
61
+ grid-row: span 4;
62
+ grid-template-rows: subgrid;
63
+ align-content: start;
64
+ min-width: 0;
44
65
  }
45
66
 
67
+ .col-icon-wrapper { grid-row: 1; }
68
+ .col-title-wrapper { grid-row: 2; }
69
+ .col-description { grid-row: 3; }
70
+ /* The last part keeps its own height: the row is as tall as the longest
71
+ accordion, and a shorter one has nothing to fill it with. */
72
+ .bd-col > bd-accordion-section { grid-row: 4; align-self: start; }
73
+
46
74
  /* Icon wrapper */
47
75
  .col-icon-wrapper {
48
76
  display: flex;
@@ -70,20 +98,27 @@ export default css`
70
98
  overflow: hidden;
71
99
  }
72
100
 
73
- /* Responsive */
74
- @media ${unsafeCSS(below('lg'))} {
75
- .bd-col {
76
- max-width: 100%;
77
- }
78
- }
79
-
80
- @media (max-width: 600px) {
101
+ /* One column under another: nothing to line up across, so each column is a
102
+ plain stack again, its parts at their own heights. The !important that
103
+ stood here was beating the inline repeat(N) features.js wrote. */
104
+ @container (width <= 600px) {
81
105
  .bd-features-container {
82
- grid-template-columns: 1fr !important;
106
+ grid-auto-flow: row;
107
+ grid-template-columns: minmax(0, 1fr);
108
+ grid-template-rows: none;
109
+ row-gap: var(--spacing-32);
110
+ width: 100%;
83
111
  }
84
112
 
85
113
  .bd-col {
86
- width: 100%;
114
+ display: flex;
115
+ flex-direction: column;
116
+ grid-row: auto;
117
+ }
118
+
119
+ /* across, in a column: full width, as every other part */
120
+ .bd-col > bd-accordion-section {
121
+ align-self: stretch;
87
122
  }
88
123
  }
89
124
  `;
@@ -11,119 +11,18 @@ import { ensembleCSS } from "../shared/ensemble.css.js";
11
11
  class BdFeatureCol extends HTMLElement {}
12
12
  customElements.define("bd-feature-col", BdFeatureCol);
13
13
 
14
+ /* The columns line up row by row -- icon, title, description, accordion --
15
+ because every column is a subgrid of the same four row tracks; see
16
+ features.css.js. This used to be done here: a ResizeObserver, a wait for the
17
+ fonts, two pairs of animation frames and a px height written on every icon,
18
+ title and description, plus a min-height pinned to the first measurement. */
14
19
  class BdFeatures extends LitElement {
15
- static properties = {
16
- _minHeight: { state: true }
17
- };
18
-
19
20
  static styles = [ensembleCSS, featuresCSS];
20
21
 
21
- constructor() {
22
- super();
23
- this._minHeight = 0;
24
- this._resizeObserver = null;
25
- }
26
-
27
22
  _getCols() {
28
23
  return Array.from(this.querySelectorAll(":scope > bd-feature-col"));
29
24
  }
30
25
 
31
- async firstUpdated() {
32
- if (document.fonts?.ready) {
33
- await document.fonts.ready;
34
- }
35
-
36
- await this._measureMaxHeight();
37
-
38
- const container = this.renderRoot.querySelector(".bd-features-container");
39
- if (container) {
40
- this._resizeObserver = new ResizeObserver(() => {
41
- this._equalizeRows();
42
- });
43
- this._resizeObserver.observe(container);
44
- }
45
- }
46
-
47
- disconnectedCallback() {
48
- super.disconnectedCallback();
49
- this._resizeObserver?.disconnect();
50
- }
51
-
52
- _isVisible() {
53
- return this.offsetWidth > 0 && this.offsetHeight > 0;
54
- }
55
-
56
- _equalizeRows() {
57
- if (!this._isVisible()) return;
58
-
59
- const container = this.renderRoot.querySelector(".bd-features-container");
60
- if (!container) return;
61
-
62
- const icons = container.querySelectorAll(".col-icon-wrapper");
63
- const titles = container.querySelectorAll(".col-title-wrapper");
64
- const descriptions = container.querySelectorAll(".col-description");
65
-
66
- icons.forEach(el => el.style.height = "auto");
67
- titles.forEach(el => el.style.height = "auto");
68
- descriptions.forEach(el => el.style.height = "auto");
69
-
70
- const measure = (els) => {
71
- let maxH = 0;
72
- els.forEach(el => {
73
- const h = el.getBoundingClientRect().height;
74
- if (h > maxH) maxH = h;
75
- });
76
- return maxH;
77
- };
78
-
79
- const iconMax = measure(icons);
80
- const titleMax = measure(titles);
81
- const descMax = measure(descriptions);
82
-
83
- // Aplica doar daca > 0, altfel removeProperty
84
- if (iconMax > 0) {
85
- icons.forEach(el => el.style.height = `${iconMax}px`);
86
- } else {
87
- icons.forEach(el => el.style.removeProperty("height"));
88
- }
89
-
90
- if (titleMax > 0) {
91
- titles.forEach(el => el.style.height = `${titleMax}px`);
92
- } else {
93
- titles.forEach(el => el.style.removeProperty("height"));
94
- }
95
-
96
- if (descMax > 0) {
97
- descriptions.forEach(el => el.style.height = `${descMax}px`);
98
- } else {
99
- descriptions.forEach(el => el.style.removeProperty("height"));
100
- }
101
- }
102
-
103
- async _measureMaxHeight() {
104
- const container = this.renderRoot.querySelector(".bd-features-container");
105
- if (!container) return;
106
-
107
- // Daca e ascunsa, nu masura
108
- if (!this._isVisible()) return;
109
-
110
- await this.updateComplete;
111
-
112
- await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
113
-
114
- this._equalizeRows();
115
-
116
- await this.updateComplete;
117
-
118
- const h = container.getBoundingClientRect().height;
119
- if (h > 0) {
120
- this._minHeight = h;
121
- }
122
-
123
- await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
124
- this._equalizeRows();
125
- }
126
-
127
26
  _renderCol(col) {
128
27
  const descEl = col.querySelector("[slot='description']");
129
28
  const iconEl = col.querySelector("[slot='icon']");
@@ -170,19 +69,10 @@ class BdFeatures extends LitElement {
170
69
  }
171
70
 
172
71
  render() {
173
- const cols = this._getCols();
174
- const colCount = cols.length;
175
- const colWidth = 400;
176
- const gap = 32;
177
- const maxWidth = colCount * colWidth + (colCount - 1) * gap;
178
-
179
72
  return html`
180
73
  <div class="bd-ensemble">
181
- <div
182
- class="bd-features-container"
183
- style="grid-template-columns: repeat(${colCount}, 1fr); max-width: ${maxWidth}px; ${this._minHeight ? `min-height: ${this._minHeight}px;` : ""}"
184
- >
185
- ${cols.map(col => this._renderCol(col))}
74
+ <div class="bd-features-container">
75
+ ${this._getCols().map(col => this._renderCol(col))}
186
76
  </div>
187
77
  </div>
188
78
  `;