@atlaskit/media-card 70.10.0 → 72.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/dist/cjs/errors.js +76 -5
  3. package/dist/cjs/files/cardImageView/index.js +58 -89
  4. package/dist/cjs/files/index.js +0 -6
  5. package/dist/cjs/index.js +16 -6
  6. package/dist/cjs/root/card/cardAnalytics.js +33 -19
  7. package/dist/cjs/root/card/cardConstants.js +8 -0
  8. package/dist/cjs/root/card/cardLoader.js +66 -124
  9. package/dist/cjs/root/card/cardState.js +50 -0
  10. package/dist/cjs/root/card/getCardPreview/cache.js +5 -0
  11. package/dist/cjs/root/card/getCardPreview/filePreviewStatus.js +50 -0
  12. package/dist/cjs/root/card/getCardPreview/helpers.js +13 -21
  13. package/dist/cjs/root/card/getCardPreview/index.js +171 -100
  14. package/dist/cjs/root/card/getCardStatus.js +7 -1
  15. package/dist/cjs/root/card/index.js +407 -322
  16. package/dist/cjs/root/cardView.js +115 -76
  17. package/dist/cjs/root/index.js +9 -1
  18. package/dist/cjs/root/inline/loader.js +22 -21
  19. package/dist/cjs/root/inline/{inlineMediaCard.js → mediaInlineCard.js} +72 -25
  20. package/dist/cjs/root/inlinePlayer.js +5 -15
  21. package/dist/cjs/root/ui/iconMessage/index.js +17 -9
  22. package/dist/cjs/root/ui/imageRenderer/imageRenderer.js +36 -115
  23. package/dist/cjs/root/ui/styled.js +1 -1
  24. package/dist/cjs/root/ui/titleBox/failedTitleBox.js +7 -3
  25. package/dist/cjs/utils/analytics.js +26 -43
  26. package/dist/cjs/utils/cardActions/cardActionsDropdownMenu.js +16 -9
  27. package/dist/cjs/utils/dimensionComparer.js +1 -1
  28. package/dist/cjs/utils/document.js +12 -0
  29. package/dist/cjs/utils/getDataURIDimension.js +13 -2
  30. package/dist/cjs/utils/metadata.js +11 -3
  31. package/dist/cjs/utils/objectURLCache.js +6 -0
  32. package/dist/cjs/utils/resizeModeToMediaImageProps.js +13 -0
  33. package/dist/cjs/utils/shouldDisplayImageThumbnail.js +1 -1
  34. package/dist/cjs/version.json +1 -1
  35. package/dist/es2019/errors.js +42 -2
  36. package/dist/es2019/files/cardImageView/index.js +12 -46
  37. package/dist/es2019/files/index.js +1 -1
  38. package/dist/es2019/index.js +3 -3
  39. package/dist/es2019/root/card/cardAnalytics.js +23 -17
  40. package/dist/es2019/root/card/cardConstants.js +1 -0
  41. package/dist/es2019/root/card/cardLoader.js +47 -53
  42. package/dist/es2019/root/card/cardState.js +26 -0
  43. package/dist/es2019/root/card/getCardPreview/cache.js +5 -0
  44. package/dist/es2019/root/card/getCardPreview/filePreviewStatus.js +35 -0
  45. package/dist/es2019/root/card/getCardPreview/helpers.js +2 -12
  46. package/dist/es2019/root/card/getCardPreview/index.js +112 -79
  47. package/dist/es2019/root/card/getCardStatus.js +1 -0
  48. package/dist/es2019/root/card/index.js +356 -254
  49. package/dist/es2019/root/cardView.js +98 -58
  50. package/dist/es2019/root/index.js +2 -1
  51. package/dist/es2019/root/inline/loader.js +16 -15
  52. package/dist/es2019/root/inline/mediaInlineCard.js +132 -0
  53. package/dist/es2019/root/inlinePlayer.js +5 -13
  54. package/dist/es2019/root/ui/iconMessage/index.js +10 -6
  55. package/dist/es2019/root/ui/imageRenderer/imageRenderer.js +26 -74
  56. package/dist/es2019/root/ui/styled.js +1 -0
  57. package/dist/es2019/root/ui/titleBox/failedTitleBox.js +5 -3
  58. package/dist/es2019/utils/analytics.js +29 -40
  59. package/dist/es2019/utils/cardActions/cardActionsDropdownMenu.js +8 -4
  60. package/dist/es2019/utils/dimensionComparer.js +1 -1
  61. package/dist/es2019/utils/document.js +1 -0
  62. package/dist/es2019/utils/getDataURIDimension.js +8 -0
  63. package/dist/es2019/utils/metadata.js +12 -4
  64. package/dist/es2019/utils/objectURLCache.js +5 -0
  65. package/dist/es2019/utils/resizeModeToMediaImageProps.js +6 -0
  66. package/dist/es2019/utils/shouldDisplayImageThumbnail.js +1 -1
  67. package/dist/es2019/version.json +1 -1
  68. package/dist/esm/errors.js +60 -1
  69. package/dist/esm/files/cardImageView/index.js +55 -87
  70. package/dist/esm/files/index.js +1 -1
  71. package/dist/esm/index.js +3 -3
  72. package/dist/esm/root/card/cardAnalytics.js +23 -18
  73. package/dist/esm/root/card/cardConstants.js +1 -0
  74. package/dist/esm/root/card/cardLoader.js +66 -126
  75. package/dist/esm/root/card/cardState.js +32 -0
  76. package/dist/esm/root/card/getCardPreview/cache.js +6 -0
  77. package/dist/esm/root/card/getCardPreview/filePreviewStatus.js +35 -0
  78. package/dist/esm/root/card/getCardPreview/helpers.js +13 -21
  79. package/dist/esm/root/card/getCardPreview/index.js +142 -95
  80. package/dist/esm/root/card/getCardStatus.js +3 -0
  81. package/dist/esm/root/card/index.js +416 -325
  82. package/dist/esm/root/cardView.js +114 -73
  83. package/dist/esm/root/index.js +2 -1
  84. package/dist/esm/root/inline/loader.js +23 -22
  85. package/dist/esm/root/inline/mediaInlineCard.js +145 -0
  86. package/dist/esm/root/inlinePlayer.js +5 -13
  87. package/dist/esm/root/ui/iconMessage/index.js +12 -7
  88. package/dist/esm/root/ui/imageRenderer/imageRenderer.js +28 -106
  89. package/dist/esm/root/ui/styled.js +1 -1
  90. package/dist/esm/root/ui/titleBox/failedTitleBox.js +6 -3
  91. package/dist/esm/utils/analytics.js +22 -35
  92. package/dist/esm/utils/cardActions/cardActionsDropdownMenu.js +16 -9
  93. package/dist/esm/utils/dimensionComparer.js +1 -1
  94. package/dist/esm/utils/document.js +3 -0
  95. package/dist/esm/utils/getDataURIDimension.js +8 -0
  96. package/dist/esm/utils/metadata.js +12 -4
  97. package/dist/esm/utils/objectURLCache.js +6 -0
  98. package/dist/esm/utils/resizeModeToMediaImageProps.js +6 -0
  99. package/dist/esm/utils/shouldDisplayImageThumbnail.js +1 -1
  100. package/dist/esm/version.json +1 -1
  101. package/dist/types/errors.d.ts +15 -1
  102. package/dist/types/files/cardImageView/index.d.ts +5 -12
  103. package/dist/types/files/cardImageView/styled.d.ts +1 -1
  104. package/dist/types/files/index.d.ts +1 -1
  105. package/dist/types/index.d.ts +11 -13
  106. package/dist/types/root/card/cardAnalytics.d.ts +5 -7
  107. package/dist/types/root/card/cardConstants.d.ts +1 -0
  108. package/dist/types/root/card/cardLoader.d.ts +4 -18
  109. package/dist/types/root/card/cardState.d.ts +5 -0
  110. package/dist/types/root/card/getCardPreview/cache.d.ts +4 -2
  111. package/dist/types/root/card/getCardPreview/filePreviewStatus.d.ts +5 -0
  112. package/dist/types/root/card/getCardPreview/helpers.d.ts +4 -5
  113. package/dist/types/root/card/getCardPreview/index.d.ts +25 -14
  114. package/dist/types/root/card/getCardStatus.d.ts +1 -0
  115. package/dist/types/root/card/index.d.ts +18 -15
  116. package/dist/types/root/cardView.d.ts +14 -8
  117. package/dist/types/root/index.d.ts +1 -0
  118. package/dist/types/root/inline/loader.d.ts +8 -8
  119. package/dist/types/root/inline/{inlineMediaCard.d.ts → mediaInlineCard.d.ts} +4 -4
  120. package/dist/types/root/inlinePlayer.d.ts +1 -1
  121. package/dist/types/root/ui/iconMessage/index.d.ts +7 -2
  122. package/dist/types/root/ui/imageRenderer/imageRenderer.d.ts +5 -18
  123. package/dist/types/root/ui/titleBox/failedTitleBox.d.ts +2 -0
  124. package/dist/types/types.d.ts +9 -1
  125. package/dist/types/utils/analytics.d.ts +20 -21
  126. package/dist/types/utils/cardDimensions.d.ts +5 -1
  127. package/dist/types/utils/dimensionComparer.d.ts +1 -1
  128. package/dist/types/utils/document.d.ts +2 -0
  129. package/dist/types/utils/getDataURIDimension.d.ts +3 -1
  130. package/dist/types/utils/index.d.ts +1 -0
  131. package/dist/types/utils/lazyContent/styled.d.ts +1 -1
  132. package/dist/types/utils/lightCards/types.d.ts +1 -1
  133. package/dist/types/utils/metadata.d.ts +2 -2
  134. package/dist/types/utils/objectURLCache.d.ts +2 -1
  135. package/dist/types/utils/resizeModeToMediaImageProps.d.ts +5 -0
  136. package/dist/types/utils/shouldDisplayImageThumbnail.d.ts +1 -1
  137. package/example-helpers/developmentUseMessage.tsx +14 -0
  138. package/example-helpers/index.tsx +55 -4
  139. package/example-helpers/selectableCard.tsx +2 -1
  140. package/package.json +18 -14
  141. package/dist/cjs/root/card/getCardPreview/types.js +0 -5
  142. package/dist/cjs/utils/fileAttributesContext.js +0 -40
  143. package/dist/es2019/root/card/getCardPreview/types.js +0 -1
  144. package/dist/es2019/root/inline/inlineMediaCard.js +0 -92
  145. package/dist/es2019/utils/fileAttributesContext.js +0 -19
  146. package/dist/esm/root/card/getCardPreview/types.js +0 -1
  147. package/dist/esm/root/inline/inlineMediaCard.js +0 -100
  148. package/dist/esm/utils/fileAttributesContext.js +0 -18
  149. package/dist/types/root/card/getCardPreview/types.d.ts +0 -5
  150. package/dist/types/utils/fileAttributesContext.d.ts +0 -10
