Skip to content

Commit 12815db

Browse files
igauchfengtianze
authored andcommitted
feat: use template menu
1 parent bd1d2fc commit 12815db

33 files changed

+213
-249
lines changed

.changeset/famous-beers-sip.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@alauda/ui': minor
3+
---
4+
5+
feat: select, dropdown, tree-select and autocomplete add animation
6+
[BREAKING CHANGE] refactor: remove auiMenuContent directive; When using the auiDropdown directive, you cannot directly use aui-menu, but need to wrap it with ng-template, because the aui-menu template has been removed

src/autocomplete/autocomplete.directive.ts

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
} from 'rxjs';
3030

3131
import { BaseTooltip, TooltipTrigger, TooltipType } from '../tooltip';
32+
import { AnimationType } from '../tooltip/animations';
3233
import { scrollIntoView } from '../utils';
3334

3435
import { AutocompleteComponent } from './autocomplete.component';
@@ -93,6 +94,8 @@ export class AutoCompleteDirective
9394
@Input('auiAutocompleteAutoPatch')
9495
autoPatch = true;
9596

97+
override animationType: AnimationType = 'scaleY';
98+
9699
private _autocomplete: AutocompleteComponent;
97100
private focusedSuggestion: SuggestionComponent;
98101

src/core/animation/animation-consts.ts

+5
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ export enum AnimationDuration {
33
Base = '0.24s',
44
Fast = '0.2s',
55
}
6+
7+
export enum TimingFunction {
8+
easeOut = 'cubic-bezier(0, 0, 0.2, 1)',
9+
easeInOut = 'cubic-bezier(0.38, 0, 0.24, 1)',
10+
}

src/date-picker/date-picker/date-picker.template.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[format]="format"
55
style="display: flex"
66
[auiTooltip]="template"
7-
[auiDisableAnimation]="true"
7+
auiTooltipAnimType="none"
88
auiTooltipType="info"
99
auiTooltipClass="date-picker-wrapper"
1010
[disabled]="!!disabled"

src/date-picker/range-picker/range-picker.template.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[size]="size"
55
[value]="value"
66
[auiTooltip]="template"
7-
[auiDisableAnimation]="true"
7+
auiTooltipAnimType="none"
88
[disabled]="!!disabled"
99
style="display: flex"
1010
auiTooltipType="info"

src/dropdown/dropdown-button/dropdown-button.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@
2323
<aui-icon icon="angle_down"></aui-icon>
2424
</button>
2525
</div>
26+
<ng-template #menu><ng-content select="aui-menu"></ng-content></ng-template>

src/dropdown/dropdown-button/dropdown-button.component.ts

-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
AfterContentInit,
44
ChangeDetectionStrategy,
55
Component,
6-
ContentChild,
76
ContentChildren,
87
EventEmitter,
98
Input,
@@ -19,7 +18,6 @@ import { IconComponent } from '../../icon/icon.component';
1918
import { ComponentSize } from '../../types';
2019
import { Bem, buildBem, coerceAttrBoolean } from '../../utils';
2120
import { DropdownDirective } from '../dropdown.directive';
22-
import { MenuComponent } from '../menu/menu.component';
2321
import { MenuItemComponent } from '../menu-item/menu-item.component';
2422

