gd-bs 6.6.36 → 6.6.38
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/common.js +2 -3
- package/build/components/dropdown/index.js +23 -13
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.js +1 -1
- package/dist/gd-bs.min.js +1 -1
- package/package.json +1 -1
- package/src/components/common.ts +3 -3
- package/src/components/dropdown/index.ts +27 -17
package/package.json
CHANGED
package/src/components/common.ts
CHANGED
|
@@ -49,9 +49,9 @@ export const configureParent = (component: Element, parent: Element): Element =>
|
|
|
49
49
|
return el;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export const setClassNames = (el: HTMLElement, className
|
|
53
|
-
// Ensure the element exists
|
|
54
|
-
if (el) {
|
|
52
|
+
export const setClassNames = (el: HTMLElement, className) => {
|
|
53
|
+
// Ensure the element and class name exists exists
|
|
54
|
+
if (el && className) {
|
|
55
55
|
// Set the class names
|
|
56
56
|
let classNames = className.split(' ');
|
|
57
57
|
for (let i = 0; i < classNames.length; i++) {
|
|
@@ -167,8 +167,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
167
167
|
if (menu) {
|
|
168
168
|
// Add a change event
|
|
169
169
|
menu.addEventListener("change", ev => {
|
|
170
|
-
let values = "";
|
|
171
|
-
|
|
172
170
|
// See if multiple options are allowed
|
|
173
171
|
if (this.props.multi == true) {
|
|
174
172
|
// See if we are selecting the values
|
|
@@ -179,9 +177,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
179
177
|
|
|
180
178
|
// Update the flag
|
|
181
179
|
item.isSelected = (item.el as HTMLOptionElement).selected;
|
|
182
|
-
|
|
183
|
-
// Append the value
|
|
184
|
-
values = (values ? ", " : "") + (item.props.text || item.props.value);
|
|
185
180
|
}
|
|
186
181
|
}
|
|
187
182
|
|
|
@@ -191,9 +186,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
191
186
|
// Get the selected value
|
|
192
187
|
let selectedValue = ((ev.target as HTMLSelectElement).value || "").trim();
|
|
193
188
|
|
|
194
|
-
// Set the selected value
|
|
195
|
-
values = selectedValue;
|
|
196
|
-
|
|
197
189
|
// Parse the items
|
|
198
190
|
for (let i = 0; i < this._items.length; i++) {
|
|
199
191
|
let item = this._items[i];
|
|
@@ -214,15 +206,6 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
214
206
|
}
|
|
215
207
|
}
|
|
216
208
|
}
|
|
217
|
-
|
|
218
|
-
// See if we are updating the label
|
|
219
|
-
if (this.props.updateLabel) {
|
|
220
|
-
// Set the label
|
|
221
|
-
let toggle = this.el.querySelector(".dropdown-toggle");
|
|
222
|
-
if (toggle) {
|
|
223
|
-
toggle.innerHTML = values || this.props.label;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
209
|
});
|
|
227
210
|
}
|
|
228
211
|
|
|
@@ -346,6 +329,22 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
346
329
|
selectedItem.toggle();
|
|
347
330
|
}
|
|
348
331
|
}
|
|
332
|
+
|
|
333
|
+
// See if we are updating the label
|
|
334
|
+
if (this.props.updateLabel) {
|
|
335
|
+
let selectedItems = this.getValue() as IDropdownItem[];
|
|
336
|
+
let selectedValues = [];
|
|
337
|
+
for (let i = 0; i < selectedItems.length; i++) {
|
|
338
|
+
// Append the value
|
|
339
|
+
selectedValues.push(selectedItems[i].text);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Set the label
|
|
343
|
+
let toggle = this.el.querySelector(".dropdown-toggle");
|
|
344
|
+
if (toggle) {
|
|
345
|
+
toggle.innerHTML = selectedValues.length > 0 ? selectedValues.join(', ') : this.props.label;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
349
348
|
});
|
|
350
349
|
}
|
|
351
350
|
|
|
@@ -362,6 +361,17 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
362
361
|
|
|
363
362
|
// Execute the event
|
|
364
363
|
this.props.onChange ? this.props.onChange(this.getValue(), ev) : null;
|
|
364
|
+
|
|
365
|
+
// See if we are updating the label
|
|
366
|
+
if (this.props.updateLabel) {
|
|
367
|
+
let selectedItem = this.getValue() as IDropdownItem;
|
|
368
|
+
|
|
369
|
+
// Set the label
|
|
370
|
+
let toggle = this.el.querySelector(".dropdown-toggle");
|
|
371
|
+
if (toggle) {
|
|
372
|
+
toggle.innerHTML = selectedItem ? selectedItem.text : this.props.label;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
365
375
|
});
|
|
366
376
|
}
|
|
367
377
|
|