Skip to content

Commit 8467c8a

Browse files
committed
refactor: update PropTypes
1 parent c69fcf8 commit 8467c8a

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

src/components/badge/CBadge.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ CBadge.propTypes = {
6868
color: colorPropType,
6969
component: PropTypes.string,
7070
shape: shapePropType,
71+
size: PropTypes.oneOf(['sm']),
7172
textColor: PropTypes.string,
7273
}
7374

src/components/offcanvas/COffcanvas.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import PropTypes from 'prop-types'
12
import React, { forwardRef, HTMLAttributes, useCallback, useEffect, useRef, useState } from 'react'
23
import { createPortal } from 'react-dom'
34
import { Transition } from 'react-transition-group'
@@ -122,3 +123,17 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
122123
)
123124
},
124125
)
126+
127+
COffcanvas.propTypes = {
128+
backdrop: PropTypes.bool,
129+
children: PropTypes.node,
130+
className: PropTypes.string,
131+
keyboard: PropTypes.bool,
132+
onDismiss: PropTypes.func,
133+
placement: PropTypes.oneOf<'start' | 'end' | 'top' | 'bottom'>(['start', 'end', 'top', 'bottom'])
134+
.isRequired,
135+
portal: PropTypes.bool,
136+
visible: PropTypes.bool,
137+
}
138+
139+
COffcanvas.displayName = 'COffcanvas'

src/components/sidebar/CCreateNavItem.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { ElementType, useMemo } from 'react'
1+
import PropTypes from 'prop-types'
2+
import React, { FC, ElementType, useMemo } from 'react'
23
import { CNavGroup } from '../nav/CNavGroup'
34
import { CNavGroupItems } from '../nav/CNavGroupItems'
45
import { CNavItem } from '../nav/CNavItem'
@@ -20,7 +21,8 @@ interface CCreateNavItemProps {
2021
items: Array<object>
2122
}
2223

23-
export const CCreateNavItem: React.FC<CCreateNavItemProps> = ({ items, idx }) => {
24+
export const CCreateNavItem: FC<CCreateNavItemProps> = ({ items, idx }) => {
25+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2426
const renderItem = (item: any, index: number, idx?: string) => {
2527
const { _component, as, anchor, items, ...rest }: CSidebarNavItemGeneratorProps = item
2628
const components = { CNavGroup, CNavGroupItems, CNavItem, CNavLink, CNavTitle }
@@ -47,3 +49,8 @@ export const CCreateNavItem: React.FC<CCreateNavItemProps> = ({ items, idx }) =>
4749

4850
return <React.Fragment>{generatedItems}</React.Fragment>
4951
}
52+
53+
CCreateNavItem.propTypes = {
54+
idx: PropTypes.any,
55+
items: PropTypes.any, // TODO: find better solution
56+
}

src/components/toast/CToaster.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export interface CToasterProps extends HTMLAttributes<HTMLDivElement> {
3131
}
3232

3333
export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
34-
//@ts-expect-error
3534
({ children, className, placement, push, ...rest }, ref) => {
3635
const [toasts, setToasts] = useState<ReactElement[]>([])
3736
const index = useRef<number>(0)
@@ -42,7 +41,7 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
4241
}, [push])
4342

4443
// TODO: remove invisible items
45-
const addToast = (push: any) => {
44+
const addToast = (push: ReactElement) => {
4645
setToasts((state) => [
4746
...state,
4847
React.cloneElement(push, {
@@ -52,8 +51,6 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
5251
])
5352
}
5453

55-
// a.splice(a.findIndex(e => e.name === "tc_001"),1);
56-
5754
const _className = classNames(
5855
'toaster toast-container p-3',
5956
{
@@ -77,15 +74,15 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
7774
) : null
7875
}
7976

80-
return placement
81-
? typeof window !== 'undefined' && createPortal(toaster(ref), document.body)
77+
return typeof window !== 'undefined' && placement
78+
? createPortal(toaster(ref), document.body)
8279
: toaster(ref)
8380
},
8481
)
8582

8683
CToaster.propTypes = {
87-
children: PropTypes.any,
88-
className: PropTypes.any,
84+
children: PropTypes.node,
85+
className: PropTypes.string,
8986
placement: PropTypes.oneOfType([
9087
PropTypes.string,
9188
PropTypes.oneOf([

src/components/widgets/CWidgetProgressIcon.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export interface CWidgetProgressIconProps extends HTMLAttributes<HTMLDivElement>
2828
progressValue?: number
2929
progressWhite?: boolean
3030
title?: string
31-
text?: string
3231
/**
3332
* Sets the text color context of the component to one of CoreUI’s themed colors. [docs]
3433
*
@@ -47,7 +46,6 @@ export const CWidgetProgressIcon = forwardRef<HTMLDivElement, CWidgetProgressIco
4746
progressColor,
4847
progressValue,
4948
progressWhite,
50-
text,
5149
textColor,
5250
title,
5351
value,
@@ -97,7 +95,6 @@ CWidgetProgressIcon.propTypes = {
9795
progressColor: PropTypes.string,
9896
progressValue: PropTypes.number,
9997
progressWhite: PropTypes.bool,
100-
text: PropTypes.string,
10198
textColor: PropTypes.string,
10299
title: PropTypes.string,
103100
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

0 commit comments

Comments
 (0)