From 25a358ac04236b90f76911b86ea42613d4034b0c Mon Sep 17 00:00:00 2001 From: evansmwendwa Date: Fri, 31 Mar 2017 02:12:09 +0300 Subject: [PATCH 1/4] add support for emiting picker label --- .../daterangepicker.component.ts | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/app/daterangepicker/daterangepicker.component.ts diff --git a/src/app/daterangepicker/daterangepicker.component.ts b/src/app/daterangepicker/daterangepicker.component.ts new file mode 100644 index 0000000..f1c0f72 --- /dev/null +++ b/src/app/daterangepicker/daterangepicker.component.ts @@ -0,0 +1,102 @@ +import { Directive, OnInit, AfterViewInit, Input, Output, EventEmitter, ElementRef, OnDestroy } from '@angular/core'; +//import { ControlValueAccessor } from '@angular/forms'; +import { DaterangepickerConfig } from './config.service'; + +import * as $ from "jquery"; +import * as moment from 'moment'; +import 'bootstrap-daterangepicker'; + +@Directive({ + selector: '[daterangepicker]' +}) +export class DaterangePickerComponent implements AfterViewInit, OnDestroy { + + @Input() options: any = {}; + @Output() selected = new EventEmitter(); + + // daterangepicker events + @Output() cancelDaterangepicker = new EventEmitter(); + @Output() applyDaterangepicker = new EventEmitter(); + @Output() hideCalendarDaterangepicker = new EventEmitter(); + @Output() showCalendarDaterangepicker = new EventEmitter(); + @Output() hideDaterangepicker = new EventEmitter(); + @Output() showDaterangepicker = new EventEmitter(); + + public datePicker: any; + + constructor(private input: ElementRef, private config: DaterangepickerConfig) { } + + ngAfterViewInit() { + + let targetOptions: any = Object.assign({}, this.config.settings, this.options); + + // tell config service to embed the css + this.config.embedCSS(); + + // cast $ to any to avoid jquery type checking + //$(this.input.nativeElement).daterangepicker(targetOptions, this.callback.bind(this)); + ($(this.input.nativeElement)).daterangepicker(targetOptions, this.callback.bind(this)); + + this.datePicker = ($(this.input.nativeElement)).data('daterangepicker'); + + $(this.input.nativeElement).on('cancel.daterangepicker', + (e:any, picker:any) => { + let event = { event: e, picker: picker }; + this.cancelDaterangepicker.emit(event); + } + ); + + $(this.input.nativeElement).on('apply.daterangepicker', + (e:any, picker:any) => { + let event = { event: e, picker: picker }; + this.applyDaterangepicker.emit(event); + } + ); + + $(this.input.nativeElement).on('hideCalendar.daterangepicker', + (e:any, picker:any) => { + let event = { event: e, picker: picker }; + this.hideCalendarDaterangepicker.emit(event); + } + ); + + $(this.input.nativeElement).on('showCalendar.daterangepicker', + (e:any, picker:any) => { + let event = { event: e, picker: picker }; + this.showCalendarDaterangepicker.emit(event); + } + ); + + $(this.input.nativeElement).on('hide.daterangepicker', + (e:any, picker:any) => { + let event = { event: e, picker: picker }; + this.hideDaterangepicker.emit(event); + } + ); + + $(this.input.nativeElement).on('show.daterangepicker', + (e:any, picker:any) => { + let event = { event: e, picker: picker }; + this.showDaterangepicker.emit(event); + } + ); + } + + private callback(start?: any, end?: any, label?: any): void { + let obj = { + start: start, + end: end, + label: label + }; + + this.selected.emit(obj); + } + + ngOnDestroy() { + try { + ($(this.input.nativeElement)).data('daterangepicker').remove(); + } catch(e) { + console.log(e.message); + } + } +} From 585e50020d2a972cde380f3ead5cf5e5d532224f Mon Sep 17 00:00:00 2001 From: evansmwendwa Date: Fri, 31 Mar 2017 02:13:09 +0300 Subject: [PATCH 2/4] added label usage in example --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9386f88..a14e7aa 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ export class AppComponent { public selectedDate(value: any) { this.daterange.start = value.start; this.daterange.end = value.end; + this.daterange.label = value.label; } } ``` From 9ec72eef323cdda97779da6544e59bbb2f0a1ed1 Mon Sep 17 00:00:00 2001 From: evansmwendwa Date: Fri, 31 Mar 2017 02:14:03 +0300 Subject: [PATCH 3/4] project migration to angular-cli and angular 4 --- .angular-cli.json | 59 +++++++++ .editorconfig | 16 +++ .gitignore | 4 +- e2e/app.e2e-spec.ts | 14 +++ e2e/app.po.ts | 11 ++ e2e/tsconfig.e2e.json | 12 ++ karma.conf.js | 44 +++++++ package.json | 55 ++++++--- protractor.conf.js | 30 +++++ src/app/app.component.css | 3 + src/app/app.component.html | 75 +++++++++++ src/app/app.component.spec.ts | 32 +++++ src/app/app.component.ts | 82 +++++++++++++ src/app/app.module.ts | 23 ++++ .../daterangepicker/config.service.ts | 0 .../daterangepicker/daterangepicker.module.ts | 0 src/assets/.gitkeep | 0 .../daterangepicker.component.ts | 101 --------------- src/environments/environment.prod.ts | 3 + src/environments/environment.ts | 8 ++ src/favicon.ico | Bin 0 -> 5430 bytes src/index.html | 15 +++ src/main.ts | 11 ++ src/polyfills.ts | 68 ++++++++++ src/styles.css | 1 + src/test.ts | 32 +++++ src/tsconfig.app.json | 13 ++ src/tsconfig.spec.json | 20 +++ src/typings.d.ts | 5 + tsconfig-aot.json | 38 +++--- tsconfig.json | 33 ++--- tslint.json | 116 ++++++++++++++++++ 32 files changed, 768 insertions(+), 156 deletions(-) create mode 100644 .angular-cli.json create mode 100644 .editorconfig create mode 100644 e2e/app.e2e-spec.ts create mode 100644 e2e/app.po.ts create mode 100644 e2e/tsconfig.e2e.json create mode 100644 karma.conf.js create mode 100644 protractor.conf.js create mode 100644 src/app/app.component.css create mode 100644 src/app/app.component.html create mode 100644 src/app/app.component.spec.ts create mode 100644 src/app/app.component.ts create mode 100644 src/app/app.module.ts rename src/{ => app}/daterangepicker/config.service.ts (100%) rename src/{ => app}/daterangepicker/daterangepicker.module.ts (100%) create mode 100644 src/assets/.gitkeep delete mode 100644 src/daterangepicker/daterangepicker.component.ts create mode 100644 src/environments/environment.prod.ts create mode 100644 src/environments/environment.ts create mode 100644 src/favicon.ico create mode 100644 src/index.html create mode 100644 src/main.ts create mode 100644 src/polyfills.ts create mode 100644 src/styles.css create mode 100644 src/test.ts create mode 100644 src/tsconfig.app.json create mode 100644 src/tsconfig.spec.json create mode 100644 src/typings.d.ts create mode 100644 tslint.json diff --git a/.angular-cli.json b/.angular-cli.json new file mode 100644 index 0000000..49dfabd --- /dev/null +++ b/.angular-cli.json @@ -0,0 +1,59 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "project": { + "name": "ci" + }, + "apps": [ + { + "root": "src", + "outDir": "dist", + "assets": [ + "assets", + "favicon.ico" + ], + "index": "index.html", + "main": "main.ts", + "polyfills": "polyfills.ts", + "test": "test.ts", + "tsconfig": "tsconfig.app.json", + "testTsconfig": "tsconfig.spec.json", + "prefix": "app", + "styles": [ + "styles.css" + ], + "scripts": [ + + ], + "environmentSource": "environments/environment.ts", + "environments": { + "dev": "environments/environment.ts", + "prod": "environments/environment.prod.ts" + } + } + ], + "e2e": { + "protractor": { + "config": "./protractor.conf.js" + } + }, + "lint": [ + { + "project": "src/tsconfig.app.json" + }, + { + "project": "src/tsconfig.spec.json" + }, + { + "project": "e2e/tsconfig.e2e.json" + } + ], + "test": { + "karma": { + "config": "./karma.conf.js" + } + }, + "defaults": { + "styleExt": "css", + "component": {} + } +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1729b60 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = 0 +trim_trailing_whitespace = false + +[*.{json,config.js}] +indent_size = 2 diff --git a/.gitignore b/.gitignore index e921c6a..58c6ea2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,8 @@ jspm_packages bower_components aot/* lib/* -src/daterangepicker/*.json -src/daterangepicker/*.ngfactory.ts +src/app/daterangepicker/*.json +src/app/daterangepicker/*.ngfactory.ts yarn.lock # Ignore Compass/SASS cache diff --git a/e2e/app.e2e-spec.ts b/e2e/app.e2e-spec.ts new file mode 100644 index 0000000..89e2ad7 --- /dev/null +++ b/e2e/app.e2e-spec.ts @@ -0,0 +1,14 @@ +import { CiPage } from './app.po'; + +describe('ci App', () => { + let page: CiPage; + + beforeEach(() => { + page = new CiPage(); + }); + + it('should display message saying app works', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('app works!'); + }); +}); diff --git a/e2e/app.po.ts b/e2e/app.po.ts new file mode 100644 index 0000000..39dcbe5 --- /dev/null +++ b/e2e/app.po.ts @@ -0,0 +1,11 @@ +import { browser, element, by } from 'protractor'; + +export class CiPage { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/e2e/tsconfig.e2e.json b/e2e/tsconfig.e2e.json new file mode 100644 index 0000000..ac7a373 --- /dev/null +++ b/e2e/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es5", + "types":[ + "jasmine", + "node" + ] + } +} diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000..84b4cd5 --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,44 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/0.13/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular/cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular/cli/plugins/karma') + ], + client:{ + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + files: [ + { pattern: './src/test.ts', watched: false } + ], + preprocessors: { + './src/test.ts': ['@angular/cli'] + }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, + coverageIstanbulReporter: { + reports: [ 'html', 'lcovonly' ], + fixWebpackSourcePaths: true + }, + angularCli: { + environment: 'dev' + }, + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'coverage-istanbul'] + : ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/package.json b/package.json index 9e894ef..8e742a4 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,13 @@ "version": "2.0.5", "description": "Angular 2 DaterangePicker component", "scripts": { - "watch": "tsc -p src -w", - "build": "rm -rf lib && tsc -p .", - "ngc-build": "rm -rf lib && \"node_modules/.bin/ngc\" -p tsconfig.json" + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e", + "ngc-build": "rm -rf lib && \"node_modules/.bin/ngc\" -p tsconfig-aot.json" }, "repository": { "type": "git", @@ -32,19 +36,36 @@ "moment": "^2.16.0" }, "devDependencies": { - "@angular/common": "~2.4.0", - "@angular/compiler": "~2.4.0", - "@angular/compiler-cli": "^2.4.9", - "@angular/core": "~2.4.0", - "@angular/forms": "~2.4.0", - "@angular/http": "~2.4.0", - "@angular/platform-browser": "~2.4.0", - "@angular/platform-browser-dynamic": "~2.4.0", - "@angular/platform-server": "^2.4.9", - "@angular/router": "~3.4.0", - "rxjs": "5.0.1", - "typescript": "^2.0.10", - "zone.js": "^0.7.4", - "@types/es6-shim": "^0.31.32" + "@angular/cli": "1.0.0", + "@angular/common": "^4.0.0", + "@angular/compiler": "^4.0.0", + "@angular/compiler-cli": "^4.0.1", + "@angular/core": "^4.0.0", + "@angular/forms": "^4.0.0", + "@angular/http": "^4.0.0", + "@angular/platform-browser": "^4.0.0", + "@angular/platform-browser-dynamic": "^4.0.0", + "@angular/platform-server": "^4.0.1", + "@angular/router": "^4.0.0", + + "@types/jasmine": "2.5.38", + "@types/node": "~6.0.60", + "codelyzer": "~2.0.0", + "core-js": "^2.4.1", + "jasmine-core": "~2.5.2", + "jasmine-spec-reporter": "~3.2.0", + "karma": "~1.4.1", + "karma-chrome-launcher": "~2.0.0", + "karma-cli": "~1.0.1", + "karma-coverage-istanbul-reporter": "^0.2.0", + "karma-jasmine": "~1.1.0", + "karma-jasmine-html-reporter": "^0.2.2", + "moment": "^2.18.1", + "protractor": "~5.1.0", + "rxjs": "^5.1.0", + "ts-node": "~2.0.0", + "tslint": "~4.5.0", + "typescript": "~2.2.0", + "zone.js": "^0.8.4" } } diff --git a/protractor.conf.js b/protractor.conf.js new file mode 100644 index 0000000..1c5e1e5 --- /dev/null +++ b/protractor.conf.js @@ -0,0 +1,30 @@ +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + beforeLaunch: function() { + require('ts-node').register({ + project: 'e2e/tsconfig.e2e.json' + }); + }, + onPrepare() { + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; diff --git a/src/app/app.component.css b/src/app/app.component.css new file mode 100644 index 0000000..da49741 --- /dev/null +++ b/src/app/app.component.css @@ -0,0 +1,3 @@ +.main-container{ + max-width: 650px; +} diff --git a/src/app/app.component.html b/src/app/app.component.html new file mode 100644 index 0000000..1273502 --- /dev/null +++ b/src/app/app.component.html @@ -0,0 +1,75 @@ +
+

