98
98
v-bind =" field.tdAttr"
99
99
:class =" getFieldRowClasses(field, item)"
100
100
>
101
+ <label v-if =" stacked && labelStackedBoolean" class =" b-table-stacked-label" >{{
102
+ getFieldHeadLabel(field)
103
+ }}</label >
101
104
<slot
102
105
v-if =" $slots['cell(' + field.key + ')'] || $slots['cell()']"
103
106
:name =" $slots['cell(' + field.key + ')'] ? 'cell(' + field.key + ')' : 'cell()'"
@@ -222,6 +225,8 @@ interface BTableProps {
222
225
responsive? : boolean | ' sm' | ' md' | ' lg' | ' xl' | ' xxl'
223
226
small? : Booleanish
224
227
striped? : Booleanish
228
+ stacked? : boolean | ' sm' | ' md' | ' lg' | ' xl' | ' xxl' // boolean | Breakpoint
229
+ labelStacked? : boolean
225
230
variant? : ColorVariant
226
231
sortBy? : string
227
232
sortDesc? : Booleanish
@@ -254,6 +259,8 @@ const props = withDefaults(defineProps<BTableProps>(), {
254
259
responsive: false ,
255
260
small: false ,
256
261
striped: false ,
262
+ labelStacked: false ,
263
+ stacked: false ,
257
264
sortDesc: false ,
258
265
sortInternal: true ,
259
266
selectable: false ,
@@ -312,11 +319,12 @@ const sortDescBoolean = useBooleanish(toRef(props, 'sortDesc'))
312
319
const sortInternalBoolean = useBooleanish (toRef (props , ' sortInternal' ))
313
320
const selectableBoolean = useBooleanish (toRef (props , ' selectable' ))
314
321
const stickySelectBoolean = useBooleanish (toRef (props , ' stickySelect' ))
322
+ const labelStackedBoolean = useBooleanish (toRef (props , ' labelStacked' ))
315
323
const busyBoolean = useBooleanish (toRef (props , ' busy' ))
316
324
const showEmptyBoolean = useBooleanish (toRef (props , ' showEmpty' ))
317
- const noProviderPagingBoolean = useBooleanish (toRef (props , ' showEmpty ' ))
318
- const noProviderSortingBoolean = useBooleanish (toRef (props , ' showEmpty ' ))
319
- const noProviderFilteringBoolean = useBooleanish (toRef (props , ' showEmpty ' ))
325
+ const noProviderPagingBoolean = useBooleanish (toRef (props , ' noProviderPaging ' ))
326
+ const noProviderSortingBoolean = useBooleanish (toRef (props , ' noProviderSorting ' ))
327
+ const noProviderFilteringBoolean = useBooleanish (toRef (props , ' noProviderFiltering ' ))
320
328
321
329
const internalBusyFlag = ref (busyBoolean .value )
322
330
itemHelper .filterEvent .value = async (items ) => {
@@ -351,6 +359,7 @@ const containerAttrs = computed(() => ({
351
359
hover: props .hover ,
352
360
responsive: props .responsive ,
353
361
striped: props .striped ,
362
+ stacked: props .stacked ,
354
363
small: props .small ,
355
364
tableClass: tableClasses .value ,
356
365
tableVariant: props .variant ,
@@ -376,14 +385,21 @@ const isSortable = computed(
376
385
377
386
const requireItemsMapping = computed (() => isSortable .value && sortInternalBoolean .value === true )
378
387
const computedItems = computed (() => {
379
- if (usesProvider .value ) return itemHelper .internalItems .value
380
- return requireItemsMapping .value
388
+ const items = usesProvider .value
389
+ ? itemHelper .internalItems .value
390
+ : requireItemsMapping .value
381
391
? itemHelper .mapItems (props .fields , props .items , props , {
382
392
isSortable ,
383
393
isFilterableTable ,
384
394
sortDescBoolean ,
385
395
})
386
396
: props .items
397
+
398
+ if (props .perPage !== undefined ) {
399
+ const startIndex = (props .currentPage - 1 ) * props .perPage
400
+ return items .splice (startIndex , props .perPage )
401
+ }
402
+ return items
387
403
})
388
404
389
405
const getFieldHeadLabel = (field : TableField ) => {
@@ -589,6 +605,7 @@ const providerPropsWatch = async (prop: string, val: any, oldVal: any) => {
589
605
590
606
// stop provide when paging
591
607
const inNoProvider = (key : NoProviderTypes ) => props .noProvider && props .noProvider .includes (key )
608
+ const notifyFiltered = ! [' currentPage' , ' perPage' ].includes (prop )
592
609
const noProvideWhenPaging =
593
610
[' currentPage' , ' perPage' ].includes (prop ) &&
594
611
(inNoProvider (' paging' ) || noProviderPagingBoolean .value === true )
@@ -604,6 +621,8 @@ const providerPropsWatch = async (prop: string, val: any, oldVal: any) => {
604
621
}
605
622
606
623
await callItemsProvider ()
624
+
625
+ if (notifyFiltered ) itemHelper .notifyFilteredItems ()
607
626
}
608
627
609
628
watch (
0 commit comments