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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gd-bs",
3
- "version": "6.6.82",
3
+ "version": "6.6.83",
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) {
@@ -33,8 +35,14 @@ class _Table extends Base<ITableProps> implements ITable {
33
35
  let column = document.createElement("th");
34
36
  row.appendChild(column);
35
37
 
38
+ // See if the footer exists
39
+ if (this.props.columns[i].footer) {
40
+ // Set the flag
41
+ hasFooter = true;
42
+ }
43
+
36
44
  // Render the column
37
- this.renderColumn(i, column, this.props.columns[i]);
45
+ this.renderColumn(column, this.props.columns[i]);
38
46
  }
39
47
 
40
48
  // See if there is an event
@@ -47,10 +55,74 @@ class _Table extends Base<ITableProps> implements ITable {
47
55
 
48
56
  // Add the rows
49
57
  this.addRows(this.props.rows);
58
+
59
+ // See if the footer exists
60
+ if (hasFooter) {
61
+ // Append the footer
62
+ let footer = document.createElement("tfoot");
63
+ this.el.appendChild(footer);
64
+
65
+ // Append the row
66
+ let row = document.createElement("tr");
67
+ footer.appendChild(row);
68
+
69
+ // Parse the columns
70
+ for (let i = 0; i < this.props.columns.length; i++) {
71
+ // Append the column
72
+ let column = document.createElement("td");
73
+ row.appendChild(column);
74
+
75
+ // See if the footer exists
76
+ if (this.props.columns[i].footer) {
77
+ // Set the flag
78
+ hasFooter = true;
79
+ }
80
+
81
+ // Render the column
82
+ this.renderColumnFooter(column, this.props.columns[i]);
83
+ }
84
+ }
85
+ }
86
+
87
+ // Renders a cell
88
+ private renderCell(row: HTMLTableRowElement, props: ITableColumn, data, rowIdx: number) {
89
+ // Create the cell
90
+ let cell = document.createElement("td");
91
+ cell.className = props.className || "";
92
+ cell.innerHTML = data[props.name] == null ? "" : data[props.name];
93
+ row.appendChild(cell);
94
+
95
+ // See if there is a scope
96
+ if (props.scope) {
97
+ // Set the scope
98
+ cell.setAttribute("scope", props.scope);
99
+ }
100
+
101
+ // See if there is an event for this column
102
+ if (props.onRenderCell) {
103
+ // Call the event
104
+ props.onRenderCell(cell, props, data, rowIdx);
105
+ }
106
+
107
+ // See if there is an event for this component
108
+ if (this.props.onRenderCell) {
109
+ // Call the event
110
+ this.props.onRenderCell(cell, props, data, rowIdx);
111
+ }
112
+
113
+ // See if there is a click event
114
+ if (props.onClickCell || this.props.onClickCell) {
115
+ // Add the click event
116
+ cell.addEventListener("click", ev => {
117
+ // Call the event
118
+ props.onClickCell ? props.onClickCell(cell, props, data, rowIdx) : null;
119
+ this.props.onClickCell ? this.props.onClickCell(cell, props, data, rowIdx) : null;
120
+ });
121
+ }
50
122
  }
51
123
 
52
124
  // Renders a column
53
- private renderColumn(colIdx: number, column: HTMLTableCellElement, props: ITableColumn) {
125
+ private renderColumn(column: HTMLTableCellElement, props: ITableColumn) {
54
126
  column.innerHTML = props.isHidden ? "" : props.title || props.name;
55
127
  column.setAttribute("scope", "col");
56
128
 
@@ -77,39 +149,27 @@ class _Table extends Base<ITableProps> implements ITable {
77
149
  }
78
150
  }
79
151
 
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
- }
93
-
152
+ // Renders a column footer
153
+ private renderColumnFooter(column: HTMLTableCellElement, props: ITableColumn) {
94
154
  // See if there is an event for this column
95
- if (props.onRenderCell) {
155
+ if (props.onRenderFooter) {
96
156
  // Call the event
97
- props.onRenderCell(cell, props, data, rowIdx);
157
+ props.onRenderFooter(column, props);
98
158
  }
99
159
 
100
160
  // See if there is an event for this component
101
- if (this.props.onRenderCell) {
161
+ if (this.props.onRenderFooterCell) {
102
162
  // Call the event
103
- this.props.onRenderCell(cell, props, data, rowIdx);
163
+ this.props.onRenderFooterCell(column, props);
104
164
  }
105
165
 
106
166
  // See if there is a click event
107
- if (props.onClickCell || this.props.onClickCell) {
167
+ if (props.onClickFooter || this.props.onClickFooter) {
108
168
  // Add the click event
109
- cell.addEventListener("click", ev => {
169
+ column.addEventListener("click", ev => {
110
170
  // 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;
171
+ props.onClickFooter ? props.onClickFooter(column, props) : null;
172
+ this.props.onClickFooter ? this.props.onClickFooter(column, props) : null;
113
173
  });
114
174
  }
115
175
  }
@@ -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
  }