Skip to content

Commit

Permalink
fix: typescript types
Browse files Browse the repository at this point in the history
fix #106
  • Loading branch information
jedwards1211 committed Jul 3, 2022
1 parent 3c1230f commit 2128977
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/core.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { SyntheticEvent, MouseEvent, TouchEvent, FocusEvent } from 'react'

export type Variant = 'popover' | 'popper' | 'dialog'

export type AnchorPosition = { left: number; top: number }
export interface AnchorPosition {
top: number
left: number
}

export type PopupState = {
open: (eventOrAnchorEl?: SyntheticEvent<any> | HTMLElement | null) => void
Expand Down Expand Up @@ -129,7 +131,7 @@ export function bindFocus(popupState: PopupState): ControlAriaProps & {
export function bindPopover(popupState: PopupState): {
id: string | undefined
anchorEl: HTMLElement | undefined
anchorPosition: AnchorPosition | null | undefined
anchorPosition: AnchorPosition | undefined
anchorReference: 'anchorEl' | 'anchorPosition'
open: boolean
onClose: () => void
Expand All @@ -148,7 +150,7 @@ export function bindPopover(popupState: PopupState): {
export function bindMenu(popupState: PopupState): {
id: string | undefined
anchorEl: HTMLElement | undefined
anchorPosition: AnchorPosition | null | undefined
anchorPosition: AnchorPosition | undefined
anchorReference: 'anchorEl' | 'anchorPosition'
open: boolean
onClose: () => void
Expand Down
12 changes: 6 additions & 6 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type PopupState = {|
) => void,
isOpen: boolean,
anchorEl: ?HTMLElement,
anchorPosition: ?AnchorPosition,
anchorPosition: AnchorPosition | void,
setAnchorEl: (?HTMLElement) => any,
setAnchorElUsed: boolean,
popupId: ?string,
Expand All @@ -42,7 +42,7 @@ export type CoreState = {|
isOpen: boolean,
setAnchorElUsed: boolean,
anchorEl: ?HTMLElement,
anchorPosition: ?AnchorPosition,
anchorPosition: AnchorPosition | void,
hovered: boolean,
focused: boolean,
_openEventType: ?string,
Expand All @@ -55,7 +55,7 @@ export const initCoreState: CoreState = {
isOpen: false,
setAnchorElUsed: false,
anchorEl: null,
anchorPosition: null,
anchorPosition: undefined,
hovered: false,
focused: false,
_openEventType: null,
Expand Down Expand Up @@ -119,7 +119,7 @@ export function createPopupState({
const anchorPosition =
typeof clientX === 'number' && typeof clientY === 'number'
? { left: clientX, top: clientY }
: null
: undefined

if (eventType === 'touchstart') {
setState({ _deferNextOpen: true })
Expand Down Expand Up @@ -391,7 +391,7 @@ export function bindPopover({
}: PopupState): {|
id: ?string,
anchorEl: ?HTMLElement,
anchorPosition: ?AnchorPosition,
anchorPosition: AnchorPosition | void,
anchorReference: 'anchorEl' | 'anchorPosition',
open: boolean,
onClose: () => void,
Expand Down Expand Up @@ -442,7 +442,7 @@ export function bindMenu({
}: PopupState): {|
id: ?string,
anchorEl?: ?HTMLElement,
anchorPosition?: ?AnchorPosition,
anchorPosition: AnchorPosition | void,
anchorReference: 'anchorEl' | 'anchorPosition',
open: boolean,
onClose: () => void,
Expand Down

0 comments on commit 2128977

Please sign in to comment.