@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
@@ -4,7 +4,7 @@ import { Component } from '../../models';
4
4
  import type { Size } from '../accordiongroup/accordiongroup.types';
5
5
  import type { IconNames } from '../icon/icon.types';
6
6
  import type { IconName, Variant } from './accordionbutton.types';
7
- declare const AccordionButton_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
7
+ declare const AccordionButton_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
8
8
  /**
9
9
  * An accordion button is a vertically stacked component with a clickable header and expandable/collapsible body section.
10
10
  * The entire header is clickable to toggle the visibility of the body content.
@@ -11,10 +11,10 @@ import { html, nothing } from 'lit';
11
11
  import { v4 as uuidv4 } from 'uuid';
12
12
  import { property } from 'lit/decorators.js';
13
13
  import { Component } from '../../models';
14
- import { KEYS } from '../../utils/keys';
15
14
  import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
16
15
  import { ROLE } from '../../utils/roles';
17
16
  import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
17
+ import { KeyToActionMixin, ACTIONS } from '../../utils/mixins/KeyToActionMixin';
18
18
  import { DEFAULTS, ICON_NAME } from './accordionbutton.constants';
19
19
  import styles from './accordionbutton.styles';
20
20
  /**
@@ -63,7 +63,7 @@ import styles from './accordionbutton.styles';
63
63
  * @csspart trailing-header - The trailing header of the accordion button.
64
64
  * @csspart trailing-header__icon - The trailing header icon of the accordion button.
65
65
  */
