Skip to content

Commit eec949f

Browse files
committed
fix(list): list item slots wasn't passed due to slot name prefix
1 parent e340271 commit eec949f

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

packages/anu-vue/src/components/list/AList.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ExtractPropTypes } from 'vue'
33
import type { ListPropItems } from './props'
44
import { listProps } from './props'
55
import type { listSlots } from './slots'
6-
import { listItemSlot } from './slots'
6+
import { listItemSlots } from './slots'
77
import { isObject } from '@/utils/helpers'
88
import { useGroupModel } from '@/composables'
99
import { AListItem } from '@/components/list-item'
@@ -70,12 +70,11 @@ const handleListItemClick = (item: ListPropItems[number]) => {
7070
>
7171
<!-- ℹ️ Recursively pass down slots to child -->
7272
<template
73-
v-for="name in Object.keys(listItemSlot)"
74-
#[name]="slotProps"
73+
v-for="{ originalKey: originalSlotName, prefixedKey: updatedSlotName } in listItemSlots"
74+
#[originalSlotName]="slotProps"
7575
>
76-
<!-- ℹ️ v-if condition will omit passing slots. Here, we don't want to pass default slot. -->
7776
<slot
78-
:name="name"
77+
:name="updatedSlotName"
7978
:index="index"
8079
v-bind="slotProps || {}"
8180
/>
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ListPropItems } from './props'
2-
import { listItemSlots } from '@/components/list-item/slots'
2+
import { listItemSlots as listItemComponentSlots } from '@/components/list-item/slots'
3+
import { prefixObjectKeys } from '@/utils/helpers'
34

45
export const listOwnSlots = {
56
before: {},
@@ -9,22 +10,25 @@ export const listOwnSlots = {
910
after: {},
1011
} as const
1112

12-
export const listItemSlot = {
13-
'item-prepend': {
14-
item: listItemSlots.prepend.item,
15-
index: Number(),
16-
},
17-
'item-item': {
18-
item: listItemSlots.item.item,
19-
index: Number(),
20-
},
21-
'item-append': {
22-
item: listItemSlots.append.item,
23-
index: Number(),
24-
},
25-
} as const
13+
// export const listItemSlots = {
14+
// 'item-prepend': {
15+
// item: listItemComponentSlots.prepend.item,
16+
// index: Number(),
17+
// },
18+
// 'item-item': {
19+
// item: listItemComponentSlots.item.item,
20+
// index: Number(),
21+
// },
22+
// 'item-append': {
23+
// item: listItemComponentSlots.append.item,
24+
// index: Number(),
25+
// },
26+
// } as const
27+
28+
const { 'item-default': _, ...listItemSlots } = prefixObjectKeys(listItemComponentSlots, 'item-')
29+
export { listItemSlots }
2630

2731
export const listSlots = {
28-
...listItemSlot,
32+
...listItemSlots,
2933
...listOwnSlots,
3034
} as const

0 commit comments

Comments
 (0)