@redvars/peacock 4.5.0 → 4.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 (252) 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 +13 -8
  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/color-field.js +4 -1
  37. package/dist/color-field.js.map +1 -1
  38. package/dist/currency-field.js +4 -1
  39. package/dist/currency-field.js.map +1 -1
  40. package/dist/custom-elements-jsdocs.json +26 -20
  41. package/dist/custom-elements.json +755 -90
  42. package/dist/{datasource-OwvH7SVq.js → datasource-DxEA6jHW.js} +6 -4
  43. package/dist/datasource-DxEA6jHW.js.map +1 -0
  44. package/dist/{date-cfPx3alz.js → date-DPQOY8Zd.js} +2 -2
  45. package/dist/{date-cfPx3alz.js.map → date-DPQOY8Zd.js.map} +1 -1
  46. package/dist/date-field.js +8 -5
  47. package/dist/date-field.js.map +1 -1
  48. package/dist/date-picker.js +2 -2
  49. package/dist/date-range-field.js +8 -5
  50. package/dist/date-range-field.js.map +1 -1
  51. package/dist/datetime-field.js +7 -4
  52. package/dist/datetime-field.js.map +1 -1
  53. package/dist/diagram-controls.js +1 -1
  54. package/dist/{throttle-SQ9t-HL7.js → dispatch-event-utils-DfgqVBK8.js} +2 -24
  55. package/dist/dispatch-event-utils-DfgqVBK8.js.map +1 -0
  56. package/dist/{form-submitter-beG1CXAn.js → dispatch-hooks-J_godlHh.js} +2 -87
  57. package/dist/dispatch-hooks-J_godlHh.js.map +1 -0
  58. package/dist/dropdown-button.js +11 -7
  59. package/dist/dropdown-button.js.map +1 -1
  60. package/dist/{event-manager-KGMT2x2Q.js → event-manager-DYfeN3VE.js} +3 -3
  61. package/dist/{event-manager-KGMT2x2Q.js.map → event-manager-DYfeN3VE.js.map} +1 -1
  62. package/dist/fab.js +15 -19
  63. package/dist/fab.js.map +1 -1
  64. package/dist/filter-bar.js +3 -3
  65. package/dist/form-submission-h40coUI8.js +13 -0
  66. package/dist/form-submission-h40coUI8.js.map +1 -0
  67. package/dist/form-submitter-BIFqZ0wq.js +88 -0
  68. package/dist/form-submitter-BIFqZ0wq.js.map +1 -0
  69. package/dist/form.js +1 -9
  70. package/dist/form.js.map +1 -1
  71. package/dist/icon-button.js +15 -19
  72. package/dist/icon-button.js.map +1 -1
  73. package/dist/icon.js +1 -1
  74. package/dist/implicit-submission-ChLdbxaR.js +100 -0
  75. package/dist/implicit-submission-ChLdbxaR.js.map +1 -0
  76. package/dist/index.js +20 -15
  77. package/dist/index.js.map +1 -1
  78. package/dist/{indicator-navigation-item-CmyhsOmy.js → indicator-navigation-item-BsQE3kUr.js} +2 -2
  79. package/dist/{indicator-navigation-item-CmyhsOmy.js.map → indicator-navigation-item-BsQE3kUr.js.map} +1 -1
  80. package/dist/input.js +13 -4
  81. package/dist/input.js.map +1 -1
  82. package/dist/json-viewer.js +1 -1
  83. package/dist/kanban.js +8 -7
  84. package/dist/kanban.js.map +1 -1
  85. package/dist/link-button.js +13 -14
  86. package/dist/link-button.js.map +1 -1
  87. package/dist/list-item.js +52 -16
  88. package/dist/list-item.js.map +1 -1
  89. package/dist/list.js +5 -3
  90. package/dist/list.js.map +1 -1
  91. package/dist/listbox.js +1 -1
  92. package/dist/loader-full.js +17 -12
  93. package/dist/loader-full.js.map +1 -1
  94. package/dist/loader.js +17 -12
  95. package/dist/loader.js.map +1 -1
  96. package/dist/locale-DEsJZCQG.js.map +1 -1
  97. package/dist/mention-input.js +8 -1
  98. package/dist/mention-input.js.map +1 -1
  99. package/dist/menu-item.js +12 -12
  100. package/dist/menu-item.js.map +1 -1
  101. package/dist/menu.js +7 -3
  102. package/dist/menu.js.map +1 -1
  103. package/dist/navigation-bar-item.js +4 -3
  104. package/dist/navigation-bar-item.js.map +1 -1
  105. package/dist/navigation-bar.js +4 -3
  106. package/dist/navigation-bar.js.map +1 -1
  107. package/dist/navigation-drawer-item.js +3 -2
  108. package/dist/navigation-drawer-item.js.map +1 -1
  109. package/dist/navigation-drawer.js +3 -2
  110. package/dist/navigation-drawer.js.map +1 -1
  111. package/dist/{navigation-item-base-kUrvJgCx.js → navigation-item-base-5ljwtLG_.js} +3 -2
  112. package/dist/{navigation-item-base-kUrvJgCx.js.map → navigation-item-base-5ljwtLG_.js.map} +1 -1
  113. package/dist/navigation-rail-item.js +4 -3
  114. package/dist/navigation-rail-item.js.map +1 -1
  115. package/dist/navigation-rail.js +6 -5
  116. package/dist/navigation-rail.js.map +1 -1
  117. package/dist/number-field.js +4 -1
  118. package/dist/number-field.js.map +1 -1
  119. package/dist/option.js +3 -2
  120. package/dist/option.js.map +1 -1
  121. package/dist/password-field.js +11 -4
  122. package/dist/password-field.js.map +1 -1
  123. package/dist/phone-field.js +4 -1
  124. package/dist/phone-field.js.map +1 -1
  125. package/dist/{picker-field-DmXYPvbF.js → picker-field-BiM3iXAQ.js} +2 -2
  126. package/dist/{picker-field-DmXYPvbF.js.map → picker-field-BiM3iXAQ.js.map} +1 -1
  127. package/dist/pin-input.js +4 -1
  128. package/dist/pin-input.js.map +1 -1
  129. package/dist/{range-utils-DZe96GnO.js → range-utils-vgG1SJ2o.js} +2 -2
  130. package/dist/{range-utils-DZe96GnO.js.map → range-utils-vgG1SJ2o.js.map} +1 -1
  131. package/dist/{roving-focus-controller-fm95JkZJ.js → roving-focus-controller-YtNbxH95.js} +30 -7
  132. package/dist/roving-focus-controller-YtNbxH95.js.map +1 -0
  133. package/dist/search.js +12 -6
  134. package/dist/search.js.map +1 -1
  135. package/dist/select.js +11 -3
  136. package/dist/select.js.map +1 -1
  137. package/dist/shipped-icons.js +1 -1
  138. package/dist/split-button.js +9 -1
  139. package/dist/split-button.js.map +1 -1
  140. package/dist/src/__internal/controllers/roving-focus-controller.d.ts +14 -2
  141. package/dist/src/__internal/implicit-submission.d.ts +25 -0
  142. package/dist/src/__internal/utils/activation-gate.d.ts +8 -0
  143. package/dist/src/__internal/utils/form-submission.d.ts +2 -0
  144. package/dist/src/avatar-group/avatar-group.d.ts +1 -1
  145. package/dist/src/button/base-button/base-button.d.ts +1 -1
  146. package/dist/src/button/button/button.d.ts +2 -1
  147. package/dist/src/button/fab/fab.d.ts +2 -1
  148. package/dist/src/button/icon-button/icon-button.d.ts +2 -1
  149. package/dist/src/button/link-button/link-button.d.ts +5 -1
  150. package/dist/src/calendar/calendar-month-view.d.ts +5 -1
  151. package/dist/src/calendar/calendar.d.ts +6 -1
  152. package/dist/src/card/card.d.ts +19 -9
  153. package/dist/src/chart-pie/chart-pie.d.ts +5 -0
  154. package/dist/src/chip/chip/chip.d.ts +4 -4
  155. package/dist/src/dropdown-button/dropdown-button.d.ts +5 -1
  156. package/dist/src/input/BaseField.d.ts +7 -0
  157. package/dist/src/input/input.d.ts +5 -1
  158. package/dist/src/list/list-item.d.ts +2 -1
  159. package/dist/src/mention-input/mention-input.d.ts +2 -0
  160. package/dist/src/menu/menu-item/menu-item.d.ts +6 -4
  161. package/dist/src/password-field/password-field.d.ts +3 -1
  162. package/dist/src/search/search.d.ts +1 -0
  163. package/dist/src/select/select.d.ts +2 -0
  164. package/dist/src/split-button/split-button.d.ts +6 -1
  165. package/dist/src/stepper/step.d.ts +3 -1
  166. package/dist/src/tabs/tab.d.ts +12 -2
  167. package/dist/src/textarea/textarea.d.ts +2 -0
  168. package/dist/src/toolbar/toolbar.d.ts +13 -2
  169. package/dist/step.js +7 -1
  170. package/dist/step.js.map +1 -1
  171. package/dist/stepper.js +10 -1
  172. package/dist/stepper.js.map +1 -1
  173. package/dist/sub-menu.js +3 -2
  174. package/dist/sub-menu.js.map +1 -1
  175. package/dist/svg.js +1 -1
  176. package/dist/tab-group.js +3 -2
  177. package/dist/tab-group.js.map +1 -1
  178. package/dist/tab.js +17 -12
  179. package/dist/tab.js.map +1 -1
  180. package/dist/tabs.js +3 -2
  181. package/dist/tabs.js.map +1 -1
  182. package/dist/test/accessible-name.test.d.ts +1 -0
  183. package/dist/test/helpers/count-activations.d.ts +9 -0
  184. package/dist/test/navigation-rail.test.d.ts +1 -0
  185. package/dist/test/throttle-delay.test.d.ts +1 -0
  186. package/dist/textarea.js +8 -1
  187. package/dist/textarea.js.map +1 -1
  188. package/dist/throttle-C7ZAPqtu.js +24 -0
  189. package/dist/throttle-C7ZAPqtu.js.map +1 -0
  190. package/dist/time-field.js +7 -4
  191. package/dist/time-field.js.map +1 -1
  192. package/dist/time-picker.js +2 -2
  193. package/dist/toolbar.js +25 -8
  194. package/dist/toolbar.js.map +1 -1
  195. package/dist/tree.js +1 -1
  196. package/dist/tsconfig.tsbuildinfo +1 -1
  197. package/dist/url-field.js +4 -1
  198. package/dist/url-field.js.map +1 -1
  199. package/dist/{utils-DcvLgexs.js → utils-CQzycr9J.js} +2 -1
  200. package/dist/utils-CQzycr9J.js.map +1 -0
  201. package/package.json +2 -1
  202. package/src/__internal/controllers/roving-focus-controller.ts +35 -7
  203. package/src/__internal/i18n/locale.ts +1 -1
  204. package/src/__internal/implicit-submission.ts +102 -0
  205. package/src/__internal/utils/activation-gate.ts +20 -0
  206. package/src/__internal/utils/cache-fetch.ts +6 -3
  207. package/src/__internal/utils/form-submission.ts +11 -0
  208. package/src/avatar/avatar.scss +5 -0
  209. package/src/avatar-group/avatar-group.scss +3 -0
  210. package/src/avatar-group/avatar-group.ts +1 -1
  211. package/src/button/base-button/base-button.ts +41 -16
  212. package/src/button/button/button.ts +5 -16
  213. package/src/button/fab/fab.ts +7 -18
  214. package/src/button/icon-button/icon-button.ts +7 -18
  215. package/src/button/link-button/link-button.ts +8 -15
  216. package/src/calendar/_calendar-header.scss +7 -1
  217. package/src/calendar/calendar-month-view.scss +36 -2
  218. package/src/calendar/calendar-month-view.ts +33 -8
  219. package/src/calendar/calendar.ts +17 -2
  220. package/src/calendar/utils.ts +1 -0
  221. package/src/calendar-timeline/calendar-timeline.scss +15 -5
  222. package/src/card/card.ts +27 -16
  223. package/src/chart-doughnut/chart-doughnut.ts +6 -1
  224. package/src/chart-pie/chart-pie.ts +10 -1
  225. package/src/chip/chip/chip.ts +6 -26
  226. package/src/dropdown-button/dropdown-button.ts +7 -2
  227. package/src/form/form.ts +1 -9
  228. package/src/input/BaseField.ts +17 -0
  229. package/src/input/input.ts +13 -1
  230. package/src/kanban/kanban.scss +11 -7
  231. package/src/list/list-item.scss +5 -0
  232. package/src/list/list-item.ts +44 -16
  233. package/src/mention-input/mention-input.ts +5 -0
  234. package/src/menu/menu/menu.ts +4 -1
  235. package/src/menu/menu-item/menu-item.ts +9 -14
  236. package/src/navigation-rail/navigation-rail.scss +3 -2
  237. package/src/password-field/password-field.ts +11 -1
  238. package/src/search/search.ts +9 -0
  239. package/src/select/select.ts +5 -0
  240. package/src/split-button/split-button.ts +10 -1
  241. package/src/stepper/step.ts +7 -1
  242. package/src/stepper/stepper.scss +13 -0
  243. package/src/tabs/tab.ts +21 -17
  244. package/src/textarea/textarea.ts +5 -0
  245. package/src/toolbar/toolbar.ts +26 -7
  246. package/dist/BaseField-BbOj212R.js.map +0 -1
  247. package/dist/base-button-BJMGMcMv.js.map +0 -1
  248. package/dist/datasource-OwvH7SVq.js.map +0 -1
  249. package/dist/form-submitter-beG1CXAn.js.map +0 -1
  250. package/dist/roving-focus-controller-fm95JkZJ.js.map +0 -1
  251. package/dist/throttle-SQ9t-HL7.js.map +0 -1
  252. package/dist/utils-DcvLgexs.js.map +0 -1
