Skip to content

Commit

Permalink
Merge branch 'NG-ZORRO:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
LemniscateX authored Sep 25, 2022
2 parents db69210 + 2cb80fc commit c7fafcd
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 25 deletions.
4 changes: 2 additions & 2 deletions components/core/testing/component-bed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import { CommonModule } from '@angular/common';
import { DebugElement, NgModule, NO_ERRORS_SCHEMA, Type } from '@angular/core';
import { ComponentFixture, TestBed, TestBedStatic } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

type ComponentBedOptions = Pick<NgModule, 'providers' | 'declarations' | 'imports'>;
export interface ComponentBed<T> {
bed: TestBedStatic;
bed: TestBed;
fixture: ComponentFixture<T>;
nativeElement: HTMLElement;
debugElement: DebugElement;
Expand Down
18 changes: 16 additions & 2 deletions components/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,18 @@ describe('NzDatePickerComponent', () => {
expect(element.classList.contains('ant-picker-dropdown-placement-bottomRight')).toBe(false);
expect(element.classList.contains('ant-picker-dropdown-placement-topRight')).toBe(true);
}));

it('should support nzShowWeekNumber', fakeAsync(() => {
fixtureInstance.nzShowWeekNumber = true;
fixture.detectChanges();
openPickerByClickTrigger();
expect(queryFromOverlay('.ant-picker-week-panel-row .ant-picker-cell-week')).toBeDefined();
fixtureInstance.nzShowWeekNumber = false;
fixture.detectChanges();
tick(500);
openPickerByClickTrigger();
expect(queryFromOverlay('.ant-picker-week-panel-row .ant-picker-cell-week')).toBeNull();
}));
});

