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