@karta.io/utils 1.0.0-beta.5 → 1.0.0-beta.51
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/helpers/appComponentsResolver.d.ts +5 -0
- package/dist/helpers/camelizeKeys.d.ts +2 -0
- package/dist/helpers/convertEnumToOptions.d.ts +8 -0
- package/dist/helpers/enrichError.d.ts +8 -0
- package/dist/helpers/formatError.d.ts +7 -0
- package/dist/helpers/formatMoney.d.ts +6 -0
- package/dist/helpers/genHash.d.ts +1 -0
- package/dist/helpers/genRandomNumber.d.ts +1 -0
- package/dist/helpers/genUUID.d.ts +1 -0
- package/dist/helpers/getCardNumber.d.ts +7 -0
- package/dist/helpers/getCountryFromPhone.d.ts +1 -0
- package/dist/helpers/isElementIgnored.d.ts +4 -0
- package/dist/helpers/isEmptyObject.d.ts +1 -0
- package/dist/helpers/isHtml.d.ts +1 -0
- package/dist/helpers/mapDataObjectForFilters.d.ts +10 -0
- package/dist/helpers/pagination.d.ts +18 -0
- package/dist/helpers/parsePhone.d.ts +1 -0
- package/dist/helpers/snakelizeKeys.d.ts +3 -0
- package/dist/helpers/uiComponentsResolver.d.ts +5 -0
- package/dist/helpers/unformatNumber.d.ts +19 -0
- package/dist/helpers/validateNumber.d.ts +1 -0
- package/dist/hooks/useAbortController.d.ts +6 -0
- package/dist/hooks/useAsyncItems.d.ts +19 -0
- package/dist/hooks/useAsyncMultiselect.d.ts +31 -0
- package/dist/hooks/useAsyncSelect.d.ts +30 -0
- package/dist/hooks/useBreakpoint.d.ts +11 -0
- package/dist/hooks/useClassName.d.ts +9 -0
- package/dist/hooks/useDayjs.d.ts +10 -0
- package/dist/hooks/useDetectBrowser.d.ts +13 -0
- package/dist/hooks/useDialog.d.ts +48 -0
- package/dist/hooks/useFilters.d.ts +18 -0
- package/dist/hooks/useGlobalScroll.d.ts +6 -0
- package/dist/hooks/useLogger.d.ts +8 -0
- package/dist/hooks/usePanel.d.ts +27 -0
- package/dist/index.cjs +1550 -1352
- package/dist/index.d.ts +37 -350
- package/dist/index.mjs +1503 -1329
- package/dist/types.d.ts +11 -0
- package/dist/validator/formRules.d.ts +14 -0
- package/dist/validator/validatePhone.d.ts +1 -0
- package/package.json +39 -41
- package/dist/index.d.cts +0 -350
- package/dist/index.d.mts +0 -350
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ResponseError } from '../types';
|
|
2
|
+
export declare function getStatusMessage(status: number): string;
|
|
3
|
+
export declare function formatErrorDataMessage(data?: Record<string, string | string[]>): string;
|
|
4
|
+
export declare function formatErrorForNotify(error: Error | ResponseError | any): {
|
|
5
|
+
title: string;
|
|
6
|
+
message: any;
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function genHash(hashLength: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function genRandomNumber(min: number, max: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function genUUID(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCountryFromPhone(phone: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEmptyObject(object: object): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isHtml(data: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function getPaginationParams({ page, limit, }: {
|
|
2
|
+
page: string | number;
|
|
3
|
+
limit: string | number;
|
|
4
|
+
}): {
|
|
5
|
+
limit: number;
|
|
6
|
+
offset: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function getPaginationLimit({ limit, }: {
|
|
9
|
+
limit: string | number;
|
|
10
|
+
}): number;
|
|
11
|
+
export declare function getPaginationOffset({ page, limit, }: {
|
|
12
|
+
page: string | number;
|
|
13
|
+
limit: string | number;
|
|
14
|
+
}): number;
|
|
15
|
+
export declare function getPaginationPages({ count, limit, }: {
|
|
16
|
+
count: number;
|
|
17
|
+
limit: string | number;
|
|
18
|
+
}): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parsePhone(phone: string | null | undefined): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Принимает на вход число в виде строки или числа,
|
|
3
|
+
* возвращает корректное значение типа Number (убирает лишние пробелы и запятые)
|
|
4
|
+
* @example
|
|
5
|
+
* // returns 1000
|
|
6
|
+
* unformatNumber('1 000');
|
|
7
|
+
* @example
|
|
8
|
+
* // returns 1000
|
|
9
|
+
* unformatNumber('1,000')
|
|
10
|
+
* @example
|
|
11
|
+
* // returns 1000.123
|
|
12
|
+
* unformatNummber('1 000,123')
|
|
13
|
+
* @example
|
|
14
|
+
* // returns 1000.123
|
|
15
|
+
* unformatNummber('1,000.123')
|
|
16
|
+
* @param value
|
|
17
|
+
* @return number
|
|
18
|
+
*/
|
|
19
|
+
export declare function unformatNumber(value: string | number): string | number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateNumber(value: string | number, defaultValue: number): number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MaybeRef, Ref, ComputedRef } from 'vue';
|
|
2
|
+
import { HttpRequestConfig } from '../types';
|
|
3
|
+
export declare function useAsyncItems<T extends (...args: any[]) => any>({ apiMethod, queryKey, params, config, }: {
|
|
4
|
+
apiMethod: T;
|
|
5
|
+
queryKey: string;
|
|
6
|
+
params: MaybeRef<Parameters<T>[0]>;
|
|
7
|
+
config?: HttpRequestConfig;
|
|
8
|
+
}): {
|
|
9
|
+
isLoading: Ref<false, false> | Ref<true, true> | Ref<boolean, boolean>;
|
|
10
|
+
isFetching: Ref<boolean, boolean>;
|
|
11
|
+
isError: Ref<false, false> | Ref<true, true>;
|
|
12
|
+
data: Ref<any, any> | Ref<undefined, undefined>;
|
|
13
|
+
error: Ref<Error, Error> | Ref<null, null>;
|
|
14
|
+
items: ComputedRef<Awaited<ReturnType<T>>["results"]>;
|
|
15
|
+
count: Ref<number, number>;
|
|
16
|
+
refetch: () => void;
|
|
17
|
+
reload: () => void;
|
|
18
|
+
abort: () => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MaybeRef, ComputedRef, Ref } from 'vue';
|
|
2
|
+
interface ReactiveData {
|
|
3
|
+
search: string;
|
|
4
|
+
page: number;
|
|
5
|
+
selectedValues?: any[];
|
|
6
|
+
params?: any;
|
|
7
|
+
}
|
|
8
|
+
export declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValues, params, queryKey, dataItemsKey, dataItemIdKey, dataCountKey, delay, onUpdated, }: {
|
|
9
|
+
apiMethod: T;
|
|
10
|
+
mapOptionCallback?: K;
|
|
11
|
+
selectedValues?: MaybeRef<Parameters<T>[0]['includedIds']>;
|
|
12
|
+
params?: MaybeRef<Partial<Parameters<T>[0]>>;
|
|
13
|
+
queryKey: string;
|
|
14
|
+
dataItemsKey?: string;
|
|
15
|
+
dataItemIdKey?: string;
|
|
16
|
+
dataCountKey?: string;
|
|
17
|
+
delay?: number;
|
|
18
|
+
onUpdated?: (data: ReactiveData) => void;
|
|
19
|
+
}): {
|
|
20
|
+
items: ComputedRef<any[]>;
|
|
21
|
+
options: ComputedRef<ReturnType<K>[]>;
|
|
22
|
+
search: Ref<string, string>;
|
|
23
|
+
hasNextPage: ComputedRef<boolean>;
|
|
24
|
+
isFetching: Ref<boolean, boolean>;
|
|
25
|
+
isLoading: Ref<false, false> | Ref<true, true> | Ref<boolean, boolean>;
|
|
26
|
+
loadPage: (newPage?: number) => void;
|
|
27
|
+
updateSearch: (value: string) => void;
|
|
28
|
+
refetch: () => void;
|
|
29
|
+
reload: () => void;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MaybeRef, ComputedRef, Ref } from 'vue';
|
|
2
|
+
interface ReactiveData {
|
|
3
|
+
search: string;
|
|
4
|
+
page: number;
|
|
5
|
+
selectedValue?: any[];
|
|
6
|
+
params?: any;
|
|
7
|
+
}
|
|
8
|
+
export declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValue, params, queryKey, dataItemsKey, dataCountKey, delay, onUpdated, }: {
|
|
9
|
+
apiMethod: T;
|
|
10
|
+
mapOptionCallback?: K;
|
|
11
|
+
selectedValue?: MaybeRef<Parameters<T>[0]['includedIds']>;
|
|
12
|
+
params?: MaybeRef<Partial<Parameters<T>[0]>>;
|
|
13
|
+
queryKey: string;
|
|
14
|
+
dataItemsKey?: string;
|
|
15
|
+
dataCountKey?: string;
|
|
16
|
+
delay?: number;
|
|
17
|
+
onUpdated?: (data: ReactiveData) => void;
|
|
18
|
+
}): {
|
|
19
|
+
items: ComputedRef<any[]>;
|
|
20
|
+
options: ComputedRef<ReturnType<K>[]>;
|
|
21
|
+
search: Ref<string, string>;
|
|
22
|
+
hasNextPage: ComputedRef<boolean>;
|
|
23
|
+
isFetching: Ref<boolean, boolean>;
|
|
24
|
+
isLoading: Ref<false, false> | Ref<true, true> | Ref<boolean, boolean>;
|
|
25
|
+
loadPage: (newPage?: number) => void;
|
|
26
|
+
updateSearch: (value: string) => void;
|
|
27
|
+
refetch: () => void;
|
|
28
|
+
reload: () => void;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
export declare function useBreakpoint(): {
|
|
3
|
+
isMobile: ComputedRef<boolean>;
|
|
4
|
+
isDesktop: ComputedRef<boolean>;
|
|
5
|
+
isGreaterXxs: ComputedRef<boolean>;
|
|
6
|
+
isGreaterXs: ComputedRef<boolean>;
|
|
7
|
+
isGreaterSm: ComputedRef<boolean>;
|
|
8
|
+
isGreaterMd: ComputedRef<boolean>;
|
|
9
|
+
isGreaterLg: ComputedRef<boolean>;
|
|
10
|
+
isGreaterXl: ComputedRef<boolean>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function useClassName(block: string): {
|
|
2
|
+
b: (blockSuffix?: string) => string;
|
|
3
|
+
e: (element?: string) => string;
|
|
4
|
+
m: (modifier?: string, condition?: boolean) => string;
|
|
5
|
+
em: (element?: string, modifier?: string, condition?: boolean) => string;
|
|
6
|
+
mv: (modifier: string, modifierValue: string, condition?: boolean) => string;
|
|
7
|
+
cssVar: (object: Record<string, string | number>) => Record<string, string | number>;
|
|
8
|
+
cssVarName: (name: string) => string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as dayjs } from 'dayjs';
|
|
2
|
+
/**
|
|
3
|
+
* Обертка над dayjs, позволяющая задавать timezone
|
|
4
|
+
* @see https://day.js.org/en/
|
|
5
|
+
*
|
|
6
|
+
* Использовать параметр timezone нужно крайне аккуратно,
|
|
7
|
+
* может привести к утечкам памяти
|
|
8
|
+
* @todo Подумать как сделать оптимальнее
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDayjs(timezone?: string): (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean) => dayjs.Dayjs;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Browser } from 'detect-browser';
|
|
2
|
+
export interface BrowserInfo {
|
|
3
|
+
isDeprecated?: boolean;
|
|
4
|
+
name?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
os?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
options?: any;
|
|
9
|
+
}
|
|
10
|
+
export type VersionsList = {
|
|
11
|
+
[key in Browser]?: string | boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function useDetectBrowser(versions: VersionsList, userAgent?: any): BrowserInfo;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component, EmitsOptions, VNode } from 'vue';
|
|
2
|
+
interface VNodeCustom extends VNode {
|
|
3
|
+
close: () => void;
|
|
4
|
+
}
|
|
5
|
+
export interface Dialog {
|
|
6
|
+
uuid: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
vnode: VNodeCustom;
|
|
9
|
+
layer: number;
|
|
10
|
+
}
|
|
11
|
+
export interface DialogOptions {
|
|
12
|
+
hashPrefix?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DialogParseHashResult {
|
|
15
|
+
name: string;
|
|
16
|
+
layer: number;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
export declare function useDialog(options?: DialogOptions): {
|
|
20
|
+
open: ({ layer, component, props, }: {
|
|
21
|
+
component: Component;
|
|
22
|
+
props?: any;
|
|
23
|
+
layer?: number;
|
|
24
|
+
}) => string;
|
|
25
|
+
getInstance: (uuid: string) => VNodeCustom;
|
|
26
|
+
getLayer: (uuid: string) => number;
|
|
27
|
+
close: (uuid: string) => void;
|
|
28
|
+
closeAll: () => void;
|
|
29
|
+
showConfirm: (text?: string) => boolean;
|
|
30
|
+
isOnTop: (uuid: string) => boolean;
|
|
31
|
+
genHash: ({ layer, componentName, props, }: {
|
|
32
|
+
componentName: string;
|
|
33
|
+
props?: any;
|
|
34
|
+
layer?: number;
|
|
35
|
+
}) => string;
|
|
36
|
+
parseHash: (hash: string, componentName: string) => DialogParseHashResult | undefined;
|
|
37
|
+
clearHash: () => void;
|
|
38
|
+
openByHash: ({ layer, component, props, }: {
|
|
39
|
+
component: Component;
|
|
40
|
+
props?: any;
|
|
41
|
+
layer?: number;
|
|
42
|
+
}) => void;
|
|
43
|
+
watchHash: ({ component, events, }: {
|
|
44
|
+
component: Component;
|
|
45
|
+
events?: EmitsOptions;
|
|
46
|
+
}) => any;
|
|
47
|
+
};
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Ref, ComputedRef } from 'vue';
|
|
2
|
+
export declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters }: {
|
|
3
|
+
config: T;
|
|
4
|
+
initialFilters: K;
|
|
5
|
+
}): {
|
|
6
|
+
isOpen: Ref<boolean, boolean>;
|
|
7
|
+
filtersModel: Ref<K, K>;
|
|
8
|
+
filtersFromQuery: ComputedRef<{}>;
|
|
9
|
+
filtersCount: ComputedRef<number>;
|
|
10
|
+
updateOne: (key: keyof K, value: any) => void;
|
|
11
|
+
updateMany: (filters: Record<string, any>) => void;
|
|
12
|
+
open: () => void;
|
|
13
|
+
clear: () => void;
|
|
14
|
+
setQueryFromFilters: (filters: Record<string, any>) => void;
|
|
15
|
+
getValidatedParams: (query: Record<string, any>) => {
|
|
16
|
+
filters: any;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Component, EmitsOptions, VNode } from 'vue';
|
|
2
|
+
interface VNodeCustom extends VNode {
|
|
3
|
+
close: () => void;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use useDialog
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePanel(): {
|
|
9
|
+
open: ({ layer, component, props, }: {
|
|
10
|
+
component: Component;
|
|
11
|
+
props?: any;
|
|
12
|
+
layer?: number;
|
|
13
|
+
}) => string;
|
|
14
|
+
getInstance: (uuid: string) => VNodeCustom;
|
|
15
|
+
close: (uuid: string) => void;
|
|
16
|
+
closeAll: () => void;
|
|
17
|
+
openByHash: ({ layer, component, props, }: {
|
|
18
|
+
component: Component;
|
|
19
|
+
props?: any;
|
|
20
|
+
layer?: number;
|
|
21
|
+
}) => void;
|
|
22
|
+
watchHash: ({ component, events, }: {
|
|
23
|
+
component: Component;
|
|
24
|
+
events?: EmitsOptions;
|
|
25
|
+
}) => any;
|
|
26
|
+
};
|
|
27
|
+
export {};
|