@momentum-design/components 0.129.43 → 0.129.44

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 (52) hide show
  1. package/dist/browser/index.js +386 -386
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/accordionbutton/accordionbutton.component.d.ts +1 -1
  4. package/dist/components/accordionbutton/accordionbutton.component.js +4 -3
  5. package/dist/components/buttonsimple/buttonsimple.component.d.ts +1 -1
  6. package/dist/components/buttonsimple/buttonsimple.component.js +8 -6
  7. package/dist/components/cardcheckbox/cardcheckbox.component.d.ts +1 -1
  8. package/dist/components/cardcheckbox/cardcheckbox.component.js +7 -5
  9. package/dist/components/cardradio/cardradio.component.d.ts +1 -1
  10. package/dist/components/cardradio/cardradio.component.js +8 -7
  11. package/dist/components/checkbox/checkbox.component.d.ts +2 -1
  12. package/dist/components/checkbox/checkbox.component.js +7 -4
  13. package/dist/components/combobox/combobox.component.d.ts +1 -1
  14. package/dist/components/combobox/combobox.component.js +11 -11
  15. package/dist/components/input/input.component.d.ts +1 -1
  16. package/dist/components/input/input.component.js +3 -3
  17. package/dist/components/list/list.component.d.ts +1 -1
  18. package/dist/components/listbox/listbox.component.d.ts +1 -1
  19. package/dist/components/listitem/listitem.component.d.ts +1 -1
  20. package/dist/components/listitem/listitem.component.js +11 -5
  21. package/dist/components/menubar/menubar.component.d.ts +2 -2
  22. package/dist/components/menubar/menubar.component.js +10 -20
  23. package/dist/components/menuitem/menuitem.component.js +3 -3
  24. package/dist/components/menupopover/menupopover.component.d.ts +0 -10
  25. package/dist/components/menupopover/menupopover.component.js +15 -36
  26. package/dist/components/popover/popover.component.d.ts +1 -1
  27. package/dist/components/popover/popover.component.js +3 -2
  28. package/dist/components/radio/radio.component.d.ts +1 -1
  29. package/dist/components/radio/radio.component.js +8 -7
  30. package/dist/components/searchfield/searchfield.component.d.ts +3 -0
  31. package/dist/components/searchfield/searchfield.component.js +18 -5
  32. package/dist/components/searchpopover/searchpopover.component.js +3 -4
  33. package/dist/components/select/select.component.d.ts +1 -1
  34. package/dist/components/select/select.component.js +9 -8
  35. package/dist/components/slider/slider.component.d.ts +2 -1
  36. package/dist/components/slider/slider.component.js +4 -3
  37. package/dist/components/stepperitem/stepperitem.component.d.ts +1 -1
  38. package/dist/components/stepperitem/stepperitem.component.js +8 -6
  39. package/dist/components/textarea/textarea.component.d.ts +1 -1
  40. package/dist/components/textarea/textarea.component.js +5 -4
  41. package/dist/components/toggle/toggle.component.d.ts +1 -1
  42. package/dist/components/toggle/toggle.component.js +5 -4
  43. package/dist/components/virtualizedlist/virtualizedlist.component.d.ts +1 -1
  44. package/dist/components/virtualizedlist/virtualizedlist.component.js +7 -6
  45. package/dist/custom-elements.json +1343 -202
  46. package/dist/react/checkbox/index.d.ts +1 -0
  47. package/dist/react/checkbox/index.js +1 -0
  48. package/dist/utils/mixins/KeyToActionMixin.d.ts +69 -0
  49. package/dist/utils/mixins/KeyToActionMixin.js +92 -0
  50. package/dist/utils/mixins/ListNavigationMixin.d.ts +2 -1
  51. package/dist/utils/mixins/ListNavigationMixin.js +10 -33
  52. package/package.json +1 -1
@@ -12,7 +12,7 @@ import { property } from 'lit/decorators.js';
12
12
  import { ROLE } from '../../utils/roles';
13
13
  import ListItem from '../listitem/listitem.component';
14
14
  import { LISTITEM_VARIANTS } from '../listitem/listitem.constants';
15
- import { KEYS } from '../../utils/keys';
15
+ import { ACTIONS } from '../../utils/mixins/KeyToActionMixin';
16
16
  import { ARROW_ICONS, ARROW_DIRECTIONS, ARROW_POSITIONS } from './menuitem.constants';
17
17
  import styles from './menuitem.styles';
