@coreui/react-pro 5.0.0-alpha.0 → 5.0.0-alpha.2
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/avatar/CAvatar.d.ts +1 -1
- package/dist/components/badge/CBadge.d.ts +1 -1
- package/dist/components/calendar/CCalendar.d.ts +25 -7
- package/dist/components/calendar/utils.d.ts +12 -3
- package/dist/components/card/CCard.d.ts +1 -1
- package/dist/components/close-button/CCloseButton.d.ts +6 -0
- package/dist/components/dropdown/CDropdown.d.ts +1 -0
- package/dist/components/modal/CModal.d.ts +6 -0
- package/dist/components/multi-select/types.d.ts +2 -2
- package/dist/components/multi-select/utils.d.ts +2 -2
- package/dist/components/nav/CNav.d.ts +1 -1
- package/dist/components/navbar/CNavbar.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvas.d.ts +4 -0
- package/dist/components/smart-table/CSmartTableBody.d.ts +2 -1
- package/dist/components/smart-table/CSmartTableHead.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -3
- package/dist/components/smart-table/types.d.ts +2 -2
- package/dist/components/smart-table/utils.d.ts +3 -1
- package/dist/index.es.js +1468 -1130
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1468 -1130
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/executeAfterTransition.d.ts +2 -0
- package/dist/utils/getTransitionDurationFromElement.d.ts +2 -0
- package/dist/utils/index.d.ts +3 -1
- package/package.json +2 -2
- package/src/components/avatar/CAvatar.tsx +1 -1
- package/src/components/badge/CBadge.tsx +1 -1
- package/src/components/button/CButton.tsx +1 -1
- package/src/components/button/__tests__/__snapshots__/CButton.spec.tsx.snap +0 -1
- package/src/components/calendar/CCalendar.tsx +396 -193
- package/src/components/calendar/utils.ts +91 -4
- package/src/components/card/CCard.tsx +1 -1
- package/src/components/carousel/CCarousel.tsx +9 -5
- package/src/components/carousel/__tests__/__snapshots__/CCarousel.spec.tsx.snap +9 -5
- package/src/components/close-button/CCloseButton.tsx +9 -1
- package/src/components/date-range-picker/CDateRangePicker.tsx +49 -45
- package/src/components/dropdown/CDropdown.tsx +43 -1
- package/src/components/dropdown/CDropdownMenu.tsx +1 -1
- package/src/components/dropdown/CDropdownToggle.tsx +3 -12
- package/src/components/modal/CModal.tsx +25 -9
- package/src/components/multi-select/CMultiSelect.tsx +3 -3
- package/src/components/multi-select/CMultiSelectNativeSelect.tsx +1 -1
- package/src/components/multi-select/CMultiSelectOptions.tsx +1 -1
- package/src/components/multi-select/CMultiSelectSelection.tsx +3 -3
- package/src/components/multi-select/types.ts +2 -2
- package/src/components/multi-select/utils.ts +5 -5
- package/src/components/nav/CNav.tsx +2 -2
- package/src/components/nav/CNavGroup.tsx +9 -2
- package/src/components/nav/__tests__/__snapshots__/CNav.spec.tsx.snap +5 -4
- package/src/components/navbar/CNavbar.tsx +2 -2
- package/src/components/navbar/__tests__/CNavbar.spec.tsx +1 -1
- package/src/components/navbar/__tests__/__snapshots__/CNavbar.spec.tsx.snap +2 -1
- package/src/components/offcanvas/COffcanvas.tsx +8 -1
- package/src/components/popover/CPopover.tsx +2 -2
- package/src/components/progress/__tests__/__snapshots__/CProgress.spec.tsx.snap +10 -5
- package/src/components/progress/__tests__/__snapshots__/CProgressBar.spec.tsx.snap +0 -8
- package/src/components/sidebar/CSidebar.tsx +1 -1
- package/src/components/smart-table/CSmartTable.tsx +13 -6
- package/src/components/smart-table/CSmartTableBody.tsx +11 -5
- package/src/components/smart-table/CSmartTableHead.tsx +31 -11
- package/src/components/smart-table/CSmartTableInterface.tsx +1 -3
- package/src/components/smart-table/types.ts +2 -2
- package/src/components/smart-table/utils.ts +40 -5
- package/src/components/time-picker/CTimePicker.tsx +2 -2
- package/src/components/time-picker/utils.ts +5 -1
- package/src/components/tooltip/CTooltip.tsx +2 -2
- package/src/components/widgets/CWidgetStatsA.tsx +1 -1
- package/src/components/widgets/CWidgetStatsB.tsx +2 -2
- package/src/components/widgets/CWidgetStatsC.tsx +4 -12
- package/src/components/widgets/CWidgetStatsD.tsx +1 -1
- package/src/components/widgets/CWidgetStatsE.tsx +1 -1
- package/src/components/widgets/CWidgetStatsF.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsA.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsB.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsC.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsD.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsE.spec.tsx +1 -1
- package/src/components/widgets/__tests__/CWidgetStatsF.spec.tsx +1 -1
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsA.spec.tsx.snap +1 -1
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsB.spec.tsx.snap +12 -7
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsC.spec.tsx.snap +14 -9
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsD.spec.tsx.snap +2 -2
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsE.spec.tsx.snap +1 -1
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsF.spec.tsx.snap +2 -2
- package/src/hooks/usePopper.ts +10 -2
- package/src/types.ts +14 -7
- package/src/utils/executeAfterTransition.ts +46 -0
- package/src/utils/getTransitionDurationFromElement.ts +24 -0
- package/src/utils/index.ts +10 -1
|
@@ -115,9 +115,7 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
115
115
|
itemsPerPageOptions?: number[]
|
|
116
116
|
/**
|
|
117
117
|
* Adds select element over table, which is used for control items per page in pagination. If you want to customize this element, pass object with optional values:
|
|
118
|
-
* -
|
|
119
|
-
* - values (Array) - custom array of pagination values
|
|
120
|
-
* - external (Boolean) - disables automatic 'itemsPerPage' change (use to change pages externaly by 'pagination-change' event).
|
|
118
|
+
* - external (Boolean) - disables automatic 'itemsPerPage' change.
|
|
121
119
|
*/
|
|
122
120
|
itemsPerPageSelect?: boolean | ItemsPerPageSelect
|
|
123
121
|
/**
|
|
@@ -13,6 +13,8 @@ export type Column = {
|
|
|
13
13
|
sorter?: boolean
|
|
14
14
|
_style?: any
|
|
15
15
|
_props?: CTableHeaderCellProps
|
|
16
|
+
_colStyle?: any
|
|
17
|
+
_colProps?: CTableDataCellProps
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export type ColumnFilter = {
|
|
@@ -49,8 +51,6 @@ export type Item = {
|
|
|
49
51
|
|
|
50
52
|
export type ItemsPerPageSelect = {
|
|
51
53
|
external?: boolean
|
|
52
|
-
label?: string
|
|
53
|
-
values?: Array<number>
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export type Pagination = {
|
|
@@ -65,7 +65,7 @@ export const getClickedColumnName = (
|
|
|
65
65
|
const closest = target.closest('tr')
|
|
66
66
|
const children = closest ? Array.from(closest.children) : []
|
|
67
67
|
const clickedCell = children.filter((child) => child.contains(target))[0]
|
|
68
|
-
return columnNames[children.indexOf(clickedCell)]
|
|
68
|
+
return columnNames[children.indexOf(clickedCell) - 1]
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export const getColumnKey = (column: Column | string) =>
|
|
@@ -78,6 +78,14 @@ export const getColumnLabel = (column: Column | string) =>
|
|
|
78
78
|
: pretifyName(column.key)
|
|
79
79
|
: pretifyName(column)
|
|
80
80
|
|
|
81
|
+
export const getColumnName = (column: string | Column) => {
|
|
82
|
+
if (typeof column === 'object') {
|
|
83
|
+
return column.key
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return column
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
export const getColumnNames = (
|
|
82
90
|
columns: (string | Column)[] | undefined,
|
|
83
91
|
items: Item[],
|
|
@@ -217,15 +225,42 @@ export const getColumnValues = (items: Item[], key: string) => {
|
|
|
217
225
|
return items.map((item) => item[key])
|
|
218
226
|
}
|
|
219
227
|
|
|
220
|
-
export const getTableDataCellProps = (item: Item, colName: string) => {
|
|
221
|
-
const props =
|
|
222
|
-
|
|
223
|
-
|
|
228
|
+
export const getTableDataCellProps = (column: Column | string, item: Item, colName: string) => {
|
|
229
|
+
const props = {}
|
|
230
|
+
|
|
231
|
+
if (typeof column === 'object' && column._colProps) {
|
|
232
|
+
Object.assign(props, column._colProps)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (item._cellProps && item._cellProps['all']) {
|
|
236
|
+
Object.assign(props, item._cellProps['all'])
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (item._cellProps && item._cellProps[colName]) {
|
|
240
|
+
Object.assign(props, item._cellProps[colName])
|
|
224
241
|
}
|
|
225
242
|
|
|
226
243
|
return props
|
|
227
244
|
}
|
|
228
245
|
|
|
246
|
+
export const getTableDataCellStyles = (column: Column | string, item: Item, colName: string) => {
|
|
247
|
+
const styles = {}
|
|
248
|
+
|
|
249
|
+
if (typeof column === 'object' && column._colStyle) {
|
|
250
|
+
Object.assign(styles, column._colStyle)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (item._cellStyle && item._cellStyle['all']) {
|
|
254
|
+
Object.assign(styles, item._cellStyle['all'])
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (item._cellStyle && item._cellStyle[colName]) {
|
|
258
|
+
Object.assign(styles, item._cellStyle[colName])
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return styles
|
|
262
|
+
}
|
|
263
|
+
|
|
229
264
|
export const getTableHeaderCellProps = (column: Column | string) => {
|
|
230
265
|
if (typeof column === 'object' && column._props) {
|
|
231
266
|
return column._props
|
|
@@ -171,7 +171,7 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
171
171
|
|
|
172
172
|
const [date, setDate] = useState<Date | null>(convertTimeToDate(time))
|
|
173
173
|
const [initialDate, setInitialDate] = useState<Date | null>(null)
|
|
174
|
-
const [isValid, setIsValid] = useState(valid
|
|
174
|
+
const [isValid, setIsValid] = useState(valid ?? (invalid === true ? false : undefined))
|
|
175
175
|
const [_ampm, setAmPm] = useState<'am' | 'pm'>(date ? getAmPm(new Date(date), locale) : 'am')
|
|
176
176
|
const [_visible, setVisible] = useState(visible)
|
|
177
177
|
|
|
@@ -187,7 +187,7 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
187
187
|
}, [time])
|
|
188
188
|
|
|
189
189
|
useEffect(() => {
|
|
190
|
-
setIsValid(valid
|
|
190
|
+
setIsValid(valid ?? (invalid === true ? false : undefined))
|
|
191
191
|
}, [valid, invalid])
|
|
192
192
|
|
|
193
193
|
useEffect(() => {
|
|
@@ -16,7 +16,11 @@ export const convert12hTo24h = (abbr: 'am' | 'pm', hour: number) => {
|
|
|
16
16
|
export const convert24hTo12h = (hour: number) => hour % 12 || 12
|
|
17
17
|
|
|
18
18
|
export const convertTimeToDate = (time: Date | string | null | undefined) =>
|
|
19
|
-
time
|
|
19
|
+
time
|
|
20
|
+
? time instanceof Date
|
|
21
|
+
? time
|
|
22
|
+
: new Date(`1970-01-01 ${time}`)
|
|
23
|
+
: null
|
|
20
24
|
|
|
21
25
|
export const getAmPm = (date: Date, locale: string) => {
|
|
22
26
|
if (date.toLocaleTimeString(locale).includes('AM')) {
|
|
@@ -7,7 +7,7 @@ import { Transition } from 'react-transition-group'
|
|
|
7
7
|
import { usePopper } from '../../hooks'
|
|
8
8
|
import { fallbackPlacementsPropType, triggerPropType } from '../../props'
|
|
9
9
|
import type { Placements, Triggers } from '../../types'
|
|
10
|
-
import { getRTLPlacement } from '../../utils'
|
|
10
|
+
import { getRTLPlacement, getTransitionDurationFromElement } from '../../utils'
|
|
11
11
|
|
|
12
12
|
export interface CTooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'content'> {
|
|
13
13
|
/**
|
|
@@ -158,7 +158,7 @@ export const CTooltip: FC<CTooltipProps> = ({
|
|
|
158
158
|
onExit={onHide}
|
|
159
159
|
timeout={{
|
|
160
160
|
enter: 0,
|
|
161
|
-
exit: 200,
|
|
161
|
+
exit: tooltipRef.current ? getTransitionDurationFromElement(tooltipRef.current) + 50 : 200,
|
|
162
162
|
}}
|
|
163
163
|
unmountOnExit
|
|
164
164
|
>
|
|
@@ -41,7 +41,7 @@ export const CWidgetStatsA = forwardRef<HTMLDivElement, CWidgetStatsAProps>(
|
|
|
41
41
|
return (
|
|
42
42
|
<CCard
|
|
43
43
|
className={classNames(
|
|
44
|
-
{ [`bg-${color}`]: color, 'text-
|
|
44
|
+
{ [`bg-${color}`]: color, 'text-white': color },
|
|
45
45
|
className,
|
|
46
46
|
)}
|
|
47
47
|
{...rest}
|
|
@@ -48,7 +48,7 @@ export const CWidgetStatsB = forwardRef<HTMLDivElement, CWidgetStatsBProps>(
|
|
|
48
48
|
<CCard
|
|
49
49
|
className={className}
|
|
50
50
|
color={color}
|
|
51
|
-
{...(inverse && { textColor: '
|
|
51
|
+
{...(inverse && { textColor: 'white' })}
|
|
52
52
|
{...rest}
|
|
53
53
|
ref={ref}
|
|
54
54
|
>
|
|
@@ -57,7 +57,7 @@ export const CWidgetStatsB = forwardRef<HTMLDivElement, CWidgetStatsBProps>(
|
|
|
57
57
|
{title && <div>{title}</div>}
|
|
58
58
|
<CProgress className="my-2" height={4} {...(inverse && { white: true })} {...progress} />
|
|
59
59
|
{text && (
|
|
60
|
-
<small className={inverse ? 'text-
|
|
60
|
+
<small className={inverse ? 'text-white text-opacity-75' : 'text-body-secondary'}>
|
|
61
61
|
{text}
|
|
62
62
|
</small>
|
|
63
63
|
)}
|
|
@@ -48,23 +48,15 @@ export const CWidgetStatsC = forwardRef<HTMLDivElement, CWidgetStatsCProps>(
|
|
|
48
48
|
<CCard
|
|
49
49
|
className={className}
|
|
50
50
|
color={color}
|
|
51
|
-
{...(inverse && { textColor: '
|
|
51
|
+
{...(inverse && { textColor: 'white' })}
|
|
52
52
|
{...rest}
|
|
53
53
|
ref={ref}
|
|
54
54
|
>
|
|
55
55
|
<CCardBody>
|
|
56
|
-
{icon &&
|
|
57
|
-
|
|
58
|
-
{icon}
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
61
|
-
{value && (
|
|
62
|
-
<div className={`text-high-emphasis${inverse ? '-inverse' : ''} fs-4 fw-semibold`}>
|
|
63
|
-
{value}
|
|
64
|
-
</div>
|
|
65
|
-
)}
|
|
56
|
+
{icon && <div className="text-end mb-4">{icon}</div>}
|
|
57
|
+
{value && <div className="fs-4 fw-semibold">{value}</div>}
|
|
66
58
|
{title && (
|
|
67
|
-
<div className={inverse ? 'text-
|
|
59
|
+
<div className={inverse ? 'text-white text-opacity-75' : 'text-body-secondary'}>
|
|
68
60
|
{title}
|
|
69
61
|
</div>
|
|
70
62
|
)}
|
|
@@ -61,7 +61,7 @@ export const CWidgetStatsD = forwardRef<HTMLDivElement, CWidgetStatsDProps>(
|
|
|
61
61
|
{index % 2 !== 0 && <div className="vr"></div>}
|
|
62
62
|
<CCol>
|
|
63
63
|
<div className="fs-5 fw-semibold">{value.value}</div>
|
|
64
|
-
<div className="text-uppercase text-
|
|
64
|
+
<div className="text-uppercase text-body-secondary small">{value.title}</div>
|
|
65
65
|
</CCol>
|
|
66
66
|
</React.Fragment>
|
|
67
67
|
)
|
|
@@ -29,7 +29,7 @@ export const CWidgetStatsE = forwardRef<HTMLDivElement, CWidgetStatsEProps>(
|
|
|
29
29
|
<CCard className={classNames(className)} {...rest} ref={ref}>
|
|
30
30
|
<CCardBody className="text-center">
|
|
31
31
|
{title && (
|
|
32
|
-
<div className="text-
|
|
32
|
+
<div className="text-body-secondary small text-uppercase fw-semibold">{title}</div>
|
|
33
33
|
)}
|
|
34
34
|
{value && <div className="fs-6 fw-semibold py-3">{value}</div>}
|
|
35
35
|
{chart}
|
|
@@ -47,7 +47,7 @@ export const CWidgetStatsF = forwardRef<HTMLDivElement, CWidgetStatsFProps>(
|
|
|
47
47
|
<div className={`me-3 text-white bg-${color} ${padding ? 'p-3' : 'p-4'}`}>{icon}</div>
|
|
48
48
|
<div>
|
|
49
49
|
<div className={`fs-6 fw-semibold text-${color}`}>{value}</div>
|
|
50
|
-
<div className="text-
|
|
50
|
+
<div className="text-body-secondary text-uppercase fw-semibold small">{title}</div>
|
|
51
51
|
</div>
|
|
52
52
|
</CCardBody>
|
|
53
53
|
{footer && <CCardFooter>{footer}</CCardFooter>}
|
|
@@ -23,7 +23,7 @@ test('CWidgetStatsA customize', async () => {
|
|
|
23
23
|
)
|
|
24
24
|
expect(container).toMatchSnapshot()
|
|
25
25
|
expect(container.firstChild).toHaveClass('bg-info')
|
|
26
|
-
expect(container.firstChild).toHaveClass('text-
|
|
26
|
+
expect(container.firstChild).toHaveClass('text-white')
|
|
27
27
|
expect(container.firstChild).toHaveClass('bazinga')
|
|
28
28
|
if (container.firstChild === null) {
|
|
29
29
|
expect(true).toBe(false)
|
|
@@ -32,7 +32,7 @@ test('CWidgetStatsB customize', async () => {
|
|
|
32
32
|
expect(container.firstChild.firstChild.firstChild).toHaveClass('fs-4')
|
|
33
33
|
expect(container.firstChild.firstChild.firstChild).toHaveClass('fw-semibold')
|
|
34
34
|
expect(container.firstChild.firstChild.firstChild).toHaveTextContent('value')
|
|
35
|
-
expect(container.firstChild.firstChild.lastChild).toHaveClass('text-
|
|
35
|
+
expect(container.firstChild.firstChild.lastChild).toHaveClass('text-white')
|
|
36
36
|
expect(container.firstChild.firstChild.lastChild).toHaveTextContent('text')
|
|
37
37
|
}
|
|
38
38
|
})
|
|
@@ -29,7 +29,7 @@ test('CWidgetStatsC customize', async () => {
|
|
|
29
29
|
expect(true).toBe(false)
|
|
30
30
|
} else {
|
|
31
31
|
expect(container.firstChild.firstChild).toHaveClass('card-body')
|
|
32
|
-
expect(container.firstChild.firstChild.firstChild).toHaveClass('text-
|
|
32
|
+
expect(container.firstChild.firstChild.firstChild).toHaveClass('text-white')
|
|
33
33
|
expect(container.firstChild.firstChild.firstChild).toHaveClass('text-end')
|
|
34
34
|
expect(container.firstChild.firstChild.firstChild).toHaveClass('mb-4')
|
|
35
35
|
expect(container.firstChild.firstChild.firstChild).toHaveTextContent('icon')
|
|
@@ -42,7 +42,7 @@ test('CWidgetStatsD customize', async () => {
|
|
|
42
42
|
expect(container.firstChild.lastChild.firstChild.firstChild).toHaveTextContent('89K')
|
|
43
43
|
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveClass('text-uppercase')
|
|
44
44
|
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveClass(
|
|
45
|
-
'text-
|
|
45
|
+
'text-body-secondary',
|
|
46
46
|
)
|
|
47
47
|
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveClass('small')
|
|
48
48
|
expect(container.firstChild.lastChild.firstChild.lastChild).toHaveTextContent('friends')
|
|
@@ -21,7 +21,7 @@ test('CWidgetStatsE customize', async () => {
|
|
|
21
21
|
expect(true).toBe(false)
|
|
22
22
|
} else {
|
|
23
23
|
expect(container.firstChild.firstChild).toHaveClass('card-body')
|
|
24
|
-
expect(container.firstChild.firstChild.firstChild).toHaveClass('text-
|
|
24
|
+
expect(container.firstChild.firstChild.firstChild).toHaveClass('text-body-secondary')
|
|
25
25
|
expect(container.firstChild.firstChild.firstChild).toHaveClass('small')
|
|
26
26
|
expect(container.firstChild.firstChild.firstChild).toHaveClass('text-uppercase')
|
|
27
27
|
expect(container.firstChild.firstChild.firstChild).toHaveClass('fw-semibold')
|
|
@@ -47,7 +47,7 @@ test('CWidgetStatsF customize', async () => {
|
|
|
47
47
|
expect(container.firstChild.firstChild.lastChild.firstChild).toHaveClass('text-info')
|
|
48
48
|
expect(container.firstChild.firstChild.lastChild.firstChild).toHaveTextContent('value')
|
|
49
49
|
expect(container.firstChild.firstChild.lastChild.lastChild).toHaveClass(
|
|
50
|
-
'text-
|
|
50
|
+
'text-body-secondary',
|
|
51
51
|
)
|
|
52
52
|
expect(container.firstChild.firstChild.lastChild.lastChild).toHaveClass('text-uppercase')
|
|
53
53
|
expect(container.firstChild.firstChild.lastChild.lastChild).toHaveClass('fw-semibold ')
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`CWidgetStatsB customize 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
class="card bg-info text-
|
|
6
|
+
class="card bg-info text-white bazinga"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
9
|
class="card-body"
|
|
@@ -17,20 +17,20 @@ exports[`CWidgetStatsB customize 1`] = `
|
|
|
17
17
|
title
|
|
18
18
|
</div>
|
|
19
19
|
<div
|
|
20
|
+
aria-valuemax="100"
|
|
21
|
+
aria-valuemin="0"
|
|
22
|
+
aria-valuenow="75"
|
|
20
23
|
class="progress progress-white my-2"
|
|
24
|
+
role="progressbar"
|
|
21
25
|
style="height: 4px;"
|
|
22
26
|
>
|
|
23
27
|
<div
|
|
24
|
-
aria-valuemax="100"
|
|
25
|
-
aria-valuemin="0"
|
|
26
|
-
aria-valuenow="75"
|
|
27
28
|
class="progress-bar bg-warning"
|
|
28
|
-
role="progressbar"
|
|
29
29
|
style="width: 75%;"
|
|
30
30
|
/>
|
|
31
31
|
</div>
|
|
32
32
|
<small
|
|
33
|
-
class="text-
|
|
33
|
+
class="text-white text-opacity-75"
|
|
34
34
|
>
|
|
35
35
|
text
|
|
36
36
|
</small>
|
|
@@ -50,7 +50,12 @@ exports[`loads and displays CWidgetStatsB component 1`] = `
|
|
|
50
50
|
<div
|
|
51
51
|
class="progress my-2"
|
|
52
52
|
style="height: 4px;"
|
|
53
|
-
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
class="progress-bar"
|
|
56
|
+
style="width: 0%;"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
54
59
|
</div>
|
|
55
60
|
</div>
|
|
56
61
|
</div>
|
|
@@ -3,36 +3,36 @@
|
|
|
3
3
|
exports[`CWidgetStatsC customize 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
class="card bg-info text-
|
|
6
|
+
class="card bg-info text-white bazinga"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
9
|
class="card-body"
|
|
10
10
|
>
|
|
11
11
|
<div
|
|
12
|
-
class="text-
|
|
12
|
+
class="text-end mb-4"
|
|
13
13
|
>
|
|
14
14
|
icon
|
|
15
15
|
</div>
|
|
16
16
|
<div
|
|
17
|
-
class="
|
|
17
|
+
class="fs-4 fw-semibold"
|
|
18
18
|
>
|
|
19
19
|
value
|
|
20
20
|
</div>
|
|
21
21
|
<div
|
|
22
|
-
class="text-
|
|
22
|
+
class="text-white text-opacity-75"
|
|
23
23
|
>
|
|
24
24
|
title
|
|
25
25
|
</div>
|
|
26
26
|
<div
|
|
27
|
+
aria-valuemax="100"
|
|
28
|
+
aria-valuemin="0"
|
|
29
|
+
aria-valuenow="75"
|
|
27
30
|
class="progress progress-white mt-3 mb-0"
|
|
31
|
+
role="progressbar"
|
|
28
32
|
style="height: 4px;"
|
|
29
33
|
>
|
|
30
34
|
<div
|
|
31
|
-
aria-valuemax="100"
|
|
32
|
-
aria-valuemin="0"
|
|
33
|
-
aria-valuenow="75"
|
|
34
35
|
class="progress-bar bg-warning"
|
|
35
|
-
role="progressbar"
|
|
36
36
|
style="width: 75%;"
|
|
37
37
|
/>
|
|
38
38
|
</div>
|
|
@@ -52,7 +52,12 @@ exports[`loads and displays CWidgetStatsC component 1`] = `
|
|
|
52
52
|
<div
|
|
53
53
|
class="progress mt-3 mb-0"
|
|
54
54
|
style="height: 4px;"
|
|
55
|
-
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
class="progress-bar"
|
|
58
|
+
style="width: 0%;"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
56
61
|
</div>
|
|
57
62
|
</div>
|
|
58
63
|
</div>
|
|
@@ -20,7 +20,7 @@ exports[`CWidgetStatsD customize 1`] = `
|
|
|
20
20
|
89K
|
|
21
21
|
</div>
|
|
22
22
|
<div
|
|
23
|
-
class="text-uppercase text-
|
|
23
|
+
class="text-uppercase text-body-secondary small"
|
|
24
24
|
>
|
|
25
25
|
friends
|
|
26
26
|
</div>
|
|
@@ -37,7 +37,7 @@ exports[`CWidgetStatsD customize 1`] = `
|
|
|
37
37
|
459
|
|
38
38
|
</div>
|
|
39
39
|
<div
|
|
40
|
-
class="text-uppercase text-
|
|
40
|
+
class="text-uppercase text-body-secondary small"
|
|
41
41
|
>
|
|
42
42
|
feeds
|
|
43
43
|
</div>
|
|
@@ -20,7 +20,7 @@ exports[`CWidgetStatsF customize 1`] = `
|
|
|
20
20
|
value
|
|
21
21
|
</div>
|
|
22
22
|
<div
|
|
23
|
-
class="text-
|
|
23
|
+
class="text-body-secondary text-uppercase fw-semibold small"
|
|
24
24
|
>
|
|
25
25
|
title
|
|
26
26
|
</div>
|
|
@@ -51,7 +51,7 @@ exports[`loads and displays CWidgetStatsF component 1`] = `
|
|
|
51
51
|
class="fs-6 fw-semibold text-undefined"
|
|
52
52
|
/>
|
|
53
53
|
<div
|
|
54
|
-
class="text-
|
|
54
|
+
class="text-body-secondary text-uppercase fw-semibold small"
|
|
55
55
|
/>
|
|
56
56
|
</div>
|
|
57
57
|
</div>
|
package/src/hooks/usePopper.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { useRef } from 'react'
|
|
|
2
2
|
import { createPopper } from '@popperjs/core'
|
|
3
3
|
import type { Instance, Options } from '@popperjs/core'
|
|
4
4
|
|
|
5
|
+
import { executeAfterTransition } from '../utils'
|
|
6
|
+
|
|
5
7
|
interface UsePopperOutput {
|
|
6
8
|
popper: Instance | undefined
|
|
7
9
|
initPopper: (reference: HTMLElement, popper: HTMLElement, options: Partial<Options>) => void
|
|
@@ -10,14 +12,20 @@ interface UsePopperOutput {
|
|
|
10
12
|
|
|
11
13
|
export const usePopper = (): UsePopperOutput => {
|
|
12
14
|
const _popper = useRef<Instance>()
|
|
15
|
+
const el = useRef<HTMLElement>()
|
|
13
16
|
|
|
14
17
|
const initPopper = (reference: HTMLElement, popper: HTMLElement, options: Partial<Options>) => {
|
|
15
18
|
_popper.current = createPopper(reference, popper, options)
|
|
19
|
+
el.current = popper
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
const destroyPopper = () => {
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
const popperInstance = _popper.current
|
|
24
|
+
|
|
25
|
+
if (popperInstance && el.current) {
|
|
26
|
+
executeAfterTransition(() => {
|
|
27
|
+
popperInstance.destroy()
|
|
28
|
+
}, el.current)
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
_popper.current = undefined
|
package/src/types.ts
CHANGED
|
@@ -55,14 +55,21 @@ export type Shapes =
|
|
|
55
55
|
|
|
56
56
|
export type TextColors =
|
|
57
57
|
| Colors
|
|
58
|
+
| 'primary-emphasis'
|
|
59
|
+
| 'secondary-emphasis'
|
|
60
|
+
| 'success-emphasis'
|
|
61
|
+
| 'danger-emphasis'
|
|
62
|
+
| 'warning-emphasis'
|
|
63
|
+
| 'info-emphasis'
|
|
64
|
+
| 'light-emphasis'
|
|
65
|
+
| 'body'
|
|
66
|
+
| 'body-emphasis'
|
|
67
|
+
| 'body-secondary'
|
|
68
|
+
| 'body-tertiary'
|
|
69
|
+
| 'black'
|
|
70
|
+
| 'black-50'
|
|
58
71
|
| 'white'
|
|
59
|
-
| '
|
|
60
|
-
| 'high-emphasis'
|
|
61
|
-
| 'medium-emphasis'
|
|
62
|
-
| 'disabled'
|
|
63
|
-
| 'high-emphasis-inverse'
|
|
64
|
-
| 'medium-emphasis-inverse'
|
|
65
|
-
| 'disabled-inverse'
|
|
72
|
+
| 'white-50'
|
|
66
73
|
| string
|
|
67
74
|
|
|
68
75
|
export type Triggers = 'hover' | 'focus' | 'click'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import getTransitionDurationFromElement from './getTransitionDurationFromElement'
|
|
2
|
+
|
|
3
|
+
const execute = (callback: () => void) => {
|
|
4
|
+
if (typeof callback === 'function') {
|
|
5
|
+
callback()
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const triggerTransitionEnd = (element: HTMLElement) => {
|
|
10
|
+
element.dispatchEvent(new Event('transitionend'))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const executeAfterTransition = (
|
|
14
|
+
callback: () => void,
|
|
15
|
+
transitionElement: HTMLElement,
|
|
16
|
+
waitForTransition = true,
|
|
17
|
+
) => {
|
|
18
|
+
if (!waitForTransition) {
|
|
19
|
+
execute(callback)
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const durationPadding = 5
|
|
24
|
+
const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding
|
|
25
|
+
|
|
26
|
+
let called = false
|
|
27
|
+
|
|
28
|
+
const handler = ({ target }: { target: any }) => {
|
|
29
|
+
if (target !== transitionElement) {
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
called = true
|
|
34
|
+
transitionElement.removeEventListener('transitionend', handler)
|
|
35
|
+
execute(callback)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
transitionElement.addEventListener('transitionend', handler)
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
if (!called) {
|
|
41
|
+
triggerTransitionEnd(transitionElement)
|
|
42
|
+
}
|
|
43
|
+
}, emulatedDuration)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default executeAfterTransition
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const getTransitionDurationFromElement = (element: HTMLElement) => {
|
|
2
|
+
if (!element) {
|
|
3
|
+
return 0
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// Get transition-duration of the element
|
|
7
|
+
let { transitionDuration, transitionDelay } = window.getComputedStyle(element)
|
|
8
|
+
|
|
9
|
+
const floatTransitionDuration = Number.parseFloat(transitionDuration)
|
|
10
|
+
const floatTransitionDelay = Number.parseFloat(transitionDelay)
|
|
11
|
+
|
|
12
|
+
// Return 0 if element or transition duration is not found
|
|
13
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
|
14
|
+
return 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// If multiple durations are defined, take the first
|
|
18
|
+
transitionDuration = transitionDuration.split(',')[0]
|
|
19
|
+
transitionDelay = transitionDelay.split(',')[0]
|
|
20
|
+
|
|
21
|
+
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * 1000
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default getTransitionDurationFromElement
|
package/src/utils/index.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import executeAfterTransition from './executeAfterTransition'
|
|
1
2
|
import getRTLPlacement from './getRTLPlacement'
|
|
3
|
+
import getTransitionDurationFromElement from './getTransitionDurationFromElement'
|
|
2
4
|
import isInViewport from './isInViewport'
|
|
3
5
|
import isObjectInArray from './isObjectInArray'
|
|
4
6
|
import isRTL from './isRTL'
|
|
5
7
|
|
|
6
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
executeAfterTransition,
|
|
10
|
+
getRTLPlacement,
|
|
11
|
+
getTransitionDurationFromElement,
|
|
12
|
+
isInViewport,
|
|
13
|
+
isObjectInArray,
|
|
14
|
+
isRTL,
|
|
15
|
+
}
|