@karta.io/utils 1.0.0-beta.1 → 1.0.0-beta.10

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 CHANGED
@@ -506,7 +506,7 @@ function useAsyncMultiselect({
506
506
  if (!items.value.length)
507
507
  return [];
508
508
  if (!mapOptionCallback)
509
- return this.items.value;
509
+ return items.value;
510
510
  return items.value.map(mapOptionCallback);
511
511
  });
512
512
  const hasNextPage = vue.computed(() => count.value > items.value.length);
@@ -656,7 +656,7 @@ function useAsyncSelect({
656
656
  if (!items.value.length)
657
657
  return [];
658
658
  if (!mapOptionCallback)
659
- return this.items.value;
659
+ return items.value;
660
660
  return items.value.map(mapOptionCallback);
661
661
  });
662
662
  const hasNextPage = vue.computed(() => count.value > items.value.length);
@@ -0,0 +1,350 @@
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(object: Dictionary): Dictionary;
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 Options$2 extends Intl.NumberFormatOptions {
37
+ locale?: string;
38
+ defaultValue?: string | number;
39
+ }
40
+ declare function formatMoney(value: string | number | null | undefined, currency?: string, options?: Options$2): string | number;
41
+
42
+ declare function genHash(hashLength: number): string;
43
+
44
+ declare function genRandomNumber(min: number, max: number): number;
45
+
46
+ declare function genUUID(): string;
47
+
48
+ interface Options$1 {
49
+ hasOnlyLast4: boolean;
50
+ isHidden: boolean;
51
+ dot: string;
52
+ }
53
+ declare function getCardNumber(number: string, options?: Partial<Options$1>): string;
54
+
55
+ declare function getCountryFromPhone(phone: string): string;
56
+
57
+ declare function isElementIgnored({ ignoredClasses, event, }?: {
58
+ ignoredClasses?: string[];
59
+ event?: Event;
60
+ }): boolean;
61
+
62
+ declare function isEmptyObject(object: object): boolean;
63
+
64
+ interface MapOptions {
65
+ labelKey?: string;
66
+ valueKey?: string;
67
+ excludedItems?: any[];
68
+ }
69
+ declare function mapDataObjectForFilters<T extends Record<string, any>>(data: T, options?: MapOptions): {
70
+ label: string;
71
+ value: any;
72
+ }[];
73
+
74
+ declare function getPaginationParams({ page, limit, }: {
75
+ page: string | number;
76
+ limit: string | number;
77
+ }): {
78
+ limit: number;
79
+ offset: number;
80
+ };
81
+ declare function getPaginationLimit({ limit }: {
82
+ limit: string | number;
83
+ }): number;
84
+ declare function getPaginationOffset({ page, limit, }: {
85
+ page: string | number;
86
+ limit: string | number;
87
+ }): number;
88
+ declare function getPaginationPages({ count, limit, }: {
89
+ count: number;
90
+ limit: string | number;
91
+ }): number;
92
+
93
+ declare function parsePhone(phone: string | null | undefined): string;
94
+
95
+ type SnakelizeKeysProp = Record<string | number, any>;
96
+ declare function snakelizeKeys(prop: SnakelizeKeysProp): SnakelizeKeysProp;
97
+
98
+ /**
99
+ * Принимает на вход число в виде строки или числа,
100
+ * возвращает корректное значение типа Number (убирает лишние пробелы и запятые)
101
+ * @example
102
+ * // returns 1000
103
+ * unformatNumber('1 000');
104
+ * @example
105
+ * // returns 1000
106
+ * unformatNumber('1,000')
107
+ * @example
108
+ * // returns 1000.123
109
+ * unformatNummber('1 000,123')
110
+ * @example
111
+ * // returns 1000.123
112
+ * unformatNummber('1,000.123')
113
+ * @param value
114
+ * @return number
115
+ */
116
+ declare function unformatNumber(value: string | number): string | number;
117
+
118
+ declare function validateNumber(value: string | number, defaultValue: number): number;
119
+
120
+ interface UiComponentsResolverOptions {
121
+ prefix?: string;
122
+ }
123
+ declare function UiComponentsResolver(options?: UiComponentsResolverOptions): any;
124
+
125
+ declare function useAbortController<T extends (...args: any[]) => any>(callback: T): {
126
+ call(...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
127
+ abort(): void;
128
+ isAborted(error: ResponseError): boolean;
129
+ };
130
+
131
+ declare function useAsyncItems<T extends (...args: any[]) => any>({ apiMethod, queryKey, params, config, }: {
132
+ apiMethod: T;
133
+ queryKey: string;
134
+ params: MaybeRef<Parameters<T>[0]>;
135
+ config?: AxiosRequestConfig;
136
+ }): {
137
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
138
+ isFetching: vue.Ref<boolean>;
139
+ isError: vue.Ref<true> | vue.Ref<false>;
140
+ data: vue.Ref<any>;
141
+ error: vue.Ref<Error>;
142
+ items: vue.ComputedRef<Awaited<ReturnType<T>>["results"]>;
143
+ count: vue.Ref<number>;
144
+ refetch: () => void;
145
+ reload: () => void;
146
+ abort: () => void;
147
+ };
148
+
149
+ interface ReactiveData$1 {
150
+ search: string;
151
+ page: number;
152
+ selectedValues?: any[];
153
+ params?: any;
154
+ }
155
+ declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValues, params, queryKey, dataItemsKey, dataItemIdKey, dataCountKey, delay, onUpdated, }: {
156
+ apiMethod: T;
157
+ mapOptionCallback?: K;
158
+ selectedValues?: MaybeRef$1<Parameters<T>[0]['includedIds']>;
159
+ params?: MaybeRef$1<Partial<Parameters<T>[0]>>;
160
+ queryKey: string;
161
+ dataItemsKey?: string;
162
+ dataItemIdKey?: string;
163
+ dataCountKey?: string;
164
+ delay?: number;
165
+ onUpdated?: (data: ReactiveData$1) => void;
166
+ }): {
167
+ items: vue.ComputedRef<any[]>;
168
+ options: vue.ComputedRef<ReturnType<K>[]>;
169
+ search: vue.Ref<string>;
170
+ hasNextPage: vue.ComputedRef<boolean>;
171
+ isFetching: vue.Ref<boolean>;
172
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
173
+ loadPage: (newPage?: number) => void;
174
+ updateSearch: (value: string) => void;
175
+ };
176
+
177
+ interface ReactiveData {
178
+ search: string;
179
+ page: number;
180
+ selectedValue?: any[];
181
+ params?: any;
182
+ }
183
+ declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValue, params, queryKey, dataItemsKey, dataCountKey, delay, onUpdated, }: {
184
+ apiMethod: T;
185
+ mapOptionCallback?: K;
186
+ selectedValue?: MaybeRef$1<Parameters<T>[0]['includedIds']>;
187
+ params?: MaybeRef$1<Partial<Parameters<T>[0]>>;
188
+ queryKey: string;
189
+ dataItemsKey?: string;
190
+ dataCountKey?: string;
191
+ delay?: number;
192
+ onUpdated?: (data: ReactiveData) => void;
193
+ }): {
194
+ items: vue.ComputedRef<any[]>;
195
+ options: vue.ComputedRef<ReturnType<K>[]>;
196
+ search: vue.Ref<string>;
197
+ hasNextPage: vue.ComputedRef<boolean>;
198
+ isFetching: vue.Ref<boolean>;
199
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
200
+ loadPage: (newPage?: number) => void;
201
+ updateSearch: (value: string) => void;
202
+ };
203
+
204
+ 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>;
213
+ };
214
+
215
+ declare function useClassName(block: string): {
216
+ b: (blockSuffix?: string) => string;
217
+ e: (element?: string) => string;
218
+ m: (modifier?: string, condition?: boolean) => string;
219
+ em: (element?: string, modifier?: string, condition?: boolean) => string;
220
+ mv: (modifier: string, modifierValue: string, condition?: boolean) => string;
221
+ cssVar: (object: Record<string, string | number>) => Record<string, string | number>;
222
+ cssVarName: (name: string) => string;
223
+ };
224
+
225
+ /**
226
+ * Обертка над dayjs, позволяющая задавать timezone
227
+ * @see https://day.js.org/en/
228
+ *
229
+ * Использовать параметр timezone нужно крайне аккуратно,
230
+ * может привести к утечкам памяти
231
+ * @todo Подумать как сделать оптимальнее
232
+ */
233
+ declare function useDayjs(timezone?: string): (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean) => dayjs.Dayjs;
234
+
235
+ interface BrowserInfo {
236
+ isDeprecated?: boolean;
237
+ name?: string;
238
+ version?: string;
239
+ os?: string;
240
+ type?: string;
241
+ options?: any;
242
+ }
243
+ type VersionsList = {
244
+ [key in Browser]?: string | boolean;
245
+ };
246
+ declare function useDetectBrowser(versions: VersionsList, userAgent?: any): BrowserInfo;
247
+
248
+ interface VNodeCustom$1 extends VNode {
249
+ close(): void;
250
+ }
251
+ declare function useDialog(): {
252
+ open: ({ layer, component, props, }: {
253
+ component: Component;
254
+ props?: any;
255
+ layer?: number;
256
+ }) => string;
257
+ getInstance: (uuid: string) => VNodeCustom$1;
258
+ close: (uuid: string) => void;
259
+ closeAll: () => void;
260
+ showConfirm: (text?: string) => boolean;
261
+ isOnTop: (uuid: string) => boolean;
262
+ openByHash: ({ layer, component, props, }: {
263
+ component: Component;
264
+ props?: any;
265
+ layer?: number;
266
+ }) => void;
267
+ watchHash: ({ component, events, }: {
268
+ component: Component;
269
+ events?: EmitsOptions;
270
+ }) => any;
271
+ };
272
+
273
+ declare function useGlobalScroll(): {
274
+ isLocked: vue.Ref<boolean>;
275
+ lock: () => void;
276
+ unlock: () => void;
277
+ };
278
+
279
+ declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters, }: {
280
+ config: T;
281
+ initialFilters: K;
282
+ }): {
283
+ isOpen: Ref<boolean>;
284
+ filtersModel: Ref<K>;
285
+ filtersFromQuery: vue.ComputedRef<{}>;
286
+ filtersCount: vue.ComputedRef<number>;
287
+ updateOne: (key: keyof K, value: any) => void;
288
+ updateMany: (filters: Record<string, any>) => void;
289
+ open: () => void;
290
+ clear: () => void;
291
+ setQueryFromFilters: (filters: Record<string, any>) => void;
292
+ getValidatedParams: (query: Record<string, any>) => {
293
+ filters: any;
294
+ };
295
+ };
296
+
297
+ /**
298
+ * @see https://github.com/caiogondim/logdown.js#readme
299
+ */
300
+
301
+ interface Options {
302
+ tag?: string;
303
+ color?: string;
304
+ debug?: boolean;
305
+ }
306
+ declare function useLogger(scope: string, options?: Options): logdown.Logger;
307
+
308
+ interface VNodeCustom extends VNode {
309
+ close(): void;
310
+ }
311
+ /**
312
+ * @deprecated use useDialog
313
+ */
314
+ declare function usePanel(): {
315
+ open: ({ layer, component, props, }: {
316
+ component: Component;
317
+ props?: any;
318
+ layer?: number;
319
+ }) => string;
320
+ getInstance: (uuid: string) => VNodeCustom;
321
+ close: (uuid: string) => void;
322
+ closeAll: () => void;
323
+ openByHash: ({ layer, component, props, }: {
324
+ component: Component;
325
+ props?: any;
326
+ layer?: number;
327
+ }) => void;
328
+ watchHash: ({ component, events, }: {
329
+ component: Component;
330
+ events?: EmitsOptions;
331
+ }) => any;
332
+ };
333
+
334
+ declare function validatePhone(rule: string, value: string): boolean;
335
+
336
+ declare function isRequired(value?: boolean, message?: string): RuleItem;
337
+ declare function isMax(value?: number, message?: string): {
338
+ max: number;
339
+ message: string;
340
+ };
341
+ declare function isMin(value?: number, message?: string): {
342
+ min: number;
343
+ message: string;
344
+ };
345
+ declare function isTypeEmail(message?: string): RuleItem;
346
+ declare function isTypeUrl(message?: string): RuleItem;
347
+ declare function isTypeNumber(value?: number, message?: string): RuleItem;
348
+ declare function isStrictLength(value?: number, message?: string): RuleItem;
349
+
350
+ export { AppComponentsResolver, type BrowserInfo, type Dictionary, type ResponseError, UiComponentsResolver, type 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 };
@@ -0,0 +1,350 @@
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(object: Dictionary): Dictionary;
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 Options$2 extends Intl.NumberFormatOptions {
37
+ locale?: string;
38
+ defaultValue?: string | number;
39
+ }
40
+ declare function formatMoney(value: string | number | null | undefined, currency?: string, options?: Options$2): string | number;
41
+
42
+ declare function genHash(hashLength: number): string;
43
+
44
+ declare function genRandomNumber(min: number, max: number): number;
45
+
46
+ declare function genUUID(): string;
47
+
48
+ interface Options$1 {
49
+ hasOnlyLast4: boolean;
50
+ isHidden: boolean;
51
+ dot: string;
52
+ }
53
+ declare function getCardNumber(number: string, options?: Partial<Options$1>): string;
54
+
55
+ declare function getCountryFromPhone(phone: string): string;
56
+
57
+ declare function isElementIgnored({ ignoredClasses, event, }?: {
58
+ ignoredClasses?: string[];
59
+ event?: Event;
60
+ }): boolean;
61
+
62
+ declare function isEmptyObject(object: object): boolean;
63
+
64
+ interface MapOptions {
65
+ labelKey?: string;
66
+ valueKey?: string;
67
+ excludedItems?: any[];
68
+ }
69
+ declare function mapDataObjectForFilters<T extends Record<string, any>>(data: T, options?: MapOptions): {
70
+ label: string;
71
+ value: any;
72
+ }[];
73
+
74
+ declare function getPaginationParams({ page, limit, }: {
75
+ page: string | number;
76
+ limit: string | number;
77
+ }): {
78
+ limit: number;
79
+ offset: number;
80
+ };
81
+ declare function getPaginationLimit({ limit }: {
82
+ limit: string | number;
83
+ }): number;
84
+ declare function getPaginationOffset({ page, limit, }: {
85
+ page: string | number;
86
+ limit: string | number;
87
+ }): number;
88
+ declare function getPaginationPages({ count, limit, }: {
89
+ count: number;
90
+ limit: string | number;
91
+ }): number;
92
+
93
+ declare function parsePhone(phone: string | null | undefined): string;
94
+
95
+ type SnakelizeKeysProp = Record<string | number, any>;
96
+ declare function snakelizeKeys(prop: SnakelizeKeysProp): SnakelizeKeysProp;
97
+
98
+ /**
99
+ * Принимает на вход число в виде строки или числа,
100
+ * возвращает корректное значение типа Number (убирает лишние пробелы и запятые)
101
+ * @example
102
+ * // returns 1000
103
+ * unformatNumber('1 000');
104
+ * @example
105
+ * // returns 1000
106
+ * unformatNumber('1,000')
107
+ * @example
108
+ * // returns 1000.123
109
+ * unformatNummber('1 000,123')
110
+ * @example
111
+ * // returns 1000.123
112
+ * unformatNummber('1,000.123')
113
+ * @param value
114
+ * @return number
115
+ */
116
+ declare function unformatNumber(value: string | number): string | number;
117
+
118
+ declare function validateNumber(value: string | number, defaultValue: number): number;
119
+
120
+ interface UiComponentsResolverOptions {
121
+ prefix?: string;
122
+ }
123
+ declare function UiComponentsResolver(options?: UiComponentsResolverOptions): any;
124
+
125
+ declare function useAbortController<T extends (...args: any[]) => any>(callback: T): {
126
+ call(...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
127
+ abort(): void;
128
+ isAborted(error: ResponseError): boolean;
129
+ };
130
+
131
+ declare function useAsyncItems<T extends (...args: any[]) => any>({ apiMethod, queryKey, params, config, }: {
132
+ apiMethod: T;
133
+ queryKey: string;
134
+ params: MaybeRef<Parameters<T>[0]>;
135
+ config?: AxiosRequestConfig;
136
+ }): {
137
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
138
+ isFetching: vue.Ref<boolean>;
139
+ isError: vue.Ref<true> | vue.Ref<false>;
140
+ data: vue.Ref<any>;
141
+ error: vue.Ref<Error>;
142
+ items: vue.ComputedRef<Awaited<ReturnType<T>>["results"]>;
143
+ count: vue.Ref<number>;
144
+ refetch: () => void;
145
+ reload: () => void;
146
+ abort: () => void;
147
+ };
148
+
149
+ interface ReactiveData$1 {
150
+ search: string;
151
+ page: number;
152
+ selectedValues?: any[];
153
+ params?: any;
154
+ }
155
+ declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValues, params, queryKey, dataItemsKey, dataItemIdKey, dataCountKey, delay, onUpdated, }: {
156
+ apiMethod: T;
157
+ mapOptionCallback?: K;
158
+ selectedValues?: MaybeRef$1<Parameters<T>[0]['includedIds']>;
159
+ params?: MaybeRef$1<Partial<Parameters<T>[0]>>;
160
+ queryKey: string;
161
+ dataItemsKey?: string;
162
+ dataItemIdKey?: string;
163
+ dataCountKey?: string;
164
+ delay?: number;
165
+ onUpdated?: (data: ReactiveData$1) => void;
166
+ }): {
167
+ items: vue.ComputedRef<any[]>;
168
+ options: vue.ComputedRef<ReturnType<K>[]>;
169
+ search: vue.Ref<string>;
170
+ hasNextPage: vue.ComputedRef<boolean>;
171
+ isFetching: vue.Ref<boolean>;
172
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
173
+ loadPage: (newPage?: number) => void;
174
+ updateSearch: (value: string) => void;
175
+ };
176
+
177
+ interface ReactiveData {
178
+ search: string;
179
+ page: number;
180
+ selectedValue?: any[];
181
+ params?: any;
182
+ }
183
+ declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (params: any) => any>({ apiMethod, mapOptionCallback, selectedValue, params, queryKey, dataItemsKey, dataCountKey, delay, onUpdated, }: {
184
+ apiMethod: T;
185
+ mapOptionCallback?: K;
186
+ selectedValue?: MaybeRef$1<Parameters<T>[0]['includedIds']>;
187
+ params?: MaybeRef$1<Partial<Parameters<T>[0]>>;
188
+ queryKey: string;
189
+ dataItemsKey?: string;
190
+ dataCountKey?: string;
191
+ delay?: number;
192
+ onUpdated?: (data: ReactiveData) => void;
193
+ }): {
194
+ items: vue.ComputedRef<any[]>;
195
+ options: vue.ComputedRef<ReturnType<K>[]>;
196
+ search: vue.Ref<string>;
197
+ hasNextPage: vue.ComputedRef<boolean>;
198
+ isFetching: vue.Ref<boolean>;
199
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
200
+ loadPage: (newPage?: number) => void;
201
+ updateSearch: (value: string) => void;
202
+ };
203
+
204
+ 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>;
213
+ };
214
+
215
+ declare function useClassName(block: string): {
216
+ b: (blockSuffix?: string) => string;
217
+ e: (element?: string) => string;
218
+ m: (modifier?: string, condition?: boolean) => string;
219
+ em: (element?: string, modifier?: string, condition?: boolean) => string;
220
+ mv: (modifier: string, modifierValue: string, condition?: boolean) => string;
221
+ cssVar: (object: Record<string, string | number>) => Record<string, string | number>;
222
+ cssVarName: (name: string) => string;
223
+ };
224
+
225
+ /**
226
+ * Обертка над dayjs, позволяющая задавать timezone
227
+ * @see https://day.js.org/en/
228
+ *
229
+ * Использовать параметр timezone нужно крайне аккуратно,
230
+ * может привести к утечкам памяти
231
+ * @todo Подумать как сделать оптимальнее
232
+ */
233
+ declare function useDayjs(timezone?: string): (date?: dayjs.ConfigType, format?: dayjs.OptionType, locale?: string, strict?: boolean) => dayjs.Dayjs;
234
+
235
+ interface BrowserInfo {
236
+ isDeprecated?: boolean;
237
+ name?: string;
238
+ version?: string;
239
+ os?: string;
240
+ type?: string;
241
+ options?: any;
242
+ }
243
+ type VersionsList = {
244
+ [key in Browser]?: string | boolean;
245
+ };
246
+ declare function useDetectBrowser(versions: VersionsList, userAgent?: any): BrowserInfo;
247
+
248
+ interface VNodeCustom$1 extends VNode {
249
+ close(): void;
250
+ }
251
+ declare function useDialog(): {
252
+ open: ({ layer, component, props, }: {
253
+ component: Component;
254
+ props?: any;
255
+ layer?: number;
256
+ }) => string;
257
+ getInstance: (uuid: string) => VNodeCustom$1;
258
+ close: (uuid: string) => void;
259
+ closeAll: () => void;
260
+ showConfirm: (text?: string) => boolean;
261
+ isOnTop: (uuid: string) => boolean;
262
+ openByHash: ({ layer, component, props, }: {
263
+ component: Component;
264
+ props?: any;
265
+ layer?: number;
266
+ }) => void;
267
+ watchHash: ({ component, events, }: {
268
+ component: Component;
269
+ events?: EmitsOptions;
270
+ }) => any;
271
+ };
272
+
273
+ declare function useGlobalScroll(): {
274
+ isLocked: vue.Ref<boolean>;
275
+ lock: () => void;
276
+ unlock: () => void;
277
+ };
278
+
279
+ declare function useFilters<T extends Record<string, any>, K extends Record<string, any>>({ config, initialFilters, }: {
280
+ config: T;
281
+ initialFilters: K;
282
+ }): {
283
+ isOpen: Ref<boolean>;
284
+ filtersModel: Ref<K>;
285
+ filtersFromQuery: vue.ComputedRef<{}>;
286
+ filtersCount: vue.ComputedRef<number>;
287
+ updateOne: (key: keyof K, value: any) => void;
288
+ updateMany: (filters: Record<string, any>) => void;
289
+ open: () => void;
290
+ clear: () => void;
291
+ setQueryFromFilters: (filters: Record<string, any>) => void;
292
+ getValidatedParams: (query: Record<string, any>) => {
293
+ filters: any;
294
+ };
295
+ };
296
+
297
+ /**
298
+ * @see https://github.com/caiogondim/logdown.js#readme
299
+ */
300
+
301
+ interface Options {
302
+ tag?: string;
303
+ color?: string;
304
+ debug?: boolean;
305
+ }
306
+ declare function useLogger(scope: string, options?: Options): logdown.Logger;
307
+
308
+ interface VNodeCustom extends VNode {
309
+ close(): void;
310
+ }
311
+ /**
312
+ * @deprecated use useDialog
313
+ */
314
+ declare function usePanel(): {
315
+ open: ({ layer, component, props, }: {
316
+ component: Component;
317
+ props?: any;
318
+ layer?: number;
319
+ }) => string;
320
+ getInstance: (uuid: string) => VNodeCustom;
321
+ close: (uuid: string) => void;
322
+ closeAll: () => void;
323
+ openByHash: ({ layer, component, props, }: {
324
+ component: Component;
325
+ props?: any;
326
+ layer?: number;
327
+ }) => void;
328
+ watchHash: ({ component, events, }: {
329
+ component: Component;
330
+ events?: EmitsOptions;
331
+ }) => any;
332
+ };
333
+
334
+ declare function validatePhone(rule: string, value: string): boolean;
335
+
336
+ declare function isRequired(value?: boolean, message?: string): RuleItem;
337
+ declare function isMax(value?: number, message?: string): {
338
+ max: number;
339
+ message: string;
340
+ };
341
+ declare function isMin(value?: number, message?: string): {
342
+ min: number;
343
+ message: string;
344
+ };
345
+ declare function isTypeEmail(message?: string): RuleItem;
346
+ declare function isTypeUrl(message?: string): RuleItem;
347
+ declare function isTypeNumber(value?: number, message?: string): RuleItem;
348
+ declare function isStrictLength(value?: number, message?: string): RuleItem;
349
+
350
+ export { AppComponentsResolver, type BrowserInfo, type Dictionary, type ResponseError, UiComponentsResolver, type 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.d.ts CHANGED
@@ -134,11 +134,11 @@ declare function useAsyncItems<T extends (...args: any[]) => any>({ apiMethod, q
134
134
  params: MaybeRef<Parameters<T>[0]>;
135
135
  config?: AxiosRequestConfig;
136
136
  }): {
137
- isLoading: vue.Ref<false> | vue.Ref<true>;
137
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
138
138
  isFetching: vue.Ref<boolean>;
139
- isError: vue.Ref<false> | vue.Ref<true>;
139
+ isError: vue.Ref<true> | vue.Ref<false>;
140
140
  data: vue.Ref<any>;
141
- error: vue.Ref<unknown>;
141
+ error: vue.Ref<Error>;
142
142
  items: vue.ComputedRef<Awaited<ReturnType<T>>["results"]>;
143
143
  count: vue.Ref<number>;
144
144
  refetch: () => void;
@@ -169,7 +169,7 @@ declare function useAsyncMultiselect<T extends (...args: any[]) => any, K extend
169
169
  search: vue.Ref<string>;
170
170
  hasNextPage: vue.ComputedRef<boolean>;
171
171
  isFetching: vue.Ref<boolean>;
172
- isLoading: vue.Ref<false> | vue.Ref<true>;
172
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
173
173
  loadPage: (newPage?: number) => void;
174
174
  updateSearch: (value: string) => void;
175
175
  };
@@ -196,7 +196,7 @@ declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (pa
196
196
  search: vue.Ref<string>;
197
197
  hasNextPage: vue.ComputedRef<boolean>;
198
198
  isFetching: vue.Ref<boolean>;
199
- isLoading: vue.Ref<false> | vue.Ref<true>;
199
+ isLoading: vue.Ref<boolean> | vue.Ref<true> | vue.Ref<false>;
200
200
  loadPage: (newPage?: number) => void;
201
201
  updateSearch: (value: string) => void;
202
202
  };
@@ -347,4 +347,4 @@ declare function isTypeUrl(message?: string): RuleItem;
347
347
  declare function isTypeNumber(value?: number, message?: string): RuleItem;
348
348
  declare function isStrictLength(value?: number, message?: string): RuleItem;
349
349
 
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 };
350
+ export { AppComponentsResolver, type BrowserInfo, type Dictionary, type ResponseError, UiComponentsResolver, type 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
@@ -488,7 +488,7 @@ function useAsyncMultiselect({
488
488
  if (!items.value.length)
489
489
  return [];
490
490
  if (!mapOptionCallback)
491
- return this.items.value;
491
+ return items.value;
492
492
  return items.value.map(mapOptionCallback);
493
493
  });
494
494
  const hasNextPage = computed(() => count.value > items.value.length);
@@ -638,7 +638,7 @@ function useAsyncSelect({
638
638
  if (!items.value.length)
639
639
  return [];
640
640
  if (!mapOptionCallback)
641
- return this.items.value;
641
+ return items.value;
642
642
  return items.value.map(mapOptionCallback);
643
643
  });
644
644
  const hasNextPage = computed(() => count.value > items.value.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karta.io/utils",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.10",
4
4
  "description": "karta.io utils for admin and application",
5
5
  "author": "Vitaly Blokhin <karambafe@gmail.com>",
6
6
  "homepage": "",
@@ -10,7 +10,8 @@
10
10
  "exports": {
11
11
  ".": {
12
12
  "require": "./dist/index.cjs",
13
- "import": "./dist/index.mjs"
13
+ "import": "./dist/index.mjs",
14
+ "types": "./dist/index.d.ts"
14
15
  },
15
16
  "./*": "./*"
16
17
  },
@@ -21,35 +22,35 @@
21
22
  "dist"
22
23
  ],
23
24
  "peerDependencies": {
24
- "vue": "3.3.x"
25
+ "vue": "3.x"
25
26
  },
26
27
  "dependencies": {
27
- "@karta.io/common-data": "^1.0.0-beta.1",
28
- "@tanstack/vue-query": "4.33.1",
29
- "@vueuse/core": "10.7.0",
28
+ "@karta.io/common-data": "^1.0.0-beta.10",
29
+ "@tanstack/vue-query": "5.x",
30
+ "@vueuse/core": "10.7.2",
30
31
  "async-validator": "4.2.5",
31
- "axios": "1.4.0",
32
- "dayjs": "1.11.8",
32
+ "axios": "1.6.7",
33
+ "dayjs": "1.11.10",
33
34
  "detect-browser": "5.3.0",
34
- "libphonenumber-js": "1.10.36",
35
+ "libphonenumber-js": "1.10.55",
35
36
  "lodash": "4.17.21",
36
37
  "logdown": "3.3.1",
37
38
  "qs": "6.11.2",
38
- "vue-router": "4.x.x"
39
+ "vue-router": "4.x"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@qvant/prettier-config": "0.1.0",
42
- "@types/lodash": "4.14.195",
43
- "@typescript-eslint/eslint-plugin": "5.60.1",
44
- "@typescript-eslint/parser": "5.60.1",
45
- "eslint": "8.43.0",
43
+ "@types/lodash": "4.14.202",
44
+ "@typescript-eslint/eslint-plugin": "6.20.0",
45
+ "@typescript-eslint/parser": "6.20.0",
46
+ "eslint": "8.56.0",
46
47
  "eslint-config-airbnb-base": "15.0.0",
47
- "eslint-plugin-import": "2.27.5",
48
- "prettier": "3.0.1",
49
- "typescript": "5.1.6",
50
- "unbuild": "1.2.1",
51
- "vitest": "0.32.2",
52
- "vue": "3.3.4"
48
+ "eslint-plugin-import": "2.29.1",
49
+ "prettier": "3.2.5",
50
+ "typescript": "5.3.3",
51
+ "unbuild": "2.0.0",
52
+ "vitest": "1.2.2",
53
+ "vue": "3.4.15"
53
54
  },
54
55
  "scripts": {
55
56
  "dev": "vitest",