@phoenix-cg/v-filters 0.3.0-beta.1 → 0.3.0-beta.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/dist/v-filters.es.js +205 -205
- package/dist/v-filters.umd.js +1 -1
- package/package.json +1 -1
- package/src/components/VFilters.vue +16 -19
package/dist/v-filters.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
1
|
+
import { ref as M, computed as x, watch as K, createElementBlock as N, openBlock as w, createElementVNode as Ae, renderSlot as C, Fragment as je, renderList as be, createBlock as k, resolveDynamicComponent as P, normalizeClass as Ee, withCtx as H, mergeProps as Ie, normalizeProps as G, guardReactiveProps as J, createCommentVNode as Q, toDisplayString as xe, nextTick as Ne } from "vue";
|
|
2
|
+
const Ce = (e, r) => {
|
|
3
3
|
let t = [1, 0, 2, 2, 2, 1];
|
|
4
4
|
return r[e % 100 > 4 && e % 100 < 20 ? 1 : t[e % 10 < 5 ? e % 10 : 5]];
|
|
5
|
-
},
|
|
6
|
-
function
|
|
5
|
+
}, qe = (e) => Object.prototype.toString.call(e).slice(8, -1), oe = "%[a-f0-9]{2}", X = new RegExp("(" + oe + ")|([^%]+?)", "gi"), Y = new RegExp("(" + oe + ")+", "gi");
|
|
6
|
+
function R(e, r) {
|
|
7
7
|
try {
|
|
8
8
|
return [decodeURIComponent(e.join(""))];
|
|
9
9
|
} catch {
|
|
@@ -12,32 +12,32 @@ function U(e, r) {
|
|
|
12
12
|
return e;
|
|
13
13
|
r = r || 1;
|
|
14
14
|
const t = e.slice(0, r), n = e.slice(r);
|
|
15
|
-
return Array.prototype.concat.call([],
|
|
15
|
+
return Array.prototype.concat.call([], R(t), R(n));
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function $e(e) {
|
|
18
18
|
try {
|
|
19
19
|
return decodeURIComponent(e);
|
|
20
20
|
} catch {
|
|
21
|
-
let r = e.match(
|
|
21
|
+
let r = e.match(X) || [];
|
|
22
22
|
for (let t = 1; t < r.length; t++)
|
|
23
|
-
e =
|
|
23
|
+
e = R(r, t).join(""), r = e.match(X) || [];
|
|
24
24
|
return e;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function ve(e) {
|
|
28
28
|
const r = {
|
|
29
29
|
"%FE%FF": "��",
|
|
30
30
|
"%FF%FE": "��"
|
|
31
31
|
};
|
|
32
|
-
let t =
|
|
32
|
+
let t = Y.exec(e);
|
|
33
33
|
for (; t; ) {
|
|
34
34
|
try {
|
|
35
35
|
r[t[0]] = decodeURIComponent(t[0]);
|
|
36
36
|
} catch {
|
|
37
|
-
const a =
|
|
37
|
+
const a = $e(t[0]);
|
|
38
38
|
a !== t[0] && (r[t[0]] = a);
|
|
39
39
|
}
|
|
40
|
-
t =
|
|
40
|
+
t = Y.exec(e);
|
|
41
41
|
}
|
|
42
42
|
r["%C2"] = "�";
|
|
43
43
|
const n = Object.keys(r);
|
|
@@ -45,16 +45,16 @@ function Pe(e) {
|
|
|
45
45
|
e = e.replace(new RegExp(a, "g"), r[a]);
|
|
46
46
|
return e;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function ke(e) {
|
|
49
49
|
if (typeof e != "string")
|
|
50
50
|
throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof e + "`");
|
|
51
51
|
try {
|
|
52
52
|
return decodeURIComponent(e);
|
|
53
53
|
} catch {
|
|
54
|
-
return
|
|
54
|
+
return ve(e);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Pe(e, r) {
|
|
58
58
|
const t = {};
|
|
59
59
|
if (Array.isArray(r))
|
|
60
60
|
for (const n of r) {
|
|
@@ -71,7 +71,7 @@ function Ve(e, r) {
|
|
|
71
71
|
}
|
|
72
72
|
return t;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function le(e, r) {
|
|
75
75
|
if (!(typeof e == "string" && typeof r == "string"))
|
|
76
76
|
throw new TypeError("Expected the arguments to be of type `string`");
|
|
77
77
|
if (e === "" || r === "")
|
|
@@ -82,8 +82,8 @@ function fe(e, r) {
|
|
|
82
82
|
e.slice(t + r.length)
|
|
83
83
|
];
|
|
84
84
|
}
|
|
85
|
-
const
|
|
86
|
-
function
|
|
85
|
+
const Ve = (e) => e == null, Re = (e) => encodeURIComponent(e).replaceAll(/[!'()*]/g, (r) => `%${r.charCodeAt(0).toString(16).toUpperCase()}`), U = Symbol("encodeFragmentIdentifier");
|
|
86
|
+
function Ue(e) {
|
|
87
87
|
switch (e.arrayFormat) {
|
|
88
88
|
case "index":
|
|
89
89
|
return (r) => (t, n) => {
|
|
@@ -128,7 +128,7 @@ function Te(e) {
|
|
|
128
128
|
];
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function De(e) {
|
|
132
132
|
let r;
|
|
133
133
|
switch (e.arrayFormat) {
|
|
134
134
|
case "index":
|
|
@@ -166,19 +166,19 @@ function Be(e) {
|
|
|
166
166
|
case "comma":
|
|
167
167
|
case "separator":
|
|
168
168
|
return (t, n, a) => {
|
|
169
|
-
const i = typeof n == "string" && n.includes(e.arrayFormatSeparator), u = typeof n == "string" && !i &&
|
|
170
|
-
n = u ?
|
|
171
|
-
const
|
|
172
|
-
a[t] =
|
|
169
|
+
const i = typeof n == "string" && n.includes(e.arrayFormatSeparator), u = typeof n == "string" && !i && F(n, e).includes(e.arrayFormatSeparator);
|
|
170
|
+
n = u ? F(n, e) : n;
|
|
171
|
+
const c = i || u ? n.split(e.arrayFormatSeparator).map((y) => F(y, e)) : n === null ? n : F(n, e);
|
|
172
|
+
a[t] = c;
|
|
173
173
|
};
|
|
174
174
|
case "bracket-separator":
|
|
175
175
|
return (t, n, a) => {
|
|
176
176
|
const i = /(\[])$/.test(t);
|
|
177
177
|
if (t = t.replace(/\[]$/, ""), !i) {
|
|
178
|
-
a[t] = n &&
|
|
178
|
+
a[t] = n && F(n, e);
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
|
-
const u = n === null ? [] :
|
|
181
|
+
const u = n === null ? [] : F(n, e).split(e.arrayFormatSeparator);
|
|
182
182
|
if (a[t] === void 0) {
|
|
183
183
|
a[t] = u;
|
|
184
184
|
return;
|
|
@@ -195,37 +195,37 @@ function Be(e) {
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function fe(e) {
|
|
199
199
|
if (typeof e != "string" || e.length !== 1)
|
|
200
200
|
throw new TypeError("arrayFormatSeparator must be single character string");
|
|
201
201
|
}
|
|
202
202
|
function f(e, r) {
|
|
203
|
-
return r.encode ? r.strict ?
|
|
203
|
+
return r.encode ? r.strict ? Re(e) : encodeURIComponent(e) : e;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
return r.decode ?
|
|
205
|
+
function F(e, r) {
|
|
206
|
+
return r.decode ? ke(e) : e;
|
|
207
207
|
}
|
|
208
|
-
function
|
|
209
|
-
return Array.isArray(e) ? e.sort() : typeof e == "object" ?
|
|
208
|
+
function de(e) {
|
|
209
|
+
return Array.isArray(e) ? e.sort() : typeof e == "object" ? de(Object.keys(e)).sort((r, t) => Number(r) - Number(t)).map((r) => e[r]) : e;
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function me(e) {
|
|
212
212
|
const r = e.indexOf("#");
|
|
213
213
|
return r !== -1 && (e = e.slice(0, r)), e;
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function Te(e) {
|
|
216
216
|
let r = "";
|
|
217
217
|
const t = e.indexOf("#");
|
|
218
218
|
return t !== -1 && (r = e.slice(t)), r;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function Z(e, r, t) {
|
|
221
221
|
return t === "string" && typeof e == "string" ? e : typeof t == "function" && typeof e == "string" ? t(e) : r.parseBooleans && e !== null && (e.toLowerCase() === "true" || e.toLowerCase() === "false") ? e.toLowerCase() === "true" : t === "number" && !Number.isNaN(Number(e)) && typeof e == "string" && e.trim() !== "" || r.parseNumbers && !Number.isNaN(Number(e)) && typeof e == "string" && e.trim() !== "" ? Number(e) : e;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
e =
|
|
223
|
+
function D(e) {
|
|
224
|
+
e = me(e);
|
|
225
225
|
const r = e.indexOf("?");
|
|
226
226
|
return r === -1 ? "" : e.slice(r + 1);
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function T(e, r) {
|
|
229
229
|
r = {
|
|
230
230
|
decode: !0,
|
|
231
231
|
sort: !0,
|
|
@@ -235,30 +235,30 @@ function L(e, r) {
|
|
|
235
235
|
parseBooleans: !1,
|
|
236
236
|
types: /* @__PURE__ */ Object.create(null),
|
|
237
237
|
...r
|
|
238
|
-
},
|
|
239
|
-
const t =
|
|
238
|
+
}, fe(r.arrayFormatSeparator);
|
|
239
|
+
const t = De(r), n = /* @__PURE__ */ Object.create(null);
|
|
240
240
|
if (typeof e != "string" || (e = e.trim().replace(/^[?#&]/, ""), !e))
|
|
241
241
|
return n;
|
|
242
242
|
for (const a of e.split("&")) {
|
|
243
243
|
if (a === "")
|
|
244
244
|
continue;
|
|
245
245
|
const i = r.decode ? a.replaceAll("+", " ") : a;
|
|
246
|
-
let [u,
|
|
247
|
-
u === void 0 && (u = i),
|
|
246
|
+
let [u, c] = le(i, "=");
|
|
247
|
+
u === void 0 && (u = i), c = c === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(r.arrayFormat) ? c : F(c, r), t(F(u, r), c, n);
|
|
248
248
|
}
|
|
249
249
|
for (const [a, i] of Object.entries(n))
|
|
250
250
|
if (typeof i == "object" && i !== null && r.types[a] !== "string")
|
|
251
|
-
for (const [u,
|
|
252
|
-
const
|
|
253
|
-
i[u] =
|
|
251
|
+
for (const [u, c] of Object.entries(i)) {
|
|
252
|
+
const y = r.types[a] ? r.types[a].replace("[]", "") : void 0;
|
|
253
|
+
i[u] = Z(c, r, y);
|
|
254
254
|
}
|
|
255
|
-
else typeof i == "object" && i !== null && r.types[a] === "string" ? n[a] = Object.values(i).join(r.arrayFormatSeparator) : n[a] =
|
|
255
|
+
else typeof i == "object" && i !== null && r.types[a] === "string" ? n[a] = Object.values(i).join(r.arrayFormatSeparator) : n[a] = Z(i, r, r.types[a]);
|
|
256
256
|
return r.sort === !1 ? n : (r.sort === !0 ? Object.keys(n).sort() : Object.keys(n).sort(r.sort)).reduce((a, i) => {
|
|
257
257
|
const u = n[i];
|
|
258
|
-
return a[i] = u && typeof u == "object" && !Array.isArray(u) ?
|
|
258
|
+
return a[i] = u && typeof u == "object" && !Array.isArray(u) ? de(u) : u, a;
|
|
259
259
|
}, /* @__PURE__ */ Object.create(null));
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function ye(e, r) {
|
|
262
262
|
if (!e)
|
|
263
263
|
return "";
|
|
264
264
|
r = {
|
|
@@ -267,75 +267,75 @@ function ge(e, r) {
|
|
|
267
267
|
arrayFormat: "none",
|
|
268
268
|
arrayFormatSeparator: ",",
|
|
269
269
|
...r
|
|
270
|
-
},
|
|
271
|
-
const t = (u) => r.skipNull &&
|
|
272
|
-
for (const [u,
|
|
273
|
-
t(u) || (a[u] =
|
|
270
|
+
}, fe(r.arrayFormatSeparator);
|
|
271
|
+
const t = (u) => r.skipNull && Ve(e[u]) || r.skipEmptyString && e[u] === "", n = Ue(r), a = {};
|
|
272
|
+
for (const [u, c] of Object.entries(e))
|
|
273
|
+
t(u) || (a[u] = c);
|
|
274
274
|
const i = Object.keys(a);
|
|
275
275
|
return r.sort !== !1 && i.sort(r.sort), i.map((u) => {
|
|
276
|
-
const
|
|
277
|
-
return
|
|
276
|
+
const c = e[u];
|
|
277
|
+
return c === void 0 ? "" : c === null ? f(u, r) : Array.isArray(c) ? c.length === 0 && r.arrayFormat === "bracket-separator" ? f(u, r) + "[]" : c.reduce(n(u), []).join("&") : f(u, r) + "=" + f(c, r);
|
|
278
278
|
}).filter((u) => u.length > 0).join("&");
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function ge(e, r) {
|
|
281
281
|
var a;
|
|
282
282
|
r = {
|
|
283
283
|
decode: !0,
|
|
284
284
|
...r
|
|
285
285
|
};
|
|
286
|
-
let [t, n] =
|
|
286
|
+
let [t, n] = le(e, "#");
|
|
287
287
|
return t === void 0 && (t = e), {
|
|
288
288
|
url: ((a = t == null ? void 0 : t.split("?")) == null ? void 0 : a[0]) ?? "",
|
|
289
|
-
query:
|
|
290
|
-
...r && r.parseFragmentIdentifier && n ? { fragmentIdentifier:
|
|
289
|
+
query: T(D(e), r),
|
|
290
|
+
...r && r.parseFragmentIdentifier && n ? { fragmentIdentifier: F(n, r) } : {}
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function pe(e, r) {
|
|
294
294
|
r = {
|
|
295
295
|
encode: !0,
|
|
296
296
|
strict: !0,
|
|
297
|
-
[
|
|
297
|
+
[U]: !0,
|
|
298
298
|
...r
|
|
299
299
|
};
|
|
300
|
-
const t =
|
|
301
|
-
...
|
|
300
|
+
const t = me(e.url).split("?")[0] || "", n = D(e.url), a = {
|
|
301
|
+
...T(n, { sort: !1 }),
|
|
302
302
|
...e.query
|
|
303
303
|
};
|
|
304
|
-
let i =
|
|
304
|
+
let i = ye(a, r);
|
|
305
305
|
i && (i = `?${i}`);
|
|
306
|
-
let u =
|
|
306
|
+
let u = Te(e.url);
|
|
307
307
|
if (typeof e.fragmentIdentifier == "string") {
|
|
308
|
-
const
|
|
309
|
-
|
|
308
|
+
const c = new URL(t);
|
|
309
|
+
c.hash = e.fragmentIdentifier, u = r[U] ? c.hash : `#${e.fragmentIdentifier}`;
|
|
310
310
|
}
|
|
311
311
|
return `${t}${i}${u}`;
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function he(e, r, t) {
|
|
314
314
|
t = {
|
|
315
315
|
parseFragmentIdentifier: !0,
|
|
316
|
-
[
|
|
316
|
+
[U]: !1,
|
|
317
317
|
...t
|
|
318
318
|
};
|
|
319
|
-
const { url: n, query: a, fragmentIdentifier: i } =
|
|
320
|
-
return
|
|
319
|
+
const { url: n, query: a, fragmentIdentifier: i } = ge(e, t);
|
|
320
|
+
return pe({
|
|
321
321
|
url: n,
|
|
322
|
-
query:
|
|
322
|
+
query: Pe(a, r),
|
|
323
323
|
fragmentIdentifier: i
|
|
324
324
|
}, t);
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function Be(e, r, t) {
|
|
327
327
|
const n = Array.isArray(r) ? (a) => !r.includes(a) : (a, i) => !r(a, i);
|
|
328
|
-
return
|
|
328
|
+
return he(e, n, t);
|
|
329
329
|
}
|
|
330
|
-
const
|
|
330
|
+
const ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
331
331
|
__proto__: null,
|
|
332
|
-
exclude:
|
|
333
|
-
extract:
|
|
334
|
-
parse:
|
|
335
|
-
parseUrl:
|
|
336
|
-
pick:
|
|
337
|
-
stringify:
|
|
338
|
-
stringifyUrl:
|
|
332
|
+
exclude: Be,
|
|
333
|
+
extract: D,
|
|
334
|
+
parse: T,
|
|
335
|
+
parseUrl: ge,
|
|
336
|
+
pick: he,
|
|
337
|
+
stringify: ye,
|
|
338
|
+
stringifyUrl: pe
|
|
339
339
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
340
340
|
function O(e) {
|
|
341
341
|
return e != null && typeof e == "object" && e["@@functional/placeholder"] === !0;
|
|
@@ -345,7 +345,7 @@ function S(e) {
|
|
|
345
345
|
return arguments.length === 0 || O(t) ? r : e.apply(this, arguments);
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function Le(e) {
|
|
349
349
|
return function r(t, n) {
|
|
350
350
|
switch (arguments.length) {
|
|
351
351
|
case 0:
|
|
@@ -363,12 +363,12 @@ function We(e) {
|
|
|
363
363
|
}
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function re(e) {
|
|
367
367
|
for (var r = [], t; !(t = e.next()).done; )
|
|
368
368
|
r.push(t.value);
|
|
369
369
|
return r;
|
|
370
370
|
}
|
|
371
|
-
function
|
|
371
|
+
function te(e, r, t) {
|
|
372
372
|
for (var n = 0, a = t.length; n < a; ) {
|
|
373
373
|
if (e(r, t[n]))
|
|
374
374
|
return !0;
|
|
@@ -376,63 +376,63 @@ function ne(e, r, t) {
|
|
|
376
376
|
}
|
|
377
377
|
return !1;
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function ze(e) {
|
|
380
380
|
var r = String(e).match(/^function (\w*)/);
|
|
381
381
|
return r == null ? "" : r[1];
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function q(e, r) {
|
|
384
384
|
return Object.prototype.hasOwnProperty.call(r, e);
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function We(e, r) {
|
|
387
387
|
return e === r ? e !== 0 || 1 / e === 1 / r : e !== e && r !== r;
|
|
388
388
|
}
|
|
389
|
-
const
|
|
390
|
-
var
|
|
391
|
-
return
|
|
392
|
-
return
|
|
389
|
+
const V = typeof Object.is == "function" ? Object.is : We;
|
|
390
|
+
var ne = Object.prototype.toString, Me = /* @__PURE__ */ function() {
|
|
391
|
+
return ne.call(arguments) === "[object Arguments]" ? function(r) {
|
|
392
|
+
return ne.call(r) === "[object Arguments]";
|
|
393
393
|
} : function(r) {
|
|
394
|
-
return
|
|
394
|
+
return q("callee", r);
|
|
395
395
|
};
|
|
396
|
-
}(),
|
|
396
|
+
}(), Ke = !/* @__PURE__ */ {
|
|
397
397
|
toString: null
|
|
398
|
-
}.propertyIsEnumerable("toString"),
|
|
398
|
+
}.propertyIsEnumerable("toString"), ae = ["constructor", "valueOf", "isPrototypeOf", "toString", "propertyIsEnumerable", "hasOwnProperty", "toLocaleString"], se = /* @__PURE__ */ function() {
|
|
399
399
|
return arguments.propertyIsEnumerable("length");
|
|
400
|
-
}(),
|
|
400
|
+
}(), He = function(r, t) {
|
|
401
401
|
for (var n = 0; n < r.length; ) {
|
|
402
402
|
if (r[n] === t)
|
|
403
403
|
return !0;
|
|
404
404
|
n += 1;
|
|
405
405
|
}
|
|
406
406
|
return !1;
|
|
407
|
-
},
|
|
407
|
+
}, ie = /* @__PURE__ */ S(typeof Object.keys == "function" && !se ? function(r) {
|
|
408
408
|
return Object(r) !== r ? [] : Object.keys(r);
|
|
409
409
|
} : function(r) {
|
|
410
410
|
if (Object(r) !== r)
|
|
411
411
|
return [];
|
|
412
|
-
var t, n, a = [], i =
|
|
412
|
+
var t, n, a = [], i = se && Me(r);
|
|
413
413
|
for (t in r)
|
|
414
|
-
|
|
415
|
-
if (
|
|
416
|
-
for (n =
|
|
417
|
-
t =
|
|
414
|
+
q(t, r) && (!i || t !== "length") && (a[a.length] = t);
|
|
415
|
+
if (Ke)
|
|
416
|
+
for (n = ae.length - 1; n >= 0; )
|
|
417
|
+
t = ae[n], q(t, r) && !He(a, t) && (a[a.length] = t), n -= 1;
|
|
418
418
|
return a;
|
|
419
|
-
}),
|
|
419
|
+
}), ue = /* @__PURE__ */ S(function(r) {
|
|
420
420
|
return r === null ? "Null" : r === void 0 ? "Undefined" : Object.prototype.toString.call(r).slice(8, -1);
|
|
421
421
|
});
|
|
422
|
-
function
|
|
423
|
-
var a =
|
|
424
|
-
function u(
|
|
425
|
-
return
|
|
422
|
+
function ce(e, r, t, n) {
|
|
423
|
+
var a = re(e), i = re(r);
|
|
424
|
+
function u(c, y) {
|
|
425
|
+
return B(c, y, t.slice(), n.slice());
|
|
426
426
|
}
|
|
427
|
-
return !
|
|
428
|
-
return !
|
|
427
|
+
return !te(function(c, y) {
|
|
428
|
+
return !te(u, y, c);
|
|
429
429
|
}, i, a);
|
|
430
430
|
}
|
|
431
|
-
function
|
|
432
|
-
if (
|
|
431
|
+
function B(e, r, t, n) {
|
|
432
|
+
if (V(e, r))
|
|
433
433
|
return !0;
|
|
434
|
-
var a =
|
|
435
|
-
if (a !==
|
|
434
|
+
var a = ue(e);
|
|
435
|
+
if (a !== ue(r))
|
|
436
436
|
return !1;
|
|
437
437
|
if (typeof e["fantasy-land/equals"] == "function" || typeof r["fantasy-land/equals"] == "function")
|
|
438
438
|
return typeof e["fantasy-land/equals"] == "function" && e["fantasy-land/equals"](r) && typeof r["fantasy-land/equals"] == "function" && r["fantasy-land/equals"](e);
|
|
@@ -442,17 +442,17 @@ function z(e, r, t, n) {
|
|
|
442
442
|
case "Arguments":
|
|
443
443
|
case "Array":
|
|
444
444
|
case "Object":
|
|
445
|
-
if (typeof e.constructor == "function" &&
|
|
445
|
+
if (typeof e.constructor == "function" && ze(e.constructor) === "Promise")
|
|
446
446
|
return e === r;
|
|
447
447
|
break;
|
|
448
448
|
case "Boolean":
|
|
449
449
|
case "Number":
|
|
450
450
|
case "String":
|
|
451
|
-
if (!(typeof e == typeof r &&
|
|
451
|
+
if (!(typeof e == typeof r && V(e.valueOf(), r.valueOf())))
|
|
452
452
|
return !1;
|
|
453
453
|
break;
|
|
454
454
|
case "Date":
|
|
455
|
-
if (!
|
|
455
|
+
if (!V(e.valueOf(), r.valueOf()))
|
|
456
456
|
return !1;
|
|
457
457
|
break;
|
|
458
458
|
case "Error":
|
|
@@ -469,9 +469,9 @@ function z(e, r, t, n) {
|
|
|
469
469
|
}
|
|
470
470
|
switch (a) {
|
|
471
471
|
case "Map":
|
|
472
|
-
return e.size !== r.size ? !1 :
|
|
472
|
+
return e.size !== r.size ? !1 : ce(e.entries(), r.entries(), t.concat([e]), n.concat([r]));
|
|
473
473
|
case "Set":
|
|
474
|
-
return e.size !== r.size ? !1 :
|
|
474
|
+
return e.size !== r.size ? !1 : ce(e.values(), r.values(), t.concat([e]), n.concat([r]));
|
|
475
475
|
case "Arguments":
|
|
476
476
|
case "Array":
|
|
477
477
|
case "Object":
|
|
@@ -495,22 +495,22 @@ function z(e, r, t, n) {
|
|
|
495
495
|
default:
|
|
496
496
|
return !1;
|
|
497
497
|
}
|
|
498
|
-
var u =
|
|
499
|
-
if (u.length !==
|
|
498
|
+
var u = ie(e);
|
|
499
|
+
if (u.length !== ie(r).length)
|
|
500
500
|
return !1;
|
|
501
|
-
var
|
|
501
|
+
var c = t.concat([e]), y = n.concat([r]);
|
|
502
502
|
for (i = u.length - 1; i >= 0; ) {
|
|
503
|
-
var
|
|
504
|
-
if (!(
|
|
503
|
+
var _ = u[i];
|
|
504
|
+
if (!(q(_, r) && B(r[_], e[_], c, y)))
|
|
505
505
|
return !1;
|
|
506
506
|
i -= 1;
|
|
507
507
|
}
|
|
508
508
|
return !0;
|
|
509
509
|
}
|
|
510
|
-
var
|
|
511
|
-
return
|
|
510
|
+
var Ge = /* @__PURE__ */ Le(function(r, t) {
|
|
511
|
+
return B(r, t, [], []);
|
|
512
512
|
});
|
|
513
|
-
const
|
|
513
|
+
const Je = { class: "v-filters" }, Qe = { class: "v-filters_fields" }, Ye = {
|
|
514
514
|
__name: "VFilters",
|
|
515
515
|
props: {
|
|
516
516
|
componentsMap: {
|
|
@@ -587,148 +587,148 @@ const Xe = { class: "v-filters" }, Ye = { class: "v-filters_fields" }, er = {
|
|
|
587
587
|
},
|
|
588
588
|
emits: ["reset-filters", "request-count", "show-result"],
|
|
589
589
|
setup(e, { emit: r }) {
|
|
590
|
-
const t = e, n =
|
|
591
|
-
let
|
|
590
|
+
const t = e, n = r, a = (o) => ee.stringify(o, { arrayFormat: "index", encode: !1 }), i = (o) => ee.parse(o, { arrayFormat: "index" }), u = M({}), c = M([]), y = x(() => c.value.length > 0), _ = x(() => y.value || t.editedOutside), Fe = x(() => {
|
|
591
|
+
let o = t.notFoundTitle;
|
|
592
592
|
if (t.count > 0) {
|
|
593
|
-
const d = t.showWords.length && t.isResultShown ? t.showWords[1] :
|
|
594
|
-
|
|
593
|
+
const d = t.showWords.length && t.isResultShown ? t.showWords[1] : t.showWords[0], s = Ce(t.count, t.declensionWords);
|
|
594
|
+
o = `${d + " " || ""}${t.count} ${s}`;
|
|
595
595
|
}
|
|
596
|
-
return
|
|
597
|
-
}), j =
|
|
598
|
-
const
|
|
599
|
-
return Object.keys(
|
|
596
|
+
return o;
|
|
597
|
+
}), j = x(() => {
|
|
598
|
+
const o = { ...t.filterParamsToInclude }, d = [...c.value, ...t.alwaysSendFields];
|
|
599
|
+
return Object.keys(u.value).forEach((s) => {
|
|
600
600
|
if (d.includes(s) || t.sendAllFields) {
|
|
601
|
-
const l =
|
|
602
|
-
|
|
601
|
+
const l = u.value[s], p = qe(l) === "Object" ? [l] : l;
|
|
602
|
+
o[s] = p.map((h) => h._id || h);
|
|
603
603
|
}
|
|
604
|
-
}),
|
|
604
|
+
}), o;
|
|
605
605
|
});
|
|
606
|
-
function
|
|
607
|
-
const d =
|
|
608
|
-
|
|
606
|
+
function L(o) {
|
|
607
|
+
const d = W();
|
|
608
|
+
t.fields.forEach((s) => {
|
|
609
609
|
let l = s._type === "range" ? s.value : [];
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
s._type !== "range" ? (l = s.data.reduce((
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
-
}, []),
|
|
617
|
-
} else d[s._name] &&
|
|
618
|
-
let
|
|
610
|
+
const p = t.notArrayValueFields.includes(s._type);
|
|
611
|
+
if (p && ([l] = s.value), d[s._name] && !o) {
|
|
612
|
+
const m = d[s._name];
|
|
613
|
+
s._type !== "range" ? (l = s.data.reduce((g, E) => {
|
|
614
|
+
const I = E._id || E;
|
|
615
|
+
return m.includes(I.toString()) && g.push(E), g;
|
|
616
|
+
}, []), p && ([l] = l)) : l = m, v(s._name);
|
|
617
|
+
} else d[s._name] && o && s._type !== "range" ? p ? s.data.some((g) => g._id === l._id || g._id === l) || (l = s.data[0]) : l = s.value.reduce((m, g) => (s.data.some((I) => I._id === g._id || I._id === g) && m.push(g), m), []) : (!d[s._name] || o) && p ? [l] = s.value : (!d[s._name] || o) && (l = s.value);
|
|
618
|
+
let h = !1;
|
|
619
619
|
switch (s._type) {
|
|
620
620
|
case "range":
|
|
621
|
-
|
|
621
|
+
h = s.data.map((m, g) => s.value[g] === m).some((m) => !m);
|
|
622
622
|
break;
|
|
623
623
|
case "select":
|
|
624
624
|
case "tab":
|
|
625
|
-
|
|
625
|
+
h = s.value.length > 0 && s.value[0]._id !== s.data[0]._id;
|
|
626
626
|
break;
|
|
627
627
|
case "checkbox":
|
|
628
|
-
|
|
628
|
+
h = s.value.length > 0;
|
|
629
629
|
break;
|
|
630
630
|
}
|
|
631
|
-
|
|
632
|
-
}), !
|
|
631
|
+
h && v(s._name), u.value[s._name] = l;
|
|
632
|
+
}), !o && b(), !o && z(!0);
|
|
633
633
|
}
|
|
634
|
-
async function
|
|
635
|
-
|
|
634
|
+
async function $() {
|
|
635
|
+
c.value = [], b(!0, {}), await Ne(), n("reset-filters", j.value);
|
|
636
636
|
}
|
|
637
|
-
function
|
|
638
|
-
|
|
637
|
+
function v(o) {
|
|
638
|
+
c.value.includes(o) || c.value.push(o);
|
|
639
639
|
}
|
|
640
|
-
function
|
|
641
|
-
|
|
640
|
+
function _e(o) {
|
|
641
|
+
c.value = c.value.filter((d) => d !== o);
|
|
642
642
|
}
|
|
643
|
-
function
|
|
644
|
-
if (
|
|
645
|
-
const s =
|
|
646
|
-
|
|
643
|
+
function we(o) {
|
|
644
|
+
if (t.fields.find((s) => s._name === o).reset) {
|
|
645
|
+
const s = t.fields.filter((l) => !l.reset).map((l) => l._name);
|
|
646
|
+
c.value = c.value.filter((l) => !s.includes(l));
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
function
|
|
650
|
-
|
|
649
|
+
function z(o = !1) {
|
|
650
|
+
o || t.immediate ? A() : Oe();
|
|
651
651
|
}
|
|
652
|
-
function
|
|
653
|
-
|
|
652
|
+
function Oe() {
|
|
653
|
+
n("request-count", j.value);
|
|
654
654
|
}
|
|
655
655
|
function A() {
|
|
656
|
-
b(),
|
|
656
|
+
b(), n("show-result", j.value);
|
|
657
657
|
}
|
|
658
|
-
function
|
|
659
|
-
return
|
|
658
|
+
function W() {
|
|
659
|
+
return i(window.location.search);
|
|
660
660
|
}
|
|
661
|
-
function b(
|
|
661
|
+
function b(o, d) {
|
|
662
662
|
if (t.showParams) {
|
|
663
|
-
const s = d || { ...j.value, ...
|
|
664
|
-
if ((
|
|
665
|
-
const
|
|
666
|
-
history.replaceState({ state:
|
|
663
|
+
const s = d || { ...j.value, ...t.paramsToInclude }, l = W(), p = Object.keys(s).length;
|
|
664
|
+
if ((p && !Ge(s, l) || o || d) && !t.humanLink) {
|
|
665
|
+
const h = a(s), m = window.location.origin + window.location.pathname + `${p ? "?" : ""}${h}`;
|
|
666
|
+
history.replaceState({ state: m }, "", m);
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
-
function
|
|
671
|
-
d !== null ? (
|
|
670
|
+
function Se(o, d) {
|
|
671
|
+
d !== null ? (v(o), we(o)) : _e(o), z();
|
|
672
672
|
}
|
|
673
|
-
return
|
|
674
|
-
|
|
675
|
-
}),
|
|
673
|
+
return K(() => t.fields, () => {
|
|
674
|
+
L(!0);
|
|
675
|
+
}, { deep: !0 }), K(() => t.paramsToInclude, () => {
|
|
676
676
|
b(!0);
|
|
677
|
-
}),
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
(w(!0),
|
|
677
|
+
}, { deep: !0 }), L(), (o, d) => (w(), N("div", Je, [
|
|
678
|
+
Ae("div", Qe, [
|
|
679
|
+
C(o.$slots, "before-fields"),
|
|
680
|
+
(w(!0), N(je, null, be(t.fields, (s) => (w(), k(P(t.fieldComponentName), {
|
|
681
681
|
key: s._name,
|
|
682
|
-
class:
|
|
682
|
+
class: Ee([`__${s._name}`]),
|
|
683
683
|
title: s.title
|
|
684
684
|
}, {
|
|
685
|
-
default:
|
|
686
|
-
(w(),
|
|
685
|
+
default: H(() => [
|
|
686
|
+
(w(), k(P(t.componentsMap[s._type]), Ie({
|
|
687
687
|
key: e.fieldKey,
|
|
688
|
-
modelValue:
|
|
689
|
-
"onUpdate:modelValue": (l) =>
|
|
688
|
+
modelValue: u.value[s._name],
|
|
689
|
+
"onUpdate:modelValue": (l) => u.value[s._name] = l,
|
|
690
690
|
ref_for: !0
|
|
691
691
|
}, s._fieldProps || {}, {
|
|
692
|
-
|
|
693
|
-
}), null, 16, ["modelValue", "onUpdate:modelValue"
|
|
692
|
+
"onUpdate:modelValue": (l) => Se(s._name, l)
|
|
693
|
+
}), null, 16, ["modelValue", "onUpdate:modelValue"]))
|
|
694
694
|
]),
|
|
695
695
|
_: 2
|
|
696
696
|
}, 1032, ["class", "title"]))), 128)),
|
|
697
|
-
|
|
698
|
-
|
|
697
|
+
C(o.$slots, "after-fields"),
|
|
698
|
+
C(o.$slots, "actions", G(J({
|
|
699
699
|
showResult: A,
|
|
700
|
-
resetFilters:
|
|
700
|
+
resetFilters: $,
|
|
701
701
|
count: t.count,
|
|
702
702
|
immediate: t.immediate,
|
|
703
|
-
edited:
|
|
703
|
+
edited: _.value
|
|
704
704
|
})), () => [
|
|
705
|
-
(w(),
|
|
706
|
-
default:
|
|
707
|
-
e.immediate ?
|
|
705
|
+
(w(), k(P(t.fieldComponentName), null, {
|
|
706
|
+
default: H(() => [
|
|
707
|
+
e.immediate ? Q("", !0) : (w(), N("button", {
|
|
708
708
|
key: 0,
|
|
709
709
|
class: "v-button v-filters_button",
|
|
710
710
|
onClick: A
|
|
711
|
-
},
|
|
712
|
-
|
|
711
|
+
}, xe(Fe.value), 1)),
|
|
712
|
+
_.value ? (w(), N("button", {
|
|
713
713
|
key: 1,
|
|
714
714
|
class: "v-button v-filters_button __reset",
|
|
715
|
-
onClick:
|
|
716
|
-
}, " Сбросить параметры ")) :
|
|
715
|
+
onClick: $
|
|
716
|
+
}, " Сбросить параметры ")) : Q("", !0)
|
|
717
717
|
]),
|
|
718
718
|
_: 1
|
|
719
719
|
}))
|
|
720
720
|
])
|
|
721
721
|
]),
|
|
722
|
-
|
|
722
|
+
C(o.$slots, "actions-after", G(J({
|
|
723
723
|
showResult: A,
|
|
724
|
-
resetFilters:
|
|
724
|
+
resetFilters: $,
|
|
725
725
|
count: t.count,
|
|
726
726
|
immediate: t.immediate,
|
|
727
|
-
edited:
|
|
727
|
+
edited: _.value
|
|
728
728
|
})))
|
|
729
729
|
]));
|
|
730
730
|
}
|
|
731
731
|
};
|
|
732
732
|
export {
|
|
733
|
-
|
|
733
|
+
Ye as default
|
|
734
734
|
};
|
package/dist/v-filters.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,A){typeof exports=="object"&&typeof module<"u"?module.exports=A(require("vue")):typeof define=="function"&&define.amd?define(["vue"],A):(s=typeof globalThis<"u"?globalThis:s||self,s.VFilters=A(s.Vue))})(this,function(s){"use strict";const A=(e,r)=>{let t=[1,0,2,2,2,1];return r[e%100>4&&e%100<20?1:t[e%10<5?e%10:5]]},le=e=>Object.prototype.toString.call(e).slice(8,-1),T="%[a-f0-9]{2}",U=new RegExp("("+T+")|([^%]+?)","gi"),z=new RegExp("("+T+")+","gi");function k(e,r){try{return[decodeURIComponent(e.join(""))]}catch{}if(e.length===1)return e;r=r||1;const t=e.slice(0,r),n=e.slice(r);return Array.prototype.concat.call([],k(t),k(n))}function ue(e){try{return decodeURIComponent(e)}catch{let r=e.match(U)||[];for(let t=1;t<r.length;t++)e=k(r,t).join(""),r=e.match(U)||[];return e}}function fe(e){const r={"%FE%FF":"��","%FF%FE":"��"};let t=z.exec(e);for(;t;){try{r[t[0]]=decodeURIComponent(t[0])}catch{const a=ue(t[0]);a!==t[0]&&(r[t[0]]=a)}t=z.exec(e)}r["%C2"]="�";const n=Object.keys(r);for(const a of n)e=e.replace(new RegExp(a,"g"),r[a]);return e}function de(e){if(typeof e!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return fe(e)}}function me(e,r){const t={};if(Array.isArray(r))for(const n of r){const a=Object.getOwnPropertyDescriptor(e,n);a!=null&&a.enumerable&&Object.defineProperty(t,n,a)}else for(const n of Reflect.ownKeys(e)){const a=Object.getOwnPropertyDescriptor(e,n);if(a.enumerable){const i=e[n];r(n,i,e)&&Object.defineProperty(t,n,a)}}return t}function L(e,r){if(!(typeof e=="string"&&typeof r=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e===""||r==="")return[];const t=e.indexOf(r);return t===-1?[]:[e.slice(0,t),e.slice(t+r.length)]}const ye=e=>e==null,pe=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`),N=Symbol("encodeFragmentIdentifier");function ge(e){switch(e.arrayFormat){case"index":return r=>(t,n)=>{const a=t.length;return n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[d(r,e),"[",a,"]"].join("")]:[...t,[d(r,e),"[",d(a,e),"]=",d(n,e)].join("")]};case"bracket":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[d(r,e),"[]"].join("")]:[...t,[d(r,e),"[]=",d(n,e)].join("")];case"colon-list-separator":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[d(r,e),":list="].join("")]:[...t,[d(r,e),":list=",d(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const r=e.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(n,a)=>a===void 0||e.skipNull&&a===null||e.skipEmptyString&&a===""?n:(a=a===null?"":a,n.length===0?[[d(t,e),r,d(a,e)].join("")]:[[n,d(a,e)].join(e.arrayFormatSeparator)])}default:return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,d(r,e)]:[...t,[d(r,e),"=",d(n,e)].join("")]}}function he(e){let r;switch(e.arrayFormat){case"index":return(t,n,a)=>{if(r=/\[(\d*)]$/.exec(t),t=t.replace(/\[\d*]$/,""),!r){a[t]=n;return}a[t]===void 0&&(a[t]={}),a[t][r[1]]=n};case"bracket":return(t,n,a)=>{if(r=/(\[])$/.exec(t),t=t.replace(/\[]$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"colon-list-separator":return(t,n,a)=>{if(r=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"comma":case"separator":return(t,n,a)=>{const i=typeof n=="string"&&n.includes(e.arrayFormatSeparator),o=typeof n=="string"&&!i&&F(n,e).includes(e.arrayFormatSeparator);n=o?F(n,e):n;const u=i||o?n.split(e.arrayFormatSeparator).map(y=>F(y,e)):n===null?n:F(n,e);a[t]=u};case"bracket-separator":return(t,n,a)=>{const i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!i){a[t]=n&&F(n,e);return}const o=n===null?[]:F(n,e).split(e.arrayFormatSeparator);if(a[t]===void 0){a[t]=o;return}a[t]=[...a[t],...o]};default:return(t,n,a)=>{if(a[t]===void 0){a[t]=n;return}a[t]=[...[a[t]].flat(),n]}}}function W(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function d(e,r){return r.encode?r.strict?pe(e):encodeURIComponent(e):e}function F(e,r){return r.decode?de(e):e}function M(e){return Array.isArray(e)?e.sort():typeof e=="object"?M(Object.keys(e)).sort((r,t)=>Number(r)-Number(t)).map(r=>e[r]):e}function K(e){const r=e.indexOf("#");return r!==-1&&(e=e.slice(0,r)),e}function Fe(e){let r="";const t=e.indexOf("#");return t!==-1&&(r=e.slice(t)),r}function H(e,r,t){return t==="string"&&typeof e=="string"?e:typeof t=="function"&&typeof e=="string"?t(e):r.parseBooleans&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":t==="number"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""||r.parseNumbers&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):e}function q(e){e=K(e);const r=e.indexOf("?");return r===-1?"":e.slice(r+1)}function $(e,r){r={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...r},W(r.arrayFormatSeparator);const t=he(r),n=Object.create(null);if(typeof e!="string"||(e=e.trim().replace(/^[?#&]/,""),!e))return n;for(const a of e.split("&")){if(a==="")continue;const i=r.decode?a.replaceAll("+"," "):a;let[o,u]=L(i,"=");o===void 0&&(o=i),u=u===void 0?null:["comma","separator","bracket-separator"].includes(r.arrayFormat)?u:F(u,r),t(F(o,r),u,n)}for(const[a,i]of Object.entries(n))if(typeof i=="object"&&i!==null&&r.types[a]!=="string")for(const[o,u]of Object.entries(i)){const y=r.types[a]?r.types[a].replace("[]",""):void 0;i[o]=H(u,r,y)}else typeof i=="object"&&i!==null&&r.types[a]==="string"?n[a]=Object.values(i).join(r.arrayFormatSeparator):n[a]=H(i,r,r.types[a]);return r.sort===!1?n:(r.sort===!0?Object.keys(n).sort():Object.keys(n).sort(r.sort)).reduce((a,i)=>{const o=n[i];return a[i]=o&&typeof o=="object"&&!Array.isArray(o)?M(o):o,a},Object.create(null))}function G(e,r){if(!e)return"";r={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...r},W(r.arrayFormatSeparator);const t=o=>r.skipNull&&ye(e[o])||r.skipEmptyString&&e[o]==="",n=ge(r),a={};for(const[o,u]of Object.entries(e))t(o)||(a[o]=u);const i=Object.keys(a);return r.sort!==!1&&i.sort(r.sort),i.map(o=>{const u=e[o];return u===void 0?"":u===null?d(o,r):Array.isArray(u)?u.length===0&&r.arrayFormat==="bracket-separator"?d(o,r)+"[]":u.reduce(n(o),[]).join("&"):d(o,r)+"="+d(u,r)}).filter(o=>o.length>0).join("&")}function J(e,r){var a;r={decode:!0,...r};let[t,n]=L(e,"#");return t===void 0&&(t=e),{url:((a=t==null?void 0:t.split("?"))==null?void 0:a[0])??"",query:$(q(e),r),...r&&r.parseFragmentIdentifier&&n?{fragmentIdentifier:F(n,r)}:{}}}function Q(e,r){r={encode:!0,strict:!0,[N]:!0,...r};const t=K(e.url).split("?")[0]||"",n=q(e.url),a={...$(n,{sort:!1}),...e.query};let i=G(a,r);i&&(i=`?${i}`);let o=Fe(e.url);if(typeof e.fragmentIdentifier=="string"){const u=new URL(t);u.hash=e.fragmentIdentifier,o=r[N]?u.hash:`#${e.fragmentIdentifier}`}return`${t}${i}${o}`}function X(e,r,t){t={parseFragmentIdentifier:!0,[N]:!1,...t};const{url:n,query:a,fragmentIdentifier:i}=J(e,t);return Q({url:n,query:me(a,r),fragmentIdentifier:i},t)}function _e(e,r,t){const n=Array.isArray(r)?a=>!r.includes(a):(a,i)=>!r(a,i);return X(e,n,t)}const Y=Object.freeze(Object.defineProperty({__proto__:null,exclude:_e,extract:q,parse:$,parseUrl:J,pick:X,stringify:G,stringifyUrl:Q},Symbol.toStringTag,{value:"Module"}));function S(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function O(e){return function r(t){return arguments.length===0||S(t)?r:e.apply(this,arguments)}}function we(e){return function r(t,n){switch(arguments.length){case 0:return r;case 1:return S(t)?r:O(function(a){return e(t,a)});default:return S(t)&&S(n)?r:S(t)?O(function(a){return e(a,n)}):S(n)?O(function(a){return e(t,a)}):e(t,n)}}}function Z(e){for(var r=[],t;!(t=e.next()).done;)r.push(t.value);return r}function v(e,r,t){for(var n=0,a=t.length;n<a;){if(e(r,t[n]))return!0;n+=1}return!1}function Se(e){var r=String(e).match(/^function (\w*)/);return r==null?"":r[1]}function E(e,r){return Object.prototype.hasOwnProperty.call(r,e)}function Oe(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}const B=typeof Object.is=="function"?Object.is:Oe;var ee=Object.prototype.toString,Ae=function(){return ee.call(arguments)==="[object Arguments]"?function(r){return ee.call(r)==="[object Arguments]"}:function(r){return E("callee",r)}}(),je=!{toString:null}.propertyIsEnumerable("toString"),re=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],te=function(){return arguments.propertyIsEnumerable("length")}(),Ee=function(r,t){for(var n=0;n<r.length;){if(r[n]===t)return!0;n+=1}return!1},ne=O(typeof Object.keys=="function"&&!te?function(r){return Object(r)!==r?[]:Object.keys(r)}:function(r){if(Object(r)!==r)return[];var t,n,a=[],i=te&&Ae(r);for(t in r)E(t,r)&&(!i||t!=="length")&&(a[a.length]=t);if(je)for(n=re.length-1;n>=0;)t=re[n],E(t,r)&&!Ee(a,t)&&(a[a.length]=t),n-=1;return a}),ae=O(function(r){return r===null?"Null":r===void 0?"Undefined":Object.prototype.toString.call(r).slice(8,-1)});function se(e,r,t,n){var a=Z(e),i=Z(r);function o(u,y){return P(u,y,t.slice(),n.slice())}return!v(function(u,y){return!v(o,y,u)},i,a)}function P(e,r,t,n){if(B(e,r))return!0;var a=ae(e);if(a!==ae(r))return!1;if(typeof e["fantasy-land/equals"]=="function"||typeof r["fantasy-land/equals"]=="function")return typeof e["fantasy-land/equals"]=="function"&&e["fantasy-land/equals"](r)&&typeof r["fantasy-land/equals"]=="function"&&r["fantasy-land/equals"](e);if(typeof e.equals=="function"||typeof r.equals=="function")return typeof e.equals=="function"&&e.equals(r)&&typeof r.equals=="function"&&r.equals(e);switch(a){case"Arguments":case"Array":case"Object":if(typeof e.constructor=="function"&&Se(e.constructor)==="Promise")return e===r;break;case"Boolean":case"Number":case"String":if(!(typeof e==typeof r&&B(e.valueOf(),r.valueOf())))return!1;break;case"Date":if(!B(e.valueOf(),r.valueOf()))return!1;break;case"Error":return e.name===r.name&&e.message===r.message;case"RegExp":if(!(e.source===r.source&&e.global===r.global&&e.ignoreCase===r.ignoreCase&&e.multiline===r.multiline&&e.sticky===r.sticky&&e.unicode===r.unicode))return!1;break}for(var i=t.length-1;i>=0;){if(t[i]===e)return n[i]===r;i-=1}switch(a){case"Map":return e.size!==r.size?!1:se(e.entries(),r.entries(),t.concat([e]),n.concat([r]));case"Set":return e.size!==r.size?!1:se(e.values(),r.values(),t.concat([e]),n.concat([r]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=ne(e);if(o.length!==ne(r).length)return!1;var u=t.concat([e]),y=n.concat([r]);for(i=o.length-1;i>=0;){var p=o[i];if(!(E(p,r)&&P(r[p],e[p],u,y)))return!1;i-=1}return!0}var be=we(function(r,t){return P(r,t,[],[])});const Ie={class:"v-filters"},xe={class:"v-filters_fields"};return{__name:"VFilters",props:{componentsMap:{type:Object,required:!0},fieldComponentName:{type:String,default:"v-filter-field"},declensionWords:{type:Array,default:()=>[]},showWords:{type:Array,default:()=>[]},notFoundTitle:{type:String,default:""},fields:{type:Array,required:!0},count:{type:Number,default:0},showParams:{type:Boolean,default:!0},isResultShown:{type:Boolean,default:!1},humanLink:{type:Object},editedOutside:{type:Boolean,defualt:!1},immediate:{type:Boolean,default:!1},fieldKey:{type:[String,Number],default:"1"},alwaysSendFields:{type:Array,default:()=>[]},paramsToInclude:{type:Object,default:()=>({})},filterParamsToInclude:{type:Object,default:()=>({})},notArrayValueFields:{type:Array,default:()=>["select","tab"]},sendAllFields:{type:Boolean,default:!1}},emits:["reset-filters","request-count","show-result"],setup(e,{emit:r}){const t=e,n=s.ref(t.fields),a=s.ref(t.paramsToInclude),i=r,o=l=>Y.stringify(l,{arrayFormat:"index",encode:!1}),u=l=>Y.parse(l,{arrayFormat:"index"}),y=s.ref({}),p=s.ref([]),Ce=s.computed(()=>p.value.length>0),V=s.computed(()=>Ce.value||t.editedOutside),ke=s.computed(()=>{let l=t.notFoundTitle;if(t.count>0){const m=t.showWords.length&&t.isResultShown?t.showWords[1]:prosp.showWords[0],c=A(t.count,t.declensionWords);l=`${m+" "||""}${t.count} ${c}`}return l}),b=s.computed(()=>{const l={...t.filterParamsToInclude},m=[...p.value,...t.alwaysSendFields];return Object.keys(l).forEach(c=>{if(m.includes(c)||t.sendAllFields){const f=t.filters[c],_=le(f)==="Object"?[f]:f;l[c]=_.map(w=>w._id||w)}}),l});function ce(l){const m=oe();n.value.forEach(c=>{let f=c._type==="range"?c.value:[];const _=t.notArrayValueFields.includes(c._type);if(_&&([f]=c.value),m[c._name]&&!l){const g=m[c._name];c._type!=="range"?(f=c.data.reduce((h,x)=>{const C=x._id||x;return g.includes(C.toString())&&h.push(x),h},[]),_&&([f]=f)):f=g,R(c._name)}else m[c._name]&&l&&c._type!=="range"?_?c.data.some(h=>h._id===f._id||h._id===f)||(f=c.data[0]):f=c.value.reduce((g,h)=>(c.data.some(C=>C._id===h._id||C._id===h)&&g.push(h),g),[]):(!m[c._name]||l)&&_?[f]=c.value:(!m[c._name]||l)&&(f=c.value);let w=!1;switch(c._type){case"range":w=c.data.map((g,h)=>c.value[h]===g).some(g=>!g);break;case"select":case"tab":w=c.value.length>0&&c.value[0]._id!==c.data[0]._id;break;case"checkbox":w=c.value.length>0;break}w&&R(c._name),y.value[c._name]=f}),!l&&I(),!l&&ie(!0)}async function D(){p.value=[],I(!0,{}),await s.nextTick(),i("reset-filters",b.value)}function R(l){p.value.includes(l)||p.value.push(l)}function Ne(l){p.value=p.value.filter(m=>m!==l)}function qe(l){if(n.value.find(c=>c._name===l).reset){const c=n.value.filter(f=>!f.reset).map(f=>f._name);p.value=p.value.filter(f=>!c.includes(f))}}function ie(l=!1){l||t.immediate?j():$e()}function $e(){i("request-count",b.value)}function j(){I(),i("show-result",b.value)}function oe(){return u(window.location.search)}function I(l,m){if(t.showParams){const c=m||{...b.value,...a.value},f=oe(),_=Object.keys(c).length;if((_&&!be(c,f)||l||m)&&!t.humanLink){const w=o(c),g=window.location.origin+window.location.pathname+`${_?"?":""}${w}`;history.replaceState({state:g},"",g)}}}function Be(l,m){m!==null?(R(l),qe(l)):Ne(l),ie()}return s.watch(n,()=>{ce(!0)}),s.watch(a,()=>{I(!0)}),ce(),(l,m)=>(s.openBlock(),s.createElementBlock("div",Ie,[s.createElementVNode("div",xe,[s.renderSlot(l.$slots,"before-fields"),(s.openBlock(!0),s.createElementBlock(s.Fragment,null,s.renderList(n.value,c=>(s.openBlock(),s.createBlock(s.resolveDynamicComponent(t.fieldComponentName),{key:c._name,class:s.normalizeClass([`__${c._name}`]),title:c.title},{default:s.withCtx(()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(t.componentsMap[c._type]),s.mergeProps({key:e.fieldKey,modelValue:y.value[c._name],"onUpdate:modelValue":f=>y.value[c._name]=f,ref_for:!0},c._fieldProps||{},{onInput:f=>Be(c._name,f)}),null,16,["modelValue","onUpdate:modelValue","onInput"]))]),_:2},1032,["class","title"]))),128)),s.renderSlot(l.$slots,"after-fields"),s.renderSlot(l.$slots,"actions",s.normalizeProps(s.guardReactiveProps({showResult:j,resetFilters:D,count:t.count,immediate:t.immediate,edited:V.value})),()=>[(s.openBlock(),s.createBlock(s.resolveDynamicComponent(t.fieldComponentName),null,{default:s.withCtx(()=>[e.immediate?s.createCommentVNode("",!0):(s.openBlock(),s.createElementBlock("button",{key:0,class:"v-button v-filters_button",onClick:j},s.toDisplayString(ke.value),1)),V.value?(s.openBlock(),s.createElementBlock("button",{key:1,class:"v-button v-filters_button __reset",onClick:D}," Сбросить параметры ")):s.createCommentVNode("",!0)]),_:1}))])]),s.renderSlot(l.$slots,"actions-after",s.normalizeProps(s.guardReactiveProps({showResult:j,resetFilters:D,count:t.count,immediate:t.immediate,edited:V.value})))]))}}});
|
|
1
|
+
(function(i,A){typeof exports=="object"&&typeof module<"u"?module.exports=A(require("vue")):typeof define=="function"&&define.amd?define(["vue"],A):(i=typeof globalThis<"u"?globalThis:i||self,i.VFilters=A(i.Vue))})(this,function(i){"use strict";const A=(e,r)=>{let t=[1,0,2,2,2,1];return r[e%100>4&&e%100<20?1:t[e%10<5?e%10:5]]},oe=e=>Object.prototype.toString.call(e).slice(8,-1),R="%[a-f0-9]{2}",U=new RegExp("("+R+")|([^%]+?)","gi"),T=new RegExp("("+R+")+","gi");function k(e,r){try{return[decodeURIComponent(e.join(""))]}catch{}if(e.length===1)return e;r=r||1;const t=e.slice(0,r),n=e.slice(r);return Array.prototype.concat.call([],k(t),k(n))}function le(e){try{return decodeURIComponent(e)}catch{let r=e.match(U)||[];for(let t=1;t<r.length;t++)e=k(r,t).join(""),r=e.match(U)||[];return e}}function ue(e){const r={"%FE%FF":"��","%FF%FE":"��"};let t=T.exec(e);for(;t;){try{r[t[0]]=decodeURIComponent(t[0])}catch{const a=le(t[0]);a!==t[0]&&(r[t[0]]=a)}t=T.exec(e)}r["%C2"]="�";const n=Object.keys(r);for(const a of n)e=e.replace(new RegExp(a,"g"),r[a]);return e}function fe(e){if(typeof e!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return ue(e)}}function de(e,r){const t={};if(Array.isArray(r))for(const n of r){const a=Object.getOwnPropertyDescriptor(e,n);a!=null&&a.enumerable&&Object.defineProperty(t,n,a)}else for(const n of Reflect.ownKeys(e)){const a=Object.getOwnPropertyDescriptor(e,n);if(a.enumerable){const c=e[n];r(n,c,e)&&Object.defineProperty(t,n,a)}}return t}function z(e,r){if(!(typeof e=="string"&&typeof r=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e===""||r==="")return[];const t=e.indexOf(r);return t===-1?[]:[e.slice(0,t),e.slice(t+r.length)]}const me=e=>e==null,ye=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`),N=Symbol("encodeFragmentIdentifier");function pe(e){switch(e.arrayFormat){case"index":return r=>(t,n)=>{const a=t.length;return n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[d(r,e),"[",a,"]"].join("")]:[...t,[d(r,e),"[",d(a,e),"]=",d(n,e)].join("")]};case"bracket":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[d(r,e),"[]"].join("")]:[...t,[d(r,e),"[]=",d(n,e)].join("")];case"colon-list-separator":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[d(r,e),":list="].join("")]:[...t,[d(r,e),":list=",d(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const r=e.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(n,a)=>a===void 0||e.skipNull&&a===null||e.skipEmptyString&&a===""?n:(a=a===null?"":a,n.length===0?[[d(t,e),r,d(a,e)].join("")]:[[n,d(a,e)].join(e.arrayFormatSeparator)])}default:return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,d(r,e)]:[...t,[d(r,e),"=",d(n,e)].join("")]}}function ge(e){let r;switch(e.arrayFormat){case"index":return(t,n,a)=>{if(r=/\[(\d*)]$/.exec(t),t=t.replace(/\[\d*]$/,""),!r){a[t]=n;return}a[t]===void 0&&(a[t]={}),a[t][r[1]]=n};case"bracket":return(t,n,a)=>{if(r=/(\[])$/.exec(t),t=t.replace(/\[]$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"colon-list-separator":return(t,n,a)=>{if(r=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"comma":case"separator":return(t,n,a)=>{const c=typeof n=="string"&&n.includes(e.arrayFormatSeparator),o=typeof n=="string"&&!c&&h(n,e).includes(e.arrayFormatSeparator);n=o?h(n,e):n;const l=c||o?n.split(e.arrayFormatSeparator).map(p=>h(p,e)):n===null?n:h(n,e);a[t]=l};case"bracket-separator":return(t,n,a)=>{const c=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!c){a[t]=n&&h(n,e);return}const o=n===null?[]:h(n,e).split(e.arrayFormatSeparator);if(a[t]===void 0){a[t]=o;return}a[t]=[...a[t],...o]};default:return(t,n,a)=>{if(a[t]===void 0){a[t]=n;return}a[t]=[...[a[t]].flat(),n]}}}function L(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function d(e,r){return r.encode?r.strict?ye(e):encodeURIComponent(e):e}function h(e,r){return r.decode?fe(e):e}function W(e){return Array.isArray(e)?e.sort():typeof e=="object"?W(Object.keys(e)).sort((r,t)=>Number(r)-Number(t)).map(r=>e[r]):e}function M(e){const r=e.indexOf("#");return r!==-1&&(e=e.slice(0,r)),e}function he(e){let r="";const t=e.indexOf("#");return t!==-1&&(r=e.slice(t)),r}function K(e,r,t){return t==="string"&&typeof e=="string"?e:typeof t=="function"&&typeof e=="string"?t(e):r.parseBooleans&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":t==="number"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""||r.parseNumbers&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):e}function q(e){e=M(e);const r=e.indexOf("?");return r===-1?"":e.slice(r+1)}function $(e,r){r={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...r},L(r.arrayFormatSeparator);const t=ge(r),n=Object.create(null);if(typeof e!="string"||(e=e.trim().replace(/^[?#&]/,""),!e))return n;for(const a of e.split("&")){if(a==="")continue;const c=r.decode?a.replaceAll("+"," "):a;let[o,l]=z(c,"=");o===void 0&&(o=c),l=l===void 0?null:["comma","separator","bracket-separator"].includes(r.arrayFormat)?l:h(l,r),t(h(o,r),l,n)}for(const[a,c]of Object.entries(n))if(typeof c=="object"&&c!==null&&r.types[a]!=="string")for(const[o,l]of Object.entries(c)){const p=r.types[a]?r.types[a].replace("[]",""):void 0;c[o]=K(l,r,p)}else typeof c=="object"&&c!==null&&r.types[a]==="string"?n[a]=Object.values(c).join(r.arrayFormatSeparator):n[a]=K(c,r,r.types[a]);return r.sort===!1?n:(r.sort===!0?Object.keys(n).sort():Object.keys(n).sort(r.sort)).reduce((a,c)=>{const o=n[c];return a[c]=o&&typeof o=="object"&&!Array.isArray(o)?W(o):o,a},Object.create(null))}function H(e,r){if(!e)return"";r={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...r},L(r.arrayFormatSeparator);const t=o=>r.skipNull&&me(e[o])||r.skipEmptyString&&e[o]==="",n=pe(r),a={};for(const[o,l]of Object.entries(e))t(o)||(a[o]=l);const c=Object.keys(a);return r.sort!==!1&&c.sort(r.sort),c.map(o=>{const l=e[o];return l===void 0?"":l===null?d(o,r):Array.isArray(l)?l.length===0&&r.arrayFormat==="bracket-separator"?d(o,r)+"[]":l.reduce(n(o),[]).join("&"):d(o,r)+"="+d(l,r)}).filter(o=>o.length>0).join("&")}function G(e,r){var a;r={decode:!0,...r};let[t,n]=z(e,"#");return t===void 0&&(t=e),{url:((a=t==null?void 0:t.split("?"))==null?void 0:a[0])??"",query:$(q(e),r),...r&&r.parseFragmentIdentifier&&n?{fragmentIdentifier:h(n,r)}:{}}}function J(e,r){r={encode:!0,strict:!0,[N]:!0,...r};const t=M(e.url).split("?")[0]||"",n=q(e.url),a={...$(n,{sort:!1}),...e.query};let c=H(a,r);c&&(c=`?${c}`);let o=he(e.url);if(typeof e.fragmentIdentifier=="string"){const l=new URL(t);l.hash=e.fragmentIdentifier,o=r[N]?l.hash:`#${e.fragmentIdentifier}`}return`${t}${c}${o}`}function Q(e,r,t){t={parseFragmentIdentifier:!0,[N]:!1,...t};const{url:n,query:a,fragmentIdentifier:c}=G(e,t);return J({url:n,query:de(a,r),fragmentIdentifier:c},t)}function Fe(e,r,t){const n=Array.isArray(r)?a=>!r.includes(a):(a,c)=>!r(a,c);return Q(e,n,t)}const X=Object.freeze(Object.defineProperty({__proto__:null,exclude:Fe,extract:q,parse:$,parseUrl:G,pick:Q,stringify:H,stringifyUrl:J},Symbol.toStringTag,{value:"Module"}));function S(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function O(e){return function r(t){return arguments.length===0||S(t)?r:e.apply(this,arguments)}}function _e(e){return function r(t,n){switch(arguments.length){case 0:return r;case 1:return S(t)?r:O(function(a){return e(t,a)});default:return S(t)&&S(n)?r:S(t)?O(function(a){return e(a,n)}):S(n)?O(function(a){return e(t,a)}):e(t,n)}}}function Y(e){for(var r=[],t;!(t=e.next()).done;)r.push(t.value);return r}function Z(e,r,t){for(var n=0,a=t.length;n<a;){if(e(r,t[n]))return!0;n+=1}return!1}function we(e){var r=String(e).match(/^function (\w*)/);return r==null?"":r[1]}function E(e,r){return Object.prototype.hasOwnProperty.call(r,e)}function Se(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}const B=typeof Object.is=="function"?Object.is:Se;var v=Object.prototype.toString,Oe=function(){return v.call(arguments)==="[object Arguments]"?function(r){return v.call(r)==="[object Arguments]"}:function(r){return E("callee",r)}}(),Ae=!{toString:null}.propertyIsEnumerable("toString"),ee=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],re=function(){return arguments.propertyIsEnumerable("length")}(),je=function(r,t){for(var n=0;n<r.length;){if(r[n]===t)return!0;n+=1}return!1},te=O(typeof Object.keys=="function"&&!re?function(r){return Object(r)!==r?[]:Object.keys(r)}:function(r){if(Object(r)!==r)return[];var t,n,a=[],c=re&&Oe(r);for(t in r)E(t,r)&&(!c||t!=="length")&&(a[a.length]=t);if(Ae)for(n=ee.length-1;n>=0;)t=ee[n],E(t,r)&&!je(a,t)&&(a[a.length]=t),n-=1;return a}),ne=O(function(r){return r===null?"Null":r===void 0?"Undefined":Object.prototype.toString.call(r).slice(8,-1)});function ae(e,r,t,n){var a=Y(e),c=Y(r);function o(l,p){return P(l,p,t.slice(),n.slice())}return!Z(function(l,p){return!Z(o,p,l)},c,a)}function P(e,r,t,n){if(B(e,r))return!0;var a=ne(e);if(a!==ne(r))return!1;if(typeof e["fantasy-land/equals"]=="function"||typeof r["fantasy-land/equals"]=="function")return typeof e["fantasy-land/equals"]=="function"&&e["fantasy-land/equals"](r)&&typeof r["fantasy-land/equals"]=="function"&&r["fantasy-land/equals"](e);if(typeof e.equals=="function"||typeof r.equals=="function")return typeof e.equals=="function"&&e.equals(r)&&typeof r.equals=="function"&&r.equals(e);switch(a){case"Arguments":case"Array":case"Object":if(typeof e.constructor=="function"&&we(e.constructor)==="Promise")return e===r;break;case"Boolean":case"Number":case"String":if(!(typeof e==typeof r&&B(e.valueOf(),r.valueOf())))return!1;break;case"Date":if(!B(e.valueOf(),r.valueOf()))return!1;break;case"Error":return e.name===r.name&&e.message===r.message;case"RegExp":if(!(e.source===r.source&&e.global===r.global&&e.ignoreCase===r.ignoreCase&&e.multiline===r.multiline&&e.sticky===r.sticky&&e.unicode===r.unicode))return!1;break}for(var c=t.length-1;c>=0;){if(t[c]===e)return n[c]===r;c-=1}switch(a){case"Map":return e.size!==r.size?!1:ae(e.entries(),r.entries(),t.concat([e]),n.concat([r]));case"Set":return e.size!==r.size?!1:ae(e.values(),r.values(),t.concat([e]),n.concat([r]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=te(e);if(o.length!==te(r).length)return!1;var l=t.concat([e]),p=n.concat([r]);for(c=o.length-1;c>=0;){var w=o[c];if(!(E(w,r)&&P(r[w],e[w],l,p)))return!1;c-=1}return!0}var Ee=_e(function(r,t){return P(r,t,[],[])});const be={class:"v-filters"},Ie={class:"v-filters_fields"};return{__name:"VFilters",props:{componentsMap:{type:Object,required:!0},fieldComponentName:{type:String,default:"v-filter-field"},declensionWords:{type:Array,default:()=>[]},showWords:{type:Array,default:()=>[]},notFoundTitle:{type:String,default:""},fields:{type:Array,required:!0},count:{type:Number,default:0},showParams:{type:Boolean,default:!0},isResultShown:{type:Boolean,default:!1},humanLink:{type:Object},editedOutside:{type:Boolean,defualt:!1},immediate:{type:Boolean,default:!1},fieldKey:{type:[String,Number],default:"1"},alwaysSendFields:{type:Array,default:()=>[]},paramsToInclude:{type:Object,default:()=>({})},filterParamsToInclude:{type:Object,default:()=>({})},notArrayValueFields:{type:Array,default:()=>["select","tab"]},sendAllFields:{type:Boolean,default:!1}},emits:["reset-filters","request-count","show-result"],setup(e,{emit:r}){const t=e,n=r,a=u=>X.stringify(u,{arrayFormat:"index",encode:!1}),c=u=>X.parse(u,{arrayFormat:"index"}),o=i.ref({}),l=i.ref([]),p=i.computed(()=>l.value.length>0),w=i.computed(()=>p.value||t.editedOutside),xe=i.computed(()=>{let u=t.notFoundTitle;if(t.count>0){const m=t.showWords.length&&t.isResultShown?t.showWords[1]:t.showWords[0],s=A(t.count,t.declensionWords);u=`${m+" "||""}${t.count} ${s}`}return u}),b=i.computed(()=>{const u={...t.filterParamsToInclude},m=[...l.value,...t.alwaysSendFields];return Object.keys(o.value).forEach(s=>{if(m.includes(s)||t.sendAllFields){const f=o.value[s],F=oe(f)==="Object"?[f]:f;u[s]=F.map(_=>_._id||_)}}),u});function se(u){const m=ce();t.fields.forEach(s=>{let f=s._type==="range"?s.value:[];const F=t.notArrayValueFields.includes(s._type);if(F&&([f]=s.value),m[s._name]&&!u){const y=m[s._name];s._type!=="range"?(f=s.data.reduce((g,x)=>{const C=x._id||x;return y.includes(C.toString())&&g.push(x),g},[]),F&&([f]=f)):f=y,D(s._name)}else m[s._name]&&u&&s._type!=="range"?F?s.data.some(g=>g._id===f._id||g._id===f)||(f=s.data[0]):f=s.value.reduce((y,g)=>(s.data.some(C=>C._id===g._id||C._id===g)&&y.push(g),y),[]):(!m[s._name]||u)&&F?[f]=s.value:(!m[s._name]||u)&&(f=s.value);let _=!1;switch(s._type){case"range":_=s.data.map((y,g)=>s.value[g]===y).some(y=>!y);break;case"select":case"tab":_=s.value.length>0&&s.value[0]._id!==s.data[0]._id;break;case"checkbox":_=s.value.length>0;break}_&&D(s._name),o.value[s._name]=f}),!u&&I(),!u&&ie(!0)}async function V(){l.value=[],I(!0,{}),await i.nextTick(),n("reset-filters",b.value)}function D(u){l.value.includes(u)||l.value.push(u)}function Ce(u){l.value=l.value.filter(m=>m!==u)}function ke(u){if(t.fields.find(s=>s._name===u).reset){const s=t.fields.filter(f=>!f.reset).map(f=>f._name);l.value=l.value.filter(f=>!s.includes(f))}}function ie(u=!1){u||t.immediate?j():Ne()}function Ne(){n("request-count",b.value)}function j(){I(),n("show-result",b.value)}function ce(){return c(window.location.search)}function I(u,m){if(t.showParams){const s=m||{...b.value,...t.paramsToInclude},f=ce(),F=Object.keys(s).length;if((F&&!Ee(s,f)||u||m)&&!t.humanLink){const _=a(s),y=window.location.origin+window.location.pathname+`${F?"?":""}${_}`;history.replaceState({state:y},"",y)}}}function qe(u,m){m!==null?(D(u),ke(u)):Ce(u),ie()}return i.watch(()=>t.fields,()=>{se(!0)},{deep:!0}),i.watch(()=>t.paramsToInclude,()=>{I(!0)},{deep:!0}),se(),(u,m)=>(i.openBlock(),i.createElementBlock("div",be,[i.createElementVNode("div",Ie,[i.renderSlot(u.$slots,"before-fields"),(i.openBlock(!0),i.createElementBlock(i.Fragment,null,i.renderList(t.fields,s=>(i.openBlock(),i.createBlock(i.resolveDynamicComponent(t.fieldComponentName),{key:s._name,class:i.normalizeClass([`__${s._name}`]),title:s.title},{default:i.withCtx(()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(t.componentsMap[s._type]),i.mergeProps({key:e.fieldKey,modelValue:o.value[s._name],"onUpdate:modelValue":f=>o.value[s._name]=f,ref_for:!0},s._fieldProps||{},{"onUpdate:modelValue":f=>qe(s._name,f)}),null,16,["modelValue","onUpdate:modelValue"]))]),_:2},1032,["class","title"]))),128)),i.renderSlot(u.$slots,"after-fields"),i.renderSlot(u.$slots,"actions",i.normalizeProps(i.guardReactiveProps({showResult:j,resetFilters:V,count:t.count,immediate:t.immediate,edited:w.value})),()=>[(i.openBlock(),i.createBlock(i.resolveDynamicComponent(t.fieldComponentName),null,{default:i.withCtx(()=>[e.immediate?i.createCommentVNode("",!0):(i.openBlock(),i.createElementBlock("button",{key:0,class:"v-button v-filters_button",onClick:j},i.toDisplayString(xe.value),1)),w.value?(i.openBlock(),i.createElementBlock("button",{key:1,class:"v-button v-filters_button __reset",onClick:V}," Сбросить параметры ")):i.createCommentVNode("",!0)]),_:1}))])]),i.renderSlot(u.$slots,"actions-after",i.normalizeProps(i.guardReactiveProps({showResult:j,resetFilters:V,count:t.count,immediate:t.immediate,edited:w.value})))]))}}});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<slot name="before-fields" />
|
|
5
5
|
<component
|
|
6
6
|
:is="props.fieldComponentName"
|
|
7
|
-
v-for="field in fields"
|
|
7
|
+
v-for="field in props.fields"
|
|
8
8
|
:key="field._name"
|
|
9
9
|
:class="[`__${field._name}`]"
|
|
10
10
|
:title="field.title"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
:key="fieldKey"
|
|
15
15
|
v-model="filters[field._name]"
|
|
16
16
|
v-bind="field._fieldProps || {}"
|
|
17
|
-
@
|
|
17
|
+
@update:model-value="handleFieldChange(field._name, $event)"
|
|
18
18
|
/>
|
|
19
19
|
</component>
|
|
20
20
|
<slot name="after-fields" />
|
|
@@ -139,9 +139,6 @@ const props = defineProps({
|
|
|
139
139
|
}
|
|
140
140
|
})
|
|
141
141
|
|
|
142
|
-
const fields = ref(props.fields)
|
|
143
|
-
const paramsToInclude = ref(props.paramsToInclude)
|
|
144
|
-
|
|
145
142
|
const emit = defineEmits(['reset-filters', 'request-count', 'show-result'])
|
|
146
143
|
|
|
147
144
|
const serialize = (obj) => {
|
|
@@ -163,28 +160,28 @@ const edited = computed(() => {
|
|
|
163
160
|
const actionTitle = computed(() => {
|
|
164
161
|
let title = props.notFoundTitle
|
|
165
162
|
if (props.count > 0) {
|
|
166
|
-
const showWord = props.showWords.length && props.isResultShown ? props.showWords[1] :
|
|
163
|
+
const showWord = props.showWords.length && props.isResultShown ? props.showWords[1] : props.showWords[0]
|
|
167
164
|
const flatWord = declension(props.count, props.declensionWords)
|
|
168
165
|
title = `${showWord + ' ' || ''}${props.count} ${flatWord}`
|
|
169
166
|
}
|
|
170
167
|
return title
|
|
171
168
|
})
|
|
172
169
|
const flatFilters = computed(() => {
|
|
173
|
-
const
|
|
170
|
+
const allFilters = { ...props.filterParamsToInclude }
|
|
174
171
|
const fieldsToInclude = [...editedFields.value, ...props.alwaysSendFields]
|
|
175
|
-
Object.keys(filters).forEach(name => {
|
|
172
|
+
Object.keys(filters.value).forEach(name => {
|
|
176
173
|
if (fieldsToInclude.includes(name) || props.sendAllFields) {
|
|
177
|
-
const filtersValue =
|
|
174
|
+
const filtersValue = filters.value[name]
|
|
178
175
|
const wrappedValue = getType(filtersValue) === 'Object' ? [filtersValue] : filtersValue
|
|
179
|
-
|
|
176
|
+
allFilters[name] = wrappedValue.map(value => value._id || value)
|
|
180
177
|
}
|
|
181
178
|
})
|
|
182
|
-
return
|
|
179
|
+
return allFilters
|
|
183
180
|
})
|
|
184
181
|
|
|
185
182
|
function setFilters (isUpdate) {
|
|
186
183
|
const params = getUrlParams()
|
|
187
|
-
fields.
|
|
184
|
+
props.fields.forEach(field => {
|
|
188
185
|
let value = field._type === 'range' ? field.value : []
|
|
189
186
|
const valueNotArray = props.notArrayValueFields.includes(field._type)
|
|
190
187
|
if (valueNotArray) {
|
|
@@ -267,9 +264,9 @@ function removeEditedField (name) {
|
|
|
267
264
|
}
|
|
268
265
|
|
|
269
266
|
function removeDependentFieldsFromEdited (name) {
|
|
270
|
-
const field = fields.
|
|
267
|
+
const field = props.fields.find(field => field._name === name)
|
|
271
268
|
if (field.reset) {
|
|
272
|
-
const dependentFields = fields.
|
|
269
|
+
const dependentFields = props.fields.filter(field => !field.reset).map(field => field._name)
|
|
273
270
|
editedFields.value = editedFields.value.filter(fieldName => !dependentFields.includes(fieldName))
|
|
274
271
|
}
|
|
275
272
|
}
|
|
@@ -297,7 +294,7 @@ function getUrlParams () {
|
|
|
297
294
|
|
|
298
295
|
function setUrlParams (isUpdate, rewriteParams) {
|
|
299
296
|
if (props.showParams) {
|
|
300
|
-
const params = rewriteParams || { ...flatFilters.value, ...paramsToInclude
|
|
297
|
+
const params = rewriteParams || { ...flatFilters.value, ...props.paramsToInclude }
|
|
301
298
|
const currentParams = getUrlParams()
|
|
302
299
|
const newParamsLength = Object.keys(params).length
|
|
303
300
|
if (((newParamsLength && !equals(params, currentParams)) || isUpdate || rewriteParams) && !props.humanLink) {
|
|
@@ -318,13 +315,13 @@ function handleFieldChange (name, value) {
|
|
|
318
315
|
doAction()
|
|
319
316
|
}
|
|
320
317
|
|
|
321
|
-
watch(fields, () => {
|
|
318
|
+
watch(() => props.fields, () => {
|
|
322
319
|
setFilters(true)
|
|
323
|
-
})
|
|
320
|
+
}, { deep: true })
|
|
324
321
|
|
|
325
|
-
watch(paramsToInclude, () => {
|
|
322
|
+
watch(() => props.paramsToInclude, () => {
|
|
326
323
|
setUrlParams(true)
|
|
327
|
-
})
|
|
324
|
+
}, { deep: true })
|
|
328
325
|
|
|
329
326
|
setFilters()
|
|
330
327
|
</script>
|