gd-bs 6.5.4 → 6.5.6
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/card/index.js +5 -0
- package/build/components/cardGroup/index.js +34 -3
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.d.ts +9 -4
- package/dist/gd-bs.js +1 -1
- package/dist/gd-bs.min.js +1 -1
- package/index.html +91 -0
- package/package.json +1 -1
- package/src/components/button/index.ts +0 -2
- package/src/components/card/index.ts +6 -0
- package/src/components/card/types.d.ts +5 -4
- package/src/components/cardGroup/index.ts +42 -3
- package/src/components/cardGroup/types.d.ts +4 -0
package/index.html
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
<div id="panel"></div>
|
|
24
24
|
<div id="badge"></div>
|
|
25
25
|
<div id="card"></div>
|
|
26
|
+
<div id="card-group"></div>
|
|
26
27
|
<div id="tooltip"></div>
|
|
27
28
|
<div id="toolbar"></div>
|
|
28
29
|
<div id="ddl"></div>
|
|
@@ -152,9 +153,11 @@
|
|
|
152
153
|
|
|
153
154
|
window["card"] = GD.Components.Card({
|
|
154
155
|
el: document.getElementById("card"),
|
|
156
|
+
onRender: (el) => { console.log("Card Render: ", el); },
|
|
155
157
|
body: [{
|
|
156
158
|
title: "Card Title",
|
|
157
159
|
text: "This is the card contents.",
|
|
160
|
+
onRender: (el) => { console.log("Card Body Render: ", el); },
|
|
158
161
|
actions: [{
|
|
159
162
|
text: "Card Action",
|
|
160
163
|
buttonType: GD.Components.ButtonTypes.OutlinePrimary,
|
|
@@ -165,6 +168,94 @@
|
|
|
165
168
|
}]
|
|
166
169
|
});
|
|
167
170
|
|
|
171
|
+
window["cardGroup"] = GD.Components.CardGroup({
|
|
172
|
+
el: document.getElementById("card-group"),
|
|
173
|
+
className: "g-4",
|
|
174
|
+
col: 4,
|
|
175
|
+
onRender: (el) => { console.log("Card Group Render: ", el); },
|
|
176
|
+
cards: [
|
|
177
|
+
{
|
|
178
|
+
body: [{
|
|
179
|
+
title: "Card Title 1",
|
|
180
|
+
text: "This is the card contents.",
|
|
181
|
+
onRender: (el) => { console.log("Card Group Body Render: ", el); },
|
|
182
|
+
actions: [{
|
|
183
|
+
text: "Card Action",
|
|
184
|
+
buttonType: GD.Components.ButtonTypes.OutlinePrimary,
|
|
185
|
+
onClick: function(action, card) {
|
|
186
|
+
alert(card.title + " was clicked.");
|
|
187
|
+
}
|
|
188
|
+
}]
|
|
189
|
+
}]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
body: [{
|
|
193
|
+
title: "Card Title 2",
|
|
194
|
+
text: "This is the card contents.",
|
|
195
|
+
actions: [{
|
|
196
|
+
text: "Card Action",
|
|
197
|
+
buttonType: GD.Components.ButtonTypes.OutlinePrimary,
|
|
198
|
+
onClick: function(action, card) {
|
|
199
|
+
alert(card.title + " was clicked.");
|
|
200
|
+
}
|
|
201
|
+
}]
|
|
202
|
+
}]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
body: [{
|
|
206
|
+
title: "Card Title 3",
|
|
207
|
+
text: "This is the card contents.",
|
|
208
|
+
actions: [{
|
|
209
|
+
text: "Card Action",
|
|
210
|
+
buttonType: GD.Components.ButtonTypes.OutlinePrimary,
|
|
211
|
+
onClick: function(action, card) {
|
|
212
|
+
alert(card.title + " was clicked.");
|
|
213
|
+
}
|
|
214
|
+
}]
|
|
215
|
+
}]
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
body: [{
|
|
219
|
+
title: "Card Title 4",
|
|
220
|
+
text: "This is the card contents.",
|
|
221
|
+
actions: [{
|
|
222
|
+
text: "Card Action",
|
|
223
|
+
buttonType: GD.Components.ButtonTypes.OutlinePrimary,
|
|
224
|
+
onClick: function(action, card) {
|
|
225
|
+
alert(card.title + " was clicked.");
|
|
226
|
+
}
|
|
227
|
+
}]
|
|
228
|
+
}]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
body: [{
|
|
232
|
+
title: "Card Title 5",
|
|
233
|
+
text: "This is the card contents.",
|
|
234
|
+
actions: [{
|
|
235
|
+
text: "Card Action",
|
|
236
|
+
buttonType: GD.Components.ButtonTypes.OutlinePrimary,
|
|
237
|
+
onClick: function(action, card) {
|
|
238
|
+
alert(card.title + " was clicked.");
|
|
239
|
+
}
|
|
240
|
+
}]
|
|
241
|
+
}]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
body: [{
|
|
245
|
+
title: "Card Title 6",
|
|
246
|
+
text: "This is the card contents.",
|
|
247
|
+
actions: [{
|
|
248
|
+
text: "Card Action",
|
|
249
|
+
buttonType: GD.Components.ButtonTypes.OutlinePrimary,
|
|
250
|
+
onClick: function(action, card) {
|
|
251
|
+
alert(card.title + " was clicked.");
|
|
252
|
+
}
|
|
253
|
+
}]
|
|
254
|
+
}]
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
});
|
|
258
|
+
|
|
168
259
|
window["cbg"] = GD.Components.CheckboxGroup({
|
|
169
260
|
el: document.getElementById("cbGroup"),
|
|
170
261
|
label: "Label",
|
package/package.json
CHANGED
|
@@ -62,6 +62,12 @@ class _Card extends Base<ICardProps> implements ICard {
|
|
|
62
62
|
this.props.onClick(body.props);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
// See if there is a render event
|
|
67
|
+
if (this.props.onRender) {
|
|
68
|
+
// Call the event
|
|
69
|
+
this.props.onRender(this.el, body.props);
|
|
70
|
+
}
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
// Configure the header
|
|
@@ -84,7 +84,7 @@ export interface ICardAction {
|
|
|
84
84
|
/**
|
|
85
85
|
* Card Body
|
|
86
86
|
*/
|
|
87
|
-
export interface ICardBody<T=Element> {
|
|
87
|
+
export interface ICardBody<T = Element> {
|
|
88
88
|
actions?: Array<ICardAction>;
|
|
89
89
|
className?: string;
|
|
90
90
|
content?: string | T;
|
|
@@ -100,7 +100,7 @@ export interface ICardBody<T=Element> {
|
|
|
100
100
|
/**
|
|
101
101
|
* Card Footer
|
|
102
102
|
*/
|
|
103
|
-
export interface ICardFooter<T=Element> {
|
|
103
|
+
export interface ICardFooter<T = Element> {
|
|
104
104
|
className?: string;
|
|
105
105
|
content?: string | T;
|
|
106
106
|
onRender?: (el?: HTMLElement, card?: ICardFooter) => void;
|
|
@@ -109,7 +109,7 @@ export interface ICardFooter<T=Element> {
|
|
|
109
109
|
/**
|
|
110
110
|
* Card Header
|
|
111
111
|
*/
|
|
112
|
-
export interface ICardHeader<T=Element> {
|
|
112
|
+
export interface ICardHeader<T = Element> {
|
|
113
113
|
className?: string;
|
|
114
114
|
content?: string | T;
|
|
115
115
|
onRender?: (el?: HTMLElement, card?: ICardHeader) => void;
|
|
@@ -119,7 +119,7 @@ export interface ICardHeader<T=Element> {
|
|
|
119
119
|
/**
|
|
120
120
|
* Card Properties
|
|
121
121
|
*/
|
|
122
|
-
export interface ICardProps<T=Element> extends IBaseProps<ICard> {
|
|
122
|
+
export interface ICardProps<T = Element> extends IBaseProps<ICard> {
|
|
123
123
|
body?: Array<ICardBody<T>>;
|
|
124
124
|
footer?: ICardFooter<T>;
|
|
125
125
|
header?: ICardHeader<T>;
|
|
@@ -132,4 +132,5 @@ export interface ICardProps<T=Element> extends IBaseProps<ICard> {
|
|
|
132
132
|
src?: string;
|
|
133
133
|
};
|
|
134
134
|
onClick?: (card?: ICardBody, ev?: Event) => void;
|
|
135
|
+
onRender?: (el?: HTMLElement, card?: ICardProps) => void;
|
|
135
136
|
}
|
|
@@ -21,12 +21,51 @@ class _CardGroup extends Base<ICardGroupProps> implements ICardGroup {
|
|
|
21
21
|
|
|
22
22
|
// Configure the card group
|
|
23
23
|
private configure(cardTemplate: string) {
|
|
24
|
-
// Parse the cards
|
|
25
24
|
let cards = this.props.cards || [];
|
|
25
|
+
let isGrid = false;
|
|
26
|
+
|
|
27
|
+
// See if we are rendering columns
|
|
28
|
+
if (typeof (this.props.colSize) === "number") {
|
|
29
|
+
// Update the flag
|
|
30
|
+
isGrid = true;
|
|
31
|
+
|
|
32
|
+
// Update the class name
|
|
33
|
+
(this.el as HTMLElement).classList.remove("card-group");
|
|
34
|
+
(this.el as HTMLElement).classList.add("row");
|
|
35
|
+
|
|
36
|
+
// Determine the column class to use
|
|
37
|
+
let colSize = this.props.colSize > 0 && this.props.colSize <= 12 ? this.props.colSize : 4;
|
|
38
|
+
(this.el as HTMLElement).classList.add("row-cols-" + colSize);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Parse the cards
|
|
26
42
|
for (let i = 0; i < cards.length; i++) {
|
|
27
|
-
//
|
|
28
|
-
|
|
43
|
+
// Create the card
|
|
44
|
+
let card = Card(cards[i], cardTemplate);
|
|
45
|
+
|
|
46
|
+
// See if we are using a grid
|
|
47
|
+
if (isGrid) {
|
|
48
|
+
// Create a column element
|
|
49
|
+
let elCol = document.createElement("div");
|
|
50
|
+
elCol.classList.add("col");
|
|
51
|
+
elCol.appendChild(card.el);
|
|
52
|
+
|
|
53
|
+
// Add the card
|
|
54
|
+
this.el.appendChild(elCol);
|
|
55
|
+
|
|
56
|
+
// Call the event
|
|
57
|
+
this.props.onColRender ? this.props.onColRender(elCol, cards[i]) : null;
|
|
58
|
+
} else {
|
|
59
|
+
// Add the card
|
|
60
|
+
this.el.appendChild(card.el);
|
|
61
|
+
|
|
62
|
+
// Call the event
|
|
63
|
+
this.props.onCardRender ? this.props.onCardRender(card.el, cards[i]) : null;
|
|
64
|
+
}
|
|
29
65
|
}
|
|
66
|
+
|
|
67
|
+
// Call the event
|
|
68
|
+
this.props.onRender ? this.props.onRender(this.el, this.props) : null;
|
|
30
69
|
}
|
|
31
70
|
}
|
|
32
71
|
export const CardGroup = (props: ICardGroupProps, template?: string, cardTemplate?: string): ICardGroup => { return new _CardGroup(props, template, cardTemplate); }
|
|
@@ -107,4 +107,8 @@ export interface ICardGroup {
|
|
|
107
107
|
*/
|
|
108
108
|
export interface ICardGroupProps extends IBaseProps<ICardGroup> {
|
|
109
109
|
cards?: Array<ICardProps>;
|
|
110
|
+
colSize?: number;
|
|
111
|
+
onCardRender?: (el?: HTMLElement, props?: ICardProps) => void;
|
|
112
|
+
onColRender?: (el?: HTMLElement, props?: ICardProps) => void;
|
|
113
|
+
onRender?: (el?: HTMLElement, props?: ICardGroupProps) => void;
|
|
110
114
|
}
|