@atlaskit/smart-card 23.5.2 → 23.6.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/cjs/view/CardWithUrl/component.js +4 -1
  4. package/dist/cjs/view/EmbedCard/views/UnauthorisedView.js +5 -16
  5. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +4 -2
  6. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +30 -92
  7. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +134 -0
  8. package/dist/cjs/view/HoverCard/components/views/resolved/styled.js +24 -0
  9. package/dist/cjs/view/HoverCard/components/views/resolved/types.js +5 -0
  10. package/dist/cjs/view/HoverCard/components/{HoverCardLoadingView.js → views/resolving/index.js} +8 -6
  11. package/dist/cjs/view/HoverCard/components/views/resolving/styled.js +19 -0
  12. package/dist/cjs/view/HoverCard/components/views/resolving/types.js +5 -0
  13. package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +85 -0
  14. package/dist/cjs/view/HoverCard/components/views/unauthorised/styled.js +24 -0
  15. package/dist/cjs/view/HoverCard/components/views/unauthorised/types.js +5 -0
  16. package/dist/cjs/view/HoverCard/styled.js +4 -13
  17. package/dist/cjs/view/InlineCard/UnauthorisedView/index.js +16 -2
  18. package/dist/cjs/view/InlineCard/index.js +4 -2
  19. package/dist/cjs/view/common/UnauthorisedViewContent.js +40 -0
  20. package/dist/es2019/version.json +1 -1
  21. package/dist/es2019/view/CardWithUrl/component.js +4 -1
  22. package/dist/es2019/view/EmbedCard/views/UnauthorisedView.js +5 -13
  23. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +4 -2
  24. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +28 -76
  25. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +96 -0
  26. package/dist/es2019/view/HoverCard/components/views/resolved/styled.js +34 -0
  27. package/dist/es2019/view/HoverCard/components/views/resolved/types.js +1 -0
  28. package/dist/es2019/view/HoverCard/components/{HoverCardLoadingView.js → views/resolving/index.js} +5 -4
  29. package/dist/es2019/view/HoverCard/components/views/resolving/styled.js +11 -0
  30. package/dist/es2019/view/HoverCard/components/views/resolving/types.js +1 -0
  31. package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +58 -0
  32. package/dist/es2019/view/HoverCard/components/views/unauthorised/styled.js +18 -0
  33. package/dist/es2019/view/HoverCard/components/views/unauthorised/types.js +1 -0
  34. package/dist/es2019/view/HoverCard/styled.js +1 -42
  35. package/dist/es2019/view/InlineCard/UnauthorisedView/index.js +13 -2
  36. package/dist/es2019/view/InlineCard/index.js +4 -2
  37. package/dist/es2019/view/common/UnauthorisedViewContent.js +24 -0
  38. package/dist/esm/version.json +1 -1
  39. package/dist/esm/view/CardWithUrl/component.js +4 -1
  40. package/dist/esm/view/EmbedCard/views/UnauthorisedView.js +5 -13
  41. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +4 -2
  42. package/dist/esm/view/HoverCard/components/HoverCardContent.js +29 -83
  43. package/dist/esm/view/HoverCard/components/views/resolved/index.js +104 -0
  44. package/dist/esm/view/HoverCard/components/views/resolved/styled.js +10 -0
  45. package/dist/esm/view/HoverCard/components/views/resolved/types.js +1 -0
  46. package/dist/esm/view/HoverCard/components/{HoverCardLoadingView.js → views/resolving/index.js} +5 -4
  47. package/dist/esm/view/HoverCard/components/views/resolving/styled.js +7 -0
  48. package/dist/esm/view/HoverCard/components/views/resolving/types.js +1 -0
  49. package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +58 -0
  50. package/dist/esm/view/HoverCard/components/views/unauthorised/styled.js +11 -0
  51. package/dist/esm/view/HoverCard/components/views/unauthorised/types.js +1 -0
  52. package/dist/esm/view/HoverCard/styled.js +3 -8
  53. package/dist/esm/view/InlineCard/UnauthorisedView/index.js +14 -2
  54. package/dist/esm/view/InlineCard/index.js +4 -2
  55. package/dist/esm/view/common/UnauthorisedViewContent.js +26 -0
  56. package/dist/types/view/HoverCard/components/HoverCardContent.d.ts +0 -2
  57. package/dist/types/view/HoverCard/components/views/resolved/index.d.ts +7 -0
  58. package/dist/types/view/HoverCard/components/views/resolved/styled.d.ts +3 -0
  59. package/dist/types/view/HoverCard/components/views/resolved/types.d.ts +13 -0
  60. package/dist/types/view/HoverCard/components/{HoverCardLoadingView.d.ts → views/resolving/index.d.ts} +1 -1
  61. package/dist/types/view/HoverCard/components/views/resolving/styled.d.ts +2 -0
  62. package/dist/types/view/HoverCard/components/views/resolving/types.d.ts +6 -0
  63. package/dist/types/view/HoverCard/components/views/unauthorised/index.d.ts +4 -0
  64. package/dist/types/view/HoverCard/components/views/unauthorised/styled.d.ts +3 -0
  65. package/dist/types/view/HoverCard/components/views/unauthorised/types.d.ts +19 -0
  66. package/dist/types/view/HoverCard/index.d.ts +1 -1
  67. package/dist/types/view/HoverCard/styled.d.ts +1 -5
  68. package/dist/types/view/HoverCard/types.d.ts +3 -6
  69. package/dist/types/view/InlineCard/UnauthorisedView/index.d.ts +2 -0
  70. package/dist/types/view/InlineCard/types.d.ts +1 -0
  71. package/dist/types/view/common/UnauthorisedViewContent.d.ts +20 -0
  72. package/package.json +2 -2
