@coreui/react-pro 4.9.0-next.1 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/conditional-portal/CConditionalPortal.d.ts +12 -0
- package/dist/components/conditional-portal/index.d.ts +2 -0
- package/dist/components/form/CFormCheck.d.ts +7 -1
- package/dist/components/form/CFormSwitch.d.ts +6 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/table/CTableResponsiveWrapper.d.ts +0 -1
- package/dist/index.es.js +498 -720
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +497 -718
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
- package/src/components/accordion/CAccordion.tsx +7 -3
- package/src/components/accordion/CAccordionBody.tsx +1 -2
- package/src/components/accordion/CAccordionButton.tsx +1 -3
- package/src/components/accordion/CAccordionHeader.tsx +1 -3
- package/src/components/accordion/CAccordionItem.tsx +2 -4
- package/src/components/accordion/__tests__/__snapshots__/CAccordionBody.spec.tsx.snap +2 -2
- package/src/components/alert/CAlert.tsx +19 -27
- package/src/components/alert/CAlertHeading.tsx +1 -3
- package/src/components/alert/CAlertLink.tsx +1 -3
- package/src/components/alert/__tests__/__snapshots__/CAlert.spec.tsx.snap +1 -1
- package/src/components/avatar/CAvatar.tsx +14 -11
- package/src/components/backdrop/CBackdrop.tsx +9 -12
- package/src/components/badge/CBadge.tsx +19 -17
- package/src/components/breadcrumb/CBreadcrumb.tsx +1 -2
- package/src/components/breadcrumb/CBreadcrumbItem.tsx +12 -8
- package/src/components/button/CButton.tsx +7 -9
- package/src/components/button-group/CButtonGroup.tsx +9 -7
- package/src/components/button-group/CButtonToolbar.tsx +1 -3
- package/src/components/calendar/utils.ts +7 -9
- package/src/components/callout/CCallout.tsx +11 -9
- package/src/components/card/CCard.tsx +12 -10
- package/src/components/card/CCardBody.tsx +1 -3
- package/src/components/card/CCardFooter.tsx +1 -3
- package/src/components/card/CCardGroup.tsx +1 -3
- package/src/components/card/CCardHeader.tsx +1 -3
- package/src/components/card/CCardImage.tsx +5 -3
- package/src/components/card/CCardImageOverlay.tsx +1 -3
- package/src/components/card/CCardLink.tsx +1 -3
- package/src/components/card/CCardSubtitle.tsx +1 -3
- package/src/components/card/CCardText.tsx +1 -3
- package/src/components/card/CCardTitle.tsx +1 -3
- package/src/components/carousel/CCarousel.tsx +8 -8
- package/src/components/carousel/CCarouselCaption.tsx +1 -3
- package/src/components/carousel/CCarouselItem.tsx +11 -9
- package/src/components/close-button/CCloseButton.tsx +9 -10
- package/src/components/collapse/CCollapse.tsx +8 -20
- package/src/components/collapse/__tests__/CCollapse.spec.tsx +2 -3
- package/src/components/conditional-portal/CConditionalPortal.tsx +29 -0
- package/src/components/conditional-portal/index.ts +3 -0
- package/src/components/date-range-picker/CDateRangePicker.tsx +9 -11
- package/src/components/date-range-picker/utils.ts +2 -2
- package/src/components/dropdown/CDropdown.tsx +24 -22
- package/src/components/dropdown/CDropdownDivider.tsx +1 -3
- package/src/components/dropdown/CDropdownHeader.tsx +1 -3
- package/src/components/dropdown/CDropdownItem.tsx +6 -3
- package/src/components/dropdown/CDropdownItemPlain.tsx +1 -3
- package/src/components/dropdown/CDropdownMenu.tsx +27 -31
- package/src/components/dropdown/CDropdownToggle.tsx +29 -23
- package/src/components/dropdown/__tests__/CDropdown.spec.tsx +2 -4
- package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
- package/src/components/footer/CFooter.tsx +5 -3
- package/src/components/form/CForm.tsx +5 -2
- package/src/components/form/CFormCheck.tsx +87 -63
- package/src/components/form/CFormControlWrapper.tsx +3 -3
- package/src/components/form/CFormFeedback.tsx +11 -8
- package/src/components/form/CFormFloating.tsx +1 -2
- package/src/components/form/CFormInput.tsx +10 -12
- package/src/components/form/CFormLabel.tsx +1 -2
- package/src/components/form/CFormRange.tsx +1 -2
- package/src/components/form/CFormSelect.tsx +15 -10
- package/src/components/form/CFormSwitch.tsx +31 -20
- package/src/components/form/CFormText.tsx +1 -2
- package/src/components/form/CFormTextarea.tsx +13 -9
- package/src/components/form/CInputGroup.tsx +11 -8
- package/src/components/form/CInputGroupText.tsx +1 -2
- package/src/components/form/__tests__/CFormRange.spec.tsx +1 -1
- package/src/components/form/__tests__/__snapshots__/CForm.spec.tsx.snap +2 -6
- package/src/components/form/__tests__/__snapshots__/CFormRange.spec.tsx.snap +2 -2
- package/src/components/grid/CCol.tsx +8 -6
- package/src/components/grid/CContainer.tsx +8 -6
- package/src/components/grid/CRow.tsx +4 -3
- package/src/components/header/CHeader.tsx +12 -13
- package/src/components/header/CHeaderBrand.tsx +1 -3
- package/src/components/header/CHeaderBrand.tsx~HEAD +1 -3
- package/src/components/header/CHeaderDivider.tsx +1 -3
- package/src/components/header/CHeaderNav.tsx +6 -3
- package/src/components/header/CHeaderText.tsx +1 -3
- package/src/components/header/CHeaderToggler.tsx +2 -4
- package/src/components/image/CImage.tsx +17 -10
- package/src/components/image/__tests__/__snapshots__/CImage.spec.tsx.snap +1 -3
- package/src/components/index.ts +1 -0
- package/src/components/link/CLink.tsx +2 -4
- package/src/components/list-group/CListGroup.tsx +11 -10
- package/src/components/list-group/CListGroupItem.tsx +13 -12
- package/src/components/loading-button/CLoadingButton.tsx +1 -3
- package/src/components/modal/CModal.tsx +55 -70
- package/src/components/modal/CModalBody.tsx +1 -3
- package/src/components/modal/CModalContent.tsx +1 -3
- package/src/components/modal/CModalDialog.tsx +16 -14
- package/src/components/modal/CModalFooter.tsx +1 -3
- package/src/components/modal/CModalHeader.tsx +1 -2
- package/src/components/modal/CModalTitle.tsx +1 -3
- package/src/components/modal/__tests__/CModal.spec.tsx +19 -20
- package/src/components/multi-select/CMultiSelect.tsx +19 -19
- package/src/components/multi-select/utils.ts +3 -3
- package/src/components/nav/CNav.tsx +13 -10
- package/src/components/nav/CNavGroup.tsx +1 -3
- package/src/components/nav/CNavGroupItems.tsx +1 -2
- package/src/components/nav/CNavItem.tsx +8 -10
- package/src/components/nav/CNavLink.tsx +1 -2
- package/src/components/nav/CNavTitle.tsx +1 -2
- package/src/components/navbar/CNavbar.tsx +21 -22
- package/src/components/navbar/CNavbarBrand.tsx +2 -3
- package/src/components/navbar/CNavbarNav.tsx +6 -3
- package/src/components/navbar/CNavbarText.tsx +1 -3
- package/src/components/navbar/CNavbarToggler.tsx +2 -4
- package/src/components/offcanvas/COffcanvas.tsx +39 -66
- package/src/components/offcanvas/COffcanvasBody.tsx +1 -3
- package/src/components/offcanvas/COffcanvasHeader.tsx +1 -3
- package/src/components/offcanvas/COffcanvasTitle.tsx +1 -3
- package/src/components/offcanvas/__tests__/COffcanvas.spec.tsx +7 -2
- package/src/components/offcanvas/__tests__/__snapshots__/COffcanvas.spec.tsx.snap +9 -4
- package/src/components/pagination/CPagination.tsx +12 -9
- package/src/components/pagination/CPaginationItem.tsx +12 -11
- package/src/components/pagination/__tests__/CPagination.spec.tsx +3 -3
- package/src/components/pagination/__tests__/CPaginationItem.spec.tsx +3 -3
- package/src/components/picker/CPicker.tsx +6 -6
- package/src/components/placeholder/CPlaceholder.tsx +13 -11
- package/src/components/popover/CPopover.tsx +22 -33
- package/src/components/progress/CProgress.tsx +12 -10
- package/src/components/progress/CProgressBar.tsx +9 -11
- package/src/components/sidebar/CSidebar.tsx +20 -18
- package/src/components/sidebar/CSidebarBrand.tsx +1 -2
- package/src/components/sidebar/CSidebarFooter.tsx +1 -2
- package/src/components/sidebar/CSidebarHeader.tsx +1 -2
- package/src/components/sidebar/CSidebarNav.tsx +2 -2
- package/src/components/sidebar/CSidebarToggler.tsx +1 -2
- package/src/components/smart-pagination/CSmartPagination.tsx +22 -20
- package/src/components/smart-table/CSmartTable.tsx +4 -8
- package/src/components/smart-table/utils.ts +3 -4
- package/src/components/spinner/CSpinner.tsx +11 -8
- package/src/components/table/CTable.tsx +20 -18
- package/src/components/table/CTableBody.tsx +12 -8
- package/src/components/table/CTableDataCell.tsx +14 -10
- package/src/components/table/CTableFoot.tsx +12 -8
- package/src/components/table/CTableHead.tsx +12 -8
- package/src/components/table/CTableHeaderCell.tsx +12 -8
- package/src/components/table/CTableResponsiveWrapper.tsx +2 -3
- package/src/components/table/CTableRow.tsx +14 -10
- package/src/components/table/__tests__/__snapshots__/CTable.spec.tsx.snap +1 -5
- package/src/components/table/utils.ts +2 -7
- package/src/components/tabs/CTabContent.tsx +1 -2
- package/src/components/tabs/CTabPane.tsx +17 -20
- package/src/components/tabs/__tests__/CTabPane.spec.tsx +2 -5
- package/src/components/tabs/__tests__/__snapshots__/CTabPane.spec.tsx.snap +1 -1
- package/src/components/time-picker/CTimePicker.tsx +12 -14
- package/src/components/toast/CToast.tsx +29 -42
- package/src/components/toast/CToastBody.tsx +1 -2
- package/src/components/toast/CToastClose.tsx +3 -1
- package/src/components/toast/CToastHeader.tsx +1 -2
- package/src/components/toast/CToaster.tsx +26 -26
- package/src/components/toast/__tests__/CToast.spec.tsx +2 -1
- package/src/components/toast/__tests__/__snapshots__/CToast.spec.tsx.snap +1 -66
- package/src/components/tooltip/CTooltip.tsx +21 -32
- package/src/components/virtual-scroller/CVirtualScroller.tsx +4 -6
- package/src/components/widgets/CWidgetStatsA.tsx +8 -6
- package/src/components/widgets/CWidgetStatsD.tsx +9 -10
- package/src/components/widgets/CWidgetStatsE.tsx +1 -3
- package/src/components/widgets/CWidgetStatsF.tsx +1 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Option, SelectedOption } from './types'
|
|
2
2
|
|
|
3
3
|
export const filterOptionsList = (search: string, _options: Option[]) => {
|
|
4
|
-
return search.length
|
|
4
|
+
return search.length > 0
|
|
5
5
|
? _options &&
|
|
6
6
|
_options.reduce((acc: Option[], val: Option) => {
|
|
7
7
|
const options =
|
|
@@ -13,9 +13,9 @@ export const filterOptionsList = (search: string, _options: Option[]) => {
|
|
|
13
13
|
|
|
14
14
|
if (
|
|
15
15
|
(val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
|
|
16
|
-
(options && options.length)
|
|
16
|
+
(options && options.length > 0)
|
|
17
17
|
) {
|
|
18
|
-
acc.push(Object.assign({}, val, options && options.length && { options }))
|
|
18
|
+
acc.push(Object.assign({}, val, options && options.length > 0 && { options }))
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
return acc
|
|
@@ -24,17 +24,20 @@ export interface CNavProps
|
|
|
24
24
|
|
|
25
25
|
export const CNav = forwardRef<HTMLDivElement | HTMLUListElement | HTMLOListElement, CNavProps>(
|
|
26
26
|
({ children, className, component: Component = 'ul', layout, variant, ...rest }, ref) => {
|
|
27
|
-
const _className = classNames(
|
|
28
|
-
'nav',
|
|
29
|
-
{
|
|
30
|
-
[`nav-${layout}`]: layout,
|
|
31
|
-
[`nav-${variant}`]: variant,
|
|
32
|
-
},
|
|
33
|
-
className,
|
|
34
|
-
)
|
|
35
|
-
|
|
36
27
|
return (
|
|
37
|
-
<Component
|
|
28
|
+
<Component
|
|
29
|
+
className={classNames(
|
|
30
|
+
'nav',
|
|
31
|
+
{
|
|
32
|
+
[`nav-${layout}`]: layout,
|
|
33
|
+
[`nav-${variant}`]: variant,
|
|
34
|
+
},
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
role="navigation"
|
|
38
|
+
{...rest}
|
|
39
|
+
ref={ref}
|
|
40
|
+
>
|
|
38
41
|
{children}
|
|
39
42
|
</Component>
|
|
40
43
|
)
|
|
@@ -95,10 +95,8 @@ export const CNavGroup = forwardRef<HTMLLIElement, CNavGroupProps>(
|
|
|
95
95
|
exited: { height: height },
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
const _className = classNames('nav-group', { show: _visible }, className)
|
|
99
|
-
|
|
100
98
|
return (
|
|
101
|
-
<li className={
|
|
99
|
+
<li className={classNames('nav-group', { show: _visible }, className)} {...rest} ref={ref}>
|
|
102
100
|
{toggler && (
|
|
103
101
|
<a className="nav-link nav-group-toggle" onClick={(event) => handleTogglerOnCLick(event)}>
|
|
104
102
|
{toggler}
|
|
@@ -11,9 +11,8 @@ export interface CNavGroupItemsProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CNavGroupItems = forwardRef<HTMLUListElement, CNavGroupItemsProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('nav-group-items', className)
|
|
15
14
|
return (
|
|
16
|
-
<ul className={
|
|
15
|
+
<ul className={classNames('nav-group-items', className)} {...rest} ref={ref}>
|
|
17
16
|
{children}
|
|
18
17
|
</ul>
|
|
19
18
|
)
|
|
@@ -6,17 +6,15 @@ import { CNavLink, CNavLinkProps } from './CNavLink'
|
|
|
6
6
|
|
|
7
7
|
export const CNavItem = forwardRef<HTMLLIElement, CNavLinkProps>(
|
|
8
8
|
({ children, className, ...rest }, ref) => {
|
|
9
|
-
const _className = classNames('nav-item', className)
|
|
10
|
-
if (rest.href || rest.to) {
|
|
11
|
-
children = (
|
|
12
|
-
<CNavLink className={className} {...rest}>
|
|
13
|
-
{children}
|
|
14
|
-
</CNavLink>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
9
|
return (
|
|
18
|
-
<li className={
|
|
19
|
-
{
|
|
10
|
+
<li className={classNames('nav-item', className)} ref={ref}>
|
|
11
|
+
{rest.href || rest.to ? (
|
|
12
|
+
<CNavLink className={className} {...rest}>
|
|
13
|
+
{children}
|
|
14
|
+
</CNavLink>
|
|
15
|
+
) : (
|
|
16
|
+
children
|
|
17
|
+
)}
|
|
20
18
|
</li>
|
|
21
19
|
)
|
|
22
20
|
},
|
|
@@ -42,7 +42,6 @@ export const CNavLink = forwardRef<
|
|
|
42
42
|
const forkedRef = useForkedRef(ref, navLinkRef)
|
|
43
43
|
|
|
44
44
|
const { setVisibleGroup } = useContext(CNavContext)
|
|
45
|
-
const _className = classNames('nav-link', className)
|
|
46
45
|
|
|
47
46
|
useEffect(() => {
|
|
48
47
|
rest.active = navLinkRef.current?.classList.contains('active')
|
|
@@ -50,7 +49,7 @@ export const CNavLink = forwardRef<
|
|
|
50
49
|
}, [rest.active, className])
|
|
51
50
|
|
|
52
51
|
return (
|
|
53
|
-
<CLink className={
|
|
52
|
+
<CLink className={classNames('nav-link', className)} {...rest} ref={forkedRef}>
|
|
54
53
|
{children}
|
|
55
54
|
</CLink>
|
|
56
55
|
)
|
|
@@ -11,9 +11,8 @@ export interface CNavTitleProps extends HTMLAttributes<HTMLLIElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CNavTitle = forwardRef<HTMLLIElement, CNavTitleProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('nav-title', className)
|
|
15
14
|
return (
|
|
16
|
-
<li className={
|
|
15
|
+
<li className={classNames('nav-title', className)} {...rest} ref={ref}>
|
|
17
16
|
{children}
|
|
18
17
|
</li>
|
|
19
18
|
)
|
|
@@ -53,29 +53,28 @@ export const CNavbar = forwardRef<HTMLDivElement, CNavbarProps>(
|
|
|
53
53
|
},
|
|
54
54
|
ref,
|
|
55
55
|
) => {
|
|
56
|
-
const _className = classNames(
|
|
57
|
-
'navbar',
|
|
58
|
-
{
|
|
59
|
-
[`bg-${color}`]: color,
|
|
60
|
-
[`navbar-${colorScheme}`]: colorScheme,
|
|
61
|
-
[typeof expand === 'boolean' ? 'navbar-expand' : `navbar-expand-${expand}`]: expand,
|
|
62
|
-
},
|
|
63
|
-
placement,
|
|
64
|
-
className,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
let content
|
|
68
|
-
if (container) {
|
|
69
|
-
content = (
|
|
70
|
-
<div className={`container${container !== true ? '-' + container : ''}`}>{children}</div>
|
|
71
|
-
)
|
|
72
|
-
} else {
|
|
73
|
-
content = children
|
|
74
|
-
}
|
|
75
|
-
|
|
76
56
|
return (
|
|
77
|
-
<Component
|
|
78
|
-
{
|
|
57
|
+
<Component
|
|
58
|
+
className={classNames(
|
|
59
|
+
'navbar',
|
|
60
|
+
{
|
|
61
|
+
[`bg-${color}`]: color,
|
|
62
|
+
[`navbar-${colorScheme}`]: colorScheme,
|
|
63
|
+
[typeof expand === 'boolean' ? 'navbar-expand' : `navbar-expand-${expand}`]: expand,
|
|
64
|
+
},
|
|
65
|
+
placement,
|
|
66
|
+
className,
|
|
67
|
+
)}
|
|
68
|
+
{...rest}
|
|
69
|
+
ref={ref}
|
|
70
|
+
>
|
|
71
|
+
{container ? (
|
|
72
|
+
<div className={typeof container === 'string' ? `container-${container}` : 'container'}>
|
|
73
|
+
{children}
|
|
74
|
+
</div>
|
|
75
|
+
) : (
|
|
76
|
+
<>{children}</>
|
|
77
|
+
)}
|
|
79
78
|
</Component>
|
|
80
79
|
)
|
|
81
80
|
},
|
|
@@ -20,11 +20,10 @@ export interface CNavbarBrandProps extends HTMLAttributes<HTMLAnchorElement | HT
|
|
|
20
20
|
|
|
21
21
|
export const CNavbarBrand = forwardRef<HTMLAnchorElement | HTMLSpanElement, CNavbarBrandProps>(
|
|
22
22
|
({ children, component, className, ...rest }, ref) => {
|
|
23
|
-
const Component = component
|
|
24
|
-
const _className = classNames('navbar-brand', className)
|
|
23
|
+
const Component = component ?? (rest.href ? 'a' : 'span')
|
|
25
24
|
|
|
26
25
|
return (
|
|
27
|
-
<Component className={
|
|
26
|
+
<Component className={classNames('navbar-brand', className)} {...rest} ref={ref}>
|
|
28
27
|
{children}
|
|
29
28
|
</Component>
|
|
30
29
|
)
|
|
@@ -15,10 +15,13 @@ export interface CNavbarNavProps extends HTMLAttributes<HTMLDivElement | HTMLULi
|
|
|
15
15
|
|
|
16
16
|
export const CNavbarNav = forwardRef<HTMLDivElement | HTMLUListElement, CNavbarNavProps>(
|
|
17
17
|
({ children, component: Component = 'ul', className, ...rest }, ref) => {
|
|
18
|
-
const _className = classNames('navbar-nav', className)
|
|
19
|
-
|
|
20
18
|
return (
|
|
21
|
-
<Component
|
|
19
|
+
<Component
|
|
20
|
+
className={classNames('navbar-nav', className)}
|
|
21
|
+
role="navigation"
|
|
22
|
+
{...rest}
|
|
23
|
+
ref={ref}
|
|
24
|
+
>
|
|
22
25
|
{children}
|
|
23
26
|
</Component>
|
|
24
27
|
)
|
|
@@ -11,10 +11,8 @@ export interface CNavbarTextProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CNavbarText = forwardRef<HTMLSpanElement, CNavbarTextProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('navbar-text', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<span className={
|
|
15
|
+
<span className={classNames('navbar-text', className)} {...rest} ref={ref}>
|
|
18
16
|
{children}
|
|
19
17
|
</span>
|
|
20
18
|
)
|
|
@@ -11,11 +11,9 @@ export interface CNavbarTogglerProps extends HTMLAttributes<HTMLButtonElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CNavbarToggler = forwardRef<HTMLButtonElement, CNavbarTogglerProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('navbar-toggler', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<button type="button" className={
|
|
18
|
-
{children
|
|
15
|
+
<button type="button" className={classNames('navbar-toggler', className)} {...rest} ref={ref}>
|
|
16
|
+
{children ?? <span className="navbar-toggler-icon"></span>}
|
|
19
17
|
</button>
|
|
20
18
|
)
|
|
21
19
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { forwardRef, HTMLAttributes,
|
|
2
|
-
import { createPortal } from 'react-dom'
|
|
1
|
+
import React, { forwardRef, HTMLAttributes, useEffect, useRef, useState } from 'react'
|
|
3
2
|
import PropTypes from 'prop-types'
|
|
4
3
|
import classNames from 'classnames'
|
|
5
4
|
import { Transition } from 'react-transition-group'
|
|
6
5
|
|
|
7
6
|
import { CBackdrop } from '../backdrop/CBackdrop'
|
|
7
|
+
import { CConditionalPortal } from '../conditional-portal'
|
|
8
8
|
|
|
9
9
|
import { useForkedRef } from '../../hooks'
|
|
10
10
|
|
|
@@ -94,24 +94,6 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
|
|
|
94
94
|
}
|
|
95
95
|
}, [_visible])
|
|
96
96
|
|
|
97
|
-
const getTransitionClass = (state: string) => {
|
|
98
|
-
return state === 'entering'
|
|
99
|
-
? 'showing'
|
|
100
|
-
: state === 'entered'
|
|
101
|
-
? 'show'
|
|
102
|
-
: state === 'exiting'
|
|
103
|
-
? 'show hiding'
|
|
104
|
-
: ''
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const _className = classNames(
|
|
108
|
-
{
|
|
109
|
-
[`offcanvas${typeof responsive !== 'boolean' ? '-' + responsive : ''}`]: responsive,
|
|
110
|
-
[`offcanvas-${placement}`]: placement,
|
|
111
|
-
},
|
|
112
|
-
className,
|
|
113
|
-
)
|
|
114
|
-
|
|
115
97
|
const handleDismiss = () => {
|
|
116
98
|
setVisible(false)
|
|
117
99
|
}
|
|
@@ -122,30 +104,10 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
|
|
|
122
104
|
}
|
|
123
105
|
}
|
|
124
106
|
|
|
125
|
-
const handleKeyDown =
|
|
126
|
-
(event
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
[ref, handleDismiss],
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
const offcanvas = (ref: React.Ref<HTMLDivElement>, state: string) => {
|
|
135
|
-
return (
|
|
136
|
-
<>
|
|
137
|
-
<div
|
|
138
|
-
className={classNames(_className, getTransitionClass(state))}
|
|
139
|
-
role="dialog"
|
|
140
|
-
tabIndex={-1}
|
|
141
|
-
onKeyDown={handleKeyDown}
|
|
142
|
-
{...rest}
|
|
143
|
-
ref={ref}
|
|
144
|
-
>
|
|
145
|
-
{children}
|
|
146
|
-
</div>
|
|
147
|
-
</>
|
|
148
|
-
)
|
|
107
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
108
|
+
if (event.key === 'Escape' && keyboard) {
|
|
109
|
+
return handleDismiss()
|
|
110
|
+
}
|
|
149
111
|
}
|
|
150
112
|
|
|
151
113
|
return (
|
|
@@ -158,29 +120,40 @@ export const COffcanvas = forwardRef<HTMLDivElement, COffcanvasProps>(
|
|
|
158
120
|
onExit={onHide}
|
|
159
121
|
timeout={300}
|
|
160
122
|
>
|
|
161
|
-
{(state) =>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
123
|
+
{(state) => (
|
|
124
|
+
<CConditionalPortal portal={portal}>
|
|
125
|
+
<div
|
|
126
|
+
className={classNames(
|
|
127
|
+
{
|
|
128
|
+
[`offcanvas${typeof responsive === 'string' ? '-' + responsive : ''}`]:
|
|
129
|
+
responsive,
|
|
130
|
+
[`offcanvas-${placement}`]: placement,
|
|
131
|
+
showing: state === 'entering',
|
|
132
|
+
show: state === 'entered',
|
|
133
|
+
'show hiding': state === 'exiting',
|
|
134
|
+
},
|
|
135
|
+
className,
|
|
136
|
+
)}
|
|
137
|
+
role="dialog"
|
|
138
|
+
tabIndex={-1}
|
|
139
|
+
onKeyDown={handleKeyDown}
|
|
140
|
+
{...rest}
|
|
141
|
+
ref={forkedRef}
|
|
142
|
+
>
|
|
143
|
+
{children}
|
|
144
|
+
</div>
|
|
145
|
+
</CConditionalPortal>
|
|
146
|
+
)}
|
|
166
147
|
</Transition>
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
177
|
-
: backdrop && (
|
|
178
|
-
<CBackdrop
|
|
179
|
-
className="offcanvas-backdrop"
|
|
180
|
-
onClick={handleBackdropDismiss}
|
|
181
|
-
visible={_visible}
|
|
182
|
-
/>
|
|
183
|
-
)}
|
|
148
|
+
{backdrop && (
|
|
149
|
+
<CConditionalPortal portal={portal}>
|
|
150
|
+
<CBackdrop
|
|
151
|
+
className="offcanvas-backdrop"
|
|
152
|
+
onClick={handleBackdropDismiss}
|
|
153
|
+
visible={_visible}
|
|
154
|
+
/>
|
|
155
|
+
</CConditionalPortal>
|
|
156
|
+
)}
|
|
184
157
|
</>
|
|
185
158
|
)
|
|
186
159
|
},
|
|
@@ -11,10 +11,8 @@ export interface COffcanvasBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const COffcanvasBody = forwardRef<HTMLDivElement, COffcanvasBodyProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('offcanvas-body', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<div className={
|
|
15
|
+
<div className={classNames('offcanvas-body', className)} {...rest} ref={ref}>
|
|
18
16
|
{children}
|
|
19
17
|
</div>
|
|
20
18
|
)
|
|
@@ -11,10 +11,8 @@ export interface COffcanvasHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const COffcanvasHeader = forwardRef<HTMLDivElement, COffcanvasHeaderProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('offcanvas-header', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<div className={
|
|
15
|
+
<div className={classNames('offcanvas-header', className)} {...rest} ref={ref}>
|
|
18
16
|
{children}
|
|
19
17
|
</div>
|
|
20
18
|
)
|
|
@@ -15,10 +15,8 @@ export interface COffcanvasTitleProps extends HTMLAttributes<HTMLHeadingElement>
|
|
|
15
15
|
|
|
16
16
|
export const COffcanvasTitle = forwardRef<HTMLHeadingElement, COffcanvasTitleProps>(
|
|
17
17
|
({ children, component: Component = 'h5', className, ...rest }, ref) => {
|
|
18
|
-
const _className = classNames('offcanvas-title', className)
|
|
19
|
-
|
|
20
18
|
return (
|
|
21
|
-
<Component className={
|
|
19
|
+
<Component className={classNames('offcanvas-title', className)} {...rest} ref={ref}>
|
|
22
20
|
{children}
|
|
23
21
|
</Component>
|
|
24
22
|
)
|
|
@@ -29,7 +29,7 @@ test('COffcanvas customize one', async () => {
|
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
test('COffcanvas customize and event on click backdrop', async () => {
|
|
32
|
-
jest.useFakeTimers()
|
|
32
|
+
// jest.useFakeTimers()
|
|
33
33
|
const onHide = jest.fn()
|
|
34
34
|
const { container } = render(
|
|
35
35
|
<COffcanvas
|
|
@@ -56,11 +56,13 @@ test('COffcanvas customize and event on click backdrop', async () => {
|
|
|
56
56
|
fireEvent.click(backdrop)
|
|
57
57
|
}
|
|
58
58
|
expect(onHide).toHaveBeenCalledTimes(1)
|
|
59
|
+
expect(container.firstChild).toHaveClass('show')
|
|
60
|
+
expect(container.firstChild).toHaveClass('hiding')
|
|
61
|
+
await new Promise((r) => setTimeout(r, 1000))
|
|
59
62
|
expect(container.firstChild).not.toHaveClass('show')
|
|
60
63
|
})
|
|
61
64
|
|
|
62
65
|
test('COffcanvas customize and event on keypress', async () => {
|
|
63
|
-
jest.useFakeTimers()
|
|
64
66
|
const onHide = jest.fn()
|
|
65
67
|
const { container } = render(
|
|
66
68
|
<COffcanvas
|
|
@@ -93,5 +95,8 @@ test('COffcanvas customize and event on keypress', async () => {
|
|
|
93
95
|
})
|
|
94
96
|
}
|
|
95
97
|
expect(onHide).toHaveBeenCalledTimes(1)
|
|
98
|
+
expect(container.firstChild).toHaveClass('show')
|
|
99
|
+
expect(container.firstChild).toHaveClass('hiding')
|
|
100
|
+
await new Promise((r) => setTimeout(r, 1000))
|
|
96
101
|
expect(container.firstChild).not.toHaveClass('show')
|
|
97
102
|
})
|
|
@@ -5,7 +5,6 @@ exports[`COffcanvas customize and event on click backdrop 1`] = `
|
|
|
5
5
|
<div
|
|
6
6
|
class="offcanvas offcanvas-end show bazinga"
|
|
7
7
|
role="dialog"
|
|
8
|
-
style="visibility: visible;"
|
|
9
8
|
tabindex="-1"
|
|
10
9
|
>
|
|
11
10
|
Test
|
|
@@ -21,7 +20,6 @@ exports[`COffcanvas customize and event on keypress 1`] = `
|
|
|
21
20
|
<div
|
|
22
21
|
class="offcanvas offcanvas-end show bazinga"
|
|
23
22
|
role="dialog"
|
|
24
|
-
style="visibility: visible;"
|
|
25
23
|
tabindex="-1"
|
|
26
24
|
>
|
|
27
25
|
Test
|
|
@@ -37,7 +35,6 @@ exports[`COffcanvas customize one 1`] = `
|
|
|
37
35
|
<div
|
|
38
36
|
class="offcanvas offcanvas-start bazinga"
|
|
39
37
|
role="dialog"
|
|
40
|
-
style="visibility: hidden;"
|
|
41
38
|
tabindex="-1"
|
|
42
39
|
>
|
|
43
40
|
Test
|
|
@@ -45,4 +42,12 @@ exports[`COffcanvas customize one 1`] = `
|
|
|
45
42
|
</div>
|
|
46
43
|
`;
|
|
47
44
|
|
|
48
|
-
exports[`loads and displays COffcanvas component 1`] =
|
|
45
|
+
exports[`loads and displays COffcanvas component 1`] = `
|
|
46
|
+
<div>
|
|
47
|
+
<div
|
|
48
|
+
class="offcanvas offcanvas-top"
|
|
49
|
+
role="dialog"
|
|
50
|
+
tabindex="-1"
|
|
51
|
+
/>
|
|
52
|
+
</div>
|
|
53
|
+
`;
|
|
@@ -19,17 +19,20 @@ export interface CPaginationProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
19
19
|
|
|
20
20
|
export const CPagination = forwardRef<HTMLUListElement, CPaginationProps>(
|
|
21
21
|
({ children, align, className, size, ...rest }, ref) => {
|
|
22
|
-
const _className = classNames(
|
|
23
|
-
'pagination',
|
|
24
|
-
{
|
|
25
|
-
[`justify-content-${align}`]: align,
|
|
26
|
-
[`pagination-${size}`]: size,
|
|
27
|
-
},
|
|
28
|
-
className,
|
|
29
|
-
)
|
|
30
22
|
return (
|
|
31
23
|
<nav ref={ref} {...rest}>
|
|
32
|
-
<ul
|
|
24
|
+
<ul
|
|
25
|
+
className={classNames(
|
|
26
|
+
'pagination',
|
|
27
|
+
{
|
|
28
|
+
[`justify-content-${align}`]: align,
|
|
29
|
+
[`pagination-${size}`]: size,
|
|
30
|
+
},
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</ul>
|
|
33
36
|
</nav>
|
|
34
37
|
)
|
|
35
38
|
},
|
|
@@ -21,19 +21,20 @@ export interface CPaginationItemProps extends HTMLAttributes<HTMLAnchorElement>
|
|
|
21
21
|
|
|
22
22
|
export const CPaginationItem = forwardRef<HTMLAnchorElement, CPaginationItemProps>(
|
|
23
23
|
({ children, className, component, ...rest }, ref) => {
|
|
24
|
-
const
|
|
25
|
-
'page-item',
|
|
26
|
-
{
|
|
27
|
-
active: rest.active,
|
|
28
|
-
disabled: rest.disabled,
|
|
29
|
-
},
|
|
30
|
-
className,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
const Component = component ? component : rest.active ? 'span' : 'a'
|
|
24
|
+
const Component = component ?? (rest.active ? 'span' : 'a')
|
|
34
25
|
|
|
35
26
|
return (
|
|
36
|
-
<li
|
|
27
|
+
<li
|
|
28
|
+
className={classNames(
|
|
29
|
+
'page-item',
|
|
30
|
+
{
|
|
31
|
+
active: rest.active,
|
|
32
|
+
disabled: rest.disabled,
|
|
33
|
+
},
|
|
34
|
+
className,
|
|
35
|
+
)}
|
|
36
|
+
{...(rest.active && { 'aria-current': 'page' })}
|
|
37
|
+
>
|
|
37
38
|
{Component === 'a' ? (
|
|
38
39
|
<CLink className="page-link" component={Component} {...rest} ref={ref}>
|
|
39
40
|
{children}
|
|
@@ -16,13 +16,13 @@ test('CPagination customize', async () => {
|
|
|
16
16
|
)
|
|
17
17
|
expect(container).toMatchSnapshot()
|
|
18
18
|
let element = container.firstChild
|
|
19
|
-
if (element
|
|
19
|
+
if (element === null) {
|
|
20
|
+
expect(true).toBe(false)
|
|
21
|
+
} else {
|
|
20
22
|
element = element.firstChild
|
|
21
23
|
expect(element).toHaveClass('bazinga')
|
|
22
24
|
expect(element).toHaveClass('pagination')
|
|
23
25
|
expect(element).toHaveClass('pagination-lg')
|
|
24
|
-
} else {
|
|
25
|
-
expect(true).toBe(false)
|
|
26
26
|
}
|
|
27
27
|
})
|
|
28
28
|
|
|
@@ -20,10 +20,10 @@ test('CPaginationItem customize', async () => {
|
|
|
20
20
|
expect(container.firstChild).toHaveClass('active')
|
|
21
21
|
expect(container.firstChild).toHaveClass('disabled')
|
|
22
22
|
let element = container.firstChild
|
|
23
|
-
if (element
|
|
23
|
+
if (element === null) {
|
|
24
|
+
expect(true).toBe(false)
|
|
25
|
+
} else {
|
|
24
26
|
element = element.firstChild
|
|
25
27
|
expect(element).toHaveClass('page-link')
|
|
26
|
-
} else {
|
|
27
|
-
expect(true).toBe(false)
|
|
28
28
|
}
|
|
29
29
|
})
|
|
@@ -150,16 +150,15 @@ export const CPicker = forwardRef<HTMLDivElement | HTMLLIElement, CPickerProps>(
|
|
|
150
150
|
</>
|
|
151
151
|
)
|
|
152
152
|
|
|
153
|
-
const _className = classNames('picker', className)
|
|
154
|
-
|
|
155
153
|
switch (container) {
|
|
156
|
-
case 'inline':
|
|
157
|
-
return <div className={
|
|
158
|
-
|
|
154
|
+
case 'inline': {
|
|
155
|
+
return <div className={classNames('picker', className)}>{children}</div>
|
|
156
|
+
}
|
|
157
|
+
default: {
|
|
159
158
|
return (
|
|
160
159
|
<CDropdown
|
|
161
160
|
autoClose="outside"
|
|
162
|
-
className={
|
|
161
|
+
className={classNames('picker', className)}
|
|
163
162
|
onHide={() => {
|
|
164
163
|
setVisible(false)
|
|
165
164
|
onHide && onHide()
|
|
@@ -186,6 +185,7 @@ export const CPicker = forwardRef<HTMLDivElement | HTMLLIElement, CPickerProps>(
|
|
|
186
185
|
</CDropdownMenu>
|
|
187
186
|
</CDropdown>
|
|
188
187
|
)
|
|
188
|
+
}
|
|
189
189
|
}
|
|
190
190
|
},
|
|
191
191
|
)
|
|
@@ -85,18 +85,20 @@ export const CPlaceholder = forwardRef<HTMLSpanElement, CPlaceholderProps>(
|
|
|
85
85
|
}
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
const _className = classNames(
|
|
89
|
-
animation ? `placeholder-${animation}` : 'placeholder',
|
|
90
|
-
{
|
|
91
|
-
[`bg-${color}`]: color,
|
|
92
|
-
[`placeholder-${size}`]: size,
|
|
93
|
-
},
|
|
94
|
-
repsonsiveClassNames,
|
|
95
|
-
className,
|
|
96
|
-
)
|
|
97
|
-
|
|
98
88
|
return (
|
|
99
|
-
<Component
|
|
89
|
+
<Component
|
|
90
|
+
className={classNames(
|
|
91
|
+
animation ? `placeholder-${animation}` : 'placeholder',
|
|
92
|
+
{
|
|
93
|
+
[`bg-${color}`]: color,
|
|
94
|
+
[`placeholder-${size}`]: size,
|
|
95
|
+
},
|
|
96
|
+
repsonsiveClassNames,
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
99
|
+
{...rest}
|
|
100
|
+
ref={ref}
|
|
101
|
+
>
|
|
100
102
|
{children}
|
|
101
103
|
</Component>
|
|
102
104
|
)
|