@atlaskit/smart-card 23.1.2 → 23.1.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/extractors/common/actions/extractPreviewAction.js +0 -2
  3. package/dist/cjs/state/hooks-external/useSmartLinkActions.js +2 -12
  4. package/dist/cjs/version.json +1 -1
  5. package/dist/cjs/view/BlockCard/actions/PreviewAction.js +1 -5
  6. package/dist/cjs/view/BlockCard/index.js +0 -10
  7. package/dist/cjs/view/EmbedModal/index.js +2 -4
  8. package/dist/es2019/extractors/common/actions/extractPreviewAction.js +0 -2
  9. package/dist/es2019/state/hooks-external/useSmartLinkActions.js +2 -11
  10. package/dist/es2019/version.json +1 -1
  11. package/dist/es2019/view/BlockCard/actions/PreviewAction.js +0 -4
  12. package/dist/es2019/view/BlockCard/index.js +0 -9
  13. package/dist/es2019/view/EmbedModal/index.js +2 -3
  14. package/dist/esm/extractors/common/actions/extractPreviewAction.js +0 -2
  15. package/dist/esm/state/hooks-external/useSmartLinkActions.js +2 -11
  16. package/dist/esm/version.json +1 -1
  17. package/dist/esm/view/BlockCard/actions/PreviewAction.js +1 -5
  18. package/dist/esm/view/BlockCard/index.js +0 -9
  19. package/dist/esm/view/EmbedModal/index.js +2 -3
  20. package/dist/types/extractors/block/types.d.ts +0 -2
  21. package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +1 -1
  22. package/dist/types/view/BlockCard/actions/PreviewAction.d.ts +0 -2
  23. package/dist/types/view/Card/index.d.ts +1 -1
  24. package/dist/types/view/EmbedModal/index.d.ts +1 -3
  25. package/dist/types/view/EmbedModal/types.d.ts +1 -4
  26. package/dist/types-ts4.0/extractors/block/types.d.ts +0 -2
  27. package/dist/types-ts4.0/extractors/common/actions/extractPreviewAction.d.ts +1 -1
  28. package/dist/types-ts4.0/view/BlockCard/actions/PreviewAction.d.ts +0 -2
  29. package/dist/types-ts4.0/view/Card/index.d.ts +1 -1
  30. package/dist/types-ts4.0/view/EmbedModal/index.d.ts +1 -3
  31. package/dist/types-ts4.0/view/EmbedModal/types.d.ts +1 -4
  32. package/package.json +1 -1
  33. package/dist/cjs/view/EmbedModal/components/size-experiment/index.js +0 -36
  34. package/dist/cjs/view/EmbedModal/components/size-experiment/types.js +0 -5
  35. package/dist/cjs/view/common/Modal.js +0 -158
  36. package/dist/cjs/view/common/ModalHeader.js +0 -114
  37. package/dist/es2019/view/EmbedModal/components/size-experiment/index.js +0 -24
  38. package/dist/es2019/view/EmbedModal/components/size-experiment/types.js +0 -1
  39. package/dist/es2019/view/common/Modal.js +0 -115
  40. package/dist/es2019/view/common/ModalHeader.js +0 -88
  41. package/dist/esm/view/EmbedModal/components/size-experiment/index.js +0 -23
  42. package/dist/esm/view/EmbedModal/components/size-experiment/types.js +0 -1
  43. package/dist/esm/view/common/Modal.js +0 -148
  44. package/dist/esm/view/common/ModalHeader.js +0 -89
  45. package/dist/types/view/EmbedModal/components/size-experiment/index.d.ts +0 -7
  46. package/dist/types/view/EmbedModal/components/size-experiment/types.d.ts +0 -4
  47. package/dist/types/view/common/Modal.d.ts +0 -26
  48. package/dist/types/view/common/ModalHeader.d.ts +0 -19
  49. package/dist/types-ts4.0/view/EmbedModal/components/size-experiment/index.d.ts +0 -7
  50. package/dist/types-ts4.0/view/EmbedModal/components/size-experiment/types.d.ts +0 -4
  51. package/dist/types-ts4.0/view/common/Modal.d.ts +0 -26
  52. package/dist/types-ts4.0/view/common/ModalHeader.d.ts +0 -19
