@coreui/react 4.0.0-rc.4 → 4.0.1
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 +37 -24
- package/dist/components/form/CFormCheck.d.ts +4 -0
- package/dist/components/form/CFormSelect.d.ts +13 -0
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/tooltip/CTooltip.d.ts +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.es.js +49 -50
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +48 -51
- package/dist/index.js.map +1 -1
- package/package.json +39 -77
- package/src/components/alert/CAlert.tsx +0 -1
- package/src/components/dropdown/CDropdown.tsx +18 -16
- package/src/components/form/CFormCheck.tsx +30 -3
- package/src/components/form/CFormSelect.tsx +28 -2
- package/src/components/popover/CPopover.tsx +24 -11
- package/src/components/tooltip/CTooltip.tsx +22 -12
- package/src/index.ts +0 -4
- package/dist/components/carousel/CCarouselControl.d.ts +0 -16
- package/dist/components/carousel/CCarouselIndicators.d.ts +0 -12
- package/dist/components/carousel/CCarouselInner.d.ts +0 -8
- package/dist/components/popover/CPopoverContent.d.ts +0 -10
- package/dist/components/tooltip/CTooltipContent.d.ts +0 -10
- package/dist/docs/components/CodeBlock copy.d.ts +0 -3
- package/dist/docs/components/CodeBlock.d.ts +0 -3
- package/dist/docs/components/Example.d.ts +0 -6
- package/dist/docs/components/Footer.d.ts +0 -3
- package/dist/docs/components/Header.d.ts +0 -3
- package/dist/docs/components/Seo.d.ts +0 -22
- package/dist/docs/components/Sidebar.d.ts +0 -6
- package/dist/docs/components/SidebarNav.d.ts +0 -24
- package/dist/docs/components/index.d.ts +0 -9
- package/dist/docs/index.d.ts +0 -1
- package/dist/docs/nav.d.ts +0 -20
- package/dist/docs/templates/Docs.d.ts +0 -6
- package/dist/docs/templates/Layout.d.ts +0 -4
- package/dist/pages/404.d.ts +0 -2
- package/src/components/popover/CPopoverContent.tsx +0 -41
- package/src/components/tooltip/CTooltipContent.tsx +0 -37
- package/tsconfig.json +0 -25
package/package.json
CHANGED
|
@@ -1,99 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreui/react",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "UI Components Library for React.js",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"react-component",
|
|
8
|
+
"react component",
|
|
9
|
+
"react bootstrap",
|
|
10
|
+
"bootstrap react",
|
|
11
|
+
"ui library",
|
|
12
|
+
"ui components",
|
|
13
|
+
"component library",
|
|
14
|
+
"components"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://coreui.io/react/",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/coreui/coreui-react/issues"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/coreui/coreui-react.git"
|
|
6
23
|
},
|
|
7
|
-
"description": "",
|
|
8
24
|
"license": "MIT",
|
|
25
|
+
"author": "The CoreUI Team (https://github.com/orgs/coreui/people)",
|
|
9
26
|
"main": "dist/index.js",
|
|
10
27
|
"module": "dist/index.es.js",
|
|
11
28
|
"jsnext:main": "dist/index.es.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
12
30
|
"files": [
|
|
13
31
|
"dist/",
|
|
14
|
-
"src/
|
|
15
|
-
"src/utils/",
|
|
16
|
-
"src/index.ts",
|
|
17
|
-
"tsconfig.json",
|
|
18
|
-
"package.json"
|
|
32
|
+
"src/"
|
|
19
33
|
],
|
|
20
34
|
"scripts": {
|
|
21
|
-
"build": "rollup -c"
|
|
22
|
-
"docs:api": "rimraf \"content/docs/$npm_package_config_version_short/api/*\" & node build/api.js",
|
|
23
|
-
"docs:build": "gatsby build --prefix-paths",
|
|
24
|
-
"docs:dist": "run-s docs:api docs:build",
|
|
25
|
-
"docs:dev": "gatsby develop",
|
|
26
|
-
"docs:serve": "gatsby serve",
|
|
27
|
-
"lint": "eslint \"src/components/**/*.{js,ts,tsx}\"",
|
|
28
|
-
"test": "jest --coverage",
|
|
29
|
-
"test:update": "jest --coverage --updateSnapshot"
|
|
30
|
-
},
|
|
31
|
-
"peerDependencies": {
|
|
32
|
-
"@coreui/coreui": "^4.0.4",
|
|
33
|
-
"react": "^17",
|
|
34
|
-
"react-dom": "^17"
|
|
35
|
+
"build": "rollup -c"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@coreui/coreui": "^4.0.4",
|
|
38
|
-
"@coreui/icons": "^2.0.1",
|
|
39
|
-
"@coreui/icons-react": "^2.0.0-rc.5",
|
|
40
|
-
"@coreui/react-chartjs": "^2.0.0-rc.1",
|
|
41
|
-
"@mdx-js/mdx": "^1.6.22",
|
|
42
|
-
"@mdx-js/react": "^1.6.22",
|
|
43
38
|
"@popperjs/core": "^2.10.2",
|
|
44
|
-
"@rollup/plugin-commonjs": "^21.0.
|
|
45
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
46
|
-
"@rollup/plugin-typescript": "^8.
|
|
47
|
-
"@testing-library/jest-dom": "^5.
|
|
39
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
41
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
42
|
+
"@testing-library/jest-dom": "^5.15.0",
|
|
48
43
|
"@testing-library/react": "^12.1.2",
|
|
49
|
-
"@types/react": "^17.0.
|
|
50
|
-
"@types/react-dom": "^17.0.
|
|
51
|
-
"@types/react-
|
|
52
|
-
"@types/react-transition-group": "^4.4.3",
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^4.32.0",
|
|
54
|
-
"@typescript-eslint/parser": "^4.32.0",
|
|
44
|
+
"@types/react": "^17.0.34",
|
|
45
|
+
"@types/react-dom": "^17.0.11",
|
|
46
|
+
"@types/react-transition-group": "^4.4.4",
|
|
55
47
|
"classnames": "^2.3.1",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
60
|
-
"eslint-plugin-react": "^7.26.1",
|
|
61
|
-
"eslint-plugin-react-hooks": "^4.2.0",
|
|
62
|
-
"gatsby": "^3.14.1",
|
|
63
|
-
"gatsby-plugin-google-gtag": "3",
|
|
64
|
-
"gatsby-plugin-manifest": "^3.14.0",
|
|
65
|
-
"gatsby-plugin-mdx": "^2.14.0",
|
|
66
|
-
"gatsby-plugin-sass": "4",
|
|
67
|
-
"gatsby-plugin-sitemap": "4",
|
|
68
|
-
"gatsby-remark-autolink-headers": "^4.11.0",
|
|
69
|
-
"gatsby-source-filesystem": "^3.14.0",
|
|
70
|
-
"glob": "^7.2.0",
|
|
71
|
-
"globby": "^11.0.4",
|
|
72
|
-
"jest": "^27.2.4",
|
|
73
|
-
"npm-run-all": "^4.1.5",
|
|
74
|
-
"prettier": "^2.4.1",
|
|
75
|
-
"prism-react-renderer": "^1.2.1",
|
|
76
|
-
"prismjs": "^1.25.0",
|
|
77
|
-
"react": "^17.0.1",
|
|
78
|
-
"react-docgen-typescript": "^2.1.0",
|
|
79
|
-
"react-dom": "^17.0.1",
|
|
80
|
-
"react-github-btn": "^1.2.1",
|
|
81
|
-
"react-helmet": "^6.1.0",
|
|
48
|
+
"prop-types": "^15.7.2",
|
|
49
|
+
"react": "^17.0.2",
|
|
50
|
+
"react-dom": "^17.0.2",
|
|
82
51
|
"react-popper": "^2.2.5",
|
|
83
52
|
"react-transition-group": "^4.4.2",
|
|
84
|
-
"
|
|
85
|
-
"rimraf": "^3.0.2",
|
|
86
|
-
"rollup": "^2.56.22.56.2",
|
|
53
|
+
"rollup": "^2.59.0",
|
|
87
54
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
88
|
-
"
|
|
89
|
-
"ts-jest": "^27.0.5",
|
|
90
|
-
"typescript": "^4.4.3"
|
|
55
|
+
"typescript": "^4.4.4"
|
|
91
56
|
},
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"testPathIgnorePatterns": [
|
|
96
|
-
"dist/"
|
|
97
|
-
]
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"react": "^17",
|
|
59
|
+
"react-dom": "^17"
|
|
98
60
|
}
|
|
99
61
|
}
|
|
@@ -136,14 +136,17 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
136
136
|
)
|
|
137
137
|
|
|
138
138
|
useEffect(() => {
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
_visible &&
|
|
140
|
+
setTimeout(() => {
|
|
141
|
+
window.addEventListener('click', handleClickOutside)
|
|
142
|
+
window.addEventListener('keyup', handleKeyup)
|
|
143
|
+
})
|
|
141
144
|
|
|
142
145
|
return () => {
|
|
143
146
|
window.removeEventListener('click', handleClickOutside)
|
|
144
147
|
window.removeEventListener('keyup', handleKeyup)
|
|
145
148
|
}
|
|
146
|
-
})
|
|
149
|
+
}, [_visible])
|
|
147
150
|
|
|
148
151
|
useEffect(() => {
|
|
149
152
|
setVisible(visible)
|
|
@@ -165,24 +168,23 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
|
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
|
|
171
|
+
const dropdownContent = () => {
|
|
172
|
+
return variant === 'input-group' ? (
|
|
173
|
+
<>{children}</>
|
|
174
|
+
) : (
|
|
175
|
+
<Component className={_className} {...rest} ref={forkedRef}>
|
|
176
|
+
{children}
|
|
177
|
+
</Component>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
168
181
|
return popper ? (
|
|
169
182
|
<CDropdownContext.Provider value={contextValues}>
|
|
170
|
-
<Manager>
|
|
171
|
-
{/* TODO: find solution how to handle click outside */}
|
|
172
|
-
{variant === 'input-group' ? (
|
|
173
|
-
<>{children}</>
|
|
174
|
-
) : (
|
|
175
|
-
<Component className={_className} {...rest} ref={forkedRef}>
|
|
176
|
-
{children}
|
|
177
|
-
</Component>
|
|
178
|
-
)}
|
|
179
|
-
</Manager>
|
|
183
|
+
<Manager>{dropdownContent()}</Manager>
|
|
180
184
|
</CDropdownContext.Provider>
|
|
181
185
|
) : (
|
|
182
186
|
<CDropdownContext.Provider value={contextValues}>
|
|
183
|
-
|
|
184
|
-
{children}
|
|
185
|
-
</Component>
|
|
187
|
+
{dropdownContent()}
|
|
186
188
|
</CDropdownContext.Provider>
|
|
187
189
|
)
|
|
188
190
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { forwardRef, InputHTMLAttributes, ReactNode } from 'react'
|
|
1
|
+
import React, { forwardRef, InputHTMLAttributes, ReactNode, useEffect, useRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
+
import { useForkedRef } from '../../utils/hooks'
|
|
5
6
|
import { Colors, Shapes } from '../Types'
|
|
6
7
|
|
|
7
8
|
import { CFormLabel } from './CFormLabel'
|
|
@@ -46,6 +47,10 @@ export interface CFormCheckProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
46
47
|
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
47
48
|
*/
|
|
48
49
|
id?: string
|
|
50
|
+
/**
|
|
51
|
+
* Input Checkbox indeterminate Property.
|
|
52
|
+
*/
|
|
53
|
+
indeterminate?: boolean
|
|
49
54
|
/**
|
|
50
55
|
* Group checkboxes or radios on the same horizontal row by adding.
|
|
51
56
|
*/
|
|
@@ -70,9 +75,30 @@ export interface CFormCheckProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
|
70
75
|
|
|
71
76
|
export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
|
|
72
77
|
(
|
|
73
|
-
{
|
|
78
|
+
{
|
|
79
|
+
className,
|
|
80
|
+
button,
|
|
81
|
+
hitArea,
|
|
82
|
+
id,
|
|
83
|
+
indeterminate,
|
|
84
|
+
inline,
|
|
85
|
+
invalid,
|
|
86
|
+
label,
|
|
87
|
+
type = 'checkbox',
|
|
88
|
+
valid,
|
|
89
|
+
...rest
|
|
90
|
+
},
|
|
74
91
|
ref,
|
|
75
92
|
) => {
|
|
93
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
94
|
+
const forkedRef = useForkedRef(ref, inputRef)
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (inputRef.current && indeterminate) {
|
|
98
|
+
inputRef.current.indeterminate = indeterminate
|
|
99
|
+
}
|
|
100
|
+
}, [indeterminate])
|
|
101
|
+
|
|
76
102
|
const _className = classNames(
|
|
77
103
|
'form-check',
|
|
78
104
|
{
|
|
@@ -102,7 +128,7 @@ export const CFormCheck = forwardRef<HTMLInputElement, CFormCheckProps>(
|
|
|
102
128
|
)
|
|
103
129
|
|
|
104
130
|
const formControl = () => {
|
|
105
|
-
return <input type={type} className={inputClassName} id={id} {...rest} ref={
|
|
131
|
+
return <input type={type} className={inputClassName} id={id} {...rest} ref={forkedRef} />
|
|
106
132
|
}
|
|
107
133
|
|
|
108
134
|
const formLabel = () => {
|
|
@@ -141,6 +167,7 @@ CFormCheck.propTypes = {
|
|
|
141
167
|
className: PropTypes.string,
|
|
142
168
|
hitArea: PropTypes.oneOf(['full']),
|
|
143
169
|
id: PropTypes.string,
|
|
170
|
+
indeterminate: PropTypes.bool,
|
|
144
171
|
inline: PropTypes.bool,
|
|
145
172
|
invalid: PropTypes.bool,
|
|
146
173
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
@@ -2,6 +2,11 @@ import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes } from 'reac
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
+
type Option = {
|
|
6
|
+
disabled?: boolean
|
|
7
|
+
label?: string
|
|
8
|
+
value?: string
|
|
9
|
+
}
|
|
5
10
|
export interface CFormSelectProps extends Omit<InputHTMLAttributes<HTMLSelectElement>, 'size'> {
|
|
6
11
|
/**
|
|
7
12
|
* A string of all className you want applied to the component.
|
|
@@ -19,6 +24,13 @@ export interface CFormSelectProps extends Omit<InputHTMLAttributes<HTMLSelectEle
|
|
|
19
24
|
* Method called immediately after the `value` prop changes.
|
|
20
25
|
*/
|
|
21
26
|
onChange?: ChangeEventHandler<HTMLSelectElement>
|
|
27
|
+
/**
|
|
28
|
+
* Options list of the select component. Available keys: `label`, `value`, `disabled`.
|
|
29
|
+
* Examples:
|
|
30
|
+
* - `options={[{ value: 'js', label: 'JavaScript' }, { value: 'html', label: 'HTML', disabled: true }]}`
|
|
31
|
+
* - `options={['js', 'html']}`
|
|
32
|
+
*/
|
|
33
|
+
options?: Option[] | string[]
|
|
22
34
|
/**
|
|
23
35
|
* Size the component small or large.
|
|
24
36
|
*/
|
|
@@ -36,7 +48,7 @@ export interface CFormSelectProps extends Omit<InputHTMLAttributes<HTMLSelectEle
|
|
|
36
48
|
}
|
|
37
49
|
|
|
38
50
|
export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
|
|
39
|
-
({ children, className, htmlSize, invalid, size, valid, ...rest }, ref) => {
|
|
51
|
+
({ children, className, htmlSize, invalid, options, size, valid, ...rest }, ref) => {
|
|
40
52
|
const _className = classNames(
|
|
41
53
|
'form-select',
|
|
42
54
|
{
|
|
@@ -48,7 +60,20 @@ export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
|
|
|
48
60
|
)
|
|
49
61
|
return (
|
|
50
62
|
<select className={_className} size={htmlSize} {...rest} ref={ref}>
|
|
51
|
-
{
|
|
63
|
+
{options
|
|
64
|
+
? options.map((option, index) => {
|
|
65
|
+
return (
|
|
66
|
+
<option
|
|
67
|
+
{...(typeof option === 'object' &&
|
|
68
|
+
option.disabled && { disabled: option.disabled })}
|
|
69
|
+
{...(typeof option === 'object' && option.value && { value: option.value })}
|
|
70
|
+
key={index}
|
|
71
|
+
>
|
|
72
|
+
{typeof option === 'string' ? option : option.label}
|
|
73
|
+
</option>
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
: children}
|
|
52
77
|
</select>
|
|
53
78
|
)
|
|
54
79
|
},
|
|
@@ -59,6 +84,7 @@ CFormSelect.propTypes = {
|
|
|
59
84
|
className: PropTypes.string,
|
|
60
85
|
htmlSize: PropTypes.number,
|
|
61
86
|
invalid: PropTypes.bool,
|
|
87
|
+
options: PropTypes.array,
|
|
62
88
|
size: PropTypes.oneOf(['sm', 'lg']),
|
|
63
89
|
valid: PropTypes.bool,
|
|
64
90
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { FC, ReactElement, ReactNode, useState } from 'react'
|
|
2
2
|
import { createPortal } from 'react-dom'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
|
+
import classNames from 'classnames'
|
|
4
5
|
import { Manager, Popper, Reference } from 'react-popper'
|
|
5
6
|
import { Transition } from 'react-transition-group'
|
|
6
7
|
|
|
7
|
-
import { CPopoverContent } from './CPopoverContent'
|
|
8
|
+
// import { CPopoverContent } from './CPopoverContent'
|
|
8
9
|
import { Triggers, triggerPropType } from '../Types'
|
|
9
10
|
|
|
10
11
|
export interface CPopoverProps {
|
|
@@ -38,7 +39,7 @@ export interface CPopoverProps {
|
|
|
38
39
|
/**
|
|
39
40
|
* Describes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.
|
|
40
41
|
*/
|
|
41
|
-
placement?: 'top' | 'right' | 'bottom' | 'left'
|
|
42
|
+
placement?: 'auto' | 'top' | 'right' | 'bottom' | 'left'
|
|
42
43
|
/**
|
|
43
44
|
* Toggle the visibility of popover component.
|
|
44
45
|
*/
|
|
@@ -47,10 +48,12 @@ export interface CPopoverProps {
|
|
|
47
48
|
|
|
48
49
|
export const CPopover: FC<CPopoverProps> = ({
|
|
49
50
|
children,
|
|
51
|
+
content,
|
|
50
52
|
placement = 'top',
|
|
51
53
|
offset = [0, 8],
|
|
52
54
|
onHide,
|
|
53
55
|
onShow,
|
|
56
|
+
title,
|
|
54
57
|
trigger = 'click',
|
|
55
58
|
visible,
|
|
56
59
|
...rest
|
|
@@ -114,15 +117,23 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
114
117
|
},
|
|
115
118
|
]}
|
|
116
119
|
>
|
|
117
|
-
{(
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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}
|
|
123
131
|
{...rest}
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
>
|
|
133
|
+
<div className="popover-arrow" {...arrowProps}></div>
|
|
134
|
+
<div className="popover-header">{title}</div>
|
|
135
|
+
<div className="popover-body">{content}</div>
|
|
136
|
+
</div>
|
|
126
137
|
)}
|
|
127
138
|
</Popper>
|
|
128
139
|
)
|
|
@@ -136,10 +147,12 @@ export const CPopover: FC<CPopoverProps> = ({
|
|
|
136
147
|
|
|
137
148
|
CPopover.propTypes = {
|
|
138
149
|
children: PropTypes.any,
|
|
139
|
-
|
|
150
|
+
content: PropTypes.node,
|
|
151
|
+
placement: PropTypes.oneOf(['auto', 'top', 'right', 'bottom', 'left']),
|
|
140
152
|
offset: PropTypes.any, // TODO: find good proptype
|
|
141
153
|
onHide: PropTypes.func,
|
|
142
154
|
onShow: PropTypes.func,
|
|
155
|
+
title: PropTypes.string,
|
|
143
156
|
trigger: triggerPropType,
|
|
144
157
|
visible: PropTypes.bool,
|
|
145
158
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { FC, ReactElement, ReactNode, useState } from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
2
|
import { createPortal } from 'react-dom'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import classNames from 'classnames'
|
|
4
5
|
import { Manager, Popper, Reference } from 'react-popper'
|
|
5
6
|
import { Transition } from 'react-transition-group'
|
|
6
7
|
|
|
7
|
-
import { CTooltipContent } from './CTooltipContent'
|
|
8
|
+
// import { CTooltipContent } from './CTooltipContent'
|
|
8
9
|
import { Triggers, triggerPropType } from '../Types'
|
|
9
10
|
|
|
10
11
|
export interface CTooltipProps {
|
|
@@ -30,7 +31,7 @@ export interface CTooltipProps {
|
|
|
30
31
|
/**
|
|
31
32
|
* Describes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.
|
|
32
33
|
*/
|
|
33
|
-
placement?: 'top' | 'right' | 'bottom' | 'left'
|
|
34
|
+
placement?: 'auto' | 'top' | 'right' | 'bottom' | 'left'
|
|
34
35
|
/**
|
|
35
36
|
* Toggle the visibility of popover component.
|
|
36
37
|
*/
|
|
@@ -39,6 +40,7 @@ export interface CTooltipProps {
|
|
|
39
40
|
|
|
40
41
|
export const CTooltip: FC<CTooltipProps> = ({
|
|
41
42
|
children,
|
|
43
|
+
content,
|
|
42
44
|
placement = 'top',
|
|
43
45
|
onHide,
|
|
44
46
|
onShow,
|
|
@@ -95,15 +97,22 @@ export const CTooltip: FC<CTooltipProps> = ({
|
|
|
95
97
|
const transitionClass = getTransitionClass(state)
|
|
96
98
|
return (
|
|
97
99
|
<Popper placement={placement}>
|
|
98
|
-
{(
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
{({ arrowProps, style, ref }) => (
|
|
101
|
+
<div
|
|
102
|
+
className={classNames(
|
|
103
|
+
`tooltip bs-tooltip-${
|
|
104
|
+
placement === 'left' ? 'start' : placement === 'right' ? 'end' : placement
|
|
105
|
+
}`,
|
|
106
|
+
transitionClass,
|
|
107
|
+
)}
|
|
108
|
+
ref={ref}
|
|
109
|
+
role="tooltip"
|
|
110
|
+
style={style}
|
|
104
111
|
{...rest}
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
>
|
|
113
|
+
<div className="tooltip-arrow" {...arrowProps}></div>
|
|
114
|
+
<div className="tooltip-inner">{content}</div>
|
|
115
|
+
</div>
|
|
107
116
|
)}
|
|
108
117
|
</Popper>
|
|
109
118
|
)
|
|
@@ -117,7 +126,8 @@ export const CTooltip: FC<CTooltipProps> = ({
|
|
|
117
126
|
|
|
118
127
|
CTooltip.propTypes = {
|
|
119
128
|
children: PropTypes.any,
|
|
120
|
-
|
|
129
|
+
content: PropTypes.node,
|
|
130
|
+
placement: PropTypes.oneOf(['auto', 'top', 'right', 'bottom', 'left']),
|
|
121
131
|
onHide: PropTypes.func,
|
|
122
132
|
onShow: PropTypes.func,
|
|
123
133
|
trigger: triggerPropType,
|
package/src/index.ts
CHANGED
|
@@ -87,7 +87,6 @@ import { CNavbarToggler } from './components/navbar/CNavbarToggler'
|
|
|
87
87
|
import { CPagination } from './components/pagination/CPagination'
|
|
88
88
|
import { CPaginationItem } from './components/pagination/CPaginationItem'
|
|
89
89
|
import { CPopover } from './components/popover/CPopover'
|
|
90
|
-
import { CPopoverContent } from './components/popover/CPopoverContent'
|
|
91
90
|
import { CProgress } from './components/progress/CProgress'
|
|
92
91
|
import { CProgressBar } from './components/progress/CProgressBar'
|
|
93
92
|
import { CSidebar } from './components/sidebar/CSidebar'
|
|
@@ -117,7 +116,6 @@ import { CToastClose } from './components/toast/CToastClose'
|
|
|
117
116
|
import { CToastHeader } from './components/toast/CToastHeader'
|
|
118
117
|
import { CToaster } from './components/toast/CToaster'
|
|
119
118
|
import { CTooltip } from './components/tooltip/CTooltip'
|
|
120
|
-
import { CTooltipContent } from './components/tooltip/CTooltipContent'
|
|
121
119
|
|
|
122
120
|
export {
|
|
123
121
|
CAccordion,
|
|
@@ -209,7 +207,6 @@ export {
|
|
|
209
207
|
CPagination,
|
|
210
208
|
CPaginationItem,
|
|
211
209
|
CPopover,
|
|
212
|
-
CPopoverContent,
|
|
213
210
|
CProgress,
|
|
214
211
|
CProgressBar,
|
|
215
212
|
COffcanvas,
|
|
@@ -239,7 +236,6 @@ export {
|
|
|
239
236
|
CToastHeader,
|
|
240
237
|
CToaster,
|
|
241
238
|
CTooltip,
|
|
242
|
-
CTooltipContent,
|
|
243
239
|
}
|
|
244
240
|
|
|
245
241
|
export * from './components/'
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
2
|
-
declare type Direction = 'prev' | 'next';
|
|
3
|
-
export interface CCarouselControlProps extends HTMLAttributes<HTMLButtonElement> {
|
|
4
|
-
/**
|
|
5
|
-
* A string of all className you want applied to the base component. [docs]
|
|
6
|
-
*/
|
|
7
|
-
className?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Direction. [docs]
|
|
10
|
-
*
|
|
11
|
-
* @type 'prev' | 'next'
|
|
12
|
-
*/
|
|
13
|
-
direction: Direction;
|
|
14
|
-
}
|
|
15
|
-
export declare const CCarouselControl: React.ForwardRefExoticComponent<CCarouselControlProps & React.RefAttributes<HTMLButtonElement>>;
|
|
16
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
2
|
-
export interface CCarouselIndicatorsProps extends HTMLAttributes<HTMLOListElement> {
|
|
3
|
-
/**
|
|
4
|
-
* A string of all className you want applied to the base component. [docs]
|
|
5
|
-
*/
|
|
6
|
-
className?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Indicators section user classes. [docs]
|
|
9
|
-
*/
|
|
10
|
-
indicatorsClass?: string;
|
|
11
|
-
}
|
|
12
|
-
export declare const CCarouselIndicators: React.ForwardRefExoticComponent<CCarouselIndicatorsProps & React.RefAttributes<HTMLOListElement>>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from 'react';
|
|
2
|
-
export interface CCarouselInnerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
/**
|
|
4
|
-
* A string of all className you want applied to the base component. [docs]
|
|
5
|
-
*/
|
|
6
|
-
className?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const CCarouselInner: React.ForwardRefExoticComponent<CCarouselInnerProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties } from 'react';
|
|
2
|
-
import { CPopoverProps } from './CPopover';
|
|
3
|
-
import { PopperChildrenProps } from 'react-popper';
|
|
4
|
-
interface CPopoverContentProps extends Omit<CPopoverProps, 'placement' | 'children' | 'trigger'>, Omit<PopperChildrenProps, 'placementPostfix' | 'style'> {
|
|
5
|
-
transitionClass?: string;
|
|
6
|
-
style?: CSSProperties;
|
|
7
|
-
placementClassNamePostfix?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const CPopoverContent: React.ForwardRefExoticComponent<Pick<CPopoverContentProps, "style" | "title" | "visible" | "onHide" | "onShow" | "content" | "placement" | "arrowProps" | "forceUpdate" | "hasPopperEscaped" | "isReferenceHidden" | "update" | "offset" | "placementClassNamePostfix" | "transitionClass"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties } from 'react';
|
|
2
|
-
import { CTooltipProps } from './CTooltip';
|
|
3
|
-
import { PopperChildrenProps } from 'react-popper';
|
|
4
|
-
interface CTooltipContentProps extends Omit<CTooltipProps, 'placement' | 'children' | 'trigger'>, Omit<PopperChildrenProps, 'placementPostfix' | 'style'> {
|
|
5
|
-
transitionClass?: string;
|
|
6
|
-
style?: CSSProperties;
|
|
7
|
-
placementClassNamePostfix?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const CTooltipContent: React.ForwardRefExoticComponent<Pick<CTooltipContentProps, "style" | "visible" | "onHide" | "onShow" | "content" | "placement" | "arrowProps" | "forceUpdate" | "hasPopperEscaped" | "isReferenceHidden" | "update" | "placementClassNamePostfix" | "transitionClass"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
declare const SEO: {
|
|
3
|
-
({ title, description, image, article }: {
|
|
4
|
-
title: any;
|
|
5
|
-
description: any;
|
|
6
|
-
image: any;
|
|
7
|
-
article: any;
|
|
8
|
-
}): JSX.Element;
|
|
9
|
-
propTypes: {
|
|
10
|
-
title: PropTypes.Requireable<string>;
|
|
11
|
-
description: PropTypes.Requireable<string>;
|
|
12
|
-
image: PropTypes.Requireable<string>;
|
|
13
|
-
article: PropTypes.Requireable<boolean>;
|
|
14
|
-
};
|
|
15
|
-
defaultProps: {
|
|
16
|
-
title: null;
|
|
17
|
-
description: null;
|
|
18
|
-
image: null;
|
|
19
|
-
article: boolean;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export default SEO;
|