@momentum-design/components 0.129.42 → 0.129.43

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.
@@ -1,8 +1,22 @@
1
1
  import Popover from '../popover/popover.component';
2
2
  import type { PopoverTrigger } from '../popover/popover.types';
3
3
  /**
4
+ * A Coachmark is a contextual guidance component used to highlight a specific UI element and explain its purpose or functionality.
5
+ * It is typically shown as part of onboarding, feature discovery, or progressive education within the product.
6
+ *
4
7
  * Coachmark component based on top of the popover component,
5
8
  * with the default value of certain properties changed.
9
+ * Coachmark component will always have an arrow attached to it.
10
+ * The color of the coachmark is contrast.
11
+ *
12
+ * ## When to use
13
+ * - Introducing a new or complex feature to users.
14
+ * - Drawing attention to a UI element that might otherwise be missed.
15
+ * - Providing step-by-step guidance in an onboarding or walkthrough flow.
16
+ *
17
+ * ## Accessibility
18
+ * - The default role of coachmark is `"dialog"`, which can be changed via the `role` attribute.
19
+ * - aria-label or aria-labelledby can be provided to give the coachmark an accessible name.
6
20
  *
7
21
  * @dependency mdc-popover
8
22
  *
@@ -24,7 +38,6 @@ import type { PopoverTrigger } from '../popover/popover.types';
24
38
  * @cssproperty --mdc-popover-elevation-3 - elevation of the popover
25
39
  *
26
40
  * @slot - Default slot for modal container
27
- *
28
41
  */
