@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.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRef, Component, EmitsOptions,
|
|
2
|
+
import { MaybeRef, VNode, Component, EmitsOptions, Ref } from 'vue';
|
|
3
3
|
import { AxiosRequestConfig } from 'axios';
|
|
4
4
|
export { AxiosError as HttpError, AxiosPromise as HttpPromise, AxiosRequestConfig as HttpRequestConfig, AxiosResponse as HttpResponse } from 'axios';
|
|
5
5
|
import { MaybeRef as MaybeRef$1 } from '@vueuse/core';
|
|
@@ -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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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.
|
|
206
|
-
isDesktop: vue.
|
|
207
|
-
isGreaterXxs: vue.
|
|
208
|
-
isGreaterXs: vue.
|
|
209
|
-
isGreaterSm: vue.
|
|
210
|
-
isGreaterMd: vue.
|
|
211
|
-
isGreaterLg: vue.
|
|
212
|
-
isGreaterXl: vue.
|
|
226
|
+
isMobile: vue.ComputedRef<boolean>;
|
|
227
|
+
isDesktop: vue.ComputedRef<boolean>;
|
|
228
|
+
isGreaterXxs: vue.ComputedRef<boolean>;
|
|
229
|
+
isGreaterXs: vue.ComputedRef<boolean>;
|
|
230
|
+
isGreaterSm: vue.ComputedRef<boolean>;
|
|
231
|
+
isGreaterMd: vue.ComputedRef<boolean>;
|
|
232
|
+
isGreaterLg: vue.ComputedRef<boolean>;
|
|
233
|
+
isGreaterXl: vue.ComputedRef<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,5 @@ 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,
|
|
393
|
+
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 };
|
|
394
|
+
export type { BrowserInfo, Dialog, DialogOptions, DialogParseHashResult, Dictionary, ResponseError, VersionsList };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRef, Component, EmitsOptions,
|
|
2
|
+
import { MaybeRef, VNode, Component, EmitsOptions, Ref } from 'vue';
|
|
3
3
|
import { AxiosRequestConfig } from 'axios';
|
|
4
4
|
export { AxiosError as HttpError, AxiosPromise as HttpPromise, AxiosRequestConfig as HttpRequestConfig, AxiosResponse as HttpResponse } from 'axios';
|
|
5
5
|
import { MaybeRef as MaybeRef$1 } from '@vueuse/core';
|
|
@@ -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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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.
|
|
206
|
-
isDesktop: vue.
|
|
207
|
-
isGreaterXxs: vue.
|
|
208
|
-
isGreaterXs: vue.
|
|
209
|
-
isGreaterSm: vue.
|
|
210
|
-
isGreaterMd: vue.
|
|
211
|
-
isGreaterLg: vue.
|
|
212
|
-
isGreaterXl: vue.
|
|
226
|
+
isMobile: vue.ComputedRef<boolean>;
|
|
227
|
+
isDesktop: vue.ComputedRef<boolean>;
|
|
228
|
+
isGreaterXxs: vue.ComputedRef<boolean>;
|
|
229
|
+
isGreaterXs: vue.ComputedRef<boolean>;
|
|
230
|
+
isGreaterSm: vue.ComputedRef<boolean>;
|
|
231
|
+
isGreaterMd: vue.ComputedRef<boolean>;
|
|
232
|
+
isGreaterLg: vue.ComputedRef<boolean>;
|
|
233
|
+
isGreaterXl: vue.ComputedRef<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,5 @@ 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,
|
|
393
|
+
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 };
|
|
394
|
+
export type { BrowserInfo, Dialog, DialogOptions, DialogParseHashResult, Dictionary, ResponseError, VersionsList };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { MaybeRef, Component, EmitsOptions,
|
|
2
|
+
import { MaybeRef, VNode, Component, EmitsOptions, Ref } from 'vue';
|
|
3
3
|
import { AxiosRequestConfig } from 'axios';
|
|
4
4
|
export { AxiosError as HttpError, AxiosPromise as HttpPromise, AxiosRequestConfig as HttpRequestConfig, AxiosResponse as HttpResponse } from 'axios';
|
|
5
5
|
import { MaybeRef as MaybeRef$1 } from '@vueuse/core';
|
|
@@ -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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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<boolean, boolean> | vue.Ref<false, false> | vue.Ref<true, true>;
|
|
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.
|
|
206
|
-
isDesktop: vue.
|
|
207
|
-
isGreaterXxs: vue.
|
|
208
|
-
isGreaterXs: vue.
|
|
209
|
-
isGreaterSm: vue.
|
|
210
|
-
isGreaterMd: vue.
|
|
211
|
-
isGreaterLg: vue.
|
|
212
|
-
isGreaterXl: vue.
|
|
226
|
+
isMobile: vue.ComputedRef<boolean>;
|
|
227
|
+
isDesktop: vue.ComputedRef<boolean>;
|
|
228
|
+
isGreaterXxs: vue.ComputedRef<boolean>;
|
|
229
|
+
isGreaterXs: vue.ComputedRef<boolean>;
|
|
230
|
+
isGreaterSm: vue.ComputedRef<boolean>;
|
|
231
|
+
isGreaterMd: vue.ComputedRef<boolean>;
|
|
232
|
+
isGreaterLg: vue.ComputedRef<boolean>;
|
|
233
|
+
isGreaterXl: vue.ComputedRef<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,5 @@ 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,
|
|
393
|
+
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 };
|
|
394
|
+
export type { BrowserInfo, Dialog, DialogOptions, DialogParseHashResult, Dictionary, ResponseError, VersionsList };
|