@@ -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,5 @@
1
+ import { ImageResizeMode } from '@atlaskit/media-client';
2
+ export declare function resizeModeToMediaImageProps(resizeMode?: ImageResizeMode): {
3
+ crop: boolean;
4
+ stretch: boolean;
5
+ };
@@ -1,3 +1,3 @@
1
1
  import { MediaItemType } from '@atlaskit/media-client';
2
2
  import { CardStatus } from '..';
3
- export declare const shouldDisplayImageThumbnail: (cardStatus: CardStatus, mediaItemType: MediaItemType, dataURI?: string | undefined, mediaType?: "audio" | "video" | "doc" | "image" | "archive" | "unknown" | undefined, mimeType?: string | undefined) => boolean;
3
+ export declare const shouldDisplayImageThumbnail: (cardStatus: CardStatus, mediaItemType: MediaItemType, dataURI?: string | undefined, mediaType?: "audio" | "video" | "image" | "doc" | "archive" | "unknown" | undefined, mimeType?: string | undefined) => boolean;
@@ -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.10.0",
3
+ "version": "72.1.0",
4
4
  "description": "Includes all media card related components, CardView, CardViewSmall, Card...",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,23 +29,23 @@
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.7.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.1.0",
37
- "@atlaskit/media-common": "^2.8.0",
38
- "@atlaskit/media-ui": "^16.5.0",
36
+ "@atlaskit/media-client": "^14.3.0",
37
+ "@atlaskit/media-common": "^2.10.0",
38
+ "@atlaskit/media-ui": "^17.2.0",
39
39
  "@atlaskit/media-viewer": "^45.8.0",
