Skip to content

Commit 622faad

Browse files
desig9steinsimeonoffSisIvanovajackofdiamond5Lipata
authored
refactor(input): use the same design as web components. (#12453)
* refactor(input): use the same design as web components --------- Co-authored-by: Simeon Simeonoff <[email protected]> Co-authored-by: Silvia Ivanova <[email protected]> Co-authored-by: Boris Penkov <[email protected]> Co-authored-by: Nikolay Alipiev <[email protected]> Co-authored-by: Konstantin Dinev <[email protected]>
1 parent d072852 commit 622faad

Some content is hidden

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

55 files changed

+3771
-2410
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes for each version of this project will be documented in this file.
44

5+
## 15.1.1
6+
- **Breaking Changes** - ` $label-floated-background` and `$label-floated-disabled-background` properties of `IgxInputGroupComponent` theme has been removed.
7+
- `IgxInputGroupComponent` The input group has been refactored so that the floating label for the input of `type="border"` does not require a background to match the surface background under the input field. Also, suffixes and prefixes are refactored to take the full height of the input which makes it easy to add background to them.
8+
-
9+
- **Breaking Changes** - `$size` property of `scrollbar-theme` theme has been renamed to `$scrollbar-size`.
10+
511
## 15.1.0
612

713
### New Features
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "../../common/schema/theme-changes.schema.json",
3+
"changes": [
4+
{
5+
"name": "$size",
6+
"replaceWith": "$scrollbar-size",
7+
"owner": "scrollbar-theme",
8+
"type":"property"
9+
},
10+
{
11+
"name": "$label-floated-background",
12+
"remove": true,
13+
"owner": "input-group-theme",
14+
"type":"property"
15+
},
16+
{
17+
"name": "$label-floated-disabled-background",
18+
"remove": true,
19+
"owner": "input-group-theme",
20+
"type":"property"
21+
}
22+
]
23+
}

