crossroad 1.2.3 → 1.3.1

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.
Files changed (2) hide show
  1. package/package.json +9 -4
  2. package/src/index.d.ts +56 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crossroad",
3
- "version": "1.2.3",
3
+ "version": "1.3.1",
4
4
  "description": "A React library to handle navigation easily in your WebApp",
5
5
  "homepage": "https://crossroad.page/",
6
6
  "repository": "https://github.com/franciscop/crossroad.git",
@@ -12,7 +12,7 @@
12
12
  "build": "rollup -c",
13
13
  "size": "echo $(gzip -c index.min.js | wc -c) bytes",
14
14
  "start": "jest --watch",
15
- "test": "jest --coverage"
15
+ "test": "jest --coverage && npx check-dts"
16
16
  },
17
17
  "keywords": [
18
18
  "react",
@@ -23,16 +23,21 @@
23
23
  ],
24
24
  "main": "index.min.js",
25
25
  "type": "module",
26
- "files": [],
26
+ "types": "src/index.d.ts",
27
+ "files": [
28
+ "src/index.d.ts"
29
+ ],
27
30
  "devDependencies": {
28
31
  "@babel/core": "^7.15.0",
29
32
  "@babel/preset-env": "^7.15.0",
30
33
  "@babel/preset-react": "^7.14.5",
34
+ "@types/react": "^18.3.4",
31
35
  "babel-loader": "^8.2.2",
32
36
  "babel-polyfill": "^6.26.0",
37
+ "check-dts": "^0.8.2",
33
38
  "jest": "^28.1.0",
34
39
  "jest-environment-jsdom": "^28.1.0",
35
- "react": "^18.2.0",
40
+ "react": "^18.3.1",
36
41
  "react-test": "^0.19.0",
37
42
  "rollup": "^1.32.1",
38
43
  "rollup-plugin-babel": "^4.4.0",
package/src/index.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ import React from "react";
2
+
3
+ type FC<T> = React.FC<React.PropsWithChildren<T>>;
4
+
5
+ declare const Router: FC<{ scrollUp?: boolean; url?: string }>;
6
+
7
+ declare const Route: <T = any>(props: {
8
+ path?: string;
9
+ scrollUp?: boolean;
10
+ component?: React.FunctionComponent<T>;
11
+ render?: (params: T) => React.ReactNode;
12
+ children?: any;
13
+ }) => any;
14
+
15
+ declare const Switch: FC<{
16
+ redirect?: string | { path: string } | (() => string);
17
+ }>;
18
+
19
+ type Query = {
20
+ [key: string]: string;
21
+ };
22
+
23
+ type Url = URL & {
24
+ path: string;
25
+ query: Query;
26
+ hash?: string;
27
+ };
28
+
29
+ type UrlSet = {
30
+ path?: string;
31
+ query?: Query;
32
+ hash?: string;
33
+ };
34
+
35
+ declare const Context: React.Context<any>;
36
+
37
+ type Callable<T = string> = React.Dispatch<React.SetStateAction<T>>;
38
+
39
+ declare function useUrl(): [Url, Callable<UrlSet | string>];
40
+ declare function usePath(): [string, Callable<string>];
41
+ declare function useQuery(): [Query, Callable<Query>];
42
+ declare function useQuery(filter: string): [string, Callable<string>];
43
+ declare function useHash(): [string, Callable<string>];
44
+ declare function useParams(ref: string): any;
45
+
46
+ export default Router;
47
+ export {
48
+ Route,
49
+ Switch,
50
+ useUrl,
51
+ usePath,
52
+ useQuery,
53
+ useHash,
54
+ useParams,
55
+ Context,
56
+ };