@atlaskit/media-picker 63.0.4 → 63.0.6

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 (37) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/util/analytics.js +1 -1
  3. package/dist/cjs/util/ufoExperiences.js +1 -1
  4. package/dist/cjs/version.json +1 -1
  5. package/dist/es2019/util/analytics.js +1 -1
  6. package/dist/es2019/util/ufoExperiences.js +1 -1
  7. package/dist/es2019/version.json +1 -1
  8. package/dist/esm/util/analytics.js +1 -1
  9. package/dist/esm/util/ufoExperiences.js +1 -1
  10. package/dist/esm/version.json +1 -1
  11. package/dist/types/types.d.ts +3 -1
  12. package/dist/types-ts4.0/components/browser/browser.d.ts +32 -0
  13. package/dist/types-ts4.0/components/browser/index.d.ts +24 -0
  14. package/dist/types-ts4.0/components/clipboard/clipboard.d.ts +38 -0
  15. package/dist/types-ts4.0/components/clipboard/index.d.ts +21 -0
  16. package/dist/types-ts4.0/components/component.d.ts +17 -0
  17. package/dist/types-ts4.0/components/dropzone/dropzone.d.ts +36 -0
  18. package/dist/types-ts4.0/components/dropzone/index.d.ts +23 -0
  19. package/dist/types-ts4.0/components/localUploadReact.d.ts +35 -0
  20. package/dist/types-ts4.0/components/media-picker-analytics-error-boundary.d.ts +10 -0
  21. package/dist/types-ts4.0/components/types.d.ts +18 -0
  22. package/dist/types-ts4.0/config.d.ts +8 -0
  23. package/dist/types-ts4.0/domain/plugin.d.ts +8 -0
  24. package/dist/types-ts4.0/domain/preview.d.ts +2 -0
  25. package/dist/types-ts4.0/index.d.ts +6 -0
  26. package/dist/types-ts4.0/popup/domain/index.d.ts +14 -0
  27. package/dist/types-ts4.0/service/types.d.ts +29 -0
  28. package/dist/types-ts4.0/service/uploadServiceImpl.d.ts +33 -0
  29. package/dist/types-ts4.0/types.d.ts +120 -0
  30. package/dist/types-ts4.0/util/analytics.d.ts +7 -0
  31. package/dist/types-ts4.0/util/appendTimestamp.d.ts +1 -0
  32. package/dist/types-ts4.0/util/eventEmitter.d.ts +25 -0
  33. package/dist/types-ts4.0/util/getPreviewFromBlob.d.ts +4 -0
  34. package/dist/types-ts4.0/util/getPreviewFromImage.d.ts +3 -0
  35. package/dist/types-ts4.0/util/ufoExperiences.d.ts +13 -0
  36. package/package.json +12 -5
  37. package/types/package.json +8 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/media-picker
2
2
 