@@ -1,158 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.default = void 0;
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
24
- var _react = _interopRequireWildcard(require("react"));
25
-
26
- var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
27
-
28
- var _ModalHeader = require("./ModalHeader");
29
-
30
- var _utils = require("../../utils");
31
-
32
- var _analytics = _interopRequireDefault(require("../EmbedModal/components/analytics"));
33
-
34
- var _types = require("../EmbedModal/types");
35
-
36
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
-
38
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
-
40
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
41
-
42
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
43
-
44
- var iframeStyles = {
45
- width: "100%",
46
- height: 'calc(100vh - 248px)'
47
- };
48
-
49
- var ModalWithErrorBoundary = /*#__PURE__*/function (_React$Component) {
50
- (0, _inherits2.default)(ModalWithErrorBoundary, _React$Component);
51
-
52
- var _super = _createSuper(ModalWithErrorBoundary);
53
-
54
- function ModalWithErrorBoundary() {
55
- (0, _classCallCheck2.default)(this, ModalWithErrorBoundary);
56
- return _super.apply(this, arguments);
57
- }
58
-
59
- (0, _createClass2.default)(ModalWithErrorBoundary, [{
60
- key: "componentDidCatch",
61
- value: function componentDidCatch(error, errorInfo) {
62
- if (this.props.onOpenFailed) {
63
- this.props.onOpenFailed(error, errorInfo);
64
- }
65
- }
66
- }, {
67
- key: "render",
68
- value: function render() {
69
- return /*#__PURE__*/_react.default.createElement(Modal, this.props);
70
- }
71
- }]);
72
- return ModalWithErrorBoundary;
73
- }(_react.default.Component);
74
-
75
- var Modal = function Modal(_ref) {
76
- var onClose = _ref.onClose,
77
- onOpen = _ref.onOpen,
78
- src = _ref.src,
79
- _ref$testId = _ref.testId,
80
- testId = _ref$testId === void 0 ? 'smart-links-preview-modal' : _ref$testId,
81
- showModal = _ref.showModal,
82
- providerName = _ref.providerName,
83
- metadata = _ref.metadata,
84
- icon = _ref.icon,
85
- _ref$closeLabel = _ref.closeLabel,
86
- closeLabel = _ref$closeLabel === void 0 ? 'Close Preview' : _ref$closeLabel,
87
- iframeName = _ref.iframeName,
88
- title = _ref.title,
89
- url = _ref.url,
90
- download = _ref.download,
91
- byline = _ref.byline,
92
- _ref$isTrusted = _ref.isTrusted,
93
- isTrusted = _ref$isTrusted === void 0 ? false : _ref$isTrusted,
94
- onViewActionClick = _ref.onViewActionClick,
95
- onDownloadActionClick = _ref.onDownloadActionClick;
96
-
97
- var _useState = (0, _react.useState)(showModal),
98
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
99
- isOpen = _useState2[0],
100
- setIsOpen = _useState2[1];
101
-
102
- var openAt = (0, _react.useRef)();
103
- var handleOnOpenComplete = (0, _react.useCallback)(function () {
104
- openAt.current = Date.now();
105
-
106
- if (onOpen) {
107
- onOpen({
108
- size: _types.EmbedModalSize.Small
109
- });
110
- }
111
- }, [onOpen]);
112
- var handleOnCloseComplete = (0, _react.useCallback)(function () {
113
- if (onClose) {
114
- var duration = openAt.current ? Date.now() - openAt.current : undefined;
115
- onClose({
116
- duration: duration,
117
- size: _types.EmbedModalSize.Small
118
- });
119
- }
120
- }, [onClose]);
121
- var sandbox = (0, _utils.getIframeSandboxAttribute)(isTrusted);
122
- return /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTransition, null, isOpen && /*#__PURE__*/_react.default.createElement(_modalDialog.default, {
123
- height: "100%",
124
- width: "large",
125
- testId: testId,
126
- onOpenComplete: handleOnOpenComplete,
127
- onClose: function onClose() {
128
- setIsOpen(false);
129
- },
130
- onCloseComplete: handleOnCloseComplete
131
- }, /*#__PURE__*/_react.default.createElement(_ModalHeader.Header, {
132
- providerName: providerName,
133
- icon: icon,
134
- metadata: metadata,
135
- url: url,
136
- title: title,
137
- label: closeLabel,
138
- download: download,
139
- byline: byline,
140
- onViewActionClick: onViewActionClick,
141
- onDownloadActionClick: onDownloadActionClick
142
- }), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, src ? /*#__PURE__*/_react.default.createElement("iframe", {
143
- style: iframeStyles,
144
- name: iframeName,
145
- frameBorder: 0,
146
- src: src,
147
- sandbox: sandbox
148
- }) : /*#__PURE__*/_react.default.createElement("iframe", {
149
- style: iframeStyles,
150
- name: iframeName,
151
- frameBorder: 0,
152
- sandbox: sandbox
153
- }))));
154
- };
155
-
156
- var _default = (0, _analytics.default)(ModalWithErrorBoundary);
157
-
158
- exports.default = _default;
@@ -1,114 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.Header = void 0;
9
-
10
- var _react = require("@emotion/react");
11
-
12
- var _react2 = require("react");
13
-
14
- var _modalDialog = require("@atlaskit/modal-dialog");
15
-
16
- var _close = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/close"));
17
-
18
- var _shortcut = _interopRequireDefault(require("@atlaskit/icon/glyph/shortcut"));
19
-
20
- var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
21
-
22
- var _colors = require("@atlaskit/theme/colors");
23
-
24
- var _tokens = require("@atlaskit/tokens");
25
-
26
- var _reactIntlNext = require("react-intl-next");
27
-
28
- var _utils = require("./utils");
29
-
30
- var _Icon = require("./Icon");
31
-
32
- var _MetadataList = require("./MetadataList");
33
-
34
- var _Byline = require("./Byline");
35
-
36
- var _messages = require("../../messages");
37
-
38
- /** @jsx jsx */
39
- var Header = function Header(_ref) {
40
- var title = _ref.title,
41
- label = _ref.label,
42
- _ref$metadata = _ref.metadata,
43
- metadata = _ref$metadata === void 0 ? {
44
- items: []
45
- } : _ref$metadata,
46
- icon = _ref.icon,
47
- providerName = _ref.providerName,
48
- url = _ref.url,
49
- download = _ref.download,
50
- byline = _ref.byline,
51
- onViewActionClick = _ref.onViewActionClick,
52
- onDownloadActionClick = _ref.onDownloadActionClick;
53
-
54
- var _useModal = (0, _modalDialog.useModal)(),
55
- onClose = _useModal.onClose;
56
-
57
- return (0, _react.jsx)("div", {
58
- style: {
59
- paddingLeft: (0, _utils.gs)(3),
60
- paddingRight: (0, _utils.gs)(3),
61
- paddingBottom: (0, _utils.gs)(2),
62
- paddingTop: (0, _utils.gs)(2)
63
- }
64
- }, (0, _react.jsx)("div", {
65
- style: {
66
- display: 'flex',
67
- justifyContent: 'space-between',
68
- alignItems: 'baseline',
69
- borderBottom: "1px solid ".concat((0, _tokens.token)('color.border', _colors.N30A))
70
- }
71
- }, (0, _react.jsx)("div", {
72
- css: {
73
- flex: 1
74
- }
75
- }, (0, _react.jsx)("div", {
76
- css: {
77
- display: 'flex'
78
- }
79
- }, icon && (0, _react.jsx)(_Icon.Icon, icon), (0, _react.jsx)("div", {
80
- css: {
81
- paddingLeft: (0, _utils.gs)(2),
82
- paddingBottom: (0, _utils.gs)(2)
83
- }
84
- }, (0, _react.jsx)("h3", null, title), (0, _react.jsx)("div", {
85
- css: {
86
- color: (0, _tokens.token)('color.text.subtlest', _colors.N100)
87
- }
88
- }, metadata.items.length && (0, _react.jsx)(_MetadataList.MetadataList, {
89
- items: metadata.items
90
- }) || (0, _react.jsx)(_Byline.Byline, null, byline))))), (0, _react.jsx)("div", null, download && (0, _react.jsx)(_customThemeButton.default, {
91
- appearance: "primary",
92
- href: download,
93
- onClick: onDownloadActionClick
94
- }, (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.download)), url && (0, _react.jsx)(_customThemeButton.default, {
95
- href: url,
96
- target: "_blank",
97
- appearance: "link",
98
- testId: "preview-view-action",
99
- iconAfter: (0, _react.jsx)(_shortcut.default, {
100
- size: "small",
101
- label: ""
102
- }),
103
- onClick: onViewActionClick
104
- }, providerName ? (0, _react.jsx)(_react2.Fragment, null, (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.viewIn), " ", providerName) : (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.viewOriginal)), (0, _react.jsx)(_customThemeButton.default, {
105
- appearance: "subtle",
106
- iconBefore: (0, _react.jsx)(_close.default, {
107
- label: label
108
- }),
109
- onClick: onClose,
110
- testId: "preview-close-button"
111
- }))));
112
- };
113
-
114
- exports.Header = Header;
@@ -1,24 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import Modal from '../../../common/Modal';
4
- import { EmbedModalSize } from '../../types';
5
-
6
- const withSizeExperiment = Component => props => {
7
- const {
8
- featureFlags = {}
9
- } = props;
10
- const {
11
- embedModalSize: size
12
- } = featureFlags; // Experiment
13
-
14
- if (size === EmbedModalSize.Large || size === EmbedModalSize.Small) {
15
- return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
16
- size: size
17
- }));
18
- } // Control
19
-
20
-
21
- return /*#__PURE__*/React.createElement(Modal, props);
22
- };
23
-
24
- export default withSizeExperiment;
@@ -1,115 +0,0 @@
1
- /* TODO: (from codemod)
2
- We have converted this file as best we could but you might still need
3
- to manually complete migrating this usage of ModalDialog.
4
-
5
- This file uses one or more of the following ModalDialog props: 'components', 'header',
6
- 'footer', 'body'. These props have been removed as part of moving to
7
- a compositional API.
8
-
9
- The render props that used to be exposed by the custom component APIs are
10
- now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
11
-
12
- We are also no longer exposing 'appearance' as render prop, so this needs to be
13
- manually passed to your custom components.
14
-
15
- For a complete guide on customization using the new compositional API, refer to the docs at
16
- https://atlassian.design/components/modal-dialog/examples#customizing-modal-dialog. */
17
- import React, { useCallback, useRef, useState } from 'react';
18
- import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
19
- import { Header } from './ModalHeader';
20
- import { getIframeSandboxAttribute } from '../../utils';
21
- import withAnalytics from '../EmbedModal/components/analytics';
22
- import { EmbedModalSize } from '../EmbedModal/types';
23
- const iframeStyles = {
24
- width: `100%`,
25
- height: 'calc(100vh - 248px)'
26
- };
27
-
28
- class ModalWithErrorBoundary extends React.Component {
29
- componentDidCatch(error, errorInfo) {
30
- if (this.props.onOpenFailed) {
31
- this.props.onOpenFailed(error, errorInfo);
32
- }
33
- }
34
-
35
- render() {
36
- return /*#__PURE__*/React.createElement(Modal, this.props);
37
- }
38
-
39
- }
40
-
41
- const Modal = ({
42
- onClose,
43
- onOpen,
44
- src,
45
- testId = 'smart-links-preview-modal',
46
- showModal,
47
- providerName,
48
- metadata,
49
- icon,
50
- closeLabel = 'Close Preview',
51
- iframeName,
52
- title,
53
- url,
54
- download,
55
- byline,
56
- isTrusted = false,
57
- onViewActionClick,
58
- onDownloadActionClick
59
- }) => {
60
- let [isOpen, setIsOpen] = useState(showModal);
61
- const openAt = useRef();
62
- const handleOnOpenComplete = useCallback(() => {
63
- openAt.current = Date.now();
64
-
65
- if (onOpen) {
66
- onOpen({
67
- size: EmbedModalSize.Small
68
- });
69
- }
70
- }, [onOpen]);
71
- const handleOnCloseComplete = useCallback(() => {
72
- if (onClose) {
73
- const duration = openAt.current ? Date.now() - openAt.current : undefined;
74
- onClose({
75
- duration,
76
- size: EmbedModalSize.Small
77
- });
78
- }
79
- }, [onClose]);
80
- const sandbox = getIframeSandboxAttribute(isTrusted);
81
- return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
82
- height: "100%",
83
- width: "large",
84
- testId: testId,
85
- onOpenComplete: handleOnOpenComplete,
86
- onClose: () => {
87
- setIsOpen(false);
88
- },
89
- onCloseComplete: handleOnCloseComplete
90
- }, /*#__PURE__*/React.createElement(Header, {
91
- providerName: providerName,
92
- icon: icon,
93
- metadata: metadata,
94
- url: url,
95
- title: title,
96
- label: closeLabel,
97
- download: download,
98
- byline: byline,
99
- onViewActionClick: onViewActionClick,
100
- onDownloadActionClick: onDownloadActionClick
101
- }), /*#__PURE__*/React.createElement(ModalBody, null, src ? /*#__PURE__*/React.createElement("iframe", {
102
- style: iframeStyles,
103
- name: iframeName,
104
- frameBorder: 0,
105
- src: src,
106
- sandbox: sandbox
107
- }) : /*#__PURE__*/React.createElement("iframe", {
108
- style: iframeStyles,
109
- name: iframeName,
110
- frameBorder: 0,
111
- sandbox: sandbox
112
- }))));
113
- };
114
-
115
- export default withAnalytics(ModalWithErrorBoundary);
@@ -1,88 +0,0 @@
1
- /** @jsx jsx */
2
- import { jsx } from '@emotion/react';
3
- import { Fragment as F } from 'react';
4
- import { useModal } from '@atlaskit/modal-dialog';
5
- import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
6
- import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
7
- import Button from '@atlaskit/button/custom-theme-button';
8
- import { N100, N30A } from '@atlaskit/theme/colors';
9
- import { token } from '@atlaskit/tokens';
10
- import { FormattedMessage } from 'react-intl-next';
11
- import { gs } from './utils';
12
- import { Icon } from './Icon';
13
- import { MetadataList } from './MetadataList';
14
- import { Byline } from './Byline';
15
- import { messages } from '../../messages';
16
- export const Header = ({
17
- title,
18
- label,
19
- metadata = {
20
- items: []
21
- },
22
- icon,
23
- providerName,
24
- url,
25
- download,
26
- byline,
27
- onViewActionClick,
28
- onDownloadActionClick
29
- }) => {
30
- const {
31
- onClose
32
- } = useModal();
33
- return jsx("div", {
34
- style: {
35
- paddingLeft: gs(3),
36
- paddingRight: gs(3),
37
- paddingBottom: gs(2),
38
- paddingTop: gs(2)
39
- }
40
- }, jsx("div", {
41
- style: {
42
- display: 'flex',
43
- justifyContent: 'space-between',
44
- alignItems: 'baseline',
45
- borderBottom: `1px solid ${token('color.border', N30A)}`
46
- }
47
- }, jsx("div", {
48
- css: {
49
- flex: 1
50
- }
51
- }, jsx("div", {
52
- css: {
53
- display: 'flex'
54
- }
55
- }, icon && jsx(Icon, icon), jsx("div", {
56
- css: {
57
- paddingLeft: gs(2),
58
- paddingBottom: gs(2)
59
- }
60
- }, jsx("h3", null, title), jsx("div", {
61
- css: {
62
- color: token('color.text.subtlest', N100)
63
- }
64
- }, metadata.items.length && jsx(MetadataList, {
65
- items: metadata.items
66
- }) || jsx(Byline, null, byline))))), jsx("div", null, download && jsx(Button, {
67
- appearance: "primary",
68
- href: download,
69
- onClick: onDownloadActionClick
70
- }, jsx(FormattedMessage, messages.download)), url && jsx(Button, {
71
- href: url,
72
- target: "_blank",
73
- appearance: "link",
74
- testId: "preview-view-action",
75
- iconAfter: jsx(ShortcutIcon, {
76
- size: "small",
77
- label: ""
78
- }),
79
- onClick: onViewActionClick
80
- }, providerName ? jsx(F, null, jsx(FormattedMessage, messages.viewIn), " ", providerName) : jsx(FormattedMessage, messages.viewOriginal)), jsx(Button, {
81
- appearance: "subtle",
82
- iconBefore: jsx(EditorCloseIcon, {
83
- label: label
84
- }),
85
- onClick: onClose,
86
- testId: "preview-close-button"
87
- }))));
88
- };
@@ -1,23 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React from 'react';
3
- import Modal from '../../../common/Modal';
4
- import { EmbedModalSize } from '../../types';
5
-
6
- var withSizeExperiment = function withSizeExperiment(Component) {
7
- return function (props) {
8
- var _props$featureFlags = props.featureFlags,
9
- featureFlags = _props$featureFlags === void 0 ? {} : _props$featureFlags;
10
- var size = featureFlags.embedModalSize; // Experiment
11
-
12
- if (size === EmbedModalSize.Large || size === EmbedModalSize.Small) {
13
- return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
14
- size: size
15
- }));
16
- } // Control
17
-
18
-
19
- return /*#__PURE__*/React.createElement(Modal, props);
20
- };
21
- };
22
-
23
- export default withSizeExperiment;
@@ -1,148 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
-
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
-
10
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
-
12
- /* TODO: (from codemod)
13
- We have converted this file as best we could but you might still need
14
- to manually complete migrating this usage of ModalDialog.
15
-
16
- This file uses one or more of the following ModalDialog props: 'components', 'header',
17
- 'footer', 'body'. These props have been removed as part of moving to
18
- a compositional API.
19
-
20
- The render props that used to be exposed by the custom component APIs are
21
- now accessible using the 'useModal' hook instead: 'testId', 'titleId', and 'onClose'.
22
-
23
- We are also no longer exposing 'appearance' as render prop, so this needs to be
24
- manually passed to your custom components.
25
-
26
- For a complete guide on customization using the new compositional API, refer to the docs at
27
- https://atlassian.design/components/modal-dialog/examples#customizing-modal-dialog. */
28
- import React, { useCallback, useRef, useState } from 'react';
29
- import ModalDialog, { ModalBody, ModalTransition } from '@atlaskit/modal-dialog';
30
- import { Header } from './ModalHeader';
31
- import { getIframeSandboxAttribute } from '../../utils';
32
- import withAnalytics from '../EmbedModal/components/analytics';
33
- import { EmbedModalSize } from '../EmbedModal/types';
34
- var iframeStyles = {
35
- width: "100%",
36
- height: 'calc(100vh - 248px)'
37
- };
38
-
39
- var ModalWithErrorBoundary = /*#__PURE__*/function (_React$Component) {
40
- _inherits(ModalWithErrorBoundary, _React$Component);
41
-
42
- var _super = _createSuper(ModalWithErrorBoundary);
43
-
44
- function ModalWithErrorBoundary() {
45
- _classCallCheck(this, ModalWithErrorBoundary);
46
-
47
- return _super.apply(this, arguments);
48
- }
49
-
50
- _createClass(ModalWithErrorBoundary, [{
51
- key: "componentDidCatch",
52
- value: function componentDidCatch(error, errorInfo) {
53
- if (this.props.onOpenFailed) {
54
- this.props.onOpenFailed(error, errorInfo);
55
- }
56
- }
57
- }, {
58
- key: "render",
59
- value: function render() {
60
- return /*#__PURE__*/React.createElement(Modal, this.props);
61
- }
62
- }]);
63
-
64
- return ModalWithErrorBoundary;
65
- }(React.Component);
66
-
67
- var Modal = function Modal(_ref) {
68
- var onClose = _ref.onClose,
69
- onOpen = _ref.onOpen,
70
- src = _ref.src,
71
- _ref$testId = _ref.testId,
72
- testId = _ref$testId === void 0 ? 'smart-links-preview-modal' : _ref$testId,
73
- showModal = _ref.showModal,
74
- providerName = _ref.providerName,
75
- metadata = _ref.metadata,
76
- icon = _ref.icon,
77
- _ref$closeLabel = _ref.closeLabel,
78
- closeLabel = _ref$closeLabel === void 0 ? 'Close Preview' : _ref$closeLabel,
79
- iframeName = _ref.iframeName,
80
- title = _ref.title,
81
- url = _ref.url,
82
- download = _ref.download,
83
- byline = _ref.byline,
84
- _ref$isTrusted = _ref.isTrusted,
85
- isTrusted = _ref$isTrusted === void 0 ? false : _ref$isTrusted,
86
- onViewActionClick = _ref.onViewActionClick,
87
- onDownloadActionClick = _ref.onDownloadActionClick;
88
-
89
- var _useState = useState(showModal),
90
- _useState2 = _slicedToArray(_useState, 2),
91
- isOpen = _useState2[0],
92
- setIsOpen = _useState2[1];
93
-
94
- var openAt = useRef();
95
- var handleOnOpenComplete = useCallback(function () {
96
- openAt.current = Date.now();
97
-
98
- if (onOpen) {
99
- onOpen({
100
- size: EmbedModalSize.Small
101
- });
102
- }
103
- }, [onOpen]);
104
- var handleOnCloseComplete = useCallback(function () {
105
- if (onClose) {
106
- var duration = openAt.current ? Date.now() - openAt.current : undefined;
107
- onClose({
108
- duration: duration,
109
- size: EmbedModalSize.Small
110
- });
111
- }
112
- }, [onClose]);
113
- var sandbox = getIframeSandboxAttribute(isTrusted);
114
- return /*#__PURE__*/React.createElement(ModalTransition, null, isOpen && /*#__PURE__*/React.createElement(ModalDialog, {
115
- height: "100%",
116
- width: "large",
117
- testId: testId,
118
- onOpenComplete: handleOnOpenComplete,
119
- onClose: function onClose() {
120
- setIsOpen(false);
121
- },
122
- onCloseComplete: handleOnCloseComplete
123
- }, /*#__PURE__*/React.createElement(Header, {
124
- providerName: providerName,
125
- icon: icon,
126
- metadata: metadata,
127
- url: url,
128
- title: title,
129
- label: closeLabel,
130
- download: download,
131
- byline: byline,
132
- onViewActionClick: onViewActionClick,
133
- onDownloadActionClick: onDownloadActionClick
134
- }), /*#__PURE__*/React.createElement(ModalBody, null, src ? /*#__PURE__*/React.createElement("iframe", {
135
- style: iframeStyles,
136
- name: iframeName,
137
- frameBorder: 0,
138
- src: src,
139
- sandbox: sandbox
140
- }) : /*#__PURE__*/React.createElement("iframe", {
141
- style: iframeStyles,
142
- name: iframeName,
143
- frameBorder: 0,
144
- sandbox: sandbox
145
- }))));
146
- };
147
-
148
- export default withAnalytics(ModalWithErrorBoundary);