@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
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Loadable from 'react-loadable';
|
|
3
|
+
import { B200, B400, N700 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { IconType } from '../../../../../../constants';
|
|
5
|
+
// prettier-ignore
|
|
6
|
+
const importIconMapper = {
|
|
7
|
+
[IconType.Archive]: () => import(
|
|
8
|
+
/* webpackChunkName: "glyphArchive" */
|
|
9
|
+
'@atlaskit/icon-file-type/glyph/archive/16'),
|
|
10
|
+
[IconType.Audio]: () => import(
|
|
11
|
+
/* webpackChunkName: "glyphAudio" */
|
|
12
|
+
'@atlaskit/icon-file-type/glyph/audio/16'),
|
|
13
|
+
[IconType.Blog]: () => import(
|
|
14
|
+
/* webpackChunkName: "glyphBlog" */
|
|
15
|
+
'@atlaskit/icon-object/glyph/blog/16'),
|
|
16
|
+
[IconType.Code]: () => import(
|
|
17
|
+
/* webpackChunkName: "glyphCode" */
|
|
18
|
+
'@atlaskit/icon-file-type/glyph/source-code/16'),
|
|
19
|
+
[IconType.Document]: () => import(
|
|
20
|
+
/* webpackChunkName: "glyphDocument" */
|
|
21
|
+
'@atlaskit/icon-file-type/glyph/document/16'),
|
|
22
|
+
[IconType.Executable]: () => import(
|
|
23
|
+
/* webpackChunkName: "glyphExecutable" */
|
|
24
|
+
'@atlaskit/icon-file-type/glyph/executable/16'),
|
|
25
|
+
[IconType.File]: () => import(
|
|
26
|
+
/* webpackChunkName: "glyphFile" */
|
|
27
|
+
'@atlaskit/icon-file-type/glyph/generic/16'),
|
|
28
|
+
[IconType.Folder]: () => import(
|
|
29
|
+
/* webpackChunkName: "glyphFolder" */
|
|
30
|
+
'@atlaskit/icon-file-type/glyph/folder/16'),
|
|
31
|
+
[IconType.Generic]: () => import(
|
|
32
|
+
/* webpackChunkName: "glyphGeneric" */
|
|
33
|
+
'@atlaskit/icon-file-type/glyph/generic/16'),
|
|
34
|
+
[IconType.GIF]: () => import(
|
|
35
|
+
/* webpackChunkName: "glyphGIF" */
|
|
36
|
+
'@atlaskit/icon-file-type/glyph/gif/16'),
|
|
37
|
+
[IconType.GoogleDocs]: () => import(
|
|
38
|
+
/* webpackChunkName: "glyphGoogleDocs" */
|
|
39
|
+
'@atlaskit/icon-file-type/glyph/google-doc/16'),
|
|
40
|
+
[IconType.GoogleForms]: () => import(
|
|
41
|
+
/* webpackChunkName: "glyphGoogleForms" */
|
|
42
|
+
'@atlaskit/icon-file-type/glyph/google-form/16'),
|
|
43
|
+
[IconType.GoogleSheets]: () => import(
|
|
44
|
+
/* webpackChunkName: "glyphGoogleSheets" */
|
|
45
|
+
'@atlaskit/icon-file-type/glyph/google-sheet/16'),
|
|
46
|
+
[IconType.GoogleSlides]: () => import(
|
|
47
|
+
/* webpackChunkName: "glyphGoogleSlides" */
|
|
48
|
+
'@atlaskit/icon-file-type/glyph/google-slide/16'),
|
|
49
|
+
[IconType.Image]: () => import(
|
|
50
|
+
/* webpackChunkName: "glyphImage" */
|
|
51
|
+
'@atlaskit/icon-file-type/glyph/image/16'),
|
|
52
|
+
[IconType.MSExcel]: () => import(
|
|
53
|
+
/* webpackChunkName: "glyphMSExcel" */
|
|
54
|
+
'@atlaskit/icon-file-type/glyph/excel-spreadsheet/16'),
|
|
55
|
+
[IconType.MSPowerpoint]: () => import(
|
|
56
|
+
/* webpackChunkName: "glyphMSPowerpoint" */
|
|
57
|
+
'@atlaskit/icon-file-type/glyph/powerpoint-presentation/16'),
|
|
58
|
+
[IconType.MSWord]: () => import(
|
|
59
|
+
/* webpackChunkName: "glyphMSWord" */
|
|
60
|
+
'@atlaskit/icon-file-type/glyph/word-document/16'),
|
|
61
|
+
[IconType.PDF]: () => import(
|
|
62
|
+
/* webpackChunkName: "glyphPDF" */
|
|
63
|
+
'@atlaskit/icon-file-type/glyph/pdf-document/16'),
|
|
64
|
+
[IconType.Presentation]: () => import(
|
|
65
|
+
/* webpackChunkName: "glyphPresentation" */
|
|
66
|
+
'@atlaskit/icon-file-type/glyph/presentation/16'),
|
|
67
|
+
[IconType.Sketch]: () => import(
|
|
68
|
+
/* webpackChunkName: "glyphSketch" */
|
|
69
|
+
'@atlaskit/icon-file-type/glyph/sketch/16'),
|
|
70
|
+
[IconType.Spreadsheet]: () => import(
|
|
71
|
+
/* webpackChunkName: "glyphSpreadsheet" */
|
|
72
|
+
'@atlaskit/icon-file-type/glyph/spreadsheet/16'),
|
|
73
|
+
[IconType.Template]: () => import(
|
|
74
|
+
/* webpackChunkName: "glyphTemplate" */
|
|
75
|
+
'@atlaskit/icon/glyph/document-filled'),
|
|
76
|
+
[IconType.Video]: () => import(
|
|
77
|
+
/* webpackChunkName: "glyphVideo" */
|
|
78
|
+
'@atlaskit/icon-file-type/glyph/video/16'),
|
|
79
|
+
// Bitbucket icons
|
|
80
|
+
[IconType.Branch]: () => import(
|
|
81
|
+
/* webpackChunkName: "glyphBranch" */
|
|
82
|
+
'@atlaskit/icon-object/glyph/branch/16'),
|
|
83
|
+
[IconType.Commit]: () => import(
|
|
84
|
+
/* webpackChunkName: "glyphCommit" */
|
|
85
|
+
'@atlaskit/icon-object/glyph/commit/16'),
|
|
86
|
+
[IconType.Project]: () => import(
|
|
87
|
+
/* webpackChunkName: "glyphProject" */
|
|
88
|
+
'@atlaskit/icon/glyph/people-group'),
|
|
89
|
+
[IconType.PullRequest]: () => import(
|
|
90
|
+
/* webpackChunkName: "glyphPullRequest" */
|
|
91
|
+
'@atlaskit/icon-object/glyph/pull-request/16'),
|
|
92
|
+
[IconType.Repo]: () => import(
|
|
93
|
+
/* webpackChunkName: "glyphRepo" */
|
|
94
|
+
'@atlaskit/icon-object/glyph/code/16'),
|
|
95
|
+
// Jira icons
|
|
96
|
+
[IconType.Bug]: () => import(
|
|
97
|
+
/* webpackChunkName: "glyphBug" */
|
|
98
|
+
'@atlaskit/icon-object/glyph/bug/16'),
|
|
99
|
+
[IconType.Change]: () => import(
|
|
100
|
+
/* webpackChunkName: "glyphChange" */
|
|
101
|
+
'@atlaskit/icon-object/glyph/changes/16'),
|
|
102
|
+
[IconType.Epic]: () => import(
|
|
103
|
+
/* webpackChunkName: "glyphEpic" */
|
|
104
|
+
'@atlaskit/icon-object/glyph/epic/16'),
|
|
105
|
+
[IconType.Incident]: () => import(
|
|
106
|
+
/* webpackChunkName: "glyphIncident" */
|
|
107
|
+
'@atlaskit/icon-object/glyph/incident/16'),
|
|
108
|
+
[IconType.Problem]: () => import(
|
|
109
|
+
/* webpackChunkName: "glyphProblem" */
|
|
110
|
+
'@atlaskit/icon-object/glyph/problem/16'),
|
|
111
|
+
[IconType.ServiceRequest]: () => import(
|
|
112
|
+
/* webpackChunkName: "glyphServiceRequest" */
|
|
113
|
+
'@atlaskit/icon-object/glyph/issue/16'),
|
|
114
|
+
[IconType.Story]: () => import(
|
|
115
|
+
/* webpackChunkName: "glyphStory" */
|
|
116
|
+
'@atlaskit/icon-object/glyph/story/16'),
|
|
117
|
+
[IconType.SubTask]: () => import(
|
|
118
|
+
/* webpackChunkName: "glyphSubTask" */
|
|
119
|
+
'@atlaskit/icon-object/glyph/subtask/16'),
|
|
120
|
+
[IconType.Task]: () => import(
|
|
121
|
+
/* webpackChunkName: "glyphTask" */
|
|
122
|
+
'@atlaskit/icon-object/glyph/task/16'),
|
|
123
|
+
// Provider icons
|
|
124
|
+
[IconType.Confluence]: () => import(
|
|
125
|
+
/* webpackChunkName: "glyphConfluence" */
|
|
126
|
+
'@atlaskit/logo/confluence-icon').then(({
|
|
127
|
+
ConfluenceIcon
|
|
128
|
+
}) => ({
|
|
129
|
+
default: ConfluenceIcon
|
|
130
|
+
})),
|
|
131
|
+
[IconType.Jira]: () => import(
|
|
132
|
+
/* webpackChunkName: "glyphJira" */
|
|
133
|
+
'@atlaskit/logo/jira-icon').then(({
|
|
134
|
+
JiraIcon
|
|
135
|
+
}) => ({
|
|
136
|
+
default: JiraIcon
|
|
137
|
+
}))
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const getIconImportFn = icon => importIconMapper[icon];
|
|
141
|
+
|
|
142
|
+
const importIcon = importFn => {
|
|
143
|
+
return Loadable({
|
|
144
|
+
loader: () => importFn().then(module => module.default),
|
|
145
|
+
loading: () => null
|
|
146
|
+
}); // Because we're using dynamic loading here, TS will not be able to infer the type.
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const AtlaskitIcon = ({
|
|
150
|
+
icon,
|
|
151
|
+
label,
|
|
152
|
+
testId
|
|
153
|
+
}) => {
|
|
154
|
+
const importFn = getIconImportFn(icon);
|
|
155
|
+
|
|
156
|
+
if (!importFn) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const ImportedIcon = importIcon(importFn); // Logo component has a different prop set from other icon components
|
|
161
|
+
// and yet to support the token system.
|
|
162
|
+
|
|
163
|
+
const importedIcon = icon === IconType.Confluence || icon === IconType.Jira ? /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
164
|
+
textColor: N700,
|
|
165
|
+
iconColor: B200,
|
|
166
|
+
iconGradientStart: B400,
|
|
167
|
+
iconGradientStop: B200
|
|
168
|
+
}) : /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
169
|
+
label: label,
|
|
170
|
+
testId: testId
|
|
171
|
+
});
|
|
172
|
+
return importedIcon;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export default AtlaskitIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { jsx } from '@emotion/core';
|
|
4
|
+
import ImageLoader from 'react-render-image';
|
|
5
|
+
|
|
6
|
+
const ImageIcon = ({
|
|
7
|
+
defaultIcon,
|
|
8
|
+
testId,
|
|
9
|
+
url
|
|
10
|
+
}) => jsx(ImageLoader, {
|
|
11
|
+
src: url,
|
|
12
|
+
loaded: jsx("img", {
|
|
13
|
+
src: url,
|
|
14
|
+
"data-testid": `${testId}-image`
|
|
15
|
+
}),
|
|
16
|
+
errored: defaultIcon
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export default ImageIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
|
+
import LinkIcon from '@atlaskit/icon/glyph/link';
|
|
4
|
+
import { css, jsx } from '@emotion/core';
|
|
5
|
+
import { SmartLinkSize } from '../../../../../constants';
|
|
6
|
+
import AtlaskitIcon from './atlaskit-icon';
|
|
7
|
+
import ImageIcon from './image-icon';
|
|
8
|
+
|
|
9
|
+
const getDimensionStyles = value => ({
|
|
10
|
+
maxHeight: value,
|
|
11
|
+
maxWidth: value,
|
|
12
|
+
minHeight: value,
|
|
13
|
+
minWidth: value,
|
|
14
|
+
height: value,
|
|
15
|
+
width: value
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const getSizeStyles = size => {
|
|
19
|
+
switch (size) {
|
|
20
|
+
case SmartLinkSize.XLarge:
|
|
21
|
+
return getDimensionStyles('1.75rem');
|
|
22
|
+
|
|
23
|
+
case SmartLinkSize.Large:
|
|
24
|
+
return getDimensionStyles('1.5rem');
|
|
25
|
+
|
|
26
|
+
case SmartLinkSize.Medium:
|
|
27
|
+
return getDimensionStyles('1rem');
|
|
28
|
+
|
|
29
|
+
case SmartLinkSize.Small:
|
|
30
|
+
default:
|
|
31
|
+
return getDimensionStyles('.75rem');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const getMargin = size => {
|
|
36
|
+
switch (size) {
|
|
37
|
+
case SmartLinkSize.XLarge:
|
|
38
|
+
return '0.12em 0 0 0';
|
|
39
|
+
|
|
40
|
+
case SmartLinkSize.Large:
|
|
41
|
+
return '0';
|
|
42
|
+
|
|
43
|
+
case SmartLinkSize.Medium:
|
|
44
|
+
return '0';
|
|
45
|
+
|
|
46
|
+
case SmartLinkSize.Small:
|
|
47
|
+
default:
|
|
48
|
+
return '-.05em 0 0 0';
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const getIconStyles = size => {
|
|
53
|
+
const styles = getSizeStyles(size);
|
|
54
|
+
return css({
|
|
55
|
+
flex: '0 0 auto',
|
|
56
|
+
alignSelf: 'flex-start',
|
|
57
|
+
margin: getMargin(size),
|
|
58
|
+
...styles,
|
|
59
|
+
'[class$="-Icon"],[class$="-Wrapper"]': { ...styles,
|
|
60
|
+
'> svg': { ...styles,
|
|
61
|
+
padding: 0
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
'& > img': styles
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const renderAtlaskitIcon = (icon, label, testId) => {
|
|
69
|
+
if (icon) {
|
|
70
|
+
return jsx(AtlaskitIcon, {
|
|
71
|
+
icon: icon,
|
|
72
|
+
label: label,
|
|
73
|
+
testId: `${testId}-icon`
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const renderDefaultIcon = (label, testId) => jsx(LinkIcon, {
|
|
79
|
+
label: label,
|
|
80
|
+
testId: `${testId}-default`
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const renderImageIcon = (defaultIcon, icon, url, testId) => {
|
|
84
|
+
if (url) {
|
|
85
|
+
return jsx(ImageIcon, {
|
|
86
|
+
defaultIcon: defaultIcon,
|
|
87
|
+
testId: testId,
|
|
88
|
+
url: url
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const Icon = ({
|
|
94
|
+
icon,
|
|
95
|
+
label = 'Link',
|
|
96
|
+
size = SmartLinkSize.Medium,
|
|
97
|
+
testId = 'smart-element-icon',
|
|
98
|
+
url
|
|
99
|
+
}) => {
|
|
100
|
+
const element = useMemo(() => {
|
|
101
|
+
const defaultIcon = renderDefaultIcon(label, testId);
|
|
102
|
+
return renderImageIcon(defaultIcon, icon, url, testId) || renderAtlaskitIcon(icon, label, testId) || defaultIcon;
|
|
103
|
+
}, [icon, label, testId, url]);
|
|
104
|
+
const styles = getIconStyles(size);
|
|
105
|
+
return jsx("div", {
|
|
106
|
+
css: styles,
|
|
107
|
+
"data-smart-element-icon": true,
|
|
108
|
+
"data-testid": testId
|
|
109
|
+
}, element);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export default Icon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { B400, N800, N900, B500 } from '@atlaskit/theme/colors';
|
|
4
|
+
import { h200, h400, h600, h800 } from '@atlaskit/theme/typography';
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
import { css, jsx } from '@emotion/core';
|
|
7
|
+
import { SmartLinkSize, SmartLinkTheme } from '../../../../../constants';
|
|
8
|
+
const DEFAULT_MAX_LINES = 2;
|
|
9
|
+
const MAXIMUM_MAX_LINES = 2;
|
|
10
|
+
const MINIMUM_MAX_LINES = 1;
|
|
11
|
+
|
|
12
|
+
const getSizeStyles = size => {
|
|
13
|
+
const overrides = {
|
|
14
|
+
marginTop: 'unset'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
switch (size) {
|
|
18
|
+
case SmartLinkSize.XLarge:
|
|
19
|
+
return { ...h800(),
|
|
20
|
+
...overrides
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
case SmartLinkSize.Large:
|
|
24
|
+
return { ...h600(),
|
|
25
|
+
...overrides
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
case SmartLinkSize.Medium:
|
|
29
|
+
return { ...h400(),
|
|
30
|
+
...overrides
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
case SmartLinkSize.Small:
|
|
34
|
+
default:
|
|
35
|
+
return { ...h200(),
|
|
36
|
+
...overrides
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getThemeStyles = theme => {
|
|
42
|
+
switch (theme) {
|
|
43
|
+
case SmartLinkTheme.Black:
|
|
44
|
+
return {
|
|
45
|
+
color: token('color.text.subtle', N800),
|
|
46
|
+
fontWeight: 500,
|
|
47
|
+
':active': {
|
|
48
|
+
color: token('color.text', N900)
|
|
49
|
+
},
|
|
50
|
+
':hover': {
|
|
51
|
+
color: token('color.text.subtle', N800),
|
|
52
|
+
textDecoration: 'underline'
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
case SmartLinkTheme.Link:
|
|
57
|
+
default:
|
|
58
|
+
return {
|
|
59
|
+
color: token('color.link', B400),
|
|
60
|
+
':active': {
|
|
61
|
+
color: token('color.link.pressed', B500)
|
|
62
|
+
},
|
|
63
|
+
':hover': {
|
|
64
|
+
color: token('color.link', B400),
|
|
65
|
+
textDecoration: 'underline'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const getTruncateStyles = (maxLines, lineHeight = 16) => ({
|
|
72
|
+
display: '-webkit-box',
|
|
73
|
+
flex: '1 1 auto',
|
|
74
|
+
overflow: 'hidden',
|
|
75
|
+
textOverflow: 'ellipsis',
|
|
76
|
+
wordBreak: 'break-word',
|
|
77
|
+
WebkitLineClamp: maxLines,
|
|
78
|
+
WebkitBoxOrient: 'vertical',
|
|
79
|
+
// Fallback options.
|
|
80
|
+
maxHeight: `${(maxLines * lineHeight).toFixed(3)}em`
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const getStyles = (size, theme, maxLines) => {
|
|
84
|
+
const sizeStyles = getSizeStyles(size);
|
|
85
|
+
return css({ ...sizeStyles,
|
|
86
|
+
...getTruncateStyles(maxLines, sizeStyles === null || sizeStyles === void 0 ? void 0 : sizeStyles.lineHeight),
|
|
87
|
+
// Theme should be last to be spread because it contains override values
|
|
88
|
+
...getThemeStyles(theme)
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const getMaxLines = maxLines => {
|
|
93
|
+
if (maxLines > MAXIMUM_MAX_LINES) {
|
|
94
|
+
return DEFAULT_MAX_LINES;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (maxLines < MINIMUM_MAX_LINES) {
|
|
98
|
+
return MINIMUM_MAX_LINES;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return maxLines;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const Link = ({
|
|
105
|
+
maxLines = DEFAULT_MAX_LINES,
|
|
106
|
+
size = SmartLinkSize.Medium,
|
|
107
|
+
testId = 'smart-element-link',
|
|
108
|
+
text,
|
|
109
|
+
theme = SmartLinkTheme.Link,
|
|
110
|
+
url
|
|
111
|
+
}) => jsx("a", {
|
|
112
|
+
css: getStyles(size, theme, getMaxLines(maxLines)),
|
|
113
|
+
href: url,
|
|
114
|
+
"data-smart-element-link": true,
|
|
115
|
+
"data-testid": testId
|
|
116
|
+
}, text);
|
|
117
|
+
|
|
118
|
+
export default Link;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/client/api.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
5
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
6
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
9
|
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
9
10
|
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
11
|
+
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; }
|
|
11
12
|
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
13
|
+
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; }
|
|
13
14
|
|
|
14
15
|
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); }; }
|
|
15
16
|
|
|
@@ -27,7 +28,7 @@ export var NetworkError = /*#__PURE__*/function (_Error) {
|
|
|
27
28
|
return _super.call(this, error);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
return NetworkError;
|
|
31
|
+
return _createClass(NetworkError);
|
|
31
32
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
32
33
|
export function request(_x, _x2, _x3, _x4) {
|
|
33
34
|
return _request.apply(this, arguments);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
3
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
@@ -35,5 +36,5 @@ export var APIError = /*#__PURE__*/function (_Error) {
|
|
|
35
36
|
return _this;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
return APIError;
|
|
39
|
+
return _createClass(APIError);
|
|
39
40
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export var SmartLinkDirection;
|
|
2
|
+
|
|
3
|
+
(function (SmartLinkDirection) {
|
|
4
|
+
SmartLinkDirection["Horizontal"] = "Horizontal";
|
|
5
|
+
SmartLinkDirection["Vertical"] = "Vertical";
|
|
6
|
+
})(SmartLinkDirection || (SmartLinkDirection = {}));
|
|
7
|
+
|
|
8
|
+
export var SmartLinkSize;
|
|
9
|
+
|
|
10
|
+
(function (SmartLinkSize) {
|
|
11
|
+
SmartLinkSize["XLarge"] = "xlarge";
|
|
12
|
+
SmartLinkSize["Large"] = "large";
|
|
13
|
+
SmartLinkSize["Medium"] = "medium";
|
|
14
|
+
SmartLinkSize["Small"] = "small";
|
|
15
|
+
})(SmartLinkSize || (SmartLinkSize = {}));
|
|
16
|
+
|
|
17
|
+
export var SmartLinkTheme;
|
|
18
|
+
|
|
19
|
+
(function (SmartLinkTheme) {
|
|
20
|
+
SmartLinkTheme["Black"] = "Black";
|
|
21
|
+
SmartLinkTheme["Link"] = "Link";
|
|
22
|
+
})(SmartLinkTheme || (SmartLinkTheme = {}));
|
|
23
|
+
|
|
24
|
+
export var IconType;
|
|
25
|
+
|
|
26
|
+
(function (IconType) {
|
|
27
|
+
IconType["Archive"] = "FileType:Archive";
|
|
28
|
+
IconType["Audio"] = "FileType:Audio";
|
|
29
|
+
IconType["Blog"] = "FileType:Blog";
|
|
30
|
+
IconType["Code"] = "FileType:Code";
|
|
31
|
+
IconType["Document"] = "FileType:Document";
|
|
32
|
+
IconType["Executable"] = "FileType:Executable";
|
|
33
|
+
IconType["File"] = "FileType:File";
|
|
34
|
+
IconType["Folder"] = "FileType:Folder";
|
|
35
|
+
IconType["Generic"] = "FileType:Generic";
|
|
36
|
+
IconType["GIF"] = "FileType:GIF";
|
|
37
|
+
IconType["GoogleDocs"] = "FileType:GoogleDocs";
|
|
38
|
+
IconType["GoogleForms"] = "FileType:GoogleForms";
|
|
39
|
+
IconType["GoogleSheets"] = "FileType:GoogleSheets";
|
|
40
|
+
IconType["GoogleSlides"] = "FileType:GoogleSlides";
|
|
41
|
+
IconType["Image"] = "FileType.Image";
|
|
42
|
+
IconType["MSExcel"] = "FileType:Excel";
|
|
43
|
+
IconType["MSPowerpoint"] = "FileType:Powerpoint";
|
|
44
|
+
IconType["MSWord"] = "FileType:WordDocument";
|
|
45
|
+
IconType["PDF"] = "FileType:PDF";
|
|
46
|
+
IconType["Presentation"] = "FileType:Presentation";
|
|
47
|
+
IconType["Sketch"] = "FileType:Sketch";
|
|
48
|
+
IconType["Spreadsheet"] = "FileType:Spreadsheet";
|
|
49
|
+
IconType["Template"] = "FileType:Template";
|
|
50
|
+
IconType["Video"] = "FileType:Video";
|
|
51
|
+
IconType["Branch"] = "BitBucket:Branch";
|
|
52
|
+
IconType["Commit"] = "BitBucket:Commit";
|
|
53
|
+
IconType["Project"] = "BitBucket:Project";
|
|
54
|
+
IconType["PullRequest"] = "BitBucket:PullRequest";
|
|
55
|
+
IconType["Repo"] = "BitBucket:Repo";
|
|
56
|
+
IconType["Bug"] = "Jira:Bug";
|
|
57
|
+
IconType["Change"] = "Jira:Change";
|
|
58
|
+
IconType["Epic"] = "Jira:Epic";
|
|
59
|
+
IconType["Incident"] = "Jira:Incident";
|
|
60
|
+
IconType["Problem"] = "Jira:Problem";
|
|
61
|
+
IconType["ServiceRequest"] = "Jira:ServiceRequest";
|
|
62
|
+
IconType["Story"] = "Jira:Story";
|
|
63
|
+
IconType["SubTask"] = "Jira:SubTask";
|
|
64
|
+
IconType["Task"] = "Jira:Task";
|
|
65
|
+
IconType["Confluence"] = "Provider:Confluence";
|
|
66
|
+
IconType["Jira"] = "Provider:Jira";
|
|
67
|
+
})(IconType || (IconType = {}));
|
|
@@ -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, extractTitleTextColor, extractSummary } from '../common/primitives';
|
|
8
8
|
import { extractLozenge } from '../common/lozenge';
|
|
@@ -44,10 +44,10 @@ export var extractBlockActions = function extractBlockActions(props, jsonLd, opt
|
|
|
44
44
|
if (opts) {
|
|
45
45
|
var handleInvoke = opts.handleInvoke,
|
|
46
46
|
handleAnalytics = opts.handleAnalytics,
|
|
47
|
-
|
|
47
|
+
extensionKey = opts.extensionKey,
|
|
48
48
|
testId = opts.testId;
|
|
49
49
|
var actions = extractActions(jsonLd, handleInvoke);
|
|
50
|
-
var previewAction = extractPreviewAction(
|
|
50
|
+
var previewAction = extractPreviewAction(extensionKey, props, jsonLd, handleInvoke, handleAnalytics, testId, platform); // The previewAction should always be the last action
|
|
51
51
|
|
|
52
52
|
if (previewAction) {
|
|
53
53
|
actions.push(previewAction);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
4
|
+
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; }
|
|
5
5
|
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
6
|
+
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; }
|
|
7
7
|
|
|
8
8
|
import { DownloadAction, ViewAction } from '@atlaskit/media-ui';
|
|
9
9
|
|
|
@@ -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 { PreviewAction } from '@atlaskit/media-ui';
|
|
8
8
|
import { uiRenderSuccessEvent, uiRenderFailedEvent } from '../../../utils/analytics';
|
|
@@ -53,7 +53,7 @@ var getInvokeOpts = function getInvokeOpts(key, action, source) {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
export var extractPreviewAction = function extractPreviewAction() {
|
|
56
|
-
var
|
|
56
|
+
var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'empty-object-provider';
|
|
57
57
|
var viewProps = arguments.length > 1 ? arguments[1] : undefined;
|
|
58
58
|
var jsonLd = arguments.length > 2 ? arguments[2] : undefined;
|
|
59
59
|
var handleInvoke = arguments.length > 3 ? arguments[3] : undefined;
|
|
@@ -69,7 +69,7 @@ export var extractPreviewAction = function extractPreviewAction() {
|
|
|
69
69
|
|
|
70
70
|
if (metadataFromJsonLd.src) {
|
|
71
71
|
// Build action using instrumentation hooks.
|
|
72
|
-
var key =
|
|
72
|
+
var key = extensionKey;
|
|
73
73
|
var previewAction = PreviewAction(_objectSpread(_objectSpread({}, metadata), {}, {
|
|
74
74
|
testId: testId,
|
|
75
75
|
onOpen: function onOpen() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormattedRelativeTime } from 'react-intl-next';
|
|
3
|
+
import { selectUnit } from '@formatjs/intl-utils';
|
|
3
4
|
import { extractPersonUpdatedBy } from '../person/extractPersonUpdatedBy';
|
|
4
5
|
import { extractPersonCreatedBy } from '../person/extractPersonCreatedBy';
|
|
5
6
|
import { extractDateCreated } from '../date/extractDateCreated';
|
|
@@ -9,15 +10,25 @@ export var extractByline = function extractByline(jsonLd) {
|
|
|
9
10
|
var createdAt = extractDateCreated(jsonLd);
|
|
10
11
|
|
|
11
12
|
if (updatedAt) {
|
|
13
|
+
var _selectUnit = selectUnit(new Date(updatedAt).getTime()),
|
|
14
|
+
value = _selectUnit.value,
|
|
15
|
+
unit = _selectUnit.unit;
|
|
16
|
+
|
|
12
17
|
var updatedBy = extractPersonUpdatedBy(jsonLd);
|
|
13
|
-
return /*#__PURE__*/React.createElement("span", null, "Updated ", updatedBy && "by ".concat(updatedBy.name), ' ', /*#__PURE__*/React.createElement(
|
|
14
|
-
value:
|
|
18
|
+
return /*#__PURE__*/React.createElement("span", null, "Updated ", updatedBy && "by ".concat(updatedBy.name), ' ', /*#__PURE__*/React.createElement(FormattedRelativeTime, {
|
|
19
|
+
value: value,
|
|
20
|
+
unit: unit
|
|
15
21
|
}));
|
|
16
22
|
} else if (createdAt) {
|
|
23
|
+
var _selectUnit2 = selectUnit(new Date(createdAt).getTime()),
|
|
24
|
+
_value = _selectUnit2.value,
|
|
25
|
+
_unit = _selectUnit2.unit;
|
|
26
|
+
|
|
17
27
|
var createdBy = extractPersonCreatedBy(jsonLd);
|
|
18
28
|
var createdByPerson = extractFirstPerson(createdBy);
|
|
19
|
-
return /*#__PURE__*/React.createElement("span", null, "Created ", createdByPerson && "by ".concat(createdByPerson.name), ' ', /*#__PURE__*/React.createElement(
|
|
20
|
-
value:
|
|
29
|
+
return /*#__PURE__*/React.createElement("span", null, "Created ", createdByPerson && "by ".concat(createdByPerson.name), ' ', /*#__PURE__*/React.createElement(FormattedRelativeTime, {
|
|
30
|
+
value: _value,
|
|
31
|
+
unit: _unit
|
|
21
32
|
}));
|
|
22
33
|
}
|
|
23
34
|
};
|