@justeattakeaway/pie-tooltip 0.3.0 → 0.5.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/README.md +99 -33
- package/custom-elements.json +136 -6
- package/dist/index.d.ts +27 -56
- package/dist/index.js +352 -240
- package/dist/react.d.ts +27 -56
- package/dist/react.js +1 -1
- package/package.json +4 -4
- package/src/defs.ts +14 -54
- package/src/index.ts +338 -95
- package/src/react.ts +1 -1
- package/src/tooltip.scss +8 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,9 @@ import { PropertyValues } from 'lit';
|
|
|
5
5
|
import { TemplateResult } from 'lit';
|
|
6
6
|
|
|
7
7
|
declare type AriaProps = {
|
|
8
|
-
/**
|
|
9
|
-
* The accessible name for the close button. Required whenever `isDismissible` is set.
|
|
10
|
-
*/
|
|
8
|
+
/** The accessible name for the close button. Required whenever `isDismissible` is set. */
|
|
11
9
|
close?: string;
|
|
12
|
-
/**
|
|
13
|
-
* The accessible name for the panel in dialog mode. Only used when `heading` is not provided.
|
|
14
|
-
*/
|
|
10
|
+
/** The accessible name for the panel in dialog mode, when no `heading` is provided. */
|
|
15
11
|
label?: string;
|
|
16
12
|
};
|
|
17
13
|
|
|
@@ -25,10 +21,7 @@ export declare const defaultProps: DefaultProps;
|
|
|
25
21
|
|
|
26
22
|
export declare const headingLevels: readonly ["h2", "h3", "h4", "h5", "h6"];
|
|
27
23
|
|
|
28
|
-
/**
|
|
29
|
-
* The two patterns the panel can present as. Inferred from the `action` slot rather than
|
|
30
|
-
* configured: an empty `action` slot is a tooltip, a filled one is a non-modal dialog.
|
|
31
|
-
*/
|
|
24
|
+
/** The two patterns the panel can present as, inferred from the `action` slot. */
|
|
32
25
|
export declare const modes: readonly ["tooltip", "dialog"];
|
|
33
26
|
|
|
34
27
|
export declare const ON_TOOLTIP_CLOSE_EVENT = "pie-tooltip-close";
|
|
@@ -38,7 +31,7 @@ export declare const ON_TOOLTIP_OPEN_EVENT = "pie-tooltip-open";
|
|
|
38
31
|
/**
|
|
39
32
|
* @tagname pie-tooltip
|
|
40
33
|
* @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.
|
|
34
|
+
* @event {Event} pie-tooltip-close - When the close button is clicked, Escape is pressed, or a configured trigger asks to dismiss the panel. Set `isOpen` to `false` in response.
|
|
42
35
|
* @slot content - The descriptive content of the panel. Must not contain focusable elements.
|
|
43
36
|
* @slot action - An optional slot for interactive content such as a `pie-button`. Filling this slot switches the panel to a non-modal dialog.
|
|
44
37
|
*/
|
|
@@ -59,25 +52,36 @@ export declare class PieTooltip extends PieElement implements TooltipProps {
|
|
|
59
52
|
private _hasActionContent;
|
|
60
53
|
private _isPositioned;
|
|
61
54
|
private _isAnchorVisible;
|
|
55
|
+
private _resolvedPosition;
|
|
62
56
|
private _clippedTriggerElement;
|
|
63
57
|
private _triggerClippers;
|
|
58
|
+
private _overlayClippers;
|
|
59
|
+
private _collisionSignature;
|
|
60
|
+
private _overlayModeDirty;
|
|
64
61
|
private _triggerTrackingController;
|
|
65
62
|
private _interactionController;
|
|
66
63
|
private _directionObserver;
|
|
67
64
|
private _triggerObserver;
|
|
68
65
|
private _reanchorFrame;
|
|
69
|
-
private _shouldResolveOverlayMode;
|
|
70
66
|
private _hoverCloseTimer;
|
|
67
|
+
private _openedByClick;
|
|
68
|
+
private readonly _instanceId;
|
|
69
|
+
private get _headingId();
|
|
71
70
|
static styles: CSSResult;
|
|
72
71
|
private get _mode();
|
|
73
72
|
protected firstUpdated(): void;
|
|
74
73
|
protected updated(changedProperties: PropertyValues<this>): void;
|
|
75
74
|
disconnectedCallback(): void;
|
|
75
|
+
focusPanel(): Promise<boolean>;
|
|
76
76
|
private startTrackingTrigger;
|
|
77
77
|
private stopTrackingTrigger;
|
|
78
78
|
private resolveMode;
|
|
79
79
|
private resolveOverlayMode;
|
|
80
80
|
private projectOverTrigger;
|
|
81
|
+
private resolveCollision;
|
|
82
|
+
private _setResolvedPosition;
|
|
83
|
+
private _getCollisionBoundary;
|
|
84
|
+
private _getCandidatePositions;
|
|
81
85
|
private _refreshTriggerClippers;
|
|
82
86
|
private handleCloseButtonClick;
|
|
83
87
|
private _getTriggerElement;
|
|
@@ -99,60 +103,27 @@ export declare const sizes: readonly ["default", "fit-to-content", "fill-contain
|
|
|
99
103
|
export declare type TooltipMode = typeof modes[number];
|
|
100
104
|
|
|
101
105
|
export declare interface TooltipProps {
|
|
102
|
-
/**
|
|
103
|
-
* The `id` of the element the panel is anchored to. The trigger lives elsewhere in the
|
|
104
|
-
* DOM and is never slotted into the tooltip.
|
|
105
|
-
*/
|
|
106
|
+
/** The `id` of the element the panel is anchored to. */
|
|
106
107
|
trigger?: string;
|
|
107
|
-
/**
|
|
108
|
-
* When true, the panel is visible. The component never writes to this property: the
|
|
109
|
-
* consumer owns it and updates it in response to the close event.
|
|
110
|
-
*/
|
|
108
|
+
/** When true, the panel is visible. The component never writes to this property. */
|
|
111
109
|
isOpen?: boolean;
|
|
112
|
-
/**
|
|
113
|
-
* The side of the trigger the panel sits on, and its alignment along the cross axis.
|
|
114
|
-
*/
|
|
110
|
+
/** The preferred side and alignment; the panel repositions itself to avoid collisions. */
|
|
115
111
|
position?: typeof positions[number];
|
|
116
|
-
/**
|
|
117
|
-
* How the panel sizes itself. `default` is a fixed 280px and wraps, `fit-to-content` is as
|
|
118
|
-
* wide as its content, and `fill-container` matches the inline size of the trigger's parent
|
|
119
|
-
* element. Not applied when `type` is `icon`.
|
|
120
|
-
*/
|
|
112
|
+
/** How the panel sizes itself. Not applied when `type` is `icon`. */
|
|
121
113
|
size?: typeof sizes[number];
|
|
122
|
-
/**
|
|
123
|
-
* The colour treatment of the panel. `default` is the dark panel, `inverse` the light one.
|
|
124
|
-
*/
|
|
114
|
+
/** The colour treatment of the panel. `default` is the dark panel, `inverse` the light one. */
|
|
125
115
|
variant?: typeof variants[number];
|
|
126
|
-
/**
|
|
127
|
-
* The presentation of the panel. `icon` is the compact treatment intended for icon triggers:
|
|
128
|
-
* it has no arrow and is always as wide as its content, so `size` and `--tooltip-width` have
|
|
129
|
-
* no effect on it.
|
|
130
|
-
*/
|
|
116
|
+
/** The presentation of the panel. `icon` is the compact, arrow-less treatment. */
|
|
131
117
|
type?: typeof types[number];
|
|
132
|
-
/**
|
|
133
|
-
* When true, a close button is rendered inside the panel.
|
|
134
|
-
*/
|
|
118
|
+
/** When true, a close button is rendered inside the panel and the panel presents as a non-modal dialog, so it needs `heading` or `aria.label` for its accessible name. */
|
|
135
119
|
isDismissible?: boolean;
|
|
136
|
-
/**
|
|
137
|
-
* The text to display in the panel's heading. In dialog mode this also provides the
|
|
138
|
-
* panel's accessible name.
|
|
139
|
-
*/
|
|
120
|
+
/** The text to display in the panel's heading. In dialog mode this also names the panel. */
|
|
140
121
|
heading?: string;
|
|
141
|
-
/**
|
|
142
|
-
* The HTML heading tag to use for the panel's heading. Can be h2-h6.
|
|
143
|
-
*/
|
|
122
|
+
/** The HTML heading tag to use for the panel's heading. Can be h2-h6. */
|
|
144
123
|
headingLevel?: typeof headingLevels[number];
|
|
145
|
-
/**
|
|
146
|
-
* The ARIA labels used for various parts of the tooltip.
|
|
147
|
-
*/
|
|
124
|
+
/** The ARIA labels used for various parts of the tooltip. */
|
|
148
125
|
aria?: AriaProps;
|
|
149
|
-
/**
|
|
150
|
-
* Which interactions request that the panel opens and closes. The component never opens or
|
|
151
|
-
* closes itself: a configured interaction emits `pie-tooltip-open` or `pie-tooltip-close`
|
|
152
|
-
* and the consumer decides whether to honour it by setting `isOpen`. Empty by default, so
|
|
153
|
-
* no interaction is watched at all. Configure `hover` and `focus` together for keyboard
|
|
154
|
-
* reachability, and `click` for pointer users.
|
|
155
|
-
*/
|
|
126
|
+
/** Which interactions request that the panel opens and closes. */
|
|
156
127
|
triggers?: Array<TooltipTrigger>;
|
|
157
128
|
}
|
|
158
129
|
|