@@ -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() {
@@ -26,7 +26,9 @@ const SEPARATOR_SELECTOR = 'wc-divider, hr, [role="separator"]';
26
26
  *
27
27
  * <p>The toolbar follows the WAI-ARIA toolbar pattern: it is a single tab stop, and the arrow
28
28
  * keys along its orientation move focus between actions (Home and End jump to the first and last).
29
- * Disabled actions and dividers are skipped. Give the toolbar an <code>aria-label</code>.</p>
29
+ * Disabled actions and dividers are skipped, and when the action that holds the tab stop becomes
30
+ * disabled or hidden, the next enabled action (else the previous one) takes it over. Give the
31
+ * toolbar an <code>aria-label</code>.</p>
30
32
  *
31
33
  * @cssprop --toolbar-container-color - Background color of the toolbar.
32
34
  * @cssprop --toolbar-container-shape - Border radius of the floating toolbar.
@@ -104,12 +106,30 @@ export class Toolbar extends LitElement {
104
106
  orientation: () => this.orientation,
105
107
  });
106
108
 
109
+ /**
110
+ * Re-applies the tab stop when an action becomes disabled, aria-disabled or hidden, so it moves
111
+ * to the next enabled action instead of leaving the toolbar out of the Tab order.
112
+ */
113
+ private readonly __actionStateObserver = new MutationObserver(() => {
114
+ this.roving.sync();
115
+ });
116
+
107
117
  // ── Lifecycle
