@box/uploads-manager 1.13.1

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 (103) hide show
  1. package/LICENSE +379 -0
  2. package/README.md +167 -0
  3. package/dist/chunks/uploads-header.js +149 -0
  4. package/dist/chunks/uploads-item-list.js +41 -0
  5. package/dist/chunks/uploads-item.module.js +10 -0
  6. package/dist/chunks/uploads-manager.js +52 -0
  7. package/dist/esm/index.js +5 -0
  8. package/dist/esm/lib/uploads-header/index.js +2 -0
  9. package/dist/esm/lib/uploads-header/uploads-header.js +2 -0
  10. package/dist/esm/lib/uploads-header/uploads-header.messages.js +68 -0
  11. package/dist/esm/lib/uploads-item/components/action-buttons.js +57 -0
  12. package/dist/esm/lib/uploads-item/components/index.js +4 -0
  13. package/dist/esm/lib/uploads-item/components/item-row-icon.js +24 -0
  14. package/dist/esm/lib/uploads-item/components/status-line.js +64 -0
  15. package/dist/esm/lib/uploads-item/index.js +2 -0
  16. package/dist/esm/lib/uploads-item/uploads-item.js +32 -0
  17. package/dist/esm/lib/uploads-item/uploads-item.messages.js +72 -0
  18. package/dist/esm/lib/uploads-item-list/index.js +2 -0
  19. package/dist/esm/lib/uploads-item-list/uploads-item-list.js +2 -0
  20. package/dist/esm/lib/uploads-item-list/uploads-item-list.messages.js +6 -0
  21. package/dist/esm/lib/uploads-manager.js +3 -0
  22. package/dist/esm/lib/utils/getProgress.js +9 -0
  23. package/dist/esm/lib/utils/getStatus.js +11 -0
  24. package/dist/i18n/bn-IN.js +36 -0
  25. package/dist/i18n/bn-IN.properties +68 -0
  26. package/dist/i18n/da-DK.js +36 -0
  27. package/dist/i18n/da-DK.properties +68 -0
  28. package/dist/i18n/de-DE.js +36 -0
  29. package/dist/i18n/de-DE.properties +68 -0
  30. package/dist/i18n/en-AU.js +36 -0
  31. package/dist/i18n/en-AU.properties +68 -0
  32. package/dist/i18n/en-CA.js +36 -0
  33. package/dist/i18n/en-CA.properties +68 -0
  34. package/dist/i18n/en-GB.js +36 -0
  35. package/dist/i18n/en-GB.properties +68 -0
  36. package/dist/i18n/en-US.js +36 -0
  37. package/dist/i18n/en-US.properties +68 -0
  38. package/dist/i18n/en-x-pseudo.js +36 -0
  39. package/dist/i18n/en-x-pseudo.properties +68 -0
  40. package/dist/i18n/es-419.js +36 -0
  41. package/dist/i18n/es-419.properties +68 -0
  42. package/dist/i18n/es-ES.js +36 -0
  43. package/dist/i18n/es-ES.properties +68 -0
  44. package/dist/i18n/fi-FI.js +36 -0
  45. package/dist/i18n/fi-FI.properties +68 -0
  46. package/dist/i18n/fr-CA.js +36 -0
  47. package/dist/i18n/fr-CA.properties +68 -0
  48. package/dist/i18n/fr-FR.js +36 -0
  49. package/dist/i18n/fr-FR.properties +68 -0
  50. package/dist/i18n/hi-IN.js +36 -0
  51. package/dist/i18n/hi-IN.properties +68 -0
  52. package/dist/i18n/it-IT.js +36 -0
  53. package/dist/i18n/it-IT.properties +68 -0
  54. package/dist/i18n/ja-JP.js +36 -0
  55. package/dist/i18n/ja-JP.properties +68 -0
  56. package/dist/i18n/json/src/lib/uploads-header/uploads-header.messages.json +1 -0
  57. package/dist/i18n/json/src/lib/uploads-item/uploads-item.messages.json +1 -0
  58. package/dist/i18n/json/src/lib/uploads-item-list/uploads-item-list.messages.json +1 -0
  59. package/dist/i18n/ko-KR.js +36 -0
  60. package/dist/i18n/ko-KR.properties +68 -0
  61. package/dist/i18n/nb-NO.js +36 -0
  62. package/dist/i18n/nb-NO.properties +68 -0
  63. package/dist/i18n/nl-NL.js +36 -0
  64. package/dist/i18n/nl-NL.properties +68 -0
  65. package/dist/i18n/pl-PL.js +36 -0
  66. package/dist/i18n/pl-PL.properties +68 -0
  67. package/dist/i18n/pt-BR.js +36 -0
  68. package/dist/i18n/pt-BR.properties +68 -0
  69. package/dist/i18n/ru-RU.js +36 -0
  70. package/dist/i18n/ru-RU.properties +68 -0
  71. package/dist/i18n/sv-SE.js +36 -0
  72. package/dist/i18n/sv-SE.properties +68 -0
  73. package/dist/i18n/tr-TR.js +36 -0
  74. package/dist/i18n/tr-TR.properties +68 -0
  75. package/dist/i18n/zh-CN.js +36 -0
  76. package/dist/i18n/zh-CN.properties +68 -0
  77. package/dist/i18n/zh-TW.js +36 -0
  78. package/dist/i18n/zh-TW.properties +68 -0
  79. package/dist/styles/uploads-header.css +1 -0
  80. package/dist/styles/uploads-item-list.css +1 -0
  81. package/dist/styles/uploads-item.css +1 -0
  82. package/dist/styles/uploads-manager.css +1 -0
  83. package/dist/types/index.d.ts +4 -0
  84. package/dist/types/lib/stories/decorators.d.ts +2 -0
  85. package/dist/types/lib/stories/mocks.d.ts +2 -0
  86. package/dist/types/lib/types.d.ts +141 -0
  87. package/dist/types/lib/uploads-header/index.d.ts +2 -0
  88. package/dist/types/lib/uploads-header/uploads-header.d.ts +19 -0
  89. package/dist/types/lib/uploads-header/uploads-header.messages.d.ts +83 -0
  90. package/dist/types/lib/uploads-item/components/action-buttons.d.ts +5 -0
  91. package/dist/types/lib/uploads-item/components/index.d.ts +3 -0
  92. package/dist/types/lib/uploads-item/components/item-row-icon.d.ts +4 -0
  93. package/dist/types/lib/uploads-item/components/status-line.d.ts +4 -0
  94. package/dist/types/lib/uploads-item/index.d.ts +1 -0
  95. package/dist/types/lib/uploads-item/uploads-item.d.ts +6 -0
  96. package/dist/types/lib/uploads-item/uploads-item.messages.d.ts +88 -0
  97. package/dist/types/lib/uploads-item-list/index.d.ts +1 -0
  98. package/dist/types/lib/uploads-item-list/uploads-item-list.d.ts +6 -0
  99. package/dist/types/lib/uploads-item-list/uploads-item-list.messages.d.ts +8 -0
  100. package/dist/types/lib/uploads-manager.d.ts +3 -0
  101. package/dist/types/lib/utils/getProgress.d.ts +2 -0
  102. package/dist/types/lib/utils/getStatus.d.ts +2 -0
  103. package/package.json +51 -0
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Status of an individual upload item.
3
+ *
4
+ * - `pending` — queued, upload has not started yet
5
+ * - `uploading` — actively transferring data
6
+ * - `staged` — commit phase after upload completes (brief, transient)
7
+ * - `complete` — upload finished successfully
8
+ * - `error` — upload failed
9
+ * - `canceled` — user canceled the upload; item remains visible
10
+ */
11
+ export type UploadItemStatus = 'pending' | 'uploading' | 'staged' | 'complete' | 'error' | 'canceled';
12
+ /**
13
+ * Aggregate status of all uploads, derived by the parent from the items array.
14
+ * Drives the header icon, title, subtitle, and action button.
15
+ */
16
+ export type UploadsStatus = 'idle' | 'uploading' | 'success' | 'error' | 'canceled';
17
+ /**
18
+ * Represents a single upload item in the uploads manager.
19
+ *
20
+ * This is a decoupled, primitive-based type. The consuming app is responsible
21
+ * for mapping its internal upload objects to this shape.
22
+ */
23
+ export interface UploadItem {
24
+ /** Unique identifier for this upload */
25
+ id: string;
26
+ /** Display name of the file or folder */
27
+ name: string;
28
+ /**
29
+ * File extension used to determine the file-type icon (e.g. `"pdf"`, `"docx"`).
30
+ * Empty string for folders.
31
+ */
32
+ extension: string;
33
+ /**
34
+ * Upload progress percentage (0–100).
35
+ * Only meaningful when status is `uploading` or `staged`.
36
+ */
37
+ progress: number;
38
+ /** Current status of this upload item */
39
+ status: UploadItemStatus;
40
+ /**
41
+ * Whether this item represents a folder rather than a file.
42
+ * Folder items display a folder icon and have limited actions.
43
+ *
44
+ * @default false
45
+ */
46
+ isFolder?: boolean;
47
+ /**
48
+ * Human-readable error message to display when `status` is `'error'`.
49
+ * The consuming app resolves error codes to localized strings before passing them here.
50
+ */
51
+ errorMessage?: string;
52
+ /**
53
+ * Version label for completed uploads that created a new file version (e.g. `"V2"`).
54
+ * Displayed as a badge next to the file name.
55
+ */
56
+ versionNumber?: string;
57
+ /**
58
+ * Whether retry is available for this errored item.
59
+ * Set to `false` for non-retryable errors (e.g. item-name-in-use conflicts).
60
+ * Ignored when status is not `'error'`.
61
+ *
62
+ * @default true
63
+ */
64
+ isRetryable?: boolean;
65
+ }
66
+ export interface UploadsItemActionCallbacks {
67
+ /**
68
+ * Cancel a single upload item.
69
+ * For `pending` items: removes from queue.
70
+ * For `uploading` items: transitions to `canceled` status.
71
+ */
72
+ onItemCancel?: (itemId: string) => void;
73
+ /**
74
+ * Retry a single errored or canceled item.
75
+ * Always labeled "Retry" in the UI — the handler internally determines
76
+ * whether to resume from the last chunk or restart from scratch.
77
+ */
78
+ onItemRetry?: (itemId: string) => void;
79
+ /** Remove a completed, errored, or canceled item from the list */
80
+ onItemRemove?: (itemId: string) => void;
81
+ /**
82
+ * Open file preview for a completed item.
83
+ * When not provided, the "Open" action button is not rendered.
84
+ */
85
+ onItemOpen?: (itemId: string) => void;
86
+ /**
87
+ * Share a completed item via link.
88
+ * When not provided, the "Share" action button is not rendered.
89
+ */
90
+ onItemShare?: (itemId: string) => void;
91
+ }
92
+ /**
93
+ * Props for the UploadsManager shared feature component (Approach B).
94
+ *
95
+ * The component receives an `items` array and derives header state
96
+ * (overall progress, status text, counts) internally. The consuming app
97
+ * passes items and action callbacks — no data fetching or external
98
+ * context dependencies (except `IntlProvider`).
99
+ */
100
+ export interface UploadsManagerProps extends UploadsItemActionCallbacks {
101
+ /**
102
+ * Controlled: whether the panel is expanded (item list visible).
103
+ * When omitted, the component is uncontrolled and manages its own
104
+ * expanded state (see `defaultExpanded`).
105
+ */
106
+ isExpanded?: boolean;
107
+ /**
108
+ * Called when the expand/collapse state changes (both controlled and
109
+ * uncontrolled modes).
110
+ *
111
+ * In controlled mode, the parent is responsible for updating
112
+ * `isExpanded` in response. In uncontrolled mode, this callback fires
113
+ * for observation only.
114
+ */
115
+ onToggle?: () => void;
116
+ /**
117
+ * Uncontrolled initial expanded state.
118
+ * Ignored when `isExpanded` is provided.
119
+ *
120
+ * @default true
121
+ */
122
+ defaultExpanded?: boolean;
123
+ /**
124
+ * The list of upload items to display.
125
+ * The component derives overall progress, status, and counts from this array.
126
+ */
127
+ items: UploadItem[];
128
+ /**
129
+ * Cancel all pending and in-progress uploads.
130
+ * Completed items are not affected. When provided, a "Cancel All" button
131
+ * appears in the header during active uploads.
132
+ */
133
+ onCancelAll?: () => void;
134
+ /**
135
+ * Retry all errored items. Always labeled "Retry All" in the UI
136
+ * (covers both failed and resumable uploads per PRD-QA decision).
137
+ * When provided, a "Retry All" button appears in the header when
138
+ * errors exist and no uploads are active.
139
+ */
140
+ onRetryAll?: () => void;
141
+ }
@@ -0,0 +1,2 @@
1
+ export * from './uploads-header';
2
+ export { default } from './uploads-header';
@@ -0,0 +1,19 @@
1
+ import { UploadsStatus } from '../types';
2
+ export interface UploadsHeaderProps {
3
+ status: UploadsStatus;
4
+ /** Upload progress percentage (0–100). Pre-computed by the parent. */
5
+ progress: number;
6
+ totalCount: number;
7
+ completedCount: number;
8
+ failedCount: number;
9
+ /** Included for completeness; not currently used in header rendering. */
10
+ canceledCount: number;
11
+ isExpanded: boolean;
12
+ onToggle: () => void;
13
+ /** At most one of onCancelAll / onRetryAll is provided at a time. */
14
+ onCancelAll?: () => void;
15
+ /** At most one of onCancelAll / onRetryAll is provided at a time. */
16
+ onRetryAll?: () => void;
17
+ }
18
+ export declare function UploadsHeader({ status, progress, totalCount, completedCount, failedCount, isExpanded, onToggle, onCancelAll, onRetryAll, }: Readonly<UploadsHeaderProps>): import("react/jsx-runtime").JSX.Element;
19
+ export default UploadsHeader;
@@ -0,0 +1,83 @@
1
+ declare const _default: {
2
+ titleDragAndDrop: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ titleUploading: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ titleComplete: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ titleCanceled: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ titleErrorAllFailed: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ subtitleProgress: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ subtitleErrors: {
33
+ id: string;
34
+ defaultMessage: string;
35
+ description: string;
36
+ };
37
+ cancelAll: {
38
+ id: string;
39
+ defaultMessage: string;
40
+ description: string;
41
+ };
42
+ retryAll: {
43
+ id: string;
44
+ defaultMessage: string;
45
+ description: string;
46
+ };
47
+ toggleExpand: {
48
+ id: string;
49
+ defaultMessage: string;
50
+ description: string;
51
+ };
52
+ toggleCollapse: {
53
+ id: string;
54
+ defaultMessage: string;
55
+ description: string;
56
+ };
57
+ progressAriaLabel: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
62
+ statusIconPending: {
63
+ id: string;
64
+ defaultMessage: string;
65
+ description: string;
66
+ };
67
+ statusIconComplete: {
68
+ id: string;
69
+ defaultMessage: string;
70
+ description: string;
71
+ };
72
+ statusIconError: {
73
+ id: string;
74
+ defaultMessage: string;
75
+ description: string;
76
+ };
77
+ statusIconCanceled: {
78
+ id: string;
79
+ defaultMessage: string;
80
+ description: string;
81
+ };
82
+ };
83
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import { UploadItem, UploadsItemActionCallbacks } from '../../types';
2
+ export interface ActionButtonsProps extends UploadsItemActionCallbacks {
3
+ item: UploadItem;
4
+ }
5
+ export declare function ActionButtons({ item, onItemCancel, onItemRetry, onItemRemove, onItemOpen, onItemShare }: Readonly<ActionButtonsProps>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ export { ItemRowIcon } from './item-row-icon';
2
+ export { StatusLine } from './status-line';
3
+ export { ActionButtons, type ActionButtonsProps } from './action-buttons';
@@ -0,0 +1,4 @@
1
+ import { UploadItem } from '../../types';
2
+ export declare function ItemRowIcon({ item }: Readonly<{
3
+ item: UploadItem;
4
+ }>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { UploadItem } from '../../types';
2
+ export declare function StatusLine({ item }: Readonly<{
3
+ item: UploadItem;
4
+ }>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export { UploadsItem, type UploadsItemProps } from './uploads-item';
@@ -0,0 +1,6 @@
1
+ import { UploadItem, UploadsItemActionCallbacks } from '../types';
2
+ export interface UploadsItemProps extends UploadsItemActionCallbacks {
3
+ item: UploadItem;
4
+ }
5
+ export declare function UploadsItem({ item, onItemCancel, onItemRetry, onItemRemove, onItemOpen, onItemShare }: Readonly<UploadsItemProps>): import("react/jsx-runtime").JSX.Element;
6
+ export default UploadsItem;
@@ -0,0 +1,88 @@
1
+ declare const _default: {
2
+ itemStatusUploading: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ itemStatusCompleted: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ description: string;
11
+ };
12
+ itemStatusCompletedWithVersion: {
13
+ id: string;
14
+ defaultMessage: string;
15
+ description: string;
16
+ };
17
+ itemStatusVersionSuffix: {
18
+ id: string;
19
+ defaultMessage: string;
20
+ description: string;
21
+ };
22
+ itemStatusCanceled: {
23
+ id: string;
24
+ defaultMessage: string;
25
+ description: string;
26
+ };
27
+ itemStatusError: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ description: string;
31
+ };
32
+ itemProgressAriaLabel: {
33
+ id: string;
34
+ defaultMessage: string;
35
+ description: string;
36
+ };
37
+ itemActionCancel: {
38
+ id: string;
39
+ defaultMessage: string;
40
+ description: string;
41
+ };
42
+ itemActionCancelAriaLabel: {
43
+ id: string;
44
+ defaultMessage: string;
45
+ description: string;
46
+ };
47
+ itemActionRetry: {
48
+ id: string;
49
+ defaultMessage: string;
50
+ description: string;
51
+ };
52
+ itemActionRetryAriaLabel: {
53
+ id: string;
54
+ defaultMessage: string;
55
+ description: string;
56
+ };
57
+ itemActionRemove: {
58
+ id: string;
59
+ defaultMessage: string;
60
+ description: string;
61
+ };
62
+ itemActionRemoveAriaLabel: {
63
+ id: string;
64
+ defaultMessage: string;
65
+ description: string;
66
+ };
67
+ itemActionOpen: {
68
+ id: string;
69
+ defaultMessage: string;
70
+ description: string;
71
+ };
72
+ itemActionOpenAriaLabel: {
73
+ id: string;
74
+ defaultMessage: string;
75
+ description: string;
76
+ };
77
+ itemActionShare: {
78
+ id: string;
79
+ defaultMessage: string;
80
+ description: string;
81
+ };
82
+ itemActionShareAriaLabel: {
83
+ id: string;
84
+ defaultMessage: string;
85
+ description: string;
86
+ };
87
+ };
88
+ export default _default;
@@ -0,0 +1 @@
1
+ export { UploadsItemList, type UploadsItemListProps } from './uploads-item-list';
@@ -0,0 +1,6 @@
1
+ import { UploadItem, UploadsItemActionCallbacks } from '../types';
2
+ export interface UploadsItemListProps extends UploadsItemActionCallbacks {
3
+ items: UploadItem[];
4
+ }
5
+ export declare function UploadsItemList({ items, onItemCancel, onItemRetry, onItemRemove, onItemOpen, onItemShare, }: Readonly<UploadsItemListProps>): import("react/jsx-runtime").JSX.Element;
6
+ export default UploadsItemList;
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ listAriaLabel: {
3
+ id: string;
4
+ defaultMessage: string;
5
+ description: string;
6
+ };
7
+ };
8
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import { UploadsManagerProps } from './types';
2
+ export declare function UploadsManager({ isExpanded: isExpandedProp, defaultExpanded, onToggle: onToggleProp, items, onCancelAll, onRetryAll, onItemCancel, onItemRetry, onItemRemove, onItemOpen, onItemShare, }: Readonly<UploadsManagerProps>): import("react/jsx-runtime").JSX.Element;
3
+ export default UploadsManager;
@@ -0,0 +1,2 @@
1
+ import { UploadItem } from '../types';
2
+ export declare function getProgress(items: UploadItem[]): number;
@@ -0,0 +1,2 @@
1
+ import { UploadItem, UploadsStatus } from '../types';
2
+ export declare function getStatus(items: UploadItem[]): UploadsStatus;
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@box/uploads-manager",
3
+ "version": "1.13.1",
4
+ "license": "SEE LICENSE IN LICENSE",
5
+ "peerDependencies": {
6
+ "@box/blueprint-web": "^14.30.0",
7
+ "@box/blueprint-web-assets": "^4.117.2",
8
+ "@box/item-icon": "^2.35.3",
9
+ "react": "^18.0.0",
10
+ "react-aria-components": "1.16.0",
11
+ "react-dom": "^18.0.0",
12
+ "react-intl": "^6.4.2"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "devDependencies": {
18
+ "@box/blueprint-web": "^14.30.0",
19
+ "@box/blueprint-web-assets": "^4.117.2",
20
+ "@box/eslint-plugin-blueprint": "1.2.0",
21
+ "@box/item-icon": "^2.35.3",
22
+ "@box/storybook-utils": "0.19.2",
23
+ "react-aria-components": "1.16.0",
24
+ "react-intl": "^6.4.2"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "main": "./dist/esm/index.js",
30
+ "module": "./dist/esm/index.js",
31
+ "types": "./dist/types/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "require": "./dist/esm/index.js",
35
+ "import": "./dist/esm/index.js",
36
+ "types": "./dist/types/index.d.ts"
37
+ },
38
+ "./*": {
39
+ "require": "./dist/esm/*",
40
+ "import": "./dist/esm/*",
41
+ "types": "./dist/types/*"
42
+ },
43
+ "./i18n/*": {
44
+ "require": "./dist/i18n/*",
45
+ "import": "./dist/i18n/*"
46
+ }
47
+ },
48
+ "sideEffects": [
49
+ "**/*.css"
50
+ ]
51
+ }