@@ -22,6 +22,7 @@ import { Frame } from '../Frame';
22
22
  import { AKIconWrapper } from '../Icon';
23
23
  import { IconAndTitleLayout } from '../IconAndTitleLayout';
24
24
  import { IconStyledButton, LinkAppearance } from '../styled';
25
+ import { HoverCard } from '../../HoverCard';
25
26
  var FallbackUnauthorizedIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
26
27
  label: "error",
27
28
  size: "small",
@@ -81,8 +82,10 @@ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component)
81
82
  onClick = _this$props2.onClick,
82
83
  isSelected = _this$props2.isSelected,
83
84
  _this$props2$testId = _this$props2.testId,
84
- testId = _this$props2$testId === void 0 ? 'inline-card-unauthorized-view' : _this$props2$testId;
85
- return /*#__PURE__*/React.createElement(Frame, {
85
+ testId = _this$props2$testId === void 0 ? 'inline-card-unauthorized-view' : _this$props2$testId,
86
+ _this$props2$showAuth = _this$props2.showAuthTooltip,
87
+ showAuthTooltip = _this$props2$showAuth === void 0 ? false : _this$props2$showAuth;
88
+ var inlineCardUnauthenticatedView = /*#__PURE__*/React.createElement(Frame, {
86
89
  testId: testId,
87
90
  link: url,
88
91
  onClick: onClick,
@@ -92,6 +95,15 @@ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component)
92
95
  title: this.renderMessage(),
93
96
  titleColor: token('color.text.subtle', N500)
94
97
  }));
98
+
99
+ if (showAuthTooltip) {
100
+ return /*#__PURE__*/React.createElement(HoverCard, {
101
+ url: url,
102
+ onAuthorize: this.props.onAuthorise
103
+ }, inlineCardUnauthenticatedView);
104
+ }
105
+
106
+ return inlineCardUnauthenticatedView;
95
107
  }
96
108
  }]);
97
109
 
