-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
885 additions
and
807 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MDB 5 React | ||
|
||
Version: FREE 7.0.0 | ||
Version: FREE 7.1.0 | ||
|
||
Documentation: | ||
https://mdbootstrap.com/docs/b5/react/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import clsx from 'clsx'; | ||
import React from 'react'; | ||
import React, { useRef, forwardRef, useImperativeHandle } from 'react'; | ||
import type { FileProps } from './types'; | ||
|
||
const MDBFile: React.FC<FileProps> = ({ className, labelClass, labelStyle, inputRef, size, label, id, ...props }) => { | ||
const inputClasses = clsx('form-control', `form-control-${size}`, className); | ||
const labelClasses = clsx('form-label', labelClass); | ||
const MDBFile: React.FC<FileProps> = forwardRef<HTMLInputElement, FileProps>( | ||
({ className, labelClass, labelStyle, inputRef: inputRefProp, size, label, id, ...props }, ref) => { | ||
const inputClasses = clsx('form-control', `form-control-${size}`, className); | ||
const labelClasses = clsx('form-label', labelClass); | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
return ( | ||
<> | ||
{label && ( | ||
<label className={labelClasses} style={labelStyle} htmlFor={id}> | ||
{label} | ||
</label> | ||
)} | ||
<input className={inputClasses} type='file' id={id} ref={inputRef} {...props} /> | ||
</> | ||
); | ||
}; | ||
useImperativeHandle(ref, () => inputRef.current || inputRefProp?.current); | ||
|
||
return ( | ||
<> | ||
{label && ( | ||
<label className={labelClasses} style={labelStyle} htmlFor={id}> | ||
{label} | ||
</label> | ||
)} | ||
<input className={inputClasses} type='file' id={id} ref={inputRef} {...props} /> | ||
</> | ||
); | ||
} | ||
); | ||
|
||
MDBFile.displayName = 'MDBFile'; | ||
export default MDBFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,74 @@ | ||
import clsx from 'clsx'; | ||
import React from 'react'; | ||
import React, { forwardRef } from 'react'; | ||
import type { InputTemplateProps } from './types'; | ||
|
||
const InputTemplate: React.FC<InputTemplateProps> = ({ | ||
className, | ||
inputRef, | ||
labelClass, | ||
wrapperClass, | ||
labelStyle, | ||
wrapperTag: WrapperTag = 'div', | ||
wrapperStyle, | ||
label, | ||
inline, | ||
btn, | ||
id, | ||
btnColor, | ||
disableWrapper, | ||
toggleSwitch, | ||
...props | ||
}) => { | ||
let inputStyle = 'form-check-input'; | ||
let labelClassName = 'form-check-label'; | ||
const InputTemplate: React.FC<InputTemplateProps> = forwardRef( | ||
( | ||
{ | ||
className, | ||
inputRef, | ||
labelClass, | ||
wrapperClass, | ||
labelStyle, | ||
wrapperTag: WrapperTag = 'div', | ||
wrapperStyle, | ||
label, | ||
inline, | ||
btn, | ||
id, | ||
btnColor, | ||
disableWrapper, | ||
toggleSwitch, | ||
...props | ||
}, | ||
ref | ||
) => { | ||
let inputStyle = 'form-check-input'; | ||
let labelClassName = 'form-check-label'; | ||
|
||
if (btn) { | ||
inputStyle = 'btn-check'; | ||
if (btn) { | ||
inputStyle = 'btn-check'; | ||
|
||
if (btnColor) { | ||
labelClassName = `btn btn-${btnColor}`; | ||
} else { | ||
labelClassName = 'btn btn-primary'; | ||
if (btnColor) { | ||
labelClassName = `btn btn-${btnColor}`; | ||
} else { | ||
labelClassName = 'btn btn-primary'; | ||
} | ||
} | ||
} | ||
|
||
const wrapperClasses = clsx( | ||
label && !btn && 'form-check', | ||
inline && !btn && 'form-check-inline', | ||
toggleSwitch && 'form-switch', | ||
wrapperClass | ||
); | ||
const inputClasses = clsx(inputStyle, className); | ||
const labelClasses = clsx(labelClassName, labelClass); | ||
const wrapperClasses = clsx( | ||
label && !btn && 'form-check', | ||
inline && !btn && 'form-check-inline', | ||
toggleSwitch && 'form-switch', | ||
wrapperClass | ||
); | ||
const inputClasses = clsx(inputStyle, className); | ||
const labelClasses = clsx(labelClassName, labelClass); | ||
|
||
const inputBody = ( | ||
<> | ||
<input className={inputClasses} id={id} ref={inputRef} {...props} /> | ||
{label && ( | ||
<label className={labelClasses} style={labelStyle} htmlFor={id}> | ||
{label} | ||
</label> | ||
)} | ||
</> | ||
); | ||
const inputBody = ( | ||
<> | ||
<input className={inputClasses} id={id} ref={inputRef} {...props} /> | ||
{label && ( | ||
<label className={labelClasses} style={labelStyle} htmlFor={id}> | ||
{label} | ||
</label> | ||
)} | ||
</> | ||
); | ||
|
||
return ( | ||
<> | ||
{disableWrapper ? ( | ||
inputBody | ||
) : ( | ||
<WrapperTag style={wrapperStyle} className={wrapperClasses}> | ||
{inputBody} | ||
</WrapperTag> | ||
)} | ||
</> | ||
); | ||
}; | ||
return ( | ||
<> | ||
{disableWrapper ? ( | ||
inputBody | ||
) : ( | ||
<WrapperTag style={wrapperStyle} className={wrapperClasses} ref={ref}> | ||
{inputBody} | ||
</WrapperTag> | ||
)} | ||
</> | ||
); | ||
} | ||
); | ||
|
||
InputTemplate.displayName = 'InputTemplate'; | ||
export default InputTemplate; |
Oops, something went wrong.