@atlaskit/smart-card 23.6.2 → 23.6.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 23.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b3c2a297df4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3c2a297df4) - Hover Preview: Actionable element experiment: Reload link after embed view modal is closed
8
+
3
9
  ## 23.6.2
4
10
 
5
11
  ### Patch Changes
@@ -100,8 +100,8 @@ var extractPreviewAction = function extractPreviewAction(_ref) {
100
100
 
101
101
  previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
102
102
 
103
- previewAction.promise = function () {
104
- return handleInvoke(previewActionProps);
103
+ previewAction.promise = function (opts) {
104
+ return handleInvoke(_objectSpread(_objectSpread({}, previewActionProps), opts));
105
105
  };
106
106
 
107
107
  return previewAction;
@@ -23,6 +23,8 @@ var _store = require("../store");
23
23
 
24
24
  var _helpers = require("../helpers");
25
25
 
26
+ var _linkProvider = require("@atlaskit/link-provider");
27
+
26
28
  function useSmartLinkActions(_ref) {
27
29
  var url = _ref.url,
28
30
  appearance = _ref.appearance,
@@ -41,16 +43,36 @@ function useSmartLinkActions(_ref) {
41
43
 
42
44
  var linkState = (0, _store.useSmartCardState)(url);
43
45
  var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(url, analyticsHandler, id);
44
- var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics);
46
+ var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics); // Start: Smart ink Actions experiment
47
+
48
+ var enableActionableElement = (0, _linkProvider.useFeatureFlag)('enableActionableElement');
49
+ var reload = (0, _react.useCallback)(function () {
50
+ return linkActions.reload();
51
+ }, [linkActions]);
52
+ var handleInvoke = (0, _react.useCallback)(function (opts) {
53
+ var _opts$action;
54
+
55
+ if (enableActionableElement && opts.type === 'client' && opts.isReloadRequired && ((_opts$action = opts.action) === null || _opts$action === void 0 ? void 0 : _opts$action.type) === 'PreviewAction') {
56
+ // Reload when embed preview modal close
57
+ var promise = opts.action.promise;
58
+
59
+ opts.action.promise = function () {
60
+ return promise({
61
+ onClose: reload
62
+ });
63
+ };
64
+ }
65
+
66
+ return linkActions.invoke(opts, appearance);
67
+ }, [appearance, enableActionableElement, linkActions, reload]); // End: Smart ink Actions experiment
68
+
45
69
  (0, _react.useEffect)(function () {
46
70
  if (!linkState.details) {
47
71
  return;
48
72
  }
49
73
 
50
74
  var cardProperties = (0, _block.extractBlockProps)(linkState.details.data, linkState.details.meta, {
51
- handleInvoke: function handleInvoke(opts) {
52
- return linkActions.invoke(opts, appearance);
53
- },
75
+ handleInvoke: handleInvoke,
54
76
  analytics: linkAnalytics,
55
77
  origin: origin,
56
78
  extensionKey: (0, _helpers.getExtensionKey)(linkState.details),
@@ -69,6 +91,6 @@ function useSmartLinkActions(_ref) {
69
91
  };
70
92
  });
71
93
  setActions(cardActions);
72
- }, [linkState, linkActions, linkAnalytics, appearance, platform, origin]);
94
+ }, [linkState, linkActions, linkAnalytics, appearance, platform, origin, handleInvoke]);
73
95
  return actions;
74
96
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.2",
3
+ "version": "23.6.3",
4
4
  "sideEffects": false
5
5
  }
@@ -115,14 +115,14 @@ var _default = function _default(_ref2) {
115
115
  return {
116
116
  id: 'preview-content',
117
117
  text: /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, _messages.messages.preview),
118
- promise: function promise() {
119
- return previewFunction(_objectSpread({
118
+ promise: function promise(props) {
119
+ return previewFunction(_objectSpread(_objectSpread({
120
120
  popupMountPointId: 'twp-editor-preview-iframe',
121
121
  providerName: 'Preview',
122
122
  showModal: true,
123
123
  iframeName: 'twp-editor-preview-iframe',
124
124
  onClose: function onClose() {}
125
- }, rest));
125
+ }, props), rest));
126
126
  }
127
127
  };
128
128
  };
