@salesforce/ui-bundle-template-feature-vue-file-upload 0.0.0-stage → 13.4.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 +267 -2
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/CHANGELOG.md +5454 -0
- package/dist/README.md +83 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/eslint.config.js +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/.forceignore +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/.prettierignore +9 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/.prettierrc +11 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/README.md +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/codegen.yml +95 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/components.json +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/e2e/app.spec.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/eslint.config.js +124 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/feature-vue-file-upload.uibundle-meta.xml +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/index.html +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/package.json +72 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/playwright.config.ts +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/scripts/get-graphql-schema.mjs +71 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/App.vue +5 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/api/graphqlClient.ts +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/appLayout.vue +80 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/alerts/status-alert.vue +59 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/layouts/card-layout.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/alert/Alert.vue +21 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/alert/AlertAction.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/alert/AlertDescription.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/alert/AlertTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/alert/index.ts +25 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/avatar/Avatar.vue +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/avatar/AvatarFallback.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/avatar/AvatarImage.vue +16 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/avatar/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/button/Button.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/button/index.ts +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/Card.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/CardAction.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/CardContent.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/CardDescription.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/CardFooter.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/CardHeader.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/CardTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/card/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/checkbox/Checkbox.vue +43 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/checkbox/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/collapsible/Collapsible.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/collapsible/CollapsibleContent.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/collapsible/CollapsibleTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/collapsible/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/Dialog.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogClose.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogContent.vue +59 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogDescription.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogFooter.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogHeader.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogOverlay.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogPortal.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogTitle.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/DialogTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dialog/index.ts +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +51 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuContent.vue +47 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuItem.vue +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuPortal.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +52 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +37 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +38 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/dropdown-menu/index.ts +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/Field.vue +27 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldContent.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldDescription.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldError.vue +48 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldGroup.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldLabel.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldLegend.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldSeparator.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldSet.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/FieldTitle.vue +22 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/field/index.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/index.ts +115 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/input/Input.vue +30 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/input/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/label/Label.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/label/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/Pagination.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/PaginationContent.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/PaginationEllipsis.vue +23 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/PaginationItem.vue +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/PaginationLink.vue +31 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/PaginationNext.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/PaginationPrevious.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/pagination/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/Popover.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/PopoverAnchor.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/PopoverContent.vue +44 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/PopoverDescription.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/PopoverHeader.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/PopoverTitle.vue +14 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/PopoverTrigger.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/popover/index.ts +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/Select.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectContent.vue +65 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectGroup.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectItem.vue +41 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectLabel.vue +26 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectScrollDownButton.vue +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectScrollUpButton.vue +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectSeparator.vue +24 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectTrigger.vue +45 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/SelectValue.vue +12 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/select/index.ts +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/separator/Separator.vue +33 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/separator/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/skeleton/Skeleton.vue +15 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/skeleton/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/sonner/Sonner.vue +29 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/sonner/index.ts +3 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/spinner/Spinner.vue +17 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/spinner/index.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/composables/useAsyncData.ts +69 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/__examples__/upload-test-page-example.vue +51 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/api/fileUpload.ts +304 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/assets/symbols.svg +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUpload.vue +95 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadDialog.vue +82 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadDropZone.vue +103 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadFileItem.vue +95 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadIcons.ts +175 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/composables/useFileUpload.ts +218 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/composables/useFileUploadDialog.ts +81 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/types/fileUpload.ts +27 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/utils/fileUploadUtils.ts +59 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/utils/labels.ts +28 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/index.ts +65 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/main.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/pages/Home.vue +10 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/pages/NotFound.vue +18 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/router-utils.ts +32 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/router.ts +46 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/styles/global.css +134 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/src/test/setup.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/tsconfig.json +45 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/tsconfig.tsbuildinfo +1 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/ui-bundle.json +7 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/vite-env.d.ts +14 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/vite.config.ts +106 -0
- package/dist/force-app/main/default/uiBundles/feature-vue-file-upload/vitest-env.d.ts +2 -0
- package/dist/jest.config.js +6 -0
- package/dist/package-lock.json +12554 -0
- package/dist/package.json +46 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/gitignore-templates.json +4 -0
- package/dist/scripts/graphql-search.sh +191 -0
- package/dist/scripts/network-senders.mjs +84 -0
- package/dist/scripts/org-setup-config-schema.mjs +132 -0
- package/dist/scripts/org-setup-dev.mjs +114 -0
- package/dist/scripts/org-setup-url.mjs +108 -0
- package/dist/scripts/org-setup-utils.mjs +569 -0
- package/dist/scripts/org-setup-xml.mjs +283 -0
- package/dist/scripts/org-setup.config.json +5 -0
- package/dist/scripts/org-setup.mjs +2545 -0
- package/dist/scripts/sf-project-setup.mjs +103 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/scripts/validate-org-setup-config.mjs +38 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +53 -4
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/__inherit__appLayout.vue +12 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/__inherit__button/index.ts +21 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/components/ui/__inherit__dialog/index.ts +61 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/__examples__/upload-test-page-example.vue +51 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/api/fileUpload.ts +304 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/assets/symbols.svg +1 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUpload.vue +95 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadDialog.vue +82 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadDropZone.vue +103 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadFileItem.vue +95 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/components/FileUploadIcons.ts +175 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/composables/useFileUpload.ts +218 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/composables/useFileUploadDialog.ts +81 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/types/fileUpload.ts +27 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/utils/fileUploadUtils.ts +59 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/features/file-upload/utils/labels.ts +28 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/index.ts +65 -0
- package/src/force-app/main/default/uiBundles/feature-vue-file-upload/src/router.ts +31 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { SelectTriggerProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { computed } from 'vue';
|
|
5
|
+
import { ChevronDownIcon } from '@lucide/vue';
|
|
6
|
+
import { SelectIcon, SelectTrigger, useForwardProps } from 'reka-ui';
|
|
7
|
+
import { cn } from '@/lib/utils';
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(
|
|
10
|
+
defineProps<
|
|
11
|
+
SelectTriggerProps & {
|
|
12
|
+
class?: HTMLAttributes['class'];
|
|
13
|
+
size?: 'sm' | 'default';
|
|
14
|
+
}
|
|
15
|
+
>(),
|
|
16
|
+
{ size: 'default' }
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const delegatedProps = computed(() => {
|
|
20
|
+
const { class: _class, size: _size, ...rest } = props;
|
|
21
|
+
return rest;
|
|
22
|
+
});
|
|
23
|
+
const forwardedProps = useForwardProps(delegatedProps);
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<SelectTrigger
|
|
28
|
+
data-slot="select-trigger"
|
|
29
|
+
:data-size="size"
|
|
30
|
+
v-bind="forwardedProps"
|
|
31
|
+
:class="
|
|
32
|
+
cn(
|
|
33
|
+
`border-input data-placeholder:text-muted-foreground dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-lg border bg-transparent py-2 pr-2 pl-2.5 text-sm transition-colors select-none focus-visible:ring-3 aria-invalid:ring-3 data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-4 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,
|
|
34
|
+
props.class
|
|
35
|
+
)
|
|
36
|
+
"
|
|
37
|
+
>
|
|
38
|
+
<slot />
|
|
39
|
+
<SelectIcon as-child>
|
|
40
|
+
<ChevronDownIcon
|
|
41
|
+
class="text-muted-foreground size-4 pointer-events-none"
|
|
42
|
+
/>
|
|
43
|
+
</SelectIcon>
|
|
44
|
+
</SelectTrigger>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { SelectValueProps } from 'reka-ui';
|
|
3
|
+
import { SelectValue } from 'reka-ui';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<SelectValueProps>();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<SelectValue data-slot="select-value" v-bind="props">
|
|
10
|
+
<slot />
|
|
11
|
+
</SelectValue>
|
|
12
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Select } from './Select.vue';
|
|
2
|
+
export { default as SelectContent } from './SelectContent.vue';
|
|
3
|
+
export { default as SelectGroup } from './SelectGroup.vue';
|
|
4
|
+
export { default as SelectItem } from './SelectItem.vue';
|
|
5
|
+
export { default as SelectLabel } from './SelectLabel.vue';
|
|
6
|
+
export { default as SelectScrollDownButton } from './SelectScrollDownButton.vue';
|
|
7
|
+
export { default as SelectScrollUpButton } from './SelectScrollUpButton.vue';
|
|
8
|
+
export { default as SelectSeparator } from './SelectSeparator.vue';
|
|
9
|
+
export { default as SelectTrigger } from './SelectTrigger.vue';
|
|
10
|
+
export { default as SelectValue } from './SelectValue.vue';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { SeparatorProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { computed } from 'vue';
|
|
5
|
+
import { Separator } from 'reka-ui';
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
const props = withDefaults(
|
|
9
|
+
defineProps<SeparatorProps & { class?: HTMLAttributes['class'] }>(),
|
|
10
|
+
{
|
|
11
|
+
orientation: 'horizontal',
|
|
12
|
+
decorative: true,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const delegatedProps = computed(() => {
|
|
17
|
+
const { class: _class, ...rest } = props;
|
|
18
|
+
return rest;
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<Separator
|
|
24
|
+
data-slot="separator"
|
|
25
|
+
v-bind="delegatedProps"
|
|
26
|
+
:class="
|
|
27
|
+
cn(
|
|
28
|
+
'bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
|
|
29
|
+
props.class
|
|
30
|
+
)
|
|
31
|
+
"
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Separator } from './Separator.vue';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div
|
|
12
|
+
data-slot="skeleton"
|
|
13
|
+
:class="cn('bg-accent animate-pulse rounded-md', props.class)"
|
|
14
|
+
/>
|
|
15
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Skeleton } from './Skeleton.vue';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Toaster as Sonner } from 'vue-sonner';
|
|
3
|
+
import type { ToasterProps } from 'vue-sonner';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renders the toast container. Use with `toast()` from `vue-sonner` for
|
|
7
|
+
* messages with title, description, actions, and variants (success, error,
|
|
8
|
+
* warning).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { toast } from 'vue-sonner';
|
|
12
|
+
* toast('Event has been created', {
|
|
13
|
+
* description: 'Sunday, December 03, 2023 at 9:00 AM',
|
|
14
|
+
* action: { label: 'Undo', onClick: () => {} },
|
|
15
|
+
* });
|
|
16
|
+
* toast.success('Saved!');
|
|
17
|
+
* toast.error('Something went wrong');
|
|
18
|
+
* toast.warning('Please review');
|
|
19
|
+
*/
|
|
20
|
+
// Defaults for position/richColors; callers can still override via props.
|
|
21
|
+
const props = withDefaults(defineProps<ToasterProps>(), {
|
|
22
|
+
position: 'top-right',
|
|
23
|
+
richColors: true,
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<Sonner v-bind="props" />
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { Loader2Icon } from '@lucide/vue';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
class?: HTMLAttributes['class'];
|
|
8
|
+
}>();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<Loader2Icon
|
|
13
|
+
role="status"
|
|
14
|
+
aria-label="Loading"
|
|
15
|
+
:class="cn('size-4 animate-spin', props.class)"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Spinner } from './Spinner.vue';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Ref, WatchSource } from 'vue';
|
|
2
|
+
import { ref, shallowRef, watch } from 'vue';
|
|
3
|
+
|
|
4
|
+
/** Reactive async-data snapshot: current data, loading, and error. */
|
|
5
|
+
export interface AsyncData<T> {
|
|
6
|
+
/** Latest successful result. Kept visible during a refetch. */
|
|
7
|
+
data: Ref<T | null>;
|
|
8
|
+
/** True while a fetch for the current args is in flight. */
|
|
9
|
+
loading: Ref<boolean>;
|
|
10
|
+
/** Error message from the most recent failed fetch, else null. */
|
|
11
|
+
error: Ref<string | null>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Runs an async `fetcher` immediately and again whenever `source` changes,
|
|
16
|
+
* exposing the result as reactive refs. Stale responses (the source changed
|
|
17
|
+
* during a fetch, or the component unmounted) are dropped via a generation
|
|
18
|
+
* counter, so only the latest in-flight request can write state.
|
|
19
|
+
*
|
|
20
|
+
* The Vue analogue of the React `useAsyncData` hook and the Angular
|
|
21
|
+
* `createAsyncData` helper: the state shape (`data` / `loading` / `error`) is
|
|
22
|
+
* identical so pages port across frameworks unchanged.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam TArgs - The reactive arguments passed to the fetcher.
|
|
25
|
+
* @typeParam T - The fetched result type.
|
|
26
|
+
* @param source - Reactive source (ref, getter, or array of them) whose value
|
|
27
|
+
* is forwarded to `fetcher`. Re-runs on change.
|
|
28
|
+
* @param fetcher - Async function producing the data for the current args.
|
|
29
|
+
* @returns Reactive `{ data, loading, error }` refs.
|
|
30
|
+
*/
|
|
31
|
+
export function useAsyncData<TArgs, T>(
|
|
32
|
+
source: WatchSource<TArgs>,
|
|
33
|
+
fetcher: (args: TArgs) => Promise<T>
|
|
34
|
+
): AsyncData<T> {
|
|
35
|
+
const data = shallowRef<T | null>(null);
|
|
36
|
+
const loading = ref<boolean>(true);
|
|
37
|
+
const error = ref<string | null>(null);
|
|
38
|
+
|
|
39
|
+
let generation = 0;
|
|
40
|
+
|
|
41
|
+
const run = (args: TArgs): void => {
|
|
42
|
+
const current = ++generation;
|
|
43
|
+
loading.value = true;
|
|
44
|
+
error.value = null;
|
|
45
|
+
|
|
46
|
+
fetcher(args)
|
|
47
|
+
.then(result => {
|
|
48
|
+
if (current === generation) {
|
|
49
|
+
data.value = result;
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.catch((err: unknown) => {
|
|
53
|
+
console.error(err);
|
|
54
|
+
if (current === generation) {
|
|
55
|
+
error.value =
|
|
56
|
+
err instanceof Error ? err.message : 'An error occurred';
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.finally(() => {
|
|
60
|
+
if (current === generation) {
|
|
61
|
+
loading.value = false;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
watch(source, args => run(args), { immediate: true, deep: true });
|
|
67
|
+
|
|
68
|
+
return { data, loading, error };
|
|
69
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Upload test page for testing the file-upload feature standalone.
|
|
4
|
+
* Renders FileUpload for dialog-based file upload with progress.
|
|
5
|
+
* Demonstrates manual ContentVersion creation after file upload, linking
|
|
6
|
+
* each uploaded file to the current user.
|
|
7
|
+
*
|
|
8
|
+
* Mounted at `/upload-test` by the feature's router.ts. When copied into an app
|
|
9
|
+
* by the features CLI, register it as a child route in `src/router.ts`.
|
|
10
|
+
*/
|
|
11
|
+
import FileUpload from "../components/FileUpload.vue";
|
|
12
|
+
import { createContentVersion, getCurrentUserId } from "../api/fileUpload";
|
|
13
|
+
import type { UploadedFile } from "../types/fileUpload";
|
|
14
|
+
|
|
15
|
+
const handleUploadComplete = async (files: UploadedFile[]) => {
|
|
16
|
+
console.log("Uploaded files:", JSON.stringify(files, null, 2));
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const userId = await getCurrentUserId();
|
|
20
|
+
for (const uploadedFile of files) {
|
|
21
|
+
if (uploadedFile.contentVersionId) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
// Create a File object from the uploaded file info (for API signature)
|
|
25
|
+
const file = new File([""], uploadedFile.name);
|
|
26
|
+
const contentVersionId = await createContentVersion(file, uploadedFile.contentBodyId, userId);
|
|
27
|
+
console.log(`Created ContentVersion for ${uploadedFile.name}:`, contentVersionId);
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error("Error creating ContentVersion:", error);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<main class="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-12 space-y-16">
|
|
37
|
+
<section>
|
|
38
|
+
<h2 class="text-2xl font-bold text-gray-900 mb-2">File Upload (Dialog + Progress)</h2>
|
|
39
|
+
<p class="text-gray-600 mb-8">
|
|
40
|
+
Choose files to open a dialog showing upload status with progress bar for each file.
|
|
41
|
+
ContentVersion is created manually after upload using current user ID.
|
|
42
|
+
</p>
|
|
43
|
+
<FileUpload
|
|
44
|
+
multiple
|
|
45
|
+
accept="image/jpeg,.jpg,.jpeg,application/pdf,.pdf"
|
|
46
|
+
:max-file-size="50"
|
|
47
|
+
@upload-complete="handleUploadComplete"
|
|
48
|
+
/>
|
|
49
|
+
</section>
|
|
50
|
+
</main>
|
|
51
|
+
</template>
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* File upload API – config, upload, and ContentVersion creation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createRecord, getCurrentUser } from "@salesforce/ui-bundle/api";
|
|
11
|
+
|
|
12
|
+
import { createDataSDK } from "@salesforce/platform-sdk";
|
|
13
|
+
|
|
14
|
+
declare const __SF_API_VERSION__: string;
|
|
15
|
+
|
|
16
|
+
export interface UploadConfig {
|
|
17
|
+
token: string;
|
|
18
|
+
uploadUrl: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Get upload config (token, uploadUrl) from /connect/file/upload/config.
|
|
23
|
+
*/
|
|
24
|
+
export async function getUploadConfig(): Promise<UploadConfig> {
|
|
25
|
+
const sdk = await createDataSDK();
|
|
26
|
+
if (!sdk?.fetch) {
|
|
27
|
+
throw new Error("Failed to initialize SDK");
|
|
28
|
+
}
|
|
29
|
+
const API_VERSION = __SF_API_VERSION__ || "65.0";
|
|
30
|
+
const configRes = await sdk.fetch(`/services/data/v${API_VERSION}/connect/file/upload/config`, {
|
|
31
|
+
method: "GET",
|
|
32
|
+
});
|
|
33
|
+
if (!configRes.ok) {
|
|
34
|
+
throw new Error(`Failed to get upload config: ${configRes.status} ${configRes.statusText}`);
|
|
35
|
+
}
|
|
36
|
+
const config = (await configRes.json()) as UploadConfig;
|
|
37
|
+
const { token, uploadUrl } = config;
|
|
38
|
+
if (!token || !uploadUrl) {
|
|
39
|
+
throw new Error("Invalid upload config: missing token or uploadUrl");
|
|
40
|
+
}
|
|
41
|
+
return { token, uploadUrl };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Upload file via XHR
|
|
46
|
+
* @param signal - Optional AbortSignal to cancel the upload
|
|
47
|
+
*/
|
|
48
|
+
export function uploadToUrl(
|
|
49
|
+
file: File,
|
|
50
|
+
token: string,
|
|
51
|
+
uploadUrl: string,
|
|
52
|
+
onProgress: (percent: number) => void,
|
|
53
|
+
signal?: AbortSignal,
|
|
54
|
+
): Promise<string> {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
const xhr = new XMLHttpRequest();
|
|
57
|
+
const formData = new FormData();
|
|
58
|
+
formData.append("token", token);
|
|
59
|
+
formData.append("fromUITier", "true");
|
|
60
|
+
formData.append("target", "ContentVersion");
|
|
61
|
+
formData.append("origin", "LWC");
|
|
62
|
+
formData.append("file", file, file.name);
|
|
63
|
+
|
|
64
|
+
xhr.upload.addEventListener("progress", (e) => {
|
|
65
|
+
if (e.lengthComputable) {
|
|
66
|
+
onProgress(Math.round((e.loaded / e.total) * 100));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
xhr.addEventListener("load", () => {
|
|
71
|
+
if (xhr.status < 200 || xhr.status >= 300) {
|
|
72
|
+
reject(new Error(`Upload failed: ${xhr.status} ${xhr.statusText}`));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const data = parseJsonResponse(xhr.responseText);
|
|
77
|
+
const id =
|
|
78
|
+
(data.content_body_id as string | undefined) ??
|
|
79
|
+
(data.contentBodyId as string | undefined);
|
|
80
|
+
if (!id) {
|
|
81
|
+
reject(new Error("Response missing content_body_id"));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
resolve(id);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
xhr.addEventListener("error", () => reject(new Error("Network error during upload")));
|
|
91
|
+
xhr.addEventListener("abort", () => reject(new Error("Upload aborted")));
|
|
92
|
+
|
|
93
|
+
if (signal) {
|
|
94
|
+
signal.addEventListener("abort", () => {
|
|
95
|
+
xhr.abort();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
xhr.open("POST", uploadUrl);
|
|
100
|
+
xhr.send(formData);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Strip "while(1);" or similar JSON prefix from LWC-style responses.
|
|
106
|
+
*/
|
|
107
|
+
function parseJsonResponse(text: string): Record<string, unknown> {
|
|
108
|
+
const trimmed = text.trim();
|
|
109
|
+
const prefix = "while(1);";
|
|
110
|
+
const jsonStr = trimmed.startsWith(prefix) ? trimmed.slice(prefix.length).trim() : trimmed;
|
|
111
|
+
return JSON.parse(jsonStr) as Record<string, unknown>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Create ContentVersion record via ui-api createRecord.
|
|
116
|
+
*/
|
|
117
|
+
export async function createContentVersion(
|
|
118
|
+
file: File,
|
|
119
|
+
contentBodyId: string,
|
|
120
|
+
recordId: string,
|
|
121
|
+
): Promise<string | undefined> {
|
|
122
|
+
const fields = {
|
|
123
|
+
FirstPublishLocationId: recordId,
|
|
124
|
+
Title: fileNameWithoutExtension(file.name),
|
|
125
|
+
PathOnClient: file.name,
|
|
126
|
+
ContentBodyId: contentBodyId,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const response = await createRecord("ContentVersion", fields);
|
|
130
|
+
const id = (response as { id?: string }).id ?? response.fields?.Id?.value;
|
|
131
|
+
return id;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get file name without extension.
|
|
136
|
+
*/
|
|
137
|
+
function fileNameWithoutExtension(name: string): string {
|
|
138
|
+
const lastDot = name.lastIndexOf(".");
|
|
139
|
+
return lastDot > 0 ? name.slice(0, lastDot) : name;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get current user Id (for FirstPublishLocationId).
|
|
144
|
+
*/
|
|
145
|
+
export async function getCurrentUserId(): Promise<string> {
|
|
146
|
+
const user = await getCurrentUser();
|
|
147
|
+
if (!user?.id) {
|
|
148
|
+
throw new Error("Current user not found");
|
|
149
|
+
}
|
|
150
|
+
return user.id;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Upload status for a single file
|
|
155
|
+
*/
|
|
156
|
+
export type UploadStatus = "pending" | "uploading" | "processing" | "success" | "error";
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Progress callback for file upload
|
|
160
|
+
*/
|
|
161
|
+
export interface FileUploadProgress {
|
|
162
|
+
fileName: string;
|
|
163
|
+
status: UploadStatus;
|
|
164
|
+
progress: number; // 0-100 for uploading, 0 for other states
|
|
165
|
+
error?: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Result of a file upload
|
|
170
|
+
*/
|
|
171
|
+
export interface FileUploadResult {
|
|
172
|
+
fileName: string;
|
|
173
|
+
size: number;
|
|
174
|
+
contentBodyId: string;
|
|
175
|
+
contentVersionId?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Options for the upload API
|
|
180
|
+
*/
|
|
181
|
+
export interface UploadOptions {
|
|
182
|
+
/** Files to upload */
|
|
183
|
+
files: File[];
|
|
184
|
+
/** Record ID to link files to (FirstPublishLocationId). If null/undefined, ContentVersion is not created. */
|
|
185
|
+
recordId?: string | null;
|
|
186
|
+
/** Callback for upload progress of each file */
|
|
187
|
+
onProgress?: (progress: FileUploadProgress) => void;
|
|
188
|
+
/** Optional abort signal to cancel all uploads */
|
|
189
|
+
signal?: AbortSignal;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Unified upload API that combines all steps:
|
|
194
|
+
* 1. Get upload config (once for all files)
|
|
195
|
+
* 2. Upload each file with progress tracking
|
|
196
|
+
* 3. Create ContentVersion (if recordId is provided)
|
|
197
|
+
*
|
|
198
|
+
* Returns array of upload results with file info and IDs.
|
|
199
|
+
* Calls onProgress for each file as it progresses through stages.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const results = await upload({
|
|
204
|
+
* files: [file1, file2],
|
|
205
|
+
* recordId: accountId,
|
|
206
|
+
* onProgress: (progress) => {
|
|
207
|
+
* console.log(`${progress.fileName}: ${progress.status} ${progress.progress}%`);
|
|
208
|
+
* }
|
|
209
|
+
* });
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export async function upload(options: UploadOptions): Promise<FileUploadResult[]> {
|
|
213
|
+
const { files, recordId, onProgress, signal } = options;
|
|
214
|
+
|
|
215
|
+
if (!files || files.length === 0) {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Get upload config once for all files
|
|
220
|
+
const config = await getUploadConfig();
|
|
221
|
+
|
|
222
|
+
const results: FileUploadResult[] = [];
|
|
223
|
+
|
|
224
|
+
// Upload each file sequentially (can be made parallel if needed)
|
|
225
|
+
for (const file of files) {
|
|
226
|
+
try {
|
|
227
|
+
// Update status: pending
|
|
228
|
+
onProgress?.({
|
|
229
|
+
fileName: file.name,
|
|
230
|
+
status: "pending",
|
|
231
|
+
progress: 0,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Update status: uploading
|
|
235
|
+
onProgress?.({
|
|
236
|
+
fileName: file.name,
|
|
237
|
+
status: "uploading",
|
|
238
|
+
progress: 0,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Upload file with progress tracking
|
|
242
|
+
const contentBodyId = await uploadToUrl(
|
|
243
|
+
file,
|
|
244
|
+
config.token,
|
|
245
|
+
config.uploadUrl,
|
|
246
|
+
(percent) => {
|
|
247
|
+
onProgress?.({
|
|
248
|
+
fileName: file.name,
|
|
249
|
+
status: "uploading",
|
|
250
|
+
progress: percent,
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
signal,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
// Create ContentVersion if recordId is provided
|
|
257
|
+
let contentVersionId: string | undefined;
|
|
258
|
+
if (recordId) {
|
|
259
|
+
// Update status: processing (creating ContentVersion)
|
|
260
|
+
onProgress?.({
|
|
261
|
+
fileName: file.name,
|
|
262
|
+
status: "processing",
|
|
263
|
+
progress: 0,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
contentVersionId = await createContentVersion(file, contentBodyId, recordId);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Update status: success
|
|
270
|
+
onProgress?.({
|
|
271
|
+
fileName: file.name,
|
|
272
|
+
status: "success",
|
|
273
|
+
progress: 100,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
results.push({
|
|
277
|
+
fileName: file.name,
|
|
278
|
+
size: file.size,
|
|
279
|
+
contentBodyId,
|
|
280
|
+
contentVersionId,
|
|
281
|
+
});
|
|
282
|
+
} catch (error) {
|
|
283
|
+
// Update status: error
|
|
284
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
285
|
+
onProgress?.({
|
|
286
|
+
fileName: file.name,
|
|
287
|
+
status: "error",
|
|
288
|
+
progress: 0,
|
|
289
|
+
error: errorMessage,
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
// Optionally continue with other files or rethrow
|
|
293
|
+
// For now, we'll continue with remaining files
|
|
294
|
+
results.push({
|
|
295
|
+
fileName: file.name,
|
|
296
|
+
size: file.size,
|
|
297
|
+
contentBodyId: "",
|
|
298
|
+
contentVersionId: undefined,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return results;
|
|
304
|
+
}
|