solid-navigator 0.3.7 → 0.3.9
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 -4
- package/dist/dev.jsx +9 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.js +13 -4
- package/dist/index.jsx +9 -4
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -74,6 +74,7 @@ var createLocation = (path, query, setQuery) => {
|
|
|
74
74
|
const search = createMemo(() => url().search);
|
|
75
75
|
const pathname = createMemo(() => url().pathname);
|
|
76
76
|
const hash = createMemo(() => url().hash);
|
|
77
|
+
const state = createMemo(on([hash, pathname, search], () => history.state));
|
|
77
78
|
return {
|
|
78
79
|
query,
|
|
79
80
|
get search() {
|
|
@@ -84,6 +85,9 @@ var createLocation = (path, query, setQuery) => {
|
|
|
84
85
|
},
|
|
85
86
|
get hash() {
|
|
86
87
|
return hash();
|
|
88
|
+
},
|
|
89
|
+
get state() {
|
|
90
|
+
return state();
|
|
87
91
|
}
|
|
88
92
|
};
|
|
89
93
|
};
|
|
@@ -170,7 +174,8 @@ function Router(props) {
|
|
|
170
174
|
return;
|
|
171
175
|
event.preventDefault();
|
|
172
176
|
navigate(href, {
|
|
173
|
-
replace: target.hasAttribute("replace")
|
|
177
|
+
replace: target.hasAttribute("replace"),
|
|
178
|
+
state: JSON.parse(target.getAttribute("state") || "null")
|
|
174
179
|
});
|
|
175
180
|
};
|
|
176
181
|
delegateEvents(["click"]);
|
|
@@ -281,9 +286,9 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
281
286
|
newPath = currentPathname + "/" + newPath.slice(2);
|
|
282
287
|
}
|
|
283
288
|
if (options?.replace) {
|
|
284
|
-
history.replaceState(
|
|
289
|
+
history.replaceState(options.state || null, "", newPath);
|
|
285
290
|
} else {
|
|
286
|
-
history.pushState(
|
|
291
|
+
history.pushState(options?.state || null, "", newPath);
|
|
287
292
|
}
|
|
288
293
|
if (!isValidPath(routes, location.pathname)) {
|
|
289
294
|
console.warn("Invalid path: " + path);
|
|
@@ -383,7 +388,11 @@ var A = (props) => {
|
|
|
383
388
|
};
|
|
384
389
|
return (() => {
|
|
385
390
|
var _el$ = _tmpl$();
|
|
386
|
-
spread(_el$, mergeProps$1(
|
|
391
|
+
spread(_el$, mergeProps$1({
|
|
392
|
+
get state() {
|
|
393
|
+
return JSON.stringify(props.state);
|
|
394
|
+
}
|
|
395
|
+
}, props, {
|
|
387
396
|
get href() {
|
|
388
397
|
return resolvedHref();
|
|
389
398
|
}
|
package/dist/dev.jsx
CHANGED
|
@@ -88,6 +88,7 @@ var createLocation = (path, query, setQuery) => {
|
|
|
88
88
|
const search = createMemo(() => url().search);
|
|
89
89
|
const pathname = createMemo(() => url().pathname);
|
|
90
90
|
const hash = createMemo(() => url().hash);
|
|
91
|
+
const state = createMemo(on([hash, pathname, search], () => history.state));
|
|
91
92
|
return {
|
|
92
93
|
query,
|
|
93
94
|
get search() {
|
|
@@ -98,6 +99,9 @@ var createLocation = (path, query, setQuery) => {
|
|
|
98
99
|
},
|
|
99
100
|
get hash() {
|
|
100
101
|
return hash();
|
|
102
|
+
},
|
|
103
|
+
get state() {
|
|
104
|
+
return state();
|
|
101
105
|
}
|
|
102
106
|
};
|
|
103
107
|
};
|
|
@@ -181,7 +185,8 @@ function Router(props) {
|
|
|
181
185
|
return;
|
|
182
186
|
event.preventDefault();
|
|
183
187
|
navigate(href, {
|
|
184
|
-
replace: target.hasAttribute("replace")
|
|
188
|
+
replace: target.hasAttribute("replace"),
|
|
189
|
+
state: JSON.parse(target.getAttribute("state") || "null")
|
|
185
190
|
});
|
|
186
191
|
};
|
|
187
192
|
delegateEvents(["click"]);
|
|
@@ -287,9 +292,9 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
287
292
|
newPath = currentPathname + "/" + newPath.slice(2);
|
|
288
293
|
}
|
|
289
294
|
if (options?.replace) {
|
|
290
|
-
history.replaceState(
|
|
295
|
+
history.replaceState(options.state || null, "", newPath);
|
|
291
296
|
} else {
|
|
292
|
-
history.pushState(
|
|
297
|
+
history.pushState(options?.state || null, "", newPath);
|
|
293
298
|
}
|
|
294
299
|
if (!isValidPath(routes, location.pathname)) {
|
|
295
300
|
console.warn("Invalid path: " + path);
|
|
@@ -395,7 +400,7 @@ var A = (props) => {
|
|
|
395
400
|
}
|
|
396
401
|
return newPath;
|
|
397
402
|
};
|
|
398
|
-
return <a sn-link {...props} href={resolvedHref()} />;
|
|
403
|
+
return <a sn-link state={JSON.stringify(props.state)} {...props} href={resolvedHref()} />;
|
|
399
404
|
};
|
|
400
405
|
var useMatch = (path) => {
|
|
401
406
|
const location2 = useLocation();
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare const matchComponent: (name: () => string) => () => Component;
|
|
|
14
14
|
|
|
15
15
|
interface NavigateOptions {
|
|
16
16
|
replace?: boolean;
|
|
17
|
+
state?: any;
|
|
17
18
|
}
|
|
18
19
|
declare const useNavigate: () => (path: string, options?: NavigateOptions | undefined) => void;
|
|
19
20
|
declare const Navigate: (props: {
|
|
@@ -43,10 +44,12 @@ declare const useLocation: () => {
|
|
|
43
44
|
readonly search: string;
|
|
44
45
|
readonly pathname: string;
|
|
45
46
|
readonly hash: string;
|
|
47
|
+
readonly state: any;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
type LinkProps = {
|
|
49
51
|
replace?: boolean;
|
|
52
|
+
state?: any;
|
|
50
53
|
} & JSX.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
51
54
|
declare const A: (props: LinkProps) => JSX.Element;
|
|
52
55
|
declare const useMatch: (path: () => string) => solid_js.Accessor<PathMatch | undefined>;
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,7 @@ var createLocation = (path, query, setQuery) => {
|
|
|
74
74
|
const search = createMemo(() => url().search);
|
|
75
75
|
const pathname = createMemo(() => url().pathname);
|
|
76
76
|
const hash = createMemo(() => url().hash);
|
|
77
|
+
const state = createMemo(on([hash, pathname, search], () => history.state));
|
|
77
78
|
return {
|
|
78
79
|
query,
|
|
79
80
|
get search() {
|
|
@@ -84,6 +85,9 @@ var createLocation = (path, query, setQuery) => {
|
|
|
84
85
|
},
|
|
85
86
|
get hash() {
|
|
86
87
|
return hash();
|
|
88
|
+
},
|
|
89
|
+
get state() {
|
|
90
|
+
return state();
|
|
87
91
|
}
|
|
88
92
|
};
|
|
89
93
|
};
|
|
@@ -170,7 +174,8 @@ function Router(props) {
|
|
|
170
174
|
return;
|
|
171
175
|
event.preventDefault();
|
|
172
176
|
navigate(href, {
|
|
173
|
-
replace: target.hasAttribute("replace")
|
|
177
|
+
replace: target.hasAttribute("replace"),
|
|
178
|
+
state: JSON.parse(target.getAttribute("state") || "null")
|
|
174
179
|
});
|
|
175
180
|
};
|
|
176
181
|
delegateEvents(["click"]);
|
|
@@ -281,9 +286,9 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
281
286
|
newPath = currentPathname + "/" + newPath.slice(2);
|
|
282
287
|
}
|
|
283
288
|
if (options?.replace) {
|
|
284
|
-
history.replaceState(
|
|
289
|
+
history.replaceState(options.state || null, "", newPath);
|
|
285
290
|
} else {
|
|
286
|
-
history.pushState(
|
|
291
|
+
history.pushState(options?.state || null, "", newPath);
|
|
287
292
|
}
|
|
288
293
|
if (!isValidPath(routes, location.pathname)) ;
|
|
289
294
|
batch(() => {
|
|
@@ -379,7 +384,11 @@ var A = (props) => {
|
|
|
379
384
|
};
|
|
380
385
|
return (() => {
|
|
381
386
|
var _el$ = _tmpl$();
|
|
382
|
-
spread(_el$, mergeProps$1(
|
|
387
|
+
spread(_el$, mergeProps$1({
|
|
388
|
+
get state() {
|
|
389
|
+
return JSON.stringify(props.state);
|
|
390
|
+
}
|
|
391
|
+
}, props, {
|
|
383
392
|
get href() {
|
|
384
393
|
return resolvedHref();
|
|
385
394
|
}
|
package/dist/index.jsx
CHANGED
|
@@ -88,6 +88,7 @@ var createLocation = (path, query, setQuery) => {
|
|
|
88
88
|
const search = createMemo(() => url().search);
|
|
89
89
|
const pathname = createMemo(() => url().pathname);
|
|
90
90
|
const hash = createMemo(() => url().hash);
|
|
91
|
+
const state = createMemo(on([hash, pathname, search], () => history.state));
|
|
91
92
|
return {
|
|
92
93
|
query,
|
|
93
94
|
get search() {
|
|
@@ -98,6 +99,9 @@ var createLocation = (path, query, setQuery) => {
|
|
|
98
99
|
},
|
|
99
100
|
get hash() {
|
|
100
101
|
return hash();
|
|
102
|
+
},
|
|
103
|
+
get state() {
|
|
104
|
+
return state();
|
|
101
105
|
}
|
|
102
106
|
};
|
|
103
107
|
};
|
|
@@ -181,7 +185,8 @@ function Router(props) {
|
|
|
181
185
|
return;
|
|
182
186
|
event.preventDefault();
|
|
183
187
|
navigate(href, {
|
|
184
|
-
replace: target.hasAttribute("replace")
|
|
188
|
+
replace: target.hasAttribute("replace"),
|
|
189
|
+
state: JSON.parse(target.getAttribute("state") || "null")
|
|
185
190
|
});
|
|
186
191
|
};
|
|
187
192
|
delegateEvents(["click"]);
|
|
@@ -287,9 +292,9 @@ var createNavigate = (routes, pathname, setPathname, setHashAndSearch) => {
|
|
|
287
292
|
newPath = currentPathname + "/" + newPath.slice(2);
|
|
288
293
|
}
|
|
289
294
|
if (options?.replace) {
|
|
290
|
-
history.replaceState(
|
|
295
|
+
history.replaceState(options.state || null, "", newPath);
|
|
291
296
|
} else {
|
|
292
|
-
history.pushState(
|
|
297
|
+
history.pushState(options?.state || null, "", newPath);
|
|
293
298
|
}
|
|
294
299
|
if (!isValidPath(routes, location.pathname)) {
|
|
295
300
|
}
|
|
@@ -392,7 +397,7 @@ var A = (props) => {
|
|
|
392
397
|
}
|
|
393
398
|
return newPath;
|
|
394
399
|
};
|
|
395
|
-
return <a sn-link {...props} href={resolvedHref()} />;
|
|
400
|
+
return <a sn-link state={JSON.stringify(props.state)} {...props} href={resolvedHref()} />;
|
|
396
401
|
};
|
|
397
402
|
var useMatch = (path) => {
|
|
398
403
|
const location2 = useLocation();
|