@salesforce/webapp-template-feature-react-file-upload-experimental 1.61.2 → 1.61.4
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/dist/.a4drules/{graphql.md → features/feature-graphql-graphql-data-access-rule.md} +127 -117
- package/dist/.a4drules/features/feature-react-agentforce-conversation-client-embedded-agent-rule.md +32 -0
- package/dist/.a4drules/features/feature-react-chart-analytics-charts-rule.md +27 -0
- package/dist/.a4drules/skills/feature-graphql-graphql-data-access/SKILL.md +155 -0
- package/dist/.a4drules/{graphql/tools/knowledge/lds-explore-graphql-schema.md → skills/feature-graphql-graphql-data-access/docs/explore-schema.md} +58 -29
- package/dist/.a4drules/{graphql/tools/knowledge/lds-generate-graphql-mutationquery.md → skills/feature-graphql-graphql-data-access/docs/generate-mutation-query.md} +52 -42
- package/dist/.a4drules/{graphql/tools/knowledge/lds-generate-graphql-readquery.md → skills/feature-graphql-graphql-data-access/docs/generate-read-query.md} +32 -22
- package/dist/.a4drules/{graphql/tools/schemas/shared.graphqls → skills/feature-graphql-graphql-data-access/docs/shared-schema.graphqls} +1 -1
- package/dist/.a4drules/skills/feature-micro-frontend-micro-frontend/SKILL.md +137 -0
- package/dist/.a4drules/skills/feature-react-agentforce-conversation-client-embedded-agent/SKILL.md +108 -0
- package/dist/.a4drules/skills/feature-react-agentforce-conversation-client-embedded-agent/docs/embed-examples.md +182 -0
- package/dist/.a4drules/skills/feature-react-chart-analytics-charts/SKILL.md +41 -0
- package/dist/.a4drules/skills/feature-react-chart-analytics-charts/docs/schema-mapping.md +4 -0
- package/dist/.a4drules/webapp-code-quality.md +136 -0
- package/dist/.a4drules/{images.md → webapp-images.md} +6 -4
- package/dist/.a4drules/webapp-no-node-e.md +3 -2
- package/dist/.a4drules/webapp-react.md +149 -0
- package/dist/.a4drules/{typescript.md → webapp-typescript.md} +9 -17
- package/dist/.a4drules/webapp.md +62 -45
- package/dist/CHANGELOG.md +16 -0
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/package-lock.json +18 -18
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/vite.config.ts +1 -2
- package/dist/package.json +1 -1
- package/package.json +5 -14
- package/dist/.a4drules/README.md +0 -35
- package/dist/.a4drules/a4d-webapp-generate.md +0 -27
- package/dist/.a4drules/build-validation.md +0 -78
- package/dist/.a4drules/code-quality.md +0 -136
- package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +0 -205
- package/dist/.a4drules/react.md +0 -388
- package/dist/.a4drules/react_image_processing.md +0 -45
- package/dist/.a4drules/ui-layout.md +0 -23
- package/dist/.a4drules/webapp-nav-and-placeholders.md +0 -33
- package/dist/.a4drules/webapp-ui-first.md +0 -32
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/build/vite.config.d.ts +0 -2
- package/dist/force-app/main/default/webapplications/feature-react-file-upload/build/vite.config.js +0 -93
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/api/fileUpload.ts +0 -146
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/appLayout.tsx +0 -9
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/icon-image-close.svg +0 -3
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/image.svg +0 -3
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/success.svg +0 -3
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/assets/symbols.svg +0 -1
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUpload.tsx +0 -100
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDialog.tsx +0 -79
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadDropZone.tsx +0 -90
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadFileItem.tsx +0 -99
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/FileUploadIcons.tsx +0 -90
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/__inherit__button.tsx +0 -39
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/components/ui/__inherit__dialog.tsx +0 -102
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUpload.ts +0 -312
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/hooks/useFileUploadDialog.ts +0 -70
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/index.ts +0 -74
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/pages/UploadTest.tsx +0 -56
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/routes.tsx +0 -22
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/types/fileUpload.ts +0 -28
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/fileUploadUtils.ts +0 -54
- package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/labels.ts +0 -23
- package/src/force-app/main/default/webapplications/feature-react-file-upload/vite.config.ts +0 -44
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { FileUpload } from "../components/FileUpload";
|
|
2
|
-
import { createContentVersion, getCurrentUserId } from "../api/fileUpload";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Upload test page for testing the file-upload feature standalone.
|
|
6
|
-
* Renders FileUpload for dialog-based file upload with progress.
|
|
7
|
-
* Demonstrates manual ContentVersion creation after file upload.
|
|
8
|
-
*/
|
|
9
|
-
export default function UploadTest() {
|
|
10
|
-
const handleUploadComplete = async (
|
|
11
|
-
files: { name: string; size: number; contentBodyId: string; contentVersionId?: string }[],
|
|
12
|
-
) => {
|
|
13
|
-
// eslint-disable-next-line no-console
|
|
14
|
-
console.log("Uploaded files:", JSON.stringify(files, null, 2));
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
for (const uploadedFile of files) {
|
|
18
|
-
if (uploadedFile.contentVersionId) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const userId = await getCurrentUserId();
|
|
22
|
-
// Create a File object from the uploaded file info (for API signature)
|
|
23
|
-
const file = new File([""], uploadedFile.name);
|
|
24
|
-
const contentVersionId = await createContentVersion(
|
|
25
|
-
file,
|
|
26
|
-
uploadedFile.contentBodyId,
|
|
27
|
-
userId,
|
|
28
|
-
);
|
|
29
|
-
// eslint-disable-next-line no-console
|
|
30
|
-
console.log(`Created ContentVersion for ${uploadedFile.name}:`, contentVersionId);
|
|
31
|
-
}
|
|
32
|
-
} catch (error) {
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.error("Error creating ContentVersion:", error);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div className="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-12 space-y-16">
|
|
40
|
-
<section>
|
|
41
|
-
<h2 className="text-2xl font-bold text-gray-900 mb-2">File Upload (Dialog + Progress)</h2>
|
|
42
|
-
<p className="text-gray-600 mb-8">
|
|
43
|
-
Choose files to open a dialog showing upload status with progress bar for each file.
|
|
44
|
-
ContentVersion is created manually after upload using current user ID.
|
|
45
|
-
</p>
|
|
46
|
-
<FileUpload
|
|
47
|
-
multiple
|
|
48
|
-
recordId="500SG00001Bbi1dYAB"
|
|
49
|
-
accept="image/jpeg,.jpg,.jpeg,application/pdf,.pdf"
|
|
50
|
-
maxFileSize={50}
|
|
51
|
-
onUploadComplete={handleUploadComplete}
|
|
52
|
-
/>
|
|
53
|
-
</section>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { RouteObject } from "react-router";
|
|
2
|
-
import { Navigate } from "react-router";
|
|
3
|
-
import AppLayout from "./appLayout";
|
|
4
|
-
import UploadTest from "./pages/UploadTest";
|
|
5
|
-
|
|
6
|
-
export const routes: RouteObject[] = [
|
|
7
|
-
{
|
|
8
|
-
path: "/",
|
|
9
|
-
element: <AppLayout />,
|
|
10
|
-
children: [
|
|
11
|
-
{
|
|
12
|
-
index: true,
|
|
13
|
-
element: <Navigate to="/upload-test" replace />,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
path: "upload-test",
|
|
17
|
-
element: <UploadTest />,
|
|
18
|
-
handle: { showInNavigation: true, label: "Upload Test" },
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
];
|
package/src/force-app/main/default/webapplications/feature-react-file-upload/src/types/fileUpload.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
contentBodyId?: string;
|
|
20
|
-
contentVersionId?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface UploadedFile {
|
|
24
|
-
name: string;
|
|
25
|
-
size: number;
|
|
26
|
-
contentBodyId: string;
|
|
27
|
-
contentVersionId?: string;
|
|
28
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
/** Convert megabytes to bytes */
|
|
11
|
-
export function bytesFromMB(mb: number): number {
|
|
12
|
-
return mb * 1024 * 1024;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Check if file exceeds size limit.
|
|
17
|
-
* @param file - File to check
|
|
18
|
-
* @param maxBytes - Max size in bytes. Defaults to MAX_FILE_SIZE_BYTES when omitted.
|
|
19
|
-
*/
|
|
20
|
-
export function isFileTooLarge(file: File, maxBytes: number = MAX_FILE_SIZE_BYTES): boolean {
|
|
21
|
-
return file.size > maxBytes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const UPLOADING_STATES: UploadState[] = ["loading_config", "uploading", "creating_record"];
|
|
25
|
-
|
|
26
|
-
export function isUploading(state: UploadState): boolean {
|
|
27
|
-
return UPLOADING_STATES.includes(state);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function formatFileSize(bytes: number): string {
|
|
31
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
32
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
33
|
-
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
34
|
-
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function getFileExtension(name: string): string {
|
|
38
|
-
const lastDot = name.lastIndexOf(".");
|
|
39
|
-
return lastDot > 0 ? name.slice(lastDot + 1).toUpperCase() : "FILE";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function formatUploadSummary(successCount: number, totalCount: number): string {
|
|
43
|
-
const noun = totalCount === 1 ? "file" : "files";
|
|
44
|
-
if (totalCount === 1) {
|
|
45
|
-
return successCount === 1 ? "1 of 1 file uploaded" : "1 file uploading";
|
|
46
|
-
}
|
|
47
|
-
return `${successCount} of ${totalCount} ${noun} uploaded`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function getProgressWidth(state: UploadState, progress: number): number {
|
|
51
|
-
if (state === "success") return 100;
|
|
52
|
-
if (state === "error" || state === "cancelled") return 0;
|
|
53
|
-
return progress;
|
|
54
|
-
}
|
package/src/force-app/main/default/webapplications/feature-react-file-upload/src/utils/labels.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
chooseFileOrDrop: "Choose a file or drag & drop for reference here.",
|
|
8
|
-
formatHint: "JPEG, PNG, PDF, and MP4 formats, up to 50MB",
|
|
9
|
-
uploadFilesDialogTitle: "Upload Files",
|
|
10
|
-
done: "Done",
|
|
11
|
-
cancelled: "Cancelled",
|
|
12
|
-
dropZone: "Upload files by clicking or dragging files here",
|
|
13
|
-
cancelUpload: (fileName: string) => `Cancel upload of ${fileName}`,
|
|
14
|
-
uploadComplete: "Upload complete",
|
|
15
|
-
uploadFailed: "Upload failed",
|
|
16
|
-
uploadStatus: "Upload status",
|
|
17
|
-
uploadedFiles: "Uploaded files",
|
|
18
|
-
uploadProgress: (fileName: string) => `Upload progress for ${fileName}`,
|
|
19
|
-
fileName: (name: string) => `File name: ${name}`,
|
|
20
|
-
fileSize: (size: string) => `File size: ${size}`,
|
|
21
|
-
fileTooLarge: (maxSize: string) => `File exceeds maximum size of ${maxSize}`,
|
|
22
|
-
doneButton: "Close dialog and finish upload",
|
|
23
|
-
} as const;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { PluginOption } from "vite";
|
|
2
|
-
import { defineConfig } from "vite";
|
|
3
|
-
import react from "@vitejs/plugin-react";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { resolve } from "path";
|
|
6
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
7
|
-
import salesforce from "@salesforce/vite-plugin-webapp-experimental";
|
|
8
|
-
|
|
9
|
-
export default defineConfig(({ mode }) => {
|
|
10
|
-
return {
|
|
11
|
-
plugins: [tailwindcss(), react(), salesforce({ debug: true })] as PluginOption[],
|
|
12
|
-
|
|
13
|
-
build: {
|
|
14
|
-
outDir: resolve(__dirname, "dist"),
|
|
15
|
-
assetsDir: "assets",
|
|
16
|
-
sourcemap: false,
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
resolve: {
|
|
20
|
-
dedupe: ["react", "react-dom"],
|
|
21
|
-
alias: {
|
|
22
|
-
react: path.resolve(__dirname, "node_modules/react"),
|
|
23
|
-
"react-dom": path.resolve(__dirname, "node_modules/react-dom"),
|
|
24
|
-
"@": path.resolve(__dirname, "./src"),
|
|
25
|
-
"@api": path.resolve(__dirname, "./src/api"),
|
|
26
|
-
"@components": path.resolve(__dirname, "./src/components"),
|
|
27
|
-
"@utils": path.resolve(__dirname, "./src/utils"),
|
|
28
|
-
"@styles": path.resolve(__dirname, "./src/styles"),
|
|
29
|
-
"@assets": path.resolve(__dirname, "./src/assets"),
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
test: {
|
|
34
|
-
root: resolve(__dirname),
|
|
35
|
-
environment: "jsdom",
|
|
36
|
-
include: [
|
|
37
|
-
"src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
38
|
-
"src/**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
39
|
-
],
|
|
40
|
-
testTimeout: 10000,
|
|
41
|
-
globals: true,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
});
|