|
32 | 32 | <slot name="overTable"/> |
33 | 33 | <div :class="notResponsive ? '' : 'table-responsive'" class="position-relative"> |
34 | 34 | <table :class="tableClasses"> |
35 | | - <thead > |
| 35 | + <thead :class="headVariant ? `thead-${headVariant}` : ''"> |
36 | 36 | <tr> |
37 | 37 | <th v-if="indexCol" style="width:40px"></th> |
38 | 38 | <template v-for="(name, index) in columnNames"> |
39 | 39 | <th @click="changeSort(rawColumnNames[index], index)" |
40 | 40 | :class="headerClass(index)" |
41 | 41 | :style="headerStyles(index)" |
42 | 42 | > |
43 | | - <slot :name="`${rawColumnNames[index]}-header`"> |
44 | | - {{name}} |
45 | | - </slot> |
46 | | - <slot v-if="!noSorting && sortable(index)" name="sorting-icon" :state="getIconState(index)"> |
47 | | - <i :class="iconClasses(index)"></i> |
48 | | - </slot> |
| 43 | + <slot v-if="$slots[`${rawColumnNames[index]}-header`]" |
| 44 | + :name="`${rawColumnNames[index]}-header`" |
| 45 | + > |
| 46 | + </slot> |
| 47 | + <div v-else v-html="name" class="d-inline"></div> |
| 48 | + <slot v-if="!noSorting && sortable(index)" name="sorting-icon" :state="getIconState(index)"> |
| 49 | + <i :class="iconClasses(index)"></i> |
| 50 | + </slot> |
49 | 51 | </th> |
50 | 52 | </template> |
51 | 53 | </tr> |
@@ -198,15 +200,19 @@ export default { |
198 | 200 | }, |
199 | 201 | defaultTableFilter: String, |
200 | 202 | defaultColumnFilter: Object, |
201 | | - loading: Boolean |
| 203 | + loading: Boolean, |
| 204 | + headVariant: { |
| 205 | + type: String, |
| 206 | + validator: val => ['light', 'dark'].includes(val) |
| 207 | + } |
202 | 208 | }, |
203 | 209 | data () { |
204 | 210 | return { |
205 | 211 | tableFilter: this.defaultTableFilter, |
206 | 212 | columnFilter: this.defaultColumnFilter || {}, |
207 | 213 | sorter: { name: this.defaultSorter.name, direction: this.defaultSorter.direction }, |
208 | 214 | firstItemIndex: 0, |
209 | | - page: this.activePage || 2, |
| 215 | + page: this.activePage || 1, |
210 | 216 | pages: 0, |
211 | 217 | perPageItems: this.perPage, |
212 | 218 | passedItems: this.items |
@@ -235,8 +241,12 @@ export default { |
235 | 241 | const n = this.sorter.name |
236 | 242 | return this.tableFiltered.sort((a,b) => { |
237 | 243 | //escape html |
238 | | - const c = a[n] ? a[n].replace(/<(?:.|\n)*?>/gm, '') : '' |
239 | | - const d = b[n] ? b[n].replace(/<(?:.|\n)*?>/gm, '') : '' |
| 244 | + let c = typeof a[n] === 'string' ? a[n].replace(/<(?:.|\n)*?>/gm, '') : a[n] |
| 245 | + let d = typeof b[n] === 'string' ? b[n].replace(/<(?:.|\n)*?>/gm, '') : b[n] |
| 246 | + if (typeof c !== typeof d) { |
| 247 | + c = String(c) |
| 248 | + d = String(d) |
| 249 | + } |
240 | 250 | return (c > d) ? 1 * flip : ((d > c) ? -1 * flip : 0) |
241 | 251 | }) |
242 | 252 | }, |
|
0 commit comments