-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import * as cy from "cytoscape"; | ||
|
||
declare const cytoscapePopper: cy.Ext; | ||
export = cytoscapePopper; | ||
export as namespace cytoscapePopper; | ||
|
||
declare namespace cytoscapePopper { | ||
interface Dimensions { | ||
w: number; | ||
h: number; | ||
} | ||
|
||
interface PopperOptions { | ||
} | ||
interface PopperInstance { | ||
} | ||
|
||
type RefElement = Pick<Element, 'getBoundingClientRect'>; | ||
|
||
interface Options<Type> { | ||
/* | ||
* The HTML content of the popper. May be a DOM Element reference or a function that returns one. | ||
*/ | ||
content?: HTMLElement | (() => HTMLElement); | ||
/* | ||
* A function that can be used to override the [rendered](http://js.cytoscape.org/#notation/position) Cytoscape position of the Popper target. | ||
* This option is mandatory when using Popper on the core. | ||
* For an element, the centre of its bounding box is used by default. | ||
*/ | ||
renderedPosition?: (el: Type) => cytoscape.Position; | ||
/* | ||
* A function that can be used to override the [rendered](http://js.cytoscape.org/#notation/position) Cytoscape bounding box dimensions | ||
* considered for the popper target (i.e. `cy` or `ele`). | ||
* It defines only the effective `width` and `height` (`bb.w` and `bb.h`) of the Popper target. | ||
* This option is more often useful for elements rather than for the core. | ||
*/ | ||
renderedDimensions?: (el: Type) => Dimensions; | ||
/* | ||
* The PopperOptions object. | ||
* You may use this to override Popper options. | ||
*/ | ||
popper?: PopperOptions; | ||
} | ||
|
||
type getPopperInstance<Type> = (opts?: Options<Type>) => PopperInstance; | ||
|
||
type getPopperRef<Type> = (opts?: Options<Type>) => RefElement; | ||
|
||
type PopperFactory = (ref: RefElement, content: HTMLElement, options: PopperOptions) => PopperInstance; | ||
} | ||
|
||
declare global { | ||
namespace cytoscape { | ||
interface SingularData { | ||
/* | ||
* User-provided popper factory | ||
*/ | ||
popperFactory: cytoscapePopper.PopperFactory; | ||
/* | ||
* Make a PopperInstance using provided popperFactory for the specified element. | ||
*/ | ||
popper: cytoscapePopper.getPopperInstance<SingularData>; | ||
/* | ||
* Make a virtual popperRef element from the cytoscape instance | ||
*/ | ||
popperRef: cytoscapePopper.getPopperRef<SingularData>; | ||
} | ||
|
||
interface Core { | ||
/* | ||
* User-provided popper factory | ||
*/ | ||
popperFactory: cytoscapePopper.PopperFactory; | ||
/* | ||
* Make a PopperInstance using provided popperFactory for the specified element. | ||
*/ | ||
popper: cytoscapePopper.getPopperInstance<SingularData>; | ||
/* | ||
* Make a virtual popperRef element from the cytoscape instance | ||
*/ | ||
popperRef: cytoscapePopper.getPopperRef<SingularData>; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6", | ||
"dom" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"cytoscape-popper.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters