@atlaskit/media-ui 22.3.0 → 22.3.2

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.
Files changed (191) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/MediaButton.js +12 -29
  3. package/dist/cjs/MediaInlineCard/ErroredView/index.js +5 -32
  4. package/dist/cjs/MediaInlineCard/Frame/index.js +4 -27
  5. package/dist/cjs/MediaInlineCard/Frame/styled.js +1 -12
  6. package/dist/cjs/MediaInlineCard/Icon.js +3 -10
  7. package/dist/cjs/MediaInlineCard/IconAndTitleLayout/index.js +7 -35
  8. package/dist/cjs/MediaInlineCard/IconAndTitleLayout/styled.js +15 -33
  9. package/dist/cjs/MediaInlineCard/LoadedView/index.js +8 -24
  10. package/dist/cjs/MediaInlineCard/LoadingView/index.js +6 -26
  11. package/dist/cjs/MediaInlineCard/LoadingView/styled.js +0 -6
  12. package/dist/cjs/MediaInlineCard/index.js +0 -3
  13. package/dist/cjs/MediaInlineCard/styled.js +0 -7
  14. package/dist/cjs/browser.js +1 -5
  15. package/dist/cjs/camera.js +14 -36
  16. package/dist/cjs/codeViewer.js +1 -46
  17. package/dist/cjs/customMediaPlayer/analytics/events/screen/customMediaPlayer.js +0 -7
  18. package/dist/cjs/customMediaPlayer/analytics/events/track/playCount.js +0 -7
  19. package/dist/cjs/customMediaPlayer/analytics/events/track/played.js +0 -7
  20. package/dist/cjs/customMediaPlayer/analytics/events/ui/mediaButtonClicked.js +0 -6
  21. package/dist/cjs/customMediaPlayer/analytics/events/ui/playPauseBlanketClicked.js +0 -6
  22. package/dist/cjs/customMediaPlayer/analytics/events/ui/playbackSpeedChanged.js +0 -6
  23. package/dist/cjs/customMediaPlayer/analytics/events/ui/shortcutPressed.js +0 -6
  24. package/dist/cjs/customMediaPlayer/analytics/events/ui/timeRangeNavigated.js +0 -6
  25. package/dist/cjs/customMediaPlayer/analytics/index.js +0 -9
  26. package/dist/cjs/customMediaPlayer/analytics/utils/analytics.js +4 -8
  27. package/dist/cjs/customMediaPlayer/analytics/utils/playbackAttributes.js +10 -12
  28. package/dist/cjs/customMediaPlayer/fullscreen.js +4 -20
  29. package/dist/cjs/customMediaPlayer/getControlsWrapperClassName.js +0 -3
  30. package/dist/cjs/customMediaPlayer/icons.js +0 -8
  31. package/dist/cjs/customMediaPlayer/index.js +54 -157
  32. package/dist/cjs/customMediaPlayer/playPauseBlanket.js +0 -6
  33. package/dist/cjs/customMediaPlayer/playbackSpeedControls.js +7 -45
  34. package/dist/cjs/customMediaPlayer/simultaneousPlayManager.js +0 -4
  35. package/dist/cjs/customMediaPlayer/styled.js +0 -43
  36. package/dist/cjs/customMediaPlayer/timeRange.js +24 -55
  37. package/dist/cjs/customMediaPlayer/timeSaver.js +5 -12
  38. package/dist/cjs/ellipsify.js +4 -25
  39. package/dist/cjs/errorIcon.js +1 -5
  40. package/dist/cjs/formatDate.js +6 -12
  41. package/dist/cjs/formatDuration.js +0 -5
  42. package/dist/cjs/humanReadableSize.js +1 -6
  43. package/dist/cjs/i18n/cs.js +0 -1
  44. package/dist/cjs/i18n/da.js +0 -1
  45. package/dist/cjs/i18n/de.js +0 -1
  46. package/dist/cjs/i18n/en.js +0 -1
  47. package/dist/cjs/i18n/en_GB.js +0 -1
  48. package/dist/cjs/i18n/en_ZZ.js +0 -1
  49. package/dist/cjs/i18n/es.js +0 -1
  50. package/dist/cjs/i18n/et.js +0 -1
  51. package/dist/cjs/i18n/fi.js +0 -1
  52. package/dist/cjs/i18n/fr.js +0 -1
  53. package/dist/cjs/i18n/hu.js +0 -1
  54. package/dist/cjs/i18n/index.js +0 -30
  55. package/dist/cjs/i18n/it.js +0 -1
  56. package/dist/cjs/i18n/ja.js +0 -1
  57. package/dist/cjs/i18n/ko.js +0 -1
  58. package/dist/cjs/i18n/nb.js +0 -1
  59. package/dist/cjs/i18n/nl.js +0 -1
  60. package/dist/cjs/i18n/pl.js +0 -1
  61. package/dist/cjs/i18n/pt_BR.js +0 -1
  62. package/dist/cjs/i18n/pt_PT.js +0 -1
  63. package/dist/cjs/i18n/ru.js +0 -1
  64. package/dist/cjs/i18n/sk.js +0 -1
  65. package/dist/cjs/i18n/sv.js +0 -1
  66. package/dist/cjs/i18n/th.js +0 -1
  67. package/dist/cjs/i18n/tr.js +0 -1
  68. package/dist/cjs/i18n/uk.js +0 -1
  69. package/dist/cjs/i18n/vi.js +0 -1
  70. package/dist/cjs/i18n/zh.js +0 -1
  71. package/dist/cjs/i18n/zh_TW.js +0 -1
  72. package/dist/cjs/imageMetaData/imageOrientationUtil.js +1 -5
  73. package/dist/cjs/imageMetaData/index.js +8 -50
  74. package/dist/cjs/imageMetaData/metatags.js +0 -23
  75. package/dist/cjs/imageMetaData/parseJPEG.js +1 -18
  76. package/dist/cjs/imageMetaData/parsePNG.js +0 -30
  77. package/dist/cjs/imageMetaData/parsePNGXMP.js +0 -4
  78. package/dist/cjs/imageMetaData/types.js +0 -5
  79. package/dist/cjs/inactivityDetector/inactivityDetector.js +5 -34
  80. package/dist/cjs/inactivityDetector/styled.js +0 -8
  81. package/dist/cjs/index.js +0 -29
  82. package/dist/cjs/intersectionObserver.js +0 -2
  83. package/dist/cjs/locales.js +0 -5
  84. package/dist/cjs/media-type-icon.js +3 -35
  85. package/dist/cjs/mediaImage/index.js +28 -62
  86. package/dist/cjs/mediaImage/styled.js +2 -13
  87. package/dist/cjs/messages.js +0 -2
  88. package/dist/cjs/mime-type-icon.js +13 -18
  89. package/dist/cjs/mixins.js +0 -11
  90. package/dist/cjs/modalSpinner.js +1 -15
  91. package/dist/cjs/shortcut.js +3 -25
  92. package/dist/cjs/truncateText.js +12 -33
  93. package/dist/cjs/util.js +16 -72
  94. package/dist/cjs/version.json +1 -1
  95. package/dist/es2019/MediaButton.js +8 -11
  96. package/dist/es2019/MediaInlineCard/ErroredView/index.js +0 -3
  97. package/dist/es2019/MediaInlineCard/Frame/index.js +0 -8
  98. package/dist/es2019/MediaInlineCard/Frame/styled.js +1 -3
  99. package/dist/es2019/MediaInlineCard/Icon.js +6 -4
  100. package/dist/es2019/MediaInlineCard/IconAndTitleLayout/index.js +0 -14
  101. package/dist/es2019/MediaInlineCard/IconAndTitleLayout/styled.js +19 -13
  102. package/dist/es2019/MediaInlineCard/LoadedView/index.js +0 -1
  103. package/dist/es2019/MediaInlineCard/LoadingView/index.js +0 -2
  104. package/dist/es2019/browser.js +1 -5
  105. package/dist/es2019/camera.js +9 -52
  106. package/dist/es2019/codeViewer.js +1 -42
  107. package/dist/es2019/customMediaPlayer/analytics/utils/analytics.js +4 -2
  108. package/dist/es2019/customMediaPlayer/fullscreen.js +4 -9
  109. package/dist/es2019/customMediaPlayer/icons.js +0 -4
  110. package/dist/es2019/customMediaPlayer/index.js +9 -85
  111. package/dist/es2019/customMediaPlayer/playbackSpeedControls.js +14 -20
  112. package/dist/es2019/customMediaPlayer/simultaneousPlayManager.js +0 -4
  113. package/dist/es2019/customMediaPlayer/timeRange.js +12 -29
  114. package/dist/es2019/customMediaPlayer/timeSaver.js +5 -9
  115. package/dist/es2019/ellipsify.js +0 -8
  116. package/dist/es2019/formatDuration.js +0 -3
  117. package/dist/es2019/humanReadableSize.js +3 -2
  118. package/dist/es2019/imageMetaData/imageOrientationUtil.js +1 -2
  119. package/dist/es2019/imageMetaData/index.js +10 -24
  120. package/dist/es2019/imageMetaData/metatags.js +4 -4
  121. package/dist/es2019/imageMetaData/parseJPEG.js +0 -3
  122. package/dist/es2019/imageMetaData/parsePNG.js +5 -10
  123. package/dist/es2019/imageMetaData/parsePNGXMP.js +0 -3
  124. package/dist/es2019/imageMetaData/types.js +0 -5
  125. package/dist/es2019/inactivityDetector/inactivityDetector.js +5 -15
  126. package/dist/es2019/inactivityDetector/styled.js +0 -2
  127. package/dist/es2019/media-type-icon.js +0 -2
  128. package/dist/es2019/mediaImage/index.js +10 -24
  129. package/dist/es2019/mediaImage/styled.js +2 -1
  130. package/dist/es2019/mime-type-icon.js +5 -5
  131. package/dist/es2019/shortcut.js +0 -9
  132. package/dist/es2019/truncateText.js +1 -9
  133. package/dist/es2019/util.js +14 -26
  134. package/dist/es2019/version.json +1 -1
  135. package/dist/esm/MediaButton.js +12 -22
  136. package/dist/esm/MediaInlineCard/ErroredView/index.js +5 -17
  137. package/dist/esm/MediaInlineCard/Frame/index.js +4 -21
  138. package/dist/esm/MediaInlineCard/Frame/styled.js +1 -6
  139. package/dist/esm/MediaInlineCard/Icon.js +4 -4
  140. package/dist/esm/MediaInlineCard/IconAndTitleLayout/index.js +7 -24
  141. package/dist/esm/MediaInlineCard/IconAndTitleLayout/styled.js +17 -13
  142. package/dist/esm/MediaInlineCard/LoadedView/index.js +8 -16
  143. package/dist/esm/MediaInlineCard/LoadingView/index.js +6 -15
  144. package/dist/esm/MediaInlineCard/LoadingView/styled.js +0 -2
  145. package/dist/esm/MediaInlineCard/styled.js +0 -2
  146. package/dist/esm/browser.js +1 -5
  147. package/dist/esm/camera.js +14 -31
  148. package/dist/esm/codeViewer.js +1 -42
  149. package/dist/esm/customMediaPlayer/analytics/events/screen/customMediaPlayer.js +0 -3
  150. package/dist/esm/customMediaPlayer/analytics/events/track/playCount.js +0 -3
  151. package/dist/esm/customMediaPlayer/analytics/events/track/played.js +0 -3
  152. package/dist/esm/customMediaPlayer/analytics/events/ui/mediaButtonClicked.js +0 -3
  153. package/dist/esm/customMediaPlayer/analytics/events/ui/playPauseBlanketClicked.js +0 -3
  154. package/dist/esm/customMediaPlayer/analytics/events/ui/playbackSpeedChanged.js +0 -3
  155. package/dist/esm/customMediaPlayer/analytics/events/ui/shortcutPressed.js +0 -3
  156. package/dist/esm/customMediaPlayer/analytics/events/ui/timeRangeNavigated.js +0 -3
  157. package/dist/esm/customMediaPlayer/analytics/utils/analytics.js +4 -2
  158. package/dist/esm/customMediaPlayer/analytics/utils/playbackAttributes.js +10 -10
  159. package/dist/esm/customMediaPlayer/fullscreen.js +4 -9
  160. package/dist/esm/customMediaPlayer/icons.js +0 -4
  161. package/dist/esm/customMediaPlayer/index.js +54 -153
  162. package/dist/esm/customMediaPlayer/playPauseBlanket.js +0 -2
  163. package/dist/esm/customMediaPlayer/playbackSpeedControls.js +7 -30
  164. package/dist/esm/customMediaPlayer/simultaneousPlayManager.js +0 -4
  165. package/dist/esm/customMediaPlayer/styled.js +0 -2
  166. package/dist/esm/customMediaPlayer/timeRange.js +24 -51
  167. package/dist/esm/customMediaPlayer/timeSaver.js +5 -10
  168. package/dist/esm/ellipsify.js +4 -14
  169. package/dist/esm/formatDate.js +6 -6
  170. package/dist/esm/formatDuration.js +0 -3
  171. package/dist/esm/humanReadableSize.js +3 -2
  172. package/dist/esm/imageMetaData/imageOrientationUtil.js +1 -2
  173. package/dist/esm/imageMetaData/index.js +8 -40
  174. package/dist/esm/imageMetaData/metatags.js +0 -15
  175. package/dist/esm/imageMetaData/parseJPEG.js +1 -8
  176. package/dist/esm/imageMetaData/parsePNG.js +0 -21
  177. package/dist/esm/imageMetaData/parsePNGXMP.js +0 -3
  178. package/dist/esm/imageMetaData/types.js +0 -5
  179. package/dist/esm/inactivityDetector/inactivityDetector.js +5 -25
  180. package/dist/esm/inactivityDetector/styled.js +0 -4
  181. package/dist/esm/media-type-icon.js +3 -13
  182. package/dist/esm/mediaImage/index.js +28 -51
  183. package/dist/esm/mediaImage/styled.js +2 -6
  184. package/dist/esm/mime-type-icon.js +13 -13
  185. package/dist/esm/mixins.js +0 -2
  186. package/dist/esm/modalSpinner.js +1 -3
  187. package/dist/esm/shortcut.js +3 -19
  188. package/dist/esm/truncateText.js +12 -22
  189. package/dist/esm/util.js +16 -46
  190. package/dist/esm/version.json +1 -1
  191. package/package.json +6 -4
