solid-navigator 0.3.5 → 0.3.7

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/dist/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createContext, children, createMemo, createSignal, onCleanup, batch, mergeProps, createEffect, on, useContext } from 'solid-js';
2
- import { delegateEvents, createComponent, spread, template } from 'solid-js/web';
2
+ import { delegateEvents, createComponent, spread, mergeProps as mergeProps$1, template } from 'solid-js/web';
3
3
  import { createStore, reconcile } from 'solid-js/store';
4
4
 
5
5
  // src/navigator.ts
@@ -306,14 +306,17 @@ var Navigate = (props) => {
306
306
  function useSearchParams() {
307
307
  const context = useRouterContext();
308
308
  const navigate = useNavigate();
309
- const updateQuery = (query) => {
309
+ const updateQuery = (query, options) => {
310
310
  context.setQuery(reconcile(query));
311
311
  const url = new URL(window.location.href);
312
312
  const newSearch = new URLSearchParams(context.query);
313
313
  url.search = newSearch.toString();
314
- navigate(url.pathname + url.search + url.hash);
314
+ navigate(url.pathname + url.search + url.hash, options);
315
315
  };
316
- return [context.location.query, updateQuery];
316
+ return [
317
+ context.location.query,
318
+ updateQuery
319
+ ];
317
320
  }
318
321
  var Fragment = () => [];
319
322
  var Outlet = (props) => {
@@ -364,9 +367,27 @@ var matchComponent = (name) => {
364
367
  };
365
368
  var _tmpl$ = /* @__PURE__ */ template(`<a sn-link>`);
366
369
  var A = (props) => {
370
+ const location2 = useLocation();
371
+ const resolvedHref = () => {
372
+ if (!props.href)
373
+ return props.href;
374
+ let newPath = props.href;
375
+ let currentPathname = location2.pathname;
376
+ if (currentPathname.endsWith("/")) {
377
+ currentPathname = currentPathname.slice(0, -1);
378
+ }
379
+ if (newPath.startsWith("./")) {
380
+ newPath = currentPathname + "/" + newPath.slice(2);
381
+ }
382
+ return newPath;
383
+ };
367
384
  return (() => {
368
385
  var _el$ = _tmpl$();
369
- spread(_el$, props, false, false);
386
+ spread(_el$, mergeProps$1(props, {
387
+ get href() {
388
+ return resolvedHref();
389
+ }
390
+ }), false, false);
370
391
  return _el$;
371
392
  })();
372
393
  };
package/dist/dev.jsx CHANGED
@@ -312,14 +312,17 @@ var Navigate = (props) => {
312
312
  function useSearchParams() {
313
313
  const context = useRouterContext();
314
314
  const navigate = useNavigate();
315
- const updateQuery = (query) => {
315
+ const updateQuery = (query, options) => {
316
316
  context.setQuery(reconcile3(query));
317
317
  const url = new URL(window.location.href);
318
318
  const newSearch = new URLSearchParams(context.query);
319
319
  url.search = newSearch.toString();
320
- navigate(url.pathname + url.search + url.hash);
320
+ navigate(url.pathname + url.search + url.hash, options);
321
321
  };
322
- return [context.location.query, updateQuery];
322
+ return [
323
+ context.location.query,
324
+ updateQuery
325
+ ];
323
326
  }
324
327
 
325
328
  // src/Outlet.tsx
@@ -378,7 +381,21 @@ var matchComponent = (name) => {
378
381
  // src/Link.tsx
379
382
  import { createMemo as createMemo5 } from "solid-js";
380
383
  var A = (props) => {
381
- return <a sn-link {...props} />;
384
+ const location2 = useLocation();
385
+ const resolvedHref = () => {
386
+ if (!props.href)
387
+ return props.href;
388
+ let newPath = props.href;
389
+ let currentPathname = location2.pathname;
390
+ if (currentPathname.endsWith("/")) {
391
+ currentPathname = currentPathname.slice(0, -1);
392
+ }
393
+ if (newPath.startsWith("./")) {
394
+ newPath = currentPathname + "/" + newPath.slice(2);
395
+ }
396
+ return newPath;
397
+ };
398
+ return <a sn-link {...props} href={resolvedHref()} />;
382
399
  };
383
400
  var useMatch = (path) => {
384
401
  const location2 = useLocation();
package/dist/index.d.ts CHANGED
@@ -19,7 +19,7 @@ declare const useNavigate: () => (path: string, options?: NavigateOptions | unde
19
19
  declare const Navigate: (props: {
20
20
  href: string;
21
21
  }) => null;
22
- declare function useSearchParams<T = Record<string, string>>(): readonly [T, (query: T) => void];
22
+ declare function useSearchParams<T = Record<string, string>>(): readonly [T, (query: T, options?: NavigateOptions) => void];
23
23
 
24
24
  declare const Outlet: (props: {
25
25
  children?: string;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createContext, children, createMemo, createSignal, onCleanup, batch, mergeProps, createEffect, on, useContext } from 'solid-js';
2
- import { delegateEvents, createComponent, spread, template } from 'solid-js/web';
2
+ import { delegateEvents, createComponent, spread, mergeProps as mergeProps$1, template } from 'solid-js/web';
3
3
  import { createStore, reconcile } from 'solid-js/store';
4
4
 
5
5
  // src/navigator.ts
@@ -304,14 +304,17 @@ var Navigate = (props) => {
304
304
  function useSearchParams() {
305
305
  const context = useRouterContext();
306
306
  const navigate = useNavigate();
307
- const updateQuery = (query) => {
307
+ const updateQuery = (query, options) => {
308
308
  context.setQuery(reconcile(query));
309
309
  const url = new URL(window.location.href);
310
310
  const newSearch = new URLSearchParams(context.query);
311
311
  url.search = newSearch.toString();
312
- navigate(url.pathname + url.search + url.hash);
312
+ navigate(url.pathname + url.search + url.hash, options);
313
313
  };
314
- return [context.location.query, updateQuery];
314
+ return [
315
+ context.location.query,
316
+ updateQuery
317
+ ];
315
318
  }
316
319
  var Fragment = () => [];
317
320
  var Outlet = (props) => {
@@ -360,9 +363,27 @@ var matchComponent = (name) => {
360
363
  };
361
364
  var _tmpl$ = /* @__PURE__ */ template(`<a sn-link>`);
362
365
  var A = (props) => {
366
+ const location2 = useLocation();
367
+ const resolvedHref = () => {
368
+ if (!props.href)
369
+ return props.href;
370
+ let newPath = props.href;
371
+ let currentPathname = location2.pathname;
372
+ if (currentPathname.endsWith("/")) {
373
+ currentPathname = currentPathname.slice(0, -1);
374
+ }
375
+ if (newPath.startsWith("./")) {
376
+ newPath = currentPathname + "/" + newPath.slice(2);
377
+ }
378
+ return newPath;
379
+ };
363
380
  return (() => {
364
381
  var _el$ = _tmpl$();
365
- spread(_el$, props, false, false);
382
+ spread(_el$, mergeProps$1(props, {
383
+ get href() {
384
+ return resolvedHref();
385
+ }
386
+ }), false, false);
366
387
  return _el$;
367
388
  })();
368
389
  };
package/dist/index.jsx CHANGED
@@ -311,14 +311,17 @@ var Navigate = (props) => {
311
311
  function useSearchParams() {
312
312
  const context = useRouterContext();
313
313
  const navigate = useNavigate();
314
- const updateQuery = (query) => {
314
+ const updateQuery = (query, options) => {
315
315
  context.setQuery(reconcile3(query));
316
316
  const url = new URL(window.location.href);
317
317
  const newSearch = new URLSearchParams(context.query);
318
318
  url.search = newSearch.toString();
319
- navigate(url.pathname + url.search + url.hash);
319
+ navigate(url.pathname + url.search + url.hash, options);
320
320
  };
321
- return [context.location.query, updateQuery];
321
+ return [
322
+ context.location.query,
323
+ updateQuery
324
+ ];
322
325
  }
323
326
 
324
327
  // src/Outlet.tsx
@@ -375,7 +378,21 @@ var matchComponent = (name) => {
375
378
  // src/Link.tsx
376
379
  import { createMemo as createMemo5 } from "solid-js";
377
380
  var A = (props) => {
378
- return <a sn-link {...props} />;
381
+ const location2 = useLocation();
382
+ const resolvedHref = () => {
383
+ if (!props.href)
384
+ return props.href;
385
+ let newPath = props.href;
386
+ let currentPathname = location2.pathname;
387
+ if (currentPathname.endsWith("/")) {
388
+ currentPathname = currentPathname.slice(0, -1);
389
+ }
390
+ if (newPath.startsWith("./")) {
391
+ newPath = currentPathname + "/" + newPath.slice(2);
392
+ }
393
+ return newPath;
394
+ };
395
+ return <a sn-link {...props} href={resolvedHref()} />;
379
396
  };
380
397
  var useMatch = (path) => {
381
398
  const location2 = useLocation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-navigator",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Solid Navigator is a library that is inspired by vue router and solid router.",
5
5
  "license": "MIT",
6
6
  "author": "SupertigerDev",