gd-bs 6.6.0 → 6.6.2
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/build/components/accordion/item.js +3 -1
- package/build/components/dropdown/index.js +73 -30
- package/build/components/form/control.js +2 -0
- package/build/components/form/types.js +18 -14
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.d.ts +7 -0
- package/dist/gd-bs.js +1 -1
- package/dist/gd-bs.min.js +1 -1
- package/index.html +7 -22
- package/package.json +1 -1
- package/src/components/accordion/item.ts +3 -1
- package/src/components/accordion/types.d.ts +2 -0
- package/src/components/dropdown/index.ts +78 -31
- package/src/components/dropdown/types.d.ts +1 -0
- package/src/components/form/control.ts +68 -0
- package/src/components/form/controlTypes.d.ts +4 -0
- package/src/components/form/types.ts +18 -14
package/index.html
CHANGED
|
@@ -59,32 +59,17 @@
|
|
|
59
59
|
let items = [];
|
|
60
60
|
for (var i = 0; i < 10; i++) {
|
|
61
61
|
items.push({
|
|
62
|
-
label: "Item " + i,
|
|
63
62
|
data: i,
|
|
64
|
-
|
|
63
|
+
text: "Item " + i,
|
|
64
|
+
value: i
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
|
-
window["
|
|
67
|
+
window["cb_ddl"] = GD.Components.Dropdown({
|
|
68
68
|
el: document.getElementById("dev"),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
renderRow: true,
|
|
74
|
-
colSize: 3,
|
|
75
|
-
type: 8
|
|
76
|
-
}, {
|
|
77
|
-
name: "switch",
|
|
78
|
-
label: "Select an Option",
|
|
79
|
-
type: GD.Components.FormControlTypes.Switch,
|
|
80
|
-
items: [{
|
|
81
|
-
label: "Switch 1"
|
|
82
|
-
}, {
|
|
83
|
-
label: "Switch 2"
|
|
84
|
-
}, {
|
|
85
|
-
label: "Switch 3"
|
|
86
|
-
}]
|
|
87
|
-
}]
|
|
69
|
+
items: items,
|
|
70
|
+
isCheckbox: true,
|
|
71
|
+
multi: true,
|
|
72
|
+
label: "CB Dropdown"
|
|
88
73
|
});
|
|
89
74
|
|
|
90
75
|
// Components
|
package/package.json
CHANGED
|
@@ -76,7 +76,9 @@ export class AccordionItem {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
// Execute the render event
|
|
79
|
-
this._props.onRender ? this._props.onRender(this._el
|
|
79
|
+
this._props.onRender ? this._props.onRender(this._el, this._props) : null;
|
|
80
|
+
this._props.onRenderBody ? this._props.onRenderBody(this._el.querySelector(".accordion-body"), this._props) : null;
|
|
81
|
+
this._props.onRenderHeader ? this._props.onRenderHeader(this._el.querySelector(".accordion-header"), this._props) : null;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
// Renders the header
|
|
@@ -75,6 +75,8 @@ export interface IAccordionItem<T = HTMLElement> {
|
|
|
75
75
|
header?: string;
|
|
76
76
|
onClick?: (el?: HTMLElement, item?: IAccordionItem<T>) => void;
|
|
77
77
|
onRender?: (el?: HTMLElement, item?: IAccordionItem<T>) => void;
|
|
78
|
+
onRenderBody?: (el?: HTMLElement, item?: IAccordionItem<T>) => void;
|
|
79
|
+
onRenderHeader?: (el?: HTMLElement, item?: IAccordionItem<T>) => void;
|
|
78
80
|
showFl?: boolean;
|
|
79
81
|
}
|
|
80
82
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { IDropdown, IDropdownItem, IDropdownProps } from "./types";
|
|
2
|
+
import { ICheckboxGroup, ICheckboxGroupItem } from "../checkboxGroup/types";
|
|
2
3
|
import { IPopover, IPopoverProps } from "../popover/types";
|
|
3
4
|
import { Base } from "../base";
|
|
4
5
|
import { ButtonClassNames, ButtonTypes } from "../button";
|
|
6
|
+
import { CheckboxGroup, CheckboxGroupTypes } from "../checkboxGroup"
|
|
5
7
|
import { Popover, PopoverPlacements, PopoverTypes } from "../popover";
|
|
6
8
|
import { DropdownFormItem } from "./formItem";
|
|
7
9
|
import { DropdownItem } from "./item";
|
|
@@ -33,6 +35,7 @@ const GetHTML = (props: IDropdownProps) => {
|
|
|
33
35
|
*/
|
|
34
36
|
class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
35
37
|
private _autoSelect: boolean = null;
|
|
38
|
+
private _cb: ICheckboxGroup = null;
|
|
36
39
|
private _elMenu: HTMLElement;
|
|
37
40
|
private _initFl: boolean = false;
|
|
38
41
|
private _items: Array<DropdownFormItem | DropdownItem> = null;
|
|
@@ -389,32 +392,61 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
389
392
|
// Get the menu
|
|
390
393
|
let menu = this.el.querySelector(".dropdown-menu") || this.el.querySelector("select");
|
|
391
394
|
if (menu) {
|
|
392
|
-
|
|
395
|
+
// See if we are creating checkboxes
|
|
396
|
+
if (this.props.isCheckbox) {
|
|
397
|
+
let cbItems: ICheckboxGroupItem[] = [];
|
|
393
398
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
399
|
+
// Parse the items
|
|
400
|
+
let items = this.props.items || [];
|
|
401
|
+
for (let i = 0; i < items.length; i++) {
|
|
402
|
+
let item = items[i];
|
|
403
|
+
|
|
404
|
+
// Create the checkbox item
|
|
405
|
+
cbItems.push({
|
|
406
|
+
data: item,
|
|
407
|
+
isDisabled: item.isDisabled,
|
|
408
|
+
isSelected: item.isSelected,
|
|
409
|
+
label: item.text,
|
|
410
|
+
onChange: item.onClick,
|
|
411
|
+
type: CheckboxGroupTypes.Checkbox
|
|
412
|
+
});
|
|
405
413
|
}
|
|
406
414
|
|
|
407
|
-
//
|
|
408
|
-
|
|
409
|
-
|
|
415
|
+
// Render the checkbox
|
|
416
|
+
this._cb = CheckboxGroup({
|
|
417
|
+
className: "m-2",
|
|
418
|
+
el: menu,
|
|
419
|
+
items: cbItems,
|
|
420
|
+
multi: this.props.multi
|
|
421
|
+
});
|
|
422
|
+
} else {
|
|
423
|
+
let isForm = menu.nodeName == "SELECT";
|
|
410
424
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
425
|
+
// Parse the items
|
|
426
|
+
let items = this.props.items || [];
|
|
427
|
+
for (let i = 0; i < items.length; i++) {
|
|
428
|
+
// Create the item
|
|
429
|
+
let item = isForm ? new DropdownFormItem(items[i], this.props) : new DropdownItem(items[i], this.props);
|
|
430
|
+
this._items.push(item);
|
|
431
|
+
|
|
432
|
+
// See if this isn't for a form
|
|
433
|
+
if (!isForm) {
|
|
434
|
+
// Configure the item events
|
|
435
|
+
this.configureItemEvents(item);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Add the item to the menu
|
|
439
|
+
menu.appendChild(item.el);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// See if this is a form
|
|
443
|
+
if (isForm) {
|
|
444
|
+
// Ensure the selected values match the index
|
|
445
|
+
let idx = (menu as HTMLSelectElement).selectedIndex;
|
|
446
|
+
if (this._items[idx] && this._items[idx].isSelected == false) {
|
|
447
|
+
// Select the item
|
|
448
|
+
this._items[idx].toggle();
|
|
449
|
+
}
|
|
418
450
|
}
|
|
419
451
|
}
|
|
420
452
|
}
|
|
@@ -448,17 +480,32 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
448
480
|
getValue() {
|
|
449
481
|
let values = [];
|
|
450
482
|
|
|
451
|
-
//
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
if ((item.el as HTMLOptionElement).disabled) { continue; }
|
|
483
|
+
// See if the checkboxes exist
|
|
484
|
+
if (this._cb) {
|
|
485
|
+
// Get the values
|
|
486
|
+
let items = this._cb.getValue() as ICheckboxGroupItem[];
|
|
487
|
+
items = typeof (items["length"]) === "number" ? items : [items] as any;
|
|
457
488
|
|
|
458
|
-
//
|
|
459
|
-
|
|
489
|
+
// Parse the items
|
|
490
|
+
for (let i = 0; i < items.length; i++) {
|
|
460
491
|
// Add the value
|
|
461
|
-
values.push(
|
|
492
|
+
values.push(items[i].data);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Return the value
|
|
496
|
+
} else {
|
|
497
|
+
// Parse the items
|
|
498
|
+
for (let i = 0; i < this._items.length; i++) {
|
|
499
|
+
let item = this._items[i];
|
|
500
|
+
|
|
501
|
+
// Skip disabled items
|
|
502
|
+
if ((item.el as HTMLOptionElement).disabled) { continue; }
|
|
503
|
+
|
|
504
|
+
// See if this item is selected
|
|
505
|
+
if (item.isSelected) {
|
|
506
|
+
// Add the value
|
|
507
|
+
values.push(item.props);
|
|
508
|
+
}
|
|
462
509
|
}
|
|
463
510
|
}
|
|
464
511
|
|
|
@@ -177,6 +177,39 @@ export class FormControl implements IFormControl {
|
|
|
177
177
|
value
|
|
178
178
|
});
|
|
179
179
|
break;
|
|
180
|
+
// Dropdown
|
|
181
|
+
case FormControlTypes.DropdownButton:
|
|
182
|
+
// Add the dropdown
|
|
183
|
+
this._ddl = Dropdown({
|
|
184
|
+
className,
|
|
185
|
+
formFl: false,
|
|
186
|
+
id: this._props.id,
|
|
187
|
+
isReadonly: this._props.isReadonly,
|
|
188
|
+
items: (this._props as IFormControlPropsDropdown).items,
|
|
189
|
+
onChange: (this._props as IFormControlPropsDropdown).onChange,
|
|
190
|
+
onMenuRendering: (this._props as IFormControlPropsDropdown).onMenuRendering,
|
|
191
|
+
required: this._props.required,
|
|
192
|
+
title: this._props.title,
|
|
193
|
+
value
|
|
194
|
+
});
|
|
195
|
+
break;
|
|
196
|
+
// Dropdown
|
|
197
|
+
case FormControlTypes.DropdownCheckbox:
|
|
198
|
+
// Add the dropdown
|
|
199
|
+
this._ddl = Dropdown({
|
|
200
|
+
className,
|
|
201
|
+
formFl: false,
|
|
202
|
+
id: this._props.id,
|
|
203
|
+
isCheckbox: true,
|
|
204
|
+
isReadonly: this._props.isReadonly,
|
|
205
|
+
items: (this._props as IFormControlPropsDropdown).items,
|
|
206
|
+
onChange: (this._props as IFormControlPropsDropdown).onChange,
|
|
207
|
+
onMenuRendering: (this._props as IFormControlPropsDropdown).onMenuRendering,
|
|
208
|
+
required: this._props.required,
|
|
209
|
+
title: this._props.title,
|
|
210
|
+
value
|
|
211
|
+
});
|
|
212
|
+
break;
|
|
180
213
|
// Email
|
|
181
214
|
case FormControlTypes.Email:
|
|
182
215
|
// Add the input
|
|
@@ -264,6 +297,41 @@ export class FormControl implements IFormControl {
|
|
|
264
297
|
value
|
|
265
298
|
});
|
|
266
299
|
break;
|
|
300
|
+
// Multi-Dropdown Button
|
|
301
|
+
case FormControlTypes.MultiDropdownButton:
|
|
302
|
+
// Add the dropdown
|
|
303
|
+
this._ddl = Dropdown({
|
|
304
|
+
className,
|
|
305
|
+
formFl: false,
|
|
306
|
+
id: this._props.id,
|
|
307
|
+
isReadonly: this._props.isReadonly,
|
|
308
|
+
items: (this._props as IFormControlPropsDropdown).items,
|
|
309
|
+
multi: true,
|
|
310
|
+
onChange: (this._props as IFormControlPropsDropdown).onChange,
|
|
311
|
+
onMenuRendering: (this._props as IFormControlPropsDropdown).onMenuRendering,
|
|
312
|
+
required: this._props.required,
|
|
313
|
+
title: this._props.title,
|
|
314
|
+
value
|
|
315
|
+
});
|
|
316
|
+
break;
|
|
317
|
+
// Multi-Dropdown Checkbox
|
|
318
|
+
case FormControlTypes.MultiDropdownCheckbox:
|
|
319
|
+
// Add the dropdown
|
|
320
|
+
this._ddl = Dropdown({
|
|
321
|
+
className,
|
|
322
|
+
formFl: false,
|
|
323
|
+
id: this._props.id,
|
|
324
|
+
isCheckbox: true,
|
|
325
|
+
isReadonly: this._props.isReadonly,
|
|
326
|
+
items: (this._props as IFormControlPropsDropdown).items,
|
|
327
|
+
multi: true,
|
|
328
|
+
onChange: (this._props as IFormControlPropsDropdown).onChange,
|
|
329
|
+
onMenuRendering: (this._props as IFormControlPropsDropdown).onMenuRendering,
|
|
330
|
+
required: this._props.required,
|
|
331
|
+
title: this._props.title,
|
|
332
|
+
value
|
|
333
|
+
});
|
|
334
|
+
break;
|
|
267
335
|
// Multi-List Box
|
|
268
336
|
case FormControlTypes.MultiListBox:
|
|
269
337
|
// Add the list box
|
|
@@ -222,10 +222,14 @@ export type IFormControlTypes = {
|
|
|
222
222
|
Email: number;
|
|
223
223
|
Datalist: number;
|
|
224
224
|
Dropdown: number;
|
|
225
|
+
DropdownButton: number;
|
|
226
|
+
DropdownCheckbox: number;
|
|
225
227
|
File: number;
|
|
226
228
|
ListBox: number;
|
|
227
229
|
MultiCheckbox: number;
|
|
228
230
|
MultiDropdown: number;
|
|
231
|
+
MultiDropdownButton: number;
|
|
232
|
+
MultiDropdownCheckbox: number;
|
|
229
233
|
MultiListBox: number;
|
|
230
234
|
MultiRadio: number;
|
|
231
235
|
MultiSwitch: number;
|
|
@@ -7,20 +7,24 @@ export enum FormControlTypes {
|
|
|
7
7
|
Email = 3,
|
|
8
8
|
Datalist = 4,
|
|
9
9
|
Dropdown = 5,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
DropdownButton = 6,
|
|
11
|
+
DropdownCheckbox = 7,
|
|
12
|
+
File = 8,
|
|
13
|
+
ListBox = 9,
|
|
14
|
+
MultiCheckbox = 10,
|
|
15
|
+
MultiDropdown = 11,
|
|
16
|
+
MultiDropdownButton = 12,
|
|
17
|
+
MultiDropdownCheckbox = 13,
|
|
18
|
+
MultiListBox = 14,
|
|
19
|
+
MultiRadio = 15,
|
|
20
|
+
MultiSwitch = 16,
|
|
21
|
+
Password = 17,
|
|
22
|
+
Radio = 18,
|
|
23
|
+
Range = 19,
|
|
24
|
+
Readonly = 20,
|
|
25
|
+
Switch = 21,
|
|
26
|
+
TextArea = 22,
|
|
27
|
+
TextField = 23
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|