@justeattakeaway/pie-tooltip 0.2.0 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -19,7 +19,7 @@ export declare const componentClass = "c-tooltip";
19
19
 
20
20
  export declare const componentSelector = "pie-tooltip";
21
21
 
22
- export declare type DefaultProps = ComponentDefaultProps<TooltipProps, keyof Omit<TooltipProps, 'trigger' | 'heading' | 'aria'>>;
22
+ export declare type DefaultProps = ComponentDefaultProps<TooltipProps, keyof Omit<TooltipProps, 'trigger' | 'heading' | 'aria' | 'triggers'>>;
23
23
 
24
24
  export declare const defaultProps: DefaultProps;
25
25
 
@@ -33,9 +33,12 @@ export declare const modes: readonly ["tooltip", "dialog"];
33
33
 
34
34
  export declare const ON_TOOLTIP_CLOSE_EVENT = "pie-tooltip-close";
35
35
 
36
+ export declare const ON_TOOLTIP_OPEN_EVENT = "pie-tooltip-open";
37
+
36
38
  /**
37
39
  * @tagname pie-tooltip
38
- * @event {Event} pie-tooltip-close - When the close button is clicked. Set `isOpen` to `false` in response.
40
+ * @event {Event} pie-tooltip-open - When a configured trigger asks for the panel. Set `isOpen` to `true` in response.
41
+ * @event {Event} pie-tooltip-close - When the close button is clicked, or a configured trigger asks to dismiss the panel. Set `isOpen` to `false` in response.
39
42
  * @slot content - The descriptive content of the panel. Must not contain focusable elements.
40
43
  * @slot action - An optional slot for interactive content such as a `pie-button`. Filling this slot switches the panel to a non-modal dialog.
41
44
  */
@@ -50,14 +53,25 @@ export declare class PieTooltip extends PieElement implements TooltipProps {
50
53
  heading: TooltipProps['heading'];
51
54
  headingLevel: "h2" | "h3" | "h4" | "h5" | "h6";
52
55
  aria: TooltipProps['aria'];
56
+ triggers: TooltipProps['triggers'];
53
57
  private _assignedActionElements;
54
58
  private _originElement;
55
59
  private _hasActionContent;
56
60
  private _isPositioned;
61
+ private _isAnchorVisible;
62
+ private _resolvedPosition;
63
+ private _clippedTriggerElement;
64
+ private _triggerClippers;
65
+ private _overlayClippers;
66
+ private _collisionSignature;
67
+ private _overlayModeDirty;
57
68
  private _triggerTrackingController;
69
+ private _interactionController;
58
70
  private _directionObserver;
71
+ private _triggerObserver;
59
72
  private _reanchorFrame;
60
- private _shouldResolveOverlayMode;
73
+ private _hoverCloseTimer;
74
+ private _openedByClick;
61
75
  static styles: CSSResult;
62
76
  private get _mode();
63
77
  protected firstUpdated(): void;
@@ -68,7 +82,19 @@ export declare class PieTooltip extends PieElement implements TooltipProps {
68
82
  private resolveMode;
69
83
  private resolveOverlayMode;
70
84
  private projectOverTrigger;
85
+ private resolveCollision;
86
+ private _setResolvedPosition;
87
+ private _getCollisionBoundary;
88
+ private _getCandidatePositions;
89
+ private _refreshTriggerClippers;
71
90
  private handleCloseButtonClick;
91
+ private _getTriggerElement;
92
+ private _requestOpen;
93
+ private _requestClose;
94
+ private _startHoverCloseTimer;
95
+ private _cancelHoverCloseTimer;
96
+ private _rebuildInteractionListeners;
97
+ private _teardownInteractionListeners;
72
98
  private renderHeading;
73
99
  private renderCloseButton;
74
100
  render(): TemplateResult;
@@ -92,7 +118,10 @@ export declare interface TooltipProps {
92
118
  */
93
119
  isOpen?: boolean;
94
120
  /**
95
- * The side of the trigger the panel sits on, and its alignment along the cross axis.
121
+ * The preferred side of the trigger the panel sits on, and its alignment along the cross axis.
122
+ * The component repositions the panel automatically — flipping to the opposite side and/or
123
+ * shifting its alignment — when the preferred position would collide with the viewport or with
124
+ * a clipping scroll container. This behaviour cannot be disabled.
96
125
  */
97
126
  position?: typeof positions[number];
98
127
  /**
@@ -128,8 +157,20 @@ export declare interface TooltipProps {
128
157
  * The ARIA labels used for various parts of the tooltip.
129
158
  */
130
159
  aria?: AriaProps;
160
+ /**
161
+ * Which interactions request that the panel opens and closes. The component never opens or
162
+ * closes itself: a configured interaction emits `pie-tooltip-open` or `pie-tooltip-close`
163
+ * and the consumer decides whether to honour it by setting `isOpen`. Empty by default, so
164
+ * no interaction is watched at all. Configure `hover` and `focus` together for keyboard
165
+ * reachability, and `click` for pointer users.
166
+ */
167
+ triggers?: Array<TooltipTrigger>;
131
168
  }
132
169
 
170
+ export declare type TooltipTrigger = typeof triggers[number];
171
+
172
+ export declare const triggers: readonly ["hover", "focus", "click"];
173
+
133
174
  export declare const types: readonly ["default", "icon"];
134
175
 
135
176
  export declare const variants: readonly ["default", "inverse"];