@atlaskit/media-card 70.11.0 → 73.0.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.
Files changed (197) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/cjs/errors.js +78 -5
  3. package/dist/cjs/files/cardImageView/cardOverlay/styled.js +1 -1
  4. package/dist/cjs/files/cardImageView/index.js +53 -104
  5. package/dist/cjs/files/cardImageView/styled.js +1 -1
  6. package/dist/cjs/files/index.js +0 -6
  7. package/dist/cjs/index.js +12 -6
  8. package/dist/cjs/root/card/cardAnalytics.js +11 -17
  9. package/dist/cjs/root/card/cardLoader.js +66 -124
  10. package/dist/cjs/root/card/cardState.js +50 -0
  11. package/dist/cjs/root/card/getCardPreview/cache.js +6 -1
  12. package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +53 -0
  13. package/dist/cjs/root/card/getCardPreview/helpers.js +14 -22
  14. package/dist/cjs/root/card/getCardPreview/index.js +176 -102
  15. package/dist/cjs/root/card/getCardStatus.js +7 -1
  16. package/dist/cjs/root/card/index.js +361 -281
  17. package/dist/cjs/root/cardView.js +109 -86
  18. package/dist/cjs/root/index.js +9 -1
  19. package/dist/cjs/root/inline/loader.js +22 -21
  20. package/dist/cjs/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +84 -26
  21. package/dist/cjs/root/inlinePlayer.js +4 -3
  22. package/dist/cjs/root/styled.js +7 -3
  23. package/dist/cjs/root/ui/actionsBar/styled.js +1 -1
  24. package/dist/cjs/root/ui/blanket/styled.js +1 -1
  25. package/dist/cjs/root/ui/common.js +11 -5
  26. package/dist/cjs/root/ui/iconMessage/index.js +16 -7
  27. package/dist/cjs/root/ui/iconWrapper/styled.js +1 -1
  28. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +34 -124
  29. package/dist/cjs/root/ui/loadingRateLimited/loadingRateLimited.js +6 -4
  30. package/dist/cjs/root/ui/loadingRateLimited/styled.js +1 -1
  31. package/dist/cjs/root/ui/playButton/styled.js +1 -1
  32. package/dist/cjs/root/ui/progressBar/progressBar.js +2 -2
  33. package/dist/cjs/root/ui/progressBar/styled.js +2 -4
  34. package/dist/cjs/root/ui/styled.js +80 -17
  35. package/dist/cjs/root/ui/tickBox/styled.js +1 -1
  36. package/dist/cjs/root/ui/titleBox/failedTitleBox.js +9 -3
  37. package/dist/cjs/root/ui/titleBox/styled.js +2 -4
  38. package/dist/cjs/root/ui/titleBox/titleBox.js +2 -2
  39. package/dist/cjs/styles/index.js +25 -23
  40. package/dist/cjs/styles/mixins.js +1 -1
  41. package/dist/cjs/utils/analytics.js +21 -43
  42. package/dist/cjs/utils/breakpoint.js +1 -1
  43. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +16 -9
  44. package/dist/cjs/utils/cardActions/index.js +10 -10
  45. package/dist/cjs/utils/cardActions/styled.js +1 -1
  46. package/dist/cjs/utils/cardDimensions.js +1 -1
  47. package/dist/cjs/utils/dimensionComparer.js +1 -1
  48. package/dist/cjs/utils/getErrorMessage.js +2 -2
  49. package/dist/cjs/utils/index.js +46 -46
  50. package/dist/cjs/utils/lightCards/styled.js +1 -1
  51. package/dist/cjs/utils/metadata.js +11 -3
  52. package/dist/cjs/utils/objectURLCache.js +7 -1
  53. package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
  54. package/dist/cjs/utils/viewportDetector.js +1 -1
  55. package/dist/cjs/version.json +1 -1
  56. package/dist/es2019/errors.js +42 -2
  57. package/dist/es2019/files/cardImageView/index.js +8 -61
  58. package/dist/es2019/files/index.js +1 -1
  59. package/dist/es2019/index.js +1 -1
  60. package/dist/es2019/root/card/cardAnalytics.js +7 -15
  61. package/dist/es2019/root/card/cardLoader.js +47 -53
  62. package/dist/es2019/root/card/cardState.js +26 -0
  63. package/dist/es2019/root/card/getCardPreview/cache.js +5 -0
  64. package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +38 -0
  65. package/dist/es2019/root/card/getCardPreview/helpers.js +2 -12
  66. package/dist/es2019/root/card/getCardPreview/index.js +112 -79
  67. package/dist/es2019/root/card/getCardStatus.js +1 -0
  68. package/dist/es2019/root/card/index.js +285 -190
  69. package/dist/es2019/root/cardView.js +93 -68
  70. package/dist/es2019/root/index.js +2 -1
  71. package/dist/es2019/root/inline/loader.js +16 -15
  72. package/dist/es2019/root/inline/mediaInlineCard.js +143 -0
  73. package/dist/es2019/root/inlinePlayer.js +3 -2
  74. package/dist/es2019/root/styled.js +2 -1
  75. package/dist/es2019/root/ui/common.js +7 -1
  76. package/dist/es2019/root/ui/iconMessage/index.js +8 -5
  77. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +25 -88
  78. package/dist/es2019/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  79. package/dist/es2019/root/ui/progressBar/progressBar.js +1 -1
  80. package/dist/es2019/root/ui/progressBar/styled.js +1 -2
  81. package/dist/es2019/root/ui/styled.js +64 -3
  82. package/dist/es2019/root/ui/titleBox/failedTitleBox.js +6 -3
  83. package/dist/es2019/root/ui/titleBox/styled.js +1 -2
  84. package/dist/es2019/root/ui/titleBox/titleBox.js +1 -1
  85. package/dist/es2019/utils/analytics.js +15 -34
  86. package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
  87. package/dist/es2019/utils/dimensionComparer.js +1 -1
  88. package/dist/es2019/utils/getErrorMessage.js +1 -1
  89. package/dist/es2019/utils/metadata.js +12 -4
  90. package/dist/es2019/utils/objectURLCache.js +5 -0
  91. package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
  92. package/dist/es2019/version.json +1 -1
  93. package/dist/esm/errors.js +60 -1
  94. package/dist/esm/files/cardImageView/index.js +51 -102
  95. package/dist/esm/files/index.js +1 -1
  96. package/dist/esm/index.js +1 -1
  97. package/dist/esm/root/card/cardAnalytics.js +7 -16
  98. package/dist/esm/root/card/cardLoader.js +66 -126
  99. package/dist/esm/root/card/cardState.js +32 -0
  100. package/dist/esm/root/card/getCardPreview/cache.js +6 -0
  101. package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +38 -0
  102. package/dist/esm/root/card/getCardPreview/helpers.js +13 -21
  103. package/dist/esm/root/card/getCardPreview/index.js +142 -95
  104. package/dist/esm/root/card/getCardStatus.js +3 -0
  105. package/dist/esm/root/card/index.js +370 -284
  106. package/dist/esm/root/cardView.js +109 -84
  107. package/dist/esm/root/index.js +2 -1
  108. package/dist/esm/root/inline/loader.js +23 -22
  109. package/dist/esm/root/inline/mediaInlineCard.js +156 -0
  110. package/dist/esm/root/inlinePlayer.js +3 -2
  111. package/dist/esm/root/styled.js +3 -2
  112. package/dist/esm/root/ui/common.js +7 -1
  113. package/dist/esm/root/ui/iconMessage/index.js +10 -5
  114. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +27 -118
  115. package/dist/esm/root/ui/loadingRateLimited/loadingRateLimited.js +4 -3
  116. package/dist/esm/root/ui/progressBar/progressBar.js +1 -1
  117. package/dist/esm/root/ui/progressBar/styled.js +1 -2
  118. package/dist/esm/root/ui/styled.js +61 -13
  119. package/dist/esm/root/ui/titleBox/failedTitleBox.js +7 -3
  120. package/dist/esm/root/ui/titleBox/styled.js +1 -2
  121. package/dist/esm/root/ui/titleBox/titleBox.js +1 -1
  122. package/dist/esm/utils/analytics.js +16 -35
  123. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +16 -9
  124. package/dist/esm/utils/dimensionComparer.js +1 -1
  125. package/dist/esm/utils/getErrorMessage.js +1 -1
  126. package/dist/esm/utils/metadata.js +12 -4
  127. package/dist/esm/utils/objectURLCache.js +6 -0
  128. package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
  129. package/dist/esm/version.json +1 -1
  130. package/dist/types/errors.d.ts +15 -1
  131. package/dist/types/files/cardImageView/index.d.ts +4 -13
  132. package/dist/types/files/cardImageView/styled.d.ts +1 -1
  133. package/dist/types/files/index.d.ts +1 -1
  134. package/dist/types/index.d.ts +7 -5
  135. package/dist/types/root/card/cardAnalytics.d.ts +2 -6
  136. package/dist/types/root/card/cardLoader.d.ts +5 -19
  137. package/dist/types/root/card/cardState.d.ts +5 -0
  138. package/dist/types/root/card/getCardPreview/cache.d.ts +3 -1
  139. package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
  140. package/dist/types/root/card/getCardPreview/helpers.d.ts +3 -4
  141. package/dist/types/root/card/getCardPreview/index.d.ts +24 -14
  142. package/dist/types/root/card/getCardStatus.d.ts +1 -0
  143. package/dist/types/root/card/index.d.ts +19 -18
  144. package/dist/types/root/cardView.d.ts +13 -8
  145. package/dist/types/root/index.d.ts +1 -0
  146. package/dist/types/root/inline/loader.d.ts +8 -8
  147. package/dist/types/root/inline/{inlineMediaCard.d.ts → mediaInlineCard.d.ts} +4 -6
  148. package/dist/types/root/inlinePlayer.d.ts +1 -1
  149. package/dist/types/root/styled.d.ts +1 -0
  150. package/dist/types/root/ui/common.d.ts +4 -1
  151. package/dist/types/root/ui/iconMessage/index.d.ts +4 -3
  152. package/dist/types/root/ui/iconWrapper/styled.d.ts +1 -1
  153. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +5 -15
  154. package/dist/types/root/ui/loadingRateLimited/loadingRateLimited.d.ts +2 -1
  155. package/dist/types/root/ui/loadingRateLimited/styled.d.ts +1 -1
  156. package/dist/types/root/ui/playButton/playButton.d.ts +1 -0
  157. package/dist/types/root/ui/progressBar/progressBar.d.ts +2 -1
  158. package/dist/types/root/ui/progressBar/styled.d.ts +1 -1
  159. package/dist/types/root/ui/styled.d.ts +10 -3
  160. package/dist/types/root/ui/tickBox/tickBox.d.ts +1 -0
  161. package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +3 -1
  162. package/dist/types/root/ui/titleBox/styled.d.ts +1 -1
  163. package/dist/types/root/ui/titleBox/titleBox.d.ts +2 -10
  164. package/dist/types/styles/mixins.d.ts +1 -1
  165. package/dist/types/types.d.ts +7 -1
  166. package/dist/types/utils/analytics.d.ts +14 -15
  167. package/dist/types/utils/cardDimensions.d.ts +4 -4
  168. package/dist/types/utils/dimensionComparer.d.ts +1 -1
  169. package/dist/types/utils/getErrorMessage.d.ts +1 -0
  170. package/dist/types/utils/metadata.d.ts +2 -2
  171. package/dist/types/utils/objectURLCache.d.ts +2 -1
  172. package/example-helpers/developmentUseMessage.tsx +14 -0
  173. package/example-helpers/index.tsx +55 -4
  174. package/example-helpers/selectableCard.tsx +2 -1
  175. package/package.json +20 -16
  176. package/dist/cjs/root/card/cardSSRView.js +0 -99
  177. package/dist/cjs/root/card/getCardPreview/types.js +0 -5
  178. package/dist/cjs/root/ui/Breakpoint.js +0 -13
  179. package/dist/cjs/root/ui/styledSSR.js +0 -108
  180. package/dist/cjs/utils/fileAttributesContext.js +0 -40
  181. package/dist/es2019/root/card/cardSSRView.js +0 -79
  182. package/dist/es2019/root/card/getCardPreview/types.js +0 -1
  183. package/dist/es2019/root/inline/inlineMediaCard.js +0 -92
  184. package/dist/es2019/root/ui/Breakpoint.js +0 -6
  185. package/dist/es2019/root/ui/styledSSR.js +0 -93
  186. package/dist/es2019/utils/fileAttributesContext.js +0 -19
  187. package/dist/esm/root/card/cardSSRView.js +0 -78
  188. package/dist/esm/root/card/getCardPreview/types.js +0 -1
  189. package/dist/esm/root/inline/inlineMediaCard.js +0 -100
  190. package/dist/esm/root/ui/Breakpoint.js +0 -6
  191. package/dist/esm/root/ui/styledSSR.js +0 -76
  192. package/dist/esm/utils/fileAttributesContext.js +0 -18
  193. package/dist/types/root/card/cardSSRView.d.ts +0 -12
  194. package/dist/types/root/card/getCardPreview/types.d.ts +0 -5
  195. package/dist/types/root/ui/Breakpoint.d.ts +0 -4
  196. package/dist/types/root/ui/styledSSR.d.ts +0 -16
  197. package/dist/types/utils/fileAttributesContext.d.ts +0 -10
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes, ComponentClass } from 'react';
2
- import { Breakpoint } from '../Breakpoint';
2
+ import { Breakpoint } from '../common';
3
3
  export declare const LoadingRateLimitedContainer: import("styled-components").StyledComponentClass<import("react").DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any, import("react").DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
