forked from Paratron/hookrouter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* now has types support * json update Co-authored-by: Victor Kuria <victorkushmere@gmail.com>
- Loading branch information
Showing
4 changed files
with
135 additions
and
17 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
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Microsoft Corporation. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE |
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,63 @@ | ||
// Type definitions for hookrouter 2.2 | ||
// Project: https://github.com/Paratron/hookrouter | ||
// Definitions by: Mete Can Eris <https://github.com/mcaneris> | ||
// Sam Calvert <https://github.com/sam-outschool> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 3.4 | ||
import * as React from 'react'; | ||
export namespace HookRouter { | ||
type InterceptedPath = string | null; | ||
interface AProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> { | ||
href: string; | ||
} | ||
interface QueryParams { | ||
[key: string]: any; | ||
} | ||
interface RouteObject<T = any> { | ||
[key: string]: (params: QueryParams) => T; | ||
} | ||
} | ||
export function setLinkProps(props: HookRouter.AProps): HookRouter.AProps; | ||
export function A(props: HookRouter.AProps): React.ReactHTMLElement<HTMLAnchorElement>; | ||
export function confirmNavigation(): void; | ||
export function resetPath(): void; | ||
export function stopInterception(): void; | ||
export function useControlledInterceptor(): [ | ||
HookRouter.InterceptedPath, | ||
typeof confirmNavigation, | ||
typeof resetPath, | ||
typeof stopInterception, | ||
]; | ||
export function interceptRoute(previousRoute: string, nextRoute: string): string[]; | ||
export function get(componentId: number): HookRouter.RouteObject | null; | ||
export function remove(componentId: number): void; | ||
export function useInterceptor(handlerFn: (currentPath: string, nextPath: string) => string): () => typeof remove; | ||
export function setQueryParams(inObj: HookRouter.QueryParams, replace?: boolean): void; | ||
export function getQueryParams(): HookRouter.QueryParams; | ||
export function queryStringToObject(inStr: string): HookRouter.QueryParams; | ||
export function objectToQueryString(inObj: HookRouter.QueryParams): string; | ||
export function useQueryParams(): [HookRouter.QueryParams, typeof setQueryParams]; | ||
export function useRedirect( | ||
fromURL: string, | ||
toURL: string, | ||
queryParams?: HookRouter.QueryParams | null, | ||
replace?: boolean, | ||
): void; | ||
export function setBasepath(inBasepath: string): void; | ||
export function getBasepath(): string; | ||
export function resolvePath(inPath: string): string; | ||
export function prepareRoute(inRoute: string): [RegExp, string[]]; | ||
export function navigate( | ||
url: string, | ||
replace?: boolean, | ||
queryParams?: HookRouter.QueryParams | null, | ||
replaceQueryParams?: boolean, | ||
): void; | ||
export function setPath(inPath: string): void; | ||
export function getPath(): string; | ||
export function usePath(active?: boolean, withBasePath?: boolean): string; | ||
export function updatePathHooks(): void; | ||
export function getWorkingPath(parentRouterId: string): string; | ||
export function useRoutes<T = any>(routeObj: HookRouter.RouteObject<T>): T | null; | ||
export function useTitle(inString: string): void; | ||
export function getTitle(): string; |
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,32 @@ | ||
{ | ||
"name": "@types/hookrouter", | ||
"version": "2.2.5", | ||
"description": "TypeScript definitions for hookrouter", | ||
"license": "MIT", | ||
"contributors": [ | ||
{ | ||
"name": "Mete Can Eris", | ||
"url": "https://github.com/mcaneris", | ||
"githubUsername": "mcaneris" | ||
}, | ||
{ | ||
"name": "Sam Calvert", | ||
"url": "https://github.com/sam-outschool", | ||
"githubUsername": "sam-outschool" | ||
} | ||
], | ||
"main": "", | ||
"types": "index.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git", | ||
"directory": "types/hookrouter" | ||
}, | ||
"scripts": {}, | ||
"dependencies": { | ||
"@types/react": "*", | ||
"csstype": "^3.0.2" | ||
}, | ||
"typesPublisherContentHash": "fccdd1b29e9c9035d59fd99b4e8190af85cc633a4c7fb5862ddfbbe52cc535c8", | ||
"typeScriptVersion": "3.4" | ||
} |