Skip to content

Commit

Permalink
Initital commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 24, 2023
1 parent 395bfde commit d0f8b0e
Show file tree
Hide file tree
Showing 26 changed files with 1,453 additions and 61 deletions.
130 changes: 108 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,130 @@
<p align="center">
<a href="https://github.com/yii2-extensions/template" target="_blank">
<a href="https://github.com/yii2-extensions/datetime-picker" 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">Tempus Dominus Date/Time Picker.</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/datetime-picker/actions/workflows/build.yml" target="_blank">
<img src="https://github.com/yii2-extensions/datetime-picker/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 href="https://github.com/yii2-extensions/datetime-picker/actions/workflows/compatibility.yml" target="_blank">
<img src="https://github.com/yii2-extensions/datetime-picker/actions/workflows/compatibility.yml/badge.svg" alt="PHPUnit">
</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>
<a href="https://codecov.io/gh/yii2-extensions/datetime-picker" target="_blank">
<img src="https://codecov.io/gh/yii2-extensions/datetime-picker/branch/main/graph/badge.svg?token=MF0XUGVLYC" alt="Codecov">
</a>
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/datetime-picker/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Fdatetime-picker%2Fmain" alt="Infection">
</a>
</p>

## Requirements
## Installation

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

Either run

```
composer require --dev --prefer-dist yii2-extensions/datetime-picker
```

The minimun version of `PHP` required by this package is `PHP 8.1`.
or add

