@coreui/react-pro 5.0.0-alpha.1 → 5.0.0-alpha.3
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/card/CCard.d.ts +1 -1
- package/dist/components/dropdown/CDropdown.d.ts +1 -0
- package/dist/components/dropdown/CDropdownToggle.d.ts +6 -0
- package/dist/components/smart-table/CSmartTableHead.d.ts +1 -1
- package/dist/index.es.js +84 -33
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +84 -33
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- 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/card/CCard.tsx +1 -1
- package/src/components/carousel/__tests__/__snapshots__/CCarousel.spec.tsx.snap +9 -5
- package/src/components/dropdown/CDropdown.tsx +43 -1
- package/src/components/dropdown/CDropdownToggle.tsx +12 -5
- package/src/components/nav/__tests__/__snapshots__/CNav.spec.tsx.snap +5 -4
- 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/progress/__tests__/__snapshots__/CProgress.spec.tsx.snap +10 -5
- package/src/components/progress/__tests__/__snapshots__/CProgressBar.spec.tsx.snap +0 -8
- package/src/components/smart-table/CSmartTable.tsx +11 -5
- package/src/components/smart-table/CSmartTableHead.tsx +31 -11
- 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/types.ts +14 -7
package/dist/types.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export type Colors = 'primary' | 'secondary' | 'success' | 'danger' | 'warning'
|
|
|
3
3
|
export type Gradients = 'primary-gradient' | 'secondary-gradient' | 'success-gradient' | 'danger-gradient' | 'warning-gradient' | 'info-gradient' | 'dark-gradient' | 'light-gradient';
|
|
4
4
|
export type Placements = 'auto' | 'auto-start' | 'auto-end' | 'top-end' | 'top' | 'top-start' | 'bottom-end' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | 'left-start' | 'left' | 'left-end' | undefined;
|
|
5
5
|
export type Shapes = 'rounded' | 'rounded-top' | 'rounded-end' | 'rounded-bottom' | 'rounded-start' | 'rounded-circle' | 'rounded-pill' | 'rounded-0' | 'rounded-1' | 'rounded-2' | 'rounded-3' | string;
|
|
6
|
-
export type TextColors = Colors | '
|
|
6
|
+
export type TextColors = Colors | 'primary-emphasis' | 'secondary-emphasis' | 'success-emphasis' | 'danger-emphasis' | 'warning-emphasis' | 'info-emphasis' | 'light-emphasis' | 'body' | 'body-emphasis' | 'body-secondary' | 'body-tertiary' | 'black' | 'black-50' | 'white' | 'white-50' | string;
|
|
7
7
|
export type Triggers = 'hover' | 'focus' | 'click';
|
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@ export interface CAvatarProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
39
39
|
/**
|
|
40
40
|
* Sets the text color of the component to one of CoreUI’s themed colors.
|
|
41
41
|
*
|
|
42
|
-
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | '
|
|
42
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-emphasis' | 'secondary-emphasis' | 'success-emphasis' | 'danger-emphasis' | 'warning-emphasis' | 'info-emphasis' | 'light-emphasis' | 'body' | 'body-emphasis' | 'body-secondary' | 'body-tertiary' | 'black' | 'black-50' | 'white' | 'white-50' | string
|
|
43
43
|
*/
|
|
44
44
|
textColor?: TextColors
|
|
45
45
|
}
|
|
@@ -37,7 +37,7 @@ export interface CBadgeProps extends HTMLAttributes<HTMLDivElement | HTMLSpanEle
|
|
|
37
37
|
/**
|
|
38
38
|
* Sets the text color of the component to one of CoreUI’s themed colors.
|
|
39
39
|
*
|
|
40
|
-
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | '
|
|
40
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-emphasis' | 'secondary-emphasis' | 'success-emphasis' | 'danger-emphasis' | 'warning-emphasis' | 'info-emphasis' | 'light-emphasis' | 'body' | 'body-emphasis' | 'body-secondary' | 'body-tertiary' | 'black' | 'black-50' | 'white' | 'white-50' | string
|
|
41
41
|
*/
|
|
42
42
|
textColor?: TextColors
|
|
43
43
|
}
|
|
@@ -77,7 +77,7 @@ export const CButton = forwardRef<HTMLButtonElement | HTMLAnchorElement, CButton
|
|
|
77
77
|
return (
|
|
78
78
|
<CLink
|
|
79
79
|
component={rest.href ? 'a' : component}
|
|
80
|
-
|
|
80
|
+
{...(!rest.href && { type: type })}
|
|
81
81
|
className={classNames(
|
|
82
82
|
'btn',
|
|
83
83
|
variant ? `btn-${variant}-${color}` : `btn-${color}`,
|
|
@@ -19,7 +19,7 @@ export interface CCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
19
19
|
/**
|
|
20
20
|
* Sets the text color context of the component to one of CoreUI’s themed colors.
|
|
21
21
|
*
|
|
22
|
-
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | '
|
|
22
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-emphasis' | 'secondary-emphasis' | 'success-emphasis' | 'danger-emphasis' | 'warning-emphasis' | 'info-emphasis' | 'light-emphasis' | 'body' | 'body-emphasis' | 'body-secondary' | 'body-tertiary' | 'black' | 'black-50' | 'white' | 'white-50' | string
|
|
23
23
|
*/
|
|
24
24
|
textColor?: string
|
|
25
25
|
}
|
|
@@ -5,22 +5,26 @@ exports[`loads and displays CCarousel component 1`] = `
|
|
|
5
5
|
<div
|
|
6
6
|
class="carousel slide"
|
|
7
7
|
>
|
|
8
|
-
<
|
|
8
|
+
<div
|
|
9
9
|
class="carousel-indicators"
|
|
10
10
|
>
|
|
11
|
-
<
|
|
11
|
+
<button
|
|
12
|
+
aria-current="true"
|
|
13
|
+
aria-label="Slide 1"
|
|
12
14
|
class="active"
|
|
13
15
|
data-coreui-target=""
|
|
14
16
|
/>
|
|
15
|
-
<
|
|
17
|
+
<button
|
|
18
|
+
aria-label="Slide 2"
|
|
16
19
|
class=""
|
|
17
20
|
data-coreui-target=""
|
|
18
21
|
/>
|
|
19
|
-
<
|
|
22
|
+
<button
|
|
23
|
+
aria-label="Slide 3"
|
|
20
24
|
class=""
|
|
21
25
|
data-coreui-target=""
|
|
22
26
|
/>
|
|
23
|
-
</
|
|
27
|
+
</div>
|
|
24
28
|
<div
|
|
25
29
|
class="carousel-inner"
|
|
26
30
|
>
|
|
@@ -107,6 +107,28 @@ interface ContextProps extends CDropdownProps {
|
|
|
107
107
|
portal: boolean
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
export const getNextActiveElement = (
|
|
111
|
+
list: HTMLElement[],
|
|
112
|
+
activeElement: HTMLElement,
|
|
113
|
+
shouldGetNext: boolean,
|
|
114
|
+
isCycleAllowed: boolean,
|
|
115
|
+
) => {
|
|
116
|
+
const listLength = list.length
|
|
117
|
+
let index = list.indexOf(activeElement)
|
|
118
|
+
|
|
119
|
+
if (index === -1) {
|
|
120
|
+
return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
index += shouldGetNext ? 1 : -1
|
|
124
|
+
|
|
125
|
+
if (isCycleAllowed) {
|
|
126
|
+
index = (index + listLength) % listLength
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return list[Math.max(0, Math.min(index, listLength - 1))]
|
|
130
|
+
}
|
|
131
|
+
|
|
110
132
|
const getPlacement = (
|
|
111
133
|
placement: Placements,
|
|
112
134
|
direction: CDropdownProps['direction'],
|
|
@@ -207,9 +229,12 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
207
229
|
|
|
208
230
|
useEffect(() => {
|
|
209
231
|
if (_visible && dropdownToggleRef.current && dropdownMenuRef.current) {
|
|
232
|
+
dropdownToggleRef.current.focus()
|
|
210
233
|
popper && initPopper(dropdownToggleRef.current, dropdownMenuRef.current, popperConfig)
|
|
211
234
|
window.addEventListener('mouseup', handleMouseUp)
|
|
212
235
|
window.addEventListener('keyup', handleKeyup)
|
|
236
|
+
dropdownToggleRef.current.addEventListener('keydown', handleKeydown)
|
|
237
|
+
dropdownMenuRef.current.addEventListener('keydown', handleKeydown)
|
|
213
238
|
onShow && onShow()
|
|
214
239
|
}
|
|
215
240
|
|
|
@@ -217,10 +242,28 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
217
242
|
popper && destroyPopper()
|
|
218
243
|
window.removeEventListener('mouseup', handleMouseUp)
|
|
219
244
|
window.removeEventListener('keyup', handleKeyup)
|
|
245
|
+
dropdownToggleRef.current &&
|
|
246
|
+
dropdownToggleRef.current.removeEventListener('keydown', handleKeydown)
|
|
247
|
+
dropdownMenuRef.current &&
|
|
248
|
+
dropdownMenuRef.current.removeEventListener('keydown', handleKeydown)
|
|
220
249
|
onHide && onHide()
|
|
221
250
|
}
|
|
222
251
|
}, [_visible])
|
|
223
252
|
|
|
253
|
+
const handleKeydown = (event: KeyboardEvent) => {
|
|
254
|
+
if (_visible && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
255
|
+
const target = event.target as HTMLElement
|
|
256
|
+
event.preventDefault()
|
|
257
|
+
const items = [].concat(
|
|
258
|
+
...Element.prototype.querySelectorAll.call(
|
|
259
|
+
dropdownMenuRef.current,
|
|
260
|
+
'.dropdown-item:not(.disabled):not(:disabled)',
|
|
261
|
+
),
|
|
262
|
+
)
|
|
263
|
+
getNextActiveElement(items, target, event.key === 'ArrowDown', true).focus()
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
224
267
|
const handleKeyup = (event: KeyboardEvent) => {
|
|
225
268
|
if (autoClose === false) {
|
|
226
269
|
return
|
|
@@ -263,7 +306,6 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
263
306
|
'dropup dropup-center': direction === 'dropup-center',
|
|
264
307
|
[`${direction}`]:
|
|
265
308
|
direction && direction !== 'center' && direction !== 'dropup-center',
|
|
266
|
-
show: _visible,
|
|
267
309
|
},
|
|
268
310
|
className,
|
|
269
311
|
)}
|
|
@@ -18,6 +18,12 @@ export interface CDropdownToggleProps extends Omit<CButtonProps, 'type'> {
|
|
|
18
18
|
* Create a custom toggler which accepts any content.
|
|
19
19
|
*/
|
|
20
20
|
custom?: boolean
|
|
21
|
+
/**
|
|
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-alpha.3
|
|
25
|
+
*/
|
|
26
|
+
navLink?: boolean
|
|
21
27
|
/**
|
|
22
28
|
* Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of `.dropdown-toggle-split` className for proper spacing around the dropdown caret.
|
|
23
29
|
*/
|
|
@@ -35,6 +41,7 @@ export const CDropdownToggle: FC<CDropdownToggleProps> = ({
|
|
|
35
41
|
caret = true,
|
|
36
42
|
custom,
|
|
37
43
|
className,
|
|
44
|
+
navLink = true,
|
|
38
45
|
split,
|
|
39
46
|
trigger = 'click',
|
|
40
47
|
...rest
|
|
@@ -57,9 +64,10 @@ export const CDropdownToggle: FC<CDropdownToggleProps> = ({
|
|
|
57
64
|
const togglerProps = {
|
|
58
65
|
className: classNames(
|
|
59
66
|
{
|
|
67
|
+
'nav-link': variant === 'nav-item' && navLink,
|
|
60
68
|
'dropdown-toggle': caret,
|
|
61
69
|
'dropdown-toggle-split': split,
|
|
62
|
-
|
|
70
|
+
show: visible,
|
|
63
71
|
},
|
|
64
72
|
className,
|
|
65
73
|
),
|
|
@@ -67,7 +75,6 @@ export const CDropdownToggle: FC<CDropdownToggleProps> = ({
|
|
|
67
75
|
...(!rest.disabled && { ...triggers }),
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
// We use any because Toggler can be `a` as well as `button`.
|
|
71
78
|
const Toggler = () => {
|
|
72
79
|
if (custom && React.isValidElement(children)) {
|
|
73
80
|
return (
|
|
@@ -81,16 +88,16 @@ export const CDropdownToggle: FC<CDropdownToggleProps> = ({
|
|
|
81
88
|
)
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
if (variant === 'nav-item') {
|
|
91
|
+
if (variant === 'nav-item' && navLink) {
|
|
85
92
|
return (
|
|
86
|
-
<a href="#" {...togglerProps} ref={dropdownToggleRef}>
|
|
93
|
+
<a href="#" {...togglerProps} role="button" ref={dropdownToggleRef}>
|
|
87
94
|
{children}
|
|
88
95
|
</a>
|
|
89
96
|
)
|
|
90
97
|
}
|
|
91
98
|
|
|
92
99
|
return (
|
|
93
|
-
<CButton
|
|
100
|
+
<CButton {...togglerProps} tabIndex={0} {...rest} ref={dropdownToggleRef}>
|
|
94
101
|
{children}
|
|
95
102
|
{split && <span className="visually-hidden">Toggle Dropdown</span>}
|
|
96
103
|
</CButton>
|
|
@@ -41,13 +41,14 @@ exports[`CNav example 1`] = `
|
|
|
41
41
|
<li
|
|
42
42
|
class="nav-item dropdown"
|
|
43
43
|
>
|
|
44
|
-
<
|
|
44
|
+
<button
|
|
45
45
|
aria-expanded="false"
|
|
46
|
-
class="dropdown-toggle
|
|
47
|
-
|
|
46
|
+
class="btn btn-primary dropdown-toggle"
|
|
47
|
+
tabindex="0"
|
|
48
|
+
type="button"
|
|
48
49
|
>
|
|
49
50
|
A
|
|
50
|
-
</
|
|
51
|
+
</button>
|
|
51
52
|
<ul
|
|
52
53
|
aria-hidden="true"
|
|
53
54
|
class="dropdown-menu"
|
|
@@ -26,9 +26,9 @@ test('CNavbar customize', async () => {
|
|
|
26
26
|
expect(container.firstChild).toHaveClass('bazinga')
|
|
27
27
|
expect(container.firstChild).toHaveClass('navbar')
|
|
28
28
|
expect(container.firstChild).toHaveClass('bg-warning')
|
|
29
|
-
expect(container.firstChild).toHaveClass('navbar-dark')
|
|
30
29
|
expect(container.firstChild).toHaveClass('navbar-expand-lg')
|
|
31
30
|
expect(container.firstChild).toHaveClass('fixed-bottom')
|
|
31
|
+
expect(container.firstChild).toHaveAttribute('data-coreui-theme', 'dark')
|
|
32
32
|
const arrLength = container.getElementsByClassName('container-xl').length
|
|
33
33
|
expect(arrLength).toBe(1)
|
|
34
34
|
})
|
|
@@ -17,7 +17,8 @@ exports[`CNavbar customize - container and expand are boolean 1`] = `
|
|
|
17
17
|
exports[`CNavbar customize 1`] = `
|
|
18
18
|
<div>
|
|
19
19
|
<h3
|
|
20
|
-
class="navbar bg-warning navbar-
|
|
20
|
+
class="navbar bg-warning navbar-expand-lg fixed-bottom bazinga"
|
|
21
|
+
data-coreui-theme="dark"
|
|
21
22
|
>
|
|
22
23
|
<div
|
|
23
24
|
class="container-xl"
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
exports[`CProgress customize 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
+
aria-valuemax="100"
|
|
7
|
+
aria-valuemin="0"
|
|
8
|
+
aria-valuenow="50"
|
|
6
9
|
class="progress bazinga"
|
|
10
|
+
role="progressbar"
|
|
7
11
|
style="height: 100px;"
|
|
8
12
|
>
|
|
9
13
|
<div
|
|
10
|
-
aria-valuemax="100"
|
|
11
|
-
aria-valuemin="0"
|
|
12
|
-
aria-valuenow="50"
|
|
13
14
|
class="progress-bar bg-warning"
|
|
14
|
-
role="progressbar"
|
|
15
15
|
style="width: 50%;"
|
|
16
16
|
>
|
|
17
17
|
Test
|
|
@@ -25,7 +25,12 @@ exports[`loads and displays CProgress component 1`] = `
|
|
|
25
25
|
<div
|
|
26
26
|
class="progress"
|
|
27
27
|
>
|
|
28
|
-
|
|
28
|
+
<div
|
|
29
|
+
class="progress-bar bg-warning"
|
|
30
|
+
style="width: 0%;"
|
|
31
|
+
>
|
|
32
|
+
Test
|
|
33
|
+
</div>
|
|
29
34
|
</div>
|
|
30
35
|
</div>
|
|
31
36
|
`;
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
exports[`CProgressBar customize 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<div
|
|
6
|
-
aria-valuemax="100"
|
|
7
|
-
aria-valuemin="0"
|
|
8
|
-
aria-valuenow="50"
|
|
9
6
|
class="progress-bar bg-warning progress-bar-striped progress-bar-animated bazinga"
|
|
10
|
-
role="progressbar"
|
|
11
7
|
style="width: 50%;"
|
|
12
8
|
>
|
|
13
9
|
Test
|
|
@@ -18,11 +14,7 @@ exports[`CProgressBar customize 1`] = `
|
|
|
18
14
|
exports[`loads and displays CProgressBar component 1`] = `
|
|
19
15
|
<div>
|
|
20
16
|
<div
|
|
21
|
-
aria-valuemax="100"
|
|
22
|
-
aria-valuemin="0"
|
|
23
|
-
aria-valuenow="0"
|
|
24
17
|
class="progress-bar bg-warning"
|
|
25
|
-
role="progressbar"
|
|
26
18
|
style="width: 0%;"
|
|
27
19
|
>
|
|
28
20
|
Test
|
|
@@ -285,7 +285,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
285
285
|
)
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
const handleSorterChange = (column: string, index: number): void => {
|
|
288
|
+
const handleSorterChange = (column: string, index: number, order?: 'asc' | 'desc'): void => {
|
|
289
289
|
if (!isSortable(index, columns, columnSorter, itemsDataColumns, columnNames)) {
|
|
290
290
|
return
|
|
291
291
|
}
|
|
@@ -293,8 +293,14 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
293
293
|
//if column changed or sort was descending change asc to true
|
|
294
294
|
const state = sorterState ?? { column: '', state: '' }
|
|
295
295
|
|
|
296
|
+
if (order) {
|
|
297
|
+
state.state = order
|
|
298
|
+
}
|
|
299
|
+
|
|
296
300
|
if (state.column === column) {
|
|
297
|
-
if (
|
|
301
|
+
if (order) {
|
|
302
|
+
state.state = order
|
|
303
|
+
} else if (state.state === 0) {
|
|
298
304
|
state.state = 'asc'
|
|
299
305
|
} else if (state.state === 'asc') {
|
|
300
306
|
state.state = 'desc'
|
|
@@ -303,13 +309,13 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
303
309
|
}
|
|
304
310
|
} else {
|
|
305
311
|
state.column = column
|
|
306
|
-
state.state = 'asc'
|
|
312
|
+
state.state = order || 'asc'
|
|
307
313
|
}
|
|
308
314
|
|
|
309
315
|
setSorterState({ ...state })
|
|
310
316
|
}
|
|
311
317
|
|
|
312
|
-
const handleTableFilterChange = (value: string, type: string): void => {
|
|
318
|
+
const handleTableFilterChange = (value: string, type: string): void => {to
|
|
313
319
|
const isLazy = tableFilter && typeof tableFilter === 'object' && tableFilter.lazy === true
|
|
314
320
|
if ((isLazy && type === 'input') || (!isLazy && type === 'change')) {
|
|
315
321
|
return
|
|
@@ -404,7 +410,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
404
410
|
handleFilterOnInput={(key, event) => handleColumnFilterChange(key, event, 'input')}
|
|
405
411
|
handleOnCustomFilterChange={(key, event) => handleColumnFilterChange(key, event)}
|
|
406
412
|
handleSelectAllChecked={() => handleSelectAllChecked()}
|
|
407
|
-
handleSort={(key, index) => handleSorterChange(key, index)}
|
|
413
|
+
handleSort={(key, index, order) => handleSorterChange(key, index, order)}
|
|
408
414
|
/>
|
|
409
415
|
)}
|
|
410
416
|
<CSmartTableBody
|
|
@@ -35,7 +35,7 @@ export interface CSmartTableHeadProps extends CTableHeadProps {
|
|
|
35
35
|
handleFilterOnChange?: (key: string, value: string) => void
|
|
36
36
|
handleFilterOnInput?: (key: string, value: string) => void
|
|
37
37
|
handleSelectAllChecked?: () => void
|
|
38
|
-
handleSort?: (key: string, index: number) => void
|
|
38
|
+
handleSort?: (key: string, index: number, order?: 'asc' | 'desc') => void
|
|
39
39
|
items: Item[]
|
|
40
40
|
selectable?: boolean
|
|
41
41
|
selectAll?: boolean | { external?: boolean }
|
|
@@ -144,21 +144,41 @@ export const CSmartTableHead = forwardRef<HTMLTableSectionElement, CSmartTableHe
|
|
|
144
144
|
</CTableHeaderCell>
|
|
145
145
|
)}
|
|
146
146
|
{_columns.map((column: Column | string, index: number) => {
|
|
147
|
+
const isSortable =
|
|
148
|
+
columnSorter &&
|
|
149
|
+
(typeof column === 'object'
|
|
150
|
+
? column.sorter === undefined
|
|
151
|
+
? true
|
|
152
|
+
: column.sorter
|
|
153
|
+
: true)
|
|
147
154
|
return (
|
|
148
155
|
<CTableHeaderCell
|
|
149
156
|
{...getTableHeaderCellProps(column)}
|
|
150
|
-
onClick={() => handleSort && handleSort(getColumnKey(column), index)}
|
|
157
|
+
// onClick={() => handleSort && handleSort(getColumnKey(column), index)}
|
|
151
158
|
style={getTableHeaderCellStyles(column, columnSorter)}
|
|
152
159
|
key={index}
|
|
160
|
+
{...(isSortable && {
|
|
161
|
+
onClick: () => handleSort && handleSort(getColumnKey(column), index),
|
|
162
|
+
onKeyDown: (event) => {
|
|
163
|
+
if (event.key === 'Enter') {
|
|
164
|
+
handleSort && handleSort(getColumnKey(column), index)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (event.key === 'ArrowUp') {
|
|
168
|
+
event.preventDefault()
|
|
169
|
+
handleSort && handleSort(getColumnKey(column), index, 'asc')
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (event.key === 'ArrowDown') {
|
|
173
|
+
event.preventDefault()
|
|
174
|
+
handleSort && handleSort(getColumnKey(column), index, 'desc')
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
tabIndex: 0,
|
|
178
|
+
})}
|
|
153
179
|
>
|
|
154
180
|
<div className="d-inline">{getColumnLabel(column)}</div>
|
|
155
|
-
{
|
|
156
|
-
(typeof column === 'object'
|
|
157
|
-
? (column.sorter === undefined
|
|
158
|
-
? true
|
|
159
|
-
: column.sorter)
|
|
160
|
-
: true) &&
|
|
161
|
-
columnSorterIcon(column)}
|
|
181
|
+
{isSortable && columnSorterIcon(column)}
|
|
162
182
|
</CTableHeaderCell>
|
|
163
183
|
)
|
|
164
184
|
})}
|
|
@@ -171,9 +191,9 @@ export const CSmartTableHead = forwardRef<HTMLTableSectionElement, CSmartTableHe
|
|
|
171
191
|
<CTableHeaderCell {...getTableHeaderCellProps(column)} key={index}>
|
|
172
192
|
{(
|
|
173
193
|
typeof column === 'object'
|
|
174
|
-
?
|
|
194
|
+
? column.filter === undefined
|
|
175
195
|
? true
|
|
176
|
-
: column.filter
|
|
196
|
+
: column.filter
|
|
177
197
|
: true
|
|
178
198
|
) ? (
|
|
179
199
|
typeof column !== 'string' && typeof column.filter === 'function' ? (
|
|
@@ -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 ')
|