@atlaskit/smart-card 38.9.0 → 38.9.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/extractors/common/context/index.js +2 -1
  3. package/dist/cjs/extractors/embed/index.js +4 -16
  4. package/dist/cjs/extractors/flexible/extract-link-title.js +2 -4
  5. package/dist/cjs/extractors/flexible/index.js +12 -14
  6. package/dist/cjs/extractors/inline/index.js +7 -18
  7. package/dist/cjs/state/hooks/use-resolve/index.js +1 -2
  8. package/dist/cjs/state/hooks/useSmartLink.js +4 -4
  9. package/dist/cjs/utils/analytics/analytics.js +1 -1
  10. package/dist/cjs/view/BlockCard/views/ForbiddenView.js +1 -1
  11. package/dist/cjs/view/BlockCard/views/NotFoundView.js +1 -1
  12. package/dist/cjs/view/BlockCard/views/UnauthorisedView.js +2 -3
  13. package/dist/cjs/view/CardWithUrl/component.js +10 -9
  14. package/dist/cjs/view/FlexibleCard/components/elements/common/base-badge-element/index.js +2 -7
  15. package/dist/cjs/view/FlexibleCard/components/elements/index.js +225 -189
  16. package/dist/cjs/view/FlexibleCard/utils.js +5 -8
  17. package/dist/cjs/view/HoverCard/components/HoverCardComponent.js +1 -2
  18. package/dist/cjs/view/HoverCard/components/ImagePreview.js +2 -15
  19. package/dist/cjs/view/HoverCard/components/views/forbidden/index.js +3 -4
  20. package/dist/cjs/view/HoverCard/components/views/unauthorised/index.js +2 -3
  21. package/dist/cjs/view/InlineCard/index.js +3 -5
  22. package/dist/cjs/view/LinkUrl/index.js +1 -1
  23. package/dist/es2019/extractors/common/context/index.js +2 -1
  24. package/dist/es2019/extractors/embed/index.js +6 -19
  25. package/dist/es2019/extractors/flexible/extract-link-title.js +3 -5
  26. package/dist/es2019/extractors/flexible/index.js +15 -15
  27. package/dist/es2019/extractors/inline/index.js +8 -22
  28. package/dist/es2019/state/hooks/use-resolve/index.js +1 -2
  29. package/dist/es2019/state/hooks/useSmartLink.js +4 -4
  30. package/dist/es2019/utils/analytics/analytics.js +1 -1
  31. package/dist/es2019/view/BlockCard/views/ForbiddenView.js +2 -2
  32. package/dist/es2019/view/BlockCard/views/NotFoundView.js +2 -2
  33. package/dist/es2019/view/BlockCard/views/UnauthorisedView.js +3 -4
  34. package/dist/es2019/view/CardWithUrl/component.js +10 -9
  35. package/dist/es2019/view/FlexibleCard/components/elements/common/base-badge-element/index.js +2 -7
  36. package/dist/es2019/view/FlexibleCard/components/elements/index.js +32 -183
  37. package/dist/es2019/view/FlexibleCard/utils.js +7 -8
  38. package/dist/es2019/view/HoverCard/components/HoverCardComponent.js +1 -2
  39. package/dist/es2019/view/HoverCard/components/ImagePreview.js +2 -15
  40. package/dist/es2019/view/HoverCard/components/views/forbidden/index.js +4 -5
  41. package/dist/es2019/view/HoverCard/components/views/unauthorised/index.js +3 -4
  42. package/dist/es2019/view/InlineCard/index.js +5 -7
  43. package/dist/es2019/view/LinkUrl/index.js +1 -1
  44. package/dist/esm/extractors/common/context/index.js +2 -1
  45. package/dist/esm/extractors/embed/index.js +6 -18
  46. package/dist/esm/extractors/flexible/extract-link-title.js +3 -5
  47. package/dist/esm/extractors/flexible/index.js +15 -15
  48. package/dist/esm/extractors/inline/index.js +8 -21
  49. package/dist/esm/state/hooks/use-resolve/index.js +1 -2
  50. package/dist/esm/state/hooks/useSmartLink.js +4 -4
  51. package/dist/esm/utils/analytics/analytics.js +1 -1
  52. package/dist/esm/view/BlockCard/views/ForbiddenView.js +2 -2
  53. package/dist/esm/view/BlockCard/views/NotFoundView.js +2 -2
  54. package/dist/esm/view/BlockCard/views/UnauthorisedView.js +3 -4
  55. package/dist/esm/view/CardWithUrl/component.js +10 -9
  56. package/dist/esm/view/FlexibleCard/components/elements/common/base-badge-element/index.js +2 -7
  57. package/dist/esm/view/FlexibleCard/components/elements/index.js +32 -183
  58. package/dist/esm/view/FlexibleCard/utils.js +7 -8
  59. package/dist/esm/view/HoverCard/components/HoverCardComponent.js +1 -2
  60. package/dist/esm/view/HoverCard/components/ImagePreview.js +2 -15
  61. package/dist/esm/view/HoverCard/components/views/forbidden/index.js +4 -5
  62. package/dist/esm/view/HoverCard/components/views/unauthorised/index.js +3 -4
  63. package/dist/esm/view/InlineCard/index.js +5 -7
  64. package/dist/esm/view/LinkUrl/index.js +1 -1
  65. package/dist/types/extractors/flexible/extract-link-title.d.ts +2 -2
  66. package/dist/types/state/hooks/useSmartLink.d.ts +3 -3
  67. package/dist/types/utils/analytics/types.d.ts +1 -1
  68. package/dist/types/view/Card/types.d.ts +1 -0
  69. package/dist/types/view/FlexibleCard/components/elements/attachment-count-element/index.d.ts +1 -1
  70. package/dist/types/view/FlexibleCard/components/elements/common/base-atlaskit-badge-element/index.d.ts +1 -1
  71. package/dist/types/view/FlexibleCard/components/elements/common/base-text-element/index.d.ts +1 -1
  72. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +32 -176
  73. package/dist/types/view/FlexibleCard/components/elements/programming-language-element/index.d.ts +1 -1
  74. package/dist/types/view/FlexibleCard/components/elements/provider-element/index.d.ts +1 -1
  75. package/dist/types/view/FlexibleCard/components/elements/view-count-element/index.d.ts +1 -1
  76. package/dist/types/view/FlexibleCard/external.d.ts +2 -2
  77. package/dist/types-ts4.5/extractors/flexible/extract-link-title.d.ts +2 -2
  78. package/dist/types-ts4.5/state/hooks/useSmartLink.d.ts +3 -3
  79. package/dist/types-ts4.5/utils/analytics/types.d.ts +1 -1
  80. package/dist/types-ts4.5/view/Card/types.d.ts +1 -0
  81. package/dist/types-ts4.5/view/FlexibleCard/components/elements/attachment-count-element/index.d.ts +1 -1
  82. package/dist/types-ts4.5/view/FlexibleCard/components/elements/common/base-atlaskit-badge-element/index.d.ts +1 -1
  83. package/dist/types-ts4.5/view/FlexibleCard/components/elements/common/base-text-element/index.d.ts +1 -1
  84. package/dist/types-ts4.5/view/FlexibleCard/components/elements/index.d.ts +32 -176
  85. package/dist/types-ts4.5/view/FlexibleCard/components/elements/programming-language-element/index.d.ts +1 -1
  86. package/dist/types-ts4.5/view/FlexibleCard/components/elements/provider-element/index.d.ts +1 -1
  87. package/dist/types-ts4.5/view/FlexibleCard/components/elements/view-count-element/index.d.ts +1 -1
  88. package/dist/types-ts4.5/view/FlexibleCard/external.d.ts +2 -2
  89. package/package.json +3 -6
  90. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +0 -302
  91. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +0 -327
  92. package/dist/esm/view/FlexibleCard/components/elements/utils.js +0 -294
  93. package/dist/types/view/FlexibleCard/components/elements/utils.d.ts +0 -6
  94. package/dist/types-ts4.5/view/FlexibleCard/components/elements/utils.d.ts +0 -6
