/
select-popover.tsx
66 lines (55 loc) · 1.51 KB
/
select-popover.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Component, Listen, Prop } from '@stencil/core';
export interface SelectPopoverOption {
text: string;
value: string;
disabled: boolean;
checked: boolean;
handler?: Function;
}
@Component({
tag: 'ion-select-popover',
host: {
theme: 'select-popover'
}}
)
export class SelectPopover {
private mode: string;
@Prop() header: string;
@Prop() subHeader: string;
@Prop() message: string;
@Prop() options: SelectPopoverOption[] = [];
@Listen('ionSelect')
onSelect(ev: any) {
const option = this.options.find(o => o.value === ev.target.value);
option && option.handler && option.handler();
}
render() {
return (
<ion-list no-lines={this.mode === 'md'}>
{ this.header ? <ion-list-header>{this.header}</ion-list-header> : null }
{ this.subHeader || this.message
? <ion-item text-wrap>
<ion-label>
{ this.subHeader ? <h3>{this.subHeader}</h3> : null }
{ this.message ? <p>{this.message}</p> : null }
</ion-label>
</ion-item>
: null}
<ion-radio-group>
{this.options.map(option =>
<ion-item>
<ion-label>
{option.text}
</ion-label>
<ion-radio
checked={option.checked}
value={option.value}
disabled={option.disabled}>
</ion-radio>
</ion-item>
)}
</ion-radio-group>
</ion-list>
);
}
}