@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
|
@@ -9,14 +9,6 @@ export interface CVirtualScrollerProps extends Omit<HTMLAttributes<HTMLDivElemen
|
|
|
9
9
|
* A string of all className you want applied to the base component.
|
|
10
10
|
*/
|
|
11
11
|
className?: string
|
|
12
|
-
/**
|
|
13
|
-
* Single item height.
|
|
14
|
-
*/
|
|
15
|
-
itemHeight?: number | 'auto'
|
|
16
|
-
/**
|
|
17
|
-
* Number of items.
|
|
18
|
-
*/
|
|
19
|
-
itemsNumber?: number
|
|
20
12
|
/**
|
|
21
13
|
* Event fires when the component has been scrolled.
|
|
22
14
|
*/
|
|
@@ -28,29 +20,26 @@ export interface CVirtualScrollerProps extends Omit<HTMLAttributes<HTMLDivElemen
|
|
|
28
20
|
}
|
|
29
21
|
|
|
30
22
|
export const CVirtualScroller = forwardRef<HTMLDivElement, CVirtualScrollerProps>(
|
|
31
|
-
({ children, className,
|
|
23
|
+
({ children, className, visibleItems, onScroll }, ref) => {
|
|
32
24
|
const virtualScrollRef = useRef<HTMLDivElement>(null)
|
|
33
25
|
const virtualScrollContentRef = useRef<HTMLDivElement>(null)
|
|
34
26
|
const forkedRef = useForkedRef(ref, virtualScrollRef)
|
|
35
27
|
|
|
36
|
-
const [
|
|
37
|
-
const [
|
|
38
|
-
const [
|
|
28
|
+
const [buffer, setBuffer] = useState(Math.floor(visibleItems / 2))
|
|
29
|
+
const [currentItemIndex, setCurrentItemIndex] = useState(1)
|
|
30
|
+
const [itemHeight, setItemHeight] = useState(0)
|
|
31
|
+
const [itemsNumber, setItemsNumber] = useState(React.Children.count(children))
|
|
39
32
|
const [viewportPadding, setViewportPadding] = useState(0)
|
|
40
33
|
const [viewportHeight, setViewportHeight] = useState(
|
|
41
|
-
visibleItems *
|
|
34
|
+
visibleItems * itemHeight + 2 * viewportPadding,
|
|
42
35
|
)
|
|
43
|
-
const [maxHeight, setMaxHeight] = useState(
|
|
44
|
-
const [topPadding, setTopPadding] = useState(0)
|
|
45
|
-
const [bottomPadding, setBottomPadding] = useState(0)
|
|
46
|
-
|
|
47
|
-
const [contentHeight, setContentHeight] = useState(0)
|
|
36
|
+
const [maxHeight, setMaxHeight] = useState(itemsNumber * itemHeight + 2 * viewportPadding)
|
|
48
37
|
|
|
49
38
|
useEffect(() => {
|
|
50
39
|
virtualScrollRef.current && virtualScrollRef.current.scrollTop
|
|
51
40
|
|
|
52
41
|
virtualScrollRef.current &&
|
|
53
|
-
setViewportPadding(parseFloat(getComputedStyle(virtualScrollRef.current).paddingTop))
|
|
42
|
+
setViewportPadding(Number.parseFloat(getComputedStyle(virtualScrollRef.current).paddingTop))
|
|
54
43
|
})
|
|
55
44
|
|
|
56
45
|
useEffect(() => {
|
|
@@ -58,42 +47,27 @@ export const CVirtualScroller = forwardRef<HTMLDivElement, CVirtualScrollerProps
|
|
|
58
47
|
}, [children, itemsNumber])
|
|
59
48
|
|
|
60
49
|
useEffect(() => {
|
|
61
|
-
setViewportHeight(visibleItems *
|
|
62
|
-
}, [viewportPadding, visibleItems,
|
|
50
|
+
setViewportHeight(visibleItems * itemHeight + 2 * viewportPadding)
|
|
51
|
+
}, [viewportPadding, visibleItems, itemHeight])
|
|
63
52
|
|
|
64
53
|
useEffect(() => {
|
|
65
|
-
setMaxHeight(
|
|
54
|
+
setMaxHeight(itemsNumber * itemHeight + 2 * viewportPadding)
|
|
66
55
|
virtualScrollRef.current && virtualScrollRef.current.scrollTop
|
|
67
|
-
|
|
68
|
-
}, [_itemsNumber, _itemHeight])
|
|
56
|
+
}, [itemsNumber, itemHeight])
|
|
69
57
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
1 +
|
|
74
|
-
Math.max(Math.floor(scrollTop / _itemHeight), 0) -
|
|
75
|
-
Math.min(
|
|
76
|
-
Math.floor(visibleItems / 2) - (Math.floor(visibleItems / 2) - currentItemIndex) - 1,
|
|
77
|
-
Math.floor(visibleItems / 2),
|
|
78
|
-
),
|
|
79
|
-
1,
|
|
80
|
-
),
|
|
81
|
-
_itemsNumber - visibleItems + 1,
|
|
82
|
-
)
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setBuffer(Math.floor(visibleItems / 2))
|
|
60
|
+
}, [visibleItems])
|
|
83
61
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setTopPadding(Math.max(_currentItemIndex * _itemHeight - _itemHeight, 0))
|
|
87
|
-
setBottomPadding(Math.max(maxHeight - topPadding - contentHeight, 0))
|
|
62
|
+
const handleScroll = (scrollTop: number) => {
|
|
63
|
+
const _currentItemIndex = itemHeight && Math.max(Math.ceil(scrollTop / itemHeight), 1)
|
|
88
64
|
setCurrentItemIndex(_currentItemIndex)
|
|
89
65
|
onScroll && onScroll(_currentItemIndex)
|
|
90
66
|
}
|
|
91
67
|
|
|
92
|
-
const _className = classNames('virtual-scroller', className)
|
|
93
|
-
|
|
94
68
|
return (
|
|
95
69
|
<div
|
|
96
|
-
className={
|
|
70
|
+
className={classNames('virtual-scroller', className)}
|
|
97
71
|
onScroll={(event: UIEvent<HTMLDivElement>) =>
|
|
98
72
|
handleScroll((event.target as HTMLDivElement).scrollTop)
|
|
99
73
|
}
|
|
@@ -103,48 +77,49 @@ export const CVirtualScroller = forwardRef<HTMLDivElement, CVirtualScrollerProps
|
|
|
103
77
|
overflowY: 'auto',
|
|
104
78
|
}}
|
|
105
79
|
>
|
|
106
|
-
<div
|
|
107
|
-
|
|
80
|
+
<div
|
|
81
|
+
className="virtual-scroller-content"
|
|
82
|
+
style={{
|
|
83
|
+
height: maxHeight,
|
|
84
|
+
}}
|
|
85
|
+
ref={virtualScrollContentRef}
|
|
86
|
+
>
|
|
108
87
|
{React.Children.map(children, (child, index) => {
|
|
109
|
-
const _index = index + 1
|
|
110
88
|
if (
|
|
111
89
|
React.isValidElement(child) &&
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
index + 1 > Math.max(currentItemIndex - buffer, 0) &&
|
|
91
|
+
index + 1 <= currentItemIndex + visibleItems + buffer
|
|
114
92
|
) {
|
|
115
93
|
return React.cloneElement(child as React.ReactElement<any>, {
|
|
116
94
|
className: classNames(child.props.className, {
|
|
117
95
|
'virtual-scroller-item-preload':
|
|
118
|
-
|
|
96
|
+
index + 1 > currentItemIndex + visibleItems || index + 1 < currentItemIndex,
|
|
119
97
|
}),
|
|
120
98
|
key: index,
|
|
99
|
+
style: {
|
|
100
|
+
...(currentItemIndex > buffer && {
|
|
101
|
+
transform: `translateY(${(currentItemIndex - buffer) * itemHeight}px)`,
|
|
102
|
+
}),
|
|
103
|
+
},
|
|
121
104
|
ref: (node: HTMLElement) =>
|
|
122
|
-
itemHeight === 'auto' &&
|
|
123
105
|
node &&
|
|
124
106
|
node.offsetHeight &&
|
|
125
107
|
setItemHeight(
|
|
126
108
|
node.offsetHeight +
|
|
127
|
-
parseFloat(getComputedStyle(node).marginTop) +
|
|
128
|
-
parseFloat(getComputedStyle(node).marginBottom),
|
|
109
|
+
Number.parseFloat(getComputedStyle(node).marginTop) +
|
|
110
|
+
Number.parseFloat(getComputedStyle(node).marginBottom),
|
|
129
111
|
),
|
|
130
112
|
})
|
|
131
113
|
}
|
|
132
114
|
return
|
|
133
115
|
})}
|
|
134
116
|
</div>
|
|
135
|
-
<div
|
|
136
|
-
style={{
|
|
137
|
-
height: bottomPadding,
|
|
138
|
-
}}
|
|
139
|
-
/>
|
|
140
117
|
</div>
|
|
141
118
|
)
|
|
142
119
|
},
|
|
143
120
|
)
|
|
144
121
|
|
|
145
122
|
CVirtualScroller.propTypes = {
|
|
146
|
-
itemHeight: PropTypes.number,
|
|
147
|
-
itemsNumber: PropTypes.number,
|
|
148
123
|
onScroll: PropTypes.func,
|
|
149
124
|
visibleItems: PropTypes.number.isRequired,
|
|
150
125
|
}
|
|
@@ -2,10 +2,10 @@ import React, { forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { CCard, CCardBody } from '../card'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { colorPropType } from '../../props'
|
|
8
|
+
import type { Colors } from '../../types'
|
|
9
9
|
|
|
10
10
|
export interface CWidgetStatsAProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
11
11
|
/**
|
|
@@ -38,13 +38,15 @@ export interface CWidgetStatsAProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
38
38
|
|
|
39
39
|
export const CWidgetStatsA = forwardRef<HTMLDivElement, CWidgetStatsAProps>(
|
|
40
40
|
({ action, chart, className, color, title, value, ...rest }, ref) => {
|
|
41
|
-
const _className = classNames(
|
|
42
|
-
{ [`bg-${color}`]: color, 'text-high-emphasis-inverse': color },
|
|
43
|
-
className,
|
|
44
|
-
)
|
|
45
|
-
|
|
46
41
|
return (
|
|
47
|
-
<CCard
|
|
42
|
+
<CCard
|
|
43
|
+
className={classNames(
|
|
44
|
+
{ [`bg-${color}`]: color, 'text-high-emphasis-inverse': color },
|
|
45
|
+
className,
|
|
46
|
+
)}
|
|
47
|
+
{...rest}
|
|
48
|
+
ref={ref}
|
|
49
|
+
>
|
|
48
50
|
<CCardBody className="pb-0 d-flex justify-content-between align-items-start">
|
|
49
51
|
<div>
|
|
50
52
|
{value && <div className="fs-4 fw-semibold">{value}</div>}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { CCard } from '../card/CCard'
|
|
7
|
-
import { CCardBody } from '../card/CCardBody'
|
|
4
|
+
import { CCard, CCardBody } from '../card'
|
|
8
5
|
import { CProgress, CProgressProps } from '../progress/CProgress'
|
|
9
6
|
|
|
7
|
+
import { colorPropType } from '../../props'
|
|
8
|
+
import type { Colors } from '../../types'
|
|
9
|
+
|
|
10
10
|
export interface CWidgetStatsBProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
11
11
|
/**
|
|
12
12
|
* A string of all className you want applied to the base component.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { CCard } from '../card/CCard'
|
|
7
|
-
import { CCardBody } from '../card/CCardBody'
|
|
4
|
+
import { CCard, CCardBody } from '../card'
|
|
8
5
|
import { CProgress, CProgressProps } from '../progress/CProgress'
|
|
9
6
|
|
|
7
|
+
import { colorPropType } from '../../props'
|
|
8
|
+
import type { Colors } from '../../types'
|
|
9
|
+
|
|
10
10
|
export interface CWidgetStatsCProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
11
11
|
/**
|
|
12
12
|
* A string of all className you want applied to the base component.
|
|
@@ -2,13 +2,12 @@ import React, { forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { CCard } from '../card/CCard'
|
|
8
|
-
import { CCardBody } from '../card/CCardBody'
|
|
9
|
-
import { CCardHeader } from '../card/CCardHeader'
|
|
5
|
+
import { CCard, CCardBody, CCardHeader } from '../card'
|
|
10
6
|
import { CCol } from '../grid/CCol'
|
|
11
7
|
|
|
8
|
+
import { colorPropType } from '../../props'
|
|
9
|
+
import type { Colors } from '../../types'
|
|
10
|
+
|
|
12
11
|
type Value = {
|
|
13
12
|
title?: string | ReactNode
|
|
14
13
|
value?: number | string | ReactNode
|
|
@@ -41,17 +40,16 @@ export interface CWidgetStatsDProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
41
40
|
|
|
42
41
|
export const CWidgetStatsD = forwardRef<HTMLDivElement, CWidgetStatsDProps>(
|
|
43
42
|
({ className, chart, color, icon, values, ...rest }, ref) => {
|
|
44
|
-
const _className = classNames(className)
|
|
45
|
-
const classNameHeader = classNames(
|
|
46
|
-
'position-relative d-flex justify-content-center align-items-center',
|
|
47
|
-
{
|
|
48
|
-
[`bg-${color}`]: color,
|
|
49
|
-
},
|
|
50
|
-
)
|
|
51
|
-
|
|
52
43
|
return (
|
|
53
|
-
<CCard className={
|
|
54
|
-
<CCardHeader
|
|
44
|
+
<CCard className={className} {...rest} ref={ref}>
|
|
45
|
+
<CCardHeader
|
|
46
|
+
className={classNames(
|
|
47
|
+
'position-relative d-flex justify-content-center align-items-center',
|
|
48
|
+
{
|
|
49
|
+
[`bg-${color}`]: color,
|
|
50
|
+
},
|
|
51
|
+
)}
|
|
52
|
+
>
|
|
55
53
|
{icon}
|
|
56
54
|
{chart}
|
|
57
55
|
</CCardHeader>
|
|
@@ -2,8 +2,7 @@ import React, { forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { CCard } from '../card
|
|
6
|
-
import { CCardBody } from '../card/CCardBody'
|
|
5
|
+
import { CCard, CCardBody } from '../card'
|
|
7
6
|
|
|
8
7
|
export interface CWidgetStatsEProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
9
8
|
/**
|
|
@@ -26,10 +25,8 @@ export interface CWidgetStatsEProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
26
25
|
|
|
27
26
|
export const CWidgetStatsE = forwardRef<HTMLDivElement, CWidgetStatsEProps>(
|
|
28
27
|
({ chart, className, title, value, ...rest }, ref) => {
|
|
29
|
-
const _className = classNames(className)
|
|
30
|
-
|
|
31
28
|
return (
|
|
32
|
-
<CCard className={
|
|
29
|
+
<CCard className={classNames(className)} {...rest} ref={ref}>
|
|
33
30
|
<CCardBody className="text-center">
|
|
34
31
|
{title && (
|
|
35
32
|
<div className="text-medium-emphasis small text-uppercase fw-semibold">{title}</div>
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes, ReactNode } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import classNames from 'classnames'
|
|
4
3
|
|
|
5
|
-
import {
|
|
4
|
+
import { CCard, CCardBody, CCardFooter } from '../card'
|
|
6
5
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { CCardFooter } from '../card/CCardFooter'
|
|
6
|
+
import { colorPropType } from '../../props'
|
|
7
|
+
import type { Colors } from '../../types'
|
|
10
8
|
|
|
11
9
|
export interface CWidgetStatsFProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
12
10
|
/**
|
|
@@ -43,10 +41,8 @@ export interface CWidgetStatsFProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
43
41
|
|
|
44
42
|
export const CWidgetStatsF = forwardRef<HTMLDivElement, CWidgetStatsFProps>(
|
|
45
43
|
({ className, color, footer, icon, padding = true, title, value, ...rest }, ref) => {
|
|
46
|
-
const _className = classNames(className)
|
|
47
|
-
|
|
48
44
|
return (
|
|
49
|
-
<CCard className={
|
|
45
|
+
<CCard className={className} {...rest} ref={ref}>
|
|
50
46
|
<CCardBody className={`d-flex align-items-center ${padding === false && 'p-0'}`}>
|
|
51
47
|
<div className={`me-3 text-white bg-${color} ${padding ? 'p-3' : 'p-4'}`}>{icon}</div>
|
|
52
48
|
<div>
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type Colors =
|
|
6
|
-
| 'primary'
|
|
7
|
-
| 'secondary'
|
|
8
|
-
| 'success'
|
|
9
|
-
| 'danger'
|
|
10
|
-
| 'warning'
|
|
11
|
-
| 'info'
|
|
12
|
-
| 'dark'
|
|
13
|
-
| 'light'
|
|
14
|
-
| string
|
|
3
|
+
import type { Placements, Triggers } from './types'
|
|
15
4
|
|
|
16
5
|
export const colorPropType = PropTypes.oneOfType([
|
|
17
6
|
PropTypes.oneOf([
|
|
@@ -27,16 +16,6 @@ export const colorPropType = PropTypes.oneOfType([
|
|
|
27
16
|
PropTypes.string,
|
|
28
17
|
])
|
|
29
18
|
|
|
30
|
-
export type Gradients =
|
|
31
|
-
| 'primary-gradient'
|
|
32
|
-
| 'secondary-gradient'
|
|
33
|
-
| 'success-gradient'
|
|
34
|
-
| 'danger-gradient'
|
|
35
|
-
| 'warning-gradient'
|
|
36
|
-
| 'info-gradient'
|
|
37
|
-
| 'dark-gradient'
|
|
38
|
-
| 'light-gradient'
|
|
39
|
-
|
|
40
19
|
export const gradientsPropType = PropTypes.oneOf([
|
|
41
20
|
'primary-gradient',
|
|
42
21
|
'secondary-gradient',
|
|
@@ -48,24 +27,6 @@ export const gradientsPropType = PropTypes.oneOf([
|
|
|
48
27
|
'light-gradient',
|
|
49
28
|
])
|
|
50
29
|
|
|
51
|
-
export type Placements =
|
|
52
|
-
| 'auto'
|
|
53
|
-
| 'auto-start'
|
|
54
|
-
| 'auto-end'
|
|
55
|
-
| 'top-end'
|
|
56
|
-
| 'top'
|
|
57
|
-
| 'top-start'
|
|
58
|
-
| 'bottom-end'
|
|
59
|
-
| 'bottom'
|
|
60
|
-
| 'bottom-start'
|
|
61
|
-
| 'right-start'
|
|
62
|
-
| 'right'
|
|
63
|
-
| 'right-end'
|
|
64
|
-
| 'left-start'
|
|
65
|
-
| 'left'
|
|
66
|
-
| 'left-end'
|
|
67
|
-
| undefined
|
|
68
|
-
|
|
69
30
|
export const placementPropType = PropTypes.oneOf<Placements>([
|
|
70
31
|
'auto',
|
|
71
32
|
'auto-start',
|
|
@@ -84,20 +45,6 @@ export const placementPropType = PropTypes.oneOf<Placements>([
|
|
|
84
45
|
'left-end',
|
|
85
46
|
])
|
|
86
47
|
|
|
87
|
-
export type Shapes =
|
|
88
|
-
| 'rounded'
|
|
89
|
-
| 'rounded-top'
|
|
90
|
-
| 'rounded-end'
|
|
91
|
-
| 'rounded-bottom'
|
|
92
|
-
| 'rounded-start'
|
|
93
|
-
| 'rounded-circle'
|
|
94
|
-
| 'rounded-pill'
|
|
95
|
-
| 'rounded-0'
|
|
96
|
-
| 'rounded-1'
|
|
97
|
-
| 'rounded-2'
|
|
98
|
-
| 'rounded-3'
|
|
99
|
-
| string
|
|
100
|
-
|
|
101
48
|
export const shapePropType = PropTypes.oneOfType([
|
|
102
49
|
PropTypes.oneOf([
|
|
103
50
|
'rounded',
|
|
@@ -115,24 +62,10 @@ export const shapePropType = PropTypes.oneOfType([
|
|
|
115
62
|
PropTypes.string,
|
|
116
63
|
])
|
|
117
64
|
|
|
118
|
-
export type TextColors =
|
|
119
|
-
| Colors
|
|
120
|
-
| 'white'
|
|
121
|
-
| 'muted'
|
|
122
|
-
| 'high-emphasis'
|
|
123
|
-
| 'medium-emphasis'
|
|
124
|
-
| 'disabled'
|
|
125
|
-
| 'high-emphasis-inverse'
|
|
126
|
-
| 'medium-emphasis-inverse'
|
|
127
|
-
| 'disabled-inverse'
|
|
128
|
-
| string
|
|
129
|
-
|
|
130
65
|
export const textColorsPropType = PropTypes.oneOfType([
|
|
131
66
|
colorPropType,
|
|
132
67
|
PropTypes.oneOf(['white', 'muted']),
|
|
133
68
|
PropTypes.string,
|
|
134
69
|
])
|
|
135
70
|
|
|
136
|
-
export type Triggers = 'hover' | 'focus' | 'click'
|
|
137
|
-
|
|
138
71
|
export const triggerPropType = PropTypes.oneOf<Triggers>(['hover', 'focus', 'click'])
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export type Breakpoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
|
|
2
|
+
|
|
3
|
+
export type Colors =
|
|
4
|
+
| 'primary'
|
|
5
|
+
| 'secondary'
|
|
6
|
+
| 'success'
|
|
7
|
+
| 'danger'
|
|
8
|
+
| 'warning'
|
|
9
|
+
| 'info'
|
|
10
|
+
| 'dark'
|
|
11
|
+
| 'light'
|
|
12
|
+
| string
|
|
13
|
+
|
|
14
|
+
export type Gradients =
|
|
15
|
+
| 'primary-gradient'
|
|
16
|
+
| 'secondary-gradient'
|
|
17
|
+
| 'success-gradient'
|
|
18
|
+
| 'danger-gradient'
|
|
19
|
+
| 'warning-gradient'
|
|
20
|
+
| 'info-gradient'
|
|
21
|
+
| 'dark-gradient'
|
|
22
|
+
| 'light-gradient'
|
|
23
|
+
|
|
24
|
+
export type Placements =
|
|
25
|
+
| 'auto'
|
|
26
|
+
| 'auto-start'
|
|
27
|
+
| 'auto-end'
|
|
28
|
+
| 'top-end'
|
|
29
|
+
| 'top'
|
|
30
|
+
| 'top-start'
|
|
31
|
+
| 'bottom-end'
|
|
32
|
+
| 'bottom'
|
|
33
|
+
| 'bottom-start'
|
|
34
|
+
| 'right-start'
|
|
35
|
+
| 'right'
|
|
36
|
+
| 'right-end'
|
|
37
|
+
| 'left-start'
|
|
38
|
+
| 'left'
|
|
39
|
+
| 'left-end'
|
|
40
|
+
| undefined
|
|
41
|
+
|
|
42
|
+
export type Shapes =
|
|
43
|
+
| 'rounded'
|
|
44
|
+
| 'rounded-top'
|
|
45
|
+
| 'rounded-end'
|
|
46
|
+
| 'rounded-bottom'
|
|
47
|
+
| 'rounded-start'
|
|
48
|
+
| 'rounded-circle'
|
|
49
|
+
| 'rounded-pill'
|
|
50
|
+
| 'rounded-0'
|
|
51
|
+
| 'rounded-1'
|
|
52
|
+
| 'rounded-2'
|
|
53
|
+
| 'rounded-3'
|
|
54
|
+
| string
|
|
55
|
+
|
|
56
|
+
export type TextColors =
|
|
57
|
+
| Colors
|
|
58
|
+
| 'white'
|
|
59
|
+
| 'muted'
|
|
60
|
+
| 'high-emphasis'
|
|
61
|
+
| 'medium-emphasis'
|
|
62
|
+
| 'disabled'
|
|
63
|
+
| 'high-emphasis-inverse'
|
|
64
|
+
| 'medium-emphasis-inverse'
|
|
65
|
+
| 'disabled-inverse'
|
|
66
|
+
| string
|
|
67
|
+
|
|
68
|
+
export type Triggers = 'hover' | 'focus' | 'click'
|
package/src/utils/index.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import getNextSibling from './getNextSibling'
|
|
2
|
-
import getPreviousSibling from './getPreviousSibling'
|
|
3
1
|
import isInViewport from './isInViewport'
|
|
4
2
|
import isObjectInArray from './isObjectInArray'
|
|
5
3
|
|
|
6
|
-
export {
|
|
4
|
+
export { isInViewport, isObjectInArray }
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// TODO: check if component property is necessary.
|
|
2
|
-
|
|
3
|
-
import React, { forwardRef, HTMLAttributes } from 'react'
|
|
4
|
-
|
|
5
|
-
export const CMultiSelectCleaner = forwardRef<HTMLButtonElement, HTMLAttributes<HTMLButtonElement>>(
|
|
6
|
-
(props, ref) => {
|
|
7
|
-
return (
|
|
8
|
-
<button
|
|
9
|
-
type="button"
|
|
10
|
-
className="form-multi-select-selection-cleaner"
|
|
11
|
-
{...props}
|
|
12
|
-
ref={ref}
|
|
13
|
-
></button>
|
|
14
|
-
)
|
|
15
|
-
},
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
CMultiSelectCleaner.displayName = 'CMultiSelectCleaner'
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const getNextSibling = (elem: HTMLElement, selector?: string) => {
|
|
2
|
-
// Get the next sibling element
|
|
3
|
-
let sibling = elem.nextElementSibling
|
|
4
|
-
|
|
5
|
-
// If there's no selector, return the first sibling
|
|
6
|
-
if (!selector) return sibling
|
|
7
|
-
|
|
8
|
-
// If the sibling matches our selector, use it
|
|
9
|
-
// If not, jump to the next sibling and continue the loop
|
|
10
|
-
while (sibling) {
|
|
11
|
-
if (sibling.matches(selector)) return sibling
|
|
12
|
-
sibling = sibling.nextElementSibling
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default getNextSibling
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const getPreviousSibling = (elem: HTMLElement, selector?: string) => {
|
|
2
|
-
// Get the next sibling element
|
|
3
|
-
let sibling = elem.previousElementSibling
|
|
4
|
-
|
|
5
|
-
// If there's no selector, return the first sibling
|
|
6
|
-
if (!selector) return sibling
|
|
7
|
-
|
|
8
|
-
// If the sibling matches our selector, use it
|
|
9
|
-
// If not, jump to the next sibling and continue the loop
|
|
10
|
-
while (sibling) {
|
|
11
|
-
if (sibling.matches(selector)) return sibling
|
|
12
|
-
sibling = sibling.previousElementSibling
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default getPreviousSibling
|
|
@@ -6,8 +6,8 @@ import { CTableRowProps } from '../table/CTableRow'
|
|
|
6
6
|
|
|
7
7
|
export type Column = {
|
|
8
8
|
filter?: boolean | ((values: any[], onChange: (value: any) => void) => ReactNode)
|
|
9
|
-
label?: string
|
|
10
9
|
key: string
|
|
10
|
+
label?: string
|
|
11
11
|
sorter?: boolean
|
|
12
12
|
_style?: any
|
|
13
13
|
_props?: CTableHeaderCellProps
|