@momentum-design/components 0.135.0 → 0.135.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.
@@ -500,13 +500,16 @@ class SpatialNavigationProvider extends Provider {
500
500
  goBack() {
501
501
  const goBackElement = findFocusable(this.root).find(el => el.hasAttribute(DATA_ATTRIBUTES.GO_BACK));
502
502
  const isDefaultPrevented = this.emitGoBackEvent(goBackElement);
503
- if (goBackElement && !isDefaultPrevented) {
504
- goBackElement.click();
505
- return true;
506
- }
507
- if (window.history.length > this.initialHistoryLength) {
508
- window.history.back();
509
- return true;
503
+ // Skip default behavior when event was prevented by the user
504
+ if (!isDefaultPrevented) {
505
+ if (goBackElement) {
506
+ goBackElement.click();
507
+ return true;
508
+ }
509
+ if (window.history.length > this.initialHistoryLength) {
510
+ window.history.back();
511
+ return true;
512
+ }
510
513
  }
511
514
  return false;
512
515
  }
@@ -106,11 +106,14 @@ declare class Toast extends Toast_base {
106
106
  * It is used to notify that the toast should be closed.
107
107
  */
108
108
  private closeToast;
109
+ private updateDataExpanded;
109
110
  private toggleDetailVisibility;
110
111
  private updateDetailedSlotPresence;
111
112
  private updateFooterButtonsPresence;
112
113
  protected firstUpdated(changedProperties: PropertyValues): Promise<void>;
114
+ protected updated(changedProperties: PropertyValues): void;
113
115
  protected renderIcon(iconName: string): import("lit-html").TemplateResult<1> | typeof nothing;
116
+ private canRenderToggleButton;
114
117
  private shouldRenderToggleButton;
115
118
  private renderToggleDetailButton;
116
119
  protected renderHeader(): import("lit-html").TemplateResult<1> | typeof nothing;
@@ -93,15 +93,18 @@ class Toast extends FooterMixin(Component) {
93
93
  });
94
94
  this.dispatchEvent(closeEvent);
95
95
  }
96
- toggleDetailVisibility() {
97
- this.isDetailVisible = !this.isDetailVisible;
98
- if (this.isDetailVisible) {
96
+ updateDataExpanded() {
97
+ if (this.isDetailVisible || !this.canRenderToggleButton()) {
99
98
  this.setAttribute('data-expanded', 'true');
100
99
  }
101
100
  else {
102
101
  this.removeAttribute('data-expanded');
103
102
  }
104
103
  }
104
+ toggleDetailVisibility() {
105
+ this.isDetailVisible = !this.isDetailVisible;
106
+ this.updateDataExpanded();
107
+ }
105
108
  updateDetailedSlotPresence() {
106
109
  var _a, _b;
107
110
  this.hasDetailedSlot = (_b = (_a = this.detailedElements) === null || _a === void 0 ? void 0 : _a.some(el => { var _a; return (_a = el.textContent) === null || _a === void 0 ? void 0 : _a.trim(); })) !== null && _b !== void 0 ? _b : false;
@@ -118,11 +121,17 @@ class Toast extends FooterMixin(Component) {
118
121
  async firstUpdated(changedProperties) {
119
122
  super.firstUpdated(changedProperties);
120
123
  this.updateDetailedSlotPresence();
124
+ this.updateDataExpanded();
121
125
  await this.updateComplete;
122
126
  if (hasOverflowMixin(this.headerTextElement)) {
123
127
  this.hasOverflowingHeaderText = this.headerTextElement.isHeightOverflowing();
124
128
  }
125
129
  }
130
+ updated(changedProperties) {
131
+ if (changedProperties.has('showMoreText') || changedProperties.has('showLessText')) {
132
+ this.updateDataExpanded();
133
+ }
134
+ }
126
135
  renderIcon(iconName) {
127
136
  if (!iconName)
128
137
  return nothing;
@@ -130,8 +139,11 @@ class Toast extends FooterMixin(Component) {
130
139
  <mdc-icon name="${iconName}" size="${DEFAULTS.PREFIX_ICON_SIZE}" part="toast-prefix-icon"></mdc-icon>
131
140
  `;
132
141
  }
142
+ canRenderToggleButton() {
143
+ return !!(this.showMoreText && this.showLessText);
144
+ }
133
145
  shouldRenderToggleButton() {
134
- return (this.hasDetailedSlot || this.hasOverflowingHeaderText) && this.showMoreText && this.showLessText;
146
+ return this.canRenderToggleButton() && (this.hasDetailedSlot || this.hasOverflowingHeaderText);
135
147
  }
136
148
  renderToggleDetailButton() {
137
149
  if (!this.shouldRenderToggleButton())
@@ -55,7 +55,7 @@ const styles = css `
55
55
  :host::part(toast-header) {
56
56
  display: -webkit-box;
57
57
  -webkit-box-orient: vertical;
58
- -webkit-line-clamp: 2;
58
+ -webkit-line-clamp: 3;
59
59
  align-self: stretch;
60
60
  overflow: hidden;
61
61
  text-overflow: ellipsis;
@@ -72,7 +72,7 @@ const styles = css `
72
72
  }
73
73
 
74
74
  :host([data-expanded='true'])::part(toast-header) {
75
- -webkit-line-clamp: unset;
75
+ -webkit-line-clamp: 6;
76
76
  }
77
77
 
78
78
  :host::part(footer) {
@@ -50613,6 +50613,11 @@
50613
50613
  "attribute": "aria-label",
50614
50614
  "reflects": true
50615
50615
  },
50616
+ {
50617
+ "kind": "method",
50618
+ "name": "canRenderToggleButton",
50619
+ "privacy": "private"
50620
+ },
50616
50621
  {
50617
50622
  "kind": "field",
50618
50623
  "name": "closeButtonAriaLabel",
@@ -50777,6 +50782,11 @@
50777
50782
  "name": "toggleDetailVisibility",
50778
50783
  "privacy": "private"
50779
50784
  },
50785
+ {
50786
+ "kind": "method",
50787
+ "name": "updateDataExpanded",
50788
+ "privacy": "private"
50789
+ },
50780
50790
  {
50781
50791
  "kind": "method",
50782
50792
  "name": "updateDetailedSlotPresence",
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@momentum-design/components",
3
3
  "packageManager": "yarn@3.2.4",
4
- "version": "0.135.0",
4
+ "version": "0.135.2",
5
5
  "engines": {
6
- "node": ">=20.0.0",
6
+ "node": ">=24.0.0",
7
7
  "npm": ">=8.0.0"
8
8
  },
9
9
  "main": "./dist/index.js",