@coreui/react-pro 5.0.0-beta.0 → 5.0.0-rc.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/cjs/components/button/CButton.js +1 -1
- package/dist/cjs/components/button/CButton.js.map +1 -1
- package/dist/cjs/components/calendar/CCalendar.d.ts +3 -3
- package/dist/cjs/components/carousel/CCarousel.js +1 -1
- package/dist/cjs/components/date-range-picker/CDateRangePicker.d.ts +3 -3
- package/dist/cjs/components/dropdown/CDropdown.js +3 -1
- package/dist/cjs/components/dropdown/CDropdown.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownMenu.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownToggle.d.ts +1 -1
- package/dist/cjs/components/dropdown/utils.js.map +1 -1
- package/dist/cjs/components/picker/CPicker.d.ts +2 -2
- package/dist/cjs/components/picker/CPicker.js +1 -1
- package/dist/cjs/components/picker/CPicker.js.map +1 -1
- package/dist/cjs/components/sidebar/CSidebar.js +17 -9
- package/dist/cjs/components/sidebar/CSidebar.js.map +1 -1
- package/dist/cjs/components/smart-table/CSmartTable.d.ts +0 -1
- package/dist/cjs/components/smart-table/CSmartTable.js +5 -6
- package/dist/cjs/components/smart-table/CSmartTable.js.map +1 -1
- package/dist/cjs/components/smart-table/CSmartTableBody.js +3 -3
- package/dist/cjs/components/smart-table/CSmartTableBody.js.map +1 -1
- package/dist/cjs/components/smart-table/consts.d.ts +1 -0
- package/dist/cjs/components/smart-table/consts.js +6 -0
- package/dist/cjs/components/smart-table/consts.js.map +1 -0
- package/dist/cjs/components/toast/CToaster.js +1 -1
- package/dist/cjs/components/toast/CToaster.js.map +1 -1
- package/dist/cjs/components/widgets/CWidgetStatsA.js.map +1 -1
- package/dist/cjs/components/widgets/CWidgetStatsC.js +2 -1
- package/dist/cjs/components/widgets/CWidgetStatsC.js.map +1 -1
- package/dist/esm/components/button/CButton.js +1 -1
- package/dist/esm/components/button/CButton.js.map +1 -1
- package/dist/esm/components/calendar/CCalendar.d.ts +3 -3
- package/dist/esm/components/carousel/CCarousel.js +1 -1
- package/dist/esm/components/date-range-picker/CDateRangePicker.d.ts +3 -3
- package/dist/esm/components/dropdown/CDropdown.js +3 -1
- package/dist/esm/components/dropdown/CDropdown.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownMenu.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownToggle.d.ts +1 -1
- package/dist/esm/components/dropdown/utils.js.map +1 -1
- package/dist/esm/components/picker/CPicker.d.ts +2 -2
- package/dist/esm/components/picker/CPicker.js +1 -1
- package/dist/esm/components/picker/CPicker.js.map +1 -1
- package/dist/esm/components/sidebar/CSidebar.js +17 -9
- package/dist/esm/components/sidebar/CSidebar.js.map +1 -1
- package/dist/esm/components/smart-table/CSmartTable.d.ts +0 -1
- package/dist/esm/components/smart-table/CSmartTable.js +2 -2
- package/dist/esm/components/smart-table/CSmartTable.js.map +1 -1
- package/dist/esm/components/smart-table/CSmartTableBody.js +1 -1
- package/dist/esm/components/smart-table/consts.d.ts +1 -0
- package/dist/esm/components/smart-table/consts.js +4 -0
- package/dist/esm/components/smart-table/consts.js.map +1 -0
- package/dist/esm/components/toast/CToaster.js +1 -1
- package/dist/esm/components/toast/CToaster.js.map +1 -1
- package/dist/esm/components/widgets/CWidgetStatsA.js.map +1 -1
- package/dist/esm/components/widgets/CWidgetStatsC.js +2 -1
- package/dist/esm/components/widgets/CWidgetStatsC.js.map +1 -1
- package/package.json +12 -15
- package/src/components/button/CButton.tsx +1 -1
- package/src/components/calendar/CCalendar.tsx +3 -3
- package/src/components/carousel/CCarousel.tsx +1 -1
- package/src/components/close-button/CCloseButton.tsx +1 -1
- package/src/components/date-range-picker/CDateRangePicker.tsx +3 -3
- package/src/components/dropdown/CDropdown.tsx +8 -2
- package/src/components/dropdown/CDropdownMenu.tsx +0 -1
- package/src/components/dropdown/CDropdownToggle.tsx +2 -2
- package/src/components/dropdown/__tests__/CDropdown.spec.tsx +12 -12
- package/src/components/dropdown/utils.ts +5 -4
- package/src/components/picker/CPicker.tsx +3 -3
- package/src/components/sidebar/CSidebar.tsx +21 -9
- package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.tsx.snap +1 -1
- package/src/components/smart-table/CSmartTable.tsx +1 -2
- package/src/components/smart-table/CSmartTableBody.tsx +1 -1
- package/src/components/smart-table/consts.ts +1 -0
- package/src/components/toast/CToaster.tsx +1 -1
- package/src/components/toast/__tests__/__snapshots__/CToaster.spec.tsx.snap +2 -2
- package/src/components/tooltip/__tests__/CTooltip.spec.tsx +7 -12
- package/src/components/widgets/CWidgetStatsA.tsx +1 -4
- package/src/components/widgets/CWidgetStatsC.tsx +11 -1
- package/src/components/widgets/__tests__/CWidgetStatsD.spec.tsx +1 -3
- package/src/utils/getTransitionDurationFromElement.ts +1 -1
|
@@ -122,7 +122,7 @@ export interface CCalendarProps {
|
|
|
122
122
|
/**
|
|
123
123
|
* Set whether to display week numbers in the calendar.
|
|
124
124
|
*
|
|
125
|
-
* @since 5.0.0-
|
|
125
|
+
* @since 5.0.0-rc.0
|
|
126
126
|
*/
|
|
127
127
|
showWeekNumber?: boolean
|
|
128
128
|
/**
|
|
@@ -132,7 +132,7 @@ export interface CCalendarProps {
|
|
|
132
132
|
/**
|
|
133
133
|
* Specify the type of date selection as day, week, month, or year.
|
|
134
134
|
*
|
|
135
|
-
* @since 5.0.0-
|
|
135
|
+
* @since 5.0.0-rc.0
|
|
136
136
|
*/
|
|
137
137
|
selectionType?: 'day' | 'week' | 'month' | 'year'
|
|
138
138
|
/**
|
|
@@ -148,7 +148,7 @@ export interface CCalendarProps {
|
|
|
148
148
|
/**
|
|
149
149
|
* Label displayed over week numbers in the calendar.
|
|
150
150
|
*
|
|
151
|
-
* @since 5.0.0-
|
|
151
|
+
* @since 5.0.0-rc.0
|
|
152
152
|
*/
|
|
153
153
|
weekNumbersLabel?: string
|
|
154
154
|
/**
|
|
@@ -253,7 +253,7 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
|
|
|
253
253
|
!animating && handleIndicatorClick(index)
|
|
254
254
|
}}
|
|
255
255
|
className={classNames({
|
|
256
|
-
active: active === index
|
|
256
|
+
active: active === index,
|
|
257
257
|
})}
|
|
258
258
|
data-coreui-target=""
|
|
259
259
|
{...(active === index && { 'aria-current': true })}
|
|
@@ -99,19 +99,19 @@ export interface CDateRangePickerProps
|
|
|
99
99
|
/**
|
|
100
100
|
* Custom function to format the selected date into a string according to a custom format.
|
|
101
101
|
*
|
|
102
|
-
* @since v5.0.0-
|
|
102
|
+
* @since v5.0.0-rc.0
|
|
103
103
|
*/
|
|
104
104
|
inputDateFormat?: (date: Date) => string
|
|
105
105
|
/**
|
|
106
106
|
* Custom function to parse the input value into a valid Date object.
|
|
107
107
|
*
|
|
108
|
-
* @since v5.0.0-
|
|
108
|
+
* @since v5.0.0-rc.0
|
|
109
109
|
*/
|
|
110
110
|
inputDateParse?: (date: string | Date) => Date
|
|
111
111
|
/**
|
|
112
112
|
* Defines the delay (in milliseconds) for the input field's onChange event.
|
|
113
113
|
*
|
|
114
|
-
* @since v5.0.0-
|
|
114
|
+
* @since v5.0.0-rc.0
|
|
115
115
|
*/
|
|
116
116
|
inputOnChangeDelay?: number
|
|
117
117
|
/**
|
|
@@ -197,10 +197,16 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
197
197
|
}, [_visible])
|
|
198
198
|
|
|
199
199
|
const handleKeydown = (event: KeyboardEvent) => {
|
|
200
|
-
if (
|
|
200
|
+
if (
|
|
201
|
+
_visible &&
|
|
202
|
+
dropdownMenuRef.current &&
|
|
203
|
+
(event.key === 'ArrowDown' || event.key === 'ArrowUp')
|
|
204
|
+
) {
|
|
201
205
|
event.preventDefault()
|
|
202
206
|
const target = event.target as HTMLElement
|
|
203
|
-
const items: HTMLElement[] = Array.from(
|
|
207
|
+
const items: HTMLElement[] = Array.from(
|
|
208
|
+
dropdownMenuRef.current.querySelectorAll('.dropdown-item:not(.disabled):not(:disabled)'),
|
|
209
|
+
)
|
|
204
210
|
getNextActiveElement(items, target, event.key === 'ArrowDown', true).focus()
|
|
205
211
|
}
|
|
206
212
|
}
|
|
@@ -9,7 +9,6 @@ import { useForkedRef } from '../../hooks'
|
|
|
9
9
|
|
|
10
10
|
import { getAlignmentClassNames } from './utils'
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
export interface CDropdownMenuProps extends HTMLAttributes<HTMLDivElement | HTMLUListElement> {
|
|
14
13
|
/**
|
|
15
14
|
* A string of all className you want applied to the base component.
|
|
@@ -20,8 +20,8 @@ export interface CDropdownToggleProps extends Omit<CButtonProps, 'type'> {
|
|
|
20
20
|
custom?: boolean
|
|
21
21
|
/**
|
|
22
22
|
* If a dropdown `variant` is set to `nav-item` then render the toggler as a link instead of a button.
|
|
23
|
-
*
|
|
24
|
-
* @since v5.0.0-
|
|
23
|
+
*
|
|
24
|
+
* @since v5.0.0-rc.0
|
|
25
25
|
*/
|
|
26
26
|
navLink?: boolean
|
|
27
27
|
/**
|
|
@@ -39,18 +39,18 @@ test('CDropdown customize', async () => {
|
|
|
39
39
|
expect(container.firstChild).toHaveClass('dropstart')
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
test('CDropdown change visible prop', async () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
42
|
+
// test('CDropdown change visible prop', async () => {
|
|
43
|
+
// jest.useFakeTimers()
|
|
44
|
+
// const { rerender } = render(<CDropdown visible={false}>Test</CDropdown>)
|
|
45
|
+
// expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
46
|
+
// rerender(<CDropdown visible={true}>Test</CDropdown>)
|
|
47
|
+
// jest.runAllTimers()
|
|
48
|
+
// expect(screen.getByText('Test')).toHaveClass('show')
|
|
49
|
+
// rerender(<CDropdown visible={false}>Test</CDropdown>)
|
|
50
|
+
// expect(screen.getByText('Test')).not.toHaveClass('show')
|
|
51
|
+
// jest.runAllTimers()
|
|
52
|
+
// jest.useRealTimers()
|
|
53
|
+
// })
|
|
54
54
|
|
|
55
55
|
test('CDropdown click', async () => {
|
|
56
56
|
render(
|
|
@@ -5,16 +5,17 @@ import type { Alignments, Breakpoints } from './types'
|
|
|
5
5
|
export const getAlignmentClassNames = (alignment: Alignments) => {
|
|
6
6
|
const classNames: string[] = []
|
|
7
7
|
if (typeof alignment === 'object') {
|
|
8
|
-
|
|
9
8
|
for (const key in alignment) {
|
|
10
|
-
classNames.push(
|
|
9
|
+
classNames.push(
|
|
10
|
+
`dropdown-menu${key === 'xs' ? '' : `-${key}`}-${alignment[key as keyof Breakpoints]}`,
|
|
11
|
+
)
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
if (typeof alignment === 'string') {
|
|
15
16
|
classNames.push(`dropdown-menu-${alignment}`)
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
return classNames
|
|
19
20
|
}
|
|
20
21
|
|
|
@@ -69,4 +70,4 @@ export const getPlacement = (
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
return _placement
|
|
72
|
-
}
|
|
73
|
+
}
|
|
@@ -21,9 +21,9 @@ export interface CPickerProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
21
21
|
*/
|
|
22
22
|
dropdownClassNames?: string
|
|
23
23
|
/**
|
|
24
|
-
* Toggle visibility of footer element
|
|
24
|
+
* Toggle visibility of footer element.
|
|
25
25
|
*/
|
|
26
|
-
footer?: boolean
|
|
26
|
+
footer?: boolean
|
|
27
27
|
/**
|
|
28
28
|
* Add custom elements to the footer.
|
|
29
29
|
*/
|
|
@@ -171,7 +171,7 @@ CPicker.propTypes = {
|
|
|
171
171
|
container: PropTypes.oneOf(['dropdown', 'inline']),
|
|
172
172
|
disabled: PropTypes.bool,
|
|
173
173
|
dropdownClassNames: PropTypes.string,
|
|
174
|
-
footer: PropTypes.
|
|
174
|
+
footer: PropTypes.bool,
|
|
175
175
|
footerContent: PropTypes.node,
|
|
176
176
|
onHide: PropTypes.func,
|
|
177
177
|
onShow: PropTypes.func,
|
|
@@ -87,14 +87,17 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
|
|
|
87
87
|
) => {
|
|
88
88
|
const sidebarRef = useRef<HTMLDivElement>(null)
|
|
89
89
|
const forkedRef = useForkedRef(ref, sidebarRef)
|
|
90
|
-
|
|
91
|
-
const [_visible, setVisible] = useState(visible)
|
|
90
|
+
|
|
92
91
|
const [inViewport, setInViewport] = useState<boolean>()
|
|
92
|
+
const [mobile, setMobile] = useState(false)
|
|
93
|
+
const [visibleMobile, setVisibleMobile] = useState<boolean>(false)
|
|
94
|
+
const [visibleDesktop, setVisibleDesktop] = useState<boolean>(
|
|
95
|
+
visible !== undefined ? visible : overlaid ? false : true,
|
|
96
|
+
)
|
|
93
97
|
|
|
94
98
|
useEffect(() => {
|
|
95
99
|
sidebarRef.current && setMobile(isOnMobile(sidebarRef.current))
|
|
96
|
-
|
|
97
|
-
setVisible(visible)
|
|
100
|
+
visible !== undefined && handleVisibleChange(visible)
|
|
98
101
|
}, [visible])
|
|
99
102
|
|
|
100
103
|
useEffect(() => {
|
|
@@ -104,7 +107,7 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
|
|
|
104
107
|
}, [inViewport])
|
|
105
108
|
|
|
106
109
|
useEffect(() => {
|
|
107
|
-
mobile &&
|
|
110
|
+
mobile && setVisibleMobile(false)
|
|
108
111
|
}, [mobile])
|
|
109
112
|
|
|
110
113
|
useEffect(() => {
|
|
@@ -132,8 +135,17 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
|
|
|
132
135
|
}
|
|
133
136
|
})
|
|
134
137
|
|
|
138
|
+
const handleVisibleChange = (visible: boolean) => {
|
|
139
|
+
if (mobile) {
|
|
140
|
+
setVisibleMobile(visible)
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
setVisibleDesktop(visible)
|
|
145
|
+
}
|
|
146
|
+
|
|
135
147
|
const handleHide = () => {
|
|
136
|
-
|
|
148
|
+
handleVisibleChange(false)
|
|
137
149
|
}
|
|
138
150
|
|
|
139
151
|
const handleResize = () => {
|
|
@@ -182,8 +194,8 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
|
|
|
182
194
|
[`sidebar-${position}`]: position,
|
|
183
195
|
[`sidebar-${size}`]: size,
|
|
184
196
|
'sidebar-narrow-unfoldable': unfoldable,
|
|
185
|
-
show:
|
|
186
|
-
hide:
|
|
197
|
+
show: (mobile && visibleMobile) || (overlaid && visibleDesktop),
|
|
198
|
+
hide: visibleDesktop === false && !mobile && !overlaid,
|
|
187
199
|
},
|
|
188
200
|
className,
|
|
189
201
|
)}
|
|
@@ -195,7 +207,7 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
|
|
|
195
207
|
{typeof window !== 'undefined' &&
|
|
196
208
|
mobile &&
|
|
197
209
|
createPortal(
|
|
198
|
-
<CBackdrop className="sidebar-backdrop" visible={
|
|
210
|
+
<CBackdrop className="sidebar-backdrop" visible={mobile && visibleMobile} />,
|
|
199
211
|
document.body,
|
|
200
212
|
)}
|
|
201
213
|
</>
|
|
@@ -13,7 +13,7 @@ exports[`CSidebar customize hide 1`] = `
|
|
|
13
13
|
exports[`CSidebar customize show 1`] = `
|
|
14
14
|
<div>
|
|
15
15
|
<div
|
|
16
|
-
class="sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-narrow-unfoldable bazinga"
|
|
16
|
+
class="sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-narrow-unfoldable show bazinga"
|
|
17
17
|
>
|
|
18
18
|
Test
|
|
19
19
|
</div>
|
|
@@ -15,6 +15,7 @@ import { CSmartTableProps } from './CSmartTableInterface'
|
|
|
15
15
|
|
|
16
16
|
import { isObjectInArray } from '../../utils'
|
|
17
17
|
|
|
18
|
+
import { ITEM_INTERNAL_KEYS } from './consts'
|
|
18
19
|
import type { ColumnFilterValue, FooterItem, Item, SorterValue } from './types'
|
|
19
20
|
import {
|
|
20
21
|
filterColumns,
|
|
@@ -25,8 +26,6 @@ import {
|
|
|
25
26
|
sortItems,
|
|
26
27
|
} from './utils'
|
|
27
28
|
|
|
28
|
-
export const ITEM_INTERNAL_KEYS = ['_cellProps', '_props', '_selectable', '_selected']
|
|
29
|
-
|
|
30
29
|
export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
31
30
|
(
|
|
32
31
|
{
|
|
@@ -4,10 +4,10 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import { CTableBody, CTableBodyProps } from '../table/CTableBody'
|
|
5
5
|
import { CFormCheck } from '../form'
|
|
6
6
|
import { CTableDataCell, CTableRow } from '../table'
|
|
7
|
-
import { ITEM_INTERNAL_KEYS } from './CSmartTable'
|
|
8
7
|
|
|
9
8
|
import { isObjectInArray } from '../../utils'
|
|
10
9
|
|
|
10
|
+
import { ITEM_INTERNAL_KEYS } from './consts'
|
|
11
11
|
import type { Column, Item, ScopedColumns } from './types'
|
|
12
12
|
import {
|
|
13
13
|
getClickedColumnName,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ITEM_INTERNAL_KEYS = ['_cellProps', '_props', '_selectable', '_selected']
|
|
@@ -57,7 +57,7 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
|
|
|
57
57
|
{toasts.length > 0 || children ? (
|
|
58
58
|
<div
|
|
59
59
|
className={classNames(
|
|
60
|
-
'toaster toast-container
|
|
60
|
+
'toaster toast-container',
|
|
61
61
|
{
|
|
62
62
|
'position-fixed': placement,
|
|
63
63
|
'top-0': placement && placement.includes('top'),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`CToaster customize 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
class="toaster toast-container
|
|
6
|
+
class="toaster toast-container bazinga"
|
|
7
7
|
/>
|
|
8
8
|
<button
|
|
9
9
|
class="btn btn-primary"
|
|
@@ -17,7 +17,7 @@ exports[`CToaster customize 1`] = `
|
|
|
17
17
|
exports[`loads and displays CToaster component 1`] = `
|
|
18
18
|
<div>
|
|
19
19
|
<div
|
|
20
|
-
class="toaster toast-container
|
|
20
|
+
class="toaster toast-container"
|
|
21
21
|
>
|
|
22
22
|
Test
|
|
23
23
|
</div>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import ReactDOM from 'react-dom'
|
|
3
2
|
import { act } from 'react-dom/test-utils'
|
|
4
|
-
import { fireEvent } from '@testing-library/react'
|
|
3
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
5
4
|
import '@testing-library/jest-dom'
|
|
6
5
|
import { CTooltip, CLink } from '../../../index'
|
|
7
6
|
|
|
@@ -18,24 +17,20 @@ afterEach(() => {
|
|
|
18
17
|
})
|
|
19
18
|
|
|
20
19
|
test('loads and displays CTooltip component', async () => {
|
|
21
|
-
|
|
20
|
+
const { container } = render(
|
|
22
21
|
<CTooltip content="content">
|
|
23
22
|
<CLink>Test</CLink>
|
|
24
23
|
</CTooltip>,
|
|
25
|
-
container,
|
|
26
24
|
)
|
|
27
25
|
expect(container).toMatchSnapshot()
|
|
28
26
|
})
|
|
29
27
|
|
|
30
28
|
test('CTooltip customize', async () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
container,
|
|
37
|
-
)
|
|
38
|
-
})
|
|
29
|
+
const { container } = render(
|
|
30
|
+
<CTooltip trigger="hover" placement="right" content="content">
|
|
31
|
+
<CLink className="link">Test</CLink>
|
|
32
|
+
</CTooltip>,
|
|
33
|
+
)
|
|
39
34
|
const link = document.querySelector('.link')
|
|
40
35
|
act(() => {
|
|
41
36
|
if (link !== null) {
|
|
@@ -40,10 +40,7 @@ export const CWidgetStatsA = forwardRef<HTMLDivElement, CWidgetStatsAProps>(
|
|
|
40
40
|
({ action, chart, className, color, title, value, ...rest }, ref) => {
|
|
41
41
|
return (
|
|
42
42
|
<CCard
|
|
43
|
-
className={classNames(
|
|
44
|
-
{ [`bg-${color}`]: color, 'text-white': color },
|
|
45
|
-
className,
|
|
46
|
-
)}
|
|
43
|
+
className={classNames({ [`bg-${color}`]: color, 'text-white': color }, className)}
|
|
47
44
|
{...rest}
|
|
48
45
|
ref={ref}
|
|
49
46
|
>
|
|
@@ -6,6 +6,7 @@ import { CProgress, CProgressProps } from '../progress/CProgress'
|
|
|
6
6
|
|
|
7
7
|
import { colorPropType } from '../../props'
|
|
8
8
|
import type { Colors } from '../../types'
|
|
9
|
+
import classNames from 'classnames'
|
|
9
10
|
|
|
10
11
|
export interface CWidgetStatsCProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
11
12
|
/**
|
|
@@ -53,7 +54,16 @@ export const CWidgetStatsC = forwardRef<HTMLDivElement, CWidgetStatsCProps>(
|
|
|
53
54
|
ref={ref}
|
|
54
55
|
>
|
|
55
56
|
<CCardBody>
|
|
56
|
-
{icon &&
|
|
57
|
+
{icon && (
|
|
58
|
+
<div
|
|
59
|
+
className={classNames(
|
|
60
|
+
'text-end mb-4',
|
|
61
|
+
inverse ? 'text-white text-opacity-75' : 'text-body-secondary',
|
|
62
|
+
)}
|
|
63
|
+
>
|
|
64
|
+
{icon}
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
57
67
|
{value && <div className="fs-4 fw-semibold">{value}</div>}
|
|
58
68
|
{title && (
|
|
59
69
|
<div className={inverse ? 'text-white text-opacity-75' : 'text-body-secondary'}>
|
|
@@ -41,9 +41,7 @@ test('CWidgetStatsD customize', async () => {
|
|
|
41
41
|
expect(container.firstChild.lastChild.firstChild.firstChild).toHaveClass('fw-semibold')
|
|
42
42
|
expect(container.firstChild.lastChild.firstChild.firstChild).toHaveTextContent('89K')
|
|
43
43
|
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveClass('text-uppercase')
|
|
44
|
-
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveClass(
|
|
45
|
-
'text-body-secondary',
|
|
46
|
-
)
|
|
44
|
+
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveClass('text-body-secondary')
|
|
47
45
|
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveClass('small')
|
|
48
46
|
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveTextContent('friends')
|
|
49
47
|
}
|
|
@@ -21,4 +21,4 @@ const getTransitionDurationFromElement = (element: HTMLElement) => {
|
|
|
21
21
|
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * 1000
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export default getTransitionDurationFromElement
|
|
24
|
+
export default getTransitionDurationFromElement
|