Skip to content

Commit 9cd3e06

Browse files
committed
fix(table): fix modelValue
1 parent 7ec606f commit 9cd3e06

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/components/table/UTable.vue

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type { DeepPartial } from '~/types'
88
interface Sort { column?: string; direction?: 'asc' | 'desc' }
99
1010
const props = withDefaults(defineProps<{
11-
modelValue?: any[]
1211
sortBy?: string | ((a: unknown, b: unknown) => void)
1312
rows?: { [key: string]: any }[]
1413
columns?: { key: string; sortable?: boolean; class?: string; [key: string]: any }[]
@@ -30,7 +29,7 @@ const props = withDefaults(defineProps<{
3029
emptyState: () => useAppUi().table.default.emptyState,
3130
ui: () => useAppUi().table,
3231
})
33-
const selected = defineModel<any[]>({ default: [] })
32+
const selected = defineModel<any[]>()
3433
3534
const sort = ref<Sort>(merge({}, { column: null, direction: 'asc' }, props.sort))
3635
@@ -70,7 +69,7 @@ function onSort(column: { key: string; direction?: 'asc' | 'desc' }) {
7069
<table :class="[config.base, config.divide]">
7170
<thead :class="config.thead">
7271
<tr :class="config.tr.base">
73-
<th v-if="modelValue" scope="col" class="pl-4">
72+
<th v-if="selected" scope="col" class="pl-4">
7473
<UCheckbox :is-checked="isIndeterminate || selected?.length === rows.length" :is-indeterminate="isIndeterminate" @change="selected = $event.target.checked ? rows : []" />
7574
</th>
7675
<th v-for="(column, index) in columns" :key="index" scope="col" :class="[config.th.base, config.th.padding, config.th.color, config.th.font, config.th.size, column.class]">
@@ -95,7 +94,7 @@ function onSort(column: { key: string; direction?: 'asc' | 'desc' }) {
9594
</thead>
9695
<tbody :class="config.tbody">
9796
<tr v-for="(row, index) in rows" :key="index" :class="[config.tr.base, isSelected(row) && config.tr.selected]">
98-
<td v-if="modelValue" class="pl-4">
97+
<td v-if="selected" class="pl-4">
9998
<UCheckbox v-model="selected" :value="row" />
10099
</td>
101100
<td v-for="(column, subIndex) in columns" :key="subIndex" :class="[config.td.base, config.td.padding, config.td.color, config.td.font, config.td.size]">

0 commit comments

Comments
 (0)