@@ -10,6 +10,7 @@ An interactive image zoom and pan component for Filament PHP. This package provi
1010** Features:**
1111- 🔍 Mouse wheel zooming
1212- 🖱️ Click and drag panning
13+ - 🖱️ Double-click zoom in/out
1314- 📱 Touch support for mobile devices
1415- ⚡ Smooth transitions and animations
1516- 🎯 Zoom in/out buttons
@@ -68,9 +69,67 @@ php artisan vendor:publish --tag="filament-panzoom-config"
6869
6970## Usage
7071
72+ ### Filament Version Compatibility
73+
74+ This package supports both ** Filament 3.0+** and ** Filament 4.0+** with automatic compatibility detection.
75+
76+ #### Filament 3.0+ (Legacy)
77+ ``` php
78+ // Forms, Actions & Tables
79+ use SolutionForest\FilamentPanzoom\Components\PanZoom;
80+
81+ public static function form(Form $form): Form
82+ {
83+ return $form->schema([
84+ PanZoom::make('image_preview')
85+ ->imageUrl(fn ($record) => $record?->image_url)
86+ ->label('Image Preview')
87+ ->columnSpanFull(),
88+ ]);
89+ }
90+
91+ // Infolists
92+ use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
93+
94+ public function infolist(Infolist $infolist): Infolist
95+ {
96+ return $infolist->schema([
97+ PanZoomEntry::make('image_preview')
98+ ->imageUrl(fn ($record) => $record?->image_url)
99+ ->label('Image Preview'),
100+ ]);
101+ }
102+ ```
103+
104+ #### Filament 4.0+ (Current)
105+ ``` php
106+ // Forms - Uses Schemas
107+ use SolutionForest\FilamentPanzoom\Components\PanZoom;
108+
109+ public static function configure(Schema $schema): Schema
110+ {
111+ return $schema->components([
112+ PanZoom::make('image_preview')
113+ ->imageUrl(fn ($record) => $record?->image_url),
114+ // Note: label() and columnSpanFull() methods not available in 4.0+
115+ ]);
116+ }
117+
118+ // Infolists - Uses Schemas
119+ use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
120+
121+ public static function configure(Schema $schema): Schema
122+ {
123+ return $schema->components([
124+ PanZoomEntry::make('image_preview')
125+ ->imageUrl(fn ($record) => $record?->image_url),
126+ ]);
127+ }
128+ ```
129+
71130### In Blade Views
72131
73- You can use the component directly in any Blade view:
132+ You can use the component directly in any Blade view (works in both 3.0+ and 4.0+) :
74133
75134``` blade
76135@include('filament-panzoom::filament-panzoom', [
@@ -79,41 +138,43 @@ You can use the component directly in any Blade view:
79138])
80139```
81140
82- ### Usage
141+ ### Component Selection Guide
83142
84143** ⚠️ Important: Choose the correct component for your context!**
85144
86- Filament requires different component base classes for different contexts:
87-
88- ** For Forms, Actions & Tables:**
89- ``` php
90- use SolutionForest\FilamentPanzoom\Components\PanZoom;
91-
92- PanZoom::make('image_viewer')
93- ->imageUrl(fn ($record) => $record?->image_url)
94- ->columnSpanFull(),
95- ```
145+ | Context | Component | Import |
146+ | ---------| -----------| --------|
147+ | Forms (3.0+) | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
148+ | Forms (4.0+) | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
149+ | Actions | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
150+ | Tables | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
151+ | Infolists (3.0+) | ` PanZoomEntry ` | ` use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; ` |
152+ | Infolists (4.0+) | ` PanZoomEntry ` | ` use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; ` |
96153
97- ** For Infolists:**
98- ``` php
99- use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
154+ > ** Why two components?** Filament has separate component hierarchies for Forms and Infolists. Using the wrong one will cause a TypeError.
100155
101- PanZoomEntry::make('image_viewer')
102- ->imageUrl(fn ($record) => $record?->image_url)
103- ->imageId(fn ($record) => 'receipt-' . $record->id),
104- ```
156+ ### Key Differences: Filament 3.0+ vs 4.0+
105157
106- > ** Why two components?** Filament has separate component hierarchies for Forms (` Filament\Forms\Components\Component ` ) and Infolists (` Filament\Infolists\Components\Component ` ). Using the wrong one will cause a TypeError.
158+ | Feature | Filament 3.0+ | Filament 4.0+ |
159+ | ---------| ---------------| ---------------|
160+ | ** Forms Structure** | ` form(Form $form): Form ` | ` configure(Schema $schema): Schema ` |
161+ | ** Infolists Structure** | ` infolist(Infolist $infolist): Infolist ` | ` configure(Schema $schema): Schema ` |
162+ | ** Available Methods** | ` label() ` , ` columnSpanFull() ` , etc. | Limited methods (Schemas-based) |
163+ | ** Component Base** | ` Filament\Forms\Components\Component ` | ` Filament\Schemas\Components\Component ` |
164+ | ** Auto-detection** | ✅ Yes | ✅ Yes |
107165
108166### Usage Examples
109167
168+ #### Filament 3.0+ Examples
169+
110170** In Forms:**
111171``` php
112172public static function form(Form $form): Form
113173{
114174 return $form->schema([
115175 PanZoom::make('image_preview')
116176 ->imageUrl(fn ($record) => $record?->image_url)
177+ ->label('Image Preview')
117178 ->columnSpanFull(),
118179 ]);
119180}
@@ -128,6 +189,7 @@ public function infolist(Infolist $infolist): Infolist
128189 return $infolist->schema([
129190 PanZoomEntry::make('receipt_image')
130191 ->imageUrl(fn ($record) => asset('storage/' . $record->image_path))
192+ ->label('Receipt Image')
131193 ->imageId(fn ($record) => 'receipt-' . $record->id),
132194 ]);
133195}
@@ -141,7 +203,8 @@ public static function table(Table $table): Table
141203 Action::make('viewImage')
142204 ->form([
143205 PanZoom::make('image_viewer')
144- ->imageUrl(fn ($record) => $record->image_url),
206+ ->imageUrl(fn ($record) => $record->image_url)
207+ ->label('Image Viewer'),
145208 ])
146209 ]);
147210}
@@ -154,11 +217,66 @@ protected function getFormSchema(): array
154217 return [
155218 PanZoom::make('document_viewer')
156219 ->imageUrl($this->imageUrl)
220+ ->label('Document Viewer')
157221 ->columnSpanFull(),
158222 ];
159223}
160224```
161225
226+ #### Filament 4.0+ Examples
227+
228+ ** In Forms (Schemas):**
229+ ``` php
230+ public static function configure(Schema $schema): Schema
231+ {
232+ return $schema->components([
233+ PanZoom::make('image_preview')
234+ ->imageUrl(fn ($record) => $record?->image_url),
235+ // Note: label() and columnSpanFull() methods not available in 4.0+
236+ ]);
237+ }
238+ ```
239+
240+ ** In Infolists (Schemas):**
241+ ``` php
242+ use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
243+
244+ public static function configure(Schema $schema): Schema
245+ {
246+ return $schema->components([
247+ PanZoomEntry::make('receipt_image')
248+ ->imageUrl(fn ($record) => asset('storage/' . $record->image_path))
249+ ->imageId(fn ($record) => 'receipt-' . $record->id),
250+ ]);
251+ }
252+ ```
253+
254+ ** In Table Actions:**
255+ ``` php
256+ public static function table(Table $table): Table
257+ {
258+ return $table->actions([
259+ Action::make('viewImage')
260+ ->form([
261+ PanZoom::make('image_viewer')
262+ ->imageUrl(fn ($record) => $record->image_url),
263+ ])
264+ ]);
265+ }
266+ ```
267+
268+ ** In Custom Pages:**
269+ ``` php
270+ protected function getFormSchema(): array
271+ {
272+ return [
273+ PanZoom::make('document_viewer')
274+ ->imageUrl($this->imageUrl),
275+ // Note: columnSpanFull() method not available in 4.0+
276+ ];
277+ }
278+ ```
279+
162280## Component Properties
163281
164282The component accepts the following properties:
@@ -168,10 +286,15 @@ The component accepts the following properties:
168286| ` imageUrl ` | string | Yes | The URL of the image to display |
169287| ` imageId ` | string | Yes | Unique identifier for the component instance |
170288
289+ ## Quick Tips
290+
291+ 💡 ** Pro Tip** : Double-click anywhere on the image to quickly toggle between fit-to-container view and 2x zoom for detailed inspection!
292+
171293## Features
172294
173295### Zoom Controls
174296- ** Mouse Wheel** : Scroll to zoom in/out
297+ - ** Double-Click** : Double-click to toggle between fit-to-container and 2x zoom
175298- ** Zoom Buttons** : Click the + and - buttons in the control panel
176299- ** Zoom Range** : 0.5x to 5x magnification
177300
@@ -212,14 +335,35 @@ The component uses Tailwind CSS classes and is designed to work seamlessly with
212335** Fatal Error: Class was composed with trait conflicts**
213336- ✅ Fixed in v1.2.1+ - update your package
214337
338+ ** Method not found: label() or columnSpanFull() in Filament 4.0+**
339+ - ❌ These methods aren't available in Filament 4.0+ Schemas
340+ - ✅ Remove these method calls or use Filament 3.0+ syntax
341+
342+ ** Undefined type 'Filament\Schemas\Components\Component'**
343+ - ❌ Linter error in Filament 3.0+ environment
344+ - ✅ This is expected - the package uses runtime detection for compatibility
345+
346+ ### Version-Specific Issues
347+
348+ #### Filament 3.0+
349+ - ✅ All methods available (` label() ` , ` columnSpanFull() ` , etc.)
350+ - ✅ Traditional Forms/Infolists structure
351+
352+ #### Filament 4.0+
353+ - ⚠️ Limited methods available (Schemas-based)
354+ - ⚠️ Different structure (` configure(Schema $schema) ` )
355+ - ✅ Automatic compatibility detection
356+
215357### Quick Reference
216358
217359| Context | Component | Import |
218360| ---------| -----------| --------|
219- | Forms | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
361+ | Forms (3.0+) | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
362+ | Forms (4.0+) | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
220363| Actions | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
221364| Tables | ` PanZoom ` | ` use SolutionForest\FilamentPanzoom\Components\PanZoom; ` |
222- | Infolists | ` PanZoomEntry ` | ` use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; ` |
365+ | Infolists (3.0+) | ` PanZoomEntry ` | ` use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; ` |
366+ | Infolists (4.0+) | ` PanZoomEntry ` | ` use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry; ` |
223367
224368## Browser Support
225369
0 commit comments