vue-router-query-sync 2.0.0-alpha.0 → 2.0.0-alpha.2
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/README.md +25 -18
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +114 -94
- package/dist/internal/batch.d.ts +10 -0
- package/dist/internal/batch.d.ts.map +1 -0
- package/dist/internal/field.d.ts +2 -2
- package/dist/internal/field.d.ts.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/useQueryFilters.d.ts +2 -2
- package/dist/useQueryFilters.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/internal/queryQueue.d.ts +0 -3
- package/dist/internal/queryQueue.d.ts.map +0 -1
- package/dist/useQueryParam.d.ts +0 -4
- package/dist/useQueryParam.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -20,40 +20,43 @@ npm install vue-router-query-sync
|
|
|
20
20
|
|
|
21
21
|
## `useQueryFilters(schema)`
|
|
22
22
|
|
|
23
|
-
Returns
|
|
23
|
+
Returns `{ filters, patch, reset }`. `filters` is a reactive object of schema fields only
|
|
24
|
+
(no methods on it); access fields without `.value`. The type is inferred from the schema.
|
|
24
25
|
|
|
25
26
|
```ts
|
|
26
27
|
import { useQueryFilters, param } from 'vue-router-query-sync'
|
|
27
28
|
|
|
28
29
|
enum SortType { Popular = 'popular', New = 'new' }
|
|
29
30
|
|
|
30
|
-
const filters = useQueryFilters({
|
|
31
|
+
const { filters, patch, reset } = useQueryFilters({
|
|
31
32
|
sort: param.enum(SortType, { default: SortType.Popular, history: 'push' }),
|
|
32
33
|
brands: param.stringArray(), // default: []
|
|
33
34
|
page: param.number({ default: 1 }),
|
|
34
35
|
from: param.custom(dateCodec), // default: null
|
|
35
36
|
})
|
|
36
37
|
|
|
37
|
-
filters.sort = SortType.New
|
|
38
|
-
filters.brands
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
filters.sort = SortType.New // write -> router navigation
|
|
39
|
+
filters.brands // read -> parses route.query (or pending write)
|
|
40
|
+
patch({ brands: ['lg'], page: 2 }) // several fields, ONE navigation
|
|
41
|
+
reset() // all fields back to defaults (keys removed)
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
- **Read**: `route.query[key]` → `deserialize` → on
|
|
44
|
+
- **Read**: pending write (same tick) → else `route.query[key]` → `deserialize` → on
|
|
45
|
+
`undefined`/throw → `default`. Reading a field right after writing it returns the new value.
|
|
44
46
|
- **Write**: `serialize` → if `null` or equal to `serialize(default)` → the key is removed.
|
|
45
47
|
- Query keys not described in the schema are left untouched.
|
|
46
|
-
-
|
|
47
|
-
- Destructuring loses reactivity — use Vue's `toRefs(filters)`.
|
|
48
|
+
- Destructuring `filters` loses reactivity — use Vue's `toRefs(filters)`.
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
### Single parameter
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
There is no separate single-param helper: use a one-key schema and `toRef`.
|
|
52
53
|
|
|
53
54
|
```ts
|
|
54
|
-
import {
|
|
55
|
+
import { toRef } from 'vue'
|
|
56
|
+
import { useQueryFilters, param } from 'vue-router-query-sync'
|
|
55
57
|
|
|
56
|
-
const
|
|
58
|
+
const { filters } = useQueryFilters({ tab: param.enum(['all', 'favorite'] as const) })
|
|
59
|
+
const tab = toRef(filters, 'tab') // WritableComputedRef<'all' | 'favorite' | null>
|
|
57
60
|
tab.value = 'favorite'
|
|
58
61
|
```
|
|
59
62
|
|
|
@@ -98,9 +101,12 @@ const dateCodec = defineCodec<Date | null>({
|
|
|
98
101
|
|
|
99
102
|
## Batching & history
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`
|
|
104
|
+
All writes in the same tick — field assignments, `patch`, `reset` — accumulate into one
|
|
105
|
+
pending batch (kept per router instance) and are applied as a **single** navigation via
|
|
106
|
+
`queueMicrotask`. The batch is layered over the last *scheduled* state, so reads within the
|
|
107
|
+
same tick see pending writes. If any changed param in the batch has `history: 'push'`, the
|
|
108
|
+
whole batch uses `router.push`; otherwise `router.replace`. Query keys are sorted for a
|
|
109
|
+
deterministic URL.
|
|
104
110
|
|
|
105
111
|
## Playground
|
|
106
112
|
|
|
@@ -108,8 +114,9 @@ If any changed param in the batch has `history: 'push'`, `router.push` is used;
|
|
|
108
114
|
npm run dev
|
|
109
115
|
```
|
|
110
116
|
|
|
111
|
-
A catalog page exercises every param type plus `reset`/`patch`, and a second route
|
|
112
|
-
`
|
|
117
|
+
A catalog page exercises every param type plus `reset`/`patch`, and a second route shows the
|
|
118
|
+
single-parameter pattern (`toRef` over a one-key schema). The current `route.query` is
|
|
119
|
+
rendered on screen.
|
|
113
120
|
|
|
114
121
|
## License
|
|
115
122
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { useQueryFilters } from './useQueryFilters';
|
|
2
|
-
export { useQueryParam } from './useQueryParam';
|
|
3
2
|
export { param } from './param';
|
|
4
3
|
export { defineCodec } from './defineCodec';
|
|
5
|
-
export type { QueryCodec, ParamOptions, Param, FilterSchema, InferFilters,
|
|
4
|
+
export type { QueryCodec, ParamOptions, Param, FilterSchema, InferFilters, UseQueryFiltersReturn } from './types';
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EACV,UAAU,EACV,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACtB,MAAM,SAAS,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,96 +1,117 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRoute as
|
|
3
|
-
function
|
|
1
|
+
import { reactive as A, computed as N } from "vue";
|
|
2
|
+
import { useRoute as v, useRouter as S } from "vue-router";
|
|
3
|
+
function g(e) {
|
|
4
4
|
if (e != null)
|
|
5
5
|
return Array.isArray(e) ? e.filter((r) => r !== null) : e;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function o(e, r) {
|
|
8
8
|
return e === r ? !0 : Array.isArray(e) && Array.isArray(r) ? e.length !== r.length ? !1 : e.every((t, u) => t === r[u]) : !1;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
let r =
|
|
13
|
-
return r || (r = {
|
|
10
|
+
const h = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
function m(e) {
|
|
12
|
+
let r = h.get(e);
|
|
13
|
+
return r || (r = {
|
|
14
|
+
patch: A(/* @__PURE__ */ new Map()),
|
|
15
|
+
usePush: !1,
|
|
16
|
+
scheduled: !1
|
|
17
|
+
}, h.set(e, r)), r;
|
|
14
18
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
t
|
|
19
|
+
function P(e, r) {
|
|
20
|
+
const t = m(e);
|
|
21
|
+
return t.patch.has(r) ? { pending: !0, value: t.patch.get(r) ?? null } : { pending: !1, value: null };
|
|
22
|
+
}
|
|
23
|
+
function z(e, r, t, u) {
|
|
24
|
+
const l = m(e);
|
|
25
|
+
l.patch.set(r, t), u === "push" && (l.usePush = !0), l.scheduled || (l.scheduled = !0, queueMicrotask(() => q(e)));
|
|
18
26
|
}
|
|
19
|
-
function
|
|
27
|
+
function j(e, r) {
|
|
20
28
|
const t = Object.keys(e), u = Object.keys(r);
|
|
21
29
|
if (t.length !== u.length)
|
|
22
30
|
return !1;
|
|
23
|
-
const
|
|
24
|
-
if (Array.isArray(
|
|
25
|
-
const
|
|
26
|
-
return
|
|
31
|
+
const l = (n, c) => {
|
|
32
|
+
if (Array.isArray(n) || Array.isArray(c)) {
|
|
33
|
+
const a = Array.isArray(n) ? n : [n], s = Array.isArray(c) ? c : [c];
|
|
34
|
+
return a.length === s.length && a.every((i, f) => String(i) === String(s[f]));
|
|
27
35
|
}
|
|
28
|
-
return String(
|
|
36
|
+
return String(n) === String(c);
|
|
29
37
|
};
|
|
30
|
-
return t.every((
|
|
38
|
+
return t.every((n) => n in r && l(e[n], r[n]));
|
|
31
39
|
}
|
|
32
|
-
function
|
|
33
|
-
const r =
|
|
40
|
+
function q(e) {
|
|
41
|
+
const r = h.get(e);
|
|
34
42
|
if (!r)
|
|
35
43
|
return;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
for (const [c, l] of Object.entries(t))
|
|
39
|
-
l !== null && (u[c] = Array.isArray(l) ? l.filter((a) => a !== null) : l);
|
|
40
|
-
r.deletes.forEach((c) => delete u[c]), r.sets.forEach((c, l) => {
|
|
41
|
-
u[l] = c;
|
|
42
|
-
});
|
|
43
|
-
const n = {};
|
|
44
|
-
for (const c of Object.keys(u).sort())
|
|
45
|
-
n[c] = u[c];
|
|
46
|
-
if (v(t, n))
|
|
44
|
+
if (r.scheduled = !1, r.patch.size === 0) {
|
|
45
|
+
r.usePush = !1;
|
|
47
46
|
return;
|
|
48
|
-
|
|
47
|
+
}
|
|
48
|
+
const t = r.usePush;
|
|
49
|
+
r.usePush = !1;
|
|
50
|
+
const u = e.currentRoute.value.query, l = {};
|
|
51
|
+
for (const [i, f] of Object.entries(u))
|
|
52
|
+
f !== null && (l[i] = Array.isArray(f) ? f.filter((b) => b !== null) : f);
|
|
53
|
+
const n = new Map(r.patch);
|
|
54
|
+
n.forEach((i, f) => {
|
|
55
|
+
i === null ? delete l[f] : l[f] = i;
|
|
49
56
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
const c = {};
|
|
58
|
+
for (const i of Object.keys(l).sort())
|
|
59
|
+
c[i] = l[i];
|
|
60
|
+
const a = () => {
|
|
61
|
+
n.forEach((i, f) => {
|
|
62
|
+
r.patch.get(f) === i && r.patch.delete(f);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
if (j(u, c)) {
|
|
66
|
+
a();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
(t ? e.push({ query: c }) : e.replace({ query: c })).then(a, a);
|
|
70
|
+
}
|
|
71
|
+
function O(e, r, t, u) {
|
|
72
|
+
const l = P(r, t);
|
|
73
|
+
let n;
|
|
74
|
+
if (l.pending) {
|
|
75
|
+
if (l.value === null)
|
|
76
|
+
return u.default;
|
|
77
|
+
n = g(l.value);
|
|
78
|
+
} else
|
|
79
|
+
n = g(e.query[t]);
|
|
80
|
+
if (n === void 0)
|
|
81
|
+
return u.default;
|
|
55
82
|
try {
|
|
56
|
-
const
|
|
57
|
-
return
|
|
83
|
+
const c = u.codec.deserialize(n);
|
|
84
|
+
return c === void 0 ? u.default : c;
|
|
58
85
|
} catch {
|
|
59
|
-
return
|
|
86
|
+
return u.default;
|
|
60
87
|
}
|
|
61
88
|
}
|
|
62
|
-
function
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
for (const l of u)
|
|
75
|
-
n[l] = h({
|
|
76
|
-
get: () => g(r.query, l, e[l]),
|
|
77
|
-
set: (a) => i(t, l, e[l], a)
|
|
78
|
-
});
|
|
79
|
-
return b({ ...n, patch: (l) => {
|
|
80
|
-
for (const a of Object.keys(l))
|
|
81
|
-
a in e && i(t, a, e[a], l[a]);
|
|
82
|
-
}, reset: () => {
|
|
83
|
-
for (const l of u)
|
|
84
|
-
i(t, l, e[l], e[l].default);
|
|
85
|
-
} });
|
|
86
|
-
}
|
|
87
|
-
function C(e, r) {
|
|
88
|
-
const t = o(), u = A();
|
|
89
|
-
return h({
|
|
90
|
-
get: () => g(t.query, e, r),
|
|
91
|
-
set: (n) => i(u, e, r, n)
|
|
89
|
+
function y(e, r, t, u) {
|
|
90
|
+
const l = t.codec.serialize(u), n = t.codec.serialize(t.default);
|
|
91
|
+
l === null || o(l, n) ? z(e, r, null, t.history) : z(e, r, l, t.history);
|
|
92
|
+
}
|
|
93
|
+
function k(e, r, t, u) {
|
|
94
|
+
let l = !1, n, c;
|
|
95
|
+
return N({
|
|
96
|
+
get: () => {
|
|
97
|
+
const a = O(e, r, t, u), s = u.codec.serialize(a);
|
|
98
|
+
return l && o(s, c) ? n : (l = !0, n = a, c = s, a);
|
|
99
|
+
},
|
|
100
|
+
set: (a) => y(r, t, u, a)
|
|
92
101
|
});
|
|
93
102
|
}
|
|
103
|
+
function W(e) {
|
|
104
|
+
const r = v(), t = S(), u = Object.keys(e), l = {};
|
|
105
|
+
for (const s of u)
|
|
106
|
+
l[s] = k(r, t, s, e[s]);
|
|
107
|
+
return { filters: A(l), patch: (s) => {
|
|
108
|
+
for (const i of Object.keys(s))
|
|
109
|
+
i in e && y(t, i, e[i], s[i]);
|
|
110
|
+
}, reset: () => {
|
|
111
|
+
for (const s of u)
|
|
112
|
+
y(t, s, e[s], e[s].default);
|
|
113
|
+
} };
|
|
114
|
+
}
|
|
94
115
|
function d(e) {
|
|
95
116
|
return Array.isArray(e) ? e[0] ?? "" : e;
|
|
96
117
|
}
|
|
@@ -100,16 +121,16 @@ function w(e) {
|
|
|
100
121
|
deserialize: (t) => d(t)
|
|
101
122
|
}, default: (e == null ? void 0 : e.default) ?? null, history: (e == null ? void 0 : e.history) ?? "replace" };
|
|
102
123
|
}
|
|
103
|
-
function
|
|
124
|
+
function F(e) {
|
|
104
125
|
return { codec: {
|
|
105
126
|
serialize: (t) => t === null ? null : String(t),
|
|
106
127
|
deserialize: (t) => {
|
|
107
|
-
const u = d(t),
|
|
108
|
-
return u === "" || Number.isNaN(
|
|
128
|
+
const u = d(t), l = Number(u);
|
|
129
|
+
return u === "" || Number.isNaN(l) ? void 0 : l;
|
|
109
130
|
}
|
|
110
131
|
}, default: (e == null ? void 0 : e.default) ?? null, history: (e == null ? void 0 : e.history) ?? "replace" };
|
|
111
132
|
}
|
|
112
|
-
function
|
|
133
|
+
function M(e) {
|
|
113
134
|
return { codec: {
|
|
114
135
|
serialize: (t) => t === null ? null : t ? "true" : "false",
|
|
115
136
|
deserialize: (t) => {
|
|
@@ -127,24 +148,24 @@ function R(e) {
|
|
|
127
148
|
deserialize: (t) => Array.isArray(t) ? [...t] : [t]
|
|
128
149
|
}, default: (e == null ? void 0 : e.default) ?? [], history: (e == null ? void 0 : e.history) ?? "replace" };
|
|
129
150
|
}
|
|
130
|
-
function
|
|
151
|
+
function E(e) {
|
|
131
152
|
return Object.entries(e).filter(([r]) => Number.isNaN(Number(r))).map(([, r]) => r);
|
|
132
153
|
}
|
|
133
|
-
function
|
|
134
|
-
const t = Array.isArray(e) ? [...e] :
|
|
154
|
+
function C(e, r) {
|
|
155
|
+
const t = Array.isArray(e) ? [...e] : E(e), u = new Set(t);
|
|
135
156
|
return { codec: {
|
|
136
|
-
serialize: (
|
|
137
|
-
deserialize: (
|
|
138
|
-
const c = d(
|
|
157
|
+
serialize: (n) => n === null ? null : String(n),
|
|
158
|
+
deserialize: (n) => {
|
|
159
|
+
const c = d(n);
|
|
139
160
|
if (u.has(c))
|
|
140
161
|
return c;
|
|
141
|
-
const
|
|
142
|
-
if (c !== "" && !Number.isNaN(
|
|
143
|
-
return
|
|
162
|
+
const a = Number(c);
|
|
163
|
+
if (c !== "" && !Number.isNaN(a) && u.has(a))
|
|
164
|
+
return a;
|
|
144
165
|
}
|
|
145
166
|
}, default: (r == null ? void 0 : r.default) ?? null, history: (r == null ? void 0 : r.history) ?? "replace" };
|
|
146
167
|
}
|
|
147
|
-
function
|
|
168
|
+
function K(e, r) {
|
|
148
169
|
return {
|
|
149
170
|
codec: {
|
|
150
171
|
serialize: (u) => u === null ? null : e.serialize(u),
|
|
@@ -154,20 +175,19 @@ function F(e, r) {
|
|
|
154
175
|
history: (r == null ? void 0 : r.history) ?? "replace"
|
|
155
176
|
};
|
|
156
177
|
}
|
|
157
|
-
const
|
|
178
|
+
const B = {
|
|
158
179
|
string: w,
|
|
159
|
-
number:
|
|
160
|
-
boolean:
|
|
180
|
+
number: F,
|
|
181
|
+
boolean: M,
|
|
161
182
|
stringArray: R,
|
|
162
|
-
enum:
|
|
163
|
-
custom:
|
|
183
|
+
enum: C,
|
|
184
|
+
custom: K
|
|
164
185
|
};
|
|
165
|
-
function
|
|
186
|
+
function D(e) {
|
|
166
187
|
return e;
|
|
167
188
|
}
|
|
168
189
|
export {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
C as useQueryParam
|
|
190
|
+
D as defineCodec,
|
|
191
|
+
B as param,
|
|
192
|
+
W as useQueryFilters
|
|
173
193
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Router } from 'vue-router';
|
|
2
|
+
type Serialized = string | string[];
|
|
3
|
+
export interface PendingRead {
|
|
4
|
+
pending: boolean;
|
|
5
|
+
value: Serialized | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function readPending(router: Router, key: string): PendingRead;
|
|
8
|
+
export declare function scheduleWrite(router: Router, key: string, value: Serialized | null, history: 'push' | 'replace'): void;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/internal/batch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmC,MAAM,EAAE,MAAM,YAAY,CAAA;AAEzE,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,CAAA;AA2BnC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;CACzB;AAGD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAMpE;AAGD,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,UAAU,GAAG,IAAI,EACxB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAUN"}
|
package/dist/internal/field.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RouteLocationNormalizedLoaded, Router } from 'vue-router';
|
|
2
2
|
import { Param } from '../types';
|
|
3
|
-
export declare function readField<Out>(
|
|
3
|
+
export declare function readField<Out>(route: RouteLocationNormalizedLoaded, router: Router, key: string, p: Param<Out>): Out;
|
|
4
4
|
export declare function writeField<Out>(router: Router, key: string, p: Param<Out>, value: Out): void;
|
|
5
5
|
//# sourceMappingURL=field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/internal/field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/internal/field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAOrC,wBAAgB,SAAS,CAAC,GAAG,EAC3B,KAAK,EAAE,6BAA6B,EACpC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GACZ,GAAG,CAoBL;AAGD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAQ5F"}
|
package/dist/types.d.ts
CHANGED
|
@@ -15,8 +15,9 @@ export type FilterSchema = Record<string, Param<unknown>>;
|
|
|
15
15
|
export type InferFilters<S extends FilterSchema> = {
|
|
16
16
|
[K in keyof S]: S[K] extends Param<infer O> ? O : never;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export interface UseQueryFiltersReturn<S extends FilterSchema> {
|
|
19
|
+
filters: InferFilters<S>;
|
|
19
20
|
patch(partial: Partial<InferFilters<S>>): void;
|
|
20
21
|
reset(): void;
|
|
21
|
-
}
|
|
22
|
+
}
|
|
22
23
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,UAAU,CAAC,CAAC;IAE3B,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAA;IAE7C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;CACnD;AAGD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,OAAO,CAAC,EAAE,CAAC,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B,CAAA;AAGD,MAAM,WAAW,KAAK,CAAC,GAAG;IACxB,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;IACtB,OAAO,EAAE,GAAG,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAGD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;AAGzD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,YAAY,IAAI;KAChD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACxD,CAAA;AAGD,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,UAAU,CAAC,CAAC;IAE3B,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAA;IAE7C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;CACnD;AAGD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,OAAO,CAAC,EAAE,CAAC,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B,CAAA;AAGD,MAAM,WAAW,KAAK,CAAC,GAAG;IACxB,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;IACtB,OAAO,EAAE,GAAG,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAGD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;AAGzD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,YAAY,IAAI;KAChD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACxD,CAAA;AAGD,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,YAAY;IAC3D,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IACxB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAC9C,KAAK,IAAI,IAAI,CAAA;CACd"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FilterSchema,
|
|
2
|
-
export declare function useQueryFilters<S extends FilterSchema>(schema: S):
|
|
1
|
+
import { FilterSchema, UseQueryFiltersReturn } from './types';
|
|
2
|
+
export declare function useQueryFilters<S extends FilterSchema>(schema: S): UseQueryFiltersReturn<S>;
|
|
3
3
|
//# sourceMappingURL=useQueryFilters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryFilters.d.ts","sourceRoot":"","sources":["../src/useQueryFilters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQueryFilters.d.ts","sourceRoot":"","sources":["../src/useQueryFilters.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAuB,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAiCvF,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CA0B3F"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queryQueue.d.ts","sourceRoot":"","sources":["../../src/internal/queryQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmC,MAAM,EAAE,MAAM,YAAY,CAAA;AAsBzE,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EAC/B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAiBN"}
|
package/dist/useQueryParam.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryParam.d.ts","sourceRoot":"","sources":["../src/useQueryParam.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,KAAK,CAAA;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAOvF"}
|