solid-navigator 0.3.3 → 0.3.5
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 +13 -7
- package/dist/dev.jsx +15 -5
- package/dist/index.js +13 -7
- package/dist/index.jsx +15 -5
- 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)
|
|
@@ -163,8 +165,10 @@ function Router(props) {
|
|
|
163
165
|
return;
|
|
164
166
|
if (!target.hasAttribute("sn-link"))
|
|
165
167
|
return;
|
|
166
|
-
event.preventDefault();
|
|
167
168
|
const href = target.getAttribute("href") || "";
|
|
169
|
+
if (href.startsWith("http://") || href.startsWith("https://"))
|
|
170
|
+
return;
|
|
171
|
+
event.preventDefault();
|
|
168
172
|
navigate(href, {
|
|
169
173
|
replace: target.hasAttribute("replace")
|
|
170
174
|
});
|
|
@@ -284,8 +288,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
284
288
|
if (!isValidPath(routes, location.pathname)) {
|
|
285
289
|
console.warn("Invalid path: " + path);
|
|
286
290
|
}
|
|
287
|
-
|
|
288
|
-
|
|
291
|
+
batch(() => {
|
|
292
|
+
setPathname(location.pathname);
|
|
293
|
+
setHashAndSearch(getHashAndSearch());
|
|
294
|
+
});
|
|
289
295
|
};
|
|
290
296
|
};
|
|
291
297
|
var useNavigate = () => {
|
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)
|
|
@@ -170,8 +176,10 @@ function Router(props) {
|
|
|
170
176
|
return;
|
|
171
177
|
if (!target.hasAttribute("sn-link"))
|
|
172
178
|
return;
|
|
173
|
-
event.preventDefault();
|
|
174
179
|
const href = target.getAttribute("href") || "";
|
|
180
|
+
if (href.startsWith("http://") || href.startsWith("https://"))
|
|
181
|
+
return;
|
|
182
|
+
event.preventDefault();
|
|
175
183
|
navigate(href, {
|
|
176
184
|
replace: target.hasAttribute("replace")
|
|
177
185
|
});
|
|
@@ -286,8 +294,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
286
294
|
if (!isValidPath(routes, location.pathname)) {
|
|
287
295
|
console.warn("Invalid path: " + path);
|
|
288
296
|
}
|
|
289
|
-
|
|
290
|
-
|
|
297
|
+
batch2(() => {
|
|
298
|
+
setPathname(location.pathname);
|
|
299
|
+
setHashAndSearch(getHashAndSearch());
|
|
300
|
+
});
|
|
291
301
|
};
|
|
292
302
|
};
|
|
293
303
|
var useNavigate = () => {
|
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)
|
|
@@ -163,8 +165,10 @@ function Router(props) {
|
|
|
163
165
|
return;
|
|
164
166
|
if (!target.hasAttribute("sn-link"))
|
|
165
167
|
return;
|
|
166
|
-
event.preventDefault();
|
|
167
168
|
const href = target.getAttribute("href") || "";
|
|
169
|
+
if (href.startsWith("http://") || href.startsWith("https://"))
|
|
170
|
+
return;
|
|
171
|
+
event.preventDefault();
|
|
168
172
|
navigate(href, {
|
|
169
173
|
replace: target.hasAttribute("replace")
|
|
170
174
|
});
|
|
@@ -282,8 +286,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
282
286
|
history.pushState({}, "", newPath);
|
|
283
287
|
}
|
|
284
288
|
if (!isValidPath(routes, location.pathname)) ;
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
batch(() => {
|
|
290
|
+
setPathname(location.pathname);
|
|
291
|
+
setHashAndSearch(getHashAndSearch());
|
|
292
|
+
});
|
|
287
293
|
};
|
|
288
294
|
};
|
|
289
295
|
var useNavigate = () => {
|
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)
|
|
@@ -170,8 +176,10 @@ function Router(props) {
|
|
|
170
176
|
return;
|
|
171
177
|
if (!target.hasAttribute("sn-link"))
|
|
172
178
|
return;
|
|
173
|
-
event.preventDefault();
|
|
174
179
|
const href = target.getAttribute("href") || "";
|
|
180
|
+
if (href.startsWith("http://") || href.startsWith("https://"))
|
|
181
|
+
return;
|
|
182
|
+
event.preventDefault();
|
|
175
183
|
navigate(href, {
|
|
176
184
|
replace: target.hasAttribute("replace")
|
|
177
185
|
});
|
|
@@ -285,8 +293,10 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
285
293
|
}
|
|
286
294
|
if (!isValidPath(routes, location.pathname)) {
|
|
287
295
|
}
|
|
288
|
-
|
|
289
|
-
|
|
296
|
+
batch2(() => {
|
|
297
|
+
setPathname(location.pathname);
|
|
298
|
+
setHashAndSearch(getHashAndSearch());
|
|
299
|
+
});
|
|
290
300
|
};
|
|
291
301
|
};
|
|
292
302
|
var useNavigate = () => {
|