Skip to content

Commit

Permalink
re-add Flow type defs
Browse files Browse the repository at this point in the history
  • Loading branch information
Macil committed Sep 29, 2023
1 parent aa50be0 commit 0a058aa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions index.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* @flow */

export type PositionOption = "top" | "bottom" | "left" | "right" | "cover";
export type HAlignOption = "center" | "left" | "right" | "unaligned";
export type VAlignOption = "center" | "top" | "bottom" | "unaligned";

export type Position = PositionOption | PositionOption[];
export type HAlign = HAlignOption | HAlignOption[];
export type VAlign = VAlignOption | VAlignOption[];
export interface Choice {
position: PositionOption;
hAlign: HAlignOption;
vAlign: VAlignOption;
}

export interface Coordinates {
top: number;
left: number;
}

export interface ChoiceAndCoordinates {
choice: Choice;
coordinates: Coordinates;
}

export interface Options {
position?: Position | null | void;
forcePosition?: boolean | null | void;
hAlign?: HAlign | null | void;
forceHAlign?: boolean | null | void;
vAlign?: VAlign | null | void;
forceVAlign?: boolean | null | void;
buffer?: number | null | void;
topBuffer?: number | null | void;
bottomBuffer?: number | null | void;
leftBuffer?: number | null | void;
rightBuffer?: number | null | void;
}

declare export function containByScreen(
element: HTMLElement,
anchorPoint: HTMLElement,
options: Options,
): Choice;

declare export function getContainByScreenResults(
element: HTMLElement,
anchorPoint: HTMLElement,
options: Options,
): ChoiceAndCoordinates;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "dist/src/index.js",
"sideEffects": false,
"scripts": {
"prepare": "rimraf dist && babel -s true -d dist/src/ src/ -x .ts,.tsx --ignore '**/*.test.ts,**/*.test.tsx' && tsc",
"prepare": "rimraf dist && babel -s true -d dist/src/ src/ -x .ts,.tsx --ignore '**/*.test.ts,**/*.test.tsx' && tsc && cp index.js.flow dist/src/",
"build-watch": "babel --watch -s true -d dist/src/ src/ -x .ts,.tsx --ignore '**/*.test.ts,**/*.test.tsx'",
"test": "yarn run lint && mocha && tsc --noEmit --emitDeclarationOnly false",
"lint": "eslint .",
Expand Down

0 comments on commit 0a058aa

Please sign in to comment.