Skip to content

Commit aaaa18e

Browse files
authored
Merge branch 'master' into mvenkov/reposition-outlet-in-perspective-container
2 parents bcea14b + 2c4c07b commit aaaa18e

File tree

11 files changed

+475
-69
lines changed

11 files changed

+475
-69
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ All notable changes for each version of this project will be documented in this
1919
- `IgxGrid`: The `findNext` and `findPrev` methods now have a new optional parameter called `exactMatch` (defaults to false).
2020
- If its value is false, all occurrences of the search text will be highlighted in the grid's cells.
2121
- If its value is true, the entire value of each cell should equals the search text in order to be highlighted (caseSensitive argument is respected as well).
22+
- `IgxChip`
23+
- Introduced event argument types to all `EventEmitter` `@Output`s.
24+
- **Breaking change** `onSelection`'s EventEmitter interface property `nextStatus` is renamed to `selected`.
25+
- `IgxChipArea`
26+
- Introduced event argument types to all `EventEmitter` `@Output`s.
27+
- `IgxCombo`
28+
- Added the following directives for `TemplateRef` assignment for combo templates (item, footer, etc.):
29+
- Added `IgxComboItemDirective`. Use `[igxComboItem]` in markup to assing a TemplateRef to `combo.itemTemplate`.
30+
- Added `IgxComboHeaderDirective`. Use `[igxComboHeader]` in markup to assing a TemplateRef to `combo.headerTemplate`.
31+
- Added `IgxComboFooterDirective`. Use `[igxComboFooter]` in markup to assing a TemplateRef to `combo.footerTemplate`.
32+
- Added `IgxComboEmptyDirective`. Use `[igxComboEmpty]` in markup to assing a TemplateRef to `combo.emptyTemplate`.
33+
- Added `IgxComboAddItemirective`. Use `[igxComboAddItem]` in markup to assing a TemplateRef to `combo.addItemTemplate`.
34+
- Added `IgxComboHeaderItemDirective`. Use `[igxComboHeaderItem]` in markup to assing a TemplateRef to `combo.headerItemTemplate`.
35+
- **Breaking change** Assigning templates with the following template ref variables is now deprecated in favor of the new directives:
36+
`#itemTemplate`, `#headerTemplate`, `#footerTemplate`, `#emptyTemplate`, `#addItemTemplate`, `#headerItemTemplate`.
2237