ng2-daterangepicker (Demos)

+

+ +
+

Using Datepicker with Events

+
+
+                {{ eventLog }}
+            
+
+
+ +
+ + {{ mainInput.start | date:'M/dd/y' }} - {{ mainInput.end| date:'M/dd/y' }} + + + + +
+
+ +

+ Above example demonstrates how to tap to the events fired by the daterangepicker +

+ +
+ +

Single Datepicker

+ +
+ +
+ + {{ singleDate | date:'M/dd/y' }} + + + + +
+
+ +

+ Above example demonstrates how to tap to the events fired by the daterangepicker +

+ +
+ +

Different Presets

+ +
+ +
+ + {{ dateInput.start | date:'M/dd/y' }} - {{ dateInput.end| date:'M/dd/y' }} + + + + +
+ +
+ +
{{ dateInput | json }}
+
+
+
+ +
diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts new file mode 100644 index 0000000..c740bcd --- /dev/null +++ b/src/app/app.component.spec.ts @@ -0,0 +1,32 @@ +import { TestBed, async } from '@angular/core/testing'; + +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ + AppComponent + ], + }).compileComponents(); + })); + + it('should create the app', async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + })); + + it(`should have as title 'app works!'`, async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app.title).toEqual('app works!'); + })); + + it('should render title in a h1 tag', async(() => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector('h1').textContent).toContain('app works!'); + })); +}); diff --git a/src/app/app.component.ts b/src/app/app.component.ts new file mode 100644 index 0000000..5fd09de --- /dev/null +++ b/src/app/app.component.ts @@ -0,0 +1,82 @@ +import { Component, OnInit } from '@angular/core'; +import { DaterangepickerConfig } from './daterangepicker/config.service'; + +import * as moment from 'moment'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] +}) +export class AppComponent implements OnInit { + + public dateInputs: any = [ + { + start: moment().subtract(12, 'month'), + end: moment().subtract(6, 'month') + }, + { + start: moment().subtract(9, 'month'), + end: moment().subtract(6, 'month') + }, + { + start: moment().subtract(4, 'month'), + end: moment() + }, + { + start: moment(), + end: moment().add(5, 'month'), + } + ]; + + public mainInput = { + start: moment().subtract(12, 'month'), + end: moment().subtract(6, 'month') + } + + public singlePicker = { + singleDatePicker: true, + showDropdowns: true, + "opens": "left" + } + + public singleDate: any; + + public eventLog = ''; + + constructor(private daterangepickerOptions: DaterangepickerConfig) { + this.daterangepickerOptions.settings = { + locale: { format: 'YYYY-MM-DD' }, + alwaysShowCalendars: false, + ranges: { + 'Last Month': [moment().subtract(1, 'month'), moment()], + 'Last 3 Months': [moment().subtract(4, 'month'), moment()], + 'Last 6 Months': [moment().subtract(6, 'month'), moment()], + 'Last 12 Months': [moment().subtract(12, 'month'), moment()], + } + }; + } + + ngOnInit() { } + + private selectedDate(value: any, dateInput: any) { + dateInput.start = value.start; + dateInput.end = value.end; + dateInput.label = value.label; + } + + private singleSelect(value: any) { + this.singleDate = value.start; + } + + private applyDate(value: any, dateInput: any) { + dateInput.start = value.start; + dateInput.end = value.end; + dateInput.label = value.label; + } + + public calendarEventsHandler(e: any) { + console.log(e); + this.eventLog += '\nEvent Fired: ' + e.event.type; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts new file mode 100644 index 0000000..c29ba3d --- /dev/null +++ b/src/app/app.module.ts @@ -0,0 +1,23 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { HttpModule } from '@angular/http'; + +import { Daterangepicker } from './daterangepicker/daterangepicker.module'; + +import { AppComponent } from './app.component'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ + BrowserModule, + FormsModule, + HttpModule, + Daterangepicker + ], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/src/daterangepicker/config.service.ts b/src/app/daterangepicker/config.service.ts similarity index 100% rename from src/daterangepicker/config.service.ts rename to src/app/daterangepicker/config.service.ts diff --git a/src/daterangepicker/daterangepicker.module.ts b/src/app/daterangepicker/daterangepicker.module.ts similarity index 100% rename from src/daterangepicker/daterangepicker.module.ts rename to src/app/daterangepicker/daterangepicker.module.ts diff --git a/src/assets/.gitkeep b/src/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/daterangepicker/daterangepicker.component.ts b/src/daterangepicker/daterangepicker.component.ts deleted file mode 100644 index 453a4ed..0000000 --- a/src/daterangepicker/daterangepicker.component.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { Directive, OnInit, AfterViewInit, Input, Output, EventEmitter, ElementRef, OnDestroy } from '@angular/core'; -//import { ControlValueAccessor } from '@angular/forms'; -import { DaterangepickerConfig } from './config.service'; - -import * as $ from "jquery"; -import * as moment from 'moment'; -import 'bootstrap-daterangepicker'; - -@Directive({ - selector: '[daterangepicker]' -}) -export class DaterangePickerComponent implements AfterViewInit, OnDestroy { - - @Input() options: any = {}; - @Output() selected = new EventEmitter(); - - // daterangepicker events - @Output() cancelDaterangepicker = new EventEmitter(); - @Output() applyDaterangepicker = new EventEmitter(); - @Output() hideCalendarDaterangepicker = new EventEmitter(); - @Output() showCalendarDaterangepicker = new EventEmitter(); - @Output() hideDaterangepicker = new EventEmitter(); - @Output() showDaterangepicker = new EventEmitter(); - - public datePicker: any; - - constructor(private input: ElementRef, private config: DaterangepickerConfig) { } - - ngAfterViewInit() { - - let targetOptions: any = Object.assign({}, this.config.settings, this.options); - - // tell config service to embed the css - this.config.embedCSS(); - - // cast $ to any to avoid jquery type checking - //$(this.input.nativeElement).daterangepicker(targetOptions, this.callback.bind(this)); - ($(this.input.nativeElement)).daterangepicker(targetOptions, this.callback.bind(this)); - - this.datePicker = ($(this.input.nativeElement)).data('daterangepicker'); - - $(this.input.nativeElement).on('cancel.daterangepicker', - (e:any, picker:any) => { - let event = { event: e, picker: picker }; - this.cancelDaterangepicker.emit(event); - } - ); - - $(this.input.nativeElement).on('apply.daterangepicker', - (e:any, picker:any) => { - let event = { event: e, picker: picker }; - this.applyDaterangepicker.emit(event); - } - ); - - $(this.input.nativeElement).on('hideCalendar.daterangepicker', - (e:any, picker:any) => { - let event = { event: e, picker: picker }; - this.hideCalendarDaterangepicker.emit(event); - } - ); - - $(this.input.nativeElement).on('showCalendar.daterangepicker', - (e:any, picker:any) => { - let event = { event: e, picker: picker }; - this.showCalendarDaterangepicker.emit(event); - } - ); - - $(this.input.nativeElement).on('hide.daterangepicker', - (e:any, picker:any) => { - let event = { event: e, picker: picker }; - this.hideDaterangepicker.emit(event); - } - ); - - $(this.input.nativeElement).on('show.daterangepicker', - (e:any, picker:any) => { - let event = { event: e, picker: picker }; - this.showDaterangepicker.emit(event); - } - ); - } - - private callback(start?: any, end?: any): void { - let obj = { - start: start, - end: end - }; - - this.selected.emit(obj); - } - - ngOnDestroy() { - try { - ($(this.input.nativeElement)).data('daterangepicker').remove(); - } catch(e) { - console.log(e.message); - } - } -} diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts new file mode 100644 index 0000000..3612073 --- /dev/null +++ b/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..b7f639a --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,8 @@ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `.angular-cli.json`. + +export const environment = { + production: false +}; diff --git a/src/favicon.ico b/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8081c7ceaf2be08bf59010158c586170d9d2d517 GIT binary patch literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- + + + + Ci + + + + + + + + Loading... + + diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..a9ca1ca --- /dev/null +++ b/src/main.ts @@ -0,0 +1,11 @@ +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/src/polyfills.ts b/src/polyfills.ts new file mode 100644 index 0000000..53bdaf1 --- /dev/null +++ b/src/polyfills.ts @@ -0,0 +1,68 @@ +/** + * This file includes polyfills needed by Angular and is loaded before the app. + * You can add your own extra polyfills to this file. + * + * This file is divided into 2 sections: + * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. + * 2. Application imports. Files imported after ZoneJS that should be loaded before your main + * file. + * + * The current setup is for so-called "evergreen" browsers; the last versions of browsers that + * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), + * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. + * + * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html + */ + +/*************************************************************************************************** + * BROWSER POLYFILLS + */ + +/** IE9, IE10 and IE11 requires all of the following polyfills. **/ +// import 'core-js/es6/symbol'; +// import 'core-js/es6/object'; +// import 'core-js/es6/function'; +// import 'core-js/es6/parse-int'; +// import 'core-js/es6/parse-float'; +// import 'core-js/es6/number'; +// import 'core-js/es6/math'; +// import 'core-js/es6/string'; +// import 'core-js/es6/date'; +// import 'core-js/es6/array'; +// import 'core-js/es6/regexp'; +// import 'core-js/es6/map'; +// import 'core-js/es6/set'; + +/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +// import 'classlist.js'; // Run `npm install --save classlist.js`. + +/** IE10 and IE11 requires the following to support `@angular/animation`. */ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + +/** Evergreen browsers require these. **/ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; + + +/** ALL Firefox browsers require the following to support `@angular/animation`. **/ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + + +/*************************************************************************************************** + * Zone JS is required by Angular itself. + */ +import 'zone.js/dist/zone'; // Included with Angular CLI. + + + +/*************************************************************************************************** + * APPLICATION IMPORTS + */ + +/** + * Date, currency, decimal and percent pipes. + * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 + */ +// import 'intl'; // Run `npm install --save intl`. diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..90d4ee0 --- /dev/null +++ b/src/styles.css @@ -0,0 +1 @@ +/* You can add global styles to this file, and also import other style files */ diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 0000000..9bf7226 --- /dev/null +++ b/src/test.ts @@ -0,0 +1,32 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/long-stack-trace-zone'; +import 'zone.js/dist/proxy.js'; +import 'zone.js/dist/sync-test'; +import 'zone.js/dist/jasmine-patch'; +import 'zone.js/dist/async-test'; +import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. +declare var __karma__: any; +declare var require: any; + +// Prevent Karma from running prematurely. +__karma__.loaded = function () {}; + +// 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); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json new file mode 100644 index 0000000..5e2507d --- /dev/null +++ b/src/tsconfig.app.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "module": "es2015", + "baseUrl": "", + "types": [] + }, + "exclude": [ + "test.ts", + "**/*.spec.ts" + ] +} diff --git a/src/tsconfig.spec.json b/src/tsconfig.spec.json new file mode 100644 index 0000000..510e3f1 --- /dev/null +++ b/src/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/spec", + "module": "commonjs", + "target": "es5", + "baseUrl": "", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/src/typings.d.ts b/src/typings.d.ts new file mode 100644 index 0000000..ef5c7bd --- /dev/null +++ b/src/typings.d.ts @@ -0,0 +1,5 @@ +/* SystemJS module definition */ +declare var module: NodeModule; +interface NodeModule { + id: string; +} diff --git a/tsconfig-aot.json b/tsconfig-aot.json index 56bc4a7..d12362d 100644 --- a/tsconfig-aot.json +++ b/tsconfig-aot.json @@ -1,22 +1,20 @@ { - "compilerOptions": { - "target": "es5", - "module": "es2015", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "lib": ["es2015", "dom"], - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true - }, - - "include": [ - "src/**/*" - ], - - "angularCompilerOptions": { - "genDir": "aot", - "skipMetadataEmit" : false - } + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": true, + "noImplicitAny": true, + "suppressImplicitAnyIndexErrors": true, + "declaration": true, + "outDir": "lib", + "rootDir": "src/app/", + "lib": ["es6", "dom"] + }, + "include": [ + "src/app/daterangepicker/**/*" + ] } diff --git a/tsconfig.json b/tsconfig.json index dd56716..a35a8ee 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,19 +1,20 @@ { - "compilerOptions": { - "target": "es5", - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "removeComments": true, - "noImplicitAny": true, - "suppressImplicitAnyIndexErrors": true, - "declaration": true, - "outDir": "lib", - "rootDir": "src" - }, - "include": [ - "src/**/*" + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "baseUrl": "src", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es5", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2016", + "dom" ] + } } diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..9113f13 --- /dev/null +++ b/tslint.json @@ -0,0 +1,116 @@ +{ + "rulesDirectory": [ + "node_modules/codelyzer" + ], + "rules": { + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "import-blacklist": [true, "rxjs"], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [true, "ignore-params"], + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": true, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true + } +} From 40aa90ea1153634adb35af9b28fca640ea0b680f Mon Sep 17 00:00:00 2001 From: evansmwendwa Date: Fri, 31 Mar 2017 03:18:11 +0300 Subject: [PATCH 4/4] 2.0.6 --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 8e742a4..c3e1db4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng2-daterangepicker", - "version": "2.0.5", + "version": "2.0.6", "description": "Angular 2 DaterangePicker component", "scripts": { "ng": "ng", @@ -47,7 +47,6 @@ "@angular/platform-browser-dynamic": "^4.0.0", "@angular/platform-server": "^4.0.1", "@angular/router": "^4.0.0", - "@types/jasmine": "2.5.38", "@types/node": "~6.0.60", "codelyzer": "~2.0.0",