@atlaskit/media-card 72.1.0 → 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 +89 -0
- package/dist/cjs/actions.js +2 -2
- package/dist/cjs/errors.js +11 -7
- package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
- package/dist/cjs/files/cardImageView/index.js +52 -42
- package/dist/cjs/files/cardImageView/styled.js +1 -1
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/root/card/cardAnalytics.js +2 -2
- package/dist/cjs/root/card/cardState.js +2 -2
- package/dist/cjs/root/card/getCardPreview/cache.js +5 -5
- package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/cjs/root/card/getCardPreview/helpers.js +1 -1
- package/dist/cjs/root/card/getCardPreview/index.js +18 -9
- package/dist/cjs/root/card/getCardStatus.js +1 -1
- package/dist/cjs/root/card/index.js +279 -159
- package/dist/cjs/root/cardView.js +130 -118
- package/dist/cjs/root/inline/loader.js +45 -14
- package/dist/cjs/root/inline/mediaInlineCard.js +24 -9
- package/dist/cjs/root/inlinePlayer.js +80 -25
- package/dist/cjs/root/styled.js +7 -3
- package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
- package/dist/cjs/root/ui/blanket/styled.js +1 -1
- package/dist/cjs/root/ui/common.js +1 -1
- package/dist/cjs/root/ui/iconMessage/index.js +5 -3
- package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
- package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +4 -2
- package/dist/cjs/root/ui/loadingRateLimited/styled.js +2 -2
- package/dist/cjs/root/ui/playButton/styled.js +1 -1
- package/dist/cjs/root/ui/progressBar/progressBar.js +5 -2
- package/dist/cjs/root/ui/progressBar/styled.js +7 -6
- package/dist/cjs/root/ui/styled.js +6 -6
- package/dist/cjs/root/ui/tickBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/failedTitleBox.js +4 -2
- package/dist/cjs/root/ui/titleBox/styled.js +1 -1
- package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
- package/dist/cjs/styles/index.js +25 -23
- package/dist/cjs/styles/mixins.js +1 -1
- package/dist/cjs/types.js +10 -1
- package/dist/cjs/utils/analytics.js +24 -7
- package/dist/cjs/utils/breakpoint.js +1 -1
- package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +3 -1
- package/dist/cjs/utils/cardActions/index.js +10 -10
- package/dist/cjs/utils/cardActions/styled.js +1 -1
- package/dist/cjs/utils/cardDimensions.js +1 -1
- package/dist/cjs/utils/dimensionComparer.js +7 -13
- package/dist/cjs/utils/getErrorMessage.js +2 -2
- 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/index.js +46 -46
- package/dist/cjs/utils/lightCards/styled.js +1 -1
- package/dist/cjs/utils/objectURLCache.js +1 -1
- package/dist/cjs/utils/printScript.js +44 -0
- package/dist/cjs/utils/viewportDetector.js +49 -22
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/files/cardImageView/index.js +19 -5
- package/dist/es2019/root/card/cardAnalytics.js +1 -1
- package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/es2019/root/card/getCardPreview/index.js +1 -0
- package/dist/es2019/root/card/index.js +150 -49
- package/dist/es2019/root/cardView.js +40 -30
- package/dist/es2019/root/inline/loader.js +15 -4
- package/dist/es2019/root/inline/mediaInlineCard.js +23 -8
- package/dist/es2019/root/inlinePlayer.js +59 -5
- package/dist/es2019/root/styled.js +2 -1
- package/dist/es2019/root/ui/iconMessage/index.js +3 -2
- package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
- package/dist/es2019/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/es2019/root/ui/progressBar/progressBar.js +4 -2
- package/dist/es2019/root/ui/progressBar/styled.js +6 -4
- package/dist/es2019/root/ui/styled.js +5 -5
- package/dist/es2019/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
- 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/getErrorMessage.js +1 -1
- 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/utils/viewportDetector.js +48 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions.js +2 -2
- package/dist/esm/errors.js +6 -5
- package/dist/esm/files/cardImageView/index.js +53 -41
- package/dist/esm/root/card/cardAnalytics.js +1 -1
- package/dist/esm/root/card/cardState.js +2 -2
- package/dist/esm/root/card/getCardPreview/cache.js +3 -2
- package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +4 -1
- package/dist/esm/root/card/getCardPreview/index.js +5 -2
- package/dist/esm/root/card/index.js +266 -145
- package/dist/esm/root/cardView.js +128 -117
- package/dist/esm/root/inline/loader.js +46 -14
- package/dist/esm/root/inline/mediaInlineCard.js +23 -8
- package/dist/esm/root/inlinePlayer.js +77 -24
- package/dist/esm/root/styled.js +3 -2
- package/dist/esm/root/ui/iconMessage/index.js +3 -2
- package/dist/esm/root/ui/imageRenderer/imageRenderer.js +14 -6
- package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +3 -2
- package/dist/esm/root/ui/loadingRateLimited/styled.js +1 -1
- package/dist/esm/root/ui/progressBar/progressBar.js +5 -2
- package/dist/esm/root/ui/progressBar/styled.js +6 -5
- package/dist/esm/root/ui/styled.js +5 -5
- package/dist/esm/root/ui/titleBox/failedTitleBox.js +3 -2
- package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
- package/dist/esm/types.js +7 -1
- package/dist/esm/utils/analytics.js +17 -6
- package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +2 -1
- package/dist/esm/utils/dimensionComparer.js +8 -13
- package/dist/esm/utils/getErrorMessage.js +1 -1
- 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/utils/viewportDetector.js +48 -21
- 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/index.d.ts +1 -0
- package/dist/types/root/card/cardLoader.d.ts +2 -2
- package/dist/types/root/card/getCardPreview/index.d.ts +1 -0
- package/dist/types/root/card/index.d.ts +10 -9
- package/dist/types/root/cardView.d.ts +10 -8
- package/dist/types/root/inline/loader.d.ts +2 -0
- package/dist/types/root/inline/mediaInlineCard.d.ts +3 -5
- package/dist/types/root/inlinePlayer.d.ts +10 -1
- package/dist/types/root/styled.d.ts +1 -0
- package/dist/types/root/ui/iconMessage/index.d.ts +2 -2
- package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +4 -4
- package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +1 -0
- package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
- package/dist/types/root/ui/progressBar/progressBar.d.ts +3 -1
- package/dist/types/root/ui/progressBar/styled.d.ts +2 -1
- package/dist/types/root/ui/styled.d.ts +2 -1
- package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
- package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -2
- package/dist/types/root/ui/titleBox/titleBox.d.ts +1 -9
- package/dist/types/types.d.ts +6 -1
- package/dist/types/utils/analytics.d.ts +6 -0
- package/dist/types/utils/getErrorMessage.d.ts +1 -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/dist/types/utils/viewportDetector.d.ts +13 -5
- package/package.json +14 -16
- package/dist/cjs/utils/lazyContent/index.js +0 -56
- package/dist/cjs/utils/lazyContent/styled.js +0 -23
- package/dist/es2019/utils/lazyContent/index.js +0 -18
- package/dist/es2019/utils/lazyContent/styled.js +0 -12
- package/dist/esm/utils/lazyContent/index.js +0 -41
- package/dist/esm/utils/lazyContent/styled.js +0 -14
- package/dist/types/utils/lazyContent/index.d.ts +0 -11
- package/dist/types/utils/lazyContent/styled.d.ts +0 -5
|
@@ -6,9 +6,9 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
9
|
+
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; }
|
|
10
10
|
|
|
11
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
11
|
+
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; }
|
|
12
12
|
|
|
13
13
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
14
|
|
|
@@ -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({
|
|
@@ -32,6 +32,8 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
32
32
|
|
|
33
33
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
34
|
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "isMounted", false);
|
|
36
|
+
|
|
35
37
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
36
38
|
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
|
|
37
39
|
ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
|
|
@@ -50,13 +52,15 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
50
52
|
while (1) {
|
|
51
53
|
switch (_context.prev = _context.next) {
|
|
52
54
|
case 0:
|
|
55
|
+
this.isMounted = true;
|
|
56
|
+
|
|
53
57
|
if (this.state.MediaInlineCard) {
|
|
54
|
-
_context.next =
|
|
58
|
+
_context.next = 17;
|
|
55
59
|
break;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
_context.prev =
|
|
59
|
-
_context.next =
|
|
62
|
+
_context.prev = 2;
|
|
63
|
+
_context.next = 5;
|
|
60
64
|
return Promise.all([import(
|
|
61
65
|
/* webpackChunkName: "@atlaskit-internal_media-client" */
|
|
62
66
|
'@atlaskit/media-client'), import(
|
|
@@ -65,7 +69,7 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
65
69
|
/* webpackChunkName: "@atlaskit-internal_media-card-error-boundary" */
|
|
66
70
|
'../media-card-analytics-error-boundary')]);
|
|
67
71
|
|
|
68
|
-
case
|
|
72
|
+
case 5:
|
|
69
73
|
_yield$Promise$all = _context.sent;
|
|
70
74
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
71
75
|
mediaClient = _yield$Promise$all2[0];
|
|
@@ -73,23 +77,27 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
73
77
|
mediaCardErrorBoundaryModule = _yield$Promise$all2[2];
|
|
74
78
|
MediaInlineCardLoader.MediaInlineCard = mediaClient.withMediaClient(cardModule.MediaInlineCard);
|
|
75
79
|
MediaInlineCardLoader.ErrorBoundary = mediaCardErrorBoundaryModule.default;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
if (this.isMounted) {
|
|
82
|
+
this.setState({
|
|
83
|
+
MediaInlineCard: MediaInlineCardLoader.MediaInlineCard,
|
|
84
|
+
ErrorBoundary: MediaInlineCardLoader.ErrorBoundary
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
_context.next = 17;
|
|
81
89
|
break;
|
|
82
90
|
|
|
83
|
-
case
|
|
84
|
-
_context.prev =
|
|
85
|
-
_context.t0 = _context["catch"](
|
|
91
|
+
case 15:
|
|
92
|
+
_context.prev = 15;
|
|
93
|
+
_context.t0 = _context["catch"](2);
|
|
86
94
|
|
|
87
|
-
case
|
|
95
|
+
case 17:
|
|
88
96
|
case "end":
|
|
89
97
|
return _context.stop();
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
|
-
}, _callee, this, [[
|
|
100
|
+
}, _callee, this, [[2, 15]]);
|
|
93
101
|
}));
|
|
94
102
|
|
|
95
103
|
function componentDidMount() {
|
|
@@ -98,6 +106,30 @@ var MediaInlineCardLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
98
106
|
|
|
99
107
|
return componentDidMount;
|
|
100
108
|
}()
|
|
109
|
+
}, {
|
|
110
|
+
key: "componentWillUnmount",
|
|
111
|
+
value: function () {
|
|
112
|
+
var _componentWillUnmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
113
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
114
|
+
while (1) {
|
|
115
|
+
switch (_context2.prev = _context2.next) {
|
|
116
|
+
case 0:
|
|
117
|
+
this.isMounted = false;
|
|
118
|
+
|
|
119
|
+
case 1:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context2.stop();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, _callee2, this);
|
|
125
|
+
}));
|
|
126
|
+
|
|
127
|
+
function componentWillUnmount() {
|
|
128
|
+
return _componentWillUnmount.apply(this, arguments);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return componentWillUnmount;
|
|
132
|
+
}()
|
|
101
133
|
}, {
|
|
102
134
|
key: "render",
|
|
103
135
|
value: function render() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useState, useEffect } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
|
-
import { injectIntl } from 'react-intl';
|
|
4
|
+
import { injectIntl, IntlProvider, createIntl } from 'react-intl-next';
|
|
5
5
|
import { MediaInlineCardLoadedView, MediaInlineCardLoadingView, MediaInlineCardErroredView, messages } from '@atlaskit/media-ui';
|
|
6
6
|
import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
|
|
7
7
|
import { MediaViewer } from '@atlaskit/media-viewer';
|
|
@@ -63,29 +63,42 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
63
63
|
return null;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
var renderContent = function renderContent(children) {
|
|
67
|
+
return intl ? children : /*#__PURE__*/React.createElement(IntlProvider, {
|
|
68
|
+
locale: "en"
|
|
69
|
+
}, children);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var defaultIntl = createIntl({
|
|
73
|
+
locale: 'en'
|
|
74
|
+
});
|
|
66
75
|
useEffect(function () {
|
|
67
|
-
mediaClient.file.getFileState(identifier.id, {
|
|
76
|
+
var subscription = mediaClient.file.getFileState(identifier.id, {
|
|
68
77
|
collectionName: identifier.collectionName
|
|
69
78
|
}).subscribe({
|
|
70
79
|
next: function next(fileState) {
|
|
71
80
|
setFileState(fileState);
|
|
81
|
+
setIsErrored(false);
|
|
72
82
|
},
|
|
73
83
|
error: function error() {
|
|
74
84
|
setIsErrored(true);
|
|
75
85
|
}
|
|
76
86
|
});
|
|
87
|
+
return function () {
|
|
88
|
+
subscription.unsubscribe();
|
|
89
|
+
};
|
|
77
90
|
}, [identifier.collectionName, identifier.id, mediaClient.file]);
|
|
78
91
|
|
|
79
92
|
if (!fileState) {
|
|
80
93
|
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
81
|
-
message: intl.formatMessage(messages.loading_file),
|
|
94
|
+
message: (intl || defaultIntl).formatMessage(messages.loading_file),
|
|
82
95
|
isSelected: isSelected
|
|
83
96
|
});
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
if (isErrored) {
|
|
87
100
|
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
88
|
-
message: intl.formatMessage(messages.couldnt_load_file),
|
|
101
|
+
message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
|
|
89
102
|
isSelected: isSelected
|
|
90
103
|
});
|
|
91
104
|
}
|
|
@@ -99,7 +112,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
99
112
|
|
|
100
113
|
if (fileState.status === 'failed-processing') {
|
|
101
114
|
return /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
102
|
-
message: intl.formatMessage(messages.couldnt_load_file),
|
|
115
|
+
message: (intl || defaultIntl).formatMessage(messages.couldnt_load_file),
|
|
103
116
|
isSelected: isSelected
|
|
104
117
|
});
|
|
105
118
|
}
|
|
@@ -131,7 +144,7 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
131
144
|
formattedDate = formatDate(fileState.createdAt, locale);
|
|
132
145
|
}
|
|
133
146
|
|
|
134
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
147
|
+
return renderContent( /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
135
148
|
position: "bottom",
|
|
136
149
|
content: formattedDate,
|
|
137
150
|
tag: "span"
|
|
@@ -140,6 +153,8 @@ export var MediaInlineCardInternal = function MediaInlineCardInternal(_ref) {
|
|
|
140
153
|
title: name,
|
|
141
154
|
onClick: onMediaInlineCardClick,
|
|
142
155
|
isSelected: isSelected
|
|
143
|
-
})), mediaViewer);
|
|
156
|
+
})), mediaViewer));
|
|
144
157
|
};
|
|
145
|
-
export var MediaInlineCard = injectIntl(MediaInlineCardInternal
|
|
158
|
+
export var MediaInlineCard = injectIntl(MediaInlineCardInternal, {
|
|
159
|
+
enforceContext: false
|
|
160
|
+
});
|