@momentum-design/components 0.129.45 → 0.129.46

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.
@@ -3,7 +3,7 @@ import { CSSResult } from 'lit';
3
3
  import type { RoleType } from '../../utils/roles';
4
4
  import Buttonsimple from '../buttonsimple/buttonsimple.component';
5
5
  import type { IconButtonSize, PillButtonSize } from './button.types';
6
- declare const Button_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ButtonComponentMixin").ButtonComponentMixinInterface> & typeof Buttonsimple;
6
+ declare const Button_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/OverflowMixin").OverflowMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ButtonComponentMixin").ButtonComponentMixinInterface> & typeof Buttonsimple;
7
7
  /**
8
8
  * `mdc-button` is a component that can be configured in various ways to suit different use cases.
9
9
  *
@@ -68,6 +68,10 @@ declare const Button_base: import("../../utils/mixins/index.types").Constructor<
68
68
  * @cssproperty --mdc-button-line-height - Line height of the button text
69
69
  */
70
70
  declare class Button extends Button_base {
71
+ /**
72
+ * @internal
73
+ */
74
+ protected buttonTextPart: HTMLSlotElement;
71
75
  /**
72
76
  * Specifies the size of the button in pixels. Available sizes depend on the button type:
73
77
  *
@@ -119,6 +123,10 @@ declare class Button extends Button_base {
119
123
  * @internal
120
124
  */
121
125
  private postfixFilledIconName?;
126
+ /**
127
+ * @internal
128
+ */
129
+ protected get overflowElement(): HTMLElement;
122
130
  update(changedProperties: PropertyValues): void;
123
131
  /**
124
132
  * Modifies the icon name based on the active state.
@@ -8,10 +8,11 @@ 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 } from 'lit';
11
- import { property, state } from 'lit/decorators.js';
11
+ import { property, query, state } from 'lit/decorators.js';
12
12
  import { ButtonComponentMixin } from '../../utils/mixins/ButtonComponentMixin';
13
13
  import { ROLE } from '../../utils/roles';
14
14
  import Buttonsimple from '../buttonsimple/buttonsimple.component';
15
+ import { OverflowMixin } from '../../utils/mixins/OverflowMixin';
15
16
  import { DEFAULTS } from './button.constants';
16
17
  import styles from './button.styles';
17
18
  import { getIconNameWithoutStyle } from './button.utils';
@@ -78,7 +79,7 @@ import { getIconNameWithoutStyle } from './button.utils';
78
79
  * @cssproperty --mdc-button-postfix-icon-size - Size of the postfix icon
79
80
  * @cssproperty --mdc-button-line-height - Line height of the button text
80
81
  */
81
- class Button extends ButtonComponentMixin(Buttonsimple) {
82
+ class Button extends OverflowMixin(ButtonComponentMixin(Buttonsimple)) {
82
83
  constructor() {
83
84
  super(...arguments);
84
85
  /**
@@ -125,6 +126,12 @@ class Button extends ButtonComponentMixin(Buttonsimple) {
125
126
  */
126
127
  this.role = ROLE.BUTTON;
127
128
  }
129
+ /**
130
+ * @internal
131
+ */
132
+ get overflowElement() {
133
+ return this.buttonTextPart;
134
+ }
128
135
  update(changedProperties) {
129
136
  super.update(changedProperties);
130
137
  if (changedProperties.has('active')) {
@@ -195,6 +202,10 @@ class Button extends ButtonComponentMixin(Buttonsimple) {
195
202
  }
196
203
  }
197
204
  Button.styles = [...Buttonsimple.styles, ...styles];
205
+ __decorate([
206
+ query('slot[part="button-text"]'),
207
+ __metadata("design:type", HTMLSlotElement)
208
+ ], Button.prototype, "buttonTextPart", void 0);
198
209
  __decorate([
199
210
  property({ type: Number }),
200
211
  __metadata("design:type", Number)
@@ -478,7 +478,7 @@ declare class Popover extends Popover_base {
478
478
  /**
479
479
  * Shows the popover.
480
480
  */
481
- show: () => void;
481
+ show(): void;
482
482
  /**
483
483
  * Hides the popover.
484
484
  */
@@ -614,28 +614,6 @@ class Popover extends KeyToActionMixin(BackdropMixin(PreventScrollMixin(FocusTra
614
614
  this.timers.clearTimeout(TIMEOUTS.HOVER);
615
615
  this.timers.clearTimeout(TIMEOUTS.CLOSE);
616
616
  };
617
- /**
618
- * Shows the popover.
619
- */
620
- this.show = () => {
621
- if (this.shouldSuppressOpening) {
622
- return;
623
- }
624
- this.cancelCloseDelay();
625
- if (this.visible) {
626
- return;
627
- }
628
- const callback = () => {
629
- this.visible = true;
630
- };
631
- if (this.openDelay > 0) {
632
- this.timers.setTimeout(TIMEOUTS.OPEN, callback, this.openDelay);
633
- }
634
- else {
635
- this.timers.clearTimeout(TIMEOUTS.OPEN);
636
- callback();
637
- }
638
- };
639
617
  /**
640
618
  * Hides the popover.
641
619
  */
@@ -746,6 +724,7 @@ class Popover extends KeyToActionMixin(BackdropMixin(PreventScrollMixin(FocusTra
746
724
  animationFrame: this.animationFrame,
747
725
  });
748
726
  };
727
+ this.show = this.show.bind(this);
749
728
  this.utils = new PopoverUtils(this);
750
729
  this.parseTrigger();
751
730
  [this.openDelay, this.closeDelay] = this.utils.setupDelay();
@@ -931,6 +910,28 @@ class Popover extends KeyToActionMixin(BackdropMixin(PreventScrollMixin(FocusTra
931
910
  PopoverEventManager.onHidePopover(this);
932
911
  }
933
912
  }
913
+ /**
914
+ * Shows the popover.
915
+ */
916
+ show() {
917
+ if (this.shouldSuppressOpening) {
918
+ return;
919
+ }
920
+ this.cancelCloseDelay();
921
+ if (this.visible) {
922
+ return;
923
+ }
924
+ const callback = () => {
925
+ this.visible = true;
926
+ };
927
+ if (this.openDelay > 0) {
928
+ this.timers.setTimeout(TIMEOUTS.OPEN, callback, this.openDelay);
929
+ }
930
+ else {
931
+ this.timers.clearTimeout(TIMEOUTS.OPEN);
932
+ callback();
933
+ }
934
+ }
934
935
  isEventFromTrigger(event) {
935
936
  var _a;
936
937
  if (!this.triggerID)
@@ -1,6 +1,7 @@
1
1
  import { CSSResult } from 'lit';
2
2
  import { Component } from '../../models';
3
3
  import type { TextType, TagName } from './text.types';
4
+ declare const Text_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/OverflowMixin").OverflowMixinInterface> & typeof Component;
4
5
  /**
5
6
  * Text component for creating styled text elements.
6
7
  * It has to be mounted within the ThemeProvider to access color and font tokens.
@@ -19,7 +20,11 @@ import type { TextType, TagName } from './text.types';
19
20
  *
20
21
  * @csspart text - The text element
21
22
  */
22
- declare class Text extends Component {
23
+ declare class Text extends Text_base {
24
+ /**
25
+ * @internal
26
+ */
27
+ private textPartElement;
23
28
  /**
24
29
  * Specifies the text style to be applied.
25
30
  *
@@ -77,7 +82,11 @@ declare class Text extends Component {
77
82
  * For instance, setting this attribute to `h2` will render the text element as an `h2` element.
78
83
  * Note that the styling is determined by the `type` attribute.
79
84
  */
80
- tagname?: TagName;
85
+ tagname: TagName;
86
+ /**
87
+ * @internal
88
+ */
89
+ protected get overflowElement(): HTMLElement;
81
90
  render(): import("lit-html").TemplateResult<1>;
82
91
  static styles: Array<CSSResult>;
83
92
  }
@@ -8,8 +8,9 @@ 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 } from 'lit';
11
- import { property } from 'lit/decorators.js';
11
+ import { property, query } from 'lit/decorators.js';
12
12
  import { Component } from '../../models';
13
+ import { OverflowMixin } from '../../utils/mixins/OverflowMixin';
13
14
  import styles from './text.styles';
14
15
  import { DEFAULTS, VALID_TEXT_TAGS } from './text.constants';
15
16
  /**
@@ -30,7 +31,7 @@ import { DEFAULTS, VALID_TEXT_TAGS } from './text.constants';
30
31
  *
31
32
  * @csspart text - The text element
32
33
  */
33
- class Text extends Component {
34
+ class Text extends OverflowMixin(Component) {
34
35
  constructor() {
35
36
  super(...arguments);
36
37
  /**
@@ -92,6 +93,16 @@ class Text extends Component {
92
93
  */
93
94
  this.tagname = DEFAULTS.TEXT_ELEMENT_TAGNAME;
94
95
  }
96
+ /**
97
+ * @internal
98
+ */
99
+ get overflowElement() {
100
+ // span and small are inline elements therefore we need to return the host element itself
101
+ if ([VALID_TEXT_TAGS.SPAN, VALID_TEXT_TAGS.SMALL].includes(this.tagname)) {
102
+ return this;
103
+ }
104
+ return this.textPartElement;
105
+ }
95
106
  render() {
96
107
  // Lit does not support dynamically changing values for the tag name of a custom element.
97
108
  // Read more: https://lit.dev/docs/templates/expressions/#invalid-locations
@@ -121,6 +132,10 @@ class Text extends Component {
121
132
  }
122
133
  }
123
134
  Text.styles = [...Component.styles, ...styles];
135
+ __decorate([
136
+ query(`[part='${DEFAULTS.CSS_PART_TEXT}']`),
137
+ __metadata("design:type", HTMLElement)
138
+ ], Text.prototype, "textPartElement", void 0);
124
139
  __decorate([
125
140
  property({ attribute: 'type', reflect: true, type: String }),
126
141
  __metadata("design:type", String)
@@ -38,6 +38,16 @@ declare class Tooltip extends Popover {
38
38
  * @default 'description'
39
39
  */
40
40
  tooltipType: TooltipType;
41
+ /**
42
+ * If true, the tooltip will only be shown when the trigger element's content is overflowing on the x-axis.
43
+ *
44
+ * Supports the following components:
45
+ * - mdc-button
46
+ * - mdc-text
47
+ *
48
+ * @default false
49
+ */
50
+ onlyShowWhenTriggerOverflows: boolean;
41
51
  connectedCallback(): void;
42
52
  /**
43
53
  * Sets the type attribute for the tooltip component.
@@ -61,7 +71,8 @@ declare class Tooltip extends Popover {
61
71
  * @param changedProperties - The changed properties.
62
72
  */
63
73
  private onTooltipTypeUpdated;
64
- update(changedProperties: PropertyValues): Promise<void>;
74
+ update(changedProperties: PropertyValues<this>): Promise<void>;
75
+ show(): void;
65
76
  static styles: Array<CSSResult>;
66
77
  }
67
78
  export default Tooltip;
@@ -12,6 +12,7 @@ import { v4 as uuidv4 } from 'uuid';
12
12
  import { ROLE } from '../../utils/roles';
13
13
  import Popover from '../popover/popover.component';
14
14
  import { DEFAULTS as POPOVER_DEFAULTS, POPOVER_PLACEMENT } from '../popover/popover.constants';
15
+ import { hasOverflowMixin } from '../../utils/dom';
15
16
  import { DEFAULTS, TOOLTIP_TYPES } from './tooltip.constants';
16
17
  import styles from './tooltip.styles';
17
18
  /**
@@ -52,6 +53,16 @@ class Tooltip extends Popover {
52
53
  * @default 'description'
53
54
  */
54
55
  this.tooltipType = DEFAULTS.TOOLTIP_TYPE;
56
+ /**
57
+ * If true, the tooltip will only be shown when the trigger element's content is overflowing on the x-axis.
58
+ *
59
+ * Supports the following components:
60
+ * - mdc-button
61
+ * - mdc-text
62
+ *
63
+ * @default false
64
+ */
65
+ this.onlyShowWhenTriggerOverflows = DEFAULTS.ONLY_SHOW_WHEN_TRIGGER_OVERFLOWS;
55
66
  }
56
67
  connectedCallback() {
57
68
  super.connectedCallback();
@@ -165,10 +176,22 @@ class Tooltip extends Popover {
165
176
  this.onTooltipTypeUpdated(changedProperties);
166
177
  }
167
178
  }
179
+ show() {
180
+ if (this.onlyShowWhenTriggerOverflows && this.triggerElement && hasOverflowMixin(this.triggerElement)) {
181
+ if (!this.triggerElement.isWidthOverflowing()) {
182
+ return;
183
+ }
184
+ }
185
+ super.show();
186
+ }
168
187
  }
169
188
  Tooltip.styles = [...Popover.styles, ...styles];
170
189
  __decorate([
171
190
  property({ type: String, attribute: 'tooltip-type', reflect: true }),
172
191
  __metadata("design:type", String)
173
192
  ], Tooltip.prototype, "tooltipType", void 0);
193
+ __decorate([
194
+ property({ type: Boolean, attribute: 'only-show-when-trigger-overflows', reflect: true }),
195
+ __metadata("design:type", Boolean)
196
+ ], Tooltip.prototype, "onlyShowWhenTriggerOverflows", void 0);
174
197
  export default Tooltip;
@@ -16,5 +16,6 @@ declare const DEFAULTS: {
16
16
  readonly PLACEMENT: "top";
17
17
  readonly SHOW_ARROW: true;
18
18
  readonly TOOLTIP_TYPE: "description";
19
+ readonly ONLY_SHOW_WHEN_TRIGGER_OVERFLOWS: false;
19
20
  };
20
21
  export { DEFAULTS, TAG_NAME, TOOLTIP_TYPES };
@@ -18,5 +18,6 @@ const DEFAULTS = {
18
18
  PLACEMENT: POPOVER_PLACEMENT.TOP,
19
19
  SHOW_ARROW: true,
20
20
  TOOLTIP_TYPE: TOOLTIP_TYPES.DESCRIPTION,
21
+ ONLY_SHOW_WHEN_TRIGGER_OVERFLOWS: false,
21
22
  };
22
23
  export { DEFAULTS, TAG_NAME, TOOLTIP_TYPES };
@@ -5054,6 +5054,21 @@
5054
5054
  "attribute": "inverted",
5055
5055
  "reflects": true
5056
5056
  },
5057
+ {
5058
+ "kind": "method",
5059
+ "name": "isWidthOverflowing",
5060
+ "privacy": "public",
5061
+ "return": {
5062
+ "type": {
5063
+ "text": ""
5064
+ }
5065
+ },
5066
+ "description": "Determines if the content of the overflow element is overflowing its width.",
5067
+ "inheritedFrom": {
5068
+ "name": "OverflowMixin",
5069
+ "module": "utils/mixins/OverflowMixin.js"
5070
+ }
5071
+ },
5057
5072
  {
5058
5073
  "kind": "field",
5059
5074
  "name": "name",
@@ -5549,6 +5564,10 @@
5549
5564
  }
5550
5565
  ],
5551
5566
  "mixins": [
5567
+ {
5568
+ "name": "OverflowMixin",
5569
+ "module": "/src/utils/mixins/OverflowMixin"
5570
+ },
5552
5571
  {
5553
5572
  "name": "ButtonComponentMixin",
5554
5573
  "module": "/src/utils/mixins/ButtonComponentMixin"
@@ -5559,7 +5578,7 @@
5559
5578
  "module": "/src/components/buttonsimple/buttonsimple.component"
5560
5579
  },
5561
5580
  "tagName": "mdc-button",
5562
- "jsDoc": "/**\n * `mdc-button` is a component that can be configured in various ways to suit different use cases.\n *\n * ## Button configuration\n *\n * The appearance of the button depends on combination of multiple attributes.\n *\n * ### Button Types\n * \n * The type of button is inferred based on the presence of slot and/or prefix and postfix icons/slots:\n * \n * - **Pill button**: Contains text value, commonly used for call to action, tags, or filters\n * - **Pill button with icons**: Contains an icon on the left or right side of the button\n * - **Icon button**: Represented by just an icon without any text\n * \n * ### Button Variants:\n *\n * Options for button backgrounds and borders:\n * \n * - **Primary**: Solid background color\n * - **Secondary**: Transparent background with solid border\n * - **Tertiary**: No background or border, text-only appearance\n *\n * ### Button Colors\n * \n * Color options for **Primary** and **Secondary** buttons:\n *\n * - **Default**: For standard actions\n * - **Positive**: For success or confirmation actions\n * - **Negative**: For destructive or error actions\n * - **Accent**: For informational actions\n * - **Promotional**: For promotional actions\n *\n * ### Button Sizes\n * \n * Size options for different button configurations in REM:\n * \n * - **Pill button**: 40, 32, 28, 24\n * - **Icon button**: 64, 52, 40, 32, 28, 24\n * - **Tertiary icon button**: 20\n *\n * @dependency mdc-icon\n *\n * @tagname mdc-button\n *\n * @slot - Text label of the button.\n * @slot prefix - Content to be displayed before the text label.\n * @slot postfix - Content to be displayed after the text label.\n *\n * @csspart button-text - Text label of the button, passed in default slot\n * @csspart prefix - Content before the text label, passed in `prefix` slot\n * @csspart postfix - Content after the text label, passed in `postfix` slot\n * @csspart prefix-icon - Icon element displayed before the text label when `prefix-icon` attribute is set\n * @csspart postfix-icon - Icon element displayed after the text label when `postfix-icon` attribute is set\n *\n * @cssproperty --mdc-button-height - Height for button size\n * @cssproperty --mdc-button-background - Background of the button\n * @cssproperty --mdc-button-border-color - Borer color of the button\n * @cssproperty --mdc-button-text-color - Text color of the button\n * @cssproperty --mdc-button-prefix-icon-size - Size of the prefix icon\n * @cssproperty --mdc-button-postfix-icon-size - Size of the postfix icon\n * @cssproperty --mdc-button-line-height - Line height of the button text\n */",
5581
+ "jsDoc": "/**\n * `mdc-button` is a component that can be configured in various ways to suit different use cases.\n *\n * ## Button configuration\n *\n * The appearance of the button depends on combination of multiple attributes.\n *\n * ### Button Types\n *\n * The type of button is inferred based on the presence of slot and/or prefix and postfix icons/slots:\n *\n * - **Pill button**: Contains text value, commonly used for call to action, tags, or filters\n * - **Pill button with icons**: Contains an icon on the left or right side of the button\n * - **Icon button**: Represented by just an icon without any text\n *\n * ### Button Variants:\n *\n * Options for button backgrounds and borders:\n *\n * - **Primary**: Solid background color\n * - **Secondary**: Transparent background with solid border\n * - **Tertiary**: No background or border, text-only appearance\n *\n * ### Button Colors\n *\n * Color options for **Primary** and **Secondary** buttons:\n *\n * - **Default**: For standard actions\n * - **Positive**: For success or confirmation actions\n * - **Negative**: For destructive or error actions\n * - **Accent**: For informational actions\n * - **Promotional**: For promotional actions\n *\n * ### Button Sizes\n *\n * Size options for different button configurations in REM:\n *\n * - **Pill button**: 40, 32, 28, 24\n * - **Icon button**: 64, 52, 40, 32, 28, 24\n * - **Tertiary icon button**: 20\n *\n * @dependency mdc-icon\n *\n * @tagname mdc-button\n *\n * @slot - Text label of the button.\n * @slot prefix - Content to be displayed before the text label.\n * @slot postfix - Content to be displayed after the text label.\n *\n * @csspart button-text - Text label of the button, passed in default slot\n * @csspart prefix - Content before the text label, passed in `prefix` slot\n * @csspart postfix - Content after the text label, passed in `postfix` slot\n * @csspart prefix-icon - Icon element displayed before the text label when `prefix-icon` attribute is set\n * @csspart postfix-icon - Icon element displayed after the text label when `postfix-icon` attribute is set\n *\n * @cssproperty --mdc-button-height - Height for button size\n * @cssproperty --mdc-button-background - Background of the button\n * @cssproperty --mdc-button-border-color - Borer color of the button\n * @cssproperty --mdc-button-text-color - Text color of the button\n * @cssproperty --mdc-button-prefix-icon-size - Size of the prefix icon\n * @cssproperty --mdc-button-postfix-icon-size - Size of the postfix icon\n * @cssproperty --mdc-button-line-height - Line height of the button text\n */",
5563
5582
  "customElement": true,
5564
5583
  "events": [
5565
5584
  {
@@ -12304,7 +12323,7 @@
12304
12323
  }
12305
12324
  },
12306
12325
  {
12307
- "kind": "field",
12326
+ "kind": "method",
12308
12327
  "name": "show",
12309
12328
  "privacy": "public",
12310
12329
  "description": "Shows the popover.",
@@ -26853,7 +26872,7 @@
26853
26872
  }
26854
26873
  },
26855
26874
  {
26856
- "kind": "field",
26875
+ "kind": "method",
26857
26876
  "name": "show",
26858
26877
  "privacy": "public",
26859
26878
  "description": "Shows the popover.",
@@ -32452,7 +32471,7 @@
32452
32471
  "reflects": true
32453
32472
  },
32454
32473
  {
32455
- "kind": "field",
32474
+ "kind": "method",
32456
32475
  "name": "show",
32457
32476
  "privacy": "public",
32458
32477
  "description": "Shows the popover."
@@ -44597,11 +44616,26 @@
44597
44616
  }
44598
44617
  ],
44599
44618
  "members": [
44619
+ {
44620
+ "kind": "method",
44621
+ "name": "isWidthOverflowing",
44622
+ "privacy": "public",
44623
+ "return": {
44624
+ "type": {
44625
+ "text": ""
44626
+ }
44627
+ },
44628
+ "description": "Determines if the content of the overflow element is overflowing its width.",
44629
+ "inheritedFrom": {
44630
+ "name": "OverflowMixin",
44631
+ "module": "utils/mixins/OverflowMixin.js"
44632
+ }
44633
+ },
44600
44634
  {
44601
44635
  "kind": "field",
44602
44636
  "name": "tagname",
44603
44637
  "type": {
44604
- "text": "TagName | undefined"
44638
+ "text": "TagName"
44605
44639
  },
44606
44640
  "privacy": "public",
44607
44641
  "description": "Specifies the HTML tag name for the text element. The default tag name is `p`.\nThis attribute is optional. When set, it changes the tag name of the text element.\n\nAcceptable values include:\n\n- 'h1'\n- 'h2'\n- 'h3'\n- 'h4'\n- 'h5'\n- 'h6'\n- 'p'\n- 'small'\n- 'span'\n- 'div'\n\nFor instance, setting this attribute to `h2` will render the text element as an `h2` element.\nNote that the styling is determined by the `type` attribute.",
@@ -44634,12 +44668,18 @@
44634
44668
  {
44635
44669
  "name": "tagname",
44636
44670
  "type": {
44637
- "text": "TagName | undefined"
44671
+ "text": "TagName"
44638
44672
  },
44639
44673
  "description": "Specifies the HTML tag name for the text element. The default tag name is `p`.\nThis attribute is optional. When set, it changes the tag name of the text element.\n\nAcceptable values include:\n\n- 'h1'\n- 'h2'\n- 'h3'\n- 'h4'\n- 'h5'\n- 'h6'\n- 'p'\n- 'small'\n- 'span'\n- 'div'\n\nFor instance, setting this attribute to `h2` will render the text element as an `h2` element.\nNote that the styling is determined by the `type` attribute.",
44640
44674
  "fieldName": "tagname"
44641
44675
  }
44642
44676
  ],
44677
+ "mixins": [
44678
+ {
44679
+ "name": "OverflowMixin",
44680
+ "module": "/src/utils/mixins/OverflowMixin"
44681
+ }
44682
+ ],
44643
44683
  "superclass": {
44644
44684
  "name": "Component",
44645
44685
  "module": "/src/models"
@@ -48101,7 +48141,7 @@
48101
48141
  "reflects": true
48102
48142
  },
48103
48143
  {
48104
- "kind": "field",
48144
+ "kind": "method",
48105
48145
  "name": "show",
48106
48146
  "privacy": "public",
48107
48147
  "description": "Shows the popover.",
@@ -49429,6 +49469,17 @@
49429
49469
  },
49430
49470
  "description": "Updates the tooltip id if it is empty."
49431
49471
  },
49472
+ {
49473
+ "kind": "field",
49474
+ "name": "onlyShowWhenTriggerOverflows",
49475
+ "type": {
49476
+ "text": "boolean"
49477
+ },
49478
+ "description": "If true, the tooltip will only be shown when the trigger element's content is overflowing on the x-axis.\n\nSupports the following components:\n- mdc-button\n- mdc-text",
49479
+ "default": "false",
49480
+ "attribute": "only-show-when-trigger-overflows",
49481
+ "reflects": true
49482
+ },
49432
49483
  {
49433
49484
  "kind": "method",
49434
49485
  "name": "onPlacementUpdated",
@@ -49453,7 +49504,7 @@
49453
49504
  {
49454
49505
  "name": "changedProperties",
49455
49506
  "type": {
49456
- "text": "PropertyValues"
49507
+ "text": "PropertyValues<this>"
49457
49508
  },
49458
49509
  "description": "The changed properties."
49459
49510
  }
@@ -49541,7 +49592,7 @@
49541
49592
  "description": "Sets the type attribute for the tooltip component.\nIf the provided type is not included in the TOOLTIP_TYPES,\nit defaults to the value specified in DEFAULTS.TOOLTIP_TYPE."
49542
49593
  },
49543
49594
  {
49544
- "kind": "field",
49595
+ "kind": "method",
49545
49596
  "name": "show",
49546
49597
  "privacy": "public",
49547
49598
  "description": "Shows the popover.",
@@ -49747,6 +49798,15 @@
49747
49798
  "default": "'description'",
49748
49799
  "fieldName": "tooltipType"
49749
49800
  },
49801
+ {
49802
+ "name": "only-show-when-trigger-overflows",
49803
+ "type": {
49804
+ "text": "boolean"
49805
+ },
49806
+ "description": "If true, the tooltip will only be shown when the trigger element's content is overflowing on the x-axis.\n\nSupports the following components:\n- mdc-button\n- mdc-text",
49807
+ "default": "false",
49808
+ "fieldName": "onlyShowWhenTriggerOverflows"
49809
+ },
49750
49810
  {
49751
49811
  "name": "id",
49752
49812
  "type": {
@@ -53118,6 +53178,82 @@
53118
53178
  }
53119
53179
  ]
53120
53180
  },
53181
+ {
53182
+ "kind": "javascript-module",
53183
+ "path": "utils/mixins/OverflowMixin.js",
53184
+ "declarations": [
53185
+ {
53186
+ "kind": "mixin",
53187
+ "description": "",
53188
+ "name": "OverflowMixin",
53189
+ "members": [
53190
+ {
53191
+ "kind": "method",
53192
+ "name": "isWidthOverflowing",
53193
+ "privacy": "public",
53194
+ "return": {
53195
+ "type": {
53196
+ "text": ""
53197
+ }
53198
+ },
53199
+ "description": "Determines if the content of the overflow element is overflowing its width."
53200
+ }
53201
+ ],
53202
+ "parameters": [
53203
+ {
53204
+ "name": "superClass",
53205
+ "type": {
53206
+ "text": "T"
53207
+ }
53208
+ }
53209
+ ]
53210
+ },
53211
+ {
53212
+ "kind": "class",
53213
+ "description": "",
53214
+ "name": "OverflowMixinInterface",
53215
+ "members": [
53216
+ {
53217
+ "kind": "method",
53218
+ "name": "isWidthOverflowing",
53219
+ "privacy": "public",
53220
+ "return": {
53221
+ "type": {
53222
+ "text": "boolean"
53223
+ }
53224
+ }
53225
+ },
53226
+ {
53227
+ "kind": "field",
53228
+ "name": "overflowElement",
53229
+ "type": {
53230
+ "text": "HTMLElement"
53231
+ },
53232
+ "privacy": "protected",
53233
+ "readonly": true
53234
+ }
53235
+ ]
53236
+ }
53237
+ ],
53238
+ "exports": [
53239
+ {
53240
+ "kind": "js",
53241
+ "name": "OverflowMixin",
53242
+ "declaration": {
53243
+ "name": "OverflowMixin",
53244
+ "module": "utils/mixins/OverflowMixin.js"
53245
+ }
53246
+ },
53247
+ {
53248
+ "kind": "js",
53249
+ "name": "OverflowMixinInterface",
53250
+ "declaration": {
53251
+ "name": "OverflowMixinInterface",
53252
+ "module": "utils/mixins/OverflowMixin.js"
53253
+ }
53254
+ }
53255
+ ]
53256
+ },
53121
53257
  {
53122
53258
  "kind": "javascript-module",
53123
53259
  "path": "utils/mixins/PreventScrollMixin.js",
@@ -1,3 +1,4 @@
1
+ import type { OverflowMixinInterface } from './mixins/OverflowMixin';
1
2
  /**
2
3
  * nodeB precedes nodeA in either a pre-order depth-first traversal of a tree containing both
3
4
  * (e.g., as a descendant or preceding sibling or a descendant of a preceding sibling or
@@ -107,3 +108,10 @@ export declare const findFocusable: (root: ShadowRoot | HTMLElement | null) => H
107
108
  * Get the active element from the DOM, including shadow DOMs
108
109
  */
109
110
  export declare const getDomActiveElement: (root?: Document) => Element | null;
111
+ /**
112
+ * Type guard to check if an element inherits the OverflowMixin.
113
+ *
114
+ * @param element - The element to check
115
+ * @returns True if the element has the OverflowMixin methods
116
+ */
117
+ export declare const hasOverflowMixin: <T extends HTMLElement>(element: T) => element is T & OverflowMixinInterface;
package/dist/utils/dom.js CHANGED
@@ -189,3 +189,10 @@ export const getDomActiveElement = (root = document) => {
189
189
  activeElement = activeElement.shadowRoot.activeElement;
190
190
  return activeElement;
191
191
  };
192
+ /**
193
+ * Type guard to check if an element inherits the OverflowMixin.
194
+ *
195
+ * @param element - The element to check
196
+ * @returns True if the element has the OverflowMixin methods
197
+ */
198
+ export const hasOverflowMixin = (element) => 'isWidthOverflowing' in element && typeof element.isWidthOverflowing === 'function';
@@ -0,0 +1,7 @@
1
+ import { LitElement } from 'lit';
2
+ import type { Constructor } from './index.types';
3
+ export declare abstract class OverflowMixinInterface {
4
+ protected get overflowElement(): HTMLElement;
5
+ isWidthOverflowing(): boolean;
6
+ }
7
+ export declare const OverflowMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<OverflowMixinInterface> & T;
@@ -0,0 +1,23 @@
1
+ export const OverflowMixin = (superClass) => {
2
+ class InnerMixinClass extends superClass {
3
+ /**
4
+ * Gets the element whose overflow will be monitored.
5
+ *
6
+ * @internal
7
+ */
8
+ get overflowElement() {
9
+ return this;
10
+ }
11
+ /**
12
+ * Determines if the content of the overflow element is overflowing its width.
13
+ *
14
+ * @returns True if the scroll width of the overflow element is greater than its client width.
15
+ */
16
+ isWidthOverflowing() {
17
+ const el = this.overflowElement;
18
+ return el.scrollWidth > el.clientWidth;
19
+ }
20
+ }
21
+ // Cast return type to your mixin's interface intersected with the superClass type
22
+ return InnerMixinClass;
23
+ };
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.129.45",
4
+ "version": "0.129.46",
5
5
  "engines": {
6
6
  "node": ">=20.0.0",
7
7
  "npm": ">=8.0.0"