定制 drpshtiwan/livewire-async-select 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

drpshtiwan/livewire-async-select

最新稳定版本:2.0.0

Composer 安装命令:

composer require drpshtiwan/livewire-async-select

包简介

A powerful async select component for Laravel Livewire with Alpine.js - a modern alternative to Select2

README 文档

README

A powerful async select component for Laravel Livewire with Alpine.js - a modern, lightweight alternative to Select2.

Latest Version GitHub Tests Action Status Total Downloads Code Style License

🎥 Demo

Livewire Async Select Demo

▶️ Watch Full Demo on YouTube

✨ Features

  • 🚀 Asynchronous Loading - Load options dynamically from API endpoints
  • 🔍 Search & Filter - Built-in search with debouncing
  • 🎯 Multiple Selection - Beautiful chip/tag display
  • Alpine.js Powered - Lightweight, no jQuery dependency
  • 🎨 Styled with Tailwind CSS - Pre-built styles with las- prefix
  • 🎭 Custom Slots - Fully customizable rendering
  • 📦 Easy Integration - Native Livewire component
  • 🔄 Two-way Binding - Full wire:model support
  • 🔒 No Style Conflicts - All classes prefixed with las-
  • 🔐 Authentication Support - Custom headers and internal authentication
  • 🛡️ Secure Internal Auth - Signed tokens with replay protection

📚 Documentation

📖 Full Documentation

Complete guides, examples, and API reference available at:

https://livewire-select.thejano.com/

To build and view the documentation locally, see DOCS.md.

⚡ Quick Install

  1. Install via Composer:
composer require drpshtiwan/livewire-async-select
  1. Publish the CSS assets:
php artisan vendor:publish --tag=async-select-assets
  1. Setup your layout (important!):
<head>
    @asyncSelectStyles
    @livewireStyles
</head>
<body>
    {{ $slot }}
    
    @livewireScripts
    @stack('scripts')  {{-- Required! --}}
</body>

⚠️ Important: The @stack('scripts') directive is required for the component to work properly.

🎯 Basic Usage

<livewire:async-select
    name="user_id"
    wire:model="selectedUser"
    endpoint="/api/users/search"
    placeholder="Search users..."
/>

API Route with async-auth middleware:

// Default guard (web)
Route::middleware(['async-auth'])->get('/api/users/search', function (Request $request) {
    $users = User::where('name', 'like', "%{$request->get('search')}%")
        ->limit(20)
        ->get();
    
    return response()->json(['data' => $users]);
});

// With Sanctum
Route::middleware(['async-auth:sanctum'])->get('/api/users/search', function (Request $request) {
    // Works with Sanctum tokens or internal auth
    $users = User::where('name', 'like', "%{$request->get('search')}%")
        ->limit(20)
        ->get();
    
    return response()->json(['data' => $users]);
});

// With web guard and session persistence
Route::middleware(['web', 'async-auth:web,persist'])->get('/api/users/search', function (Request $request) {
    // Persists login in session
    $users = User::where('name', 'like', "%{$request->get('search')}%")
        ->limit(20)
        ->get();
    
    return response()->json(['data' => $users]);
});

The async-auth middleware is automatically registered and works exactly like auth middleware, but also handles internal authentication automatically when the X-Internal-User header is present. Supports all guards: async-auth:web, async-auth:sanctum, async-auth:api, etc.

→ View full documentation

📋 Requirements

  • PHP 8.1+
  • Laravel 10.x, 11.x, or 12.x
  • Livewire 3.3+

🆚 Why This Package?

Feature Livewire Async Select Select2
jQuery Dependency ❌ No ✅ Yes
Livewire Integration ✅ Native ⚠️ Manual
Bundle Size 🟢 Small 🟡 Large
Modern Stack ✅ Yes ❌ Legacy

🤝 Contributing

Contributions are welcome! Please see the documentation for details.

📄 License

The MIT License (MIT). Please see License File for more information.

🙏 Credits

🔗 Links

统计信息

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

GitHub 信息

  • Stars: 98
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-02