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
package/package.json
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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,
|
|
139
|
+
let checkbox = new CheckboxItem(item, this.props, this._cbTemplate);
|
|
129
140
|
this._checkboxes.push(checkbox);
|
|
130
|
-
|
|
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
|
|
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. */
|
|
@@ -419,6 +419,7 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
419
419
|
el: menu,
|
|
420
420
|
items: cbItems,
|
|
421
421
|
multi: this.props.multi,
|
|
422
|
+
value: this.props.value,
|
|
422
423
|
onChange: this.props.onChange ? (values, ev) => {
|
|
423
424
|
// Pass the current values
|
|
424
425
|
this.props.onChange(this.getValue(), ev);
|
|
@@ -532,6 +533,13 @@ class _Dropdown extends Base<IDropdownProps> implements IDropdown {
|
|
|
532
533
|
// Update the properties
|
|
533
534
|
this.props.items = newItems;
|
|
534
535
|
|
|
536
|
+
// See if we are rendering checkboxes
|
|
537
|
+
if (this._cb) {
|
|
538
|
+
// Set the items
|
|
539
|
+
this._cb.setItems(newItems);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
|
|
535
543
|
// Get the menu
|
|
536
544
|
let menu: HTMLSelectElement = this.el.querySelector(".dropdown-menu") || this.el.querySelector("select");
|
|
537
545
|
if (menu) {
|