@@ -25,7 +25,8 @@ export var InlineCard = function InlineCard(_ref) {
25
25
  onError = _ref.onError,
26
26
  testId = _ref.testId,
27
27
  inlinePreloaderStyle = _ref.inlinePreloaderStyle,
28
- showHoverPreview = _ref.showHoverPreview;
28
+ showHoverPreview = _ref.showHoverPreview,
29
+ showAuthTooltip = _ref.showAuthTooltip;
29
30
  var status = cardState.status,
30
31
  details = cardState.details;
31
32
  var cardDetails = details && details.data || getEmptyJsonLd();
@@ -77,7 +78,8 @@ export var InlineCard = function InlineCard(_ref) {
77
78
  isSelected: isSelected,
78
79
  onClick: handleFrameClick,
79
80
  onAuthorise: handleAuthorize,
80
- testId: testIdWithStatus
81
+ testId: testIdWithStatus,
82
+ showAuthTooltip: showAuthTooltip
81
83
  });
82
84
 
83
85
  case 'forbidden':
@@ -0,0 +1,26 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { FormattedMessage } from 'react-intl-next';
4
+ import { messages } from '../../messages';
5
+ import { CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../constants';
6
+
7
+ /**
8
+ * This component is used in unauthorized views of a smart link.
9
+ * It represents the main text that provides a user with information on how to connect their account
10
+ */
11
+ var UnauthorisedViewContent = function UnauthorisedViewContent(_ref) {
12
+ var providerName = _ref.providerName,
13
+ _ref$testId = _ref.testId,
14
+ testId = _ref$testId === void 0 ? 'unauthorised-view-content' : _ref$testId;
15
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_unauthorised_account_description, {
16
+ values: {
17
+ context: providerName
18
+ }
19
+ })), ' ', /*#__PURE__*/React.createElement("a", {
20
+ href: CONTENT_URL_SECURITY_AND_PERMISSIONS,
21
+ target: "_blank",
22
+ "data-testid": "".concat(testId, "-learn-more")
23
+ }, /*#__PURE__*/React.createElement(FormattedMessage, messages.learn_more_about_smart_links_security)));
24
+ };
25
+
26
+ export default UnauthorisedViewContent;
@@ -1,9 +1,7 @@
1
1
  import React from 'react';
2
2
  import { AnalyticsFacade } from '../../../state/analytics';
3
- import { LinkAction } from '../../../state/hooks-external/useSmartLinkActions';
4
3
  import { ActionItem } from '../../FlexibleCard/components/blocks/types';
5
4
  import { HoverCardContentProps } from '../types';
6
5
  export declare const getOpenAction: (url: string, analytics: AnalyticsFacade, onActionClick?: ((actionId: string) => void) | undefined) => ActionItem;
7
- export declare const toFooterActions: (cardActions: LinkAction[], onActionClick?: ((actionId: string) => void) | undefined) => ActionItem[];
8
6
  declare const HoverCardContent: React.FC<HoverCardContentProps>;
9
7
  export default HoverCardContent;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { ActionItem } from '../../../../FlexibleCard/components/blocks/types';
3
+ import { LinkAction } from '../../../../../state/hooks-external/useSmartLinkActions';
4
+ import { HoverCardResolvedProps } from './types';
5
+ export declare const toFooterActions: (cardActions: LinkAction[], onActionClick?: ((actionId: string) => void) | undefined) => ActionItem[];
6
+ declare const HoverCardResolvedView: React.FC<HoverCardResolvedProps>;
7
+ export default HoverCardResolvedView;
@@ -0,0 +1,3 @@
1
+ export declare const metadataBlockCss: import("@emotion/react").SerializedStyles;
2
+ export declare const footerBlockCss: import("@emotion/react").SerializedStyles;
3
+ export declare const hiddenSnippetStyles: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,13 @@
1
+ import { AnalyticsFacade } from '../../../../../state/analytics';
2
+ import { LinkAction } from '../../../../../state/hooks-external/useSmartLinkActions';
3
+ import { CardState } from '@atlaskit/linking-common';
4
+ import { HoverCardLoadingViewProps } from '../resolving/types';
5
+ export declare type HoverCardResolvedProps = {
6
+ extensionKey?: string;
7
+ id?: string;
8
+ url: string;
9
+ analytics: AnalyticsFacade;
10
+ cardActions?: LinkAction[];
11
+ cardState: CardState;
12
+ onActionClick: (actionId: string) => void;
13
+ } & HoverCardLoadingViewProps;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { HoverCardLoadingViewProps } from '../types';
2
+ import { HoverCardLoadingViewProps } from './types';
3
3
  declare const HoverCardLoadingView: React.FC<HoverCardLoadingViewProps>;
