Skip to content

Commit

Permalink
feat(theme): add new DatePicker component (#732)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa committed Sep 20, 2018
1 parent b5b02e9 commit c00cc23
Show file tree
Hide file tree
Showing 84 changed files with 3,058 additions and 610 deletions.
47 changes: 47 additions & 0 deletions docs/assets/images/components/datepicker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/structure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ export const structure = [
'NbSelectComponent',
],
},
{
type: 'tabs',
name: 'Datepicker',
icon: 'datepicker.svg',
source: [
'NbDatepickerDirective',
'NbDatepickerComponent',
'NbRangepickerComponent',
],
},
{
type: 'group',
name: 'Modals & Overlays',
Expand Down
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"bootstrap": "4.0.0",
"colors.js": "1.2.4",
"core-js": "2.5.1",
"date-fns": "^2.0.0-alpha.16",
"docsearch.js": "^2.5.2",
"gulp-bump": "2.7.0",
"highlight.js": "9.12.0",
Expand All @@ -97,6 +98,7 @@
"jasmine-fail-fast": "2.0.0",
"leaflet": "1.0.3",
"marked": "0.3.9",
"moment": "^2.22.2",
"nebular-icons": "1.1.0",
"normalize.css": "8.0.0",
"rxjs": "^6.1.0",
Expand Down Expand Up @@ -132,6 +134,7 @@
"gulp-replace": "0.5.4",
"gulp-rollup": "2.13.0",
"gulp-sass": "3.1.0",
"gulp-sequence": "1.0.0",
"gulp-sourcemaps": "2.6.0",
"gulp-typedoc": "2.0.2",
"husky": "0.13.3",
Expand Down
2 changes: 0 additions & 2 deletions scripts/gulp/gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ import './tasks/copy-sources';
import './tasks/bump-versions';

task('default', ['copy-sources']);
task('version', ['bump', 'bump-peer']);

59 changes: 32 additions & 27 deletions scripts/gulp/tasks/bump-versions.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
import { dest, src, task } from 'gulp';

const modify = require('gulp-json-modify');
const seq = require('gulp-sequence');

const VERSION_APPENDIX = process.env.NEBULAR_VERSION_APPENDIX;
const VERSION = process.env.NEBULAR_VERSION || require('../../../package.json').version +
(VERSION_APPENDIX ? '-' + VERSION_APPENDIX : '');

task('version', seq('bump', 'bump-peer'));

task('bump', () => {
src([
return bumpVersion([
'./package.json',
'./src/framework/theme/package.json',
'./src/framework/auth/package.json',
'./src/framework/security/package.json',
'./src/framework/bootstrap/package.json',
], { base: './' })
.pipe(modify({
key: 'version',
value: VERSION,
}))
.pipe(dest('./'));
'./src/framework/moment/package.json',
'./src/framework/date-fns/package.json',
]);
});

task('bump-peer', () => {
src([
'./src/framework/bootstrap/package.json',
], { base: './' })
.pipe(modify({
key: 'peerDependencies.@nebular/theme',
value: VERSION,
}))
.pipe(dest('./'));
task('bump-peer', seq('bump-theme', 'bump-bootstrap'));

src([
task('bump-theme', () => {
return bumpPeer([
'./src/framework/auth/package.json',
], { base: './' })
.pipe(modify({
key: 'peerDependencies.@nebular/theme',
value: VERSION,
}))
.pipe(modify({
key: 'peerDependencies.@nebular/bootstrap',
value: VERSION,
}))
.pipe(dest('./'));
'./src/framework/bootstrap/package.json',
'./src/framework/moment/package.json',
'./src/framework/date-fns/package.json',
], 'theme');
});

task('bump-bootstrap', () => {
return bumpPeer(['./src/framework/auth/package.json'], 'bootstrap');
});

function bumpPeer(packages: string[], peer: string) {
return bump(packages, `peerDependencies.@nebular/${peer}`);
}

function bumpVersion(packages: string[]) {
return bump(packages, 'version');
}

function bump(packages: string[], key: string) {
return src(packages, { base: './' })
.pipe(modify({ key, value: VERSION }))
.pipe(dest('./'));
}
17 changes: 17 additions & 0 deletions src/framework/date-fns/date-fns.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { NgModule } from '@angular/core';

import { NbDateService } from '@nebular/theme';
import { NbDateFnsDateService } from './services/date-fns-date.service';


@NgModule({
providers: [{ provide: NbDateService, useClass: NbDateFnsDateService }],
})
export class NbDateFnsDateModule {
}
8 changes: 8 additions & 0 deletions src/framework/date-fns/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export * from './services/date-fns-date.service';
export * from './date-fns.module';
30 changes: 30 additions & 0 deletions src/framework/date-fns/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@nebular/date-fns",
"version": "2.0.0-rc.10",
"description": "@nebular/date-fns",
"main": "./bundles/theme.umd.js",
"module": "./index.js",
"typings": "./index.d.ts",
"author": "akveo",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/akveo/nebular.git"
},
"bugs": {
"url": "https://github.com/akveo/nebular/issues"
},
"homepage": "https://github.com/akveo/nebular#readme",
"keywords": [
"angular",
"typescript",
"ng2-admin",
"ngx-admin",
"theme",
"nebular"
],
"peerDependencies": {
"@nebular/theme": "2.0.0-rc.10",
"date-fns": "^2.0.0-alpha.16"
}
}
27 changes: 27 additions & 0 deletions src/framework/date-fns/services/date-fns-date.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { TestBed } from '@angular/core/testing';
import { LOCALE_ID } from '@angular/core';

import { NbDateService } from '@nebular/theme';

import { NbDateFnsDateService } from './date-fns-date.service';


describe('date-fns-date-service', () => {
let dateService: NbDateService<Date>;

beforeEach(() => {
TestBed.configureTestingModule({});
dateService = new NbDateFnsDateService(TestBed.get(LOCALE_ID));
});

it('should parse date according to the MM.dd.yyyy format', () => {
const date = '06.15.2018';
expect(dateService.parse(date, 'MM.dd.yyyy')).toEqual(new Date(2018, 5, 15));
});
});
24 changes: 24 additions & 0 deletions src/framework/date-fns/services/date-fns-date.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { Inject, Injectable, LOCALE_ID } from '@angular/core';

import { NbNativeDateService } from '@nebular/theme';

import * as parse from 'date-fns/parse';


@Injectable()
export class NbDateFnsDateService extends NbNativeDateService {
constructor(@Inject(LOCALE_ID) locale: string) {
super(locale);
this.setLocale(locale);
}

parse(date: string, format: string): Date {
return parse(date, format, new Date());
}
}
8 changes: 8 additions & 0 deletions src/framework/moment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export * from './services/moment-date.service';
export * from './moment.module';
17 changes: 17 additions & 0 deletions src/framework/moment/moment.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { NgModule } from '@angular/core';

import { NbDateService } from '@nebular/theme';
import { NbMomentDateService } from './services/moment-date.service';


@NgModule({
providers: [{ provide: NbDateService, useClass: NbMomentDateService }],
})
export class NbMomentDateModule {
}
31 changes: 31 additions & 0 deletions src/framework/moment/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@nebular/moment",
"version": "2.0.0-rc.10",
"description": "@nebular/moment",
"main": "./bundles/theme.umd.js",
"module": "./index.js",
"typings": "./index.d.ts",
"author": "akveo",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/akveo/nebular.git"
},
"bugs": {
"url": "https://github.com/akveo/nebular/issues"
},
"homepage": "https://github.com/akveo/nebular#readme",
"keywords": [
"angular",
"typescript",
"ng2-admin",
"ngx-admin",
"theme",
"nebular"
],
"peerDependencies": {
"@nebular/theme": "2.0.0-rc.10",
"moment": "^2.22.2"
}
}

Loading

0 comments on commit c00cc23

Please sign in to comment.