66
- class AccordionButton extends DisabledMixin(Component) {
66
+ class AccordionButton extends KeyToActionMixin(DisabledMixin(Component)) {
67
67
  constructor() {
68
68
  super(...arguments);
69
69
  /**
@@ -128,7 +128,8 @@ class AccordionButton extends DisabledMixin(Component) {
128
128
  * @param event - The KeyboardEvent fired.
129
129
  */
130
130
  handleKeyDown(event) {
131
- if (event.key === KEYS.ENTER || event.key === KEYS.SPACE) {
131
+ const action = this.getActionForKeyEvent(event);
132
+ if (action === ACTIONS.ENTER || action === ACTIONS.SPACE) {
132
133
  this.handleHeaderClick();
133
134
  }
134
135
  }
@@ -3,7 +3,7 @@ import { CSSResult } from 'lit';
3
3
  import { Component } from '../../models';
4
4
  import type { RoleType } from '../../utils/roles';
5
5
  import type { ButtonSize, ButtonType } from './buttonsimple.types';
6
- declare const Buttonsimple_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
6
+ declare const Buttonsimple_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
7
7
  /**
8
8
  * `mdc-buttonsimple` is a component that can be configured in various ways to suit different use cases.
9
9
  * It is used as an internal component and is not intended to be used directly by consumers.
@@ -10,10 +10,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { html } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
12
  import { Component } from '../../models';
13
- import { KEYS } from '../../utils/keys';
14
13
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
15
14
  import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
16
15
  import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
16
+ import { KeyToActionMixin, ACTIONS } from '../../utils/mixins/KeyToActionMixin';
17
17
  import { BUTTON_TYPE, DEFAULTS } from './buttonsimple.constants';
18
18
  import styles from './buttonsimple.styles';
19
19
  /**
@@ -35,7 +35,7 @@ import styles from './buttonsimple.styles';
35
35
  * @cssproperty --mdc-button-border-color - Border color of the button
36
36
  * @cssproperty --mdc-button-text-color - Text color of the button
37
37
  */
38
- class Buttonsimple extends AutoFocusOnMountMixin(TabIndexMixin(DisabledMixin(Component))) {
38
+ class Buttonsimple extends KeyToActionMixin(AutoFocusOnMountMixin(TabIndexMixin(DisabledMixin(Component)))) {
39
39
  /** @internal */
40
40
  get form() {
41
41
  return this.internals.form;
@@ -190,9 +190,10 @@ class Buttonsimple extends AutoFocusOnMountMixin(TabIndexMixin(DisabledMixin(Com
190
190
  * @param event - The keyboard event.
191
191
  */
192
192
  handleKeyDown(event) {
193
- if ([KEYS.ENTER, KEYS.SPACE].includes(event.key)) {
193
+ const action = this.getActionForKeyEvent(event);
194
+ if (action === ACTIONS.ENTER || action === ACTIONS.SPACE) {
194
195
  this.classList.add('pressed');
195
- if (event.key === KEYS.ENTER) {
196
+ if (action === ACTIONS.ENTER) {
196
197
  this.triggerClickEvent();
197
198
  }
198
199
  // preventing the default event behavior for space key
@@ -210,9 +211,10 @@ class Buttonsimple extends AutoFocusOnMountMixin(TabIndexMixin(DisabledMixin(Com
210
211
  * @param event - The keyboard event.
211
212
  */
212
213
  handleKeyUp(event) {
213
- if ([KEYS.ENTER, KEYS.SPACE].includes(event.key)) {
214
+ const action = this.getActionForKeyEvent(event);
215
+ if (action === ACTIONS.ENTER || action === ACTIONS.SPACE) {
214
216
  this.classList.remove('pressed');
215
- if (event.key === KEYS.SPACE) {
217
+ if (action === ACTIONS.SPACE) {
216
218
  this.triggerClickEvent();
217
219
  }
218
220
  }
@@ -1,7 +1,7 @@
1
1
  import { CSSResult, nothing, PropertyValues } from 'lit';
2
2
  import Card from '../card/card.component';
3
3
  import type { SelectionType } from './cardcheckbox.types';
4
- declare const CardCheckbox_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Card;
4
+ declare const CardCheckbox_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Card;
5
5
  /**
6
6
  * cardcheckbox component extends `mdc-card` and supports checkbox selection interaction.
7
7
  * Multiple cards can be checked simultaneously.
@@ -13,7 +13,7 @@ import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
13
13
  import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
14
14
  import Card from '../card/card.component';
15
15
  import { ROLE } from '../../utils/roles';
16
- import { KEYS } from '../../utils/keys';
16
+ import { KeyToActionMixin, ACTIONS } from '../../utils/mixins/KeyToActionMixin';
17
17
  import { CHECK_MARK, DEFAULTS, SELECTION_TYPE } from './cardcheckbox.constants';
18
18
  import styles from './cardcheckbox.styles';
19
19
  /**
@@ -67,7 +67,7 @@ import styles from './cardcheckbox.styles';
67
67
  *
68
68
  * @cssproperty --mdc-card-width - The width of the card
69
69
  */
70
- class CardCheckbox extends DisabledMixin(TabIndexMixin(Card)) {
70
+ class CardCheckbox extends KeyToActionMixin(DisabledMixin(TabIndexMixin(Card))) {
71
71
  constructor() {
72
72
  super();
73
73
  /**
@@ -114,10 +114,12 @@ class CardCheckbox extends DisabledMixin(TabIndexMixin(Card)) {
114
114
  * @param event - The keyboard event
115
115
  */
116
116
  handleKeyDown(event) {
117
- if (event.key === KEYS.ENTER) {
117
+ const action = this.getActionForKeyEvent(event);
118
+ if (action === ACTIONS.ENTER) {
118
119
  this.toggleChecked();
120
+ event.preventDefault();
119
121
  }
120
- else if (event.key === KEYS.SPACE) {
122
+ if (action === ACTIONS.SPACE) {
121
123
  event.preventDefault();
122
124
  }
123
125
  }
@@ -126,7 +128,7 @@ class CardCheckbox extends DisabledMixin(TabIndexMixin(Card)) {
126
128
  * @param event - The keyboard event
127
129
  */
128
130
  toggleOnSpace(event) {
129
- if (event.key === KEYS.SPACE) {
131
+ if (this.getActionForKeyEvent(event) === ACTIONS.SPACE) {
130
132
  event.preventDefault();
131
133
  this.toggleChecked();
132
134
  }
@@ -1,6 +1,6 @@
1
1
  import { CSSResult, nothing, PropertyValues } from 'lit';
2
2
  import Card from '../card/card.component';
3
- declare const CardRadio_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Card;
3
+ declare const CardRadio_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Card;
4
4
  /**
5
5
  * cardradio component extends `mdc-card` and supports radio selection interaction.
6
6
  * Only one card can be selected at a time within the same group (defined by `name` attribute).
@@ -14,7 +14,7 @@ import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
14
14
  import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
15
15
  import Card from '../card/card.component';
16
16
  import { ROLE } from '../../utils/roles';
17
- import { KEYS } from '../../utils/keys';
17
+ import { KeyToActionMixin, ACTIONS } from '../../utils/mixins/KeyToActionMixin';
18
18
  import styles from './cardradio.styles';
19
19
  /**
20
20
  * cardradio component extends `mdc-card` and supports radio selection interaction.
@@ -68,7 +68,7 @@ import styles from './cardradio.styles';
68
68
  *
69
69
  * @cssproperty --mdc-card-width - The width of the card
70
70
  */
71
- class CardRadio extends DisabledMixin(TabIndexMixin(Card)) {
71
+ class CardRadio extends KeyToActionMixin(DisabledMixin(TabIndexMixin(Card))) {
72
72
  constructor() {
73
73
  super();
74
74
  /**
@@ -136,7 +136,8 @@ class CardRadio extends DisabledMixin(TabIndexMixin(Card)) {
136
136
  * @param event - The keyboard event
137
137
  */
138
138
  handleKeyDown(event) {
139
- if (event.key === KEYS.SPACE) {
139
+ const action = this.getActionForKeyEvent(event);
140
+ if (action === ACTIONS.SPACE) {
140
141
  event.preventDefault();
141
142
  return;
142
143
  }
@@ -145,17 +146,17 @@ class CardRadio extends DisabledMixin(TabIndexMixin(Card)) {
145
146
  const cards = this.getAllCardsWithinSameGroup();
146
147
  const enabledCards = cards.filter(card => !card.disabled);
147
148
  const currentIndex = enabledCards.indexOf(this);
148
- if (['ArrowDown', 'ArrowRight'].includes(event.key)) {
149
+ if (action === ACTIONS.DOWN || ACTIONS.RIGHT === action) {
149
150
  // Move focus to the next radio
150
151
  const nextIndex = (currentIndex + 1) % enabledCards.length;
151
152
  this.updateCardRadio(enabledCards, nextIndex);
152
153
  }
153
- else if (['ArrowUp', 'ArrowLeft'].includes(event.key)) {
154
+ else if (action === ACTIONS.UP || ACTIONS.LEFT === action) {
154
155
  // Move focus to the previous radio
155
156
  const prevIndex = (currentIndex - 1 + enabledCards.length) % enabledCards.length;
156
157
  this.updateCardRadio(enabledCards, prevIndex);
157
158
  }
158
- if (event.key === KEYS.ENTER) {
159
+ if (action === ACTIONS.ENTER) {
159
160
  this.toggleChecked();
160
161
  }
161
162
  }
@@ -164,7 +165,7 @@ class CardRadio extends DisabledMixin(TabIndexMixin(Card)) {
164
165
  * @param event - The keyboard event
165
166
  */
166
167
  toggleOnSpace(event) {
167
- if (event.key === KEYS.SPACE) {
168
+ if (this.getActionForKeyEvent(event) === ACTIONS.SPACE) {
168
169
  this.toggleChecked();
169
170
  }
170
171
  }
@@ -2,7 +2,7 @@ import { CSSResult, PropertyValueMap, PropertyValues } from 'lit';
2
2
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
3
3
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
4
4
  import type { CheckboxValidationType } from './checkbox.types';
5
- declare const Checkbox_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 Checkbox_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
  * The Checkbox component allows users to select one or multiple options from a list, toggle features on/off,
8
8
  * or indicate agreement in forms and settings. These are commonly used in forms, lists, and settings panels
@@ -13,6 +13,7 @@ declare const Checkbox_base: import("../../utils/mixins/index.types").Constructo
13
13
  * **Note:** This component internally renders a native checkbox input element with custom styling.
14
14
  *
15
15
  * ## When to use
16
+ *
16
17
  * Use checkboxes when users can select multiple options from a list, or when a single checkbox represents a binary choice (e.g., agreeing to terms).
17
18
  *
18
19
  * ## Accessibility
@@ -10,12 +10,12 @@ 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 { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
16
15
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
17
16
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
18
17
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
18
+ import { KeyToActionMixin, ACTIONS } from '../../utils/mixins/KeyToActionMixin';
19
19
  import styles from './checkbox.styles';
20
20
  import { CHECKBOX_VALIDATION } from './checkbox.constants';
21
21
  /**
@@ -28,6 +28,7 @@ import { CHECKBOX_VALIDATION } from './checkbox.constants';
28
28
  * **Note:** This component internally renders a native checkbox input element with custom styling.
29
29
  *
30
30
  * ## When to use
31
+ *
31
32
  * Use checkboxes when users can select multiple options from a list, or when a single checkbox represents a binary choice (e.g., agreeing to terms).
32
33
  *
33
34
  * ## Accessibility
@@ -62,7 +63,7 @@ import { CHECKBOX_VALIDATION } from './checkbox.constants';
62
63
  * @csspart text-container - The container for the label and helper text elements.
63
64
  * @csspart static-checkbox - The staticcheckbox that provides the visual checkbox appearance.
64
65
  */
65
- class Checkbox extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))) {
66
+ class Checkbox extends KeyToActionMixin(KeyToActionMixin(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))))) {
66
67
  constructor() {
67
68
  super(...arguments);
68
69
  /**
@@ -177,11 +178,13 @@ class Checkbox extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMix
177
178
  */
178
179
  handleKeyDown(event) {
179
180
  var _a;
180
- if ((this.readonly || this.softDisabled) && event.key === KEYS.SPACE) {
181
+ const action = this.getActionForKeyEvent(event);
182
+ if ((this.readonly || this.softDisabled) && action === ACTIONS.SPACE) {
181
183
  event.preventDefault();
182
184
  }
183
- if (event.key === KEYS.ENTER) {
185
+ if (action === ACTIONS.ENTER) {
184
186
  (_a = this.form) === null || _a === void 0 ? void 0 : _a.requestSubmit();
187
+ event.preventDefault();
185
188
  }
186
189
  }
187
190
  /**
@@ -4,7 +4,7 @@ import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
4
4
  import type Option from '../option/option.component';
5
5
  import type { PopoverStrategy } from '../popover/popover.types';
6
6
  import type { Placement } from './combobox.types';
7
- declare const Combobox_base: 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;
7
+ declare const Combobox_base: import("../../utils/mixins/index.types").Constructor<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;
8
8
  /**
9
9
  * The Combobox component is a text-based dropdown control that allows users to select an option from a predefined list.
10
10
  * Users can type text to filter the options and select their desired choice.
@@ -12,7 +12,6 @@ import { property, query, queryAssignedElements, state } from 'lit/decorators.js
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
13
  import { live } from 'lit/directives/live.js';
14
14
  import { ElementStore } from '../../utils/controllers/ElementStore';
15
- import { KEYS } from '../../utils/keys';
16
15
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
17
16
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
18
17
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
@@ -28,6 +27,7 @@ import { TAG_NAME as OPTIONGROUP_TAG_NAME } from '../optgroup/optgroup.constants
28
27
  import { TAG_NAME as OPTION_TAG_NAME } from '../option/option.constants';
29
28
  import { DEFAULTS as POPOVER_DEFAULTS, POPOVER_PLACEMENT, TRIGGER } from '../popover/popover.constants';
30
29
  import { TAG_NAME as SELECTLISTBOX_TAG_NAME } from '../selectlistbox/selectlistbox.constants';
30
+ import { KeyToActionMixin, ACTIONS } from '../../utils/mixins/KeyToActionMixin';
31
31
  import { AUTOCOMPLETE_LIST, ICON_NAME, TRIGGER_ID } from './combobox.constants';
32
32
  import { ComboboxEventManager } from './combobox.events';
33
33
  import styles from './combobox.styles';
@@ -105,7 +105,7 @@ import styles from './combobox.styles';
105
105
  * @csspart combobox__button - The button element of the combobox.
106
106
  * @csspart combobox__button-icon - The icon element of the button of the combobox.
107
107
  */
108
- class Combobox extends CaptureDestroyEventForChildElement(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)))) {
108
+ class Combobox extends KeyToActionMixin(CaptureDestroyEventForChildElement(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))))) {
109
109
  /** @internal */
110
110
  get navItems() {
111
111
  return this.itemsStore.items;
@@ -440,31 +440,31 @@ class Combobox extends CaptureDestroyEventForChildElement(AutoFocusOnMountMixin(
440
440
  handleInputKeydown(event) {
441
441
  const options = this.getVisibleOptions(this.filteredValue);
442
442
  const activeIndex = options.findIndex(option => option.hasAttribute('data-focused'));
443
- switch (event.key) {
444
- case KEYS.ARROW_DOWN: {
443
+ switch (this.getActionForKeyEvent(event)) {
444
+ case ACTIONS.DOWN: {
445
445
  this.openPopover();
446
446
  const newIndex = options.length - 1 === activeIndex ? 0 : activeIndex + 1;
447
447
  this.updateFocusAndScrollIntoView(options, activeIndex, newIndex);
448
448
  event.preventDefault();
449
449
  break;
450
450
  }
451
- case KEYS.ARROW_UP: {
451
+ case ACTIONS.UP: {
452
452
  this.openPopover();
453
453
  const newIndex = activeIndex === -1 || activeIndex === 0 ? options.length - 1 : activeIndex - 1;
454
454
  this.updateFocusAndScrollIntoView(options, activeIndex, newIndex);
455
455
  event.preventDefault();
456
456
  break;
457
457
  }
458
- case KEYS.ENTER: {
458
+ case ACTIONS.ENTER: {
459
459
  if (activeIndex === -1)
460
460
  return;
461
461
  this.setSelectedValue(options[activeIndex]);
462
- if (this.isOpen === true) {
462
+ if (this.isOpen) {
463
463
  this.closePopover();
464
464
  }
465
465
  break;
466
466
  }
467
- case KEYS.ESCAPE: {
467
+ case ACTIONS.ESCAPE: {
468
468
  if (activeIndex !== -1) {
469
469
  this.updateOptionAttributes(options[activeIndex], false);
470
470
  }
@@ -478,12 +478,12 @@ class Combobox extends CaptureDestroyEventForChildElement(AutoFocusOnMountMixin(
478
478
  }
479
479
  break;
480
480
  }
481
- case KEYS.TAB: {
481
+ case ACTIONS.TAB: {
482
482
  this.closePopover();
483
483
  break;
484
484
  }
485
- case KEYS.HOME:
486
- case KEYS.END: {
485
+ case ACTIONS.HOME:
486
+ case ACTIONS.END: {
487
487
  this.resetFocusedOption();
488
488
  break;
489
489
  }
@@ -3,7 +3,7 @@ import FormfieldWrapper from '../formfieldwrapper';
3
3
  import type { IconNames } from '../icon/icon.types';
4
4
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
5
5
  import type { AutoCapitalizeType, AutoCompleteType, InputType } from './input.types';
6
- declare const Input_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;
6
+ declare const Input_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;
7
7
  /**
8
8
  * mdc-input is a component that allows users to input text.
9
9
  * It contains:
@@ -15,8 +15,8 @@ import FormfieldWrapper from '../formfieldwrapper';
15
15
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
16
16
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
17
17
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
18
- import { KEYS } from '../../utils/keys';
19
18
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
19
+ import { KeyToActionMixin, ACTIONS } from '../../utils/mixins/KeyToActionMixin';
20
20
  import { AUTO_CAPITALIZE, AUTO_COMPLETE, DEFAULTS, PREFIX_TEXT_OPTIONS } from './input.constants';
21
21
  import styles from './input.styles';
22
22
  /**
@@ -84,7 +84,7 @@ import styles from './input.styles';
84
84
  * @csspart input-text - The input field element.
85
85
  * @csspart trailing-button - The trailing button element that is displayed to clear the input field when the `trailingButton` property is set to true.
86
86
  */
87
- class Input extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))) {
87
+ class Input extends KeyToActionMixin(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)))) {
88
88
  constructor() {
89
89
  super(...arguments);
90
90
  /**
@@ -225,7 +225,7 @@ class Input extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(
225
225
  */
226
226
  handleKeyDown(event) {
227
227
  var _a;
228
- if (event.key === KEYS.ENTER) {
228
+ if (this.getActionForKeyEvent(event) === ACTIONS.ENTER) {
229
229
  (_a = this.form) === null || _a === void 0 ? void 0 : _a.requestSubmit();
230
230
  }
231
231
  }
@@ -3,7 +3,7 @@ import { Component } from '../../models';
3
3
  import { ElementStoreChangeTypes } from '../../utils/controllers/ElementStore';
4
4
  import type ListItem from '../listitem';
5
5
  import type { BaseArray } from '../../utils/virtualIndexArray';
6
- declare const List_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/ListNavigationMixin").ListNavigationMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement").CaptureDestroyEventForChildElementInterface> & typeof Component;
6
+ declare const List_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/ListNavigationMixin").ListNavigationMixinInterface & import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement").CaptureDestroyEventForChildElementInterface> & typeof Component;
7
7
  /**
8
8
  * mdc-list component is used to display a group of list items. It is used as a container to wrap other list items.
9
9
  *
@@ -1,7 +1,7 @@
1
1
  import { CSSResult, PropertyValues } from 'lit';
2
2
  import type Option from '../option';
3
3
  import { Component } from '../../models';
4
- declare const ListBox_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/ListNavigationMixin").ListNavigationMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement").CaptureDestroyEventForChildElementInterface> & typeof Component;
4
+ declare const ListBox_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/ListNavigationMixin").ListNavigationMixinInterface & import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement").CaptureDestroyEventForChildElementInterface> & typeof Component;
5
5
  /**
6
6
  * listbox component presents a list of options and allows a user to select one of them.
7
7
  *
@@ -2,7 +2,7 @@ import { CSSResult, PropertyValues, TemplateResult } from 'lit';
2
2
  import { Component } from '../../models';
3
3
  import type { TextType } from '../text/text.types';
4
4
  import { ListItemVariants } from './listitem.types';
5
- declare const ListItem_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/LifeCycleMixin").LifeCycleMixinInterface> & typeof Component;
5
+ declare const ListItem_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/LifeCycleMixin").LifeCycleMixinInterface> & typeof Component;
6
6
  /**
7
7
  * mdc-listitem component is used to display a label with different types of controls.
8
8
  * There can be three types of controls, a radio button, a checkbox on the
@@ -10,12 +10,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { html, nothing } from 'lit';
11
11
  import { property, queryAssignedElements } from 'lit/decorators.js';
12
12
  import { Component } from '../../models';
13
- import { KEYS } from '../../utils/keys';
14
13
  import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
15
14
  import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
16
15
  import { ROLE } from '../../utils/roles';
17
16
  import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
18
17
  import { LifeCycleMixin } from '../../utils/mixins/lifecycle/LifeCycleMixin';
18
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
19
19
  import { DEFAULTS } from './listitem.constants';
20
20
  import { ListItemEventManager } from './listitem.events';
21
21
  import styles from './listitem.styles';
@@ -76,7 +76,7 @@ import styles from './listitem.styles';
76
76
  * @event created - (React: onCreated) This event is dispatched after the listitem is created (added to the DOM)
77
77
  * @event destroyed - (React: onDestroyed) This event is dispatched after the listitem is destroyed (removed from the DOM)
78
78
  */
79
- class ListItem extends DisabledMixin(TabIndexMixin(LifeCycleMixin(Component))) {
79
+ class ListItem extends KeyToActionMixin(DisabledMixin(TabIndexMixin(LifeCycleMixin(Component)))) {
80
80
  constructor() {
81
81
  super();
82
82
  /**
@@ -110,7 +110,8 @@ class ListItem extends DisabledMixin(TabIndexMixin(LifeCycleMixin(Component))) {
110
110
  * @param event - The keyboard event triggered when a key is pressed down.
111
111
  */
112
112
  handleKeyDown(event) {
113
- if (event.key === KEYS.ENTER || event.key === KEYS.SPACE) {
113
+ const action = this.getActionForKeyEvent(event);
114
+ if (action === ACTIONS.ENTER || action === ACTIONS.SPACE) {
114
115
  const eventDispatched = this.triggerClickEvent(event);
115
116
  if (eventDispatched) {
116
117
  event.preventDefault();
@@ -219,8 +220,13 @@ class ListItem extends DisabledMixin(TabIndexMixin(LifeCycleMixin(Component))) {
219
220
  * @param event - The mouse event triggered when a click occurs.
220
221
  */
221
222
  stopEventPropagation(event) {
222
- if ((event instanceof KeyboardEvent && (event.key === KEYS.ENTER || event.key === KEYS.SPACE)) ||
223
- event instanceof MouseEvent) {
223
+ if (event instanceof KeyboardEvent) {
224
+ const action = this.getActionForKeyEvent(event);
225
+ if (action === ACTIONS.ENTER || action === ACTIONS.SPACE) {
226
+ event.stopPropagation();
227
+ }
228
+ }
229
+ else if (event instanceof MouseEvent) {
224
230
  event.stopPropagation();
225
231
  }
226
232
  }
@@ -1,5 +1,6 @@
1
1
  import type { CSSResult, PropertyValues } from 'lit';
2
2
  import { Component } from '../../models';
3
+ declare const MenuBar_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/KeyToActionMixin").KeyToActionInterface> & typeof Component;
3
4
  /**
4
5
  * Menubar is a navigational menu component that provides a vertical fixed list of menu items,
5
6
  * with support for nested submenus and keyboard navigation. It serves as a container
@@ -23,7 +24,7 @@ import { Component } from '../../models';
23
24
  * @tagname mdc-menubar
24
25
  * @slot default - Contains the menu items and their associated popovers
25
26
  */
26
- declare class MenuBar extends Component {
27
+ declare class MenuBar extends MenuBar_base {
27
28
  menusections: Array<HTMLElement>;
28
29
  constructor();
29
30
  connectedCallback(): Promise<void>;
@@ -60,7 +61,6 @@ declare class MenuBar extends Component {
60
61
  private updatePopoverPlacement;
61
62
  private updateTabIndexAndFocus;
62
63
  private navigateToMenuItem;
63
- private getKeyWithDirectionFix;
64
64
  /**
65
65
  * Determines if a menuitem is a top-level menuitem (direct child of menubar or child of menusection whose parent is menubar)
66
66
  */
@@ -15,8 +15,8 @@ import { POPOVER_PLACEMENT } from '../popover/popover.constants';
15
15
  import { TAG_NAME as MENUPOPOVER_TAGNAME } from '../menupopover/menupopover.constants';
16
16
  import { TAG_NAME as MENUSECTION_TAGNAME } from '../menusection/menusection.constants';
17
17
  import { TAG_NAME as SIDENAV_TAGNAME } from '../sidenavigation/sidenavigation.constants';
18
- import { KEYS } from '../../utils/keys';
19
18
  import { popoverStack } from '../popover/popover.stack';
19
+ import { ACTIONS, KeyToActionMixin } from '../../utils/mixins/KeyToActionMixin';
20
20
  import { DEFAULTS, TAG_NAME as MENUBAR_TAGNAME } from './menubar.constants';
21
21
  import styles from './menubar.styles';
22
22
  /**
@@ -42,7 +42,7 @@ import styles from './menubar.styles';
42
42
  * @tagname mdc-menubar
43
43
  * @slot default - Contains the menu items and their associated popovers
44
44
  */
45
- class MenuBar extends Component {
45
+ class MenuBar extends KeyToActionMixin(Component) {
46
46
  constructor() {
47
47
  super();
48
48
  this.addEventListener('click', this.handleClick.bind(this));
@@ -206,16 +206,6 @@ class MenuBar extends Component {
206
206
  }
207
207
  }
208
208
  }
209
- getKeyWithDirectionFix(originalKey) {
210
- const isRtl = window.getComputedStyle(this).direction === 'rtl';
211
- if (!isRtl)
212
- return originalKey;
213
- if (originalKey === KEYS.ARROW_LEFT)
214
- return KEYS.ARROW_RIGHT;
215
- if (originalKey === KEYS.ARROW_RIGHT)
216
- return KEYS.ARROW_LEFT;
217
- return originalKey;
218
- }
219
209
  /**
220
210
  * Determines if a menuitem is a top-level menuitem (direct child of menubar or child of menusection whose parent is menubar)
221
211
  */
@@ -294,30 +284,30 @@ class MenuBar extends Component {
294
284
  }
295
285
  async handleKeyDown(event) {
296
286
  const currentIndex = this.getCurrentIndex(event.target);
297
- const key = this.getKeyWithDirectionFix(event.key);
298
- switch (key) {
299
- case KEYS.HOME:
287
+ const action = this.getActionForKeyEvent(event, true);
288
+ switch (action) {
289
+ case ACTIONS.HOME:
300
290
  this.updateTabIndexAndFocus(this.menuItems, currentIndex, 0);
301
291
  break;
302
- case KEYS.END:
292
+ case ACTIONS.END:
303
293
  this.updateTabIndexAndFocus(this.menuItems, currentIndex, this.menuItems.length - 1);
304
294
  break;
305
- case KEYS.ARROW_LEFT: {
295
+ case ACTIONS.LEFT: {
306
296
  const element = currentIndex >= 0 ? this.menuItems[currentIndex] : event.target;
307
297
  await this.crossMenubarNavigationOnLeft(element);
308
298
  break;
309
299
  }
310
- case KEYS.ARROW_RIGHT: {
300
+ case ACTIONS.RIGHT: {
311
301
  const element = currentIndex >= 0 ? this.menuItems[currentIndex] : event.target;
312
302
  await this.crossMenubarNavigationOnRight(element);
313
303
  break;
314
304
  }
315
- case KEYS.ARROW_UP: {
305
+ case ACTIONS.UP: {
316
306
  this.navigateToMenuItem(currentIndex, 'prev');
317
307
  event.preventDefault();
318
308
  break;
319
309
  }
320
- case KEYS.ARROW_DOWN: {
310
+ case ACTIONS.DOWN: {
321
311
  this.navigateToMenuItem(currentIndex, 'next');
322
312
  event.preventDefault();
323
313
  break;