@atlaskit/smart-card 24.0.0 → 24.0.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 +13 -0
- package/dist/cjs/state/analytics/useMouseDownEvent.js +24 -0
- package/dist/cjs/utils/analytics/click.js +121 -0
- package/dist/cjs/utils/index.js +10 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/components/ContentHeader.js +4 -0
- package/dist/cjs/view/BlockCard/index.js +1 -0
- package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +2 -0
- package/dist/cjs/view/CardWithUrl/component.js +24 -9
- package/dist/cjs/view/EmbedCard/components/ExpandedFrame.js +4 -1
- package/dist/cjs/view/EmbedModal/components/link-info/link-info-button/index.js +3 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/index.js +3 -0
- package/dist/cjs/view/FlexibleCard/components/container/layered-link/index.js +3 -0
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +3 -0
- package/dist/cjs/view/HoverCard/components/HoverCardContent.js +6 -1
- package/dist/cjs/view/InlineCard/Frame/index.js +4 -0
- package/dist/es2019/state/analytics/useMouseDownEvent.js +18 -0
- package/dist/es2019/utils/analytics/click.js +106 -0
- package/dist/es2019/utils/index.js +10 -0
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/components/ContentHeader.js +19 -14
- package/dist/es2019/view/BlockCard/index.js +1 -0
- package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +2 -0
- package/dist/es2019/view/CardWithUrl/component.js +25 -9
- package/dist/es2019/view/EmbedCard/components/ExpandedFrame.js +4 -1
- package/dist/es2019/view/EmbedModal/components/link-info/link-info-button/index.js +3 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/index.js +3 -0
- package/dist/es2019/view/FlexibleCard/components/container/layered-link/index.js +14 -9
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +3 -0
- package/dist/es2019/view/HoverCard/components/HoverCardContent.js +7 -1
- package/dist/es2019/view/InlineCard/Frame/index.js +3 -0
- package/dist/esm/state/analytics/useMouseDownEvent.js +17 -0
- package/dist/esm/utils/analytics/click.js +109 -0
- package/dist/esm/utils/index.js +10 -0
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/components/ContentHeader.js +3 -0
- package/dist/esm/view/BlockCard/index.js +1 -0
- package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +2 -0
- package/dist/esm/view/CardWithUrl/component.js +24 -9
- package/dist/esm/view/EmbedCard/components/ExpandedFrame.js +4 -1
- package/dist/esm/view/EmbedModal/components/link-info/link-info-button/index.js +3 -0
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/index.js +3 -0
- package/dist/esm/view/FlexibleCard/components/container/layered-link/index.js +3 -0
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +3 -0
- package/dist/esm/view/HoverCard/components/HoverCardContent.js +6 -1
- package/dist/esm/view/InlineCard/Frame/index.js +3 -0
- package/dist/types/state/analytics/useMouseDownEvent.d.ts +3 -0
- package/dist/types/utils/analytics/click.d.ts +21 -0
- package/dist/types/utils/analytics/types.d.ts +16 -0
- package/dist/types/utils/index.d.ts +9 -0
- package/dist/types/view/FlexibleCard/components/elements/link/types.d.ts +4 -0
- package/package.json +4 -2
|
@@ -3,6 +3,7 @@ var _templateObject;
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { jsx, css } from '@emotion/react';
|
|
6
|
+
import useMouseDownEvent from '../../../../../state/analytics/useMouseDownEvent';
|
|
6
7
|
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n // Stretch the invisible link over the whole of the post.\n // Hide the link\u2019s text.\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n overflow-x: hidden;\n text-indent: 100%;\n white-space: nowrap;\n\n // Needs a heightened specificity to trump other anchor.\n // Stack it under all other links in the post text.\n a&.layered-link {\n position: absolute;\n z-index: 0;\n }\n\n // When hovering over the layered link, any hidden action buttons inside\n // the Container should become visible.\n // As actions resides inside blocks and layered link is expected to be\n // on the same level of blocks. That makes the blocks, e.g. TitleBlock,\n // its sibling. Using general sibling combinator here to apply styling to\n // all the siblings of layered link.\n // The general sibling combinator (~) separates two selectors and matches all\n // iterations of the second element, that are following the first element\n // (though not necessarily immediately), and are children of the same parent\n // element.\n &:hover ~ * {\n .actions-button-group {\n opacity: 1;\n }\n }\n"])));
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -16,12 +17,14 @@ var LayeredLink = function LayeredLink(_ref) {
|
|
|
16
17
|
testId = _ref.testId,
|
|
17
18
|
text = _ref.text,
|
|
18
19
|
url = _ref.url;
|
|
20
|
+
var onMouseDown = useMouseDownEvent();
|
|
19
21
|
return jsx("a", {
|
|
20
22
|
className: "layered-link",
|
|
21
23
|
css: styles,
|
|
22
24
|
"data-testid": "".concat(testId, "-layered-link"),
|
|
23
25
|
href: url,
|
|
24
26
|
onClick: onClick,
|
|
27
|
+
onMouseDown: onMouseDown,
|
|
25
28
|
target: target,
|
|
26
29
|
tabIndex: -1 // Hide tab index and let the title link be the link.
|
|
27
30
|
}, text);
|
|
@@ -7,6 +7,7 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
7
7
|
import { SmartLinkSize, SmartLinkTheme } from '../../../../../constants';
|
|
8
8
|
import { getLinkLineHeight, getLinkSizeStyles, getTruncateStyles, hasWhiteSpace } from '../../utils';
|
|
9
9
|
import { tokens } from '../../../../../utils/token';
|
|
10
|
+
import useMouseDownEvent from '../../../../../state/analytics/useMouseDownEvent';
|
|
10
11
|
var DEFAULT_MAX_LINES = 2;
|
|
11
12
|
var MAXIMUM_MAX_LINES = 2;
|
|
12
13
|
var MINIMUM_MAX_LINES = 1;
|
|
@@ -64,6 +65,7 @@ var Link = function Link(_ref) {
|
|
|
64
65
|
url = _ref.url,
|
|
65
66
|
onClick = _ref.onClick,
|
|
66
67
|
target = _ref.target;
|
|
68
|
+
var onMouseDown = useMouseDownEvent();
|
|
67
69
|
var hasSpace = useMemo(function () {
|
|
68
70
|
return text ? hasWhiteSpace(text) : false;
|
|
69
71
|
}, [text]);
|
|
@@ -73,6 +75,7 @@ var Link = function Link(_ref) {
|
|
|
73
75
|
"data-smart-element-link": true,
|
|
74
76
|
"data-testid": testId,
|
|
75
77
|
onClick: onClick,
|
|
78
|
+
onMouseDown: onMouseDown,
|
|
76
79
|
href: url,
|
|
77
80
|
target: target || '_blank'
|
|
78
81
|
}, text);
|
|
@@ -5,6 +5,7 @@ import { jsx } from '@emotion/react';
|
|
|
5
5
|
import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
|
|
6
6
|
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
7
7
|
import { extractType } from '@atlaskit/linking-common/extractors';
|
|
8
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
8
9
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
9
10
|
import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
|
|
10
11
|
import { extractMetadata } from '../../../extractors/hover/extractMetadata';
|
|
@@ -18,6 +19,7 @@ import HoverCardResolvedView from './views/resolved';
|
|
|
18
19
|
import { FormattedMessage } from 'react-intl-next';
|
|
19
20
|
import { messages } from '../../../messages';
|
|
20
21
|
import { useSmartCardActions } from '../../../state/actions';
|
|
22
|
+
import { fireLinkClickedEvent } from '../../../utils/analytics/click';
|
|
21
23
|
export var hoverCardClassName = 'smart-links-hover-preview';
|
|
22
24
|
export var getOpenAction = function getOpenAction(url, analytics, onActionClick) {
|
|
23
25
|
return {
|
|
@@ -88,6 +90,8 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
88
90
|
url = _ref.url,
|
|
89
91
|
onMouseEnter = _ref.onMouseEnter,
|
|
90
92
|
onMouseLeave = _ref.onMouseLeave;
|
|
93
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
94
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
91
95
|
var extensionKey = useMemo(function () {
|
|
92
96
|
return getExtensionKey(cardState.details);
|
|
93
97
|
}, [cardState.details]);
|
|
@@ -104,7 +108,8 @@ var HoverCardContent = function HoverCardContent(_ref) {
|
|
|
104
108
|
isModifierKeyPressed: isModifierKeyPressed,
|
|
105
109
|
actionSubjectId: 'titleGoToLink'
|
|
106
110
|
});
|
|
107
|
-
|
|
111
|
+
fireLinkClickedEvent(createAnalyticsEvent)(event);
|
|
112
|
+
}, [createAnalyticsEvent, cardState.status, analytics.ui, id]);
|
|
108
113
|
var titleActions = useMemo(function () {
|
|
109
114
|
return [getCopyAction(url), getOpenAction(url, analytics, onActionClick)];
|
|
110
115
|
}, [url, analytics, onActionClick]);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
3
3
|
import { WrapperAnchor, WrapperSpan } from './styled';
|
|
4
|
+
import useMouseDownEvent from '../../../state/analytics/useMouseDownEvent';
|
|
4
5
|
export var Frame = function Frame(props) {
|
|
5
6
|
var isSelected = props.isSelected,
|
|
6
7
|
children = props.children,
|
|
@@ -26,6 +27,7 @@ export var Frame = function Frame(props) {
|
|
|
26
27
|
onClick(event);
|
|
27
28
|
}
|
|
28
29
|
}, [onClick]);
|
|
30
|
+
var handleMouseDown = useMouseDownEvent();
|
|
29
31
|
var isInteractive = Boolean(onClick);
|
|
30
32
|
|
|
31
33
|
// Depending on whenever Frame was given onClick or link itself we display span or anchor elements
|
|
@@ -42,6 +44,7 @@ export var Frame = function Frame(props) {
|
|
|
42
44
|
tabIndex: isInteractive ? 0 : undefined,
|
|
43
45
|
role: isInteractive ? 'button' : undefined,
|
|
44
46
|
onClick: handleClick,
|
|
47
|
+
onMouseDown: handleMouseDown,
|
|
45
48
|
onKeyPress: handleKeyPress,
|
|
46
49
|
"data-testid": testId,
|
|
47
50
|
className: className
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AnalyticsEventPayload, UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
3
|
+
import { GasPayload } from '@atlaskit/analytics-gas-types';
|
|
4
|
+
import { ClickOutcome, ClickType, UiLinkClickedEventProps } from './types';
|
|
5
|
+
import { AnalyticsPayload } from '../types';
|
|
6
|
+
export declare const buttonMap: Map<number | undefined, "left" | "right" | "none" | "middle">;
|
|
7
|
+
export declare const getKeys: (e: React.MouseEvent) => ("meta" | "alt" | "shift" | "ctrl")[];
|
|
8
|
+
export declare function getLinkClickOutcome(e: React.MouseEvent, clickType: ClickType): ClickOutcome;
|
|
9
|
+
export declare const createLinkClickedPayload: (event: React.MouseEvent) => AnalyticsPayload | undefined;
|
|
10
|
+
declare type DeepPartial<T> = T extends object ? {
|
|
11
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
12
|
+
} : T;
|
|
13
|
+
export declare const fireLinkClickedEvent: (createAnalyticsEvent: (payload: AnalyticsEventPayload) => UIAnalyticsEvent) => (event: React.MouseEvent, overrides?: {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
attributes?: {
|
|
16
|
+
clickType?: ClickType | undefined;
|
|
17
|
+
clickOutcome?: ClickOutcome | undefined;
|
|
18
|
+
keysHeld?: ("meta" | "alt" | "shift" | "ctrl" | undefined)[] | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
} | undefined) => void;
|
|
21
|
+
export {};
|
|
@@ -105,3 +105,19 @@ export declare type InstrumentEventProps = CommonEventProps & {
|
|
|
105
105
|
status: CardType;
|
|
106
106
|
id: string;
|
|
107
107
|
};
|
|
108
|
+
export declare type ClickType = 'left' | 'middle' | 'right' | 'none';
|
|
109
|
+
export declare type ClickOutcome = 'prevented' | 'clickThrough' | 'clickThroughNewTabOrWindow' | 'contextMenu' | 'alt' | 'contentEditable' | '_unknown';
|
|
110
|
+
export declare type UiLinkClickedEventProps = {
|
|
111
|
+
/**
|
|
112
|
+
* Whether the click occurred with the left, middle or right mouse button
|
|
113
|
+
*/
|
|
114
|
+
clickType: ClickType;
|
|
115
|
+
/**
|
|
116
|
+
* The user outcome for clicking the link as far as can be reasonably be determined
|
|
117
|
+
*/
|
|
118
|
+
clickOutcome: ClickOutcome;
|
|
119
|
+
/**
|
|
120
|
+
* The keys held by the user at the time of clicking the link (which influence `clickOutcome`)
|
|
121
|
+
*/
|
|
122
|
+
keysHeld: ('alt' | 'ctrl' | 'meta' | 'shift')[];
|
|
123
|
+
};
|
|
@@ -3,6 +3,15 @@ import { CardProps } from '../view/Card';
|
|
|
3
3
|
export declare const isCardWithData: (props: CardProps) => boolean;
|
|
4
4
|
export declare const isSpecialEvent: (evt: React.MouseEvent | React.KeyboardEvent) => boolean;
|
|
5
5
|
export declare const isIframe: () => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Meta key = cmd on mac, windows key on windows
|
|
8
|
+
* Ctrl key on mac by default triggers a right click instead of left click
|
|
9
|
+
* Ctrl key on Windows has the same behaviour of cmd key of mac (open in new tab)
|
|
10
|
+
*
|
|
11
|
+
* `isSpecialKey` on a mouse event on mac with default behaviour should be equivalent to opening in new tab
|
|
12
|
+
* On Windows it will be equivalent to opening a new tab, unless its the Window key that is held
|
|
13
|
+
* in which case typically only a standard clickthrough will occur, this is likely a small portion of events
|
|
14
|
+
*/
|
|
6
15
|
export declare const isSpecialKey: (event: React.MouseEvent | React.KeyboardEvent) => boolean;
|
|
7
16
|
export declare const isSpecialClick: (event: React.MouseEvent) => boolean;
|
|
8
17
|
export declare const getIconForFileType: (fileMimeType: string) => React.ReactNode | undefined;
|
|
@@ -12,6 +12,10 @@ export declare type LinkProps = ElementProps & {
|
|
|
12
12
|
* propagate analytics.
|
|
13
13
|
*/
|
|
14
14
|
onClick?: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
|
|
15
|
+
/**
|
|
16
|
+
* Mouse event to be provided to the link
|
|
17
|
+
*/
|
|
18
|
+
onMouseDown?: React.MouseEventHandler;
|
|
15
19
|
/**
|
|
16
20
|
* The number of lines that the link text should spread over. Maximum of 2 lines.
|
|
17
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.2",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@atlaskit/icon-object": "^6.2.0",
|
|
34
34
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
35
35
|
"@atlaskit/in-product-testing": "^0.1.0",
|
|
36
|
-
"@atlaskit/linking-common": "^1.
|
|
36
|
+
"@atlaskit/linking-common": "^1.22.0",
|
|
37
37
|
"@atlaskit/logo": "^13.11.0",
|
|
38
38
|
"@atlaskit/lozenge": "^11.3.0",
|
|
39
39
|
"@atlaskit/media-common": "^2.19.0",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"@atlaskit/field-base": "^15.0.6",
|
|
73
73
|
"@atlaskit/form": "^8.8.0",
|
|
74
74
|
"@atlaskit/inline-message": "^11.4.0",
|
|
75
|
+
"@atlaskit/link-test-helpers": "^2.1.0",
|
|
75
76
|
"@atlaskit/lozenge": "^11.3.0",
|
|
76
77
|
"@atlaskit/media-integration-test-helpers": "^2.6.0",
|
|
77
78
|
"@atlaskit/media-test-helpers": "^30.1.0",
|
|
@@ -87,6 +88,7 @@
|
|
|
87
88
|
"@atlaskit/toggle": "^12.5.0",
|
|
88
89
|
"@atlaskit/visual-regression": "*",
|
|
89
90
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
91
|
+
"@testing-library/dom": "^8.17.1",
|
|
90
92
|
"@testing-library/jest-dom": "^5.16.5",
|
|
91
93
|
"@testing-library/react": "^12.1.5",
|
|
92
94
|
"@testing-library/react-hooks": "^8.0.1",
|