@momentum-design/components 0.135.1 → 0.136.0

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.
@@ -24,6 +24,11 @@ import type { SkeletonVariant } from './skeleton.types';
24
24
  * @cssproperty --mdc-skeleton-width - width of the skeleton
25
25
  */
26
26
  declare class Skeleton extends Component {
27
+ /**
28
+ * When true, displays the skeleton with motion applied.
29
+ * @default false
30
+ */
31
+ motion?: boolean;
27
32
  /**
28
33
  * The variant of skeleton to display
29
34
  * - **rectangular**: Default rectangular shape with 0.25rem border radius
@@ -24,6 +24,11 @@ import styles from './skeleton.styles';
24
24
  class Skeleton extends Component {
25
25
  constructor() {
26
26
  super(...arguments);
27
+ /**
28
+ * When true, displays the skeleton with motion applied.
29
+ * @default false
30
+ */
31
+ this.motion = DEFAULTS.MOTION;
27
32
  /**
28
33
  * The variant of skeleton to display
29
34
  * - **rectangular**: Default rectangular shape with 0.25rem border radius
@@ -63,6 +68,10 @@ class Skeleton extends Component {
63
68
  * Styles associated with this component.
64
69
  */
65
70
  Skeleton.styles = [...Component.styles, styles];
71
+ __decorate([
72
+ property({ type: Boolean, reflect: true }),
73
+ __metadata("design:type", Boolean)
74
+ ], Skeleton.prototype, "motion", void 0);
66
75
  __decorate([
67
76
  property({ type: String, reflect: true }),
68
77
  __metadata("design:type", String)
@@ -6,6 +6,7 @@ declare const SKELETON_VARIANTS: {
6
6
  readonly ROUNDED: "rounded";
7
7
  };
8
8
  declare const DEFAULTS: {
9
+ readonly MOTION: false;
9
10
  readonly VARIANT: "rectangular";
10
11
  };
11
12
  export { TAG_NAME, SKELETON_VARIANTS, DEFAULTS };
@@ -7,6 +7,7 @@ const SKELETON_VARIANTS = {
7
7
  ROUNDED: 'rounded',
8
8
  };
9
9
  const DEFAULTS = {
10
+ MOTION: false,
10
11
  VARIANT: SKELETON_VARIANTS.RECTANGULAR,
11
12
  };
12
13
  export { TAG_NAME, SKELETON_VARIANTS, DEFAULTS };
@@ -11,6 +11,35 @@ const styles = css `
11
11
  width: var(--mdc-skeleton-width);
12
12
  }
13
13
 
14
+ :host([motion]) {
15
+ background-image: linear-gradient(
16
+ 90deg,
17
+ var(--mds-color-theme-background-skeleton-shimmer-0) 0%,
18
+ var(--mds-color-theme-background-skeleton-shimmer-1) 50%,
19
+ var(--mds-color-theme-background-skeleton-shimmer-2) 100%
20
+ );
21
+ background-repeat: no-repeat;
22
+ background-size: 200% 100%;
23
+ animation: skeleton-shimmer 2s linear infinite;
24
+ }
25
+
26
+ @media (prefers-reduced-motion: reduce) {
27
+ :host([motion]) {
28
+ animation: none;
29
+ background-position: 50% 0;
30
+ }
31
+ }
32
+
33
+ @keyframes skeleton-shimmer {
34
+ 0% {
35
+ background-position: 200% 0;
36
+ }
37
+
38
+ 100% {
39
+ background-position: -200% 0;
40
+ }
41
+ }
42
+
14
43
  :host([variant='rectangular']) {
15
44
  border-radius: 0.25rem;
16
45
  }
@@ -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) {
@@ -44195,6 +44195,17 @@
44195
44195
  }
44196
44196
  }
44197
44197
  },
44198
+ {
44199
+ "kind": "field",
44200
+ "name": "motion",
44201
+ "type": {
44202
+ "text": "boolean | undefined"
44203
+ },
44204
+ "description": "When true, displays the skeleton with motion applied.",
44205
+ "default": "false",
44206
+ "attribute": "motion",
44207
+ "reflects": true
44208
+ },
44198
44209
  {
44199
44210
  "kind": "field",
44200
44211
  "name": "variant",
@@ -44208,6 +44219,15 @@
44208
44219
  }
44209
44220
  ],
44210
44221
  "attributes": [
44222
+ {
44223
+ "name": "motion",
44224
+ "type": {
44225
+ "text": "boolean | undefined"
44226
+ },
44227
+ "description": "When true, displays the skeleton with motion applied.",
44228
+ "default": "false",
44229
+ "fieldName": "motion"
44230
+ },
44211
44231
  {
44212
44232
  "name": "variant",
44213
44233
  "type": {
@@ -50613,6 +50633,11 @@
50613
50633
  "attribute": "aria-label",
50614
50634
  "reflects": true
50615
50635
  },
50636
+ {
50637
+ "kind": "method",
50638
+ "name": "canRenderToggleButton",
50639
+ "privacy": "private"
50640
+ },
50616
50641
  {
50617
50642
  "kind": "field",
50618
50643
  "name": "closeButtonAriaLabel",
@@ -50777,6 +50802,11 @@
50777
50802
  "name": "toggleDetailVisibility",
50778
50803
  "privacy": "private"
50779
50804
  },
50805
+ {
50806
+ "kind": "method",
50807
+ "name": "updateDataExpanded",
50808
+ "privacy": "private"
50809
+ },
50780
50810
  {
50781
50811
  "kind": "method",
50782
50812
  "name": "updateDetailedSlotPresence",
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.135.1",
4
+ "version": "0.136.0",
5
5
  "engines": {
6
6
  "node": ">=24.0.0",
7
7
  "npm": ">=8.0.0"