@@ -7,12 +7,10 @@ import { getCssFromImageOrientation, isRotated } from '../imageMetaData';
7
7
  export class MediaImage extends Component {
8
8
  constructor(props) {
9
9
  super(props);
10
-
11
10
  _defineProperty(this, "onImageLoad", e => {
12
11
  if (!this.imageRef || !this.imageRef.current) {
13
12
  return;
14
13
  }
15
-
16
14
  const {
17
15
  onImageLoad
18
16
  } = this.props;
@@ -21,12 +19,10 @@ export class MediaImage extends Component {
21
19
  imgWidth: this.imageRef.current.naturalWidth,
22
20
  imgHeight: this.imageRef.current.naturalHeight
23
21
  });
24
-
25
22
  if (onImageLoad) {
26
23
  onImageLoad(e.currentTarget);
27
24
  }
28
25
  });
29
-
30
26
  this.imageRef = /*#__PURE__*/React.createRef();
31
27
  this.state = {
32
28
  isImageLoaded: false,
@@ -35,17 +31,16 @@ export class MediaImage extends Component {
35
31
  parentWidth: Infinity,
36
32
  parentHeight: Infinity
37
33
  };
38
- } // TODO FIL-4060 we need to check whether the dataURI changes in UNSAFE_componentWillReceiveProps()
39
- // and if it does recalculate the image height and width
34
+ }
40
35
 