@@ -121,7 +121,9 @@ var toActionableMetadata = function toActionableMetadata(onActionClick, extensio
121
121
  onActionClick(previewAction.id);
122
122
  }
123
123
 
124
- return previewAction.invoke();
124
+ return previewAction.invoke({
125
+ isReloadRequired: true
126
+ });
125
127
  }
126
128
  }) : elementItem;
127
129
  });
@@ -76,7 +76,9 @@ export const extractPreviewAction = ({
76
76
 
77
77
  previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
78
78
 
79
- previewAction.promise = () => handleInvoke(previewActionProps);
79
+ previewAction.promise = opts => handleInvoke({ ...previewActionProps,
80
+ ...opts
81
+ });
80
82
 
81
83
  return previewAction;
82
84
  }
@@ -1,10 +1,11 @@
1
- import { useEffect, useMemo, useState } from 'react';
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
2
  import uuid from 'uuid';
3
3
  import { extractBlockProps as extractCardProps } from '../../extractors/block';
4
4
  import { useSmartCardActions as useLinkActions } from '../actions';
5
5
  import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
6
6
  import { useSmartCardState as useLinkState } from '../store';
7
7
  import { getExtensionKey } from '../helpers';
8
+ import { useFeatureFlag } from '@atlaskit/link-provider';
8
9
  export function useSmartLinkActions({
9
10
  url,
10
11
  appearance,
@@ -16,14 +17,34 @@ export function useSmartLinkActions({
16
17
  const [actions, setActions] = useState([]);
17
18
  const linkState = useLinkState(url);
18
19
  const linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
19
- const linkActions = useLinkActions(id, url, linkAnalytics);
20
+ const linkActions = useLinkActions(id, url, linkAnalytics); // Start: Smart ink Actions experiment
21
+
22
+ const enableActionableElement = useFeatureFlag('enableActionableElement');
23
+ const reload = useCallback(() => linkActions.reload(), [linkActions]);
24
+ const handleInvoke = useCallback(opts => {
25
+ var _opts$action;
26
+
27
+ if (enableActionableElement && opts.type === 'client' && opts.isReloadRequired && ((_opts$action = opts.action) === null || _opts$action === void 0 ? void 0 : _opts$action.type) === 'PreviewAction') {
28
+ // Reload when embed preview modal close
29
+ const {
30
+ promise
31
+ } = opts.action;
32
+
33
+ opts.action.promise = () => promise({
34
+ onClose: reload
35
+ });
36
+ }
37
+
38
+ return linkActions.invoke(opts, appearance);
39
+ }, [appearance, enableActionableElement, linkActions, reload]); // End: Smart ink Actions experiment
40
+
20
41
  useEffect(() => {
21
42
  if (!linkState.details) {
22
43
  return;
23
44
  }
24
45
 
25
46
  const cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
26
- handleInvoke: opts => linkActions.invoke(opts, appearance),
47
+ handleInvoke,
27
48
  analytics: linkAnalytics,
28
49
  origin,
29
50
  extensionKey: getExtensionKey(linkState.details),
@@ -40,6 +61,6 @@ export function useSmartLinkActions({
40
61
  invoke: action.promise
41
62
  }));
42
63
  setActions(cardActions);
43
- }, [linkState, linkActions, linkAnalytics, appearance, platform, origin]);
64
+ }, [linkState, linkActions, linkAnalytics, appearance, platform, origin, handleInvoke]);
44
65
  return actions;
45
66
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.2",
3
+ "version": "23.6.3",
4
4
  "sideEffects": false
5
5
  }
@@ -55,12 +55,13 @@ export default (({
55
55
  }) => ({
56
56
  id: 'preview-content',
57
57
  text: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview),
58
- promise: () => previewFunction({
58
+ promise: props => previewFunction({
59
59
  popupMountPointId: 'twp-editor-preview-iframe',
60
60
  providerName: 'Preview',
61
61
  showModal: true,
62
62
  iframeName: 'twp-editor-preview-iframe',
63
63
  onClose: () => {},
64
+ ...props,
64
65
  ...rest
65
66
  })
66
67
  }));
@@ -90,7 +90,9 @@ export const toActionableMetadata = (onActionClick, extensionKey, types = [], ca
90
90
  onActionClick(previewAction.id);
91
91
  }
92
92
 
93
- return previewAction.invoke();
93
+ return previewAction.invoke({
94
+ isReloadRequired: true
95
+ });
94
96
  }
95
97
  } : elementItem);
