@momentum-design/components 0.134.4 → 0.134.5

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.
@@ -44,6 +44,11 @@ declare const Toast_base: import("../../utils/mixins/index.types").Constructor<i
44
44
  * @cssproperty --mdc-toast-padding - Padding inside the toast.
45
45
  */
46
46
  declare class Toast extends Toast_base {
47
+ /**
48
+ * Reference to the header text element
49
+ * @internal
50
+ */
51
+ private headerTextElement;
47
52
  /**
48
53
  * Type of toast
49
54
  * - Can be `custom`, `success`, `warning` or `error`.
@@ -79,6 +84,12 @@ declare class Toast extends Toast_base {
79
84
  showLessText?: string;
80
85
  private isDetailVisible;
81
86
  private hasDetailedSlot;
87
+ /**
88
+ * Indicates whether the header text is overflowing and requires the show more/less toggle button to be shown when detailed content is present.
89
+ * This is determined on first update and will not update dynamically if the header text changes after initial render.
90
+ * @internal
91
+ */
92
+ private hasOverflowingHeaderText;
82
93
  private detailedElements;
83
94
  private hasFooterButtons;
84
95
  /**
@@ -90,7 +101,7 @@ declare class Toast extends Toast_base {
90
101
  private toggleDetailVisibility;
91
102
  private updateDetailedSlotPresence;
92
103
  private updateFooterButtonsPresence;
93
- protected firstUpdated(changedProperties: PropertyValues): void;
104
+ protected firstUpdated(changedProperties: PropertyValues): Promise<void>;
94
105
  protected renderIcon(iconName: string): import("lit-html").TemplateResult<1> | typeof nothing;
95
106
  private shouldRenderToggleButton;
96
107
  private renderToggleDetailButton;
@@ -8,11 +8,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { html, nothing } from 'lit';
11
- import { property, queryAssignedElements, state } from 'lit/decorators.js';
11
+ import { property, query, queryAssignedElements, state } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
13
  import { Component } from '../../models';
14
14
  import { FooterMixin } from '../../utils/mixins/FooterMixin';
15
15
  import { TYPE } from '../text/text.constants';
16
+ import { hasOverflowMixin } from '../../utils/dom';
16
17
  import { DEFAULTS } from './toast.constants';
17
18
  import { getIconNameForVariant } from './toast.utils';
18
19
  import styles from './toast.styles';
@@ -77,6 +78,12 @@ class Toast extends FooterMixin(Component) {
77
78
  this.ariaLabel = null;
78
79
  this.isDetailVisible = false;
79
80
  this.hasDetailedSlot = false;
81
+ /**
82
+ * Indicates whether the header text is overflowing and requires the show more/less toggle button to be shown when detailed content is present.
83
+ * This is determined on first update and will not update dynamically if the header text changes after initial render.
84
+ * @internal
85
+ */
86
+ this.hasOverflowingHeaderText = false;
80
87
  this.hasFooterButtons = '';
81
88
  }
