Skip to content

Commit

Permalink
feat: add component to tag prop types
Browse files Browse the repository at this point in the history
* Update tag prop types

* Fix type
  • Loading branch information
jonathanjameswatson committed Jun 18, 2023
1 parent 1dc1f2d commit 7c62f2b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
</template>

<script lang="ts">
import type { Component, PropType } from 'vue'
import { defineComponent } from 'vue'
import Input from '../input/Input.vue'
Expand Down Expand Up @@ -208,7 +209,7 @@ export default defineComponent({
* Menu tag name
*/
menuTag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: () => {
return getValueByPath(getOptions(), 'autocomplete.menuTag', 'div')
}
Expand All @@ -217,7 +218,7 @@ export default defineComponent({
* Menu item tag name
*/
itemTag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: () => {
return getValueByPath(getOptions(), 'autocomplete.itemTag', 'div')
}
Expand Down
3 changes: 2 additions & 1 deletion packages/oruga-next/src/components/button/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</template>

<script lang="ts">
import type { Component, PropType } from 'vue'
import { defineComponent } from 'vue'
import Icon from '../icon/Icon.vue'
Expand Down Expand Up @@ -121,7 +122,7 @@ export default defineComponent({
* @values button, a, input, router-link, nuxt-link (or other nuxt alias)
*/
tag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: 'button'
},
/**
Expand Down
3 changes: 2 additions & 1 deletion packages/oruga-next/src/components/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
</template>

<script lang="ts">
import type { Component, PropType } from 'vue'
import { defineComponent } from 'vue'
import BaseComponentMixin from '../../utils/BaseComponentMixin'
Expand Down Expand Up @@ -190,7 +191,7 @@ export default defineComponent({
* Dropdown menu tag name
*/
menuTag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: () => {
return getValueByPath(getOptions(), 'dropdown.menuTag', 'div')
}
Expand Down
3 changes: 2 additions & 1 deletion packages/oruga-next/src/components/dropdown/DropdownItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</template>

<script lang="ts">
import type { Component, PropType } from 'vue'
import { defineComponent } from 'vue'
import BaseComponentMixin from '../../utils/BaseComponentMixin'
Expand Down Expand Up @@ -48,7 +49,7 @@ export default defineComponent({
* Dropdown item tag name
*/
tag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: () => {
return getValueByPath(getOptions(), 'dropdown.itemTag', 'div')
}
Expand Down
3 changes: 2 additions & 1 deletion packages/oruga-next/src/components/menu/MenuItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

<script lang="ts">
import BaseComponentMixin from '../../utils/BaseComponentMixin';
import type { Component, PropType } from 'vue'
import {defineComponent} from "vue";
export default defineComponent({
Expand All @@ -58,7 +59,7 @@ export default defineComponent({
default: 'slide'
},
tag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: 'a'
},
ariaRole: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</template>

<script lang="ts">
import type { Component, PropType } from 'vue'
import { defineComponent } from 'vue'
import { getOptions } from '../../utils/config'
import { getValueByPath } from '../../utils/helpers'
Expand All @@ -28,9 +29,14 @@ export default defineComponent({
required: true
},
tag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: 'a',
validator: (value) => getValueByPath(getOptions(), 'linkTags', ['a', 'button', 'input', 'router-link', 'nuxt-link']).indexOf(value) >= 0
validator: (value) => {
if (typeof value === 'string') {
return getValueByPath(getOptions(), 'linkTags', ['a', 'button', 'input', 'router-link', 'nuxt-link']).indexOf(value) >= 0
}
return true
}
},
disabled: {
type: Boolean,
Expand Down
3 changes: 2 additions & 1 deletion packages/oruga-next/src/components/tabs/TabItem.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import type { Component, PropType } from 'vue'
import { defineComponent } from 'vue'
import BaseComponentMixin from '../../utils/BaseComponentMixin'
Expand All @@ -21,7 +22,7 @@ export default defineComponent({
* Tabs item tag name
*/
tag: {
type: String,
type: [String, Object, Function] as PropType<string | Component>,
default: () => {
return getValueByPath(getOptions(), 'tabs.itemTag', 'button')
}
Expand Down
6 changes: 3 additions & 3 deletions packages/oruga-next/src/utils/SlotComponent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DefineComponent } from 'vue';
import type { Component, DefineComponent, PropType } from 'vue';
import { defineComponent, h } from 'vue';

export default defineComponent({
Expand All @@ -16,8 +16,8 @@ export default defineComponent({
type: Object
},
tag: {
type: String,
default: 'div'
type: [String, Object, Function] as PropType<string | Component>,
default: 'div'
}
},
render() {
Expand Down

0 comments on commit 7c62f2b

Please sign in to comment.