projects/igniteui-angular/migrations/update-15_1_0/index.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,34 @@ describe(`Update to ${version}`, () => {
138138
`
139139
);
140140
});
141+
142+
it('should rename the $size property to the $scrollbar-size', async () => {
143+
appTree.create(
144+
`/testSrc/appPrefix/component/test.component.scss`,
145+
`$custom-scrollbar: scrollbar-theme($size: 10px);`
146+
);
147+
148+
const tree = await schematicRunner
149+
.runSchematicAsync(migrationName, {}, appTree)
150+
.toPromise();
151+
152+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.scss')).toEqual(
153+
`$custom-scrollbar: scrollbar-theme($scrollbar-size: 10px);`
154+
);
155+
});
156+
157+
it('should remove the $label-floated-background amd $label-floated-disabled-background properties from the input-group-theme', async () => {
158+
appTree.create(
159+
`/testSrc/appPrefix/component/test.component.scss`,
160+
`$custom-input: input-group-theme($label-floated-background: transparent, $label-floated-disabled-background: transparent);`
161+
);
162+
163+
const tree = await schematicRunner
164+
.runSchematicAsync(migrationName, {}, appTree)
165+
.toPromise();
166+
167+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.scss')).toEqual(
168+
`$custom-input: input-group-theme();`
169+
);
170+
});
141171
});

projects/igniteui-angular/src/lib/combo/combo.common.ts

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import {
2+
AfterContentChecked,
3+
AfterViewChecked,
24
AfterViewInit,
35
ChangeDetectorRef,
46
ContentChild,
7+
ContentChildren,
58
Directive,
69
DoCheck,
710
ElementRef,
@@ -16,6 +19,7 @@ import {
1619
OnInit,
1720
Optional,
1821
Output,
22+
QueryList,
1923
TemplateRef,
2024
ViewChild
2125
} from '@angular/core';
@@ -30,7 +34,7 @@ import { SortingDirection } from '../data-operations/sorting-strategy';
3034
import { IForOfState, IgxForOfDirective } from '../directives/for-of/for_of.directive';
3135
import { IgxIconService } from '../icon/public_api';
3236
import { IgxInputGroupType, IGX_INPUT_GROUP_TYPE } from '../input-group/inputGroupType';
33-
import { IgxInputDirective, IgxInputGroupComponent, IgxInputState, IgxLabelDirective } from '../input-group/public_api';
37+
import { IgxInputDirective, IgxInputGroupComponent, IgxInputState, IgxLabelDirective, IgxPrefixDirective, IgxSuffixDirective } from '../input-group/public_api';
3438
import { AbsoluteScrollStrategy, AutoPositionStrategy, OverlaySettings } from '../services/public_api';
3539
import { IgxComboDropDownComponent } from './combo-dropdown.component';
3640
import { IgxComboAPIService } from './combo.api';
@@ -124,8 +128,8 @@ export interface IComboFilteringOptions {
124128
}
125129

126130
@Directive()
127-
export abstract class IgxComboBaseDirective extends DisplayDensityBase implements IgxComboBase, OnInit, DoCheck,
128-
AfterViewInit, OnDestroy, ControlValueAccessor {
131+
export abstract class IgxComboBaseDirective extends DisplayDensityBase implements IgxComboBase, AfterViewChecked, OnInit, DoCheck,
132+
AfterViewInit, AfterContentChecked, OnDestroy, ControlValueAccessor {
129133
/**
130134
* Defines whether the caseSensitive icon should be shown in the search input
131135
*
@@ -752,6 +756,12 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
752756
@ViewChild('complex', { read: TemplateRef, static: true })
753757
protected complexTemplate: TemplateRef<any>;
754758

759+
@ContentChildren(IgxPrefixDirective, { descendants: true })
760+
protected prefixes: QueryList<IgxPrefixDirective>;
761+
762+
@ContentChildren(IgxSuffixDirective, { descendants: true })
763+
protected suffixes: QueryList<IgxSuffixDirective>;
764+
755765
/** @hidden @internal */
756766
public get searchValue(): string {
757767
return this._searchValue;
@@ -950,24 +960,39 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
950960
super(_displayDensityOptions);
951961
}
952962

953-
/** @hidden @internal */
954-
public ngOnInit() {
955-
this.ngControl = this._injector.get<NgControl>(NgControl, null);
956-
const targetElement = this.elementRef.nativeElement;
963+
public ngAfterViewChecked() {
964+
const targetElement = this.inputGroup.element.nativeElement.querySelector('.igx-input-group__bundle') as HTMLElement;
965+
957966
this._overlaySettings = {
958967
target: targetElement,
959968
scrollStrategy: new AbsoluteScrollStrategy(),
960969
positionStrategy: new AutoPositionStrategy(),
961970
modal: false,
962971
closeOnOutsideClick: true,
963-
excludeFromOutsideClick: [targetElement as HTMLElement]
972+
excludeFromOutsideClick: [targetElement]
964973
};
974+
}
975+
976+
/** @hidden @internal */
977+
public ngAfterContentChecked(): void {
978+
if (this.inputGroup && this.prefixes?.length > 0) {
979+
this.inputGroup.prefixes = this.prefixes;
980+
}
981+
982+
if (this.inputGroup && this.suffixes?.length > 0) {
983+
this.inputGroup.suffixes = this.suffixes;
984+
}
985+
}
986+
987+
/** @hidden @internal */
988+
public ngOnInit() {
989+
this.ngControl = this._injector.get<NgControl>(NgControl, null);
965990
this.selectionService.set(this.id, new Set());
966991
this._iconService.addSvgIconFromText(caseSensitive.name, caseSensitive.value, 'imx-icons');
967992
}
968993

969994
/** @hidden @internal */
970-
public ngAfterViewInit() {
995+
public ngAfterViewInit(): void {
971996
this.filteredData = [...this.data];
972997

973998
if (this.ngControl) {
@@ -982,14 +1007,14 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
9821007
}
9831008

9841009
/** @hidden @internal */
985-
public ngDoCheck() {
1010+
public ngDoCheck(): void {
9861011
if (this.data?.length && this.selection.length && !this._value) {
9871012
this._value = this.createDisplayText(this.selection, []);
9881013
}
9891014
}
9901015

9911016
/** @hidden @internal */
992-
public ngOnDestroy() {
1017+
public ngOnDestroy(): void {
9931018
this.destroy$.next();
9941019
this.destroy$.complete();
9951020
this.comboAPI.clear();
@@ -1068,6 +1093,26 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
10681093
return this.selectionService.is_item_selected(this.id, item);
10691094
}
10701095

1096+
/** @hidden @internal */
1097+
public get toggleIcon(): string {
1098+
if (this.inputGroup.theme === 'material') {
1099+
return this.dropdown.collapsed
1100+
? 'expand_more'
1101+
: 'expand_less';
1102+
}
1103+
1104+
return this.dropdown.collapsed
1105+
? 'arrow_drop_down'
1106+
: 'arrow_drop_up';
1107+
}
1108+
1109+
/** @hidden @internal */
1110+
public get clearIcon(): string {
1111+
return this.inputGroup.theme === 'material'
1112+
? 'cancel'
1113+
: 'clear';
1114+
}
1115+
10711116
/** @hidden @internal */
10721117
public addItemToCollection() {
10731118
if (!this.searchValue) {

projects/igniteui-angular/src/lib/combo/combo.component.html

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,35 @@
2323
<ng-container *ngTemplateOutlet="clearIconTemplate"></ng-container>
2424
</ng-container>
2525
<igx-icon *ngIf="!clearIconTemplate">
26-
clear
26+
{{ clearIcon }}
2727
</igx-icon>
2828
</igx-suffix>
2929
<igx-suffix class="igx-combo__toggle-button">
3030
<ng-container *ngIf="toggleIconTemplate">
3131
<ng-container *ngTemplateOutlet="toggleIconTemplate; context: {$implicit: this.collapsed}"></ng-container>
3232
</ng-container>
3333
<igx-icon *ngIf="!toggleIconTemplate">
34-
{{ dropdown.collapsed ? 'arrow_drop_down' : 'arrow_drop_up'}}
34+
{{ toggleIcon }}
3535
</igx-icon>
3636
</igx-suffix>
3737
</igx-input-group>
3838
<igx-combo-drop-down #igxComboDropDown class="igx-combo__drop-down" [displayDensity]="displayDensity"
3939
[labelledBy]="this.ariaLabelledBy || this.label?.id || this.placeholder || ''"
4040
[width]="itemsWidth || '100%'" (opening)="handleOpening($event)" (closing)="handleClosing($event)"
4141
(opened)="handleOpened()" (closed)="handleClosed()">
42-
<igx-input-group *ngIf="displaySearchInput" [displayDensity]="displayDensity" theme="material" class="igx-combo__search">
43-
<input class="igx-combo-input" igxInput #searchInput name="searchInput" autocomplete="off" type="text"
44-
[(ngModel)]="searchValue" (ngModelChange)="handleInputChange($event)" (keyup)="handleKeyUp($event)"
45-
(keydown)="handleKeyDown($event)" (focus)="dropdown.onBlur($event)" [attr.placeholder]="searchPlaceholder"
46-
aria-autocomplete="list" role="searchbox" aria-label="search"/>
47-
<igx-suffix *ngIf="showSearchCaseIcon">
48-
<igx-icon family="imx-icons" name="case-sensitive" [active]="filteringOptions.caseSensitive"
49-
(click)="toggleCaseSensitive()">
50-
</igx-icon>
51-
</igx-suffix>
52-
</igx-input-group>
42+
<div class="igx-combo__search">
43+
<igx-input-group *ngIf="displaySearchInput" [displayDensity]="displayDensity" theme="material" >
44+
<input igxInput #searchInput name="searchInput" autocomplete="off" type="text"
45+
[(ngModel)]="searchValue" (ngModelChange)="handleInputChange($event)" (keyup)="handleKeyUp($event)"
46+
(keydown)="handleKeyDown($event)" (focus)="dropdown.onBlur($event)" [attr.placeholder]="searchPlaceholder"
47+
aria-autocomplete="list" role="searchbox" aria-label="search"/>
48+
<igx-suffix *ngIf="showSearchCaseIcon" (click)="toggleCaseSensitive()">
49+
<span [ngClass]="filteringOptions.caseSensitive? 'igx-combo__case-icon--active' : 'igx-combo__case-icon'">
50+
<igx-icon family="imx-icons" name="case-sensitive" [active]="filteringOptions.caseSensitive"></igx-icon>
51+
</span>
52+
</igx-suffix>
53+
</igx-input-group>
54+
</div>
5355
<ng-container *ngTemplateOutlet="headerTemplate">
5456
</ng-container>
5557
<div #dropdownItemContainer class="igx-combo__content" [style.overflow]="'hidden'"

0 commit comments

Comments
 (0)