40
40
  "@atlaskit/spinner": "^15.1.0",
41
- "@atlaskit/theme": "^11.4.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
- "uuid": "^3.1.0",
48
+ "react-loadable": "^5.1.0",
49
49
  "video-snapshot": "^1.0.11"
50
50
  },
51
51
  "peerDependencies": {
@@ -62,19 +62,22 @@
62
62
  "@atlaskit/button": "^16.1.0",
63
63
  "@atlaskit/checkbox": "^12.3.0",
64
64
  "@atlaskit/docs": "*",
65
- "@atlaskit/field-radio-group": "^8.0.0",
66
- "@atlaskit/field-range": "^9.0.0",
65
+ "@atlaskit/inline-message": "^11.1.5",
67
66
  "@atlaskit/item": "^12.0.0",
68
67
  "@atlaskit/media-core": "^32.2.0",
69
- "@atlaskit/media-test-helpers": "^28.7.0",
68
+ "@atlaskit/media-test-helpers": "^28.9.0",
69
+ "@atlaskit/radio": "^5.3.2",
70
+ "@atlaskit/range": "^5.1.0",
71
+ "@atlaskit/select": "^15.2.1",
70
72
  "@atlaskit/ssr": "*",
71
73
  "@atlaskit/textfield": "^5.1.0",
72
- "@atlaskit/toggle": "^12.2.0",
74
+ "@atlaskit/toggle": "^12.3.0",
73
75
  "@atlaskit/visual-regression": "*",
74
76
  "@atlaskit/webdriver-runner": "*",
75
77
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
76
78
  "@testing-library/react": "^8.0.1",
77
79
  "@types/classnames": "^2.2.6",
80
+ "@types/react-loadable": "^5.4.1",
78
81
  "deepcopy": "0.6.3",
79
82
  "enzyme": "^3.10.0",
80
83
  "exenv": "^1.2.2",
@@ -84,6 +87,7 @@
84
87
  "react-intl": "^2.6.0",
85
88
  "rxjs": "^5.5.0",
86
89
  "typescript": "3.9.6",
90
+ "uuid": "^3.1.0",
87
91
  "wait-for-expect": "^1.2.0"
88
92
  },
