Skip to content

Commit

Permalink
fix: Export all types from react menu, fix: MenuHeader not having chi…
Browse files Browse the repository at this point in the history
…ldren property (#51)

* fix: Use correct types for anchor ref

* Fix menu header missing children

* Export react-menu types

* fix: child type in MenuHeader

* Removed proptypes
  • Loading branch information
matttdawson authored Oct 31, 2022
1 parent b6cc280 commit f4f794b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
7 changes: 4 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export * from "./src/react-menu3/index";
export * from "./src/react-menu3/types";

export { UpdatingContext } from "./src/contexts/UpdatingContext";
export { UpdatingContextProvider } from "./src/contexts/UpdatingContextProvider";
export { GridContext } from "./src/contexts/GridContext";
Expand Down Expand Up @@ -37,9 +40,7 @@ export { GridFormTextInput } from "./src/components/gridForm/GridFormTextInput";

export { TextAreaInput } from "./src/lui/TextAreaInput";
export { TextInputFormatted } from "./src/lui/TextInputFormatted";
export { GridSubComponentTextArea } from "./src/components/GridSubComponentTextArea"
export { GridSubComponentTextArea } from "./src/components/GridSubComponentTextArea";

export * from "./src/utils/bearing";
export * from "./src/utils/util";

export * from "./src/react-menu3/index";
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"ag-grid-react": ">=27",
"debounce-promise": "^3.1.2",
"lodash-es": "^4.17.21",
"prop-types": "^15.8.1",
"react": ">=17",
"react-dom": ">=17",
"react-transition-state": "^1.1.5",
Expand Down
2 changes: 1 addition & 1 deletion src/react-menu3/components/ControlledMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const ControlledMenuFr = (
</div>
);

if (portal === true && anchorRef?.current !== undefined) {
if (portal === true && anchorRef?.current != null) {
portal = { target: anchorRef.current.ownerDocument.body } as PortalFieldType;
}

Expand Down
7 changes: 5 additions & 2 deletions src/react-menu3/components/MenuHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { memo, forwardRef, ForwardedRef } from "react";
import { useBEM } from "../hooks";
import { menuClass, menuHeaderClass } from "../utils";
import { BaseProps } from "../types";
import { BasePropsWithChildren } from "../types";

export const MenuHeaderFr = ({ className, ...restProps }: BaseProps, externalRef: ForwardedRef<HTMLLIElement>) => {
export const MenuHeaderFr = (
{ className, ...restProps }: BasePropsWithChildren,
externalRef: ForwardedRef<HTMLLIElement>,
) => {
return (
<li
role="presentation"
Expand Down
2 changes: 1 addition & 1 deletion src/react-menu3/positionUtils/positionMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface positionMenuProps {
offsetX: number;
offsetY: number;
arrowRef: MutableRefObject<HTMLDivElement | null>;
anchorRef: MutableRefObject<HTMLElement | null>;
anchorRef: MutableRefObject<Element | null>;
arrow?: boolean;
direction: MenuDirection;
position: "auto" | "anchor" | "initial";
Expand Down
10 changes: 9 additions & 1 deletion src/react-menu3/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export interface BaseProps<M = undefined> extends Omit<React.HTMLAttributes<HTML
className?: ClassNameProp<M>;
}

export interface BasePropsWithChildren<M = undefined> extends Omit<React.HTMLAttributes<HTMLElement>, "className"> {
ref?: React.Ref<any>;
/**
* Can be a string or a function which receives a modifier object and returns a CSS `class` string.
*/
className?: ClassNameProp<M>;
}

export interface Event {
/**
* The `value` prop passed to the `MenuItem` being clicked.
Expand Down Expand Up @@ -397,7 +405,7 @@ export interface ControlledMenuProps extends RootMenuProps, ExtraMenuProps {
*
* *Don't set this prop for context menu*
*/
anchorRef?: React.MutableRefObject<HTMLElement>;
anchorRef?: React.RefObject<Element>;
skipOpen?: React.MutableRefObject<boolean>;
/**
* If `true`, the menu list element will gain focus after menu is open.
Expand Down

0 comments on commit f4f794b

Please sign in to comment.