defineComponents is a utility function that registers all File Uploader Web Components with the browser’s custom elements registry. This must be called before you can use any File Uploader components in your HTML.
Signature
An object containing the File Uploader component exports, typically the entire module import
Usage
Basic Usage
defineComponents, all File Uploader Web Components are registered and ready to use:
How It Works
The function automatically:- Iterates through component exports - Processes all exported components from the module
- Converts to kebab-case - Transforms component names from PascalCase to kebab-case
- Adds
uc-prefix - Ensures all components have theuc-prefix - Registers components - Calls each component’s
reg()method to register it with the custom elements registry
Name Transformation Examples
| Component Class | Registered Tag Name |
|---|---|
FileUploaderRegular | uc-file-uploader-regular |
Config | uc-config |
UploadList | uc-upload-list |
DropArea | uc-drop-area |
Excluded Components
The following base classes are automatically excluded from registration as they are not meant to be used directly:UploaderBlockActivityBlockBlockSolutionBlock
Implementation Details
Here’s the actual implementation from the source code:When to Use
You must call
defineComponents once in your application before using any File Uploader components. Typically, this is done in your main application entry point or at the top of your script.Framework-Specific Examples
Common Issues
Components Not Rendering
If your components aren’t rendering, ensure you’ve calleddefineComponents before the components are added to the DOM:
Multiple Definitions
CallingdefineComponents multiple times is generally safe, but unnecessary. The browser’s custom elements registry will handle duplicate registrations gracefully.
TypeScript Support
When using TypeScript, you may want to add type definitions for the custom elements:See Also
- Configuration - Learn how to configure the uploader
- Solutions - Available uploader solutions
- UploaderPublicApi - Programmatic API reference