-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kit):
MultiSelect
add ability to use native dropdown on mobile (…
- Loading branch information
1 parent
d20b0e7
commit 35b86e0
Showing
23 changed files
with
347 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import {Directive} from '@angular/core'; | ||
import {Directive, Provider, Type} from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: 'ng-template[tuiDataList]', | ||
}) | ||
export class TuiDataListDirective {} | ||
|
||
export function tuiAsDataList(useExisting: Type<TuiDataListDirective>): Provider { | ||
return { | ||
provide: TuiDataListDirective, | ||
useExisting, | ||
}; | ||
} |
37 changes: 37 additions & 0 deletions
37
projects/demo/src/modules/components/multi-select/examples/10/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<tui-multi-select | ||
placeholder="Ignored text" | ||
class="b-form" | ||
[formControl]="itemControl" | ||
[tuiTextfieldLabelOutside]="true" | ||
[tuiTextfieldCleaner]="true" | ||
[tuiHintContent]="'hint'" | ||
[editable]="false" | ||
> | ||
Star Wars persons | ||
|
||
<select | ||
tuiSelect | ||
tuiMultiSelectGroup | ||
multiple | ||
[items]="items" | ||
></select> | ||
</tui-multi-select> | ||
|
||
<tui-multi-select | ||
placeholder="Ignored text" | ||
class="b-form tui-space_top-5" | ||
[formControl]="itemGroupControl" | ||
[tuiTextfieldLabelOutside]="true" | ||
[editable]="false" | ||
[disabledItemHandler]="disableHandler" | ||
> | ||
Star Wars persons | ||
|
||
<select | ||
tuiSelect | ||
tuiMultiSelectGroup | ||
multiple | ||
[items]="groupItems" | ||
[labels]="labels" | ||
></select> | ||
</tui-multi-select> |
34 changes: 34 additions & 0 deletions
34
projects/demo/src/modules/components/multi-select/examples/10/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Component} from '@angular/core'; | ||
import {FormControl} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiBooleanHandler} from '@taiga-ui/cdk'; | ||
|
||
@Component({ | ||
selector: 'tui-multi-select-example-10', | ||
templateUrl: './index.html', | ||
changeDetection, | ||
encapsulation, | ||
}) | ||
export class TuiMultiSelectExample10 { | ||
itemControl = new FormControl(); | ||
itemGroupControl = new FormControl(); | ||
|
||
items = [ | ||
'Luke Skywalker', | ||
'Leia Organa Solo', | ||
'Darth Vader', | ||
'Han Solo', | ||
'Obi-Wan Kenobi', | ||
'Yoda', | ||
]; | ||
|
||
groupItems = [ | ||
['Caesar', 'Greek', 'Apple and Chicken'], | ||
['Broccoli Cheddar', 'Chicken and Rice', 'Chicken Noodle'], | ||
]; | ||
|
||
labels = ['Salad', 'Soup']; | ||
|
||
disableHandler: TuiBooleanHandler<string> = item => item.startsWith('Broccoli'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
export * from './hide-selected.pipe'; | ||
export * from './multi-select.component'; | ||
export * from './multi-select.directive'; | ||
export * from './multi-select.module'; | ||
export * from './multi-select-group/multi-select-group.component'; | ||
export * from './multi-select-group/multi-select-group.directive'; | ||
export * from './multi-select-options'; | ||
export * from './native-multi-select/native-multi-select'; | ||
export * from './native-multi-select/native-multi-select.component'; | ||
export * from './native-multi-select/native-multi-select-group.component'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
projects/kit/components/multi-select/multi-select.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Directive} from '@angular/core'; | ||
import {TuiBooleanHandler} from '@taiga-ui/cdk'; | ||
import {AbstractTuiTextfieldHost, tuiAsTextfieldHost} from '@taiga-ui/core'; | ||
|
||
import type {TuiMultiSelectComponent} from './multi-select.component'; | ||
|
||
@Directive({ | ||
selector: 'tui-multi-select', | ||
providers: [tuiAsTextfieldHost(TuiMultiSelectDirective)], | ||
}) | ||
export class TuiMultiSelectDirective extends AbstractTuiTextfieldHost< | ||
TuiMultiSelectComponent<string> | ||
> { | ||
override get readOnly(): boolean { | ||
return true; | ||
} | ||
|
||
disableItemHandler: TuiBooleanHandler<string> = item => | ||
this.host.disabledItemHandler(item); | ||
|
||
onValueChange(_: string): void { | ||
// | ||
} | ||
|
||
onSelectionChange(value: string[]): void { | ||
this.host.onValueChange(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,4 +71,8 @@ | |
.t-arrow { | ||
pointer-events: auto; | ||
cursor: pointer; | ||
|
||
&_native-dropdown { | ||
pointer-events: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ts/kit/components/multi-select/native-multi-select/native-multi-select-group.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {ChangeDetectionStrategy, Component, Input, TemplateRef} from '@angular/core'; | ||
import {tuiAsDataList} from '@taiga-ui/core'; | ||
|
||
import {AbstractTuiNativeMultiSelect} from './native-multi-select'; | ||
|
||
@Component({ | ||
selector: 'select[multiple][tuiSelect][labels]', | ||
templateUrl: './native-multi-select-group.template.html', | ||
providers: [ | ||
tuiAsDataList(TuiNativeMultiSelectGroupComponent), | ||
{ | ||
provide: TemplateRef, | ||
deps: [TuiNativeMultiSelectGroupComponent], | ||
useFactory: ({datalist}: TuiNativeMultiSelectGroupComponent) => datalist, | ||
}, | ||
{ | ||
provide: AbstractTuiNativeMultiSelect, | ||
useExisting: TuiNativeMultiSelectGroupComponent, | ||
}, | ||
], | ||
host: { | ||
'[attr.aria-invalid]': 'host.invalid', | ||
'[disabled]': 'host.disabled || control.readOnly', | ||
'[tabIndex]': 'host.focusable ? 0 : -1', | ||
'(change)': 'onValueChange()', | ||
'(click.stop.silent)': '0', | ||
'(mousedown.stop.silent)': '0', | ||
}, | ||
styleUrls: ['./native-multi-select.style.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiNativeMultiSelectGroupComponent extends AbstractTuiNativeMultiSelect { | ||
@Input() | ||
items: readonly string[][] | null = []; | ||
|
||
@Input() | ||
labels: readonly string[] = []; | ||
} |
Oops, something went wrong.