@coreui/react-pro 4.9.0-next.1 → 4.10.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/date-range-picker/CDateRangePicker.d.ts +6 -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/components/time-picker/CTimePicker.d.ts +6 -0
- package/dist/index.es.js +507 -728
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +506 -726
- 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 +19 -11
- package/src/components/date-range-picker/utils.ts +2 -2
- package/src/components/dropdown/CDropdown.tsx +35 -30
- 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 +21 -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
- package/dist/components/Types.d.ts +0 -14
- package/dist/components/multi-select/CMultiSelectCleaner.d.ts +0 -2
- package/dist/components/multi-select/CMultiSelectSearchInput.d.ts +0 -5
- package/dist/components/pagination/CSmartPagination.d.ts +0 -80
- package/dist/components/time-picker/CTimePicker copy.d.ts +0 -46
- package/dist/utils/calendar.d.ts +0 -23
- package/dist/utils/getNextSibling.d.ts +0 -2
- package/dist/utils/getPreviousSibling.d.ts +0 -2
- package/dist/utils/hooks/index.d.ts +0 -3
- package/dist/utils/hooks/useForkedRef.d.ts +0 -7
- package/dist/utils/hooks/useStateWithCallback.d.ts +0 -2
- package/dist/utils/isVisible.d.ts +0 -2
- package/dist/utils/time.d.ts +0 -21
|
@@ -20,15 +20,19 @@ export interface CTableFootProps extends HTMLAttributes<HTMLTableSectionElement>
|
|
|
20
20
|
|
|
21
21
|
export const CTableFoot = forwardRef<HTMLTableSectionElement, CTableFootProps>(
|
|
22
22
|
({ children, className, color, ...rest }, ref) => {
|
|
23
|
-
const _className = classNames(
|
|
24
|
-
{
|
|
25
|
-
[`table-${color}`]: color,
|
|
26
|
-
},
|
|
27
|
-
className,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
23
|
return (
|
|
31
|
-
<tfoot
|
|
24
|
+
<tfoot
|
|
25
|
+
className={
|
|
26
|
+
classNames(
|
|
27
|
+
{
|
|
28
|
+
[`table-${color}`]: color,
|
|
29
|
+
},
|
|
30
|
+
className,
|
|
31
|
+
) || undefined
|
|
32
|
+
}
|
|
33
|
+
{...rest}
|
|
34
|
+
ref={ref}
|
|
35
|
+
>
|
|
32
36
|
{children}
|
|
33
37
|
</tfoot>
|
|
34
38
|
)
|
|
@@ -20,15 +20,19 @@ export interface CTableHeadProps extends HTMLAttributes<HTMLTableSectionElement>
|
|
|
20
20
|
|
|
21
21
|
export const CTableHead = forwardRef<HTMLTableSectionElement, CTableHeadProps>(
|
|
22
22
|
({ children, className, color, ...rest }, ref) => {
|
|
23
|
-
const _className = classNames(
|
|
24
|
-
{
|
|
25
|
-
[`table-${color}`]: color,
|
|
26
|
-
},
|
|
27
|
-
className,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
23
|
return (
|
|
31
|
-
<thead
|
|
24
|
+
<thead
|
|
25
|
+
className={
|
|
26
|
+
classNames(
|
|
27
|
+
{
|
|
28
|
+
[`table-${color}`]: color,
|
|
29
|
+
},
|
|
30
|
+
className,
|
|
31
|
+
) || undefined
|
|
32
|
+
}
|
|
33
|
+
{...rest}
|
|
34
|
+
ref={ref}
|
|
35
|
+
>
|
|
32
36
|
{children}
|
|
33
37
|
</thead>
|
|
34
38
|
)
|
|
@@ -20,15 +20,19 @@ export interface CTableHeaderCellProps extends ThHTMLAttributes<HTMLTableCellEle
|
|
|
20
20
|
|
|
21
21
|
export const CTableHeaderCell = forwardRef<HTMLTableCellElement, CTableHeaderCellProps>(
|
|
22
22
|
({ children, className, color, ...rest }, ref) => {
|
|
23
|
-
const _className = classNames(
|
|
24
|
-
{
|
|
25
|
-
[`table-${color}`]: color,
|
|
26
|
-
},
|
|
27
|
-
className,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
23
|
return (
|
|
31
|
-
<th
|
|
24
|
+
<th
|
|
25
|
+
className={
|
|
26
|
+
classNames(
|
|
27
|
+
{
|
|
28
|
+
[`table-${color}`]: color,
|
|
29
|
+
},
|
|
30
|
+
className,
|
|
31
|
+
) || undefined
|
|
32
|
+
}
|
|
33
|
+
{...rest}
|
|
34
|
+
ref={ref}
|
|
35
|
+
>
|
|
32
36
|
{children}
|
|
33
37
|
</th>
|
|
34
38
|
)
|
|
@@ -2,7 +2,6 @@ import React, { FC, HTMLAttributes } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
4
|
export interface CTableResponsiveWrapperProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children: any
|
|
6
5
|
/**
|
|
7
6
|
* Make any table responsive across all viewports or pick a maximum breakpoint with which to have a responsive table up to.
|
|
8
7
|
*/
|
|
@@ -24,12 +23,12 @@ export const CTableResponsiveWrapper: FC<CTableResponsiveWrapperProps> = ({
|
|
|
24
23
|
{children}
|
|
25
24
|
</div>
|
|
26
25
|
) : (
|
|
27
|
-
children
|
|
26
|
+
<>{children}</>
|
|
28
27
|
)
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
CTableResponsiveWrapper.propTypes = {
|
|
32
|
-
children: PropTypes.
|
|
31
|
+
children: PropTypes.node,
|
|
33
32
|
responsive: PropTypes.oneOfType([
|
|
34
33
|
PropTypes.bool,
|
|
35
34
|
PropTypes.oneOf<'sm' | 'md' | 'lg' | 'xl' | 'xxl'>(['sm', 'md', 'lg', 'xl', 'xxl']),
|
|
@@ -28,17 +28,21 @@ export interface CTableRowProps extends HTMLAttributes<HTMLTableRowElement> {
|
|
|
28
28
|
|
|
29
29
|
export const CTableRow = forwardRef<HTMLTableRowElement, CTableRowProps>(
|
|
30
30
|
({ children, active, align, className, color, ...rest }, ref) => {
|
|
31
|
-
const _className = classNames(
|
|
32
|
-
{
|
|
33
|
-
[`align-${align}`]: align,
|
|
34
|
-
'table-active': active,
|
|
35
|
-
[`table-${color}`]: color,
|
|
36
|
-
},
|
|
37
|
-
className,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
31
|
return (
|
|
41
|
-
<tr
|
|
32
|
+
<tr
|
|
33
|
+
className={
|
|
34
|
+
classNames(
|
|
35
|
+
{
|
|
36
|
+
[`align-${align}`]: align,
|
|
37
|
+
'table-active': active,
|
|
38
|
+
[`table-${color}`]: color,
|
|
39
|
+
},
|
|
40
|
+
className,
|
|
41
|
+
) || undefined
|
|
42
|
+
}
|
|
43
|
+
{...rest}
|
|
44
|
+
ref={ref}
|
|
45
|
+
>
|
|
42
46
|
{children}
|
|
43
47
|
</tr>
|
|
44
48
|
)
|
|
@@ -8,7 +8,6 @@ exports[`CTable customize 1`] = `
|
|
|
8
8
|
<table
|
|
9
9
|
class="table align-middle border-primary caption-top table-bordered table-borderless table-info table-hover table-sm table-striped bazinga"
|
|
10
10
|
>
|
|
11
|
-
<tbody />
|
|
12
11
|
<tbody>
|
|
13
12
|
<tr>
|
|
14
13
|
<td>
|
|
@@ -26,7 +25,6 @@ exports[`CTable full example test 1`] = `
|
|
|
26
25
|
<table
|
|
27
26
|
class="table caption-top"
|
|
28
27
|
>
|
|
29
|
-
<tbody />
|
|
30
28
|
<caption>
|
|
31
29
|
List of users
|
|
32
30
|
</caption>
|
|
@@ -194,8 +192,6 @@ exports[`loads and displays CTable component 1`] = `
|
|
|
194
192
|
<div>
|
|
195
193
|
<table
|
|
196
194
|
class="table"
|
|
197
|
-
|
|
198
|
-
<tbody />
|
|
199
|
-
</table>
|
|
195
|
+
/>
|
|
200
196
|
</div>
|
|
201
197
|
`;
|
|
@@ -11,17 +11,12 @@ export const pretifyName = (name: string) => {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const getColumnLabel = (column: Column | string) =>
|
|
14
|
-
typeof column === 'object'
|
|
15
|
-
? column.label !== undefined
|
|
16
|
-
? column.label
|
|
17
|
-
: pretifyName(column.key)
|
|
18
|
-
: pretifyName(column)
|
|
14
|
+
typeof column === 'object' ? column.label ?? pretifyName(column.key) : pretifyName(column)
|
|
19
15
|
|
|
20
16
|
export const getColumnNames = (columns: (string | Column)[] | undefined, items?: Item[]) =>
|
|
21
17
|
columns
|
|
22
18
|
? columns.map((column: Column | string) => {
|
|
23
|
-
|
|
24
|
-
else return column
|
|
19
|
+
return typeof column === 'object' ? column.key : column
|
|
25
20
|
})
|
|
26
21
|
: items && getColumnNamesFromItems(items)
|
|
27
22
|
|
|
@@ -11,9 +11,8 @@ export interface CTabContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CTabContent = forwardRef<HTMLDivElement, CTabContentProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('tab-content', className)
|
|
15
14
|
return (
|
|
16
|
-
<div className={
|
|
15
|
+
<div className={classNames('tab-content', className)} {...rest} ref={ref}>
|
|
17
16
|
{children}
|
|
18
17
|
</div>
|
|
19
18
|
)
|
|
@@ -29,28 +29,25 @@ export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
|
|
|
29
29
|
const tabPaneRef = useRef()
|
|
30
30
|
const forkedRef = useForkedRef(ref, tabPaneRef)
|
|
31
31
|
|
|
32
|
-
const getTransitionClass = (state: string) => {
|
|
33
|
-
return state === 'entered' && 'show'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const _className = classNames(
|
|
37
|
-
'tab-pane',
|
|
38
|
-
'fade',
|
|
39
|
-
{
|
|
40
|
-
active: visible,
|
|
41
|
-
},
|
|
42
|
-
className,
|
|
43
|
-
)
|
|
44
32
|
return (
|
|
45
33
|
<Transition in={visible} nodeRef={tabPaneRef} onEnter={onShow} onExit={onHide} timeout={150}>
|
|
46
|
-
{(state) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
{(state) => (
|
|
35
|
+
<div
|
|
36
|
+
className={classNames(
|
|
37
|
+
'tab-pane',
|
|
38
|
+
'fade',
|
|
39
|
+
{
|
|
40
|
+
active: visible,
|
|
41
|
+
show: state === 'entered',
|
|
42
|
+
},
|
|
43
|
+
className,
|
|
44
|
+
)}
|
|
45
|
+
{...rest}
|
|
46
|
+
ref={forkedRef}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
54
51
|
</Transition>
|
|
55
52
|
)
|
|
56
53
|
},
|
|
@@ -18,7 +18,6 @@ test('CTabPane customize', async () => {
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
test('CTabContent use case test', async () => {
|
|
21
|
-
jest.useFakeTimers()
|
|
22
21
|
const { rerender } = render(
|
|
23
22
|
<CTabContent>
|
|
24
23
|
<CTabPane visible={false}>Test</CTabPane>
|
|
@@ -33,7 +32,7 @@ test('CTabContent use case test', async () => {
|
|
|
33
32
|
)
|
|
34
33
|
expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
35
34
|
expect(screen.getByText('Test')).toHaveClass('active')
|
|
36
|
-
|
|
35
|
+
await new Promise((r) => setTimeout(r, 1000))
|
|
37
36
|
expect(screen.getByText('Test')).toHaveClass('show')
|
|
38
37
|
expect(screen.getByText('Test')).toHaveClass('active')
|
|
39
38
|
rerender(
|
|
@@ -43,9 +42,7 @@ test('CTabContent use case test', async () => {
|
|
|
43
42
|
)
|
|
44
43
|
expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
45
44
|
expect(screen.getByText('Test')).not.toHaveClass('active')
|
|
46
|
-
|
|
45
|
+
await new Promise((r) => setTimeout(r, 1000))
|
|
47
46
|
expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
48
47
|
expect(screen.getByText('Test')).not.toHaveClass('active')
|
|
49
|
-
jest.runAllTimers()
|
|
50
|
-
jest.useRealTimers()
|
|
51
48
|
})
|
|
@@ -60,6 +60,12 @@ export interface CTimePickerProps
|
|
|
60
60
|
* Specifies a short hint that is visible in the input.
|
|
61
61
|
*/
|
|
62
62
|
placeholder?: string
|
|
63
|
+
/**
|
|
64
|
+
* When present, it specifies that time must be filled out before submitting the form.
|
|
65
|
+
*
|
|
66
|
+
* @since 4.10.0
|
|
67
|
+
*/
|
|
68
|
+
required?: boolean
|
|
63
69
|
/**
|
|
64
70
|
* Show seconds.
|
|
65
71
|
*
|
|
@@ -102,6 +108,7 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
102
108
|
onHide,
|
|
103
109
|
onShow,
|
|
104
110
|
placeholder = 'Select time',
|
|
111
|
+
required,
|
|
105
112
|
seconds = true,
|
|
106
113
|
size,
|
|
107
114
|
text,
|
|
@@ -166,18 +173,18 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
166
173
|
|
|
167
174
|
if (set === 'hours') {
|
|
168
175
|
if (localizedTimePartials && localizedTimePartials.hour12) {
|
|
169
|
-
_date.setHours(convert12hTo24h(_ampm, parseInt(value)))
|
|
176
|
+
_date.setHours(convert12hTo24h(_ampm, Number.parseInt(value)))
|
|
170
177
|
} else {
|
|
171
|
-
_date.setHours(parseInt(value))
|
|
178
|
+
_date.setHours(Number.parseInt(value))
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
|
|
175
182
|
if (set === 'minutes') {
|
|
176
|
-
_date.setMinutes(parseInt(value))
|
|
183
|
+
_date.setMinutes(Number.parseInt(value))
|
|
177
184
|
}
|
|
178
185
|
|
|
179
186
|
if (set === 'seconds') {
|
|
180
|
-
_date.setSeconds(parseInt(value))
|
|
187
|
+
_date.setSeconds(Number.parseInt(value))
|
|
181
188
|
}
|
|
182
189
|
|
|
183
190
|
setDate(new Date(_date))
|
|
@@ -195,6 +202,7 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
195
202
|
}
|
|
196
203
|
placeholder={placeholder}
|
|
197
204
|
readOnly={inputReadOnly}
|
|
205
|
+
required={required}
|
|
198
206
|
ref={inputRef}
|
|
199
207
|
/>
|
|
200
208
|
{(indicator || cleaner) && (
|
|
@@ -333,15 +341,6 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
333
341
|
</>
|
|
334
342
|
)
|
|
335
343
|
|
|
336
|
-
const _className = classNames(
|
|
337
|
-
'time-picker',
|
|
338
|
-
{
|
|
339
|
-
'is-invalid': invalid,
|
|
340
|
-
'is-valid': valid,
|
|
341
|
-
},
|
|
342
|
-
className,
|
|
343
|
-
)
|
|
344
|
-
|
|
345
344
|
return (
|
|
346
345
|
<CFormControlWrapper
|
|
347
346
|
describedby={rest['aria-describedby']}
|
|
@@ -356,7 +355,14 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
356
355
|
valid={valid}
|
|
357
356
|
>
|
|
358
357
|
<CPicker
|
|
359
|
-
className={
|
|
358
|
+
className={classNames(
|
|
359
|
+
'time-picker',
|
|
360
|
+
{
|
|
361
|
+
'is-invalid': invalid,
|
|
362
|
+
'is-valid': valid,
|
|
363
|
+
},
|
|
364
|
+
className,
|
|
365
|
+
)}
|
|
360
366
|
container={container}
|
|
361
367
|
disabled={disabled}
|
|
362
368
|
footer={footer}
|
|
@@ -399,6 +405,7 @@ CTimePicker.propTypes = {
|
|
|
399
405
|
className: PropTypes.string,
|
|
400
406
|
locale: PropTypes.string,
|
|
401
407
|
onTimeChange: PropTypes.func,
|
|
408
|
+
required: PropTypes.bool,
|
|
402
409
|
seconds: PropTypes.bool,
|
|
403
410
|
time: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
404
411
|
variant: PropTypes.oneOf(['roll', 'select']),
|
|
@@ -114,55 +114,42 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
const _className = classNames(
|
|
118
|
-
'toast',
|
|
119
|
-
{
|
|
120
|
-
fade: animation,
|
|
121
|
-
[`bg-${color}`]: color,
|
|
122
|
-
'border-0': color,
|
|
123
|
-
},
|
|
124
|
-
className,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
const getTransitionClass = (state: string) => {
|
|
128
|
-
return state === 'entering'
|
|
129
|
-
? 'showing'
|
|
130
|
-
: state === 'entered'
|
|
131
|
-
? 'show'
|
|
132
|
-
: state === 'exiting'
|
|
133
|
-
? 'showing'
|
|
134
|
-
: 'fade'
|
|
135
|
-
}
|
|
136
|
-
|
|
137
117
|
return (
|
|
138
118
|
<Transition
|
|
139
119
|
in={_visible}
|
|
140
120
|
nodeRef={toastRef}
|
|
141
|
-
onEnter={() => onShow && onShow(index
|
|
142
|
-
onExited={() => onClose && onClose(index
|
|
121
|
+
onEnter={() => onShow && onShow(index ?? null)}
|
|
122
|
+
onExited={() => onClose && onClose(index ?? null)}
|
|
143
123
|
timeout={250}
|
|
144
124
|
unmountOnExit
|
|
145
125
|
>
|
|
146
|
-
{(state) =>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
126
|
+
{(state) => (
|
|
127
|
+
<CToastContext.Provider value={contextValues}>
|
|
128
|
+
<div
|
|
129
|
+
className={classNames(
|
|
130
|
+
'toast',
|
|
131
|
+
{
|
|
132
|
+
fade: animation,
|
|
133
|
+
[`bg-${color}`]: color,
|
|
134
|
+
'border-0': color,
|
|
135
|
+
'show showing': state === 'entering' || state === 'exiting',
|
|
136
|
+
show: state === 'entered',
|
|
137
|
+
},
|
|
138
|
+
className,
|
|
139
|
+
)}
|
|
140
|
+
aria-live="assertive"
|
|
141
|
+
aria-atomic="true"
|
|
142
|
+
role="alert"
|
|
143
|
+
onMouseEnter={() => clearTimeout(timeout.current)}
|
|
144
|
+
onMouseLeave={() => _autohide()}
|
|
145
|
+
{...rest}
|
|
146
|
+
key={key}
|
|
147
|
+
ref={forkedRef}
|
|
148
|
+
>
|
|
149
|
+
{children}
|
|
150
|
+
</div>
|
|
151
|
+
</CToastContext.Provider>
|
|
152
|
+
)}
|
|
166
153
|
</Transition>
|
|
167
154
|
)
|
|
168
155
|
},
|
|
@@ -11,9 +11,8 @@ export interface CToastBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CToastBody = forwardRef<HTMLDivElement, CToastBodyProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('toast-body', className)
|
|
15
14
|
return (
|
|
16
|
-
<div className={
|
|
15
|
+
<div className={classNames('toast-body', className)} {...rest} ref={ref}>
|
|
17
16
|
{children}
|
|
18
17
|
</div>
|
|
19
18
|
)
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { ElementType, forwardRef, useContext } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { CToastContext } from './CToast'
|
|
4
3
|
|
|
5
4
|
import { CButtonProps } from '../button/CButton'
|
|
6
5
|
import { CCloseButton, CCloseButtonProps } from '../close-button/CCloseButton'
|
|
7
6
|
|
|
7
|
+
import { CToastContext } from './CToast'
|
|
8
|
+
|
|
8
9
|
type CombineButtonProps = CCloseButtonProps & CButtonProps
|
|
10
|
+
|
|
9
11
|
export interface CToastCloseProps extends CombineButtonProps {
|
|
10
12
|
/**
|
|
11
13
|
* Component used for the root node. Either a string to use a HTML element or a component.
|
|
@@ -17,9 +17,8 @@ export interface CToastHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
17
17
|
|
|
18
18
|
export const CToastHeader = forwardRef<HTMLDivElement, CToastHeaderProps>(
|
|
19
19
|
({ children, className, closeButton, ...rest }, ref) => {
|
|
20
|
-
const _className = classNames('toast-header', className)
|
|
21
20
|
return (
|
|
22
|
-
<div className={
|
|
21
|
+
<div className={classNames('toast-header', className)} {...rest} ref={ref}>
|
|
23
22
|
{children}
|
|
24
23
|
{closeButton && <CToastClose />}
|
|
25
24
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes, useEffect, useState, useRef, ReactElement } from 'react'
|
|
2
|
-
import { createPortal } from 'react-dom'
|
|
3
2
|
import PropTypes from 'prop-types'
|
|
4
3
|
import classNames from 'classnames'
|
|
4
|
+
import { CConditionalPortal } from '../conditional-portal'
|
|
5
5
|
|
|
6
6
|
export interface CToasterProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
7
|
/**
|
|
@@ -52,32 +52,32 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
|
|
|
52
52
|
])
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
return (
|
|
56
|
+
<CConditionalPortal portal={typeof placement === 'string'}>
|
|
57
|
+
{toasts.length > 0 || children ? (
|
|
58
|
+
<div
|
|
59
|
+
className={classNames(
|
|
60
|
+
'toaster toast-container p-3',
|
|
61
|
+
{
|
|
62
|
+
'position-fixed': placement,
|
|
63
|
+
'top-0': placement && placement.includes('top'),
|
|
64
|
+
'top-50 translate-middle-y': placement && placement.includes('middle'),
|
|
65
|
+
'bottom-0': placement && placement.includes('bottom'),
|
|
66
|
+
'start-0': placement && placement.includes('start'),
|
|
67
|
+
'start-50 translate-middle-x': placement && placement.includes('center'),
|
|
68
|
+
'end-0': placement && placement.includes('end'),
|
|
69
|
+
},
|
|
70
|
+
className,
|
|
71
|
+
)}
|
|
72
|
+
{...rest}
|
|
73
|
+
ref={ref}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
{toasts.map((toast) => React.cloneElement(toast, { visible: true }))}
|
|
77
|
+
</div>
|
|
78
|
+
) : null}
|
|
79
|
+
</CConditionalPortal>
|
|
67
80
|
)
|
|
68
|
-
|
|
69
|
-
const toaster = (ref?: React.Ref<HTMLDivElement>) => {
|
|
70
|
-
return toasts.length > 0 || children ? (
|
|
71
|
-
<div className={_className} {...rest} ref={ref}>
|
|
72
|
-
{children}
|
|
73
|
-
{toasts.map((toast) => React.cloneElement(toast, { visible: true }))}
|
|
74
|
-
</div>
|
|
75
|
-
) : null
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return typeof window !== 'undefined' && placement
|
|
79
|
-
? createPortal(toaster(ref), document.body)
|
|
80
|
-
: toaster(ref)
|
|
81
81
|
},
|
|
82
82
|
)
|
|
83
83
|
|
|
@@ -32,7 +32,7 @@ test('CToast customize', async () => {
|
|
|
32
32
|
})
|
|
33
33
|
|
|
34
34
|
test('CToast click on dismiss button', async () => {
|
|
35
|
-
jest.useFakeTimers()
|
|
35
|
+
// jest.useFakeTimers()
|
|
36
36
|
const onClose = jest.fn()
|
|
37
37
|
const { container } = render(
|
|
38
38
|
<CToast
|
|
@@ -71,6 +71,7 @@ test('CToast click on dismiss button', async () => {
|
|
|
71
71
|
fireEvent.click(btn)
|
|
72
72
|
}
|
|
73
73
|
jest.runAllTimers()
|
|
74
|
+
await new Promise((r) => setTimeout(r, 1000))
|
|
74
75
|
expect(onClose).toHaveBeenCalledTimes(1)
|
|
75
76
|
expect(container.firstChild).toBeNull()
|
|
76
77
|
jest.useRealTimers()
|
|
@@ -5,72 +5,7 @@ exports[`CToast customize 1`] = `
|
|
|
5
5
|
<div
|
|
6
6
|
aria-atomic="true"
|
|
7
7
|
aria-live="assertive"
|
|
8
|
-
class="toast fade bg-warning border-0
|
|
9
|
-
role="alert"
|
|
10
|
-
>
|
|
11
|
-
Test
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
exports[`CToast customize 2`] = `
|
|
17
|
-
<div>
|
|
18
|
-
<div
|
|
19
|
-
aria-atomic="true"
|
|
20
|
-
aria-live="assertive"
|
|
21
|
-
class="toast fade bg-warning border-0 bazinga showing"
|
|
22
|
-
role="alert"
|
|
23
|
-
>
|
|
24
|
-
Test
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
exports[`CToast customize 3`] = `
|
|
30
|
-
<div>
|
|
31
|
-
<div
|
|
32
|
-
aria-atomic="true"
|
|
33
|
-
aria-live="assertive"
|
|
34
|
-
class="toast fade bg-warning border-0 bazinga showing"
|
|
35
|
-
role="alert"
|
|
36
|
-
>
|
|
37
|
-
Test
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
exports[`CToast customize 4`] = `
|
|
43
|
-
<div>
|
|
44
|
-
<div
|
|
45
|
-
aria-atomic="true"
|
|
46
|
-
aria-live="assertive"
|
|
47
|
-
class="toast fade bg-warning border-0 bazinga showing"
|
|
48
|
-
role="alert"
|
|
49
|
-
>
|
|
50
|
-
Test
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
exports[`CToast customize 5`] = `
|
|
56
|
-
<div>
|
|
57
|
-
<div
|
|
58
|
-
aria-atomic="true"
|
|
59
|
-
aria-live="assertive"
|
|
60
|
-
class="toast fade bg-warning border-0 bazinga showing"
|
|
61
|
-
role="alert"
|
|
62
|
-
>
|
|
63
|
-
Test
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
exports[`CToast customize 6`] = `
|
|
69
|
-
<div>
|
|
70
|
-
<div
|
|
71
|
-
aria-atomic="true"
|
|
72
|
-
aria-live="assertive"
|
|
73
|
-
class="toast fade bg-warning border-0 bazinga show"
|
|
8
|
+
class="toast fade bg-warning border-0 show showing bazinga"
|
|
74
9
|
role="alert"
|
|
75
10
|
>
|
|
76
11
|
Test
|