96
98
  }
@@ -89,8 +89,8 @@ export var extractPreviewAction = function extractPreviewAction(_ref) {
89
89
 
90
90
  previewActionProps.action.promise = previewAction.promise; // - Promise invoked on click of `Preview` on block card; trigger above promise.
91
91
 
92
- previewAction.promise = function () {
93
- return handleInvoke(previewActionProps);
92
+ previewAction.promise = function (opts) {
93
+ return handleInvoke(_objectSpread(_objectSpread({}, previewActionProps), opts));
94
94
  };
95
95
 
96
96
  return previewAction;
@@ -1,11 +1,12 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import { useEffect, useMemo, useState } from 'react';
2
+ import { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import uuid from 'uuid';
4
4
  import { extractBlockProps as extractCardProps } from '../../extractors/block';
5
5
  import { useSmartCardActions as useLinkActions } from '../actions';
6
6
  import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
7
7
  import { useSmartCardState as useLinkState } from '../store';
8
8
  import { getExtensionKey } from '../helpers';
9
+ import { useFeatureFlag } from '@atlaskit/link-provider';
9
10
  export function useSmartLinkActions(_ref) {
10
11
  var url = _ref.url,
11
12
  appearance = _ref.appearance,
@@ -24,16 +25,36 @@ export function useSmartLinkActions(_ref) {
24
25
 
25
26
  var linkState = useLinkState(url);
26
27
  var linkAnalytics = useLinkAnalytics(url, analyticsHandler, id);
27
- var linkActions = useLinkActions(id, url, linkAnalytics);
28
+ var linkActions = useLinkActions(id, url, linkAnalytics); // Start: Smart ink Actions experiment
29
+
30
+ var enableActionableElement = useFeatureFlag('enableActionableElement');
31
+ var reload = useCallback(function () {
32
+ return linkActions.reload();
33
+ }, [linkActions]);
34
+ var handleInvoke = useCallback(function (opts) {
35
+ var _opts$action;
36
+
37
+ if (enableActionableElement && opts.type === 'client' && opts.isReloadRequired && ((_opts$action = opts.action) === null || _opts$action === void 0 ? void 0 : _opts$action.type) === 'PreviewAction') {
38
+ // Reload when embed preview modal close
39
+ var promise = opts.action.promise;
40
+
41
+ opts.action.promise = function () {
42
+ return promise({
43
+ onClose: reload
44
+ });
45
+ };
46
+ }
47
+
48
+ return linkActions.invoke(opts, appearance);
49
+ }, [appearance, enableActionableElement, linkActions, reload]); // End: Smart ink Actions experiment
50
+
28
51
  useEffect(function () {
29
52
  if (!linkState.details) {
30
53
  return;
31
54
  }
32
55
 
33
56
  var cardProperties = extractCardProps(linkState.details.data, linkState.details.meta, {
34
- handleInvoke: function handleInvoke(opts) {
35
- return linkActions.invoke(opts, appearance);
36
- },
57
+ handleInvoke: handleInvoke,
37
58
  analytics: linkAnalytics,
38
59
  origin: origin,
39
60
  extensionKey: getExtensionKey(linkState.details),
@@ -52,6 +73,6 @@ export function useSmartLinkActions(_ref) {
52
73
  };
53
74
  });
54
75
  setActions(cardActions);
55
- }, [linkState, linkActions, linkAnalytics, appearance, platform, origin]);
76
+ }, [linkState, linkActions, linkAnalytics, appearance, platform, origin, handleInvoke]);
56
77
  return actions;
57
78
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.2",
3
+ "version": "23.6.3",
4
4
  "sideEffects": false
5
5
  }
@@ -88,14 +88,14 @@ export default (function (_ref2) {
88
88
  return {
89
89
  id: 'preview-content',
90
90
  text: /*#__PURE__*/React.createElement(FormattedMessage, messages.preview),
91
- promise: function promise() {
92
- return previewFunction(_objectSpread({
91
+ promise: function promise(props) {
92
+ return previewFunction(_objectSpread(_objectSpread({
93
93
  popupMountPointId: 'twp-editor-preview-iframe',
94
94
  providerName: 'Preview',
95
95
  showModal: true,
96
96
  iframeName: 'twp-editor-preview-iframe',
97
97
  onClose: function onClose() {}
98
- }, rest));
98
+ }, props), rest));
99
99
  }
100
100
  };
101
101
  });
@@ -106,7 +106,9 @@ export var toActionableMetadata = function toActionableMetadata(onActionClick, e
106
106
  onActionClick(previewAction.id);
107
107
  }
108
108
 
109
- return previewAction.invoke();
109
+ return previewAction.invoke({
110
+ isReloadRequired: true
111
+ });
110
112
  }
111
113
  }) : elementItem;