18
18
  /**
@@ -77,7 +77,7 @@ class MenuItem extends ListItem {
77
77
  * @param event - The keyboard event that triggered the action.
78
78
  */
79
79
  handleKeyDown(event) {
80
- if (event.key === KEYS.ENTER) {
80
+ if (this.getActionForKeyEvent(event) === ACTIONS.ENTER) {
81
81
  this.triggerClickEvent(event);
82
82
  event.preventDefault();
83
83
  }
@@ -95,7 +95,7 @@ class MenuItem extends ListItem {
95
95
  * @param event - The keyboard event that triggered the action.
96
96
  */
97
97
  handleKeyUp(event) {
98
- if (event.key === KEYS.SPACE) {
98
+ if (this.getActionForKeyEvent(event) === ACTIONS.SPACE) {
99
99
  this.triggerClickEvent(event);
100
100
  event.preventDefault();
101
101
  }
@@ -154,16 +154,6 @@ declare class MenuPopover extends Popover {
154
154
  private handleItemCreation;
155
155
  private handleItemChangeEvent;
156
156
  private resetMenuNavigation;
157
- /**
158
- * Resolves the key pressed by the user based on the direction of the layout.
159
- * This method is used to handle keyboard navigation in a right-to-left (RTL) layout.
160
- * It checks if the layout is RTL and adjusts the arrow keys accordingly.
161
- * For example, in RTL, the left arrow key behaves like the right arrow key and vice versa.
162
- * @param key - The key pressed by the user.
163
- * @param isRtl - A boolean indicating if the layout is right-to-left (RTL).
164
- * @returns - The resolved key based on the direction.
165
- */
166
- private resolveDirectionKey;
167
157
  /**
168
158
  * Handles keydown events for keyboard navigation within the menu popover.
169
159
  * This method allows users to navigate through the menu items using the keyboard.
@@ -8,7 +8,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { property } from 'lit/decorators.js';
11
- import { KEYS } from '../../utils/keys';
12
11
  import { ROLE } from '../../utils/roles';
13
12
  import { TAG_NAME as MENUSECTION_TAGNAME } from '../menusection/menusection.constants';
14
13
  import { TAG_NAME as NAVMENUITEM_TAGNAME } from '../navmenuitem/navmenuitem.constants';
@@ -18,6 +17,7 @@ import { TAG_NAME as MENUITEMRADIO_TAGNAME } from '../menuitemradio/menuitemradi
18
17
  import Popover from '../popover/popover.component';
19
18
  import { COLOR } from '../popover/popover.constants';
20
19
  import { popoverStack } from '../popover/popover.stack';
20
+ import { ACTIONS } from '../../utils/mixins/KeyToActionMixin';
21
21
  import { DEFAULTS, TAG_NAME as MENU_POPOVER } from './menupopover.constants';
22
22
  import styles from './menupopover.styles';
23
23
  import { isValidMenuItem, isValidMenuPopover } from './menupopover.utils';
@@ -173,36 +173,35 @@ class MenuPopover extends Popover {
173
173
  if (currentIndex === -1)
174
174
  return;
175
175
  this.resetTabIndexes(currentIndex);
176
- const isRtl = window.getComputedStyle(this).direction === 'rtl';
177
- const targetKey = this.resolveDirectionKey(event.key, isRtl);
176
+ const targetKey = this.getActionForKeyEvent(event, true);
178
177
  switch (targetKey) {
179
- case KEYS.HOME: {
178
+ case ACTIONS.HOME: {
180
179
  // Move focus to the first menu item
181
180
  this.resetTabIndexAndSetFocus(0, currentIndex);
182
181
  isKeyHandled = true;
183
182
  break;
184
183
  }
185
- case KEYS.END: {
184
+ case ACTIONS.END: {
186
185
  // Move focus to the last menu item
187
186
  this.resetTabIndexAndSetFocus(this.menuItems.length - 1, currentIndex);
188
187
  isKeyHandled = true;
189
188
  break;
190
189
  }
191
- case KEYS.ARROW_DOWN: {
190
+ case ACTIONS.DOWN: {
192
191
  // Move focus to the next menu item
193
192
  const newIndex = currentIndex + 1 === this.menuItems.length ? 0 : currentIndex + 1;
194
193
  this.resetTabIndexAndSetFocus(newIndex, currentIndex);
195
194
  isKeyHandled = true;
196
195
  break;
197
196
  }
198
- case KEYS.ARROW_UP: {
197
+ case ACTIONS.UP: {
199
198
  // Move focus to the prev menu item
200
199
  const newIndex = currentIndex - 1 === -1 ? this.menuItems.length - 1 : currentIndex - 1;
201
200
  this.resetTabIndexAndSetFocus(newIndex, currentIndex);
202
201
  isKeyHandled = true;
203
202
  break;
204
203
  }
205
- case KEYS.ARROW_RIGHT: {
204
+ case ACTIONS.RIGHT: {
206
205
  // If there is a submenu, open it.
207
206
  const subMenu = this.getSubMenuPopoverOfTarget(target);
208
207
  if (subMenu) {
@@ -211,7 +210,7 @@ class MenuPopover extends Popover {
211
210
  }
212
211
  break;
213
212
  }
214
- case KEYS.ARROW_LEFT: {
213
+ case ACTIONS.LEFT: {
215
214
  // If the current popover is a submenu then close this popover.
216
215
  if (isValidMenuPopover(this.parentElement)) {
217
216
  this.hide();
@@ -220,12 +219,12 @@ class MenuPopover extends Popover {
220
219
  }
221
220
  break;
222
221
  }
223
- case KEYS.ESCAPE: {
222
+ case ACTIONS.ESCAPE: {
224
223
  this.resetTabIndexAndSetFocus(0, currentIndex);
225
224
  isKeyHandled = true;
226
225
  break;
227
226
  }
228
- case KEYS.ENTER: {
227
+ case ACTIONS.ENTER: {
229
228
  if (!this.getSubMenuPopoverOfTarget(target) && !target.hasAttribute('soft-disabled')) {
230
229
  this.closeAllMenuPopovers();
231
230
  this.fireMenuItemAction(target);
@@ -233,7 +232,7 @@ class MenuPopover extends Popover {
233
232
  }
234
233
  break;
235
234
  }
236
- case KEYS.SPACE: {
235
+ case ACTIONS.SPACE: {
237
236
  // Prevent page scroll when space is pressed down
238
237
  isKeyHandled = true;
239
238
  break;
@@ -264,10 +263,11 @@ class MenuPopover extends Popover {
264
263
  this.handleKeyUp = (event) => {
265
264
  let isKeyHandled = false;
266
265
  const target = event.target;
267
- switch (event.key) {
268
- case KEYS.SPACE: {
266
+ switch (this.getActionForKeyEvent(event)) {
267
+ case ACTIONS.SPACE: {
269
268
  // If the target is a menu item, trigger its click event
270
- if (!target.matches(`${MENUITEMRADIO_TAGNAME}, ${MENUITEMCHECKBOX_TAGNAME}`) && !target.hasAttribute('soft-disabled')) {
269
+ if (!target.matches(`${MENUITEMRADIO_TAGNAME}, ${MENUITEMCHECKBOX_TAGNAME}`) &&
270
+ !target.hasAttribute('soft-disabled')) {
271
271
  // only close all menu popovers if the target is not opening a menu popover
272
272
  if (!this.getSubMenuPopoverOfTarget(target)) {
273
273
  this.closeAllMenuPopovers();
@@ -483,27 +483,6 @@ class MenuPopover extends Popover {
483
483
  this.closeAllMenuPopovers();
484
484
  this.fireMenuItemAction(target);
485
485
  }
486
- /**
487
- * Resolves the key pressed by the user based on the direction of the layout.
488
- * This method is used to handle keyboard navigation in a right-to-left (RTL) layout.
489
- * It checks if the layout is RTL and adjusts the arrow keys accordingly.
490
- * For example, in RTL, the left arrow key behaves like the right arrow key and vice versa.
491
- * @param key - The key pressed by the user.
492
- * @param isRtl - A boolean indicating if the layout is right-to-left (RTL).
493
- * @returns - The resolved key based on the direction.
494
- */
495
- resolveDirectionKey(key, isRtl) {
496
- if (!isRtl)
497
- return key;
498
- switch (key) {
499
- case KEYS.ARROW_LEFT:
500
- return KEYS.ARROW_RIGHT;
501
- case KEYS.ARROW_RIGHT:
502
- return KEYS.ARROW_LEFT;
503
- default:
504
- return key;
505
- }
506
- }
507
486
  }
508
487
  MenuPopover.styles = [...Popover.styles, ...styles];
509
488
  __decorate([
@@ -1,7 +1,7 @@
1
1
  import { CSSResult, PropertyValues } from 'lit';
2
2
  import { Component } from '../../models';
3
3
  import type { PopoverBoundaryRoot, PopoverColor, PopoverPlacement, PopoverStrategy, PopoverTrigger } from './popover.types';
4
- declare const Popover_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/BackdropMixin").BackdropMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/PreventScrollMixin").PreventScrollMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/FocusTrapMixin").FocusTrapClassInterface> & typeof Component;
4
+ declare const Popover_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/BackdropMixin").BackdropMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/PreventScrollMixin").PreventScrollMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/FocusTrapMixin").FocusTrapClassInterface> & typeof Component;
5
5
  /**
6
6
  * Popover is generic overlay which can be triggered by any actionable element.
7
7
  *
@@ -17,6 +17,7 @@ import { BackdropMixin } from '../../utils/mixins/BackdropMixin';
17
17
  import { FocusTrapMixin } from '../../utils/mixins/FocusTrapMixin';
18
18
  import { PreventScrollMixin } from '../../utils/mixins/PreventScrollMixin';
19
19
  import { Timers } from '../../utils/controllers/Timers';
20
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
20
21
  import { COLOR, DEFAULTS, POPOVER_PLACEMENT, TIMEOUTS, TRIGGER } from './popover.constants';
21
22
  import { PopoverEventManager } from './popover.events';
22
23
  import { popoverStack } from './popover.stack';
@@ -96,7 +97,7 @@ import { PopoverUtils } from './popover.utils';
96
97
  * @csspart popover-content - The content of the popover.
97
98
  * @csspart popover-hover-bridge - The hover bridge of the popover.
98
99
  */
99
- class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component))) {
100
+ class Popover extends KeyToActionMixin(BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)))) {
100
101
  /**
101
102
  * The effective z-index of the popover.
102
103
  *
@@ -496,7 +497,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
496
497
  * @internal
497
498
  */
498
499
  this.onEscapeKeydown = (event) => {
499
- if (!this.visible || event.code !== 'Escape') {
500
+ if (!this.visible || this.getActionForKeyEvent(event) !== ACTIONS.ESCAPE) {
500
501
  return;
501
502
  }
502
503
  if (!this.propagateEventOnEscape) {
@@ -1,7 +1,7 @@
1
1
  import { CSSResult, PropertyValueMap, PropertyValues } from 'lit';
2
2
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
3
3
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
4
- declare const Radio_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
4
+ declare const Radio_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
5
5
  /**
6
6
  * The Radio component allows users to select a single option from a group of mutually exclusive choices.
7
7
  * Unlike checkboxes which allow multiple selections, radio buttons ensure only one option can be selected
@@ -16,8 +16,8 @@ import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
16
16
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
17
17
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
18
18
  import { ROLE } from '../../utils/roles';
19
- import { KEYS } from '../../utils/keys';
20
19
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
20
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
21
21
  import styles from './radio.styles';
22
22
  /**
23
23
  * The Radio component allows users to select a single option from a group of mutually exclusive choices.
@@ -67,7 +67,7 @@ import styles from './radio.styles';
67
67
  * @csspart text-container - The container for the label and helper text elements.
68
68
  * @csspart static-radio - The staticradio that provides the visual radio appearance.
69
69
  */
70
- class Radio extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))) {
70
+ class Radio extends KeyToActionMixin(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)))) {
71
71
  constructor() {
72
72
  super(...arguments);
73
73
  /**
@@ -243,27 +243,28 @@ class Radio extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(
243
243
  var _a;
244
244
  if (this.disabled)
245
245
  return;
246
- if ((this.readonly || this.softDisabled) && event.key === KEYS.SPACE) {
246
+ const action = this.getActionForKeyEvent(event);
247
+ if ((this.readonly || this.softDisabled) && action === ACTIONS.SPACE) {
247
248
  event.preventDefault();
248
249
  }
249
250
  const radios = this.getAllRadiosWithinSameGroup();
250
251
  const enabledRadios = radios.filter(radio => !radio.disabled);
251
252
  const currentIndex = enabledRadios.indexOf(this);
252
- if (['ArrowDown', 'ArrowRight'].includes(event.key)) {
253
+ if (action === ACTIONS.DOWN || action === ACTIONS.RIGHT) {
253
254
  // Move focus to the next radio
254
255
  const nextIndex = (currentIndex + 1) % enabledRadios.length;
255
256
  this.updateRadio(enabledRadios, nextIndex);
256
257
  }
257
- else if (['ArrowUp', 'ArrowLeft'].includes(event.key)) {
258
+ else if (action === ACTIONS.UP || action === ACTIONS.LEFT) {
258
259
  // Move focus to the previous radio
259
260
  const prevIndex = (currentIndex - 1 + enabledRadios.length) % enabledRadios.length;
260
261
  this.updateRadio(enabledRadios, prevIndex);
261
262
  }
262
- else if (event.key === KEYS.SPACE) {
263
+ else if (action === ACTIONS.SPACE) {
263
264
  this.updateRadio(enabledRadios, currentIndex);
264
265
  }
265
266
  this.updateTabIndex();
266
- if (event.key === KEYS.ENTER) {
267
+ if (action === ACTIONS.ENTER) {
267
268
  (_a = this.form) === null || _a === void 0 ? void 0 : _a.requestSubmit();
268
269
  }
269
270
  }
@@ -94,6 +94,9 @@ declare class Searchfield extends Input {
94
94
  */
95
95
  protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
96
96
  clearInputText(): void;
97
+ handleFilterContainerClick: () => void;
98
+ protected handleFilterContainerKeyDown: (e: KeyboardEvent) => void;
99
+ protected handleFilterContainerKeyUp: (e: KeyboardEvent) => void;
97
100
  render(): import("lit-html").TemplateResult<1>;
98
101
  static styles: Array<CSSResult>;
99
102
  }
@@ -11,7 +11,7 @@ import { html } from 'lit';
11
11
  import { queryAssignedElements, state } from 'lit/decorators.js';
12
12
  import { classMap } from 'lit-html/directives/class-map.js';
13
13
  import Input from '../input/input.component';
14
- import { KEYS } from '../../utils/keys';
14
+ import { ACTIONS } from '../../utils/mixins/KeyToActionMixin';
15
15
  import styles from './searchfield.styles';
16
16
  import { DEFAULTS } from './searchfield.constants';
17
17
  /**
@@ -88,6 +88,19 @@ class Searchfield extends Input {
88
88
  * @internal
89
89
  */
90
90
  this.hasInputChips = false;
91
+ this.handleFilterContainerClick = () => {
92
+ this.inputElement.focus();
93
+ };
94
+ this.handleFilterContainerKeyDown = (e) => {
95
+ if (this.getActionForKeyEvent(e) === ACTIONS.ENTER) {
96
+ this.handleFilterContainerClick();
97
+ }
98
+ };
99
+ this.handleFilterContainerKeyUp = (e) => {
100
+ if (this.getActionForKeyEvent(e) === ACTIONS.SPACE) {
101
+ this.handleFilterContainerClick();
102
+ }
103
+ };
91
104
  }
