vue-router-query-sync 2.0.0-alpha.0 → 2.0.0-alpha.3
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 +46 -18
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +122 -102
- 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 +6 -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,43 +20,67 @@ 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
|
|
|
63
|
+
### `prefix` — namespacing keys
|
|
64
|
+
|
|
65
|
+
When the same schema is used more than once on a page (e.g. one paginated component per
|
|
66
|
+
tab), pass a `prefix` so each instance owns its own URL keys and they don't collide. Field
|
|
67
|
+
names in `filters` stay unprefixed; only the URL key becomes `${prefix}.${key}`.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
const users = useQueryFilters({ page: param.number({ default: 1 }) }, { prefix: 'users' })
|
|
71
|
+
const orders = useQueryFilters({ page: param.number({ default: 1 }) }, { prefix: 'orders' })
|
|
72
|
+
|
|
73
|
+
users.filters.page = 3 // URL: ?users.page=3
|
|
74
|
+
orders.filters.page = 5 // URL: ?users.page=3&orders.page=5
|
|
75
|
+
|
|
76
|
+
users.filters.page // reads users.page only — independent from orders
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Each instance keeps its own state in the URL, so switching between tabs and back restores
|
|
80
|
+
their pagination; a direct link reproduces everything. If you'd rather keep the URL minimal,
|
|
81
|
+
render inactive tabs with `v-if` and call `reset()` in `onUnmounted` to drop the leaving
|
|
82
|
+
tab's keys.
|
|
83
|
+
|
|
60
84
|
## `param`
|
|
61
85
|
|
|
62
86
|
All options are shared: `{ default?: T; history?: 'push' | 'replace' }` (`history` defaults to
|
|
@@ -98,9 +122,12 @@ const dateCodec = defineCodec<Date | null>({
|
|
|
98
122
|
|
|
99
123
|
## Batching & history
|
|
100
124
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`
|
|
125
|
+
All writes in the same tick — field assignments, `patch`, `reset` — accumulate into one
|
|
126
|
+
pending batch (kept per router instance) and are applied as a **single** navigation via
|
|
127
|
+
`queueMicrotask`. The batch is layered over the last *scheduled* state, so reads within the
|
|
128
|
+
same tick see pending writes. If any changed param in the batch has `history: 'push'`, the
|
|
129
|
+
whole batch uses `router.push`; otherwise `router.replace`. Query keys are sorted for a
|
|
130
|
+
deterministic URL.
|
|
104
131
|
|
|
105
132
|
## Playground
|
|
106
133
|
|
|
@@ -108,8 +135,9 @@ If any changed param in the batch has `history: 'push'`, `router.push` is used;
|
|
|
108
135
|
npm run dev
|
|
109
136
|
```
|
|
110
137
|
|
|
111
|
-
A catalog page exercises every param type plus `reset`/`patch`, and a second route
|
|
112
|
-
`
|
|
138
|
+
A catalog page exercises every param type plus `reset`/`patch`, and a second route shows the
|
|
139
|
+
single-parameter pattern (`toRef` over a one-key schema). The current `route.query` is
|
|
140
|
+
rendered on screen.
|
|
113
141
|
|
|
114
142
|
## License
|
|
115
143
|
|
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, UseQueryFiltersOptions, 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,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,SAAS,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,119 +1,140 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useRoute as
|
|
3
|
-
function
|
|
1
|
+
import { reactive as m, computed as v } from "vue";
|
|
2
|
+
import { useRoute as S, useRouter as P } from "vue-router";
|
|
3
|
+
function A(e) {
|
|
4
4
|
if (e != null)
|
|
5
5
|
return Array.isArray(e) ? e.filter((r) => r !== null) : e;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function b(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 = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
function
|
|
10
|
+
const g = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
function N(e) {
|
|
12
|
+
let r = g.get(e);
|
|
13
|
+
return r || (r = {
|
|
14
|
+
patch: m(/* @__PURE__ */ new Map()),
|
|
15
|
+
usePush: !1,
|
|
16
|
+
scheduled: !1
|
|
17
|
+
}, g.set(e, r)), r;
|
|
18
|
+
}
|
|
19
|
+
function j(e, r) {
|
|
20
|
+
const t = N(e);
|
|
21
|
+
return t.patch.has(r) ? { pending: !0, value: t.patch.get(r) ?? null } : { pending: !1, value: null };
|
|
22
|
+
}
|
|
23
|
+
function o(e, r, t, u) {
|
|
24
|
+
const l = N(e);
|
|
25
|
+
l.patch.set(r, t), u === "push" && (l.usePush = !0), l.scheduled || (l.scheduled = !0, queueMicrotask(() => O(e)));
|
|
26
|
+
}
|
|
27
|
+
function q(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], d = Array.isArray(c) ? c : [c];
|
|
34
|
+
return a.length === d.length && a.every((f, i) => String(f) === String(d[i]));
|
|
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 O(e) {
|
|
41
|
+
const r = g.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 [f, i] of Object.entries(u))
|
|
52
|
+
i !== null && (l[f] = Array.isArray(i) ? i.filter((s) => s !== null) : i);
|
|
53
|
+
const n = new Map(r.patch);
|
|
54
|
+
n.forEach((f, i) => {
|
|
55
|
+
f === null ? delete l[i] : l[i] = f;
|
|
49
56
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
const c = {};
|
|
58
|
+
for (const f of Object.keys(l).sort())
|
|
59
|
+
c[f] = l[f];
|
|
60
|
+
const a = () => {
|
|
61
|
+
n.forEach((f, i) => {
|
|
62
|
+
r.patch.get(i) === f && r.patch.delete(i);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
if (q(u, c)) {
|
|
66
|
+
a();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
(t ? e.push({ query: c }) : e.replace({ query: c })).then(a, a);
|
|
70
|
+
}
|
|
71
|
+
function w(e, r, t, u) {
|
|
72
|
+
const l = j(r, t);
|
|
73
|
+
let n;
|
|
74
|
+
if (l.pending) {
|
|
75
|
+
if (l.value === null)
|
|
76
|
+
return u.default;
|
|
77
|
+
n = A(l.value);
|
|
78
|
+
} else
|
|
79
|
+
n = A(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
|
-
const k = ["patch", "reset"];
|
|
67
|
-
function V(e) {
|
|
68
|
-
for (const l of k)
|
|
69
|
-
if (l in e)
|
|
70
|
-
throw new Error(
|
|
71
|
-
`[vue-router-query-sync] "${l}" is a reserved method name and cannot be used as a param key.`
|
|
72
|
-
);
|
|
73
|
-
const r = o(), t = A(), u = Object.keys(e), n = {};
|
|
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
|
-
} });
|
|
89
|
+
function z(e, r, t, u) {
|
|
90
|
+
const l = t.codec.serialize(u), n = t.codec.serialize(t.default);
|
|
91
|
+
l === null || b(l, n) ? o(e, r, null, t.history) : o(e, r, l, t.history);
|
|
86
92
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
return
|
|
90
|
-
get: () =>
|
|
91
|
-
|
|
93
|
+
function k(e, r, t, u) {
|
|
94
|
+
let l = !1, n, c;
|
|
95
|
+
return v({
|
|
96
|
+
get: () => {
|
|
97
|
+
const a = w(e, r, t, u), d = u.codec.serialize(a);
|
|
98
|
+
return l && b(d, c) ? n : (l = !0, n = a, c = d, a);
|
|
99
|
+
},
|
|
100
|
+
set: (a) => z(r, t, u, a)
|
|
92
101
|
});
|
|
93
102
|
}
|
|
94
|
-
function
|
|
103
|
+
function $(e, r = {}) {
|
|
104
|
+
const t = S(), u = P(), l = Object.keys(e), { prefix: n } = r, c = (s) => n ? `${n}.${s}` : s, a = {};
|
|
105
|
+
for (const s of l)
|
|
106
|
+
a[s] = k(t, u, c(s), e[s]);
|
|
107
|
+
return { filters: m(a), patch: (s) => {
|
|
108
|
+
for (const h of Object.keys(s))
|
|
109
|
+
h in e && z(u, c(h), e[h], s[h]);
|
|
110
|
+
}, reset: () => {
|
|
111
|
+
for (const s of l)
|
|
112
|
+
z(u, c(s), e[s], e[s].default);
|
|
113
|
+
} };
|
|
114
|
+
}
|
|
115
|
+
function y(e) {
|
|
95
116
|
return Array.isArray(e) ? e[0] ?? "" : e;
|
|
96
117
|
}
|
|
97
|
-
function
|
|
118
|
+
function F(e) {
|
|
98
119
|
return { codec: {
|
|
99
120
|
serialize: (t) => t === null || t === "" ? null : t,
|
|
100
|
-
deserialize: (t) =>
|
|
121
|
+
deserialize: (t) => y(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 M(e) {
|
|
104
125
|
return { codec: {
|
|
105
126
|
serialize: (t) => t === null ? null : String(t),
|
|
106
127
|
deserialize: (t) => {
|
|
107
|
-
const u =
|
|
108
|
-
return u === "" || Number.isNaN(
|
|
128
|
+
const u = y(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 R(e) {
|
|
113
134
|
return { codec: {
|
|
114
135
|
serialize: (t) => t === null ? null : t ? "true" : "false",
|
|
115
136
|
deserialize: (t) => {
|
|
116
|
-
const u =
|
|
137
|
+
const u = y(t);
|
|
117
138
|
if (u === "true")
|
|
118
139
|
return !0;
|
|
119
140
|
if (u === "false")
|
|
@@ -121,30 +142,30 @@ function O(e) {
|
|
|
121
142
|
}
|
|
122
143
|
}, default: (e == null ? void 0 : e.default) ?? null, history: (e == null ? void 0 : e.history) ?? "replace" };
|
|
123
144
|
}
|
|
124
|
-
function
|
|
145
|
+
function E(e) {
|
|
125
146
|
return { codec: {
|
|
126
147
|
serialize: (t) => t.length === 0 ? null : [...t],
|
|
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 K(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] : K(e), u = new Set(t);
|
|
135
156
|
return { codec: {
|
|
136
|
-
serialize: (
|
|
137
|
-
deserialize: (
|
|
138
|
-
const c =
|
|
157
|
+
serialize: (n) => n === null ? null : String(n),
|
|
158
|
+
deserialize: (n) => {
|
|
159
|
+
const c = y(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 Q(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
|
|
158
|
-
string:
|
|
159
|
-
number:
|
|
160
|
-
boolean:
|
|
161
|
-
stringArray:
|
|
162
|
-
enum:
|
|
163
|
-
custom:
|
|
178
|
+
const B = {
|
|
179
|
+
string: F,
|
|
180
|
+
number: M,
|
|
181
|
+
boolean: R,
|
|
182
|
+
stringArray: E,
|
|
183
|
+
enum: C,
|
|
184
|
+
custom: Q
|
|
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
|
+
$ 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,12 @@ 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 UseQueryFiltersOptions {
|
|
19
|
+
prefix?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface UseQueryFiltersReturn<S extends FilterSchema> {
|
|
22
|
+
filters: InferFilters<S>;
|
|
19
23
|
patch(partial: Partial<InferFilters<S>>): void;
|
|
20
24
|
reset(): void;
|
|
21
|
-
}
|
|
25
|
+
}
|
|
22
26
|
//# 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,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,sBAAsB;IAGrC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;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, UseQueryFiltersOptions, UseQueryFiltersReturn } from './types';
|
|
2
|
+
export declare function useQueryFilters<S extends FilterSchema>(schema: S, options?: UseQueryFiltersOptions): 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,EACV,YAAY,EAGZ,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAiChB,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACpD,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CAAC,CAAC,CAAC,CA6B1B"}
|
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"}
|