112
114
  });
@@ -13,5 +13,5 @@ export declare type InvokeServerOpts = InvokeOpts<ServerActionOpts> & {
13
13
  };
14
14
  export interface ClientActionOpts {
15
15
  type: string;
16
- promise: () => Promise<void>;
16
+ promise: <T>(opts?: T) => Promise<void>;
17
17
  }
@@ -2,6 +2,9 @@
2
2
  import { JsonLd } from 'json-ld-types';
3
3
  import type { AnalyticsHandler, AnalyticsOrigin } from '../../utils/types';
4
4
  import type { CardInnerAppearance } from '../../view/Card/types';
5
+ declare type ExperimentInvokeOpts = {
6
+ isReloadRequired?: boolean;
7
+ };
5
8
  export interface LinkAction {
6
9
  /**
7
10
  * Unique ID for the action.
@@ -18,7 +21,7 @@ export interface LinkAction {
18
21
  * Promise to invoke on triggering this action.
19
22
  * @example Clicking on `Delete` leading to deletion of content.
20
23
  */
21
- invoke: () => Promise<any>;
24
+ invoke: (opts?: ExperimentInvokeOpts) => Promise<any>;
22
25
  }
23
26
  export interface UseSmartLinkActionsOpts {
24
27
  /**
@@ -47,3 +50,4 @@ export interface UseSmartLinkActionsOpts {
47
50
  origin?: AnalyticsOrigin;
48
51
  }
49
52
  export declare function useSmartLinkActions({ url, appearance, analyticsHandler, platform, origin, }: UseSmartLinkActionsOpts): LinkAction[];
53
+ export {};
@@ -5,7 +5,7 @@ import { Appearance } from '@atlaskit/button/types';
5
5
  export interface ActionProps {
6
6
  id: string;
7
7
  text: React.ReactNode;
8
- promise: () => Promise<any>;
8
+ promise: <T>(opts?: T) => Promise<any>;
9
9
  buttonAppearance?: Appearance;
10
10
  }
11
11
  export declare type ActionState = 'init' | 'loading' | 'success' | 'failure';
@@ -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<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "onResolve" | "platform" | "isFrameVisible" | "embedIframeRef" | "showHoverPreview" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "onResolve" | "platform" | "showHoverPreview" | "isFrameVisible" | "embedIframeRef" | "inlinePreloaderStyle" | "importer" | "container" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.6.2",
3
+ "version": "23.6.3",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"