Skip to content

Commit bbb5807

Browse files
chore(release): release 14.1.0 (#279)
Co-authored-by: huaweidevcloud <[email protected]>
1 parent 9ee29ae commit bbb5807

File tree

239 files changed

+6603
-2899
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+6603
-2899
lines changed

angular.json

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"highlight.js",
1919
"codemirror",
2020
"xss",
21-
"enquire.js",
2221
"color",
2322
"codesandbox"
2423
],

devui/anchor/anchor-box.directive.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ContentChildren, Directive, Input, OnDestroy, OnInit, QueryList } from '@angular/core';
2-
import { Subject, Subscription} from 'rxjs';
1+
import { ContentChildren, Directive, Input, OnDestroy, QueryList } from '@angular/core';
2+
import { Subject, Subscription } from 'rxjs';
33
import { filter } from 'rxjs/operators';
44
import { AnchorDirective } from './anchor.directive';
55
import { AnchorActiveChangeSource, IAnchorBox } from './anchor.type';

devui/auto-complete/auto-complete-popup.component.html

+13-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
<ng-template #popTpl>
2020
<div
2121
class="devui-dropdown-menu"
22-
[ngClass]="{ 'devui-dropdown-menu-cdk': appendToBody }"
22+
[ngClass]="{
23+
'devui-dropdown-menu-cdk': appendToBody,
24+
'devui-custom-right': customViewTemplate && customViewDirection === 'right',
25+
'devui-custom-left': customViewTemplate && customViewDirection === 'left',
26+
'devui-custom-top': customViewTemplate && customViewDirection === 'top'
27+
}"
2328
[style.display]="isOpen && (source?.length || noResultItemTemplate) && !disabled ? 'inline-block' : 'none'"
2429
[style.top]="overview === 'multiline' ? (position?.top < labelMinHeight ? '50%' : '100%') : '100%'"
2530
[style.left]="overview === 'multiline' ? position?.left + 'px' : '0'"
@@ -32,7 +37,7 @@
3237
[backdrop]="true"
3338
>
3439
<ul
35-
class="devui-list-unstyled devui-scrollbar scroll-height"
40+
class="devui-list-unstyled devui-scrollbar scroll-height devui-dropdown-menu-wrap"
3641
[style.maxHeight]="maxHeight + 'px'"
3742
dLazyLoad
3843
[enableLazyLoad]="enableLazyLoad"
@@ -53,6 +58,7 @@
5358
disabled: disabledKey && item[disabledKey]
5459
}"
5560
(click)="onSelect($event, item)"
61+
(mouseover)="onMouseOver($event, item)"
5662
>
5763
<ng-template
5864
[ngTemplateOutlet]="itemTemplate || defaultItemTemplate"
@@ -74,6 +80,11 @@
7480
<ng-template [ngTemplateOutlet]="searchingTemplate" [ngTemplateOutletContext]="{ term: term }"> </ng-template>
7581
</div>
7682
</ul>
83+
<ng-container *ngIf="customViewTemplate">
84+
<div class="devui-select-custom-area">
85+
<ng-template [ngTemplateOutlet]="customViewTemplate" [ngTemplateOutletContext]="{ $implicit: this }"></ng-template>
86+
</div>
87+
</ng-container>
7788
</div>
7889
</ng-template>
7990

devui/auto-complete/auto-complete-popup.component.scss

+54
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,60 @@
33
.devui-dropdown-menu {
44
width: 100%;
55
display: block;
6+
7+
&.devui-custom-right,
8+
&.devui-custom-left,
9+
&.devui-custom-top {
10+
min-width: 400px;
11+
display: flex !important;
12+
13+
& > .devui-dropdown-menu-wrap {
14+
display: inline-block;
15+
}
16+
17+
& > .devui-select-custom-area {
18+
display: inline-block;
19+
overflow: auto;
20+
}
21+
22+
&:not(.devui-custom-top) > .devui-dropdown-menu-wrap {
23+
width: calc(50% - 1px);
24+
}
25+
26+
&:not(.devui-custom-top) > .devui-select-custom-area {
27+
width: 50%;
28+
}
29+
30+
& > .devui-select-custom-area::before {
31+
display: none;
32+
}
33+
}
34+
35+
&.devui-custom-top {
36+
flex-direction: column-reverse;
37+
}
38+
39+
&.devui-custom-left > .devui-select-custom-area {
40+
border-right: 1px solid $devui-dividing-line;
41+
order: -1;
42+
}
43+
44+
&.devui-custom-right > .devui-select-custom-area {
45+
border-left: 1px solid $devui-dividing-line;
46+
}
47+
48+
&.devui-custom-top > .devui-select-custom-area {
49+
border-bottom: 1px solid $devui-dividing-line;
50+
}
51+
}
52+
53+
.devui-select-custom-area::before {
54+
display: block;
55+
content: '';
56+
width: calc(100% - 20px);
57+
margin: 0 10px;
58+
height: 1px;
59+
border-top: 1px solid $devui-dividing-line;
660
}
761

