solid-navigator 0.3.4 → 0.3.6
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 +12 -8
- package/dist/dev.jsx +14 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -8
- package/dist/index.jsx +14 -6
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { createContext, children, createMemo, createSignal, onCleanup, batch, mergeProps, createEffect, on, useContext } from 'solid-js';
|
|
1
2
|
import { delegateEvents, createComponent, spread, template } from 'solid-js/web';
|
|
2
|
-
import { createContext, children, createMemo, createSignal, onCleanup, mergeProps, createEffect, on, useContext } from 'solid-js';
|
|
3
3
|
import { createStore, reconcile } from 'solid-js/store';
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/navigator.ts
|
|
6
6
|
|
|
7
7
|
// src/utils/matcher.ts
|
|
8
8
|
function createMatcher(path, partial, matchFilters) {
|
|
@@ -152,8 +152,10 @@ function Router(props) {
|
|
|
152
152
|
});
|
|
153
153
|
const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
|
|
154
154
|
const onPopState = (_event) => {
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
batch(() => {
|
|
156
|
+
setPathname(location.pathname);
|
|
157
|
+
setHashAndSearch(getHashAndSearch());
|
|
158
|
+
});
|
|
157
159
|
};
|
|
158
160
|
const onClick = (event) => {
|
|
159
161
|
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
|
|
@@ -286,8 +288,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
286
288
|
if (!isValidPath(routes, location.pathname)) {
|
|
287
289
|
console.warn("Invalid path: " + path);
|
|
288
290
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
+
batch(() => {
|
|
292
|
+
setPathname(location.pathname);
|
|
293
|
+
setHashAndSearch(getHashAndSearch());
|
|
294
|
+
});
|
|
291
295
|
};
|
|
292
296
|
};
|
|
293
297
|
var useNavigate = () => {
|
|
@@ -302,12 +306,12 @@ var Navigate = (props) => {
|
|
|
302
306
|
function useSearchParams() {
|
|
303
307
|
const context = useRouterContext();
|
|
304
308
|
const navigate = useNavigate();
|
|
305
|
-
const updateQuery = (query) => {
|
|
309
|
+
const updateQuery = (query, options) => {
|
|
306
310
|
context.setQuery(reconcile(query));
|
|
307
311
|
const url = new URL(window.location.href);
|
|
308
312
|
const newSearch = new URLSearchParams(context.query);
|
|
309
313
|
url.search = newSearch.toString();
|
|
310
|
-
navigate(url.pathname + url.search + url.hash);
|
|
314
|
+
navigate(url.pathname + url.search + url.hash, options);
|
|
311
315
|
};
|
|
312
316
|
return [context.location.query, updateQuery];
|
|
313
317
|
}
|
package/dist/dev.jsx
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// src/navigator.ts
|
|
2
|
+
import { batch as batch2 } from "solid-js";
|
|
3
|
+
|
|
1
4
|
// src/Router.tsx
|
|
2
5
|
import {
|
|
6
|
+
batch,
|
|
3
7
|
children,
|
|
4
8
|
createContext,
|
|
5
9
|
createMemo as createMemo2,
|
|
@@ -159,8 +163,10 @@ function Router(props) {
|
|
|
159
163
|
});
|
|
160
164
|
const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
|
|
161
165
|
const onPopState = (_event) => {
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
batch(() => {
|
|
167
|
+
setPathname(location.pathname);
|
|
168
|
+
setHashAndSearch(getHashAndSearch());
|
|
169
|
+
});
|
|
164
170
|
};
|
|
165
171
|
const onClick = (event) => {
|
|
166
172
|
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
|
|
@@ -288,8 +294,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
288
294
|
if (!isValidPath(routes, location.pathname)) {
|
|
289
295
|
console.warn("Invalid path: " + path);
|
|
290
296
|
}
|
|
291
|
-
|
|
292
|
-
|
|
297
|
+
batch2(() => {
|
|
298
|
+
setPathname(location.pathname);
|
|
299
|
+
setHashAndSearch(getHashAndSearch());
|
|
300
|
+
});
|
|
293
301
|
};
|
|
294
302
|
};
|
|
295
303
|
var useNavigate = () => {
|
|
@@ -304,12 +312,12 @@ var Navigate = (props) => {
|
|
|
304
312
|
function useSearchParams() {
|
|
305
313
|
const context = useRouterContext();
|
|
306
314
|
const navigate = useNavigate();
|
|
307
|
-
const updateQuery = (query) => {
|
|
315
|
+
const updateQuery = (query, options) => {
|
|
308
316
|
context.setQuery(reconcile3(query));
|
|
309
317
|
const url = new URL(window.location.href);
|
|
310
318
|
const newSearch = new URLSearchParams(context.query);
|
|
311
319
|
url.search = newSearch.toString();
|
|
312
|
-
navigate(url.pathname + url.search + url.hash);
|
|
320
|
+
navigate(url.pathname + url.search + url.hash, options);
|
|
313
321
|
};
|
|
314
322
|
return [context.location.query, updateQuery];
|
|
315
323
|
}
|
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,8 +1,8 @@
|
|
|
1
|
+
import { createContext, children, createMemo, createSignal, onCleanup, batch, mergeProps, createEffect, on, useContext } from 'solid-js';
|
|
1
2
|
import { delegateEvents, createComponent, spread, template } from 'solid-js/web';
|
|
2
|
-
import { createContext, children, createMemo, createSignal, onCleanup, mergeProps, createEffect, on, useContext } from 'solid-js';
|
|
3
3
|
import { createStore, reconcile } from 'solid-js/store';
|
|
4
4
|
|
|
5
|
-
// src/
|
|
5
|
+
// src/navigator.ts
|
|
6
6
|
|
|
7
7
|
// src/utils/matcher.ts
|
|
8
8
|
function createMatcher(path, partial, matchFilters) {
|
|
@@ -152,8 +152,10 @@ function Router(props) {
|
|
|
152
152
|
});
|
|
153
153
|
const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
|
|
154
154
|
const onPopState = (_event) => {
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
batch(() => {
|
|
156
|
+
setPathname(location.pathname);
|
|
157
|
+
setHashAndSearch(getHashAndSearch());
|
|
158
|
+
});
|
|
157
159
|
};
|
|
158
160
|
const onClick = (event) => {
|
|
159
161
|
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
|
|
@@ -284,8 +286,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
284
286
|
history.pushState({}, "", newPath);
|
|
285
287
|
}
|
|
286
288
|
if (!isValidPath(routes, location.pathname)) ;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
+
batch(() => {
|
|
290
|
+
setPathname(location.pathname);
|
|
291
|
+
setHashAndSearch(getHashAndSearch());
|
|
292
|
+
});
|
|
289
293
|
};
|
|
290
294
|
};
|
|
291
295
|
var useNavigate = () => {
|
|
@@ -300,12 +304,12 @@ var Navigate = (props) => {
|
|
|
300
304
|
function useSearchParams() {
|
|
301
305
|
const context = useRouterContext();
|
|
302
306
|
const navigate = useNavigate();
|
|
303
|
-
const updateQuery = (query) => {
|
|
307
|
+
const updateQuery = (query, options) => {
|
|
304
308
|
context.setQuery(reconcile(query));
|
|
305
309
|
const url = new URL(window.location.href);
|
|
306
310
|
const newSearch = new URLSearchParams(context.query);
|
|
307
311
|
url.search = newSearch.toString();
|
|
308
|
-
navigate(url.pathname + url.search + url.hash);
|
|
312
|
+
navigate(url.pathname + url.search + url.hash, options);
|
|
309
313
|
};
|
|
310
314
|
return [context.location.query, updateQuery];
|
|
311
315
|
}
|
package/dist/index.jsx
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// src/navigator.ts
|
|
2
|
+
import { batch as batch2 } from "solid-js";
|
|
3
|
+
|
|
1
4
|
// src/Router.tsx
|
|
2
5
|
import {
|
|
6
|
+
batch,
|
|
3
7
|
children,
|
|
4
8
|
createContext,
|
|
5
9
|
createMemo as createMemo2,
|
|
@@ -159,8 +163,10 @@ function Router(props) {
|
|
|
159
163
|
});
|
|
160
164
|
const navigate = createNavigate(routes, pathname, setPathname, setHashAndSearch);
|
|
161
165
|
const onPopState = (_event) => {
|
|
162
|
-
|
|
163
|
-
|
|
166
|
+
batch(() => {
|
|
167
|
+
setPathname(location.pathname);
|
|
168
|
+
setHashAndSearch(getHashAndSearch());
|
|
169
|
+
});
|
|
164
170
|
};
|
|
165
171
|
const onClick = (event) => {
|
|
166
172
|
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
|
|
@@ -287,8 +293,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
287
293
|
}
|
|
288
294
|
if (!isValidPath(routes, location.pathname)) {
|
|
289
295
|
}
|
|
290
|
-
|
|
291
|
-
|
|
296
|
+
batch2(() => {
|
|
297
|
+
setPathname(location.pathname);
|
|
298
|
+
setHashAndSearch(getHashAndSearch());
|
|
299
|
+
});
|
|
292
300
|
};
|
|
293
301
|
};
|
|
294
302
|
var useNavigate = () => {
|
|
@@ -303,12 +311,12 @@ var Navigate = (props) => {
|
|
|
303
311
|
function useSearchParams() {
|
|
304
312
|
const context = useRouterContext();
|
|
305
313
|
const navigate = useNavigate();
|
|
306
|
-
const updateQuery = (query) => {
|
|
314
|
+
const updateQuery = (query, options) => {
|
|
307
315
|
context.setQuery(reconcile3(query));
|
|
308
316
|
const url = new URL(window.location.href);
|
|
309
317
|
const newSearch = new URLSearchParams(context.query);
|
|
310
318
|
url.search = newSearch.toString();
|
|
311
|
-
navigate(url.pathname + url.search + url.hash);
|
|
319
|
+
navigate(url.pathname + url.search + url.hash, options);
|
|
312
320
|
};
|
|
313
321
|
return [context.location.query, updateQuery];
|
|
314
322
|
}
|