@karta.io/utils 1.0.0-beta.4 → 1.0.0-beta.40
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 +288 -74
- package/dist/index.d.cts +393 -0
- package/dist/index.d.mts +393 -0
- package/dist/index.d.ts +74 -31
- package/dist/index.mjs +284 -76
- package/package.json +33 -34
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { MaybeRef, Component, EmitsOptions, VNode, Ref } from 'vue';
|
|
3
|
+
import { AxiosRequestConfig } from 'axios';
|
|
4
|
+
export { AxiosError as HttpError, AxiosPromise as HttpPromise, AxiosRequestConfig as HttpRequestConfig, AxiosResponse as HttpResponse } from 'axios';
|
|
5
|
+
import { MaybeRef as MaybeRef$1 } from '@vueuse/core';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import { Browser } from 'detect-browser';
|
|
8
|
+
import logdown from 'logdown';
|
|
9
|
+
import { RuleItem } from 'async-validator';
|
|
10
|
+
|
|
11
|
+
interface AppComponentsResolverOptions {
|
|
12
|
+
prefix?: string;
|
|
13
|
+
}
|
|
14
|
+
declare function AppComponentsResolver(options?: AppComponentsResolverOptions): any;
|
|
15
|
+
|
|
16
|
+
interface Dictionary {
|
|
17
|
+
[keys: string | number]: any;
|
|
18
|
+
}
|
|
19
|
+
interface ResponseError {
|
|
20
|
+
status: number;
|
|
21
|
+
statusMessage: string;
|
|
22
|
+
message: string;
|
|
23
|
+
data: Record<string, string | string[]> | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare function camelizeKeys<T extends Record<string, any> = Dictionary>(object: Dictionary): T;
|
|
27
|
+
|
|
28
|
+
interface Options$3 {
|
|
29
|
+
labelType: 'key' | 'value';
|
|
30
|
+
}
|
|
31
|
+
declare function convertEnumToOptions(obj: any, options?: Options$3): {
|
|
32
|
+
value: unknown;
|
|
33
|
+
label: unknown;
|
|
34
|
+
}[];
|
|
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
|
+
interface Options$2 extends Intl.NumberFormatOptions {
|
|
52
|
+
locale?: string;
|
|
53
|
+
defaultValue?: string | number;
|
|
54
|
+
}
|
|
55
|
+
declare function formatMoney(value: string | number | null | undefined, currency?: string, options?: Options$2): string | number;
|
|
56
|
+
|
|
57
|
+
declare function genHash(hashLength: number): string;
|
|
58
|
+
|
|
59
|
+
declare function genRandomNumber(min: number, max: number): number;
|
|
60
|
+
|
|
61
|
+
declare function genUUID(): string;
|
|
62
|
+
|
|
63
|
+
interface Options$1 {
|
|
64
|
+
hasOnlyLast4: boolean;
|
|
65
|
+
isHidden: boolean;
|
|
66
|
+
dot: string;
|
|
67
|
+
}
|
|
68
|
+
declare function getCardNumber(number: string, options?: Partial<Options$1>): string;
|
|
69
|
+
|
|
70
|
+
declare function getCountryFromPhone(phone: string): string;
|
|
71
|
+
|
|
72
|
+
declare function isElementIgnored({ ignoredClasses, event, }?: {
|
|
73
|
+
ignoredClasses?: string[];
|
|
74
|
+
event?: Event;
|
|
75
|
+
}): boolean;
|
|
76
|
+
|
|
77
|
+
declare function isEmptyObject(object: object): boolean;
|
|
78
|
+
|
|
79
|
+
declare function isHtml(data: string): boolean;
|
|
80
|
+
|
|
81
|
+
interface MapOptions {
|
|
82
|
+
labelKey?: string;
|
|
83
|
+
valueKey?: string;
|
|
84
|
+
excludedItems?: any[];
|
|
85
|
+
}
|
|
86
|
+
declare function mapDataObjectForFilters<T extends Record<string, any>>(data: T, options?: MapOptions): {
|
|
87
|
+
label: string;
|
|
88
|
+
value: any;
|
|
89
|
+
}[];
|
|
90
|
+
|
|
91
|
+
declare function getPaginationParams({ page, limit, }: {
|
|
92
|
+
page: string | number;
|
|
93
|
+
limit: string | number;
|
|
94
|
+
}): {
|
|
95
|
+
limit: number;
|
|
96
|
+
offset: number;
|
|
97
|
+
};
|
|
98
|
+
declare function getPaginationLimit({ limit, }: {
|
|
99
|
+
limit: string | number;
|
|
100
|
+
}): number;
|
|
101
|
+
declare function getPaginationOffset({ page, limit, }: {
|
|
102
|
+
page: string | number;
|
|
103
|
+
limit: string | number;
|
|
104
|
+
}): number;
|
|
105
|
+
declare function getPaginationPages({ count, limit, }: {
|
|
106
|
+
count: number;
|
|
107
|
+
limit: string | number;
|
|
108
|
+
}): number;
|
|
109
|
+
|
|
110
|
+
declare function parsePhone(phone: string | null | undefined): string;
|
|
111
|
+
|
|
112
|
+
type SnakelizeKeysProp = Record<string | number, any>;
|
|
113
|
+
declare function snakelizeKeys<T extends Record<string, any> = SnakelizeKeysProp>(prop: SnakelizeKeysProp): T;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Принимает на вход число в виде строки или числа,
|
|
117
|
+
* возвращает корректное значение типа Number (убирает лишние пробелы и запятые)
|
|
118
|
+
* @example
|
|
119
|
+
* // returns 1000
|
|
120
|
+
* unformatNumber('1 000');
|
|
121
|
+
* @example
|
|
122
|
+
* // returns 1000
|
|
123
|
+
* unformatNumber('1,000')
|
|
124
|
+
* @example
|
|
125
|
+
* // returns 1000.123
|
|
126
|
+
* unformatNummber('1 000,123')
|
|
127
|
+
* @example
|
|
128
|
+
* // returns 1000.123
|
|
129
|
+
* unformatNummber('1,000.123')
|
|
130
|
+
* @param value
|
|
131
|
+
* @return number
|
|
132
|
+
*/
|
|
133
|
+
declare function unformatNumber(value: string | number): string | number;
|
|
134
|
+
|
|
135
|
+
declare function validateNumber(value: string | number, defaultValue: number): number;
|
|
136
|
+
|
|
137
|
+
interface UiComponentsResolverOptions {
|
|
138
|
+
prefix?: string;
|
|
139
|
+
}
|
|
140
|
+
declare function UiComponentsResolver(options?: UiComponentsResolverOptions): any;
|
|
141
|
+
|
|
142
|
+
declare function useAbortController<T extends (...args: any[]) => any>(callback: T): {
|
|
143
|
+
call(...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
|
|
144
|
+
abort(): void;
|
|
145
|
+
isAborted(error: ResponseError): boolean;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
declare function useAsyncItems<T extends (...args: any[]) => any>({ apiMethod, queryKey, params, config, }: {
|
|
149
|
+
apiMethod: T;
|
|
150
|
+
queryKey: string;
|
|
151
|
+
params: MaybeRef<Parameters<T>[0]>;
|
|
152
|
+
config?: AxiosRequestConfig;
|
|
153
|
+
}): {
|
|
154
|
+
isLoading: vue.Ref<false, false> | vue.Ref<true, true> | vue.Ref<boolean, boolean>;
|
|
155
|
+
isFetching: vue.Ref<boolean, boolean>;
|
|
156
|
+
isError: vue.Ref<false, false> | vue.Ref<true, true>;
|
|
157
|
+
data: vue.Ref<any, any> | vue.Ref<undefined, undefined>;
|
|
158
|
+
error: vue.Ref<Error, Error> | vue.Ref<null, null>;
|
|
159
|
+
items: vue.ComputedRef<Awaited<ReturnType<T>>["results"]>;
|
|
160
|
+
count: vue.Ref<number, number>;
|
|
161
|
+
refetch: () => void;
|
|
162
|
+
reload: () => void;
|
|
163
|
+
abort: () => void;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
interface ReactiveData$1 {
|
|
167
|
+
search: string;
|
|
168
|
+
page: number;
|
|
169
|
+
selectedValues?: any[];
|
|
170
|
+
params?: any;
|
|
171
|
+
}
|
|
172
|
+
declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValues, params, queryKey, dataItemsKey, dataItemIdKey, dataCountKey, delay, onUpdated, }: {
|
|
173
|
+
apiMethod: T;
|
|
174
|
+
mapOptionCallback?: K;
|
|
175
|
+
selectedValues?: MaybeRef$1<Parameters<T>[0]['includedIds']>;
|
|
176
|
+
params?: MaybeRef$1<Partial<Parameters<T>[0]>>;
|
|
177
|
+
queryKey: string;
|
|
178
|
+
dataItemsKey?: string;
|
|
179
|
+
dataItemIdKey?: string;
|
|
180
|
+
dataCountKey?: string;
|
|
181
|
+
delay?: number;
|
|
182
|
+
onUpdated?: (data: ReactiveData$1) => void;
|
|
183
|
+
}): {
|
|
184
|
+
items: vue.ComputedRef<any[]>;
|
|
185
|
+
options: vue.ComputedRef<ReturnType<K>[]>;
|
|
186
|
+
search: vue.Ref<string, string>;
|
|
187
|
+
hasNextPage: vue.ComputedRef<boolean>;
|
|
188
|
+
isFetching: vue.Ref<boolean, boolean>;
|
|
189
|
+
isLoading: vue.Ref<false, false> | vue.Ref<true, true> | vue.Ref<boolean, boolean>;
|
|
190
|
+
loadPage: (newPage?: number) => void;
|
|
191
|
+
updateSearch: (value: string) => void;
|
|
192
|
+
refetch: () => void;
|
|
193
|
+
reload: () => void;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
interface ReactiveData {
|
|
197
|
+
search: string;
|
|
198
|
+
page: number;
|
|
199
|
+
selectedValue?: any[];
|
|
200
|
+
params?: any;
|
|
201
|
+
}
|
|
202
|
+
declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValue, params, queryKey, dataItemsKey, dataCountKey, delay, onUpdated, }: {
|
|
203
|
+
apiMethod: T;
|
|
204
|
+
mapOptionCallback?: K;
|
|
205
|
+
selectedValue?: MaybeRef$1<Parameters<T>[0]['includedIds']>;
|
|
206
|
+
params?: MaybeRef$1<Partial<Parameters<T>[0]>>;
|
|
207
|
+
queryKey: string;
|
|
208
|
+
dataItemsKey?: string;
|
|
209
|
+
dataCountKey?: string;
|
|
210
|
+
delay?: number;
|
|
211
|
+
onUpdated?: (data: ReactiveData) => void;
|
|
212
|
+
}): {
|
|
213
|
+
items: vue.ComputedRef<any[]>;
|
|
214
|
+
options: vue.ComputedRef<ReturnType<K>[]>;
|
|
215
|
+
search: vue.Ref<string, string>;
|
|
216
|
+
hasNextPage: vue.ComputedRef<boolean>;
|
|
217
|
+
isFetching: vue.Ref<boolean, boolean>;
|
|
218
|
+
isLoading: vue.Ref<false, false> | vue.Ref<true, true> | vue.Ref<boolean, boolean>;
|
|
219
|
+
loadPage: (newPage?: number) => void;
|
|
220
|
+
updateSearch: (value: string) => void;
|
|
221
|
+
refetch: () => void;
|
|
222
|
+
reload: () => void;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
declare function useBreakpoint(): {
|
|
226
|
+
isMobile: vue.Ref<boolean, boolean>;
|
|
227
|
+
isDesktop: vue.Ref<boolean, boolean>;
|
|
228
|
+
isGreaterXxs: vue.Ref<boolean, boolean>;
|
|
229
|
+
isGreaterXs: vue.Ref<boolean, boolean>;
|
|
230
|
+
isGreaterSm: vue.Ref<boolean, boolean>;
|
|
231
|
+
isGreaterMd: vue.Ref<boolean, boolean>;
|
|
232
|
+
isGreaterLg: vue.Ref<boolean, boolean>;
|
|
233
|
+
isGreaterXl: vue.Ref<boolean, boolean>;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
declare function useClassName(block: string): {
|
|
237
|
+
b: (blockSuffix?: string) => string;
|
|
238
|
+
e: (element?: string) => string;
|
|
239
|
+
m: (modifier?: string, condition?: boolean) => string;
|
|
240
|
+
em: (element?: string, modifier?: string, condition?: boolean) => string;
|
|
241
|
+
mv: (modifier: string, modifierValue: string, condition?: boolean) => string;
|
|
242
|
+
cssVar: (object: Record<string, string | number>) => Record<string, string | number>;
|
|
243
|
+
cssVarName: (name: string) => string;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Обертка над dayjs, позволяющая задавать timezone
|
|
248
|
+
* @see https://day.js.org/en/
|
|
249
|
+
*
|
|
250
|
+
* Использовать параметр timezone нужно крайне аккуратно,
|
|
251
|
+
* может привести к утечкам памяти
|
|
252
|
+
* @todo Подумать как сделать оптимальнее
|
|
253
|
+
*/
|
|
254
|
+
declare function useDayjs(timezone?: string): (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean) => dayjs.Dayjs;
|
|
255
|
+
|
|
256
|
+
interface BrowserInfo {
|
|
257
|
+
isDeprecated?: boolean;
|
|
258
|
+
name?: string;
|
|
259
|
+
version?: string;
|
|
260
|
+
os?: string;
|
|
261
|
+
type?: string;
|
|
262
|
+
options?: any;
|
|
263
|
+
}
|
|
264
|
+
type VersionsList = {
|
|
265
|
+
[key in Browser]?: string | boolean;
|
|
266
|
+
};
|
|
267
|
+
declare function useDetectBrowser(versions: VersionsList, userAgent?: any): BrowserInfo;
|
|
268
|
+
|
|
269
|
+
interface VNodeCustom$1 extends VNode {
|
|
270
|
+
close: () => void;
|
|
271
|
+
}
|
|
272
|
+
interface Dialog {
|
|
273
|
+
uuid: string;
|
|
274
|
+
name?: string;
|
|
275
|
+
vnode: VNodeCustom$1;
|
|
276
|
+
layer: number;
|
|
277
|
+
}
|
|
278
|
+
interface DialogOptions {
|
|
279
|
+
hashPrefix?: string;
|
|
280
|
+
}
|
|
281
|
+
interface DialogParseHashResult {
|
|
282
|
+
name: string;
|
|
283
|
+
layer: number;
|
|
284
|
+
[key: string]: any;
|
|
285
|
+
}
|
|
286
|
+
declare function useDialog(options?: DialogOptions): {
|
|
287
|
+
open: ({ layer, component, props, }: {
|
|
288
|
+
component: Component;
|
|
289
|
+
props?: any;
|
|
290
|
+
layer?: number;
|
|
291
|
+
}) => string;
|
|
292
|
+
getInstance: (uuid: string) => VNodeCustom$1;
|
|
293
|
+
getLayer: (uuid: string) => number;
|
|
294
|
+
close: (uuid: string) => void;
|
|
295
|
+
closeAll: () => void;
|
|
296
|
+
showConfirm: (text?: string) => boolean;
|
|
297
|
+
isOnTop: (uuid: string) => boolean;
|
|
298
|
+
genHash: ({ layer, componentName, props, }: {
|
|
299
|
+
componentName: string;
|
|
300
|
+
props?: any;
|
|
301
|
+
layer?: number;
|
|
302
|
+
}) => string;
|
|
303
|
+
parseHash: (hash: string, componentName: string) => DialogParseHashResult | undefined;
|
|
304
|
+
clearHash: () => void;
|
|
305
|
+
openByHash: ({ layer, component, props, }: {
|
|
306
|
+
component: Component;
|
|
307
|
+
props?: any;
|
|
308
|
+
layer?: number;
|
|
309
|
+
}) => void;
|
|
310
|
+
watchHash: ({ component, events, }: {
|
|
311
|
+
component: Component;
|
|
312
|
+
events?: EmitsOptions;
|
|
313
|
+
}) => any;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
declare function useGlobalScroll(): {
|
|
317
|
+
isLocked: vue.Ref<boolean, boolean>;
|
|
318
|
+
lock: () => void;
|
|
319
|
+
unlock: () => void;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters }: {
|
|
323
|
+
config: T;
|
|
324
|
+
initialFilters: K;
|
|
325
|
+
}): {
|
|
326
|
+
isOpen: Ref<boolean, boolean>;
|
|
327
|
+
filtersModel: Ref<K, K>;
|
|
328
|
+
filtersFromQuery: vue.ComputedRef<{}>;
|
|
329
|
+
filtersCount: vue.ComputedRef<number>;
|
|
330
|
+
updateOne: (key: keyof K, value: any) => void;
|
|
331
|
+
updateMany: (filters: Record<string, any>) => void;
|
|
332
|
+
open: () => void;
|
|
333
|
+
clear: () => void;
|
|
334
|
+
setQueryFromFilters: (filters: Record<string, any>) => void;
|
|
335
|
+
getValidatedParams: (query: Record<string, any>) => {
|
|
336
|
+
filters: any;
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* @see https://github.com/caiogondim/logdown.js#readme
|
|
342
|
+
*/
|
|
343
|
+
|
|
344
|
+
interface Options {
|
|
345
|
+
tag?: string;
|
|
346
|
+
color?: string;
|
|
347
|
+
debug?: boolean;
|
|
348
|
+
}
|
|
349
|
+
declare function useLogger(scope: string, options?: Options): logdown.Logger;
|
|
350
|
+
|
|
351
|
+
interface VNodeCustom extends VNode {
|
|
352
|
+
close: () => void;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* @deprecated use useDialog
|
|
356
|
+
*/
|
|
357
|
+
declare function usePanel(): {
|
|
358
|
+
open: ({ layer, component, props, }: {
|
|
359
|
+
component: Component;
|
|
360
|
+
props?: any;
|
|
361
|
+
layer?: number;
|
|
362
|
+
}) => string;
|
|
363
|
+
getInstance: (uuid: string) => VNodeCustom;
|
|
364
|
+
close: (uuid: string) => void;
|
|
365
|
+
closeAll: () => void;
|
|
366
|
+
openByHash: ({ layer, component, props, }: {
|
|
367
|
+
component: Component;
|
|
368
|
+
props?: any;
|
|
369
|
+
layer?: number;
|
|
370
|
+
}) => void;
|
|
371
|
+
watchHash: ({ component, events, }: {
|
|
372
|
+
component: Component;
|
|
373
|
+
events?: EmitsOptions;
|
|
374
|
+
}) => any;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
declare function validatePhone(rule: string, value: string): boolean;
|
|
378
|
+
|
|
379
|
+
declare function isRequired(value?: boolean, message?: string): RuleItem;
|
|
380
|
+
declare function isMax(value?: number, message?: string): {
|
|
381
|
+
max: number;
|
|
382
|
+
message: string;
|
|
383
|
+
};
|
|
384
|
+
declare function isMin(value?: number, message?: string): {
|
|
385
|
+
min: number;
|
|
386
|
+
message: string;
|
|
387
|
+
};
|
|
388
|
+
declare function isTypeEmail(message?: string): RuleItem;
|
|
389
|
+
declare function isTypeUrl(message?: string): RuleItem;
|
|
390
|
+
declare function isTypeNumber(value?: number, message?: string): RuleItem;
|
|
391
|
+
declare function isStrictLength(value?: number, message?: string): RuleItem;
|
|
392
|
+
|
|
393
|
+
export { AppComponentsResolver, type BrowserInfo, type Dialog, type DialogOptions, type DialogParseHashResult, 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 };
|
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(object: Dictionary):
|
|
26
|
+
declare function camelizeKeys<T extends Record<string, any> = Dictionary>(object: Dictionary): T;
|
|
27
27
|
|
|
28
28
|
interface Options$3 {
|
|
29
29
|
labelType: 'key' | 'value';
|
|
@@ -33,6 +33,21 @@ 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
|
+
|
|
36
51
|
interface Options$2 extends Intl.NumberFormatOptions {
|
|
37
52
|
locale?: string;
|
|
38
53
|
defaultValue?: string | number;
|
|
@@ -61,6 +76,8 @@ declare function isElementIgnored({ ignoredClasses, event, }?: {
|
|
|
61
76
|
|
|
62
77
|
declare function isEmptyObject(object: object): boolean;
|
|
63
78
|
|
|
79
|
+
declare function isHtml(data: string): boolean;
|
|
80
|
+
|
|
64
81
|
interface MapOptions {
|
|
65
82
|
labelKey?: string;
|
|
66
83
|
valueKey?: string;
|
|
@@ -78,7 +95,7 @@ declare function getPaginationParams({ page, limit, }: {
|
|
|
78
95
|
limit: number;
|
|
79
96
|
offset: number;
|
|
80
97
|
};
|
|
81
|
-
declare function getPaginationLimit({ limit }: {
|
|
98
|
+
declare function getPaginationLimit({ limit, }: {
|
|
82
99
|
limit: string | number;
|
|
83
100
|
}): number;
|
|
84
101
|
declare function getPaginationOffset({ page, limit, }: {
|
|
@@ -93,7 +110,7 @@ declare function getPaginationPages({ count, limit, }: {
|
|
|
93
110
|
declare function parsePhone(phone: string | null | undefined): string;
|
|
94
111
|
|
|
95
112
|
type SnakelizeKeysProp = Record<string | number, any>;
|
|
96
|
-
declare function snakelizeKeys(prop: SnakelizeKeysProp):
|
|
113
|
+
declare function snakelizeKeys<T extends Record<string, any> = SnakelizeKeysProp>(prop: SnakelizeKeysProp): T;
|
|
97
114
|
|
|
98
115
|
/**
|
|
99
116
|
* Принимает на вход число в виде строки или числа,
|
|
@@ -134,13 +151,13 @@ declare function useAsyncItems<T extends (...args: any[]) => any>({ apiMethod, q
|
|
|
134
151
|
params: MaybeRef<Parameters<T>[0]>;
|
|
135
152
|
config?: AxiosRequestConfig;
|
|
136
153
|
}): {
|
|
137
|
-
isLoading: vue.Ref<false> | vue.Ref<true>;
|
|
138
|
-
isFetching: vue.Ref<boolean>;
|
|
139
|
-
isError: vue.Ref<false> | vue.Ref<true>;
|
|
140
|
-
data: vue.Ref<any>;
|
|
141
|
-
error: vue.Ref<
|
|
154
|
+
isLoading: vue.Ref<false, false> | vue.Ref<true, true> | vue.Ref<boolean, boolean>;
|
|
155
|
+
isFetching: vue.Ref<boolean, boolean>;
|
|
156
|
+
isError: vue.Ref<false, false> | vue.Ref<true, true>;
|
|
157
|
+
data: vue.Ref<any, any> | vue.Ref<undefined, undefined>;
|
|
158
|
+
error: vue.Ref<Error, Error> | vue.Ref<null, null>;
|
|
142
159
|
items: vue.ComputedRef<Awaited<ReturnType<T>>["results"]>;
|
|
143
|
-
count: vue.Ref<number>;
|
|
160
|
+
count: vue.Ref<number, number>;
|
|
144
161
|
refetch: () => void;
|
|
145
162
|
reload: () => void;
|
|
146
163
|
abort: () => void;
|
|
@@ -166,12 +183,14 @@ declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extend
|
|
|
166
183
|
}): {
|
|
167
184
|
items: vue.ComputedRef<any[]>;
|
|
168
185
|
options: vue.ComputedRef<ReturnType<K>[]>;
|
|
169
|
-
search: vue.Ref<string>;
|
|
186
|
+
search: vue.Ref<string, string>;
|
|
170
187
|
hasNextPage: vue.ComputedRef<boolean>;
|
|
171
|
-
isFetching: vue.Ref<boolean>;
|
|
172
|
-
isLoading: vue.Ref<false> | vue.Ref<true>;
|
|
188
|
+
isFetching: vue.Ref<boolean, boolean>;
|
|
189
|
+
isLoading: vue.Ref<false, false> | vue.Ref<true, true> | vue.Ref<boolean, boolean>;
|
|
173
190
|
loadPage: (newPage?: number) => void;
|
|
174
191
|
updateSearch: (value: string) => void;
|
|
192
|
+
refetch: () => void;
|
|
193
|
+
reload: () => void;
|
|
175
194
|
};
|
|
176
195
|
|
|
177
196
|
interface ReactiveData {
|
|
@@ -193,23 +212,25 @@ declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (pa
|
|
|
193
212
|
}): {
|
|
194
213
|
items: vue.ComputedRef<any[]>;
|
|
195
214
|
options: vue.ComputedRef<ReturnType<K>[]>;
|
|
196
|
-
search: vue.Ref<string>;
|
|
215
|
+
search: vue.Ref<string, string>;
|
|
197
216
|
hasNextPage: vue.ComputedRef<boolean>;
|
|
198
|
-
isFetching: vue.Ref<boolean>;
|
|
199
|
-
isLoading: vue.Ref<false> | vue.Ref<true>;
|
|
217
|
+
isFetching: vue.Ref<boolean, boolean>;
|
|
218
|
+
isLoading: vue.Ref<false, false> | vue.Ref<true, true> | vue.Ref<boolean, boolean>;
|
|
200
219
|
loadPage: (newPage?: number) => void;
|
|
201
220
|
updateSearch: (value: string) => void;
|
|
221
|
+
refetch: () => void;
|
|
222
|
+
reload: () => void;
|
|
202
223
|
};
|
|
203
224
|
|
|
204
225
|
declare function useBreakpoint(): {
|
|
205
|
-
isMobile: vue.Ref<boolean>;
|
|
206
|
-
isDesktop: vue.Ref<boolean>;
|
|
207
|
-
isGreaterXxs: vue.Ref<boolean>;
|
|
208
|
-
isGreaterXs: vue.Ref<boolean>;
|
|
209
|
-
isGreaterSm: vue.Ref<boolean>;
|
|
210
|
-
isGreaterMd: vue.Ref<boolean>;
|
|
211
|
-
isGreaterLg: vue.Ref<boolean>;
|
|
212
|
-
isGreaterXl: vue.Ref<boolean>;
|
|
226
|
+
isMobile: vue.Ref<boolean, boolean>;
|
|
227
|
+
isDesktop: vue.Ref<boolean, boolean>;
|
|
228
|
+
isGreaterXxs: vue.Ref<boolean, boolean>;
|
|
229
|
+
isGreaterXs: vue.Ref<boolean, boolean>;
|
|
230
|
+
isGreaterSm: vue.Ref<boolean, boolean>;
|
|
231
|
+
isGreaterMd: vue.Ref<boolean, boolean>;
|
|
232
|
+
isGreaterLg: vue.Ref<boolean, boolean>;
|
|
233
|
+
isGreaterXl: vue.Ref<boolean, boolean>;
|
|
213
234
|
};
|
|
214
235
|
|
|
215
236
|
declare function useClassName(block: string): {
|
|
@@ -246,19 +267,41 @@ type VersionsList = {
|
|
|
246
267
|
declare function useDetectBrowser(versions: VersionsList, userAgent?: any): BrowserInfo;
|
|
247
268
|
|
|
248
269
|
interface VNodeCustom$1 extends VNode {
|
|
249
|
-
close()
|
|
270
|
+
close: () => void;
|
|
271
|
+
}
|
|
272
|
+
interface Dialog {
|
|
273
|
+
uuid: string;
|
|
274
|
+
name?: string;
|
|
275
|
+
vnode: VNodeCustom$1;
|
|
276
|
+
layer: number;
|
|
277
|
+
}
|
|
278
|
+
interface DialogOptions {
|
|
279
|
+
hashPrefix?: string;
|
|
250
280
|
}
|
|
251
|
-
|
|
281
|
+
interface DialogParseHashResult {
|
|
282
|
+
name: string;
|
|
283
|
+
layer: number;
|
|
284
|
+
[key: string]: any;
|
|
285
|
+
}
|
|
286
|
+
declare function useDialog(options?: DialogOptions): {
|
|
252
287
|
open: ({ layer, component, props, }: {
|
|
253
288
|
component: Component;
|
|
254
289
|
props?: any;
|
|
255
290
|
layer?: number;
|
|
256
291
|
}) => string;
|
|
257
292
|
getInstance: (uuid: string) => VNodeCustom$1;
|
|
293
|
+
getLayer: (uuid: string) => number;
|
|
258
294
|
close: (uuid: string) => void;
|
|
259
295
|
closeAll: () => void;
|
|
260
296
|
showConfirm: (text?: string) => boolean;
|
|
261
297
|
isOnTop: (uuid: string) => boolean;
|
|
298
|
+
genHash: ({ layer, componentName, props, }: {
|
|
299
|
+
componentName: string;
|
|
300
|
+
props?: any;
|
|
301
|
+
layer?: number;
|
|
302
|
+
}) => string;
|
|
303
|
+
parseHash: (hash: string, componentName: string) => DialogParseHashResult | undefined;
|
|
304
|
+
clearHash: () => void;
|
|
262
305
|
openByHash: ({ layer, component, props, }: {
|
|
263
306
|
component: Component;
|
|
264
307
|
props?: any;
|
|
@@ -271,17 +314,17 @@ declare function useDialog(): {
|
|
|
271
314
|
};
|
|
272
315
|
|
|
273
316
|
declare function useGlobalScroll(): {
|
|
274
|
-
isLocked: vue.Ref<boolean>;
|
|
317
|
+
isLocked: vue.Ref<boolean, boolean>;
|
|
275
318
|
lock: () => void;
|
|
276
319
|
unlock: () => void;
|
|
277
320
|
};
|
|
278
321
|
|
|
279
|
-
declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters
|
|
322
|
+
declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters }: {
|
|
280
323
|
config: T;
|
|
281
324
|
initialFilters: K;
|
|
282
325
|
}): {
|
|
283
|
-
isOpen: Ref<boolean>;
|
|
284
|
-
filtersModel: Ref<K>;
|
|
326
|
+
isOpen: Ref<boolean, boolean>;
|
|
327
|
+
filtersModel: Ref<K, K>;
|
|
285
328
|
filtersFromQuery: vue.ComputedRef<{}>;
|
|
286
329
|
filtersCount: vue.ComputedRef<number>;
|
|
287
330
|
updateOne: (key: keyof K, value: any) => void;
|
|
@@ -306,7 +349,7 @@ interface Options {
|
|
|
306
349
|
declare function useLogger(scope: string, options?: Options): logdown.Logger;
|
|
307
350
|
|
|
308
351
|
interface VNodeCustom extends VNode {
|
|
309
|
-
close()
|
|
352
|
+
close: () => void;
|
|
310
353
|
}
|
|
311
354
|
/**
|
|
312
355
|
* @deprecated use useDialog
|
|
@@ -347,4 +390,4 @@ declare function isTypeUrl(message?: string): RuleItem;
|
|
|
347
390
|
declare function isTypeNumber(value?: number, message?: string): RuleItem;
|
|
348
391
|
declare function isStrictLength(value?: number, message?: string): RuleItem;
|
|
349
392
|
|
|
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 };
|
|
393
|
+
export { AppComponentsResolver, type BrowserInfo, type Dialog, type DialogOptions, type DialogParseHashResult, 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 };
|