fix(ui): bump @invoke-ai/ui, fix TS issues

This commit is contained in:
psychedelicious
2024-01-20 20:03:12 +11:00
parent 580d29257c
commit be72765d02
40 changed files with 313 additions and 292 deletions

View File

@ -28,51 +28,48 @@ type Props = {
children: ReactElement;
};
const IAIInformationalPopover = ({
feature,
children,
inPortal = true,
...rest
}: Props) => {
const shouldEnableInformationalPopovers = useAppSelector(
(s) => s.system.shouldEnableInformationalPopovers
);
export const InformationalPopover = memo(
({ feature, children, inPortal = true, ...rest }: Props) => {
const shouldEnableInformationalPopovers = useAppSelector(
(s) => s.system.shouldEnableInformationalPopovers
);
const data = useMemo(() => POPOVER_DATA[feature], [feature]);
const data = useMemo(() => POPOVER_DATA[feature], [feature]);
const popoverProps = useMemo(
() => merge(omit(data, ['image', 'href', 'buttonLabel']), rest),
[data, rest]
);
const popoverProps = useMemo(
() => merge(omit(data, ['image', 'href', 'buttonLabel']), rest),
[data, rest]
);
if (!shouldEnableInformationalPopovers) {
return children;
}
if (!shouldEnableInformationalPopovers) {
return children;
}
return (
<Popover
isLazy
closeOnBlur={false}
trigger="hover"
variant="informational"
openDelay={OPEN_DELAY}
modifiers={POPPER_MODIFIERS}
placement="top"
{...popoverProps}
>
<PopoverTrigger>{children}</PopoverTrigger>
{inPortal ? (
<Portal>
return (
<Popover
isLazy
closeOnBlur={false}
trigger="hover"
variant="informational"
openDelay={OPEN_DELAY}
modifiers={POPPER_MODIFIERS}
placement="top"
{...popoverProps}
>
<PopoverTrigger>{children}</PopoverTrigger>
{inPortal ? (
<Portal>
<Content data={data} feature={feature} />
</Portal>
) : (
<Content data={data} feature={feature} />
</Portal>
) : (
<Content data={data} feature={feature} />
)}
</Popover>
);
};
)}
</Popover>
);
}
);
export default memo(IAIInformationalPopover);
InformationalPopover.displayName = 'InformationalPopover';
type ContentProps = {
data?: PopoverData;

View File

@ -1,40 +0,0 @@
import { Box, forwardRef, Textarea as ChakraTextarea } from '@invoke-ai/ui';
import { useGlobalModifiersSetters } from 'common/hooks/useGlobalModifiers';
import { stopPastePropagation } from 'common/util/stopPastePropagation';
import type { KeyboardEvent } from 'react';
import { memo, useCallback } from 'react';
import ResizeTextarea from 'react-textarea-autosize';
import type { InvAutosizeTextareaProps } from './types';
export const InvAutosizeTextarea = memo(
forwardRef<InvAutosizeTextareaProps, typeof ResizeTextarea>(
(props: InvAutosizeTextareaProps, ref) => {
const { setShift } = useGlobalModifiersSetters();
const onKeyUpDown = useCallback(
(e: KeyboardEvent<HTMLTextAreaElement>) => {
setShift(e.shiftKey);
},
[setShift]
);
return (
<Box pos="relative">
<ChakraTextarea
as={ResizeTextarea}
ref={ref}
overflow="scroll"
w="100%"
minRows={3}
minH={20}
onPaste={stopPastePropagation}
onKeyUp={onKeyUpDown}
onKeyDown={onKeyUpDown}
{...props}
/>
</Box>
);
}
)
);
InvAutosizeTextarea.displayName = 'InvAutosizeTextarea';

View File

@ -1,21 +0,0 @@
import type { Meta, StoryObj } from '@storybook/react';
import { InvAutosizeTextarea } from './InvAutosizeTextarea';
import type { InvAutosizeTextareaProps } from './types';
const meta: Meta<typeof InvAutosizeTextarea> = {
title: 'Primitives/InvAutosizeTextarea',
tags: ['autodocs'],
component: InvAutosizeTextarea,
};
export default meta;
type Story = StoryObj<typeof InvAutosizeTextarea>;
const Component = (props: InvAutosizeTextareaProps) => {
return <InvAutosizeTextarea {...props} />;
};
export const Default: Story = {
render: Component,
};

View File

@ -1,7 +0,0 @@
import type { TextareaProps as ChakraTextareaProps } from '@invoke-ai/ui';
import type { TextareaAutosizeProps } from 'react-textarea-autosize';
export type InvAutosizeTextareaProps = Omit<
ChakraTextareaProps & TextareaAutosizeProps,
'resize'
>;