Skip to content

Commit

Permalink
Merge branch 'master' into luxiaobei/#INFR-10910
Browse files Browse the repository at this point in the history
  • Loading branch information
minlovehua committed Dec 14, 2023
2 parents 39c9cc4 + e41fa5a commit b73b83b
Show file tree
Hide file tree
Showing 46 changed files with 866 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ export const namePackageRelationsInNg13 = {
LibPackerModule: 'date-picker',
MonthHeaderComponent: 'date-picker',
MonthTableComponent: 'date-picker',
QuarterTableComponent: 'date-picker',
DatePopupComponent: 'date-picker',
InnerPopupComponent: 'date-picker',
YearHeaderComponent: 'date-picker',
YearTableComponent: 'date-picker',
ThyMonthPickerComponent: 'date-picker',
ThyPickerComponent: 'date-picker',
ThyDatePickerFormatPipe: 'date-picker',
ThyQuarterPickerFormatPipe: 'date-picker',
ThyDatePickerFormatStringPipe: 'date-picker',
DatePickerAdvancedShowYearTipPipe: 'date-picker',
transformDateValue: 'date-picker',
Expand Down Expand Up @@ -224,6 +226,7 @@ export const namePackageRelationsInNg13 = {
RangeEntry: 'date-picker',
ThyWeekPickerComponent: 'date-picker',
ThyYearPickerComponent: 'date-picker',
ThyQuarterPickerComponent: 'date-picker',
AttachTypes: 'date-range',
DateRangeItemInfo: 'date-range',
ThyDateRangeComponent: 'date-range',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const NAME_PACKAGE_RELATION = {
LibPackerModule: 'date-picker',
MonthPanelComponent: 'date-picker',
MonthTableComponent: 'date-picker',
QuarterTableComponent: 'date-picker',
PanelMonthData: 'date-picker',
DatePopupComponent: 'date-picker',
RangePartType: 'date-picker',
Expand All @@ -176,6 +177,7 @@ const NAME_PACKAGE_RELATION = {
ThyMonthPickerComponent: 'date-picker',
ThyPickerComponent: 'date-picker',
ThyDatePickerFormatPipe: 'date-picker',
ThyQuarterPickerFormatPipe: 'date-picker',
ThyDatePickerFormatStringPipe: 'date-picker',
transformDateValue: 'date-picker',
convertDate: 'date-picker',
Expand All @@ -200,6 +202,7 @@ const NAME_PACKAGE_RELATION = {
SupportTimeOptions: 'date-picker',
ThyWeekPickerComponent: 'date-picker',
ThyYearPickerComponent: 'date-picker',
ThyQuarterPickerComponent: 'date-picker',
AttachTypes: 'date-range',
DateRangeItemInfo: 'date-range',
ThyDateRangeComponent: 'date-range',
Expand Down
3 changes: 3 additions & 0 deletions scripts/name-package-relation.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@
"LibPackerModule": "date-picker",
"MonthHeaderComponent": "date-picker",
"MonthTableComponent": "date-picker",
"QuarterTableComponent": "date-picker",
"DatePopupComponent": "date-picker",
"InnerPopupComponent": "date-picker",
"YearHeaderComponent": "date-picker",
"YearTableComponent": "date-picker",
"ThyMonthPickerComponent": "date-picker",
"ThyPickerComponent": "date-picker",
"ThyDatePickerFormatPipe": "date-picker",
"ThyQuarterPickerFormatPipe": "date-picker",
"ThyDatePickerFormatStringPipe": "date-picker",
"DatePickerAdvancedShowYearTipPipe": "date-picker",
"transformDateValue": "date-picker",
Expand Down Expand Up @@ -206,6 +208,7 @@
"RangeEntry": "date-picker",
"ThyWeekPickerComponent": "date-picker",
"ThyYearPickerComponent": "date-picker",
"ThyQuarterPickerComponent": "date-picker",
"AttachTypes": "date-range",
"DateRangeItemInfo": "date-range",
"ThyDateRangeComponent": "date-range",
Expand Down
9 changes: 8 additions & 1 deletion src/cascader/cascader.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@
[cdkConnectedOverlayOrigin]="origin"
[cdkConnectedOverlayPositions]="positions"
[cdkConnectedOverlayMinWidth]="menuMinWidth"
cdkConnectedOverlayTransformOriginOn=".thy-cascader-menus"
(backdropClick)="closeMenu()"
(detach)="closeMenu()"
(attach)="attached()"
(positionChange)="positionChange($event)"
[cdkConnectedOverlayOpen]="menuVisible">
<div [attr.tabindex]="-1" #menu [ngClass]="menuCls" [ngStyle]="thyMenuStyle" (mouseleave)="mouseleaveMenu($event)">
<div
[attr.tabindex]="-1"
#menu
[ngClass]="menuCls"
[ngStyle]="thyMenuStyle"
(mouseleave)="mouseleaveMenu($event)"
[@scaleYMotion]="'enter'">
<ng-container *ngIf="!isShowSearchPanel">
<ng-container *ngIf="columns.length > 0; else emptyPlaceholder">
<ul #cascaderOptionContainers *ngFor="let options of columns; let i = index" [ngClass]="menuColumnCls">
Expand Down
5 changes: 3 additions & 2 deletions src/cascader/cascader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { useHostRenderer } from '@tethys/cdk/dom';
import { ThyCascaderOptionComponent } from './cascader-li.component';
import { ThyCascaderSearchOptionComponent } from './cascader-search-option.component';
import { ThyCascaderExpandTrigger, ThyCascaderOption, ThyCascaderSearchOption, ThyCascaderTriggerType } from './types';
import { deepCopy } from '@angular-devkit/core';
import { scaleYMotion } from 'ngx-tethys/core';

function toArray<T>(value: T | T[]): T[] {
let ret: T[];
Expand Down Expand Up @@ -119,7 +119,8 @@ const defaultDisplayRender = (label: any) => label.join(' / ');
ThyCascaderSearchOptionComponent,
ThyEmptyComponent,
ThyIconComponent
]
],
animations: [scaleYMotion]
})
export class ThyCascaderComponent
extends TabIndexDisabledControlValueAccessorMixin
Expand Down
3 changes: 2 additions & 1 deletion src/cascader/test/cascader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { By } from '@angular/platform-browser';
import { clone } from '../examples/cascader-address-options';
import { ThyCascaderModule } from '../module';
import { ThyCascaderExpandTrigger, ThyCascaderTriggerType } from '../types';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

registerLocaleData(zh);

Expand Down Expand Up @@ -406,7 +407,7 @@ class CascaderMultipleComponent {
describe('thy-cascader', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [FormsModule, CommonModule, OverlayModule, ThyCascaderModule],
imports: [FormsModule, CommonModule, OverlayModule, ThyCascaderModule, NoopAnimationsModule],
declarations: [CascaderTemplateComponent, CascaderBasicComponent, CascaderLoadComponent, CascaderMultipleComponent],
providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }]
});
Expand Down
1 change: 1 addition & 0 deletions src/date-picker/base-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class BasePickerComponent extends AbstractPickerComponent implements OnIn
if (!this.thyFormat) {
const inputFormats: { [key in ThyPanelMode]?: string } = {
year: 'yyyy',
quarter: 'yyyy-qqq',
month: 'yyyy-MM',
week: 'yyyy-ww周',
date: this.thyShowTime ? 'yyyy-MM-dd HH:mm' : 'yyyy-MM-dd'
Expand Down
3 changes: 3 additions & 0 deletions src/date-picker/date-picker.directive.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('ThyPickerDirective', () => {
expect(queryFromOverlay('.thy-calendar-year-btn').textContent.includes('2021')).toBeTruthy();
expect(queryFromOverlay('.thy-calendar-month-btn').textContent.includes('10')).toBeTruthy();
}));

it('should support thyMaxDate', fakeAsync(() => {
fixtureInstance.thyValue = new Date('2021-10-10 10:00');
fixtureInstance.thyMaxDate = new Date('2021-10-10');
Expand All @@ -74,6 +75,7 @@ describe('ThyPickerDirective', () => {
const disabledCell = queryFromOverlay('tbody.thy-calendar-tbody td.thy-calendar-disabled-cell');
expect(disabledCell.textContent.trim()).toBe('11');
}));

it('should support thyMinDate', fakeAsync(() => {
fixtureInstance.thyValue = new Date('2021-10-11 11:00');
fixtureInstance.thyMinDate = new Date('2021-10-11');
Expand Down Expand Up @@ -103,6 +105,7 @@ describe('ThyPickerDirective', () => {
expect(debugElement.query(By.css('thy-picker .thy-input-disabled'))).toBeNull();
expect(debugElement.query(By.css('thy-picker thy-icon.thy-calendar-picker-clear'))).toBeDefined();
}));

it('should support thyShowTime', fakeAsync(() => {
// fixtureInstance.thyAllowClear = true;
fixtureInstance.thyValue = new Date();
Expand Down
7 changes: 6 additions & 1 deletion src/date-picker/date-picker.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import { ThyPickerComponent } from './picker.component';
import { ThyIconModule } from 'ngx-tethys/icon';
import { ThyInputModule } from 'ngx-tethys/input';
import { DatePickerRequiredValidator, RangePickerRequiredValidator } from './picker.validators';
import { ThyDatePickerFormatPipe, ThyDatePickerFormatStringPipe } from './picker.pipes';
import { ThyDatePickerFormatPipe, ThyDatePickerFormatStringPipe, ThyQuarterPickerFormatPipe } from './picker.pipes';
import { ThyDatePickerDirective } from './date-picker.directive';
import { ThyRangePickerDirective } from './range-picker.directive';
import { ThyPopoverModule } from 'ngx-tethys/popover';
import { ThyDatePickerConfigService } from './date-picker.service';
import { ThyQuarterPickerComponent } from './quarter-picker.component';

registerLocaleData(localeZhHans, 'zh-Hans');

Expand All @@ -36,11 +37,13 @@ registerLocaleData(localeZhHans, 'zh-Hans');
ThyDatePickerComponent,
ThyMonthPickerComponent,
ThyYearPickerComponent,
ThyQuarterPickerComponent,
ThyWeekPickerComponent,
ThyRangePickerComponent,
DatePickerRequiredValidator,
RangePickerRequiredValidator,
ThyDatePickerFormatPipe,
ThyQuarterPickerFormatPipe,
ThyDatePickerFormatStringPipe,
ThyDatePickerDirective,
ThyRangePickerDirective
Expand All @@ -50,10 +53,12 @@ registerLocaleData(localeZhHans, 'zh-Hans');
ThyRangePickerComponent,
ThyMonthPickerComponent,
ThyYearPickerComponent,
ThyQuarterPickerComponent,
ThyWeekPickerComponent,
DatePickerRequiredValidator,
RangePickerRequiredValidator,
ThyDatePickerFormatPipe,
ThyQuarterPickerFormatPipe,
ThyDatePickerFormatStringPipe,
ThyDatePickerDirective,
ThyRangePickerDirective
Expand Down
6 changes: 6 additions & 0 deletions src/date-picker/date-picker.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import { ThyDatePickerConfigService } from './date-picker.service';
import { DEFAULT_DATE_PICKER_CONFIG } from './date-picker.config';

describe('thyDatePickerConfigService Angular testing', () => {
let thyDatePickerConfigService: ThyDatePickerConfigService = new ThyDatePickerConfigService(DEFAULT_DATE_PICKER_CONFIG);
const { showShortcut, shortcutPosition, shortcutDatePresets, shortcutRangesPresets, weekStartsOn } = DEFAULT_DATE_PICKER_CONFIG;

it('get default shortcut', () => {
expect(thyDatePickerConfigService.showShortcut).toBe(showShortcut);
});

it('get default shortcut position', () => {
expect(thyDatePickerConfigService.shortcutPosition).toBe(shortcutPosition);
});

it('get default shortcut date presets', () => {
expect(thyDatePickerConfigService.shortcutDatePresets).toBe(shortcutDatePresets);
});

it('get default shortcut ranges presets', () => {
expect(thyDatePickerConfigService.shortcutRangesPresets).toBe(shortcutRangesPresets);
});

it('get default weekStartsOn', () => {
expect(thyDatePickerConfigService.config.weekStartsOn).toBe(weekStartsOn);
});
Expand Down
50 changes: 30 additions & 20 deletions src/date-picker/examples/basic/basic.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
thyPlaceHolder="选择时间"
[(ngModel)]="dateTime"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
></thy-date-picker>
[thyAllowClear]="isAllowClear"></thy-date-picker>
</thy-form-group>

<thy-form-group thyLabelText="高级时间选择器">
<thy-date-picker
class="d-block w-50 mb-3"
Expand All @@ -19,18 +19,17 @@
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
[thyShowShortcut]="true"
[thyShortcutPresets]="shortcutDatePresets"
></thy-date-picker>
[thyShortcutPresets]="shortcutDatePresets"></thy-date-picker>
</thy-form-group>

<thy-form-group thyLabelText="周选择器">
<thy-date-picker
class="d-block w-50 mb-3"
thyPlaceHolder="选择周"
[(ngModel)]="week"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
[thyMode]="'week'"
></thy-date-picker>
[thyMode]="'week'"></thy-date-picker>
</thy-form-group>

<thy-form-group thyLabelText="月份选择器">
Expand All @@ -39,8 +38,7 @@
[(ngModel)]="dateTime"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
thyPlaceHolder="请选择月份"
>
thyPlaceHolder="请选择月份">
</thy-month-picker>
</thy-form-group>

Expand All @@ -50,8 +48,16 @@
[(ngModel)]="dateTime"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
thyPlaceHolder="请选择年份"
></thy-year-picker>
thyPlaceHolder="请选择年份"></thy-year-picker>
</thy-form-group>

<thy-form-group thyLabelText="季度选择器">
<thy-quarter-picker
class="d-block w-50 mb-3"
[(ngModel)]="dateTime"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
thyPlaceHolder="请选择季度"></thy-quarter-picker>
</thy-form-group>

<thy-form-group thyLabelText="月份范围选择器">
Expand All @@ -61,17 +67,15 @@
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
[thyMode]="'month'"
[thyAutoStartAndEnd]="true"
></thy-range-picker>
[thyAutoStartAndEnd]="true"></thy-range-picker>
</thy-form-group>

<thy-form-group thyLabelText="日期范围选择器">
<thy-range-picker
class="d-block w-50 mb-3"
[(ngModel)]="dateRange"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
></thy-range-picker>
[thyAllowClear]="isAllowClear"></thy-range-picker>
</thy-form-group>

<thy-form-group thyLabelText="年范围选择器">
Expand All @@ -80,8 +84,7 @@
[(ngModel)]="yearRange"
thyMode="year"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
></thy-range-picker>
[thyAllowClear]="isAllowClear"></thy-range-picker>
</thy-form-group>

<thy-form-group thyLabelText="周范围选择器">
Expand All @@ -92,8 +95,16 @@
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
[thyShowShortcut]="true"
[thyShortcutPresets]="shortcutMonthPresets"
></thy-range-picker>
[thyShortcutPresets]="shortcutMonthPresets"></thy-range-picker>
</thy-form-group>

<thy-form-group thyLabelText="季度范围选择器">
<thy-range-picker
class="d-block w-50 mb-3"
[(ngModel)]="quarterRange"
thyMode="quarter"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"></thy-range-picker>
</thy-form-group>

<thy-form-group thyLabelText="高级范围选择器">
Expand All @@ -103,6 +114,5 @@
thyMode="flexible"
[thyShowShortcut]="true"
(ngModelChange)="onChange($event)"
[thyAllowClear]="isAllowClear"
></thy-range-picker>
[thyAllowClear]="isAllowClear"></thy-range-picker>
</thy-form-group>
4 changes: 3 additions & 1 deletion src/date-picker/examples/basic/basic.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export class ThyDatePickerBasicExampleComponent implements OnInit {
flexibleDateTime = 1234567890;
week = { date: new Date(), with_time: 0 };

dateRange = { begin: new Date('2021-10'), end: new Date('2021-12') };
dateRange = { begin: new Date('2023-10'), end: new Date('2023-12') };

weekRange = { begin: new Date('2021-10-03'), end: new Date('2021-12-12') };

yearRange = { begin: new Date('2021'), end: new Date('2028') };

quarterRange = { begin: new Date('2023-6'), end: new Date('2023-12') };

flexibleDateRange: ThyDateRangeEntry;

isAllowClear = true;
Expand Down

0 comments on commit b73b83b

Please sign in to comment.