-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
Copy pathstepper-demo.html
261 lines (241 loc) · 7.86 KB
/
stepper-demo.html
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<h1>Stepper Demo</h1>
<p>
<mat-checkbox [(ngModel)]="isNonLinear">Disable linear mode</mat-checkbox>
</p>
<p>
<mat-checkbox [(ngModel)]="disableRipple">Disable header ripple</mat-checkbox>
</p>
<p>
<mat-checkbox [(ngModel)]="isVertical">Vertical</mat-checkbox>
</p>
<p>
<button mat-stroked-button (click)="showLabelBottom = !showLabelBottom">
Toggle label position
</button>
</p>
<p>
<mat-form-field>
<mat-label>Theme</mat-label>
<mat-select [(ngModel)]="theme">
@for (theme of availableThemes; track theme) {
<mat-option [value]="theme.value">{{theme.name}}</mat-option>
}
</mat-select>
</mat-form-field>
</p>
<h2>Linear Stepper Demo using a single form</h2>
<form [formGroup]="formGroup">
<mat-stepper
#linearStepper="matVerticalStepper"
formArrayName="formArray"
[orientation]="isVertical ? 'vertical' : 'horizontal'"
[linear]="!isNonLinear"
[disableRipple]="disableRipple"
[color]="theme">
<mat-step formGroupName="0" [stepControl]="formArray?.get([0]) === null ? undefined! : formArray?.get([0])!">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput formControlName="firstNameFormCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput formControlName="lastNameFormCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step formGroupName="1" [stepControl]="formArray?.get([1]) === null ? undefined! : formArray?.get([1])!"
optional>
<ng-template matStepLabel>
<div>Fill out your email address</div>
</ng-template>
<mat-form-field>
<mat-label>Email address</mat-label>
<input matInput formControlName="emailFormCtrl">
<mat-error>The input is invalid.</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>Confirm your information</ng-template>
Everything seems correct.
<div>
<button mat-button>Done</button>
<button type="button" mat-button (click)="linearStepper.reset()">Reset</button>
</div>
</mat-step>
</mat-stepper>
</form>
<h2>Linear Horizontal Stepper Demo using a different form for each step</h2>
<mat-stepper #linearHorizontalStepper="matHorizontalStepper" [linear]="!isNonLinear"
[disableRipple]="disableRipple"
[labelPosition]="showLabelBottom ? 'bottom' : 'end'"
[color]="theme">
<mat-step [stepControl]="nameFormGroup">
<form [formGroup]="nameFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput formControlName="firstNameCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput formControlName="lastNameCtrl" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step [stepControl]="emailFormGroup" optional>
<form [formGroup]="emailFormGroup">
<ng-template matStepLabel>Fill out your email address</ng-template>
<mat-form-field>
<mat-label>Email address</mat-label>
<input matInput formControlName="emailCtrl">
<mat-error>The input is invalid</mat-error>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>
<mat-step>
<form>
<ng-template matStepLabel>Confirm your information</ng-template>
Everything seems correct.
<div>
<button mat-button>Done</button>
<button type="button" mat-button (click)="linearHorizontalStepper.reset()">Reset</button>
</div>
</form>
</mat-step>
</mat-stepper>
<h2>Vertical Stepper Demo</h2>
<mat-checkbox [(ngModel)]="isNonEditable">Make steps non-editable</mat-checkbox>
<mat-stepper orientation="vertical" [color]="theme">
<mat-step [editable]="!isNonEditable">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step [editable]="!isNonEditable">
<ng-template matStepLabel>
<div>Fill out your phone number</div>
</ng-template>
<mat-form-field>
<mat-label>Phone number</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step [editable]="!isNonEditable">
<ng-template matStepLabel>
<div>Fill out your address</div>
</ng-template>
<mat-form-field>
<mat-label>Address</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>Confirm your information</ng-template>
Everything seems correct.
<div>
<button mat-button>Done</button>
</div>
</mat-step>
</mat-stepper>
<h2>Horizontal Stepper Demo with Text Label</h2>
<mat-stepper [color]="theme">
<mat-step label="Fill out your name">
<mat-form-field>
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field>
<mat-label>Last name</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Fill out your phone number">
<mat-form-field>
<mat-label>Phone number</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Fill out your address">
<mat-form-field>
<mat-label>Address</mat-label>
<input matInput>
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
<mat-step label="Confirm your information">
Everything seems correct.
<div>
<button mat-button>Done</button>
</div>
</mat-step>
</mat-stepper>
<h2>Horizontal Stepper Demo with Templated Label</h2>
<mat-stepper [color]="theme">
@for (step of steps; track step) {
<mat-step>
<ng-template matStepLabel>{{step.label}}</ng-template>
<mat-form-field>
<mat-label>Answer</mat-label>
<input matInput [(ngModel)]="step.content">
</mat-form-field>
<div>
<button mat-button matStepperPrevious>Back</button>
<button mat-button matStepperNext>Next</button>
</div>
</mat-step>
}
</mat-stepper>
<h2>Stepper with autosize textarea</h2>
<mat-stepper [color]="theme">
<mat-step label="Step 1">
<mat-form-field>
<mat-label>Autosize textarea</mat-label>
<textarea matInput cdkTextareaAutosize>This is an autosize textarea, it should adjust to the size of its content.</textarea>
</mat-form-field>
</mat-step>
</mat-stepper>