@atlaskit/media-card 72.0.0 → 72.1.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 +22 -0
- package/dist/cjs/errors.js +26 -6
- package/dist/cjs/root/card/cardLoader.js +66 -124
- package/dist/cjs/root/card/getCardPreview/index.js +90 -10
- package/dist/cjs/root/card/index.js +154 -84
- package/dist/cjs/root/cardView.js +41 -54
- package/dist/cjs/root/inline/mediaInlineCard.js +10 -5
- package/dist/cjs/root/ui/common.js +11 -5
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +2 -2
- package/dist/cjs/root/ui/progressBar/progressBar.js +2 -2
- package/dist/cjs/root/ui/progressBar/styled.js +1 -3
- package/dist/cjs/root/ui/styled.js +80 -17
- package/dist/cjs/root/ui/titleBox/styled.js +1 -3
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +16 -9
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/errors.js +9 -1
- package/dist/es2019/root/card/cardLoader.js +47 -53
- package/dist/es2019/root/card/getCardPreview/index.js +45 -3
- package/dist/es2019/root/card/index.js +87 -20
- package/dist/es2019/root/cardView.js +26 -40
- package/dist/es2019/root/inline/mediaInlineCard.js +10 -5
- package/dist/es2019/root/ui/common.js +7 -1
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +1 -1
- package/dist/es2019/root/ui/progressBar/styled.js +1 -2
- package/dist/es2019/root/ui/styled.js +64 -3
- package/dist/es2019/root/ui/titleBox/styled.js +1 -2
- package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
- package/dist/es2019/version.json +1 -1
- package/dist/esm/errors.js +23 -5
- package/dist/esm/root/card/cardLoader.js +66 -126
- package/dist/esm/root/card/getCardPreview/index.js +72 -10
- package/dist/esm/root/card/index.js +156 -85
- package/dist/esm/root/cardView.js +40 -52
- package/dist/esm/root/inline/mediaInlineCard.js +10 -5
- package/dist/esm/root/ui/common.js +7 -1
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +6 -2
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +1 -1
- package/dist/esm/root/ui/progressBar/styled.js +1 -2
- package/dist/esm/root/ui/styled.js +61 -13
- package/dist/esm/root/ui/titleBox/styled.js +1 -2
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +16 -9
- package/dist/esm/version.json +1 -1
- package/dist/types/errors.d.ts +9 -3
- package/dist/types/index.d.ts +2 -1
- package/dist/types/root/card/cardLoader.d.ts +4 -18
- package/dist/types/root/card/getCardPreview/index.d.ts +7 -1
- package/dist/types/root/card/index.d.ts +2 -0
- package/dist/types/root/cardView.d.ts +3 -1
- package/dist/types/root/ui/common.d.ts +4 -1
- package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +3 -2
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -1
- package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
- package/dist/types/root/ui/progressBar/progressBar.d.ts +1 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +1 -1
- package/dist/types/root/ui/styled.d.ts +10 -3
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +1 -1
- package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
- package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/example-helpers/developmentUseMessage.tsx +14 -0
- package/example-helpers/index.tsx +34 -4
- package/example-helpers/selectableCard.tsx +2 -1
- package/package.json +8 -5
- package/dist/cjs/root/card/cardSSRView.js +0 -114
- package/dist/cjs/root/ui/Breakpoint.js +0 -13
- package/dist/cjs/root/ui/styledSSR.js +0 -108
- package/dist/es2019/root/card/cardSSRView.js +0 -93
- package/dist/es2019/root/ui/Breakpoint.js +0 -6
- package/dist/es2019/root/ui/styledSSR.js +0 -93
- package/dist/esm/root/card/cardSSRView.js +0 -92
- package/dist/esm/root/ui/Breakpoint.js +0 -6
- package/dist/esm/root/ui/styledSSR.js +0 -76
- package/dist/types/root/card/cardSSRView.d.ts +0 -13
- package/dist/types/root/ui/Breakpoint.d.ts +0 -4
- package/dist/types/root/ui/styledSSR.d.ts +0 -16
|
@@ -146,6 +146,26 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
146
146
|
mediaBlobUrlAttrs: _this.getMediaBlobUrlAttrs(identifier, fileState)
|
|
147
147
|
};
|
|
148
148
|
});
|
|
149
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setCacheSSRPreview", function (identifier) {
|
|
150
|
+
var _this$props3 = _this.props,
|
|
151
|
+
mediaClient = _this$props3.mediaClient,
|
|
152
|
+
_this$props3$dimensio = _this$props3.dimensions,
|
|
153
|
+
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
154
|
+
(0, _getCardPreview.fetchAndCacheRemotePreview)(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier)).catch(function () {// No need to log this error.
|
|
155
|
+
// If preview fails, it will be refetched later
|
|
156
|
+
//TODO: test this catch
|
|
157
|
+
// https://product-fabric.atlassian.net/browse/MEX-1071
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolveSSRPreview", function (identifier, ssr) {
|
|
161
|
+
var mediaClient = _this.props.mediaClient;
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
return (0, _getCardPreview.getSSRCardPreview)(ssr, mediaClient, identifier.id, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
165
|
+
} catch (e) {// TODO: log SSR reliability 'failed'
|
|
166
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
167
|
+
}
|
|
168
|
+
});
|
|
149
169
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
150
170
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(identifier, fileState) {
|
|
151
171
|
var params, cardPreview, wrappedError;
|
|
@@ -215,20 +235,31 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
215
235
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onImageError", function () {
|
|
216
236
|
var cardPreview = _this.state.cardPreview;
|
|
217
237
|
var error = new _errors.ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
|
|
238
|
+
var isLocal = cardPreview && (0, _getCardPreview.isLocalPreview)(cardPreview);
|
|
239
|
+
var isSSR = cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview);
|
|
218
240
|
|
|
219
|
-
if (
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
224
|
-
(0, _mediaClient.isFileIdentifier)(identifier) && (0, _getCardPreview.removeCardPreviewFromCache)(identifier.id, dimensions);
|
|
241
|
+
if (isLocal || isSSR) {
|
|
242
|
+
var updateState = {
|
|
243
|
+
cardPreview: undefined
|
|
244
|
+
};
|
|
225
245
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
246
|
+
if (isLocal) {
|
|
247
|
+
updateState.isBannedLocalPreview = true;
|
|
248
|
+
|
|
249
|
+
_this.fireLocalPreviewErrorEvent(error);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (isSSR) {// TODO: set SSR-client reliability 'failed'.
|
|
253
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
254
|
+
}
|
|
230
255
|
|
|
231
|
-
_this.
|
|
256
|
+
var _this$props4 = _this.props,
|
|
257
|
+
identifier = _this$props4.identifier,
|
|
258
|
+
_this$props4$dimensio = _this$props4.dimensions,
|
|
259
|
+
dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
|
|
260
|
+
(0, _mediaClient.isFileIdentifier)(identifier) && (0, _getCardPreview.removeCardPreviewFromCache)(identifier.id, dimensions);
|
|
261
|
+
|
|
262
|
+
_this.safeSetState(updateState);
|
|
232
263
|
} else {
|
|
233
264
|
_this.safeSetState({
|
|
234
265
|
status: 'error',
|
|
@@ -276,10 +307,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
276
307
|
}
|
|
277
308
|
});
|
|
278
309
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
279
|
-
var _this$
|
|
280
|
-
identifier = _this$
|
|
281
|
-
useInlinePlayer = _this$
|
|
282
|
-
shouldOpenMediaViewer = _this$
|
|
310
|
+
var _this$props5 = _this.props,
|
|
311
|
+
identifier = _this$props5.identifier,
|
|
312
|
+
useInlinePlayer = _this$props5.useInlinePlayer,
|
|
313
|
+
shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
|
|
283
314
|
var cardPreview = _this.state.cardPreview;
|
|
284
315
|
|
|
285
316
|
var _assertThisInitialize2 = (0, _assertThisInitialized2.default)(_this),
|
|
@@ -331,13 +362,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
331
362
|
});
|
|
332
363
|
});
|
|
333
364
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderInlinePlayer", function () {
|
|
334
|
-
var _this$
|
|
335
|
-
identifier = _this$
|
|
336
|
-
mediaClient = _this$
|
|
337
|
-
dimensions = _this$
|
|
338
|
-
selected = _this$
|
|
339
|
-
testId = _this$
|
|
340
|
-
originalDimensions = _this$
|
|
365
|
+
var _this$props6 = _this.props,
|
|
366
|
+
identifier = _this$props6.identifier,
|
|
367
|
+
mediaClient = _this$props6.mediaClient,
|
|
368
|
+
dimensions = _this$props6.dimensions,
|
|
369
|
+
selected = _this$props6.selected,
|
|
370
|
+
testId = _this$props6.testId,
|
|
371
|
+
originalDimensions = _this$props6.originalDimensions;
|
|
341
372
|
return /*#__PURE__*/_react.default.createElement(_inlinePlayer.InlinePlayer, {
|
|
342
373
|
mediaClient: mediaClient,
|
|
343
374
|
dimensions: dimensions,
|
|
@@ -377,12 +408,12 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
377
408
|
});
|
|
378
409
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderMediaViewer", function () {
|
|
379
410
|
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
380
|
-
var _this$
|
|
381
|
-
mediaClient = _this$
|
|
382
|
-
identifier = _this$
|
|
383
|
-
mediaViewerDataSource = _this$
|
|
384
|
-
contextId = _this$
|
|
385
|
-
featureFlags = _this$
|
|
411
|
+
var _this$props7 = _this.props,
|
|
412
|
+
mediaClient = _this$props7.mediaClient,
|
|
413
|
+
identifier = _this$props7.identifier,
|
|
414
|
+
mediaViewerDataSource = _this$props7.mediaViewerDataSource,
|
|
415
|
+
contextId = _this$props7.contextId,
|
|
416
|
+
featureFlags = _this$props7.featureFlags;
|
|
386
417
|
|
|
387
418
|
if (!mediaViewerSelectedItem) {
|
|
388
419
|
return;
|
|
@@ -403,20 +434,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
403
434
|
}), document.body);
|
|
404
435
|
});
|
|
405
436
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderCard", function () {
|
|
406
|
-
var _this$
|
|
407
|
-
identifier = _this$
|
|
408
|
-
isLazy = _this$
|
|
409
|
-
appearance = _this$
|
|
410
|
-
resizeMode = _this$
|
|
411
|
-
dimensions = _this$
|
|
412
|
-
selectable = _this$
|
|
413
|
-
selected = _this$
|
|
414
|
-
disableOverlay = _this$
|
|
415
|
-
alt = _this$
|
|
416
|
-
testId = _this$
|
|
417
|
-
featureFlags = _this$
|
|
418
|
-
titleBoxBgColor = _this$
|
|
419
|
-
titleBoxIcon = _this$
|
|
437
|
+
var _this$props8 = _this.props,
|
|
438
|
+
identifier = _this$props8.identifier,
|
|
439
|
+
isLazy = _this$props8.isLazy,
|
|
440
|
+
appearance = _this$props8.appearance,
|
|
441
|
+
resizeMode = _this$props8.resizeMode,
|
|
442
|
+
dimensions = _this$props8.dimensions,
|
|
443
|
+
selectable = _this$props8.selectable,
|
|
444
|
+
selected = _this$props8.selected,
|
|
445
|
+
disableOverlay = _this$props8.disableOverlay,
|
|
446
|
+
alt = _this$props8.alt,
|
|
447
|
+
testId = _this$props8.testId,
|
|
448
|
+
featureFlags = _this$props8.featureFlags,
|
|
449
|
+
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
450
|
+
titleBoxIcon = _this$props8.titleBoxIcon,
|
|
451
|
+
ssr = _this$props8.ssr;
|
|
420
452
|
var mediaItemType = identifier.mediaItemType;
|
|
421
453
|
var _this$state = _this.state,
|
|
422
454
|
status = _this$state.status,
|
|
@@ -429,7 +461,8 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
429
461
|
var dataURI = _this$state$cardPrevi.dataURI,
|
|
430
462
|
orientation = _this$state$cardPrevi.orientation,
|
|
431
463
|
error = _this$state.error,
|
|
432
|
-
cardRef = _this$state.cardRef
|
|
464
|
+
cardRef = _this$state.cardRef,
|
|
465
|
+
isCardVisible = _this$state.isCardVisible;
|
|
433
466
|
|
|
434
467
|
var _assertThisInitialize3 = (0, _assertThisInitialized2.default)(_this),
|
|
435
468
|
metadata = _assertThisInitialize3.metadata;
|
|
@@ -438,7 +471,13 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
438
471
|
onCardViewClick = _assertThisInitialize4.onCardViewClick,
|
|
439
472
|
onDisplayImage = _assertThisInitialize4.onDisplayImage,
|
|
440
473
|
actions = _assertThisInitialize4.actions,
|
|
441
|
-
onMouseEnter = _assertThisInitialize4.onMouseEnter;
|
|
474
|
+
onMouseEnter = _assertThisInitialize4.onMouseEnter; // Card can be artificially turned visible before entering the viewport
|
|
475
|
+
// For example, when we have the image in cache
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
var nativeLazyLoad = isLazy && !isCardVisible; // Force Media Image to always display img for SSR
|
|
479
|
+
|
|
480
|
+
var forceSyncDisplay = !!ssr;
|
|
442
481
|
|
|
443
482
|
var card = /*#__PURE__*/_react.default.createElement(_cardView.CardView, {
|
|
444
483
|
status: status,
|
|
@@ -465,7 +504,9 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
465
504
|
titleBoxBgColor: titleBoxBgColor,
|
|
466
505
|
titleBoxIcon: titleBoxIcon,
|
|
467
506
|
onImageError: _this.onImageError,
|
|
468
|
-
onImageLoad: _this.onImageLoad
|
|
507
|
+
onImageLoad: _this.onImageLoad,
|
|
508
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
509
|
+
forceSyncDisplay: forceSyncDisplay
|
|
469
510
|
});
|
|
470
511
|
|
|
471
512
|
return isLazy ? /*#__PURE__*/_react.default.createElement(_viewportDetector.ViewportDetector, {
|
|
@@ -510,14 +551,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
510
551
|
|
|
511
552
|
var _cardPreview;
|
|
512
553
|
|
|
513
|
-
var _this$
|
|
514
|
-
_identifier = _this$
|
|
515
|
-
_this$
|
|
516
|
-
_dimensions = _this$
|
|
554
|
+
var _this$props9 = _this.props,
|
|
555
|
+
_identifier = _this$props9.identifier,
|
|
556
|
+
_this$props9$dimensio = _this$props9.dimensions,
|
|
557
|
+
_dimensions = _this$props9$dimensio === void 0 ? {} : _this$props9$dimensio,
|
|
558
|
+
_ssr = _this$props9.ssr;
|
|
517
559
|
|
|
518
560
|
if ((0, _mediaClient.isFileIdentifier)(_identifier)) {
|
|
519
561
|
var id = _identifier.id;
|
|
520
562
|
_cardPreview = (0, _getCardPreview.getCardPreviewFromCache)(id, _dimensions);
|
|
563
|
+
|
|
564
|
+
if (!_cardPreview && _ssr) {
|
|
565
|
+
_this.fireCommencedEvent();
|
|
566
|
+
|
|
567
|
+
_cardPreview = _this.resolveSSRPreview(_identifier, _ssr);
|
|
568
|
+
}
|
|
521
569
|
} else if ((0, _mediaClient.isExternalImageIdentifier)(_identifier)) {
|
|
522
570
|
_this.fireCommencedEvent();
|
|
523
571
|
|
|
@@ -528,14 +576,17 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
528
576
|
orientation: 1,
|
|
529
577
|
source: 'external'
|
|
530
578
|
};
|
|
531
|
-
} //
|
|
532
|
-
//
|
|
579
|
+
} // If cardPreview is available from local cache or external, `isCardVisible`
|
|
580
|
+
// should be true to avoid flickers during re-mount of the component
|
|
581
|
+
// should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
|
|
582
|
+
// outside the viewport
|
|
583
|
+
|
|
533
584
|
|
|
585
|
+
var _isCardVisible = !_this.props.isLazy || !!_cardPreview && !(0, _getCardPreview.isSSRPreview)(_cardPreview);
|
|
534
586
|
|
|
535
|
-
var isCardVisible = _cardPreview ? true : !_this.props.isLazy;
|
|
536
587
|
_this.state = {
|
|
537
588
|
status: _status,
|
|
538
|
-
isCardVisible:
|
|
589
|
+
isCardVisible: _isCardVisible,
|
|
539
590
|
isPlayingFile: false,
|
|
540
591
|
cardPreview: _cardPreview,
|
|
541
592
|
cardRef: null,
|
|
@@ -549,11 +600,21 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
549
600
|
key: "componentDidMount",
|
|
550
601
|
value: function componentDidMount() {
|
|
551
602
|
this.hasBeenMounted = true;
|
|
552
|
-
var
|
|
553
|
-
|
|
603
|
+
var _this$state2 = this.state,
|
|
604
|
+
isCardVisible = _this$state2.isCardVisible,
|
|
605
|
+
cardPreview = _this$state2.cardPreview;
|
|
606
|
+
var _this$props10 = this.props,
|
|
607
|
+
identifier = _this$props10.identifier,
|
|
608
|
+
ssr = _this$props10.ssr;
|
|
554
609
|
|
|
555
610
|
if (isCardVisible && (0, _mediaClient.isFileIdentifier)(identifier)) {
|
|
556
611
|
this.updateStateForIdentifier(identifier);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (isCardVisible && !!ssr && !!cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview) && (0, _mediaClient.isFileIdentifier)(identifier)) {
|
|
615
|
+
// Since the SSR preview brings the token in the query params,
|
|
616
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
617
|
+
this.setCacheSSRPreview(identifier);
|
|
557
618
|
} // we add a listener for each of the cards on the page
|
|
558
619
|
// and then check if the triggered listener is from the card
|
|
559
620
|
// that contains a div in current window.getSelection()
|
|
@@ -569,18 +630,18 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
569
630
|
prevIdentifier = prevProps.identifier,
|
|
570
631
|
prevDimensions = prevProps.dimensions;
|
|
571
632
|
var prevIsCardVisible = prevState.isCardVisible;
|
|
572
|
-
var _this$
|
|
573
|
-
mediaClient = _this$
|
|
574
|
-
identifier = _this$
|
|
575
|
-
dimensions = _this$
|
|
576
|
-
featureFlags = _this$
|
|
577
|
-
var _this$
|
|
578
|
-
isCardVisible = _this$
|
|
579
|
-
cardPreview = _this$
|
|
580
|
-
status = _this$
|
|
581
|
-
fileState = _this$
|
|
582
|
-
isBannedLocalPreview = _this$
|
|
583
|
-
previewDidRender = _this$
|
|
633
|
+
var _this$props11 = this.props,
|
|
634
|
+
mediaClient = _this$props11.mediaClient,
|
|
635
|
+
identifier = _this$props11.identifier,
|
|
636
|
+
dimensions = _this$props11.dimensions,
|
|
637
|
+
featureFlags = _this$props11.featureFlags;
|
|
638
|
+
var _this$state3 = this.state,
|
|
639
|
+
isCardVisible = _this$state3.isCardVisible,
|
|
640
|
+
cardPreview = _this$state3.cardPreview,
|
|
641
|
+
status = _this$state3.status,
|
|
642
|
+
fileState = _this$state3.fileState,
|
|
643
|
+
isBannedLocalPreview = _this$state3.isBannedLocalPreview,
|
|
644
|
+
previewDidRender = _this$state3.previewDidRender;
|
|
584
645
|
var isDifferent = (0, _mediaClient.isDifferentIdentifier)(prevIdentifier, identifier);
|
|
585
646
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
586
647
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
@@ -623,8 +684,14 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
623
684
|
this.resolvePreview(identifier, fileState);
|
|
624
685
|
}
|
|
625
686
|
|
|
687
|
+
if (turnedVisible && this.props.ssr && !!cardPreview && (0, _getCardPreview.isSSRClientPreview)(cardPreview) && (0, _mediaClient.isFileIdentifier)(identifier)) {
|
|
688
|
+
// Since the SSR preview brings the token in the query params,
|
|
689
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
690
|
+
this.setCacheSSRPreview(identifier);
|
|
691
|
+
}
|
|
692
|
+
|
|
626
693
|
if (previewDidRender && // We should't complete if status is uploading
|
|
627
|
-
['loading
|
|
694
|
+
['loading-preview', 'processing'].includes(status)) {
|
|
628
695
|
this.safeSetState({
|
|
629
696
|
status: 'complete'
|
|
630
697
|
});
|
|
@@ -680,7 +747,10 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
680
747
|
key: "requestedDimensions",
|
|
681
748
|
get: function get() {
|
|
682
749
|
var dimensions = this.props.dimensions;
|
|
683
|
-
|
|
750
|
+
|
|
751
|
+
var _ref3 = this.state || {},
|
|
752
|
+
element = _ref3.cardRef;
|
|
753
|
+
|
|
684
754
|
return (0, _getDataURIDimension.getRequestedDimensions)({
|
|
685
755
|
dimensions: dimensions,
|
|
686
756
|
element: element
|
|
@@ -689,23 +759,23 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
689
759
|
}, {
|
|
690
760
|
key: "metadata",
|
|
691
761
|
get: function get() {
|
|
692
|
-
var _this$
|
|
762
|
+
var _this$state4;
|
|
693
763
|
|
|
694
|
-
return (0, _metadata.getFileDetails)(this.props.identifier, (_this$
|
|
764
|
+
return (0, _metadata.getFileDetails)(this.props.identifier, (_this$state4 = this.state) === null || _this$state4 === void 0 ? void 0 : _this$state4.fileState);
|
|
695
765
|
}
|
|
696
766
|
}, {
|
|
697
767
|
key: "fileAttributes",
|
|
698
768
|
get: function get() {
|
|
699
|
-
var _this$
|
|
769
|
+
var _this$state5, _this$state5$fileStat;
|
|
700
770
|
|
|
701
|
-
return (0, _analytics.getFileAttributes)(this.metadata, (_this$
|
|
771
|
+
return (0, _analytics.getFileAttributes)(this.metadata, (_this$state5 = this.state) === null || _this$state5 === void 0 ? void 0 : (_this$state5$fileStat = _this$state5.fileState) === null || _this$state5$fileStat === void 0 ? void 0 : _this$state5$fileStat.status);
|
|
702
772
|
}
|
|
703
773
|
}, {
|
|
704
774
|
key: "fireOperationalEvent",
|
|
705
775
|
value: function fireOperationalEvent() {
|
|
706
|
-
var _this$
|
|
707
|
-
status = _this$
|
|
708
|
-
error = _this$
|
|
776
|
+
var _this$state6 = this.state,
|
|
777
|
+
status = _this$state6.status,
|
|
778
|
+
error = _this$state6.error;
|
|
709
779
|
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
710
780
|
createAnalyticsEvent && (0, _cardAnalytics.fireOperationalEvent)(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
|
|
711
781
|
}
|
|
@@ -725,11 +795,11 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
725
795
|
get: function get() {
|
|
726
796
|
var _this3 = this;
|
|
727
797
|
|
|
728
|
-
var _this$
|
|
729
|
-
_this$
|
|
730
|
-
actions = _this$
|
|
731
|
-
identifier = _this$
|
|
732
|
-
shouldEnableDownloadButton = _this$
|
|
798
|
+
var _this$props12 = this.props,
|
|
799
|
+
_this$props12$actions = _this$props12.actions,
|
|
800
|
+
actions = _this$props12$actions === void 0 ? [] : _this$props12$actions,
|
|
801
|
+
identifier = _this$props12.identifier,
|
|
802
|
+
shouldEnableDownloadButton = _this$props12.shouldEnableDownloadButton;
|
|
733
803
|
var status = this.state.status;
|
|
734
804
|
var metadata = this.metadata;
|
|
735
805
|
|
|
@@ -751,9 +821,9 @@ var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
751
821
|
}, {
|
|
752
822
|
key: "render",
|
|
753
823
|
value: function render() {
|
|
754
|
-
var _this$
|
|
755
|
-
isPlayingFile = _this$
|
|
756
|
-
mediaViewerSelectedItem = _this$
|
|
824
|
+
var _this$state7 = this.state,
|
|
825
|
+
isPlayingFile = _this$state7.isPlayingFile,
|
|
826
|
+
mediaViewerSelectedItem = _this$state7.mediaViewerSelectedItem;
|
|
757
827
|
|
|
758
828
|
var innerContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null);
|
|
759
829
|
|
|
@@ -51,8 +51,6 @@ var _mediaUi = require("@atlaskit/media-ui");
|
|
|
51
51
|
|
|
52
52
|
var _styled2 = require("./ui/styled");
|
|
53
53
|
|
|
54
|
-
var _styledSSR = require("./ui/styledSSR");
|
|
55
|
-
|
|
56
54
|
var _imageRenderer = require("./ui/imageRenderer/imageRenderer");
|
|
57
55
|
|
|
58
56
|
var _titleBox = require("./ui/titleBox/titleBox");
|
|
@@ -178,11 +176,9 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
178
176
|
var shouldUsePointerCursor = status !== 'error' && status !== 'failed-processing';
|
|
179
177
|
var shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
|
|
180
178
|
var isPlayButtonClickable = !!(_this.shouldRenderPlayButton() && disableOverlay);
|
|
181
|
-
var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; //
|
|
182
|
-
// Intention is to show full file name when it's truncate in titlebox,
|
|
183
|
-
// and to hide it when no titlebox exists.
|
|
179
|
+
var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Disable tooltip for Media Single
|
|
184
180
|
|
|
185
|
-
var shouldDisplayTooltip =
|
|
181
|
+
var shouldDisplayTooltip = !disableOverlay;
|
|
186
182
|
return /*#__PURE__*/_react.default.createElement(_styled2.NewFileExperienceWrapper, {
|
|
187
183
|
className: _cardConstants.newFileExperienceClassName,
|
|
188
184
|
"data-testid": testId || 'media-card-view',
|
|
@@ -308,40 +304,29 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
308
304
|
});
|
|
309
305
|
|
|
310
306
|
var iconMessage;
|
|
307
|
+
var customTitleMessage;
|
|
311
308
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
var secondaryError = error.secondaryError;
|
|
315
|
-
|
|
316
|
-
if ((0, _mediaClient.isRateLimitedError)(secondaryError) || secondaryError && (0, _mediaClient.isPollingError)(secondaryError)) {
|
|
317
|
-
iconMessage = /*#__PURE__*/_react.default.createElement(_iconMessage.PreviewCurrentlyUnavailable, null);
|
|
318
|
-
}
|
|
319
|
-
} else if (!isZeroSize) {
|
|
320
|
-
iconMessage = /*#__PURE__*/_react.default.createElement(_iconMessage.PreviewUnavailable, null);
|
|
321
|
-
}
|
|
322
|
-
} else if (!!disableOverlay) {
|
|
323
|
-
iconMessage = /*#__PURE__*/_react.default.createElement(_iconMessage.FailedToLoad, null);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (error && (0, _errors.isUploadError)(error)) {
|
|
327
|
-
if (!disableOverlay) {
|
|
328
|
-
return _objectSpread(_objectSpread({}, baseErrorConfig), {}, {
|
|
329
|
-
renderFailedTitleBox: true,
|
|
330
|
-
customTitleMessage: _mediaUi.messages.failed_to_upload
|
|
331
|
-
});
|
|
332
|
-
}
|
|
309
|
+
var _ref4 = error || {},
|
|
310
|
+
secondaryError = _ref4.secondaryError;
|
|
333
311
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
312
|
+
if ((0, _mediaClient.isRateLimitedError)(secondaryError) || (0, _mediaClient.isPollingError)(secondaryError)) {
|
|
313
|
+
iconMessage = /*#__PURE__*/_react.default.createElement(_iconMessage.PreviewCurrentlyUnavailable, null);
|
|
314
|
+
} else if ((0, _errors.isUploadError)(error)) {
|
|
315
|
+
iconMessage = /*#__PURE__*/_react.default.createElement(_iconMessage.FailedToUpload, null);
|
|
316
|
+
customTitleMessage = _mediaUi.messages.failed_to_upload;
|
|
317
|
+
} else if (!metadata) {
|
|
318
|
+
iconMessage = /*#__PURE__*/_react.default.createElement(_iconMessage.FailedToLoad, null);
|
|
319
|
+
} else {
|
|
320
|
+
iconMessage = /*#__PURE__*/_react.default.createElement(_iconMessage.PreviewUnavailable, null);
|
|
338
321
|
}
|
|
339
322
|
|
|
340
323
|
if (!disableOverlay) {
|
|
324
|
+
var renderFailedTitleBox = !name || !!customTitleMessage;
|
|
341
325
|
return _objectSpread(_objectSpread({}, baseErrorConfig), {}, {
|
|
342
|
-
renderTitleBox: !!name,
|
|
343
|
-
renderFailedTitleBox:
|
|
344
|
-
iconMessage: iconMessage
|
|
326
|
+
renderTitleBox: !!name && !customTitleMessage,
|
|
327
|
+
renderFailedTitleBox: renderFailedTitleBox,
|
|
328
|
+
iconMessage: !renderFailedTitleBox ? iconMessage : undefined,
|
|
329
|
+
customTitleMessage: customTitleMessage
|
|
345
330
|
});
|
|
346
331
|
}
|
|
347
332
|
|
|
@@ -379,11 +364,11 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
379
364
|
status = _this$props4.status,
|
|
380
365
|
metadata = _this$props4.metadata;
|
|
381
366
|
|
|
382
|
-
var
|
|
383
|
-
name =
|
|
367
|
+
var _ref5 = metadata || {},
|
|
368
|
+
name = _ref5.name;
|
|
384
369
|
|
|
385
370
|
var hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
|
|
386
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
371
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_styled2.CardImageContainer, {
|
|
387
372
|
className: "media-file-card-view",
|
|
388
373
|
"data-testid": "media-file-card-view",
|
|
389
374
|
"data-test-media-name": name,
|
|
@@ -404,8 +389,8 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
404
389
|
}
|
|
405
390
|
}, {
|
|
406
391
|
key: "componentDidUpdate",
|
|
407
|
-
value: function componentDidUpdate(
|
|
408
|
-
var prevDataURI =
|
|
392
|
+
value: function componentDidUpdate(_ref6) {
|
|
393
|
+
var prevDataURI = _ref6.dataURI;
|
|
409
394
|
var dataURI = this.props.dataURI; // We should only switch didImageRender to false
|
|
410
395
|
// when dataURI goes undefined, not when it is updated.
|
|
411
396
|
// as this method could be triggered after onImageLoad callback,
|
|
@@ -426,10 +411,10 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
426
411
|
return elementWidth;
|
|
427
412
|
}
|
|
428
413
|
|
|
429
|
-
var
|
|
414
|
+
var _ref7 = this.props.dimensions || {
|
|
430
415
|
width: undefined
|
|
431
416
|
},
|
|
432
|
-
width =
|
|
417
|
+
width = _ref7.width;
|
|
433
418
|
|
|
434
419
|
if (!width) {
|
|
435
420
|
return _cardDimensions.defaultImageCardDimensions.width;
|
|
@@ -441,7 +426,7 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
441
426
|
key: "breakpoint",
|
|
442
427
|
get: function get() {
|
|
443
428
|
var width = this.state.elementWidth || (this.props.dimensions ? this.props.dimensions.width : '') || _cardDimensions.defaultImageCardDimensions.width;
|
|
444
|
-
return (0,
|
|
429
|
+
return (0, _styled2.calcBreakpointSize)(parseInt("".concat(width), 10));
|
|
445
430
|
} // If the dimensions.width is a percentage, we need to transform it
|
|
446
431
|
// into a pixel value in order to get the right breakpoints applied.
|
|
447
432
|
|
|
@@ -486,8 +471,8 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
486
471
|
metadata = _this$props6.metadata,
|
|
487
472
|
dataURI = _this$props6.dataURI;
|
|
488
473
|
|
|
489
|
-
var
|
|
490
|
-
mediaType =
|
|
474
|
+
var _ref8 = metadata || {},
|
|
475
|
+
mediaType = _ref8.mediaType;
|
|
491
476
|
|
|
492
477
|
if (mediaType !== 'video' || !dataURI) {
|
|
493
478
|
return false;
|
|
@@ -520,9 +505,9 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
520
505
|
titleBoxBgColor = _this$props7.titleBoxBgColor,
|
|
521
506
|
titleBoxIcon = _this$props7.titleBoxIcon;
|
|
522
507
|
|
|
523
|
-
var
|
|
524
|
-
name =
|
|
525
|
-
createdAt =
|
|
508
|
+
var _ref9 = metadata || {},
|
|
509
|
+
name = _ref9.name,
|
|
510
|
+
createdAt = _ref9.createdAt;
|
|
526
511
|
|
|
527
512
|
return !!name && /*#__PURE__*/_react.default.createElement(_titleBox.TitleBox, {
|
|
528
513
|
name: name,
|
|
@@ -563,17 +548,19 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
563
548
|
alt = _this$props8.alt,
|
|
564
549
|
resizeMode = _this$props8.resizeMode,
|
|
565
550
|
onDisplayImage = _this$props8.onDisplayImage,
|
|
566
|
-
|
|
551
|
+
nativeLazyLoad = _this$props8.nativeLazyLoad,
|
|
552
|
+
forceSyncDisplay = _this$props8.forceSyncDisplay;
|
|
567
553
|
return !!dataURI && /*#__PURE__*/_react.default.createElement(_imageRenderer.ImageRenderer, {
|
|
568
554
|
dataURI: dataURI,
|
|
569
555
|
mediaType: mediaType,
|
|
570
|
-
mediaItemType: mediaItemType,
|
|
571
556
|
previewOrientation: previewOrientation,
|
|
572
557
|
alt: alt,
|
|
573
558
|
resizeMode: resizeMode,
|
|
574
559
|
onDisplayImage: onDisplayImage,
|
|
575
560
|
onImageLoad: this.onImageLoad,
|
|
576
|
-
onImageError: this.onImageError
|
|
561
|
+
onImageError: this.onImageError,
|
|
562
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
563
|
+
forceSyncDisplay: forceSyncDisplay
|
|
577
564
|
});
|
|
578
565
|
}
|
|
579
566
|
}, {
|
|
@@ -589,10 +576,10 @@ var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
589
576
|
value: function renderMediaTypeIcon(hasTitleBox, iconMessage) {
|
|
590
577
|
var metadata = this.props.metadata;
|
|
591
578
|
|
|
592
|
-
var
|
|
593
|
-
mediaType =
|
|
594
|
-
mimeType =
|
|
595
|
-
name =
|
|
579
|
+
var _ref10 = metadata || {},
|
|
580
|
+
mediaType = _ref10.mediaType,
|
|
581
|
+
mimeType = _ref10.mimeType,
|
|
582
|
+
name = _ref10.name;
|
|
596
583
|
|
|
597
584
|
return /*#__PURE__*/_react.default.createElement(_styled4.IconWrapper, {
|
|
598
585
|
breakpoint: this.breakpoint,
|
|
@@ -102,31 +102,36 @@ var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
102
102
|
|
|
103
103
|
if (!fileState) {
|
|
104
104
|
return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadingView, {
|
|
105
|
-
message: intl.formatMessage(_mediaUi.messages.loading_file)
|
|
105
|
+
message: intl.formatMessage(_mediaUi.messages.loading_file),
|
|
106
|
+
isSelected: isSelected
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
if (isErrored) {
|
|
110
111
|
return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
|
|
111
|
-
message: intl.formatMessage(_mediaUi.messages.couldnt_load_file)
|
|
112
|
+
message: intl.formatMessage(_mediaUi.messages.couldnt_load_file),
|
|
113
|
+
isSelected: isSelected
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
if (fileState.status === 'error') {
|
|
116
118
|
return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
|
|
117
|
-
message: fileState.message || ''
|
|
119
|
+
message: fileState.message || '',
|
|
120
|
+
isSelected: isSelected
|
|
118
121
|
});
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
if (fileState.status === 'failed-processing') {
|
|
122
125
|
return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardErroredView, {
|
|
123
|
-
message: intl.formatMessage(_mediaUi.messages.couldnt_load_file)
|
|
126
|
+
message: intl.formatMessage(_mediaUi.messages.couldnt_load_file),
|
|
127
|
+
isSelected: isSelected
|
|
124
128
|
});
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
if (fileState.status === 'uploading') {
|
|
128
132
|
return /*#__PURE__*/_react.default.createElement(_mediaUi.MediaInlineCardLoadingView, {
|
|
129
|
-
message: fileState.name
|
|
133
|
+
message: fileState.name,
|
|
134
|
+
isSelected: isSelected
|
|
130
135
|
});
|
|
131
136
|
}
|
|
132
137
|
|
|
@@ -5,22 +5,28 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getTitleBoxHeight = exports.responsiveSettings = void 0;
|
|
8
|
+
exports.getTitleBoxHeight = exports.responsiveSettings = exports.Breakpoint = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
|
-
var _Breakpoint = require("./Breakpoint");
|
|
13
|
-
|
|
14
12
|
var _responsiveSettings;
|
|
15
13
|
|
|
16
|
-
var
|
|
14
|
+
var Breakpoint;
|
|
15
|
+
exports.Breakpoint = Breakpoint;
|
|
16
|
+
|
|
17
|
+
(function (Breakpoint) {
|
|
18
|
+
Breakpoint["SMALL"] = "small";
|
|
19
|
+
Breakpoint["LARGE"] = "large";
|
|
20
|
+
})(Breakpoint || (exports.Breakpoint = Breakpoint = {}));
|
|
21
|
+
|
|
22
|
+
var responsiveSettings = (_responsiveSettings = {}, (0, _defineProperty2.default)(_responsiveSettings, Breakpoint.SMALL, {
|
|
17
23
|
fontSize: 11,
|
|
18
24
|
lineHeight: 14,
|
|
19
25
|
titleBox: {
|
|
20
26
|
verticalPadding: 4,
|
|
21
27
|
horizontalPadding: 8
|
|
22
28
|
}
|
|
23
|
-
}), (0, _defineProperty2.default)(_responsiveSettings,
|
|
29
|
+
}), (0, _defineProperty2.default)(_responsiveSettings, Breakpoint.LARGE, {
|
|
24
30
|
fontSize: 14,
|
|
25
31
|
lineHeight: 22,
|
|
26
32
|
titleBox: {
|