@atlaskit/media-card 73.1.1 → 73.2.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 +19 -0
- package/dist/cjs/files/cardImageView/index.js +51 -41
- package/dist/cjs/root/card/getCardPreview/index.js +7 -1
- package/dist/cjs/root/card/index.js +247 -151
- package/dist/cjs/root/cardView.js +127 -115
- package/dist/cjs/root/inlinePlayer.js +4 -2
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/cjs/root/ui/styled.js +5 -5
- package/dist/cjs/types.js +10 -1
- package/dist/cjs/utils/analytics.js +23 -7
- 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/getCardPreview/index.js +1 -0
- package/dist/es2019/root/card/index.js +107 -35
- package/dist/es2019/root/cardView.js +40 -30
- package/dist/es2019/root/inlinePlayer.js +4 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/es2019/root/ui/styled.js +4 -4
- package/dist/es2019/types.js +7 -1
- package/dist/es2019/utils/analytics.js +8 -3
- 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/getCardPreview/index.js +3 -0
- package/dist/esm/root/card/index.js +228 -134
- package/dist/esm/root/cardView.js +126 -115
- package/dist/esm/root/inlinePlayer.js +4 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/esm/root/ui/styled.js +5 -5
- package/dist/esm/types.js +7 -1
- package/dist/esm/utils/analytics.js +17 -6
- 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/errors.d.ts +1 -1
- package/dist/types/files/cardImageView/index.d.ts +6 -2
- package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +3 -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 +4 -4
- 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 +6 -0
- 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 +5 -5
|
@@ -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,22 +515,20 @@ 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
|
-
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,
|
|
520
531
|
mediaType: mediaType,
|
|
521
|
-
previewOrientation: previewOrientation,
|
|
522
532
|
alt: alt,
|
|
523
533
|
resizeMode: resizeMode,
|
|
524
534
|
onDisplayImage: onDisplayImage,
|
|
@@ -541,10 +551,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
541
551
|
value: function renderMediaTypeIcon(hasTitleBox, iconMessage) {
|
|
542
552
|
var metadata = this.props.metadata;
|
|
543
553
|
|
|
544
|
-
var
|
|
545
|
-
mediaType =
|
|
546
|
-
mimeType =
|
|
547
|
-
name =
|
|
554
|
+
var _ref11 = metadata || {},
|
|
555
|
+
mediaType = _ref11.mediaType,
|
|
556
|
+
mimeType = _ref11.mimeType,
|
|
557
|
+
name = _ref11.name;
|
|
548
558
|
|
|
549
559
|
return /*#__PURE__*/React.createElement(IconWrapper, {
|
|
550
560
|
breakpoint: this.breakpoint,
|
|
@@ -559,10 +569,10 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
559
569
|
}, {
|
|
560
570
|
key: "renderActionsBar",
|
|
561
571
|
value: function renderActionsBar() {
|
|
562
|
-
var _this$
|
|
563
|
-
disableOverlay = _this$
|
|
564
|
-
actions = _this$
|
|
565
|
-
metadata = _this$
|
|
572
|
+
var _this$props10 = this.props,
|
|
573
|
+
disableOverlay = _this$props10.disableOverlay,
|
|
574
|
+
actions = _this$props10.actions,
|
|
575
|
+
metadata = _this$props10.metadata;
|
|
566
576
|
var actionsWithDetails = metadata && actions ? attachDetailsToActions(actions, metadata) : [];
|
|
567
577
|
|
|
568
578
|
if (disableOverlay || !actions || actions.length === 0) {
|
|
@@ -579,7 +589,8 @@ export var CardViewBase = /*#__PURE__*/function (_React$Component) {
|
|
|
579
589
|
}(React.Component);
|
|
580
590
|
|
|
581
591
|
_defineProperty(CardViewBase, "defaultProps", {
|
|
582
|
-
appearance: 'auto'
|
|
592
|
+
appearance: 'auto',
|
|
593
|
+
mediaCardCursor: MediaCardCursor.NoAction
|
|
583
594
|
});
|
|
584
595
|
|
|
585
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,
|
|
@@ -3,8 +3,7 @@ import React, { useEffect } from 'react';
|
|
|
3
3
|
import { MediaImage } from '@atlaskit/media-ui';
|
|
4
4
|
import { resizeModeToMediaImageProps } from '../../../utils/resizeModeToMediaImageProps';
|
|
5
5
|
export var ImageRenderer = function ImageRenderer(_ref) {
|
|
6
|
-
var
|
|
7
|
-
previewOrientation = _ref.previewOrientation,
|
|
6
|
+
var cardPreview = _ref.cardPreview,
|
|
8
7
|
alt = _ref.alt,
|
|
9
8
|
resizeMode = _ref.resizeMode,
|
|
10
9
|
onImageLoad = _ref.onImageLoad,
|
|
@@ -19,12 +18,21 @@ export var ImageRenderer = function ImageRenderer(_ref) {
|
|
|
19
18
|
onDisplayImage();
|
|
20
19
|
}
|
|
21
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
|
+
|
|
22
30
|
return /*#__PURE__*/React.createElement(MediaImage, _extends({
|
|
23
|
-
dataURI: dataURI,
|
|
31
|
+
dataURI: cardPreview.dataURI,
|
|
24
32
|
alt: alt,
|
|
25
|
-
previewOrientation:
|
|
26
|
-
onImageLoad:
|
|
27
|
-
onImageError:
|
|
33
|
+
previewOrientation: cardPreview.orientation,
|
|
34
|
+
onImageLoad: onLoad,
|
|
35
|
+
onImageError: onError,
|
|
28
36
|
loading: nativeLazyLoad ? 'lazy' : undefined,
|
|
29
37
|
forceSyncDisplay: forceSyncDisplay
|
|
30
38
|
}, resizeModeToMediaImageProps(resizeMode)));
|
|
@@ -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';
|
|
@@ -89,20 +95,25 @@ export var getRenderErrorRequestMetadata = function getRenderErrorRequestMetadat
|
|
|
89
95
|
return error.secondaryError.metadata;
|
|
90
96
|
}
|
|
91
97
|
};
|
|
98
|
+
export var extractErrorInfo = function extractErrorInfo(error) {
|
|
99
|
+
return {
|
|
100
|
+
failReason: getRenderErrorFailReason(error),
|
|
101
|
+
error: getRenderErrorErrorReason(error),
|
|
102
|
+
errorDetail: getRenderErrorErrorDetail(error)
|
|
103
|
+
};
|
|
104
|
+
};
|
|
92
105
|
export var getRenderErrorEventPayload = function getRenderErrorEventPayload(fileAttributes, performanceAttributes, error) {
|
|
93
106
|
return {
|
|
94
107
|
eventType: 'operational',
|
|
95
108
|
action: 'failed',
|
|
96
109
|
actionSubject: 'mediaCardRender',
|
|
97
|
-
attributes: {
|
|
110
|
+
attributes: _objectSpread(_objectSpread({
|
|
98
111
|
fileAttributes: fileAttributes,
|
|
99
112
|
performanceAttributes: performanceAttributes,
|
|
100
|
-
status: 'fail'
|
|
101
|
-
|
|
102
|
-
error: getRenderErrorErrorReason(error),
|
|
103
|
-
errorDetail: getRenderErrorErrorDetail(error),
|
|
113
|
+
status: 'fail'
|
|
114
|
+
}, extractErrorInfo(error)), {}, {
|
|
104
115
|
request: getRenderErrorRequestMetadata(error)
|
|
105
|
-
}
|
|
116
|
+
})
|
|
106
117
|
};
|
|
107
118
|
};
|
|
108
119
|
export var getRenderFailedFileStatusPayload = function getRenderFailedFileStatusPayload(fileAttributes, performanceAttributes) {
|
|
@@ -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)) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MediaCardCursor } from '../types';
|
|
2
|
+
export var getMediaCardCursor = function getMediaCardCursor(useInlinePlayer, useMediaViewer, isErrorStatus, hasCardPreview, mediaType) {
|
|
3
|
+
// If error status or no action is requested = NoAction
|
|
4
|
+
if (isErrorStatus || !useInlinePlayer && !useMediaViewer) {
|
|
5
|
+
return MediaCardCursor.NoAction;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!mediaType && (useInlinePlayer || useInlinePlayer && useMediaViewer)) {
|
|
9
|
+
return MediaCardCursor.NotReady;
|
|
10
|
+
} else if (mediaType === 'video' && hasCardPreview && useInlinePlayer) {
|
|
11
|
+
return MediaCardCursor.Action;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (useMediaViewer) {
|
|
15
|
+
return MediaCardCursor.Action;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return MediaCardCursor.NoAction;
|
|
19
|
+
};
|