Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Version 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Илья Глинский authored and Илья Глинский committed Aug 25, 2018
0 parents commit 7bebb51
Show file tree
Hide file tree
Showing 45 changed files with 8,656 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"plugins": [
"transform-runtime",
"transform-object-rest-spread",
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
],
"presets": [["env"]],
"env": {
"test": {
"presets": [["env", { "targets": { "node": "current" } }]]
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/components
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "nightkit/nova-element-ui",
"version": "0.6.0",
"description": "Element UI components for Laravel Nova",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Ilya Glinsky",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"laravel/nova": "*"
},
"autoload": {
"psr-4": {
"NightKit\\NovaElements\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"NightKit\\NovaElements\\NovaElementsServiceProvider"
]
}
}

}
1 change: 1 addition & 0 deletions dist/nova-element-ui.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"/dist/nova-element-ui.js": "/dist/nova-element-ui.js"
}
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"private": true,
"scripts": {
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"dependencies": {
"element-ui": "^2.4.6",
"vue": "^2.5.17"
},
"devDependencies": {
"babel-plugin-component": "^1.1.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^5.2.0",
"laravel-mix": "^1.0"
}
}
83 changes: 83 additions & 0 deletions resources/js/nova-element-ui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import locale from 'element-ui/lib/locale';
const mapLocales = {
'af-ZA': require('element-ui/lib/locale/lang/af-ZA'),
'ar': require('element-ui/lib/locale/lang/ar'),
'bg': require('element-ui/lib/locale/lang/bg'),
'ca': require('element-ui/lib/locale/lang/ca'),
'cs-CZ': require('element-ui/lib/locale/lang/cs-CZ'),
'da': require('element-ui/lib/locale/lang/da'),
'de': require('element-ui/lib/locale/lang/de'),
'ee': require('element-ui/lib/locale/lang/ee'),
'el': require('element-ui/lib/locale/lang/el'),
'en': require('element-ui/lib/locale/lang/en'),
'es': require('element-ui/lib/locale/lang/es'),
'fa': require('element-ui/lib/locale/lang/fa'),
'fi': require('element-ui/lib/locale/lang/fi'),
'fr': require('element-ui/lib/locale/lang/fr'),
'he': require('element-ui/lib/locale/lang/he'),
'hu': require('element-ui/lib/locale/lang/hu'),
'id': require('element-ui/lib/locale/lang/id'),
'it': require('element-ui/lib/locale/lang/it'),
'ja': require('element-ui/lib/locale/lang/ja'),
'km': require('element-ui/lib/locale/lang/km'),
'ko': require('element-ui/lib/locale/lang/ko'),
'ku': require('element-ui/lib/locale/lang/ku'),
'kz': require('element-ui/lib/locale/lang/kz'),
'lt': require('element-ui/lib/locale/lang/lt'),
'lv': require('element-ui/lib/locale/lang/lv'),
'mn': require('element-ui/lib/locale/lang/mn'),
'nb': require('element-ui/lib/locale/lang/nb-NO'),
'nl': require('element-ui/lib/locale/lang/nl'),
'pl': require('element-ui/lib/locale/lang/pl'),
'pt': require('element-ui/lib/locale/lang/pt'),
'pt-br': require('element-ui/lib/locale/lang/pt-br'),
'ro': require('element-ui/lib/locale/lang/ro'),
'ru-RU': require('element-ui/lib/locale/lang/ru-RU'),
'sk': require('element-ui/lib/locale/lang/sk'),
'sl': require('element-ui/lib/locale/lang/sl'),
'sv-SE': require('element-ui/lib/locale/lang/sv-SE'),
'ta': require('element-ui/lib/locale/lang/ta'),
'th': require('element-ui/lib/locale/lang/th'),
'tk': require('element-ui/lib/locale/lang/tk'),
'tr-TR': require('element-ui/lib/locale/lang/tr-TR'),
'ua': require('element-ui/lib/locale/lang/ua'),
'ug-CN': require('element-ui/lib/locale/lang/ug-CN'),
'vi': require('element-ui/lib/locale/lang/vi'),
'zh-CH': require('element-ui/lib/locale/lang/zh-CN'),
'zh-TW': require('element-ui/lib/locale/lang/zh-TW')
}

