@atlaskit/smart-card 18.0.1 → 18.0.4

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 (30) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/cjs/view/CardWithUrl/component.js +12 -6
  4. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +17 -36
  5. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolved/index.js +6 -80
  6. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/resolving/index.js +12 -27
  7. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/utils.js +103 -0
  8. package/dist/cjs/view/HoverCard/index.js +36 -7
  9. package/dist/cjs/view/HoverCard/styled.js +2 -4
  10. package/dist/es2019/version.json +1 -1
  11. package/dist/es2019/view/CardWithUrl/component.js +11 -6
  12. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +14 -29
  13. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolved/index.js +6 -60
  14. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/resolving/index.js +11 -23
  15. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/utils.js +69 -0
  16. package/dist/es2019/view/HoverCard/index.js +30 -9
  17. package/dist/es2019/view/HoverCard/styled.js +2 -4
  18. package/dist/esm/version.json +1 -1
  19. package/dist/esm/view/CardWithUrl/component.js +11 -6
  20. package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +15 -31
  21. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolved/index.js +6 -65
  22. package/dist/esm/view/FlexibleCard/components/blocks/title-block/resolving/index.js +11 -25
  23. package/dist/esm/view/FlexibleCard/components/blocks/title-block/utils.js +74 -0
  24. package/dist/esm/view/HoverCard/index.js +36 -9
  25. package/dist/esm/view/HoverCard/styled.js +2 -3
  26. package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
  27. package/dist/types/view/Card/index.d.ts +1 -1
  28. package/dist/types/view/FlexibleCard/components/blocks/title-block/utils.d.ts +11 -0
  29. package/dist/types/view/HoverCard/styled.d.ts +1 -2
  30. package/package.json +1 -1
@@ -1,10 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import React, { useCallback, useRef } from 'react';
3
+
4
+ /** @jsx jsx */
5
+ import { jsx } from '@emotion/core';
6
+ import React, { useCallback, useRef, useMemo } from 'react';
4
7
  import { TitleBlock, SnippetBlock, FooterBlock } from '../FlexibleCard/components/blocks';
5
8
  import { Card } from '../Card';
6
9
  import Popup from '@atlaskit/popup';
7
- import { SmartLinkSize } from '../../constants';
10
+ import { SmartLinkSize, ActionName } from '../../constants';
11
+ import { useSmartLinkActions } from '../../state/hooks-external/useSmartLinkActions';
12
+ import { HoverCardContainer } from './styled';
8
13
  export var HoverCard = function HoverCard(_ref) {
9
14
  var children = _ref.children,
10
15
  url = _ref.url;
@@ -34,33 +39,55 @@ export var HoverCard = function HoverCard(_ref) {
34
39
  fadeInTimeoutId.current = setTimeout(function () {
35
40
  setIsOpen(true);
36
41
  }, delay);
37
- }, [delay]);
42
+ }, [delay]); //TODO: EDM-2905: Add analytics events
43
+
44
+ var analyticsHandler = useCallback(function () {}, []);
45
+ var linkActions = useSmartLinkActions({
46
+ url: url,
47
+ appearance: 'block',
48
+ analyticsHandler: analyticsHandler
49
+ });
50
+ var actions = useMemo(function () {
51
+ return linkActions.map(function (action) {
52
+ return {
53
+ content: action.text,
54
+ name: ActionName.CustomAction,
55
+ onClick: function onClick() {
56
+ return action.invoke();
57
+ },
58
+ testId: action.id
59
+ };
60
+ });
61
+ }, [linkActions]);
38
62
 
39
63
  var cardComponent = function cardComponent() {
40
- return /*#__PURE__*/React.createElement("span", {
64
+ return jsx("div", {
41
65
  onMouseEnter: initShowCard,
42
- onMouseLeave: initHideCard
43
- }, /*#__PURE__*/React.createElement(Card, {
66
+ onMouseLeave: initHideCard,
67
+ css: HoverCardContainer
68
+ }, jsx(Card, {
44
69
  appearance: "block",
45
70
  url: url,
46
71
  ui: {
47
72
  hideElevation: true,
48
73
  size: SmartLinkSize.Large
49
74
  }
50
- }, /*#__PURE__*/React.createElement(TitleBlock, null), /*#__PURE__*/React.createElement(SnippetBlock, null), /*#__PURE__*/React.createElement(FooterBlock, null)));
75
+ }, jsx(TitleBlock, null), jsx(SnippetBlock, null), jsx(FooterBlock, {
76
+ actions: actions
77
+ })));
51
78
  };