@@ -1,294 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _typeof from "@babel/runtime/helpers/typeof";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- var _elementMappings;
5
- import React, { useContext } from 'react';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
- import { ElementName, IconType, SmartLinkInternalTheme } from '../../../../constants';
8
- import { messages } from '../../../../messages';
9
- import { FlexibleUiContext, useFlexibleUiContext } from '../../../../state/flexible-ui-context';
10
- import AppliedToComponentsCount from './applied-to-components-count-element';
11
- import assignedToElement from './assigned-to-element';
12
- import assignedToGroupElement from './assigned-to-group-element';
13
- import attachmentCountElement from './attachment-count-element';
14
- import authorGroupElement from './author-group-element';
15
- import checklistProgressElement from './checklist-progress-element';
16
- import collaboratorGroupElement from './collaborator-group-element';
17
- import commentCountElement from './comment-count-element';
18
- import { BaseAtlaskitBadgeElement, BaseAvatarGroupElement, BaseBadgeElement, BaseDateTimeElement, BaseIconElement, BaseLinkElement, BaseLozengeElement, BaseTextElement, toAtlaskitBadgeProps, toAvatarGroupProps, toBadgeProps, toDateLozengeProps, toDateTimeProps, toFormattedTextProps, toLinkIconProps, toLinkProps, toTextProps } from './common';
19
- import createdByElement from './created-by-element';
20
- import createdOnElement from './created-on-element';
21
- import dueOnElement from './due-on-element';
22
- import latestCommitElement from './latest-commit-element';
23
- import linkIconElement from './link-icon-element';
24
- import locationElement from './location-element';
25
- import MediaElement from './media-element';
26
- import modifiedByElement from './modified-by-element';
27
- import modifiedOnElement from './modified-on-element';
28
- import ownedByElement from './owned-by-element';
29
- import ownedByGroupElement from './owned-by-group-element';
30
- import previewElement from './preview-element';
31
- import priorityElement from './priority-element';
32
- import programmingLanguageElement from './programming-language-element';
33
- import providerElement from './provider-element';
34
- import reactCountElement from './react-count-element';
35
- import readTimeElement from './read-time-element';
36
- import sentOnElement from './sent-on-element';
37
- import sourceBranchElement from './source-branch-element';
38
- import stateElement from './state-element';
39
- import storyPointsElement from './story-points-element';
40
- import subTasksProgressElement from './sub-tasks-progress-element';
41
- import subscriberCountElement from './subscriber-count-element';
42
- import targetBranchElement from './target-branch-element';
43
- import titleElement from './title-element';
44
- import viewCountElement from './view-count-element';
45
- import voteCountElement from './vote-count-element';
46
-
47
- /**
48
- * @deprecated remove on FG clean up platform-linking-flexible-card-elements-refactor
49
- */
50
-
51
- /**
52
- * @deprecated remove on FG clean up platform-linking-flexible-card-elements-refactor
53
- */
54
- var elementMappings = (_elementMappings = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_elementMappings, ElementName.AppliedToComponentsCount, {
55
- component: AppliedToComponentsCount,
56
- props: {
57
- icon: IconType.Component
58
- }
59
- }), ElementName.AttachmentCount, {
60
- component: BaseBadgeElement,
61
- props: {
62
- icon: IconType.Attachment
63
- },
64
- newComponent: attachmentCountElement
65
- }), ElementName.AuthorGroup, {
66
- component: BaseAvatarGroupElement,
67
- newComponent: authorGroupElement
68
- }), ElementName.ChecklistProgress, {
69
- component: BaseBadgeElement,
70
- props: {
71
- icon: IconType.CheckItem
72
- },
73
- newComponent: checklistProgressElement
74
- }), ElementName.CollaboratorGroup, {
75
- component: BaseAvatarGroupElement,
76
- newComponent: collaboratorGroupElement
77
- }), ElementName.CommentCount, {
78
- component: BaseBadgeElement,
79
- props: {
80
- icon: IconType.Comment
81
- },
82
- newComponent: commentCountElement
83
- }), ElementName.ViewCount, {
84
- component: BaseBadgeElement,
85
- props: {
86
- icon: IconType.View
87
- },
88
- newComponent: viewCountElement
89
- }), ElementName.ReactCount, {
90
- component: BaseBadgeElement,
91
- props: {
92
- icon: IconType.React
93
- },
94
- newComponent: reactCountElement
95
- }), ElementName.VoteCount, {
96
- component: BaseBadgeElement,
97
- props: {
98
- icon: IconType.Vote
99
- },
100
- newComponent: voteCountElement
101
- }), ElementName.CreatedBy, {
102
- component: BaseTextElement,
103
- newComponent: createdByElement
104
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_elementMappings, ElementName.OwnedBy, {
105
- component: BaseTextElement,
106
- newComponent: ownedByElement
107
- }), ElementName.AssignedTo, {
108
- component: BaseTextElement,
109
- newComponent: assignedToElement
110
- }), ElementName.AssignedToGroup, {
111
- component: BaseAvatarGroupElement,
112
- newComponent: assignedToGroupElement
113
- }), ElementName.OwnedByGroup, {
114
- component: BaseAvatarGroupElement,
115
- newComponent: ownedByGroupElement
116
- }), ElementName.CreatedOn, {
117
- component: BaseDateTimeElement,
118
- newComponent: createdOnElement
119
- }), ElementName.DueOn, {
120
- component: BaseLozengeElement,
121
- newComponent: dueOnElement
122
- }), ElementName.LatestCommit, {
123
- component: BaseBadgeElement,
124
- props: {
125
- icon: IconType.Commit
126
- },
127
- newComponent: latestCommitElement
128
- }), ElementName.LinkIcon, {
129
- component: BaseIconElement,
130
- newComponent: linkIconElement
131
- }), ElementName.ModifiedBy, {
132
- component: BaseTextElement,
133
- newComponent: modifiedByElement
134
- }), ElementName.ModifiedOn, {
135
- component: BaseDateTimeElement,
136
- newComponent: modifiedOnElement
137
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_elementMappings, ElementName.Preview, {
138
- component: MediaElement,
139
- newComponent: previewElement
140
- }), ElementName.Priority, {
141
- component: BaseBadgeElement,
142
- newComponent: priorityElement
143
- }), ElementName.ProgrammingLanguage, {
144
- component: BaseBadgeElement,
145
- props: {
146
- icon: IconType.ProgrammingLanguage
147
- },
148
- newComponent: programmingLanguageElement
149
- }), ElementName.Provider, {
150
- component: BaseBadgeElement,
151
- newComponent: providerElement
152
- }), ElementName.ReadTime, {
153
- component: BaseTextElement,
154
- newComponent: readTimeElement
155
- }), ElementName.SentOn, {
156
- component: BaseDateTimeElement,
157
- newComponent: sentOnElement
158
- }), ElementName.SourceBranch, {
159
- component: BaseTextElement,
160
- newComponent: sourceBranchElement
161
- }), ElementName.State, {
162
- component: BaseLozengeElement,
163
- newComponent: stateElement
164
- }), ElementName.SubscriberCount, {
165
- component: BaseBadgeElement,
166
- props: {
167
- icon: IconType.Subscriber
168
- },
169
- newComponent: subscriberCountElement
170
- }), ElementName.SubTasksProgress, {
171
- component: BaseBadgeElement,
172
- props: {
173
- icon: IconType.SubTasksProgress
174
- },
175
- newComponent: subTasksProgressElement
176
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_elementMappings, ElementName.StoryPoints, {
177
- component: BaseAtlaskitBadgeElement,
178
- newComponent: storyPointsElement
179
- }), ElementName.TargetBranch, {
180
- component: BaseTextElement,
181
- newComponent: targetBranchElement
182
- }), ElementName.Title, {
183
- component: BaseLinkElement,
184
- newComponent: titleElement
185
- }), ElementName.Location, {
186
- component: BaseLinkElement,
187
- props: {
188
- theme: SmartLinkInternalTheme.Grey
189
- },
190
- newComponent: locationElement
191
- }));
192
-
193
- /**
194
- * @deprecated remove on FG clean up platform-linking-flexible-card-elements-refactor
195
- */
196
- var getContextKey = function getContextKey(name) {
197
- // Attempt to predict context prop name in advance to reduce the amount of
198
- // code run during runtime
199
- return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
200
- };
201
-
202
- /**
203
- * @deprecated remove on FG clean up platform-linking-flexible-card-elements-refactor
204
- */
205
- var getData = function getData(elementName, contextKey, context) {
206
- if (!context) {
207
- return undefined;
208
- }
209
- var data = context[contextKey];
210
- switch (elementName) {
211
- case ElementName.AssignedToGroup:
212
- case ElementName.AuthorGroup:
213
- case ElementName.CollaboratorGroup:
214
- case ElementName.OwnedByGroup:
215
- var AvatarGroupsWithFallback = [ElementName.AssignedToGroup];
216
- var showFallbackAvatar = AvatarGroupsWithFallback.includes(elementName);
217
- return toAvatarGroupProps(data, showFallbackAvatar);
218
- case ElementName.AppliedToComponentsCount:
219
- case ElementName.AttachmentCount:
220
- case ElementName.ChecklistProgress:
221
- case ElementName.CommentCount:
222
- case ElementName.ViewCount:
223
- case ElementName.ReactCount:
224
- case ElementName.VoteCount:
225
- case ElementName.ProgrammingLanguage:
226
- case ElementName.SubscriberCount:
227
- case ElementName.LatestCommit:
228
- case ElementName.SubTasksProgress:
229
- return toBadgeProps(data);
230
- case ElementName.StoryPoints:
231
- return toAtlaskitBadgeProps(data);
232
- case ElementName.CreatedBy:
233
- return toFormattedTextProps(messages.created_by, context.createdBy);
234
- case ElementName.AssignedTo:
235
- return toFormattedTextProps(messages.assigned_to, context.assignedTo);
236
- case ElementName.OwnedBy:
237
- return toFormattedTextProps(messages.owned_by, context.ownedBy);
238
- case ElementName.CreatedOn:
239
- return toDateTimeProps('created', context.createdOn);
240
- case ElementName.DueOn:
241
- return toDateLozengeProps(context.dueOn);
242
- case ElementName.ModifiedBy:
243
- return toFormattedTextProps(messages.modified_by, context.modifiedBy);
244
- case ElementName.ModifiedOn:
245
- return toDateTimeProps('modified', context.modifiedOn);
246
- case ElementName.SentOn:
247
- return toDateTimeProps('sent', context.sentOn);
248
- case ElementName.ReadTime:
249
- return toFormattedTextProps(messages.read_time, data);
250
- case ElementName.SourceBranch:
251
- case ElementName.TargetBranch:
252
- return toTextProps(data);
253
- case ElementName.Title:
254
- if (fg('platform-linking-flexible-card-context')) {
255
- return context.linkTitle;
256
- }
257
- return toLinkProps(context.title, context.url);
258
- case ElementName.LinkIcon:
259
- if (fg('platform-linking-visual-refresh-v2')) {
260
- return toLinkIconProps(data, context.type);
261
- }
262
- return _typeof(data) === 'object' ? data : undefined;
263
- default:
264
- return _typeof(data) === 'object' ? data : undefined;
265
- }
266
- };
267
-
268
- /**
269
- * @deprecated remove on FG platform-linking-flexible-card-elements-refactor clean up
270
- */
271
- export var createElement = function createElement(name) {
272
- var _ref = elementMappings[name] || {},
273
- BaseElement = _ref.component,
274
- props = _ref.props,
275
- newComponent = _ref.newComponent;
276
- if (newComponent && fg('platform-linking-flexible-card-elements-refactor')) {
277
- return newComponent;
278
- }
279
- var contextKey = getContextKey(name);
280
- if (!BaseElement) {
281
- throw Error("Element ".concat(name, " does not exist."));
282
- }
283
- return function (overrides) {
284
- var context = fg('platform-linking-flexible-card-context') ?
285
- // eslint-disable-next-line react-hooks/rules-of-hooks
286
- useFlexibleUiContext() :
287
- // eslint-disable-next-line react-hooks/rules-of-hooks
288
- useContext(FlexibleUiContext);
289
- var data = getData(name, contextKey, context);
290
- return data ? /*#__PURE__*/React.createElement(BaseElement, _extends({}, props, data, overrides, {
291
- name: name
292
- })) : null;
293
- };
294
- };
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { ElementName } from '../../../../constants';
3
- /**
4
- * @deprecated remove on FG platform-linking-flexible-card-elements-refactor clean up
5
- */
6
- export declare const createElement: <P extends {}>(name: ElementName) => React.ComponentType<P>;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { ElementName } from '../../../../constants';
3
- /**
4
- * @deprecated remove on FG platform-linking-flexible-card-elements-refactor clean up
5
- */
6
- export declare const createElement: <P extends {}>(name: ElementName) => React.ComponentType<P>;