@coreui/react-pro 4.2.0-beta.0 → 4.2.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/accordion/index.d.ts +7 -0
- package/dist/components/alert/index.d.ts +4 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/backdrop/index.d.ts +2 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button-group/index.d.ts +3 -0
- package/dist/components/calendar/CCalendar.d.ts +36 -12
- package/dist/components/callout/index.d.ts +2 -0
- package/dist/components/card/index.d.ts +12 -0
- package/dist/components/carousel/index.d.ts +4 -0
- package/dist/components/close-button/index.d.ts +2 -0
- package/dist/components/collapse/index.d.ts +2 -0
- package/dist/components/date-picker/CDatePicker.d.ts +13 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +93 -0
- package/dist/components/date-range-picker/index.d.ts +2 -0
- package/dist/components/datepicker/index.d.ts +2 -0
- package/dist/components/daterangepicker/CDateRangePicker.d.ts +26 -11
- package/dist/components/daterangepicker/index.d.ts +2 -0
- package/dist/components/dropdown/index.d.ts +8 -0
- package/dist/components/footer/index.d.ts +2 -0
- package/dist/components/form/CForm.d.ts +2 -2
- package/dist/components/form/CFormCheck.d.ts +2 -1
- package/dist/components/form/CFormControlValidation.d.ts +46 -0
- package/dist/components/form/CFormControlWrapper.d.ts +31 -0
- package/dist/components/form/CFormInput.d.ts +6 -9
- package/dist/components/form/CFormRange.d.ts +7 -1
- package/dist/components/form/CFormSelect.d.ts +3 -10
- package/dist/components/form/CFormTextarea.d.ts +2 -9
- package/dist/components/form/index.d.ts +14 -0
- package/dist/components/grid/index.d.ts +4 -0
- package/dist/components/header/index.d.ts +7 -0
- package/dist/components/image/index.d.ts +2 -0
- package/dist/components/index.d.ts +41 -0
- package/dist/components/link/index.d.ts +2 -0
- package/dist/components/list-group/index.d.ts +3 -0
- package/dist/components/loading-button/index.d.ts +2 -0
- package/dist/components/modal/CModal.d.ts +3 -0
- package/dist/components/modal/index.d.ts +8 -0
- package/dist/components/multi-select/index.d.ts +2 -0
- package/dist/components/nav/index.d.ts +7 -0
- package/dist/components/navbar/index.d.ts +6 -0
- package/dist/components/offcanvas/index.d.ts +5 -0
- package/dist/components/pagination/index.d.ts +4 -0
- package/dist/components/picker/CPicker.d.ts +52 -7
- package/dist/components/placeholder/index.d.ts +2 -0
- package/dist/components/popover/CPopover.d.ts +2 -2
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/sidebar/index.d.ts +7 -0
- package/dist/components/smart-table/index.d.ts +2 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/table/index.d.ts +9 -0
- package/dist/components/tabs/index.d.ts +3 -0
- package/dist/components/time-picker/CTimePicker.d.ts +45 -0
- package/dist/components/time-picker/CTimePickerRollCol.d.ts +11 -0
- package/dist/components/time-picker/index.d.ts +2 -0
- package/dist/components/timepicker/CTimePicker.d.ts +9 -13
- package/dist/components/timepicker/index.d.ts +2 -0
- package/dist/components/toast/index.d.ts +6 -0
- package/dist/components/tooltip/CTooltip.d.ts +6 -2
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/index.d.ts +0 -128
- package/dist/index.es.js +8368 -5764
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +8367 -5764
- package/dist/index.js.map +1 -1
- package/dist/{components/calendar/CCalendar.utils.d.ts → utils/calendar.d.ts} +5 -2
- package/dist/utils/hooks/useStateWithCallback.d.ts +2 -1
- package/dist/utils/time.d.ts +21 -0
- package/package.json +14 -11
- package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.tsx.snap +2 -0
- package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.tsx.snap +2 -0
- package/src/components/accordion/index.ts +15 -0
- package/src/components/alert/CAlert.tsx +14 -3
- package/src/components/alert/index.ts +5 -0
- package/src/components/avatar/index.ts +3 -0
- package/src/components/backdrop/CBackdrop.tsx +10 -3
- package/src/components/backdrop/index.ts +3 -0
- package/src/components/badge/index.ts +3 -0
- package/src/components/breadcrumb/index.ts +4 -0
- package/src/components/button/index.ts +3 -0
- package/src/components/button-group/index.ts +4 -0
- package/src/components/calendar/CCalendar.tsx +221 -131
- package/src/components/calendar/__tests__/CCalendar.spec.tsx +9 -0
- package/src/components/calendar/__tests__/__snapshots__/CCalendar.spec.tsx.snap +573 -0
- package/src/components/callout/index.ts +3 -0
- package/src/components/card/index.ts +25 -0
- package/src/components/carousel/index.ts +5 -0
- package/src/components/close-button/index.ts +3 -0
- package/src/components/collapse/CCollapse.tsx +1 -0
- package/src/components/collapse/index.ts +3 -0
- package/src/components/{datepicker → date-picker}/CDatePicker.tsx +3 -2
- package/src/components/date-picker/__tests__/CDatePicker.spec.tsx +9 -0
- package/src/components/date-picker/__tests__/__snapshots__/CDatePicker.spec.tsx.snap +617 -0
- package/src/components/date-picker/index.ts +3 -0
- package/src/components/date-range-picker/CDateRangePicker.tsx +495 -0
- package/src/components/date-range-picker/__tests__/CDateRangePicker.spec.tsx +9 -0
- package/src/components/date-range-picker/__tests__/__snapshots__/CDateRangePicker.spec.tsx.snap +1201 -0
- package/src/components/date-range-picker/index.ts +3 -0
- package/src/components/dropdown/CDropdownItem.tsx +1 -1
- package/src/components/dropdown/CDropdownMenu.tsx +14 -14
- package/src/components/dropdown/index.ts +17 -0
- package/src/components/footer/index.ts +3 -0
- package/src/components/form/CForm.tsx +2 -2
- package/src/components/form/CFormCheck.tsx +32 -7
- package/src/components/form/CFormControlValidation.tsx +97 -0
- package/src/components/form/CFormControlWrapper.tsx +85 -0
- package/src/components/form/CFormInput.tsx +75 -19
- package/src/components/form/CFormRange.tsx +18 -4
- package/src/components/form/CFormSelect.tsx +60 -32
- package/src/components/form/CFormTextarea.tsx +45 -17
- package/src/components/form/index.ts +29 -0
- package/src/components/grid/index.ts +5 -0
- package/src/components/header/index.ts +8 -0
- package/src/components/image/index.ts +3 -0
- package/src/components/index.ts +41 -0
- package/src/components/link/index.ts +3 -0
- package/src/components/list-group/index.ts +4 -0
- package/src/components/loading-button/index.ts +3 -0
- package/src/components/modal/CModal.tsx +3 -2
- package/src/components/modal/index.ts +9 -0
- package/src/components/multi-select/CMultiSelect.tsx +46 -38
- package/src/components/multi-select/index.ts +3 -0
- package/src/components/nav/CNavGroup.tsx +1 -0
- package/src/components/nav/index.ts +8 -0
- package/src/components/navbar/index.ts +7 -0
- package/src/components/offcanvas/COffcanvas.tsx +1 -0
- package/src/components/offcanvas/index.ts +6 -0
- package/src/components/pagination/index.ts +5 -0
- package/src/components/picker/CPicker.tsx +104 -32
- package/src/components/picker/__tests__/CPicker.spec.tsx +9 -0
- package/src/components/picker/__tests__/__snapshots__/CPicker.spec.tsx.snap +23 -0
- package/src/components/placeholder/index.ts +3 -0
- package/src/components/popover/CPopover.tsx +59 -57
- package/src/components/popover/index.ts +3 -0
- package/src/components/progress/index.ts +4 -0
- package/src/components/sidebar/index.ts +8 -0
- package/src/components/smart-table/CSmartTable.tsx +2 -2
- package/src/components/smart-table/index.ts +3 -0
- package/src/components/spinner/index.ts +3 -0
- package/src/components/table/index.ts +19 -0
- package/src/components/tabs/CTabPane.tsx +7 -3
- package/src/components/tabs/index.ts +4 -0
- package/src/components/{timepicker → time-picker}/CTimePicker.tsx +71 -98
- package/src/components/{timepicker → time-picker}/CTimePickerRollCol.tsx +7 -1
- package/src/components/time-picker/__tests__/CTimePicker.spec.tsx +9 -0
- package/src/components/time-picker/index.ts +3 -0
- package/src/components/toast/CToast.tsx +6 -1
- package/src/components/toast/index.ts +7 -0
- package/src/components/tooltip/CTooltip.tsx +63 -45
- package/src/components/tooltip/index.ts +3 -0
- package/src/index.ts +0 -258
- package/src/{components/calendar/CCalendar.utils.ts → utils/calendar.ts} +97 -10
- package/src/utils/hooks/useStateWithCallback.ts +6 -3
- package/src/utils/time.ts +84 -0
- package/dist/components/dropdown/CDropdownToggleCustom.d.ts +0 -15
- package/dist/components/timepicker/CTimePicker.utils.d.ts +0 -4
- package/src/components/daterangepicker/CDateRangePicker.tsx +0 -366
- package/src/components/timepicker/CTimePicker.utils.ts +0 -27
|
@@ -7,11 +7,57 @@ import { CDropdown, CDropdownProps } from '../dropdown/CDropdown'
|
|
|
7
7
|
import { CDropdownMenu } from '../dropdown/CDropdownMenu'
|
|
8
8
|
import { CDropdownToggle } from '../dropdown/CDropdownToggle'
|
|
9
9
|
|
|
10
|
+
import { Colors } from '../Types'
|
|
11
|
+
|
|
10
12
|
export interface CPickerProps extends Omit<CDropdownProps, 'variant'> {
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* Toggle visibility or set the content of cancel button.
|
|
15
|
+
*
|
|
16
|
+
* @default 'Cancel'
|
|
17
|
+
*/
|
|
18
|
+
cancelButton?: boolean | ReactNode
|
|
19
|
+
/**
|
|
20
|
+
* Sets the color context of the cancel button to one of CoreUI’s themed colors.
|
|
21
|
+
*
|
|
22
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
|
|
23
|
+
* @default 'primary'
|
|
24
|
+
*/
|
|
25
|
+
cancelButtonColor?: Colors
|
|
26
|
+
/**
|
|
27
|
+
* Size the cancel button small or large.
|
|
28
|
+
*
|
|
29
|
+
* @default 'sm'
|
|
30
|
+
*/
|
|
31
|
+
cancelButtonSize?: 'sm' | 'lg'
|
|
32
|
+
/**
|
|
33
|
+
* Set the cancel button variant to an outlined button or a ghost button.
|
|
34
|
+
*
|
|
35
|
+
* @default 'ghost'
|
|
36
|
+
*/
|
|
37
|
+
cancelButtonVariant?: 'outline' | 'ghost'
|
|
38
|
+
/**
|
|
39
|
+
* Toggle visibility or set the content of confirm button.
|
|
40
|
+
*
|
|
41
|
+
* @default 'OK'
|
|
42
|
+
*/
|
|
43
|
+
confirmButton?: boolean | ReactNode
|
|
44
|
+
/**
|
|
45
|
+
* Sets the color context of the confirm button to one of CoreUI’s themed colors.
|
|
46
|
+
*
|
|
47
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
|
|
48
|
+
* @default 'primary'
|
|
13
49
|
*/
|
|
14
|
-
|
|
50
|
+
confirmButtonColor?: Colors
|
|
51
|
+
/**
|
|
52
|
+
* Size the confirm button small or large.
|
|
53
|
+
*
|
|
54
|
+
* @default 'sm'
|
|
55
|
+
*/
|
|
56
|
+
confirmButtonSize?: 'sm' | 'lg'
|
|
57
|
+
/**
|
|
58
|
+
* Set the confirm button variant to an outlined button or a ghost button.
|
|
59
|
+
*/
|
|
60
|
+
confirmButtonVariant?: 'outline' | 'ghost'
|
|
15
61
|
/**
|
|
16
62
|
* Set container type for the component.
|
|
17
63
|
*/
|
|
@@ -25,17 +71,17 @@ export interface CPickerProps extends Omit<CDropdownProps, 'variant'> {
|
|
|
25
71
|
*/
|
|
26
72
|
footer?: boolean | ReactNode
|
|
27
73
|
/**
|
|
28
|
-
*
|
|
74
|
+
* Add custom elements to the footer.
|
|
29
75
|
*/
|
|
30
|
-
|
|
76
|
+
footerContent?: ReactNode
|
|
31
77
|
/**
|
|
32
78
|
* Callback fired when the cancel button has been clicked.
|
|
33
79
|
*/
|
|
34
|
-
|
|
80
|
+
onCancel?: () => void
|
|
35
81
|
/**
|
|
36
|
-
* Callback fired when the
|
|
82
|
+
* Callback fired when the confirm button has been clicked.
|
|
37
83
|
*/
|
|
38
|
-
|
|
84
|
+
onConfirm?: () => void
|
|
39
85
|
/**
|
|
40
86
|
* The content of toggler.
|
|
41
87
|
*/
|
|
@@ -46,14 +92,21 @@ export const CPicker = forwardRef<HTMLDivElement | HTMLLIElement, CPickerProps>(
|
|
|
46
92
|
(
|
|
47
93
|
{
|
|
48
94
|
children,
|
|
49
|
-
|
|
95
|
+
cancelButton = 'Cancel',
|
|
96
|
+
cancelButtonColor = 'primary',
|
|
97
|
+
cancelButtonSize = 'sm',
|
|
98
|
+
cancelButtonVariant = 'ghost',
|
|
99
|
+
confirmButton = 'OK',
|
|
100
|
+
confirmButtonColor = 'primary',
|
|
101
|
+
confirmButtonSize = 'sm',
|
|
102
|
+
confirmButtonVariant,
|
|
50
103
|
className,
|
|
51
104
|
container = 'dropdown',
|
|
52
105
|
disabled,
|
|
53
106
|
footer,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
107
|
+
footerContent,
|
|
108
|
+
onCancel,
|
|
109
|
+
onConfirm,
|
|
57
110
|
onHide,
|
|
58
111
|
onShow,
|
|
59
112
|
toggler: Toggler,
|
|
@@ -70,24 +123,30 @@ export const CPicker = forwardRef<HTMLDivElement | HTMLLIElement, CPickerProps>(
|
|
|
70
123
|
|
|
71
124
|
const Footer = () => (
|
|
72
125
|
<>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
126
|
+
{footerContent}
|
|
127
|
+
{cancelButton && (
|
|
128
|
+
<CButton
|
|
129
|
+
color={cancelButtonColor}
|
|
130
|
+
size={cancelButtonSize}
|
|
131
|
+
variant={cancelButtonVariant}
|
|
132
|
+
onClick={() => onCancel && onCancel()}
|
|
133
|
+
>
|
|
134
|
+
{cancelButton}
|
|
135
|
+
</CButton>
|
|
136
|
+
)}
|
|
137
|
+
{confirmButton && (
|
|
138
|
+
<CButton
|
|
139
|
+
color={confirmButtonColor}
|
|
140
|
+
size={confirmButtonSize}
|
|
141
|
+
variant={confirmButtonVariant}
|
|
142
|
+
onClick={() => {
|
|
143
|
+
onConfirm && onConfirm()
|
|
144
|
+
setVisible(false)
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
{confirmButton}
|
|
148
|
+
</CButton>
|
|
149
|
+
)}
|
|
91
150
|
</>
|
|
92
151
|
)
|
|
93
152
|
|
|
@@ -134,9 +193,22 @@ export const CPicker = forwardRef<HTMLDivElement | HTMLLIElement, CPickerProps>(
|
|
|
134
193
|
CPicker.displayName = 'CPicker'
|
|
135
194
|
|
|
136
195
|
CPicker.propTypes = {
|
|
137
|
-
|
|
196
|
+
cancelButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
197
|
+
cancelButtonColor: CButton.propTypes?.color,
|
|
198
|
+
cancelButtonSize: CButton.propTypes?.size,
|
|
199
|
+
cancelButtonVariant: CButton.propTypes?.variant,
|
|
200
|
+
confirmButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
201
|
+
confirmButtonColor: CButton.propTypes?.color,
|
|
202
|
+
confirmButtonSize: CButton.propTypes?.size,
|
|
203
|
+
confirmButtonVariant: CButton.propTypes?.variant,
|
|
204
|
+
children: PropTypes.node,
|
|
205
|
+
className: PropTypes.string,
|
|
138
206
|
container: PropTypes.oneOf(['dropdown', 'inline']),
|
|
139
207
|
disabled: PropTypes.bool,
|
|
140
|
-
|
|
141
|
-
|
|
208
|
+
footer: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
209
|
+
footerContent: PropTypes.node,
|
|
210
|
+
onCancel: PropTypes.func,
|
|
211
|
+
onConfirm: PropTypes.func,
|
|
212
|
+
toggler: PropTypes.node,
|
|
213
|
+
...CDropdown.propTypes,
|
|
142
214
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect'
|
|
4
|
+
import { CPicker } from '../CPicker'
|
|
5
|
+
|
|
6
|
+
test('loads and displays CPicker component', async () => {
|
|
7
|
+
const { container } = render(<CPicker>Test</CPicker>)
|
|
8
|
+
expect(container).toMatchSnapshot()
|
|
9
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`loads and displays CPicker component 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="dropdown picker"
|
|
7
|
+
>
|
|
8
|
+
<button
|
|
9
|
+
aria-expanded="false"
|
|
10
|
+
class="btn btn-primary dropdown-toggle"
|
|
11
|
+
tabindex="0"
|
|
12
|
+
type="button"
|
|
13
|
+
/>
|
|
14
|
+
<div
|
|
15
|
+
aria-hidden="true"
|
|
16
|
+
class="dropdown-menu"
|
|
17
|
+
role="menu"
|
|
18
|
+
>
|
|
19
|
+
Test
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import React, { FC,
|
|
1
|
+
import React, { FC, ReactNode, useRef, useState } from 'react'
|
|
2
2
|
import { createPortal } from 'react-dom'
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import classNames from 'classnames'
|
|
5
|
-
import
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import { usePopper } from 'react-popper'
|
|
6
7
|
import { Transition } from 'react-transition-group'
|
|
7
8
|
|
|
8
|
-
// import { CPopoverContent } from './CPopoverContent'
|
|
9
9
|
import { Triggers, triggerPropType } from '../Types'
|
|
10
10
|
|
|
11
11
|
export interface CPopoverProps {
|
|
12
|
-
|
|
12
|
+
// TODO: find solution to not use any
|
|
13
|
+
children: any
|
|
13
14
|
/**
|
|
14
15
|
* Content node for your component.
|
|
15
16
|
*/
|
|
@@ -49,16 +50,33 @@ export interface CPopoverProps {
|
|
|
49
50
|
export const CPopover: FC<CPopoverProps> = ({
|
|
50
51
|
children,
|
|
51
52
|
content,
|
|
52
|
-
placement = 'top',
|
|
53
53
|
offset = [0, 8],
|
|
54
54
|
onHide,
|
|
55
55
|
onShow,
|
|
56
|
+
placement = 'top',
|
|
56
57
|
title,
|
|
57
58
|
trigger = 'click',
|
|
58
59
|
visible,
|
|
59
60
|
...rest
|
|
60
61
|
}) => {
|
|
61
62
|
const [_visible, setVisible] = useState(visible)
|
|
63
|
+
const popoverRef = useRef()
|
|
64
|
+
|
|
65
|
+
const [referenceElement, setReferenceElement] = useState(null)
|
|
66
|
+
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null)
|
|
67
|
+
const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null)
|
|
68
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
69
|
+
modifiers: [
|
|
70
|
+
{ name: 'arrow', options: { element: arrowElement } },
|
|
71
|
+
{
|
|
72
|
+
name: 'offset',
|
|
73
|
+
options: {
|
|
74
|
+
offset: offset,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
placement: placement,
|
|
79
|
+
})
|
|
62
80
|
|
|
63
81
|
const getTransitionClass = (state: string) => {
|
|
64
82
|
return state === 'entering'
|
|
@@ -71,32 +89,29 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
71
89
|
}
|
|
72
90
|
|
|
73
91
|
return (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}),
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
</Reference>
|
|
92
|
+
<>
|
|
93
|
+
{React.cloneElement(children, {
|
|
94
|
+
ref: setReferenceElement,
|
|
95
|
+
...((trigger === 'click' || trigger.includes('click')) && {
|
|
96
|
+
onClick: () => setVisible(!_visible),
|
|
97
|
+
}),
|
|
98
|
+
...((trigger === 'focus' || trigger.includes('focus')) && {
|
|
99
|
+
onFocus: () => setVisible(true),
|
|
100
|
+
onBlur: () => setVisible(false),
|
|
101
|
+
}),
|
|
102
|
+
...((trigger === 'hover' || trigger.includes('hover')) && {
|
|
103
|
+
onMouseEnter: () => setVisible(true),
|
|
104
|
+
onMouseLeave: () => setVisible(false),
|
|
105
|
+
}),
|
|
106
|
+
})}
|
|
93
107
|
{typeof window !== 'undefined' &&
|
|
94
108
|
createPortal(
|
|
95
109
|
<Transition
|
|
96
110
|
in={_visible}
|
|
111
|
+
mountOnEnter
|
|
112
|
+
nodeRef={popoverRef}
|
|
97
113
|
onEnter={onShow}
|
|
98
114
|
onExit={onHide}
|
|
99
|
-
mountOnEnter
|
|
100
115
|
timeout={{
|
|
101
116
|
enter: 0,
|
|
102
117
|
exit: 200,
|
|
@@ -106,52 +121,39 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
106
121
|
{(state) => {
|
|
107
122
|
const transitionClass = getTransitionClass(state)
|
|
108
123
|
return (
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
offset: offset,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
]}
|
|
119
|
-
>
|
|
120
|
-
{({ arrowProps, style, ref }) => (
|
|
121
|
-
<div
|
|
122
|
-
className={classNames(
|
|
123
|
-
`popover bs-popover-${
|
|
124
|
-
placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
|
|
125
|
-
}`,
|
|
126
|
-
transitionClass,
|
|
127
|
-
)}
|
|
128
|
-
ref={ref}
|
|
129
|
-
role="tooltip"
|
|
130
|
-
style={style}
|
|
131
|
-
{...rest}
|
|
132
|
-
>
|
|
133
|
-
<div className="popover-arrow" {...arrowProps}></div>
|
|
134
|
-
<div className="popover-header">{title}</div>
|
|
135
|
-
<div className="popover-body">{content}</div>
|
|
136
|
-
</div>
|
|
124
|
+
<div
|
|
125
|
+
className={classNames(
|
|
126
|
+
`popover bs-popover-${
|
|
127
|
+
placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
|
|
128
|
+
}`,
|
|
129
|
+
transitionClass,
|
|
137
130
|
)}
|
|
138
|
-
|
|
131
|
+
ref={setPopperElement}
|
|
132
|
+
role="tooltip"
|
|
133
|
+
style={styles.popper}
|
|
134
|
+
{...attributes.popper}
|
|
135
|
+
{...rest}
|
|
136
|
+
>
|
|
137
|
+
<div className="popover-arrow" style={styles.arrow} ref={setArrowElement}></div>
|
|
138
|
+
<div className="popover-header">{title}</div>
|
|
139
|
+
<div className="popover-body">{content}</div>
|
|
140
|
+
</div>
|
|
139
141
|
)
|
|
140
142
|
}}
|
|
141
143
|
</Transition>,
|
|
142
144
|
document.body,
|
|
143
145
|
)}
|
|
144
|
-
|
|
146
|
+
</>
|
|
145
147
|
)
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
CPopover.propTypes = {
|
|
149
151
|
children: PropTypes.any,
|
|
150
152
|
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
151
|
-
placement: PropTypes.oneOf(['auto', 'top', 'right', 'bottom', 'left']),
|
|
152
153
|
offset: PropTypes.any, // TODO: find good proptype
|
|
153
154
|
onHide: PropTypes.func,
|
|
154
155
|
onShow: PropTypes.func,
|
|
156
|
+
placement: PropTypes.oneOf(['auto', 'top', 'right', 'bottom', 'left']),
|
|
155
157
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
156
158
|
trigger: triggerPropType,
|
|
157
159
|
visible: PropTypes.bool,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSidebar } from './CSidebar'
|
|
2
|
+
import { CSidebarBrand } from './CSidebarBrand'
|
|
3
|
+
import { CSidebarFooter } from './CSidebarFooter'
|
|
4
|
+
import { CSidebarToggler } from './CSidebarToggler'
|
|
5
|
+
import { CSidebarHeader } from './CSidebarHeader'
|
|
6
|
+
import { CSidebarNav } from './CSidebarNav'
|
|
7
|
+
|
|
8
|
+
export { CSidebar, CSidebarBrand, CSidebarFooter, CSidebarToggler, CSidebarHeader, CSidebarNav }
|
|
@@ -340,7 +340,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
340
340
|
}, [_items])
|
|
341
341
|
|
|
342
342
|
return (
|
|
343
|
-
|
|
343
|
+
<>
|
|
344
344
|
<div {...rest} ref={ref}>
|
|
345
345
|
{(itemsPerPageSelect || tableFilter || cleaner) && (
|
|
346
346
|
<div className="row my-2 mx-0">
|
|
@@ -460,7 +460,7 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
|
|
|
460
460
|
</div>
|
|
461
461
|
</div>
|
|
462
462
|
)}
|
|
463
|
-
|
|
463
|
+
</>
|
|
464
464
|
)
|
|
465
465
|
},
|
|
466
466
|
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CTable } from './CTable'
|
|
2
|
+
import { CTableBody } from './CTableBody'
|
|
3
|
+
import { CTableCaption } from './CTableCaption'
|
|
4
|
+
import { CTableDataCell } from './CTableDataCell'
|
|
5
|
+
import { CTableFoot } from './CTableFoot'
|
|
6
|
+
import { CTableHead } from './CTableHead'
|
|
7
|
+
import { CTableHeaderCell } from './CTableHeaderCell'
|
|
8
|
+
import { CTableRow } from './CTableRow'
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
CTable,
|
|
12
|
+
CTableBody,
|
|
13
|
+
CTableCaption,
|
|
14
|
+
CTableDataCell,
|
|
15
|
+
CTableFoot,
|
|
16
|
+
CTableHead,
|
|
17
|
+
CTableHeaderCell,
|
|
18
|
+
CTableRow,
|
|
19
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { HTMLAttributes, forwardRef } from 'react'
|
|
1
|
+
import React, { HTMLAttributes, forwardRef, useRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { Transition } from 'react-transition-group'
|
|
5
5
|
|
|
6
|
+
import { useForkedRef } from '../../utils/hooks'
|
|
6
7
|
export interface CTabPaneProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
8
|
/**
|
|
8
9
|
* A string of all className you want applied to the base component.
|
|
@@ -24,6 +25,9 @@ export interface CTabPaneProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
24
25
|
|
|
25
26
|
export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
|
|
26
27
|
({ children, className, onHide, onShow, visible, ...rest }, ref) => {
|
|
28
|
+
const tabPaneRef = useRef()
|
|
29
|
+
const forkedRef = useForkedRef(ref, tabPaneRef)
|
|
30
|
+
|
|
27
31
|
const getTransitionClass = (state: string) => {
|
|
28
32
|
return state === 'entered' && 'show'
|
|
29
33
|
}
|
|
@@ -37,11 +41,11 @@ export const CTabPane = forwardRef<HTMLDivElement, CTabPaneProps>(
|
|
|
37
41
|
className,
|
|
38
42
|
)
|
|
39
43
|
return (
|
|
40
|
-
<Transition in={visible} onEnter={onShow} onExit={onHide} timeout={150}>
|
|
44
|
+
<Transition in={visible} nodeRef={tabPaneRef} onEnter={onShow} onExit={onHide} timeout={150}>
|
|
41
45
|
{(state) => {
|
|
42
46
|
const transitionClass = getTransitionClass(state)
|
|
43
47
|
return (
|
|
44
|
-
<div className={classNames(_className, transitionClass)} {...rest} ref={
|
|
48
|
+
<div className={classNames(_className, transitionClass)} {...rest} ref={forkedRef}>
|
|
45
49
|
{children}
|
|
46
50
|
</div>
|
|
47
51
|
)
|