4
4
  export declare const WarningIconWrapper: ComponentClass<HTMLAttributes<{}>>;
5
5
  export declare type StyledTextProps = {
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const PlayButton: () => JSX.Element;
@@ -1,4 +1,5 @@
1
- import { Breakpoint } from '../Breakpoint';
1
+ /// <reference types="react" />
2
+ import { Breakpoint } from '../common';
2
3
  export declare type ProgressBarProps = {
3
4
  progress?: number;
4
5
  breakpoint?: Breakpoint;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Breakpoint } from '../Breakpoint';
2
+ import { Breakpoint } from '../common';
3
3
  export declare function generateResponsiveStyles(breakpoint: Breakpoint, positionBottom: boolean, multiplier?: number): string;
4
4
  export declare type StyledBarProps = {
5
5
  progress: number;
@@ -1,6 +1,12 @@
1
1
  /// <reference types="react" />
2
- import { BaseNewFileExperienceWrapperProps } from './styledSSR';
3
- export interface NewFileExperienceWrapperProps extends BaseNewFileExperienceWrapperProps {
2
+ import { CardDimensions, CardAppearance } from '../..';
3
+ import { Breakpoint } from './common';
4
+ export declare const calcBreakpointSize: (wrapperWidth?: number) => Breakpoint;
5
+ export interface NewFileExperienceWrapperProps {
6
+ breakpoint: Breakpoint;
7
+ dimensions?: CardDimensions;
8
+ appearance?: CardAppearance;
9
+ mediaType?: string;
4
10
  shouldUsePointerCursor: boolean;
5
11
  disableOverlay: boolean;
6
12
  displayBackground: boolean;
@@ -9,4 +15,5 @@ export interface NewFileExperienceWrapperProps extends BaseNewFileExperienceWrap
9
15
  isTickBoxSelectable: boolean;
10
16
  shouldDisplayTooltip: boolean;
11
17
  }
12
- export declare const NewFileExperienceWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & BaseNewFileExperienceWrapperProps & NewFileExperienceWrapperProps, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & BaseNewFileExperienceWrapperProps & NewFileExperienceWrapperProps>;
18
+ export declare const NewFileExperienceWrapper: import("styled-components").StyledComponentClass<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & NewFileExperienceWrapperProps, any, import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & NewFileExperienceWrapperProps>;
19
+ export declare const CardImageContainer: import("styled-components").StyledComponentClass<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare type TickBoxProps = {
2
3
  selected?: boolean;
3
4
  };
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
- import { Breakpoint } from '../Breakpoint';
2
+ import { Breakpoint } from '../common';
3
+ import { MessageDescriptor } from 'react-intl-next';
3
4
  export declare type OnRetryFunction = () => void;
4
5
  export declare type FailedTitleBoxProps = {
5
6
  breakpoint: Breakpoint;
7
+ customMessage?: MessageDescriptor;
6
8
  };
7
9
  export declare const FailedTitleBox: React.FC<FailedTitleBoxProps>;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Breakpoint } from '../Breakpoint';
2
+ import { Breakpoint } from '../common';
3
3
  export declare type TitleBoxWrapperProps = {
4
4
  breakpoint: Breakpoint;
5
5
  titleBoxBgColor?: string;
@@ -1,7 +1,6 @@
1
- /// <reference types="react-intl" />
2
1
  import React from 'react';
3
2
  import { TitleBoxIcon as TitleBoxIconType } from '../../../index';
4
- import { Breakpoint } from '../Breakpoint';
3
+ import { Breakpoint } from '../common';
5
4
  export declare type TitleBoxProps = {
6
5
  name: string;
7
6
  breakpoint: Breakpoint;
@@ -12,13 +11,6 @@ export declare type TitleBoxProps = {
12
11
  declare type FormattedDateProps = {
13
12
  timestamp: number;
14
13
  };
15
- declare type WithIntlProps = {
16
- intl?: {
17
- locale?: string;
18
- };
19
- };
20
- export declare const FormattedDate: React.ComponentClass<FormattedDateProps & WithIntlProps, any> & {
21
- WrappedComponent: ReactIntl.ComponentConstructor<FormattedDateProps & WithIntlProps & ReactIntl.InjectedIntlProps>;
22
- };
14
+ export declare const FormattedDate: React.ComponentType<FormattedDateProps>;
23
15
  export declare const TitleBox: ({ name, createdAt, breakpoint, titleBoxBgColor, titleBoxIcon, }: TitleBoxProps) => JSX.Element;
24
16
  export {};
@@ -14,8 +14,8 @@ export interface WithAppearanceProps {
14
14
  appearance?: CardAppearance;
15
15
  }
16
16
  export declare const withAppearance: (styleMap: {
17
- auto?: string | undefined;
18
17
  image?: string | undefined;
18
+ auto?: string | undefined;
19
19
  square?: string | undefined;
20
20
  horizontal?: string | undefined;
21
21
  }) => ({ appearance }: WithAppearanceProps) => string;
@@ -1,4 +1,4 @@
1
- export declare type CardStatus = 'uploading' | 'loading' | 'processing' | 'loading-preview' | 'complete' | 'error' | 'failed-processing' | 'loading-preview';
1
+ export declare type CardStatus = 'uploading' | 'loading' | 'processing' | 'loading-preview' | 'complete' | 'error' | 'failed-processing';
2
2
  export declare type FilePreviewStatus = {
3
3
  hasFilesize: boolean;
4
4
  isPreviewable: boolean;
@@ -7,3 +7,9 @@ export declare type FilePreviewStatus = {
7
7
  };
8
8
  export declare type CardAppearance = 'auto' | 'image' | 'square' | 'horizontal';
9
9
  export declare type CardDimensionValue = number | string;
10
+ export declare type CardPreviewSource = 'local' | 'remote' | 'ssr-server' | 'ssr-client' | 'cache-local' | 'cache-remote' | 'cache-ssr-client' | 'cache-ssr-server' | 'external';
11
+ export interface CardPreview {
12
+ dataURI: string;
13
+ orientation?: number;
14
+ source: CardPreviewSource;
15
+ }
@@ -1,32 +1,31 @@
1
1
  import { FileDetails, MediaClientErrorReason, RequestMetadata } from '@atlaskit/media-client';
2
- import { FileAttributes, PerformanceAttributes, OperationalEventPayload, UIEventPayload, WithFileAttributes, WithPerformanceAttributes, SuccessAttributes, FailureAttributes } from '@atlaskit/media-common';
2
+ import { FileAttributes, PerformanceAttributes, OperationalEventPayload, UIEventPayload, WithFileAttributes, WithPerformanceAttributes, SuccessAttributes, FailureAttributes, ScreenEventPayload, ScreenAttributes } from '@atlaskit/media-common';
3
3
  import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
4
4
  import { MediaCardError, MediaCardErrorPrimaryReason } from '../errors';
5
- export declare enum RenderEventAction {
6
- COMMENCED = "commenced",
7
- SUCCEEDED = "succeeded",
8
- FAILED = "failed"
9
- }
10
5
  export declare type FileUriFailReason = 'local-uri' | 'remote-uri' | `unknown-uri`;
11
6
  export declare type FailedErrorFailReason = MediaCardErrorPrimaryReason | 'nativeError';
12
- export declare type RenderEventFailReason = FailedErrorFailReason | 'failed-processing' | FileUriFailReason | 'external-uri';
13
7
  export declare type RenderFailedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & FailureAttributes & {
14
- failReason: RenderEventFailReason;
8
+ failReason: FailedErrorFailReason | 'failed-processing';
15
9
  error?: MediaClientErrorReason | 'nativeError';
16
10
  request?: RequestMetadata;
17
- }, RenderEventAction.FAILED, 'mediaCardRender'>;
18
- export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & SuccessAttributes, RenderEventAction.SUCCEEDED, 'mediaCardRender'>;
19
- export declare type RenderCommencedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes, RenderEventAction.COMMENCED, 'mediaCardRender'>;
11
+ }, 'failed', 'mediaCardRender'>;
12
+ export declare type RenderSucceededEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes & SuccessAttributes, 'succeeded', 'mediaCardRender'>;
13
+ export declare type RenderCommencedEventPayload = OperationalEventPayload<WithFileAttributes & WithPerformanceAttributes, 'commenced', 'mediaCardRender'>;
20
14
  export declare type CopiedFileEventPayload = UIEventPayload<{}, 'copied', string>;
21
15
  export declare type ClickedEventPayload = UIEventPayload<{
22
16
  label?: string;
23
17
  }, 'clicked', string>;
24
- export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload | RenderSucceededEventPayload | RenderFailedEventPayload | CopiedFileEventPayload | ClickedEventPayload;
25
- export declare const getFileAttributes: (metadata: FileDetails, fileStatus?: "error" | "uploading" | "processing" | "failed-processing" | "processed" | undefined) => FileAttributes;
18
+ export declare type RenderScreenEventPayload = Omit<ScreenEventPayload<ScreenAttributes, 'mediaCardRenderScreen'>, 'attributes'> & {
19
+ attributes: {
20
+ type: string | undefined;
21
+ fileAttributes: FileAttributes;
22
+ };
23
+ };
24
+ export declare type MediaCardAnalyticsEventPayload = RenderCommencedEventPayload | RenderSucceededEventPayload | RenderFailedEventPayload | CopiedFileEventPayload | ClickedEventPayload | RenderScreenEventPayload;
25
+ export declare const getFileAttributes: (metadata: FileDetails, fileStatus?: "failed-processing" | "uploading" | "processing" | "processed" | "error" | undefined) => FileAttributes;
26
+ export declare const getRenderPreviewableCardPayload: (fileAttributes: FileAttributes) => RenderScreenEventPayload;
26
27
  export declare const getRenderCommencedEventPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderCommencedEventPayload;
27
28
  export declare const getRenderSucceededEventPayload: (fileAttributes: FileAttributes, performanceAttributes?: PerformanceAttributes | undefined) => RenderSucceededEventPayload;
28
- export declare const getFailedFileUriFailReason: (fileStatus?: "error" | "uploading" | "processing" | "failed-processing" | "processed" | undefined) => FileUriFailReason;
29
- export declare const getRenderFailedFileUriPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
30
29
  export declare const getRenderFailedExternalUriPayload: (fileAttributes: FileAttributes, performanceAttributes: PerformanceAttributes) => RenderFailedEventPayload;
31
30
  export declare const getRenderErrorFailReason: (error: MediaCardError) => FailedErrorFailReason;
32
31
  export declare const getRenderErrorErrorReason: (error: MediaCardError) => MediaClientErrorReason | 'nativeError';
@@ -47,7 +47,7 @@ export declare const maxSquareCardDimensions: {
47
47
  width: number;
48
48
  height: number;
49
49
  };
50
- export declare const getCardMaxHeight: (appearance?: "auto" | "image" | "square" | "horizontal" | undefined) => number;
51
- export declare const getCardMinWidth: (appearance?: "auto" | "image" | "square" | "horizontal" | undefined) => number;
52
- export declare const getCardMaxWidth: (appearance?: "auto" | "image" | "square" | "horizontal" | undefined) => number;
53
- export declare const getDefaultCardDimensions: (appearance?: "auto" | "image" | "square" | "horizontal" | undefined) => Required<CardDimensions>;
50
+ export declare const getCardMaxHeight: (appearance?: "image" | "auto" | "square" | "horizontal" | undefined) => number;
51
+ export declare const getCardMinWidth: (appearance?: "image" | "auto" | "square" | "horizontal" | undefined) => number;
52
+ export declare const getCardMaxWidth: (appearance?: "image" | "auto" | "square" | "horizontal" | undefined) => number;
53
+ export declare const getDefaultCardDimensions: (appearance?: "image" | "auto" | "square" | "horizontal" | undefined) => Required<CardDimensions>;
@@ -1,3 +1,3 @@
1
1
  import { CardDimensions } from '../';
2
2
  export declare const canCompareDimension: (current?: string | number | undefined, next?: string | number | undefined) => boolean;
3
- export declare const isBigger: (current: CardDimensions, next: CardDimensions) => boolean;
3
+ export declare const isBigger: (current?: CardDimensions | undefined, next?: CardDimensions | undefined) => boolean;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const getErrorMessage: (status: string) => false | JSX.Element;
@@ -1,2 +1,2 @@
1
- import { FileState, FileDetails } from '@atlaskit/media-client';
2
- export declare const getFileDetails: (state: FileState) => FileDetails;
1
+ import { FileDetails, Identifier, ErrorFileState } from '@atlaskit/media-client';
2
+ export declare const getFileDetails: (identifier: Identifier, fileState?: import("@atlaskit/media-client").UploadingFileState | import("@atlaskit/media-client").ProcessingFileState | import("@atlaskit/media-client").ProcessedFileState | ErrorFileState | import("@atlaskit/media-client").ProcessingFailedState | undefined) => FileDetails;
@@ -1,4 +1,4 @@
1
- import { CardPreview } from '../root/card/getCardPreview';
1
+ import { CardPreview } from '../';
2
2
  export declare const PREVIEW_CACHE_LRU_SIZE = 50;
3
3
  export declare class ObjectURLCache {
4
4
  private readonly cache;
@@ -6,5 +6,6 @@ export declare class ObjectURLCache {
6
6
  has(key: string): boolean;
7
7
  get(key: string): CardPreview | undefined;
8
8
  set(key: string, value: CardPreview): void;
9
+ remove(key: string): void;
9
10
  }
10
11
  export declare const createObjectURLCache: () => ObjectURLCache;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import InlineMessage from '@atlaskit/inline-message';
3
+
4
+ const DevelopmentUseMessage: React.FC = () => (
5
+ <div style={{ textAlign: 'center' }}>
6
+ <InlineMessage type={'warning'} title={'Development use only'}>
7
+ The purpose of this example is to explore on edge cases for this
8
+ component's feature. Some ways of using the component in here might not be
9
+ the standard way. It is discouraged to use this code as a base for
10
+ consumers.
11
+ </InlineMessage>
12
+ </div>
13
+ );
14
+ export default DevelopmentUseMessage;
@@ -3,14 +3,22 @@
3
3
  import React from 'react';
4
4
  import { FileItem, Identifier } from '@atlaskit/media-client';
5
5
  import {
6
+ createPollingMaxAttemptsError,
7
+ createRateLimitedError,
6
8
  createStorybookMediaClientConfig,
7
9
  FeatureFlagsWrapper,
8
10
  } from '@atlaskit/media-test-helpers';
9
11
  import CrossIcon from '@atlaskit/icon/glyph/cross';
12
+ import FabricAnalyticsListeners, {
13
+ AnalyticsWebClient,
14
+ } from '@atlaskit/analytics-listeners';
15
+
10
16
  import AnnotateIcon from '@atlaskit/icon/glyph/media-services/annotate';
11
17
  import { SelectableCard } from './selectableCard';
12
18
  import { Card, CardAppearance, CardEvent, CardAction } from '../src';
13
19
  import { relevantFeatureFlagNames } from '../src/root/card/cardAnalytics';
20
+ import { MediaCardError } from '../src/errors';
21
+ import DevelopmentUseMessage from './developmentUseMessage';
14
22
 
15
23
  const mediaClientConfig = createStorybookMediaClientConfig();
16
24
 
@@ -116,8 +124,51 @@ export const wrongMediaClientConfig = createStorybookMediaClientConfig({
116
124
  });
117
125
  export const wrongCollection = 'adfasdf';
118
126
 
119
- export const MainWrapper: React.FC = ({ children }) => (
120
- <FeatureFlagsWrapper filterFlags={relevantFeatureFlagNames}>
121
- {children}
122
- </FeatureFlagsWrapper>
127
+ export type MainWrapperProps = {
128
+ developmentOnly?: boolean;
129
+ };
130
+
131
+ export const MainWrapper: React.FC<MainWrapperProps> = ({
132
+ children,
133
+ developmentOnly,
134
+ }) => (
135
+ <>
136
+ {developmentOnly && <DevelopmentUseMessage />}
137
+ <FeatureFlagsWrapper filterFlags={relevantFeatureFlagNames}>
138
+ {children}
139
+ </FeatureFlagsWrapper>
140
+ </>
123
141
  );
142
+
143
+ export const mediaCardErrorState = (
144
+ error?: string,
145
+ ): MediaCardError | undefined => {
146
+ switch (error) {
147
+ case 'rateLimitedError':
148
+ return new MediaCardError('error-file-state', createRateLimitedError());
149
+ case 'pollingMaxAttemptsError':
150
+ return new MediaCardError(
151
+ 'error-file-state',
152
+ createPollingMaxAttemptsError(),
153
+ );
154
+ case 'uploadError':
155
+ return new MediaCardError('upload');
156
+ default:
157
+ return undefined;
158
+ }
159
+ };
160
+
161
+ export const SSRAnalyticsWrapper: React.FC = ({ children }) => {
162
+ const mockClient: AnalyticsWebClient = {
163
+ sendUIEvent: (e) => console.debug('UI event', e),
164
+ sendOperationalEvent: (e) => console.debug('Operational event', e),
165
+ sendTrackEvent: (e) => console.debug('Track event', e),
166
+ sendScreenEvent: (e) => console.debug('Screen event', e),
167
+ };
168
+
169
+ return (
170
+ <FabricAnalyticsListeners client={mockClient}>
171
+ {children}
172
+ </FabricAnalyticsListeners>
173
+ );
174
+ };
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
2
  import { Component } from 'react';
3
+ import { MediaClientConfig } from '@atlaskit/media-core';
3
4
  import { Identifier } from '@atlaskit/media-client';
4
5
  import { Card } from '../src';
5
6
 
6
7
  export interface SelectableCardProps {
7
- mediaClientConfig: Card['props']['mediaClientConfig'];
8
+ mediaClientConfig: MediaClientConfig;
8
9
  identifier: Identifier;
9
10
  }
10
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-card",
3
- "version": "70.11.0",
3
+ "version": "73.0.0",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,28 +29,29 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/analytics-next": "^8.2.0",
32
- "@atlaskit/dropdown-menu": "^10.1.0",
33
- "@atlaskit/editor-shared-styles": "^1.3.0",
34
- "@atlaskit/icon": "^21.8.0",
32
+ "@atlaskit/dropdown-menu": "^11.0.0",
33
+ "@atlaskit/editor-shared-styles": "^1.6.0",
34
+ "@atlaskit/icon": "^21.9.0",
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
- "@atlaskit/media-client": "^14.2.0",
37
- "@atlaskit/media-common": "^2.9.0",
38
- "@atlaskit/media-ui": "^16.6.0",
39
- "@atlaskit/media-viewer": "^45.8.0",
36
+ "@atlaskit/media-client": "^14.3.0",
37
+ "@atlaskit/media-common": "^2.10.0",
38
+ "@atlaskit/media-ui": "^18.0.0",
39
+ "@atlaskit/media-viewer": "^46.0.0",
40
40
  "@atlaskit/spinner": "^15.1.0",
41
- "@atlaskit/theme": "^11.5.0",
42
- "@atlaskit/tooltip": "^17.4.0",
41
+ "@atlaskit/theme": "^12.0.0",
42
+ "@atlaskit/tooltip": "^17.5.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "classnames": "^2.2.5",
45
45
  "eventemitter2": "^4.1.0",
46
46
  "lru-fast": "^0.2.2",
47
47
  "react-lazily-render": "^1.2.0",
48
+ "react-loadable": "^5.1.0",
48
49
  "video-snapshot": "^1.0.11"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "react": "^16.8.0",
52
53
  "react-dom": "^16.8.0",
53
- "react-intl": "^2.6.0",
54
+ "react-intl-next": "npm:react-intl@^5.18.1",
54
55
  "rxjs": "^5.5.0",
55
56
  "styled-components": "^3.2.6"
56
57
  },
@@ -61,26 +62,29 @@
61
62
  "@atlaskit/button": "^16.1.0",
62
63
  "@atlaskit/checkbox": "^12.3.0",
63
64
  "@atlaskit/docs": "*",
64
- "@atlaskit/field-radio-group": "^8.0.0",
65
- "@atlaskit/field-range": "^9.0.0",
65
+ "@atlaskit/inline-message": "^11.2.0",
66
66
  "@atlaskit/item": "^12.0.0",
67
67
  "@atlaskit/media-core": "^32.2.0",
68
- "@atlaskit/media-test-helpers": "^28.7.0",
68
+ "@atlaskit/media-test-helpers": "^29.0.0",
69
+ "@atlaskit/radio": "^5.3.2",
70
+ "@atlaskit/range": "^5.1.0",
71
+ "@atlaskit/select": "^15.2.1",
69
72
  "@atlaskit/ssr": "*",
70
73
  "@atlaskit/textfield": "^5.1.0",
71
- "@atlaskit/toggle": "^12.2.0",
74
+ "@atlaskit/toggle": "^12.3.0",
72
75
  "@atlaskit/visual-regression": "*",
73
76
  "@atlaskit/webdriver-runner": "*",
74
77
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
75
78
  "@testing-library/react": "^8.0.1",
76
79
  "@types/classnames": "^2.2.6",
80
+ "@types/react-loadable": "^5.4.1",
77
81
  "deepcopy": "0.6.3",
78
82
  "enzyme": "^3.10.0",
79
83
  "exenv": "^1.2.2",
80
84
  "local-cypress": "^1.2.1",
81
85
  "react": "^16.8.0",
82
86
  "react-dom": "^16.8.0",
83
- "react-intl": "^2.6.0",
87
+ "react-intl-next": "npm:react-intl@^5.18.1",
84
88
  "rxjs": "^5.5.0",
85
89
  "typescript": "3.9.6",
86
90
  "uuid": "^3.1.0",
@@ -1,99 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.CardSSRView = void 0;
9
-
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
- var _react = _interopRequireDefault(require("react"));
13
-
14
- var _mediaUi = require("@atlaskit/media-ui");
15
-
16
- var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
17
-
18
- var _getDataURIDimension = require("../../utils/getDataURIDimension");
19
-
20
- var _cardDimensions = require("../../utils/cardDimensions");
21
-
22
- var _styled = require("../ui/iconWrapper/styled");
23
-
24
- var _styledSSR = require("../ui/styledSSR");
25
-
26
- var _styled2 = require("../ui/blanket/styled");
27
-
28
- var _cardConstants = require("./cardConstants");
29
-
30
- var _resizeModeToMediaImageProps = require("../../utils/resizeModeToMediaImageProps");
31
-
32
- /*
33
- * This file is designed to be optimised for maximum performance.
34
- * Because of this the imports are optimised to import only what is required
35
- * If you're adding a new dependency please ensure that the
36
- * imported file only contains and depends on only what is required for it to function.
37
- */
38
- var CardSSRView = function CardSSRView(_ref) {
39
- var identifier = _ref.identifier,
40
- dimensions = _ref.dimensions,
41
- mediaClient = _ref.mediaClient,
42
- resizeMode = _ref.resizeMode,
43
- disableOverlay = _ref.disableOverlay;
44
- var dataURI;
45
-
46
- try {
47
- var _getRequestedDimensio = (0, _getDataURIDimension.getRequestedDimensions)({
48
- dimensions: dimensions
49
- }),
50
- width = _getRequestedDimensio.width,
51
- height = _getRequestedDimensio.height;
52
-
53
- var mode = resizeMode === 'stretchy-fit' ? 'full-fit' : resizeMode;
54
- dataURI = mediaClient.getImageUrlSync(identifier.id, {
55
- collection: identifier.collectionName,
56
- mode: mode,
57
- width: width,
58
- height: height,
59
- allowAnimated: true
60
- });
61
- } catch (e) {
62
- // if we are unable to get the image url (eg missing auth) we want to continue rendering with a spinner
63
- dataURI = '';
64
- }
65
-
66
- var shouldDisplayBackground = !dataURI || !disableOverlay;
67
- return /*#__PURE__*/_react.default.createElement(_styledSSR.SSRFileExperienceWrapper, {
68
- className: _cardConstants.newFileExperienceClassName,
69
- dimensions: dimensions,
70
- breakpoint: calculateBreakpoint(dimensions),
71
- shouldUsePointerCursor: Boolean(dataURI),
72
- displayBackground: shouldDisplayBackground,
73
- disableOverlay: disableOverlay,
74
- selected: false,
75
- "data-testid": "media-card-view"
76
- }, /*#__PURE__*/_react.default.createElement(_styledSSR.CardImageContainer, {
77
- className: "media-file-card-view",
78
- "data-testid": "media-file-card-view"
79
- }, /*#__PURE__*/_react.default.createElement(_styled.IconWrapper, {
80
- breakpoint: calculateBreakpoint(dimensions),
81
- hasTitleBox: false
82
- }, /*#__PURE__*/_react.default.createElement(_spinner.default, null)), !!dataURI && /*#__PURE__*/_react.default.createElement(_mediaUi.MediaImage, (0, _extends2.default)({
83
- dataURI: dataURI // alt={alt} // having alt text causes the image to fail to render with a broken image.
84
- // onImageLoad={this.onImageLoad} // TODO add these back as part of tracking performance.
85
- // onImageError={this.onImageError}
86
-
87
- }, (0, _resizeModeToMediaImageProps.resizeModeToMediaImageProps)(resizeMode))), !disableOverlay && /*#__PURE__*/_react.default.createElement(_styled2.Blanket, {
88
- isFixed: false
89
- })));
90
- };
91
-
92
- exports.CardSSRView = CardSSRView;
93
-
94
- function calculateBreakpoint(dimensions) {
95
- var _dimensions$width;
96
-
97
- var width = (_dimensions$width = dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) !== null && _dimensions$width !== void 0 ? _dimensions$width : _cardDimensions.defaultImageCardDimensions.width;
98
- return (0, _styledSSR.calcBreakpointSize)(parseInt("".concat(width), 10));
99
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Breakpoint = void 0;
7
- var Breakpoint;
8
- exports.Breakpoint = Breakpoint;
9
-
10
- (function (Breakpoint) {
11
- Breakpoint["SMALL"] = "small";
12
- Breakpoint["LARGE"] = "large";
13
- })(Breakpoint || (exports.Breakpoint = Breakpoint = {}));