2523
@Component({
@@ -53,9 +51,6 @@ export class DropdownButtonComponent implements AfterContentInit {
5351
@Output()
5452
buttonClick = new EventEmitter<Event>();
5553

56-
@ContentChild(MenuComponent, { static: true })
57-
menu: MenuComponent;
58-
5954
@ContentChildren(MenuItemComponent, { descendants: true })
6055
private readonly menuItems: QueryList<MenuItemComponent>;
6156

src/dropdown/dropdown.directive.ts

+5-38
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ import {
66
EventEmitter,
77
Input,
88
NgZone,
9-
OnInit,
109
Output,
1110
Renderer2,
1211
ViewContainerRef,
1312
} from '@angular/core';
14-
import { takeUntil } from 'rxjs';
1513

1614
import { BaseTooltip, TooltipTrigger, TooltipType } from '../tooltip';
15+
import { AnimationType } from '../tooltip/animations';
1716

1817
import { DropdownActiveDirective } from './dropdown-active.directive';
19-
import { MenuComponent } from './menu/menu.component';
2018

2119
@Directive({
2220
selector: '[auiDropdown]',
@@ -26,6 +24,8 @@ import { MenuComponent } from './menu/menu.component';
2624
'disabled:auiDropdownDisabled',
2725
'position:auiDropdownPosition',
2826
'trigger:auiDropdownTrigger',
27+
'context:auiDropdownContext',
28+
'content:auiDropdown',
2929
],
3030
providers: [
3131
{
@@ -35,30 +35,14 @@ import { MenuComponent } from './menu/menu.component';
3535
],
3636
standalone: true,
3737
})
38-
export class DropdownDirective extends BaseTooltip implements OnInit {
39-
@Input('auiDropdown')
40-
get menu() {
41-
return this._menu;
42-
}
43-
44-
set menu(value) {
45-
if (value === this._menu) {
46-
return;
47-
}
48-
this._menu = value;
49-
this.content = value.template;
50-
}
51-
52-
@Input('auiDropdownContext')
53-
lazyContentContext: any;
54-
38+
export class DropdownDirective extends BaseTooltip {
5539
@Input('auiDropdownHideOnClick')
5640
override hideOnClick = true;
5741

5842
@Output('auiDropdownVisibleChange')
5943
override visibleChange = new EventEmitter<boolean>();
6044

61-
private _menu: MenuComponent;
45+
override animationType: AnimationType = 'scaleY';
6246

6347
constructor(
6448
overlay: Overlay,
@@ -73,22 +57,5 @@ export class DropdownDirective extends BaseTooltip implements OnInit {
7357
this.type = TooltipType.Plain;
7458
this.position = 'bottom end';
7559
this.trigger = TooltipTrigger.Click;
76-
this.disableAnimation = false;
77-
this.animationType = 'scaleY';
78-
}
79-
80-
ngOnInit() {
81-
this.visibleChange.pipe(takeUntil(this.destroy$)).subscribe(visible => {
82-
if (this.menu.lazyContent) {
83-
if (visible) {
84-
setTimeout(() => {
85-
this.menu.lazyContent.attach(this.lazyContentContext);
86-
this.updatePosition();
87-
});
88-
} else {
89-
this.menu.lazyContent.detach();
90-
}
91-
}
92-
});
9360
}
9461
}

src/dropdown/dropdown.module.ts

-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { DropdownActiveDirective } from './dropdown-active.directive';
99
import { DropdownButtonComponent } from './dropdown-button/dropdown-button.component';
1010
import { DropdownDirective } from './dropdown.directive';
1111
import { MenuGroupTitleDirective } from './helper-directives';
12-
import { MenuContentDirective } from './menu/menu-content.directive';
1312
import { MenuComponent } from './menu/menu.component';
1413
import { MenuGroupComponent } from './menu-group/menu-group.component';
1514
import { MenuItemComponent } from './menu-item/menu-item.component';
@@ -29,7 +28,6 @@ import { SubmenuComponent } from './submenu/submenu.component';
2928
MenuGroupTitleDirective,
3029
MenuItemComponent,
3130
SubmenuComponent,
32-
MenuContentDirective,
3331
],
3432
exports: [
3533
DropdownDirective,
@@ -40,7 +38,6 @@ import { SubmenuComponent } from './submenu/submenu.component';
4038
MenuGroupTitleDirective,
4139
MenuItemComponent,
4240
SubmenuComponent,
43-
MenuContentDirective,
4441
],
4542
})
4643
export class DropdownModule {}

src/dropdown/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export * from './dropdown-active.directive';
55
export * from './dropdown-button/dropdown-button.component';
66
export * from './helper-directives';
77
export * from './menu/menu.component';
8-
export * from './menu/menu-content.directive';
98
export * from './menu-group/menu-group.component';
109
export * from './menu-item/menu-item.component';
1110
export * from './submenu/submenu.component';

src/dropdown/menu/menu-content.directive.ts

-67
This file was deleted.

src/dropdown/menu/menu.component.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
<ng-template>
2-
<div [class]="bem.block(size)"><ng-content></ng-content></div>
3-
</ng-template>
1+
<div [class]="bem.block(size)"><ng-content></ng-content></div>

src/dropdown/menu/menu.component.scss

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
@import '../../theme/var';
22
@import '../../theme/mixin';
33

4-
aui-menu {
5-
display: none;
6-
}
7-
84
$max-width: 280px;
95

106
$button-size: (

src/dropdown/menu/menu.component.ts

-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import {
22
ChangeDetectionStrategy,
33
Component,
4-
ContentChild,
54
Input,
6-
TemplateRef,
7-
ViewChild,
85
ViewEncapsulation,
96
} from '@angular/core';
107

118
import { ComponentSize } from '../../types';
129
import { Bem, buildBem } from '../../utils';
1310

14-
import { MenuContentDirective } from './menu-content.directive';
15-
1611
@Component({
1712
selector: 'aui-menu',
1813
templateUrl: './menu.component.html',
@@ -27,10 +22,4 @@ export class MenuComponent {
2722

2823
@Input()
2924
size: ComponentSize = ComponentSize.Small;
30-
31-
@ViewChild(TemplateRef, { static: true })
32-
template: TemplateRef<any>;
33-
34-
@ContentChild(MenuContentDirective, { static: true })
35-
lazyContent: MenuContentDirective;
3625
}

src/dropdown/submenu/submenu.component.html

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<button
22
[class]="className"
3-
[auiTooltip]="menu.template"
4-
auiTooltipAnimationType="scaleY"
3+
[auiTooltip]="menu"
4+
auiTooltipAnimType="scaleY"
55
[auiTooltipDisabled]="disabled"
66
[auiTooltipTrigger]="trigger"
77
[auiTooltipHideOnClick]="true"
@@ -18,9 +18,8 @@
1818
></aui-icon>
1919
</button>
2020

21-
<aui-menu
22-
#menu
23-
[size]="size"
24-
>
25-
<ng-content select="aui-menu-item"></ng-content>
26-
</aui-menu>
21+
<ng-template #menu>
22+
<aui-menu [size]="size">
23+
<ng-content select="aui-menu-item"></ng-content>
24+
</aui-menu>
25+
</ng-template>

src/paginator/__snapshots__/paginator.component.spec.ts.snap

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ exports[`PaginatorComponent should change page size correctly 1`] = `
118118
>
119119
<aui-select>
120120
<div
121+
auitooltipanimtype="scaleY"
121122
auitooltipposition="bottom start"
122123
auitooltiptrigger="click"
123124
auitooltiptype="plain"
@@ -395,6 +396,7 @@ exports[`PaginatorComponent should render current template 1`] = `
395396
>
396397
<aui-select>
397398
<div
399+
auitooltipanimtype="scaleY"
398400
auitooltipposition="bottom start"
399401
auitooltiptrigger="click"
400402
auitooltiptype="plain"
@@ -681,6 +683,7 @@ exports[`PaginatorComponent should render current template 2`] = `
681683
>
682684
<aui-select>
683685
<div
686+
auitooltipanimtype="scaleY"
684687
auitooltipposition="bottom start"
685688
auitooltiptrigger="click"
686689
auitooltiptype="plain"

0 commit comments

Comments
 (0)