82
89
  /**
@@ -94,6 +101,12 @@ class Toast extends FooterMixin(Component) {
94
101
  }
95
102
  toggleDetailVisibility() {
96
103
  this.isDetailVisible = !this.isDetailVisible;
104
+ if (this.isDetailVisible) {
105
+ this.setAttribute('data-expanded', 'true');
106
+ }
107
+ else {
108
+ this.removeAttribute('data-expanded');
109
+ }
97
110
  }
98
111
  updateDetailedSlotPresence() {
99
112
  var _a, _b;
@@ -108,9 +121,13 @@ class Toast extends FooterMixin(Component) {
108
121
  ? 'has-footer-buttons'
109
122
  : '';
110
123
  }
111
- firstUpdated(changedProperties) {
124
+ async firstUpdated(changedProperties) {
112
125
  super.firstUpdated(changedProperties);
113
126
  this.updateDetailedSlotPresence();
127
+ await this.updateComplete;
128
+ if (hasOverflowMixin(this.headerTextElement)) {
129
+ this.hasOverflowingHeaderText = this.headerTextElement.isHeightOverflowing();
130
+ }
114
131
  }
115
132
  renderIcon(iconName) {
116
133
  if (!iconName)
@@ -120,7 +137,7 @@ class Toast extends FooterMixin(Component) {
120
137
  `;
121
138
  }
122
139
  shouldRenderToggleButton() {
123
- return this.hasDetailedSlot && this.showMoreText && this.showLessText;
140
+ return (this.hasDetailedSlot || this.hasOverflowingHeaderText) && this.showMoreText && this.showLessText;
124
141
  }
125
142
  renderToggleDetailButton() {
126
143
  if (!this.shouldRenderToggleButton())
@@ -193,6 +210,10 @@ class Toast extends FooterMixin(Component) {
193
210
  }
194
211
  }
195
212
  Toast.styles = [...Component.styles, ...styles];
213
+ __decorate([
214
+ query("[part='toast-header']"),
215
+ __metadata("design:type", HTMLElement)
216
+ ], Toast.prototype, "headerTextElement", void 0);
196
217
  __decorate([
197
218
  property({ type: String, reflect: true }),
198
219
  __metadata("design:type", String)
@@ -229,6 +250,10 @@ __decorate([
229
250
  state(),
230
251
  __metadata("design:type", Boolean)
231
252
  ], Toast.prototype, "hasDetailedSlot", void 0);
253
+ __decorate([
254
+ state(),
255
+ __metadata("design:type", Boolean)
256
+ ], Toast.prototype, "hasOverflowingHeaderText", void 0);
232
257
  __decorate([
233
258
  queryAssignedElements({ slot: 'toast-body-detailed', flatten: true }),
234
259
  __metadata("design:type", Array)
@@ -65,6 +65,16 @@ const styles = css `
65
65
  line-height: var(--mds-font-lineheight-body-large);
66
66
  }
67
67
 
68
+ [part='toast-header']::part(text) {
69
+ display: unset;
70
+ -webkit-box-orient: inherit;
71
+ -webkit-line-clamp: inherit;
72
+ }
73
+
74
+ :host([data-expanded='true'])::part(toast-header) {
75
+ -webkit-line-clamp: unset;
76
+ }
77
+
68
78
  :host::part(footer) {
69
79
  display: flex;
70
80
  justify-content: flex-end;
@@ -5160,6 +5160,20 @@
5160
5160
  "attribute": "inverted",
5161
5161
  "reflects": true
5162
5162
  },
5163
+ {
5164
+ "kind": "method",
5165
+ "name": "isHeightOverflowing",
5166
+ "privacy": "public",
5167
+ "return": {
5168
+ "type": {
5169
+ "text": "boolean"
5170
+ }
5171
+ },
5172
+ "inheritedFrom": {
5173
+ "name": "OverflowMixin",
5174
+ "module": "utils/mixins/OverflowMixin.js"
5175
+ }
5176
+ },
5163
5177
  {
5164
5178
  "kind": "method",
5165
5179
  "name": "isWidthOverflowing",
@@ -47421,6 +47435,20 @@
47421
47435
  }
47422
47436
  ],
47423
47437
  "members": [
47438
+ {
47439
+ "kind": "method",
47440
+ "name": "isHeightOverflowing",
47441
+ "privacy": "public",
47442
+ "return": {
47443
+ "type": {
47444
+ "text": "boolean"
47445
+ }
47446
+ },
47447
+ "inheritedFrom": {
47448
+ "name": "OverflowMixin",
47449
+ "module": "utils/mixins/OverflowMixin.js"
47450
+ }
47451
+ },
47424
47452
  {
47425
47453
  "kind": "method",
47426
47454
  "name": "isWidthOverflowing",
@@ -57835,6 +57863,16 @@
57835
57863
  "description": "",
57836
57864
  "name": "OverflowMixin",
57837
57865
  "members": [
57866
+ {
57867
+ "kind": "method",
57868
+ "name": "isHeightOverflowing",
57869
+ "privacy": "public",
57870
+ "return": {
57871
+ "type": {
57872
+ "text": "boolean"
57873
+ }
57874
+ }
57875
+ },
57838
57876
  {
57839
57877
  "kind": "method",
57840
57878
  "name": "isWidthOverflowing",
@@ -57861,6 +57899,16 @@
57861
57899
  "description": "",
57862
57900
  "name": "OverflowMixinInterface",
57863
57901
  "members": [
57902
+ {
57903
+ "kind": "method",
57904
+ "name": "isHeightOverflowing",
57905
+ "privacy": "public",
57906
+ "return": {
57907
+ "type": {
57908
+ "text": "boolean"
57909
+ }
57910
+ }
57911
+ },
57864
57912
  {
57865
57913
  "kind": "method",
57866
57914
  "name": "isWidthOverflowing",
@@ -3,5 +3,6 @@ import type { Constructor } from './index.types';
3
3
  export declare abstract class OverflowMixinInterface {
4
4
  protected get overflowElement(): HTMLElement;
5
5
  isWidthOverflowing(): boolean;
6
+ isHeightOverflowing(): boolean;
6
7
  }
7
8
  export declare const OverflowMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<OverflowMixinInterface> & T;
@@ -17,6 +17,10 @@ export const OverflowMixin = (superClass) => {
17
17
  const el = this.overflowElement;
18
18
  return el.scrollWidth > el.clientWidth;
19
19
  }
20
+ isHeightOverflowing() {
21
+ const el = this.overflowElement;
22
+ return el.scrollHeight > el.clientHeight;
23
+ }
20
24
  }
21
25
  // Cast return type to your mixin's interface intersected with the superClass type
22
26
  return InnerMixinClass;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@momentum-design/components",
3
3
  "packageManager": "yarn@3.2.4",
4
- "version": "0.134.4",
4
+ "version": "0.134.5",
5
5
  "engines": {
6
6
  "node": ">=20.0.0",
7
7
  "npm": ">=8.0.0"