gd-bs 6.0.5 → 6.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -101,6 +101,10 @@ export class FormControl implements IFormControl {
|
|
|
101
101
|
// Parse the custom classes to add
|
|
102
102
|
let className = [(this._props.className || ""), (this._props.controlClassName || "")].join(" ").trim();
|
|
103
103
|
|
|
104
|
+
// Set the value
|
|
105
|
+
let formValue = this._formProps.value ? this._formProps.value[this._props.name] : null;
|
|
106
|
+
let value = typeof (this._props.value) === "undefined" ? formValue : this._props.value;
|
|
107
|
+
|
|
104
108
|
// Render the control based on the type
|
|
105
109
|
switch (this._props.type) {
|
|
106
110
|
// Checkbox
|
|
@@ -120,7 +124,7 @@ export class FormControl implements IFormControl {
|
|
|
120
124
|
renderRow: cbProps.renderRow,
|
|
121
125
|
title: this._props.title,
|
|
122
126
|
type: CheckboxGroupTypes.Checkbox,
|
|
123
|
-
value
|
|
127
|
+
value
|
|
124
128
|
});
|
|
125
129
|
break;
|
|
126
130
|
// Color Picker
|
|
@@ -135,7 +139,7 @@ export class FormControl implements IFormControl {
|
|
|
135
139
|
placeholder: (this._props as IFormControlPropsTextField).placeholder,
|
|
136
140
|
title: this._props.title,
|
|
137
141
|
type: InputGroupTypes.ColorPicker,
|
|
138
|
-
value
|
|
142
|
+
value
|
|
139
143
|
});
|
|
140
144
|
break;
|
|
141
145
|
// Datalist
|
|
@@ -150,7 +154,7 @@ export class FormControl implements IFormControl {
|
|
|
150
154
|
items: (this._props as IFormControlPropsDropdown).items,
|
|
151
155
|
onChange: (this._props as IFormControlPropsDropdown).onChange,
|
|
152
156
|
title: this._props.title,
|
|
153
|
-
value
|
|
157
|
+
value
|
|
154
158
|
});
|
|
155
159
|
break;
|
|
156
160
|
// Dropdown
|
|
@@ -165,7 +169,7 @@ export class FormControl implements IFormControl {
|
|
|
165
169
|
onChange: (this._props as IFormControlPropsDropdown).onChange,
|
|
166
170
|
onMenuRendering: (this._props as IFormControlPropsDropdown).onMenuRendering,
|
|
167
171
|
title: this._props.title,
|
|
168
|
-
value
|
|
172
|
+
value
|
|
169
173
|
});
|
|
170
174
|
break;
|
|
171
175
|
// Email
|
|
@@ -180,7 +184,7 @@ export class FormControl implements IFormControl {
|
|
|
180
184
|
placeholder: (this._props as IFormControlPropsTextField).placeholder,
|
|
181
185
|
title: this._props.title,
|
|
182
186
|
type: InputGroupTypes.Email,
|
|
183
|
-
value
|
|
187
|
+
value
|
|
184
188
|
});
|
|
185
189
|
break;
|
|
186
190
|
// File
|
|
@@ -195,7 +199,7 @@ export class FormControl implements IFormControl {
|
|
|
195
199
|
placeholder: (this._props as IFormControlPropsTextField).placeholder,
|
|
196
200
|
title: this._props.title,
|
|
197
201
|
type: InputGroupTypes.File,
|
|
198
|
-
value
|
|
202
|
+
value
|
|
199
203
|
});
|
|
200
204
|
break;
|
|
201
205
|
// List Box
|
|
@@ -207,7 +211,7 @@ export class FormControl implements IFormControl {
|
|
|
207
211
|
items: (this._props as IFormControlPropsListBox).items,
|
|
208
212
|
onChange: (this._props as IFormControlPropsListBox).onChange,
|
|
209
213
|
placeholder: (this._props as IFormControlPropsListBox).placeholder,
|
|
210
|
-
value
|
|
214
|
+
value
|
|
211
215
|
});
|
|
212
216
|
break;
|
|
213
217
|
// Multi-Checkbox
|
|
@@ -228,7 +232,7 @@ export class FormControl implements IFormControl {
|
|
|
228
232
|
renderRow: cbMultiProps.renderRow,
|
|
229
233
|
title: this._props.title,
|
|
230
234
|
type: CheckboxGroupTypes.Checkbox,
|
|
231
|
-
value
|
|
235
|
+
value
|
|
232
236
|
});
|
|
233
237
|
break;
|
|
234
238
|
// Multi-Dropdown
|
|
@@ -244,7 +248,7 @@ export class FormControl implements IFormControl {
|
|
|
244
248
|
onChange: (this._props as IFormControlPropsDropdown).onChange,
|
|
245
249
|
onMenuRendering: (this._props as IFormControlPropsDropdown).onMenuRendering,
|
|
246
250
|
title: this._props.title,
|
|
247
|
-
value
|
|
251
|
+
value
|
|
248
252
|
});
|
|
249
253
|
break;
|
|
250
254
|
// Multi-List Box
|
|
@@ -257,7 +261,7 @@ export class FormControl implements IFormControl {
|
|
|
257
261
|
multi: true,
|
|
258
262
|
onChange: (this._props as IFormControlPropsMultiListBox).onChange,
|
|
259
263
|
placeholder: (this._props as IFormControlPropsMultiListBox).placeholder,
|
|
260
|
-
value
|
|
264
|
+
value
|
|
261
265
|
});
|
|
262
266
|
break;
|
|
263
267
|
// Multi-Radio
|
|
@@ -275,7 +279,7 @@ export class FormControl implements IFormControl {
|
|
|
275
279
|
renderRow: (this._props as IFormControlPropsMultiCheckbox).renderRow,
|
|
276
280
|
title: this._props.title,
|
|
277
281
|
type: CheckboxGroupTypes.Radio,
|
|
278
|
-
value
|
|
282
|
+
value
|
|
279
283
|
});
|
|
280
284
|
break;
|
|
281
285
|
// Multi-Switch
|
|
@@ -293,7 +297,7 @@ export class FormControl implements IFormControl {
|
|
|
293
297
|
renderRow: (this._props as IFormControlPropsMultiCheckbox).renderRow,
|
|
294
298
|
title: this._props.title,
|
|
295
299
|
type: CheckboxGroupTypes.Switch,
|
|
296
|
-
value
|
|
300
|
+
value
|
|
297
301
|
});
|
|
298
302
|
break;
|
|
299
303
|
// Password
|
|
@@ -308,7 +312,7 @@ export class FormControl implements IFormControl {
|
|
|
308
312
|
placeholder: (this._props as IFormControlPropsTextField).placeholder,
|
|
309
313
|
title: this._props.title,
|
|
310
314
|
type: InputGroupTypes.Password,
|
|
311
|
-
value
|
|
315
|
+
value
|
|
312
316
|
});
|
|
313
317
|
break;
|
|
314
318
|
// Radio
|
|
@@ -325,7 +329,7 @@ export class FormControl implements IFormControl {
|
|
|
325
329
|
renderRow: (this._props as IFormControlPropsCheckbox).renderRow,
|
|
326
330
|
title: this._props.title,
|
|
327
331
|
type: CheckboxGroupTypes.Radio,
|
|
328
|
-
value
|
|
332
|
+
value
|
|
329
333
|
});
|
|
330
334
|
break;
|
|
331
335
|
// Range
|
|
@@ -343,7 +347,7 @@ export class FormControl implements IFormControl {
|
|
|
343
347
|
step: (this._props as IFormControlPropsRange).step,
|
|
344
348
|
title: this._props.title,
|
|
345
349
|
type: InputGroupTypes.Range,
|
|
346
|
-
value
|
|
350
|
+
value
|
|
347
351
|
});
|
|
348
352
|
break;
|
|
349
353
|
// Read Only
|
|
@@ -357,7 +361,7 @@ export class FormControl implements IFormControl {
|
|
|
357
361
|
placeholder: (this._props as IFormControlPropsTextField).placeholder,
|
|
358
362
|
title: this._props.title,
|
|
359
363
|
type: InputGroupTypes.TextField,
|
|
360
|
-
value
|
|
364
|
+
value
|
|
361
365
|
});
|
|
362
366
|
break;
|
|
363
367
|
// Switch
|
|
@@ -374,7 +378,7 @@ export class FormControl implements IFormControl {
|
|
|
374
378
|
renderRow: (this._props as IFormControlPropsCheckbox).renderRow,
|
|
375
379
|
title: this._props.title,
|
|
376
380
|
type: CheckboxGroupTypes.Switch,
|
|
377
|
-
value
|
|
381
|
+
value
|
|
378
382
|
});
|
|
379
383
|
break;
|
|
380
384
|
// Text Area
|
|
@@ -390,7 +394,7 @@ export class FormControl implements IFormControl {
|
|
|
390
394
|
rows: (this._props as IFormControlPropsTextField).rows,
|
|
391
395
|
title: this._props.title,
|
|
392
396
|
type: InputGroupTypes.TextArea,
|
|
393
|
-
value
|
|
397
|
+
value
|
|
394
398
|
});
|
|
395
399
|
break;
|
|
396
400
|
// Text Field
|
|
@@ -405,7 +409,7 @@ export class FormControl implements IFormControl {
|
|
|
405
409
|
placeholder: (this._props as IFormControlPropsTextField).placeholder,
|
|
406
410
|
title: this._props.title,
|
|
407
411
|
type: InputGroupTypes.TextField,
|
|
408
|
-
value
|
|
412
|
+
value
|
|
409
413
|
});
|
|
410
414
|
break;
|
|
411
415
|
|
|
@@ -419,7 +423,7 @@ export class FormControl implements IFormControl {
|
|
|
419
423
|
let custom = CustomControls.getByType(this._props.type);
|
|
420
424
|
if (custom && typeof (custom) === "function") {
|
|
421
425
|
// Execute the event
|
|
422
|
-
this._custom = custom(this._props);
|
|
426
|
+
this._custom = custom(this._props, this._formProps);
|
|
423
427
|
}
|
|
424
428
|
break;
|
|
425
429
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IFormControlProps } from "./controlTypes";
|
|
2
|
+
import { IFormProps } from "./formTypes";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Custom Controls
|
|
@@ -7,8 +8,8 @@ export class CustomControls {
|
|
|
7
8
|
private static _customTypes = {};
|
|
8
9
|
|
|
9
10
|
// Gets the event by type
|
|
10
|
-
static getByType(key: number): (props?: IFormControlProps) => void { return this._customTypes[key]; }
|
|
11
|
+
static getByType(key: number): (props?: IFormControlProps, formProps?: IFormProps) => void { return this._customTypes[key]; }
|
|
11
12
|
|
|
12
13
|
// Registers a custom control type
|
|
13
|
-
static registerType(key: number, event: (props?: IFormControlProps) => void) { this._customTypes[key] = event; }
|
|
14
|
+
static registerType(key: number, event: (props?: IFormControlProps, formProps?: IFormProps) => void) { this._customTypes[key] = event; }
|
|
14
15
|
}
|