@standardbeagle/virtual-router 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Component Router
2
+
3
+ Compoent router is a basic memory only hook based router for react. Component router does not interface or connect with the browser path at all.
4
+
5
+ ## Why Component Router
6
+
7
+ I built component router because I was working on a complicated react component intented to be used by multiple projects. I initally started building it with react router, which worked exactly as I needed it in my test project. However when I included it in multiple external projects, it forced me to use react router as the router for the entire project, and copy all the component routes up to the main router file.
8
+
9
+ I'm a huge fan of using routing for UI state management. I think the process of tying rednering components to manipulating the path with links and pattern matching makes my applications easier to maintain and understand. It also happens to be the way that http servers manage loading files.
10
+
11
+ ## Getting Started
12
+
13
+ ``` npm i @standardbeagle/component-router ```
14
+
15
+ The core of your application is the Provider which manages and shares path and route data to all its child components.
16
+
17
+ ```
18
+ <Component>
19
+ ```
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import type { PropsWithChildren } from 'react';
3
+ import type { ReactElement } from 'react';
4
+ export { PathProvider } from './provider.tsx';
5
+ export declare function usePath(): string;
6
+ export declare function useHistory(): string[];
7
+ export declare function useNavigate(): (url: string) => void;
8
+ export declare function useNavigation(): any;
9
+ export declare function useParams(): any;
10
+ export declare function useSearchParams(): any;
11
+ export declare function useRouteError(): any;
12
+ export declare const Link: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
13
+ interface RoutesProps {
14
+ }
15
+ export declare function Routes(props: PropsWithChildren<RoutesProps>): ReactElement;
16
+ interface RouteProps {
17
+ route: string;
18
+ }
19
+ export declare function Route(_: PropsWithChildren<RouteProps>): ReactElement;
@@ -0,0 +1 @@
1
+ export * from './index'