describe('panel switch and move forward/afterward', () => {
Expand Down Expand Up @@ -1138,7 +1150,7 @@ describe('NzDatePickerComponent', () => {
return queryFromOverlay(`.${PREFIX_CLASS}-header-super-next-btn`);
}

describe('ngModel value accesors', () => {
describe('ngModel value accessors', () => {
beforeEach(() => (fixtureInstance.useSuite = 3));

it('should specified date provide by "modelValue" be chosen', fakeAsync(() => {
Expand Down Expand Up @@ -1356,14 +1368,15 @@ describe('in form', () => {
[nzInline]="nzInline"
[nzBackdrop]="nzBackdrop"
[nzPlacement]="nzPlacement"
[nzShowWeekNumber]="nzShowWeekNumber"
></nz-date-picker>
<ng-template #tplDateRender let-current>
<div [class.test-first-day]="current.getDate() === 1">{{ current.getDate() }}</div>
</ng-template>
<ng-template #tplExtraFooter>TEST_EXTRA_FOOTER</ng-template>
<!-- Suite 2 -->
<!-- use another picker to avoid nzOpen's side-effects beacuse nzOpen act as "true" if used -->
<!-- use another picker to avoid nzOpen's side-effects because nzOpen acts as "true" if used -->
<nz-date-picker *ngSwitchCase="2" [nzOpen]="nzOpen" (nzOnOpenChange)="nzOnOpenChange($event)"></nz-date-picker>
<!-- Suite 3 -->
Expand Down Expand Up @@ -1416,6 +1429,7 @@ class NzTestDatePickerComponent {
nzInline = false;
nzBackdrop = false;
nzPlacement = 'bottomLeft';
nzShowWeekNumber = false;

// nzRanges;
nzOnPanelChange(_: string): void {}
Expand Down
3 changes: 2 additions & 1 deletion components/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export type NzPlacement = 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
[isRange]="isRange"
[inline]="nzInline"
[defaultPickerValue]="nzDefaultPickerValue"
[showWeek]="nzMode === 'week'"
[showWeek]="nzShowWeekNumber || nzMode === 'week'"
[panelMode]="panelMode"
(panelModeChange)="onPanelModeChange($event)"
(calendarChange)="onCalendarChange($event)"
Expand Down Expand Up @@ -306,6 +306,7 @@ export class NzDatePickerComponent implements OnInit, OnChanges, OnDestroy, Afte
@Input() @WithConfig() nzBackdrop = false;
@Input() nzId: string | null = null;
@Input() nzPlacement: NzPlacement = 'bottomLeft';
@Input() @InputBoolean() nzShowWeekNumber: boolean = false;

// TODO(@wenqi73) The PanelMode need named for each pickers and export
@Output() readonly nzOnPanelChange = new EventEmitter<NzDateMode | NzDateMode[] | string | string[]>();
Expand Down
2 changes: 1 addition & 1 deletion components/date-picker/date-range-popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import { getTimeConfig, isAllowedDate, PREFIX_CLASS } from './util';
<ng-container *ngIf="isRange; else singlePanel">
<div class="{{ prefixCls }}-range-wrapper {{ prefixCls }}-date-range-wrapper">
<div class="{{ prefixCls }}-range-arrow" [style.left.px]="datePickerService?.arrowLeft"></div>
<div class="{{ prefixCls }}-panel-container">
<div class="{{ prefixCls }}-panel-container {{ showWeek ? prefixCls + '-week-number' : '' }}">
<div class="{{ prefixCls }}-panels">
<ng-container *ngIf="hasTimePicker; else noTimePicker">
<ng-container
Expand Down
14 changes: 14 additions & 0 deletions components/date-picker/demo/week-number.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 16
title:
zh-CN: 显示周数
en-US: Week Number
---

## zh-CN

使用 `nzShowWeekNumber` 显示周数

## en-US

Display week numbers with `nzShowWeekNumber`.
27 changes: 27 additions & 0 deletions components/date-picker/demo/week-number.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component } from '@angular/core';

@Component({
selector: 'nz-demo-date-picker-week-number',
template: `
<nz-radio-group [(ngModel)]="showWeekNumber">
<label nz-radio-button [nzValue]="true">true</label>
<label nz-radio-button [nzValue]="false">false</label>
</nz-radio-group>
<br />
<br />
<nz-date-picker [nzShowWeekNumber]="showWeekNumber"></nz-date-picker>
<br />
<nz-range-picker [nzShowWeekNumber]="showWeekNumber"></nz-range-picker>
`,
styles: [
`
nz-date-picker,
nz-range-picker {
margin: 0 8px 12px 0;
}
`
]
})
export class NzDemoDatePickerWeekNumberComponent {
showWeekNumber: boolean = false;
}
2 changes: 2 additions & 0 deletions components/date-picker/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The following APIs are shared by nz-date-picker, nz-range-picker.
| `[nzShowTime]` | to provide an additional time selection | `object \| boolean` | [TimePicker Options](/components/time-picker/en#api) |
| `[nzShowToday]` | whether to show 'Today' button | `boolean` | `true` |
| `[nzShowNow]` | whether to show 'Now' button on panel when `nzShowTime` is set | `boolean` | `true` |
| `[nzShowWeekNumber]` | whether to show the week number on each row (Only supported by date picker. Week picker always shows week numbers) | `boolean` | `false` |
| `(nzOnOk)` | callback when click ok button | `EventEmitter<Date>` | - |

### nz-range-picker
Expand All @@ -95,6 +96,7 @@ The following APIs are shared by nz-date-picker, nz-range-picker.
| -------- | ----------- | ---- | ------- |
| `[nzShowTime]` | to provide an additional time selection | `object \| boolean` | [TimePicker Options](/components/time-picker/en#api) |
| `[nzDisabledTime]` | to specify the time that cannot be selected | `(current: Date, partial: 'start' \| 'end') => { nzDisabledHours, nzDisabledMinutes, nzDisabledSeconds }` | - |
| `[nzShowWeekNumber]` | whether to show the week number on each row (Only supported by date picker. Week picker always shows week numbers) | `boolean` | `false` |
| `(nzOnOk)` | click ok callback | `EventEmitter<Date[]>` | - |

> Currently, supported `nz-time-picker` parameters in `nzShowTime` are: `nzFormat`, `nzHourStep`, `nzMinuteStep`, `nzSecondStep`, `nzDisabledHours`, `nzDisabledMinutes`, `nzDisabledSeconds`, `nzHideDisabledOptions`, `nzDefaultOpenValue`, `nzAddOn`
Expand Down
2 changes: 2 additions & 0 deletions components/date-picker/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ registerLocaleData(zh);
| `[nzShowTime]` | 增加时间选择功能 | `object \| boolean` | [TimePicker Options](/components/time-picker/zh#api) |
| `[nzShowToday]` | 是否展示“今天”按钮 | `boolean` | `true` |
| `[nzShowNow]` | 当设定了`nzShowTime`的时候,面板是否显示“此刻”按钮 | `boolean` | `true` |
| `[nzShowWeekNumber]` | 是否在每一行显示周数(仅日期选择器支持。周选择器始终显示周数) | `boolean` | `false` |
| `(nzOnOk)` | 点击确定按钮的回调 | `EventEmitter<Date>` | - |


Expand All @@ -96,6 +97,7 @@ registerLocaleData(zh);
| --- | --- | --- | --- |
| `[nzShowTime]` | 增加时间选择功能 | `object \| boolean` | [TimePicker Options](/components/time-picker/zh#api) |
| `[nzDisabledTime]` | 不可选择的时间 | `(current: Date, partial: 'start' \| 'end') => { nzDisabledHours, nzDisabledMinutes, nzDisabledSeconds }` | - |
| `[nzShowWeekNumber]` | 是否在每一行显示周数(仅日期选择器支持。周选择器始终显示周数) | `boolean` | `false` |
| `(nzOnOk)` | 点击确定按钮的回调 | `EventEmitter<Date[]>` | - |

> `nzShowTime` 中当前支持的 `nz-time-picker` 参数有:`nzFormat`, `nzHourStep`, `nzMinuteStep`, `nzSecondStep`, `nzDisabledHours`, `nzDisabledMinutes`, `nzDisabledSeconds`, `nzHideDisabledOptions`, `nzDefaultOpenValue`, `nzAddOn`
Expand Down
11 changes: 7 additions & 4 deletions components/date-picker/inner-popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ import { PREFIX_CLASS } from './util';
<date-header
[(value)]="activeDate"
[locale]="locale"
[showSuperPreBtn]="showWeek ? enablePrevNext('prev', 'week') : enablePrevNext('prev', 'date')"
[showSuperNextBtn]="showWeek ? enablePrevNext('next', 'week') : enablePrevNext('next', 'date')"
[showPreBtn]="showWeek ? enablePrevNext('prev', 'week') : enablePrevNext('prev', 'date')"
[showNextBtn]="showWeek ? enablePrevNext('next', 'week') : enablePrevNext('next', 'date')"
[showSuperPreBtn]="panelMode === 'week' ? enablePrevNext('prev', 'week') : enablePrevNext('prev', 'date')"
[showSuperNextBtn]="
panelMode === 'week' ? enablePrevNext('next', 'week') : enablePrevNext('next', 'date')
"
[showPreBtn]="panelMode === 'week' ? enablePrevNext('prev', 'week') : enablePrevNext('prev', 'date')"
[showNextBtn]="panelMode === 'week' ? enablePrevNext('next', 'week') : enablePrevNext('next', 'date')"
(panelModeChange)="panelModeChange.emit($event)"
(valueChange)="headerChange.emit($event)"
></date-header>
Expand All @@ -123,6 +125,7 @@ import { PREFIX_CLASS } from './util';
[cellRender]="dateRender"
[selectedValue]="selectedValue"
[hoverValue]="hoverValue"
[canSelectWeek]="panelMode === 'week'"
(valueChange)="onSelectDate($event)"
(cellHover)="cellHover.emit($event)"
></date-table>
Expand Down
2 changes: 2 additions & 0 deletions components/date-picker/lib/abstract-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export abstract class AbstractTable implements OnInit, OnChanges {
@Input() disabledDate?: (d: Date) => boolean;
@Input() cellRender?: string | TemplateRef<Date> | FunctionProp<TemplateRef<Date> | string>;
@Input() fullCellRender?: string | TemplateRef<Date> | FunctionProp<TemplateRef<Date> | string>;
@Input() canSelectWeek: boolean = false;

@Output() readonly valueChange = new EventEmitter<CandyDate>();
@Output() readonly cellHover = new EventEmitter<CandyDate>(); // Emitted when hover on a day by mouse enter
Expand Down Expand Up @@ -90,6 +91,7 @@ export abstract class AbstractTable implements OnInit, OnChanges {
changes.disabledDate ||
changes.locale ||
changes.showWeek ||
changes.selectWeek ||
this.isDateRealChange(changes.activeDate) ||
this.isDateRealChange(changes.value) ||
this.isDateRealChange(changes.selectedValue) ||
Expand Down
6 changes: 3 additions & 3 deletions components/date-picker/lib/date-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ export class DateTableComponent extends AbstractTable implements OnChanges, OnIn
row.dateCells.push(cell);
}
row.classMap = {
[`ant-picker-week-panel-row`]: this.showWeek,
[`ant-picker-week-panel-row-selected`]: this.showWeek && row.isActive
[`ant-picker-week-panel-row`]: this.canSelectWeek,
[`ant-picker-week-panel-row-selected`]: this.canSelectWeek && row.isActive
};
weekRows.push(row);
}
return weekRows;
}

addCellProperty(cell: DateCell, date: CandyDate): void {
if (this.hasRangeValue() && !this.showWeek) {
if (this.hasRangeValue() && !this.canSelectWeek) {
const [startHover, endHover] = this.hoverValue;
const [startSelected, endSelected] = this.selectedValue;
// Selected
Expand Down
9 changes: 9 additions & 0 deletions components/date-picker/style/patch.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@
top: unset;
left: unset;
}

// ensure table is correct width to display week numbers in date mode
.@{picker-prefix-cls}-panel-container.@{picker-prefix-cls}-week-number .@{picker-prefix-cls}-date-panel .@{picker-prefix-cls}-content {
width: 100%;

th {
width: inherit;
}
}
52 changes: 46 additions & 6 deletions components/i18n/languages/it_IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ export default {
DatePicker: {
lang: {
placeholder: 'Selezionare la data',
yearPlaceholder: "Selezionare l'anno",
quarterPlaceholder: 'Selezionare il trimestre',
monthPlaceholder: 'Selezionare il mese',
weekPlaceholder: 'Selezionare la settimana',
rangePlaceholder: ["Data d'inizio", 'Data di fine'],
rangeYearPlaceholder: ["Anno d'inizio", 'Anno di fine'],
rangeMonthPlaceholder: ["Mese d'inizio ", 'Mese di fine'],
rangeWeekPlaceholder: ["Settimana d'inizio", 'Settimana di fine'],
locale: 'it_IT',
today: 'Oggi',
now: 'Adesso',
Expand All @@ -32,6 +39,7 @@ export default {
year: 'Anno',
timeSelect: "Seleziona l'ora",
dateSelect: 'Seleziona la data',
weekSelect: 'Seleziona la settimana',
monthSelect: 'Seleziona il mese',
yearSelect: "Seleziona l'anno",
decadeSelect: 'Seleziona il decennio',
Expand All @@ -50,16 +58,25 @@ export default {
nextCentury: 'Prossimo secolo'
},
timePickerLocale: {
placeholder: "Selezionare l'orario"
placeholder: "Selezionare l'orario",
rangePlaceholder: ["Ora d'inizio", 'Ora di fine']
}
},
TimePicker: {
placeholder: "Selezionare l'orario"
placeholder: "Selezionare l'orario",
rangePlaceholder: ["Ora d'inizio", 'Ora di fine']
},
Calendar: {
lang: {
placeholder: 'Selezionare la data',
yearPlaceholder: "Selezionare l'anno",
quarterPlaceholder: 'Selezionare il trimestre',
monthPlaceholder: 'Selezionare il mese',
weekPlaceholder: 'Selezionare la settimana',
rangePlaceholder: ["Data d'inizio", 'Data di fine'],
rangeYearPlaceholder: ["Anno d'inizio", 'Anno di fine'],
rangeMonthPlaceholder: ["Mese d'inizio ", 'Mese di fine'],
rangeWeekPlaceholder: ["Settimana d'inizio", 'Settimana di fine'],
locale: 'it_IT',
today: 'Oggi',
now: 'Adesso',
Expand All @@ -69,6 +86,7 @@ export default {
month: 'Mese',
year: 'Anno',
timeSelect: "Seleziona l'ora",
weekSelect: 'Seleziona la settimana',
dateSelect: 'Seleziona la data',
monthSelect: 'Seleziona il mese',
yearSelect: "Seleziona l'anno",
Expand All @@ -88,7 +106,8 @@ export default {
nextCentury: 'Prossimo secolo'
},
timePickerLocale: {
placeholder: "Selezionare l'orario"
placeholder: "Selezionare l'orario",
rangePlaceholder: ["Ora d'inizio", 'Ora di fine']
}
},
global: {
Expand All @@ -98,12 +117,20 @@ export default {
filterTitle: 'Menù Filtro',
filterConfirm: 'OK',
filterReset: 'Reset',
filterEmptyText: 'Nessun filtro',
emptyText: 'Nessun dato',
selectAll: 'Seleziona pagina corrente',
selectInvert: 'Inverti selezione nella pagina corrente',
selectionAll: 'Seleziona tutti i dati',
sortTitle: 'Ordina',
expand: 'Esapandi riga',
collapse: 'Chiudi riga',
triggerDesc: 'Clicca per ordinare in modo discendente',
triggerAsc: 'Clicca per ordinare in modo ascendente',
cancelSort: 'Clicca per eliminare i filtri'
triggerAsc: 'Clicca per ordinare in modo ascendente',
cancelSort: 'Clicca per eliminare i filtri',
filterCheckall: 'Seleziona tutto',
filterSearchPlaceholder: 'Cerca nei filtri',
selectNone: 'Pulisci tutti i dati'
},
Modal: {
okText: 'OK',
Expand All @@ -115,9 +142,16 @@ export default {
cancelText: 'Annulla'
},
Transfer: {
titles: ['', ''],
searchPlaceholder: 'Cerca qui',
itemUnit: 'elemento',
itemsUnit: 'elementi'
itemsUnit: 'elementi',
remove: 'Rimuovi',
selectCurrent: 'Seleziona pagina corrente',
removeCurrent: 'Rimuovi pagina corrente',
selectAll: 'Selezione tutti i dati',
removeAll: 'Rimuovi tutti i dati',
selectInvert: 'Inverti selezione nella pagina corrente'
},
Upload: {
uploading: 'Caricamento...',
Expand All @@ -137,5 +171,11 @@ export default {
copy: 'copia',
copied: 'copia effettuata',
expand: 'espandi'
},
PageHeader: {
back: 'Indietro'
},
Image: {
preview: 'Anteprima'
}
};
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
},
"devDependencies": {
"@angular-builders/custom-webpack": "^14.0.0",
"@angular-devkit/build-angular": "^14.1.0",
"@angular-devkit/core": "^14.1.0",
"@angular-devkit/schematics": "^14.1.0",
"@angular-devkit/build-angular": "~14.1.0",
"@angular-devkit/core": "~14.1.0",
"@angular-devkit/schematics": "~14.1.0",
"@angular-eslint/builder": "^14.0.2",
"@angular-eslint/eslint-plugin": "^14.0.2",
"@angular-eslint/eslint-plugin-template": "^14.0.2",
Expand All @@ -57,9 +57,9 @@
"@ant-design/dark-theme": "^2.0.2",
"@commitlint/cli": "^13.0.0",
"@commitlint/config-angular": "^13.0.0",
"@nguniversal/builders": "^14.0.3",
"@nguniversal/express-engine": "^14.0.3",
"@schematics/angular": "^14.1.0",
"@nguniversal/builders": "~14.1.0",
"@nguniversal/express-engine": "~14.1.0",
"@schematics/angular": "~14.1.0",
"@stackblitz/sdk": "^1.5.2",
"@types/d3": "^6.2.0",
"@types/fs-extra": "^9.0.5",
Expand Down

0 comments on commit c7fafcd

Please sign in to comment.