Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
topBarCurrentPathLabel?: string;
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 = (// Pass tab components
tabControls: 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 = (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}