@atlaskit/smart-card 23.13.1 → 23.13.3
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 +12 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +88 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +90 -42
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +5 -69
- package/dist/cjs/view/FlexibleCard/index.js +3 -1
- package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +27 -25
- package/dist/cjs/view/LinkUrl/LinkWarningModal/hooks/use-link-warning-modal.js +17 -0
- package/dist/cjs/view/LinkUrl/index.js +11 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +64 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +75 -34
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +3 -56
- package/dist/es2019/view/FlexibleCard/index.js +2 -2
- package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +24 -22
- package/dist/es2019/view/LinkUrl/LinkWarningModal/hooks/use-link-warning-modal.js +16 -0
- package/dist/es2019/view/LinkUrl/index.js +8 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +69 -0
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +89 -42
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +4 -66
- package/dist/esm/view/FlexibleCard/index.js +4 -2
- package/dist/esm/view/HoverCard/components/HoverCardComponent.js +27 -25
- package/dist/esm/view/LinkUrl/LinkWarningModal/hooks/use-link-warning-modal.js +15 -0
- package/dist/esm/view/LinkUrl/index.js +8 -1
- package/dist/types/view/FlexibleCard/components/blocks/action-group/action-group-item/index.d.ts +12 -0
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +2 -3
- package/dist/types/view/LinkUrl/index.d.ts +4 -2
- package/dist/types/view/LinkUrl/types.d.ts +5 -0
- package/package.json +1 -1
|
@@ -3,23 +3,18 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
-
var _excluded = ["name"]
|
|
7
|
-
_excluded2 = ["name", "hideContent", "hideIcon", "onClick"];
|
|
6
|
+
var _excluded = ["name"];
|
|
8
7
|
|
|
9
8
|
var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
10
9
|
|
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
-
|
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
-
|
|
15
10
|
import React from 'react';
|
|
16
11
|
import { css } from '@emotion/react';
|
|
17
12
|
import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
|
|
18
13
|
import * as Elements from '../elements';
|
|
19
|
-
import * as Actions from '../actions';
|
|
20
14
|
import { isFlexibleUiElement } from '../../../../utils/flexible';
|
|
21
15
|
import ActionGroup from './action-group';
|
|
22
|
-
import ElementGroup from './element-group';
|
|
16
|
+
import ElementGroup from './element-group'; // Determine whether the element can be display as inline/block.
|
|
17
|
+
|
|
23
18
|
export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AttachmentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ChecklistProgress, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.DueOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LatestCommit, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.SourceBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.TargetBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _ElementDisplaySchema);
|
|
24
19
|
|
|
25
20
|
var getDirectionStyles = function getDirectionStyles(direction) {
|
|
@@ -64,7 +59,7 @@ var isElementDisplayValid = function isElementDisplayValid(name, display) {
|
|
|
64
59
|
return (_ElementDisplaySchema2 = (_ElementDisplaySchema3 = ElementDisplaySchema[name]) === null || _ElementDisplaySchema3 === void 0 ? void 0 : _ElementDisplaySchema3.includes(display)) !== null && _ElementDisplaySchema2 !== void 0 ? _ElementDisplaySchema2 : false;
|
|
65
60
|
};
|
|
66
61
|
|
|
67
|
-
var isJSXElementNull = function isJSXElementNull(children) {
|
|
62
|
+
export var isJSXElementNull = function isJSXElementNull(children) {
|
|
68
63
|
return Boolean(children.type() === null);
|
|
69
64
|
};
|
|
70
65
|
|
|
@@ -111,61 +106,4 @@ export var renderElementItems = function renderElementItems() {
|
|
|
111
106
|
if (elements.length) {
|
|
112
107
|
return elements;
|
|
113
108
|
}
|
|
114
|
-
};
|
|
115
|
-
export var renderActionItems = function renderActionItems() {
|
|
116
|
-
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
117
|
-
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
|
|
118
|
-
var appearance = arguments.length > 2 ? arguments[2] : undefined;
|
|
119
|
-
var asDropDownItems = arguments.length > 3 ? arguments[3] : undefined;
|
|
120
|
-
var onActionItemClick = arguments.length > 4 ? arguments[4] : undefined;
|
|
121
|
-
var actions = items.reduce(function (acc, curr, idx) {
|
|
122
|
-
var name = curr.name,
|
|
123
|
-
hideContent = curr.hideContent,
|
|
124
|
-
hideIcon = curr.hideIcon,
|
|
125
|
-
onClick = curr.onClick,
|
|
126
|
-
props = _objectWithoutProperties(curr, _excluded2);
|
|
127
|
-
|
|
128
|
-
var Action = Actions[name];
|
|
129
|
-
|
|
130
|
-
var actionProps = _objectSpread({}, props);
|
|
131
|
-
|
|
132
|
-
if (hideContent && !asDropDownItems) {
|
|
133
|
-
actionProps.content = '';
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (hideIcon) {
|
|
137
|
-
actionProps.icon = undefined;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (Action) {
|
|
141
|
-
var handleOnClick = function handleOnClick() {
|
|
142
|
-
if (onActionItemClick) {
|
|
143
|
-
onActionItemClick();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (onClick) {
|
|
147
|
-
onClick();
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
var action = /*#__PURE__*/React.createElement(Action, _extends({
|
|
152
|
-
url: '',
|
|
153
|
-
asDropDownItem: asDropDownItems,
|
|
154
|
-
size: size,
|
|
155
|
-
key: idx,
|
|
156
|
-
appearance: appearance,
|
|
157
|
-
onClick: handleOnClick
|
|
158
|
-
}, actionProps));
|
|
159
|
-
|
|
160
|
-
if (!isJSXElementNull(action)) {
|
|
161
|
-
return [].concat(_toConsumableArray(acc), [action]);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return acc;
|
|
166
|
-
}, []);
|
|
167
|
-
|
|
168
|
-
if (actions.length) {
|
|
169
|
-
return actions;
|
|
170
|
-
}
|
|
171
109
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
2
|
+
import React, { useEffect, useMemo } from 'react';
|
|
3
3
|
import { SmartLinkStatus } from '../../constants';
|
|
4
4
|
import Container from './components/container';
|
|
5
5
|
import { FlexibleUiAnalyticsContext, FlexibleUiContext } from '../../state/flexible-ui-context';
|
|
@@ -27,7 +27,9 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
27
27
|
var cardType = cardState.status,
|
|
28
28
|
details = cardState.details;
|
|
29
29
|
var status = cardType;
|
|
30
|
-
var context =
|
|
30
|
+
var context = useMemo(function () {
|
|
31
|
+
return getContextByStatus(url, status, details, renderers);
|
|
32
|
+
}, [details, renderers, status, url]);
|
|
31
33
|
var retry = getRetryOptions(url, status, details, onAuthorize);
|
|
32
34
|
|
|
33
35
|
var _ref2 = context || {},
|
|
@@ -120,6 +120,31 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
120
120
|
hideCard();
|
|
121
121
|
}
|
|
122
122
|
}, [closeOnChildClick, hideCard]);
|
|
123
|
+
var content = useCallback(function (_ref2) {
|
|
124
|
+
var update = _ref2.update;
|
|
125
|
+
return jsx(HoverCardContent, {
|
|
126
|
+
onMouseEnter: initShowCard,
|
|
127
|
+
onMouseLeave: initHideCard,
|
|
128
|
+
analytics: analytics,
|
|
129
|
+
cardActions: linkActions,
|
|
130
|
+
cardState: linkState,
|
|
131
|
+
onActionClick: onActionClick,
|
|
132
|
+
onResolve: update,
|
|
133
|
+
renderers: renderers,
|
|
134
|
+
url: url
|
|
135
|
+
});
|
|
136
|
+
}, [analytics, initHideCard, initShowCard, linkActions, linkState, onActionClick, renderers, url]);
|
|
137
|
+
var trigger = useCallback(function (triggerProps) {
|
|
138
|
+
return jsx("span", {
|
|
139
|
+
ref: parentSpan
|
|
140
|
+
}, jsx("span", _extends({}, triggerProps, {
|
|
141
|
+
onMouseEnter: initShowCard,
|
|
142
|
+
onMouseLeave: initHideCard,
|
|
143
|
+
onMouseMove: setMousePosition,
|
|
144
|
+
onClick: onChildClick,
|
|
145
|
+
"data-testid": "hover-card-trigger-wrapper"
|
|
146
|
+
}), children));
|
|
147
|
+
}, [children, initHideCard, initShowCard, onChildClick, setMousePosition]);
|
|
123
148
|
return jsx(Popup, {
|
|
124
149
|
testId: "hover-card",
|
|
125
150
|
isOpen: isOpen && canOpen,
|
|
@@ -127,31 +152,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
127
152
|
placement: "bottom-start",
|
|
128
153
|
offset: popupOffset.current,
|
|
129
154
|
autoFocus: false,
|
|
130
|
-
content:
|
|
131
|
-
|
|
132
|
-
return jsx(HoverCardContent, {
|
|
133
|
-
onMouseEnter: initShowCard,
|
|
134
|
-
onMouseLeave: initHideCard,
|
|
135
|
-
analytics: analytics,
|
|
136
|
-
cardActions: linkActions,
|
|
137
|
-
cardState: linkState,
|
|
138
|
-
onActionClick: onActionClick,
|
|
139
|
-
onResolve: update,
|
|
140
|
-
renderers: renderers,
|
|
141
|
-
url: url
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
trigger: function trigger(triggerProps) {
|
|
145
|
-
return jsx("span", {
|
|
146
|
-
ref: parentSpan
|
|
147
|
-
}, jsx("span", _extends({}, triggerProps, {
|
|
148
|
-
onMouseEnter: initShowCard,
|
|
149
|
-
onMouseLeave: initHideCard,
|
|
150
|
-
onMouseMove: setMousePosition,
|
|
151
|
-
onClick: onChildClick,
|
|
152
|
-
"data-testid": "hover-card-trigger-wrapper"
|
|
153
|
-
}), children));
|
|
154
|
-
},
|
|
155
|
+
content: content,
|
|
156
|
+
trigger: trigger,
|
|
155
157
|
zIndex: 511 // Temporary fix for Confluence inline comment on editor mod has z-index of 500, Jira issue view has z-index of 510
|
|
156
158
|
|
|
157
159
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { normalizeUrl } from '@atlaskit/linking-common/url';
|
|
4
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
+
import { ANALYTICS_CHANNEL } from '../../../../utils/analytics';
|
|
4
6
|
export var useLinkWarningModal = function useLinkWarningModal() {
|
|
5
7
|
var _useState = useState(null),
|
|
6
8
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -16,6 +18,18 @@ export var useLinkWarningModal = function useLinkWarningModal() {
|
|
|
16
18
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
17
19
|
isOpen = _useState6[0],
|
|
18
20
|
setIsOpen = _useState6[1];
|
|
21
|
+
|
|
22
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
23
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
24
|
+
|
|
25
|
+
var sendAnalyticsEvent = function sendAnalyticsEvent() {
|
|
26
|
+
createAnalyticsEvent({
|
|
27
|
+
action: 'shown',
|
|
28
|
+
actionSubject: 'warningModal',
|
|
29
|
+
actionSubjectId: 'linkSafetyWarning',
|
|
30
|
+
eventType: 'operational'
|
|
31
|
+
}).fire(ANALYTICS_CHANNEL);
|
|
32
|
+
};
|
|
19
33
|
/**
|
|
20
34
|
* It checks and warns if a link text is a URL and different from an actual link destination
|
|
21
35
|
*/
|
|
@@ -37,6 +51,7 @@ export var useLinkWarningModal = function useLinkWarningModal() {
|
|
|
37
51
|
setUnsafeLinkText(linkText);
|
|
38
52
|
href && setUrl(href);
|
|
39
53
|
setIsOpen(true);
|
|
54
|
+
sendAnalyticsEvent();
|
|
40
55
|
}
|
|
41
56
|
};
|
|
42
57
|
|
|
@@ -5,6 +5,13 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-modal';
|
|
7
7
|
import LinkWarningModal from './LinkWarningModal';
|
|
8
|
+
import { withAnalyticsContext } from '@atlaskit/analytics-next';
|
|
9
|
+
import { name as packageName, version as packageVersion } from '../../version.json';
|
|
10
|
+
var PACKAGE_DATA = {
|
|
11
|
+
packageName: packageName,
|
|
12
|
+
packageVersion: packageVersion,
|
|
13
|
+
componentName: 'linkUrl'
|
|
14
|
+
};
|
|
8
15
|
|
|
9
16
|
var LinkUrl = function LinkUrl(_ref) {
|
|
10
17
|
var href = _ref.href,
|
|
@@ -30,4 +37,4 @@ var LinkUrl = function LinkUrl(_ref) {
|
|
|
30
37
|
}, props), children), checkSafety && /*#__PURE__*/React.createElement(LinkWarningModal, linkWarningModalProps));
|
|
31
38
|
};
|
|
32
39
|
|
|
33
|
-
export default LinkUrl;
|
|
40
|
+
export default withAnalyticsContext(PACKAGE_DATA)(LinkUrl);
|
package/dist/types/view/FlexibleCard/components/blocks/action-group/action-group-item/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Appearance } from '@atlaskit/button';
|
|
3
|
+
import { SmartLinkSize } from '../../../../../../constants';
|
|
4
|
+
import { ActionItem } from '../../types';
|
|
5
|
+
declare const ActionGroupItem: React.FC<{
|
|
6
|
+
item: ActionItem;
|
|
7
|
+
size: SmartLinkSize;
|
|
8
|
+
appearance?: Appearance;
|
|
9
|
+
asDropDownItems?: boolean;
|
|
10
|
+
onActionItemClick?: () => void;
|
|
11
|
+
}>;
|
|
12
|
+
export default ActionGroupItem;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SerializedStyles } from '@emotion/react';
|
|
3
|
-
import {
|
|
3
|
+
import { ElementItem } from './types';
|
|
4
4
|
import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
|
|
5
|
-
import { Appearance } from '@atlaskit/button';
|
|
6
5
|
export declare type ElementDisplaySchemaType = 'inline' | 'block';
|
|
7
6
|
export declare const ElementDisplaySchema: Record<ElementName, ElementDisplaySchemaType[]>;
|
|
8
7
|
export declare const getGapSize: (size: SmartLinkSize) => number;
|
|
9
8
|
export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
|
|
10
9
|
export declare const highlightRemoveStyles: SerializedStyles;
|
|
10
|
+
export declare const isJSXElementNull: (children: JSX.Element) => boolean;
|
|
11
11
|
export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
|
|
12
12
|
export declare const renderElementItems: (items?: ElementItem[], display?: ElementDisplaySchemaType) => React.ReactNode | undefined;
|
|
13
|
-
export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: Appearance | undefined, asDropDownItems?: boolean | undefined, onActionItemClick?: (() => void) | undefined) => React.ReactElement[] | undefined;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { LinkUrlProps } from './types';
|
|
3
|
-
declare const
|
|
4
|
-
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<LinkUrlProps & {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
} & import("@atlaskit/analytics-next").WithContextProps & React.RefAttributes<any>>;
|
|
6
|
+
export default _default;
|
|
@@ -6,3 +6,8 @@ export interface LinkUrlProps extends React.AnchorHTMLAttributes<HTMLAnchorEleme
|
|
|
6
6
|
checkSafety?: boolean;
|
|
7
7
|
testId?: string;
|
|
8
8
|
}
|
|
9
|
+
export declare type PackageDataType = {
|
|
10
|
+
packageName: '@atlaskit/smart-card';
|
|
11
|
+
packageVersion: string;
|
|
12
|
+
componentName: 'linkUrl';
|
|
13
|
+
};
|