4
4
  export default HoverCardLoadingView;
@@ -0,0 +1,2 @@
1
+ export declare const loadingViewContainer: import("@emotion/react").SerializedStyles;
2
+ export declare const skeletonContainer: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,6 @@
1
+ import { FlexibleCardProps } from '../../../../FlexibleCard/types';
2
+ import { TitleBlockProps } from '../../../../FlexibleCard/components/blocks/title-block/types';
3
+ export declare type HoverCardLoadingViewProps = {
4
+ flexibleCardProps: FlexibleCardProps;
5
+ titleBlockProps: TitleBlockProps;
6
+ };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { HoverCardUnauthorisedProps } from './types';
3
+ declare const HoverCardUnauthorisedView: React.FC<HoverCardUnauthorisedProps>;
4
+ export default HoverCardUnauthorisedView;
@@ -0,0 +1,3 @@
1
+ export declare const connectButtonStyles: import("@emotion/react").SerializedStyles;
2
+ export declare const titleBlockStyles: import("@emotion/react").SerializedStyles;
3
+ export declare const mainTextStyles: import("@emotion/react").SerializedStyles;
@@ -0,0 +1,19 @@
1
+ import { FlexibleCardProps } from '../../../../FlexibleCard/types';
2
+ export declare type HoverCardUnauthorisedProps = {
3
+ /**
4
+ * Data required for rendering a Flexible Card
5
+ */
6
+ flexibleCardProps: FlexibleCardProps;
7
+ /**
8
+ * A function that determines an additional action that can be performed on an unauthorised link, e.g.
9
+ * connecting an account to gain access.
10
+ * @internal
11
+ */
12
+ onAuthorize?: () => void;
13
+ /**
14
+ * A `testId` prop is provided for specified elements, which is a unique
15
+ * string that appears as a data attribute `data-testid` in the rendered code,
16
+ * serving as a hook for automated tests
17
+ */
18
+ testId?: string;
19
+ };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { HoverCardProps } from './types';
3
- export declare const HoverCard: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").PropsWithChildren<HoverCardProps>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "key" | "id" | "analyticsContext"> & import("react").RefAttributes<any>>;
3
+ export declare const HoverCard: import("react").ForwardRefExoticComponent<Pick<Omit<import("react").PropsWithChildren<HoverCardProps>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "key" | "id" | "analyticsContext" | "onAuthorize"> & import("react").RefAttributes<any>>;
@@ -2,11 +2,7 @@ import { FlexibleUiOptions } from '../FlexibleCard/types';
2
2
  export declare const flexibleUiOptions: FlexibleUiOptions;
3
3
  export declare const CARD_WIDTH_REM = 24;
4
4
  export declare const CARD_GAP_PX = 10;
5
+ export declare const separatorCss: import("@emotion/react").SerializedStyles;
5
6
  export declare const HoverCardContainer: import("@emotion/react").SerializedStyles;
6
7
  export declare const titleBlockCss: import("@emotion/react").SerializedStyles;
7
- export declare const metadataBlockCss: import("@emotion/react").SerializedStyles;
8
- export declare const footerBlockCss: import("@emotion/react").SerializedStyles;
9
- export declare const loadingViewContainer: import("@emotion/react").SerializedStyles;
10
- export declare const skeletonContainer: import("@emotion/react").SerializedStyles;
11
- export declare const hiddenSnippetStyles: import("@emotion/react").SerializedStyles;
12
8
  export declare const getTransitionStyles: (snippetHeight: number) => import("@emotion/react").SerializedStyles;
