@coreui/react-pro 4.9.0-next.0 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/README.md +1 -1
  2. package/dist/components/alert/CAlert.d.ts +1 -1
  3. package/dist/components/avatar/CAvatar.d.ts +1 -1
  4. package/dist/components/badge/CBadge.d.ts +1 -1
  5. package/dist/components/button/CButton.d.ts +1 -1
  6. package/dist/components/calendar/utils.d.ts +0 -1
  7. package/dist/components/callout/CCallout.d.ts +1 -1
  8. package/dist/components/card/CCard.d.ts +1 -1
  9. package/dist/components/conditional-portal/CConditionalPortal.d.ts +12 -0
  10. package/dist/components/conditional-portal/index.d.ts +2 -0
  11. package/dist/components/date-range-picker/CDateRangePicker.d.ts +1 -1
  12. package/dist/components/date-range-picker/utils.d.ts +1 -0
  13. package/dist/components/dropdown/CDropdown.d.ts +1 -1
  14. package/dist/components/dropdown/CDropdownToggle.d.ts +1 -1
  15. package/dist/components/form/CFormCheck.d.ts +8 -2
  16. package/dist/components/form/CFormSwitch.d.ts +6 -0
  17. package/dist/components/index.d.ts +1 -0
  18. package/dist/components/list-group/CListGroupItem.d.ts +4 -5
  19. package/dist/components/multi-select/CMultiSelect.d.ts +1 -13
  20. package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +1 -1
  21. package/dist/components/multi-select/CMultiSelectOptions.d.ts +1 -1
  22. package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
  23. package/dist/components/multi-select/types.d.ts +14 -0
  24. package/dist/components/multi-select/utils.d.ts +6 -0
  25. package/dist/components/navbar/CNavbar.d.ts +1 -1
  26. package/dist/components/picker/CPicker.d.ts +1 -1
  27. package/dist/components/placeholder/CPlaceholder.d.ts +1 -1
  28. package/dist/components/popover/CPopover.d.ts +1 -1
  29. package/dist/components/progress/CProgressBar.d.ts +1 -1
  30. package/dist/components/smart-table/CSmartTableHead.d.ts +1 -1
  31. package/dist/components/smart-table/CSmartTableInterface.d.ts +8 -0
  32. package/dist/components/smart-table/types.d.ts +1 -1
  33. package/dist/components/spinner/CSpinner.d.ts +1 -1
  34. package/dist/components/table/CTable.d.ts +2 -18
  35. package/dist/components/table/CTableBody.d.ts +1 -1
  36. package/dist/components/table/CTableDataCell.d.ts +1 -1
  37. package/dist/components/table/CTableFoot.d.ts +1 -1
  38. package/dist/components/table/CTableHead.d.ts +1 -1
  39. package/dist/components/table/CTableHeaderCell.d.ts +1 -1
  40. package/dist/components/table/CTableResponsiveWrapper.d.ts +0 -1
  41. package/dist/components/table/CTableRow.d.ts +1 -1
  42. package/dist/components/table/types.d.ts +17 -0
  43. package/dist/components/table/utils.d.ts +5 -0
  44. package/dist/components/toast/CToast.d.ts +1 -1
  45. package/dist/components/toast/CToastClose.d.ts +1 -1
  46. package/dist/components/tooltip/CTooltip.d.ts +1 -1
  47. package/dist/components/virtual-scroller/CVirtualScroller.d.ts +0 -8
  48. package/dist/components/widgets/CWidgetStatsA.d.ts +1 -1
  49. package/dist/components/widgets/CWidgetStatsB.d.ts +1 -1
  50. package/dist/components/widgets/CWidgetStatsC.d.ts +1 -1
  51. package/dist/components/widgets/CWidgetStatsD.d.ts +1 -1
  52. package/dist/components/widgets/CWidgetStatsF.d.ts +1 -1
  53. package/dist/index.es.js +696 -927
  54. package/dist/index.es.js.map +1 -1
  55. package/dist/index.js +695 -925
  56. package/dist/index.js.map +1 -1
  57. package/dist/props.d.ts +8 -0
  58. package/dist/types.d.ts +7 -0
  59. package/dist/utils/index.d.ts +1 -3
  60. package/package.json +11 -6
  61. package/src/components/accordion/CAccordion.tsx +7 -3
  62. package/src/components/accordion/CAccordionBody.tsx +2 -2
  63. package/src/components/accordion/CAccordionButton.tsx +1 -3
  64. package/src/components/accordion/CAccordionCollapse.tsx +1 -0
  65. package/src/components/accordion/CAccordionHeader.tsx +1 -3
  66. package/src/components/accordion/CAccordionItem.tsx +2 -4
  67. package/src/components/accordion/__tests__/__snapshots__/CAccordionBody.spec.tsx.snap +2 -2
  68. package/src/components/alert/CAlert.tsx +21 -28
  69. package/src/components/alert/CAlertHeading.tsx +1 -3
  70. package/src/components/alert/CAlertLink.tsx +1 -3
  71. package/src/components/alert/__tests__/__snapshots__/CAlert.spec.tsx.snap +1 -1
  72. package/src/components/avatar/CAvatar.tsx +16 -19
  73. package/src/components/backdrop/CBackdrop.tsx +10 -13
  74. package/src/components/badge/CBadge.tsx +21 -27
  75. package/src/components/breadcrumb/CBreadcrumb.tsx +1 -2
  76. package/src/components/breadcrumb/CBreadcrumbItem.tsx +12 -8
  77. package/src/components/button/CButton.tsx +10 -10
  78. package/src/components/button-group/CButtonGroup.tsx +9 -7
  79. package/src/components/button-group/CButtonToolbar.tsx +1 -3
  80. package/src/components/calendar/utils.ts +7 -55
  81. package/src/components/callout/CCallout.tsx +13 -10
  82. package/src/components/card/CCard.tsx +14 -11
  83. package/src/components/card/CCardBody.tsx +1 -3
  84. package/src/components/card/CCardFooter.tsx +1 -3
  85. package/src/components/card/CCardGroup.tsx +1 -3
  86. package/src/components/card/CCardHeader.tsx +1 -3
  87. package/src/components/card/CCardImage.tsx +5 -3
  88. package/src/components/card/CCardImageOverlay.tsx +1 -3
  89. package/src/components/card/CCardLink.tsx +1 -3
  90. package/src/components/card/CCardSubtitle.tsx +1 -3
  91. package/src/components/card/CCardText.tsx +1 -3
  92. package/src/components/card/CCardTitle.tsx +1 -3
  93. package/src/components/carousel/CCarousel.tsx +8 -8
  94. package/src/components/carousel/CCarouselCaption.tsx +1 -3
  95. package/src/components/carousel/CCarouselItem.tsx +11 -9
  96. package/src/components/close-button/CCloseButton.tsx +9 -10
  97. package/src/components/collapse/CCollapse.tsx +8 -20
  98. package/src/components/collapse/__tests__/CCollapse.spec.tsx +2 -3
  99. package/src/components/conditional-portal/CConditionalPortal.tsx +29 -0
  100. package/src/components/conditional-portal/index.ts +3 -0
  101. package/src/components/date-range-picker/CDateRangePicker.tsx +11 -13
  102. package/src/components/date-range-picker/utils.ts +49 -0
  103. package/src/components/dropdown/CDropdown.tsx +26 -23
  104. package/src/components/dropdown/CDropdownDivider.tsx +1 -3
  105. package/src/components/dropdown/CDropdownHeader.tsx +1 -3
  106. package/src/components/dropdown/CDropdownItem.tsx +7 -5
  107. package/src/components/dropdown/CDropdownItemPlain.tsx +1 -3
  108. package/src/components/dropdown/CDropdownMenu.tsx +29 -32
  109. package/src/components/dropdown/CDropdownToggle.tsx +34 -27
  110. package/src/components/dropdown/__tests__/CDropdown.spec.tsx +2 -4
  111. package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
  112. package/src/components/footer/CFooter.tsx +5 -3
  113. package/src/components/form/CForm.tsx +5 -2
  114. package/src/components/form/CFormCheck.tsx +90 -66
  115. package/src/components/form/CFormControlValidation.tsx +0 -1
  116. package/src/components/form/CFormControlWrapper.tsx +3 -4
  117. package/src/components/form/CFormFeedback.tsx +11 -8
  118. package/src/components/form/CFormFloating.tsx +1 -2
  119. package/src/components/form/CFormInput.tsx +18 -16
  120. package/src/components/form/CFormLabel.tsx +1 -2
  121. package/src/components/form/CFormRange.tsx +2 -4
  122. package/src/components/form/CFormSelect.tsx +16 -12
  123. package/src/components/form/CFormSwitch.tsx +31 -20
  124. package/src/components/form/CFormText.tsx +1 -2
  125. package/src/components/form/CFormTextarea.tsx +14 -11
  126. package/src/components/form/CInputGroup.tsx +11 -8
  127. package/src/components/form/CInputGroupText.tsx +1 -2
  128. package/src/components/form/__tests__/CFormRange.spec.tsx +1 -1
  129. package/src/components/form/__tests__/__snapshots__/CForm.spec.tsx.snap +2 -6
  130. package/src/components/form/__tests__/__snapshots__/CFormRange.spec.tsx.snap +2 -2
  131. package/src/components/grid/CCol.tsx +8 -6
  132. package/src/components/grid/CContainer.tsx +8 -6
  133. package/src/components/grid/CRow.tsx +4 -3
  134. package/src/components/header/CHeader.tsx +12 -13
  135. package/src/components/header/CHeaderBrand.tsx +1 -3
  136. package/src/components/header/CHeaderBrand.tsx~HEAD +1 -3
  137. package/src/components/header/CHeaderDivider.tsx +1 -3
  138. package/src/components/header/CHeaderNav.tsx +6 -3
  139. package/src/components/header/CHeaderText.tsx +1 -3
  140. package/src/components/header/CHeaderToggler.tsx +2 -4
  141. package/src/components/image/CImage.tsx +17 -10
  142. package/src/components/image/__tests__/__snapshots__/CImage.spec.tsx.snap +1 -3
  143. package/src/components/index.ts +1 -0
  144. package/src/components/link/CLink.tsx +2 -4
  145. package/src/components/list-group/CListGroup.tsx +11 -10
  146. package/src/components/list-group/CListGroupItem.tsx +21 -20
  147. package/src/components/list-group/CListGroupItem.tsx~HEAD +3 -1
  148. package/src/components/loading-button/CLoadingButton.tsx +1 -3
  149. package/src/components/modal/CModal.tsx +57 -72
  150. package/src/components/modal/CModalBody.tsx +1 -3
  151. package/src/components/modal/CModalContent.tsx +1 -3
  152. package/src/components/modal/CModalDialog.tsx +16 -14
  153. package/src/components/modal/CModalFooter.tsx +1 -3
  154. package/src/components/modal/CModalHeader.tsx +4 -4
  155. package/src/components/modal/CModalTitle.tsx +1 -3
  156. package/src/components/modal/__tests__/CModal.spec.tsx +19 -20
  157. package/src/components/multi-select/CMultiSelect.tsx +34 -93
  158. package/src/components/multi-select/CMultiSelectNativeSelect.tsx +1 -1
  159. package/src/components/multi-select/CMultiSelectOptions.tsx +2 -2
  160. package/src/components/multi-select/CMultiSelectSelection.tsx +1 -1
  161. package/src/components/multi-select/types.ts +15 -0
  162. package/src/components/multi-select/utils.ts +92 -0
  163. package/src/components/nav/CNav.tsx +13 -10
  164. package/src/components/nav/CNavGroup.tsx +1 -3
  165. package/src/components/nav/CNavGroupItems.tsx +1 -2
  166. package/src/components/nav/CNavItem.tsx +9 -10
  167. package/src/components/nav/CNavLink.tsx +4 -5
  168. package/src/components/nav/CNavTitle.tsx +1 -2
  169. package/src/components/navbar/CNavbar.tsx +23 -23
  170. package/src/components/navbar/CNavbarBrand.tsx +2 -3
  171. package/src/components/navbar/CNavbarNav.tsx +6 -3
  172. package/src/components/navbar/CNavbarText.tsx +1 -3
  173. package/src/components/navbar/CNavbarToggler.tsx +2 -4
  174. package/src/components/offcanvas/COffcanvas.tsx +42 -68
  175. package/src/components/offcanvas/COffcanvasBody.tsx +1 -3
  176. package/src/components/offcanvas/COffcanvasHeader.tsx +1 -3
  177. package/src/components/offcanvas/COffcanvasTitle.tsx +1 -3
  178. package/src/components/offcanvas/__tests__/COffcanvas.spec.tsx +7 -2
  179. package/src/components/offcanvas/__tests__/__snapshots__/COffcanvas.spec.tsx.snap +9 -4
  180. package/src/components/pagination/CPagination.tsx +12 -9
  181. package/src/components/pagination/CPaginationItem.tsx +12 -11
  182. package/src/components/pagination/__tests__/CPagination.spec.tsx +3 -3
  183. package/src/components/pagination/__tests__/CPaginationItem.spec.tsx +3 -3
  184. package/src/components/picker/CPicker.tsx +7 -7
  185. package/src/components/placeholder/CPlaceholder.tsx +15 -12
  186. package/src/components/popover/CPopover.tsx +24 -34
  187. package/src/components/progress/CProgress.tsx +13 -10
  188. package/src/components/progress/CProgressBar.tsx +11 -12
  189. package/src/components/sidebar/CSidebar.tsx +22 -19
  190. package/src/components/sidebar/CSidebarBrand.tsx +1 -2
  191. package/src/components/sidebar/CSidebarFooter.tsx +1 -2
  192. package/src/components/sidebar/CSidebarHeader.tsx +1 -2
  193. package/src/components/sidebar/CSidebarNav.tsx +2 -2
  194. package/src/components/sidebar/CSidebarToggler.tsx +1 -2
  195. package/src/components/smart-pagination/CSmartPagination.tsx +22 -20
  196. package/src/components/smart-table/CSmartTable.tsx +5 -9
  197. package/src/components/smart-table/CSmartTableBody.tsx +82 -81
  198. package/src/components/smart-table/CSmartTableHead.tsx +5 -2
  199. package/src/components/smart-table/CSmartTableInterface.tsx +8 -0
  200. package/src/components/smart-table/{utils.tsx → utils.ts} +4 -5
  201. package/src/components/spinner/CSpinner.tsx +13 -9
  202. package/src/components/table/CTable.tsx +45 -77
  203. package/src/components/table/CTableBody.tsx +14 -9
  204. package/src/components/table/CTableDataCell.tsx +16 -11
  205. package/src/components/table/CTableFoot.tsx +14 -9
  206. package/src/components/table/CTableHead.tsx +14 -9
  207. package/src/components/table/CTableHeaderCell.tsx +14 -9
  208. package/src/components/table/CTableResponsiveWrapper.tsx +2 -3
  209. package/src/components/table/CTableRow.tsx +16 -11
  210. package/src/components/table/__tests__/__snapshots__/CTable.spec.tsx.snap +1 -5
  211. package/src/components/table/types.ts +20 -0
  212. package/src/components/table/utils.ts +24 -0
  213. package/src/components/tabs/CTabContent.tsx +1 -2
  214. package/src/components/tabs/CTabPane.tsx +18 -20
  215. package/src/components/tabs/__tests__/CTabPane.spec.tsx +2 -5
  216. package/src/components/tabs/__tests__/__snapshots__/CTabPane.spec.tsx.snap +1 -1
  217. package/src/components/time-picker/CTimePicker.tsx +14 -18
  218. package/src/components/toast/CToast.tsx +32 -45
  219. package/src/components/toast/CToastBody.tsx +1 -2
  220. package/src/components/toast/CToastClose.tsx +4 -2
  221. package/src/components/toast/CToastHeader.tsx +1 -2
  222. package/src/components/toast/CToaster.tsx +27 -26
  223. package/src/components/toast/__tests__/CToast.spec.tsx +2 -1
  224. package/src/components/toast/__tests__/__snapshots__/CToast.spec.tsx.snap +1 -66
  225. package/src/components/tooltip/CTooltip.tsx +24 -34
  226. package/src/components/virtual-scroller/CVirtualScroller.tsx +35 -60
  227. package/src/components/widgets/CWidgetStatsA.tsx +11 -9
  228. package/src/components/widgets/CWidgetStatsB.tsx +4 -4
  229. package/src/components/widgets/CWidgetStatsC.tsx +4 -4
  230. package/src/components/widgets/CWidgetStatsD.tsx +13 -15
  231. package/src/components/widgets/CWidgetStatsE.tsx +2 -5
  232. package/src/components/widgets/CWidgetStatsF.tsx +4 -8
  233. package/src/{components/Types.tsx → props.ts} +1 -68
  234. package/src/types.ts +68 -0
  235. package/src/utils/index.ts +1 -3
  236. package/src/components/multi-select/CMultiSelectCleaner.tsx +0 -18
  237. package/src/utils/getNextSibling.ts +0 -18
  238. package/src/utils/getPreviousSibling.ts +0 -18
  239. package/src/components/smart-table/{types.tsx → types.ts} +1 -1
