@atlaskit/smart-card 26.50.14 → 26.51.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 (84) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/extractors/common/context/extractAccessContext.js +28 -67
  3. package/dist/cjs/extractors/common/context/index.js +2 -2
  4. package/dist/cjs/extractors/flexible/actions/index.js +17 -0
  5. package/dist/cjs/extractors/flexible/index.js +2 -2
  6. package/dist/cjs/state/flexible-ui-context/types.js +1 -3
  7. package/dist/cjs/utils/analytics/analytics.js +1 -1
  8. package/dist/cjs/view/BlockCard/index.js +7 -3
  9. package/dist/cjs/view/BlockCard/views/ForbiddenView.js +3 -2
  10. package/dist/cjs/view/FlexibleCard/components/actions/index.js +8 -12
  11. package/dist/cjs/view/FlexibleCard/components/actions/preview-action/index.js +83 -0
  12. package/dist/cjs/view/FlexibleCard/components/actions/types.js +5 -0
  13. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +0 -13
  14. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  15. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +45 -11
  16. package/dist/cjs/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  17. package/dist/cjs/view/FlexibleCard/utils.js +4 -4
  18. package/dist/cjs/view/LinkUrl/index.js +1 -1
  19. package/dist/cjs/view/common/ai-summary/index.js +5 -1
  20. package/dist/es2019/extractors/common/context/extractAccessContext.js +26 -68
  21. package/dist/es2019/extractors/common/context/index.js +1 -1
  22. package/dist/es2019/extractors/flexible/actions/index.js +9 -0
  23. package/dist/es2019/extractors/flexible/index.js +2 -2
  24. package/dist/es2019/state/flexible-ui-context/types.js +6 -1
  25. package/dist/es2019/utils/analytics/analytics.js +1 -1
  26. package/dist/es2019/view/BlockCard/index.js +9 -4
  27. package/dist/es2019/view/BlockCard/views/ForbiddenView.js +3 -2
  28. package/dist/es2019/view/FlexibleCard/components/actions/index.js +1 -11
  29. package/dist/es2019/view/FlexibleCard/components/actions/preview-action/index.js +52 -0
  30. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +0 -14
  31. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  32. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +42 -33
  33. package/dist/es2019/view/FlexibleCard/components/elements/snippet-element/index.js +7 -4
  34. package/dist/es2019/view/FlexibleCard/utils.js +5 -5
  35. package/dist/es2019/view/LinkUrl/index.js +1 -1
  36. package/dist/es2019/view/common/ai-summary/index.js +5 -1
  37. package/dist/esm/extractors/common/context/extractAccessContext.js +27 -66
  38. package/dist/esm/extractors/common/context/index.js +1 -1
  39. package/dist/esm/extractors/flexible/actions/index.js +10 -0
  40. package/dist/esm/extractors/flexible/index.js +2 -2
  41. package/dist/esm/state/flexible-ui-context/types.js +6 -1
  42. package/dist/esm/utils/analytics/analytics.js +1 -1
  43. package/dist/esm/view/BlockCard/index.js +8 -4
  44. package/dist/esm/view/BlockCard/views/ForbiddenView.js +3 -2
  45. package/dist/esm/view/FlexibleCard/components/actions/index.js +1 -11
  46. package/dist/esm/view/FlexibleCard/components/actions/preview-action/index.js +73 -0
  47. package/dist/esm/view/FlexibleCard/components/actions/preview-action/types.js +1 -0
  48. package/dist/esm/view/FlexibleCard/components/actions/types.js +1 -0
  49. package/dist/esm/view/FlexibleCard/components/actions/utils.js +0 -13
  50. package/dist/esm/view/FlexibleCard/components/blocks/action-group/action-group-item/index.js +8 -6
  51. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +45 -11
  52. package/dist/esm/view/FlexibleCard/components/elements/snippet-element/index.js +7 -3
  53. package/dist/esm/view/FlexibleCard/utils.js +5 -5
  54. package/dist/esm/view/LinkUrl/index.js +1 -1
  55. package/dist/esm/view/common/ai-summary/index.js +5 -1
  56. package/dist/types/extractors/common/context/extractAccessContext.d.ts +1 -6
  57. package/dist/types/extractors/common/context/index.d.ts +1 -1
  58. package/dist/types/extractors/flexible/actions/index.d.ts +5 -0
  59. package/dist/types/state/flexible-ui-context/types.d.ts +8 -7
  60. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -7
  61. package/dist/types/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  62. package/dist/types/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  63. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +7 -0
  64. package/dist/types/view/FlexibleCard/types.d.ts +20 -2
  65. package/dist/types-ts4.5/extractors/common/context/extractAccessContext.d.ts +1 -6
  66. package/dist/types-ts4.5/extractors/common/context/index.d.ts +1 -1
  67. package/dist/types-ts4.5/extractors/flexible/actions/index.d.ts +5 -0
  68. package/dist/types-ts4.5/state/flexible-ui-context/types.d.ts +8 -7
  69. package/dist/types-ts4.5/view/FlexibleCard/components/actions/index.d.ts +1 -7
  70. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/index.d.ts +4 -0
  71. package/dist/types-ts4.5/view/FlexibleCard/components/actions/preview-action/types.d.ts +2 -0
  72. package/dist/types-ts4.5/view/FlexibleCard/components/actions/types.d.ts +7 -0
  73. package/dist/types-ts4.5/view/FlexibleCard/types.d.ts +20 -2
  74. package/package.json +2 -2
  75. package/dist/cjs/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -87
  76. package/dist/es2019/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -63
  77. package/dist/esm/view/FlexibleCard/components/actions/action/preview-action/index.js +0 -80
  78. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  79. package/dist/types/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  80. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/index.d.ts +0 -4
  81. package/dist/types-ts4.5/view/FlexibleCard/components/actions/action/preview-action/types.d.ts +0 -12
  82. /package/dist/cjs/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  83. /package/dist/es2019/view/FlexibleCard/components/actions/{action/preview-action → preview-action}/types.js +0 -0
  84. /package/dist/{esm/view/FlexibleCard/components/actions/action/preview-action → es2019/view/FlexibleCard/components/actions}/types.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { LinkLozenge } from '../../extractors/common/lozenge/types';
