@atlaskit/smart-card 27.2.0 → 27.2.2
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 +17 -0
- package/dist/cjs/state/modal/index.js +69 -0
- package/dist/cjs/state/modal/types.js +5 -0
- package/dist/cjs/utils/analytics/analytics.js +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +3 -2
- package/dist/cjs/view/HoverCard/index.js +2 -1
- package/dist/cjs/view/LinkUrl/index.js +1 -1
- package/dist/cjs/view/RelatedLinksModal/components/RelatedLinksBaseModal.js +10 -2
- package/dist/es2019/state/modal/index.js +47 -0
- package/dist/es2019/state/modal/types.js +1 -0
- package/dist/es2019/utils/analytics/analytics.js +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +3 -2
- package/dist/es2019/view/HoverCard/index.js +2 -1
- package/dist/es2019/view/LinkUrl/index.js +1 -1
- package/dist/es2019/view/RelatedLinksModal/components/RelatedLinksBaseModal.js +10 -2
- package/dist/esm/state/modal/index.js +59 -0
- package/dist/esm/state/modal/types.js +1 -0
- package/dist/esm/utils/analytics/analytics.js +1 -1
- package/dist/esm/view/CardWithUrl/component.js +3 -2
- package/dist/esm/view/HoverCard/index.js +2 -1
- package/dist/esm/view/LinkUrl/index.js +1 -1
- package/dist/esm/view/RelatedLinksModal/components/RelatedLinksBaseModal.js +10 -2
- package/dist/types/state/modal/index.d.ts +19 -0
- package/dist/types/state/modal/types.d.ts +16 -0
- package/dist/types-ts4.5/state/modal/index.d.ts +19 -0
- package/dist/types-ts4.5/state/modal/types.d.ts +16 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 27.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#103697](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103697)
|
|
8
|
+
[`9b1bedee923a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9b1bedee923a) -
|
|
9
|
+
[ux] Added fixed width and min height to related links modal
|
|
10
|
+
|
|
11
|
+
## 27.2.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#103165](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103165)
|
|
16
|
+
[`ea89f19613e2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ea89f19613e2) -
|
|
17
|
+
Create modal context to fix issue where action modal triggered from hover card disappears when
|
|
18
|
+
hover card disappears
|
|
19
|
+
|
|
3
20
|
## 27.2.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useSmartLinkModal = exports.SmartLinkModalProvider = exports.SmartLinkModalContext = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _reactErrorBoundary = require("react-error-boundary");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
var FALLBACK_API = {
|
|
15
|
+
open: function open() {},
|
|
16
|
+
close: function close() {}
|
|
17
|
+
};
|
|
18
|
+
var SmartLinkModalContext = exports.SmartLinkModalContext = /*#__PURE__*/_react.default.createContext(FALLBACK_API);
|
|
19
|
+
var SmartLinkModalProvider = exports.SmartLinkModalProvider = function SmartLinkModalProvider(_ref) {
|
|
20
|
+
var children = _ref.children;
|
|
21
|
+
var _useState = (0, _react.useState)(null),
|
|
22
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
23
|
+
element = _useState2[0],
|
|
24
|
+
setElement = _useState2[1];
|
|
25
|
+
var api = (0, _react.useMemo)(function () {
|
|
26
|
+
return {
|
|
27
|
+
open: function open(modal) {
|
|
28
|
+
return setElement( /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
29
|
+
fallback: null
|
|
30
|
+
}, modal));
|
|
31
|
+
},
|
|
32
|
+
close: function close() {
|
|
33
|
+
return setElement(null);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
var fallbackRender = (0, _react.useCallback)(function (_ref2) {
|
|
38
|
+
var resetErrorBoundary = _ref2.resetErrorBoundary;
|
|
39
|
+
resetErrorBoundary();
|
|
40
|
+
return null;
|
|
41
|
+
}, []);
|
|
42
|
+
var onReset = (0, _react.useCallback)(function () {
|
|
43
|
+
return setElement(null);
|
|
44
|
+
}, []);
|
|
45
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(SmartLinkModalContext.Provider, {
|
|
46
|
+
value: api
|
|
47
|
+
}, children), /*#__PURE__*/_react.default.createElement(_reactErrorBoundary.ErrorBoundary, {
|
|
48
|
+
fallbackRender: fallbackRender,
|
|
49
|
+
onReset: onReset
|
|
50
|
+
}, element));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Open (lazy load) modal
|
|
55
|
+
*
|
|
56
|
+
* This hook injects the element below Card and standalone HoverCard component.
|
|
57
|
+
* It is intended to solve the issue where modal triggered by the parent component
|
|
58
|
+
* disappear when the parent component is unmounted.
|
|
59
|
+
*
|
|
60
|
+
* For example, clicking on hover card action to open a modal. Once the modal is opened,
|
|
61
|
+
* hover card disappears.
|
|
62
|
+
*
|
|
63
|
+
* Usage:
|
|
64
|
+
* const modal = useSmartLinkModal()
|
|
65
|
+
* modal.open(<SomeLazyLoadModal isOpen={true} onClose={() => modal.close()} />);
|
|
66
|
+
*/
|
|
67
|
+
var useSmartLinkModal = exports.useSmartLinkModal = function useSmartLinkModal() {
|
|
68
|
+
return (0, _react.useContext)(SmartLinkModalContext);
|
|
69
|
+
};
|
|
@@ -22,7 +22,7 @@ var ANALYTICS_CHANNEL = exports.ANALYTICS_CHANNEL = 'media';
|
|
|
22
22
|
var context = exports.context = {
|
|
23
23
|
componentName: 'smart-cards',
|
|
24
24
|
packageName: "@atlaskit/smart-card",
|
|
25
|
-
packageVersion: "27.2.
|
|
25
|
+
packageVersion: "27.2.2"
|
|
26
26
|
};
|
|
27
27
|
var TrackQuickActionType = exports.TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
28
28
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -9,6 +9,7 @@ exports.CardWithUrlContent = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
11
11
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
12
|
+
var _modal = require("../../state/modal");
|
|
12
13
|
var _utils = require("../../utils");
|
|
13
14
|
var measure = _interopRequireWildcard(require("../../utils/performance"));
|
|
14
15
|
var _helpers = require("../../state/helpers");
|
|
@@ -278,9 +279,9 @@ function Component(_ref) {
|
|
|
278
279
|
}
|
|
279
280
|
var CardWithUrlContent = exports.CardWithUrlContent = function CardWithUrlContent(props) {
|
|
280
281
|
var display = (0, _flexible.isFlexibleUiCard)(props.children) ? _constants.CardDisplay.Flexible : props.appearance;
|
|
281
|
-
return /*#__PURE__*/_react.default.createElement(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
|
|
282
|
+
return /*#__PURE__*/_react.default.createElement(_modal.SmartLinkModalProvider, null, /*#__PURE__*/_react.default.createElement(_SmartLinkAnalyticsContext.SmartLinkAnalyticsContext, {
|
|
282
283
|
url: props.url,
|
|
283
284
|
id: props.id,
|
|
284
285
|
display: display
|
|
285
|
-
}, /*#__PURE__*/_react.default.createElement(Component, props));
|
|
286
|
+
}, /*#__PURE__*/_react.default.createElement(Component, props)));
|
|
286
287
|
};
|
|
@@ -9,6 +9,7 @@ var _react = require("@emotion/react");
|
|
|
9
9
|
var _react2 = require("react");
|
|
10
10
|
var _reactErrorBoundary = require("react-error-boundary");
|
|
11
11
|
var _analytics = require("../../state/analytics");
|
|
12
|
+
var _modal = require("../../state/modal");
|
|
12
13
|
var _HoverCardComponent = require("./components/HoverCardComponent");
|
|
13
14
|
var _constants = require("../../constants");
|
|
14
15
|
var _reactMagneticDi = require("react-magnetic-di");
|
|
@@ -30,7 +31,7 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
|
|
|
30
31
|
return (0, _react.jsx)(_reactErrorBoundary.ErrorBoundary, {
|
|
31
32
|
fallback: children,
|
|
32
33
|
onError: onError
|
|
33
|
-
}, (0, _react.jsx)(_HoverCardComponent.HoverCardComponent, props, children));
|
|
34
|
+
}, (0, _react.jsx)(_modal.SmartLinkModalProvider, null, (0, _react.jsx)(_HoverCardComponent.HoverCardComponent, props, children)));
|
|
34
35
|
};
|
|
35
36
|
var HoverCardWithoutAnalyticsContext = (0, _analyticsNext.withAnalyticsEvents)()(HoverCardWithErrorBoundary);
|
|
36
37
|
|
|
@@ -17,7 +17,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
|
|
|
17
17
|
_excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
|
|
18
18
|
var PACKAGE_DATA = {
|
|
19
19
|
packageName: "@atlaskit/smart-card",
|
|
20
|
-
packageVersion: "27.2.
|
|
20
|
+
packageVersion: "27.2.2",
|
|
21
21
|
componentName: 'linkUrl'
|
|
22
22
|
};
|
|
23
23
|
var Link = (0, _click.withLinkClickedEvent)('a');
|
|
@@ -11,18 +11,26 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
11
11
|
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
12
12
|
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
13
13
|
var _messages = require("../../../messages");
|
|
14
|
+
var _primitives = require("@atlaskit/primitives");
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
17
|
/** @jsx jsx */
|
|
17
18
|
|
|
19
|
+
var fixedWidth = 'small'; // pre-defined 400px by Atlaskit
|
|
20
|
+
|
|
21
|
+
var boxStyles = (0, _primitives.xcss)({
|
|
22
|
+
height: '396px' // Specified by the designer as this will display 5 incoming links and 2 outgoing links
|
|
23
|
+
});
|
|
18
24
|
var RelatedLinksBaseModal = function RelatedLinksBaseModal(_ref) {
|
|
19
25
|
var onClose = _ref.onClose,
|
|
20
26
|
showModal = _ref.showModal,
|
|
21
27
|
children = _ref.children;
|
|
22
28
|
return (0, _react.jsx)(_modalDialog.ModalTransition, null, showModal && (0, _react.jsx)(_modalDialog.default, {
|
|
23
29
|
onClose: onClose,
|
|
24
|
-
width:
|
|
25
|
-
}, (0, _react.jsx)(_modalDialog.ModalHeader, null, (0, _react.jsx)(_modalDialog.ModalTitle, null, (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.related_links_modal_title))), (0, _react.jsx)(_modalDialog.ModalBody, null,
|
|
30
|
+
width: fixedWidth
|
|
31
|
+
}, (0, _react.jsx)(_modalDialog.ModalHeader, null, (0, _react.jsx)(_modalDialog.ModalTitle, null, (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.related_links_modal_title))), (0, _react.jsx)(_modalDialog.ModalBody, null, (0, _react.jsx)(_primitives.Box, {
|
|
32
|
+
xcss: boxStyles
|
|
33
|
+
}, children)), (0, _react.jsx)(_modalDialog.ModalFooter, null, (0, _react.jsx)(_new.default, {
|
|
26
34
|
appearance: "primary",
|
|
27
35
|
onClick: onClose
|
|
28
36
|
}, (0, _react.jsx)(_reactIntlNext.FormattedMessage, _messages.messages.close)))));
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { Suspense, useCallback, useContext, useMemo, useState } from 'react';
|
|
2
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
|
+
const FALLBACK_API = {
|
|
4
|
+
open: () => {},
|
|
5
|
+
close: () => {}
|
|
6
|
+
};
|
|
7
|
+
export const SmartLinkModalContext = /*#__PURE__*/React.createContext(FALLBACK_API);
|
|
8
|
+
export const SmartLinkModalProvider = ({
|
|
9
|
+
children
|
|
10
|
+
}) => {
|
|
11
|
+
const [element, setElement] = useState(null);
|
|
12
|
+
const api = useMemo(() => ({
|
|
13
|
+
open: modal => setElement( /*#__PURE__*/React.createElement(Suspense, {
|
|
14
|
+
fallback: null
|
|
15
|
+
}, modal)),
|
|
16
|
+
close: () => setElement(null)
|
|
17
|
+
}), []);
|
|
18
|
+
const fallbackRender = useCallback(({
|
|
19
|
+
resetErrorBoundary
|
|
20
|
+
}) => {
|
|
21
|
+
resetErrorBoundary();
|
|
22
|
+
return null;
|
|
23
|
+
}, []);
|
|
24
|
+
const onReset = useCallback(() => setElement(null), []);
|
|
25
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SmartLinkModalContext.Provider, {
|
|
26
|
+
value: api
|
|
27
|
+
}, children), /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
28
|
+
fallbackRender: fallbackRender,
|
|
29
|
+
onReset: onReset
|
|
30
|
+
}, element));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Open (lazy load) modal
|
|
35
|
+
*
|
|
36
|
+
* This hook injects the element below Card and standalone HoverCard component.
|
|
37
|
+
* It is intended to solve the issue where modal triggered by the parent component
|
|
38
|
+
* disappear when the parent component is unmounted.
|
|
39
|
+
*
|
|
40
|
+
* For example, clicking on hover card action to open a modal. Once the modal is opened,
|
|
41
|
+
* hover card disappears.
|
|
42
|
+
*
|
|
43
|
+
* Usage:
|
|
44
|
+
* const modal = useSmartLinkModal()
|
|
45
|
+
* modal.open(<SomeLazyLoadModal isOpen={true} onClose={() => modal.close()} />);
|
|
46
|
+
*/
|
|
47
|
+
export const useSmartLinkModal = () => useContext(SmartLinkModalContext);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,7 +4,7 @@ export const ANALYTICS_CHANNEL = 'media';
|
|
|
4
4
|
export const context = {
|
|
5
5
|
componentName: 'smart-cards',
|
|
6
6
|
packageName: "@atlaskit/smart-card",
|
|
7
|
-
packageVersion: "27.2.
|
|
7
|
+
packageVersion: "27.2.2"
|
|
8
8
|
};
|
|
9
9
|
export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
10
10
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
3
|
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
4
|
+
import { SmartLinkModalProvider } from '../../state/modal';
|
|
4
5
|
import { combineFrameStyle, isSpecialEvent } from '../../utils';
|
|
5
6
|
import * as measure from '../../utils/performance';
|
|
6
7
|
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct, getCanBeDatasource } from '../../state/helpers';
|
|
@@ -265,9 +266,9 @@ function Component({
|
|
|
265
266
|
}
|
|
266
267
|
export const CardWithUrlContent = props => {
|
|
267
268
|
const display = isFlexibleUiCard(props.children) ? CardDisplay.Flexible : props.appearance;
|
|
268
|
-
return /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
269
|
+
return /*#__PURE__*/React.createElement(SmartLinkModalProvider, null, /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
269
270
|
url: props.url,
|
|
270
271
|
id: props.id,
|
|
271
272
|
display: display
|
|
272
|
-
}, /*#__PURE__*/React.createElement(Component, props));
|
|
273
|
+
}, /*#__PURE__*/React.createElement(Component, props)));
|
|
273
274
|
};
|
|
@@ -4,6 +4,7 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
6
6
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
7
|
+
import { SmartLinkModalProvider } from '../../state/modal';
|
|
7
8
|
import { HoverCardComponent } from './components/HoverCardComponent';
|
|
8
9
|
import { CardDisplay } from '../../constants';
|
|
9
10
|
import { di } from 'react-magnetic-di';
|
|
@@ -25,7 +26,7 @@ const HoverCardWithErrorBoundary = props => {
|
|
|
25
26
|
return jsx(ErrorBoundary, {
|
|
26
27
|
fallback: children,
|
|
27
28
|
onError: onError
|
|
28
|
-
}, jsx(HoverCardComponent, props, children));
|
|
29
|
+
}, jsx(SmartLinkModalProvider, null, jsx(HoverCardComponent, props, children)));
|
|
29
30
|
};
|
|
30
31
|
const HoverCardWithoutAnalyticsContext = withAnalyticsEvents()(HoverCardWithErrorBoundary);
|
|
31
32
|
|
|
@@ -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: "27.2.
|
|
10
|
+
packageVersion: "27.2.2",
|
|
11
11
|
componentName: 'linkUrl'
|
|
12
12
|
};
|
|
13
13
|
const Link = withLinkClickedEvent('a');
|
|
@@ -5,6 +5,12 @@ import { FormattedMessage } from 'react-intl-next';
|
|
|
5
5
|
import Button from '@atlaskit/button/new';
|
|
6
6
|
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
7
7
|
import { messages } from '../../../messages';
|
|
8
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
9
|
+
const fixedWidth = 'small'; // pre-defined 400px by Atlaskit
|
|
10
|
+
|
|
11
|
+
const boxStyles = xcss({
|
|
12
|
+
height: '396px' // Specified by the designer as this will display 5 incoming links and 2 outgoing links
|
|
13
|
+
});
|
|
8
14
|
const RelatedLinksBaseModal = ({
|
|
9
15
|
onClose,
|
|
10
16
|
showModal,
|
|
@@ -12,8 +18,10 @@ const RelatedLinksBaseModal = ({
|
|
|
12
18
|
}) => {
|
|
13
19
|
return jsx(ModalTransition, null, showModal && jsx(Modal, {
|
|
14
20
|
onClose: onClose,
|
|
15
|
-
width:
|
|
16
|
-
}, jsx(ModalHeader, null, jsx(ModalTitle, null, jsx(FormattedMessage, messages.related_links_modal_title))), jsx(ModalBody, null,
|
|
21
|
+
width: fixedWidth
|
|
22
|
+
}, jsx(ModalHeader, null, jsx(ModalTitle, null, jsx(FormattedMessage, messages.related_links_modal_title))), jsx(ModalBody, null, jsx(Box, {
|
|
23
|
+
xcss: boxStyles
|
|
24
|
+
}, children)), jsx(ModalFooter, null, jsx(Button, {
|
|
17
25
|
appearance: "primary",
|
|
18
26
|
onClick: onClose
|
|
19
27
|
}, jsx(FormattedMessage, messages.close)))));
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { Suspense, useCallback, useContext, useMemo, useState } from 'react';
|
|
3
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
4
|
+
var FALLBACK_API = {
|
|
5
|
+
open: function open() {},
|
|
6
|
+
close: function close() {}
|
|
7
|
+
};
|
|
8
|
+
export var SmartLinkModalContext = /*#__PURE__*/React.createContext(FALLBACK_API);
|
|
9
|
+
export var SmartLinkModalProvider = function SmartLinkModalProvider(_ref) {
|
|
10
|
+
var children = _ref.children;
|
|
11
|
+
var _useState = useState(null),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
element = _useState2[0],
|
|
14
|
+
setElement = _useState2[1];
|
|
15
|
+
var api = useMemo(function () {
|
|
16
|
+
return {
|
|
17
|
+
open: function open(modal) {
|
|
18
|
+
return setElement( /*#__PURE__*/React.createElement(Suspense, {
|
|
19
|
+
fallback: null
|
|
20
|
+
}, modal));
|
|
21
|
+
},
|
|
22
|
+
close: function close() {
|
|
23
|
+
return setElement(null);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
var fallbackRender = useCallback(function (_ref2) {
|
|
28
|
+
var resetErrorBoundary = _ref2.resetErrorBoundary;
|
|
29
|
+
resetErrorBoundary();
|
|
30
|
+
return null;
|
|
31
|
+
}, []);
|
|
32
|
+
var onReset = useCallback(function () {
|
|
33
|
+
return setElement(null);
|
|
34
|
+
}, []);
|
|
35
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SmartLinkModalContext.Provider, {
|
|
36
|
+
value: api
|
|
37
|
+
}, children), /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
38
|
+
fallbackRender: fallbackRender,
|
|
39
|
+
onReset: onReset
|
|
40
|
+
}, element));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Open (lazy load) modal
|
|
45
|
+
*
|
|
46
|
+
* This hook injects the element below Card and standalone HoverCard component.
|
|
47
|
+
* It is intended to solve the issue where modal triggered by the parent component
|
|
48
|
+
* disappear when the parent component is unmounted.
|
|
49
|
+
*
|
|
50
|
+
* For example, clicking on hover card action to open a modal. Once the modal is opened,
|
|
51
|
+
* hover card disappears.
|
|
52
|
+
*
|
|
53
|
+
* Usage:
|
|
54
|
+
* const modal = useSmartLinkModal()
|
|
55
|
+
* modal.open(<SomeLazyLoadModal isOpen={true} onClose={() => modal.close()} />);
|
|
56
|
+
*/
|
|
57
|
+
export var useSmartLinkModal = function useSmartLinkModal() {
|
|
58
|
+
return useContext(SmartLinkModalContext);
|
|
59
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,7 +15,7 @@ export var ANALYTICS_CHANNEL = 'media';
|
|
|
15
15
|
export var context = {
|
|
16
16
|
componentName: 'smart-cards',
|
|
17
17
|
packageName: "@atlaskit/smart-card",
|
|
18
|
-
packageVersion: "27.2.
|
|
18
|
+
packageVersion: "27.2.2"
|
|
19
19
|
};
|
|
20
20
|
export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
|
|
21
21
|
TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useCallback, useMemo } from 'react';
|
|
2
2
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
3
3
|
import { useFeatureFlag } from '@atlaskit/link-provider';
|
|
4
|
+
import { SmartLinkModalProvider } from '../../state/modal';
|
|
4
5
|
import { combineFrameStyle, isSpecialEvent } from '../../utils';
|
|
5
6
|
import * as measure from '../../utils/performance';
|
|
6
7
|
import { getDefinitionId, getServices, isFinalState, getClickUrl, getResourceType, getExtensionKey, getSubproduct, getProduct, getCanBeDatasource } from '../../state/helpers';
|
|
@@ -268,9 +269,9 @@ function Component(_ref) {
|
|
|
268
269
|
}
|
|
269
270
|
export var CardWithUrlContent = function CardWithUrlContent(props) {
|
|
270
271
|
var display = isFlexibleUiCard(props.children) ? CardDisplay.Flexible : props.appearance;
|
|
271
|
-
return /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
272
|
+
return /*#__PURE__*/React.createElement(SmartLinkModalProvider, null, /*#__PURE__*/React.createElement(SmartLinkAnalyticsContext, {
|
|
272
273
|
url: props.url,
|
|
273
274
|
id: props.id,
|
|
274
275
|
display: display
|
|
275
|
-
}, /*#__PURE__*/React.createElement(Component, props));
|
|
276
|
+
}, /*#__PURE__*/React.createElement(Component, props)));
|
|
276
277
|
};
|
|
@@ -4,6 +4,7 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
6
6
|
import { useSmartLinkAnalytics } from '../../state/analytics';
|
|
7
|
+
import { SmartLinkModalProvider } from '../../state/modal';
|
|
7
8
|
import { HoverCardComponent } from './components/HoverCardComponent';
|
|
8
9
|
import { CardDisplay } from '../../constants';
|
|
9
10
|
import { di } from 'react-magnetic-di';
|
|
@@ -23,7 +24,7 @@ var HoverCardWithErrorBoundary = function HoverCardWithErrorBoundary(props) {
|
|
|
23
24
|
return jsx(ErrorBoundary, {
|
|
24
25
|
fallback: children,
|
|
25
26
|
onError: onError
|
|
26
|
-
}, jsx(HoverCardComponent, props, children));
|
|
27
|
+
}, jsx(SmartLinkModalProvider, null, jsx(HoverCardComponent, props, children)));
|
|
27
28
|
};
|
|
28
29
|
var HoverCardWithoutAnalyticsContext = withAnalyticsEvents()(HoverCardWithErrorBoundary);
|
|
29
30
|
|
|
@@ -10,7 +10,7 @@ import { useLinkWarningModal } from './LinkWarningModal/hooks/use-link-warning-m
|
|
|
10
10
|
import LinkWarningModal from './LinkWarningModal';
|
|
11
11
|
var PACKAGE_DATA = {
|
|
12
12
|
packageName: "@atlaskit/smart-card",
|
|
13
|
-
packageVersion: "27.2.
|
|
13
|
+
packageVersion: "27.2.2",
|
|
14
14
|
componentName: 'linkUrl'
|
|
15
15
|
};
|
|
16
16
|
var Link = withLinkClickedEvent('a');
|
|
@@ -5,14 +5,22 @@ import { FormattedMessage } from 'react-intl-next';
|
|
|
5
5
|
import Button from '@atlaskit/button/new';
|
|
6
6
|
import Modal, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
7
7
|
import { messages } from '../../../messages';
|
|
8
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
9
|
+
var fixedWidth = 'small'; // pre-defined 400px by Atlaskit
|
|
10
|
+
|
|
11
|
+
var boxStyles = xcss({
|
|
12
|
+
height: '396px' // Specified by the designer as this will display 5 incoming links and 2 outgoing links
|
|
13
|
+
});
|
|
8
14
|
var RelatedLinksBaseModal = function RelatedLinksBaseModal(_ref) {
|
|
9
15
|
var onClose = _ref.onClose,
|
|
10
16
|
showModal = _ref.showModal,
|
|
11
17
|
children = _ref.children;
|
|
12
18
|
return jsx(ModalTransition, null, showModal && jsx(Modal, {
|
|
13
19
|
onClose: onClose,
|
|
14
|
-
width:
|
|
15
|
-
}, jsx(ModalHeader, null, jsx(ModalTitle, null, jsx(FormattedMessage, messages.related_links_modal_title))), jsx(ModalBody, null,
|
|
20
|
+
width: fixedWidth
|
|
21
|
+
}, jsx(ModalHeader, null, jsx(ModalTitle, null, jsx(FormattedMessage, messages.related_links_modal_title))), jsx(ModalBody, null, jsx(Box, {
|
|
22
|
+
xcss: boxStyles
|
|
23
|
+
}, children)), jsx(ModalFooter, null, jsx(Button, {
|
|
16
24
|
appearance: "primary",
|
|
17
25
|
onClick: onClose
|
|
18
26
|
}, jsx(FormattedMessage, messages.close)))));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SmartLinkModalAPI, type SmartLinkModalProviderProps } from './types';
|
|
3
|
+
export declare const SmartLinkModalContext: React.Context<SmartLinkModalAPI>;
|
|
4
|
+
export declare const SmartLinkModalProvider: ({ children, }: SmartLinkModalProviderProps) => JSX.Element;
|
|
5
|
+
/**
|
|
6
|
+
* Open (lazy load) modal
|
|
7
|
+
*
|
|
8
|
+
* This hook injects the element below Card and standalone HoverCard component.
|
|
9
|
+
* It is intended to solve the issue where modal triggered by the parent component
|
|
10
|
+
* disappear when the parent component is unmounted.
|
|
11
|
+
*
|
|
12
|
+
* For example, clicking on hover card action to open a modal. Once the modal is opened,
|
|
13
|
+
* hover card disappears.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* const modal = useSmartLinkModal()
|
|
17
|
+
* modal.open(<SomeLazyLoadModal isOpen={true} onClose={() => modal.close()} />);
|
|
18
|
+
*/
|
|
19
|
+
export declare const useSmartLinkModal: () => SmartLinkModalAPI;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type SmartLinkModalAPI = {
|
|
3
|
+
/**
|
|
4
|
+
* Insert a modal component on the root of Card or standalone HoverCard.
|
|
5
|
+
* This is to ensure that the modal would not be unmounted
|
|
6
|
+
* when HoverCard is unmounted.
|
|
7
|
+
*/
|
|
8
|
+
open: (node: JSX.Element) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Remove modal component.
|
|
11
|
+
*/
|
|
12
|
+
close: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type SmartLinkModalProviderProps = {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type SmartLinkModalAPI, type SmartLinkModalProviderProps } from './types';
|
|
3
|
+
export declare const SmartLinkModalContext: React.Context<SmartLinkModalAPI>;
|
|
4
|
+
export declare const SmartLinkModalProvider: ({ children, }: SmartLinkModalProviderProps) => JSX.Element;
|
|
5
|
+
/**
|
|
6
|
+
* Open (lazy load) modal
|
|
7
|
+
*
|
|
8
|
+
* This hook injects the element below Card and standalone HoverCard component.
|
|
9
|
+
* It is intended to solve the issue where modal triggered by the parent component
|
|
10
|
+
* disappear when the parent component is unmounted.
|
|
11
|
+
*
|
|
12
|
+
* For example, clicking on hover card action to open a modal. Once the modal is opened,
|
|
13
|
+
* hover card disappears.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* const modal = useSmartLinkModal()
|
|
17
|
+
* modal.open(<SomeLazyLoadModal isOpen={true} onClose={() => modal.close()} />);
|
|
18
|
+
*/
|
|
19
|
+
export declare const useSmartLinkModal: () => SmartLinkModalAPI;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type SmartLinkModalAPI = {
|
|
3
|
+
/**
|
|
4
|
+
* Insert a modal component on the root of Card or standalone HoverCard.
|
|
5
|
+
* This is to ensure that the modal would not be unmounted
|
|
6
|
+
* when HoverCard is unmounted.
|
|
7
|
+
*/
|
|
8
|
+
open: (node: JSX.Element) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Remove modal component.
|
|
11
|
+
*/
|
|
12
|
+
close: () => void;
|
|
13
|
+
};
|
|
14
|
+
export type SmartLinkModalProviderProps = {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "27.2.
|
|
3
|
+
"version": "27.2.2",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@atlaskit/avatar-group": "^9.6.0",
|
|
35
35
|
"@atlaskit/badge": "^16.1.0",
|
|
36
36
|
"@atlaskit/button": "^17.17.0",
|
|
37
|
-
"@atlaskit/checkbox": "^13.
|
|
37
|
+
"@atlaskit/checkbox": "^13.4.0",
|
|
38
38
|
"@atlaskit/dropdown-menu": "^12.10.0",
|
|
39
39
|
"@atlaskit/form": "^10.2.0",
|
|
40
40
|
"@atlaskit/frontend-utilities": "^2.7.0",
|