@aws-amplify/ui-react-storage 3.0.13 → 3.0.15

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.
@@ -1,9 +1,10 @@
1
1
  import * as React from 'react';
2
+ import { isString, isFunction } from '@aws-amplify/ui';
2
3
  import { uploadFile } from '../../utils/uploadFile.mjs';
3
4
  import { FileStatus } from '../../types.mjs';
4
5
  import { resolveFile } from './resolveFile.mjs';
5
6
 
6
- function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile, path = '', }) {
7
+ function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile, path, }) {
7
8
  React.useEffect(() => {
8
9
  const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
9
10
  if (filesReadyToUpload.length > maxFileCount) {
@@ -11,7 +12,9 @@ function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, se
11
12
  }
12
13
  for (const { file, key, id } of filesReadyToUpload) {
13
14
  const onComplete = (event) => {
14
- onUploadSuccess?.(event);
15
+ if (isFunction(onUploadSuccess)) {
16
+ onUploadSuccess(event);
17
+ }
15
18
  setUploadSuccess({ id });
16
19
  };
17
20
  const onProgress = (event) => {
@@ -24,24 +27,28 @@ function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, se
24
27
  : Math.floor((event.transferredBytes / event.totalBytes) * 100);
25
28
  setUploadProgress({ id, progress: progressPercentage });
26
29
  };
27
- const onError = (error) => {
28
- onUploadError?.(error, { key });
29
- };
30
30
  if (file) {
31
31
  resolveFile({ processFile, file, key }).then(({ key: processedKey, ...rest }) => {
32
- onUploadStart?.({ key: processedKey });
32
+ // prepend `path` to `processedKey`
33
+ const resolvedKey = isString(path)
34
+ ? `${path}${processedKey}`
35
+ : processedKey;
36
+ if (isFunction(onUploadStart)) {
37
+ onUploadStart({ key: resolvedKey });
38
+ }
33
39
  const uploadTask = uploadFile({
34
40
  ...rest,
35
- key: processedKey,
41
+ key: resolvedKey,
36
42
  level: accessLevel,
37
43
  progressCallback: onProgress,
38
- errorCallback: onError,
44
+ errorCallback: (error) => {
45
+ if (isFunction(onUploadError)) {
46
+ onUploadError(error, { key: resolvedKey });
47
+ }
48
+ },
39
49
  completeCallback: onComplete,
40
50
  });
41
- setUploadingFile({
42
- id,
43
- uploadTask,
44
- });
51
+ setUploadingFile({ id, uploadTask });
45
52
  });
46
53
  }
47
54
  }
@@ -1,3 +1,3 @@
1
- const VERSION = '3.0.13';
1
+ const VERSION = '3.0.15';
2
2
 
3
3
  export { VERSION };
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ function _interopNamespace(e) {
32
32
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
33
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
34
34
 
35
- const VERSION = '3.0.13';
35
+ const VERSION = '3.0.15';
36
36
 
37
37
  const StorageImage = ({ accessLevel, className, fallbackSrc, identityId, imgKey, onStorageGetError, validateObjectExistence, ...rest }) => {
38
38
  const resolvedValidateObjectExistence = ui.isUndefined(validateObjectExistence)
@@ -348,7 +348,7 @@ const resolveFile = ({ processFile, file, key, }) => {
348
348
  });
349
349
  };
350
350
 
351
- function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile, path = '', }) {
351
+ function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, setUploadingFile, setUploadSuccess, onUploadError, onUploadSuccess, onUploadStart, maxFileCount, processFile, path, }) {
352
352
  React__namespace.useEffect(() => {
353
353
  const filesReadyToUpload = files.filter((file) => file.status === FileStatus.QUEUED);
354
354
  if (filesReadyToUpload.length > maxFileCount) {
@@ -356,7 +356,9 @@ function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, se
356
356
  }
357
357
  for (const { file, key, id } of filesReadyToUpload) {
358
358
  const onComplete = (event) => {
359
- onUploadSuccess?.(event);
359
+ if (ui.isFunction(onUploadSuccess)) {
360
+ onUploadSuccess(event);
361
+ }
360
362
  setUploadSuccess({ id });
361
363
  };
362
364
  const onProgress = (event) => {
@@ -369,24 +371,28 @@ function useUploadFiles({ files, accessLevel, isResumable, setUploadProgress, se
369
371
  : Math.floor((event.transferredBytes / event.totalBytes) * 100);
370
372
  setUploadProgress({ id, progress: progressPercentage });
371
373
  };
372
- const onError = (error) => {
373
- onUploadError?.(error, { key });
374
- };
375
374
  if (file) {
376
375
  resolveFile({ processFile, file, key }).then(({ key: processedKey, ...rest }) => {
377
- onUploadStart?.({ key: processedKey });
376
+ // prepend `path` to `processedKey`
377
+ const resolvedKey = ui.isString(path)
378
+ ? `${path}${processedKey}`
379
+ : processedKey;
380
+ if (ui.isFunction(onUploadStart)) {
381
+ onUploadStart({ key: resolvedKey });
382
+ }
378
383
  const uploadTask = uploadFile({
379
384
  ...rest,
380
- key: processedKey,
385
+ key: resolvedKey,
381
386
  level: accessLevel,
382
387
  progressCallback: onProgress,
383
- errorCallback: onError,
388
+ errorCallback: (error) => {
389
+ if (ui.isFunction(onUploadError)) {
390
+ onUploadError(error, { key: resolvedKey });
391
+ }
392
+ },
384
393
  completeCallback: onComplete,
385
394
  });
386
- setUploadingFile({
387
- id,
388
- uploadTask,
389
- });
395
+ setUploadingFile({ id, uploadTask });
390
396
  });
391
397
  }
392
398
  }
package/dist/styles.css CHANGED
@@ -512,6 +512,7 @@
512
512
  --amplify-components-checkbox-icon-indeterminate-opacity: var(--amplify-opacities-100);
513
513
  --amplify-components-checkbox-icon-indeterminate-transform: scale(1);
514
514
  --amplify-components-checkbox-icon-indeterminate-disabled-background-color: var(--amplify-colors-background-disabled);
515
+ --amplify-components-checkbox-label-color: var(--amplify-components-text-color);
515
516
  --amplify-components-checkbox-label-disabled-color: var(--amplify-colors-font-disabled);
516
517
  --amplify-components-checkboxfield-align-items: flex-start;
517
518
  --amplify-components-checkboxfield-align-content: center;
@@ -3668,7 +3669,10 @@ strong.amplify-text {
3668
3669
  }
3669
3670
 
3670
3671
  .amplify-checkbox__label {
3671
- color: inherit;
3672
+ color: var(--amplify-components-checkbox-label-color);
3673
+ }
3674
+ .amplify-checkbox__label--disabled {
3675
+ color: var(--amplify-components-checkbox-label-disabled-color);
3672
3676
  }
3673
3677
 
3674
3678
  .amplify-checkboxfield {
@@ -1 +1 @@
1
- export declare const VERSION = "3.0.13";
1
+ export declare const VERSION = "3.0.15";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-react-storage",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {
@@ -39,9 +39,9 @@
39
39
  "typecheck": "tsc --noEmit"
40
40
  },
41
41
  "dependencies": {
42
- "@aws-amplify/ui": "6.0.9",
43
- "@aws-amplify/ui-react": "6.1.3",
44
- "@aws-amplify/ui-react-core": "3.0.9",
42
+ "@aws-amplify/ui": "6.0.11",
43
+ "@aws-amplify/ui-react": "6.1.5",
44
+ "@aws-amplify/ui-react-core": "3.0.11",
45
45
  "lodash": "4.17.21",
46
46
  "tslib": "^2.5.2"
47
47
  },