Skip to content

Commit 811f37f

Browse files
committed
release: 7.2.0
1 parent 02524ae commit 811f37f

File tree

14 files changed

+765
-719
lines changed

14 files changed

+765
-719
lines changed

README.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MDB 5 React
22

3-
Version: FREE 7.1.0
3+
Version: FREE 7.2.0
44

55
Documentation:
66
https://mdbootstrap.com/docs/b5/react/

app/demo/App.tsx

+14-39
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,25 @@
11
import React from "react";
2-
import {
3-
MDBDropdown,
4-
MDBDropdownMenu,
5-
MDBDropdownToggle,
6-
MDBDropdownItem,
7-
} from "mdb-react-ui-kit";
2+
import { MDBBtn, MDBContainer } from "mdb-react-ui-kit";
83

9-
export default function App() {
4+
function App() {
105
return (
11-
<div className="container">
12-
<div
13-
className="d-flex justify-content-center align-items-center"
14-
style={{ height: "100vh" }}
15-
>
6+
<MDBContainer fluid>
7+
<div className="d-flex justify-content-center align-items-center" style={{ height: "100vh" }}>
168
<div className="text-center">
179
<img
1810
className="mb-4"
19-
src="https://v1.mdbootstrap.com/wp-content/uploads/2022/11/mdb-sale.png"
11+
src="https://mdbootstrap.com/img/logo/mdb-transparent-250px.png"
12+
style={{ width: 250, height: 90 }}
2013
/>
21-
<h5 className="mb-4">
22-
Only now, you can get all premium features & more with the best
23-
discounts of the year.
24-
</h5>
25-
<p className="mb-4 fw-bold">All offers are LIMITED!</p>
26-
<a
27-
className="btn btn-lg btn-danger fw-bold mb-3"
28-
style={{ backgroundColor: "#e70808" }}
29-
href="https://mdbootstrap.com/sale/november/"
30-
target="_blank"
31-
role="button"
32-
>
33-
Check insane offers
34-
</a>
35-
<hr />
36-
<p className="mt-4 lead fw-bold">
37-
Publish your project with a single command.
38-
</p>
39-
<p className="mt-2">
40-
Use{" "}
41-
<a href="https://mdbgo.com/" className="fw-bold" target="_blank">
42-
<u>MDB GO</u>
43-
</a>{" "}
44-
for a free hosting & deployment tool
45-
</p>
14+
<h5 className="mb-3">Thank you for using our product. We're glad you're with us.</h5>
15+
<p className="mb-3">MDB Team</p>
16+
<MDBBtn tag="a" href="https://mdbootstrap.com/docs/react/" target="_blank" role="button">
17+
MDB REACT DOCS
18+
</MDBBtn>
4619
</div>
4720
</div>
48-
</div>
21+
</MDBContainer>
4922
);
5023
}
24+
25+
export default App;

app/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mdb-react-ui-kit-demo",
3-
"version": "7.1.0",
3+
"version": "7.2.0",
44
"main": "index.js",
55
"repository": {
66
"type": "git",
@@ -31,15 +31,15 @@
3131
"css-loader": "5.0.1",
3232
"file-loader": "6.2.0",
3333
"html-loader": "^1.3.2",
34-
"html-webpack-plugin": "4.5.0",
34+
"html-webpack-plugin": "^5.1.0",
3535
"prettier": "^2.2.1",
3636
"sass": "^1.29.0",
3737
"sass-loader": "^10.1.0",
3838
"style-loader": "2.0.0",
3939
"ts-loader": "^8.0.11",
4040
"typescript": "^4.1.3",
4141
"url-loader": "4.1.1",
42-
"webpack": "5.1.0",
42+
"webpack": "^5.20.0",
4343
"webpack-cli": "4.10.0",
4444
"webpack-dev-server": "4.9.1"
4545
},

app/src/free/components/Dropdown/DropdownMenu/DropdownMenu.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import clsx from 'clsx';
44
import React, { Children, cloneElement } from 'react';
5-
import { createPortal } from 'react-dom';
5+
import Portal from '../../../../utils/Portal';
66
import { useDropdownContext } from '../hooks/useDropdownContext';
77
import { useKeyboard } from '../hooks/useKeyboard';
88
import { useFade } from '../hooks/useFade';
@@ -93,7 +93,7 @@ const MDBDropdownMenu = ({
9393
</Tag>
9494
);
9595

96-
return <>{appendToBody ? createPortal(menu, document.body) : menu}</>;
96+
return <Portal disablePortal={!appendToBody}>{menu}</Portal>;
9797
};
9898

9999
export default MDBDropdownMenu;

app/src/free/components/Popover/Popover.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import clsx from 'clsx';
44
import React, { useCallback, useEffect, useState } from 'react';
55
import MDBBtn from '../Button/Button';
66
import type { PopoverProps } from './types';
7-
import ReactDOM from 'react-dom';
87
import { usePopper } from 'react-popper';
98
import { useOpenStatus } from '../../../utils/hooks';
9+
import Portal from '../../../../src/utils/Portal';
1010

1111
const MDBPopover: React.FC<PopoverProps> = ({
1212
className,
@@ -23,6 +23,7 @@ const MDBPopover: React.FC<PopoverProps> = ({
2323
options,
2424
poperStyle,
2525
onClick,
26+
disablePortal = false,
2627
...props
2728
}): JSX.Element => {
2829
const [referenceElement, setReferenceElement] = useState<HTMLElement>();
@@ -92,18 +93,18 @@ const MDBPopover: React.FC<PopoverProps> = ({
9293
{btnChildren}
9394
</Tag>
9495

95-
{(attachELements || isOpen) &&
96-
ReactDOM.createPortal(
96+
{(attachELements || isOpen) && (
97+
<Portal disablePortal={disablePortal}>
9798
<PopperTag
9899
className={classes}
99100
ref={setPopperElement}
100101
style={{ ...styles.popper, ...poperStyle }}
101102
{...attributes.popper}
102103
>
103104
{children}
104-
</PopperTag>,
105-
document.body
106-
)}
105+
</PopperTag>
106+
</Portal>
107+
)}
107108
</>
108109
);
109110
};

app/src/free/components/Popover/types.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface PopoverProps extends ButtonProps {
1111
poperStyle?: React.CSSProperties;
1212
popperTag?: React.ComponentProps<any>;
1313
tag?: React.ComponentProps<any>;
14+
disablePortal?: boolean;
1415
onOpen?: () => void;
1516
onClose?: () => void;
1617
}

app/src/free/components/Tooltip/Tooltip.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use client';
22

33
import React, { useState, useEffect, useCallback, SyntheticEvent } from 'react';
4-
import ReactDOM from 'react-dom';
54
import clsx from 'clsx';
65
import { usePopper } from 'react-popper';
76
import type { TooltipProps } from './types';
87
import MDBBtn from '../Button/Button';
8+
import Portal from '../../../utils/Portal';
99

1010
const MDBTooltip: React.FC<TooltipProps> = ({
1111
className,
@@ -22,6 +22,7 @@ const MDBTooltip: React.FC<TooltipProps> = ({
2222
onClose,
2323
onMouseEnter,
2424
onMouseLeave,
25+
type,
2526
...props
2627
}) => {
2728
const [referenceElement, setReferenceElement] = useState(null);
@@ -91,7 +92,6 @@ const MDBTooltip: React.FC<TooltipProps> = ({
9192
};
9293
}
9394
}, [handleClick, disableMouseDown]);
94-
9595
return (
9696
<>
9797
<Tag
@@ -100,12 +100,13 @@ const MDBTooltip: React.FC<TooltipProps> = ({
100100
onMouseLeave={handleOnMouseLeave}
101101
ref={setReferenceElement}
102102
{...wrapperProps}
103+
type={type}
103104
>
104105
{children}
105106
</Tag>
106107

107-
{isReadyToHide &&
108-
ReactDOM.createPortal(
108+
{isReadyToHide && (
109+
<Portal>
109110
<TooltipTag
110111
ref={setPopperElement}
111112
className={classes}
@@ -115,9 +116,9 @@ const MDBTooltip: React.FC<TooltipProps> = ({
115116
{...props}
116117
>
117118
<div className='tooltip-inner'>{title}</div>
118-
</TooltipTag>,
119-
document.body
120-
)}
119+
</TooltipTag>
120+
</Portal>
121+
)}
121122
</>
122123
);
123124
};

app/src/utils/Portal.tsx

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React, { useState, useEffect, RefObject } from 'react';
2+
import { createPortal } from 'react-dom';
3+
4+
type PortalTypes = {
5+
children: React.ReactNode;
6+
/**
7+
* The reference to the container element where the elements will be rendered. If not specified the element will be rendered in the document body.
8+
* */
9+
containerRef?: RefObject<HTMLElement>;
10+
/**
11+
* When `true` children will be rendered in normal DOM hierarchy.
12+
* @default false
13+
* */
14+
disablePortal?: boolean;
15+
};
16+
17+
/**
18+
* Renders elements outside the component's normal DOM hierarchy.
19+
*/
20+
const Portal = ({ children, containerRef, disablePortal }: PortalTypes) => {
21+
const [mounted, setMounted] = useState(false);
22+
23+
useEffect(() => {
24+
!disablePortal && setMounted(true);
25+
}, [disablePortal]);
26+
27+
if (disablePortal) {
28+
return <>{children}</>;
29+
}
30+
31+
return mounted ? createPortal(<>{children}</>, containerRef?.current || document.body) : null;
32+
};
33+
34+
export default Portal;

app/src/utils/hooks.tsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@ import { useEffect, useState, useMemo, RefObject } from 'react';
22

33
const useOnScreen = (ref: RefObject<HTMLElement>) => {
44
const [isIntersecting, setIntersecting] = useState(false);
5+
const [observer, setObserver] = useState<any>(null);
56

67
// prettier-ignore
7-
const observer = useMemo(() => new IntersectionObserver(([entry]) => {
8-
setIntersecting(entry.isIntersecting)
9-
}), []);
8+
// const observer = useMemo(() => {
9+
// return new IntersectionObserver(([entry]) => {
10+
// setIntersecting(entry.isIntersecting)
11+
// });
12+
// }, []);
1013

1114
useEffect(() => {
12-
if (!ref.current) return;
15+
setObserver(() => {
16+
return new IntersectionObserver(([entry]) => {
17+
setIntersecting(entry.isIntersecting);
18+
});
19+
});
20+
}, []);
21+
22+
useEffect(() => {
23+
if (!ref.current || !observer) return;
1324
observer.observe(ref.current);
1425
return () => observer.disconnect();
1526
}, [observer, ref]);

dist/mdb-react-ui-kit.cjs

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)