Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/atomiks/tippyjs
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Mar 10, 2019
2 parents 0d107e2 + dce36f8 commit 692f938
Show file tree
Hide file tree
Showing 40 changed files with 2,199 additions and 1,564 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["@babel/env"],
"presets": ["@babel/env", "@babel/typescript"],
"plugins": [
["@babel/proposal-object-rest-spread", { "loose": true }, "unique"]
],
Expand Down
23 changes: 19 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@
"env": {
"browser": true,
"node": true,
"jest": true
"jest": true,
"es6": true
},
"extends": ["eslint:recommended", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2018
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/no-use-before-define": [
"error",
{ "functions": false }
],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
4 changes: 2 additions & 2 deletions build/all.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import css from '../index.css'
import tippy from '../src/js/index'
import { injectCSS } from '../src/js/css'
import tippy from '../src/index.ts'
import { injectCSS } from '../src/css'

injectCSS(css)

Expand Down
2 changes: 1 addition & 1 deletion build/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import tippy from '../src/js'
import tippy from '../src/index.ts'
export default tippy
2 changes: 1 addition & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tippy from '../src/js'
import tippy from '../src/index'
import '../src/scss/index.scss'
import '../src/scss/themes/light-border.scss'

Expand Down
167 changes: 103 additions & 64 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,80 +15,108 @@ export type Placement =

export type Content = string | Element | ((ref: Element) => Element | string)

export type Targets =
| string
| Element
| Element[]
| NodeList
| Popper.ReferenceObject

export interface Props {
a11y?: boolean
allowHTML?: boolean
animateFill?: boolean
animation?: 'fade' | 'scale' | 'shift-toward' | 'perspective' | 'shift-away'
appendTo?: 'parent' | Element | ((ref: Element) => Element)
aria?: 'describedby' | 'labelledby'
arrow?: boolean
arrowType?: 'sharp' | 'round'
boundary?: 'scrollParent' | 'window' | 'viewport' | HTMLElement
content?: Content
delay?: number | [number, number]
distance?: number
duration?: number | [number, number]
flip?: boolean
flipBehavior?: 'flip' | Placement[]
flipOnUpdate?: boolean
followCursor?: boolean | 'vertical' | 'horizontal' | 'initial'
hideOnClick?: boolean | 'toggle'
ignoreAttributes?: boolean
inertia?: boolean
interactive?: boolean
interactiveBorder?: number
interactiveDebounce?: number
lazy?: boolean
maxWidth?: number | string
multiple?: boolean
offset?: number | string
onHidden?(instance: Instance): void
onHide?(instance: Instance): void | false
onMount?(instance: Instance): void
onShow?(instance: Instance): void | false
onShown?(instance: Instance): void
placement?: Placement
popperOptions?: Popper.PopperOptions
role?: string
showOnInit?: boolean
size?: 'small' | 'regular' | 'large'
sticky?: boolean
target?: string
theme?: 'dark' | 'light' | 'light-border' | 'google' | string
touch?: boolean
touchHold?: boolean
trigger?: string
updateDuration?: number
wait?(instance: Instance, event: Event): void
zIndex?: number
export type Targets = string | Element | Element[] | NodeList | VirtualReference

export interface ReferenceElement extends Element {
_tippy?: Instance
}

export interface PopperElement extends HTMLDivElement {
_tippy?: Instance
}

export interface VirtualReference extends Popper.ReferenceObject {
attributes: {
[key: string]: any
}
classList: {
classNames: {
[key: string]: boolean
}
[key: string]: any
}
}

export interface PopperInstance extends Popper {
reference: ReferenceElement
popper: PopperElement
modifiers: { name: string; padding: object | number }[]
}

/**
* This interface will be called `Props` in the next major.
* Exists for backwards-compat after TypeScript rewrite.
*/
export interface WholeProps {
a11y: boolean
allowHTML: boolean
animateFill: boolean
animation: 'fade' | 'scale' | 'shift-toward' | 'perspective' | 'shift-away'
appendTo: 'parent' | Element | ((ref: Element) => Element)
aria: 'describedby' | 'labelledby' | null
arrow: boolean
arrowType: 'sharp' | 'round'
boundary: 'scrollParent' | 'window' | 'viewport' | HTMLElement
content: Content
delay: number | [number, number]
distance: number
duration: number | [number, number]
flip: boolean
flipBehavior: 'flip' | Placement[]
flipOnUpdate: boolean
followCursor: boolean | 'vertical' | 'horizontal' | 'initial'
hideOnClick: boolean | 'toggle'
ignoreAttributes: boolean
inertia: boolean
interactive: boolean
interactiveBorder: number
interactiveDebounce: number
lazy: boolean
maxWidth: number | string
multiple: boolean
offset: number | string
onHidden(instance: Instance): void
onHide(instance: Instance): void | false
onMount(instance: Instance): void
onShow(instance: Instance): void | false
onShown(instance: Instance): void
placement: Placement
popperOptions: Popper.PopperOptions
role: string
showOnInit: boolean
size: 'small' | 'regular' | 'large'
sticky: boolean
target: string
theme: 'dark' | 'light' | 'light-border' | 'google' | string
touch: boolean
touchHold: boolean
trigger: string
updateDuration: number
wait: ((instance: Instance, event?: Event) => void) | null
zIndex: number
}

/**
* @deprecated
* Use `Options` instead.
*/
export type Props = Partial<WholeProps>

export type Options = Partial<WholeProps>

export interface Instance {
clearDelayTimeouts(): void
destroy(): void
disable(): void
enable(): void
hide(duration?: number): void
id: number
popper: Element
popperChildren: {
arrow: Element | null
backdrop: Element | null
content: Element | null
tooltip: Element | null
}
popperInstance: Popper | null
popper: PopperElement
popperChildren: PopperChildren
popperInstance: PopperInstance | null
props: Props
reference: Element
set(options: Props): void
reference: ReferenceElement
set(options: Options): void
setContent(content: Content): void
show(duration?: number): void
state: {
Expand All @@ -100,11 +128,22 @@ export interface Instance {
}
}

export interface GroupedInstance extends Instance {
_originalProps: Props
}

export interface GroupOptions {
delay?: number | [number, number]
duration?: number | [number, number]
}

export interface PopperChildren {
tooltip: HTMLDivElement
content: HTMLDivElement
arrow: HTMLDivElement | null
backdrop: HTMLDivElement | null
}

export interface HideAllOptions {
checkHideOnClick?: boolean
duration?: number
Expand Down
Loading

0 comments on commit 692f938

Please sign in to comment.