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