@atlaskit/media-picker 66.7.5 → 67.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @atlaskit/media-picker
2
2
 
3
+ ## 67.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#157917](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/157917)
8
+ [`3a51e350e14ce`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3a51e350e14ce) -
9
+ [ux] Property `onUploadRejection` now also catches rejected empty files (zero byte).
10
+
11
+ You must ensure that the user gets the right feedback if your `onUploadRejection` callback
12
+ overrides the default Error Flag (i.e. returns true).
13
+
14
+ The new callback parameter is of the type:
15
+
16
+ ```
17
+ type UploadRejectionData = FileSizeLimitExceededData | FileEmptyData
18
+ ```
19
+
20
+ Where:
21
+
22
+ ```
23
+ type FileSizeLimitExceededData = {
24
+ reason: 'fileSizeLimitExceeded';
25
+ fileName: string;
26
+ limit: number;
27
+ }
28
+
29
+ type FileEmptyData = {
30
+ reason: 'fileEmpty';
31
+ fileName: string;
32
+ }
33
+ ```
34
+
3
35
  ## 66.7.5
4
36
 
5
37
  ### Patch Changes
@@ -213,18 +213,15 @@ var LocalUploadComponentReact = exports.LocalUploadComponentReact = /*#__PURE__*
213
213
  _this.uploadService.on('file-preview-update', _this.onFilePreviewUpdate);
214
214
  _this.uploadService.on('file-converting', _this.onFileConverting);
215
215
  _this.uploadService.on('file-upload-error', _this.onUploadError);
216
- _this.uploadService.onFileEmpty(_this.addErrorFlag);
217
- if (tenantUploadParams.onUploadRejection) {
216
+ var onFileRejection = function onFileRejection(rejectionData) {
218
217
  var onUploadRejection = tenantUploadParams.onUploadRejection;
219
- _this.uploadService.onFileRejection(function (rejectionData) {
220
- var shouldOverride = onUploadRejection(rejectionData);
221
- if (!shouldOverride) {
222
- _this.addErrorFlag(rejectionData);
223
- }
224
- });
225
- } else {
226
- _this.uploadService.onFileRejection(_this.addErrorFlag);
227
- }
218
+ var shouldOverride = onUploadRejection === null || onUploadRejection === void 0 ? void 0 : onUploadRejection(rejectionData);
219
+ if (!shouldOverride) {
220
+ _this.addErrorFlag(rejectionData);
221
+ }
222
+ };
223
+ _this.uploadService.onFileRejection(onFileRejection);
224
+ _this.uploadService.onFileEmpty(onFileRejection);
228
225
  return _this;
229
226
  }
230
227
  (0, _createClass2.default)(LocalUploadComponentReact, [{
@@ -9,7 +9,7 @@ var _mediaClient = require("@atlaskit/media-client");
9
9
  // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
10
10
 
11
11
  var packageName = "@atlaskit/media-picker";
12
- var packageVersion = "66.7.5";
12
+ var packageVersion = "67.0.0";
13
13
  function getPackageAttributes(componentName) {
14
14
  return {
15
15
  packageName: packageName,
@@ -12,7 +12,7 @@ var _mediaClient = require("@atlaskit/media-client");
12
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
14
  var packageName = "@atlaskit/media-picker";
15
- var packageVersion = "66.7.5";
15
+ var packageVersion = "67.0.0";
16
16
  var ufoExperience;
17
17
  var initExperience = function initExperience(id, componentName) {
18
18
  if (!ufoExperience) {
@@ -200,20 +200,17 @@ export class LocalUploadComponentReact extends Component {
200
200
  this.uploadService.on('file-preview-update', this.onFilePreviewUpdate);
201
201
  this.uploadService.on('file-converting', this.onFileConverting);
202
202
  this.uploadService.on('file-upload-error', this.onUploadError);
203
- this.uploadService.onFileEmpty(this.addErrorFlag);
204
- if (tenantUploadParams.onUploadRejection) {
203
+ const onFileRejection = rejectionData => {
205
204
  const {
206
205
  onUploadRejection
207
206
  } = tenantUploadParams;
208
- this.uploadService.onFileRejection(rejectionData => {
209
- const shouldOverride = onUploadRejection(rejectionData);
210
- if (!shouldOverride) {
211
- this.addErrorFlag(rejectionData);
212
- }
213
- });
214
- } else {
215
- this.uploadService.onFileRejection(this.addErrorFlag);
216
- }
207
+ const shouldOverride = onUploadRejection === null || onUploadRejection === void 0 ? void 0 : onUploadRejection(rejectionData);
208
+ if (!shouldOverride) {
209
+ this.addErrorFlag(rejectionData);
210
+ }
211
+ };
212
+ this.uploadService.onFileRejection(onFileRejection);
213
+ this.uploadService.onFileEmpty(onFileRejection);
217
214
  }
218
215
  setUploadParams(uploadParams) {
219
216
  this.uploadService.setUploadParams(uploadParams);
@@ -3,7 +3,7 @@ import { isRequestError } from '@atlaskit/media-client';
3
3
  // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
4
4
 
5
5
  const packageName = "@atlaskit/media-picker";
6
- const packageVersion = "66.7.5";
6
+ const packageVersion = "67.0.0";
7
7
  export function getPackageAttributes(componentName) {
8
8
  return {
9
9
  packageName,
@@ -2,7 +2,7 @@ import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } fro
2
2
  import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
3
3
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
4
4
  const packageName = "@atlaskit/media-picker";
5
- const packageVersion = "66.7.5";
5
+ const packageVersion = "67.0.0";
6
6
  let ufoExperience;
7
7
  const initExperience = (id, componentName) => {
8
8
  if (!ufoExperience) {
@@ -206,18 +206,15 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
206
206
  _this.uploadService.on('file-preview-update', _this.onFilePreviewUpdate);
207
207
  _this.uploadService.on('file-converting', _this.onFileConverting);
208
208
  _this.uploadService.on('file-upload-error', _this.onUploadError);
209
- _this.uploadService.onFileEmpty(_this.addErrorFlag);
210
- if (tenantUploadParams.onUploadRejection) {
209
+ var onFileRejection = function onFileRejection(rejectionData) {
211
210
  var onUploadRejection = tenantUploadParams.onUploadRejection;
212
- _this.uploadService.onFileRejection(function (rejectionData) {
213
- var shouldOverride = onUploadRejection(rejectionData);
214
- if (!shouldOverride) {
215
- _this.addErrorFlag(rejectionData);
216
- }
217
- });
218
- } else {
219
- _this.uploadService.onFileRejection(_this.addErrorFlag);
220
- }
211
+ var shouldOverride = onUploadRejection === null || onUploadRejection === void 0 ? void 0 : onUploadRejection(rejectionData);
212
+ if (!shouldOverride) {
213
+ _this.addErrorFlag(rejectionData);
214
+ }
215
+ };
216
+ _this.uploadService.onFileRejection(onFileRejection);
217
+ _this.uploadService.onFileEmpty(onFileRejection);
221
218
  return _this;
222
219
  }
223
220
  _createClass(LocalUploadComponentReact, [{
@@ -3,7 +3,7 @@ import { isRequestError } from '@atlaskit/media-client';
3
3
  // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
4
4
 
5
5
  var packageName = "@atlaskit/media-picker";
6
- var packageVersion = "66.7.5";
6
+ var packageVersion = "67.0.0";
7
7
  export function getPackageAttributes(componentName) {
8
8
  return {
9
9
  packageName: packageName,
@@ -5,7 +5,7 @@ import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } fro
5
5
  import { getFeatureFlagKeysAllProducts } from '@atlaskit/media-common';
6
6
  import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
7
7
  var packageName = "@atlaskit/media-picker";
8
- var packageVersion = "66.7.5";
8
+ var packageVersion = "67.0.0";
9
9
  var ufoExperience;
10
10
  var initExperience = function initExperience(id, componentName) {
11
11
  if (!ufoExperience) {
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { type FlagData } from '../../types';
2
+ import { type UploadRejectionData } from '../../types';
3
3
  import { type WrappedComponentProps } from 'react-intl-next';
4
4
  export interface ErrorFlagGroupProps {
5
- readonly flagData: FlagData[];
5
+ readonly flagData: UploadRejectionData[];
6
6
  onFlagDismissed: () => void;
7
7
  }
8
8
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ErrorFlagGroupProps & WrappedComponentProps>> & {
@@ -2,7 +2,7 @@ import { Component } from 'react';
2
2
  import { type MediaClient } from '@atlaskit/media-client';
3
3
  import { type MediaFeatureFlags } from '@atlaskit/media-common';
4
4
  import { type UploadService } from '../service/types';
5
- import { type UploadEndEventPayload, type UploadErrorEventPayload, type UploadPreviewUpdateEventPayload, type UploadsStartEventPayload, type UploadParams, type FlagData } from '../types';
5
+ import { type UploadEndEventPayload, type UploadErrorEventPayload, type UploadPreviewUpdateEventPayload, type UploadsStartEventPayload, type UploadParams, type UploadRejectionData } from '../types';
6
6
  import { UploadComponent } from './component';
7
7
  import { type LocalUploadConfig } from './types';
8
8
  import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
@@ -18,7 +18,7 @@ export type LocalUploadComponentBaseProps = {
18
18
  featureFlags?: MediaFeatureFlags;
19
19
  } & WithAnalyticsEventsProps;
20
20
  export type LocalUploadComponentBaseState = {
21
- errorFlags: FlagData[];
21
+ errorFlags: UploadRejectionData[];
22
22
  };
23
23
  export declare class LocalUploadComponentReact<Props extends LocalUploadComponentBaseProps> extends Component<Props, LocalUploadComponentBaseState> {
24
24
  protected readonly componentName: ComponentName;
@@ -52,7 +52,8 @@ export type UploadEventPayloadMap = {
52
52
  readonly 'upload-end': UploadEndEventPayload;
53
53
  readonly 'upload-error': UploadErrorEventPayload;
54
54
  };
55
- export type UploadRejectionData = {
55
+ export type UploadRejectionData = FileSizeLimitExceededData | FileEmptyData;
56
+ export type FileSizeLimitExceededData = {
56
57
  reason: 'fileSizeLimitExceeded';
57
58
  fileName: string;
58
59
  limit: number;
@@ -61,7 +62,6 @@ export type FileEmptyData = {
61
62
  reason: 'fileEmpty';
62
63
  fileName: string;
63
64
  };
64
- export type FlagData = UploadRejectionData | FileEmptyData;
65
65
  export interface BrowserConfig extends LocalUploadConfig {
66
66
  readonly multiple?: boolean;
67
67
  readonly fileExtensions?: Array<string>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { type FlagData } from '../../types';
2
+ import { type UploadRejectionData } from '../../types';
3
3
  import { type WrappedComponentProps } from 'react-intl-next';
4
4
  export interface ErrorFlagGroupProps {
5
- readonly flagData: FlagData[];
5
+ readonly flagData: UploadRejectionData[];
6
6
  onFlagDismissed: () => void;
7
7
  }
8
8
  declare const _default: React.FC<import("react-intl-next").WithIntlProps<ErrorFlagGroupProps & WrappedComponentProps>> & {
@@ -2,7 +2,7 @@ import { Component } from 'react';
2
2
  import { type MediaClient } from '@atlaskit/media-client';
3
3
  import { type MediaFeatureFlags } from '@atlaskit/media-common';
4
4
  import { type UploadService } from '../service/types';
5
- import { type UploadEndEventPayload, type UploadErrorEventPayload, type UploadPreviewUpdateEventPayload, type UploadsStartEventPayload, type UploadParams, type FlagData } from '../types';
5
+ import { type UploadEndEventPayload, type UploadErrorEventPayload, type UploadPreviewUpdateEventPayload, type UploadsStartEventPayload, type UploadParams, type UploadRejectionData } from '../types';
6
6
  import { UploadComponent } from './component';
7
7
  import { type LocalUploadConfig } from './types';
8
8
  import { type WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
@@ -18,7 +18,7 @@ export type LocalUploadComponentBaseProps = {
18
18
  featureFlags?: MediaFeatureFlags;
19
19
  } & WithAnalyticsEventsProps;
20
20
  export type LocalUploadComponentBaseState = {
21
- errorFlags: FlagData[];
21
+ errorFlags: UploadRejectionData[];
22
22
  };
23
23
  export declare class LocalUploadComponentReact<Props extends LocalUploadComponentBaseProps> extends Component<Props, LocalUploadComponentBaseState> {
24
24
  protected readonly componentName: ComponentName;
@@ -52,7 +52,8 @@ export type UploadEventPayloadMap = {
52
52
  readonly 'upload-end': UploadEndEventPayload;
53
53
  readonly 'upload-error': UploadErrorEventPayload;
54
54
  };
55
- export type UploadRejectionData = {
55
+ export type UploadRejectionData = FileSizeLimitExceededData | FileEmptyData;
56
+ export type FileSizeLimitExceededData = {
56
57
  reason: 'fileSizeLimitExceeded';
57
58
  fileName: string;
58
59
  limit: number;
@@ -61,7 +62,6 @@ export type FileEmptyData = {
61
62
  reason: 'fileEmpty';
62
63
  fileName: string;
63
64
  };
64
- export type FlagData = UploadRejectionData | FileEmptyData;
65
65
  export interface BrowserConfig extends LocalUploadConfig {
66
66
  readonly multiple?: boolean;
67
67
  readonly fileExtensions?: Array<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-picker",
3
- "version": "66.7.5",
3
+ "version": "67.0.0",
4
4
  "description": "Library for handling file uploads",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"