2338
## 6.1.3
2439
- **General**

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Current list of controls include:
2828
| **card** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/card/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/card.html) | | **hint** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/tree/master/projects/igniteui-angular/src/lib/input-group/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/input_group.html) |
2929
| **carousel** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/carousel/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/carousel.html) | | **input** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/input/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/input_group.html) |
3030
| **checkbox** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/checkbox/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/checkbox.html) | | **label** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/label/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/input_group.html) |
31-
| **chips** | In Progress | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/chips/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/chips.html) | | **layout** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/layout/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/layout.html) |
31+
| **chips** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/chips/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/chip.html) | | **layout** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/layout/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/layout.html) |
3232
| **circular progress** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/progressbar/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/circular_progress.html) | | **mask** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/mask/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/mask.html) |
3333
| **combo** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/combo/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/combo.html) | | **prefix** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/input-group/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/input_group.html) |
3434
| **datePicker** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/date-picker/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/date_picker.html) | | **ripple** | Available | [Readme](https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/directives/ripple/README.md) | [Docs](https://www.infragistics.com/products/ignite-ui-angular/angular/components/button.html) |
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# igxChip Component
2+
3+
The **igxChip** is a compact visual component that displays information in an obround. Chip can be templated, deleted, and selected. Multiple chips can be reordered and visually connected to each other. Chips reside in a container called chips area which is responsible for managing the interactions between the chips.
4+
5+
#### Initializing Chips
6+
7+
The `IgxChipComponent` is the main class for a chip elemenent and the `IgxChipsAreaComponent` is the main class for the chip area. The chip area is used when handling more complex scenarios that require interaction between chips (dragging, selection, navigation and etc.). The `IgxChipComponent` requires an `id` to be defined so that the different chips can be easily distinguished.
8+
9+
Example of using `igxChip` with `igxChipArea`:
10+
11+
```html
12+
<igx-chips-area>
13+
<igx-chip *ngFor="let chip of chipList" [id]="chip.id">
14+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
15+
</igx-chip>
16+
</igx-chips-area>
17+
```
18+
19+
### Features
20+
21+
#### Selection
22+
23+
Selection is disabled by default, but can be enabled with an option called `selectable`. The selecting is done by clicking on the chip itself or either by focusing the chip by using the `Tab` key and then pressing the `Space` key. An event `onSelection` is fired when the selection state of the `igxChip` changes. If a chip is already selected it can be deselected by pressing the `Space` key again while the chip is focused or by clicking on it.
24+
25+
```html
26+
<igx-chips-area #chipsArea>
27+
<igx-chip *ngFor="let chip of chipList" [selectable]="'true'">
28+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
29+
</igx-chip>
30+
</igx-chips-area>
31+
```
32+
33+
```ts
34+
public ngOnInit() {
35+
chipsArea.forEach((chip) => {
36+
chip.selectable = true;
37+
});
38+
}
39+
```
40+
41+
#### Removing
42+
43+
The `remove button` is part of the chip as well. You can control the remove button visibility by the `removable` boolean option. An event `onRemove` is fired when the end-user deletes a chip.
44+
45+
```html
46+
<igx-chips-area #chipsArea>
47+
<igx-chip *ngFor="let chip of chipList" [id]="chip.id" [removable]="'true'" (onRemove)="chipRemoved($event)">
48+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
49+
</igx-chip>
50+
</igx-chips-area>
51+
```
52+
53+
```ts
54+
public ngOnInit() {
55+
chipsArea.forEach((chip) => {
56+
chip.removable = true;
57+
});
58+
}
59+
60+
public chipRemoved(event) {
61+
this.chipList = this.chipList.filter((item) => {
62+
return item.id !== event.owner.id;
63+
});
64+
this.cdr.detectChanges();
65+
}
66+
```
67+
68+
#### Moving/Dragging
69+
70+
The chip can be dragged by the end-user in order to change it's position. The moving/dragging is disabled by default, but can be enabled with an option called `draggable`. You need to handle the actual moving of the chip in the data source manually.
71+
72+
```html
73+
<igx-chips-area #chipArea (onReorder)="chipsOrderChanged($event)">
74+
<igx-chip *ngFor="let chip of chipList" [draggable]="'true'">
75+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
76+
</igx-chip>
77+
</igx-chips-area>
78+
```
79+
80+
```ts
81+
public ngOnInit() {
82+
chipArea.forEach((chip) => {
83+
chip.draggable = true;
84+
});
85+
}
86+
87+
public chipsOrderChanged(event) {
88+
const newChipList = [];
89+
for (const chip of event.chipsArray) {
90+
const chipItem = this.chipList.filter((item) => {
91+
return item.id === chip.id;
92+
})[0];
93+
newChipList.push(chipItem);
94+
}
95+
this.chipList = newChipList;
96+
event.isValid = true;
97+
}
98+
99+
```
100+
101+
#### Chip Templates
102+
103+
The `IgxChipComponent`'s main structure consists of chip content, `remove button`, `prefix`, `suffix` and `connector`. All of those elements are templatable except the `remove button`.
104+
105+
The content of the chip is taken by the content defined inside the chip template except elements that define the `prefix`, `suffix` or `connector` of the chip. You can define any type of content you need.
106+
107+
The `prefix` and `suffix` are also elements inside the actual chip area where they can be templated by your preference. The way they can be specified is by respectively using the `IgxPrefix` and `IxgSuffix` directives.
108+
109+
Example of using an icon for `prefix`, a text for `label` and a custom icon button for `suffix`:
110+
111+
```html
112+
<igx-chip *ngFor="let chip of chipList" [id]="chip.id">
113+
<igx-icon igxPrefix fontSet="material" [name]="'drag_indicator'"></igx-icon>
114+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
115+
<span igxSuffix *ngIf="removable" igxButton="icon" (click)="onClick()">
116+
<igx-icon fontSet="material" [name]="'close'"></igx-icon>
117+
</span>
118+
</igx-chip>
119+
```
120+
121+
The `connectors` of the `igxChip` are fully templatable and are positioned after each chip. Their purpose is to provide a way to link two chips next to each other with an icon/text or anything you would like to use. The last chip (most right) does not have connector applied. Connectors hide while dragging chips around and show again when interactions with the chips have finished. The connector is defined by using the `IgxConnector` directive.
122+
123+
Example of using prefix connector:
124+
125+
```html
126+
<igx-chip *ngFor="let chip of chipList" [id]="chip.id">
127+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
128+
<span igxConnector> -> </span>
129+
</igx-chip>
130+
```
131+
132+
Example of using suffix connector:
133+
134+
```html
135+
<igx-chip *ngFor="let chip of chipList" [id]="chip.id">
136+
<span #label [class]="'igx-chip__text'">{{chip.text}}</span>
137+
<span igxSuffixConnector> -> </span>
138+
</igx-chip>
139+
```
140+
141+
#### Keyboard Navigation
142+
143+
The chip can be focused using the `Tab` key or by clicking on them. Chips can be reordered using keyboard navigation:
144+
145+
- Keyboard controls when the chip is focused:
146+
147+
- <kbd>LEFT</kbd> - Focuses the chip on the left
148+
- <kbd>RIGHT</kbd> - Focuses the chip on the right
149+
- <kbd>SPACE</kbd> - Toggles chip selection if it is selectable
150+
- <kbd>DELETE</kbd> - Fires the `onRemove` output so the chip deletion can be handled manually
151+
- <kbd>SHIFT</kbd> + <kbd>LEFT</kbd> - Moves the focused chip one position to the left
152+
- <kbd>SHIFT</kbd> + <kbd>RIGHT</kbd> - Moves the focused chip one position to the right
153+
154+
- Keyboard controls when the remove button is focused:
155+
156+
- <kbd>SPACE</kbd> or <kbd>ENTER</kbd> Fires the `onRemove` output so the chip deletion can be handled manually
157+
158+
# API
159+
160+
## IgxChipComponent
161+
162+
### Inputs
163+
| Name | Type | Description |
164+
|:----------|:-------------:|:------|
165+
| `id` | `string` | Unique identifier of the component. |
166+
| `draggable ` | `boolean` | Defines if the chip can be dragged in order to change it's position. |
167+
| `removable ` | `boolean` | Defines if the chip should render remove button and throw remove events. |
168+
| `selectable ` | `boolen` | Defines if the chip can be selected on click or through navigation. |
169+
| `selected` | `boolen` | Sets if the chip is selected. |
170+
| `disabled` | `boolean` | Defines if the chip is disabled. |
171+
| `displayDensity`| `DisplayDensity | string` | Sets the chip theme. Available options are `compact`, `cosy`, `comfortable`. |
172+
| `color` | `string` | Sets the chip background color. |
173+
174+
### Outputs
175+
| Name | Return Type | Description |
176+
|:--:|:---|:---|
177+
| `onMoveStart` | `any` | Fired when the chip moving(dragging) starts. |
178+
| `onMoveEnd` | `any` | Fired when the chip moving(dragging) end. |
179+
| `onRemove ` | `any` | Fired when the chip remove button is clicked. |
180+
| `onClick ` | `any` | Fired when the chip is clicked instead of dragged. |
181+
| `onSelection` | `IChipSelectEventArgs` | Fired when the chip is being selected. |
182+
| `onKeyDown ` | `any` | Fired when the chip keyboard navigation is being used. |
183+
| `onDragEnter ` | `any` | Fired when another chip has entered the current chip area. |
184+
185+
## IgxChipsAreaComponent
186+
187+
### Inputs
188+
| Name | Type | Description |
189+
|:----------|:-------------:|:------|
190+
| `width` | `number` | Sets the width of the chips area. |
191+
| `height ` | `number` | Sets the height of the chip area. |
192+
193+
### Outputs
194+
| Name | Return Type | Description |
195+
|:--:|:---|:---|
196+
| `onReorder ` | `any` | Fired when the chip moving(dragging) starts. |
197+
| `onSelection ` | `any` | Fired when the chip moving(dragging) end. |
198+
| `onMoveStart ` | `any` | Fired when the chip remove button is clicked. |
199+
| `onMoveEnd ` | `any` | Fired when the chip is clicked instead of dragged. |
200+
201+
### Properties
202+
| Name | Return Type | Description |
203+
|:----------:|:------|:------|
204+
| `chipsList` | `QueryList<IgxChipComponent>` | Returns the list of chips inside the chip area. |

projects/igniteui-angular/src/lib/chips/chip.component.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ import { IgxSuffixDirective } from '../directives/suffix/suffix.directive';
2323
import { IgxDragDirective } from '../directives/dragdrop/dragdrop.directive';
2424
import { DisplayDensity } from '../core/utils';
2525

26+
export interface IChipSelectEventArgs {
27+
owner: IgxChipComponent;
28+
cancel: boolean;
29+
selected: boolean;
30+
}
31+
2632
let CHIP_ID = 0;
2733

2834
@Component({
@@ -218,17 +224,19 @@ export class IgxChipComponent implements AfterViewInit {
218224

219225
/**
220226
* Emits event when the `IgxChipComponent` is selected.
227+
* Returns the selected chip reference, whether the event should be canceled,
228+
* and what is the next selection state.
221229
* ```typescript
222-
* chipSelect(){
223-
* alert("The chip has been selected.");
230+
* chipSelect(event: IChipSelectEventArgs){
231+
* const selectArgs = event;
224232
* }
225233
* ```
226234
* ```html
227235
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (onSelection)="chipSelect()">
228236
* ```
229237
*/
230238
@Output()
231-
public onSelection = new EventEmitter<any>();
239+
public onSelection = new EventEmitter<IChipSelectEventArgs>();
232240

233241
/**
234242
* Emits event when the `IgxChipComponent` keyboard navigation is being used.
@@ -312,13 +320,13 @@ export class IgxChipComponent implements AfterViewInit {
312320
* ```
313321
*/
314322
public set selected(newValue: boolean) {
315-
const onSelectArgs = {
323+
const onSelectArgs: IChipSelectEventArgs = {
316324
owner: this,
317-
nextStatus: false,
325+
selected: false,
318326
cancel: false
319327
};
320328
if (newValue && !this._selected) {
321-
onSelectArgs.nextStatus = true;
329+
onSelectArgs.selected = true;
322330
this.onSelection.emit(onSelectArgs);
323331

324332
if (!onSelectArgs.cancel) {

projects/igniteui-angular/src/lib/chips/chips-area.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ export class IgxChipsAreaComponent implements DoCheck {
279279
* @hidden
280280
*/
281281
protected onChipSelectionChange(event) {
282-
if (event.nextStatus) {
282+
if (event.selected) {
283283
this.selectedChips.push(event.owner);
284-
} else if (!event.nextStatus) {
284+
} else if (!event.selected) {
285285
this.selectedChips = this.selectedChips.filter((chip) => {
286286
return chip.id !== event.owner.id;
287287
});

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,17 +3080,17 @@ class IgxComboScrollTestComponent {
30803080
<igx-combo #combo [placeholder]="'Location'" [data]='items'
30813081
[filterable]='true' [valueKey]="'field'" [groupKey]="'region'" [width]="'400px'"
30823082
(onSelectionChange)="onSelectionChange($event)" [allowCustomValues]="true">
3083-
<ng-template #itemTemplate let-display let-key="valueKey">
3083+
<ng-template igxComboItem let-display let-key="valueKey">
30843084
<div class="state-card--simple">
30853085
<span class="small-red-circle"></span>
30863086
<div class="display-value--main">State: {{display[key]}}</div>
30873087
<div class="display-value--sub">Region: {{display.region}}</div>
30883088
</div>
30893089
</ng-template>
3090-
<ng-template #headerTemplate>
3090+
<ng-template igxComboHeader>
30913091
<div class="header-class">This is a header</div>
30923092
</ng-template>
3093-
<ng-template #footerTemplate>
3093+
<ng-template igxComboFooter>
30943094
<div class="footer-class">This is a footer</div>
30953095
</ng-template>
30963096
</igx-combo>

0 commit comments

Comments
 (0)