@atlaskit/tooltip 17.8.1 → 17.8.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/tooltip
2
2
 
3
+ ## 17.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
8
+
3
9
  ## 17.8.1
4
10
 
5
11
  ### Patch Changes
@@ -32,7 +32,7 @@ var tooltipZIndex = _constants.layers.tooltip();
32
32
  var analyticsAttributes = {
33
33
  componentName: 'tooltip',
34
34
  packageName: "@atlaskit/tooltip",
35
- packageVersion: "17.8.1"
35
+ packageVersion: "17.8.2"
36
36
  };
37
37
 
38
38
  // Inverts motion direction
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.8.1",
3
+ "version": "17.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -20,7 +20,7 @@ const tooltipZIndex = layers.tooltip();
20
20
  const analyticsAttributes = {
21
21
  componentName: 'tooltip',
22
22
  packageName: "@atlaskit/tooltip",
23
- packageVersion: "17.8.1"
23
+ packageVersion: "17.8.2"
24
24
  };
25
25
 
26
26
  // Inverts motion direction
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.8.1",
3
+ "version": "17.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -24,7 +24,7 @@ var tooltipZIndex = layers.tooltip();
24
24
  var analyticsAttributes = {
25
25
  componentName: 'tooltip',
26
26
  packageName: "@atlaskit/tooltip",
27
- packageVersion: "17.8.1"
27
+ packageVersion: "17.8.2"
28
28
  };
29
29
 
