@coreui/react-pro 4.1.4 → 4.2.0-rc.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/Types.d.ts +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 +113 -0
- 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/datepicker/CDatePicker.d.ts +13 -0
- package/dist/components/datepicker/index.d.ts +2 -0
- package/dist/components/daterangepicker/CDateRangePicker.d.ts +65 -0
- package/dist/components/daterangepicker/index.d.ts +2 -0
- package/dist/components/dropdown/CDropdown.d.ts +10 -1
- package/dist/components/dropdown/CDropdownToggle.d.ts +4 -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 +2 -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 +78 -0
- 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/timepicker/CTimePicker.d.ts +45 -0
- package/dist/components/timepicker/CTimePickerRollCol.d.ts +11 -0
- 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 +2 -2
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/index.d.ts +0 -125
- package/dist/index.es.js +3268 -1339
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3513 -1582
- package/dist/index.js.map +1 -1
- package/dist/utils/calendar.d.ts +23 -0
- package/dist/utils/hooks/useStateWithCallback.d.ts +2 -1
- package/dist/utils/time.d.ts +21 -0
- package/package.json +12 -11
- package/src/components/Types.tsx +2 -2
- package/src/components/accordion/CAccordionButton.tsx +2 -1
- 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 +559 -0
- 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/CDatePicker.tsx +50 -0
- package/src/components/datepicker/__tests__/CDatePicker.spec.tsx +9 -0
- package/src/components/datepicker/__tests__/__snapshots__/CDatePicker.spec.tsx.snap +617 -0
- package/src/components/datepicker/index.ts +3 -0
- package/src/components/daterangepicker/CDateRangePicker.tsx +432 -0
- package/src/components/daterangepicker/__tests__/CDateRangePicker.spec.tsx +9 -0
- package/src/components/daterangepicker/__tests__/__snapshots__/CDateRangePicker.spec.tsx.snap +1201 -0
- package/src/components/daterangepicker/index.ts +3 -0
- package/src/components/dropdown/CDropdown.tsx +19 -24
- package/src/components/dropdown/CDropdownItem.tsx +1 -1
- package/src/components/dropdown/CDropdownMenu.tsx +55 -3
- package/src/components/dropdown/CDropdownToggle.tsx +28 -5
- 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 +47 -18
- 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 +45 -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 +207 -0
- 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 +78 -70
- 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/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/CTimePicker.tsx +313 -0
- package/src/components/timepicker/CTimePickerRollCol.tsx +63 -0
- package/src/components/timepicker/__tests__/CTimePicker.spec.tsx +9 -0
- package/src/components/timepicker/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 +68 -60
- package/src/components/tooltip/index.ts +3 -0
- package/src/index.ts +0 -252
- package/src/utils/calendar.ts +270 -0
- 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/src/components/dropdown/CDropdownToggleCustom.tsx +0 -81
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CNavbar } from './CNavbar'
|
|
2
|
+
import { CNavbarBrand } from './CNavbarBrand'
|
|
3
|
+
import { CNavbarNav } from './CNavbarNav'
|
|
4
|
+
import { CNavbarText } from './CNavbarText'
|
|
5
|
+
import { CNavbarToggler } from './CNavbarToggler'
|
|
6
|
+
|
|
7
|
+
export { CNavbar, CNavbarBrand, CNavbarNav, CNavbarText, CNavbarToggler }
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { COffcanvas } from './COffcanvas'
|
|
2
|
+
import { COffcanvasBody } from './COffcanvasBody'
|
|
3
|
+
import { COffcanvasHeader } from './COffcanvasHeader'
|
|
4
|
+
import { COffcanvasTitle } from './COffcanvasTitle'
|
|
5
|
+
|
|
6
|
+
export { COffcanvas, COffcanvasBody, COffcanvasHeader, COffcanvasTitle }
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import React, { forwardRef, ReactNode, useEffect, useState } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import classNames from 'classnames'
|
|
4
|
+
|
|
5
|
+
import { CButton } from '../button/CButton'
|
|
6
|
+
import { CDropdown, CDropdownProps } from '../dropdown/CDropdown'
|
|
7
|
+
import { CDropdownMenu } from '../dropdown/CDropdownMenu'
|
|
8
|
+
import { CDropdownToggle } from '../dropdown/CDropdownToggle'
|
|
9
|
+
|
|
10
|
+
import { Colors } from '../Types'
|
|
11
|
+
|
|
12
|
+
export interface CPickerProps extends Omit<CDropdownProps, 'variant'> {
|
|
13
|
+
/**
|
|
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'
|
|
49
|
+
*/
|
|
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'
|
|
61
|
+
/**
|
|
62
|
+
* Set container type for the component.
|
|
63
|
+
*/
|
|
64
|
+
container?: 'dropdown' | 'inline'
|
|
65
|
+
/**
|
|
66
|
+
* Toggle the disabled state for the component.
|
|
67
|
+
*/
|
|
68
|
+
disabled?: boolean
|
|
69
|
+
/**
|
|
70
|
+
* Toggle visibility of footer element or set the content of footer.
|
|
71
|
+
*/
|
|
72
|
+
footer?: boolean | ReactNode
|
|
73
|
+
/**
|
|
74
|
+
* Callback fired when the cancel button has been clicked.
|
|
75
|
+
*/
|
|
76
|
+
onCancel?: () => void
|
|
77
|
+
/**
|
|
78
|
+
* Callback fired when the confirm button has been clicked.
|
|
79
|
+
*/
|
|
80
|
+
onConfirm?: () => void
|
|
81
|
+
/**
|
|
82
|
+
* The content of toggler.
|
|
83
|
+
*/
|
|
84
|
+
toggler?: ReactNode
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const CPicker = forwardRef<HTMLDivElement | HTMLLIElement, CPickerProps>(
|
|
88
|
+
(
|
|
89
|
+
{
|
|
90
|
+
children,
|
|
91
|
+
cancelButton = 'Cancel',
|
|
92
|
+
cancelButtonColor = 'primary',
|
|
93
|
+
cancelButtonSize = 'sm',
|
|
94
|
+
cancelButtonVariant = 'ghost',
|
|
95
|
+
confirmButton = 'OK',
|
|
96
|
+
confirmButtonColor = 'primary',
|
|
97
|
+
confirmButtonSize = 'sm',
|
|
98
|
+
confirmButtonVariant,
|
|
99
|
+
className,
|
|
100
|
+
container = 'dropdown',
|
|
101
|
+
disabled,
|
|
102
|
+
footer,
|
|
103
|
+
onCancel,
|
|
104
|
+
onConfirm,
|
|
105
|
+
onHide,
|
|
106
|
+
onShow,
|
|
107
|
+
toggler: Toggler,
|
|
108
|
+
visible,
|
|
109
|
+
...rest
|
|
110
|
+
},
|
|
111
|
+
ref,
|
|
112
|
+
) => {
|
|
113
|
+
const [_visible, setVisible] = useState(visible)
|
|
114
|
+
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
setVisible(visible)
|
|
117
|
+
}, [visible])
|
|
118
|
+
|
|
119
|
+
const Footer = () => (
|
|
120
|
+
<>
|
|
121
|
+
{cancelButton && (
|
|
122
|
+
<CButton
|
|
123
|
+
color={cancelButtonColor}
|
|
124
|
+
size={cancelButtonSize}
|
|
125
|
+
variant={cancelButtonVariant}
|
|
126
|
+
onClick={() => onCancel && onCancel()}
|
|
127
|
+
>
|
|
128
|
+
{cancelButton}
|
|
129
|
+
</CButton>
|
|
130
|
+
)}
|
|
131
|
+
{confirmButton && (
|
|
132
|
+
<CButton
|
|
133
|
+
color={confirmButtonColor}
|
|
134
|
+
size={confirmButtonSize}
|
|
135
|
+
variant={confirmButtonVariant}
|
|
136
|
+
onClick={() => {
|
|
137
|
+
onConfirm && onConfirm()
|
|
138
|
+
setVisible(false)
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
{confirmButton}
|
|
142
|
+
</CButton>
|
|
143
|
+
)}
|
|
144
|
+
</>
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
const _className = classNames('picker', className)
|
|
148
|
+
|
|
149
|
+
switch (container) {
|
|
150
|
+
case 'inline':
|
|
151
|
+
return <div className={_className}>{children}</div>
|
|
152
|
+
default:
|
|
153
|
+
return (
|
|
154
|
+
<CDropdown
|
|
155
|
+
autoClose="outside"
|
|
156
|
+
className={_className}
|
|
157
|
+
onHide={() => {
|
|
158
|
+
setVisible(false)
|
|
159
|
+
onHide && onHide()
|
|
160
|
+
}}
|
|
161
|
+
onShow={() => {
|
|
162
|
+
setVisible(true)
|
|
163
|
+
onShow && onShow()
|
|
164
|
+
}}
|
|
165
|
+
variant="dropdown"
|
|
166
|
+
visible={_visible}
|
|
167
|
+
{...rest}
|
|
168
|
+
ref={ref}
|
|
169
|
+
>
|
|
170
|
+
<CDropdownToggle custom disabled={_visible || disabled}>
|
|
171
|
+
{Toggler}
|
|
172
|
+
</CDropdownToggle>
|
|
173
|
+
<CDropdownMenu component="div">
|
|
174
|
+
{children}
|
|
175
|
+
{footer && (
|
|
176
|
+
<div className="picker-footer">
|
|
177
|
+
{typeof footer === 'boolean' ? Footer() : footer}
|
|
178
|
+
</div>
|
|
179
|
+
)}
|
|
180
|
+
</CDropdownMenu>
|
|
181
|
+
</CDropdown>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
CPicker.displayName = 'CPicker'
|
|
188
|
+
|
|
189
|
+
CPicker.propTypes = {
|
|
190
|
+
cancelButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
191
|
+
cancelButtonColor: CButton.propTypes?.color,
|
|
192
|
+
cancelButtonSize: CButton.propTypes?.size,
|
|
193
|
+
cancelButtonVariant: CButton.propTypes?.variant,
|
|
194
|
+
confirmButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
195
|
+
confirmButtonColor: CButton.propTypes?.color,
|
|
196
|
+
confirmButtonSize: CButton.propTypes?.size,
|
|
197
|
+
confirmButtonVariant: CButton.propTypes?.variant,
|
|
198
|
+
children: PropTypes.node,
|
|
199
|
+
className: PropTypes.string,
|
|
200
|
+
container: PropTypes.oneOf(['dropdown', 'inline']),
|
|
201
|
+
disabled: PropTypes.bool,
|
|
202
|
+
footer: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
203
|
+
onCancel: PropTypes.func,
|
|
204
|
+
onConfirm: PropTypes.func,
|
|
205
|
+
toggler: PropTypes.node,
|
|
206
|
+
...CDropdown.propTypes,
|
|
207
|
+
}
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import React, { FC,
|
|
1
|
+
import React, { FC, ReactNode, useRef, useState } from 'react'
|
|
2
2
|
import { createPortal } from 'react-dom'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import classNames from 'classnames'
|
|
@@ -9,7 +9,7 @@ import { Transition } from 'react-transition-group'
|
|
|
9
9
|
import { Triggers, triggerPropType } from '../Types'
|
|
10
10
|
|
|
11
11
|
export interface CPopoverProps {
|
|
12
|
-
children:
|
|
12
|
+
children: any
|
|
13
13
|
/**
|
|
14
14
|
* Content node for your component.
|
|
15
15
|
*/
|
|
@@ -59,6 +59,7 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
59
59
|
...rest
|
|
60
60
|
}) => {
|
|
61
61
|
const [_visible, setVisible] = useState(visible)
|
|
62
|
+
const popoverRef = useRef()
|
|
62
63
|
|
|
63
64
|
const getTransitionClass = (state: string) => {
|
|
64
65
|
return state === 'entering'
|
|
@@ -72,75 +73,82 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
72
73
|
|
|
73
74
|
return (
|
|
74
75
|
<Manager>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
76
|
+
<>
|
|
77
|
+
<Reference>
|
|
78
|
+
{({ ref }) =>
|
|
79
|
+
React.cloneElement(children, {
|
|
80
|
+
ref: ref,
|
|
81
|
+
...((trigger === 'click' || trigger.includes('click')) && {
|
|
82
|
+
onClick: () => setVisible(!_visible),
|
|
83
|
+
}),
|
|
84
|
+
...((trigger === 'focus' || trigger.includes('focus')) && {
|
|
85
|
+
onFocus: () => setVisible(true),
|
|
86
|
+
onBlur: () => setVisible(false),
|
|
87
|
+
}),
|
|
88
|
+
...((trigger === 'hover' || trigger.includes('hover')) && {
|
|
89
|
+
onMouseEnter: () => setVisible(true),
|
|
90
|
+
onMouseLeave: () => setVisible(false),
|
|
91
|
+
}),
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
</Reference>
|
|
95
|
+
{typeof window !== 'undefined' &&
|
|
96
|
+
createPortal(
|
|
97
|
+
<Transition
|
|
98
|
+
in={_visible}
|
|
99
|
+
mountOnEnter
|
|
100
|
+
nodeRef={popoverRef}
|
|
101
|
+
onEnter={onShow}
|
|
102
|
+
onExit={onHide}
|
|
103
|
+
timeout={{
|
|
104
|
+
enter: 0,
|
|
105
|
+
exit: 200,
|
|
106
|
+
}}
|
|
107
|
+
unmountOnExit
|
|
108
|
+
>
|
|
109
|
+
{(state) => {
|
|
110
|
+
const transitionClass = getTransitionClass(state)
|
|
111
|
+
return (
|
|
112
|
+
<Popper
|
|
113
|
+
placement={placement}
|
|
114
|
+
modifiers={[
|
|
115
|
+
{
|
|
116
|
+
name: 'offset',
|
|
117
|
+
options: {
|
|
118
|
+
offset: offset,
|
|
119
|
+
},
|
|
116
120
|
},
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
121
|
+
]}
|
|
122
|
+
>
|
|
123
|
+
{({ arrowProps, style, ref }) => (
|
|
124
|
+
<div
|
|
125
|
+
className={classNames(
|
|
126
|
+
`popover bs-popover-${
|
|
127
|
+
placement === 'left'
|
|
128
|
+
? 'start'
|
|
129
|
+
: placement === 'right'
|
|
130
|
+
? 'end'
|
|
131
|
+
: placement
|
|
132
|
+
}`,
|
|
133
|
+
transitionClass,
|
|
134
|
+
)}
|
|
135
|
+
ref={ref}
|
|
136
|
+
role="tooltip"
|
|
137
|
+
style={style}
|
|
138
|
+
{...rest}
|
|
139
|
+
>
|
|
140
|
+
<div className="popover-arrow" {...arrowProps}></div>
|
|
141
|
+
<div className="popover-header">{title}</div>
|
|
142
|
+
<div className="popover-body">{content}</div>
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
</Popper>
|
|
146
|
+
)
|
|
147
|
+
}}
|
|
148
|
+
</Transition>,
|
|
149
|
+
document.body,
|
|
150
|
+
)}
|
|
151
|
+
</>
|
|
144
152
|
</Manager>
|
|
145
153
|
)
|
|
146
154
|
}
|
|
@@ -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 }
|
|
@@ -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
|
)
|