11<script setup lang="ts">
22import type { AssetItem } from " ~/types" ;
33import type { TableColumn } from " @nuxt/ui" ;
4+ import { UCheckbox , UButton } from " #components" ;
45import { h , resolveComponent } from " vue" ;
56
67interface MenuItem {
@@ -160,6 +161,25 @@ function cancelRename() {
160161}
161162
162163const columns: TableColumn <AssetItem >[] = [
164+ {
165+ id: ' select' ,
166+ header : ({ table }) =>
167+ h (UCheckbox , {
168+ modelValue: table .getIsSomePageRowsSelected ()
169+ ? ' indeterminate'
170+ : table .getIsAllPageRowsSelected (),
171+ ' onUpdate:modelValue' : (value : boolean | ' indeterminate' ) =>
172+ table .toggleAllPageRowsSelected (!! value ),
173+ ' aria-label' : ' Select all'
174+ }),
175+ cell : ({ row }) =>
176+ h (UCheckbox , {
177+ modelValue: row .getIsSelected (),
178+ ' onUpdate:modelValue' : (value : boolean | ' indeterminate' ) => row .toggleSelected (!! value ),
179+ ' aria-label' : ' Select row'
180+ }),
181+ meta: { class: { th: " w-[50px]" , td: " w-[50px]" } }
182+ },
163183 {
164184 accessorKey: " assetName" ,
165185 header : () => t (" AssetCard.AssetName" ),
@@ -191,7 +211,7 @@ const columns: TableColumn<AssetItem>[] = [
191211 row .original .name
192212 );
193213 },
194- meta: { class: { th: " w-1/5 " , td: " w-1/5 " } }
214+ meta: { class: { th: " max-w-[300px] " , td: " max-w-[300px] " } }
195215 },
196216 {
197217 accessorKey: " address" ,
@@ -205,7 +225,7 @@ const columns: TableColumn<AssetItem>[] = [
205225 },
206226 row .original .address
207227 ),
208- meta: { class: { th: " w-1/5 " , td: " w-1/5 " } }
228+ meta: { class: { th: " max-w-[300px] " , td: " max-w-[300px] " } }
209229 },
210230 {
211231 id: " user" ,
@@ -221,23 +241,27 @@ const columns: TableColumn<AssetItem>[] = [
221241 userText
222242 );
223243 },
224- meta: { class: { th: " w-1/5 " , td: " w-1/5 " } }
244+ meta: { class: { th: " w-[250px] " , td: " w-[250px] " } }
225245 },
226246 {
227247 id: " protocol" ,
228248 header : () => t (" AssetCard.Protocol" ),
229249 cell : ({ row }) => {
230250 const protocolText = displayProtocol (row .original .id , row .original .permedProtocols ! );
231- return h (
232- " div" ,
233- {
234- class: " truncate" ,
235- title: protocolText
236- },
251+ if (! protocolText || protocolText === " -" ) {
252+ return h (" div" , { class: " truncate" }, " -" );
253+ }
254+ const color = {
255+ paid: ' success' as const ,
256+ failed: ' error' as const ,
257+ refunded: ' neutral' as const
258+ }[row .getValue (' status' ) as string ]
259+
260+ return h (UButton , { size: ' xs' , class: ' rounded-sm' , variant: ' subtle' , color: ' primary' }, () =>
237261 protocolText
238- );
262+ )
239263 },
240- meta: { class: { th: " w-1/5 " , td: " w-1/5 " } }
264+ meta: { class: { th: " w-[150px] " , td: " w-[150px] " } }
241265 },
242266 {
243267 id: " actions" ,
@@ -248,14 +272,15 @@ const columns: TableColumn<AssetItem>[] = [
248272 return h (
249273 UFieldGroup ,
250274 {
251- size: " sm " ,
252- class: " inline-flex rounded-md shadow-sm "
275+ size: " xs " ,
276+ class: " inline-flex rounded-sm text-right "
253277 },
254278 {
255279 default : () => [
256280 h (UButton , {
257281 color: " primary" ,
258282 variant: " outline" ,
283+ class: " rounded-sm" ,
259284 label: t (" Common.Connect" ),
260285 onClick : () => emits (" connectAsset" , row .original )
261286 }),
@@ -275,6 +300,7 @@ const columns: TableColumn<AssetItem>[] = [
275300 icon: " i-lucide-ellipsis" ,
276301 color: " primary" ,
277302 variant: " outline" ,
303+ class: " rounded-sm" ,
278304 " data-table-context-button" : true
279305 })
280306 }
@@ -283,7 +309,7 @@ const columns: TableColumn<AssetItem>[] = [
283309 }
284310 );
285311 },
286- meta: { class: { th: " w-1/5 " , td: " w-1/5 " } }
312+ meta: { class: { th: " w-[260px] text-center " , td: " w-[260px] text-center " } }
287313 }
288314];
289315 </script >
@@ -302,11 +328,11 @@ const columns: TableColumn<AssetItem>[] = [
302328 :data =" props .items "
303329 :columns =" columns "
304330 :empty =" t (' Common.NoData' )"
305- class="w-full table-fixed "
331+ class="w-full table-auto "
306332 :ui =" {
307- tr: ' hover:bg-muted/50' ,
333+ tr: ' hover:bg-muted/50 ' ,
308334 th: ' whitespace-nowrap text-xs sm:text-sm' ,
309- td: ' whitespace-nowrap text-xs sm:text-sm'
335+ td: ' whitespace-nowrap text-xs sm:text-sm py-2 '
310336 } "
311337 ></UTable >
312338 </div >
0 commit comments