Skip to content

Commit

Permalink
Refactor types in Popover-consuming packages
Browse files Browse the repository at this point in the history
  • Loading branch information
stephl3 committed Sep 18, 2024
1 parent 95a4e18 commit 17d4fbc
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 15 deletions.
4 changes: 2 additions & 2 deletions chat/input-bar/src/InputBar/InputBar.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FormEvent, ReactElement } from 'react';
import { TextareaAutosizeProps } from 'react-textarea-autosize';

import { DarkModeProps, HTMLElementProps } from '@leafygreen-ui/lib';
import { PortalControlProps } from '@leafygreen-ui/popover';
import { PopoverRenderModeProps } from '@leafygreen-ui/popover';

export type InputBarProps = HTMLElementProps<'form'> &
DarkModeProps & {
Expand Down Expand Up @@ -48,7 +48,7 @@ export type InputBarProps = HTMLElementProps<'form'> &
/**
* Props passed to the Popover that renders the suggested promps.
*/
dropdownProps?: PortalControlProps;
dropdownProps?: PopoverRenderModeProps;
};

export type { TextareaAutosizeProps };
4 changes: 2 additions & 2 deletions packages/combobox/src/Combobox/Combobox.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';

import { type ChipProps } from '@leafygreen-ui/chip';
import { Either, HTMLElementProps } from '@leafygreen-ui/lib';
import { PortalControlProps } from '@leafygreen-ui/popover';
import { PopoverRenderModeProps } from '@leafygreen-ui/popover';

import {
ComboboxSize,
Expand Down Expand Up @@ -60,7 +60,7 @@ type PartialChipProps = Pick<
>;

export type BaseComboboxProps = Omit<HTMLElementProps<'div'>, 'onChange'> &
PortalControlProps &
PopoverRenderModeProps &
PartialChipProps & {
/**
* Defines the Combobox Options by passing children. Must be `ComboboxOption` or `ComboboxGroup`
Expand Down
4 changes: 2 additions & 2 deletions packages/combobox/src/ComboboxMenu/ComboboxMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useAvailableSpace, useForwardedRef } from '@leafygreen-ui/hooks';
import Icon from '@leafygreen-ui/icon';
import { useDarkMode } from '@leafygreen-ui/leafygreen-provider';
import { palette } from '@leafygreen-ui/palette';
import Popover, { PortalControlProps } from '@leafygreen-ui/popover';
import Popover, { PopoverRenderModeProps } from '@leafygreen-ui/popover';
import { Error } from '@leafygreen-ui/typography';

import { ComboboxProps } from '../Combobox';
Expand All @@ -30,7 +30,7 @@ type ComboboxMenuProps = {
id: string;
labelId: string;
menuWidth: number;
} & PortalControlProps &
} & PopoverRenderModeProps &
Pick<
ComboboxProps<any>,
| 'searchLoadingMessage'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { HTMLElementProps } from '@leafygreen-ui/lib';
import { PopoverProps } from '@leafygreen-ui/popover';
import { PortalControlProps } from '@leafygreen-ui/popover';

export type DatePickerMenuProps = PortalControlProps &
Omit<PopoverProps, 'children'> &
export type DatePickerMenuProps = Omit<
PopoverProps,
'children' | 'renderMode' | 'usePortal'
> &
HTMLElementProps<'div'>;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import Popover, { PopoverProps } from '@leafygreen-ui/popover';

import { menuStyles } from './MenuWrapper.styles';

export type MenuWrapperProps = PopoverProps & HTMLElementProps<'div'>;
export type MenuWrapperProps = Omit<
PopoverProps,
'dismissMode' | 'onToggle' | 'renderMode'
> &
HTMLElementProps<'div'>;

/**
* A simple styled popover component
Expand All @@ -24,6 +28,7 @@ export const MenuWrapper = forwardRef<HTMLDivElement, MenuWrapperProps>(
ref={fwdRef}
className={cx(menuStyles[theme], className)}
{...props}
usePortal
>
{/*
* Prevents the opening and closing state of a select dropdown from propagating up
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { AutoComplete, DatePickerState } from './types';

export type ModifiedPopoverProps = Omit<
PopoverProps,
'usePortal' | 'refEl' | 'children' | 'className' | 'active' | 'onClick'
| 'usePortal'
| 'refEl'
| 'children'
| 'className'
| 'active'
| 'onClick'
| 'renderMode'
>;

export type BaseDatePickerProps = {
Expand Down
1 change: 1 addition & 0 deletions packages/guide-cue/src/GuideCue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function GuideCue({
adjustOnMutation={true}
popoverZIndex={popoverZIndex}
{...sharedProps}
usePortal={true}
>
{/* The beacon is using the popover component to position itself */}
<div
Expand Down
1 change: 1 addition & 0 deletions packages/guide-cue/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type ModifiedTooltipProps = Omit<
| 'refEl'
| 'darkMode'
| 'initialOpen'
| 'renderMode'
>;

interface StandaloneProps {
Expand Down
4 changes: 2 additions & 2 deletions packages/number-input/src/UnitSelect/UnitSelect.types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
PopoverProps as ImportedPopoverProps,
PortalControlProps,
PopoverRenderModeProps,
} from '@leafygreen-ui/popover';

import { Size, UnitOption } from '../NumberInput/NumberInput.types';

export type PopoverProps = PortalControlProps &
export type PopoverProps = PopoverRenderModeProps &
Pick<ImportedPopoverProps, 'popoverZIndex'>;

export type UnitSelectProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { ReactElement } from 'react';

import { HTMLElementProps } from '@leafygreen-ui/lib';
import { PortalControlProps } from '@leafygreen-ui/popover';
import { PopoverRenderModeProps } from '@leafygreen-ui/popover';

export type SearchResultsMenuProps = HTMLElementProps<'ul', HTMLUListElement> &
PortalControlProps & {
PopoverRenderModeProps & {
refEl: React.RefObject<HTMLElement>;
open?: boolean;
footerSlot?: ReactElement;
Expand Down

0 comments on commit 17d4fbc

Please sign in to comment.