@coreui/react-pro 4.9.0-next.1 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/conditional-portal/CConditionalPortal.d.ts +12 -0
- package/dist/components/conditional-portal/index.d.ts +2 -0
- package/dist/components/form/CFormCheck.d.ts +7 -1
- package/dist/components/form/CFormSwitch.d.ts +6 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/table/CTableResponsiveWrapper.d.ts +0 -1
- package/dist/index.es.js +498 -720
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +497 -718
- package/dist/index.js.map +1 -1
- package/package.json +11 -6
- package/src/components/accordion/CAccordion.tsx +7 -3
- package/src/components/accordion/CAccordionBody.tsx +1 -2
- package/src/components/accordion/CAccordionButton.tsx +1 -3
- package/src/components/accordion/CAccordionHeader.tsx +1 -3
- package/src/components/accordion/CAccordionItem.tsx +2 -4
- package/src/components/accordion/__tests__/__snapshots__/CAccordionBody.spec.tsx.snap +2 -2
- package/src/components/alert/CAlert.tsx +19 -27
- package/src/components/alert/CAlertHeading.tsx +1 -3
- package/src/components/alert/CAlertLink.tsx +1 -3
- package/src/components/alert/__tests__/__snapshots__/CAlert.spec.tsx.snap +1 -1
- package/src/components/avatar/CAvatar.tsx +14 -11
- package/src/components/backdrop/CBackdrop.tsx +9 -12
- package/src/components/badge/CBadge.tsx +19 -17
- package/src/components/breadcrumb/CBreadcrumb.tsx +1 -2
- package/src/components/breadcrumb/CBreadcrumbItem.tsx +12 -8
- package/src/components/button/CButton.tsx +7 -9
- package/src/components/button-group/CButtonGroup.tsx +9 -7
- package/src/components/button-group/CButtonToolbar.tsx +1 -3
- package/src/components/calendar/utils.ts +7 -9
- package/src/components/callout/CCallout.tsx +11 -9
- package/src/components/card/CCard.tsx +12 -10
- package/src/components/card/CCardBody.tsx +1 -3
- package/src/components/card/CCardFooter.tsx +1 -3
- package/src/components/card/CCardGroup.tsx +1 -3
- package/src/components/card/CCardHeader.tsx +1 -3
- package/src/components/card/CCardImage.tsx +5 -3
- package/src/components/card/CCardImageOverlay.tsx +1 -3
- package/src/components/card/CCardLink.tsx +1 -3
- package/src/components/card/CCardSubtitle.tsx +1 -3
- package/src/components/card/CCardText.tsx +1 -3
- package/src/components/card/CCardTitle.tsx +1 -3
- package/src/components/carousel/CCarousel.tsx +8 -8
- package/src/components/carousel/CCarouselCaption.tsx +1 -3
- package/src/components/carousel/CCarouselItem.tsx +11 -9
- package/src/components/close-button/CCloseButton.tsx +9 -10
- package/src/components/collapse/CCollapse.tsx +8 -20
- package/src/components/collapse/__tests__/CCollapse.spec.tsx +2 -3
- package/src/components/conditional-portal/CConditionalPortal.tsx +29 -0
- package/src/components/conditional-portal/index.ts +3 -0
- package/src/components/date-range-picker/CDateRangePicker.tsx +9 -11
- package/src/components/date-range-picker/utils.ts +2 -2
- package/src/components/dropdown/CDropdown.tsx +24 -22
- package/src/components/dropdown/CDropdownDivider.tsx +1 -3
- package/src/components/dropdown/CDropdownHeader.tsx +1 -3
- package/src/components/dropdown/CDropdownItem.tsx +6 -3
- package/src/components/dropdown/CDropdownItemPlain.tsx +1 -3
- package/src/components/dropdown/CDropdownMenu.tsx +27 -31
- package/src/components/dropdown/CDropdownToggle.tsx +29 -23
- package/src/components/dropdown/__tests__/CDropdown.spec.tsx +2 -4
- package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
- package/src/components/footer/CFooter.tsx +5 -3
- package/src/components/form/CForm.tsx +5 -2
- package/src/components/form/CFormCheck.tsx +87 -63
- package/src/components/form/CFormControlWrapper.tsx +3 -3
- package/src/components/form/CFormFeedback.tsx +11 -8
- package/src/components/form/CFormFloating.tsx +1 -2
- package/src/components/form/CFormInput.tsx +10 -12
- package/src/components/form/CFormLabel.tsx +1 -2
- package/src/components/form/CFormRange.tsx +1 -2
- package/src/components/form/CFormSelect.tsx +15 -10
- package/src/components/form/CFormSwitch.tsx +31 -20
- package/src/components/form/CFormText.tsx +1 -2
- package/src/components/form/CFormTextarea.tsx +13 -9
- package/src/components/form/CInputGroup.tsx +11 -8
- package/src/components/form/CInputGroupText.tsx +1 -2
- package/src/components/form/__tests__/CFormRange.spec.tsx +1 -1
- package/src/components/form/__tests__/__snapshots__/CForm.spec.tsx.snap +2 -6
- package/src/components/form/__tests__/__snapshots__/CFormRange.spec.tsx.snap +2 -2
- package/src/components/grid/CCol.tsx +8 -6
- package/src/components/grid/CContainer.tsx +8 -6
- package/src/components/grid/CRow.tsx +4 -3
- package/src/components/header/CHeader.tsx +12 -13
- package/src/components/header/CHeaderBrand.tsx +1 -3
- package/src/components/header/CHeaderBrand.tsx~HEAD +1 -3
- package/src/components/header/CHeaderDivider.tsx +1 -3
- package/src/components/header/CHeaderNav.tsx +6 -3
- package/src/components/header/CHeaderText.tsx +1 -3
- package/src/components/header/CHeaderToggler.tsx +2 -4
- package/src/components/image/CImage.tsx +17 -10
- package/src/components/image/__tests__/__snapshots__/CImage.spec.tsx.snap +1 -3
- package/src/components/index.ts +1 -0
- package/src/components/link/CLink.tsx +2 -4
- package/src/components/list-group/CListGroup.tsx +11 -10
- package/src/components/list-group/CListGroupItem.tsx +13 -12
- package/src/components/loading-button/CLoadingButton.tsx +1 -3
- package/src/components/modal/CModal.tsx +55 -70
- package/src/components/modal/CModalBody.tsx +1 -3
- package/src/components/modal/CModalContent.tsx +1 -3
- package/src/components/modal/CModalDialog.tsx +16 -14
- package/src/components/modal/CModalFooter.tsx +1 -3
- package/src/components/modal/CModalHeader.tsx +1 -2
- package/src/components/modal/CModalTitle.tsx +1 -3
- package/src/components/modal/__tests__/CModal.spec.tsx +19 -20
- package/src/components/multi-select/CMultiSelect.tsx +19 -19
- package/src/components/multi-select/utils.ts +3 -3
- package/src/components/nav/CNav.tsx +13 -10
- package/src/components/nav/CNavGroup.tsx +1 -3
- package/src/components/nav/CNavGroupItems.tsx +1 -2
- package/src/components/nav/CNavItem.tsx +8 -10
- package/src/components/nav/CNavLink.tsx +1 -2
- package/src/components/nav/CNavTitle.tsx +1 -2
- package/src/components/navbar/CNavbar.tsx +21 -22
- package/src/components/navbar/CNavbarBrand.tsx +2 -3
- package/src/components/navbar/CNavbarNav.tsx +6 -3
- package/src/components/navbar/CNavbarText.tsx +1 -3
- package/src/components/navbar/CNavbarToggler.tsx +2 -4
- package/src/components/offcanvas/COffcanvas.tsx +39 -66
- package/src/components/offcanvas/COffcanvasBody.tsx +1 -3
- package/src/components/offcanvas/COffcanvasHeader.tsx +1 -3
- package/src/components/offcanvas/COffcanvasTitle.tsx +1 -3
- package/src/components/offcanvas/__tests__/COffcanvas.spec.tsx +7 -2
- package/src/components/offcanvas/__tests__/__snapshots__/COffcanvas.spec.tsx.snap +9 -4
- package/src/components/pagination/CPagination.tsx +12 -9
- package/src/components/pagination/CPaginationItem.tsx +12 -11
- package/src/components/pagination/__tests__/CPagination.spec.tsx +3 -3
- package/src/components/pagination/__tests__/CPaginationItem.spec.tsx +3 -3
- package/src/components/picker/CPicker.tsx +6 -6
- package/src/components/placeholder/CPlaceholder.tsx +13 -11
- package/src/components/popover/CPopover.tsx +22 -33
- package/src/components/progress/CProgress.tsx +12 -10
- package/src/components/progress/CProgressBar.tsx +9 -11
- package/src/components/sidebar/CSidebar.tsx +20 -18
- package/src/components/sidebar/CSidebarBrand.tsx +1 -2
- package/src/components/sidebar/CSidebarFooter.tsx +1 -2
- package/src/components/sidebar/CSidebarHeader.tsx +1 -2
- package/src/components/sidebar/CSidebarNav.tsx +2 -2
- package/src/components/sidebar/CSidebarToggler.tsx +1 -2
- package/src/components/smart-pagination/CSmartPagination.tsx +22 -20
- package/src/components/smart-table/CSmartTable.tsx +4 -8
- package/src/components/smart-table/utils.ts +3 -4
- package/src/components/spinner/CSpinner.tsx +11 -8
- package/src/components/table/CTable.tsx +20 -18
- package/src/components/table/CTableBody.tsx +12 -8
- package/src/components/table/CTableDataCell.tsx +14 -10
- package/src/components/table/CTableFoot.tsx +12 -8
- package/src/components/table/CTableHead.tsx +12 -8
- package/src/components/table/CTableHeaderCell.tsx +12 -8
- package/src/components/table/CTableResponsiveWrapper.tsx +2 -3
- package/src/components/table/CTableRow.tsx +14 -10
- package/src/components/table/__tests__/__snapshots__/CTable.spec.tsx.snap +1 -5
- package/src/components/table/utils.ts +2 -7
- package/src/components/tabs/CTabContent.tsx +1 -2
- package/src/components/tabs/CTabPane.tsx +17 -20
- package/src/components/tabs/__tests__/CTabPane.spec.tsx +2 -5
- package/src/components/tabs/__tests__/__snapshots__/CTabPane.spec.tsx.snap +1 -1
- package/src/components/time-picker/CTimePicker.tsx +12 -14
- package/src/components/toast/CToast.tsx +29 -42
- package/src/components/toast/CToastBody.tsx +1 -2
- package/src/components/toast/CToastClose.tsx +3 -1
- package/src/components/toast/CToastHeader.tsx +1 -2
- package/src/components/toast/CToaster.tsx +26 -26
- package/src/components/toast/__tests__/CToast.spec.tsx +2 -1
- package/src/components/toast/__tests__/__snapshots__/CToast.spec.tsx.snap +1 -66
- package/src/components/tooltip/CTooltip.tsx +21 -32
- package/src/components/virtual-scroller/CVirtualScroller.tsx +4 -6
- package/src/components/widgets/CWidgetStatsA.tsx +8 -6
- package/src/components/widgets/CWidgetStatsD.tsx +9 -10
- package/src/components/widgets/CWidgetStatsE.tsx +1 -3
- package/src/components/widgets/CWidgetStatsF.tsx +1 -4
|
@@ -85,16 +85,6 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
85
85
|
setVisible(visible)
|
|
86
86
|
}, [visible])
|
|
87
87
|
|
|
88
|
-
const getTransitionClass = (state: string) => {
|
|
89
|
-
return state === 'entering'
|
|
90
|
-
? 'fade'
|
|
91
|
-
: state === 'entered'
|
|
92
|
-
? 'fade show'
|
|
93
|
-
: state === 'exiting'
|
|
94
|
-
? 'fade'
|
|
95
|
-
: 'fade'
|
|
96
|
-
}
|
|
97
|
-
|
|
98
88
|
return (
|
|
99
89
|
<>
|
|
100
90
|
{React.cloneElement(children as React.ReactElement<any>, {
|
|
@@ -125,29 +115,28 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
125
115
|
}}
|
|
126
116
|
unmountOnExit
|
|
127
117
|
>
|
|
128
|
-
{(state) =>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}}
|
|
118
|
+
{(state) => (
|
|
119
|
+
<div
|
|
120
|
+
className={classNames(
|
|
121
|
+
'popover',
|
|
122
|
+
`bs-popover-${placement.replace('left', 'start').replace('right', 'end')}`,
|
|
123
|
+
'fade',
|
|
124
|
+
{
|
|
125
|
+
show: state === 'entered',
|
|
126
|
+
},
|
|
127
|
+
className,
|
|
128
|
+
)}
|
|
129
|
+
ref={setPopperElement}
|
|
130
|
+
role="tooltip"
|
|
131
|
+
style={styles.popper}
|
|
132
|
+
{...attributes.popper}
|
|
133
|
+
{...rest}
|
|
134
|
+
>
|
|
135
|
+
<div className="popover-arrow" style={styles.arrow} ref={setArrowElement}></div>
|
|
136
|
+
<div className="popover-header">{title}</div>
|
|
137
|
+
<div className="popover-body">{content}</div>
|
|
138
|
+
</div>
|
|
139
|
+
)}
|
|
151
140
|
</Transition>,
|
|
152
141
|
document.body,
|
|
153
142
|
)}
|
|
@@ -31,17 +31,19 @@ export interface CProgressProps
|
|
|
31
31
|
|
|
32
32
|
export const CProgress = forwardRef<HTMLDivElement, CProgressProps>(
|
|
33
33
|
({ children, className, height, thin, value = 0, white, ...rest }, ref) => {
|
|
34
|
-
const _className = classNames(
|
|
35
|
-
'progress',
|
|
36
|
-
{
|
|
37
|
-
'progress-thin': thin,
|
|
38
|
-
'progress-white': white,
|
|
39
|
-
},
|
|
40
|
-
className,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
34
|
return (
|
|
44
|
-
<div
|
|
35
|
+
<div
|
|
36
|
+
className={classNames(
|
|
37
|
+
'progress',
|
|
38
|
+
{
|
|
39
|
+
'progress-thin': thin,
|
|
40
|
+
'progress-white': white,
|
|
41
|
+
},
|
|
42
|
+
className,
|
|
43
|
+
)}
|
|
44
|
+
style={height ? { height: `${height}px` } : {}}
|
|
45
|
+
ref={ref}
|
|
46
|
+
>
|
|
45
47
|
{value ? (
|
|
46
48
|
<CProgressBar value={value} {...rest}>
|
|
47
49
|
{children}
|
|
@@ -32,19 +32,17 @@ export interface CProgressBarProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
32
32
|
|
|
33
33
|
export const CProgressBar = forwardRef<HTMLDivElement, CProgressBarProps>(
|
|
34
34
|
({ children, animated, className, color, value = 0, variant, ...rest }, ref) => {
|
|
35
|
-
const _className = classNames(
|
|
36
|
-
'progress-bar',
|
|
37
|
-
{
|
|
38
|
-
[`bg-${color}`]: color,
|
|
39
|
-
[`progress-bar-${variant}`]: variant,
|
|
40
|
-
'progress-bar-animated': animated,
|
|
41
|
-
},
|
|
42
|
-
className,
|
|
43
|
-
)
|
|
44
|
-
|
|
45
35
|
return (
|
|
46
36
|
<div
|
|
47
|
-
className={
|
|
37
|
+
className={classNames(
|
|
38
|
+
'progress-bar',
|
|
39
|
+
{
|
|
40
|
+
[`bg-${color}`]: color,
|
|
41
|
+
[`progress-bar-${variant}`]: variant,
|
|
42
|
+
'progress-bar-animated': animated,
|
|
43
|
+
},
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
48
46
|
role="progressbar"
|
|
49
47
|
style={{ width: `${value}%` }}
|
|
50
48
|
aria-valuenow={value}
|
|
@@ -98,7 +98,7 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
|
|
|
98
98
|
}, [visible])
|
|
99
99
|
|
|
100
100
|
useEffect(() => {
|
|
101
|
-
|
|
101
|
+
inViewport !== undefined && onVisibleChange && onVisibleChange(inViewport)
|
|
102
102
|
!inViewport && onHide && onHide()
|
|
103
103
|
inViewport && onShow && onShow()
|
|
104
104
|
}, [inViewport])
|
|
@@ -169,25 +169,27 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
|
|
|
169
169
|
handleHide()
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
const _className = classNames(
|
|
173
|
-
'sidebar',
|
|
174
|
-
{
|
|
175
|
-
[`sidebar-${colorScheme}`]: colorScheme,
|
|
176
|
-
'sidebar-narrow': narrow,
|
|
177
|
-
'sidebar-overlaid': overlaid,
|
|
178
|
-
[`sidebar-${placement}`]: placement,
|
|
179
|
-
[`sidebar-${position}`]: position,
|
|
180
|
-
[`sidebar-${size}`]: size,
|
|
181
|
-
'sidebar-narrow-unfoldable': unfoldable,
|
|
182
|
-
show: _visible === true && mobile,
|
|
183
|
-
hide: _visible === false && !mobile,
|
|
184
|
-
},
|
|
185
|
-
className,
|
|
186
|
-
)
|
|
187
|
-
|
|
188
172
|
return (
|
|
189
173
|
<>
|
|
190
|
-
<div
|
|
174
|
+
<div
|
|
175
|
+
className={classNames(
|
|
176
|
+
'sidebar',
|
|
177
|
+
{
|
|
178
|
+
[`sidebar-${colorScheme}`]: colorScheme,
|
|
179
|
+
'sidebar-narrow': narrow,
|
|
180
|
+
'sidebar-overlaid': overlaid,
|
|
181
|
+
[`sidebar-${placement}`]: placement,
|
|
182
|
+
[`sidebar-${position}`]: position,
|
|
183
|
+
[`sidebar-${size}`]: size,
|
|
184
|
+
'sidebar-narrow-unfoldable': unfoldable,
|
|
185
|
+
show: _visible === true && mobile,
|
|
186
|
+
hide: _visible === false && !mobile,
|
|
187
|
+
},
|
|
188
|
+
className,
|
|
189
|
+
)}
|
|
190
|
+
{...rest}
|
|
191
|
+
ref={forkedRef}
|
|
192
|
+
>
|
|
191
193
|
{children}
|
|
192
194
|
</div>
|
|
193
195
|
{typeof window !== 'undefined' &&
|
|
@@ -11,9 +11,8 @@ export interface CSidebarBrandProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CSidebarBrand = forwardRef<HTMLDivElement, CSidebarBrandProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('sidebar-brand', className)
|
|
15
14
|
return (
|
|
16
|
-
<div className={
|
|
15
|
+
<div className={classNames('sidebar-brand', className)} ref={ref} {...rest}>
|
|
17
16
|
{children}
|
|
18
17
|
</div>
|
|
19
18
|
)
|
|
@@ -11,9 +11,8 @@ export interface CSidebarFooterProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CSidebarFooter = forwardRef<HTMLDivElement, CSidebarFooterProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('sidebar-footer', className)
|
|
15
14
|
return (
|
|
16
|
-
<div className={
|
|
15
|
+
<div className={classNames('sidebar-footer', className)} ref={ref} {...rest}>
|
|
17
16
|
{children}
|
|
18
17
|
</div>
|
|
19
18
|
)
|
|
@@ -11,9 +11,8 @@ export interface CSidebarHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const CSidebarHeader = forwardRef<HTMLDivElement, CSidebarHeaderProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('sidebar-header', className)
|
|
15
14
|
return (
|
|
16
|
-
<div className={
|
|
15
|
+
<div className={classNames('sidebar-header', className)} ref={ref} {...rest}>
|
|
17
16
|
{children}
|
|
18
17
|
</div>
|
|
19
18
|
)
|
|
@@ -23,9 +23,9 @@ export const CSidebarNav = forwardRef<HTMLUListElement, CSidebarNavProps>(
|
|
|
23
23
|
visibleGroup,
|
|
24
24
|
setVisibleGroup,
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
return (
|
|
28
|
-
<ul className={
|
|
28
|
+
<ul className={classNames('sidebar-nav', className)} ref={ref} {...rest}>
|
|
29
29
|
<CNavContext.Provider value={CNavContextValues}>
|
|
30
30
|
{React.Children.map(children, (child, index) => {
|
|
31
31
|
if (React.isValidElement(child)) {
|
|
@@ -11,9 +11,8 @@ export interface CSidebarTogglerProps extends HTMLAttributes<HTMLButtonElement>
|
|
|
11
11
|
|
|
12
12
|
export const CSidebarToggler = forwardRef<HTMLButtonElement, CSidebarTogglerProps>(
|
|
13
13
|
({ children, className, ...rest }, ref) => {
|
|
14
|
-
const _className = classNames('sidebar-toggler', className)
|
|
15
14
|
return (
|
|
16
|
-
<button className={
|
|
15
|
+
<button className={classNames('sidebar-toggler', className)} ref={ref} {...rest}>
|
|
17
16
|
{children}
|
|
18
17
|
</button>
|
|
19
18
|
)
|
|
@@ -92,8 +92,6 @@ export const CSmartPagination = forwardRef<HTMLUListElement, CSmartPaginationPro
|
|
|
92
92
|
},
|
|
93
93
|
ref,
|
|
94
94
|
) => {
|
|
95
|
-
const _classNames = classNames(`justify-content-${align}`, className)
|
|
96
|
-
|
|
97
95
|
const showDots: boolean = (() => {
|
|
98
96
|
return dots && limit > 4 && limit < pages
|
|
99
97
|
})()
|
|
@@ -131,23 +129,21 @@ export const CSmartPagination = forwardRef<HTMLUListElement, CSmartPaginationPro
|
|
|
131
129
|
})()
|
|
132
130
|
|
|
133
131
|
const items: number[] = (() => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
).reverse()
|
|
150
|
-
}
|
|
132
|
+
return activePage - maxPrevItems <= 1
|
|
133
|
+
? Array.from(
|
|
134
|
+
{
|
|
135
|
+
length: itemsAmount,
|
|
136
|
+
},
|
|
137
|
+
(_v, i) => i + 1,
|
|
138
|
+
)
|
|
139
|
+
: Array.from(
|
|
140
|
+
{
|
|
141
|
+
length: itemsAmount,
|
|
142
|
+
},
|
|
143
|
+
(_v, i) => {
|
|
144
|
+
return lastItem - i
|
|
145
|
+
},
|
|
146
|
+
).reverse()
|
|
151
147
|
})()
|
|
152
148
|
|
|
153
149
|
const setPage = (number: number): void => {
|
|
@@ -157,7 +153,13 @@ export const CSmartPagination = forwardRef<HTMLUListElement, CSmartPaginationPro
|
|
|
157
153
|
}
|
|
158
154
|
|
|
159
155
|
return (
|
|
160
|
-
<CPagination
|
|
156
|
+
<CPagination
|
|
157
|
+
className={classNames(`justify-content-${align}`, className)}
|
|
158
|
+
aria-label="pagination"
|
|
159
|
+
size={size}
|
|
160
|
+
{...rest}
|
|
161
|
+
ref={ref}
|
|
162
|
+
>
|
|
161
163
|
{doubleArrows && (
|
|
162
164
|
<CPaginationItem
|
|
163
165
|
onClick={() => setPage(1)}
|
|
@@ -284,7 +284,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
//if column changed or sort was descending change asc to true
|
|
287
|
-
const state = sorterState
|
|
287
|
+
const state = sorterState ?? { column: '', state: '' }
|
|
288
288
|
|
|
289
289
|
if (state.column === column) {
|
|
290
290
|
if (state.state === 0) {
|
|
@@ -292,11 +292,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
292
292
|
} else if (state.state === 'asc') {
|
|
293
293
|
state.state = 'desc'
|
|
294
294
|
} else {
|
|
295
|
-
|
|
296
|
-
state.state = 'asc'
|
|
297
|
-
} else {
|
|
298
|
-
state.state = 0
|
|
299
|
-
}
|
|
295
|
+
state.state = typeof columnSorter === 'object' && !columnSorter.resetable ? 'asc' : 0
|
|
300
296
|
}
|
|
301
297
|
} else {
|
|
302
298
|
state.column = column
|
|
@@ -378,7 +374,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
378
374
|
{...tableHeadProps}
|
|
379
375
|
columnFilter={columnFilter}
|
|
380
376
|
columnFilterState={columnFilterState}
|
|
381
|
-
columns={columns
|
|
377
|
+
columns={columns ?? columnNames}
|
|
382
378
|
columnSorter={columnSorter}
|
|
383
379
|
items={_items}
|
|
384
380
|
selectable={selectable}
|
|
@@ -418,7 +414,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
418
414
|
{...tableFootProps}
|
|
419
415
|
columnFilter={false}
|
|
420
416
|
columnSorter={false}
|
|
421
|
-
columns={columns
|
|
417
|
+
columns={columns ?? columnNames}
|
|
422
418
|
items={_items}
|
|
423
419
|
handleSelectAllChecked={() => handleSelectAllChecked()}
|
|
424
420
|
selectable={selectable}
|
|
@@ -80,8 +80,7 @@ export const getColumnLabel = (column: Column | string) =>
|
|
|
80
80
|
export const getColumnNames = (columns: (string | Column)[] | undefined, items: Item[]) =>
|
|
81
81
|
columns
|
|
82
82
|
? columns.map((column: Column | string) => {
|
|
83
|
-
|
|
84
|
-
else return column
|
|
83
|
+
return typeof column === 'object' ? column.key : column
|
|
85
84
|
})
|
|
86
85
|
: getColumnNamesFromItems(items)
|
|
87
86
|
|
|
@@ -132,7 +131,7 @@ export const getTableHeaderCellStyles = (
|
|
|
132
131
|
if (
|
|
133
132
|
columnSorter &&
|
|
134
133
|
(typeof column !== 'object' ||
|
|
135
|
-
(typeof column === 'object' && (
|
|
134
|
+
(typeof column === 'object' && (column.sorter === undefined || column.sorter)))
|
|
136
135
|
) {
|
|
137
136
|
style['cursor'] = 'pointer'
|
|
138
137
|
}
|
|
@@ -157,7 +156,7 @@ export const isSortable = (
|
|
|
157
156
|
columnSorter &&
|
|
158
157
|
(!columns ||
|
|
159
158
|
typeof column !== 'object' ||
|
|
160
|
-
(typeof column === 'object' && (
|
|
159
|
+
(typeof column === 'object' && (column.sorter === undefined || column.sorter))) &&
|
|
161
160
|
isDataColumn
|
|
162
161
|
)
|
|
163
162
|
}
|
|
@@ -47,15 +47,18 @@ export const CSpinner = forwardRef<HTMLDivElement | HTMLSpanElement, CSpinnerPro
|
|
|
47
47
|
},
|
|
48
48
|
ref,
|
|
49
49
|
) => {
|
|
50
|
-
const _className = classNames(
|
|
51
|
-
`spinner-${variant}`,
|
|
52
|
-
`text-${color}`,
|
|
53
|
-
size && `spinner-${variant}-${size}`,
|
|
54
|
-
className,
|
|
55
|
-
)
|
|
56
|
-
|
|
57
50
|
return (
|
|
58
|
-
<Component
|
|
51
|
+
<Component
|
|
52
|
+
className={classNames(
|
|
53
|
+
`spinner-${variant}`,
|
|
54
|
+
`text-${color}`,
|
|
55
|
+
size && `spinner-${variant}-${size}`,
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
role="status"
|
|
59
|
+
{...rest}
|
|
60
|
+
ref={ref}
|
|
61
|
+
>
|
|
59
62
|
<span className="visually-hidden">{visuallyHiddenLabel}</span>
|
|
60
63
|
</Component>
|
|
61
64
|
)
|
|
@@ -153,28 +153,30 @@ export const CTable = forwardRef<HTMLTableElement, CTableProps>(
|
|
|
153
153
|
},
|
|
154
154
|
ref,
|
|
155
155
|
) => {
|
|
156
|
-
const _className = classNames(
|
|
157
|
-
'table',
|
|
158
|
-
{
|
|
159
|
-
[`align-${align}`]: align,
|
|
160
|
-
[`border-${borderColor}`]: borderColor,
|
|
161
|
-
[`caption-top`]: captionTop || caption === 'top',
|
|
162
|
-
'table-bordered': bordered,
|
|
163
|
-
'table-borderless': borderless,
|
|
164
|
-
[`table-${color}`]: color,
|
|
165
|
-
'table-hover': hover,
|
|
166
|
-
'table-sm': small,
|
|
167
|
-
'table-striped': striped,
|
|
168
|
-
'table-striped-columns': stripedColumns,
|
|
169
|
-
},
|
|
170
|
-
className,
|
|
171
|
-
)
|
|
172
|
-
|
|
173
156
|
const columnNames = useMemo(() => getColumnNames(columns, items), [columns, items])
|
|
174
157
|
|
|
175
158
|
return (
|
|
176
159
|
<CTableResponsiveWrapper responsive={responsive}>
|
|
177
|
-
<table
|
|
160
|
+
<table
|
|
161
|
+
className={classNames(
|
|
162
|
+
'table',
|
|
163
|
+
{
|
|
164
|
+
[`align-${align}`]: align,
|
|
165
|
+
[`border-${borderColor}`]: borderColor,
|
|
166
|
+
[`caption-top`]: captionTop || caption === 'top',
|
|
167
|
+
'table-bordered': bordered,
|
|
168
|
+
'table-borderless': borderless,
|
|
169
|
+
[`table-${color}`]: color,
|
|
170
|
+
'table-hover': hover,
|
|
171
|
+
'table-sm': small,
|
|
172
|
+
'table-striped': striped,
|
|
173
|
+
'table-striped-columns': stripedColumns,
|
|
174
|
+
},
|
|
175
|
+
className,
|
|
176
|
+
)}
|
|
177
|
+
{...rest}
|
|
178
|
+
ref={ref}
|
|
179
|
+
>
|
|
178
180
|
{((caption && caption !== 'top') || captionTop) && (
|
|
179
181
|
<CTableCaption>{caption || captionTop}</CTableCaption>
|
|
180
182
|
)}
|
|
@@ -20,15 +20,19 @@ export interface CTableBodyProps extends HTMLAttributes<HTMLTableSectionElement>
|
|
|
20
20
|
|
|
21
21
|
export const CTableBody = forwardRef<HTMLTableSectionElement, CTableBodyProps>(
|
|
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
|
-
<tbody
|
|
24
|
+
<tbody
|
|
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
|
</tbody>
|
|
34
38
|
)
|
|
@@ -34,19 +34,23 @@ export interface CTableDataCellProps
|
|
|
34
34
|
|
|
35
35
|
export const CTableDataCell = forwardRef<HTMLTableCellElement, CTableDataCellProps>(
|
|
36
36
|
({ children, active, align, className, color, ...rest }, ref) => {
|
|
37
|
-
const _className = classNames(
|
|
38
|
-
{
|
|
39
|
-
[`align-${align}`]: align,
|
|
40
|
-
'table-active': active,
|
|
41
|
-
[`table-${color}`]: color,
|
|
42
|
-
},
|
|
43
|
-
className,
|
|
44
|
-
)
|
|
45
|
-
|
|
46
37
|
const Component = rest.scope ? 'th' : 'td'
|
|
47
38
|
|
|
48
39
|
return (
|
|
49
|
-
<Component
|
|
40
|
+
<Component
|
|
41
|
+
className={
|
|
42
|
+
classNames(
|
|
43
|
+
{
|
|
44
|
+
[`align-${align}`]: align,
|
|
45
|
+
'table-active': active,
|
|
46
|
+
[`table-${color}`]: color,
|
|
47
|
+
},
|
|
48
|
+
className,
|
|
49
|
+
) || undefined
|
|
50
|
+
}
|
|
51
|
+
{...rest}
|
|
52
|
+
ref={ref}
|
|
53
|
+
>
|
|
50
54
|
{children}
|
|
51
55
|
</Component>
|
|
52
56
|
)
|
|
@@ -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
|
)
|