30
30
  // Inverts motion direction
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.8.1",
3
+ "version": "17.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,8 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { TooltipProps } from './types';
4
+ declare function Tooltip({ children, position, mousePosition, content, truncate, component: Container, tag: TargetContainer, testId, delay, onShow, onHide, hideTooltipOnClick, hideTooltipOnMouseDown, analyticsContext, strategy, }: TooltipProps): jsx.JSX.Element;
5
+ declare namespace Tooltip {
6
+ var displayName: string;
7
+ }
8
+ export default Tooltip;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { TooltipPrimitiveProps } from './TooltipPrimitive';
3
+ export interface TooltipContainerProps extends TooltipPrimitiveProps {
4
+ }
5
+ declare const TooltipContainer: import("react").ForwardRefExoticComponent<Pick<TooltipContainerProps, "style" | "className" | "children" | "placement" | "testId" | "onMouseOut" | "onMouseOver" | "id" | "truncate"> & import("react").RefAttributes<HTMLDivElement>>;
6
+ export default TooltipContainer;
@@ -0,0 +1,17 @@
1
+ /** @jsx jsx */
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ import { PositionType } from './types';
4
+ export interface TooltipPrimitiveProps {
5
+ truncate?: boolean;
6
+ style?: CSSProperties;
7
+ className?: string;
8
+ children: ReactNode;
9
+ testId?: string;
10
+ placement: PositionType;
11
+ ref: React.Ref<any>;
12
+ onMouseOver?: (e: React.MouseEvent<HTMLElement>) => void;
13
+ onMouseOut?: (e: React.MouseEvent<HTMLElement>) => void;
14
+ id?: string;
15
+ }
16
+ declare const TooltipPrimitive: import("react").ForwardRefExoticComponent<Pick<TooltipPrimitiveProps, "style" | "className" | "children" | "placement" | "testId" | "onMouseOut" | "onMouseOver" | "id" | "truncate"> & import("react").RefAttributes<HTMLDivElement>>;
17
+ export default TooltipPrimitive;
@@ -0,0 +1,4 @@
1
+ export { default } from './Tooltip';
2
+ export { default as TooltipPrimitive } from './TooltipPrimitive';
3
+ export type { TooltipPrimitiveProps } from './TooltipPrimitive';
4
+ export type { PositionType, TooltipProps } from './types';
@@ -0,0 +1,84 @@
1
+ import { ComponentType, ElementType, ReactNode } from 'react';
2
+ import { TooltipPrimitiveProps } from '../TooltipPrimitive';
3
+ import { PositionType, PositionTypeBase } from '../types';
4
+ type Props = {
5
+ /**
6
+ * The content of the tooltip. It can be either a:
7
+ * 1. `ReactNode`
8
+ * 2. Function which returns a `ReactNode`
9
+
10
+ * The benefit of the second approach is that it allows you to consume the `update` render prop.
11
+ * This `update` function can be called to manually recalculate the position of the tooltip.
12
+ */
13
+ content: ReactNode | (({ update }: {
14
+ update: () => void;
15
+ }) => ReactNode);
16
+ /**
17
+ * Extend `TooltipPrimitive` to create your own tooltip and pass it as component
18
+ */
19
+ component?: ComponentType<TooltipPrimitiveProps>;
20
+ /**
21
+ * Time in milliseconds to wait before showing and hiding the tooltip. Defaults to 300.
22
+ */
23
+ delay?: number;
24
+ /**
25
+ * Hide the tooltip when the click event is triggered. This should be
26
+ * used when tooltip should be hidden if `onClick` react synthetic event
27
+ * is triggered, which happens after `onMouseDown` event
28
+ */
29
+ hideTooltipOnClick?: boolean;
30
+ /**
31
+ * Hide the tooltip when the mousedown event is triggered. This should be
32
+ * used when tooltip should be hidden if `onMouseDown` react synthetic event
33
+ * is triggered, which happens before `onClick` event
34
+ */
35
+ hideTooltipOnMouseDown?: boolean;
36
+ /**
37
+ * Where the tooltip should appear relative to the mouse pointer.
38
+ * Only used when the `position` prop is set to `"mouse"`.
39
+ * When interacting with the target element using the keyboard will use this position against the target element instead.
40
+ */
41
+ mousePosition?: PositionTypeBase;
42
+ /**
43
+ * Function to be called when the tooltip will be shown. It is called when the
44
+ * tooltip begins to animate in.
45
+ */
46
+ onShow?: () => void;
47
+ /**
48
+ * Function to be called when the tooltip will be hidden. It is called after the
49
+ * delay, when the tooltip begins to animate out.
50
+ */
51
+ onHide?: () => void;
52
+ /**
53
+ * Where the tooltip should appear relative to its target.
54
+ * If set to `"mouse"` the tooltip will display next to the mouse pointer instead.
55
+ * Make sure to utilize the `mousePosition` if you want to customize where the tooltip will show in relation to the mouse.
56
+ */
57
+ position?: PositionType;
58
+ /**
59
+ * Replace the wrapping element. This accepts the name of a html tag which will
60
+ * be used to wrap the element.
61
+ * If you provide a component it needs to support a ref prop which is used by popper for positioning
62
+ * Note: actual type is not ElementType, it is either a JSX.IntrinsticElement (eg "div")
63
+ * or a component that supports React.AllHTMLAttributes<HTMLElement> has a ref prop (React.Ref<HTMLElement>).
64
+ * Using ElementType here for documentation because it is close and works with our prop extraction tool
65
+ */
66
+ tag?: ElementType;
67
+ /**
68
+ * Show only one line of text, and truncate when too long
69
+ */
70
+ truncate?: boolean;
71
+ /**
72
+ * Elements to be wrapped by the tooltip
73
+ */
74
+ children: ReactNode;
75
+ /**
76
+ * A `testId` prop is provided for specified elements, which is a unique
77
+ * string that appears as a data attribute `data-testid` in the rendered code,
78
+ * serving as a hook for automated tests */
79
+ testId?: string;
80
+ /** Analytics context metadata */
81
+ analyticsContext?: Record<string, any>;
82
+ };
83
+ export default function PropsHack(props: Props): null;
84
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function clearScheduled(): void;
2
+ export declare function scheduleTimeout(fn: () => void, delay: number): void;
@@ -0,0 +1,29 @@
1
+ import { FakeMouseElement } from '../utilities';
2
+ export type Source = {
3
+ type: 'mouse';
4
+ mouse: FakeMouseElement;
5
+ } | {
6
+ type: 'keyboard';
7
+ };
8
+ export type Entry = {
9
+ source: Source;
10
+ show: (value: {
11
+ isImmediate: boolean;
12
+ }) => void;
13
+ hide: (value: {
14
+ isImmediate: boolean;
15
+ }) => void;
16
+ delay: number;
17
+ done: () => void;
18
+ };
19
+ export type API = {
20
+ isActive: () => boolean;
21
+ mousePosition: FakeMouseElement | null;
22
+ requestHide: (value: {
23
+ isImmediate: boolean;
24
+ }) => void;
25
+ finishHideAnimation: () => void;
26
+ keep: () => void;
27
+ abort: () => void;
28
+ };
29
+ export declare function show(entry: Entry): API;
@@ -0,0 +1 @@
1
+ export default function useUniqueId(prefix: string, shouldRenderId: boolean): string | undefined;
@@ -0,0 +1,102 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import { Placement } from '@atlaskit/popper';
4
+ import { TooltipPrimitiveProps } from './TooltipPrimitive';
5
+ export type PositionTypeBase = Placement;
6
+ export type PositionType = PositionTypeBase | 'mouse';
7
+ export interface TriggerProps {
8
+ onMouseOver: (event: React.MouseEvent<HTMLElement>) => void;
9
+ onMouseOut: (event: React.MouseEvent<HTMLElement>) => void;
10
+ onMouseMove: ((event: React.MouseEvent<HTMLElement>) => void) | undefined;
11
+ onMouseDown: (event: React.MouseEvent<HTMLElement>) => void;
12
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
13
+ onFocus: (event: React.FocusEvent<HTMLElement>) => void;
14
+ onBlur: (event: React.FocusEvent<HTMLElement>) => void;
15
+ ref: (node: HTMLElement | null) => void;
16
+ 'aria-describedby'?: string | undefined;
17
+ }
18
+ export interface TooltipProps {
19
+ /**
20
+ * The content of the tooltip. It can be either a:
21
+ * 1. `ReactNode`
22
+ * 2. Function which returns a `ReactNode`
23
+
24
+ * The benefit of the second approach is that it allows you to consume the `update` render prop.
25
+ * This `update` function can be called to manually recalculate the position of the tooltip.
26
+ */
27
+ content: ReactNode | (({ update }: {
28
+ update: () => void;
29
+ }) => ReactNode);
30
+ /**
31
+ * Extend `TooltipPrimitive` to create your own tooltip and pass it as component
32
+ */
33
+ component?: ComponentType<TooltipPrimitiveProps>;
34
+ /**
35
+ * Time in milliseconds to wait before showing and hiding the tooltip. Defaults to 300.
36
+ */
37
+ delay?: number;
38
+ /**
39
+ * Hide the tooltip when the click event is triggered. This should be
40
+ * used when tooltip should be hidden if `onClick` react synthetic event
41
+ * is triggered, which happens after `onMouseDown` event
42
+ */
43
+ hideTooltipOnClick?: boolean;
44
+ /**
45
+ * Hide the tooltip when the mousedown event is triggered. This should be
46
+ * used when tooltip should be hidden if `onMouseDown` react synthetic event
47
+ * is triggered, which happens before `onClick` event
48
+ */
49
+ hideTooltipOnMouseDown?: boolean;
50
+ /**
51
+ * Where the tooltip should appear relative to the mouse pointer.
52
+ * Only used when the `position` prop is set to `"mouse"`.
53
+ * When interacting with the target element using the keyboard will use this position against the target element instead.
54
+ */
55
+ mousePosition?: PositionTypeBase;
56
+ /**
57
+ * Function to be called when the tooltip will be shown. It is called when the
58
+ * tooltip begins to animate in.
59
+ */
60
+ onShow?: (analyticsEvent: UIAnalyticsEvent) => void;
61
+ /**
62
+ * Function to be called when the tooltip will be hidden. It is called after the
63
+ * delay, when the tooltip begins to animate out.
64
+ */
65
+ onHide?: (analyticsEvent: UIAnalyticsEvent) => void;
66
+ /**
67
+ * Where the tooltip should appear relative to its target.
68
+ * If set to `"mouse"` the tooltip will display next to the mouse pointer instead.
69
+ * Make sure to utilize the `mousePosition` if you want to customize where the tooltip will show in relation to the mouse.
70
+ */
71
+ position?: PositionType;
72
+ /**
73
+ * Replace the wrapping element. This accepts the name of a html tag which will
74
+ * be used to wrap the element.
75
+ * If you provide a component it needs to support a ref prop which is used by popper for positioning
76
+ */
77
+ tag?: keyof JSX.IntrinsicElements | React.ComponentType<React.AllHTMLAttributes<HTMLElement> & {
78
+ ref: React.Ref<HTMLElement>;
79
+ }>;
80
+ /**
81
+ * Show only one line of text, and truncate when too long
82
+ */
83
+ truncate?: boolean;
84
+ /**
85
+ * Elements to be wrapped by the tooltip.
86
+ * It can be either a:
87
+ * 1. `ReactNode`
88
+ * 2. Function which returns a `ReactNode`
89
+ */
90
+ children: ReactNode | ((props: TriggerProps) => ReactNode);
91
+ /**
92
+ * A `testId` prop is provided for specified elements, which is a unique
93
+ * string that appears as a data attribute `data-testid` in the rendered code,
94
+ * serving as a hook for automated tests */
95
+ testId?: string;
96
+ /** Analytics context metadata */
97
+ analyticsContext?: Record<string, any>;
98
+ /**
99
+ * Used to define the strategy of popper.
100
+ */
101
+ strategy?: 'absolute' | 'fixed' | undefined;
102
+ }
@@ -0,0 +1,16 @@
1
+ export interface FakeMouseElement {
2
+ getBoundingClientRect: () => {
3
+ top: number;
4
+ left: number;
5
+ bottom: number;
6
+ right: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ clientWidth: number;
11
+ clientHeight: number;
12
+ }
13
+ export declare function getMousePosition(mouseCoordinates: {
14
+ top: number;
15
+ left: number;
16
+ }): FakeMouseElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tooltip",
3
- "version": "17.8.1",
3
+ "version": "17.8.2",
4
4
  "description": "A tooltip is a floating, non-actionable label used to explain a user interface element or feature.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"