29
42
  declare class Coachmark extends Popover {
30
43
  /**
@@ -11,8 +11,22 @@ import { property } from 'lit/decorators.js';
11
11
  import Popover from '../popover/popover.component';
12
12
  import { DEFAULTS } from './coachmark.constants';
13
13
  /**
14
+ * A Coachmark is a contextual guidance component used to highlight a specific UI element and explain its purpose or functionality.
15
+ * It is typically shown as part of onboarding, feature discovery, or progressive education within the product.
16
+ *
14
17
  * Coachmark component based on top of the popover component,
15
18
  * with the default value of certain properties changed.
19
+ * Coachmark component will always have an arrow attached to it.
20
+ * The color of the coachmark is contrast.
21
+ *
22
+ * ## When to use
23
+ * - Introducing a new or complex feature to users.
24
+ * - Drawing attention to a UI element that might otherwise be missed.
25
+ * - Providing step-by-step guidance in an onboarding or walkthrough flow.
26
+ *
27
+ * ## Accessibility
28
+ * - The default role of coachmark is `"dialog"`, which can be changed via the `role` attribute.
29
+ * - aria-label or aria-labelledby can be provided to give the coachmark an accessible name.
16
30
  *
17
31
  * @dependency mdc-popover
18
32
  *
@@ -34,7 +48,6 @@ import { DEFAULTS } from './coachmark.constants';
34
48
  * @cssproperty --mdc-popover-elevation-3 - elevation of the popover
35
49
  *
36
50
  * @slot - Default slot for modal container
37
- *
38
51
  */
39
52
  class Coachmark extends Popover {
40
53
  constructor() {
@@ -1,5 +1,4 @@
1
1
  import Coachmark from './coachmark.component';
2
- import '../button';
3
2
  declare global {
4
3
  interface HTMLElementTagNameMap {
5
4
  ['mdc-coachmark']: Coachmark;
@@ -1,5 +1,4 @@
1
1
  import Coachmark from './coachmark.component';
2
2
  import { TAG_NAME } from './coachmark.constants';
3
- import '../button';
4
3
  Coachmark.register(TAG_NAME);
5
4
  export default Coachmark;
@@ -1,6 +1,6 @@
1
1
  import { CSSResult, PropertyValues } from 'lit';
2
2
  import { Component } from '../../models';
3
- import type { PopoverColor, PopoverPlacement, PopoverStrategy, PopoverTrigger } from './popover.types';
3
+ import type { PopoverBoundaryRoot, PopoverColor, PopoverPlacement, PopoverStrategy, PopoverTrigger } from './popover.types';
4
4
  declare const Popover_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/BackdropMixin").BackdropMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/PreventScrollMixin").PreventScrollMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/FocusTrapMixin").FocusTrapClassInterface> & typeof Component;
5
5
  /**
6
6
  * Popover is generic overlay which can be triggered by any actionable element.
@@ -156,7 +156,7 @@ declare class Popover extends Popover_base {
156
156
  *
157
157
  * @see [Floating UI - rootBoundary](https://floating-ui.com/docs/detectOverflow#rootboundary)
158
158
  */
159
- boundaryRoot: 'viewport' | 'document';
159
+ boundaryRoot: PopoverBoundaryRoot;
160
160
  /**
161
161
  * Virtual padding around the boundary to check for overflow.
162
162
  * So the popover will not be placed on top of the edge of the boundary.
@@ -374,12 +374,12 @@ declare class Popover extends Popover_base {
374
374
  /**
375
375
  * Get trigger element on-demand
376
376
  * It is necessary because trigger might appear later in the DOM, or it could be replaced completely.
377
- *
378
- * @internal
379
377
  */
380
378
  get triggerElement(): HTMLElement | null;
379
+ /** @internal */
381
380
  private timers;
382
381
  constructor();
382
+ /** @internal */
383
383
  private parseTrigger;
384
384
  protected firstUpdated(changedProperties: PropertyValues): Promise<void>;
385
385
  connectedCallback(): void;
@@ -390,14 +390,17 @@ declare class Popover extends Popover_base {
390
390
  *
391
391
  * We are using capture phase for to make sure we capture trigger events even when they are not propagated during the
392
392
  * bubble phase (e.g.: buttons in list item)
393
+ * @internal
393
394
  */
394
395
  private setupTriggerListeners;
395
396
  /**
396
397
  * Removes the trigger related event listeners.
398
+ * @internal
397
399
  */
398
400
  private removeTriggerListeners;
399
401
  /**
400
402
  * Removes all event listeners related to the popover.
403
+ * @internal
401
404
  */
402
405
  private removeAllListeners;
403
406
  protected updated(changedProperties: PropertyValues): Promise<void>;
@@ -405,6 +408,7 @@ declare class Popover extends Popover_base {
405
408
  * Handles the outside click event to close the popover.
406
409
  *
407
410
  * @param event - The mouse event.
411
+ * @internal
408
412
  */
409
413
  protected onOutsidePopoverClick: (event: MouseEvent) => void;
410
414
  /**
@@ -413,12 +417,14 @@ declare class Popover extends Popover_base {
413
417
  * This method is attached to the document.
414
418
  *
415
419
  * @param event - The keyboard event.
420
+ * @internal
416
421
  */
417
422
  private onEscapeKeydown;
418
423
  /**
419
424
  * Handles the popover focus out event.
420
425
  *
421
426
  * @param event - The focus event.
427
+ * @internal
422
428
  */
423
429
  private onPopoverFocusOut;
424
430
  /**
@@ -430,37 +436,43 @@ declare class Popover extends Popover_base {
430
436
  */
431
437
  protected isOpenUpdated(oldValue: boolean, newValue: boolean): Promise<void>;
432
438
  /**
433
- * Handles mouse enter event on the trigger element.
434
- * This method sets the `isHovered` flag to true and shows the popover
439
+ * Handles mouse enter event on the trigger element.
440
+ * This method sets the `isHovered` flag to true and shows the popover
441
+ * @internal
435
442
  */
436
443
  private handleMouseEnter;
437
444
  /**
438
- * Handles mouse leave event on the trigger element.
439
- * This method sets the `isHovered` flag to false and starts the close delay
440
- * timer to hide the popover.
445
+ * Handles mouse leave event on the trigger element.
446
+ * This method sets the `isHovered` flag to false and starts the close delay
447
+ * timer to hide the popover.
448
+ * @internal
441
449
  */
442
450
  private handleMouseLeave;
443
451
  /**
444
- * Handles focus out event on the trigger element.
445
452
  * Closes based on hideOnBlur property or hover state.
453
+ * @internal
446
454
  */
447
455
  private handleFocusOut;
448
456
  /**
449
- * Handles focus in event on the trigger element.
450
- * This method checks if the trigger element has visible focus or is being hovered.
457
+ * Handles focus in event on the trigger element.
458
+ * This method checks if the trigger element has visible focus or is being hovered.
459
+ * @internal
451
460
  */
452
461
  private handleFocusIn;
453
462
  /**
454
463
  * Cancels the open delay timer.
464
+ * @internal
455
465
  */
456
466
  private cancelOpenDelay;
457
467
  /**
458
468
  * Starts the close delay timer.
459
469
  * If the popover is not interactive, it will close the popover after the delay.
470
+ * @internal
460
471
  */
461
472
  private startCloseDelay;
462
473
  /**
463
474
  * Cancels the close delay timer.
475
+ * @internal
464
476
  */
465
477
  private cancelCloseDelay;
466
478
  /**
@@ -479,6 +491,7 @@ declare class Popover extends Popover_base {
479
491
  * Positions the popover based on the trigger element.
480
492
  * It also handles the flip, size and arrow placement.
481
493
  * It uses the floating-ui/dom library to calculate the position.
494
+ * @internal
482
495
  */
483
496
  private positionPopover;
484
497
  protected isEventFromTrigger(event: Event): boolean;
@@ -129,8 +129,6 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
129
129
  /**
130
130
  * Get trigger element on-demand
131
131
  * It is necessary because trigger might appear later in the DOM, or it could be replaced completely.
132
- *
133
- * @internal
134
132
  */
135
133
  get triggerElement() {
136
134
  return this.getRootNode().querySelector(`[id="${this.triggerID}"]`);
@@ -384,7 +382,9 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
384
382
  * @internal
385
383
  */
386
384
  this.popoverDepth = 0;
385
+ /** @internal */
387
386
  this.timers = new Timers(this);
387
+ /** @internal */
388
388
  this.parseTrigger = () => {
389
389
  var _a;
390
390
  const triggers = ((_a = this.trigger) === null || _a === void 0 ? void 0 : _a.split(' ')) || [];
@@ -411,6 +411,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
411
411
  *
412
412
  * We are using capture phase for to make sure we capture trigger events even when they are not propagated during the
413
413
  * bubble phase (e.g.: buttons in list item)
414
+ * @internal
414
415
  */
415
416
  this.setupTriggerListeners = () => {
416
417
  if (this.trigger.includes('click')) {
@@ -436,6 +437,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
436
437
  };
437
438
  /**
438
439
  * Removes the trigger related event listeners.
440
+ * @internal
439
441
  */
440
442
  this.removeTriggerListeners = () => {
441
443
  // click trigger
@@ -453,6 +455,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
453
455
  };
454
456
  /**
455
457
  * Removes all event listeners related to the popover.
458
+ * @internal
456
459
  */
457
460
  this.removeAllListeners = () => {
458
461
  this.removeTriggerListeners();
@@ -471,6 +474,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
471
474
  * Handles the outside click event to close the popover.
472
475
  *
473
476
  * @param event - The mouse event.
477
+ * @internal
474
478
  */
475
479
  this.onOutsidePopoverClick = (event) => {
476
480
  if (popoverStack.peek() !== this)
@@ -489,6 +493,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
489
493
  * This method is attached to the document.
490
494
  *
491
495
  * @param event - The keyboard event.
496
+ * @internal
492
497
  */
493
498
  this.onEscapeKeydown = (event) => {
494
499
  if (!this.visible || event.code !== 'Escape') {
@@ -506,6 +511,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
506
511
  * Handles the popover focus out event.
507
512
  *
508
513
  * @param event - The focus event.
514
+ * @internal
509
515
  */
510
516
  this.onPopoverFocusOut = (event) => {
511
517
  if (!this.contains(event.relatedTarget)) {
@@ -513,8 +519,9 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
513
519
  }
514
520
  };
515
521
  /**
516
- * Handles mouse enter event on the trigger element.
517
- * This method sets the `isHovered` flag to true and shows the popover
522
+ * Handles mouse enter event on the trigger element.
523
+ * This method sets the `isHovered` flag to true and shows the popover
524
+ * @internal
518
525
  */
519
526
  this.handleMouseEnter = (event) => {
520
527
  if (!this.isEventFromTrigger(event))
@@ -523,9 +530,10 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
523
530
  this.show();
524
531
  };
525
532
  /**
526
- * Handles mouse leave event on the trigger element.
527
- * This method sets the `isHovered` flag to false and starts the close delay
528
- * timer to hide the popover.
533
+ * Handles mouse leave event on the trigger element.
534
+ * This method sets the `isHovered` flag to false and starts the close delay
535
+ * timer to hide the popover.
536
+ * @internal
529
537
  */
530
538
  this.handleMouseLeave = (event) => {
531
539
  if (!this.isEventFromTrigger(event))
@@ -534,8 +542,8 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
534
542
  this.startCloseDelay();
535
543
  };
536
544
  /**
537
- * Handles focus out event on the trigger element.
538
545
  * Closes based on hideOnBlur property or hover state.
546
+ * @internal
539
547
  */
540
548
  this.handleFocusOut = (event) => {
541
549
  if (!this.isEventFromTrigger(event))
@@ -553,8 +561,9 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
553
561
  }
554
562
  };
555
563
  /**
556
- * Handles focus in event on the trigger element.
557
- * This method checks if the trigger element has visible focus or is being hovered.
564
+ * Handles focus in event on the trigger element.
565
+ * This method checks if the trigger element has visible focus or is being hovered.
566
+ * @internal
558
567
  */
559
568
  this.handleFocusIn = (event) => {
560
569
  var _a, _b, _c, _d;
@@ -568,6 +577,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
568
577
  };
569
578
  /**
570
579
  * Cancels the open delay timer.
580
+ * @internal
571
581
  */
572
582
  this.cancelOpenDelay = () => {
573
583
  this.timers.clearTimeout(TIMEOUTS.OPEN);
@@ -575,6 +585,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
575
585
  /**
576
586
  * Starts the close delay timer.
577
587
  * If the popover is not interactive, it will close the popover after the delay.
588
+ * @internal
578
589
  */
579
590
  this.startCloseDelay = () => {
580
591
  this.cancelOpenDelay();
@@ -596,6 +607,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
596
607
  };
597
608
  /**
598
609
  * Cancels the close delay timer.
610
+ * @internal
599
611
  */
600
612
  this.cancelCloseDelay = () => {
601
613
  this.timers.clearTimeout(TIMEOUTS.HOVER);
@@ -656,6 +668,7 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
656
668
  * Positions the popover based on the trigger element.
657
669
  * It also handles the flip, size and arrow placement.
658
670
  * It uses the floating-ui/dom library to calculate the position.
671
+ * @internal
659
672
  */
660
673
  this.positionPopover = () => {
661
674
  const { triggerElement } = this;
@@ -27,6 +27,10 @@ declare const STRATEGY: {
27
27
  readonly ABSOLUTE: "absolute";
28
28
  readonly FIXED: "fixed";
29
29
  };
30
+ declare const BOUNDARY_ROOT: {
31
+ readonly VIEWPORT: "viewport";
32
+ readonly DOCUMENT: "document";
33
+ };
30
34
  declare const DEFAULTS: {
31
35
  readonly PLACEMENT: "bottom";
32
36
  readonly TRIGGER: "click";
@@ -63,4 +67,4 @@ declare const TIMEOUTS: {
63
67
  readonly HOVER: "hover";
64
68
  readonly CLOSE: "close";
65
69
  };
66
- export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, DEFAULTS, TIMEOUTS };
70
+ export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, BOUNDARY_ROOT, DEFAULTS, TIMEOUTS };
@@ -29,6 +29,10 @@ const STRATEGY = {
29
29
  ABSOLUTE: 'absolute',
30
30
  FIXED: 'fixed',
31
31
  };
32
+ const BOUNDARY_ROOT = {
33
+ VIEWPORT: 'viewport',
34
+ DOCUMENT: 'document',
35
+ };
32
36
  const DEFAULTS = {
33
37
  PLACEMENT: POPOVER_PLACEMENT.BOTTOM,
34
38
  TRIGGER: TRIGGER.CLICK,
@@ -36,7 +40,7 @@ const DEFAULTS = {
36
40
  STRATEGY: STRATEGY.ABSOLUTE,
37
41
  OFFSET: 4,
38
42
  BOUNDARY: 'clippingAncestors',
39
- BOUNDARY_ROOT: 'viewport',
43
+ BOUNDARY_ROOT: BOUNDARY_ROOT.VIEWPORT,
40
44
  BOUNDARY_PADDING: 0,
41
45
  VISIBLE: false,
42
46
  ARROW: false,
@@ -65,4 +69,4 @@ const TIMEOUTS = {
65
69
  HOVER: 'hover',
66
70
  CLOSE: 'close',
67
71
  };
68
- export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, DEFAULTS, TIMEOUTS };
72
+ export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, BOUNDARY_ROOT, DEFAULTS, TIMEOUTS };
@@ -1,9 +1,10 @@
1
1
  import type { ValueOf, TypedCustomEvent } from '../../utils/types';
2
2
  import type Popover from './popover.component';
3
- import { POPOVER_PLACEMENT, TRIGGER, COLOR, STRATEGY } from './popover.constants';
3
+ import { POPOVER_PLACEMENT, TRIGGER, COLOR, STRATEGY, BOUNDARY_ROOT } from './popover.constants';
4
4
  type PopoverPlacement = ValueOf<typeof POPOVER_PLACEMENT>;
5
5
  type PopoverColor = ValueOf<typeof COLOR>;
6
6
  type PopoverStrategy = ValueOf<typeof STRATEGY>;
7
+ type PopoverBoundaryRoot = ValueOf<typeof BOUNDARY_ROOT>;
7
8
  type PopoverTrigger = ValueOf<typeof TRIGGER> | `${ValueOf<typeof TRIGGER>} ${ValueOf<typeof TRIGGER>}`;
8
9
  type PopoverShownEvent = TypedCustomEvent<Popover, {
9
10
  show: boolean;
@@ -23,4 +24,4 @@ interface Events {
23
24
  onCreatedEvent: PopoverCreatedEvent;
24
25
  onDestroyedEvent: PopoverDestroyedEvent;
25
26
  }
26
- export type { PopoverPlacement, PopoverColor, PopoverStrategy, PopoverTrigger, Events, PopoverShownEvent, PopoverHiddenEvent, };
27
+ export type { PopoverPlacement, PopoverColor, PopoverStrategy, PopoverBoundaryRoot, PopoverTrigger, Events, PopoverShownEvent, PopoverHiddenEvent, };