gd-bs 6.6.6 → 6.6.8
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/checkboxGroup/index.js +30 -6
- package/build/components/dropdown/index.js +7 -0
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.d.ts +4 -1
- package/dist/gd-bs.js +1 -1
- package/dist/gd-bs.min.js +1 -1
- package/package.json +1 -1
- package/src/components/checkboxGroup/index.ts +32 -6
- package/src/components/checkboxGroup/types.d.ts +4 -1
- package/src/components/dropdown/index.ts +8 -0
|
@@ -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(
|
|
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 (
|
|
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(
|
|
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 (
|
|
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,
|
|
144
|
+
var checkbox = new item_1.CheckboxItem(item, this.props, this._cbTemplate);
|
|
135
145
|
this._checkboxes.push(checkbox);
|
|
136
|
-
|
|
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) {
|
|
@@ -408,6 +408,7 @@ var _Dropdown = /** @class */ (function (_super) {
|
|
|
408
408
|
el: menu,
|
|
409
409
|
items: cbItems,
|
|
410
410
|
multi: this.props.multi,
|
|
411
|
+
value: this.props.value,
|
|
411
412
|
onChange: this.props.onChange ? function (values, ev) {
|
|
412
413
|
// Pass the current values
|
|
413
414
|
_this.props.onChange(_this.getValue(), ev);
|
|
@@ -519,6 +520,12 @@ var _Dropdown = /** @class */ (function (_super) {
|
|
|
519
520
|
if (newItems === void 0) { newItems = []; }
|
|
520
521
|
// Update the properties
|
|
521
522
|
this.props.items = newItems;
|
|
523
|
+
// See if we are rendering checkboxes
|
|
524
|
+
if (this._cb) {
|
|
525
|
+
// Set the items
|
|
526
|
+
this._cb.setItems(newItems);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
522
529
|
// Get the menu
|
|
523
530
|
var menu = this.el.querySelector(".dropdown-menu") || this.el.querySelector("select");
|
|
524
531
|
if (menu) {
|