Skip to content

Commit

Permalink
Iniitial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 20, 2023
1 parent 8a22940 commit 30e0739
Show file tree
Hide file tree
Showing 22 changed files with 843 additions and 64 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ name: build

jobs:
phpunit:
uses: yiisoft/actions/.github/workflows/phpunit.yml@master
uses: php-forge/actions/.github/workflows/phpunit.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: compatibility

jobs:
phpunit:
uses: php-forge/actions/.github/workflows/phpunit.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.0.49 --prefer-dist --no-progress --no-interaction --no-scripts --ansi
extensions: intl
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.1', '8.2', '8.3']
4 changes: 3 additions & 1 deletion .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ name: Composer require checker

jobs:
composer-require-checker:
uses: yiisoft/actions/.github/workflows/composer-require-checker.yml@master
uses: php-forge/actions/.github/workflows/composer-require-checker.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest']
php: >-
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'psalm.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'psalm.xml'

name: mutation test

jobs:
mutation:
uses: php-forge/actions/.github/workflows/roave-infection.yml@main
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest']
php: >-
['8.1']
2 changes: 2 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
phpstan:
uses: php-forge/actions/.github/workflows/phpstan.yml@main
with:
composer-command: |
composer require yiisoft/yii2:^2.2.x-dev --prefer-dist --no-progress --no-interaction --no-scripts --ansi
os: >-
['ubuntu-latest']
php: >-
Expand Down
101 changes: 79 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,101 @@
<p align="center">
<a href="https://github.com/yii2-extensions/template" target="_blank">
<a href="https://github.com/yii2-extensions/selectize" target="_blank">
<img src="https://www.yiiframework.com/image/yii_logo_light.svg" height="100px;">
</a>
<h1 align="center">Yii2-Template.</h1>
<h1 align="center">Selectize.</h1>
<br>
</p>

<p align="center">
<a href="https://www.php.net/releases/8.1/en.php" target="_blank">
<img src="https://img.shields.io/badge/PHP-%3E%3D8.1-787CB5" alt="php-version">
</a>
<a href="https://github.com/yiisoft/yii2/tree/2.2" target="_blank">
<img src="https://img.shields.io/badge/Yii2%20version-2.2-blue" alt="yii2-version">
<a href="https://github.com/yii2-extensions/selectize/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/selectize/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/template/actions/workflows/build.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://codecov.io/gh/yii2-extensions/template" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/template/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<img src="https://github.com/yii2-extensions/gii/actions/workflows/static.yml/badge.svg" alt="PHPStan">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/badge/PHPStan%20level-2-blue" alt="PHPStan level">
</a>
<a href="https://github.styleci.io/repos/698621511?branch=main" target="_blank">
<img src="https://github.styleci.io/repos/698621511/shield?branch=main" alt="Code style">
<a href="https://github.com/yii2-extensions/selectize/actions/workflows/compatibility.yml" target="_blank">
<img src="https://github.com/yii2-extensions/selectize/actions/workflows/compatibility.yml/badge.svg" alt="PHPUnit">
</a>
<a href="https://codecov.io/gh/yii2-extensions/selectize" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/selectize/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/selectize/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgit.luolix.top%2Fyii2-extensions%2Fselectize%2Fmain" alt="Infection">
</a>
</p>

## Requirements
## Installation

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

The minimun version of `PHP` required by this package is `PHP 8.1`.
Either run

