diff --git a/src/index.ts b/src/index.ts index 1942ecbac..0d1244f24 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,15 @@ import bindGlobalEventListeners, { } from './bindGlobalEventListeners'; import {getArrayOfElements, isReferenceElement, isElement} from './utils'; import {warnWhen, validateTargets, validateProps} from './validation'; -import {Props, Instance, Targets, HideAllOptions, Plugin, Tippy} from './types'; +import { + Props, + Instance, + Targets, + HideAllOptions, + Plugin, + Tippy, + DefaultProps, +} from './types'; /** * Exported module @@ -68,7 +76,7 @@ tippy.currentInput = currentInput; /** * Mutates the defaultProps object by setting the props specified */ -function setDefaultProps(partialProps: Partial): void { +function setDefaultProps(partialProps: Partial): void { if (__DEV__) { validateProps(partialProps, []); } diff --git a/src/props.ts b/src/props.ts index f676f9736..4e712bd53 100644 --- a/src/props.ts +++ b/src/props.ts @@ -1,6 +1,6 @@ -import {Props, Plugin} from './types'; +import {Props, DefaultProps, Plugin} from './types'; -export const defaultProps: Props = { +export const defaultProps: DefaultProps = { allowHTML: true, animation: 'fade', appendTo: (): Element => document.body, diff --git a/src/types.ts b/src/types.ts index 73fed53f3..1568c7b21 100644 --- a/src/types.ts +++ b/src/types.ts @@ -47,9 +47,9 @@ export interface Props extends LifecycleHooks { arrow: boolean | string | SVGElement; boundary: 'scrollParent' | 'window' | 'viewport' | HTMLElement; content: Content; - delay: number | [number, number]; + delay: number | [number | null, number | null]; distance: number | string; - duration: number | [number, number]; + duration: number | [number | null, number | null]; flip: boolean; flipBehavior: 'flip' | Placement[]; flipOnUpdate: boolean; @@ -76,6 +76,11 @@ export interface Props extends LifecycleHooks { [key: string]: any; } +export interface DefaultProps extends Props { + delay: number | [number, number]; + duration: number | [number, number]; +} + export interface AnimateFillProps { animateFill: boolean; } diff --git a/src/utils.ts b/src/utils.ts index 153af8e76..69e4ace8f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -38,9 +38,9 @@ export function getArrayOfElements(value: Targets): Element[] { * Returns a value at a given index depending on if it's an array or number */ export function getValueAtIndexOrReturn( - value: T | T[], + value: T | [T | null, T | null], index: number, - defaultValue: T | T[], + defaultValue: T | [T, T], ): T { if (Array.isArray(value)) { const v = value[index];