@atlaskit/media-card 73.1.0 → 73.3.0
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 +35 -0
- package/dist/cjs/files/cardImageView/index.js +51 -41
- package/dist/cjs/root/card/cardAnalytics.js +4 -4
- package/dist/cjs/root/card/getCardPreview/index.js +7 -1
- package/dist/cjs/root/card/index.js +301 -155
- package/dist/cjs/root/cardView.js +128 -118
- package/dist/cjs/root/inlinePlayer.js +4 -2
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +17 -23
- package/dist/cjs/root/ui/styled.js +5 -5
- package/dist/cjs/types.js +10 -1
- package/dist/cjs/utils/analytics.js +32 -13
- package/dist/cjs/utils/dimensionComparer.js +7 -13
- package/dist/cjs/utils/getMediaCardCursor.js +29 -0
- package/dist/cjs/utils/globalScope/getSSRData.js +20 -0
- package/dist/cjs/utils/globalScope/globalScope.js +94 -0
- package/dist/cjs/utils/globalScope/index.js +39 -0
- package/dist/cjs/utils/globalScope/types.js +5 -0
- package/dist/cjs/utils/printScript.js +44 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/files/cardImageView/index.js +19 -5
- package/dist/es2019/root/card/cardAnalytics.js +4 -4
- package/dist/es2019/root/card/getCardPreview/index.js +1 -0
- package/dist/es2019/root/card/index.js +167 -40
- package/dist/es2019/root/cardView.js +41 -35
- package/dist/es2019/root/inlinePlayer.js +4 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +17 -19
- package/dist/es2019/root/ui/styled.js +4 -4
- package/dist/es2019/types.js +7 -1
- package/dist/es2019/utils/analytics.js +17 -9
- package/dist/es2019/utils/dimensionComparer.js +6 -13
- package/dist/es2019/utils/getMediaCardCursor.js +19 -0
- package/dist/es2019/utils/globalScope/getSSRData.js +10 -0
- package/dist/es2019/utils/globalScope/globalScope.js +62 -0
- package/dist/es2019/utils/globalScope/index.js +2 -0
- package/dist/es2019/utils/globalScope/types.js +1 -0
- package/dist/es2019/utils/printScript.js +19 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/files/cardImageView/index.js +53 -41
- package/dist/esm/root/card/cardAnalytics.js +4 -4
- package/dist/esm/root/card/getCardPreview/index.js +3 -0
- package/dist/esm/root/card/index.js +284 -138
- package/dist/esm/root/cardView.js +127 -118
- package/dist/esm/root/inlinePlayer.js +4 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +17 -21
- package/dist/esm/root/ui/styled.js +5 -5
- package/dist/esm/types.js +7 -1
- package/dist/esm/utils/analytics.js +26 -12
- package/dist/esm/utils/dimensionComparer.js +8 -13
- package/dist/esm/utils/getMediaCardCursor.js +19 -0
- package/dist/esm/utils/globalScope/getSSRData.js +10 -0
- package/dist/esm/utils/globalScope/globalScope.js +69 -0
- package/dist/esm/utils/globalScope/index.js +2 -0
- package/dist/esm/utils/globalScope/types.js +1 -0
- package/dist/esm/utils/printScript.js +30 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/__tests_external__/page-objects/MediaCard.d.ts +0 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/files/cardImageView/index.d.ts +6 -2
- package/dist/types/root/card/cardAnalytics.d.ts +2 -1
- package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +5 -1
- package/dist/types/root/cardView.d.ts +8 -6
- package/dist/types/root/inlinePlayer.d.ts +3 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +5 -14
- package/dist/types/root/ui/styled.d.ts +2 -1
- package/dist/types/types.d.ts +6 -1
- package/dist/types/utils/analytics.d.ts +27 -5
- package/dist/types/utils/getMediaCardCursor.d.ts +2 -0
- package/dist/types/utils/globalScope/getSSRData.d.ts +3 -0
- package/dist/types/utils/globalScope/globalScope.d.ts +21 -0
- package/dist/types/utils/globalScope/index.d.ts +4 -0
- package/dist/types/utils/globalScope/types.d.ts +8 -0
- package/dist/types/utils/printScript.d.ts +2 -0
- package/package.json +12 -12
|
@@ -45,6 +45,7 @@ import { PreviewUnavailable, CreatingPreview, FailedToUpload, PreviewCurrentlyUn
|
|
|
45
45
|
import { isRateLimitedError, isPollingError } from '@atlaskit/media-client';
|
|
46
46
|
import { newFileExperienceClassName } from './card/cardConstants';
|
|
47
47
|
import { isUploadError } from '../errors';
|
|
48
|
+
import { MediaCardCursor } from '../types';
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* This is classic vanilla CardView class. To create an instance of class one would need to supply
|
|
@@ -72,31 +73,38 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
72
73
|
|
|
73
74
|
_defineProperty(_assertThisInitialized(_this), "divRef", /*#__PURE__*/React.createRef());
|
|
74
75
|
|
|
75
|
-
_defineProperty(_assertThisInitialized(_this), "onImageLoad", function () {
|
|
76
|
-
var
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "onImageLoad", function (prevCardPreview) {
|
|
77
|
+
var _this$props = _this.props,
|
|
78
|
+
onImageLoad = _this$props.onImageLoad,
|
|
79
|
+
cardPreview = _this$props.cardPreview;
|
|
80
|
+
|
|
81
|
+
if (prevCardPreview.dataURI !== (cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI)) {
|
|
82
|
+
return;
|
|
83
|
+
} // We render the icon & icon message always, even if there is cardPreview available.
|
|
77
84
|
// If the image fails to load/render, the icon will remain, i.e. the user won't see a change until
|
|
78
85
|
// the root card decides to chage status to error.
|
|
79
86
|
// If the image renders successfully, we switch this variable to hide the icon & icon message
|
|
80
87
|
// behind the thumbnail in case the image has transparency.
|
|
81
|
-
// It is less likely that root component replaces a suceeded
|
|
88
|
+
// It is less likely that root component replaces a suceeded cardPreview for a failed one
|
|
82
89
|
// than the opposite case. Therefore we prefer to hide the icon instead show when the image fails,
|
|
83
90
|
// for a smoother transition
|
|
84
91
|
|
|
92
|
+
|
|
85
93
|
_this.setState({
|
|
86
94
|
didImageRender: true
|
|
87
95
|
});
|
|
88
96
|
|
|
89
|
-
onImageLoad && onImageLoad();
|
|
97
|
+
onImageLoad && onImageLoad(cardPreview);
|
|
90
98
|
});
|
|
91
99
|
|
|
92
|
-
_defineProperty(_assertThisInitialized(_this), "onImageError", function () {
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "onImageError", function (cardPreview) {
|
|
93
101
|
var onImageError = _this.props.onImageError;
|
|
94
102
|
|
|
95
103
|
_this.setState({
|
|
96
104
|
didImageRender: false
|
|
97
105
|
});
|
|
98
106
|
|
|
99
|
-
onImageError && onImageError();
|
|
107
|
+
onImageError && onImageError(cardPreview);
|
|
100
108
|
});
|
|
101
109
|
|
|
102
110
|
_defineProperty(_assertThisInitialized(_this), "saveElementWidth", function () {
|
|
@@ -118,24 +126,24 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
118
126
|
});
|
|
119
127
|
|
|
120
128
|
_defineProperty(_assertThisInitialized(_this), "renderFileNewExperience", function () {
|
|
121
|
-
var _this$
|
|
122
|
-
dimensions = _this$
|
|
123
|
-
appearance = _this$
|
|
124
|
-
onClick = _this$
|
|
125
|
-
onMouseEnter = _this$
|
|
126
|
-
testId = _this$
|
|
127
|
-
metadata = _this$
|
|
128
|
-
status = _this$
|
|
129
|
-
selected = _this$
|
|
130
|
-
selectable = _this$
|
|
131
|
-
disableOverlay = _this$
|
|
132
|
-
|
|
129
|
+
var _this$props2 = _this.props,
|
|
130
|
+
dimensions = _this$props2.dimensions,
|
|
131
|
+
appearance = _this$props2.appearance,
|
|
132
|
+
onClick = _this$props2.onClick,
|
|
133
|
+
onMouseEnter = _this$props2.onMouseEnter,
|
|
134
|
+
testId = _this$props2.testId,
|
|
135
|
+
metadata = _this$props2.metadata,
|
|
136
|
+
status = _this$props2.status,
|
|
137
|
+
selected = _this$props2.selected,
|
|
138
|
+
selectable = _this$props2.selectable,
|
|
139
|
+
disableOverlay = _this$props2.disableOverlay,
|
|
140
|
+
cardPreview = _this$props2.cardPreview,
|
|
141
|
+
mediaCardCursor = _this$props2.mediaCardCursor;
|
|
133
142
|
|
|
134
143
|
var _ref = metadata || {},
|
|
135
144
|
name = _ref.name;
|
|
136
145
|
|
|
137
|
-
var
|
|
138
|
-
var shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
|
|
146
|
+
var shouldDisplayBackground = !cardPreview || !disableOverlay || status === 'error' || status === 'failed-processing';
|
|
139
147
|
var isPlayButtonClickable = !!(_this.shouldRenderPlayButton() && disableOverlay);
|
|
140
148
|
var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Disable tooltip for Media Single
|
|
141
149
|
|
|
@@ -149,7 +157,7 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
149
157
|
onMouseEnter: onMouseEnter,
|
|
150
158
|
innerRef: _this.divRef,
|
|
151
159
|
breakpoint: _this.breakpoint,
|
|
152
|
-
|
|
160
|
+
mediaCardCursor: mediaCardCursor,
|
|
153
161
|
disableOverlay: !!disableOverlay,
|
|
154
162
|
selected: !!selected,
|
|
155
163
|
displayBackground: shouldDisplayBackground,
|
|
@@ -164,27 +172,30 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
164
172
|
});
|
|
165
173
|
|
|
166
174
|
_defineProperty(_assertThisInitialized(_this), "renderFile", function () {
|
|
167
|
-
var _this$
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
progress = _this$
|
|
173
|
-
resizeMode = _this$
|
|
174
|
-
dimensions = _this$
|
|
175
|
-
selectable = _this$
|
|
176
|
-
selected = _this$
|
|
177
|
-
disableOverlay = _this$
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
actions = _this$props2.actions;
|
|
175
|
+
var _this$props3 = _this.props,
|
|
176
|
+
cardPreview = _this$props3.cardPreview,
|
|
177
|
+
status = _this$props3.status,
|
|
178
|
+
mediaItemType = _this$props3.mediaItemType,
|
|
179
|
+
metadata = _this$props3.metadata,
|
|
180
|
+
progress = _this$props3.progress,
|
|
181
|
+
resizeMode = _this$props3.resizeMode,
|
|
182
|
+
dimensions = _this$props3.dimensions,
|
|
183
|
+
selectable = _this$props3.selectable,
|
|
184
|
+
selected = _this$props3.selected,
|
|
185
|
+
disableOverlay = _this$props3.disableOverlay,
|
|
186
|
+
alt = _this$props3.alt,
|
|
187
|
+
onDisplayImage = _this$props3.onDisplayImage,
|
|
188
|
+
actions = _this$props3.actions;
|
|
182
189
|
|
|
183
|
-
var _ref2 =
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
var _ref2 = cardPreview || {},
|
|
191
|
+
dataURI = _ref2.dataURI,
|
|
192
|
+
orientation = _ref2.orientation;
|
|
193
|
+
|
|
194
|
+
var _ref3 = metadata || {},
|
|
195
|
+
name = _ref3.name,
|
|
196
|
+
mediaType = _ref3.mediaType,
|
|
197
|
+
mimeType = _ref3.mimeType,
|
|
198
|
+
size = _ref3.size;
|
|
188
199
|
|
|
189
200
|
var actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
|
|
190
201
|
var errorMessage = getErrorMessage(status);
|
|
@@ -206,33 +217,34 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
206
217
|
onDisplayImage: onDisplayImage,
|
|
207
218
|
actions: actionsWithDetails,
|
|
208
219
|
disableOverlay: disableOverlay,
|
|
209
|
-
previewOrientation:
|
|
220
|
+
previewOrientation: orientation,
|
|
210
221
|
alt: alt,
|
|
211
222
|
onImageLoad: _this.onImageLoad,
|
|
212
|
-
onImageError: _this.onImageError
|
|
223
|
+
onImageError: _this.onImageError,
|
|
224
|
+
cardPreview: cardPreview
|
|
213
225
|
});
|
|
214
226
|
});
|
|
215
227
|
|
|
216
228
|
_defineProperty(_assertThisInitialized(_this), "getRenderConfigByStatus", function () {
|
|
217
|
-
var _this$
|
|
218
|
-
|
|
219
|
-
status = _this$
|
|
220
|
-
metadata = _this$
|
|
221
|
-
disableOverlay = _this$
|
|
222
|
-
error = _this$
|
|
223
|
-
selectable = _this$
|
|
224
|
-
disableAnimation = _this$
|
|
229
|
+
var _this$props4 = _this.props,
|
|
230
|
+
cardPreview = _this$props4.cardPreview,
|
|
231
|
+
status = _this$props4.status,
|
|
232
|
+
metadata = _this$props4.metadata,
|
|
233
|
+
disableOverlay = _this$props4.disableOverlay,
|
|
234
|
+
error = _this$props4.error,
|
|
235
|
+
selectable = _this$props4.selectable,
|
|
236
|
+
disableAnimation = _this$props4.disableAnimation;
|
|
225
237
|
|
|
226
|
-
var
|
|
227
|
-
name =
|
|
228
|
-
mediaType =
|
|
238
|
+
var _ref4 = metadata || {},
|
|
239
|
+
name = _ref4.name,
|
|
240
|
+
mediaType = _ref4.mediaType;
|
|
229
241
|
|
|
230
242
|
var didImageRender = _this.state.didImageRender;
|
|
231
243
|
var isZeroSize = !!(metadata && metadata.size === 0);
|
|
232
244
|
var defaultConfig = {
|
|
233
245
|
renderTypeIcon: !didImageRender,
|
|
234
|
-
renderImageRenderer: !!
|
|
235
|
-
renderPlayButton: !!
|
|
246
|
+
renderImageRenderer: !!cardPreview,
|
|
247
|
+
renderPlayButton: !!cardPreview && mediaType === 'video',
|
|
236
248
|
renderBlanket: !disableOverlay,
|
|
237
249
|
renderTitleBox: !disableOverlay && !!name,
|
|
238
250
|
renderTickBox: !disableOverlay && !!selectable
|
|
@@ -269,8 +281,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
269
281
|
var iconMessage;
|
|
270
282
|
var customTitleMessage;
|
|
271
283
|
|
|
272
|
-
var
|
|
273
|
-
secondaryError =
|
|
284
|
+
var _ref5 = error || {},
|
|
285
|
+
secondaryError = _ref5.secondaryError;
|
|
274
286
|
|
|
275
287
|
if (isRateLimitedError(secondaryError) || isPollingError(secondaryError)) {
|
|
276
288
|
iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
|
|
@@ -322,14 +334,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
322
334
|
isFixedBlanket = _this$getRenderConfig.isFixedBlanket,
|
|
323
335
|
customTitleMessage = _this$getRenderConfig.customTitleMessage;
|
|
324
336
|
|
|
325
|
-
var _this$
|
|
326
|
-
progress = _this$
|
|
327
|
-
selected = _this$
|
|
328
|
-
status = _this$
|
|
329
|
-
metadata = _this$
|
|
337
|
+
var _this$props5 = _this.props,
|
|
338
|
+
progress = _this$props5.progress,
|
|
339
|
+
selected = _this$props5.selected,
|
|
340
|
+
status = _this$props5.status,
|
|
341
|
+
metadata = _this$props5.metadata;
|
|
330
342
|
|
|
331
|
-
var
|
|
332
|
-
name =
|
|
343
|
+
var _ref6 = metadata || {},
|
|
344
|
+
name = _ref6.name;
|
|
333
345
|
|
|
334
346
|
var hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
|
|
335
347
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardImageContainer, {
|
|
@@ -354,14 +366,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
354
366
|
}
|
|
355
367
|
}, {
|
|
356
368
|
key: "componentDidUpdate",
|
|
357
|
-
value: function componentDidUpdate(
|
|
358
|
-
var
|
|
359
|
-
var
|
|
360
|
-
// when
|
|
369
|
+
value: function componentDidUpdate(_ref7) {
|
|
370
|
+
var prevCardPreview = _ref7.cardPreview;
|
|
371
|
+
var cardPreview = this.props.cardPreview; // We should only switch didImageRender to false
|
|
372
|
+
// when cardPreview goes undefined, not when it is updated.
|
|
361
373
|
// as this method could be triggered after onImageLoad callback,
|
|
362
374
|
// falling on a race condition
|
|
363
375
|
|
|
364
|
-
|
|
376
|
+
!!prevCardPreview && !cardPreview && this.setState({
|
|
365
377
|
didImageRender: false
|
|
366
378
|
});
|
|
367
379
|
}
|
|
@@ -376,10 +388,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
376
388
|
return elementWidth;
|
|
377
389
|
}
|
|
378
390
|
|
|
379
|
-
var
|
|
391
|
+
var _ref8 = this.props.dimensions || {
|
|
380
392
|
width: undefined
|
|
381
393
|
},
|
|
382
|
-
width =
|
|
394
|
+
width = _ref8.width;
|
|
383
395
|
|
|
384
396
|
if (!width) {
|
|
385
397
|
return defaultImageCardDimensions.width;
|
|
@@ -404,12 +416,12 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
404
416
|
return this.renderFileNewExperience();
|
|
405
417
|
}
|
|
406
418
|
|
|
407
|
-
var _this$
|
|
408
|
-
dimensions = _this$
|
|
409
|
-
appearance = _this$
|
|
410
|
-
onClick = _this$
|
|
411
|
-
onMouseEnter = _this$
|
|
412
|
-
testId = _this$
|
|
419
|
+
var _this$props6 = this.props,
|
|
420
|
+
dimensions = _this$props6.dimensions,
|
|
421
|
+
appearance = _this$props6.appearance,
|
|
422
|
+
onClick = _this$props6.onClick,
|
|
423
|
+
onMouseEnter = _this$props6.onMouseEnter,
|
|
424
|
+
testId = _this$props6.testId;
|
|
413
425
|
var wrapperDimensions = dimensions ? dimensions : getDefaultCardDimensions(appearance);
|
|
414
426
|
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
415
427
|
"data-testid": testId || 'media-card-view',
|
|
@@ -432,14 +444,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
432
444
|
}, {
|
|
433
445
|
key: "shouldRenderPlayButton",
|
|
434
446
|
value: function shouldRenderPlayButton() {
|
|
435
|
-
var _this$
|
|
436
|
-
metadata = _this$
|
|
437
|
-
|
|
447
|
+
var _this$props7 = this.props,
|
|
448
|
+
metadata = _this$props7.metadata,
|
|
449
|
+
cardPreview = _this$props7.cardPreview;
|
|
438
450
|
|
|
439
|
-
var
|
|
440
|
-
mediaType =
|
|
451
|
+
var _ref9 = metadata || {},
|
|
452
|
+
mediaType = _ref9.mediaType;
|
|
441
453
|
|
|
442
|
-
if (mediaType !== 'video' || !
|
|
454
|
+
if (mediaType !== 'video' || !cardPreview) {
|
|
443
455
|
return false;
|
|
444
456
|
}
|
|
445
457
|
|
|
@@ -465,14 +477,14 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
465
477
|
}, {
|
|
466
478
|
key: "renderTitleBox",
|
|
467
479
|
value: function renderTitleBox() {
|
|
468
|
-
var _this$
|
|
469
|
-
metadata = _this$
|
|
470
|
-
titleBoxBgColor = _this$
|
|
471
|
-
titleBoxIcon = _this$
|
|
480
|
+
var _this$props8 = this.props,
|
|
481
|
+
metadata = _this$props8.metadata,
|
|
482
|
+
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
483
|
+
titleBoxIcon = _this$props8.titleBoxIcon;
|
|
472
484
|
|
|
473
|
-
var
|
|
474
|
-
name =
|
|
475
|
-
createdAt =
|
|
485
|
+
var _ref10 = metadata || {},
|
|
486
|
+
name = _ref10.name,
|
|
487
|
+
createdAt = _ref10.createdAt;
|
|
476
488
|
|
|
477
489
|
return !!name && /*#__PURE__*/React.createElement(TitleBox, {
|
|
478
490
|
name: name,
|
|
@@ -503,31 +515,27 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
503
515
|
}, {
|
|
504
516
|
key: "renderImageRenderer",
|
|
505
517
|
value: function renderImageRenderer() {
|
|
506
|
-
var _this$
|
|
507
|
-
|
|
508
|
-
_this$
|
|
509
|
-
_this$
|
|
510
|
-
var _this$
|
|
511
|
-
mediaType = _this$
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return !!dataURI && /*#__PURE__*/React.createElement(ImageRenderer, {
|
|
520
|
-
dataURI: dataURI,
|
|
518
|
+
var _this$props9 = this.props,
|
|
519
|
+
cardPreview = _this$props9.cardPreview,
|
|
520
|
+
_this$props9$metadata = _this$props9.metadata;
|
|
521
|
+
_this$props9$metadata = _this$props9$metadata === void 0 ? {} : _this$props9$metadata;
|
|
522
|
+
var _this$props9$metadata2 = _this$props9$metadata.mediaType,
|
|
523
|
+
mediaType = _this$props9$metadata2 === void 0 ? 'unknown' : _this$props9$metadata2,
|
|
524
|
+
alt = _this$props9.alt,
|
|
525
|
+
resizeMode = _this$props9.resizeMode,
|
|
526
|
+
onDisplayImage = _this$props9.onDisplayImage,
|
|
527
|
+
nativeLazyLoad = _this$props9.nativeLazyLoad,
|
|
528
|
+
forceSyncDisplay = _this$props9.forceSyncDisplay;
|
|
529
|
+
return !!cardPreview && /*#__PURE__*/React.createElement(ImageRenderer, {
|
|
530
|
+
cardPreview: cardPreview,
|
|
521
531
|
mediaType: mediaType,
|
|
522
|
-
previewOrientation: previewOrientation,
|
|
523
532
|
alt: alt,
|
|
524
533
|
resizeMode: resizeMode,
|
|
525
534
|
onDisplayImage: onDisplayImage,
|
|
526
535
|
onImageLoad: this.onImageLoad,
|
|
527
536
|
onImageError: this.onImageError,
|
|
528
537
|
nativeLazyLoad: nativeLazyLoad,
|
|
529
|
-
forceSyncDisplay: forceSyncDisplay
|
|
530
|
-
isImageVisible: forceSyncDisplay || didImageRender
|
|
538
|
+
forceSyncDisplay: forceSyncDisplay
|
|
531
539
|
});
|
|
532
540
|
}
|
|
533
541
|
}, {
|
|
@@ -543,10 +551,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
543
551
|
value: function renderMediaTypeIcon(hasTitleBox, iconMessage) {
|
|
544
552
|
var metadata = this.props.metadata;
|
|
545
553
|
|
|
546
|
-
var
|
|
547
|
-
mediaType =
|
|
548
|
-
mimeType =
|
|
549
|
-
name =
|
|
554
|
+
var _ref11 = metadata || {},
|
|
555
|
+
mediaType = _ref11.mediaType,
|
|
556
|
+
mimeType = _ref11.mimeType,
|
|
557
|
+
name = _ref11.name;
|
|
550
558
|
|
|
551
559
|
return /*#__PURE__*/React.createElement(IconWrapper, {
|
|
552
560
|
breakpoint: this.breakpoint,
|
|
@@ -561,10 +569,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
561
569
|
}, {
|
|
562
570
|
key: "renderActionsBar",
|
|
563
571
|
value: function renderActionsBar() {
|
|
564
|
-
var _this$
|
|
565
|
-
disableOverlay = _this$
|
|
566
|
-
actions = _this$
|
|
567
|
-
metadata = _this$
|
|
572
|
+
var _this$props10 = this.props,
|
|
573
|
+
disableOverlay = _this$props10.disableOverlay,
|
|
574
|
+
actions = _this$props10.actions,
|
|
575
|
+
metadata = _this$props10.metadata;
|
|
568
576
|
var actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
|
|
569
577
|
|
|
570
578
|
if (disableOverlay || !actions || actions.length === 0) {
|
|
@@ -581,7 +589,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
581
589
|
}(React.Component);
|
|
582
590
|
|
|
583
591
|
_defineProperty(CardViewBase, "defaultProps", {
|
|
584
|
-
appearance: 'auto'
|
|
592
|
+
appearance: 'auto',
|
|
593
|
+
mediaCardCursor: MediaCardCursor.NoAction
|
|
585
594
|
});
|
|
586
595
|
|
|
587
596
|
export var CardView = withAnalyticsEvents({
|
|
@@ -302,7 +302,8 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
302
302
|
testId = _this$props4.testId,
|
|
303
303
|
identifier = _this$props4.identifier,
|
|
304
304
|
forwardRef = _this$props4.forwardRef,
|
|
305
|
-
autoplay = _this$props4.autoplay
|
|
305
|
+
autoplay = _this$props4.autoplay,
|
|
306
|
+
cardPreview = _this$props4.cardPreview;
|
|
306
307
|
var _this$state = this.state,
|
|
307
308
|
fileSrc = _this$state.fileSrc,
|
|
308
309
|
isUploading = _this$state.isUploading,
|
|
@@ -335,7 +336,8 @@ export var InlinePlayerBase = /*#__PURE__*/function (_Component) {
|
|
|
335
336
|
contentId: identifier.id
|
|
336
337
|
},
|
|
337
338
|
originalDimensions: originalDimensions,
|
|
338
|
-
showControls: checkMouseMovement
|
|
339
|
+
showControls: checkMouseMovement,
|
|
340
|
+
poster: cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.dataURI
|
|
339
341
|
});
|
|
340
342
|
}), isUploading ? /*#__PURE__*/React.createElement(ProgressBar, {
|
|
341
343
|
progress: progress,
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
|
|
4
|
-
var _templateObject;
|
|
5
|
-
|
|
6
2
|
import React, { useEffect } from 'react';
|
|
7
3
|
import { MediaImage } from '@atlaskit/media-ui';
|
|
8
4
|
import { resizeModeToMediaImageProps } from '../../../utils/resizeModeToMediaImageProps';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var dataURI = _ref.dataURI,
|
|
12
|
-
previewOrientation = _ref.previewOrientation,
|
|
5
|
+
export var ImageRenderer = function ImageRenderer(_ref) {
|
|
6
|
+
var cardPreview = _ref.cardPreview,
|
|
13
7
|
alt = _ref.alt,
|
|
14
8
|
resizeMode = _ref.resizeMode,
|
|
15
9
|
onImageLoad = _ref.onImageLoad,
|
|
@@ -17,27 +11,29 @@ export var ImageRendererBase = function ImageRendererBase(_ref) {
|
|
|
17
11
|
onDisplayImage = _ref.onDisplayImage,
|
|
18
12
|
mediaType = _ref.mediaType,
|
|
19
13
|
nativeLazyLoad = _ref.nativeLazyLoad,
|
|
20
|
-
forceSyncDisplay = _ref.forceSyncDisplay
|
|
21
|
-
_ref$className = _ref.className,
|
|
22
|
-
className = _ref$className === void 0 ? 'media-card-image-renderer' : _ref$className;
|
|
14
|
+
forceSyncDisplay = _ref.forceSyncDisplay;
|
|
23
15
|
useEffect(function () {
|
|
24
16
|
// TODO: trigger accordingly with the succeeded event. This could be a breaking change
|
|
25
17
|
if (mediaType === 'image' && onDisplayImage) {
|
|
26
18
|
onDisplayImage();
|
|
27
19
|
}
|
|
28
20
|
}, [mediaType, onDisplayImage]);
|
|
21
|
+
|
|
22
|
+
var onLoad = function onLoad() {
|
|
23
|
+
onImageLoad && onImageLoad(cardPreview);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
var onError = function onError() {
|
|
27
|
+
onImageError && onImageError(cardPreview);
|
|
28
|
+
};
|
|
29
|
+
|
|
29
30
|
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
30
|
-
|
|
31
|
-
dataURI: dataURI,
|
|
31
|
+
dataURI: cardPreview.dataURI,
|
|
32
32
|
alt: alt,
|
|
33
|
-
previewOrientation:
|
|
34
|
-
onImageLoad:
|
|
35
|
-
onImageError:
|
|
33
|
+
previewOrientation: cardPreview.orientation,
|
|
34
|
+
onImageLoad: onLoad,
|
|
35
|
+
onImageError: onError,
|
|
36
36
|
loading: nativeLazyLoad ? 'lazy' : undefined,
|
|
37
37
|
forceSyncDisplay: forceSyncDisplay
|
|
38
38
|
}, resizeModeToMediaImageProps(resizeMode)));
|
|
39
|
-
};
|
|
40
|
-
export var ImageRenderer = styled(ImageRendererBase)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n"])), function (_ref2) {
|
|
41
|
-
var isImageVisible = _ref2.isImageVisible;
|
|
42
|
-
return "\n visibility: ".concat(isImageVisible ? 'visible' : 'hidden', ";\n");
|
|
43
|
-
});
|
|
39
|
+
};
|
|
@@ -61,8 +61,8 @@ var getWrapperShadow = function getWrapperShadow(disableOverlay, selected) {
|
|
|
61
61
|
return shadow ? "box-shadow: ".concat(shadow, ";") : '';
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
var getCursorStyle = function getCursorStyle(
|
|
65
|
-
return "cursor: ".concat(
|
|
64
|
+
var getCursorStyle = function getCursorStyle(cursor) {
|
|
65
|
+
return "cursor: ".concat(cursor, ";");
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
var getClickablePlayButtonStyles = function getClickablePlayButtonStyles(isPlayButtonClickable) {
|
|
@@ -85,14 +85,14 @@ export var NewFileExperienceWrapper = styled.div(_templateObject || (_templateOb
|
|
|
85
85
|
var breakpoint = _ref6.breakpoint,
|
|
86
86
|
dimensions = _ref6.dimensions,
|
|
87
87
|
appearance = _ref6.appearance,
|
|
88
|
-
shouldUsePointerCursor = _ref6.shouldUsePointerCursor,
|
|
89
88
|
disableOverlay = _ref6.disableOverlay,
|
|
90
89
|
displayBackground = _ref6.displayBackground,
|
|
91
90
|
selected = _ref6.selected,
|
|
92
91
|
isPlayButtonClickable = _ref6.isPlayButtonClickable,
|
|
93
92
|
isTickBoxSelectable = _ref6.isTickBoxSelectable,
|
|
94
|
-
shouldDisplayTooltip = _ref6.shouldDisplayTooltip
|
|
95
|
-
|
|
93
|
+
shouldDisplayTooltip = _ref6.shouldDisplayTooltip,
|
|
94
|
+
mediaCardCursor = _ref6.mediaCardCursor;
|
|
95
|
+
return "\n ".concat(transition(), "\n box-sizing: border-box;\n * {\n box-sizing: border-box;\n }\n position: relative;\n font-family: ").concat(fontFamily(), ";\n ").concat(getWrapperDimensions(dimensions, appearance), "\n ").concat(displayBackground ? "background-color: ".concat(N20, ";") : '', "\n ").concat(borderRadius, "\n ").concat(getCursorStyle(mediaCardCursor), "\n ").concat(getWrapperShadow(disableOverlay, selected), "\n ").concat(generateResponsiveStyles(breakpoint), "\n ").concat(hideNativeBrowserTextSelectionStyles, "\n\n /* We use classnames from here exceptionally to be able to handle styles when the Card is on hover */\n ").concat(getClickablePlayButtonStyles(isPlayButtonClickable), "\n ").concat(getSelectableTickBoxStyles(isTickBoxSelectable), "\n &:hover .").concat(blanketClassName, " {\n ").concat(fixedBlanketStyles, "\n }\n\n &:hover .").concat(actionsBarClassName, " {\n ").concat(fixedActionBarStyles, "\n }\n\n /* Tooltip does not support percentage dimensions. We enforce them here */\n ").concat(shouldDisplayTooltip ? "> div { width: 100%; height: 100% }" : '', "\n");
|
|
96
96
|
});
|
|
97
97
|
NewFileExperienceWrapper.displayName = 'NewFileExperienceWrapper';
|
|
98
98
|
export var CardImageContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n position: relative;\n max-width: 100%;\n width: 100%;\n height: 100%;\n max-height: 100%;\n overflow: hidden;\n ", "\n"])), borderRadius);
|
package/dist/esm/types.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
|
|
1
7
|
import { getMediaClientErrorReason, isRequestError } from '@atlaskit/media-client';
|
|
2
8
|
import { ANALYTICS_MEDIA_CHANNEL } from '@atlaskit/media-common';
|
|
3
9
|
import { createAndFireEvent } from '@atlaskit/analytics-next';
|
|
@@ -34,7 +40,7 @@ export var getRenderCommencedEventPayload = function getRenderCommencedEventPayl
|
|
|
34
40
|
}
|
|
35
41
|
};
|
|
36
42
|
};
|
|
37
|
-
export var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes) {
|
|
43
|
+
export var getRenderSucceededEventPayload = function getRenderSucceededEventPayload(fileAttributes, performanceAttributes, ssrReliability) {
|
|
38
44
|
return {
|
|
39
45
|
eventType: 'operational',
|
|
40
46
|
action: 'succeeded',
|
|
@@ -42,7 +48,8 @@ export var getRenderSucceededEventPayload = function getRenderSucceededEventPayl
|
|
|
42
48
|
attributes: {
|
|
43
49
|
fileAttributes: fileAttributes,
|
|
44
50
|
performanceAttributes: performanceAttributes,
|
|
45
|
-
status: 'success'
|
|
51
|
+
status: 'success',
|
|
52
|
+
ssrReliability: ssrReliability
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
55
|
};
|
|
@@ -89,23 +96,29 @@ export var getRenderErrorRequestMetadata = function getRenderErrorRequestMetadat
|
|
|
89
96
|
return error.secondaryError.metadata;
|
|
90
97
|
}
|
|
91
98
|
};
|
|
92
|
-
export var
|
|
99
|
+
export var extractErrorInfo = function extractErrorInfo(error) {
|
|
100
|
+
return {
|
|
101
|
+
failReason: getRenderErrorFailReason(error),
|
|
102
|
+
error: getRenderErrorErrorReason(error),
|
|
103
|
+
errorDetail: getRenderErrorErrorDetail(error)
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error, ssrReliability) {
|
|
93
107
|
return {
|
|
94
108
|
eventType: 'operational',
|
|
95
109
|
action: 'failed',
|
|
96
110
|
actionSubject: 'mediaCardRender',
|
|
97
|
-
attributes: {
|
|
111
|
+
attributes: _objectSpread(_objectSpread({
|
|
98
112
|
fileAttributes: fileAttributes,
|
|
99
113
|
performanceAttributes: performanceAttributes,
|
|
100
|
-
status: 'fail'
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
114
|
+
status: 'fail'
|
|
115
|
+
}, extractErrorInfo(error)), {}, {
|
|
116
|
+
request: getRenderErrorRequestMetadata(error),
|
|
117
|
+
ssrReliability: ssrReliability
|
|
118
|
+
})
|
|
106
119
|
};
|
|
107
120
|
};
|
|
108
|
-
export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes) {
|
|
121
|
+
export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes, ssrReliability) {
|
|
109
122
|
return {
|
|
110
123
|
eventType: 'operational',
|
|
111
124
|
action: 'failed',
|
|
@@ -114,7 +127,8 @@ export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatus
|
|
|
114
127
|
fileAttributes: fileAttributes,
|
|
115
128
|
performanceAttributes: performanceAttributes,
|
|
116
129
|
status: 'fail',
|
|
117
|
-
failReason: 'failed-processing'
|
|
130
|
+
failReason: 'failed-processing',
|
|
131
|
+
ssrReliability: ssrReliability
|
|
118
132
|
}
|
|
119
133
|
};
|
|
120
134
|
};
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { isValidPercentageUnit } from './isValidPercentageUnit';
|
|
2
2
|
import { containsPixelUnit } from './containsPixelUnit';
|
|
3
|
+
|
|
4
|
+
var isPixelEquivalent = function isPixelEquivalent(dimension) {
|
|
5
|
+
return typeof dimension === 'number' || containsPixelUnit("".concat(dimension));
|
|
6
|
+
};
|
|
7
|
+
|
|
3
8
|
export var canCompareDimension = function canCompareDimension(current, next) {
|
|
4
9
|
if (!current || !next) {
|
|
5
10
|
return false;
|
|
6
11
|
}
|
|
7
12
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (containsPixelUnit("".concat(current)) && containsPixelUnit("".concat(next))) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (typeof current === 'number' && typeof next === 'number') {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return false;
|
|
13
|
+
var bothPixelEquivalent = isPixelEquivalent(current) && isPixelEquivalent(next);
|
|
14
|
+
var bothPercentage = isValidPercentageUnit(current) && isValidPercentageUnit(next);
|
|
15
|
+
return bothPixelEquivalent || bothPercentage;
|
|
21
16
|
};
|
|
22
17
|
export var isBigger = function isBigger(current, next) {
|
|
23
18
|
if (!!current && !!next && canCompareDimension(current.width, next.width) && canCompareDimension(current.height, next.height)) {
|