@atlaskit/smart-card 26.52.2 → 26.52.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 (112) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/extractors/flexible/actions/index.js +1 -1
  3. package/dist/cjs/messages.js +5 -0
  4. package/dist/cjs/state/hooks/use-ai-summary/ai-summary-service/index.js +72 -102
  5. package/dist/cjs/utils/analytics/analytics.js +1 -1
  6. package/dist/cjs/view/FlexibleCard/components/actions/action/action-icon/index.js +23 -6
  7. package/dist/cjs/view/FlexibleCard/components/actions/action/action-stack-item/index.js +94 -0
  8. package/dist/cjs/view/FlexibleCard/components/actions/action/action-stack-item/types.js +5 -0
  9. package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +36 -20
  10. package/dist/cjs/view/FlexibleCard/components/actions/delete-action/index.js +24 -0
  11. package/dist/cjs/view/FlexibleCard/components/actions/delete-action/types.js +5 -0
  12. package/dist/cjs/view/FlexibleCard/components/actions/edit-action/index.js +24 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/edit-action/types.js +5 -0
  14. package/dist/cjs/view/FlexibleCard/components/actions/index.js +15 -15
  15. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +6 -2
  16. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/preview-icon/index.js +19 -0
  17. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -22
  18. package/dist/cjs/view/FlexibleCard/components/blocks/action-block/index.js +72 -0
  19. package/dist/cjs/view/FlexibleCard/components/blocks/action-block/types.js +5 -0
  20. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +8 -1
  21. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +6 -0
  22. package/dist/cjs/view/FlexibleCard/components/container/index.js +26 -5
  23. package/dist/cjs/view/FlexibleCard/components/utils.js +76 -8
  24. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +2 -0
  25. package/dist/cjs/view/LinkUrl/index.js +1 -1
  26. package/dist/es2019/extractors/flexible/actions/index.js +2 -2
  27. package/dist/es2019/messages.js +5 -0
  28. package/dist/es2019/state/hooks/use-ai-summary/ai-summary-service/index.js +4 -4
  29. package/dist/es2019/utils/analytics/analytics.js +1 -1
  30. package/dist/es2019/view/FlexibleCard/components/actions/action/action-icon/index.js +21 -6
  31. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/index.js +83 -0
  32. package/dist/es2019/view/FlexibleCard/components/actions/action/action-stack-item/types.js +1 -0
  33. package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +34 -17
  34. package/dist/es2019/view/FlexibleCard/components/actions/delete-action/index.js +15 -0
  35. package/dist/es2019/view/FlexibleCard/components/actions/delete-action/types.js +1 -0
  36. package/dist/es2019/view/FlexibleCard/components/actions/edit-action/index.js +15 -0
  37. package/dist/es2019/view/FlexibleCard/components/actions/edit-action/types.js +1 -0
  38. package/dist/es2019/view/FlexibleCard/components/actions/index.js +2 -13
  39. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +6 -2
  40. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/preview-icon/index.js +10 -0
  41. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -24
  42. package/dist/es2019/view/FlexibleCard/components/blocks/action-block/index.js +61 -0
  43. package/dist/es2019/view/FlexibleCard/components/blocks/action-block/types.js +1 -0
  44. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +2 -1
  45. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +6 -0
  46. package/dist/es2019/view/FlexibleCard/components/container/index.js +23 -24
  47. package/dist/es2019/view/FlexibleCard/components/utils.js +73 -38
  48. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +3 -1
  49. package/dist/es2019/view/LinkUrl/index.js +1 -1
  50. package/dist/esm/extractors/flexible/actions/index.js +1 -1
  51. package/dist/esm/messages.js +5 -0
  52. package/dist/esm/state/hooks/use-ai-summary/ai-summary-service/index.js +72 -102
  53. package/dist/esm/utils/analytics/analytics.js +1 -1
  54. package/dist/esm/view/FlexibleCard/components/actions/action/action-icon/index.js +22 -6
  55. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/index.js +84 -0
  56. package/dist/esm/view/FlexibleCard/components/actions/action/action-stack-item/types.js +1 -0
  57. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +35 -18
  58. package/dist/esm/view/FlexibleCard/components/actions/delete-action/index.js +17 -0
  59. package/dist/esm/view/FlexibleCard/components/actions/delete-action/types.js +1 -0
  60. package/dist/esm/view/FlexibleCard/components/actions/edit-action/index.js +17 -0
  61. package/dist/esm/view/FlexibleCard/components/actions/edit-action/types.js +1 -0
  62. package/dist/esm/view/FlexibleCard/components/actions/index.js +2 -13
  63. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +6 -2
  64. package/dist/esm/view/FlexibleCard/components/actions/preview-action/preview-icon/index.js +12 -0
  65. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -22
  66. package/dist/esm/view/FlexibleCard/components/blocks/action-block/index.js +63 -0
  67. package/dist/esm/view/FlexibleCard/components/blocks/action-block/types.js +1 -0
  68. package/dist/esm/view/FlexibleCard/components/blocks/index.js +2 -1
  69. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +6 -0
  70. package/dist/esm/view/FlexibleCard/components/container/index.js +26 -5
  71. package/dist/esm/view/FlexibleCard/components/utils.js +75 -7
  72. package/dist/esm/view/HoverCard/components/views/resolved/index.js +3 -1
  73. package/dist/esm/view/LinkUrl/index.js +1 -1
  74. package/dist/types/messages.d.ts +1 -1
  75. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +2 -2
  76. package/dist/types/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +4 -4
  77. package/dist/types/view/FlexibleCard/components/actions/action/action-icon/types.d.ts +4 -3
  78. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/index.d.ts +4 -0
  79. package/dist/types/view/FlexibleCard/components/actions/action/action-stack-item/types.d.ts +10 -0
  80. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +3 -6
  81. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +24 -16
  82. package/dist/types/view/FlexibleCard/components/actions/delete-action/index.d.ts +4 -0
  83. package/dist/types/view/FlexibleCard/components/actions/delete-action/types.d.ts +2 -0
  84. package/dist/types/view/FlexibleCard/components/actions/edit-action/index.d.ts +4 -0
  85. package/dist/types/view/FlexibleCard/components/actions/edit-action/types.d.ts +2 -0
  86. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +2 -12
  87. package/dist/types/view/FlexibleCard/components/actions/preview-action/preview-icon/index.d.ts +4 -0
  88. package/dist/types/view/FlexibleCard/components/blocks/action-block/index.d.ts +4 -0
  89. package/dist/types/view/FlexibleCard/components/blocks/action-block/types.d.ts +17 -0
  90. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  91. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +5 -0
  92. package/dist/types/view/FlexibleCard/components/utils.d.ts +11 -0
  93. package/dist/types-ts4.5/messages.d.ts +1 -1
  94. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/index.d.ts +2 -2
  95. package/dist/types-ts4.5/state/hooks/use-ai-summary/ai-summary-service/types.d.ts +4 -4
  96. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-icon/types.d.ts +4 -3
  97. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/index.d.ts +4 -0
  98. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/action-stack-item/types.d.ts +10 -0
  99. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/index.d.ts +3 -6
  100. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/types.d.ts +24 -16
  101. package/dist/types-ts4.5/view/FlexibleCard/components/actions/delete-action/index.d.ts +4 -0
  102. package/dist/types-ts4.5/view/FlexibleCard/components/actions/delete-action/types.d.ts +2 -0
  103. package/dist/types-ts4.5/view/FlexibleCard/components/actions/edit-action/index.d.ts +4 -0
  104. package/dist/types-ts4.5/view/FlexibleCard/components/actions/edit-action/types.d.ts +2 -0
  105. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +2 -12
  106. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/preview-icon/index.d.ts +4 -0
  107. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/action-block/index.d.ts +4 -0
  108. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/action-block/types.d.ts +17 -0
  109. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  110. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/utils.d.ts +5 -0
  111. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +11 -0
  112. package/package.json +4 -1
