From 4586726470bfe8e49b033369d759a014d098cd3c Mon Sep 17 00:00:00 2001 From: kaminderpal Date: Wed, 17 Jul 2024 16:40:57 -0400 Subject: [PATCH] fix(UI): pass rest props to underline material ui components closes364 --- .../geoview-core/src/ui/card-media/card-media.tsx | 4 ++-- .../src/ui/circular-progress/circular-progress.tsx | 4 ++-- packages/geoview-core/src/ui/divider/divider.tsx | 3 ++- packages/geoview-core/src/ui/drawer/drawer.tsx | 3 ++- packages/geoview-core/src/ui/fade/fade.tsx | 8 ++++++-- .../geoview-core/src/ui/icon-button/icon-button.tsx | 2 ++ .../src/ui/linear-progress/linear-progress.tsx | 4 ++-- packages/geoview-core/src/ui/list/collapse.tsx | 11 +++++++++-- packages/geoview-core/src/ui/list/list-item-icon.tsx | 4 ++-- packages/geoview-core/src/ui/list/list.tsx | 3 ++- packages/geoview-core/src/ui/panel/panel.tsx | 3 ++- packages/geoview-core/src/ui/slider/slider.tsx | 1 + packages/geoview-core/src/ui/snackbar/snackbar.tsx | 3 ++- .../geoview-core/src/ui/stepper/custom-stepper.tsx | 2 ++ .../geoview-core/src/ui/text-field/text-field.tsx | 4 ++-- 15 files changed, 40 insertions(+), 19 deletions(-) diff --git a/packages/geoview-core/src/ui/card-media/card-media.tsx b/packages/geoview-core/src/ui/card-media/card-media.tsx index 9d407214286..957806738d1 100644 --- a/packages/geoview-core/src/ui/card-media/card-media.tsx +++ b/packages/geoview-core/src/ui/card-media/card-media.tsx @@ -18,7 +18,7 @@ interface TypeCardMediaProps extends CardMediaProps { * @returns {JSX.Element} the created Card Media element */ export function CardMedia(props: TypeCardMediaProps): JSX.Element { - const { sx, src, alt, click, keyDown } = props; + const { sx, src, alt, click, keyDown, ...rest } = props; - return ; + return ; } diff --git a/packages/geoview-core/src/ui/circular-progress/circular-progress.tsx b/packages/geoview-core/src/ui/circular-progress/circular-progress.tsx index 9b0972ac0c6..ec24154f0b5 100644 --- a/packages/geoview-core/src/ui/circular-progress/circular-progress.tsx +++ b/packages/geoview-core/src/ui/circular-progress/circular-progress.tsx @@ -22,14 +22,14 @@ interface TypeCircularProgressProps extends CircularProgressProps { * @returns {JSX.Element} the created Circular Progress element */ export function CircularProgress(props: TypeCircularProgressProps): JSX.Element { - const { style = {}, isLoaded, sx = {} } = props; + const { style = {}, isLoaded, sx = {}, ...rest } = props; const theme = useTheme(); const sxClasses = getSxClasses(theme); return !isLoaded ? ( - + ) : ( // eslint-disable-next-line react/jsx-no-useless-fragment diff --git a/packages/geoview-core/src/ui/divider/divider.tsx b/packages/geoview-core/src/ui/divider/divider.tsx index fc29ccf4171..fbcd358b0f8 100644 --- a/packages/geoview-core/src/ui/divider/divider.tsx +++ b/packages/geoview-core/src/ui/divider/divider.tsx @@ -19,7 +19,7 @@ interface TypeDividerProps extends DividerProps { * @returns {JSX.Element} the created Divider element */ export function Divider(props: TypeDividerProps): JSX.Element { - const { className, style, grow, orientation, sx } = props; + const { className, style, grow, orientation, sx, ...rest } = props; const theme = useTheme(); const sxClasses = getSxClasses(theme); @@ -35,6 +35,7 @@ export function Divider(props: TypeDividerProps): JSX.Element { sx={{ ...(grow ? sxClasses.grow : {}), ...dividerOrientation, ...sx }} className={`${className ?? ''}`} style={style} + {...rest} /> ); } diff --git a/packages/geoview-core/src/ui/drawer/drawer.tsx b/packages/geoview-core/src/ui/drawer/drawer.tsx index 1fae8bc7fb2..b711c554ad9 100644 --- a/packages/geoview-core/src/ui/drawer/drawer.tsx +++ b/packages/geoview-core/src/ui/drawer/drawer.tsx @@ -23,7 +23,7 @@ export interface TypeDrawerProps extends DrawerProps { * @returns {JSX.Element} the created Drawer element */ export function Drawer(props: TypeDrawerProps): JSX.Element { - const { variant, status, className, style, children } = props; + const { variant, status, className, style, children, ...rest } = props; const { t } = useTranslation(); @@ -55,6 +55,7 @@ export function Drawer(props: TypeDrawerProps): JSX.Element { paper: className, }} style={style || undefined} + {...rest} > {children && children}; + return ( + + {children && children} + + ); } diff --git a/packages/geoview-core/src/ui/icon-button/icon-button.tsx b/packages/geoview-core/src/ui/icon-button/icon-button.tsx index 6dcbfa7f29b..d353142ecee 100644 --- a/packages/geoview-core/src/ui/icon-button/icon-button.tsx +++ b/packages/geoview-core/src/ui/icon-button/icon-button.tsx @@ -26,6 +26,7 @@ export function IconButton(props: TypeIconButtonProps): JSX.Element { size, disabled, color, + ...rest } = props; const { t } = useTranslation(); @@ -44,6 +45,7 @@ export function IconButton(props: TypeIconButtonProps): JSX.Element { ref={iconRef} disabled={disabled} color={color} + {...rest} > {children && children} diff --git a/packages/geoview-core/src/ui/linear-progress/linear-progress.tsx b/packages/geoview-core/src/ui/linear-progress/linear-progress.tsx index 28df429a0c6..07001a4e485 100644 --- a/packages/geoview-core/src/ui/linear-progress/linear-progress.tsx +++ b/packages/geoview-core/src/ui/linear-progress/linear-progress.tsx @@ -22,8 +22,8 @@ interface ProgressbarProps { * @param {ProgressbarProps} props the properties passed to the element * @returns {JSX.Element} the created element */ -export function ProgressBar({ className = '', variant = 'indeterminate', value = 0 }: ProgressbarProps): JSX.Element { - return ; +export function ProgressBar({ className = '', variant = 'indeterminate', value = 0, ...rest }: ProgressbarProps): JSX.Element { + return ; } /** diff --git a/packages/geoview-core/src/ui/list/collapse.tsx b/packages/geoview-core/src/ui/list/collapse.tsx index d40a26caae2..545eec4d85f 100644 --- a/packages/geoview-core/src/ui/list/collapse.tsx +++ b/packages/geoview-core/src/ui/list/collapse.tsx @@ -7,12 +7,19 @@ import { Collapse as MaterialCollapse, CollapseProps } from '@mui/material'; * @returns {JSX.Element} the created Collapse element */ export function Collapse(props: CollapseProps): JSX.Element { - const { children, className, style, timeout, unmountOnExit } = props; + const { children, className, style, timeout, unmountOnExit, ...rest } = props; // eslint-disable-next-line react/destructuring-assignment const inProp = props.in; return ( - + {children !== undefined && children} ); diff --git a/packages/geoview-core/src/ui/list/list-item-icon.tsx b/packages/geoview-core/src/ui/list/list-item-icon.tsx index 2ba30ff9428..cdc690435ad 100644 --- a/packages/geoview-core/src/ui/list/list-item-icon.tsx +++ b/packages/geoview-core/src/ui/list/list-item-icon.tsx @@ -7,10 +7,10 @@ import { ListItemIcon as MaterialListItemIcon, ListItemIconProps } from '@mui/ma * @returns {JSX.Element} the created List Item element */ export function ListItemIcon(props: ListItemIconProps): JSX.Element { - const { children, className, style } = props; + const { children, className, style, ...rest } = props; return ( - + {children !== undefined && children} ); diff --git a/packages/geoview-core/src/ui/list/list.tsx b/packages/geoview-core/src/ui/list/list.tsx index 2db41b62d71..8973b51a4be 100644 --- a/packages/geoview-core/src/ui/list/list.tsx +++ b/packages/geoview-core/src/ui/list/list.tsx @@ -26,7 +26,7 @@ const sxClasses = { * @returns {JSX.Element} the created List element */ export const List = React.forwardRef((props: TypeListProps, ref): JSX.Element => { - const { children, className, style, type, sx } = props; + const { children, className, style, type, sx, ...rest } = props; return ( ((props: Ty className={className || ''} style={style || undefined} component={type || 'ul'} + {...rest} > {children !== undefined && children} diff --git a/packages/geoview-core/src/ui/panel/panel.tsx b/packages/geoview-core/src/ui/panel/panel.tsx index 3f3ac21dc74..eaf6a2fc301 100644 --- a/packages/geoview-core/src/ui/panel/panel.tsx +++ b/packages/geoview-core/src/ui/panel/panel.tsx @@ -38,7 +38,7 @@ export type TypePanelAppProps = { * @returns {JSX.Element} the created Panel element */ export function Panel(props: TypePanelAppProps): JSX.Element { - const { panel, button, onPanelOpened, onPanelClosed, onGeneralCloseClicked } = props; + const { panel, button, onPanelOpened, onPanelClosed, onGeneralCloseClicked, ...rest } = props; const { status: open = false, panelStyles, panelGroupName } = panel; const { t } = useTranslation(); @@ -132,6 +132,7 @@ export function Panel(props: TypePanelAppProps): JSX.Element { } }} {...{ 'data-id': button.id }} + {...rest} > onClose?.()} + {...rest} > onClose?.()} severity={type} sx={{ width: '100%' }}> {message} diff --git a/packages/geoview-core/src/ui/stepper/custom-stepper.tsx b/packages/geoview-core/src/ui/stepper/custom-stepper.tsx index d1ed974f96d..ac2d505cb36 100644 --- a/packages/geoview-core/src/ui/stepper/custom-stepper.tsx +++ b/packages/geoview-core/src/ui/stepper/custom-stepper.tsx @@ -78,6 +78,7 @@ export function CustomStepper(props: TypeCustomStepperProps): JSX.Element { backButtonText, nextButtonText, resetButtonText, + ...rest } = props; const theme = useTheme(); @@ -198,6 +199,7 @@ export function CustomStepper(props: TypeCustomStepperProps): JSX.Element { // eslint-disable-next-line no-nested-ternary alternativeLabel={stepsOrientation === 'horizontal' ? (alternativeLabel !== undefined ? alternativeLabel : true) : false} nonLinear={nonLinear || buttonedLabels || false} + {...rest} > {steps?.map((step: any, index: number) => { return ( diff --git a/packages/geoview-core/src/ui/text-field/text-field.tsx b/packages/geoview-core/src/ui/text-field/text-field.tsx index 3c440edbbb9..a53326c9308 100644 --- a/packages/geoview-core/src/ui/text-field/text-field.tsx +++ b/packages/geoview-core/src/ui/text-field/text-field.tsx @@ -13,7 +13,7 @@ import { TypeTextFieldProps } from '@/ui/panel/panel-types'; * @returns {JSX.Element} the text field ui component */ export function TextField(props: TypeTextFieldProps): JSX.Element { - const { tooltip, tooltipPlacement } = props; + const { tooltip, tooltipPlacement, ...rest } = props; const { t } = useTranslation(); @@ -22,7 +22,7 @@ export function TextField(props: TypeTextFieldProps): JSX.Element { return ( - + ); }