Skip to content

Commit 7be591f

Browse files
committed
fix: Don't use child comp slot if isn't used
related: #180 #181
1 parent 9f88f18 commit 7be591f

File tree

12 files changed

+37
-20
lines changed

12 files changed

+37
-20
lines changed

packages/anu-vue/src/components/card/ACard.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isTypographyUsed } from '@/components/typography/utils'
77
import { type ConfigurableValue, useConfigurable } from '@/composables/useConfigurable'
88
import { useDefaults } from '@/composables/useDefaults'
99
import { useLayer } from '@/composables/useLayer'
10+
import { filterUsedSlots } from '@/utils/vue'
1011
1112
// SECTION Meta
1213
const _props = defineProps(aCardProps)
@@ -77,7 +78,7 @@ else
7778
>
7879
<!-- ℹ️ Recursively pass down slots to child -->
7980
<template
80-
v-for="(_, name) in aCardTypographySlots"
81+
v-for="name in filterUsedSlots(aCardTypographySlots)"
8182
#[name]="slotProps"
8283
>
8384
<slot

packages/anu-vue/src/components/data-table/ADataTable.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useSearch } from '@/composables/useSearch'
1111
import type { typeSortBy } from '@/composables/useSort'
1212
import { useSort } from '@/composables/useSort'
1313
import { objectKeys } from '@/utils/typescripts'
14+
import { filterUsedSlots } from '@/utils/vue'
1415
1516
// TODO: Check usage with useDebounceFn. Can we limit the # of req to server?
1617
@@ -372,8 +373,9 @@ const paginationMeta = computed(() => {
372373

373374
<!-- TODO: If you are using child component props in component => Filter them out -->
374375
<!-- ℹ️ Recursively pass down slots to child -->
376+
<!-- TODO: (types) Don't use type assertion -->
375377
<template
376-
v-for="(_, name) in _aDataTableTableSlots"
378+
v-for="name in filterUsedSlots(_aDataTableTableSlots as any)"
377379
#[name]="slotProps"
378380
>
379381
<slot

packages/anu-vue/src/components/dialog/ADialog.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ACard } from '@/components/card'
66
import { useDOMScrollLock } from '@/composables/useDOMScrollLock'
77
import { useDefaults } from '@/composables/useDefaults'
88
import { useTeleport } from '@/composables/useTeleport'
9+
import { filterUsedSlots } from '@/utils/vue'
910
1011
// SECTION Meta
1112
const _props = defineProps(aDialogProps)
@@ -56,7 +57,7 @@ useDOMScrollLock(toRef(props, 'modelValue') as Ref<boolean>)
5657
>
5758
<!-- ℹ️ Recursively pass down slots to child -->
5859
<template
59-
v-for="(_, name) in aDialogSlots"
60+
v-for="name in filterUsedSlots(aDialogSlots)"
6061
#[name]="slotProps"
6162
>
6263
<slot

packages/anu-vue/src/components/drawer/ADrawer.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ACard } from '@/components/card'
66
import { useDOMScrollLock } from '@/composables/useDOMScrollLock'
77
import { useDefaults } from '@/composables/useDefaults'
88
import { useTeleport } from '@/composables/useTeleport'
9+
import { filterUsedSlots } from '@/utils/vue'
910
1011
// SECTION Meta
1112
const _props = defineProps(aDrawerProps)
@@ -92,7 +93,7 @@ useDOMScrollLock(toRef(props, 'modelValue') as Ref<boolean>)
9293
>
9394
<!-- ℹ️ Recursively pass down slots to child -->
9495
<template
95-
v-for="(_, name) in aDrawerSlots"
96+
v-for="name in filterUsedSlots(aDrawerSlots)"
9697
#[name]="slotProps"
9798
>
9899
<slot

