@pinnacle0/react-stack-router
Advanced tools
Comparing version 0.1.3-beta.25 to 0.1.3-beta.26
import type { History } from "history"; | ||
import type { Lifecycle } from "./screen/lifecycle"; | ||
import type { Location, Router } from "./type"; | ||
export interface RouterContext extends Pick<Router, "push" | "replace" | "pop" | "replaceHash"> { | ||
export interface RouterContext extends Pick<Router, "push" | "replace" | "pop" | "replaceHash" | "replaceSearchParams"> { | ||
history: History; | ||
@@ -6,0 +6,0 @@ } |
@@ -39,2 +39,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
const replaceHash = router.replaceHash.bind(router); | ||
const replaceSearchParams = router.replaceSearchParams.bind(router); | ||
const Root = ({ children }) => { | ||
@@ -47,3 +48,3 @@ const route = useMemo(() => createChildrenRoute(children, null), [children]); | ||
}, []); | ||
return (_jsx(RouterContext.Provider, { value: { history: internalHistory, push, pop, replace, replaceHash }, children: _jsx(Stack, { router: router }) })); | ||
return (_jsx(RouterContext.Provider, { value: { history: internalHistory, push, pop, replace, replaceHash, replaceSearchParams }, children: _jsx(Stack, { router: router }) })); | ||
}; | ||
@@ -57,4 +58,5 @@ return { | ||
replaceHash, | ||
replaceSearchParams, | ||
}; | ||
} | ||
//# sourceMappingURL=createRouter.js.map |
export { createRouter } from "./createRouter"; | ||
export { Link } from "./component/Link"; | ||
export { RouterContext, RouteContext } from "./context"; | ||
export * from "./hooks"; | ||
export * from "./hook"; | ||
export type { History } from "history"; | ||
@@ -6,0 +6,0 @@ export type { RouteProps, PathRouteProps, ComponentRouteProps } from "./component/Route"; |
export { createRouter } from "./createRouter"; | ||
export { Link } from "./component/Link"; | ||
export { RouterContext, RouteContext } from "./context"; | ||
export * from "./hooks"; | ||
export * from "./hook"; | ||
//# sourceMappingURL=index.js.map |
@@ -34,2 +34,3 @@ import { Route } from "../route"; | ||
replaceHash(hash: string): void; | ||
replaceSearchParams(params: Record<string, string>): void; | ||
private createKey; | ||
@@ -36,0 +37,0 @@ private notify; |
@@ -81,2 +81,7 @@ import { Action } from "history"; | ||
} | ||
replaceSearchParams(params) { | ||
const location = this.stackHistory.location; | ||
const search = new URLSearchParams(params).toString(); | ||
this.stackHistory.replace({ pathname: location.pathname, search, hash: location.hash }, location.state); | ||
} | ||
createKey() { | ||
@@ -83,0 +88,0 @@ return Date.now().toString(36) + Math.random().toString(36).substring(2); |
@@ -28,3 +28,4 @@ import type React from "react"; | ||
replaceHash: (hash: string) => void; | ||
replaceSearchParams: (params: Record<string, string>) => void; | ||
} | ||
//# sourceMappingURL=type.d.ts.map |
{ | ||
"name": "@pinnacle0/react-stack-router", | ||
"version": "0.1.3-beta.25", | ||
"version": "0.1.3-beta.26", | ||
"author": "Pinnacle", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,3 +6,3 @@ import {createContext} from "react"; | ||
export interface RouterContext extends Pick<Router, "push" | "replace" | "pop" | "replaceHash"> { | ||
export interface RouterContext extends Pick<Router, "push" | "replace" | "pop" | "replaceHash" | "replaceSearchParams"> { | ||
history: History; | ||
@@ -9,0 +9,0 @@ } |
export {createRouter} from "./createRouter"; | ||
export {Link} from "./component/Link"; | ||
export {RouterContext, RouteContext} from "./context"; | ||
export * from "./hooks"; | ||
export * from "./hook"; | ||
export type {History} from "history"; | ||
@@ -6,0 +6,0 @@ export type {RouteProps, PathRouteProps, ComponentRouteProps} from "./component/Route"; |
@@ -121,2 +121,8 @@ import {Action} from "history"; | ||
replaceSearchParams(params: Record<string, string>): void { | ||
const location = this.stackHistory.location; | ||
const search = new URLSearchParams(params).toString(); | ||
this.stackHistory.replace({pathname: location.pathname, search, hash: location.hash}, location.state); | ||
} | ||
private createKey() { | ||
@@ -123,0 +129,0 @@ return Date.now().toString(36) + Math.random().toString(36).substring(2); |
@@ -34,2 +34,3 @@ import type React from "react"; | ||
replaceHash: (hash: string) => void; | ||
replaceSearchParams: (params: Record<string, string>) => void; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
149414
2388