52
79
 
53
80
  var onClose = useCallback(function () {
54
81
  return setIsOpen(false);
55
82
  }, []);
56
- return /*#__PURE__*/React.createElement(Popup, {
83
+ return jsx(Popup, {
57
84
  testId: "hover-card",
58
85
  isOpen: isOpen,
59
86
  onClose: onClose,
60
87
  placement: "bottom",
61
88
  content: cardComponent,
62
89
  trigger: function trigger(triggerProps) {
63
- return /*#__PURE__*/React.createElement("span", _extends({}, triggerProps, {
90
+ return jsx("span", _extends({}, triggerProps, {
64
91
  onMouseEnter: initShowCard,
65
92
  onMouseLeave: initHideCard
66
93
  }), children);
@@ -2,6 +2,5 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
2
2
 
3
3
  var _templateObject;
4
4
 
5
- import styled from '@emotion/styled';
6
- import { TooltipPrimitive } from '@atlaskit/tooltip';
7
- export var HoverCardContainer = styled(TooltipPrimitive)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: none;\n border-width: 0;\n box-sizing: content-box; /* do not set this to border-box or it will break the overflow handling */\n max-width: 500px;\n padding: 0;\n"])));
5
+ import { css } from '@emotion/core';
6
+ export var HoverCardContainer = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: none;\n border-width: 0;\n max-width: 500px;\n padding: 0;\n"])));
@@ -34,5 +34,5 @@ export declare function useSmartLink(id: string, url: string, dispatchAnalytics:
34
34
  };
35
35
  };
36
36
  renderers: import("../context/types").CardProviderRenderers | undefined;
37
- error: null;
37
+ error: Error | null;
38
38
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Pick<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "onClick" | "url" | "forwardedRef" | "platform" | "isFrameVisible" | "importer" | "container" | "showActions" | "onResolve" | "embedIframeRef" | "inlinePreloaderStyle" | "ui"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "onClick" | "analyticsContext" | "key" | "url" | "forwardedRef" | "platform" | "isFrameVisible" | "importer" | "container" | "showActions" | "onResolve" | "embedIframeRef" | "inlinePreloaderStyle" | "ui"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Pick<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "onClick" | "url" | "ui" | "showActions" | "onResolve" | "platform" | "forwardedRef" | "isFrameVisible" | "importer" | "container" | "embedIframeRef" | "inlinePreloaderStyle"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "children" | "data" | "appearance" | "testId" | "isSelected" | "inheritDimensions" | "onClick" | "analyticsContext" | "key" | "url" | "ui" | "showActions" | "onResolve" | "platform" | "forwardedRef" | "isFrameVisible" | "importer" | "container" | "embedIframeRef" | "inlinePreloaderStyle"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
@@ -0,0 +1,11 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { SerializedStyles } from '@emotion/core';
4
+ import { TitleBlockProps } from './types';
5
+ export declare const actionOnHoverOnlyStyle: SerializedStyles;
6
+ interface BaseTitleBlockProps {
7
+ blockTestIdPostfix: string;
8
+ blockIcon?: React.ReactElement;
9
+ }
10
+ export declare const BaseTitleBlockComponent: React.FC<TitleBlockProps & BaseTitleBlockProps>;
11
+ export {};
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const HoverCardContainer: import("@emotion/styled-base").StyledComponent<Pick<import("@atlaskit/tooltip").TooltipPrimitiveProps, "children" | "style" | "testId" | "className" | "id" | "onMouseOut" | "onMouseOver" | "placement" | "truncate"> & import("react").RefAttributes<HTMLDivElement> & import("react").Attributes, Pick<Pick<import("@atlaskit/tooltip").TooltipPrimitiveProps, "children" | "style" | "testId" | "className" | "id" | "onMouseOut" | "onMouseOver" | "placement" | "truncate"> & import("react").RefAttributes<HTMLDivElement> & import("react").Attributes, "children" | "style" | "testId" | "className" | "id" | "onMouseOut" | "onMouseOver" | "placement" | "truncate">, any>;
1
+ export declare const HoverCardContainer: import("@emotion/utils").SerializedStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.1",
3
+ "version": "18.0.4",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"