@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.
- package/README.md +1 -1
- package/dist/components/alert/CAlert.d.ts +1 -1
- package/dist/components/avatar/CAvatar.d.ts +1 -1
- package/dist/components/badge/CBadge.d.ts +1 -1
- package/dist/components/button/CButton.d.ts +1 -1
- package/dist/components/calendar/utils.d.ts +0 -1
- package/dist/components/callout/CCallout.d.ts +1 -1
- package/dist/components/card/CCard.d.ts +1 -1
- package/dist/components/conditional-portal/CConditionalPortal.d.ts +12 -0
- package/dist/components/conditional-portal/index.d.ts +2 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +1 -1
- package/dist/components/date-range-picker/utils.d.ts +1 -0
- package/dist/components/dropdown/CDropdown.d.ts +1 -1
- package/dist/components/dropdown/CDropdownToggle.d.ts +1 -1
- package/dist/components/form/CFormCheck.d.ts +8 -2
- package/dist/components/form/CFormSwitch.d.ts +6 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/list-group/CListGroupItem.d.ts +4 -5
- package/dist/components/multi-select/CMultiSelect.d.ts +1 -13
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
- package/dist/components/multi-select/types.d.ts +14 -0
- package/dist/components/multi-select/utils.d.ts +6 -0
- package/dist/components/navbar/CNavbar.d.ts +1 -1
- package/dist/components/picker/CPicker.d.ts +1 -1
- package/dist/components/placeholder/CPlaceholder.d.ts +1 -1
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/progress/CProgressBar.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableHead.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableInterface.d.ts +8 -0
- package/dist/components/smart-table/types.d.ts +1 -1
- package/dist/components/spinner/CSpinner.d.ts +1 -1
- package/dist/components/table/CTable.d.ts +2 -18
- package/dist/components/table/CTableBody.d.ts +1 -1
- package/dist/components/table/CTableDataCell.d.ts +1 -1
- package/dist/components/table/CTableFoot.d.ts +1 -1
- package/dist/components/table/CTableHead.d.ts +1 -1
- package/dist/components/table/CTableHeaderCell.d.ts +1 -1
- package/dist/components/table/CTableResponsiveWrapper.d.ts +0 -1
- package/dist/components/table/CTableRow.d.ts +1 -1
- package/dist/components/table/types.d.ts +17 -0
- package/dist/components/table/utils.d.ts +5 -0
- package/dist/components/toast/CToast.d.ts +1 -1
- package/dist/components/toast/CToastClose.d.ts +1 -1
- package/dist/components/tooltip/CTooltip.d.ts +1 -1
- package/dist/components/virtual-scroller/CVirtualScroller.d.ts +0 -8
- package/dist/components/widgets/CWidgetStatsA.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsB.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsC.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsD.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsF.d.ts +1 -1
- package/dist/index.es.js +696 -927
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +695 -925
- package/dist/index.js.map +1 -1
- package/dist/props.d.ts +8 -0
- package/dist/types.d.ts +7 -0
- package/dist/utils/index.d.ts +1 -3
- package/package.json +11 -6
- package/src/components/accordion/CAccordion.tsx +7 -3
- package/src/components/accordion/CAccordionBody.tsx +2 -2
- package/src/components/accordion/CAccordionButton.tsx +1 -3
- package/src/components/accordion/CAccordionCollapse.tsx +1 -0
- package/src/components/accordion/CAccordionHeader.tsx +1 -3
- package/src/components/accordion/CAccordionItem.tsx +2 -4
- package/src/components/accordion/__tests__/__snapshots__/CAccordionBody.spec.tsx.snap +2 -2
- package/src/components/alert/CAlert.tsx +21 -28
- package/src/components/alert/CAlertHeading.tsx +1 -3
- package/src/components/alert/CAlertLink.tsx +1 -3
- package/src/components/alert/__tests__/__snapshots__/CAlert.spec.tsx.snap +1 -1
- package/src/components/avatar/CAvatar.tsx +16 -19
- package/src/components/backdrop/CBackdrop.tsx +10 -13
- package/src/components/badge/CBadge.tsx +21 -27
- package/src/components/breadcrumb/CBreadcrumb.tsx +1 -2
- package/src/components/breadcrumb/CBreadcrumbItem.tsx +12 -8
- package/src/components/button/CButton.tsx +10 -10
- package/src/components/button-group/CButtonGroup.tsx +9 -7
- package/src/components/button-group/CButtonToolbar.tsx +1 -3
- package/src/components/calendar/utils.ts +7 -55
- package/src/components/callout/CCallout.tsx +13 -10
- package/src/components/card/CCard.tsx +14 -11
- package/src/components/card/CCardBody.tsx +1 -3
- package/src/components/card/CCardFooter.tsx +1 -3
- package/src/components/card/CCardGroup.tsx +1 -3
- package/src/components/card/CCardHeader.tsx +1 -3
- package/src/components/card/CCardImage.tsx +5 -3
- package/src/components/card/CCardImageOverlay.tsx +1 -3
- package/src/components/card/CCardLink.tsx +1 -3
- package/src/components/card/CCardSubtitle.tsx +1 -3
- package/src/components/card/CCardText.tsx +1 -3
- package/src/components/card/CCardTitle.tsx +1 -3
- package/src/components/carousel/CCarousel.tsx +8 -8
- package/src/components/carousel/CCarouselCaption.tsx +1 -3
- package/src/components/carousel/CCarouselItem.tsx +11 -9
- package/src/components/close-button/CCloseButton.tsx +9 -10
- package/src/components/collapse/CCollapse.tsx +8 -20
- package/src/components/collapse/__tests__/CCollapse.spec.tsx +2 -3
- package/src/components/conditional-portal/CConditionalPortal.tsx +29 -0
- package/src/components/conditional-portal/index.ts +3 -0
- package/src/components/date-range-picker/CDateRangePicker.tsx +11 -13
- package/src/components/date-range-picker/utils.ts +49 -0
- package/src/components/dropdown/CDropdown.tsx +26 -23
- package/src/components/dropdown/CDropdownDivider.tsx +1 -3
- package/src/components/dropdown/CDropdownHeader.tsx +1 -3
- package/src/components/dropdown/CDropdownItem.tsx +7 -5
- package/src/components/dropdown/CDropdownItemPlain.tsx +1 -3
- package/src/components/dropdown/CDropdownMenu.tsx +29 -32
- package/src/components/dropdown/CDropdownToggle.tsx +34 -27
- package/src/components/dropdown/__tests__/CDropdown.spec.tsx +2 -4
- package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
- package/src/components/footer/CFooter.tsx +5 -3
- package/src/components/form/CForm.tsx +5 -2
- package/src/components/form/CFormCheck.tsx +90 -66
- package/src/components/form/CFormControlValidation.tsx +0 -1
- package/src/components/form/CFormControlWrapper.tsx +3 -4
- package/src/components/form/CFormFeedback.tsx +11 -8
- package/src/components/form/CFormFloating.tsx +1 -2
- package/src/components/form/CFormInput.tsx +18 -16
- package/src/components/form/CFormLabel.tsx +1 -2
- package/src/components/form/CFormRange.tsx +2 -4
- package/src/components/form/CFormSelect.tsx +16 -12
- package/src/components/form/CFormSwitch.tsx +31 -20
- package/src/components/form/CFormText.tsx +1 -2
- package/src/components/form/CFormTextarea.tsx +14 -11
- package/src/components/form/CInputGroup.tsx +11 -8
- package/src/components/form/CInputGroupText.tsx +1 -2
- package/src/components/form/__tests__/CFormRange.spec.tsx +1 -1
- package/src/components/form/__tests__/__snapshots__/CForm.spec.tsx.snap +2 -6
- package/src/components/form/__tests__/__snapshots__/CFormRange.spec.tsx.snap +2 -2
- package/src/components/grid/CCol.tsx +8 -6
- package/src/components/grid/CContainer.tsx +8 -6
- package/src/components/grid/CRow.tsx +4 -3
- package/src/components/header/CHeader.tsx +12 -13
- package/src/components/header/CHeaderBrand.tsx +1 -3
- package/src/components/header/CHeaderBrand.tsx~HEAD +1 -3
- package/src/components/header/CHeaderDivider.tsx +1 -3
- package/src/components/header/CHeaderNav.tsx +6 -3
- package/src/components/header/CHeaderText.tsx +1 -3
- package/src/components/header/CHeaderToggler.tsx +2 -4
- package/src/components/image/CImage.tsx +17 -10
- package/src/components/image/__tests__/__snapshots__/CImage.spec.tsx.snap +1 -3
- package/src/components/index.ts +1 -0
- package/src/components/link/CLink.tsx +2 -4
- package/src/components/list-group/CListGroup.tsx +11 -10
- package/src/components/list-group/CListGroupItem.tsx +21 -20
- package/src/components/list-group/CListGroupItem.tsx~HEAD +3 -1
- package/src/components/loading-button/CLoadingButton.tsx +1 -3
- package/src/components/modal/CModal.tsx +57 -72
- package/src/components/modal/CModalBody.tsx +1 -3
- package/src/components/modal/CModalContent.tsx +1 -3
- package/src/components/modal/CModalDialog.tsx +16 -14
- package/src/components/modal/CModalFooter.tsx +1 -3
- package/src/components/modal/CModalHeader.tsx +4 -4
- package/src/components/modal/CModalTitle.tsx +1 -3
- package/src/components/modal/__tests__/CModal.spec.tsx +19 -20
- package/src/components/multi-select/CMultiSelect.tsx +34 -93
- package/src/components/multi-select/CMultiSelectNativeSelect.tsx +1 -1
- package/src/components/multi-select/CMultiSelectOptions.tsx +2 -2
- package/src/components/multi-select/CMultiSelectSelection.tsx +1 -1
- package/src/components/multi-select/types.ts +15 -0
- package/src/components/multi-select/utils.ts +92 -0
- package/src/components/nav/CNav.tsx +13 -10
- package/src/components/nav/CNavGroup.tsx +1 -3
- package/src/components/nav/CNavGroupItems.tsx +1 -2
- package/src/components/nav/CNavItem.tsx +9 -10
- package/src/components/nav/CNavLink.tsx +4 -5
- package/src/components/nav/CNavTitle.tsx +1 -2
- package/src/components/navbar/CNavbar.tsx +23 -23
- package/src/components/navbar/CNavbarBrand.tsx +2 -3
- package/src/components/navbar/CNavbarNav.tsx +6 -3
- package/src/components/navbar/CNavbarText.tsx +1 -3
- package/src/components/navbar/CNavbarToggler.tsx +2 -4
- package/src/components/offcanvas/COffcanvas.tsx +42 -68
- package/src/components/offcanvas/COffcanvasBody.tsx +1 -3
- package/src/components/offcanvas/COffcanvasHeader.tsx +1 -3
- package/src/components/offcanvas/COffcanvasTitle.tsx +1 -3
- package/src/components/offcanvas/__tests__/COffcanvas.spec.tsx +7 -2
- package/src/components/offcanvas/__tests__/__snapshots__/COffcanvas.spec.tsx.snap +9 -4
- package/src/components/pagination/CPagination.tsx +12 -9
- package/src/components/pagination/CPaginationItem.tsx +12 -11
- package/src/components/pagination/__tests__/CPagination.spec.tsx +3 -3
- package/src/components/pagination/__tests__/CPaginationItem.spec.tsx +3 -3
- package/src/components/picker/CPicker.tsx +7 -7
- package/src/components/placeholder/CPlaceholder.tsx +15 -12
- package/src/components/popover/CPopover.tsx +24 -34
- package/src/components/progress/CProgress.tsx +13 -10
- package/src/components/progress/CProgressBar.tsx +11 -12
- package/src/components/sidebar/CSidebar.tsx +22 -19
- package/src/components/sidebar/CSidebarBrand.tsx +1 -2
- package/src/components/sidebar/CSidebarFooter.tsx +1 -2
- package/src/components/sidebar/CSidebarHeader.tsx +1 -2
- package/src/components/sidebar/CSidebarNav.tsx +2 -2
- package/src/components/sidebar/CSidebarToggler.tsx +1 -2
- package/src/components/smart-pagination/CSmartPagination.tsx +22 -20
- package/src/components/smart-table/CSmartTable.tsx +5 -9
- package/src/components/smart-table/CSmartTableBody.tsx +82 -81
- package/src/components/smart-table/CSmartTableHead.tsx +5 -2
- package/src/components/smart-table/CSmartTableInterface.tsx +8 -0
- package/src/components/smart-table/{utils.tsx → utils.ts} +4 -5
- package/src/components/spinner/CSpinner.tsx +13 -9
- package/src/components/table/CTable.tsx +45 -77
- package/src/components/table/CTableBody.tsx +14 -9
- package/src/components/table/CTableDataCell.tsx +16 -11
- package/src/components/table/CTableFoot.tsx +14 -9
- package/src/components/table/CTableHead.tsx +14 -9
- package/src/components/table/CTableHeaderCell.tsx +14 -9
- package/src/components/table/CTableResponsiveWrapper.tsx +2 -3
- package/src/components/table/CTableRow.tsx +16 -11
- package/src/components/table/__tests__/__snapshots__/CTable.spec.tsx.snap +1 -5
- package/src/components/table/types.ts +20 -0
- package/src/components/table/utils.ts +24 -0
- package/src/components/tabs/CTabContent.tsx +1 -2
- package/src/components/tabs/CTabPane.tsx +18 -20
- package/src/components/tabs/__tests__/CTabPane.spec.tsx +2 -5
- package/src/components/tabs/__tests__/__snapshots__/CTabPane.spec.tsx.snap +1 -1
- package/src/components/time-picker/CTimePicker.tsx +14 -18
- package/src/components/toast/CToast.tsx +32 -45
- package/src/components/toast/CToastBody.tsx +1 -2
- package/src/components/toast/CToastClose.tsx +4 -2
- package/src/components/toast/CToastHeader.tsx +1 -2
- package/src/components/toast/CToaster.tsx +27 -26
- package/src/components/toast/__tests__/CToast.spec.tsx +2 -1
- package/src/components/toast/__tests__/__snapshots__/CToast.spec.tsx.snap +1 -66
- package/src/components/tooltip/CTooltip.tsx +24 -34
- package/src/components/virtual-scroller/CVirtualScroller.tsx +35 -60
- package/src/components/widgets/CWidgetStatsA.tsx +11 -9
- package/src/components/widgets/CWidgetStatsB.tsx +4 -4
- package/src/components/widgets/CWidgetStatsC.tsx +4 -4
- package/src/components/widgets/CWidgetStatsD.tsx +13 -15
- package/src/components/widgets/CWidgetStatsE.tsx +2 -5
- package/src/components/widgets/CWidgetStatsF.tsx +4 -8
- package/src/{components/Types.tsx → props.ts} +1 -68
- package/src/types.ts +68 -0
- package/src/utils/index.ts +1 -3
- package/src/components/multi-select/CMultiSelectCleaner.tsx +0 -18
- package/src/utils/getNextSibling.ts +0 -18
- package/src/utils/getPreviousSibling.ts +0 -18
- 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
|
|
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
|
|
58
|
-
|
|
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=
|
|
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={
|
|
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
|
|
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
|
|
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={
|
|
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('
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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={
|
|
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
|
|
35
|
-
{
|
|
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={
|
|
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={
|
|
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
|
-
|
|
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
|
|
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={
|
|
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={
|
|
18
|
-
{children
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
package/src/components/index.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
37
|
+
HTMLLIElement | HTMLAnchorElement | HTMLButtonElement,
|
|
37
38
|
CListGroupItemProps
|
|
38
|
-
>(({ children, active, className, disabled,
|
|
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
|
-
|
|
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
|
|
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={
|
|
65
|
+
className={classNames('btn-loading', _loading && 'is-loading', className)}
|
|
68
66
|
{...(disabledOnLoading && _loading && { disabled: true })}
|
|
69
67
|
onClick={handleOnClick}
|
|
70
68
|
{...rest}
|