Skip to content

Commit

Permalink
feat(dropdown): allow passing props to component (#308) (#309)
Browse files Browse the repository at this point in the history
close #308
  • Loading branch information
brc-dd committed Jun 21, 2023
1 parent ba28500 commit 6a3f9a1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/components/SDropdownSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ defineProps<{
<SDropdownSectionComponent
v-else-if="section.type === 'component'"
:comp="section.component"
:props="section.props"
/>
</template>
7 changes: 4 additions & 3 deletions lib/components/SDropdownSectionComponent.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script setup lang="ts">
import { type DefineComponent } from 'vue'
import { type Component } from 'vue'
defineProps<{
comp: DefineComponent
comp: Component
props?: Record<string, any>
}>()
</script>

<template>
<Component :is="comp" />
<component :is="comp" v-bind="props" />
</template>
5 changes: 3 additions & 2 deletions lib/composables/Dropdown.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type MaybeRef, useElementBounding, useWindowSize } from '@vueuse/core'
import { type Ref } from 'vue'
import { type Component, type Ref } from 'vue'
import { ref, unref } from 'vue'

export type DropdownSection =
Expand Down Expand Up @@ -74,7 +74,8 @@ export interface DropdownSectionActionsOption {

export interface DropdownSectionComponent extends DropdownSectionBase {
type: 'component'
component: any
component: Component
props?: Record<string, any>
}

export interface ManualDropdownPosition {
Expand Down

0 comments on commit 6a3f9a1

Please sign in to comment.