gd-bs 6.6.82 → 6.6.84

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": "6.6.82",
3
+ "version": "6.6.84",
4
4
  "description": "Bootstrap JavaScript, TypeScript and Web Components library.",
5
5
  "main": "build/index.js",
6
6
  "typings": "src/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  "@popperjs/core": "^2.11.8",
37
37
  "bootstrap": "^5.3.3",
38
38
  "bootstrap-icons": "^1.11.3",
39
- "core-js": "^3.39.0",
39
+ "core-js": "^3.40.0",
40
40
  "tippy.js": "^6.3.7"
41
41
  },
42
42
  "devDependencies": {
@@ -19,6 +19,8 @@ class _Table extends Base<ITableProps> implements ITable {
19
19
 
20
20
  // Configure the card group
21
21
  private configure() {
22
+ let hasFooter = false;
23
+
22
24
  // See if columns are defined
23
25
  let head = this.el.querySelector("thead");
24
26
  if (head) {
@@ -29,12 +31,20 @@ class _Table extends Base<ITableProps> implements ITable {
29
31
 
30
32
  // Parse the columns
31
33
  for (let i = 0; i < this.props.columns.length; i++) {
34
+ let colProp = this.props.columns[i];
35
+
32
36
  // Append the column
33
37
  let column = document.createElement("th");
34
38
  row.appendChild(column);
35
39
 
40
+ // See if the footer exists
41
+ if (colProp.footer || colProp.onRenderFooter) {
42
+ // Set the flag
43
+ hasFooter = true;
44
+ }
45
+
36
46
  // Render the column
37
- this.renderColumn(i, column, this.props.columns[i]);
47
+ this.renderColumn(column, colProp);
38
48
  }
39
49
 
40
50
  // See if there is an event
@@ -47,10 +57,68 @@ class _Table extends Base<ITableProps> implements ITable {
47
57
 
48
58
  // Add the rows
49
59
  this.addRows(this.props.rows);
60
+
61
+ // See if the footer exists
62
+ if (hasFooter) {
63
+ // Append the footer
64
+ let footer = document.createElement("tfoot");
65
+ this.el.appendChild(footer);
66
+
67
+ // Append the row
68
+ let row = document.createElement("tr");
69
+ footer.appendChild(row);
70
+
71
+ // Parse the columns
72
+ for (let i = 0; i < this.props.columns.length; i++) {
73
+ // Append the column
74
+ let column = document.createElement("td");
75
+ row.appendChild(column);
76
+
77
+ // Render the column
78
+ this.renderColumnFooter(column, this.props.columns[i]);
79
+ }
80
+ }
81
+ }
82
+
83
+ // Renders a cell
84
+ private renderCell(row: HTMLTableRowElement, props: ITableColumn, data, rowIdx: number) {
85
+ // Create the cell
86
+ let cell = document.createElement("td");
87
+ cell.className = props.className || "";
88
+ cell.innerHTML = data[props.name] == null ? "" : data[props.name];
89
+ row.appendChild(cell);
90
+
91
+ // See if there is a scope
92
+ if (props.scope) {
93
+ // Set the scope
94
+ cell.setAttribute("scope", props.scope);
95
+ }
96
+
97
+ // See if there is an event for this column
98
+ if (props.onRenderCell) {
99
+ // Call the event
100
+ props.onRenderCell(cell, props, data, rowIdx);
101
+ }
102
+
103
+ // See if there is an event for this component
104
+ if (this.props.onRenderCell) {
105
+ // Call the event
106
+ this.props.onRenderCell(cell, props, data, rowIdx);
107
+ }
108
+
109
+ // See if there is a click event
110
+ if (props.onClickCell || this.props.onClickCell) {
111
+ // Add the click event
112
+ cell.addEventListener("click", ev => {
113
+ // Call the event
114
+ props.onClickCell ? props.onClickCell(cell, props, data, rowIdx) : null;
115
+ this.props.onClickCell ? this.props.onClickCell(cell, props, data, rowIdx) : null;
116
+ });
117
+ }
50
118
  }
51
119
 
52
120
  // Renders a column
53
- private renderColumn(colIdx: number, column: HTMLTableCellElement, props: ITableColumn) {
121
+ private renderColumn(column: HTMLTableCellElement, props: ITableColumn) {
54
122
  column.innerHTML = props.isHidden ? "" : props.title || props.name;
55
123
  column.setAttribute("scope", "col");
56
124
 
@@ -77,39 +145,29 @@ class _Table extends Base<ITableProps> implements ITable {
77
145
  }
78
146
  }
79
147
 
80
- // Renders a cell
81
- private renderCell(row: HTMLTableRowElement, props: ITableColumn, data, rowIdx: number) {
82
- // Create the cell
83
- let cell = document.createElement("td");
84
- cell.className = props.className || "";
85
- cell.innerHTML = data[props.name] == null ? "" : data[props.name];
86
- row.appendChild(cell);
87
-
88
- // See if there is a scope
89
- if (props.scope) {
90
- // Set the scope
91
- cell.setAttribute("scope", props.scope);
92
- }
148
+ // Renders a column footer
149
+ private renderColumnFooter(column: HTMLTableCellElement, props: ITableColumn) {
150
+ column.innerHTML = props.footer || "";
93
151
 
94
152
  // See if there is an event for this column
95
- if (props.onRenderCell) {
153
+ if (props.onRenderFooter) {
96
154
  // Call the event
97
- props.onRenderCell(cell, props, data, rowIdx);
155
+ props.onRenderFooter(column, props);
98
156
  }
99
157
 
100
158
  // See if there is an event for this component
101
- if (this.props.onRenderCell) {
159
+ if (this.props.onRenderFooterCell) {
102
160
  // Call the event
103
- this.props.onRenderCell(cell, props, data, rowIdx);
161
+ this.props.onRenderFooterCell(column, props);
104
162
  }
105
163
 
106
164
  // See if there is a click event
107
- if (props.onClickCell || this.props.onClickCell) {
165
+ if (props.onClickFooter || this.props.onClickFooter) {
108
166
  // Add the click event
109
- cell.addEventListener("click", ev => {
167
+ column.addEventListener("click", ev => {
110
168
  // Call the event
111
- props.onClickCell ? props.onClickCell(cell, props, data, rowIdx) : null;
112
- this.props.onClickCell ? this.props.onClickCell(cell, props, data, rowIdx) : null;
169
+ props.onClickFooter ? props.onClickFooter(column, props) : null;
170
+ this.props.onClickFooter ? this.props.onClickFooter(column, props) : null;
113
171
  });
114
172
  }
115
173
  }
@@ -85,10 +85,13 @@ export interface ITable {
85
85
  */
86
86
  export interface ITableProps extends IBaseProps<ITable> {
87
87
  columns?: Array<ITableColumn>;
88
- onClickCell?: (el: HTMLTableDataCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
89
- onClickHeader?: (el: HTMLTableHeaderCellElement, column?: ITableColumn) => void;
90
- onRenderCell?: (el?: HTMLTableDataCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
91
- onRenderHeaderCell?: (el?: HTMLTableDataCellElement, column?: ITableColumn) => void;
88
+ onClickCell?: (el: HTMLTableCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
89
+ onClickFooter?: (el: HTMLTableCellElement, column?: ITableColumn) => void;
90
+ onClickHeader?: (el: HTMLTableCellElement, column?: ITableColumn) => void;
91
+ onRenderCell?: (el?: HTMLTableCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
92
+ onRenderFooterCell?: (el?: HTMLTableCellElement, column?: ITableColumn) => void;
93
+ onRenderFooterRow?: (el?: HTMLTableRowElement) => void;
94
+ onRenderHeaderCell?: (el?: HTMLTableCellElement, column?: ITableColumn) => void;
92
95
  onRenderHeaderRow?: (el?: HTMLTableRowElement) => void;
93
96
  onRenderRow?: (el?: HTMLTableRowElement, data?: any, rowIdx?: number) => void;
94
97
  rows?: Array<any>;
@@ -100,12 +103,15 @@ export interface ITableProps extends IBaseProps<ITable> {
100
103
  export interface ITableColumn {
101
104
  className?: string;
102
105
  data?: any;
106
+ footer?: string;
103
107
  isHidden?: boolean;
104
108
  name: string;
105
- onClickCell?: (el: HTMLTableDataCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
106
- onClickHeader?: (el: HTMLTableHeaderCellElement, column?: ITableColumn) => void;
107
- onRenderCell?: (el: HTMLTableDataCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
108
- onRenderHeader?: (el?: HTMLTableDataCellElement, column?: ITableColumn) => void;
109
+ onClickCell?: (el: HTMLTableCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
110
+ onClickFooter?: (el: HTMLTableCellElement, column?: ITableColumn) => void;
111
+ onClickHeader?: (el: HTMLTableCellElement, column?: ITableColumn) => void;
112
+ onRenderCell?: (el: HTMLTableCellElement, column?: ITableColumn, data?: any, rowIdx?: number) => void;
113
+ onRenderFooter?: (el?: HTMLTableCellElement, column?: ITableColumn) => void;
114
+ onRenderHeader?: (el?: HTMLTableCellElement, column?: ITableColumn) => void;
109
115
  scope?: string;
110
116
  title?: string;
111
117
  }