Skip to content

Commit

Permalink
release: 6.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mako3577 committed Aug 7, 2023
1 parent da743a6 commit 173315a
Show file tree
Hide file tree
Showing 72 changed files with 1,485 additions and 1,595 deletions.
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MDB 5 React

Version: FREE 6.1.0
Version: FREE 6.2.0

Documentation:
https://mdbootstrap.com/docs/b5/react/
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mdb-react-ui-kit-demo",
"version": "6.1.0",
"version": "6.2.0",
"main": "index.js",
"repository": {
"type": "git",
Expand Down
7 changes: 4 additions & 3 deletions app/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import type { AccordionProps } from './types';
import { AccordionContext } from './AccordionContext';

const MDBAccordion: React.FC<AccordionProps> = React.forwardRef<HTMLAllCollection, AccordionProps>(
({ alwaysOpen, borderless, className, flush, initialActive, tag: Tag, children, onChange, ...props }, ref) => {
(
{ alwaysOpen, borderless, className, flush, initialActive = 0, tag: Tag = 'div', children, onChange, ...props },
ref
) => {
const classes = clsx('accordion', flush && 'accordion-flush', borderless && 'accordion-borderless', className);

const [activeItem, setActiveItem] = useState(initialActive);
Expand All @@ -25,6 +28,4 @@ const MDBAccordion: React.FC<AccordionProps> = React.forwardRef<HTMLAllCollectio
}
);

MDBAccordion.defaultProps = { tag: 'div', initialActive: 0 };

export default MDBAccordion;
4 changes: 1 addition & 3 deletions app/src/components/Accordion/AccordionItem/AccordionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const MDBAccordionItem: React.FC<AccordionItemProps> = React.forwardRef<HTMLAllC
headerTitle,
headerStyle,
btnClassName,
tag: Tag,
tag: Tag = 'div',
children,
...props
},
Expand Down Expand Up @@ -62,6 +62,4 @@ const MDBAccordionItem: React.FC<AccordionItemProps> = React.forwardRef<HTMLAllC
}
);

MDBAccordionItem.defaultProps = { tag: 'div' };

export default MDBAccordionItem;
4 changes: 1 addition & 3 deletions app/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import type { BadgeProps } from './types';