89
93
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.withFileAttributes = withFileAttributes;
11
- exports.FileAttributesProvider = void 0;
12
-
13
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
14
-
15
- var _react = _interopRequireWildcard(require("react"));
16
-
17
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
-
19
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
-
21
- var FileAttributesContext = /*#__PURE__*/_react.default.createContext(null);
22
-
23
- var FileAttributesProvider = function FileAttributesProvider(_ref) {
24
- var children = _ref.children,
25
- data = _ref.data;
26
- return data ? /*#__PURE__*/_react.default.createElement(FileAttributesContext.Provider, {
27
- value: data
28
- }, children) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
29
- };
30
-
31
- exports.FileAttributesProvider = FileAttributesProvider;
32
-
33
- function withFileAttributes(Component) {
34
- return function (props) {
35
- var fileAttributes = (0, _react.useContext)(FileAttributesContext);
36
- return fileAttributes ? /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, props, {
37
- fileAttributes: fileAttributes
38
- })) : /*#__PURE__*/_react.default.createElement(Component, props);
39
- };
40
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,92 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import ReactDOM from 'react-dom';
3
- import { injectIntl } from 'react-intl';
4
- import { InlineCardResolvedView, InlineCardResolvingView, InlineCardErroredView, messages } from '@atlaskit/media-ui';
5
- import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
6
- import { MediaViewer } from '@atlaskit/media-viewer';
7
- // UI component which renders an inline link in the appropiate state based on a media file
8
- export const InlineMediaCardInternal = ({
9
- mediaClient,
10
- identifier,
11
- shouldOpenMediaViewer,
12
- isSelected,
13
- onClick,
14
- mediaViewerDataSource,
15
- intl
16
- }) => {
17
- const [fileState, setFileState] = useState();
18
- const [isMediaViewerVisible, setMediaViewerVisible] = useState(false);
19
-
20
- const onInlineCardClick = event => {
21
- if (shouldOpenMediaViewer) {
22
- setMediaViewerVisible(true);
23
- }
24
-
25
- if (onClick) {
26
- onClick(event);
27
- }
28
- };
29
-
30
- const onMediaViewerClose = () => setMediaViewerVisible(false);
31
-
32
- const renderMediaViewer = () => {
33
- if (isMediaViewerVisible) {
34
- const dataSource = mediaViewerDataSource || {
35
- list: []
36
- };
37
- return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
38
- collectionName: identifier.collectionName || '',
39
- dataSource: dataSource,
40
- mediaClientConfig: mediaClient.mediaClientConfig,
41
- selectedItem: identifier,
42
- onClose: onMediaViewerClose
43
- }), document.body);
44
- }
45
-
46
- return null;
47
- };
48
-
49
- useEffect(() => {
50
- // [EDM-1948] TODO: use mediaClient.file.getFileState()
51
- // [EDM-1948] TODO: handle error here
52
- mediaClient.file.getCurrentState(identifier.id, {
53
- collectionName: identifier.collectionName
54
- }).then(fileState => {
55
- setFileState(fileState);
56
- });
57
- }, [identifier.collectionName, identifier.id, mediaClient.file]);
58
-
59
- if (!fileState) {
60
- return /*#__PURE__*/React.createElement(InlineCardResolvingView, {
61
- url: intl.formatMessage(messages.loading_file),
62
- titleTextColor: "black",
63
- withoutHover: true
64
- });
65
- }
66
-
67
- if (fileState.status === 'error') {
68
- return /*#__PURE__*/React.createElement(InlineCardErroredView, {
69
- url: "",
70
- message: fileState.message || ''
71
- });
72
- }
73
-
74
- const {
75
- mediaType,
76
- name
77
- } = fileState;
78
- const linkIcon = /*#__PURE__*/React.createElement(MediaTypeIcon, {
79
- testId: 'inline-media-card-file-type-icon',
80
- size: "small",
81
- type: mediaType
82
- });
83
- const mediaViewer = renderMediaViewer(); // [EDM-1948] TODO: add Tooltip
84
-
85
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InlineCardResolvedView, {
86
- icon: linkIcon,
87
- title: name,
88
- onClick: onInlineCardClick,
89
- isSelected: isSelected
90
- }), mediaViewer);
91
- };
92
- export const InlineMediaCard = injectIntl(InlineMediaCardInternal);
@@ -1,19 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useContext } from 'react';
3
- const FileAttributesContext = /*#__PURE__*/React.createContext(null);
4
- export const FileAttributesProvider = ({
5
- children,
6
- data
7
- }) => {
8
- return data ? /*#__PURE__*/React.createElement(FileAttributesContext.Provider, {
9
- value: data
10
- }, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
11
- };
12
- export function withFileAttributes(Component) {
13
- return props => {
14
- const fileAttributes = useContext(FileAttributesContext);
15
- return fileAttributes ? /*#__PURE__*/React.createElement(Component, _extends({}, props, {
16
- fileAttributes: fileAttributes
17
- })) : /*#__PURE__*/React.createElement(Component, props);
18
- };
19
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,100 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useState, useEffect } from 'react';
3
- import ReactDOM from 'react-dom';
4
- import { injectIntl } from 'react-intl';
5
- import { InlineCardResolvedView, InlineCardResolvingView, InlineCardErroredView, messages } from '@atlaskit/media-ui';
6
- import { MediaTypeIcon } from '@atlaskit/media-ui/media-type-icon';
7
- import { MediaViewer } from '@atlaskit/media-viewer';
8
- // UI component which renders an inline link in the appropiate state based on a media file
9
- export var InlineMediaCardInternal = function InlineMediaCardInternal(_ref) {
10
- var mediaClient = _ref.mediaClient,
11
- identifier = _ref.identifier,
12
- shouldOpenMediaViewer = _ref.shouldOpenMediaViewer,
13
- isSelected = _ref.isSelected,
14
- onClick = _ref.onClick,
15
- mediaViewerDataSource = _ref.mediaViewerDataSource,
16
- intl = _ref.intl;
17
-
18
- var _useState = useState(),
19
- _useState2 = _slicedToArray(_useState, 2),
20
- fileState = _useState2[0],
21
- setFileState = _useState2[1];
22
-
23
- var _useState3 = useState(false),
24
- _useState4 = _slicedToArray(_useState3, 2),
25
- isMediaViewerVisible = _useState4[0],
26
- setMediaViewerVisible = _useState4[1];
27
-
28
- var onInlineCardClick = function onInlineCardClick(event) {
29
- if (shouldOpenMediaViewer) {
30
- setMediaViewerVisible(true);
31
- }
32
-
33
- if (onClick) {
34
- onClick(event);
35
- }
36
- };
37
-
38
- var onMediaViewerClose = function onMediaViewerClose() {
39
- return setMediaViewerVisible(false);
40
- };
41
-
42
- var renderMediaViewer = function renderMediaViewer() {
43
- if (isMediaViewerVisible) {
44
- var dataSource = mediaViewerDataSource || {
45
- list: []
46
- };
47
- return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/React.createElement(MediaViewer, {
48
- collectionName: identifier.collectionName || '',
49
- dataSource: dataSource,
50
- mediaClientConfig: mediaClient.mediaClientConfig,
51
- selectedItem: identifier,
52
- onClose: onMediaViewerClose
53
- }), document.body);
54
- }
55
-
56
- return null;
57
- };
58
-
59
- useEffect(function () {
60
- // [EDM-1948] TODO: use mediaClient.file.getFileState()
61
- // [EDM-1948] TODO: handle error here
62
- mediaClient.file.getCurrentState(identifier.id, {
63
- collectionName: identifier.collectionName
64
- }).then(function (fileState) {
65
- setFileState(fileState);
66
- });
67
- }, [identifier.collectionName, identifier.id, mediaClient.file]);
68
-
69
- if (!fileState) {
70
- return /*#__PURE__*/React.createElement(InlineCardResolvingView, {
71
- url: intl.formatMessage(messages.loading_file),
72
- titleTextColor: "black",
73
- withoutHover: true
74
- });
75
- }
76
-
77
- if (fileState.status === 'error') {
78
- return /*#__PURE__*/React.createElement(InlineCardErroredView, {
79
- url: "",
80
- message: fileState.message || ''
81
- });
82
- }
83
-
84
- var mediaType = fileState.mediaType,
85
- name = fileState.name;
86
- var linkIcon = /*#__PURE__*/React.createElement(MediaTypeIcon, {
87
- testId: 'inline-media-card-file-type-icon',
88
- size: "small",
89
- type: mediaType
90
- });
91
- var mediaViewer = renderMediaViewer(); // [EDM-1948] TODO: add Tooltip
92
-
93
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InlineCardResolvedView, {
94
- icon: linkIcon,
95
- title: name,
96
- onClick: onInlineCardClick,
97
- isSelected: isSelected
98
- }), mediaViewer);
99
- };
100
- export var InlineMediaCard = injectIntl(InlineMediaCardInternal);
@@ -1,18 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import React, { useContext } from 'react';
3
- var FileAttributesContext = /*#__PURE__*/React.createContext(null);
4
- export var FileAttributesProvider = function FileAttributesProvider(_ref) {
5
- var children = _ref.children,
6
- data = _ref.data;
7
- return data ? /*#__PURE__*/React.createElement(FileAttributesContext.Provider, {
8
- value: data
9
- }, children) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
10
- };
11
- export function withFileAttributes(Component) {
12
- return function (props) {
13
- var fileAttributes = useContext(FileAttributesContext);
14
- return fileAttributes ? /*#__PURE__*/React.createElement(Component, _extends({}, props, {
15
- fileAttributes: fileAttributes
16
- })) : /*#__PURE__*/React.createElement(Component, props);
17
- };
18
- }
@@ -1,5 +0,0 @@
1
- export interface CardPreview {
2
- dataURI: string;
3
- orientation?: number;
4
- source: 'local' | 'remote' | 'cache' | 'external';
5
- }
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import { FileAttributes } from '@atlaskit/media-common';
3
- export declare type FileAttributesProviderProps = {
4
- data: FileAttributes;
5
- };
6
- export declare const FileAttributesProvider: React.FC<FileAttributesProviderProps>;
7
- export declare type WithFileAttributesProps = {
8
- fileAttributes?: FileAttributes;
9
- };
10
- export declare function withFileAttributes<Props>(Component: React.ComponentType<Props & WithFileAttributesProps>): React.FC<Props>;