fix(all): strong typed events

This commit is contained in:
Manu Mtz.-Almeida
2018-04-23 17:26:10 +02:00
parent b8c87c453a
commit d5129df970
44 changed files with 434 additions and 607 deletions

View File

@ -12,7 +12,6 @@ let ids = 0;
}
})
export class SegmentButton {
styleTmr: any;
@Element() el!: HTMLElement;
@ -49,31 +48,20 @@ export class SegmentButton {
/**
* The value of the segment button.
*/
@Prop({ mutable: true }) value!: string;
@Prop() value: string = 'ion-sb-' + (ids++);
/**
* Emitted when the segment button is clicked.
*/
@Event() ionClick!: EventEmitter;
componentWillLoad() {
if (this.value === undefined) {
this.value = `ion-sb-${ids++}`;
}
}
@Event() ionSelect!: EventEmitter<void>;
/**
* Emit the click event to the parent segment
*/
private segmentButtonClick() {
clearTimeout(this.styleTmr);
this.styleTmr = setTimeout(() => {
this.ionClick.emit();
});
private onClick() {
this.ionSelect.emit();
}
render() {
const themedClasses = createThemedClasses(this.mode, this.color, 'segment-button');
const hostClasses = getElementClassMap(this.el.classList);
@ -97,7 +85,7 @@ export class SegmentButton {
class={buttonClasses}
disabled={this.disabled}
href={this.href}
onClick={this.segmentButtonClick.bind(this)}>
onClick={this.onClick.bind(this)}>
<slot></slot>
{ this.mode === 'md' && <ion-ripple-effect tapClick={true}/> }
</TagType>