diff --git a/angular.json b/angular.json index c28fc2e..c83e8ec 100644 --- a/angular.json +++ b/angular.json @@ -28,6 +28,7 @@ "src/assets" ], "styles": [ + "node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.scss" ], "scripts": [] @@ -203,6 +204,46 @@ } } } + }, + "@poweredsoft/ng-select": { + "projectType": "library", + "root": "projects/poweredsoft/ng-select", + "sourceRoot": "projects/poweredsoft/ng-select/src", + "prefix": "ps-ng", + "architect": { + "build": { + "builder": "@angular-devkit/build-ng-packagr:build", + "options": { + "tsConfig": "projects/poweredsoft/ng-select/tsconfig.lib.json", + "project": "projects/poweredsoft/ng-select/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "projects/poweredsoft/ng-select/tsconfig.lib.prod.json" + } + } + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "projects/poweredsoft/ng-select/src/test.ts", + "tsConfig": "projects/poweredsoft/ng-select/tsconfig.spec.json", + "karmaConfig": "projects/poweredsoft/ng-select/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-devkit/build-angular:tslint", + "options": { + "tsConfig": [ + "projects/poweredsoft/ng-select/tsconfig.lib.json", + "projects/poweredsoft/ng-select/tsconfig.spec.json" + ], + "exclude": [ + "**/node_modules/**" + ] + } + } + } }}, "defaultProject": "ngx-cdk-ui" } diff --git a/package-lock.json b/package-lock.json index c3334f8..ed812a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1644,6 +1644,14 @@ } } }, + "@ng-select/ng-select": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@ng-select/ng-select/-/ng-select-4.0.1.tgz", + "integrity": "sha512-f5NzrKRvswOvxa8BzBgAUOpzl0B8SrlVQHQLB2zPymuZlzC2dWUi9mUhgu6s2igwdClmrZ8bysNBBNpgqHskyA==", + "requires": { + "tslib": "^1.10.0" + } + }, "@ngtools/webpack": { "version": "9.1.7", "resolved": "https://registry.npmjs.org/@ngtools/webpack/-/webpack-9.1.7.tgz", @@ -1668,9 +1676,9 @@ } }, "@poweredsoft/data": { - "version": "0.0.26", - "resolved": "https://registry.npmjs.org/@poweredsoft/data/-/data-0.0.26.tgz", - "integrity": "sha512-JogKJQ01w4hTQr4EDSoYp2KfJzBbzC8trc7iHCxw7tjF6kB9nqWxu8gvRxX5pqzDK6ORz0Ieuw7i0hEZusW+ww==", + "version": "0.0.30", + "resolved": "https://registry.npmjs.org/@poweredsoft/data/-/data-0.0.30.tgz", + "integrity": "sha512-lKojW+yCKPSrdohqhuoEUTo196Z1cHs+SkOZ9N43N7MUcbIR0SA6Uz6k4QZtbmbXmR5AvDKPrDp37nqPXGZFYA==", "requires": { "tslib": "^1.9.0" } @@ -1684,9 +1692,9 @@ } }, "@poweredsoft/ngx-data-apollo": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@poweredsoft/ngx-data-apollo/-/ngx-data-apollo-0.0.8.tgz", - "integrity": "sha512-8nIlvHTnbLyG9aNxkSYOHIbNBBSjj92v0BeFTq4xkttp3UmYzhOO7lkgo1cEIDUuYo+ITAYoZbKwrd4CbnBgcA==", + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/@poweredsoft/ngx-data-apollo/-/ngx-data-apollo-0.0.10.tgz", + "integrity": "sha512-0HjJthjXstNXS/T9u6t9VTWtQO/LUzGsbT/m0tjj8y0YuivMzfK76EyQldvjGXDYGfIL12kEhsKEbiOPXyCXcA==", "requires": { "tslib": "^1.9.0" } diff --git a/package.json b/package.json index 2d27be7..03cac8b 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,10 @@ "@angular/platform-browser": "~9.1.4", "@angular/platform-browser-dynamic": "~9.1.4", "@angular/router": "~9.1.4", - "@poweredsoft/data": "0.0.26", + "@ng-select/ng-select": "^4.0.1", + "@poweredsoft/data": "0.0.30", "@poweredsoft/ngx-data": "0.0.13", - "@poweredsoft/ngx-data-apollo": "0.0.8", + "@poweredsoft/ngx-data-apollo": "0.0.10", "apollo-angular": "^1.8.0", "apollo-angular-link-http": "^1.9.0", "apollo-cache-inmemory": "^1.6.0", diff --git a/projects/poweredsoft/ng-select/README.md b/projects/poweredsoft/ng-select/README.md new file mode 100644 index 0000000..26c0003 --- /dev/null +++ b/projects/poweredsoft/ng-select/README.md @@ -0,0 +1,24 @@ +# NgSelect + +This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.9. + +## Code scaffolding + +Run `ng generate component component-name --project ng-select` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ng-select`. +> Note: Don't forget to add `--project ng-select` or else it will be added to the default project in your `angular.json` file. + +## Build + +Run `ng build ng-select` to build the project. The build artifacts will be stored in the `dist/` directory. + +## Publishing + +After building your library with `ng build ng-select`, go to the dist folder `cd dist/ng-select` and run `npm publish`. + +## Running unit tests + +Run `ng test ng-select` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/projects/poweredsoft/ng-select/karma.conf.js b/projects/poweredsoft/ng-select/karma.conf.js new file mode 100644 index 0000000..1b4e689 --- /dev/null +++ b/projects/poweredsoft/ng-select/karma.conf.js @@ -0,0 +1,32 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/1.0/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular-devkit/build-angular'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular-devkit/build-angular/plugins/karma') + ], + client: { + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + dir: require('path').join(__dirname, '../../../coverage/poweredsoft/ng-select'), + reports: ['html', 'lcovonly', 'text-summary'], + fixWebpackSourcePaths: true + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false, + restartOnFileChange: true + }); +}; diff --git a/projects/poweredsoft/ng-select/ng-package.json b/projects/poweredsoft/ng-select/ng-package.json new file mode 100644 index 0000000..70f4cbd --- /dev/null +++ b/projects/poweredsoft/ng-select/ng-package.json @@ -0,0 +1,7 @@ +{ + "$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", + "dest": "../../../dist/poweredsoft/ng-select", + "lib": { + "entryFile": "src/public-api.ts" + } +} \ No newline at end of file diff --git a/projects/poweredsoft/ng-select/package.json b/projects/poweredsoft/ng-select/package.json new file mode 100644 index 0000000..e724836 --- /dev/null +++ b/projects/poweredsoft/ng-select/package.json @@ -0,0 +1,11 @@ +{ + "name": "@poweredsoft/ng-select", + "version": "0.0.1", + "peerDependencies": { + "@angular/common": "^9.1.9", + "@angular/core": "^9.1.9" + }, + "dependencies": { + "tslib": "^1.10.0" + } +} \ No newline at end of file diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/not-found-template.directive.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/not-found-template.directive.ts new file mode 100644 index 0000000..dce5e7b --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/not-found-template.directive.ts @@ -0,0 +1,11 @@ +import { Directive, TemplateRef } from '@angular/core'; + + +@Directive({ + selector: '[psNgNotFoundTemplate]' +}) +export class NotFoundTemplateDirective { + + constructor(public template: TemplateRef) { } + +} diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-label-template.directive.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-label-template.directive.ts new file mode 100644 index 0000000..7c667a0 --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-label-template.directive.ts @@ -0,0 +1,9 @@ +import { Directive, TemplateRef } from '@angular/core'; + +@Directive({ + selector: '[psNgSelectLabel]' +}) +export class SelectLabelTemplateDirective { + constructor(public template: TemplateRef) { } + +} diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-option-template.directive.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-option-template.directive.ts new file mode 100644 index 0000000..1b79579 --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/directives/select-option-template.directive.ts @@ -0,0 +1,10 @@ +import { Directive, TemplateRef } from '@angular/core'; + +@Directive({ + selector: '[psNgSelectOption]' +}) +export class SelectOptionTemplateDirective { + + constructor(public template: TemplateRef) { } + +} diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.html b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.html new file mode 100644 index 0000000..f907a74 --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.html @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.scss b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.ts new file mode 100644 index 0000000..c976dfa --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/multi-select/multi-select.component.ts @@ -0,0 +1,153 @@ +import { Component, OnInit, ContentChild, ViewChild, Input, Output, EventEmitter, ChangeDetectorRef, forwardRef, OnDestroy } from '@angular/core'; +import { SelectLabelTemplateDirective } from '../directives/select-label-template.directive'; +import { IDataSource, ISimpleFilter } from '@poweredsoft/data'; +import { Observable, Subject, Subscription } from 'rxjs'; +import { map, distinctUntilChanged, debounceTime } from 'rxjs/operators'; +import { NgSelectComponent as SelectComponent } from '@ng-select/ng-select'; +import { NG_VALUE_ACCESSOR } from '@angular/forms'; +import { SelectOptionTemplateDirective } from '../directives/select-option-template.directive'; + +@Component({ + selector: 'ps-ng-multi-select', + templateUrl: './multi-select.component.html', + providers: [{ + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => MultiSelectComponent), + multi: true +}], + styleUrls: ['./multi-select.component.scss'] +}) +export class MultiSelectComponent implements OnInit,OnDestroy { + + + @ContentChild(SelectOptionTemplateDirective) optionTemplate: SelectOptionTemplateDirective; + @ContentChild(SelectLabelTemplateDirective) labelTemplate: SelectLabelTemplateDirective; + + @ViewChild(SelectComponent, { static: true }) selectComponent: SelectComponent; + @Input() dataSource: IDataSource; + @Input() searchPath: string; + @Input() searchType: string; + @Input() sortingPath: string; + @Input() serverFiltering:boolean; + @Input() bindLabel:string; + @Input() bindValue: string; + + @Output('change') changeEvent = new EventEmitter(); + + trackFn: (item: any) => any; + data$ : Observable; + isLoading:boolean = false; + searchInput$ = new Subject(); + + private _loadingSubscription: Subscription; + + constructor(private cdr: ChangeDetectorRef) { + this.trackFn = this.trackBy.bind(this); + + } + + trackBy(item: any) { + return this.dataSource.resolveIdField(item); + } + + valueChanged(event) { + this.changeEvent.emit(event); + } + + writeValue(obj: any): void { + this.selectComponent.writeValue(obj); + } + registerOnChange(fn: any): void { + this.selectComponent.registerOnChange(fn); + } + registerOnTouched(fn: any): void { + this.selectComponent.registerOnTouched(fn); + } + setDisabledState?(isDisabled: boolean): void { + if (this.selectComponent.setDisabledState) + this.selectComponent.setDisabledState(isDisabled); + } + ngOnDestroy(): void { + this._loadingSubscription.unsubscribe(); + } + + ngOnInit(): void { + this.dataFetching(); + this.detectLoading(); + if(this.serverFiltering){ + this.searchOnServer(); + }else{ + this.refreshDataSource(); + } + } + + dataFetching(){ + this.data$ = this.dataSource.data$.pipe( + map(t => { + if (t == null) + return []; + return t.data; + }) + ); + } + + detectLoading(){ + this._loadingSubscription = this.dataSource.loading$.subscribe(loading => { + this.isLoading = loading; + this.cdr.detectChanges(); + }); + } + + searchOnServer(){ + this.searchInput$.pipe( + distinctUntilChanged(), // emit the difference from previous input + debounceTime(500) // this is for delaying searching speed + ).subscribe(searchTerm => this.refreshDataSource(searchTerm, 1, 100)); // page: 1, pageSize: 50 + + this.refreshDataSource(); //send the query to server to sorting & filtering by default + } + + get selectedModel() { + return this.selectComponent.selectedItems.map(t => t.value); + } + + refreshDataSource(searchTerm:any = null, page:number = null, pageSize:number = null){ + let searchfilters:ISimpleFilter[] = null; + if(searchTerm){ + searchfilters = [{ + path: this.searchPath || this.bindLabel, + type: this.searchType || 'Contains', // Default: Contains + value: searchTerm + }] + } + this.dataSource.query({ + page: page, + pageSize: pageSize, + filters:searchfilters, + sorts:[ + {path: this.sortingPath || this.bindLabel, ascending: true} + ] + }) + } + + get hasOptionTemplate() { + return this.optionTemplate ? true : false; + } + + get selectOptionTemplate(){ + if (this.optionTemplate) + return this.optionTemplate.template; + return null; + } + + get hasLabelTemplate() { + return this.labelTemplate ? true : false; + } + + get selectLabelTemplate(){ + if (this.labelTemplate) + return this.labelTemplate.template; + return null; + } + +} diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.html b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.html new file mode 100644 index 0000000..f218c4f --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.html @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.scss b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.ts new file mode 100644 index 0000000..971ed6b --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ng-select/ng-select.component.ts @@ -0,0 +1,170 @@ +import { Component, OnInit, ContentChild, ViewChild, Input, Output, EventEmitter, ChangeDetectorRef, forwardRef, OnDestroy } from '@angular/core'; +import { SelectLabelTemplateDirective } from '../directives/select-label-template.directive'; +import { IDataSource, ISimpleFilter } from '@poweredsoft/data'; +import { Observable, Subject, Subscription } from 'rxjs'; +import { map, distinctUntilChanged, debounceTime } from 'rxjs/operators'; +import { NgSelectComponent as SelectComponent } from '@ng-select/ng-select'; +import { NG_VALUE_ACCESSOR } from '@angular/forms'; +import { SelectOptionTemplateDirective } from '../directives/select-option-template.directive'; +import { NotFoundTemplateDirective } from '../directives/not-found-template.directive'; + + +@Component({ + selector: 'ps-ng-select', + templateUrl: './ng-select.component.html', + providers: [{ + provide: NG_VALUE_ACCESSOR, + useExisting: forwardRef(() => NgSelectComponent), + multi: true +}], + styleUrls: ['./ng-select.component.scss'] +}) +export class NgSelectComponent implements OnInit,OnDestroy { + + @ContentChild(SelectOptionTemplateDirective) optionTemplate: SelectOptionTemplateDirective; + @ContentChild(SelectLabelTemplateDirective) labelTemplate: SelectLabelTemplateDirective; + @ContentChild(NotFoundTemplateDirective) notFoundTemplate: NotFoundTemplateDirective; + + + + @ViewChild(SelectComponent, { static: true }) selectComponent: SelectComponent; + @Input() dataSource: IDataSource; + @Input() searchPath: string; + @Input() searchType: string; + @Input() sortingPath: string; + @Input() serverFiltering:boolean; + @Input() bindLabel:string; + @Input() bindValue: string; + + @Output('change') changeEvent = new EventEmitter(); + + trackFn: (item: any) => any; + data$ : Observable; + isLoading:boolean = false; + searchInput$ = new Subject(); + + private _loadingSubscription: Subscription; + + constructor(private cdr: ChangeDetectorRef) { + this.trackFn = this.trackBy.bind(this); + + } + + ngOnInit(): void { + this.dataFetching(); + this.detectLoading(); + + if(this.serverFiltering){ + this.searchOnServer(); + }else{ + this.refreshDataSource(); + } + } + + + valueChanged(event) { + this.changeEvent.emit(event); + } + + writeValue(obj: any): void { + this.selectComponent.writeValue(obj); + } + registerOnChange(fn: any): void { + this.selectComponent.registerOnChange(fn); + } + registerOnTouched(fn: any): void { + this.selectComponent.registerOnTouched(fn); + } + setDisabledState?(isDisabled: boolean): void { + if (this.selectComponent.setDisabledState) + this.selectComponent.setDisabledState(isDisabled); + } + + trackBy(item: any) { + return this.dataSource.resolveIdField(item); + } + + ngOnDestroy(): void { + this._loadingSubscription.unsubscribe(); + } + + + dataFetching(){ + this.data$ = this.dataSource.data$.pipe( + map(t => { + if (t == null) + return []; + return t.data; + }) + ); + } + + detectLoading(){ + this._loadingSubscription = this.dataSource.loading$.subscribe(loading => { + this.isLoading = loading; + this.cdr.detectChanges(); + }); + } + + searchOnServer(){ + this.searchInput$.pipe( + distinctUntilChanged(), // emit the difference from previous input + debounceTime(500) // this is for delaying searching speed + ).subscribe(searchTerm => this.refreshDataSource(searchTerm, 1, 100)); // page: 1, pageSize: 50 + + this.refreshDataSource(); //send the query to server to sorting & filtering by default + } + + get selectedModel() { + return this.selectComponent.hasValue ? this.selectComponent.selectedItems[0] : null; + } + + refreshDataSource(searchTerm:any = null, page:number = null, pageSize:number = null){ + let searchfilters:ISimpleFilter[] = null; + if(searchTerm){ + searchfilters = [{ + path: this.searchPath || this.bindLabel, + type: this.searchType || 'Contains', // Default: Contains + value: searchTerm + }] + } + this.dataSource.query({ + page: page, + pageSize: pageSize, + filters:searchfilters, + sorts:[ + {path: this.sortingPath || this.bindLabel, ascending: true} + ] + }) + } + + get hasOptionTemplate() { + return this.optionTemplate ? true : false; + } + + get selectOptionTemplate(){ + if (this.optionTemplate) + return this.optionTemplate.template; + return null; + } + + get hasLabelTemplate() { + return this.labelTemplate ? true : false; + } + + get selectLabelTemplate(){ + if (this.labelTemplate) + return this.labelTemplate.template; + return null; + } + + get hasNotFoundTemplate() { + return this.notFoundTemplate ? true : false; + } + + get selectNotFoundTemplate(){ + if(this.notFoundTemplate) + return this.notFoundTemplate.template; + return null; + } +} diff --git a/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ps-ng-select.module.ts b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ps-ng-select.module.ts new file mode 100644 index 0000000..3b89b59 --- /dev/null +++ b/projects/poweredsoft/ng-select/src/lib/ps-ng-select/ps-ng-select.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { NgSelectComponent } from './ng-select/ng-select.component'; +import { MultiSelectComponent } from './multi-select/multi-select.component'; +import { FormsModule } from '@angular/forms'; +import { NgSelectModule } from '@ng-select/ng-select'; +import { SelectLabelTemplateDirective } from './directives/select-label-template.directive'; +import { SelectOptionTemplateDirective } from './directives/select-option-template.directive'; +import { NotFoundTemplateDirective } from './directives/not-found-template.directive'; + + + +@NgModule({ + declarations: [NgSelectComponent, MultiSelectComponent, SelectLabelTemplateDirective, SelectOptionTemplateDirective, NotFoundTemplateDirective], + imports: [ + CommonModule, + FormsModule, + NgSelectModule, + ], + exports:[ + NgSelectComponent, + MultiSelectComponent, + SelectLabelTemplateDirective, + SelectOptionTemplateDirective, + NotFoundTemplateDirective + ] +}) +export class PsNgSelectModule { }//NGSELECT diff --git a/projects/poweredsoft/ng-select/src/public-api.ts b/projects/poweredsoft/ng-select/src/public-api.ts new file mode 100644 index 0000000..7a883ee --- /dev/null +++ b/projects/poweredsoft/ng-select/src/public-api.ts @@ -0,0 +1,10 @@ +/* + * Public API Surface of ng-select + */ + +export * from './lib/ps-ng-select/ps-ng-select.module'; +export * from './lib/ps-ng-select/ng-select/ng-select.component'; +export * from './lib/ps-ng-select/multi-select/multi-select.component'; +export * from './lib/ps-ng-select/directives/select-label-template.directive'; +export * from './lib/ps-ng-select/directives/select-option-template.directive'; +export * from './lib/ps-ng-select/directives/not-found-template.directive'; diff --git a/projects/poweredsoft/ng-select/src/test.ts b/projects/poweredsoft/ng-select/src/test.ts new file mode 100644 index 0000000..303b32a --- /dev/null +++ b/projects/poweredsoft/ng-select/src/test.ts @@ -0,0 +1,26 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/zone'; +import 'zone.js/dist/zone-testing'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: { + context(path: string, deep?: boolean, filter?: RegExp): { + keys(): string[]; + (id: string): T; + }; +}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/projects/poweredsoft/ng-select/tsconfig.lib.json b/projects/poweredsoft/ng-select/tsconfig.lib.json new file mode 100644 index 0000000..38a679b --- /dev/null +++ b/projects/poweredsoft/ng-select/tsconfig.lib.json @@ -0,0 +1,23 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../../../out-tsc/lib", + "target": "es2015", + "declaration": true, + "inlineSources": true, + "types": [], + "lib": [ + "dom", + "es2018" + ] + }, + "angularCompilerOptions": { + "skipTemplateCodegen": true, + "strictMetadataEmit": true, + "enableResourceInlining": true + }, + "exclude": [ + "src/test.ts", + "**/*.spec.ts" + ] +} diff --git a/projects/poweredsoft/ng-select/tsconfig.lib.prod.json b/projects/poweredsoft/ng-select/tsconfig.lib.prod.json new file mode 100644 index 0000000..cbae794 --- /dev/null +++ b/projects/poweredsoft/ng-select/tsconfig.lib.prod.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.lib.json", + "angularCompilerOptions": { + "enableIvy": false + } +} diff --git a/projects/poweredsoft/ng-select/tsconfig.spec.json b/projects/poweredsoft/ng-select/tsconfig.spec.json new file mode 100644 index 0000000..4acf941 --- /dev/null +++ b/projects/poweredsoft/ng-select/tsconfig.spec.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../../../out-tsc/spec", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "src/test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/projects/poweredsoft/ng-select/tslint.json b/projects/poweredsoft/ng-select/tslint.json new file mode 100644 index 0000000..3aa2f4c --- /dev/null +++ b/projects/poweredsoft/ng-select/tslint.json @@ -0,0 +1,17 @@ +{ + "extends": "../../../tslint.json", + "rules": { + "directive-selector": [ + true, + "attribute", + "lib", + "camelCase" + ], + "component-selector": [ + true, + "element", + "lib", + "kebab-case" + ] + } +} diff --git a/projects/poweredsoft/ngx-bootstrap/package.json b/projects/poweredsoft/ngx-bootstrap/package.json index a3c3207..f84b055 100644 --- a/projects/poweredsoft/ngx-bootstrap/package.json +++ b/projects/poweredsoft/ngx-bootstrap/package.json @@ -1,6 +1,6 @@ { "name": "@poweredsoft/ngx-bootstrap", - "version": "0.0.1", + "version": "0.0.3", "peerDependencies": { "@angular/common": "^9.1.9", "@angular/core": "^9.1.9", diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts index 0940f87..c80c5da 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal.module.ts @@ -3,7 +3,7 @@ import { CommonModule } from '@angular/common'; import { ModalModule } from 'ngx-bootstrap/modal'; import { CommandModalDirective } from './directives/command-modal.directive'; import { CommandModalComponent } from './command-modal/command-modal.component'; -import { InputValidatorDirective } from './directives/input-validator.directive'; + import { FormsModule } from '@angular/forms'; @NgModule({ @@ -12,7 +12,7 @@ import { FormsModule } from '@angular/forms'; ModalModule.forRoot(), FormsModule ], - declarations: [CommandModalDirective, CommandModalComponent, InputValidatorDirective], + declarations: [CommandModalDirective, CommandModalComponent], exports: [CommandModalDirective] }) export class CommandModalModule { } diff --git a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html index 2c11963..875fd6d 100644 --- a/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html +++ b/projects/poweredsoft/ngx-bootstrap/src/lib/command-modal/command-modal/command-modal.component.html @@ -12,7 +12,7 @@