gd-bs 6.6.82 → 6.6.83
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/table/index.js +73 -22
- package/dist/gd-bs-icons.js +1 -1
- package/dist/gd-bs-icons.min.js +1 -1
- package/dist/gd-bs.d.ts +14 -8
- package/dist/gd-bs.js +1 -1
- package/dist/gd-bs.min.js +1 -1
- package/package.json +2 -2
- package/src/components/table/index.ts +84 -24
- package/src/components/table/types.d.ts +14 -8
|
@@ -35,6 +35,7 @@ var _Table = /** @class */ (function (_super) {
|
|
|
35
35
|
}
|
|
36
36
|
// Configure the card group
|
|
37
37
|
_Table.prototype.configure = function () {
|
|
38
|
+
var hasFooter = false;
|
|
38
39
|
// See if columns are defined
|
|
39
40
|
var head = this.el.querySelector("thead");
|
|
40
41
|
if (head) {
|
|
@@ -47,8 +48,13 @@ var _Table = /** @class */ (function (_super) {
|
|
|
47
48
|
// Append the column
|
|
48
49
|
var column = document.createElement("th");
|
|
49
50
|
row.appendChild(column);
|
|
51
|
+
// See if the footer exists
|
|
52
|
+
if (this.props.columns[i].footer) {
|
|
53
|
+
// Set the flag
|
|
54
|
+
hasFooter = true;
|
|
55
|
+
}
|
|
50
56
|
// Render the column
|
|
51
|
-
this.renderColumn(
|
|
57
|
+
this.renderColumn(column, this.props.columns[i]);
|
|
52
58
|
}
|
|
53
59
|
// See if there is an event
|
|
54
60
|
if (this.props.onRenderHeaderRow) {
|
|
@@ -59,9 +65,64 @@ var _Table = /** @class */ (function (_super) {
|
|
|
59
65
|
}
|
|
60
66
|
// Add the rows
|
|
61
67
|
this.addRows(this.props.rows);
|
|
68
|
+
// See if the footer exists
|
|
69
|
+
if (hasFooter) {
|
|
70
|
+
// Append the footer
|
|
71
|
+
var footer = document.createElement("tfoot");
|
|
72
|
+
this.el.appendChild(footer);
|
|
73
|
+
// Append the row
|
|
74
|
+
var row = document.createElement("tr");
|
|
75
|
+
footer.appendChild(row);
|
|
76
|
+
// Parse the columns
|
|
77
|
+
for (var i = 0; i < this.props.columns.length; i++) {
|
|
78
|
+
// Append the column
|
|
79
|
+
var column = document.createElement("td");
|
|
80
|
+
row.appendChild(column);
|
|
81
|
+
// See if the footer exists
|
|
82
|
+
if (this.props.columns[i].footer) {
|
|
83
|
+
// Set the flag
|
|
84
|
+
hasFooter = true;
|
|
85
|
+
}
|
|
86
|
+
// Render the column
|
|
87
|
+
this.renderColumnFooter(column, this.props.columns[i]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
// Renders a cell
|
|
92
|
+
_Table.prototype.renderCell = function (row, props, data, rowIdx) {
|
|
93
|
+
var _this = this;
|
|
94
|
+
// Create the cell
|
|
95
|
+
var cell = document.createElement("td");
|
|
96
|
+
cell.className = props.className || "";
|
|
97
|
+
cell.innerHTML = data[props.name] == null ? "" : data[props.name];
|
|
98
|
+
row.appendChild(cell);
|
|
99
|
+
// See if there is a scope
|
|
100
|
+
if (props.scope) {
|
|
101
|
+
// Set the scope
|
|
102
|
+
cell.setAttribute("scope", props.scope);
|
|
103
|
+
}
|
|
104
|
+
// See if there is an event for this column
|
|
105
|
+
if (props.onRenderCell) {
|
|
106
|
+
// Call the event
|
|
107
|
+
props.onRenderCell(cell, props, data, rowIdx);
|
|
108
|
+
}
|
|
109
|
+
// See if there is an event for this component
|
|
110
|
+
if (this.props.onRenderCell) {
|
|
111
|
+
// Call the event
|
|
112
|
+
this.props.onRenderCell(cell, props, data, rowIdx);
|
|
113
|
+
}
|
|
114
|
+
// See if there is a click event
|
|
115
|
+
if (props.onClickCell || this.props.onClickCell) {
|
|
116
|
+
// Add the click event
|
|
117
|
+
cell.addEventListener("click", function (ev) {
|
|
118
|
+
// Call the event
|
|
119
|
+
props.onClickCell ? props.onClickCell(cell, props, data, rowIdx) : null;
|
|
120
|
+
_this.props.onClickCell ? _this.props.onClickCell(cell, props, data, rowIdx) : null;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
62
123
|
};
|
|
63
124
|
// Renders a column
|
|
64
|
-
_Table.prototype.renderColumn = function (
|
|
125
|
+
_Table.prototype.renderColumn = function (column, props) {
|
|
65
126
|
var _this = this;
|
|
66
127
|
column.innerHTML = props.isHidden ? "" : props.title || props.name;
|
|
67
128
|
column.setAttribute("scope", "col");
|
|
@@ -85,36 +146,26 @@ var _Table = /** @class */ (function (_super) {
|
|
|
85
146
|
});
|
|
86
147
|
}
|
|
87
148
|
};
|
|
88
|
-
// Renders a
|
|
89
|
-
_Table.prototype.
|
|
149
|
+
// Renders a column footer
|
|
150
|
+
_Table.prototype.renderColumnFooter = function (column, props) {
|
|
90
151
|
var _this = this;
|
|
91
|
-
// Create the cell
|
|
92
|
-
var cell = document.createElement("td");
|
|
93
|
-
cell.className = props.className || "";
|
|
94
|
-
cell.innerHTML = data[props.name] == null ? "" : data[props.name];
|
|
95
|
-
row.appendChild(cell);
|
|
96
|
-
// See if there is a scope
|
|
97
|
-
if (props.scope) {
|
|
98
|
-
// Set the scope
|
|
99
|
-
cell.setAttribute("scope", props.scope);
|
|
100
|
-
}
|
|
101
152
|
// See if there is an event for this column
|
|
102
|
-
if (props.
|
|
153
|
+
if (props.onRenderFooter) {
|
|
103
154
|
// Call the event
|
|
104
|
-
props.
|
|
155
|
+
props.onRenderFooter(column, props);
|
|
105
156
|
}
|
|
106
157
|
// See if there is an event for this component
|
|
107
|
-
if (this.props.
|
|
158
|
+
if (this.props.onRenderFooterCell) {
|
|
108
159
|
// Call the event
|
|
109
|
-
this.props.
|
|
160
|
+
this.props.onRenderFooterCell(column, props);
|
|
110
161
|
}
|
|
111
162
|
// See if there is a click event
|
|
112
|
-
if (props.
|
|
163
|
+
if (props.onClickFooter || this.props.onClickFooter) {
|
|
113
164
|
// Add the click event
|
|
114
|
-
|
|
165
|
+
column.addEventListener("click", function (ev) {
|
|
115
166
|
// Call the event
|
|
116
|
-
props.
|
|
117
|
-
_this.props.
|
|
167
|
+
props.onClickFooter ? props.onClickFooter(column, props) : null;
|
|
168
|
+
_this.props.onClickFooter ? _this.props.onClickFooter(column, props) : null;
|
|
118
169
|
});
|
|
119
170
|
}
|
|
120
171
|
};
|