Skip to content

Commit 52af7f8

Browse files
committed
release: 8.0.0
1 parent 998da36 commit 52af7f8

File tree

88 files changed

+1561
-1343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1561
-1343
lines changed

LICENSE

-21
This file was deleted.

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.2.0
3+
Version: FREE 8.0.0
44

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

app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mdb-react-ui-kit-demo",
3-
"version": "7.2.0",
3+
"version": "8.0.0",
44
"main": "index.js",
55
"repository": {
66
"type": "git",

app/src/free/components/Carousel/CarouselCaption/types.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseComponent } from 'src/types/baseComponent';
1+
import { BaseComponent } from '../../../../types/baseComponent';
22

33
type CarouselCaptionProps = BaseComponent & {
44
className?: string;

app/src/free/components/Carousel/CarouselItem/types.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseComponent } from 'src/types/baseComponent';
1+
import { BaseComponent } from '../../../../types/baseComponent';
22

33
type CarouselItemProps = BaseComponent & {
44
itemId: number;

app/src/free/components/Collapse/Collapse.tsx

+14-22
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import clsx from 'clsx';
44
import React, { useCallback, useEffect, useRef, useState } from 'react';
55
import type { CollapseProps } from './types';
6+
import useHeight from './hooks/useHeight';
67

78
const MDBCollapse: React.FC<CollapseProps> = ({
89
className,
@@ -18,7 +19,7 @@ const MDBCollapse: React.FC<CollapseProps> = ({
1819
...props
1920
}): JSX.Element => {
2021
const [showCollapse, setShowCollapse] = useState<boolean | undefined>(false);
21-
const [collapseHeight, setCollapseHeight] = useState<string | number | undefined>(undefined);
22+
const [collapseHeight, setCollapseHeight] = useState<string | undefined>(undefined);
2223
const [transition, setTransition] = useState(false);
2324

2425
const classes = clsx(
@@ -29,6 +30,7 @@ const MDBCollapse: React.FC<CollapseProps> = ({
2930
);
3031
const collapseEl = useRef<HTMLElement>(null);
3132
const refCollapse = collapseRef ?? collapseEl;
33+
const contentRef = useRef<HTMLDivElement>(null);
3234

3335
const handleResize = useCallback(() => {
3436
if (showCollapse) {
@@ -37,10 +39,14 @@ const MDBCollapse: React.FC<CollapseProps> = ({
3739
}, [showCollapse]);
3840

3941
useEffect(() => {
40-
if (collapseHeight === undefined && showCollapse) {
41-
setCollapseHeight(refCollapse?.current?.scrollHeight);
42-
}
43-
}, [collapseHeight, showCollapse, refCollapse]);
42+
window.addEventListener('resize', handleResize);
43+
44+
return () => {
45+
window.removeEventListener('resize', handleResize);
46+
};
47+
}, [handleResize]);
48+
49+
useHeight({ showCollapse, setCollapseHeight, refCollapse, contentRef });
4450

4551
useEffect(() => {
4652
if (showCollapse !== open) {
@@ -61,25 +67,11 @@ const MDBCollapse: React.FC<CollapseProps> = ({
6167
};
6268
}, [open, showCollapse, onOpen, onClose]);
6369

64-
useEffect(() => {
65-
if (showCollapse) {
66-
setCollapseHeight(refCollapse?.current?.scrollHeight);
67-
} else {
68-
setCollapseHeight(0);
69-
}
70-
}, [showCollapse, refCollapse, children]);
71-
72-
useEffect(() => {
73-
window.addEventListener('resize', handleResize);
74-
75-
return () => {
76-
window.removeEventListener('resize', handleResize);
77-
};
78-
}, [handleResize]);
79-
8070
return (
8171
<Tag style={{ height: collapseHeight, ...style }} id={id} className={classes} {...props} ref={refCollapse}>
82-
{children}
72+
<div ref={contentRef} className='collapse-content'>
73+
{children}
74+
</div>
8375
</Tag>
8476
);
8577
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { useEffect, Dispatch } from 'react';
2+
3+
type useHeightType = {
4+
showCollapse?: boolean;
5+
setCollapseHeight: Dispatch<React.SetStateAction<string | undefined>>;
6+
refCollapse: React.RefObject<HTMLElement>;
7+
contentRef: React.RefObject<HTMLElement>;
8+
};
9+
export default function useHeight({ showCollapse, setCollapseHeight, refCollapse, contentRef }: useHeightType) {
10+
useEffect(() => {
11+
if (!showCollapse) {
12+
setCollapseHeight('0px');
13+
}
14+
// eslint-disable-next-line
15+
}, [showCollapse]);
16+
17+
useEffect(() => {
18+
const collapseEl = refCollapse.current;
19+
const handleResize = (content: ResizeObserverEntry) => {
20+
if (!collapseEl) {
21+
return;
22+
}
23+
24+
const contentHeight = content.contentRect.height;
25+
const computed = window.getComputedStyle(collapseEl);
26+
27+
const offsetY =
28+
parseFloat(computed.paddingTop) +
29+
parseFloat(computed.paddingBottom) +
30+
parseFloat(computed.marginBottom) +
31+
parseFloat(computed.marginTop);
32+
33+
const height = `${contentHeight + offsetY}px`;
34+
35+
setCollapseHeight(height);
36+
};
37+
38+
const observer = new ResizeObserver(([content]) => {
39+
handleResize(content);
40+
});
41+
42+
observer.observe(contentRef.current as Element);
43+
44+
return () => {
45+
observer.disconnect();
46+
};
47+
// eslint-disable-next-line
48+
}, []);
49+
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import React, { MouseEvent } from 'react';
44
import { useDropdownContext } from '../hooks/useDropdownContext';
55
import { ItemChild } from '../ItemChild/ItemChild';
66
import type { DropdownItemProps } from './types';
7-
import './style.css';
87

98
const MDBDropdownItem = ({
109
onClick,

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

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { useDropdownContext } from '../hooks/useDropdownContext';
77
import { useKeyboard } from '../hooks/useKeyboard';
88
import { useFade } from '../hooks/useFade';
99
import type { DropdownMenuProps } from './types';
10-
import './style.css';
1110
import { usePopper } from 'react-popper';
1211
import { flip } from '@popperjs/core';
1312

0 commit comments

Comments
 (0)