akhmads/select-components 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

akhmads/select-components

Composer 安装命令:

composer require akhmads/select-components

包简介

Laravel Blade components for remote, offline and multi selects.

README 文档

README

A small Laravel package providing reusable Blade components for select inputs.

This package is designed for Livewire and works well together with Mary UI (daisyUI + Tailwind UI components).

Stack

This package is built using:

  • Alpine.js
  • Tailwind CSS
  • daisyUI

Requirements

  • Laravel 12+
  • Livewire (includes Alpine.js)
  • daisyUI (Tailwind CSS plugin) or Mary UI

Features

  • Responsive design
  • Dark mode support
  • Adaptive dropdowns (auto width, truncation)
  • Keyboard navigation support (arrow keys + enter)
  • Built for Livewire (wire:model friendly)
  • Clearable selection + optional placeholder
  • Supports disabled state + focus management
  • Initial value support (pre-selected values)
  • Works well with Mary UI / daisyUI styling

Included components

  • <x-remote-select />

    • Fetches options via AJAX (remote endpoint)
    • Supports searching/filtering as you type
    • Keeps label/value in sync when wire:model changes
  • <x-offline-select />

    • Uses a local options array (static data)
    • Supports searching locally
  • <x-multi-select />

    • Supports selecting multiple values
    • Uses the same remote (AJAX) mechanism as remote-select

Installation

Install livewire

Install daisyUI (Tailwind CSS plugin) or Mary UI

Install via Composer (Packagist)

composer require akhmads/select-components

Usage

Remote select

<x-remote-select
    wire:model="selected"
    remote="/api/users"
    option_value="id"
    option_label="label"
    placeholder="Select a user"
    clearable
    :initial_value="\App\Models\User::find($selected)"
/>
  • remote: URL endpoint that returns a JSON array of option objects (e.g. /api/users or {{ route('api.user') }}).
  • option_value: the key to use for the option value (default: id).
  • option_label: the key to use for the option label (default: name).
  • placeholder: placeholder text shown when nothing is selected.
  • clearable: when present, allows clearing the selection.
  • initial_value: (optional) can be either:
    • an array of IDs (will fetch labels from remote)
    • an array of objects {id, name} (will be used directly)

Add a simple endpoint to routes/web.php (or routes/api.php) that returns users in JSON:

use Illuminate\Http\Request;

Route::get('/api/users', function (Request $request) {
     $search = $request->query('search');

     $users = \App\Models\User::query()
         ->when($search, function ($q) use ($search) {
             $q->where('name', 'like', "%{$search}%")
                 ->orWhere('email', 'like', "%{$search}%");
         })
         ->orderBy('name')
         ->limit(20)
         ->get();

     return $users;
})->name('api.users');

Offline select

<x-offline-select
    wire:model="selected"
    :options="[['id' => 1, 'name' => 'Foo'], ['id' => 2, 'name' => 'Bar']]"
    option_value="id"
    option_label="name"
    placeholder="Select a user"
    clearable
    :initial_value="['id' => 2, 'name' => 'Bar']"
/>

Multi select

<x-multi-select
    wire:model="selected"
    remote="/api/users"
    option_value="id"
    option_label="label"
    placeholder="Select users"
    clearable
    :initial_value="\App\Models\User::whereIn([1,2])->get()"
/>

Overriding views (optional)

To customize the component Blade templates, publish the views:

php artisan vendor:publish --tag=views --provider="SelectComponents\SelectComponentsServiceProvider"

Notes

  • The components are registered automatically via package discovery.
  • remote-select and multi-select rely on a JSON endpoint returning an array of objects. Each object should have an id (or your chosen key) and a label key.

Contributing

To work on this package locally, clone the repo into a packages folder inside your Laravel project.

From your Laravel project root:

mkdir -p packages
cd packages
git clone https://github.com/akhmads/select-components.git

Then configure Composer to load it as a local package by adding a path repository to your composer.json (this is already configured in this workspace):

"repositories": [
  {
    "type": "path",
    "url": "packages/select-components",
    "options": {
      "symlink": true
    }
  }
]

Finally, require the local package in your app:

composer require akhmads/select-components:*@dev --prefer-source

Once installed, you can make changes in packages/select-components and test them directly in your Laravel app.

License

This package is released under the MIT License. See the official license text at https://opensource.org/licenses/MIT.

akhmads/select-components 适用场景与选型建议

akhmads/select-components 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「components」 「laravel」 「select」 「tailwindcss」 「livewire」 「alpinejs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 akhmads/select-components 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 akhmads/select-components 我们能提供哪些服务?
定制开发 / 二次开发

基于 akhmads/select-components 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-16