@redvars/peacock 4.5.1 → 4.6.1

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 (256) hide show
  1. package/dist/{BaseField-BbOj212R.js → BaseField-DOCmylob.js} +16 -3
  2. package/dist/BaseField-DOCmylob.js.map +1 -0
  3. package/dist/accordion.js +1 -1
  4. package/dist/activation-gate-D4IpmwyD.js +23 -0
  5. package/dist/activation-gate-D4IpmwyD.js.map +1 -0
  6. package/dist/avatar-group.js +2 -1
  7. package/dist/avatar-group.js.map +1 -1
  8. package/dist/avatar.js +3 -0
  9. package/dist/avatar.js.map +1 -1
  10. package/dist/{base-button-BJMGMcMv.js → base-button-9tGu5RSC.js} +30 -10
  11. package/dist/base-button-9tGu5RSC.js.map +1 -0
  12. package/dist/button-group.js +5 -3
  13. package/dist/button-group.js.map +1 -1
  14. package/dist/button.js +12 -16
  15. package/dist/button.js.map +1 -1
  16. package/dist/calendar-column-view.js +4 -4
  17. package/dist/{calendar-drag-IXMPZrTN.js → calendar-drag-DdJwSpEz.js} +2 -2
  18. package/dist/{calendar-drag-IXMPZrTN.js.map → calendar-drag-DdJwSpEz.js.map} +1 -1
  19. package/dist/{calendar-event-BQChlMXy.js → calendar-event-BvbYZHx1.js} +2 -2
  20. package/dist/{calendar-event-BQChlMXy.js.map → calendar-event-BvbYZHx1.js.map} +1 -1
  21. package/dist/calendar-month-view.js +65 -14
  22. package/dist/calendar-month-view.js.map +1 -1
  23. package/dist/calendar-timeline.js +9 -4
  24. package/dist/calendar-timeline.js.map +1 -1
  25. package/dist/calendar.js +21 -6
  26. package/dist/calendar.js.map +1 -1
  27. package/dist/card.js +29 -16
  28. package/dist/card.js.map +1 -1
  29. package/dist/chart-doughnut.js +3 -1
  30. package/dist/chart-doughnut.js.map +1 -1
  31. package/dist/chart-pie.js +9 -1
  32. package/dist/chart-pie.js.map +1 -1
  33. package/dist/chip-set.js +1 -1
  34. package/dist/chip.js +10 -19
  35. package/dist/chip.js.map +1 -1
  36. package/dist/code-editor.js +56 -5
  37. package/dist/code-editor.js.map +1 -1
  38. package/dist/color-field.js +4 -1
  39. package/dist/color-field.js.map +1 -1
  40. package/dist/currency-field.js +4 -1
  41. package/dist/currency-field.js.map +1 -1
  42. package/dist/custom-elements-jsdocs.json +29 -23
  43. package/dist/custom-elements.json +758 -93
  44. package/dist/{datasource-OwvH7SVq.js → datasource-DxEA6jHW.js} +6 -4
  45. package/dist/datasource-DxEA6jHW.js.map +1 -0
  46. package/dist/{date-cfPx3alz.js → date-DPQOY8Zd.js} +2 -2
  47. package/dist/{date-cfPx3alz.js.map → date-DPQOY8Zd.js.map} +1 -1
  48. package/dist/date-field.js +8 -5
  49. package/dist/date-field.js.map +1 -1
  50. package/dist/date-picker.js +2 -2
  51. package/dist/date-range-field.js +8 -5
  52. package/dist/date-range-field.js.map +1 -1
  53. package/dist/datetime-field.js +7 -4
  54. package/dist/datetime-field.js.map +1 -1
  55. package/dist/diagram-controls.js +1 -1
  56. package/dist/{throttle-SQ9t-HL7.js → dispatch-event-utils-DfgqVBK8.js} +2 -24
  57. package/dist/dispatch-event-utils-DfgqVBK8.js.map +1 -0
  58. package/dist/{form-submitter-beG1CXAn.js → dispatch-hooks-J_godlHh.js} +2 -87
  59. package/dist/dispatch-hooks-J_godlHh.js.map +1 -0
  60. package/dist/dropdown-button.js +11 -7
  61. package/dist/dropdown-button.js.map +1 -1
  62. package/dist/{event-manager-KGMT2x2Q.js → event-manager-DYfeN3VE.js} +3 -3
  63. package/dist/{event-manager-KGMT2x2Q.js.map → event-manager-DYfeN3VE.js.map} +1 -1
  64. package/dist/fab.js +15 -19
  65. package/dist/fab.js.map +1 -1
  66. package/dist/filter-bar.js +3 -3
  67. package/dist/form-submission-h40coUI8.js +13 -0
  68. package/dist/form-submission-h40coUI8.js.map +1 -0
  69. package/dist/form-submitter-BIFqZ0wq.js +88 -0
  70. package/dist/form-submitter-BIFqZ0wq.js.map +1 -0
  71. package/dist/form.js +1 -9
  72. package/dist/form.js.map +1 -1
  73. package/dist/icon-button.js +15 -19
  74. package/dist/icon-button.js.map +1 -1
  75. package/dist/icon.js +1 -1
  76. package/dist/implicit-submission-ChLdbxaR.js +100 -0
  77. package/dist/implicit-submission-ChLdbxaR.js.map +1 -0
  78. package/dist/index.js +20 -15
  79. package/dist/index.js.map +1 -1
  80. package/dist/{indicator-navigation-item-CmyhsOmy.js → indicator-navigation-item-BsQE3kUr.js} +2 -2
  81. package/dist/{indicator-navigation-item-CmyhsOmy.js.map → indicator-navigation-item-BsQE3kUr.js.map} +1 -1
  82. package/dist/input.js +13 -4
  83. package/dist/input.js.map +1 -1
  84. package/dist/json-viewer.js +1 -1
  85. package/dist/kanban.js +8 -7
  86. package/dist/kanban.js.map +1 -1
  87. package/dist/link-button.js +13 -14
  88. package/dist/link-button.js.map +1 -1
  89. package/dist/list-item.js +52 -16
  90. package/dist/list-item.js.map +1 -1
  91. package/dist/list.js +5 -3
  92. package/dist/list.js.map +1 -1
  93. package/dist/listbox.js +1 -1
  94. package/dist/loader-full.js +17 -12
  95. package/dist/loader-full.js.map +1 -1
  96. package/dist/loader.js +17 -12
  97. package/dist/loader.js.map +1 -1
  98. package/dist/locale-DEsJZCQG.js.map +1 -1
  99. package/dist/mention-input.js +8 -1
  100. package/dist/mention-input.js.map +1 -1
  101. package/dist/menu-item.js +12 -12
  102. package/dist/menu-item.js.map +1 -1
  103. package/dist/menu.js +7 -3
  104. package/dist/menu.js.map +1 -1
  105. package/dist/navigation-bar-item.js +4 -3
  106. package/dist/navigation-bar-item.js.map +1 -1
  107. package/dist/navigation-bar.js +4 -3
  108. package/dist/navigation-bar.js.map +1 -1
  109. package/dist/navigation-drawer-item.js +3 -2
  110. package/dist/navigation-drawer-item.js.map +1 -1
  111. package/dist/navigation-drawer.js +3 -2
  112. package/dist/navigation-drawer.js.map +1 -1
  113. package/dist/{navigation-item-base-kUrvJgCx.js → navigation-item-base-5ljwtLG_.js} +3 -2
  114. package/dist/{navigation-item-base-kUrvJgCx.js.map → navigation-item-base-5ljwtLG_.js.map} +1 -1
  115. package/dist/navigation-rail-item.js +4 -3
  116. package/dist/navigation-rail-item.js.map +1 -1
  117. package/dist/navigation-rail.js +6 -5
  118. package/dist/navigation-rail.js.map +1 -1
  119. package/dist/number-field.js +4 -1
  120. package/dist/number-field.js.map +1 -1
  121. package/dist/option.js +3 -2
  122. package/dist/option.js.map +1 -1
  123. package/dist/password-field.js +11 -4
  124. package/dist/password-field.js.map +1 -1
  125. package/dist/phone-field.js +4 -1
  126. package/dist/phone-field.js.map +1 -1
  127. package/dist/{picker-field-DmXYPvbF.js → picker-field-BiM3iXAQ.js} +2 -2
  128. package/dist/{picker-field-DmXYPvbF.js.map → picker-field-BiM3iXAQ.js.map} +1 -1
  129. package/dist/pin-input.js +4 -1
  130. package/dist/pin-input.js.map +1 -1
  131. package/dist/{range-utils-DZe96GnO.js → range-utils-vgG1SJ2o.js} +2 -2
  132. package/dist/{range-utils-DZe96GnO.js.map → range-utils-vgG1SJ2o.js.map} +1 -1
  133. package/dist/{roving-focus-controller-fm95JkZJ.js → roving-focus-controller-YtNbxH95.js} +30 -7
  134. package/dist/roving-focus-controller-YtNbxH95.js.map +1 -0
  135. package/dist/search.js +12 -6
  136. package/dist/search.js.map +1 -1
  137. package/dist/select.js +11 -3
  138. package/dist/select.js.map +1 -1
  139. package/dist/shipped-icons.js +1 -1
  140. package/dist/split-button.js +9 -1
  141. package/dist/split-button.js.map +1 -1
  142. package/dist/src/__internal/controllers/roving-focus-controller.d.ts +14 -2
  143. package/dist/src/__internal/implicit-submission.d.ts +25 -0
  144. package/dist/src/__internal/utils/activation-gate.d.ts +8 -0
  145. package/dist/src/__internal/utils/form-submission.d.ts +2 -0
  146. package/dist/src/avatar-group/avatar-group.d.ts +1 -1
  147. package/dist/src/button/base-button/base-button.d.ts +1 -1
  148. package/dist/src/button/button/button.d.ts +2 -1
  149. package/dist/src/button/fab/fab.d.ts +2 -1
  150. package/dist/src/button/icon-button/icon-button.d.ts +2 -1
  151. package/dist/src/button/link-button/link-button.d.ts +5 -1
  152. package/dist/src/calendar/calendar-month-view.d.ts +5 -1
  153. package/dist/src/calendar/calendar.d.ts +6 -1
  154. package/dist/src/card/card.d.ts +19 -9
  155. package/dist/src/chart-pie/chart-pie.d.ts +5 -0
  156. package/dist/src/chip/chip/chip.d.ts +4 -4
  157. package/dist/src/code-editor/code-editor.d.ts +3 -3
  158. package/dist/src/dropdown-button/dropdown-button.d.ts +5 -1
  159. package/dist/src/input/BaseField.d.ts +7 -0
  160. package/dist/src/input/input.d.ts +5 -1
  161. package/dist/src/list/list-item.d.ts +2 -1
  162. package/dist/src/mention-input/mention-input.d.ts +2 -0
  163. package/dist/src/menu/menu-item/menu-item.d.ts +6 -4
  164. package/dist/src/password-field/password-field.d.ts +3 -1
  165. package/dist/src/search/search.d.ts +1 -0
  166. package/dist/src/select/select.d.ts +2 -0
  167. package/dist/src/split-button/split-button.d.ts +6 -1
  168. package/dist/src/stepper/step.d.ts +3 -1
  169. package/dist/src/tabs/tab.d.ts +12 -2
  170. package/dist/src/textarea/textarea.d.ts +2 -0
  171. package/dist/src/toolbar/toolbar.d.ts +13 -2
  172. package/dist/step.js +7 -1
  173. package/dist/step.js.map +1 -1
  174. package/dist/stepper.js +10 -1
  175. package/dist/stepper.js.map +1 -1
  176. package/dist/sub-menu.js +3 -2
  177. package/dist/sub-menu.js.map +1 -1
  178. package/dist/svg.js +1 -1
  179. package/dist/tab-group.js +3 -2
  180. package/dist/tab-group.js.map +1 -1
  181. package/dist/tab.js +17 -12
  182. package/dist/tab.js.map +1 -1
  183. package/dist/tabs.js +3 -2
  184. package/dist/tabs.js.map +1 -1
  185. package/dist/test/accessible-name.test.d.ts +1 -0
  186. package/dist/test/helpers/count-activations.d.ts +9 -0
  187. package/dist/test/navigation-rail.test.d.ts +1 -0
  188. package/dist/test/throttle-delay.test.d.ts +1 -0
  189. package/dist/textarea.js +8 -1
  190. package/dist/textarea.js.map +1 -1
  191. package/dist/throttle-C7ZAPqtu.js +24 -0
  192. package/dist/throttle-C7ZAPqtu.js.map +1 -0
  193. package/dist/time-field.js +7 -4
  194. package/dist/time-field.js.map +1 -1
  195. package/dist/time-picker.js +2 -2
  196. package/dist/toolbar.js +25 -8
  197. package/dist/toolbar.js.map +1 -1
  198. package/dist/tree.js +1 -1
  199. package/dist/tsconfig.tsbuildinfo +1 -1
  200. package/dist/url-field.js +4 -1
  201. package/dist/url-field.js.map +1 -1
  202. package/dist/{utils-DcvLgexs.js → utils-CQzycr9J.js} +2 -1
  203. package/dist/utils-CQzycr9J.js.map +1 -0
  204. package/package.json +2 -1
  205. package/src/__internal/controllers/roving-focus-controller.ts +35 -7
  206. package/src/__internal/i18n/locale.ts +1 -1
  207. package/src/__internal/implicit-submission.ts +102 -0
  208. package/src/__internal/utils/activation-gate.ts +20 -0
  209. package/src/__internal/utils/cache-fetch.ts +6 -3
  210. package/src/__internal/utils/form-submission.ts +11 -0
  211. package/src/avatar/avatar.scss +5 -0
  212. package/src/avatar-group/avatar-group.scss +3 -0
  213. package/src/avatar-group/avatar-group.ts +1 -1
  214. package/src/button/base-button/base-button.ts +41 -16
  215. package/src/button/button/button.ts +5 -16
  216. package/src/button/fab/fab.ts +7 -18
  217. package/src/button/icon-button/icon-button.ts +7 -18
  218. package/src/button/link-button/link-button.ts +8 -15
  219. package/src/calendar/_calendar-header.scss +7 -1
  220. package/src/calendar/calendar-month-view.scss +36 -2
  221. package/src/calendar/calendar-month-view.ts +33 -8
  222. package/src/calendar/calendar.ts +17 -2
  223. package/src/calendar/utils.ts +1 -0
  224. package/src/card/card.ts +27 -16
  225. package/src/chart-doughnut/chart-doughnut.ts +6 -1
  226. package/src/chart-pie/chart-pie.ts +10 -1
  227. package/src/chip/chip/chip.ts +6 -26
  228. package/src/code-editor/code-editor.scss +70 -1
  229. package/src/code-editor/code-editor.ts +12 -4
  230. package/src/dropdown-button/dropdown-button.ts +7 -2
  231. package/src/form/form.ts +1 -9
  232. package/src/input/BaseField.ts +17 -0
  233. package/src/input/input.ts +13 -1
  234. package/src/kanban/kanban.scss +11 -7
  235. package/src/list/list-item.scss +5 -0
  236. package/src/list/list-item.ts +44 -16
  237. package/src/mention-input/mention-input.ts +5 -0
  238. package/src/menu/menu/menu.ts +4 -1
  239. package/src/menu/menu-item/menu-item.ts +9 -14
  240. package/src/navigation-rail/navigation-rail.scss +3 -2
  241. package/src/password-field/password-field.ts +11 -1
  242. package/src/search/search.ts +9 -0
  243. package/src/select/select.ts +5 -0
  244. package/src/split-button/split-button.ts +10 -1
  245. package/src/stepper/step.ts +7 -1
  246. package/src/stepper/stepper.scss +13 -0
  247. package/src/tabs/tab.ts +21 -17
  248. package/src/textarea/textarea.ts +5 -0
  249. package/src/toolbar/toolbar.ts +26 -7
  250. package/dist/BaseField-BbOj212R.js.map +0 -1
  251. package/dist/base-button-BJMGMcMv.js.map +0 -1
  252. package/dist/datasource-OwvH7SVq.js.map +0 -1
  253. package/dist/form-submitter-beG1CXAn.js.map +0 -1
  254. package/dist/roving-focus-controller-fm95JkZJ.js.map +0 -1
  255. package/dist/throttle-SQ9t-HL7.js.map +0 -1
  256. package/dist/utils-DcvLgexs.js.map +0 -1
