Skip to content

Commit

Permalink
fix: work around Next.js 13.5 ESM issue
Browse files Browse the repository at this point in the history
fix #124
fix #125
  • Loading branch information
jedwards1211 committed Oct 23, 2023
1 parent ddd3506 commit a68193f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/HoverMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react'
import { Menu, MenuProps } from '@mui/material'
import { Menu as _Menu, type MenuProps } from '@mui/material'
import { interopRequireDefault } from './util/interopRequireDefault'
// work around https://github.com/vercel/next.js/issues/57285
const Menu = interopRequireDefault(_Menu)

const HoverMenu: React.ComponentType<MenuProps> = React.forwardRef(
function HoverMenu(props: MenuProps, ref): any {
Expand Down
5 changes: 4 additions & 1 deletion src/HoverPopover.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as React from 'react'
import { Popover, PopoverProps } from '@mui/material'
import { Popover as _Popover, type PopoverProps } from '@mui/material'
import { interopRequireDefault } from './util/interopRequireDefault'
// work around https://github.com/vercel/next.js/issues/57285
const Popover = interopRequireDefault(_Popover)

const HoverPopover: React.ComponentType<PopoverProps> = React.forwardRef(
function HoverPopover(props: PopoverProps, ref): any {
Expand Down
10 changes: 5 additions & 5 deletions src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint-env browser */

import {
SyntheticEvent,
MouseEvent,
TouchEvent,
FocusEvent,
type SyntheticEvent,
type MouseEvent,
type TouchEvent,
type FocusEvent,
useCallback,
useState,
useRef,
useEffect,
} from 'react'
import { PopoverPosition, PopoverReference } from '@mui/material'
import { type PopoverPosition, type PopoverReference } from '@mui/material'
import { useEvent } from './useEvent'

const printedWarnings: Record<string, boolean> = {}
Expand Down
4 changes: 4 additions & 0 deletions src/util/interopRequireDefault.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function interopRequireDefault<T>(defaultImport: T): T {
const asAny: any = defaultImport
return asAny.__esModule ? asAny.default : defaultImport
}

0 comments on commit a68193f

Please sign in to comment.