gd-bs 6.6.1 → 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/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
- isSelected: true
63
+ text: "Item " + i,
64
+ value: i
65
65
  });
66
66
  }
67
- window["form"] = GD.Components.Form({
67
+ window["cb_ddl"] = GD.Components.Dropdown({
68
68
  el: document.getElementById("dev"),
69
- controls: [{
70
- name: "cb",
71
- label: "My CB",
72
- items,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.6.1",
3
+ "version": "6.6.2",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -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
- let isForm = menu.nodeName == "SELECT";
395
+ // See if we are creating checkboxes
396
+ if (this.props.isCheckbox) {
397
+ let cbItems: ICheckboxGroupItem[] = [];
393
398
 
394
- // Parse the items
395
- let items = this.props.items || [];
396
- for (let i = 0; i < items.length; i++) {
397
- // Create the item
398
- let item = isForm ? new DropdownFormItem(items[i], this.props) : new DropdownItem(items[i], this.props);
399
- this._items.push(item);
400
-
401
- // See if this isn't for a form
402
- if (!isForm) {
403
- // Configure the item events
404
- this.configureItemEvents(item);
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
- // Add the item to the menu
408
- menu.appendChild(item.el);
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
- // See if this is a form
412
- if (isForm) {
413
- // Ensure the selected values match the index
414
- let idx = (menu as HTMLSelectElement).selectedIndex;
415
- if (this._items[idx] && this._items[idx].isSelected == false) {
416
- // Select the item
417
- this._items[idx].toggle();
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
- // Parse the items
452
- for (let i = 0; i < this._items.length; i++) {
453
- let item = this._items[i];
454
-
455
- // Skip disabled items
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
- // See if this item is selected
459
- if (item.isSelected) {
489
+ // Parse the items
490
+ for (let i = 0; i < items.length; i++) {
460
491
  // Add the value
461
- values.push(item.props);
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
 
@@ -135,6 +135,7 @@ export interface IDropdownProps extends IBaseProps<IDropdown> {
135
135
  dropUp?: boolean;
136
136
  formFl?: boolean;
137
137
  id?: string;
138
+ isCheckbox?: boolean;
138
139
  isDark?: boolean;
139
140
  isDatalist?: boolean;
140
141
  isReadonly?: boolean;
@@ -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
- File = 6,
11
- ListBox = 7,
12
- MultiCheckbox = 8,
13
- MultiDropdown = 9,
14
- MultiListBox = 10,
15
- MultiRadio = 11,
16
- MultiSwitch = 12,
17
- Password = 13,
18
- Radio = 14,
19
- Range = 15,
20
- Readonly = 16,
21
- Switch = 17,
22
- TextArea = 18,
23
- TextField = 19
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
  /**