@@ -171,7 +171,7 @@ export function newActionEvent<T extends EditorAction>(
171
171
172
172
export const wizardInputSelector =
173
173
'wizard-textfield, mwc-textfield, ace-editor, mwc-select,wizard-select, wizard-checkbox' ;
174
- export type WizardInput =
174
+ export type WizardInputElement =
175
175
| WizardTextField
176
176
| TextField
177
177
| ( AceEditor & { checkValidity : ( ) => boolean ; label : string } )
@@ -183,7 +183,7 @@ export type WizardAction = EditorAction | WizardFactory;
183
183
184
184
/** @returns [[`EditorAction`]]s to dispatch on [[`WizardDialog`]] commit. */
185
185
export type WizardActor = (
186
- inputs : WizardInput [ ] ,
186
+ inputs : WizardInputElement [ ] ,
187
187
wizard : Element ,
188
188
list ?: List | null
189
189
) => WizardAction [ ] ;
@@ -195,21 +195,21 @@ export function isWizardFactory(
195
195
}
196
196
197
197
/** @returns the validity of `input` depending on type. */
198
- export function checkValidity ( input : WizardInput ) : boolean {
198
+ export function checkValidity ( input : WizardInputElement ) : boolean {
199
199
if ( input instanceof WizardTextField || input instanceof Select )
200
200
return input . checkValidity ( ) ;
201
201
else return true ;
202
202
}
203
203
204
204
/** reports the validity of `input` depending on type. */
205
- export function reportValidity ( input : WizardInput ) : boolean {
205
+ export function reportValidity ( input : WizardInputElement ) : boolean {
206
206
if ( input instanceof WizardTextField || input instanceof Select )
207
207
return input . reportValidity ( ) ;
208
208
else return true ;
209
209
}
210
210
211
211
/** @returns the `value` or `maybeValue` of `input` depending on type. */
212
- export function getValue ( input : WizardInput ) : string | null {
212
+ export function getValue ( input : WizardInputElement ) : string | null {
213
213
if (
214
214
input instanceof WizardTextField ||
215
215
input instanceof WizardSelect ||
@@ -220,11 +220,78 @@ export function getValue(input: WizardInput): string | null {
220
220
}
221
221
222
222
/** @returns the `multiplier` of `input` if available. */
223
- export function getMultiplier ( input : WizardInput ) : string | null {
223
+ export function getMultiplier ( input : WizardInputElement ) : string | null {
224
224
if ( input instanceof WizardTextField ) return input . multiplier ;
225
225
else return null ;
226
226
}
227
227
228
+ /** Inputs as `TextField`, `Select` or `Checkbox `used in`wizard-dialog` */
229
+ export type WizardInput =
230
+ | WizardInputTextField
231
+ | WizardInputSelect
232
+ | WizardInputCheckbox ;
233
+
234
+ interface WizardInputBase {
235
+ /** maps attribute key */
236
+ label : string ;
237
+ /** maps attribute value */
238
+ maybeValue : string | null ;
239
+ /** whether attribute is optional */
240
+ nullable ?: boolean ;
241
+ /** whether the input shall be disabled */
242
+ disabled ?: boolean ;
243
+ /** helper text */
244
+ helper ?: string ;
245
+ /** initial focused element in `wizard-dialog` (once per dialog) */
246
+ dialogInitialFocus ?: boolean ;
247
+ }
248
+
249
+ interface WizardInputTextField extends WizardInputBase {
250
+ kind : 'TextField' ;
251
+ /** wether the input might be empty string */
252
+ required ?: boolean ;
253
+ /** pattern definition from schema */
254
+ pattern ?: string ;
255
+ /** minimal characters allowed */
256
+ minLength ?: number ;
257
+ /** maximal characters allowed */
258
+ maxLength ?: number ;
259
+ /** message text explaining invalid inputs */
260
+ validationMessage ?: string ;
261
+ /** suffix definition - overwrites unit multiplier definition */
262
+ suffix ?: string ;
263
+ /** SI unit for specific suffix definition */
264
+ unit ?: string ;
265
+ /** in comibination with unit defines specific suffix */
266
+ multiplier ?: string | null ;
267
+ /** array of multipliers allowed for the input */
268
+ multipliers ?: ( string | null ) [ ] ;
269
+ /** used for specific input type e.g. number */
270
+ type ?: string ;
271
+ /** minimal valid number in combination with type number */
272
+ min ?: number ;
273
+ /** maximal valid number in combination with type number */
274
+ max ?: number ;
275
+ /** value displaxed when input is nulled */
276
+ default ?: string ;
277
+ }
278
+
279
+ interface WizardInputSelect extends WizardInputBase {
280
+ kind : 'Select' ;
281
+ /** selectabled values */
282
+ values : string [ ] ;
283
+ /** value displayed with input is nulled */
284
+ default ?: string ;
285
+ /** message explaining invalid inputs */
286
+ valadationMessage ?: string ;
287
+ }
288
+
289
+ interface WizardInputCheckbox extends WizardInputBase {
290
+ kind : 'Checkbox' ;
291
+ /** wether checkbox is checked with nulled input */
292
+ default ?: boolean ;
293
+ }
294
+
228
295
/** @returns [[`WizardAction`]]s to dispatch on [[`WizardDialog`]] menu action. */
229
296
export type WizardMenuActor = ( ) => WizardAction [ ] ;
230
297
@@ -238,7 +305,7 @@ export interface MenuAction {
238
305
/** Represents a page of a wizard dialog */
239
306
export interface WizardPage {
240
307
title : string ;
241
- content ?: TemplateResult [ ] ;
308
+ content ?: ( TemplateResult | WizardInput ) [ ] ;
242
309
primary ?: {
243
310
icon : string ;
244
311
label : string ;
0 commit comments