92
105
  /**
93
106
  * Handles the keydown event of the search field.
@@ -97,7 +110,7 @@ class Searchfield extends Input {
97
110
  */
98
111
  handleKeyDown(event) {
99
112
  super.handleKeyDown(event);
100
- if (event.key === KEYS.ESCAPE) {
113
+ if (this.getActionForKeyEvent(event) === ACTIONS.ESCAPE) {
101
114
  this.clearInputText();
102
115
  }
103
116
  }
@@ -162,9 +175,9 @@ class Searchfield extends Input {
162
175
  <div part="scrollable-container" tabindex="-1">
163
176
  <div
164
177
  part="filters-container"
165
- @click=${() => this.inputElement.focus()}
166
- @keydown=${(e) => (e.key === KEYS.ENTER ? this.inputElement.focus() : null)}
167
- @keyup=${(e) => (e.key === KEYS.SPACE ? this.inputElement.focus() : null)}
178
+ @click=${this.handleFilterContainerClick}
179
+ @keydown=${this.handleFilterContainerKeyDown}
180
+ @keyup=${this.handleFilterContainerKeyUp}
168
181
  >
169
182
  <slot name="filters" @slotchange=${this.renderInputChips}></slot>
170
183
  </div>
@@ -13,7 +13,6 @@ import { property } from 'lit/decorators.js';
13
13
  import { ifDefined } from 'lit/directives/if-defined.js';
14
14
  import { live } from 'lit/directives/live.js';
15
15
  import Searchfield from '../searchfield/searchfield.component';
16
- import { KEYS } from '../../utils/keys';
17
16
  import { POPOVER_PLACEMENT, DEFAULTS as POPOVER_DEFAULTS } from '../popover/popover.constants';
18
17
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
19
18
  import { ROLE } from '../../utils/roles';
@@ -162,9 +161,9 @@ class Searchpopover extends Searchfield {
162
161
  <div part="scrollable-container" tabindex="-1">
163
162
  <div
164
163
  part="filters-container"
165
- @click=${() => this.inputElement.focus()}
166
- @keydown=${(e) => (e.key === KEYS.ENTER ? this.inputElement.focus() : null)}
167
- @keyup=${(e) => (e.key === KEYS.SPACE ? this.inputElement.focus() : null)}
164
+ @click=${this.handleFilterContainerClick}
165
+ @keydown=${this.handleFilterContainerKeyDown}
166
+ @keyup=${this.handleFilterContainerKeyUp}
168
167
  >
169
168
  <slot name="filters" @slotchange=${this.renderInputChips}></slot>
170
169
  </div>
@@ -5,7 +5,7 @@ import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
5
5
  import type Option from '../option/option.component';
6
6
  import type { PopoverStrategy } from '../popover/popover.types';
7
7
  import type { Placement } from './select.types';
8
- declare const Select_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/ListNavigationMixin").ListNavigationMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement").CaptureDestroyEventForChildElementInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
8
+ declare const Select_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/ListNavigationMixin").ListNavigationMixinInterface & import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement").CaptureDestroyEventForChildElementInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
9
9
  /**
10
10
  * The mdc-select component is a dropdown selection control that allows users to pick an option from a predefined list.
11
11
  * It is designed to work with `mdc-option` for individual options and `mdc-optgroup` for grouping related options.
@@ -11,7 +11,6 @@ import { html, nothing } from 'lit';
11
11
  import { property, query, state } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
13
  import { ElementStore } from '../../utils/controllers/ElementStore';
14
- import { KEYS } from '../../utils/keys';
15
14
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
16
15
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
17
16
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
@@ -25,6 +24,7 @@ import { TAG_NAME as OPTION_TAG_NAME } from '../option/option.constants';
25
24
  import { DEFAULTS as POPOVER_DEFAULTS, POPOVER_PLACEMENT, TRIGGER } from '../popover/popover.constants';
26
25
  import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
27
26
  import { debounce } from '../../utils/debounce';
27
+ import { ACTIONS } from '../../utils/mixins/KeyToActionMixin';
28
28
  import { ARROW_ICON, DEFAULTS, LISTBOX_ID, TRIGGER_ID } from './select.constants';
29
29
  import styles from './select.styles';
30
30
  /**
@@ -553,23 +553,24 @@ class Select extends ListNavigationMixin(CaptureDestroyEventForChildElement(Auto
553
553
  if (this.disabled || this.softDisabled || this.readonly) {
554
554
  return;
555
555
  }
556
- switch (event.key) {
557
- case KEYS.ARROW_DOWN:
558
- case KEYS.ARROW_UP:
559
- case KEYS.ENTER:
560
- case KEYS.SPACE:
556
+ const action = this.getActionForKeyEvent(event);
557
+ switch (action) {
558
+ case ACTIONS.DOWN:
559
+ case ACTIONS.UP:
560
+ case ACTIONS.ENTER:
561
+ case ACTIONS.SPACE:
561
562
  this.displayPopover = true;
562
563
  event.preventDefault();
563
564
  event.stopPropagation();
564
565
  break;
565
- case KEYS.HOME: {
566
+ case ACTIONS.HOME: {
566
567
  this.displayPopover = true;
567
568
  this.resetTabIndexAndSetFocusAfterUpdate(0);
568
569
  event.preventDefault();
569
570
  event.stopPropagation();
570
571
  break;
571
572
  }
572
- case KEYS.END: {
573
+ case ACTIONS.END: {
573
574
  this.displayPopover = true;
574
575
  this.resetTabIndexAndSetFocusAfterUpdate(this.navItems.length - 1);
575
576
  event.preventDefault();
@@ -1,5 +1,6 @@
1
1
  import type { CSSResult, PropertyValueMap } from 'lit';
2
2
  import { Component } from '../../models';
3
+ declare const Slider_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & typeof Component;
3
4
  /**
4
5
  * Slider component is used to select a value or range of values from within a defined range.
5
6
  * It provides a visual representation of the current value(s) and allows users to adjust the value(s) by dragging the thumb(s) along the track.
@@ -33,7 +34,7 @@ import { Component } from '../../models';
33
34
  * @cssproperty --mdc-slider-tooltip-left - The left position of the slider tooltip
34
35
  * @cssproperty --mdc-slider-tick-left - The left position of the slider tick marks
35
36
  */
36
- declare class Slider extends Component {
37
+ declare class Slider extends Slider_base {
37
38
  /**
38
39
  * Internal state to track if the slider thumb is focused (single value)
39
40
  * @internal
@@ -11,7 +11,7 @@ import { html, nothing } from 'lit';
11
11
  import { property, queryAll, state } from 'lit/decorators.js';
12
12
  import { repeat } from 'lit/directives/repeat.js';
13
13
  import { Component } from '../../models';
14
- import { KEYS } from '../../utils/keys';
14
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
15
15
  import { DEFAULTS } from './slider.constants';
16
16
  import styles from './slider.styles';
17
17
  /**
@@ -47,7 +47,7 @@ import styles from './slider.styles';
47
47
  * @cssproperty --mdc-slider-tooltip-left - The left position of the slider tooltip
48
48
  * @cssproperty --mdc-slider-tick-left - The left position of the slider tick marks
49
49
  */
50
- class Slider extends Component {
50
+ class Slider extends KeyToActionMixin(Component) {
51
51
  constructor() {
52
52
  super();
53
53
  /**
@@ -109,7 +109,8 @@ class Slider extends Component {
109
109
  * @param e - The event to prevent.
110
110
  */
111
111
  preventChange(e) {
112
- if (this.softDisabled && ((e instanceof KeyboardEvent && e.key !== KEYS.TAB) || !(e instanceof KeyboardEvent))) {
112
+ if (this.softDisabled &&
113
+ ((e instanceof KeyboardEvent && this.getActionForKeyEvent(e) !== ACTIONS.TAB) || !(e instanceof KeyboardEvent))) {
113
114
  e.preventDefault();
114
115
  e.stopPropagation();
115
116
  }
@@ -1,7 +1,7 @@
1
1
  import { CSSResult } from 'lit';
2
2
  import { Component } from '../../models';
3
3
  import type { StatusType, VariantType } from './stepperitem.types';
4
- declare const StepperItem_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Component;
4
+ declare const StepperItem_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Component;
5
5
  /**
6
6
  * stepperitem component is used to represent a single step in a stepper component. It is used within a `mdc-stepper` component to indicate the current step in a process.
7
7
  * It can have different statuses such as `completed`, `current`, `incomplete`, `error-current`, and `error-incomplete`.
@@ -13,9 +13,9 @@ import { Component } from '../../models';
13
13
  import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
14
14
  import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
15
15
  import { ROLE } from '../../utils/roles';
16
- import { KEYS } from '../../utils/keys';
17
16
  import providerUtils from '../../utils/provider';
18
17
  import Stepper from '../stepper/stepper.component';
18
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
19
19
  import styles from './stepperitem.styles';
20
20
  import { DEFAULT, STATUS, STATUS_ICON } from './stepperitem.constants';
21
21
  /**
@@ -52,7 +52,7 @@ import { DEFAULT, STATUS, STATUS_ICON } from './stepperitem.constants';
52
52
  * @cssproperty --mdc-stepperitem-help-text-color - The color of the optional label text.
53
53
  * @cssproperty --mdc-stepperitem-label-container-background - The background color of the label container.
54
54
  */
55
- class StepperItem extends TabIndexMixin(Component) {
55
+ class StepperItem extends KeyToActionMixin(TabIndexMixin(Component)) {
56
56
  updated(changedProperties) {
57
57
  var _a;
58
58
  super.updated(changedProperties);
@@ -99,9 +99,10 @@ class StepperItem extends TabIndexMixin(Component) {
99
99
  * @param event - The keyboard event.
100
100
  */
101
101
  handleKeyDown(event) {
102
- if ([KEYS.ENTER, KEYS.SPACE].includes(event.key)) {
102
+ const action = this.getActionForKeyEvent(event);
103
+ if (action === ACTIONS.ENTER || action === ACTIONS.SPACE) {
103
104
  this.classList.add('pressed');
104
- if (event.key === KEYS.ENTER) {
105
+ if (action === ACTIONS.ENTER) {
105
106
  this.triggerClickEvent();
106
107
  }
107
108
  // Prevent default event behavior to avoid scrolling or double-triggering
@@ -127,9 +128,10 @@ class StepperItem extends TabIndexMixin(Component) {
127
128
  * @param event - The keyboard event.
128
129
  */
129
130
  handleKeyUp(event) {
130
- if ([KEYS.ENTER, KEYS.SPACE].includes(event.key)) {
131
+ const action = this.getActionForKeyEvent(event);
132
+ if (action === ACTIONS.ENTER || action === ACTIONS.SPACE) {
131
133
  this.classList.remove('pressed');
132
- if (event.key === KEYS.SPACE) {
134
+ if (action === ACTIONS.SPACE) {
133
135
  this.triggerClickEvent();
134
136
  }
135
137
  }
@@ -2,7 +2,7 @@ import { CSSResult, nothing, PropertyValueMap } from 'lit';
2
2
  import FormfieldWrapper from '../formfieldwrapper';
3
3
  import type { AutoCapitalizeType } from '../input/input.types';
4
4
  import type { WrapType, AutoCompleteType } from './textarea.types';
5
- declare const Textarea_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
5
+ declare const Textarea_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
6
6
  /**
7
7
  * mdc-textarea component, which is used to get the multi-line text input from the user.
8
8
  * It contains:
@@ -16,7 +16,7 @@ import { AUTO_CAPITALIZE } from '../input/input.constants';
16
16
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
17
17
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
18
18
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
19
- import { KEYS } from '../../utils/keys';
19
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
20
20
  import { AUTO_COMPLETE, WRAP, DEFAULTS } from './textarea.constants';
21
21
  import styles from './textarea.styles';
22
22
  /**
@@ -104,7 +104,7 @@ import styles from './textarea.styles';
104
104
  * @cssproperty --mdc-textarea-text-line-height - Line height for the textarea field
105
105
  * @cssproperty --mdc-textarea-container-background-color - Background color for the textarea container
106
106
  */
107
- class Textarea extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))) {
107
+ class Textarea extends KeyToActionMixin(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)))) {
108
108
  constructor() {
109
109
  super(...arguments);
110
110
  /**
@@ -379,10 +379,11 @@ class Textarea extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMix
379
379
  }
380
380
  const currentRows = this.rows || DEFAULTS.ROWS;
381
381
  let newRows;
382
- if (event.key === KEYS.ARROW_UP) {
382
+ const action = this.getActionForKeyEvent(event);
383
+ if (action === ACTIONS.UP) {
383
384
  newRows = Math.max(1, currentRows - 1);
384
385
  }
385
- else if (event.key === KEYS.ARROW_DOWN) {
386
+ else if (action === ACTIONS.DOWN) {
386
387
  newRows = currentRows + 1;
387
388
  }
388
389
  if (newRows !== undefined) {
@@ -2,7 +2,7 @@ import { CSSResult, PropertyValueMap } from 'lit';
2
2
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
3
3
  import FormfieldWrapper from '../formfieldwrapper';
4
4
  import type { ToggleSize } from './toggle.types';
5
- declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ControlTypeMixin").ControlTypeMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
5
+ declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ControlTypeMixin").ControlTypeMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
6
6
  /**
7
7
  * The Toggle component is an interactive control used to switch between two mutually exclusive states,
8
8
  * such as On/Off or Active/Inactive. It is commonly used in settings panels, forms, and preference selections
@@ -10,7 +10,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { html, nothing } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
- import { KEYS } from '../../utils/keys';
14
13
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
15
14
  import { ControlTypeMixin } from '../../utils/mixins/ControlTypeMixin';
16
15
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
@@ -18,6 +17,7 @@ import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
18
17
  import { ROLE } from '../../utils/roles';
19
18
  import FormfieldWrapper from '../formfieldwrapper';
20
19
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
20
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
21
21
  import { DEFAULTS, TOGGLE_SIZE } from './toggle.constants';
22
22
  import styles from './toggle.styles';
23
23
  /**
@@ -64,7 +64,7 @@ import styles from './toggle.styles';
64
64
  * @csspart static-toggle - The statictoggle that provides the visual toggle switch appearance.
65
65
  * @csspart toggle-input - The native input element with switch role that provides the interactive functionality.
66
66
  */
67
- class Toggle extends ControlTypeMixin(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)))) {
67
+ class Toggle extends KeyToActionMixin(ControlTypeMixin(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))))) {
68
68
  constructor() {
69
69
  super(...arguments);
70
70
  /**
@@ -173,10 +173,11 @@ class Toggle extends ControlTypeMixin(AutoFocusOnMountMixin(FormInternalsMixin(D
173
173
  */
174
174
  handleKeyDown(event) {
175
175
  var _a;
176
- if ((this.readonly || this.softDisabled) && event.key === KEYS.SPACE) {
176
+ const action = this.getActionForKeyEvent(event);
177
+ if ((this.readonly || this.softDisabled) && action === ACTIONS.SPACE) {
177
178
  event.preventDefault();
178
179
  }
179
- if (event.key === KEYS.ENTER) {
180
+ if (action === ACTIONS.ENTER) {
180
181
  (_a = this.form) === null || _a === void 0 ? void 0 : _a.requestSubmit();
181
182
  }
182
183
  }