@coreui/react 4.3.1 → 4.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreui/react",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "description": "UI Components Library for React.js",
5
5
  "keywords": [
6
6
  "react",
@@ -36,24 +36,24 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@popperjs/core": "^2.11.5",
39
- "@rollup/plugin-commonjs": "^22.0.1",
39
+ "@rollup/plugin-commonjs": "^22.0.2",
40
40
  "@rollup/plugin-node-resolve": "^13.3.0",
41
- "@rollup/plugin-typescript": "^8.3.4",
42
- "@testing-library/jest-dom": "^5.16.4",
43
- "@testing-library/react": "^13.3.0",
44
- "@types/react": "18.0.15",
41
+ "@rollup/plugin-typescript": "^8.5.0",
42
+ "@testing-library/jest-dom": "^5.16.5",
43
+ "@testing-library/react": "^13.4.0",
44
+ "@types/react": "18.0.19",
45
45
  "@types/react-dom": "^18.0.6",
46
46
  "@types/react-transition-group": "^4.4.5",
47
- "classnames": "^2.3.1",
47
+ "classnames": "^2.3.2",
48
48
  "prop-types": "^15.8.1",
49
49
  "react": "^18.2.0",
50
50
  "react-dom": "^18.2.0",
51
51
  "react-popper": "^2.2.5",
52
52
  "react-transition-group": "^4.4.5",
53
- "rollup": "^2.77.2",
53
+ "rollup": "^2.79.0",
54
54
  "rollup-plugin-peer-deps-external": "^2.2.4",
55
55
  "tslib": "^2.4.0",
56
- "typescript": "^4.7.4"
56
+ "typescript": "^4.8.3"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "react": ">=17",
@@ -235,7 +235,7 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
235
235
  <div className="carousel-inner">
236
236
  {Children.map(children, (child, index) => {
237
237
  if (React.isValidElement(child)) {
238
- return React.cloneElement(child, {
238
+ return React.cloneElement(child as React.ReactElement<any>, {
239
239
  active: active === index ? true : false,
240
240
  direction: direction,
241
241
  key: index,
@@ -56,10 +56,8 @@ export interface CDropdownProps extends HTMLAttributes<HTMLDivElement | HTMLLIEl
56
56
  dark?: boolean
57
57
  /**
58
58
  * Sets a specified direction and location of the dropdown menu.
59
- *
60
- * @type 'dropup' | 'dropend' | 'dropstart'
61
59
  */
62
- direction?: 'dropup' | 'dropend' | 'dropstart'
60
+ direction?: 'center' | 'dropup' | 'dropup-center' | 'dropend' | 'dropstart'
63
61
  /**
64
62
  * Callback fired when the component requests to be hidden.
65
63
  */
@@ -146,7 +144,11 @@ export const CDropdown = forwardRef<HTMLDivElement | HTMLLIElement, CDropdownPro
146
144
  {
147
145
  show: _visible,
148
146
  },
149
- direction,
147
+ direction === 'center'
148
+ ? 'dropdown-center'
149
+ : direction === 'dropup-center'
150
+ ? 'dropup dropup-center'
151
+ : direction,
150
152
  className,
151
153
  )
152
154
 
@@ -202,7 +204,7 @@ CDropdown.propTypes = {
202
204
  className: PropTypes.string,
203
205
  component: PropTypes.elementType,
204
206
  dark: PropTypes.bool,
205
- direction: PropTypes.oneOf(['dropup', 'dropend', 'dropstart']),
207
+ direction: PropTypes.oneOf(['center', 'dropup', 'dropup-center', 'dropend', 'dropstart']),
206
208
  onHide: PropTypes.func,
207
209
  onShow: PropTypes.func,
208
210
  placement: placementPropType,
@@ -86,10 +86,18 @@ export const CDropdownMenu: FC<CDropdownMenuProps> = ({
86
86
 
87
87
  let _placement: Placements = placement
88
88
 
89
+ if (direction === 'center') {
90
+ _placement = 'bottom'
91
+ }
92
+
89
93
  if (direction === 'dropup') {
90
94
  _placement = 'top-start'
91
95
  }
92
96
 
97
+ if (direction === 'dropup-center') {
98
+ _placement = 'top'
99
+ }
100
+
93
101
  if (direction === 'dropend') {
94
102
  _placement = 'right-start'
95
103
  }
@@ -75,7 +75,7 @@ export const CDropdownToggle: FC<CDropdownToggleProps> = ({
75
75
  const Toggler = (ref?: React.Ref<any>) => {
76
76
  return custom && React.isValidElement(children) ? (
77
77
  <>
78
- {React.cloneElement(children, {
78
+ {React.cloneElement(children as React.ReactElement<any>, {
79
79
  'aria-expanded': visible,
80
80
  ...(!rest.disabled && { ...triggers }),
81
81
  ref: useForkedRef(ref, dropdownToggleRef),
@@ -171,6 +171,12 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
171
171
  useLayoutEffect(() => {
172
172
  if (_visible) {
173
173
  document.body.classList.add('modal-open')
174
+
175
+ if (backdrop) {
176
+ document.body.style.overflow = 'hidden'
177
+ document.body.style.paddingRight = '0px'
178
+ }
179
+
174
180
  setTimeout(
175
181
  () => {
176
182
  modalRef.current?.focus()
@@ -179,8 +185,19 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
179
185
  )
180
186
  } else {
181
187
  document.body.classList.remove('modal-open')
188
+
189
+ if (backdrop) {
190
+ document.body.style.removeProperty('overflow')
191
+ document.body.style.removeProperty('padding-right')
192
+ }
193
+ }
194
+ return () => {
195
+ document.body.classList.remove('modal-open')
196
+ if (backdrop) {
197
+ document.body.style.removeProperty('overflow')
198
+ document.body.style.removeProperty('padding-right')
199
+ }
182
200
  }
183
- return () => document.body.classList.remove('modal-open')
184
201
  }, [_visible])
185
202
 
186
203
  const handleClickOutside = (event: Event) => {
@@ -124,7 +124,10 @@ export const CNavGroup = forwardRef<HTMLLIElement, CNavGroupProps>(
124
124
  >
125
125
  {React.Children.map(children, (child, index) => {
126
126
  if (React.isValidElement(child)) {
127
- return React.cloneElement(child, { key: index, idx: `${idx}.${index}` })
127
+ return React.cloneElement(child as React.ReactElement<any>, {
128
+ key: index,
129
+ idx: `${idx}.${index}`,
130
+ })
128
131
  }
129
132
  return
130
133
  })}
@@ -29,7 +29,10 @@ export const CSidebarNav = forwardRef<HTMLUListElement, CSidebarNavProps>(
29
29
  <CNavContext.Provider value={CNavContextValues}>
30
30
  {React.Children.map(children, (child, index) => {
31
31
  if (React.isValidElement(child)) {
32
- return React.cloneElement(child, { key: index, idx: `${index}` })
32
+ return React.cloneElement(child as React.ReactElement<any>, {
33
+ key: index,
34
+ idx: `${index}`,
35
+ })
33
36
  }
34
37
  return
35
38
  })}
@@ -53,6 +53,19 @@ exports[`CToast customize 4`] = `
53
53
  `;
54
54
 
55
55
  exports[`CToast customize 5`] = `
56
+ <div>
57
+ <div
58
+ aria-atomic="true"
59
+ aria-live="assertive"
60
+ class="toast fade bg-warning border-0 bazinga showing"
61
+ role="alert"
62
+ >
63
+ Test
64
+ </div>
65
+ </div>
66
+ `;
67
+
68
+ exports[`CToast customize 6`] = `
56
69
  <div>
57
70
  <div
58
71
  aria-atomic="true"