Skip to content

Commit

Permalink
feat(module:select): support option height and opiton overflow size (#…
Browse files Browse the repository at this point in the history
…5133)

close #5112
  • Loading branch information
Yadong Xie authored Apr 24, 2020
1 parent d69415a commit 7b3937e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/select/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import { NzSelectModule } from 'ng-zorro-antd/select';
| `[nzLoading]` | indicate loading state | `boolean` | false |
| `[nzMaxTagCount]` | Max tag count to show| `number` | - |
| `[nzMaxTagPlaceholder]` | Placeholder for not showing tags | `TemplateRef<{ $implicit: any[] }>` | - |
| `[nzOptionHeightPx]` | Each option height inside the dropdown | `number` | `32` |
| `[nzOptionOverflowSize]` | Max option size inside the dropdown, overflow when exceed the size | `number` | `8` |
| `(ngModelChange)` | Current selected nz-option value change callback. | `EventEmitter<any[]>` | - |
| `(nzOpenChange)` | dropdown expand change callback | `EventEmitter<boolean>` | `false` |
| `(nzScrollToBottom)` | Called when dropdown scrolls to bottom | `EventEmitter<any>` | - |
Expand Down
2 changes: 2 additions & 0 deletions components/select/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import { NzSelectModule } from 'ng-zorro-antd/select';
| `[nzLoading]` | 加载中状态 | `boolean` | `false` |
| `[nzMaxTagCount]` | 最多显示多少个 tag | `number` | - |
| `[nzMaxTagPlaceholder]` | 隐藏 tag 时显示的内容 | `TemplateRef<{ $implicit: any[] }>` | - |
| `[nzOptionHeightPx]` | 下拉菜单中每个 Option 的高度 | `number` | `32` |
| `[nzOptionOverflowSize]` | 下拉菜单中最多展示的 Option 个数,超出部分滚动 | `number` | `8` |
| `(ngModelChange)` | 选中的 nz-option 发生变化时,调用此函数 | `EventEmitter<any[]>` | - |
| `(nzOpenChange)` | 下拉菜单打开状态变化回调 | `EventEmitter<boolean>` | - |
| `(nzScrollToBottom)` | 下拉列表滚动到底部的回调 | `EventEmitter<any>` | - |
Expand Down
4 changes: 2 additions & 2 deletions components/select/option-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ export class NzOptionContainerComponent implements OnChanges, AfterViewInit {
@Input() compareWith: (o1: NzSafeAny, o2: NzSafeAny) => boolean;
@Input() mode: NzSelectModeType = 'default';
@Input() matchWidth = true;
@Input() itemSize = 32;
@Input() maxItemLength = 8;
@Input() listOfContainerItem: NzSelectItemInterface[] = [];
@Output() readonly itemClick = new EventEmitter<NzSafeAny>();
@Output() readonly scrollToBottom = new EventEmitter<void>();
@ViewChild(CdkVirtualScrollViewport, { static: true }) cdkVirtualScrollViewport: CdkVirtualScrollViewport;
private scrolledIndex = 0;
readonly itemSize = 32;
readonly maxItemLength = 8;

onItemClick(value: NzSafeAny): void {
this.itemClick.emit(value);
Expand Down
4 changes: 4 additions & 0 deletions components/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export type NzSelectSizeType = 'large' | 'default' | 'small';
>
<nz-option-container
[ngStyle]="nzDropdownStyle"
[itemSize]="nzOptionHeightPx"
[maxItemLength]="nzOptionOverflowSize"
[matchWidth]="nzDropdownMatchSelectWidth"
[class.ant-select-dropdown-placement-bottomLeft]="dropDownPosition === 'bottom'"
[class.ant-select-dropdown-placement-topLeft]="dropDownPosition === 'top'"
Expand Down Expand Up @@ -170,6 +172,8 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie
static ngAcceptInputType_nzOpen: BooleanInput;

@Input() nzSize: NzSelectSizeType = 'default';
@Input() nzOptionHeightPx = 32;
@Input() nzOptionOverflowSize = 8;
@Input() nzDropdownClassName: string | null = null;
@Input() nzDropdownMatchSelectWidth = true;
@Input() nzDropdownStyle: { [key: string]: string } | null = null;
Expand Down

0 comments on commit 7b3937e

Please sign in to comment.