├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── bin └── build.js ├── composer.json ├── config └── swiper.php ├── postcss.config.cjs ├── resources ├── css │ └── index.css ├── dist │ ├── .gitkeep │ └── filament-swiper.js ├── js │ └── index.js ├── lang │ └── en │ │ └── swiper.php └── views │ ├── .gitkeep │ ├── infolists │ └── components │ │ ├── swiper-container.blade.php │ │ ├── swiper-image-entry.blade.php │ │ └── swiper.blade.php │ └── widgets │ ├── components │ └── swiper.blade.php │ └── swiper-widget.blade.php ├── src ├── Commands │ └── FilamentSwiperCommand.php ├── Facades │ └── FilamentSwiper.php ├── FilamentSwiper.php ├── FilamentSwiperPlugin.php ├── FilamentSwiperServiceProvider.php ├── Infolists │ └── Components │ │ ├── Concerns │ │ ├── HasEffect.php │ │ ├── HasLoop.php │ │ ├── HasPagination.php │ │ ├── HasScrollbar.php │ │ └── HasSpaceBetween.php │ │ ├── Section.php │ │ ├── Swiper.php │ │ ├── SwiperContainer.php │ │ └── SwiperImageEntry.php ├── Testing │ └── TestsFilamentSwiper.php ├── Views │ └── ViewComponent.php └── Widgets │ ├── Components │ └── Swiper.php │ └── SwiperWidget.php └── stubs └── .gitkeep /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `filament-swiper` will be documented in this file. 4 | 5 | ## 3.0.4-beta - 2024-10-28 6 | 7 | ### What's Changed 8 | 9 | * Bump tsickert/discord-webhook from 5.3.0 to 5.4.0 by @dependabot in https://github.com/rupadana/filament-swiper/pull/7 10 | * Bump tsickert/discord-webhook from 5.4.0 to 5.5.0 by @dependabot in https://github.com/rupadana/filament-swiper/pull/9 11 | * Bump aglipanci/laravel-pint-action from 2.3.1 to 2.4 by @dependabot in https://github.com/rupadana/filament-swiper/pull/11 12 | * fix paginationHideOnClick by @sadegh19b in https://github.com/rupadana/filament-swiper/pull/14 13 | 14 | ### New Contributors 15 | 16 | * @sadegh19b made their first contribution in https://github.com/rupadana/filament-swiper/pull/14 17 | 18 | **Full Changelog**: https://github.com/rupadana/filament-swiper/compare/3.0.3-beta...3.0.4-beta 19 | 20 | ## 3.0.3-beta - 2024-03-16 21 | 22 | ### What's Changed 23 | 24 | * change: Support laravel 11 by @rupadana in https://github.com/rupadana/filament-swiper/pull/6 25 | 26 | ### New Contributors 27 | 28 | * @rupadana made their first contribution in https://github.com/rupadana/filament-swiper/pull/6 29 | 30 | **Full Changelog**: https://github.com/rupadana/filament-swiper/compare/3.0.2-beta...3.0.3-beta 31 | 32 | ## 3.0.2-beta - 2024-02-08 33 | 34 | **Full Changelog**: https://github.com/rupadana/filament-swiper/compare/3.0.1-beta...3.0.2-beta 35 | 36 | ## 3.0.1-beta - 2024-01-26 37 | 38 | ### What's Changed 39 | 40 | * Bump aglipanci/laravel-pint-action from 2.3.0 to 2.3.1 by @dependabot in https://github.com/rupadana/filament-swiper/pull/3 41 | 42 | ### New Contributors 43 | 44 | * @dependabot made their first contribution in https://github.com/rupadana/filament-swiper/pull/3 45 | 46 | **Full Changelog**: https://github.com/rupadana/filament-swiper/compare/3.0.0-beta...3.0.1-beta 47 | 48 | ## Add SwiperWidgets - 2023-11-06 49 | 50 | **Full Changelog**: https://github.com/rupadana/filament-swiper/compare/1.1.0-beta...3.0.0-beta 51 | 52 | ## add spatie api - 2023-11-04 53 | 54 | **Full Changelog**: https://github.com/rupadana/filament-swiper/compare/1.0.0-beta...1.1.0-beta 55 | 56 | ## 1.0.0 - 202X-XX-XX 57 | 58 | - initial release 59 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) rupadana 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Most Modern Mobile Touch Slider now on Filamentphp 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/rupadana/filament-swiper.svg?style=flat-square)](https://packagist.org/packages/rupadana/filament-swiper) 4 | [![Total Downloads](https://img.shields.io/packagist/dt/rupadana/filament-swiper.svg?style=flat-square)](https://packagist.org/packages/rupadana/filament-swiper) 5 | 6 | 7 | ![Image](https://raw.githubusercontent.com/rupadana/filament-swiper/main/docs/images/filament-swiper-image.png) 8 | 9 | This is a Swiper Component for filament, using [SwiperJS](https://swiperjs.com/). 10 | 11 | ## Installation 12 | 13 | You can install the package via composer: 14 | 15 | ```bash 16 | composer require rupadana/filament-swiper 17 | ``` 18 | 19 | 20 | ## Usage 21 | 22 | Available API 23 | 24 | ```php 25 | public function infolists(Infolists $infolists) { 26 | return $infolists 27 | ->schema([ 28 | \Rupadana\FilamentSwiper\Infolists\Components\SwiperImageEntry::make('attachment') 29 | ->navigation(false) 30 | ->pagination() 31 | ->paginationType(SwiperImageEntry::BULLETS) 32 | ->paginationClickable() 33 | ->paginationDynamicBullets() 34 | ->paginationHideOnClick() 35 | ->paginationDynamicMainBullets(2) 36 | ->scrollbar() 37 | ->scrollbarDragSize(100) 38 | ->scrollbarDraggable() 39 | ->scrollbarSnapOnRelease() 40 | ->scrollbarHide(false) 41 | ->height(300) 42 | ->autoplay() 43 | ->effect(SwiperImageEntry::CARDS_EFFECT) 44 | ->cardsPerSlideOffset(2) 45 | ->autoplayDelay(500) 46 | ->centeredSlides() 47 | ->slidesPerView(2) 48 | ]) 49 | } 50 | ``` 51 | 52 | 53 | ## Widget 54 | 55 | Create a class whatever u want. example ``App\Livewire\Widgets\Swipget`` and extends ``Rupadana\FilamentSwiper\Widgets\SwiperWidget``, 56 | 57 | ```php 58 | { 32 | console.log(`Build started at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`) 33 | }) 34 | 35 | build.onEnd((result) => { 36 | if (result.errors.length > 0) { 37 | console.log(`Build failed at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`, result.errors) 38 | } else { 39 | console.log(`Build finished at ${new Date(Date.now()).toLocaleTimeString()}: ${build.initialOptions.outfile}`) 40 | } 41 | }) 42 | } 43 | }], 44 | } 45 | 46 | compile({ 47 | ...defaultOptions, 48 | entryPoints: ['./resources/js/index.js'], 49 | outfile: './resources/dist/filament-swiper.js', 50 | }) 51 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rupadana/filament-swiper", 3 | "description": "The Most Modern Mobile Touch Slider on Filamentphp", 4 | "keywords": [ 5 | "rupadana", 6 | "laravel", 7 | "filament-swiper" 8 | ], 9 | "homepage": "https://github.com/rupadana/filament-swiper", 10 | "support": { 11 | "issues": "https://github.com/rupadana/filament-swiper/issues", 12 | "source": "https://github.com/rupadana/filament-swiper" 13 | }, 14 | "license": "MIT", 15 | "authors": [ 16 | { 17 | "name": "Rupadana", 18 | "email": "rupadanawayan@gmail.com", 19 | "role": "Developer" 20 | } 21 | ], 22 | "require": { 23 | "php": "^8.1", 24 | "filament/filament": "^3.0", 25 | "spatie/laravel-package-tools": "^1.15.0", 26 | "illuminate/contracts": "^10.0|^11.0" 27 | }, 28 | "require-dev": { 29 | "laravel/pint": "^1.0", 30 | "nunomaduro/collision": "^7.9", 31 | "nunomaduro/larastan": "^2.0.1", 32 | "orchestra/testbench": "^8.0", 33 | "pestphp/pest": "^2.0", 34 | "pestphp/pest-plugin-arch": "^2.0", 35 | "pestphp/pest-plugin-laravel": "^2.0", 36 | "phpstan/extension-installer": "^1.1", 37 | "phpstan/phpstan-deprecation-rules": "^1.0", 38 | "phpstan/phpstan-phpunit": "^1.0" 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "Rupadana\\FilamentSwiper\\": "src/", 43 | "Rupadana\\FilamentSwiper\\Database\\Factories\\": "database/factories/" 44 | } 45 | }, 46 | "autoload-dev": { 47 | "psr-4": { 48 | "Rupadana\\FilamentSwiper\\Tests\\": "tests/" 49 | } 50 | }, 51 | "scripts": { 52 | "post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi", 53 | "analyse": "vendor/bin/phpstan analyse", 54 | "test": "vendor/bin/pest", 55 | "test-coverage": "vendor/bin/pest --coverage", 56 | "format": "vendor/bin/pint" 57 | }, 58 | "config": { 59 | "sort-packages": true, 60 | "allow-plugins": { 61 | "pestphp/pest-plugin": true, 62 | "phpstan/extension-installer": true 63 | } 64 | }, 65 | "extra": { 66 | "laravel": { 67 | "providers": [ 68 | "Rupadana\\FilamentSwiper\\FilamentSwiperServiceProvider" 69 | ], 70 | "aliases": { 71 | "FilamentSwiper": "Rupadana\\FilamentSwiper\\Facades\\FilamentSwiper" 72 | } 73 | } 74 | }, 75 | "minimum-stability": "dev", 76 | "prefer-stable": true 77 | } -------------------------------------------------------------------------------- /config/swiper.php: -------------------------------------------------------------------------------- 1 | getPagination(); 13 | $navigation = $getParentComponent()->getNavigation(); 14 | $slidesPerView = $getParentComponent()->getSlidesPerView(); 15 | 16 | $paginationType = $getParentComponent()->getPaginationType(); 17 | $autoplay = $getParentComponent()->getAutoplay(); 18 | $autoplayDelay = $getParentComponent()->getAutoplayDelay(); 19 | $paginationClickable = $getParentComponent()->getPaginationClickable(); 20 | $paginationDynamicBullets = $getParentComponent()->getPaginationDynamicBullets(); 21 | $paginationDynamicMainBullets = $getParentComponent()->getPaginationDynamicMainBullets(); 22 | $paginationHideOnClick = $getParentComponent()->getPaginationHideOnClick(); 23 | 24 | $scrollbar = $getParentComponent()->getScrollbar(); 25 | $scrollbarDraggable = $getParentComponent()->getScrollbarDraggable(); 26 | $scrollbarHide = $getParentComponent()->getScrollbarHide(); 27 | $scrollbarSnapOnRelease = $getParentComponent()->getScrollbarSnapOnRelease(); 28 | $scrollbarDragSize = $getParentComponent()->getScrollbarDragSize(); 29 | 30 | $effect = $getParentComponent()->getEffect(); 31 | 32 | 33 | @endphp 34 | 35 | 86 | 87 | @foreach ($getComponents() as $infolistComponent) 88 | 89 | {{ $infolistComponent }} 90 | 91 | @endforeach 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /resources/views/infolists/components/swiper-image-entry.blade.php: -------------------------------------------------------------------------------- 1 | @php 2 | $limit = $getLimit(); 3 | $state = \Illuminate\Support\Arr::wrap($getState()); 4 | $limitedState = array_slice($state, 0, $limit); 5 | $isCircular = $isCircular(); 6 | $isSquare = $isSquare(); 7 | $isStacked = $isStacked(); 8 | $overlap = $isStacked ? $getOverlap() ?? 2 : null; 9 | $ring = $isStacked ? $getRing() ?? 2 : null; 10 | $height = $getHeight() ?? ($isStacked ? '2.5rem' : '8rem'); 11 | $width = $getWidth() ?? ($isCircular || $isSquare ? $height : null); 12 | $defaultImageUrl = $getDefaultImageUrl(); 13 | $pagination = $getPagination(); 14 | $navigation = $getNavigation(); 15 | $slidesPerView = $getSlidesPerView(); 16 | $paginationType = $getPaginationType(); 17 | $autoplay = $getAutoplay(); 18 | $autoplayDelay = $getAutoplayDelay(); 19 | $paginationClickable = $getPaginationClickable(); 20 | $paginationDynamicBullets = $getPaginationDynamicBullets(); 21 | $paginationDynamicMainBullets = $getPaginationDynamicMainBullets(); 22 | $paginationHideOnClick = $getPaginationHideOnClick(); 23 | 24 | $scrollbar = $getScrollbar(); 25 | $scrollbarDraggable = $getScrollbarDraggable(); 26 | $scrollbarHide = $getScrollbarHide(); 27 | $scrollbarSnapOnRelease = $getScrollbarSnapOnRelease(); 28 | $scrollbarDragSize = $getScrollbarDragSize(); 29 | 30 | $effect = $getEffect(); 31 | 32 | if (!count($limitedState) && filled($defaultImageUrl)) { 33 | $limitedState = [null]; 34 | } 35 | 36 | $ringClasses = \Illuminate\Support\Arr::toCssClasses([ 37 | 'ring-white dark:ring-gray-900', 38 | match ($ring) { 39 | 0 => null, 40 | 1 => 'ring-1', 41 | 2 => 'ring-2', 42 | 3 => 'ring', 43 | 4 => 'ring-4', 44 | default => $ring, 45 | }, 46 | ]); 47 | 48 | $hasLimitedRemainingText = $hasLimitedRemainingText(); 49 | $isLimitedRemainingTextSeparate = $isLimitedRemainingTextSeparate(); 50 | 51 | $limitedRemainingTextSizeClasses = match ($getLimitedRemainingTextSize()) { 52 | 'xs' => 'text-xs', 53 | 'sm', null => 'text-sm', 54 | 'base', 'md' => 'text-base', 55 | 'lg' => 'text-lg', 56 | default => $size, 57 | }; 58 | @endphp 59 | 60 | 87 |
merge($getExtraAttributes(), escape: false)->class(['fi-in-image flex items-center gap-x-2.5']) }} 88 | ax-load 89 | ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getScriptSrc('filament-swiper-scripts', 'rupadana/filament-swiper') }}"> 90 | @if (count($limitedState)) 91 | 100 | @foreach ($limitedState as $stateItem) 101 | 102 | class(['max-w-none object-cover object-center', 'rounded-full' => $isCircular, $ringClasses])->style([ 104 | "height: {$height}" => $height, 105 | "width: {$width}" => $width, 106 | ]) }} /> 107 | 108 | @endforeach 109 | 110 | @if ( 111 | $hasLimitedRemainingText && 112 | $loop->iteration < count($limitedState) && 113 | !$isLimitedRemainingTextSeparate && 114 | $isCircular) 115 |
$isCircular, 122 | $limitedRemainingTextSizeClasses, 123 | $ringClasses, 124 | ]) @style([ 125 | "height: {$height}" => $height, 126 | "width: {$width}" => $width, 127 | ])> 128 | 129 | +{{ count($state) - count($limitedState) }} 130 | 131 |
132 | @endif 133 |
134 | 135 | @if ( 136 | $hasLimitedRemainingText && 137 | $loop->iteration < count($limitedState) && 138 | ($isLimitedRemainingTextSeparate || !$isCircular)) 139 |
143 | +{{ count($state) - count($limitedState) }} 144 |
145 | @endif 146 | @elseif (($placeholder = $getPlaceholder()) !== null) 147 | 148 | {{ $placeholder }} 149 | 150 | @endif 151 |
152 | -------------------------------------------------------------------------------- /resources/views/infolists/components/swiper.blade.php: -------------------------------------------------------------------------------- 1 | 28 | 29 | 30 |
31 |

