@karta.io/utils 0.32.0 → 0.32.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/index.d.ts +128 -128
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,180 +4,180 @@ import dayjs from 'dayjs';
|
|
|
4
4
|
import { Browser } from 'detect-browser';
|
|
5
5
|
import logdown from 'logdown';
|
|
6
6
|
|
|
7
|
-
interface Dictionary {
|
|
8
|
-
[keys: string | number]: any;
|
|
9
|
-
}
|
|
10
|
-
interface ResponseError {
|
|
11
|
-
status: number;
|
|
12
|
-
statusMessage: string;
|
|
13
|
-
message: string;
|
|
14
|
-
data: Record<string, string | string[]> | null;
|
|
7
|
+
interface Dictionary {
|
|
8
|
+
[keys: string | number]: any;
|
|
9
|
+
}
|
|
10
|
+
interface ResponseError {
|
|
11
|
+
status: number;
|
|
12
|
+
statusMessage: string;
|
|
13
|
+
message: string;
|
|
14
|
+
data: Record<string, string | string[]> | null;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare function camelizeKeys(object: Dictionary): Dictionary;
|
|
18
18
|
|
|
19
19
|
declare function createClassName(className: string): (...classNames: string[]) => string;
|
|
20
20
|
|
|
21
|
-
declare function formatMoney(value: string | number | null | undefined, currency?: string, options?: {
|
|
22
|
-
locale: string;
|
|
23
|
-
minimumFractionDigits: number;
|
|
24
|
-
maximumFractionDigits: number;
|
|
21
|
+
declare function formatMoney(value: string | number | null | undefined, currency?: string, options?: {
|
|
22
|
+
locale: string;
|
|
23
|
+
minimumFractionDigits: number;
|
|
24
|
+
maximumFractionDigits: number;
|
|
25
25
|
}): string;
|
|
26
26
|
|
|
27
|
-
declare function genLoadingTableRows(columns: Dictionary[], limit: number): {
|
|
28
|
-
id: number | undefined;
|
|
29
|
-
key?: undefined;
|
|
27
|
+
declare function genLoadingTableRows(columns: Dictionary[], limit: number): {
|
|
28
|
+
id: number | undefined;
|
|
29
|
+
key?: undefined;
|
|
30
30
|
}[];
|
|
31
31
|
|
|
32
32
|
declare function genRandomNumber(min: number, max: number): number;
|
|
33
33
|
|
|
34
34
|
declare function genUUID(): string;
|
|
35
35
|
|
|
36
|
-
interface Options$1 {
|
|
37
|
-
hasOnlyLast4: boolean;
|
|
38
|
-
isHidden: boolean;
|
|
39
|
-
dot: string;
|
|
40
|
-
}
|
|
36
|
+
interface Options$1 {
|
|
37
|
+
hasOnlyLast4: boolean;
|
|
38
|
+
isHidden: boolean;
|
|
39
|
+
dot: string;
|
|
40
|
+
}
|
|
41
41
|
declare function getCardNumber(number: string, options?: Partial<Options$1>): string;
|
|
42
42
|
|
|
43
43
|
declare function getCountryFromPhone(phone: string): string;
|
|
44
44
|
|
|
45
|
-
declare function isElementIgnored({ ignoredClasses, event, }?: {
|
|
46
|
-
ignoredClasses?: string[];
|
|
47
|
-
event?: Event;
|
|
45
|
+
declare function isElementIgnored({ ignoredClasses, event, }?: {
|
|
46
|
+
ignoredClasses?: string[];
|
|
47
|
+
event?: Event;
|
|
48
48
|
}): boolean;
|
|
49
49
|
|
|
50
50
|
declare function isEmptyObject(object: {}): boolean;
|
|
51
51
|
|
|
52
|
-
declare function getPaginationParams({ page, limit, }: {
|
|
53
|
-
page: string | number;
|
|
54
|
-
limit: string | number;
|
|
55
|
-
}): {
|
|
56
|
-
limit: number;
|
|
57
|
-
offset: number;
|
|
58
|
-
};
|
|
59
|
-
declare function getPaginationLimit({ limit, }: {
|
|
60
|
-
limit: string | number;
|
|
61
|
-
}): number;
|
|
62
|
-
declare function getPaginationOffset({ page, limit, }: {
|
|
63
|
-
page: string | number;
|
|
64
|
-
limit: string | number;
|
|
65
|
-
}): number;
|
|
66
|
-
declare function getPaginationPages({ count, limit, }: {
|
|
67
|
-
count: number;
|
|
68
|
-
limit: string | number;
|
|
52
|
+
declare function getPaginationParams({ page, limit, }: {
|
|
53
|
+
page: string | number;
|
|
54
|
+
limit: string | number;
|
|
55
|
+
}): {
|
|
56
|
+
limit: number;
|
|
57
|
+
offset: number;
|
|
58
|
+
};
|
|
59
|
+
declare function getPaginationLimit({ limit, }: {
|
|
60
|
+
limit: string | number;
|
|
61
|
+
}): number;
|
|
62
|
+
declare function getPaginationOffset({ page, limit, }: {
|
|
63
|
+
page: string | number;
|
|
64
|
+
limit: string | number;
|
|
65
|
+
}): number;
|
|
66
|
+
declare function getPaginationPages({ count, limit, }: {
|
|
67
|
+
count: number;
|
|
68
|
+
limit: string | number;
|
|
69
69
|
}): number;
|
|
70
70
|
|
|
71
71
|
declare function parsePhone(phone: string): string;
|
|
72
72
|
|
|
73
|
-
type SnakelizeKeysProp = Record<string | number, any>;
|
|
73
|
+
type SnakelizeKeysProp = Record<string | number, any>;
|
|
74
74
|
declare function snakelizeKeys(prop: SnakelizeKeysProp): SnakelizeKeysProp;
|
|
75
75
|
|
|
76
|
-
/**
|
|
77
|
-
* Принимает на вход число в виде строки или числа,
|
|
78
|
-
* возвращает корректное значение типа Number (убирает лишние пробелы и запятые)
|
|
79
|
-
* @example
|
|
80
|
-
* // returns 1000
|
|
81
|
-
* unformatNumber('1 000');
|
|
82
|
-
* @example
|
|
83
|
-
* // returns 1000
|
|
84
|
-
* unformatNumber('1,000')
|
|
85
|
-
* @example
|
|
86
|
-
* // returns 1000.123
|
|
87
|
-
* unformatNummber('1 000,123')
|
|
88
|
-
* @example
|
|
89
|
-
* // returns 1000.123
|
|
90
|
-
* unformatNummber('1,000.123')
|
|
91
|
-
* @param value
|
|
92
|
-
* @return number
|
|
93
|
-
*/
|
|
76
|
+
/**
|
|
77
|
+
* Принимает на вход число в виде строки или числа,
|
|
78
|
+
* возвращает корректное значение типа Number (убирает лишние пробелы и запятые)
|
|
79
|
+
* @example
|
|
80
|
+
* // returns 1000
|
|
81
|
+
* unformatNumber('1 000');
|
|
82
|
+
* @example
|
|
83
|
+
* // returns 1000
|
|
84
|
+
* unformatNumber('1,000')
|
|
85
|
+
* @example
|
|
86
|
+
* // returns 1000.123
|
|
87
|
+
* unformatNummber('1 000,123')
|
|
88
|
+
* @example
|
|
89
|
+
* // returns 1000.123
|
|
90
|
+
* unformatNummber('1,000.123')
|
|
91
|
+
* @param value
|
|
92
|
+
* @return number
|
|
93
|
+
*/
|
|
94
94
|
declare function unformatNumber(value: string | number): string | number;
|
|
95
95
|
|
|
96
96
|
declare function validateNumber(value: string | number, defaultValue: number): number;
|
|
97
97
|
|
|
98
|
-
interface UiComponentsResolverOptions {
|
|
99
|
-
prefix?: string;
|
|
100
|
-
}
|
|
98
|
+
interface UiComponentsResolverOptions {
|
|
99
|
+
prefix?: string;
|
|
100
|
+
}
|
|
101
101
|
declare function UiComponentsResolver(options?: UiComponentsResolverOptions): any;
|
|
102
102
|
|
|
103
|
-
declare function useAbortController<T extends (...args: any[]) => any>(callback: T): {
|
|
104
|
-
call(...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
|
|
105
|
-
abort(): void;
|
|
106
|
-
isAborted(error: ResponseError): boolean;
|
|
103
|
+
declare function useAbortController<T extends (...args: any[]) => any>(callback: T): {
|
|
104
|
+
call(...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
|
|
105
|
+
abort(): void;
|
|
106
|
+
isAborted(error: ResponseError): boolean;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extends (params: Awaited<ReturnType<T>>['results'][0]) => any>({ apiMethod, mapResultCallback, selectedValues, params, }: {
|
|
110
|
-
apiMethod: T;
|
|
111
|
-
mapResultCallback: K;
|
|
112
|
-
selectedValues: ComputedRef<Parameters<T>[0]['includedIds']> | WritableComputedRef<Parameters<T>[0]['includedIds']>;
|
|
113
|
-
params?: Parameters<T>[0];
|
|
114
|
-
}): {
|
|
115
|
-
search: vue.Ref<string>;
|
|
116
|
-
options: ComputedRef<ReturnType<K>[1][]>;
|
|
117
|
-
loading: vue.Ref<boolean>;
|
|
118
|
-
hasNextPage: ComputedRef<boolean>;
|
|
119
|
-
items: vue.Ref<Map<ReturnType<K>[0], ReturnType<K>[1]>>;
|
|
120
|
-
loadItems: (isSearch?: boolean) => Promise<void>;
|
|
121
|
-
handleSearch: (value: string) => Promise<void>;
|
|
109
|
+
declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extends (params: Awaited<ReturnType<T>>['results'][0]) => any>({ apiMethod, mapResultCallback, selectedValues, params, }: {
|
|
110
|
+
apiMethod: T;
|
|
111
|
+
mapResultCallback: K;
|
|
112
|
+
selectedValues: ComputedRef<Parameters<T>[0]['includedIds']> | WritableComputedRef<Parameters<T>[0]['includedIds']>;
|
|
113
|
+
params?: Parameters<T>[0];
|
|
114
|
+
}): {
|
|
115
|
+
search: vue.Ref<string>;
|
|
116
|
+
options: ComputedRef<ReturnType<K>[1][]>;
|
|
117
|
+
loading: vue.Ref<boolean>;
|
|
118
|
+
hasNextPage: ComputedRef<boolean>;
|
|
119
|
+
items: vue.Ref<Map<ReturnType<K>[0], ReturnType<K>[1]>>;
|
|
120
|
+
loadItems: (isSearch?: boolean) => Promise<void>;
|
|
121
|
+
handleSearch: (value: string) => Promise<void>;
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (params: Awaited<ReturnType<T>>['results'][0]) => any>({ apiMethod, mapResultCallback, includedIds, params, }: {
|
|
125
|
-
apiMethod: T;
|
|
126
|
-
mapResultCallback: K;
|
|
127
|
-
includedIds?: Parameters<T>[0]['includedIds'];
|
|
128
|
-
params?: Parameters<T>[0];
|
|
129
|
-
}): {
|
|
130
|
-
search: vue.Ref<string>;
|
|
131
|
-
options: vue.ComputedRef<ReturnType<K>[1][]>;
|
|
132
|
-
loading: vue.Ref<boolean>;
|
|
133
|
-
hasNextPage: vue.ComputedRef<boolean>;
|
|
134
|
-
items: vue.Ref<Map<ReturnType<K>[0], ReturnType<K>[1]>>;
|
|
135
|
-
loadItems: (isSearch?: boolean) => Promise<void>;
|
|
136
|
-
handleSearch: (value: string) => Promise<void>;
|
|
124
|
+
declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (params: Awaited<ReturnType<T>>['results'][0]) => any>({ apiMethod, mapResultCallback, includedIds, params, }: {
|
|
125
|
+
apiMethod: T;
|
|
126
|
+
mapResultCallback: K;
|
|
127
|
+
includedIds?: Parameters<T>[0]['includedIds'];
|
|
128
|
+
params?: Parameters<T>[0];
|
|
129
|
+
}): {
|
|
130
|
+
search: vue.Ref<string>;
|
|
131
|
+
options: vue.ComputedRef<ReturnType<K>[1][]>;
|
|
132
|
+
loading: vue.Ref<boolean>;
|
|
133
|
+
hasNextPage: vue.ComputedRef<boolean>;
|
|
134
|
+
items: vue.Ref<Map<ReturnType<K>[0], ReturnType<K>[1]>>;
|
|
135
|
+
loadItems: (isSearch?: boolean) => Promise<void>;
|
|
136
|
+
handleSearch: (value: string) => Promise<void>;
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
declare const useClassName: (block: string) => {
|
|
140
|
-
b: (blockSuffix?: string) => string;
|
|
141
|
-
e: (element?: string) => string;
|
|
142
|
-
m: (modifier?: string, condition?: boolean) => string;
|
|
143
|
-
em: (element?: string, modifier?: string, condition?: boolean) => string;
|
|
144
|
-
mv: (modifier: string, modifierValue: string, condition?: boolean) => string;
|
|
145
|
-
cssVar: (object: Record<string, string>) => Record<string, string>;
|
|
146
|
-
cssVarName: (name: string) => string;
|
|
139
|
+
declare const useClassName: (block: string) => {
|
|
140
|
+
b: (blockSuffix?: string) => string;
|
|
141
|
+
e: (element?: string) => string;
|
|
142
|
+
m: (modifier?: string, condition?: boolean) => string;
|
|
143
|
+
em: (element?: string, modifier?: string, condition?: boolean) => string;
|
|
144
|
+
mv: (modifier: string, modifierValue: string, condition?: boolean) => string;
|
|
145
|
+
cssVar: (object: Record<string, string>) => Record<string, string>;
|
|
146
|
+
cssVarName: (name: string) => string;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
/**
|
|
150
|
-
* Обертка над dayjs, позволяющая задавать timezone
|
|
151
|
-
* @see https://day.js.org/en/
|
|
152
|
-
*
|
|
153
|
-
* Использовать параметр timezone нужно крайне аккуратно,
|
|
154
|
-
* может привести к утечкам памяти
|
|
155
|
-
* @todo Подумать как сделать оптимальнее
|
|
156
|
-
*/
|
|
149
|
+
/**
|
|
150
|
+
* Обертка над dayjs, позволяющая задавать timezone
|
|
151
|
+
* @see https://day.js.org/en/
|
|
152
|
+
*
|
|
153
|
+
* Использовать параметр timezone нужно крайне аккуратно,
|
|
154
|
+
* может привести к утечкам памяти
|
|
155
|
+
* @todo Подумать как сделать оптимальнее
|
|
156
|
+
*/
|
|
157
157
|
declare function useDayjs(timezone?: string): (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean) => dayjs.Dayjs;
|
|
158
158
|
|
|
159
|
-
interface BrowserInfo {
|
|
160
|
-
isDeprecated?: boolean;
|
|
161
|
-
name?: string;
|
|
162
|
-
version?: string;
|
|
163
|
-
os?: string;
|
|
164
|
-
type?: string;
|
|
165
|
-
options?: any;
|
|
166
|
-
}
|
|
167
|
-
type VersionsList = {
|
|
168
|
-
[key in Browser]?: string | boolean;
|
|
169
|
-
};
|
|
159
|
+
interface BrowserInfo {
|
|
160
|
+
isDeprecated?: boolean;
|
|
161
|
+
name?: string;
|
|
162
|
+
version?: string;
|
|
163
|
+
os?: string;
|
|
164
|
+
type?: string;
|
|
165
|
+
options?: any;
|
|
166
|
+
}
|
|
167
|
+
type VersionsList = {
|
|
168
|
+
[key in Browser]?: string | boolean;
|
|
169
|
+
};
|
|
170
170
|
declare function useDetectBrowser(versions: VersionsList, userAgent?: any): BrowserInfo;
|
|
171
171
|
|
|
172
|
-
/**
|
|
173
|
-
* @see https://github.com/caiogondim/logdown.js#readme
|
|
174
|
-
*/
|
|
175
|
-
|
|
176
|
-
interface Options {
|
|
177
|
-
tag?: string;
|
|
178
|
-
color?: string;
|
|
179
|
-
debug?: boolean;
|
|
180
|
-
}
|
|
172
|
+
/**
|
|
173
|
+
* @see https://github.com/caiogondim/logdown.js#readme
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
interface Options {
|
|
177
|
+
tag?: string;
|
|
178
|
+
color?: string;
|
|
179
|
+
debug?: boolean;
|
|
180
|
+
}
|
|
181
181
|
declare function useLogger(scope: string, options?: Options): logdown.Logger;
|
|
182
182
|
|
|
183
183
|
declare function validatePhone(rule: string, value: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karta.io/utils",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.2",
|
|
4
4
|
"description": "karta.io utils for admin and application",
|
|
5
5
|
"author": "Vitaly Blokhin <karambafe@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"vue": "3.2.x"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@karta.io/common-data": "^0.32.
|
|
26
|
+
"@karta.io/common-data": "^0.32.2",
|
|
27
27
|
"@vueuse/core": "9.13.0",
|
|
28
28
|
"dayjs": "1.11.7",
|
|
29
29
|
"detect-browser": "5.3.0",
|