UNPKG

@appbuckets/react-ui-smart-components

Version:

UI Extended Components that work with @appbuckets/react-client and @appbuckets/react-ui

49 lines (48 loc) 1.75 kB
import * as React from 'react'; import type { ShorthandItem } from '@appbuckets/react-ui-core'; import type { ButtonProps } from '@appbuckets/react-ui/Button'; import type { ModalProps } from '@appbuckets/react-ui/Modal'; import type { ClientRequestError } from '@appbuckets/react-app-client'; import type { BaseActionHelpers, BaseActionBuilderActions, BaseActionBuilderConfig, BaseActionBuilderProps, } from '../BaseActionBuilder.types'; interface BaseUseActionBuilderResult { /** Action Helpers to be passed to Action Handlers */ actionHelpers: BaseActionHelpers; /** Current action error */ actionError: ClientRequestError | undefined; /** Check if an Action button could be rendered */ couldRenderActionButton: ( userDefinedButton?: ShorthandItem<ButtonProps>, defaultDefinedButton?: ShorthandItem<ButtonProps> ) => boolean; /** Handle modal close, changing open state */ handleModalClose: ( e: React.MouseEvent<HTMLElement> | null, modalProps: ModalProps ) => void; /** Handle modal open, changing open state */ handleModalOpen: ( e: React.MouseEvent<HTMLElement> | null, modalProps: ModalProps ) => void; /** Current modal state */ open: boolean; /** Current modal trigger */ trigger: ModalProps['trigger']; } declare type UseActionBuilderResult<Actions extends BaseActionBuilderActions> = BaseUseActionBuilderResult & Actions; export default function useActionBuilder< Content extends React.ComponentType<any>, Actions extends BaseActionBuilderActions, Config extends BaseActionBuilderConfig<Content, Actions, any>, Props extends BaseActionBuilderProps<{}, Actions> >( configuration: Config, userDefinedProps: Props ): UseActionBuilderResult<Actions>; export {};