@momentum-design/components 0.84.1 → 0.84.3

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.
@@ -215,6 +215,8 @@ declare class Popover extends Popover_base {
215
215
  /** @internal */
216
216
  private hoverTimer;
217
217
  /** @internal */
218
+ private isHovered;
219
+ /** @internal */
218
220
  protected isTriggerClicked: boolean;
219
221
  /** @internal */
220
222
  private openDelay;
@@ -264,6 +266,23 @@ declare class Popover extends Popover_base {
264
266
  * @param newValue - The new value of the visible property.
265
267
  */
266
268
  private isOpenUpdated;
269
+ /**
270
+ * Handles mouse enter event on the trigger element.
271
+ * This method sets the `isHovered` flag to true and shows the popover
272
+ */
273
+ private handleMouseEnter;
274
+ /**
275
+ * Handles mouse leave event on the trigger element.
276
+ * This method sets the `isHovered` flag to false and starts the close delay
277
+ * timer to hide the popover.
278
+ */
279
+ private handleMouseLeave;
280
+ /**
281
+ * Handles focus out event on the trigger element.
282
+ * This method checks if the popover is not hovered and hides the popover.
283
+ * If the popover is hovered, it will not hide the popover.
284
+ */
285
+ private handleFocusOut;
267
286
  /**
268
287
  * Starts the close delay timer.
269
288
  * If the popover is not interactive, it will close the popover after the delay.
@@ -229,6 +229,8 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
229
229
  /** @internal */
230
230
  this.hoverTimer = null;
231
231
  /** @internal */
232
+ this.isHovered = false;
233
+ /** @internal */
232
234
  this.isTriggerClicked = false;
233
235
  /** @internal */
234
236
  this.openDelay = 0;
@@ -280,6 +282,33 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
280
282
  this.hidePopover();
281
283
  }
282
284
  };
285
+ /**
286
+ * Handles mouse enter event on the trigger element.
287
+ * This method sets the `isHovered` flag to true and shows the popover
288
+ */
289
+ this.handleMouseEnter = () => {
290
+ this.isHovered = true;
291
+ this.showPopover();
292
+ };
293
+ /**
294
+ * Handles mouse leave event on the trigger element.
295
+ * This method sets the `isHovered` flag to false and starts the close delay
296
+ * timer to hide the popover.
297
+ */
298
+ this.handleMouseLeave = () => {
299
+ this.isHovered = false;
300
+ this.startCloseDelay();
301
+ };
302
+ /**
303
+ * Handles focus out event on the trigger element.
304
+ * This method checks if the popover is not hovered and hides the popover.
305
+ * If the popover is hovered, it will not hide the popover.
306
+ */
307
+ this.handleFocusOut = () => {
308
+ if (!this.isHovered) {
309
+ this.hidePopover();
310
+ }
311
+ };
283
312
  /**
284
313
  * Starts the close delay timer.
285
314
  * If the popover is not interactive, it will close the popover after the delay.
@@ -394,8 +423,8 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
394
423
  }
395
424
  if (this.trigger.includes('mouseenter')) {
396
425
  const hoverBridge = this.renderRoot.querySelector('.popover-hover-bridge');
397
- this.triggerElement.addEventListener('mouseenter', this.showPopover);
398
- this.triggerElement.addEventListener('mouseleave', this.startCloseDelay);
426
+ this.triggerElement.addEventListener('mouseenter', this.handleMouseEnter);
427
+ this.triggerElement.addEventListener('mouseleave', this.handleMouseLeave);
399
428
  this.addEventListener('mouseenter', this.cancelCloseDelay);
400
429
  this.addEventListener('mouseleave', this.startCloseDelay);
401
430
  hoverBridge === null || hoverBridge === void 0 ? void 0 : hoverBridge.addEventListener('mouseenter', this.showPopover);
@@ -403,7 +432,7 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
403
432
  if (this.trigger.includes('focusin')) {
404
433
  this.triggerElement.addEventListener('focusin', this.showPopover);
405
434
  if (!this.interactive) {
406
- this.triggerElement.addEventListener('focusout', this.hidePopover);
435
+ this.triggerElement.addEventListener('focusout', this.handleFocusOut);
407
436
  }
408
437
  }
409
438
  this.addEventListener('focus-trap-exit', this.hidePopover);
@@ -416,12 +445,12 @@ class Popover extends PreventScrollMixin(FocusTrapMixin(Component)) {
416
445
  return;
417
446
  const hoverBridge = this.renderRoot.querySelector('.popover-hover-bridge');
418
447
  this.triggerElement.removeEventListener('click', this.togglePopoverVisible);
419
- this.triggerElement.removeEventListener('mouseenter', this.showPopover);
420
- this.triggerElement.removeEventListener('mouseleave', this.hidePopover);
448
+ this.triggerElement.removeEventListener('mouseenter', this.handleMouseEnter);
449
+ this.triggerElement.removeEventListener('mouseleave', this.handleMouseLeave);
421
450
  this.removeEventListener('mouseenter', this.cancelCloseDelay);
422
451
  this.removeEventListener('mouseleave', this.startCloseDelay);
423
452
  this.triggerElement.removeEventListener('focusin', this.showPopover);
424
- this.triggerElement.removeEventListener('focusout', this.hidePopover);
453
+ this.triggerElement.removeEventListener('focusout', this.handleFocusOut);
425
454
  hoverBridge === null || hoverBridge === void 0 ? void 0 : hoverBridge.removeEventListener('mouseenter', this.showPopover);
426
455
  this.removeEventListener('focus-trap-exit', this.hidePopover);
427
456
  }