@@ -1,7 +1,6 @@
1
1
  import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes } from 'react'
2
-
3
- import classNames from 'classnames'
4
2
  import PropTypes from 'prop-types'
3
+ import classNames from 'classnames'
5
4
 
6
5
  import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
7
6
 
@@ -67,15 +66,6 @@ export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
67
66
  },
68
67
  ref,
69
68
  ) => {
70
- const _className = classNames(
71
- 'form-select',
72
- {
73
- [`form-select-${size}`]: size,
74
- 'is-invalid': invalid,
75
- 'is-valid': valid,
76
- },
77
- className,
78
- )
79
69
  return (
80
70
  <CFormControlWrapper
81
71
  describedby={rest['aria-describedby']}
@@ -91,7 +81,21 @@ export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
91
81
  tooltipFeedback={tooltipFeedback}
92
82
  valid={valid}
93
83
  >
94
- <select id={id} className={_className} size={htmlSize} {...rest} ref={ref}>
84
+ <select
85
+ id={id}
86
+ className={classNames(
87
+ 'form-select',
88
+ {
89
+ [`form-select-${size}`]: size,
90
+ 'is-invalid': invalid,
91
+ 'is-valid': valid,
92
+ },
93
+ className,
94
+ )}
95
+ size={htmlSize}
96
+ {...rest}
97
+ ref={ref}
98
+ >
95
99
  {options
96
100
  ? options.map((option, index) => {
97
101
  return (
@@ -21,6 +21,12 @@ export interface CFormSwitchProps extends Omit<InputHTMLAttributes<HTMLInputElem
21
21
  * The element represents a caption for a component.
22
22
  */
23
23
  label?: string | ReactNode
24
+ /**
25
+ * Put switch on the opposite side.
26
+ *
27
+ * @sinve 4.7.0
28
+ */
29
+ reverse?: boolean
24
30
  /**
25
31
  * Size the component large or extra large. Works only with `switch`.
26
32
  */
@@ -36,28 +42,32 @@ export interface CFormSwitchProps extends Omit<InputHTMLAttributes<HTMLInputElem
36
42
  }
37
43
 
38
44
  export const CFormSwitch = forwardRef<HTMLInputElement, CFormSwitchProps>(
39
- ({ className, id, invalid, label, size, type = 'checkbox', valid, ...rest }, ref) => {
40
- const _className = classNames(
41
- 'form-check form-switch',
42
- {
43
- [`form-switch-${size}`]: size,
44
- 'is-invalid': invalid,
45
- 'is-valid': valid,
46
- },
47
- className,
48
- )
49
-
50
- const inputClassName = classNames('form-check-input', {
51
- 'is-invalid': invalid,
52
- 'is-valid': valid,
53
- })
54
- const labelClassName = classNames('form-check-label')
55
-
45
+ ({ className, id, invalid, label, reverse, size, type = 'checkbox', valid, ...rest }, ref) => {
56
46
  return (
57
- <div className={_className}>
58
- <input type={type} className={inputClassName} id={id} {...rest} ref={ref} />
47
+ <div
48
+ className={classNames(
49
+ 'form-check form-switch',
50
+ {
51
+ 'form-check-reverse': reverse,
52
+ [`form-switch-${size}`]: size,
53
+ 'is-invalid': invalid,
54
+ 'is-valid': valid,
55
+ },
56
+ className,
57
+ )}
58
+ >
59
+ <input
60
+ type={type}
61
+ className={classNames('form-check-input', {
62
+ 'is-invalid': invalid,
63
+ 'is-valid': valid,
64
+ })}
65
+ id={id}
66
+ {...rest}
67
+ ref={ref}
68
+ />
59
69
  {label && (
60
- <CFormLabel customClassName={labelClassName} {...(id && { htmlFor: id })}>
70
+ <CFormLabel customClassName="form-check-label" {...(id && { htmlFor: id })}>
61
71
  {label}
62
72
  </CFormLabel>
63
73
  )}
@@ -71,6 +81,7 @@ CFormSwitch.propTypes = {
71
81
  id: PropTypes.string,
72
82
  invalid: PropTypes.bool,
73
83
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
84
+ reverse: PropTypes.bool,
74
85
  size: PropTypes.oneOf(['lg', 'xl']),
75
86
  type: PropTypes.oneOf(['checkbox', 'radio']),
76
87
  valid: PropTypes.bool,
@@ -15,9 +15,8 @@ export interface CFormTextProps extends HTMLAttributes<HTMLDivElement | HTMLSpan
15
15
 
16
16
  export const CFormText = forwardRef<HTMLDivElement | HTMLSpanElement, CFormTextProps>(
17
17
  ({ children, className, component: Component = 'div', ...rest }, ref) => {
18
- const _className = classNames('form-text', className)
19
18
  return (
20
- <Component className={_className} {...rest} ref={ref}>
19
+ <Component className={classNames('form-text', className)} {...rest} ref={ref}>
21
20
  {children}
22
21
  </Component>
23
22
  )
@@ -1,7 +1,6 @@
1
1
  import React, { ChangeEventHandler, forwardRef, TextareaHTMLAttributes } from 'react'
2
-
3
- import classNames from 'classnames'
4
2
  import PropTypes from 'prop-types'
3
+ import classNames from 'classnames'
5
4
 
6
5
  import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
7
6
 
@@ -57,14 +56,6 @@ export const CFormTextarea = forwardRef<HTMLTextAreaElement, CFormTextareaProps>
57
56
  },
58
57
  ref,
59
58
  ) => {
60
- const _className = classNames(
61
- plainText ? 'form-control-plaintext' : 'form-control',
62
- {
63
- 'is-invalid': invalid,
64
- 'is-valid': valid,
65
- },
66
- className,
67
- )
68
59
  return (
69
60
  <CFormControlWrapper
70
61
  describedby={rest['aria-describedby']}
@@ -80,7 +71,19 @@ export const CFormTextarea = forwardRef<HTMLTextAreaElement, CFormTextareaProps>
80
71
  tooltipFeedback={tooltipFeedback}
81
72
  valid={valid}
82
73
  >
83
- <textarea className={_className} id={id} {...rest} ref={ref}>
74
+ <textarea
75
+ className={classNames(
76
+ plainText ? 'form-control-plaintext' : 'form-control',
77
+ {
78
+ 'is-invalid': invalid,
79
+ 'is-valid': valid,
80
+ },
81
+ className,
82
+ )}
83
+ id={id}
84
+ {...rest}
85
+ ref={ref}
86
+ >
84
87
  {children}
85
88
  </textarea>
86
89
  </CFormControlWrapper>
@@ -15,15 +15,18 @@ export interface CInputGroupProps extends HTMLAttributes<HTMLDivElement> {
15
15
 
16
16
  export const CInputGroup = forwardRef<HTMLDivElement, CInputGroupProps>(
17
17
  ({ children, className, size, ...rest }, ref) => {
18
- const _className = classNames(
19
- 'input-group',
20
- {
21
- [`input-group-${size}`]: size,
22
- },
23
- className,
24
- )
25
18
  return (
26
- <div className={_className} {...rest} ref={ref}>
19
+ <div
20
+ className={classNames(
21
+ 'input-group',
22
+ {
23
+ [`input-group-${size}`]: size,
24
+ },
25
+ className,
26
+ )}
27
+ {...rest}
28
+ ref={ref}
29
+ >
27
30
  {children}
28
31
  </div>
29
32
  )
@@ -16,9 +16,8 @@ export interface CInputGroupTextProps
16
16
 
17
17
  export const CInputGroupText = forwardRef<HTMLLabelElement | HTMLSpanElement, CInputGroupTextProps>(
18
18
  ({ children, className, component: Component = 'span', ...rest }, ref) => {
19
- const _className = classNames('input-group-text', className)
20
19
  return (
21
- <Component className={_className} {...rest} ref={ref}>
20
+ <Component className={classNames('input-group-text', className)} {...rest} ref={ref}>
22
21
  {children}
23
22
  </Component>
24
23
  )
@@ -27,7 +27,7 @@ test('CFormRange customize', async () => {
27
27
  expect(container.firstChild).toHaveAttribute('max', '150')
28
28
  expect(container.firstChild).toHaveAttribute('min', '20')
29
29
  expect(container.firstChild).toHaveAttribute('readonly', '')
30
- expect(container.firstChild).toHaveAttribute('steps', '2')
30
+ expect(container.firstChild).toHaveAttribute('step', '2')
31
31
  expect(container.firstChild).toHaveAttribute('type', 'range')
32
32
  expect(container.firstChild).toHaveAttribute('value', '80')
33
33
  })
@@ -12,9 +12,7 @@ exports[`CForm customize 1`] = `
12
12
 
13
13
  exports[`CForm example 1`] = `
14
14
  <div>
15
- <form
16
- class=""
17
- >
15
+ <form>
18
16
  <label
19
17
  class="form-label"
20
18
  >
@@ -55,9 +53,7 @@ exports[`CForm example 1`] = `
55
53
 
56
54
  exports[`loads and displays CForm component 1`] = `
57
55
  <div>
58
- <form
59
- class=""
60
- >
56
+ <form>
61
57
  Test
62
58
  </form>
63
59
  </div>
@@ -8,7 +8,7 @@ exports[`CFormRange customize 1`] = `
8
8
  max="150"
9
9
  min="20"
10
10
  readonly=""
11
- steps="2"
11
+ step="2"
12
12
  type="range"
13
13
  value="80"
14
14
  />
@@ -19,7 +19,7 @@ exports[`loads and displays CFormRange component 1`] = `
19
19
  <div>
20
20
  <input
21
21
  class="form-range"
22
- steps="3"
22
+ step="3"
23
23
  type="range"
24
24
  />
25
25
  </div>
@@ -101,13 +101,15 @@ export const CCol = forwardRef<HTMLDivElement, CColProps>(
101
101
  }
102
102
  })
103
103
 
104
- const _className = classNames(
105
- repsonsiveClassNames.length ? repsonsiveClassNames : 'col',
106
- className,
107
- )
108
-
109
104
  return (
110
- <div className={_className} {...rest} ref={ref}>
105
+ <div
106
+ className={classNames(
107
+ repsonsiveClassNames.length > 0 ? repsonsiveClassNames : 'col',
108
+ className,
109
+ )}
110
+ {...rest}
111
+ ref={ref}
112
+ >
111
113
  {children}
112
114
  </div>
113
115
  )
@@ -53,13 +53,15 @@ export const CContainer = forwardRef<HTMLDivElement, CContainerProps>(
53
53
  breakpoint && repsonsiveClassNames.push(`container-${bp}`)
54
54
  })
55
55
 
56
- const _className = classNames(
57
- repsonsiveClassNames.length ? repsonsiveClassNames : 'container',
58
- className,
59
- )
60
-
61
56
  return (
62
- <div className={_className} {...rest} ref={ref}>
57
+ <div
58
+ className={classNames(
59
+ repsonsiveClassNames.length > 0 ? repsonsiveClassNames : 'container',
60
+ className,
61
+ )}
62
+ {...rest}
63
+ ref={ref}
64
+ >
63
65
  {children}
64
66
  </div>
65
67
  )
@@ -75,22 +75,23 @@ export const CRow = forwardRef<HTMLDivElement, CRowProps>(
75
75
  if (breakpoint.cols) {
76
76
  repsonsiveClassNames.push(`row-cols${infix}-${breakpoint.cols}`)
77
77
  }
78
+
78
79
  if (typeof breakpoint.gutter === 'number') {
79
80
  repsonsiveClassNames.push(`g${infix}-${breakpoint.gutter}`)
80
81
  }
82
+
81
83
  if (typeof breakpoint.gutterX === 'number') {
82
84
  repsonsiveClassNames.push(`gx${infix}-${breakpoint.gutterX}`)
83
85
  }
86
+
84
87
  if (typeof breakpoint.gutterY === 'number') {
85
88
  repsonsiveClassNames.push(`gy${infix}-${breakpoint.gutterY}`)
86
89
  }
87
90
  }
88
91
  })
89
92
 
90
- const _className = classNames('row', repsonsiveClassNames, className)
91
-
92
93
  return (
93
- <div className={_className} ref={ref}>
94
+ <div className={classNames('row', repsonsiveClassNames, className)} ref={ref}>
94
95
  {children}
95
96
  </div>
96
97
  )
@@ -19,20 +19,19 @@ export interface CHeaderProps extends HTMLAttributes<HTMLDivElement> {
19
19
 
20
20
  export const CHeader = forwardRef<HTMLDivElement, CHeaderProps>(
21
21
  ({ children, className, container, position, ...rest }, ref) => {
22
- const _className = classNames('header', { [`header-${position}`]: position }, className)
23
-
24
- let content
25
- if (container) {
26
- content = (
27
- <div className={`container${container !== true ? '-' + container : ''}`}>{children}</div>
28
- )
29
- } else {
30
- content = children
31
- }
32
-
33
22
  return (
34
- <div className={_className} {...rest} ref={ref}>
35
- {content}
23
+ <div
24
+ className={classNames('header', { [`header-${position}`]: position }, className)}
25
+ {...rest}
26
+ ref={ref}
27
+ >
28
+ {container ? (
29
+ <div className={typeof container === 'string' ? `container-${container}` : 'container'}>
30
+ {children}
31
+ </div>
32
+ ) : (
33
+ <>{children}</>
34
+ )}
36
35
  </div>
37
36
  )
38
37
  },
@@ -22,10 +22,8 @@ export const CHeaderBrand = forwardRef<
22
22
  HTMLAnchorElement | HTMLLinkElement | HTMLSpanElement,
23
23
  CHeaderBrandProps
24
24
  >(({ children, component: Component = 'a', className, ...rest }, ref) => {
25
- const _className = classNames('header-brand', className)
26
-
27
25
  return (
28
- <Component className={_className} {...rest} ref={ref}>
26
+ <Component className={classNames('header-brand', className)} {...rest} ref={ref}>
29
27
  {children}
30
28
  </Component>
31
29
  )
@@ -16,10 +16,8 @@ export interface CHeaderBrandProps
16
16
 
17
17
  export const CHeaderBrand = forwardRef<HTMLAnchorElement | HTMLSpanElement, CHeaderBrandProps>(
18
18
  ({ children, component: Component = 'a', className, ...rest }, ref) => {
19
- const _className = classNames('header-brand', className)
20
-
21
19
  return (
22
- <Component className={_className} {...rest} ref={ref}>
20
+ <Component className={classNames('header-brand', className)} {...rest} ref={ref}>
23
21
  {children}
24
22
  </Component>
25
23
  )
@@ -11,9 +11,7 @@ export interface CHeaderDividerProps extends HTMLAttributes<HTMLDivElement> {
11
11
 
12
12
  export const CHeaderDivider = forwardRef<HTMLDivElement, CHeaderDividerProps>(
13
13
  ({ className, ...rest }, ref) => {
14
- const _className = classNames('header-divider', className)
15
-
16
- return <div className={_className} {...rest} ref={ref} />
14
+ return <div className={classNames('header-divider', className)} {...rest} ref={ref} />
17
15
  },
18
16
  )
19
17
 
@@ -15,10 +15,13 @@ export interface CHeaderNavProps extends HTMLAttributes<HTMLDivElement | HTMLULi
15
15
 
16
16
  export const CHeaderNav = forwardRef<HTMLDivElement | HTMLUListElement, CHeaderNavProps>(
17
17
  ({ children, component: Component = 'ul', className, ...rest }, ref) => {
18
- const _className = classNames('header-nav', className)
19
-
20
18
  return (
21
- <Component className={_className} role="navigation" {...rest} ref={ref}>
19
+ <Component
20
+ className={classNames('header-nav', className)}
21
+ role="navigation"
22
+ {...rest}
23
+ ref={ref}
24
+ >
22
25
  {children}
23
26
  </Component>
24
27
  )
@@ -11,10 +11,8 @@ export interface CHeaderTextProps extends HTMLAttributes<HTMLSpanElement> {
11
11
 
12
12
  export const CHeaderText = forwardRef<HTMLSpanElement, CHeaderTextProps>(
13
13
  ({ children, className, ...rest }, ref) => {
14
- const _className = classNames('header-text', className)
15
-
16
14
  return (
17
- <span className={_className} {...rest} ref={ref}>
15
+ <span className={classNames('header-text', className)} {...rest} ref={ref}>
18
16
  {children}
19
17
  </span>
20
18
  )
@@ -11,11 +11,9 @@ export interface CHeaderTogglerProps extends HTMLAttributes<HTMLButtonElement> {
11
11
 
12
12
  export const CHeaderToggler = forwardRef<HTMLButtonElement, CHeaderTogglerProps>(
13
13
  ({ children, className, ...rest }, ref) => {
14
- const _className = classNames('header-toggler', className)
15
-
16
14
  return (
17
- <button type="button" className={_className} {...rest} ref={ref}>
18
- {children ? children : <span className="header-toggler-icon"></span>}
15
+ <button type="button" className={classNames('header-toggler', className)} {...rest} ref={ref}>
16
+ {children ?? <span className="header-toggler-icon"></span>}
19
17
  </button>
20
18
  )
21
19
  },
@@ -27,17 +27,24 @@ export interface CImageProps extends ImgHTMLAttributes<HTMLOrSVGImageElement> {
27
27
 
28
28
  export const CImage = forwardRef<HTMLImageElement, CImageProps>(
29
29
  ({ align, className, fluid, rounded, thumbnail, ...rest }, ref) => {
30
- const _className = classNames(
31
- {
32
- [`float-${align}`]: align && (align === 'start' || align === 'end'),
33
- 'd-block mx-auto': align && align === 'center',
34
- 'img-fluid': fluid,
35
- rounded: rounded,
36
- 'img-thumbnail': thumbnail,
37
- },
38
- className,
30
+ return (
31
+ <img
32
+ className={
33
+ classNames(
34
+ {
35
+ [`float-${align}`]: align && (align === 'start' || align === 'end'),
36
+ 'd-block mx-auto': align && align === 'center',
37
+ 'img-fluid': fluid,
38
+ rounded: rounded,
39
+ 'img-thumbnail': thumbnail,
40
+ },
41
+ className,
42
+ ) || undefined
43
+ }
44
+ {...rest}
45
+ ref={ref}
46
+ />
39
47
  )
40
- return <img className={_className} {...rest} ref={ref} />
41
48
  },
42
49
  )
43
50
 
@@ -18,8 +18,6 @@ exports[`CImage customize two 1`] = `
18
18
 
19
19
  exports[`loads and displays CImage component 1`] = `
20
20
  <div>
21
- <img
22
- class=""
23
- />
21
+ <img />
24
22
  </div>
25
23
  `;
@@ -11,6 +11,7 @@ export * from './card'
11
11
  export * from './carousel'
12
12
  export * from './close-button'
13
13
  export * from './collapse'
14
+ export * from './conditional-portal'
14
15
  export * from './date-picker'
15
16
  export * from './date-range-picker'
16
17
  export * from './dropdown'
@@ -27,12 +27,10 @@ export interface CLinkProps extends AllHTMLAttributes<HTMLButtonElement | HTMLAn
27
27
 
28
28
  export const CLink = forwardRef<HTMLButtonElement | HTMLAnchorElement, CLinkProps>(
29
29
  ({ children, active, className, component: Component = 'a', disabled, ...rest }, ref) => {
30
- // TODO: remove duplicated classes ex. `active active` in `<CListGroupItem>`
31
- const _className = classNames(className, { active, disabled })
32
-
33
30
  return (
34
31
  <Component
35
- className={_className}
32
+ // TODO: remove duplicated classes ex. `active active` in `<CListGroupItem>`
33
+ className={classNames(className, { active, disabled })}
36
34
  {...(active && { 'aria-current': 'page' })}
37
35
  {...(Component === 'a' && disabled && { 'aria-disabled': true, tabIndex: -1 })}
38
36
  {...((Component === 'a' || Component === 'button') && {
@@ -29,17 +29,18 @@ export interface CListGroupProps extends HTMLAttributes<HTMLDivElement | HTMLULi
29
29
 
30
30
  export const CListGroup = forwardRef<HTMLDivElement | HTMLUListElement, CListGroupProps>(
31
31
  ({ children, className, component: Component = 'ul', flush, layout }, ref) => {
32
- const _className = classNames(
33
- 'list-group',
34
- {
35
- 'list-group-flush': flush,
36
- [`list-group-${layout}`]: layout,
37
- },
38
- className,
39
- )
40
-
41
32
  return (
42
- <Component className={_className} ref={ref}>
33
+ <Component
34
+ className={classNames(
35
+ 'list-group',
36
+ {
37
+ 'list-group-flush': flush,
38
+ [`list-group-${layout}`]: layout,
39
+ },
40
+ className,
41
+ )}
42
+ ref={ref}
43
+ >
43
44
  {children}
44
45
  </Component>
45
46
  )
@@ -1,12 +1,14 @@
1
- import React, { ElementType, HTMLAttributes, forwardRef } from 'react'
1
+ import React, { ElementType, AnchorHTMLAttributes, forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
5
- import { Colors, colorPropType } from '../Types'
6
5
  import { CLink } from '../link/CLink'
7
6
 
7
+ import { colorPropType } from '../../props'
8
+ import type { Colors } from '../../types'
9
+
8
10
  export interface CListGroupItemProps
9
- extends HTMLAttributes<HTMLLIElement | HTMLAnchorElement | HTMLButtonElement | HTMLLinkElement> {
11
+ extends AnchorHTMLAttributes<HTMLLIElement | HTMLAnchorElement | HTMLButtonElement> {
10
12
  /**
11
13
  * Toggle the active state for the component.
12
14
  */
@@ -29,32 +31,19 @@ export interface CListGroupItemProps
29
31
  * Component used for the root node. Either a string to use a HTML element or a component.
30
32
  */
31
33
  component?: string | ElementType
32
- href?: string
33
34
  }
34
35
 
35
36
  export const CListGroupItem = forwardRef<
36
- HTMLLIElement | HTMLAnchorElement | HTMLButtonElement | HTMLLinkElement,
37
+ HTMLLIElement | HTMLAnchorElement | HTMLButtonElement,
37
38
  CListGroupItemProps
38
- >(({ children, active, className, disabled, href, color, component = 'li', ...rest }, ref) => {
39
- const _className = classNames(
40
- 'list-group-item',
41
- {
42
- [`list-group-item-${color}`]: color,
43
- 'list-group-item-action': component === 'a' || component === 'button',
44
- active,
45
- disabled,
46
- },
47
- className,
48
- )
49
-
39
+ >(({ children, active, className, disabled, color, component = 'li', ...rest }, ref) => {
50
40
  const Component = component === 'a' || component === 'button' ? CLink : component
51
41
 
52
42
  rest = {
53
43
  ...((component === 'a' || component === 'button') && {
54
44
  active,
55
- component,
56
45
  disabled,
57
- href: href,
46
+ component,
58
47
  ref: ref,
59
48
  }),
60
49
  ...(active && { 'aria-current': true }),
@@ -63,7 +52,19 @@ export const CListGroupItem = forwardRef<
63
52
  }
64
53
 
65
54
  return (
66
- <Component className={_className} {...rest}>
55
+ <Component
56
+ className={classNames(
57
+ 'list-group-item',
58
+ {
59
+ [`list-group-item-${color}`]: color,
60
+ 'list-group-item-action': component === 'a' || component === 'button',
61
+ active,
62
+ disabled,
63
+ },
64
+ className,
65
+ )}
66
+ {...rest}
67
+ >
67
68
  {children}
68
69
  </Component>
69
70
  )
@@ -2,9 +2,11 @@ import React, { ElementType, AnchorHTMLAttributes, forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
5
- import { Colors, colorPropType } from '../Types'
6
5
  import { CLink } from '../link/CLink'
7
6
 
7
+ import { colorPropType } from '../../props'
8
+ import type { Colors } from '../../types'
9
+
8
10
  export interface CListGroupItemProps
9
11
  extends AnchorHTMLAttributes<HTMLLIElement | HTMLAnchorElement | HTMLButtonElement> {
10
12
  /**
@@ -60,11 +60,9 @@ export const CLoadingButton = forwardRef<HTMLButtonElement, CLoadingButtonProps>
60
60
  }
61
61
  }
62
62
 
63
- const _className = classNames('btn-loading', _loading && 'is-loading', className)
64
-
65
63
  return (
66
64
  <CButton
67
- className={_className}
65
+ className={classNames('btn-loading', _loading && 'is-loading', className)}
68
66
  {...(disabledOnLoading && _loading && { disabled: true })}
69
67
  onClick={handleOnClick}
70
68
  {...rest}