11import { html , LitElement , nothing , type PropertyValues } from 'lit' ;
2- import { property , query , state } from 'lit/decorators.js' ;
3- import { classMap } from 'lit/directives/class-map.js' ;
2+ import { property , query } from 'lit/decorators.js' ;
43import { createRef , ref } from 'lit/directives/ref.js' ;
54import { EaseOut } from '../../animations/easings.js' ;
65import { addAnimationController } from '../../animations/player.js' ;
76import { fadeOut } from '../../animations/presets/fade/index.js' ;
87import { scaleInCenter } from '../../animations/presets/scale/index.js' ;
98import { addThemingController } from '../../theming/theming-controller.js' ;
109import { addInternalsController } from '../common/controllers/internals.js' ;
10+ import { addSlotController , setSlots } from '../common/controllers/slot.js' ;
1111import { registerComponent } from '../common/definitions/register.js' ;
1212import type { Constructor } from '../common/mixins/constructor.js' ;
1313import { EventEmitterMixin } from '../common/mixins/event-emitter.js' ;
14+ import { partMap } from '../common/part-map.js' ;
1415import { asNumber , isLTR } from '../common/util.js' ;
1516import IgcIconComponent from '../icon/icon.js' ;
1617import IgcPopoverComponent , {
@@ -44,6 +45,7 @@ type TooltipStateOptions = {
4445 * @slot close-button - Slot for custom sticky-mode close action (e.g., an icon/button).
4546 *
4647 * @csspart base - The wrapping container of the tooltip content.
48+ * @csspart simple-text - The container where the message property of the tooltip is rendered.
4749 *
4850 * @fires igcOpening - Emitted before the tooltip begins to open. Can be canceled to prevent opening.
4951 * @fires igcOpened - Emitted after the tooltip has successfully opened and is visible.
@@ -83,6 +85,7 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
8385
8486 private readonly _containerRef = createRef < HTMLElement > ( ) ;
8587 private readonly _player = addAnimationController ( this , this . _containerRef ) ;
88+ private readonly _slots = addSlotController ( this , { slots : setSlots ( ) } ) ;
8689
8790 private readonly _showAnimation = scaleInCenter ( {
8891 duration : 150 ,
@@ -102,14 +105,6 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
102105 @query ( '#arrow' )
103106 private _arrowElement ! : HTMLElement ;
104107
105- @query ( 'slot:not([name])' )
106- private _defaultSlot ! : HTMLSlotElement ;
107-
108- @state ( )
109- private _hasCustomContent = false ;
110-
111- private _initialCheckDone = false ;
112-
113108 private get _arrowOffset ( ) {
114109 if ( this . placement . includes ( '-' ) ) {
115110 // Horizontal start | end placement
@@ -302,15 +297,6 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
302297 }
303298 }
304299
305- protected override updated ( changedProperties : PropertyValues < this> ) : void {
306- super . updated ( changedProperties ) ;
307- // Check on first update when slot becomes available, or when message changes
308- if ( ! this . _initialCheckDone || changedProperties . has ( 'message' ) ) {
309- this . _initialCheckDone = true ;
310- this . updateComplete . then ( ( ) => this . _checkForCustomContent ( ) ) ;
311- }
312- }
313-
314300 protected override willUpdate ( changedProperties : PropertyValues < this> ) : void {
315301 if ( changedProperties . has ( 'anchor' ) ) {
316302 this . _controller . resolveAnchor ( this . anchor ) ;
@@ -447,19 +433,10 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
447433 this . _emitEvent ( 'igcClosed' ) ;
448434 }
449435
450- private _checkForCustomContent ( ) : void {
451- if ( ! this . _defaultSlot ) {
452- this . _hasCustomContent = false ;
453- return ;
454- }
455- const assignedNodes = this . _defaultSlot . assignedNodes ( { flatten : true } ) ;
456- // If there are assigned nodes, we have custom content
457- this . _hasCustomContent = assignedNodes . length > 0 ;
458- }
459-
460436 protected override render ( ) {
461- const classes = {
462- 'simple-text' : ! this . _hasCustomContent ,
437+ const parts = {
438+ base : true ,
439+ 'simple-text' : ! this . _slots . hasAssignedNodes ( '[default]' , true ) ,
463440 } ;
464441
465442 return html `
@@ -475,10 +452,8 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
475452 flip
476453 shift
477454 >
478- < div ${ ref ( this . _containerRef ) } part ="base " class =${ classMap ( classes ) } >
479- < slot @slotchange =${ this . _checkForCustomContent }
480- > ${ this . message } </ slot
481- >
455+ < div ${ ref ( this . _containerRef ) } part =${ partMap ( parts ) } >
456+ < slot > ${ this . message } </ slot >
482457 ${ this . sticky
483458 ? html `
484459 < slot name ="close-button " @click =${ this . _setAutoHide } >
0 commit comments