aymericcucherousset/ux-sortable
最新稳定版本:v0.0.2
Composer 安装命令:
composer require aymericcucherousset/ux-sortable
包简介
Sortable integration for Symfony
关键字:
README 文档
README
A lightweight Symfony UX wrapper around SortableJS using AssetMapper & Stimulus.
Symfony UX Sortable integrates SortableJS into Symfony applications using:
- AssetMapper (no Webpack/Vite required)
- Stimulus
- Twig helper
- Importmap
Features
- Drag & drop reordering
- Fully configurable SortableJS options
- Clean Twig API
- Zero build step
Compatible with Symfony 7.4 / 8+
Installation
composer require aymericcucherousset/ux-sortable
If you are using Symfony Flex, the bundle is auto-registered.
Then install JavaScript dependencies:
php bin/console importmap:install
Basic Usage
Twig
<ul {{ sortable_attributes() }}> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>
That’s it. Drag & drop is now enabled.
Passing Options
You can pass any SortableJS option:
<ul {{ sortable_attributes({ group: 'tasks', animation: 150, ghostClass: 'bg-gray-200' }) }}> <li>Task A</li> <li>Task B</li> </ul>
Options are automatically encoded as a valid JSON object.
How It Works
Registers a Stimulus controller Uses AssetMapper to expose JS assets Wraps SortableJS Generates correct Stimulus data attributes via Twig Generated HTML example:
<ul data-controller="aymericcucherousset--ux-sortable--sortable" data-aymericcucherousset--ux-sortable--sortable-options-value='{"animation":150}' >
Requirements
- PHP 8.3+
- Symfony 7.4+ or 8+
- symfony/stimulus-bundle
- symfony/asset-mapper
Advanced Usage
You can still access the controller manually if needed:
<ul data-controller="aymericcucherousset--ux-sortable--sortable" data-aymericcucherousset--ux-sortable--sortable-options-value='{"animation":300}' >
Roadmap
- Emit custom events
- Integration with Symfony UX LiveComponent
- Nested sortable support
- TypeScript support
- Auto persistence helper
Versioning
Current version: v0.0.1
This is an early release. API may evolve before 1.0.
Contributing
Issues and pull requests are welcome.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-01