32 | {{ $getTitle() }} 33 |

34 | 35 |
merge($getExtraAttributes(), escape: false)->class(['fi-in-image flex items-center gap-x-2.5 max-w-7xl mx-auto px-6 md:px-12 xl:px-6 mt-16']) }} 36 | ax-load 37 | ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getScriptSrc('filament-swiper-scripts', 'rupadana/filament-swiper') }}"> 38 | 39 | 40 | 41 | {{ $getChildComponentContainers()['default'] }} 42 | 43 | 44 |
45 | 46 |
47 | -------------------------------------------------------------------------------- /resources/views/widgets/components/swiper.blade.php: -------------------------------------------------------------------------------- 1 | @php 2 | // $isCircular = $isCircular(); 3 | // $isSquare = $isSquare(); 4 | // $isStacked = $isStacked(); 5 | // $overlap = $isStacked ? ($getOverlap() ?? 2) : null; 6 | // $ring = $isStacked ? ($getRing() ?? 2) : null; 7 | // $height = $getHeight() ?? ($isStacked ? '2.5rem' : '8rem'); 8 | // $width = $getWidth() ?? (($isCircular || $isSquare) ? $height : null); 9 | 10 | $pagination = $getPagination(); 11 | $navigation = $getNavigation(); 12 | $slidesPerView = $getSlidesPerView(); 13 | 14 | $paginationType = $getPaginationType(); 15 | $autoplay = $getAutoplay(); 16 | $autoplayDelay = $getAutoplayDelay(); 17 | $paginationClickable = $getPaginationClickable(); 18 | $paginationDynamicBullets = $getPaginationDynamicBullets(); 19 | $paginationDynamicMainBullets = $getPaginationDynamicMainBullets(); 20 | $paginationHideOnClick = $getPaginationHideOnClick(); 21 | 22 | $scrollbar = $getScrollbar(); 23 | $scrollbarDraggable = $getScrollbarDraggable(); 24 | $scrollbarHide = $getScrollbarHide(); 25 | $scrollbarSnapOnRelease = $getScrollbarSnapOnRelease(); 26 | $scrollbarDragSize = $getScrollbarDragSize(); 27 | 28 | $effect = $getEffect(); 29 | 30 | $loop = $isLoop(); 31 | 32 | 33 | @endphp 34 | 35 | 62 | 63 | 64 |
65 |

