@salesforce/webapp-template-feature-react-file-upload-experimental 1.55.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/LICENSE.txt +82 -0
- package/README.md +102 -0
- package/dist/.a4drules/README.md +35 -0
- package/dist/.a4drules/a4d-webapp-generate.md +27 -0
- package/dist/.a4drules/build-validation.md +78 -0
- package/dist/.a4drules/code-quality.md +137 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-explore-graphql-schema.md +227 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-mutationquery.md +212 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-readquery.md +185 -0
- package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +205 -0
- package/dist/.a4drules/graphql/tools/schemas/shared.graphqls +1150 -0
- package/dist/.a4drules/graphql.md +409 -0
- package/dist/.a4drules/images.md +13 -0
- package/dist/.a4drules/react.md +387 -0
- package/dist/.a4drules/react_image_processing.md +45 -0
- package/dist/.a4drules/typescript.md +224 -0
- package/dist/.a4drules/ui-layout.md +23 -0
- package/dist/.a4drules/webapp-nav-and-placeholders.md +33 -0
- package/dist/.a4drules/webapp-no-node-e.md +25 -0
- package/dist/.a4drules/webapp-ui-first.md +32 -0
- package/dist/.a4drules/webapp.md +75 -0
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/AGENT.md +75 -0
- package/dist/CHANGELOG.md +803 -0
- package/dist/README.md +18 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/.prettierignore +9 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/.prettierrc +11 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/build/vite.config.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/build/vite.config.js +93 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/codegen.yml +94 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/e2e/app.spec.ts +17 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/eslint.config.js +141 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/feature-react-file-upload.webapplication-meta.xml +7 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/index.html +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/package-lock.json +18396 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/package.json +66 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/playwright.config.ts +24 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/scripts/get-graphql-schema.mjs +68 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/fileUpload.ts +154 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/graphql-operations-types.ts +116 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/utils/accounts.ts +41 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/api/utils/query/highRevenueAccountsQuery.graphql +29 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/app.tsx +22 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/appLayout.tsx +9 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/book.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/copy.svg +4 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/rocket.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icons/star.svg +3 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/images/vibe-codey.svg +194 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/symbols.svg +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/assets/utility.svg +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUpload.tsx +83 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDialog.tsx +79 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDropZone.tsx +82 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadFileItem.tsx +99 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadIcons.tsx +58 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/alert.tsx +69 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/button.tsx +67 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/card.tsx +92 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/dialog.tsx +143 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/field.tsx +222 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/index.ts +84 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/input.tsx +19 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/label.tsx +19 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/pagination.tsx +112 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/select.tsx +183 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/separator.tsx +26 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/skeleton.tsx +14 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/spinner.tsx +15 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/table.tsx +87 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/tabs.tsx +78 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/components.json +18 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUpload.ts +299 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUploadDialog.ts +70 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/index.ts +56 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/navigationMenu.tsx +80 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/pages/Home.tsx +25 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/pages/NotFound.tsx +18 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/router-utils.tsx +35 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/routes.tsx +22 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/styles/global.css +135 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/types/fileUpload.ts +26 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/utils/fileUploadUtils.ts +44 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/src/utils/labels.ts +21 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/tsconfig.json +36 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vite-env.d.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vite.config.ts +43 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vitest-env.d.ts +2 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vitest.config.ts +11 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vitest.setup.ts +1 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/webapplication.json +7 -0
- package/dist/jest.config.js +6 -0
- package/dist/package.json +38 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +53 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/api/fileUpload.ts +154 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/appLayout.tsx +9 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/symbols.svg +1 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/utility.svg +1 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUpload.tsx +83 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDialog.tsx +79 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDropZone.tsx +82 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadFileItem.tsx +99 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadIcons.tsx +58 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUpload.ts +299 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUploadDialog.ts +70 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/index.ts +56 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/pages/Home.tsx +25 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/routes.tsx +17 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/types/fileUpload.ts +26 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/fileUploadUtils.ts +44 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/labels.ts +21 -0
- package/src/force-app/main/default/webapplications/feature-react-file-upload/vite.config.ts +43 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook: useFileUploadDialog
|
|
3
|
+
*
|
|
4
|
+
* Manages file upload dialog state: open/close and list of successfully uploaded file names.
|
|
5
|
+
* Powers the FileUpload component internally. Opens dialog when fileItems has items; on close,
|
|
6
|
+
* captures success names for display and resets upload state.
|
|
7
|
+
*
|
|
8
|
+
* Not exported from the package. Use the FileUpload component for file upload UIs.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Dialog options (fileItems, reset)
|
|
11
|
+
* @returns Object containing dialogOpen, uploadedFileNames, handleOpenChange
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Coordinates with useFileUpload: opens when fileItems.length > 0, on close calls reset and
|
|
15
|
+
* accumulates successfully uploaded file names for the summary list below the drop zone.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const { dialogOpen, uploadedFileNames, handleOpenChange } = useFileUploadDialog({
|
|
20
|
+
* fileItems,
|
|
21
|
+
* reset,
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
import * as React from "react";
|
|
26
|
+
import type { FileUploadItem } from "../types/fileUpload";
|
|
27
|
+
|
|
28
|
+
interface UseFileUploadDialogOptions {
|
|
29
|
+
fileItems: FileUploadItem[];
|
|
30
|
+
reset: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface UseFileUploadDialogReturn {
|
|
34
|
+
dialogOpen: boolean;
|
|
35
|
+
uploadedFileNames: string[];
|
|
36
|
+
handleOpenChange: (open: boolean) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function useFileUploadDialog({
|
|
40
|
+
fileItems,
|
|
41
|
+
reset,
|
|
42
|
+
}: UseFileUploadDialogOptions): UseFileUploadDialogReturn {
|
|
43
|
+
const [dialogOpen, setDialogOpen] = React.useState(false);
|
|
44
|
+
const [uploadedFileNames, setUploadedFileNames] = React.useState<string[]>([]);
|
|
45
|
+
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (fileItems.length > 0) {
|
|
48
|
+
setDialogOpen(true);
|
|
49
|
+
setUploadedFileNames([]);
|
|
50
|
+
}
|
|
51
|
+
}, [fileItems.length]);
|
|
52
|
+
|
|
53
|
+
const handleOpenChange = React.useCallback(
|
|
54
|
+
(open: boolean) => {
|
|
55
|
+
if (!open) {
|
|
56
|
+
const successNames = fileItems
|
|
57
|
+
.filter((item) => item.state === "success")
|
|
58
|
+
.map((item) => item.file.name);
|
|
59
|
+
if (successNames.length > 0) {
|
|
60
|
+
setUploadedFileNames((prev) => [...prev, ...successNames]);
|
|
61
|
+
}
|
|
62
|
+
reset();
|
|
63
|
+
}
|
|
64
|
+
setDialogOpen(open);
|
|
65
|
+
},
|
|
66
|
+
[fileItems, reset],
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
return { dialogOpen, uploadedFileNames, handleOpenChange };
|
|
70
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feature-react-file-upload – File upload component
|
|
3
|
+
*
|
|
4
|
+
* Provides a React file upload experience with drag-and-drop, progress tracking,
|
|
5
|
+
* and Salesforce ContentVersion integration. Supports single or multiple files,
|
|
6
|
+
* optional record linking (FirstPublishLocationId), and custom accept filters.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* File upload component. Renders a drop zone for selecting files, a modal dialog
|
|
13
|
+
* showing upload progress, and a list of successfully uploaded files. Supports
|
|
14
|
+
* click-to-select and drag-and-drop.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <FileUpload
|
|
19
|
+
* accept="image/*"
|
|
20
|
+
* multiple
|
|
21
|
+
* recordId={accountId}
|
|
22
|
+
* onUploadComplete={(files) => console.log('Uploaded:', files)}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export { FileUpload } from "./components/FileUpload";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Props for the FileUpload component.
|
|
30
|
+
*
|
|
31
|
+
* @see FileUpload
|
|
32
|
+
*/
|
|
33
|
+
export type { FileUploadProps } from "./components/FileUpload";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Hook that manages file upload state and logic: config fetch, upload to URL,
|
|
37
|
+
* and ContentVersion creation. Use for custom upload UIs or with the FileUpload
|
|
38
|
+
* component. Returns fileItems, getInputProps, getDropZoneProps, and helpers
|
|
39
|
+
* for progress, cancel, and reset.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const { fileItems, getDropZoneProps, openFilePicker } = useFileUpload({
|
|
44
|
+
* accept: '.pdf',
|
|
45
|
+
* onUploadComplete: (files) => handleComplete(files),
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export { useFileUpload } from "./hooks/useFileUpload";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Options for the useFileUpload hook.
|
|
53
|
+
*
|
|
54
|
+
* @see useFileUpload
|
|
55
|
+
*/
|
|
56
|
+
export type { UseFileUploadOptions } from "./hooks/useFileUpload";
|
package/src/force-app/main/default/webapplications/feature-react-file-upload/src/pages/Home.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FileUpload } from "../components/FileUpload";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Home page for testing the file-upload feature standalone.
|
|
5
|
+
* Renders FileUpload for dialog-based file upload with progress.
|
|
6
|
+
*/
|
|
7
|
+
export default function Home() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-12 space-y-16">
|
|
10
|
+
<section>
|
|
11
|
+
<h2 className="text-2xl font-bold text-gray-900 mb-2">File Upload (Dialog + Progress)</h2>
|
|
12
|
+
<p className="text-gray-600 mb-8">
|
|
13
|
+
Choose files to open a dialog showing upload status with progress bar for each file.
|
|
14
|
+
</p>
|
|
15
|
+
<FileUpload
|
|
16
|
+
multiple
|
|
17
|
+
onUploadComplete={(files) => {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log("Uploaded files:", files);
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
</section>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RouteObject } from "react-router";
|
|
2
|
+
import AppLayout from "./appLayout";
|
|
3
|
+
import Home from "./pages/Home";
|
|
4
|
+
|
|
5
|
+
export const routes: RouteObject[] = [
|
|
6
|
+
{
|
|
7
|
+
path: "/",
|
|
8
|
+
element: <AppLayout />,
|
|
9
|
+
children: [
|
|
10
|
+
{
|
|
11
|
+
index: true,
|
|
12
|
+
element: <Home />,
|
|
13
|
+
handle: { showInNavigation: true, label: "Home" },
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
];
|
package/src/force-app/main/default/webapplications/feature-react-file-upload/src/types/fileUpload.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File upload type definitions.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type UploadState =
|
|
6
|
+
| "idle"
|
|
7
|
+
| "loading_config"
|
|
8
|
+
| "uploading"
|
|
9
|
+
| "creating_record"
|
|
10
|
+
| "success"
|
|
11
|
+
| "error"
|
|
12
|
+
| "cancelled";
|
|
13
|
+
|
|
14
|
+
export interface FileUploadItem {
|
|
15
|
+
file: File;
|
|
16
|
+
state: UploadState;
|
|
17
|
+
progress: number;
|
|
18
|
+
error?: string;
|
|
19
|
+
contentVersionId?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface UploadedFile {
|
|
23
|
+
name: string;
|
|
24
|
+
size: number;
|
|
25
|
+
contentVersionId?: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File upload utility functions.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { UploadState } from "../types/fileUpload";
|
|
6
|
+
|
|
7
|
+
/** Maximum allowed file size: 2 GB */
|
|
8
|
+
export const MAX_FILE_SIZE_BYTES = 2 * 1024 * 1024 * 1024;
|
|
9
|
+
|
|
10
|
+
export function isFileTooLarge(file: File): boolean {
|
|
11
|
+
return file.size > MAX_FILE_SIZE_BYTES;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const UPLOADING_STATES: UploadState[] = ["loading_config", "uploading", "creating_record"];
|
|
15
|
+
|
|
16
|
+
export function isUploading(state: UploadState): boolean {
|
|
17
|
+
return UPLOADING_STATES.includes(state);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function formatFileSize(bytes: number): string {
|
|
21
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
22
|
+
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
23
|
+
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
24
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getFileExtension(name: string): string {
|
|
28
|
+
const lastDot = name.lastIndexOf(".");
|
|
29
|
+
return lastDot > 0 ? name.slice(lastDot + 1).toUpperCase() : "FILE";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function formatUploadSummary(successCount: number, totalCount: number): string {
|
|
33
|
+
const noun = totalCount === 1 ? "file" : "files";
|
|
34
|
+
if (totalCount === 1) {
|
|
35
|
+
return successCount === 1 ? "1 of 1 file uploaded" : "1 file uploading";
|
|
36
|
+
}
|
|
37
|
+
return `${successCount} of ${totalCount} ${noun} uploaded`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getProgressWidth(state: UploadState, progress: number): number {
|
|
41
|
+
if (state === "success") return 100;
|
|
42
|
+
if (state === "error" || state === "cancelled") return 0;
|
|
43
|
+
return progress;
|
|
44
|
+
}
|
package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/labels.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** User-visible text and accessibility labels. */
|
|
2
|
+
export const LABELS = {
|
|
3
|
+
attach: "Attach",
|
|
4
|
+
uploadFiles: "Upload Files",
|
|
5
|
+
dropFilesHere: "Drop files here",
|
|
6
|
+
orDropFiles: "Or drop files",
|
|
7
|
+
uploadFilesDialogTitle: "Upload Files",
|
|
8
|
+
done: "Done",
|
|
9
|
+
cancelled: "Cancelled",
|
|
10
|
+
dropZone: "Upload files by clicking or dragging files here",
|
|
11
|
+
cancelUpload: (fileName: string) => `Cancel upload of ${fileName}`,
|
|
12
|
+
uploadComplete: "Upload complete",
|
|
13
|
+
uploadFailed: "Upload failed",
|
|
14
|
+
uploadStatus: "Upload status",
|
|
15
|
+
uploadedFiles: "Uploaded files",
|
|
16
|
+
uploadProgress: (fileName: string) => `Upload progress for ${fileName}`,
|
|
17
|
+
fileName: (name: string) => `File name: ${name}`,
|
|
18
|
+
fileSize: (size: string) => `File size: ${size}`,
|
|
19
|
+
fileTooLarge: (maxSize: string) => `File exceeds maximum size of ${maxSize}`,
|
|
20
|
+
doneButton: "Close dialog and finish upload",
|
|
21
|
+
} as const;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { resolve } from "path";
|
|
5
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
6
|
+
import salesforce from "@salesforce/vite-plugin-webapp-experimental";
|
|
7
|
+
|
|
8
|
+
export default defineConfig(({ mode }) => {
|
|
9
|
+
return {
|
|
10
|
+
plugins: [tailwindcss(), react(), salesforce({ debug: true })],
|
|
11
|
+
|
|
12
|
+
build: {
|
|
13
|
+
outDir: resolve(__dirname, "dist"),
|
|
14
|
+
assetsDir: "assets",
|
|
15
|
+
sourcemap: false,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
resolve: {
|
|
19
|
+
dedupe: ["react", "react-dom"],
|
|
20
|
+
alias: {
|
|
21
|
+
react: path.resolve(__dirname, "node_modules/react"),
|
|
22
|
+
"react-dom": path.resolve(__dirname, "node_modules/react-dom"),
|
|
23
|
+
"@": path.resolve(__dirname, "./src"),
|
|
24
|
+
"@api": path.resolve(__dirname, "./src/api"),
|
|
25
|
+
"@components": path.resolve(__dirname, "./src/components"),
|
|
26
|
+
"@utils": path.resolve(__dirname, "./src/utils"),
|
|
27
|
+
"@styles": path.resolve(__dirname, "./src/styles"),
|
|
28
|
+
"@assets": path.resolve(__dirname, "./src/assets"),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
test: {
|
|
33
|
+
root: resolve(__dirname),
|
|
34
|
+
environment: "jsdom",
|
|
35
|
+
include: [
|
|
36
|
+
"src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
37
|
+
"src/**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
38
|
+
],
|
|
39
|
+
testTimeout: 10000,
|
|
40
|
+
globals: true,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
});
|