@@ -0,0 +1,83 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import { Box, Inline, xcss } from '@atlaskit/primitives';
3
+ import Spinner from '@atlaskit/spinner';
4
+ import Tooltip from '@atlaskit/tooltip';
5
+ import React, { useCallback } from 'react';
6
+ import { getPrimitivesInlineSpaceBySize } from '../../../utils';
7
+ import ActionIcon from '../action-icon';
8
+ const buttonStyles = xcss({
9
+ all: 'unset',
10
+ padding: 'space.050',
11
+ width: '100%',
12
+ ':focus:not(:focus-visible)': {
13
+ outline: 'none'
14
+ },
15
+ ':focus': {
16
+ outlineColor: 'color.border.focused',
17
+ // xcss outlineOffset does not support space.negative.025
18
+ // @ts-ignore-next-line TS2322: Type "var(--ds-space-negative-025)" is not assignable to type
19
+ outlineOffset: "var(--ds-space-negative-025, -2px)",
20
+ outlineStyle: 'solid',
21
+ outlineWidth: 'border.width.outline'
22
+ },
23
+ ':hover': {
24
+ backgroundColor: 'color.background.neutral.subtle.hovered'
25
+ },
26
+ ':active': {
27
+ backgroundColor: 'color.background.neutral.subtle.pressed'
28
+ }
29
+ });
30
+ const contentStyles = xcss({
31
+ color: 'color.text',
32
+ // Replace with font token once it becomes stable (currently alpha)
33
+ // font: 'font.body.small',
34
+ fontSize: '12px',
35
+ fontStyle: 'normal',
36
+ fontWeight: '400',
37
+ lineHeight: '20px'
38
+ });
39
+ const ActionStackItem = ({
40
+ content,
41
+ icon: iconOption,
42
+ isDisabled,
43
+ isLoading,
44
+ onClick: onClickCallback,
45
+ size,
46
+ space: spaceOption,
47
+ testId,
48
+ tooltipMessage,
49
+ xcss
50
+ }) => {
51
+ const space = spaceOption !== null && spaceOption !== void 0 ? spaceOption : getPrimitivesInlineSpaceBySize(size);
52
+ const onClick = useCallback(() => {
53
+ if (!isDisabled && !isLoading && onClickCallback) {
54
+ onClickCallback();
55
+ }
56
+ }, [isDisabled, isLoading, onClickCallback]);
57
+ const icon = iconOption && isLoading ? /*#__PURE__*/React.createElement(ActionIcon, {
58
+ icon: /*#__PURE__*/React.createElement(Spinner, {
59
+ testId: `${testId}-loading`
60
+ }),
61
+ showBackground: true,
62
+ size: size
63
+ }) : iconOption;
64
+
65
+ // Replace Box with Pressable once it becomes stable (currently beta)
66
+ return /*#__PURE__*/React.createElement(Tooltip, {
67
+ content: tooltipMessage || content,
68
+ hideTooltipOnMouseDown: true
69
+ }, tooltipProps => /*#__PURE__*/React.createElement(Box, _extends({
70
+ as: "button",
71
+ xcss: [buttonStyles, xcss]
72
+ }, tooltipProps, {
73
+ onClick: onClick
74
+ }), /*#__PURE__*/React.createElement(Inline, {
75
+ alignBlock: "center",
76
+ grow: "fill",
77
+ space: space,
78
+ testId: testId
79
+ }, icon, /*#__PURE__*/React.createElement(Box, {
80
+ xcss: contentStyles
81
+ }, content))));
82
+ };
83
+ export default ActionStackItem;
@@ -1,7 +1,8 @@
1
1
  /** @jsx jsx */
