Component Hierarchy
The File Uploader uses a hierarchical component system with three main layers:Base: LitBlock
All components extend fromLitBlock, which provides core functionality:
From src/lit/LitBlock.ts:35-52:
- State management via reactive context
- Localization support (l10n)
- Shared instance management
- Debug utilities
- Accessibility features
Uploader Block
LitUploaderBlock extends LitActivityBlock and adds upload-specific functionality:
From src/lit/LitUploaderBlock.ts:24-35:
- Upload collection management
- File validation
- Upload queue control
- Event emission
- API access
Solution Block
LitSolutionBlock is the top-level container for complete solutions:
From src/lit/LitSolutionBlock.ts:7-21:
- Complete uploader experience
- Pre-configured component composition
- Theme support
- Clipboard integration
Core Components
Config Component
Manages all configuration options and propagates changes:UploadCtxProvider
Provides shared context for upload operations:Modal Component
Containers for activities that appear in modal dialogs:Upload Sources
Components for different file upload sources:DropArea
Drag-and-drop zone for local files
CameraSource
Camera/webcam capture interface
UrlSource
Upload files from URLs
ExternalSource
External services (Dropbox, Google Drive, etc.)
UploadList Component
Displays and manages uploaded files:SourceList Component
Displays available upload sources as buttons:Component Registration
Components are automatically registered as custom elements using a naming convention: Fromsrc/abstract/defineComponents.ts:3-26:
FileUploaderRegular→uc-file-uploader-regularUploadList→uc-upload-listCameraSource→uc-camera-source
State Management
Components use a reactive state system based onTypedData:
From src/abstract/TypedData.ts:7-30:
Subscribing to State Changes
Components can subscribe to state changes:Publishing State Changes
Components can publish state changes:Shared Instances
Certain functionality is shared across all components in a context:- Event Emitter
- Upload Collection
- Modal Manager
- Validation Manager
Handles all uploader events:
Building Custom Components
You can create custom components by extending the base classes:Custom Block
Custom Solution
Component Communication
Components communicate through several mechanisms:1. Shared State
All components in a context share reactive state:2. Events
Components emit events through the event emitter:3. Public API
The public API provides methods for programmatic control:Component Lifecycle
Lifecycle Hooks
Best Practices
Use shared context
Use shared context
Clean up subscriptions
Clean up subscriptions
Unsubscribe from state changes in
disconnectedCallback to prevent memory leaks.Leverage composition
Leverage composition
Build complex UIs by composing simple components rather than creating monolithic components.
Follow naming conventions
Follow naming conventions
Use the
uc- prefix for custom components to maintain consistency.Next Steps
Configuration System
Learn about configuration options
Solutions Overview
Explore pre-built solutions