@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
|
@@ -4,6 +4,7 @@ import classNames from 'classnames'
|
|
|
4
4
|
import { Transition } from 'react-transition-group'
|
|
5
5
|
|
|
6
6
|
import { useForkedRef } from '../../hooks'
|
|
7
|
+
|
|
7
8
|
export interface CTabPaneProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
9
|
/**
|
|
9
10
|
* A string of all className you want applied to the base component.
|
|
@@ -28,28 +29,25 @@ export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
|
|
|
28
29
|
const tabPaneRef = useRef()
|
|
29
30
|
const forkedRef = useForkedRef(ref, tabPaneRef)
|
|
30
31
|
|
|
31
|
-
const getTransitionClass = (state: string) => {
|
|
32
|
-
return state === 'entered' && 'show'
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const _className = classNames(
|
|
36
|
-
'tab-pane',
|
|
37
|
-
'fade',
|
|
38
|
-
{
|
|
39
|
-
active: visible,
|
|
40
|
-
},
|
|
41
|
-
className,
|
|
42
|
-
)
|
|
43
32
|
return (
|
|
44
33
|
<Transition in={visible} nodeRef={tabPaneRef} onEnter={onShow} onExit={onHide} timeout={150}>
|
|
45
|
-
{(state) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
)}
|
|
53
51
|
</Transition>
|
|
54
52
|
)
|
|
55
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
|
})
|
|
@@ -127,15 +127,13 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
127
127
|
hour12: false,
|
|
128
128
|
})
|
|
129
129
|
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
setLocalizedTimePartials(getLocalizedTimePartials(locale, ampm))
|
|
132
|
-
}, [date])
|
|
133
|
-
|
|
134
130
|
useEffect(() => {
|
|
135
131
|
setDate(convertTimeToDate(time))
|
|
136
132
|
}, [time])
|
|
137
133
|
|
|
138
134
|
useEffect(() => {
|
|
135
|
+
setLocalizedTimePartials(getLocalizedTimePartials(locale, ampm))
|
|
136
|
+
|
|
139
137
|
if (inputRef.current) {
|
|
140
138
|
inputRef.current.value = date
|
|
141
139
|
? date.toLocaleTimeString(locale, {
|
|
@@ -168,18 +166,18 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
168
166
|
|
|
169
167
|
if (set === 'hours') {
|
|
170
168
|
if (localizedTimePartials && localizedTimePartials.hour12) {
|
|
171
|
-
_date.setHours(convert12hTo24h(_ampm, parseInt(value)))
|
|
169
|
+
_date.setHours(convert12hTo24h(_ampm, Number.parseInt(value)))
|
|
172
170
|
} else {
|
|
173
|
-
_date.setHours(parseInt(value))
|
|
171
|
+
_date.setHours(Number.parseInt(value))
|
|
174
172
|
}
|
|
175
173
|
}
|
|
176
174
|
|
|
177
175
|
if (set === 'minutes') {
|
|
178
|
-
_date.setMinutes(parseInt(value))
|
|
176
|
+
_date.setMinutes(Number.parseInt(value))
|
|
179
177
|
}
|
|
180
178
|
|
|
181
179
|
if (set === 'seconds') {
|
|
182
|
-
_date.setSeconds(parseInt(value))
|
|
180
|
+
_date.setSeconds(Number.parseInt(value))
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
setDate(new Date(_date))
|
|
@@ -335,15 +333,6 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
335
333
|
</>
|
|
336
334
|
)
|
|
337
335
|
|
|
338
|
-
const _className = classNames(
|
|
339
|
-
'time-picker',
|
|
340
|
-
{
|
|
341
|
-
'is-invalid': invalid,
|
|
342
|
-
'is-valid': valid,
|
|
343
|
-
},
|
|
344
|
-
className,
|
|
345
|
-
)
|
|
346
|
-
|
|
347
336
|
return (
|
|
348
337
|
<CFormControlWrapper
|
|
349
338
|
describedby={rest['aria-describedby']}
|
|
@@ -358,7 +347,14 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
358
347
|
valid={valid}
|
|
359
348
|
>
|
|
360
349
|
<CPicker
|
|
361
|
-
className={
|
|
350
|
+
className={classNames(
|
|
351
|
+
'time-picker',
|
|
352
|
+
{
|
|
353
|
+
'is-invalid': invalid,
|
|
354
|
+
'is-valid': valid,
|
|
355
|
+
},
|
|
356
|
+
className,
|
|
357
|
+
)}
|
|
362
358
|
container={container}
|
|
363
359
|
disabled={disabled}
|
|
364
360
|
footer={footer}
|
|
@@ -6,13 +6,13 @@ import React, {
|
|
|
6
6
|
useRef,
|
|
7
7
|
useState,
|
|
8
8
|
} from 'react'
|
|
9
|
-
import { Transition } from 'react-transition-group'
|
|
10
9
|
import PropTypes from 'prop-types'
|
|
11
10
|
import classNames from 'classnames'
|
|
12
|
-
|
|
13
|
-
import { Colors, colorPropType } from '../Types'
|
|
11
|
+
import { Transition } from 'react-transition-group'
|
|
14
12
|
|
|
15
13
|
import { useForkedRef } from '../../hooks'
|
|
14
|
+
import { colorPropType } from '../../props'
|
|
15
|
+
import type { Colors } from '../../types'
|
|
16
16
|
|
|
17
17
|
export interface CToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
18
18
|
/**
|
|
@@ -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
|
-
|
|
3
|
+
|
|
4
|
+
import { CButtonProps } from '../button/CButton'
|
|
4
5
|
import { CCloseButton, CCloseButtonProps } from '../close-button/CCloseButton'
|
|
5
6
|
|
|
6
|
-
import
|
|
7
|
+
import { CToastContext } from './CToast'
|
|
7
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,8 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes, useEffect, useState, useRef, ReactElement } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { createPortal } from 'react-dom'
|
|
4
3
|
import classNames from 'classnames'
|
|
4
|
+
import { CConditionalPortal } from '../conditional-portal'
|
|
5
|
+
|
|
5
6
|
export interface CToasterProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
7
|
/**
|
|
7
8
|
* A string of all className you want applied to the base component.
|
|
@@ -51,32 +52,32 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
|
|
|
51
52
|
])
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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>
|
|
66
80
|
)
|
|
67
|
-
|
|
68
|
-
const toaster = (ref?: React.Ref<HTMLDivElement>) => {
|
|
69
|
-
return toasts.length > 0 || children ? (
|
|
70
|
-
<div className={_className} {...rest} ref={ref}>
|
|
71
|
-
{children}
|
|
72
|
-
{toasts.map((toast) => React.cloneElement(toast, { visible: true }))}
|
|
73
|
-
</div>
|
|
74
|
-
) : null
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return typeof window !== 'undefined' && placement
|
|
78
|
-
? createPortal(toaster(ref), document.body)
|
|
79
|
-
: toaster(ref)
|
|
80
81
|
},
|
|
81
82
|
)
|
|
82
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
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { FC, HTMLAttributes, ReactNode, useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { createPortal } from 'react-dom'
|
|
3
|
-
import classNames from 'classnames'
|
|
4
3
|
import PropTypes from 'prop-types'
|
|
4
|
+
import classNames from 'classnames'
|
|
5
5
|
import { usePopper } from 'react-popper'
|
|
6
6
|
import { Transition } from 'react-transition-group'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { triggerPropType } from '../../props'
|
|
9
|
+
import type { Triggers } from '../../types'
|
|
9
10
|
|
|
10
11
|
export interface CTooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
12
|
/**
|
|
@@ -79,16 +80,6 @@ export const CTooltip: FC<CTooltipProps> = ({
|
|
|
79
80
|
setVisible(visible)
|
|
80
81
|
}, [visible])
|
|
81
82
|
|
|
82
|
-
const getTransitionClass = (state: string) => {
|
|
83
|
-
return state === 'entering'
|
|
84
|
-
? 'fade'
|
|
85
|
-
: state === 'entered'
|
|
86
|
-
? 'fade show'
|
|
87
|
-
: state === 'exiting'
|
|
88
|
-
? 'fade'
|
|
89
|
-
: 'fade'
|
|
90
|
-
}
|
|
91
|
-
|
|
92
83
|
return (
|
|
93
84
|
<>
|
|
94
85
|
{React.cloneElement(children as React.ReactElement<any>, {
|
|
@@ -119,28 +110,27 @@ export const CTooltip: FC<CTooltipProps> = ({
|
|
|
119
110
|
}}
|
|
120
111
|
unmountOnExit
|
|
121
112
|
>
|
|
122
|
-
{(state) =>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}}
|
|
113
|
+
{(state) => (
|
|
114
|
+
<div
|
|
115
|
+
className={classNames(
|
|
116
|
+
'tooltip',
|
|
117
|
+
`bs-popover-${placement.replace('left', 'start').replace('right', 'end')}`,
|
|
118
|
+
'fade',
|
|
119
|
+
{
|
|
120
|
+
show: state === 'entered',
|
|
121
|
+
},
|
|
122
|
+
className,
|
|
123
|
+
)}
|
|
124
|
+
ref={setPopperElement}
|
|
125
|
+
role="tooltip"
|
|
126
|
+
style={styles.popper}
|
|
127
|
+
{...attributes.popper}
|
|
128
|
+
{...rest}
|
|
129
|
+
>
|
|
130
|
+
<div className="tooltip-arrow" style={styles.arrow} ref={setArrowElement}></div>
|
|
131
|
+
<div className="tooltip-inner">{content}</div>
|
|
132
|
+
</div>
|
|
133
|
+
)}
|
|
144
134
|
</Transition>,
|
|
145
135
|
document.body,
|
|
146
136
|
)}
|