const MDBBadge: React.FC<BadgeProps> = React.forwardRef<HTMLAllCollection, BadgeProps>(
({ className, color, pill, light, dot, tag: Tag, children, notification, ...props }, ref) => {
({ className, color = 'primary', pill, light, dot, tag: Tag = 'span', children, notification, ...props }, ref) => {
const classes = clsx(
'badge',
light ? color && `badge-${color}` : color && `bg-${color}`,
Expand All @@ -21,6 +21,4 @@ const MDBBadge: React.FC<BadgeProps> = React.forwardRef<HTMLAllCollection, Badge
}
);

MDBBadge.defaultProps = { tag: 'span', color: 'primary' };

export default MDBBadge;
9 changes: 5 additions & 4 deletions app/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
(
{
className,
color,
color = 'primary',
outline,
children,
rounded,
Expand All @@ -19,7 +19,8 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
active,
toggle,
noRipple,
tag: Tag,
tag: Tag = 'button',
role = 'button',
...props
},
ref
Expand Down Expand Up @@ -74,6 +75,7 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
disabled={disabled && Tag === 'button' ? true : undefined}
href={href}
ref={ref}
role={role}
{...props}
>
{children}
Expand All @@ -93,6 +95,7 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
disabled={disabled && Tag === 'button' ? true : undefined}
href={href}
ref={ref}
role={role}
{...props}
>
{children}
Expand All @@ -101,6 +104,4 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
}
);

MDBBtn.defaultProps = { tag: 'button', role: 'button', color: 'primary' };

export default MDBBtn;
6 changes: 2 additions & 4 deletions app/src/components/ButtonGroup/ButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { ButtonGroupProps } from './types';

const MDBBtnGroup: React.FC<ButtonGroupProps> = React.forwardRef<HTMLAllCollection, ButtonGroupProps>(
({ className, children, shadow, toolbar, size, vertical, tag: Tag, ...props }, ref) => {
({ className, children, shadow, toolbar, size, vertical, tag: Tag = 'div', role = 'group', ...props }, ref) => {
let type;

if (toolbar) {
Expand All @@ -16,13 +16,11 @@ const MDBBtnGroup: React.FC<ButtonGroupProps> = React.forwardRef<HTMLAllCollecti
const classes = clsx(type, shadow && `shadow-${shadow}`, size && `btn-group-${size}`, className);

return (
<Tag className={classes} ref={ref} {...props}>
<Tag className={classes} ref={ref} role={role} {...props}>
{children}
</Tag>
);
}
);

MDBBtnGroup.defaultProps = { tag: 'div', role: 'group' };

export default MDBBtnGroup;
4 changes: 1 addition & 3 deletions app/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardProps } from './types';

const MDBCard: React.FC<CardProps> = React.forwardRef<HTMLAllCollection, CardProps>(
({ className, children, border, background, tag: Tag, shadow, alignment, ...props }, ref) => {
({ className, children, border, background, tag: Tag = 'div', shadow, alignment, ...props }, ref) => {
const classes = clsx(
'card',
border && `border border-${border}`,
Expand All @@ -21,6 +21,4 @@ const MDBCard: React.FC<CardProps> = React.forwardRef<HTMLAllCollection, CardPro
}
);

MDBCard.defaultProps = { tag: 'div' };

export default MDBCard;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardBody/CardBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardBodyProps } from './types';

const MDBCardBody: React.FC<CardBodyProps> = React.forwardRef<HTMLAllCollection, CardBodyProps>(
({ className, children, tag: Tag, ...props }, ref) => {
({ className, children, tag: Tag = 'div', ...props }, ref) => {
const classes = clsx('card-body', className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardBody: React.FC<CardBodyProps> = React.forwardRef<HTMLAllCollection,
}
);

MDBCardBody.defaultProps = { tag: 'div' };

export default MDBCardBody;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardFooter/CardFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardFooterProps } from './types';

const MDBCardFooter: React.FC<CardFooterProps> = React.forwardRef<HTMLAllCollection, CardFooterProps>(
({ className, children, border, background, tag: Tag, ...props }, ref) => {
({ className, children, border, background, tag: Tag = 'div', ...props }, ref) => {
const classes = clsx('card-footer', border && `border-${border}`, background && `bg-${background}`, className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardFooter: React.FC<CardFooterProps> = React.forwardRef<HTMLAllCollect
}
);

MDBCardFooter.defaultProps = { tag: 'div' };

export default MDBCardFooter;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardGroup/CardGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardGroupProps } from './types';

const MDBCardGroup: React.FC<CardGroupProps> = React.forwardRef<HTMLAllCollection, CardGroupProps>(
({ className, children, tag: Tag, ...props }, ref) => {
({ className, children, tag: Tag = 'div', ...props }, ref) => {
const classes = clsx('card-group', className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardGroup: React.FC<CardGroupProps> = React.forwardRef<HTMLAllCollectio
}
);

MDBCardGroup.defaultProps = { tag: 'div' };

export default MDBCardGroup;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardHeader/CardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardHeaderProps } from './types';

const MDBCardHeader: React.FC<CardHeaderProps> = React.forwardRef<HTMLAllCollection, CardHeaderProps>(
({ className, children, border, background, tag: Tag, ...props }, ref) => {
({ className, children, border, background, tag: Tag = 'div', ...props }, ref) => {
const classes = clsx('card-header', border && `border-${border}`, background && `bg-${background}`, className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardHeader: React.FC<CardHeaderProps> = React.forwardRef<HTMLAllCollect
}
);

MDBCardHeader.defaultProps = { tag: 'div' };

export default MDBCardHeader;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardOverlay/CardOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardOverlayProps } from './types';

const MDBCardOverlay: React.FC<CardOverlayProps> = React.forwardRef<HTMLAllCollection, CardOverlayProps>(
({ className, children, tag: Tag, ...props }, ref) => {
({ className, children, tag: Tag = 'div', ...props }, ref) => {
const classes = clsx('card-img-overlay', className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardOverlay: React.FC<CardOverlayProps> = React.forwardRef<HTMLAllColle
}
);

MDBCardOverlay.defaultProps = { tag: 'div' };

export default MDBCardOverlay;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardSubTitle/CardSubTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardSubTitleProps } from './types';

const MDBCardSubTitle: React.FC<CardSubTitleProps> = React.forwardRef<HTMLAllCollection, CardSubTitleProps>(
({ className, children, tag: Tag, ...props }, ref) => {
({ className, children, tag: Tag = 'p', ...props }, ref) => {
const classes = clsx('card-subtitle', className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardSubTitle: React.FC<CardSubTitleProps> = React.forwardRef<HTMLAllCol
}
);

MDBCardSubTitle.defaultProps = { tag: 'p' };

export default MDBCardSubTitle;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardText/CardText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardTextProps } from './types';

const MDBCardText: React.FC<CardTextProps> = React.forwardRef<HTMLAllCollection, CardTextProps>(
({ className, children, tag: Tag, ...props }, ref) => {
({ className, children, tag: Tag = 'p', ...props }, ref) => {
const classes = clsx('card-text', className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardText: React.FC<CardTextProps> = React.forwardRef<HTMLAllCollection,
}
);

MDBCardText.defaultProps = { tag: 'p' };

export default MDBCardText;
4 changes: 1 addition & 3 deletions app/src/components/Card/CardTitle/CardTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import type { CardTitleProps } from './types';

const MDBCardTitle: React.FC<CardTitleProps> = React.forwardRef<HTMLAllCollection, CardTitleProps>(
({ className, children, tag: Tag, ...props }, ref) => {
({ className, children, tag: Tag = 'h5', ...props }, ref) => {
const classes = clsx('card-title', className);

return (
Expand All @@ -14,6 +14,4 @@ const MDBCardTitle: React.FC<CardTitleProps> = React.forwardRef<HTMLAllCollectio
}
);

MDBCardTitle.defaultProps = { tag: 'h5' };

export default MDBCardTitle;
48 changes: 27 additions & 21 deletions app/src/components/Carousel/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import React, { ReactElement, useCallback, useEffect, useRef, useState } from 'react';
import type { CarouselProps } from './types';

import CarouselIndicators from './CarouselIndicators/CarouselIndicators';
Expand All @@ -8,13 +8,14 @@ import { CarouselContext } from './utils/CarouselContext';
import { getCarouselItems, isVisible, queueCallback, reflow } from './utils/utils';

const MDBCarousel: React.FC<CarouselProps> = ({
fade,
fade = false,
className,
carouselInnerClassName,
dark,
children,
interval,
keyboard,
touch,
interval = 5000,
keyboard = false,
touch = true,
showControls,
showIndicators,
onSlide,
Expand All @@ -34,14 +35,7 @@ const MDBCarousel: React.FC<CarouselProps> = ({
const carouselRef = useRef<HTMLDivElement>(null);

const classes = clsx('carousel', 'slide', fade && 'carousel-fade', dark && 'carousel-dark', className);

const pauseInterval = () => {
if (carouselInterval.current) {
clearInterval(carouselInterval.current);

carouselInterval.current = null;
}
};
const carouselInnerClasses = clsx('carousel-inner', carouselInnerClassName);

const setElementActive = useCallback(
(direction: string, newIndex?: number) => {
Expand All @@ -59,8 +53,17 @@ const MDBCarousel: React.FC<CarouselProps> = ({
[active, itemsLength]
);

const pauseInterval = useCallback(() => {
if (carouselInterval.current) {
clearInterval(carouselInterval.current);

carouselInterval.current = null;
}
}, []);

const slide = useCallback(
(direction: string, nextElement: HTMLDivElement, index?: number) => {
if (!items.current || items.current.length < 2) return;
setIsTransitioning(true);
const carouselElements = items.current as HTMLDivElement[];
const activeElement = carouselElements[active];
Expand Down Expand Up @@ -114,7 +117,7 @@ const MDBCarousel: React.FC<CarouselProps> = ({
}
},

[carouselRef, active, setElementActive]
[carouselRef, active, setElementActive, pauseInterval]
);

const block = (timer: number) => {
Expand Down Expand Up @@ -194,14 +197,15 @@ const MDBCarousel: React.FC<CarouselProps> = ({
}, [carouselRef, changeStep]);

const startInterval = useCallback(() => {
const individualInterval = (children as ReactElement[])?.[active]?.props?.interval;
if (carouselInterval.current) {
clearInterval(carouselInterval.current);

carouselInterval.current = null;
}

carouselInterval.current = setInterval(changeNext, interval);
}, [changeNext, interval]);
carouselInterval.current = setInterval(changeNext, individualInterval || interval);
}, [changeNext, interval, children, active]);

const startTouch = (e: React.TouchEvent<HTMLDivElement>) => {
if (!touch) return;
Expand Down Expand Up @@ -277,12 +281,16 @@ const MDBCarousel: React.FC<CarouselProps> = ({
}, [carouselRef]);

useEffect(() => {
onSlide?.();
isTransitioning && onSlide?.();
}, [isTransitioning, onSlide]);

useEffect(() => {
startInterval();
}, [startInterval]);

return () => {
pauseInterval();
};
}, [startInterval, pauseInterval]);

return (
<div
Expand All @@ -295,7 +303,7 @@ const MDBCarousel: React.FC<CarouselProps> = ({
ref={carouselRef}
{...props}
>
<div className='carousel-inner'>
<div className={carouselInnerClasses}>
<CarouselContext.Provider value={{ active }}>
{showIndicators && <CarouselIndicators to={changeTo} imagesCount={itemsLength} />}
{children}
Expand All @@ -306,6 +314,4 @@ const MDBCarousel: React.FC<CarouselProps> = ({
);
};

MDBCarousel.defaultProps = { fade: false, interval: 5000, touch: true, keyboard: false };

export default MDBCarousel;
Loading

0 comments on commit 173315a

Please sign in to comment.