@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/README.md +202 -8
- package/custom-elements.json +292 -2
- package/dist/index.d.ts +45 -4
- package/dist/index.js +387 -160
- package/dist/react.d.ts +46 -4
- package/dist/react.js +16 -12
- package/package.json +6 -6
- package/src/defs.ts +17 -2
- package/src/index.ts +599 -39
- package/src/react.ts +3 -1
- package/src/tooltip.scss +46 -2
package/dist/react.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const componentClass = "c-tooltip";
|
|
|
20
20
|
|
|
21
21
|
export declare const componentSelector = "pie-tooltip";
|
|
22
22
|
|
|
23
|
-
export declare type DefaultProps = ComponentDefaultProps<TooltipProps, keyof Omit<TooltipProps, 'trigger' | 'heading' | 'aria'>>;
|
|
23
|
+
export declare type DefaultProps = ComponentDefaultProps<TooltipProps, keyof Omit<TooltipProps, 'trigger' | 'heading' | 'aria' | 'triggers'>>;
|
|
24
24
|
|
|
25
25
|
export declare const defaultProps: DefaultProps;
|
|
26
26
|
|
|
@@ -34,11 +34,14 @@ export declare const modes: readonly ["tooltip", "dialog"];
|
|
|
34
34
|
|
|
35
35
|
export declare const ON_TOOLTIP_CLOSE_EVENT = "pie-tooltip-close";
|
|
36
36
|
|
|
37
|
+
export declare const ON_TOOLTIP_OPEN_EVENT = "pie-tooltip-open";
|
|
38
|
+
|
|
37
39
|
export declare const PieTooltip: React_2.ForwardRefExoticComponent<React_2.PropsWithChildren<Omit<React_2.PropsWithoutRef<TooltipProps>, "children">> & React_2.RefAttributes<PieTooltip_2> & PieTooltipEvents & ReactBaseType>;
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* @tagname pie-tooltip
|
|
41
|
-
* @event {Event} pie-tooltip-
|
|
43
|
+
* @event {Event} pie-tooltip-open - When a configured trigger asks for the panel. Set `isOpen` to `true` in response.
|
|
44
|
+
* @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.
|
|
42
45
|
* @slot content - The descriptive content of the panel. Must not contain focusable elements.
|
|
43
46
|
* @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
47
|
*/
|
|
@@ -53,14 +56,25 @@ declare class PieTooltip_2 extends PieElement implements TooltipProps {
|
|
|
53
56
|
heading: TooltipProps['heading'];
|
|
54
57
|
headingLevel: "h2" | "h3" | "h4" | "h5" | "h6";
|
|
55
58
|
aria: TooltipProps['aria'];
|
|
59
|
+
triggers: TooltipProps['triggers'];
|
|
56
60
|
private _assignedActionElements;
|
|
57
61
|
private _originElement;
|
|
58
62
|
private _hasActionContent;
|
|
59
63
|
private _isPositioned;
|
|
64
|
+
private _isAnchorVisible;
|
|
65
|
+
private _resolvedPosition;
|
|
66
|
+
private _clippedTriggerElement;
|
|
67
|
+
private _triggerClippers;
|
|
68
|
+
private _overlayClippers;
|
|
69
|
+
private _collisionSignature;
|
|
70
|
+
private _overlayModeDirty;
|
|
60
71
|
private _triggerTrackingController;
|
|
72
|
+
private _interactionController;
|
|
61
73
|
private _directionObserver;
|
|
74
|
+
private _triggerObserver;
|
|
62
75
|
private _reanchorFrame;
|
|
63
|
-
private
|
|
76
|
+
private _hoverCloseTimer;
|
|
77
|
+
private _openedByClick;
|
|
64
78
|
static styles: CSSResult;
|
|
65
79
|
private get _mode();
|
|
66
80
|
protected firstUpdated(): void;
|
|
@@ -71,13 +85,26 @@ declare class PieTooltip_2 extends PieElement implements TooltipProps {
|
|
|
71
85
|
private resolveMode;
|
|
72
86
|
private resolveOverlayMode;
|
|
73
87
|
private projectOverTrigger;
|
|
88
|
+
private resolveCollision;
|
|
89
|
+
private _setResolvedPosition;
|
|
90
|
+
private _getCollisionBoundary;
|
|
91
|
+
private _getCandidatePositions;
|
|
92
|
+
private _refreshTriggerClippers;
|
|
74
93
|
private handleCloseButtonClick;
|
|
94
|
+
private _getTriggerElement;
|
|
95
|
+
private _requestOpen;
|
|
96
|
+
private _requestClose;
|
|
97
|
+
private _startHoverCloseTimer;
|
|
98
|
+
private _cancelHoverCloseTimer;
|
|
99
|
+
private _rebuildInteractionListeners;
|
|
100
|
+
private _teardownInteractionListeners;
|
|
75
101
|
private renderHeading;
|
|
76
102
|
private renderCloseButton;
|
|
77
103
|
render(): TemplateResult;
|
|
78
104
|
}
|
|
79
105
|
|
|
80
106
|
declare type PieTooltipEvents = {
|
|
107
|
+
onPieTooltipOpen?: (event: Event) => void;
|
|
81
108
|
onPieTooltipClose?: (event: Event) => void;
|
|
82
109
|
};
|
|
83
110
|
|
|
@@ -101,7 +128,10 @@ export declare interface TooltipProps {
|
|
|
101
128
|
*/
|
|
102
129
|
isOpen?: boolean;
|
|
103
130
|
/**
|
|
104
|
-
* The side of the trigger the panel sits on, and its alignment along the cross axis.
|
|
131
|
+
* The preferred side of the trigger the panel sits on, and its alignment along the cross axis.
|
|
132
|
+
* The component repositions the panel automatically — flipping to the opposite side and/or
|
|
133
|
+
* shifting its alignment — when the preferred position would collide with the viewport or with
|
|
134
|
+
* a clipping scroll container. This behaviour cannot be disabled.
|
|
105
135
|
*/
|
|
106
136
|
position?: typeof positions[number];
|
|
107
137
|
/**
|
|
@@ -137,8 +167,20 @@ export declare interface TooltipProps {
|
|
|
137
167
|
* The ARIA labels used for various parts of the tooltip.
|
|
138
168
|
*/
|
|
139
169
|
aria?: AriaProps;
|
|
170
|
+
/**
|
|
171
|
+
* Which interactions request that the panel opens and closes. The component never opens or
|
|
172
|
+
* closes itself: a configured interaction emits `pie-tooltip-open` or `pie-tooltip-close`
|
|
173
|
+
* and the consumer decides whether to honour it by setting `isOpen`. Empty by default, so
|
|
174
|
+
* no interaction is watched at all. Configure `hover` and `focus` together for keyboard
|
|
175
|
+
* reachability, and `click` for pointer users.
|
|
176
|
+
*/
|
|
177
|
+
triggers?: Array<TooltipTrigger>;
|
|
140
178
|
}
|
|
141
179
|
|
|
180
|
+
export declare type TooltipTrigger = typeof triggers[number];
|
|
181
|
+
|
|
182
|
+
export declare const triggers: readonly ["hover", "focus", "click"];
|
|
183
|
+
|
|
142
184
|
export declare const types: readonly ["default", "icon"];
|
|
143
185
|
|
|
144
186
|
export declare const variants: readonly ["default", "inverse"];
|
package/dist/react.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import * as o from "react";
|
|
2
2
|
import { createComponent as e } from "@lit/react";
|
|
3
3
|
import { PieTooltip as t } from "./index.js";
|
|
4
|
-
import { ON_TOOLTIP_CLOSE_EVENT as
|
|
4
|
+
import { ON_TOOLTIP_CLOSE_EVENT as r, ON_TOOLTIP_OPEN_EVENT as m, componentClass as T, componentSelector as P, defaultProps as c, headingLevels as O, modes as N, positions as E, sizes as _, triggers as f, types as C, variants as d } from "./index.js";
|
|
5
5
|
const i = e({
|
|
6
6
|
displayName: "PieTooltip",
|
|
7
7
|
elementClass: t,
|
|
8
8
|
react: o,
|
|
9
9
|
tagName: "pie-tooltip",
|
|
10
10
|
events: {
|
|
11
|
+
onPieTooltipOpen: "pie-tooltip-open",
|
|
12
|
+
// When a configured trigger asks for the panel. Set `isOpen` to `true` in response.
|
|
11
13
|
onPieTooltipClose: "pie-tooltip-close"
|
|
12
|
-
// When the close button is clicked. Set `isOpen` to `false` in response.
|
|
14
|
+
// When the close button is clicked, or a configured trigger asks to dismiss the panel. Set `isOpen` to `false` in response.
|
|
13
15
|
}
|
|
14
16
|
}), l = i;
|
|
15
17
|
export {
|
|
16
|
-
|
|
18
|
+
r as ON_TOOLTIP_CLOSE_EVENT,
|
|
19
|
+
m as ON_TOOLTIP_OPEN_EVENT,
|
|
17
20
|
l as PieTooltip,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
T as componentClass,
|
|
22
|
+
P as componentSelector,
|
|
23
|
+
c as defaultProps,
|
|
24
|
+
O as headingLevels,
|
|
25
|
+
N as modes,
|
|
26
|
+
E as positions,
|
|
27
|
+
_ as sizes,
|
|
28
|
+
f as triggers,
|
|
29
|
+
C as types,
|
|
30
|
+
d as variants
|
|
27
31
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-tooltip",
|
|
3
3
|
"description": "PIE Design System Tooltip built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@justeattakeaway/pie-components-config": "0.21.4",
|
|
39
|
-
"@justeattakeaway/pie-css": "1.
|
|
40
|
-
"@justeattakeaway/pie-monorepo-utils": "0.9.
|
|
39
|
+
"@justeattakeaway/pie-css": "1.9.0",
|
|
40
|
+
"@justeattakeaway/pie-monorepo-utils": "0.9.10"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@justeattakeaway/pie-icon-button": "2.7.
|
|
44
|
-
"@justeattakeaway/pie-icons-webc": "1.29.
|
|
45
|
-
"@justeattakeaway/pie-webc-core": "
|
|
43
|
+
"@justeattakeaway/pie-icon-button": "2.7.35",
|
|
44
|
+
"@justeattakeaway/pie-icons-webc": "1.29.4",
|
|
45
|
+
"@justeattakeaway/pie-webc-core": "22.0.0"
|
|
46
46
|
},
|
|
47
47
|
"customElements": "custom-elements.json",
|
|
48
48
|
"sideEffects": [
|
package/src/defs.ts
CHANGED
|
@@ -19,6 +19,7 @@ export const sizes = ['default', 'fit-to-content', 'fill-container'] as const;
|
|
|
19
19
|
export const variants = ['default', 'inverse'] as const;
|
|
20
20
|
export const types = ['default', 'icon'] as const;
|
|
21
21
|
export const headingLevels = ['h2', 'h3', 'h4', 'h5', 'h6'] as const;
|
|
22
|
+
export const triggers = ['hover', 'focus', 'click'] as const;
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* The two patterns the panel can present as. Inferred from the `action` slot rather than
|
|
@@ -27,6 +28,7 @@ export const headingLevels = ['h2', 'h3', 'h4', 'h5', 'h6'] as const;
|
|
|
27
28
|
export const modes = ['tooltip', 'dialog'] as const;
|
|
28
29
|
|
|
29
30
|
export type TooltipMode = typeof modes[number];
|
|
31
|
+
export type TooltipTrigger = typeof triggers[number];
|
|
30
32
|
|
|
31
33
|
type AriaProps = {
|
|
32
34
|
/**
|
|
@@ -54,7 +56,10 @@ export interface TooltipProps {
|
|
|
54
56
|
isOpen?: boolean;
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
|
-
* The side of the trigger the panel sits on, and its alignment along the cross axis.
|
|
59
|
+
* The preferred side of the trigger the panel sits on, and its alignment along the cross axis.
|
|
60
|
+
* The component repositions the panel automatically — flipping to the opposite side and/or
|
|
61
|
+
* shifting its alignment — when the preferred position would collide with the viewport or with
|
|
62
|
+
* a clipping scroll container. This behaviour cannot be disabled.
|
|
58
63
|
*/
|
|
59
64
|
position?: typeof positions[number];
|
|
60
65
|
|
|
@@ -97,14 +102,24 @@ export interface TooltipProps {
|
|
|
97
102
|
* The ARIA labels used for various parts of the tooltip.
|
|
98
103
|
*/
|
|
99
104
|
aria?: AriaProps;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Which interactions request that the panel opens and closes. The component never opens or
|
|
108
|
+
* closes itself: a configured interaction emits `pie-tooltip-open` or `pie-tooltip-close`
|
|
109
|
+
* and the consumer decides whether to honour it by setting `isOpen`. Empty by default, so
|
|
110
|
+
* no interaction is watched at all. Configure `hover` and `focus` together for keyboard
|
|
111
|
+
* reachability, and `click` for pointer users.
|
|
112
|
+
*/
|
|
113
|
+
triggers?: Array<TooltipTrigger>;
|
|
100
114
|
}
|
|
101
115
|
|
|
102
116
|
export const componentSelector = 'pie-tooltip';
|
|
103
117
|
export const componentClass = 'c-tooltip';
|
|
104
118
|
|
|
119
|
+
export const ON_TOOLTIP_OPEN_EVENT = `${componentSelector}-open`;
|
|
105
120
|
export const ON_TOOLTIP_CLOSE_EVENT = `${componentSelector}-close`;
|
|
106
121
|
|
|
107
|
-
export type DefaultProps = ComponentDefaultProps<TooltipProps, keyof Omit<TooltipProps, 'trigger' | 'heading' | 'aria'>>;
|
|
122
|
+
export type DefaultProps = ComponentDefaultProps<TooltipProps, keyof Omit<TooltipProps, 'trigger' | 'heading' | 'aria' | 'triggers'>>;
|
|
108
123
|
|
|
109
124
|
export const defaultProps: DefaultProps = {
|
|
110
125
|
isOpen: false,
|