承接 mrshanebarron/sortable-list 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrshanebarron/sortable-list

最新稳定版本:v1.0.3

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

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固