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.
@@ -37,10 +37,14 @@ var _CheckboxGroup = /** @class */ (function (_super) {
37
37
  function _CheckboxGroup(props, template, cbTemplate) {
38
38
  if (template === void 0) { template = templates_1.HTML; }
39
39
  var _this = _super.call(this, template, props) || this;
40
+ _this._cbTemplate = null;
40
41
  _this._checkboxes = null;
42
+ _this._elCheckboxes = null;
41
43
  _this._initFl = false;
44
+ // Set the template
45
+ _this._cbTemplate = cbTemplate;
42
46
  // Configure the checkbox group
43
- _this.configure(cbTemplate);
47
+ _this.configure();
44
48
  // Configure the parent
45
49
  _this.configureParent();
46
50
  // Set the flag
@@ -48,7 +52,7 @@ var _CheckboxGroup = /** @class */ (function (_super) {
48
52
  return _this;
49
53
  }
50
54
  // Configure the card group
51
- _CheckboxGroup.prototype.configure = function (cbTemplate) {
55
+ _CheckboxGroup.prototype.configure = function () {
52
56
  var renderRow = typeof (this.props.colSize) === "number" ? this.props.colSize > 0 : false;
53
57
  // See if a label is defined
54
58
  var label = this.el.querySelector("legend");
@@ -68,10 +72,16 @@ var _CheckboxGroup = /** @class */ (function (_super) {
68
72
  if (!renderRow) {
69
73
  // Remove the group element
70
74
  this.el.removeChild(group);
75
+ // Set the checkboxes element
76
+ this._elCheckboxes = this.el;
77
+ }
78
+ else {
79
+ // Set the checkboxes element
80
+ this._elCheckboxes = group;
71
81
  }
72
82
  }
73
83
  // Render the checkboxes
74
- this.renderItems(renderRow ? group : this.el, cbTemplate);
84
+ this.renderItems();
75
85
  };
76
86
  // Configure the events
77
87
  _CheckboxGroup.prototype.configureEvents = function (item) {
@@ -106,7 +116,7 @@ var _CheckboxGroup = /** @class */ (function (_super) {
106
116
  }
107
117
  };
108
118
  // Render the checkboxes
109
- _CheckboxGroup.prototype.renderItems = function (group, cbTemplate) {
119
+ _CheckboxGroup.prototype.renderItems = function () {
110
120
  // Clear the checkboxes
111
121
  this._checkboxes = [];
112
122
  // Set the items
@@ -131,9 +141,9 @@ var _CheckboxGroup = /** @class */ (function (_super) {
131
141
  for (var i = 0; i < items.length; i++) {
132
142
  var item = items[i];
133
143
  // Create the checkbox
134
- var checkbox = new item_1.CheckboxItem(item, this.props, cbTemplate);
144
+ var checkbox = new item_1.CheckboxItem(item, this.props, this._cbTemplate);
135
145
  this._checkboxes.push(checkbox);
136
- group.appendChild(checkbox.el);
146
+ this._elCheckboxes.appendChild(checkbox.el);
137
147
  // Configure the events
138
148
  this.configureEvents(checkbox);
139
149
  // Execute the render event
@@ -158,6 +168,20 @@ var _CheckboxGroup = /** @class */ (function (_super) {
158
168
  // Return the values
159
169
  return this.props.multi ? values : values[0];
160
170
  };
171
+ // Sets the checkbox items
172
+ _CheckboxGroup.prototype.setItems = function (newItems) {
173
+ if (newItems === void 0) { newItems = []; }
174
+ var renderRow = typeof (this.props.colSize) === "number" ? this.props.colSize > 0 : false;
175
+ // Update the properties
176
+ this.props.items = newItems;
177
+ // Get the element containing the checkboxes and clear them
178
+ var elParent = renderRow ? this.el.querySelector("div") : this.el;
179
+ while (elParent.firstChild) {
180
+ elParent.removeChild(elParent.firstChild);
181
+ }
182
+ // Render the checkboxes
183
+ this.renderItems();
184
+ };
161
185
  // Method to set the value
162
186
  // Sets the dropdown value
163
187
  _CheckboxGroup.prototype.setValue = function (value) {
@@ -519,6 +519,12 @@ var _Dropdown = /** @class */ (function (_super) {
519
519
  if (newItems === void 0) { newItems = []; }
520
520
  // Update the properties
521
521
  this.props.items = newItems;
522
+ // See if we are rendering checkboxes
523
+ if (this._cb) {
524
+ // Set the items
525
+ this._cb.setItems(newItems);
526
+ return;
527
+ }
522
528
  // Get the menu
523
529
  var menu = this.el.querySelector(".dropdown-menu") || this.el.querySelector("select");
524
530
  if (menu) {