gd-bs 5.0.6 → 5.1.0

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": "5.0.6",
3
+ "version": "5.1.0",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -9,15 +9,16 @@
9
9
  * id: "demoAccordion",
10
10
  * items: [
11
11
  * {
12
- * btnProps: { text: "Item 1" },
13
- * content: "This is the content for item 1."
12
+ * header: "Item 1",
13
+ * content: "This is the content for item 1.",
14
+ * showFl: true
14
15
  * },
15
16
  * {
16
- * btnProps: { text: "Item 2" },
17
+ * header: "Item 2",
17
18
  * content: "This is the content for item 2."
18
19
  * },
19
20
  * {
20
- * btnProps: { text: "Item 3" },
21
+ * header: "Item 3",
21
22
  * content: "This is the content for item 3."
22
23
  * }
23
24
  * ]
@@ -39,15 +40,16 @@
39
40
  * id: "demoAccordion",
40
41
  * items: [
41
42
  * {
42
- * btnProps: { text: "Item 1" },
43
- * content: "This is the content for item 1."
43
+ * header: "Item 1",
44
+ * content: "This is the content for item 1.",
45
+ * showFl: true
44
46
  * },
45
47
  * {
46
- * btnProps: { text: "Item 2" },
48
+ * header: "Item 2",
47
49
  * content: "This is the content for item 2."
48
50
  * },
49
51
  * {
50
- * btnProps: { text: "Item 3" },
52
+ * header: "Item 3",
51
53
  * content: "This is the content for item 3."
52
54
  * }
53
55
  * ]
@@ -57,7 +59,6 @@
57
59
  export const Accordion: (props: IAccordionProps, template?: string, itemTemplate?: string) => IAccordion;
58
60
 
59
61
  import { IBase, IBaseProps } from "../types";
60
- import { ICollapseOptions } from "../collapse/types";
61
62
 
62
63
  /**
63
64
  * Accordion
@@ -77,11 +78,6 @@ export interface IAccordionItem<T = Element> {
77
78
  showFl?: boolean;
78
79
  }
79
80
 
80
- /**
81
- * Accordion Options
82
- */
83
- export interface IAccordionOptions extends ICollapseOptions { }
84
-
85
81
  /**
86
82
  * Accordion Properties
87
83
  */
@@ -89,5 +85,4 @@ export interface IAccordionProps<T = Element> extends IBaseProps<IAccordion> {
89
85
  autoCollapse?: boolean;
90
86
  id?: string;
91
87
  items?: Array<IAccordionItem<T>>;
92
- options?: IAccordionOptions;
93
88
  }
@@ -81,6 +81,28 @@ class _ListBox extends Base<IListBoxProps> implements IListBox {
81
81
 
82
82
  // Configures the events
83
83
  private configureEvents() {
84
+ // Execute the load event
85
+ let returnVal: any = this.props.onLoadData ? this.props.onLoadData() : null;
86
+ if (returnVal) {
87
+ // See if a promise was returned
88
+ if (typeof (returnVal.then) === "function") {
89
+ // Wait for the promise to complete
90
+ returnVal.then(items => {
91
+ // Set the options
92
+ this.setOptions(items);
93
+
94
+ // Set the value if it's been defined
95
+ if (this.props.value != undefined) { this.setValue(this.props.value); }
96
+ });
97
+ } else {
98
+ // Set the options
99
+ this.setOptions(returnVal);
100
+
101
+ // Set the value if it's been defined
102
+ if (this.props.value != undefined) { this.setValue(this.props.value); }
103
+ }
104
+ }
105
+
84
106
  // Set the change event on the search box
85
107
  this._elSearchBox.addEventListener("input", ev => {
86
108
  let value = this._elSearchBox.value;
@@ -172,8 +194,10 @@ class _ListBox extends Base<IListBoxProps> implements IListBox {
172
194
  * Public Interface
173
195
  */
174
196
 
197
+ // Gets the selected items
175
198
  getValue() { return this._selectedItems; }
176
199
 
200
+ // Sets the options
177
201
  setOptions(items: Array<IDropdownItem> = []) {
178
202
  let elDatalist = this.el.querySelector("datalist") as HTMLDataListElement;
179
203
  if (elDatalist) {
@@ -16,6 +16,9 @@ export interface IListBox extends IBase<IListBoxProps> {
16
16
  /** The selected listbox items. */
17
17
  getValue: () => Array<IDropdownItem>;
18
18
 
19
+ /** Sets the options */
20
+ setOptions: (items: Array<IDropdownItem>) => void;
21
+
19
22
  /** Sets the listbox value. */
20
23
  setValue: (value?: string | Array<string> | Array<IDropdownItem>) => void;
21
24
  }
@@ -30,6 +33,7 @@ export interface IListBoxProps {
30
33
  items: Array<IDropdownItem>;
31
34
  multi?: boolean;
32
35
  placeholder?: string;
36
+ onLoadData?: () => Array<IDropdownItem> | PromiseLike<Array<IDropdownItem>>;
33
37
  onChange?: (items: IDropdownItem | Array<IDropdownItem>, ev?: Event) => void;
34
38
  value?: string | Array<string>;
35
39
  }
@@ -91,24 +91,24 @@ class _Nav extends Base<INavProps> implements INav {
91
91
  this.configureEvents(link);
92
92
 
93
93
  // Add the tab content
94
- tabs.appendChild(link.elTab);
94
+ tabs.appendChild(link.elTabContent);
95
95
 
96
96
  // See if the fade option is enabled
97
97
  if (this.props.fadeTabs) {
98
98
  // Set the class name
99
- link.elTab.classList.add("fade");
99
+ link.elTabContent.classList.add("fade");
100
100
 
101
101
  // See if the tab is active
102
102
  if (link.props.isActive) {
103
103
  // Set the class name
104
- link.elTab.classList.add("show");
104
+ link.elTabContent.classList.add("show");
105
105
  }
106
106
  }
107
107
  }
108
108
 
109
109
  // Call the render events
110
- this.props.onLinkRendered ? this.props.onLinkRendered(link.el, links[i]) : null;
111
- this.props.onTabRendered ? this.props.onTabRendered(link.elTab, links[i]) : null;
110
+ this.props.onLinkRendered ? this.props.onLinkRendered(link.elTab, links[i]) : null;
111
+ this.props.onTabRendered ? this.props.onTabRendered(link.elTabContent, links[i]) : null;
112
112
  }
113
113
  }
114
114
  }
@@ -143,7 +143,7 @@ class _Nav extends Base<INavProps> implements INav {
143
143
  let link = this._links[i];
144
144
 
145
145
  // See if this is the target tab
146
- if (tabId === i + 1 || link.elTab.getAttribute("data-title") == tabId) {
146
+ if (tabId === i + 1 || link.elTabContent.getAttribute("data-title") == tabId) {
147
147
  // Toggle it if it's not active
148
148
  link.isActive ? null : link.toggle(this.props.fadeTabs);
149
149
  }