From ca22a7f37be816881a21cd0124d08b0bb17a8fcc Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Fri, 8 Dec 2023 19:41:06 +0100 Subject: [PATCH] Fix buttons prop types issues in automation [MAILPOPET-5714] --- .../mailpoet/components/button.tsx | 18 ++++++++++++++++-- .../templates/components/from-scratch.tsx | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mailpoet/assets/js/src/automation/integrations/mailpoet/components/button.tsx b/mailpoet/assets/js/src/automation/integrations/mailpoet/components/button.tsx index a5eb8a4b03..770f2327dd 100644 --- a/mailpoet/assets/js/src/automation/integrations/mailpoet/components/button.tsx +++ b/mailpoet/assets/js/src/automation/integrations/mailpoet/components/button.tsx @@ -1,13 +1,27 @@ import classnames from 'classnames'; import { Button as WpButton } from '@wordpress/components'; -import { ButtonAsAnchorProps } from '@wordpress/components/build-types/button/types'; +import { + ButtonAsAnchorProps, + ButtonAsButtonProps, +} from '@wordpress/components/src/button/types'; +import { WordPressComponentProps } from '@wordpress/components/build-types/ui/context'; type ExtendedProps = { variant: ButtonAsAnchorProps['variant'] | 'sidebar-primary'; centered?: boolean; }; -type Props = Omit & ExtendedProps; +type Props = + | WordPressComponentProps< + Omit & ExtendedProps, + 'button', + false + > + | WordPressComponentProps< + Omit & ExtendedProps, + 'a', + false + >; export function Button({ centered, variant, ...props }: Props): JSX.Element { return ( diff --git a/mailpoet/assets/js/src/automation/templates/components/from-scratch.tsx b/mailpoet/assets/js/src/automation/templates/components/from-scratch.tsx index 4d02ce9e5c..3bf1469cb8 100644 --- a/mailpoet/assets/js/src/automation/templates/components/from-scratch.tsx +++ b/mailpoet/assets/js/src/automation/templates/components/from-scratch.tsx @@ -2,6 +2,7 @@ import { Dispatch, useCallback, useState } from 'react'; import { __ } from '@wordpress/i18n'; import { Button } from '@wordpress/components'; import { Hooks } from 'wp-js-hooks'; +import { ButtonProps } from '@wordpress/components/build-types/button/types'; import { PremiumModal } from '../../../common/premium-modal'; import { Notice } from '../../../notices/notice'; import { FromScratchHookType } from '../../types/filters'; @@ -42,7 +43,7 @@ function fromScratchHook(callback: () => void, errorHandler: Dispatch) { } type FromScratchButtonProps = { - variant?: Button.Props['variant']; + variant?: ButtonProps['variant']; }; export function FromScratchButton({