@atlaskit/smart-card 16.2.0 → 17.0.1
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 +95 -0
- package/dist/cjs/client/api.js +6 -4
- package/dist/cjs/client/errors.js +3 -1
- package/dist/cjs/client/types/responses.js +1 -1
- package/dist/cjs/client/utils/environments.js +1 -1
- package/dist/cjs/constants.js +77 -0
- package/dist/cjs/extractors/block/index.js +5 -5
- package/dist/cjs/extractors/common/actions/extractActions.js +2 -2
- package/dist/cjs/extractors/common/actions/extractPreviewAction.js +4 -4
- package/dist/cjs/extractors/common/byline/extractByline.js +17 -5
- package/dist/cjs/extractors/common/context/extractAccessContext.js +2 -2
- package/dist/cjs/extractors/common/lozenge/utils.js +1 -1
- package/dist/cjs/extractors/common/utils.js +1 -1
- package/dist/cjs/extractors/constants.js +1 -1
- package/dist/cjs/extractors/embed/index.js +2 -2
- package/dist/cjs/extractors/flexible/index.js +22 -0
- package/dist/cjs/in-product.js +8 -8
- package/dist/cjs/index.js +74 -32
- package/dist/cjs/providers/editor/transformer.js +5 -1
- package/dist/cjs/state/actions/constants.js +1 -1
- package/dist/cjs/state/actions/index.js +1 -1
- package/dist/cjs/state/analytics/index.js +8 -8
- package/dist/cjs/state/analytics/ufoExperiences.js +18 -15
- package/dist/cjs/state/analytics/useSmartLinkAnalytics.js +12 -4
- package/dist/cjs/state/context/index.js +3 -2
- package/dist/cjs/state/flexible-ui-context/index.js +17 -0
- package/dist/cjs/state/flexible-ui-context/types.js +5 -0
- package/dist/cjs/state/helpers.js +1 -1
- package/dist/cjs/state/index.js +4 -4
- package/dist/cjs/state/reducers/index.js +2 -2
- package/dist/cjs/utils/analytics/analytics.js +9 -9
- package/dist/cjs/utils/analytics/index.js +29 -29
- package/dist/cjs/utils/index.js +1 -1
- package/dist/cjs/utils/mocks.js +1 -1
- package/dist/cjs/utils/performance.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/BlockCard/index.js +1 -1
- package/dist/cjs/view/Card/index.js +9 -2
- package/dist/cjs/view/CardWithUrl/component-lazy/LazyFallback.js +1 -1
- package/dist/cjs/view/CardWithUrl/loader.js +27 -32
- package/dist/cjs/view/EmbedCard/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/block/index.js +87 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/container/index.js +117 -0
- package/dist/cjs/view/FlexibleCard/components/container/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.js +244 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/image-icon/index.js +32 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/image-icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/index.js +144 -0
- package/dist/cjs/view/FlexibleCard/components/elements/icon/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +135 -0
- package/dist/cjs/view/FlexibleCard/components/elements/link/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/elements/types.js +5 -0
- package/dist/es2019/constants.js +67 -0
- package/dist/es2019/extractors/block/index.js +2 -2
- package/dist/es2019/extractors/common/actions/extractPreviewAction.js +2 -2
- package/dist/es2019/extractors/common/byline/extractByline.js +16 -5
- package/dist/es2019/extractors/flexible/index.js +14 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/providers/editor/transformer.js +3 -1
- package/dist/es2019/state/actions/index.js +1 -1
- package/dist/es2019/state/analytics/ufoExperiences.js +17 -14
- package/dist/es2019/state/analytics/useSmartLinkAnalytics.js +18 -4
- package/dist/es2019/state/flexible-ui-context/index.js +3 -0
- package/dist/es2019/state/flexible-ui-context/types.js +1 -0
- package/dist/es2019/utils/analytics/analytics.js +6 -6
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/BlockCard/index.js +2 -2
- package/dist/es2019/view/Card/index.js +8 -2
- package/dist/es2019/view/CardWithUrl/loader.js +30 -37
- package/dist/es2019/view/EmbedCard/index.js +2 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/block/index.js +62 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/container/index.js +89 -0
- package/dist/es2019/view/FlexibleCard/components/container/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.js +175 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/image-icon/index.js +19 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/image-icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/index.js +112 -0
- package/dist/es2019/view/FlexibleCard/components/elements/icon/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +118 -0
- package/dist/es2019/view/FlexibleCard/components/elements/link/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/types.js +1 -0
- package/dist/esm/client/api.js +4 -3
- package/dist/esm/client/errors.js +2 -1
- package/dist/esm/constants.js +67 -0
- package/dist/esm/extractors/block/index.js +4 -4
- package/dist/esm/extractors/common/actions/extractActions.js +2 -2
- package/dist/esm/extractors/common/actions/extractPreviewAction.js +4 -4
- package/dist/esm/extractors/common/byline/extractByline.js +16 -5
- package/dist/esm/extractors/common/context/extractAccessContext.js +2 -2
- package/dist/esm/extractors/embed/index.js +2 -2
- package/dist/esm/extractors/flexible/index.js +14 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/providers/editor/transformer.js +5 -1
- package/dist/esm/state/actions/index.js +1 -1
- package/dist/esm/state/analytics/ufoExperiences.js +17 -14
- package/dist/esm/state/analytics/useSmartLinkAnalytics.js +13 -5
- package/dist/esm/state/flexible-ui-context/index.js +5 -0
- package/dist/esm/state/flexible-ui-context/types.js +1 -0
- package/dist/esm/state/reducers/index.js +2 -2
- package/dist/esm/utils/analytics/analytics.js +8 -8
- package/dist/esm/utils/analytics/index.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/BlockCard/index.js +2 -2
- package/dist/esm/view/Card/index.js +8 -2
- package/dist/esm/view/CardWithUrl/loader.js +28 -33
- package/dist/esm/view/EmbedCard/index.js +2 -2
- package/dist/esm/view/FlexibleCard/components/blocks/block/index.js +74 -0
- package/dist/esm/view/FlexibleCard/components/blocks/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/container/index.js +102 -0
- package/dist/esm/view/FlexibleCard/components/container/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.js +224 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/image-icon/index.js +20 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/image-icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/index.js +124 -0
- package/dist/esm/view/FlexibleCard/components/elements/icon/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +120 -0
- package/dist/esm/view/FlexibleCard/components/elements/link/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/elements/types.js +1 -0
- package/dist/types/constants.d.ts +56 -0
- package/dist/types/extractors/block/types.d.ts +1 -1
- package/dist/types/extractors/common/actions/extractPreviewAction.d.ts +1 -1
- package/dist/types/extractors/flexible/index.d.ts +4 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/state/analytics/ufoExperiences.d.ts +1 -1
- package/dist/types/state/analytics/useSmartLinkAnalytics.d.ts +2 -1
- package/dist/types/state/context/provider.d.ts +1 -0
- package/dist/types/state/flexible-ui-context/index.d.ts +4 -0
- package/dist/types/state/flexible-ui-context/types.d.ts +3 -0
- package/dist/types/state/hooks/useSmartLink.d.ts +1 -1
- package/dist/types/utils/analytics/analytics.d.ts +3 -3
- package/dist/types/utils/test-utils.d.ts +1 -0
- package/dist/types/view/Card/index.d.ts +2 -1
- package/dist/types/view/CardWithUrl/component-lazy/LazyIntersectionObserverCard.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component-lazy/LazyLazilyRenderCard.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component-lazy/index.d.ts +1 -0
- package/dist/types/view/CardWithUrl/component.d.ts +1 -0
- package/dist/types/view/CardWithUrl/loader.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/block/index.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/container/index.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/container/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/atlaskit-icon/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/atlaskit-icon/types.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/image-icon/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/image-icon/types.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/elements/icon/types.d.ts +7 -0
- package/dist/types/view/FlexibleCard/components/elements/link/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/elements/link/types.d.ts +8 -0
- package/dist/types/view/FlexibleCard/components/elements/types.d.ts +5 -0
- package/package.json +23 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { ForbiddenAction, messages } from '@atlaskit/media-ui';
|
|
8
8
|
export var extractRequestAccessContext = function extractRequestAccessContext(_ref) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { extractLink, extractTitle } from '../common/primitives';
|
|
8
8
|
import { extractProvider } from '../common/context';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { extractTitle } from '../common/primitives';
|
|
2
|
+
|
|
3
|
+
var extractFlexibleUiContext = function extractFlexibleUiContext(response) {
|
|
4
|
+
if (!response) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var data = response.data;
|
|
9
|
+
return {
|
|
10
|
+
title: extractTitle(data)
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default extractFlexibleUiContext;
|
package/dist/esm/index.js
CHANGED
|
@@ -9,5 +9,5 @@ export { embedHeaderHeight } from '@atlaskit/media-ui/embeds';
|
|
|
9
9
|
export { SmartLinkEvents } from './utils/analytics/analytics';
|
|
10
10
|
export { useSmartLinkEvents } from './view/SmartLinkEvents/useSmartLinkEvents'; // Classnames for integrators
|
|
11
11
|
|
|
12
|
-
export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName } from '@atlaskit/media-ui/classNames';
|
|
12
|
+
export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName, blockCardResolvedViewByClassName, blockCardForbiddenViewLinkClassName, blockCardContentClassName, blockCardContentHeaderClassName, blockCardContentHeaderNameClassName, blockCardNotFoundViewClassName, blockCardErroredViewClassName } from '@atlaskit/media-ui/classNames';
|
|
13
13
|
export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback';
|
|
@@ -9,6 +9,10 @@ var isPolarisView = function isPolarisView(url) {
|
|
|
9
9
|
return url.match(/^https:\/\/.*?\/jira\/polaris\/projects\/[^\/]+?\/ideas\/view\/\d+$|^https:\/\/.*?\/secure\/JiraProductDiscoveryAnonymous\.jspa\?hash=\w+|^https:\/\/.*?\/jira\/polaris\/share\/\w+/);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
var isJwmView = function isJwmView(url) {
|
|
13
|
+
return url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar)\/?/);
|
|
14
|
+
};
|
|
15
|
+
|
|
12
16
|
var isSlackMessage = function isSlackMessage(url) {
|
|
13
17
|
return url.match(/^https:\/\/.+?\.slack\.com\/archives\/[CG][A-Z0-9]+\/p[0-9]+(\?.*)?$/);
|
|
14
18
|
};
|
|
@@ -52,7 +56,7 @@ export var Transformer = /*#__PURE__*/function () {
|
|
|
52
56
|
}, {
|
|
53
57
|
key: "toAdf",
|
|
54
58
|
value: function toAdf(url, appearance) {
|
|
55
|
-
if (isJiraRoadMap(url) || isPolarisView(url)) {
|
|
59
|
+
if (isJiraRoadMap(url) || isPolarisView(url) || isJwmView(url)) {
|
|
56
60
|
return this.buildEmbedAdf(url);
|
|
57
61
|
} else if (isSlackMessage(url)) {
|
|
58
62
|
return this.buildBlockAdf(url);
|
|
@@ -185,7 +185,7 @@ export var useSmartCardActions = function useSmartCardActions(id, url, analytics
|
|
|
185
185
|
measure.mark(markName, 'pending');
|
|
186
186
|
_context2.prev = 4;
|
|
187
187
|
// Begin analytics instrumentation.
|
|
188
|
-
analytics.ui.actionClickedEvent(key, action.type, source); // Invoke action - either client-side or server-side.
|
|
188
|
+
analytics.ui.actionClickedEvent(id, key, action.type, source, opts.type); // Invoke action - either client-side or server-side.
|
|
189
189
|
|
|
190
190
|
if (!(opts.type === 'client')) {
|
|
191
191
|
_context2.next = 12;
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
2
|
+
var inlineExperience = {
|
|
3
|
+
platform: {
|
|
4
|
+
component: 'smart-links'
|
|
5
|
+
},
|
|
6
|
+
type: ExperienceTypes.Experience,
|
|
7
|
+
performanceType: ExperiencePerformanceTypes.InlineResult
|
|
8
|
+
};
|
|
9
|
+
var renderExperience = {
|
|
10
|
+
platform: {
|
|
11
|
+
component: 'smart-links'
|
|
12
|
+
},
|
|
13
|
+
type: ExperienceTypes.Load,
|
|
14
|
+
performanceType: ExperiencePerformanceTypes.PageSegmentLoad
|
|
15
|
+
};
|
|
2
16
|
var ufoExperiences = {
|
|
3
|
-
'smart-link-rendered': new ConcurrentExperience('smart-link-rendered',
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
platform: {
|
|
7
|
-
component: 'smart-links'
|
|
8
|
-
}
|
|
9
|
-
}),
|
|
10
|
-
'smart-link-authenticated': new ConcurrentExperience('smart-link-authenticated', {
|
|
11
|
-
type: ExperienceTypes.Load,
|
|
12
|
-
performanceType: ExperiencePerformanceTypes.PageSegmentLoad,
|
|
13
|
-
platform: {
|
|
14
|
-
component: 'smart-links'
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
+
'smart-link-rendered': new ConcurrentExperience('smart-link-rendered', renderExperience),
|
|
18
|
+
'smart-link-authenticated': new ConcurrentExperience('smart-link-authenticated', inlineExperience),
|
|
19
|
+
'smart-link-action-invocation': new ConcurrentExperience('smart-link-action-invocation', inlineExperience)
|
|
17
20
|
};
|
|
18
21
|
export var startUfoExperience = function startUfoExperience(experienceName, id, properties) {
|
|
19
22
|
var experience = ufoExperiences[experienceName].getInstance(id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { uiAuthEvent, uiAuthAlternateAccountEvent, uiCardClickedEvent, uiActionClickedEvent, uiClosedAuthEvent, uiRenderSuccessEvent, resolvedEvent as _resolvedEvent, unresolvedEvent as _unresolvedEvent, invokeSucceededEvent as _invokeSucceededEvent, invokeFailedEvent as _invokeFailedEvent, connectSucceededEvent as _connectSucceededEvent, connectFailedEvent as _connectFailedEvent, trackAppAccountConnected, screenAuthPopupEvent, instrumentEvent } from '../../utils/analytics';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
3
|
+
import { failUfoExperience, startUfoExperience, succeedUfoExperience } from './ufoExperiences';
|
|
4
4
|
export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalytics) {
|
|
5
5
|
var ui = useMemo(function () {
|
|
6
6
|
return {
|
|
@@ -13,8 +13,14 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalyt
|
|
|
13
13
|
cardClickedEvent: function cardClickedEvent(display, definitionId, extensionKey) {
|
|
14
14
|
return dispatchAnalytics(uiCardClickedEvent(display, definitionId, extensionKey));
|
|
15
15
|
},
|
|
16
|
-
actionClickedEvent: function actionClickedEvent(
|
|
17
|
-
|
|
16
|
+
actionClickedEvent: function actionClickedEvent(id, extensionKey, actionType, display, invokeType) {
|
|
17
|
+
startUfoExperience('smart-link-action-invocation', id, {
|
|
18
|
+
actionType: actionType,
|
|
19
|
+
display: display,
|
|
20
|
+
extensionKey: extensionKey,
|
|
21
|
+
invokeType: invokeType
|
|
22
|
+
});
|
|
23
|
+
dispatchAnalytics(uiActionClickedEvent(extensionKey, actionType, display));
|
|
18
24
|
},
|
|
19
25
|
closedAuthEvent: function closedAuthEvent(display, definitionId, extensionKey) {
|
|
20
26
|
return dispatchAnalytics(uiClosedAuthEvent(display, definitionId, extensionKey));
|
|
@@ -41,10 +47,12 @@ export var useSmartLinkAnalytics = function useSmartLinkAnalytics(dispatchAnalyt
|
|
|
41
47
|
return dispatchAnalytics(_unresolvedEvent(id, status, definitionId, extensionKey, resourceType));
|
|
42
48
|
},
|
|
43
49
|
invokeSucceededEvent: function invokeSucceededEvent(id, providerKey, actionType, display) {
|
|
44
|
-
|
|
50
|
+
succeedUfoExperience('smart-link-action-invocation', id);
|
|
51
|
+
dispatchAnalytics(_invokeSucceededEvent(id, providerKey, actionType, display));
|
|
45
52
|
},
|
|
46
53
|
invokeFailedEvent: function invokeFailedEvent(id, providerKey, actionType, display, reason) {
|
|
47
|
-
|
|
54
|
+
failUfoExperience('smart-link-action-invocation', id);
|
|
55
|
+
dispatchAnalytics(_invokeFailedEvent(id, providerKey, actionType, display, reason));
|
|
48
56
|
},
|
|
49
57
|
connectSucceededEvent: function connectSucceededEvent(id, definitionId, extensionKey) {
|
|
50
58
|
startUfoExperience('smart-link-authenticated', id, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
var _cardReducerMap;
|
|
4
4
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
|
|
9
9
|
import * as actions from '../actions/constants';
|
|
10
10
|
import { getStatus } from '../helpers';
|
|
@@ -2,9 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
8
|
|
|
9
9
|
import { name as packageName, version as packageVersion } from '../../version.json';
|
|
10
10
|
import { getMeasure } from '../performance';
|
|
@@ -82,7 +82,7 @@ export var unresolvedEvent = function unresolvedEvent(id, status, definitionId,
|
|
|
82
82
|
})
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
export var invokeSucceededEvent = function invokeSucceededEvent(id,
|
|
85
|
+
export var invokeSucceededEvent = function invokeSucceededEvent(id, extensionKey, actionType, display) {
|
|
86
86
|
var measure = getMeasure(id, 'resolved') || {
|
|
87
87
|
duration: undefined
|
|
88
88
|
};
|
|
@@ -94,12 +94,12 @@ export var invokeSucceededEvent = function invokeSucceededEvent(id, providerKey,
|
|
|
94
94
|
id: id,
|
|
95
95
|
actionType: actionType,
|
|
96
96
|
display: display,
|
|
97
|
-
|
|
97
|
+
extensionKey: extensionKey,
|
|
98
98
|
duration: measure.duration
|
|
99
99
|
})
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
-
export var invokeFailedEvent = function invokeFailedEvent(id,
|
|
102
|
+
export var invokeFailedEvent = function invokeFailedEvent(id, extensionKey, actionType, display, reason) {
|
|
103
103
|
var measure = getMeasure(id, 'errored') || {
|
|
104
104
|
duration: undefined
|
|
105
105
|
};
|
|
@@ -111,7 +111,7 @@ export var invokeFailedEvent = function invokeFailedEvent(id, providerKey, actio
|
|
|
111
111
|
id: id,
|
|
112
112
|
actionType: actionType,
|
|
113
113
|
display: display,
|
|
114
|
-
|
|
114
|
+
extensionKey: extensionKey,
|
|
115
115
|
duration: measure.duration,
|
|
116
116
|
reason: reason
|
|
117
117
|
})
|
|
@@ -194,14 +194,14 @@ export var uiCardClickedEvent = function uiCardClickedEvent(display, definitionI
|
|
|
194
194
|
})
|
|
195
195
|
};
|
|
196
196
|
};
|
|
197
|
-
export var uiActionClickedEvent = function uiActionClickedEvent(
|
|
197
|
+
export var uiActionClickedEvent = function uiActionClickedEvent(extensionKey, actionType, display) {
|
|
198
198
|
return {
|
|
199
199
|
action: 'clicked',
|
|
200
200
|
actionSubject: 'smartLinkAction',
|
|
201
201
|
eventType: 'ui',
|
|
202
202
|
attributes: _objectSpread(_objectSpread({}, context), {}, {
|
|
203
203
|
display: display,
|
|
204
|
-
|
|
204
|
+
extensionKey: extensionKey,
|
|
205
205
|
actionType: actionType
|
|
206
206
|
})
|
|
207
207
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { resolvedEvent, unresolvedEvent } from './analytics';
|
|
8
8
|
import { getMeasure } from '../performance';
|
package/dist/esm/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { CardLinkView, BlockCardResolvingView, BlockCardErroredView, BlockCardUnauthorisedView, BlockCardForbiddenView, BlockCardResolvedView, BlockCardNotFoundView, AuthorizeAction, ForbiddenAction } from '@atlaskit/media-ui';
|
|
4
|
-
import {
|
|
4
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
5
5
|
import { extractBlockProps } from '../../extractors/block';
|
|
6
6
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
7
7
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
@@ -29,7 +29,7 @@ export var BlockCard = function BlockCard(_ref) {
|
|
|
29
29
|
var extractorOpts = {
|
|
30
30
|
handleAnalytics: handlePreviewAnalytics,
|
|
31
31
|
handleInvoke: handleInvoke,
|
|
32
|
-
|
|
32
|
+
extensionKey: getExtensionKey(details)
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
switch (status) {
|
|
@@ -14,6 +14,7 @@ import { CardWithDataRenderer } from '../CardWithData/loader';
|
|
|
14
14
|
import { CardWithURLRenderer } from '../CardWithUrl/loader';
|
|
15
15
|
import { isCardWithData } from '../../utils';
|
|
16
16
|
import { context } from '../../utils/analytics';
|
|
17
|
+
import { injectIntl, IntlProvider } from 'react-intl-next';
|
|
17
18
|
|
|
18
19
|
var PlainCard = /*#__PURE__*/function (_React$PureComponent) {
|
|
19
20
|
_inherits(PlainCard, _React$PureComponent);
|
|
@@ -29,11 +30,16 @@ var PlainCard = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
29
30
|
_createClass(PlainCard, [{
|
|
30
31
|
key: "render",
|
|
31
32
|
value: function render() {
|
|
32
|
-
|
|
33
|
+
var content = isCardWithData(this.props) ? /*#__PURE__*/React.createElement(CardWithDataRenderer, this.props) : /*#__PURE__*/React.createElement(CardWithURLRenderer, this.props);
|
|
34
|
+
return this.props.intl ? content : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
35
|
+
locale: "en"
|
|
36
|
+
}, content);
|
|
33
37
|
}
|
|
34
38
|
}]);
|
|
35
39
|
|
|
36
40
|
return PlainCard;
|
|
37
41
|
}(React.PureComponent);
|
|
38
42
|
|
|
39
|
-
export var Card = withAnalyticsContext(context)(withAnalyticsEvents()(PlainCard
|
|
43
|
+
export var Card = withAnalyticsContext(context)(withAnalyticsEvents()(injectIntl(PlainCard, {
|
|
44
|
+
enforceContext: false
|
|
45
|
+
})));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { lazy, useEffect, useState, Suspense } from 'react';
|
|
2
|
+
import React, { lazy, useEffect, useState, Suspense, useCallback } from 'react';
|
|
3
3
|
import uuid from 'uuid';
|
|
4
4
|
import { CardLinkView } from '@atlaskit/media-ui';
|
|
5
5
|
import { uiRenderFailedEvent, fireSmartLinkEvent } from '../../utils/analytics';
|
|
@@ -30,8 +30,33 @@ export function CardWithURLRenderer(props) {
|
|
|
30
30
|
clearMeasures(id);
|
|
31
31
|
};
|
|
32
32
|
}, [id]);
|
|
33
|
+
var url = props.url,
|
|
34
|
+
appearance = props.appearance,
|
|
35
|
+
isSelected = props.isSelected,
|
|
36
|
+
isFrameVisible = props.isFrameVisible,
|
|
37
|
+
onClick = props.onClick,
|
|
38
|
+
container = props.container,
|
|
39
|
+
onResolve = props.onResolve,
|
|
40
|
+
testId = props.testId,
|
|
41
|
+
showActions = props.showActions,
|
|
42
|
+
inheritDimensions = props.inheritDimensions,
|
|
43
|
+
platform = props.platform,
|
|
44
|
+
embedIframeRef = props.embedIframeRef,
|
|
45
|
+
inlinePreloaderStyle = props.inlinePreloaderStyle,
|
|
46
|
+
createAnalyticsEvent = props.createAnalyticsEvent; // Wrapper around analytics.
|
|
33
47
|
|
|
34
|
-
var
|
|
48
|
+
var dispatchAnalytics = useCallback(function (analyticsPayload) {
|
|
49
|
+
if (analyticsPayload && analyticsPayload.attributes) {
|
|
50
|
+
// Update if we haven't already set the display - possible
|
|
51
|
+
// in the case of `preview` which is rendered differently.
|
|
52
|
+
if (!analyticsPayload.attributes.display) {
|
|
53
|
+
analyticsPayload.attributes.display = appearance;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
58
|
+
}, [appearance, createAnalyticsEvent]);
|
|
59
|
+
var logError = useCallback(function (error, info) {
|
|
35
60
|
var componentStack = info.componentStack; // NB: APIErrors are thrown in response to Object Resolver Service.
|
|
36
61
|
// In these cases, control is handed back to the Editor. We do not
|
|
37
62
|
// fire an event for these, as they do not cover failed UI render events.
|
|
@@ -49,37 +74,7 @@ export function CardWithURLRenderer(props) {
|
|
|
49
74
|
failUfoExperience('smart-link-authenticated', id);
|
|
50
75
|
dispatchAnalytics(uiRenderFailedEvent(appearance, error, errorInfo));
|
|
51
76
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var dispatchAnalytics = function dispatchAnalytics(analyticsPayload) {
|
|
56
|
-
var appearance = props.appearance,
|
|
57
|
-
createAnalyticsEvent = props.createAnalyticsEvent;
|
|
58
|
-
|
|
59
|
-
if (analyticsPayload && analyticsPayload.attributes) {
|
|
60
|
-
// Update if we haven't already set the display - possible
|
|
61
|
-
// in the case of `preview` which is rendered differently.
|
|
62
|
-
if (!analyticsPayload.attributes.display) {
|
|
63
|
-
analyticsPayload.attributes.display = appearance;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
fireSmartLinkEvent(analyticsPayload, createAnalyticsEvent);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
var url = props.url,
|
|
71
|
-
appearance = props.appearance,
|
|
72
|
-
isSelected = props.isSelected,
|
|
73
|
-
isFrameVisible = props.isFrameVisible,
|
|
74
|
-
onClick = props.onClick,
|
|
75
|
-
container = props.container,
|
|
76
|
-
onResolve = props.onResolve,
|
|
77
|
-
testId = props.testId,
|
|
78
|
-
showActions = props.showActions,
|
|
79
|
-
inheritDimensions = props.inheritDimensions,
|
|
80
|
-
platform = props.platform,
|
|
81
|
-
embedIframeRef = props.embedIframeRef,
|
|
82
|
-
inlinePreloaderStyle = props.inlinePreloaderStyle;
|
|
77
|
+
}, [appearance, dispatchAnalytics, id]);
|
|
83
78
|
|
|
84
79
|
if (!url) {
|
|
85
80
|
throw new Error('@atlaskit/smart-card: url property is missing.');
|
|
@@ -6,7 +6,7 @@ import { extractEmbedProps } from '../../extractors/embed';
|
|
|
6
6
|
import { getEmptyJsonLd, getUnauthorizedJsonLd } from '../../utils/jsonld';
|
|
7
7
|
import { extractInlineProps } from '../../extractors/inline';
|
|
8
8
|
import { extractBlockProps } from '../../extractors/block';
|
|
9
|
-
import {
|
|
9
|
+
import { getExtensionKey } from '../../state/helpers';
|
|
10
10
|
import { extractRequestAccessContext } from '../../extractors/common/context';
|
|
11
11
|
export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef) {
|
|
12
12
|
var _details$meta, _forbiddenViewProps$c;
|
|
@@ -73,7 +73,7 @@ export var EmbedCard = /*#__PURE__*/React.forwardRef(function (_ref, iframeRef)
|
|
|
73
73
|
var resolvedBlockViewProps = extractBlockProps(data, meta, {
|
|
74
74
|
handleAnalytics: handleAnalytics,
|
|
75
75
|
handleInvoke: handleInvoke,
|
|
76
|
-
|
|
76
|
+
extensionKey: getExtensionKey(details)
|
|
77
77
|
});
|
|
78
78
|
return /*#__PURE__*/React.createElement(BlockCardResolvedView, _extends({}, resolvedBlockViewProps, {
|
|
79
79
|
isSelected: isSelected,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
/** @jsx jsx */
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { css, jsx } from '@emotion/core';
|
|
10
|
+
import { SmartLinkDirection, SmartLinkSize } from '../../../../../constants';
|
|
11
|
+
|
|
12
|
+
var getDirectionStyles = function getDirectionStyles(direction) {
|
|
13
|
+
switch (direction) {
|
|
14
|
+
case SmartLinkDirection.Vertical:
|
|
15
|
+
return {
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
alignItems: 'flex-start'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
case SmartLinkDirection.Horizontal:
|
|
21
|
+
default:
|
|
22
|
+
return {
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
alignItems: 'center'
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var getGapSize = function getGapSize(size) {
|
|
30
|
+
switch (size) {
|
|
31
|
+
case SmartLinkSize.XLarge:
|
|
32
|
+
return '1.25rem';
|
|
33
|
+
|
|
34
|
+
case SmartLinkSize.Large:
|
|
35
|
+
return '1rem';
|
|
36
|
+
|
|
37
|
+
case SmartLinkSize.Medium:
|
|
38
|
+
return '.5rem';
|
|
39
|
+
|
|
40
|
+
case SmartLinkSize.Small:
|
|
41
|
+
default:
|
|
42
|
+
return '.25rem';
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export var getBlockStyles = function getBlockStyles(direction, size) {
|
|
47
|
+
return css(_objectSpread(_objectSpread({
|
|
48
|
+
display: 'flex',
|
|
49
|
+
gap: getGapSize(size),
|
|
50
|
+
lineHeight: '1rem',
|
|
51
|
+
minWidth: 0
|
|
52
|
+
}, getDirectionStyles(direction)), {}, {
|
|
53
|
+
'& > *': {
|
|
54
|
+
minWidth: 0
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var Block = function Block(_ref) {
|
|
60
|
+
var children = _ref.children,
|
|
61
|
+
_ref$direction = _ref.direction,
|
|
62
|
+
direction = _ref$direction === void 0 ? SmartLinkDirection.Horizontal : _ref$direction,
|
|
63
|
+
_ref$size = _ref.size,
|
|
64
|
+
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
65
|
+
_ref$testId = _ref.testId,
|
|
66
|
+
testId = _ref$testId === void 0 ? 'smart-block' : _ref$testId;
|
|
67
|
+
return jsx("div", {
|
|
68
|
+
css: getBlockStyles(direction, size),
|
|
69
|
+
"data-smart-block": true,
|
|
70
|
+
"data-testid": testId
|
|
71
|
+
}, children);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default Block;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
/** @jsx jsx */
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { N0, N40A, N50A } from '@atlaskit/theme/colors';
|
|
10
|
+
import { css, jsx } from '@emotion/core';
|
|
11
|
+
import { SmartLinkSize } from '../../../../constants';
|
|
12
|
+
import { token } from '@atlaskit/tokens';
|
|
13
|
+
|
|
14
|
+
var getElevationStyles = function getElevationStyles() {
|
|
15
|
+
return {
|
|
16
|
+
border: "1px solid transparent",
|
|
17
|
+
borderRadius: '1.5px',
|
|
18
|
+
boxShadow: token('elevation.shadow.raised', "0 1px 1px ".concat(N50A, ", 0 0 1px 1px ").concat(N40A)),
|
|
19
|
+
margin: '2px'
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var getGapSize = function getGapSize(size) {
|
|
24
|
+
switch (size) {
|
|
25
|
+
case SmartLinkSize.XLarge:
|
|
26
|
+
return '1.25rem';
|
|
27
|
+
|
|
28
|
+
case SmartLinkSize.Large:
|
|
29
|
+
return '1rem';
|
|
30
|
+
|
|
31
|
+
case SmartLinkSize.Medium:
|
|
32
|
+
return '.5rem';
|
|
33
|
+
|
|
34
|
+
case SmartLinkSize.Small:
|
|
35
|
+
default:
|
|
36
|
+
return '.25rem';
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var getPaddingSize = function getPaddingSize(size) {
|
|
41
|
+
switch (size) {
|
|
42
|
+
case SmartLinkSize.XLarge:
|
|
43
|
+
return '1.5rem';
|
|
44
|
+
|
|
45
|
+
case SmartLinkSize.Large:
|
|
46
|
+
return '1.25rem';
|
|
47
|
+
|
|
48
|
+
case SmartLinkSize.Medium:
|
|
49
|
+
return '1rem';
|
|
50
|
+
|
|
51
|
+
case SmartLinkSize.Small:
|
|
52
|
+
default:
|
|
53
|
+
return '.5rem';
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export var getContainerStyles = function getContainerStyles(size, hideBackground, hideElevation, hidePadding) {
|
|
58
|
+
var elevation = hideElevation ? {} : getElevationStyles();
|
|
59
|
+
return css(_objectSpread({
|
|
60
|
+
backgroundColor: hideBackground ? undefined : token('elevation.surface', N0),
|
|
61
|
+
display: 'flex',
|
|
62
|
+
gap: "".concat(getGapSize(size), " 0"),
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
minWidth: 0,
|
|
65
|
+
overflow: 'hidden',
|
|
66
|
+
padding: hidePadding ? undefined : getPaddingSize(size)
|
|
67
|
+
}, elevation));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var renderChildren = function renderChildren(children, containerSize) {
|
|
71
|
+
return React.Children.map(children, function (child) {
|
|
72
|
+
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
73
|
+
var blockSize = child.props.size;
|
|
74
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
75
|
+
size: blockSize || containerSize
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return child;
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
var Container = function Container(_ref) {
|
|
84
|
+
var children = _ref.children,
|
|
85
|
+
_ref$hideBackground = _ref.hideBackground,
|
|
86
|
+
hideBackground = _ref$hideBackground === void 0 ? false : _ref$hideBackground,
|
|
87
|
+
_ref$hideElevation = _ref.hideElevation,
|
|
88
|
+
hideElevation = _ref$hideElevation === void 0 ? false : _ref$hideElevation,
|
|
89
|
+
_ref$hidePadding = _ref.hidePadding,
|
|
90
|
+
hidePadding = _ref$hidePadding === void 0 ? false : _ref$hidePadding,
|
|
91
|
+
_ref$size = _ref.size,
|
|
92
|
+
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
93
|
+
_ref$testId = _ref.testId,
|
|
94
|
+
testId = _ref$testId === void 0 ? 'smart-links-container' : _ref$testId;
|
|
95
|
+
return jsx("div", {
|
|
96
|
+
css: getContainerStyles(size, hideBackground, hideElevation, hidePadding),
|
|
97
|
+
"data-smart-link-container": true,
|
|
98
|
+
"data-testid": testId
|
|
99
|
+
}, renderChildren(children, size));
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default Container;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|