2
2
  import { LinkPerson } from '@atlaskit/link-extractors';
3
- import { IconType, MediaType } from '../../constants';
3
+ import { ActionName, IconType, MediaType } from '../../constants';
4
4
  import { InvokeRequestWithCardDetails } from '../hooks/use-invoke/types';
5
5
  import type { CardInnerAppearance } from '../../view/Card/types';
6
6
  import type { AnalyticsFacade } from '../analytics';
@@ -9,6 +9,10 @@ import type { AnalyticsFacade } from '../analytics';
9
9
  * underlying elements.
10
10
  */
11
11
  export type FlexibleUiDataContext = {
12
+ /**
13
+ * An object containing available action on the linked resource.
14
+ */
15
+ actions?: FlexibleUiActions;
12
16
  /**
13
17
  * An array containing data used to populate the AssignedToGroup element.
14
18
  * @see AvatarGroup
@@ -102,12 +106,6 @@ export type FlexibleUiDataContext = {
102
106
  * @see CreatedOn
103
107
  */
104
108
  createdOn?: string;
105
- /**
106
- * Contains data needed to show a preview action.
107
- * @type PreviewActionData
108
- * @see PreviewAction
109
- */
110
- previewAction?: PreviewActionData;
111
109
  /**
112
110
  * Contains data needed to show a view action.
113
111
  * @type ViewActionData
@@ -254,6 +252,9 @@ export type Media = {
254
252
  type: MediaType;
255
253
  url: string;
256
254
  };
255
+ export type FlexibleUiActions = {
256
+ [ActionName.PreviewAction]?: PreviewActionData;
257
+ };
257
258
  export type PreviewActionData = {
258
259
  downloadUrl?: string;
259
260
  linkIcon?: Icon;
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionProps } from './action/types';
3
- import { PreviewActionProps } from './action/preview-action/types';
4
3
  import { ViewActionProps } from './action/view-action/types';
5
4
  import { DownloadActionProps } from './action/download-action/types';
6
5
  export { default as FollowAction } from './follow-action';
6
+ export { default as PreviewAction } from './preview-action';
7
7
  /**
8
8
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
9
9
  * the icon to a cross icon.
@@ -16,12 +16,6 @@ export declare const DeleteAction: import("react").FC<ActionProps>;
16
16
  * @see Action
17
17
  */
18
18
  export declare const EditAction: import("react").FC<ActionProps>;
19
- /**
20
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
21
- * to the text 'Preview' inside the button.
22
- * @see Action
23
- */
24
- export declare const PreviewAction: import("react").FC<PreviewActionProps>;
25
19
  /**
26
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
27
21
  * to the text 'View' inside the button.
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import type { PreviewActionProps } from './types';
3
+ declare const PreviewAction: FC<PreviewActionProps>;
4
+ export default PreviewAction;
@@ -0,0 +1,2 @@
1
+ import { LinkActionProps } from '../types';
2
+ export type PreviewActionProps = LinkActionProps;
@@ -0,0 +1,7 @@
1
+ import type { Optional } from '../../types';
2
+ import type { ActionProps } from './action/types';
3
+ /**
4
+ * Action based on link data.
5
+ * Action behaviour is determined by the availability of the link data.
6
+ */
7
+ export type LinkActionProps = Optional<ActionProps, 'onClick'>;
@@ -79,12 +79,12 @@ export type FlexibleCardProps = {
79
79
  * Determine whether or not a preview card should show up when a user hovers
80
80
  * over the smartlink. Default value is false.
81
81
  */
82
- showHoverPreview?: Boolean;
82
+ showHoverPreview?: boolean;
83
83
  /**
84
84
  * Determines whether to show an unauthorised view of the hover card
85
85
  * when a user hovers over a smartlink.
86
86
  */
87
- showAuthTooltip?: Boolean;
87
+ showAuthTooltip?: boolean;
88
88
  };
89
89
  export type FlexibleUiOptions = {
90
90
  /**
@@ -146,3 +146,21 @@ export type ExtractFlexibleUiDataContextParams = Pick<FlexibleCardProps, 'id' |
146
146
  response?: JsonLd.Response;
147
147
  featureFlags?: Partial<LinkingPlatformFeatureFlags>;
148
148
  };
149
+ /**
150
+ * Mark a specific props in the type as optional.
151
+ * FlexibleCard use this concept where base component has required props
152
+ * and the extended component provides these props. The props become an optional
153
+ * for the extended component but is still available for override/callback.
154
+ *
155
+ * For example: Action component require onClick callback to perform action
156
+ * but PreviewAction defines the onClick behaviour inside its component.
157
+ * PreviewAction still wants the onClick for a callback to executed after the
158
+ * action completes, but it is optional.
159
+ *
160
+ * Usage:
161
+ * type ActionProps = { onClick: () => {}, content: string, icon?: React.ReactNode }
162
+ * type PreviewActionProps = Optional<ActionProps, 'onClick'>
163
+ */
164
+ export type Optional<T, K extends keyof T> = Omit<T, K> & {
165
+ [K in keyof T]?: T[K];
166
+ };
@@ -1,14 +1,9 @@
1
1
  import { JsonLd } from 'json-ld-types';
2
2
  import { RequestAccessContextProps } from '../../../view/types';
3
3
  import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
4
- export declare const extractRequestAccessContext: ({ jsonLd, url, product, }: {
5
- jsonLd: JsonLd.Meta.BaseMeta;
6
- url: string;
7
- product?: string | undefined;
8
- }) => RequestAccessContextProps;
9
4
  export declare const extractRequestAccessContextImproved: ({ jsonLd, url, product, createAnalyticsEvent, }: {
10
5
  jsonLd: JsonLd.Meta.BaseMeta;
11
6
  url: string;
12
7
  product: string;
13
- createAnalyticsEvent: CreateUIAnalyticsEvent;
8
+ createAnalyticsEvent?: CreateUIAnalyticsEvent | undefined;
14
9
  }) => RequestAccessContextProps;
@@ -1 +1 @@
1
- export { extractRequestAccessContext } from './extractAccessContext';
1
+ export { extractRequestAccessContextImproved } from './extractAccessContext';
@@ -0,0 +1,5 @@
1
+ import type { JsonLd } from 'json-ld-types';
2
+ import type { FlexibleUiActions } from '../../../state/flexible-ui-context/types';
3
+ import type { CardActionOptions } from '../../../view/Card/types';
4
+ declare const extractActions: (response: JsonLd.Response, actionOptions?: CardActionOptions) => FlexibleUiActions | undefined;
5
+ export default extractActions;
@@ -1,6 +1,6 @@
1
1
  import { LinkLozenge } from '../../extractors/common/lozenge/types';
2
2
  import { LinkPerson } from '@atlaskit/link-extractors';
3
- import { IconType, MediaType } from '../../constants';
3
+ import { ActionName, IconType, MediaType } from '../../constants';
4
4
  import { InvokeRequestWithCardDetails } from '../hooks/use-invoke/types';
5
5
  import type { CardInnerAppearance } from '../../view/Card/types';
6
6
  import type { AnalyticsFacade } from '../analytics';
@@ -9,6 +9,10 @@ import type { AnalyticsFacade } from '../analytics';
9
9
  * underlying elements.
10
10
  */
11
11
  export type FlexibleUiDataContext = {
12
+ /**
13
+ * An object containing available action on the linked resource.
14
+ */
15
+ actions?: FlexibleUiActions;
12
16
  /**
13
17
  * An array containing data used to populate the AssignedToGroup element.
14
18
  * @see AvatarGroup
@@ -102,12 +106,6 @@ export type FlexibleUiDataContext = {
102
106
  * @see CreatedOn
103
107
  */
104
108
  createdOn?: string;
105
- /**
106
- * Contains data needed to show a preview action.
107
- * @type PreviewActionData
108
- * @see PreviewAction
109
- */
110
- previewAction?: PreviewActionData;
111
109
  /**
112
110
  * Contains data needed to show a view action.
113
111
  * @type ViewActionData
@@ -254,6 +252,9 @@ export type Media = {
254
252
  type: MediaType;
255
253
  url: string;
256
254
  };
255
+ export type FlexibleUiActions = {
256
+ [ActionName.PreviewAction]?: PreviewActionData;
257
+ };
257
258
  export type PreviewActionData = {
258
259
  downloadUrl?: string;
259
260
  linkIcon?: Icon;
@@ -1,9 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { ActionProps } from './action/types';
3
- import { PreviewActionProps } from './action/preview-action/types';
4
3
  import { ViewActionProps } from './action/view-action/types';
5
4
  import { DownloadActionProps } from './action/download-action/types';
6
5
  export { default as FollowAction } from './follow-action';
6
+ export { default as PreviewAction } from './preview-action';
7
7
  /**
8
8
  * Creates a DeleteAction component. Accepts default ActionProps, but defaults
9
9
  * the icon to a cross icon.
@@ -16,12 +16,6 @@ export declare const DeleteAction: import("react").FC<ActionProps>;
16
16
  * @see Action
17
17
  */
18
18
  export declare const EditAction: import("react").FC<ActionProps>;
19
- /**
20
- * Creates a PreviewAction component. Accepts default PreviewActionProps, and defaults
21
- * to the text 'Preview' inside the button.
22
- * @see Action
23
- */
24
- export declare const PreviewAction: import("react").FC<PreviewActionProps>;
25
19
  /**
26
20
  * Creates a ViewAction component. Accepts default ViewActionProps, and defaults
27
21
  * to the text 'View' inside the button.
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import type { PreviewActionProps } from './types';
3
+ declare const PreviewAction: FC<PreviewActionProps>;
4
+ export default PreviewAction;
@@ -0,0 +1,2 @@
1
+ import { LinkActionProps } from '../types';
2
+ export type PreviewActionProps = LinkActionProps;
@@ -0,0 +1,7 @@
1
+ import type { Optional } from '../../types';
2
+ import type { ActionProps } from './action/types';
3
+ /**
4
+ * Action based on link data.
5
+ * Action behaviour is determined by the availability of the link data.
6
+ */
7
+ export type LinkActionProps = Optional<ActionProps, 'onClick'>;
@@ -79,12 +79,12 @@ export type FlexibleCardProps = {
79
79
  * Determine whether or not a preview card should show up when a user hovers
80
80
  * over the smartlink. Default value is false.
81
81
  */
82
- showHoverPreview?: Boolean;
82
+ showHoverPreview?: boolean;
83
83
  /**
84
84
  * Determines whether to show an unauthorised view of the hover card
85
85
  * when a user hovers over a smartlink.
86
86
  */
87
- showAuthTooltip?: Boolean;
87
+ showAuthTooltip?: boolean;
88
88
  };
89
89
  export type FlexibleUiOptions = {
90
90
  /**
@@ -146,3 +146,21 @@ export type ExtractFlexibleUiDataContextParams = Pick<FlexibleCardProps, 'id' |
146
146
  response?: JsonLd.Response;
147
147
  featureFlags?: Partial<LinkingPlatformFeatureFlags>;
148
148
  };
149
+ /**
150
+ * Mark a specific props in the type as optional.
151
+ * FlexibleCard use this concept where base component has required props
152
+ * and the extended component provides these props. The props become an optional
153
+ * for the extended component but is still available for override/callback.
154
+ *
155
+ * For example: Action component require onClick callback to perform action
156
+ * but PreviewAction defines the onClick behaviour inside its component.
157
+ * PreviewAction still wants the onClick for a callback to executed after the
158
+ * action completes, but it is optional.
159
+ *
160
+ * Usage:
161
+ * type ActionProps = { onClick: () => {}, content: string, icon?: React.ReactNode }
162
+ * type PreviewActionProps = Optional<ActionProps, 'onClick'>
163
+ */
164
+ export type Optional<T, K extends keyof T> = Omit<T, K> & {
165
+ [K in keyof T]?: T[K];
166
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.50.14",
3
+ "version": "26.51.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -51,7 +51,7 @@
51
51
  "@atlaskit/outbound-auth-flow-client": "^3.4.0",
52
52
  "@atlaskit/platform-feature-flags": "^0.2.1",
53
53
  "@atlaskit/popup": "^1.14.0",
54
- "@atlaskit/primitives": "^5.2.0",
54
+ "@atlaskit/primitives": "^5.3.0",
55
55
  "@atlaskit/spinner": "^16.0.0",
56
56
  "@atlaskit/theme": "^12.7.0",
57
57
  "@atlaskit/tokens": "^1.42.0",
@@ -1,87 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
- var _react = _interopRequireDefault(require("react"));
13
- var _index = _interopRequireDefault(require("../index"));
14
- var _flexibleUiContext = require("../../../../../../state/flexible-ui-context");
15
- var _utils = require("../../../utils");
16
- var _useInvokeClientAction = _interopRequireDefault(require("../../../../../../state/hooks/use-invoke-client-action"));
17
- var _constants = require("../../../../../../constants");
18
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
- var PreviewAction = function PreviewAction(props) {
21
- var appearance = props.appearance,
22
- asDropDownItem = props.asDropDownItem,
23
- testId = props.testId,
24
- _onClick = props.onClick,
25
- linkIcon = props.linkIcon,
26
- src = props.src,
27
- url = props.url,
28
- title = props.title,
29
- providerName = props.providerName,
30
- downloadUrl = props.downloadUrl,
31
- isSupportTheming = props.isSupportTheming;
32
- var analytics = (0, _flexibleUiContext.useFlexibleUiAnalyticsContext)();
33
- var invoke = (0, _useInvokeClientAction.default)({
34
- analytics: analytics
35
- });
36
- if (src && url) {
37
- var actionFn = /*#__PURE__*/function () {
38
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
39
- return _regenerator.default.wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
41
- case 0:
42
- return _context.abrupt("return", (0, _utils.openEmbedModalWithFlexibleUiIcon)({
43
- download: downloadUrl,
44
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
45
- title: title,
46
- providerName: providerName,
47
- isSupportTheming: isSupportTheming,
48
- analytics: analytics,
49
- linkIcon: linkIcon,
50
- src: src,
51
- url: url
52
- }));
53
- case 1:
54
- case "end":
55
- return _context.stop();
56
- }
57
- }, _callee);
58
- }));
59
- return function actionFn() {
60
- return _ref.apply(this, arguments);
61
- };
62
- }();
63
- var action = _objectSpread(_objectSpread({}, props), {}, {
64
- onClick: function onClick() {
65
- invoke({
66
- actionType: _constants.ActionName.PreviewAction,
67
- actionFn: actionFn,
68
- // These values have already been set in analytics context.
69
- // We only pass these here for ufo experience.
70
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
71
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
72
- });
73
- if (_onClick) {
74
- _onClick();
75
- }
76
- }
77
- });
78
- return /*#__PURE__*/_react.default.createElement(_index.default, (0, _extends2.default)({}, action, {
79
- appearance: appearance,
80
- asDropDownItem: asDropDownItem,
81
- testId: testId
82
- }));
83
- } else {
84
- return null;
85
- }
86
- };
87
- var _default = exports.default = PreviewAction;
@@ -1,63 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import Action from '../index';
4
- import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
5
- import { openEmbedModalWithFlexibleUiIcon } from '../../../utils';
6
- import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
7
- import { ActionName } from '../../../../../../constants';
8
- const PreviewAction = props => {
9
- const {
10
- appearance,
11
- asDropDownItem,
12
- testId,
13
- onClick,
14
- linkIcon,
15
- src,
16
- url,
17
- title,
18
- providerName,
19
- downloadUrl,
20
- isSupportTheming
21
- } = props;
22
- const analytics = useFlexibleUiAnalyticsContext();
23
- const invoke = useInvokeClientAction({
24
- analytics
25
- });
26
- if (src && url) {
27
- const actionFn = async () => openEmbedModalWithFlexibleUiIcon({
28
- download: downloadUrl,
29
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
30
- title,
31
- providerName,
32
- isSupportTheming,
33
- analytics,
34
- linkIcon,
35
- src,
36
- url
37
- });
38
- const action = {
39
- ...props,
40
- onClick: () => {
41
- invoke({
42
- actionType: ActionName.PreviewAction,
43
- actionFn,
44
- // These values have already been set in analytics context.
45
- // We only pass these here for ufo experience.
46
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
47
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
48
- });
49
- if (onClick) {
50
- onClick();
51
- }
52
- }
53
- };
54
- return /*#__PURE__*/React.createElement(Action, _extends({}, action, {
55
- appearance: appearance,
56
- asDropDownItem: asDropDownItem,
57
- testId: testId
58
- }));
59
- } else {
60
- return null;
61
- }
62
- };
63
- export default PreviewAction;
@@ -1,80 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
- import _regeneratorRuntime from "@babel/runtime/regenerator";
7
- import React from 'react';
8
- import Action from '../index';
9
- import { useFlexibleUiAnalyticsContext } from '../../../../../../state/flexible-ui-context';
10
- import { openEmbedModalWithFlexibleUiIcon } from '../../../utils';
11
- import useInvokeClientAction from '../../../../../../state/hooks/use-invoke-client-action';
12
- import { ActionName } from '../../../../../../constants';
13
- var PreviewAction = function PreviewAction(props) {
14
- var appearance = props.appearance,
15
- asDropDownItem = props.asDropDownItem,
16
- testId = props.testId,
17
- _onClick = props.onClick,
18
- linkIcon = props.linkIcon,
19
- src = props.src,
20
- url = props.url,
21
- title = props.title,
22
- providerName = props.providerName,
23
- downloadUrl = props.downloadUrl,
24
- isSupportTheming = props.isSupportTheming;
25
- var analytics = useFlexibleUiAnalyticsContext();
26
- var invoke = useInvokeClientAction({
27
- analytics: analytics
28
- });
29
- if (src && url) {
30
- var actionFn = /*#__PURE__*/function () {
31
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
32
- return _regeneratorRuntime.wrap(function _callee$(_context) {
33
- while (1) switch (_context.prev = _context.next) {
34
- case 0:
35
- return _context.abrupt("return", openEmbedModalWithFlexibleUiIcon({
36
- download: downloadUrl,
37
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey,
38
- title: title,
39
- providerName: providerName,
40
- isSupportTheming: isSupportTheming,
41
- analytics: analytics,
42
- linkIcon: linkIcon,
43
- src: src,
44
- url: url
45
- }));
46
- case 1:
47
- case "end":
48
- return _context.stop();
49
- }
50
- }, _callee);
51
- }));
52
- return function actionFn() {
53
- return _ref.apply(this, arguments);
54
- };
55
- }();
56
- var action = _objectSpread(_objectSpread({}, props), {}, {
57
- onClick: function onClick() {
58
- invoke({
59
- actionType: ActionName.PreviewAction,
60
- actionFn: actionFn,
61
- // These values have already been set in analytics context.
62
- // We only pass these here for ufo experience.
63
- display: analytics === null || analytics === void 0 ? void 0 : analytics.display,
64
- extensionKey: analytics === null || analytics === void 0 ? void 0 : analytics.extensionKey
65
- });
66
- if (_onClick) {
67
- _onClick();
68
- }
69
- }
70
- });
71
- return /*#__PURE__*/React.createElement(Action, _extends({}, action, {
72
- appearance: appearance,
73
- asDropDownItem: asDropDownItem,
74
- testId: testId
75
- }));
76
- } else {
77
- return null;
78
- }
79
- };
80
- export default PreviewAction;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { PreviewActionProps } from './types';
3
- declare const PreviewAction: React.FC<PreviewActionProps>;
4
- export default PreviewAction;
@@ -1,12 +0,0 @@
1
- import { Icon } from '../../../../../../state/flexible-ui-context/types';
2
- import { ActionProps } from '../types';
3
- export type PreviewActionProps = ActionProps & FlexibleEmbedProps;
4
- export type FlexibleEmbedProps = {
5
- downloadUrl?: string;
6
- linkIcon?: Icon;
7
- providerName?: string;
8
- src?: string;
9
- title?: string;
10
- url: string;
11
- isSupportTheming?: boolean;
12
- };
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { PreviewActionProps } from './types';
3
- declare const PreviewAction: React.FC<PreviewActionProps>;
4
- export default PreviewAction;
@@ -1,12 +0,0 @@
1
- import { Icon } from '../../../../../../state/flexible-ui-context/types';
2
- import { ActionProps } from '../types';
3
- export type PreviewActionProps = ActionProps & FlexibleEmbedProps;
4
- export type FlexibleEmbedProps = {
5
- downloadUrl?: string;
6
- linkIcon?: Icon;
7
- providerName?: string;
8
- src?: string;
9
- title?: string;
10
- url: string;
11
- isSupportTheming?: boolean;
12
- };