@momentum-design/components 0.70.3 → 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
  }