66 | {{$getTitle()}} 67 |

68 | 69 |
merge($getExtraAttributes(), escape: false) 73 | ->class([ 74 | 'fi-in-image flex items-center gap-x-2.5 max-w-7xl mx-auto', 75 | ]) 76 | }} 77 | 78 | ax-load 79 | ax-load-src="{{\Filament\Support\Facades\FilamentAsset::getScriptSrc('filament-swiper-scripts', 80 | 'rupadana/filament-swiper')}}" 81 | > 82 | 83 | 134 | 135 | @foreach($getComponents() as $component) 136 | 137 | {{$component}} 138 | 139 | @endforeach 140 | 141 | 142 | {{-- {{ $getChildComponentContainers()['default'] }}--}} 143 | 144 | 145 |
146 | 147 |
148 | -------------------------------------------------------------------------------- /resources/views/widgets/swiper-widget.blade.php: -------------------------------------------------------------------------------- 1 | 2 | $this->isDefaultWidget(), 6 | 'grid-cols-1', 7 | ]) 8 | > 9 |
10 | {{ $this->getFinalSwiper() }} 11 |
12 |
13 | 14 | -------------------------------------------------------------------------------- /src/Commands/FilamentSwiperCommand.php: -------------------------------------------------------------------------------- 1 | comment('All done'); 16 | 17 | return self::SUCCESS; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Facades/FilamentSwiper.php: -------------------------------------------------------------------------------- 1 | getId()); 34 | 35 | return $plugin; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/FilamentSwiperServiceProvider.php: -------------------------------------------------------------------------------- 1 | name(static::$name) 31 | ->hasCommands($this->getCommands()) 32 | ->hasInstallCommand(function (InstallCommand $command) { 33 | $command 34 | ->publishConfigFile() 35 | ->askToRunMigrations() 36 | ->askToStarRepoOnGitHub('rupadana/filament-swiper'); 37 | }); 38 | 39 | $configFileName = $package->shortName(); 40 | 41 | if (file_exists($package->basePath("/../config/{$configFileName}.php"))) { 42 | $package->hasConfigFile(); 43 | } 44 | 45 | if (file_exists($package->basePath('/../resources/lang'))) { 46 | $package->hasTranslations(); 47 | } 48 | 49 | if (file_exists($package->basePath('/../resources/views'))) { 50 | $package->hasViews(static::$viewNamespace); 51 | } 52 | } 53 | 54 | public function packageRegistered(): void {} 55 | 56 | public function packageBooted(): void 57 | { 58 | // Asset Registration 59 | FilamentAsset::register( 60 | $this->getAssets(), 61 | $this->getAssetPackageName() 62 | ); 63 | 64 | FilamentAsset::registerScriptData( 65 | $this->getScriptData(), 66 | $this->getAssetPackageName() 67 | ); 68 | 69 | // Icon Registration 70 | FilamentIcon::register($this->getIcons()); 71 | 72 | // Handle Stubs 73 | if (app()->runningInConsole()) { 74 | foreach (app(Filesystem::class)->files(__DIR__ . '/../stubs/') as $file) { 75 | $this->publishes([ 76 | $file->getRealPath() => base_path("stubs/filament-swiper/{$file->getFilename()}"), 77 | ], 'filament-swiper-stubs'); 78 | } 79 | } 80 | 81 | // Testing 82 | Testable::mixin(new TestsFilamentSwiper); 83 | } 84 | 85 | protected function getAssetPackageName(): ?string 86 | { 87 | return 'rupadana/filament-swiper'; 88 | } 89 | 90 | /** 91 | * @return array 92 | */ 93 | protected function getAssets(): array 94 | { 95 | return [ 96 | Js::make('filament-swiper-scripts', __DIR__ . '/../resources/dist/filament-swiper.js'), 97 | ]; 98 | } 99 | 100 | /** 101 | * @return array 102 | */ 103 | protected function getCommands(): array 104 | { 105 | return [ 106 | FilamentSwiperCommand::class, 107 | ]; 108 | } 109 | 110 | /** 111 | * @return array 112 | */ 113 | protected function getIcons(): array 114 | { 115 | return []; 116 | } 117 | 118 | /** 119 | * @return array 120 | */ 121 | protected function getRoutes(): array 122 | { 123 | return []; 124 | } 125 | 126 | /** 127 | * @return array 128 | */ 129 | protected function getScriptData(): array 130 | { 131 | return []; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/Infolists/Components/Concerns/HasEffect.php: -------------------------------------------------------------------------------- 1 | effect; 30 | } 31 | 32 | public function effect(string $effect = Swiper::FADE_EFFECT): HasEffect 33 | { 34 | $this->effect = $effect; 35 | 36 | return $this; 37 | } 38 | 39 | public function getCoverflowEffectModifier(): int 40 | { 41 | return $this->coverflowEffectModifier; 42 | } 43 | 44 | public function coverflowEffectModifier(int $coverflowEffectModifier): HasEffect 45 | { 46 | $this->coverflowEffectModifier = $coverflowEffectModifier; 47 | 48 | return $this; 49 | } 50 | 51 | public function getCoverflowDepth(): int 52 | { 53 | return $this->coverflowDepth; 54 | } 55 | 56 | public function coverflowDepth(int $coverflowDepth): HasEffect 57 | { 58 | $this->coverflowDepth = $coverflowDepth; 59 | 60 | return $this; 61 | } 62 | 63 | public function getCoverflowSlideShadows(): bool 64 | { 65 | return $this->coverflowSlideShadows; 66 | } 67 | 68 | public function coverflowSlideShadows(bool $coverflowSlideShadows = true): HasEffect 69 | { 70 | $this->coverflowSlideShadows = $coverflowSlideShadows; 71 | 72 | return $this; 73 | } 74 | 75 | public function getCoverflowStretch(): int 76 | { 77 | return $this->coverflowStretch; 78 | } 79 | 80 | public function coverflowStretch(int $coverflowStretch): HasEffect 81 | { 82 | $this->coverflowStretch = $coverflowStretch; 83 | 84 | return $this; 85 | } 86 | 87 | public function getCardsPerSlideOffset(): int 88 | { 89 | return $this->cardsPerSlideOffset; 90 | } 91 | 92 | public function cardsPerSlideOffset(int $cardsPerSlideOffset = 8): HasEffect 93 | { 94 | $this->cardsPerSlideOffset = $cardsPerSlideOffset; 95 | 96 | return $this; 97 | } 98 | 99 | public function getCardsPerSlideRotate(): int 100 | { 101 | return $this->cardsPerSlideRotate; 102 | } 103 | 104 | public function cardsPerSlideRotate(int $cardsPerSlideRotate = 2): HasEffect 105 | { 106 | $this->cardsPerSlideRotate = $cardsPerSlideRotate; 107 | 108 | return $this; 109 | } 110 | 111 | public function getCardsRotate(): bool 112 | { 113 | return $this->cardsRotate; 114 | } 115 | 116 | public function cardsRotate(bool $cardsRotate = true): HasEffect 117 | { 118 | $this->cardsRotate = $cardsRotate; 119 | 120 | return $this; 121 | } 122 | 123 | public function getCardsSlideShadows(): bool 124 | { 125 | return $this->cardsSlideShadows; 126 | } 127 | 128 | public function cardsSlideShadows(bool $cardsSlideShadows = true): HasEffect 129 | { 130 | $this->cardsSlideShadows = $cardsSlideShadows; 131 | 132 | return $this; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/Infolists/Components/Concerns/HasLoop.php: -------------------------------------------------------------------------------- 1 | loop; 12 | } 13 | 14 | public function loop(bool $loop = true): HasLoop 15 | { 16 | $this->loop = $loop; 17 | 18 | return $this; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Infolists/Components/Concerns/HasPagination.php: -------------------------------------------------------------------------------- 1 | pagination; 24 | } 25 | 26 | public function pagination(bool $pagination = true) 27 | { 28 | $this->pagination = $pagination; 29 | 30 | return $this; 31 | } 32 | 33 | public function getPaginationType(): string 34 | { 35 | return $this->paginationType; 36 | } 37 | 38 | public function paginationType(string $type = Swiper::BULLETS) 39 | { 40 | $this->paginationType = $type; 41 | 42 | return $this; 43 | } 44 | 45 | public function getPaginationClickable(): bool 46 | { 47 | return $this->paginationClickable; 48 | } 49 | 50 | public function paginationClickable(bool $paginationClickable = true) 51 | { 52 | $this->paginationClickable = $paginationClickable; 53 | 54 | return $this; 55 | } 56 | 57 | public function getPaginationDynamicBullets(): bool 58 | { 59 | return $this->paginationDynamicBullets; 60 | } 61 | 62 | public function paginationDynamicBullets(bool $paginationDynamicBullets = true) 63 | { 64 | $this->paginationDynamicBullets = $paginationDynamicBullets; 65 | 66 | return $this; 67 | } 68 | 69 | public function getPaginationDynamicMainBullets(): int 70 | { 71 | return $this->paginationDynamicMainBullets; 72 | } 73 | 74 | public function paginationDynamicMainBullets(int $paginationDynamicMainBullets) 75 | { 76 | $this->paginationDynamicMainBullets = $paginationDynamicMainBullets; 77 | 78 | return $this; 79 | } 80 | 81 | public function getPaginationHideOnClick(): bool 82 | { 83 | return $this->paginationHideOnClick; 84 | } 85 | 86 | public function paginationHideOnClick(bool $paginationHideOnClick = true) 87 | { 88 | $this->paginationHideOnClick = $paginationHideOnClick; 89 | 90 | return $this; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/Infolists/Components/Concerns/HasScrollbar.php: -------------------------------------------------------------------------------- 1 | scrollbar; 20 | } 21 | 22 | public function scrollbar(bool $scrollbar = true): HasScrollbar 23 | { 24 | $this->scrollbar = $scrollbar; 25 | 26 | return $this; 27 | } 28 | 29 | public function getScrollbarDraggable(): bool 30 | { 31 | return $this->scrollbarDraggable; 32 | } 33 | 34 | public function scrollbarDraggable(bool $scrollbarDraggable = true): HasScrollbar 35 | { 36 | $this->scrollbarDraggable = $scrollbarDraggable; 37 | 38 | return $this; 39 | } 40 | 41 | public function getScrollbarHide(): bool 42 | { 43 | return $this->scrollbarHide; 44 | } 45 | 46 | public function scrollbarHide(bool $scrollbarHide = true): HasScrollbar 47 | { 48 | $this->scrollbarHide = $scrollbarHide; 49 | 50 | return $this; 51 | } 52 | 53 | public function getScrollbarSnapOnRelease(): bool 54 | { 55 | return $this->scrollbarSnapOnRelease; 56 | } 57 | 58 | public function scrollbarSnapOnRelease(bool $scrollbarSnapOnRelease = true): HasScrollbar 59 | { 60 | $this->scrollbarSnapOnRelease = $scrollbarSnapOnRelease; 61 | 62 | return $this; 63 | } 64 | 65 | public function getScrollbarDragSize(): int 66 | { 67 | return $this->scrollbarDragSize; 68 | } 69 | 70 | public function scrollbarDragSize(int $scrollbarDragSize): HasScrollbar 71 | { 72 | $this->scrollbarDragSize = $scrollbarDragSize; 73 | 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Infolists/Components/Concerns/HasSpaceBetween.php: -------------------------------------------------------------------------------- 1 | spaceBetween; 12 | } 13 | 14 | public function spaceBetween(int $spaceBetween): HasSpaceBetween 15 | { 16 | $this->spaceBetween = $spaceBetween; 17 | 18 | return $this; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Infolists/Components/Section.php: -------------------------------------------------------------------------------- 1 | | Htmlable | Closure | null $heading 40 | */ 41 | final public function __construct(string | array | Htmlable | Closure | null $heading = null) 42 | { 43 | is_array($heading) 44 | ? $this->childComponents($heading) 45 | : $this->heading($heading); 46 | } 47 | 48 | /** 49 | * @param string | array | Htmlable | Closure | null $heading 50 | */ 51 | public static function make(string | array | Htmlable | Closure | null $heading = null): static 52 | { 53 | $static = app(static::class, ['heading' => $heading]); 54 | $static->configure(); 55 | 56 | return $static; 57 | } 58 | 59 | protected function setUp(): void 60 | { 61 | parent::setUp(); 62 | 63 | $this->columnSpan('full'); 64 | } 65 | 66 | public function aside(bool | Closure | null $condition = true): static 67 | { 68 | $this->isAside = $condition; 69 | 70 | return $this; 71 | } 72 | 73 | public function getId(): ?string 74 | { 75 | $id = parent::getId(); 76 | 77 | if (filled($id)) { 78 | return $id; 79 | } 80 | 81 | $heading = $this->getHeading(); 82 | 83 | if (blank($heading)) { 84 | return null; 85 | } 86 | 87 | $id = Str::slug($heading); 88 | 89 | if ($statePath = $this->getStatePath()) { 90 | $id = "{$statePath}.{$id}"; 91 | } 92 | 93 | return $id; 94 | } 95 | 96 | public function getKey(): ?string 97 | { 98 | return parent::getKey() ?? ($this->getActions() ? $this->getId() : null); 99 | } 100 | 101 | public function isAside(): bool 102 | { 103 | return (bool) ($this->evaluate($this->isAside) ?? false); 104 | } 105 | 106 | public function contentBefore(bool | Closure $condition = true): static 107 | { 108 | $this->isContentBefore = $condition; 109 | 110 | return $this; 111 | } 112 | 113 | public function isContentBefore(): bool 114 | { 115 | return (bool) $this->evaluate($this->isContentBefore); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/Infolists/Components/Swiper.php: -------------------------------------------------------------------------------- 1 | title; 48 | } 49 | 50 | public function title(string $title): Swiper 51 | { 52 | $this->title = $title; 53 | 54 | return $this; 55 | } 56 | 57 | public function getNavigation(): bool 58 | { 59 | return $this->navigation; 60 | } 61 | 62 | public function navigation(bool $navigation = true) 63 | { 64 | $this->navigation = $navigation; 65 | 66 | return $this; 67 | } 68 | 69 | public function getSlidesPerView(): int 70 | { 71 | return $this->slidesPerView; 72 | } 73 | 74 | public function slidesPerView(int $slidesPerView = 3) 75 | { 76 | $this->slidesPerView = $slidesPerView; 77 | 78 | return $this; 79 | } 80 | 81 | public function getAutoplay(): bool 82 | { 83 | return $this->autoplay; 84 | } 85 | 86 | public function autoplay(bool $autoplay = true) 87 | { 88 | $this->autoplay = $autoplay; 89 | 90 | return $this; 91 | } 92 | 93 | public function getAutoplayDelay(): int 94 | { 95 | return $this->autoplayDelay; 96 | } 97 | 98 | public function autoplayDelay(int $autoplayDelay = 3000) 99 | { 100 | $this->autoplayDelay = $autoplayDelay; 101 | 102 | return $this; 103 | } 104 | 105 | public function getCenteredSlides(): bool 106 | { 107 | return $this->centeredSlides; 108 | } 109 | 110 | public function centeredSlides(bool $centeredSlides = true): Swiper 111 | { 112 | $this->centeredSlides = $centeredSlides; 113 | 114 | return $this; 115 | } 116 | 117 | public function getChildComponentContainers(bool $withHidden = false): array 118 | { 119 | if (! $this->hasChildComponentContainer($withHidden)) { 120 | return []; 121 | } 122 | 123 | return [ 124 | 'default' => SwiperContainer::make($this->getLivewire()) 125 | ->parentComponent($this) 126 | ->components($this->getChildComponents()) 127 | ->elementTag('swiper-container'), 128 | ]; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/Infolists/Components/SwiperContainer.php: -------------------------------------------------------------------------------- 1 | collection = $collection; 27 | 28 | return $this; 29 | } 30 | 31 | const PROGRESSBAR = 'progressbar'; 32 | 33 | const BULLETS = 'bullets'; 34 | 35 | const FRACTIONAL = 'fraction'; 36 | 37 | const FADE_EFFECT = 'fade'; 38 | 39 | const COVERFLOW_EFFECT = 'coverflow'; 40 | 41 | const CARDS_EFFECT = 'cards'; 42 | 43 | protected string $view = 'filament-swiper::infolists.components.swiper-image-entry'; 44 | 45 | protected bool $navigation = true; 46 | 47 | protected bool $centeredSlides = false; 48 | 49 | protected bool $autoplay = false; 50 | 51 | protected int $autoplayDelay = 3000; 52 | 53 | protected int $slidesPerView = 1; 54 | 55 | public function getNavigation(): bool 56 | { 57 | return $this->navigation; 58 | } 59 | 60 | public function navigation(bool $navigation = true) 61 | { 62 | $this->navigation = $navigation; 63 | 64 | return $this; 65 | } 66 | 67 | public function getSlidesPerView(): int 68 | { 69 | return $this->slidesPerView; 70 | } 71 | 72 | public function slidesPerView(int $slidesPerView = 3) 73 | { 74 | $this->slidesPerView = $slidesPerView; 75 | 76 | return $this; 77 | } 78 | 79 | public function getAutoplay(): bool 80 | { 81 | return $this->autoplay; 82 | } 83 | 84 | public function autoplay(bool $autoplay = true) 85 | { 86 | $this->autoplay = $autoplay; 87 | 88 | return $this; 89 | } 90 | 91 | public function getAutoplayDelay(): int 92 | { 93 | return $this->autoplayDelay; 94 | } 95 | 96 | public function autoplayDelay(int $autoplayDelay = 3000) 97 | { 98 | $this->autoplayDelay = $autoplayDelay; 99 | 100 | return $this; 101 | } 102 | 103 | public function getCenteredSlides(): bool 104 | { 105 | return $this->centeredSlides; 106 | } 107 | 108 | public function centeredSlides(bool $centeredSlides = true): SwiperImageEntry 109 | { 110 | $this->centeredSlides = $centeredSlides; 111 | 112 | return $this; 113 | } 114 | 115 | public function getSpatie(): bool 116 | { 117 | return $this->spatie; 118 | } 119 | 120 | public function spatie(bool $spatie = true): SwiperImageEntry 121 | { 122 | $this->spatie = $spatie; 123 | 124 | return $this; 125 | } 126 | 127 | public function conversion(string | Closure | null $conversion): static 128 | { 129 | $this->conversion = $conversion; 130 | 131 | return $this; 132 | } 133 | 134 | public function getCollection(): ?string 135 | { 136 | return $this->evaluate($this->collection) ?? 'default'; 137 | } 138 | 139 | public function getConversion(): ?string 140 | { 141 | return $this->evaluate($this->conversion); 142 | } 143 | 144 | public function getImageUrl(?string $state = null): ?string 145 | { 146 | 147 | if ($this->getSpatie() == false) { 148 | return parent::getImageUrl($state); 149 | } 150 | 151 | $record = $this->getRecord(); 152 | 153 | if (! $record) { 154 | return null; 155 | } 156 | 157 | $relationshipName = $this->getRelationshipName(); 158 | 159 | if (filled($relationshipName)) { 160 | $record = $record->getRelationValue($relationshipName); 161 | } 162 | 163 | /** @var ?Media $media */ 164 | $media = $record->media->first(fn (Media $media): bool => $media->uuid === $state); 165 | 166 | if (! $media) { 167 | return null; 168 | } 169 | 170 | $conversion = $this->getConversion(); 171 | 172 | if ($this->getVisibility() === 'private') { 173 | try { 174 | return $media->getTemporaryUrl( 175 | now()->addMinutes(5), 176 | $conversion ?? '', 177 | ); 178 | } catch (Throwable $exception) { 179 | // This driver does not support creating temporary URLs. 180 | } 181 | } 182 | 183 | return $media->getAvailableUrl(Arr::wrap($conversion)); 184 | } 185 | 186 | public function getState(): array 187 | { 188 | 189 | if ($this->getSpatie() == false) { 190 | return parent::getState(); 191 | } 192 | 193 | $collection = $this->getCollection(); 194 | 195 | return $this->getRecord()->getRelationValue('media') 196 | ->filter(fn (Media $media): bool => blank($collection) || ($media->getAttributeValue('collection_name') === $collection)) 197 | ->sortBy('order_column') 198 | ->map(fn (Media $media): string => $media->uuid) 199 | ->all(); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /src/Testing/TestsFilamentSwiper.php: -------------------------------------------------------------------------------- 1 | title; 60 | } 61 | 62 | public function title(string $title): Swiper 63 | { 64 | $this->title = $title; 65 | 66 | return $this; 67 | } 68 | 69 | public function getNavigation(): bool 70 | { 71 | return $this->navigation; 72 | } 73 | 74 | public function navigation(bool $navigation = true) 75 | { 76 | $this->navigation = $navigation; 77 | 78 | return $this; 79 | } 80 | 81 | public function getSlidesPerView(): int 82 | { 83 | return $this->slidesPerView; 84 | } 85 | 86 | public function slidesPerView(int $slidesPerView = 3) 87 | { 88 | $this->slidesPerView = $slidesPerView; 89 | 90 | return $this; 91 | } 92 | 93 | public function getAutoplay(): bool 94 | { 95 | return $this->autoplay; 96 | } 97 | 98 | public function autoplay(bool $autoplay = true) 99 | { 100 | $this->autoplay = $autoplay; 101 | 102 | return $this; 103 | } 104 | 105 | public function getAutoplayDelay(): int 106 | { 107 | return $this->autoplayDelay; 108 | } 109 | 110 | public function autoplayDelay(int $autoplayDelay = 3000) 111 | { 112 | $this->autoplayDelay = $autoplayDelay; 113 | 114 | return $this; 115 | } 116 | 117 | public function getCenteredSlides(): bool 118 | { 119 | return $this->centeredSlides; 120 | } 121 | 122 | public function centeredSlides(bool $centeredSlides = true): Swiper 123 | { 124 | $this->centeredSlides = $centeredSlides; 125 | 126 | return $this; 127 | } 128 | 129 | public function getChildComponentContainers(bool $withHidden = false): array 130 | { 131 | if (! $this->hasChildComponentContainer($withHidden)) { 132 | return []; 133 | } 134 | 135 | return [ 136 | 'default' => SwiperContainer::make($this->getLivewire()) 137 | ->parentComponent($this) 138 | ->components($this->getChildComponents()) 139 | ->elementTag('swiper-container'), 140 | ]; 141 | } 142 | 143 | public function schema(array $schema): Swiper 144 | { 145 | $this->components = $schema; 146 | 147 | return $this; 148 | } 149 | 150 | public function getComponents(): array 151 | { 152 | return $this->components; 153 | } 154 | 155 | public function getExtraAttributes() 156 | { 157 | return []; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /src/Widgets/SwiperWidget.php: -------------------------------------------------------------------------------- 1 | defaultWidget; 21 | } 22 | 23 | public function getFinalSwiper() 24 | { 25 | return $this->getSwiper(Swiper::make()) 26 | ->schema($this->getComponents()); 27 | } 28 | 29 | public function getSwiper(Swiper $swiper) 30 | { 31 | return $swiper 32 | ->loop() 33 | ->navigation(false) 34 | ->pagination() 35 | ->paginationClickable() 36 | ->paginationHideOnClick() 37 | ->autoplay(); 38 | } 39 | 40 | public function getComponents(): array 41 | { 42 | return []; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /stubs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rupadana/filament-swiper/2d3f7cec5aa572c06b0b36031cae1e1ed2e2735a/stubs/.gitkeep --------------------------------------------------------------------------------