@momentum-design/components 0.54.0 → 0.54.2

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.
@@ -80,11 +80,11 @@ declare class Button extends Buttonsimple {
80
80
  /**
81
81
  * @internal
82
82
  */
83
- private prevPrefixIcon?;
83
+ private prefixFilledIconName?;
84
84
  /**
85
85
  * @internal
86
86
  */
87
- private prevPostfixIcon?;
87
+ private postfixFilledIconName?;
88
88
  update(changedProperties: PropertyValues): void;
89
89
  /**
90
90
  * Modifies the icon name based on the active state.
@@ -94,7 +94,7 @@ declare class Button extends Buttonsimple {
94
94
  *
95
95
  * @param active - The active state.
96
96
  */
97
- private modifyIconName;
97
+ private inferFilledIconName;
98
98
  /**
99
99
  * Sets the variant attribute for the button component.
100
100
  * If the provided variant is not included in the BUTTON_VARIANTS,
@@ -83,7 +83,7 @@ class Button extends Buttonsimple {
83
83
  update(changedProperties) {
84
84
  super.update(changedProperties);
85
85
  if (changedProperties.has('active')) {
86
- this.modifyIconName(this.active);
86
+ this.inferFilledIconName(this.active);
87
87
  }
88
88
  if (changedProperties.has('size')) {
89
89
  this.setSize(this.size);
@@ -99,6 +99,7 @@ class Button extends Buttonsimple {
99
99
  this.setSize(this.size);
100
100
  }
101
101
  if (changedProperties.has('prefixIcon') || changedProperties.has('postfixIcon')) {
102
+ this.inferFilledIconName(this.active);
102
103
  this.inferButtonType();
103
104
  }
104
105
  }
@@ -110,24 +111,18 @@ class Button extends Buttonsimple {
110
111
  *
111
112
  * @param active - The active state.
112
113
  */
113
- modifyIconName(active) {
114
+ inferFilledIconName(active) {
114
115
  if (active) {
115
116
  if (this.prefixIcon) {
116
- this.prevPrefixIcon = this.prefixIcon;
117
- this.prefixIcon = `${getIconNameWithoutStyle(this.prefixIcon)}-filled`;
117
+ this.prefixFilledIconName = `${getIconNameWithoutStyle(this.prefixIcon)}-filled`;
118
118
  }
119
119
  if (this.postfixIcon) {
120
- this.prevPostfixIcon = this.postfixIcon;
121
- this.postfixIcon = `${getIconNameWithoutStyle(this.postfixIcon)}-filled`;
120
+ this.postfixFilledIconName = `${getIconNameWithoutStyle(this.postfixIcon)}-filled`;
122
121
  }
123
122
  }
124
123
  else {
125
- if (this.prevPrefixIcon) {
126
- this.prefixIcon = this.prevPrefixIcon;
127
- }
128
- if (this.prevPostfixIcon) {
129
- this.postfixIcon = this.prevPostfixIcon;
130
- }
124
+ this.prefixFilledIconName = this.prefixIcon;
125
+ this.postfixFilledIconName = this.postfixIcon;
131
126
  }
132
127
  }
133
128
  /**
@@ -191,10 +186,12 @@ class Button extends Buttonsimple {
191
186
  }
192
187
  render() {
193
188
  return html `
194
- ${this.prefixIcon ? html ` <mdc-icon name="${this.prefixIcon}" part="prefix-icon"></mdc-icon>` : ''}
189
+ ${this.prefixFilledIconName
190
+ ? html ` <mdc-icon name="${this.prefixFilledIconName}" part="prefix-icon"></mdc-icon>`
191
+ : ''}
195
192
  <slot @slotchange=${this.inferButtonType}></slot>
196
- ${this.postfixIcon
197
- ? html ` <mdc-icon name="${this.postfixIcon}" part="postfix-icon"></mdc-icon>`
193
+ ${this.postfixFilledIconName
194
+ ? html ` <mdc-icon name="${this.postfixFilledIconName}" part="postfix-icon"></mdc-icon>`
198
195
  : ''}
199
196
  `;
200
197
  }
@@ -228,4 +225,12 @@ __decorate([
228
225
  state(),
229
226
  __metadata("design:type", String)
230
227
  ], Button.prototype, "typeInternal", void 0);
228
+ __decorate([
229
+ state(),
230
+ __metadata("design:type", String)
231
+ ], Button.prototype, "prefixFilledIconName", void 0);
232
+ __decorate([
233
+ state(),
234
+ __metadata("design:type", String)
235
+ ], Button.prototype, "postfixFilledIconName", void 0);
231
236
  export default Button;
@@ -75,8 +75,10 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
75
75
  this.setSoftDisabled(this, this.softDisabled);
76
76
  }
77
77
  if (changedProperties.has('active')) {
78
- if (this.active) {
79
- // if active is true and no ariaStateKey is provided, set it to the default (= aria-pressed)
78
+ if (this.active !== undefined) {
79
+ // if active is not undefined and no ariaStateKey is provided, set it to the default (= aria-pressed)
80
+ // this will make sure that if active is set to true or false regardless
81
+ // the ariaStateKey fallback will still work
80
82
  this.ariaStateKey = this.ariaStateKey || DEFAULTS.ARIA_STATE_KEY;
81
83
  }
82
84
  this.setActive(this, this.active);