3
+ ## 63.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
8
+ - Updated dependencies
9
+
10
+ ## 63.0.5
11
+
12
+ ### Patch Changes
13
+
14
+ - [`45b6d35ea96`](https://bitbucket.org/atlassian/atlassian-frontend/commits/45b6d35ea96) - [ME-1327] Added new upload methods to editor mobile bridge to support previews and progress for media cards.
15
+
3
16
  ## 63.0.4
4
17
 
5
18
  ### Patch Changes
@@ -22,7 +22,7 @@ var relevantFlags = {
22
22
  memoryCacheLogging: false
23
23
  };
24
24
  var packageName = "@atlaskit/media-picker";
25
- var packageVersion = "63.0.4";
25
+ var packageVersion = "63.0.6";
26
26
  var LOGGED_FEATURE_FLAGS = (0, _mediaCommon.filterFeatureFlagNames)(relevantFlags);
27
27
  exports.LOGGED_FEATURE_FLAGS = LOGGED_FEATURE_FLAGS;
28
28
  var LOGGED_FEATURE_FLAG_KEYS = (0, _mediaCommon.filterFeatureFlagKeysAllProducts)(relevantFlags);
@@ -20,7 +20,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
20
20
  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) { (0, _defineProperty2.default)(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; }
21
21
 
22
22
  var packageName = "@atlaskit/media-picker";
23
- var packageVersion = "63.0.4";
23
+ var packageVersion = "63.0.6";
24
24
  var ufoExperience;
25
25
 
26
26
  var initExperience = function initExperience(id, componentName) {
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/media-picker",
3
- "version": "63.0.4"
3
+ "version": "63.0.6"
4
4
  }
@@ -12,7 +12,7 @@ const relevantFlags = {
12
12
  memoryCacheLogging: false
13
13
  };
14
14
  const packageName = "@atlaskit/media-picker";
15
- const packageVersion = "63.0.4";
15
+ const packageVersion = "63.0.6";
16
16
  export const LOGGED_FEATURE_FLAGS = filterFeatureFlagNames(relevantFlags);
17
17
  export const LOGGED_FEATURE_FLAG_KEYS = filterFeatureFlagKeysAllProducts(relevantFlags);
18
18
  export function getPackageAttributes(componentName) {
@@ -2,7 +2,7 @@ import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } fro
2
2
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
3
3
  import { LOGGED_FEATURE_FLAG_KEYS } from './analytics';
4
4
  const packageName = "@atlaskit/media-picker";
5
- const packageVersion = "63.0.4";
5
+ const packageVersion = "63.0.6";
6
6
  let ufoExperience;
7
7
 
8
8
  const initExperience = (id, componentName) => {
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/media-picker",
3
- "version": "63.0.4"
3
+ "version": "63.0.6"
4
4
  }
@@ -12,7 +12,7 @@ var relevantFlags = {
12
12
  memoryCacheLogging: false
13
13
  };
14
14
  var packageName = "@atlaskit/media-picker";
15
- var packageVersion = "63.0.4";
15
+ var packageVersion = "63.0.6";
16
16
  export var LOGGED_FEATURE_FLAGS = filterFeatureFlagNames(relevantFlags);
17
17
  export var LOGGED_FEATURE_FLAG_KEYS = filterFeatureFlagKeysAllProducts(relevantFlags);
18
18
  export function getPackageAttributes(componentName) {
@@ -8,7 +8,7 @@ import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } fro
8
8
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
9
9
  import { LOGGED_FEATURE_FLAG_KEYS } from './analytics';
10
10
  var packageName = "@atlaskit/media-picker";
11
- var packageVersion = "63.0.4";
11
+ var packageVersion = "63.0.6";
12
12
  var ufoExperience;
13
13
 
14
14
  var initExperience = function initExperience(id, componentName) {
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/media-picker",
3
- "version": "63.0.4"
3
+ "version": "63.0.6"
4
4
  }
@@ -28,7 +28,9 @@ export declare type UploadsStartEventPayload = {
28
28
  readonly files: MediaFile[];
29
29
  };
30
30
  export declare type UploadPreviewUpdateEventPayload = {
31
- readonly file: MediaFile;
31
+ readonly file: MediaFile & {
32
+ readonly collectionName?: string;
33
+ };
32
34
  readonly preview: Preview;
33
35
  };
34
36
  export declare type UploadEndEventPayload = {
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { BrowserConfig } from '../../types';
3
+ import { LocalUploadComponentReact, LocalUploadComponentBaseProps } from '../localUploadReact';
4
+ export interface BrowserOwnProps {
5
+ config: BrowserConfig;
6
+ isOpen?: boolean;
7
+ onClose?: () => void;
8
+ /**
9
+ * This prop will be mainly used for those contexts (like Editor) where there is no react lifecylce and we cannot rerender easily.
10
+ * Otherwise, isOpen prop is preferred.
11
+ */
12
+ onBrowseFn?: (browse: () => void) => void;
13
+ onCancelFn?: (cancel: (uniqueIdentifier: string) => void) => void;
14
+ children?: (browse: () => void) => React.ReactChild;
15
+ }
16
+ export declare type BrowseFn = () => void;
17
+ export declare type BrowserProps = LocalUploadComponentBaseProps & BrowserOwnProps;
18
+ export declare class BrowserBase extends LocalUploadComponentReact<BrowserProps> {
19
+ private browserRef;
20
+ constructor(props: BrowserProps);
21
+ static defaultProps: {
22
+ config: BrowserConfig;
23
+ };
24
+ private onFilePicked;
25
+ componentDidMount(): void;
26
+ UNSAFE_componentWillReceiveProps(nextProps: BrowserProps): void;
27
+ browse: BrowseFn;
28
+ render(): JSX.Element;
29
+ }
30
+ export declare const Browser: React.ForwardRefExoticComponent<Pick<Pick<Omit<BrowserProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "mediaClient" | "onUploadsStart" | "onPreviewUpdate" | "onEnd" | "onError" | "featureFlags" | "children" | "onCancelFn" | "isOpen" | "onClose" | "onBrowseFn"> & Partial<Pick<Omit<BrowserProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "config">> & Partial<Pick<{
31
+ config: BrowserConfig;
32
+ }, never>> & React.RefAttributes<any>, "mediaClient" | "config" | "onUploadsStart" | "onPreviewUpdate" | "onEnd" | "onError" | "featureFlags" | "children" | "onCancelFn" | "key" | "isOpen" | "onClose" | "onBrowseFn"> & React.RefAttributes<any>>;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { BrowserProps } from './browser';
3
+ import { WithMediaClientConfigProps } from '@atlaskit/media-client';
4
+ import { BrowserConfig } from '../../types';
5
+ declare type BrowserWithMediaClientConfigProps = WithMediaClientConfigProps<Omit<BrowserProps, 'config'> & {
6
+ config?: BrowserConfig;
7
+ }>;
8
+ declare type BrowserWithMediaClientConfigComponent = React.ComponentType<BrowserWithMediaClientConfigProps>;
9
+ declare type State = {
10
+ Browser?: BrowserWithMediaClientConfigComponent;
11
+ };
12
+ export declare class BrowserLoader extends React.PureComponent<BrowserWithMediaClientConfigProps, State> {
13
+ private mounted;
14
+ static displayName: string;
15
+ static Browser?: BrowserWithMediaClientConfigComponent;
16
+ state: {
17
+ Browser: BrowserWithMediaClientConfigComponent | undefined;
18
+ };
19
+ componentDidMount(): void;
20
+ componentWillUnmount(): void;
21
+ UNSAFE_componentWillMount(): Promise<void>;
22
+ render(): JSX.Element | null;
23
+ }
24
+ export {};
@@ -0,0 +1,38 @@
1
+ /// <reference types="react" />
2
+ import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
3
+ import { LocalUploadComponentReact, LocalUploadComponentBaseProps } from '../localUploadReact';
4
+ import { LocalFileWithSource, UploadService } from '../../service/types';
5
+ import { ClipboardConfig } from '../../types';
6
+ export declare const getFilesFromClipboard: (files: FileList) => File[];
7
+ export interface ClipboardOwnProps {
8
+ config: ClipboardConfig;
9
+ }
10
+ export declare type ClipboardProps = LocalUploadComponentBaseProps & {
11
+ config: ClipboardConfig;
12
+ };
13
+ declare class ClipboardImpl {
14
+ private readonly uploadService;
15
+ private readonly createAnalyticsEvent?;
16
+ static instances: ClipboardImpl[];
17
+ constructor(uploadService: UploadService, createAnalyticsEvent?: CreateUIAnalyticsEvent | undefined);
18
+ static get latestInstance(): ClipboardImpl | undefined;
19
+ activate(): void;
20
+ deactivate(): void;
21
+ onFilesPasted(files: LocalFileWithSource[]): void;
22
+ private fireAnalyticsEvent;
23
+ static handleEvent: (event: ClipboardEvent) => void;
24
+ }
25
+ export declare class ClipboardBase extends LocalUploadComponentReact<ClipboardProps> {
26
+ clipboard: ClipboardImpl;
27
+ constructor(props: ClipboardProps);
28
+ static defaultProps: {
29
+ config: ClipboardConfig;
30
+ };
31
+ componentDidMount(): void;
32
+ componentWillUnmount(): void;
33
+ render(): null;
34
+ }
35
+ export declare const Clipboard: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<ClipboardProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "mediaClient" | "onUploadsStart" | "onPreviewUpdate" | "onEnd" | "onError" | "featureFlags"> & Partial<Pick<Omit<ClipboardProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "config">> & Partial<Pick<{
36
+ config: ClipboardConfig;
37
+ }, never>> & import("react").RefAttributes<any>, "mediaClient" | "config" | "onUploadsStart" | "onPreviewUpdate" | "onEnd" | "onError" | "featureFlags" | "key"> & import("react").RefAttributes<any>>;
38
+ export {};
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { ClipboardProps } from './clipboard';
3
+ import { ClipboardConfig } from '../../types';
4
+ import { WithMediaClientConfigProps } from '@atlaskit/media-client';
5
+ declare type ClipboardWithMediaClientConfigProps = WithMediaClientConfigProps<Omit<ClipboardProps, 'config'> & {
6
+ config?: ClipboardConfig;
7
+ }>;
8
+ declare type ClipboardWithMediaClientConfigComponent = React.ComponentType<ClipboardWithMediaClientConfigProps>;
9
+ declare type State = {
10
+ Clipboard?: ClipboardWithMediaClientConfigComponent;
11
+ };
12
+ export declare class ClipboardLoader extends React.PureComponent<ClipboardWithMediaClientConfigProps, State> {
13
+ static displayName: string;
14
+ static Clipboard?: ClipboardWithMediaClientConfigComponent;
15
+ state: {
16
+ Clipboard: ClipboardWithMediaClientConfigComponent | undefined;
17
+ };
18
+ UNSAFE_componentWillMount(): Promise<void>;
19
+ render(): JSX.Element | null;
20
+ }
21
+ export {};
@@ -0,0 +1,17 @@
1
+ import { MediaFile, Preview, MediaError, UploadEventPayloadMap } from '../types';
2
+ import { GenericEventEmitter } from '../util/eventEmitter';
3
+ import { SelectedItem } from '../popup/domain';
4
+ export interface UploadEventEmitter {
5
+ emitPluginItemsInserted(selectedPluginItems: SelectedItem[]): void;
6
+ emitUploadsStart(files: MediaFile[]): void;
7
+ emitUploadPreviewUpdate(file: MediaFile, preview: Preview): void;
8
+ emitUploadEnd(file: MediaFile): void;
9
+ emitUploadError(fileId: string, error: MediaError): void;
10
+ }
11
+ export declare class UploadComponent<M extends UploadEventPayloadMap> extends GenericEventEmitter<M> implements UploadEventEmitter {
12
+ emitPluginItemsInserted(selectedPluginItems: SelectedItem[]): void;
13
+ emitUploadsStart(files: MediaFile[]): void;
14
+ emitUploadPreviewUpdate(file: MediaFile, preview: Preview): void;
15
+ emitUploadEnd(file: MediaFile): void;
16
+ emitUploadError(fileId: string, error: MediaError): void;
17
+ }
@@ -0,0 +1,36 @@
1
+ /// <reference types="react" />
2
+ import { LocalUploadComponentReact, LocalUploadComponentBaseProps } from '../localUploadReact';
3
+ import { DropzoneConfig } from '../../types';
4
+ import { DropzoneDragEnterEventPayload, DropzoneDragLeaveEventPayload, DropzoneUploadEventPayloadMap } from '../types';
5
+ export declare type DropzoneProps = LocalUploadComponentBaseProps & {
6
+ config: DropzoneConfig;
7
+ onDrop?: () => void;
8
+ onDragEnter?: (payload: DropzoneDragEnterEventPayload) => void;
9
+ onDragLeave?: (payload: DropzoneDragLeaveEventPayload) => void;
10
+ onCancelFn?: (cancel: (uniqueIdentifier: string) => void) => void;
11
+ };
12
+ export declare class DropzoneBase extends LocalUploadComponentReact<DropzoneProps, DropzoneUploadEventPayloadMap> {
13
+ private uiActive;
14
+ constructor(props: DropzoneProps);
15
+ private getContainer;
16
+ componentDidMount(): void;
17
+ componentWillUnmount(): void;
18
+ UNSAFE_componentWillReceiveProps(nextProps: DropzoneProps): void;
19
+ private addContainerListeners;
20
+ private removeContainerListeners;
21
+ private onDragOver;
22
+ private onDragLeave;
23
+ private readonly onFileDropped;
24
+ private fireAnalyticsForFolders;
25
+ private getFilesFromDragEvent;
26
+ private filterFilesAgainstBlacklist;
27
+ private getDraggedItemsLength;
28
+ private onDropFolders;
29
+ private onDrop;
30
+ private sendAnalyticsAndEmitDragLeave;
31
+ private emitDragOver;
32
+ private emitDragLeave;
33
+ private fireAnalyticsEvent;
34
+ render(): null;
35
+ }
36
+ export declare const Dropzone: import("react").ForwardRefExoticComponent<Pick<Omit<DropzoneProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & import("react").RefAttributes<any>, "mediaClient" | "config" | "onUploadsStart" | "onPreviewUpdate" | "onEnd" | "onError" | "featureFlags" | "onDrop" | "onDragEnter" | "onDragLeave" | "onCancelFn" | "key"> & import("react").RefAttributes<any>>;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { WithMediaClientConfigProps } from '@atlaskit/media-client';
3
+ import { DropzoneProps } from './dropzone';
4
+ import { MediaPickerAnalyticsErrorBoundaryProps } from '../media-picker-analytics-error-boundary';
5
+ export declare type DropzoneWithMediaClientConfigProps = WithMediaClientConfigProps<DropzoneProps>;
6
+ declare type DropzoneWithMediaClientConfigComponent = React.ComponentType<DropzoneWithMediaClientConfigProps>;
7
+ declare type MediaPickerErrorBoundaryComponent = React.ComponentType<MediaPickerAnalyticsErrorBoundaryProps>;
8
+ export declare type State = {
9
+ Dropzone?: DropzoneWithMediaClientConfigComponent;
10
+ MediaPickerErrorBoundary?: MediaPickerErrorBoundaryComponent;
11
+ };
12
+ export declare class DropzoneLoader extends React.PureComponent<DropzoneWithMediaClientConfigProps, State> {
13
+ static displayName: string;
14
+ static Dropzone?: DropzoneWithMediaClientConfigComponent;
15
+ static MediaPickerErrorBoundary?: MediaPickerErrorBoundaryComponent;
16
+ state: {
17
+ Dropzone: DropzoneWithMediaClientConfigComponent | undefined;
18
+ MediaPickerErrorBoundary: MediaPickerErrorBoundaryComponent | undefined;
19
+ };
20
+ UNSAFE_componentWillMount(): Promise<void>;
21
+ render(): JSX.Element | null;
22
+ }
23
+ export {};
@@ -0,0 +1,35 @@
1
+ import { Component } from 'react';
2
+ import { MediaClient } from '@atlaskit/media-client';
3
+ import { MediaFeatureFlags } from '@atlaskit/media-common';
4
+ import { UploadService } from '../service/types';
5
+ import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadEventPayloadMap, UploadParams } from '../types';
6
+ import { UploadComponent } from './component';
7
+ import { LocalUploadConfig } from './types';
8
+ import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
9
+ import { AnalyticsEventPayload } from '../types';
10
+ import { ComponentName } from '../util/analytics';
11
+ export declare type LocalUploadComponentBaseProps = {
12
+ mediaClient: MediaClient;
13
+ config: LocalUploadConfig;
14
+ onUploadsStart?: (payload: UploadsStartEventPayload) => void;
15
+ onPreviewUpdate?: (payload: UploadPreviewUpdateEventPayload) => void;
16
+ onEnd?: (payload: UploadEndEventPayload) => void;
17
+ onError?: (payload: UploadErrorEventPayload) => void;
18
+ featureFlags?: MediaFeatureFlags;
19
+ } & WithAnalyticsEventsProps;
20
+ export declare class LocalUploadComponentReact<Props extends LocalUploadComponentBaseProps, M extends UploadEventPayloadMap = UploadEventPayloadMap> extends Component<Props, {}> {
21
+ protected readonly componentName: ComponentName;
22
+ protected readonly uploadService: UploadService;
23
+ protected uploadComponent: UploadComponent<UploadEventPayloadMap>;
24
+ constructor(props: Props, componentName: ComponentName);
25
+ private fireCommencedEvent;
26
+ private fireUploadSucceeded;
27
+ private fireUploadFailed;
28
+ protected createAndFireAnalyticsEvent: (payload: AnalyticsEventPayload) => void;
29
+ cancel: (uniqueIdentifier?: string | undefined) => void;
30
+ setUploadParams(uploadParams: UploadParams): void;
31
+ private onFilesAdded;
32
+ private onFilePreviewUpdate;
33
+ private onFileConverting;
34
+ private onUploadError;
35
+ }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export declare type MediaPickerAnalyticsErrorBoundaryProps = {
3
+ data?: {
4
+ [k: string]: any;
5
+ };
6
+ };
7
+ export default class MediaPickerAnalyticsErrorBoundary extends React.Component<MediaPickerAnalyticsErrorBoundaryProps> {
8
+ static displayName: string;
9
+ render(): JSX.Element;
10
+ }
@@ -0,0 +1,18 @@
1
+ import { UploadEventPayloadMap, UploadParams } from '../types';
2
+ import { MediaFeatureFlags } from '@atlaskit/media-common/mediaFeatureFlags';
3
+ export interface LocalUploadConfig {
4
+ uploadParams: UploadParams;
5
+ shouldCopyFileToRecents?: boolean;
6
+ featureFlags?: MediaFeatureFlags;
7
+ }
8
+ export interface DropzoneDragEnterEventPayload {
9
+ length: number;
10
+ }
11
+ export interface DropzoneDragLeaveEventPayload {
12
+ length: number;
13
+ }
14
+ export declare type DropzoneUploadEventPayloadMap = UploadEventPayloadMap & {
15
+ readonly drop: undefined;
16
+ readonly 'drag-enter': DropzoneDragEnterEventPayload;
17
+ readonly 'drag-leave': DropzoneDragLeaveEventPayload;
18
+ };
@@ -0,0 +1,8 @@
1
+ export interface AppConfig {
2
+ readonly version: number;
3
+ readonly html: {
4
+ readonly redirectUrl: string;
5
+ };
6
+ }
7
+ declare const _default: AppConfig;
8
+ export default _default;
@@ -0,0 +1,8 @@
1
+ export interface PluginFile {
2
+ id: string;
3
+ metadata: any;
4
+ }
5
+ export interface PluginItemPayload {
6
+ pluginName: string;
7
+ pluginFile: PluginFile;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { Preview, ImagePreview } from '../types';
2
+ export declare const isImagePreview: (preview: Preview) => preview is ImagePreview;
@@ -0,0 +1,6 @@
1
+ export { isImagePreview } from './domain/preview';
2
+ export type { BrowserConfig, DropzoneConfig, UploadParams, UploadsStartEventPayload, UploadPreviewUpdateEventPayload, UploadEndEventPayload, UploadErrorEventPayload, MediaFile, Preview, NonImagePreview, ImagePreview, MediaError, MediaErrorName, } from './types';
3
+ export type { LocalUploadConfig } from './components/types';
4
+ export { DropzoneLoader as Dropzone } from './components/dropzone';
5
+ export { ClipboardLoader as Clipboard } from './components/clipboard';
6
+ export { BrowserLoader as Browser } from './components/browser';
@@ -0,0 +1,14 @@
1
+ export interface ServiceFile {
2
+ readonly mimeType: string;
3
+ readonly id: string;
4
+ readonly name: string;
5
+ readonly size: number;
6
+ readonly date: number;
7
+ readonly occurrenceKey?: string;
8
+ readonly metadata?: any;
9
+ readonly createdAt?: number;
10
+ }
11
+ export interface SelectedItem extends ServiceFile {
12
+ readonly serviceName: string;
13
+ readonly accountId?: string;
14
+ }
@@ -0,0 +1,29 @@
1
+ import { UploadEndEventPayload, UploadErrorEventPayload, UploadPreviewUpdateEventPayload, UploadsStartEventPayload, UploadParams } from '../types';
2
+ export declare type UploadServiceEventPayloadTypes = {
3
+ readonly 'files-added': UploadsStartEventPayload;
4
+ readonly 'file-preview-update': UploadPreviewUpdateEventPayload;
5
+ readonly 'file-converting': UploadEndEventPayload;
6
+ readonly 'file-upload-error': UploadErrorEventPayload;
7
+ readonly 'file-dropped': DragEvent;
8
+ };
9
+ export declare type UploadServiceEventListener<E extends keyof UploadServiceEventPayloadTypes> = (payload: UploadServiceEventPayloadTypes[E]) => void;
10
+ export declare const MAX_FILE_SIZE_FOR_PREVIEW = 10000000;
11
+ export interface UploadService {
12
+ setUploadParams(uploadParams: UploadParams): void;
13
+ addFile(file: File, replaceFileId?: string): void;
14
+ addFiles(files: File[]): void;
15
+ addFilesWithSource(files: LocalFileWithSource[]): void;
16
+ cancel(id?: string): void;
17
+ on<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
18
+ off<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
19
+ }
20
+ export declare enum LocalFileSource {
21
+ PastedFile = "pastedFile",
22
+ PastedScreenshot = "pastedScreenshot",
23
+ LocalUpload = "localUpload"
24
+ }
25
+ export interface LocalFileWithSource {
26
+ file: File;
27
+ source: LocalFileSource;
28
+ replaceFileId?: string;
29
+ }
@@ -0,0 +1,33 @@
1
+ import { MediaClient } from '@atlaskit/media-client';
2
+ import { MediaFile, UploadParams } from '../types';
3
+ import { UploadService, UploadServiceEventListener, UploadServiceEventPayloadTypes } from './types';
4
+ import { LocalFileSource, LocalFileWithSource } from '../service/types';
5
+ export interface CancellableFileUpload {
6
+ mediaFile: MediaFile;
7
+ file: File;
8
+ source: LocalFileSource;
9
+ cancel?: () => void;
10
+ }
11
+ export declare class UploadServiceImpl implements UploadService {
12
+ private readonly tenantMediaClient;
13
+ private tenantUploadParams;
14
+ private readonly shouldCopyFileToRecents;
15
+ private readonly userMediaClient?;
16
+ private readonly emitter;
17
+ private cancellableFilesUploads;
18
+ constructor(tenantMediaClient: MediaClient, tenantUploadParams: UploadParams, shouldCopyFileToRecents: boolean);
19
+ setUploadParams(uploadParams: UploadParams): void;
20
+ private createUploadController;
21
+ addFiles(files: File[]): void;
22
+ addFile(file: File, replaceFileId?: string): void;
23
+ addFilesWithSource(files: LocalFileWithSource[]): void;
24
+ cancel(id?: string): void;
25
+ on<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
26
+ off<E extends keyof UploadServiceEventPayloadTypes>(event: E, listener: UploadServiceEventListener<E>): void;
27
+ private readonly emit;
28
+ private emitPreviews;
29
+ private getMediaTypeFromFile;
30
+ private releaseCancellableFile;
31
+ private readonly onFileSuccess;
32
+ private readonly onFileError;
33
+ }
@@ -0,0 +1,120 @@
1
+ import { RequestMetadata } from '@atlaskit/media-client';
2
+ import { UIAttributes, UIEventPayload, OperationalAttributes, SuccessAttributes, FailureAttributes, OperationalEventPayload } from '@atlaskit/media-common';
3
+ import { LocalUploadConfig } from './components/types';
4
+ import { PluginItemPayload } from './domain/plugin';
5
+ export interface UploadParams {
6
+ collection?: string;
7
+ }
8
+ export declare type MediaFile = {
9
+ readonly id: string;
10
+ readonly name: string;
11
+ readonly size: number;
12
+ readonly creationDate: number;
13
+ readonly type: string;
14
+ readonly occurrenceKey?: string;
15
+ };
16
+ export declare type NonImagePreview = {
17
+ readonly file?: Blob;
18
+ };
19
+ export declare type ImagePreview = NonImagePreview & {
20
+ readonly dimensions: {
21
+ readonly width: number;
22
+ readonly height: number;
23
+ };
24
+ readonly scaleFactor: number;
25
+ };
26
+ export declare type Preview = NonImagePreview | ImagePreview;
27
+ export declare type UploadsStartEventPayload = {
28
+ readonly files: MediaFile[];
29
+ };
30
+ export declare type UploadPreviewUpdateEventPayload = {
31
+ readonly file: MediaFile & {
32
+ readonly collectionName?: string;
33
+ };
34
+ readonly preview: Preview;
35
+ };
36
+ export declare type UploadEndEventPayload = {
37
+ readonly file: MediaFile;
38
+ };
39
+ export declare type UploadErrorEventPayload = {
40
+ readonly fileId: string;
41
+ readonly error: MediaError;
42
+ };
43
+ export declare type UploadEventPayloadMap = {
44
+ readonly 'plugin-items-inserted': PluginItemPayload[];
45
+ readonly 'uploads-start': UploadsStartEventPayload;
46
+ readonly 'upload-preview-update': UploadPreviewUpdateEventPayload;
47
+ readonly 'upload-end': UploadEndEventPayload;
48
+ readonly 'upload-error': UploadErrorEventPayload;
49
+ };
50
+ export interface BrowserConfig extends LocalUploadConfig {
51
+ readonly multiple?: boolean;
52
+ readonly fileExtensions?: Array<string>;
53
+ readonly replaceFileId?: string;
54
+ }
55
+ export interface ClipboardConfig extends LocalUploadConfig {
56
+ }
57
+ export interface DropzoneConfig extends LocalUploadConfig {
58
+ container?: HTMLElement;
59
+ headless?: boolean;
60
+ }
61
+ export declare type MediaErrorName = 'object_create_fail' | 'metadata_fetch_fail' | 'token_fetch_fail' | 'token_update_fail' | 'token_source_empty' | 'upload_fail' | 'user_token_fetch_fail' | 'remote_upload_fail' | 'invalid_uuid';
62
+ export declare type MediaError = {
63
+ readonly fileId?: string;
64
+ readonly name: MediaErrorName;
65
+ readonly description: string;
66
+ readonly rawError?: Error;
67
+ };
68
+ export type { PluginItemPayload } from './domain/plugin';
69
+ export type { DropzoneDragEnterEventPayload } from './components/types';
70
+ export declare type ButtonClickedPayload = UIEventPayload<UIAttributes & {
71
+ fileId?: string;
72
+ fileCount?: number;
73
+ collectionName?: string;
74
+ cloudType?: string;
75
+ serviceNames?: string[];
76
+ files?: Array<{
77
+ serviceName: string;
78
+ accountId?: string;
79
+ fileId: string;
80
+ fileMimetype: string;
81
+ fileSize: number;
82
+ fileAge?: string;
83
+ }>;
84
+ }, 'clicked', 'button'>;
85
+ export declare type ClipboardPastePayload = UIEventPayload<UIAttributes & {
86
+ fileCount?: number;
87
+ fileAttributes: Array<{
88
+ fileMimetype: string;
89
+ fileSize: number;
90
+ }>;
91
+ }, 'pasted', 'clipboard'>;
92
+ export declare type DropzoneEventAction = 'draggedOut' | 'draggedInto' | 'droppedInto' | 'folderDroppedInto';
93
+ export declare type DropzoneEventPayload = UIEventPayload<UIAttributes & {
94
+ fileCount: number;
95
+ }, DropzoneEventAction, 'dropzone'>;
96
+ export declare type MediaUploadType = 'localMedia' | 'cloudMedia';
97
+ export declare type MediaUploadSource = 'local' | 'cloud';
98
+ export declare type MediaUploadCommencedPayload = OperationalEventPayload<OperationalAttributes & {
99
+ sourceType: MediaUploadSource;
100
+ serviceName: string;
101
+ }, 'commenced', 'mediaUpload', MediaUploadType>;
102
+ export declare type MediaUploadSuccessPayload = OperationalEventPayload<OperationalAttributes & SuccessAttributes & {
103
+ sourceType: MediaUploadSource;
104
+ serviceName: string;
105
+ uploadDurationMsec: number;
106
+ }, 'succeeded', 'mediaUpload', MediaUploadType>;
107
+ export declare type MediaUploadFailurePayload = OperationalEventPayload<OperationalAttributes & FailureAttributes & {
108
+ sourceType: MediaUploadSource;
109
+ serviceName: string;
110
+ uploadDurationMsec: number;
111
+ request?: RequestMetadata;
112
+ }, 'failed', 'mediaUpload', MediaUploadType>;
113
+ export declare type UnhandledErrorPayload = OperationalEventPayload<OperationalAttributes & FailureAttributes & {
114
+ browserInfo: string;
115
+ info?: string;
116
+ }, 'unhandledError', 'error'>;
117
+ export declare type UUIDValidationErrorPayload = OperationalEventPayload<OperationalAttributes & FailureAttributes & {
118
+ uuid: string;
119
+ }, 'failed', 'mediaUpload'>;
120
+ export declare type AnalyticsEventPayload = ButtonClickedPayload | ClipboardPastePayload | MediaUploadCommencedPayload | MediaUploadSuccessPayload | MediaUploadFailurePayload | UnhandledErrorPayload | UUIDValidationErrorPayload;
@@ -0,0 +1,7 @@
1
+ import { RequestMetadata } from '@atlaskit/media-client';
2
+ import { PackageAttributes } from '@atlaskit/media-common';
3
+ export declare type ComponentName = 'browser' | 'clipboard' | 'dropzone';
4
+ export declare const LOGGED_FEATURE_FLAGS: (keyof import("@atlaskit/media-common").MediaFeatureFlags)[];
5
+ export declare const LOGGED_FEATURE_FLAG_KEYS: string[];
6
+ export declare function getPackageAttributes(componentName: ComponentName): PackageAttributes;
7
+ export declare function getRequestMetadata(error?: Error): RequestMetadata | undefined;
@@ -0,0 +1 @@
1
+ export declare const appendTimestamp: (fileName: string, timestamp: number) => string;
@@ -0,0 +1,25 @@
1
+ export declare type EventPayloadMap<P = any> = {
2
+ readonly [event: string]: P;
3
+ };
4
+ export declare type EventPayloadListener<M extends EventPayloadMap<P>, E extends keyof M, P = any> = (payload: M[E]) => void;
5
+ export interface EventEmitter<M extends EventPayloadMap<P>, P = any> {
6
+ once<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
7
+ on<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
8
+ onAny<E extends keyof M>(listener: (event: E, payload: M[E]) => void): void;
9
+ addListener<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
10
+ off<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
11
+ removeListener<E extends keyof M>(event: E, handler: EventPayloadListener<M, E>): void;
12
+ removeAllListeners<E extends keyof M>(event?: E): void;
13
+ emit<E extends keyof M>(event: E, payload: M[E]): boolean;
14
+ }
15
+ export declare class GenericEventEmitter<M extends EventPayloadMap<P>, P = any> implements EventEmitter<M> {
16
+ private readonly emitter;
17
+ once<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
18
+ on<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
19
+ onAny<E extends keyof M>(listener: (event: E, payload: M[E]) => void): void;
20
+ addListener<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
21
+ off<E extends keyof M>(event: E, listener: EventPayloadListener<M, E>): void;
22
+ removeListener<E extends keyof M>(event: E, handler: EventPayloadListener<M, E>): void;
23
+ removeAllListeners<E extends keyof M>(event?: E): void;
24
+ emit<E extends keyof M>(event: E, payload: M[E]): boolean;
25
+ }
@@ -0,0 +1,4 @@
1
+ import { MediaType, Dimensions } from '@atlaskit/media-client';
2
+ import { Preview } from '../types';
3
+ export declare const isUnknownDimensions: (dimensions: Dimensions) => boolean;
4
+ export declare function getPreviewFromBlob(mediaType: MediaType, file: Blob): Promise<Preview>;
@@ -0,0 +1,3 @@
1
+ import { Preview } from '../types';
2
+ export declare function getPreviewFromImage(file: File, devicePixelRatio?: number): Promise<Preview>;
3
+ export declare const SCALE_FACTOR_DEFAULT = 1;
@@ -0,0 +1,13 @@
1
+ import { FileAttributes, WithFileAttributes } from '@atlaskit/media-common';
2
+ import { RequestMetadata } from '@atlaskit/media-client';
3
+ import { ComponentName } from './analytics';
4
+ export declare type UFOFailedEventPayload = {
5
+ failReason: string;
6
+ error?: string;
7
+ errorDetail?: string | undefined;
8
+ uploadDurationMsec: number;
9
+ request?: RequestMetadata;
10
+ } & WithFileAttributes;
11
+ export declare const startMediaUploadUfoExperience: (id: string, componentName: ComponentName) => void;
12
+ export declare const succeedMediaUploadUfoExperience: (id: string, properties: FileAttributes) => void;
13
+ export declare const failMediaUploadUfoExperience: (id: string, properties?: UFOFailedEventPayload | undefined) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-picker",
3
- "version": "63.0.4",
3
+ "version": "63.0.6",
4
4
  "description": "Library for handling file uploads",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -12,6 +12,13 @@
12
12
  "module": "dist/esm/index.js",
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
+ "typesVersions": {
16
+ ">=4.0 <4.5": {
17
+ "*": [
18
+ "dist/types-ts4.0/*"
19
+ ]
20
+ }
21
+ },
15
22
  "atlaskit:src": "src/index.ts",
16
23
  "af:exports": {
17
24
  "./types": "./src/types.ts",
@@ -41,7 +48,7 @@
41
48
  "uuid-validate": "^0.0.3"
42
49
  },
43
50
  "peerDependencies": {
44
- "@atlaskit/media-core": "^33.0.2",
51
+ "@atlaskit/media-core": "^33.0.3",
45
52
  "react": "^16.8.0",
46
53
  "react-dom": "^16.8.0",
47
54
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -51,13 +58,13 @@
51
58
  "@atlaskit/analytics-namespaced-context": "^6.5.0",
52
59
  "@atlaskit/button": "^16.3.0",
53
60
  "@atlaskit/docs": "*",
54
- "@atlaskit/dropdown-menu": "^11.3.0",
61
+ "@atlaskit/dropdown-menu": "^11.5.0",
55
62
  "@atlaskit/media-card": "^74.1.0",
56
63
  "@atlaskit/media-core": "^33.0.0",
57
64
  "@atlaskit/media-test-helpers": "^30.0.0",
58
65
  "@atlaskit/spinner": "^15.0.0",
59
66
  "@atlaskit/ssr": "*",
60
- "@atlaskit/toggle": "^12.4.0",
67
+ "@atlaskit/toggle": "^12.5.0",
61
68
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
62
69
  "@atlassian/ufo": "^0.1.12",
63
70
  "@emotion/react": "^11.7.1",
@@ -69,7 +76,7 @@
69
76
  "react": "^16.8.0",
70
77
  "react-dom": "^16.8.0",
71
78
  "react-intl-next": "npm:react-intl@^5.18.1",
72
- "typescript": "4.3.5",
79
+ "typescript": "4.5.5",
73
80
  "wait-for-expect": "^1.2.0"
74
81
  },
75
82
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
@@ -3,5 +3,12 @@
3
3
  "main": "../dist/cjs/types.js",
4
4
  "module": "../dist/esm/types.js",
5
5
  "module:es2019": "../dist/es2019/types.js",
6
- "types": "../dist/types/types.d.ts"
6
+ "types": "../dist/types/types.d.ts",
7
+ "typesVersions": {
8
+ ">=4.0 <4.5": {
9
+ "*": [
10
+ "../dist/types-ts4.0/types.d.ts"
11
+ ]
12
+ }
13
+ }
7
14
  }