Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: converted index.js to index.ts for OverflowMenu #16494

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions packages/react/src/components/OverflowMenu/OverflowMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import invariant from 'invariant';
import PropTypes from 'prop-types';
import React from 'react';
import React, { ComponentType } from 'react';
import classNames from 'classnames';
import ClickListener from '../../internal/ClickListener';
import FloatingMenu, {
Expand Down Expand Up @@ -97,15 +97,20 @@ export const getMenuOffset = (menuBody, direction, trigger, flip) => {
};

interface Offset {
top: number;
left: number;
top?: number | null | undefined;
left?: number | null | undefined;
}

interface OverflowMenuProps {
type IconProps = {
className?: string;
'aria-label'?: string;
};

export interface OverflowMenuProps {
/**
* Specify a label to be read by screen readers on the container node
*/
['aria-label']: string;
['aria-label']?: string;

/**
* Deprecated, please use `aria-label` instead.
Expand Down Expand Up @@ -198,7 +203,7 @@ interface OverflowMenuProps {
/**
* Function called to override icon rendering.
*/
renderIcon?: React.ElementType;
renderIcon?: ComponentType<IconProps>;

/**
* Specify a CSS selector that matches the DOM element that should
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

import React from 'react';
import { useFeatureFlag } from '../FeatureFlags';
import { type OverflowMenuProps } from './OverflowMenu';

import { OverflowMenu as OverflowMenuV12 } from './next';

import { OverflowMenu as OverflowMenuComponent } from './OverflowMenu';
import { createClassWrapper } from '../../internal/createClassWrapper';

const OverflowMenuV11 = createClassWrapper(OverflowMenuComponent);
const OverflowMenuV11 = createClassWrapper(
OverflowMenuComponent as typeof React.Component
);

function OverflowMenu(props) {
const enableV12OverflowMenu = useFeatureFlag('enable-v12-overflowmenu');
Expand All @@ -28,4 +31,4 @@ function OverflowMenu(props) {
OverflowMenu.displayName = 'OverflowMenu';

export default OverflowMenu;
export { OverflowMenu };
export { OverflowMenu, type OverflowMenuProps };
Loading