Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
topBarPreviousPathLabel?: Label;
// Header Props
subtitle?: string | React.ReactElement;
isPrimaryButtonDisabled?: boolean;
dataAttributesPrimaryButton?: { [key: string]: string };
dataAttributesSecondaryButton?: { [key: string]: string };
};
type Props = CommonProps & WithCustomControls & WithoutCustomControls;
type PropsWithCustomControls = CommonProps & Required;
type PropsWithoutCustomControls = CommonProps & Required;
const defaultProps: Pick<
Props,
'labelPrimaryButton' | 'labelSecondaryButton'
> = {
labelPrimaryButton: sharedMessages.confirm,
labelSecondaryButton: sharedMessages.cancel,
};
// Type-guard validation for the correct props, based on the existence `customControls`
const hasCustomControls = (
props: PropsWithCustomControls | PropsWithoutCustomControls
): props is PropsWithCustomControls =>
'customControls' in props && props.customControls !== undefined;
const getConditionalProps = (props: Props) => {
if ('customControls' in props && props.customControls !== undefined) {
return props as PropsWithCustomControls;
}
return props as PropsWithoutCustomControls;
};
const FormModalPageHeaderControls = (
props: PropsWithCustomControls | PropsWithoutCustomControlstabControls: React.ReactNode;
// Header Props
subtitle?: string | React.ReactElement;
isPrimaryButtonDisabled?: boolean;
dataAttributesPrimaryButton?: { [key: string]: string };
dataAttributesSecondaryButton?: { [key: string]: string };
};
type Props = CommonProps & WithCustomControls & WithoutCustomControls;
type PropsWithCustomControls = CommonProps & Required;
type PropsWithoutCustomControls = CommonProps & Required;
const defaultProps: Pick<
Props,
'labelPrimaryButton' | 'labelSecondaryButton'
> = {
labelPrimaryButton: sharedMessages.confirm,
labelSecondaryButton: sharedMessages.cancel,
};
// Type-guard validation for the correct props, based on the existence `customControls`
const hasCustomControls = (
props: PropsWithCustomControls | PropsWithoutCustomControls
): props is PropsWithCustomControls =>
'customControls' in props && props.customControls !== undefined;
const getConditionalProps = (props: Props) => {
if ('customControls' in props && props.customControls !== undefined) {
return props as PropsWithCustomControls;
}
return props as PropsWithoutCustomControls;
};
const TabularModalPageHeaderControls = (
props: PropsWithCustomControls | PropsWithoutCustomControlsonClose?: (event: React.SyntheticEvent) => void;
title: string;
size?: 'm' | 'l' | 'scale';
zIndex?: number;
children: React.ReactNode;
labelSecondary: Label;
labelPrimary: Label;
isPrimaryButtonDisabled?: boolean;
onSecondaryButtonClick: (event: React.SyntheticEvent) => void;
onPrimaryButtonClick: (event: React.SyntheticEvent) => void;
dataAttributesSecondaryButton?: { [key: string]: string };
dataAttributesPrimaryButton?: { [key: string]: string };
getParentSelector?: () => HTMLElement;
};
const defaultProps: Pick = {
labelSecondary: sharedMessages.cancel,
labelPrimary: sharedMessages.save,
};
const FormDialog = (props: Props) => (
{props.children}onClose?: (event: React.SyntheticEvent) => void;
title: string;
size?: 'm' | 'l' | 'scale';
zIndex?: number;
children: React.ReactNode;
labelSecondary: Label;
labelPrimary: Label;
isPrimaryButtonDisabled?: boolean;
onCancel: (event: React.SyntheticEvent) => void;
onConfirm: (event: React.SyntheticEvent) => void;
dataAttributesSecondaryButton?: { [key: string]: string };
dataAttributesPrimaryButton?: { [key: string]: string };
getParentSelector?: () => HTMLElement;
};
const defaultProps: Pick = {
labelSecondary: sharedMessages.cancel,
labelPrimary: sharedMessages.confirm,
};
const ConfirmationDialog = (props: Props) => (
{props.children}