@ovineko/react-router 0.0.1 → 0.0.2

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 CHANGED
@@ -174,7 +174,7 @@ userRoute.path({ id: "42" }, { tab: "settings" }, "profile");
174
174
  #### Type-safe Links
175
175
 
176
176
  ```tsx
177
- <userRoute.Link params={{ id: "42" }} queryParams={{ tab: "profile" }}>
177
+ <userRoute.Link params={{ id: "42" }} searchParams={{ tab: "profile" }}>
178
178
  View Profile
179
179
  </userRoute.Link>
180
180
 
@@ -256,25 +256,6 @@ const params = route.useParams(); // Readonly<{ id: string }>
256
256
  const [searchParams] = route.useSearchParams(); // Readonly<{ page?: number }>
257
257
  ```
258
258
 
259
- ## Migration from v0.x
260
-
261
- The library now uses valibot for validation instead of TypeScript generics:
262
-
263
- **Before:**
264
-
265
- ```tsx
266
- const route = createRouteWithParams<{ id: string }, { q: string }>("/users/:id");
267
- ```
268
-
269
- **After:**
270
-
271
- ```tsx
272
- const route = createRouteWithParams("/users/:id", {
273
- params: v.object({ id: v.string() }),
274
- searchParams: v.object({ q: v.string() }),
275
- });
276
- ```
277
-
278
259
  **Benefits:**
279
260
 
280
261
  - Runtime validation
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ function safeDecodeURIComponent(value) {
32
32
  }
33
33
 
34
34
  // src/utils.ts
35
- var queryParamsToString = (params) => {
35
+ var searchParamsToString = (params) => {
36
36
  if (!params || typeof params !== "object" || Array.isArray(params)) {
37
37
  return "";
38
38
  }
@@ -207,13 +207,13 @@ var createSearchParamsHook = (schema) => {
207
207
  return { useSearchParamsHook, useSearchParamsRaw };
208
208
  };
209
209
  var createRouteWithParams = (pattern, config) => {
210
- const getPath = (params, searchParams, hash) => `${generatePath(pattern, params)}${queryParamsToString(searchParams)}${hash ? `#${hash}` : ""}`;
210
+ const getPath = (params, searchParams, hash) => `${generatePath(pattern, params)}${searchParamsToString(searchParams)}${hash ? `#${hash}` : ""}`;
211
211
  const searchParamsHooks = config.searchParams ? createSearchParamsHook(config.searchParams) : null;
212
212
  const LinkComponent = memo(
213
213
  ({
214
214
  children,
215
215
  params,
216
- queryParams,
216
+ searchParams,
217
217
  state,
218
218
  ...props
219
219
  }) => {
@@ -222,7 +222,7 @@ var createRouteWithParams = (pattern, config) => {
222
222
  () => ({ prevPath: pathname, ...state }),
223
223
  [pathname, state]
224
224
  );
225
- return /* @__PURE__ */ jsx(Link, { ...props, state: mergedState, to: getPath(params, queryParams), children });
225
+ return /* @__PURE__ */ jsx(Link, { ...props, state: mergedState, to: getPath(params, searchParams), children });
226
226
  }
227
227
  );
228
228
  const useParamsRaw = () => {
@@ -259,16 +259,16 @@ var createRouteWithParams = (pattern, config) => {
259
259
  };
260
260
  };
261
261
  var createRouteWithoutParams = (pattern, config) => {
262
- const getPath = (searchParams, hash) => `${pattern}${queryParamsToString(searchParams)}${hash ? `#${hash}` : ""}`;
262
+ const getPath = (searchParams, hash) => `${pattern}${searchParamsToString(searchParams)}${hash ? `#${hash}` : ""}`;
263
263
  const searchParamsHooks = config?.searchParams ? createSearchParamsHook(config.searchParams) : null;
264
264
  const LinkComponent = memo(
265
- ({ children, queryParams, state, ...props }) => {
265
+ ({ children, searchParams, state, ...props }) => {
266
266
  const { pathname } = useLocation();
267
267
  const mergedState = useMemo(
268
268
  () => ({ prevPath: pathname, ...state }),
269
269
  [pathname, state]
270
270
  );
271
- return /* @__PURE__ */ jsx(Link, { ...props, state: mergedState, to: getPath(queryParams), children });
271
+ return /* @__PURE__ */ jsx(Link, { ...props, state: mergedState, to: getPath(searchParams), children });
272
272
  }
273
273
  );
274
274
  return {
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@ export type InferSearchParams<T> = T extends v.GenericSchema ? v.InferOutput<T>
4
4
  export interface LinkPropsWithoutParams<SearchParams> extends Omit<LinkPropsLib, "to"> {
5
5
  children: React.ReactNode | string;
6
6
  className?: string;
7
- queryParams?: SearchParams;
7
+ searchParams?: SearchParams;
8
8
  state?: State;
9
9
  style?: React.CSSProperties;
10
10
  }
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as v from "valibot";
2
2
  import type { SearchParamsInput } from "./types";
3
- export declare const queryParamsToString: (params?: SearchParamsInput) => string;
3
+ export declare const searchParamsToString: (params?: SearchParamsInput) => string;
4
4
  export declare const searchParamsToObject: (params: URLSearchParams) => Record<string, string | string[]>;
5
5
  export declare const objectToSearchParams: (obj: Record<string, unknown>) => URLSearchParams;
6
6
  export declare const parseURLParamsRaw: (pattern: string, url: string) => Record<string, string>;
7
7
  /**
8
8
  * Filters an object to only include keys that exist in the valibot object schema.
9
- * Ignores extra query parameters not defined in the schema.
9
+ * Ignores extra search parameters not defined in the schema.
10
10
  */
11
11
  export declare const filterBySchemaKeys: <T extends v.ObjectSchema<any, any>>(obj: Record<string, unknown>, schema: T) => Record<string, unknown>;
12
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovineko/react-router",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Type-safe wrapper for React Router v7 with typed params, query params, and Link components",
5
5
  "keywords": [
6
6
  "react",