gd-bs 6.6.6 → 6.6.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.6.6",
3
+ "version": "6.6.7",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -16,15 +16,20 @@ export enum CheckboxGroupTypes {
16
16
  * Checkbox Group
17
17
  */
18
18
  class _CheckboxGroup extends Base<ICheckboxGroupProps> implements ICheckboxGroup {
19
+ private _cbTemplate: string = null;
19
20
  private _checkboxes: Array<CheckboxItem> = null;
21
+ private _elCheckboxes: HTMLElement = null;
20
22
  private _initFl: boolean = false;
21
23
 
22
24
  // Constructor
23
25
  constructor(props: ICheckboxGroupProps, template: string = HTML, cbTemplate?: string) {
24
26
  super(template, props);
25
27
 
28
+ // Set the template
29
+ this._cbTemplate = cbTemplate;
30
+
26
31
  // Configure the checkbox group
27
- this.configure(cbTemplate);
32
+ this.configure();
28
33
 
29
34
  // Configure the parent
30
35
  this.configureParent();
@@ -34,7 +39,7 @@ class _CheckboxGroup extends Base<ICheckboxGroupProps> implements ICheckboxGroup
34
39
  }
35
40
 
36
41
  // Configure the card group
37
- private configure(cbTemplate: string) {
42
+ private configure() {
38
43
  let renderRow = typeof (this.props.colSize) === "number" ? this.props.colSize > 0 : false;
39
44
 
40
45
  // See if a label is defined
@@ -55,11 +60,17 @@ class _CheckboxGroup extends Base<ICheckboxGroupProps> implements ICheckboxGroup
55
60
  if (!renderRow) {
56
61
  // Remove the group element
57
62
  this.el.removeChild(group);
63
+
64
+ // Set the checkboxes element
65
+ this._elCheckboxes = this.el;
66
+ } else {
67
+ // Set the checkboxes element
68
+ this._elCheckboxes = group;
58
69
  }
59
70
  }
60
71
 
61
72
  // Render the checkboxes
62
- this.renderItems(renderRow ? group : this.el, cbTemplate);
73
+ this.renderItems();
63
74
  }
64
75
 
65
76
  // Configure the events
@@ -95,7 +106,7 @@ class _CheckboxGroup extends Base<ICheckboxGroupProps> implements ICheckboxGroup
95
106
  }
96
107
 
97
108
  // Render the checkboxes
98
- private renderItems(group: HTMLDivElement, cbTemplate: string) {
109
+ private renderItems() {
99
110
  // Clear the checkboxes
100
111
  this._checkboxes = [];
101
112
 
@@ -125,9 +136,9 @@ class _CheckboxGroup extends Base<ICheckboxGroupProps> implements ICheckboxGroup
125
136
  let item = items[i];
126
137
 
127
138
  // Create the checkbox
128
- let checkbox = new CheckboxItem(item, this.props, cbTemplate);
139
+ let checkbox = new CheckboxItem(item, this.props, this._cbTemplate);
129
140
  this._checkboxes.push(checkbox);
130
- group.appendChild(checkbox.el);
141
+ this._elCheckboxes.appendChild(checkbox.el);
131
142
 
132
143
  // Configure the events
133
144
  this.configureEvents(checkbox);
@@ -160,6 +171,21 @@ class _CheckboxGroup extends Base<ICheckboxGroupProps> implements ICheckboxGroup
160
171
  return this.props.multi ? values : values[0];
161
172
  }
162
173
 
174
+ // Sets the checkbox items
175
+ setItems(newItems: Array<ICheckboxGroupItem> = []) {
176
+ let renderRow = typeof (this.props.colSize) === "number" ? this.props.colSize > 0 : false;
177
+
178
+ // Update the properties
179
+ this.props.items = newItems;
180
+
181
+ // Get the element containing the checkboxes and clear them
182
+ let elParent = renderRow ? this.el.querySelector("div") : this.el;
183
+ while (elParent.firstChild) { elParent.removeChild(elParent.firstChild); }
184
+
185
+ // Render the checkboxes
186
+ this.renderItems();
187
+ }
188
+
163
189
  // Method to set the value
164
190
  // Sets the dropdown value
165
191
  setValue(value) {
@@ -61,7 +61,10 @@ export interface ICheckboxGroup {
61
61
  /** Hides the checkbox group. */
62
62
  hide: () => void;
63
63
 
64
- /** Sets the dropdown value. */
64
+ /** Sets the checkbox items. */
65
+ setItems: (value: Array<ICheckboxGroupItem>) => void;
66
+
67
+ /** Sets the checkbox value. */
65
68
  setValue: (value: string | Array<string>) => void;
66
69
 
67
70
  /** Shows the checkbox group. */
@@ -532,6 +532,13 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
532
532
  // Update the properties
533
533
  this.props.items = newItems;
534
534
 
535
+ // See if we are rendering checkboxes
536
+ if (this._cb) {
537
+ // Set the items
538
+ this._cb.setItems(newItems);
539
+ return;
540
+ }
541
+
535
542
  // Get the menu
536
543
  let menu: HTMLSelectElement = this.el.querySelector(".dropdown-menu") || this.el.querySelector("select");
537
544
  if (menu) {