packages/anu-vue/src/components/input/AInput.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { AInputEvents } from './meta'
33
import { aInputProps, aTextareaBaseInputSlots } from './meta'
44
import { ABaseInput, aBaseInputProps } from '@/components/base-input'
55
import { useDefaults } from '@/composables/useDefaults'
6+
import { filterUsedSlots } from '@/utils/vue'
67
78
// SECTION Meta
89
const _props = defineProps(aInputProps)
@@ -39,7 +40,7 @@ function handleInputWrapperClick() {
3940
>
4041
<!-- ℹ️ Recursively pass down slots to child -->
4142
<template
42-
v-for="(_, name) in aTextareaBaseInputSlots"
43+
v-for="name in filterUsedSlots(aTextareaBaseInputSlots)"
4344
#[name]="slotProps"
4445
>
4546
<slot

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { aListListItemSlotsWithPrefixMeta, aListProps } from './meta'
44
import { AListItem } from '@/components/list-item'
55
import { useDefaults } from '@/composables/useDefaults'
66
import { calculateSelectionItems, extractItemValueFromItemOption, useSelection } from '@/composables/useSelection'
7+
import { filterUsedRenamedSlots } from '@/utils/vue'
78
89
// SECTION Meta
910
const _props = defineProps(aListProps)
@@ -73,7 +74,7 @@ function handleListItemClick(item: AListPropItems[number]) {
7374
>
7475
<!-- ℹ️ Recursively pass down slots to child -->
7576
<template
76-
v-for="{ originalKey: originalSlotName, prefixedKey: updatedSlotName } in aListListItemSlotsWithPrefixMeta"
77+
v-for="{ originalKey: originalSlotName, prefixedKey: updatedSlotName } in filterUsedRenamedSlots(aListListItemSlotsWithPrefixMeta)"
7778
#[originalSlotName]="slotProps"
7879
>
7980
<slot

packages/anu-vue/src/components/loader/ALoader.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { isTypographyUsed } from '@/components/typography/utils'
77
import { type ConfigurableValue, useConfigurable } from '@/composables/useConfigurable'
88
import { useDOMScrollLock } from '@/composables/useDOMScrollLock'
99
import { useDefaults } from '@/composables/useDefaults'
10+
import { filterUsedSlots } from '@/utils/vue'
1011
1112
// SECTION Meta
1213
const _props = defineProps(aLoaderProps)
@@ -74,7 +75,7 @@ if (props.fullPage) {
7475
>
7576
<!-- ℹ️ Recursively pass down slots to child -->
7677
<template
77-
v-for="(_, name) in aLoaderTypographySlots"
78+
v-for="name in filterUsedSlots(aLoaderTypographySlots)"
7879
#[name]="slotProps"
7980
>
8081
<slot

packages/anu-vue/src/components/select/ASelect.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { AFloating, sameWidthFloatingUIMiddleware } from '@/components/floating'
88
import type { AListPropItems } from '@/components/list'
99
import { useDefaults } from '@/composables/useDefaults'
1010
import { extractItemValueFromItemOption } from '@/composables/useSelection'
11-
import { filterUsedSlots } from '@/utils/reactivity'
11+
import { filterUsedRenamedSlots, filterUsedSlots } from '@/utils/vue'
1212
1313
// SECTION Meta
1414
export interface ObjectOption { label: string; value: string | number }
@@ -102,7 +102,7 @@ function middleware() {
102102
>
103103
<!-- ℹ️ Recursively pass down slots to child -->
104104
<template
105-
v-for="(_, name) in aSelectBaseInputSlots"
105+
v-for="name in filterUsedSlots(aSelectBaseInputSlots)"
106106
#[name]="slotProps"
107107
>
108108
<slot
@@ -154,7 +154,7 @@ function middleware() {
154154
>
155155
<!-- ℹ️ Recursively pass down slots to child -->
156156
<template
157-
v-for="{ originalKey: originalSlotName, prefixedKey: updatedSlotName } in aSelectListSlotsWithPrefixMeta"
157+
v-for="{ originalKey: originalSlotName, prefixedKey: updatedSlotName } in filterUsedRenamedSlots(aSelectListSlotsWithPrefixMeta)"
158158
#[originalSlotName]="slotProps"
159159
>
160160
<slot

packages/anu-vue/src/components/table/ATable.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ACardProps } from '@/components/card'
55
import { aCardProps } from '@/components/card'
66
import { useDefaults } from '@/composables/useDefaults'
77
import { objectKeys } from '@/utils/typescripts'
8+
import { filterUsedSlots } from '@/utils/vue'
89
910
// SECTION Meta
1011
const _props = defineProps(aTableProps<Row>())
@@ -121,7 +122,7 @@ const _cols = computed<ATablePropColumn<Row>[]>(() => {
121122

122123
<!-- ℹ️ Recursively pass down slots to child -->
123124
<template
124-
v-for="(_, name) in aTableCardSlots"
125+
v-for="name in filterUsedSlots(aTableCardSlots)"
125126
#[name]="slotProps"
126127
>
127128
<slot

packages/anu-vue/src/components/textarea/ATextarea.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ATextareaEvents, aTextareaSlots } from './meta'
33
import { aTextareaBaseInputSlots, aTextareaProps } from './meta'
44
import { ABaseInput, aBaseInputProps } from '@/components/base-input'
55
import { useDefaults } from '@/composables/useDefaults'
6+
import { filterUsedSlots } from '@/utils/vue'
67
78
// SECTION Meta
89
const _props = defineProps(aTextareaProps)
@@ -55,7 +56,7 @@ if (props.autoSize) {
5556
>
5657
<!-- ℹ️ Recursively pass down slots to child -->
5758
<template
58-
v-for="(_, name) in aTextareaBaseInputSlots"
59+
v-for="name in filterUsedSlots(aTextareaBaseInputSlots)"
5960
#[name]="slotProps"
6061
>
6162
<slot

0 commit comments

Comments
 (0)