862
.devui-dropdown-menu-cdk {

devui/auto-complete/auto-complete-popup.component.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {
33
CdkOverlayOrigin,
44
ConnectedOverlayPositionChange,
55
ConnectedPosition,
6-
VerticalConnectionPos
6+
VerticalConnectionPos,
77
} from '@angular/cdk/overlay';
8-
import { Component, ElementRef, Input, TemplateRef, ViewChild } from '@angular/core';
8+
import { Component, ElementRef, EventEmitter, Input, Output, TemplateRef, ViewChild } from '@angular/core';
99
import { ControlValueAccessor } from '@angular/forms';
1010
import { fadeInOut } from 'ng-devui/utils';
1111
import { AutoCompleteConfig } from './auto-complete-config';
@@ -34,6 +34,8 @@ export class AutoCompletePopupComponent implements ControlValueAccessor {
3434
@Input() overview: string;
3535
@Input() itemTemplate: TemplateRef<any>;
3636
@Input() noResultItemTemplate: TemplateRef<any>;
37+
@Input() customViewTemplate: TemplateRef<any>;
38+
@Input() customViewDirection: 'bottom' | 'right' | 'left' | 'top' = 'bottom';
3739
@Input() searchingTemplate: TemplateRef<any>;
3840
@Input() isSearching = false;
3941
@Input() formatter: (item: any) => string;
@@ -44,6 +46,7 @@ export class AutoCompletePopupComponent implements ControlValueAccessor {
4446
@Input() cdkOverlayOffsetY = 0;
4547
@Input() origin: CdkOverlayOrigin | undefined;
4648
@Input() showAnimation = true;
49+
@Output() hoverItem: EventEmitter<any> = new EventEmitter();
4750
@ViewChild('selectMenuElement') selectMenuElement: ElementRef;
4851
@ViewChild('dropdownUl') dropdownUl: ElementRef;
4952
@ViewChild(CdkConnectedOverlay) connectedOverlay: CdkConnectedOverlay;
@@ -176,4 +179,8 @@ export class AutoCompletePopupComponent implements ControlValueAccessor {
176179
onPositionChange(position: ConnectedOverlayPositionChange) {
177180
this.popPosition = position.connectionPair.originY;
178181
}
182+
183+
onMouseOver(event: MouseEvent, item: any) {
184+
this.hoverItem.emit(item);
185+
}
179186
}

devui/auto-complete/auto-complete.directive.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export class AutoCompleteDirective implements OnInit, OnDestroy, OnChanges, Cont
102102
*/
103103
@Input() enableLazyLoad = false;
104104
@Input() allowEmptyValueSearch = false; // 在value为空时,是否允许进行搜索
105+
@Input() customViewTemplate: TemplateRef<any>;
106+
@Input() customViewDirection: 'bottom' | 'right' | 'left' | 'top' = 'bottom';
105107
@Output() loadMore = new EventEmitter<any>();
106108
@Output() selectValue = new EventEmitter<any>();
107109
@Output() transInputFocusEmit = new EventEmitter<any>(); // input状态传给父组件函数
@@ -110,6 +112,7 @@ export class AutoCompleteDirective implements OnInit, OnDestroy, OnChanges, Cont
110112
*/
111113
@Output() changeDropDownStatus = new EventEmitter<any>();
112114
@Output() toggleChange = new EventEmitter<boolean>();
115+
@Output() hoverItem: EventEmitter<any> = new EventEmitter();
113116
KEYBOARD_EVENT_NOT_REFRESH = ['escape', 'enter', 'arrowup', 'arrowdown', /* ie 10 edge */ 'esc', 'up', 'down'];
114117
popupRef: ComponentRef<AutoCompletePopupComponent>;
115118

@@ -136,9 +139,7 @@ export class AutoCompleteDirective implements OnInit, OnDestroy, OnChanges, Cont
136139
private changeDetectorRef: ChangeDetectorRef,
137140
private i18n: I18nService,
138141
private devConfigService: DevConfigService
139-
) {
140-
141-
}
142+
) {}
142143

143144
ngOnInit() {
144145
this.init();
@@ -150,6 +151,7 @@ export class AutoCompleteDirective implements OnInit, OnDestroy, OnChanges, Cont
150151
// 动态的创建了popup组件,
151152
const factory = this.componentFactoryResolver.resolveComponentFactory(AutoCompletePopupComponent);
152153
this.popupRef = this.viewContainerRef.createComponent(factory, this.viewContainerRef.length, this.injector);
154+
this.popupRef.instance.hoverItem.subscribe((item) => this.hoverItem.emit(item));
153155
this.fillPopup(this.source);
154156

155157
if (!this.searchFn) {
@@ -463,6 +465,8 @@ export class AutoCompleteDirective implements OnInit, OnDestroy, OnChanges, Cont
463465
'position',
464466
'overview',
465467
'showAnimation',
468+
'customViewTemplate',
469+
'customViewDirection',
466470
].forEach((key) => {
467471
if (this[key] !== undefined) {
468472
pop[key] = this[key];
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<d-button bsStyle="danger" type="submit">Buy</d-button>
1+
<d-button bsStyle="danger" type="submit">Delete</d-button>

devui/card/demo/card-demo.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { TranslateModule } from '@ngx-translate/core';
1111
import { DDemoNavModule } from 'devui-commons/src/demo-nav/d-demo-nav.module';
1212
import { BasicComponent } from './basic/basic.component';
1313
import { CardDemoComponent } from './card-demo.component';
14+
import { CardInteractiveComponent } from './card-interactive/card-interactive.component';
1415
import { CustomComponent } from './custom/custom.component';
1516
import { WithMediaComponent } from './with-media/with-media.component';
16-
import { CardInteractiveComponent } from './card-interactive/card-interactive.component';
1717

1818
@NgModule({
1919
declarations: [CardDemoComponent, BasicComponent, CustomComponent, WithMediaComponent, CardInteractiveComponent],

devui/cascader/cascader-li.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<ng-template
6868
[ngTemplateOutlet]="dropDownItemTemplate || defaultDropdownItemTemplate"
6969
[ngTemplateOutletContext]="{
70-
source: option,
70+
option: option,
7171
label: option.label
7272
}"
7373
>

devui/cascader/cascader.component.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
119119
this.cascaderSrv.initOptions(this.options);
120120
this.cascaderSrv.isMultiple = this.multiple;
121121
this.cascaderSrv.isLazyLoad = this.isLazyLoad;
122+
this.cascaderSrv.checkboxRelation = this.checkboxRelation;
122123
this.initObservale();
123124
this.initI18n();
124125
}
@@ -247,6 +248,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
247248
tagEvent.event.stopPropagation();
248249
this.cascaderSrv.updateOptionCheckedStatus(option.value, false, this.checkboxRelation.upward, this.checkboxRelation.downward);
249250
this.multipleValueList = this.multipleValueList.filter(t => t.value !== option.value);
251+
this.onChange(this.cascaderSrv.currentMultipleValue);
250252
// 当taglist变化导致input高度变化时,更新相对位置
251253
setTimeout(() => {
252254
this.mainDropdown.updateCdkConnectedOverlayOrigin();
@@ -287,9 +289,11 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
287289
const targetList = [];
288290
valueList.forEach(value => {
289291
let cur: CascaderItem;
292+
let cacheTarget: CascaderItem;
290293
let list = this.cascaderSrv.options;
291294
for (let i = 0; i < value.length; i++) {
292295
cur = list.find(l => l.value === value[i]);
296+
cacheTarget = cur;
293297
if (this.isLazyLoad && cur && !cur.children?.length && !cur.isLeaf) {
294298
this.cascaderSrv.lazyloadMultipleChild(cur, i);
295299
break;
@@ -299,17 +303,24 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
299303
}
300304
if (cur && cur.isLeaf) {
301305
targetList.push(cur);
306+
cacheTarget = null;
302307
this.cascaderSrv.updateOptionCheckedStatus(cur.value, true, this.checkboxRelation.upward, this.checkboxRelation.downward);
303308
}
309+
310+
if (cacheTarget) {
311+
targetList.push(cacheTarget);
312+
this.cascaderSrv.updateOptionCheckedStatus(cacheTarget.value, true, this.checkboxRelation.upward, this.checkboxRelation.downward);
313+
}
304314
});
315+
305316
return targetList;
306317
}
307318

308319
// 获取路径末的label
309320
getLabelFromValue(value: Array<number | string>): string {
310321
let cur;
311322
let list = this.cascaderSrv.options;
312-
value.map(item => {
323+
value.forEach(item => {
313324
cur = list.find(t => t.value === item) || '';
314325
list = cur.children || [];
315326
});
@@ -323,7 +334,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
323334
let cur;
324335
let list = this.cascaderSrv.options;
325336

326-
value.map((item, index) => {
337+
value.forEach((item, index) => {
327338
cur = list.find(t => t.value === item) || '';
328339
if (cur) {
329340
path = path === '' ? path + cur.label : path + ' / ' + cur.label;
@@ -385,7 +396,7 @@ export class CascaderComponent implements OnInit, OnDestroy, OnChanges, ControlV
385396
const width = this.dropdownComp.overlay.overlayRef?.overlayElement.clientWidth;
386397
const offsetX = this.dropdownComp.overlay.overlayRef?.overlayElement.offsetLeft;
387398
const offsetRight = window.innerWidth - width - offsetX - 20;
388-
this.subMenuDirections.map(t => {t.offsetX = offsetRight < 0 ? offsetRight : 0;});
399+
this.subMenuDirections.forEach(t => {t.offsetX = offsetRight < 0 ? offsetRight : 0;});
389400
this.dropdownComp.reposition();
390401
}, 0);
391402
}

devui/cascader/cascader.service.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class CascaderService implements OnDestroy {
2121

2222
isLazyLoad = false;
2323
lazyloadCache = {};
24+
checkboxRelation = { upward: true, downward: true };
2425

2526
loadChildrenFn: (value: CascaderItem) => Promise<CascaderItem[]> | Observable<CascaderItem[]>;
2627

@@ -274,16 +275,22 @@ export class CascaderService implements OnDestroy {
274275
}
275276

276277
getMultipleValue(value, option: CascaderItem[]): void {
278+
const isNoRelation = !this.checkboxRelation.downward || !this.checkboxRelation.upward;
277279
option.forEach(item => {
278280
const _value = [...value];
281+
_value.push(item.value);
279282
if (item.children && item.children.length && (item.checked || item.halfChecked)) {
280-
_value.push(item.value);
281283
this.getMultipleValue(_value, item.children);
284+
if (isNoRelation) {
285+
this.multipleValue.push(_value);
286+
}
282287
} else if (item.checked) {
283-
_value.push(item.value);
284288
this.multipleValue.push(_value);
289+
} else if (isNoRelation && item.children?.length) {
290+
this.getMultipleValue(_value, item.children);
285291
}
286292
});
293+
287294
}
288295

289296
closeAllDropdown(): void {

devui/cascader/demo/parent-select-cascader/parent-select-cascader.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class ParentSelectCascaderComponent {
106106
];
107107

108108
value1: Array<string | number>[] = [];
109-
value2: Array<string | number>[] = [[1, 4, 8], [1, 4, 9, 81], [1, 41]];
109+
value2: Array<string | number>[] = [ [1], [2], [1, 4]];
110110
value3: Array<string | number>[] = [[1, 4, 8], [1, 4, 9, 81], [1, 41]];
111111
value4: Array<string | number>[] = [[1, 4, 8], [1, 4, 9, 81], [1, 41]];
112112

0 commit comments

Comments
 (0)