@coreui/react-pro 5.11.0 → 5.12.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/cjs/components/accordion/CAccordionBody.js +2 -2
- package/dist/cjs/components/accordion/CAccordionBody.js.map +1 -1
- package/dist/cjs/components/accordion/CAccordionItem.d.ts +4 -0
- package/dist/cjs/components/accordion/CAccordionItem.js +4 -4
- package/dist/cjs/components/accordion/CAccordionItem.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdown.d.ts +77 -20
- package/dist/cjs/components/dropdown/CDropdown.js +6 -3
- package/dist/cjs/components/dropdown/CDropdown.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownMenu.js +1 -1
- package/dist/cjs/components/dropdown/CDropdownMenu.js.map +1 -1
- package/dist/cjs/components/popover/CPopover.d.ts +75 -20
- package/dist/cjs/components/popover/CPopover.js +8 -21
- package/dist/cjs/components/popover/CPopover.js.map +1 -1
- package/dist/cjs/components/smart-table/CSmartTableHead.js +3 -1
- package/dist/cjs/components/smart-table/CSmartTableHead.js.map +1 -1
- package/dist/cjs/components/smart-table/types.d.ts +1 -1
- package/dist/cjs/components/tooltip/CTooltip.d.ts +67 -15
- package/dist/cjs/components/tooltip/CTooltip.js +8 -21
- package/dist/cjs/components/tooltip/CTooltip.js.map +1 -1
- package/dist/cjs/hooks/useColorModes.js +5 -5
- package/dist/cjs/hooks/useColorModes.js.map +1 -1
- package/dist/esm/components/accordion/CAccordionBody.js +2 -2
- package/dist/esm/components/accordion/CAccordionBody.js.map +1 -1
- package/dist/esm/components/accordion/CAccordionItem.d.ts +4 -0
- package/dist/esm/components/accordion/CAccordionItem.js +4 -4
- package/dist/esm/components/accordion/CAccordionItem.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdown.d.ts +77 -20
- package/dist/esm/components/dropdown/CDropdown.js +6 -3
- package/dist/esm/components/dropdown/CDropdown.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownMenu.js +1 -1
- package/dist/esm/components/dropdown/CDropdownMenu.js.map +1 -1
- package/dist/esm/components/popover/CPopover.d.ts +75 -20
- package/dist/esm/components/popover/CPopover.js +8 -21
- package/dist/esm/components/popover/CPopover.js.map +1 -1
- package/dist/esm/components/smart-table/CSmartTableHead.js +3 -1
- package/dist/esm/components/smart-table/CSmartTableHead.js.map +1 -1
- package/dist/esm/components/smart-table/types.d.ts +1 -1
- package/dist/esm/components/tooltip/CTooltip.d.ts +67 -15
- package/dist/esm/components/tooltip/CTooltip.js +8 -21
- package/dist/esm/components/tooltip/CTooltip.js.map +1 -1
- package/dist/esm/hooks/useColorModes.js +5 -5
- package/dist/esm/hooks/useColorModes.js.map +1 -1
- package/package.json +4 -4
- package/src/components/accordion/CAccordionBody.tsx +3 -3
- package/src/components/accordion/CAccordionItem.tsx +9 -5
- package/src/components/dropdown/CDropdown.tsx +106 -26
- package/src/components/dropdown/CDropdownMenu.tsx +0 -1
- package/src/components/popover/CPopover.tsx +103 -43
- package/src/components/smart-table/CSmartTableHead.tsx +3 -0
- package/src/components/smart-table/types.ts +7 -1
- package/src/components/tooltip/CTooltip.tsx +94 -38
- package/src/hooks/useColorModes.ts +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useColorModes.js","sources":["../../../src/hooks/useColorModes.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQA,IAAM,cAAc,GAAG,UAAC,oBAA4B,EAAA;IAClD,OAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useColorModes.js","sources":["../../../src/hooks/useColorModes.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAQA,IAAM,cAAc,GAAG,UAAC,oBAA4B,EAAA;IAClD,OAAA,OAAO,MAAM,KAAK,WAAW,IAAI,YAAY,CAAC,OAAO,CAAC,oBAAoB,CAAC;AAA3E,CAA2E;AAE7E,IAAM,cAAc,GAAG,UAAC,oBAA4B,EAAE,SAAiB,EAAA;AACrE,IAAA,OAAA,YAAY,CAAC,OAAO,CAAC,oBAAoB,EAAE,SAAS,CAAC;AAArD,CAAqD;AAEvD,IAAM,uBAAuB,GAAG,UAAC,oBAA4B,EAAA;AAC3D,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAA,OAAO,OAAO;;AAGhB,IAAA,IAAM,WAAW,GAAG,cAAc,CAAC,oBAAoB,CAAC;IAExD,IAAI,WAAW,EAAE;AACf,QAAA,OAAO,WAAW;;AAGpB,IAAA,OAAO,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO;AACrF,CAAC;AAED,IAAM,QAAQ,GAAG,UAAC,SAAiB,EAAA;AACjC,IAAA,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,WAAW;QAC1C,SAAS,KAAK,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC;AACxE,cAAE;cACA,SAAS;AAEf,IAAA,IAAM,KAAK,GAAG,IAAI,KAAK,CAAC,mBAAmB,CAAC;AAC5C,IAAA,QAAQ,CAAC,eAAe,CAAC,aAAa,CAAC,KAAK,CAAC;AAC/C,CAAC;AAEM,IAAM,aAAa,GAAG,UAC3B,oBAAkD,EAAA;AAAlD,IAAA,IAAA,oBAAA,KAAA,KAAA,CAAA,EAAA,EAAA,oBAAkD,GAAA,2BAAA,CAAA;AAE5C,IAAA,IAAA,EAA4B,GAAA,QAAQ,CACxC,uBAAuB,CAAC,oBAAoB,CAAC,CAC9C,EAFM,SAAS,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,YAAY,QAE7B;AAED,IAAA,SAAS,CAAC,YAAA;QACR,IAAI,SAAS,EAAE;AACb,YAAA,cAAc,CAAC,oBAAoB,EAAE,SAAS,CAAC;YAC/C,QAAQ,CAAC,SAAS,CAAC;;AAEvB,KAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AAEf,IAAA,SAAS,CAAC,YAAA;QACR,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAA;AAC3E,YAAA,IAAM,WAAW,GAAG,cAAc,CAAC,oBAAoB,CAAC;YACxD,IAAI,WAAW,KAAK,OAAO,IAAI,WAAW,KAAK,MAAM,IAAI,SAAS,EAAE;gBAClE,QAAQ,CAAC,SAAS,CAAC;;AAEvB,SAAC,CAAC;AACJ,KAAC,CAAC;IAEF,OAAO;AACL,QAAA,SAAS,EAAA,SAAA;QACT,cAAc,EAAE,YAAM,EAAA,OAAA,OAAO,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAA,EAAA;AACnE,QAAA,YAAY,EAAA,YAAA;KACb;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreui/react-pro",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "UI Components Library for React.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
52
52
|
"@testing-library/dom": "^10.4.0",
|
|
53
53
|
"@testing-library/jest-dom": "^6.6.3",
|
|
54
|
-
"@testing-library/react": "^16.
|
|
54
|
+
"@testing-library/react": "^16.2.0",
|
|
55
55
|
"@types/jest": "^29.5.14",
|
|
56
56
|
"@types/prop-types": "15.7.13",
|
|
57
57
|
"@types/react": "^18.3.18",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"react-device-detect": "^2.2.3",
|
|
66
66
|
"react-dom": "^18.3.1",
|
|
67
67
|
"react-transition-group": "^4.4.5",
|
|
68
|
-
"rollup": "^4.
|
|
68
|
+
"rollup": "^4.34.4",
|
|
69
69
|
"ts-jest": "^29.2.5",
|
|
70
70
|
"tslib": "^2.8.1",
|
|
71
|
-
"typescript": "^5.7.
|
|
71
|
+
"typescript": "^5.7.3"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"react": ">=17",
|
|
@@ -15,16 +15,16 @@ export interface CAccordionBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
15
15
|
|
|
16
16
|
export const CAccordionBody = forwardRef<HTMLDivElement, CAccordionBodyProps>(
|
|
17
17
|
({ children, className, ...rest }, ref) => {
|
|
18
|
-
const { visible } = useContext(CAccordionItemContext)
|
|
18
|
+
const { id, visible } = useContext(CAccordionItemContext)
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
|
-
<CCollapse className="accordion-collapse" visible={visible}>
|
|
21
|
+
<CCollapse className="accordion-collapse" id={id} visible={visible}>
|
|
22
22
|
<div className={classNames('accordion-body', className)} {...rest} ref={ref}>
|
|
23
23
|
{children}
|
|
24
24
|
</div>
|
|
25
25
|
</CCollapse>
|
|
26
26
|
)
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
)
|
|
29
29
|
|
|
30
30
|
CAccordionBody.propTypes = {
|
|
@@ -22,6 +22,10 @@ export interface CAccordionItemContextProps {
|
|
|
22
22
|
export const CAccordionItemContext = createContext({} as CAccordionItemContextProps)
|
|
23
23
|
|
|
24
24
|
export interface CAccordionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
25
|
+
/**
|
|
26
|
+
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
27
|
+
*/
|
|
28
|
+
id?: string
|
|
25
29
|
/**
|
|
26
30
|
* A string of all className you want applied to the base component.
|
|
27
31
|
*/
|
|
@@ -33,9 +37,9 @@ export interface CAccordionItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
export const CAccordionItem = forwardRef<HTMLDivElement, CAccordionItemProps>(
|
|
36
|
-
({ children, className, itemKey, ...rest }, ref) => {
|
|
37
|
-
const
|
|
38
|
-
const _itemKey = useRef(itemKey ??
|
|
40
|
+
({ children, className, id, itemKey, ...rest }, ref) => {
|
|
41
|
+
const _id = id ?? useId()
|
|
42
|
+
const _itemKey = useRef(itemKey ?? _id)
|
|
39
43
|
|
|
40
44
|
const { _activeItemKey, alwaysOpen, setActiveKey } = useContext(CAccordionContext)
|
|
41
45
|
const [visible, setVisible] = useState(Boolean(_activeItemKey === _itemKey.current))
|
|
@@ -52,12 +56,12 @@ export const CAccordionItem = forwardRef<HTMLDivElement, CAccordionItemProps>(
|
|
|
52
56
|
|
|
53
57
|
return (
|
|
54
58
|
<div className={classNames('accordion-item', className)} {...rest} ref={ref}>
|
|
55
|
-
<CAccordionItemContext.Provider value={{ id, setVisible, visible }}>
|
|
59
|
+
<CAccordionItemContext.Provider value={{ id: _id, setVisible, visible }}>
|
|
56
60
|
{children}
|
|
57
61
|
</CAccordionItemContext.Provider>
|
|
58
62
|
</div>
|
|
59
63
|
)
|
|
60
|
-
}
|
|
64
|
+
}
|
|
61
65
|
)
|
|
62
66
|
|
|
63
67
|
CAccordionItem.propTypes = {
|
|
@@ -10,6 +10,7 @@ import React, {
|
|
|
10
10
|
} from 'react'
|
|
11
11
|
import PropTypes from 'prop-types'
|
|
12
12
|
import classNames from 'classnames'
|
|
13
|
+
import type { Options } from '@popperjs/core'
|
|
13
14
|
|
|
14
15
|
import { PolymorphicRefForwardingComponent } from '../../helpers'
|
|
15
16
|
import { useForkedRef, usePopper } from '../../hooks'
|
|
@@ -22,77 +23,148 @@ import { getPlacement } from './utils'
|
|
|
22
23
|
|
|
23
24
|
export interface CDropdownProps extends HTMLAttributes<HTMLDivElement | HTMLLIElement> {
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Specifies the alignment of the React Dropdown Menu within this React Dropdown.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Align dropdown menu to the end on large devices, otherwise start
|
|
30
|
+
* <CDropdown alignment={{ lg: 'end', xs: 'start' }}>
|
|
31
|
+
* <CDropdownToggle>Toggle dropdown</CDropdownToggle>
|
|
32
|
+
* <CDropdownMenu>
|
|
33
|
+
* <CDropdownItem>Action</CDropdownItem>
|
|
34
|
+
* <CDropdownItem>Another Action</CDropdownItem>
|
|
35
|
+
* </CDropdownMenu>
|
|
36
|
+
* </CDropdown>
|
|
26
37
|
*
|
|
27
38
|
* @type 'start' | 'end' | { xs: 'start' | 'end' } | { sm: 'start' | 'end' } | { md: 'start' | 'end' } | { lg: 'start' | 'end' } | { xl: 'start' | 'end'} | { xxl: 'start' | 'end'}
|
|
28
39
|
*/
|
|
29
40
|
alignment?: Alignments
|
|
41
|
+
|
|
30
42
|
/**
|
|
31
|
-
*
|
|
43
|
+
* Determines the root node component (native HTML element or a custom React component) for the React Dropdown.
|
|
32
44
|
*/
|
|
33
45
|
as?: ElementType
|
|
46
|
+
|
|
34
47
|
/**
|
|
35
|
-
*
|
|
36
|
-
* - `true` -
|
|
37
|
-
* - `false` -
|
|
38
|
-
* - `'inside'` -
|
|
39
|
-
* - `'outside'` -
|
|
48
|
+
* Configures automatic closing behavior for the React Dropdown:
|
|
49
|
+
* - `true` - Close on clicks inside or outside of the React Dropdown Menu.
|
|
50
|
+
* - `false` - Disable auto-close; manually call `hide` or `toggle` (also not closed by `Escape`).
|
|
51
|
+
* - `'inside'` - Close only when clicking inside the React Dropdown Menu.
|
|
52
|
+
* - `'outside'` - Close only when clicking outside the React Dropdown Menu.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Close only when user clicks outside of the menu
|
|
56
|
+
* <CDropdown autoClose="outside" />
|
|
40
57
|
*/
|
|
41
58
|
autoClose?: 'inside' | 'outside' | boolean
|
|
59
|
+
|
|
42
60
|
/**
|
|
43
|
-
*
|
|
61
|
+
* Adds custom classes to the React Dropdown root element.
|
|
44
62
|
*/
|
|
45
63
|
className?: string
|
|
64
|
+
|
|
46
65
|
/**
|
|
47
|
-
* Appends the
|
|
66
|
+
* Appends the React Dropdown Menu to a specific element. You can pass an HTML element or a function returning an element. Defaults to `document.body`.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Append the menu to a custom container
|
|
70
|
+
* const myContainer = document.getElementById('my-container')
|
|
71
|
+
*
|
|
72
|
+
* <CDropdown container={myContainer} />
|
|
48
73
|
*
|
|
49
74
|
* @since 4.11.0
|
|
50
75
|
*/
|
|
51
76
|
container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null
|
|
77
|
+
|
|
52
78
|
/**
|
|
53
|
-
*
|
|
79
|
+
* Applies a darker color scheme to the React Dropdown Menu, often used within dark navbars.
|
|
54
80
|
*/
|
|
55
81
|
dark?: boolean
|
|
82
|
+
|
|
56
83
|
/**
|
|
57
|
-
*
|
|
84
|
+
* Specifies the direction of the React Dropdown.
|
|
58
85
|
*/
|
|
59
86
|
direction?: 'center' | 'dropup' | 'dropup-center' | 'dropend' | 'dropstart'
|
|
87
|
+
|
|
60
88
|
/**
|
|
61
|
-
*
|
|
89
|
+
* Defines x and y offsets ([x, y]) for the React Dropdown Menu relative to its target.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* // Offset the menu 10px in X and 5px in Y direction
|
|
93
|
+
* <CDropdown offset={[10, 5]}>
|
|
94
|
+
* ...
|
|
95
|
+
* </CDropdown>
|
|
62
96
|
*/
|
|
63
97
|
offset?: [number, number]
|
|
98
|
+
|
|
64
99
|
/**
|
|
65
|
-
* Callback fired
|
|
100
|
+
* Callback fired right before the React Dropdown becomes hidden.
|
|
66
101
|
*
|
|
67
102
|
* @since 4.9.0
|
|
68
103
|
*/
|
|
69
104
|
onHide?: () => void
|
|
105
|
+
|
|
70
106
|
/**
|
|
71
|
-
* Callback fired
|
|
107
|
+
* Callback fired immediately after the React Dropdown is displayed.
|
|
72
108
|
*/
|
|
73
109
|
onShow?: () => void
|
|
110
|
+
|
|
74
111
|
/**
|
|
75
|
-
*
|
|
112
|
+
* Determines the placement of the React Dropdown Menu after Popper.js modifiers.
|
|
76
113
|
*
|
|
77
|
-
* @type 'auto' | 'top-end' | 'top' | 'top-start' | 'bottom-end' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | 'left-start' | 'left' | 'left-end'
|
|
114
|
+
* @type 'auto' | 'auto-start' | 'auto-end' | 'top-end' | 'top' | 'top-start' | 'bottom-end' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | 'left-start' | 'left' | 'left-end'
|
|
78
115
|
*/
|
|
79
116
|
placement?: Placements
|
|
117
|
+
|
|
80
118
|
/**
|
|
81
|
-
*
|
|
119
|
+
* Enables or disables dynamic positioning via Popper.js for the React Dropdown Menu.
|
|
82
120
|
*/
|
|
83
121
|
popper?: boolean
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Provides a custom Popper.js configuration or a function that returns a modified Popper.js configuration for advanced positioning of the React Dropdown Menu. [Read more](https://popper.js.org/docs/v2/constructors/#options)
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* // Providing a custom popper config
|
|
128
|
+
* <CDropdown
|
|
129
|
+
* popperConfig={{
|
|
130
|
+
* modifiers: [
|
|
131
|
+
* {
|
|
132
|
+
* name: 'flip',
|
|
133
|
+
* options: { fallbackPlacements: ['bottom', 'top'] },
|
|
134
|
+
* },
|
|
135
|
+
* ],
|
|
136
|
+
* }}
|
|
137
|
+
* >...</CDropdown>
|
|
138
|
+
*
|
|
139
|
+
* @since 5.5.0
|
|
140
|
+
*/
|
|
141
|
+
popperConfig?: Partial<Options> | ((defaultPopperConfig: Partial<Options>) => Partial<Options>)
|
|
142
|
+
|
|
84
143
|
/**
|
|
85
|
-
*
|
|
144
|
+
* Renders the React Dropdown Menu using a React Portal, allowing it to escape the DOM hierarchy for improved positioning.
|
|
86
145
|
*
|
|
87
146
|
* @since 4.8.0
|
|
88
147
|
*/
|
|
89
148
|
portal?: boolean
|
|
149
|
+
|
|
90
150
|
/**
|
|
91
|
-
*
|
|
151
|
+
* Defines the visual variant of the React Dropdown
|
|
92
152
|
*/
|
|
93
153
|
variant?: 'btn-group' | 'dropdown' | 'input-group' | 'nav-item'
|
|
154
|
+
|
|
94
155
|
/**
|
|
95
|
-
*
|
|
156
|
+
* Controls the visibility of the React Dropdown Menu:
|
|
157
|
+
* - `true` - Visible
|
|
158
|
+
* - `false` - Hidden
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* // Programmatically manage the dropdown visibility
|
|
162
|
+
* const [visible, setVisible] = useState(false)
|
|
163
|
+
*
|
|
164
|
+
* <CDropdown visible={visible}>
|
|
165
|
+
* ...
|
|
166
|
+
* </CDropdown>
|
|
167
|
+
*
|
|
96
168
|
*/
|
|
97
169
|
visible?: boolean
|
|
98
170
|
}
|
|
@@ -126,12 +198,13 @@ export const CDropdown: PolymorphicRefForwardingComponent<'div', CDropdownProps>
|
|
|
126
198
|
onShow,
|
|
127
199
|
placement = 'bottom-start',
|
|
128
200
|
popper = true,
|
|
201
|
+
popperConfig,
|
|
129
202
|
portal = false,
|
|
130
203
|
variant = 'btn-group',
|
|
131
204
|
visible = false,
|
|
132
205
|
...rest
|
|
133
206
|
},
|
|
134
|
-
ref
|
|
207
|
+
ref
|
|
135
208
|
) => {
|
|
136
209
|
const dropdownRef = useRef<HTMLDivElement>(null)
|
|
137
210
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -161,7 +234,7 @@ export const CDropdown: PolymorphicRefForwardingComponent<'div', CDropdownProps>
|
|
|
161
234
|
setVisible,
|
|
162
235
|
}
|
|
163
236
|
|
|
164
|
-
const
|
|
237
|
+
const defaultPopperConfig = {
|
|
165
238
|
modifiers: [
|
|
166
239
|
{
|
|
167
240
|
name: 'offset',
|
|
@@ -173,6 +246,11 @@ export const CDropdown: PolymorphicRefForwardingComponent<'div', CDropdownProps>
|
|
|
173
246
|
placement: getPlacement(placement, direction, alignment, isRTL(dropdownMenuRef.current)),
|
|
174
247
|
}
|
|
175
248
|
|
|
249
|
+
const computedPopperConfig: Partial<Options> = {
|
|
250
|
+
...defaultPopperConfig,
|
|
251
|
+
...(typeof popperConfig === 'function' ? popperConfig(defaultPopperConfig) : popperConfig),
|
|
252
|
+
}
|
|
253
|
+
|
|
176
254
|
useEffect(() => {
|
|
177
255
|
setVisible(visible)
|
|
178
256
|
}, [visible])
|
|
@@ -180,7 +258,8 @@ export const CDropdown: PolymorphicRefForwardingComponent<'div', CDropdownProps>
|
|
|
180
258
|
useEffect(() => {
|
|
181
259
|
if (_visible && dropdownToggleRef.current && dropdownMenuRef.current) {
|
|
182
260
|
dropdownToggleRef.current.focus()
|
|
183
|
-
popper &&
|
|
261
|
+
popper &&
|
|
262
|
+
initPopper(dropdownToggleRef.current, dropdownMenuRef.current, computedPopperConfig)
|
|
184
263
|
window.addEventListener('mouseup', handleMouseUp)
|
|
185
264
|
window.addEventListener('keyup', handleKeyup)
|
|
186
265
|
dropdownToggleRef.current.addEventListener('keydown', handleKeydown)
|
|
@@ -209,7 +288,7 @@ export const CDropdown: PolymorphicRefForwardingComponent<'div', CDropdownProps>
|
|
|
209
288
|
event.preventDefault()
|
|
210
289
|
const target = event.target as HTMLElement
|
|
211
290
|
const items: HTMLElement[] = Array.from(
|
|
212
|
-
dropdownMenuRef.current.querySelectorAll('.dropdown-item:not(.disabled):not(:disabled)')
|
|
291
|
+
dropdownMenuRef.current.querySelectorAll('.dropdown-item:not(.disabled):not(:disabled)')
|
|
213
292
|
)
|
|
214
293
|
getNextActiveElement(items, target, event.key === 'ArrowDown', true).focus()
|
|
215
294
|
}
|
|
@@ -258,7 +337,7 @@ export const CDropdown: PolymorphicRefForwardingComponent<'div', CDropdownProps>
|
|
|
258
337
|
[`${direction}`]:
|
|
259
338
|
direction && direction !== 'center' && direction !== 'dropup-center',
|
|
260
339
|
},
|
|
261
|
-
className
|
|
340
|
+
className
|
|
262
341
|
)}
|
|
263
342
|
{...rest}
|
|
264
343
|
ref={forkedRef}
|
|
@@ -268,7 +347,7 @@ export const CDropdown: PolymorphicRefForwardingComponent<'div', CDropdownProps>
|
|
|
268
347
|
)}
|
|
269
348
|
</CDropdownContext.Provider>
|
|
270
349
|
)
|
|
271
|
-
}
|
|
350
|
+
}
|
|
272
351
|
)
|
|
273
352
|
|
|
274
353
|
const alignmentDirection = PropTypes.oneOf<Directions>(['start', 'end'])
|
|
@@ -297,6 +376,7 @@ CDropdown.propTypes = {
|
|
|
297
376
|
onShow: PropTypes.func,
|
|
298
377
|
placement: placementPropType,
|
|
299
378
|
popper: PropTypes.bool,
|
|
379
|
+
popperConfig: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
300
380
|
portal: PropTypes.bool,
|
|
301
381
|
variant: PropTypes.oneOf(['btn-group', 'dropdown', 'input-group', 'nav-item']),
|
|
302
382
|
visible: PropTypes.bool,
|
|
@@ -42,7 +42,6 @@ export const CDropdownMenu: PolymorphicRefForwardingComponent<'ul', CDropdownMen
|
|
|
42
42
|
)}
|
|
43
43
|
ref={forkedRef}
|
|
44
44
|
role="menu"
|
|
45
|
-
aria-hidden={!visible}
|
|
46
45
|
{...(!popper && { 'data-coreui-popper': 'static' })}
|
|
47
46
|
{...(dark && { 'data-coreui-theme': 'dark' })}
|
|
48
47
|
{...rest}
|
|
@@ -9,6 +9,7 @@ import React, {
|
|
|
9
9
|
} from 'react'
|
|
10
10
|
import classNames from 'classnames'
|
|
11
11
|
import PropTypes from 'prop-types'
|
|
12
|
+
import type { Options } from '@popperjs/core'
|
|
12
13
|
|
|
13
14
|
import { CConditionalPortal } from '../conditional-portal'
|
|
14
15
|
import { useForkedRef, usePopper } from '../../hooks'
|
|
@@ -18,65 +19,132 @@ import { executeAfterTransition, getRTLPlacement } from '../../utils'
|
|
|
18
19
|
|
|
19
20
|
export interface CPopoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'content'> {
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
+
* Adds a fade transition animation to the React Popover.
|
|
22
23
|
*
|
|
23
24
|
* @since 4.9.0
|
|
24
25
|
*/
|
|
25
26
|
animation?: boolean
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
29
|
+
* Custom class name(s) for additional styling.
|
|
28
30
|
*/
|
|
29
31
|
className?: string
|
|
32
|
+
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
34
|
+
* Defines the container element to which the React Popover is appended.
|
|
35
|
+
* Accepts:
|
|
36
|
+
* - A DOM element (`HTMLElement` or `DocumentFragment`)
|
|
37
|
+
* - A function that returns a single element
|
|
38
|
+
* - `null` (defaults to `document.body`)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* <CPopover container={document.getElementById('my-container')}>...</CPopover>
|
|
32
42
|
*
|
|
43
|
+
* @default document.body
|
|
33
44
|
* @since 4.11.0
|
|
34
45
|
*/
|
|
35
46
|
container?: DocumentFragment | Element | (() => DocumentFragment | Element | null) | null
|
|
47
|
+
|
|
36
48
|
/**
|
|
37
|
-
*
|
|
49
|
+
* Main content of the React Popover. It can be a string or any valid React node.
|
|
38
50
|
*/
|
|
39
51
|
content: ReactNode | string
|
|
52
|
+
|
|
40
53
|
/**
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
54
|
+
* Delay (in milliseconds) before showing or hiding the React Popover.
|
|
55
|
+
* - If a number is provided, that delay applies to both "show" and "hide".
|
|
56
|
+
* - If an object is provided, use separate values for "show" and "hide".
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Delays 300ms on both show and hide
|
|
60
|
+
* <CPopover delay={300}>...</CPopover>
|
|
61
|
+
*
|
|
62
|
+
* // Delays 500ms on show and 100ms on hide
|
|
63
|
+
* <CPopover delay={{ show: 500, hide: 100 }}>...</CPopover>
|
|
46
64
|
*
|
|
47
65
|
* @since 4.9.0
|
|
48
66
|
*/
|
|
49
67
|
delay?: number | { show: number; hide: number }
|
|
68
|
+
|
|
50
69
|
/**
|
|
51
|
-
*
|
|
70
|
+
* Specifies the fallback placements when the preferred `placement` cannot be met.
|
|
52
71
|
*
|
|
72
|
+
* @type 'top', 'right', 'bottom', 'left' | ('top', 'right', 'bottom', 'left')[]
|
|
53
73
|
* @since 4.9.0
|
|
54
74
|
*/
|
|
55
75
|
fallbackPlacements?: Placements | Placements[]
|
|
76
|
+
|
|
56
77
|
/**
|
|
57
|
-
*
|
|
78
|
+
* Offset of the React Popover relative to its toggle element, in the form `[x, y]`.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // Offset the menu 0px in X and 10px in Y direction
|
|
82
|
+
* <CPopover offset={[0, 10]}>...</CPopover>
|
|
83
|
+
*
|
|
84
|
+
* // Offset the menu 5px in both X and Y direction
|
|
85
|
+
* <CPopover offset={[5, 5]}>...</CPopover>
|
|
86
|
+
*/
|
|
87
|
+
offset?: [number, number]
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Invoked when the React Popover is about to hide.
|
|
58
91
|
*/
|
|
59
92
|
onHide?: () => void
|
|
93
|
+
|
|
60
94
|
/**
|
|
61
|
-
*
|
|
95
|
+
* Invoked when the React Popover is about to show.
|
|
62
96
|
*/
|
|
63
97
|
onShow?: () => void
|
|
98
|
+
|
|
64
99
|
/**
|
|
65
|
-
*
|
|
100
|
+
* Placement of the React Popover. Popper.js may override this based on available space.
|
|
66
101
|
*/
|
|
67
|
-
|
|
102
|
+
placement?: 'auto' | 'top' | 'right' | 'bottom' | 'left'
|
|
103
|
+
|
|
68
104
|
/**
|
|
69
|
-
*
|
|
105
|
+
* Allows customization of the Popper.js configuration for the React Popover.
|
|
106
|
+
* Can be an object or a function returning a modified configuration.
|
|
107
|
+
* [Learn more](https://popper.js.org/docs/v2/constructors/#options)
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* <CPopover
|
|
111
|
+
* popperConfig={(defaultConfig) => ({
|
|
112
|
+
* ...defaultConfig,
|
|
113
|
+
* strategy: 'fixed',
|
|
114
|
+
* modifiers: [
|
|
115
|
+
* ...defaultConfig.modifiers,
|
|
116
|
+
* { name: 'computeStyles', options: { adaptive: false } },
|
|
117
|
+
* ],
|
|
118
|
+
* })}
|
|
119
|
+
* >...</CPopover>
|
|
70
120
|
*
|
|
71
|
-
* @
|
|
121
|
+
* @since 5.5.0
|
|
72
122
|
*/
|
|
73
|
-
|
|
123
|
+
popperConfig?: Partial<Options> | ((defaultPopperConfig: Partial<Options>) => Partial<Options>)
|
|
124
|
+
|
|
74
125
|
/**
|
|
75
|
-
*
|
|
126
|
+
* Title for the React Popover header. Can be a string or any valid React node.
|
|
76
127
|
*/
|
|
77
|
-
|
|
128
|
+
title?: ReactNode | string
|
|
129
|
+
|
|
78
130
|
/**
|
|
79
|
-
*
|
|
131
|
+
* Determines which events trigger the visibility of the React Popover. Can be a single trigger or an array of triggers.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* // Hover-only popover
|
|
135
|
+
* <CPopover trigger="hover">...</CPopover>
|
|
136
|
+
*
|
|
137
|
+
* // Hover + click combined
|
|
138
|
+
* <CPopover trigger={['hover', 'click']}>...</CPopover>
|
|
139
|
+
*
|
|
140
|
+
* @type 'hover' | 'focus' | 'click' | ('hover' | 'focus' | 'click')[]
|
|
141
|
+
*/
|
|
142
|
+
trigger?: Triggers | Triggers[]
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Controls the visibility of the React Popover.
|
|
146
|
+
* - `true` shows the popover.
|
|
147
|
+
* - `false` hides the popover.
|
|
80
148
|
*/
|
|
81
149
|
visible?: boolean
|
|
82
150
|
}
|
|
@@ -95,12 +163,13 @@ export const CPopover = forwardRef<HTMLDivElement, CPopoverProps>(
|
|
|
95
163
|
onHide,
|
|
96
164
|
onShow,
|
|
97
165
|
placement = 'top',
|
|
166
|
+
popperConfig,
|
|
98
167
|
title,
|
|
99
168
|
trigger = 'click',
|
|
100
169
|
visible,
|
|
101
170
|
...rest
|
|
102
171
|
},
|
|
103
|
-
ref
|
|
172
|
+
ref
|
|
104
173
|
) => {
|
|
105
174
|
const popoverRef = useRef<HTMLDivElement>(null)
|
|
106
175
|
const togglerRef = useRef(null)
|
|
@@ -114,30 +183,20 @@ export const CPopover = forwardRef<HTMLDivElement, CPopoverProps>(
|
|
|
114
183
|
|
|
115
184
|
const _delay = typeof delay === 'number' ? { show: delay, hide: delay } : delay
|
|
116
185
|
|
|
117
|
-
const
|
|
186
|
+
const defaultPopperConfig: Partial<Options> = {
|
|
118
187
|
modifiers: [
|
|
119
|
-
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
element: '.popover-arrow',
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
name: 'flip',
|
|
127
|
-
options: {
|
|
128
|
-
fallbackPlacements: fallbackPlacements,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
name: 'offset',
|
|
133
|
-
options: {
|
|
134
|
-
offset: offset,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
188
|
+
{ name: 'arrow', options: { element: '.popover-arrow' } },
|
|
189
|
+
{ name: 'flip', options: { fallbackPlacements } },
|
|
190
|
+
{ name: 'offset', options: { offset } },
|
|
137
191
|
],
|
|
138
192
|
placement: getRTLPlacement(placement, togglerRef.current),
|
|
139
193
|
}
|
|
140
194
|
|
|
195
|
+
const computedPopperConfig: Partial<Options> = {
|
|
196
|
+
...defaultPopperConfig,
|
|
197
|
+
...(typeof popperConfig === 'function' ? popperConfig(defaultPopperConfig) : popperConfig),
|
|
198
|
+
}
|
|
199
|
+
|
|
141
200
|
useEffect(() => {
|
|
142
201
|
if (visible) {
|
|
143
202
|
handleShow()
|
|
@@ -149,7 +208,7 @@ export const CPopover = forwardRef<HTMLDivElement, CPopoverProps>(
|
|
|
149
208
|
|
|
150
209
|
useEffect(() => {
|
|
151
210
|
if (mounted && togglerRef.current && popoverRef.current) {
|
|
152
|
-
initPopper(togglerRef.current, popoverRef.current,
|
|
211
|
+
initPopper(togglerRef.current, popoverRef.current, computedPopperConfig)
|
|
153
212
|
setTimeout(() => {
|
|
154
213
|
setVisible(true)
|
|
155
214
|
}, _delay.show)
|
|
@@ -215,7 +274,7 @@ export const CPopover = forwardRef<HTMLDivElement, CPopoverProps>(
|
|
|
215
274
|
fade: animation,
|
|
216
275
|
show: _visible,
|
|
217
276
|
},
|
|
218
|
-
className
|
|
277
|
+
className
|
|
219
278
|
)}
|
|
220
279
|
id={id}
|
|
221
280
|
ref={forkedRef}
|
|
@@ -230,7 +289,7 @@ export const CPopover = forwardRef<HTMLDivElement, CPopoverProps>(
|
|
|
230
289
|
</CConditionalPortal>
|
|
231
290
|
</>
|
|
232
291
|
)
|
|
233
|
-
}
|
|
292
|
+
}
|
|
234
293
|
)
|
|
235
294
|
|
|
236
295
|
CPopover.propTypes = {
|
|
@@ -251,6 +310,7 @@ CPopover.propTypes = {
|
|
|
251
310
|
onHide: PropTypes.func,
|
|
252
311
|
onShow: PropTypes.func,
|
|
253
312
|
placement: PropTypes.oneOf(['auto', 'top', 'right', 'bottom', 'left']),
|
|
313
|
+
popperConfig: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
254
314
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
255
315
|
trigger: triggerPropType,
|
|
256
316
|
visible: PropTypes.bool,
|
|
@@ -177,6 +177,9 @@ export const CSmartTableHead: PolymorphicRefForwardingComponent<'thead', CSmartT
|
|
|
177
177
|
(value: any) =>
|
|
178
178
|
handleOnCustomFilterChange &&
|
|
179
179
|
handleOnCustomFilterChange(getColumnKey(column), value),
|
|
180
|
+
columnFilterState && columnFilterState[getColumnKey(column)]
|
|
181
|
+
? columnFilterState[getColumnKey(column)]
|
|
182
|
+
: undefined
|
|
180
183
|
)
|
|
181
184
|
) : (
|
|
182
185
|
<CFormInput
|
|
@@ -6,7 +6,13 @@ import { CTableRowProps } from '../table/CTableRow'
|
|
|
6
6
|
|
|
7
7
|
export type Column = {
|
|
8
8
|
children?: Column[]
|
|
9
|
-
filter?:
|
|
9
|
+
filter?:
|
|
10
|
+
| boolean
|
|
11
|
+
| ((
|
|
12
|
+
values: any[],
|
|
13
|
+
onChange: (value: any) => void,
|
|
14
|
+
state: ColumnFilterValue | undefined
|
|
15
|
+
) => ReactNode)
|
|
10
16
|
group?: string
|
|
11
17
|
key: string
|
|
12
18
|
label?: string
|