@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
|
@@ -29,7 +29,7 @@ import { IntlProvider, intlShape } from 'react-intl';
|
|
|
29
29
|
import { CardView } from '../cardView';
|
|
30
30
|
import { ViewportDetector } from '../../utils/viewportDetector';
|
|
31
31
|
import { getRequestedDimensions } from '../../utils/getDataURIDimension';
|
|
32
|
-
import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview } from './getCardPreview';
|
|
32
|
+
import { getCardPreview, getCardPreviewFromCache, removeCardPreviewFromCache, getFilePreviewFromFileState, shouldResolvePreview, getSSRCardPreview, isLocalPreview, isSSRPreview, isSSRClientPreview, fetchAndCacheRemotePreview } from './getCardPreview';
|
|
33
33
|
import { getFileDetails } from '../../utils/metadata';
|
|
34
34
|
import { InlinePlayer } from '../inlinePlayer';
|
|
35
35
|
import { getFileAttributes } from '../../utils/analytics';
|
|
@@ -109,6 +109,28 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
109
109
|
};
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
+
_defineProperty(_assertThisInitialized(_this), "setCacheSSRPreview", function (identifier) {
|
|
113
|
+
var _this$props3 = _this.props,
|
|
114
|
+
mediaClient = _this$props3.mediaClient,
|
|
115
|
+
_this$props3$dimensio = _this$props3.dimensions,
|
|
116
|
+
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
117
|
+
fetchAndCacheRemotePreview(mediaClient, identifier.id, dimensions, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier)).catch(function () {// No need to log this error.
|
|
118
|
+
// If preview fails, it will be refetched later
|
|
119
|
+
//TODO: test this catch
|
|
120
|
+
// https://product-fabric.atlassian.net/browse/MEX-1071
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
_defineProperty(_assertThisInitialized(_this), "resolveSSRPreview", function (identifier, ssr) {
|
|
125
|
+
var mediaClient = _this.props.mediaClient;
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
return getSSRCardPreview(ssr, mediaClient, identifier.id, _this.getImageURLParams(identifier), _this.getMediaBlobUrlAttrs(identifier));
|
|
129
|
+
} catch (e) {// TODO: log SSR reliability 'failed'
|
|
130
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
112
134
|
_defineProperty(_assertThisInitialized(_this), "resolvePreview", /*#__PURE__*/function () {
|
|
113
135
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(identifier, fileState) {
|
|
114
136
|
var params, cardPreview, wrappedError;
|
|
@@ -180,20 +202,31 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
180
202
|
_defineProperty(_assertThisInitialized(_this), "onImageError", function () {
|
|
181
203
|
var cardPreview = _this.state.cardPreview;
|
|
182
204
|
var error = new ImageLoadError(cardPreview === null || cardPreview === void 0 ? void 0 : cardPreview.source);
|
|
205
|
+
var isLocal = cardPreview && isLocalPreview(cardPreview);
|
|
206
|
+
var isSSR = cardPreview && isSSRClientPreview(cardPreview);
|
|
183
207
|
|
|
184
|
-
if (
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
dimensions = _this$props3$dimensio === void 0 ? {} : _this$props3$dimensio;
|
|
189
|
-
isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, dimensions);
|
|
208
|
+
if (isLocal || isSSR) {
|
|
209
|
+
var updateState = {
|
|
210
|
+
cardPreview: undefined
|
|
211
|
+
};
|
|
190
212
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
isBannedLocalPreview: true
|
|
194
|
-
});
|
|
213
|
+
if (isLocal) {
|
|
214
|
+
updateState.isBannedLocalPreview = true;
|
|
195
215
|
|
|
196
|
-
|
|
216
|
+
_this.fireLocalPreviewErrorEvent(error);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (isSSR) {// TODO: set SSR-client reliability 'failed'.
|
|
220
|
+
// https://product-fabric.atlassian.net/browse/MEX-770
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
var _this$props4 = _this.props,
|
|
224
|
+
identifier = _this$props4.identifier,
|
|
225
|
+
_this$props4$dimensio = _this$props4.dimensions,
|
|
226
|
+
dimensions = _this$props4$dimensio === void 0 ? {} : _this$props4$dimensio;
|
|
227
|
+
isFileIdentifier(identifier) && removeCardPreviewFromCache(identifier.id, dimensions);
|
|
228
|
+
|
|
229
|
+
_this.safeSetState(updateState);
|
|
197
230
|
} else {
|
|
198
231
|
_this.safeSetState({
|
|
199
232
|
status: 'error',
|
|
@@ -248,10 +281,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
248
281
|
});
|
|
249
282
|
|
|
250
283
|
_defineProperty(_assertThisInitialized(_this), "onCardViewClick", function (event, analyticsEvent) {
|
|
251
|
-
var _this$
|
|
252
|
-
identifier = _this$
|
|
253
|
-
useInlinePlayer = _this$
|
|
254
|
-
shouldOpenMediaViewer = _this$
|
|
284
|
+
var _this$props5 = _this.props,
|
|
285
|
+
identifier = _this$props5.identifier,
|
|
286
|
+
useInlinePlayer = _this$props5.useInlinePlayer,
|
|
287
|
+
shouldOpenMediaViewer = _this$props5.shouldOpenMediaViewer;
|
|
255
288
|
var cardPreview = _this.state.cardPreview;
|
|
256
289
|
|
|
257
290
|
var _assertThisInitialize2 = _assertThisInitialized(_this),
|
|
@@ -306,13 +339,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
306
339
|
});
|
|
307
340
|
|
|
308
341
|
_defineProperty(_assertThisInitialized(_this), "renderInlinePlayer", function () {
|
|
309
|
-
var _this$
|
|
310
|
-
identifier = _this$
|
|
311
|
-
mediaClient = _this$
|
|
312
|
-
dimensions = _this$
|
|
313
|
-
selected = _this$
|
|
314
|
-
testId = _this$
|
|
315
|
-
originalDimensions = _this$
|
|
342
|
+
var _this$props6 = _this.props,
|
|
343
|
+
identifier = _this$props6.identifier,
|
|
344
|
+
mediaClient = _this$props6.mediaClient,
|
|
345
|
+
dimensions = _this$props6.dimensions,
|
|
346
|
+
selected = _this$props6.selected,
|
|
347
|
+
testId = _this$props6.testId,
|
|
348
|
+
originalDimensions = _this$props6.originalDimensions;
|
|
316
349
|
return /*#__PURE__*/React.createElement(InlinePlayer, {
|
|
317
350
|
mediaClient: mediaClient,
|
|
318
351
|
dimensions: dimensions,
|
|
@@ -355,12 +388,12 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
355
388
|
|
|
356
389
|
_defineProperty(_assertThisInitialized(_this), "renderMediaViewer", function () {
|
|
357
390
|
var mediaViewerSelectedItem = _this.state.mediaViewerSelectedItem;
|
|
358
|
-
var _this$
|
|
359
|
-
mediaClient = _this$
|
|
360
|
-
identifier = _this$
|
|
361
|
-
mediaViewerDataSource = _this$
|
|
362
|
-
contextId = _this$
|
|
363
|
-
featureFlags = _this$
|
|
391
|
+
var _this$props7 = _this.props,
|
|
392
|
+
mediaClient = _this$props7.mediaClient,
|
|
393
|
+
identifier = _this$props7.identifier,
|
|
394
|
+
mediaViewerDataSource = _this$props7.mediaViewerDataSource,
|
|
395
|
+
contextId = _this$props7.contextId,
|
|
396
|
+
featureFlags = _this$props7.featureFlags;
|
|
364
397
|
|
|
365
398
|
if (!mediaViewerSelectedItem) {
|
|
366
399
|
return;
|
|
@@ -382,20 +415,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
382
415
|
});
|
|
383
416
|
|
|
384
417
|
_defineProperty(_assertThisInitialized(_this), "renderCard", function () {
|
|
385
|
-
var _this$
|
|
386
|
-
identifier = _this$
|
|
387
|
-
isLazy = _this$
|
|
388
|
-
appearance = _this$
|
|
389
|
-
resizeMode = _this$
|
|
390
|
-
dimensions = _this$
|
|
391
|
-
selectable = _this$
|
|
392
|
-
selected = _this$
|
|
393
|
-
disableOverlay = _this$
|
|
394
|
-
alt = _this$
|
|
395
|
-
testId = _this$
|
|
396
|
-
featureFlags = _this$
|
|
397
|
-
titleBoxBgColor = _this$
|
|
398
|
-
titleBoxIcon = _this$
|
|
418
|
+
var _this$props8 = _this.props,
|
|
419
|
+
identifier = _this$props8.identifier,
|
|
420
|
+
isLazy = _this$props8.isLazy,
|
|
421
|
+
appearance = _this$props8.appearance,
|
|
422
|
+
resizeMode = _this$props8.resizeMode,
|
|
423
|
+
dimensions = _this$props8.dimensions,
|
|
424
|
+
selectable = _this$props8.selectable,
|
|
425
|
+
selected = _this$props8.selected,
|
|
426
|
+
disableOverlay = _this$props8.disableOverlay,
|
|
427
|
+
alt = _this$props8.alt,
|
|
428
|
+
testId = _this$props8.testId,
|
|
429
|
+
featureFlags = _this$props8.featureFlags,
|
|
430
|
+
titleBoxBgColor = _this$props8.titleBoxBgColor,
|
|
431
|
+
titleBoxIcon = _this$props8.titleBoxIcon,
|
|
432
|
+
ssr = _this$props8.ssr;
|
|
399
433
|
var mediaItemType = identifier.mediaItemType;
|
|
400
434
|
var _this$state = _this.state,
|
|
401
435
|
status = _this$state.status,
|
|
@@ -408,7 +442,8 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
408
442
|
var dataURI = _this$state$cardPrevi.dataURI,
|
|
409
443
|
orientation = _this$state$cardPrevi.orientation,
|
|
410
444
|
error = _this$state.error,
|
|
411
|
-
cardRef = _this$state.cardRef
|
|
445
|
+
cardRef = _this$state.cardRef,
|
|
446
|
+
isCardVisible = _this$state.isCardVisible;
|
|
412
447
|
|
|
413
448
|
var _assertThisInitialize3 = _assertThisInitialized(_this),
|
|
414
449
|
metadata = _assertThisInitialize3.metadata;
|
|
@@ -417,8 +452,13 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
417
452
|
onCardViewClick = _assertThisInitialize4.onCardViewClick,
|
|
418
453
|
onDisplayImage = _assertThisInitialize4.onDisplayImage,
|
|
419
454
|
actions = _assertThisInitialize4.actions,
|
|
420
|
-
onMouseEnter = _assertThisInitialize4.onMouseEnter;
|
|
455
|
+
onMouseEnter = _assertThisInitialize4.onMouseEnter; // Card can be artificially turned visible before entering the viewport
|
|
456
|
+
// For example, when we have the image in cache
|
|
421
457
|
|
|
458
|
+
|
|
459
|
+
var nativeLazyLoad = isLazy && !isCardVisible; // Force Media Image to always display img for SSR
|
|
460
|
+
|
|
461
|
+
var forceSyncDisplay = !!ssr;
|
|
422
462
|
var card = /*#__PURE__*/React.createElement(CardView, {
|
|
423
463
|
status: status,
|
|
424
464
|
error: error,
|
|
@@ -444,7 +484,9 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
444
484
|
titleBoxBgColor: titleBoxBgColor,
|
|
445
485
|
titleBoxIcon: titleBoxIcon,
|
|
446
486
|
onImageError: _this.onImageError,
|
|
447
|
-
onImageLoad: _this.onImageLoad
|
|
487
|
+
onImageLoad: _this.onImageLoad,
|
|
488
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
489
|
+
forceSyncDisplay: forceSyncDisplay
|
|
448
490
|
});
|
|
449
491
|
return isLazy ? /*#__PURE__*/React.createElement(ViewportDetector, {
|
|
450
492
|
targetRef: cardRef,
|
|
@@ -492,14 +534,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
492
534
|
|
|
493
535
|
var _cardPreview;
|
|
494
536
|
|
|
495
|
-
var _this$
|
|
496
|
-
_identifier = _this$
|
|
497
|
-
_this$
|
|
498
|
-
_dimensions = _this$
|
|
537
|
+
var _this$props9 = _this.props,
|
|
538
|
+
_identifier = _this$props9.identifier,
|
|
539
|
+
_this$props9$dimensio = _this$props9.dimensions,
|
|
540
|
+
_dimensions = _this$props9$dimensio === void 0 ? {} : _this$props9$dimensio,
|
|
541
|
+
_ssr = _this$props9.ssr;
|
|
499
542
|
|
|
500
543
|
if (isFileIdentifier(_identifier)) {
|
|
501
544
|
var id = _identifier.id;
|
|
502
545
|
_cardPreview = getCardPreviewFromCache(id, _dimensions);
|
|
546
|
+
|
|
547
|
+
if (!_cardPreview && _ssr) {
|
|
548
|
+
_this.fireCommencedEvent();
|
|
549
|
+
|
|
550
|
+
_cardPreview = _this.resolveSSRPreview(_identifier, _ssr);
|
|
551
|
+
}
|
|
503
552
|
} else if (isExternalImageIdentifier(_identifier)) {
|
|
504
553
|
_this.fireCommencedEvent();
|
|
505
554
|
|
|
@@ -510,14 +559,17 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
510
559
|
orientation: 1,
|
|
511
560
|
source: 'external'
|
|
512
561
|
};
|
|
513
|
-
} //
|
|
514
|
-
//
|
|
562
|
+
} // If cardPreview is available from local cache or external, `isCardVisible`
|
|
563
|
+
// should be true to avoid flickers during re-mount of the component
|
|
564
|
+
// should not be visible for SSR preview, otherwise we'll fire the metadata fetch from
|
|
565
|
+
// outside the viewport
|
|
566
|
+
|
|
515
567
|
|
|
568
|
+
var _isCardVisible = !_this.props.isLazy || !!_cardPreview && !isSSRPreview(_cardPreview);
|
|
516
569
|
|
|
517
|
-
var isCardVisible = _cardPreview ? true : !_this.props.isLazy;
|
|
518
570
|
_this.state = {
|
|
519
571
|
status: _status,
|
|
520
|
-
isCardVisible:
|
|
572
|
+
isCardVisible: _isCardVisible,
|
|
521
573
|
isPlayingFile: false,
|
|
522
574
|
cardPreview: _cardPreview,
|
|
523
575
|
cardRef: null,
|
|
@@ -531,11 +583,21 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
531
583
|
key: "componentDidMount",
|
|
532
584
|
value: function componentDidMount() {
|
|
533
585
|
this.hasBeenMounted = true;
|
|
534
|
-
var
|
|
535
|
-
|
|
586
|
+
var _this$state2 = this.state,
|
|
587
|
+
isCardVisible = _this$state2.isCardVisible,
|
|
588
|
+
cardPreview = _this$state2.cardPreview;
|
|
589
|
+
var _this$props10 = this.props,
|
|
590
|
+
identifier = _this$props10.identifier,
|
|
591
|
+
ssr = _this$props10.ssr;
|
|
536
592
|
|
|
537
593
|
if (isCardVisible && isFileIdentifier(identifier)) {
|
|
538
594
|
this.updateStateForIdentifier(identifier);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (isCardVisible && !!ssr && !!cardPreview && isSSRClientPreview(cardPreview) && isFileIdentifier(identifier)) {
|
|
598
|
+
// Since the SSR preview brings the token in the query params,
|
|
599
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
600
|
+
this.setCacheSSRPreview(identifier);
|
|
539
601
|
} // we add a listener for each of the cards on the page
|
|
540
602
|
// and then check if the triggered listener is from the card
|
|
541
603
|
// that contains a div in current window.getSelection()
|
|
@@ -551,18 +613,18 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
551
613
|
prevIdentifier = prevProps.identifier,
|
|
552
614
|
prevDimensions = prevProps.dimensions;
|
|
553
615
|
var prevIsCardVisible = prevState.isCardVisible;
|
|
554
|
-
var _this$
|
|
555
|
-
mediaClient = _this$
|
|
556
|
-
identifier = _this$
|
|
557
|
-
dimensions = _this$
|
|
558
|
-
featureFlags = _this$
|
|
559
|
-
var _this$
|
|
560
|
-
isCardVisible = _this$
|
|
561
|
-
cardPreview = _this$
|
|
562
|
-
status = _this$
|
|
563
|
-
fileState = _this$
|
|
564
|
-
isBannedLocalPreview = _this$
|
|
565
|
-
previewDidRender = _this$
|
|
616
|
+
var _this$props11 = this.props,
|
|
617
|
+
mediaClient = _this$props11.mediaClient,
|
|
618
|
+
identifier = _this$props11.identifier,
|
|
619
|
+
dimensions = _this$props11.dimensions,
|
|
620
|
+
featureFlags = _this$props11.featureFlags;
|
|
621
|
+
var _this$state3 = this.state,
|
|
622
|
+
isCardVisible = _this$state3.isCardVisible,
|
|
623
|
+
cardPreview = _this$state3.cardPreview,
|
|
624
|
+
status = _this$state3.status,
|
|
625
|
+
fileState = _this$state3.fileState,
|
|
626
|
+
isBannedLocalPreview = _this$state3.isBannedLocalPreview,
|
|
627
|
+
previewDidRender = _this$state3.previewDidRender;
|
|
566
628
|
var isDifferent = isDifferentIdentifier(prevIdentifier, identifier);
|
|
567
629
|
var turnedVisible = !prevIsCardVisible && isCardVisible;
|
|
568
630
|
var isNewMediaClient = prevMediaClient !== mediaClient;
|
|
@@ -605,8 +667,14 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
605
667
|
this.resolvePreview(identifier, fileState);
|
|
606
668
|
}
|
|
607
669
|
|
|
670
|
+
if (turnedVisible && this.props.ssr && !!cardPreview && isSSRClientPreview(cardPreview) && isFileIdentifier(identifier)) {
|
|
671
|
+
// Since the SSR preview brings the token in the query params,
|
|
672
|
+
// We need to fetch the remote preview to be able to cache it,
|
|
673
|
+
this.setCacheSSRPreview(identifier);
|
|
674
|
+
}
|
|
675
|
+
|
|
608
676
|
if (previewDidRender && // We should't complete if status is uploading
|
|
609
|
-
['loading
|
|
677
|
+
['loading-preview', 'processing'].includes(status)) {
|
|
610
678
|
this.safeSetState({
|
|
611
679
|
status: 'complete'
|
|
612
680
|
});
|
|
@@ -662,7 +730,10 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
662
730
|
key: "requestedDimensions",
|
|
663
731
|
get: function get() {
|
|
664
732
|
var dimensions = this.props.dimensions;
|
|
665
|
-
|
|
733
|
+
|
|
734
|
+
var _ref3 = this.state || {},
|
|
735
|
+
element = _ref3.cardRef;
|
|
736
|
+
|
|
666
737
|
return getRequestedDimensions({
|
|
667
738
|
dimensions: dimensions,
|
|
668
739
|
element: element
|
|
@@ -671,23 +742,23 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
671
742
|
}, {
|
|
672
743
|
key: "metadata",
|
|
673
744
|
get: function get() {
|
|
674
|
-
var _this$
|
|
745
|
+
var _this$state4;
|
|
675
746
|
|
|
676
|
-
return getFileDetails(this.props.identifier, (_this$
|
|
747
|
+
return getFileDetails(this.props.identifier, (_this$state4 = this.state) === null || _this$state4 === void 0 ? void 0 : _this$state4.fileState);
|
|
677
748
|
}
|
|
678
749
|
}, {
|
|
679
750
|
key: "fileAttributes",
|
|
680
751
|
get: function get() {
|
|
681
|
-
var _this$
|
|
752
|
+
var _this$state5, _this$state5$fileStat;
|
|
682
753
|
|
|
683
|
-
return getFileAttributes(this.metadata, (_this$
|
|
754
|
+
return 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);
|
|
684
755
|
}
|
|
685
756
|
}, {
|
|
686
757
|
key: "fireOperationalEvent",
|
|
687
758
|
value: function fireOperationalEvent() {
|
|
688
|
-
var _this$
|
|
689
|
-
status = _this$
|
|
690
|
-
error = _this$
|
|
759
|
+
var _this$state6 = this.state,
|
|
760
|
+
status = _this$state6.status,
|
|
761
|
+
error = _this$state6.error;
|
|
691
762
|
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
692
763
|
createAnalyticsEvent && _fireOperationalEvent(createAnalyticsEvent, status, this.fileAttributes, this.getPerformanceAttributes(), error);
|
|
693
764
|
}
|
|
@@ -707,11 +778,11 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
707
778
|
get: function get() {
|
|
708
779
|
var _this3 = this;
|
|
709
780
|
|
|
710
|
-
var _this$
|
|
711
|
-
_this$
|
|
712
|
-
actions = _this$
|
|
713
|
-
identifier = _this$
|
|
714
|
-
shouldEnableDownloadButton = _this$
|
|
781
|
+
var _this$props12 = this.props,
|
|
782
|
+
_this$props12$actions = _this$props12.actions,
|
|
783
|
+
actions = _this$props12$actions === void 0 ? [] : _this$props12$actions,
|
|
784
|
+
identifier = _this$props12.identifier,
|
|
785
|
+
shouldEnableDownloadButton = _this$props12.shouldEnableDownloadButton;
|
|
715
786
|
var status = this.state.status;
|
|
716
787
|
var metadata = this.metadata;
|
|
717
788
|
|
|
@@ -733,9 +804,9 @@ export var CardBase = /*#__PURE__*/function (_Component) {
|
|
|
733
804
|
}, {
|
|
734
805
|
key: "render",
|
|
735
806
|
value: function render() {
|
|
736
|
-
var _this$
|
|
737
|
-
isPlayingFile = _this$
|
|
738
|
-
mediaViewerSelectedItem = _this$
|
|
807
|
+
var _this$state7 = this.state,
|
|
808
|
+
isPlayingFile = _this$state7.isPlayingFile,
|
|
809
|
+
mediaViewerSelectedItem = _this$state7.mediaViewerSelectedItem;
|
|
739
810
|
var innerContent = /*#__PURE__*/React.createElement(React.Fragment, null, isPlayingFile ? this.renderInlinePlayer() : this.renderCard(), mediaViewerSelectedItem ? this.renderMediaViewer() : null);
|
|
740
811
|
return this.context.intl ? innerContent : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
741
812
|
locale: "en"
|
|
@@ -28,8 +28,7 @@ import { createAndFireMediaCardEvent } from '../utils/analytics';
|
|
|
28
28
|
import { attachDetailsToActions } from '../actions';
|
|
29
29
|
import { getErrorMessage } from '../utils/getErrorMessage';
|
|
30
30
|
import { toHumanReadableMediaSize, messages } from '@atlaskit/media-ui';
|
|
31
|
-
import { NewFileExperienceWrapper } from './ui/styled';
|
|
32
|
-
import { CardImageContainer, calcBreakpointSize } from './ui/styledSSR';
|
|
31
|
+
import { NewFileExperienceWrapper, CardImageContainer, calcBreakpointSize } from './ui/styled';
|
|
33
32
|
import { ImageRenderer } from './ui/imageRenderer/imageRenderer';
|
|
34
33
|
import { TitleBox } from './ui/titleBox/titleBox';
|
|
35
34
|
import { FailedTitleBox } from './ui/titleBox/failedTitleBox';
|
|
@@ -138,11 +137,9 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
138
137
|
var shouldUsePointerCursor = status !== 'error' && status !== 'failed-processing';
|
|
139
138
|
var shouldDisplayBackground = !dataURI || !disableOverlay || status === 'error' || status === 'failed-processing';
|
|
140
139
|
var isPlayButtonClickable = !!(_this.shouldRenderPlayButton() && disableOverlay);
|
|
141
|
-
var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; //
|
|
142
|
-
// Intention is to show full file name when it's truncate in titlebox,
|
|
143
|
-
// and to hide it when no titlebox exists.
|
|
140
|
+
var isTickBoxSelectable = !disableOverlay && !!selectable && !selected; // Disable tooltip for Media Single
|
|
144
141
|
|
|
145
|
-
var shouldDisplayTooltip =
|
|
142
|
+
var shouldDisplayTooltip = !disableOverlay;
|
|
146
143
|
return /*#__PURE__*/React.createElement(NewFileExperienceWrapper, {
|
|
147
144
|
className: newFileExperienceClassName,
|
|
148
145
|
"data-testid": testId || 'media-card-view',
|
|
@@ -270,40 +267,29 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
270
267
|
});
|
|
271
268
|
|
|
272
269
|
var iconMessage;
|
|
270
|
+
var customTitleMessage;
|
|
273
271
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
var secondaryError = error.secondaryError;
|
|
277
|
-
|
|
278
|
-
if (isRateLimitedError(secondaryError) || secondaryError && isPollingError(secondaryError)) {
|
|
279
|
-
iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
|
|
280
|
-
}
|
|
281
|
-
} else if (!isZeroSize) {
|
|
282
|
-
iconMessage = /*#__PURE__*/React.createElement(PreviewUnavailable, null);
|
|
283
|
-
}
|
|
284
|
-
} else if (!!disableOverlay) {
|
|
285
|
-
iconMessage = /*#__PURE__*/React.createElement(FailedToLoad, null);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (error && isUploadError(error)) {
|
|
289
|
-
if (!disableOverlay) {
|
|
290
|
-
return _objectSpread(_objectSpread({}, baseErrorConfig), {}, {
|
|
291
|
-
renderFailedTitleBox: true,
|
|
292
|
-
customTitleMessage: messages.failed_to_upload
|
|
293
|
-
});
|
|
294
|
-
}
|
|
272
|
+
var _ref4 = error || {},
|
|
273
|
+
secondaryError = _ref4.secondaryError;
|
|
295
274
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
275
|
+
if (isRateLimitedError(secondaryError) || isPollingError(secondaryError)) {
|
|
276
|
+
iconMessage = /*#__PURE__*/React.createElement(PreviewCurrentlyUnavailable, null);
|
|
277
|
+
} else if (isUploadError(error)) {
|
|
278
|
+
iconMessage = /*#__PURE__*/React.createElement(FailedToUpload, null);
|
|
279
|
+
customTitleMessage = messages.failed_to_upload;
|
|
280
|
+
} else if (!metadata) {
|
|
281
|
+
iconMessage = /*#__PURE__*/React.createElement(FailedToLoad, null);
|
|
282
|
+
} else {
|
|
283
|
+
iconMessage = /*#__PURE__*/React.createElement(PreviewUnavailable, null);
|
|
300
284
|
}
|
|
301
285
|
|
|
302
286
|
if (!disableOverlay) {
|
|
287
|
+
var renderFailedTitleBox = !name || !!customTitleMessage;
|
|
303
288
|
return _objectSpread(_objectSpread({}, baseErrorConfig), {}, {
|
|
304
|
-
renderTitleBox: !!name,
|
|
305
|
-
renderFailedTitleBox:
|
|
306
|
-
iconMessage: iconMessage
|
|
289
|
+
renderTitleBox: !!name && !customTitleMessage,
|
|
290
|
+
renderFailedTitleBox: renderFailedTitleBox,
|
|
291
|
+
iconMessage: !renderFailedTitleBox ? iconMessage : undefined,
|
|
292
|
+
customTitleMessage: customTitleMessage
|
|
307
293
|
});
|
|
308
294
|
}
|
|
309
295
|
|
|
@@ -342,8 +328,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
342
328
|
status = _this$props4.status,
|
|
343
329
|
metadata = _this$props4.metadata;
|
|
344
330
|
|
|
345
|
-
var
|
|
346
|
-
name =
|
|
331
|
+
var _ref5 = metadata || {},
|
|
332
|
+
name = _ref5.name;
|
|
347
333
|
|
|
348
334
|
var hasTitleBox = !!renderTitleBox || !!renderFailedTitleBox;
|
|
349
335
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CardImageContainer, {
|
|
@@ -368,8 +354,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
368
354
|
}
|
|
369
355
|
}, {
|
|
370
356
|
key: "componentDidUpdate",
|
|
371
|
-
value: function componentDidUpdate(
|
|
372
|
-
var prevDataURI =
|
|
357
|
+
value: function componentDidUpdate(_ref6) {
|
|
358
|
+
var prevDataURI = _ref6.dataURI;
|
|
373
359
|
var dataURI = this.props.dataURI; // We should only switch didImageRender to false
|
|
374
360
|
// when dataURI goes undefined, not when it is updated.
|
|
375
361
|
// as this method could be triggered after onImageLoad callback,
|
|
@@ -390,10 +376,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
390
376
|
return elementWidth;
|
|
391
377
|
}
|
|
392
378
|
|
|
393
|
-
var
|
|
379
|
+
var _ref7 = this.props.dimensions || {
|
|
394
380
|
width: undefined
|
|
395
381
|
},
|
|
396
|
-
width =
|
|
382
|
+
width = _ref7.width;
|
|
397
383
|
|
|
398
384
|
if (!width) {
|
|
399
385
|
return defaultImageCardDimensions.width;
|
|
@@ -450,8 +436,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
450
436
|
metadata = _this$props6.metadata,
|
|
451
437
|
dataURI = _this$props6.dataURI;
|
|
452
438
|
|
|
453
|
-
var
|
|
454
|
-
mediaType =
|
|
439
|
+
var _ref8 = metadata || {},
|
|
440
|
+
mediaType = _ref8.mediaType;
|
|
455
441
|
|
|
456
442
|
if (mediaType !== 'video' || !dataURI) {
|
|
457
443
|
return false;
|
|
@@ -484,9 +470,9 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
484
470
|
titleBoxBgColor = _this$props7.titleBoxBgColor,
|
|
485
471
|
titleBoxIcon = _this$props7.titleBoxIcon;
|
|
486
472
|
|
|
487
|
-
var
|
|
488
|
-
name =
|
|
489
|
-
createdAt =
|
|
473
|
+
var _ref9 = metadata || {},
|
|
474
|
+
name = _ref9.name,
|
|
475
|
+
createdAt = _ref9.createdAt;
|
|
490
476
|
|
|
491
477
|
return !!name && /*#__PURE__*/React.createElement(TitleBox, {
|
|
492
478
|
name: name,
|
|
@@ -527,17 +513,19 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
527
513
|
alt = _this$props8.alt,
|
|
528
514
|
resizeMode = _this$props8.resizeMode,
|
|
529
515
|
onDisplayImage = _this$props8.onDisplayImage,
|
|
530
|
-
|
|
516
|
+
nativeLazyLoad = _this$props8.nativeLazyLoad,
|
|
517
|
+
forceSyncDisplay = _this$props8.forceSyncDisplay;
|
|
531
518
|
return !!dataURI && /*#__PURE__*/React.createElement(ImageRenderer, {
|
|
532
519
|
dataURI: dataURI,
|
|
533
520
|
mediaType: mediaType,
|
|
534
|
-
mediaItemType: mediaItemType,
|
|
535
521
|
previewOrientation: previewOrientation,
|
|
536
522
|
alt: alt,
|
|
537
523
|
resizeMode: resizeMode,
|
|
538
524
|
onDisplayImage: onDisplayImage,
|
|
539
525
|
onImageLoad: this.onImageLoad,
|
|
540
|
-
onImageError: this.onImageError
|
|
526
|
+
onImageError: this.onImageError,
|
|
527
|
+
nativeLazyLoad: nativeLazyLoad,
|
|
528
|
+
forceSyncDisplay: forceSyncDisplay
|
|
541
529
|
});
|
|
542
530
|
}
|
|
543
531
|
}, {
|
|
@@ -553,10 +541,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
553
541
|
value: function renderMediaTypeIcon(hasTitleBox, iconMessage) {
|
|
554
542
|
var metadata = this.props.metadata;
|
|
555
543
|
|
|
556
|
-
var
|
|
557
|
-
mediaType =
|
|
558
|
-
mimeType =
|
|
559
|
-
name =
|
|
544
|
+
var _ref10 = metadata || {},
|
|
545
|
+
mediaType = _ref10.mediaType,
|
|
546
|
+
mimeType = _ref10.mimeType,
|
|
547
|
+
name = _ref10.name;
|
|
560
548
|
|
|
561
549
|
return /*#__PURE__*/React.createElement(IconWrapper, {
|
|
562
550
|
breakpoint: this.breakpoint,
|
|
@@ -78,31 +78,36 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
78
78
|
|
|
79
79
|
if (!fileState) {
|
|
80
80
|
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
81
|
-
message: intl.formatMessage(messages.loading_file)
|
|
81
|
+
message: intl.formatMessage(messages.loading_file),
|
|
82
|
+
isSelected: isSelected
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
if (isErrored) {
|
|
86
87
|
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
87
|
-
message: intl.formatMessage(messages.couldnt_load_file)
|
|
88
|
+
message: intl.formatMessage(messages.couldnt_load_file),
|
|
89
|
+
isSelected: isSelected
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
if (fileState.status === 'error') {
|
|
92
94
|
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
93
|
-
message: fileState.message || ''
|
|
95
|
+
message: fileState.message || '',
|
|
96
|
+
isSelected: isSelected
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
if (fileState.status === 'failed-processing') {
|
|
98
101
|
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
99
|
-
message: intl.formatMessage(messages.couldnt_load_file)
|
|
102
|
+
message: intl.formatMessage(messages.couldnt_load_file),
|
|
103
|
+
isSelected: isSelected
|
|
100
104
|
});
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
if (fileState.status === 'uploading') {
|
|
104
108
|
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
105
|
-
message: fileState.name
|
|
109
|
+
message: fileState.name,
|
|
110
|
+
isSelected: isSelected
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
|
|
@@ -2,7 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
|
|
3
3
|
var _responsiveSettings;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export var Breakpoint;
|
|
6
|
+
|
|
7
|
+
(function (Breakpoint) {
|
|
8
|
+
Breakpoint["SMALL"] = "small";
|
|
9
|
+
Breakpoint["LARGE"] = "large";
|
|
10
|
+
})(Breakpoint || (Breakpoint = {}));
|
|
11
|
+
|
|
6
12
|
export var responsiveSettings = (_responsiveSettings = {}, _defineProperty(_responsiveSettings, Breakpoint.SMALL, {
|
|
7
13
|
fontSize: 11,
|
|
8
14
|
lineHeight: 14,
|
|
@@ -10,7 +10,9 @@ export var ImageRenderer = function ImageRenderer(_ref) {
|
|
|
10
10
|
onImageLoad = _ref.onImageLoad,
|
|
11
11
|
onImageError = _ref.onImageError,
|
|
12
12
|
onDisplayImage = _ref.onDisplayImage,
|
|
13
|
-
mediaType = _ref.mediaType
|
|
13
|
+
mediaType = _ref.mediaType,
|
|
14
|
+
nativeLazyLoad = _ref.nativeLazyLoad,
|
|
15
|
+
forceSyncDisplay = _ref.forceSyncDisplay;
|
|
14
16
|
useEffect(function () {
|
|
15
17
|
// TODO: trigger accordingly with the succeeded event. This could be a breaking change
|
|
16
18
|
if (mediaType === 'image' && onDisplayImage) {
|
|
@@ -22,6 +24,8 @@ export var ImageRenderer = function ImageRenderer(_ref) {
|
|
|
22
24
|
alt: alt,
|
|
23
25
|
previewOrientation: previewOrientation,
|
|
24
26
|
onImageLoad: onImageLoad,
|
|
25
|
-
onImageError: onImageError
|
|
27
|
+
onImageError: onImageError,
|
|
28
|
+
loading: nativeLazyLoad ? 'lazy' : undefined,
|
|
29
|
+
forceSyncDisplay: forceSyncDisplay
|
|
26
30
|
}, resizeModeToMediaImageProps(resizeMode)));
|
|
27
31
|
};
|
|
@@ -3,7 +3,7 @@ import { errorIcon } from '@atlaskit/media-ui/errorIcon';
|
|
|
3
3
|
import { WarningIconWrapper, LoadingRateLimitedContainer, CouldntLoadWrapper, ErrorWrapper, LoadingRateLimitedTextWrapper } from './styled';
|
|
4
4
|
import { messages } from '@atlaskit/media-ui';
|
|
5
5
|
import { FormattedMessage } from 'react-intl';
|
|
6
|
-
import { Breakpoint } from '../
|
|
6
|
+
import { Breakpoint } from '../common';
|
|
7
7
|
export var LoadingRateLimited = function LoadingRateLimited(_ref) {
|
|
8
8
|
var _ref$breakpoint = _ref.breakpoint,
|
|
9
9
|
breakpoint = _ref$breakpoint === void 0 ? Breakpoint.SMALL : _ref$breakpoint,
|