108
118
 
109
119
  override connectedCallback() {
110
120
  super.connectedCallback();
111
121
  // The role lives on the host so the host's aria-label names the toolbar.
112
122
  this.setAttribute('role', 'toolbar');
123
+ this.__actionStateObserver.observe(this, {
124
+ subtree: true,
125
+ attributes: true,
126
+ attributeFilter: ['disabled', 'aria-disabled', 'hidden'],
127
+ });
128
+ }
129
+
130
+ override disconnectedCallback() {
131
+ super.disconnectedCallback();
132
+ this.__actionStateObserver.disconnect();
113
133
  }
114
134
 
115
135
  override updated(changed: Map<string, unknown>) {
@@ -120,7 +140,10 @@ export class Toolbar extends LitElement {
120
140
 
121
141
  // ── Private methods
122
142
 
123
- /** Actions that can take focus, in slot order. */
143
+ /**
144
+ * The actions, in slot order. Disabled and hidden ones are included: the roving controller skips
145
+ * them, takes the tab stop off them and hands it to the next enabled action.
146
+ */
124
147
  private __getItems(): HTMLElement[] {
125
148
  const slot = this.shadowRoot?.querySelector('slot');
126
149
  if (!slot) return [];
@@ -128,11 +151,7 @@ export class Toolbar extends LitElement {
128
151
  .assignedElements({ flatten: true })
129
152
  .filter(
130
153
  (el): el is HTMLElement =>
131
- el instanceof HTMLElement &&
132
- !el.matches(SEPARATOR_SELECTOR) &&
133
- !el.hasAttribute('disabled') &&
134
- el.getAttribute('aria-disabled') !== 'true' &&
135
- !el.hidden,
154
+ el instanceof HTMLElement && !el.matches(SEPARATOR_SELECTOR),
136
155
  );
137
156
  }
138
157
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseField-BbOj212R.js","sources":["../../src/input/BaseField.ts"],"sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\n\nimport { peacockString } from '@/__internal/i18n/strings.js';\nimport type { Size } from '@/__internal/utils/size.js';\nimport BaseInput from './BaseInput.js';\n\n/** Below this width, in pixels, a field's Suggested badge shows just the sparkle. */\nconst NARROW_FIELD_WIDTH = 320;\n\n/** What a field component passes to `renderField()`. */\nexport interface FieldRenderOptions {\n /** Whether the field has a value; outlined fields float their label when it does. */\n populated: boolean;\n /** Overrides the field's own focus state, for fields whose popup keeps them active. */\n focused?: boolean;\n /** An error the control found itself, such as text that does not parse. */\n controlError?: string;\n /** Extra content before the control (after the `start` slot). */\n start?: unknown;\n /** Extra content after the control (after the `end` slot), such as a picker button. */\n end?: unknown;\n /** Character counter shown in the footer, such as `12/100`; empty or unset for none. */\n textCount?: string;\n}\n\nlet fieldCount = 0;\n\n/**\n * Base class for Peacock's text-like fields (input, textarea, number, URL, select, date/time,\n * color). It adds the props every field shares (label, helper/error/warning text, variant, size,\n * clearable, `start`/`end` slots) and renders the `wc-field` frame.\n *\n * It also makes the inner control accessible across the shadow boundary: `fieldAria()` gives it\n * an accessible name from `label`, `aria-invalid` while an error shows, and `aria-describedby`\n * pointing at a hidden copy of the helper or error text in the same shadow root.\n *\n * Subclasses call `renderField(control, options)` in `render()`, spread `fieldAria()` onto the\n * native control, call `emitValue('input' | 'change')` instead of re-dispatching native events\n * (the field event contract: `CustomEvent<{ value }>`, bubbling and composed), and override\n * `clearValue()` if clearing means more than `value = ''`.\n */\nexport default abstract class BaseField extends BaseInput {\n // ── Properties ───────────────────────────────────────────────────────────\n\n /** Label shown above the field; also the control's accessible name. */\n @property({ type: String }) label = '';\n\n /** Hint shown inside the empty control. */\n @property({ type: String }) placeholder = '';\n\n /** Help text shown below the field. */\n @property({ type: String, attribute: 'helper-text' }) helperText = '';\n\n /** Shows the field in its error state with `error-text`. */\n @property({ type: Boolean }) error = false;\n\n /** Error message shown below the field while `error` is set; replaces the help text. */\n @property({ type: String, attribute: 'error-text' }) errorText = '';\n\n /** Shows the field in its warning state with `warning-text`. */\n @property({ type: Boolean }) warning = false;\n\n /** Warning message shown below the field while `warning` is set; replaces the help text. */\n @property({ type: String, attribute: 'warning-text' }) warningText = '';\n\n /** Visual variant of the field. */\n @property({ type: String }) variant: 'default' | 'filled' | 'outlined' =\n 'default';\n\n /** Height of the field: `sm` (2.5rem, default), `md` (3.5rem) or `lg` (4rem). */\n @property({ type: String, reflect: true }) size: Size = 'sm';\n\n /** Shows a button that clears the value while the field has one. */\n @property({ type: Boolean }) clearable = false;\n\n /** ARIA attributes moved from the host onto the inner control. */\n @property({ type: Object }) configAria: Record<string, string> = {};\n\n // ── State ────────────────────────────────────────────────────────────────\n\n @state() protected focused = false;\n\n /** The field is too narrow for the Suggested badge's label; it shows just the sparkle. */\n @state() private __narrow = false;\n\n // ── Private fields ───────────────────────────────────────────────────────\n\n /** Id of the hidden description the inner control points at. */\n protected readonly fieldDescriptionId = `wc-field-description-${(fieldCount += 1)}`;\n\n /** A `tabindex` set on the host, moved to the inner control. */\n protected controlTabIndex?: string;\n\n /** Watches the field's width while it holds a suggestion, so the badge can shrink. */\n private __widthObserver?: ResizeObserver;\n\n // ── Lifecycle ────────────────────────────────────────────────────────────\n\n override connectedCallback() {\n super.connectedCallback();\n // `aria-*` and `tabindex` set on the host belong to the inner control; move them there.\n for (const attr of Array.from(this.attributes)) {\n if (attr.name.startsWith('aria-')) {\n this.configAria = { ...this.configAria, [attr.name]: attr.value };\n this.removeAttribute(attr.name);\n }\n }\n if (this.hasAttribute('tabindex')) {\n this.controlTabIndex = this.getAttribute('tabindex') ?? undefined;\n this.removeAttribute('tabindex');\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.__widthObserver?.disconnect();\n this.__widthObserver = undefined;\n }\n\n protected override updated(changed: PropertyValues) {\n super.updated(changed);\n // Only a field showing a suggestion pays for an observer.\n if (this.suggestionVisible && !this.__widthObserver) {\n this.__widthObserver = new ResizeObserver(([entry]) => {\n this.__narrow = entry.contentRect.width < NARROW_FIELD_WIDTH;\n });\n this.__widthObserver.observe(this);\n } else if (!this.suggestionVisible && this.__widthObserver) {\n this.__widthObserver.disconnect();\n this.__widthObserver = undefined;\n }\n }\n\n // ── Protected ────────────────────────────────────────────────────────────\n\n /**\n * Whether the Suggested badge always shows just the sparkle, whatever the width. A textarea\n * sets it: a label beside it would narrow every line of the text.\n */\n protected get suggestionBadgeIconOnly(): boolean {\n return false;\n }\n\n /**\n * The error text the field shows: the consumer's `error-text` while `error` is set, else an\n * error the control found itself, else the validation message once it should show.\n */\n protected fieldErrorText(controlError = ''): string {\n if (this.error) return this.errorText;\n return controlError || this.validationText;\n }\n\n /**\n * Attributes for the native control: accessible name, invalid state, description and the\n * host's `tabindex`, plus `configAria`. Spread them onto it with `spread(this.fieldAria())`.\n */\n protected fieldAria(controlError = ''): Record<string, string | undefined> {\n const invalid = this.error || !!this.fieldErrorText(controlError);\n return {\n tabindex: this.controlTabIndex,\n 'aria-label': this.label || undefined,\n 'aria-invalid': invalid ? 'true' : undefined,\n 'aria-describedby': this.fieldDescription(controlError)\n ? this.fieldDescriptionId\n : undefined,\n ...this.configAria,\n };\n }\n\n /** Renders the `wc-field` frame around `control`, plus the hidden description. */\n protected renderField(\n control: unknown,\n options: FieldRenderOptions,\n ): TemplateResult {\n const errorText = this.fieldErrorText(options.controlError);\n const description = this.fieldDescription(options.controlError);\n // While a suggestion shows, its reason takes the helper text's place.\n const helperText = this.suggestionReason || this.helperText;\n return html`\n <wc-field\n label=${this.label}\n size=${this.size}\n variant=${this.variant}\n helper-text=${helperText}\n ?required=${this.required}\n ?disabled=${this.disabled}\n ?readonly=${this.readonly}\n ?skeleton=${this.skeleton}\n ?error=${this.error || !!errorText}\n error-text=${errorText}\n ?warning=${this.warning}\n warning-text=${this.warningText}\n text-count=${options.textCount ?? ''}\n ?populated=${options.populated}\n ?focused=${options.focused ?? this.focused}\n .host=${this}\n class=\"field\"\n >\n <slot name=\"start\" slot=\"field-start\"></slot>\n ${options.start ?? nothing} ${control}\n <slot name=\"end\" slot=\"field-end\"></slot>\n ${this.suggestionBadge({\n slot: 'field-end',\n iconOnly: this.__narrow || this.suggestionBadgeIconOnly,\n })}\n ${this.renderClearButton(options.populated)} ${options.end ?? nothing}\n </wc-field>\n ${description\n ? html`<span id=${this.fieldDescriptionId} hidden>${description}</span>`\n : nothing}\n `;\n }\n\n /** Dispatches `input` or `change` with the current value: the field event contract. */\n protected emitValue(type: 'input' | 'change') {\n this.dispatchEvent(\n new CustomEvent(type, {\n detail: { value: this.value },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n protected override emitSuggestionValue() {\n this.emitValue('input');\n this.emitValue('change');\n }\n\n /** Clears the value for the clear button. Fields with another empty value override it. */\n protected clearValue() {\n this.value = '';\n this.emitValue('input');\n this.emitValue('change');\n }\n\n /** The counter text for a field with a `maxlength`: `12/100`, or '' when there is no limit. */\n protected characterCount(maxLength: number | null | undefined): string {\n if (typeof maxLength !== 'number' || !Number.isFinite(maxLength)) return '';\n if (maxLength < 0) return '';\n const count = String(this.value ?? '').length;\n return peacockString('characterCount')(count, maxLength);\n }\n\n /** Tracks focus of the inner control; bind it to the control's `focus` and `blur`. */\n protected handleFieldFocus = (event: FocusEvent) => {\n this.focused = event.type === 'focus';\n };\n\n // ── Private ──────────────────────────────────────────────────────────────\n\n /** The text the description carries: the error, else the warning, else the help. */\n private fieldDescription(controlError = ''): string {\n const errorText = this.fieldErrorText(controlError);\n if (errorText) return errorText;\n if (this.warning && this.warningText) return this.warningText;\n if (this.suggestionVisible) {\n return peacockString('aiSuggestedDescription')(this.suggestionReason);\n }\n return this.helperText;\n }\n\n private renderClearButton(populated: boolean) {\n if (!this.clearable || !populated || this.disabled || this.readonly) {\n return nothing;\n }\n return html`<wc-icon-button\n slot=\"field-end\"\n class=\"clear-button\"\n shape=\"round\"\n variant=\"text\"\n size=\"sm\"\n aria-label=${peacockString('clear')}\n @click=${() => {\n this.clearValue();\n this.focus();\n }}\n >\n <wc-icon name=\"close\"></wc-icon>\n </wc-icon-button>`;\n }\n}\n"],"names":["html","nothing","property","state"],"mappings":";;;;;;AAOA;AACA,MAAM,kBAAkB,GAAG,GAAG;AAkB9B,IAAI,UAAU,GAAG,CAAC;AAElB;;;;;;;;;;;;;AAaG;AACW,MAAgB,SAAU,SAAQ,SAAS,CAAA;AAAzD,IAAA,WAAA,GAAA;;;;QAI8B,IAAA,CAAA,KAAK,GAAG,EAAE;;QAGV,IAAA,CAAA,WAAW,GAAG,EAAE;;QAGU,IAAA,CAAA,UAAU,GAAG,EAAE;;QAGxC,IAAA,CAAA,KAAK,GAAG,KAAK;;QAGW,IAAA,CAAA,SAAS,GAAG,EAAE;;QAGtC,IAAA,CAAA,OAAO,GAAG,KAAK;;QAGW,IAAA,CAAA,WAAW,GAAG,EAAE;;QAG3C,IAAA,CAAA,OAAO,GACjC,SAAS;;QAGgC,IAAA,CAAA,IAAI,GAAS,IAAI;;QAG/B,IAAA,CAAA,SAAS,GAAG,KAAK;;QAGlB,IAAA,CAAA,UAAU,GAA2B,EAAE;;QAIhD,IAAA,CAAA,OAAO,GAAG,KAAK;;QAGjB,IAAA,CAAA,QAAQ,GAAG,KAAK;;;QAKd,IAAA,CAAA,kBAAkB,GAAG,yBAAyB,UAAU,IAAI,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