Skip to content

Commit

Permalink
Chore/now preview (#1)
Browse files Browse the repository at this point in the history
* chore: sync ant-design v3.19.6 (NG-ZORRO#3602)

* fix(module:table): fix sortChange with dynamic columns (NG-ZORRO#3603) (NG-ZORRO#3605)

close NG-ZORRO#3603

* chore: sync with antd 3.19 (NG-ZORRO#3590)

* chore: sync with antd 3.19

* test(module:page-header): fix test

* chore: refactor commit hook (NG-ZORRO#3610)

* chore: refactor commit hook

* chore(packaging): clean dependencie

* chore(packaging): clean dev dependencie

* chore: refactor commit hook (NG-ZORRO#3610)

* chore: refactor commit hook

* chore(packaging): clean dependencie

* chore(packaging): clean dev dependencie

* chore: refactor commit hook (NG-ZORRO#3610)

* chore: refactor commit hook

* chore(packaging): clean dependencie

* chore(packaging): clean dev dependencie

* build: refactor scripts

ref NG-ZORRO#2474

* chore: update ci config

* ci: fix integration

* ci: add travis_wait

* ci: fix ci

* ci: fix ci

* ci: fix ci

* ci: fix ci

* ci: fix ci

* chore: fix type

* build: add site release scripts

* build: _

* build: add `test:watch` task

* build: fix `test:watch` task

* chore: bump node to 12.1.0

* ci: add now.json
  • Loading branch information
hsuanxyz committed Jun 21, 2019
1 parent c10a7a9 commit f9a1b05
Show file tree
Hide file tree
Showing 58 changed files with 1,262 additions and 639 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ integration/**/*.ngsummary.json
schematics/demo
schematics/utils/create-custom-theme.ts
schematics/utils/version-names.ts
ng-zorro.github.io/

# dependencies
node_modules
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.9.0
12.1.0
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ sudo: required
dist: trusty
language: node_js
node_js:
- '10.9.0'
- '12.1.0'

env:
- TASK=pre-release
- TASK=build
- TASK=test
- TASK=lint
- TASK=integration-cli
Expand Down
13 changes: 13 additions & 0 deletions build-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const {join} = require('path');

const packageJson = require('./package.json');
const buildVersion = packageJson.version;

module.exports = {
projectVersion: buildVersion,
projectDir: __dirname,
componentsDir: join(__dirname, 'components'),
scriptsDir: join(__dirname, 'scripts'),
outputDir: join(__dirname, 'dist'),
publishDir: join(__dirname, 'publish'),
};
60 changes: 60 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';
const message = process.env['HUSKY_GIT_PARAMS'];
const fs = require('fs');

const types = [
'build',
"chore",
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
"release",
'revert',
'style',
'test'
];

const scopes = [
"showcase",
"packaging",
"changelog",
"schematics",
"module:*"
];

function parseMessage(message) {
const PATTERN = /^(\w+)(?:\(([^)]+)\))?\: (.+)$/;
const match = PATTERN.exec(message);
if (!match) {
return null;
}
return {
type: match[1] || null,
scope: match[2] || null,
}
}

function getScopesRule() {
const messages = fs.readFileSync(message, {encoding: 'utf-8'});
const parsed = parseMessage(messages.split('\n')[0]);
if (!parsed) {
return [2, 'always', scopes]
}
const { scope, type } = parsed;
if (scope && !scopes.includes(scope) && type !== 'release' && !/module:.+/.test(scope)) {
return [2, 'always', scopes]
} else {
return [2, 'always', []]
}
}

module.exports = {
extends: ['@commitlint/config-angular'],
rules: {
'type-enum': [2, 'always', types],
'scope-enum': getScopesRule
}
};
2 changes: 1 addition & 1 deletion components/card/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
padding-bottom: 0;
}

&-contain-tabs &-extra {
&-contain-tabs > &-head &-extra {
padding-bottom: 0;
}

Expand Down
8 changes: 8 additions & 0 deletions components/core/responsive/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export * from './public-api';
8 changes: 8 additions & 0 deletions components/core/responsive/public-api.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export * from './break-point';
4 changes: 4 additions & 0 deletions components/date-picker/style/Picker.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

&-input {
outline: none;

&.@{ant-prefix}-input {
line-height: @line-height-base;
}
}

&-input.@{ant-prefix}-input-sm {
Expand Down
1 change: 0 additions & 1 deletion components/date-picker/style/RangePicker.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
background-color: transparent;
border: 0;
outline: 0;
vertical-align: top;
.placeholder();

&[disabled] {
Expand Down
1 change: 1 addition & 0 deletions components/input/style/mixin.less
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
min-height: @input-height-base;
vertical-align: bottom;
transition: all 0.3s, height 0s;
line-height: @line-height-base;
}

// Size
Expand Down
2 changes: 2 additions & 0 deletions components/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

const tags = process.env && process.env['NG_TEST_TAGS'];
module.exports = function(config) {
config.set({
basePath: '',
Expand All @@ -15,6 +16,7 @@ module.exports = function(config) {
require('karma-viewport')
],
client: {
args: [tags],
clearContext: true // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
Expand Down
8 changes: 5 additions & 3 deletions components/page-header/nz-page-header.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<ng-content select="nz-breadcrumb[nz-page-header-breadcrumb]"></ng-content>

<div *ngIf="nzBackIcon !== null" (click)="onBack()" class="ant-page-header-back-icon">
<i *ngIf="isStringBackIcon" nz-icon [type]="nzBackIcon ? nzBackIcon : 'arrow-left'" theme="outline"></i>
<ng-container *ngIf="isTemplateRefBackIcon" [ngTemplateOutlet]="nzBackIcon"></ng-container>
<div *ngIf="nzBackIcon !== null" (click)="onBack()" class="ant-page-header-back">
<div role="button" tabindex="0" class="ant-page-header-back-button">
<i *ngIf="isStringBackIcon" nz-icon [type]="nzBackIcon ? nzBackIcon : 'arrow-left'" theme="outline"></i>
<ng-container *ngIf="isTemplateRefBackIcon" [ngTemplateOutlet]="nzBackIcon"></ng-container>
</div>
<nz-divider nzType="vertical"></nz-divider>
</div>

Expand Down
13 changes: 12 additions & 1 deletion components/page-header/nz-page-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ import { NzPageHeaderFooterDirective } from './nz-page-header-cells';
host: {
class: 'ant-page-header',
'[class.ant-page-header-has-footer]': 'nzPageHeaderFooter'
}
},
styles: [
`
.ant-page-header-back-button {
border: 0px;
background: transparent;
padding: 0px;
line-height: inherit;
display: inline-block;
}
`
]
})
export class NzPageHeaderComponent implements OnInit, OnChanges {
isTemplateRefBackIcon = false;
Expand Down
6 changes: 3 additions & 3 deletions components/page-header/nz-page-header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ describe('NzPageHeaderComponent', () => {
const fixture = TestBed.createComponent(NzDemoPageHeaderBasicComponent);
const pageHeader = fixture.debugElement.query(By.directive(NzPageHeaderComponent));
fixture.detectChanges();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back-icon > i.anticon-arrow-left')).toBeTruthy();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back i.anticon-arrow-left')).toBeTruthy();
});

it('should does not have an default back icon', () => {
const fixture = TestBed.createComponent(NzDemoPageHeaderContentComponent);
const pageHeader = fixture.debugElement.query(By.directive(NzPageHeaderComponent));
fixture.detectChanges();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back-icon')).toBeFalsy();
expect(pageHeader.nativeElement.querySelector('.ant-page-header-back')).toBeFalsy();
});

it('should nzBack work', () => {
Expand All @@ -82,7 +82,7 @@ describe('NzPageHeaderComponent', () => {
spyOn(context, 'onBack');
fixture.detectChanges();
expect(context.onBack).not.toHaveBeenCalled();
const back = pageHeader.nativeElement.querySelector('.ant-page-header-back-icon');
const back = pageHeader.nativeElement.querySelector('.ant-page-header-back');
(back as HTMLElement).click();
fixture.detectChanges();
expect(context.onBack).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions components/table/nz-thead.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
ViewEncapsulation
} from '@angular/core';
import { merge, Subject } from 'rxjs';
import { flatMap, startWith, takeUntil } from 'rxjs/operators';
import { startWith, switchMap, takeUntil } from 'rxjs/operators';

import { InputBoolean } from 'ng-zorro-antd/core';

Expand Down Expand Up @@ -62,7 +62,7 @@ export class NzTheadComponent implements AfterContentInit, OnDestroy, AfterViewI
this.listOfNzThComponent.changes
.pipe(
startWith(true),
flatMap(() =>
switchMap(() =>
merge<{ key: string; value: string }>(...this.listOfNzThComponent.map(th => th.nzSortChangeWithKey))
),
takeUntil(this.destroy$)
Expand Down
23 changes: 23 additions & 0 deletions components/table/nz-thead.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ describe('nz-thead', () => {
expect(upButtons[1].querySelector('.ant-table-column-sorter-down').classList).toContain('on');
expect(testComponent.sortChange).toHaveBeenCalledTimes(2);
});

// Test for #3603
it('should support dynamic headers', () => {
testComponent.singleSort = true;
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(0);
let upButtons = table.nativeElement.querySelectorAll('.ant-table-column-sorters');
upButtons[2].click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(1);
upButtons[3].click();
fixture.detectChanges();
expect(testComponent.sortChange).toHaveBeenCalledTimes(2);

testComponent.columns = testComponent.columns.slice(0, 1);
fixture.detectChanges();
upButtons = table.nativeElement.querySelectorAll('.ant-table-column-sorters');
expect(upButtons.length).toBe(3);
upButtons[2].click();
expect(testComponent.sortChange).toHaveBeenCalledTimes(3);
});
});
});

Expand All @@ -64,11 +85,13 @@ describe('nz-thead', () => {
<thead [nzSingleSort]="singleSort" (nzSortChange)="sortChange($event)">
<th nzShowSort nzSortKey="first"></th>
<th nzShowSort nzSortKey="second"></th>
<th nzShowSort *ngFor="let col of columns" [nzSortKey]="col"></th>
</thead>
</nz-table>
`
})
export class NzTheadTestNzTableComponent {
singleSort = false;
sortChange = jasmine.createSpy('sort change');
columns = ['third', 'fourth'];
}
26 changes: 23 additions & 3 deletions components/test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

// tslint:disable-next-line:no-import-side-effect
import 'zone.js/dist/zone-testing';

import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
platformBrowserDynamicTesting,
BrowserDynamicTestingModule
} from '@angular/platform-browser-dynamic/testing';

// tslint:disable-next-line:no-any
declare const __karma__: any;
// tslint:disable-next-line:no-any
declare const require: any;

const tags = __karma__.config.args[0];
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);

let filterRegExp: RegExp;

if (tags) {
filterRegExp = new RegExp(`(${tags})\\.spec\\.ts$`);
} else {
filterRegExp = /\.spec\.ts$/;
}

// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// Filter specify file
const specFiles = context.keys().filter((path: string) => {
console.log(filterRegExp);
return filterRegExp.test(path);
});
// And load the modules.
context.keys().map(context);
specFiles.map(context);
17 changes: 17 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const path = require('path');

const projectDir = __dirname;
const tsconfigPath = path.join(projectDir, 'scripts/gulp/tsconfig.json');

if (projectDir.includes(' ')) {
console.error('Error: Cannot run the build tasks if the project is ' +
'located in a directory with spaces in between. Please rename your project directory.');
process.exit(1);
}

// Register TS compilation.
require('ts-node').register({
project: tsconfigPath
});

require('./scripts/gulp/gulpfile');
Empty file added now.json
Empty file.
Loading

0 comments on commit f9a1b05

Please sign in to comment.