aboutsummaryrefslogtreecommitdiffstats
path: root/stories/ng2-component-lab/radio.component.exp.ts
blob: aa3959bb5a9dfa52a7162511797ade8d56716fdc (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import { experimentOn } from '@islavi/ng2-component-lab';

export default experimentOn('Radios')
    .group("Radios",[
      {
        id: 'radioButtonsGroupTwoWaysBinding',
        showSource: true,
        context: {
            selectedValue: "val2"
        },
        title: 'Radio buttons group (two ways binding)',
        description: 'Radio buttons group (two ways binding)',
        template:
        `
        <sdc-radio-group
            [legend]="'Radio Buttons Group legend'"
            [(value)]="selectedValue"
            [options] = "{
                items: [
                    {
                        value: 'val1',
                        name: 'radio5',
                        label: 'Label of Radio 1'
                    },
                    {
                        value: 'val2',
                        name: 'radio5',
                        label: 'Label of Radio 2'
                    }
                ]}"
            ></sdc-radio-group>
        <br><div>Selected Radio: {{selectedValue}}</div>
        `
    },
    {
        id: 'radioButtonsGroupDisabled',
        title: 'Radio buttons group disabled',
        description: 'Radio buttons group disabled',
        showSource: true,
        context: {
            selectedValue: "val1"
        },
        template: `
        <sdc-radio-group
            [legend]="'Radio Buttons Group Disabled legend'"
            [disabled]="true"
            [value]="selectedValue"
            [options] = "{
            items: [{
                value: 'val1',
                name: 'radio6',
                label: 'Label of Radio 1'
            }, {
                value: 'val2',
                name: 'radio6',
                label: 'Label of Radio 2'
            }]
        }"></sdc-radio-group>
        <br><div>Selected Radio: {{selectedValue}}</div>
        `
    },
    {
        id: 'radioButtonsGroupPartiallyDisabled',
        title: 'Radio buttons group partially disabled',
        description: 'Radio buttons group partially disabled',
        showSource: true,
        context: {
            selectedValue: "val2"
        },
        template: `
        <sdc-radio-group
            [legend]="'Radio Buttons Group partially disabled'"
            [(value)]="selectedValue"
            [options] = "{
            items: [{
                value: 'val1',
                name: 'radio7',
                label: 'Label of Radio 1'
            }, {
                value: 'val2',
                disabled: 'true',
                name: 'radio7',
                label: 'Label of Radio 2'
            }, {
                value: 'val3',
                name: 'radio7',
                label: 'Label of Radio 3'
            }]
        }"></sdc-radio-group>
        <br><div>Selected Radio: {{selectedValue}}</div>
        `
    },
    {
        id: 'radioButtonsGroupVertical',
        title: 'Radio buttons group vertical',
        description: 'Radio buttons group vertical',
        showSource: true,
        context: {
            selectedValue: "val1"
        },
        template: `
        <sdc-radio-group
            [legend]="'Radio Buttons Group Vertical legend'"
            [(value)]="selectedValue"
            [direction]="'horizontal'"
            [options]="{
            items: [{
                value:'val1',
                name: 'radio8',
                label: 'Label of Radio1'
            }, {
                value:'val2',
                name: 'radio8',
                label: 'Label of Radio2'
            }]
        }"></sdc-radio-group>
        <br><div>Selected Radio: {{selectedValue}}</div>
        `
    },
    {
        id: 'radioButtonsGroupGetValue',
        title: 'Radio buttons group get value',
        description: 'Radio buttons group get value',
        showSource: true,
        context: {
            selectedValue: "val1",
            getSelectedValue: (val)=>{
                alert(val);
            }
        },
        template: `
        <sdc-radio-group
            #myRadioGroup
            [legend]="'Radio Buttons Group Vertical legend'"
            [(value)]="selectedValue"
            [options]="{
            items: [{
                value:'val1',
                name: 'radio8',
                label: 'Label of Radio1'
            }, {
                value:'val2',
                name: 'radio8',
                label: 'Label of Radio2'
            }]
        }"></sdc-radio-group>
        <br><div>Selected Radio: {{selectedValue}}</div>
        <br><button (click)="getSelectedValue(myRadioGroup.value)">Get selected value</button>
        `
    },
    {
        id: 'radioButtonsGroupSelectValue',
        title: 'Radio buttons group select value',
        description: 'Radio buttons group select value',
        showSource: true,
        context: {
            selectedValue: "val1"
        },
        template: `
        <sdc-radio-group
            #myRadioGroup
            [legend]="'Radio Buttons Group Vertical legend'"
            [(value)]="selectedValue"
            [options]="{
            items: [{
                value:'val1',
                name: 'radio8',
                label: 'Label of Radio1'
            }, {
                value:'val2',
                name: 'radio8',
                label: 'Label of Radio2'
            }]
        }"></sdc-radio-group>
        <br><div>Selected Radio: {{selectedValue}}</div>
        <br><button (click)="myRadioGroup.value='val2'">Set value to val2</button>
        `
    }
    ]);