nickstarlight/live-select

此包已被废弃,不再维护。未建议替代包。

使用Laravel、Alpine、Livewire和TailwindCSS制作的可定制下拉组件。

1.1.3 2021-01-07 14:30 UTC

This package is auto-updated.

Last update: 2021-05-07 15:09:59 UTC


README

使用Laravel、Alpine、Livewire和TailwindCSS制作的可定制下拉组件。

目录

需求

  1. PHP >= 7.4 - 我们使用类型属性
  2. Laravel >= 8.0
  3. Livewire >= 2.3
  4. Alpine.js >= 2.8
  5. TailwindCSS >= 2.0

所有这些需求都可以通过使用 Laravel Jetstream 简单搭建。

安装

composer require nickstarlight/live-select

使用

在父组件中

  1. 在组件类中
use LiveSelect\Traits\WithLiveSelect; // The LiveSelect trait required for component communication

class YourComponent extends Component 
{
    use WithLiveSelect; // Include the LiveSelect trait

    public $yourModel; // Create a model
    public $data = [
        [
            'id' => 1,
            'name' => 'Leroy Jenkins'
        ]
    ]; // Define your data
}
  1. 在组件视图中
<div>
    <livewire:live-select
        :multi="false"                  // Multiselection mode                                         - Defaults to false 
        :search="true"                  // Allows the user to filter values on the dropdown            - Defaults to false
        :description="'Select a value'" // The input label                                             - Defaults to null
        :options="$data"                // The options that will be rendered on the dropdown           - Required
        :label="'name'"                 // The key/value pair to be used as the options label          - Optional, will assume 'label' if omitted
        :value="'id'"                   // The key/value pair to be used as the options value          - Optional, will assume 'value' if omitted
        :model="'yourModel'"            // Your parent component public variable name for data binding - Required
    >
</div>

支持

提交问题 以获取支持。

贡献

项目目前处于初步结构化阶段,如果您认为可以做出贡献,请,提交问题进行讨论。

许可

版权所有 (c) 2021 Nickolas Gomes Moraes

在此特此授予任何获得此软件及其相关文档文件(以下简称“软件”)副本的任何人免费使用软件的权利,不受限制地处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向软件提供方提供软件的人士从事上述活动,前提是遵守以下条件

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

软件按“现状”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论这些责任是基于合同、侵权或其他方式,这些责任源自、因之而起或与此软件或软件的使用或其他交易有关。