@@ -6,17 +6,17 @@ import { CardState } from '@atlaskit/linking-common';
6
6
  import { CardProviderRenderers } from '@atlaskit/link-provider';
7
7
  import { AnalyticsHandler } from '../../utils/types';
8
8
  import { ReactElement } from 'react';
9
- import { TitleBlockProps } from '../FlexibleCard/components/blocks/title-block/types';
10
- import { FlexibleCardProps } from '../FlexibleCard/types';
11
9
  import { JsonLd } from 'json-ld-types';
12
10
  export interface HoverCardProps extends WithAnalyticsEventsProps {
13
11
  id?: string;
14
12
  url: string;
15
13
  children: ReactElement;
14
+ onAuthorize?: () => void;
16
15
  }
17
16
  export interface HoverCardComponentProps extends HoverCardProps {
18
17
  analyticsHandler: AnalyticsHandler;
19
18
  analytics: AnalyticsFacade;
19
+ onAuthorize?: () => void;
20
20
  }
21
21
  export declare type PreviewDisplay = 'card' | 'embed';
22
22
  export declare type PreviewInvokeMethod = 'keyboard' | 'mouse_hover' | 'mouse_click';
@@ -34,10 +34,7 @@ export declare type HoverCardContentProps = {
34
34
  onActionClick: (actionId: string) => void;
35
35
  onResolve: () => void;
36
36
  url: string;
37
- };
38
- export declare type HoverCardLoadingViewProps = {
39
- flexibleCardProps: FlexibleCardProps;
40
- titleBlockProps: TitleBlockProps;
37
+ onAuthorize?: () => void;
41
38
  };
42
39
  export declare type SnippetOrPreviewProps = {
43
40
  data: JsonLd.Data.BaseData;
@@ -14,6 +14,8 @@ export interface InlineCardUnauthorizedViewProps {
14
14
  isSelected?: boolean;
15
15
  /** A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests */
16
16
  testId?: string;
17
+ /** A flag that determines is a tooltip should show up on hover over the unauthorised link */
18
+ showAuthTooltip?: boolean;
17
19
  }
18
20
  export declare class InlineCardUnauthorizedView extends React.Component<InlineCardUnauthorizedViewProps> {
19
21
  handleConnectAccount: (event: React.MouseEvent<HTMLElement>) => void;
@@ -18,4 +18,5 @@ export declare type InlineCardProps = {
18
18
  inlinePreloaderStyle?: InlinePreloaderStyle;
19
19
  renderers?: CardProviderRenderers;
20
20
  showHoverPreview?: boolean;
21
+ showAuthTooltip?: boolean;
21
22
  };
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ declare type UnauthorisedViewContentProps = {
3
+ /**
4
+ * Is the name of the provider for the account that needs to be connected
5
+ * Eg. Google, Microsoft etc
6
+ */
7
+ providerName?: string;
8
+ /**
9
+ * A `testId` prop is provided for specified elements, which is a unique
10
+ * string that appears as a data attribute `data-testid` in the rendered code,
11
+ * serving as a hook for automated tests
12
+ */
13
+ testId?: string;
14
+ };
15
+ /**
16
+ * This component is used in unauthorized views of a smart link.
17
+ * It represents the main text that provides a user with information on how to connect their account
18
+ */
19
+ declare const UnauthorisedViewContent: ({ providerName, testId, }: UnauthorisedViewContentProps) => JSX.Element;
20
+ export default UnauthorisedViewContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.5.2",
3
+ "version": "23.6.0",
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.14.0",
36
+ "@atlaskit/linking-common": "^1.15.0",
37
37
  "@atlaskit/logo": "^13.10.0",
38
38
  "@atlaskit/lozenge": "^11.3.0",
39
39
  "@atlaskit/media-common": "^2.17.0",