|
1 | 1 | import { CheckBoxInterface } from "./index"; |
| 2 | +import { BoxType } from "./checkbox-common"; |
2 | 3 | import { |
3 | 4 | Property, |
4 | 5 | CssProperty, |
@@ -57,10 +58,12 @@ const checkedProperty = new Property<CheckBox, boolean>({ |
57 | 58 | valueChanged: onCheckedPropertyChanged |
58 | 59 | }); |
59 | 60 |
|
60 | | -const boxTypeProperty = new Property<CheckBox, number>({ |
| 61 | +const boxTypeProperty = new Property<CheckBox, BEMBoxType>({ |
61 | 62 | name: "boxType", |
62 | 63 | valueConverter: v => { |
63 | | - return parseInt(v, 10); |
| 64 | + return BoxType[v] === BoxType.circle |
| 65 | + ? BEMBoxType.Circle |
| 66 | + : BEMBoxType.Square; |
64 | 67 | } |
65 | 68 | }); |
66 | 69 |
|
@@ -121,16 +124,10 @@ export class CheckBox extends Button implements CheckBoxInterface { |
121 | 124 | this._iosCheckbox.onCheckColor = new Color(color).ios; |
122 | 125 | } |
123 | 126 |
|
124 | | - [boxTypeProperty.getDefault](): number { |
125 | | - return 1; |
126 | | - } |
127 | | - |
128 | | - [boxTypeProperty.setNative](value: number) { |
129 | | - let type = BEMBoxType.Circle; |
130 | | - if (value === 2) { |
131 | | - type = BEMBoxType.Square; |
| 127 | + [boxTypeProperty.setNative](value: any) { |
| 128 | + if (this._iosCheckbox) { |
| 129 | + this._iosCheckbox.boxType = value; |
132 | 130 | } |
133 | | - this._iosCheckbox.boxType = type; |
134 | 131 | } |
135 | 132 |
|
136 | 133 | [checkedProperty.getDefault](): boolean { |
@@ -236,9 +233,8 @@ export class CheckBox extends Button implements CheckBoxInterface { |
236 | 233 | if (typeof this._hideBox !== "undefined") { |
237 | 234 | this.hideBox = this._hideBox; |
238 | 235 | } |
239 | | - if (typeof this._boxType !== "undefined") { |
240 | | - this.boxType = this._boxType; |
241 | | - } |
| 236 | + |
| 237 | + this.boxType = this.boxType === 0 ? BEMBoxType.Circle : BEMBoxType.Square; |
242 | 238 |
|
243 | 239 | if (typeof this._animationDuration !== "undefined") { |
244 | 240 | this.animationDuration = this._animationDuration; |
|
0 commit comments