@karta.io/utils 1.0.0-beta.5 → 1.0.0-beta.50
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/index.cjs +336 -179
- package/dist/index.d.cts +76 -32
- package/dist/index.d.mts +76 -32
- package/dist/index.d.ts +76 -32
- package/dist/index.mjs +324 -173
- package/package.json +35 -36
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const camelCase = require('lodash/camelCase.js');
|
|
4
|
+
const flatMap = require('lodash/flatMap.js');
|
|
4
5
|
const commonData = require('@karta.io/common-data');
|
|
5
6
|
const libphonenumberJs = require('libphonenumber-js');
|
|
6
7
|
const snakeCase = require('lodash/snakeCase.js');
|
|
7
8
|
const vue = require('vue');
|
|
8
|
-
const core = require('@vueuse/core');
|
|
9
9
|
const vueQuery = require('@tanstack/vue-query');
|
|
10
|
+
const core = require('@vueuse/core');
|
|
10
11
|
const get = require('lodash/get.js');
|
|
11
12
|
const has = require('lodash/has.js');
|
|
12
13
|
const union = require('lodash/union.js');
|
|
@@ -24,6 +25,7 @@ const qs = require('qs');
|
|
|
24
25
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
25
26
|
|
|
26
27
|
const camelCase__default = /*#__PURE__*/_interopDefaultCompat(camelCase);
|
|
28
|
+
const flatMap__default = /*#__PURE__*/_interopDefaultCompat(flatMap);
|
|
27
29
|
const snakeCase__default = /*#__PURE__*/_interopDefaultCompat(snakeCase);
|
|
28
30
|
const get__default = /*#__PURE__*/_interopDefaultCompat(get);
|
|
29
31
|
const has__default = /*#__PURE__*/_interopDefaultCompat(has);
|
|
@@ -42,14 +44,16 @@ function AppComponentsResolver(options = {}) {
|
|
|
42
44
|
return (name) => {
|
|
43
45
|
const componentName = prefix && name.startsWith(prefix) ? name.substring(prefix.length) : name;
|
|
44
46
|
const isAppComponent = componentName.startsWith("App");
|
|
45
|
-
if (isAppComponent)
|
|
47
|
+
if (isAppComponent) {
|
|
46
48
|
return { name: componentName, from: "@karta.io/app-components" };
|
|
49
|
+
}
|
|
47
50
|
};
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
function camelizeKeys(object) {
|
|
51
|
-
if (Array.isArray(object))
|
|
54
|
+
if (Array.isArray(object)) {
|
|
52
55
|
return object.map((v) => camelizeKeys(v));
|
|
56
|
+
}
|
|
53
57
|
if (object !== null && object.constructor === Object) {
|
|
54
58
|
return Object.keys(object).reduce(
|
|
55
59
|
(result, key) => ({
|
|
@@ -76,13 +80,113 @@ function convertEnumToOptions(obj, options) {
|
|
|
76
80
|
}));
|
|
77
81
|
}
|
|
78
82
|
|
|
83
|
+
class EnrichError extends Error {
|
|
84
|
+
constructor(data) {
|
|
85
|
+
super(data.message);
|
|
86
|
+
Object.assign(this, data);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isHtml(data) {
|
|
91
|
+
try {
|
|
92
|
+
if (typeof DOMParser !== "undefined") {
|
|
93
|
+
const parser = new DOMParser();
|
|
94
|
+
const doc = parser.parseFromString(data, "text/html");
|
|
95
|
+
return Array.from(doc.body.childNodes).some(
|
|
96
|
+
(node) => node.nodeType === Node.ELEMENT_NODE
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const htmlPattern = /<\/?[a-z][\s\S]*>/i;
|
|
100
|
+
return htmlPattern.test(data);
|
|
101
|
+
} catch (_) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getStatusMessage(status) {
|
|
107
|
+
let message = "";
|
|
108
|
+
switch (status) {
|
|
109
|
+
case 200:
|
|
110
|
+
message = "All done. Request successfully executed";
|
|
111
|
+
break;
|
|
112
|
+
case 201:
|
|
113
|
+
message = "Data successfully created";
|
|
114
|
+
break;
|
|
115
|
+
case 400:
|
|
116
|
+
message = "Bad request";
|
|
117
|
+
break;
|
|
118
|
+
case 401:
|
|
119
|
+
message = "Need auth";
|
|
120
|
+
break;
|
|
121
|
+
case 404:
|
|
122
|
+
message = "Not found";
|
|
123
|
+
break;
|
|
124
|
+
case 500:
|
|
125
|
+
message = "Something wrong. Internal server error";
|
|
126
|
+
break;
|
|
127
|
+
case 501:
|
|
128
|
+
message = "501: Not implemented";
|
|
129
|
+
break;
|
|
130
|
+
case 502:
|
|
131
|
+
message = "502: Bad gateway";
|
|
132
|
+
break;
|
|
133
|
+
case 503:
|
|
134
|
+
message = "Service unavailable. Try again later";
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
message = "Something wrong. Client default error message";
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return message;
|
|
141
|
+
}
|
|
142
|
+
function formatErrorDataMessage(data) {
|
|
143
|
+
if (!data) return "";
|
|
144
|
+
return Object.values(data).reduce((accum, current) => {
|
|
145
|
+
if (current && typeof current === "string")
|
|
146
|
+
return accum ? `${accum} | ${current}` : current;
|
|
147
|
+
if (Array.isArray(current) && current.length) {
|
|
148
|
+
const value = `${flatMap__default(current).join(" | ")}`;
|
|
149
|
+
return accum ? `${accum} | ${value}` : value;
|
|
150
|
+
}
|
|
151
|
+
return accum;
|
|
152
|
+
}, "");
|
|
153
|
+
}
|
|
154
|
+
function formatErrorForNotify(error) {
|
|
155
|
+
if (!error) return;
|
|
156
|
+
if (error.status >= 400 && error.status < 500) {
|
|
157
|
+
let message = "";
|
|
158
|
+
if (!error.data || typeof error.data === "string" && isHtml(error.data)) {
|
|
159
|
+
message = error.statusMessage || error.message || getStatusMessage(error.status);
|
|
160
|
+
} else if (typeof error.data === "string" && !isHtml(error.data)) {
|
|
161
|
+
message = error.data;
|
|
162
|
+
} else {
|
|
163
|
+
message = formatErrorDataMessage(error.data);
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
title: "Request error",
|
|
167
|
+
message
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (error.status >= 500) {
|
|
171
|
+
return {
|
|
172
|
+
title: "Internal server error",
|
|
173
|
+
message: error.statusMessage || error.message || getStatusMessage(error.status)
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (error instanceof Error) {
|
|
177
|
+
return {
|
|
178
|
+
title: "Internal client error",
|
|
179
|
+
message: error.message
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
79
184
|
function formatMoney(value, currency = commonData.CURRENCY_DEFAULT, options = {}) {
|
|
80
185
|
const { locale = "en-US", defaultValue = 0, ...otherOptions } = options;
|
|
81
186
|
try {
|
|
82
187
|
let convertedValue = Number(value);
|
|
83
188
|
if (value === null || Number.isNaN(convertedValue)) {
|
|
84
|
-
if (defaultValue === "")
|
|
85
|
-
return defaultValue;
|
|
189
|
+
if (defaultValue === "") return defaultValue;
|
|
86
190
|
convertedValue = Number(defaultValue);
|
|
87
191
|
}
|
|
88
192
|
const formatter = new Intl.NumberFormat(locale, {
|
|
@@ -93,7 +197,7 @@ function formatMoney(value, currency = commonData.CURRENCY_DEFAULT, options = {}
|
|
|
93
197
|
...otherOptions
|
|
94
198
|
});
|
|
95
199
|
return formatter.format(convertedValue);
|
|
96
|
-
} catch (
|
|
200
|
+
} catch (_error) {
|
|
97
201
|
return defaultValue;
|
|
98
202
|
}
|
|
99
203
|
}
|
|
@@ -123,7 +227,7 @@ function genUUID() {
|
|
|
123
227
|
r = (d2 + r) % 16 | 0;
|
|
124
228
|
d2 = Math.floor(d2 / 16);
|
|
125
229
|
}
|
|
126
|
-
return (c
|
|
230
|
+
return (c === "x" ? r : r & 7 | 8).toString(16);
|
|
127
231
|
});
|
|
128
232
|
}
|
|
129
233
|
|
|
@@ -142,8 +246,7 @@ function getCardNumber(number, options) {
|
|
|
142
246
|
}
|
|
143
247
|
|
|
144
248
|
function getCountryFromPhone(phone) {
|
|
145
|
-
if (!phone)
|
|
146
|
-
return "";
|
|
249
|
+
if (!phone) return "";
|
|
147
250
|
const replacedPhone = phone.replace(/[a-zA-Z]/g, "");
|
|
148
251
|
const phoneNumber = libphonenumberJs.parsePhoneNumberFromString(replacedPhone);
|
|
149
252
|
return phoneNumber?.country ?? "";
|
|
@@ -185,8 +288,7 @@ function mapDataObjectForFilters(data, options) {
|
|
|
185
288
|
}
|
|
186
289
|
|
|
187
290
|
function validateNumber(value, defaultValue) {
|
|
188
|
-
if (value === "")
|
|
189
|
-
return defaultValue;
|
|
291
|
+
if (value === "") return defaultValue;
|
|
190
292
|
return Number.isNaN(Number(value)) ? defaultValue : Number(value);
|
|
191
293
|
}
|
|
192
294
|
|
|
@@ -203,7 +305,9 @@ function getPaginationParams({
|
|
|
203
305
|
offset: validatedPage * validatedLimit - validatedLimit
|
|
204
306
|
};
|
|
205
307
|
}
|
|
206
|
-
function getPaginationLimit({
|
|
308
|
+
function getPaginationLimit({
|
|
309
|
+
limit
|
|
310
|
+
}) {
|
|
207
311
|
return validateNumber(limit, LIMIT_DEFAULT);
|
|
208
312
|
}
|
|
209
313
|
function getPaginationOffset({
|
|
@@ -222,18 +326,19 @@ function getPaginationPages({
|
|
|
222
326
|
}
|
|
223
327
|
|
|
224
328
|
function parsePhone(phone) {
|
|
225
|
-
if (!phone || typeof phone !== "string")
|
|
226
|
-
return "";
|
|
329
|
+
if (!phone || typeof phone !== "string") return "";
|
|
227
330
|
const replacedPhone = phone.replace(/[a-zA-Z]/g, "");
|
|
228
|
-
if (replacedPhone.length === 1 && replacedPhone !== "+")
|
|
331
|
+
if (replacedPhone.length === 1 && replacedPhone !== "+") {
|
|
229
332
|
return `+${replacedPhone}`;
|
|
333
|
+
}
|
|
230
334
|
const phoneNumber = libphonenumberJs.parsePhoneNumberFromString(replacedPhone);
|
|
231
335
|
return phoneNumber ? phoneNumber.formatInternational() : replacedPhone;
|
|
232
336
|
}
|
|
233
337
|
|
|
234
338
|
function snakelizeKeys(prop) {
|
|
235
|
-
if (Array.isArray(prop))
|
|
339
|
+
if (Array.isArray(prop)) {
|
|
236
340
|
return prop.map((item) => snakelizeKeys(item));
|
|
341
|
+
}
|
|
237
342
|
if (prop !== null && prop !== void 0 && prop.constructor === Object) {
|
|
238
343
|
return Object.keys(prop).reduce(
|
|
239
344
|
(accum, current) => ({
|
|
@@ -249,8 +354,7 @@ function snakelizeKeys(prop) {
|
|
|
249
354
|
const LOCALE_RU = "ru-RU";
|
|
250
355
|
const LOCALE_EN = "en-US";
|
|
251
356
|
function unformatNumber(value) {
|
|
252
|
-
if (!value || typeof value !== "string")
|
|
253
|
-
return value;
|
|
357
|
+
if (!value || typeof value !== "string") return value;
|
|
254
358
|
const string = value.trim();
|
|
255
359
|
let locale;
|
|
256
360
|
const spaceIndex = string.lastIndexOf(" ");
|
|
@@ -260,23 +364,18 @@ function unformatNumber(value) {
|
|
|
260
364
|
const hasComma = commaIndex !== -1;
|
|
261
365
|
const hasDot = dotIndex !== -1;
|
|
262
366
|
const commasCount = (string.match(/,/g) || []).length;
|
|
263
|
-
if (!Number.isNaN(Number(string)))
|
|
264
|
-
|
|
265
|
-
if (hasSpace && hasComma &&
|
|
266
|
-
|
|
267
|
-
if (
|
|
268
|
-
locale = LOCALE_RU;
|
|
269
|
-
if (hasComma && hasDot && dotIndex > commaIndex)
|
|
270
|
-
locale = LOCALE_EN;
|
|
271
|
-
if (hasComma && !hasSpace && !hasDot && commasCount > 1)
|
|
272
|
-
locale = LOCALE_EN;
|
|
367
|
+
if (!Number.isNaN(Number(string))) return Number(string);
|
|
368
|
+
if (hasSpace && hasComma && commaIndex > spaceIndex) locale = LOCALE_RU;
|
|
369
|
+
if (hasSpace && !hasComma && !hasDot) locale = LOCALE_RU;
|
|
370
|
+
if (hasComma && hasDot && dotIndex > commaIndex) locale = LOCALE_EN;
|
|
371
|
+
if (hasComma && !hasSpace && !hasDot && commasCount > 1) locale = LOCALE_EN;
|
|
273
372
|
if (commasCount === 1 && !hasSpace && !hasDot) {
|
|
274
373
|
locale = string.length - 1 - commaIndex === 3 ? LOCALE_EN : LOCALE_RU;
|
|
275
374
|
}
|
|
276
|
-
if (locale === LOCALE_RU)
|
|
375
|
+
if (locale === LOCALE_RU) {
|
|
277
376
|
return Number(string.replaceAll(" ", "").replace(",", "."));
|
|
278
|
-
|
|
279
|
-
|
|
377
|
+
}
|
|
378
|
+
if (locale === LOCALE_EN) return Number(string.replaceAll(",", ""));
|
|
280
379
|
return value;
|
|
281
380
|
}
|
|
282
381
|
|
|
@@ -285,8 +384,9 @@ function UiComponentsResolver(options = {}) {
|
|
|
285
384
|
return (name) => {
|
|
286
385
|
const componentName = prefix && name.startsWith(prefix) ? name.substring(prefix.length) : name;
|
|
287
386
|
const isUiComponent = componentName.startsWith("Ui");
|
|
288
|
-
if (isUiComponent)
|
|
387
|
+
if (isUiComponent) {
|
|
289
388
|
return { name: componentName, from: "@karta.io/ui-components" };
|
|
389
|
+
}
|
|
290
390
|
};
|
|
291
391
|
}
|
|
292
392
|
|
|
@@ -294,8 +394,7 @@ function useAbortController(callback) {
|
|
|
294
394
|
let controller = null;
|
|
295
395
|
return {
|
|
296
396
|
async call(...args) {
|
|
297
|
-
if (controller)
|
|
298
|
-
controller.abort();
|
|
397
|
+
if (controller) controller.abort();
|
|
299
398
|
controller = new AbortController();
|
|
300
399
|
let response;
|
|
301
400
|
if (args.length > 0) {
|
|
@@ -311,8 +410,7 @@ function useAbortController(callback) {
|
|
|
311
410
|
return response;
|
|
312
411
|
},
|
|
313
412
|
abort() {
|
|
314
|
-
if (!controller)
|
|
315
|
-
return;
|
|
413
|
+
if (!controller) return;
|
|
316
414
|
controller.abort();
|
|
317
415
|
controller = null;
|
|
318
416
|
},
|
|
@@ -332,15 +430,16 @@ function useAsyncItems({
|
|
|
332
430
|
const { call, abort } = useAbortController(apiMethod);
|
|
333
431
|
const { isLoading, isFetching, isError, data, error } = vueQuery.useQuery({
|
|
334
432
|
queryKey: getQueryKey(),
|
|
335
|
-
queryFn: () => call(
|
|
433
|
+
queryFn: () => call(vue.toValue(params), config)
|
|
336
434
|
});
|
|
337
|
-
const items = vue.computed(
|
|
435
|
+
const items = vue.computed(
|
|
436
|
+
() => data.value?.results || []
|
|
437
|
+
);
|
|
338
438
|
const count = vue.ref(0);
|
|
339
439
|
vue.watch(
|
|
340
440
|
data,
|
|
341
441
|
(newValue) => {
|
|
342
|
-
if (newValue === void 0 || newValue.count === void 0)
|
|
343
|
-
return;
|
|
442
|
+
if (newValue === void 0 || newValue.count === void 0) return;
|
|
344
443
|
count.value = newValue.count;
|
|
345
444
|
},
|
|
346
445
|
{ immediate: true }
|
|
@@ -367,23 +466,18 @@ function useAsyncItems({
|
|
|
367
466
|
}
|
|
368
467
|
|
|
369
468
|
function isEnabled(options) {
|
|
370
|
-
if (options?.debug !== void 0)
|
|
371
|
-
return options.debug;
|
|
469
|
+
if (options?.debug !== void 0) return options.debug;
|
|
372
470
|
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
373
471
|
if (isBrowser) {
|
|
374
472
|
const debug = localStorage.getItem("debug");
|
|
375
|
-
if (debug === "true")
|
|
376
|
-
|
|
377
|
-
if (debug === "false")
|
|
378
|
-
return false;
|
|
473
|
+
if (debug === "true") return true;
|
|
474
|
+
if (debug === "false") return false;
|
|
379
475
|
}
|
|
380
476
|
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
381
477
|
if (isNode) {
|
|
382
478
|
const debug = process.env.NODE_DEBUG;
|
|
383
|
-
if (debug === "true")
|
|
384
|
-
|
|
385
|
-
if (debug === "false")
|
|
386
|
-
return false;
|
|
479
|
+
if (debug === "true") return true;
|
|
480
|
+
if (debug === "false") return false;
|
|
387
481
|
}
|
|
388
482
|
return false;
|
|
389
483
|
}
|
|
@@ -411,12 +505,17 @@ function useAsyncMultiselect({
|
|
|
411
505
|
color: "#b54708",
|
|
412
506
|
debug: true
|
|
413
507
|
});
|
|
414
|
-
const paramsForLogger = {
|
|
508
|
+
const paramsForLogger = {
|
|
509
|
+
queryKey,
|
|
510
|
+
dataItemsKey,
|
|
511
|
+
dataItemIdKey,
|
|
512
|
+
dataCountKey
|
|
513
|
+
};
|
|
415
514
|
const reactiveData = vue.reactive({
|
|
416
515
|
search: "",
|
|
417
516
|
page: 1,
|
|
418
|
-
selectedValues:
|
|
419
|
-
params: JSON.stringify(
|
|
517
|
+
selectedValues: vue.toValue(selectedValues),
|
|
518
|
+
params: JSON.stringify(vue.toValue(params))
|
|
420
519
|
});
|
|
421
520
|
const search = vue.ref("");
|
|
422
521
|
const { call, abort } = useAbortController(apiMethod);
|
|
@@ -441,8 +540,7 @@ function useAsyncMultiselect({
|
|
|
441
540
|
vue.watch(
|
|
442
541
|
data,
|
|
443
542
|
(newValue) => {
|
|
444
|
-
if (!newValue)
|
|
445
|
-
return;
|
|
543
|
+
if (!newValue) return;
|
|
446
544
|
if (!has__default(newValue, dataItemsKey)) {
|
|
447
545
|
logger.warn(
|
|
448
546
|
`Unable to find key *"${dataItemsKey}"* (property "dataItemsKey") in data object from API.`,
|
|
@@ -457,8 +555,9 @@ function useAsyncMultiselect({
|
|
|
457
555
|
);
|
|
458
556
|
return;
|
|
459
557
|
}
|
|
460
|
-
if (!get__default(newValue, dataItemsKey) || get__default(newValue, dataCountKey) === void 0)
|
|
558
|
+
if (!get__default(newValue, dataItemsKey) || get__default(newValue, dataCountKey) === void 0) {
|
|
461
559
|
return;
|
|
560
|
+
}
|
|
462
561
|
count.value = get__default(newValue, dataCountKey, 0);
|
|
463
562
|
const newItems = get__default(newValue, dataItemsKey);
|
|
464
563
|
itemsByPages.value = {
|
|
@@ -487,10 +586,10 @@ function useAsyncMultiselect({
|
|
|
487
586
|
{ immediate: true }
|
|
488
587
|
);
|
|
489
588
|
const items = vue.computed(() => {
|
|
490
|
-
if (!itemsByPages.value)
|
|
491
|
-
|
|
492
|
-
if (!Object.keys(itemsByPages.value).length)
|
|
589
|
+
if (!itemsByPages.value) return selectedItemsCached.value;
|
|
590
|
+
if (!Object.keys(itemsByPages.value).length) {
|
|
493
591
|
return selectedItemsCached.value;
|
|
592
|
+
}
|
|
494
593
|
const itemsByPagesAsArray = Object.values(itemsByPages.value).reduce(
|
|
495
594
|
(acc, item) => [...acc, ...item],
|
|
496
595
|
[]
|
|
@@ -503,28 +602,48 @@ function useAsyncMultiselect({
|
|
|
503
602
|
return [...itemsAsMap.values()];
|
|
504
603
|
});
|
|
505
604
|
const options = vue.computed(() => {
|
|
506
|
-
if (!items.value.length)
|
|
507
|
-
|
|
508
|
-
if (!mapOptionCallback)
|
|
509
|
-
return this.items.value;
|
|
605
|
+
if (!items.value.length) return [];
|
|
606
|
+
if (!mapOptionCallback) return items.value;
|
|
510
607
|
return items.value.map(mapOptionCallback);
|
|
511
608
|
});
|
|
512
609
|
const hasNextPage = vue.computed(() => count.value > items.value.length);
|
|
513
610
|
const loadPage = (newPage = 1) => {
|
|
514
611
|
reactiveData.page = newPage;
|
|
515
612
|
if (newPage === 1) {
|
|
516
|
-
reactiveData.selectedValues =
|
|
613
|
+
reactiveData.selectedValues = vue.toValue(selectedValues);
|
|
517
614
|
}
|
|
518
615
|
};
|
|
519
616
|
const updateSearchWithDebounce = core.useDebounceFn((value) => {
|
|
520
617
|
reactiveData.search = value;
|
|
521
618
|
reactiveData.page = 1;
|
|
522
|
-
reactiveData.selectedValues =
|
|
619
|
+
reactiveData.selectedValues = vue.toValue(selectedValues);
|
|
523
620
|
}, delay);
|
|
524
621
|
const updateSearch = (value) => {
|
|
525
622
|
search.value = value;
|
|
526
623
|
updateSearchWithDebounce(value);
|
|
527
624
|
};
|
|
625
|
+
const queryClient = vueQuery.useQueryClient();
|
|
626
|
+
const refetch = () => {
|
|
627
|
+
if (reactiveData.page !== 1) {
|
|
628
|
+
queryClient.invalidateQueries({
|
|
629
|
+
queryKey: [queryKey],
|
|
630
|
+
refetchType: "none"
|
|
631
|
+
});
|
|
632
|
+
loadPage(1);
|
|
633
|
+
} else {
|
|
634
|
+
queryClient.invalidateQueries({
|
|
635
|
+
queryKey: [queryKey]
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
const reload = () => {
|
|
640
|
+
if (reactiveData.page !== 1) {
|
|
641
|
+
queryClient.removeQueries({ queryKey: [queryKey] });
|
|
642
|
+
loadPage(1);
|
|
643
|
+
} else {
|
|
644
|
+
queryClient.resetQueries({ queryKey: [queryKey] });
|
|
645
|
+
}
|
|
646
|
+
};
|
|
528
647
|
if (vue.isRef(selectedValues)) {
|
|
529
648
|
vue.watch(selectedValues, async (newSelectedValues) => {
|
|
530
649
|
if (!newSelectedValues.length) {
|
|
@@ -551,7 +670,7 @@ function useAsyncMultiselect({
|
|
|
551
670
|
vue.watch(params, (newParams) => {
|
|
552
671
|
reactiveData.page = 1;
|
|
553
672
|
reactiveData.params = JSON.stringify(newParams);
|
|
554
|
-
reactiveData.selectedValues =
|
|
673
|
+
reactiveData.selectedValues = vue.toValue(selectedValues);
|
|
555
674
|
});
|
|
556
675
|
}
|
|
557
676
|
vue.onBeforeUnmount(() => {
|
|
@@ -565,7 +684,9 @@ function useAsyncMultiselect({
|
|
|
565
684
|
isFetching,
|
|
566
685
|
isLoading,
|
|
567
686
|
loadPage,
|
|
568
|
-
updateSearch
|
|
687
|
+
updateSearch,
|
|
688
|
+
refetch,
|
|
689
|
+
reload
|
|
569
690
|
};
|
|
570
691
|
}
|
|
571
692
|
|
|
@@ -589,15 +710,17 @@ function useAsyncSelect({
|
|
|
589
710
|
const reactiveData = vue.reactive({
|
|
590
711
|
search: "",
|
|
591
712
|
page: 1,
|
|
592
|
-
selectedValue:
|
|
593
|
-
params: JSON.stringify(
|
|
713
|
+
selectedValue: vue.toValue(selectedValue),
|
|
714
|
+
params: JSON.stringify(vue.toValue(params))
|
|
594
715
|
});
|
|
595
716
|
const search = vue.ref("");
|
|
596
717
|
const { call, abort } = useAbortController(apiMethod);
|
|
597
718
|
const loadWAC = () => call({
|
|
598
719
|
page: reactiveData.page,
|
|
599
720
|
search: reactiveData.search,
|
|
600
|
-
...reactiveData.selectedValue && {
|
|
721
|
+
...reactiveData.selectedValue && {
|
|
722
|
+
includedIds: [reactiveData.selectedValue]
|
|
723
|
+
},
|
|
601
724
|
...reactiveData.params && { ...JSON.parse(reactiveData.params) }
|
|
602
725
|
});
|
|
603
726
|
const { data, isFetching, isLoading } = vueQuery.useQuery({
|
|
@@ -609,8 +732,7 @@ function useAsyncSelect({
|
|
|
609
732
|
vue.watch(
|
|
610
733
|
data,
|
|
611
734
|
(newValue) => {
|
|
612
|
-
if (!newValue)
|
|
613
|
-
return;
|
|
735
|
+
if (!newValue) return;
|
|
614
736
|
if (!has__default(newValue, dataItemsKey)) {
|
|
615
737
|
logger.warn(
|
|
616
738
|
`Unable to find key *"${dataItemsKey}"* (property "dataItemsKey") in data object from API.`,
|
|
@@ -625,8 +747,9 @@ function useAsyncSelect({
|
|
|
625
747
|
);
|
|
626
748
|
return;
|
|
627
749
|
}
|
|
628
|
-
if (!get__default(newValue, dataItemsKey) || get__default(newValue, dataCountKey) === void 0)
|
|
750
|
+
if (!get__default(newValue, dataItemsKey) || get__default(newValue, dataCountKey) === void 0) {
|
|
629
751
|
return;
|
|
752
|
+
}
|
|
630
753
|
count.value = get__default(newValue, dataCountKey, 0);
|
|
631
754
|
const newItems = get__default(newValue, dataItemsKey);
|
|
632
755
|
itemsByPages.value = {
|
|
@@ -643,20 +766,16 @@ function useAsyncSelect({
|
|
|
643
766
|
{ immediate: true }
|
|
644
767
|
);
|
|
645
768
|
const items = vue.computed(() => {
|
|
646
|
-
if (!itemsByPages.value)
|
|
647
|
-
|
|
648
|
-
if (!Object.keys(itemsByPages.value).length)
|
|
649
|
-
return [];
|
|
769
|
+
if (!itemsByPages.value) return [];
|
|
770
|
+
if (!Object.keys(itemsByPages.value).length) return [];
|
|
650
771
|
return Object.values(itemsByPages.value).reduce(
|
|
651
772
|
(acc, item) => [...acc, ...item],
|
|
652
773
|
[]
|
|
653
774
|
);
|
|
654
775
|
});
|
|
655
776
|
const options = vue.computed(() => {
|
|
656
|
-
if (!items.value.length)
|
|
657
|
-
|
|
658
|
-
if (!mapOptionCallback)
|
|
659
|
-
return this.items.value;
|
|
777
|
+
if (!items.value.length) return [];
|
|
778
|
+
if (!mapOptionCallback) return items.value;
|
|
660
779
|
return items.value.map(mapOptionCallback);
|
|
661
780
|
});
|
|
662
781
|
const hasNextPage = vue.computed(() => count.value > items.value.length);
|
|
@@ -671,6 +790,28 @@ function useAsyncSelect({
|
|
|
671
790
|
search.value = value;
|
|
672
791
|
updateSearchWithDebounce(value);
|
|
673
792
|
};
|
|
793
|
+
const queryClient = vueQuery.useQueryClient();
|
|
794
|
+
const refetch = () => {
|
|
795
|
+
if (reactiveData.page !== 1) {
|
|
796
|
+
queryClient.invalidateQueries({
|
|
797
|
+
queryKey: [queryKey],
|
|
798
|
+
refetchType: "none"
|
|
799
|
+
});
|
|
800
|
+
loadPage(1);
|
|
801
|
+
} else {
|
|
802
|
+
queryClient.invalidateQueries({
|
|
803
|
+
queryKey: [queryKey]
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
const reload = () => {
|
|
808
|
+
if (reactiveData.page !== 1) {
|
|
809
|
+
queryClient.removeQueries({ queryKey: [queryKey] });
|
|
810
|
+
loadPage(1);
|
|
811
|
+
} else {
|
|
812
|
+
queryClient.resetQueries({ queryKey: [queryKey] });
|
|
813
|
+
}
|
|
814
|
+
};
|
|
674
815
|
if (vue.isRef(selectedValue)) {
|
|
675
816
|
vue.watch(selectedValue, (newSelectedValue) => {
|
|
676
817
|
reactiveData.page = 1;
|
|
@@ -694,20 +835,22 @@ function useAsyncSelect({
|
|
|
694
835
|
isFetching,
|
|
695
836
|
isLoading,
|
|
696
837
|
loadPage,
|
|
697
|
-
updateSearch
|
|
838
|
+
updateSearch,
|
|
839
|
+
refetch,
|
|
840
|
+
reload
|
|
698
841
|
};
|
|
699
842
|
}
|
|
700
843
|
|
|
701
844
|
function useBreakpoint() {
|
|
702
845
|
const breakpoints = core.useBreakpoints(commonData.BREAKPOINTS);
|
|
703
846
|
const isMobile = breakpoints.smaller("sm");
|
|
704
|
-
const isDesktop = breakpoints.
|
|
705
|
-
const isGreaterXxs = breakpoints.
|
|
706
|
-
const isGreaterXs = breakpoints.
|
|
707
|
-
const isGreaterSm = breakpoints.
|
|
708
|
-
const isGreaterMd = breakpoints.
|
|
709
|
-
const isGreaterLg = breakpoints.
|
|
710
|
-
const isGreaterXl = breakpoints.
|
|
847
|
+
const isDesktop = breakpoints.greaterOrEqual("md");
|
|
848
|
+
const isGreaterXxs = breakpoints.greaterOrEqual("xxs");
|
|
849
|
+
const isGreaterXs = breakpoints.greaterOrEqual("xs");
|
|
850
|
+
const isGreaterSm = breakpoints.greaterOrEqual("sm");
|
|
851
|
+
const isGreaterMd = breakpoints.greaterOrEqual("md");
|
|
852
|
+
const isGreaterLg = breakpoints.greaterOrEqual("lg");
|
|
853
|
+
const isGreaterXl = breakpoints.greaterOrEqual("xl");
|
|
711
854
|
return {
|
|
712
855
|
isMobile,
|
|
713
856
|
isDesktop,
|
|
@@ -722,14 +865,10 @@ function useBreakpoint() {
|
|
|
722
865
|
|
|
723
866
|
function _bem(block, blockSuffix, element, modifier, modifierValue) {
|
|
724
867
|
let cls = block;
|
|
725
|
-
if (blockSuffix)
|
|
726
|
-
|
|
727
|
-
if (
|
|
728
|
-
|
|
729
|
-
if (modifier)
|
|
730
|
-
cls += `_${modifier}`;
|
|
731
|
-
if (modifierValue)
|
|
732
|
-
cls += `_${modifierValue}`;
|
|
868
|
+
if (blockSuffix) cls += `-${blockSuffix}`;
|
|
869
|
+
if (element) cls += `__${element}`;
|
|
870
|
+
if (modifier) cls += `_${modifier}`;
|
|
871
|
+
if (modifierValue) cls += `_${modifierValue}`;
|
|
733
872
|
return cls;
|
|
734
873
|
}
|
|
735
874
|
function useClassName(block) {
|
|
@@ -740,8 +879,7 @@ function useClassName(block) {
|
|
|
740
879
|
const mv = (modifier, modifierValue, condition = true) => modifier && modifierValue && condition ? _bem(block, "", "", modifier, modifierValue) : "";
|
|
741
880
|
const cssVar = (object) => {
|
|
742
881
|
const styles = {};
|
|
743
|
-
for (const key in object)
|
|
744
|
-
styles[`--${block}-${key}`] = object[key];
|
|
882
|
+
for (const key in object) styles[`--${block}-${key}`] = object[key];
|
|
745
883
|
return styles;
|
|
746
884
|
};
|
|
747
885
|
const cssVarName = (name) => `--${block}-${name}`;
|
|
@@ -766,15 +904,16 @@ function useDayjs(timezone) {
|
|
|
766
904
|
dayjs__default.updateLocale("en", {
|
|
767
905
|
weekStart: 1
|
|
768
906
|
});
|
|
769
|
-
if (!timezone)
|
|
770
|
-
return dayjs__default;
|
|
907
|
+
if (!timezone) return dayjs__default;
|
|
771
908
|
const dayjsExtended = (date, format, locale, strict) => dayjs__default(date, format, locale, strict).tz(timezone);
|
|
772
909
|
return dayjsExtended;
|
|
773
910
|
}
|
|
774
911
|
|
|
775
912
|
function parseVersion(version) {
|
|
776
913
|
if (typeof version !== "string" && typeof version !== "number") {
|
|
777
|
-
throw new TypeError(
|
|
914
|
+
throw new TypeError(
|
|
915
|
+
"Browser version must be type of string, number or negative boolean"
|
|
916
|
+
);
|
|
778
917
|
}
|
|
779
918
|
const [major, minor = 0, patch = 0, build = 0] = typeof version === "string" ? version.split(".").map(Number) : [version];
|
|
780
919
|
return {
|
|
@@ -786,8 +925,7 @@ function parseVersion(version) {
|
|
|
786
925
|
}
|
|
787
926
|
function isVersionLower(minimum, target) {
|
|
788
927
|
for (const k of ["major", "minor", "patch"]) {
|
|
789
|
-
if (minimum[k] !== target[k])
|
|
790
|
-
return minimum[k] > target[k];
|
|
928
|
+
if (minimum[k] !== target[k]) return minimum[k] > target[k];
|
|
791
929
|
}
|
|
792
930
|
return minimum.build > target.build;
|
|
793
931
|
}
|
|
@@ -835,9 +973,20 @@ function useGlobalScroll() {
|
|
|
835
973
|
|
|
836
974
|
const CONFIRM_TEXT = "Are you sure you want to close? \nAll changes will be lost.";
|
|
837
975
|
let dialogs = [];
|
|
838
|
-
|
|
839
|
-
|
|
976
|
+
const HASH_PREFIX = "#ud_";
|
|
977
|
+
function useDialog(options) {
|
|
840
978
|
const logger = useLogger("use-dialog");
|
|
979
|
+
let hashPrefix = HASH_PREFIX;
|
|
980
|
+
if (options?.hashPrefix) {
|
|
981
|
+
if (options.hashPrefix.charAt(0) === "#") {
|
|
982
|
+
hashPrefix = options?.hashPrefix;
|
|
983
|
+
} else {
|
|
984
|
+
logger.warn(
|
|
985
|
+
`*hashPrefix* must start with "#". The default prefix "${HASH_PREFIX}" will be used`
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
let appContext;
|
|
841
990
|
const {
|
|
842
991
|
isLocked: isGlobalScrollLocked,
|
|
843
992
|
lock: lockGlobalScroll,
|
|
@@ -845,26 +994,33 @@ function useDialog() {
|
|
|
845
994
|
} = useGlobalScroll();
|
|
846
995
|
const route = vueRouter.useRoute();
|
|
847
996
|
const router = vueRouter.useRouter();
|
|
848
|
-
const
|
|
997
|
+
const genHash = ({
|
|
998
|
+
layer = 0,
|
|
999
|
+
componentName,
|
|
1000
|
+
props
|
|
1001
|
+
}) => {
|
|
1002
|
+
const data = {
|
|
1003
|
+
name: componentName,
|
|
1004
|
+
layer,
|
|
1005
|
+
props
|
|
1006
|
+
};
|
|
1007
|
+
return `${hashPrefix}${window.btoa(JSON.stringify(data))}`;
|
|
1008
|
+
};
|
|
849
1009
|
const parseHash = (hash, componentName) => {
|
|
850
|
-
if (!hash)
|
|
851
|
-
|
|
852
|
-
if (!hash.includes(HASH_PREFIX))
|
|
853
|
-
return void 0;
|
|
1010
|
+
if (!hash) return void 0;
|
|
1011
|
+
if (!hash.includes(hashPrefix)) return void 0;
|
|
854
1012
|
let dataFromHash;
|
|
855
1013
|
try {
|
|
856
|
-
dataFromHash = JSON.parse(window.atob(hash.slice(
|
|
857
|
-
} catch (
|
|
1014
|
+
dataFromHash = JSON.parse(window.atob(hash.slice(hashPrefix.length)));
|
|
1015
|
+
} catch (_error) {
|
|
858
1016
|
logger.warn("*parseHash* cant parse hash");
|
|
859
1017
|
}
|
|
860
|
-
if (typeof dataFromHash !== "object")
|
|
861
|
-
return void 0;
|
|
1018
|
+
if (typeof dataFromHash !== "object") return void 0;
|
|
862
1019
|
if (!dataFromHash.name) {
|
|
863
1020
|
logger.warn("*parseHash* cant find component name in hash");
|
|
864
1021
|
return void 0;
|
|
865
1022
|
}
|
|
866
|
-
if (dataFromHash.name !== componentName)
|
|
867
|
-
return void 0;
|
|
1023
|
+
if (dataFromHash.name !== componentName) return void 0;
|
|
868
1024
|
return dataFromHash;
|
|
869
1025
|
};
|
|
870
1026
|
const clearHash = () => {
|
|
@@ -901,8 +1057,7 @@ function useDialog() {
|
|
|
901
1057
|
vnode2.component.props.modelValue = value;
|
|
902
1058
|
if (!value && route?.hash) {
|
|
903
1059
|
const dataFromHash = parseHash(route.hash, component.name);
|
|
904
|
-
if (dataFromHash)
|
|
905
|
-
clearHash();
|
|
1060
|
+
if (dataFromHash?.layer === layer) clearHash();
|
|
906
1061
|
}
|
|
907
1062
|
if (!value && (dialogs.length === 1 || layer === 0) && isGlobalScrollLocked.value) {
|
|
908
1063
|
unlockGlobalScroll();
|
|
@@ -911,14 +1066,11 @@ function useDialog() {
|
|
|
911
1066
|
};
|
|
912
1067
|
}
|
|
913
1068
|
vnode2.close = () => {
|
|
914
|
-
if (!vnode2 || !vnode2.component)
|
|
915
|
-
return;
|
|
1069
|
+
if (!vnode2 || !vnode2.component) return;
|
|
916
1070
|
vnode2.component.props.modelValue = false;
|
|
917
|
-
if (!route?.hash)
|
|
918
|
-
return;
|
|
1071
|
+
if (!route?.hash) return;
|
|
919
1072
|
const dataFromHash = parseHash(route.hash, component.name);
|
|
920
|
-
if (dataFromHash)
|
|
921
|
-
clearHash();
|
|
1073
|
+
if (dataFromHash?.layer === layer) clearHash();
|
|
922
1074
|
};
|
|
923
1075
|
vnode2.props.onDestroy = () => {
|
|
924
1076
|
vue.render(null, el2);
|
|
@@ -991,9 +1143,12 @@ function useDialog() {
|
|
|
991
1143
|
const getInstance = (uuid) => {
|
|
992
1144
|
return dialogs.find((item) => item.uuid === uuid)?.vnode;
|
|
993
1145
|
};
|
|
1146
|
+
const getLayer = (uuid) => {
|
|
1147
|
+
if (!dialogs.length) return 0;
|
|
1148
|
+
return dialogs.find((dialog) => dialog.uuid === uuid)?.layer || 0;
|
|
1149
|
+
};
|
|
994
1150
|
const isOnTop = (uuid) => {
|
|
995
|
-
if (!dialogs.length)
|
|
996
|
-
return false;
|
|
1151
|
+
if (!dialogs.length) return false;
|
|
997
1152
|
const dialogsSorted = [...dialogs].sort((a, b) => b.layer - a.layer);
|
|
998
1153
|
return dialogsSorted[0].uuid === uuid;
|
|
999
1154
|
};
|
|
@@ -1005,15 +1160,10 @@ function useDialog() {
|
|
|
1005
1160
|
component,
|
|
1006
1161
|
props
|
|
1007
1162
|
}) => {
|
|
1008
|
-
const data = {
|
|
1009
|
-
name: component.name,
|
|
1010
|
-
layer,
|
|
1011
|
-
props
|
|
1012
|
-
};
|
|
1013
1163
|
router.push({
|
|
1014
1164
|
name: route.name || void 0,
|
|
1015
1165
|
query: route.query,
|
|
1016
|
-
hash:
|
|
1166
|
+
hash: genHash({ layer, props, componentName: component.name })
|
|
1017
1167
|
});
|
|
1018
1168
|
};
|
|
1019
1169
|
const watchHash = ({
|
|
@@ -1025,14 +1175,12 @@ function useDialog() {
|
|
|
1025
1175
|
() => route.hash,
|
|
1026
1176
|
async (newHash) => {
|
|
1027
1177
|
if (!newHash) {
|
|
1028
|
-
if (!dialogs.length)
|
|
1029
|
-
return;
|
|
1178
|
+
if (!dialogs.length) return;
|
|
1030
1179
|
closeAll();
|
|
1031
1180
|
return;
|
|
1032
1181
|
}
|
|
1033
1182
|
const dataFromHash = parseHash(newHash, component.name);
|
|
1034
|
-
if (!dataFromHash)
|
|
1035
|
-
return;
|
|
1183
|
+
if (!dataFromHash) return;
|
|
1036
1184
|
logger.info("*watchHash* data from hash", dataFromHash);
|
|
1037
1185
|
await vue.nextTick();
|
|
1038
1186
|
open({
|
|
@@ -1058,10 +1206,14 @@ function useDialog() {
|
|
|
1058
1206
|
return {
|
|
1059
1207
|
open,
|
|
1060
1208
|
getInstance,
|
|
1209
|
+
getLayer,
|
|
1061
1210
|
close,
|
|
1062
1211
|
closeAll,
|
|
1063
1212
|
showConfirm,
|
|
1064
1213
|
isOnTop,
|
|
1214
|
+
genHash,
|
|
1215
|
+
parseHash,
|
|
1216
|
+
clearHash,
|
|
1065
1217
|
openByHash,
|
|
1066
1218
|
watchHash
|
|
1067
1219
|
};
|
|
@@ -1074,46 +1226,47 @@ const QS_STRINGIFY_PARAMS = {
|
|
|
1074
1226
|
addQueryPrefix: true
|
|
1075
1227
|
};
|
|
1076
1228
|
const isOpen = vue.ref(false);
|
|
1077
|
-
function useFilters({
|
|
1078
|
-
config,
|
|
1079
|
-
initialFilters
|
|
1080
|
-
}) {
|
|
1229
|
+
function useFilters({ config, initialFilters }) {
|
|
1081
1230
|
const router = vueRouter.useRouter();
|
|
1082
1231
|
const route = vueRouter.useRoute();
|
|
1083
1232
|
const parseRouteQuery = (query) => qs__default.parse(query ?? route.query);
|
|
1084
1233
|
const filtersFromQuery = vue.computed(() => {
|
|
1085
1234
|
const parsedRouteQuery = parseRouteQuery();
|
|
1086
|
-
if (!parsedRouteQuery.filters)
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
return accum;
|
|
1235
|
+
if (!parsedRouteQuery.filters) return void 0;
|
|
1236
|
+
return Object.entries(config).reduce(
|
|
1237
|
+
(accum, [currentKey, currentValue]) => {
|
|
1238
|
+
if (!parsedRouteQuery.filters[currentKey]) return accum;
|
|
1239
|
+
if (currentValue.type === "ARRAY" /* Array */) {
|
|
1240
|
+
const splitValues = parsedRouteQuery.filters[currentKey].split(",");
|
|
1241
|
+
const checkedValue = currentValue?.possibleValues ? splitValues.filter(
|
|
1242
|
+
(k) => currentValue?.possibleValues?.includes(k)
|
|
1243
|
+
) : splitValues;
|
|
1244
|
+
if (!checkedValue?.length) return accum;
|
|
1245
|
+
return {
|
|
1246
|
+
...accum,
|
|
1247
|
+
[currentKey]: checkedValue
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1096
1250
|
return {
|
|
1097
1251
|
...accum,
|
|
1098
|
-
[currentKey]:
|
|
1252
|
+
[currentKey]: parsedRouteQuery.filters[currentKey]
|
|
1099
1253
|
};
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
[currentKey]: parsedRouteQuery.filters[currentKey]
|
|
1104
|
-
};
|
|
1105
|
-
}, {});
|
|
1254
|
+
},
|
|
1255
|
+
{}
|
|
1256
|
+
);
|
|
1106
1257
|
});
|
|
1107
1258
|
const filtersCount = vue.computed(
|
|
1108
1259
|
() => filtersFromQuery.value ? Object.keys(filtersFromQuery.value).length : 0
|
|
1109
1260
|
);
|
|
1110
1261
|
const setQueryFromFilters = (filters) => {
|
|
1111
1262
|
const parsedRouteQuery = parseRouteQuery();
|
|
1112
|
-
const filteredValue = Object.entries(filters).reduce(
|
|
1113
|
-
|
|
1114
|
-
return accum;
|
|
1115
|
-
|
|
1116
|
-
|
|
1263
|
+
const filteredValue = Object.entries(filters).reduce(
|
|
1264
|
+
(accum, [currentKey, currentValue]) => {
|
|
1265
|
+
if (!currentValue?.length) return accum;
|
|
1266
|
+
return { ...accum, [currentKey]: currentValue };
|
|
1267
|
+
},
|
|
1268
|
+
{}
|
|
1269
|
+
);
|
|
1117
1270
|
const query = qs__default.stringify(
|
|
1118
1271
|
{
|
|
1119
1272
|
...parsedRouteQuery,
|
|
@@ -1122,7 +1275,7 @@ function useFilters({
|
|
|
1122
1275
|
},
|
|
1123
1276
|
QS_STRINGIFY_PARAMS
|
|
1124
1277
|
);
|
|
1125
|
-
router.push(query);
|
|
1278
|
+
router.push(query.replaceAll("#", ""));
|
|
1126
1279
|
};
|
|
1127
1280
|
const getValidatedParams = (query) => {
|
|
1128
1281
|
const parsedRouteQuery = parseRouteQuery(query);
|
|
@@ -1150,12 +1303,15 @@ function useFilters({
|
|
|
1150
1303
|
});
|
|
1151
1304
|
};
|
|
1152
1305
|
const updateMany = (filters) => {
|
|
1153
|
-
const newFilters = Object.entries(filters).reduce(
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1306
|
+
const newFilters = Object.entries(filters).reduce(
|
|
1307
|
+
(accum, [currentKey, currentValue]) => {
|
|
1308
|
+
return {
|
|
1309
|
+
...accum,
|
|
1310
|
+
[currentKey]: currentValue ? String(currentValue) : void 0
|
|
1311
|
+
};
|
|
1312
|
+
},
|
|
1313
|
+
{}
|
|
1314
|
+
);
|
|
1159
1315
|
setQueryFromFilters({
|
|
1160
1316
|
...filtersModel.value,
|
|
1161
1317
|
...newFilters
|
|
@@ -1331,17 +1487,15 @@ function usePanel() {
|
|
|
1331
1487
|
let dataFromHash;
|
|
1332
1488
|
try {
|
|
1333
1489
|
dataFromHash = JSON.parse(window.atob(newHash.slice(1)));
|
|
1334
|
-
} catch (
|
|
1490
|
+
} catch (_error) {
|
|
1335
1491
|
logger.error("*watchHash* cant parse hash");
|
|
1336
1492
|
}
|
|
1337
|
-
if (typeof dataFromHash !== "object")
|
|
1338
|
-
return;
|
|
1493
|
+
if (typeof dataFromHash !== "object") return;
|
|
1339
1494
|
if (!dataFromHash.name) {
|
|
1340
1495
|
logger.error("*watchHash* cant find component name in hash");
|
|
1341
1496
|
return;
|
|
1342
1497
|
}
|
|
1343
|
-
if (dataFromHash.name !== component.name)
|
|
1344
|
-
return;
|
|
1498
|
+
if (dataFromHash.name !== component.name) return;
|
|
1345
1499
|
logger.info("*watchHash* data from hash", dataFromHash);
|
|
1346
1500
|
await vue.nextTick();
|
|
1347
1501
|
open({
|
|
@@ -1349,8 +1503,7 @@ function usePanel() {
|
|
|
1349
1503
|
layer: dataFromHash.layer || 0,
|
|
1350
1504
|
props: {
|
|
1351
1505
|
"onUpdate:modelValue": (value) => {
|
|
1352
|
-
if (value)
|
|
1353
|
-
return;
|
|
1506
|
+
if (value) return;
|
|
1354
1507
|
router.push({
|
|
1355
1508
|
name: route.name || void 0,
|
|
1356
1509
|
query: route.query,
|
|
@@ -1384,8 +1537,7 @@ function usePanel() {
|
|
|
1384
1537
|
}
|
|
1385
1538
|
|
|
1386
1539
|
function validatePhone(rule, value) {
|
|
1387
|
-
if (!value)
|
|
1388
|
-
return true;
|
|
1540
|
+
if (!value) return true;
|
|
1389
1541
|
const phoneNumber = libphonenumberJs.parsePhoneNumberFromString(value);
|
|
1390
1542
|
return phoneNumber ? phoneNumber.isValid() : false;
|
|
1391
1543
|
}
|
|
@@ -1435,9 +1587,12 @@ function isStrictLength(value = 3, message) {
|
|
|
1435
1587
|
}
|
|
1436
1588
|
|
|
1437
1589
|
exports.AppComponentsResolver = AppComponentsResolver;
|
|
1590
|
+
exports.EnrichError = EnrichError;
|
|
1438
1591
|
exports.UiComponentsResolver = UiComponentsResolver;
|
|
1439
1592
|
exports.camelizeKeys = camelizeKeys;
|
|
1440
1593
|
exports.convertEnumToOptions = convertEnumToOptions;
|
|
1594
|
+
exports.formatErrorDataMessage = formatErrorDataMessage;
|
|
1595
|
+
exports.formatErrorForNotify = formatErrorForNotify;
|
|
1441
1596
|
exports.formatMoney = formatMoney;
|
|
1442
1597
|
exports.genHash = genHash;
|
|
1443
1598
|
exports.genRandomNumber = genRandomNumber;
|
|
@@ -1448,8 +1603,10 @@ exports.getPaginationLimit = getPaginationLimit;
|
|
|
1448
1603
|
exports.getPaginationOffset = getPaginationOffset;
|
|
1449
1604
|
exports.getPaginationPages = getPaginationPages;
|
|
1450
1605
|
exports.getPaginationParams = getPaginationParams;
|
|
1606
|
+
exports.getStatusMessage = getStatusMessage;
|
|
1451
1607
|
exports.isElementIgnored = isElementIgnored;
|
|
1452
1608
|
exports.isEmptyObject = isEmptyObject;
|
|
1609
|
+
exports.isHtml = isHtml;
|
|
1453
1610
|
exports.isMax = isMax;
|
|
1454
1611
|
exports.isMin = isMin;
|
|
1455
1612
|
exports.isRequired = isRequired;
|