2
- import React from 'react';
2
+
3
3
  import { jsx } from '@emotion/react';
4
4
  import { SmartLinkSize } from '../../../../../constants';
5
+ import ActionStackItem from './action-stack-item';
5
6
  import ActionButton from './action-button';
6
7
  import ActionDropdownItem from './action-dropdown-item';
7
8
  import ActionIcon from './action-icon';
@@ -10,11 +11,9 @@ import ActionIcon from './action-icon';
10
11
  * A base action that can be triggered with an on click.
11
12
  * @internal
12
13
  * @param {ActionProps} ActionProps - The props necessary for the Action.
13
- * @see DeleteAction
14
- * @see EditAction
15
- * @see CustomAction
16
14
  */
17
15
  const Action = ({
16
+ as,
18
17
  appearance = 'subtle',
19
18
  content,
20
19
  isLoading = false,
@@ -23,7 +22,9 @@ const Action = ({
23
22
  testId = 'smart-action',
24
23
  icon,
25
24
  iconPosition = 'before',
25
+ spaceInline,
26
26
  tooltipMessage,
27
+ xcss,
27
28
  asDropDownItem,
28
29
  overrideCss,
29
30
  isDisabled
@@ -31,37 +32,53 @@ const Action = ({
31
32
  if (!onClick) {
32
33
  return null;
33
34
  }
35
+ const isStackItem = as === 'stack-item';
36
+ const isDropdownItem = as === 'dropdown-item' || asDropDownItem;
34
37
  const actionIcon = icon && jsx(ActionIcon, {
35
38
  isDisabled: isDisabled,
36
39
  icon: icon,
37
40
  size: size,
41
+ showBackground: isStackItem,
38
42
  testId: testId
39
43
  });
40
44
  const iconBefore = icon && iconPosition === 'before' ? actionIcon : undefined;
41
45
  const iconAfter = icon && iconPosition === 'after' ? actionIcon : undefined;
42
- if (asDropDownItem) {
43
- return jsx(ActionDropdownItem, {
46
+ if (isStackItem) {
47
+ return jsx(ActionStackItem, {
44
48
  content: content,
45
- iconAfter: iconAfter,
46
- iconBefore: iconBefore,
49
+ icon: actionIcon,
50
+ space: spaceInline,
51
+ isDisabled: isDisabled,
47
52
  isLoading: isLoading,
48
53
  onClick: onClick,
49
- testId: testId
54
+ size: size,
55
+ testId: testId,
56
+ tooltipMessage: tooltipMessage || content,
57
+ xcss: xcss
50
58
  });
51
- } else {
52
- return jsx(ActionButton, {
53
- appearance: appearance,
59
+ }
60
+ if (isDropdownItem) {
61
+ return jsx(ActionDropdownItem, {
54
62
  content: content,
55
63
  iconAfter: iconAfter,
56
64
  iconBefore: iconBefore,
57
65
  isLoading: isLoading,
58
66
  onClick: onClick,
59
- overrideCss: overrideCss,
60
- size: size,
61
- testId: testId,
62
- tooltipMessage: tooltipMessage || content,
63
- isDisabled: isDisabled
67
+ testId: testId
64
68
  });
65
69
  }
70
+ return jsx(ActionButton, {
71
+ appearance: appearance,
72
+ content: content,
73
+ iconAfter: iconAfter,
74
+ iconBefore: iconBefore,
75
+ isLoading: isLoading,
76
+ onClick: onClick,
77
+ overrideCss: overrideCss,
78
+ size: size,
79
+ testId: testId,
80
+ tooltipMessage: tooltipMessage || content,
81
+ isDisabled: isDisabled
82
+ });
66
83
  };
67
84
  export default Action;
@@ -0,0 +1,15 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Action from '../action';
4
+ import { messages } from '../../../../../messages';
5
+ import { FormattedMessage } from 'react-intl-next';
6
+ import CrossIcon from '@atlaskit/icon/glyph/cross';
7
+ const DeleteAction = props => /*#__PURE__*/React.createElement(Action, _extends({
8
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete),
9
+ icon: /*#__PURE__*/React.createElement(CrossIcon, {
10
+ label: "Delete"
11
+ }),
12
+ testId: "smart-action-delete-action",
13
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
14
+ }, props));
15
+ export default DeleteAction;
@@ -0,0 +1,15 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Action from '../action';
4
+ import { messages } from '../../../../../messages';
5
+ import { FormattedMessage } from 'react-intl-next';
6
+ import EditIcon from '@atlaskit/icon/glyph/edit';
7
+ const EditAction = props => /*#__PURE__*/React.createElement(Action, _extends({
8
+ content: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit),
9
+ icon: /*#__PURE__*/React.createElement(EditIcon, {
10
+ label: "Edit"
11
+ }),
12
+ testId: "smart-action-edit-action",
13
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
14
+ }, props));
15
+ export default EditAction;
@@ -3,19 +3,8 @@ import { createDataAction, createUIAction } from './utils';
3
3
  export { default as FollowAction } from './follow-action';
4
4
  export { default as PreviewAction } from './preview-action';
5
5
  export { default as DownloadAction } from './download-action';
6
-
7
- /**
8
- * Creates a DeleteAction component. Accepts default ActionProps, but defaults
9
- * the icon to a cross icon.
10
- * @see Action
11
- */
12
- export const DeleteAction = createUIAction(ActionName.DeleteAction);
13
- /**
14
- * Creates a EditAction component. Accepts default ActionProps, but defaults
15
- * the icon to an edit (pencil) icon.
16
- * @see Action
17
- */
18
- export const EditAction = createUIAction(ActionName.EditAction);
6
+ export { default as EditAction } from './edit-action';
7
+ export { default as DeleteAction } from './delete-action';
19
8
 
20
9
  /**
21
10
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
@@ -8,6 +8,7 @@ import { useFlexibleUiAnalyticsContext, useFlexibleUiContext } from '../../../..
8
8
  import useInvokeClientAction from '../../../../../state/hooks/use-invoke-client-action';
9
9
  import { openEmbedModalWithFlexibleUiIcon } from '../../utils';
10
10
  import Action from '../action';
11
+ import PreviewIcon from './preview-icon';
11
12
  const PreviewAction = ({
12
13
  onClick: onClickCallback,
13
14
  ...props
@@ -39,14 +40,17 @@ const PreviewAction = ({
39
40
  onClickCallback();
40
41
  }
41
42
  }, [analytics, data, invoke, onClickCallback]);
43
+ const isStackItem = props.as === 'stack-item';
44
+ const Icon = isStackItem ? PreviewIcon : VidFullScreenOnIcon;
45
+ const tooltipMessage = isStackItem ? messages.preview_description : messages.preview_improved;
42
46
  return data ? /*#__PURE__*/React.createElement(Action, _extends({
43
47
  content: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved),
44
- icon: /*#__PURE__*/React.createElement(VidFullScreenOnIcon, {
48
+ icon: /*#__PURE__*/React.createElement(Icon, {
45
49
  label: "Open preview"
46
50
  }),
47
51
  onClick: onClick,
48
52
  testId: "smart-action-preview-action",
49
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview_improved)
53
+ tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, tooltipMessage)
50
54
  }, data, props)) : null;
51
55
  };
52
56
  export default PreviewAction;
@@ -0,0 +1,10 @@
1
+ import EditorExpandIcon from '@atlaskit/icon/glyph/editor/expand';
2
+ import { Box, xcss } from '@atlaskit/primitives';
3
+ import React from 'react';
4
+ const iconStyles = xcss({
5
+ transform: 'rotate(-45deg)'
6
+ });
7
+ const PreviewIcon = props => /*#__PURE__*/React.createElement(Box, {
8
+ xcss: iconStyles
9
+ }, /*#__PURE__*/React.createElement(EditorExpandIcon, props));
10
+ export default PreviewIcon;
@@ -5,8 +5,6 @@ import React, { useContext } from 'react';
5
5
  import Action from './action';
6
6
  import { FormattedMessage } from 'react-intl-next';
7
7
  import { messages } from '../../../../messages';
8
- import CrossIcon from '@atlaskit/icon/glyph/cross';
9
- import EditIcon from '@atlaskit/icon/glyph/edit';
10
8
  import ViewAction from './action/view-action';
11
9
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
12
10
  const actionMappings = {
@@ -14,28 +12,6 @@ const actionMappings = {
14
12
  component: Action,
15
13
  props: {}
16
14
  },
17
- [ActionName.DeleteAction]: {
18
- component: Action,
19
- props: {
20
- testId: 'smart-action-delete-action',
21
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete),
22
- icon: /*#__PURE__*/React.createElement(CrossIcon, {
23
- label: "Delete"
24
- }),
25
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
26
- }
27
- },
28
- [ActionName.EditAction]: {
29
- component: Action,
30
- props: {
31
- testId: 'smart-action-edit-action',
32
- content: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit),
33
- icon: /*#__PURE__*/React.createElement(EditIcon, {
34
- label: "Edit"
35
- }),
36
- tooltipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.edit)
37
- }
38
- },
39
15
  [ActionName.ViewAction]: {
40
16
  component: ViewAction,
41
17
  props: {
@@ -0,0 +1,61 @@
1
+ import { Stack, xcss } from '@atlaskit/primitives';
2
+ import React, { useMemo } from 'react';
3
+ import { SmartLinkSize } from '../../../../../constants';
4
+ import { useFlexibleUiContext, useFlexibleUiOptionContext } from '../../../../../state/flexible-ui-context';
5
+ import * as Actions from '../../actions';
6
+ import { getPrimitivesPaddingSpaceBySize } from '../../utils';
7
+ // We have to find a better way to ignore container padding
8
+ // This has become more and more of a common use case.
9
+ const ignoreContainerPaddingStyles = xcss({
10
+ marginLeft: 'calc(var(--container-gap-left) * -1)',
11
+ marginRight: 'calc(var(--container-gap-right) * -1)'
12
+ });
13
+ const ActionBlock = ({
14
+ blockRef,
15
+ onClick: onClickCallback,
16
+ size,
17
+ sort,
18
+ spaceInline,
19
+ testId = 'smart-block-action'
20
+ }) => {
21
+ const context = useFlexibleUiContext();
22
+ const ui = useFlexibleUiOptionContext();
23
+ const padding = !(ui !== null && ui !== void 0 && ui.hidePadding) ? getPrimitivesPaddingSpaceBySize((ui === null || ui === void 0 ? void 0 : ui.size) || SmartLinkSize.Medium) : undefined;
24
+ const actions = useMemo(() => {
25
+ if (!(context !== null && context !== void 0 && context.actions)) {
26
+ return;
27
+ }
28
+ const arr = Object.keys(context.actions);
29
+ if (sort) {
30
+ arr.sort(sort);
31
+ }
32
+ return arr.map(name => {
33
+ const Action = Actions[name];
34
+ return Action ? /*#__PURE__*/React.createElement(Action, {
35
+ as: "stack-item",
36
+ spaceInline: spaceInline,
37
+ key: name,
38
+ onClick: () => onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback(name),
39
+ size: size
40
+ // Remove url once ViewAction is retired.
41
+ // This seems to be a typescript workaround
42
+ // because ViewAction marks it as required,
43
+ // which does not reflect actual implementation as the url
44
+ // came from data context and not all actions require url.
45
+ // https://product-fabric.atlassian.net/browse/EDM-9547
46
+ ,
47
+ url: "",
48
+ xcss: xcss({
49
+ paddingInline: padding
50
+ })
51
+ }) : null;
52
+ });
53
+ }, [context === null || context === void 0 ? void 0 : context.actions, onClickCallback, padding, size, sort, spaceInline]);
54
+ return actions ? /*#__PURE__*/React.createElement(Stack, {
55
+ grow: "fill",
56
+ xcss: ignoreContainerPaddingStyles,
57
+ ref: blockRef,
58
+ testId: testId
59
+ }, actions) : null;
60
+ };
61
+ export default ActionBlock;
@@ -8,4 +8,5 @@ export { default as CustomBlock } from './block';
8
8
  // Internal components to be used within @atlaskit/smart-card only.
9
9
  export { default as InternalFooterBlock } from './footer-block/resolved';
10
10
  export { default as RelatedUrlsBlock } from './related-urls-block';
11
- export { default as AISummaryBlock } from './ai-summary-block';
11
+ export { default as AISummaryBlock } from './ai-summary-block';
12
+ export { default as ActionBlock } from './action-block';
@@ -60,6 +60,12 @@ const getDirectionStyles = direction => {
60
60
  });
61
61
  }
62
62
  };
63
+
64
+ /**
65
+ * Get gap size between elements inside a block
66
+ * Equivalent version for DS primitives space token is getPrimitivesInlineSpaceBySize()
67
+ * at view/FlexibleCard/components/utils.tsx
68
+ */
63
69
  export const getGapSize = size => {
64
70
  switch (size) {
65
71
  case SmartLinkSize.XLarge:
@@ -9,11 +9,11 @@ import HoverCardControl from './hover-card-control';
9
9
  import { isFlexUiPreviewPresent } from '../../../../state/flexible-ui-context/utils';
10
10
  import { N40 } from '@atlaskit/theme/colors';
11
11
  import { di } from 'react-magnetic-di';
12
- const elevationStyles = css`
13
- border: 1px solid ${`var(--ds-border, ${N40})`};
14
- border-radius: ${"var(--ds-border-radius-200, 8px)"};
15
- margin: ${"var(--ds-space-025, 2px)"};
16
- `;
12
+ const elevationStyles = css({
13
+ border: `1px solid ${`var(--ds-border, ${N40})`}`,
14
+ borderRadius: "var(--ds-border-radius-200, 8px)",
15
+ margin: "var(--ds-space-025, 2px)"
16
+ });
17
17
  const getGap = size => {
18
18
  switch (size) {
19
19
  case SmartLinkSize.XLarge:
@@ -27,6 +27,12 @@ const getGap = size => {
27
27
  return '.25rem';
28
28
  }
29
29
  };
30
+
31
+ /**
32
+ * Get container padding based on smart link size
33
+ * Equivalent version for DS primitives space token is getPrimitivesPaddingSpaceBySize()
34
+ * at view/FlexibleCard/components/utils.tsx
35
+ */
30
36
  const getPadding = size => {
31
37
  switch (size) {
32
38
  case SmartLinkSize.XLarge:
@@ -40,15 +46,12 @@ const getPadding = size => {
40
46
  return '.5rem';
41
47
  }
42
48
  };
43
- const clickableContainerStyles = css`
44
- // Position any interactive elements at the top of the z-index stack.
45
- a,
46
- button,
47
- .has-action {
48
- position: relative;
49
- z-index: 1;
49
+ const clickableContainerStyles = css({
50
+ 'a, button, .has-action': {
51
+ position: 'relative',
52
+ zIndex: 1
50
53
  }
51
- `;
54
+ });
52
55
  const getContainerPaddingStyles = (size, hidePadding, childrenOptions) => {
53
56
  const padding = hidePadding ? '0rem' : getPadding(size);
54
57
  const gap = getGap(size);
@@ -56,17 +59,13 @@ const getContainerPaddingStyles = (size, hidePadding, childrenOptions) => {
56
59
  previewOnLeft,
57
60
  previewOnRight
58
61
  } = childrenOptions;
59
- return css`
60
- // Set variables for PreviewBlock to use.
61
- --container-padding: ${padding};
62
- --container-gap-left: ${previewOnLeft ? gap : padding};
63
- --container-gap-right: ${previewOnRight ? gap : padding};
64
- --preview-block-width: 30%;
65
-
66
- padding: ${padding};
67
- ${previewOnLeft ? `padding-left: calc(var(--preview-block-width) + ${gap});` : ''}
68
- ${previewOnRight ? `padding-right: calc(var(--preview-block-width) + ${gap});` : ''}
69
- `;
62
+ return css({
63
+ '--container-padding': padding,
64
+ '--container-gap-left': previewOnLeft ? gap : padding,
65
+ '--container-gap-right': previewOnRight ? gap : padding,
66
+ '--preview-block-width': '30%',
67
+ padding: padding
68
+ }, previewOnLeft ? `padding-left: calc(var(--preview-block-width) + ${gap});` : '', previewOnRight ? `padding-right: calc(var(--preview-block-width) + ${gap});` : '');
70
69
  };
71
70
  const getChildrenOptions = (children, context) => {
72
71
  let options = {};
@@ -30,14 +30,14 @@ export const getFormattedMessageAsString = (intl, message, context) => {
30
30
  context
31
31
  }) : '';
32
32
  };
33
- const getIconDimensionStyles = value => css`
34
- height: ${value};
35
- min-height: ${value};
36
- max-height: ${value};
37
- width: ${value};
38
- min-width: ${value};
39
- max-width: ${value};
40
- `;
33
+ const getIconDimensionStyles = value => css({
34
+ height: value,
35
+ minHeight: value,
36
+ maxHeight: value,
37
+ width: value,
38
+ minWidth: value,
39
+ maxWidth: value
40
+ });
41
41
  export const getIconSizeStyles = width => {
42
42
  const sizeStyles = getIconDimensionStyles(width);
43
43
  return css`
@@ -80,28 +80,28 @@ export const getLinkLineHeight = size => {
80
80
  export const getLinkSizeStyles = size => {
81
81
  switch (size) {
82
82
  case SmartLinkSize.XLarge:
83
- return css`
84
- font-size: 1.25rem;
85
- font-weight: 400;
86
- letter-spacing: -0.008em;
87
- line-height: ${getLinkLineHeight(size)};
88
- `;
83
+ return css({
84
+ fontSize: '1.25rem',
85
+ fontWeight: 400,
86
+ letterSpacing: '-0.008em',
87
+ lineHeight: getLinkLineHeight(size)
88
+ });
89
89
  case SmartLinkSize.Large:
90
90
  case SmartLinkSize.Medium:
91
- return css`
92
- font-size: 0.875rem;
93
- font-weight: 400;
94
- letter-spacing: -0.003em;
95
- line-height: ${getLinkLineHeight(size)};
96
- `;
91
+ return css({
92
+ fontSize: '0.875rem',
93
+ fontWeight: 400,
94
+ letterSpacing: '-0.003em',
95
+ lineHeight: getLinkLineHeight(size)
96
+ });
97
97
  case SmartLinkSize.Small:
98
98
  default:
99
- return css`
100
- font-size: 0.75rem;
101
- font-weight: 400;
102
- letter-spacing: 0em;
103
- line-height: ${getLinkLineHeight(size)};
104
- `;
99
+ return css({
100
+ fontSize: '0.75rem',
101
+ fontWeight: 400,
102
+ letterSpacing: '0em',
103
+ lineHeight: getLinkLineHeight(size)
104
+ });
105
105
  }
106
106
  };
107
107
  export const getMaxLineHeight = size => {
@@ -126,18 +126,53 @@ export const getMaxLines = (value, defaultValue, max, min) => {
126
126
  }
127
127
  return value;
128
128
  };
129
- export const getTruncateStyles = (maxLines, lineHeight = '1rem', wordBreak = 'break-word') => css`
130
- display: -webkit-box;
131
- overflow: hidden;
132
- text-overflow: ellipsis;
133
- word-break: ${wordBreak};
134
- -webkit-line-clamp: ${maxLines};
135
- -webkit-box-orient: vertical;
136
- // Fallback options
137
- @supports not (-webkit-line-clamp: 1) {
138
- max-height: calc(${maxLines} * ${lineHeight});
139
- }
140
- `;
129
+
130
+ /**
131
+ * A space between element based on smart link size
132
+ * To replace blocks/utils.tsz getGapSize() with space token for primitives
133
+ */
134
+ export const getPrimitivesInlineSpaceBySize = size => {
135
+ switch (size) {
136
+ case SmartLinkSize.XLarge:
137
+ return 'space.250';
138
+ case SmartLinkSize.Large:
139
+ return 'space.200';
140
+ case SmartLinkSize.Medium:
141
+ return 'space.100';
142
+ case SmartLinkSize.Small:
143
+ default:
144
+ return 'space.050';
145
+ }
146
+ };
147
+
148
+ /**
149
+ * Get container padding based on smart link size
150
+ * To replace container/index.tsx getPadding() with space token for primitives
151
+ */
152
+ export const getPrimitivesPaddingSpaceBySize = size => {
153
+ switch (size) {
154
+ case SmartLinkSize.XLarge:
155
+ return 'space.300';
156
+ case SmartLinkSize.Large:
157
+ return 'space.250';
158
+ case SmartLinkSize.Medium:
159
+ return 'space.200';
160
+ case SmartLinkSize.Small:
161
+ default:
162
+ return 'space.100';
163
+ }
164
+ };
165
+ export const getTruncateStyles = (maxLines, lineHeight = '1rem', wordBreak = 'break-word') => css({
166
+ display: '-webkit-box',
167
+ overflow: 'hidden',
168
+ textOverflow: 'ellipsis',
169
+ wordBreak: wordBreak,
170
+ WebkitLineClamp: maxLines,
171
+ WebkitBoxOrient: 'vertical',
172
+ '@supports not (-webkit-line-clamp: 1)': {
173
+ maxHeight: `calc(${maxLines} * ${lineHeight})`
174
+ }
175
+ });
141
176
  export const hasWhiteSpace = str => {
142
177
  return str.search(/\s/) >= 0;
143
178
  };
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import { ActionName, CardDisplay, ElementName, SmartLinkPosition, SmartLinkSize, SmartLinkDirection } from '../../../../../constants';
4
- import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock, CustomBlock } from '../../../../FlexibleCard/components/blocks';
4
+ import { FooterBlock, MetadataBlock, RelatedUrlsBlock, SnippetBlock, TitleBlock, AISummaryBlock, CustomBlock, ActionBlock } from '../../../../FlexibleCard/components/blocks';
5
5
  import { footerBlockCss, hiddenSnippetStyles, metadataBlockCss } from './styled';
6
6
  import FlexibleCard from '../../../../FlexibleCard';
7
7
  import { getSimulatedBetterMetadata } from '../../../utils';
@@ -184,6 +184,8 @@ const HoverCardResolvedView = ({
184
184
  actions: footerActions,
185
185
  size: SmartLinkSize.Large,
186
186
  overrideCss: footerBlockCss
187
+ }), getBooleanFF('platform.linking-platform.smart-card.hover-card-action-redesign') && /*#__PURE__*/React.createElement(ActionBlock, {
188
+ spaceInline: "space.150"
187
189
  }));
188
190
  };
189
191
  export default HoverCardResolvedView;
@@ -7,7 +7,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
7
7
  import LinkWarningModal from './LinkWarningModal';
8
8
  const PACKAGE_DATA = {
9
9
  packageName: "@atlaskit/smart-card",
10
- packageVersion: "26.52.2",
10
+ packageVersion: "26.52.4",
11
11
  componentName: 'linkUrl'
12
12
  };
13
13
  const Link = withLinkClickedEvent('a');
@@ -5,7 +5,7 @@ import { extractPreviewAction } from './extract-preview-action';
5
5
  import extractFollowAction from './extract-follow-action';
6
6
  var extractActions = function extractActions(response, data, actionOptions, id) {
7
7
  var _action;
8
- var action = (_action = {}, _defineProperty(_action, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _defineProperty(_action, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_action, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _action);
8
+ var action = (_action = {}, _defineProperty(_action, ActionName.DownloadAction, extractDownloadAction(data, actionOptions)), _defineProperty(_action, ActionName.FollowAction, extractFollowAction(response, actionOptions, id)), _defineProperty(_action, ActionName.PreviewAction, extractPreviewAction(response, actionOptions)), _action);
9
9
  return Object.values(action).some(function (value) {
10
10
  return Boolean(value);
11
11
  }) ? action : undefined;