For install this package, you need [composer](https://getcomposer.org/).
```
composer require --dev --prefer-dist yii2-extensions/selectize
```

or add

```
"yii2-extensions/selectize": "dev-main"
```

to the require-dev section of your `composer.json` file.

## Usage

[Check the documentation docs](/docs/README.md) to learn about usage.
### DropdownList

```php
use Yii2\Extension\Selectize\Selectize;

Selectize::widget(
[
'attribute' => 'tags',
'items' => ['foo', 'bar'],
'model' => new SelectizeModel(), // your model
],
);
```

### Text input

```php
use Yii2\Extension\Selectize\Selectize;

Selectize::widget(
[
'attribute' => 'tags',
'items' => ['foo', 'bar'],
'model' => new SelectizeModel(), // your model
'type' => Selectize::TYPE_TEXT, // `Selectize::TYPE_SELECT`, `Selectize::TYPE_TEXT`
],
);
```

### Properties of the widget

| Property | Type | Description | Default |
|----------------|---------------|----------------------------------------------------------------------------------|--------------------------|
| `attribute` | `string` | The attribute associated with this widget. | `null` |
| `clientOptions`| `array` | The options for the underlying Selectize JS plugin. | `[]` |
| `items` | `array` | Items to be displayed in the dropdown list. | `[]` |
| `loadUrl` | `string` | The URL that will return JSON data. | `null` |
| `model` | `Model` | The data model that this widget is associated with. | `null` |
| `options` | `array` | The HTML attributes for the widget container tag. | `[]` |
| `queryParam` | `string` | The name of the parameter that will be sent to the server with the search query. | `query` |
| `type` | `string` | The type of the widget. | `Selectize::TYPE_SELECT` |

## Quality code

[![static-analysis](https://github.com/yii2-extensions/selectize/actions/workflows/static.yml/badge.svg)](https://github.com/yii2-extensions/selectize/actions/workflows/static.yml)
[![phpstan-level](https://img.shields.io/badge/PHPStan%20level-5-blue)](https://github.com/yii2-extensions/selectize/actions/workflows/static.yml)
[![StyleCI](https://github.styleci.io/repos/720718108/shield?branch=main)](https://github.styleci.io/repos/720718108?branch=main)

## Support versions Yii2

[![Yii20](https://img.shields.io/badge/Yii2%20version-2.0-blue)](https://github.com/yiisoft/yii2/tree/2.0.49.3)
[![Yii22](https://img.shields.io/badge/Yii2%20version-2.2-blue)](https://github.com/yiisoft/yii2/tree/2.2)

## Testing

Expand Down
34 changes: 27 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
{
"name": "yii2/template",
"name": "yii2-extension/selectize",
"type": "library",
"description": "_____",
"description": "Selectize widget for Yii Framework 2",
"keywords": [
"_____"
"yii2",
"selectize",
"widget"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"yiisoft/yii2": "^2.2"
"npm-asset/selectize--selectize": "^0.15.2",
"oomphinc/composer-installers-extender": "^2.0",
"yii2-extensions/asset-bootstrap5": "dev-main",
"yiisoft/yii2": "*"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.6",
"php-forge/support": "dev-main",
"phpunit/phpunit": "^10.2",
"roave/infection-static-analysis-plugin": "^1.32",
"yii2-extensions/phpstan": "dev-main"
},
"autoload": {
"psr-4": {
"yii\\template\\": "src"
"Yii2\\Extensions\\Selectize\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yii\\template\\tests\\": "tests"
"Yii2\\Extensions\\Selectize\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
},
"installer-types": [
"bower-asset",
"npm-asset"
],
"installer-paths": {
"./node_modules/{$name}/": [
"type:bower-asset",
"type:npm-asset"
]
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"yiisoft/yii2-composer": true
"yiisoft/yii2-composer": true,
"composer/installers": true,
"oomphinc/composer-installers-extender": true,
"infection/extension-installer": true
}
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
bootstrap="tests/Support/bootstrap.php"
cacheDirectory=".phpunit.cache"
colors="true"
executionOrder="depends,defects"
Expand All @@ -11,7 +11,7 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="Template">
<testsuite name="Yii2-Selectize">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
</issueHandlers>
</psalm>
39 changes: 39 additions & 0 deletions src/Asset/SelectizeAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Yii2\Extensions\Selectize\Asset;

use Yii2\Asset\BootstrapPluginAsset;
use yii\web\AssetBundle;
use yii\web\JqueryAsset;

final class SelectizeAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $sourcePath = '@npm/selectize--selectize/dist';

/**
* @inheritdoc
*/
public $css = [
'css/selectize.bootstrap5.css',
];

/**
* @inheritdoc
*/
public $js = [
'js/selectize.js',
];

/**
* @inheritdoc
*/
public $depends = [
BootstrapPluginAsset::class,
JqueryAsset::class,
];
}
13 changes: 0 additions & 13 deletions src/Example.php

This file was deleted.

Loading

0 comments on commit 30e0739

Please sign in to comment.