For install this package, you need [composer](https://getcomposer.org/).
```
"yii2-extensions/datetime-picker": "dev-main"
```

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

## Usage

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

```php
use Yii2\Extensions\DateTimePicker\DateTimePicker;

echo DateTimePicker::widget(['name' => 'datetime-picker']);
```

### Active Field

```php
use Yii2\Extensions\DateTimePicker\DateTimePicker;

echo $form
->field($formModel, 'date')
->widget(
DateTimePicker::class,
[
'icon' => Icon::renderIcon('solid', 'calendar', ['class' => 'me-2 fa-solid'])
]
);
```

### Active Field Floating Label

```php
use Yii2\Extensions\DateTimePicker\DateTimePicker;

echo $form
->field($formModel, 'date', ['options' => ['class' => 'mt-3']])
->label(false)
->widget(
DateTimePicker::class,
[
'floatingLabel' => true,
'icon' => Icon::renderIcon('solid', 'calendar', ['class' => 'me-2 fa-solid'])
]
)
```

### Properties of the widget

| Property | Type | Description | Default |
|------------------|---------------|------------------------------------|-----------------------------|
| `config` | `array` | The configuration of the widget. | `[]` |
| `containerClass` | `string` | The class of the container. | `input-group` |
| `cdn` | `boolean` | Whether to use the CDN. | `true` |
| `floatingLabel` | `boolean` | Whether to use the floating label. | `false` |
| `formatMonth` | `string` | The format of the month. | `long` |
| `formatYear` | `string` | The format of the year. | `numeric` |
| `icon` | `string` | The icon of the widget. | `''` |
| `id` | `string` | The ID of the widget. | `datetimepicker1` |
| `labelClass` | `string` | The class of the label. | `form-label` |
| `labelContent` | `string` | The content of the label. | `''` |
| `spanClass` | `string` | The class of the span. | `input-group-text` |
| `startOfTheWeek` | `integer` | The start of the week. | `1` |
| `template` | `string` | The template of the widget. `'{label}\n{input}\n{span}'` |

### Translation support

The extension supports translation. You can translate the extension into your language,
for default the extension supports the following languages:

- Chinese
- English
- French
- German
- Portuguese
- Russian
- Spanish

## Quality code

[![static-analysis](https://github.com/yii2-extensions/datetime-picker/actions/workflows/static.yml/badge.svg)](https://github.com/yii2-extensions/datetime-picker/actions/workflows/static.yml)
[![phpstan-level](https://img.shields.io/badge/PHPStan%20level-7-blue)](https://github.com/yii2-extensions/datetime-picker/actions/workflows/static.yml)
[![StyleCI](https://github.styleci.io/repos/722487175/shield?branch=main)](https://github.styleci.io/repos/722487175?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
41 changes: 35 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,70 @@
{
"name": "yii2/template",
"name": "yii2-extensions/datetime-picker",
"type": "library",
"description": "_____",
"description": "Date and time picker for Yii Framework.",
"keywords": [
"_____"
"yii2",
"date",
"time",
"picker"
],
"license": "mit",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"npm-asset/eonasdan--tempus-dominus": "^6.7",
"oomphinc/composer-installers-extender": "^2.0",
"php-forge/html": "dev-main",
"yii2-extensions/asset-popper": "dev-main",
"yiisoft/yii2": "^2.2"
},
"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\\DateTimePicker\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yii\\template\\tests\\": "tests"
"Yii2\\Extensions\\DateTimePicker\\Tests\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
},
"config-plugin": {
"params": "params.php",
"yii2-datetime-picker": "extension.php"
},
"config-plugin-options": {
"source-directory": "config"
},
"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
18 changes: 18 additions & 0 deletions config/extension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

use yii\i18n\PhpMessageSource;

return [
'components' => [
'i18n' => [
'translations' => [
'yii2.extensions.datetime.picker' => [
'class' => PhpMessageSource::class,
'basePath' => '@yii2-extension-datetime-picker/resource/message',
],
],
],
],
];
66 changes: 66 additions & 0 deletions config/messages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

declare(strict_types=1);

/**
* This is a configuration file for the [[\yii\console\controllers\MessageController]] console command.
*
* In order to update translations, run the following console command:
* php yii message messages/config.php
*
* @see yii\console\controllers\MessageController
*/

return [
// string, required, root directory of all source files
'sourcePath' => dirname(__DIR__) . '/src',
// array, required, list of language codes that the extracted messages
// should be translated to. For example, ['zh-CN', 'de'].
'languages' => ['de', 'es', 'fr', 'pt', 'ru', 'zh'],
// string, the name of the function for translating messages.
// Defaults to 'Yii::t'. This is used as a mark to find the messages to be
// translated. You may use a string for single function name or an array for
// multiple function names.
'translator' => ['Yii::t'],
// boolean, whether to sort messages by keys when merging new messages
// with the existing ones. Defaults to false, which means the new (untranslated)
// messages will be separated from the old (translated) ones.
'sort' => true,
// boolean, whether to remove messages that no longer appear in the source code.
// Defaults to false, which means each of these messages will be enclosed with a pair of '@@' marks.
'removeUnused' => false,
// array, list of patterns that specify which files (not directories) should be processed.
// If empty or not set, all files will be processed.
// Please refer to "except" for details about the patterns.
'only' => ['*.php'],
// array, list of patterns that specify which files/directories should NOT be processed.
// If empty or not set, all files/directories will be processed.
// A path matches a pattern if it contains the pattern string at its end. For example,
// '/a/b' will match all files and directories ending with '/a/b';
// the '*.svn' will match all files and directories whose name ends with '.svn'.
// and the '.svn' will match all files and directories named exactly '.svn'.
// Note, the '/' characters in a pattern matches both '/' and '\'.
// See helpers/FileHelper::findFiles() description for more details on pattern matching rules.
// If a file/directory matches both a pattern in "only" and "except", it will NOT be processed.
'except' => [
'.svn',
'.git',
'.gitignore',
'.gitkeep',
'.hg',
'.hgignore',
'.hgkeep',
'/messages',
'/migrations',
],
// 'php' output format is for saving messages to php files.
'format' => 'php',
// Root directory containing message translations.
'messagePath' => dirname(__DIR__) . '/resource/message',
// boolean, whether the message file should be overwritten with the merged messages
'overwrite' => true,
// Message categories to ignore
'ignoreCategories' => [
'yii',
],
];
9 changes: 9 additions & 0 deletions config/params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

return [
'common.aliases' => [
'@yii2-extension-datetime-picker' => '@vendor/yii2-extensions/datetime-picker',
],
];
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-DateTimePicker">
<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>
Loading

0 comments on commit d0f8b0e

Please sign in to comment.