Skip to content

Commit

Permalink
feat(module: checkboxItem&radioItem): API sync with listItem (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisherspy committed Apr 30, 2019
1 parent acb2a95 commit 6cf232f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 13 deletions.
10 changes: 8 additions & 2 deletions components/checkbox/checkbox-item.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<ListItem [className]="'am-checkbox-item ' + (disabled ? 'am-checkbox-item-disabled' : '')"
[disabled]="disabled"
[thumb]="checkbox"
[wrap]="wrap"
[align]="align"
[arrow]="arrow"
[error]="error"
[extra]="extra"
[thumb]="checkbox"
[disabled]="disabled"
[platform]="platform"
[multipleLine]="multipleLine"
(onClick)="onCheckboxClick($event)"
>
<ng-content></ng-content>
Expand Down
14 changes: 13 additions & 1 deletion components/checkbox/checkbox-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, forwardRef, Input, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, ViewEncapsulation } from '@angular/core';
import { Component, forwardRef, Input, Output, EventEmitter, ChangeDetectionStrategy, TemplateRef, ChangeDetectorRef, ViewEncapsulation } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { CheckboxStatus } from './PropsType';

Expand Down Expand Up @@ -27,8 +27,20 @@ export class CheckboxItem implements ControlValueAccessor {
@Input()
value: string;
@Input()
arrow: string;
@Input()
extra: string | TemplateRef<any>;
@Input()
wrap: boolean = false;
@Input()
error: boolean = false;
@Input()
multipleLine: boolean = false;
@Input()
platform: string = 'ios';
@Input()
align: string = 'middle';
@Input()
get disabled(): boolean {
return this._disabled;
}
Expand Down
3 changes: 1 addition & 2 deletions components/checkbox/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ Checkbox

### CheckboxItem

The encapsulation about `Checkbox` based on `ListItem`, the property `thumb` of `ListItem` will be passed to `Checkbox`, while other properties remain the same.
The encapsulation about `Checkbox` based on `ListItem`, the property `thumb` of `ListItem` will be passed to `Checkbox`, while other properties remain the same (except for onClick, which has been changed to onChange).

| Properties | Descrition | Type | Default |
| ---------- | -------------------------------------- | ------------------------------------------------------- | -------------------- |
| name | name | String | - |
| value | value | String | - |
| ngModel | whether is checked now, double binding | Boolean | <span> false </span> |
| disabled | whether is been disabled | Boolean | false |
| wrap | Whether to wrap long texts, otherwise it will be hidden by default. | Boolean | `false` |
| onChange | callback when check status is changed | (name: string, value: string, checked: boolean) => void | - |

### AgreeItem
Expand Down
3 changes: 1 addition & 2 deletions components/checkbox/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ subtitle: 复选框

### CheckboxItem

基于`ListItem``Checkbox`进行封装,`ListItem``thumb`属性固定传入`Checkbox`,其他属性和`ListItem`一致。
基于`ListItem``Checkbox`进行封装,`ListItem``thumb`属性固定传入`Checkbox`,其他属性和`ListItem`一致(除了onClick回调事件,在这里它被onChange回调事件所替代)

| 属性 | 说明 | 类型 | 默认值 |
| -------- | ---------------------------- | ------------------------------------------------------- | ------ |
| name | name | String | - |
| value | value | String | - |
| ngModel | 指定当前是否选中,可双向绑定 | Boolean | false |
| disabled | 是否禁用 | Boolean | false |
| wrap | 是否换行,默认情况下,文字超长会被隐藏, | Boolean | `false` |
| onChange | change 事件触发的回调函数 | (name: string, value: string, checked: boolean) => void ||

### AgreeItem
Expand Down
5 changes: 2 additions & 3 deletions components/radio/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ Properties | Descrition | Type | Default

### RadioItem

The encapsulation about `Radio` based on `ListItem`, the property `extra` of `ListItem` will be passed to `Radio`, while other properties remain the same.
The encapsulation about `Radio` based on `ListItem`, the property `extra` of `ListItem` will be passed to `Radio`, while other properties remain the same(except for onClick, cause RadioItemGroup will emit the onChange output).

Properties | Descrition | Type | Default
-----------|------------|------|--------
| name | name | String | - |
| value | value | String | - |
| disabled | whether disabled | Boolean | false |
| wrap | Whether to wrap long texts, otherwise it will be hidden by default. | Boolean | `false` |
| disabled | whether disabled | Boolean | false |
3 changes: 1 addition & 2 deletions components/radio/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ subtitle: 单选框

### RadioItem

基于`ListItem``Radio`进行封装,`ListItem``extra`属性固定传入`Radio`,其他属性和`ListItem`一致。
基于`ListItem``Radio`进行封装,`ListItem``extra`属性固定传入`Radio`,其他属性和`ListItem`一致(除了onClick回调事件不可用之外,因为在这里是由RadioItemGroup传递回调事件)

属性 | 说明 | 类型 | 默认值
----|-----|------|------
| name | name | String ||
| value | value | String ||
| disabled | 禁用 | Boolean | false |
| wrap | 是否换行,默认情况下,文字超长会被隐藏, | Boolean | `false` |
8 changes: 8 additions & 0 deletions components/radio/radio-item.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<ListItem [className]="'am-radio-item ' + (disabled ? 'am-radio-item-disabled' : '')"
[wrap]="wrap"
[align]="align"
[arrow]="arrow"
[error]="error"
[extra]="radio"
[thumb]="thumb"
[disabled]="disabled"
[platform]="platform"
[multipleLine]="multipleLine"
[disabled]="disabled"
[wrap]="wrap"
(onClick)="onRadioItemClick($event)"
Expand Down
14 changes: 13 additions & 1 deletion components/radio/radio-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ChangeDetectorRef, Input, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import { Component, ChangeDetectorRef, Input, TemplateRef, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import { Subject } from 'rxjs';

@Component({
Expand Down Expand Up @@ -26,8 +26,20 @@ export class RadioItem {
@Input()
value: string;
@Input()
arrow: string;
@Input()
thumb: string | TemplateRef<any>;
@Input()
wrap: boolean = false;
@Input()
error: boolean = false;
@Input()
multipleLine: boolean = false;
@Input()
platform: string = 'ios';
@Input()
align: string = 'middle';
@Input()
get disabled(): boolean {
return this._disabled;
}
Expand Down

0 comments on commit 6cf232f

Please sign in to comment.