@thetinkerinc/sprout 0.1.5 → 0.1.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.
@@ -0,0 +1,3 @@
1
+ export declare function updateSearch(params: {
2
+ [key: string]: string | undefined;
3
+ }): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import { page } from '$app/state';
2
+ import { goto } from '$app/navigation';
3
+ import { resolve } from '$app/paths';
4
+ export async function updateSearch(params) {
5
+ const currentParams = page.url.searchParams;
6
+ Object.entries(params).forEach(([k, v]) => {
7
+ if (v) {
8
+ currentParams.set(k, v);
9
+ }
10
+ else {
11
+ currentParams.delete(k);
12
+ }
13
+ });
14
+ let query = currentParams.toString();
15
+ if (query) {
16
+ query = '?' + query;
17
+ }
18
+ await goto(resolve((page.url.pathname + query)), {
19
+ replaceState: true,
20
+ invalidateAll: true
21
+ });
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thetinkerinc/sprout",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -42,6 +42,10 @@
42
42
  "types": "./dist/auth/index.d.ts",
43
43
  "svelte": "./dist/auth/index.js"
44
44
  },
45
+ "./navigation": {
46
+ "types": "./dist/navigation/index.d.ts",
47
+ "svelte": "./dist/navigation/index.js"
48
+ },
45
49
  "./vite": {
46
50
  "types": "./dist/vite/index.d.ts",
47
51
  "import": "./dist/vite/index.js"