mrshanebarron/sortable-list
Composer 安装命令:
composer require mrshanebarron/sortable-list
包简介
Drag and drop sortable list for Laravel - supports Livewire and Vue
README 文档
README
Drag and drop reorderable lists for Laravel applications. Supports vertical and horizontal directions, optional drag handles, and emits reorder events. Works with Livewire and Vue 3.
Installation
composer require mrshanebarron/sortable-list
Livewire Usage
Basic Usage
@php $items = [ ['id' => 1, 'title' => 'First Item'], ['id' => 2, 'title' => 'Second Item'], ['id' => 3, 'title' => 'Third Item'], ]; @endphp <livewire:sb-sortable-list :items="$items" />
With Drag Handle
<livewire:sb-sortable-list :items="$items" :handle="true" />
Horizontal Direction
<livewire:sb-sortable-list :items="$items" direction="horizontal" />
With Wire Model
<livewire:sb-sortable-list wire:model="items" :handle="true" />
Livewire Props
| Prop | Type | Default | Description |
|---|---|---|---|
items |
array | [] |
Array of items with id and title keys (modelable) |
handle |
boolean | false |
Show drag handle instead of full-item drag |
direction |
string | 'vertical' |
Direction: vertical or horizontal |
Item Structure
$items = [ ['id' => 1, 'title' => 'Homepage Banner', 'description' => 'Image'], ['id' => 2, 'title' => 'Featured Products', 'description' => 'Collection'], ['id' => 3, 'title' => 'Newsletter Signup', 'description' => 'Form'], ];
Events
<livewire:sb-sortable-list :items="$items" @items-reordered="handleReorder" />
The items-reordered event includes the reordered items array.
Vue 3 Usage
Setup
import { SbSortableList } from './vendor/sb-sortable-list'; app.component('SbSortableList', SbSortableList);
Basic Usage
<template> <SbSortableList v-model="items" /> </template> <script setup> import { ref } from 'vue'; const items = ref([ { id: 1, title: 'First' }, { id: 2, title: 'Second' }, { id: 3, title: 'Third' }, ]); </script>
With Options
<template> <SbSortableList v-model="items" :handle="true" direction="vertical" @reordered="onReorder" /> </template>
Vue Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue |
Array | [] |
v-model binding for items |
handle |
Boolean | false |
Show drag handle |
direction |
String | 'vertical' |
Layout direction |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue |
array | Emitted when items are reordered |
reordered |
array | Emitted with new order after drag ends |
Handling Reorder in Backend
// In your Livewire component public array $items = []; #[On('items-reordered')] public function handleReorder(array $items): void { foreach ($items as $index => $item) { Model::where('id', $item['id'])->update(['order' => $index]); } }
Styling
The sortable list includes:
- Smooth drag animations
- Visual feedback during drag
- Optional grab cursor on handles
- Border and shadow effects
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
- Tailwind CSS 3.x
- Alpine.js (for drag functionality)
License
MIT License
mrshanebarron/sortable-list 适用场景与选型建议
mrshanebarron/sortable-list 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mrshanebarron/sortable-list 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrshanebarron/sortable-list 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-14