import {
Select,
Option,
Input,
Autocomplete,
InputNumber,
Radio,
RadioButton,
RadioGroup,
Checkbox,
CheckboxButton,
CheckboxGroup,
ColorPicker,
Switch,
Tag
} from 'element-ui';

Nova.booting(function(Vue, router) {
locale.use(mapLocales[Nova.config.locale] || mapLocales['en']);
Vue.use(Select);
Vue.use(Option);
Vue.use(Input);
Vue.use(Autocomplete);
Vue.use(InputNumber);
Vue.use(Radio);
Vue.use(RadioButton);
Vue.use(RadioGroup);
Vue.use(Checkbox);
Vue.use(CheckboxButton);
Vue.use(CheckboxGroup);
Vue.use(ColorPicker);
Vue.use(Tag);
Vue.use(Switch);
})
125 changes: 125 additions & 0 deletions src/Fields/ElementAutocomplete/ElementAutocomplete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

namespace NightKit\NovaElements\Fields\ElementAutocomplete;

use Laravel\Nova\Fields\Field;

class ElementAutocomplete extends Field
{
/**
* The field's component.
*
* @var string
*/
public $component = 'element-autocomplete';

/**
* Suggestions list for field
* @var array
*/
public $suggestions = [];

/**
* Set suggestions list for field
* @param array
* @return $this
*/

/**
* Placement of the popup menu
* top / top-start / top-end / bottom / bottom-start / bottom-end
* default button-start
* @var string
*/
public $placement = '';

/**
* Whether show suggestions when input focus
* @var bool
*/
public $triggerOnFocus = true;

/**
* Debounce delay when typing, in milliseconds
* @var int
*/
public $debounce = 300;

/**
* Set placement value
* @param string $value
* @return $this
*/
public function placement($value = 'bottom-start')
{
$this->placement = $value;
return $this;
}

/**
* Set triger-on-focus value
* @param bool $bool
* @return $this
*/
public function triggerOnFocus($bool = true)
{
$this->triggerOnFocus = $bool;
return $this;
}

/**
* Set debounce value
* @param int
* @return $this
*/
public function debounce($int) {
$this->debounce = $int;
return $this;
}

public function suggestions($array)
{

if ($this->isSimpleArray($array)) {
$this->suggestions = $this->transformToMulti($array);
} else {
$this->suggestions = $array;
}
return $this;
}

/**
* Suggestions list for field
* @param array
* @return array
*/
private function transformToMulti($array) {
$multi = [];
foreach ($array as $value) {
$multi[] = ['value' => $value];
}
return $multi;
}

/**
* Check is multidimension array
* @param array
* @return bool
*/
private function isSimpleArray($array) {
$rv = array_filter($array, 'is_array');
if(count($rv) > 0) return false;
return true;
}

public function meta()
{
return array_merge([
'suggestions' => $this->suggestions,
'placement' => $this->placement,
'triggerOnFocus' => $this->triggerOnFocus,
'debounce' => $this->debounce
], $this->meta);
}

}
33 changes: 33 additions & 0 deletions src/Fields/ElementAutocomplete/FieldServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace NightKit\NovaElements\Fields\ElementAutocomplete;

use Laravel\Nova\Nova;
use Laravel\Nova\Events\ServingNova;
use Illuminate\Support\ServiceProvider;

class FieldServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Nova::serving(function (ServingNova $event) {
Nova::script('element-autocomplete', __DIR__.'/assets/js/field.js');
Nova::style('element-autocomplete', __DIR__.'/assets/css/field.css');
});
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
Empty file.
1 change: 1 addition & 0 deletions src/Fields/ElementAutocomplete/assets/js/field.js

Large diffs are not rendered by default.

Loading

0 comments on commit 7bebb51

Please sign in to comment.