36
+ // TODO FIL-4060 we need to check whether the dataURI changes in UNSAFE_componentWillReceiveProps()
37
+ // and if it does recalculate the image height and width
41
38
 
42
39
  componentDidMount() {
43
40
  const parent = ReactDOM.findDOMNode(this).parentElement;
44
-
45
41
  if (!parent) {
46
42
  return;
47
43
  }
48
-
49
44
  const {
50
45
  width,
51
46
  height
@@ -55,7 +50,6 @@ export class MediaImage extends Component {
55
50
  parentHeight: height
56
51
  });
57
52
  }
58
-
59
53
  render() {
60
54
  const {
61
55
  crop,
@@ -78,6 +72,7 @@ export class MediaImage extends Component {
78
72
  const parentRatio = parentWidth / parentHeight;
79
73
  let imgRatio = imgWidth / imgHeight;
80
74
  let percentSize = '100%';
75
+
81
76
  /*
82
77
  Cover strategy means we want to full entire screen with an image. Here is an example:
83
78
  Image Container Result (░ - is what cropped out)
@@ -88,8 +83,8 @@ export class MediaImage extends Component {
88
83
  │▓▓▓▓▓▓▓▓▓▓▓▓▓▓│ └──────┘ └───┴──────┴───┘
89
84
  └──────────────┘
90
85
  */
91
-
92
86
  const isCoverStrategy = crop;
87
+
93
88
  /*
94
89
  Fit strategy means image is fully inside container even if there is empty space left.
95
90
  Here is an example:
@@ -101,9 +96,9 @@ export class MediaImage extends Component {
101
96
  │▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓│ │ │ ├──────┤
102
97
  └────────────────────┘ └──────┘ └──────┘
103
98
  */
104
-
105
99
  const isFitStrategy = !crop;
106
100
  const isImageRotated = previewOrientation !== 'from-image' && isRotated(previewOrientation);
101
+
107
102
  /*
108
103
  When photo has orientation of 90deg or 270deg (stored in EXIF meta data)
109
104
  things get very tricky. Let me go through an two examples to explain how we deal with that:
@@ -225,11 +220,11 @@ export class MediaImage extends Component {
225
220
  750px -> (750x134) / 1000 = 100px
226
221
  So, 100x134 image in 100x200 container.
227
222
  */
228
-
229
223
  if (isImageRotated) {
230
224
  imgRatio = 1 / imgRatio;
231
225
  percentSize = `${Math.ceil(imgRatio * 100)}%`;
232
226
  }
227
+
233
228
  /*
234
229
  Here is an example of when isImageMoreLandscapyThanContainer is true:
235
230
  Image Container OR Image Container
@@ -241,27 +236,25 @@ export class MediaImage extends Component {
241
236
  |____| |__|
242
237
  For false just swap "Image" and "Container" in the example above.
243
238
  */
244
-
245
-
246
239
  const isImageMoreLandscapyThanContainer = imgRatio > parentRatio;
247
240
  const isImgLandscape = imgWidth > imgHeight;
241
+
248
242
  /*
249
243
  This is two cases we need to cover as described in Example #2 above, but only for rotated landscape images.
250
244
  */
251
-
252
245
  if (isImageRotated && isImgLandscape) {
253
246
  if (isFitStrategy || isImageMoreLandscapyThanContainer || isCoverStrategy && !isImageMoreLandscapyThanContainer) {
254
247
  percentSize = `${Math.ceil(1 / imgRatio * 100)}%`;
255
248
  }
256
249
  }
250
+
257
251
  /*
258
252
  When isStretchingAllowed is false image is as big as it is, but as small as container
259
253
  (according to strategy - cover or fit).
260
254
  isStretchingAllowed is true if image is bigger then container.
261
255
  */
262
-
263
-
264
256
  const isStretchingAllowed = stretch;
257
+
265
258
  /*
266
259
  We do not want to show image until we finish deciding on sizing strategy.
267
260
  Though if it is a "fit" strategy (and image hasn't been rotated) we can display it right away,
@@ -270,12 +263,10 @@ export class MediaImage extends Component {
270
263
  The reason for exclude isImageRotated is that we need to calculate percentSize variable
271
264
  and we can do that only when image is loaded (and we have image size)
272
265
  */
273
-
274
266
  const showImage = forceSyncDisplay || isImageLoaded || isFitStrategy && !isImageRotated;
275
267
  const style = {
276
268
  transform: 'translate(-50%, -50%)'
277
269
  };
278
-
279
270
  if (isStretchingAllowed) {
280
271
  if (isFitStrategy && isImageMoreLandscapyThanContainer) {
281
272
  /*
@@ -351,18 +342,15 @@ export class MediaImage extends Component {
351
342
  style.maxWidth = percentSize;
352
343
  }
353
344
  }
354
-
355
345
  if (!showImage) {
356
346
  style.display = 'none';
357
347
  }
358
-
359
348
  if (previewOrientation === 'from-image') {
360
349
  style.imageOrientation = 'from-image';
361
350
  } else if (previewOrientation > 1) {
362
351
  const transform = getCssFromImageOrientation(previewOrientation);
363
352
  style.transform += ` ${transform}`;
364
353
  }
365
-
366
354
  return /*#__PURE__*/React.createElement(ImageComponent, {
367
355
  loading: loading,
368
356
  "data-testid": "media-image",
@@ -376,9 +364,7 @@ export class MediaImage extends Component {
376
364
  crossOrigin: crossOrigin
377
365
  });
378
366
  }
379
-
380
367
  }
381
-
382
368
  _defineProperty(MediaImage, "defaultProps", {
383
369
  crop: true,
384
370
  stretch: false,
@@ -15,7 +15,8 @@ export const ImageComponent = props => {
15
15
  } = props;
16
16
  return /*#__PURE__*/React.createElement("img", _extends({}, otherProps, {
17
17
  ref: imageRef,
18
- style: { ...imgStyle,
18
+ style: {
19
+ ...imgStyle,
19
20
  ...style
20
21
  }
21
22
  }));
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { getMimeIcon } from './util';
3
3
  import { MediaTypeIcon } from './media-type-icon';
4
4
  import { IconWrapper } from './media-type-icon';
5
-
6
5
  /*
7
6
  * Renders an icon. First, check if the mimeType corresponds to any of the special mimeType icons (.gif, .sketch, .exe, ect). If so, render that icon.
8
7
  * Else, render an icon corresponding to its mediaType (doc/audio/image/video/unknown)
@@ -15,8 +14,9 @@ export const MimeTypeIcon = ({
15
14
  size = 'large'
16
15
  }) => {
17
16
  // retrieve mimetype icon and label
18
- const iconInfo = getMimeIcon(mimeType, name); // a corresponding mimetype icon and label was found.
17
+ const iconInfo = getMimeIcon(mimeType, name);
19
18
 
19
+ // a corresponding mimetype icon and label was found.
20
20
  if (iconInfo) {
21
21
  const Icon = iconInfo.icon;
22
22
  return /*#__PURE__*/React.createElement(IconWrapper, {
@@ -26,10 +26,10 @@ export const MimeTypeIcon = ({
26
26
  }, /*#__PURE__*/React.createElement(Icon, {
27
27
  label: iconInfo.label
28
28
  }));
29
- } // no corresponding mimetype icon/label was found.
30
- // Hence, return a mediatype (image/doc/audio/video/unknown) icon
31
-
29
+ }
32
30
 
31
+ // no corresponding mimetype icon/label was found.
32
+ // Hence, return a mediatype (image/doc/audio/video/unknown) icon
33
33
  return /*#__PURE__*/React.createElement(MediaTypeIcon, {
34
34
  testId: testId,
35
35
  type: mediaType,
@@ -9,42 +9,33 @@ export const keyCodes = {
9
9
  export class Shortcut extends Component {
10
10
  constructor(...args) {
11
11
  super(...args);
12
-
13
12
  _defineProperty(this, "keyHandler", e => {
14
13
  const {
15
14
  handler,
16
15
  code,
17
16
  keyCode
18
17
  } = this.props;
19
-
20
18
  if (keyCode !== undefined && e.keyCode === keyCode) {
21
19
  handler();
22
20
  }
23
-
24
21
  if (code !== undefined && e.code === code) {
25
22
  handler();
26
23
  }
27
24
  });
28
-
29
25
  _defineProperty(this, "init", () => {
30
26
  document.addEventListener('keydown', this.keyHandler);
31
27
  });
32
-
33
28
  _defineProperty(this, "release", () => {
34
29
  document.removeEventListener('keydown', this.keyHandler);
35
30
  });
36
31
  }
37
-
38
32
  componentDidMount() {
39
33
  this.init();
40
34
  }
41
-
42
35
  componentWillUnmount() {
43
36
  this.release();
44
37
  }
45
-
46
38
  render() {
47
39
  return null;
48
40
  }
49
-
50
41
  }
@@ -28,7 +28,6 @@ export const TruncateRight = styled.span`
28
28
  `;
29
29
  export const calculateTruncation = (text, startFixedChars, endFixedChars) => {
30
30
  const minAllowedLength = endFixedChars + startFixedChars;
31
-
32
31
  if (text.length <= minAllowedLength) {
33
32
  // if no truncation return same value for left and right
34
33
  return {
@@ -36,7 +35,6 @@ export const calculateTruncation = (text, startFixedChars, endFixedChars) => {
36
35
  right: text
37
36
  };
38
37
  }
39
-
40
38
  const splitAt = text.length - endFixedChars;
41
39
  const left = text.substr(0, splitAt);
42
40
  const right = text.substr(splitAt);
@@ -45,10 +43,7 @@ export const calculateTruncation = (text, startFixedChars, endFixedChars) => {
45
43
  right
46
44
  };
47
45
  };
48
-
49
- const fontFaceScaleFactor = fontSizePX => fontSizePX / 11 * 0.46;
50
- /* factor for fontSize of 11px */
51
-
46
+ const fontFaceScaleFactor = fontSizePX => fontSizePX / 11 * 0.46; /* factor for fontSize of 11px */
52
47
 
53
48
  export const Truncate = ({
54
49
  text,
@@ -57,17 +52,14 @@ export const Truncate = ({
57
52
  startFixedChars = 4,
58
53
  // 1 char + 3 dots
59
54
  endFixedChars = 7 // file extension 3/4 chars + a fraction of the name
60
-
61
55
  }) => {
62
56
  const {
63
57
  left: leftStr,
64
58
  right: rightStr
65
59
  } = calculateTruncation(text, startFixedChars, endFixedChars);
66
-
67
60
  if (leftStr === rightStr) {
68
61
  return /*#__PURE__*/React.createElement(React.Fragment, null, text);
69
62
  }
70
-
71
63
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TruncateLeft, {
72
64
  fontSizePX: fontSizePX,
73
65
  startFixedChars: startFixedChars,
@@ -17,32 +17,29 @@ import { isCodeViewerItem } from './codeViewer';
17
17
  export function dataURItoFile(dataURI, filename = 'untitled') {
18
18
  if (dataURI.length === 0) {
19
19
  throw new Error('dataURI not found');
20
- } // convert base64/URLEncoded data component to raw binary data held in a string
21
-
20
+ }
22
21
 
22
+ // convert base64/URLEncoded data component to raw binary data held in a string
23
23
  const dataURIParts = dataURI.split(',');
24
- const byteString = dataURIParts[0].indexOf('base64') >= 0 ? atob(dataURIParts[1]) : decodeURIComponent(dataURIParts[1]); // separate out the mime component
24
+ const byteString = dataURIParts[0].indexOf('base64') >= 0 ? atob(dataURIParts[1]) : decodeURIComponent(dataURIParts[1]);
25
25
 
26
+ // separate out the mime component
26
27
  let mimeString;
27
-
28
28
  try {
29
29
  mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
30
30
  } catch (e) {
31
31
  // https://stackoverflow.com/questions/1176022/unknown-file-type-mime
32
32
  mimeString = 'application/octet-stream';
33
- } // write the bytes of the string to a typed array
34
-
33
+ }
35
34
 
35
+ // write the bytes of the string to a typed array
36
36
  const intArray = new Uint8Array(byteString.length);
37
-
38
37
  for (let i = 0; i < byteString.length; i++) {
39
38
  intArray[i] = byteString.charCodeAt(i);
40
39
  }
41
-
42
40
  const blob = new Blob([intArray], {
43
41
  type: mimeString
44
42
  });
45
-
46
43
  try {
47
44
  return new File([blob], filename, {
48
45
  type: mimeString
@@ -65,7 +62,6 @@ export function fileToDataURI(blob) {
65
62
  const reader = new FileReader();
66
63
  reader.addEventListener('load', () => {
67
64
  const result = reader.result;
68
-
69
65
  if (typeof result === 'string') {
70
66
  resolve(result);
71
67
  } else if (result === null) {
@@ -103,11 +99,9 @@ export function loadImage(src) {
103
99
  return new Promise((resolve, reject) => {
104
100
  const img = new Image();
105
101
  img.src = src;
106
-
107
102
  img.onload = () => {
108
103
  resolve(img);
109
104
  };
110
-
111
105
  img.onerror = reject;
112
106
  });
113
107
  }
@@ -129,13 +123,10 @@ export const findParentByClassname = (element, className, maxParentElement = doc
129
123
  if (element.classList.contains(className)) {
130
124
  return element;
131
125
  }
132
-
133
126
  let currentElement = element;
134
-
135
127
  while (currentElement.parentElement !== maxParentElement) {
136
128
  if (currentElement.parentElement) {
137
129
  currentElement = currentElement.parentElement;
138
-
139
130
  if (currentElement.classList.contains(className)) {
140
131
  return currentElement;
141
132
  }
@@ -143,7 +134,6 @@ export const findParentByClassname = (element, className, maxParentElement = doc
143
134
  return undefined;
144
135
  }
145
136
  }
146
-
147
137
  return undefined;
148
138
  };
149
139
  const mimeTypes = [{
@@ -195,48 +185,46 @@ const mimeTypes = [{
195
185
  mimeTypes: ['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel', 'application/x-iwork-keynote-sffnumbers'],
196
186
  icon: ExcelSpreadsheetIcon
197
187
  }];
188
+
198
189
  /*
199
190
  * Returns a label and icon
200
191
  */
201
-
202
192
  export function getMimeIcon(mimeType, fileName) {
203
193
  // based on the mimeType, determine the corresponding icon and label
204
- const iconInfo = mimeTypes.find(file => file.mimeTypes.indexOf(mimeType) > -1); //return the appropriate icon and its label if we have it
194
+ const iconInfo = mimeTypes.find(file => file.mimeTypes.indexOf(mimeType) > -1);
205
195
 
196
+ //return the appropriate icon and its label if we have it
206
197
  if (iconInfo) {
207
198
  return iconInfo;
208
199
  }
209
-
210
200
  if (isCodeViewerItem(fileName, mimeType)) {
211
201
  return {
212
202
  label: 'source-code',
213
203
  icon: SourceCodeIcon
214
204
  };
215
- } // we are not able to determine what icon to render based on the mimeType
216
- // hence we render the icon based on the filename
217
-
205
+ }
218
206
 
207
+ // we are not able to determine what icon to render based on the mimeType
208
+ // hence we render the icon based on the filename
219
209
  if (fileName.match(/.*\.sketch$/)) {
220
210
  return {
221
211
  label: 'sketch',
222
212
  icon: SketchIcon
223
213
  };
224
214
  }
225
-
226
215
  if (fileName.match(/.*\.fig$/)) {
227
216
  return {
228
217
  label: 'figma',
229
218
  icon: FigmaIcon
230
219
  };
231
220
  }
232
-
233
221
  if (fileName.match(/.*\.exe$/) || fileName.match(/.*\.dmg$/)) {
234
222
  return {
235
223
  label: 'executable',
236
224
  icon: ExecutableIcon
237
225
  };
238
- } // cannot find a corresponding mimeType icon.
239
-
226
+ }
240
227
 
228
+ // cannot find a corresponding mimeType icon.
241
229
  return undefined;
242
230
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/media-ui",
3
- "version": "22.3.0",
3
+ "version": "22.3.2",
4
4
  "sideEffects": false
5
5
  }
@@ -3,12 +3,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _typeof from "@babel/runtime/helpers/typeof";
5
5
  var _excluded = ["appearance", "buttonRef"],
6
- _excluded2 = ["buttonStyles"];
7
-
6
+ _excluded2 = ["buttonStyles"];
8
7
  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; }
9
-
10
8
  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; }
11
-
12
9
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
13
10
  // Keep Media buttons to use static colors from the new color palette to support the hybrid
14
11
  // theming in media viewer https://product-fabric.atlassian.net/browse/DSP-6067
@@ -84,18 +81,15 @@ var buttonTheme = {
84
81
  }
85
82
  }
86
83
  };
87
-
88
84
  function extract(newTheme, _ref) {
89
85
  var appearance = _ref.appearance,
90
- state = _ref.state,
91
- mode = _ref.mode;
92
-
86
+ state = _ref.state,
87
+ mode = _ref.mode;
93
88
  // @ts-ignore
94
89
  if (!newTheme[appearance]) {
95
90
  return;
96
- } // @ts-ignore
97
-
98
-
91
+ }
92
+ // @ts-ignore
99
93
  var root = newTheme[appearance];
100
94
  return Object.keys(root).reduce(function (acc, val) {
101
95
  var node = root;
@@ -103,34 +97,30 @@ function extract(newTheme, _ref) {
103
97
  if (!node[item]) {
104
98
  return;
105
99
  }
106
-
107
100
  if (_typeof(node[item]) !== 'object') {
108
101
  acc[val] = node[item];
109
102
  return;
110
103
  }
111
-
112
104
  node = node[item];
113
105
  return;
114
106
  });
115
107
  return acc;
116
108
  }, {});
117
109
  }
118
-
119
110
  export default function MediaButton(_ref2) {
120
111
  var _ref2$appearance = _ref2.appearance,
121
- appearance = _ref2$appearance === void 0 ? 'default' : _ref2$appearance,
122
- buttonRef = _ref2.buttonRef,
123
- rest = _objectWithoutProperties(_ref2, _excluded);
124
-
112
+ appearance = _ref2$appearance === void 0 ? 'default' : _ref2$appearance,
113
+ buttonRef = _ref2.buttonRef,
114
+ rest = _objectWithoutProperties(_ref2, _excluded);
125
115
  return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
126
- ref: buttonRef // Giving button the 'default' appearance so it can calculate the base styles
116
+ ref: buttonRef
117
+ // Giving button the 'default' appearance so it can calculate the base styles
127
118
  ,
128
119
  appearance: appearance,
129
120
  theme: function theme(currentTheme, themeProps) {
130
121
  var _currentTheme = currentTheme(themeProps),
131
- buttonStyles = _currentTheme.buttonStyles,
132
- rest = _objectWithoutProperties(_currentTheme, _excluded2);
133
-
122
+ buttonStyles = _currentTheme.buttonStyles,
123
+ rest = _objectWithoutProperties(_currentTheme, _excluded2);
134
124
  return _objectSpread({
135
125
  buttonStyles: _objectSpread(_objectSpread({}, buttonStyles), extract(buttonTheme, _objectSpread(_objectSpread({}, themeProps), {}, {
136
126
  appearance: appearance
@@ -5,11 +5,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
8
  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); }; }
10
-
11
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
10
  import React from 'react';
14
11
  import { R300 } from '@atlaskit/theme/colors';
15
12
  import WarningIcon from '@atlaskit/icon/glyph/warning';
@@ -19,38 +16,30 @@ import { AKIconWrapper } from '../Icon';
19
16
  import { NoLinkAppearance } from '../styled';
20
17
  export var MediaInlineCardErroredView = /*#__PURE__*/function (_React$Component) {
21
18
  _inherits(MediaInlineCardErroredView, _React$Component);
22
-
23
19
  var _super = _createSuper(MediaInlineCardErroredView);
24
-
25
20
  function MediaInlineCardErroredView() {
26
21
  var _this;
27
-
28
22
  _classCallCheck(this, MediaInlineCardErroredView);
29
-
30
23
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
31
24
  args[_key] = arguments[_key];
32
25
  }
33
-
34
26
  _this = _super.call.apply(_super, [this].concat(args));
35
-
36
27
  _defineProperty(_assertThisInitialized(_this), "renderMessage", function () {
37
28
  var message = _this.props.message;
38
29
  var errorMessage = /*#__PURE__*/React.createElement(NoLinkAppearance, null, message);
39
30
  return /*#__PURE__*/React.createElement(React.Fragment, null, errorMessage);
40
31
  });
41
-
42
32
  return _this;
43
33
  }
44
-
45
34
  _createClass(MediaInlineCardErroredView, [{
46
35
  key: "render",
47
36
  value: function render() {
48
37
  var _this$props = this.props,
49
- onClick = _this$props.onClick,
50
- isSelected = _this$props.isSelected,
51
- _this$props$testId = _this$props.testId,
52
- testId = _this$props$testId === void 0 ? 'media-inline-card-errored-view' : _this$props$testId,
53
- icon = _this$props.icon;
38
+ onClick = _this$props.onClick,
39
+ isSelected = _this$props.isSelected,
40
+ _this$props$testId = _this$props.testId,
41
+ testId = _this$props$testId === void 0 ? 'media-inline-card-errored-view' : _this$props$testId,
42
+ icon = _this$props.icon;
54
43
  return /*#__PURE__*/React.createElement(Frame, {
55
44
  testId: testId,
56
45
  onClick: onClick,
@@ -65,6 +54,5 @@ export var MediaInlineCardErroredView = /*#__PURE__*/function (_React$Component)
65
54
  }));
66
55
  }
67
56
  }]);
68
-
69
57
  return MediaInlineCardErroredView;
70
58
  }(React.Component);
@@ -5,68 +5,52 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
8
  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); }; }
10
-
11
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
10
  import React from 'react';
14
11
  import { Wrapper } from './styled';
15
12
  export var Frame = /*#__PURE__*/function (_React$Component) {
16
13
  _inherits(Frame, _React$Component);
17
-
18
14
  var _super = _createSuper(Frame);
19
-
20
15
  function Frame() {
21
16
  var _this;
22
-
23
17
  _classCallCheck(this, Frame);
24
-
25
18
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
19
  args[_key] = arguments[_key];
27
20
  }
28
-
29
21
  _this = _super.call.apply(_super, [this].concat(args));
30
-
31
22
  _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
32
23
  var onClick = _this.props.onClick;
33
-
34
24
  if (onClick) {
35
25
  event.preventDefault();
36
26
  event.stopPropagation();
37
27
  onClick(event);
38
28
  }
39
29
  });
40
-
41
30
  _defineProperty(_assertThisInitialized(_this), "handleKeyPress", function (event) {
42
31
  if (event.key !== ' ' && event.key !== 'Enter') {
43
32
  return;
44
33
  }
45
-
46
34
  var onClick = _this.props.onClick;
47
-
48
35
  if (onClick) {
49
36
  event.preventDefault();
50
37
  event.stopPropagation();
51
38
  onClick(event);
52
39
  }
53
40
  });
54
-
55
41
  _defineProperty(_assertThisInitialized(_this), "handleMouseDown", function (e) {
56
42
  e.preventDefault();
57
43
  });
58
-
59
44
  return _this;
60
45
  }
61
-
62
46
  _createClass(Frame, [{
63
47
  key: "render",
64
48
  value: function render() {
65
49
  var _this$props = this.props,
66
- isSelected = _this$props.isSelected,
67
- children = _this$props.children,
68
- onClick = _this$props.onClick,
69
- testId = _this$props.testId;
50
+ isSelected = _this$props.isSelected,
51
+ children = _this$props.children,
52
+ onClick = _this$props.onClick,
53
+ testId = _this$props.testId;
70
54
  var isInteractive = Boolean(onClick);
71
55
  return /*#__PURE__*/React.createElement(Wrapper, {
72
56
  isSelected: isSelected,
@@ -79,6 +63,5 @@ export var Frame = /*#__PURE__*/function (_React$Component) {
79
63
  }, children);
80
64
  }
81
65
  }]);
82
-
83
66
  return Frame;
84
67
  }(React.Component);