@karta.io/utils 1.0.0-beta.38 → 1.0.0-beta.4

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.d.ts CHANGED
@@ -23,7 +23,7 @@ interface ResponseError {
23
23
  data: Record<string, string | string[]> | null;
24
24
  }
25
25
 
26
- declare function camelizeKeys<T extends Record<string, any> = Dictionary>(object: Dictionary): T;
26
+ declare function camelizeKeys(object: Dictionary): Dictionary;
27
27
 
28
28
  interface Options$3 {
29
29
  labelType: 'key' | 'value';
@@ -33,21 +33,6 @@ declare function convertEnumToOptions(obj: any, options?: Options$3): {
33
33
  label: unknown;
34
34
  }[];
35
35
 
36
- interface EnrichErrorParams {
37
- message: string;
38
- [key: string]: any;
39
- }
40
- declare class EnrichError extends Error {
41
- constructor(data: EnrichErrorParams);
42
- }
43
-
44
- declare function getStatusMessage(status: number): string;
45
- declare function formatErrorDataMessage(data?: Record<string, string | string[]>): string;
46
- declare function formatErrorForNotify(error: Error | ResponseError | any): {
47
- title: string;
48
- message: any;
49
- };
50
-
51
36
  interface Options$2 extends Intl.NumberFormatOptions {
52
37
  locale?: string;
53
38
  defaultValue?: string | number;
@@ -76,8 +61,6 @@ declare function isElementIgnored({ ignoredClasses, event, }?: {
76
61
 
77
62
  declare function isEmptyObject(object: object): boolean;
78
63
 
79
- declare function isHtml(data: string): boolean;
80
-
81
64
  interface MapOptions {
82
65
  labelKey?: string;
83
66
  valueKey?: string;
@@ -95,7 +78,7 @@ declare function getPaginationParams({ page, limit, }: {
95
78
  limit: number;
96
79
  offset: number;
97
80
  };
98
- declare function getPaginationLimit({ limit, }: {
81
+ declare function getPaginationLimit({ limit }: {
99
82
  limit: string | number;
100
83
  }): number;
101
84
  declare function getPaginationOffset({ page, limit, }: {
@@ -110,7 +93,7 @@ declare function getPaginationPages({ count, limit, }: {
110
93
  declare function parsePhone(phone: string | null | undefined): string;
111
94
 
112
95
  type SnakelizeKeysProp = Record<string | number, any>;
113
- declare function snakelizeKeys<T extends Record<string, any> = SnakelizeKeysProp>(prop: SnakelizeKeysProp): T;
96
+ declare function snakelizeKeys(prop: SnakelizeKeysProp): SnakelizeKeysProp;
114
97
 
115
98
  /**
116
99
  * Принимает на вход число в виде строки или числа,
@@ -151,11 +134,11 @@ declare function useAsyncItems<T extends (...args: any[]) => any>({ apiMethod, q
151
134
  params: MaybeRef<Parameters<T>[0]>;
152
135
  config?: AxiosRequestConfig;
153
136
  }): {
154
- isLoading: vue.Ref<boolean> | vue.Ref<false> | vue.Ref<true>;
137
+ isLoading: vue.Ref<false> | vue.Ref<true>;
155
138
  isFetching: vue.Ref<boolean>;
156
139
  isError: vue.Ref<false> | vue.Ref<true>;
157
- data: vue.Ref<any> | vue.Ref<undefined>;
158
- error: vue.Ref<Error> | vue.Ref<null>;
140
+ data: vue.Ref<any>;
141
+ error: vue.Ref<unknown>;
159
142
  items: vue.ComputedRef<Awaited<ReturnType<T>>["results"]>;
160
143
  count: vue.Ref<number>;
161
144
  refetch: () => void;
@@ -186,11 +169,9 @@ declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extend
186
169
  search: vue.Ref<string>;
187
170
  hasNextPage: vue.ComputedRef<boolean>;
188
171
  isFetching: vue.Ref<boolean>;
189
- isLoading: vue.Ref<boolean> | vue.Ref<false> | vue.Ref<true>;
172
+ isLoading: vue.Ref<false> | vue.Ref<true>;
190
173
  loadPage: (newPage?: number) => void;
191
174
  updateSearch: (value: string) => void;
192
- refetch: () => void;
193
- reload: () => void;
194
175
  };
195
176
 
196
177
  interface ReactiveData {
@@ -215,11 +196,9 @@ declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (pa
215
196
  search: vue.Ref<string>;
216
197
  hasNextPage: vue.ComputedRef<boolean>;
217
198
  isFetching: vue.Ref<boolean>;
218
- isLoading: vue.Ref<boolean> | vue.Ref<false> | vue.Ref<true>;
199
+ isLoading: vue.Ref<false> | vue.Ref<true>;
219
200
  loadPage: (newPage?: number) => void;
220
201
  updateSearch: (value: string) => void;
221
- refetch: () => void;
222
- reload: () => void;
223
202
  };
224
203
 
225
204
  declare function useBreakpoint(): {
@@ -267,7 +246,7 @@ type VersionsList = {
267
246
  declare function useDetectBrowser(versions: VersionsList, userAgent?: any): BrowserInfo;
268
247
 
269
248
  interface VNodeCustom$1 extends VNode {
270
- close: () => void;
249
+ close(): void;
271
250
  }
272
251
  declare function useDialog(): {
273
252
  open: ({ layer, component, props, }: {
@@ -276,7 +255,6 @@ declare function useDialog(): {
276
255
  layer?: number;
277
256
  }) => string;
278
257
  getInstance: (uuid: string) => VNodeCustom$1;
279
- getLayer: (uuid: string) => number;
280
258
  close: (uuid: string) => void;
281
259
  closeAll: () => void;
282
260
  showConfirm: (text?: string) => boolean;
@@ -298,7 +276,7 @@ declare function useGlobalScroll(): {
298
276
  unlock: () => void;
299
277
  };
300
278
 
301
- declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters }: {
279
+ declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters, }: {
302
280
  config: T;
303
281
  initialFilters: K;
304
282
  }): {
@@ -328,7 +306,7 @@ interface Options {
328
306
  declare function useLogger(scope: string, options?: Options): logdown.Logger;
329
307
 
330
308
  interface VNodeCustom extends VNode {
331
- close: () => void;
309
+ close(): void;
332
310
  }
333
311
  /**
334
312
  * @deprecated use useDialog
@@ -369,4 +347,4 @@ declare function isTypeUrl(message?: string): RuleItem;
369
347
  declare function isTypeNumber(value?: number, message?: string): RuleItem;
370
348
  declare function isStrictLength(value?: number, message?: string): RuleItem;
371
349
 
372
- export { AppComponentsResolver, type BrowserInfo, type Dictionary, EnrichError, type ResponseError, UiComponentsResolver, type VersionsList, camelizeKeys, convertEnumToOptions, formatErrorDataMessage, formatErrorForNotify, formatMoney, genHash, genRandomNumber, genUUID, getCardNumber, getCountryFromPhone, getPaginationLimit, getPaginationOffset, getPaginationPages, getPaginationParams, getStatusMessage, isElementIgnored, isEmptyObject, isHtml, isMax, isMin, isRequired, isStrictLength, isTypeEmail, isTypeNumber, isTypeUrl, mapDataObjectForFilters, parsePhone, snakelizeKeys, unformatNumber, useAbortController, useAsyncItems, useAsyncMultiselect, useAsyncSelect, useBreakpoint, useClassName, useDayjs, useDetectBrowser, useDialog, useFilters, useGlobalScroll, useLogger, usePanel, validateNumber, validatePhone };
350
+ export { AppComponentsResolver, BrowserInfo, Dictionary, ResponseError, UiComponentsResolver, VersionsList, camelizeKeys, convertEnumToOptions, formatMoney, genHash, genRandomNumber, genUUID, getCardNumber, getCountryFromPhone, getPaginationLimit, getPaginationOffset, getPaginationPages, getPaginationParams, isElementIgnored, isEmptyObject, isMax, isMin, isRequired, isStrictLength, isTypeEmail, isTypeNumber, isTypeUrl, mapDataObjectForFilters, parsePhone, snakelizeKeys, unformatNumber, useAbortController, useAsyncItems, useAsyncMultiselect, useAsyncSelect, useBreakpoint, useClassName, useDayjs, useDetectBrowser, useDialog, useFilters, useGlobalScroll, useLogger, usePanel, validateNumber, validatePhone };
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import camelCase from 'lodash/camelCase.js';
2
- import flatMap from 'lodash/flatMap.js';
3
2
  import { CURRENCY_DEFAULT, BREAKPOINTS } from '@karta.io/common-data';
4
3
  import { parsePhoneNumberFromString } from 'libphonenumber-js';
5
4
  import snakeCase from 'lodash/snakeCase.js';
@@ -25,16 +24,14 @@ function AppComponentsResolver(options = {}) {
25
24
  return (name) => {
26
25
  const componentName = prefix && name.startsWith(prefix) ? name.substring(prefix.length) : name;
27
26
  const isAppComponent = componentName.startsWith("App");
28
- if (isAppComponent) {
27
+ if (isAppComponent)
29
28
  return { name: componentName, from: "@karta.io/app-components" };
30
- }
31
29
  };
32
30
  }
33
31
 
34
32
  function camelizeKeys(object) {
35
- if (Array.isArray(object)) {
33
+ if (Array.isArray(object))
36
34
  return object.map((v) => camelizeKeys(v));
37
- }
38
35
  if (object !== null && object.constructor === Object) {
39
36
  return Object.keys(object).reduce(
40
37
  (result, key) => ({
@@ -61,109 +58,6 @@ function convertEnumToOptions(obj, options) {
61
58
  }));
62
59
  }
63
60
 
64
- class EnrichError extends Error {
65
- constructor(data) {
66
- super(data.message);
67
- Object.assign(this, data);
68
- }
69
- }
70
-
71
- function isHtml(data) {
72
- try {
73
- if (typeof DOMParser !== "undefined") {
74
- const parser = new DOMParser();
75
- const doc = parser.parseFromString(data, "text/html");
76
- return Array.from(doc.body.childNodes).some(
77
- (node) => node.nodeType === Node.ELEMENT_NODE
78
- );
79
- }
80
- const htmlPattern = /<\/?[a-z][\s\S]*>/i;
81
- return htmlPattern.test(data);
82
- } catch (_) {
83
- return false;
84
- }
85
- }
86
-
87
- function getStatusMessage(status) {
88
- let message = "";
89
- switch (status) {
90
- case 200:
91
- message = "All done. Request successfully executed";
92
- break;
93
- case 201:
94
- message = "Data successfully created";
95
- break;
96
- case 400:
97
- message = "Bad request";
98
- break;
99
- case 401:
100
- message = "Need auth";
101
- break;
102
- case 404:
103
- message = "Not found";
104
- break;
105
- case 500:
106
- message = "Something wrong. Internal server error";
107
- break;
108
- case 501:
109
- message = "501: Not implemented";
110
- break;
111
- case 502:
112
- message = "502: Bad gateway";
113
- break;
114
- case 503:
115
- message = "Service unavailable. Try again later";
116
- break;
117
- default:
118
- message = "Something wrong. Client default error message";
119
- break;
120
- }
121
- return message;
122
- }
123
- function formatErrorDataMessage(data) {
124
- if (!data)
125
- return "";
126
- return Object.values(data).reduce((accum, current) => {
127
- if (current && typeof current === "string")
128
- return accum ? `${accum} | ${current}` : current;
129
- if (Array.isArray(current) && current.length) {
130
- const value = `${flatMap(current).join(" | ")}`;
131
- return accum ? `${accum} | ${value}` : value;
132
- }
133
- return accum;
134
- }, "");
135
- }
136
- function formatErrorForNotify(error) {
137
- if (!error)
138
- return;
139
- if (error.status >= 400 && error.status < 500) {
140
- let message = "";
141
- if (!error.data || typeof error.data === "string" && isHtml(error.data)) {
142
- message = error.statusMessage || error.message || getStatusMessage(error.status);
143
- } else if (typeof error.data === "string" && !isHtml(error.data)) {
144
- message = error.data;
145
- } else {
146
- message = formatErrorDataMessage(error.data);
147
- }
148
- return {
149
- title: "Request error",
150
- message
151
- };
152
- }
153
- if (error.status >= 500) {
154
- return {
155
- title: "Internal server error",
156
- message: error.statusMessage || error.message || getStatusMessage(error.status)
157
- };
158
- }
159
- if (error instanceof Error) {
160
- return {
161
- title: "Internal client error",
162
- message: error.message
163
- };
164
- }
165
- }
166
-
167
61
  function formatMoney(value, currency = CURRENCY_DEFAULT, options = {}) {
168
62
  const { locale = "en-US", defaultValue = 0, ...otherOptions } = options;
169
63
  try {
@@ -181,7 +75,7 @@ function formatMoney(value, currency = CURRENCY_DEFAULT, options = {}) {
181
75
  ...otherOptions
182
76
  });
183
77
  return formatter.format(convertedValue);
184
- } catch (_error) {
78
+ } catch (error) {
185
79
  return defaultValue;
186
80
  }
187
81
  }
@@ -211,7 +105,7 @@ function genUUID() {
211
105
  r = (d2 + r) % 16 | 0;
212
106
  d2 = Math.floor(d2 / 16);
213
107
  }
214
- return (c === "x" ? r : r & 7 | 8).toString(16);
108
+ return (c == "x" ? r : r & 7 | 8).toString(16);
215
109
  });
216
110
  }
217
111
 
@@ -291,9 +185,7 @@ function getPaginationParams({
291
185
  offset: validatedPage * validatedLimit - validatedLimit
292
186
  };
293
187
  }
294
- function getPaginationLimit({
295
- limit
296
- }) {
188
+ function getPaginationLimit({ limit }) {
297
189
  return validateNumber(limit, LIMIT_DEFAULT);
298
190
  }
299
191
  function getPaginationOffset({
@@ -315,17 +207,15 @@ function parsePhone(phone) {
315
207
  if (!phone || typeof phone !== "string")
316
208
  return "";
317
209
  const replacedPhone = phone.replace(/[a-zA-Z]/g, "");
318
- if (replacedPhone.length === 1 && replacedPhone !== "+") {
210
+ if (replacedPhone.length === 1 && replacedPhone !== "+")
319
211
  return `+${replacedPhone}`;
320
- }
321
212
  const phoneNumber = parsePhoneNumberFromString(replacedPhone);
322
213
  return phoneNumber ? phoneNumber.formatInternational() : replacedPhone;
323
214
  }
324
215
 
325
216
  function snakelizeKeys(prop) {
326
- if (Array.isArray(prop)) {
217
+ if (Array.isArray(prop))
327
218
  return prop.map((item) => snakelizeKeys(item));
328
- }
329
219
  if (prop !== null && prop !== void 0 && prop.constructor === Object) {
330
220
  return Object.keys(prop).reduce(
331
221
  (accum, current) => ({
@@ -365,9 +255,8 @@ function unformatNumber(value) {
365
255
  if (commasCount === 1 && !hasSpace && !hasDot) {
366
256
  locale = string.length - 1 - commaIndex === 3 ? LOCALE_EN : LOCALE_RU;
367
257
  }
368
- if (locale === LOCALE_RU) {
258
+ if (locale === LOCALE_RU)
369
259
  return Number(string.replaceAll(" ", "").replace(",", "."));
370
- }
371
260
  if (locale === LOCALE_EN)
372
261
  return Number(string.replaceAll(",", ""));
373
262
  return value;
@@ -378,9 +267,8 @@ function UiComponentsResolver(options = {}) {
378
267
  return (name) => {
379
268
  const componentName = prefix && name.startsWith(prefix) ? name.substring(prefix.length) : name;
380
269
  const isUiComponent = componentName.startsWith("Ui");
381
- if (isUiComponent) {
270
+ if (isUiComponent)
382
271
  return { name: componentName, from: "@karta.io/ui-components" };
383
- }
384
272
  };
385
273
  }
386
274
 
@@ -428,9 +316,7 @@ function useAsyncItems({
428
316
  queryKey: getQueryKey(),
429
317
  queryFn: () => call(toValue(params), config)
430
318
  });
431
- const items = computed(
432
- () => data.value?.results || []
433
- );
319
+ const items = computed(() => data.value?.results || []);
434
320
  const count = ref(0);
435
321
  watch(
436
322
  data,
@@ -507,12 +393,7 @@ function useAsyncMultiselect({
507
393
  color: "#b54708",
508
394
  debug: true
509
395
  });
510
- const paramsForLogger = {
511
- queryKey,
512
- dataItemsKey,
513
- dataItemIdKey,
514
- dataCountKey
515
- };
396
+ const paramsForLogger = { queryKey, dataItemsKey, dataItemIdKey, dataCountKey };
516
397
  const reactiveData = reactive({
517
398
  search: "",
518
399
  page: 1,
@@ -558,9 +439,8 @@ function useAsyncMultiselect({
558
439
  );
559
440
  return;
560
441
  }
561
- if (!get(newValue, dataItemsKey) || get(newValue, dataCountKey) === void 0) {
442
+ if (!get(newValue, dataItemsKey) || get(newValue, dataCountKey) === void 0)
562
443
  return;
563
- }
564
444
  count.value = get(newValue, dataCountKey, 0);
565
445
  const newItems = get(newValue, dataItemsKey);
566
446
  itemsByPages.value = {
@@ -591,9 +471,8 @@ function useAsyncMultiselect({
591
471
  const items = computed(() => {
592
472
  if (!itemsByPages.value)
593
473
  return selectedItemsCached.value;
594
- if (!Object.keys(itemsByPages.value).length) {
474
+ if (!Object.keys(itemsByPages.value).length)
595
475
  return selectedItemsCached.value;
596
- }
597
476
  const itemsByPagesAsArray = Object.values(itemsByPages.value).reduce(
598
477
  (acc, item) => [...acc, ...item],
599
478
  []
@@ -609,7 +488,7 @@ function useAsyncMultiselect({
609
488
  if (!items.value.length)
610
489
  return [];
611
490
  if (!mapOptionCallback)
612
- return items.value;
491
+ return this.items.value;
613
492
  return items.value.map(mapOptionCallback);
614
493
  });
615
494
  const hasNextPage = computed(() => count.value > items.value.length);
@@ -628,28 +507,6 @@ function useAsyncMultiselect({
628
507
  search.value = value;
629
508
  updateSearchWithDebounce(value);
630
509
  };
631
- const queryClient = useQueryClient();
632
- const refetch = () => {
633
- if (reactiveData.page !== 1) {
634
- queryClient.invalidateQueries({
635
- queryKey: [queryKey],
636
- refetchType: "none"
637
- });
638
- loadPage(1);
639
- } else {
640
- queryClient.invalidateQueries({
641
- queryKey: [queryKey]
642
- });
643
- }
644
- };
645
- const reload = () => {
646
- if (reactiveData.page !== 1) {
647
- queryClient.removeQueries({ queryKey: [queryKey] });
648
- loadPage(1);
649
- } else {
650
- queryClient.resetQueries({ queryKey: [queryKey] });
651
- }
652
- };
653
510
  if (isRef(selectedValues)) {
654
511
  watch(selectedValues, async (newSelectedValues) => {
655
512
  if (!newSelectedValues.length) {
@@ -690,9 +547,7 @@ function useAsyncMultiselect({
690
547
  isFetching,
691
548
  isLoading,
692
549
  loadPage,
693
- updateSearch,
694
- refetch,
695
- reload
550
+ updateSearch
696
551
  };
697
552
  }
698
553
 
@@ -724,9 +579,7 @@ function useAsyncSelect({
724
579
  const loadWAC = () => call({
725
580
  page: reactiveData.page,
726
581
  search: reactiveData.search,
727
- ...reactiveData.selectedValue && {
728
- includedIds: [reactiveData.selectedValue]
729
- },
582
+ ...reactiveData.selectedValue && { includedIds: [reactiveData.selectedValue] },
730
583
  ...reactiveData.params && { ...JSON.parse(reactiveData.params) }
731
584
  });
732
585
  const { data, isFetching, isLoading } = useQuery({
@@ -754,9 +607,8 @@ function useAsyncSelect({
754
607
  );
755
608
  return;
756
609
  }
757
- if (!get(newValue, dataItemsKey) || get(newValue, dataCountKey) === void 0) {
610
+ if (!get(newValue, dataItemsKey) || get(newValue, dataCountKey) === void 0)
758
611
  return;
759
- }
760
612
  count.value = get(newValue, dataCountKey, 0);
761
613
  const newItems = get(newValue, dataItemsKey);
762
614
  itemsByPages.value = {
@@ -786,7 +638,7 @@ function useAsyncSelect({
786
638
  if (!items.value.length)
787
639
  return [];
788
640
  if (!mapOptionCallback)
789
- return items.value;
641
+ return this.items.value;
790
642
  return items.value.map(mapOptionCallback);
791
643
  });
792
644
  const hasNextPage = computed(() => count.value > items.value.length);
@@ -801,28 +653,6 @@ function useAsyncSelect({
801
653
  search.value = value;
802
654
  updateSearchWithDebounce(value);
803
655
  };
804
- const queryClient = useQueryClient();
805
- const refetch = () => {
806
- if (reactiveData.page !== 1) {
807
- queryClient.invalidateQueries({
808
- queryKey: [queryKey],
809
- refetchType: "none"
810
- });
811
- loadPage(1);
812
- } else {
813
- queryClient.invalidateQueries({
814
- queryKey: [queryKey]
815
- });
816
- }
817
- };
818
- const reload = () => {
819
- if (reactiveData.page !== 1) {
820
- queryClient.removeQueries({ queryKey: [queryKey] });
821
- loadPage(1);
822
- } else {
823
- queryClient.resetQueries({ queryKey: [queryKey] });
824
- }
825
- };
826
656
  if (isRef(selectedValue)) {
827
657
  watch(selectedValue, (newSelectedValue) => {
828
658
  reactiveData.page = 1;
@@ -846,22 +676,20 @@ function useAsyncSelect({
846
676
  isFetching,
847
677
  isLoading,
848
678
  loadPage,
849
- updateSearch,
850
- refetch,
851
- reload
679
+ updateSearch
852
680
  };
853
681
  }
854
682
 
855
683
  function useBreakpoint() {
856
684
  const breakpoints = useBreakpoints(BREAKPOINTS);
857
685
  const isMobile = breakpoints.smaller("sm");
858
- const isDesktop = breakpoints.greaterOrEqual("md");
859
- const isGreaterXxs = breakpoints.greaterOrEqual("xxs");
860
- const isGreaterXs = breakpoints.greaterOrEqual("xs");
861
- const isGreaterSm = breakpoints.greaterOrEqual("sm");
862
- const isGreaterMd = breakpoints.greaterOrEqual("md");
863
- const isGreaterLg = breakpoints.greaterOrEqual("lg");
864
- const isGreaterXl = breakpoints.greaterOrEqual("xl");
686
+ const isDesktop = breakpoints.greater("md");
687
+ const isGreaterXxs = breakpoints.greater("xxs");
688
+ const isGreaterXs = breakpoints.greater("xs");
689
+ const isGreaterSm = breakpoints.greater("sm");
690
+ const isGreaterMd = breakpoints.greater("md");
691
+ const isGreaterLg = breakpoints.greater("lg");
692
+ const isGreaterXl = breakpoints.greater("xl");
865
693
  return {
866
694
  isMobile,
867
695
  isDesktop,
@@ -928,9 +756,7 @@ function useDayjs(timezone) {
928
756
 
929
757
  function parseVersion(version) {
930
758
  if (typeof version !== "string" && typeof version !== "number") {
931
- throw new TypeError(
932
- "Browser version must be type of string, number or negative boolean"
933
- );
759
+ throw new TypeError("Browser version must be type of string, number or negative boolean");
934
760
  }
935
761
  const [major, minor = 0, patch = 0, build = 0] = typeof version === "string" ? version.split(".").map(Number) : [version];
936
762
  return {
@@ -1010,7 +836,7 @@ function useDialog() {
1010
836
  let dataFromHash;
1011
837
  try {
1012
838
  dataFromHash = JSON.parse(window.atob(hash.slice(HASH_PREFIX.length)));
1013
- } catch (_error) {
839
+ } catch (error) {
1014
840
  logger.warn("*parseHash* cant parse hash");
1015
841
  }
1016
842
  if (typeof dataFromHash !== "object")
@@ -1147,11 +973,6 @@ function useDialog() {
1147
973
  const getInstance = (uuid) => {
1148
974
  return dialogs.find((item) => item.uuid === uuid)?.vnode;
1149
975
  };
1150
- const getLayer = (uuid) => {
1151
- if (!dialogs.length)
1152
- return 0;
1153
- return dialogs.find((dialog) => dialog.uuid === uuid)?.layer || 0;
1154
- };
1155
976
  const isOnTop = (uuid) => {
1156
977
  if (!dialogs.length)
1157
978
  return false;
@@ -1219,7 +1040,6 @@ function useDialog() {
1219
1040
  return {
1220
1041
  open,
1221
1042
  getInstance,
1222
- getLayer,
1223
1043
  close,
1224
1044
  closeAll,
1225
1045
  showConfirm,
@@ -1236,7 +1056,10 @@ const QS_STRINGIFY_PARAMS = {
1236
1056
  addQueryPrefix: true
1237
1057
  };
1238
1058
  const isOpen = ref(false);
1239
- function useFilters({ config, initialFilters }) {
1059
+ function useFilters({
1060
+ config,
1061
+ initialFilters
1062
+ }) {
1240
1063
  const router = useRouter();
1241
1064
  const route = useRoute();
1242
1065
  const parseRouteQuery = (query) => qs.parse(query ?? route.query);
@@ -1244,43 +1067,35 @@ function useFilters({ config, initialFilters }) {
1244
1067
  const parsedRouteQuery = parseRouteQuery();
1245
1068
  if (!parsedRouteQuery.filters)
1246
1069
  return void 0;
1247
- return Object.entries(config).reduce(
1248
- (accum, [currentKey, currentValue]) => {
1249
- if (!parsedRouteQuery.filters[currentKey])
1070
+ return Object.entries(config).reduce((accum, [currentKey, currentValue]) => {
1071
+ if (!parsedRouteQuery.filters[currentKey])
1072
+ return accum;
1073
+ if (currentValue.type === "ARRAY" /* Array */) {
1074
+ const splitValues = parsedRouteQuery.filters[currentKey].split(",");
1075
+ const checkedValue = currentValue?.possibleValues ? splitValues.filter((k) => currentValue?.possibleValues?.includes(k)) : splitValues;
1076
+ if (!checkedValue?.length)
1250
1077
  return accum;
1251
- if (currentValue.type === "ARRAY" /* Array */) {
1252
- const splitValues = parsedRouteQuery.filters[currentKey].split(",");
1253
- const checkedValue = currentValue?.possibleValues ? splitValues.filter(
1254
- (k) => currentValue?.possibleValues?.includes(k)
1255
- ) : splitValues;
1256
- if (!checkedValue?.length)
1257
- return accum;
1258
- return {
1259
- ...accum,
1260
- [currentKey]: checkedValue
1261
- };
1262
- }
1263
1078
  return {
1264
1079
  ...accum,
1265
- [currentKey]: parsedRouteQuery.filters[currentKey]
1080
+ [currentKey]: checkedValue
1266
1081
  };
1267
- },
1268
- {}
1269
- );
1082
+ }
1083
+ return {
1084
+ ...accum,
1085
+ [currentKey]: parsedRouteQuery.filters[currentKey]
1086
+ };
1087
+ }, {});
1270
1088
  });
1271
1089
  const filtersCount = computed(
1272
1090
  () => filtersFromQuery.value ? Object.keys(filtersFromQuery.value).length : 0
1273
1091
  );
1274
1092
  const setQueryFromFilters = (filters) => {
1275
1093
  const parsedRouteQuery = parseRouteQuery();
1276
- const filteredValue = Object.entries(filters).reduce(
1277
- (accum, [currentKey, currentValue]) => {
1278
- if (!currentValue?.length)
1279
- return accum;
1280
- return { ...accum, [currentKey]: currentValue };
1281
- },
1282
- {}
1283
- );
1094
+ const filteredValue = Object.entries(filters).reduce((accum, [currentKey, currentValue]) => {
1095
+ if (!currentValue?.length)
1096
+ return accum;
1097
+ return { ...accum, [currentKey]: currentValue };
1098
+ }, {});
1284
1099
  const query = qs.stringify(
1285
1100
  {
1286
1101
  ...parsedRouteQuery,
@@ -1289,7 +1104,7 @@ function useFilters({ config, initialFilters }) {
1289
1104
  },
1290
1105
  QS_STRINGIFY_PARAMS
1291
1106
  );
1292
- router.push(query.replaceAll("#", ""));
1107
+ router.push(query);
1293
1108
  };
1294
1109
  const getValidatedParams = (query) => {
1295
1110
  const parsedRouteQuery = parseRouteQuery(query);
@@ -1317,15 +1132,12 @@ function useFilters({ config, initialFilters }) {
1317
1132
  });
1318
1133
  };
1319
1134
  const updateMany = (filters) => {
1320
- const newFilters = Object.entries(filters).reduce(
1321
- (accum, [currentKey, currentValue]) => {
1322
- return {
1323
- ...accum,
1324
- [currentKey]: currentValue ? String(currentValue) : void 0
1325
- };
1326
- },
1327
- {}
1328
- );
1135
+ const newFilters = Object.entries(filters).reduce((accum, [currentKey, currentValue]) => {
1136
+ return {
1137
+ ...accum,
1138
+ [currentKey]: currentValue ? String(currentValue) : void 0
1139
+ };
1140
+ }, {});
1329
1141
  setQueryFromFilters({
1330
1142
  ...filtersModel.value,
1331
1143
  ...newFilters
@@ -1501,7 +1313,7 @@ function usePanel() {
1501
1313
  let dataFromHash;
1502
1314
  try {
1503
1315
  dataFromHash = JSON.parse(window.atob(newHash.slice(1)));
1504
- } catch (_error) {
1316
+ } catch (error) {
1505
1317
  logger.error("*watchHash* cant parse hash");
1506
1318
  }
1507
1319
  if (typeof dataFromHash !== "object")
@@ -1604,4 +1416,4 @@ function isStrictLength(value = 3, message) {
1604
1416
  };
1605
1417
  }
1606
1418
 
1607
- export { AppComponentsResolver, EnrichError, UiComponentsResolver, camelizeKeys, convertEnumToOptions, formatErrorDataMessage, formatErrorForNotify, formatMoney, genHash, genRandomNumber, genUUID, getCardNumber, getCountryFromPhone, getPaginationLimit, getPaginationOffset, getPaginationPages, getPaginationParams, getStatusMessage, isElementIgnored, isEmptyObject, isHtml, isMax, isMin, isRequired, isStrictLength, isTypeEmail, isTypeNumber, isTypeUrl, mapDataObjectForFilters, parsePhone, snakelizeKeys, unformatNumber, useAbortController, useAsyncItems, useAsyncMultiselect, useAsyncSelect, useBreakpoint, useClassName, useDayjs, useDetectBrowser, useDialog, useFilters, useGlobalScroll, useLogger, usePanel, validateNumber, validatePhone };
1419
+ export { AppComponentsResolver, UiComponentsResolver, camelizeKeys, convertEnumToOptions, formatMoney, genHash, genRandomNumber, genUUID, getCardNumber, getCountryFromPhone, getPaginationLimit, getPaginationOffset, getPaginationPages, getPaginationParams, isElementIgnored, isEmptyObject, isMax, isMin, isRequired, isStrictLength, isTypeEmail, isTypeNumber, isTypeUrl, mapDataObjectForFilters, parsePhone, snakelizeKeys, unformatNumber, useAbortController, useAsyncItems, useAsyncMultiselect, useAsyncSelect, useBreakpoint, useClassName, useDayjs, useDetectBrowser, useDialog, useFilters, useGlobalScroll, useLogger, usePanel, validateNumber, validatePhone };