@@ -1,7 +1,9 @@
1
- import { html, LitElement } from 'lit';
1
+ import { html, LitElement, nothing } from 'lit';
2
2
  import { property, query } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import IndividualComponent from '@/IndividualComponent.js';
5
+ import type { ARIAMixinStrict } from '@/__internal/aria/aria.js';
6
+ import { mixinDelegatesAria } from '@/__internal/aria/delegate.js';
5
7
  import { MenuTriggerController } from '@/__internal/menu-trigger-controller.js';
6
8
  import type { OverlayPlacement } from '@/__internal/utils/placement.js';
7
9
  import styles from './dropdown-button.scss';
@@ -15,6 +17,8 @@ import type { Menu, MenuFocusTarget } from '../menu/menu/menu.js';
15
17
  * @summary A button that opens a menu of actions or options.
16
18
  * @overview
17
19
  * <p>Clicking the button opens its menu, and clicking it again closes it.</p>
20
+ * <p>An <code>aria-label</code> on the dropdown button names its button. Give one to a dropdown
21
+ * button that shows only an icon.</p>
18
22
  *
19
23
  * @cssprop --dropdown-button-container-shape: Defines the border radius of the dropdown button container shape.
20
24
  *
@@ -32,7 +36,7 @@ import type { Menu, MenuFocusTarget } from '../menu/menu/menu.js';
32
36
  * @tags controls
