@momentum-design/components 0.70.2 → 0.70.4

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.
@@ -6,7 +6,7 @@ const TAG_NAME = utils.constructTagName('card');
6
6
  const VARIANTS = {
7
7
  BORDER: 'border',
8
8
  GHOST: 'ghost',
9
- PROMOTIONAL: 'promotional', // This is applicable only on interactive-card
9
+ PROMOTIONAL: 'promotional',
10
10
  };
11
11
  const ORIENTATIONS = {
12
12
  HORIZONTAL: 'horizontal',
@@ -12,11 +12,11 @@ const styles = css `
12
12
  border-color: transparent;
13
13
  }
14
14
  :host([orientation="horizontal"]){
15
- width: 40rem;
15
+ max-width: 40rem;
16
16
  }
17
17
 
18
18
  :host([orientation="vertical"]){
19
- width: 20rem;
19
+ max-width: 20rem;
20
20
  flex-direction: column;
21
21
  }
22
22
 
@@ -59,16 +59,25 @@ const styles = css `
59
59
  border-color: var(--mds-color-theme-outline-promotion-normal);
60
60
  }
61
61
 
62
- :host::part(icon-button), :host::part(footer) {
62
+ :host(:dir(ltr))::part(icon-button), :host(:dir(ltr))::part(footer) {
63
63
  margin-left: auto;
64
+ }
65
+
66
+ :host(:dir(rtl))::part(icon-button), :host(:dir(rtl))::part(footer) {
67
+ margin-right: auto;
68
+ }
69
+
70
+ :host::part(icon-button), :host::part(footer) {
64
71
  display: flex;
65
72
  gap: 0.5rem;
66
73
  align-items: center;
67
74
  justify-content: center;
68
75
  }
76
+
69
77
  :host::part(footer){
70
78
  gap: 1rem;
71
79
  }
80
+
72
81
  ::slotted([slot='footer-link']),
73
82
  ::slotted([slot='footer-button-primary']),
74
83
  ::slotted([slot='footer-button-secondary']){
@@ -14,6 +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 { CHECK_MARK, DEFAULTS, SELECTION_TYPE } from './cardcheckbox.constants';
17
+ import { ROLE } from '../../utils/roles';
17
18
  /**
18
19
  * cardcheckbox component extends `mdc-card` and supports checkbox selection interaction addtionally.
19
20
  *
@@ -63,7 +64,7 @@ class CardCheckbox extends DisabledMixin(TabIndexMixin(Card)) {
63
64
  }
64
65
  connectedCallback() {
65
66
  super.connectedCallback();
66
- this.role = 'checkbox';
67
+ this.role = ROLE.CHECKBOX;
67
68
  }
68
69
  update(changedProperties) {
69
70
  super.update(changedProperties);
@@ -72,6 +73,7 @@ class CardCheckbox extends DisabledMixin(TabIndexMixin(Card)) {
72
73
  }
73
74
  if (changedProperties.has('disabled')) {
74
75
  this.setAttribute('aria-disabled', `${this.disabled}`);
76
+ this.tabIndex = this.disabled ? -1 : 0;
75
77
  }
76
78
  }
77
79
  /**
@@ -153,7 +155,7 @@ __decorate([
153
155
  __metadata("design:type", Boolean)
154
156
  ], CardCheckbox.prototype, "checked", void 0);
155
157
  __decorate([
156
- property({ type: String, attribute: 'selection-type' }),
158
+ property({ type: String, attribute: 'selection-type', reflect: true }),
157
159
  __metadata("design:type", String)
158
160
  ], CardCheckbox.prototype, "selectionType", void 0);
159
161
  export default CardCheckbox;
@@ -6,10 +6,14 @@ const styles = css `
6
6
  user-select: none;
7
7
  }
8
8
 
9
- :host::part(check){
9
+ :host(:dir(ltr))::part(check){
10
10
  margin-left: auto;
11
11
  }
12
12
 
13
+ :host(:dir(rtl))::part(check){
14
+ margin-right: auto;
15
+ }
16
+
13
17
  :host(:hover) {
14
18
  background-color: var(--mds-color-theme-background-primary-hover);
15
19
  }
@@ -54,7 +54,9 @@ declare class CardRadio extends CardRadio_base {
54
54
  * Dispatches the change event.
55
55
  */
56
56
  private toggleChecked;
57
+ setDisabled(disabled: boolean): void;
57
58
  update(changedProperties: PropertyValues<CardRadio>): void;
59
+ private updateCardRadio;
58
60
  /**
59
61
  * Toggles the checked state when enter key is used
60
62
  * @param event - The keyboard event
@@ -14,6 +14,7 @@ import styles from './cardradio.styles';
14
14
  import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
15
15
  import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
16
16
  import Card from '../card/card.component';
17
+ import { ROLE } from '../../utils/roles';
17
18
  /**
18
19
  * cardradio component extends `mdc-card` and supports radio selection interaction addtionally.
19
20
  *
@@ -63,7 +64,7 @@ class CardRadio extends DisabledMixin(TabIndexMixin(Card)) {
63
64
  }
64
65
  connectedCallback() {
65
66
  super.connectedCallback();
66
- this.role = 'radio';
67
+ this.role = ROLE.RADIO;
67
68
  }
68
69
  /**
69
70
  * Returns all cards within the same group (name).
@@ -88,20 +89,43 @@ class CardRadio extends DisabledMixin(TabIndexMixin(Card)) {
88
89
  });
89
90
  this.checked = true;
90
91
  }
92
+ setDisabled(disabled) {
93
+ this.setAttribute('aria-disabled', `${disabled}`);
94
+ this.tabIndex = disabled ? -1 : 0;
95
+ }
91
96
  update(changedProperties) {
92
97
  super.update(changedProperties);
93
98
  if (changedProperties.has('checked')) {
94
99
  this.setAttribute('aria-checked', `${this.checked}`);
95
100
  }
96
101
  if (changedProperties.has('disabled')) {
97
- this.setAttribute('aria-disabled', `${this.disabled}`);
102
+ this.setDisabled(this.disabled);
98
103
  }
99
104
  }
105
+ updateCardRadio(cards, index) {
106
+ cards[index].focus();
107
+ cards[index].toggleChecked();
108
+ }
100
109
  /**
101
110
  * Toggles the checked state when enter key is used
102
111
  * @param event - The keyboard event
103
112
  */
104
113
  toggleOnEnter(event) {
114
+ if (this.disabled)
115
+ return;
116
+ const cards = this.getAllCardsWithinSameGroup();
117
+ const enabledCards = cards.filter((card) => !card.disabled);
118
+ const currentIndex = enabledCards.indexOf(this);
119
+ if (['ArrowDown', 'ArrowRight'].includes(event.key)) {
120
+ // Move focus to the next radio
121
+ const nextIndex = (currentIndex + 1) % enabledCards.length;
122
+ this.updateCardRadio(enabledCards, nextIndex);
123
+ }
124
+ else if (['ArrowUp', 'ArrowLeft'].includes(event.key)) {
125
+ // Move focus to the previous radio
126
+ const prevIndex = (currentIndex - 1 + enabledCards.length) % enabledCards.length;
127
+ this.updateCardRadio(enabledCards, prevIndex);
128
+ }
105
129
  if (event.key === 'Enter') {
106
130
  this.toggleChecked();
107
131
  }
@@ -6,10 +6,14 @@ const styles = css `
6
6
  user-select: none;
7
7
  }
8
8
 
9
- :host::part(check){
9
+ :host(:dir(ltr))::part(check){
10
10
  margin-left: auto;
11
11
  }
12
12
 
13
+ :host(:dir(rtl))::part(check){
14
+ margin-right: auto;
15
+ }
16
+
13
17
  :host(:hover) {
14
18
  background-color: var(--mds-color-theme-background-primary-hover);
15
19
  }
@@ -2,6 +2,7 @@ import type { PropertyValues, TemplateResult } from 'lit';
2
2
  import { CSSResult } from 'lit';
3
3
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
4
4
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
5
+ import type { IconNames } from '../icon/icon.types';
5
6
  declare const Select_base: 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
7
  /**
7
8
  * The mdc-select component is a dropdown selection control that allows users to pick an option from a predefined list.
@@ -45,6 +46,8 @@ declare class Select extends Select_base implements AssociatedFormControl {
45
46
  /** @internal */
46
47
  selectedValueText?: string;
47
48
  /** @internal */
49
+ selectedIcon?: IconNames | null;
50
+ /** @internal */
48
51
  selectedValue: string;
49
52
  /** @internal */
50
53
  displayPopover: boolean;
@@ -143,6 +143,7 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
143
143
  setSelectedValue(option) {
144
144
  var _a, _b, _c, _d;
145
145
  this.selectedValueText = (_b = (_a = option === null || option === void 0 ? void 0 : option.getAttribute('label')) !== null && _a !== void 0 ? _a : option === null || option === void 0 ? void 0 : option.textContent) !== null && _b !== void 0 ? _b : '';
146
+ this.selectedIcon = option === null || option === void 0 ? void 0 : option.getAttribute('prefix-icon');
146
147
  this.selectedValue = (_d = (_c = option === null || option === void 0 ? void 0 : option.getAttribute('value')) !== null && _c !== void 0 ? _c : option === null || option === void 0 ? void 0 : option.textContent) !== null && _d !== void 0 ? _d : '';
147
148
  // Set form value
148
149
  this.internals.setFormValue(this.selectedValue);
@@ -176,6 +177,7 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
176
177
  formResetCallback() {
177
178
  this.selectedValue = '';
178
179
  this.selectedValueText = undefined;
180
+ this.selectedIcon = null;
179
181
  this.internals.setFormValue(this.selectedValue);
180
182
  this.updateTabIndexForAllOptions();
181
183
  }
@@ -486,6 +488,9 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
486
488
  aria-labelledby="${this.label ? FORMFIELD_DEFAULTS.HEADING_ID : ''}"
487
489
  aria-expanded="${this.displayPopover ? 'true' : 'false'}"
488
490
  >
491
+ ${this.selectedIcon
492
+ ? html `<mdc-icon length-unit="rem" size="1" name="${this.selectedIcon}" part="selected-icon"></mdc-icon>`
493
+ : nothing}
489
494
  <mdc-text
490
495
  part="base-text ${this.selectedValueText ? 'selected' : ''}"
491
496
  type="${TYPE.BODY_MIDSIZE_REGULAR}"
@@ -529,6 +534,10 @@ __decorate([
529
534
  state(),
530
535
  __metadata("design:type", String)
531
536
  ], Select.prototype, "selectedValueText", void 0);
537
+ __decorate([
538
+ state(),
539
+ __metadata("design:type", Object)
540
+ ], Select.prototype, "selectedIcon", void 0);
532
541
  __decorate([
533
542
  state(),
534
543
  __metadata("design:type", Object)
@@ -42,6 +42,7 @@ const styles = css `
42
42
  background: var(--mdc-select-background-color);
43
43
  display: flex;
44
44
  gap: 0.375rem;
45
+ align-items: center;
45
46
  user-select: none;
46
47
  }
47
48
  :host::part(base-container):hover {
@@ -61,6 +62,9 @@ const styles = css `
61
62
  :host::part(selected) {
62
63
  color: var(--mdc-select-selected-text-color);
63
64
  }
65
+ :host::part(selected-icon) {
66
+ flex-shrink: 0;
67
+ }
64
68
  :host::part(icon-container) {
65
69
  margin-left: auto;
66
70
  display: flex;