Skip to content

Commit 69a05dd

Browse files
committed
refactor: update shared props types handling
1 parent e0239fd commit 69a05dd

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

packages/coreui-vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
"vue-types": "^5.1.3"
6363
},
6464
"peerDependencies": {
65-
"vue": "^3.2.21"
65+
"vue": "^3.5.0"
6666
}
6767
}

packages/coreui-vue/src/components/form/CFormControlWrapper.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { CFormFloating } from './CFormFloating'
44
import { CFormLabel } from './CFormLabel'
55
import { CFormText } from './CFormText'
66

7-
type CFormControlValidationProps = InstanceType<typeof CFormControlValidation>['$props']
7+
import type { ComponentProps } from '../../utils/ComponentProps'
88

9-
interface CFormControlWrapperProps {
9+
interface CFormControlWrapperProps extends ComponentProps<typeof CFormControlValidation> {
1010
floatingLabel?: string
1111
id?: string
1212
label?: string
@@ -27,7 +27,9 @@ const CFormControlWrapper = defineComponent({
2727
/**
2828
* @ignore
2929
*/
30-
id: String,
30+
id: {
31+
type: String,
32+
},
3133
/**
3234
* Add a caption for a component.
3335
*
@@ -41,7 +43,7 @@ const CFormControlWrapper = defineComponent({
4143
*/
4244
text: String,
4345
},
44-
setup(props: CFormControlWrapperProps & CFormControlValidationProps, { slots }) {
46+
setup(props: CFormControlWrapperProps, { slots }) {
4547
const formControlValidation = () =>
4648
h(
4749
CFormControlValidation,
@@ -50,7 +52,6 @@ const CFormControlWrapper = defineComponent({
5052
feedback: props.feedback,
5153
feedbackInvalid: props.feedbackInvalid,
5254
feedbackValid: props.feedbackValid,
53-
floatingLabel: props.floatingLabel,
5455
invalid: props.invalid,
5556
tooltipFeedback: props.tooltipFeedback,
5657
valid: props.valid,

packages/coreui-vue/src/components/nav/CNavItem.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { defineComponent, h } from 'vue'
2-
32
import { CNavLink } from './CNavLink'
43

5-
type CNavLinkProps = Omit<InstanceType<typeof CNavLink>['$props'], 'as'>
4+
import type { ComponentProps } from '../../utils/ComponentProps'
65

7-
interface CNavItemProps {
6+
interface CNavItemProps extends ComponentProps<typeof CNavLink> {
87
as: string
98
}
109

@@ -20,7 +19,7 @@ const CNavItem = defineComponent({
2019
default: 'li',
2120
},
2221
},
23-
setup(props: CNavLinkProps & CNavItemProps, { slots }) {
22+
setup(props: CNavItemProps, { slots }) {
2423
return () =>
2524
h(
2625
props.as,

packages/coreui-vue/src/components/toast/CToastClose.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { defineComponent, h, inject, resolveComponent } from 'vue'
22
import { CCloseButton } from '../close-button/CCloseButton'
33

4-
type CCloseButtonProps = InstanceType<typeof CCloseButton>['$props']
4+
import type { ComponentProps } from '../../utils/ComponentProps'
55

6-
interface CToastCloseProps {
7-
as: string
6+
interface CCloseButtonProps extends ComponentProps<typeof CCloseButton> {
7+
as?: string
88
}
99

1010
const CToastClose = defineComponent({
@@ -22,7 +22,7 @@ const CToastClose = defineComponent({
2222
*/
2323
'close',
2424
],
25-
setup(props: CToastCloseProps & CCloseButtonProps, { slots, emit }) {
25+
setup(props: CCloseButtonProps, { slots, emit }) {
2626
// eslint-disable-next-line no-unused-vars
2727
const updateVisible = inject('updateVisible') as (visible: boolean) => void
2828
const handleClose = () => {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { DefineComponent, ExtractPropTypes, ExtractPublicPropTypes } from 'vue'
2+
3+
export type ComponentProps<T> =
4+
T extends DefineComponent<ExtractPropTypes<infer Props>, any, any>
5+
? ExtractPublicPropTypes<Props>
6+
: never

packages/docs/build/docgen.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ module.exports = {
88
components: [
99
'**/[A-Z]*.ts',
1010
'!**/[A-Z]*.d.ts',
11-
'!**/[A-Z]*.spec.ts'
11+
'!**/[A-Z]*.spec.ts',
12+
'!**/ComponentProps.ts',
1213
],
1314
outDir: 'api', // folder to save components docs in (relative to the current working directry)
1415
getDocFileName: (componentPath) =>

0 commit comments

Comments
 (0)