33
37
  */
34
38
  @IndividualComponent
35
- export class DropdownButton extends LitElement {
39
+ export class DropdownButton extends mixinDelegatesAria(LitElement) {
36
40
  static override styles = [styles];
37
41
 
38
42
  /**
@@ -128,6 +132,7 @@ export class DropdownButton extends LitElement {
128
132
  color=${this.color}
129
133
  trailing-icon
130
134
  ?disabled=${this.disabled}
135
+ aria-label=${(this as ARIAMixinStrict).ariaLabel || nothing}
131
136
  aria-haspopup="menu"
132
137
  aria-expanded=${String(this._trigger.open)}
133
138
  @click=${this._trigger.handleTriggerClick}
package/src/form/form.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  } from '@/__internal/ai/suggestion-controller.js';
10
10
  import type { AiSuggestion } from '@/__internal/ai/types.js';
11
11
  import { I18nController } from '@/__internal/i18n/i18n-controller.js';
12
+ import { isSubmitButton } from '@/__internal/utils/form-submission.js';
12
13
  import IndividualComponent from '@/IndividualComponent.js';
13
14
  import styles from './form.scss';
14
15
 
@@ -124,15 +125,6 @@ function isNativeControl(
124
125
  );
125
126
  }
126
127
 
127
- /** Whether `el` is a submit button of the form: native, or a Peacock button with `type="submit"`. */
128
- function isSubmitButton(el: FormControl): boolean {
129
- if (el instanceof HTMLButtonElement) return el.type === 'submit';
130
- if (el instanceof HTMLInputElement) {
131
- return el.type === 'submit' || el.type === 'image';
132
- }
133
- return el.localName.includes('-') && el.type === 'submit';
134
- }
135
-
136
128
  let formCount = 0;
137
129
 
138
130
  /**
@@ -2,6 +2,7 @@ import { html, nothing, type PropertyValues, type TemplateResult } from 'lit';
2
2
  import { property, state } from 'lit/decorators.js';
3
3
 
4
4
  import { peacockString } from '@/__internal/i18n/strings.js';
5
+ import { registerTextField } from '@/__internal/implicit-submission.js';
5
6
  import type { Size } from '@/__internal/utils/size.js';
6
7
  import BaseInput from './BaseInput.js';
7
8
 
@@ -97,6 +98,13 @@ export default abstract class BaseField extends BaseInput {
97
98
 
98
99
  // ── Lifecycle ────────────────────────────────────────────────────────────
99
100
 
101
+ constructor() {
102
+ super();
103
+ // A single-line field keeps Enter in another field from submitting a form without a
104
+ // submit button, as a second native text input would.
105
+ if (this.singleLineTextField) registerTextField(this);
106
+ }
107
+
100
108
  override connectedCallback() {
101
109
  super.connectedCallback();
102
110
  // `aria-*` and `tabindex` set on the host belong to the inner control; move them there.
@@ -142,6 +150,15 @@ export default abstract class BaseField extends BaseInput {
142
150
  return false;
143
151
  }
144
152
 
153
+ /**
154
+ * Whether the field is a single-line text field, which counts like a native text input when
155
+ * Enter decides whether to submit a form that has no submit button. Multi-line fields and
156
+ * selects turn it off. Read in the constructor, so an override must not use instance fields.
157
+ */
158
+ protected get singleLineTextField(): boolean {
159
+ return true;
160
+ }
161
+
145
162
  /**
146
163
  * The error text the field shows: the consumer's `error-text` while `error` is set, else an
147
164
  * error the control found itself, else the validation message once it should show.
@@ -2,6 +2,7 @@ import { html, nothing } from 'lit';
2
2
  import { property, query } from 'lit/decorators.js';
3
3
 
4
4
  import { spread } from '@/__internal/directive/spread.js';
5
+ import { setupImplicitSubmission } from '@/__internal/implicit-submission.js';
5
6
  import IndividualComponent from '@/IndividualComponent.js';
6
7
 
7
8
  import BaseField from './BaseField.js';
@@ -16,7 +17,10 @@ import styles from './input.scss';
16
17
  * @summary A single-line text field for plain text, an email address or a phone number.
17
18
  * @overview
18
19
  * <p>Input is form-associated: inside a <code>&lt;form&gt;</code> its <code>value</code> is submitted
19
- * under its <code>name</code>, and <code>form.reset()</code> restores the starting value.</p>
20
+ * under its <code>name</code>, and <code>form.reset()</code> restores the starting value. Enter
21
+ * submits the form as in a native text input: it clicks the form's first submit button, or,
22
+ * without one, submits a form that has no other text field. A disabled default button blocks it,
23
+ * and <code>preventDefault()</code> on the <code>keydown</code> stops it.</p>
20
24
  * <p>It validates like a native input: <code>required</code> and an invalid <code>type="email"</code>
21
25
  * block form submission, and the message shows under the field once the value is committed or the
22
26
  * form is submitted. <code>checkValidity()</code>, <code>reportValidity()</code> and
@@ -87,6 +91,14 @@ export class Input extends BaseField {
87
91
  @query('.input-element')
88
92
  private inputElement?: HTMLInputElement;
89
93
 
94
+ // ── Lifecycle ────────────────────────────────────────────────────────────
95
+
96
+ constructor() {
97
+ super();
98
+ // Enter submits the surrounding form, as in a native text input.
99
+ setupImplicitSubmission(this, () => this.inputElement);
100
+ }
101
+
90
102
  // ── Public methods ───────────────────────────────────────────────────────
91
103
 
92
104
  override focus() {
@@ -108,19 +108,23 @@
108
108
  min-block-size: 3rem;
109
109
  }
110
110
 
111
+ // The card wrappers are light-DOM divs, so a page rule such as `div { padding: 0 }` would beat a
112
+ // normal ::slotted declaration. Important declarations from the shadow tree win over the page's,
113
+ // so the chrome is marked important; the --kanban-card-* properties stay the way to change it.
111
114
  ::slotted([data-kanban-card]) {
112
115
  @include mixin.get-typography-not-important(body-medium);
113
116
 
114
- display: block;
115
- box-sizing: border-box;
116
- padding: var(--kanban-card-padding, var(--spacing-150));
117
- border-radius: var(--shape-corner-small);
117
+ display: block !important;
118
+ box-sizing: border-box !important;
119
+ margin: 0 !important;
120
+ padding: var(--kanban-card-padding, var(--spacing-150)) !important;
121
+ border-radius: var(--shape-corner-small) !important;
118
122
  background-color: var(
119
123
  --kanban-card-container-color,
120
124
  var(--color-surface)
121
- );
125
+ ) !important;
122
126
  color: var(--color-on-surface);
123
- box-shadow: var(--elevation-level1);
127
+ box-shadow: var(--elevation-level1) !important;
124
128
  cursor: grab;
125
129
  user-select: none;
126
130
  outline: none;
@@ -132,7 +136,7 @@
132
136
  }
133
137
 
134
138
  ::slotted([data-dragging]) {
135
- box-shadow: var(--elevation-level3);
139
+ box-shadow: var(--elevation-level3) !important;
136
140
  outline: 2px solid var(--color-primary);
137
141
  outline-offset: 2px;
138
142
  }
@@ -45,6 +45,11 @@
45
45
  --item-multiline-height: 3rem;
46
46
  --item-label-text-color: var(--_label-text-color);
47
47
  --item-label-text-opacity: var(--_label-text-opacity);
48
+
49
+ /* In a button or link, clicks land on the control, not on its content. */
50
+ &.clickable {
51
+ pointer-events: none;
52
+ }
48
53
  }
49
54
 
50
55
  .icon-slot {
@@ -1,6 +1,7 @@
1
1
  import { html, LitElement, nothing } from 'lit';
2
2
  import { property, query } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
5
  import IndividualComponent from '@/IndividualComponent.js';
5
6
  import styles from './list-item.scss';
6
7
  import { isLink } from '@/__internal/utils/is-link.js';
@@ -106,11 +107,6 @@ export class ListItem extends mixinBaseButton(
106
107
  this.requestUpdate();
107
108
  });
108
109
 
109
- constructor() {
110
- super();
111
- this.addEventListener('click', this.__dispatchClickWithThrottle);
112
- }
113
-
114
110
  connectedCallback() {
115
111
  // eslint-disable-next-line wc/guard-super-call
116
112
  super.connectedCallback();
@@ -146,11 +142,15 @@ export class ListItem extends mixinBaseButton(
146
142
  this.itemElement?.blur();
147
143
  }
148
144
 
145
+ /** A soft-disabled or skeleton item, or a disabled link, swallows clicks. */
146
+ override __isClickBlocked() {
147
+ return this.softDisabled || (this.disabled && !!this.href) || this.skeleton;
148
+ }
149
+
149
150
  __dispatchClick = (event: MouseEvent | KeyboardEvent) => {
150
- // If the button is soft-disabled or a disabled link, we need to explicitly
151
- // prevent the click from propagating to other event listeners as well as
152
- // prevent the default action.
153
- if (this.softDisabled || (this.disabled && this.href) || this.skeleton) {
151
+ // The inner control calls this directly as well as through the host
152
+ // listener, so it repeats the block.
153
+ if (this.__isClickBlocked()) {
154
154
  event.stopImmediatePropagation();
155
155
  event.preventDefault();
156
156
  return;
@@ -246,9 +246,14 @@ export class ListItem extends mixinBaseButton(
246
246
  const hasTrailingSupportingText = this.__hasNamedSlot(
247
247
  'trailing-supporting-text',
248
248
  );
249
+ // In a clickable item the content gives the button or link its name, so it
250
+ // must stay in the accessibility tree; `inert` would remove it. Slots with a
251
+ // negative tabindex take the slotted content out of the tab order instead,
252
+ // and `.clickable` makes it ignore the pointer (see list-item.scss).
253
+ const slotTabindex = clickable ? '-1' : undefined;
249
254
 
250
255
  return html`
251
- <wc-item class="list-item-content" ?inert=${clickable}>
256
+ <wc-item class=${classMap({ 'list-item-content': true, clickable })}>
252
257
  <div class="background" slot="container"></div>
253
258
  ${clickable
254
259
  ? html`<wc-focus-ring
@@ -265,20 +270,43 @@ export class ListItem extends mixinBaseButton(
265
270
  <wc-skeleton class="skeleton" slot="container"></wc-skeleton>
266
271
 
267
272
  ${hasStart
268
- ? html`<slot class="icon-slot" name="start" slot="start"></slot>`
273
+ ? html`<slot
274
+ class="icon-slot"
275
+ name="start"
276
+ slot="start"
277
+ tabindex=${ifDefined(slotTabindex)}
278
+ ></slot>`
269
279
  : nothing}
270
- <slot name="overline" slot="overline"></slot>
271
- <slot name="headline" slot="headline"></slot>
272
- <slot></slot>
273
- <slot name="supporting-text" slot="supporting-text"></slot>
280
+ <slot
281
+ name="overline"
282
+ slot="overline"
283
+ tabindex=${ifDefined(slotTabindex)}
284
+ ></slot>
285
+ <slot
286
+ name="headline"
287
+ slot="headline"
288
+ tabindex=${ifDefined(slotTabindex)}
289
+ ></slot>
290
+ <slot tabindex=${ifDefined(slotTabindex)}></slot>
291
+ <slot
292
+ name="supporting-text"
293
+ slot="supporting-text"
294
+ tabindex=${ifDefined(slotTabindex)}
295
+ ></slot>
274
296
  ${hasTrailingSupportingText
275
297
  ? html`<slot
276
298
  name="trailing-supporting-text"
277
299
  slot="trailing-supporting-text"
300
+ tabindex=${ifDefined(slotTabindex)}
278
301
  ></slot>`
279
302
  : nothing}
280
303
  ${hasEnd
281
- ? html`<slot class="icon-slot" name="end" slot="end"></slot>`
304
+ ? html`<slot
305
+ class="icon-slot"
306
+ name="end"
307
+ slot="end"
308
+ tabindex=${ifDefined(slotTabindex)}
309
+ ></slot>`
282
310
  : nothing}
283
311
  </wc-item>
284
312
  `;
@@ -271,6 +271,11 @@ export class MentionInput extends BaseField {
271
271
 
272
272
  // ── Protected methods ────────────────────────────────────────────────────
273
273
 
274
+ /** Multi-line: like a native textarea, it does not count for implicit submission. */
275
+ protected override get singleLineTextField(): boolean {
276
+ return false;
277
+ }
278
+
274
279
  protected override computeValidity(): ControlValidity {
275
280
  return this._textarea
276
281
  ? nativeValidity(this._textarea)
@@ -597,7 +597,10 @@ export class Menu extends LitElement {
597
597
  return;
598
598
  }
599
599
 
600
- activeItem.click();
600
+ // Click the item's own button or link, as a pointer does: the click reaches the item's
601
+ // listeners before a link follows its href, so `preventDefault()` (a single-page app
602
+ // routing the link itself) works for the keyboard as it does for the mouse.
603
+ (activeItem.itemElement ?? activeItem).click();
601
604
  break;
602
605
  }
603
606
  default:
@@ -107,11 +107,6 @@ export class MenuItem extends mixinBaseButton(
107
107
  /** Roving tabindex value managed by the parent Menu. */
108
108
  private _rovingTabIndex = -1;
109
109
 
110
- constructor() {
111
- super();
112
- this.addEventListener('click', this.__dispatchClickWithThrottle);
113
- }
114
-
115
110
  connectedCallback() {
116
111
  // eslint-disable-next-line wc/guard-super-call
117
112
  super.connectedCallback();
@@ -173,18 +168,18 @@ export class MenuItem extends mixinBaseButton(
173
168
  this.itemElement?.blur();
174
169
  }
175
170
 
171
+ /** A soft-disabled item, or a disabled link, swallows clicks. */
172
+ override __isClickBlocked() {
173
+ return this.softDisabled || (this.disabled && isLink(this));
174
+ }
175
+
176
176
  /**
177
- * Handles clicks on the host: stops them for soft-disabled items and disabled links, and turns
178
- * a click fired at the host (`item.click()`, Enter in the menu) into a click on the inner button
179
- * or link, so a link item navigates.
177
+ * Turns a click fired at the host (`item.click()`) into a click on the inner button or link, so
178
+ * a link item navigates. Enter and Space in the menu click the inner button or link directly,
179
+ * like a pointer, so a listener on the item can cancel a link with `preventDefault()`. Blocked
180
+ * clicks (soft-disabled items, disabled links) are swallowed before this, by the host listener.
180
181
  */
181
182
  __dispatchClick = (event: MouseEvent | KeyboardEvent) => {
182
- if (this.softDisabled || (this.disabled && isLink(this))) {
183
- event.stopImmediatePropagation();
184
- event.preventDefault();
185
- return;
186
- }
187
-
188
183
  if (!isActivationClick(event) || !this.itemElement) {
189
184
  return;
190
185
  }
@@ -18,12 +18,13 @@
18
18
  display: flex;
19
19
  flex-direction: column;
20
20
  align-items: center;
21
- height: calc(100% - var(--nav-rail-padding-block) * 2);
21
+ // Padding, not margin, keeps the container color down to the bottom edge (as in an app shell).
22
+ min-height: 100%;
22
23
  width: 100%;
23
24
  border-radius: inherit;
24
25
  background-color: var(--nav-rail-container-color);
25
26
  color: var(--nav-rail-label-text-color);
26
- margin-block: var(--nav-rail-padding-block); /* 24dp */
27
+ padding-block: var(--nav-rail-padding-block); /* 24dp */
27
28
  box-sizing: border-box;
28
29
 
29
30
  .header {
@@ -4,6 +4,7 @@ import { property, query, state } from 'lit/decorators.js';
4
4
  import { ALWAYS_SENSITIVE } from '@/__internal/ai/ai-controller.js';
5
5
  import { spread } from '@/__internal/directive/spread.js';
6
6
  import { I18nController } from '@/__internal/i18n/i18n-controller.js';
7
+ import { setupImplicitSubmission } from '@/__internal/implicit-submission.js';
7
8
  import IndividualComponent from '@/IndividualComponent.js';
8
9
 
9
10
  import BaseField from '../input/BaseField.js';
@@ -24,7 +25,8 @@ import styles from './password-field.scss';
24
25
  * <p>It validates like a native password input: <code>required</code>, <code>minlength</code>,
25
26
  * <code>maxlength</code> and <code>pattern</code> block form submission, and the message shows under
26
27
  * the field once the value is committed or the form is submitted. Inside a <code>&lt;form&gt;</code>
27
- * its <code>value</code> is submitted under its <code>name</code>.</p>
28
+ * its <code>value</code> is submitted under its <code>name</code>, and Enter submits the form as in
29
+ * a native input (see <code>wc-input</code>).</p>
28
30
  *
29
31
  * @fires {CustomEvent<{value: string}>} input - Dispatched as the user types.
30
32
  * @fires {CustomEvent<{value: string}>} change - Dispatched when the value is committed.
@@ -89,6 +91,14 @@ export class PasswordField extends BaseField {
89
91
  /** Peacock's strings for the show/hide toggle. */
90
92
  private readonly i18n = new I18nController(this);
91
93
 
94
+ // ── Lifecycle ────────────────────────────────────────────────────────────
95
+
96
+ constructor() {
97
+ super();
98
+ // Enter in the input (not on the show/hide toggle) submits the form, as in a native one.
99
+ setupImplicitSubmission(this, () => this.inputElement);
100
+ }
101
+
92
102
  // ── Public methods ───────────────────────────────────────────────────────
93
103
 
94
104
  override focus() {
@@ -4,6 +4,7 @@ import { classMap } from 'lit/directives/class-map.js';
4
4
  import { live } from 'lit/directives/live.js';
5
5
  import IndividualComponent from '@/IndividualComponent.js';
6
6
  import { I18nController } from '@/__internal/i18n/i18n-controller.js';
7
+ import { registerTextField } from '@/__internal/implicit-submission.js';
7
8
  import { AiController } from '@/__internal/ai/ai-controller.js';
8
9
  import { sparkle } from '@/__internal/ai/sparkle.js';
9
10
  import BaseInput, {
@@ -142,6 +143,14 @@ export class Search extends BaseInput {
142
143
  return this.ask && this.ai.available;
143
144
  }
144
145
 
146
+ // ── Lifecycle ────────────────────────────────────────────────────────────
147
+
148
+ constructor() {
149
+ super();
150
+ // Counts like a native search input when Enter decides whether to submit a form.
151
+ registerTextField(this);
152
+ }
153
+
145
154
  // ── Public methods ───────────────────────────────────────────────────────
146
155
 
147
156
  override focus() {
@@ -245,6 +245,11 @@ export class Select extends BaseField {
245
245
 
246
246
  // ── Protected ──────────────────────────────────────────────────────────────
247
247
 
248
+ /** Like a native select, it does not count for implicit submission. */
249
+ protected override get singleLineTextField(): boolean {
250
+ return false;
251
+ }
252
+
248
253
  protected override valueMissingText(): string {
249
254
  return peacockString('valueMissingSelect');
250
255
  }
@@ -34,7 +34,7 @@ import type { Menu, MenuFocusTarget } from '../menu/menu/menu.js';
34
34
  * @cssprop --elevated-split-button-container-color: Color of the elevated split button container.
35
35
  * @cssprop --elevated-split-button-label-text-color: Text color of the elevated split button label.
36
36
  *
37
- * @fires {MouseEvent} click - Dispatched when the primary action button is clicked.
37
+ * @fires {MouseEvent} click - Dispatched when the primary action button is clicked, and only then: a menu item's click does not bubble past the split button. Listen on the item, or for the `menu-item-activate` event (`detail.item`) that the menu fires through the split button.
38
38
  * @fires {CustomEvent} open - Dispatched after the menu opens.
39
39
  * @fires {CustomEvent<{reason: 'escape' | 'light-dismiss' | 'action' | 'api'}>} close - Dispatched after the menu closes: an item pick is `action`, Escape `escape`, a press outside or Tab `light-dismiss`, `close()` or the primary action `api`.
40
40
  *
@@ -143,6 +143,14 @@ export class SplitButton extends LitElement {
143
143
  }
144
144
  }
145
145
 
146
+ /**
147
+ * The split button's `click` means the primary action, so a menu item's click stops here: the
148
+ * item's own listeners and the menu have seen it, and the host still gets `menu-item-activate`.
149
+ */
150
+ private _onMenuClick(event: MouseEvent) {
151
+ event.stopPropagation();
152
+ }
153
+
146
154
  override render() {
147
155
  const actionClasses = {
148
156
  'action-button': true,
@@ -196,6 +204,7 @@ export class SplitButton extends LitElement {
196
204
  id=${this._trigger.menuId}
197
205
  .placement=${this.placement}
198
206
  variant=${this.menuVariant}
207
+ @click=${this._onMenuClick}
199
208
  @open=${this._trigger.handleMenuOpen}
200
209
  @close=${this._trigger.handleMenuClose}
201
210
  >
@@ -36,7 +36,9 @@ const STEPPER_INPUTS = ['value', 'error', 'disabled', 'optional'] as const;
36
36
  * before the stepper's <code>current</code> step are complete (a check), the current one has
37
37
  * <code>aria-current="step"</code>, and later ones are upcoming (their number). <code>error</code>
38
38
  * marks it with a warning icon and <code>error-text</code>, <code>disabled</code> takes it out of
39
- * navigation, and <code>optional</code> adds an "Optional" caption.</p>
39
+ * navigation, and <code>optional</code> adds an "Optional" caption. The step reflects its state
40
+ * as a read-only <code>status</code> attribute (<code>complete</code>, <code>current</code> or
41
+ * <code>upcoming</code>) for styling, for example <code>wc-step[status='current']</code>.</p>
40
42
  * <p>A screen reader reads each step as its position, label and state, for example
41
43
  * "Step 2 of 4, Shipping, Completed".</p>
42
44
  *
@@ -150,6 +152,10 @@ export class Step extends LitElement {
150
152
  ) {
151
153
  this.context = context;
152
154
  }
155
+ // Reflected so pages (and the stepper's narrow layout) can style a step by its state.
156
+ if (this.getAttribute('status') !== context.status) {
157
+ this.setAttribute('status', context.status);
158
+ }
153
159
  }
154
160
 
155
161
  override focus(options?: Parameters<HTMLElement['focus']>[0]) {
@@ -49,3 +49,16 @@
49
49
  .stepper.horizontal ::slotted(wc-step:last-child) {
50
50
  flex: none;
51
51
  }
52
+
53
+ // A narrow row shows only the current step's text (see step.scss). The other steps keep their
54
+ // indicator and connector, and the current step takes most of the spare room, shrinking (with an
55
+ // ellipsis) only when the row is too narrow for its label.
56
+ @container stepper (inline-size < 36rem) {
57
+ .stepper.horizontal ::slotted(wc-step:not(:last-child)) {
58
+ flex: 1 0 auto;
59
+ }
60
+
61
+ .stepper.horizontal ::slotted(wc-step[status='current']:not(:last-child)) {
62
+ flex: 8 1 auto;
63
+ }
64
+ }
package/src/tabs/tab.ts CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  isActivationClick,
8
8
  } from '@/__internal/utils/dispatch-event-utils.js';
9
9
  import { observerSlotChangesWithCallback } from '@/__internal/utils/observe-slot-change.js';
10
- import { throttle } from '@/__internal/utils/throttle.js';
10
+ import { createActivationGate } from '@/__internal/utils/activation-gate.js';
11
11
  import { isLink } from '@/__internal/utils/is-link.js';
12
12
  import { spread } from '@/__internal/directive/spread.js';
13
13
 
@@ -84,7 +84,9 @@ export class Tab extends LitElement {
84
84
  @property({ type: String, reflect: true }) href?: string;
85
85
 
86
86
  /**
87
- * Sets the delay for throttle in milliseconds. When unset (default), no throttle is applied.
87
+ * Throttles activation by this many milliseconds: after a click, every click inside the delay
88
+ * is swallowed, so neither `click` listeners nor `wc-tabs` see it. When unset (default), no
89
+ * throttle is applied.
88
90
  */
89
91
  @property({ type: Number, attribute: 'throttle-delay' })
90
92
  throttleDelay?: number;
@@ -112,16 +114,10 @@ export class Tab extends LitElement {
112
114
 
113
115
  constructor() {
114
116
  super();
115
- this.addEventListener('click', this.__dispatchClickWithThrottle);
117
+ this.addEventListener('click', this.__handleHostClick);
116
118
  }
117
119
 
118
120
  override firstUpdated() {
119
- if (typeof this.throttleDelay === 'number') {
120
- this.__dispatchClickWithThrottle = throttle(
121
- this.__dispatchClick,
122
- this.throttleDelay,
123
- );
124
- }
125
121
  observerSlotChangesWithCallback(
126
122
  this.renderRoot.querySelector('slot:not([name])'),
127
123
  hasContent => {
@@ -167,19 +163,27 @@ export class Tab extends LitElement {
167
163
 
168
164
  // ── Private
169
165
 
170
- __dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =
171
- event => {
172
- this.__dispatchClick(event);
173
- };
166
+ /** Whether `throttle-delay` lets a click through now; opens a new delay when it does. */
167
+ private readonly __throttleAllows = createActivationGate(
168
+ () => this.throttleDelay,
169
+ );
174
170
 
175
- __dispatchClick = (event: MouseEvent | KeyboardEvent) => {
176
- // A disabled link must not navigate, and its click must not reach other listeners.
177
- if (this.disabled && this.href) {
178
- event.stopImmediatePropagation();
171
+ /**
172
+ * Host click listener. Every activation reaches it once: a click on the inner control
173
+ * bubbling out, or a click fired at the host. A disabled link must not navigate, and a click
174
+ * inside the `throttle-delay` window must not act; both are swallowed so no other listener
175
+ * (including `wc-tabs`) sees them. A disabled link's click does not open a throttle window.
176
+ */
177
+ private __handleHostClick = (event: MouseEvent) => {
178
+ if ((this.disabled && this.href) || !this.__throttleAllows()) {
179
179
  event.preventDefault();
180
+ event.stopImmediatePropagation();
180
181
  return;
181
182
  }
183
+ this.__dispatchClick(event);
184
+ };
182
185
 
186
+ __dispatchClick = (event: MouseEvent | KeyboardEvent) => {
183
187
  if (!isActivationClick(event) || !this.tabElement) {
184
188
  return;
185
189
  }
@@ -124,6 +124,11 @@ export class Textarea extends BaseField {
124
124
  return true;
125
125
  }
126
126
 
127
+ /** Multi-line: like a native textarea, it does not count for implicit submission. */
128
+ protected override get singleLineTextField(): boolean {
129
+ return false;
130
+ }
131
+
127
132
  // ── Public methods ───────────────────────────────────────────────────────
128
133
 
129
134
  override focus() {