@coreui/react-pro 4.9.0-next.0 → 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/alert/CAlert.d.ts +1 -1
- package/dist/components/avatar/CAvatar.d.ts +1 -1
- package/dist/components/badge/CBadge.d.ts +1 -1
- package/dist/components/button/CButton.d.ts +1 -1
- package/dist/components/calendar/utils.d.ts +0 -1
- package/dist/components/callout/CCallout.d.ts +1 -1
- package/dist/components/card/CCard.d.ts +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/date-range-picker/CDateRangePicker.d.ts +1 -1
- package/dist/components/date-range-picker/utils.d.ts +1 -0
- package/dist/components/dropdown/CDropdown.d.ts +1 -1
- package/dist/components/dropdown/CDropdownToggle.d.ts +1 -1
- package/dist/components/form/CFormCheck.d.ts +8 -2
- package/dist/components/form/CFormSwitch.d.ts +6 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/list-group/CListGroupItem.d.ts +4 -5
- package/dist/components/multi-select/CMultiSelect.d.ts +1 -13
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
- package/dist/components/multi-select/types.d.ts +14 -0
- package/dist/components/multi-select/utils.d.ts +6 -0
- package/dist/components/navbar/CNavbar.d.ts +1 -1
- package/dist/components/picker/CPicker.d.ts +1 -1
- package/dist/components/placeholder/CPlaceholder.d.ts +1 -1
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/progress/CProgressBar.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableHead.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableInterface.d.ts +8 -0
- package/dist/components/smart-table/types.d.ts +1 -1
- package/dist/components/spinner/CSpinner.d.ts +1 -1
- package/dist/components/table/CTable.d.ts +2 -18
- package/dist/components/table/CTableBody.d.ts +1 -1
- package/dist/components/table/CTableDataCell.d.ts +1 -1
- package/dist/components/table/CTableFoot.d.ts +1 -1
- package/dist/components/table/CTableHead.d.ts +1 -1
- package/dist/components/table/CTableHeaderCell.d.ts +1 -1
- package/dist/components/table/CTableResponsiveWrapper.d.ts +0 -1
- package/dist/components/table/CTableRow.d.ts +1 -1
- package/dist/components/table/types.d.ts +17 -0
- package/dist/components/table/utils.d.ts +5 -0
- package/dist/components/toast/CToast.d.ts +1 -1
- package/dist/components/toast/CToastClose.d.ts +1 -1
- package/dist/components/tooltip/CTooltip.d.ts +1 -1
- package/dist/components/virtual-scroller/CVirtualScroller.d.ts +0 -8
- package/dist/components/widgets/CWidgetStatsA.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsB.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsC.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsD.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsF.d.ts +1 -1
- package/dist/index.es.js +696 -927
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +695 -925
- package/dist/index.js.map +1 -1
- package/dist/props.d.ts +8 -0
- package/dist/types.d.ts +7 -0
- package/dist/utils/index.d.ts +1 -3
- package/package.json +11 -6
- package/src/components/accordion/CAccordion.tsx +7 -3
- package/src/components/accordion/CAccordionBody.tsx +2 -2
- package/src/components/accordion/CAccordionButton.tsx +1 -3
- package/src/components/accordion/CAccordionCollapse.tsx +1 -0
- 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 +21 -28
- 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 +16 -19
- package/src/components/backdrop/CBackdrop.tsx +10 -13
- package/src/components/badge/CBadge.tsx +21 -27
- package/src/components/breadcrumb/CBreadcrumb.tsx +1 -2
- package/src/components/breadcrumb/CBreadcrumbItem.tsx +12 -8
- package/src/components/button/CButton.tsx +10 -10
- 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 -55
- package/src/components/callout/CCallout.tsx +13 -10
- package/src/components/card/CCard.tsx +14 -11
- 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 +11 -13
- package/src/components/date-range-picker/utils.ts +49 -0
- package/src/components/dropdown/CDropdown.tsx +26 -23
- package/src/components/dropdown/CDropdownDivider.tsx +1 -3
- package/src/components/dropdown/CDropdownHeader.tsx +1 -3
- package/src/components/dropdown/CDropdownItem.tsx +7 -5
- package/src/components/dropdown/CDropdownItemPlain.tsx +1 -3
- package/src/components/dropdown/CDropdownMenu.tsx +29 -32
- package/src/components/dropdown/CDropdownToggle.tsx +34 -27
- 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 +90 -66
- package/src/components/form/CFormControlValidation.tsx +0 -1
- package/src/components/form/CFormControlWrapper.tsx +3 -4
- package/src/components/form/CFormFeedback.tsx +11 -8
- package/src/components/form/CFormFloating.tsx +1 -2
- package/src/components/form/CFormInput.tsx +18 -16
- package/src/components/form/CFormLabel.tsx +1 -2
- package/src/components/form/CFormRange.tsx +2 -4
- package/src/components/form/CFormSelect.tsx +16 -12
- package/src/components/form/CFormSwitch.tsx +31 -20
- package/src/components/form/CFormText.tsx +1 -2
- package/src/components/form/CFormTextarea.tsx +14 -11
- 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 +21 -20
- package/src/components/list-group/CListGroupItem.tsx~HEAD +3 -1
- package/src/components/loading-button/CLoadingButton.tsx +1 -3
- package/src/components/modal/CModal.tsx +57 -72
- 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 +4 -4
- 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 +34 -93
- package/src/components/multi-select/CMultiSelectNativeSelect.tsx +1 -1
- package/src/components/multi-select/CMultiSelectOptions.tsx +2 -2
- package/src/components/multi-select/CMultiSelectSelection.tsx +1 -1
- package/src/components/multi-select/types.ts +15 -0
- package/src/components/multi-select/utils.ts +92 -0
- 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 +9 -10
- package/src/components/nav/CNavLink.tsx +4 -5
- package/src/components/nav/CNavTitle.tsx +1 -2
- package/src/components/navbar/CNavbar.tsx +23 -23
- 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 +42 -68
- 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 +7 -7
- package/src/components/placeholder/CPlaceholder.tsx +15 -12
- package/src/components/popover/CPopover.tsx +24 -34
- package/src/components/progress/CProgress.tsx +13 -10
- package/src/components/progress/CProgressBar.tsx +11 -12
- package/src/components/sidebar/CSidebar.tsx +22 -19
- 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 +5 -9
- package/src/components/smart-table/CSmartTableBody.tsx +82 -81
- package/src/components/smart-table/CSmartTableHead.tsx +5 -2
- package/src/components/smart-table/CSmartTableInterface.tsx +8 -0
- package/src/components/smart-table/{utils.tsx → utils.ts} +4 -5
- package/src/components/spinner/CSpinner.tsx +13 -9
- package/src/components/table/CTable.tsx +45 -77
- package/src/components/table/CTableBody.tsx +14 -9
- package/src/components/table/CTableDataCell.tsx +16 -11
- package/src/components/table/CTableFoot.tsx +14 -9
- package/src/components/table/CTableHead.tsx +14 -9
- package/src/components/table/CTableHeaderCell.tsx +14 -9
- package/src/components/table/CTableResponsiveWrapper.tsx +2 -3
- package/src/components/table/CTableRow.tsx +16 -11
- package/src/components/table/__tests__/__snapshots__/CTable.spec.tsx.snap +1 -5
- package/src/components/table/types.ts +20 -0
- package/src/components/table/utils.ts +24 -0
- package/src/components/tabs/CTabContent.tsx +1 -2
- package/src/components/tabs/CTabPane.tsx +18 -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 +14 -18
- package/src/components/toast/CToast.tsx +32 -45
- package/src/components/toast/CToastBody.tsx +1 -2
- package/src/components/toast/CToastClose.tsx +4 -2
- package/src/components/toast/CToastHeader.tsx +1 -2
- package/src/components/toast/CToaster.tsx +27 -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 +24 -34
- package/src/components/virtual-scroller/CVirtualScroller.tsx +35 -60
- package/src/components/widgets/CWidgetStatsA.tsx +11 -9
- package/src/components/widgets/CWidgetStatsB.tsx +4 -4
- package/src/components/widgets/CWidgetStatsC.tsx +4 -4
- package/src/components/widgets/CWidgetStatsD.tsx +13 -15
- package/src/components/widgets/CWidgetStatsE.tsx +2 -5
- package/src/components/widgets/CWidgetStatsF.tsx +4 -8
- package/src/{components/Types.tsx → props.ts} +1 -68
- package/src/types.ts +68 -0
- package/src/utils/index.ts +1 -3
- package/src/components/multi-select/CMultiSelectCleaner.tsx +0 -18
- package/src/utils/getNextSibling.ts +0 -18
- package/src/utils/getPreviousSibling.ts +0 -18
- package/src/components/smart-table/{types.tsx → types.ts} +1 -1
|
@@ -2,7 +2,8 @@ import React, { forwardRef, HTMLAttributes } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { colorPropType } from '../../props'
|
|
6
|
+
import type { Colors } from '../../types'
|
|
6
7
|
|
|
7
8
|
export interface CCalloutProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
9
|
/**
|
|
@@ -19,16 +20,18 @@ export interface CCalloutProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
19
20
|
|
|
20
21
|
export const CCallout = forwardRef<HTMLDivElement, CCalloutProps>(
|
|
21
22
|
({ children, className, color, ...rest }, ref) => {
|
|
22
|
-
const _className = classNames(
|
|
23
|
-
'callout',
|
|
24
|
-
{
|
|
25
|
-
[`callout-${color}`]: color,
|
|
26
|
-
},
|
|
27
|
-
className,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
23
|
return (
|
|
31
|
-
<div
|
|
24
|
+
<div
|
|
25
|
+
className={classNames(
|
|
26
|
+
'callout',
|
|
27
|
+
{
|
|
28
|
+
[`callout-${color}`]: color,
|
|
29
|
+
},
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
{...rest}
|
|
33
|
+
ref={ref}
|
|
34
|
+
>
|
|
32
35
|
{children}
|
|
33
36
|
</div>
|
|
34
37
|
)
|
|
@@ -2,7 +2,8 @@ import React, { forwardRef, HTMLAttributes } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { colorPropType, gradientsPropType } from '../../props'
|
|
6
|
+
import type { Colors, Gradients } from '../../types'
|
|
6
7
|
|
|
7
8
|
export interface CCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
9
|
/**
|
|
@@ -25,17 +26,19 @@ export interface CCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
25
26
|
|
|
26
27
|
export const CCard = forwardRef<HTMLDivElement, CCardProps>(
|
|
27
28
|
({ children, className, color, textColor, ...rest }, ref) => {
|
|
28
|
-
const _className = classNames(
|
|
29
|
-
'card',
|
|
30
|
-
{
|
|
31
|
-
[`bg-${color}`]: color,
|
|
32
|
-
[`text-${textColor}`]: textColor,
|
|
33
|
-
},
|
|
34
|
-
className,
|
|
35
|
-
)
|
|
36
|
-
|
|
37
29
|
return (
|
|
38
|
-
<div
|
|
30
|
+
<div
|
|
31
|
+
className={classNames(
|
|
32
|
+
'card',
|
|
33
|
+
{
|
|
34
|
+
[`bg-${color}`]: color,
|
|
35
|
+
[`text-${textColor}`]: textColor,
|
|
36
|
+
},
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...rest}
|
|
40
|
+
ref={ref}
|
|
41
|
+
>
|
|
39
42
|
{children}
|
|
40
43
|
</div>
|
|
41
44
|
)
|
|
@@ -11,10 +11,8 @@ export interface CCardBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CCardBody = forwardRef<HTMLDivElement, CCardBodyProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('card-body', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<div className={
|
|
15
|
+
<div className={classNames('card-body', className)} {...rest} ref={ref}>
|
|
18
16
|
{children}
|
|
19
17
|
</div>
|
|
20
18
|
)
|
|
@@ -11,10 +11,8 @@ export interface CCardFooterProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CCardFooter = forwardRef<HTMLDivElement, CCardFooterProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('card-footer', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<div className={
|
|
15
|
+
<div className={classNames('card-footer', className)} {...rest} ref={ref}>
|
|
18
16
|
{children}
|
|
19
17
|
</div>
|
|
20
18
|
)
|
|
@@ -11,10 +11,8 @@ export interface CCardGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CCardGroup = forwardRef<HTMLDivElement, CCardGroupProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('card-group', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<div className={
|
|
15
|
+
<div className={classNames('card-group', className)} {...rest} ref={ref}>
|
|
18
16
|
{children}
|
|
19
17
|
</div>
|
|
20
18
|
)
|
|
@@ -15,10 +15,8 @@ export interface CCardHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
15
15
|
|
|
16
16
|
export const CCardHeader = forwardRef<HTMLDivElement, CCardHeaderProps>(
|
|
17
17
|
({ children, component: Component = 'div', className, ...rest }, ref) => {
|
|
18
|
-
const _className = classNames('card-header', className)
|
|
19
|
-
|
|
20
18
|
return (
|
|
21
|
-
<Component className={
|
|
19
|
+
<Component className={classNames('card-header', className)} {...rest} ref={ref}>
|
|
22
20
|
{children}
|
|
23
21
|
</Component>
|
|
24
22
|
)
|
|
@@ -22,10 +22,12 @@ export const CCardImage = forwardRef<
|
|
|
22
22
|
HTMLImageElement | HTMLOrSVGElement | HTMLOrSVGImageElement,
|
|
23
23
|
CCardImageProps
|
|
24
24
|
>(({ children, className, component: Component = 'img', orientation, ...rest }, ref) => {
|
|
25
|
-
const _className = classNames(orientation ? `card-img-${orientation}` : 'card-img', className)
|
|
26
|
-
|
|
27
25
|
return (
|
|
28
|
-
<Component
|
|
26
|
+
<Component
|
|
27
|
+
className={classNames(orientation ? `card-img-${orientation}` : 'card-img', className)}
|
|
28
|
+
{...rest}
|
|
29
|
+
ref={ref}
|
|
30
|
+
>
|
|
29
31
|
{children}
|
|
30
32
|
</Component>
|
|
31
33
|
)
|
|
@@ -11,10 +11,8 @@ export interface CCardImageOverlayProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CCardImageOverlay = forwardRef<HTMLDivElement, CCardImageOverlayProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('card-img-overlay', className)
|
|
15
|
-
|
|
16
14
|
return (
|
|
17
|
-
<div className={
|
|
15
|
+
<div className={classNames('card-img-overlay', className)} {...rest} ref={ref}>
|
|
18
16
|
{children}
|
|
19
17
|
</div>
|
|
20
18
|
)
|
|
@@ -17,10 +17,8 @@ export interface CCardLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement>
|
|
|
17
17
|
|
|
18
18
|
export const CCardLink = forwardRef<HTMLAnchorElement, CCardLinkProps>(
|
|
19
19
|
({ children, className, ...rest }, ref) => {
|
|
20
|
-
const _className = classNames('card-link', className)
|
|
21
|
-
|
|
22
20
|
return (
|
|
23
|
-
<CLink className={
|
|
21
|
+
<CLink className={classNames('card-link', className)} {...rest} ref={ref}>
|
|
24
22
|
{children}
|
|
25
23
|
</CLink>
|
|
26
24
|
)
|
|
@@ -14,10 +14,8 @@ export interface CCardSubtitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
|
14
14
|
}
|
|
15
15
|
export const CCardSubtitle = forwardRef<HTMLHeadingElement, CCardSubtitleProps>(
|
|
16
16
|
({ children, component: Component = 'h6', className, ...rest }, ref) => {
|
|
17
|
-
const _className = classNames('card-subtitle', className)
|
|
18
|
-
|
|
19
17
|
return (
|
|
20
|
-
<Component className={
|
|
18
|
+
<Component className={classNames('card-subtitle', className)} {...rest} ref={ref}>
|
|
21
19
|
{children}
|
|
22
20
|
</Component>
|
|
23
21
|
)
|
|
@@ -15,10 +15,8 @@ export interface CCardTextProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
|
15
15
|
|
|
16
16
|
export const CCardText = forwardRef<HTMLParagraphElement, CCardTextProps>(
|
|
17
17
|
({ children, component: Component = 'p', className, ...rest }, ref) => {
|
|
18
|
-
const _className = classNames('card-text', className)
|
|
19
|
-
|
|
20
18
|
return (
|
|
21
|
-
<Component className={
|
|
19
|
+
<Component className={classNames('card-text', className)} {...rest} ref={ref}>
|
|
22
20
|
{children}
|
|
23
21
|
</Component>
|
|
24
22
|
)
|
|
@@ -15,10 +15,8 @@ export interface CCardTitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
|
15
15
|
|
|
16
16
|
export const CCardTitle = forwardRef<HTMLHeadingElement, CCardTitleProps>(
|
|
17
17
|
({ children, component: Component = 'h5', className, ...rest }, ref) => {
|
|
18
|
-
const _className = classNames('card-title', className)
|
|
19
|
-
|
|
20
18
|
return (
|
|
21
|
-
<Component className={
|
|
19
|
+
<Component className={classNames('card-title', className)} {...rest} ref={ref}>
|
|
22
20
|
{children}
|
|
23
21
|
</Component>
|
|
24
22
|
)
|
|
@@ -132,13 +132,6 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
|
|
|
132
132
|
}
|
|
133
133
|
})
|
|
134
134
|
|
|
135
|
-
const _className = classNames(
|
|
136
|
-
'carousel slide',
|
|
137
|
-
transition === 'crossfade' && 'carousel-fade',
|
|
138
|
-
dark && 'carousel-dark',
|
|
139
|
-
className,
|
|
140
|
-
)
|
|
141
|
-
|
|
142
135
|
const cycle = () => {
|
|
143
136
|
_pause()
|
|
144
137
|
if (!wrap && active === itemsNumber - 1) {
|
|
@@ -230,7 +223,14 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
|
|
|
230
223
|
|
|
231
224
|
return (
|
|
232
225
|
<div
|
|
233
|
-
className={
|
|
226
|
+
className={classNames(
|
|
227
|
+
'carousel slide',
|
|
228
|
+
{
|
|
229
|
+
'carousel-dark': dark,
|
|
230
|
+
'carousel-fade': transition === 'crossfade',
|
|
231
|
+
},
|
|
232
|
+
className,
|
|
233
|
+
)}
|
|
234
234
|
onMouseEnter={_pause}
|
|
235
235
|
onMouseLeave={cycle}
|
|
236
236
|
{...(touch && { onTouchStart: handleTouchStart, onTouchMove: handleTouchMove })}
|
|
@@ -11,9 +11,7 @@ export interface CCarouselCaptionProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CCarouselCaption = forwardRef<HTMLDivElement, CCarouselCaptionProps>(
|
|
13
13
|
({ className, ...rest }, ref) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return <div className={_className} {...rest} ref={ref} />
|
|
14
|
+
return <div className={classNames('carousel-caption', className)} {...rest} ref={ref} />
|
|
17
15
|
},
|
|
18
16
|
)
|
|
19
17
|
|
|
@@ -94,16 +94,18 @@ export const CCarouselItem = forwardRef<HTMLDivElement, CCarouselItemProps>(
|
|
|
94
94
|
}
|
|
95
95
|
})
|
|
96
96
|
|
|
97
|
-
const _className = classNames(
|
|
98
|
-
'carousel-item',
|
|
99
|
-
activeClassName,
|
|
100
|
-
directionClassName,
|
|
101
|
-
orderClassName,
|
|
102
|
-
className,
|
|
103
|
-
)
|
|
104
|
-
|
|
105
97
|
return (
|
|
106
|
-
<div
|
|
98
|
+
<div
|
|
99
|
+
className={classNames(
|
|
100
|
+
'carousel-item',
|
|
101
|
+
activeClassName,
|
|
102
|
+
directionClassName,
|
|
103
|
+
orderClassName,
|
|
104
|
+
className,
|
|
105
|
+
)}
|
|
106
|
+
ref={forkedRef}
|
|
107
|
+
{...rest}
|
|
108
|
+
>
|
|
107
109
|
{children}
|
|
108
110
|
</div>
|
|
109
111
|
)
|
|
@@ -19,19 +19,18 @@ export interface CCloseButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
|
|
19
19
|
|
|
20
20
|
export const CCloseButton = forwardRef<HTMLButtonElement, CCloseButtonProps>(
|
|
21
21
|
({ className, disabled, white, ...rest }, ref) => {
|
|
22
|
-
const _className = classNames(
|
|
23
|
-
'btn',
|
|
24
|
-
'btn-close',
|
|
25
|
-
{
|
|
26
|
-
'btn-close-white': white,
|
|
27
|
-
},
|
|
28
|
-
disabled,
|
|
29
|
-
className,
|
|
30
|
-
)
|
|
31
22
|
return (
|
|
32
23
|
<button
|
|
33
24
|
type="button"
|
|
34
|
-
className={
|
|
25
|
+
className={classNames(
|
|
26
|
+
'btn',
|
|
27
|
+
'btn-close',
|
|
28
|
+
{
|
|
29
|
+
'btn-close-white': white,
|
|
30
|
+
},
|
|
31
|
+
disabled,
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
35
34
|
aria-label="Close"
|
|
36
35
|
disabled={disabled}
|
|
37
36
|
{...rest}
|
|
@@ -30,20 +30,11 @@ export interface CCollapseProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
30
30
|
|
|
31
31
|
export const CCollapse = forwardRef<HTMLDivElement, CCollapseProps>(
|
|
32
32
|
({ children, className, horizontal, onHide, onShow, visible, ...rest }, ref) => {
|
|
33
|
-
const [height, setHeight] = useState<number>()
|
|
34
|
-
const [width, setWidth] = useState<number>()
|
|
35
33
|
const collapseRef = useRef<HTMLDivElement>(null)
|
|
36
34
|
const forkedRef = useForkedRef(ref, collapseRef)
|
|
37
35
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
? 'collapsing'
|
|
41
|
-
: state === 'entered'
|
|
42
|
-
? 'collapse show'
|
|
43
|
-
: state === 'exiting'
|
|
44
|
-
? 'collapsing'
|
|
45
|
-
: 'collapse'
|
|
46
|
-
}
|
|
36
|
+
const [height, setHeight] = useState<number>()
|
|
37
|
+
const [width, setWidth] = useState<number>()
|
|
47
38
|
|
|
48
39
|
const onEntering = () => {
|
|
49
40
|
onShow && onShow()
|
|
@@ -88,13 +79,6 @@ export const CCollapse = forwardRef<HTMLDivElement, CCollapseProps>(
|
|
|
88
79
|
setHeight(0)
|
|
89
80
|
}
|
|
90
81
|
|
|
91
|
-
const _className = classNames(
|
|
92
|
-
{
|
|
93
|
-
'collapse-horizontal': horizontal,
|
|
94
|
-
},
|
|
95
|
-
className,
|
|
96
|
-
)
|
|
97
|
-
|
|
98
82
|
return (
|
|
99
83
|
<CSSTransition
|
|
100
84
|
in={visible}
|
|
@@ -107,12 +91,16 @@ export const CCollapse = forwardRef<HTMLDivElement, CCollapseProps>(
|
|
|
107
91
|
timeout={350}
|
|
108
92
|
>
|
|
109
93
|
{(state) => {
|
|
110
|
-
const transitionClass = getTransitionClass(state)
|
|
111
94
|
const currentHeight = height === 0 ? null : { height }
|
|
112
95
|
const currentWidth = width === 0 ? null : { width }
|
|
113
96
|
return (
|
|
114
97
|
<div
|
|
115
|
-
className={classNames(
|
|
98
|
+
className={classNames(className, {
|
|
99
|
+
'collapse-horizontal': horizontal,
|
|
100
|
+
collapsing: state === 'entering' || state === 'exiting',
|
|
101
|
+
'collapse show': state === 'entered',
|
|
102
|
+
collapse: state === 'exited',
|
|
103
|
+
})}
|
|
116
104
|
style={{ ...currentHeight, ...currentWidth }}
|
|
117
105
|
{...rest}
|
|
118
106
|
ref={forkedRef}
|
|
@@ -15,7 +15,6 @@ test('CCollapse customize', async () => {
|
|
|
15
15
|
})
|
|
16
16
|
|
|
17
17
|
test('CCollapse use case test', async () => {
|
|
18
|
-
jest.useFakeTimers()
|
|
19
18
|
const { rerender } = render(<CCollapse visible={false}>Test</CCollapse>)
|
|
20
19
|
expect(screen.getByText('Test')).toHaveClass('collapse')
|
|
21
20
|
expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
@@ -24,7 +23,7 @@ test('CCollapse use case test', async () => {
|
|
|
24
23
|
expect(screen.getByText('Test')).not.toHaveClass('collapse')
|
|
25
24
|
expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
26
25
|
expect(screen.getByText('Test')).toHaveClass('collapsing')
|
|
27
|
-
|
|
26
|
+
await new Promise((r) => setTimeout(r, 1000))
|
|
28
27
|
expect(screen.getByText('Test')).toHaveClass('collapse')
|
|
29
28
|
expect(screen.getByText('Test')).toHaveClass('show')
|
|
30
29
|
expect(screen.getByText('Test')).not.toHaveClass('collapsing')
|
|
@@ -32,7 +31,7 @@ test('CCollapse use case test', async () => {
|
|
|
32
31
|
expect(screen.getByText('Test')).not.toHaveClass('collapse')
|
|
33
32
|
expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
34
33
|
expect(screen.getByText('Test')).toHaveClass('collapsing')
|
|
35
|
-
|
|
34
|
+
await new Promise((r) => setTimeout(r, 1000))
|
|
36
35
|
expect(screen.getByText('Test')).toHaveClass('collapse')
|
|
37
36
|
expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
38
37
|
expect(screen.getByText('Test')).not.toHaveClass('collapsing')
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react'
|
|
2
|
+
import { createPortal } from 'react-dom'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
|
|
5
|
+
export interface CConditionalPortalProps {
|
|
6
|
+
/**
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode
|
|
10
|
+
/**
|
|
11
|
+
* Render some children into a different part of the DOM
|
|
12
|
+
*/
|
|
13
|
+
portal: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CConditionalPortal: FC<CConditionalPortalProps> = ({ children, portal }) => {
|
|
17
|
+
return typeof window !== 'undefined' && portal ? (
|
|
18
|
+
createPortal(children, document.body)
|
|
19
|
+
) : (
|
|
20
|
+
<>{children}</>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
CConditionalPortal.propTypes = {
|
|
25
|
+
children: PropTypes.node,
|
|
26
|
+
portal: PropTypes.bool.isRequired,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
CConditionalPortal.displayName = 'CConditionalPortal'
|
|
@@ -12,9 +12,9 @@ import { CFormControlWrapper, CFormControlWrapperProps } from '../form/CFormCont
|
|
|
12
12
|
import { CPicker, CPickerProps } from '../picker/CPicker'
|
|
13
13
|
import { CTimePicker } from '../time-picker/CTimePicker'
|
|
14
14
|
|
|
15
|
-
import { getLocalDateFromString } from '
|
|
15
|
+
import { getLocalDateFromString } from './utils'
|
|
16
16
|
|
|
17
|
-
import { Colors } from '
|
|
17
|
+
import { Colors } from '../../types'
|
|
18
18
|
export interface CDateRangePickerProps
|
|
19
19
|
extends Omit<CFormControlWrapperProps, 'floatingLabel'>,
|
|
20
20
|
Omit<CPickerProps, 'autoClose' | 'component' | 'dark' | 'placeholder' | 'variant'>,
|
|
@@ -304,15 +304,6 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
304
304
|
setEndDate(null)
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
const _className = classNames(
|
|
308
|
-
'date-picker',
|
|
309
|
-
{
|
|
310
|
-
'is-invalid': invalid,
|
|
311
|
-
'is-valid': valid,
|
|
312
|
-
},
|
|
313
|
-
className,
|
|
314
|
-
)
|
|
315
|
-
|
|
316
307
|
const InputGroup = () => (
|
|
317
308
|
<CInputGroup className="picker-input-group" size={size}>
|
|
318
309
|
<CFormInput
|
|
@@ -409,7 +400,14 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
409
400
|
valid={valid}
|
|
410
401
|
>
|
|
411
402
|
<CPicker
|
|
412
|
-
className={
|
|
403
|
+
className={classNames(
|
|
404
|
+
'date-picker',
|
|
405
|
+
{
|
|
406
|
+
'is-invalid': invalid,
|
|
407
|
+
'is-valid': valid,
|
|
408
|
+
},
|
|
409
|
+
className,
|
|
410
|
+
)}
|
|
413
411
|
disabled={disabled}
|
|
414
412
|
footer={footer || timepicker}
|
|
415
413
|
footerContent={
|
|
@@ -431,7 +429,7 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
431
429
|
)
|
|
432
430
|
}
|
|
433
431
|
id={id}
|
|
434
|
-
toggler={toggler
|
|
432
|
+
toggler={toggler ?? InputGroup()}
|
|
435
433
|
onCancel={() => {
|
|
436
434
|
handleStartDateChange(initialStartDate)
|
|
437
435
|
handleEndDateChange(initialEndDate)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const getLocalDateFromString = (string: string, locale: string, time?: boolean) => {
|
|
2
|
+
if (!Number.isNaN(Date.parse(string))) {
|
|
3
|
+
return new Date(Date.parse(string))
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const date = new Date(2013, 11, 31, 17, 19, 22)
|
|
7
|
+
let regex = time ? date.toLocaleString(locale) : date.toLocaleDateString(locale)
|
|
8
|
+
regex = regex
|
|
9
|
+
.replace('2013', '(?<year>[0-9]{2,4})')
|
|
10
|
+
.replace('12', '(?<month>[0-9]{1,2})')
|
|
11
|
+
.replace('31', '(?<day>[0-9]{1,2})')
|
|
12
|
+
|
|
13
|
+
if (time) {
|
|
14
|
+
regex = regex
|
|
15
|
+
.replace('5', '(?<hour>[0-9]{1,2})')
|
|
16
|
+
.replace('17', '(?<hour>[0-9]{1,2})')
|
|
17
|
+
.replace('19', '(?<minute>[0-9]{1,2})')
|
|
18
|
+
.replace('22', '(?<second>[0-9]{1,2})')
|
|
19
|
+
.replace('PM', '(?<ampm>[A-Z]{2})')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rgx = new RegExp(`${regex}`)
|
|
23
|
+
const partials = string.match(rgx)
|
|
24
|
+
|
|
25
|
+
if (partials === null) return
|
|
26
|
+
|
|
27
|
+
const newDate =
|
|
28
|
+
partials.groups &&
|
|
29
|
+
(time
|
|
30
|
+
? new Date(
|
|
31
|
+
Number(partials.groups['year']),
|
|
32
|
+
Number(partials.groups['month']) - 1,
|
|
33
|
+
Number(partials.groups['day']),
|
|
34
|
+
partials.groups['ampm']
|
|
35
|
+
? partials.groups['ampm'] === 'PM'
|
|
36
|
+
? Number(partials.groups['hour']) + 12
|
|
37
|
+
: Number(partials.groups['hour'])
|
|
38
|
+
: Number(partials.groups['hour']),
|
|
39
|
+
Number(partials.groups['minute']),
|
|
40
|
+
Number(partials.groups['second']),
|
|
41
|
+
)
|
|
42
|
+
: new Date(
|
|
43
|
+
Number(partials.groups['year']),
|
|
44
|
+
Number(partials.groups['month']) - 1,
|
|
45
|
+
Number(partials.groups['day']),
|
|
46
|
+
))
|
|
47
|
+
|
|
48
|
+
return newDate
|
|
49
|
+
}
|
|
@@ -12,8 +12,9 @@ import PropTypes from 'prop-types'
|
|
|
12
12
|
import classNames from 'classnames'
|
|
13
13
|
import { Manager } from 'react-popper'
|
|
14
14
|
|
|
15
|
-
import { Placements, placementPropType } from '../Types'
|
|
16
15
|
import { useForkedRef } from '../../hooks'
|
|
16
|
+
import { placementPropType } from '../../props'
|
|
17
|
+
import type { Placements } from '../../types'
|
|
17
18
|
|
|
18
19
|
export type Directions = 'start' | 'end'
|
|
19
20
|
|
|
@@ -114,10 +115,10 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
114
115
|
},
|
|
115
116
|
ref,
|
|
116
117
|
) => {
|
|
117
|
-
const [_visible, setVisible] = useState(visible)
|
|
118
118
|
const dropdownRef = useRef<HTMLDivElement>(null)
|
|
119
119
|
const dropdownToggleRef = useRef(null)
|
|
120
120
|
const forkedRef = useForkedRef(ref, dropdownRef)
|
|
121
|
+
const [_visible, setVisible] = useState(visible)
|
|
121
122
|
|
|
122
123
|
const Component = variant === 'nav-item' ? 'li' : component
|
|
123
124
|
|
|
@@ -139,19 +140,6 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
139
140
|
setVisible,
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
const _className = classNames(
|
|
143
|
-
variant === 'nav-item' ? 'nav-item dropdown' : variant,
|
|
144
|
-
{
|
|
145
|
-
show: _visible,
|
|
146
|
-
},
|
|
147
|
-
direction === 'center'
|
|
148
|
-
? 'dropdown-center'
|
|
149
|
-
: direction === 'dropup-center'
|
|
150
|
-
? 'dropup dropup-center'
|
|
151
|
-
: direction,
|
|
152
|
-
className,
|
|
153
|
-
)
|
|
154
|
-
|
|
155
143
|
useEffect(() => {
|
|
156
144
|
setVisible(visible)
|
|
157
145
|
}, [visible])
|
|
@@ -161,23 +149,38 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
161
149
|
!_visible && onHide && onHide()
|
|
162
150
|
}, [_visible])
|
|
163
151
|
|
|
164
|
-
const
|
|
152
|
+
const DropdownContent = () => {
|
|
165
153
|
return variant === 'input-group' ? (
|
|
166
154
|
<>{children}</>
|
|
167
155
|
) : (
|
|
168
|
-
<Component
|
|
156
|
+
<Component
|
|
157
|
+
className={classNames(
|
|
158
|
+
variant === 'nav-item' ? 'nav-item dropdown' : variant,
|
|
159
|
+
{
|
|
160
|
+
'dropdown-center': direction === 'center',
|
|
161
|
+
'dropup dropup-center': direction === 'dropup-center',
|
|
162
|
+
direction: direction && direction !== 'center' && direction !== 'dropup-center',
|
|
163
|
+
show: _visible,
|
|
164
|
+
},
|
|
165
|
+
className,
|
|
166
|
+
)}
|
|
167
|
+
{...rest}
|
|
168
|
+
ref={forkedRef}
|
|
169
|
+
>
|
|
169
170
|
{children}
|
|
170
171
|
</Component>
|
|
171
172
|
)
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
return
|
|
175
|
-
<CDropdownContext.Provider value={contextValues}>
|
|
176
|
-
<Manager>{dropdownContent()}</Manager>
|
|
177
|
-
</CDropdownContext.Provider>
|
|
178
|
-
) : (
|
|
175
|
+
return (
|
|
179
176
|
<CDropdownContext.Provider value={contextValues}>
|
|
180
|
-
{
|
|
177
|
+
{popper ? (
|
|
178
|
+
<Manager>
|
|
179
|
+
<DropdownContent />
|
|
180
|
+
</Manager>
|
|
181
|
+
) : (
|
|
182
|
+
<DropdownContent />
|
|
183
|
+
)}
|
|
181
184
|
</CDropdownContext.Provider>
|
|
182
185
|
)
|
|
183
186
|
},
|
|
@@ -11,9 +11,7 @@ export interface CDropdownDividerProps extends HTMLAttributes<HTMLHRElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CDropdownDivider = forwardRef<HTMLHRElement, CDropdownDividerProps>(
|
|
13
13
|
({ className, ...rest }, ref) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return <hr className={_className} {...rest} ref={ref} />
|
|
14
|
+
return <hr className={classNames('dropdown-divider', className)} {...rest} ref={ref} />
|
|
17
15
|
},
|
|
18
16
|
)
|
|
19
17
|
|
|
@@ -15,10 +15,8 @@ export interface CDropdownHeaderProps extends HTMLAttributes<HTMLHeadingElement>
|
|
|
15
15
|
|
|
16
16
|
export const CDropdownHeader = forwardRef<HTMLHeadingElement, CDropdownHeaderProps>(
|
|
17
17
|
({ children, className, component: Component = 'h6', ...rest }, ref) => {
|
|
18
|
-
const _className = classNames('dropdown-header', className)
|
|
19
|
-
|
|
20
18
|
return (
|
|
21
|
-
<Component className={
|
|
19
|
+
<Component className={classNames('dropdown-header', className)} {...rest} ref={ref}>
|
|
22
20
|
{children}
|
|
23
21
|
</Component>
|
|
24
22
|
)
|